1
/** Public Agent Teams identities, durable records, and service request values. */3
import type { Branded } from '@deepseek-ai/dsh-brand'4
import type { ContentBlock } from '@deepseek-ai/dsh-llm/types'5
import type { SessionId } from '@deepseek-ai/dsh-session/types'7
/** Identifies the implicit team rooted at one top-level Session. */8
export type TeamId = Branded<'TeamId'>10
/**11
* Brand one root Session identity as its implicit Team identity.12
* @param id - Root Session identity.13
* @returns the same string branded as a Team identity.14
*/15
export function TeamId(id: SessionId | string): TeamId {16
return id as TeamId17
}19
/** Stable identifier for one task in a Team. */20
export type TeamTaskId = Branded<'TeamTaskId'>22
/**23
* Brand a validated task id.24
* @param id - Team-local task identity.25
* @returns the same string branded as a Team task identity.26
*/27
export function TeamTaskId(id: string): TeamTaskId {28
return id as TeamTaskId29
}31
/** Stable identifier for one durable peer message. */32
export type TeamMessageId = Branded<'TeamMessageId'>34
/**35
* Brand a generated peer-message id.36
* @param id - Durable mailbox message identity.37
* @returns the same string branded as a Team message identity.38
*/39
export function TeamMessageId(id: string): TeamMessageId {40
return id as TeamMessageId41
}43
/** Durable teammate lifecycle. */44
export type TeamMemberPhase = 'provisioning' | 'active' | 'failed'46
/** Whole durable value written on every teammate lifecycle change. */47
export interface TeamMemberSnapshot {48
readonly id: SessionId49
readonly name: string50
readonly description: string51
readonly provider: string52
readonly context: 'fresh' | 'fork'53
readonly phase: TeamMemberPhase54
readonly error?: string55
}57
/** Current runtime-enriched roster row. */58
export interface TeamMemberView {59
readonly id: SessionId60
readonly name: string61
readonly role: 'lead' | 'teammate'62
readonly status: 'running' | 'inactive' | 'provisioning' | 'failed'63
readonly description?: string64
readonly provider?: string65
readonly context?: 'fresh' | 'fork'66
readonly model?: string67
readonly diagnostics: string[]68
}70
/** Durable task lifecycle. */71
export type TeamTaskStatus = 'pending' | 'in_progress' | 'completed' | 'deleted'73
/** Whole durable task snapshot; every mutation increments {@link revision}. */74
export interface TeamTaskSnapshot {75
readonly id: TeamTaskId76
readonly revision: number77
readonly subject: string78
readonly description: string79
readonly status: TeamTaskStatus80
readonly ownerId?: SessionId81
readonly blockedBy: TeamTaskId[]82
readonly writeScopes: string[]83
}85
/** Runtime-enriched task view returned to tools and hosts. */86
export interface TeamTaskView {87
readonly id: TeamTaskId88
readonly revision: number89
readonly subject: string90
readonly description: string91
readonly status: TeamTaskStatus92
readonly blockedBy: TeamTaskId[]93
readonly writeScopes: string[]94
readonly ownerName?: string95
readonly ready: boolean96
readonly writeScopeWarnings: string[]97
}99
/** One durable roster row published through the `agentTeam` Session projection. */100
export interface TeamMemberProjection {101
readonly id: SessionId102
readonly name: string103
readonly role: 'lead' | 'teammate'104
/** Durable lifecycle; the Lead row is always `active`. Turn activity comes from Session status. */105
readonly phase: TeamMemberPhase106
readonly error?: string107
}109
/**110
* Durable Team state published to browser clients through the Lead Session's111
* `agentTeam` projection. `failure` names the first rejected persisted Team112
* record; members and tasks then stay at the last valid state.113
*/114
export interface TeamProjection {115
readonly members: TeamMemberProjection[]116
readonly tasks: TeamTaskView[]117
readonly failure?: string118
}120
declare module '@deepseek-ai/dsh-session-projection/types' {121
interface SessionProjectionMap {122
/** Durable roster and non-deleted task board of the Team rooted at the projected Session. */123
agentTeam: TeamProjection124
}125
}127
/** One peer message retained until its target Session records it. */128
export interface TeamMessageSnapshot {129
readonly id: TeamMessageId130
readonly senderId: SessionId131
readonly senderName: string132
readonly targetId: SessionId133
readonly content: ContentBlock[]134
}136
/** Source retained by the target Session for durable mailbox de-duplication. */137
export interface TeamMessageSource {138
readonly kind: 'team-message'139
readonly teamId: TeamId140
readonly messageId: TeamMessageId141
readonly senderId: SessionId142
readonly senderName: string143
}145
declare module '@deepseek-ai/dsh-llm' {146
interface MessageSourceMap {147
'team-message': TeamMessageSource148
}149
}151
/** Team-service deployment limits. */152
export interface Config {153
/** Maximum immutable teammate names retained by one Team. */154
readonly maxMembers?: number155
/** Maximum non-deleted tasks retained by one Team. */156
readonly maxTasks?: number157
/** Maximum queued-minus-delivered messages for one target member. */158
readonly maxPendingMessagesPerMember?: number159
/** Maximum UTF-8 bytes in one complete sender-framed delivery. */160
readonly maxMessageBytes?: number161
/** Maximum milliseconds allowed for Team-owned runtime disposal. */162
readonly disposalTimeoutMs?: number163
}165
/** Input for creating one durable teammate. */166
export interface SpawnTeammateRequest {167
readonly name: string168
readonly description: string169
readonly prompt: ContentBlock[]170
readonly context: 'fresh' | 'fork'171
readonly provider: string172
readonly signal: AbortSignal173
}175
/** Result after one teammate reaches a durable active or failed edge. */176
export interface SpawnTeammateResult {177
readonly member: TeamMemberView178
}180
/** Input for one durable peer message. */181
export interface SendTeamMessageRequest {182
readonly target: string183
readonly content: ContentBlock[]184
readonly signal: AbortSignal185
}187
/** Result after a peer message enters the durable mailbox. */188
export interface SendTeamMessageResult {189
readonly messageId: TeamMessageId190
readonly status: 'accepted' | 'queued'191
}193
/** Input for creating one shared task. */194
export interface CreateTeamTaskRequest {195
readonly subject: string196
readonly description: string197
readonly blockedBy?: readonly TeamTaskId[]198
readonly writeScopes?: readonly string[]199
}201
/** Supported task mutation actions. */202
export type TeamTaskAction =203
| 'claim'204
| 'release'205
| 'edit'206
| 'set_dependencies'207
| 'complete'208
| 'reopen'209
| 'reassign'210
| 'delete'212
/** Compare-and-set mutation of one shared task. */213
export interface UpdateTeamTaskRequest {214
readonly taskId: TeamTaskId215
readonly expectedRevision: number216
readonly action: TeamTaskAction217
readonly subject?: string218
readonly description?: string219
readonly blockedBy?: readonly TeamTaskId[]220
readonly writeScopes?: readonly string[]221
readonly owner?: string222
}224
/** Result of waiting for Team activity. */225
export interface TeamWaitResult {226
readonly timedOut: boolean227
}229
declare module '@deepseek-ai/dsh-session/types' {230
interface SessionEventMap {231
/** Whole teammate lifecycle value, stored only in the Team Lead Session. */232
'team/member': { version: 2; teamId: TeamId; member: TeamMemberSnapshot }233
/** Whole shared-task value, stored only in the Team Lead Session. */234
'team/task': { version: 2; teamId: TeamId; task: TeamTaskSnapshot }235
/** Durable mailbox enqueue, stored before delivery is attempted. */236
'team/message/queued': { version: 2; teamId: TeamId; message: TeamMessageSnapshot }237
/** Durable acknowledgement that the target Session recorded the message. */238
'team/message/delivered': {239
version: 2240
teamId: TeamId241
messageId: TeamMessageId242
targetId: SessionId243
}244
}245
}