@aryacode/dsh-local-llm 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,80 @@
1
+ import { createRequire } from "node:module";
2
+ //#region \0rolldown/runtime.js
3
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
4
+ var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
5
+ //#endregion
6
+ //#region node_modules/.pnpm/@earendil-works+pi-ai@0.87.1_ws@8.22.0_zod@4.6.7/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js
7
+ var FifoQueue = class {
8
+ incoming = [];
9
+ outgoing = [];
10
+ get length() {
11
+ return this.incoming.length + this.outgoing.length;
12
+ }
13
+ enqueue(value) {
14
+ this.incoming.push(value);
15
+ }
16
+ dequeue() {
17
+ if (this.outgoing.length === 0) while (this.incoming.length > 0) this.outgoing.push(this.incoming.pop());
18
+ return this.outgoing.pop();
19
+ }
20
+ };
21
+ var EventStream = class {
22
+ queue = new FifoQueue();
23
+ waiting = new FifoQueue();
24
+ done = false;
25
+ finalResultPromise;
26
+ resolveFinalResult;
27
+ isComplete;
28
+ extractResult;
29
+ constructor(isComplete, extractResult) {
30
+ this.isComplete = isComplete;
31
+ this.extractResult = extractResult;
32
+ this.finalResultPromise = new Promise((resolve) => {
33
+ this.resolveFinalResult = resolve;
34
+ });
35
+ }
36
+ push(event) {
37
+ if (this.done) return;
38
+ if (this.isComplete(event)) {
39
+ this.done = true;
40
+ this.resolveFinalResult(this.extractResult(event));
41
+ }
42
+ const waiter = this.waiting.dequeue();
43
+ if (waiter) waiter({
44
+ value: event,
45
+ done: false
46
+ });
47
+ else this.queue.enqueue(event);
48
+ }
49
+ end(result) {
50
+ this.done = true;
51
+ if (result !== void 0) this.resolveFinalResult(result);
52
+ while (this.waiting.length > 0) this.waiting.dequeue()({
53
+ value: void 0,
54
+ done: true
55
+ });
56
+ }
57
+ async *[Symbol.asyncIterator]() {
58
+ while (true) if (this.queue.length > 0) yield this.queue.dequeue();
59
+ else if (this.done) return;
60
+ else {
61
+ const result = await new Promise((resolve) => this.waiting.enqueue(resolve));
62
+ if (result.done) return;
63
+ yield result.value;
64
+ }
65
+ }
66
+ result() {
67
+ return this.finalResultPromise;
68
+ }
69
+ };
70
+ var AssistantMessageEventStream = class extends EventStream {
71
+ constructor() {
72
+ super((event) => event.type === "done" || event.type === "error", (event) => {
73
+ if (event.type === "done") return event.message;
74
+ else if (event.type === "error") return event.error;
75
+ throw new Error("Unexpected event type for final result");
76
+ });
77
+ }
78
+ };
79
+ //#endregion
80
+ export { __commonJSMin as n, __require as r, AssistantMessageEventStream as t };
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { networkInterfaces } from "node:os";
2
2
  import { IncomingMessage } from "node:http";
3
3
  import si from "systeminformation";
4
- //#region node_modules/@deepseek-ai/cosmokit/lib/types/misc.d.ts
4
+ //#region node_modules/.pnpm/@deepseek-ai+cosmokit@1.8.5/node_modules/@deepseek-ai/cosmokit/lib/types/misc.d.ts
5
5
  /** String/symbol keyed dictionary type. */
6
6
  type Dict<T = any, K extends string | symbol = string> = { [key in K]: T; };
7
7
  /** Wrap a value in `Promise`, preserving the resolved type of existing promises. */
@@ -9,7 +9,7 @@ type Promisify<T> = Promise<T extends Promise<infer S> ? S : T>;
9
9
  /** Accept a value or promise unless the value type is already promise-like. */
10
10
  type Awaitable<T> = [T] extends [Promise<unknown>] ? T : T | Promise<T>;
11
11
  //#endregion
12
- //#region node_modules/@standard-schema/spec/dist/index.d.ts
12
+ //#region node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
13
13
  /** The Standard Typed interface. This is a base type extended by other specs. */
