@artenx/dshb 0.1.18 → 0.1.20

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.
Files changed (112) hide show
  1. package/lib/auth/decorate-webserver.d.ts +2 -1
  2. package/lib/auth/decorate-webserver.js +21 -10
  3. package/lib/auth/decorate-webserver.js.map +1 -1
  4. package/lib/auth/gate.d.ts +3 -1
  5. package/lib/auth/gate.js +18 -1
  6. package/lib/auth/gate.js.map +1 -1
  7. package/lib/auth/index.js +11 -3
  8. package/lib/auth/index.js.map +1 -1
  9. package/lib/auth/webserver.d.ts +3 -1
  10. package/lib/auth/webserver.js +10 -1
  11. package/lib/auth/webserver.js.map +1 -1
  12. package/lib/client.js +2157 -567
  13. package/lib/client.js.map +1 -1
  14. package/lib/core/index.js +72 -4
  15. package/lib/core/index.js.map +1 -1
  16. package/lib/core/node-registry.d.ts +2 -108
  17. package/lib/core/node-registry.js +43 -2
  18. package/lib/core/node-registry.js.map +1 -1
  19. package/lib/core/routes.d.ts +4 -3
  20. package/lib/core/routes.js +67 -23
  21. package/lib/core/routes.js.map +1 -1
  22. package/lib/core/sync/coordinator.d.ts +48 -0
  23. package/lib/core/sync/coordinator.js +247 -0
  24. package/lib/core/sync/coordinator.js.map +1 -0
  25. package/lib/core/sync/host-key.d.ts +2 -0
  26. package/lib/core/sync/host-key.js +71 -0
  27. package/lib/core/sync/host-key.js.map +1 -0
  28. package/lib/core/sync/internal-routes.d.ts +9 -0
  29. package/lib/core/sync/internal-routes.js +236 -0
  30. package/lib/core/sync/internal-routes.js.map +1 -0
  31. package/lib/core/sync/model.d.ts +2 -0
  32. package/lib/core/sync/model.js +106 -0
  33. package/lib/core/sync/model.js.map +1 -0
  34. package/lib/core/sync/node-sync.d.ts +2 -0
  35. package/lib/core/sync/node-sync.js +660 -0
  36. package/lib/core/sync/node-sync.js.map +1 -0
  37. package/lib/core/sync/offline-archive.d.ts +55 -0
  38. package/lib/core/sync/offline-archive.js +673 -0
  39. package/lib/core/sync/offline-archive.js.map +1 -0
  40. package/lib/core/sync/offline-journal.d.ts +22 -0
  41. package/lib/core/sync/offline-journal.js +74 -0
  42. package/lib/core/sync/offline-journal.js.map +1 -0
  43. package/lib/core/sync/offline-routes.d.ts +7 -0
  44. package/lib/core/sync/offline-routes.js +192 -0
  45. package/lib/core/sync/offline-routes.js.map +1 -0
  46. package/lib/core/sync/peer-manager.d.ts +56 -0
  47. package/lib/core/sync/peer-manager.js +258 -0
  48. package/lib/core/sync/peer-manager.js.map +1 -0
  49. package/lib/core/sync/protocol.d.ts +2 -0
  50. package/lib/core/sync/protocol.js +124 -0
  51. package/lib/core/sync/protocol.js.map +1 -0
  52. package/lib/core/sync/remote-helper.d.ts +5 -0
  53. package/lib/core/sync/remote-helper.js +160 -0
  54. package/lib/core/sync/remote-helper.js.map +1 -0
  55. package/lib/core/sync/revision.d.ts +2 -0
  56. package/lib/core/sync/revision.js +77 -0
  57. package/lib/core/sync/revision.js.map +1 -0
  58. package/lib/core/sync/routes.d.ts +9 -0
  59. package/lib/core/sync/routes.js +339 -0
  60. package/lib/core/sync/routes.js.map +1 -0
  61. package/lib/core/sync/scheduler.d.ts +14 -0
  62. package/lib/core/sync/scheduler.js +81 -0
  63. package/lib/core/sync/scheduler.js.map +1 -0
  64. package/lib/core/sync/session-journal.d.ts +2 -0
  65. package/lib/core/sync/session-journal.js +191 -0
  66. package/lib/core/sync/session-journal.js.map +1 -0
  67. package/lib/core/sync/session-routes.d.ts +7 -0
  68. package/lib/core/sync/session-routes.js +67 -0
  69. package/lib/core/sync/session-routes.js.map +1 -0
  70. package/lib/core/sync/session-sync.d.ts +2 -0
  71. package/lib/core/sync/session-sync.js +2 -0
  72. package/lib/core/sync/ssh-transport.d.ts +2 -0
  73. package/lib/core/sync/ssh-transport.js +408 -0
  74. package/lib/core/sync/ssh-transport.js.map +1 -0
  75. package/lib/core/sync/stores.d.ts +3 -0
  76. package/lib/core/sync/stores.js +385 -0
  77. package/lib/core/sync/stores.js.map +1 -0
  78. package/lib/core/test.d.ts +1 -1
  79. package/lib/core/workspace-bindings.d.ts +2 -28
  80. package/lib/core/workspace-bindings.js +14 -14
  81. package/lib/core/workspace-bindings.js.map +1 -1
  82. package/lib/core/workspace-instruction-context.d.ts +3 -2260
  83. package/lib/core/workspace-instruction-context.js +104 -2
  84. package/lib/core/workspace-instruction-context.js.map +1 -0
  85. package/lib/core/workspace-instruction-routes.d.ts +1 -1
  86. package/lib/core/workspace-instructions.d.ts +2 -68
  87. package/lib/core/workspace-instructions.js +13 -0
  88. package/lib/core/workspace-instructions.js.map +1 -1
  89. package/lib/core/workspaces.d.ts +4 -3
  90. package/lib/core/workspaces.js +17 -1
  91. package/lib/core/workspaces.js.map +1 -1
  92. package/lib/host-key-C5afhAUd.d.ts +30 -0
  93. package/lib/index-VF8bcBeX.d.ts +2293 -0
  94. package/lib/{workspace-instruction-context-DytAmaPY.js → lib-gdtU_WKT.js} +159 -102
  95. package/lib/lib-gdtU_WKT.js.map +1 -0
  96. package/lib/model-BP7Gw1yk.d.ts +104 -0
  97. package/lib/node-registry-BTnnM5-k.d.ts +112 -0
  98. package/lib/node-sync-3Z9QLz2n.d.ts +89 -0
  99. package/lib/protocol-CV7LGE44.d.ts +35 -0
  100. package/lib/revision-C9sOlDZ6.d.ts +25 -0
  101. package/lib/router/router-fs.d.ts +12 -3
  102. package/lib/router/router-fs.js.map +1 -1
  103. package/lib/session-journal-pgPqcWn9.d.ts +40 -0
  104. package/lib/session-sync-EdfwUON5.js +2177 -0
  105. package/lib/session-sync-EdfwUON5.js.map +1 -0
  106. package/lib/session-sync-g6qKZzjV.d.ts +1252 -0
  107. package/lib/ssh-transport-BcIiLxsX.d.ts +55 -0
  108. package/lib/stores-CKyEt0yk.d.ts +31 -0
  109. package/lib/workspace-bindings-CsB0TIJB.d.ts +28 -0
  110. package/lib/workspace-instructions-DirYYiku.d.ts +69 -0
  111. package/package.json +20 -1
  112. package/lib/workspace-instruction-context-DytAmaPY.js.map +0 -1
