dsh-plugin-local-infer 0.1.1 → 0.1.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.
Files changed (108) hide show
  1. package/README.md +14 -3
  2. package/docs/zh/README.md +14 -3
  3. package/dsh/client.js +1214 -242
  4. package/package.json +16 -10
  5. package/packages/core/lib/adapter.d.ts +119 -6
  6. package/packages/core/lib/deps.d.ts +4 -3
  7. package/packages/core/lib/index.d.ts +2 -1
  8. package/packages/core/lib/index.js +1 -0
  9. package/packages/core/lib/launch-command.d.ts +13 -0
  10. package/packages/core/lib/launch-command.js +64 -0
  11. package/packages/core/lib/models.d.ts +2 -1
  12. package/packages/core/lib/models.js +10 -1
  13. package/packages/core/lib/registrar.d.ts +5 -5
  14. package/packages/core/lib/registrar.js +3 -3
  15. package/packages/core/lib/status.d.ts +9 -1
  16. package/packages/core/lib/status.js +6 -1
  17. package/packages/core/package.json +1 -1
  18. package/packages/providers/lib/acquire.d.ts +127 -0
  19. package/packages/providers/lib/acquire.js +346 -0
  20. package/packages/providers/lib/adapters.d.ts +19 -172
  21. package/packages/providers/lib/adapters.js +114 -659
  22. package/packages/providers/lib/deps.d.ts +26 -2
  23. package/packages/providers/lib/deps.js +37 -4
  24. package/packages/providers/lib/engines/hyperqwenAdapter.d.ts +38 -0
  25. package/packages/providers/lib/engines/hyperqwenAdapter.js +105 -0
  26. package/packages/providers/lib/engines/infernix.d.ts +170 -0
  27. package/packages/providers/lib/engines/infernix.js +671 -0
  28. package/packages/providers/lib/engines/infernixAdapter.d.ts +53 -0
  29. package/packages/providers/lib/engines/infernixAdapter.js +202 -0
  30. package/packages/providers/lib/engines/llamacppAdapter.d.ts +51 -0
  31. package/packages/providers/lib/engines/llamacppAdapter.js +232 -0
  32. package/packages/providers/lib/{ninfer.d.ts → engines/ninfer.d.ts} +7 -0
  33. package/packages/providers/lib/{ninfer.js → engines/ninfer.js} +8 -1
  34. package/packages/providers/lib/engines/ninferAdapter.d.ts +82 -0
  35. package/packages/providers/lib/engines/ninferAdapter.js +324 -0
  36. package/packages/providers/lib/engines/strata.d.ts +53 -0
  37. package/packages/providers/lib/engines/strata.js +197 -0
  38. package/packages/providers/lib/engines/strataAdapter.d.ts +98 -0
  39. package/packages/providers/lib/engines/strataAdapter.js +427 -0
  40. package/packages/providers/lib/engines.d.ts +5 -3
  41. package/packages/providers/lib/engines.js +16 -8
  42. package/packages/providers/lib/guidelines.js +16 -0
  43. package/packages/providers/lib/index.d.ts +21 -10
  44. package/packages/providers/lib/index.js +23 -9
  45. package/packages/providers/lib/model-defaults.d.ts +8 -5
  46. package/packages/providers/lib/model-defaults.js +47 -5
  47. package/packages/providers/lib/platform.d.ts +31 -0
  48. package/packages/providers/lib/platform.js +64 -0
  49. package/packages/providers/package.json +1 -1
  50. package/packages/service/lib/index.d.ts +74 -22
  51. package/packages/service/lib/index.js +354 -44
  52. package/packages/service/lib/types.d.ts +48 -5
  53. package/packages/service/package.json +1 -1
  54. package/packages/tool/package.json +1 -1
  55. package/packages/ui/lib/config.d.ts +79 -0
  56. package/packages/ui/lib/config.js +235 -0
  57. package/packages/ui/lib/deps.d.ts +3 -3
  58. package/packages/ui/lib/ops/engine.d.ts +108 -0
  59. package/packages/ui/lib/ops/engine.js +493 -0
  60. package/packages/ui/lib/ops/hf.d.ts +27 -0
  61. package/packages/ui/lib/ops/hf.js +60 -0
  62. package/packages/ui/lib/ops/logs.d.ts +23 -0
  63. package/packages/ui/lib/ops/logs.js +58 -0
  64. package/packages/ui/lib/ops/model.d.ts +79 -0
  65. package/packages/ui/lib/ops/model.js +130 -0
  66. package/packages/ui/lib/request.d.ts +106 -0
  67. package/packages/ui/lib/request.js +80 -0
  68. package/packages/ui/lib/route.d.ts +96 -357
  69. package/packages/ui/lib/route.js +123 -1415
  70. package/packages/ui/lib/routes/chat-template.d.ts +14 -0
  71. package/packages/ui/lib/routes/chat-template.js +37 -0
  72. package/packages/ui/lib/routes/deps.d.ts +16 -0
  73. package/packages/ui/lib/routes/deps.js +27 -0
  74. package/packages/ui/lib/routes/download.d.ts +16 -0
  75. package/packages/ui/lib/routes/download.js +48 -0
  76. package/packages/ui/lib/routes/get.d.ts +18 -0
  77. package/packages/ui/lib/routes/get.js +57 -0
  78. package/packages/ui/lib/routes/install.d.ts +16 -0
  79. package/packages/ui/lib/routes/install.js +36 -0
  80. package/packages/ui/lib/routes/launch.d.ts +18 -0
  81. package/packages/ui/lib/routes/launch.js +50 -0
  82. package/packages/ui/lib/routes/provider-delete.d.ts +15 -0
  83. package/packages/ui/lib/routes/provider-delete.js +37 -0
  84. package/packages/ui/lib/routes/register.d.ts +16 -0
  85. package/packages/ui/lib/routes/register.js +28 -0
  86. package/packages/ui/lib/routes/save.d.ts +18 -0
  87. package/packages/ui/lib/routes/save.js +139 -0
  88. package/packages/ui/lib/routes/stop.d.ts +16 -0
  89. package/packages/ui/lib/routes/stop.js +29 -0
  90. package/packages/ui/lib/routes/summary.d.ts +15 -0
  91. package/packages/ui/lib/routes/summary.js +26 -0
  92. package/packages/ui/lib/routes/unregister.d.ts +14 -0
  93. package/packages/ui/lib/routes/unregister.js +26 -0
  94. package/packages/ui/lib/viewmodels/deps.d.ts +31 -0
  95. package/packages/ui/lib/viewmodels/deps.js +89 -0
  96. package/packages/ui/lib/viewmodels/depsHelpers.d.ts +28 -0
  97. package/packages/ui/lib/viewmodels/depsHelpers.js +33 -0
  98. package/packages/ui/lib/viewmodels/summary.d.ts +140 -0
  99. package/packages/ui/lib/viewmodels/summary.js +225 -0
  100. package/packages/ui/lib/viewmodels/summaryHelpers.d.ts +30 -0
  101. package/packages/ui/lib/viewmodels/summaryHelpers.js +42 -0
  102. package/packages/ui/package.json +1 -1
  103. package/packages/providers/lib/strata.d.ts +0 -15
  104. package/packages/providers/lib/strata.js +0 -14
  105. /package/packages/providers/lib/{hyperqwen.d.ts → engines/hyperqwen.d.ts} +0 -0
  106. /package/packages/providers/lib/{hyperqwen.js → engines/hyperqwen.js} +0 -0
  107. /package/packages/providers/lib/{llamacpp.d.ts → engines/llamacpp.d.ts} +0 -0
  108. /package/packages/providers/lib/{llamacpp.js → engines/llamacpp.js} +0 -0
