super-dsh 0.1.6 → 0.1.10-e

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 (260) hide show
  1. package/README.md +25 -3
  2. package/agent-agy/cordis.patch.yml +7 -4
  3. package/agent-agy/dist/agent.d.ts +12 -11
  4. package/agent-agy/dist/agy-auth-gateway.d.ts +124 -0
  5. package/agent-agy/dist/agy-auth-gateway.js +233 -0
  6. package/agent-agy/dist/agy-auth.d.ts +153 -0
  7. package/agent-agy/dist/agy-auth.js +179 -0
  8. package/agent-agy/dist/agy-cli-client.d.ts +39 -9
  9. package/agent-agy/dist/agy-cli-client.js +82 -18
  10. package/agent-agy/dist/agy-store.d.ts +8 -0
  11. package/agent-agy/dist/index.d.ts +46 -16
  12. package/agent-agy/dist/index.js +82 -56
  13. package/agent-agy/dist/models.d.ts +70 -0
  14. package/agent-agy/dist/models.js +102 -3
  15. package/agent-agy/package.json +7 -5
  16. package/agent-agy-sdk/cordis.patch.yml +58 -0
  17. package/agent-agy-sdk/dist/adapter.d.ts +15 -0
  18. package/agent-agy-sdk/dist/adapter.js +42 -0
  19. package/agent-agy-sdk/dist/agent-preset-agy.d.ts +27 -0
  20. package/agent-agy-sdk/dist/agent-preset-agy.js +32 -0
  21. package/agent-agy-sdk/dist/agent.d.ts +138 -0
  22. package/agent-agy-sdk/dist/agent.js +494 -0
  23. package/{agent-agy → agent-agy-sdk}/dist/agy-client.d.ts +26 -6
  24. package/{agent-agy → agent-agy-sdk}/dist/agy-client.js +43 -25
  25. package/agent-agy-sdk/dist/agy-sessions.d.ts +25 -0
  26. package/agent-agy-sdk/dist/agy-sessions.js +107 -0
  27. package/agent-agy-sdk/dist/agy-store.d.ts +39 -0
  28. package/agent-agy-sdk/dist/agy-store.js +83 -0
  29. package/agent-agy-sdk/dist/inbox.d.ts +26 -0
  30. package/agent-agy-sdk/dist/inbox.js +53 -0
  31. package/agent-agy-sdk/dist/index.d.ts +93 -0
  32. package/agent-agy-sdk/dist/index.js +476 -0
  33. package/agent-agy-sdk/dist/models.d.ts +41 -0
  34. package/agent-agy-sdk/dist/models.js +74 -0
  35. package/agent-agy-sdk/dist/sdk-venv.d.ts +76 -0
  36. package/agent-agy-sdk/dist/sdk-venv.js +173 -0
  37. package/agent-agy-sdk/dist/world-plugin.d.ts +10 -0
  38. package/agent-agy-sdk/dist/world-plugin.js +82 -0
  39. package/agent-agy-sdk/package.json +64 -0
  40. package/agent-claude/dist/adapter.js +106 -31
  41. package/agent-claude/dist/agent.js +154 -17
  42. package/agent-claude/dist/claude-client.js +84 -43
  43. package/agent-claude/dist/claude-launch.js +101 -0
  44. package/agent-claude/dist/claude-native-config.js +169 -0
  45. package/agent-claude/dist/claude-provider-gateway.js +340 -0
  46. package/agent-claude/dist/claude-providers.js +391 -0
  47. package/agent-claude/dist/claude-route.js +152 -0
  48. package/agent-claude/dist/index.js +214 -37
  49. package/agent-claude/dist/models.js +14 -0
  50. package/agent-claude/dist/sdk-runtime.js +320 -0
  51. package/agent-claude/package.json +6 -4
  52. package/agent-codex/README.md +141 -36
  53. package/agent-codex/cordis.patch.yml +14 -10
  54. package/agent-codex/dist/adapter.js +64 -28
  55. package/agent-codex/dist/agent.js +255 -81
  56. package/agent-codex/dist/app-server-approvals.js +165 -0
  57. package/agent-codex/dist/app-server-client.js +723 -0
  58. package/agent-codex/dist/app-server-events.js +432 -0
  59. package/agent-codex/dist/app-server-protocol.js +95 -0
  60. package/agent-codex/dist/app-server-wire.js +299 -0
  61. package/agent-codex/dist/codex-launch.js +78 -0
  62. package/agent-codex/dist/codex-native-config.js +392 -0
  63. package/agent-codex/dist/codex-provider-gateway.js +402 -0
  64. package/agent-codex/dist/codex-providers.js +376 -0
  65. package/agent-codex/dist/codex-route.js +86 -0
  66. package/agent-codex/dist/index.js +256 -115
  67. package/agent-codex/dist/permission.js +75 -1
  68. package/agent-codex/package.json +1 -2
  69. package/agent-codex-sdk/README.md +79 -0
  70. package/agent-codex-sdk/cordis.patch.yml +81 -0
  71. package/agent-codex-sdk/dist/adapter.js +91 -0
  72. package/agent-codex-sdk/dist/agent-preset-codex.js +32 -0
  73. package/agent-codex-sdk/dist/agent.js +1085 -0
  74. package/agent-codex-sdk/dist/codex-native-config.js +392 -0
  75. package/agent-codex-sdk/dist/codex-provider-gateway.js +402 -0
  76. package/agent-codex-sdk/dist/codex-providers.js +376 -0
  77. package/agent-codex-sdk/dist/codex-route.js +86 -0
  78. package/{agent-codex/dist/codex-client.js → agent-codex-sdk/dist/codex-sdk-client.js} +253 -32
  79. package/agent-codex-sdk/dist/codex-sdk-launch.js +92 -0
  80. package/agent-codex-sdk/dist/codex-store.js +180 -0
  81. package/agent-codex-sdk/dist/inbox.js +53 -0
  82. package/agent-codex-sdk/dist/index.js +739 -0
  83. package/agent-codex-sdk/dist/permission.js +71 -0
  84. package/agent-codex-sdk/dist/sdk-runtime.js +307 -0
  85. package/agent-codex-sdk/dist/session-map.js +167 -0
  86. package/agent-codex-sdk/dist/world-plugin.js +93 -0
  87. package/agent-codex-sdk/package.json +79 -0
  88. package/agent-codex-sdk/scripts/fetch-sdk-runtime.mjs +57 -0
  89. package/agent-omp/README.md +72 -55
  90. package/agent-omp/dist/agent.js +36 -11
  91. package/agent-omp/dist/index.js +92 -52
  92. package/agent-omp/dist/lazy-rpc.js +11 -4
  93. package/agent-omp/dist/omp-cli.js +114 -97
  94. package/agent-omp/dist/omp-store.js +12 -4
  95. package/agent-omp/dist/permission.js +70 -5
  96. package/agent-omp/dist/rpc-client.js +409 -0
  97. package/agent-omp/dist/world-plugin.js +36 -3
  98. package/agent-omp/package.json +2 -6
  99. package/agent-omp-sdk/README.md +103 -0
  100. package/agent-omp-sdk/cordis.patch.yml +108 -0
  101. package/agent-omp-sdk/dist/adapter.d.ts +21 -0
  102. package/agent-omp-sdk/dist/adapter.js +36 -0
  103. package/agent-omp-sdk/dist/agent-preset-omp.d.ts +31 -0
  104. package/agent-omp-sdk/dist/agent-preset-omp.js +32 -0
  105. package/agent-omp-sdk/dist/agent.d.ts +64 -0
  106. package/agent-omp-sdk/dist/agent.js +1178 -0
  107. package/agent-omp-sdk/dist/discovery.d.ts +57 -0
  108. package/agent-omp-sdk/dist/discovery.js +116 -0
  109. package/agent-omp-sdk/dist/inbox.d.ts +28 -0
  110. package/agent-omp-sdk/dist/inbox.js +53 -0
  111. package/agent-omp-sdk/dist/index.d.ts +60 -0
  112. package/agent-omp-sdk/dist/index.js +632 -0
  113. package/agent-omp-sdk/dist/knobs.d.ts +34 -0
  114. package/agent-omp-sdk/dist/knobs.js +50 -0
  115. package/agent-omp-sdk/dist/lazy-rpc.d.ts +98 -0
  116. package/agent-omp-sdk/dist/lazy-rpc.js +178 -0
  117. package/agent-omp-sdk/dist/mobile/zoom-guard.d.ts +187 -0
  118. package/agent-omp-sdk/dist/mobile/zoom-guard.js +294 -0
  119. package/agent-omp-sdk/dist/mobile-boot.d.ts +49 -0
  120. package/agent-omp-sdk/dist/mobile-boot.js +38 -0
  121. package/agent-omp-sdk/dist/models.d.ts +39 -0
  122. package/agent-omp-sdk/dist/models.js +299 -0
  123. package/agent-omp-sdk/dist/omp-cli.d.ts +67 -0
  124. package/agent-omp-sdk/dist/omp-cli.js +164 -0
  125. package/agent-omp-sdk/dist/omp-disk-discovery.d.ts +27 -0
  126. package/agent-omp-sdk/dist/omp-disk-discovery.js +178 -0
  127. package/agent-omp-sdk/dist/omp-executable.d.ts +2 -0
  128. package/agent-omp-sdk/dist/omp-executable.js +30 -0
  129. package/agent-omp-sdk/dist/omp-store.d.ts +134 -0
  130. package/agent-omp-sdk/dist/omp-store.js +526 -0
  131. package/agent-omp-sdk/dist/pairing.d.ts +7 -0
  132. package/agent-omp-sdk/dist/pairing.js +45 -0
  133. package/agent-omp-sdk/dist/permission.d.ts +138 -0
  134. package/agent-omp-sdk/dist/permission.js +161 -0
  135. package/agent-omp-sdk/dist/protocol.d.ts +189 -0
  136. package/agent-omp-sdk/dist/rpc-types.d.ts +77 -0
  137. package/agent-omp-sdk/dist/rpc-types.js +1 -0
  138. package/agent-omp-sdk/dist/sdk-client.d.ts +160 -0
  139. package/{agent-omp → agent-omp-sdk}/dist/sdk-client.js +108 -56
  140. package/agent-omp-sdk/dist/sdk-runtime.d.ts +211 -0
  141. package/agent-omp-sdk/dist/sdk-runtime.js +418 -0
  142. package/agent-omp-sdk/dist/sidecar-client.d.ts +87 -0
  143. package/agent-omp-sdk/dist/sidecar-client.js +197 -0
  144. package/agent-omp-sdk/dist/store/adapter.d.ts +17 -0
  145. package/agent-omp-sdk/dist/store/adapter.js +47 -0
  146. package/agent-omp-sdk/dist/store/db.d.ts +70 -0
  147. package/agent-omp-sdk/dist/store/db.js +210 -0
  148. package/agent-omp-sdk/dist/store/index.d.ts +23 -0
  149. package/agent-omp-sdk/dist/store/index.js +59 -0
  150. package/agent-omp-sdk/dist/store/reconcile.d.ts +15 -0
  151. package/agent-omp-sdk/dist/store/reconcile.js +51 -0
  152. package/agent-omp-sdk/dist/store/schema.d.ts +8 -0
  153. package/agent-omp-sdk/dist/store/schema.js +40 -0
  154. package/agent-omp-sdk/dist/transport.d.ts +49 -0
  155. package/agent-omp-sdk/dist/transport.js +35 -0
  156. package/agent-omp-sdk/dist/world-home.d.ts +4 -0
  157. package/agent-omp-sdk/dist/world-home.js +23 -0
  158. package/agent-omp-sdk/dist/world-plugin.d.ts +10 -0
  159. package/agent-omp-sdk/dist/world-plugin.js +137 -0
  160. package/agent-omp-sdk/package.json +87 -0
  161. package/client/index.js +1883 -287
  162. package/cordis.patch.yml +80 -0
  163. package/package.json +23 -9
  164. package/superd-hub/dist/a2a-delivery.d.ts +189 -0
  165. package/superd-hub/dist/a2a-delivery.js +240 -0
  166. package/superd-hub/dist/a2a-host.d.ts +76 -0
  167. package/superd-hub/dist/a2a-host.js +145 -0
  168. package/superd-hub/dist/a2a-ingest.d.ts +31 -0
  169. package/superd-hub/dist/a2a-ingest.js +636 -0
  170. package/superd-hub/dist/a2a-log.d.ts +17 -0
  171. package/superd-hub/dist/a2a-log.js +42 -0
  172. package/superd-hub/dist/a2a-row.d.ts +65 -0
  173. package/superd-hub/dist/a2a-row.js +162 -0
  174. package/superd-hub/dist/a2a-service.d.ts +357 -0
  175. package/superd-hub/dist/a2a-service.js +980 -0
  176. package/superd-hub/dist/a2a-wire.d.ts +220 -0
  177. package/superd-hub/dist/a2a-wire.js +305 -0
  178. package/superd-hub/dist/agent-ids.d.ts +10 -0
  179. package/superd-hub/dist/agent-ids.js +68 -0
  180. package/superd-hub/dist/agent-roster.d.ts +29 -18
  181. package/superd-hub/dist/agent-roster.js +54 -15
  182. package/superd-hub/dist/agent-status.d.ts +119 -0
  183. package/superd-hub/dist/agent-status.js +386 -0
  184. package/superd-hub/dist/client/agent-settings.d.ts +210 -0
  185. package/superd-hub/dist/client/agent-settings.js +300 -0
  186. package/superd-hub/dist/client/mesh-api.d.ts +134 -0
  187. package/superd-hub/dist/client/mesh-api.js +219 -0
  188. package/superd-hub/dist/client/mesh-groups.d.ts +63 -0
  189. package/superd-hub/dist/client/mesh-groups.js +66 -0
  190. package/superd-hub/dist/client/roster.d.ts +48 -0
  191. package/superd-hub/dist/client/roster.js +102 -0
  192. package/superd-hub/dist/client/runtime-settings-api.d.ts +76 -0
  193. package/superd-hub/dist/client/runtime-settings-api.js +137 -0
  194. package/superd-hub/dist/client/switch.d.ts +165 -0
  195. package/superd-hub/dist/client/switch.js +295 -0
  196. package/superd-hub/dist/exec-pty-channel.d.ts +58 -0
  197. package/superd-hub/dist/exec-pty-channel.js +162 -0
  198. package/superd-hub/dist/exec-pty-framing.d.ts +32 -0
  199. package/superd-hub/dist/exec-pty-framing.js +81 -0
  200. package/superd-hub/dist/exec-pty-rpc.d.ts +21 -0
  201. package/superd-hub/dist/exec-pty-rpc.js +128 -0
  202. package/superd-hub/dist/exec-pty-session.d.ts +76 -0
  203. package/superd-hub/dist/exec-pty-session.js +234 -0
  204. package/superd-hub/dist/exec.d.ts +56 -0
  205. package/superd-hub/dist/exec.js +225 -0
  206. package/superd-hub/dist/gateway.d.ts +39 -2
  207. package/superd-hub/dist/gateway.js +62 -3
  208. package/superd-hub/dist/hub-tool.d.ts +174 -0
  209. package/superd-hub/dist/hub-tool.js +464 -0
  210. package/superd-hub/dist/index.d.ts +15 -1
  211. package/superd-hub/dist/index.js +16 -0
  212. package/superd-hub/dist/machines.d.ts +45 -0
  213. package/superd-hub/dist/machines.js +125 -0
  214. package/superd-hub/dist/mesh-federate.d.ts +138 -0
  215. package/superd-hub/dist/mesh-federate.js +223 -0
  216. package/superd-hub/dist/mesh-gateway.d.ts +67 -0
  217. package/superd-hub/dist/mesh-gateway.js +408 -0
  218. package/superd-hub/dist/mesh-link.d.ts +274 -0
  219. package/superd-hub/dist/mesh-link.js +441 -0
  220. package/superd-hub/dist/mesh-rpc.d.ts +123 -0
  221. package/superd-hub/dist/mesh-rpc.js +250 -0
  222. package/superd-hub/dist/mux-client.d.ts +71 -0
  223. package/superd-hub/dist/mux-client.js +281 -0
  224. package/superd-hub/dist/pack-version.d.ts +2 -0
  225. package/superd-hub/dist/pack-version.js +30 -0
  226. package/superd-hub/dist/roster.d.ts +6 -0
  227. package/superd-hub/dist/rpc.d.ts +18 -2
  228. package/superd-hub/dist/rpc.js +34 -4
  229. package/superd-hub/dist/spawn-world.js +3 -1
  230. package/superd-hub/dist/switch-core.d.ts +62 -25
  231. package/superd-hub/dist/switch-core.js +53 -30
  232. package/superd-hub/dist/system-head.d.ts +22 -12
  233. package/superd-hub/dist/system-head.js +100 -84
  234. package/superd-hub/dist/wire-endpoints.d.ts +264 -0
  235. package/superd-hub/dist/wire-endpoints.js +180 -0
  236. package/superd-hub/lib/client/index.js +1883 -287
  237. package/superd-hub/package.json +11 -2
  238. package/agent-agy/dist/agent-preset-projection.d.ts +0 -31
  239. package/agent-agy/dist/agent-preset-projection.js +0 -33
  240. package/agent-claude/dist/agent-preset-projection.js +0 -30
  241. package/agent-codex/dist/agent-preset-projection.js +0 -37
  242. package/agent-codex/dist/app-home.js +0 -65
  243. package/agent-codex/dist/models.js +0 -152
  244. package/agent-codex/dist/spike.js +0 -46
  245. package/agent-hermes/dist/agent-preset-projection.js +0 -34
  246. package/agent-omp/dist/agent-preset-projection.js +0 -36
  247. package/agent-omp/dist/app-home.js +0 -86
  248. package/agent-omp/dist/sidecar-client.js +0 -195
  249. package/agent-pi/dist/agent-preset-projection.js +0 -29
  250. package/superd-hub/dist/client-shim.d.ts +0 -28
  251. package/superd-hub/dist/client-shim.js +0 -251
  252. package/superd-hub/dist/index-pass.d.ts +0 -22
  253. package/superd-hub/dist/index-pass.js +0 -47
  254. package/superd-hub/dist/labels.d.ts +0 -45
  255. package/superd-hub/dist/labels.js +0 -83
  256. /package/{agent-agy → agent-agy-sdk}/bridge/agy_bridge.py +0 -0
  257. /package/{agent-agy → agent-agy-sdk}/bridge/gemini_openai_server.mjs +0 -0
  258. /package/{agent-codex/dist/codex-events.js → agent-codex-sdk/dist/codex-sdk-events.js} +0 -0
  259. /package/{agent-omp → agent-omp-sdk}/dist/protocol.js +0 -0
  260. /package/{agent-omp → agent-omp-sdk}/sidecar/main.ts +0 -0
