dsh-remote-go 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +11 -3
  2. package/{client.js → dist/client.js} +7144 -8367
  3. package/dist/index.js +4 -0
  4. package/dist/src/admission.js +21 -0
  5. package/dist/src/api.js +380 -0
  6. package/dist/src/atomic-json.js +201 -0
  7. package/dist/src/bootstrap.js +96 -0
  8. package/dist/src/connect/attach.js +21 -0
  9. package/dist/src/connect/bootstrap.js +8 -0
  10. package/dist/src/connect/failures.js +29 -0
  11. package/dist/src/connect/guards.js +36 -0
  12. package/dist/src/connect/launch.js +70 -0
  13. package/dist/src/connect/links.js +54 -0
  14. package/dist/src/connect/ownership.js +139 -0
  15. package/dist/src/connect/pipeline.js +376 -0
  16. package/dist/src/connect/reattach.js +191 -0
  17. package/dist/src/connect/registry.js +10 -0
  18. package/dist/src/connect/repair.js +97 -0
  19. package/dist/src/connect/restart.js +255 -0
  20. package/dist/src/connect/stop.js +164 -0
  21. package/dist/src/connect/transport.js +101 -0
  22. package/dist/src/connect/verify.js +30 -0
  23. package/dist/src/connect/watchdog.js +44 -0
  24. package/dist/src/connect-log.js +137 -0
  25. package/dist/src/connect-progress.js +110 -0
  26. package/dist/src/constants.js +29 -0
  27. package/dist/src/context.js +96 -0
  28. package/dist/src/diagnostics.js +133 -0
  29. package/dist/src/download-jobs.js +221 -0
  30. package/dist/src/errors.js +228 -0
  31. package/dist/src/events.js +326 -0
  32. package/dist/src/host-lifecycle.js +368 -0
  33. package/dist/src/host-registry.js +181 -0
  34. package/dist/src/host-runtime.js +77 -0
  35. package/dist/src/host-view.js +52 -0
  36. package/dist/src/index.js +196 -0
  37. package/dist/src/kernel-adapter.js +388 -0
  38. package/dist/src/key-files.js +39 -0
  39. package/dist/src/known-hosts.js +104 -0
  40. package/dist/src/layout.js +26 -0
  41. package/dist/src/local-download.js +311 -0
  42. package/dist/src/local-ssh.js +23 -0
  43. package/dist/src/local-version.js +87 -0
  44. package/dist/src/node/download.js +157 -0
  45. package/dist/src/node-runtime.js +327 -0
  46. package/dist/src/probe.js +95 -0
  47. package/dist/src/prompts.js +198 -0
  48. package/dist/src/proxy/cookies.js +102 -0
  49. package/dist/src/proxy/headers.js +167 -0
  50. package/dist/src/proxy/http.js +134 -0
  51. package/dist/src/proxy/index.js +121 -0
  52. package/dist/src/proxy/limits.js +6 -0
  53. package/dist/src/proxy/routes.js +32 -0
  54. package/dist/src/proxy/upgrade.js +160 -0
  55. package/dist/src/redact.js +85 -0
  56. package/dist/src/remote-files.js +60 -0
  57. package/dist/src/remote-path.js +82 -0
  58. package/dist/src/remote-proc.js +271 -0
  59. package/dist/src/remote-web/registry.js +107 -0
  60. package/dist/src/remote-web/resolve.js +229 -0
  61. package/dist/src/remote-web/start.js +190 -0
  62. package/dist/src/remote-web/stop.js +74 -0
  63. package/dist/src/request-trust.js +70 -0
  64. package/dist/src/runtime/dispatch.js +200 -0
  65. package/dist/src/runtime/effects.js +81 -0
  66. package/dist/src/runtime/events.js +35 -0
  67. package/dist/src/runtime/fsm.js +70 -0
  68. package/dist/src/runtime/rules.js +480 -0
  69. package/dist/src/secrets.js +119 -0
  70. package/dist/src/service.js +300 -0
  71. package/dist/src/settings.js +143 -0
  72. package/dist/src/ssh-config.js +257 -0
  73. package/dist/src/ssh-failures.js +71 -0
  74. package/dist/src/ssh-port.js +4 -0
  75. package/dist/src/ssh-sftp.js +258 -0
  76. package/dist/src/ssh.js +395 -0
  77. package/dist/src/store.js +174 -0
  78. package/dist/src/tool-shared.js +146 -0
  79. package/dist/src/tools-exec-policy.js +121 -0
  80. package/dist/src/tools-exec.js +307 -0
  81. package/dist/src/tools-report.js +357 -0
  82. package/dist/src/tools.js +337 -0
  83. package/dist/src/tunnel.js +111 -0
  84. package/dist/src/util.js +112 -0
  85. package/dist/src/version.js +108 -0
  86. package/dist/src/watchdog-bus.js +21 -0
  87. package/dist/src/watchdog.js +116 -0
  88. package/index.js +5 -4
  89. package/locale/en.json +1 -1
  90. package/locale/zh.json +1 -1
  91. package/package.json +37 -19
  92. package/src/admission.js +0 -43
  93. package/src/api.js +0 -536
  94. package/src/atomic-json.js +0 -225
  95. package/src/bootstrap.js +0 -113
  96. package/src/connect-log.js +0 -176
  97. package/src/connect-pipeline.js +0 -1900
  98. package/src/connect-progress.js +0 -155
  99. package/src/constants.js +0 -93
  100. package/src/diagnostics.js +0 -160
  101. package/src/download-jobs.js +0 -234
  102. package/src/errors.js +0 -412
  103. package/src/host-lifecycle.js +0 -604
  104. package/src/host-registry.js +0 -217
  105. package/src/host-runtime.js +0 -127
  106. package/src/host-view.js +0 -75
  107. package/src/index.js +0 -206
  108. package/src/key-files.js +0 -54
  109. package/src/known-hosts.js +0 -133
  110. package/src/layout.js +0 -53
  111. package/src/local-download.js +0 -381
  112. package/src/local-ssh.js +0 -27
  113. package/src/local-version.js +0 -88
  114. package/src/node-runtime.js +0 -521
  115. package/src/probe.js +0 -101
  116. package/src/prompts.js +0 -229
  117. package/src/redact.js +0 -68
  118. package/src/remote-files.js +0 -71
  119. package/src/remote-path.js +0 -137
  120. package/src/remote-proc.js +0 -343
  121. package/src/remote-proxy.js +0 -815
  122. package/src/remote-web.js +0 -751
  123. package/src/request-trust.js +0 -89
  124. package/src/secrets.js +0 -109
  125. package/src/service.js +0 -459
  126. package/src/settings.js +0 -163
  127. package/src/ssh-config.js +0 -271
  128. package/src/ssh.js +0 -731
  129. package/src/store.js +0 -193
  130. package/src/tools.js +0 -386
  131. package/src/tunnel.js +0 -132
  132. package/src/util.js +0 -153
  133. package/src/version.js +0 -103
  134. package/src/webapp.js +0 -43
  135. /package/{vendor → dist/vendor}/ssh2.bundle.cjs +0 -0
