@sema-agent/server 1.322.0 → 2.0.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 (539) hide show
  1. package/dist/approval-hmac.d.ts +40 -0
  2. package/dist/approval-hmac.js +67 -0
  3. package/dist/approval.d.ts +31 -0
  4. package/dist/approval.js +72 -4
  5. package/dist/audit.d.ts +26 -0
  6. package/dist/audit.js +40 -1
  7. package/dist/auth-bridge.d.ts +10 -0
  8. package/dist/auth-bridge.js +47 -4
  9. package/dist/auth-keys.d.ts +19 -0
  10. package/dist/auth-keys.js +13 -0
  11. package/dist/bake-runner/main.d.ts +5 -0
  12. package/dist/bake-runner/main.js +43 -4
  13. package/dist/bake-runner/protocol.d.ts +57 -0
  14. package/dist/bake-runner/protocol.js +58 -3
  15. package/dist/bake-runner/runner.d.ts +54 -0
  16. package/dist/bake-runner/runner.js +87 -5
  17. package/dist/bench/l8/artifact.d.ts +63 -0
  18. package/dist/bench/l8/artifact.js +61 -2
  19. package/dist/bench/l8/escape.d.ts +36 -0
  20. package/dist/bench/l8/escape.js +25 -0
  21. package/dist/bench/l8/index.d.ts +14 -0
  22. package/dist/bench/l8/index.js +14 -0
  23. package/dist/bench/l8/probes.d.ts +74 -0
  24. package/dist/bench/l8/probes.js +60 -0
  25. package/dist/bench/l8/run-probes.d.ts +43 -0
  26. package/dist/bench/l8/run-probes.js +45 -2
  27. package/dist/bench/s1/arms.d.ts +126 -0
  28. package/dist/bench/s1/arms.js +188 -13
  29. package/dist/bench/s1/live-deps.d.ts +66 -0
  30. package/dist/bench/s1/live-deps.js +249 -11
  31. package/dist/bench/s1/oracle.d.ts +49 -0
  32. package/dist/bench/s1/oracle.js +36 -1
  33. package/dist/bench/s1/repair-oracle-adapter.d.ts +33 -0
  34. package/dist/bench/s1/repair-oracle-adapter.js +30 -0
  35. package/dist/bench/s1/reviewer.d.ts +38 -0
  36. package/dist/bench/s1/reviewer.js +34 -0
  37. package/dist/bench/s1/row.d.ts +77 -0
  38. package/dist/bench/s1/row.js +62 -0
  39. package/dist/bench/s1/run-firm.d.ts +47 -0
  40. package/dist/bench/s1/run-firm.js +70 -4
  41. package/dist/bench/s1/runner-ctx.d.ts +71 -0
  42. package/dist/bench/s1/runner-ctx.js +36 -0
  43. package/dist/bench/s1/tasks.d.ts +108 -0
  44. package/dist/bench/s1/tasks.js +115 -0
  45. package/dist/boot-reclaim.d.ts +19 -0
  46. package/dist/boot-reclaim.js +20 -0
  47. package/dist/brain.d.ts +25 -0
  48. package/dist/brain.js +61 -1
  49. package/dist/budget.d.ts +66 -0
  50. package/dist/budget.js +128 -4
  51. package/dist/capabilities/builtin-tools.d.ts +3 -0
  52. package/dist/capabilities/builtin-tools.js +3 -0
  53. package/dist/capabilities/center-plugins.d.ts +17 -1
  54. package/dist/capabilities/center-plugins.js +45 -4
  55. package/dist/capabilities/center-prompts.d.ts +46 -0
  56. package/dist/capabilities/center-prompts.js +57 -3
  57. package/dist/capabilities/code-review-council.d.ts +28 -0
  58. package/dist/capabilities/code-review-council.js +40 -7
  59. package/dist/capabilities/collab-wire.d.ts +2 -0
  60. package/dist/capabilities/collab-workflows.d.ts +7 -0
  61. package/dist/capabilities/collab-workflows.js +44 -1
  62. package/dist/capabilities/oa-tools.d.ts +6 -0
  63. package/dist/capabilities/oa-tools.js +10 -0
  64. package/dist/capabilities/prompt.d.ts +14 -0
  65. package/dist/capabilities/prompt.js +14 -0
  66. package/dist/capabilities/prompts/code-review.d.ts +14 -0
  67. package/dist/capabilities/prompts/code-review.js +14 -0
  68. package/dist/capabilities/prompts/identity.d.ts +6 -0
  69. package/dist/capabilities/prompts/identity.js +6 -0
  70. package/dist/capabilities/prompts/team.d.ts +4 -0
  71. package/dist/capabilities/prompts/team.js +4 -0
  72. package/dist/capabilities/repo-tools.d.ts +11 -0
  73. package/dist/capabilities/repo-tools.js +8 -0
  74. package/dist/capabilities/sandbox-file-send.d.ts +95 -0
  75. package/dist/capabilities/sandbox-file-send.js +91 -3
  76. package/dist/capabilities/scenarios.d.ts +130 -0
  77. package/dist/capabilities/scenarios.js +180 -7
  78. package/dist/capabilities/select-environment-tool.d.ts +7 -0
  79. package/dist/capabilities/select-environment-tool.js +30 -0
  80. package/dist/capabilities/send-user-file-tool.d.ts +33 -0
  81. package/dist/capabilities/send-user-file-tool.js +65 -1
  82. package/dist/capabilities/skills.d.ts +29 -0
  83. package/dist/capabilities/skills.js +13 -2
  84. package/dist/capabilities/team.d.ts +22 -0
  85. package/dist/capabilities/team.js +22 -2
  86. package/dist/capabilities/tool-defer.d.ts +26 -0
  87. package/dist/capabilities/tool-defer.js +3 -0
  88. package/dist/config-center/apply-effective.d.ts +65 -0
  89. package/dist/config-center/apply-effective.js +204 -12
  90. package/dist/config-center/http-client.d.ts +34 -0
  91. package/dist/config-center/http-client.js +68 -0
  92. package/dist/config-center/restart-signal.d.ts +22 -0
  93. package/dist/config-center/restart-signal.js +39 -0
  94. package/dist/config-center/skills-mcp.d.ts +20 -1
  95. package/dist/config-center/skills-mcp.js +42 -7
  96. package/dist/config-center/types.d.ts +92 -1
  97. package/dist/config-lkg.d.ts +12 -0
  98. package/dist/config-lkg.js +41 -0
  99. package/dist/config-provider.d.ts +78 -0
  100. package/dist/config-provider.js +165 -2
  101. package/dist/config-types.d.ts +546 -0
  102. package/dist/config.d.ts +64 -0
  103. package/dist/config.js +455 -60
  104. package/dist/degenerate-instrument.d.ts +38 -0
  105. package/dist/degenerate-instrument.js +55 -3
  106. package/dist/elicitation.d.ts +39 -0
  107. package/dist/elicitation.js +87 -3
  108. package/dist/env-facts.d.ts +61 -0
  109. package/dist/env-facts.js +73 -7
  110. package/dist/fleet/fleet-bus.d.ts +185 -0
  111. package/dist/fleet/fleet-bus.js +333 -27
  112. package/dist/fleet/subagent-tail-bus.d.ts +11 -0
  113. package/dist/fleet/subagent-tail-bus.js +33 -2
  114. package/dist/fleet-client.d.ts +38 -0
  115. package/dist/fleet-client.js +44 -9
  116. package/dist/fleet-lease.d.ts +46 -0
  117. package/dist/fleet-lease.js +73 -5
  118. package/dist/hooks/branch-transcript.d.ts +8 -0
  119. package/dist/hooks/branch-transcript.js +33 -0
  120. package/dist/hooks/cc-stop-prompt.d.ts +42 -0
  121. package/dist/hooks/cc-stop-prompt.js +43 -1
  122. package/dist/hooks/hook-llm.d.ts +15 -0
  123. package/dist/hooks/hook-llm.js +47 -0
  124. package/dist/hooks/hook-runner.d.ts +89 -0
  125. package/dist/hooks/hook-runner.js +327 -18
  126. package/dist/http/idempotency.d.ts +31 -0
  127. package/dist/http/idempotency.js +34 -0
  128. package/dist/http/principal-gate.d.ts +17 -0
  129. package/dist/http/principal-gate.js +35 -3
  130. package/dist/http/route-ctx.d.ts +36 -0
  131. package/dist/http/routes/approvals-assistant.d.ts +25 -0
  132. package/dist/http/routes/approvals-assistant.js +253 -23
  133. package/dist/http/routes/attachments.js +22 -4
  134. package/dist/http/routes/capabilities.d.ts +7 -0
  135. package/dist/http/routes/capabilities.js +202 -1
  136. package/dist/http/routes/fleet.d.ts +6 -0
  137. package/dist/http/routes/fleet.js +94 -5
  138. package/dist/http/routes/images.d.ts +17 -0
  139. package/dist/http/routes/images.js +222 -14
  140. package/dist/http/routes/leader.d.ts +7 -0
  141. package/dist/http/routes/leader.js +10 -0
  142. package/dist/http/routes/memory-policy.d.ts +6 -0
  143. package/dist/http/routes/memory-policy.js +38 -6
  144. package/dist/http/routes/notify-wake.d.ts +10 -0
  145. package/dist/http/routes/notify-wake.js +19 -3
  146. package/dist/http/routes/observability.d.ts +6 -0
  147. package/dist/http/routes/observability.js +19 -2
  148. package/dist/http/routes/runs.d.ts +15 -0
  149. package/dist/http/routes/runs.js +464 -41
  150. package/dist/http/routes/session-sync.d.ts +15 -0
  151. package/dist/http/routes/session-sync.js +229 -19
  152. package/dist/http/routes/sessions-list.d.ts +6 -0
  153. package/dist/http/routes/sessions-list.js +35 -4
  154. package/dist/http/routes/sessions.d.ts +14 -0
  155. package/dist/http/routes/sessions.js +176 -31
  156. package/dist/http/routes/side-query.d.ts +8 -0
  157. package/dist/http/routes/side-query.js +26 -1
  158. package/dist/http/routes/tasks.d.ts +18 -0
  159. package/dist/http/routes/tasks.js +501 -38
  160. package/dist/http/routes/trace-usage.d.ts +10 -0
  161. package/dist/http/routes/trace-usage.js +66 -14
  162. package/dist/http/routes/workflows.d.ts +12 -0
  163. package/dist/http/routes/workflows.js +180 -19
  164. package/dist/http/run-meta.d.ts +11 -0
  165. package/dist/http/run-meta.js +6 -0
  166. package/dist/http/send.d.ts +19 -0
  167. package/dist/http/send.js +11 -0
  168. package/dist/http/server.d.ts +255 -0
  169. package/dist/http/server.js +921 -75
  170. package/dist/http/sse-log.d.ts +15 -0
  171. package/dist/http/sse-log.js +16 -0
  172. package/dist/http/tar.d.ts +9 -0
  173. package/dist/http/tar.js +21 -5
  174. package/dist/http/wire-gate.d.ts +9 -0
  175. package/dist/http/wire-gate.js +9 -0
  176. package/dist/http/wire-types.d.ts +187 -0
  177. package/dist/http/workspace-content.d.ts +8 -0
  178. package/dist/http/workspace-content.js +10 -0
  179. package/dist/images/bake-validate.d.ts +63 -0
  180. package/dist/images/bake-validate.js +71 -1
  181. package/dist/images/manifest.d.ts +19 -0
  182. package/dist/images/manifest.js +6 -1
  183. package/dist/index.d.ts +1 -5
  184. package/dist/index.js +10 -5
  185. package/dist/key-resolver.d.ts +23 -0
  186. package/dist/key-resolver.js +27 -2
  187. package/dist/leader/diffout.d.ts +23 -0
  188. package/dist/leader/diffout.js +8 -1
  189. package/dist/leader/diffup.d.ts +32 -0
  190. package/dist/leader/diffup.js +43 -0
  191. package/dist/leader/endpoint.d.ts +20 -0
  192. package/dist/leader/endpoint.js +25 -2
  193. package/dist/leader/fanout.d.ts +60 -0
  194. package/dist/leader/fanout.js +29 -3
  195. package/dist/leader/grader-env-factory.d.ts +74 -0
  196. package/dist/leader/grader-env-factory.js +62 -3
  197. package/dist/leader/leader.d.ts +97 -0
  198. package/dist/leader/leader.js +151 -4
  199. package/dist/leader/merge.d.ts +94 -0
  200. package/dist/leader/merge.js +112 -9
  201. package/dist/leader/planner.d.ts +52 -0
  202. package/dist/leader/planner.js +47 -3
  203. package/dist/leader/repair-oracle.d.ts +61 -0
  204. package/dist/leader/repair-oracle.js +59 -1
  205. package/dist/leader/repair-wire.d.ts +78 -0
  206. package/dist/leader/repair-wire.js +79 -2
  207. package/dist/leader/wire.d.ts +79 -0
  208. package/dist/leader/wire.js +255 -8
  209. package/dist/lsp/e2b-bridge.d.ts +16 -0
  210. package/dist/lsp/e2b-bridge.js +32 -4
  211. package/dist/lsp/e2b-manager.d.ts +10 -0
  212. package/dist/lsp/e2b-manager.js +18 -2
  213. package/dist/lsp/lsp-frames.d.ts +12 -0
  214. package/dist/lsp/lsp-frames.js +12 -0
  215. package/dist/lsp/manager.d.ts +12 -0
  216. package/dist/lsp/manager.js +35 -2
  217. package/dist/lsp/types.d.ts +10 -0
  218. package/dist/lsp/ws-transport.d.ts +12 -0
  219. package/dist/lsp/ws-transport.js +53 -5
  220. package/dist/lsp-evict.d.ts +14 -0
  221. package/dist/lsp-evict.js +15 -1
  222. package/dist/main.js +2132 -96
  223. package/dist/memory-export.d.ts +1 -0
  224. package/dist/memory-export.js +4 -0
  225. package/dist/memory-scope.d.ts +49 -0
  226. package/dist/memory-scope.js +87 -4
  227. package/dist/memory-sync-client.d.ts +24 -0
  228. package/dist/memory-sync-client.js +41 -2
  229. package/dist/memory-sync.d.ts +23 -0
  230. package/dist/memory-sync.js +70 -1
  231. package/dist/model-select.d.ts +39 -0
  232. package/dist/model-select.js +42 -1
  233. package/dist/observability/cost-quota.d.ts +20 -0
  234. package/dist/observability/cost-quota.js +4 -0
  235. package/dist/observability/cost-taxonomy.d.ts +45 -0
  236. package/dist/observability/cost-taxonomy.js +34 -0
  237. package/dist/observability/logger.d.ts +1 -0
  238. package/dist/observability/logger.js +6 -0
  239. package/dist/observability/metrics.d.ts +13 -0
  240. package/dist/observability/metrics.js +63 -0
  241. package/dist/observability/otel-exporter.d.ts +9 -0
  242. package/dist/observability/otel-exporter.js +11 -3
  243. package/dist/observability/principal-context.d.ts +9 -0
  244. package/dist/observability/principal-context.js +9 -0
  245. package/dist/observability/prompt-manifest.d.ts +37 -0
  246. package/dist/observability/prompt-manifest.js +35 -1
  247. package/dist/observability/rate-limit.d.ts +10 -0
  248. package/dist/observability/rate-limit.js +1 -0
  249. package/dist/observability/tool-trace.d.ts +24 -0
  250. package/dist/observability/tool-trace.js +41 -1
  251. package/dist/orchestration/hardened-vm-runner.d.ts +107 -0
  252. package/dist/orchestration/hardened-vm-runner.js +119 -4
  253. package/dist/orchestration/hardened-vm-worker-runner.d.ts +14 -0
  254. package/dist/orchestration/hardened-vm-worker-runner.js +26 -1
  255. package/dist/orchestration/hardened-vm-worker.js +27 -0
  256. package/dist/orchestration/subagent-steer.d.ts +44 -0
  257. package/dist/orchestration/subagent-steer.js +45 -1
  258. package/dist/orchestration/workflow-agent-steer.d.ts +54 -0
  259. package/dist/orchestration/workflow-agent-steer.js +80 -1
  260. package/dist/orchestration/workflow-completion-inbox.d.ts +189 -2
  261. package/dist/orchestration/workflow-completion-inbox.js +283 -32
  262. package/dist/orchestration/workflow-notify-journal.d.ts +132 -1
  263. package/dist/orchestration/workflow-notify-journal.js +187 -13
  264. package/dist/parked-decide.d.ts +61 -0
  265. package/dist/parked-decide.js +58 -1
  266. package/dist/per-task-image.d.ts +54 -0
  267. package/dist/per-task-image.js +41 -0
  268. package/dist/plan-cache-probe.d.ts +35 -0
  269. package/dist/plan-cache-probe.js +18 -3
  270. package/dist/plugins/approval-exemption-store.d.ts +7 -0
  271. package/dist/plugins/approval-exemption-store.js +28 -2
  272. package/dist/plugins/approval-store-sql.d.ts +64 -0
  273. package/dist/plugins/approval-store-sql.js +32 -0
  274. package/dist/plugins/background-agent-store-sql.d.ts +55 -0
  275. package/dist/plugins/background-agent-store-sql.js +91 -4
  276. package/dist/plugins/background-shell-support.d.ts +98 -0
  277. package/dist/plugins/background-shell-support.js +117 -13
  278. package/dist/plugins/blob-backend.d.ts +104 -0
  279. package/dist/plugins/blob-backend.js +163 -6
  280. package/dist/plugins/breaker-state-sql.d.ts +65 -1
  281. package/dist/plugins/breaker-state-sql.js +46 -8
  282. package/dist/plugins/caching-session-store.d.ts +42 -0
  283. package/dist/plugins/caching-session-store.js +63 -3
  284. package/dist/plugins/checkpoint-store-sql.d.ts +179 -0
  285. package/dist/plugins/checkpoint-store-sql.js +239 -11
  286. package/dist/plugins/file-outcome-sink.d.ts +4 -0
  287. package/dist/plugins/file-outcome-sink.js +9 -0
  288. package/dist/plugins/file-resume-anchor-store.d.ts +20 -0
  289. package/dist/plugins/file-resume-anchor-store.js +43 -4
  290. package/dist/plugins/file-run-store.d.ts +90 -0
  291. package/dist/plugins/file-run-store.js +145 -13
  292. package/dist/plugins/file-snapshot-store-sql.d.ts +133 -1
  293. package/dist/plugins/file-snapshot-store-sql.js +178 -10
  294. package/dist/plugins/file-workflow-journal-store.d.ts +10 -0
  295. package/dist/plugins/file-workflow-journal-store.js +10 -0
  296. package/dist/plugins/fork-routing-session-store.d.ts +47 -0
  297. package/dist/plugins/fork-routing-session-store.js +51 -3
  298. package/dist/plugins/host-platform.d.ts +69 -0
  299. package/dist/plugins/host-platform.js +81 -2
  300. package/dist/plugins/image-bake-store-sql.d.ts +136 -1
  301. package/dist/plugins/image-bake-store-sql.js +241 -7
  302. package/dist/plugins/image-index-sql.d.ts +46 -0
  303. package/dist/plugins/image-index-sql.js +113 -4
  304. package/dist/plugins/k8s-bg-scripts.d.ts +34 -0
  305. package/dist/plugins/k8s-bg-scripts.js +88 -4
  306. package/dist/plugins/k8s-exec-protocol.d.ts +33 -0
  307. package/dist/plugins/k8s-exec-protocol.js +41 -0
  308. package/dist/plugins/local-checkpoint-store.d.ts +40 -0
  309. package/dist/plugins/local-checkpoint-store.js +86 -7
  310. package/dist/plugins/local-session-store.d.ts +157 -0
  311. package/dist/plugins/local-session-store.js +289 -34
  312. package/dist/plugins/local-task-attachment-store.js +14 -2
  313. package/dist/plugins/mailbox-store-sql.d.ts +38 -0
  314. package/dist/plugins/mailbox-store-sql.js +39 -6
  315. package/dist/plugins/memory-engine-pg.d.ts +30 -0
  316. package/dist/plugins/memory-engine-pg.js +122 -4
  317. package/dist/plugins/memory-engine-tidb.d.ts +26 -0
  318. package/dist/plugins/memory-engine-tidb.js +115 -5
  319. package/dist/plugins/memory-engine-vector-util.d.ts +5 -0
  320. package/dist/plugins/memory-engine-vector-util.js +5 -0
  321. package/dist/plugins/memory-resume-anchor-store.d.ts +8 -0
  322. package/dist/plugins/memory-resume-anchor-store.js +17 -0
  323. package/dist/plugins/memory-run-store.d.ts +63 -0
  324. package/dist/plugins/memory-run-store.js +73 -8
  325. package/dist/plugins/memory-session-policy-store.d.ts +17 -0
  326. package/dist/plugins/memory-session-policy-store.js +17 -0
  327. package/dist/plugins/memory-sync-store-pg.d.ts +42 -0
  328. package/dist/plugins/memory-sync-store-pg.js +45 -2
  329. package/dist/plugins/memory-sync-store-tidb.d.ts +9 -0
  330. package/dist/plugins/memory-sync-store-tidb.js +31 -1
  331. package/dist/plugins/outcome-ledger-sql.d.ts +63 -0
  332. package/dist/plugins/outcome-ledger-sql.js +97 -3
  333. package/dist/plugins/pg-approval-store.d.ts +7 -0
  334. package/dist/plugins/pg-approval-store.js +7 -0
  335. package/dist/plugins/pg-breaker-state.d.ts +6 -0
  336. package/dist/plugins/pg-breaker-state.js +6 -0
  337. package/dist/plugins/pg-checkpoint-store.d.ts +8 -0
  338. package/dist/plugins/pg-checkpoint-store.js +8 -0
  339. package/dist/plugins/pg-cost-quota.d.ts +17 -0
  340. package/dist/plugins/pg-cost-quota.js +6 -0
  341. package/dist/plugins/pg-file-snapshot-store.d.ts +6 -0
  342. package/dist/plugins/pg-file-snapshot-store.js +6 -0
  343. package/dist/plugins/pg-image-bake.d.ts +9 -0
  344. package/dist/plugins/pg-image-bake.js +9 -0
  345. package/dist/plugins/pg-image-index.d.ts +9 -0
  346. package/dist/plugins/pg-image-index.js +9 -0
  347. package/dist/plugins/pg-outcome-ledger.d.ts +9 -0
  348. package/dist/plugins/pg-outcome-ledger.js +9 -0
  349. package/dist/plugins/pg-pool.d.ts +50 -0
  350. package/dist/plugins/pg-pool.js +78 -0
  351. package/dist/plugins/pg-query.d.ts +11 -0
  352. package/dist/plugins/pg-rate-limiter.d.ts +23 -0
  353. package/dist/plugins/pg-rate-limiter.js +12 -2
  354. package/dist/plugins/pg-resume-anchor-store.d.ts +5 -0
  355. package/dist/plugins/pg-resume-anchor-store.js +5 -0
  356. package/dist/plugins/pg-run-store.d.ts +7 -0
  357. package/dist/plugins/pg-run-store.js +7 -0
  358. package/dist/plugins/pg-safe-json.d.ts +13 -0
  359. package/dist/plugins/pg-safe-json.js +40 -4
  360. package/dist/plugins/pg-session-policy-store.d.ts +5 -0
  361. package/dist/plugins/pg-session-policy-store.js +5 -0
  362. package/dist/plugins/pg-session-storage.d.ts +72 -0
  363. package/dist/plugins/pg-session-storage.js +152 -20
  364. package/dist/plugins/pg-session-store.d.ts +10 -0
  365. package/dist/plugins/pg-session-store.js +10 -0
  366. package/dist/plugins/pg-tool-result-store.d.ts +7 -0
  367. package/dist/plugins/pg-tool-result-store.js +7 -0
  368. package/dist/plugins/pg-workflow-journal-store.d.ts +7 -0
  369. package/dist/plugins/pg-workflow-journal-store.js +7 -0
  370. package/dist/plugins/pg-workflow-run-store.d.ts +7 -0
  371. package/dist/plugins/pg-workflow-run-store.js +7 -0
  372. package/dist/plugins/posix-shell-fs.d.ts +3 -0
  373. package/dist/plugins/posix-shell-fs.js +31 -1
  374. package/dist/plugins/remote-env-adb.d.ts +25 -0
  375. package/dist/plugins/remote-env-adb.js +95 -12
  376. package/dist/plugins/remote-env-e2b.d.ts +146 -0
  377. package/dist/plugins/remote-env-e2b.js +371 -40
  378. package/dist/plugins/remote-env-file-error.d.ts +34 -0
  379. package/dist/plugins/remote-env-file-error.js +37 -0
  380. package/dist/plugins/remote-env-host.d.ts +151 -0
  381. package/dist/plugins/remote-env-host.js +468 -70
  382. package/dist/plugins/remote-env-k8s.d.ts +135 -0
  383. package/dist/plugins/remote-env-k8s.js +318 -32
  384. package/dist/plugins/remote-env-local-docker.d.ts +65 -0
  385. package/dist/plugins/remote-env-local-docker.js +149 -24
  386. package/dist/plugins/remote-env-ssh.d.ts +35 -0
  387. package/dist/plugins/remote-env-ssh.js +117 -20
  388. package/dist/plugins/remote-scratchpad.d.ts +38 -0
  389. package/dist/plugins/remote-scratchpad.js +32 -2
  390. package/dist/plugins/remote-shell.d.ts +22 -0
  391. package/dist/plugins/remote-shell.js +27 -1
  392. package/dist/plugins/resume-anchor-store-sql.d.ts +28 -0
  393. package/dist/plugins/resume-anchor-store-sql.js +11 -0
  394. package/dist/plugins/roster-store-sql.d.ts +27 -0
  395. package/dist/plugins/roster-store-sql.js +54 -0
  396. package/dist/plugins/run-store-sql.d.ts +194 -0
  397. package/dist/plugins/run-store-sql.js +210 -9
  398. package/dist/plugins/s3-presign.d.ts +20 -0
  399. package/dist/plugins/s3-presign.js +49 -2
  400. package/dist/plugins/scheduler-support.d.ts +12 -0
  401. package/dist/plugins/scheduler-support.js +75 -3
  402. package/dist/plugins/send-file-ledger.d.ts +15 -0
  403. package/dist/plugins/send-file-ledger.js +53 -4
  404. package/dist/plugins/send-user-file.d.ts +77 -0
  405. package/dist/plugins/send-user-file.js +92 -4
  406. package/dist/plugins/session-policy-store-sql.d.ts +15 -0
  407. package/dist/plugins/session-policy-store-sql.js +75 -3
  408. package/dist/plugins/session-store.d.ts +45 -0
  409. package/dist/plugins/session-store.js +51 -0
  410. package/dist/plugins/sql-driver.d.ts +77 -0
  411. package/dist/plugins/sql-driver.js +4 -0
  412. package/dist/plugins/sql-escape.d.ts +8 -0
  413. package/dist/plugins/sql-escape.js +8 -0
  414. package/dist/plugins/sql-row-helpers.d.ts +25 -0
  415. package/dist/plugins/sql-row-helpers.js +25 -0
  416. package/dist/plugins/store-backend.d.ts +103 -0
  417. package/dist/plugins/store-backend.js +120 -27
  418. package/dist/plugins/store-contracts.d.ts +62 -0
  419. package/dist/plugins/store-contracts.js +3 -0
  420. package/dist/plugins/task-attachment-store.d.ts +60 -0
  421. package/dist/plugins/task-attachment-store.js +49 -3
  422. package/dist/plugins/task-list-store-sql.d.ts +25 -0
  423. package/dist/plugins/task-list-store-sql.js +21 -0
  424. package/dist/plugins/tidb-approval-store.d.ts +6 -0
  425. package/dist/plugins/tidb-approval-store.js +6 -0
  426. package/dist/plugins/tidb-breaker-state.d.ts +5 -0
  427. package/dist/plugins/tidb-breaker-state.js +5 -0
  428. package/dist/plugins/tidb-checkpoint-store.d.ts +7 -0
  429. package/dist/plugins/tidb-checkpoint-store.js +7 -0
  430. package/dist/plugins/tidb-cost-quota.d.ts +6 -0
  431. package/dist/plugins/tidb-cost-quota.js +1 -0
  432. package/dist/plugins/tidb-file-snapshot-store.d.ts +6 -0
  433. package/dist/plugins/tidb-file-snapshot-store.js +6 -0
  434. package/dist/plugins/tidb-image-bake.d.ts +8 -0
  435. package/dist/plugins/tidb-image-bake.js +8 -0
  436. package/dist/plugins/tidb-image-index.d.ts +8 -0
  437. package/dist/plugins/tidb-image-index.js +8 -0
  438. package/dist/plugins/tidb-outcome-ledger.d.ts +10 -0
  439. package/dist/plugins/tidb-outcome-ledger.js +10 -0
  440. package/dist/plugins/tidb-pool.d.ts +56 -0
  441. package/dist/plugins/tidb-pool.js +181 -1
  442. package/dist/plugins/tidb-rate-limiter.d.ts +11 -0
  443. package/dist/plugins/tidb-rate-limiter.js +5 -2
  444. package/dist/plugins/tidb-resume-anchor-store.d.ts +5 -0
  445. package/dist/plugins/tidb-resume-anchor-store.js +5 -0
  446. package/dist/plugins/tidb-run-store.d.ts +7 -0
  447. package/dist/plugins/tidb-run-store.js +7 -0
  448. package/dist/plugins/tidb-session-policy-store.d.ts +5 -0
  449. package/dist/plugins/tidb-session-policy-store.js +5 -0
  450. package/dist/plugins/tidb-session-storage.d.ts +43 -0
  451. package/dist/plugins/tidb-session-storage.js +62 -3
  452. package/dist/plugins/tidb-session-store.d.ts +142 -0
  453. package/dist/plugins/tidb-session-store.js +264 -16
  454. package/dist/plugins/tidb-tool-result-store.d.ts +5 -0
  455. package/dist/plugins/tidb-tool-result-store.js +7 -0
  456. package/dist/plugins/tidb-workflow-journal-store.d.ts +7 -0
  457. package/dist/plugins/tidb-workflow-journal-store.js +7 -0
  458. package/dist/plugins/tidb-workflow-run-store.d.ts +8 -0
  459. package/dist/plugins/tidb-workflow-run-store.js +8 -0
  460. package/dist/plugins/tool-result-store-sql.d.ts +58 -0
  461. package/dist/plugins/tool-result-store-sql.js +38 -2
  462. package/dist/plugins/web-search.d.ts +35 -0
  463. package/dist/plugins/web-search.js +45 -9
  464. package/dist/plugins/workflow-journal-limits.d.ts +10 -0
  465. package/dist/plugins/workflow-journal-limits.js +10 -0
  466. package/dist/plugins/workflow-journal-store-sql.d.ts +78 -0
  467. package/dist/plugins/workflow-journal-store-sql.js +59 -3
  468. package/dist/plugins/workflow-run-store-sql.d.ts +84 -0
  469. package/dist/plugins/workflow-run-store-sql.js +84 -6
  470. package/dist/plugins/worktree-isolation.d.ts +45 -0
  471. package/dist/plugins/worktree-isolation.js +105 -6
  472. package/dist/plugins/write-behind-counter.d.ts +56 -1
  473. package/dist/plugins/write-behind-counter.js +53 -14
  474. package/dist/principal-jwt.d.ts +24 -0
  475. package/dist/principal-jwt.js +60 -5
  476. package/dist/project-memory.d.ts +22 -0
  477. package/dist/project-memory.js +144 -15
  478. package/dist/prompts-domain-validate.d.ts +28 -0
  479. package/dist/prompts-domain-validate.js +42 -1
  480. package/dist/question.d.ts +33 -0
  481. package/dist/question.js +69 -2
  482. package/dist/resource-suspend.d.ts +21 -0
  483. package/dist/resource-suspend.js +16 -0
  484. package/dist/router/route-orchestration.d.ts +78 -0
  485. package/dist/router/route-orchestration.js +77 -0
  486. package/dist/run-local.d.ts +32 -0
  487. package/dist/run-local.js +172 -8
  488. package/dist/runs.d.ts +189 -4
  489. package/dist/runs.js +465 -24
  490. package/dist/runtime-caps-resolver.d.ts +106 -0
  491. package/dist/runtime-caps-resolver.js +89 -4
  492. package/dist/runtime-governance.d.ts +84 -0
  493. package/dist/runtime-governance.js +127 -1
  494. package/dist/sandbox-pkg-source.d.ts +23 -0
  495. package/dist/sandbox-pkg-source.js +37 -0
  496. package/dist/sealed-key.d.ts +54 -0
  497. package/dist/sealed-key.js +68 -3
  498. package/dist/security.d.ts +108 -0
  499. package/dist/security.js +145 -6
  500. package/dist/sema-registry.d.ts +21 -0
  501. package/dist/sema-registry.js +21 -0
  502. package/dist/session-leaf-bus.d.ts +31 -0
  503. package/dist/session-leaf-bus.js +32 -0
  504. package/dist/session-sync-content.d.ts +46 -0
  505. package/dist/session-sync-content.js +47 -1
  506. package/dist/session-sync-kernel.d.ts +89 -0
  507. package/dist/session-sync-kernel.js +48 -3
  508. package/dist/session-sync.d.ts +125 -0
  509. package/dist/session-sync.js +181 -8
  510. package/dist/session-titler.d.ts +26 -0
  511. package/dist/session-titler.js +41 -7
  512. package/dist/session-watch.d.ts +53 -1
  513. package/dist/session-watch.js +73 -9
  514. package/dist/sighup-idle.d.ts +30 -0
  515. package/dist/sighup-idle.js +12 -1
  516. package/dist/spec-fields.d.ts +91 -3
  517. package/dist/spec-fields.js +116 -4
  518. package/dist/task-cwd.d.ts +50 -0
  519. package/dist/task-cwd.js +68 -1
  520. package/dist/task-mcp.d.ts +47 -0
  521. package/dist/task-mcp.js +29 -0
  522. package/dist/task-settings.d.ts +175 -0
  523. package/dist/task-settings.js +226 -11
  524. package/dist/task-workflow.d.ts +67 -0
  525. package/dist/task-workflow.js +75 -8
  526. package/dist/tool-approval.d.ts +91 -0
  527. package/dist/tool-approval.js +215 -0
  528. package/dist/trace/artifacts.d.ts +9 -0
  529. package/dist/trace/artifacts.js +30 -5
  530. package/dist/trace/core-keyset-guard.d.ts +18 -0
  531. package/dist/trace/ledger-sink.d.ts +43 -0
  532. package/dist/trace/ledger-sink.js +64 -5
  533. package/dist/trace/project.d.ts +133 -0
  534. package/dist/trace/project.js +189 -2
  535. package/dist/trace/redact.d.ts +19 -0
  536. package/dist/trace/redact.js +66 -9
  537. package/dist/usage-analytics.d.ts +26 -0
  538. package/dist/usage-analytics.js +26 -3
  539. package/package.json +1 -1