@@ -1,195 +0,0 @@
1
- /**
2
- * Node-side client for the agent-omp bun sidecar.
3
- * Spawns `bun run sidecar/main.ts`, speaks the v0 JSON-lines protocol,
4
- * correlates requests by id and dispatches pushed event frames.
5
- */
6
- import { spawn } from "node:child_process";
7
- import { existsSync } from "node:fs";
8
- import { createRequire } from "node:module";
9
- import path from "node:path";
10
- import { fileURLToPath } from "node:url";
11
- import { PROTOCOL_VERSION, } from "./protocol.js";
12
- const require = createRequire(import.meta.url);
13
- const pkgDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
14
- /**
15
- * Locate the bun binary for the sidecar spawn.
16
- *
17
- * Layout-dependent: a checkout has it at `<pkg>/node_modules/.bin/bun`, but a
18
- * pnpm-hoisted profile install (prod) puts binaries in the profile root's
19
- * `node_modules/.bin` with the package itself symlinked under
20
- * `node_modules/<name>` — so walk the ancestors' .bin directories, and fall
21
- * back to a plain `bun` on PATH.
22
- */
23
- function resolveBunBinary(fromDir) {
24
- const local = path.join(fromDir, "node_modules", ".bin", "bun");
25
- if (existsSync(local))
26
- return local;
27
- let dir = fromDir;
28
- for (let i = 0; i < 8; i++) {
29
- const parent = path.dirname(dir);
30
- if (parent === dir)
31
- break;
32
- dir = parent;
33
- const candidate = path.join(dir, "node_modules", ".bin", "bun");
34
- if (existsSync(candidate))
35
- return candidate;
36
- }
37
- return "bun";
38
- }
39
- export class OmpSdkSidecar {
40
- options;
41
- proc = null;
42
- nextId = 1;
43
- pending = new Map();
44
- eventHandlers = new Set();
45
- readyPromise = null;
46
- buffer = "";
47
- startError = null;
48
- constructor(options = {}) {
49
- this.options = options;
50
- }
51
- get started() {
52
- return this.proc !== null;
53
- }
54
- onEvent(handler) {
55
- this.eventHandlers.add(handler);
56
- return () => this.eventHandlers.delete(handler);
57
- }
58
- async start() {
59
- if (this.readyPromise)
60
- return this.readyPromise;
61
- this.readyPromise = new Promise((resolve, reject) => {
62
- const bunBin = resolveBunBinary(pkgDir);
63
- const sidecarEntry = path.join(pkgDir, "sidecar", "main.ts");
64
- const env = {
65
- ...process.env,
66
- ...this.options.env,
67
- };
68
- let proc;
69
- try {
70
- proc = spawn(bunBin, ["run", sidecarEntry], {
71
- cwd: this.options.cwd ?? pkgDir,
72
- env,
73
- stdio: ["pipe", "pipe", "pipe"],
74
- });
75
- }
76
- catch (err) {
77
- reject(new Error(`failed to spawn bun sidecar: ${err.message}`));
78
- return;
79
- }
80
- this.proc = proc;
81
- const timeout = setTimeout(() => reject(new Error(`sidecar ready timeout (60s): ${this.startError ?? "no output"}`)), 60_000);
82
- const settle = (fn) => { clearTimeout(timeout); fn(); };
83
- // A dead sidecar surfaces as EPIPE on stdin writes; keep a permanent
84
- // no-op error sink so no window exists where the stream throws out of the
85
- // event loop (per-call degradation is handled by #writeSafe).
86
- proc.stdin.on("error", () => { });
87
- proc.stdout.setEncoding("utf8");
88
- proc.stdout.on("data", (chunk) => this.consume(chunk, (r) => settle(() => resolve(r))));
89
- proc.stderr.setEncoding("utf8");
90
- proc.stderr.on("data", (chunk) => {
91
- this.startError = (this.startError ?? "") + chunk;
92
- process.stderr.write(`[omp-sdk-sidecar] ${chunk}`);
93
- });
94
- proc.on("exit", (code, signal) => {
95
- settle(() => reject(new Error(`sidecar exited before ready (${code ?? signal}): ${this.startError ?? ""}`)));
96
- for (const [, p] of this.pending)
97
- p.reject(new Error(`sidecar exited (${code ?? signal})`));
98
- this.pending.clear();
99
- this.proc = null;
100
- });
101
- });
102
- return this.readyPromise;
103
- }
104
- consume(chunk, onReady) {
105
- this.buffer += chunk;
106
- let nl;
107
- while ((nl = this.buffer.indexOf("\n")) >= 0) {
108
- const raw = this.buffer.slice(0, nl).trim();
109
- this.buffer = this.buffer.slice(nl + 1);
110
- if (!raw)
111
- continue;
112
- let frame;
113
- try {
114
- frame = JSON.parse(raw);
115
- }
116
- catch {
117
- continue;
118
- }
119
- if (frame.event === "ready") {
120
- onReady?.({ protocol: frame.payload?.protocol ?? PROTOCOL_VERSION });
121
- continue;
122
- }
123
- if (typeof frame.id === "number" && ("ok" in frame)) {
124
- const p = this.pending.get(frame.id);
125
- if (p) {
126
- this.pending.delete(frame.id);
127
- if (frame.ok)
128
- p.resolve(frame.result);
129
- else
130
- p.reject(new Error(frame.error));
131
- }
132
- continue;
133
- }
134
- if (frame.event) {
135
- for (const h of this.eventHandlers)
136
- h(frame);
137
- }
138
- }
139
- }
140
- call(method, params) {
141
- if (!this.proc?.stdin)
142
- return Promise.reject(new Error("sidecar not started"));
143
- const id = this.nextId++;
144
- const frame = { id, method, params };
145
- return new Promise((resolve, reject) => {
146
- this.pending.set(id, { resolve, reject });
147
- this.#writeSafe(JSON.stringify(frame) + "\n", () => {
148
- this.pending.delete(id);
149
- reject(new Error(`sidecar write failed: ${method}`));
150
- });
151
- });
152
- }
153
- /** Write to the sidecar's stdin without ever throwing EPIPE out of the loop. */
154
- #writeSafe(chunk, onLost) {
155
- const stdin = this.proc?.stdin;
156
- if (!stdin)
157
- return onLost();
158
- const fail = (err) => {
159
- // EPIPE/ECONNRESET when the sidecar died between checks — a lost frame
160
- // must degrade the caller, never crash the host process.
161
- stdin.removeListener("error", fail);
162
- try {
163
- stdin.destroy();
164
- }
165
- catch { /* already gone */ }
166
- onLost();
167
- };
168
- stdin.once("error", fail);
169
- try {
170
- stdin.write(chunk, () => stdin.removeListener("error", fail));
171
- }
172
- catch {
173
- fail(new Error("write threw"));
174
- }
175
- }
176
- notify(method, params) {
177
- if (!this.proc?.stdin)
178
- return;
179
- this.#writeSafe(JSON.stringify({ method, params }) + "\n", () => { });
180
- }
181
- async stop() {
182
- const proc = this.proc;
183
- if (!proc)
184
- return;
185
- this.proc = null;
186
- await new Promise((resolve) => {
187
- proc.once("exit", () => resolve());
188
- proc.stdin.end();
189
- setTimeout(() => {
190
- proc.kill("SIGTERM");
191
- setTimeout(() => proc.kill("SIGKILL"), 3000);
192
- }, 3000).unref?.();
193
- });
194
- }
195
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * The `agentPreset` session projection, owned by the adapter.
3
- *
4
- * Upstream registers this fold from the `dsh-agent-presets` package, which our
5
- * patch disables (the pi provider replaces preset composition wholesale).
6
- * But the Web UI depends on the projection regardless: the preset hero chip
7
- * renders only when `session.projectionValues.agentPreset` resolves, and the
8
- * session-header label reads it too. Without a registrant the projection is
9
- * absent for every adapter session and both surfaces stay blank (the omp
10
- * line's "no mode" bug).
11
- *
12
- * Same fold as upstream; adapter-pi is single-preset: default every session
13
- * to "pi" so the header chip resolves for scan-native (never-resumed)
14
- * sessions too. Registered under the provider's own fiber via
15
- * `ctx.inject(['sessionProjections'])`.
16
- */
17
- import { z } from "zod";
18
- const agentPresetSchema = z.union([z.string(), z.null()]);
19
- /** Current Session preset, initialized from its header and advanced by selection events. */
20
- export const piAgentPresetProjection = {
21
- key: "agentPreset",
22
- stateSchema: agentPresetSchema,
23
- init: (header) => header.agentPreset ?? "pi",
24
- apply: (state, event) => event.type === "agent-preset/selected"
25
- ? event.data.agentPreset
26
- : state,
27
- wire: { viewSchema: agentPresetSchema, view: (state) => state },
28
- stateVersion: 1,
29
- };
@@ -1,28 +0,0 @@
1
- /**
2
- * Client mount shim (AW-B DL8).
3
- *
4
- * ONE head script installs every client-side break point:
5
- * - `__DSH_TRANSPORT__.fetch` → the Connection RPC fetch (URL object input)
6
- * - `WebSocket` / `EventSource` / `XMLHttpRequest` constructors → path rewrite
7
- * - `__DSH_FILE_UPLOAD__` → uploads bypass the blob worker + its XHR
8
- * - Storage.prototype get/set/remove → per-world key namespace
9
- * - `globalThis.fetch` → global-fetch calls asking for ctx0-root `/api`
10
- * URLs (2026-09-17 H1: upstream session-log-export resolves the GLOBAL
11
- * fetch at call time; narrow `/api`-only rule, query + hash preserved)
12
- * - `HTMLAnchorElement.prototype.click` → download-anchor clicks re-rooted
13
- * (2026-09-18 H1 r2: upstream hands the UNREWRITTEN absolute URL to a
14
- * DETACHED `<a download>` and clicks it — detached clicks never reach
15
- * document, so a document-level listener cannot see them, and a blanket
16
- * rewrite breaks the runtime selector's root-absolute anchors
17
- * (live-found 2026-09-18). Narrow rule: ONLY anchors carrying a
18
- * `download` attribute AND a same-authority root-absolute `/api` href.)
19
- * The rule is namespace-agnostic: a same-origin root-absolute URL is re-rooted
20
- * under the mount (`/omp`), nothing else is touched. That covers every prefix
21
- * a plugin may declare later — no list to keep in sync.
22
- */
23
- /**
24
- * Render the shim as a classic script (parser-blocking head injection).
25
- * @param labelPath - mount root, e.g. `/omp`.
26
- * @returns JavaScript source.
27
- */
28
- export declare function renderClientShim(labelPath: string): string;
@@ -1,251 +0,0 @@
1
- /**
2
- * Client mount shim (AW-B DL8).
3
- *
4
- * ONE head script installs every client-side break point:
5
- * - `__DSH_TRANSPORT__.fetch` → the Connection RPC fetch (URL object input)
6
- * - `WebSocket` / `EventSource` / `XMLHttpRequest` constructors → path rewrite
7
- * - `__DSH_FILE_UPLOAD__` → uploads bypass the blob worker + its XHR
8
- * - Storage.prototype get/set/remove → per-world key namespace
9
- * - `globalThis.fetch` → global-fetch calls asking for ctx0-root `/api`
10
- * URLs (2026-09-17 H1: upstream session-log-export resolves the GLOBAL
11
- * fetch at call time; narrow `/api`-only rule, query + hash preserved)
12
- * - `HTMLAnchorElement.prototype.click` → download-anchor clicks re-rooted
13
- * (2026-09-18 H1 r2: upstream hands the UNREWRITTEN absolute URL to a
14
- * DETACHED `<a download>` and clicks it — detached clicks never reach
15
- * document, so a document-level listener cannot see them, and a blanket
16
- * rewrite breaks the runtime selector's root-absolute anchors
17
- * (live-found 2026-09-18). Narrow rule: ONLY anchors carrying a
18
- * `download` attribute AND a same-authority root-absolute `/api` href.)
19
- * The rule is namespace-agnostic: a same-origin root-absolute URL is re-rooted
20
- * under the mount (`/omp`), nothing else is touched. That covers every prefix
21
- * a plugin may declare later — no list to keep in sync.
22
- */
23
- /** Escape a label for embedding in generated JavaScript. */
24
- function js(value) {
25
- return JSON.stringify(value);
26
- }
27
- /**
28
- * Render the shim as a classic script (parser-blocking head injection).
29
- * @param labelPath - mount root, e.g. `/omp`.
30
- * @returns JavaScript source.
31
- */
32
- export function renderClientShim(labelPath) {
33
- if (typeof labelPath !== 'string' || !labelPath.startsWith('/') || labelPath === '/' || labelPath.endsWith('/')) {
34
- throw new Error(`client-shim: labelPath must start with "/" and carry no trailing slash, got ${JSON.stringify(labelPath)}`);
35
- }
36
- const prefix = `${labelPath}/`;
37
- return `(() => {
38
- const LABEL = ${js(labelPath)}
39
- const PREFIX = ${js(prefix)}
40
-
41
- /** Re-root one pathname when it is same-origin root-absolute and not mounted yet. */
42
- const rewritePath = (path) => {
43
- if (typeof path !== 'string' || !path.startsWith('/') || path.startsWith('//')) return path
44
- if (path === LABEL || path.startsWith(PREFIX)) return path
45
- return PREFIX + path.slice(1)
46
- }
47
-
48
- const origin = () => {
49
- const loc = globalThis.location
50
- if (loc !== undefined && typeof loc.origin === 'string' && loc.origin !== 'null') return loc.origin
51
- return 'http://dsh.internal'
52
- }
53
-
54
- /** Same authority as the page (scheme-agnostic: ws/wss/http/https share host). */
55
- const sameAuthority = (url) => {
56
- try {
57
- return url.host === new URL(origin()).host
58
- } catch {
59
- return false
60
- }
61
- }
62
-
63
- /** Rewrite a full URL (absolute or relative); other authorities are untouched. */
64
- const rewriteUrl = (input) => {
65
- if (typeof input === 'string') {
66
- if (input.startsWith('/')) return rewritePath(input)
67
- try {
68
- const url = new URL(input, origin())
69
- if (!sameAuthority(url)) return input
70
- const next = rewritePath(url.pathname)
71
- if (next === url.pathname) return input
72
- url.pathname = next
73
- return url.href
74
- } catch {
75
- return input
76
- }
77
- }
78
- if (input !== null && typeof input === 'object' && typeof input.href === 'string') {
79
- try {
80
- const url = new URL(input.href)
81
- if (!sameAuthority(url)) return input
82
- const next = rewritePath(url.pathname)
83
- if (next === url.pathname) return input
84
- url.pathname = next
85
- return url
86
- } catch {
87
- return input
88
- }
89
- }
90
- return input
91
- }
92
-
93
- const nativeFetch = globalThis.fetch
94
- const shimFetch = (input, init) => {
95
- if (typeof nativeFetch !== 'function') throw new Error('client-shim: fetch is unavailable')
96
- if (typeof Request === 'function' && input instanceof Request) {
97
- const url = rewriteUrl(input.url)
98
- return nativeFetch(url === input.url ? input : new Request(url, input), init)
99
- }
100
- return nativeFetch(rewriteUrl(input), init)
101
- }
102
-
103
- const transport = (globalThis.__DSH_TRANSPORT__ = globalThis.__DSH_TRANSPORT__ || {})
104
- transport.rewrite = rewritePath
105
- transport.fetch = shimFetch
106
-
107
- // Construct through a Proxy, never a hand-rolled wrapper function: the
108
- // upstream client compares socket.readyState against WebSocket.OPEN, so the
109
- // native statics (CONNECTING/OPEN/CLOSING/CLOSED), prototype and instanceof
110
- // must survive the interception.
111
- const NativeWebSocket = globalThis.WebSocket
112
- if (typeof NativeWebSocket === 'function') {
113
- globalThis.WebSocket = new Proxy(NativeWebSocket, {
114
- construct: (Target, args) => new Target(rewriteUrl(args[0]), ...args.slice(1)),
115
- })
116
- }
117
-
118
- const NativeEventSource = globalThis.EventSource
119
-
120
- if (typeof NativeEventSource === 'function') {
121
- globalThis.EventSource = new Proxy(NativeEventSource, {
122
- construct: (Target, args) => new Target(rewriteUrl(args[0]), ...args.slice(1)),
123
- })
124
- }
125
-
126
- const NativeXhr = globalThis.XMLHttpRequest
127
- if (typeof NativeXhr === 'function' && NativeXhr.prototype !== undefined && typeof NativeXhr.prototype.open === 'function') {
128
- const nativeOpen = NativeXhr.prototype.open
129
- NativeXhr.prototype.open = function (method, url, ...rest) {
130
- return nativeOpen.call(this, method, rewriteUrl(url), ...rest)
131
- }
132
- }
133
-
134
- // Read by the file-upload service at construction time: present ⇒ the page
135
- // fetch carries uploads (no blob worker, and therefore no worker-scope XHR).
136
- globalThis.__DSH_FILE_UPLOAD__ = { fetch: shimFetch }
137
-
138
- // Narrow '/api' re-root helpers (2026-09-17 session-log 404, H1): upstream
139
- // client code (session-log-export) resolves the GLOBAL fetch at call time
140
- // and hands absolute ctx0-root URLs both to fetch and to a DETACHED
141
- // download anchor — neither is visible to the transport faces above.
142
- // Narrow rule: only root-absolute '/api' paths move under the mount;
143
- // relative, same-mount, and foreign URLs pass through untouched. Query and
144
- // hash survive because only the pathname is rewritten. The mount root comes
145
- // from this shim's argument, never from location.pathname. NOTE: the '/api'
146
- // literals below stay SINGLE-quoted on purpose — index-pass.ts rewrites
147
- // every DOUBLE-quoted root-absolute string in the served HTML, and a
148
- // doubled literal would silently disable these rewrites (regression tests
149
- // survive the mount HTML pass).
150
- const rewriteApiPath = (path) => {
151
- if (path === '/api' || path.startsWith('/api/')) return PREFIX + path.slice(1)
152
- return path
153
- }
154
- const rewriteApiUrl = (input) => {
155
- if (typeof input === 'string') {
156
- if (input.startsWith('/') && !input.startsWith('//')) return rewriteApiPath(input)
157
- try {
158
- const url = new URL(input, origin())
159
- if (!sameAuthority(url)) return input
160
- const next = rewriteApiPath(url.pathname)
161
- if (next === url.pathname) return input
162
- url.pathname = next
163
- return url.href
164
- } catch {
165
- return input
166
- }
167
- }
168
- if (input !== null && typeof input === 'object' && typeof input.href === 'string') {
169
- try {
170
- const url = new URL(input.href)
171
- if (!sameAuthority(url)) return input
172
- const next = rewriteApiPath(url.pathname)
173
- if (next === url.pathname) return input
174
- url.pathname = next
175
- return url
176
- } catch {
177
- return input
178
- }
179
- }
180
- return input
181
- }
182
- if (typeof nativeFetch === 'function' && globalThis.__DSH_FETCH_REWRITE__ !== true) {
183
- globalThis.__DSH_FETCH_REWRITE__ = true
184
- globalThis.fetch = (input, init) => nativeFetch(rewriteApiUrl(input), init)
185
- }
186
-
187
- // Download anchors (2026-09-18 H1 r2): upstream session-log-export hands
188
- // the UNREWRITTEN absolute URL to a DETACHED '<a download>' element and
189
- // calls .click() — detached clicks never propagate to document, so the r1
190
- // document-level capture listener could not see them, while its BLANKET
191
- // rewrite re-rooted the runtime selector's root-absolute anchors and broke
192
- // cross-world navigation (live-found 2026-09-18). Narrow seam: wrap
193
- // HTMLAnchorElement.prototype.click itself and rewrite ONLY anchors that
194
- // carry a 'download' attribute AND a same-authority root-absolute '/api'
195
- // href. Everything else — the runtime selector's links included — passes
196
- // through untouched.
197
- if (globalThis.HTMLAnchorElement !== undefined
198
- && globalThis.HTMLAnchorElement.prototype !== undefined
199
- && typeof globalThis.HTMLAnchorElement.prototype.click === 'function'
200
- && globalThis.__DSH_ANCHOR_CLICK_REWRITE__ !== true) {
201
- globalThis.__DSH_ANCHOR_CLICK_REWRITE__ = true
202
- const nativeAnchorClick = globalThis.HTMLAnchorElement.prototype.click
203
- globalThis.HTMLAnchorElement.prototype.click = function (...args) {
204
- try {
205
- if (this.hasAttribute('download')) {
206
- const current = this.getAttribute('href')
207
- if (typeof current === 'string' && current !== '') {
208
- const next = rewriteApiUrl(current)
209
- if (typeof next === 'string' && next !== current) this.setAttribute('href', next)
210
- }
211
- }
212
- } catch {
213
- /* best-effort: never break the click itself */
214
- }
215
- return nativeAnchorClick.apply(this, args)
216
- }
217
- }
218
-
219
- // Storage namespace (2026-09-16 storage findings P1): all worlds share one
220
-
221
- // origin, so bare localStorage keys would overwrite each other across
222
- // mounts. Prefix every key with the label; root '/' never injects this
223
- // shim and keeps bare keys. Never throws: attachPersistence only
224
- // console-errors on failure, so a throwing shim would silently disable
225
- // persistence.
226
- try {
227
- const StorageProto = globalThis.Storage && globalThis.Storage.prototype
228
- if (globalThis.localStorage !== undefined && StorageProto !== undefined
229
- && !globalThis.__DSH_STORAGE_NS__
230
- && typeof StorageProto.getItem === 'function'
231
- && typeof StorageProto.setItem === 'function'
232
- && typeof StorageProto.removeItem === 'function') {
233
- // NS derives from PREFIX, never LABEL: the mount HTML pass (index-pass)
234
- // rewrites every quoted root-absolute string EXCEPT "<label>/"-prefixed
235
- // ones, so the shim's LABEL="/omp" literal doubles to "/omp/omp" while
236
- // PREFIX="/omp/" is immune (live-found 2026-09-17, acceptance A2/A5).
237
- // The NS-from-PREFIX coupling is DELIBERATE: index-pass.ts rewrites double-quoted root-absolute strings except "<label>/"-prefixed ones, so LABEL="/omp" doubles while PREFIX="/omp/" survives; do NOT derive NS from LABEL.
238
- const NS = PREFIX.slice(1, -1) + ':'
239
- globalThis.__DSH_STORAGE_NS__ = NS
240
- const nativeGetItem = StorageProto.getItem
241
- const nativeSetItem = StorageProto.setItem
242
- const nativeRemoveItem = StorageProto.removeItem
243
- StorageProto.getItem = function (name) { return nativeGetItem.call(this, NS + name) }
244
- StorageProto.setItem = function (name, value) { return nativeSetItem.call(this, NS + name, value) }
245
- StorageProto.removeItem = function (name) { return nativeRemoveItem.call(this, NS + name) }
246
- }
247
- } catch {
248
- /* storage namespace is best-effort: never break the shim */
249
- }
250
- })()`;
251
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Mount HTML pass (AW-B DL1/DL8 server half).
3
- *
4
- * The world dist is built with RELATIVE asset URLs (`./assets/...`), so a
5
- * `<base>` pointing at the mount makes every relative reference resolve under
6
- * `/<label>/`. Root-absolute strings (the boot graph's `/plugins/...` URLs,
7
- * injected script sources, `href="/"`-style anchors) do NOT follow `<base>`,
8
- * so they are re-rooted explicitly — one generic rule, no namespace list.
9
- */
10
- /**
11
- * Rewrite a world index for serving under `<labelPath>/`.
12
- *
13
- * - pins `<base>` at the mount (inserting one after `<head>` when absent);
14
- * - prefixes every double-quoted root-absolute string that is not already
15
- * mounted and not protocol-relative (`//host/...`);
16
- * - idempotent (a second pass changes nothing).
17
- *
18
- * @param html - the world's index.html (already rendered with its own rows).
19
- * @param labelPath - mount root, e.g. `/omp`.
20
- * @returns the mount-ready HTML.
21
- */
22
- export declare function rewriteIndexHtml(html: string, labelPath: string): string;
@@ -1,47 +0,0 @@
1
- /**
2
- * Mount HTML pass (AW-B DL1/DL8 server half).
3
- *
4
- * The world dist is built with RELATIVE asset URLs (`./assets/...`), so a
5
- * `<base>` pointing at the mount makes every relative reference resolve under
6
- * `/<label>/`. Root-absolute strings (the boot graph's `/plugins/...` URLs,
7
- * injected script sources, `href="/"`-style anchors) do NOT follow `<base>`,
8
- * so they are re-rooted explicitly — one generic rule, no namespace list.
9
- */
10
- /** Root of the mount including the trailing slash (`/omp` → `/omp/`). */
11
- function mountPrefix(labelPath) {
12
- return labelPath.endsWith('/') ? labelPath : `${labelPath}/`;
13
- }
14
- /**
15
- * Rewrite a world index for serving under `<labelPath>/`.
16
- *
17
- * - pins `<base>` at the mount (inserting one after `<head>` when absent);
18
- * - prefixes every double-quoted root-absolute string that is not already
19
- * mounted and not protocol-relative (`//host/...`);
20
- * - idempotent (a second pass changes nothing).
21
- *
22
- * @param html - the world's index.html (already rendered with its own rows).
23
- * @param labelPath - mount root, e.g. `/omp`.
24
- * @returns the mount-ready HTML.
25
- */
26
- export function rewriteIndexHtml(html, labelPath) {
27
- if (typeof labelPath !== 'string' || !labelPath.startsWith('/') || labelPath === '/' || labelPath.endsWith('/')) {
28
- throw new Error(`index-pass: labelPath must start with "/" and carry no trailing slash, got ${JSON.stringify(labelPath)}`);
29
- }
30
- const prefix = mountPrefix(labelPath);
31
- let out = html;
32
- if (/<base\b[^>]*>/i.test(out)) {
33
- out = out.replace(/<base\b[^>]*>/i, `<base href="${prefix}">`);
34
- }
35
- else if (/<head(?:\s[^>]*)?>/i.test(out)) {
36
- out = out.replace(/<head(?:\s[^>]*)?>/i, open => `${open}<base href="${prefix}">`);
37
- }
38
- out = out.replace(/"(\/[^"]*)"/g, (whole, path) => {
39
- if (path.startsWith('//'))
40
- return whole;
41
- // Load-bearing contract: client-shim.ts derives its storage NS from the surviving "<label>/" literal (regression test: the storage NS survives the mount HTML pass). Changing this exclusion breaks that coupling.
42
- if (path.startsWith(prefix))
43
- return whole;
44
- return `"${prefix}${path.slice(1)}"`;
45
- });
46
- return out;
47
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * Label table (AW-B DL2/DL4): one world ↔ one mount path under the ctx0 origin.
3
- *
4
- * The addressed world is the request's path (`/<label>/...`), so the label is
5
- * the ONLY routing key. Reserving it must be atomic against the real
6
- * webServer's duplicate-registration throw — that throw is the only collision
7
- * signal the framework offers (the route tables are private and there is no
8
- * query API), so it is used here as the probe.
9
- *
10
- * A collision is a composition-level conflict and must be loud; an optional
11
- * alternate root lets a deployment re-home instead of failing to boot.
12
- */
13
- /** One reserved mount path. */
14
- export interface LabelClaim {
15
- /** Runtime key (`omp`, `codex`, …). */
16
- readonly key: string;
17
- /** Reserved mount root, e.g. `/omp` or `/_agents/omp` (no trailing slash). */
18
- readonly path: string;
19
- /** Release the claim (idempotent). */
20
- release(): void;
21
- }
22
- /** How to reserve a path: the injected real-webServer registration. */
23
- export interface ClaimOptions {
24
- /** Attempt a prefix registration; throws when `(kind, path)` is already taken. */
25
- register(path: string): () => void;
26
- /** Optional root prefix (default: the origin root). */
27
- root?: string;
28
- /** Candidate roots to try, in order, when the clean path is taken. */
29
- alternateRoots?: readonly string[];
30
- }
31
- /**
32
- * Reserve the mount path for `key`.
33
- * @param key - runtime key (one path segment).
34
- * @param opts - registration probe plus optional roots.
35
- * @returns the live claim.
36
- */
37
- export declare function claimLabel(key: string, opts: ClaimOptions): LabelClaim;
38
- /** The reserved mount root for a key, or undefined when unclaimed. */
39
- export declare function labelOf(key: string): string | undefined;
40
- /** Release a key's claim; unknown keys are a no-op. */
41
- export declare function releaseLabel(key: string): void;
42
- /** Claimed keys, registration order. */
43
- export declare function listLabels(): string[];
44
- /** Test/introspection helper: is this object a claim? */
45
- export declare function isLabelClaim(value: unknown): value is LabelClaim;