@@ -0,0 +1,324 @@
1
+ /**
2
+ * The NInfer engine adapter. NInferModelArtifact is the per-model deploy data:
3
+ * the `.ninfer` artifact file, the Hugging Face repo the model download pulls
4
+ * it from, and the `--model-id` alias the server advertises. The data is the
5
+ * surface; adding a model is a data edit here, never an adapter rewire.
6
+ * NInferAdapter is the canonical both-capable engine. `renderLaunch` renders a
7
+ * local `ninfer-serve` process or a `docker run` of the ghcr image from the
8
+ * same spec surface; `deploy` builds the engine in the engine directory (or
9
+ * pulls the image), downloads the model into the model directory, and starts
10
+ * the engine; `healthCheck` polls the health URL; `stop` signals the tracked
11
+ * process and stops the named container.
12
+ * @module dsh-plugin-local-infer/providers/engines/ninferAdapter
13
+ */
14
+ import { basename, dirname, join } from 'node:path';
15
+ import { EngineAdapter } from '../../../core/lib/index.js';
16
+ import { customArgFlags, flagsFromSpecs, nodeLifecycleHost, pollHealth, trackChild, } from "../adapters.js";
17
+ import { syncAndRebuildEngine } from "../acquire.js";
18
+ import { NINFER_PARAMETERS } from "./ninfer.js";
19
+ /**
20
+ * The NInfer model artifacts, keyed by the model registry id. The 27B entry
21
+ * is the default the DEFAULT_MODELS list names; the 35B-A3B entries are the
22
+ * Qwen3.8 measured artifact (`qwen3-35b`) and the Qwen3.6 default
23
+ * (`qwen36-35b`).
24
+ */
25
+ export const NINFER_MODEL_ARTIFACTS = {
26
+ 'qwen3-27b': {
27
+ file: 'qwen3_8_27b_nvfp4.ninfer',
28
+ repo: 'neroued/Qwen3.8-27B-nvfp4-NInfer',
29
+ modelId: 'Qwen3.8-27B',
30
+ },
31
+ // The Swift 1.5 ablated 27B the local launcher bootstraps: the nvfp4-full
32
+ // DFlash2 artifact the qwen-ninfer script serves. It reuses the 27B model id
33
+ // the engine advertises, so a chat turn routes to the same alias.
34
+ 'qwen3-27b-swift15': {
35
+ file: 'qwen3_8_27b_swift15abl_nvfp4full-dflash2.ninfer',
36
+ repo: 'kaushikvira/Qwen3.8-27B-swift15-uncensored-ajgazin-nvfp4full-dflash2-NInfer-v3',
37
+ modelId: 'Qwen3.8-27B',
38
+ },
39
+ 'qwen3-35b': {
40
+ file: 'qwen3_8_35b_a3b.ninfer',
41
+ repo: 'Neroued/Qwen3.8-35B-A3B-NInfer',
42
+ modelId: 'Qwen3.8-35B-A3B',
43
+ },
44
+ 'qwen36-35b': {
45
+ file: 'qwen3_6_35b_a3b.ninfer',
46
+ repo: 'neroued/Qwen3.6-35B-A3B-NInfer',
47
+ modelId: 'Qwen3.6-35B-A3B',
48
+ },
49
+ };
50
+ /**
51
+ * artifactFor resolves the artifact a model id deploys. An id no entry names
52
+ * falls back to the 27B artifact, so a bare config always renders a plan.
53
+ */
54
+ function artifactFor(modelId) {
55
+ const artifact = modelId !== undefined ? NINFER_MODEL_ARTIFACTS[modelId] : undefined;
56
+ return artifact ?? NINFER_MODEL_ARTIFACTS['qwen3-27b'];
57
+ }
58
+ /**
59
+ * The NInfer docker image the adapter pulls and runs. The engineFork platform
60
+ * config overrides the git source for a local build; the image stays the
61
+ * upstream ghcr artifact.
62
+ */
63
+ export const NINFER_DOCKER_IMAGE = 'ghcr.io/iamwavecut/ninfer-all';
64
+ /**
65
+ * NInferAdapter is the canonical both-capable engine. `renderLaunch` renders a
66
+ * local `ninfer-serve` process or a `docker run` of the ghcr image from the
67
+ * same spec surface; `deploy` builds the engine in the engine directory (or
68
+ * pulls the image), downloads the model into the model directory, and starts
69
+ * the engine; `healthCheck` polls the health URL; `stop` signals the tracked
70
+ * process and stops the named container.
71
+ */
72
+ export class NInferAdapter extends EngineAdapter {
73
+ id = 'ninfer';
74
+ supports = { docker: true, local: true };
75
+ host;
76
+ children = new Map();
77
+ constructor(host = nodeLifecycleHost) {
78
+ super();
79
+ this.host = host;
80
+ }
81
+ parameters() {
82
+ return NINFER_PARAMETERS;
83
+ }
84
+ modelRef(config) {
85
+ // The id the engine advertises on its OpenAI endpoint is the artifact's
86
+ // --model-id alias, not the VramModel registry key the config names, so
87
+ // the registrar publishes the alias and a chat turn routes to it.
88
+ const artifact = artifactFor(typeof config.model === 'string' ? config.model : 'qwen3-27b');
89
+ return { id: artifact.modelId, name: artifact.modelId };
90
+ }
91
+ launchSignature(config = {}) {
92
+ // The local plan runs the ninfer-serve binary; the docker plan's host
93
+ // process is docker run of the ghcr image, so the image name is the
94
+ // command-line marker the reserve probe matches on.
95
+ const port = this.port(config);
96
+ if (this.buildMode(config) === 'docker') {
97
+ return { binary: NINFER_DOCKER_IMAGE, port };
98
+ }
99
+ return { binary: 'ninfer-serve', port };
100
+ }
101
+ renderLaunch(config, _hw) {
102
+ const port = this.port(config);
103
+ const modelId = typeof config.model === 'string' ? config.model : 'qwen3-27b';
104
+ const artifact = artifactFor(modelId);
105
+ // A model key that names a local artifact file (a directory-scanned
106
+ // model) overrides the artifact map's file, so a file the user has on
107
+ // disk launches as-is.
108
+ const file = modelId.endsWith('.ninfer') ? modelId : artifact.file;
109
+ const modelDirectory = typeof config.modelDirectory === 'string' ? config.modelDirectory : '';
110
+ const flags = flagsFromSpecs(NINFER_PARAMETERS, config);
111
+ if (this.buildMode(config) === 'docker') {
112
+ const modelPath = modelDirectory === '' ? file : join(modelDirectory, file);
113
+ const containerModelPath = `/models/${basename(file)}`;
114
+ const modelMount = modelDirectory === ''
115
+ ? `${file}:${containerModelPath}`
116
+ : `${dirname(modelPath)}:/models`;
117
+ const containerName = `ninfer-${port}`;
118
+ const customArgs = customArgFlags(config);
119
+ return {
120
+ engineId: this.id,
121
+ kind: 'docker',
122
+ argv: [
123
+ 'docker',
124
+ 'run',
125
+ '--rm',
126
+ '--gpus',
127
+ 'all',
128
+ '--name',
129
+ containerName,
130
+ '-p',
131
+ `127.0.0.1:${port}:8080`,
132
+ '--ulimit',
133
+ 'memlock=-1',
134
+ '-v',
135
+ 'ninfer-cache:/cache',
136
+ '-v',
137
+ modelMount,
138
+ NINFER_DOCKER_IMAGE,
139
+ 'serve',
140
+ containerModelPath,
141
+ '--model-id',
142
+ artifact.modelId,
143
+ ...flags,
144
+ ...customArgs,
145
+ ],
146
+ env: {},
147
+ containerName,
148
+ modelId,
149
+ ...(modelDirectory === '' ? {} : { modelDirectory }),
150
+ port,
151
+ healthUrl: `http://127.0.0.1:${port}/health`,
152
+ };
153
+ }
154
+ const modelPath = modelDirectory === '' ? file : join(modelDirectory, file);
155
+ const customArgs = customArgFlags(config);
156
+ return {
157
+ engineId: this.id,
158
+ kind: 'process',
159
+ argv: [
160
+ 'ninfer-serve',
161
+ modelPath,
162
+ '--host',
163
+ '127.0.0.1',
164
+ '--port',
165
+ String(port),
166
+ '--model-id',
167
+ artifact.modelId,
168
+ ...flags,
169
+ ...customArgs,
170
+ ],
171
+ env: {},
172
+ modelId,
173
+ ...(modelDirectory === '' ? {} : { modelDirectory }),
174
+ port,
175
+ healthUrl: `http://127.0.0.1:${port}/health`,
176
+ };
177
+ }
178
+ async deploy(plan, platform, onProgress, options) {
179
+ if (plan.kind === 'process') {
180
+ const engineDir = platform?.engineDirectory;
181
+ let buildLogs = '';
182
+ // Auto Rebuild off (the card's checkbox): the git sync (fetch, rebase,
183
+ // rebuild) is skipped and the checkout launches as-is.
184
+ if (engineDir !== undefined && options?.autoRebuild !== false) {
185
+ // The git sync is the checkout download: the card's button reads
186
+ // "Downloading..." for it, not "Building...".
187
+ onProgress?.('download');
188
+ // The conditional rebuild fetches the checkout, prices it against the
189
+ // remote branch, and rebuilds only when it is behind (or a fresh
190
+ // clone). The decision, the build command, and its output are captured
191
+ // into buildLogs and threaded to the card's Logs section.
192
+ const sync = await syncAndRebuildEngine(this.host, {
193
+ engineId: this.id,
194
+ directory: engineDir,
195
+ ...(platform?.engineFork !== undefined ? { fork: platform.engineFork } : {}),
196
+ ...(plan.argv?.[0] !== undefined ? { binary: plan.argv[0] } : {}),
197
+ ...(options?.allowRunDeps !== undefined ? { allowRunDeps: options.allowRunDeps } : {}),
198
+ ...(platform?.buildCommands !== undefined
199
+ ? { buildCommands: platform.buildCommands }
200
+ : {}),
201
+ // Report the build phase the moment the build steps start, so the
202
+ // card's button reads "Building..." while the build is in flight.
203
+ onBuildStart: () => onProgress?.('build'),
204
+ }, () => { });
205
+ buildLogs = sync.logs;
206
+ if (!sync.ok) {
207
+ return { ok: false, detail: sync.detail ?? 'unknown', logs: buildLogs };
208
+ }
209
+ // The build output reads as a fresh Logs section: a "Building..."
210
+ // separator leads the build decision and output, the same line the
211
+ // card writes when the build step event lands.
212
+ if (sync.rebuilt && buildLogs !== '') {
213
+ buildLogs = `--- Building...\n${buildLogs}`;
214
+ }
215
+ }
216
+ const withLogs = (result) => buildLogs !== '' ? { ...result, logs: buildLogs } : result;
217
+ onProgress?.('download');
218
+ const download = await this.downloadModel(plan);
219
+ if (!download.ok)
220
+ return withLogs(download);
221
+ // A chat template the user picked as an HF repo reference (the combo
222
+ // control's known choices) is not a path the engine can read, so the
223
+ // deploy step downloads it into the model directory and rewrites the
224
+ // --chat-template flag to the local file before the spawn.
225
+ onProgress?.('download');
226
+ const templateResult = await this.resolveChatTemplate(plan);
227
+ if (!templateResult.ok)
228
+ return withLogs(templateResult);
229
+ const handle = this.host.spawn(plan.argv ?? [], plan.env ?? {}, engineDir);
230
+ trackChild(this.children, this.planKey(plan), handle);
231
+ return withLogs({ ok: true, handle });
232
+ }
233
+ if (plan.kind === 'docker') {
234
+ // The image pull is the docker build step: the card's button reads
235
+ // "Building..." for it.
236
+ onProgress?.('build');
237
+ const pull = await this.host.run(`docker pull ${NINFER_DOCKER_IMAGE}`);
238
+ if (!pull.ok) {
239
+ return { ok: false, detail: `docker pull failed: ${pull.detail ?? 'unknown'}` };
240
+ }
241
+ const handle = this.host.spawn(plan.argv ?? [], plan.env ?? {});
242
+ trackChild(this.children, this.planKey(plan), handle);
243
+ return { ok: true, handle };
244
+ }
245
+ // NInfer renders process and docker plans; a compose plan is a no-op.
246
+ return { ok: true };
247
+ }
248
+ async healthCheck(plan, options) {
249
+ return pollHealth(this.host, plan, options);
250
+ }
251
+ async stop(plan) {
252
+ if (plan.kind === 'docker' && plan.containerName !== undefined) {
253
+ await this.host.run(`docker stop ${plan.containerName}`);
254
+ }
255
+ const handle = this.children.get(this.planKey(plan));
256
+ if (handle !== undefined) {
257
+ handle.kill();
258
+ this.children.delete(this.planKey(plan));
259
+ }
260
+ }
261
+ buildMode(config) {
262
+ return config.buildMode === 'docker' ? 'docker' : 'local';
263
+ }
264
+ port(config) {
265
+ return typeof config.port === 'number' ? config.port : 18020;
266
+ }
267
+ planKey(plan) {
268
+ return `${plan.engineId}:${plan.port}`;
269
+ }
270
+ async downloadModel(plan) {
271
+ const artifact = plan.modelId !== undefined ? NINFER_MODEL_ARTIFACTS[plan.modelId] : undefined;
272
+ if (artifact === undefined)
273
+ return { ok: true };
274
+ const target = plan.modelDirectory ?? '.';
275
+ const download = await this.host.run(`hf download ${artifact.repo} ${artifact.file} --local-dir ${target}`);
276
+ if (!download.ok) {
277
+ return { ok: false, detail: `model download failed: ${download.detail ?? 'unknown'}` };
278
+ }
279
+ return { ok: true };
280
+ }
281
+ /**
282
+ * resolveChatTemplate rewrites a --chat-template flag that carries an HF repo
283
+ * reference into the local file the engine reads. A value with a slash that
284
+ * is not an absolute path (the combo control's known choices) is a repo the
285
+ * deploy step downloads into the model directory; an already-local path is
286
+ * left as-is. The download is best-effort: a template that is already on
287
+ * disk is used without a re-fetch, and a missing hf CLI leaves the flag
288
+ * untouched so the engine reports the missing template itself.
289
+ */
290
+ async resolveChatTemplate(plan) {
291
+ const argv = plan.argv;
292
+ if (argv === undefined)
293
+ return { ok: true };
294
+ const index = argv.indexOf('--chat-template');
295
+ if (index === -1)
296
+ return { ok: true };
297
+ const value = argv[index + 1];
298
+ if (value === undefined)
299
+ return { ok: true };
300
+ // An absolute path (a leading /) is already local; a value with no slash
301
+ // is a bare file name the engine resolves against its own directory.
302
+ if (value.startsWith('/') || !value.includes('/'))
303
+ return { ok: true };
304
+ // An HF repo reference: download the template file into the model
305
+ // directory and point the flag at the local copy.
306
+ const target = plan.modelDirectory ?? '.';
307
+ const localPath = `${target.endsWith('/') ? '' : `${target}/`}chat_template.jinja`;
308
+ // A template already on disk skips the re-fetch; the hf CLI is optional,
309
+ // so a download failure is reported but does not abort the launch.
310
+ const probe = await this.host.run(`[ -f ${localPath} ]`);
311
+ if (!probe.ok) {
312
+ const download = await this.host.run(`hf download ${value} chat_template.jinja --local-dir ${target}`);
313
+ if (!download.ok) {
314
+ return {
315
+ ok: false,
316
+ detail: `chat template download failed: ${download.detail ?? 'unknown'}`,
317
+ };
318
+ }
319
+ }
320
+ argv[index + 1] = localPath;
321
+ return { ok: true };
322
+ }
323
+ }
324
+ //# sourceMappingURL=ninferAdapter.js.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Strata parameter surface. The declarative `ParameterSpec` data for the
3
+ * Strata engine (https://github.com/Niko1221/Strata), sourced from the
4
+ * repository's `docs/AI_SETUP.md` (the `strata launch` flags) and
5
+ * `docs/DOCKER.md` (the container environment variables). Each spec carries
6
+ * both a `toArgv` spelling (the `strata launch` flag the binary and source
7
+ * build modes pass) and a `toEnv` spelling (the container variable the docker
8
+ * mode passes), so the one surface renders every build mode.
9
+ *
10
+ * The data is the surface; the `StrataAdapter` composes it into a `LaunchPlan`.
11
+ * Adding a flag here is a data edit, never an adapter rewire.
12
+ * @module dsh-plugin-local-infer/providers/strata
13
+ */
14
+ import type { Config, EnumOption, ParameterSpec } from 'dsh-plugin-local-infer/core';
15
+ /**
16
+ * The model families Strata serves. `qwen` is the Qwen3.8-Flash-Next family
17
+ * (the default); the others are the size-specific variants the README's
18
+ * Models section names.
19
+ */
20
+ export declare const STRATA_FAMILY_OPTIONS: readonly EnumOption[];
21
+ /**
22
+ * The picture-reader modes. `on` lets the engine pick the CPU reader under a
23
+ * 24 GB card and the GPU reader from 24 GB; `gpu` and `cpu` force a side.
24
+ */
25
+ export declare const STRATA_VISION_OPTIONS: readonly EnumOption[];
26
+ /**
27
+ * The tuning modes. `skip` is the engine default (no tuning run); `quick` is
28
+ * a one-time run of up to about 20 minutes; `thorough` is a longer run.
29
+ */
30
+ export declare const STRATA_TUNE_OPTIONS: readonly EnumOption[];
31
+ /**
32
+ * The access modes. `local` listens on 127.0.0.1 only and needs no key; every
33
+ * other mode makes a key for you, because the server is then reachable beyond
34
+ * this machine.
35
+ */
36
+ export declare const STRATA_ACCESS_OPTIONS: readonly EnumOption[];
37
+ /**
38
+ * The Strata `ParameterSpec` surface, in form order. The `group` field is the
39
+ * form section; specs without a group render under `General`. The `toArgv`
40
+ * spelling is the `strata launch` flag the binary and source-build modes pass;
41
+ * the `toEnv` spelling is the container variable the docker mode passes. A
42
+ * spec with no `toEnv` (access, dataDir) has no docker counterpart, and a spec
43
+ * with no `toArgv` (port) is spelled by the adapter from the value.
44
+ */
45
+ export declare const STRATA_PARAMETERS: readonly ParameterSpec[];
46
+ /**
47
+ * The Strata model key a config carries: the string model value, falling back
48
+ * to an empty string so a bare config renders a plan the engine sizes for the
49
+ * card (the engine picks the model when none is named). A value that names a
50
+ * local artifact file passes through unchanged.
51
+ */
52
+ export declare function strataModelKey(config: Config): string;
53
+ //# sourceMappingURL=strata.d.ts.map
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Strata parameter surface. The declarative `ParameterSpec` data for the
3
+ * Strata engine (https://github.com/Niko1221/Strata), sourced from the
4
+ * repository's `docs/AI_SETUP.md` (the `strata launch` flags) and
5
+ * `docs/DOCKER.md` (the container environment variables). Each spec carries
6
+ * both a `toArgv` spelling (the `strata launch` flag the binary and source
7
+ * build modes pass) and a `toEnv` spelling (the container variable the docker
8
+ * mode passes), so the one surface renders every build mode.
9
+ *
10
+ * The data is the surface; the `StrataAdapter` composes it into a `LaunchPlan`.
11
+ * Adding a flag here is a data edit, never an adapter rewire.
12
+ * @module dsh-plugin-local-infer/providers/strata
13
+ */
14
+ /**
15
+ * The model families Strata serves. `qwen` is the Qwen3.8-Flash-Next family
16
+ * (the default); the others are the size-specific variants the README's
17
+ * Models section names.
18
+ */
19
+ export const STRATA_FAMILY_OPTIONS = [
20
+ { value: 'qwen', label: 'qwen', note: 'the Qwen3.8-Flash-Next family; the default' },
21
+ { value: 'swift', label: 'swift', note: 'Swift 1.5; thinks shorter before it answers' },
22
+ { value: 'coder', label: 'coder', note: 'keeps the experts code uses; the 32 GB code pick' },
23
+ {
24
+ value: 'unsloth',
25
+ label: 'unsloth',
26
+ note: 'Unsloth UD-IQ4_XS / Q4_K_XL; closest to the full model',
27
+ },
28
+ ];
29
+ /**
30
+ * The picture-reader modes. `on` lets the engine pick the CPU reader under a
31
+ * 24 GB card and the GPU reader from 24 GB; `gpu` and `cpu` force a side.
32
+ */
33
+ export const STRATA_VISION_OPTIONS = [
34
+ { value: 'off', label: 'off', note: 'no picture reading' },
35
+ {
36
+ value: 'on',
37
+ label: 'on',
38
+ note: 'read pictures; the reader runs on the CPU under 24 GB, the GPU from 24 GB',
39
+ },
40
+ { value: 'gpu', label: 'gpu', note: 'force the GPU picture reader' },
41
+ { value: 'cpu', label: 'cpu', note: 'force the CPU picture reader' },
42
+ ];
43
+ /**
44
+ * The tuning modes. `skip` is the engine default (no tuning run); `quick` is
45
+ * a one-time run of up to about 20 minutes; `thorough` is a longer run.
46
+ */
47
+ export const STRATA_TUNE_OPTIONS = [
48
+ { value: 'skip', label: 'skip', note: 'no tuning; the engine default' },
49
+ { value: 'quick', label: 'quick', note: 'up to about 20 minutes, once' },
50
+ { value: 'thorough', label: 'thorough', note: 'a longer tuning run' },
51
+ ];
52
+ /**
53
+ * The access modes. `local` listens on 127.0.0.1 only and needs no key; every
54
+ * other mode makes a key for you, because the server is then reachable beyond
55
+ * this machine.
56
+ */
57
+ export const STRATA_ACCESS_OPTIONS = [
58
+ { value: 'local', label: 'local', note: 'listen on 127.0.0.1 only; no key needed' },
59
+ { value: 'lan', label: 'lan', note: 'reachable from the network; a key is made for you' },
60
+ {
61
+ value: 'cloudflare',
62
+ label: 'cloudflare',
63
+ note: 'a Cloudflare tunnel; a key is made for you',
64
+ },
65
+ { value: 'tailscale', label: 'tailscale', note: 'a Tailscale network; a key is made for you' },
66
+ ];
67
+ /**
68
+ * The Strata `ParameterSpec` surface, in form order. The `group` field is the
69
+ * form section; specs without a group render under `General`. The `toArgv`
70
+ * spelling is the `strata launch` flag the binary and source-build modes pass;
71
+ * the `toEnv` spelling is the container variable the docker mode passes. A
72
+ * spec with no `toEnv` (access, dataDir) has no docker counterpart, and a spec
73
+ * with no `toArgv` (port) is spelled by the adapter from the value.
74
+ */
75
+ export const STRATA_PARAMETERS = [
76
+ {
77
+ key: 'port',
78
+ label: 'Port',
79
+ description: 'The loopback port the engine serves its OpenAI endpoint and health check on. The registrar publishes it as the model base URL.',
80
+ // The port is a typed number, not a range strip: a 1..65535 drag slider is
81
+ // noise, so `slider: false` renders the plain number entry only.
82
+ form: { kind: 'number', min: 1, max: 65535, step: 1, slider: false },
83
+ // 8080 is the port the strata launch CLI binds by default, so the form
84
+ // seeds the value the adapter's own fallback uses when a config names no
85
+ // port.
86
+ defaultValue: 8080,
87
+ group: 'Engine',
88
+ // The port contributes no flag of its own: renderLaunch spells the local
89
+ // --port and the docker host-port mapping from this value, and the health
90
+ // URL and container name derive from it too.
91
+ },
92
+ {
93
+ key: 'family',
94
+ label: 'Model family',
95
+ description: 'The model version when a size exists in several families. qwen is the Qwen3.8-Flash-Next family; the others are the size-specific variants.',
96
+ form: { kind: 'enum', options: [...STRATA_FAMILY_OPTIONS] },
97
+ defaultValue: 'qwen',
98
+ group: 'Model',
99
+ toArgv: (value) => ['--family', String(value)],
100
+ toEnv: (value) => ['FAMILY', String(value)],
101
+ },
102
+ {
103
+ key: 'context',
104
+ label: 'Context',
105
+ description: 'How much text the model remembers at once: 32k, 64k, 128k, 256k, or a token count. Leave unset and the engine picks the largest that fits.',
106
+ form: { kind: 'text', placeholder: '128k' },
107
+ group: 'Memory',
108
+ toArgv: (value) => (value ? ['--context', String(value)] : []),
109
+ // envFromSpecs only calls toEnv when the value is set, so the pair is
110
+ // always well-formed here.
111
+ toEnv: (value) => ['CONTEXT', String(value)],
112
+ },
113
+ {
114
+ key: 'vision',
115
+ label: 'Vision input',
116
+ description: 'Whether the model reads pictures. On by default when the model can read them; the reader runs on the CPU under a 24 GB card and on the GPU from 24 GB.',
117
+ form: { kind: 'enum', options: [...STRATA_VISION_OPTIONS] },
118
+ defaultValue: 'on',
119
+ group: 'Engine',
120
+ toArgv: (value) => ['--vision', String(value)],
121
+ toEnv: (value) => ['VISION', String(value)],
122
+ },
123
+ {
124
+ key: 'parallel',
125
+ label: 'Parallel requests',
126
+ description: 'How many requests decode at once, 1 to 8. More lanes share the model and cut per-request throughput. Leave unset and the engine fits the count to the card.',
127
+ form: { kind: 'number', min: 1, max: 8, step: 1, unit: 'lanes' },
128
+ group: 'Concurrency',
129
+ toArgv: (value) => (value === undefined ? [] : ['--parallel', String(value)]),
130
+ toEnv: (value) => ['PARALLEL', String(value)],
131
+ },
132
+ {
133
+ key: 'gpu',
134
+ label: 'GPU',
135
+ description: 'Card numbers the model shares, e.g. 0 or 0,1. Empty lets the engine choose the card with the most VRAM.',
136
+ form: { kind: 'text', placeholder: '0' },
137
+ group: 'Engine',
138
+ toArgv: (value) => (value ? ['--gpu', String(value)] : []),
139
+ toEnv: (value) => ['GPU', String(value)],
140
+ },
141
+ {
142
+ key: 'tune',
143
+ label: 'Tune',
144
+ description: 'Find the fastest settings first. quick is a one-time run of up to about 20 minutes; thorough is longer. skip is the default.',
145
+ form: { kind: 'enum', options: [...STRATA_TUNE_OPTIONS] },
146
+ defaultValue: 'skip',
147
+ group: 'Engine',
148
+ toArgv: (value) => ['--tune', String(value)],
149
+ toEnv: (value) => ['TUNE', String(value)],
150
+ },
151
+ {
152
+ key: 'access',
153
+ label: 'Access',
154
+ description: 'Who may connect. local listens on 127.0.0.1 only and needs no key; beyond local the engine makes a key for you. The docker mode reaches this through the API key and the published port instead.',
155
+ form: { kind: 'enum', options: [...STRATA_ACCESS_OPTIONS] },
156
+ defaultValue: 'local',
157
+ group: 'Engine',
158
+ // local is the engine default, so the bare value spells no flag.
159
+ toArgv: (value) => (value === 'local' ? [] : ['--access', String(value)]),
160
+ },
161
+ {
162
+ key: 'apiKey',
163
+ label: 'API key',
164
+ description: 'The key clients must send when access is beyond local. Leave unset and the engine makes one and keeps it in its data volume.',
165
+ form: { kind: 'text', placeholder: 'openssl rand -hex 24' },
166
+ group: 'Engine',
167
+ toArgv: (value) => (value ? ['--api-key', String(value)] : []),
168
+ toEnv: (value) => ['API_KEY', String(value)],
169
+ },
170
+ {
171
+ key: 'modelPath',
172
+ label: 'Model path',
173
+ description: 'GGUF files you already have: a folder of shards or one .gguf file. Nothing is downloaded for the model itself when this is set.',
174
+ form: { kind: 'path' },
175
+ group: 'Artifacts',
176
+ toArgv: (value) => (value ? ['--model-path', String(value)] : []),
177
+ toEnv: (value) => ['MODEL_PATH', String(value)],
178
+ },
179
+ {
180
+ key: 'dataDir',
181
+ label: 'Data directory',
182
+ description: 'Where new model files go. Models you already have stay where they are and stay usable.',
183
+ form: { kind: 'path' },
184
+ group: 'Artifacts',
185
+ toArgv: (value) => (value ? ['--data-dir', String(value)] : []),
186
+ },
187
+ ];
188
+ /**
189
+ * The Strata model key a config carries: the string model value, falling back
190
+ * to an empty string so a bare config renders a plan the engine sizes for the
191
+ * card (the engine picks the model when none is named). A value that names a
192
+ * local artifact file passes through unchanged.
193
+ */
194
+ export function strataModelKey(config) {
195
+ return typeof config.model === 'string' ? config.model : '';
196
+ }
197
+ //# sourceMappingURL=strata.js.map
@@ -0,0 +1,98 @@
1
+ /**
2
+ * The Strata engine adapter. StrataAdapter is the Strata engine, three build
3
+ * modes. `renderLaunch` renders a `docker run` of the ghcr image (docker
4
+ * mode), a `strata launch` process (binary mode), or a `setup.sh` run with the
5
+ * model (local mode); `deploy` pulls the image, installs the Terminal, or
6
+ * git-syncs the checkout and resolves `setup.sh` to an absolute path in it
7
+ * before spawning (spawn resolves a bare name against PATH, not the cwd);
8
+ * `healthCheck` polls the health URL; `stop` stops the named container, runs
9
+ * `strata launch --stop`, or signals the tracked process. The model the
10
+ * engine serves is the config model (or the engine's own pick when none is
11
+ * named), and the engine downloads it itself, so the deploy step runs no model
12
+ * download of its own. When the config names no model, `discoverModel`
13
+ * queries the running engine's model endpoint through the terminal for the id
14
+ * it actually loaded (family and size sized to the host), so the registrar
15
+ * publishes the served model, not a placeholder.
16
+ * @module dsh-plugin-local-infer/providers/engines/strataAdapter
17
+ */
18
+ import { EngineAdapter } from '../../../core/lib/index.js';
19
+ import type { Config, DeployOptions, DeployResult, EngineLaunchSignature, EngineLaunchState, EnginePlatformConfig, HealthCheckOptions, HealthResult, HardwareProfile, LaunchPlan, LaunchProgress, LifecycleHost, ParameterSpec } from '../../../core/lib/index.js';
20
+ /**
21
+ * The Strata docker image the adapter pulls and runs. The image is the
22
+ * upstream GitHub Container Registry artifact for the newest release's CUDA 13
23
+ * flavor (NVIDIA RTX 20/30/40/50 series, driver 580 or newer); the README pins
24
+ * a version tag when updates should only land on purpose.
25
+ */
26
+ export declare const STRATA_DOCKER_IMAGE = "ghcr.io/niko1221/strata:latest-cuda13";
27
+ /**
28
+ * The one-line install the Strata binary build mode runs: it downloads the
29
+ * `strata` Terminal from the latest release, checks its SHA-256, unpacks it into
30
+ * the user's home folder, and puts `strata` on the PATH. Sourced from
31
+ * docs/AI_SETUP.md step 2 (Linux and Mac; Windows uses the PowerShell twin).
32
+ */
33
+ export declare const STRATA_BINARY_INSTALL = "curl -fsSL https://github.com/Niko1221/Strata/releases/latest/download/install.sh -o install.sh && sh install.sh";
34
+ /**
35
+ * strataPreReadyState reads the phase the strata process is in from the tail of
36
+ * its accumulated output. The Terminal downloads the engine and the model files
37
+ * before it can serve, and prints a progress line for each (Downloading,
38
+ * Unpacking, Checking the package signature, Getting the model files, ...), so
39
+ * a tail that carries one of those reads as downloading. A tail past the
40
+ * download (the engine starting, the API binding) reads as starting. The tail
41
+ * is the most recent output, so a finished download no longer reads as
42
+ * downloading even though its progress lines are still in the buffer.
43
+ */
44
+ export declare function strataPreReadyState(logs: string): Exclude<EngineLaunchState, 'ready' | 'failed'>;
45
+ /**
46
+ * strataServedModelId reads the served model id out of a /v1/models answer:
47
+ * the id of the first entry in the JSON `data` list. The engine names the
48
+ * model it auto-selected with family and size (qwen3.8-flash-next-iq3_s), so
49
+ * the registrar can publish the id the engine actually serves. A body that is
50
+ * not JSON, or carries no usable id (an error page, a truncated answer), reads
51
+ * as no discovery.
52
+ */
53
+ export declare function strataServedModelId(body: string): string | undefined;
54
+ /**
55
+ * StrataAdapter is the Strata engine, three build modes. `renderLaunch` renders
56
+ * a `docker run` of the ghcr image (docker mode), a `strata launch` process
57
+ * (binary mode), or a `setup.sh` run with the model (local mode); `deploy` pulls
58
+ * the image, installs the Terminal, or git-syncs the checkout and resolves
59
+ * `setup.sh` to an absolute path in it before spawning (spawn resolves a bare
60
+ * name against PATH, not the cwd); `healthCheck` polls the health URL; `stop`
61
+ * stops the named container, runs `strata launch --stop`, or signals the
62
+ * tracked process. The model the engine serves is the config model (or the
63
+ * engine's own pick when none is named), and the engine downloads it itself, so
64
+ * the deploy step runs no model download of its own. When the config names no
65
+ * model, `discoverModel` queries the running engine's model endpoint through
66
+ * the terminal for the id it actually loaded (family and size sized to the
67
+ * host), so the registrar publishes the served model, not a placeholder.
68
+ */
69
+ export declare class StrataAdapter extends EngineAdapter {
70
+ readonly id = "strata";
71
+ readonly supports: {
72
+ docker: boolean;
73
+ local: boolean;
74
+ binary: boolean;
75
+ };
76
+ private readonly host;
77
+ private readonly children;
78
+ constructor(host?: LifecycleHost);
79
+ parameters(): readonly ParameterSpec[];
80
+ modelRef(config: Config): {
81
+ id: string;
82
+ name: string;
83
+ };
84
+ discoverModel(config: Config): Promise<{
85
+ id: string;
86
+ name: string;
87
+ } | undefined>;
88
+ modelInput(config: Config): string[];
89
+ launchSignature(config?: Config): EngineLaunchSignature;
90
+ renderLaunch(config: Config, _hw: HardwareProfile): LaunchPlan;
91
+ deploy(plan: LaunchPlan, platform?: EnginePlatformConfig, onProgress?: LaunchProgress, options?: DeployOptions): Promise<DeployResult>;
92
+ healthCheck(plan: LaunchPlan, options?: HealthCheckOptions): Promise<HealthResult>;
93
+ stop(plan: LaunchPlan): Promise<void>;
94
+ private buildMode;
95
+ private port;
96
+ private planKey;
97
+ }
98
+ //# sourceMappingURL=strataAdapter.d.ts.map