@@ -1,4 +1,20 @@
1
+ /**
2
+ * The WS↔stdio bridge that runs INSIDE the E2B sandbox + the setup it needs. A language server speaks LSP-JSON-RPC
3
+ * over stdio with **Content-Length** framing; our `WsLspTransport` speaks one raw JSON-RPC message per WS frame.
4
+ * This bridge (started per language server, exposed via `sandbox.getHost(port)`) translates between the two — it's
5
+ * the piece that lets core's stdio-only LSP design work over E2B's HTTP/WS proxy (no stdin on `execStream`).
6
+ *
7
+ * **Proven end-to-end** (scripts/lsp-live-test.ts): `goToDefinition` resolved to the real definition through
8
+ * `wss://…e2b.app`. For production the servers + bridge should be BAKED into an E2B template (the heavy-install
9
+ * pitfall); `lspInstallAndStart` is the on-the-fly path for P1 / un-baked templates.
10
+ */
1
11
  import { FRAME_DECODER_JS } from "./lsp-frames.js";
12
+ /**
13
+ * Bridges WS ⇄ a language server's stdio. Server command from `LSP_CMD`, port `LSP_PORT`, and a per-session
14
+ * **auth token** `LSP_TOKEN` (the endpoint is a public `wss://<port>-<id>.e2b.app` URL — the runner connects with
15
+ * `?token=<secret>`; without it, anyone with the URL could read the workspace via LSP, council #4). Frame parsing
16
+ * uses the unit-tested {@link FRAME_DECODER_JS} (council #1/#2/#5).
17
+ */
2
18
  export const BRIDGE_SOURCE = FRAME_DECODER_JS +
