@artenx/dshb 0.1.2 → 0.1.4

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.
@@ -0,0 +1,1667 @@
1
+ import { SessionInstructionSnapshot, SessionInstructionSnapshotStore, WorkspaceInstructionStore } from "./workspace-instructions.js";
2
+ import { Context, Service } from "@deepseek-ai/cordis";
3
+ import { FileAttachmentRef, ImageAttachmentRef } from "@deepseek-ai/dsh-attachment";
4
+ //#region ../../node_modules/@deepseek-ai/dsh-typert-protocol/lib/types/types.d.ts
5
+ declare const LOOKUP_HOST: unique symbol;
6
+ declare const LOOKUP_WIRE: unique symbol;
7
+ declare const CONTEXT_WIRE: unique symbol;
8
+ /** Type-level association between a Host object and its wire identity. */
9
+ interface TypertLookup<Host, Wire> {
10
+ readonly [LOOKUP_HOST]: Host;
11
+ readonly [LOOKUP_WIRE]: Wire;
12
+ }
13
+ /** Extract the Host object associated with one lookup declaration. */
14
+ type TypertLookupHost<Lookup> = Lookup extends TypertLookup<infer Host, infer _Wire> ? Host : never;
15
+ /** Extract the wire identity associated with one lookup declaration. */
16
+ type TypertLookupWire<Lookup> = Lookup extends TypertLookup<infer _Host, infer Wire> ? Wire : never;
17
+ /** Type-level association between a scoped Context kind and its wire identity. */
18
+ interface TypertContext<Wire> {
19
+ readonly [CONTEXT_WIRE]: Wire;
20
+ }
21
+ /** Extract the wire identity associated with one scoped Context declaration. */
22
+ type TypertContextWire<ContextType> = ContextType extends TypertContext<infer Wire> ? Wire : never;
23
+ /** Merge-extensible Host object lookup declarations. */
24
+ interface TypertLookupMap {}
25
+ /** Merge-extensible scoped Context declarations. */
26
+ interface TypertContextMap {}
27
+ /** Awaitable disposer returned by Cordis-owned Typert registrations. */
28
+ type TypertDisposer = () => Promise<void>;
29
+ type StringKeyOf<Value> = Extract<keyof Value, string>;
30
+ /** Minimal runtime-schema capability carried by strict generated codecs. */
31
+ interface TypertSchema<Output = unknown> {
32
+ /**
33
+ * Parse and validate one boundary value.
34
+ * @param value - untrusted boundary value.
35
+ * @returns the validated value.
36
+ */
37
+ parse(value: unknown): Output;
38
+ }
39
+ /** Codec attached to one invocation parameter or result. */
40
+ type TypertCodec = {
41
+ readonly mode: 'strict';
42
+ readonly typeSymbol: string;
43
+ readonly schema: TypertSchema;
44
+ } | {
45
+ readonly mode: 'src-json';
46
+ };
47
+ /** One ordered business parameter in a Remote invocation. */
48
+ interface InvocationParameterDescriptor {
49
+ /** Source-level parameter name. */
50
+ readonly name: string;
51
+ /** Required key in the wire `args` object. */
52
+ readonly wire: string;
53
+ /** Whether the value is JSON or requires a registered Host lookup. */
54
+ readonly source: 'json' | 'lookup';
55
+ /** Lookup key when `source` is `lookup`. */
56
+ readonly lookup?: string;
57
+ /** Boundary codec for the wire representation. */
58
+ readonly codec: TypertCodec;
59
+ /** Missing wire fields decode to `undefined` only for an explicitly declared `T | undefined`. */
60
+ readonly acceptsUndefined?: true;
61
+ }
62
+ /** Source position retained for diagnostics from generated definitions. */
63
+ interface InvocationSourceLocation {
64
+ readonly file: string;
65
+ readonly line: number;
66
+ readonly column: number;
67
+ }
68
+ /** Carrier-independent description of one exported method invocation. */
69
+ interface InvocationDescriptor {
70
+ /** Globally stable generated identity. */
71
+ readonly id: string;
72
+ /** Cordis service key owning the method. */
73
+ readonly service: string;
74
+ /** Wire namespace, defaulting to the service key. */
75
+ readonly namespace: string;
76
+ /** Public instance method name. */
77
+ readonly method: string;
78
+ /** Service member invoked when the exported method name is an alias. */
79
+ readonly implementation?: string;
80
+ /** Absent for unary calls; stream calls validate and deliver every yielded item. */
81
+ readonly mode?: 'stream';
82
+ /** Receiver selection mode. */
83
+ readonly invocation: {
84
+ readonly kind: 'direct';
85
+ } | {
86
+ readonly kind: 'context';
87
+ readonly context: string;
88
+ readonly wire: string;
89
+ readonly codec: TypertCodec;
90
+ };
91
+ /** Optional consuming-Context projection for one direct lookup parameter. */
92
+ readonly scope?: {
93
+ /** Context kind whose Client adapter supplies the identity. */
94
+ readonly context: string;
95
+ /** Lookup parameter wire field replaced by the Context identity. */
96
+ readonly wire: string;
97
+ };
98
+ /** Ordered business parameters. */
99
+ readonly parameters: readonly InvocationParameterDescriptor[];
100
+ /** Transport cancellation injected after business parameters instead of entering wire args. */
101
+ readonly cancellation?: {
102
+ /** Reserved final Host method parameter. */
103
+ readonly parameter: 'signal';
104
+ };
105
+ /** Codec for the unary result or each yielded stream item. */
106
+ readonly result: TypertCodec;
107
+ /** Source declaration used only for diagnostics. */
108
+ readonly sourceLocation?: InvocationSourceLocation;
109
+ }
110
+ /** Generated Host contract selected explicitly by a Client assembly. */
111
+ interface TypertRemoteContribution {
112
+ /** npm package that owns the Remote methods. */
113
+ readonly package: string;
114
+ /** Consumer-side invocation descriptors generated from that package. */
115
+ readonly descriptors: readonly InvocationDescriptor[];
116
+ }
117
+ /**
118
+ * Resolve one validated wire identity, synchronously or asynchronously.
119
+ * @param id - validated wire identity.
120
+ * @returns the Host object, or `undefined` when unavailable.
121
+ */
122
+ type TypertLookupResolver<Host = unknown, Wire = unknown> = (id: Wire) => Host | undefined | Promise<Host | undefined>;
123
+ /** Runtime provider for one declared Host object lookup. */
124
+ interface TypertLookupProvider<Host = unknown, Wire = unknown> {
125
+ /** Source parameter name recognized by the SRC weak parser. */
126
+ readonly parameter: string;
127
+ /** Wire field replacing the Host object parameter. */
128
+ readonly wire: string;
129
+ /** Canonical Host type symbol used by strict generation. */
130
+ readonly hostTypeSymbol: string;
131
+ /** Canonical wire type symbol used by strict generation. */
132
+ readonly wireTypeSymbol: string;
133
+ /**
134
+ * Resolve a wire identity through the provider's default policy.
135
+ * @param id - validated wire identity.
136
+ * @returns the object, `undefined` when unavailable, or either asynchronously.
137
+ */
138
+ resolve(id: Wire): Host | undefined | Promise<Host | undefined>;
139
+ }
140
+ /** Stable wire declaration retained after a lookup provider unloads. */
141
+ interface TypertLookupDefinition {
142
+ /** Merge-declared lookup key. */
143
+ readonly key: string;
144
+ /** Source parameter name recognized by the SRC weak parser. */
145
+ readonly parameter: string;
146
+ /** Wire field replacing the Host object parameter. */
147
+ readonly wire: string;
148
+ /** Canonical Host type symbol used by strict generation. */
149
+ readonly hostTypeSymbol: string;
150
+ /** Canonical wire type symbol used by strict generation. */
151
+ readonly wireTypeSymbol: string;
152
+ }
153
+ /** Host wire-to-Context resolver plus the declaration used by strict Remote methods. */
154
+ interface TypertHostContextAdapter<Wire = unknown> {
155
+ /** Wire field carrying the Context identity. */
156
+ readonly wire: string;
157
+ /** Canonical wire type symbol used by strict generation. */
158
+ readonly wireTypeSymbol: string;
159
+ /**
160
+ * Resolve a validated wire identity to a live Host Context.
161
+ * @param id - validated wire identity.
162
+ * @returns the Context, or `undefined` when it is unavailable.
163
+ */
164
+ resolve(id: Wire): Context | undefined | Promise<Context | undefined>;
165
+ }
166
+ /** Composition-owned resolver replacing one Host Context adapter's default lookup policy. */
167
+ type TypertHostContextResolver<Wire = unknown> = (id: Wire) => Context | undefined | Promise<Context | undefined>;
168
+ /** Client-side bidirectional Context adapter. */
169
+ interface TypertClientContextAdapter<Wire = unknown> {
170
+ /**
171
+ * Read the identity represented by a live Client Context.
172
+ * @param ctx - Client Context inspected by a scoped Remote caller.
173
+ * @returns the wire identity, or `undefined` for another Context kind.
174
+ */
175
+ identity(ctx: Context): Wire | undefined;
176
+ /**
177
+ * Resolve a wire identity from the Client's currently materialized Contexts.
178
+ * @param id - validated wire identity.
179
+ * @returns the Client Context, or `undefined` when unavailable.
180
+ */
181
+ resolve(id: Wire): Context | undefined;
182
+ }
183
+ /** Notification emitted after a Typert runtime registry changes. */
184
+ interface TypertRegistryChange {
185
+ readonly kind: 'local' | 'remote' | 'lookup' | 'host-context' | 'client-context';
186
+ readonly key: string;
187
+ }
188
+ /** Listener for one Typert runtime registry. */
189
+ type TypertRegistryListener = (change: TypertRegistryChange) => void;
190
+ /** Current-environment invocation definitions. */
191
+ interface TypertLocalRegistry {
192
+ /**
193
+ * Look up one invocation by `<namespace>/<method>`.
194
+ * @param endpoint - canonical endpoint.
195
+ * @returns the live descriptor, or `undefined` when absent.
196
+ */
197
+ get(endpoint: string): InvocationDescriptor | undefined;
198
+ /**
199
+ * Report whether a strict definition has existed during this Typert Service lifetime.
200
+ * @param endpoint - canonical endpoint.
201
+ * @returns `true` after the endpoint has been registered at least once, even if withdrawn.
202
+ */
203
+ hasSeen(endpoint: string): boolean;
204
+ /** @returns a registration-order snapshot of local descriptors. */
205
+ list(): readonly InvocationDescriptor[];
206
+ /**
207
+ * Observe later local-definition changes.
208
+ * @param listener - synchronous contained observer.
209
+ * @returns disposer for this subscription.
210
+ */
211
+ subscribe(listener: TypertRegistryListener): TypertDisposer;
212
+ }
213
+ /** Consumer-selected Remote contribution registry. */
214
+ interface TypertRemoteRegistry {
215
+ /**
216
+ * Register one generated contribution for the calling Cordis fiber.
217
+ * @param contribution - generated Remote descriptors.
218
+ * @returns disposer withdrawing the exact contribution.
219
+ */
220
+ register(contribution: TypertRemoteContribution): TypertDisposer;
221
+ /**
222
+ * Look up one Remote descriptor by endpoint.
223
+ * @param endpoint - canonical endpoint.
224
+ * @returns the descriptor, or `undefined` when unmounted.
225
+ */
226
+ get(endpoint: string): InvocationDescriptor | undefined;
227
+ /** @returns a registration-order snapshot of Remote descriptors. */
228
+ list(): readonly InvocationDescriptor[];
229
+ /**
230
+ * Observe later Remote contribution changes.
231
+ * @param listener - synchronous contained observer.
232
+ * @returns disposer for this subscription.
233
+ */
234
+ subscribe(listener: TypertRegistryListener): TypertDisposer;
235
+ }
236
+ /** Runtime registry for Host object lookup providers. */
237
+ interface TypertLookupRegistry {
238
+ /**
239
+ * Register one provider under its merge-declared key.
240
+ * @param key - lookup key.
241
+ * @param provider - owning package's live resolver.
242
+ * @returns disposer withdrawing the exact provider.
243
+ */
244
+ register<K extends StringKeyOf<TypertLookupMap>>(key: K, provider: TypertLookupProvider<TypertLookupHost<TypertLookupMap[K]>, TypertLookupWire<TypertLookupMap[K]>>): TypertDisposer;
245
+ /**
246
+ * Replace one provider's default resolution policy while this contribution is active.
247
+ * Configuration may precede provider registration; without a live provider, `get()` remains unavailable.
248
+ * @param key - lookup key whose wire declaration remains provider-owned.
249
+ * @param resolver - composition-owned resolver used by every lookup of this key.
250
+ * @returns disposer restoring the provider's default resolver.
251
+ */
252
+ configure<K extends StringKeyOf<TypertLookupMap>>(key: K, resolver: TypertLookupResolver<TypertLookupHost<TypertLookupMap[K]>, TypertLookupWire<TypertLookupMap[K]>>): TypertDisposer;
253
+ /**
254
+ * Look up one provider by runtime key.
255
+ * @param key - descriptor lookup key.
256
+ * @returns the live provider, or `undefined` when absent.
257
+ */
258
+ get(key: string): TypertLookupProvider | undefined;
259
+ /** @returns lookup declarations observed during this Typert Service lifetime. */
260
+ definitions(): readonly TypertLookupDefinition[];
261
+ /** @returns a snapshot of registered provider keys. */
262
+ keys(): readonly string[];
263
+ /**
264
+ * Observe later lookup changes.
265
+ * @param listener - synchronous contained observer.
266
+ * @returns disposer for this subscription.
267
+ */
268
+ subscribe(listener: TypertRegistryListener): TypertDisposer;
269
+ }
270
+ /** Runtime registry for the Host and Client adapters of each Context kind. */
271
+ interface TypertContextRegistry {
272
+ /**
273
+ * Register a Host Context adapter.
274
+ * @param key - merge-declared Context key.
275
+ * @param adapter - owning package's Host resolver and wire declaration.
276
+ * @returns disposer withdrawing the exact adapter.
277
+ */
278
+ registerHost<K extends StringKeyOf<TypertContextMap>>(key: K, adapter: TypertHostContextAdapter<TypertContextWire<TypertContextMap[K]>>): TypertDisposer;
279
+ /**
280
+ * Override one Host Context key's resolution policy for the calling fiber.
281
+ * Configuration may precede provider registration and restores the provider's default resolver on disposal.
282
+ * @param key - merge-declared Context key.
283
+ * @param resolver - composition-owned resolver used by every Host Context lookup of this key.
284
+ * @returns disposer restoring the provider's default resolver.
285
+ */
286
+ configureHost<K extends StringKeyOf<TypertContextMap>>(key: K, resolver: TypertHostContextResolver<TypertContextWire<TypertContextMap[K]>>): TypertDisposer;
287
+ /**
288
+ * Register a Client Context adapter.
289
+ * @param key - merge-declared Context key.
290
+ * @param adapter - owning package's bidirectional Client projection.
291
+ * @returns disposer withdrawing the exact adapter.
292
+ */
293
+ registerClient<K extends StringKeyOf<TypertContextMap>>(key: K, adapter: TypertClientContextAdapter<TypertContextWire<TypertContextMap[K]>>): TypertDisposer;
294
+ /**
295
+ * Look up a Host Context adapter.
296
+ * @param key - descriptor Context key.
297
+ * @returns the adapter, or `undefined` when absent.
298
+ */
299
+ getHost(key: string): TypertHostContextAdapter | undefined;
300
+ /**
301
+ * Look up a Client Context adapter.
302
+ * @param key - descriptor Context key.
303
+ * @returns the adapter, or `undefined` when absent.
304
+ */
305
+ getClient(key: string): TypertClientContextAdapter | undefined;
306
+ /**
307
+ * Observe later Context adapter changes.
308
+ * @param listener - synchronous contained observer.
309
+ * @returns disposer for this subscription.
310
+ */
311
+ subscribe(listener: TypertRegistryListener): TypertDisposer;
312
+ }
313
+ /** Minimal Typert runtime consumed through dependency inversion. */
314
+ interface TypertRegistryContract {
315
+ readonly local: TypertLocalRegistry;
316
+ readonly remotes: TypertRemoteRegistry;
317
+ readonly lookups: TypertLookupRegistry;
318
+ readonly contexts: TypertContextRegistry;
319
+ }
320
+ declare module '@deepseek-ai/cordis' {
321
+ interface Context {
322
+ typert: TypertRegistryContract;
323
+ }
324
+ }
325
+ //#endregion
326
+ //#region ../../node_modules/@deepseek-ai/dsh-typert-protocol/lib/types/index.d.ts
327
+ /** Options for an explicit Service-to-Gateway binding. */
328
+ interface TypertGatewayBindingOptions {
329
+ /** Wire namespace; defaults to the Cordis service key. */
330
+ readonly namespace?: string;
331
+ }
332
+ /** Visible declaration that one Service participates in Typert Gateway export. */
333
+ interface TypertGatewayBinding<Service extends object = object> {
334
+ readonly service: Service;
335
+ readonly serviceKey: string;
336
+ readonly namespace: string;
337
+ }
338
+ /** Cordis Service base that exposes its registered name through Typert Gateway. */
339
+ declare abstract class TypertRemoteService<out T = never> extends Service<T> {
340
+ /** Visible binding consumed by the Gateway's source-mode discovery. */
341
+ readonly typertRemote: TypertGatewayBinding<this>;
342
+ /**
343
+ * Register the Service and bind the same key to Typert Gateway.
344
+ * @param ctx - owning Cordis Context.
345
+ * @param serviceKey - exact Cordis service key and default wire namespace.
346
+ * @param options - optional distinct wire namespace.
347
+ */
348
+ protected constructor(ctx: Context, serviceKey: string, options?: TypertGatewayBindingOptions);
349
+ }
350
+ //#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
+ //#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/brand.d.ts
372
+ /** Stable identity carried by one message across inbox, log, and model-request boundaries. */
373
+ type MessageId = Branded<'MessageId'>;
374
+ /**
375
+ * Brand a message identifier.
376
+ * @param id - the opaque message identifier.
377
+ * @returns the same string with the message-id brand.
378
+ */
379
+ declare function MessageId(id: string): MessageId;
380
+ /**
381
+ * Correlates a model-issued tool call with its result. Provider-issued for
382
+ * real adapters; synthesized by mocks/assembler fallbacks.
383
+ */
384
+ type ToolCallId = Branded<'ToolCallId'>;
385
+ /**
386
+ * Brand a string as a {@link ToolCallId}.
387
+ * @param id - the provider-issued or synthesized call id.
388
+ * @returns the same string with the tool-call-id brand.
389
+ */
390
+ declare function ToolCallId(id: string): ToolCallId;
391
+ /** Provider-issued request identifier retained for diagnostics across package boundaries. */
392
+ type ProviderRequestId = Branded<'ProviderRequestId'>;
393
+ /**
394
+ * Brand a provider-issued request identifier.
395
+ * @param id - the opaque provider-issued string.
396
+ * @returns the same string, branded; no validation is performed.
397
+ */
398
+ declare function ProviderRequestId(id: string): ProviderRequestId;
399
+ /** Adapter-owned identifier for one model's selectable reasoning effort. */
400
+ type ReasoningEffortId = Branded<'ReasoningEffortId'>;
401
+ /**
402
+ * Brand an adapter-owned reasoning-effort identifier.
403
+ * @param id - the opaque identifier exposed by one model capability.
404
+ * @returns the same string, branded; no validation is performed.
405
+ */
406
+ declare function ReasoningEffortId(id: string): ReasoningEffortId;
407
+ //#endregion
408
+ //#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/message.d.ts
409
+ /** Provider/model identity and adapter-private replay data for an assistant message. */
410
+ interface AssistantProvenance {
411
+ /** Provider route that produced the message. */
412
+ provider: string;
413
+ /** Provider model id that produced the message. */
414
+ model: string;
415
+ /**
416
+ * Lossless-JSON adapter state needed to replay the provider response.
417
+ * `LlmRuntime` exposes it to a target adapter only when that adapter instance
418
+ * currently owns both this historical provider and the target provider.
419
+ */
420
+ replayState?: unknown;
421
+ }
422
+ /** Required source of an assistant message produced by a routed model. */
423
+ interface ModelMessageSource extends AssistantProvenance {
424
+ kind: 'model';
425
+ }
426
+ /** Required source of a user-role message carrying one tool result. */
427
+ interface ToolMessageSource {
428
+ kind: 'tool';
429
+ callId: ToolCallId;
430
+ }
431
+ /** One named contribution to a `snapshot`-form context, in assembly order. */
432
+ interface ContextSnapshotSection {
433
+ /** The contributing subsystem's name. */
434
+ readonly name: string;
435
+ /** That contribution's model-facing text, exactly as assembled. */
436
+ readonly text: string;
437
+ }
438
+ /**
439
+ * Producer-declared {@link ContextForm} and the fields that form requires,
440
+ * mixed into the source types that carry one.
441
+ *
442
+ * Discriminated by `form` so a producer cannot select a form without the
443
+ * fields needed to present it: a `notice` must record its one-line
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.
469
+ */
470
+ interface MessageSourceMap {
471
+ user: {
472
+ kind: 'user';
473
+ };
474
+ plugin: {
475
+ kind: 'plugin';
476
+ plugin: string;
477
+ } & ContextFormed;
478
+ model: ModelMessageSource;
479
+ tool: ToolMessageSource;
480
+ }
481
+ /** Any known message source, derived from {@link MessageSourceMap}; switch on `kind` and fall through unknowns (merge-extensible). */
482
+ type MessageSource = MessageSourceMap[keyof MessageSourceMap];
483
+ /** One immutable message representation shared by delivery, durable history, and model requests. */
484
+ interface Message {
485
+ /** Stable identity preserved across every representation boundary. */
486
+ readonly id: MessageId;
487
+ /** Provider-neutral conversation role. */
488
+ readonly role: 'system' | 'user' | 'assistant';
489
+ /** Exact model-facing blocks. */
490
+ readonly content: ContentBlock[];
491
+ /** Required source fields supplied by the producer. */
492
+ readonly source: MessageSource;
493
+ }
494
+ /** A user-role specialization of the one shared message representation. */
495
+ interface UserMessage extends Message {
496
+ readonly role: 'user';
497
+ }
498
+ type NewUserMessage = Omit<UserMessage, 'id' | 'role'>;
499
+ /**
500
+ * Create one identified user-role message and freeze it before publication.
501
+ * @param input - complete content and source for a new user message.
502
+ * @returns an immutable user message with a fresh stable identity.
503
+ */
504
+ declare function createUserMessage<T extends NewUserMessage>(input: T & {
505
+ readonly id?: never;
506
+ readonly role?: never;
507
+ }): T & Pick<UserMessage, 'id' | 'role'>;
508
+ //#endregion
509
+ //#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/types.d.ts
510
+ declare module '@deepseek-ai/cordis' {
511
+ interface Events {
512
+ /**
513
+ * The provider topology changed: an adapter registered or unregistered
514
+ * routes, or the configurable-provider directory gained or lost entries.
515
+ * This payload-free registry notification fires at each commit point
516
+ * (including registration disposal); consumers re-read `listProviders()`,
517
+ * `listModels()`, or `listConfigurableProviders()` for the new state.
518
+ * Observer failures are contained and cannot veto the registry mutation.
519
+ * @mode emit
520
+ */
521
+ 'llm/adapters-updated'(): void;
522
+ }
523
+ }
524
+ /** Serializable provider or transport failure facts; policy decides whether they are retryable. */
525
+ interface LlmFailure {
526
+ /** Human-readable provider or transport failure. */
527
+ readonly message: string;
528
+ /** Stable provider-neutral machine-routing code. */
529
+ readonly code: string;
530
+ /** HTTP status returned by the provider, when available. */
531
+ readonly status?: number;
532
+ /** Provider-requested delay in milliseconds, when valid and available. */
533
+ readonly providerRetryAfterMs?: number;
534
+ /** Opaque provider-issued request identifier for diagnostics. */
535
+ readonly requestId?: ProviderRequestId;
536
+ }
537
+ /** Plain text visible to the end user. */
538
+ interface TextBlock {
539
+ type: 'text';
540
+ text: string;
541
+ }
542
+ /** Reasoning / thinking content, distinct from visible text. */
543
+ interface ReasoningBlock {
544
+ type: 'reasoning';
545
+ text: string;
546
+ }
547
+ /**
548
+ * A durable raster image reference, valid in user or assistant content. The
549
+ * block is deliberately role-neutral; assistant-side rendering is forward
550
+ * compatibility — the current production adapters declare text-only output,
551
+ * so only user messages may carry images.
552
+ */
553
+ interface ImageBlock {
554
+ type: 'image';
555
+ /** Immutable bytes and intrinsic display metadata owned by the attachment service. */
556
+ attachment: ImageAttachmentRef;
557
+ }
558
+ /**
559
+ * A durable verbatim file reference, valid in user content. Files never reach
560
+ * a provider natively: request assembly projects every occurrence to
561
+ * deterministic handle text (name, byte size, and the read-only saved path),
562
+ * so adapters and providers see text in its place while the durable log keeps
563
+ * the structured reference for presentation and authorization.
564
+ */
565
+ interface FileBlock {
566
+ type: 'file';
567
+ /** Immutable verbatim bytes and display metadata owned by the attachment service. */
568
+ attachment: FileAttachmentRef;
569
+ }
570
+ /** A tool invocation requested by the model. */
571
+ interface ToolCallBlock {
572
+ type: 'tool-call';
573
+ /** Provider-issued call id; correlates with the matching tool result. */
574
+ id: ToolCallId;
575
+ name: string;
576
+ /** Raw JSON string as produced by the model. */
577
+ arguments: string;
578
+ }
579
+ /** The result of a tool invocation, sent back to the model. */
580
+ interface ToolResultBlock {
581
+ type: 'tool-result';
582
+ toolCallId: ToolCallId;
583
+ content: ContentBlock[];
584
+ isError?: boolean;
585
+ }
586
+ /**
587
+ * Merge-extensible content blocks keyed by `type`. New core blocks must land
588
+ * with adapter, UI, and compaction support.
589
+ */
590
+ interface ContentBlockMap {
591
+ 'text': TextBlock;
592
+ 'reasoning': ReasoningBlock;
593
+ 'image': ImageBlock;
594
+ 'file': FileBlock;
595
+ 'tool-call': ToolCallBlock;
596
+ 'tool-result': ToolResultBlock;
597
+ }
598
+ /** The block `type` tag vocabulary; widens as plugins add entries to {@link ContentBlockMap}. */
599
+ type ContentBlockType = keyof ContentBlockMap;
600
+ /** Any known content block, derived from {@link ContentBlockMap}; switch on `type` and fall through unknowns (merge-extensible). */
601
+ type ContentBlock = ContentBlockMap[ContentBlockType];
602
+ /**
603
+ * Why a model response stopped.
604
+ * Merge-extensible so adapters can surface provider-specific reasons.
605
+ */
606
+ interface FinishReasonMap {
607
+ 'stop': {
608
+ kind: 'stop';
609
+ };
610
+ 'tool-calls': {
611
+ kind: 'tool-calls';
612
+ };
613
+ 'max-tokens': {
614
+ kind: 'max-tokens';
615
+ };
616
+ 'aborted': {
617
+ kind: 'aborted';
618
+ failure: LlmFailure;
619
+ };
620
+ 'error': {
621
+ kind: 'error';
622
+ failure: LlmFailure;
623
+ };
624
+ }
625
+ /** Any known finish reason, derived from {@link FinishReasonMap}; switch on `kind` and fall through unknowns (merge-extensible). */
626
+ type FinishReason = FinishReasonMap[keyof FinishReasonMap];
627
+ /**
628
+ * Token accounting for one model call (cache fields are optional).
629
+ *
630
+ * Counts are DISJOINT: `inputTokens` is uncached input only; cached input is
631
+ * reported separately as `cacheReadTokens`/`cacheWriteTokens` (billed input =
632
+ * sum of the three). Adapters whose providers fold cache hits into a total
633
+ * prompt count (DeepSeek's `prompt_tokens`) subtract them out.
634
+ */
635
+ interface TokenUsage {
636
+ inputTokens: number;
637
+ outputTokens: number;
638
+ /**
639
+ * Exact full-call total including aggregate prompt and output tokens.
640
+ *
641
+ * Adapters preserve a provider total or derive it from authoritative
642
+ * aggregate prompt/output counters; they omit it when unavailable or
643
+ * inconsistent.
644
+ */
645
+ totalTokens?: number;
646
+ cacheReadTokens?: number;
647
+ cacheWriteTokens?: number;
648
+ reasoningTokens?: number;
649
+ }
650
+ /**
651
+ * Request price of one ordered image occurrence under one exact model route's
652
+ * request projection. Every occurrence resolves to the pair the wire actually
653
+ * carries: provider visual tokens for a retained image, plus the model-visible
654
+ * text sent with or instead of it (request-preview handle, offload placeholder,
655
+ * or text-only substitution). The caller prices `text` with its own text
656
+ * estimator so provider pricing never fixes a text tokenization.
657
+ */
658
+ interface LlmImageRequestPrice {
659
+ /** Provider visual tokens for the retained request image; 0 when only text represents this occurrence. */
660
+ visualTokens: number;
661
+ /** Model-visible text sent for this occurrence, to be priced by the caller's text estimator. */
662
+ text: string;
663
+ }
664
+ /**
665
+ * Provider-side request-image pricing for one exact model route. Implemented
666
+ * by adapters whose provider charges visual tokens; consumers (the token
667
+ * meter) resolve it synchronously per measurement, so implementations must not
668
+ * perform I/O.
669
+ */
670
+ interface LlmImageRequestPricing {
671
+ /**
672
+ * Price every image occurrence of one request projection.
673
+ * @param images - durable image references in request order, one entry per occurrence.
674
+ * @returns one price per occurrence, aligned by index with `images`.
675
+ */
676
+ priceImages(images: readonly ImageAttachmentRef[]): readonly LlmImageRequestPrice[];
677
+ }
678
+ /** Display metadata for one registered provider route. */
679
+ interface LlmProviderInfo {
680
+ /** Provider route key used by {@link GenerateOptions.provider}. */
681
+ id: string;
682
+ /** Human-readable provider name for selectors and diagnostics. */
683
+ name: string;
684
+ }
685
+ /** Merge-extensible provider model modality vocabulary. */
686
+ interface ModelModalityMap {
687
+ text: 'text';
688
+ image: 'image';
689
+ }
690
+ /** Any declared provider model modality. */
691
+ type ModelModality = ModelModalityMap[keyof ModelModalityMap];
692
+ /**
693
+ * One provider route an adapter plugin can activate through configuration,
694
+ * whether or not the route is currently registered. Configuration surfaces
695
+ * merge this directory with `listProviders()` to offer every configurable
696
+ * provider alongside its live/dormant state.
697
+ */
698
+ interface LlmConfigurableProvider {
699
+ /** Provider route key this entry activates when configured. */
700
+ provider: string;
701
+ /** Human-readable provider name for configuration surfaces. */
702
+ displayName: string;
703
+ /** User-settings namespace whose section configures this provider. */
704
+ settingsNs: string;
705
+ /**
706
+ * Path from that namespace's section root to this provider's profile
707
+ * object; empty when the whole section is the profile.
708
+ */
709
+ settingsPath: readonly string[];
710
+ /**
711
+ * Whether the owning adapter knows this route only because configuration
712
+ * declared it — a gateway or self-hosted server it ships nothing about.
713
+ * Absent means the adapter draws no such distinction; false means it does
714
+ * and this route is one of its own. Only the adapter can answer: a stored
715
+ * profile is how a user-added route AND a corrected shipped one both look
716
+ * from outside.
717
+ */
718
+ declared?: boolean;
719
+ /** Configuration diagnostic for repair; unaffected models may remain serviceable. */
720
+ error?: string;
721
+ }
722
+ /**
723
+ * One interrogation of a provider endpoint that configuration has not stored
724
+ * yet. Configuration surfaces send the draft a user is still editing, so the
725
+ * request carries the endpoint and credential directly instead of naming a
726
+ * route: a provider being added has no route to name.
727
+ */
728
+ interface LlmModelDiscoveryRequest {
729
+ /**
730
+ * Route the draft is editing, when it edits an existing one. A route whose
731
+ * adapter already knows its models answers from that knowledge instead of
732
+ * asking the endpoint — the adapter's own registry is the better answer, and
733
+ * it costs no network call.
734
+ */
735
+ provider?: string;
736
+ /**
737
+ * Endpoint to interrogate. Optional because a route the adapter already
738
+ * describes needs none; a route it does not must supply one.
739
+ */
740
+ baseURL?: string;
741
+ /** Wire protocol the endpoint speaks, when the draft names one. */
742
+ api?: string;
743
+ /** Credential for this interrogation alone; the harness never stores it. */
744
+ apiKey?: string;
745
+ }
746
+ declare module '@deepseek-ai/dsh-typert-protocol' {
747
+ interface RemoteErrorDetailsMap {
748
+ /** A draft provider interrogation refused or failed. */
749
+ 'llm/model-discovery-rejected': {
750
+ readonly settingsNs: string;
751
+ readonly baseURL?: string;
752
+ };
753
+ }
754
+ }
755
+ /**
756
+ * One model an endpoint reports about itself. Every field but the id is
757
+ * optional because most provider listings disclose an id and nothing else;
758
+ * a surface adopting one of these still owes the capacities its adapter needs.
759
+ */
760
+ interface LlmDiscoveredModel {
761
+ /** Model id the endpoint accepts. */
762
+ id: string;
763
+ /** Human-readable name when the endpoint supplies one. */
764
+ name?: string;
765
+ /** Maximum combined request and response context, when disclosed. */
766
+ contextWindow?: number;
767
+ /** Maximum output tokens, when disclosed. */
768
+ maxTokens?: number;
769
+ }
770
+ /** One adapter-discovered model; catalog membership is advisory, not request validation. */
771
+ interface LlmModelInfo {
772
+ /** Provider route that owns this model entry. */
773
+ provider: string;
774
+ /** Model id passed to {@link GenerateOptions.model}. */
775
+ id: string;
776
+ /** Human-readable model name for selectors. */
777
+ name: string;
778
+ /** Optional user-facing distinction from otherwise similar models. */
779
+ description?: string;
780
+ /** Accepted request modalities; absent means unknown, while an explicit omission is negative capability. */
781
+ inputModalities?: readonly ModelModality[];
782
+ }
783
+ /** Provider-owned context capacity for one exact provider/model route. */
784
+ interface LlmModelContext {
785
+ /** Maximum combined request and response context in tokens. */
786
+ contextWindow: number;
787
+ }
788
+ /** Display metadata for one adapter-owned reasoning effort. */
789
+ interface LlmReasoningEffortInfo {
790
+ /** Opaque stable value accepted by {@link GenerateOptions.reasoningEffort}. */
791
+ id: ReasoningEffortId;
792
+ /** Human-readable effort name for selectors and diagnostics. */
793
+ name: string;
794
+ /** Optional user-facing distinction from otherwise similar efforts. */
795
+ description?: string;
796
+ }
797
+ /** Selectable reasoning efforts for one exact provider/model route. */
798
+ interface LlmModelReasoningInfo {
799
+ /** Supported efforts in adapter-preferred display order. */
800
+ efforts: readonly LlmReasoningEffortInfo[];
801
+ /**
802
+ * Adapter-configured default materialized into requests when callers omit
803
+ * an effort. Absence preserves the provider's own default.
804
+ */
805
+ defaultEffort?: ReasoningEffortId;
806
+ }
807
+ /**
808
+ * How a model applies a system prompt that changes mid-conversation.
809
+ * `'in-history'`: the model reads the latest `system` message at any position
810
+ * of `messages` as the complete effective system prompt, so a changed prompt
811
+ * can follow the cached history instead of rewriting message 0.
812
+ */
813
+ type SystemPromptUpdate = 'in-history';
814
+ /** Exact-route model metadata resolved by its owning adapter. */
815
+ interface LlmResolvedModelInfo extends LlmModelInfo {
816
+ /** Provider-owned context capacity when known. */
817
+ context?: LlmModelContext;
818
+ /** Adapter-configured per-request output cap materialized when callers omit one. */
819
+ defaultMaxTokens?: number;
820
+ /** Adapter-owned selectable reasoning levels when exposed. */
821
+ reasoning?: LlmModelReasoningInfo;
822
+ /** Declared mid-conversation system prompt handling; absent means only a leading system message is read. */
823
+ systemPromptUpdate?: SystemPromptUpdate;
824
+ }
825
+ /**
826
+ * Adapter-private lossless-JSON state for replaying a successful response,
827
+ * carried by a terminal `finish` chunk and stored on the assembled assistant
828
+ * message's model source. Both halves stay opaque to the harness; only the
829
+ * split is shared vocabulary, so assembly can keep stored metadata aligned
830
+ * with stored content without reading either half.
831
+ */
832
+ interface ReplayEnvelope {
833
+ /** Response-level adapter-private metadata (ids, native stop reason). */
834
+ response: unknown;
835
+ /**
836
+ * Per-block adapter-private metadata, one entry per emitted block in
837
+ * first-seen stream order. When assembly drops a block it drops the entry at
838
+ * the same position; entries whose length does not match the emitted block
839
+ * count discard the whole envelope. An adapter whose metadata is independent
840
+ * of block structure omits this field and the envelope passes through
841
+ * assembly unchanged.
842
+ */
843
+ blocks?: readonly unknown[];
844
+ }
845
+ /**
846
+ * Raw streaming protocol emitted by adapters.
847
+ * Block indexes correlate interleaved deltas, and `block-end` carries the
848
+ * assembled block. Adapters emit usage before the terminal finish and nothing
849
+ * afterward; tool arguments remain raw JSON strings. An adapter implementation
850
+ * may throw, but `LlmRuntime.stream()` normalizes that failure to a terminal
851
+ * `error` or `aborted` finish before exposing it to consumers.
852
+ */
853
+ type StreamChunk = {
854
+ type: 'block-start';
855
+ index: number;
856
+ blockType: ContentBlockType;
857
+ } | {
858
+ type: 'text-delta';
859
+ index: number;
860
+ text: string;
861
+ } | {
862
+ type: 'reasoning-delta';
863
+ index: number;
864
+ text: string;
865
+ } | {
866
+ type: 'tool-call-delta';
867
+ index: number;
868
+ id: ToolCallId;
869
+ name?: string;
870
+ argumentsDelta: string;
871
+ } | {
872
+ type: 'block-end';
873
+ index: number;
874
+ block: ContentBlock;
875
+ } | {
876
+ type: 'usage';
877
+ usage: TokenUsage;
878
+ } | {
879
+ type: 'finish';
880
+ reason: FinishReason;
881
+ /** Replay metadata for a successful response; see {@link ReplayEnvelope}. */
882
+ replayState?: ReplayEnvelope;
883
+ };
884
+ /**
885
+ * JSON-schema description of a tool, as sent to the model.
886
+ *
887
+ * Declared here (not in dsh-tools) because it is part of {@link GenerateOptions};
888
+ * dsh-tools' ToolDefinition and dsh-system-prompt's PromptAssembly both import
889
+ * it from this package.
890
+ */
891
+ interface ToolSchema {
892
+ name: string;
893
+ description: string;
894
+ /** JSON Schema object for the arguments. */
895
+ parameters: Record<string, unknown>;
896
+ }
897
+ /** A single model request, fully assembled. */
898
+ interface GenerateOptions {
899
+ /** Registered provider route selecting the adapter instance. */
900
+ provider: string;
901
+ model: string;
902
+ /** Adapter-owned reasoning effort selected for this exact model. */
903
+ reasoningEffort?: ReasoningEffortId;
904
+ /**
905
+ * Ordered conversation messages, exactly as the provider sees them. A
906
+ * loop-built request passes the derived history (dsh-agent-loop), whose
907
+ * leading system-role message carries the system prompt; a hand-built
908
+ * one-shot passes any list.
909
+ */
910
+ messages: Message[];
911
+ /**
912
+ * System prompt text for one-shot callers; adapters map it to the provider's
913
+ * system slot ahead of `messages`. Loop-built requests leave it undefined.
914
+ */
915
+ system?: string;
916
+ /** Tool schemas (adapters map to the provider's `tools` field). */
917
+ tools?: ToolSchema[];
918
+ temperature?: number;
919
+ maxTokens?: number;
920
+ /**
921
+ * Stop sequences: generation halts as soon as the model produces any one of
922
+ * these strings (adapters map to the provider's stop field, e.g. OpenAI
923
+ * `stop`). The stop string itself is not included in the output.
924
+ */
925
+ stop?: string[];
926
+ signal?: AbortSignal;
927
+ /**
928
+ * Session identity stamped by the loop for request routing. Replay uses it
929
+ * to separate cursors; adapters may map it to model-hidden transport metadata.
930
+ */
931
+ sessionId?: Branded<'SessionId'>;
932
+ /**
933
+ * Provider-neutral classification for an auxiliary model call. Adapters may
934
+ * map the purpose to model-hidden transport metadata or purpose-specific
935
+ * generation policy. Ordinary conversation requests leave it unset.
936
+ */
937
+ purpose?: 'compaction' | 'session-title';
938
+ }
939
+ //#endregion
940
+ //#region ../../node_modules/@deepseek-ai/cosmokit/lib/types/types.d.ts
941
+ declare function isArrayBufferLike(value: any): value is ArrayBufferLike;
942
+ declare function isArrayBufferSource(value: any): value is Binary.Source;
943
+ /** Binary source detection and base64/hex conversion helpers. */
944
+ declare namespace Binary {
945
+ type Source<T extends ArrayBufferLike = ArrayBufferLike> = T | ArrayBufferView<T>;
946
+ const is: typeof isArrayBufferLike;
947
+ const isSource: typeof isArrayBufferSource;
948
+ function fromSource<T extends ArrayBufferLike>(source: Source<T>): T;
949
+ function toBase64(source: Source): string;
950
+ function fromBase64(source: string): ArrayBuffer | Uint8Array<ArrayBuffer>;
951
+ function toHex(source: Source): string;
952
+ function fromHex(source: string): ArrayBuffer;
953
+ }
954
+ //#endregion
955
+ //#region ../../node_modules/@deepseek-ai/cosmokit/lib/types/misc.d.ts
956
+ /** String/symbol keyed dictionary type. */
957
+ type Dict<T = any, K extends string | symbol = string> = { [key in K]: T; };
958
+ //#endregion
959
+ //#region ../../node_modules/@standard-schema/spec/dist/index.d.ts
960
+ /** The Standard Typed interface. This is a base type extended by other specs. */
961
+ interface StandardTypedV1<Input = unknown, Output = Input> {
962
+ /** The Standard properties. */
963
+ readonly "~standard": StandardTypedV1.Props<Input, Output>;
964
+ }
965
+ declare namespace StandardTypedV1 {
966
+ /** The Standard Typed properties interface. */
967
+ interface Props<Input = unknown, Output = Input> {
968
+ /** The version number of the standard. */
969
+ readonly version: 1;
970
+ /** The vendor name of the schema library. */
971
+ readonly vendor: string;
972
+ /** Inferred types associated with the schema. */
973
+ readonly types?: Types<Input, Output> | undefined;
974
+ }
975
+ /** The Standard Typed types interface. */
976
+ interface Types<Input = unknown, Output = Input> {
977
+ /** The input type of the schema. */
978
+ readonly input: Input;
979
+ /** The output type of the schema. */
980
+ readonly output: Output;
981
+ }
982
+ /** Infers the input type of a Standard Typed. */
983
+ type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
984
+ /** Infers the output type of a Standard Typed. */
985
+ type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
986
+ }
987
+ /** The Standard Schema interface. */
988
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
989
+ /** The Standard Schema properties. */
990
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
991
+ }
992
+ declare namespace StandardSchemaV1 {
993
+ /** The Standard Schema properties interface. */
994
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
995
+ /** Validates unknown input values. */
996
+ readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
997
+ }
998
+ /** The result interface of the validate function. */
999
+ type Result<Output> = SuccessResult<Output> | FailureResult;
1000
+ /** The result interface if validation succeeds. */
1001
+ interface SuccessResult<Output> {
1002
+ /** The typed output value. */
1003
+ readonly value: Output;
1004
+ /** A falsy value for `issues` indicates success. */
1005
+ readonly issues?: undefined;
1006
+ }
1007
+ interface Options {
1008
+ /** Explicit support for additional vendor-specific parameters, if needed. */
1009
+ readonly libraryOptions?: Record<string, unknown> | undefined;
1010
+ }
1011
+ /** The result interface if validation fails. */
1012
+ interface FailureResult {
1013
+ /** The issues of failed validation. */
1014
+ readonly issues: ReadonlyArray<Issue>;
1015
+ }
1016
+ /** The issue interface of the failure output. */
1017
+ interface Issue {
1018
+ /** The error message of the issue. */
1019
+ readonly message: string;
1020
+ /** The path of the issue, if any. */
1021
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
1022
+ }
1023
+ /** The path segment interface of the issue. */
1024
+ interface PathSegment {
1025
+ /** The key representing a path segment. */
1026
+ readonly key: PropertyKey;
1027
+ }
1028
+ /** The Standard types interface. */
1029
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
1030
+ /** Infers the input type of a Standard. */
1031
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
1032
+ /** Infers the output type of a Standard. */
1033
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
1034
+ }
1035
+ //#endregion
1036
+ //#region ../../node_modules/@deepseek-ai/schemastery/lib/types/index.d.ts
1037
+ declare const kSchema: unique symbol;
1038
+ declare global {
1039
+ namespace Schemastery {
1040
+ /** 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, unknown> ? S : never;
1043
+ type Inverse<X> = X extends Schema<any, infer Y> ? (arg: Y) => void : never;
1044
+ /** Input type accepted by a schema-like value. */
1045
+ type TypeS<X> = TypeS1<From<X>>;
1046
+ /** Output type returned by a schema-like value after validation. */
1047
+ type TypeT<X> = ReturnType<From<X>>;
1048
+ /** Resolver callback used by custom schema types registered with `Schema.extend()`. */
1049
+ type Resolve = (data: any, schema: Schema, options: Options, strict?: boolean) => [any, any?];
1050
+ /** Input type accepted by one schema in an intersection. */
1051
+ type IntersectS<X> = From<X> extends Schema<infer S, unknown> ? S : never;
1052
+ /** Output type returned by one schema in an intersection. */
1053
+ type IntersectT<X> = Inverse<From<X>> extends ((arg: infer T) => void) ? T : never;
1054
+ type TupleS<X extends readonly any[]> = X extends readonly [infer L, ...infer R] ? [TypeS<L>?, ...TupleS<R>] : any[];
1055
+ type TupleT<X extends readonly any[]> = X extends readonly [infer L, ...infer R] ? [TypeT<L>?, ...TupleT<R>] : any[];
1056
+ type ObjectS<X extends Dict> = { [K in keyof X]?: TypeS<X[K]> | null; } & Dict;
1057
+ type ObjectT<X extends Dict> = { [K in keyof X]: TypeT<X[K]>; } & Dict;
1058
+ type Constructor<T = any> = new (...args: any[]) => T;
1059
+ /** Static constructor and factory methods exposed by the default `Schema` export. */
1060
+ interface Static {
1061
+ <T = any>(options: Partial<Schema<T>>): Schema<T>;
1062
+ new <T = any>(options: Partial<Schema<T>>): Schema<T>;
1063
+ prototype: Schema;
1064
+ /** Validate a value against a schema node and return `[output, adaptedInput?]`. */
1065
+ resolve: Resolve;
1066
+ /** Infer a schema from a primitive value, constructor, or existing schema. */
1067
+ from<X = any>(source?: X): From<X>;
1068
+ /** Register a resolver for a custom schema `type`. */
1069
+ extend(type: string, resolve: Resolve): void;
1070
+ /** Accept any value without validation. */
1071
+ any<T = any>(): Schema<T>;
1072
+ /** Accept only nullable input. */
1073
+ never(): Schema<never>;
1074
+ /** Accept exactly one constant value. */
1075
+ const<const T>(value: T): Schema<T>;
1076
+ /** Accept strings, with optional metadata constraints added by instance methods. */
1077
+ string(): Schema<string>;
1078
+ /** Accept numbers, with optional range and step constraints. */
1079
+ number(): Schema<number>;
1080
+ /** Accept non-negative integer numbers. */
1081
+ natural(): Schema<number>;
1082
+ /** Accept a number between 0 and 1 and mark it as a slider. */
1083
+ percent(): Schema<number>;
1084
+ /** Accept booleans. */
1085
+ boolean(): Schema<boolean>;
1086
+ /** Accept `Date` instances or parse datetime strings into `Date` objects. */
1087
+ date(): Schema<string | Date, Date>;
1088
+ /** Accept `RegExp` instances or parse strings into regular expressions. */
1089
+ regExp(flag?: string): Schema<string | RegExp, RegExp>;
1090
+ /** Accept binary sources and normalize them to `ArrayBufferLike`. */
1091
+ arrayBuffer(): Schema<Binary.Source, ArrayBufferLike>;
1092
+ arrayBuffer(encoding: 'hex' | 'base64'): Schema<Binary.Source | string, ArrayBufferLike>;
1093
+ /** Accept a numeric bitset or string keys and normalize to a number. */
1094
+ bitset<K extends string>(bits: Partial<Record<K, number>>): Schema<number | readonly K[], number>;
1095
+ /** Accept functions. */
1096
+ function(): Schema<Function, (...args: any[]) => any>;
1097
+ /** Accept instances of a constructor or objects whose constructor name matches. */
1098
+ is(constructor: string): Schema;
1099
+ is<T>(constructor: Constructor<T>): Schema<T>;
1100
+ /** Accept arrays whose elements match `inner`. */
1101
+ array<X>(inner: X): Schema<TypeS<X>[], TypeT<X>[]>;
1102
+ /** Accept plain objects with values matching `inner` and optional key schema. */
1103
+ 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
+ /** Accept tuple arrays where each index matches the corresponding schema. */
1105
+ tuple<const X extends readonly any[]>(list: X): Schema<TupleS<X>, TupleT<X>>;
1106
+ /** Accept plain objects whose declared properties match the schema dictionary. */
1107
+ object<X extends Dict>(dict: X): Schema<ObjectS<X>, ObjectT<X>>;
1108
+ /** Accept values matching at least one schema in `list`. */
1109
+ union<const X>(list: readonly X[]): Schema<TypeS<X>, TypeT<X>>;
1110
+ /** Accept values matching every schema in `list`, merging object outputs. */
1111
+ intersect<const X>(list: readonly X[]): Schema<IntersectS<X>, IntersectT<X>>;
1112
+ /** Validate with `inner`, then convert the result with `callback`. */
1113
+ transform<X, T>(inner: X, callback: (value: TypeS<X>, options: Schemastery.Options) => T, preserve?: boolean): Schema<TypeS<X>, T>;
1114
+ /** Defer construction of a recursive schema until validation or serialization. */
1115
+ lazy<X extends Schema>(callback: () => X): X;
1116
+ ValidationError: typeof ValidationError;
1117
+ }
1118
+ /** Runtime validation options shared by all schema calls. */
1119
+ interface Options {
1120
+ /** Remove invalid object properties instead of throwing when possible. */
1121
+ autofix?: boolean;
1122
+ /** Skip validation for selected values and schema nodes. */
1123
+ ignore?(data: any, schema: Schema): boolean;
1124
+ /** Path used to format nested validation errors. */
1125
+ path?: (keyof any)[];
1126
+ }
1127
+ /** UI and validation metadata attached by schema builder methods. */
1128
+ interface Meta<T = any> {
1129
+ default?: T extends {} ? Partial<T> : T;
1130
+ required?: boolean;
1131
+ disabled?: boolean;
1132
+ collapse?: boolean;
1133
+ badges?: {
1134
+ text: string;
1135
+ type: string;
1136
+ }[];
1137
+ hidden?: boolean;
1138
+ loose?: boolean;
1139
+ role?: string;
1140
+ extra?: any;
1141
+ link?: string;
1142
+ description?: string | Dict<string>;
1143
+ comment?: string;
1144
+ pattern?: {
1145
+ source: string;
1146
+ flags?: string;
1147
+ };
1148
+ max?: number;
1149
+ min?: number;
1150
+ step?: number;
1151
+ }
1152
+ }
1153
+ /** 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;
1157
+ [kSchema]: true;
1158
+ uid: number;
1159
+ meta: Schemastery.Meta<T>;
1160
+ type: string;
1161
+ sKey?: Schema;
1162
+ inner?: Schema;
1163
+ list?: Schema[];
1164
+ dict?: Dict<Schema>;
1165
+ bits?: Dict<number>;
1166
+ callback?: Function;
1167
+ constructor?: string | Function;
1168
+ builder?: Function;
1169
+ value?: T;
1170
+ refs?: Dict<Schema>;
1171
+ preserve?: boolean;
1172
+ '~standard': StandardSchemaV1.Props;
1173
+ /** Format this schema as a compact TypeScript-like type string. */
1174
+ toString(inline?: boolean): string;
1175
+ /** Serialize this schema, preserving shared and recursive references. */
1176
+ toJSON(): Schema<S, T>;
1177
+ /** Mark nullable input as invalid unless a default supplies a fallback. */
1178
+ required(value?: boolean): Schema<S, T>;
1179
+ /** Hide this schema node from UI renderers. */
1180
+ hidden(value?: boolean): Schema<S, T>;
1181
+ /** Return the default value instead of throwing when validation fails. */
1182
+ loose(value?: boolean): Schema<S, T>;
1183
+ /** Attach a renderer role and optional role-specific metadata. */
1184
+ role(text: string, extra?: any): Schema<S, T>;
1185
+ /** Attach an external documentation link. */
1186
+ link(link: string): Schema<S, T>;
1187
+ /** Set the fallback value used for nullable input. */
1188
+ default(value: T): Schema<S, T>;
1189
+ /** Attach an auxiliary comment for documentation or form UIs. */
1190
+ comment(text: string): Schema<S, T>;
1191
+ /** Attach a localized or plain description for documentation or form UIs. */
1192
+ description(text: string): Schema<S, T>;
1193
+ /** Mark this schema node as disabled for form UIs. */
1194
+ disabled(value?: boolean): Schema<S, T>;
1195
+ /** Request collapsed rendering for nested form UIs. */
1196
+ collapse(value?: boolean): Schema<S, T>;
1197
+ /** Add a deprecated badge to this schema node. */
1198
+ deprecated(): Schema<S, T>;
1199
+ /** Add an experimental badge to this schema node. */
1200
+ experimental(): Schema<S, T>;
1201
+ /** Require strings to match a regular expression. */
1202
+ pattern(regexp: RegExp): Schema<S, T>;
1203
+ /** Set an inclusive maximum for numbers or collection lengths. */
1204
+ max(value: number): Schema<S, T>;
1205
+ /** Set an inclusive minimum for numbers or collection lengths. */
1206
+ min(value: number): Schema<S, T>;
1207
+ /** Set the numeric increment constraint. */
1208
+ step(value: number): Schema<S, T>;
1209
+ /** Add or replace an object property schema. */
1210
+ set(key: string, value: Schema): Schema<S, T>;
1211
+ /** Append a tuple, union, or intersection member schema. */
1212
+ push(value: Schema): Schema<S, T>;
1213
+ /** Remove values equal to schema defaults from normalized output. */
1214
+ simplify(value?: any): any;
1215
+ /** Return a schema clone with descriptions merged from locale messages. */
1216
+ i18n(messages: Dict): Schema<S, T>;
1217
+ /** 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>;
1219
+ }
1220
+ }
1221
+ declare class ValidationError extends TypeError {
1222
+ options: Schemastery.Options;
1223
+ name: string;
1224
+ constructor(message: string, options: Schemastery.Options);
1225
+ static is(error: any): error is ValidationError;
1226
+ }
1227
+ type Schema<S = any, T = S> = Schemastery<S, T>;
1228
+ declare const Schema: Schemastery.Static;
1229
+ //#endregion
1230
+ //#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/retry-policy.d.ts
1231
+ /** Fully resolved backoff shared by both retry modes. */
1232
+ interface ResolvedRetryBackoff {
1233
+ readonly initialDelayMs: number;
1234
+ readonly maxDelayMs: number;
1235
+ readonly jitterRatio: number;
1236
+ }
1237
+ /** Fully resolved bounded transient retry policy. */
1238
+ interface ResolvedNormalRetryPolicy extends ResolvedRetryBackoff {
1239
+ readonly mode: 'normal';
1240
+ readonly maxRetries: number;
1241
+ readonly retryableCodes: readonly string[];
1242
+ }
1243
+ /** Fully resolved unbounded retry policy. */
1244
+ interface ResolvedAlwaysRetryPolicy extends ResolvedRetryBackoff {
1245
+ readonly mode: 'always';
1246
+ }
1247
+ /** Immutable provider policy captured when its adapter route is registered. */
1248
+ type ResolvedRetryPolicy = ResolvedNormalRetryPolicy | ResolvedAlwaysRetryPolicy;
1249
+ //#endregion
1250
+ //#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/call-config.d.ts
1251
+ /**
1252
+ * Provider, model, reasoning effort, and sampling scalars of one conversation's
1253
+ * requests. Every field maps 1:1 onto the same-named `GenerateOptions` field;
1254
+ * the loop builds requests from the logged header rather than accepting these
1255
+ * per call.
1256
+ */
1257
+ interface LlmCallConfig {
1258
+ provider: string;
1259
+ model: string;
1260
+ reasoningEffort?: ReasoningEffortId;
1261
+ temperature?: number;
1262
+ maxTokens?: number;
1263
+ stop?: string[];
1264
+ }
1265
+ /**
1266
+ * Effective config fields supplied by exact-model adapter resolution rather
1267
+ * than by the caller's request proposal.
1268
+ */
1269
+ interface LlmCallConfigAdapterDefaults {
1270
+ reasoningEffort?: true;
1271
+ maxTokens?: true;
1272
+ }
1273
+ //#endregion
1274
+ //#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/index.d.ts
1275
+ declare module '@deepseek-ai/cordis' {
1276
+ interface Context {
1277
+ llm: LlmRuntime;
1278
+ }
1279
+ interface Events {
1280
+ /**
1281
+ * Waterfall around every streaming model call (retry, replay, routing).
1282
+ * Bound to the {@link LlmRuntime}; call `next()` to reach the resolved
1283
+ * adapter's stream, or yield your own chunks to short-circuit.
1284
+ * @param options - the full request. A LOOP-built request carries the
1285
+ * process-local {@link markAgentLoopRequest} identity and arrives deep-frozen
1286
+ * (mutation throws): its content is a pure function of the session log (the
1287
+ * reconstructability Agent Note), so listeners read it, never rewrite it.
1288
+ * Hand-built calls do not carry that marker; their messages already obey
1289
+ * the immutable creation contract.
1290
+ * @mode waterfall
1291
+ */
1292
+ 'llm/stream'(this: LlmRuntime, options: GenerateOptions, next: () => AsyncIterable<StreamChunk>): AsyncIterable<StreamChunk>;
1293
+ }
1294
+ }
1295
+ /** One model call whose config and adapter registration were resolved together. */
1296
+ interface PreparedLlmCall {
1297
+ /** Detached, deep-frozen config with any adapter-owned default materialized. */
1298
+ readonly config: LlmCallConfig;
1299
+ /** Immutable retry policy captured with the adapter registration. */
1300
+ readonly retryPolicy: ResolvedRetryPolicy;
1301
+ /** Detached context metadata resolved with the registration-bound call. */
1302
+ readonly context?: LlmModelContext;
1303
+ /** Exact model modalities captured with the adapter dispatch generation. */
1304
+ readonly inputModalities?: readonly ModelModality[];
1305
+ /** Exact model system prompt update mode captured with the adapter dispatch generation. */
1306
+ readonly systemPromptUpdate?: SystemPromptUpdate;
1307
+ /** Config fields materialized by the captured adapter rather than proposed by the caller. */
1308
+ readonly adapterDefaults: LlmCallConfigAdapterDefaults;
1309
+ /**
1310
+ * Dispatch this call once through the registration captured during
1311
+ * preparation. The request's call-config fields must match {@link config};
1312
+ * reuse or mismatch fails with `INVALID_PREPARED_CALL`.
1313
+ * @param options - fully assembled request carrying the prepared config.
1314
+ * @returns the chunk stream, including the `llm/stream` waterfall.
1315
+ */
1316
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
1317
+ }
1318
+ /** One adapter-owned model-resolution generation bound to its eventual stream call. */
1319
+ interface PreparedAdapterCall {
1320
+ /** Exact model metadata from the same adapter generation as {@link stream}. */
1321
+ readonly model: LlmResolvedModelInfo;
1322
+ /** Dispatch through that generation without re-reading dynamic connection facts. */
1323
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
1324
+ }
1325
+ /**
1326
+ * Provider-wire adapter for the harness message and stream vocabulary. Register implementations
1327
+ * with `ctx.llm.registerAdapter(providers, adapter)`. Every provider HTTP request must include
1328
+ * `attributionHeaders()`; prove the headers are added in the wire request or library header hook. The direct-fetch
1329
+ * DeepSeek and library-backed pi-ai adapters meet this contract through different internals.
1330
+ */
1331
+ declare abstract class LlmAdapter {
1332
+ /**
1333
+ * Describe one provider route owned by this adapter.
1334
+ * @param provider - a route passed to `registerAdapter()` for this instance.
1335
+ * @returns detached display metadata whose id must equal `provider`.
1336
+ */
1337
+ providerInfo(provider: string): LlmProviderInfo;
1338
+ /**
1339
+ * Return the provider-owned retry policy captured with this route.
1340
+ * @param _provider - a route passed to `registerAdapter()` for this instance.
1341
+ * @returns a resolved policy, or `undefined` to use the normal defaults.
1342
+ */
1343
+ providerRetryPolicy(_provider: string): ResolvedRetryPolicy | undefined;
1344
+ /**
1345
+ * Resolve provider-side request-image pricing for one exact model route.
1346
+ * The default declares none, so consumers fall back to their own neutral
1347
+ * estimate. Implementations must answer synchronously without I/O; the
1348
+ * token meter resolves this per measurement.
1349
+ * @param _provider - a route passed to `registerAdapter()` for this instance.
1350
+ * @param _model - exact model id passed to {@link GenerateOptions.model}.
1351
+ * @returns route-owned image pricing, or `undefined` when the route declares none.
1352
+ */
1353
+ imageRequestPricing(_provider: string, _model: string): LlmImageRequestPricing | undefined;
1354
+ /**
1355
+ * List models this adapter can currently advertise for one owned provider.
1356
+ * The result is advisory: an adapter may accept unlisted model ids, and
1357
+ * consumers must not turn absence into request rejection.
1358
+ * @param _provider - one provider route owned by this adapter.
1359
+ * @returns discoverable models in adapter-preferred order.
1360
+ */
1361
+ listModels(_provider: string): Promise<readonly LlmModelInfo[]>;
1362
+ /**
1363
+ * Resolve all metadata available for one exact model. This query is
1364
+ * independent of the advisory catalog and does not validate request routing.
1365
+ * @param provider - one provider route owned by this adapter.
1366
+ * @param model - exact model id passed to {@link GenerateOptions.model}.
1367
+ * @param _signal - cancellation for this exact-model lookup; asynchronous
1368
+ * implementations must settle promptly after it aborts.
1369
+ * @returns provider/model identity plus any context, call-default, and reasoning metadata.
1370
+ */
1371
+ resolveModel(provider: string, model: string, _signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
1372
+ /**
1373
+ * Bind exact model metadata and the eventual request dispatch to one adapter generation.
1374
+ * Dynamic adapters override this so settings changes between preparation and
1375
+ * dispatch cannot combine one generation's capabilities with another's endpoint.
1376
+ * @param provider - registered provider route.
1377
+ * @param model - exact model id.
1378
+ * @param signal - cancellation for model resolution.
1379
+ * @returns model metadata and a one-generation stream entry point.
1380
+ */
1381
+ prepareCall(provider: string, model: string, signal?: AbortSignal): Promise<PreparedAdapterCall>;
1382
+ /**
1383
+ * Stream one model call as raw chunks. The only required method.
1384
+ * @param options - the fully-assembled request; implementations must honor `options.signal`.
1385
+ * @returns the chunk stream, obeying the adapter contract documented on `StreamChunk`.
1386
+ */
1387
+ abstract stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
1388
+ }
1389
+ /**
1390
+ * What {@link LlmRuntime.registerAdapter} returns: the disposer, plus an
1391
+ * atomic route replacement for the same adapter instance.
1392
+ */
1393
+ interface AdapterRegistrationHandle {
1394
+ /** Release every route this registration currently holds. */
1395
+ (): void;
1396
+ /**
1397
+ * Replace this registration's routes with `providers`, keeping the same
1398
+ * adapter instance. The candidate set is validated in full first — a
1399
+ * conflict with another adapter, an invalid name, or bad provider metadata
1400
+ * throws and leaves the current routes untouched — and the swap itself is
1401
+ * one synchronous section, so no request can observe a gap. An empty array
1402
+ * is legal here (a settings section that emptied holds zero routes while
1403
+ * staying registered), unlike an empty initial registration.
1404
+ *
1405
+ * Throws `LlmError` with code `REGISTRATION_DISPOSED` once the registration
1406
+ * has been released: its routes are gone and its disposer has already run,
1407
+ * so anything registered afterwards would have no owner left to release it.
1408
+ * @param providers - the complete next route set for this registration.
1409
+ */
1410
+ replace(providers: string[]): void;
1411
+ }
1412
+ /**
1413
+ * A live configurable-provider registration, disposable and atomically
1414
+ * replaceable — the directory counterpart of {@link AdapterRegistrationHandle}.
1415
+ */
1416
+ interface DirectoryRegistrationHandle {
1417
+ /** Withdraw every entry this registration currently holds. */
1418
+ (): void;
1419
+ /**
1420
+ * Replace this registration's entries with `entries`. The candidate set is
1421
+ * validated in full first — an entry another registration already declares,
1422
+ * a duplicate within the set, or invalid metadata throws and leaves the
1423
+ * current entries untouched — and the swap is one synchronous section, so no
1424
+ * reader observes a gap. An empty array is legal here, unlike an empty
1425
+ * initial registration.
1426
+ *
1427
+ * Throws `LlmError` with code `REGISTRATION_DISPOSED` once the registration
1428
+ * has been disposed.
1429
+ */
1430
+ replace(entries: readonly LlmConfigurableProvider[]): void;
1431
+ }
1432
+ /**
1433
+ * The abstract `llm` service: an adapter registry plus a streaming model-call
1434
+ * API, interceptable via the `llm/stream` waterfall.
1435
+ */
1436
+ declare class LlmRuntime extends TypertRemoteService {
1437
+ private adapters;
1438
+ private directory;
1439
+ private discoveries;
1440
+ constructor(ctx: Context);
1441
+ /** Notify topology observers without letting one broken listener veto the commit. */
1442
+ private emitAdaptersUpdated;
1443
+ /** Contained-listener diagnostic shared by the sync and async failure paths. */
1444
+ private warnAdaptersListenerFailure;
1445
+ /**
1446
+ * Register an adapter for the given provider routes. Throws `LlmError` with code
1447
+ * `DUPLICATE_ADAPTER` if any provider already has an adapter (all-or-nothing).
1448
+ * Disposed with the fiber.
1449
+ * @param providers - every provider route this adapter should serve.
1450
+ * @param adapter - the adapter that streams calls for those providers.
1451
+ * @returns the disposer, carrying {@link AdapterRegistrationHandle.replace}.
1452
+ */
1453
+ registerAdapter(providers: string[], adapter: LlmAdapter): AdapterRegistrationHandle;
1454
+ /**
1455
+ * Validate one candidate route set for `adapter`, treating routes this
1456
+ * registration already holds as available. Nothing is mutated: a rejected
1457
+ * candidate leaves the registry exactly as it was.
1458
+ */
1459
+ private prepareRoutes;
1460
+ /**
1461
+ * Swap this registration's routes for the prepared ones in one synchronous
1462
+ * section, so no observer can see the registry between the release and the
1463
+ * re-registration. The route set's one mutation point is also where
1464
+ * `llm/adapters-updated` is published, so a `replace` announces itself
1465
+ * exactly like a first registration.
1466
+ */
1467
+ private commitRoutes;
1468
+ /**
1469
+ * Describe provider routes with a registered adapter.
1470
+ * @returns detached provider metadata in registration order.
1471
+ */
1472
+ listProviders(): LlmProviderInfo[];
1473
+ /**
1474
+ * Declare provider routes an adapter plugin can activate through
1475
+ * configuration. Registration is all-or-nothing: an empty list, invalid
1476
+ * entry, or a provider already declared by any registration throws
1477
+ * `LlmError` without registering the rest. Disposed with the fiber.
1478
+ * @param entries - every configurable provider this plugin owns.
1479
+ * @returns a handle that withdraws all of them, and can atomically replace them.
1480
+ */
1481
+ registerConfigurableProviders(entries: readonly LlmConfigurableProvider[]): DirectoryRegistrationHandle;
1482
+ /**
1483
+ * List every declared configurable provider, registered or dormant.
1484
+ * @returns detached directory entries in declaration order.
1485
+ */
1486
+ listConfigurableProviders(): LlmConfigurableProvider[];
1487
+ /**
1488
+ * Offer to interrogate provider endpoints on behalf of the settings
1489
+ * namespace this plugin owns. The namespace is the key because that is what
1490
+ * a configuration surface already holds from the configurable-provider
1491
+ * directory, and because a provider being *added* has no route to name yet.
1492
+ * Disposed with the fiber.
1493
+ * @param settingsNs - the namespace whose profiles this discovery serves.
1494
+ * @param discover - interrogates one endpoint and must honor the supplied signal.
1495
+ * @returns the disposer that withdraws the offer.
1496
+ */
1497
+ registerModelDiscovery(settingsNs: string, discover: (request: LlmModelDiscoveryRequest, signal?: AbortSignal) => Promise<readonly LlmDiscoveredModel[]>): () => void;
1498
+ /**
1499
+ * Interrogate one provider endpoint for the models it advertises. The
1500
+ * request describes a draft, not a stored route, so nothing here reads or
1501
+ * writes settings or credentials — the caller owns both, and the reply is
1502
+ * candidate metadata a surface may offer for adoption.
1503
+ * @param settingsNs - namespace whose registered discovery serves this draft.
1504
+ * @param request - the endpoint, protocol, and one-shot credential to use.
1505
+ * @param signal - caller cancellation.
1506
+ * @returns the advertised models, deduplicated in endpoint order.
1507
+ */
1508
+ discoverModels(settingsNs: string, request: LlmModelDiscoveryRequest, signal?: AbortSignal): Promise<LlmDiscoveredModel[]>;
1509
+ /**
1510
+ * Remote adapter for one draft provider interrogation.
1511
+ * @param settingsNs - namespace whose registered discovery serves this draft.
1512
+ * @param request - endpoint, protocol, and one-shot credential to use.
1513
+ * @param signal - caller cancellation supplied by the Remote carrier.
1514
+ * @returns advertised models in endpoint order.
1515
+ * @throws RemoteError with `llm/model-discovery-rejected` when discovery refuses or fails.
1516
+ */
1517
+ remoteDiscoverModels(settingsNs: string, request: LlmModelDiscoveryRequest, signal: AbortSignal): Promise<LlmDiscoveredModel[]>;
1518
+ /**
1519
+ * Resolve the retry policy captured when one provider route was registered.
1520
+ * @param provider - registered provider route to inspect.
1521
+ * @returns the provider-owned policy, with normal defaults already resolved.
1522
+ */
1523
+ providerRetryPolicy(provider: string): ResolvedRetryPolicy;
1524
+ /**
1525
+ * Resolve provider-side request-image pricing for one exact route, or
1526
+ * `undefined` when the provider is unregistered or declares none. Unknown
1527
+ * providers degrade to `undefined` rather than throwing because callers
1528
+ * price durable history whose route may no longer be mounted.
1529
+ * @param provider - provider route named by a request header.
1530
+ * @param model - exact model id named by the same header.
1531
+ * @returns the owning adapter's image pricing for the route, when declared.
1532
+ */
1533
+ imageRequestPricing(provider: string, model: string): LlmImageRequestPricing | undefined;
1534
+ /**
1535
+ * Resolve the exact text one durable file occurrence contributes to every
1536
+ * provider request in the current execution environment.
1537
+ * @param ref - durable verbatim file reference from model history.
1538
+ * @returns the same deterministic handle text used at adapter dispatch.
1539
+ */
1540
+ fileRequestText(ref: FileAttachmentRef): string;
1541
+ /** Detach typed adapter-owned modality metadata. */
1542
+ private detachedModalities;
1543
+ /**
1544
+ * Discover models advertised by one registered provider. Catalog membership
1545
+ * is advisory and never changes routing or request validation.
1546
+ * @param provider - registered provider route to inspect.
1547
+ * @returns detached model metadata in adapter-preferred order.
1548
+ */
1549
+ listModels(provider: string): Promise<LlmModelInfo[]>;
1550
+ /**
1551
+ * Resolve and validate all metadata from the adapter that owns one exact
1552
+ * route. The result is detached from adapter-owned objects; catalog
1553
+ * membership remains advisory and does not control request routing.
1554
+ * @param provider - registered provider route to inspect.
1555
+ * @param model - exact model id passed to the adapter.
1556
+ * @param signal - optional cancellation for adapter-owned asynchronous lookup.
1557
+ * @returns exact model identity plus available context and reasoning metadata.
1558
+ */
1559
+ resolveModelInfo(provider: string, model: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
1560
+ private resolveModelInfoFor;
1561
+ /** Validate and detach one adapter-returned exact model result. */
1562
+ private normalizeModelInfo;
1563
+ /**
1564
+ * Validate a conversation call config against its exact model capability and
1565
+ * materialize adapter-configured defaults. Unsupported explicit efforts
1566
+ * reject before provider I/O; no clamping or aliasing is performed. This
1567
+ * standalone query does not bind a later dispatch; use {@link prepareCall}
1568
+ * when logging and streaming must share one adapter registration.
1569
+ * @param config - provider/model route and optional request controls.
1570
+ * @param signal - optional cancellation for adapter-owned capability lookup.
1571
+ * @returns a detached config only when a default must be materialized.
1572
+ */
1573
+ resolveCallConfig(config: LlmCallConfig, signal?: AbortSignal): Promise<LlmCallConfig>;
1574
+ private resolveCallFor;
1575
+ /** Validate request controls against one already-bound exact model result. */
1576
+ private resolveCallWithInfo;
1577
+ /**
1578
+ * Resolve one call under its current adapter registration. The returned
1579
+ * one-shot handle keeps that registration across header logging and dispatch,
1580
+ * so HMR cannot combine one adapter's capability result with another adapter.
1581
+ * @param config - provider/model route and optional request controls.
1582
+ * @param signal - optional cancellation for adapter-owned capability lookup.
1583
+ * @returns a prepared config and its registration-bound stream entry point.
1584
+ */
1585
+ prepareCall(config: LlmCallConfig, signal?: AbortSignal): Promise<PreparedLlmCall>;
1586
+ private registration;
1587
+ /** Remove replay state whose historical route is owned by another adapter. */
1588
+ private forAdapter;
1589
+ /**
1590
+ * Resolve the current execution-world read path of one durable file
1591
+ * reference through the mounted attachment and filesystem providers.
1592
+ */
1593
+ private fileReadPath;
1594
+ /**
1595
+ * Final adapter boundary. Adapter selection, dispatch, iterator construction,
1596
+ * and iteration failures become one terminal failure chunk. Middleware and
1597
+ * downstream consumer failures remain thrown plugin or consumer errors.
1598
+ */
1599
+ private adapterStream;
1600
+ /**
1601
+ * Stream one model call as raw chunks (token-level deltas). Replay state is
1602
+ * retained only when the same adapter instance owns its historical provider
1603
+ * and the target provider. Final adapter selection remains fixed through
1604
+ * asynchronous exact-model resolution and dispatch. Adapter selection,
1605
+ * dispatch, and iteration failures become terminal `error` or `aborted`
1606
+ * finish chunks; middleware, nested-call, cleanup, and consumer failures
1607
+ * remain thrown.
1608
+ * @param options - the full request; `options.provider` selects the adapter.
1609
+ * @returns the chunk stream, possibly wrapped by `llm/stream` listeners.
1610
+ */
1611
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
1612
+ private streamWithRegistration;
1613
+ }
1614
+ //#endregion
1615
+ //#region src/core/workspace-instruction-context.d.ts
1616
+ interface InstructionSnapshotResult {
1617
+ snapshot: SessionInstructionSnapshot;
1618
+ message: ReturnType<typeof createUserMessage> | undefined;
1619
+ }
1620
+ declare function escapeInstructionFrameBody(body: string): string;
1621
+ declare function renderInstructionMessageText(workspaceTitle: string, text: string): string;
1622
+ declare function createInstructionMessage(workspaceId: string, workspaceTitle: string, snapshot: SessionInstructionSnapshot): ReturnType<typeof createUserMessage>;
1623
+ interface AgentLike {
1624
+ session: {
1625
+ id: string;
1626
+ header: {
1627
+ cwd: string;
1628
+ };
1629
+ surface?: {
1630
+ nodes?: number[];
1631
+ };
1632
+ eventAt?: (seq: number) => {
1633
+ type: string;
1634
+ data: {
1635
+ source: {
1636
+ kind: string;
1637
+ };
1638
+ };
1639
+ } | undefined;
1640
+ };
1641
+ }
1642
+ interface MessageLike {
1643
+ id: string;
1644
+ role: string;
1645
+ source: {
1646
+ kind: string;
1647
+ };
1648
+ }
1649
+ interface WorkspaceRegistryLike {
1650
+ resolveByPath(path: string): Promise<{
1651
+ id: string;
1652
+ path: string;
1653
+ title: string;
1654
+ } | undefined>;
1655
+ get(id: string): {
1656
+ id: string;
1657
+ path: string;
1658
+ title: string;
1659
+ } | undefined;
1660
+ }
1661
+ declare function resolveSnapshotForSession(agent: AgentLike, messages: MessageLike[], workspaceStore?: WorkspaceInstructionStore, snapshotStore?: SessionInstructionSnapshotStore, registry?: WorkspaceRegistryLike): Promise<SessionInstructionSnapshot | undefined>;
1662
+ declare function registerWorkspaceInstructionInjector(ctx: Context): void;
1663
+ declare const name = "dshb-workspace-instruction-injector";
1664
+ declare const inject: string[];
1665
+ //#endregion
1666
+ export { InstructionSnapshotResult, createInstructionMessage, escapeInstructionFrameBody, inject, name, registerWorkspaceInstructionInjector, renderInstructionMessageText, resolveSnapshotForSession };
1667
+ //# sourceMappingURL=workspace-instruction-context.d.ts.map