dsh-plugin-local-infer 0.1.0 → 0.1.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.
Files changed (73) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +8 -1
  3. package/cordis.patch.yml +6 -6
  4. package/docs/screenshot-20261014.png +0 -0
  5. package/docs/zh/README.md +100 -0
  6. package/dsh/client.js +644 -143
  7. package/dsh/host.js +1 -1
  8. package/package.json +14 -11
  9. package/packages/core/lib/adapter.d.ts +75 -4
  10. package/packages/core/lib/debug.d.ts +1 -1
  11. package/packages/core/lib/debug.js +1 -1
  12. package/packages/core/lib/index.d.ts +3 -2
  13. package/packages/core/lib/index.js +2 -1
  14. package/packages/core/lib/launch-command.d.ts +13 -0
  15. package/packages/core/lib/launch-command.js +64 -0
  16. package/packages/core/lib/models.d.ts +2 -1
  17. package/packages/core/lib/models.js +10 -1
  18. package/packages/core/lib/status.d.ts +9 -1
  19. package/packages/core/lib/status.js +6 -1
  20. package/packages/core/package.json +1 -1
  21. package/packages/providers/lib/acquire.d.ts +125 -0
  22. package/packages/providers/lib/acquire.js +325 -0
  23. package/packages/providers/lib/adapters.d.ts +43 -6
  24. package/packages/providers/lib/adapters.js +386 -58
  25. package/packages/providers/lib/debug.d.ts +1 -1
  26. package/packages/providers/lib/debug.js +1 -1
  27. package/packages/providers/lib/deps.d.ts +6 -4
  28. package/packages/providers/lib/deps.js +17 -3
  29. package/packages/providers/lib/engines.d.ts +6 -5
  30. package/packages/providers/lib/engines.js +12 -4
  31. package/packages/providers/lib/guidelines.d.ts +2 -2
  32. package/packages/providers/lib/guidelines.js +17 -1
  33. package/packages/providers/lib/hyperqwen.d.ts +2 -2
  34. package/packages/providers/lib/hyperqwen.js +1 -1
  35. package/packages/providers/lib/index.d.ts +10 -4
  36. package/packages/providers/lib/index.js +9 -5
  37. package/packages/providers/lib/infernix.d.ts +170 -0
  38. package/packages/providers/lib/infernix.js +671 -0
  39. package/packages/providers/lib/llamacpp.d.ts +2 -2
  40. package/packages/providers/lib/llamacpp.js +1 -1
  41. package/packages/providers/lib/model-defaults.d.ts +7 -5
  42. package/packages/providers/lib/model-defaults.js +28 -4
  43. package/packages/providers/lib/ninfer.d.ts +9 -2
  44. package/packages/providers/lib/ninfer.js +10 -3
  45. package/packages/providers/lib/platform.d.ts +31 -0
  46. package/packages/providers/lib/platform.js +58 -0
  47. package/packages/providers/lib/presets.d.ts +2 -2
  48. package/packages/providers/lib/presets.js +1 -1
  49. package/packages/providers/lib/strata.d.ts +2 -2
  50. package/packages/providers/lib/strata.js +1 -1
  51. package/packages/providers/lib/vram.d.ts +2 -2
  52. package/packages/providers/lib/vram.js +1 -1
  53. package/packages/providers/package.json +3 -3
  54. package/packages/service/lib/index.d.ts +63 -20
  55. package/packages/service/lib/index.js +279 -43
  56. package/packages/service/lib/types.d.ts +44 -2
  57. package/packages/service/package.json +2 -2
  58. package/packages/tool/lib/index.d.ts +1 -1
  59. package/packages/tool/lib/index.js +1 -1
  60. package/packages/tool/package.json +3 -3
  61. package/packages/ui/lib/deps.d.ts +2 -2
  62. package/packages/ui/lib/deps.js +1 -1
  63. package/packages/ui/lib/form.d.ts +2 -2
  64. package/packages/ui/lib/form.js +1 -1
  65. package/packages/ui/lib/index.d.ts +1 -1
  66. package/packages/ui/lib/index.js +1 -1
  67. package/packages/ui/lib/meter.d.ts +2 -2
  68. package/packages/ui/lib/meter.js +1 -1
  69. package/packages/ui/lib/route.d.ts +84 -13
  70. package/packages/ui/lib/route.js +496 -56
  71. package/packages/ui/lib/warnings.d.ts +2 -2
  72. package/packages/ui/lib/warnings.js +1 -1
  73. package/packages/ui/package.json +5 -5
@@ -6,7 +6,7 @@
6
6
  * as authoritative. The model is pure data, so the panel (Phase 8) renders
7
7
  * it without touching the domain model, and the mapping stays unit-testable
8
8
  * here.
9
- * @module @dsh/dsh-plugin-local-infer/ui/meter
9
+ * @module dsh-plugin-local-infer/ui/meter
10
10
  */