@@ -0,0 +1,21 @@
1
+ export function createWatchdogBus(options = {}) {
2
+ const listeners = new Set();
3
+ return {
4
+ publish(event) {
5
+ for (const listener of [...listeners]) {
6
+ try {
7
+ listener(event);
8
+ }
9
+ catch (error) {
10
+ options.warn?.('[dsh-remote-go] watchdog listener failed:', error);
11
+ }
12
+ }
13
+ },
14
+ subscribe(listener) {
15
+ listeners.add(listener);
16
+ return () => {
17
+ listeners.delete(listener);
18
+ };
19
+ },
20
+ };
21
+ }
@@ -0,0 +1,116 @@
1
+ /** The liveness watchdog: the heartbeat probe, the episode it opens when the remote UI stops answering, and the two
2
+ * action requests it turns into bus events. It never imports `connect/*`: an episode is published on `ctx.bus`, and
3
+ * `connect/watchdog.ts` — its only subscriber — runs the action. The timer primitives stay in `host-lifecycle.ts`. */
4
+ import { REMOTE_EPISODE_COOLDOWN_MS, REMOTE_HEARTBEAT_DEFAULT_SEC, REMOTE_HEARTBEAT_MAX_SEC, REMOTE_HEARTBEAT_MIN_SEC, REMOTE_UNREACHABLE_FAILURES, } from './constants.js';
5
+ import { cancelRemoteCheck, stopRemoteHeartbeat } from './host-lifecycle.js';
6
+ import { isUiUp } from './remote-proc.js';
7
+ export function remoteHeartbeatIntervalSec(ctx) {
8
+ const seconds = Number(ctx.settings()?.remoteHeartbeat?.intervalSec);
9
+ if (!Number.isFinite(seconds))
10
+ return REMOTE_HEARTBEAT_DEFAULT_SEC;
11
+ return Math.min(REMOTE_HEARTBEAT_MAX_SEC, Math.max(REMOTE_HEARTBEAT_MIN_SEC, Math.round(seconds)));
12
+ }
13
+ export function startRemoteHeartbeat(ctx, runtime) {
14
+ stopRemoteHeartbeat(runtime);
15
+ const enabled = ctx.settings()?.remoteHeartbeat?.enabled !== false;
16
+ if (!enabled) {
17
+ ctx.progress.log(runtime, 'debug', 'remote heartbeat: disabled by settings');
18
+ return;
19
+ }
20
+ const intervalSec = remoteHeartbeatIntervalSec(ctx);
21
+ runtime.heartbeatTimer = setInterval(() => {
22
+ void remoteHeartbeatTick(ctx, runtime);
23
+ }, intervalSec * 1000);
24
+ runtime.heartbeatTimer.unref?.();
25
+ ctx.progress.log(runtime, 'debug', `remote heartbeat: probing every ${intervalSec}s`);
26
+ }
27
+ export function watchable(ctx, runtime) {
28
+ return (ctx.state.disposed !== true &&
29
+ runtime.desired === 'connected' &&
30
+ runtime.status === 'connected' &&
31
+ runtime.linkBusy === null &&
32
+ runtime.ssh?.connected === true &&
33
+ runtime.tunnel !== null);
34
+ }
35
+ function beginRemoteEpisode(ctx, runtime, source) {
36
+ if (runtime.remoteEpisode === true)
37
+ return false;
38
+ const transient = source === 'proxy' || source === 'tunnel';
39
+ // A flapping tunnel must not emit suspected/recovered on every request: after a confirmed-healthy
40
+ // episode the same kind of transient report is ignored for the cooldown window.
41
+ if (transient && Date.now() < (Number(runtime.episodeCooldownUntil) || 0)) {
42
+ ctx.progress.log(runtime, 'debug', `remote-unreachable reported again (${source}); episode cooldown, ignoring`);
43
+ return false;
44
+ }
45
+ runtime.remoteEpisode = true;
46
+ runtime.episodeSource = source;
47
+ ctx.progress.log(runtime, 'debug', `remote-unreachable suspected (${source}); confirming with probes`);
48
+ ctx.onRemoteUnreachable?.(runtime, { phase: 'suspected', source });
49
+ return true;
50
+ }
51
+ function clearRemoteEpisode(ctx, runtime, source) {
52
+ const wasOpen = runtime.remoteEpisode === true;
53
+ const transient = runtime.episodeSource === 'proxy' || runtime.episodeSource === 'tunnel';
54
+ runtime.remoteEpisode = false;
55
+ runtime.remoteFailures = 0;
56
+ if (!wasOpen)
57
+ return;
58
+ runtime.episodeSource = null;
59
+ if (transient)
60
+ runtime.episodeCooldownUntil = Date.now() + REMOTE_EPISODE_COOLDOWN_MS;
61
+ ctx.bus.publish({ kind: 'recovered', hostId: runtime.id, source });
62
+ }
63
+ function scheduleRemoteCheck(ctx, runtime, source, delayMs) {
64
+ if (runtime.remoteCheckTimer)
65
+ return;
66
+ runtime.remoteCheckTimer = setTimeout(() => {
67
+ runtime.remoteCheckTimer = null;
68
+ void checkRemoteNow(ctx, runtime, source);
69
+ }, delayMs);
70
+ runtime.remoteCheckTimer.unref?.();
71
+ }
72
+ async function checkRemoteNow(ctx, runtime, source) {
73
+ if (!watchable(ctx, runtime) || typeof ctx.deps.remoteStatus !== 'function')
74
+ return;
75
+ const ssh = runtime.ssh;
76
+ const port = runtime.remote.port;
77
+ let status = null;
78
+ try {
79
+ status = await ctx.deps.remoteStatus(ssh, port);
80
+ }
81
+ catch {
82
+ // swallow-ok: an unreachable probe is a failed probe, handled by the same counter
83
+ status = null;
84
+ }
85
+ if (!watchable(ctx, runtime) || runtime.ssh !== ssh)
86
+ return;
87
+ if (isUiUp(status)) {
88
+ clearRemoteEpisode(ctx, runtime, source);
89
+ return;
90
+ }
91
+ runtime.remoteFailures = (Number(runtime.remoteFailures) || 0) + 1;
92
+ ctx.progress.log(runtime, 'debug', `remote heartbeat: probe failed (HTTP ${status ?? 'none'}), ${runtime.remoteFailures}/${REMOTE_UNREACHABLE_FAILURES} (${source})`);
93
+ beginRemoteEpisode(ctx, runtime, source);
94
+ if (runtime.remoteFailures < REMOTE_UNREACHABLE_FAILURES) {
95
+ scheduleRemoteCheck(ctx, runtime, source, ctx.timers.remoteRecheckMs);
96
+ return;
97
+ }
98
+ ctx.progress.log(runtime, 'warn', `remote-unreachable: ${runtime.remoteFailures} consecutive probes failed (${source}); re-attaching`);
99
+ ctx.onRemoteUnreachable?.(runtime, { phase: 'confirmed', source, failures: runtime.remoteFailures });
100
+ cancelRemoteCheck(runtime);
101
+ ctx.bus.publish({ kind: 'confirmed', hostId: runtime.id, reason: `probe-failed-${runtime.remoteFailures}`, source });
102
+ }
103
+ export async function remoteHeartbeatTick(ctx, runtime) {
104
+ if (!watchable(ctx, runtime))
105
+ return;
106
+ if (runtime.remoteCheckTimer)
107
+ return;
108
+ await checkRemoteNow(ctx, runtime, 'heartbeat');
109
+ }
110
+ export function noteRemoteUnreachable(ctx, runtime, source) {
111
+ if (!watchable(ctx, runtime))
112
+ return;
113
+ if (!beginRemoteEpisode(ctx, runtime, source))
114
+ return;
115
+ scheduleRemoteCheck(ctx, runtime, source, ctx.timers.remoteConfirmDelayMs);
116
+ }
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
- /**
2
- * Package entry for the DSH Loader. The implementation lives in `src/`.
3
- */
4
- export { apply, inject, name, optional } from './src/index.js'
1
+ // The Cordis loader resolves a linked plugin by its directory entry (`<dir>/index.js`), not
2
+ // through package exports, so a `link:` install needs this file to exist. It is a one-line shim:
3
+ // the implementation is the build output in `dist/`, and `exports["."]` names the same file for
4
+ // consumers that resolve by exports.
5
+ export { apply, inject, name, optional } from './dist/index.js'
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "dsh-remote-go",
4
- "description": "Use a remote DSH over SSH inside your local DSH: the sidebar host bar switches between Local and each host, the remote UI takes over the whole window and comes back without reloading; the connect flow shows staged progress and a live log, and you can restart or stop the remote DSH, download remote files and folders, and expose a read-only host list to local AI sessions. The remote runs on a plugin-managed Node with npx pinned to the local version, keeping its data in the remote ~/.dsh."
4
+ "description": "Use a remote DSH over SSH inside your local DSH: the sidebar host bar switches between Local and each host, the remote UI takes over the whole window and comes back without reloading; the connect flow shows staged progress and a live log, and you can restart or stop the remote DSH, download remote files and folders, and give local AI sessions a host list, a diagnosis report and a guarded remote command (hidden until the session unlocks them). The remote runs on a plugin-managed Node with npx pinned to the local version, keeping its data in the remote ~/.dsh."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "dsh-remote-go",
4
- "description": "在本地 DSH 里通过 SSH 使用远端 DSH:侧边栏主机条在「本地」与各主机间切换,远端界面整窗接管、切回不重载;连接过程有阶段进度和实时日志,可重启/关闭远端 DSH、下载远端文件与文件夹,并向本地 AI 会话提供只读主机列表。远端由插件自带的 Node + npx 按本机版本启动,数据留在远端 ~/.dsh。"
4
+ "description": "在本地 DSH 里通过 SSH 使用远端 DSH:侧边栏主机条在「本地」与各主机间切换,远端界面整窗接管、切回不重载;连接过程有阶段进度和实时日志,可重启/关闭远端 DSH、下载远端文件与文件夹,并向本地 AI 会话提供主机清单、体检报告与受控远端命令(默认隐藏,按需解锁)。远端由插件自带的 Node + npx 按本机版本启动,数据留在远端 ~/.dsh。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-remote-go",
3
- "version": "0.2.0",
4
- "description": "DSH 插件:在本地 DSH 里通过 SSH 使用远端 DSH(主机条切换、整窗接管、连接进度与日志、重启/关闭远端、远端文件下载、只读主机列表;插件自带 Node + npx,数据留在远端 ~/.dsh) | DSH plugin: use a remote DSH over SSH inside your local DSH (host switcher, full-window UI, connect progress and log, remote restart/stop, remote file downloads, read-only host list; plugin-managed Node + npx, data stays in the remote ~/.dsh)",
3
+ "version": "0.3.1",
4
+ "description": "DSH 插件:在本地 DSH 里通过 SSH 使用远端 DSH(主机条切换、整窗接管、连接进度与日志、重启/关闭远端、远端文件下载、给本地 AI 会话的主机清单 / 体检报告 / 受控远端命令,三者默认隐藏按需解锁;插件自带 Node + npx,数据留在远端 ~/.dsh) | DSH plugin: use a remote DSH over SSH inside your local DSH (host switcher, full-window UI, connect progress and log, remote restart/stop, remote file downloads, and a host list / diagnosis report / guarded remote command for local AI sessions — hidden until the session unlocks them; plugin-managed Node + npx, data stays in the remote ~/.dsh)",
5
5
  "keywords": [
6
6
  "deepseek",
7
7
  "harness",
@@ -28,19 +28,18 @@
28
28
  "node": ">=24"
29
29
  },