@@ -0,0 +1,2293 @@
1
+ import { Context, Service } from "@deepseek-ai/cordis";
2
+ //#region ../../node_modules/@deepseek-ai/dsh-brand/lib/types/index.d.ts
3
+ /**
4
+ * Duplicate-install-safe nominal primitive helpers.
5
+ *
6
+ * A brand makes structurally identical strings or numbers non-interchangeable
7
+ * at the type level: a `SessionId` cannot be passed where a `ToolCallId` is
8
+ * expected, and an event sequence cannot be passed as a log offset. Comparison,
9
+ * logging, and serialization retain the underlying primitive behavior.
10
+ *
11
+ * This package owns no concrete domain value and keeps no runtime identity or mutable
12
+ * state, so independently installed copies produce interchangeable values.
13
+ *
14
+ * @module @deepseek-ai/dsh-brand
15
+ */
16
+ declare const BRAND: unique symbol;
17
+ /** A string carrying a compile-time-only brand `B`. */
18
+ type Branded<B extends string> = string & {
19
+ readonly [BRAND]: B;
20
+ };
21
+ /** A number carrying a compile-time-only brand `B`. */
22
+ type BrandedNumber<B extends string> = number & {
23
+ readonly [BRAND]: B;
24
+ };
25
+ //#endregion
26
+ //#region ../../node_modules/@deepseek-ai/dsh-typert-protocol/lib/types/owned-value.d.ts
27
+ /** Generic invocation-owned values returned by synchronous Client Context resolvers. */
28
+ /** Shared identity across independently bundled Context providers and Gateway. */
29
+ declare const TYPERT_OWNED_VALUE: unique symbol;
30
+ /** A borrowed payload paired with the invocation owner's idempotent cleanup. */
31
+ interface TypertOwnedValue<Value> extends Disposable {
32
+ readonly [TYPERT_OWNED_VALUE]: true;
33
+ readonly value: Value;
34
+ }
35
+ //#endregion
36
+ //#region ../../node_modules/@deepseek-ai/dsh-typert-protocol/lib/types/types.d.ts
37
+ declare const LOOKUP_HOST: unique symbol;
38
+ declare const LOOKUP_WIRE: unique symbol;
39
+ declare const CONTEXT_WIRE: unique symbol;
40
+ declare const RESOURCE_ID: unique symbol;
41
+ /** Type-level association between a Host object and its wire identity. */
42
+ interface TypertLookup<Host, Wire> {
43
+ readonly [LOOKUP_HOST]: Host;
44
+ readonly [LOOKUP_WIRE]: Wire;
45
+ }
46
+ /** Extract the Host object associated with one lookup declaration. */
47
+ type TypertLookupHost<Lookup> = Lookup extends TypertLookup<infer Host, infer _Wire> ? Host : never;
48
+ /** Extract the wire identity associated with one lookup declaration. */
49
+ type TypertLookupWire<Lookup> = Lookup extends TypertLookup<infer _Host, infer Wire> ? Wire : never;
50
+ /** Type-level association between a scoped Context kind and its wire identity. */
51
+ interface TypertContext<Wire> {
52
+ readonly [CONTEXT_WIRE]: Wire;
53
+ }
54
+ /** Extract the wire identity associated with one scoped Context declaration. */
55
+ type TypertContextWire<ContextType> = ContextType extends TypertContext<infer Wire> ? Wire : never;
56
+ /** Merge-extensible Host object lookup declarations. */
57
+ interface TypertLookupMap {}
58
+ /** Merge-extensible scoped Context declarations. */
59
+ interface TypertContextMap {}
60
+ /** Type-level association between a resource kind and its identity type. */
61
+ interface TypertResource<Id> {
62
+ readonly [RESOURCE_ID]: Id;
63
+ }
64
+ /** Extract the identity type associated with one resource declaration. */
65
+ type TypertResourceId<Resource> = Resource extends TypertResource<infer Id> ? Id : never;
66
+ /**
67
+ * Merge-extensible resource kinds whose identities a Remote call or forwarded
68
+ * event may carry. The package that owns an identity type declares its kind;
69
+ * the value is that kind's identity type, a string type such as a branded id.
70
+ * `global` names the built-in identity-less resource and is never a kind here.
71
+ */
72
+ interface TypertResourceMap {}
73
+ /** One declared resource kind. */
74
+ type TypertResourceKind = Extract<keyof TypertResourceMap, string>;
75
+ /** Awaitable disposer returned by Cordis-owned Typert registrations. */
76
+ type TypertDisposer = () => Promise<void>;
77
+ type StringKeyOf<Value> = Extract<keyof Value, string>;
78
+ /** Minimal runtime-schema capability carried by strict generated codecs. */
79
+ interface TypertSchema<Output = unknown> {
80
+ /**
81
+ * Parse and validate one boundary value.
82
+ * @param value - untrusted boundary value.
83
+ * @returns the validated value.
84
+ */
85
+ parse(value: unknown): Output;
86
+ }
87
+ /** Codec attached to one invocation parameter or result. */
88
+ type TypertCodec<Value = unknown> = (TypertRemoteValue<Value> & {
89
+ readonly mode: 'strict';
90
+ readonly typeSymbol: string;
91
+ /**
92
+ * Decode a unary result whose fields require type-specific handling.
93
+ * @param value - result reconstructed by the RPC carrier.
94
+ * @returns the validated result, retaining native byte views.
95
+ */
96
+ readonly decode?: ((value: unknown) => unknown) | undefined;
97
+ /**
98
+ * Project typed binary fields into RPC result attachments.
99
+ * @param value - native unary result.
100
+ * @param writeBytes - records a byte view at its result-relative path and returns its JSON placeholder.
101
+ * @returns JSON metadata with untouched JSON subtrees retained.
102
+ */
103
+ readonly encode?: ((value: unknown, writeBytes: (bytes: Uint8Array, path: readonly (string | number)[]) => null) => unknown) | undefined;
104
+ }) | {
105
+ readonly mode: 'src-json';
106
+ };
107
+ /** One ordered business parameter in a Remote invocation. */
108
+ interface InvocationParameterDescriptor {
109
+ /** Source-level parameter name. */
110
+ readonly name: string;
111
+ /** Source parameter documentation, independent of JSON Schema support. */
112
+ readonly description?: string;
113
+ /** Required key in the wire `args` object. */
114
+ readonly wire: string;
115
+ /** Whether the value is JSON or requires a registered Host lookup. */
116
+ readonly source: 'json' | 'lookup';
117
+ /** Lookup key when `source` is `lookup`. */
118
+ readonly lookup?: string;
119
+ /** Boundary codec for the wire representation. */
120
+ readonly codec: TypertCodec;
121
+ /** Missing wire fields decode to `undefined` only for an explicitly declared `T | undefined`. */
122
+ readonly acceptsUndefined?: true;
123
+ }
124
+ /** Source position retained for diagnostics from generated definitions. */
125
+ interface InvocationSourceLocation {
126
+ readonly file: string;
127
+ readonly line: number;
128
+ readonly column: number;
129
+ }
130
+ /** Carrier-independent description of one exported method invocation. */
131
+ interface InvocationDescriptor {
132
+ /** Globally stable generated identity. */
133
+ readonly id: string;
134
+ /** Cordis service key owning the method. */
135
+ readonly service: string;
136
+ /** Wire namespace, defaulting to the service key. */
137
+ readonly namespace: string;
138
+ /** Public instance method name. */
139
+ readonly method: string;
140
+ /** Service member invoked when the exported method name is an alias. */
141
+ readonly implementation?: string;
142
+ /** Absent for unary calls; stream calls deliver every yielded item as the Host produced it. */
143
+ readonly mode?: 'stream';
144
+ /** Receiver selection mode. */
145
+ readonly invocation: {
146
+ readonly kind: 'direct';
147
+ } | {
148
+ readonly kind: 'context';
149
+ readonly context: string;
150
+ readonly wire: string;
151
+ readonly codec: TypertCodec;
152
+ };
153
+ /** Optional consuming-Context projection for one direct lookup parameter. */
154
+ readonly scope?: {
155
+ /** Context kind whose Client adapter supplies the identity. */
156
+ readonly context: string;
157
+ /** Lookup parameter wire field replaced by the Context identity. */
158
+ readonly wire: string;
159
+ };
160
+ /** Ordered business parameters. */
161
+ readonly parameters: readonly InvocationParameterDescriptor[];
162
+ /**
163
+ * Client-to-Host items of the same logical stream, generated from the `In`
164
+ * type argument of the method's `RemoteStream<Out, In>` return type; absent
165
+ * when `In` is `never`. The method reads the items through
166
+ * `RemoteInvocation.uplink()`, so nothing enters the parameter list.
167
+ */
168
+ readonly uplink?: {
169
+ /** Codec validating every uplink item before `uplink()` delivers it. */
170
+ readonly codec: TypertCodec;
171
+ };
172
+ /** Transport cancellation injected after business parameters instead of entering wire args. */
173
+ readonly cancellation?: {
174
+ /** Reserved final Host method parameter. */
175
+ readonly parameter: 'signal';
176
+ };
177
+ /** Codec for the unary result or each yielded stream item. */
178
+ readonly result: TypertCodec;
179
+ /** Source-owned method documentation; ordinary methods need not have JSDoc. */
180
+ readonly description?: string;
181
+ /** Source declaration used only for diagnostics. */
182
+ readonly sourceLocation?: InvocationSourceLocation;
183
+ }
184
+ /**
185
+ * Opaque identity of one Peer: a party admitted to this Host by the connection
186
+ * layer. "Peer" is a connection-layer word; the browser application keeps the
187
+ * word "Client".
188
+ */
189
+ type PeerId = Branded<'PeerId'>;
190
+ /**
191
+ * Merge-extensible caller identities. Each driver declares its own entry.
192
+ * Every entry is a JSON value with a unique literal `kind`, carries no
193
+ * credential, and is safe to persist in a Session log.
194
+ */
195
+ interface PrincipalMap {
196
+ /** The local user who owns this Host. */
197
+ owner: {
198
+ readonly kind: 'owner';
199
+ };
200
+ }
201
+ /** One caller identity; the authorization layer reads only this. */
202
+ type Principal = PrincipalMap[keyof PrincipalMap];
203
+ /**
204
+ * One Peer's session on this Host. Its creator owns it: `ctx` is the Cordis
205
+ * scope that owns connection-lifetime registrations and is disposed with the
206
+ * Peer, and `principal` is the caller identity fixed when the Peer was created.
207
+ */
208
+ interface PeerScope {
209
+ readonly id: PeerId;
210
+ /** Connection-lifetime registrations; disposed with the Peer. */
211
+ readonly ctx: Context;
212
+ /** Caller identity fixed at creation by in-process Host code; no wire field can set it. */
213
+ readonly principal: Principal;
214
+ /** Aborted once the Peer is disposed; Remote streams that speak for the Peer end with it. */
215
+ readonly signal: AbortSignal;
216
+ /** Whether the Peer may open a forwarded-event stream; this does not grant business permissions. */
217
+ readonly interactions: 'answer' | 'none';
218
+ /**
219
+ * Tear down every registration made through `ctx`.
220
+ * @returns settles once the scope has quiesced; racing calls share one completion.
221
+ */
222
+ dispose(): Promise<void>;
223
+ }
224
+ /** Carrier capacity for buffered uplink frames of one logical stream. */
225
+ interface RemoteUplinkWindow {
226
+ /** Maximum complete encoded frame bytes waiting for the Host consumer. */
227
+ readonly maxBytes: number;
228
+ /** UTF-8 envelope bytes added to a compact JSON item with a present value field. */
229
+ readonly frameOverheadBytes: number;
230
+ }
231
+ /**
232
+ * The context of one Remote call, reachable inside the receiving method as
233
+ * `this.ctx.invocation`. The Gateway derives the receiver from a Context that
234
+ * carries it, so no parameter is injected and nothing crosses the wire.
235
+ */
236
+ interface RemoteInvocation {
237
+ readonly request: {
238
+ readonly namespace: string;
239
+ readonly method: string;
240
+ readonly args: Readonly<Record<string, unknown>>;
241
+ };
242
+ /** Cordis service key of the receiving Service. */
243
+ readonly service: string;
244
+ /** Peer the call speaks for; every carrier names it explicitly. */
245
+ readonly peer: PeerScope;
246
+ /** Carrier cancellation: Client cancel, socket close, or an uplink failure. */
247
+ readonly signal: AbortSignal;
248
+ /** Carrier frame capacity; absent when the carrier imposes no encoded-frame inbox limit. */
249
+ readonly uplinkWindow?: RemoteUplinkWindow | undefined;
250
+ /**
251
+ * The Client's uplink items for this call. Available once; a second call
252
+ * throws. With an uplink codec on the descriptor every item is decoded to
253
+ * `In`; without one items arrive as `unknown` after a JSON-safety check.
254
+ * Iteration ends when the Client ends its uplink; when the method finishes
255
+ * its downlink the Gateway calls the iterator's `return()` and unread items
256
+ * are dropped. `In` is the caller's assertion: the runtime decodes by the
257
+ * descriptor and does not cross-check it.
258
+ * @template In - item type the caller reads; the descriptor codec decides what arrives.
259
+ * @returns the single-consumer uplink iterable.
260
+ */
261
+ uplink<In = unknown>(): AsyncIterable<In>;
262
+ }
263
+ /** Generated Host contract selected explicitly by a Client assembly. */
264
+ interface TypertRemoteContribution {
265
+ /** npm package that owns the Remote methods. */
266
+ readonly package: string;
267
+ /** Consumer-side invocation descriptors generated from that package. */
268
+ readonly descriptors: readonly InvocationDescriptor[];
269
+ }
270
+ /** Generated parser and optional lossless tool-schema projection of one Remote value. */
271
+ interface TypertRemoteValue<Value = unknown> {
272
+ /** Materialize the generated parser without loading the owning Service. */
273
+ readonly create: () => TypertSchema<Value>;
274
+ /** Source-owned value documentation, independent of tool projection support. */
275
+ readonly description?: string | undefined;
276
+ /** Present when the value is representable in the tool-schema subset without losing constraints; may be derived lazily. */
277
+ readonly jsonSchema?: Readonly<Record<string, unknown>> | undefined;
278
+ /** Projection failure for consumers that require JSON Schema; parsing remains available. */
279
+ readonly jsonSchemaError?: string | undefined;
280
+ }
281
+ /**
282
+ * Resolve one validated wire identity, synchronously or asynchronously.
283
+ * @param id - validated wire identity.
284
+ * @returns the Host object, or `undefined` when unavailable.
285
+ */
286
+ type TypertLookupResolver<Host = unknown, Wire = unknown> = (id: Wire) => Host | undefined | Promise<Host | undefined>;
287
+ /** Resource kinds whose identity type is a wire identity; every kind for a type-erased provider. */
288
+ type TypertResourceKindFor<Wire> = unknown extends Wire ? TypertResourceKind : { [Kind in TypertResourceKind]: [Wire] extends [TypertResourceId<TypertResourceMap[Kind]>] ? Kind : never; }[TypertResourceKind];
289
+ /** Runtime provider for one declared Host object lookup. */
290
+ interface TypertLookupProvider<Host = unknown, Wire = unknown> {
291
+ /** Source parameter name recognized by the SRC weak parser. */
292
+ readonly parameter: string;
293
+ /** Wire field replacing the Host object parameter. */
294
+ readonly wire: string;
295
+ /** Resource kind the wire identity names; a parameter of this lookup carries that resource. */
296
+ readonly resource?: TypertResourceKindFor<Wire>;
297
+ /** Canonical Host type symbol used by strict generation. */
298
+ readonly hostTypeSymbol: string;
299
+ /** Canonical wire type symbol used by strict generation. */
300
+ readonly wireTypeSymbol: string;
301
+ /**
302
+ * Resolve a wire identity through the provider's default policy.
303
+ * @param id - validated wire identity.
304
+ * @returns the object, `undefined` when unavailable, or either asynchronously.
305
+ */
306
+ resolve(id: Wire): Host | undefined | Promise<Host | undefined>;
307
+ }
308
+ /** Stable wire declaration retained after a lookup provider unloads. */
309
+ interface TypertLookupDefinition {
310
+ /** Merge-declared lookup key. */
311
+ readonly key: string;
312
+ /** Source parameter name recognized by the SRC weak parser. */
313
+ readonly parameter: string;
314
+ /** Wire field replacing the Host object parameter. */
315
+ readonly wire: string;
316
+ /** Canonical Host type symbol used by strict generation. */
317
+ readonly hostTypeSymbol: string;
318
+ /** Canonical wire type symbol used by strict generation. */
319
+ readonly wireTypeSymbol: string;
320
+ }
321
+ /** Host wire-to-Context resolver plus the declaration used by strict Remote methods. */
322
+ interface TypertHostContextAdapter<Wire = unknown> {
323
+ /** Wire field carrying the Context identity. */
324
+ readonly wire: string;
325
+ /** Canonical wire type symbol used by strict generation. */
326
+ readonly wireTypeSymbol: string;
327
+ /** Resource kind the wire identity names; a call scoped to this Context carries that resource. */
328
+ readonly resource?: TypertResourceKindFor<Wire>;
329
+ /**
330
+ * Resolve a validated wire identity to a live Host Context.
331
+ * @param id - validated wire identity.
332
+ * @returns the Context, or `undefined` when it is unavailable.
333
+ */
334
+ resolve(id: Wire): Context | undefined | Promise<Context | undefined>;
335
+ }
336
+ /** Composition-owned resolver replacing one Host Context adapter's default lookup policy. */
337
+ type TypertHostContextResolver<Wire = unknown> = (id: Wire) => Context | undefined | Promise<Context | undefined>;
338
+ /** Client-side bidirectional Context adapter. */
339
+ interface TypertClientContextAdapter<Wire = unknown> {
340
+ /**
341
+ * Read the identity represented by a live Client Context.
342
+ * @param ctx - Client Context inspected by a scoped Remote caller.
343
+ * @returns the wire identity, or `undefined` for another Context kind.
344
+ */
345
+ identity(ctx: Context): Wire | undefined;
346
+ /**
347
+ * Resolve a validated identity synchronously for one Client invocation.
348
+ * @param id - validated wire identity.
349
+ * @returns a borrowed or invocation-owned Client Context, or undefined when unavailable.
350
+ */
351
+ resolve(id: Wire): Context | TypertOwnedValue<Context> | undefined;
352
+ }
353
+ /** Notification emitted after a Typert runtime registry changes. */
354
+ interface TypertRegistryChange {
355
+ readonly kind: 'local' | 'remote' | 'lookup' | 'host-context' | 'client-context' | 'resource';
356
+ readonly key: string;
357
+ }
358
+ /** Listener for one Typert runtime registry. */
359
+ type TypertRegistryListener = (change: TypertRegistryChange) => void;
360
+ /** Current-environment invocation definitions. */
361
+ interface TypertLocalRegistry {
362
+ /**
363
+ * Look up one invocation by `<namespace>/<method>`.
364
+ * @param endpoint - canonical endpoint.
365
+ * @returns the live descriptor, or `undefined` when absent.
366
+ */
367
+ get(endpoint: string): InvocationDescriptor | undefined;
368
+ /**
369
+ * Report whether a strict definition has existed during this Typert Service lifetime.
370
+ * @param endpoint - canonical endpoint.
371
+ * @returns `true` after the endpoint has been registered at least once, even if withdrawn.
372
+ */
373
+ hasSeen(endpoint: string): boolean;
374
+ /** @returns a registration-order snapshot of local descriptors. */
375
+ list(): readonly InvocationDescriptor[];
376
+ /**
377
+ * Observe later local-definition changes.
378
+ * @param listener - synchronous contained observer.
379
+ * @returns disposer for this subscription.
380
+ */
381
+ subscribe(listener: TypertRegistryListener): TypertDisposer;
382
+ }
383
+ /** Consumer-selected Remote contribution registry. */
384
+ interface TypertRemoteRegistry {
385
+ /**
386
+ * Register one generated contribution for the calling Cordis fiber.
387
+ * @param contribution - generated Remote descriptors.
388
+ * @returns disposer withdrawing the exact contribution.
389
+ */
390
+ register(contribution: TypertRemoteContribution): TypertDisposer;
391
+ /**
392
+ * Look up one Remote descriptor by endpoint.
393
+ * @param endpoint - canonical endpoint.
394
+ * @returns the descriptor, or `undefined` when unmounted.
395
+ */
396
+ get(endpoint: string): InvocationDescriptor | undefined;
397
+ /** @returns a registration-order snapshot of Remote descriptors. */
398
+ list(): readonly InvocationDescriptor[];
399
+ /**
400
+ * Observe later Remote contribution changes.
401
+ * @param listener - synchronous contained observer.
402
+ * @returns disposer for this subscription.
403
+ */
404
+ subscribe(listener: TypertRegistryListener): TypertDisposer;
405
+ }
406
+ /** Runtime registry for Host object lookup providers. */
407
+ interface TypertLookupRegistry {
408
+ /**
409
+ * Register one provider under its merge-declared key.
410
+ * @param key - lookup key.
411
+ * @param provider - owning package's live resolver.
412
+ * @returns disposer withdrawing the exact provider.
413
+ */
414
+ register<K extends StringKeyOf<TypertLookupMap>>(key: K, provider: TypertLookupProvider<TypertLookupHost<TypertLookupMap[K]>, TypertLookupWire<TypertLookupMap[K]>>): TypertDisposer;
415
+ /**
416
+ * Replace one provider's default resolution policy while this contribution is active.
417
+ * Configuration may precede provider registration; without a live provider, `get()` remains unavailable.
418
+ * @param key - lookup key whose wire declaration remains provider-owned.
419
+ * @param resolver - composition-owned resolver used by every lookup of this key.
420
+ * @returns disposer restoring the provider's default resolver.
421
+ */
422
+ configure<K extends StringKeyOf<TypertLookupMap>>(key: K, resolver: TypertLookupResolver<TypertLookupHost<TypertLookupMap[K]>, TypertLookupWire<TypertLookupMap[K]>>): TypertDisposer;
423
+ /**
424
+ * Look up one provider by runtime key.
425
+ * @param key - descriptor lookup key.
426
+ * @returns the live provider, or `undefined` when absent.
427
+ */
428
+ get(key: string): TypertLookupProvider | undefined;
429
+ /** @returns lookup declarations observed during this Typert Service lifetime. */
430
+ definitions(): readonly TypertLookupDefinition[];
431
+ /** @returns a snapshot of registered provider keys. */
432
+ keys(): readonly string[];
433
+ /**
434
+ * Observe later lookup changes.
435
+ * @param listener - synchronous contained observer.
436
+ * @returns disposer for this subscription.
437
+ */
438
+ subscribe(listener: TypertRegistryListener): TypertDisposer;
439
+ }
440
+ /** Runtime registry for the Host and Client adapters of each Context kind. */
441
+ interface TypertContextRegistry {
442
+ /**
443
+ * Register a Host Context adapter.
444
+ * @param key - merge-declared Context key.
445
+ * @param adapter - owning package's Host resolver and wire declaration.
446
+ * @returns disposer withdrawing the exact adapter.
447
+ */
448
+ registerHost<K extends StringKeyOf<TypertContextMap>>(key: K, adapter: TypertHostContextAdapter<TypertContextWire<TypertContextMap[K]>>): TypertDisposer;
449
+ /**
450
+ * Override one Host Context key's resolution policy for the calling fiber.
451
+ * Configuration may precede provider registration and restores the provider's default resolver on disposal.
452
+ * @param key - merge-declared Context key.
453
+ * @param resolver - composition-owned resolver used by every Host Context lookup of this key.
454
+ * @returns disposer restoring the provider's default resolver.
455
+ */
456
+ configureHost<K extends StringKeyOf<TypertContextMap>>(key: K, resolver: TypertHostContextResolver<TypertContextWire<TypertContextMap[K]>>): TypertDisposer;
457
+ /**
458
+ * Register a Client Context adapter.
459
+ * @param key - merge-declared Context key.
460
+ * @param adapter - owning package's bidirectional Client projection.
461
+ * @returns disposer withdrawing the exact adapter.
462
+ */
463
+ registerClient<K extends StringKeyOf<TypertContextMap>>(key: K, adapter: TypertClientContextAdapter<TypertContextWire<TypertContextMap[K]>>): TypertDisposer;
464
+ /**
465
+ * Look up a Host Context adapter; a configured resolver keeps the adapter's declaration and `resource`.
466
+ * @param key - descriptor Context key.
467
+ * @returns the adapter, or `undefined` when absent.
468
+ */
469
+ getHost(key: string): TypertHostContextAdapter | undefined;
470
+ /**
471
+ * Look up a Client Context adapter.
472
+ * @param key - descriptor Context key.
473
+ * @returns the adapter, or `undefined` when absent.
474
+ */
475
+ getClient(key: string): TypertClientContextAdapter | undefined;
476
+ /**
477
+ * Observe later Context adapter changes.
478
+ * @param listener - synchronous contained observer.
479
+ * @returns disposer for this subscription.
480
+ */
481
+ subscribe(listener: TypertRegistryListener): TypertDisposer;
482
+ }
483
+ /** Default wire field of one resource kind. */
484
+ interface TypertResourceDeclaration {
485
+ /** Top-level or first-object wire field holding one identity of the kind. */
486
+ readonly field: string;
487
+ }
488
+ /** One registered resource kind with its default wire field. */
489
+ interface TypertResourceEntry extends TypertResourceDeclaration {
490
+ /** Registered resource kind. */
491
+ readonly kind: string;
492
+ }
493
+ /** Runtime registry of resource kinds' default wire fields. */
494
+ interface TypertResourceRegistry {
495
+ /**
496
+ * Register one kind's default wire field for the calling fiber. Only the
497
+ * domain that owns the kind registers it.
498
+ * @param kind - merge-declared resource kind.
499
+ * @param declaration - the kind's default wire field.
500
+ * @returns disposer withdrawing the exact registration.
501
+ * @throws Error when the kind is already registered or is `global`, the built-in resource kind.
502
+ */
503
+ register(kind: TypertResourceKind, declaration: TypertResourceDeclaration): TypertDisposer;
504
+ /**
505
+ * Look up one kind's declaration.
506
+ * @param kind - resource kind.
507
+ * @returns the live declaration, or `undefined` when unregistered.
508
+ */
509
+ get(kind: string): TypertResourceDeclaration | undefined;
510
+ /** @returns a registration-order snapshot of registered kinds with their fields. */
511
+ entries(): readonly TypertResourceEntry[];
512
+ /**
513
+ * Observe later resource-kind changes.
514
+ * @param listener - synchronous contained observer.
515
+ * @returns disposer for this subscription.
516
+ */
517
+ subscribe(listener: TypertRegistryListener): TypertDisposer;
518
+ }
519
+ /** Minimal Typert runtime consumed through dependency inversion. */
520
+ interface TypertRegistryContract {
521
+ readonly local: TypertLocalRegistry;
522
+ readonly remotes: TypertRemoteRegistry;
523
+ readonly lookups: TypertLookupRegistry;
524
+ readonly contexts: TypertContextRegistry;
525
+ readonly resources: TypertResourceRegistry;
526
+ }
527
+ declare module '@deepseek-ai/cordis' {
528
+ interface Context {
529
+ typert: TypertRegistryContract;
530
+ /**
531
+ * The Remote call this Context was derived for, or `undefined` on a
532
+ * Context no Remote call derived. A Service method reads it as
533
+ * `this.ctx.invocation`.
534
+ */
535
+ readonly invocation: RemoteInvocation | undefined;
536
+ }
537
+ }
538
+ //#endregion
539
+ //#region ../../node_modules/@deepseek-ai/dsh-typert-protocol/lib/types/index.d.ts
540
+ /** Options for an explicit Service-to-Gateway binding. */
541
+ interface TypertGatewayBindingOptions {
542
+ /** Wire namespace; defaults to the Cordis service key. */
543
+ readonly namespace?: string;
544
+ }
545
+ /** Visible declaration that one Service participates in Typert Gateway export. */
546
+ interface TypertGatewayBinding<Service extends object = object> {
547
+ readonly service: Service;
548
+ readonly serviceKey: string;
549
+ readonly namespace: string;
550
+ }
551
+ /** Cordis Service base that exposes its registered name through Typert Gateway. */
552
+ declare abstract class TypertRemoteService<out T = never> extends Service<T> {
553
+ /** Visible binding consumed by the Gateway's source-mode discovery. */
554
+ readonly typertRemote: TypertGatewayBinding<this>;
555
+ /**
556
+ * Register the Service and bind the same key to Typert Gateway.
557
+ * @param ctx - owning Cordis Context.
558
+ * @param serviceKey - exact Cordis service key and default wire namespace.
559
+ * @param options - optional wire namespace.
560
+ */
561
+ protected constructor(ctx: Context, serviceKey: string, options?: TypertGatewayBindingOptions);
562
+ }
563
+ //#endregion
564
+ //#region ../../node_modules/@deepseek-ai/dsh-attachment/lib/types/error.d.ts
565
+ declare const ATTACHMENT_ERROR_CODES: readonly ["TOO_MANY_IMAGES", "IMAGES_TOO_LARGE", "UNSUPPORTED_IMAGE_TYPE", "INVALID_IMAGE_BASE64", "INVALID_IMAGE", "IMAGE_TYPE_MISMATCH", "IMAGE_TOO_LARGE", "IMAGE_TOO_MANY_PIXELS", "IMAGE_DIMENSION_TOO_LARGE", "INVALID_FILE_BASE64", "INVALID_ATTACHMENT_REF", "ATTACHMENT_CORRUPT", "ATTACHMENT_WRITE_FAILED", "ATTACHMENT_NOT_FOUND", "ATTACHMENT_READ_FAILED", "ATTACHMENT_PROJECTION_UNSUPPORTED", "ATTACHMENT_FILES_UNSUPPORTED"];
566
+ /** Stable attachment failure codes used for protocol error routing. */
567
+ type AttachmentErrorCode = typeof ATTACHMENT_ERROR_CODES[number];
568
+ /**
569
+ * Stable failures suitable for host RPC error mapping.
570
+ *
571
+ * Deliberately re-implements the `HarnessError` shape instead of extending it:
572
+ * the base lives in `@deepseek-ai/dsh-llm`, which itself depends on this
573
+ * package (`ImageBlock` references `ImageAttachmentRef`), so sharing the base
574
+ * would create a dependency cycle. Consumers route on `code`, never on the
575
+ * prototype chain, so the shapes stay interchangeable at the wire boundary.
576
+ */
577
+ declare class AttachmentError extends Error {
578
+ /** Stable machine-routing failure code. */
579
+ readonly code: AttachmentErrorCode;
580
+ /**
581
+ * @param message - human-readable failure description without raw bytes or host paths.
582
+ * @param code - stable machine-routing code.
583
+ * @param options - optional chained cause.
584
+ */
585
+ constructor(message: string, code: AttachmentErrorCode, options?: ErrorOptions);
586
+ }
587
+ //#endregion
588
+ //#region ../../node_modules/@deepseek-ai/dsh-attachment/lib/types/brand.d.ts
589
+ /** Opaque content-addressed identifier for one immutable attachment object. */
590
+ type AttachmentId = Branded<'AttachmentId'>;
591
+ /**
592
+ * Brand a validated storage identifier.
593
+ * @param value - backend-produced opaque identifier.
594
+ * @returns the branded identifier.
595
+ */
596
+ declare function AttachmentId(value: string): AttachmentId;
597
+ /** Opaque deterministic identity for one request-image transformation. */
598
+ type ImageVariantId = Branded<'ImageVariantId'>;
599
+ /**
600
+ * Brand a validated request-image transformation identifier.
601
+ * @param value - attachment-provider-produced opaque identifier.
602
+ * @returns the branded identifier.
603
+ */
604
+ declare function ImageVariantId(value: string): ImageVariantId;
605
+ //#endregion
606
+ //#region ../../node_modules/@deepseek-ai/dsh-attachment/lib/types/types.d.ts
607
+ /** Raster image formats accepted by the version-one attachment path. */
608
+ type ImageMediaType = 'image/png' | 'image/jpeg' | 'image/webp' | 'image/gif';
609
+ /** Durable, serializable reference to one immutable normalized image. */
610
+ interface ImageAttachmentRef {
611
+ /** Opaque storage identifier; never a filesystem path or bearer URL. */
612
+ attachmentId: AttachmentId;
613
+ /** Media type verified from the stored bytes. */
614
+ mediaType: ImageMediaType;
615
+ /** Exact encoded byte length. */
616
+ bytes: number;
617
+ /** Intrinsic encoded width in pixels. */
618
+ width: number;
619
+ /** Intrinsic encoded height in pixels. */
620
+ height: number;
621
+ /** Optional display name stripped of local path information. */
622
+ name?: string;
623
+ /**
624
+ * Input dimensions after applying EXIF orientation and before normalization
625
+ * scaling. Present only when normalization reduced the image.
626
+ */
627
+ originalDimensions?: {
628
+ width: number;
629
+ height: number;
630
+ };
631
+ }
632
+ /**
633
+ * Durable, serializable reference to one verbatim stored file. Files are
634
+ * stored byte-for-byte with no normalization; `attachmentId` is the sha256
635
+ * digest of exactly those bytes.
636
+ */
637
+ interface FileAttachmentRef {
638
+ /** Opaque content-addressed storage identifier; never a filesystem path or bearer URL. */
639
+ attachmentId: AttachmentId;
640
+ /** Sanitized display filename, also the stored object's leaf name. */
641
+ name: string;
642
+ /** Exact byte length. */
643
+ bytes: number;
644
+ }
645
+ /** Base64-encoded file upload accompanying one wire request. */
646
+ interface EncodedFileAttachment {
647
+ /** Canonical base64 encoding of the file bytes. */
648
+ data: string;
649
+ /** Optional display name; it is never interpreted as a path. */
650
+ name?: string;
651
+ }
652
+ /** Request to durably commit one file verbatim. */
653
+ interface SaveFileAttachment {
654
+ data: Uint8Array;
655
+ /** Optional browser/provider display name; it is never interpreted as a path. */
656
+ name?: string;
657
+ }
658
+ /** Request to durably commit one file from bounded byte chunks. */
659
+ interface SaveFileStreamAttachment {
660
+ /** Exact file bytes in order; providers must not retain the complete sequence in memory. */
661
+ data: AsyncIterable<Uint8Array>;
662
+ /** Optional cancellation for source reads and storage writes. */
663
+ signal?: AbortSignal;
664
+ /** Optional browser/provider display name; it is never interpreted as a path. */
665
+ name?: string;
666
+ }
667
+ /** Deployment-resolved limits used by upload admission and request buffering. */
668
+ interface ImageAttachmentLimits {
669
+ maxImageBytes: number;
670
+ maxImagesPerMessage: number;
671
+ maxMessageImageBytes: number;
672
+ maxImagePixels: number;
673
+ /** Maximum intrinsic width and maximum intrinsic height in pixels for one image. */
674
+ maxImageDimension: number;
675
+ mediaTypes: readonly ImageMediaType[];
676
+ }
677
+ /**
678
+ * Browser-submitted prompt content accepted by Host prompt endpoints; the
679
+ * accepting Host promotes image parts to durable references through
680
+ * `ctx.attachments.admitPromptContent()` before any message is created, so a wire caller can
681
+ * never cite an attachment it did not upload.
682
+ */
683
+ type PromptContentPart = {
684
+ readonly type: 'text';
685
+ readonly text: string;
686
+ } | {
687
+ readonly type: 'image';
688
+ readonly mediaType: ImageMediaType;
689
+ readonly data: string;
690
+ readonly name?: string;
691
+ };
692
+ /** Host prompt content whose file receipts are resolved and whose image bytes await admission. */
693
+ type AttachmentAdmissionPart = PromptContentPart | {
694
+ readonly type: 'file';
695
+ readonly attachment: FileAttachmentRef;
696
+ };
697
+ /** Host-admitted prompt content with every attachment represented by its durable reference. */
698
+ type AdmittedPromptContentPart = {
699
+ readonly type: 'text';
700
+ readonly text: string;
701
+ } | {
702
+ readonly type: 'image';
703
+ readonly attachment: ImageAttachmentRef;
704
+ } | {
705
+ readonly type: 'file';
706
+ readonly attachment: FileAttachmentRef;
707
+ };
708
+ /** Request to validate and durably commit one image. */
709
+ interface SaveImageAttachment {
710
+ data: Uint8Array;
711
+ /** Caller-declared media type, checked against fully decoded bytes. */
712
+ mediaType: ImageMediaType;
713
+ /** Optional browser/provider display name; it is never interpreted as a path. */
714
+ name?: string;
715
+ }
716
+ /** Stored image bytes returned after reference and digest verification. */
717
+ interface StoredImageAttachment {
718
+ ref: ImageAttachmentRef;
719
+ data: Uint8Array;
720
+ }
721
+ /** Deterministic request-image target selected by one exact model route for one attachment. */
722
+ interface ImageRequestTarget {
723
+ /** Target width in pixels; a target above the source keeps the source width. */
724
+ width: number;
725
+ /** Target height in pixels; a target above the source keeps the source height. */
726
+ height: number;
727
+ /** Encoded-byte target before base64 expansion or Files API upload; the smallest quality-ladder output is kept when no quality fits. */
728
+ maxBytes: number;
729
+ }
730
+ /** Cached request version derived from one provider-independent normalized attachment. */
731
+ interface RequestImageAttachment {
732
+ /** Cache and upload-index key over the attachment id, policy, and fixed encoder parameters. */
733
+ variantId: ImageVariantId;
734
+ /** Durable normalized attachment from which this request version was derived. */
735
+ attachment: ImageAttachmentRef;
736
+ /** Encoded request bytes. */
737
+ data: Uint8Array;
738
+ mediaType: ImageMediaType;
739
+ bytes: number;
740
+ width: number;
741
+ height: number;
742
+ /** Provider-compatible sample depth proven after request encoding. */
743
+ depth: 'uchar';
744
+ /** Provider-compatible color space proven after request encoding. */
745
+ space: 'srgb';
746
+ /** Whether the encoded request version retains an alpha channel. */
747
+ hasAlpha: boolean;
748
+ }
749
+ //#endregion
750
+ //#region ../../node_modules/@deepseek-ai/dsh-attachment/lib/types/index.d.ts
751
+ declare module '@deepseek-ai/cordis' {
752
+ interface Context {
753
+ attachments: AttachmentStore;
754
+ }
755
+ }
756
+ /** Immutable binary attachment service. Implementations validate bytes before publishing a reference. */
757
+ declare abstract class AttachmentStore extends Service {
758
+ constructor(ctx: Context);
759
+ /** Deployment-resolved image policy used by authoritative and fast-path validation. */
760
+ abstract readonly imageLimits: ImageAttachmentLimits;
761
+ /**
762
+ * Validate one image without persisting it.
763
+ * Batch callers validate every member before saving any member.
764
+ * @param input - encoded bytes, declared media type, and optional display name.
765
+ * @returns completion after the encoded raster has been fully decoded.
766
+ */
767
+ abstract validateImage(input: SaveImageAttachment): Promise<void>;
768
+ /**
769
+ * Validate one ordered image batch before committing any member.
770
+ * Validation failures start no writes; storage failures return no partial
771
+ * references, although already published content-addressed objects may stay
772
+ * unreachable until a future retention policy collects them.
773
+ * @param inputs - encoded images in their owning message order.
774
+ * @returns durable references in the exact input order.
775
+ */
776
+ protected validateImageBatch(inputs: readonly SaveImageAttachment[]): void;
777
+ /**
778
+ * Validate and durably commit one ordered image batch.
779
+ * @param inputs - encoded images in owning-message order.
780
+ * @returns durable normalized attachment references in the same order after every member succeeds.
781
+ */
782
+ saveImages(inputs: readonly SaveImageAttachment[]): Promise<readonly ImageAttachmentRef[]>;
783
+ /**
784
+ * Admit one Host prompt and replace each uploaded image with its durable reference.
785
+ * Text and durable file references pass through unchanged. A prompt without image parts performs no storage operation.
786
+ * @param content - prompt parts in message order after file receipt resolution.
787
+ * @returns admitted prompt parts in the same order as `content`.
788
+ * @throws AttachmentError when the image batch is refused.
789
+ */
790
+ admitPromptContent(content: readonly AttachmentAdmissionPart[]): Promise<AdmittedPromptContentPart[]>;
791
+ /**
792
+ * Decode and durably commit one canonical base64 file upload.
793
+ * @param input - canonical base64 bytes and optional display name.
794
+ * @returns the durable content-addressed file reference.
795
+ * @throws AttachmentError when the encoding or storage operation is refused.
796
+ */
797
+ admitEncodedFile(input: EncodedFileAttachment): Promise<FileAttachmentRef>;
798
+ /**
799
+ * Identify a failure emitted by this attachment capability by its stable code.
800
+ * @param error - value caught from an attachment operation.
801
+ * @returns whether the value is an attachment failure.
802
+ */
803
+ isAttachmentError(error: unknown): error is AttachmentError;
804
+ /**
805
+ * Validate and durably commit one image before its owning session event is appended.
806
+ * The returned reference describes the persisted normalized image. When
807
+ * normalization reduces the raster, its `originalDimensions` records the
808
+ * orientation-applied input dimensions.
809
+ * @param input - encoded bytes, declared media type, and optional display name.
810
+ * @returns the durable content-addressed normalized image reference.
811
+ */
812
+ abstract saveImage(input: SaveImageAttachment): Promise<ImageAttachmentRef>;
813
+ /**
814
+ * Read one image and verify that bytes still match the recorded reference.
815
+ * @param ref - durable reference from the session log.
816
+ * @param signal - optional cancellation for backend read and verification work.
817
+ * @returns the verified bytes and normalized attachment reference.
818
+ * @throws the signal reason when aborted, or a storage error when verification fails.
819
+ */
820
+ abstract readImage(ref: ImageAttachmentRef, signal?: AbortSignal): Promise<StoredImageAttachment>;
821
+ /**
822
+ * Locate the provider-owned normalized object in the harness host filesystem.
823
+ * @param ref - durable normalized attachment reference.
824
+ * @returns an absolute host path, or undefined when this backend is not host-file-backed.
825
+ * @throws an AttachmentError when the durable reference is invalid.
826
+ */
827
+ imageHostPath(ref: ImageAttachmentRef): string | undefined;
828
+ /**
829
+ * Durably commit one file byte-for-byte before its owning session event is
830
+ * appended. Files carry no admission limits: any byte content and length is
831
+ * accepted, and the stored object is the exact submitted bytes. Backends
832
+ * without verbatim file storage keep this default rejection.
833
+ * @param input - exact bytes and optional display name.
834
+ * @returns the durable content-addressed file reference.
835
+ */
836
+ saveFile(input: SaveFileAttachment): Promise<FileAttachmentRef>;
837
+ /**
838
+ * Durably commit one file byte-for-byte from bounded chunks. Providers must
839
+ * apply backpressure and must not collect the complete file in memory.
840
+ * Backends without streamed verbatim storage keep this default rejection.
841
+ * @param input - ordered exact bytes, optional cancellation, and display name.
842
+ * @returns the durable content-addressed file reference.
843
+ */
844
+ saveFileStream(input: SaveFileStreamAttachment): Promise<FileAttachmentRef>;
845
+ /**
846
+ * Read and verify one verbatim stored file as bounded chunks. Providers must
847
+ * not collect the complete file in memory. Backends without verbatim file
848
+ * reads keep this default rejection.
849
+ * @param ref - durable reference from the session log.
850
+ * @param signal - optional cancellation for backend reads and verification work.
851
+ * @returns exact file bytes in order; integrity failures reject the iteration.
852
+ */
853
+ readFileStream(ref: FileAttachmentRef, signal?: AbortSignal): AsyncIterable<Uint8Array>;
854
+ /**
855
+ * Locate the verbatim stored file object in the harness host filesystem.
856
+ * @param ref - durable file reference.
857
+ * @returns an absolute host path, or undefined when this backend is not host-file-backed.
858
+ * @throws an AttachmentError when the durable reference is invalid.
859
+ */
860
+ fileHostPath(ref: FileAttachmentRef): string | undefined;
861
+ /**
862
+ * Generate or read one deterministic model-request version from the stored normalized image.
863
+ * @param ref - durable provider-independent normalized attachment reference.
864
+ * @param target - route-chosen dimensions and byte target; an unmet byte target yields the smallest ladder output.
865
+ * @param signal - optional cancellation.
866
+ * @returns request bytes and the cache/upload identity covering every transform input.
867
+ */
868
+ readImageRequest(ref: ImageAttachmentRef, target: ImageRequestTarget, signal?: AbortSignal): Promise<RequestImageAttachment>;
869
+ }
870
+ //#endregion
871
+ //#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/brand.d.ts
872
+ /** Stable identity carried by one message across inbox, log, and model-request boundaries. */
873
+ type MessageId = Branded<'MessageId'>;
874
+ /**
875
+ * Brand a message identifier.
876
+ * @param id - the opaque message identifier.
877
+ * @returns the same string with the message-id brand.
878
+ */
879
+ declare function MessageId(id: string): MessageId;
880
+ /**
881
+ * Correlates a model-issued tool call with its result. Provider-issued for
882
+ * real adapters; synthesized by mocks/assembler fallbacks.
883
+ */
884
+ type ToolCallId = Branded<'ToolCallId'>;
885
+ /**
886
+ * Brand a string as a {@link ToolCallId}.
887
+ * @param id - the provider-issued or synthesized call id.
888
+ * @returns the same string with the tool-call-id brand.
889
+ */
890
+ declare function ToolCallId(id: string): ToolCallId;
891
+ /** Provider-issued request identifier retained for diagnostics across package boundaries. */
892
+ type ProviderRequestId = Branded<'ProviderRequestId'>;
893
+ /**
894
+ * Brand a provider-issued request identifier.
895
+ * @param id - the opaque provider-issued string.
896
+ * @returns the same string, branded; no validation is performed.
897
+ */
898
+ declare function ProviderRequestId(id: string): ProviderRequestId;
899
+ /** Adapter-owned identifier for one model's selectable reasoning effort. */
900
+ type ReasoningEffortId = Branded<'ReasoningEffortId'>;
901
+ /**
902
+ * Brand an adapter-owned reasoning-effort identifier.
903
+ * @param id - the opaque identifier exposed by one model capability.
904
+ * @returns the same string, branded; no validation is performed.
905
+ */
906
+ declare function ReasoningEffortId(id: string): ReasoningEffortId;
907
+ //#endregion
908
+ //#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/message.d.ts
909
+ /** Provider/model identity and adapter-private replay data for an assistant message. */
910
+ interface AssistantProviderMetadata {
911
+ /** Provider route that produced the message. */
912
+ provider: string;
913
+ /** Provider model id that produced the message. */
914
+ model: string;
915
+ /**
916
+ * Lossless-JSON adapter state needed to replay the provider response.
917
+ * `LlmRuntime` exposes it to a target adapter only when that adapter instance
918
+ * currently owns both this historical provider and the target provider.
919
+ */
920
+ replayState?: unknown;
921
+ }
922
+ /** Required source of an assistant message produced by a routed model. */
923
+ interface ModelMessageSource extends AssistantProviderMetadata {
924
+ kind: 'model';
925
+ }
926
+ /** Required source of a tool-role message carrying one tool result. */
927
+ interface ToolMessageSource {
928
+ kind: 'tool';
929
+ callId: ToolCallId;
930
+ }
931
+ /** Required source of a system-role message produced by the system-prompt plugin. */
932
+ interface SystemPromptMessageSource {
933
+ kind: 'system-prompt';
934
+ }
935
+ /**
936
+ * Where a message (or injected content) came from, in the harness's own
937
+ * vocabulary. Merge-extensible sum type — each producer declares its own
938
+ * `kind` in its own module; there is no shared catch-all `plugin` kind.
939
+ * Model and tool sources answer their role messages; user messages carry any
940
+ * producer's kind, and consumers fall through unknown kinds.
941
+ */
942
+ interface MessageSourceMap {
943
+ user: {
944
+ kind: 'user';
945
+ };
946
+ model: ModelMessageSource;
947
+ tool: ToolMessageSource;
948
+ 'system-prompt': SystemPromptMessageSource;
949
+ }
950
+ /** Any known message source, derived from {@link MessageSourceMap}; switch on `kind` and fall through unknowns (merge-extensible). */
951
+ type MessageSource = MessageSourceMap[keyof MessageSourceMap];
952
+ /** Shared immutable fields of every conversation message. */
953
+ interface MessageBase {
954
+ /** Stable identity preserved across every representation boundary. */
955
+ readonly id: MessageId;
956
+ /** Exact model-facing blocks. */
957
+ readonly content: readonly ContentBlock[];
958
+ /** Required source fields supplied by the producer.
959
+ * @persistenceSource user developer
960
+ */
961
+ readonly source: MessageSource;
962
+ }
963
+ /** A rendered system prompt attributed to the system-prompt producer; empty content sends no prompt. */
964
+ interface SystemMessage extends MessageBase {
965
+ readonly role: 'system';
966
+ readonly source: MessageSourceMap['system-prompt'];
967
+ }
968
+ /** Incremental agent session changes in conversation order, currently tool additions and removals. */
969
+ interface DeveloperMessage extends MessageBase {
970
+ readonly role: 'developer';
971
+ }
972
+ /** A user-role specialization of the shared message representation. */
973
+ interface UserMessage extends MessageBase {
974
+ readonly role: 'user';
975
+ }
976
+ /** A model-produced assistant specialization of the shared message representation. */
977
+ interface AssistantMessage extends MessageBase {
978
+ readonly role: 'assistant';
979
+ readonly source: ModelMessageSource;
980
+ }
981
+ /** A first-class tool-role message carrying the result of one tool invocation. */
982
+ interface ToolResultMessage extends MessageBase {
983
+ readonly role: 'tool';
984
+ readonly source: ToolMessageSource;
985
+ /** Provider-issued id of the tool call this message answers. */
986
+ readonly toolCallId: ToolCallId;
987
+ /** Whether the tool invocation failed. */
988
+ readonly isError?: boolean;
989
+ }
990
+ /**
991
+ * The conversation messages persisted by Session, keyed by role. This map is
992
+ * closed because every model-visible role must have a durable Session event
993
+ * and an adapter projection.
994
+ */
995
+ interface MessageRoleMap {
996
+ system: SystemMessage;
997
+ developer: DeveloperMessage;
998
+ user: UserMessage;
999
+ assistant: AssistantMessage;
1000
+ tool: ToolResultMessage;
1001
+ }
1002
+ /** Any persisted conversation message, discriminated by its `role`. */
1003
+ type Message = MessageRoleMap[keyof MessageRoleMap];
1004
+ type NewUserMessage = Omit<UserMessage, 'id' | 'role'>;
1005
+ /**
1006
+ * Create one identified user-role message and freeze it before publication.
1007
+ * @param input - complete content and source for a new user message.
1008
+ * @returns an immutable user message with a fresh stable identity.
1009
+ */
1010
+ declare function createUserMessage<T extends NewUserMessage>(input: T & {
1011
+ readonly id?: never;
1012
+ readonly role?: never;
1013
+ }): T & Pick<UserMessage, 'id' | 'role'>;
1014
+ //#endregion
1015
+ //#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/types.d.ts
1016
+ declare module '@deepseek-ai/cordis' {
1017
+ interface Events {
1018
+ /**
1019
+ * The provider topology changed: an adapter registered or unregistered
1020
+ * routes, or the configurable-provider directory gained or lost entries.
1021
+ * This payload-free registry notification fires at each commit point
1022
+ * (including registration disposal); consumers re-read `listProviders()`,
1023
+ * `listModels()`, or `listConfigurableProviders()` for the new state.
1024
+ * Observer failures are contained and cannot veto the registry mutation.
1025
+ * @mode emit
1026
+ */
1027
+ 'llm/adapters-updated'(): void;
1028
+ }
1029
+ }
1030
+ /** Serializable provider or transport failure facts; policy decides whether they are retryable. */
1031
+ interface LlmFailure {
1032
+ /** Human-readable provider or transport failure. */
1033
+ readonly message: string;
1034
+ /** Stable provider-neutral machine-routing code. */
1035
+ readonly code: string;
1036
+ /** HTTP status returned by the provider, when available. */
1037
+ readonly status?: number;
1038
+ /** Provider-requested delay in milliseconds, when valid and available. */
1039
+ readonly providerRetryAfterMs?: number;
1040
+ /** Opaque provider-issued request identifier for diagnostics. */
1041
+ readonly requestId?: ProviderRequestId;
1042
+ /**
1043
+ * With code `IMAGE_OFFLOAD_REQUIRED`: how many more of the oldest retained
1044
+ * image occurrences the route needs offloaded before the same request fits
1045
+ * its exact byte accounting. `dsh-compaction-image-offload` records the
1046
+ * selected occurrences in an `image/offload` event and retries the step.
1047
+ */
1048
+ readonly offloadImages?: number;
1049
+ }
1050
+ /** Plain text visible to the end user. */
1051
+ interface TextBlock {
1052
+ type: 'text';
1053
+ text: string;
1054
+ }
1055
+ /** Reasoning / thinking content, distinct from visible text. */
1056
+ interface ReasoningBlock {
1057
+ type: 'reasoning';
1058
+ text: string;
1059
+ }
1060
+ /**
1061
+ * A durable raster image reference, valid in user or assistant content. The
1062
+ * block is deliberately role-neutral; assistant-side rendering is forward
1063
+ * compatibility — the current production adapters declare text-only output,
1064
+ * so only user messages may carry images.
1065
+ */
1066
+ interface ImageBlock {
1067
+ type: 'image';
1068
+ /** Immutable bytes and intrinsic display metadata owned by the attachment service. */
1069
+ attachment: ImageAttachmentRef;
1070
+ /**
1071
+ * Derived from a durable image-offload decision or preserved by a message
1072
+ * rewrite. Every route sends placeholder text naming the image and its
1073
+ * available read-only path instead of image bytes.
1074
+ */
1075
+ offloaded?: true;
1076
+ }
1077
+ /**
1078
+ * A durable verbatim file reference, valid in user content. Files never reach
1079
+ * a provider natively: request assembly projects every occurrence to
1080
+ * deterministic handle text (name, byte size, and the read-only saved path),
1081
+ * so adapters and providers see text in its place while the durable log keeps
1082
+ * the structured reference for presentation and authorization.
1083
+ */
1084
+ interface FileBlock {
1085
+ type: 'file';
1086
+ /** Immutable verbatim bytes and display metadata owned by the attachment service. */
1087
+ attachment: FileAttachmentRef;
1088
+ }
1089
+ /** A tool invocation requested by the model. */
1090
+ interface ToolCallBlock {
1091
+ type: 'tool-call';
1092
+ /** Provider-issued call id; correlates with the matching tool result. */
1093
+ id: ToolCallId;
1094
+ name: string;
1095
+ /** Raw JSON string as produced by the model. */
1096
+ arguments: string;
1097
+ }
1098
+ /** Activates a tool definition from the developer event's referenced request header. */
1099
+ interface ToolAdditionBlock {
1100
+ type: 'tool-addition';
1101
+ /** Name of exactly one tool in the referenced historical header. */
1102
+ toolName: string;
1103
+ /**
1104
+ * Reserved against inline definitions; the historical request header owns the schema.
1105
+ * @persistenceReserved
1106
+ */
1107
+ tool?: never;
1108
+ }
1109
+ /** Records the dynamic removal of a tool identified by its session-local name. */
1110
+ interface ToolRemovalBlock {
1111
+ type: 'tool-removal';
1112
+ toolName: string;
1113
+ }
1114
+ /**
1115
+ * Merge-extensible content blocks keyed by `type`. New core blocks must land
1116
+ * with adapter, UI, and compaction support. Tool-change blocks belong to
1117
+ * developer messages; `projectToolUpdates` selects what each route receives.
1118
+ */
1119
+ interface ContentBlockMap {
1120
+ 'text': TextBlock;
1121
+ 'reasoning': ReasoningBlock;
1122
+ 'image': ImageBlock;
1123
+ 'file': FileBlock;
1124
+ 'tool-call': ToolCallBlock;
1125
+ 'tool-addition': ToolAdditionBlock;
1126
+ 'tool-removal': ToolRemovalBlock;
1127
+ }
1128
+ /** The block `type` tag vocabulary; widens as plugins add entries to {@link ContentBlockMap}. */
1129
+ type ContentBlockType = keyof ContentBlockMap;
1130
+ /** Any known content block, derived from {@link ContentBlockMap}; switch on `type` and fall through unknowns (merge-extensible). */
1131
+ type ContentBlock = ContentBlockMap[ContentBlockType];
1132
+ /**
1133
+ * Why a model response stopped.
1134
+ * Merge-extensible so adapters can surface provider-specific reasons.
1135
+ */
1136
+ interface FinishReasonMap {
1137
+ 'stop': {
1138
+ kind: 'stop';
1139
+ };
1140
+ 'tool-calls': {
1141
+ kind: 'tool-calls';
1142
+ };
1143
+ 'max-tokens': {
1144
+ kind: 'max-tokens';
1145
+ };
1146
+ 'aborted': {
1147
+ kind: 'aborted';
1148
+ failure: LlmFailure;
1149
+ };
1150
+ 'error': {
1151
+ kind: 'error';
1152
+ failure: LlmFailure;
1153
+ };
1154
+ }
1155
+ /** Any known finish reason, derived from {@link FinishReasonMap}; switch on `kind` and fall through unknowns (merge-extensible). */
1156
+ type FinishReason = FinishReasonMap[keyof FinishReasonMap];
1157
+ /**
1158
+ * Token accounting for one model call (cache fields are optional).
1159
+ *
1160
+ * Counts are DISJOINT: `inputTokens` is uncached input only; cached input is
1161
+ * reported separately as `cacheReadTokens`/`cacheWriteTokens` (billed input =
1162
+ * sum of the three). Adapters whose providers fold cache hits into a total
1163
+ * prompt count (DeepSeek's `prompt_tokens`) subtract them out.
1164
+ */
1165
+ interface TokenUsage {
1166
+ inputTokens: number;
1167
+ outputTokens: number;
1168
+ /**
1169
+ * Exact full-call total including aggregate prompt and output tokens.
1170
+ *
1171
+ * Adapters preserve a provider total or derive it from authoritative
1172
+ * aggregate prompt/output counters; they omit it when unavailable or
1173
+ * inconsistent.
1174
+ */
1175
+ totalTokens?: number;
1176
+ cacheReadTokens?: number;
1177
+ cacheWriteTokens?: number;
1178
+ reasoningTokens?: number;
1179
+ }
1180
+ /**
1181
+ * Request price of one ordered image occurrence under one exact model route's
1182
+ * request projection. Every occurrence resolves to the pair the wire actually
1183
+ * carries: provider visual tokens for a retained image, plus the model-visible
1184
+ * text sent with or instead of it (request-preview handle, offload placeholder,
1185
+ * or text-only substitution). The caller prices `text` with its own text
1186
+ * estimator so provider pricing never fixes a text tokenization.
1187
+ */
1188
+ interface LlmImageRequestPrice {
1189
+ /** Provider visual tokens for the retained request image; 0 when only text represents this occurrence. */
1190
+ visualTokens: number;
1191
+ /** Model-visible text sent for this occurrence, to be priced by the caller's text estimator. */
1192
+ text: string;
1193
+ }
1194
+ /**
1195
+ * Provider-side request-image pricing for one exact model route. Implemented
1196
+ * by adapters whose provider charges visual tokens; consumers (the token
1197
+ * meter) resolve it synchronously per measurement, so implementations must not
1198
+ * perform I/O.
1199
+ */
1200
+ interface LlmImageRequestPricing {
1201
+ /**
1202
+ * Price every image occurrence of one request projection.
1203
+ * @param images - surface image blocks in request order, one entry per occurrence; an `offloaded` block
1204
+ * is priced as its placeholder text.
1205
+ * @returns one price per occurrence, aligned by index with `images`.
1206
+ */
1207
+ priceImages(images: readonly ImageBlock[]): readonly LlmImageRequestPrice[];
1208
+ }
1209
+ /** Display metadata for one registered provider route. */
1210
+ interface LlmProviderInfo {
1211
+ /** Provider route key used by {@link GenerateOptions.provider}. */
1212
+ id: string;
1213
+ /** Human-readable provider name for selectors and diagnostics. */
1214
+ name: string;
1215
+ }
1216
+ /** Merge-extensible provider model modality vocabulary. */
1217
+ interface ModelModalityMap {
1218
+ text: 'text';
1219
+ image: 'image';
1220
+ }
1221
+ /** Any declared provider model modality. */
1222
+ type ModelModality = ModelModalityMap[keyof ModelModalityMap];
1223
+ /**
1224
+ * One provider route an adapter plugin can activate through configuration,
1225
+ * whether or not the route is currently registered. Configuration surfaces
1226
+ * merge this directory with `listProviders()` to offer every configurable
1227
+ * provider alongside its live/dormant state.
1228
+ */
1229
+ interface LlmConfigurableProvider {
1230
+ /** Provider route key this entry activates when configured. */
1231
+ provider: string;
1232
+ /** Human-readable provider name for configuration surfaces. */
1233
+ displayName: string;
1234
+ /** User-settings namespace whose section configures this provider. */
1235
+ settingsNs: string;
1236
+ /**
1237
+ * Path from that namespace's section root to this provider's profile
1238
+ * object; empty when the whole section is the profile.
1239
+ */
1240
+ settingsPath: readonly string[];
1241
+ /**
1242
+ * Whether the owning adapter knows this route only because configuration
1243
+ * declared it — a gateway or self-hosted server it ships nothing about.
1244
+ * Absent means the adapter draws no such distinction; false means it does
1245
+ * and this route is one of its own. Only the adapter can answer: a stored
1246
+ * profile is how a user-added route AND a corrected shipped one both look
1247
+ * from outside.
1248
+ */
1249
+ declared?: boolean;
1250
+ /**
1251
+ * Route endpoint the adapter uses when the profile sets no `baseURL`; the
1252
+ * adapter may still send an individual model to that model's own endpoint.
1253
+ * Absent when the route has no fixed endpoint.
1254
+ */
1255
+ defaultBaseURL?: string;
1256
+ /** Environment variables used to construct a provider endpoint; absent when none are reported. */
1257
+ baseURLEnv?: readonly string[];
1258
+ /** Authentication the adapter performs when the profile names no credential reference; absent when it reports none. */
1259
+ nativeAuth?: LlmNativeAuth;
1260
+ /** Configuration diagnostic for repair; unaffected models may remain serviceable. */
1261
+ error?: string;
1262
+ }
1263
+ /** Authentication a provider route performs without a credential reference in its profile. */
1264
+ interface LlmNativeAuth {
1265
+ /** Environment variables the route's authentication reads, in lookup order; empty when it reads none. */
1266
+ env: readonly string[];
1267
+ /** Whether a stored OAuth sign-in can authenticate the route. */
1268
+ oauth: boolean;
1269
+ }
1270
+ /**
1271
+ * One interrogation of a provider endpoint that configuration has not stored
1272
+ * yet. Configuration surfaces send the draft a user is still editing, so the
1273
+ * request carries the endpoint and credential directly instead of naming a
1274
+ * route: a provider being added has no route to name.
1275
+ */
1276
+ interface LlmModelDiscoveryRequest {
1277
+ /**
1278
+ * Route the draft is editing, when it edits an existing one. A route whose
1279
+ * adapter already knows its models answers from that knowledge instead of
1280
+ * asking the endpoint — the adapter's own registry is the better answer, and
1281
+ * it costs no network call.
1282
+ */
1283
+ provider?: string;
1284
+ /**
1285
+ * Endpoint to interrogate. Optional because a route the adapter already
1286
+ * describes needs none; a route it does not must supply one.
1287
+ */
1288
+ baseURL?: string;
1289
+ /** Wire protocol the endpoint speaks, when the draft names one. */
1290
+ api?: string;
1291
+ /** Credential for this interrogation alone; the harness never stores it. */
1292
+ apiKey?: string;
1293
+ }
1294
+ declare module '@deepseek-ai/dsh-typert-protocol' {
1295
+ interface RemoteErrorDetailsMap {
1296
+ /** A draft provider interrogation refused or failed. */
1297
+ 'llm/model-discovery-rejected': {
1298
+ readonly settingsNs: string;
1299
+ readonly baseURL?: string;
1300
+ };
1301
+ }
1302
+ }
1303
+ /**
1304
+ * One model an endpoint reports about itself. Every field but the id is
1305
+ * optional because most provider listings disclose an id and nothing else;
1306
+ * a surface adopting one of these still owes the capacities its adapter needs.
1307
+ */
1308
+ interface LlmDiscoveredModel {
1309
+ /** Model id the endpoint accepts. */
1310
+ id: string;
1311
+ /** Human-readable name when the endpoint supplies one. */
1312
+ name?: string;
1313
+ /** Maximum combined request and response context, when disclosed. */
1314
+ contextWindow?: number;
1315
+ /** Maximum output tokens, when disclosed. */
1316
+ maxTokens?: number;
1317
+ /** Accepted input types when disclosed by the catalog or endpoint; absent means unknown. */
1318
+ inputModalities?: readonly ModelModality[];
1319
+ }
1320
+ /** One adapter-discovered model; catalog membership is advisory, not request validation. */
1321
+ interface LlmModelInfo {
1322
+ /** Provider route that owns this model entry. */
1323
+ provider: string;
1324
+ /** Model id passed to {@link GenerateOptions.model}. */
1325
+ id: string;
1326
+ /** Human-readable model name for selectors. */
1327
+ name: string;
1328
+ /** Optional user-facing distinction from otherwise similar models. */
1329
+ description?: string;
1330
+ /** Accepted request modalities; absent means unknown, while an explicit omission is negative capability. */
1331
+ inputModalities?: readonly ModelModality[];
1332
+ }
1333
+ /** Provider-owned context capacity for one exact provider/model route. */
1334
+ interface LlmModelContext {
1335
+ /** Maximum combined request and response context in tokens. */
1336
+ contextWindow: number;
1337
+ }
1338
+ /** Display metadata for one adapter-owned reasoning effort. */
1339
+ interface LlmReasoningEffortInfo {
1340
+ /** Opaque stable value accepted by {@link GenerateOptions.reasoningEffort}. */
1341
+ id: ReasoningEffortId;
1342
+ /** Human-readable effort name for selectors and diagnostics. */
1343
+ name: string;
1344
+ /** Optional user-facing distinction from otherwise similar efforts. */
1345
+ description?: string;
1346
+ }
1347
+ /** Selectable reasoning efforts for one exact provider/model route. */
1348
+ interface LlmModelReasoningInfo {
1349
+ /** Supported efforts from least to greatest selectable reasoning effort, not predicted token use or latency. */
1350
+ efforts: readonly LlmReasoningEffortInfo[];
1351
+ /**
1352
+ * Adapter-configured default materialized into requests when callers omit
1353
+ * an effort. Absence preserves the provider's own default.
1354
+ */
1355
+ defaultEffort?: ReasoningEffortId;
1356
+ }
1357
+ /**
1358
+ * How a model applies a system prompt that changes mid-conversation.
1359
+ * `'in-history'`: the model reads the latest `system` message at any position
1360
+ * of `messages` as the complete effective system prompt, so a changed prompt
1361
+ * can follow the cached history instead of rewriting message 0.
1362
+ */
1363
+ type SystemPromptUpdate = 'in-history';
1364
+ /**
1365
+ * How a model accepts native tool declarations that change mid-conversation.
1366
+ * `'addition-only'`: the model reads a `tool-addition` block in a later
1367
+ * developer message as activating a tool declared with `deferLoading`, so an
1368
+ * added tool follows the cached history instead of rewriting the declaration
1369
+ * list. `'in-history'`: the model additionally reads `tool-removal` blocks,
1370
+ * so a removed tool keeps its declaration and the removal follows the history.
1371
+ * Absent means every request declares the complete current tool list.
1372
+ */
1373
+ type ToolUpdate = 'in-history' | 'addition-only';
1374
+ /** Exact-route model metadata resolved by its owning adapter. */
1375
+ interface LlmResolvedModelInfo extends LlmModelInfo {
1376
+ /** Provider-owned context capacity when known. */
1377
+ context?: LlmModelContext;
1378
+ /** Adapter-configured per-request output cap materialized when callers omit one. */
1379
+ defaultMaxTokens?: number;
1380
+ /** Adapter-owned selectable reasoning levels when exposed. */
1381
+ reasoning?: LlmModelReasoningInfo;
1382
+ /** Declared mid-conversation system prompt handling; absent means only a leading system message is read. */
1383
+ systemPromptUpdate?: SystemPromptUpdate;
1384
+ /** Declared mid-conversation tool declaration handling; absent means every request declares the complete tool list. */
1385
+ toolUpdate?: ToolUpdate;
1386
+ }
1387
+ /**
1388
+ * Adapter-private lossless-JSON state for replaying a successful response,
1389
+ * carried by a terminal `finish` chunk and stored on the assembled assistant
1390
+ * message's model source. Both halves stay opaque to the harness; only the
1391
+ * split is shared vocabulary, so assembly can keep stored metadata aligned
1392
+ * with stored content without reading either half.
1393
+ */
1394
+ interface ReplayEnvelope {
1395
+ /** Response-level adapter-private metadata (ids, native stop reason). */
1396
+ response: unknown;
1397
+ /**
1398
+ * Per-block adapter-private metadata, one entry per emitted block in
1399
+ * first-seen stream order. When assembly drops a block it drops the entry at
1400
+ * the same position; entries whose length does not match the emitted block
1401
+ * count discard the whole envelope. An adapter whose metadata is independent
1402
+ * of block structure omits this field and the envelope passes through
1403
+ * assembly unchanged.
1404
+ */
1405
+ blocks?: readonly unknown[];
1406
+ }
1407
+ /**
1408
+ * Raw streaming protocol emitted by adapters.
1409
+ * Block indexes correlate interleaved deltas, and `block-end` carries the
1410
+ * assembled block. Adapters emit usage before the terminal finish and nothing
1411
+ * afterward; tool arguments remain raw JSON strings. An adapter implementation
1412
+ * may throw, but `LlmRuntime.stream()` normalizes that failure to a terminal
1413
+ * `error` or `aborted` finish before exposing it to consumers.
1414
+ */
1415
+ type StreamChunk = {
1416
+ type: 'block-start';
1417
+ index: number;
1418
+ blockType: ContentBlockType;
1419
+ } | {
1420
+ type: 'text-delta';
1421
+ index: number;
1422
+ text: string;
1423
+ } | {
1424
+ type: 'reasoning-delta';
1425
+ index: number;
1426
+ text: string;
1427
+ } | {
1428
+ type: 'tool-call-delta';
1429
+ index: number;
1430
+ id: ToolCallId;
1431
+ name?: string;
1432
+ argumentsDelta: string;
1433
+ } | {
1434
+ type: 'block-end';
1435
+ index: number;
1436
+ block: ContentBlock;
1437
+ } | {
1438
+ type: 'usage';
1439
+ usage: TokenUsage;
1440
+ } | {
1441
+ type: 'finish';
1442
+ reason: FinishReason;
1443
+ /** Replay metadata for a successful response; see {@link ReplayEnvelope}. */
1444
+ replayState?: ReplayEnvelope;
1445
+ };
1446
+ /**
1447
+ * JSON-schema description of a tool, as sent to the model.
1448
+ *
1449
+ * Declared here (not in dsh-tools) because it is part of {@link GenerateOptions};
1450
+ * dsh-tools' ToolDefinition and dsh-system-prompt's PromptAssembly both import
1451
+ * it from this package.
1452
+ */
1453
+ interface ToolSchema {
1454
+ /**
1455
+ * Requests deferred loading of the tool definition into model context,
1456
+ * independently of whether a tool-addition block records the tool.
1457
+ * Uses Anthropic's defer_loading terminology.
1458
+ */
1459
+ deferLoading?: true;
1460
+ name: string;
1461
+ description: string;
1462
+ /** JSON Schema object for the arguments. */
1463
+ parameters: Record<string, unknown>;
1464
+ }
1465
+ /** User input for one LLM request; it has no durable Session identity or source. */
1466
+ interface RequestUserInput {
1467
+ readonly role: 'user';
1468
+ readonly content: UserMessage['content'];
1469
+ readonly id?: never;
1470
+ readonly source?: never;
1471
+ }
1472
+ /** A durable conversation message or a user input used only for one request. */
1473
+ type RequestMessage = Message | RequestUserInput;
1474
+ /** Logged tool declarations and update identities since the last declaration reset. */
1475
+ interface ToolHistory {
1476
+ /** Complete active declarations at the start of this history. */
1477
+ readonly tools: readonly ToolSchema[];
1478
+ /** Ordered developer messages, with additions resolved from their historical headers. */
1479
+ readonly updates: readonly {
1480
+ /** Identity used to locate this update in the derived request history. */
1481
+ readonly messageId: MessageId;
1482
+ /** Added definitions resolved from the event's referenced request header. */
1483
+ readonly additions: readonly ToolSchema[];
1484
+ }[];
1485
+ }
1486
+ /** A single model request, fully assembled. */
1487
+ interface GenerateOptions {
1488
+ /** Registered provider route selecting the adapter instance. */
1489
+ provider: string;
1490
+ model: string;
1491
+ /** Adapter-owned reasoning effort selected for this exact model. */
1492
+ reasoningEffort?: ReasoningEffortId;
1493
+ /**
1494
+ * Ordered conversation messages, exactly as the provider sees them. A
1495
+ * loop-built request passes the derived history (dsh-agent-loop), whose
1496
+ * leading system-role message carries the system prompt; a hand-built
1497
+ * one-shot may include identity-free user inputs.
1498
+ */
1499
+ messages: RequestMessage[];
1500
+ /**
1501
+ * System prompt text for one-shot callers; adapters map it to the provider's
1502
+ * system slot ahead of `messages`. Loop-built requests leave it undefined.
1503
+ */
1504
+ system?: string;
1505
+ /** Tool schemas (adapters map to the provider's `tools` field). */
1506
+ tools?: ToolSchema[];
1507
+ /** Session-folded tool history used for route projection; omission sends complete declarations without tool updates. */
1508
+ toolHistory?: ToolHistory;
1509
+ temperature?: number;
1510
+ maxTokens?: number;
1511
+ /**
1512
+ * Stop sequences: generation halts as soon as the model produces any one of
1513
+ * these strings (adapters map to the provider's stop field, e.g. OpenAI
1514
+ * `stop`). The stop string itself is not included in the output.
1515
+ */
1516
+ stop?: string[];
1517
+ signal?: AbortSignal;
1518
+ /**
1519
+ * Session identity stamped by the loop for request routing. Replay uses it
1520
+ * to separate cursors; adapters may map it to model-hidden transport metadata.
1521
+ */
1522
+ sessionId?: Branded<'SessionId'>;
1523
+ /**
1524
+ * Provider-neutral classification for an auxiliary model call. Adapters may
1525
+ * map the purpose to model-hidden transport metadata. Ordinary conversation
1526
+ * requests leave it unset.
1527
+ */
1528
+ purpose?: 'compaction' | 'session-title';
1529
+ }
1530
+ //#endregion
1531
+ //#region ../../node_modules/@deepseek-ai/cosmokit/lib/types/types.d.ts
1532
+ declare function isArrayBufferLike(value: any): value is ArrayBufferLike;
1533
+ declare function isArrayBufferSource(value: any): value is Binary.Source;
1534
+ /** Binary source detection and base64/hex conversion helpers. */
1535
+ declare namespace Binary {
1536
+ type Source<T extends ArrayBufferLike = ArrayBufferLike> = T | ArrayBufferView<T>;
1537
+ const is: typeof isArrayBufferLike;
1538
+ const isSource: typeof isArrayBufferSource;
1539
+ function fromSource<T extends ArrayBufferLike>(source: Source<T>): T;
1540
+ function toBase64(source: Source): string;
1541
+ function fromBase64(source: string): ArrayBuffer | Uint8Array<ArrayBuffer>;
1542
+ function toHex(source: Source): string;
1543
+ function fromHex(source: string): ArrayBuffer;
1544
+ }
1545
+ //#endregion
1546
+ //#region ../../node_modules/@deepseek-ai/cosmokit/lib/types/misc.d.ts
1547
+ /** String/symbol keyed dictionary type. */
1548
+ type Dict<T = any, K extends string | symbol = string> = { [key in K]: T; };
1549
+ //#endregion
1550
+ //#region ../../node_modules/@deepseek-ai/cosmokit/lib/types/volatile.d.ts
1551
+ /** Shared config references used by schema validators and plugin runtimes. */
1552
+ /** Recursively readonly data returned by a volatile config reference. */
1553
+ type VolatileSnapshot<T> = T extends object ? { readonly [K in keyof T]: VolatileSnapshot<T[K]>; } : T;
1554
+ /** A stable reference; keep the reference, or capture its value for one operation only. */
1555
+ interface Volatile<T> {
1556
+ /** @returns the current immutable snapshot, including undefined for an absent value. */
1557
+ get(): VolatileSnapshot<T>;
1558
+ }
1559
+ //#endregion
1560
+ //#region ../../node_modules/@standard-schema/spec/dist/index.d.ts
1561
+ /** The Standard Typed interface. This is a base type extended by other specs. */
1562
+ interface StandardTypedV1<Input = unknown, Output = Input> {
1563
+ /** The Standard properties. */
1564
+ readonly "~standard": StandardTypedV1.Props<Input, Output>;
1565
+ }
1566
+ declare namespace StandardTypedV1 {
1567
+ /** The Standard Typed properties interface. */
1568
+ interface Props<Input = unknown, Output = Input> {
1569
+ /** The version number of the standard. */
1570
+ readonly version: 1;
1571
+ /** The vendor name of the schema library. */
1572
+ readonly vendor: string;
1573
+ /** Inferred types associated with the schema. */
1574
+ readonly types?: Types<Input, Output> | undefined;
1575
+ }
1576
+ /** The Standard Typed types interface. */
1577
+ interface Types<Input = unknown, Output = Input> {
1578
+ /** The input type of the schema. */
1579
+ readonly input: Input;
1580
+ /** The output type of the schema. */
1581
+ readonly output: Output;
1582
+ }
1583
+ /** Infers the input type of a Standard Typed. */
1584
+ type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
1585
+ /** Infers the output type of a Standard Typed. */
1586
+ type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
1587
+ }
1588
+ /** The Standard Schema interface. */
1589
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
1590
+ /** The Standard Schema properties. */
1591
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
1592
+ }
1593
+ declare namespace StandardSchemaV1 {
1594
+ /** The Standard Schema properties interface. */
1595
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
1596
+ /** Validates unknown input values. */
1597
+ readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
1598
+ }
1599
+ /** The result interface of the validate function. */
1600
+ type Result<Output> = SuccessResult<Output> | FailureResult;
1601
+ /** The result interface if validation succeeds. */
1602
+ interface SuccessResult<Output> {
1603
+ /** The typed output value. */
1604
+ readonly value: Output;
1605
+ /** A falsy value for `issues` indicates success. */
1606
+ readonly issues?: undefined;
1607
+ }
1608
+ interface Options {
1609
+ /** Explicit support for additional vendor-specific parameters, if needed. */
1610
+ readonly libraryOptions?: Record<string, unknown> | undefined;
1611
+ }
1612
+ /** The result interface if validation fails. */
1613
+ interface FailureResult {
1614
+ /** The issues of failed validation. */
1615
+ readonly issues: ReadonlyArray<Issue>;
1616
+ }
1617
+ /** The issue interface of the failure output. */
1618
+ interface Issue {
1619
+ /** The error message of the issue. */
1620
+ readonly message: string;
1621
+ /** The path of the issue, if any. */
1622
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
1623
+ }
1624
+ /** The path segment interface of the issue. */
1625
+ interface PathSegment {
1626
+ /** The key representing a path segment. */
1627
+ readonly key: PropertyKey;
1628
+ }
1629
+ /** The Standard types interface. */
1630
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
1631
+ /** Infers the input type of a Standard. */
1632
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
1633
+ /** Infers the output type of a Standard. */
1634
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
1635
+ }
1636
+ //#endregion
1637
+ //#region ../../node_modules/@deepseek-ai/schemastery/lib/types/index.d.ts
1638
+ declare const kSchema: unique symbol;
1639
+ declare global {
1640
+ namespace Schemastery {
1641
+ /** Convert primitive constructors, constants, and existing schemas into a schema type. */
1642
+ 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;
1643
+ type TypeS1<X> = X extends Schema<infer S, infer _T, infer _M> ? S : never;
1644
+ type Inverse<X> = X extends Schema<infer _S, infer T, infer M> ? (arg: SchemaOutput<T, M>) => void : never;
1645
+ /** Input type accepted by a schema-like value. */
1646
+ type TypeS<X> = TypeS1<From<X>>;
1647
+ /** Output type returned by a schema-like value after validation. */
1648
+ type TypeT<X> = ReturnType<From<X>>;
1649
+ /** Resolver callback used by custom schema types registered with `Schema.extend()`. */
1650
+ type Resolve = (data: any, schema: Schema, options: Options, strict?: boolean) => [any, any?];
1651
+ /** Input type accepted by one schema in an intersection. */
1652
+ type IntersectS<X> = From<X> extends Schema<infer S, infer _T, infer _M> ? S : never;
1653
+ /** Output type returned by one schema in an intersection. */
1654
+ type IntersectT<X> = Inverse<From<X>> extends ((arg: infer T) => void) ? T : never;
1655
+ type TupleS<X extends readonly any[]> = X extends readonly [infer L, ...infer R] ? [TypeS<L>?, ...TupleS<R>] : any[];
1656
+ type TupleT<X extends readonly any[]> = X extends readonly [infer L, ...infer R] ? [TypeT<L>?, ...TupleT<R>] : any[];
1657
+ type ObjectS<X extends Dict> = { [K in keyof X]?: TypeS<X[K]> | null; } & Dict;
1658
+ type ObjectT<X extends Dict> = { [K in keyof X]: TypeT<X[K]>; } & Dict;
1659
+ type Constructor<T = any> = new (...args: any[]) => T;
1660
+ /** Static constructor and factory methods exposed by the default `Schema` export. */
1661
+ interface Static {
1662
+ <T = any>(options: Partial<Schema<T>>): Schema<T>;
1663
+ new <T = any>(options: Partial<Schema<T>>): Schema<T>;
1664
+ prototype: Schema;
1665
+ /** Validate a value against a schema node and return `[output, adaptedInput?]`. */
1666
+ resolve: Resolve;
1667
+ /** Infer a schema from a primitive value, constructor, or existing schema. */
1668
+ from<X = any>(source?: X): From<X>;
1669
+ /** Register a resolver for a custom schema `type`. */
1670
+ extend(type: string, resolve: Resolve): void;
1671
+ /** Accept any value without validation. */
1672
+ any<T = any>(): Schema<T>;
1673
+ /** Accept only nullable input. */
1674
+ never(): Schema<never>;
1675
+ /** Accept exactly one constant value. */
1676
+ const<const T>(value: T): Schema<T>;
1677
+ /** Accept strings, with optional metadata constraints added by instance methods. */
1678
+ string(): Schema<string>;
1679
+ /** Accept numbers, with optional range and step constraints. */
1680
+ number(): Schema<number>;
1681
+ /** Accept non-negative integer numbers. */
1682
+ natural(): Schema<number>;
1683
+ /** Accept a number between 0 and 1 and mark it as a slider. */
1684
+ percent(): Schema<number>;
1685
+ /** Accept booleans. */
1686
+ boolean(): Schema<boolean>;
1687
+ /** Accept `Date` instances or parse datetime strings into `Date` objects. */
1688
+ date(): Schema<string | Date, Date>;
1689
+ /** Accept `RegExp` instances or parse strings into regular expressions. */
1690
+ regExp(flag?: string): Schema<string | RegExp, RegExp>;
1691
+ /** Accept binary sources and normalize them to `ArrayBufferLike`. */
1692
+ arrayBuffer(): Schema<Binary.Source, ArrayBufferLike>;
1693
+ arrayBuffer(encoding: 'hex' | 'base64'): Schema<Binary.Source | string, ArrayBufferLike>;
1694
+ /** Accept a numeric bitset or string keys and normalize to a number. */
1695
+ bitset<K extends string>(bits: Partial<Record<K, number>>): Schema<number | readonly K[], number>;
1696
+ /** Accept functions. */
1697
+ function(): Schema<Function, (...args: any[]) => any>;
1698
+ /** Accept instances of a constructor or objects whose constructor name matches. */
1699
+ is(constructor: string): Schema;
1700
+ is<T>(constructor: Constructor<T>): Schema<T>;
1701
+ /** Accept arrays whose elements match `inner`. */
1702
+ array<X>(inner: X): Schema<TypeS<X>[], TypeT<X>[]>;
1703
+ /** Accept plain objects with values matching `inner` and optional key schema. */
1704
+ dict<X, Y extends Schema<any, string> = Schema<string>>(inner: X, sKey?: Y): Schema<Dict<TypeS<X>, TypeS<Y>>, Dict<TypeT<X>, TypeT<Y>>>;
1705
+ /** Accept tuple arrays where each index matches the corresponding schema. */
1706
+ tuple<const X extends readonly any[]>(list: X): Schema<TupleS<X>, TupleT<X>>;
1707
+ /** Accept plain objects; infer fields from the dictionary, not the enclosing schema's output type. */
1708
+ object<X extends Dict>(dict: X): Schema<ObjectS<NoInfer<X>>, ObjectT<NoInfer<X>>>;
1709
+ /** Accept values matching at least one schema in `list`. */
1710
+ union<const X>(list: readonly X[]): Schema<TypeS<X>, TypeT<X>>;
1711
+ /** Accept values matching every schema in `list`, merging object outputs. */
1712
+ intersect<const X>(list: readonly X[]): Schema<IntersectS<X>, IntersectT<X>>;
1713
+ /** Validate with `inner`, then convert the result with `callback`. */
1714
+ transform<X, T>(inner: X, callback: (value: TypeS<X>, options: Schemastery.Options) => T, preserve?: boolean): Schema<TypeS<X>, T>;
1715
+ /** Defer construction of a recursive schema until validation or serialization. */
1716
+ lazy<X extends Schema<any, any, SchemaMode>>(callback: () => X): X;
1717
+ ValidationError: typeof ValidationError;
1718
+ }
1719
+ /** Runtime validation options shared by all schema calls. */
1720
+ interface Options {
1721
+ /** Remove invalid object properties instead of throwing when possible. */
1722
+ autofix?: boolean;
1723
+ /** Skip validation for selected values and schema nodes. */
1724
+ ignore?(data: any, schema: Schema): boolean;
1725
+ /** Path used to format nested validation errors. */
1726
+ path?: (keyof any)[];
1727
+ }
1728
+ /** UI and validation metadata attached by schema builder methods. */
1729
+ interface Meta<T = any> {
1730
+ default?: T extends {} ? Partial<T> : T;
1731
+ required?: boolean;
1732
+ /** Parse this node as a stable config reference; its type and UI metadata remain unchanged. */
1733
+ volatile?: boolean;
1734
+ disabled?: boolean;
1735
+ collapse?: boolean;
1736
+ badges?: {
1737
+ text: string;
1738
+ type: string;
1739
+ }[];
1740
+ hidden?: boolean;
1741
+ loose?: boolean;
1742
+ role?: string;
1743
+ extra?: any;
1744
+ link?: string;
1745
+ description?: string | Dict<string>;
1746
+ comment?: string;
1747
+ pattern?: {
1748
+ source: string;
1749
+ flags?: string;
1750
+ };
1751
+ max?: number;
1752
+ min?: number;
1753
+ step?: number;
1754
+ }
1755
+ }
1756
+ /** Callable schema instance that validates input and returns normalized output. */
1757
+ interface Schemastery<S = any, T = S, Mode extends SchemaMode = 'plain'> {
1758
+ (data?: S | null, options?: Schemastery.Options): SchemaOutput<T, Mode>;
1759
+ new (data?: S | null, options?: Schemastery.Options): SchemaOutput<T, Mode>;
1760
+ [kSchema]: true;
1761
+ uid: number;
1762
+ meta: Schemastery.Meta<T>;
1763
+ type: string;
1764
+ sKey?: Schema;
1765
+ inner?: Schema;
1766
+ list?: Schema[];
1767
+ dict?: Dict<Schema>;
1768
+ bits?: Dict<number>;
1769
+ callback?: Function;
1770
+ constructor?: string | Function;
1771
+ builder?: Function;
1772
+ value?: T;
1773
+ refs?: Dict<Schema>;
1774
+ preserve?: boolean;
1775
+ '~standard': StandardSchemaV1.Props;
1776
+ /** Format this schema as a compact TypeScript-like type string. */
1777
+ toString(inline?: boolean): string;
1778
+ /** Serialize this schema, preserving shared and recursive references. */
1779
+ toJSON(): Schema<S, T, Mode>;
1780
+ /** Mark nullable input as invalid unless a default supplies a fallback. */
1781
+ required<R extends boolean = true>(value?: R): Schema<S, T, SetRequired<Mode, R>>;
1782
+ /**
1783
+ * Parse this config field as a stable reference containing immutable data.
1784
+ * @returns a schema whose output supports get(), including when the field is absent.
1785
+ */
1786
+ volatile(): Schema<NoInfer<S>, NoInfer<T>, Mode extends 'defined' | 'volatile-defined' ? 'volatile-defined' : 'volatile'>;
1787
+ /** Hide this schema node from UI renderers. */
1788
+ hidden(value?: boolean): Schema<S, T, Mode>;
1789
+ /** Return the default value instead of throwing when validation fails. */
1790
+ loose(value?: boolean): Schema<S, T, Mode>;
1791
+ /** Attach a renderer role and optional role-specific metadata. */
1792
+ role(text: string, extra?: any): Schema<S, T, Mode>;
1793
+ /** Attach an external documentation link. */
1794
+ link(link: string): Schema<S, T, Mode>;
1795
+ /** Set the fallback value used for nullable input. */
1796
+ default(value: T | NoInfer<Partial<S>>): Schema<S, T, SetRequired<Mode, true>>;
1797
+ /** Attach an auxiliary comment for documentation or form UIs. */
1798
+ comment(text: string): Schema<S, T, Mode>;
1799
+ /** Attach a localized or plain description for documentation or form UIs. */
1800
+ description(text: string): Schema<S, T, Mode>;
1801
+ /** Mark this schema node as disabled for form UIs. */
1802
+ disabled(value?: boolean): Schema<S, T, Mode>;
1803
+ /** Request collapsed rendering for nested form UIs. */
1804
+ collapse(value?: boolean): Schema<S, T, Mode>;
1805
+ /** Add a deprecated badge to this schema node. */
1806
+ deprecated(): Schema<S, T, Mode>;
1807
+ /** Add an experimental badge to this schema node. */
1808
+ experimental(): Schema<S, T, Mode>;
1809
+ /** Require strings to match a regular expression. */
1810
+ pattern(regexp: RegExp): Schema<S, T, Mode>;
1811
+ /** Set an inclusive maximum for numbers or collection lengths. */
1812
+ max(value: number): Schema<S, T, Mode>;
1813
+ /** Set an inclusive minimum for numbers or collection lengths. */
1814
+ min(value: number): Schema<S, T, Mode>;
1815
+ /** Set the numeric increment constraint. */
1816
+ step(value: number): Schema<S, T, Mode>;
1817
+ /** Add or replace an object property schema. */
1818
+ set(key: string, value: Schema): Schema<S, T, Mode>;
1819
+ /** Append a tuple, union, or intersection member schema. */
1820
+ push(value: Schema): Schema<S, T, Mode>;
1821
+ /** Remove values equal to schema defaults from normalized output. */
1822
+ simplify(value?: any): any;
1823
+ /** Return a schema clone with descriptions merged from locale messages. */
1824
+ i18n(messages: Dict): Schema<S, T, Mode>;
1825
+ /** Attach arbitrary metadata consumed by form renderers and downstream tools. */
1826
+ extra<K extends keyof Schemastery.Meta>(key: K, value: Schemastery.Meta[K]): Schema<S, T, Mode>;
1827
+ }
1828
+ }
1829
+ declare class ValidationError extends TypeError {
1830
+ options: Schemastery.Options;
1831
+ name: string;
1832
+ constructor(message: string, options: Schemastery.Options);
1833
+ static is(error: any): error is ValidationError;
1834
+ }
1835
+ type SchemaMode = 'plain' | 'defined' | 'volatile' | 'volatile-defined';
1836
+ type SchemaOutput<T, M extends SchemaMode> = M extends 'volatile' ? Volatile<T | undefined> : M extends 'volatile-defined' ? Volatile<T> : T;
1837
+ type SetRequired<M extends SchemaMode, R extends boolean> = M extends 'volatile' | 'volatile-defined' ? R extends true ? 'volatile-defined' : 'volatile' : R extends true ? 'defined' : 'plain';
1838
+ type Schema<S = any, T = S, Mode extends SchemaMode = 'plain'> = Schemastery<S, T, Mode>;
1839
+ declare const Schema: Schemastery.Static;
1840
+ //#endregion
1841
+ //#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/retry-policy.d.ts
1842
+ /** Fully resolved backoff shared by both retry modes. */
1843
+ interface ResolvedRetryBackoff {
1844
+ readonly initialDelayMs: number;
1845
+ readonly maxDelayMs: number;
1846
+ readonly jitterRatio: number;
1847
+ }
1848
+ /** Fully resolved bounded transient retry policy. */
1849
+ interface ResolvedNormalRetryPolicy extends ResolvedRetryBackoff {
1850
+ readonly mode: 'normal';
1851
+ readonly maxRetries: number;
1852
+ readonly retryableCodes: readonly string[];
1853
+ }
1854
+ /** Fully resolved unbounded retry policy. */
1855
+ interface ResolvedAlwaysRetryPolicy extends ResolvedRetryBackoff {
1856
+ readonly mode: 'always';
1857
+ }
1858
+ /** Immutable provider policy captured when its adapter route is registered. */
1859
+ type ResolvedRetryPolicy = ResolvedNormalRetryPolicy | ResolvedAlwaysRetryPolicy;
1860
+ //#endregion
1861
+ //#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/call-config.d.ts
1862
+ /** Concrete generation settings; omitted controls use the selected route's defaults. */
1863
+ interface LlmCallControls {
1864
+ reasoningEffort?: ReasoningEffortId;
1865
+ temperature?: number;
1866
+ maxTokens?: number;
1867
+ stop?: string[];
1868
+ }
1869
+ /**
1870
+ * Provider, model, reasoning effort, and sampling scalars of one conversation's
1871
+ * requests. Every field maps 1:1 onto the same-named `GenerateOptions` field;
1872
+ * the loop builds requests from the logged header rather than accepting these
1873
+ * per call.
1874
+ */
1875
+ interface LlmCallConfig extends LlmCallControls {
1876
+ provider: string;
1877
+ model: string;
1878
+ }
1879
+ /**
1880
+ * Synchronous, pure configuration of one call before defaults and validation.
1881
+ * Compose functions in the desired order; later writes replace earlier ones.
1882
+ * The returned controls cannot change the captured route. Errors reject
1883
+ * preparation before dispatch; only the resolved configuration is recordable.
1884
+ * @param controls - detached, deeply frozen proposed controls, without defaults.
1885
+ * @param model - detached, deeply frozen metadata from the captured adapter generation.
1886
+ * @returns concrete controls; omitted fields receive the route's defaults.
1887
+ */
1888
+ type ConfigureCall = (controls: Readonly<LlmCallControls>, model: Readonly<LlmResolvedModelInfo>) => LlmCallControls;
1889
+ /**
1890
+ * Effective config fields supplied by exact-model adapter resolution rather
1891
+ * than by the caller's request proposal.
1892
+ */
1893
+ interface LlmCallConfigAdapterDefaults {
1894
+ reasoningEffort?: true;
1895
+ maxTokens?: true;
1896
+ }
1897
+ //#endregion
1898
+ //#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/assistant-stream.d.ts
1899
+ /** Lossless compact records embedded in durable Assistant attempt events. */
1900
+ type AssistantStreamRecord = {
1901
+ readonly type: 'text-chunks';
1902
+ readonly time0: number;
1903
+ readonly index: number;
1904
+ readonly dt: readonly number[];
1905
+ readonly texts: readonly string[];
1906
+ } | {
1907
+ readonly type: 'reasoning-chunks';
1908
+ readonly time0: number;
1909
+ readonly index: number;
1910
+ readonly dt: readonly number[];
1911
+ readonly texts: readonly string[];
1912
+ } | {
1913
+ readonly type: 'tool-call-chunks';
1914
+ readonly time0: number;
1915
+ readonly index: number;
1916
+ readonly dt: readonly number[];
1917
+ readonly id: ToolCallId;
1918
+ readonly name?: string;
1919
+ readonly args: readonly string[];
1920
+ } | {
1921
+ readonly type: 'chunk';
1922
+ readonly time: number;
1923
+ readonly chunk: StreamChunk;
1924
+ };
1925
+ //#endregion
1926
+ //#region ../../node_modules/@deepseek-ai/dsh-llm/lib/types/index.d.ts
1927
+ declare module '@deepseek-ai/cordis' {
1928
+ interface Context {
1929
+ llm: LlmRuntime;
1930
+ }
1931
+ interface Events {
1932
+ /**
1933
+ * Waterfall around every streaming model call (retry, replay, routing).
1934
+ * Bound to the {@link LlmRuntime}; call `next()` to reach the resolved
1935
+ * adapter's stream, or yield your own chunks to short-circuit.
1936
+ * @param options - the full request. A LOOP-built request carries the
1937
+ * process-local {@link markAgentLoopRequest} identity and arrives deep-frozen
1938
+ * (mutation throws): its content is a pure function of the session log (the
1939
+ * reconstructability Agent Note), so listeners read it, never rewrite it.
1940
+ * Hand-built calls do not carry that marker; callers own their request
1941
+ * inputs and must keep them unchanged until the stream settles.
1942
+ * @mode waterfall
1943
+ */
1944
+ 'llm/stream'(this: LlmRuntime, options: GenerateOptions, next: () => AsyncIterable<StreamChunk>): AsyncIterable<StreamChunk>;
1945
+ }
1946
+ }
1947
+ /** One model call whose config and adapter registration were resolved together. */
1948
+ interface PreparedLlmCall {
1949
+ /** Detached, deep-frozen config with any adapter-owned default materialized. */
1950
+ readonly config: LlmCallConfig;
1951
+ /** Immutable retry policy captured with the adapter registration. */
1952
+ readonly retryPolicy: ResolvedRetryPolicy;
1953
+ /** Detached context metadata resolved with the registration-bound call. */
1954
+ readonly context?: LlmModelContext;
1955
+ /** Exact model modalities captured with the adapter dispatch generation. */
1956
+ readonly inputModalities?: readonly ModelModality[];
1957
+ /** Exact model system prompt update mode captured with the adapter dispatch generation. */
1958
+ readonly systemPromptUpdate?: SystemPromptUpdate;
1959
+ /** Exact model tool update mode captured with the adapter dispatch generation. */
1960
+ readonly toolUpdate?: ToolUpdate;
1961
+ /** Config fields materialized by the captured adapter rather than proposed by the caller. */
1962
+ readonly adapterDefaults: LlmCallConfigAdapterDefaults;
1963
+ /**
1964
+ * Dispatch this call once through the registration captured during
1965
+ * preparation. The request's call-config fields must match {@link config};
1966
+ * reuse or mismatch fails with `INVALID_PREPARED_CALL`.
1967
+ * @param options - fully assembled request carrying the prepared config.
1968
+ * @returns the chunk stream, including the `llm/stream` waterfall.
1969
+ */
1970
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
1971
+ }
1972
+ /** One adapter-owned model-resolution generation bound to its eventual stream call. */
1973
+ interface PreparedAdapterCall {
1974
+ /** Exact model metadata from the same adapter generation as {@link stream}. */
1975
+ readonly model: LlmResolvedModelInfo;
1976
+ /** Dispatch through that generation without re-reading dynamic connection facts. */
1977
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
1978
+ }
1979
+ /**
1980
+ * Provider-wire adapter for the harness message and stream vocabulary. Register implementations
1981
+ * with `ctx.llm.registerAdapter(providers, adapter)`. Every provider HTTP request must include
1982
+ * `attributionHeaders()`; prove the headers are added in the wire request or library header hook. The direct-fetch
1983
+ * DeepSeek and library-backed pi-ai adapters meet this contract through different internals.
1984
+ */
1985
+ declare abstract class LlmAdapter {
1986
+ /**
1987
+ * Describe one provider route owned by this adapter.
1988
+ * @param provider - a route passed to `registerAdapter()` for this instance.
1989
+ * @returns detached display metadata whose id must equal `provider`.
1990
+ */
1991
+ providerInfo(provider: string): LlmProviderInfo;
1992
+ /**
1993
+ * Return the provider-owned retry policy captured with this route.
1994
+ * @param _provider - a route passed to `registerAdapter()` for this instance.
1995
+ * @returns a resolved policy, or `undefined` to use the normal defaults.
1996
+ */
1997
+ providerRetryPolicy(_provider: string): ResolvedRetryPolicy | undefined;
1998
+ /**
1999
+ * Resolve provider-side request-image pricing for one exact model route.
2000
+ * The default declares none, so consumers fall back to their own neutral
2001
+ * estimate. Implementations must answer synchronously without I/O; the
2002
+ * token meter resolves this per measurement.
2003
+ * @param _provider - a route passed to `registerAdapter()` for this instance.
2004
+ * @param _model - exact model id passed to {@link GenerateOptions.model}.
2005
+ * @returns route-owned image pricing, or `undefined` when the route declares none.
2006
+ */
2007
+ imageRequestPricing(_provider: string, _model: string): LlmImageRequestPricing | undefined;
2008
+ /**
2009
+ * Resolve the image dimensions and byte target this adapter sends to the model.
2010
+ * The default preserves normalized images; adapters that resize must override it.
2011
+ * @param _provider - registered provider route.
2012
+ * @param _model - exact model id.
2013
+ * @param image - normalized image whose request projection is being resolved.
2014
+ * @returns the same target used by request serialization, before provider-internal processing.
2015
+ */
2016
+ imageRequestTarget(_provider: string, _model: string, image: ImageAttachmentRef): ImageRequestTarget;
2017
+ /**
2018
+ * List models this adapter can currently advertise for one owned provider.
2019
+ * Core routing accepts unlisted model ids; catalog-driven entry points such
2020
+ * as the GUI may require membership. Adapters used there must advertise
2021
+ * their available models; the base empty catalog offers no GUI selection.
2022
+ * @param _provider - one provider route owned by this adapter.
2023
+ * @returns discoverable models in adapter-preferred order.
2024
+ */
2025
+ listModels(_provider: string): Promise<readonly LlmModelInfo[]>;
2026
+ /**
2027
+ * Resolve all metadata available for one exact model. This query is
2028
+ * independent of the advisory catalog and does not validate request routing.
2029
+ * @param provider - one provider route owned by this adapter.
2030
+ * @param model - exact model id passed to {@link GenerateOptions.model}.
2031
+ * @param _signal - cancellation for this exact-model lookup; asynchronous
2032
+ * implementations must settle promptly after it aborts.
2033
+ * @returns provider/model identity plus any context, call-default, and reasoning metadata.
2034
+ */
2035
+ resolveModel(provider: string, model: string, _signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
2036
+ /**
2037
+ * Bind exact model metadata and the eventual request dispatch to one adapter generation.
2038
+ * Dynamic adapters override this so settings changes between preparation and
2039
+ * dispatch cannot combine one generation's capabilities with another's endpoint.
2040
+ * @param provider - registered provider route.
2041
+ * @param model - exact model id.
2042
+ * @param signal - cancellation for model resolution.
2043
+ * @returns model metadata and a one-generation stream entry point.
2044
+ */
2045
+ prepareCall(provider: string, model: string, signal?: AbortSignal): Promise<PreparedAdapterCall>;
2046
+ /**
2047
+ * Stream one model call as raw chunks. The only required method.
2048
+ * @param options - the fully-assembled request; implementations must honor `options.signal`.
2049
+ * @returns the chunk stream, obeying the adapter contract documented on `StreamChunk`.
2050
+ */
2051
+ abstract stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
2052
+ }
2053
+ /**
2054
+ * What {@link LlmRuntime.registerAdapter} returns: the disposer, plus an
2055
+ * atomic route replacement for the same adapter instance.
2056
+ */
2057
+ interface AdapterRegistrationHandle {
2058
+ /** Release every route this registration currently holds. */
2059
+ (): void;
2060
+ /**
2061
+ * Replace this registration's routes with `providers`, keeping the same
2062
+ * adapter instance. The candidate set is validated in full first — a
2063
+ * conflict with another adapter, an invalid name, or bad provider metadata
2064
+ * throws and leaves the current routes untouched — and the swap itself is
2065
+ * one synchronous section, so no request can observe a gap. An empty array
2066
+ * is legal here (a settings section that emptied holds zero routes while
2067
+ * staying registered), unlike an empty initial registration.
2068
+ *
2069
+ * Throws `LlmError` with code `REGISTRATION_DISPOSED` once the registration
2070
+ * has been released: its routes are gone and its disposer has already run,
2071
+ * so anything registered afterwards would have no owner left to release it.
2072
+ * @param providers - the complete next route set for this registration.
2073
+ */
2074
+ replace(providers: string[]): void;
2075
+ }
2076
+ /**
2077
+ * A live configurable-provider registration, disposable and atomically
2078
+ * replaceable — the directory counterpart of {@link AdapterRegistrationHandle}.
2079
+ */
2080
+ interface DirectoryRegistrationHandle {
2081
+ /** Withdraw every entry this registration currently holds. */
2082
+ (): void;
2083
+ /**
2084
+ * Replace this registration's entries with `entries`. The candidate set is
2085
+ * validated in full first — an entry another registration already declares,
2086
+ * a duplicate within the set, or invalid metadata throws and leaves the
2087
+ * current entries untouched — and the swap is one synchronous section, so no
2088
+ * reader observes a gap. An empty array is legal here, unlike an empty
2089
+ * initial registration.
2090
+ *
2091
+ * Throws `LlmError` with code `REGISTRATION_DISPOSED` once the registration
2092
+ * has been disposed.
2093
+ */
2094
+ replace(entries: readonly LlmConfigurableProvider[]): void;
2095
+ }
2096
+ /**
2097
+ * The abstract `llm` service: an adapter registry plus a streaming model-call
2098
+ * API, interceptable via the `llm/stream` waterfall.
2099
+ */
2100
+ declare class LlmRuntime extends TypertRemoteService {
2101
+ private adapters;
2102
+ private directory;
2103
+ private discoveries;
2104
+ constructor(ctx: Context);
2105
+ /** Notify topology observers without letting one broken listener veto the commit. */
2106
+ private emitAdaptersUpdated;
2107
+ /** Contained-listener diagnostic shared by the sync and async failure paths. */
2108
+ private warnAdaptersListenerFailure;
2109
+ /**
2110
+ * Register an adapter for the given provider routes. Throws `LlmError` with code
2111
+ * `DUPLICATE_ADAPTER` if any provider already has an adapter (all-or-nothing).
2112
+ * Disposed with the fiber.
2113
+ * @param providers - every provider route this adapter should serve.
2114
+ * @param adapter - the adapter that streams calls for those providers.
2115
+ * @returns the disposer, carrying {@link AdapterRegistrationHandle.replace}.
2116
+ */
2117
+ registerAdapter(providers: string[], adapter: LlmAdapter): AdapterRegistrationHandle;
2118
+ /**
2119
+ * Validate one candidate route set for `adapter`, treating routes this
2120
+ * registration already holds as available. Nothing is mutated: a rejected
2121
+ * candidate leaves the registry exactly as it was.
2122
+ */
2123
+ private prepareRoutes;
2124
+ /**
2125
+ * Swap this registration's routes for the prepared ones in one synchronous
2126
+ * section, so no observer can see the registry between the release and the
2127
+ * re-registration. The route set's one mutation point is also where
2128
+ * `llm/adapters-updated` is published, so a `replace` announces itself
2129
+ * exactly like a first registration.
2130
+ */
2131
+ private commitRoutes;
2132
+ /**
2133
+ * Describe provider routes with a registered adapter.
2134
+ * @returns detached provider metadata in registration order.
2135
+ */
2136
+ listProviders(): LlmProviderInfo[];
2137
+ /**
2138
+ * Declare provider routes an adapter plugin can activate through
2139
+ * configuration. Registration is all-or-nothing: an empty list, invalid
2140
+ * entry, or a provider already declared by any registration throws
2141
+ * `LlmError` without registering the rest. Disposed with the fiber.
2142
+ * @param entries - every configurable provider this plugin owns.
2143
+ * @returns a handle that withdraws all of them, and can atomically replace them.
2144
+ */
2145
+ registerConfigurableProviders(entries: readonly LlmConfigurableProvider[]): DirectoryRegistrationHandle;
2146
+ /**
2147
+ * List every declared configurable provider, registered or dormant.
2148
+ * @returns detached directory entries in declaration order.
2149
+ */
2150
+ listConfigurableProviders(): LlmConfigurableProvider[];
2151
+ /**
2152
+ * Offer to interrogate provider endpoints on behalf of the settings
2153
+ * namespace this plugin owns. The namespace is the key because that is what
2154
+ * a configuration surface already holds from the configurable-provider
2155
+ * directory, and because a provider being *added* has no route to name yet.
2156
+ * Disposed with the fiber.
2157
+ * @param settingsNs - the namespace whose profiles this discovery serves.
2158
+ * @param discover - interrogates one endpoint and must honor the supplied signal.
2159
+ * @returns the disposer that withdraws the offer.
2160
+ */
2161
+ registerModelDiscovery(settingsNs: string, discover: (request: LlmModelDiscoveryRequest, signal?: AbortSignal) => Promise<readonly LlmDiscoveredModel[]>): () => void;
2162
+ /**
2163
+ * Interrogate one provider endpoint for the models it advertises. The
2164
+ * request describes a draft, not a stored route, so nothing here reads or
2165
+ * writes settings or credentials — the caller owns both, and the reply is
2166
+ * candidate metadata a surface may offer for adoption.
2167
+ * @param settingsNs - namespace whose registered discovery serves this draft.
2168
+ * @param request - the endpoint, protocol, and one-shot credential to use.
2169
+ * @param signal - caller cancellation.
2170
+ * @returns the advertised models, deduplicated in endpoint order.
2171
+ */
2172
+ discoverModels(settingsNs: string, request: LlmModelDiscoveryRequest, signal?: AbortSignal): Promise<LlmDiscoveredModel[]>;
2173
+ /**
2174
+ * Remote adapter for one draft provider interrogation.
2175
+ * @param settingsNs - namespace whose registered discovery serves this draft.
2176
+ * @param request - endpoint, protocol, and one-shot credential to use.
2177
+ * @param signal - caller cancellation supplied by the Remote carrier.
2178
+ * @returns advertised models in endpoint order.
2179
+ * @throws RemoteError with `llm/model-discovery-rejected` when discovery refuses or fails.
2180
+ */
2181
+ remoteDiscoverModels(settingsNs: string, request: LlmModelDiscoveryRequest, signal: AbortSignal): Promise<LlmDiscoveredModel[]>;
2182
+ /**
2183
+ * Resolve the retry policy captured when one provider route was registered.
2184
+ * @param provider - registered provider route to inspect.
2185
+ * @returns the provider-owned policy, with normal defaults already resolved.
2186
+ */
2187
+ providerRetryPolicy(provider: string): ResolvedRetryPolicy;
2188
+ /**
2189
+ * Resolve provider-side request-image pricing for one exact route, or
2190
+ * `undefined` when the provider is unregistered or declares none. Unknown
2191
+ * providers degrade to `undefined` rather than throwing because callers
2192
+ * price durable history whose route may no longer be mounted.
2193
+ * @param provider - provider route named by a request header.
2194
+ * @param model - exact model id named by the same header.
2195
+ * @returns the owning adapter's image pricing for the route, when declared.
2196
+ */
2197
+ imageRequestPricing(provider: string, model: string): LlmImageRequestPricing | undefined;
2198
+ /**
2199
+ * Resolve the image projection for an exact registered model route.
2200
+ * @param provider - registered provider route.
2201
+ * @param model - exact model id.
2202
+ * @param image - normalized image reference.
2203
+ * @returns dimensions and byte target used by the adapter's request serializer.
2204
+ */
2205
+ imageRequestTarget(provider: string, model: string, image: ImageAttachmentRef): ImageRequestTarget;
2206
+ /**
2207
+ * Resolve the exact text one durable file occurrence contributes to every
2208
+ * provider request in the current execution environment.
2209
+ * @param ref - durable verbatim file reference from model history.
2210
+ * @returns the same deterministic handle text used at adapter dispatch.
2211
+ */
2212
+ fileRequestText(ref: FileAttachmentRef): string;
2213
+ /** Detach typed adapter-owned modality metadata. */
2214
+ private detachedModalities;
2215
+ /**
2216
+ * Discover models advertised by one registered provider. Catalog membership
2217
+ * does not constrain core routing. Catalog-driven entry points may restrict
2218
+ * selection and submission to the advertised models.
2219
+ * @param provider - registered provider route to inspect.
2220
+ * @returns detached model metadata in adapter-preferred order.
2221
+ */
2222
+ listModels(provider: string): Promise<LlmModelInfo[]>;
2223
+ /**
2224
+ * Resolve and validate all metadata from the adapter that owns one exact
2225
+ * route. The result is detached from adapter-owned objects; catalog
2226
+ * membership remains advisory and does not control request routing.
2227
+ * @param provider - registered provider route to inspect.
2228
+ * @param model - exact model id passed to the adapter.
2229
+ * @param signal - optional cancellation for adapter-owned asynchronous lookup.
2230
+ * @returns exact model identity plus available context and reasoning metadata.
2231
+ */
2232
+ resolveModelInfo(provider: string, model: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
2233
+ private resolveModelInfoFor;
2234
+ /** Validate and detach one adapter-returned exact model result. */
2235
+ private normalizeModelInfo;
2236
+ /**
2237
+ * Validate a conversation call config against its exact model capability and
2238
+ * materialize adapter-configured defaults. Unsupported explicit efforts
2239
+ * reject before provider I/O; no clamping or aliasing is performed. This
2240
+ * standalone query does not bind a later dispatch; use {@link prepareCall}
2241
+ * when logging and streaming must share one adapter registration.
2242
+ * @param config - provider/model route and optional request controls.
2243
+ * @param signal - optional cancellation for adapter-owned capability lookup.
2244
+ * @returns a detached config only when a default must be materialized.
2245
+ */
2246
+ resolveCallConfig(config: LlmCallConfig, signal?: AbortSignal): Promise<LlmCallConfig>;
2247
+ private resolveCallFor;
2248
+ /** Validate request controls against one already-bound exact model result. */
2249
+ private resolveCallWithInfo;
2250
+ /**
2251
+ * Resolve one call under its current adapter registration. The returned
2252
+ * one-shot handle keeps that registration across header logging and dispatch,
2253
+ * so HMR cannot combine one adapter's capability result with another adapter.
2254
+ * An optional synchronous callback selects concrete controls using captured
2255
+ * model metadata. Defaults and validation apply to its result. Callback
2256
+ * failures and cancellation reject preparation before dispatch.
2257
+ * @param config - provider/model route and optional concrete request controls.
2258
+ * @param signal - optional cancellation for adapter-owned capability lookup.
2259
+ * @param configure - pure control selection, called once before defaults and validation.
2260
+ * @returns a prepared config and its registration-bound stream entry point.
2261
+ */
2262
+ prepareCall(config: LlmCallConfig, signal?: AbortSignal, configure?: ConfigureCall): Promise<PreparedLlmCall>;
2263
+ private registration;
2264
+ /** Remove replay state whose historical route is owned by another adapter. */
2265
+ private forAdapter;
2266
+ /**
2267
+ * Resolve the current execution-world read path of one durable file
2268
+ * reference through the mounted attachment and filesystem providers.
2269
+ */
2270
+ private fileReadPath;
2271
+ /**
2272
+ * Final adapter boundary. Adapter selection, dispatch, iterator construction,
2273
+ * and iteration failures become one terminal failure chunk. Middleware and
2274
+ * downstream consumer failures remain thrown plugin or consumer errors.
2275
+ */
2276
+ private adapterStream;
2277
+ /**
2278
+ * Stream one model call as raw chunks (token-level deltas). Replay state is
2279
+ * retained only when the same adapter instance owns its historical provider
2280
+ * and the target provider. Final adapter selection remains fixed through
2281
+ * asynchronous exact-model resolution and dispatch. Adapter selection,
2282
+ * dispatch, and iteration failures become terminal `error` or `aborted`
2283
+ * finish chunks; middleware, nested-call, cleanup, and consumer failures
2284
+ * remain thrown.
2285
+ * @param options - the full request; `options.provider` selects the adapter.
2286
+ * @returns the chunk stream, possibly wrapped by `llm/stream` listeners.
2287
+ */
2288
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
2289
+ private streamWithRegistration;
2290
+ }
2291
+ //#endregion
2292
+ export { BrandedNumber as S, FileAttachmentRef as _, SystemPromptUpdate as a, TypertResource as b, ToolSchema as c, Message as d, SystemMessage as f, ToolCallId as g, createUserMessage as h, LlmFailure as i, AssistantMessage as l, UserMessage as m, LlmCallConfig as n, TokenUsage as o, ToolResultMessage as p, LlmCallConfigAdapterDefaults as r, ToolHistory as s, AssistantStreamRecord as t, DeveloperMessage as u, ImageAttachmentRef as v, Branded as x, TypertLookup as y };
2293
+ //# sourceMappingURL=index-VF8bcBeX.d.ts.map