@artenx/dshb 0.1.6 → 0.1.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.md +1 -1
- package/lib/auth/index.js +10 -2
- package/lib/auth/index.js.map +1 -1
- package/lib/client.js +1 -1
- package/lib/client.js.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/workspace-instruction-context.d.ts +281 -122
- package/lib/core/workspace-instruction-context.js +1 -1
- package/lib/exec-docker/docker-backend.d.ts +1 -1
- package/lib/exec-docker/docker-client.d.ts +1 -1
- package/lib/exec-docker/docker-client.js +4 -1
- package/lib/exec-docker/docker-client.js.map +1 -1
- package/lib/exec-docker/process-provider.js +39 -5
- package/lib/exec-docker/process-provider.js.map +1 -1
- package/lib/exec-docker/remote-docker-cli.d.ts +1 -1
- package/lib/exec-docker/remote-docker-cli.js +1 -1
- package/lib/exec-docker/remote-docker-cli.js.map +1 -1
- package/lib/exec-ssh/executor.d.ts +1 -2
- package/lib/exec-ssh/executor.js +7 -5
- package/lib/exec-ssh/executor.js.map +1 -1
- package/lib/exec-ssh/process-provider.js +36 -5
- package/lib/exec-ssh/process-provider.js.map +1 -1
- package/lib/router/decorate-shell.d.ts +11 -2
- package/lib/router/decorate-shell.js +80 -18
- package/lib/router/decorate-shell.js.map +1 -1
- package/lib/router/router-shell.d.ts +2 -3
- package/lib/router/router-shell.js +4 -13
- package/lib/router/router-shell.js.map +1 -1
- package/lib/{workspace-instruction-context-CxUldQkP.js → workspace-instruction-context-DzHFTN87.js} +156 -76
- package/lib/workspace-instruction-context-DzHFTN87.js.map +1 -0
- package/package.json +34 -33
- package/lib/workspace-instruction-context-CxUldQkP.js.map +0 -1
package/lib/core/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { registerRemoteDownloadRoutes, registerWorkspaceRoutes } from "./workspa
|
|
|
8
8
|
import { sharedWorkspaceInstructionStore } from "./workspace-instructions.js";
|
|
9
9
|
import { registerWorkspaceInstructionRoutes } from "./workspace-instruction-routes.js";
|
|
10
10
|
import { WorkspaceBindingsStore } from "./workspace-bindings.js";
|
|
11
|
-
import { a as registerWorkspaceInstructionInjector } from "../workspace-instruction-context-
|
|
11
|
+
import { a as registerWorkspaceInstructionInjector } from "../workspace-instruction-context-DzHFTN87.js";
|
|
12
12
|
//#region src/core/index.ts
|
|
13
13
|
const name = "dshb-core";
|
|
14
14
|
const inject = ["webServer", "credentials"];
|
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
import { SessionInstructionSnapshot, SessionInstructionSnapshotStore, WorkspaceInstructionStore } from "./workspace-instructions.js";
|
|
2
2
|
import { Context, Service } from "@deepseek-ai/cordis";
|
|
3
3
|
import { FileAttachmentRef, ImageAttachmentRef } from "@deepseek-ai/dsh-attachment";
|
|
4
|
+
//#region ../../node_modules/@deepseek-ai/dsh-brand/lib/types/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Duplicate-install-safe nominal primitive helpers.
|
|
7
|
+
*
|
|
8
|
+
* A brand makes structurally identical strings or numbers non-interchangeable
|
|
9
|
+
* at the type level: a `SessionId` cannot be passed where a `ToolCallId` is
|
|
10
|
+
* expected, and an event sequence cannot be passed as a log offset. Comparison,
|
|
11
|
+
* logging, and serialization retain the underlying primitive behavior.
|
|
12
|
+
*
|
|
13
|
+
* This package owns no concrete domain value and keeps no runtime identity or mutable
|
|
14
|
+
* state, so independently installed copies produce interchangeable values.
|
|
15
|
+
*
|
|
16
|
+
* @module @deepseek-ai/dsh-brand
|
|
17
|
+
*/
|
|
18
|
+
declare const BRAND: unique symbol;
|
|
19
|
+
/** A string carrying a compile-time-only brand `B`. */
|
|
20
|
+
type Branded<B extends string> = string & {
|
|
21
|
+
readonly [BRAND]: B;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region ../../node_modules/@deepseek-ai/dsh-typert-protocol/lib/types/owned-value.d.ts
|
|
25
|
+
/** Generic invocation-owned values returned by synchronous Client Context resolvers. */
|
|
26
|
+
/** Shared identity across independently bundled Context providers and Gateway. */
|
|
27
|
+
declare const TYPERT_OWNED_VALUE: unique symbol;
|
|
28
|
+
/** A borrowed payload paired with the invocation owner's idempotent cleanup. */
|
|
29
|
+
interface TypertOwnedValue<Value> extends Disposable {
|
|
30
|
+
readonly [TYPERT_OWNED_VALUE]: true;
|
|
31
|
+
readonly value: Value;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
4
34
|
//#region ../../node_modules/@deepseek-ai/dsh-typert-protocol/lib/types/types.d.ts
|
|
5
35
|
declare const LOOKUP_HOST: unique symbol;
|
|
6
36
|
declare const LOOKUP_WIRE: unique symbol;
|
|
@@ -40,7 +70,21 @@ interface TypertSchema<Output = unknown> {
|
|
|
40
70
|
type TypertCodec = {
|
|
41
71
|
readonly mode: 'strict';
|
|
42
72
|
readonly typeSymbol: string;
|
|
43
|
-
|
|
73
|
+
/** Materialize and return the process-realm schema on first boundary use. */
|
|
74
|
+
readonly create: () => TypertSchema;
|
|
75
|
+
/**
|
|
76
|
+
* Decode a unary result whose fields require type-specific handling.
|
|
77
|
+
* @param value - result reconstructed by the RPC carrier.
|
|
78
|
+
* @returns the validated result, retaining native byte views.
|
|
79
|
+
*/
|
|
80
|
+
readonly decode?: (value: unknown) => unknown;
|
|
81
|
+
/**
|
|
82
|
+
* Project typed binary fields into RPC result attachments.
|
|
83
|
+
* @param value - native unary result.
|
|
84
|
+
* @param writeBytes - records a byte view at its result-relative path and returns its JSON placeholder.
|
|
85
|
+
* @returns JSON metadata with untouched JSON subtrees retained.
|
|
86
|
+
*/
|
|
87
|
+
readonly encode?: (value: unknown, writeBytes: (bytes: Uint8Array, path: readonly (string | number)[]) => null) => unknown;
|
|
44
88
|
} | {
|
|
45
89
|
readonly mode: 'src-json';
|
|
46
90
|
};
|
|
@@ -77,7 +121,7 @@ interface InvocationDescriptor {
|
|
|
77
121
|
readonly method: string;
|
|
78
122
|
/** Service member invoked when the exported method name is an alias. */
|
|
79
123
|
readonly implementation?: string;
|
|
80
|
-
/** Absent for unary calls; stream calls
|
|
124
|
+
/** Absent for unary calls; stream calls deliver every yielded item as the Host produced it. */
|
|
81
125
|
readonly mode?: 'stream';
|
|
82
126
|
/** Receiver selection mode. */
|
|
83
127
|
readonly invocation: {
|
|
@@ -97,6 +141,16 @@ interface InvocationDescriptor {
|
|
|
97
141
|
};
|
|
98
142
|
/** Ordered business parameters. */
|
|
99
143
|
readonly parameters: readonly InvocationParameterDescriptor[];
|
|
144
|
+
/**
|
|
145
|
+
* Client-to-Host items of the same logical stream, generated from the `In`
|
|
146
|
+
* type argument of the method's `RemoteStream<Out, In>` return type; absent
|
|
147
|
+
* when `In` is `never`. The method reads the items through
|
|
148
|
+
* `RemoteInvocation.uplink()`, so nothing enters the parameter list.
|
|
149
|
+
*/
|
|
150
|
+
readonly uplink?: {
|
|
151
|
+
/** Codec validating every uplink item before `uplink()` delivers it. */
|
|
152
|
+
readonly codec: TypertCodec;
|
|
153
|
+
};
|
|
100
154
|
/** Transport cancellation injected after business parameters instead of entering wire args. */
|
|
101
155
|
readonly cancellation?: {
|
|
102
156
|
/** Reserved final Host method parameter. */
|
|
@@ -107,6 +161,56 @@ interface InvocationDescriptor {
|
|
|
107
161
|
/** Source declaration used only for diagnostics. */
|
|
108
162
|
readonly sourceLocation?: InvocationSourceLocation;
|
|
109
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Opaque identity of one Peer: a party admitted to this Host by the connection
|
|
166
|
+
* layer. "Peer" is a connection-layer word; the browser application keeps the
|
|
167
|
+
* word "Client".
|
|
168
|
+
*/
|
|
169
|
+
type PeerId = Branded<'PeerId'>;
|
|
170
|
+
/**
|
|
171
|
+
* One Peer's session on this Host. Connection owns it: `ctx` is the Cordis
|
|
172
|
+
* scope that owns connection-lifetime registrations and is disposed with the
|
|
173
|
+
* Peer. Who the Peer is and what it may do are not recorded here.
|
|
174
|
+
*/
|
|
175
|
+
interface PeerScope {
|
|
176
|
+
readonly id: PeerId;
|
|
177
|
+
readonly ctx: Context;
|
|
178
|
+
/**
|
|
179
|
+
* Tear down every registration made through `ctx`.
|
|
180
|
+
* @returns settles once the scope has quiesced; racing calls share one completion.
|
|
181
|
+
*/
|
|
182
|
+
dispose(): Promise<void>;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The context of one Remote call, reachable inside the receiving method as
|
|
186
|
+
* `this.ctx.invocation`. The Gateway derives the receiver from a Context that
|
|
187
|
+
* carries it, so no parameter is injected and nothing crosses the wire.
|
|
188
|
+
*/
|
|
189
|
+
interface RemoteInvocation {
|
|
190
|
+
readonly request: {
|
|
191
|
+
readonly namespace: string;
|
|
192
|
+
readonly method: string;
|
|
193
|
+
readonly args: Readonly<Record<string, unknown>>;
|
|
194
|
+
};
|
|
195
|
+
/** Cordis service key of the receiving Service. */
|
|
196
|
+
readonly service: string;
|
|
197
|
+
/** Peer the call speaks for; an in-process carrier speaks for the operator. */
|
|
198
|
+
readonly peer: PeerScope;
|
|
199
|
+
/** Carrier cancellation: Client cancel, socket close, or an uplink failure. */
|
|
200
|
+
readonly signal: AbortSignal;
|
|
201
|
+
/**
|
|
202
|
+
* The Client's uplink items for this call. Available once; a second call
|
|
203
|
+
* throws. With an uplink codec on the descriptor every item is decoded to
|
|
204
|
+
* `In`; without one items arrive as `unknown` after a JSON-safety check.
|
|
205
|
+
* Iteration ends when the Client ends its uplink; when the method finishes
|
|
206
|
+
* its downlink the Gateway calls the iterator's `return()` and unread items
|
|
207
|
+
* are dropped. `In` is the caller's assertion: the runtime decodes by the
|
|
208
|
+
* descriptor and does not cross-check it.
|
|
209
|
+
* @template In - item type the caller reads; the descriptor codec decides what arrives.
|
|
210
|
+
* @returns the single-consumer uplink iterable.
|
|
211
|
+
*/
|
|
212
|
+
uplink<In = unknown>(): AsyncIterable<In>;
|
|
213
|
+
}
|
|
110
214
|
/** Generated Host contract selected explicitly by a Client assembly. */
|
|
111
215
|
interface TypertRemoteContribution {
|
|
112
216
|
/** npm package that owns the Remote methods. */
|
|
@@ -174,11 +278,11 @@ interface TypertClientContextAdapter<Wire = unknown> {
|
|
|
174
278
|
*/
|
|
175
279
|
identity(ctx: Context): Wire | undefined;
|
|
176
280
|
/**
|
|
177
|
-
* Resolve a
|
|
281
|
+
* Resolve a validated identity synchronously for one Client invocation.
|
|
178
282
|
* @param id - validated wire identity.
|
|
179
|
-
* @returns
|
|
283
|
+
* @returns a borrowed or invocation-owned Client Context, or undefined when unavailable.
|
|
180
284
|
*/
|
|
181
|
-
resolve(id: Wire): Context | undefined;
|
|
285
|
+
resolve(id: Wire): Context | TypertOwnedValue<Context> | undefined;
|
|
182
286
|
}
|
|
183
287
|
/** Notification emitted after a Typert runtime registry changes. */
|
|
184
288
|
interface TypertRegistryChange {
|
|
@@ -320,6 +424,12 @@ interface TypertRegistryContract {
|
|
|
320
424
|
declare module '@deepseek-ai/cordis' {
|
|
321
425
|
interface Context {
|
|
322
426
|
typert: TypertRegistryContract;
|
|
427
|
+
/**
|
|
428
|
+
* The Remote call this Context was derived for, or `undefined` on a
|
|
429
|
+
* Context no Remote call derived. A Service method reads it as
|
|
430
|
+
* `this.ctx.invocation`.
|
|
431
|
+
*/
|
|
432
|
+
readonly invocation: RemoteInvocation | undefined;
|
|
323
433
|
}
|
|
324
434
|
}
|
|
325
435
|
//#endregion
|
|
@@ -348,26 +458,6 @@ declare abstract class TypertRemoteService<out T = never> extends Service<T> {
|
|
|
348
458
|
protected constructor(ctx: Context, serviceKey: string, options?: TypertGatewayBindingOptions);
|
|
349
459
|
}
|
|
350
460
|
//#endregion
|
|
351
|
-
//#region ../../node_modules/@deepseek-ai/dsh-brand/lib/types/index.d.ts
|
|
352
|
-
/**
|
|
353
|
-
* Duplicate-install-safe nominal primitive helpers.
|
|
354
|
-
*
|
|
355
|
-
* A brand makes structurally identical strings or numbers non-interchangeable
|
|
356
|
-
* at the type level: a `SessionId` cannot be passed where a `ToolCallId` is
|
|
357
|
-
* expected, and an event sequence cannot be passed as a log offset. Comparison,
|
|
358
|
-
* logging, and serialization retain the underlying primitive behavior.
|
|
359
|
-
*
|
|
360
|
-
* This package owns no concrete domain value and keeps no runtime identity or mutable
|
|
361
|
-
* state, so independently installed copies produce interchangeable values.
|
|
362
|
-
*
|
|
363
|
-
* @module @deepseek-ai/dsh-brand
|
|
364
|
-
*/
|
|
365
|
-
declare const BRAND: unique symbol;
|
|
366
|
-
/** A string carrying a compile-time-only brand `B`. */
|
|
367
|
-
type Branded<B extends string> = string & {
|
|
368
|
-
readonly [BRAND]: B;
|
|
369
|
-
};
|
|
370
|
-
//#endregion
|
|
371
461
|
//#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/brand.d.ts
|
|
372
462
|
/** Stable identity carried by one message across inbox, log, and model-request boundaries. */
|
|
373
463
|
type MessageId = Branded<'MessageId'>;
|
|
@@ -407,7 +497,7 @@ declare function ReasoningEffortId(id: string): ReasoningEffortId;
|
|
|
407
497
|
//#endregion
|
|
408
498
|
//#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/message.d.ts
|
|
409
499
|
/** Provider/model identity and adapter-private replay data for an assistant message. */
|
|
410
|
-
interface
|
|
500
|
+
interface AssistantProviderMetadata {
|
|
411
501
|
/** Provider route that produced the message. */
|
|
412
502
|
provider: string;
|
|
413
503
|
/** Provider model id that produced the message. */
|
|
@@ -420,81 +510,87 @@ interface AssistantProvenance {
|
|
|
420
510
|
replayState?: unknown;
|
|
421
511
|
}
|
|
422
512
|
/** Required source of an assistant message produced by a routed model. */
|
|
423
|
-
interface ModelMessageSource extends
|
|
513
|
+
interface ModelMessageSource extends AssistantProviderMetadata {
|
|
424
514
|
kind: 'model';
|
|
425
515
|
}
|
|
426
|
-
/** Required source of a
|
|
516
|
+
/** Required source of a tool-role message carrying one tool result. */
|
|
427
517
|
interface ToolMessageSource {
|
|
428
518
|
kind: 'tool';
|
|
429
519
|
callId: ToolCallId;
|
|
430
520
|
}
|
|
431
|
-
/**
|
|
432
|
-
interface
|
|
433
|
-
|
|
434
|
-
readonly name: string;
|
|
435
|
-
/** That contribution's model-facing text, exactly as assembled. */
|
|
436
|
-
readonly text: string;
|
|
521
|
+
/** Required source of a system-role message produced by the system-prompt plugin. */
|
|
522
|
+
interface SystemPromptMessageSource {
|
|
523
|
+
kind: 'system-prompt';
|
|
437
524
|
}
|
|
438
525
|
/**
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
* account, a `snapshot` its sections. Omitting `form` stays valid — an
|
|
445
|
-
* undeclared context is the documented default.
|
|
446
|
-
*/
|
|
447
|
-
type ContextFormed = {
|
|
448
|
-
readonly form?: never;
|
|
449
|
-
} | {
|
|
450
|
-
readonly form: 'instructions';
|
|
451
|
-
} | {
|
|
452
|
-
readonly form: 'catalog';
|
|
453
|
-
} | {
|
|
454
|
-
readonly form: 'snapshot';
|
|
455
|
-
/** The named contributions this snapshot assembled, in order. */
|
|
456
|
-
readonly sections: readonly ContextSnapshotSection[];
|
|
457
|
-
} | {
|
|
458
|
-
readonly form: 'notice';
|
|
459
|
-
/** One-line account of what happened, shown without expanding the row. */
|
|
460
|
-
readonly summary: string;
|
|
461
|
-
} | {
|
|
462
|
-
readonly form: 'relay';
|
|
463
|
-
} | {
|
|
464
|
-
readonly form: 'recall';
|
|
465
|
-
};
|
|
466
|
-
/**
|
|
467
|
-
* Where a message (or injected content) came from.
|
|
468
|
-
* Merge-extensible sum type — plugins add their own `kind`s.
|
|
526
|
+
* Where a message (or injected content) came from, in the harness's own
|
|
527
|
+
* vocabulary. Merge-extensible sum type — each producer declares its own
|
|
528
|
+
* `kind` in its own module; there is no shared catch-all `plugin` kind.
|
|
529
|
+
* Model and tool sources answer their role messages; user messages carry any
|
|
530
|
+
* producer's kind, and consumers fall through unknown kinds.
|
|
469
531
|
*/
|
|
470
532
|
interface MessageSourceMap {
|
|
471
533
|
user: {
|
|
472
534
|
kind: 'user';
|
|
473
535
|
};
|
|
474
|
-
plugin: {
|
|
475
|
-
kind: 'plugin';
|
|
476
|
-
plugin: string;
|
|
477
|
-
} & ContextFormed;
|
|
478
536
|
model: ModelMessageSource;
|
|
479
537
|
tool: ToolMessageSource;
|
|
538
|
+
'system-prompt': SystemPromptMessageSource;
|
|
480
539
|
}
|
|
481
540
|
/** Any known message source, derived from {@link MessageSourceMap}; switch on `kind` and fall through unknowns (merge-extensible). */
|
|
482
541
|
type MessageSource = MessageSourceMap[keyof MessageSourceMap];
|
|
483
|
-
/**
|
|
484
|
-
interface
|
|
542
|
+
/** Shared immutable fields of every conversation message. */
|
|
543
|
+
interface MessageBase {
|
|
485
544
|
/** Stable identity preserved across every representation boundary. */
|
|
486
545
|
readonly id: MessageId;
|
|
487
|
-
/** Provider-neutral conversation role. */
|
|
488
|
-
readonly role: 'system' | 'user' | 'assistant';
|
|
489
546
|
/** Exact model-facing blocks. */
|
|
490
|
-
readonly content: ContentBlock[];
|
|
491
|
-
/** Required source fields supplied by the producer.
|
|
547
|
+
readonly content: readonly ContentBlock[];
|
|
548
|
+
/** Required source fields supplied by the producer.
|
|
549
|
+
* @persistenceSource user developer
|
|
550
|
+
*/
|
|
492
551
|
readonly source: MessageSource;
|
|
493
552
|
}
|
|
494
|
-
/** A
|
|
495
|
-
interface
|
|
553
|
+
/** A rendered system prompt attributed to the system-prompt producer; empty content sends no prompt. */
|
|
554
|
+
interface SystemMessage extends MessageBase {
|
|
555
|
+
readonly role: 'system';
|
|
556
|
+
readonly source: MessageSourceMap['system-prompt'];
|
|
557
|
+
}
|
|
558
|
+
/** Incremental agent session changes in conversation order, currently tool additions and removals. */
|
|
559
|
+
interface DeveloperMessage extends MessageBase {
|
|
560
|
+
readonly role: 'developer';
|
|
561
|
+
}
|
|
562
|
+
/** A user-role specialization of the shared message representation. */
|
|
563
|
+
interface UserMessage extends MessageBase {
|
|
496
564
|
readonly role: 'user';
|
|
497
565
|
}
|
|
566
|
+
/** A model-produced assistant specialization of the shared message representation. */
|
|
567
|
+
interface AssistantMessage extends MessageBase {
|
|
568
|
+
readonly role: 'assistant';
|
|
569
|
+
readonly source: ModelMessageSource;
|
|
570
|
+
}
|
|
571
|
+
/** A first-class tool-role message carrying the result of one tool invocation. */
|
|
572
|
+
interface ToolResultMessage extends MessageBase {
|
|
573
|
+
readonly role: 'tool';
|
|
574
|
+
readonly source: ToolMessageSource;
|
|
575
|
+
/** Provider-issued id of the tool call this message answers. */
|
|
576
|
+
readonly toolCallId: ToolCallId;
|
|
577
|
+
/** Whether the tool invocation failed. */
|
|
578
|
+
readonly isError?: boolean;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* The conversation messages persisted by Session, keyed by role. This map is
|
|
582
|
+
* closed because every model-visible role must have a durable Session event
|
|
583
|
+
* and an adapter projection.
|
|
584
|
+
*/
|
|
585
|
+
interface MessageRoleMap {
|
|
586
|
+
system: SystemMessage;
|
|
587
|
+
developer: DeveloperMessage;
|
|
588
|
+
user: UserMessage;
|
|
589
|
+
assistant: AssistantMessage;
|
|
590
|
+
tool: ToolResultMessage;
|
|
591
|
+
}
|
|
592
|
+
/** Any persisted conversation message, discriminated by its `role`. */
|
|
593
|
+
type Message = MessageRoleMap[keyof MessageRoleMap];
|
|
498
594
|
type NewUserMessage = Omit<UserMessage, 'id' | 'role'>;
|
|
499
595
|
/**
|
|
500
596
|
* Create one identified user-role message and freeze it before publication.
|
|
@@ -533,6 +629,13 @@ interface LlmFailure {
|
|
|
533
629
|
readonly providerRetryAfterMs?: number;
|
|
534
630
|
/** Opaque provider-issued request identifier for diagnostics. */
|
|
535
631
|
readonly requestId?: ProviderRequestId;
|
|
632
|
+
/**
|
|
633
|
+
* With code `IMAGE_OFFLOAD_REQUIRED`: how many more of the oldest retained
|
|
634
|
+
* image occurrences the route needs offloaded before the same request fits
|
|
635
|
+
* its exact byte accounting. `dsh-compaction-image-offload` records the
|
|
636
|
+
* selected occurrences in an `image/offload` event and retries the step.
|
|
637
|
+
*/
|
|
638
|
+
readonly offloadImages?: number;
|
|
536
639
|
}
|
|
537
640
|
/** Plain text visible to the end user. */
|
|
538
641
|
interface TextBlock {
|
|
@@ -554,6 +657,12 @@ interface ImageBlock {
|
|
|
554
657
|
type: 'image';
|
|
555
658
|
/** Immutable bytes and intrinsic display metadata owned by the attachment service. */
|
|
556
659
|
attachment: ImageAttachmentRef;
|
|
660
|
+
/**
|
|
661
|
+
* Derived from a durable image-offload decision or preserved by a message
|
|
662
|
+
* rewrite. Every route sends placeholder text naming the image and its
|
|
663
|
+
* available read-only path instead of image bytes.
|
|
664
|
+
*/
|
|
665
|
+
offloaded?: true;
|
|
557
666
|
}
|
|
558
667
|
/**
|
|
559
668
|
* A durable verbatim file reference, valid in user content. Files never reach
|
|
@@ -576,16 +685,27 @@ interface ToolCallBlock {
|
|
|
576
685
|
/** Raw JSON string as produced by the model. */
|
|
577
686
|
arguments: string;
|
|
578
687
|
}
|
|
579
|
-
/**
|
|
580
|
-
interface
|
|
581
|
-
type: 'tool-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
688
|
+
/** Activates a tool definition from the developer event's referenced request header. */
|
|
689
|
+
interface ToolAdditionBlock {
|
|
690
|
+
type: 'tool-addition';
|
|
691
|
+
/** Name of exactly one tool in the referenced historical header. */
|
|
692
|
+
toolName: string;
|
|
693
|
+
/**
|
|
694
|
+
* Reserved against inline definitions; the historical request header owns the schema.
|
|
695
|
+
* @persistenceReserved
|
|
696
|
+
*/
|
|
697
|
+
tool?: never;
|
|
698
|
+
}
|
|
699
|
+
/** Records the dynamic removal of a tool identified by its session-local name. */
|
|
700
|
+
interface ToolRemovalBlock {
|
|
701
|
+
type: 'tool-removal';
|
|
702
|
+
toolName: string;
|
|
585
703
|
}
|
|
586
704
|
/**
|
|
587
705
|
* Merge-extensible content blocks keyed by `type`. New core blocks must land
|
|
588
|
-
* with adapter, UI, and compaction support.
|
|
706
|
+
* with adapter, UI, and compaction support. Developer tool-change blocks are
|
|
707
|
+
* reserved for Session V4 persistence; providers and UI reject them until
|
|
708
|
+
* their producers and consumers are implemented together.
|
|
589
709
|
*/
|
|
590
710
|
interface ContentBlockMap {
|
|
591
711
|
'text': TextBlock;
|
|
@@ -593,7 +713,8 @@ interface ContentBlockMap {
|
|
|
593
713
|
'image': ImageBlock;
|
|
594
714
|
'file': FileBlock;
|
|
595
715
|
'tool-call': ToolCallBlock;
|
|
596
|
-
'tool-
|
|
716
|
+
'tool-addition': ToolAdditionBlock;
|
|
717
|
+
'tool-removal': ToolRemovalBlock;
|
|
597
718
|
}
|
|
598
719
|
/** The block `type` tag vocabulary; widens as plugins add entries to {@link ContentBlockMap}. */
|
|
599
720
|
type ContentBlockType = keyof ContentBlockMap;
|
|
@@ -670,10 +791,11 @@ interface LlmImageRequestPrice {
|
|
|
670
791
|
interface LlmImageRequestPricing {
|
|
671
792
|
/**
|
|
672
793
|
* Price every image occurrence of one request projection.
|
|
673
|
-
* @param images -
|
|
794
|
+
* @param images - surface image blocks in request order, one entry per occurrence; an `offloaded` block
|
|
795
|
+
* is priced as its placeholder text.
|
|
674
796
|
* @returns one price per occurrence, aligned by index with `images`.
|
|
675
797
|
*/
|
|
676
|
-
priceImages(images: readonly
|
|
798
|
+
priceImages(images: readonly ImageBlock[]): readonly LlmImageRequestPrice[];
|
|
677
799
|
}
|
|
678
800
|
/** Display metadata for one registered provider route. */
|
|
679
801
|
interface LlmProviderInfo {
|
|
@@ -766,6 +888,8 @@ interface LlmDiscoveredModel {
|
|
|
766
888
|
contextWindow?: number;
|
|
767
889
|
/** Maximum output tokens, when disclosed. */
|
|
768
890
|
maxTokens?: number;
|
|
891
|
+
/** Accepted input types when disclosed by the catalog or endpoint; absent means unknown. */
|
|
892
|
+
inputModalities?: readonly ModelModality[];
|
|
769
893
|
}
|
|
770
894
|
/** One adapter-discovered model; catalog membership is advisory, not request validation. */
|
|
771
895
|
interface LlmModelInfo {
|
|
@@ -889,11 +1013,26 @@ type StreamChunk = {
|
|
|
889
1013
|
* it from this package.
|
|
890
1014
|
*/
|
|
891
1015
|
interface ToolSchema {
|
|
1016
|
+
/**
|
|
1017
|
+
* Requests deferred loading of the tool definition into model context,
|
|
1018
|
+
* independently of whether a tool-addition block records the tool.
|
|
1019
|
+
* Uses Anthropic's defer_loading terminology.
|
|
1020
|
+
*/
|
|
1021
|
+
deferLoading?: true;
|
|
892
1022
|
name: string;
|
|
893
1023
|
description: string;
|
|
894
1024
|
/** JSON Schema object for the arguments. */
|
|
895
1025
|
parameters: Record<string, unknown>;
|
|
896
1026
|
}
|
|
1027
|
+
/** User input for one LLM request; it has no durable Session identity or source. */
|
|
1028
|
+
interface RequestUserInput {
|
|
1029
|
+
readonly role: 'user';
|
|
1030
|
+
readonly content: UserMessage['content'];
|
|
1031
|
+
readonly id?: never;
|
|
1032
|
+
readonly source?: never;
|
|
1033
|
+
}
|
|
1034
|
+
/** A durable conversation message or a user input used only for one request. */
|
|
1035
|
+
type RequestMessage = Message | RequestUserInput;
|
|
897
1036
|
/** A single model request, fully assembled. */
|
|
898
1037
|
interface GenerateOptions {
|
|
899
1038
|
/** Registered provider route selecting the adapter instance. */
|
|
@@ -905,9 +1044,9 @@ interface GenerateOptions {
|
|
|
905
1044
|
* Ordered conversation messages, exactly as the provider sees them. A
|
|
906
1045
|
* loop-built request passes the derived history (dsh-agent-loop), whose
|
|
907
1046
|
* leading system-role message carries the system prompt; a hand-built
|
|
908
|
-
* one-shot
|
|
1047
|
+
* one-shot may include identity-free user inputs.
|
|
909
1048
|
*/
|
|
910
|
-
messages:
|
|
1049
|
+
messages: RequestMessage[];
|
|
911
1050
|
/**
|
|
912
1051
|
* System prompt text for one-shot callers; adapters map it to the provider's
|
|
913
1052
|
* system slot ahead of `messages`. Loop-built requests leave it undefined.
|
|
@@ -956,6 +1095,16 @@ declare namespace Binary {
|
|
|
956
1095
|
/** String/symbol keyed dictionary type. */
|
|
957
1096
|
type Dict<T = any, K extends string | symbol = string> = { [key in K]: T; };
|
|
958
1097
|
//#endregion
|
|
1098
|
+
//#region ../../node_modules/@deepseek-ai/cosmokit/lib/types/volatile.d.ts
|
|
1099
|
+
/** Shared config references used by schema validators and plugin runtimes. */
|
|
1100
|
+
/** Recursively readonly data returned by a volatile config reference. */
|
|
1101
|
+
type VolatileSnapshot<T> = T extends object ? { readonly [K in keyof T]: VolatileSnapshot<T[K]>; } : T;
|
|
1102
|
+
/** A stable reference; keep the reference, or capture its value for one operation only. */
|
|
1103
|
+
interface Volatile<T> {
|
|
1104
|
+
/** @returns the current immutable snapshot, including undefined for an absent value. */
|
|
1105
|
+
get(): VolatileSnapshot<T>;
|
|
1106
|
+
}
|
|
1107
|
+
//#endregion
|
|
959
1108
|
//#region ../../node_modules/@standard-schema/spec/dist/index.d.ts
|
|
960
1109
|
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
961
1110
|
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
@@ -1038,9 +1187,9 @@ declare const kSchema: unique symbol;
|
|
|
1038
1187
|
declare global {
|
|
1039
1188
|
namespace Schemastery {
|
|
1040
1189
|
/** Convert primitive constructors, constants, and existing schemas into a schema type. */
|
|
1041
|
-
type From<X> = X extends string | number | boolean ? Schema<X> : X extends Schema ? X : X extends typeof String ? Schema<string> : X extends typeof Number ? Schema<number> : X extends typeof Boolean ? Schema<boolean> : X extends typeof Function ? Schema<Function, (...args: any[]) => any> : X extends Constructor<infer S> ? Schema<S> : never;
|
|
1042
|
-
type TypeS1<X> = X extends Schema<infer S,
|
|
1043
|
-
type Inverse<X> = X extends Schema<
|
|
1190
|
+
type From<X> = X extends string | number | boolean ? Schema<X> : X extends Schema<any, any, SchemaMode> ? X : X extends typeof String ? Schema<string> : X extends typeof Number ? Schema<number> : X extends typeof Boolean ? Schema<boolean> : X extends typeof Function ? Schema<Function, (...args: any[]) => any> : X extends Constructor<infer S> ? Schema<S> : never;
|
|
1191
|
+
type TypeS1<X> = X extends Schema<infer S, infer _T, infer _M> ? S : never;
|
|
1192
|
+
type Inverse<X> = X extends Schema<infer _S, infer T, infer M> ? (arg: SchemaOutput<T, M>) => void : never;
|
|
1044
1193
|
/** Input type accepted by a schema-like value. */
|
|
1045
1194
|
type TypeS<X> = TypeS1<From<X>>;
|
|
1046
1195
|
/** Output type returned by a schema-like value after validation. */
|
|
@@ -1048,7 +1197,7 @@ declare global {
|
|
|
1048
1197
|
/** Resolver callback used by custom schema types registered with `Schema.extend()`. */
|
|
1049
1198
|
type Resolve = (data: any, schema: Schema, options: Options, strict?: boolean) => [any, any?];
|
|
1050
1199
|
/** Input type accepted by one schema in an intersection. */
|
|
1051
|
-
type IntersectS<X> = From<X> extends Schema<infer S,
|
|
1200
|
+
type IntersectS<X> = From<X> extends Schema<infer S, infer _T, infer _M> ? S : never;
|
|
1052
1201
|
/** Output type returned by one schema in an intersection. */
|
|
1053
1202
|
type IntersectT<X> = Inverse<From<X>> extends ((arg: infer T) => void) ? T : never;
|
|
1054
1203
|
type TupleS<X extends readonly any[]> = X extends readonly [infer L, ...infer R] ? [TypeS<L>?, ...TupleS<R>] : any[];
|
|
@@ -1103,8 +1252,8 @@ declare global {
|
|
|
1103
1252
|
dict<X, Y extends Schema<any, string> = Schema<string>>(inner: X, sKey?: Y): Schema<Dict<TypeS<X>, TypeS<Y>>, Dict<TypeT<X>, TypeT<Y>>>;
|
|
1104
1253
|
/** Accept tuple arrays where each index matches the corresponding schema. */
|
|
1105
1254
|
tuple<const X extends readonly any[]>(list: X): Schema<TupleS<X>, TupleT<X>>;
|
|
1106
|
-
/** Accept plain objects
|
|
1107
|
-
object<X extends Dict>(dict: X): Schema<ObjectS<X
|
|
1255
|
+
/** Accept plain objects; infer fields from the dictionary, not the enclosing schema's output type. */
|
|
1256
|
+
object<X extends Dict>(dict: X): Schema<ObjectS<NoInfer<X>>, ObjectT<NoInfer<X>>>;
|
|
1108
1257
|
/** Accept values matching at least one schema in `list`. */
|
|
1109
1258
|
union<const X>(list: readonly X[]): Schema<TypeS<X>, TypeT<X>>;
|
|
1110
1259
|
/** Accept values matching every schema in `list`, merging object outputs. */
|
|
@@ -1112,7 +1261,7 @@ declare global {
|
|
|
1112
1261
|
/** Validate with `inner`, then convert the result with `callback`. */
|
|
1113
1262
|
transform<X, T>(inner: X, callback: (value: TypeS<X>, options: Schemastery.Options) => T, preserve?: boolean): Schema<TypeS<X>, T>;
|
|
1114
1263
|
/** Defer construction of a recursive schema until validation or serialization. */
|
|
1115
|
-
lazy<X extends Schema
|
|
1264
|
+
lazy<X extends Schema<any, any, SchemaMode>>(callback: () => X): X;
|
|
1116
1265
|
ValidationError: typeof ValidationError;
|
|
1117
1266
|
}
|
|
1118
1267
|
/** Runtime validation options shared by all schema calls. */
|
|
@@ -1128,6 +1277,8 @@ declare global {
|
|
|
1128
1277
|
interface Meta<T = any> {
|
|
1129
1278
|
default?: T extends {} ? Partial<T> : T;
|
|
1130
1279
|
required?: boolean;
|
|
1280
|
+
/** Parse this node as a stable config reference; its type and UI metadata remain unchanged. */
|
|
1281
|
+
volatile?: boolean;
|
|
1131
1282
|
disabled?: boolean;
|
|
1132
1283
|
collapse?: boolean;
|
|
1133
1284
|
badges?: {
|
|
@@ -1151,9 +1302,9 @@ declare global {
|
|
|
1151
1302
|
}
|
|
1152
1303
|
}
|
|
1153
1304
|
/** Callable schema instance that validates input and returns normalized output. */
|
|
1154
|
-
interface Schemastery<S = any, T = S> {
|
|
1155
|
-
(data?: S | null, options?: Schemastery.Options): T
|
|
1156
|
-
new (data?: S | null, options?: Schemastery.Options): T
|
|
1305
|
+
interface Schemastery<S = any, T = S, Mode extends SchemaMode = 'plain'> {
|
|
1306
|
+
(data?: S | null, options?: Schemastery.Options): SchemaOutput<T, Mode>;
|
|
1307
|
+
new (data?: S | null, options?: Schemastery.Options): SchemaOutput<T, Mode>;
|
|
1157
1308
|
[kSchema]: true;
|
|
1158
1309
|
uid: number;
|
|
1159
1310
|
meta: Schemastery.Meta<T>;
|
|
@@ -1173,49 +1324,54 @@ declare global {
|
|
|
1173
1324
|
/** Format this schema as a compact TypeScript-like type string. */
|
|
1174
1325
|
toString(inline?: boolean): string;
|
|
1175
1326
|
/** Serialize this schema, preserving shared and recursive references. */
|
|
1176
|
-
toJSON(): Schema<S, T>;
|
|
1327
|
+
toJSON(): Schema<S, T, Mode>;
|
|
1177
1328
|
/** Mark nullable input as invalid unless a default supplies a fallback. */
|
|
1178
|
-
required(value?:
|
|
1329
|
+
required<R extends boolean = true>(value?: R): Schema<S, T, SetRequired<Mode, R>>;
|
|
1330
|
+
/**
|
|
1331
|
+
* Parse this config field as a stable reference containing immutable data.
|
|
1332
|
+
* @returns a schema whose output supports get(), including when the field is absent.
|
|
1333
|
+
*/
|
|
1334
|
+
volatile(): Schema<NoInfer<S>, NoInfer<T>, Mode extends 'defined' | 'volatile-defined' ? 'volatile-defined' : 'volatile'>;
|
|
1179
1335
|
/** Hide this schema node from UI renderers. */
|
|
1180
|
-
hidden(value?: boolean): Schema<S, T>;
|
|
1336
|
+
hidden(value?: boolean): Schema<S, T, Mode>;
|
|
1181
1337
|
/** Return the default value instead of throwing when validation fails. */
|
|
1182
|
-
loose(value?: boolean): Schema<S, T>;
|
|
1338
|
+
loose(value?: boolean): Schema<S, T, Mode>;
|
|
1183
1339
|
/** Attach a renderer role and optional role-specific metadata. */
|
|
1184
|
-
role(text: string, extra?: any): Schema<S, T>;
|
|
1340
|
+
role(text: string, extra?: any): Schema<S, T, Mode>;
|
|
1185
1341
|
/** Attach an external documentation link. */
|
|
1186
|
-
link(link: string): Schema<S, T>;
|
|
1342
|
+
link(link: string): Schema<S, T, Mode>;
|
|
1187
1343
|
/** Set the fallback value used for nullable input. */
|
|
1188
|
-
default(value: T): Schema<S, T
|
|
1344
|
+
default(value: T | NoInfer<Partial<S>>): Schema<S, T, SetRequired<Mode, true>>;
|
|
1189
1345
|
/** Attach an auxiliary comment for documentation or form UIs. */
|
|
1190
|
-
comment(text: string): Schema<S, T>;
|
|
1346
|
+
comment(text: string): Schema<S, T, Mode>;
|
|
1191
1347
|
/** Attach a localized or plain description for documentation or form UIs. */
|
|
1192
|
-
description(text: string): Schema<S, T>;
|
|
1348
|
+
description(text: string): Schema<S, T, Mode>;
|
|
1193
1349
|
/** Mark this schema node as disabled for form UIs. */
|
|
1194
|
-
disabled(value?: boolean): Schema<S, T>;
|
|
1350
|
+
disabled(value?: boolean): Schema<S, T, Mode>;
|
|
1195
1351
|
/** Request collapsed rendering for nested form UIs. */
|
|
1196
|
-
collapse(value?: boolean): Schema<S, T>;
|
|
1352
|
+
collapse(value?: boolean): Schema<S, T, Mode>;
|
|
1197
1353
|
/** Add a deprecated badge to this schema node. */
|
|
1198
|
-
deprecated(): Schema<S, T>;
|
|
1354
|
+
deprecated(): Schema<S, T, Mode>;
|
|
1199
1355
|
/** Add an experimental badge to this schema node. */
|
|
1200
|
-
experimental(): Schema<S, T>;
|
|
1356
|
+
experimental(): Schema<S, T, Mode>;
|
|
1201
1357
|
/** Require strings to match a regular expression. */
|
|
1202
|
-
pattern(regexp: RegExp): Schema<S, T>;
|
|
1358
|
+
pattern(regexp: RegExp): Schema<S, T, Mode>;
|
|
1203
1359
|
/** Set an inclusive maximum for numbers or collection lengths. */
|
|
1204
|
-
max(value: number): Schema<S, T>;
|
|
1360
|
+
max(value: number): Schema<S, T, Mode>;
|
|
1205
1361
|
/** Set an inclusive minimum for numbers or collection lengths. */
|
|
1206
|
-
min(value: number): Schema<S, T>;
|
|
1362
|
+
min(value: number): Schema<S, T, Mode>;
|
|
1207
1363
|
/** Set the numeric increment constraint. */
|
|
1208
|
-
step(value: number): Schema<S, T>;
|
|
1364
|
+
step(value: number): Schema<S, T, Mode>;
|
|
1209
1365
|
/** Add or replace an object property schema. */
|
|
1210
|
-
set(key: string, value: Schema): Schema<S, T>;
|
|
1366
|
+
set(key: string, value: Schema): Schema<S, T, Mode>;
|
|
1211
1367
|
/** Append a tuple, union, or intersection member schema. */
|
|
1212
|
-
push(value: Schema): Schema<S, T>;
|
|
1368
|
+
push(value: Schema): Schema<S, T, Mode>;
|
|
1213
1369
|
/** Remove values equal to schema defaults from normalized output. */
|
|
1214
1370
|
simplify(value?: any): any;
|
|
1215
1371
|
/** Return a schema clone with descriptions merged from locale messages. */
|
|
1216
|
-
i18n(messages: Dict): Schema<S, T>;
|
|
1372
|
+
i18n(messages: Dict): Schema<S, T, Mode>;
|
|
1217
1373
|
/** Attach arbitrary metadata consumed by form renderers and downstream tools. */
|
|
1218
|
-
extra<K extends keyof Schemastery.Meta>(key: K, value: Schemastery.Meta[K]): Schema<S, T>;
|
|
1374
|
+
extra<K extends keyof Schemastery.Meta>(key: K, value: Schemastery.Meta[K]): Schema<S, T, Mode>;
|
|
1219
1375
|
}
|
|
1220
1376
|
}
|
|
1221
1377
|
declare class ValidationError extends TypeError {
|
|
@@ -1224,7 +1380,10 @@ declare class ValidationError extends TypeError {
|
|
|
1224
1380
|
constructor(message: string, options: Schemastery.Options);
|
|
1225
1381
|
static is(error: any): error is ValidationError;
|
|
1226
1382
|
}
|
|
1227
|
-
type
|
|
1383
|
+
type SchemaMode = 'plain' | 'defined' | 'volatile' | 'volatile-defined';
|
|
1384
|
+
type SchemaOutput<T, M extends SchemaMode> = M extends 'volatile' ? Volatile<T | undefined> : M extends 'volatile-defined' ? Volatile<T> : T;
|
|
1385
|
+
type SetRequired<M extends SchemaMode, R extends boolean> = M extends 'volatile' | 'volatile-defined' ? R extends true ? 'volatile-defined' : 'volatile' : R extends true ? 'defined' : 'plain';
|
|
1386
|
+
type Schema<S = any, T = S, Mode extends SchemaMode = 'plain'> = Schemastery<S, T, Mode>;
|
|
1228
1387
|
declare const Schema: Schemastery.Static;
|
|
1229
1388
|
//#endregion
|
|
1230
1389
|
//#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/retry-policy.d.ts
|
|
@@ -1285,8 +1444,8 @@ declare module '@deepseek-ai/cordis' {
|
|
|
1285
1444
|
* process-local {@link markAgentLoopRequest} identity and arrives deep-frozen
|
|
1286
1445
|
* (mutation throws): its content is a pure function of the session log (the
|
|
1287
1446
|
* reconstructability Agent Note), so listeners read it, never rewrite it.
|
|
1288
|
-
* Hand-built calls do not carry that marker;
|
|
1289
|
-
* the
|
|
1447
|
+
* Hand-built calls do not carry that marker; callers own their request
|
|
1448
|
+
* inputs and must keep them unchanged until the stream settles.
|
|
1290
1449
|
* @mode waterfall
|
|
1291
1450
|
*/
|
|
1292
1451
|
'llm/stream'(this: LlmRuntime, options: GenerateOptions, next: () => AsyncIterable<StreamChunk>): AsyncIterable<StreamChunk>;
|