30
30
  "sideEffects": [
31
- "./client.js"
31
+ "./dist/client.js"
32
32
  ],
33
+ "main": "./index.js",
33
34
  "exports": {
34
35
  ".": "./index.js",
35
- "./client": "./client.js",
36
+ "./client": "./dist/client.js",
36
37
  "./locale/*.json": "./locale/*.json",
37
38
  "./package.json": "./package.json"
38
39
  },
39
40
  "files": [
40
41
  "index.js",
41
- "client.js",
42
- "src",
43
- "vendor/ssh2.bundle.cjs",
42
+ "dist",
44
43
  "vendor/THIRD_PARTY_NOTICES.md",
45
44
  "locale",
46
45
  "cordis.patch.yml",
@@ -66,36 +65,55 @@
66
65
  },
67
66
  "dependencies": {},
68
67
  "devDependencies": {
69
- "esbuild": "^0.28.2",
68
+ "@types/node": "^24.19.2",
69
+ "@types/react": "^19.3.0",
70
+ "esbuild": "0.28.2",
70
71
  "js-yaml": "^5.5.0",
71
72
  "prettier": "^3.10.1",
72
73
  "puppeteer-core": "^25.17.0",
73
74
  "react": "^19.3.1",
74
75
  "react-dom": "^19.3.1",
75
- "ssh2": "1.17.0"
76
+ "ssh2": "1.17.0",
77
+ "typescript": "^5.9.3"
76
78
  },
