dsh-remote-vs 0.22.0 → 0.23.0
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.en.md +489 -473
- package/README.md +434 -424
- package/cordis.patch.yml +13 -5
- package/lib/client.js +141 -12
- package/lib/index.js +7 -2
- package/lib/p2-router-fs.js +6 -7
- package/lib/types/client/notices.d.ts +35 -0
- package/lib/types/deploy.d.ts +28 -2
- package/lib/types/notices.d.ts +22 -0
- package/lib/types/p2/router-fs.d.ts +4 -5
- package/lib/types/p2/worlds.d.ts +10 -0
- package/lib/{worlds-DSzyajOB.js → worlds-DXdP4SMn.js} +80 -4
- package/package.json +37 -37
- package/src/client/DirectoryFlow.tsx +65 -5
- package/src/client/api.ts +5 -0
- package/src/client/i18n.ts +4 -2
- package/src/client/index.tsx +24 -5
- package/src/client/notices.ts +86 -0
- package/src/deploy.ts +38 -2
- package/src/http.ts +12 -1
- package/src/notices.ts +37 -0
- package/src/p2/router-fs.ts +5 -6
- package/src/p2/worlds.ts +46 -2
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.helper.json +19 -0
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.tar.gz +4 -0
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.tar.gz.sha256 +1 -0
- package/vendor/dsh-remote-helpers/ssh-helper-runtime-deps.patch +14 -0
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.1-alpha.2-linux-x64.helper.json +0 -16
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.1-alpha.2-linux-x64.tar.gz +0 -4
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.1-alpha.2-linux-x64.tar.gz.sha256 +0 -1
package/cordis.patch.yml
CHANGED
|
@@ -54,6 +54,9 @@
|
|
|
54
54
|
inject: [localFileReferences, remoteWorlds]
|
|
55
55
|
|
|
56
56
|
# Remote agent preset, bound to this bundle's lifecycle.
|
|
57
|
+
# Mirrored from preset-standard @ dsh 0.2.2-rc.4. rc.4 note: the stock
|
|
58
|
+
# `presets/standard.patch.yml` is byte-identical to rc.2 (verified by hash),
|
|
59
|
+
# so this round adds no mirror delta — only the intentional diffs below.
|
|
57
60
|
# Mirrored from preset-standard @ dsh 0.2.2-rc.2. rc.2 deltas adopted:
|
|
58
61
|
# skill-filesystem customSkillDirs, tool-subagent-control interrupt:false,
|
|
59
62
|
# tool-office row.
|
|
@@ -61,7 +64,12 @@
|
|
|
61
64
|
# 1. persona prefix reframed for remote SSH work (transparent routing);
|
|
62
65
|
# 2. tool-bash moved into an isolated shell group with our routed bash
|
|
63
66
|
# executor (stock root shell stays pwsh on Windows);
|
|
64
|
-
# 3. tool-pwsh row dropped
|
|
67
|
+
# 3. tool-pwsh row dropped;
|
|
68
|
+
# 4. tool-fs `applyPatch: true` — intentional divergence from stock's
|
|
69
|
+
# `false`: 0.23.0 speaks helper protocol 3, so the remote half really
|
|
70
|
+
# implements patch/delete/move (fs.patch/fs.delete/fs.move) and the
|
|
71
|
+
# apply_patch tool is no longer a local-only promise. Stock default stays
|
|
72
|
+
# false for compositions that do not mount our remote fs.
|
|
65
73
|
# Everything else is byte-identical so future diffs against stock stay obvious.
|
|
66
74
|
# alpha.3 note: stock dropped `toolFilter` (subagent children now inherit
|
|
67
75
|
# the parent composition; fork must not select presets) — our mirror drops
|
|
@@ -115,10 +123,10 @@
|
|
|
115
123
|
- id: tool-fs
|
|
116
124
|
name: '@deepseek-ai/dsh-tool-fs'
|
|
117
125
|
config:
|
|
118
|
-
#
|
|
119
|
-
#
|
|
120
|
-
#
|
|
121
|
-
applyPatch:
|
|
126
|
+
# Intentional divergence from the stock `false`: the remote world
|
|
127
|
+
# serves protocol 3 (fs.patch/fs.delete/fs.move), so apply_patch is
|
|
128
|
+
# real for remote files as well as local ones. Stock stays false.
|
|
129
|
+
applyPatch: true
|
|
122
130
|
- id: tool-fs-search
|
|
123
131
|
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
124
132
|
config:
|
package/lib/client.js
CHANGED
|
@@ -382,6 +382,7 @@ window.__ModuleLoader__.load({
|
|
|
382
382
|
"hosts.unknownError": "未知错误",
|
|
383
383
|
"hosts.deleted": "{alias}:已删除",
|
|
384
384
|
"hosts.saved": "{alias}:已保存",
|
|
385
|
+
"hosts.helperPushed": "{alias}:已自动推送远端 helper {version}",
|
|
385
386
|
"hosts.imported": "已导入 {count} 个主机",
|
|
386
387
|
"hosts.importedSkipped": ";跳过:{list}",
|
|
387
388
|
"form.alias": "别名",
|
|
@@ -1006,6 +1007,7 @@ window.__ModuleLoader__.load({
|
|
|
1006
1007
|
"hosts.unknownError": "unknown error",
|
|
1007
1008
|
"hosts.deleted": "{alias}: deleted",
|
|
1008
1009
|
"hosts.saved": "{alias}: saved",
|
|
1010
|
+
"hosts.helperPushed": "{alias}: pushed remote helper {version} automatically",
|
|
1009
1011
|
"hosts.imported": "Imported {count} host(s)",
|
|
1010
1012
|
"hosts.importedSkipped": "; skipped: {list}",
|
|
1011
1013
|
"form.alias": "Alias",
|
|
@@ -1614,6 +1616,68 @@ window.__ModuleLoader__.load({
|
|
|
1614
1616
|
return (key) => dict[key] ?? en[key] ?? key;
|
|
1615
1617
|
}
|
|
1616
1618
|
//#endregion
|
|
1619
|
+
//#region src/client/notices.ts
|
|
1620
|
+
const MAX_QUEUED = 8;
|
|
1621
|
+
let emitter;
|
|
1622
|
+
let queued = [];
|
|
1623
|
+
/**
|
|
1624
|
+
* Install (or remove) the toast emitter; the client entry owns the lifetime.
|
|
1625
|
+
*
|
|
1626
|
+
* Messages that arrived before the entry registered are flushed, so a notice
|
|
1627
|
+
* produced during the first remote operation of a page load cannot be lost.
|
|
1628
|
+
*/
|
|
1629
|
+
function setHostNoticeEmitter(next) {
|
|
1630
|
+
emitter = next;
|
|
1631
|
+
if (next === void 0) return;
|
|
1632
|
+
const pending = queued;
|
|
1633
|
+
queued = [];
|
|
1634
|
+
for (const text of pending) next(text);
|
|
1635
|
+
}
|
|
1636
|
+
/** Render one notice in the page language. */
|
|
1637
|
+
function formatHostNotice(notice, lang = detectLang()) {
|
|
1638
|
+
const t = makeT(lang);
|
|
1639
|
+
if (notice.kind === "helper-pushed") return t("hosts.helperPushed").replace("{alias}", notice.alias).replace("{version}", notice.version);
|
|
1640
|
+
return "";
|
|
1641
|
+
}
|
|
1642
|
+
/** Deliver one rendered message: to the emitter when present, else queue it. */
|
|
1643
|
+
function deliver(text, emit) {
|
|
1644
|
+
const target = emit ?? emitter;
|
|
1645
|
+
if (target !== void 0) {
|
|
1646
|
+
target(text);
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
if (queued.length < MAX_QUEUED) queued = [...queued, text];
|
|
1650
|
+
}
|
|
1651
|
+
/**
|
|
1652
|
+
* Show every valid notice carried by one API response.
|
|
1653
|
+
*
|
|
1654
|
+
* `emit` is injectable so a gate can drive this without React or a DOM. A
|
|
1655
|
+
* malformed payload is ignored: a newer/older peer must never turn a successful
|
|
1656
|
+
* remote operation into a client exception.
|
|
1657
|
+
*/
|
|
1658
|
+
function dispatchHostNotices(payload, emit) {
|
|
1659
|
+
if (typeof payload !== "object" || payload === null) return 0;
|
|
1660
|
+
const raw = payload.notices;
|
|
1661
|
+
if (!Array.isArray(raw)) return 0;
|
|
1662
|
+
let shown = 0;
|
|
1663
|
+
for (const entry of raw) {
|
|
1664
|
+
if (typeof entry !== "object" || entry === null) continue;
|
|
1665
|
+
const notice = entry;
|
|
1666
|
+
if (notice.kind !== "helper-pushed") continue;
|
|
1667
|
+
if (typeof notice.alias !== "string" || typeof notice.version !== "string") continue;
|
|
1668
|
+
if (notice.alias === "" || notice.version === "") continue;
|
|
1669
|
+
const text = formatHostNotice({
|
|
1670
|
+
kind: "helper-pushed",
|
|
1671
|
+
alias: notice.alias,
|
|
1672
|
+
version: notice.version
|
|
1673
|
+
});
|
|
1674
|
+
if (text === "") continue;
|
|
1675
|
+
deliver(text, emit);
|
|
1676
|
+
shown += 1;
|
|
1677
|
+
}
|
|
1678
|
+
return shown;
|
|
1679
|
+
}
|
|
1680
|
+
//#endregion
|
|
1617
1681
|
//#region src/git-format.ts
|
|
1618
1682
|
/** Cap on status file rows (each side). */
|
|
1619
1683
|
const STATUS_ROW_CAP = 200;
|
|
@@ -2902,6 +2966,7 @@ window.__ModuleLoader__.load({
|
|
|
2902
2966
|
}
|
|
2903
2967
|
throw failure;
|
|
2904
2968
|
}
|
|
2969
|
+
dispatchHostNotices(data);
|
|
2905
2970
|
return data;
|
|
2906
2971
|
}
|
|
2907
2972
|
function post(path, body) {
|
|
@@ -4164,6 +4229,23 @@ window.__ModuleLoader__.load({
|
|
|
4164
4229
|
* always available. If this entry ever crashes, slot shadowing retires it and
|
|
4165
4230
|
* the stock picker renders (graceful fallback, no dead surface).
|
|
4166
4231
|
*/
|
|
4232
|
+
/**
|
|
4233
|
+
* Opt-in trace for the directory flow, silent unless the operator sets
|
|
4234
|
+
* `localStorage['dsh-remote-vs.debug'] = '1'` and reopens the dialog.
|
|
4235
|
+
*
|
|
4236
|
+
* The native-chooser interaction crosses three parties — this dialog, the stock
|
|
4237
|
+
* owner that adopts the path, and the host-side OS chooser — so "the dialog did
|
|
4238
|
+
* not close" needs to say WHICH stage was reached before it can be diagnosed.
|
|
4239
|
+
* Without this the only observable is the symptom.
|
|
4240
|
+
*/
|
|
4241
|
+
function traceFlow(...parts) {
|
|
4242
|
+
try {
|
|
4243
|
+
if (typeof localStorage === "undefined" || localStorage.getItem("dsh-remote-vs.debug") !== "1") return;
|
|
4244
|
+
} catch {
|
|
4245
|
+
return;
|
|
4246
|
+
}
|
|
4247
|
+
console.info("[rvs-flow]", ...parts);
|
|
4248
|
+
}
|
|
4167
4249
|
function errText(e) {
|
|
4168
4250
|
if (e !== null && typeof e === "object" && "rpcError" in e) {
|
|
4169
4251
|
const rpc = e.rpcError;
|
|
@@ -4202,8 +4284,11 @@ window.__ModuleLoader__.load({
|
|
|
4202
4284
|
setMode("browse");
|
|
4203
4285
|
} catch (e) {
|
|
4204
4286
|
if (gen !== generation.current) return;
|
|
4205
|
-
if (isUnavailable(e))
|
|
4206
|
-
|
|
4287
|
+
if (isUnavailable(e)) {
|
|
4288
|
+
traceFlow("browse unavailable -> native");
|
|
4289
|
+
setMode("native");
|
|
4290
|
+
} else {
|
|
4291
|
+
traceFlow("browse failed", errText(e));
|
|
4207
4292
|
setMode(mode === "browse" ? "browse" : "failed");
|
|
4208
4293
|
setError(errText(e));
|
|
4209
4294
|
}
|
|
@@ -4236,16 +4321,24 @@ window.__ModuleLoader__.load({
|
|
|
4236
4321
|
};
|
|
4237
4322
|
const nativePick = () => {
|
|
4238
4323
|
const gen = ++generation.current;
|
|
4324
|
+
const epoch = props.flowEpoch.current;
|
|
4239
4325
|
setLoading(true);
|
|
4240
4326
|
setError(void 0);
|
|
4241
4327
|
setNotice(void 0);
|
|
4328
|
+
traceFlow("native chooser requested");
|
|
4242
4329
|
injected.pickDirectory().then((picked) => {
|
|
4243
|
-
if (
|
|
4330
|
+
if (props.flowEpoch.current !== epoch) {
|
|
4331
|
+
traceFlow("native chooser result dropped (another open request)", picked);
|
|
4332
|
+
return;
|
|
4333
|
+
}
|
|
4334
|
+
if (gen !== generation.current) traceFlow("native chooser result adopted after remount", picked);
|
|
4335
|
+
traceFlow("native chooser returned", picked === null ? "cancelled" : picked);
|
|
4244
4336
|
setLoading(false);
|
|
4245
4337
|
if (picked === null) setNotice(t("flow.nativeCancelled"));
|
|
4246
4338
|
else props.onPicked(picked);
|
|
4247
4339
|
}, (e) => {
|
|
4248
|
-
if (
|
|
4340
|
+
if (props.flowEpoch.current !== epoch) return;
|
|
4341
|
+
traceFlow("native chooser failed", errText(e));
|
|
4249
4342
|
setLoading(false);
|
|
4250
4343
|
setError(errText(e));
|
|
4251
4344
|
});
|
|
@@ -4571,6 +4664,7 @@ window.__ModuleLoader__.load({
|
|
|
4571
4664
|
onCancel: props.onCancel,
|
|
4572
4665
|
onSaved: (_workspace, aliasPath) => {
|
|
4573
4666
|
setDone(true);
|
|
4667
|
+
traceFlow("remote wizard saved", aliasPath);
|
|
4574
4668
|
props.onPicked(aliasPath);
|
|
4575
4669
|
}
|
|
4576
4670
|
})
|
|
@@ -4580,12 +4674,36 @@ window.__ModuleLoader__.load({
|
|
|
4580
4674
|
const [t] = (0, react.useState)(() => makeT(detectLang()));
|
|
4581
4675
|
const [tab, setTab] = (0, react.useState)("local");
|
|
4582
4676
|
const [epoch, setEpoch] = (0, react.useState)(0);
|
|
4677
|
+
/** Mirrors `epoch` without a render lag; the local leg compares it on resolve. */
|
|
4678
|
+
const epochRef = (0, react.useRef)(0);
|
|
4679
|
+
/**
|
|
4680
|
+
* Hand the picked path to the owner and close the dialog in one step.
|
|
4681
|
+
*
|
|
4682
|
+
* The owner adopts a picked path asynchronously (`createWorkspace`), and only
|
|
4683
|
+
* then flips `open` back to false. For the in-app browser that round trip is
|
|
4684
|
+
* a local listing, but the native chooser makes the operator wait for the OS
|
|
4685
|
+
* dialog to return and for the host to create the Workspace — and until the
|
|
4686
|
+
* owner's state lands, this dialog sits on screen. Operators reported it as
|
|
4687
|
+
* "the dialog only disappears after I click or press a key": that next input
|
|
4688
|
+
* is what re-rendered the owner's surface. `onCancel` is the same owner's
|
|
4689
|
+
* "withdraw the request / just close the flow" signal, so sending it with the
|
|
4690
|
+
* path closes immediately and independently of adoption timing; the owner's
|
|
4691
|
+
* own close is then a no-op. Cancel goes first so the dialog closes even if
|
|
4692
|
+
* the owner's picked-handler throws.
|
|
4693
|
+
*/
|
|
4694
|
+
const finish = (path) => {
|
|
4695
|
+
traceFlow("finish", path);
|
|
4696
|
+
props.onCancel();
|
|
4697
|
+
props.onPicked(path);
|
|
4698
|
+
};
|
|
4583
4699
|
const wasOpen = (0, react.useRef)(false);
|
|
4584
4700
|
(0, react.useEffect)(() => {
|
|
4585
4701
|
if (props.open && !wasOpen.current) {
|
|
4586
4702
|
setTab("local");
|
|
4587
|
-
|
|
4703
|
+
epochRef.current += 1;
|
|
4704
|
+
setEpoch(epochRef.current);
|
|
4588
4705
|
}
|
|
4706
|
+
traceFlow("open", props.open);
|
|
4589
4707
|
wasOpen.current = props.open;
|
|
4590
4708
|
}, [props.open]);
|
|
4591
4709
|
/**
|
|
@@ -4710,11 +4828,12 @@ window.__ModuleLoader__.load({
|
|
|
4710
4828
|
t,
|
|
4711
4829
|
busy: props.busy,
|
|
4712
4830
|
injected,
|
|
4713
|
-
|
|
4831
|
+
flowEpoch: epochRef,
|
|
4832
|
+
onPicked: finish
|
|
4714
4833
|
}, `local-${epoch}`) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RemoteLeg, {
|
|
4715
4834
|
t,
|
|
4716
4835
|
busy: props.busy,
|
|
4717
|
-
onPicked:
|
|
4836
|
+
onPicked: finish,
|
|
4718
4837
|
onCancel: props.onCancel
|
|
4719
4838
|
}, `remote-${epoch}`)
|
|
4720
4839
|
}),
|
|
@@ -41642,7 +41761,7 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
41642
41761
|
const primary = host.querySelectorAll("[class*=\"rvs-ck-\"]").length;
|
|
41643
41762
|
const fallback = host.querySelectorAll("span[class^=\"rvs-t-\"]").length;
|
|
41644
41763
|
const count = primary > 0 ? primary : fallback;
|
|
41645
|
-
console.info(`[dsh-remote-vs] build
|
|
41764
|
+
console.info(`[dsh-remote-vs] build 1118-1711 · ${source} · colored tokens: ${count} (${propsRef.current.path})`);
|
|
41646
41765
|
propsRef.current.onTokens?.(count);
|
|
41647
41766
|
};
|
|
41648
41767
|
const armFallback = () => {
|
|
@@ -49161,8 +49280,8 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
49161
49280
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConnectionStatusChip, { compact: true }),
|
|
49162
49281
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
49163
49282
|
className: "rvs-build",
|
|
49164
|
-
title: `dsh-remote-vs build
|
|
49165
|
-
children: "
|
|
49283
|
+
title: `dsh-remote-vs build 1118-1711`,
|
|
49284
|
+
children: "1118-1711"
|
|
49166
49285
|
}),
|
|
49167
49286
|
tokenCount !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
49168
49287
|
className: "rvs-build",
|
|
@@ -77317,6 +77436,7 @@ exit 0
|
|
|
77317
77436
|
}), "dsh-remote-vs: float on tab double-click");
|
|
77318
77437
|
ctx.effect(() => {
|
|
77319
77438
|
let dispose;
|
|
77439
|
+
let disposeNotices;
|
|
77320
77440
|
try {
|
|
77321
77441
|
const slots = ctx.slots;
|
|
77322
77442
|
dispose = slots.inject("shell.overlay", () => slots.register({
|
|
@@ -77324,16 +77444,25 @@ exit 0
|
|
|
77324
77444
|
id: "remote-vs:floating-editor",
|
|
77325
77445
|
order: 40
|
|
77326
77446
|
}, () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatingEditorWindow, { ctx })));
|
|
77447
|
+
disposeNotices = slots.inject("shell.overlay", () => slots.register({
|
|
77448
|
+
name: "shell.overlay",
|
|
77449
|
+
id: "remote-vs:toast-host",
|
|
77450
|
+
order: 41
|
|
77451
|
+
}, () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DialogHost, {})));
|
|
77327
77452
|
} catch (error) {
|
|
77328
77453
|
console.warn("[dsh-remote-vs] shell.overlay registration failed (floating editor unavailable):", error);
|
|
77329
77454
|
return () => {};
|
|
77330
77455
|
}
|
|
77331
77456
|
return () => {
|
|
77332
|
-
try {
|
|
77333
|
-
|
|
77457
|
+
for (const teardown of [dispose, disposeNotices]) try {
|
|
77458
|
+
teardown?.();
|
|
77334
77459
|
} catch {}
|
|
77335
77460
|
};
|
|
77336
77461
|
}, "dsh-remote-vs: floating editor window");
|
|
77462
|
+
ctx.effect(() => {
|
|
77463
|
+
setHostNoticeEmitter(toast);
|
|
77464
|
+
return () => setHostNoticeEmitter(void 0);
|
|
77465
|
+
}, "dsh-remote-vs: host notice toasts");
|
|
77337
77466
|
}
|
|
77338
77467
|
//#endregion
|
|
77339
77468
|
exports.apply = apply;
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as ensurePrivateDir, S as dshHome, T as storePath, _ as MIN_TIMEOUT_MS, a as helperAvailability, b as require_lib, c as seedHelperCache, d as attachmentHeader, f as DEFAULT_GIT_TIMEOUT_MS, g as MAX_TIMEOUT_MS, h as DeadlineError, i as drainHostNotices, l as RemoteFiles, m as DEFAULT_TIMEOUTS, n as TombstonedError, o as probe, p as DEFAULT_READ_TIMEOUT_MS, s as pushPipeline, t as RemoteWorlds, u as WriteConflictError, v as clampExecTimeout, w as keysDir, x as aliasRoot, y as resolveTimeouts } from "./worlds-DXdP4SMn.js";
|
|
2
2
|
import z from "@deepseek-ai/schemastery";
|
|
3
3
|
import { chmodSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, statSync, writeSync } from "node:fs";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -2094,11 +2094,16 @@ function isJsonObject(value) {
|
|
|
2094
2094
|
}
|
|
2095
2095
|
/** Write one JSON response. */
|
|
2096
2096
|
function writeJson(res, status, body, headers = {}) {
|
|
2097
|
+
const notices = typeof body === "object" && body !== null && !Array.isArray(body) ? drainHostNotices() : [];
|
|
2098
|
+
const payload = notices.length > 0 ? {
|
|
2099
|
+
...body,
|
|
2100
|
+
notices
|
|
2101
|
+
} : body;
|
|
2097
2102
|
res.writeHead(status, {
|
|
2098
2103
|
...JSON_HEADERS,
|
|
2099
2104
|
...headers
|
|
2100
2105
|
});
|
|
2101
|
-
res.end(JSON.stringify(
|
|
2106
|
+
res.end(JSON.stringify(payload));
|
|
2102
2107
|
}
|
|
2103
2108
|
/**
|
|
2104
2109
|
* Write one failed-operation response, tagging a budget that merely ran out.
|
package/lib/p2-router-fs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as isWindowsAbsolute, x as aliasRoot } from "./worlds-DXdP4SMn.js";
|
|
2
2
|
import { FileSystem, FsError } from "@deepseek-ai/dsh-fs";
|
|
3
3
|
//#region src/p2/router-fs.ts
|
|
4
4
|
/**
|
|
@@ -245,14 +245,13 @@ var TransparentFileSystem = class extends FileSystem {
|
|
|
245
245
|
}
|
|
246
246
|
/**
|
|
247
247
|
* alpha.3 added patch/delete/move to the FileSystem contract for the
|
|
248
|
-
* apply_patch tool.
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
* pin `applyPatch: false`), so this only matters when it is enabled.
|
|
248
|
+
* apply_patch tool. As of 0.23.0 every provider this plugin mounts implements
|
|
249
|
+
* all three — fs-ssh 0.2.2 talks the protocol-3 helper, which serves
|
|
250
|
+
* `fs.patch`/`fs.delete`/`fs.move` — so the guards below are defensive: they
|
|
251
|
+
* turn a thinner provider into a typed FsError instead of a TypeError.
|
|
253
252
|
*/
|
|
254
253
|
unsupportedRemote(what) {
|
|
255
|
-
return new FsError(`${what} is not supported
|
|
254
|
+
return new FsError(`${what} is not supported by the remote fs provider mounted for this world; run it in a local workspace`, "FS_IO_ERROR");
|
|
256
255
|
}
|
|
257
256
|
async patchText(target, hunks, expected, signal, sandboxPolicy) {
|
|
258
257
|
const { fs, world } = await this.backendOf(target);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client side of the Host's one-shot notices (`src/notices.ts`).
|
|
3
|
+
*
|
|
4
|
+
* The Host attaches notices to a JSON response when an automatic helper push ran
|
|
5
|
+
* during that request; the API wrapper calls {@link dispatchHostNotices} after
|
|
6
|
+
* parsing, and the message goes through the plugin's toast layer (bottom-right,
|
|
7
|
+
* auto-dismiss) so the event is visible wherever the user is — including the
|
|
8
|
+
* conversation view, where no remote-workspace surface is mounted.
|
|
9
|
+
*
|
|
10
|
+
* The emitter is REGISTERED by the client entry instead of imported here: this
|
|
11
|
+
* module sits on the API path, which several offline gates load with a
|
|
12
|
+
* TypeScript-only loader. Importing the JSX widget kit from `api.ts` would drag
|
|
13
|
+
* React components into those loaders (they cannot transpile JSX) for a message
|
|
14
|
+
* that only needs a string.
|
|
15
|
+
*/
|
|
16
|
+
import type { HostNotice } from '../notices.ts';
|
|
17
|
+
/** How the toast layer receives one rendered message. */
|
|
18
|
+
export type HostNoticeEmitter = (text: string) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Install (or remove) the toast emitter; the client entry owns the lifetime.
|
|
21
|
+
*
|
|
22
|
+
* Messages that arrived before the entry registered are flushed, so a notice
|
|
23
|
+
* produced during the first remote operation of a page load cannot be lost.
|
|
24
|
+
*/
|
|
25
|
+
export declare function setHostNoticeEmitter(next: HostNoticeEmitter | undefined): void;
|
|
26
|
+
/** Render one notice in the page language. */
|
|
27
|
+
export declare function formatHostNotice(notice: HostNotice, lang?: import("./i18n.ts").Lang): string;
|
|
28
|
+
/**
|
|
29
|
+
* Show every valid notice carried by one API response.
|
|
30
|
+
*
|
|
31
|
+
* `emit` is injectable so a gate can drive this without React or a DOM. A
|
|
32
|
+
* malformed payload is ignored: a newer/older peer must never turn a successful
|
|
33
|
+
* remote operation into a client exception.
|
|
34
|
+
*/
|
|
35
|
+
export declare function dispatchHostNotices(payload: unknown, emit?: HostNoticeEmitter): number;
|
package/lib/types/deploy.d.ts
CHANGED
|
@@ -49,8 +49,16 @@ export interface HelperCacheEntry {
|
|
|
49
49
|
protocol: number;
|
|
50
50
|
nodeVersion: string;
|
|
51
51
|
}
|
|
52
|
-
/**
|
|
53
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Wire protocol this plugin's `dsh-ssh` generation speaks (see MAINTENANCE §2.7).
|
|
54
|
+
*
|
|
55
|
+
* Derived from the installed package instead of hardcoded: helper and client
|
|
56
|
+
* handshake on a strict literal, so a constant that drifts from the package
|
|
57
|
+
* silently selects a helper the handshake will reject. Before 0.23.0 this was a
|
|
58
|
+
* hand-maintained `2`; the protocol-3 move (MAINTENANCE §2.51) is why it can no
|
|
59
|
+
* longer be a second source of truth.
|
|
60
|
+
*/
|
|
61
|
+
export declare const EXPECTED_HELPER_PROTOCOL = 3;
|
|
54
62
|
/** Absolute path of one cached helper tarball; throws when it is not inside the cache. */
|
|
55
63
|
export declare function helperTarballPath(helper: HelperCacheEntry, dir?: string): string;
|
|
56
64
|
/** Scan the local helper cache; invalid/incomplete entries are skipped. */
|
|
@@ -73,6 +81,24 @@ export declare function compareHelperVersions(left: string, right: string): numb
|
|
|
73
81
|
* then fail the runtime handshake, so it is not a candidate at all.
|
|
74
82
|
*/
|
|
75
83
|
export declare function pickCached(platform: string, version?: string, expectedProtocol?: number): HelperCacheEntry | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Wire protocol of the helper build a deploy record points at, when this machine
|
|
86
|
+
* still has that build cached.
|
|
87
|
+
*
|
|
88
|
+
* Upgrade-day support for `createRpc`: it re-runs the deploy pipeline only when
|
|
89
|
+
* the record carries NO helper, so a host deployed by an older plugin keeps
|
|
90
|
+
* dialing a binary from another protocol generation — both sides pin a literal,
|
|
91
|
+
* so the handshake can only fail and nothing self-heals. The local cache is the
|
|
92
|
+
* one place that still knows that build's protocol, so the record is classified
|
|
93
|
+
* here:
|
|
94
|
+
* - unknown build (not cached here, e.g. deployed from another machine) →
|
|
95
|
+
* `undefined`: keep the record and let the handshake report the real error;
|
|
96
|
+
* - cached build of THIS protocol → returns the expected value, so a deliberate
|
|
97
|
+
* rollback pin (an older build of the same generation) stays pinned;
|
|
98
|
+
* - cached build of ANOTHER protocol → returns the foreign value; the caller
|
|
99
|
+
* re-deploys instead of dialing a doomed handshake.
|
|
100
|
+
*/
|
|
101
|
+
export declare function protocolOfStoredHelper(binarySha256: string, platform: string | undefined, entries?: HelperCacheEntry[]): number | undefined;
|
|
76
102
|
/** Honest availability of the helper channels. */
|
|
77
103
|
export declare function helperAvailability(): HelperAvailability[];
|
|
78
104
|
export declare function isHelperAvailable(kind: HelperKind): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-shot notices the Host hands to the browser on the next JSON response.
|
|
3
|
+
*
|
|
4
|
+
* Why a queue instead of a push channel: the Host half is request/response, and
|
|
5
|
+
* an event that matters (an automatic helper push) is produced *inside* a
|
|
6
|
+
* request the browser already made — the remote operation that needed a dial.
|
|
7
|
+
* Attaching the notice to that response reaches the surface that caused it with
|
|
8
|
+
* no extra connection, and a queue means a push during a streaming response or
|
|
9
|
+
* a failed request still arrives on the next successful one.
|
|
10
|
+
*/
|
|
11
|
+
export interface HostNotice {
|
|
12
|
+
/** What happened. Only kinds the client knows how to render belong here. */
|
|
13
|
+
kind: 'helper-pushed';
|
|
14
|
+
/** Host alias the helper was pushed to. */
|
|
15
|
+
alias: string;
|
|
16
|
+
/** Helper version that was installed. */
|
|
17
|
+
version: string;
|
|
18
|
+
}
|
|
19
|
+
/** Queue one notice for the next JSON response. */
|
|
20
|
+
export declare function pushHostNotice(notice: HostNotice): void;
|
|
21
|
+
/** Take everything queued; the caller attaches it and the queue starts over. */
|
|
22
|
+
export declare function drainHostNotices(): HostNotice[];
|
|
@@ -90,11 +90,10 @@ export default class TransparentFileSystem extends FileSystem {
|
|
|
90
90
|
}, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsEditOutcome>;
|
|
91
91
|
/**
|
|
92
92
|
* alpha.3 added patch/delete/move to the FileSystem contract for the
|
|
93
|
-
* apply_patch tool.
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* pin `applyPatch: false`), so this only matters when it is enabled.
|
|
93
|
+
* apply_patch tool. As of 0.23.0 every provider this plugin mounts implements
|
|
94
|
+
* all three — fs-ssh 0.2.2 talks the protocol-3 helper, which serves
|
|
95
|
+
* `fs.patch`/`fs.delete`/`fs.move` — so the guards below are defensive: they
|
|
96
|
+
* turn a thinner provider into a typed FsError instead of a TypeError.
|
|
98
97
|
*/
|
|
99
98
|
private unsupportedRemote;
|
|
100
99
|
patchText(target: FsTarget, hunks: Parameters<FileSystem['patchText']>[1], expected?: {
|
package/lib/types/p2/worlds.d.ts
CHANGED
|
@@ -187,4 +187,14 @@ export declare class RemoteWorlds {
|
|
|
187
187
|
private assertDialAllowed;
|
|
188
188
|
private noteDialFailure;
|
|
189
189
|
private createRpc;
|
|
190
|
+
/**
|
|
191
|
+
* Queue a browser notice for an automatic helper push.
|
|
192
|
+
*
|
|
193
|
+
* Only a REAL push is announced: `skipped-same` means the host already runs
|
|
194
|
+
* this build (the self-heal case where an earlier push updated the remote),
|
|
195
|
+
* and announcing an upload that did not happen would be a lie. The notice
|
|
196
|
+
* rides the next JSON response (`src/notices.ts`), which is exactly the
|
|
197
|
+
* request whose dial needed the helper — the surface the user is looking at.
|
|
198
|
+
*/
|
|
199
|
+
private notifyHelperPush;
|
|
190
200
|
}
|
|
@@ -6,8 +6,8 @@ import { createHash, randomBytes } from "node:crypto";
|
|
|
6
6
|
import path, { dirname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
|
-
import { Context } from "@deepseek-ai/cordis";
|
|
10
9
|
import { SSH_PROTOCOL_VERSION, SshRpcPeer } from "@deepseek-ai/dsh-ssh/protocol";
|
|
10
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
11
11
|
import { helloSchema } from "@deepseek-ai/dsh-ssh/schemas";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
//#region \0rolldown/runtime.js
|
|
@@ -18449,6 +18449,16 @@ const HELPER_PLATFORMS = /* @__PURE__ */ new Set([
|
|
|
18449
18449
|
"macos-x64",
|
|
18450
18450
|
"macos-arm64"
|
|
18451
18451
|
]);
|
|
18452
|
+
/**
|
|
18453
|
+
* Wire protocol this plugin's `dsh-ssh` generation speaks (see MAINTENANCE §2.7).
|
|
18454
|
+
*
|
|
18455
|
+
* Derived from the installed package instead of hardcoded: helper and client
|
|
18456
|
+
* handshake on a strict literal, so a constant that drifts from the package
|
|
18457
|
+
* silently selects a helper the handshake will reject. Before 0.23.0 this was a
|
|
18458
|
+
* hand-maintained `2`; the protocol-3 move (MAINTENANCE §2.51) is why it can no
|
|
18459
|
+
* longer be a second source of truth.
|
|
18460
|
+
*/
|
|
18461
|
+
const EXPECTED_HELPER_PROTOCOL = SSH_PROTOCOL_VERSION;
|
|
18452
18462
|
/** Resolve one cached tarball, or `undefined` when the name escapes the cache dir. */
|
|
18453
18463
|
function safeHelperTarball(dir, tarball) {
|
|
18454
18464
|
if (typeof tarball !== "string" || tarball === "" || tarball === "." || tarball === "..") return void 0;
|
|
@@ -18551,11 +18561,31 @@ function compareHelperVersionsDesc(a, b) {
|
|
|
18551
18561
|
* choice: a cached build whose protocol does not match would install fine and
|
|
18552
18562
|
* then fail the runtime handshake, so it is not a candidate at all.
|
|
18553
18563
|
*/
|
|
18554
|
-
function pickCached(platform, version, expectedProtocol =
|
|
18564
|
+
function pickCached(platform, version, expectedProtocol = EXPECTED_HELPER_PROTOCOL) {
|
|
18555
18565
|
const matches = listCachedHelpers().filter((h) => h.platform === platform && h.protocol === expectedProtocol);
|
|
18556
18566
|
if (version !== void 0 && version !== "") return matches.find((h) => h.version === version);
|
|
18557
18567
|
return matches[0];
|
|
18558
18568
|
}
|
|
18569
|
+
/**
|
|
18570
|
+
* Wire protocol of the helper build a deploy record points at, when this machine
|
|
18571
|
+
* still has that build cached.
|
|
18572
|
+
*
|
|
18573
|
+
* Upgrade-day support for `createRpc`: it re-runs the deploy pipeline only when
|
|
18574
|
+
* the record carries NO helper, so a host deployed by an older plugin keeps
|
|
18575
|
+
* dialing a binary from another protocol generation — both sides pin a literal,
|
|
18576
|
+
* so the handshake can only fail and nothing self-heals. The local cache is the
|
|
18577
|
+
* one place that still knows that build's protocol, so the record is classified
|
|
18578
|
+
* here:
|
|
18579
|
+
* - unknown build (not cached here, e.g. deployed from another machine) →
|
|
18580
|
+
* `undefined`: keep the record and let the handshake report the real error;
|
|
18581
|
+
* - cached build of THIS protocol → returns the expected value, so a deliberate
|
|
18582
|
+
* rollback pin (an older build of the same generation) stays pinned;
|
|
18583
|
+
* - cached build of ANOTHER protocol → returns the foreign value; the caller
|
|
18584
|
+
* re-deploys instead of dialing a doomed handshake.
|
|
18585
|
+
*/
|
|
18586
|
+
function protocolOfStoredHelper(binarySha256, platform, entries = listCachedHelpers()) {
|
|
18587
|
+
return entries.find((entry) => entry.binarySha256 === binarySha256 && (platform === void 0 || entry.platform === platform))?.protocol;
|
|
18588
|
+
}
|
|
18559
18589
|
/** Honest availability of the helper channels. */
|
|
18560
18590
|
function helperAvailability() {
|
|
18561
18591
|
const cached = listCachedHelpers();
|
|
@@ -18955,6 +18985,23 @@ function shRoot(path) {
|
|
|
18955
18985
|
return `'${path.replace(/'/g, `'\\''`)}'`;
|
|
18956
18986
|
}
|
|
18957
18987
|
//#endregion
|
|
18988
|
+
//#region src/notices.ts
|
|
18989
|
+
/** Bounded so an unreachable client cannot grow Host memory without limit. */
|
|
18990
|
+
const MAX_PENDING$1 = 8;
|
|
18991
|
+
let pending = [];
|
|
18992
|
+
/** Queue one notice for the next JSON response. */
|
|
18993
|
+
function pushHostNotice(notice) {
|
|
18994
|
+
if (pending.length >= MAX_PENDING$1) return;
|
|
18995
|
+
pending = [...pending, notice];
|
|
18996
|
+
}
|
|
18997
|
+
/** Take everything queued; the caller attaches it and the queue starts over. */
|
|
18998
|
+
function drainHostNotices() {
|
|
18999
|
+
if (pending.length === 0) return [];
|
|
19000
|
+
const drained = pending;
|
|
19001
|
+
pending = [];
|
|
19002
|
+
return drained;
|
|
19003
|
+
}
|
|
19004
|
+
//#endregion
|
|
18958
19005
|
//#region src/p2/in-flight-gate.ts
|
|
18959
19006
|
var import_lib = require_lib();
|
|
18960
19007
|
/**
|
|
@@ -19925,13 +19972,14 @@ var RemoteWorlds = class {
|
|
|
19925
19972
|
reason: error instanceof Error ? error.message : String(error)
|
|
19926
19973
|
});
|
|
19927
19974
|
}
|
|
19928
|
-
async createRpc(alias) {
|
|
19975
|
+
async createRpc(alias, allowRedeploy = true) {
|
|
19929
19976
|
let deploy = this.deps.store.require(alias).deploy;
|
|
19930
19977
|
if (deploy?.artifact === void 0 || !deploy.artifact.startsWith("dsh-ssh-helper/") || deploy.helper === void 0) {
|
|
19931
19978
|
const failure = deployFailure(deploy);
|
|
19932
19979
|
if (failure !== void 0 && failure.retryInMs > 0) throw new Error(`helper deploy for ${alias} failed ${failure.attempts} time(s); next automatic attempt in ${Math.ceil(failure.retryInMs / 1e3)}s (deploy it again from Settings to force one now)`);
|
|
19933
19980
|
const report = await pushPipeline(this.deps.pool, this.deps.store, alias);
|
|
19934
19981
|
if (report.action === "failed") throw new Error(`helper auto-deploy failed: ${report.detail}`);
|
|
19982
|
+
if (report.action === "pushed") this.notifyHelperPush(alias, report);
|
|
19935
19983
|
deploy = this.deps.store.require(alias).deploy;
|
|
19936
19984
|
}
|
|
19937
19985
|
const helper = deploy?.helper;
|
|
@@ -19945,6 +19993,16 @@ var RemoteWorlds = class {
|
|
|
19945
19993
|
platform = platform && platform !== "" ? platform : probed.platform === "unknown" ? void 0 : probed.platform;
|
|
19946
19994
|
if (platform === void 0) throw new Error(`cannot locate helper platform for ${alias}`);
|
|
19947
19995
|
}
|
|
19996
|
+
const storedProtocol = protocolOfStoredHelper(helper.sha256, platform);
|
|
19997
|
+
if (allowRedeploy && storedProtocol !== void 0 && storedProtocol !== EXPECTED_HELPER_PROTOCOL) {
|
|
19998
|
+
try {
|
|
19999
|
+
this.ctx.logger.info(`[remote-vs] helper on ${alias} speaks wire protocol ${storedProtocol}, this build speaks ${EXPECTED_HELPER_PROTOCOL}; re-deploying before dialing`);
|
|
20000
|
+
} catch {}
|
|
20001
|
+
const report = await pushPipeline(this.deps.pool, this.deps.store, alias);
|
|
20002
|
+
if (report.action === "failed") throw new Error(`helper re-deploy after a wire-protocol change failed: ${report.detail}`);
|
|
20003
|
+
if (report.action === "pushed") this.notifyHelperPush(alias, report);
|
|
20004
|
+
return this.createRpc(alias, false);
|
|
20005
|
+
}
|
|
19948
20006
|
const helperPath = `${home}/.dsh-helpers/dsh-ssh-helper-${helper.version}-${platform}/dsh-ssh-helper`;
|
|
19949
20007
|
const conn = new RpcConnection({
|
|
19950
20008
|
entry: this.deps.store.require(alias),
|
|
@@ -19961,6 +20019,24 @@ var RemoteWorlds = class {
|
|
|
19961
20019
|
}
|
|
19962
20020
|
return conn;
|
|
19963
20021
|
}
|
|
20022
|
+
/**
|
|
20023
|
+
* Queue a browser notice for an automatic helper push.
|
|
20024
|
+
*
|
|
20025
|
+
* Only a REAL push is announced: `skipped-same` means the host already runs
|
|
20026
|
+
* this build (the self-heal case where an earlier push updated the remote),
|
|
20027
|
+
* and announcing an upload that did not happen would be a lie. The notice
|
|
20028
|
+
* rides the next JSON response (`src/notices.ts`), which is exactly the
|
|
20029
|
+
* request whose dial needed the helper — the surface the user is looking at.
|
|
20030
|
+
*/
|
|
20031
|
+
notifyHelperPush(alias, report) {
|
|
20032
|
+
const version = report.installed?.helper?.version ?? this.deps.store.require(alias).deploy?.helper?.version;
|
|
20033
|
+
if (version === void 0 || version === "") return;
|
|
20034
|
+
pushHostNotice({
|
|
20035
|
+
kind: "helper-pushed",
|
|
20036
|
+
alias,
|
|
20037
|
+
version
|
|
20038
|
+
});
|
|
20039
|
+
}
|
|
19964
20040
|
};
|
|
19965
20041
|
//#endregion
|
|
19966
|
-
export {
|
|
20042
|
+
export { ensurePrivateDir as C, dshHome as S, storePath as T, MIN_TIMEOUT_MS as _, helperAvailability as a, require_lib as b, seedHelperCache as c, attachmentHeader as d, DEFAULT_GIT_TIMEOUT_MS as f, MAX_TIMEOUT_MS as g, DeadlineError as h, drainHostNotices as i, RemoteFiles as l, DEFAULT_TIMEOUTS as m, TombstonedError as n, probe as o, DEFAULT_READ_TIMEOUT_MS as p, isWindowsAbsolute as r, pushPipeline as s, RemoteWorlds as t, WriteConflictError as u, clampExecTimeout as v, keysDir as w, aliasRoot as x, resolveTimeouts as y };
|