11
11
  /**
12
12
  * renderMeter builds the render model for a VRAM estimate. The segments are
@@ -12,11 +12,11 @@
12
12
  * ~/.dsh/local-infer/config.json, shared with the CLI, so the browser never
13
13
  * sees a secret it did not store. The routes are held by an effect, so they
14
14
  * go when the plugin does.
15
- * @module @dsh/dsh-plugin-local-infer/ui/route
15
+ * @module dsh-plugin-local-infer/ui/route
16
16
  */
17
17
  import type { Context } from '@deepseek-ai/cordis';
18
- import type { Config, DefaultProvenance, HardwareProfile, InstallResult, ProviderLaunchRecord, ProviderStatus, RegisterResult, VramModel, VramVerdict } from '@dsh/dsh-plugin-local-infer/core';
19
- import type { DownloadResult, LaunchResult, LocalInferService } from '@dsh/dsh-plugin-local-infer/service';
18
+ import type { Config, DefaultProvenance, HardwareProfile, InstallResult, LaunchStep, LifecycleHost, ProviderLaunchRecord, ProviderStatus, RegisterResult, VramModel, VramVerdict } from 'dsh-plugin-local-infer/core';
19
+ import type { DownloadResult, EngineDeathEvent, LaunchResult, LocalInferService } from 'dsh-plugin-local-infer/service';
20
20
  import type { EngineInfo } from '../../providers/lib/index.js';
21
21
  import type { DepsModel } from './deps.ts';
22
22
  import type { FormModel } from './form.ts';
@@ -41,6 +41,13 @@ interface IncomingLike extends AsyncIterable<Buffer> {
41
41
  }
42
42
  interface OutgoingLike {
43
43
  writeHead(status: number, headers?: Record<string, string>): OutgoingLike;
44
+ /**
45
+ * Optional: stream one chunk of the answer, used by the Get route to
46
+ * append build output to the card's Logs section while it runs. The web
47
+ * server hands the handler a node ServerResponse; the tests' fake may
48
+ * omit it, and the route degrades to collecting only.
49
+ */
50
+ write?(chunk: string): unknown;
44
51
  end(body?: string): void;
45
52
  }
46
53
  /**
@@ -59,6 +66,8 @@ export interface LocalInferSummary {
59
66
  docker: boolean;
60
67
  local: boolean;
61
68
  };
69
+ defaultBuildCommand?: string;
70
+ defaultDockerTag?: string;
62
71
  }[];
63
72
  models: {
64
73
  id: string;
@@ -165,6 +174,8 @@ export declare function localInferConfigPath(): string;
165
174
  export interface StoredPlatformConfig {
166
175
  engineDirectory?: string;
167
176
  engineFork?: string;
177
+ buildCommands?: string;
178
+ dockerTag?: string;
168
179
  }
169
180
  /**
170
181
  * StoredProviderConfig is one saved provider model+engine config the card
@@ -205,6 +216,18 @@ export declare function readConfig(): StoredConfig;
205
216
  * configs, and the help toggle, creating the directory tree on first write.
206
217
  */
207
218
  export declare function writeConfig(engine: string, config: Config, allowRunDeps: boolean, platform?: Record<string, StoredPlatformConfig>, showHelp?: boolean, providers?: StoredProviderConfig[], logPath?: string, lastLogs?: string): void;
219
+ /**
220
+ * relinkStoredProviders prices every stored provider launch record against the
221
+ * live process table through the service's re-link rule and returns the
222
+ * provider list the card should read: an adopted engine is re-marked plugin-
223
+ * launched and tied to its model by the service, and a liveness watcher starts
224
+ * on its port so a later pkill settles the stored state through the death
225
+ * observer without another summary read; a dead engine's record is cleared on
226
+ * disk here (the previous-pid list with it), so a recycled pid cannot re-link
227
+ * to a config whose engine is down. The route calls it on mount and the
228
+ * summary calls it per read, making re-attach independent of the card opening.
229
+ */
230
+ export declare function relinkStoredProviders(localInfer: LocalInferService, stored: StoredConfig): Promise<StoredProviderConfig[]>;
208
231
  /**
209
232
  * buildSummary assembles the card's read model for one engine and config: the
210
233
  * static engine and model lists, the detected hardware, the form model the
@@ -311,25 +334,44 @@ export declare function chatTemplateDownloadFor(localInfer: LocalInferService, r
311
334
  * unsaved Engine Directory / Engine Fork edits for the engine, so a launch uses
312
335
  * them without a prior save. `providerId` names the saved provider entry the
313
336
  * launch drives, so the route persists the launch record (or clears it on a
314
- * stop) on that entry. Absent values fall back to the stored config, the
315
- * same rule the summary route applies.
337
+ * stop) on that entry. `autoRebuild` is the card's "Auto Rebuild" checkbox:
338
+ * when false, the deploy step skips the git sync (fetch, rebase, rebuild) and
339
+ * launches the checkout as-is. Absent values fall back to the stored config,
340
+ * the same rule the summary route applies.
316
341
  */
317
342
  export interface LaunchRequest {
318
343
  engine?: string;
319
344
  config?: Config;
320
345
  platform?: StoredPlatformConfig;
321
346
  providerId?: string;
347
+ autoRebuild?: boolean;
322
348
  }