77
79
  "scripts": {
78
- "test": "node --test \"test/unit/*.test.js\"",
79
- "test:unit": "node --test \"test/unit/*.test.js\"",
80
- "test:web": "node --test \"test/integration/web.e2e.js\"",
81
- "test:desktop": "node --test \"test/integration/desktop.e2e.js\"",
82
- "test:integration": "node --test --test-concurrency=1 \"test/integration/*.test.js\" \"test/integration/*.e2e.js\"",
83
- "test:integration:local": "node --test --test-concurrency=1 test/integration/sim.test.js test/integration/remote-restart.test.js test/integration/stop-remote.test.js",
84
- "test:integration:external": "node --test --test-concurrency=1 test/integration/client-ui.test.js test/integration/remote-proxy.test.js test/integration/web.e2e.js test/integration/browser-carrier.test.js test/integration/guest-tools.e2e.js test/integration/stop-remote.browser.test.js",
80
+ "pretest": "pnpm build",
81
+ "test": "node --test \"test/unit/*.test.ts\"",
82
+ "pretest:unit": "pnpm build",
83
+ "test:unit": "node --test \"test/unit/*.test.ts\"",
84
+ "pretest:web": "pnpm build",
85
+ "test:web": "node --test \"test/integration/web.e2e.ts\"",
86
+ "pretest:desktop": "pnpm build",
87
+ "test:desktop": "node --test \"test/integration/desktop.e2e.ts\"",
88
+ "pretest:integration": "pnpm build",
89
+ "test:integration": "node --test --test-concurrency=1 \"test/integration/*.test.ts\" \"test/integration/*.e2e.ts\"",
90
+ "pretest:integration:local": "pnpm build",
91
+ "test:integration:local": "node --test --test-concurrency=1 test/integration/sim.test.ts test/integration/remote-restart.test.ts test/integration/stop-remote.test.ts",
92
+ "pretest:integration:external": "pnpm build",
93
+ "test:integration:external": "node --test --test-concurrency=1 test/integration/client-ui.test.ts test/integration/remote-proxy.test.ts test/integration/web.e2e.ts test/integration/browser-carrier.test.ts test/integration/guest-tools.e2e.ts test/integration/stop-remote.browser.test.ts",
94
+ "presim:remote": "pnpm build",
85
95
  "sim:remote": "node e2e/sim/simulated-remote.mjs --self-test",
96
+ "pretest:coverage": "pnpm build",
86
97
  "test:coverage": "node scripts/check-coverage.mjs",
87
98
  "lint": "node scripts/check-repo.mjs",
88
99
  "check:repo": "node scripts/check-repo.mjs",
100
+ "check:arch": "node scripts/check-architecture.mjs",
89
101
  "check:syntax": "node scripts/check-syntax.mjs",
90
102
  "check:workflows": "node scripts/check-workflows.mjs",
91
103
  "check:pr-title": "node scripts/check-pr-title.mjs",
92
104
  "format": "prettier --write .",
93
105
  "format:check": "prettier --check .",
94
- "gate": "node scripts/check-repo.mjs && prettier --check . && node scripts/check-syntax.mjs && node scripts/check-workflows.mjs && node scripts/pack-check.mjs && node scripts/check-coverage.mjs",
95
- "verify": "node scripts/check-repo.mjs && prettier --check . && node scripts/check-syntax.mjs && node scripts/check-workflows.mjs && node scripts/pack-check.mjs && node scripts/check-coverage.mjs && node --test --test-concurrency=1 \"test/integration/*.test.js\" \"test/integration/*.e2e.js\"",
106
+ "gate": "pnpm build && node scripts/check-repo.mjs && node scripts/check-architecture.mjs && prettier --check . && node scripts/check-syntax.mjs && node scripts/check-workflows.mjs && node scripts/pack-check.mjs && node scripts/verify-artifacts.mjs && pnpm run verify:types && node scripts/check-coverage.mjs && pnpm pack --pack-destination artifacts && node scripts/pack-check.mjs --find artifacts",
107
+ "verify": "pnpm build && node scripts/check-repo.mjs && node scripts/check-architecture.mjs && prettier --check . && node scripts/check-syntax.mjs && node scripts/check-workflows.mjs && node scripts/pack-check.mjs && node scripts/verify-artifacts.mjs && pnpm run verify:types && node scripts/check-coverage.mjs && node --test --test-concurrency=1 \"test/integration/*.test.ts\" \"test/integration/*.e2e.ts\"",
108
+ "build": "node scripts/build.mjs && node scripts/build-client.mjs",
109
+ "clean": "node scripts/clean.mjs",
110
+ "build:client": "node scripts/build-client.mjs",
111
+ "typecheck:client": "node node_modules/typescript/bin/tsc -p client/tsconfig.json --noEmit",
112
+ "verify:artifacts": "node scripts/verify-artifacts.mjs",
113
+ "verify:types": "node scripts/build.mjs --noEmit && pnpm run typecheck:client && node scripts/check-types.mjs --stage P7 --strict",
96
114
  "build:vendor": "node scripts/build-vendor.mjs",
97
115
  "pack:check": "node scripts/pack-check.mjs",
98
116
  "pack:check:tarball": "node scripts/pack-check.mjs --find artifacts",
99
- "prepack": "node scripts/build-vendor.mjs && git diff --exit-code -- vendor/"
117
+ "prepack": "node scripts/build-vendor.mjs && git diff --exit-code -- vendor/ && pnpm build && node scripts/verify-artifacts.mjs"
100
118
  }
