@sema-agent/server 7.43.0 → 7.44.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.
Files changed (345) hide show
  1. package/USAGE.md +18 -0
  2. package/dist/adoption/plan.js +31 -192
  3. package/dist/adoption/quiesce.js +3 -86
  4. package/dist/adoption/runner.js +3 -140
  5. package/dist/adoption/sql.js +0 -74
  6. package/dist/adoption/wire.js +0 -80
  7. package/dist/approval-ask-machine.js +0 -75
  8. package/dist/approval-card.js +0 -323
  9. package/dist/approval-deny-reasons.js +0 -42
  10. package/dist/approval-hmac.js +0 -35
  11. package/dist/approval-reconciler.js +8 -166
  12. package/dist/approval.js +4 -67
  13. package/dist/audit.js +1 -44
  14. package/dist/auth-bridge.js +4 -47
  15. package/dist/auth-keys.js +0 -23
  16. package/dist/bake-runner/main.js +4 -65
  17. package/dist/bake-runner/protocol.js +3 -58
  18. package/dist/bake-runner/runner.js +5 -91
  19. package/dist/bench/l8/artifact.js +2 -61
  20. package/dist/bench/l8/escape.js +0 -25
  21. package/dist/bench/l8/index.js +0 -14
  22. package/dist/bench/l8/probes.js +0 -60
  23. package/dist/bench/l8/run-probes.js +2 -45
  24. package/dist/bench/s1/arms.js +14 -189
  25. package/dist/bench/s1/live-deps.js +11 -253
  26. package/dist/bench/s1/oracle.js +1 -36
  27. package/dist/bench/s1/repair-oracle-adapter.js +0 -30
  28. package/dist/bench/s1/reviewer.js +0 -34
  29. package/dist/bench/s1/row.js +0 -62
  30. package/dist/bench/s1/run-firm.js +4 -70
  31. package/dist/bench/s1/runner-ctx.js +0 -40
  32. package/dist/bench/s1/tasks.js +0 -115
  33. package/dist/boot/adoption.js +0 -20
  34. package/dist/boot/budget-tracing.js +3 -55
  35. package/dist/boot/config-center.js +43 -551
  36. package/dist/boot/coordinators.js +1 -69
  37. package/dist/boot/crash-last.js +0 -18
  38. package/dist/boot/deferred-sandbox-path-env.js +3 -119
  39. package/dist/boot/execution-env.js +5 -171
  40. package/dist/boot/governance-seams.js +0 -92
  41. package/dist/boot/leader.js +0 -69
  42. package/dist/boot/limit-sync.js +0 -2
  43. package/dist/boot/memory-boundary.js +3 -91
  44. package/dist/boot/org-memory.js +1 -25
  45. package/dist/boot/parked-revive-gate.js +0 -150
  46. package/dist/boot/permission-rules-audit.js +1 -56
  47. package/dist/boot/reapers.js +15 -273
  48. package/dist/boot/resolve-spec.js +9 -768
  49. package/dist/boot/retention-lane.js +4 -87
  50. package/dist/boot/runner-deps.js +3 -297
  51. package/dist/boot/runtime-caps.js +0 -40
  52. package/dist/boot/session-faces.js +2 -133
  53. package/dist/boot/shutdown.js +9 -83
  54. package/dist/boot/side-query-lane.js +2 -137
  55. package/dist/boot/stores.js +15 -215
  56. package/dist/boot/task-list-lane.js +0 -18
  57. package/dist/boot/webfetch-summarize-lane.js +0 -47
  58. package/dist/boot/workflow-orchestration.js +3 -99
  59. package/dist/boot-reclaim.js +0 -20
  60. package/dist/bounded-session-map.js +0 -19
  61. package/dist/brain.js +2 -139
  62. package/dist/budget.js +9 -244
  63. package/dist/capabilities/builtin-tools.js +0 -3
  64. package/dist/capabilities/center-plugins.js +6 -51
  65. package/dist/capabilities/center-prompts.js +6 -71
  66. package/dist/capabilities/code-review-council.js +7 -40
  67. package/dist/capabilities/collab-workflows.js +1 -44
  68. package/dist/capabilities/hands-lane.js +0 -65
  69. package/dist/capabilities/memory-notice.js +0 -70
  70. package/dist/capabilities/prompt.js +0 -14
  71. package/dist/capabilities/prompts/code-review.js +0 -14
  72. package/dist/capabilities/prompts/identity.js +0 -6
  73. package/dist/capabilities/prompts/team.js +0 -4
  74. package/dist/capabilities/repo-tools.js +0 -34
  75. package/dist/capabilities/sandbox-file-send.js +3 -92
  76. package/dist/capabilities/scenarios.d.ts +0 -1
  77. package/dist/capabilities/scenarios.js +18 -279
  78. package/dist/capabilities/select-environment-tool.js +0 -32
  79. package/dist/capabilities/send-user-file-tool.js +2 -66
  80. package/dist/capabilities/skills.d.ts +1 -2
  81. package/dist/capabilities/skills.js +3 -21
  82. package/dist/capabilities/team.d.ts +3 -11
  83. package/dist/capabilities/team.js +3 -51
  84. package/dist/capabilities/tool-defer.js +0 -3
  85. package/dist/config-center/apply-effective.js +15 -330
  86. package/dist/config-center/apply-ledger.js +5 -38
  87. package/dist/config-center/facade.js +0 -41
  88. package/dist/config-center/hot-keys-registry.js +0 -20
  89. package/dist/config-center/http-client.js +2 -125
  90. package/dist/config-center/mcp-revocation.js +2 -34
  91. package/dist/config-center/read-face.js +0 -59
  92. package/dist/config-center/restart-signal.js +1 -85
  93. package/dist/config-center/skills-mcp.d.ts +1 -1
  94. package/dist/config-center/skills-mcp.js +9 -76
  95. package/dist/config-center/stage-limits.js +8 -35
  96. package/dist/config-invariants.js +0 -16
  97. package/dist/config-lkg.js +0 -42
  98. package/dist/config-provider.js +3 -186
  99. package/dist/config-types.js +0 -5
  100. package/dist/config.js +107 -1145
  101. package/dist/degenerate-instrument.js +3 -67
  102. package/dist/deployment-governance.js +0 -124
  103. package/dist/digest-form.js +0 -12
  104. package/dist/elicitation.js +3 -86
  105. package/dist/env-facts.js +7 -75
  106. package/dist/fleet/fleet-bus.js +34 -507
  107. package/dist/fleet/fleet-reconciler.js +9 -149
  108. package/dist/fleet/fleet-terminal-window.js +10 -178
  109. package/dist/fleet/subagent-tail-bus.js +3 -72
  110. package/dist/fleet-client.js +10 -70
  111. package/dist/fleet-lease.js +5 -79
  112. package/dist/git-api-kind.js +0 -3
  113. package/dist/governance-ask-marks.js +2 -78
  114. package/dist/hooks/branch-transcript.js +0 -74
  115. package/dist/hooks/cc-agent-hook-prompt.js +0 -29
  116. package/dist/hooks/cc-stop-prompt.js +1 -46
  117. package/dist/hooks/hook-llm.js +1 -53
  118. package/dist/hooks/hook-runner.js +20 -414
  119. package/dist/http/active-run-conflict.js +4 -129
  120. package/dist/http/cursor-fingerprint.d.ts +5 -0
  121. package/dist/http/cursor-fingerprint.js +5 -0
  122. package/dist/http/idempotency.js +0 -37
  123. package/dist/http/principal-gate.js +3 -40
  124. package/dist/http/route-ctx.js +0 -9
  125. package/dist/http/routes/a2a-serve.js +7 -319
  126. package/dist/http/routes/admin-config-refresh.js +0 -4
  127. package/dist/http/routes/admin-drain.js +0 -10
  128. package/dist/http/routes/adoption.js +1 -29
  129. package/dist/http/routes/agents-roster.js +1 -47
  130. package/dist/http/routes/approvals-assistant.js +32 -395
  131. package/dist/http/routes/attachments.js +4 -22
  132. package/dist/http/routes/capabilities.js +3 -420
  133. package/dist/http/routes/diagnostics.js +1 -81
  134. package/dist/http/routes/fleet.js +9 -185
  135. package/dist/http/routes/images.js +14 -239
  136. package/dist/http/routes/leader.js +0 -13
  137. package/dist/http/routes/memory-bundle.js +1 -61
  138. package/dist/http/routes/memory-policy.js +9 -99
  139. package/dist/http/routes/notify-wake.js +3 -37
  140. package/dist/http/routes/observability.js +2 -19
  141. package/dist/http/routes/retention-ops.js +2 -34
  142. package/dist/http/routes/rules.js +1 -93
  143. package/dist/http/routes/runs.js +64 -873
  144. package/dist/http/routes/session-sync.js +19 -258
  145. package/dist/http/routes/sessions-list.js +17 -43
  146. package/dist/http/routes/sessions.js +34 -226
  147. package/dist/http/routes/shared-memory.js +5 -36
  148. package/dist/http/routes/side-query.js +1 -87
  149. package/dist/http/routes/tasks.js +52 -722
  150. package/dist/http/routes/trace-usage.js +32 -195
  151. package/dist/http/routes/workflows.js +19 -195
  152. package/dist/http/run-meta.js +0 -6
  153. package/dist/http/send.js +0 -32
  154. package/dist/http/server.js +92 -1597
  155. package/dist/http/sse-lifecycle.js +2 -13
  156. package/dist/http/sse-log.js +3 -48
  157. package/dist/http/tar.js +5 -21
  158. package/dist/http/verify-rounds.js +0 -5
  159. package/dist/http/wire-gate.js +0 -9
  160. package/dist/http/workspace-content.js +0 -10
  161. package/dist/images/bake-validate.js +1 -70
  162. package/dist/images/manifest.js +1 -6
  163. package/dist/index.js +0 -21
  164. package/dist/key-resolver.js +2 -17
  165. package/dist/leader/diffout.js +1 -20
  166. package/dist/leader/diffup.js +0 -47
  167. package/dist/leader/endpoint.js +2 -57
  168. package/dist/leader/fanout.js +3 -45
  169. package/dist/leader/grader-env-factory.js +3 -72
  170. package/dist/leader/leader.js +5 -156
  171. package/dist/leader/merge.js +8 -115
  172. package/dist/leader/planner.js +3 -54
  173. package/dist/leader/repair-oracle.js +1 -60
  174. package/dist/leader/repair-wire.js +2 -79
  175. package/dist/leader/wire.js +8 -307
  176. package/dist/lsp/e2b-bridge.js +4 -64
  177. package/dist/lsp/e2b-manager.js +6 -94
  178. package/dist/lsp/lsp-frames.js +0 -12
  179. package/dist/lsp/manager.js +4 -96
  180. package/dist/lsp/ws-transport.js +5 -55
  181. package/dist/lsp-evict.js +1 -15
  182. package/dist/main.js +57 -765
  183. package/dist/memory-bundle-engine.js +0 -55
  184. package/dist/memory-export.js +0 -4
  185. package/dist/memory-posture.js +1 -15
  186. package/dist/memory-scope.js +11 -148
  187. package/dist/memory-sync-client.js +2 -44
  188. package/dist/memory-sync.js +1 -80
  189. package/dist/model-select.js +3 -80
  190. package/dist/observability/cost-quota.js +1 -17
  191. package/dist/observability/cost-taxonomy.js +0 -34
  192. package/dist/observability/fail-open.js +7 -86
  193. package/dist/observability/logger.js +0 -6
  194. package/dist/observability/metrics.js +0 -94
  195. package/dist/observability/otel-exporter.js +3 -13
  196. package/dist/observability/principal-context.js +0 -9
  197. package/dist/observability/prompt-manifest.js +1 -37
  198. package/dist/observability/rate-limit.js +0 -4
  199. package/dist/observability/secret-env-scrub.js +2 -56
  200. package/dist/observability/tool-trace.js +1 -70
  201. package/dist/orchestration/hardened-vm-runner.js +4 -118
  202. package/dist/orchestration/hardened-vm-worker-runner.js +1 -26
  203. package/dist/orchestration/hardened-vm-worker.js +0 -27
  204. package/dist/orchestration/subagent-steer.js +1 -45
  205. package/dist/orchestration/workflow-agent-steer.js +1 -80
  206. package/dist/orchestration/workflow-completion-inbox.js +32 -285
  207. package/dist/orchestration/workflow-notify-journal.js +16 -259
  208. package/dist/org-memory-admission.js +3 -47
  209. package/dist/parent-watch.js +2 -48
  210. package/dist/parked-decide.js +1 -109
  211. package/dist/per-task-image.js +0 -57
  212. package/dist/plan-cache-probe.js +3 -27
  213. package/dist/plugins/adoption-log-sql.js +2 -119
  214. package/dist/plugins/approval-ask-store-memory.js +3 -38
  215. package/dist/plugins/approval-ask-store-sql.js +6 -188
  216. package/dist/plugins/approval-exemption-store.js +2 -28
  217. package/dist/plugins/background-agent-store-sql.js +4 -105
  218. package/dist/plugins/background-shell-support.js +14 -122
  219. package/dist/plugins/blob-backend.js +6 -169
  220. package/dist/plugins/breaker-state-sql.js +8 -46
  221. package/dist/plugins/caching-session-store.js +4 -106
  222. package/dist/plugins/checkpoint-store-sql.js +18 -505
  223. package/dist/plugins/e2b-orphan-reclaim.js +0 -45
  224. package/dist/plugins/file-outcome-sink.js +0 -9
  225. package/dist/plugins/file-resume-anchor-store.js +4 -43
  226. package/dist/plugins/file-run-store.js +26 -364
  227. package/dist/plugins/file-snapshot-store-sql.js +10 -181
  228. package/dist/plugins/fork-routing-session-store.js +8 -111
  229. package/dist/plugins/host-platform.js +2 -91
  230. package/dist/plugins/image-bake-store-sql.js +7 -250
  231. package/dist/plugins/image-index-sql.js +4 -123
  232. package/dist/plugins/k8s-bg-scripts.js +4 -88
  233. package/dist/plugins/k8s-exec-protocol.js +0 -41
  234. package/dist/plugins/leader-run-store-sql.js +0 -101
  235. package/dist/plugins/local-checkpoint-store.js +8 -128
  236. package/dist/plugins/local-session-store.js +34 -296
  237. package/dist/plugins/local-task-attachment-store.js +2 -16
  238. package/dist/plugins/mailbox-store-sql.js +8 -65
  239. package/dist/plugins/memory-embedder-fingerprint.js +5 -166
  240. package/dist/plugins/memory-embedder.js +4 -70
  241. package/dist/plugins/memory-engine-pg.js +6 -170
  242. package/dist/plugins/memory-engine-tidb.js +7 -155
  243. package/dist/plugins/memory-engine-vector-util.js +0 -10
  244. package/dist/plugins/memory-key-guards.js +0 -34
  245. package/dist/plugins/memory-origin-law.js +0 -187
  246. package/dist/plugins/memory-resume-anchor-store.js +0 -17
  247. package/dist/plugins/memory-run-store.js +12 -89
  248. package/dist/plugins/memory-session-policy-store.js +0 -17
  249. package/dist/plugins/memory-sync-store-pg.js +4 -49
  250. package/dist/plugins/memory-sync-store-tidb.js +3 -35
  251. package/dist/plugins/outcome-ledger-sql.js +3 -97
  252. package/dist/plugins/permission-rule-store-file.js +5 -133
  253. package/dist/plugins/permission-rule-store-sql.d.ts +3 -0
  254. package/dist/plugins/permission-rule-store-sql.js +50 -307
  255. package/dist/plugins/pg-cost-quota.js +0 -7
  256. package/dist/plugins/pg-pool.js +0 -92
  257. package/dist/plugins/pg-rate-limiter.js +2 -13
  258. package/dist/plugins/pg-safe-json.js +4 -40
  259. package/dist/plugins/pg-session-storage.js +25 -189
  260. package/dist/plugins/posix-shell-fs.js +1 -31
  261. package/dist/plugins/remote-env-adb.js +12 -101
  262. package/dist/plugins/remote-env-e2b.js +40 -371
  263. package/dist/plugins/remote-env-file-error.js +0 -37
  264. package/dist/plugins/remote-env-host.js +63 -483
  265. package/dist/plugins/remote-env-k8s.js +32 -326
  266. package/dist/plugins/remote-env-local-docker.js +24 -157
  267. package/dist/plugins/remote-env-ssh.js +20 -128
  268. package/dist/plugins/remote-scratchpad.js +2 -32
  269. package/dist/plugins/remote-shell.js +1 -32
  270. package/dist/plugins/resume-anchor-store-sql.js +0 -11
  271. package/dist/plugins/retention-lane-store-sql.js +0 -108
  272. package/dist/plugins/retention-store-sql.js +4 -383
  273. package/dist/plugins/roster-store-sql.js +0 -55
  274. package/dist/plugins/run-store-sql.js +14 -251
  275. package/dist/plugins/s3-presign.js +2 -49
  276. package/dist/plugins/scheduler-support.js +3 -80
  277. package/dist/plugins/send-file-ledger.js +4 -53
  278. package/dist/plugins/send-user-file.js +4 -94
  279. package/dist/plugins/session-placement.js +1 -89
  280. package/dist/plugins/session-policy-store-sql.js +3 -81
  281. package/dist/plugins/session-store.js +0 -57
  282. package/dist/plugins/shared-memory-store-sql.js +4 -167
  283. package/dist/plugins/sql-driver.js +0 -17
  284. package/dist/plugins/sql-errors.js +0 -7
  285. package/dist/plugins/sql-escape.js +0 -8
  286. package/dist/plugins/sql-row-helpers.js +0 -25
  287. package/dist/plugins/store-backend.js +42 -222
  288. package/dist/plugins/store-contracts.js +2 -46
  289. package/dist/plugins/task-attachment-store.js +3 -49
  290. package/dist/plugins/task-list-store-sql.js +0 -79
  291. package/dist/plugins/tidb-cost-quota.js +1 -4
  292. package/dist/plugins/tidb-pool.js +1 -207
  293. package/dist/plugins/tidb-rate-limiter.js +3 -9
  294. package/dist/plugins/tidb-session-storage.js +4 -70
  295. package/dist/plugins/tidb-session-store.js +19 -341
  296. package/dist/plugins/tool-result-store-sql.js +4 -179
  297. package/dist/plugins/usage-window-store-sql.js +0 -8
  298. package/dist/plugins/web-search.js +10 -132
  299. package/dist/plugins/workflow-journal-store-sql.js +2 -58
  300. package/dist/plugins/workflow-run-store-sql.js +6 -91
  301. package/dist/plugins/worktree-isolation.js +6 -126
  302. package/dist/plugins/write-behind-counter.js +16 -75
  303. package/dist/principal-jwt.js +5 -60
  304. package/dist/project-memory.js +15 -146
  305. package/dist/prompts-domain-validate.js +1 -51
  306. package/dist/question.js +2 -111
  307. package/dist/resource-suspend.js +0 -18
  308. package/dist/router/route-orchestration.js +0 -77
  309. package/dist/rules-consent.d.ts +44 -5
  310. package/dist/rules-consent.js +75 -215
  311. package/dist/run-local.js +14 -381
  312. package/dist/runs.js +29 -617
  313. package/dist/runtime-caps-resolver.js +6 -132
  314. package/dist/runtime-governance.js +1 -232
  315. package/dist/sandbox-pkg-source.js +0 -37
  316. package/dist/sealed-key.js +3 -68
  317. package/dist/security.js +6 -291
  318. package/dist/session-leaf-bus.js +0 -32
  319. package/dist/session-sync-content.js +1 -69
  320. package/dist/session-sync-kernel.js +3 -60
  321. package/dist/session-sync.js +3 -66
  322. package/dist/session-titler.js +7 -41
  323. package/dist/session-watch.js +9 -73
  324. package/dist/shared-memory-scope-authorizer.js +0 -18
  325. package/dist/sighup-idle.js +1 -12
  326. package/dist/spec-fields.js +4 -143
  327. package/dist/store-live-probe.js +3 -49
  328. package/dist/task-a2a.js +1 -126
  329. package/dist/task-cwd.js +1 -103
  330. package/dist/task-mcp.js +1 -89
  331. package/dist/task-settings.js +10 -300
  332. package/dist/task-workflow.js +8 -75
  333. package/dist/tool-approval.d.ts +28 -1
  334. package/dist/tool-approval.js +70 -1430
  335. package/dist/trace/artifacts.js +5 -20
  336. package/dist/trace/engine-notice-wire.js +6 -138
  337. package/dist/trace/ledger-sink.js +7 -96
  338. package/dist/trace/project.js +4 -448
  339. package/dist/trace/redact.js +9 -77
  340. package/dist/turn-activity.js +1 -27
  341. package/dist/usage-analytics.js +4 -34
  342. package/dist/wall-clock-jump-guard.js +1 -68
  343. package/package.json +3 -3
  344. package/dist/capabilities/scenario-alias.d.ts +0 -27
  345. package/dist/capabilities/scenario-alias.js +0 -61
