@aryacode/dsh-local-llm 0.0.0-stage → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts ADDED
@@ -0,0 +1,2411 @@
1
+ import { networkInterfaces } from "node:os";
2
+ import { IncomingMessage } from "node:http";
3
+ import si from "systeminformation";
4
+ //#region node_modules/.pnpm/@deepseek-ai+cosmokit@1.8.5/node_modules/@deepseek-ai/cosmokit/lib/types/misc.d.ts
5
+ /** String/symbol keyed dictionary type. */
6
+ type Dict<T = any, K extends string | symbol = string> = { [key in K]: T; };
7
+ /** Wrap a value in `Promise`, preserving the resolved type of existing promises. */
8
+ type Promisify<T> = Promise<T extends Promise<infer S> ? S : T>;
9
+ /** Accept a value or promise unless the value type is already promise-like. */
10
+ type Awaitable<T> = [T] extends [Promise<unknown>] ? T : T | Promise<T>;
11
+ //#endregion
12
+ //#region node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
13
+ /** The Standard Typed interface. This is a base type extended by other specs. */
14
+ interface StandardTypedV1<Input = unknown, Output = Input> {
15
+ /** The Standard properties. */
16
+ readonly "~standard": StandardTypedV1.Props<Input, Output>;
17
+ }
18
+ declare namespace StandardTypedV1 {
19
+ /** The Standard Typed properties interface. */
20
+ interface Props<Input = unknown, Output = Input> {
21
+ /** The version number of the standard. */
22
+ readonly version: 1;
23
+ /** The vendor name of the schema library. */
24
+ readonly vendor: string;
25
+ /** Inferred types associated with the schema. */
26
+ readonly types?: Types<Input, Output> | undefined;
27
+ }
28
+ /** The Standard Typed types interface. */
29
+ interface Types<Input = unknown, Output = Input> {
30
+ /** The input type of the schema. */
31
+ readonly input: Input;
32
+ /** The output type of the schema. */
33
+ readonly output: Output;
34
+ }
35
+ /** Infers the input type of a Standard Typed. */
36
+ type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
37
+ /** Infers the output type of a Standard Typed. */
38
+ type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
39
+ }
40
+ /** The Standard Schema interface. */
41
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
42
+ /** The Standard Schema properties. */
43
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
44
+ }
45
+ declare namespace StandardSchemaV1 {
46
+ /** The Standard Schema properties interface. */
47
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
48
+ /** Validates unknown input values. */
49
+ readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
50
+ }
51
+ /** The result interface of the validate function. */
52
+ type Result<Output> = SuccessResult<Output> | FailureResult;
53
+ /** The result interface if validation succeeds. */
54
+ interface SuccessResult<Output> {
55
+ /** The typed output value. */
56
+ readonly value: Output;
57
+ /** A falsy value for `issues` indicates success. */
58
+ readonly issues?: undefined;
59
+ }
60
+ interface Options {
61
+ /** Explicit support for additional vendor-specific parameters, if needed. */
62
+ readonly libraryOptions?: Record<string, unknown> | undefined;
63
+ }
64
+ /** The result interface if validation fails. */
65
+ interface FailureResult {
66
+ /** The issues of failed validation. */
67
+ readonly issues: ReadonlyArray<Issue>;
68
+ }
69
+ /** The issue interface of the failure output. */
70
+ interface Issue {
71
+ /** The error message of the issue. */
72
+ readonly message: string;
73
+ /** The path of the issue, if any. */
74
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
75
+ }
76
+ /** The path segment interface of the issue. */
77
+ interface PathSegment {
78
+ /** The key representing a path segment. */
79
+ readonly key: PropertyKey;
80
+ }
81
+ /** The Standard types interface. */
82
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
83
+ /** Infers the input type of a Standard. */
84
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
85
+ /** Infers the output type of a Standard. */
86
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
87
+ }
88
+ //#endregion
89
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/utils.d.ts
90
+ /** Ordered collection of disposable values with O(1) deletion by value. */
91
+ declare class DisposableList<T extends WeakKey> {
92
+ private sn;
93
+ private map;
94
+ private weak;
95
+ get length(): number;
96
+ push(value: T): () => boolean;
97
+ delete(value: T): boolean;
98
+ clear(): T[];
99
+ [Symbol.iterator](): MapIterator<T>;
100
+ }
101
+ /** Shared symbols used to avoid public property-name collisions. */
102
+ declare const symbols: {
103
+ shadow: symbol;
104
+ receiver: symbol;
105
+ original: symbol;
106
+ metadata: symbol;
107
+ initHooks: symbol;
108
+ checkProto: symbol;
109
+ effect: typeof Context.effect;
110
+ filter: typeof Context.filter;
111
+ isolate: typeof Context.isolate;
112
+ intercept: typeof Context.intercept;
113
+ init: typeof Service.init;
114
+ check: typeof Service.check;
115
+ config: typeof Service.config;
116
+ invoke: typeof Service.invoke;
117
+ extend: typeof Service.extend;
118
+ tracker: typeof Service.tracker;
119
+ resolveConfig: typeof Service.resolveConfig;
120
+ };
121
+ //#endregion
122
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/registry.d.ts
123
+ /**
124
+ * Service dependency declaration accepted by plugins and the `@Inject`
125
+ * decorator.
126
+ *
127
+ * Array form requests services without intercept config. Object form maps each
128
+ * service name to optional intercept config for the plugin context.
129
+ */
130
+ type Inject<M = Dict> = (keyof M)[] | { [K in keyof M]?: M[K]; };
131
+ /** Context keys that correspond to services with typed intercept config. */
132
+ type InjectKey = keyof { [K in keyof Context & string as Context[K] extends {
133
+ [symbols.config]: any;
134
+ } ? K : never]: any; };
135
+ /**
136
+ * Decorator for declaring service dependencies on classes or class methods.
137
+ *
138
+ * On classes it contributes to the plugin's static `inject` map. On methods it
139
+ * delays the method call until the declared services are available.
140
+ */
141
+ /**
142
+ * @param name — the required service name.
143
+ * @param config — optional intercept config applied for that service.
144
+ * @returns the class or method decorator.
145
+ */
146
+ declare function Inject<K extends InjectKey>(name: K, config?: Context[K] extends {
147
+ [symbols.config]: infer T;
148
+ } ? T : never): (value: any, decorator: ClassDecoratorContext<any> | ClassMethodDecoratorContext<any>) => void;
149
+ /** Utilities for normalizing plugin dependency declarations. */
150
+ declare namespace Inject {
151
+ /**
152
+ * Convert array/object/class-inherited inject metadata into a plain map.
153
+ *
154
+ * @param inject — the declaration to normalize; `null`/`undefined` add nothing.
155
+ * @param result — the map to fill (service name → intercept config or `null`).
156
+ * @returns `result`.
157
+ */
158
+ function resolve(inject: Inject | null | undefined, result?: Dict): Dict;
159
+ }
160
+ /** Supported plugin entrypoint shapes. */
161
+ type Plugin<T = any> = Plugin.Function<T> | Plugin.Constructor<T> | Plugin.Object<T>;
162
+ /** Types associated with plugin entrypoints and runtime records. */
163
+ declare namespace Plugin {
164
+ /** Shared metadata understood by the plugin registry and related tooling. */
165
+ interface Base<T = any> {
166
+ /** Display name used for fiber diagnostics and logger names. */
167
+ name?: string;
168
+ /** Standard-schema validator applied to config before the plugin starts. */
169
+ Config?: StandardSchemaV1<any, T>;
170
+ /** Services the plugin requires; it only loads while all are available. */
171
+ inject?: Inject;
172
+ /** Service name(s) the plugin provides (read by `Service` and by loaders). */
173
+ provide?: string | string[];
174
+ /** Service names whose intercept config the plugin declares it consumes. */
175
+ intercept?: Dict<boolean>;
176
+ }
177
+ interface Transform<S, T> {
178
+ /** Marks the transform object as a schema/config transform. */
179
+ schema?: true;
180
+ /** Convert user-facing config to runtime config. */
181
+ Config: (config: S) => T;
182
+ }
183
+ /** Function plugin called with `(ctx, config)`. */
184
+ interface Function<T = any> extends Base<T> {
185
+ (ctx: Context, config: T): any;
186
+ }
187
+ /** Class plugin constructed with `(ctx, config)`. */
188
+ interface Constructor<T = any> extends Base<T> {
189
+ new (ctx: Context, config: T): any;
190
+ }
191
+ /** Object plugin with an `apply(ctx, config)` method. */
192
+ interface Object<T = any> extends Base<T> {
193
+ apply(ctx: Context, config: T): any;
194
+ }
195
+ /** Mutable registry record shared by all fibers of one plugin callback. */
196
+ interface Runtime {
197
+ /** Display name copied from the first registered plugin shape. */
198
+ name?: string;
199
+ /** Every live fiber of this plugin (one per `ctx.plugin()` call). */
200
+ fibers: DisposableList<Fiber>;
201
+ /** The executable entrypoint all fibers share (registry identity key). */
202
+ callback: globalThis.Function;
203
+ /** Standard-schema validator applied to each fiber's config. */
204
+ Config?: StandardSchemaV1;
205
+ }
206
+ }
207
+ type Spread<T> = undefined extends T ? [config?: T] : [config: T];
208
+ type GetPluginParameters<P> = P extends ((ctx: Context, ...args: infer R) => any) ? R : P extends (new (ctx: Context, ...args: infer R) => any) ? R : P extends {
209
+ apply(ctx: Context, ...args: infer R): any;
210
+ } ? R : never;
211
+ type GetPluginConfig<P> = P extends Plugin.Transform<infer S, any> ? S : GetPluginParameters<P>[0];
212
+ declare module './context.ts' {
213
+ interface Context {
214
+ /**
215
+ * Run a callback once the requested services are available.
216
+ *
217
+ * Shorthand for `ctx.plugin({ inject, apply: callback })`: the callback
218
+ * is unloaded and re-run whenever a required service changes.
219
+ *
220
+ * @param deps — required services, as an array or a name → config map.
221
+ * @param callback — plugin body called with `(ctx, config)`.
222
+ * @returns the fiber; awaiting it settles once loading finished.
223
+ */
224
+ inject(deps: Inject, callback: Plugin.Function<void>): Fiber & PromiseLike<Fiber>;
225
+ /**
226
+ * Load a plugin in the current context.
227
+ *
228
+ * @param plugin — a function, class, or `{ apply }` object plugin.
229
+ * @param args — the plugin config, validated against its `Config` schema.
230
+ * @returns the fiber; awaiting it settles once loading finished
231
+ * (rejecting on config or startup errors).
232
+ */
233
+ plugin<P extends Plugin>(plugin: P, ...args: Spread<GetPluginConfig<P>>): Fiber & PromiseLike<Fiber>;
234
+ }
235
+ }
236
+ /**
237
+ * Plugin registry installed as `ctx.registry` and mixed into every context.
238
+ *
239
+ * It normalizes plugin shapes, tracks plugin runtimes, starts fibers, and
240
+ * exposes map-like inspection over active plugin callbacks.
241
+ */
242
+ declare class RegistryService {
243
+ ctx: Context;
244
+ private _counter;
245
+ private _internal;
246
+ constructor(ctx: Context);
247
+ /** Allocate the next fiber uid (increments on every read). */
248
+ get counter(): number;
249
+ /** Number of registered plugin runtimes. */
250
+ get size(): number;
251
+ /**
252
+ * Resolve a supported plugin shape to its executable callback.
253
+ *
254
+ * @param plugin — a function, class, or `{ apply }` object plugin.
255
+ * @returns the callback identifying the plugin, or `undefined` if invalid.
256
+ */
257
+ resolve(plugin: Plugin): Function | undefined;
258
+ /**
259
+ * Look up the runtime record for a plugin.
260
+ *
261
+ * @param plugin — any supported plugin shape.
262
+ * @returns the runtime, or `undefined` when the plugin is not registered.
263
+ */
264
+ get(plugin: Plugin): Plugin.Runtime | undefined;
265
+ /**
266
+ * Check whether a plugin has a registered runtime.
267
+ *
268
+ * @param plugin — any supported plugin shape.
269
+ * @returns `true` when at least one fiber of the plugin exists.
270
+ */
271
+ has(plugin: Plugin): boolean;
272
+ /**
273
+ * Dispose every running fiber for a plugin and remove its runtime record.
274
+ *
275
+ * @param plugin — any supported plugin shape.
276
+ * @returns the removed runtime, or `undefined` when none was registered.
277
+ */
278
+ delete(plugin: Plugin): Plugin.Runtime | undefined;
279
+ /** Iterate the registered plugin callbacks. */
280
+ keys(): MapIterator<Function>;
281
+ /** Iterate the registered plugin runtimes. */
282
+ values(): MapIterator<Plugin.Runtime>;
283
+ /** Iterate `[callback, runtime]` pairs. */
284
+ entries(): MapIterator<[Function, Plugin.Runtime]>;
285
+ /**
286
+ * Visit every registered runtime.
287
+ *
288
+ * @param callback — receives each runtime and its identifying callback.
289
+ */
290
+ forEach(callback: (value: Plugin.Runtime, key: Function) => void): void;
291
+ /**
292
+ * Start a callback once the requested dependencies are available.
293
+ *
294
+ * @param inject — required services, as an array or a name → config map.
295
+ * @param callback — plugin body called with `(ctx, config)`.
296
+ * @returns the fiber; awaiting it settles once loading finished.
297
+ */
298
+ inject(inject: Inject, callback: Plugin.Function<void>): Fiber & PromiseLike<Fiber>;
299
+ /**
300
+ * Start a plugin in the current context and return its fiber.
301
+ *
302
+ * Creates (or reuses) the plugin's runtime record, then starts a new fiber
303
+ * under the current context. Throws if `plugin` is not a supported shape or
304
+ * if the current fiber is already disposed.
305
+ *
306
+ * @param plugin — a function, class, or `{ apply }` object plugin.
307
+ * @param config — the plugin config, validated against its `Config` schema.
308
+ * @param getOuterStack — captures the caller stack for effect diagnostics.
309
+ * @returns the fiber; awaiting it settles once loading finished.
310
+ */
311
+ plugin(plugin: Plugin, config?: any, getOuterStack?: () => string[]): Fiber & PromiseLike<Fiber>;
312
+ }
313
+ //#endregion
314
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/reflect.d.ts
315
+ declare module './context.ts' {
316
+ interface Context {
317
+ /**
318
+ * Read a service from the store without the inject requirement.
319
+ *
320
+ * @param name — the service name.
321
+ * @param strict — when `true` (default), only return implementations
322
+ * whose providing fiber is currently active.
323
+ * @returns the service value, or `undefined` when not (yet) provided.
324
+ */
325
+ get<K extends string & keyof this>(name: K, strict?: boolean): undefined | this[K];
326
+ /** Same as above for service names outside the typed `Context` surface. */
327
+ get(name: string, strict?: boolean): any;
328
+ /**
329
+ * Overwrite a provided service's value.
330
+ *
331
+ * Only the fiber that provided the service may set it; setting an
332
+ * unprovided name throws.
333
+ *
334
+ * @param name — the service name.
335
+ * @param value — the new service value.
336
+ */
337
+ set<K extends string & keyof this>(name: K, value: undefined | this[K]): void;
338
+ /** Same as above for service names outside the typed `Context` surface. */
339
+ set(name: string, value: any): void;
340
+ /**
341
+ * Register a service implementation owned by the current fiber.
342
+ *
343
+ * The service becomes visible to dependents in the same isolation scope
344
+ * once the fiber is active; it is unregistered (waking dependents) when
345
+ * the returned disposer runs or the fiber unloads. Throws if the name is
346
+ * already provided in this scope or declared as an accessor.
347
+ *
348
+ * @param name — the service name.
349
+ * @param value — the service value.
350
+ * @returns a disposer that unregisters the service.
351
+ */
352
+ provide<K extends string & keyof this>(name: K, value: undefined | this[K]): () => void;
353
+ /** Same as above for service names outside the typed `Context` surface. */
354
+ provide(name: string, value?: any): () => void;
355
+ /**
356
+ * Define a computed context property backed by get/set hooks.
357
+ *
358
+ * The accessor is removed when the current fiber unloads. Throws if the
359
+ * name is already declared.
360
+ *
361
+ * @param name — the context property name.
362
+ * @param options — the `get` hook and optional `set` hook.
363
+ */
364
+ accessor(name: string, options: Omit<Property.Accessor, 'type'>): void;
365
+ /**
366
+ * Expose selected members of a service directly on `ctx`.
367
+ *
368
+ * Each mixed-in key becomes an accessor that forwards to the service
369
+ * (binding methods to it), so e.g. `ctx.on` forwards to `ctx.events.on`.
370
+ * Mixins are removed when the current fiber unloads.
371
+ *
372
+ * @param name — the context property holding the source service.
373
+ * @param mixins — keys to forward, or a source-key → ctx-key map.
374
+ */
375
+ mixin<K extends string & keyof this>(name: K, mixins: (keyof this & keyof this[K])[] | Dict<string>): void;
376
+ /** Same as above with a source object instead of a context property name. */
377
+ mixin<T extends {}>(source: T, mixins: (keyof this & keyof T)[] | Dict<string>): void;
378
+ }
379
+ }
380
+ /** Context property definition known by the reflection service. */
381
+ type Property = Property.Service | Property.Accessor;
382
+ /** Property definition variants understood by `ReflectService`. */
383
+ declare namespace Property {
384
+ /** Service property backed by a provided implementation. */
385
+ interface Service {
386
+ /** Discriminator. */
387
+ type: 'service';
388
+ }
389
+ /** Computed context property backed by custom get/set hooks. */
390
+ interface Accessor {
391
+ /** Discriminator. */
392
+ type: 'accessor';
393
+ /** Compute the property value; `error` carries the caller stack for diagnostics. */
394
+ get: (this: Context, receiver: any, error: Error) => any;
395
+ /** Optional setter; return `false` to reject the write. */
396
+ set?: (this: Context, value: any, receiver: any, error: Error) => boolean;
397
+ }
398
+ }
399
+ /** Concrete service implementation record stored in the root reflect service. */
400
+ interface Impl {
401
+ /** The service name. */
402
+ name: string;
403
+ /** The fiber that provided the service (owns its lifetime). */
404
+ fiber: Fiber;
405
+ /** The current service value. */
406
+ value?: any;
407
+ /** Optional availability predicate consulted before dependents may load. */
408
+ check?: () => boolean;
409
+ }
410
+ /**
411
+ * Reflection and service-resolution layer installed as `ctx.reflect`.
412
+ *
413
+ * This service powers the context proxy, service registration, accessors, and
414
+ * the mixins that expose core service methods directly on `ctx`.
415
+ */
416
+ declare class ReflectService {
417
+ ctx: Context;
418
+ /** Proxy traps implementing service resolution for every context object. */
419
+ static handler: ProxyHandler<Context>;
420
+ /** Service implementations, keyed by isolation label. */
421
+ store: Dict<Impl, symbol>;
422
+ /** Declared context properties (services and accessors), by name. */
423
+ props: Dict<Property>;
424
+ constructor(ctx: Context);
425
+ /**
426
+ * Read a service from the store without the inject requirement.
427
+ *
428
+ * @param name — the service name.
429
+ * @param strict — when `true`, only return implementations whose providing
430
+ * fiber is currently active.
431
+ * @returns the service value, or `undefined` when not (yet) provided.
432
+ */
433
+ get(name: string, strict?: boolean): any;
434
+ _getImpl(name: string, strict?: boolean): Impl | undefined;
435
+ /**
436
+ * Overwrite a provided service's value.
437
+ *
438
+ * @param name — the service name.
439
+ * @param value — the new service value.
440
+ * @param error — carrier for the caller stack in diagnostics.
441
+ * @returns `true` on success.
442
+ * @throws when `name` was never provided, or was provided by another fiber.
443
+ */
444
+ set(name: string, value: any, error?: Error): boolean;
445
+ /**
446
+ * Register a service implementation owned by the current fiber.
447
+ *
448
+ * See the `ctx.provide()` overload above for the full contract.
449
+ *
450
+ * @param name — the service name.
451
+ * @param value — the service value.
452
+ * @param check — optional availability predicate for dependents.
453
+ * @returns a disposer that unregisters the service.
454
+ */
455
+ provide(name: string, value?: any, check?: () => boolean): Disposable<Promise<void>>;
456
+ /**
457
+ * Re-evaluate every fiber that requires one of the given services.
458
+ *
459
+ * @param names — the service names that changed.
460
+ * @param filter — restricts notification to matching isolation scopes.
461
+ * @returns the fibers whose dependency state was refreshed.
462
+ */
463
+ notify(names: string[], filter?: (ctx: Context, name: string) => boolean): Fiber[];
464
+ /**
465
+ * Define a computed context property backed by get/set hooks.
466
+ *
467
+ * @param name — the context property name.
468
+ * @param options — the `get` hook and optional `set` hook.
469
+ * @returns a disposer that removes the accessor.
470
+ */
471
+ accessor(name: string, options: Omit<Property.Accessor, 'type'>): Disposable<Promise<void>>;
472
+ /**
473
+ * Expose selected members of a service directly on `ctx`.
474
+ *
475
+ * See the `ctx.mixin()` overload above for the full contract.
476
+ *
477
+ * @param source — a context property name or a source object.
478
+ * @param mixins — keys to forward, or a source-key → ctx-key map.
479
+ * @returns a disposer that removes all created accessors.
480
+ */
481
+ mixin(source: any, mixins: string[] | Dict<string>): Disposable<Promise<void>>;
482
+ /**
483
+ * Attach this context's tracing wrapper to a value.
484
+ *
485
+ * @param value — the value to wrap.
486
+ * @returns the traceable wrapper (or the value itself when not applicable).
487
+ */
488
+ trace<T>(value: T): T;
489
+ /**
490
+ * Wrap a callback so calls trace `this` and arguments to this context.
491
+ *
492
+ * @param callback — the function to wrap.
493
+ * @returns a proxy delegating to `callback` with traced values.
494
+ */
495
+ bind<T extends Function>(callback: T): T;
496
+ }
497
+ //#endregion
498
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/fiber.d.ts
499
+ declare module './context.ts' {
500
+ interface Context extends Pick<Fiber, 'effect'> {
501
+ /** The fiber (plugin runtime instance) that owns this context. */
502
+ fiber: Fiber;
503
+ }
504
+ }
505
+ interface AsyncDisposable<T extends Awaitable<void> = Awaitable<void>> extends PromiseLike<() => T> {
506
+ (): T;
507
+ }
508
+ /**
509
+ * Function returned by an effect to release resources during disposal.
510
+ *
511
+ * Disposers run in reverse registration order when the owning fiber unloads;
512
+ * they may be async, in which case unloading awaits them.
513
+ */
514
+ type Disposable<T = any> = () => T;
515
+ /**
516
+ * Effect body result accepted by `ctx.effect()` and plugin startup.
517
+ *
518
+ * Either a single disposer, a promise of one, or a (possibly async) iterable
519
+ * yielding several — generator effects register each yielded disposer as it
520
+ * is produced.
521
+ */
522
+ type Effect<T = any> = SyncEffect<T> | AsyncEffect<T>;
523
+ type SyncEffect<T = any> = Disposable<T> | Iterable<Disposable<T>, void, void>;
524
+ type AsyncEffect<T = any> = Promise<Disposable<T>> | AsyncIterable<Disposable<T>, void, void>;
525
+ /** Tree node used to expose nested effect labels for diagnostics. */
526
+ interface EffectMeta {
527
+ /** Human-readable effect label, e.g. `ctx.on("event")` or `ctx.provide("name")`. */
528
+ label: string;
529
+ /** Metadata of nested effects registered while this effect ran. */
530
+ children: EffectMeta[];
531
+ }
532
+ /**
533
+ * Lifecycle state for one plugin fiber.
534
+ *
535
+ * `PENDING` — waiting for required services; `LOADING` — the plugin callback
536
+ * is running; `ACTIVE` — loaded and providing; `FAILED` — the callback or its
537
+ * config threw; `UNLOADING` — disposers are running; `DISPOSED` — the fiber
538
+ * was removed and cannot restart.
539
+ */
540
+ declare const enum FiberState {
541
+ PENDING = 0,
542
+ LOADING = 1,
543
+ ACTIVE = 2,
544
+ FAILED = 3,
545
+ DISPOSED = 4,
546
+ UNLOADING = 5
547
+ }
548
+ /**
549
+ * Runtime instance of one plugin application.
550
+ *
551
+ * A fiber tracks dependency state, validated config, lifecycle effects, and
552
+ * cleanup for the plugin context returned by `ctx.plugin()`.
553
+ */
554
+ declare class Fiber {
555
+ parent: Context;
556
+ inject: Dict<any>;
557
+ runtime: Plugin.Runtime | null;
558
+ /** Unique id within the registry; 0 for the root fiber, `null` once disposed. */
559
+ uid: number | null;
560
+ /** The context this fiber's plugin runs in (extends the parent context). */
561
+ readonly ctx: Context;
562
+ /** The validated plugin config (updated by `update()`). */
563
+ config: any;
564
+ /** The raw plugin config, re-resolved before each activation. */
565
+ _config: any;
566
+ /** Current lifecycle state; transitions emit `internal/status`. */
567
+ state: FiberState;
568
+ /** Dispose this fiber: unload the plugin, then settle once cleanup finished. */
569
+ readonly dispose: () => Promise<void>;
570
+ /** Snapshot of required service implementations while loaded; `undefined` otherwise. */
571
+ store: Dict<Impl> | undefined;
572
+ /** The in-flight load/unload transition, if one is currently running. */
573
+ inertia: Promise<void> | undefined;
574
+ readonly _hooks: Dict<DisposableList<Function>>;
575
+ readonly _disposables: DisposableList<Disposable<any>>;
576
+ protected context: Context;
577
+ private _error;
578
+ private _runner;
579
+ private _store;
580
+ /**
581
+ * Create a fiber. Plugin authors normally obtain fibers from `ctx.plugin()`
582
+ * rather than constructing them directly.
583
+ *
584
+ * @param parent — the context the plugin was loaded from.
585
+ * @param config — raw config, validated against the runtime's schema.
586
+ * @param inject — resolved dependency map (service name → intercept config).
587
+ * @param runtime — the shared plugin runtime, or `null` for the root fiber.
588
+ * @param getOuterStack — captures the caller stack for effect diagnostics.
589
+ */
590
+ constructor(parent: Context, config: any, inject: Dict<any>, runtime: Plugin.Runtime | null, getOuterStack: () => string[]);
591
+ /** The plugin's display name, inherited from the nearest named ancestor, else `'root'`. */
592
+ get name(): string;
593
+ /**
594
+ * Throw if the fiber has already been disposed.
595
+ *
596
+ * @returns nothing when the fiber is still active.
597
+ * @throws {CordisError} `INACTIVE_EFFECT` when the fiber's uid has been cleared.
598
+ */
599
+ assertActive(): void;
600
+ private _execute;
601
+ /**
602
+ * Register a cleanup-aware effect on this fiber.
603
+ *
604
+ * `execute` runs immediately; the disposers it produces are collected and
605
+ * run (in reverse order) either when the returned disposer is called or
606
+ * when the fiber unloads, whichever comes first. Calling the disposer twice
607
+ * is a no-op. Throws `CordisError('INACTIVE_EFFECT')` if the fiber is
608
+ * already disposed, and `TypeError` if `execute` returns an invalid shape.
609
+ *
610
+ * @param execute — the effect body; see {@link Effect} for accepted shapes.
611
+ * @param label — effect label shown in `getEffects()` diagnostics.
612
+ * @returns a disposer that tears the effect down and settles once done.
613
+ */
614
+ effect(execute: () => SyncEffect, label?: string): Disposable<Promise<void>>;
615
+ /** Same as above for async effects; the disposer is also awaitable. */
616
+ effect(execute: () => Effect, label?: string): AsyncDisposable<Promise<void>>;
617
+ /**
618
+ * Return metadata for currently registered effects.
619
+ *
620
+ * @returns one {@link EffectMeta} tree per labeled live effect.
621
+ */
622
+ getEffects(): EffectMeta[];
623
+ private _getState;
624
+ private _updateState;
625
+ _checkImpl(name: string): boolean | undefined;
626
+ _refresh(): void;
627
+ private _setEpoch;
628
+ private _resolveConfig;
629
+ private _reload;
630
+ private _unload;
631
+ /**
632
+ * Wait for current lifecycle work and rethrow startup errors.
633
+ *
634
+ * @returns this fiber, once it has settled into a stable state.
635
+ * @throws the config-validation or plugin-startup error, if any.
636
+ */
637
+ await(): Promise<this>;
638
+ /**
639
+ * Dispose and immediately reload this plugin with its current config.
640
+ *
641
+ * @returns a promise resolving once the reload settled.
642
+ * @throws {CordisError} `INACTIVE_EFFECT` when the fiber is already disposed.
643
+ */
644
+ restart(): Promise<void>;
645
+ /**
646
+ * Validate and apply new config, then restart the plugin.
647
+ *
648
+ * Runs the `internal/update` waterfall first, so update hooks (and HMR)
649
+ * can veto or replace the restart.
650
+ *
651
+ * @param config — the new raw config; validated before anything restarts.
652
+ * @param noSave — hint for persistence hooks not to write the change back.
653
+ * @returns nothing; the restart runs behind the `internal/update` waterfall.
654
+ * @throws {ValidationError} when the new config fails validation.
655
+ */
656
+ update(config: any, noSave?: boolean): void;
657
+ }
658
+ //#endregion
659
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/events.d.ts
660
+ /** Extract the parameter tuple from a function type. */
661
+ type Parameters<F> = F extends ((...args: infer P) => any) ? P : never;
662
+ /** Extract the return type from a function type. */
663
+ type ReturnType$1<F> = F extends ((...args: any) => infer R) ? R : never;
664
+ /** Extract the explicit `this` type from a function type. */
665
+ type ThisType<F> = F extends ((this: infer T, ...args: any) => any) ? T : never;
666
+ /**
667
+ * Event dispatch strategy used by the event service.
668
+ *
669
+ * `emit` runs synchronous listeners without awaiting them, `parallel` awaits
670
+ * all listeners together, `serial` awaits them in order until one bails,
671
+ * `bail` stops on the first synchronous bail value, and `waterfall` composes
672
+ * listeners around a final `next` callback.
673
+ */
674
+ type DispatchMode = 'emit' | 'parallel' | 'serial' | 'bail' | 'waterfall';
675
+ declare module './context.ts' {
676
+ interface Context {
677
+ /**
678
+ * Dispatch an event, running all listeners concurrently.
679
+ *
680
+ * @param name — the event name.
681
+ * @param args — arguments passed to every listener.
682
+ * @returns a promise resolving once every listener has settled.
683
+ */
684
+ parallel<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): Promise<void>;
685
+ /** Same as above, with an explicit `this` for listeners (also used for filtering). */
686
+ parallel<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): Promise<void>;
687
+ /**
688
+ * Dispatch an event synchronously, ignoring listener return values.
689
+ *
690
+ * @param name — the event name.
691
+ * @param args — arguments passed to every listener.
692
+ */
693
+ emit<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void;
694
+ /** Same as above, with an explicit `this` for listeners (also used for filtering). */
695
+ emit<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): void;
696
+ /**
697
+ * Dispatch an event, awaiting listeners in order until one bails.
698
+ *
699
+ * @param name — the event name.
700
+ * @param args — arguments passed to each listener.
701
+ * @returns the first bail value (non-null, non-false, non-undefined), if any.
702
+ */
703
+ serial<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): Promisify<ReturnType$1<Events[K]>>;
704
+ /** Same as above, with an explicit `this` for listeners (also used for filtering). */
705
+ serial<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): Promisify<ReturnType$1<Events[K]>>;
706
+ /**
707
+ * Dispatch an event, calling listeners in order until one bails.
708
+ *
709
+ * @param name — the event name.
710
+ * @param args — arguments passed to each listener.
711
+ * @returns the first bail value (non-null, non-false, non-undefined), if any.
712
+ */
713
+ bail<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): ReturnType$1<Events[K]>;
714
+ /** Same as above, with an explicit `this` for listeners (also used for filtering). */
715
+ bail<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): ReturnType$1<Events[K]>;
716
+ /**
717
+ * Dispatch an event whose last argument is a `next` continuation.
718
+ *
719
+ * Each listener wraps the rest of the chain: calling `next()` invokes the
720
+ * next listener (finally the built-in behavior); not calling it vetoes.
721
+ *
722
+ * @param name — the event name.
723
+ * @param args — listener arguments; the final one is the innermost `next`.
724
+ * @returns the outermost listener's return value.
725
+ */
726
+ waterfall<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): ReturnType$1<Events[K]>;
727
+ /** Same as above, with an explicit `this` for listeners (also used for filtering). */
728
+ waterfall<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): ReturnType$1<Events[K]>;
729
+ /**
730
+ * Register an event listener owned by the current fiber.
731
+ *
732
+ * @param name — the event name to listen for.
733
+ * @param listener — called with the dispatch arguments.
734
+ * @param options — listener options; a boolean is shorthand for `prepend`.
735
+ * @returns a disposer removing the listener; `true` if it was still registered.
736
+ */
737
+ on<K extends keyof Events>(name: K, listener: Events[K], options?: boolean | EventOptions): () => boolean;
738
+ /**
739
+ * Same as `on()`, but the listener disposes itself after its first call.
740
+ *
741
+ * @param name — the event name to listen for.
742
+ * @param listener — called at most once with the dispatch arguments.
743
+ * @param options — listener options; a boolean is shorthand for `prepend`.
744
+ * @returns a disposer removing the listener; `true` if it was still registered.
745
+ */
746
+ once<K extends keyof Events>(name: K, listener: Events[K], options?: boolean | EventOptions): () => boolean;
747
+ }
748
+ }
749
+ /** Options accepted by `ctx.on()` and `ctx.once()`. */
750
+ interface EventOptions {
751
+ /** Add the listener before existing listeners for the same event. */
752
+ prepend?: boolean;
753
+ /** Receive the event regardless of context filter checks. */
754
+ global?: boolean;
755
+ }
756
+ /** Registered listener record stored by the event service. */
757
+ interface Hook extends EventOptions {
758
+ ctx: Context;
759
+ callback: (...args: any[]) => any;
760
+ }
761
+ /**
762
+ * Event bus installed as `ctx.events` and mixed into every context.
763
+ *
764
+ * The service supports concurrent, synchronous, serial, bail, and waterfall
765
+ * dispatch and automatically disposes listeners with their owning fiber.
766
+ */
767
+ declare class EventsService {
768
+ private ctx;
769
+ _hooks: Record<keyof any, Hook[]>;
770
+ constructor(ctx: Context);
771
+ /**
772
+ * Resolve listeners for one dispatch and apply context filtering.
773
+ *
774
+ * @param type — the dispatch mode, reported on `internal/dispatch`.
775
+ * @param args — the raw dispatch arguments; consumed up to the event name.
776
+ * @returns the matching listener callbacks, bound to the dispatch `this`.
777
+ */
778
+ dispatch(type: string, args: any[]): ((...args: any[]) => any)[];
779
+ /**
780
+ * Run listeners concurrently and wait for all of them.
781
+ *
782
+ * @param args — optional `this`, the event name, then listener arguments.
783
+ * @returns a promise resolving once every listener has settled.
784
+ */
785
+ parallel(...args: any[]): Promise<void>;
786
+ /**
787
+ * Run listeners synchronously without waiting for returned promises.
788
+ *
789
+ * @param args — optional `this`, the event name, then listener arguments.
790
+ */
791
+ emit(...args: any[]): void;
792
+ /**
793
+ * Run listeners in order, awaiting each, until one returns a bail value.
794
+ *
795
+ * @param args — optional `this`, the event name, then listener arguments.
796
+ * @returns the first bail value (see {@link isBailed}), if any.
797
+ */
798
+ serial(...args: any[]): Promise<any>;
799
+ /**
800
+ * Run listeners synchronously until one returns a bail value.
801
+ *
802
+ * @param args — optional `this`, the event name, then listener arguments.
803
+ * @returns the first bail value (see {@link isBailed}), if any.
804
+ */
805
+ bail(...args: any[]): any;
806
+ /**
807
+ * Compose listeners around the final `next` callback.
808
+ *
809
+ * The last dispatch argument is treated as the innermost `next`. Listeners
810
+ * run outermost-first; a listener that does not call `next()` vetoes the
811
+ * rest of the chain, including the built-in behavior.
812
+ *
813
+ * @param args — optional `this`, the event name, listener arguments, then `next`.
814
+ * @returns the outermost listener's return value.
815
+ */
816
+ waterfall(...args: any[]): any;
817
+ /**
818
+ * Store a listener record as an effect on the current fiber.
819
+ *
820
+ * @param label — effect label shown in fiber diagnostics.
821
+ * @param hooks — the listener list for one event.
822
+ * @param callback — the listener to store.
823
+ * @param options — placement and filtering options.
824
+ * @returns a disposer that unregisters the listener.
825
+ */
826
+ register(label: string, hooks: Hook[], callback: any, options: EventOptions): () => void;
827
+ /**
828
+ * Remove a stored listener record.
829
+ *
830
+ * @param hooks — the listener list for one event.
831
+ * @param callback — the listener to remove.
832
+ * @returns `true` if the listener was found and removed.
833
+ */
834
+ unregister(hooks: Hook[], callback: any): true | undefined;
835
+ /**
836
+ * Register an event listener owned by the current fiber.
837
+ *
838
+ * The listener is removed automatically when the fiber unloads. Throws
839
+ * `CordisError('INACTIVE_EFFECT')` if the fiber is already disposed.
840
+ *
841
+ * @param name — the event name to listen for.
842
+ * @param listener — called with the dispatch arguments.
843
+ * @param options — listener options; a boolean is shorthand for `prepend`.
844
+ * @returns a disposer removing the listener; `true` if it was still registered.
845
+ */
846
+ on(name: string | symbol, listener: (...args: any) => any, options?: boolean | EventOptions): any;
847
+ /**
848
+ * Register an event listener that disposes itself after the first call.
849
+ *
850
+ * @param name — the event name to listen for.
851
+ * @param listener — called at most once with the dispatch arguments.
852
+ * @param options — listener options; a boolean is shorthand for `prepend`.
853
+ * @returns a disposer removing the listener; `true` if it was still registered.
854
+ */
855
+ once(name: string, listener: (...args: any) => any, options?: boolean | EventOptions): any;
856
+ }
857
+ /**
858
+ * Built-in framework events used by core services and extension points.
859
+ *
860
+ * Plugin and status events track fiber lifecycle, service events observe
861
+ * dependency registration, update/get/set/listener events allow core services
862
+ * to intercept runtime operations, and `internal/dispatch` exposes event-bus
863
+ * diagnostics before public events are delivered.
864
+ */
865
+ interface Events {
866
+ /** A plugin fiber was created or its uid was cleared on disposal. */
867
+ 'internal/plugin'(fiber: Fiber): void;
868
+ /** A fiber changed lifecycle state; receives the fiber and its previous state. */
869
+ 'internal/status'(fiber: Fiber, oldValue: FiberState): void;
870
+ /**
871
+ * Resolve raw plugin config after the fiber's injections become active.
872
+ * @param config - the raw config for this activation.
873
+ * @mode waterfall
874
+ */
875
+ 'internal/config'(this: Fiber, config: any, next: () => any): any;
876
+ /** Interception hook for a service binding (no core producer). */
877
+ 'internal/service'(this: Context, name: string, value: any): void;
878
+ /** Waterfall: a fiber config update is being applied; skip `next()` to veto. */
879
+ 'internal/update'(this: Fiber, config: any, noSave: boolean, next: () => void): void;
880
+ /** Waterfall: a service is being read through the context proxy. */
881
+ 'internal/get'(ctx: Context, name: string, error: Error, next: () => any): any;
882
+ /** Waterfall: a service is being written through the context proxy. */
883
+ 'internal/set'(ctx: Context, name: string, value: any, error: Error, next: () => boolean): boolean;
884
+ /** Bail: a listener is being registered; a non-null result replaces registration. */
885
+ 'internal/listener'(this: Context, name: string, listener: any, prepend: boolean): void;
886
+ /** An event is being dispatched to listeners (fired for non-internal events only). */
887
+ 'internal/dispatch'(mode: DispatchMode, name: string, args: any[], thisArg: any): void;
888
+ }
889
+ //#endregion
890
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/logger.d.ts
891
+ declare module './context.ts' {
892
+ interface Intercept {
893
+ logger: LoggerService.Intercept;
894
+ }
895
+ }
896
+ /** Logger method name and severity category. */
897
+ type LoggerType = 'error' | 'info' | 'warn' | 'debug';
898
+ /** Callable shape for one logger severity method. */
899
+ type LoggerMethod = (format: any, ...param: any[]) => void;
900
+ /** Formatter used to resolve a printf-style placeholder. */
901
+ type Formatter = (value: any, exporter: Exporter, message: Message) => any;
902
+ /** Structured log record delivered to exporters. */
903
+ interface Message {
904
+ sn: number;
905
+ ts: number;
906
+ name: string;
907
+ type: LoggerType;
908
+ level: number;
909
+ args: any[];
910
+ fiber?: WeakRef<Fiber>;
911
+ }
912
+ /** Sink that receives structured log messages. */
913
+ interface Exporter {
914
+ colors?: number | false;
915
+ maxLength?: number;
916
+ levels?: Record<string, number>;
917
+ formatters?: Record<string, Formatter>;
918
+ export(message: Message): void;
919
+ }
920
+ /** Options used when creating a named logger facade. */
921
+ interface LoggerOptions {
922
+ /** The logger name shown with each message. */
923
+ name: string;
924
+ /** Message fields merged into every record from this logger. */
925
+ meta?: Partial<Message>;
926
+ /** Default maximum level exported when an exporter has no own threshold. */
927
+ level?: number;
928
+ }
929
+ /** Logger facade identity, inherited message metadata, and optional minimum level. */
930
+ interface Logger extends LoggerOptions {}
931
+ /** Logger facade severity methods. */
932
+ interface Logger extends Record<LoggerType, LoggerMethod> {}
933
+ /** Logger facade for one named subsystem. */
934
+ declare class Logger {
935
+ private service;
936
+ static color(exporter: Exporter, code: number, value: any, decoration?: string): string;
937
+ static code(name: string, level?: false | number): number;
938
+ static format(exporter: Exporter, message: Message): string;
939
+ constructor(options: LoggerOptions, service: LoggerService);
940
+ private _method;
941
+ }
942
+ /** Logger service configuration merged from context intercepts. */
943
+ declare namespace LoggerService {
944
+ interface Intercept {
945
+ name?: string;
946
+ level?: number;
947
+ }
948
+ }
949
+ /** Callable `ctx.logger` service shape. */
950
+ interface LoggerService extends Record<LoggerType, LoggerMethod> {
951
+ (name?: string): Logger;
952
+ }
953
+ /**
954
+ * Built-in logging service.
955
+ *
956
+ * Call `ctx.logger()` to create a named logger, or call `ctx.logger.info()`
957
+ * directly to log with the current fiber-derived name.
958
+ */
959
+ declare class LoggerService {
960
+ bufferSize: number;
961
+ buffer: Message[];
962
+ ctx: Context;
963
+ _snMessage: number;
964
+ _snExporter: number;
965
+ exporters: Map<number, Exporter>;
966
+ constructor(ctx: Context);
967
+ /**
968
+ * Register an exporter and dispose it with the current fiber.
969
+ *
970
+ * @param exporter — the sink that receives structured log messages.
971
+ * @returns a disposer that removes the exporter.
972
+ */
973
+ exporter(exporter: Exporter): Disposable<Promise<void>>;
974
+ private _resolveConfig;
975
+ [symbols.invoke](name?: string): Logger;
976
+ }
977
+ //#endregion
978
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/context.d.ts
979
+ /**
980
+ * Public shape of a Cordis context.
981
+ *
982
+ * The concrete `Context` class is proxied at runtime, so this interface is
983
+ * augmented by core services and plugins to describe the properties that may
984
+ * be read from `ctx`.
985
+ */
986
+ interface Context {
987
+ /** Isolation map: service name → scope label. Lookups for a name resolve within its label. */
988
+ [symbols.isolate]: Dict<symbol>;
989
+ /** Intercept map: service name → config merged into that service's per-plugin config. */
990
+ [symbols.intercept]: Dict;
991
+ /** The root context of the application (every child context shares it). @experimental */
992
+ root: this;
993
+ /** Base URL used to resolve relative plugin/module specifiers, if the runtime sets one. */
994
+ baseUrl?: string;
995
+ /** The event bus. Its methods are also mixed onto `ctx` (`ctx.on`, `ctx.emit`, ...). */
996
+ events: EventsService;
997
+ /** The logging service. Call `ctx.logger(name)` for a named logger. */
998
+ logger: LoggerService;
999
+ /** The reflection layer backing the context proxy (`ctx.get`, `ctx.provide`, ...). */
1000
+ reflect: ReflectService;
1001
+ /** The plugin registry. Its methods are mixed onto `ctx` (`ctx.plugin`, `ctx.inject`). */
1002
+ registry: RegistryService;
1003
+ }
1004
+ /**
1005
+ * Root and child dependency containers for Cordis plugins.
1006
+ *
1007
+ * A context is a proxy: normal property reads go through the service resolver,
1008
+ * while `extend()`, `isolate()`, and `intercept()` create scoped child
1009
+ * contexts without mutating their parent.
1010
+ */
1011
+ declare class Context {
1012
+ /** Symbol key under which a disposer exposes its {@link EffectMeta} diagnostics tree. */
1013
+ static readonly effect: unique symbol;
1014
+ /** Symbol key for a context's listener filter, consulted on every event dispatch. */
1015
+ static readonly filter: unique symbol;
1016
+ /** Symbol key of the isolation map (see the `Context[symbols.isolate]` property). */
1017
+ static readonly isolate: unique symbol;
1018
+ /** Symbol key of the intercept map (see the `Context[symbols.intercept]` property). */
1019
+ static readonly intercept: unique symbol;
1020
+ /**
1021
+ * Returns true for Cordis context proxies and context prototypes.
1022
+ *
1023
+ * Works across realms and across multiple copies of cordis, because the
1024
+ * brand is keyed by a global symbol rather than by `instanceof`.
1025
+ *
1026
+ * @param value — the value to test.
1027
+ * @returns `true` if `value` is a Cordis context, narrowing its type.
1028
+ */
1029
+ static is(value: any): value is Context;
1030
+ /** Create the root context and install the built-in services. */
1031
+ constructor();
1032
+ /**
1033
+ * Create a child context with extra metadata on top of the current scope.
1034
+ *
1035
+ * The child prototypally inherits every property of this context; own
1036
+ * properties of `meta` shadow the inherited ones. The parent is not mutated.
1037
+ *
1038
+ * @param meta — own properties (including symbol keys) to define on the child.
1039
+ * @returns a child context inheriting from this one.
1040
+ */
1041
+ extend(meta?: {}): this;
1042
+ /**
1043
+ * Create a child context with an independent service scope for `name`.
1044
+ *
1045
+ * Below the returned context, reads and writes of the service `name`
1046
+ * resolve against the new label instead of the parent's, so a different
1047
+ * implementation can be provided without affecting the parent scope.
1048
+ * Passing the same `label` to two `isolate()` calls joins their scopes.
1049
+ *
1050
+ * @param name — the service name to isolate.
1051
+ * @param label — scope label to join; defaults to a fresh unique symbol.
1052
+ * @returns a child context whose `name` service resolves in the new scope.
1053
+ */
1054
+ isolate(name: string, label?: symbol): this;
1055
+ /**
1056
+ * Add service-specific intercept config for plugins started below this
1057
+ * context.
1058
+ *
1059
+ * Plugins loaded under the returned context see `config` merged into the
1060
+ * service's resolved config (ancestor entries first; see
1061
+ * `Service[symbols.resolveConfig]`). The parent context is not affected.
1062
+ *
1063
+ * @param name — the service name whose config to intercept.
1064
+ * @param config — the intercept config to merge for that service.
1065
+ * @returns a child context carrying the additional intercept entry.
1066
+ */
1067
+ intercept<K extends InjectKey>(name: K, config: Context[K] extends {
1068
+ [symbols.config]: infer T;
1069
+ } ? T : never): this;
1070
+ intercept(name: string, config: any): this;
1071
+ }
1072
+ //#endregion
1073
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/service.d.ts
1074
+ /**
1075
+ * Base class for services that expose a named API on `ctx`.
1076
+ *
1077
+ * Subclasses call `super(ctx, name)` from their constructor. The service is
1078
+ * registered immediately and is automatically removed with the owning fiber.
1079
+ */
1080
+ declare abstract class Service<out T = never> {
1081
+ protected ctx: Context;
1082
+ /** Symbol key of an instance method run after construction (class plugins). */
1083
+ static readonly init: unique symbol;
1084
+ /** Symbol key of the availability predicate passed to `ctx.provide()`. */
1085
+ static readonly check: unique symbol;
1086
+ /** Symbol key of the phantom intercept-config type parameter. */
1087
+ static readonly config: unique symbol;
1088
+ /** Symbol key of the call body making a service callable (e.g. `ctx.logger()`). */
1089
+ static readonly invoke: unique symbol;
1090
+ /** Symbol key of the helper deriving an extended service instance. */
1091
+ static readonly extend: unique symbol;
1092
+ /** Symbol key of the tracker metadata used for context tracing. */
1093
+ static readonly tracker: unique symbol;
1094
+ /** Symbol key of the intercept-config resolution helper below. */
1095
+ static readonly resolveConfig: unique symbol;
1096
+ [symbols.config]: T;
1097
+ /** The service name this instance is registered under. */
1098
+ name: string;
1099
+ /**
1100
+ * Register this instance as `name` in the current context.
1101
+ *
1102
+ * Calls `ctx.reflect.provide(name, this, this[Service.check])`, so the
1103
+ * service is unregistered automatically when the owning fiber unloads.
1104
+ * Services with a `[Service.invoke]` body return a callable instance.
1105
+ *
1106
+ * @param ctx — the context to register in (stored as `this.ctx`).
1107
+ * @param name — the service name; defaults to the static `provide` field.
1108
+ */
1109
+ constructor(ctx: Context, name: string);
1110
+ protected [symbols.filter](ctx: Context): boolean;
1111
+ protected [symbols.extend](props?: any): any;
1112
+ /**
1113
+ * Merge intercept config from ancestors with optional base and head values.
1114
+ *
1115
+ * Entries added closer to the root apply first; `base` is prepended and
1116
+ * `head` appended. Uses `Config.merge` when the service declares one,
1117
+ * otherwise a shallow `Object.assign`.
1118
+ *
1119
+ * @param base — lowest-precedence config merged before all intercepts.
1120
+ * @param head — highest-precedence config merged after all intercepts.
1121
+ * @returns the merged config.
1122
+ */
1123
+ [symbols.resolveConfig](base?: T, head?: T): T;
1124
+ static [Symbol.hasInstance](instance: any): boolean;
1125
+ }
1126
+ //#endregion
1127
+ //#region src/strata/connection.d.ts
1128
+ /** The part of a row config this module reads. */
1129
+ interface RowConnection {
1130
+ /** `controlToken`: what any caller not on this machine must present TO this Host. */
1131
+ readonly controlToken?: unknown;
1132
+ /** `connectionToken`: what THIS Host presents to the address it dials. */
1133
+ readonly connectionToken?: unknown;
1134
+ /** `connectionAddress`: the short form. */
1135
+ readonly connectionAddress?: unknown;
1136
+ /** `connection: { address, token }`: the long form. */
1137
+ readonly connection?: unknown;
1138
+ }
1139
+ //#endregion
1140
+ //#region src/strata/pairing.d.ts
1141
+ /** One paired computer, as the engine computer stores it. */
1142
+ interface DeviceEntry {
1143
+ /** Short opaque id, for revoking this device and for nothing else. */
1144
+ readonly id: string;
1145
+ /** What the pairing computer called itself when it redeemed the code. */
1146
+ readonly label: string;
1147
+ /** Epoch milliseconds the token was issued. */
1148
+ readonly created: number;
1149
+ /** SHA-256 of the token, hex. The token itself is never stored here. */
1150
+ readonly hash: string;
1151
+ }
1152
+ /** A device as the page may see it: everything except the hash. */
1153
+ interface DeviceView {
1154
+ readonly id: string;
1155
+ readonly label: string;
1156
+ readonly created: number;
1157
+ }
1158
+ /** A freshly minted device token, and the entry that verifies it. */
1159
+ interface IssuedToken {
1160
+ /** The secret, shown to this computer once and stored only by the joining computer. */
1161
+ readonly token: string;
1162
+ /** What the engine computer records. */
1163
+ readonly device: DeviceEntry;
1164
+ }
1165
+ /**
1166
+ * The paired computers, on the engine computer.
1167
+ *
1168
+ * A file rather than the profile row, and this is the one place the choice
1169
+ * differs from `connection.ts`: an inbound token is not something a user types
1170
+ * or reviews, it is a credential this Host issued, and a profile row is read,
1171
+ * diffed and pasted around. Only the hash is written, so the file is worth
1172
+ * stealing only in the sense that it names machines.
1173
+ */
1174
+ declare class DeviceTokens {
1175
+ private readonly path;
1176
+ private readonly now;
1177
+ private cache;
1178
+ /**
1179
+ * @param path - file holding the devices.
1180
+ * @param now - clock, injected so `created` is testable.
1181
+ */
1182
+ constructor(path: string, now?: () => number);
1183
+ /**
1184
+ * Mint a token for one computer and remember its hash.
1185
+ * @param label - what the joining computer calls itself.
1186
+ * @returns The token and entry, or null when the file could not be written.
1187
+ */
1188
+ issue(label: string): IssuedToken | null;
1189
+ /**
1190
+ * Verify a presented token against every stored hash.
1191
+ * @param token - value from `Authorization: Bearer`.
1192
+ * @returns The device it belongs to, or null.
1193
+ */
1194
+ verify(token: string): DeviceEntry | null;
1195
+ /**
1196
+ * Every paired computer, without its hash.
1197
+ * @returns Devices, newest first.
1198
+ */
1199
+ list(): readonly DeviceView[];
1200
+ /**
1201
+ * Forget one computer.
1202
+ * @param id - the id {@link list} reported.
1203
+ * @returns True when something was removed and written.
1204
+ */
1205
+ revoke(id: string): boolean;
1206
+ /** Read the file, treating anything unreadable as no devices. */
1207
+ private read;
1208
+ /** Write the file atomically, and drop the cache so the next read is this write. */
1209
+ private write;
1210
+ }
1211
+ //#endregion
1212
+ //#region src/strata/index.d.ts
1213
+ /** Health of the engine as the panel reports it. */
1214
+ type StrataPhase = 'running' | 'starting' | 'stopped' | 'foreign' | 'stalled';
1215
+ /** The engine's own `/health` answer, narrowed to what the panel shows. */
1216
+ interface StrataHealth {
1217
+ readonly loaded: boolean;
1218
+ readonly model: string | null;
1219
+ readonly maxContext: number | null;
1220
+ readonly images: boolean;
1221
+ readonly apiKey: boolean;
1222
+ }
1223
+ /** Machine telemetry: the GPU and system RAM the engine reports. */
1224
+ interface StrataMachine {
1225
+ readonly gpu: {
1226
+ readonly name: string | null;
1227
+ /** Whether the engine reports an elastic VRAM allocation. */
1228
+ readonly elastic: boolean | null;
1229
+ readonly usedMib: number | null;
1230
+ readonly totalMib: number | null;
1231
+ readonly utilPct: number | null;
1232
+ readonly tempC: number | null;
1233
+ readonly powerW: number | null;
1234
+ } | null;
1235
+ readonly ram: {
1236
+ readonly usedGib: number | null;
1237
+ readonly totalGib: number | null;
1238
+ } | null;
1239
+ }
1240
+ /** One finished request's timings, in the engine's own field names. */
1241
+ interface StrataTiming {
1242
+ readonly promptTokens: number | null;
1243
+ readonly generatedTokens: number | null;
1244
+ /** Tokens reused from the prompt cache on that request. */
1245
+ readonly cachedTokens: number | null;
1246
+ readonly decodeTokPerSec: number | null;
1247
+ readonly promptTokPerSec: number | null;
1248
+ /** Wall time of that request's prefill, in ms. */
1249
+ readonly promptMs: number | null;
1250
+ /** Wall time of that request's decode, in ms. */
1251
+ readonly decodeMs: number | null;
1252
+ /** Draft tokens proposed and accepted on that request. */
1253
+ readonly draftTokens: number | null;
1254
+ readonly acceptedDraftTokens: number | null;
1255
+ /** When that request finished, in the engine's own clock units. */
1256
+ readonly at: number | null;
1257
+ }
1258
+ /** Request activity the engine counts itself, beside the log evidence. */
1259
+ interface StrataActivity {
1260
+ readonly requests: number | null;
1261
+ readonly inFlight: number | null;
1262
+ /** Engine-clock timestamp of the most recent request. */
1263
+ readonly lastRequestAt: number | null;
1264
+ /** Concurrency the engine reports: how many requests it serves at once. */
1265
+ readonly serving: number | null;
1266
+ readonly requestedConcurrency: number | null;
1267
+ }
1268
+ /** What the engine log's tail says about the last few requests. */
1269
+ interface StrataLogEvidence {
1270
+ readonly expertCacheHitPct: number | null;
1271
+ readonly pcieRoutedPct: number | null;
1272
+ readonly draftAcceptPct: number | null;
1273
+ readonly lastPromptTokens: number | null;
1274
+ }
1275
+ /** Readiness of the tune flags in the engine config. */
1276
+ interface StrataTuning {
1277
+ readonly maxContextArg: string | null;
1278
+ readonly pcieFrac: string | null;
1279
+ readonly specMinP: string | null;
1280
+ readonly kvResident: string | null;
1281
+ readonly poolWorkers: string | null;
1282
+ /** True when both calibration flags survived the last config write. */
1283
+ readonly calibrated: boolean;
1284
+ }
1285
+ /** Everything the panel renders in one poll. */
1286
+ interface StrataState {
1287
+ /** What the panel shows as the engine's condition. */
1288
+ readonly phase: StrataPhase;
1289
+ /** Whether this Host can see a process serving Strata's port. */
1290
+ readonly reachable: boolean;
1291
+ /** Whether the HTTP endpoint answers, regardless of model load. */
1292
+ readonly responding: boolean;
1293
+ readonly health: StrataHealth | null;
1294
+ readonly machine: StrataMachine | null;
1295
+ readonly timing: StrataTiming | null;
1296
+ readonly activity: StrataActivity | null;
1297
+ readonly logEvidence: StrataLogEvidence | null;
1298
+ /** Uptime of the engine process, from the load path that started it. */
1299
+ readonly uptimeS: number | null;
1300
+ /**
1301
+ * PID of the engine process (`strata.exe`). This is the process that holds
1302
+ * the model, the arena and the VRAM, and it is not the process this Host
1303
+ * starts or stops.
1304
+ */
1305
+ readonly enginePid: number | null;
1306
+ /**
1307
+ * PID of the interpreter this Host started (`server.py`), which supervises the
1308
+ * engine. Lifecycle actions act on THIS tree, so the panel names it
1309
+ * separately rather than showing one PID for both.
1310
+ */
1311
+ readonly serverPid: number | null;
1312
+ /** Resident bytes of the tracked process tree, summed over the tree. */
1313
+ readonly rssBytes: number | null;
1314
+ readonly port: number;
1315
+ readonly baseUrl: string;
1316
+ readonly modelName: string;
1317
+ /** Engine build reported by its own status endpoint. */
1318
+ readonly engineVersion: string | null;
1319
+ readonly tuning: StrataTuning;
1320
+ readonly logPath: string;
1321
+ readonly configPath: string;
1322
+ /** Whether this Host holds the process it would stop. */
1323
+ readonly owned: boolean;
1324
+ /** One line the panel shows verbatim: what happened, or why nothing did. */
1325
+ readonly detail: string;
1326
+ /** Identity of a process holding the port that this Host did not start. */
1327
+ readonly foreignPid: number | null;
1328
+ readonly checkedAt: number;
1329
+ }
1330
+ /** Outcome of one lifecycle action. */
1331
+ interface StrataActionResult {
1332
+ readonly ok: boolean;
1333
+ /** One line the panel shows verbatim. */
1334
+ readonly detail: string;
1335
+ readonly state: StrataState;
1336
+ }
1337
+ /** Raw plugin config, as the Loader hands it over. */
1338
+ interface StrataConfig {
1339
+ /** Engine HTTP base URL, used for health and telemetry. */
1340
+ readonly baseUrl?: string;
1341
+ /** Environment variable holding the engine's API key, for authorized reads only. */
1342
+ readonly apiKeyEnv?: string;
1343
+ /** Interpreter that runs the server entry point. */
1344
+ readonly pythonPath?: string;
1345
+ /** Working directory the server runs from. */
1346
+ readonly serverDirectory?: string;
1347
+ /** Engine config file the launcher reads (args, model, api_key). */
1348
+ readonly configPath?: string;
1349
+ /** Engine log the panel tails. */
1350
+ readonly logPath?: string;
1351
+ /** Port the engine listens on. */
1352
+ readonly port?: number;
1353
+ /** How long a start may take before the panel calls it stalled. */
1354
+ readonly startTimeoutMs?: number;
1355
+ /** How long a graceful stop may take before the tree is force-killed. */
1356
+ readonly stopTimeoutMs?: number;
1357
+ /** Lines of engine log the panel may read. */
1358
+ readonly logTailLines?: number;
1359
+ /** Where this Host saves the control address its pages are told to use; defaults to the profile directory. */
1360
+ readonly connectionPath?: string;
1361
+ /**
1362
+ * Where paired computers are recorded; defaults to `strata-tokens.json` beside
1363
+ * the connection file. Only token hashes are written.
1364
+ */
1365
+ readonly tokensPath?: string;
1366
+ /** Bearer token a remote caller must present; '' leaves the routes to loopback callers and paired devices. */
1367
+ readonly controlToken?: string;
1368
+ /** Extra origins allowed to call these routes, each an origin such as `https://host.example.ts.net`. */
1369
+ readonly allowedOrigins?: readonly string[];
1370
+ /**
1371
+ * Fixed port for the paired-computer relay, or 0 to turn it off.
1372
+ *
1373
+ * The app's own web port is chosen afresh at every launch, so a pairing that
1374
+ * saved that port stops working on the next restart. The relay gives those
1375
+ * routes an address that does not change.
1376
+ */
1377
+ readonly pairPort?: number;
1378
+ /** Address the relay binds; defaults to this computer's tailnet address. */
1379
+ readonly pairHost?: string;
1380
+ }
1381
+ /** The config as this plugin uses it, with every default resolved. */
1382
+ interface ResolvedConfig {
1383
+ readonly baseUrl: string;
1384
+ readonly apiKeyEnv: string;
1385
+ readonly pythonPath: string;
1386
+ readonly serverDirectory: string;
1387
+ readonly configPath: string;
1388
+ readonly logPath: string;
1389
+ readonly port: number;
1390
+ readonly startTimeoutMs: number;
1391
+ readonly stopTimeoutMs: number;
1392
+ readonly logTailLines: number;
1393
+ readonly connectionPath: string | undefined;
1394
+ readonly tokensPath: string | undefined;
1395
+ readonly controlToken: string;
1396
+ readonly allowedOrigins: readonly string[];
1397
+ readonly pairPort: number;
1398
+ readonly pairHost: string | undefined;
1399
+ /** The row's own fields, so the connection target can prefer them over the file. */
1400
+ readonly rowConnection: RowConnection;
1401
+ }
1402
+ /** The tracked process table for the port this Host owns. */
1403
+ declare class StrataService {
1404
+ readonly config: ResolvedConfig;
1405
+ private tracked;
1406
+ private startingSince;
1407
+ private lastStartDetail;
1408
+ constructor(config: ResolvedConfig);
1409
+ /** PID of the interpreter this Host started, when it still owns it. */
1410
+ get ownedPid(): number | null;
1411
+ /**
1412
+ * Whether this Host can stop what is currently running.
1413
+ *
1414
+ * Ownership is resolved from the LIVE PROCESS TABLE, not from memory, because
1415
+ * memory does not survive the cases that matter: a plugin reload, a route
1416
+ * handler in a fresh module instance, or a restart performed by anything other
1417
+ * than this panel. Tracking only "the PID I spawned" meant a server started
1418
+ * seconds earlier read as `foreign`, which disabled the panel's own Stop and
1419
+ * Restart buttons on a server it had just launched — a real defect.
1420
+ *
1421
+ * ADOPTION IS NARROW ON PURPOSE: the candidate must be a `python.exe` whose
1422
+ * command line names THIS config file. That is what keeps the rule safe on a
1423
+ * machine where port 8080 is also held by `tailscaled` and where an unrelated
1424
+ * launcher (a batch file in Explorer, or `START-HERE.bat`) may be what
1425
+ * actually started the engine. Any other launcher for the same config file is
1426
+ * still the same server this panel exists to manage, so it is adopted; a
1427
+ * process for a different config is left alone.
1428
+ */
1429
+ get owns(): boolean;
1430
+ /**
1431
+ * Find the launcher for this config file and claim its tree.
1432
+ * @returns the adopted process, or null when nothing matches.
1433
+ */
1434
+ private adopt;
1435
+ /**
1436
+ * Snapshot the engine, its telemetry and its log evidence.
1437
+ * @returns everything one panel poll renders.
1438
+ */
1439
+ state(): Promise<StrataState>;
1440
+ /** Load-path detail line: the panel shows this instead of a bare spinner. */
1441
+ private detailOf;
1442
+ /** Which of the five conditions the engine is in. */
1443
+ private phaseOf;
1444
+ /** Resident bytes across the engine plus every PID this Host started. */
1445
+ private treeResidentBytes;
1446
+ /** Headers for the engine's key-guarded reads.
1447
+ *
1448
+ * The key is looked for in the environment first, then in the engine config
1449
+ * file's own `api_key`. The second source matters because Strata's launcher
1450
+ * stores it there; without it the panel would lose the machine block and the
1451
+ * per-request timings on a machine whose shell exports nothing.
1452
+ */
1453
+ private authHeaders;
1454
+ /**
1455
+ * The key the engine's own `/v1` surface demands.
1456
+ *
1457
+ * Read here rather than in the model library because the two sources this Host
1458
+ * already trusts — the environment and the engine config the launcher wrote —
1459
+ * stay in one place; a key-guarded engine would otherwise answer the model
1460
+ * listing with 401 and look like an engine with no models.
1461
+ * @returns The bearer key, or '' when the engine is keyless.
1462
+ */
1463
+ engineApiKey(): Promise<string>;
1464
+ /** One resolution rule for every caller that needs the key. */
1465
+ private apiKeyFrom;
1466
+ /**
1467
+ * Start the engine detached and record the tree this Host owns.
1468
+ * @returns the outcome line and the state afterwards.
1469
+ */
1470
+ start(): Promise<StrataActionResult>;
1471
+ /** The engine's key, from the environment or the config file's own record. */
1472
+ private engineKey;
1473
+ /**
1474
+ * Stop the engine this Host started, by PID tree and never by port.
1475
+ *
1476
+ * A graceful path goes first when the engine holds a key: the server answers a
1477
+ * SIGTERM by telling the engine to quit, which lets it release 37 GB of
1478
+ * registered memory and its VRAM before the process ends. A forced kill of a
1479
+ * model that large leaves the GPU to clean up after it, so the gentle path is
1480
+ * worth one extra process.
1481
+ * @returns the outcome line and the state afterwards.
1482
+ */
1483
+ stop(): Promise<StrataActionResult>;
1484
+ /**
1485
+ * Stop then start, so the config file's current args are what loads.
1486
+ * @returns the outcome line and the state afterwards.
1487
+ */
1488
+ restart(): Promise<StrataActionResult>;
1489
+ /** The engine log tail, for the panel's log view. */
1490
+ logs(lines?: number): Promise<string>;
1491
+ }
1492
+ /** Wiring the desktop half needs from the plugin row, separate from the route policy. */
1493
+ interface StrataRouteOptions {
1494
+ /** The paired-computer registry, when the caller already created it. */
1495
+ readonly devices?: DeviceTokens;
1496
+ /**
1497
+ * Called once a pairing code was redeemed HERE, with the address and token of
1498
+ * the computer this one now drives.
1499
+ *
1500
+ * Pairing and model sharing are one act from the operator's point of view —
1501
+ * they typed one code to make the other engine usable here — so the routes
1502
+ * report the result rather than leaving a second, separate connection to be
1503
+ * set up by hand.
1504
+ */
1505
+ readonly onJoined?: ((address: string, token: string) => void) | undefined;
1506
+ /** Called after a local lifecycle action so host model lists resolve again. */
1507
+ readonly onChanged?: (() => void) | undefined;
1508
+ /** Stop other local engines before this start; a rejection refuses the start. */
1509
+ readonly beforeStart?: (() => Promise<void>) | undefined;
1510
+ }
1511
+ /**
1512
+ * Mount the panel's routes on the harness web server.
1513
+ *
1514
+ * TWO GATES, and they answer different questions.
1515
+ *
1516
+ * WHICH CALLERS. A browser needs an answer to its preflight before it may send
1517
+ * a custom header, so these routes answer one — but only for an origin this
1518
+ * Host accepts: the origin the page was served from, plus whatever
1519
+ * `allowedOrigins` names. An origin nobody named gets no CORS headers and its
1520
+ * preflight is refused, which is what keeps an arbitrary page from reading the
1521
+ * machine snapshot or starting a 37 GB model.
1522
+ *
1523
+ * WHICH REQUESTS. `x-strata-control` still marks a write, and it still cannot
1524
+ * be set cross-origin without the preflight above — but it is a shape check,
1525
+ * not a secret, so it is no longer the whole story. Any request that did not
1526
+ * arrive over loopback must additionally present `controlToken` as a bearer
1527
+ * token, constant-time compared. A Host with no token configured therefore
1528
+ * serves loopback callers only, which is the safe default for a setting nobody
1529
+ * has opened up yet.
1530
+ *
1531
+ * The two gates compose: the preflight is answered for a named origin, and the
1532
+ * act itself needs the token. Neither alone would be enough.
1533
+ *
1534
+ * WHICH MACHINE. The same five routes also serve a computer that was pointed at
1535
+ * another one: a request carrying `x-strata-target: remote` is relayed to the
1536
+ * saved address with the saved token, server to server. That is what lets a
1537
+ * laptop's panel drive this Host's engine — the browser stays same-origin with
1538
+ * its own AryaAI, so no origin has to be opened up for it, and the token stays
1539
+ * in the server half on both machines.
1540
+ * @param ctx - host root context.
1541
+ * @param service - the Strata service the routes act on.
1542
+ * @param config - the resolved row config, for the caller policy and the saved target.
1543
+ * @returns disposer for every registration.
1544
+ */
1545
+ declare function mountRoutes(ctx: Context, service: StrataService, config: ResolvedConfig, options?: StrataRouteOptions): () => void;
1546
+ /** The handles the desktop half needs from this plugin row. */
1547
+ interface StrataHandle {
1548
+ /** Whether a token is one this Host issued to a paired computer. */
1549
+ verifyDevice(token: string): boolean;
1550
+ /** Base URL of the engine's OpenAI-compatible surface, without a trailing slash. */
1551
+ readonly baseUrl: string;
1552
+ /** Bearer key the engine demands, or '' when it is keyless. */
1553
+ apiKey(): Promise<string>;
1554
+ }
1555
+ /**
1556
+ * The computer this one is pointed at, as the row or its stored file says.
1557
+ *
1558
+ * Startup uses this to reconnect model sharing for a pairing made before the
1559
+ * two halves were linked, so an existing installation does not have to pair a
1560
+ * second time.
1561
+ * @param rawConfig - the bundle row's config, validated here rather than trusted.
1562
+ * @returns The address and token, or null when this computer uses its own engine.
1563
+ */
1564
+ declare function linkedTarget(rawConfig?: unknown): {
1565
+ address: string;
1566
+ token: string;
1567
+ } | null;
1568
+ /**
1569
+ * Register the Strata service and its routes.
1570
+ * @param ctx - host root context.
1571
+ * @param rawConfig - the bundle row's config, validated here rather than trusted.
1572
+ * @param hooks - optional link into the desktop half (model sharing).
1573
+ */
1574
+ declare function apply$1(ctx: Context, rawConfig?: unknown, hooks?: {
1575
+ onJoined?: (address: string, token: string) => void;
1576
+ onChanged?: () => void;
1577
+ beforeStart?: () => Promise<void>;
1578
+ }): StrataHandle;
1579
+ //#endregion
1580
+ //#region src/strata/relay.d.ts
1581
+ /** What a mounted relay reports back to the routes that advertise addresses. */
1582
+ interface PairRelay {
1583
+ /** Address the relay listens on, or null while it is not listening. */
1584
+ readonly address: {
1585
+ host: string;
1586
+ port: number;
1587
+ } | null;
1588
+ /** Close the listener; safe to call more than once. */
1589
+ close(): void;
1590
+ }
1591
+ /**
1592
+ * Start the relay.
1593
+ *
1594
+ * Binding is asynchronous: a port already in use (a second AryaAI instance on
1595
+ * the same machine) or an address that is not up yet leaves {@link PairRelay.address}
1596
+ * null, and the routes fall back to the app's own port exactly as before.
1597
+ * @param options - upstream port, bind host and the fixed port.
1598
+ * @returns the relay handle, listening or not.
1599
+ */
1600
+ declare function startPairRelay(options: {
1601
+ readonly upstreamPort: number;
1602
+ readonly host: string;
1603
+ readonly port: number;
1604
+ readonly onError?: (reason: string) => void;
1605
+ }): PairRelay;
1606
+ //#endregion
1607
+ //#region src/library.d.ts
1608
+ type Data$4 = Record<string, any>;
1609
+ declare const LIBRARY_PROVIDER = "local-library";
1610
+ /**
1611
+ * The per-request output default this adapter publishes for one model.
1612
+ *
1613
+ * An engine's *maximum* response allowance is a ceiling it enforces when a
1614
+ * request asks for it, not something every request should ask for: this value
1615
+ * is materialized into requests that omit an output budget, so it stays small
1616
+ * (8K, and never more than a quarter of the model's own context window).
1617
+ */
1618
+ declare function outputDefault(context: number, ceiling?: number): number;
1619
+ /** Where the Strata engine's own OpenAI-compatible surface answers, and how to authorize it. */
1620
+ interface StrataModelSource {
1621
+ /** Engine base URL, without a trailing slash, e.g. `http://127.0.0.1:8080`. */
1622
+ readonly baseUrl: string;
1623
+ /** Bearer key the engine demands, or '' when the engine is keyless. */
1624
+ readonly apiKey: () => Promise<string>;
1625
+ /**
1626
+ * Whether the engine already serves this model.
1627
+ *
1628
+ * A loaded model needs no change, so it must not be held behind the engine's
1629
+ * busy flag: a flag left behind by a client that disconnected mid-stream
1630
+ * would otherwise refuse inference the engine can serve right now.
1631
+ */
1632
+ readonly ready?: (model: Data$4) => Promise<boolean>;
1633
+ }
1634
+ /** The owned NInfer engine this installation can start and serve. */
1635
+ interface NInferModelSource {
1636
+ readonly port: number;
1637
+ readonly outputTokens: () => number;
1638
+ readonly status: () => Promise<{
1639
+ phase?: string;
1640
+ healthy?: boolean;
1641
+ modelName?: string;
1642
+ context?: number;
1643
+ vision?: boolean;
1644
+ }>;
1645
+ }
1646
+ /**
1647
+ * Build the model-library adapter.
1648
+ *
1649
+ * The return type is restated as `any`: the harness adapter type names a private
1650
+ * `@deepseek-ai/dsh-llm` type that the emitted declaration could not reference
1651
+ * without an import this plugin does not depend on (TS2742). The value is only
1652
+ * handed to `registerAdapter`, which still checks it at the call site.
1653
+ */
1654
+ declare function libraryAdapter(controller: Data$4, ensure: (model: Data$4) => Promise<void>, gate: Data$4, checkIdle: () => Promise<void>, attachments: Data$4 | undefined, strata?: StrataModelSource, ninfer?: NInferModelSource): any;
1655
+ //#endregion
1656
+ //#region src/hardware.d.ts
1657
+ declare function hardwareCollector(source?: typeof si): () => Promise<Record<string, unknown>>;
1658
+ //#endregion
1659
+ //#region src/ninfer.d.ts
1660
+ /** Settings supported by the tested MTP and vision profile. */
1661
+ interface NInferSettings {
1662
+ context: number;
1663
+ prefill: number;
1664
+ hostKvMiB: number;
1665
+ draftTokens: number;
1666
+ vision: boolean;
1667
+ /** MTP n-gram drafts: `chain` speculates from the prompt and the running reply, `off` disables them. */
1668
+ ngram: 'off' | 'chain';
1669
+ /** Default response allowance; the engine and the chat model share the context window. */
1670
+ outputTokens: number;
1671
+ }
1672
+ /** Validate settings received from disk or the Control Center. */
1673
+ declare function validateNInfer(value: unknown): NInferSettings;
1674
+ /** Verify both Docker identity and the owner marker before a destructive action. */
1675
+ declare function ownsNInfer(owner: {
1676
+ id: string;
1677
+ name: string;
1678
+ label: string;
1679
+ } | null, container: {
1680
+ Id: string;
1681
+ Name: string;
1682
+ Config: {
1683
+ Labels: Record<string, string>;
1684
+ };
1685
+ } | null, name: string, label: string): boolean;
1686
+ /** A container as `docker inspect` describes it, limited to the fields identity needs. */
1687
+ interface NInferContainer {
1688
+ Id: string;
1689
+ Name: string;
1690
+ Config: {
1691
+ Image?: string;
1692
+ Labels?: Record<string, string>;
1693
+ };
1694
+ Mounts?: {
1695
+ Source: string;
1696
+ Destination: string;
1697
+ }[];
1698
+ HostConfig?: {
1699
+ PortBindings?: Record<string, {
1700
+ HostIp?: string;
1701
+ HostPort?: string;
1702
+ }[]> | null;
1703
+ } | null;
1704
+ State: {
1705
+ Running: boolean;
1706
+ };
1707
+ }
1708
+ /**
1709
+ * Whether a running container is provably this installation's engine: the same
1710
+ * pinned image, this artifact, our port, and the label a NInfer launcher writes.
1711
+ * Another launcher may start the engine the page will otherwise refuse to touch.
1712
+ */
1713
+ declare function reclaimsNInfer(container: NInferContainer | null, image: string, artifact: string, port: number): boolean;
1714
+ /** Control only the saved runtime identity; leave other engines untouched. */
1715
+ declare class NInferController {
1716
+ readonly directory: string;
1717
+ readonly port: number;
1718
+ readonly modelName: string;
1719
+ private changing;
1720
+ private readonly config;
1721
+ constructor(config: {
1722
+ directory: string;
1723
+ artifact: string;
1724
+ image: string;
1725
+ name: string;
1726
+ label: string;
1727
+ port: number;
1728
+ modelName: string;
1729
+ defaults: NInferSettings;
1730
+ wsl?: {
1731
+ distribution: string;
1732
+ binary: string;
1733
+ libraryPath: string;
1734
+ };
1735
+ });
1736
+ /** Resolve saved tuning or validated deployment defaults. */
1737
+ settings(): NInferSettings;
1738
+ private callWsl;
1739
+ /** A container this Host may reclaim; a missing Docker or an unrelated one is no takeover. */
1740
+ private external;
1741
+ private wslStatus;
1742
+ private docker;
1743
+ private container;
1744
+ private owner;
1745
+ private complete;
1746
+ /** Report owned process or container identity independently from API readiness. */
1747
+ status(): Promise<{
1748
+ context: number;
1749
+ prefill: number;
1750
+ hostKvMiB: number;
1751
+ draftTokens: number;
1752
+ vision: boolean;
1753
+ /** MTP n-gram drafts: `chain` speculates from the prompt and the running reply, `off` disables them. */
1754
+ ngram: "off" | "chain";
1755
+ /** Default response allowance; the engine and the chat model share the context window. */
1756
+ outputTokens: number;
1757
+ phase: string;
1758
+ healthy: boolean;
1759
+ complete: boolean;
1760
+ runtime: string;
1761
+ containerId: string | null;
1762
+ external: boolean;
1763
+ takeover: boolean;
1764
+ detail: string | undefined;
1765
+ modelName: string;
1766
+ baseUrl: string;
1767
+ } | {
1768
+ context: number;
1769
+ prefill: number;
1770
+ hostKvMiB: number;
1771
+ draftTokens: number;
1772
+ vision: boolean;
1773
+ /** MTP n-gram drafts: `chain` speculates from the prompt and the running reply, `off` disables them. */
1774
+ ngram: "off" | "chain";
1775
+ /** Default response allowance; the engine and the chat model share the context window. */
1776
+ outputTokens: number;
1777
+ phase: string;
1778
+ owned: boolean;
1779
+ healthy: boolean;
1780
+ complete: boolean;
1781
+ containerId: string | null | undefined;
1782
+ external: boolean;
1783
+ takeover: boolean;
1784
+ detail: string | undefined;
1785
+ modelName: string;
1786
+ baseUrl: string;
1787
+ }>;
1788
+ /** Return a bounded log tail from the configured owned runtime, or from the engine another launcher started. */
1789
+ logs(): Promise<Record<string, unknown>>;
1790
+ /** Persist tuning while the container and model API are stopped. */
1791
+ configure(value: unknown): Promise<{
1792
+ ok: boolean;
1793
+ detail: string;
1794
+ }>;
1795
+ private stop;
1796
+ /** Stop the external container that is provably this installation's engine. */
1797
+ private takeOver;
1798
+ /** Start, stop or restart the owned runtime, reclaiming only a container that is provably this engine. */
1799
+ action(action: 'start' | 'stop' | 'restart'): Promise<{
1800
+ ok: boolean;
1801
+ detail: string;
1802
+ }>;
1803
+ }
1804
+ //#endregion
1805
+ //#region src/ninfer-log.d.ts
1806
+ /** Read the NInfer server log into the live figures its dashboard shows. */
1807
+ interface NInferLogSummary {
1808
+ weightPercent?: number | undefined;
1809
+ weightGiB?: number | undefined;
1810
+ weightTotalGiB?: number | undefined;
1811
+ weightBytesPerSecond?: number | undefined;
1812
+ etaSeconds?: number | undefined;
1813
+ decodeTokPerSecond?: number | undefined;
1814
+ prefillTokPerSecond?: number | undefined;
1815
+ running?: number | undefined;
1816
+ batch?: number | undefined;
1817
+ hostPercent?: number | undefined;
1818
+ mtpAccepted?: number | undefined;
1819
+ mtpOffered?: number | undefined;
1820
+ mtpPercent?: number | undefined;
1821
+ requests?: number | undefined;
1822
+ error?: string | undefined;
1823
+ listening?: boolean | undefined;
1824
+ ready?: boolean | undefined;
1825
+ }
1826
+ /**
1827
+ * Summarize the part of the log that belongs to the latest start.
1828
+ *
1829
+ * The log is append-only across restarts, so a new `starting engine` line ends
1830
+ * the previous run's figures. A later `listening on` clears an earlier failure;
1831
+ * a later `server stopped` clears the throughput that only describes a live run.
1832
+ */
1833
+ declare function parseNInferLog(text: string): NInferLogSummary;
1834
+ //#endregion
1835
+ //#region src/engine-switch.d.ts
1836
+ /** Stop every other local engine before a start, so one GPU is never double-booked. */
1837
+ interface EngineMember {
1838
+ /** User-facing engine name, e.g. "Strata". */
1839
+ name: string;
1840
+ /** Current phase and whether this Host may stop it. */
1841
+ read: () => Promise<{
1842
+ phase: string;
1843
+ owned: boolean;
1844
+ }>;
1845
+ /** Stop the engine; resolved only after the request was accepted. */
1846
+ stop: () => Promise<void>;
1847
+ }
1848
+ interface StopOptions {
1849
+ wait?: (milliseconds: number) => Promise<void>;
1850
+ timeoutMs?: number;
1851
+ intervalMs?: number;
1852
+ }
1853
+ /**
1854
+ * Stop the given engines, in order, and wait until each reports an idle phase.
1855
+ *
1856
+ * An engine this Host does not own is never stopped: the caller is told to stop
1857
+ * it instead. A stop that does not settle within the timeout is an error, not a
1858
+ * silent start against a half-freed GPU.
1859
+ */
1860
+ declare function stopOtherEngines(members: EngineMember[], options?: StopOptions): Promise<string[]>;
1861
+ //#endregion
1862
+ //#region src/strata-profiles.d.ts
1863
+ /** Trusted deployment configuration; GUI requests select an id, never a path. */
1864
+ interface StrataProfile {
1865
+ id: string;
1866
+ name: string;
1867
+ path: string;
1868
+ }
1869
+ /** List names and active model without exposing credentials or engine arguments.
1870
+ * @param activePath Managed engine configuration reported by Strata.
1871
+ * @param profiles Trusted, explicit model profiles.
1872
+ * @returns Safe model choices and the id matching the current native weights.
1873
+ */
1874
+ declare function strataProfiles(activePath: string, profiles: readonly StrataProfile[]): {
1875
+ profiles: {
1876
+ id: string;
1877
+ name: string;
1878
+ }[];
1879
+ selected: string | null;
1880
+ };
1881
+ /** Preserve per-model tuning and authentication when changing the active config.
1882
+ * @param activePath Managed engine config; caller must require a stopped server.
1883
+ * @param profiles Trusted allowlist of configuration files.
1884
+ * @param id Selected GUI profile id.
1885
+ * @returns Selected id and a backup of the previous active configuration.
1886
+ */
1887
+ declare function switchStrataProfile(activePath: string, profiles: readonly StrataProfile[], id: unknown): {
1888
+ selected: string;
1889
+ backup: string;
1890
+ };
1891
+ //#endregion
1892
+ //#region src/freetoken.d.ts
1893
+ /** Tuning persisted separately from model weights and download state. */
1894
+ interface FreeTokenSettings {
1895
+ context: number;
1896
+ threads: number;
1897
+ prefill: number;
1898
+ memoryRatio: number;
1899
+ strategy: 'auto' | 'offload' | 'hybrid' | 'cpu';
1900
+ vision: boolean;
1901
+ }
1902
+ /** Validate tuning entered through a GUI or saved configuration. */
1903
+ declare function validateFreeToken(value: unknown): FreeTokenSettings;
1904
+ /** Own one isolated runtime without stopping another provider or WSL distribution. */
1905
+ declare class FreeTokenController {
1906
+ private readonly directory;
1907
+ private readonly statusFile;
1908
+ private changing;
1909
+ readonly distribution: string;
1910
+ readonly port: number;
1911
+ readonly modelPath: string;
1912
+ readonly runtime: string;
1913
+ readonly alias: string;
1914
+ readonly defaults: FreeTokenSettings;
1915
+ constructor(config: {
1916
+ directory: string;
1917
+ statusFile: string;
1918
+ distribution: string;
1919
+ port: number;
1920
+ modelPath: string;
1921
+ runtime: string;
1922
+ alias: string;
1923
+ defaults: FreeTokenSettings;
1924
+ });
1925
+ /** Read tuning, using the configured defaults only when no tuning exists. */
1926
+ settings(): FreeTokenSettings;
1927
+ private verified;
1928
+ private call;
1929
+ /** Report process ownership and whether the model API responds. */
1930
+ status(): Promise<{
1931
+ context: number;
1932
+ threads: number;
1933
+ prefill: number;
1934
+ memoryRatio: number;
1935
+ strategy: "auto" | "offload" | "hybrid" | "cpu";
1936
+ vision: boolean;
1937
+ phase: string;
1938
+ healthy: boolean;
1939
+ complete: boolean;
1940
+ modelName: string;
1941
+ baseUrl: string;
1942
+ }>;
1943
+ /** Read a bounded tail of the owned server log. */
1944
+ logs(): Promise<Record<string, unknown>>;
1945
+ /** Save validated tuning only while this managed runtime is stopped. */
1946
+ configure(value: unknown): Promise<{
1947
+ ok: boolean;
1948
+ detail: string;
1949
+ }>;
1950
+ /** Start or stop only the process whose Linux identity matches its saved owner. */
1951
+ action(action: 'start' | 'stop' | 'restart'): Promise<Record<string, unknown>>;
1952
+ }
1953
+ //#endregion
1954
+ //#region src/strata-tuning.d.ts
1955
+ /** Read only supported numeric settings from an existing engine configuration.
1956
+ * @param path Trusted config path reported by the local Strata service.
1957
+ * @returns Available tunables, excluding private configuration fields.
1958
+ */
1959
+ declare function readStrataTuning(path: string): Record<string, number>;
1960
+ /** Back up and replace supported flags while preserving all other configuration.
1961
+ * @param path Trusted engine configuration path.
1962
+ * @param values Validated GUI fields; the caller requires a stopped engine.
1963
+ * @returns Backup location for manual recovery.
1964
+ */
1965
+ declare function saveStrataTuning(path: string, values: Record<string, unknown>): string;
1966
+ //#endregion
1967
+ //#region src/ollama-tuning.d.ts
1968
+ /** Create a named Ollama variant with validated defaults, preserving the base model.
1969
+ * @param body Installed base, new model name, and explicit generation defaults.
1970
+ * @returns Completion message after Ollama confirms creation.
1971
+ */
1972
+ declare function createOllamaVariant(body: Record<string, unknown>, endpoint?: string): Promise<{
1973
+ ok: boolean;
1974
+ detail: string;
1975
+ }>;
1976
+ //#endregion
1977
+ //#region src/engineering-tests.d.ts
1978
+ declare const engineeringTests: readonly [{
1979
+ readonly id: "code-generation";
1980
+ readonly name: "Code generation";
1981
+ readonly description: "Generate and test a work-order hours calculator";
1982
+ readonly brief: "Return ONLY JavaScript defining function pendingHours(rows). Each row has hours (finite nonnegative number) and status. Sum hours only for status \"pending\". Ignore invalid hours, cancelled/completed rows, null and non-object rows. Return 0 for non-array input. Do not mutate input. No imports, network, storage or explanations.";
1983
+ }, {
1984
+ readonly id: "code-fixing";
1985
+ readonly name: "Code repair";
1986
+ readonly description: "Repair an off-by-one and falsy-value defect";
1987
+ readonly brief: "Return ONLY corrected JavaScript defining function uniqueValues(items). Preserve insertion order and distinguish values by strict identity, including 0, false, empty strings, null and repeated objects. Return [] for non-array input; do not mutate it. Fix this implementation: function uniqueValues(items){const out=[];for(let i=0;i<=items.length;i++){if(items[i]&&!out.includes(items[i]))out.push(items[i]);}return out;} No imports or explanations.";
1988
+ }, {
1989
+ readonly id: "plcopen";
1990
+ readonly name: "PLCopen XML coding";
1991
+ readonly description: "Structured Text motor start/stop latch in PLCopen XML";
1992
+ readonly brief: "Return ONLY a complete PLCopen TC6 XML project in namespace http://www.plcopen.org/xml/tc6_0201. Include fileHeader and contentHeader, types/dataTypes and types/pous/pou named MotorLatch with pouType=\"program\". Declare BOOL input variables Start, Stop, EStop; BOOL output Run. Include an ST body with XHTML p text implementing Run := (Run OR Start) AND NOT Stop AND NOT EStop; EStop must take priority. Include instances/configurations. No external entities or DTD. This is an offline review fixture, not a deployable safety program.";
1993
+ }, {
1994
+ readonly id: "l5x-generation";
1995
+ readonly name: "Rockwell L5X coding";
1996
+ readonly description: "Generate a routine export with defined tags and ladder rungs";
1997
+ readonly brief: "Return ONLY a complete RSLogix5000Content L5X XML routine export with SchemaRevision=\"1.0\", SoftwareRevision=\"35.00\", TargetName=\"MotorLatch\", TargetType=\"Routine\", ContainsContext=\"true\". Controller Use=\"Context\" named BenchController; Program Use=\"Context\" named MainProgram with BOOL Base tags Start, Stop, EStop, Run in Tags; Routine Use=\"Target\" Name=\"MotorLatch\" Type=\"RLL\" with RLLContent and normal rung Number=\"0\" containing Text <![CDATA[XIO(EStop)XIO(Stop)[XIC(Start),XIC(Run)]OTE(Run);]]>. No DTD or external entities. Offline fixture only; do not claim Studio import verification.";
1998
+ }, {
1999
+ readonly id: "l5x-identification";
2000
+ readonly name: "Rockwell L5X identification";
2001
+ readonly description: "Identify controller, program, routine, tags and priority";
2002
+ readonly brief: "Return ONLY JSON with controller, program, routine, language, tags (array of tag names), emergencyStopTag, emergencyStopPriority (boolean). Analyze: <RSLogix5000Content><Controller Name=\"BenchController\"><Programs><Program Name=\"MainProgram\"><Tags><Tag Name=\"Start\" DataType=\"BOOL\"/><Tag Name=\"Stop\" DataType=\"BOOL\"/><Tag Name=\"EStop\" DataType=\"BOOL\"/><Tag Name=\"Run\" DataType=\"BOOL\"/></Tags><Routines><Routine Name=\"MotorLatch\" Type=\"RLL\"><RLLContent><Rung><Text><![CDATA[XIO(EStop)XIO(Stop)[XIC(Start),XIC(Run)]OTE(Run);]]></Text></Rung></RLLContent></Routine></Routines></Program></Programs></Controller></RSLogix5000Content>";
2003
+ }];
2004
+ /** Run bounded, offline browser checks for generated JavaScript, XML or JSON.
2005
+ * @param source Model answer, retained in the benchmark result.
2006
+ * @param id Stable task identifier.
2007
+ * @param pw Playwright browser API.
2008
+ * @param executablePath Installed Chromium executable.
2009
+ * @param signal Cancellation signal.
2010
+ * @returns Named checks and their percentage score; XML checks do not certify PLC imports.
2011
+ */
2012
+ declare function inspectEngineering(source: string, id: string, pw: any, executablePath: string, signal: AbortSignal): Promise<{
2013
+ checks: {
2014
+ name: string;
2015
+ passed: boolean;
2016
+ }[];
2017
+ score: number;
2018
+ validationNote: string;
2019
+ }>;
2020
+ //#endregion
2021
+ //#region src/tuning.d.ts
2022
+ /** Validate persisted or GUI-supplied tuning without accepting arbitrary launch flags.
2023
+ * @param input Complete profile fields.
2024
+ * @returns A normalized profile with explicit defaults for optional controls.
2025
+ */
2026
+ declare function validateTuning(input: Record<string, unknown>): Record<string, string | number | boolean>;
2027
+ /** Render validated controls as discrete argv values.
2028
+ * @param profile Normalized model tuning.
2029
+ * @returns Flags consumed by the managed llama.cpp server.
2030
+ */
2031
+ declare function tuningArgs(profile: Record<string, string | number | boolean>): string[];
2032
+ //#endregion
2033
+ //#region src/remote.d.ts
2034
+ type Data$3 = Record<string, any>;
2035
+ declare function remoteAddress(value: unknown): string;
2036
+ declare function allowedControl(path: string, method: string): {
2037
+ path: string;
2038
+ engine: string | undefined;
2039
+ action: string;
2040
+ };
2041
+ /** Admit a browser paired through AryaAI's existing session and Host/Origin checks. */
2042
+ declare function controlCaller(req: IncomingMessage, ctx: any): boolean;
2043
+ declare class RemoteStore {
2044
+ state: Data$3;
2045
+ readonly file: string;
2046
+ constructor(directory?: string);
2047
+ save(): void;
2048
+ view(): {
2049
+ enabled: boolean;
2050
+ pairs: any;
2051
+ connection: {
2052
+ address: any;
2053
+ paired: boolean;
2054
+ } | null;
2055
+ };
2056
+ pair(label: unknown): {
2057
+ id: string;
2058
+ token: string;
2059
+ };
2060
+ authorized(token: string): any;
2061
+ revoke(id: unknown): void;
2062
+ connect(address: unknown, token: unknown): {
2063
+ address: string;
2064
+ token: string;
2065
+ };
2066
+ }
2067
+ declare class ActivityGate {
2068
+ readonly busy: () => boolean;
2069
+ active: number;
2070
+ changing: boolean;
2071
+ constructor(busy: () => boolean);
2072
+ enter(): () => void;
2073
+ change<T>(check: () => Promise<void>, action: () => Promise<T>): Promise<T>;
2074
+ }
2075
+ declare class RemoteClient {
2076
+ readonly store: RemoteStore;
2077
+ readonly fetcher: typeof fetch;
2078
+ constructor(store: RemoteStore, fetcher?: typeof fetch);
2079
+ request(operation: string, payload?: Data$3, connection?: any, signal?: AbortSignal): Promise<Response>;
2080
+ inventory(connection?: any, signal?: AbortSignal): Promise<Data$3[]>;
2081
+ }
2082
+ /** Native chunk relay preserves AryaAI tool calls, reasoning and usage accounting. */
2083
+ declare class RemoteAdapter {
2084
+ readonly client: RemoteClient;
2085
+ readonly attachments: any;
2086
+ constructor(client: RemoteClient, attachments: any);
2087
+ providerInfo(provider: string): {
2088
+ id: string;
2089
+ name: string;
2090
+ };
2091
+ providerRetryPolicy(): {
2092
+ mode: string;
2093
+ maxRetries: number;
2094
+ retryableCodes: never[];
2095
+ initialDelayMs: number;
2096
+ maxDelayMs: number;
2097
+ jitterRatio: number;
2098
+ };
2099
+ imageRequestPricing(): undefined;
2100
+ listModels(): Promise<{
2101
+ provider: string;
2102
+ }[]>;
2103
+ resolveModel(provider: string, id: string, signal?: AbortSignal, connection?: any): Promise<Data$3>;
2104
+ prepareCall(provider: string, id: string, signal?: AbortSignal): Promise<{
2105
+ model: Data$3;
2106
+ stream: (options: Data$3) => AsyncGenerator<any, void, any>;
2107
+ }>;
2108
+ stream(options: Data$3): AsyncGenerator<any, void, any>;
2109
+ streamAt(options: Data$3, connection: Data$3 | null): AsyncGenerator<any, void, any>;
2110
+ }
2111
+ type HostOptions = {
2112
+ models: () => Promise<Data$3[]>;
2113
+ stream: (options: Data$3) => AsyncIterable<Data$3>;
2114
+ ensure: (model: Data$3) => Promise<void>;
2115
+ ready?: (model: Data$3) => Promise<boolean>;
2116
+ checkIdle: () => Promise<void>;
2117
+ base: string;
2118
+ attachments: any;
2119
+ gate: ActivityGate;
2120
+ wireEndpoint?: (model: Data$3) => string;
2121
+ authorizeDevice?: (token: string) => boolean;
2122
+ };
2123
+ declare function mountRemote(ctx: any, store: RemoteStore, host: HostOptions, llm: any): (() => void) & {
2124
+ refresh: () => any;
2125
+ };
2126
+ //#endregion
2127
+ //#region src/api-benchmarks.d.ts
2128
+ type Data$2 = Record<string, any>;
2129
+ /** Reuse registered adapters and credentials; nothing secret goes in the inventory or run files. */
2130
+ declare class ApiBenchmarks {
2131
+ readonly llm: any;
2132
+ readonly attachments: any;
2133
+ readonly localProviders: string[];
2134
+ private replay;
2135
+ constructor(llm: any, attachments: any, localProviders?: string[]);
2136
+ models(): Promise<Data$2[]>;
2137
+ complete(provider: string, model: string, body: Data$2, signal: AbortSignal): Promise<{
2138
+ content: string;
2139
+ reasoning: boolean;
2140
+ calls: Data$2[];
2141
+ finishReason: string;
2142
+ api: boolean;
2143
+ reasoningEffort: any;
2144
+ contextWindow: any;
2145
+ metrics: {
2146
+ ttftMs: number | null;
2147
+ elapsedMs: number;
2148
+ outputTokens: any;
2149
+ promptTokens: any;
2150
+ cachedTokens: any;
2151
+ reasoningTokens: any;
2152
+ tps: number | null;
2153
+ tpsSource: string;
2154
+ promptMs: null;
2155
+ };
2156
+ }>;
2157
+ }
2158
+ //#endregion
2159
+ //#region src/benchmarks.d.ts
2160
+ type Data$1 = Record<string, any>;
2161
+ declare function validateRun(body: Data$1): Data$1;
2162
+ declare function parseStreamEvent(data: Data$1, state: Data$1): void;
2163
+ declare function complete(endpoint: string, model: string, body: Data$1, signal: AbortSignal, headers?: Record<string, string>): Promise<{
2164
+ content: any;
2165
+ reasoning: boolean;
2166
+ calls: any;
2167
+ finishReason: any;
2168
+ metrics: {
2169
+ ttftMs: any;
2170
+ elapsedMs: number;
2171
+ outputTokens: any;
2172
+ promptTokens: any;
2173
+ cachedTokens: any;
2174
+ tps: any;
2175
+ tpsSource: string;
2176
+ promptMs: any;
2177
+ };
2178
+ }>;
2179
+ declare class Benchmarks {
2180
+ readonly controller: any;
2181
+ readonly api?: ApiBenchmarks | undefined;
2182
+ readonly freeToken?: FreeTokenController | undefined;
2183
+ readonly ninfer?: NInferController | undefined;
2184
+ controlBase: () => string;
2185
+ readonly folder: string;
2186
+ private active;
2187
+ private strataHeaders;
2188
+ private headers;
2189
+ private complete;
2190
+ constructor(controller: any, api?: ApiBenchmarks | undefined, freeToken?: FreeTokenController | undefined, ninfer?: NInferController | undefined);
2191
+ /** Report browser prerequisites before any model is interrupted. */
2192
+ environment(): {
2193
+ available: boolean;
2194
+ runtime: string;
2195
+ executable: string;
2196
+ detail: string;
2197
+ };
2198
+ private browserTools;
2199
+ busy(): boolean;
2200
+ private save;
2201
+ history(): any[];
2202
+ get(id: string): any;
2203
+ exportZip(id: string): Buffer<ArrayBuffer>;
2204
+ remove(body: Data$1): {
2205
+ ok: boolean;
2206
+ deleted: string[];
2207
+ detail: string;
2208
+ };
2209
+ cancel(): {
2210
+ ok: boolean;
2211
+ detail: string;
2212
+ };
2213
+ rate(body: Data$1): {
2214
+ ok: boolean;
2215
+ };
2216
+ asset(runId: string, key: string, file: string): NonSharedBuffer;
2217
+ models(): Promise<Data$1[]>;
2218
+ private catalog;
2219
+ private gpu;
2220
+ private readiness;
2221
+ start(body: Data$1): Promise<{
2222
+ ok: boolean;
2223
+ id: any;
2224
+ }>;
2225
+ private localControl;
2226
+ private wait;
2227
+ private perform;
2228
+ }
2229
+ //#endregion
2230
+ //#region src/comparisons.d.ts
2231
+ type Data = Record<string, any>;
2232
+ declare function comparisonColumns(runs: Data[]): any[];
2233
+ //#endregion
2234
+ //#region src/website-tests.d.ts
2235
+ declare const websiteTests: readonly [{
2236
+ readonly id: "landing";
2237
+ readonly name: "Product launch";
2238
+ readonly description: "Marketing, pricing and newsletter signup";
2239
+ readonly brief: "Build a polished product launch site for Orbit, a local AI assistant. Include hero, features, three pricing cards, testimonials and newsletter signup. Email input data-testid=\"email\", subscribe button \"subscribe\", feedback \"feedback\". Valid email submission must show \"Subscribed\" in feedback without navigating. Include a theme toggle \"theme-toggle\" that changes the document.documentElement data-theme between light and dark.";
2240
+ }, {
2241
+ readonly id: "dashboard";
2242
+ readonly name: "Analytics dashboard";
2243
+ readonly description: "Charts, searchable data and a period filter";
2244
+ readonly brief: "Build a polished analytics dashboard for a coffee business. Include KPI cards and a chart drawn with inline SVG or canvas. Add period select data-testid=\"period\" with options week and month, and revenue figure \"revenue\" that visibly changes between periods. Include customer rows each data-testid=\"customer-row\", one containing Maya Chen and one Alex Rivera; search input \"search\" must filter those rows by customer name.";
2245
+ }, {
2246
+ readonly id: "store";
2247
+ readonly name: "Online store";
2248
+ readonly description: "Product filtering and working shopping cart";
2249
+ readonly brief: "Build a premium outdoor equipment store with six products, product cards and a shopping cart. Give each visible product card data-testid=\"product\". Include a product named Trail Pack and another named Camp Light. Search input \"search\" filters visible products. A button data-testid=\"add-cart\" on the first product adds one item to the cart; cart count \"cart-count\" starts at 0 and increases to 1. Clear-cart button \"clear-cart\" resets count to 0.";
2250
+ }, {
2251
+ readonly id: "kanban";
2252
+ readonly name: "Kanban workspace";
2253
+ readonly description: "Create, filter and move project tasks";
2254
+ readonly brief: "Build a professional three-column kanban board with Todo, Doing and Done. Each card has data-testid=\"task\" and a status label. Create task input \"task-title\" and button \"add-task\" must add a visible card with that title. Search input \"search\" filters task cards. The new task must have a button \"move-task\" that moves that card from Todo to Doing, visibly updating its status to Doing.";
2255
+ }, {
2256
+ readonly id: "booking";
2257
+ readonly name: "Booking experience";
2258
+ readonly description: "Accessible form validation and confirmation";
2259
+ readonly brief: "Build an attractive appointment booking page for a wellness studio, including service information and availability. Provide form fields data-testid=\"name\", \"email\", \"date\" (type date), and submit button \"book\". Mark all three required and label them accessibly. Empty submission must not show a confirmation. Valid submission must show \"Booking confirmed\" in a visible element data-testid=\"confirmation\", without navigating or network requests.";
2260
+ }, {
2261
+ readonly id: "docs";
2262
+ readonly name: "Documentation portal";
2263
+ readonly description: "Navigation, content search and accordion";
2264
+ readonly brief: "Build a professional developer documentation portal with sidebar, article and code examples. Sidebar button data-testid=\"api-tab\" switches the article data-testid=\"article\" to API Reference content. Search input \"search\" filters navigation entries data-testid=\"doc-link\"; include Getting Started and API Reference entries. FAQ question button data-testid=\"faq-toggle\" expands an initially hidden answer data-testid=\"faq-answer\" containing \"offline\".";
2265
+ }, {
2266
+ readonly id: "snake";
2267
+ readonly name: "Snake game";
2268
+ readonly description: "Keyboard movement, food growth, collision and reset";
2269
+ readonly brief: "Build a playable 10x10 Snake game with keyboard arrow controls, start/pause, score, reset data-testid=\"reset\", and manual tick button \"step\". Start paused. Initial snake cells are [[3,2],[2,2],[1,2]], heading right, food [4,2], score 0. Expose live JSON in a visible details element data-testid=\"game-state\" with snake (array of [x,y]), food, score, direction and gameOver. Each Step advances one cell even while paused. Eating food grows by one and raises score by 1. Ignore immediate reversal. Wall and self collisions set gameOver=true and stop movement. Reset restores the exact initial state. Render the board and snake visibly; playable on mobile with direction buttons.";
2270
+ }, {
2271
+ readonly id: "tetris";
2272
+ readonly name: "Tetris game";
2273
+ readonly description: "Movement, rotation, hard drop, line clearing and restart";
2274
+ readonly brief: "Build playable 10x20 Tetris with arrow movement, up-arrow rotation, space hard drop, pause, restart data-testid=\"reset\". Start paused with an empty board and a T piece at x=3,y=0, rotation=0. Expose live JSON in visible details data-testid=\"game-state\" with x,y,rotation,lines,score,gameOver and board (20 arrays of 10 cells). Button \"line-fixture\" loads a deterministic line-clear scenario: bottom four rows filled except column 4, active vertical I piece above that column. Button \"hard-drop\" locks the active piece and clears complete lines, adds 4 to lines and increases score for that fixture. ArrowRight changes x, ArrowUp changes rotation without leaving the board. Restart resets lines and score to 0 and empties board. Visibly render board, piece and score, include mobile controls. All fixtures and state must drive the actual game logic.";
2275
+ }];
2276
+ declare function extractHtml(text: string): string;
2277
+ declare function isolatedHtml(html: string): string;
2278
+ declare function inspectWebsite(html: string, id: string, folder: string, pw: any, executablePath: string, signal: AbortSignal): Promise<{
2279
+ checks: {
2280
+ name: string;
2281
+ passed: boolean;
2282
+ detail?: string;
2283
+ }[];
2284
+ score: number;
2285
+ errors: string[];
2286
+ }>;
2287
+ //#endregion
2288
+ //#region src/index.d.ts
2289
+ declare const name = "@aryacode/dsh-local-llm";
2290
+ declare const inject: string[];
2291
+ /** Phases where the llama.cpp controller holds no model server: nothing to stop first. */
2292
+ declare function engineIdle(phase: string): phase is "stopped" | "missing-model";
2293
+ declare class ServerController {
2294
+ directory: string;
2295
+ readonly benchmarkRuntimeDirectory: string;
2296
+ readonly port: number;
2297
+ context: number;
2298
+ cpuMoeLayers: number;
2299
+ threads: number;
2300
+ selectedModel: string;
2301
+ selectedVision: string;
2302
+ runtimeExecutable: string | undefined;
2303
+ ollamaUrl: string;
2304
+ readonly preferencesDirectory: string;
2305
+ webUiUrls: Record<string, string>;
2306
+ settingsIssue: string | undefined;
2307
+ private busy;
2308
+ constructor(config?: {
2309
+ directory?: string;
2310
+ port?: number;
2311
+ context?: number;
2312
+ cpuMoeLayers?: number;
2313
+ threads?: number;
2314
+ benchmarkRuntimeDirectory?: string;
2315
+ preferencesDirectory?: string;
2316
+ executable?: string;
2317
+ ollamaUrl?: string;
2318
+ });
2319
+ get exe(): string;
2320
+ private validateOllamaUrl;
2321
+ setup(): {
2322
+ directory: string;
2323
+ webUiUrls: Record<string, string>;
2324
+ executable: string;
2325
+ runtimeInstalled: boolean;
2326
+ ollamaUrl: string;
2327
+ platform: NodeJS.Platform;
2328
+ engines: {
2329
+ id: string;
2330
+ name: string;
2331
+ installUrl: string;
2332
+ detail: string;
2333
+ }[];
2334
+ };
2335
+ setupEngine(value: Record<string, unknown>): Promise<{
2336
+ ok: boolean;
2337
+ detail: string;
2338
+ }>;
2339
+ get model(): string;
2340
+ get vision(): string;
2341
+ private readPresets;
2342
+ private inspectPresets;
2343
+ modelPresets(): Record<string, Record<string, any>>;
2344
+ modelSettings(file: string): {
2345
+ context: any;
2346
+ threads: any;
2347
+ cpuMoeLayers: any;
2348
+ selectedVision: any;
2349
+ } | null;
2350
+ private validateSettings;
2351
+ configure(body: Record<string, unknown>): Promise<{
2352
+ ok: boolean;
2353
+ detail: string;
2354
+ }>;
2355
+ /** Save a validated per-model profile while the managed server is stopped. */
2356
+ savePreset(body: Record<string, unknown>): Promise<{
2357
+ ok: boolean;
2358
+ detail: string;
2359
+ }>;
2360
+ /** Remove an inactive model file and its profile without affecting other models. */
2361
+ removeModel(file: unknown): Promise<{
2362
+ ok: boolean;
2363
+ detail: string;
2364
+ }>;
2365
+ get ownerPath(): string;
2366
+ private owner;
2367
+ private identity;
2368
+ private owned;
2369
+ logs(): string;
2370
+ status(): Promise<{
2371
+ phase: string;
2372
+ owned: boolean;
2373
+ pid: number | null;
2374
+ downloadPercent: number;
2375
+ complete: boolean;
2376
+ runtimeInstalled: boolean;
2377
+ settingsIssue: string | undefined;
2378
+ healthy: boolean;
2379
+ gpu: string | null;
2380
+ ramUsedGiB: number;
2381
+ ramTotalGiB: number;
2382
+ context: number;
2383
+ cpuMoeLayers: number;
2384
+ threads: number;
2385
+ selectedModel: string;
2386
+ selectedVision: string;
2387
+ presets: Record<string, Record<string, any>>;
2388
+ presetIssues: Record<string, string>;
2389
+ webUiUrl: string;
2390
+ cacheType: any;
2391
+ moeCacheMiB: any;
2392
+ baseUrl: string;
2393
+ model: any;
2394
+ logs: string;
2395
+ }>;
2396
+ action(action: string): Promise<{
2397
+ ok: boolean;
2398
+ detail: string;
2399
+ }>;
2400
+ }
2401
+ declare function apply(ctx: Context, config?: ConstructorParameters<typeof ServerController>[0] & {
2402
+ connectionDirectory?: string;
2403
+ webPort?: number;
2404
+ freeToken?: ConstructorParameters<typeof FreeTokenController>[0];
2405
+ ninfer?: ConstructorParameters<typeof NInferController>[0];
2406
+ webUiUrls?: Record<string, string>;
2407
+ strataProfiles?: readonly StrataProfile[];
2408
+ strata?: StrataConfig;
2409
+ }): void;
2410
+ //#endregion
2411
+ export { ActivityGate, ApiBenchmarks, Benchmarks, type EngineMember, FreeTokenController, LIBRARY_PROVIDER, type NInferContainer, NInferController, type NInferLogSummary, RemoteAdapter, RemoteClient, RemoteStore, ServerController, type StopOptions, StrataService, allowedControl, apply, apply$1 as applyStrataRoutes, comparisonColumns, complete, controlCaller, createOllamaVariant, engineIdle, engineeringTests, extractHtml, hardwareCollector, inject, inspectEngineering, inspectWebsite, isolatedHtml, libraryAdapter, linkedTarget, mountRemote, mountRoutes as mountStrataRoutes, name, outputDefault, ownsNInfer, parseNInferLog, parseStreamEvent, readStrataTuning, reclaimsNInfer, remoteAddress, saveStrataTuning, startPairRelay, stopOtherEngines, strataProfiles, switchStrataProfile, tuningArgs, validateFreeToken, validateNInfer, validateRun, validateTuning, websiteTests };