1
/**2
* Named wire types for the DeepSeek Harness SDK runtime protocol: the three3
* request/result pairs and the four server-to-client notification payloads4
* exchanged over the newline-delimited JSON-RPC stdio transport. The server5
* plugin (`@deepseek-ai/dsh-sdk-jsonrpc-server`) and SDK clients share these shapes;6
* `serverInfo.name` stays the wire-stable `deepseek-harness-sdk-runtime`.7
*8
* @module @deepseek-ai/dsh-sdk-protocol/types9
*/11
import type { ContentBlock, ReasoningEffortId } from '@deepseek-ai/dsh-llm'12
import type { SessionEvent } from '@deepseek-ai/dsh-session'13
import type { SubagentStopReason } from '@deepseek-ai/dsh-subagent'15
/** Parameters for the process-wide SDK handshake. */16
export interface InitializeParams {17
/** Working directory recorded on every SDK-created session's header. */18
cwd: string19
/** Provider route every SDK-created agent runs on. */20
provider: string21
/** Model name every SDK-created agent runs on (the server may mount a fallback adapter; see `HarnessSdkJsonRpcServer.initialize`). */22
model: string23
/** Optional adapter-owned reasoning effort for the selected provider/model route. */24
reasoningEffort?: ReasoningEffortId25
/** Optional positive output-token cap inherited by SDK-created agents and their in-process descendants. */26
maxTokens?: number27
}29
/** Wire-stable server identity returned by initialization. */30
export interface InitializeResult {31
/** Wire-stable server identity (`deepseek-harness-sdk-runtime`) and version. */32
serverInfo: { name: string; version: string }33
}35
/** One user turn on one SDK session. */36
export interface SessionPromptParams {37
/** The SDK-side session id; an unknown id lazily creates the agent+session pair. */38
sessionId: string39
/** The prompt content blocks, sent verbatim as the user message. */40
contentBlocks: SdkPromptContentBlock[]41
}43
/** Inline raster input admitted into the runtime's durable attachment store. */44
export interface SdkEncodedImageBlock {45
type: 'image'46
/** Canonical base64-encoded raster bytes. */47
data: string48
/** Declared raster MIME type, verified during admission. */49
mimeType: 'image/png' | 'image/jpeg' | 'image/webp' | 'image/gif'50
}52
/** SDK prompt input: ordinary durable blocks plus inline images awaiting admission. */53
export type SdkPromptContentBlock = ContentBlock | SdkEncodedImageBlock55
/** Durable enqueue receipt for one prompt. */56
export interface SessionPromptResult {57
/** Identity of the queued user message. */58
messageId: string59
}61
/** Deployment-mapped SDK outcome: `ok` for an accepted result, `error` otherwise. */62
export type SdkRunStatus = 'ok' | 'error'64
/** `session.event` payload: one session-log event, streamed as it is recorded. */65
export interface SessionEventNotification {66
/** Session the event belongs to (every session in the runtime, not only SDK-created ones). */67
sessionId: string68
/** The full session-log event envelope. */69
event: SessionEvent70
}72
/** Whole-agent lifecycle state for one session. */73
export interface SessionStatusNotification {74
/** Session whose live agent changed status. */75
sessionId: string76
/** The whole-agent state after the transition. */77
status: 'idle' | 'running'78
}80
/** `subagent.started` payload: an in-runtime child session was created. */81
export interface SubagentStartedNotification {82
/** The delegating session. */83
parentSessionId: string84
/** The new child session. */85
childSessionId: string86
}88
/** `subagent.finished` payload: an in-process subagent run ended (remote runs are not reported). */89
export interface SubagentFinishedNotification {90
/** Subagent provider name that ran the child. */91
provider: string92
/** The child agent's id (equals {@link childSessionId} for local runs). */93
agentId: string94
/** The delegating session. */95
parentSessionId: string96
/** The child session. */97
childSessionId: string98
/** Deployment-mapped run outcome. */99
status: SdkRunStatus100
/** The provider-reported stop reason. */101
stopReason: SubagentStopReason102
/** The child's selected assistant output; absent when the child produced none. */103
lastAssistantMessage?: ContentBlock[]104
}106
/** Server-to-client notifications by JSON-RPC method name. */107
export interface HarnessSdkNotificationMap {108
'session.event': SessionEventNotification109
'session.status': SessionStatusNotification110
'subagent.started': SubagentStartedNotification111
'subagent.finished': SubagentFinishedNotification112
}114
/** Client-to-server request methods with their param and result shapes. */115
export interface HarnessSdkRequestMap {116
'initialize': { params: InitializeParams; result: InitializeResult }117
'session/prompt': { params: SessionPromptParams; result: SessionPromptResult }118
'shutdown': { params: undefined; result: Record<string, never> }119
}