@deepseek-ai/dsh-api-session-controller 0.1.7-alpha.1 → 0.1.7-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +6 -4
- package/README.zh.md +6 -4
- package/lib/client.js +101 -32
- package/lib/index.js +19 -6
- package/lib/typert.host.js +15 -79
- package/lib/typert.remote-client.js +9 -1
- package/lib/types/client/contract/session.d.ts +9 -4
- package/lib/types/client/contract/snapshot.d.ts +1 -1
- package/lib/types/client/sessions/assistant-stream.d.ts +5 -0
- package/lib/types/client/sessions/assistant-stream.js +16 -1
- package/lib/types/client/sessions/projection-store.d.ts +6 -0
- package/lib/types/client/sessions/projection-store.js +9 -0
- package/lib/types/client/sessions/session.d.ts +7 -5
- package/lib/types/client/sessions/session.js +81 -40
- package/lib/types/client/transport.js +5 -2
- package/lib/types/history.js +24 -9
- package/lib/types/types.d.ts +8 -2
- package/package.json +71 -71
package/lib/typert.host.js
CHANGED
|
@@ -181,8 +181,12 @@ const _deepseek_ai_dsh_api_session_controller_session_follow_parameter_0$schema
|
|
|
181
181
|
'childSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
182
182
|
'mode': z.union([z.literal("one-shot"), z.literal("continuable"), z.literal("unknown")]).readonly(),
|
|
183
183
|
})]).readonly(),
|
|
184
|
-
'maxMessages': z.number().readonly().optional(),
|
|
185
184
|
'assistantStream': z.literal(true).readonly().optional(),
|
|
185
|
+
'maxMessages': z.number().readonly().optional(),
|
|
186
|
+
'turnWindow': z.object({
|
|
187
|
+
'minMessages': z.number().readonly(),
|
|
188
|
+
'minTurns': z.number().readonly(),
|
|
189
|
+
}).readonly().optional(),
|
|
186
190
|
}))
|
|
187
191
|
let _deepseek_ai_dsh_api_session_controller_session_follow_result$schema$value
|
|
188
192
|
const _deepseek_ai_dsh_api_session_controller_session_follow_result$schema = () => (_deepseek_ai_dsh_api_session_controller_session_follow_result$schema$value ??= z.union([z.object({
|
|
@@ -534,6 +538,10 @@ const _deepseek_ai_dsh_api_session_controller_session_page_parameter_0$schema =
|
|
|
534
538
|
'throughSeq': z.number().readonly(),
|
|
535
539
|
'beforeSeq': z.number().readonly().optional(),
|
|
536
540
|
'maxMessages': z.number().readonly().optional(),
|
|
541
|
+
'turnWindow': z.object({
|
|
542
|
+
'minMessages': z.number().readonly(),
|
|
543
|
+
'minTurns': z.number().readonly(),
|
|
544
|
+
}).readonly().optional(),
|
|
537
545
|
}))
|
|
538
546
|
let _deepseek_ai_dsh_api_session_controller_session_page_result$schema$value
|
|
539
547
|
const _deepseek_ai_dsh_api_session_controller_session_page_result$schema = () => (_deepseek_ai_dsh_api_session_controller_session_page_result$schema$value ??= z.object({
|
|
@@ -1710,7 +1718,7 @@ export const TYPERT = {
|
|
|
1710
1718
|
},
|
|
1711
1719
|
{
|
|
1712
1720
|
"name": "MessageSourceMap",
|
|
1713
|
-
"declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'system-prompt': SystemPromptMessageSource;\n 'model-selection': { kind: 'model-selection'; } & ContextFormed;\n 'user-approval': { kind: 'user-approval'; } & ContextFormed;\n 'ptc-mode': { kind: 'ptc-mode'; };\n 'tool-registry': { kind: 'tool-registry'; };\n 'user-rpc': { kind: 'user'; rpcId: SessionRequestId; clientTimeZone?: string; };\n 'agent-message': AgentMessageSource;\n 'subagent-settled': SubagentSettledMessageSource;\n 'skill-invocation': SkillInvocationSource;\n 'cordis-host-runner': { kind: 'cordis-host-runner'; };\n
|
|
1721
|
+
"declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'system-prompt': SystemPromptMessageSource;\n 'model-selection': { kind: 'model-selection'; } & ContextFormed;\n 'user-approval': { kind: 'user-approval'; } & ContextFormed;\n 'ptc-mode': { kind: 'ptc-mode'; };\n 'tool-registry': { kind: 'tool-registry'; };\n 'user-rpc': { kind: 'user'; rpcId: SessionRequestId; clientTimeZone?: string; };\n 'agent-message': AgentMessageSource;\n 'subagent-settled': SubagentSettledMessageSource;\n 'skill-invocation': SkillInvocationSource;\n 'cordis-host-runner': { kind: 'cordis-host-runner'; };\n goal: GoalMessageSource;\n 'compact-checkpoint': CompactionCheckpointSource;\n 'session-reference': SessionReferenceSource;\n}"
|
|
1714
1722
|
},
|
|
1715
1723
|
{
|
|
1716
1724
|
"name": "ModelCatalog",
|
|
@@ -1902,7 +1910,7 @@ export const TYPERT = {
|
|
|
1902
1910
|
},
|
|
1903
1911
|
{
|
|
1904
1912
|
"name": "SessionEventMap",
|
|
1905
|
-
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'image/offload': { targets: ImageOffloadTarget[]; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n 'permission/preset': { preset: string; };\n 'subagent/catalog': SubagentCatalogEvent;\n 'feedback/record': FeedbackRecord;\n '
|
|
1913
|
+
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'image/offload': { targets: ImageOffloadTarget[]; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n 'permission/preset': { preset: string; };\n 'subagent/catalog': SubagentCatalogEvent;\n 'feedback/record': FeedbackRecord;\n 'goal/change': GoalChangeMeta;\n 'feedback/message-put': MessageFeedbackPut;\n 'feedback/message-delete': MessageFeedbackDelete;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; };\n}"
|
|
1906
1914
|
},
|
|
1907
1915
|
{
|
|
1908
1916
|
"name": "SessionEventType",
|
|
@@ -1914,7 +1922,7 @@ export const TYPERT = {
|
|
|
1914
1922
|
},
|
|
1915
1923
|
{
|
|
1916
1924
|
"name": "SessionFollowRequest",
|
|
1917
|
-
"declaration": "export interface SessionFollowRequest {\n readonly address: SessionAddress;\n readonly
|
|
1925
|
+
"declaration": "export interface SessionFollowRequest extends Pick<SessionPageRequest, 'maxMessages' | 'turnWindow'> {\n readonly address: SessionAddress;\n readonly assistantStream?: true;\n}"
|
|
1918
1926
|
},
|
|
1919
1927
|
{
|
|
1920
1928
|
"name": "SessionForkRequest",
|
|
@@ -1970,7 +1978,7 @@ export const TYPERT = {
|
|
|
1970
1978
|
},
|
|
1971
1979
|
{
|
|
1972
1980
|
"name": "SessionPageRequest",
|
|
1973
|
-
"declaration": "export interface SessionPageRequest {\n readonly address: SessionAddress;\n readonly throughSeq: number;\n readonly beforeSeq?: number;\n readonly maxMessages?: number;\n}"
|
|
1981
|
+
"declaration": "export interface SessionPageRequest {\n readonly address: SessionAddress;\n readonly throughSeq: number;\n readonly beforeSeq?: number;\n readonly maxMessages?: number;\n readonly turnWindow?: { readonly minMessages: number; readonly minTurns: number; };\n}"
|
|
1974
1982
|
},
|
|
1975
1983
|
{
|
|
1976
1984
|
"name": "SessionProjectionBaseline",
|
|
@@ -2164,42 +2172,6 @@ export const TYPERT = {
|
|
|
2164
2172
|
"name": "SystemPromptUpdate",
|
|
2165
2173
|
"declaration": "export type SystemPromptUpdate = 'in-history';"
|
|
2166
2174
|
},
|
|
2167
|
-
{
|
|
2168
|
-
"name": "TeamId",
|
|
2169
|
-
"declaration": "export type TeamId = Branded<'TeamId'>;"
|
|
2170
|
-
},
|
|
2171
|
-
{
|
|
2172
|
-
"name": "TeamMemberPhase",
|
|
2173
|
-
"declaration": "export type TeamMemberPhase = 'provisioning' | 'active' | 'failed';"
|
|
2174
|
-
},
|
|
2175
|
-
{
|
|
2176
|
-
"name": "TeamMemberSnapshot",
|
|
2177
|
-
"declaration": "export interface TeamMemberSnapshot {\n readonly id: SessionId;\n readonly name: string;\n readonly description: string;\n readonly provider: string;\n readonly context: 'fresh' | 'fork';\n readonly phase: TeamMemberPhase;\n readonly error?: string;\n}"
|
|
2178
|
-
},
|
|
2179
|
-
{
|
|
2180
|
-
"name": "TeamMessageId",
|
|
2181
|
-
"declaration": "export type TeamMessageId = Branded<'TeamMessageId'>;"
|
|
2182
|
-
},
|
|
2183
|
-
{
|
|
2184
|
-
"name": "TeamMessageSnapshot",
|
|
2185
|
-
"declaration": "export interface TeamMessageSnapshot {\n readonly id: TeamMessageId;\n readonly senderId: SessionId;\n readonly senderName: string;\n readonly targetId: SessionId;\n readonly content: ContentBlock[];\n}"
|
|
2186
|
-
},
|
|
2187
|
-
{
|
|
2188
|
-
"name": "TeamMessageSource",
|
|
2189
|
-
"declaration": "export interface TeamMessageSource {\n readonly kind: 'team-message';\n readonly teamId: TeamId;\n readonly messageId: TeamMessageId;\n readonly senderId: SessionId;\n readonly senderName: string;\n}"
|
|
2190
|
-
},
|
|
2191
|
-
{
|
|
2192
|
-
"name": "TeamTaskId",
|
|
2193
|
-
"declaration": "export type TeamTaskId = Branded<'TeamTaskId'>;"
|
|
2194
|
-
},
|
|
2195
|
-
{
|
|
2196
|
-
"name": "TeamTaskSnapshot",
|
|
2197
|
-
"declaration": "export interface TeamTaskSnapshot {\n readonly id: TeamTaskId;\n readonly revision: number;\n readonly subject: string;\n readonly description: string;\n readonly status: TeamTaskStatus;\n readonly ownerId?: SessionId;\n readonly blockedBy: TeamTaskId[];\n readonly writeScopes: string[];\n}"
|
|
2198
|
-
},
|
|
2199
|
-
{
|
|
2200
|
-
"name": "TeamTaskStatus",
|
|
2201
|
-
"declaration": "export type TeamTaskStatus = 'pending' | 'in_progress' | 'completed' | 'deleted';"
|
|
2202
|
-
},
|
|
2203
2175
|
{
|
|
2204
2176
|
"name": "TextBlock",
|
|
2205
2177
|
"declaration": "export interface TextBlock {\n type: 'text';\n text: string;\n}"
|
|
@@ -2549,7 +2521,7 @@ export const TYPERT = {
|
|
|
2549
2521
|
},
|
|
2550
2522
|
{
|
|
2551
2523
|
"name": "MessageSourceMap",
|
|
2552
|
-
"declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'system-prompt': SystemPromptMessageSource;\n 'model-selection': { kind: 'model-selection'; } & ContextFormed;\n 'user-approval': { kind: 'user-approval'; } & ContextFormed;\n 'ptc-mode': { kind: 'ptc-mode'; };\n 'tool-registry': { kind: 'tool-registry'; };\n 'user-rpc': { kind: 'user'; rpcId: SessionRequestId; clientTimeZone?: string; };\n 'agent-message': AgentMessageSource;\n 'subagent-settled': SubagentSettledMessageSource;\n 'skill-invocation': SkillInvocationSource;\n 'cordis-host-runner': { kind: 'cordis-host-runner'; };\n
|
|
2524
|
+
"declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'system-prompt': SystemPromptMessageSource;\n 'model-selection': { kind: 'model-selection'; } & ContextFormed;\n 'user-approval': { kind: 'user-approval'; } & ContextFormed;\n 'ptc-mode': { kind: 'ptc-mode'; };\n 'tool-registry': { kind: 'tool-registry'; };\n 'user-rpc': { kind: 'user'; rpcId: SessionRequestId; clientTimeZone?: string; };\n 'agent-message': AgentMessageSource;\n 'subagent-settled': SubagentSettledMessageSource;\n 'skill-invocation': SkillInvocationSource;\n 'cordis-host-runner': { kind: 'cordis-host-runner'; };\n goal: GoalMessageSource;\n 'compact-checkpoint': CompactionCheckpointSource;\n 'session-reference': SessionReferenceSource;\n}"
|
|
2553
2525
|
},
|
|
2554
2526
|
{
|
|
2555
2527
|
"name": "ModelMessageSource",
|
|
@@ -2613,7 +2585,7 @@ export const TYPERT = {
|
|
|
2613
2585
|
},
|
|
2614
2586
|
{
|
|
2615
2587
|
"name": "SessionEventMap",
|
|
2616
|
-
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'image/offload': { targets: ImageOffloadTarget[]; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n 'permission/preset': { preset: string; };\n 'subagent/catalog': SubagentCatalogEvent;\n 'feedback/record': FeedbackRecord;\n '
|
|
2588
|
+
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'image/offload': { targets: ImageOffloadTarget[]; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n 'permission/preset': { preset: string; };\n 'subagent/catalog': SubagentCatalogEvent;\n 'feedback/record': FeedbackRecord;\n 'goal/change': GoalChangeMeta;\n 'feedback/message-put': MessageFeedbackPut;\n 'feedback/message-delete': MessageFeedbackDelete;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; };\n}"
|
|
2617
2589
|
},
|
|
2618
2590
|
{
|
|
2619
2591
|
"name": "SessionEventType",
|
|
@@ -2711,42 +2683,6 @@ export const TYPERT = {
|
|
|
2711
2683
|
"name": "SystemPromptUpdate",
|
|
2712
2684
|
"declaration": "export type SystemPromptUpdate = 'in-history';"
|
|
2713
2685
|
},
|
|
2714
|
-
{
|
|
2715
|
-
"name": "TeamId",
|
|
2716
|
-
"declaration": "export type TeamId = Branded<'TeamId'>;"
|
|
2717
|
-
},
|
|
2718
|
-
{
|
|
2719
|
-
"name": "TeamMemberPhase",
|
|
2720
|
-
"declaration": "export type TeamMemberPhase = 'provisioning' | 'active' | 'failed';"
|
|
2721
|
-
},
|
|
2722
|
-
{
|
|
2723
|
-
"name": "TeamMemberSnapshot",
|
|
2724
|
-
"declaration": "export interface TeamMemberSnapshot {\n readonly id: SessionId;\n readonly name: string;\n readonly description: string;\n readonly provider: string;\n readonly context: 'fresh' | 'fork';\n readonly phase: TeamMemberPhase;\n readonly error?: string;\n}"
|
|
2725
|
-
},
|
|
2726
|
-
{
|
|
2727
|
-
"name": "TeamMessageId",
|
|
2728
|
-
"declaration": "export type TeamMessageId = Branded<'TeamMessageId'>;"
|
|
2729
|
-
},
|
|
2730
|
-
{
|
|
2731
|
-
"name": "TeamMessageSnapshot",
|
|
2732
|
-
"declaration": "export interface TeamMessageSnapshot {\n readonly id: TeamMessageId;\n readonly senderId: SessionId;\n readonly senderName: string;\n readonly targetId: SessionId;\n readonly content: ContentBlock[];\n}"
|
|
2733
|
-
},
|
|
2734
|
-
{
|
|
2735
|
-
"name": "TeamMessageSource",
|
|
2736
|
-
"declaration": "export interface TeamMessageSource {\n readonly kind: 'team-message';\n readonly teamId: TeamId;\n readonly messageId: TeamMessageId;\n readonly senderId: SessionId;\n readonly senderName: string;\n}"
|
|
2737
|
-
},
|
|
2738
|
-
{
|
|
2739
|
-
"name": "TeamTaskId",
|
|
2740
|
-
"declaration": "export type TeamTaskId = Branded<'TeamTaskId'>;"
|
|
2741
|
-
},
|
|
2742
|
-
{
|
|
2743
|
-
"name": "TeamTaskSnapshot",
|
|
2744
|
-
"declaration": "export interface TeamTaskSnapshot {\n readonly id: TeamTaskId;\n readonly revision: number;\n readonly subject: string;\n readonly description: string;\n readonly status: TeamTaskStatus;\n readonly ownerId?: SessionId;\n readonly blockedBy: TeamTaskId[];\n readonly writeScopes: string[];\n}"
|
|
2745
|
-
},
|
|
2746
|
-
{
|
|
2747
|
-
"name": "TeamTaskStatus",
|
|
2748
|
-
"declaration": "export type TeamTaskStatus = 'pending' | 'in_progress' | 'completed' | 'deleted';"
|
|
2749
|
-
},
|
|
2750
2686
|
{
|
|
2751
2687
|
"name": "TextBlock",
|
|
2752
2688
|
"declaration": "export interface TextBlock {\n type: 'text';\n text: string;\n}"
|
|
@@ -181,8 +181,12 @@ const _deepseek_ai_dsh_api_session_controller_session_follow_parameter_0$schema
|
|
|
181
181
|
'childSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
182
182
|
'mode': z.union([z.literal("one-shot"), z.literal("continuable"), z.literal("unknown")]).readonly(),
|
|
183
183
|
})]).readonly(),
|
|
184
|
-
'maxMessages': z.number().readonly().optional(),
|
|
185
184
|
'assistantStream': z.literal(true).readonly().optional(),
|
|
185
|
+
'maxMessages': z.number().readonly().optional(),
|
|
186
|
+
'turnWindow': z.object({
|
|
187
|
+
'minMessages': z.number().readonly(),
|
|
188
|
+
'minTurns': z.number().readonly(),
|
|
189
|
+
}).readonly().optional(),
|
|
186
190
|
}))
|
|
187
191
|
let _deepseek_ai_dsh_api_session_controller_session_follow_result$schema$value
|
|
188
192
|
const _deepseek_ai_dsh_api_session_controller_session_follow_result$schema = () => (_deepseek_ai_dsh_api_session_controller_session_follow_result$schema$value ??= z.union([z.object({
|
|
@@ -534,6 +538,10 @@ const _deepseek_ai_dsh_api_session_controller_session_page_parameter_0$schema =
|
|
|
534
538
|
'throughSeq': z.number().readonly(),
|
|
535
539
|
'beforeSeq': z.number().readonly().optional(),
|
|
536
540
|
'maxMessages': z.number().readonly().optional(),
|
|
541
|
+
'turnWindow': z.object({
|
|
542
|
+
'minMessages': z.number().readonly(),
|
|
543
|
+
'minTurns': z.number().readonly(),
|
|
544
|
+
}).readonly().optional(),
|
|
537
545
|
}))
|
|
538
546
|
let _deepseek_ai_dsh_api_session_controller_session_page_result$schema$value
|
|
539
547
|
const _deepseek_ai_dsh_api_session_controller_session_page_result$schema = () => (_deepseek_ai_dsh_api_session_controller_session_page_result$schema$value ??= z.object({
|
|
@@ -63,9 +63,10 @@ export interface ISession {
|
|
|
63
63
|
/**
|
|
64
64
|
* Register one local submission echo in `snapshot.pendingSubmissions`,
|
|
65
65
|
* synchronously, before the caller serializes and sends the prompt. The
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
66
|
+
* Chat echoes persist until durable admission; transcript identities also
|
|
67
|
+
* wait for the Inbox claim watermark so stale queue rows stay suppressed.
|
|
68
|
+
* Queued echoes retire on queue acceptance. Identified failures retire
|
|
69
|
+
* submissions that have not already reached durable admission.
|
|
69
70
|
* @param input - echo content and the optional settlement callback.
|
|
70
71
|
* @returns the minted identity for {@link prompt} plus the pre-prompt abandon path.
|
|
71
72
|
*/
|
|
@@ -118,7 +119,9 @@ export interface ISession {
|
|
|
118
119
|
seq: SessionSeq;
|
|
119
120
|
}>>;
|
|
120
121
|
/**
|
|
121
|
-
* Extend
|
|
122
|
+
* Extend history by at least 50 messages and two Turn starts, including a
|
|
123
|
+
* partial Turn at the window's beginning. Stop at 500 messages or history
|
|
124
|
+
* exhaustion even when those minima cannot be met. Publish one prepend.
|
|
122
125
|
* @returns completion; failures land in snapshot.openState/loadingOlder.
|
|
123
126
|
*/
|
|
124
127
|
loadOlder(): Promise<void>;
|
|
@@ -127,6 +130,8 @@ export interface ISession {
|
|
|
127
130
|
* turn-jump loader. Repeated calls while a jump is paging lower its shared
|
|
128
131
|
* target and return the in-flight completion; `snapshot.loadingOlder` is
|
|
129
132
|
* the busy signal for the whole jump.
|
|
133
|
+
* Each page uses the same Turn alignment as loadOlder, with a 200-message
|
|
134
|
+
* minimum. The 500-message limit applies per page, not to the whole jump.
|
|
130
135
|
* Older pages publish together at completion, including successful pages
|
|
131
136
|
* before a later failure; live events remain independently visible.
|
|
132
137
|
* @param seq - durable event seq the window must reach (a turn's `turn/start` seq).
|
|
@@ -38,7 +38,7 @@ export type PendingSubmissionPlacement = 'transcript' | 'queued' | 'steering';
|
|
|
38
38
|
export interface PendingSubmission {
|
|
39
39
|
/** The prompt RPC identity; the durable `user/message` source echoes it as `rpcId`. */
|
|
40
40
|
readonly requestId: SessionRequestId;
|
|
41
|
-
/**
|
|
41
|
+
/** Surface fixed at submission time; Inbox acceptance does not move a Chat echo into the dock. */
|
|
42
42
|
readonly placement: PendingSubmissionPlacement;
|
|
43
43
|
/** Client wall-clock ms when the submission began. */
|
|
44
44
|
readonly time: number;
|
|
@@ -6,6 +6,8 @@ import type { SessionAssistantSettlementEntry, SessionEventLikeEntry, SessionLiv
|
|
|
6
6
|
export type ClientAssistantStreamResult = {
|
|
7
7
|
readonly type: 'publish';
|
|
8
8
|
readonly entry: SessionLiveEventEntry;
|
|
9
|
+
/** Retire the successful attempt's transient rows after publishing its Step end. */
|
|
10
|
+
readonly retireAttemptId?: LlmAttemptId;
|
|
9
11
|
} | {
|
|
10
12
|
readonly type: 'settlement';
|
|
11
13
|
readonly attemptId: LlmAttemptId;
|
|
@@ -22,6 +24,7 @@ export type ClientAssistantStreamResult = {
|
|
|
22
24
|
/** Keeps transient Assistant presentation behind one settlement-aware interface. */
|
|
23
25
|
export declare class ClientAssistantStream {
|
|
24
26
|
private activeAttempt;
|
|
27
|
+
private retainedAttempt;
|
|
25
28
|
private readonly pending;
|
|
26
29
|
private publishedSeqs;
|
|
27
30
|
private durableCursor;
|
|
@@ -41,6 +44,8 @@ export declare class ClientAssistantStream {
|
|
|
41
44
|
acceptDurable(entry: SessionLiveEventEntry): ClientAssistantStreamResult;
|
|
42
45
|
/**
|
|
43
46
|
* Fold one dense transient frame and release its named durable settlement.
|
|
47
|
+
* Successful messages retain their transient rows until the owning Step ends;
|
|
48
|
+
* interrupted messages, failed attempts, and abandonment retire them immediately.
|
|
44
49
|
* @param frame - next Assistant stream frame received by the follow connection.
|
|
45
50
|
* @returns a transient, publication, or rebaseline decision, or `undefined` when no entry becomes visible.
|
|
46
51
|
*/
|
|
@@ -3,6 +3,7 @@ import { expandAssistantStream } from '@deepseek-ai/dsh-llm/assistant-stream';
|
|
|
3
3
|
/** Keeps transient Assistant presentation behind one settlement-aware interface. */
|
|
4
4
|
export class ClientAssistantStream {
|
|
5
5
|
activeAttempt;
|
|
6
|
+
retainedAttempt;
|
|
6
7
|
pending = new Map();
|
|
7
8
|
publishedSeqs = new Set();
|
|
8
9
|
durableCursor = -1;
|
|
@@ -17,6 +18,7 @@ export class ClientAssistantStream {
|
|
|
17
18
|
this.pending.clear();
|
|
18
19
|
this.transientInGap = 0;
|
|
19
20
|
this.activeAttempt = undefined;
|
|
21
|
+
this.retainedAttempt = undefined;
|
|
20
22
|
const opening = baseline?.activeAttempt;
|
|
21
23
|
if (opening !== undefined) {
|
|
22
24
|
this.activeAttempt = {
|
|
@@ -73,13 +75,16 @@ export class ClientAssistantStream {
|
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
75
77
|
* Fold one dense transient frame and release its named durable settlement.
|
|
78
|
+
* Successful messages retain their transient rows until the owning Step ends;
|
|
79
|
+
* interrupted messages, failed attempts, and abandonment retire them immediately.
|
|
76
80
|
* @param frame - next Assistant stream frame received by the follow connection.
|
|
77
81
|
* @returns a transient, publication, or rebaseline decision, or `undefined` when no entry becomes visible.
|
|
78
82
|
*/
|
|
79
83
|
acceptFrame(frame) {
|
|
80
84
|
switch (frame.type) {
|
|
81
85
|
case 'start':
|
|
82
|
-
if (this.activeAttempt !== undefined || this.
|
|
86
|
+
if (this.activeAttempt !== undefined || this.retainedAttempt !== undefined
|
|
87
|
+
|| this.pending.size > 0)
|
|
83
88
|
return { type: 'rebaseline' };
|
|
84
89
|
this.pending.clear();
|
|
85
90
|
this.activeAttempt = {
|
|
@@ -140,6 +145,10 @@ export class ClientAssistantStream {
|
|
|
140
145
|
return { type: 'rebaseline' };
|
|
141
146
|
}
|
|
142
147
|
this.pending.delete(frame.outcome.seq);
|
|
148
|
+
if (entry.event.type === 'assistant/message' && entry.event.data.interrupted !== true) {
|
|
149
|
+
this.retainedAttempt = { attemptId: attempt.attemptId, turn: attempt.turn, step: attempt.step };
|
|
150
|
+
return this.publish(entry);
|
|
151
|
+
}
|
|
143
152
|
this.publishedSeqs.add(entry.event.seq);
|
|
144
153
|
return { type: 'settlement', attemptId: attempt.attemptId, entry };
|
|
145
154
|
}
|
|
@@ -157,6 +166,12 @@ export class ClientAssistantStream {
|
|
|
157
166
|
}
|
|
158
167
|
publish(entry) {
|
|
159
168
|
this.publishedSeqs.add(entry.event.seq);
|
|
169
|
+
const retained = this.retainedAttempt;
|
|
170
|
+
if (retained !== undefined && entry.event.type === 'step/end'
|
|
171
|
+
&& entry.event.data.turn === retained.turn && entry.event.data.step === retained.step) {
|
|
172
|
+
this.retainedAttempt = undefined;
|
|
173
|
+
return { type: 'publish', entry, retireAttemptId: retained.attemptId };
|
|
174
|
+
}
|
|
160
175
|
return { type: 'publish', entry };
|
|
161
176
|
}
|
|
162
177
|
}
|
|
@@ -75,6 +75,12 @@ export declare class ProjectionValueStore {
|
|
|
75
75
|
* @returns the value, or undefined while the key is absent.
|
|
76
76
|
*/
|
|
77
77
|
get(key: string): unknown;
|
|
78
|
+
/**
|
|
79
|
+
* Read the accepted Host watermark without subscribing or copying a value.
|
|
80
|
+
* @param key - projection key.
|
|
81
|
+
* @returns the current sequence, or undefined for absent and cached values.
|
|
82
|
+
*/
|
|
83
|
+
seqOf(key: string): SessionSeqCursor | undefined;
|
|
78
84
|
/**
|
|
79
85
|
* Read every current projection value as one reference-stable snapshot.
|
|
80
86
|
* @returns The same frozen value map until a row changes.
|
|
@@ -38,6 +38,15 @@ export class ProjectionValueStore {
|
|
|
38
38
|
get(key) {
|
|
39
39
|
return this.rows.get(key)?.value;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Read the accepted Host watermark without subscribing or copying a value.
|
|
43
|
+
* @param key - projection key.
|
|
44
|
+
* @returns the current sequence, or undefined for absent and cached values.
|
|
45
|
+
*/
|
|
46
|
+
seqOf(key) {
|
|
47
|
+
const row = this.rows.get(key);
|
|
48
|
+
return row?.kind === 'sequenced' ? row.seq : undefined;
|
|
49
|
+
}
|
|
41
50
|
/**
|
|
42
51
|
* Read every current projection value as one reference-stable snapshot.
|
|
43
52
|
* @returns The same frozen value map until a row changes.
|
|
@@ -10,9 +10,9 @@ import { MutableSessionEventSource } from '../contract/events.ts';
|
|
|
10
10
|
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol';
|
|
11
11
|
import type { SessionRemotes } from './remotes.ts';
|
|
12
12
|
import { ProjectionValueStore } from './projection-store.ts';
|
|
13
|
-
/**
|
|
13
|
+
/** Minimum message count for ordinary history windows. */
|
|
14
14
|
export declare const PAGE_MESSAGES = 50;
|
|
15
|
-
/**
|
|
15
|
+
/** Minimum messages per page while a turn jump loops backwards. */
|
|
16
16
|
export declare const JUMP_PAGE_MESSAGES = 200;
|
|
17
17
|
/** Manager-owned observers of a Session object's local state edges. */
|
|
18
18
|
export interface SessionOptions {
|
|
@@ -192,7 +192,7 @@ export declare class Session implements SessionFace {
|
|
|
192
192
|
}>>;
|
|
193
193
|
/** First open: pull the tail page (idempotent — in-flight/already-open returns the existing promise). */
|
|
194
194
|
open(): Promise<void>;
|
|
195
|
-
/**
|
|
195
|
+
/** Prepend one Turn-aligned page: at least 50 messages and two Turn starts, capped at 500 messages. */
|
|
196
196
|
loadOlder(): Promise<void>;
|
|
197
197
|
/** Jump loader: page backwards until the window covers seq (see ISession.loadThrough). */
|
|
198
198
|
loadThrough(seq: SessionSeq): Promise<void>;
|
|
@@ -262,9 +262,11 @@ export declare class Session implements SessionFace {
|
|
|
262
262
|
private appendLive;
|
|
263
263
|
/** Observe durable acceptance even when insertion and claim share one projection notification. */
|
|
264
264
|
private observeSubmissionEvent;
|
|
265
|
-
private
|
|
265
|
+
private observeSubmissionInsertions;
|
|
266
266
|
private observeSubmissionMessage;
|
|
267
|
-
/** Retire
|
|
267
|
+
/** Retire admitted Chat identities only after stale Inbox rows can no longer reappear. */
|
|
268
|
+
private retireAdmittedSubmission;
|
|
269
|
+
/** Inbox acceptance retires queued echoes; its watermark completes admitted Chat handoffs. */
|
|
268
270
|
private observeSubmissionInbox;
|
|
269
271
|
/**
|
|
270
272
|
* Latch one observed settlement and remove the echo an animation frame
|