101
119
  }
package/src/admission.js DELETED
@@ -1,43 +0,0 @@
1
- /**
2
- * DSH's own admission for the routes this plugin serves.
3
- *
4
- * The kernel decides whether a request may reach a Host feature at all: its `Host`/`Origin` fence
5
- * plus browser authentication against a live Peer (`ctx.connection.requestRejection`). This module
6
- * is the one place that turns that service into a per-request function, so the local API and the
7
- * same-origin proxy share the gate and both failure modes stay testable.
8
- */
9
-
10
- /**
11
- * Build the admission gate for one plugin activation.
12
- *
13
- * `connection` is optional and has to be read through `ctx.get`: Cordis throws when a plugin reads
14
- * a service its fiber did not inject, and an older kernel may not provide the service at all. In
15
- * both cases the gate returns `undefined`, which hands the request to the caller's own fence
16
- * instead of going dark. A gate that throws while judging a request returns `500` — failing closed,
17
- * because a check that cannot decide must never admit.
18
- *
19
- * @param {object} ctx - plugin context; only `ctx.get` is read, and it may be missing in tests.
20
- * @param {{ warn?: (...args: any[]) => void }} [logger]
21
- * @returns {(req: { headers: object }) => (number | undefined)} rejection status, or undefined to admit.
22
- */
23
- export function createAdmission(ctx, logger = console) {
24
- const warn = typeof logger.warn === 'function' ? logger.warn.bind(logger) : () => {}
25
-
26
- return (req) => {
27
- let connection = null
28
- try {
29
- connection = typeof ctx?.get === 'function' ? ctx.get('connection') : null
30
- } catch (error) {
31
- // A failed lookup says nothing about this request, so the caller's own fence decides it.
32
- warn('[dsh-remote-go] DSH connection lookup failed; the local fence stays the only gate:', error)
33
- return undefined
34
- }
35
- if (!connection || typeof connection.requestRejection !== 'function') return undefined
36
- try {
37
- return connection.requestRejection(req)
38
- } catch (error) {
39
- warn('[dsh-remote-go] DSH connection admission failed; rejecting the request:', error)
40
- return 500
41
- }
42
- }
43
- }