3
19
  String.raw `
4
20
  const { WebSocketServer } = require('ws');
@@ -36,26 +52,35 @@ setInterval(() => {
36
52
  }, HEARTBEAT_MS);
37
53
  console.log('lsp-bridge listening', PORT);
38
54
  `;
55
+ /** Language server command per languageId. P1 = typescript/javascript; dart/kotlin land with their template servers.
56
+ * `--stdio` only where the server needs it to pick stdio over its other transports (the node-based servers);
57
+ * gopls/jdtls/kotlin-language-server/sourcekit-lsp/`dart language-server` speak LSP over stdio by default. */
39
58
  export const SERVER_CMD = {
40
59
  typescript: "typescript-language-server --stdio",
41
60
  javascript: "typescript-language-server --stdio",
42
- python: "pyright-langserver --stdio",
43
- go: "gopls",
44
- dart: "dart language-server",
45
- kotlin: "kotlin-language-server",
61
+ python: "pyright-langserver --stdio", // dev-base bakes pyright
62
+ go: "gopls", // gopls serves LSP over stdio by default; baked in dev-base (no on-the-fly path — needs the go toolchain)
63
+ // dev-mobile baked servers (all stdio; no on-the-fly path — they need their SDKs):
64
+ dart: "dart language-server", // built into the Dart SDK (comes with Flutter)
65
+ kotlin: "kotlin-language-server", // fwcd candidate; a future bake-off may switch this to JetBrains kotlin-lsp
46
66
  java: "jdtls",
47
67
  swift: "sourcekit-lsp",
48
68
  };