14
14
  interface StandardTypedV1<Input = unknown, Output = Input> {
15
15
  /** The Standard properties. */
@@ -86,7 +86,7 @@ declare namespace StandardSchemaV1 {
86
86
  type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
87
87
  }
88
88
  //#endregion
89
- //#region node_modules/@deepseek-ai/cordis/lib/types/utils.d.ts
89
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/utils.d.ts
90
90
  /** Ordered collection of disposable values with O(1) deletion by value. */
91
91
  declare class DisposableList<T extends WeakKey> {
92
92
  private sn;
@@ -119,7 +119,7 @@ declare const symbols: {
119
119
  resolveConfig: typeof Service.resolveConfig;
120
120
  };
121
121
  //#endregion
122
- //#region node_modules/@deepseek-ai/cordis/lib/types/registry.d.ts
122
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/registry.d.ts
123
123
  /**
124
124
  * Service dependency declaration accepted by plugins and the `@Inject`
125
125
  * decorator.
@@ -311,7 +311,7 @@ declare class RegistryService {
311
311
  plugin(plugin: Plugin, config?: any, getOuterStack?: () => string[]): Fiber & PromiseLike<Fiber>;
312
312
  }
313
313
  //#endregion
314
- //#region node_modules/@deepseek-ai/cordis/lib/types/reflect.d.ts
314
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/reflect.d.ts
315
315
  declare module './context.ts' {
316
316
  interface Context {
317
317
  /**
@@ -495,7 +495,7 @@ declare class ReflectService {
495
495
  bind<T extends Function>(callback: T): T;
496
496
  }
497
497
  //#endregion
498
- //#region node_modules/@deepseek-ai/cordis/lib/types/fiber.d.ts
498
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/fiber.d.ts
499
499
  declare module './context.ts' {
500
500
  interface Context extends Pick<Fiber, 'effect'> {
501
501
  /** The fiber (plugin runtime instance) that owns this context. */
@@ -656,7 +656,7 @@ declare class Fiber {
656
656
  update(config: any, noSave?: boolean): void;
657
657
  }
658
658
  //#endregion
659
- //#region node_modules/@deepseek-ai/cordis/lib/types/events.d.ts
659
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/events.d.ts
660
660
  /** Extract the parameter tuple from a function type. */
661
661
  type Parameters<F> = F extends ((...args: infer P) => any) ? P : never;
662
662
  /** Extract the return type from a function type. */
@@ -887,7 +887,7 @@ interface Events {
887
887
  'internal/dispatch'(mode: DispatchMode, name: string, args: any[], thisArg: any): void;
888
888
  }
889
889
  //#endregion
890
- //#region node_modules/@deepseek-ai/cordis/lib/types/logger.d.ts
890
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/logger.d.ts
891
891
  declare module './context.ts' {
892
892
  interface Intercept {
893
893
  logger: LoggerService.Intercept;
@@ -975,7 +975,7 @@ declare class LoggerService {
975
975
  [symbols.invoke](name?: string): Logger;
976
976
  }
977
977
  //#endregion
978
- //#region node_modules/@deepseek-ai/cordis/lib/types/context.d.ts
978
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/context.d.ts
979
979
  /**
980
980
  * Public shape of a Cordis context.
981
981
  *
@@ -1070,7 +1070,7 @@ declare class Context {
1070
1070
  intercept(name: string, config: any): this;
1071
1071
  }
1072
1072
  //#endregion
1073
- //#region node_modules/@deepseek-ai/cordis/lib/types/service.d.ts
1073
+ //#region node_modules/.pnpm/@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/cordis/lib/types/service.d.ts
1074
1074
  /**
1075
1075
  * Base class for services that expose a named API on `ctx`.
1076
1076
  *
@@ -1607,6 +1607,15 @@ declare function startPairRelay(options: {
1607
1607
  //#region src/library.d.ts
1608
1608
  type Data$4 = Record<string, any>;
1609
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;
1610
1619
  /** Where the Strata engine's own OpenAI-compatible surface answers, and how to authorize it. */
1611
1620
  interface StrataModelSource {
1612
1621
  /** Engine base URL, without a trailing slash, e.g. `http://127.0.0.1:8080`. */
@@ -1634,61 +1643,15 @@ interface NInferModelSource {
1634
1643
  vision?: boolean;
1635
1644
  }>;
1636
1645
  }
1637
- 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): {
1638
- providerInfo: () => {
1639
- id: string;
1640
- name: string;
1641
- };
1642
- providerRetryPolicy: () => {
1643
- mode: "normal";
1644
- maxRetries: number;
1645
- retryableCodes: never[];
1646
- initialDelayMs: number;
1647
- maxDelayMs: number;
1648
- jitterRatio: number;
1649
- };
1650
- imageRequestPricing: () => undefined;
1651
- listModels: () => Promise<{
1652
- provider: string;
1653
- id: string;
1654
- name: string;
1655
- context: {
1656
- contextWindow: number;
1657
- };
1658
- defaultMaxTokens: number;
1659
- inputModalities: ("text" | "image")[];
1660
- originalProvider: string;
1661
- originalModel: string;
1662
- }[]>;
1663
- resolveModel: (_provider: string, id: string) => Promise<{
1664
- provider: string;
1665
- id: string;
1666
- name: string;
1667
- context: {
1668
- contextWindow: number;
1669
- };
1670
- defaultMaxTokens: number;
1671
- inputModalities: ("text" | "image")[];
1672
- originalProvider: string;
1673
- originalModel: string;
1674
- }>;
1675
- prepareCall: (provider: string, id: string) => Promise<{
1676
- model: {
1677
- provider: string;
1678
- id: string;
1679
- name: string;
1680
- context: {
1681
- contextWindow: number;
1682
- };
1683
- defaultMaxTokens: number;
1684
- inputModalities: ("text" | "image")[];
1685
- originalProvider: string;
1686
- originalModel: string;
1687
- };
1688
- stream(options: Data$4): AsyncGenerator<import("@deepseek-ai/dsh-llm").StreamChunk, void, any>;
1689
- }>;
1690
- stream(options: Data$4): AsyncGenerator<import("@deepseek-ai/dsh-llm").StreamChunk, void, any>;
1691
- };
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;
1692
1655
  //#endregion
1693
1656
  //#region src/hardware.d.ts
1694
1657
  declare function hardwareCollector(source?: typeof si): () => Promise<Record<string, unknown>>;
@@ -1720,6 +1683,34 @@ declare function ownsNInfer(owner: {
1720
1683
  Labels: Record<string, string>;
1721
1684
  };
1722
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;
1723
1714
  /** Control only the saved runtime identity; leave other engines untouched. */
1724
1715
  declare class NInferController {
1725
1716
  readonly directory: string;
@@ -1734,7 +1725,7 @@ declare class NInferController {
1734
1725
  name: string;
1735
1726
  label: string;
1736
1727
  port: number;
1737
- modelName: string;
1728
+ modelName?: string;
1738
1729
  defaults: NInferSettings;
1739
1730
  wsl?: {
1740
1731
  distribution: string;
@@ -1745,6 +1736,8 @@ declare class NInferController {
1745
1736
  /** Resolve saved tuning or validated deployment defaults. */
1746
1737
  settings(): NInferSettings;
1747
1738
  private callWsl;
1739
+ /** A container this Host may reclaim; a missing Docker or an unrelated one is no takeover. */
1740
+ private external;
1748
1741
  private wslStatus;
1749
1742
  private docker;
1750
1743
  private container;
@@ -1765,7 +1758,10 @@ declare class NInferController {
1765
1758
  healthy: boolean;
1766
1759
  complete: boolean;
1767
1760
  runtime: string;
1768
- containerId: null;
1761
+ containerId: string | null;
1762
+ external: boolean;
1763
+ takeover: boolean;
1764
+ detail: string | undefined;
1769
1765
  modelName: string;
1770
1766
  baseUrl: string;
1771
1767
  } | {
@@ -1783,10 +1779,13 @@ declare class NInferController {
1783
1779
  healthy: boolean;
1784
1780
  complete: boolean;
1785
1781
  containerId: string | null | undefined;
1782
+ external: boolean;
1783
+ takeover: boolean;
1784
+ detail: string | undefined;
1786
1785
  modelName: string;
1787
1786
  baseUrl: string;
1788
1787
  }>;
1789
- /** Return a bounded log tail from the configured owned runtime. */
1788
+ /** Return a bounded log tail from the configured owned runtime, or from the engine another launcher started. */
1790
1789
  logs(): Promise<Record<string, unknown>>;
1791
1790
  /** Persist tuning while the container and model API are stopped. */
1792
1791
  configure(value: unknown): Promise<{
@@ -1794,8 +1793,13 @@ declare class NInferController {
1794
1793
  detail: string;
1795
1794
  }>;
1796
1795
  private stop;
1797
- /** Start, stop or restart the owned localhost runtime without taking over foreign containers. */
1798
- action(action: 'start' | 'stop' | 'restart'): Promise<Record<string, unknown>>;
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
+ }>;
1799
1803
  }
1800
1804
  //#endregion
1801
1805
  //#region src/ninfer-log.d.ts
@@ -2282,7 +2286,7 @@ declare function inspectWebsite(html: string, id: string, folder: string, pw: an
2282
2286
  }>;
2283
2287
  //#endregion
2284
2288
  //#region src/index.d.ts
2285
- declare const name = "dsh-local-llm";
2289
+ declare const name = "@aryacode/dsh-local-llm";
2286
2290
  declare const inject: string[];
2287
2291
  /** Phases where the llama.cpp controller holds no model server: nothing to stop first. */
2288
2292
  declare function engineIdle(phase: string): phase is "stopped" | "missing-model";
@@ -2404,4 +2408,4 @@ declare function apply(ctx: Context, config?: ConstructorParameters<typeof Serve
2404
2408
  strata?: StrataConfig;
2405
2409
  }): void;
2406
2410
  //#endregion
2407
- export { ActivityGate, ApiBenchmarks, Benchmarks, type EngineMember, FreeTokenController, LIBRARY_PROVIDER, 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, ownsNInfer, parseNInferLog, parseStreamEvent, readStrataTuning, remoteAddress, saveStrataTuning, startPairRelay, stopOtherEngines, strataProfiles, switchStrataProfile, tuningArgs, validateFreeToken, validateNInfer, validateRun, validateTuning, websiteTests };
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 };