@@ -1,14 +1,5 @@
1
- /**
2
- * `WsLspTransport` — LSP JSON-RPC over a WebSocket to the language server inside the E2B sandbox (the bridge
3
- * exposed via `sandbox.getHost(port)`). Each WS message is one JSON-RPC message (the LSP-over-WebSocket
4
- * convention — no Content-Length framing needed; that's the part that differs from CC's stdio transport). The
5
- * socket is behind a minimal `WsLike` interface so the request/response correlation is unit-testable without a
6
- * network; `connectWsLspTransport` wires the real `ws` client + the `initialize` handshake.
7
- */
8
1
  import WebSocket from "ws";
9
2
  import { pathToUri } from "@sema-agent/core";
10
- /** Error-or-event → Error. Bun's ws shim emits browser-style ErrorEvents (NOT instanceof Error) whose
11
- * String() is "[object ErrorEvent]" — extract .message so real failures (e.g. TLS) stay readable. */
12
3
  function toError(e) {
13
4
  if (e instanceof Error)
14
5
  return e;
@@ -23,7 +14,6 @@ export class WsLspTransport {
23
14
  isClosed = false;
24
15
  keepalive;
25
16
  awaitingPong = false;
26
- /** design/121: server→client NOTIFICATION subscribers (publishDiagnostics etc.). */
27
17
  notificationHandlers = new Set();
28
18
  constructor(ws, requestTimeoutMs = 30_000, keepaliveMs = 20_000) {
29
19
  this.ws = ws;
@@ -31,27 +21,17 @@ export class WsLspTransport {
31
21
  ws.on("message", (data) => this.onMessage(typeof data === "string" ? data : String(data)));
32
22
  ws.on("close", () => this.failAll(new Error("LSP websocket closed")));
33
23
  ws.on("error", (e) => this.failAll(toError(e)));
34
- // Keepalive + LIVENESS: the E2B ingress kills a WS after ~60-75s regardless of traffic (live-tested:
35
- // neither ws pings nor app-level data frames prevent it), and the kill can be SILENT — no close frame
36
- // reaches us, the socket goes half-open, requests black-hole into the 30s timeout and `closed` never
37
- // flips, so the manager keeps reusing a dead session (live-drill: "first op after a thinking gap is
38
- // none, the next op heals"). So the ping doubles as a liveness probe: a ping with no pong by the next
39
- // interval ⇒ half-open ⇒ fail everything locally + terminate, flipping `closed` so the manager heals
40
- // on the very next tool call. `$/keepalive` (LSP spec: `$/` notifications must be ignored) stays as a
41
- // best-effort data-frame keepalive for other backends.
42
24
  if (keepaliveMs > 0) {
43
25
  ws.on("pong", () => {
44
26
  this.awaitingPong = false;
45
27
  });
46
28
  this.keepalive = setInterval(() => {
47
29
  if (this.awaitingPong) {
48
- // previous ping unanswered for a full interval → half-open connection
49
30
  this.failAll(new Error("LSP websocket unresponsive (no pong)"));
50
31
  try {
51
32
  (ws.terminate ?? ws.close).call(ws);
52
33
  }
53
34
  catch {
54
- /* already gone */
55
35
  }
56
36
  return;
57
37
  }
@@ -61,7 +41,6 @@ export class WsLspTransport {
61
41
  ws.ping();
62
42
  }
63
43
  catch {
64
- /* socket gone — close/error handler does the bookkeeping */
65
44
  }
66
45
  }
67
46
  this.notify("$/keepalive", {});
@@ -69,7 +48,6 @@ export class WsLspTransport {
69
48
  this.keepalive.unref?.();
70
49
  }
71
50
  }
72
- /** Manager-visible liveness (LspTransport.closed): evict + reopen instead of reusing a dead connection. */
73
51
  get closed() {
74
52
  return this.isClosed;
75
53
  }
@@ -79,40 +57,28 @@ export class WsLspTransport {
79
57
  msg = JSON.parse(raw);
80
58
  }
81
59
  catch {
82
- return; // not JSON — ignore
60
+ return;
83
61
  }
84
- // 🔴 A server→client message (has `method`) is a REQUEST (also carries `id`) or a NOTIFICATION (no `id`) — NEVER a
85
- // response to us (a JSON-RPC response has no `method`). Handle it FIRST + by `method`, not by `id`:
86
- // otherwise a server REQUEST whose `id` (the SERVER's id space) COLLIDES with one of OUR pending request ids would
87
- // be `this.pending.get(id)` → resolve OUR request with the server's request as if it were our response = a silent
88
- // wrong answer. We implement NO server→client method → reply `-32601 MethodNotFound` to a REQUEST so the server does
89
- // not hang waiting (some servers send `workspace/configuration` etc. and block until answered); ignore a NOTIFICATION.
90
62
  if (typeof msg.method === "string") {
91
63
  if (msg.id !== undefined && msg.id !== null) {
92
64
  try {
93
65
  this.ws.send(JSON.stringify({ jsonrpc: "2.0", id: msg.id, error: { code: -32601, message: "method not found" } }));
94
66
  }
95
67
  catch {
96
- /* best-effort — a dead socket fails the pending requests elsewhere */
97
68
  }
98
- return; // an answered server REQUEST — never our response, never a notification
69
+ return;
99
70
  }
100
- // design/121 (core 1.220 LspTransport.onNotification): a server NOTIFICATION (method, no id) —
101
- // publishDiagnostics etc. — now dispatches to subscribers (previously dropped). Contract: swallow a
102
- // throwing handler (a bad consumer must never kill the WS read loop). Zero subscribers = old behavior.
103
71
  const params = msg.params;
104
72
  for (const h of this.notificationHandlers) {
105
73
  try {
106
74
  h(msg.method, params);
107
75
  }
108
76
  catch {
109
- /* per-contract: never let a consumer kill the read loop */
110
77
  }
111
78
  }
112
79
  return;
113
80
  }
114
81
  if (typeof msg.id === "number") {
115
- // A RESPONSE to one of our requests (no `method` ⇒ a server-request id can no longer hijack a pending entry).
116
82
  const p = this.pending.get(msg.id);
117
83
  if (p) {
118
84
  this.pending.delete(msg.id);
@@ -138,7 +104,7 @@ export class WsLspTransport {
138
104
  return new Promise((resolve, reject) => {
139
105
  const timer = setTimeout(() => {
140
106
  if (this.pending.delete(id)) {
141
- signal?.removeEventListener("abort", onAbort); // or a long-lived task signal accumulates one listener per timeout
107
+ signal?.removeEventListener("abort", onAbort);
142
108
  reject(new Error(`LSP ${method} timed out after ${this.requestTimeoutMs}ms`));
143
109
  }
144
110
  }, this.requestTimeoutMs);
@@ -185,11 +151,8 @@ export class WsLspTransport {
185
151
  this.ws.send(JSON.stringify({ jsonrpc: "2.0", method, params }));
186
152
  }
187
153
  catch {
188
- /* fire-and-forget */
189
154
  }
190
155
  }
191
- /** design/121 (core 1.220): subscribe to server→client notifications; returns unsubscribe. Additive —
192
- * core's diagnostics registry is the intended consumer; with no subscriber, behavior is byte-identical. */
193
156
  onNotification(handler) {
194
157
  this.notificationHandlers.add(handler);
195
158
  return () => this.notificationHandlers.delete(handler);
@@ -200,28 +163,18 @@ export class WsLspTransport {
200
163
  this.ws.close();
201
164
  }
202
165
  catch {
203
- /* noop */
204
166
  }
205
167
  }
206
168
  }
207
- /**
208
- * Connect to a language server's WS bridge inside E2B and run the LSP `initialize`/`initialized` handshake.
209
- * Returns `undefined` on any failure (→ the manager degrades that language gracefully). `wsUrl` is the
210
- * `wss://…e2b.dev` URL from `sandbox.getHost(port)`; `rootPath` is the in-sandbox workspace root.
211
- */
212
169
  export async function connectWsLspTransport(wsUrl, rootPath, signal, initializationOptions) {
213
170
  let socket;
214
171
  try {
215
172
  socket = new WebSocket(wsUrl);
216
- // Permanent no-op 'error' listener FIRST: Bun's ws shim can emit 'error' again after the once-handler
217
- // below consumed the first one (e.g. a late emission while closing a failed socket). An 'error' event
218
- // with zero listeners throws and KILLS the process — a bridge-still-booting connect retry crashed the
219
- // whole worker in the 2026-06-11 night drill. Control flow still goes through the once-handlers.
220
173
  socket.on("error", () => { });
221
174
  await new Promise((resolve, reject) => {
222
175
  const onAbort = () => reject(new Error("connect aborted"));
223
176
  const settle = (fn) => {
224
- signal?.removeEventListener("abort", onAbort); // don't accumulate listeners on a long-lived task signal
177
+ signal?.removeEventListener("abort", onAbort);
225
178
  fn();
226
179
  };
227
180
  socket.once("open", () => settle(resolve));
@@ -232,10 +185,9 @@ export async function connectWsLspTransport(wsUrl, rootPath, signal, initializat
232
185
  }
233
186
  catch {
234
187
  try {
235
- socket?.close(); // an aborted connect leaves the socket mid-handshake — don't leak it (it WOULD open)
188
+ socket?.close();
236
189
  }
237
190
  catch {
238
- /* never opened */
239
191
  }
240
192
  return undefined;
241
193
  }
@@ -245,8 +197,6 @@ export async function connectWsLspTransport(wsUrl, rootPath, signal, initializat
245
197
  processId: null,
246
198
  rootUri: pathToUri(rootPath),
247
199
  capabilities: { textDocument: { definition: {}, references: {}, hover: {}, documentSymbol: {}, implementation: {}, callHierarchy: {} }, workspace: { symbol: {} } },
248
- // #96 真机门:tls 的 tsserver 路径只能走这里(v4 移除了 CLI 旗);非 tls 服务器按 LSP 规范忽略
249
- // 未知 initializationOptions。缺席时不发键(老行为逐字保持)。
250
200
  ...(initializationOptions !== undefined ? { initializationOptions } : {}),
251
201
  }, signal);
252
202
  transport.notify("initialized", {});
package/dist/lsp-evict.js CHANGED
@@ -1,17 +1,3 @@
1
- /**
2
- * core 1.191 LSP eviction — the host-lane task-end cleanup wrap, factored out of main.ts so it is unit-testable.
3
- *
4
- * Decorate an EPHEMERAL host `ExecutionEnv` so its `destroy()` (task-end, which `rm -rf`s the per-task
5
- * `sema-host-<id>` workspace) ALSO evicts the cached LSP servers rooted at that workspace — so a busy host server
6
- * doesn't retain one heavy language server (jdtls = a whole JVM) per (task × language) until process shutdown.
7
- * `evict` is best-effort + idempotent + fire-and-forget so it NEVER blocks or breaks teardown; the server dies async
8
- * while the dir is rm'd (rooted there, it just sees ENOENT). Only the ephemeral lane is wrapped by the caller — the
9
- * cwdHonored persistent-project path keeps its warm server (stable root, reused across turns = CC-parity, no leak).
10
- *
11
- * Structural param types (no `ExecutionEnv`/`NodeLspManager` import): a non-evicting manager (e2b/k8s bridge) or an
12
- * env without a string `cwd` / callable `destroy` is returned UNWRAPPED (probe-guarded), so this is a safe no-op
13
- * everywhere the precondition doesn't hold.
14
- */
15
1
  export function evictLspOnDestroy(env, lsp) {
16
2
  const evict = lsp?.evict;
17
3
  const e = env;
@@ -20,7 +6,7 @@ export function evictLspOnDestroy(env, lsp) {
20
6
  const origDestroy = e.destroy.bind(e);
21
7
  const root = e.cwd;
22
8
  e.destroy = () => {
23
- void evict.call(lsp, root).catch(() => { }); // fire-and-forget: never block/break teardown on a slow server close
9
+ void evict.call(lsp, root).catch(() => { });
24
10
  return origDestroy();
25
11
  };
26
12
  return env;