69
+ /** npm packages a non-baked sandbox needs (on-the-fly install). Languages absent here (go) REQUIRE a baked template. */
49
70
  export const SERVER_NPM = {
50
71
  typescript: "typescript-language-server typescript",
51
72
  javascript: "typescript-language-server typescript",
52
73
  python: "pyright",
53
74
  };
75
+ /** Bridge dir + port inside the sandbox. One bridge process per language → distinct ports. */
54
76
  export const BRIDGE_DIR = "/home/user/.lsp-bridge";
55
77
  export function portForLanguage(language) {
78
+ // stable per-language port; extend the table as templates add servers (dev-mobile: dart/kotlin/java/swift)
56
79
  const ports = { typescript: 8123, javascript: 8123, dart: 8124, kotlin: 8125, python: 8126, go: 8127, java: 8128, swift: 8129 };
57
80
  return ports[language] ?? 8123;
58
81
  }
82
+ /** FOREGROUND install (run via `env.exec` — must finish before the start). A baked template makes both checks
83
+ * skip instantly; a non-baked sandbox npm-installs the server + ws here (slow once per sandbox). */
59
84
  export function lspInstallCommand(language) {
60
85
  const cmd = SERVER_CMD[language];
61
86
  const npm = SERVER_NPM[language];
@@ -65,6 +90,9 @@ export function lspInstallCommand(language) {
65
90
  npm ? `command -v ${cmd.split(" ")[0]} >/dev/null || npm i -g ${npm} >>/tmp/lsp-setup.log 2>&1` : "true",
66
91
  ].join(" && ");
67
92
  }
