dsh-plugin-local-infer 0.1.3 → 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 +22 -4
- package/cordis.patch.yml +7 -0
- package/docs/zh/README.md +14 -2
- package/dsh/client.js +4195 -4522
- package/package.json +28 -11
- package/packages/core/lib/adapter.d.ts +133 -9
- 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 +44 -17
- 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 +20 -9
- package/packages/core/lib/registrar.js +27 -7
- 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 +92 -14
- package/packages/providers/lib/acquire.js +215 -37
- package/packages/providers/lib/adapters.d.ts +136 -12
- package/packages/providers/lib/adapters.js +597 -70
- package/packages/providers/lib/debug.d.ts +1 -1
- package/packages/providers/lib/debug.js +1 -1
- package/packages/providers/lib/deps.d.ts +27 -230
- package/packages/providers/lib/deps.js +61 -214
- 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/engines/{hyperqwen.d.ts → hyperqwen/hyperqwen.d.ts} +2 -2
- package/packages/providers/lib/engines/{hyperqwen.js → hyperqwen/hyperqwen.js} +14 -2
- package/packages/providers/lib/engines/{hyperqwenAdapter.d.ts → hyperqwen/hyperqwenAdapter.d.ts} +6 -6
- package/packages/providers/lib/engines/{hyperqwenAdapter.js → hyperqwen/hyperqwenAdapter.js} +24 -14
- 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/engines/{infernix.d.ts → infernix/infernix.d.ts} +7 -4
- package/packages/providers/lib/engines/{infernix.js → infernix/infernix.js} +52 -7
- package/packages/providers/lib/engines/{infernixAdapter.d.ts → infernix/infernixAdapter.d.ts} +5 -6
- package/packages/providers/lib/engines/{infernixAdapter.js → infernix/infernixAdapter.js} +75 -42
- 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/engines/{llamacpp.d.ts → llamacpp/llamacpp.d.ts} +2 -2
- package/packages/providers/lib/engines/{llamacpp.js → llamacpp/llamacpp.js} +12 -2
- package/packages/providers/lib/engines/{llamacppAdapter.d.ts → llamacpp/llamacppAdapter.d.ts} +5 -6
- package/packages/providers/lib/engines/{llamacppAdapter.js → llamacpp/llamacppAdapter.js} +87 -45
- 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/engines/{ninfer.d.ts → ninfer/ninfer.d.ts} +2 -2
- package/packages/providers/lib/engines/{ninfer.js → ninfer/ninfer.js} +24 -2
- package/packages/providers/lib/engines/{ninferAdapter.d.ts → ninfer/ninferAdapter.d.ts} +5 -6
- package/packages/providers/lib/engines/{ninferAdapter.js → ninfer/ninferAdapter.js} +123 -55
- 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.js → strata/strata.js} +70 -3
- package/packages/providers/lib/engines/{strataAdapter.d.ts → strata/strataAdapter.d.ts} +5 -6
- package/packages/providers/lib/engines/{strataAdapter.js → strata/strataAdapter.js} +147 -111
- 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 +7 -5
- package/packages/providers/lib/engines.js +21 -10
- 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 -29
- package/packages/providers/lib/index.js +45 -33
- package/packages/providers/lib/model-defaults.d.ts +5 -1
- package/packages/providers/lib/model-defaults.js +25 -1
- package/packages/providers/lib/platform.d.ts +8 -5
- package/packages/providers/lib/platform.js +23 -9
- 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 +176 -21
- package/packages/service/lib/index.js +589 -86
- 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 +163 -6
- 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 +12 -2
- package/packages/ui/lib/config.js +18 -2
- package/packages/ui/lib/deps.d.ts +1 -1
- 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 +142 -34
- package/packages/ui/lib/ops/engine.js +469 -265
- 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 +26 -11
- package/packages/ui/lib/ops/hf.js +115 -25
- package/packages/ui/lib/ops/logs.d.ts +70 -15
- package/packages/ui/lib/ops/logs.js +96 -35
- package/packages/ui/lib/ops/model.d.ts +2 -10
- package/packages/ui/lib/ops/model.js +9 -16
- package/packages/ui/lib/request.d.ts +1 -1
- package/packages/ui/lib/request.js +1 -1
- package/packages/ui/lib/route.d.ts +22 -6
- package/packages/ui/lib/route.js +32 -9
- package/packages/ui/lib/routes/chat-template.d.ts +1 -14
- package/packages/ui/lib/routes/chat-template.js +1 -37
- package/packages/ui/lib/routes/deps.d.ts +1 -16
- package/packages/ui/lib/routes/deps.js +1 -27
- package/packages/ui/lib/routes/download.d.ts +1 -16
- package/packages/ui/lib/routes/download.js +1 -48
- package/packages/ui/lib/routes/get.d.ts +1 -18
- package/packages/ui/lib/routes/get.js +66 -17
- package/packages/ui/lib/routes/install.d.ts +1 -1
- package/packages/ui/lib/routes/install.js +1 -1
- package/packages/ui/lib/routes/launch.d.ts +13 -7
- package/packages/ui/lib/routes/launch.js +33 -9
- 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 +1 -1
- package/packages/ui/lib/routes/provider-delete.js +1 -1
- package/packages/ui/lib/routes/register.d.ts +1 -1
- package/packages/ui/lib/routes/register.js +1 -1
- package/packages/ui/lib/routes/save.d.ts +1 -1
- package/packages/ui/lib/routes/save.js +22 -2
- package/packages/ui/lib/routes/stop.d.ts +7 -4
- package/packages/ui/lib/routes/stop.js +7 -4
- 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 +1 -1
- package/packages/ui/lib/routes/summary.js +1 -1
- package/packages/ui/lib/routes/unregister.d.ts +1 -1
- package/packages/ui/lib/routes/unregister.js +1 -1
- package/packages/ui/lib/viewmodels/deps.d.ts +1 -31
- package/packages/ui/lib/viewmodels/deps.js +1 -89
- package/packages/ui/lib/viewmodels/depsHelpers.d.ts +1 -28
- package/packages/ui/lib/viewmodels/depsHelpers.js +72 -11
- package/packages/ui/lib/viewmodels/summary.d.ts +7 -2
- package/packages/ui/lib/viewmodels/summary.js +55 -35
- package/packages/ui/lib/viewmodels/summaryHelpers.d.ts +1 -1
- package/packages/ui/lib/viewmodels/summaryHelpers.js +1 -1
- 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/engines/strata.d.ts +0 -53
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Orchestrator settings routes the Web card talks to: GET
|
|
3
|
+
* /local-infer/orchestrator answers { prompt, defaultPrompt, saved } (the
|
|
4
|
+
* effective prompt, the shipped prompt.md default, and whether the effective
|
|
5
|
+
* prompt is a saved value), and POST /local-infer/orchestrator/save persists
|
|
6
|
+
* { prompt } through the config setter (an empty string clears the saved
|
|
7
|
+
* override back to the default) and answers with the same payload. The routes
|
|
8
|
+
* are held by an effect, so they go when the component does.
|
|
9
|
+
*
|
|
10
|
+
* The HTTP plumbing is a minimal local mirror of the ui package's defineRoute
|
|
11
|
+
* template (method guard 405, bounded body 413, JSON answer). The ui package
|
|
12
|
+
* does export its template, but this package deliberately keeps no dependency
|
|
13
|
+
* on ui: importing ui's route module would load its whole route graph (the
|
|
14
|
+
* service, providers, and core packages) into a component that ships disabled
|
|
15
|
+
* and must stay loadable headless, so the shared shape is copied rather than
|
|
16
|
+
* imported, and the two copies change together by hand. The stream helpers
|
|
17
|
+
* the ui template carries are dropped; these two routes only ever answer with
|
|
18
|
+
* one JSON body.
|
|
19
|
+
* @module dsh-plugin-local-infer/orchestrator/route
|
|
20
|
+
*/
|
|
21
|
+
import { defaultOrchestratorPrompt, getOrchestratorPrompt, hasSavedOrchestratorPrompt, setOrchestratorPrompt, } from './config.js';
|
|
22
|
+
/**
|
|
23
|
+
* RouteError is a route failure that carries its own HTTP status, so a
|
|
24
|
+
* handler can answer a validation rejection with its own code instead of the
|
|
25
|
+
* spec's failStatus.
|
|
26
|
+
*/
|
|
27
|
+
class RouteError extends Error {
|
|
28
|
+
status;
|
|
29
|
+
constructor(status, message) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.name = 'RouteError';
|
|
32
|
+
this.status = status;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The request body size cap the save route enforces: a prompt is a few
|
|
37
|
+
* kilobytes at most, so a body past 64 KiB is a client bug, not a prompt.
|
|
38
|
+
* Deliberately mirrors the cap in packages/ui/src/route.ts (ui is not a
|
|
39
|
+
* dependency here): one malformed client misbehaves the same on every
|
|
40
|
+
* /local-infer route, so edit the two together.
|
|
41
|
+
*/
|
|
42
|
+
const MAX_BODY_BYTES = 64 * 1024;
|
|
43
|
+
/**
|
|
44
|
+
* readJsonBody collects a bounded JSON request body: chunks up to the cap,
|
|
45
|
+
* then parses. A body past the cap destroys the request and throws a 413
|
|
46
|
+
* RouteError carrying the route's own message, so the answer names the route
|
|
47
|
+
* that rejected the body.
|
|
48
|
+
*/
|
|
49
|
+
async function readJsonBody(req, tooLargeMessage) {
|
|
50
|
+
const chunks = [];
|
|
51
|
+
let total = 0;
|
|
52
|
+
for await (const chunk of req) {
|
|
53
|
+
total += chunk.length;
|
|
54
|
+
if (total > MAX_BODY_BYTES) {
|
|
55
|
+
req.destroy();
|
|
56
|
+
throw new RouteError(413, tooLargeMessage);
|
|
57
|
+
}
|
|
58
|
+
chunks.push(chunk);
|
|
59
|
+
}
|
|
60
|
+
return JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
61
|
+
}
|
|
62
|
+
/** Writes one JSON answer (status head plus body) on the response. */
|
|
63
|
+
function writeJson(res, status, body) {
|
|
64
|
+
res.writeHead(status, { 'content-type': 'application/json' });
|
|
65
|
+
res.end(JSON.stringify(body));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* defineRoute is the local template both route specs build on: it guards the
|
|
69
|
+
* method (405), reads the bounded body (413, POST only), and maps the
|
|
70
|
+
* handler's answer to a status: a RouteError carries its own status, any
|
|
71
|
+
* other failure answers with the spec's failStatus.
|
|
72
|
+
*/
|
|
73
|
+
function defineRoute(spec) {
|
|
74
|
+
return {
|
|
75
|
+
name: spec.name,
|
|
76
|
+
kind: 'exact',
|
|
77
|
+
path: spec.path,
|
|
78
|
+
handler: async (req, res) => {
|
|
79
|
+
if (req.method !== spec.method) {
|
|
80
|
+
res.writeHead(405).end();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const body = spec.method === 'POST' ? await readJsonBody(req, spec.tooLargeMessage) : {};
|
|
85
|
+
await spec.run({ url: new URL(req.url, 'http://localhost'), body }, (status, answer) => writeJson(res, status, answer));
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error instanceof RouteError) {
|
|
89
|
+
writeJson(res, error.status, { error: error.message });
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
writeJson(res, spec.failStatus, { error: String(error?.message ?? error) });
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function orchestratorPayload() {
|
|
98
|
+
return {
|
|
99
|
+
prompt: getOrchestratorPrompt(),
|
|
100
|
+
defaultPrompt: defaultOrchestratorPrompt(),
|
|
101
|
+
saved: hasSavedOrchestratorPrompt(),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* orchestratorGetRoute builds the GET /local-infer/orchestrator route. The
|
|
106
|
+
* client treats any non-404 answer as proof the route is mounted, so the
|
|
107
|
+
* payload answers 200 even before anything is saved.
|
|
108
|
+
*/
|
|
109
|
+
function orchestratorGetRoute() {
|
|
110
|
+
return defineRoute({
|
|
111
|
+
name: 'local-infer-orchestrator',
|
|
112
|
+
path: '/local-infer/orchestrator',
|
|
113
|
+
method: 'GET',
|
|
114
|
+
failStatus: 500,
|
|
115
|
+
run: async (_input, json) => {
|
|
116
|
+
json(200, orchestratorPayload());
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* orchestratorSaveRoute builds the POST /local-infer/orchestrator/save route:
|
|
122
|
+
* a string prompt persists through setOrchestratorPrompt (an empty string
|
|
123
|
+
* clears the saved override back to the default) and the answer carries the
|
|
124
|
+
* GET payload shape so the card re-renders from one response.
|
|
125
|
+
*/
|
|
126
|
+
function orchestratorSaveRoute() {
|
|
127
|
+
return defineRoute({
|
|
128
|
+
name: 'local-infer-orchestrator-save',
|
|
129
|
+
path: '/local-infer/orchestrator/save',
|
|
130
|
+
method: 'POST',
|
|
131
|
+
failStatus: 400,
|
|
132
|
+
tooLargeMessage: 'orchestrator prompt payload too large',
|
|
133
|
+
run: async ({ body }, json) => {
|
|
134
|
+
if (typeof body.prompt !== 'string') {
|
|
135
|
+
throw new RouteError(400, 'prompt must be a string');
|
|
136
|
+
}
|
|
137
|
+
setOrchestratorPrompt(body.prompt);
|
|
138
|
+
json(200, orchestratorPayload());
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* registerOrchestratorRoutes registers the GET and save routes on the web
|
|
144
|
+
* server and holds them by an effect, so a component switch off removes them
|
|
145
|
+
* before the next switch on re-registers. The scoped context carries the
|
|
146
|
+
* webServer.
|
|
147
|
+
*/
|
|
148
|
+
export function registerOrchestratorRoutes(scope) {
|
|
149
|
+
const routes = [orchestratorGetRoute(), orchestratorSaveRoute()];
|
|
150
|
+
scope.effect(() => {
|
|
151
|
+
const disposers = routes.map((route) => scope.webServer.register(route));
|
|
152
|
+
return () => {
|
|
153
|
+
for (const dispose of disposers) {
|
|
154
|
+
dispose();
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}, 'local-infer-orchestrator: settings routes');
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-plugin-local-infer-orchestrator",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Orchestrator component for the dsh local-inference plugin: an editable Orchestrator Prompt persisted under ~/.dsh/local-infer, defaulted from the shipped prompt.md, injected into the system prompt while the component is enabled",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dsh",
|
|
7
|
+
"dsh-plugin",
|
|
8
|
+
"deepseek-harness",
|
|
9
|
+
"local-inference",
|
|
10
|
+
"orchestrator",
|
|
11
|
+
"system-prompt"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "lib/index.js",
|
|
16
|
+
"types": "lib/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./lib/index.d.ts",
|
|
20
|
+
"default": "./lib/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"lib/**/*.js",
|
|
26
|
+
"lib/**/*.d.ts",
|
|
27
|
+
"prompt.md",
|
|
28
|
+
"locale/en.json"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@deepseek-ai/cordis": ">=4.0.1"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@deepseek-ai/cordis": "^4.0.6-alpha.2"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Role & Core Objective
|
|
2
|
+
You are an advanced software engineering orchestration agent.
|
|
3
|
+
Your goal is to systematically plan, execute, and finalize user requests using micro-tasks and subagents.
|
|
4
|
+
Always adhere strictly to the following execution sequence.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Step 1: Initialization & Planning
|
|
9
|
+
1. **Gather Context**: Analyze the user request.
|
|
10
|
+
2. **Initialize Plan**: Execute the `todo_write` tool. Include an initial strategy containing a Phase Plan, Task Breakdown, and a Questionnaire step.
|
|
11
|
+
Do not include individual tasks at this time.
|
|
12
|
+
3. **Generate Plan File**: Create a Markdown file named `PLAN-{{1OR2WORD-SLUG}}.md` in the root directory containing:
|
|
13
|
+
- A short description of the objective at the very top.
|
|
14
|
+
- Verification guidelines (Do not duplicate any rules found in `AGENTS.md`).
|
|
15
|
+
- A sequential list of open questions for the user.
|
|
16
|
+
- An ordered list of micro-tasks, group logically by Phase.
|
|
17
|
+
Each task must represent the smallest possible unit of work with a concrete, verifiable "Definition of Done".
|
|
18
|
+
4. **Review Plan File**: Remove any duplicative context so that each statement
|
|
19
|
+
the single source of truth. Remove reasoning notes about task ordering,
|
|
20
|
+
replacing with a clear Markdown list of task dependencies.
|
|
21
|
+
|
|
22
|
+
## Step 2: Refactoring Tasks Injection
|
|
23
|
+
Where appropriate, insert specialized tasks starting with `Refactor:` into your task sequence.
|
|
24
|
+
These tasks must contain the exact following instruction block,
|
|
25
|
+
with the `{{N}}` count template replaced by the number of Tasks in the Phase:
|
|
26
|
+
```text
|
|
27
|
+
Review the files touched by the previous {{N}} commits and identify the following code risks:
|
|
28
|
+
- **Multiple Sources of Truth**: Same calculations done in multiple places.
|
|
29
|
+
- **Duplicate Code**: Nearly-identical code in multiple methods.
|
|
30
|
+
- **Bloaters**: Too many things done in a single method or class.
|
|
31
|
+
- **Data Clumps**: Single variables that travel in a group for multiple methods.
|
|
32
|
+
- **Shotgun Edits**: Commits with singular changes that touch multiple files.
|
|
33
|
+
- **Feature Envy**: Method where over 50% of the code manipulates a different class.
|
|
34
|
+
- **Magic Numbers**: Literals without context in method bodies.
|
|
35
|
+
Then address and resolve each risk.
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Step 3: Architecture-Dependent Architecture Selection
|
|
39
|
+
Count the total number of sequential tasks generated. Execute branch **A** or **B** based on the count:
|
|
40
|
+
|
|
41
|
+
### Branch A: High-Complexity Architecture (5 or More Tasks)
|
|
42
|
+
1. **Deconstruct Plan**: Extract each task body out of the main index file.
|
|
43
|
+
2. **Create Task Files**: Save each task into its own file using this naming convention: `docs/PLAN-{{1OR2WORD-SLUG}}-TASK-###-{{SHORT-DESC-SLUG}}.md`.
|
|
44
|
+
3. **Update Main Index**: Ensure `PLAN-{{1OR2WORD-SLUG}}.md` becomes a slim index where tasks are grouped logically by section and linked using exact Markdown checklist syntax:
|
|
45
|
+
` - [ ] [TASK-###-{{SHORT-DESC-SLUG}}](docs/PLAN-{{1OR2WORD-SLUG}}-TASK-###-{{SHORT-DESC-SLUG}}.md)`
|
|
46
|
+
4. **Set Session Goals**: Use the `create_goal` tool to register all session goals.
|
|
47
|
+
|
|
48
|
+
### Branch B: Low-Complexity Architecture (Less Than 5 Tasks)
|
|
49
|
+
1. **Deconstruct Tasks**: Break down each task into a series of todos.
|
|
50
|
+
In Step 4, when writing each task to the global todo list, include the
|
|
51
|
+
series of todos for each task as an individual todo between tasks.
|
|
52
|
+
|
|
53
|
+
## Step 4: Questionnaire & Baseline Commit
|
|
54
|
+
1. **Append To-Dos**: Use the `todo_write` tool to insert your tasks directly into the global todo list.
|
|
55
|
+
2. **Add Finalizer To-Do**: Append a final `Finalize` item to the end of that list.
|
|
56
|
+
3. **Interview User**: For every open question identified in Step 1, invoke the `ask_user_question` tool individually.
|
|
57
|
+
Provide at least one recommended answer and leave a spot open for the user to answer with their own input.
|
|
58
|
+
4. **Persist Answers**: As answers arrive, write them directly into `PLAN-{{1OR2WORD-SLUG}}.md` (or the specific task file if using Branch A).
|
|
59
|
+
5. **Close Questionnaire**: Mark the Questionnaire task as complete.
|
|
60
|
+
6. **Commit Blueprint**: If on Branch A (High-Complexity), commit the created `PLAN` file (and accompanying `docs/` task files if applicable) to repository version control.
|
|
61
|
+
|
|
62
|
+
## Step 5: Subagent Execution Loop
|
|
63
|
+
Loop through the tasks sequentially. For **each** incomplete task:
|
|
64
|
+
1. **Launch Subagent**: Trigger the `subagent` tool with this exact prompt,
|
|
65
|
+
replacing the PLAN filename template:
|
|
66
|
+
```text
|
|
67
|
+
1. Complete the next Task in @PLAN-{{1OR2WORD-SLUG}}.md .
|
|
68
|
+
2. Use the `todo_write` tool to plan your work.
|
|
69
|
+
3. Check ('[x]') the task in the file when done, then commit the completed work.
|
|
70
|
+
4. List any discovered pre-existing issues for the parent agent to review.
|
|
71
|
+
5. Then you are finished; resolve remaining todos and end the turn.
|
|
72
|
+
```
|
|
73
|
+
2. **Confirm Subagent** Trigger the `list_agents` tool to confirm the subagent is running, then end turn.
|
|
74
|
+
3. **Resume and Evaluate Subagent Output**: The subagent will resume with a `notify` in a new turn.
|
|
75
|
+
If the subagent discovers pre-existing codebase issues, insert new tasks immediately after the current task in the appropriate execution order.
|
|
76
|
+
4. **Sync State**: Invoke the `todo_write` tool to check off progress.
|
|
77
|
+
5. **Repeat**: Proceed to the next task until all items in the plan are checked `[x]`.
|
|
78
|
+
|
|
79
|
+
## Step 6: Finalization & Handoff
|
|
80
|
+
1. **Cleanup Artifacts**: Delete all generated `PLAN-{{1OR2WORD-SLUG}}.md` and `docs/PLAN-{{1OR2WORD-SLUG}}-TASK*` files.
|
|
81
|
+
Remove all memory and file references, restoring the repo development to a stateless condition.
|
|
82
|
+
2. **Commit Cleanup**: Commit these deletions to repository version control.
|
|
83
|
+
3. **Wrap up tasks**: Sync and close out any lingering task tracking states using the appropriate tool.
|
|
84
|
+
4. **Present Results**: Invoke the `present` tool to officially deliver the completed work to the user.
|
|
85
|
+
5. **Complete**: End the turn.
|
|
86
|
+
|
|
87
|
+
---
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* local changes aborts, because a rebase would eat the user's work.
|
|
9
9
|
* @module dsh-plugin-local-infer/providers/acquire
|
|
10
10
|
*/
|
|
11
|
-
import type { LifecycleHost } from '../../core/lib/index.js';
|
|
11
|
+
import type { DeployOptions, EnginePlatformConfig, LaunchProgress, LifecycleHost } from '../../core/lib/index.js';
|
|
12
|
+
import type { EngineOsProfile } from './engines/engineOs.ts';
|
|
12
13
|
/**
|
|
13
14
|
* EngineSource is the per-engine acquisition data: the upstream git repo the
|
|
14
15
|
* clone step uses when no fork is provided, the branch the fetch/rebase step
|
|
@@ -20,6 +21,7 @@ export interface EngineSource {
|
|
|
20
21
|
repo: string;
|
|
21
22
|
branch: string;
|
|
22
23
|
buildSteps: readonly string[];
|
|
24
|
+
windowsBuildSteps?: readonly string[];
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* The remote name a user-provided fork is added under, so the checkout's own
|
|
@@ -32,9 +34,35 @@ export declare const FORK_REMOTE = "dsh-fork";
|
|
|
32
34
|
* the same cmake shape as NInfer; Hyper-Qwen is the compose-driven vLLM
|
|
33
35
|
* engine, so it carries no local build steps (the compose up pulls the
|
|
34
36
|
* image); Strata builds through its own setup.sh (the README's
|
|
35
|
-
* Build-from-source route), which the source-build mode runs in the checkout
|
|
37
|
+
* Build-from-source route), which the source-build mode runs in the checkout;
|
|
38
|
+
* Basalt builds through its own CMake route (the Ninja/MSVC variant on
|
|
39
|
+
* Windows). The build steps are read from the per-engine OS profiles, so a
|
|
40
|
+
* build command has one home (the OS-specific files under engines/).
|
|
36
41
|
*/
|
|
37
42
|
export declare const ENGINE_SOURCES: Record<string, EngineSource>;
|
|
43
|
+
/**
|
|
44
|
+
* engineOsProfile reads the registered build profile for an engine id on an OS,
|
|
45
|
+
* or undefined when none is registered. A host OS with no dedicated profile
|
|
46
|
+
* (a Windows host for an engine that carries no Windows route) reads the
|
|
47
|
+
* shared Linux profile.
|
|
48
|
+
*/
|
|
49
|
+
export declare function engineOsProfile(engineId: string, os?: 'linux' | 'windows' | 'macos'): EngineOsProfile | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* engineBuildDir reads the directory, relative to the checkout, where an
|
|
52
|
+
* engine's build leaves its binary on an OS, so the binary symlink step reads
|
|
53
|
+
* the right tree. A Windows host reads the engine's Windows build tree (the
|
|
54
|
+
* vcpkg route for NInfer writes into build-windows\apps\Release); every other
|
|
55
|
+
* host reads the shared Linux build directory. An engine that installs its
|
|
56
|
+
* binary to the path (Strata) carries no build directory, so it reads as
|
|
57
|
+
* `build`, the shared default.
|
|
58
|
+
*/
|
|
59
|
+
export declare function engineBuildDir(engineId: string, os?: 'linux' | 'windows' | 'macos'): string;
|
|
60
|
+
/**
|
|
61
|
+
* engineBinary reads the engine binary name on an OS (the .exe on Windows), so
|
|
62
|
+
* the adapters and the symlink step share one source. An engine with no local
|
|
63
|
+
* binary (the compose engines) reads as undefined.
|
|
64
|
+
*/
|
|
65
|
+
export declare function engineBinary(engineId: string, os?: 'linux' | 'windows' | 'macos'): string | undefined;
|
|
38
66
|
/**
|
|
39
67
|
* AcquireLog receives one line (or chunk) of Get output as it lands, so the
|
|
40
68
|
* route can stream it to the card's Logs section.
|
|
@@ -50,44 +78,63 @@ export interface EngineStepResult {
|
|
|
50
78
|
aborted?: boolean;
|
|
51
79
|
detail?: string;
|
|
52
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* SyncStepResult is the sync step's EngineStepResult plus the path it took:
|
|
83
|
+
* `cloned` true means a fresh clone ran (no prior checkout), so a failure on
|
|
84
|
+
* that path leaves no current version to launch; an absent `cloned` means the
|
|
85
|
+
* checkout was present and the rebase, fetch, or dirty path ran, so a failure
|
|
86
|
+
* there leaves a launchable current version. The Get step reads the flag to
|
|
87
|
+
* decide a sync failure's fatality instead of re-probing the checkout.
|
|
88
|
+
*/
|
|
89
|
+
export interface SyncStepResult extends EngineStepResult {
|
|
90
|
+
cloned?: boolean;
|
|
91
|
+
}
|
|
53
92
|
/**
|
|
54
93
|
* engineSource reads the registered acquisition data for an engine id, or
|
|
55
94
|
* undefined when none is registered.
|
|
56
95
|
*/
|
|
57
96
|
export declare function engineSource(engineId: string): EngineSource | undefined;
|
|
58
97
|
/**
|
|
59
|
-
* engineBuildSteps reads the build steps an engine runs in its checkout
|
|
60
|
-
* the adapter's deploy step and the Get build step share one list.
|
|
98
|
+
* engineBuildSteps reads the build steps an engine runs in its checkout for an
|
|
99
|
+
* OS, so the adapter's deploy step and the Get build step share one list. The
|
|
100
|
+
* steps come from the engine's OS profile: a Windows host reads the engine's
|
|
101
|
+
* Windows profile (the vcpkg route for NInfer), and a host OS with no
|
|
102
|
+
* dedicated profile reads the shared Linux profile.
|
|
61
103
|
*/
|
|
62
|
-
export declare function engineBuildSteps(engineId: string): readonly string[];
|
|
104
|
+
export declare function engineBuildSteps(engineId: string, os?: 'linux' | 'windows' | 'macos'): readonly string[];
|
|
63
105
|
/**
|
|
64
106
|
* syncEngineRepo brings the engine checkout to the listed source. A missing
|
|
65
107
|
* checkout is a fresh clone of the fork (or the engine's upstream repo when
|
|
66
108
|
* no fork is provided). An existing checkout with local changes aborts, so
|
|
67
109
|
* the user's work is never rebased away; a clean checkout fetches the listed
|
|
68
110
|
* fork (added as the named fork remote when provided, origin when not) and
|
|
69
|
-
* rebases onto its branch. Every command echoes into log as it runs.
|
|
111
|
+
* rebases onto its branch. Every command echoes into log as it runs. The
|
|
112
|
+
* result's `cloned` flag names the path taken: set on a fresh clone (the
|
|
113
|
+
* checkout was absent), absent on the present-checkout path, so a caller
|
|
114
|
+
* prices a failure's fatality from the flag instead of re-probing the
|
|
115
|
+
* checkout.
|
|
70
116
|
*/
|
|
71
117
|
export declare function syncEngineRepo(host: LifecycleHost, request: {
|
|
72
118
|
engineId: string;
|
|
73
119
|
directory: string;
|
|
74
120
|
fork?: string;
|
|
75
|
-
}, log: AcquireLog): Promise<
|
|
121
|
+
}, log: AcquireLog): Promise<SyncStepResult>;
|
|
76
122
|
/**
|
|
77
123
|
* SyncRebuildRequest names the checkout the conditional rebuild prices: the
|
|
78
|
-
* engine, its directory, the optional fork remote, the
|
|
79
|
-
* symlink
|
|
80
|
-
*
|
|
81
|
-
*
|
|
124
|
+
* engine, its directory, the optional fork remote, and the Play/Run trust gate
|
|
125
|
+
* that decides whether the binary symlink (added when a rebuild leaves the
|
|
126
|
+
* binary out of the path) runs (on) or is written to the logs (off). The
|
|
127
|
+
* symlink step reads the bare binary name from the engine profile, so the
|
|
128
|
+
* request carries no binary of its own.
|
|
82
129
|
*/
|
|
83
130
|
export interface SyncRebuildRequest {
|
|
84
131
|
engineId: string;
|
|
85
132
|
directory: string;
|
|
86
133
|
fork?: string;
|
|
87
|
-
binary?: string;
|
|
88
134
|
allowRunDeps?: boolean;
|
|
89
135
|
buildCommands?: string;
|
|
90
136
|
onBuildStart?: () => void;
|
|
137
|
+
os?: 'linux' | 'windows' | 'macos';
|
|
91
138
|
}
|
|
92
139
|
/**
|
|
93
140
|
* SyncRebuildResult reports the conditional rebuild: whether it passed,
|
|
@@ -117,11 +164,42 @@ export interface SyncRebuildResult {
|
|
|
117
164
|
* added (run when the trust gate is on, written to the logs when it is off).
|
|
118
165
|
*/
|
|
119
166
|
export declare function syncAndRebuildEngine(host: LifecycleHost, request: SyncRebuildRequest, log: AcquireLog): Promise<SyncRebuildResult>;
|
|
167
|
+
/**
|
|
168
|
+
* EngineDeploySync reports the deploy step's git sync (the shared
|
|
169
|
+
* syncAndRebuildEngine): whether it passed, a detail for a failure, and the
|
|
170
|
+
* captured build output the deploy step threads to the card's Logs section
|
|
171
|
+
* (a "Building..." separator leads a rebuild's output, the same line the
|
|
172
|
+
* card writes when the build step event lands).
|
|
173
|
+
*/
|
|
174
|
+
export interface EngineDeploySync {
|
|
175
|
+
ok: boolean;
|
|
176
|
+
detail?: string;
|
|
177
|
+
buildLogs: string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* syncEngineForDeploy runs the deploy step's git sync (the shared
|
|
181
|
+
* syncAndRebuildEngine) with the option shape every adapter's deploy step
|
|
182
|
+
* assembles: the platform entry's fork and build-command override, the
|
|
183
|
+
* Play/Run trust gate, the plan's host OS (the Windows vcpkg route when the
|
|
184
|
+
* user carries no build-command override), and the progress sink the card's
|
|
185
|
+
* button reads (the git sync reports "Downloading...", the build step
|
|
186
|
+
* reports "Building..." the moment it starts). The captured build output is
|
|
187
|
+
* returned as buildLogs, so a caller threads it to the card's Logs section
|
|
188
|
+
* without re-running the steps.
|
|
189
|
+
*/
|
|
190
|
+
export declare function syncEngineForDeploy(host: LifecycleHost, request: {
|
|
191
|
+
engineId: string;
|
|
192
|
+
directory: string;
|
|
193
|
+
platform?: EnginePlatformConfig;
|
|
194
|
+
options?: DeployOptions;
|
|
195
|
+
os?: 'linux' | 'windows' | 'macos';
|
|
196
|
+
onProgress?: LaunchProgress;
|
|
197
|
+
}): Promise<EngineDeploySync>;
|
|
120
198
|
/**
|
|
121
199
|
* buildEngineRepo runs the engine's build steps in the checkout, streaming
|
|
122
200
|
* each step's output through log. An engine with no build steps (the compose
|
|
123
201
|
* engines) passes through with a note; a failing step stops the build with
|
|
124
202
|
* the step's detail.
|
|
125
203
|
*/
|
|
126
|
-
export declare function buildEngineRepo(host: LifecycleHost, engineId: string, directory: string, log: AcquireLog, buildCommands?: string): Promise<EngineStepResult>;
|
|
127
|
-
//# sourceMappingURL=acquire.d.ts.map
|
|
204
|
+
export declare function buildEngineRepo(host: LifecycleHost, engineId: string, directory: string, log: AcquireLog, buildCommands?: string, os?: 'linux' | 'windows' | 'macos'): Promise<EngineStepResult>;
|
|
205
|
+
//# sourceMappingURL=acquire.d.ts.map
|