323
349
  /**
324
350
  * launchEngine renders the plan the registered adapter produces for the config
325
351
  * and the detected hardware, then runs the service's launch entry point
326
352
  * (deploy, then the health poll). The detail the launch returns names the
327
- * broken step when the engine does not come up. The launch step persists the
353
+ * broken step when the engine does not come up. The launch line (the engine
354
+ * binary and its arguments) leads the run logs the card's Logs section and
355
+ * the log file carry, so a broken setup diagnoses against the exact child
356
+ * process the launch started. The launch step persists the
328
357
  * launch record (the engine pid, start time, launch arguments, and the DSH
329
358
  * process pid that launched it) on the request's provider entry, so a DSH
330
359
  * restart can re-link a surviving engine to its config.
331
360
  */
332
- export declare function launchEngine(localInfer: LocalInferService, request: LaunchRequest): Promise<LaunchResult>;
361
+ export declare function launchEngine(localInfer: LocalInferService, request: LaunchRequest, onProgress?: (step: LaunchStep) => void): Promise<LaunchResult>;
362
+ /**
363
+ * handleEngineDeath persists a provider entry's state when its engine process
364
+ * dies outside the plugin's stop path: a crash, a pkill of a plugin-launched
365
+ * child seen through the service's exit watch, or the poll-detected exit of a
366
+ * process adopted after a DSH restart. The entry whose launch record names the
367
+ * dead pid (or the dead engine-and-port, when the report carries no pid match)
368
+ * has its record cleared, so a restart never re-links a dead pid, and the exit
369
+ * line lands in the card's last-run logs beside the engine's own output. An
370
+ * event that matches no entry carrying a record (a stop the route already
371
+ * cleared, an engine the plugin never tracked) is a no-op, which keeps an
372
+ * expected stop quiet.
373
+ */
374
+ export declare function handleEngineDeath(event: EngineDeathEvent): void;
333
375
  /**
334
376
  * persistLaunchLogs stores a launch's captured output as the last run and
335
377
  * writes it to the configured log file. The log file is only written when the
@@ -346,6 +388,32 @@ export declare function persistLaunchLogs(result: LaunchResult, engineId: string
346
388
  * user just stopped.
347
389
  */
348
390
  export declare function stopEngine(localInfer: LocalInferService, request: LaunchRequest): Promise<void>;
391
+ /**
392
+ * GetRequest is the query the card sends for the Get route: the engine and
393
+ * the config the dep plan and the build mode read from, and the platform
394
+ * override (the card's unsaved Engine Directory / Engine Fork edits), the
395
+ * same rule the launch request applies. Absent values fall back to the
396
+ * stored config.
397
+ */
398
+ export interface GetRequest {
399
+ engine?: string;
400
+ config?: Config;
401
+ platform?: StoredPlatformConfig;
402
+ }
403
+ /**
404
+ * getEngine is the Get step: it syncs the engine checkout (clone the git
405
+ * repo, or the fork when the platform entry provides one; fetch and rebase
406
+ * a clean checkout; abort with a Logs alert when the checkout has local
407
+ * changes), runs the system dependency plan, and runs the engine's build
408
+ * steps. Every command and its output streams through log as it lands, so
409
+ * the card appends it to the Logs section live. The dependency install only
410
+ * runs while the Play/Run trust gate is on; with the gate off the deps are
411
+ * re-checked and a missing one aborts the step with the copy/paste note.
412
+ */
413
+ export declare function getEngine(localInfer: LocalInferService, request: GetRequest, log: (chunk: string) => void, host?: LifecycleHost): Promise<{
414
+ ok: boolean;
415
+ detail?: string;
416
+ }>;
349
417
  /**
350
418
  * RegisterRequest is the query the card sends for the register and
351
419
  * unregister routes: the engine and the config the plan renders from, and
@@ -393,14 +461,17 @@ export declare function unregisterFor(localInfer: LocalInferService, request?: R
393
461
  removed: boolean;
394
462
  }>;
395
463
  /**
396
- * registerLocalInferRoute registers the summary, save, deps, install, launch,
397
- * stop, register, and unregister routes on the web server and holds them by
398
- * an effect, so a bundle switch off removes them before the next switch on
399
- * re-registers. The scoped context carries the webServer; the localInfer
400
- * service is passed in because the scope only injects what it names.
464
+ * registerLocalInferRoute registers the summary, save, deps, install, get,
465
+ * launch, stop, register, and unregister routes on the web server and holds
466
+ * them by an effect, so a bundle switch off removes them before the next
467
+ * switch on re-registers. The scoped context carries the webServer; the
468
+ * localInfer service is passed in because the scope only injects what it
469
+ * names. The optional getHost is the lifecycle host the Get route's git and
470
+ * build steps run through; it defaults to the node host, and a test injects
471
+ * a stub so the route never clones a real repo in CI.
401
472
  */
402
473
  export declare function registerLocalInferRoute(scope: Context & {
403
474
  webServer: WebServerService;
404
- }, localInfer: LocalInferService): void;
475
+ }, localInfer: LocalInferService, getHost?: LifecycleHost): void;
405
476
  export {};
406
477
  //# sourceMappingURL=route.d.ts.map