dsh-plugin-local-infer 0.1.2 → 0.1.4
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/README.md +32 -6
- package/cordis.patch.yml +7 -0
- package/docs/zh/README.md +24 -4
- package/dsh/client.js +4200 -4049
- package/package.json +33 -11
- package/packages/core/lib/adapter.d.ts +177 -11
- package/packages/core/lib/adapter.js +74 -1
- package/packages/core/lib/config.d.ts +1 -1
- package/packages/core/lib/config.js +1 -1
- package/packages/core/lib/debug.d.ts +1 -1
- package/packages/core/lib/debug.js +1 -1
- package/packages/core/lib/defaults.d.ts +1 -1
- package/packages/core/lib/defaults.js +1 -1
- package/packages/core/lib/deps.d.ts +48 -20
- package/packages/core/lib/deps.js +24 -8
- package/packages/core/lib/estimator.d.ts +1 -1
- package/packages/core/lib/estimator.js +1 -1
- package/packages/core/lib/guideline.d.ts +1 -1
- package/packages/core/lib/guideline.js +1 -1
- package/packages/core/lib/hardware.d.ts +1 -1
- package/packages/core/lib/hardware.js +1 -1
- package/packages/core/lib/hf-cache.d.ts +70 -0
- package/packages/core/lib/hf-cache.js +83 -0
- package/packages/core/lib/index.d.ts +16 -9
- package/packages/core/lib/index.js +10 -6
- package/packages/core/lib/infer-cache.d.ts +39 -0
- package/packages/core/lib/infer-cache.js +53 -0
- package/packages/core/lib/launch-command.d.ts +8 -4
- package/packages/core/lib/launch-command.js +13 -6
- package/packages/core/lib/launch-record.d.ts +1 -1
- package/packages/core/lib/launch-record.js +1 -1
- package/packages/core/lib/logs.d.ts +8 -1
- package/packages/core/lib/logs.js +12 -4
- package/packages/core/lib/models.d.ts +120 -14
- package/packages/core/lib/models.js +209 -17
- package/packages/core/lib/parameter.d.ts +31 -3
- package/packages/core/lib/parameter.js +1 -1
- package/packages/core/lib/progress.d.ts +54 -0
- package/packages/core/lib/progress.js +120 -0
- package/packages/core/lib/registrar.d.ts +25 -14
- package/packages/core/lib/registrar.js +30 -10
- package/packages/core/lib/reserve.d.ts +11 -3
- package/packages/core/lib/reserve.js +6 -4
- package/packages/core/lib/status.d.ts +12 -6
- package/packages/core/lib/status.js +21 -10
- package/packages/core/lib/sudo.d.ts +80 -0
- package/packages/core/lib/sudo.js +78 -0
- package/packages/core/package.json +1 -1
- package/packages/orchestrator/lib/config.d.ts +63 -0
- package/packages/orchestrator/lib/config.js +111 -0
- package/packages/orchestrator/lib/index.d.ts +51 -0
- package/packages/orchestrator/lib/index.js +73 -0
- package/packages/orchestrator/lib/route.d.ts +60 -0
- package/packages/orchestrator/lib/route.js +159 -0
- package/packages/orchestrator/locale/en.json +6 -0
- package/packages/orchestrator/package.json +39 -0
- package/packages/orchestrator/prompt.md +87 -0
- package/packages/providers/lib/acquire.d.ts +95 -15
- package/packages/providers/lib/acquire.js +239 -40
- package/packages/providers/lib/adapters.d.ts +155 -221
- package/packages/providers/lib/adapters.js +589 -935
- package/packages/providers/lib/debug.d.ts +1 -1
- package/packages/providers/lib/debug.js +1 -1
- package/packages/providers/lib/deps.d.ts +31 -212
- package/packages/providers/lib/deps.js +71 -205
- package/packages/providers/lib/engines/basalt/basalt.d.ts +130 -0
- package/packages/providers/lib/engines/basalt/basalt.js +304 -0
- package/packages/providers/lib/engines/basalt/basaltAdapter.d.ts +85 -0
- package/packages/providers/lib/engines/basalt/basaltAdapter.js +439 -0
- package/packages/providers/lib/engines/basalt/basaltLinux.d.ts +23 -0
- package/packages/providers/lib/engines/basalt/basaltLinux.js +47 -0
- package/packages/providers/lib/engines/basalt/basaltMacOS.d.ts +17 -0
- package/packages/providers/lib/engines/basalt/basaltMacOS.js +19 -0
- package/packages/providers/lib/engines/basalt/basaltWindows.d.ts +24 -0
- package/packages/providers/lib/engines/basalt/basaltWindows.js +49 -0
- package/packages/providers/lib/engines/engineOs.d.ts +24 -0
- package/packages/providers/lib/engines/engineOs.js +17 -0
- package/packages/providers/lib/{hyperqwen.d.ts → engines/hyperqwen/hyperqwen.d.ts} +2 -2
- package/packages/providers/lib/{hyperqwen.js → engines/hyperqwen/hyperqwen.js} +14 -2
- package/packages/providers/lib/engines/hyperqwen/hyperqwenAdapter.d.ts +38 -0
- package/packages/providers/lib/engines/hyperqwen/hyperqwenAdapter.js +115 -0
- package/packages/providers/lib/engines/hyperqwen/hyperqwenArch.d.ts +9 -0
- package/packages/providers/lib/engines/hyperqwen/hyperqwenArch.js +9 -0
- package/packages/providers/lib/engines/hyperqwen/hyperqwenDebian.d.ts +9 -0
- package/packages/providers/lib/engines/hyperqwen/hyperqwenDebian.js +9 -0
- package/packages/providers/lib/engines/hyperqwen/hyperqwenFedora.d.ts +9 -0
- package/packages/providers/lib/engines/hyperqwen/hyperqwenFedora.js +9 -0
- package/packages/providers/lib/engines/hyperqwen/hyperqwenLinux.d.ts +10 -0
- package/packages/providers/lib/engines/hyperqwen/hyperqwenLinux.js +14 -0
- package/packages/providers/lib/engines/hyperqwen/hyperqwenMacOS.d.ts +9 -0
- package/packages/providers/lib/engines/hyperqwen/hyperqwenMacOS.js +9 -0
- package/packages/providers/lib/engines/hyperqwen/hyperqwenWindows.d.ts +9 -0
- package/packages/providers/lib/engines/hyperqwen/hyperqwenWindows.js +9 -0
- package/packages/providers/lib/{infernix.d.ts → engines/infernix/infernix.d.ts} +7 -4
- package/packages/providers/lib/{infernix.js → engines/infernix/infernix.js} +53 -8
- package/packages/providers/lib/engines/infernix/infernixAdapter.d.ts +52 -0
- package/packages/providers/lib/engines/infernix/infernixAdapter.js +235 -0
- package/packages/providers/lib/engines/infernix/infernixArch.d.ts +9 -0
- package/packages/providers/lib/engines/infernix/infernixArch.js +9 -0
- package/packages/providers/lib/engines/infernix/infernixDebian.d.ts +9 -0
- package/packages/providers/lib/engines/infernix/infernixDebian.js +9 -0
- package/packages/providers/lib/engines/infernix/infernixFedora.d.ts +9 -0
- package/packages/providers/lib/engines/infernix/infernixFedora.js +9 -0
- package/packages/providers/lib/engines/infernix/infernixLinux.d.ts +17 -0
- package/packages/providers/lib/engines/infernix/infernixLinux.js +35 -0
- package/packages/providers/lib/engines/infernix/infernixMacOS.d.ts +16 -0
- package/packages/providers/lib/engines/infernix/infernixMacOS.js +18 -0
- package/packages/providers/lib/engines/infernix/infernixWindows.d.ts +16 -0
- package/packages/providers/lib/engines/infernix/infernixWindows.js +34 -0
- package/packages/providers/lib/{llamacpp.d.ts → engines/llamacpp/llamacpp.d.ts} +2 -2
- package/packages/providers/lib/{llamacpp.js → engines/llamacpp/llamacpp.js} +12 -2
- package/packages/providers/lib/engines/llamacpp/llamacppAdapter.d.ts +50 -0
- package/packages/providers/lib/engines/llamacpp/llamacppAdapter.js +274 -0
- package/packages/providers/lib/engines/llamacpp/llamacppArch.d.ts +9 -0
- package/packages/providers/lib/engines/llamacpp/llamacppArch.js +9 -0
- package/packages/providers/lib/engines/llamacpp/llamacppDebian.d.ts +9 -0
- package/packages/providers/lib/engines/llamacpp/llamacppDebian.js +9 -0
- package/packages/providers/lib/engines/llamacpp/llamacppFedora.d.ts +9 -0
- package/packages/providers/lib/engines/llamacpp/llamacppFedora.js +9 -0
- package/packages/providers/lib/engines/llamacpp/llamacppLinux.d.ts +17 -0
- package/packages/providers/lib/engines/llamacpp/llamacppLinux.js +28 -0
- package/packages/providers/lib/engines/llamacpp/llamacppMacOS.d.ts +15 -0
- package/packages/providers/lib/engines/llamacpp/llamacppMacOS.js +17 -0
- package/packages/providers/lib/engines/llamacpp/llamacppWindows.d.ts +15 -0
- package/packages/providers/lib/engines/llamacpp/llamacppWindows.js +26 -0
- package/packages/providers/lib/{ninfer.d.ts → engines/ninfer/ninfer.d.ts} +2 -2
- package/packages/providers/lib/{ninfer.js → engines/ninfer/ninfer.js} +25 -3
- package/packages/providers/lib/engines/ninfer/ninferAdapter.d.ts +81 -0
- package/packages/providers/lib/engines/ninfer/ninferAdapter.js +392 -0
- package/packages/providers/lib/engines/ninfer/ninferArch.d.ts +9 -0
- package/packages/providers/lib/engines/ninfer/ninferArch.js +9 -0
- package/packages/providers/lib/engines/ninfer/ninferDebian.d.ts +9 -0
- package/packages/providers/lib/engines/ninfer/ninferDebian.js +9 -0
- package/packages/providers/lib/engines/ninfer/ninferFedora.d.ts +9 -0
- package/packages/providers/lib/engines/ninfer/ninferFedora.js +9 -0
- package/packages/providers/lib/engines/ninfer/ninferLinux.d.ts +17 -0
- package/packages/providers/lib/engines/ninfer/ninferLinux.js +37 -0
- package/packages/providers/lib/engines/ninfer/ninferMacOS.d.ts +15 -0
- package/packages/providers/lib/engines/ninfer/ninferMacOS.js +17 -0
- package/packages/providers/lib/engines/ninfer/ninferWindows.d.ts +29 -0
- package/packages/providers/lib/engines/ninfer/ninferWindows.js +59 -0
- package/packages/providers/lib/engines/strata/strata.d.ts +1 -0
- package/packages/providers/lib/engines/strata/strata.js +264 -0
- package/packages/providers/lib/engines/strata/strataAdapter.d.ts +97 -0
- package/packages/providers/lib/engines/strata/strataAdapter.js +463 -0
- package/packages/providers/lib/engines/strata/strataArch.d.ts +9 -0
- package/packages/providers/lib/engines/strata/strataArch.js +9 -0
- package/packages/providers/lib/engines/strata/strataDebian.d.ts +9 -0
- package/packages/providers/lib/engines/strata/strataDebian.js +9 -0
- package/packages/providers/lib/engines/strata/strataFedora.d.ts +9 -0
- package/packages/providers/lib/engines/strata/strataFedora.js +9 -0
- package/packages/providers/lib/engines/strata/strataLinux.d.ts +21 -0
- package/packages/providers/lib/engines/strata/strataLinux.js +30 -0
- package/packages/providers/lib/engines/strata/strataMacOS.d.ts +16 -0
- package/packages/providers/lib/engines/strata/strataMacOS.js +17 -0
- package/packages/providers/lib/engines/strata/strataWindows.d.ts +27 -0
- package/packages/providers/lib/engines/strata/strataWindows.js +37 -0
- package/packages/providers/lib/engines.d.ts +8 -5
- package/packages/providers/lib/engines.js +22 -11
- package/packages/providers/lib/guidelines.d.ts +5 -4
- package/packages/providers/lib/guidelines.js +18 -5
- package/packages/providers/lib/index.d.ts +33 -24
- package/packages/providers/lib/index.js +46 -24
- package/packages/providers/lib/model-defaults.d.ts +10 -5
- package/packages/providers/lib/model-defaults.js +47 -5
- package/packages/providers/lib/platform.d.ts +8 -5
- package/packages/providers/lib/platform.js +27 -7
- package/packages/providers/lib/presets.d.ts +6 -4
- package/packages/providers/lib/presets.js +53 -5
- package/packages/providers/lib/systemDeps.d.ts +313 -0
- package/packages/providers/lib/systemDeps.js +284 -0
- package/packages/providers/lib/vram.d.ts +34 -8
- package/packages/providers/lib/vram.js +81 -8
- package/packages/providers/package.json +2 -2
- package/packages/service/lib/index.d.ts +187 -23
- package/packages/service/lib/index.js +667 -90
- package/packages/service/lib/launch-target.d.ts +19 -0
- package/packages/service/lib/launch-target.js +28 -0
- package/packages/service/lib/run-logs.d.ts +72 -0
- package/packages/service/lib/run-logs.js +125 -0
- package/packages/service/lib/types.d.ts +166 -8
- package/packages/service/lib/types.js +1 -1
- package/packages/service/package.json +2 -2
- package/packages/tool/lib/index.d.ts +1 -1
- package/packages/tool/lib/index.js +1 -1
- package/packages/tool/package.json +2 -2
- package/packages/ui/lib/config.d.ts +89 -0
- package/packages/ui/lib/config.js +251 -0
- package/packages/ui/lib/deps.d.ts +4 -4
- package/packages/ui/lib/deps.js +1 -1
- package/packages/ui/lib/form.d.ts +1 -1
- package/packages/ui/lib/form.js +1 -1
- package/packages/ui/lib/index.d.ts +7 -1
- package/packages/ui/lib/index.js +12 -2
- package/packages/ui/lib/meter.d.ts +1 -1
- package/packages/ui/lib/meter.js +1 -1
- package/packages/ui/lib/ops/engine.d.ts +216 -0
- package/packages/ui/lib/ops/engine.js +697 -0
- package/packages/ui/lib/ops/get-steps.d.ts +98 -0
- package/packages/ui/lib/ops/get-steps.js +359 -0
- package/packages/ui/lib/ops/hf.d.ts +42 -0
- package/packages/ui/lib/ops/hf.js +150 -0
- package/packages/ui/lib/ops/logs.d.ts +78 -0
- package/packages/ui/lib/ops/logs.js +119 -0
- package/packages/ui/lib/ops/model.d.ts +71 -0
- package/packages/ui/lib/ops/model.js +123 -0
- package/packages/ui/lib/request.d.ts +106 -0
- package/packages/ui/lib/request.js +80 -0
- package/packages/ui/lib/route.d.ts +106 -422
- package/packages/ui/lib/route.js +136 -1845
- package/packages/ui/lib/routes/chat-template.d.ts +1 -0
- package/packages/ui/lib/routes/chat-template.js +1 -0
- package/packages/ui/lib/routes/deps.d.ts +1 -0
- package/packages/ui/lib/routes/deps.js +1 -0
- package/packages/ui/lib/routes/download.d.ts +1 -0
- package/packages/ui/lib/routes/download.js +1 -0
- package/packages/ui/lib/routes/get.d.ts +1 -0
- package/packages/ui/lib/routes/get.js +106 -0
- package/packages/ui/lib/routes/install.d.ts +16 -0
- package/packages/ui/lib/routes/install.js +36 -0
- package/packages/ui/lib/routes/launch.d.ts +24 -0
- package/packages/ui/lib/routes/launch.js +74 -0
- package/packages/ui/lib/routes/logs.d.ts +57 -0
- package/packages/ui/lib/routes/logs.js +117 -0
- package/packages/ui/lib/routes/provider-delete.d.ts +15 -0
- package/packages/ui/lib/routes/provider-delete.js +37 -0
- package/packages/ui/lib/routes/register.d.ts +16 -0
- package/packages/ui/lib/routes/register.js +28 -0
- package/packages/ui/lib/routes/save.d.ts +18 -0
- package/packages/ui/lib/routes/save.js +159 -0
- package/packages/ui/lib/routes/stop.d.ts +19 -0
- package/packages/ui/lib/routes/stop.js +32 -0
- package/packages/ui/lib/routes/stream.d.ts +40 -0
- package/packages/ui/lib/routes/stream.js +68 -0
- package/packages/ui/lib/routes/summary.d.ts +15 -0
- package/packages/ui/lib/routes/summary.js +26 -0
- package/packages/ui/lib/routes/unregister.d.ts +14 -0
- package/packages/ui/lib/routes/unregister.js +26 -0
- package/packages/ui/lib/viewmodels/deps.d.ts +1 -0
- package/packages/ui/lib/viewmodels/deps.js +1 -0
- package/packages/ui/lib/viewmodels/depsHelpers.d.ts +1 -0
- package/packages/ui/lib/viewmodels/depsHelpers.js +94 -0
- package/packages/ui/lib/viewmodels/summary.d.ts +145 -0
- package/packages/ui/lib/viewmodels/summary.js +245 -0
- package/packages/ui/lib/viewmodels/summaryHelpers.d.ts +30 -0
- package/packages/ui/lib/viewmodels/summaryHelpers.js +42 -0
- package/packages/ui/lib/warnings.d.ts +1 -1
- package/packages/ui/lib/warnings.js +1 -1
- package/packages/ui/package.json +4 -4
- package/packages/providers/lib/strata.d.ts +0 -15
- package/packages/providers/lib/strata.js +0 -14
|
@@ -12,27 +12,38 @@
|
|
|
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
|
+
*
|
|
16
|
+
* This module holds the HTTP plumbing every route builds on: the RouteError
|
|
17
|
+
* the domain operations throw with their own status, the RouteResponder the
|
|
18
|
+
* handlers answer through, and defineRoute, the template method that guards
|
|
19
|
+
* the method (405), reads the bounded body (413), and maps the handler's
|
|
20
|
+
* answer to a status. The request parsing lives in ./request.ts, the stored-
|
|
21
|
+
* config persistence in ./config.ts, the view models in ./viewmodels/, the
|
|
22
|
+
* operations in ./ops/, and each route definition in its own file under
|
|
23
|
+
* ./routes/. registerLocalInferRoute wires them onto the web server.
|
|
15
24
|
* @module dsh-plugin-local-infer/ui/route
|
|
16
25
|
*/
|
|
17
26
|
import type { Context } from '@deepseek-ai/cordis';
|
|
18
|
-
import type {
|
|
19
|
-
import type {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
import type { LifecycleHost } from 'dsh-plugin-local-infer/core';
|
|
28
|
+
import type { LocalInferService } from 'dsh-plugin-local-infer/service';
|
|
29
|
+
/**
|
|
30
|
+
* LocalInferRoute is one webServer route definition the register step holds
|
|
31
|
+
* by an effect: the stable name, the exact-match path, and the handler the
|
|
32
|
+
* web server invokes per request. The route files under ./routes/ each build
|
|
33
|
+
* one of these through defineRoute.
|
|
34
|
+
*/
|
|
35
|
+
export interface LocalInferRoute {
|
|
36
|
+
name: string;
|
|
37
|
+
kind: 'exact';
|
|
38
|
+
path: string;
|
|
39
|
+
handler: (req: IncomingLike, res: OutgoingLike) => void | Promise<void>;
|
|
40
|
+
}
|
|
25
41
|
/**
|
|
26
42
|
* The webServer service is dsh-specific and absent from the cordis Context
|
|
27
43
|
* type, so the route narrows the scoped context to the two members it needs.
|
|
28
44
|
*/
|
|
29
45
|
export interface WebServerService {
|
|
30
|
-
register(route:
|
|
31
|
-
name: string;
|
|
32
|
-
kind: 'exact';
|
|
33
|
-
path: string;
|
|
34
|
-
handler: (req: IncomingLike, res: OutgoingLike) => void | Promise<void>;
|
|
35
|
-
}): () => void;
|
|
46
|
+
register(route: LocalInferRoute): () => void;
|
|
36
47
|
}
|
|
37
48
|
interface IncomingLike extends AsyncIterable<Buffer> {
|
|
38
49
|
method: string;
|
|
@@ -49,198 +60,15 @@ interface OutgoingLike {
|
|
|
49
60
|
*/
|
|
50
61
|
write?(chunk: string): unknown;
|
|
51
62
|
end(body?: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* Optional: watch the response for the client disconnecting (the node
|
|
65
|
+
* ServerResponse's 'close' before the route ends), so a stream route can
|
|
66
|
+
* abort the in-flight run when the card cancels it. The web server hands
|
|
67
|
+
* the handler a node ServerResponse; the tests' fake may omit it, and the
|
|
68
|
+
* route degrades to no abort.
|
|
69
|
+
*/
|
|
70
|
+
on?(event: string, listener: (...args: unknown[]) => void): unknown;
|
|
52
71
|
}
|
|
53
|
-
/**
|
|
54
|
-
* LocalInferSummary is the JSON the card renders: the engine list, the model
|
|
55
|
-
* list, the detected hardware, the form model for the selected engine, the
|
|
56
|
-
* meter model for the current config, the verdict the banner renders, the
|
|
57
|
-
* guideline warning model the red banner and inline warnings render from,
|
|
58
|
-
* and the config the form edits. Every field is plain data, so it crosses
|
|
59
|
-
* the socket without a function left behind.
|
|
60
|
-
*/
|
|
61
|
-
export interface LocalInferSummary {
|
|
62
|
-
engines: {
|
|
63
|
-
id: string;
|
|
64
|
-
label: string;
|
|
65
|
-
supports: {
|
|
66
|
-
docker: boolean;
|
|
67
|
-
local: boolean;
|
|
68
|
-
};
|
|
69
|
-
defaultBuildCommand?: string;
|
|
70
|
-
defaultDockerTag?: string;
|
|
71
|
-
}[];
|
|
72
|
-
models: {
|
|
73
|
-
id: string;
|
|
74
|
-
source: string;
|
|
75
|
-
}[];
|
|
76
|
-
hardware: HardwareProfile;
|
|
77
|
-
engineId: string;
|
|
78
|
-
formModel: FormModel;
|
|
79
|
-
meterModel: MeterModel;
|
|
80
|
-
verdict: VramVerdict;
|
|
81
|
-
warningsModel: WarningsModel;
|
|
82
|
-
config: Config;
|
|
83
|
-
platformConfigs: Record<string, StoredPlatformConfig>;
|
|
84
|
-
defaults: DefaultsModel;
|
|
85
|
-
modelDirectory: string;
|
|
86
|
-
modelDefaults: ModelDefaultModel[];
|
|
87
|
-
modelStatus: ModelStatusModel | null;
|
|
88
|
-
chatTemplateStatus: ChatTemplateStatusModel | null;
|
|
89
|
-
modelFiles: string[];
|
|
90
|
-
showHelp: boolean;
|
|
91
|
-
providers: ProviderSummaryEntry[];
|
|
92
|
-
logPath: string;
|
|
93
|
-
lastLogs: string;
|
|
94
|
-
unsureBanner: {
|
|
95
|
-
message: string;
|
|
96
|
-
killCommands: string[];
|
|
97
|
-
} | null;
|
|
98
|
-
registered: boolean;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* ProviderSummaryEntry is the card-facing view of one saved provider config:
|
|
102
|
-
* the stable id the card edits and deletes against, the engine and model the
|
|
103
|
-
* title renders ("NInfer: <model>"), the running-state the status dot paints,
|
|
104
|
-
* and the full config and platform the expanded form draws from.
|
|
105
|
-
*/
|
|
106
|
-
export interface ProviderSummaryEntry {
|
|
107
|
-
id: string;
|
|
108
|
-
engine: string;
|
|
109
|
-
model: string;
|
|
110
|
-
status: ProviderStatus;
|
|
111
|
-
config: Config;
|
|
112
|
-
platform: StoredPlatformConfig;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* ModelDefaultModel is the card-facing view of one default model entry: the
|
|
116
|
-
* registry key the config `model` field carries, the label the dropdown
|
|
117
|
-
* shows, and the Hugging Face URL the no-CLI row links to.
|
|
118
|
-
*/
|
|
119
|
-
export interface ModelDefaultModel {
|
|
120
|
-
id: string;
|
|
121
|
-
label: string;
|
|
122
|
-
url: string;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* ModelStatusModel is the model-status read model the card draws: whether the
|
|
126
|
-
* model is present in the model directory, whether the hf CLI is available,
|
|
127
|
-
* and the download command the Download button runs. The card shows the row
|
|
128
|
-
* only while the model is absent.
|
|
129
|
-
*/
|
|
130
|
-
export interface ModelStatusModel {
|
|
131
|
-
modelId: string;
|
|
132
|
-
label: string;
|
|
133
|
-
url: string;
|
|
134
|
-
present: boolean;
|
|
135
|
-
hfCli: boolean;
|
|
136
|
-
downloadCommand: string;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* ChatTemplateStatusModel is the answer to "is the selected chat template in
|
|
140
|
-
* the model directory": the repo reference, its display label, whether the
|
|
141
|
-
* template file is present, whether the hf CLI is available, and the download
|
|
142
|
-
* command the card runs (and the System dependencies box shows when the auto-
|
|
143
|
-
* download is unavailable).
|
|
144
|
-
*/
|
|
145
|
-
export interface ChatTemplateStatusModel {
|
|
146
|
-
repo: string;
|
|
147
|
-
label: string;
|
|
148
|
-
present: boolean;
|
|
149
|
-
hfCli: boolean;
|
|
150
|
-
downloadCommand: string;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* DefaultsModel is the resolved-defaults read model the card draws: the
|
|
154
|
-
* starting config the defaults resolver produced and the per-key provenance
|
|
155
|
-
* that names the source that supplied each value (a preset, the user, or a
|
|
156
|
-
* spec default).
|
|
157
|
-
*/
|
|
158
|
-
export interface DefaultsModel {
|
|
159
|
-
config: Config;
|
|
160
|
-
provenance: DefaultProvenance[];
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* The config file the route owns. It sits under the dsh home so a web user and
|
|
164
|
-
* a CLI user share one file, the way modsearch shares ~/.modsearch.
|
|
165
|
-
*/
|
|
166
|
-
export declare function localInferConfigPath(): string;
|
|
167
|
-
/**
|
|
168
|
-
* StoredPlatformConfig is the per-engine platform config the deploy step
|
|
169
|
-
* consumes (§3.10): where the engine platform lives locally and the git repo
|
|
170
|
-
* that overrides the engine's default upstream. The map is keyed by engine id,
|
|
171
|
-
* so the stored entry carries no id of its own; the route adds it when it
|
|
172
|
-
* builds the EnginePlatformConfig the service registry stores.
|
|
173
|
-
*/
|
|
174
|
-
export interface StoredPlatformConfig {
|
|
175
|
-
engineDirectory?: string;
|
|
176
|
-
engineFork?: string;
|
|
177
|
-
buildCommands?: string;
|
|
178
|
-
dockerTag?: string;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* StoredProviderConfig is one saved provider model+engine config the card
|
|
182
|
-
* lists: a stable id the card edits and deletes against, the engine and the
|
|
183
|
-
* full parameter config it serves, the per-engine platform config the deploy
|
|
184
|
-
* step consumes, and the launch record the launch step persists when it
|
|
185
|
-
* starts the entry's engine (the engine pid, start time, launch arguments,
|
|
186
|
-
* and the DSH process pid that launched it). The record is what a DSH
|
|
187
|
-
* restart re-links a surviving engine to its config; a stop clears it.
|
|
188
|
-
*/
|
|
189
|
-
export interface StoredProviderConfig {
|
|
190
|
-
id: string;
|
|
191
|
-
engine: string;
|
|
192
|
-
config: Config;
|
|
193
|
-
platform: StoredPlatformConfig;
|
|
194
|
-
launch?: ProviderLaunchRecord;
|
|
195
|
-
}
|
|
196
|
-
export interface StoredConfig {
|
|
197
|
-
engine: string;
|
|
198
|
-
config: Config;
|
|
199
|
-
allowRunDeps: boolean;
|
|
200
|
-
platform: Record<string, StoredPlatformConfig>;
|
|
201
|
-
showHelp: boolean;
|
|
202
|
-
providers: StoredProviderConfig[];
|
|
203
|
-
logPath: string;
|
|
204
|
-
lastLogs: string;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* readConfig reads the stored engine, config, trust gate, and per-engine
|
|
208
|
-
* platform configs. A missing or broken file reads as the scaffold default
|
|
209
|
-
* (NInfer, empty config, gate off, no platform configs) so the card always has
|
|
210
|
-
* a form to draw. A platform entry that is not an object (or whose fields are
|
|
211
|
-
* not strings) is dropped, so a by-hand edit never poisons the deploy step.
|
|
212
|
-
*/
|
|
213
|
-
export declare function readConfig(): StoredConfig;
|
|
214
|
-
/**
|
|
215
|
-
* writeConfig persists the engine, config, trust gate, per-engine platform
|
|
216
|
-
* configs, and the help toggle, creating the directory tree on first write.
|
|
217
|
-
*/
|
|
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[]>;
|
|
231
|
-
/**
|
|
232
|
-
* buildSummary assembles the card's read model for one engine and config: the
|
|
233
|
-
* static engine and model lists, the detected hardware, the form model the
|
|
234
|
-
* selected engine's parameter surface renders to, the meter model the
|
|
235
|
-
* service's estimate prices, and the warning model the service's guideline
|
|
236
|
-
* engine fires. The estimate is the single source the meter and the verdict
|
|
237
|
-
* banner agree on, and the guideline results are the single source the red
|
|
238
|
-
* banner and the inline warnings agree on.
|
|
239
|
-
*/
|
|
240
|
-
export declare function buildSummary(localInfer: LocalInferService, request?: {
|
|
241
|
-
engine?: string;
|
|
242
|
-
config?: Config;
|
|
243
|
-
}): Promise<LocalInferSummary>;
|
|
244
72
|
/**
|
|
245
73
|
* RouteError is a route failure that carries its own HTTP status, so the
|
|
246
74
|
* handlers map the domain answer (a gate that is off, an unsupported build
|
|
@@ -251,227 +79,83 @@ export declare class RouteError extends Error {
|
|
|
251
79
|
constructor(status: number, message: string);
|
|
252
80
|
}
|
|
253
81
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
*/
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
|
|
279
|
-
* refreshed deps model, so the card re-renders the gate from the same
|
|
280
|
-
* re-check the install ran.
|
|
281
|
-
*/
|
|
282
|
-
export interface InstallResponse {
|
|
283
|
-
result: InstallResult;
|
|
284
|
-
deps: DepsModel;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* runInstallFor is the Play/Run path: it refuses with a 409 while the
|
|
288
|
-
* trust gate is off (the copy/paste path is always the fallback), runs the
|
|
289
|
-
* install through the service, and refreshes the deps model from the
|
|
290
|
-
* re-check, so the "Get" gate opens only after a re-check passes.
|
|
291
|
-
*/
|
|
292
|
-
export declare function runInstallFor(localInfer: LocalInferService, request: DepsRequest): Promise<InstallResponse>;
|
|
293
|
-
/**
|
|
294
|
-
* DownloadRequest is the query the card sends for the download route: the
|
|
295
|
-
* engine, model, and directory the hf CLI download targets. Absent values
|
|
296
|
-
* fall back to the stored config, the same rule the summary route applies.
|
|
297
|
-
*/
|
|
298
|
-
export interface DownloadRequest {
|
|
299
|
-
engine?: string;
|
|
300
|
-
model?: string;
|
|
301
|
-
directory?: string;
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* downloadFor runs the hf CLI download for the request's default model: it
|
|
305
|
-
* resolves the entry through the providers' default list (a 404 when no
|
|
306
|
-
* entry names the pair), resolves the directory against the request, the
|
|
307
|
-
* stored config, and the plugin's default model directory in that order, and
|
|
308
|
-
* runs the download through the service.
|
|
309
|
-
*/
|
|
310
|
-
export declare function downloadFor(localInfer: LocalInferService, request: DownloadRequest): Promise<DownloadResult>;
|
|
311
|
-
/**
|
|
312
|
-
* ChatTemplateDownloadRequest is the query the card sends for the chat-template
|
|
313
|
-
* download route: the engine, the template repo reference, and the directory
|
|
314
|
-
* the hf CLI targets. Absent values fall back to the stored config, the same
|
|
315
|
-
* rule the summary route applies.
|
|
316
|
-
*/
|
|
317
|
-
export interface ChatTemplateDownloadRequest {
|
|
318
|
-
engine?: string;
|
|
319
|
-
template?: string;
|
|
320
|
-
directory?: string;
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* chatTemplateDownloadFor runs the hf CLI download for the request's chat
|
|
324
|
-
* template: it resolves the template repo reference from the request or the
|
|
325
|
-
* stored config's chatTemplate (a 400 when neither names an HF repo
|
|
326
|
-
* reference), resolves the directory against the request, the stored config,
|
|
327
|
-
* and the plugin's default model directory in that order, and runs the
|
|
328
|
-
* download through the service.
|
|
329
|
-
*/
|
|
330
|
-
export declare function chatTemplateDownloadFor(localInfer: LocalInferService, request: ChatTemplateDownloadRequest): Promise<DownloadResult>;
|
|
331
|
-
/**
|
|
332
|
-
* LaunchRequest is the query the card sends for the launch and stop routes: the
|
|
333
|
-
* engine and the config the plan renders from. `platform` carries the card's
|
|
334
|
-
* unsaved Engine Directory / Engine Fork edits for the engine, so a launch uses
|
|
335
|
-
* them without a prior save. `providerId` names the saved provider entry the
|
|
336
|
-
* launch drives, so the route persists the launch record (or clears it on a
|
|
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.
|
|
341
|
-
*/
|
|
342
|
-
export interface LaunchRequest {
|
|
343
|
-
engine?: string;
|
|
344
|
-
config?: Config;
|
|
345
|
-
platform?: StoredPlatformConfig;
|
|
346
|
-
providerId?: string;
|
|
347
|
-
autoRebuild?: boolean;
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* launchEngine renders the plan the registered adapter produces for the config
|
|
351
|
-
* and the detected hardware, then runs the service's launch entry point
|
|
352
|
-
* (deploy, then the health poll). The detail the launch returns names 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
|
|
357
|
-
* launch record (the engine pid, start time, launch arguments, and the DSH
|
|
358
|
-
* process pid that launched it) on the request's provider entry, so a DSH
|
|
359
|
-
* restart can re-link a surviving engine to its config.
|
|
360
|
-
*/
|
|
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;
|
|
375
|
-
/**
|
|
376
|
-
* persistLaunchLogs stores a launch's captured output as the last run and
|
|
377
|
-
* writes it to the configured log file. The log file is only written when the
|
|
378
|
-
* run produced output and the log location is set; the last-run logs are always
|
|
379
|
-
* persisted (an empty string clears a stale run) so the card's Logs section
|
|
380
|
-
* shows the previous run after a reload.
|
|
381
|
-
*/
|
|
382
|
-
export declare function persistLaunchLogs(result: LaunchResult, engineId: string, config: Config): void;
|
|
383
|
-
/**
|
|
384
|
-
* stopEngine renders the same plan and runs the service's stop entry point, so
|
|
385
|
-
* the stop step targets the exact container or process the launch started. The
|
|
386
|
-
* stop then clears the target entry's launch record (the engine pid and the
|
|
387
|
-
* previous-pid list with it), so a recycled pid cannot re-link an engine the
|
|
388
|
-
* user just stopped.
|
|
389
|
-
*/
|
|
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
|
-
}>;
|
|
417
|
-
/**
|
|
418
|
-
* RegisterRequest is the query the card sends for the register and
|
|
419
|
-
* unregister routes: the engine and the config the plan renders from, and
|
|
420
|
-
* agentDefault, which points the agent default model at the registered
|
|
421
|
-
* engine. Absent values fall back to the stored config, the same rule the
|
|
422
|
-
* summary route applies.
|
|
423
|
-
*/
|
|
424
|
-
export interface RegisterRequest {
|
|
425
|
-
engine?: string;
|
|
426
|
-
config?: Config;
|
|
427
|
-
agentDefault?: boolean;
|
|
82
|
+
* RouteResponder is the answer side of a route: the JSON writer every route
|
|
83
|
+
* answers through, the stream openers the Get and launch routes use for live
|
|
84
|
+
* output, and the chunk writer a fake response may omit (the route then
|
|
85
|
+
* degrades to collecting only).
|
|
86
|
+
*/
|
|
87
|
+
export declare class RouteResponder {
|
|
88
|
+
private readonly res;
|
|
89
|
+
constructor(res: OutgoingLike);
|
|
90
|
+
/** Write a JSON answer: the status and content-type head, then the body. */
|
|
91
|
+
json(status: number, body: unknown): void;
|
|
92
|
+
/** Open a plain-text stream (the Get route's live log output). */
|
|
93
|
+
textStream(): void;
|
|
94
|
+
/** Open an NDJSON stream (the launch route's progress events). */
|
|
95
|
+
ndjsonStream(): void;
|
|
96
|
+
/** Stream one chunk; a fake response without write() collects nothing. */
|
|
97
|
+
write(chunk: string): void;
|
|
98
|
+
/**
|
|
99
|
+
* Watch the response's client disconnect (the node 'close' before the
|
|
100
|
+
* route ends): the listener fires once when the card's Cancel closes the
|
|
101
|
+
* stream, so the route aborts the in-flight run. A fake response without
|
|
102
|
+
* on() never fires it, and the run degrades to running to completion.
|
|
103
|
+
*/
|
|
104
|
+
onClose(listener: () => void): void;
|
|
105
|
+
/** End the response, optionally with a final body chunk. */
|
|
106
|
+
end(body?: string): void;
|
|
428
107
|
}
|
|
429
108
|
/**
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
109
|
+
* RouteInput is what a route handler receives: the parsed URL (the query
|
|
110
|
+
* params the GET routes read) and, for POST routes, the bounded JSON body.
|
|
111
|
+
*/
|
|
112
|
+
export interface RouteInput {
|
|
113
|
+
url: URL;
|
|
114
|
+
body: Record<string, unknown>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* RouteSpec is a route definition the register step holds by an effect: the
|
|
118
|
+
* stable name, the exact-match path, the method guard, the status an
|
|
119
|
+
* unexpected handler failure answers with, and the handler. The object
|
|
120
|
+
* literal union keeps the invariant the guard enforces: only a POST spec
|
|
121
|
+
* carries a 413 message, because only a POST spec reads a body.
|
|
122
|
+
*/
|
|
123
|
+
export type RouteSpec = {
|
|
124
|
+
name: string;
|
|
125
|
+
path: string;
|
|
126
|
+
method: 'GET';
|
|
127
|
+
failStatus: number;
|
|
128
|
+
run(input: RouteInput, res: RouteResponder): Promise<void>;
|
|
129
|
+
} | {
|
|
130
|
+
name: string;
|
|
131
|
+
path: string;
|
|
132
|
+
method: 'POST';
|
|
133
|
+
failStatus: number;
|
|
134
|
+
tooLargeMessage: string;
|
|
135
|
+
run(input: RouteInput, res: RouteResponder): Promise<void>;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* defineRoute is the template every route file builds on: it guards the
|
|
139
|
+
* method (405), reads the bounded body (413, POST only), and maps the
|
|
140
|
+
* handler's answer to a status: a RouteError carries its own status, any
|
|
141
|
+
* other failure answers with the spec's failStatus. The route files carry
|
|
142
|
+
* only the handler body.
|
|
143
|
+
*/
|
|
144
|
+
export declare function defineRoute(spec: RouteSpec): LocalInferRoute;
|
|
145
|
+
/**
|
|
146
|
+
* registerLocalInferRoute registers the summary, save, provider-delete, deps,
|
|
147
|
+
* install, download, chat-template, get, launch, stop, logs, register, and
|
|
148
|
+
* unregister routes on the web server and holds them by an effect, so a
|
|
149
|
+
* bundle switch off removes them before the next switch on re-registers. The
|
|
150
|
+
* scoped context carries the webServer; the localInfer service is passed in
|
|
151
|
+
* because the scope only injects what it names. The optional getHost is the
|
|
152
|
+
* lifecycle host the Get route's git and build steps run through, and the
|
|
153
|
+
* optional launchHost the launch route's Get steps run through; both default
|
|
154
|
+
* to the node host, and a test injects a stub so the routes never clone a
|
|
155
|
+
* real repo in CI.
|
|
472
156
|
*/
|
|
473
157
|
export declare function registerLocalInferRoute(scope: Context & {
|
|
474
158
|
webServer: WebServerService;
|
|
475
|
-
}, localInfer: LocalInferService, getHost?: LifecycleHost): void;
|
|
159
|
+
}, localInfer: LocalInferService, getHost?: LifecycleHost, launchHost?: LifecycleHost): void;
|
|
476
160
|
export {};
|
|
477
|
-
//# sourceMappingURL=route.d.ts.map
|
|
161
|
+
//# sourceMappingURL=route.d.ts.map
|