93
+ /** Start the bridge — run as a TRUE background command (`env.startBackground`), NOT `&`-backgrounded inside a
94
+ * foreground run: E2B reaps the foreground process group on completion, killing an in-shell `&`/nohup child.
95
+ * So node is the FOREGROUND here and E2B keeps the background command alive. */
68
96
  export function lspStartCommand(language, port, token) {
69
97
  return `cd ${BRIDGE_DIR} && LSP_PORT=${port} LSP_TOKEN='${token}' LSP_CMD='${SERVER_CMD[language]}' node bridge.cjs`;
70
98
  }
@@ -2,15 +2,25 @@ import { connectWsLspTransport } from "./ws-transport.js";
2
2
  import { E2bLspManager, type LspCapableEnv } from "./manager.js";
3
3
  import type { LspTransport } from "./types.js";
4
4
  export interface E2bLspOptions {
5
+ /** Injectable for tests (no E2B/ws). */
5
6
  connect?: typeof connectWsLspTransport;
6
7
  retry?: {
7
8
  attempts: number;
8
9
  delayMs: number;
9
10
  };
11
+ /** Bridge auth token override. The manager pins ONE token per env+language: on a RE-open (transport heal
12
+ * after the E2B proxy idle-killed the WS) the original bridge process is still listening with the FIRST
13
+ * token — a fresh random token would be rejected and the reconnect would always fail. */
10
14
  token?: string;
15
+ /** WS scheme for the bridge URL. E2B's `getHost` returns a public TLS proxy host → `wss` (default);
16
+ * the k8s adapter returns a cluster-internal `podIP:port` → plain `ws` (no TLS on the pod network;
17
+ * the per-session bridge token still gates access). */
11
18
  scheme?: "ws" | "wss";
19
+ /** Observability hook (open/heal/degrade events) — prod wires the service logger. */
12
20
  log?: (event: string, fields: Record<string, unknown>) => void;
13
21
  }
