@deepseek-ai/dsh-session-reference 0.1.0-rc.7 → 0.1.0-rc.8
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 -6
- package/README.zh.md +6 -6
- package/lib/index.js +232 -110
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +458 -0
- package/lib/typert.remote-client.d.ts +26 -0
- package/lib/typert.remote-client.js +62 -0
- package/lib/types/config.js +18 -0
- package/lib/types/index.d.ts +25 -5
- package/lib/types/index.js +322 -0
- package/lib/types/invariant.js +22 -0
- package/lib/types/projection.js +142 -0
- package/lib/types/serialization.js +13 -0
- package/lib/types/types.d.ts +14 -3
- package/lib/types/types.js +8 -0
- package/lib/types/uri.js +81 -0
- package/package.json +36 -16
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
/* Generated by @deepseek-ai/dsh-typert-generator from FaceModel — do not edit. */
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
const _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_parameter_0$schema = z.intersection(z.string(), z.unknown())
|
|
5
|
+
const _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_parameter_1$schema = z.string()
|
|
6
|
+
const _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_result$schema = z.array(z.object({
|
|
7
|
+
'mention': z.string(),
|
|
8
|
+
'sessionId': z.intersection(z.string(), z.unknown()),
|
|
9
|
+
'label': z.string(),
|
|
10
|
+
'cwd': z.string().optional(),
|
|
11
|
+
'createdAt': z.number(),
|
|
12
|
+
}))
|
|
13
|
+
|
|
14
|
+
export const TYPERT = {
|
|
15
|
+
package: '@deepseek-ai/dsh-session-reference',
|
|
16
|
+
face: 'host',
|
|
17
|
+
schemas: [
|
|
18
|
+
],
|
|
19
|
+
invocations: [
|
|
20
|
+
{
|
|
21
|
+
id: '@deepseek-ai/dsh-session-reference#sessionReferenceResolver/candidates',
|
|
22
|
+
service: 'sessionReferenceResolver',
|
|
23
|
+
namespace: 'sessionReferenceResolver',
|
|
24
|
+
method: 'candidates',
|
|
25
|
+
implementation: 'remoteExportCandidates',
|
|
26
|
+
invocation: { kind: 'direct' },
|
|
27
|
+
scope: {
|
|
28
|
+
context: 'agent',
|
|
29
|
+
wire: 'agentId',
|
|
30
|
+
},
|
|
31
|
+
parameters: [
|
|
32
|
+
{
|
|
33
|
+
name: 'agent',
|
|
34
|
+
wire: 'agentId',
|
|
35
|
+
source: 'lookup',
|
|
36
|
+
lookup: 'agent',
|
|
37
|
+
codec: {
|
|
38
|
+
mode: 'strict',
|
|
39
|
+
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
40
|
+
schema: _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_parameter_0$schema,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'query',
|
|
45
|
+
wire: 'query',
|
|
46
|
+
source: 'json',
|
|
47
|
+
codec: {
|
|
48
|
+
mode: 'strict',
|
|
49
|
+
typeSymbol: '@deepseek-ai/dsh-session-reference#sessionReferenceResolver/candidates:query',
|
|
50
|
+
schema: _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_parameter_1$schema,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
cancellation: { parameter: 'signal' },
|
|
55
|
+
result: {
|
|
56
|
+
mode: 'strict',
|
|
57
|
+
typeSymbol: '@deepseek-ai/dsh-session-reference#sessionReferenceResolver/candidates:result',
|
|
58
|
+
schema: _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_result$schema,
|
|
59
|
+
},
|
|
60
|
+
sourceLocation: {"file":"packages/context/session-reference/src/index.ts","line":218,"column":9},
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
model: {
|
|
64
|
+
"services": [
|
|
65
|
+
{
|
|
66
|
+
"description": "Exact-read consumer that prepares immutable cross-session message context.",
|
|
67
|
+
"summary": "Exact-read consumer that prepares immutable cross-session message context.",
|
|
68
|
+
"tags": [],
|
|
69
|
+
"jsDoc": "/** Exact-read consumer that prepares immutable cross-session message context. */",
|
|
70
|
+
"key": "sessionReferenceResolver",
|
|
71
|
+
"exportName": "SessionReferenceResolver",
|
|
72
|
+
"members": [
|
|
73
|
+
{
|
|
74
|
+
"kind": "method",
|
|
75
|
+
"name": "listCandidates",
|
|
76
|
+
"signature": "async listCandidates( agent: Agent, query: string = '', limit: number = this.config.candidateLimit, signal?: AbortSignal, ): Promise<SessionReferenceCandidate[]>",
|
|
77
|
+
"summary": "List reference candidates, ranked by working-directory affinity.",
|
|
78
|
+
"jsDoc": "/**\n * List reference candidates, ranked by working-directory affinity.\n * @param agent - target agent; self is excluded and its cwd drives ranking.\n * @param query - optional case-insensitive session-id/cwd/title substring.\n * @param limit - optional positive result cap.\n * @param signal - optional cancellation boundary for host autocomplete teardown.\n * @returns candidates labeled by latest title or, when absent, session id.\n */"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"kind": "method",
|
|
82
|
+
"name": "remoteExportCandidates",
|
|
83
|
+
"signature": "@Remote('candidates') async remoteExportCandidates( agent: Agent, query: string, signal: AbortSignal, ): Promise<SessionReferenceMentionCandidate[]>",
|
|
84
|
+
"summary": "Remote face of {@link listCandidates}: the configured candidate limit applies, and every candidate carries the canonical mention a host inserts into the prompt draft.",
|
|
85
|
+
"jsDoc": "/**\n * Remote face of {@link listCandidates}: the configured candidate limit\n * applies, and every candidate carries the canonical mention a host inserts\n * into the prompt draft.\n * @param agent - target agent; self is excluded and its cwd drives ranking.\n * @param query - optional case-insensitive session-id/cwd/title substring.\n * @param signal - caller cancellation.\n * @returns mention-carrying candidates in rank order.\n */"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"kind": "method",
|
|
89
|
+
"name": "prepare",
|
|
90
|
+
"signature": "async prepare( agent: Agent, content: ContentBlock[], references: SessionReferenceInput[], signal?: AbortSignal, ): Promise<PreparedReferencedMessage>",
|
|
91
|
+
"summary": "Snapshot all references for one accepted direct message and return one aggregated durable context.",
|
|
92
|
+
"jsDoc": "/**\n * Snapshot all references for one accepted direct message and return one aggregated durable context.\n * @param agent - target agent; references to it are rejected.\n * @param content - already host-normalized readable message content.\n * @param references - structured source sessions in mention order.\n * @param signal - optional cancellation boundary for the active turn.\n * @returns detached content and optional referenced-session context.\n */"
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"types": [
|
|
96
|
+
{
|
|
97
|
+
"name": "Agent",
|
|
98
|
+
"declaration": "export interface Agent {\n readonly id: SessionId;\n readonly options: AgentOptions;\n readonly session: Session;\n readonly inbox: Inbox;\n readonly status: AgentStatus;\n readonly ctx: Context;\n cancel(cause: AgentCancelCause, options?: CancelOptions): void;\n whenIdle(): Promise<void>;\n runMaintenance<T>(task: (signal: AbortSignal) => Promise<T>): Promise<T>;\n send(message: UserMessage, target: InboxTarget, wakeup: boolean): void;\n followup(message: UserMessage): void;\n steer(message: UserMessage): void;\n inject(message: UserMessage): void;\n}"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"name": "AgentCancelCause",
|
|
102
|
+
"declaration": "export type AgentCancelCause = { readonly kind: 'user'; } | { readonly kind: 'parent'; } | { readonly kind: 'hook'; readonly reason: string; } | { readonly kind: 'disposed'; };"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "AgentOptions",
|
|
106
|
+
"declaration": "export interface AgentOptions {\n provider?: string;\n model?: string;\n maxTokens?: number;\n}"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "AgentStatus",
|
|
110
|
+
"declaration": "export type AgentStatus = 'idle' | 'running';"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "ApprovalOutcome",
|
|
114
|
+
"declaration": "export type ApprovalOutcome = 'allowed-once' | 'rejected' | 'cancelled' | 'unavailable';"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"name": "ApprovalPolicy",
|
|
118
|
+
"declaration": "export type ApprovalPolicy = 'ask' | 'never';"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "ApprovalRequestId",
|
|
122
|
+
"declaration": "export type ApprovalRequestId = Branded<'ApprovalRequestId'>;"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "AssistantMessage",
|
|
126
|
+
"declaration": "export interface AssistantMessage extends Message {\n readonly role: 'assistant';\n readonly source: ModelMessageSource;\n}"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"name": "AssistantProvenance",
|
|
130
|
+
"declaration": "export interface AssistantProvenance {\n provider: string;\n model: string;\n replayState?: unknown;\n}"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"name": "AttachmentId",
|
|
134
|
+
"declaration": "export type AttachmentId = Branded<'AttachmentId'>;"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"name": "Branded",
|
|
138
|
+
"declaration": "export type Branded<B extends string> = string & { readonly [BRAND]: B; };"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "CallId",
|
|
142
|
+
"declaration": "export type CallId = Branded<'CallId'>;"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"name": "CancelOptions",
|
|
146
|
+
"declaration": "export interface CancelOptions {\n keepInbox?: boolean | undefined;\n}"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"name": "CodeDispatchEventData",
|
|
150
|
+
"declaration": "export interface CodeDispatchEventData extends CodeDispatchStartEventData {\n isError: boolean;\n content: ContentBlock[];\n}"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"name": "CodeDispatchStartEventData",
|
|
154
|
+
"declaration": "export interface CodeDispatchStartEventData {\n rootCallId: CallId;\n parentCallId: CallId;\n subCallId: CallId;\n name: string;\n arguments: unknown;\n}"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"name": "CommandId",
|
|
158
|
+
"declaration": "export type CommandId = Branded<'CommandId'>;"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "CommandSource",
|
|
162
|
+
"declaration": "export type CommandSource = CommandSourceMap[keyof CommandSourceMap];"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"name": "CommandSourceMap",
|
|
166
|
+
"declaration": "export interface CommandSourceMap {\n user: { kind: 'user'; };\n}"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"name": "CompactionId",
|
|
170
|
+
"declaration": "export type CompactionId = Branded<'CompactionId'>;"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"name": "ContentBlock",
|
|
174
|
+
"declaration": "export type ContentBlock = ContentBlockMap[ContentBlockType];"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"name": "ContentBlockMap",
|
|
178
|
+
"declaration": "export interface ContentBlockMap {\n text: TextBlock;\n reasoning: ReasoningBlock;\n image: ImageBlock;\n 'tool-call': ToolCallBlock;\n 'tool-result': ToolResultBlock;\n}"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"name": "ContentBlockType",
|
|
182
|
+
"declaration": "export type ContentBlockType = keyof ContentBlockMap;"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"name": "ContextFormed",
|
|
186
|
+
"declaration": "export type ContextFormed = { readonly form?: never; } | { readonly form: 'instructions'; } | { readonly form: 'catalog'; } | { readonly form: 'snapshot'; readonly sections: readonly ContextSnapshotSection[]; } | { readonly form: 'notice'; readonly summary: string; } | { readonly form: 'relay'; } | { readonly form: 'recall'; };"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"name": "ContextSnapshotSection",
|
|
190
|
+
"declaration": "export interface ContextSnapshotSection {\n readonly name: string;\n readonly text: string;\n}"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"name": "EpochHeader",
|
|
194
|
+
"declaration": "export interface EpochHeader {\n config: LlmCallConfig;\n adapterDefaults?: LlmCallConfigAdapterDefaults;\n system?: string;\n tools?: ToolSchema[];\n}"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"name": "FinishReason",
|
|
198
|
+
"declaration": "export type FinishReason = FinishReasonMap[keyof FinishReasonMap];"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"name": "FinishReasonMap",
|
|
202
|
+
"declaration": "export interface FinishReasonMap {\n stop: { kind: 'stop'; };\n 'tool-calls': { kind: 'tool-calls'; };\n 'max-tokens': { kind: 'max-tokens'; };\n aborted: { kind: 'aborted'; failure: LlmFailure; };\n error: { kind: 'error'; failure: LlmFailure; };\n}"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"name": "GoalBlockReason",
|
|
206
|
+
"declaration": "export interface GoalBlockReason {\n readonly code: string;\n readonly message: string;\n}"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"name": "GoalChangeMeta",
|
|
210
|
+
"declaration": "export type GoalChangeMeta = GoalSnapshotChangeMeta | GoalClearChangeMeta;"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"name": "GoalClearChangeMeta",
|
|
214
|
+
"declaration": "export interface GoalClearChangeMeta {\n readonly kind: 'goal/change';\n readonly version: 1;\n readonly operation: 'clear';\n readonly cleared: GoalRef;\n readonly clearedAt: number;\n}"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"name": "GoalId",
|
|
218
|
+
"declaration": "export type GoalId = Branded<'GoalId'>;"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"name": "GoalMessageSource",
|
|
222
|
+
"declaration": "export interface GoalMessageSource {\n readonly kind: 'goal';\n readonly goalId: GoalId;\n readonly revision: number;\n readonly round: number;\n}"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"name": "GoalOperation",
|
|
226
|
+
"declaration": "export type GoalOperation = 'create' | 'edit' | 'pause' | 'resume' | 'complete' | 'block' | 'clear';"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"name": "GoalPhase",
|
|
230
|
+
"declaration": "export type GoalPhase = 'active' | 'paused' | 'blocked' | 'complete';"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"name": "GoalRef",
|
|
234
|
+
"declaration": "export interface GoalRef {\n readonly id: GoalId;\n readonly revision: number;\n}"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"name": "GoalSnapshot",
|
|
238
|
+
"declaration": "export interface GoalSnapshot extends GoalRef {\n readonly objective: string;\n readonly phase: GoalPhase;\n readonly blockedReason?: GoalBlockReason;\n readonly maxGoalRounds: number;\n}"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"name": "GoalSnapshotChangeMeta",
|
|
242
|
+
"declaration": "export interface GoalSnapshotChangeMeta {\n readonly kind: 'goal/change';\n readonly version: 1;\n readonly operation: Exclude<GoalOperation, 'clear'>;\n readonly goal: GoalSnapshot;\n readonly roundsStarted: number;\n readonly createdAt: number;\n readonly updatedAt: number;\n}"
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"name": "ImageAttachmentRef",
|
|
246
|
+
"declaration": "export interface ImageAttachmentRef {\n attachmentId: AttachmentId;\n mediaType: ImageMediaType;\n bytes: number;\n width: number;\n height: number;\n name?: string;\n}"
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"name": "ImageBlock",
|
|
250
|
+
"declaration": "export interface ImageBlock {\n type: 'image';\n attachment: ImageAttachmentRef;\n}"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"name": "ImageMediaType",
|
|
254
|
+
"declaration": "export type ImageMediaType = 'image/png' | 'image/jpeg' | 'image/webp' | 'image/gif';"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"name": "Inbox",
|
|
258
|
+
"declaration": "export class Inbox {\n get nextTurn(): readonly UserMessage[];\n get nextStep(): readonly UserMessage[];\n get hasPending(): boolean;\n clear(): void;\n claim(target: InboxTarget, turn: number): UserMessage[];\n append(target: InboxTarget, message: UserMessage): void;\n prepend(target: InboxTarget, message: UserMessage): void;\n replace(messageId: MessageId, newMessage: UserMessage): boolean;\n remove(messageId: MessageId): boolean;\n splice(target: InboxTarget, start: number, deleteCount: number, inserted: UserMessage[]): UserMessage[];\n}"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"name": "InboxTarget",
|
|
262
|
+
"declaration": "export type InboxTarget = 'next-turn' | 'next-step';"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"name": "JsonValue",
|
|
266
|
+
"declaration": "export type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue; };"
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"name": "LlmCallConfig",
|
|
270
|
+
"declaration": "export interface LlmCallConfig {\n provider: string;\n model: string;\n reasoningEffort?: ReasoningEffortId;\n temperature?: number;\n maxTokens?: number;\n stop?: string[];\n}"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"name": "LlmCallConfigAdapterDefaults",
|
|
274
|
+
"declaration": "export interface LlmCallConfigAdapterDefaults {\n reasoningEffort?: true;\n maxTokens?: true;\n}"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"name": "LlmFailure",
|
|
278
|
+
"declaration": "export interface LlmFailure {\n readonly message: string;\n readonly code: string;\n readonly status?: number;\n readonly providerRetryAfterMs?: number;\n readonly requestId?: ProviderRequestId;\n}"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"name": "Message",
|
|
282
|
+
"declaration": "export interface Message {\n readonly id: MessageId;\n readonly role: 'system' | 'user' | 'assistant';\n readonly content: ContentBlock[];\n readonly source: MessageSource;\n}"
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"name": "MessageId",
|
|
286
|
+
"declaration": "export type MessageId = Branded<'MessageId'>;"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
"name": "MessageSource",
|
|
290
|
+
"declaration": "export type MessageSource = MessageSourceMap[keyof MessageSourceMap];"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"name": "MessageSourceMap",
|
|
294
|
+
"declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n plugin: { kind: 'plugin'; plugin: string; } & ContextFormed;\n model: ModelMessageSource;\n tool: ToolMessageSource;\n goal: GoalMessageSource;\n 'session-reference': SessionReferenceSource;\n}"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"name": "ModelMessageSource",
|
|
298
|
+
"declaration": "export interface ModelMessageSource extends AssistantProvenance {\n kind: 'model';\n}"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
"name": "PreparedReferencedMessage",
|
|
302
|
+
"declaration": "export interface PreparedReferencedMessage {\n content: ContentBlock[];\n additionalContext?: UserMessage;\n}"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"name": "ProviderRequestId",
|
|
306
|
+
"declaration": "export type ProviderRequestId = Branded<'ProviderRequestId'>;"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
"name": "ReasoningBlock",
|
|
310
|
+
"declaration": "export interface ReasoningBlock {\n type: 'reasoning';\n text: string;\n}"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"name": "ReasoningEffortId",
|
|
314
|
+
"declaration": "export type ReasoningEffortId = Branded<'ReasoningEffortId'>;"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"name": "ReplayEnvelope",
|
|
318
|
+
"declaration": "export interface ReplayEnvelope {\n response: unknown;\n blocks?: readonly unknown[];\n}"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"name": "RequestContext",
|
|
322
|
+
"declaration": "export interface RequestContext {\n provider: string;\n model: string;\n contextWindow?: number;\n}"
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"name": "RequestHeaderReason",
|
|
326
|
+
"declaration": "export type RequestHeaderReason = 'initial' | 'resume' | 'change';"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"name": "Session",
|
|
330
|
+
"declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n get id(): SessionId;\n readonly firstLiveSeq: number;\n get events(): readonly SessionEvent[];\n get seq(): number;\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"name": "SessionEvent",
|
|
334
|
+
"declaration": "export type SessionEvent<T extends SessionEventType = SessionEventType> = { [K in SessionEventType]: { type: K; seq: number; time: number; data: SessionEventMap[K]; ignorable?: true; } & (K extends SurfaceEventType ? { sourceEventSeqs?: number[]; surfaceOp?: SurfaceOp; } : object) }[T];"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"name": "SessionEventMap",
|
|
338
|
+
"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 'assistant/chunk': { turn: number; step: number; chunk: StreamChunk; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; usage?: TokenUsage; interrupted?: true; };\n 'tool/call': { turn: number; step: number; callId: CallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; }; meta?: JsonValue; };\n 'todo/write': { todos: TodoItem[]; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; };\n 'request/context': RequestContext;\n 'session/end-seed': Record<string, never>;\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: number; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: CallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/code-dispatch-start': CodeDispatchStartEventData;\n 'tool/code-dispatch': CodeDispatchEventData;\n 'goal/change': GoalChangeMeta;\n 'session/title': SessionTitleEventData;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: number; end: number; }; shadowedSeqs: number[]; 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: number; end: number; }; shadowedSeqs: number[]; shadowedTokenCount: number; };\n}"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"name": "SessionEventType",
|
|
342
|
+
"declaration": "export type SessionEventType = keyof SessionEventMap;"
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
"name": "SessionHeader",
|
|
346
|
+
"declaration": "export interface SessionHeader {\n readonly version: number;\n readonly id: SessionId;\n readonly createdAt: number;\n readonly cwd?: string;\n readonly parentSession?: SessionId;\n readonly seedLength?: number;\n readonly origin?: 'subagent';\n readonly delegationDepth?: number;\n readonly agentPreset?: string;\n}"
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"name": "SessionId",
|
|
350
|
+
"declaration": "export type SessionId = Branded<'SessionId'>;"
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"name": "SessionReferenceCandidate",
|
|
354
|
+
"declaration": "export interface SessionReferenceCandidate {\n sessionId: SessionId;\n label: string;\n cwd?: string;\n createdAt: number;\n}"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"name": "SessionReferenceInput",
|
|
358
|
+
"declaration": "export interface SessionReferenceInput {\n sessionId: SessionId;\n label?: string;\n}"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"name": "SessionReferenceMentionCandidate",
|
|
362
|
+
"declaration": "export interface SessionReferenceMentionCandidate extends SessionReferenceCandidate {\n mention: string;\n}"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"name": "SessionReferenceSource",
|
|
366
|
+
"declaration": "export interface SessionReferenceSource {\n kind: 'session-reference';\n form: 'recall';\n version: 1;\n references: { sessionId: string; label: string; capturedThroughSeq: number | null; compacted: boolean; originalMessages: number; retainedMessages: number; omittedMessages: number; omittedBytes: number; truncated: boolean; inputIndex: number; }[];\n}"
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
"name": "SessionSurface",
|
|
370
|
+
"declaration": "export interface SessionSurface {\n readonly nodes: readonly number[];\n readonly replaceGeneration: number;\n}"
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"name": "SessionTitleEventData",
|
|
374
|
+
"declaration": "export interface SessionTitleEventData {\n readonly title: string;\n readonly messageSeqs: number[];\n readonly source: SessionTitleSource;\n}"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"name": "SessionTitleModelProvenance",
|
|
378
|
+
"declaration": "export interface SessionTitleModelProvenance {\n readonly provider: string;\n readonly model: string;\n}"
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"name": "SessionTitleProviderId",
|
|
382
|
+
"declaration": "export type SessionTitleProviderId = Branded<'SessionTitleProviderId'>;"
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"name": "SessionTitleSource",
|
|
386
|
+
"declaration": "export type SessionTitleSource = { readonly kind: 'fallback'; } | { readonly kind: 'provider'; readonly provider: SessionTitleProviderId; readonly model?: SessionTitleModelProvenance; } | { readonly kind: 'user'; };"
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
"name": "StreamChunk",
|
|
390
|
+
"declaration": "export type StreamChunk = { type: 'block-start'; index: number; blockType: ContentBlockType; } | { type: 'text-delta'; index: number; text: string; } | { type: 'reasoning-delta'; index: number; text: string; } | { type: 'tool-call-delta'; index: number; id: CallId; name?: string; argumentsDelta: string; } | { type: 'block-end'; index: number; block: ContentBlock; } | { type: 'usage'; usage: TokenUsage; } | { type: 'finish'; reason: FinishReason; replayState?: ReplayEnvelope; };"
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
"name": "SurfaceEventType",
|
|
394
|
+
"declaration": "export type SurfaceEventType = 'user/message' | 'assistant/message' | 'tool/result';"
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
"name": "SurfaceIntent",
|
|
398
|
+
"declaration": "export interface SurfaceIntent {\n surfaceOp: SurfaceOp;\n sourceEventSeqs?: number[];\n}"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"name": "SurfaceOp",
|
|
402
|
+
"declaration": "export type SurfaceOp = 'append' | { op: 'replace'; start: number; end: number; };"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
"name": "TextBlock",
|
|
406
|
+
"declaration": "export interface TextBlock {\n type: 'text';\n text: string;\n}"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"name": "TodoItem",
|
|
410
|
+
"declaration": "export interface TodoItem {\n content: string;\n status: 'pending' | 'in_progress' | 'completed';\n}"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"name": "TokenUsage",
|
|
414
|
+
"declaration": "export interface TokenUsage {\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens?: number;\n cacheWriteTokens?: number;\n reasoningTokens?: number;\n}"
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
"name": "ToolCallBlock",
|
|
418
|
+
"declaration": "export interface ToolCallBlock {\n type: 'tool-call';\n id: CallId;\n name: string;\n arguments: string;\n}"
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
"name": "ToolMessageSource",
|
|
422
|
+
"declaration": "export interface ToolMessageSource {\n kind: 'tool';\n callId: CallId;\n}"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"name": "ToolResultBlock",
|
|
426
|
+
"declaration": "export interface ToolResultBlock {\n type: 'tool-result';\n toolCallId: CallId;\n content: ContentBlock[];\n isError?: boolean;\n}"
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"name": "ToolResultMessage",
|
|
430
|
+
"declaration": "export interface ToolResultMessage extends Message {\n readonly role: 'user';\n readonly content: [ToolResultBlock];\n readonly source: ToolMessageSource;\n}"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"name": "ToolSchema",
|
|
434
|
+
"declaration": "export interface ToolSchema {\n name: string;\n description: string;\n parameters: Record<string, unknown>;\n}"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
"name": "TurnEndCancelCause",
|
|
438
|
+
"declaration": "export type TurnEndCancelCause = AgentCancelCause | { readonly kind: 'legacy'; };"
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"name": "TurnEndReason",
|
|
442
|
+
"declaration": "export type TurnEndReason = TurnEndReasonMap[keyof TurnEndReasonMap];"
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
"name": "TurnEndReasonMap",
|
|
446
|
+
"declaration": "export interface TurnEndReasonMap {\n completed: { kind: 'completed'; };\n aborted: { kind: 'aborted'; reason: TurnEndCancelCause; };\n blocked: { kind: 'blocked'; };\n error: { kind: 'error'; error: LlmFailure; };\n 'max-tokens': { kind: 'max-tokens'; };\n interrupted: { kind: 'interrupted'; };\n}"
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
"name": "UserMessage",
|
|
450
|
+
"declaration": "export interface UserMessage extends Message {\n readonly role: 'user';\n}"
|
|
451
|
+
}
|
|
452
|
+
]
|
|
453
|
+
}
|
|
454
|
+
],
|
|
455
|
+
"events": [],
|
|
456
|
+
"objects": []
|
|
457
|
+
},
|
|
458
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* Generated by @deepseek-ai/dsh-typert-generator from the Host FaceModel — do not edit. */
|
|
2
|
+
import type {
|
|
3
|
+
RemoteResult,
|
|
4
|
+
TypertRemoteContribution,
|
|
5
|
+
} from '@deepseek-ai/dsh-typert-protocol'
|
|
6
|
+
import type { SessionReferenceMentionCandidate } from '@deepseek-ai/dsh-session-reference/types'
|
|
7
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
|
8
|
+
|
|
9
|
+
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
10
|
+
interface TypertRemoteNamespace$73657373696f6e5265666572656e63655265736f6c766572 {
|
|
11
|
+
candidates: (agentId: SessionId, query: string, signal?: AbortSignal) => Promise<RemoteResult<SessionReferenceMentionCandidate[]>>
|
|
12
|
+
}
|
|
13
|
+
interface TypertRemoteMap {
|
|
14
|
+
'sessionReferenceResolver/candidates': (agentId: SessionId, query: string, signal?: AbortSignal) => Promise<RemoteResult<SessionReferenceMentionCandidate[]>>
|
|
15
|
+
}
|
|
16
|
+
interface TypertRemoteNamespaceMap {
|
|
17
|
+
'sessionReferenceResolver': TypertRemoteNamespace$73657373696f6e5265666572656e63655265736f6c766572
|
|
18
|
+
}
|
|
19
|
+
interface TypertRemoteScopeMap {
|
|
20
|
+
'agent:sessionReferenceResolver/candidates': (query: string, signal?: AbortSignal) => Promise<RemoteResult<SessionReferenceMentionCandidate[]>>
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export declare const TYPERT_REMOTE: TypertRemoteContribution
|
|
25
|
+
export default TYPERT_REMOTE
|
|
26
|
+
//# sourceMappingURL=typert.remote-client.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* Generated by @deepseek-ai/dsh-typert-generator from the Host FaceModel — do not edit. */
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
const _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_parameter_0$schema = z.intersection(z.string(), z.unknown())
|
|
5
|
+
const _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_parameter_1$schema = z.string()
|
|
6
|
+
const _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_result$schema = z.array(z.object({
|
|
7
|
+
'mention': z.string(),
|
|
8
|
+
'sessionId': z.intersection(z.string(), z.unknown()),
|
|
9
|
+
'label': z.string(),
|
|
10
|
+
'cwd': z.string().optional(),
|
|
11
|
+
'createdAt': z.number(),
|
|
12
|
+
}))
|
|
13
|
+
|
|
14
|
+
export const TYPERT_REMOTE = {
|
|
15
|
+
package: '@deepseek-ai/dsh-session-reference',
|
|
16
|
+
descriptors: [
|
|
17
|
+
{
|
|
18
|
+
id: '@deepseek-ai/dsh-session-reference#sessionReferenceResolver/candidates',
|
|
19
|
+
service: 'sessionReferenceResolver',
|
|
20
|
+
namespace: 'sessionReferenceResolver',
|
|
21
|
+
method: 'candidates',
|
|
22
|
+
implementation: 'remoteExportCandidates',
|
|
23
|
+
invocation: { kind: 'direct' },
|
|
24
|
+
scope: {
|
|
25
|
+
context: 'agent',
|
|
26
|
+
wire: 'agentId',
|
|
27
|
+
},
|
|
28
|
+
parameters: [
|
|
29
|
+
{
|
|
30
|
+
name: 'agent',
|
|
31
|
+
wire: 'agentId',
|
|
32
|
+
source: 'lookup',
|
|
33
|
+
lookup: 'agent',
|
|
34
|
+
codec: {
|
|
35
|
+
mode: 'strict',
|
|
36
|
+
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
37
|
+
schema: _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_parameter_0$schema,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'query',
|
|
42
|
+
wire: 'query',
|
|
43
|
+
source: 'json',
|
|
44
|
+
codec: {
|
|
45
|
+
mode: 'strict',
|
|
46
|
+
typeSymbol: '@deepseek-ai/dsh-session-reference#sessionReferenceResolver/candidates:query',
|
|
47
|
+
schema: _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_parameter_1$schema,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
cancellation: { parameter: 'signal' },
|
|
52
|
+
result: {
|
|
53
|
+
mode: 'strict',
|
|
54
|
+
typeSymbol: '@deepseek-ai/dsh-session-reference#sessionReferenceResolver/candidates:result',
|
|
55
|
+
schema: _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_result$schema,
|
|
56
|
+
},
|
|
57
|
+
sourceLocation: {"file":"packages/context/session-reference/src/index.ts","line":218,"column":9},
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default TYPERT_REMOTE
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Configuration and stable diagnostics for session references. */
|
|
2
|
+
/** Hard maximum references accepted by one message. */
|
|
3
|
+
export const MAX_REFERENCES = 3;
|
|
4
|
+
/** Default number of discovery candidates returned to a host. */
|
|
5
|
+
export const DEFAULT_CANDIDATE_LIMIT = 50;
|
|
6
|
+
/** Default UTF-8 budget for one rendered reference JSON object. */
|
|
7
|
+
export const DEFAULT_MAX_REFERENCE_BYTES = 65_536;
|
|
8
|
+
/** Typed session-reference failure suitable for host protocol error mapping. */
|
|
9
|
+
export class SessionReferenceError extends Error {
|
|
10
|
+
code;
|
|
11
|
+
/** @param message Human-readable diagnosis. @param code Stable routing code. @param options Optional cause. */
|
|
12
|
+
constructor(message, code, options) {
|
|
13
|
+
super(message, options);
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.name = 'SessionReferenceError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=config.js.map
|
package/lib/types/index.d.ts
CHANGED
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module @deepseek-ai/dsh-session-reference
|
|
6
6
|
*/
|
|
7
|
-
import { Context
|
|
7
|
+
import { Context } from '@deepseek-ai/cordis';
|
|
8
8
|
import z from '@deepseek-ai/schemastery';
|
|
9
9
|
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
10
|
+
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
10
11
|
import type { ContentBlock } from '@deepseek-ai/dsh-llm';
|
|
11
12
|
import { type Config } from './config.ts';
|
|
12
|
-
import type { PreparedReferencedMessage, SessionReferenceCandidate, SessionReferenceInput } from './types.ts';
|
|
13
|
+
import type { PreparedReferencedMessage, SessionReferenceCandidate, SessionReferenceInput, SessionReferenceMentionCandidate } from './types.ts';
|
|
13
14
|
export type * from './types.ts';
|
|
14
15
|
export type { Config, SessionReferenceErrorCode } from './config.ts';
|
|
15
16
|
export { DEFAULT_CANDIDATE_LIMIT, DEFAULT_MAX_REFERENCE_BYTES, MAX_REFERENCES, SessionReferenceError, } from './config.ts';
|
|
@@ -20,11 +21,20 @@ declare module '@deepseek-ai/cordis' {
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
/** Exact-read consumer that prepares immutable cross-session message context. */
|
|
23
|
-
export declare class SessionReferenceResolver extends
|
|
24
|
+
export declare class SessionReferenceResolver extends TypertRemoteService {
|
|
24
25
|
static inject: string[];
|
|
25
26
|
static Config: z<Config>;
|
|
26
27
|
private readonly config;
|
|
27
28
|
constructor(ctx: Context, config?: Config);
|
|
29
|
+
/**
|
|
30
|
+
* Replace canonical mentions in direct user messages and place each prepared
|
|
31
|
+
* snapshot immediately after the message that cited it.
|
|
32
|
+
* @param agent - agent entering the model step.
|
|
33
|
+
* @param messages - messages accepted by downstream pre-step listeners.
|
|
34
|
+
* @param signal - active turn cancellation.
|
|
35
|
+
* @returns direct messages followed by their session-reference context in citation order.
|
|
36
|
+
*/
|
|
37
|
+
private prepareDirectMessages;
|
|
28
38
|
/**
|
|
29
39
|
* List reference candidates, ranked by working-directory affinity.
|
|
30
40
|
* @param agent - target agent; self is excluded and its cwd drives ranking.
|
|
@@ -35,11 +45,21 @@ export declare class SessionReferenceResolver extends Service {
|
|
|
35
45
|
*/
|
|
36
46
|
listCandidates(agent: Agent, query?: string, limit?: number, signal?: AbortSignal): Promise<SessionReferenceCandidate[]>;
|
|
37
47
|
/**
|
|
38
|
-
*
|
|
48
|
+
* Remote face of {@link listCandidates}: the configured candidate limit
|
|
49
|
+
* applies, and every candidate carries the canonical mention a host inserts
|
|
50
|
+
* into the prompt draft.
|
|
51
|
+
* @param agent - target agent; self is excluded and its cwd drives ranking.
|
|
52
|
+
* @param query - optional case-insensitive session-id/cwd/title substring.
|
|
53
|
+
* @param signal - caller cancellation.
|
|
54
|
+
* @returns mention-carrying candidates in rank order.
|
|
55
|
+
*/
|
|
56
|
+
remoteExportCandidates(agent: Agent, query: string, signal: AbortSignal): Promise<SessionReferenceMentionCandidate[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Snapshot all references for one accepted direct message and return one aggregated durable context.
|
|
39
59
|
* @param agent - target agent; references to it are rejected.
|
|
40
60
|
* @param content - already host-normalized readable message content.
|
|
41
61
|
* @param references - structured source sessions in mention order.
|
|
42
|
-
* @param signal - optional cancellation boundary for
|
|
62
|
+
* @param signal - optional cancellation boundary for the active turn.
|
|
43
63
|
* @returns detached content and optional referenced-session context.
|
|
44
64
|
*/
|
|
45
65
|
prepare(agent: Agent, content: ContentBlock[], references: SessionReferenceInput[], signal?: AbortSignal): Promise<PreparedReferencedMessage>;
|