22
+ /** Start (+ install on a non-baked template) the language server + bridge inside THIS env's sandbox, then connect. */
14
23
  export declare function openE2bLspTransport(language: string, env: LspCapableEnv, opts?: E2bLspOptions): Promise<LspTransport | undefined>;
24
+ /** The single shared `LspServerManager` for the deployment (`RunnerDeps.lspManager`). */
15
25
  export declare function createE2bLspManager(opts?: E2bLspOptions): E2bLspManager;
16
26
  //# sourceMappingURL=e2b-manager.d.ts.map
@@ -1,10 +1,21 @@
1
+ /**
2
+ * E2B LSP wiring — `createE2bLspManager()` builds the ONE stateless manager (core 1.86.2 seam: core passes
3
+ * the task's env into `sessionFor` at the tool mount point, so there is NO sessionId→env registry and no per-task
4
+ * manager construction; the old registry/monkey-patch wiring is gone).
5
+ *
6
+ * `openE2bLspTransport` does the per-sandbox start: write bridge.cjs from BRIDGE_SOURCE (single source of truth —
7
+ * works on baked + un-baked templates) → foreground install (baked template skips instantly) → start the bridge
8
+ * as a TRUE background command (a shell `&` child gets reaped when E2B completes the foreground command) → WS
9
+ * connect via `wss://getHost(port)?token=…` (per-session auth — the URL is public).
10
+ */
1
11
  import { randomUUID } from "node:crypto";
2
12
  import { connectWsLspTransport } from "./ws-transport.js";
3
13
  import { E2bLspManager } from "./manager.js";
4
14
  import { BRIDGE_DIR, BRIDGE_SOURCE, lspInstallCommand, lspStartCommand, portForLanguage, SERVER_CMD } from "./e2b-bridge.js";
15
+ /** Start (+ install on a non-baked template) the language server + bridge inside THIS env's sandbox, then connect. */
5
16
  export async function openE2bLspTransport(language, env, opts) {
6
17
  if (!SERVER_CMD[language])
7
- return undefined;
18
+ return undefined; // no server for this language → graceful degrade
8
19
  const connect = opts?.connect ?? connectWsLspTransport;
9
20
  const retry = opts?.retry ?? { attempts: 6, delayMs: 1500 };
10
21
  const port = portForLanguage(language);
@@ -12,9 +23,10 @@ export async function openE2bLspTransport(language, env, opts) {
12
23
  const installed = await env.exec(lspInstallCommand(language)).catch(() => undefined);
13
24
  if (!installed || !installed.ok)
14
25
  return undefined;
15
- const token = opts?.token ?? randomUUID();
26
+ const token = opts?.token ?? randomUUID(); // per-session bridge auth — the getHost URL is public (council #4)
16
27
  await env.startBackground(lspStartCommand(language, port, token)).catch(() => undefined);
17
28
  const root = env.workspaceHandle().mountPath;
29
+ // the bridge starts as a background command → retry the WS connect (with the auth token) while it comes up
18
30
  const scheme = opts?.scheme ?? "wss";
19
31
  for (let attempt = 0; attempt < retry.attempts; attempt++) {
20
32
  const host = await env.getHost(port);
@@ -27,7 +39,11 @@ export async function openE2bLspTransport(language, env, opts) {
27
39
  }
28
40
  return undefined;
29
41
  }
42
+ /** The single shared `LspServerManager` for the deployment (`RunnerDeps.lspManager`). */
30
43
  export function createE2bLspManager(opts) {
44
+ // One bridge token per env+language, pinned across re-opens (heal after an idle-killed WS): the original
45
+ // bridge keeps listening with the first token, so the reconnect must present the SAME one. WeakMap → a
46
+ // destroyed task's tokens are collectible with its env.
31
47
  const tokens = new WeakMap();
32
48
  return new E2bLspManager({
33
49
  log: opts?.log,
@@ -1,2 +1,14 @@
1
+ /**
2
+ * The LSP stdio Content-Length frame decoder, as JS SOURCE — embedded verbatim into `BRIDGE_SOURCE` (which runs
3
+ * inside the E2B sandbox, can't import TS) AND unit-tested here (test/lsp-frames.test.ts evals this same string).
4
+ * So the in-sandbox parser is actually exercised (council #5: the untestable raw-string parser was the risk).
5
+ *
6
+ * Guards: a frame claiming a non-finite / negative / over-cap length is skipped instead of looping or waiting
7
+ * forever (council #1 defense); the accumulator is dropped if it exceeds the cap with no complete frame (council
8
+ * #2 — a server that never sends `\r\n\r\n`, or a huge Content-Length, can't grow the buffer without bound).
9
+ * The runaway cap carries a `HEADER_SLACK` (core 1.196 #6 twin): a VALID frame whose PAYLOAD passes the
10
+ * `len <= maxBytes` check but whose `Content-Length: <n>\r\n\r\n` header pushes header+payload just over `maxBytes`
11
+ * must NOT be wiped mid-arrival (that silently dropped an in-window legal reply) — so cap at `maxBytes + 128`.
12
+ */
1
13
  export declare const FRAME_DECODER_JS: string;
2
14
  //# sourceMappingURL=lsp-frames.d.ts.map
@@ -1,3 +1,15 @@
1
+ /**
2
+ * The LSP stdio Content-Length frame decoder, as JS SOURCE — embedded verbatim into `BRIDGE_SOURCE` (which runs
3
+ * inside the E2B sandbox, can't import TS) AND unit-tested here (test/lsp-frames.test.ts evals this same string).
4
+ * So the in-sandbox parser is actually exercised (council #5: the untestable raw-string parser was the risk).
5
+ *
6
+ * Guards: a frame claiming a non-finite / negative / over-cap length is skipped instead of looping or waiting
7
+ * forever (council #1 defense); the accumulator is dropped if it exceeds the cap with no complete frame (council
8
+ * #2 — a server that never sends `\r\n\r\n`, or a huge Content-Length, can't grow the buffer without bound).
9
+ * The runaway cap carries a `HEADER_SLACK` (core 1.196 #6 twin): a VALID frame whose PAYLOAD passes the
10
+ * `len <= maxBytes` check but whose `Content-Length: <n>\r\n\r\n` header pushes header+payload just over `maxBytes`
11
+ * must NOT be wiped mid-arrival (that silently dropped an in-window legal reply) — so cap at `maxBytes + 128`.
12
+ */
1
13
  export const FRAME_DECODER_JS = String.raw `
2
14
  function makeFrameDecoder(maxBytes) {
3
15
  var HEADER_SLACK = 128; // room for "Content-Length: <n>\r\n\r\n" ON TOP of a max-size payload (core 1.196 #6 twin)
@@ -1,6 +1,7 @@
1
1
  import { LspDiagnosticsRegistry } from "@sema-agent/core";
2
2
  import type { ExecutionEnv } from "@sema-agent/core";
3
3
  import type { LspServerManager, LspSession, LspTransport } from "./types.js";
4
+ /** The E2B surface the LSP needs beyond base ExecutionEnv (present on RemoteContainerExecutionEnv). */
4
5
  export interface LspCapableEnv {
5
6
  exec(command: string): Promise<{
6
7
  ok: boolean;
@@ -22,17 +23,28 @@ export interface LspCapableEnv {
22
23
  mountPath: string;
23
24
  };
24
25
  }
26
+ /** Duck-type check: is this ExecutionEnv an E2B adapter with the LSP surface? */
25
27
  export declare function isLspCapable(env: ExecutionEnv): env is ExecutionEnv & LspCapableEnv;
26
28
  export interface E2bLspManagerOptions {
29
+ /** Opens (+ `initialize`s) a WS transport to the language server inside THIS env's sandbox. */
27
30
  transportFactory: (language: string, env: LspCapableEnv) => Promise<LspTransport | undefined>;
31
+ /** Override the file-extension → languageId map. */
28
32
  extToLang?: Readonly<Record<string, string>>;
33
+ /** Observability hook (open/heal/degrade events) — prod wires the service logger; silent when unset. */
29
34
  log?: (event: string, fields: Record<string, unknown>) => void;
30
35
  }
31
36
  export declare class E2bLspManager implements LspServerManager {
37
+ /** Per-sandbox session cache: env (weak) → language → in-flight/ready session. */
32
38
  private readonly perEnv;
33
39
  private readonly factory;
34
40
  private readonly extToLang;
35
41
  private readonly log;
42
+ /** design/121 (core 1.220, board [S] ①): the workspace diagnostics registry — WORKSPACE-scoped (survives
43
+ * heal/evict; diagnostics belong to files, not servers), drained by the Runner at turn boundaries. Every
44
+ * session feeds it from `textDocument/publishDiagnostics` (the WS transport now dispatches notifications).
45
+ * ⚠️ ONE registry across sandboxes on this manager instance (it is per-deployment) — same posture as
46
+ * NodeLspManager's workspace scoping; a task only sees diagnostics for files IT touched (delivered-set +
47
+ * fileEdited keying is per-uri, and sandbox workspace paths are per-task-unique). */
36
48
  readonly diagnostics: LspDiagnosticsRegistry;
37
49
  constructor(opts: E2bLspManagerOptions);
38
50
  sessionFor(filePath: string, _signal?: AbortSignal, env?: ExecutionEnv): Promise<LspSession | undefined>;
@@ -1,5 +1,16 @@
1
+ /**
2
+ * `E2bLspManager` — our `LspServerManager` (core mounts the `lsp` tool over it). STATELESS since core 1.86.2:
3
+ * core passes the task's own ExecutionEnv into `sessionFor(filePath, signal, env)` (prepare-task
4
+ * has the per-task env in scope), so ONE manager serves all tasks; no sessionId→env registry, no per-task
5
+ * construction. Sessions are cached per env+language (a language server is heavy — keep it warm per sandbox)
6
+ * in a WeakMap, so a destroyed task's entries become collectible (its bridge dies with the sandbox).
7
+ *
8
+ * Any miss (no env / unknown language / env without the E2B surface / failed open) → `undefined`, which makes
9
+ * core's tool degrade gracefully to grep/read_file.
10
+ */
1
11
  import path from "node:path";
2
12
  import { TransportLspSession, LspDiagnosticsRegistry } from "@sema-agent/core";
13
+ /** Duck-type check: is this ExecutionEnv an E2B adapter with the LSP surface? */
3
14
  export function isLspCapable(env) {
4
15
  const e = env;
5
16
  return typeof e.getHost === "function" && typeof e.startBackground === "function" && typeof e.workspaceHandle === "function";
@@ -23,10 +34,17 @@ const DEFAULT_EXT_TO_LANG = {
23
34
  ".rs": "rust",
24
35
  };
25
36
  export class E2bLspManager {
37
+ /** Per-sandbox session cache: env (weak) → language → in-flight/ready session. */
26
38
  perEnv = new WeakMap();
27
39
  factory;
28
40
  extToLang;
29
41
  log;
42
+ /** design/121 (core 1.220, board [S] ①): the workspace diagnostics registry — WORKSPACE-scoped (survives
43
+ * heal/evict; diagnostics belong to files, not servers), drained by the Runner at turn boundaries. Every
44
+ * session feeds it from `textDocument/publishDiagnostics` (the WS transport now dispatches notifications).
45
+ * ⚠️ ONE registry across sandboxes on this manager instance (it is per-deployment) — same posture as
46
+ * NodeLspManager's workspace scoping; a task only sees diagnostics for files IT touched (delivered-set +
47
+ * fileEdited keying is per-uri, and sandbox workspace paths are per-task-unique). */
30
48
  diagnostics = new LspDiagnosticsRegistry();
31
49
  constructor(opts) {
32
50
  this.factory = opts.transportFactory;
@@ -35,7 +53,7 @@ export class E2bLspManager {
35
53
  }
36
54
  async sessionFor(filePath, _signal, env) {
37
55
  if (!env || !isLspCapable(env))
38
- return undefined;
56
+ return undefined; // no env passed (core <1.86.2) or not the E2B adapter → degrade
39
57
  const language = this.extToLang[path.extname(filePath).toLowerCase()];
40
58
  if (!language)
41
59
  return undefined;
@@ -45,7 +63,7 @@ export class E2bLspManager {
45
63
  this.perEnv.set(env, sessions);
46
64
  }
47
65
  let pending = sessions.get(language);
48
- const fresh = !pending;
66
+ const fresh = !pending; // capture BEFORE assigning, or the open/open_failed log is dead code (review 2026-06-10)
49
67
  if (!pending) {
50
68
  pending = this.open(language, env);
51
69
  sessions.set(language, pending);
@@ -54,6 +72,13 @@ export class E2bLspManager {
54
72
  if (fresh)
55
73
  this.log(session ? "lsp_session_open" : "lsp_session_open_failed", { language });
56
74
  if (session?.closed) {
75
+ // Transport died between tool calls (the E2B proxy idle-kills silent WS connections — live-drill
76
+ // finding 2026-06-10). Heal: evict + reopen ONCE — the bridge spawns a fresh server per connection.
77
+ // Carry the dead session's opened files over: a fresh server with no project config only "sees" its
78
+ // open files, so without the replay cross-file ops silently degrade to single-file (live-repro).
79
+ // Guard against clobbering a concurrent heal: a racer that lost sees sessions.get !== its pending and
80
+ // adopts the winner's reopen. ⚠️ Relies on JS run-to-completion — there is NO await between the
81
+ // delete and the set below (this.open() is CALLED but not awaited); do not insert one.
57
82
  const carry = session.openedFiles();
58
83
  if (sessions.get(language) === pending)
59
84
  sessions.delete(language);
@@ -64,6 +89,8 @@ export class E2bLspManager {
64
89
  await session.warmOpen(carry);
65
90
  this.log(session ? "lsp_session_heal" : "lsp_session_heal_failed", { language, carried: carry.length });
66
91
  }
92
+ // failed open → don't cache the miss (retry next request); guarded so a slow loser awaiting an old failed
93
+ // pending can't evict a NEWER in-flight session a concurrent call already cached.
67
94
  if (!session && sessions.get(language) === pending)
68
95
  sessions.delete(language);
69
96
  return session;
@@ -78,6 +105,12 @@ export class E2bLspManager {
78
105
  throw new Error("lsp: read failed");
79
106
  return r.value;
80
107
  };
108
+ // core 1.190+ `TransportLspSession` (byte-equivalent to the former local RemoteLspSession — service originally
109
+ // ported it there; core deduplicated it back, single-source). `undefined` warmup ⇒ core's default {windowMs:10_000,
110
+ // retryMs:1_000}, identical to the old 4-arg call (equivalence-verified). 6th arg (design/121): the
111
+ // workspace diagnostics registry — the session subscribes publishDiagnostics via transport.onNotification
112
+ // (version-staleness guarded core-side); absent onNotification would be a silent no-op, but WsLspTransport
113
+ // now dispatches.
81
114
  return new TransportLspSession(transport, language, readText, this.log, undefined, this.diagnostics);
82
115
  }
83
116
  }
@@ -1,2 +1,12 @@
1
+ /**
2
+ * LSP sidecar — service-side types (design/64 §13.1). core 1.82+ ships `createLspTool(manager)`
3
+ * + the `LspServerManager`/`LspSession`/`LspResult` SEAM (`@sema-agent/core`); the runner mounts the tool
4
+ * when OUR manager is wired via `RunnerDeps.lspManager`. We re-export core's seam types — SINGLE SOURCE OF TRUTH,
5
+ * incl. the injectable `LspTransport` (the WS-bridge connection to the language server inside E2B) + `LspReadText`.
6
+ * The protocol LOGIC + the `TransportLspSession` were originally ported FROM core; core later deduplicated them
7
+ * back (session.ts/op-map.ts deleted, byte-equivalence verified). The one thing that stays SERVICE-side is the WS
8
+ * `LspTransport` IMPLEMENTATION (`WsLspTransport` in ws-transport.ts) — core has no WebSocket transport (raw TCP
9
+ * doesn't traverse E2B's HTTP proxy; WS does). "1:1-copy-CC" is the protocol; the WS transport is ours.
10
+ */
1
11
  export type { LspOperation, LspRequestParams, LspResult, LspLocation, LspSymbolInfo, LspServerManager, LspSession, LspTransport, LspReadText, } from "@sema-agent/core";
2
12
  //# sourceMappingURL=types.d.ts.map
@@ -1,9 +1,12 @@
1
1
  import type { LspTransport } from "./types.js";
2
+ /** The slice of `ws`'s WebSocket the transport uses (so tests can supply a fake). */
2
3
  export interface WsLike {
3
4
  send(data: string): void;
4
5
  close(): void;
5
6
  on(event: "message" | "close" | "error" | "pong", listener: (arg?: unknown) => void): void;
7
+ /** WS ping frame (keepalive + liveness probe). Optional — fakes without it get no ping-liveness. */
6
8
  ping?(): void;
9
+ /** Hard-kill the socket (skip the close handshake) — used when a ping goes unanswered (half-open). */
7
10
  terminate?(): void;
8
11
  }
9
12
  export declare class WsLspTransport implements LspTransport {
@@ -14,15 +17,24 @@ export declare class WsLspTransport implements LspTransport {
14
17
  private isClosed;
15
18
  private keepalive;
16
19
  private awaitingPong;
20
+ /** design/121: server→client NOTIFICATION subscribers (publishDiagnostics etc.). */
17
21
  private readonly notificationHandlers;
18
22
  constructor(ws: WsLike, requestTimeoutMs?: number, keepaliveMs?: number);
23
+ /** Manager-visible liveness (LspTransport.closed): evict + reopen instead of reusing a dead connection. */
19
24
  get closed(): boolean;
20
25
  private onMessage;
21
26
  private failAll;
22
27
  request(method: string, params: unknown, signal?: AbortSignal): Promise<unknown>;
23
28
  notify(method: string, params: unknown): void;
29
+ /** design/121 (core 1.220): subscribe to server→client notifications; returns unsubscribe. Additive —
30
+ * core's diagnostics registry is the intended consumer; with no subscriber, behavior is byte-identical. */
24
31
  onNotification(handler: (method: string, params: unknown) => void): () => void;
25
32
  close(): Promise<void>;
26
33
  }
34
+ /**
35
+ * Connect to a language server's WS bridge inside E2B and run the LSP `initialize`/`initialized` handshake.
36
+ * Returns `undefined` on any failure (→ the manager degrades that language gracefully). `wsUrl` is the
37
+ * `wss://…e2b.dev` URL from `sandbox.getHost(port)`; `rootPath` is the in-sandbox workspace root.
38
+ */
27
39
  export declare function connectWsLspTransport(wsUrl: string, rootPath: string, signal?: AbortSignal): Promise<LspTransport | undefined>;
28
40
  //# sourceMappingURL=ws-transport.d.ts.map
@@ -1,5 +1,14 @@
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
+ */
1
8
  import WebSocket from "ws";
2
9
  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. */
3
12
  function toError(e) {
4
13
  if (e instanceof Error)
5
14
  return e;
@@ -14,6 +23,7 @@ export class WsLspTransport {
14
23
  isClosed = false;
15
24
  keepalive;
16
25
  awaitingPong = false;
26
+ /** design/121: server→client NOTIFICATION subscribers (publishDiagnostics etc.). */
17
27
  notificationHandlers = new Set();
18
28
  constructor(ws, requestTimeoutMs = 30_000, keepaliveMs = 20_000) {
19
29
  this.ws = ws;
@@ -21,17 +31,27 @@ export class WsLspTransport {
21
31
  ws.on("message", (data) => this.onMessage(typeof data === "string" ? data : String(data)));
22
32
  ws.on("close", () => this.failAll(new Error("LSP websocket closed")));
23
33
  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.
24
42
  if (keepaliveMs > 0) {
25
43
  ws.on("pong", () => {
26
44
  this.awaitingPong = false;
27
45
  });
28
46
  this.keepalive = setInterval(() => {
29
47
  if (this.awaitingPong) {
48
+ // previous ping unanswered for a full interval → half-open connection
30
49
  this.failAll(new Error("LSP websocket unresponsive (no pong)"));
31
50
  try {
32
51
  (ws.terminate ?? ws.close).call(ws);
33
52
  }
34
53
  catch {
54
+ /* already gone */
35
55
  }
36
56
  return;
37
57
  }
@@ -41,6 +61,7 @@ export class WsLspTransport {
41
61
  ws.ping();
42
62
  }
43
63
  catch {
64
+ /* socket gone — close/error handler does the bookkeeping */
44
65
  }
45
66
  }
46
67
  this.notify("$/keepalive", {});
@@ -48,6 +69,7 @@ export class WsLspTransport {
48
69
  this.keepalive.unref?.();
49
70
  }
50
71
  }
72
+ /** Manager-visible liveness (LspTransport.closed): evict + reopen instead of reusing a dead connection. */
51
73
  get closed() {
52
74
  return this.isClosed;
53
75
  }
@@ -57,28 +79,40 @@ export class WsLspTransport {
57
79
  msg = JSON.parse(raw);
58
80
  }
59
81
  catch {
60
- return;
82
+ return; // not JSON — ignore
61
83
  }
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.
62
90
  if (typeof msg.method === "string") {
63
91
  if (msg.id !== undefined && msg.id !== null) {
64
92
  try {
65
93
  this.ws.send(JSON.stringify({ jsonrpc: "2.0", id: msg.id, error: { code: -32601, message: "method not found" } }));
66
94
  }
67
95
  catch {
96
+ /* best-effort — a dead socket fails the pending requests elsewhere */
68
97
  }
69
- return;
98
+ return; // an answered server REQUEST — never our response, never a notification
70
99
  }
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.
71
103
  const params = msg.params;
72
104
  for (const h of this.notificationHandlers) {
73
105
  try {
74
106
  h(msg.method, params);
75
107
  }
76
108
  catch {
109
+ /* per-contract: never let a consumer kill the read loop */
77
110
  }
78
111
  }
79
112
  return;
80
113
  }
81
114
  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).
82
116
  const p = this.pending.get(msg.id);
83
117
  if (p) {
84
118
  this.pending.delete(msg.id);
@@ -104,7 +138,7 @@ export class WsLspTransport {
104
138
  return new Promise((resolve, reject) => {
105
139
  const timer = setTimeout(() => {
106
140
  if (this.pending.delete(id)) {
107
- signal?.removeEventListener("abort", onAbort);
141
+ signal?.removeEventListener("abort", onAbort); // or a long-lived task signal accumulates one listener per timeout
108
142
  reject(new Error(`LSP ${method} timed out after ${this.requestTimeoutMs}ms`));
109
143
  }
110
144
  }, this.requestTimeoutMs);
@@ -151,8 +185,11 @@ export class WsLspTransport {
151
185
  this.ws.send(JSON.stringify({ jsonrpc: "2.0", method, params }));
152
186
  }
153
187
  catch {
188
+ /* fire-and-forget */
154
189
  }
155
190
  }
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. */
156
193
  onNotification(handler) {
157
194
  this.notificationHandlers.add(handler);
158
195
  return () => this.notificationHandlers.delete(handler);
@@ -163,18 +200,28 @@ export class WsLspTransport {
163
200
  this.ws.close();
164
201
  }
165
202
  catch {
203
+ /* noop */
166
204
  }
167
205
  }
168
206
  }
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
+ */
169
212
  export async function connectWsLspTransport(wsUrl, rootPath, signal) {
170
213
  let socket;
171
214
  try {
172
215
  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.
173
220
  socket.on("error", () => { });
174
221
  await new Promise((resolve, reject) => {
175
222
  const onAbort = () => reject(new Error("connect aborted"));
176
223
  const settle = (fn) => {
177
- signal?.removeEventListener("abort", onAbort);
224
+ signal?.removeEventListener("abort", onAbort); // don't accumulate listeners on a long-lived task signal
178
225
  fn();
179
226
  };
180
227
  socket.once("open", () => settle(resolve));
@@ -185,9 +232,10 @@ export async function connectWsLspTransport(wsUrl, rootPath, signal) {
185
232
  }
186
233
  catch {
187
234
  try {
188
- socket?.close();
235
+ socket?.close(); // an aborted connect leaves the socket mid-handshake — don't leak it (it WOULD open)
189
236
  }
190
237
  catch {
238
+ /* never opened */
191
239
  }
192
240
  return undefined;
193
241
  }
@@ -1,2 +1,16 @@
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
+ */
1
15
  export declare function evictLspOnDestroy<E extends object>(env: E, lsp: unknown): E;
2
16
  //# sourceMappingURL=lsp-evict.d.ts.map
package/dist/lsp-evict.js CHANGED
@@ -1,3 +1,17 @@
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
+ */
1
15
  export function evictLspOnDestroy(env, lsp) {
2
16
  const evict = lsp?.evict;
3
17
  const e = env;
@@ -6,7 +20,7 @@ export function evictLspOnDestroy(env, lsp) {
6
20
  const origDestroy = e.destroy.bind(e);
7
21
  const root = e.cwd;
8
22
  e.destroy = () => {
9
- void evict.call(lsp, root).catch(() => { });
23
+ void evict.call(lsp, root).catch(() => { }); // fire-and-forget: never block/break teardown on a slow server close
10
24
  return origDestroy();
11
25
  };
12
26
  return env;