@tangle-network/agent-app 0.45.54 → 0.45.56

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 (492) hide show
  1. package/README.md +1 -1
  2. package/dist/alerting/index.d.ts +5 -175
  3. package/dist/alerting/slack.d.ts +176 -0
  4. package/dist/app-auth/index.d.ts +14 -17
  5. package/dist/assets/index.d.ts +2 -504
  6. package/dist/assets/schema.d.ts +264 -0
  7. package/dist/assets/types.d.ts +237 -0
  8. package/dist/assistant/AssistantDock.d.ts +56 -0
  9. package/dist/assistant/AssistantHistory.d.ts +41 -0
  10. package/dist/assistant/AssistantPanel.d.ts +84 -0
  11. package/dist/assistant/ProposalCard.d.ts +41 -0
  12. package/dist/assistant/ResizeHandle.d.ts +19 -0
  13. package/dist/assistant/client-context.d.ts +20 -0
  14. package/dist/assistant/client.d.ts +117 -0
  15. package/dist/assistant/index.d.ts +19 -848
  16. package/dist/assistant/index.js +3 -3
  17. package/dist/assistant/launcher.d.ts +23 -0
  18. package/dist/assistant/persistence.d.ts +26 -0
  19. package/dist/assistant/presentation.d.ts +99 -0
  20. package/dist/assistant/provider-label.d.ts +7 -0
  21. package/dist/assistant/reducer.d.ts +130 -0
  22. package/dist/assistant/sse.d.ts +24 -0
  23. package/dist/assistant/time-ago.d.ts +6 -0
  24. package/dist/assistant/transcript.d.ts +97 -0
  25. package/dist/assistant/types.d.ts +291 -0
  26. package/dist/assistant/use-stick-to-bottom.d.ts +28 -0
  27. package/dist/assistant/useAssistantChat.d.ts +63 -0
  28. package/dist/assistant/useAssistantModels.d.ts +22 -0
  29. package/dist/assistant/useAssistantThreads.d.ts +47 -0
  30. package/dist/assistant/usePanelPrefs.d.ts +55 -0
  31. package/dist/billing/index.d.ts +19 -21
  32. package/dist/brand/index.d.ts +16 -10
  33. package/dist/brand-extraction/extract.d.ts +34 -0
  34. package/dist/brand-extraction/index.d.ts +12 -214
  35. package/dist/brand-extraction/map.d.ts +58 -0
  36. package/dist/brand-extraction/types.d.ts +119 -0
  37. package/dist/catalog/index.d.ts +11 -101
  38. package/dist/chat-react/composer-mode-controls.d.ts +14 -0
  39. package/dist/chat-react/entry-composer.d.ts +92 -0
  40. package/dist/chat-react/index.d.ts +22 -118
  41. package/dist/chat-react/index.js +2 -2
  42. package/dist/chat-react/types.d.ts +11 -0
  43. package/dist/chat-routes/attachment-store.d.ts +84 -0
  44. package/dist/chat-routes/attachment-upload.d.ts +89 -0
  45. package/dist/chat-routes/attachment-validation.d.ts +95 -0
  46. package/dist/chat-routes/binary-sniff.d.ts +45 -0
  47. package/dist/chat-routes/completed-sandbox-turn.d.ts +25 -0
  48. package/dist/chat-routes/detached-turn.d.ts +197 -0
  49. package/dist/chat-routes/dispatch-parts.d.ts +101 -0
  50. package/dist/chat-routes/draft-persistence.d.ts +189 -0
  51. package/dist/chat-routes/durable-projection.d.ts +18 -0
  52. package/dist/chat-routes/file-index.d.ts +115 -0
  53. package/dist/chat-routes/index.d.ts +25 -1840
  54. package/dist/chat-routes/index.js +6 -2
  55. package/dist/chat-routes/index.js.map +1 -1
  56. package/dist/chat-routes/model-failover-stream.d.ts +206 -0
  57. package/dist/chat-routes/promote-file-part.d.ts +84 -0
  58. package/dist/chat-routes/resolve-attachments.d.ts +72 -0
  59. package/dist/chat-routes/sandbox-producer.d.ts +146 -0
  60. package/dist/chat-routes/sandbox-turn-usage.d.ts +4 -0
  61. package/dist/{stale-turn-lock-DucQzvXu.d.ts → chat-routes/stale-turn-lock.d.ts} +7 -9
  62. package/dist/chat-routes/turn-routes.d.ts +540 -0
  63. package/dist/chat-routes/upload.d.ts +84 -0
  64. package/dist/{wire-DOZ-O6hD.d.ts → chat-routes/wire.d.ts} +41 -44
  65. package/dist/chat-store/core.d.ts +19 -0
  66. package/dist/chat-store/index.d.ts +22 -322
  67. package/dist/{parts-BqIHMdyu.d.ts → chat-store/parts.d.ts} +49 -47
  68. package/dist/chat-store/schema.d.ts +157 -0
  69. package/dist/chat-store/store.d.ts +177 -0
  70. package/dist/{chunk-PVP57G3S.js → chunk-2IFGVBNI.js} +2 -2
  71. package/dist/{chunk-MQO5ML66.js → chunk-KJ2Q27U7.js} +2 -2
  72. package/dist/{chunk-CCVG2TL6.js → chunk-YNMPMW3G.js} +64 -2
  73. package/dist/chunk-YNMPMW3G.js.map +1 -0
  74. package/dist/config/index.d.ts +13 -18
  75. package/dist/crypto/index.d.ts +10 -12
  76. package/dist/crypto/web-token.d.ts +22 -0
  77. package/dist/design-canvas/apply.d.ts +70 -0
  78. package/dist/design-canvas/drizzle-store.d.ts +29 -0
  79. package/dist/design-canvas/drizzle.d.ts +7 -575
  80. package/dist/{export-presets-mgVulRaV.d.ts → design-canvas/export-presets.d.ts} +18 -22
  81. package/dist/design-canvas/index.d.ts +22 -268
  82. package/dist/design-canvas/mcp-entry.d.ts +15 -0
  83. package/dist/design-canvas/mcp-handler.d.ts +34 -0
  84. package/dist/design-canvas/mcp-tools.d.ts +30 -0
  85. package/dist/{model-DnfO_PdJ.d.ts → design-canvas/model.d.ts} +33 -35
  86. package/dist/{operations-ByJ6yXOW.d.ts → design-canvas/operations.d.ts} +21 -25
  87. package/dist/design-canvas/schema.d.ts +558 -0
  88. package/dist/{store-CqfDtnPQ.d.ts → design-canvas/store.d.ts} +8 -12
  89. package/dist/design-canvas/templates.d.ts +72 -0
  90. package/dist/design-canvas/validate.d.ts +32 -0
  91. package/dist/design-canvas-react/components/BleedTrimOverlay.d.ts +22 -0
  92. package/dist/design-canvas-react/components/BrandKnot.d.ts +11 -0
  93. package/dist/design-canvas-react/components/CanvasEmptyState.d.ts +32 -0
  94. package/dist/design-canvas-react/components/CanvasInsertPanel.d.ts +53 -0
  95. package/dist/{lazy-DrkVyDpe.d.ts → design-canvas-react/components/DesignCanvas.d.ts} +27 -20
  96. package/dist/design-canvas-react/components/DesignCanvasEditor.d.ts +23 -0
  97. package/dist/design-canvas-react/components/ElementNode.d.ts +51 -0
  98. package/dist/design-canvas-react/components/ExportControl.d.ts +21 -0
  99. package/dist/design-canvas-react/components/GridLayer.d.ts +47 -0
  100. package/dist/design-canvas-react/components/InlineTextEditor.d.ts +25 -0
  101. package/dist/design-canvas-react/components/LayersPanel.d.ts +20 -0
  102. package/dist/design-canvas-react/components/PagesStrip.d.ts +34 -0
  103. package/dist/design-canvas-react/components/Rulers.d.ts +31 -0
  104. package/dist/design-canvas-react/components/SelectionLayer.d.ts +51 -0
  105. package/dist/design-canvas-react/components/SnapGuidesOverlay.d.ts +25 -0
  106. package/dist/design-canvas-react/components/Toolbar.d.ts +64 -0
  107. package/dist/design-canvas-react/components/Workspace.d.ts +92 -0
  108. package/dist/design-canvas-react/components/ZoomControls.d.ts +14 -0
  109. package/dist/design-canvas-react/components/glyphs.d.ts +46 -0
  110. package/dist/design-canvas-react/components/icon-button.d.ts +22 -0
  111. package/dist/design-canvas-react/components/index.d.ts +27 -0
  112. package/dist/design-canvas-react/components/layer-tree.d.ts +34 -0
  113. package/dist/design-canvas-react/components/ruler-math.d.ts +78 -0
  114. package/dist/design-canvas-react/components/transform-math.d.ts +168 -0
  115. package/dist/{command-stack-TNPWJCzW.d.ts → design-canvas-react/contracts.d.ts} +16 -63
  116. package/dist/design-canvas-react/engine/command-stack.d.ts +43 -0
  117. package/dist/design-canvas-react/engine/commands.d.ts +154 -0
  118. package/dist/design-canvas-react/engine/selection.d.ts +48 -0
  119. package/dist/design-canvas-react/engine/snap.d.ts +24 -0
  120. package/dist/design-canvas-react/engine/zoom-pan.d.ts +18 -0
  121. package/dist/design-canvas-react/engine.d.ts +21 -399
  122. package/dist/design-canvas-react/export-math.d.ts +104 -0
  123. package/dist/design-canvas-react/export.d.ts +89 -0
  124. package/dist/design-canvas-react/index.d.ts +16 -586
  125. package/dist/design-canvas-react/insert-builders.d.ts +61 -0
  126. package/dist/design-canvas-react/lazy.d.ts +21 -6
  127. package/dist/documents/docx.d.ts +50 -0
  128. package/dist/documents/extract.d.ts +87 -0
  129. package/dist/documents/index.d.ts +26 -232
  130. package/dist/documents/media-type.d.ts +33 -0
  131. package/dist/documents/pdf-inspector.d.ts +5 -9
  132. package/dist/{types-DrBidf3O.d.ts → documents/types.d.ts} +13 -15
  133. package/dist/documents/zip.d.ts +56 -0
  134. package/dist/eval/calibration.d.ts +106 -0
  135. package/dist/eval/index.d.ts +8 -116
  136. package/dist/eval-campaign/index.d.ts +11 -12
  137. package/dist/{trust-gate-Dcm5xSva.d.ts → eval-campaign/trust-gate.d.ts} +5 -9
  138. package/dist/forms/blank.d.ts +48 -0
  139. package/dist/forms/fill.d.ts +105 -0
  140. package/dist/forms/index.d.ts +58 -332
  141. package/dist/forms/registry.d.ts +115 -0
  142. package/dist/forms/verify.d.ts +58 -0
  143. package/dist/harness/index.d.ts +21 -19
  144. package/dist/intakes/api.d.ts +5 -11
  145. package/dist/{completion-CvcNUz07.d.ts → intakes/completion.d.ts} +7 -11
  146. package/dist/intakes/context-sufficiency.d.ts +113 -0
  147. package/dist/intakes/drizzle/schema.d.ts +338 -0
  148. package/dist/intakes/drizzle/store.d.ts +75 -0
  149. package/dist/intakes/drizzle.d.ts +12 -391
  150. package/dist/intakes/index.d.ts +23 -113
  151. package/dist/{model-C8U0HZxL.d.ts → intakes/model.d.ts} +15 -17
  152. package/dist/intakes-react/components/BrandMark.d.ts +10 -0
  153. package/dist/intakes-react/components/IntakeInterview.d.ts +15 -0
  154. package/dist/intakes-react/components/index.d.ts +1 -0
  155. package/dist/intakes-react/contracts.d.ts +42 -0
  156. package/dist/intakes-react/index.d.ts +12 -47
  157. package/dist/intakes-react/lazy.d.ts +9 -8
  158. package/dist/integrations/index.d.ts +10 -12
  159. package/dist/{contract-OxG_jVMx.d.ts → interactions/contract.d.ts} +40 -42
  160. package/dist/interactions/index.d.ts +16 -256
  161. package/dist/interactions/route.d.ts +151 -0
  162. package/dist/interactions/sidecar.d.ts +100 -0
  163. package/dist/knowledge/index.d.ts +7 -11
  164. package/dist/knowledge-loop/index.d.ts +13 -20
  165. package/dist/legibility/checks/empty-state.d.ts +59 -0
  166. package/dist/legibility/checks/reachability.d.ts +103 -0
  167. package/dist/legibility/checks/silent-failure.d.ts +57 -0
  168. package/dist/legibility/checks/success.d.ts +38 -0
  169. package/dist/legibility/checks/vocabulary.d.ts +65 -0
  170. package/dist/legibility/cli-args.d.ts +30 -0
  171. package/dist/legibility/cli.d.ts +25 -0
  172. package/dist/legibility/index.d.ts +10 -530
  173. package/dist/legibility/report.d.ts +22 -0
  174. package/dist/legibility/scan.d.ts +29 -0
  175. package/dist/legibility/source.d.ts +132 -0
  176. package/dist/legibility/suppress.d.ts +36 -0
  177. package/dist/legibility/types.d.ts +168 -0
  178. package/dist/legibility/walk-sources.d.ts +21 -0
  179. package/dist/{agent-activity-C8ZG0F0M.d.ts → missions/agent-activity.d.ts} +3 -5
  180. package/dist/missions/engine.d.ts +251 -0
  181. package/dist/missions/events.d.ts +195 -0
  182. package/dist/missions/index.d.ts +12 -765
  183. package/dist/missions/plan-parse.d.ts +50 -0
  184. package/dist/missions/service.d.ts +265 -0
  185. package/dist/{failover-D-3UXXTb.d.ts → model-resolution/failover.d.ts} +10 -12
  186. package/dist/model-resolution/index.d.ts +15 -18
  187. package/dist/object-store/index.d.ts +15 -17
  188. package/dist/openui/action.d.ts +54 -0
  189. package/dist/openui/authoring.d.ts +25 -0
  190. package/dist/openui/index.d.ts +24 -206
  191. package/dist/openui/route.d.ts +124 -0
  192. package/dist/openui/segments.d.ts +71 -0
  193. package/dist/openui/values.d.ts +82 -0
  194. package/dist/openui-react/index.d.ts +9 -13
  195. package/dist/peer-floors/check.d.ts +9 -190
  196. package/dist/peer-floors/cli.d.ts +2 -3
  197. package/dist/peer-floors/dependency-source.d.ts +178 -0
  198. package/dist/plans/index.d.ts +13 -14
  199. package/dist/{billing-BuNlaKlE.d.ts → platform/billing.d.ts} +28 -32
  200. package/dist/platform/guards.d.ts +79 -0
  201. package/dist/platform/hub.d.ts +107 -0
  202. package/dist/platform/index.d.ts +7 -112
  203. package/dist/{sso-Cm00S61u.d.ts → platform/sso.d.ts} +15 -97
  204. package/dist/preflight/cli.d.ts +3 -6
  205. package/dist/preflight/index.d.ts +16 -18
  206. package/dist/preset-cloudflare/headers.d.ts +12 -0
  207. package/dist/preset-cloudflare/index.d.ts +22 -74
  208. package/dist/preset-cloudflare/workflow-instance.d.ts +35 -0
  209. package/dist/profile/budget.d.ts +72 -0
  210. package/dist/profile/fingerprint.d.ts +65 -0
  211. package/dist/profile/index.d.ts +27 -19
  212. package/dist/prompt/index.d.ts +3 -5
  213. package/dist/record/drizzle/schema.d.ts +488 -0
  214. package/dist/record/drizzle/store.d.ts +224 -0
  215. package/dist/record/drizzle.d.ts +10 -679
  216. package/dist/record/fold.d.ts +99 -0
  217. package/dist/record/index.d.ts +13 -13
  218. package/dist/{fold-DACU7gtf.d.ts → record/model.d.ts} +22 -124
  219. package/dist/record/ulid.d.ts +12 -0
  220. package/dist/redact/index.d.ts +14 -16
  221. package/dist/run/index.d.ts +11 -16
  222. package/dist/runtime/agent.d.ts +23 -0
  223. package/dist/runtime/certified-delivery.d.ts +57 -0
  224. package/dist/runtime/index.d.ts +17 -367
  225. package/dist/runtime/loop.d.ts +58 -0
  226. package/dist/runtime/model-catalog.d.ts +103 -0
  227. package/dist/{model-CdCDfBA9.d.ts → runtime/model.d.ts} +25 -27
  228. package/dist/runtime/openai-stream.d.ts +126 -0
  229. package/dist/runtime/surface-profile.d.ts +115 -0
  230. package/dist/sandbox/binary-read.d.ts +63 -0
  231. package/dist/sandbox/diagnostics.d.ts +69 -0
  232. package/dist/sandbox/index.d.ts +103 -1085
  233. package/dist/sandbox/model.d.ts +179 -0
  234. package/dist/sandbox/outcome.d.ts +10 -0
  235. package/dist/sandbox/prewarm-claim-d1.d.ts +80 -0
  236. package/dist/sandbox/prewarm.d.ts +193 -0
  237. package/dist/sandbox/recovery.d.ts +216 -0
  238. package/dist/sandbox/terminal-connection.d.ts +145 -0
  239. package/dist/sandbox/workspace-sandbox-manager.d.ts +44 -0
  240. package/dist/sequences/apply.d.ts +54 -0
  241. package/dist/sequences/captions.d.ts +91 -0
  242. package/dist/sequences/drizzle-store.d.ts +36 -0
  243. package/dist/sequences/drizzle.d.ts +7 -1252
  244. package/dist/sequences/exports.d.ts +138 -0
  245. package/dist/sequences/index.d.ts +19 -340
  246. package/dist/sequences/mcp-entry.d.ts +15 -0
  247. package/dist/sequences/mcp-handler.d.ts +39 -0
  248. package/dist/sequences/mcp-tools.d.ts +47 -0
  249. package/dist/{store-B7LLlk9p.d.ts → sequences/model.d.ts} +26 -110
  250. package/dist/sequences/operations.d.ts +126 -0
  251. package/dist/sequences/schema.d.ts +1231 -0
  252. package/dist/sequences/store.d.ts +81 -0
  253. package/dist/sequences/validate.d.ts +98 -0
  254. package/dist/sequences-react/components/BrandMark.d.ts +10 -0
  255. package/dist/sequences-react/components/PreviewCanvas.d.ts +26 -0
  256. package/dist/sequences-react/components/SnapIndicatorLine.d.ts +11 -0
  257. package/dist/sequences-react/components/TimelineClipChip.d.ts +80 -0
  258. package/dist/sequences-react/components/TimelineEditor.d.ts +44 -0
  259. package/dist/sequences-react/components/TimelineEmptyState.d.ts +21 -0
  260. package/dist/sequences-react/components/TimelineGhostLanes.d.ts +14 -0
  261. package/dist/sequences-react/components/TimelinePlayhead.d.ts +11 -0
  262. package/dist/sequences-react/components/TimelineRuler.d.ts +16 -0
  263. package/dist/sequences-react/components/TimelineSmallScreenGate.d.ts +12 -0
  264. package/dist/sequences-react/components/TimelineTrackRow.d.ts +51 -0
  265. package/dist/sequences-react/components/ZoomControl.d.ts +15 -0
  266. package/dist/sequences-react/components/composite-command.d.ts +8 -0
  267. package/dist/sequences-react/components/glyphs.d.ts +26 -0
  268. package/dist/sequences-react/components/index.d.ts +31 -0
  269. package/dist/sequences-react/components/interaction-math.d.ts +103 -0
  270. package/dist/sequences-react/contracts.d.ts +187 -0
  271. package/dist/sequences-react/engine/command-stack.d.ts +18 -0
  272. package/dist/sequences-react/engine/commands.d.ts +146 -0
  273. package/dist/sequences-react/engine/playback.d.ts +18 -0
  274. package/dist/sequences-react/engine/snap.d.ts +29 -0
  275. package/dist/sequences-react/engine/zoom.d.ts +29 -0
  276. package/dist/sequences-react/index.d.ts +20 -880
  277. package/dist/sequences-react/lazy.d.ts +8 -0
  278. package/dist/sequences-react/media/frame-provider.d.ts +70 -0
  279. package/dist/sequences-react/media/transcription.d.ts +33 -0
  280. package/dist/sequences-react/media/waveform.d.ts +34 -0
  281. package/dist/session-shell/index.d.ts +31 -204
  282. package/dist/session-shell/nav-guard.d.ts +170 -0
  283. package/dist/session-shell/path.d.ts +19 -0
  284. package/dist/signoff/cli.d.ts +4 -7
  285. package/dist/signoff/config.d.ts +12 -0
  286. package/dist/signoff/exec.d.ts +44 -0
  287. package/dist/signoff/index.d.ts +56 -14
  288. package/dist/signoff/invoked-as-script.d.ts +25 -0
  289. package/dist/signoff/node-version.d.ts +50 -0
  290. package/dist/signoff/proof-attach.d.ts +88 -0
  291. package/dist/signoff/proof-cli.d.ts +1 -0
  292. package/dist/signoff/proof-fixture.d.ts +13 -0
  293. package/dist/signoff/proof-from-report.d.ts +22 -0
  294. package/dist/signoff/proof-git.d.ts +57 -0
  295. package/dist/signoff/proof-record.d.ts +202 -0
  296. package/dist/signoff/proof-verify.d.ts +103 -0
  297. package/dist/signoff/proof.d.ts +35 -310
  298. package/dist/signoff/report.d.ts +7 -0
  299. package/dist/{run-D80hoLKh.d.ts → signoff/run.d.ts} +3 -6
  300. package/dist/signoff/schedule.d.ts +55 -0
  301. package/dist/signoff/seeds.d.ts +50 -0
  302. package/dist/signoff/store.d.ts +22 -0
  303. package/dist/{types-Bd6uW9vQ.d.ts → signoff/types.d.ts} +15 -17
  304. package/dist/signoff/workflow-pin.d.ts +56 -0
  305. package/dist/signoff/workspace.d.ts +40 -0
  306. package/dist/skills/index.d.ts +28 -32
  307. package/dist/skills-placement/index.d.ts +7 -11
  308. package/dist/spend/budget.d.ts +123 -0
  309. package/dist/spend/ceiling.d.ts +51 -0
  310. package/dist/spend/cli-args.d.ts +20 -0
  311. package/dist/spend/cli.d.ts +1 -0
  312. package/dist/spend/fixtures/incident-parked-time.d.ts +55 -0
  313. package/dist/spend/index.d.ts +38 -1144
  314. package/dist/spend/liveness.d.ts +131 -0
  315. package/dist/spend/ownership.d.ts +87 -0
  316. package/dist/spend/reconcile.d.ts +109 -0
  317. package/dist/spend/reference.d.ts +42 -0
  318. package/dist/spend/report.d.ts +12 -0
  319. package/dist/spend/store.d.ts +123 -0
  320. package/dist/spend/types.d.ts +466 -0
  321. package/dist/store/index.d.ts +10 -12
  322. package/dist/stories/app-shell/fixtures.d.ts +43 -0
  323. package/dist/stories/app-shell/shell.d.ts +81 -0
  324. package/dist/stories/assistant/fixtures.d.ts +73 -0
  325. package/dist/stories/chat/fixtures.d.ts +70 -0
  326. package/dist/stories/chat/markdown.d.ts +11 -0
  327. package/dist/stories/chat/run-drill-in.d.ts +19 -0
  328. package/dist/stories/chat-controls/fixtures.d.ts +116 -0
  329. package/dist/stories/design-canvas/fixtures.d.ts +57 -0
  330. package/dist/stories/fixtures/canvas.d.ts +10 -0
  331. package/dist/stories/fixtures/catalog.d.ts +7 -0
  332. package/dist/stories/fixtures/chat.d.ts +39 -0
  333. package/dist/stories/fixtures/index.d.ts +4 -0
  334. package/dist/stories/fixtures/sequences.d.ts +17 -0
  335. package/dist/stories/panels/fixtures.d.ts +63 -0
  336. package/dist/stories/sequences/fixtures.d.ts +30 -0
  337. package/dist/stories/studio/fixtures.d.ts +22 -0
  338. package/dist/stream/index.d.ts +10 -56
  339. package/dist/{stream-normalizer-DKRxyVlZ.d.ts → stream/stream-normalizer.d.ts} +23 -26
  340. package/dist/{turn-buffer-COMQUwO2.d.ts → stream/turn-buffer.d.ts} +21 -23
  341. package/dist/stream/turn-identity.d.ts +49 -0
  342. package/dist/studio/generation.d.ts +179 -0
  343. package/dist/studio/index.d.ts +12 -181
  344. package/dist/studio-react/avatar-composer.d.ts +8 -0
  345. package/dist/studio-react/composer-hero.d.ts +12 -0
  346. package/dist/studio-react/composer-shell.d.ts +18 -0
  347. package/dist/studio-react/generation-card.d.ts +9 -0
  348. package/dist/studio-react/generation-detail-modal.d.ts +11 -0
  349. package/dist/studio-react/generation-detail.d.ts +6 -0
  350. package/dist/studio-react/generation-grid.d.ts +15 -0
  351. package/dist/studio-react/image-composer.d.ts +8 -0
  352. package/dist/studio-react/index.d.ts +32 -245
  353. package/dist/studio-react/library-drawer.d.ts +12 -0
  354. package/dist/studio-react/library-panel.d.ts +15 -0
  355. package/dist/studio-react/publish-package-composer.d.ts +18 -0
  356. package/dist/studio-react/result-canvas.d.ts +6 -0
  357. package/dist/studio-react/speech-composer.d.ts +4 -0
  358. package/dist/studio-react/studio-header.d.ts +5 -0
  359. package/dist/studio-react/studio-sheet.d.ts +12 -0
  360. package/dist/studio-react/studio-workspace.d.ts +23 -0
  361. package/dist/studio-react/transcription-composer.d.ts +12 -0
  362. package/dist/studio-react/type-config.d.ts +11 -0
  363. package/dist/studio-react/use-studio-generations.d.ts +20 -0
  364. package/dist/studio-react/video-composer.d.ts +10 -0
  365. package/dist/tangle/index.d.ts +7 -9
  366. package/dist/teams/drizzle/access.d.ts +82 -0
  367. package/dist/{invitations-schema-_fI7HkJP.d.ts → teams/drizzle/invitations-schema.d.ts} +39 -27
  368. package/dist/teams/drizzle/personal-organization.d.ts +41 -0
  369. package/dist/{access-490O6aOU.d.ts → teams/drizzle/schema.d.ts} +57 -122
  370. package/dist/teams/drizzle.d.ts +12 -44
  371. package/dist/teams/index.d.ts +20 -44
  372. package/dist/teams/invitations-api.d.ts +17 -21
  373. package/dist/{invitations-DoYMvXea.d.ts → teams/invitations.d.ts} +14 -18
  374. package/dist/teams/invite.d.ts +42 -0
  375. package/dist/teams/members-api.d.ts +12 -16
  376. package/dist/teams/resend.d.ts +3 -13
  377. package/dist/{roles-B4nU3jDi.d.ts → teams/roles.d.ts} +18 -20
  378. package/dist/teams-react/components/BrandMark.d.ts +10 -0
  379. package/dist/teams-react/components/InvitationsPanel.d.ts +13 -0
  380. package/dist/teams-react/components/InviteAcceptPage.d.ts +10 -0
  381. package/dist/teams-react/components/MembersPanel.d.ts +14 -0
  382. package/dist/teams-react/components/RoleSelect.d.ts +17 -0
  383. package/dist/teams-react/components/index.d.ts +3 -0
  384. package/dist/teams-react/contracts.d.ts +134 -0
  385. package/dist/teams-react/index.d.ts +12 -143
  386. package/dist/teams-react/lazy.d.ts +11 -11
  387. package/dist/test-setup.d.ts +1 -0
  388. package/dist/theme/index.d.ts +6 -104
  389. package/dist/theme/tailwind-preset.d.ts +1 -2
  390. package/dist/theme/theme.d.ts +106 -0
  391. package/dist/theme-contract/cli.d.ts +21 -0
  392. package/dist/theme-contract/index.d.ts +4 -6
  393. package/dist/{auth-BYtiazA4.d.ts → tools/auth.d.ts} +8 -11
  394. package/dist/tools/capability.d.ts +54 -0
  395. package/dist/tools/dispatch.d.ts +37 -0
  396. package/dist/tools/errors.d.ts +8 -0
  397. package/dist/tools/gating.d.ts +62 -0
  398. package/dist/tools/http.d.ts +27 -0
  399. package/dist/tools/index.d.ts +12 -217
  400. package/dist/{mcp-rpc-DYwPlYbZ.d.ts → tools/mcp-rpc.d.ts} +7 -9
  401. package/dist/{mcp-xxoZZfor.d.ts → tools/mcp.d.ts} +14 -16
  402. package/dist/tools/openai.d.ts +28 -0
  403. package/dist/tools/registry.d.ts +39 -0
  404. package/dist/tools/runtime.d.ts +22 -0
  405. package/dist/{types-B25Mib1r.d.ts → tools/types.d.ts} +15 -83
  406. package/dist/{flow-types-CJxEmaRy.d.ts → trace/flow-types.d.ts} +2 -4
  407. package/dist/trace/index.d.ts +11 -148
  408. package/dist/trace/mission-flow.d.ts +82 -0
  409. package/dist/trace/mission-trace.d.ts +52 -0
  410. package/dist/turn-health/classify.d.ts +207 -0
  411. package/dist/turn-health/index.d.ts +29 -637
  412. package/dist/turn-health/lifecycle.d.ts +75 -0
  413. package/dist/turn-health/sink.d.ts +122 -0
  414. package/dist/turn-health/sweep.d.ts +245 -0
  415. package/dist/turn-stream/adapters.d.ts +257 -0
  416. package/dist/turn-stream/core.d.ts +293 -0
  417. package/dist/turn-stream/do.d.ts +144 -0
  418. package/dist/turn-stream/index.d.ts +62 -738
  419. package/dist/turn-stream/memory.d.ts +41 -0
  420. package/dist/vault/ConfirmDialog.d.ts +22 -0
  421. package/dist/vault/VaultPane.d.ts +15 -0
  422. package/dist/{VaultPane-BDP6SB_K.d.ts → vault/contracts.d.ts} +15 -22
  423. package/dist/vault/index.d.ts +15 -22
  424. package/dist/vault/lazy.d.ts +9 -7
  425. package/dist/vault/server.d.ts +8 -10
  426. package/dist/web/free-route-limit.d.ts +187 -0
  427. package/dist/web/index.d.ts +15 -207
  428. package/dist/{rate-limit-BOVmJRXZ.d.ts → web/rate-limit.d.ts} +3 -5
  429. package/dist/web-react/agent-session-controls.d.ts +105 -0
  430. package/dist/web-react/async/async-view.d.ts +69 -0
  431. package/dist/web-react/async/index.d.ts +13 -305
  432. package/dist/web-react/async/state.d.ts +107 -0
  433. package/dist/web-react/async/use-async-resource.d.ts +41 -0
  434. package/dist/web-react/async/use-confirmed-mutation.d.ts +90 -0
  435. package/dist/web-react/brand-mark.d.ts +11 -0
  436. package/dist/web-react/chat-attachments.d.ts +21 -0
  437. package/dist/web-react/chat-composer.d.ts +174 -0
  438. package/dist/web-react/chat-interactions.d.ts +1 -0
  439. package/dist/web-react/chat-mentions.d.ts +48 -0
  440. package/dist/web-react/chat-stream.d.ts +106 -0
  441. package/dist/web-react/class-names.d.ts +10 -0
  442. package/dist/web-react/controls.d.ts +265 -0
  443. package/dist/web-react/durable-chat-cards.d.ts +40 -0
  444. package/dist/web-react/durable-interaction-submit.d.ts +22 -0
  445. package/dist/web-react/durable-plan-card.d.ts +13 -0
  446. package/dist/web-react/durable-plan-flow.d.ts +77 -0
  447. package/dist/web-react/harness-glyphs.d.ts +28 -0
  448. package/dist/web-react/index.d.ts +80 -2347
  449. package/dist/web-react/index.js +3 -3
  450. package/dist/web-react/inert.d.ts +39 -0
  451. package/dist/web-react/insight-card.d.ts +203 -0
  452. package/dist/web-react/interaction-card-support.d.ts +115 -0
  453. package/dist/web-react/interaction-plan-card.d.ts +39 -0
  454. package/dist/web-react/interaction-question-card.d.ts +100 -0
  455. package/dist/web-react/message-attachments.d.ts +56 -0
  456. package/dist/web-react/mission-activity.d.ts +96 -0
  457. package/dist/web-react/motion.d.ts +43 -0
  458. package/dist/web-react/provenance-model.d.ts +195 -0
  459. package/dist/web-react/provenance.d.ts +82 -0
  460. package/dist/web-react/provider-logo.d.ts +14 -0
  461. package/dist/web-react/record-grid-model.d.ts +257 -0
  462. package/dist/web-react/record-grid.d.ts +108 -0
  463. package/dist/web-react/sandbox-terminal.d.ts +90 -0
  464. package/dist/web-react/seat-paywall.d.ts +47 -0
  465. package/dist/web-react/session-history.d.ts +196 -0
  466. package/dist/web-react/smooth-text.d.ts +29 -0
  467. package/dist/web-react/sparkline.d.ts +150 -0
  468. package/dist/web-react/terminal.d.ts +1 -92
  469. package/dist/web-react/use-chat-interactions.d.ts +78 -0
  470. package/dist/web-react/use-composer-attachments.d.ts +111 -0
  471. package/dist/web-react/use-file-mentions.d.ts +94 -0
  472. package/dist/web-react/work-product.d.ts +105 -0
  473. package/dist/work-product/claim-support.d.ts +288 -0
  474. package/dist/work-product/index.d.ts +16 -849
  475. package/dist/work-product/provenance.d.ts +61 -0
  476. package/dist/{queue-VTBA5ONX.d.ts → work-product/queue.d.ts} +10 -12
  477. package/dist/work-product/quote.d.ts +139 -0
  478. package/dist/work-product/route.d.ts +88 -0
  479. package/dist/work-product/service.d.ts +123 -0
  480. package/dist/work-product/tools.d.ts +144 -0
  481. package/dist/{types-CCeYywdS.d.ts → work-product/types.d.ts} +29 -31
  482. package/dist/work-product-react/index.d.ts +19 -8
  483. package/dist/workspace-react/index.d.ts +8 -11
  484. package/package.json +4 -3
  485. package/dist/agent-session-controls-CmlXwp_H.d.ts +0 -384
  486. package/dist/apply-6wlMOLf8.d.ts +0 -280
  487. package/dist/attachment-validation-BfJDBU1g.d.ts +0 -261
  488. package/dist/budget-BOucfcb_.d.ts +0 -142
  489. package/dist/chunk-CCVG2TL6.js.map +0 -1
  490. package/dist/values-C7RidJuI.d.ts +0 -156
  491. /package/dist/{chunk-PVP57G3S.js.map → chunk-2IFGVBNI.js.map} +0 -0
  492. /package/dist/{chunk-MQO5ML66.js.map → chunk-KJ2Q27U7.js.map} +0 -0
@@ -1,740 +1,64 @@
1
- import { R as ReconcileStaleTurnLockOptions } from '../stale-turn-lock-DucQzvXu.js';
2
- import { T as TurnEventStore } from '../turn-buffer-COMQUwO2.js';
3
-
4
1
  /**
5
- * `/turn-stream` core the pure, substrate-free half of the shared durable
6
- * turn replay/broadcast/lock channel (issue #221).
7
- *
8
- * Extracted from the reference consumer's hand-rolled Durable Object
9
- * (gtm-agent `SessionStreamDO` + `session-broadcast.ts`): the per-turn
10
- * segment store that backs reconnect replay over a live socket, the
11
- * single-flight chat-turn lock record and its release fences, and the wire
12
- * contract (channel keys, endpoint paths, request/response bodies) shared by
13
- * the DO transport shell (`./do`) and the worker-side adapters
14
- * (`./adapters`). Everything here is plain data + functions no
15
- * `cloudflare:workers`, no storage, no sockets — so the semantics are
16
- * unit-testable in Node and the DO stays a thin shell.
17
- *
18
- * ── The two-lane rule (measured, not assumed) ────────────────────────────
19
- *
20
- * A 4-arm A/B on production (sandbox.tangle.tools, SDK 0.12.0, one box, one
21
- * gateway client per arm) established which sandbox lane a browser can see:
22
- *
23
- * | turn driver | raw turn events | seen at gateway |
24
- * | ------------------------------------ | --------------- | --------------- |
25
- * | `box.streamPrompt()` (run/stream) | 71 / 527 / 408 | 0 / 0 / 0 |
26
- * | `box.session(id).sendMessage()` | 297 | 297 |
27
- *
28
- * `POST /agents/run/stream` publishes nothing to the sidecar session event
29
- * bus, so a `SessionGatewayClient` attached to that session receives zero
30
- * turn events — three different session-id strategies all got 0, the id was
31
- * not the variable. `POST /agents/sessions/{id}/messages` publishes to the
32
- * bus and the gateway delivered every frame, byte-matching the sidecar tail.
33
- *
34
- * Consequences for this module, and they cut both ways:
35
- *
36
- * 1. INTERACTIVE sandbox turns should be driven on the message lane and
37
- * tailed by the browser through `box.mintScopedToken({ scope: 'session' })`
38
- * + `SessionGatewayClient`. Re-broadcasting those same events through the
39
- * per-turn SEGMENT buffer below duplicates the SDK and adds a worker hop.
40
- * That half is `@deprecated` (see the tags on {@link createSegmentStore},
41
- * {@link appendSegmentEvent}, {@link replayActiveSegment} and
42
- * `broadcastTurnStreamEvent` in `./adapters`).
43
- * 2. DETACHED/autonomous turns are INVISIBLE to the gateway:
44
- * `dispatchPrompt({ detach: true })` and `driveTurn` both go through
45
- * `streamPrompt` internally, i.e. the run/stream lane, which does not fan
46
- * out. A browser that must tail an unattended run still needs a buffer —
47
- * `runDetachedTurn` (`/chat-routes`) over the durable turn-event rows
48
- * below. That half is NOT deprecated and has no SDK replacement today.
49
- * 3. The LOCK and the per-workspace SIGNALS have no gateway equivalent at
50
- * all (the gateway is per-session and read-only). They stay canonical.
51
- *
52
- * Server-side resume of a run/stream turn is also already solved by the SDK
53
- * and needs nothing here: `box.streamPrompt('', { executionId, lastEventId })`
54
- * replays strictly after the cursor without re-dispatching — measured across
55
- * a SIGKILL mid-run and a fresh process resuming from the cursor alone:
56
- * 0 lost, 0 duplicated, 0 out-of-order, ids 1..517 contiguous.
57
- */
58
- /** One event on a turn-stream channel. `seq` is monotonic within a turn
59
- * segment and assigned by {@link appendSegmentEvent} on arrival at the DO. */
60
- interface TurnStreamEvent {
61
- type: string;
62
- data?: unknown;
63
- timestamp: number;
64
- seq?: number;
65
- }
66
- /** Terminal run markers: they close a turn segment and auto-release the
67
- * channel's chat-turn lock for the segment's execution.
68
- *
69
- * KEPT (not deprecated with the segment buffer): the lock auto-release
70
- * reads it. A product that stops broadcasting turn events to the thread
71
- * channel loses only that auto-release — the cooperative release on settle
72
- * (`createDurableTurnLock().release`) and `reconcileStaleDurableTurnLock`
73
- * both still fire, which is what actually frees a wedged lane. */
74
- declare function isTerminalRunEvent(type: string): boolean;
75
- /** Define the scope level for acquiring a turn lock within thread or workspace contexts */
76
- type TurnLockScope = 'thread' | 'workspace';
77
- /** Generate a unique string key combining workspace and thread identifiers.
78
- *
79
- * KEPT: thread-scope LOCKS are keyed on it (see {@link turnLockChannelKey}).
80
- * Only its second use — addressing a live-viewer socket for interactive
81
- * sandbox-turn rebroadcast — is superseded by the session gateway. */
82
- declare function threadChannelKey(workspaceId: string, threadId: string): string;
83
- /** Generate a unique channel key based on the given workspace identifier.
84
- *
85
- * KEPT and canonical: the per-workspace signal channel (`thread.created`,
86
- * `thread.activity`) plus workspace-scope locks. The session gateway is
87
- * per-SESSION and read-only, so it cannot carry either. */
88
- declare function workspaceChannelKey(workspaceId: string): string;
89
- /** The channel a lock lives on: workspace-scope locks serialize every thread
90
- * in the workspace (one shared sandbox), thread-scope locks serialize one
91
- * thread (router lane). Same keying as the reference consumer, so a product
92
- * swapping its fork for this package contends on identical instances. */
93
- declare function turnLockChannelKey(workspaceId: string, threadId: string, scope: TurnLockScope): string;
94
- /** Generate a storage channel key string for a given turn identifier.
95
- *
96
- * KEPT and canonical: the DETACHED lane's durable turn-event rows live on
97
- * this instance. A detached run never reaches the session gateway, so this
98
- * is the only way a browser tails one. */
99
- declare function turnStorageChannelKey(turnId: string): string;
100
- /** Generate a unique channel key string based on the provided scope identifier.
101
- *
102
- * KEPT and canonical: backs `TurnEventStore.listRunning`, which is how a
103
- * reloaded client rediscovers an in-flight DETACHED turn. */
104
- declare function scopeIndexChannelKey(scopeId: string): string;
105
- /** DEPRECATED (interactive turn-rebroadcast buffer) — represent a segment of a turn containing events, sequence limit, and terminal status.
106
- *
107
- * @deprecated Part of the interactive turn-rebroadcast buffer — see the
108
- * two-lane rule in this file's header. Removal is a major-version change. */
109
- interface TurnSegment {
110
- events: TurnStreamEvent[];
111
- maxSeq: number;
112
- terminal: boolean;
113
- }
114
- /** DEPRECATED (interactive turn-rebroadcast buffer) — define a store managing segments and tracking the active execution identifier.
115
- *
116
- * @deprecated Part of the interactive turn-rebroadcast buffer — see the
117
- * two-lane rule in this file's header. Removal is a major-version change. */
118
- interface SegmentStore {
119
- segments: Map<string, TurnSegment>;
120
- activeExecutionId: string | null;
121
- }
122
- /** DEPRECATED (interactive turn-rebroadcast buffer) — per-turn replay window. Generous enough for normal turns; a turn that
123
- * exceeds it loses its earliest deltas from replay (a late resumer
124
- * self-heals via the final `result` event + loader revalidation).
125
- *
126
- * @deprecated Sizes the interactive turn-rebroadcast buffer only. The
127
- * DETACHED lane's durable rows (`turnEvent:` storage) are uncapped and are
128
- * not affected. */
129
- declare const MAX_SEGMENT_EVENTS = 2000;
130
- /** Recent `thread.created` markers kept for late-connecting sidebars.
131
- *
132
- * KEPT: a workspace-level signal, not a turn rebroadcast. */
133
- declare const MAX_RECENT_CREATED = 50;
134
- /** A responding marker older than this is treated as stale, so a dropped
135
- * `end` broadcast can't leave a permanently-stuck "responding" dot. */
136
- declare const ACTIVITY_TTL_MS: number;
137
- /** DEPRECATED (interactive sandbox-turn rebroadcast; the SDK's session gateway replaces it) — create a SegmentStore with initialized segments and no active execution ID.
138
- *
139
- * @deprecated Backs the interactive sandbox-turn rebroadcast, which the
140
- * sandbox SDK already does better (measured: run/stream → 0 frames at the
141
- * gateway, message lane → 297/297; see the two-lane rule in this file's
142
- * header). Sandbox turns: drive on `box.session(id).sendMessage()` and let
143
- * the browser attach with `box.mintScopedToken({ scope: 'session' })` +
144
- * `SessionGatewayClient`. Sandbox-FREE turns: `/stream`'s
145
- * `replayTurnEvents` (`GET /chat/stream/:turnId`) already follows a running
146
- * turn from a cursor. Detached turns keep the durable turn-event rows —
147
- * they are a different, non-deprecated lane. Removal is a major-version
148
- * change; nothing is deleted here. */
149
- declare function createSegmentStore(): SegmentStore;
150
- /**
151
- * DEPRECATED (interactive turn-rebroadcast buffer) — append a per-turn event to
152
- * its execution's segment, assigning a monotonic
153
- * `seq`. A `session.run.started` (or the first-seen event for an execution)
154
- * opens a fresh segment, makes it active, and drops prior turns' buffers so a
155
- * resumer only ever replays the current turn. A terminal run event marks the
156
- * segment terminal. Returns the seq-stamped event to broadcast.
157
- *
158
- * @deprecated The interactive rebroadcast half — {@link createSegmentStore}
159
- * names the replacement per lane; this file's header holds the measurement.
160
- */
161
- declare function appendSegmentEvent(store: SegmentStore, executionId: string, incoming: TurnStreamEvent, maxEvents?: number): TurnStreamEvent;
162
- /**
163
- * DEPRECATED (interactive turn-rebroadcast buffer; the SDK replays losslessly on
164
- * both lanes) — events of the active, non-terminal turn with `seq > afterSeq`,
165
- * i.e. what a
166
- * (re)connecting client replays before going live. A terminal (finished) turn
167
- * replays nothing: the client falls back to the loader's persisted row.
168
- *
169
- * @deprecated The interactive rebroadcast half — {@link createSegmentStore}
170
- * names the replacement per lane. The SDK's own reconnect replay is
171
- * `SessionGatewayClient` + `lastEventId` (browser) or
172
- * `box.streamPrompt('', { executionId, lastEventId })` (worker); both were
173
- * measured lossless.
174
- */
175
- declare function replayActiveSegment(store: SegmentStore, afterSeq: number): TurnStreamEvent[];
176
- /**
177
- * Remove responding entries (threadId → startedAt) older than `ttlMs`, so a
178
- * dropped `end` broadcast can't leave a permanently-stuck dot. Mutates
179
- * `active` and returns the removed thread ids.
180
- */
181
- declare function pruneStaleThreads(active: Map<string, number>, now: number, ttlMs: number): string[];
182
- /** Default lifetime of an unreleased lock. Long enough that a legitimately
183
- * slow sandbox turn never loses its guard mid-run; the way OUT of a wedge is
184
- * never the TTL but `reconcileStaleTurnLock` (in `/chat-routes`), which
185
- * probes the execution's actual state.
186
- *
187
- * Everything from here down is the LOCK, and it is fully KEPT. The sandbox
188
- * SDK ships no single-flight primitive — the session gateway is a read-only
189
- * fanout — so moving a product to the message lane changes nothing about
190
- * who is allowed to start a turn. */
191
- declare const TURN_LOCK_TTL_MS: number;
192
- /** The stored single-flight lock. Field-compatible with the reference
193
- * consumer's `ChatTurnLock` so adoption is a swap, not a migration. */
194
- interface DurableTurnLock {
195
- workspaceId: string;
196
- threadId: string;
197
- scope: TurnLockScope;
198
- executionId: string;
199
- lockId: string;
200
- startedAt: number;
201
- expiresAt: number;
202
- turnId?: string;
203
- /** The turn released this lock, but a product-owned post-turn task (e.g.
204
- * file persistence reading the box) is still running, so the release is
205
- * parked on the lock until the task settles. Written only through the DO's
206
- * defer seam — the base package never sets it on its own. */
207
- releasePending?: boolean;
208
- }
209
- /** Define input parameters required to acquire a turn-based lock in a workspace thread */
210
- interface TurnLockAcquireInput {
211
- workspaceId: string;
212
- threadId: string;
213
- scope: TurnLockScope;
214
- executionId: string;
215
- lockId: string;
216
- turnId?: string;
217
- }
218
- /** Resolve the result of attempting to acquire a turn lock indicating success or active lock status */
219
- type TurnLockAcquireResult = {
220
- acquired: true;
221
- lock: DurableTurnLock;
222
- } | {
223
- acquired: false;
224
- active: DurableTurnLock;
225
- };
226
- /** Define input parameters required to release a turn lock in a specific workspace thread */
227
- interface TurnLockReleaseInput {
228
- workspaceId: string;
229
- threadId: string;
230
- scope: TurnLockScope;
231
- executionId: string;
232
- lockId: string;
233
- }
234
- /** Fenced out-of-band release (stop button, stale-lock reconciliation). The
235
- * fences make it refuse a SUCCESSOR lock: `interruptedAt` must not precede
236
- * the lock's own start, and when either side names a turn, both must name
237
- * the same one. */
238
- interface TurnLockInterruptedReleaseInput {
239
- workspaceId: string;
240
- threadId: string;
241
- /** Try only this scope; omit to try workspace then thread. */
242
- scope?: TurnLockScope;
243
- interruptedAt: number;
244
- turnId?: string;
245
- }
246
- /** `stored` is what the DO read from storage; expired locks are dead. */
247
- declare function activeTurnLock(stored: DurableTurnLock | undefined, now: number): DurableTurnLock | null;
248
- /** Create a durable turn lock object with timing and scope based on input parameters */
249
- declare function createTurnLock(input: TurnLockAcquireInput, now: number, ttlMs?: number): DurableTurnLock;
250
- /** A cooperative release must present the lock's own identity — both the
251
- * execution and the lockId minted at acquire — so a retry of a PREVIOUS turn
252
- * can never release the current one. `lockId` is optional only for the DO's
253
- * internal terminal-event auto-release, which knows the execution but not
254
- * the caller-held lockId. */
255
- declare function turnLockMatchesRelease(active: DurableTurnLock, input: {
256
- executionId: string;
257
- lockId?: string;
258
- }): boolean;
259
- /**
260
- * The interrupted/stale release fence. `interruptedAt` is the instant the
261
- * releasing evidence was observed (the stop click, the stale-lock probe) —
262
- * a lock STARTED after that instant is a successor the evidence says nothing
263
- * about, so it survives. When the lock recorded a client turnId, the release
264
- * must name the same turn; a lock without one refuses a turn-specific
265
- * release (it cannot prove it is that turn).
266
- */
267
- declare function interruptedReleaseApplies(active: DurableTurnLock, input: {
268
- threadId: string;
269
- interruptedAt: number;
270
- turnId?: string;
271
- }): boolean;
272
- /** Provide constant paths for managing chat turn streams and locks */
273
- declare const TURN_STREAM_PATHS: {
274
- readonly broadcast: "/broadcast";
275
- readonly lockAcquire: "/chat-turn-lock/acquire";
276
- readonly lockRelease: "/chat-turn-lock/release";
277
- readonly lockReleaseInterrupted: "/chat-turn-lock/release-interrupted";
278
- readonly turnEventsAppend: "/turn-events/append";
279
- readonly turnEventsRead: "/turn-events/read";
280
- readonly turnStatusSet: "/turn-status/set";
281
- readonly turnStatusGet: "/turn-status/get";
282
- readonly scopeStatusSet: "/turn-scope/set";
283
- readonly scopeRunningList: "/turn-scope/running";
284
- };
285
- /** Storage keys inside a DO instance. Exported for subclass coexistence —
286
- * a product extending the DO must not collide with these. */
287
- declare const TURN_STREAM_STORAGE_KEYS: {
288
- readonly lock: "chatTurnLock";
289
- readonly activeThreads: "activeThreads";
290
- readonly turnStatus: "turnStatus";
291
- readonly turnScope: "turnScopeIndex";
292
- readonly turnEventPrefix: "turnEvent:";
293
- };
294
- /** Zero-padded seq so DO storage `list({ prefix })` returns rows in replay
295
- * order without a sort. 10 digits holds any realistic turn. */
296
- declare function turnEventStorageKey(seq: number): string;
297
-
298
- /**
299
- * `TurnStreamDO` — the shared Durable Object transport shell over the pure
300
- * core (`./core`). One class serves every channel family; the instance NAME
301
- * decides which endpoints a given instance ever sees:
302
- *
303
- * - **thread channel** (`${workspaceId}:${threadId}`) — the thread-scope lock
304
- * (KEPT), plus the live turn rebroadcast: WebSocket fanout and per-turn
305
- * segments with `sync`/`afterSeq` reconnect replay. That rebroadcast is
306
- * `@deprecated` for sandbox-backed interactive turns — the sandbox session
307
- * gateway already does it, browser-direct, when the turn is driven on the
308
- * message lane (`./core`'s header has the production measurement).
309
- * - **workspace channel** (`${workspaceId}`) — coarse sidebar signals
310
- * (`thread.activity` responding set, durable across eviction;
311
- * `thread.created` recent list) and the workspace-scope lock. KEPT: the
312
- * gateway is per-session and read-only, so it carries neither.
313
- * - **turn storage** (`turn:${turnId}`) — the durable `TurnEventStore` rows +
314
- * status for one buffered turn (replay survives DO eviction — this is what
315
- * graduates the vertical's `turnStore` from no-op). KEPT and load-bearing:
316
- * a DETACHED run never reaches the gateway, so this is the only way a
317
- * browser tails autonomous work.
318
- * - **scope index** (`scope:${scopeId}`) — the running-turn index backing
319
- * `TurnEventStore.listRunning` reconnect discovery. KEPT.
320
- *
321
- * The class is a PLAIN class over a structural {@link TurnStreamDOState} —
322
- * no `cloudflare:workers` import, so this package stays substrate-free and
323
- * the DO is unit-testable in Node. Cloudflare's `DurableObjectState`
324
- * satisfies the interface; a product binds it in wrangler by re-exporting:
325
- *
326
- * // worker entry
327
- * export { TurnStreamDO } from '@tangle-network/agent-app/turn-stream'
328
- *
329
- * Fan-out enumerates `state.getWebSockets()` (never an in-memory socket map)
330
- * and reads per-socket metadata from the serialized attachment, so it is
331
- * correct across WebSocket hibernation.
332
- *
333
- * Product extension (how the reference consumer keeps its Vault machinery
334
- * while deleting its fork): subclass and override
335
- * {@link TurnStreamDO.handleProductRequest} (extra POST endpoints),
336
- * {@link TurnStreamDO.shouldDeferLockRelease} /
337
- * {@link TurnStreamDO.completeDeferredLockRelease} (park a lock release
338
- * behind a product-owned post-turn task), and
339
- * {@link TurnStreamDO.productSyncEvents} (extra state replayed to a
340
- * late-connecting socket). Product storage keys must avoid
341
- * {@link TURN_STREAM_STORAGE_KEYS}.
342
- */
343
-
344
- /** The socket surface the DO touches. Cloudflare's hibernatable `WebSocket`
345
- * satisfies it. */
346
- interface TurnStreamSocket {
347
- send(data: string): void;
348
- close(code?: number, reason?: string): void;
349
- serializeAttachment(value: unknown): void;
350
- deserializeAttachment(): unknown;
351
- }
352
- /** The storage surface the DO touches (Cloudflare `DurableObjectStorage`
353
- * satisfies it structurally). `list` must return keys in ascending order —
354
- * the turn-event rows rely on it for replay order. */
355
- interface TurnStreamStorage {
356
- get<T = unknown>(key: string): Promise<T | undefined>;
357
- put<T = unknown>(key: string, value: T): Promise<void>;
358
- delete(key: string): Promise<boolean | void>;
359
- list<T = unknown>(options: {
360
- prefix: string;
361
- start?: string;
362
- }): Promise<Map<string, T>>;
363
- }
364
- /** The `DurableObjectState` surface the DO uses. */
365
- interface TurnStreamDOState {
366
- storage: TurnStreamStorage;
367
- acceptWebSocket(ws: TurnStreamSocket): void;
368
- getWebSockets(): TurnStreamSocket[];
369
- }
370
- /** Define options to override default TTL and event limits for TURN stream DO operations */
371
- interface TurnStreamDOOptions {
372
- /** Override {@link TURN_LOCK_TTL_MS}. */
373
- lockTtlMs?: number;
374
- /** Override {@link MAX_SEGMENT_EVENTS}. */
375
- maxSegmentEvents?: number;
376
- /** Override {@link ACTIVITY_TTL_MS}. */
377
- activityTtlMs?: number;
378
- /** How long an unrenewed running turn remains discoverable. */
379
- runningTurnLeaseMs?: number;
380
- }
381
- /** Manage per-turn segments and track active threads with durable event storage */
382
- declare class TurnStreamDO {
383
- protected readonly state: TurnStreamDOState;
384
- protected readonly env: unknown;
385
- protected readonly options: TurnStreamDOOptions;
386
- private segments;
387
- private recentCreated;
388
- private activeThreads;
389
- constructor(state: TurnStreamDOState, env?: unknown, options?: TurnStreamDOOptions);
390
- fetch(request: Request): Promise<Response>;
391
- /** Called for any request no base endpoint claimed (before the 404), so a
392
- * subclass adds product endpoints without touching base routing. Return
393
- * `null` to decline. */
394
- protected handleProductRequest(_request: Request, _url: URL): Promise<Response | null>;
395
- /** Consulted before any lock release (cooperative, interrupted, or the
396
- * terminal-event auto-release). Return `true` while a product-owned
397
- * post-turn task for `executionId` must keep the scope serialized (e.g.
398
- * file persistence still reading the box) — the release is then parked as
399
- * `releasePending` on the lock and completed via
400
- * {@link completeDeferredLockRelease}. Base: never defer. */
401
- protected shouldDeferLockRelease(_executionId: string): Promise<boolean>;
402
- /** Complete a release parked by {@link shouldDeferLockRelease}. A subclass
403
- * calls this when its deferred condition settles. */
404
- protected completeDeferredLockRelease(executionId: string): Promise<boolean>;
405
- /** Extra product state replayed to a socket during its `sync`, after the
406
- * base replay for its scope (e.g. an in-flight persistence status card).
407
- * Base: none. */
408
- protected productSyncEvents(_scope: 'thread' | 'workspace', _meta: {
409
- sessionId: string;
410
- }): Promise<TurnStreamEvent[]>;
411
- private handleWebSocketUpgrade;
412
- /**
413
- * First (and only) client message after open: `{ type: 'sync', afterSeq }`.
414
- * Replays the current state for the socket's scope, then marks it `synced`
415
- * so live broadcasts start flowing. Because the DO is single-threaded, the
416
- * replay snapshot and the synced flip are atomic w.r.t. broadcasts — every
417
- * event reaches the socket exactly once, in order, via replay XOR live
418
- * fan-out.
419
- */
420
- webSocketMessage(ws: TurnStreamSocket, message: string | ArrayBuffer): Promise<void>;
421
- webSocketClose(ws: TurnStreamSocket, code: number, reason: string): void;
422
- webSocketError(): void;
423
- private trySend;
424
- private handleBroadcast;
425
- private loadActiveThreads;
426
- private persistActiveThreads;
427
- protected loadActiveLock(now?: number): Promise<DurableTurnLock | null>;
428
- private releaseActiveLock;
429
- /** Park a release on the lock itself; {@link completeDeferredLockRelease}
430
- * finishes it once the product's deferred condition settles. */
431
- private deferLockRelease;
432
- private handleLockAcquire;
433
- private handleLockRelease;
434
- private handleLockReleaseInterrupted;
435
- private handleTurnEventsAppend;
436
- private handleTurnEventsRead;
437
- private handleTurnStatusSet;
438
- private handleTurnStatusGet;
439
- private handleScopeStatusSet;
440
- private handleScopeRunningList;
441
- }
442
-
443
- /**
444
- * Worker-side adapters over {@link TurnStreamDO}: the concrete implementations
445
- * of the chat vertical's `turnStore` and `turnLock` seams, the WebSocket
446
- * upgrade forwarder, the best-effort broadcast helpers, and an in-process
447
- * memory harness for tests and keyless local dev.
448
- *
449
- * Everything takes the namespace STRUCTURALLY ({@link TurnStreamNamespaceLike}
450
- * — Cloudflare's `DurableObjectNamespace` satisfies it), so nothing here
451
- * imports Cloudflare types and the same adapters run against the memory
452
- * harness in vitest.
453
- *
454
- * Live fanout is deliberately NOT a side effect of the turn-event store: the
455
- * store is keyed by turnId/scopeId while viewer sockets live on the
456
- * `${workspaceId}:${threadId}` channel, and only the product's per-turn
457
- * context knows both. Products wire the workspace signal helpers into
458
- * `createChatTurnRoutes`' `onEvent`.
459
- *
460
- * Which adapters are still the right answer (see `./core`'s header for the
461
- * production measurement behind this split):
462
- *
463
- * | adapter | status |
464
- * | ------------------------------------ | --------------------------------- |
465
- * | {@link createDurableTurnLock} | KEPT — no SDK equivalent |
466
- * | {@link reconcileStaleDurableTurnLock}| KEPT — no SDK equivalent |
467
- * | {@link createDurableObjectTurnEventStore} | KEPT — the DETACHED lane |
468
- * | {@link broadcastWorkspaceActivity} | KEPT — workspace signal |
469
- * | {@link broadcastThreadCreated} | KEPT — workspace signal |
470
- * | {@link createTurnStreamUpgradeHandler} | KEPT for the workspace channel |
471
- * | {@link broadcastTurnStreamEvent} | `@deprecated` for sandbox turns |
472
- */
473
-
474
- /** Resolve a stub interface for handling fetch requests with optional initialization parameters */
475
- interface TurnStreamStubLike {
476
- fetch(input: Request | string, init?: RequestInit): Promise<Response>;
477
- }
478
- /** The surface of `DurableObjectNamespace` the adapters use. */
479
- interface TurnStreamNamespaceLike {
480
- idFromName(name: string): unknown;
481
- get(id: unknown): TurnStreamStubLike;
482
- }
483
- /**
484
- * A {@link TurnEventStore} backed by {@link TurnStreamDO} storage — the
485
- * production implementation of `createChatTurnRoutes`' `turnStore` seam for
486
- * apps that don't run D1 for turn events (or want replay co-located with the
487
- * live channel). Each buffered turn lives on its own `turn:<turnId>` DO
488
- * instance; `listRunning` reconnect discovery rides a per-scope index
489
- * instance. Drops in wherever `createD1TurnEventStore(env.DB)` would.
490
- *
491
- * KEPT and load-bearing for AUTONOMOUS work. A detached run
492
- * (`dispatchPrompt({ detach: true })`, `driveTurn`) executes on the sandbox
493
- * run/stream lane, which publishes nothing to the session event bus — a
494
- * `SessionGatewayClient` attached to that session sees zero turn events
495
- * (measured: 0 of 71 / 0 of 527 / 0 of 408 across three session-id
496
- * strategies). So a browser that must tail a mission step, a queue job, or
497
- * an inbound-email review has no SDK path; it needs these durable rows plus
498
- * `runDetachedTurn` (`/chat-routes`). Nothing here is deprecated.
499
- */
500
- declare function createDurableObjectTurnEventStore(namespace: TurnStreamNamespaceLike): TurnEventStore;
501
- /** Define input parameters required to acquire a durable turn lock in a workspace thread context */
502
- interface AcquireDurableTurnLockInput {
503
- workspaceId: string;
504
- threadId: string;
505
- scope: TurnLockScope;
506
- executionId: string;
507
- turnId?: string;
508
- /** Supply to reclaim/retry with a stable id; default mints a UUID. */
509
- lockId?: string;
510
- }
511
- /** Acquire a durable turn lock in the specified namespace with given input parameters */
512
- declare function acquireDurableTurnLock(namespace: TurnStreamNamespaceLike, input: AcquireDurableTurnLockInput): Promise<TurnLockAcquireResult>;
513
- /** Release a durable turn lock and indicate if the release was successful or deferred */
514
- declare function releaseDurableTurnLock(namespace: TurnStreamNamespaceLike, input: TurnLockReleaseInput): Promise<{
515
- released: boolean;
516
- deferred?: boolean;
517
- }>;
518
- /** Define input parameters to release an interrupted durable turn lock in a workspace or thread */
519
- interface ReleaseInterruptedDurableTurnLockInput {
520
- workspaceId: string;
521
- threadId: string;
522
- /** Try only this scope; omit to try workspace then thread (a stop button
523
- * doesn't know which lane the wedged turn ran on). */
524
- scope?: TurnLockScope;
525
- interruptedAt: number;
526
- turnId?: string;
527
- }
528
- /** Fenced out-of-band release — the DO refuses a successor lock (started
529
- * after `interruptedAt`) and a turnId mismatch. Returns whether any scope
530
- * released. */
531
- declare function releaseInterruptedDurableTurnLock(namespace: TurnStreamNamespaceLike, input: ReleaseInterruptedDurableTurnLockInput): Promise<boolean>;
532
- /** Define options to reconcile stale durable turn locks with context, namespace, workspace, and active lock details */
533
- interface ReconcileStaleDurableTurnLockOptions extends Pick<ReconcileStaleTurnLockOptions, 'probeSandbox' | 'probeSession' | 'graceMs' | 'terminalGraceMs' | 'context' | 'log' | 'now'> {
534
- namespace: TurnStreamNamespaceLike;
535
- workspaceId: string;
536
- threadId: string;
537
- /** The lock the acquire attempt was refused on. */
538
- active: DurableTurnLock;
539
- }
540
- /**
541
- * `/chat-routes`' `reconcileStaleTurnLock` policy wired to the DO: the
542
- * product supplies the probes (which box, what its session says), the policy
543
- * decides, and a release lands as a FENCED interrupted release —
544
- * `interruptedAt` is the policy's `fence.observedAt`, so a successor lock
545
- * acquired while the probes were in flight survives by construction.
546
- */
547
- declare function reconcileStaleDurableTurnLock(options: ReconcileStaleDurableTurnLockOptions): Promise<{
548
- released: boolean;
549
- diagnostics: Record<string, unknown>;
550
- }>;
551
- /** The subset of `ChatTurnProduceArgs` the lock adapter reads — structural,
552
- * so this module needs no import from `/chat-routes/turn-routes` (which
553
- * would drag the `agent-runtime` peer into every `/turn-stream` consumer). */
554
- interface TurnLockSeamArgs<TContext> {
555
- identity: {
556
- tenantId: string;
557
- sessionId: string;
558
- };
559
- executionId: string;
560
- context: TContext;
561
- body: {
562
- turnId?: string;
563
- };
564
- }
565
- /** Verdict shape of the vertical's `turnLock.acquire`. */
566
- type TurnLockSeamResult = {
567
- acquired: true;
568
- handle?: unknown;
569
- } | {
570
- acquired: false;
571
- response: Response;
572
- };
573
- /** Define options for creating a durable turn lock with customizable scope and identification methods */
574
- interface CreateDurableTurnLockOptions<TContext> {
575
- namespace: TurnStreamNamespaceLike;
576
- /** Which lane serializes this turn: `'workspace'` (shared sandbox — one
577
- * turn per workspace) or `'thread'` (router lane — one turn per thread). */
578
- scopeOf(args: TurnLockSeamArgs<TContext>): TurnLockScope;
579
- /** Override the execution id the lock records (e.g. a follow-up reclaiming
580
- * the execution it already dispatched). Default: the turn's own. */
581
- lockExecutionIdOf?(args: TurnLockSeamArgs<TContext>): string | undefined;
582
- /** Client turn id recorded on the lock (fences interrupted releases to the
583
- * right turn). Default: the request body's `turnId`. */
584
- clientTurnIdOf?(args: TurnLockSeamArgs<TContext>): string | undefined;
585
- /**
586
- * Attempt stale-lock recovery after a refused acquire. Return whether the
587
- * held lock was released (the adapter then retries the acquire once).
588
- * Products wire {@link reconcileStaleDurableTurnLock} with their sandbox +
589
- * session probes here. Omit → a refused acquire is final.
590
- */
591
- reconcile?(args: TurnLockSeamArgs<TContext>, active: DurableTurnLock): Promise<{
592
- released: boolean;
593
- diagnostics?: Record<string, unknown>;
594
- }>;
595
- /** Build the refusal `Response`. Default: a 409 with the shared body shape
596
- * (`code`, `message`, lock identity + age, reconcile diagnostics). */
597
- onRefused?(active: DurableTurnLock, diagnostics: Record<string, unknown> | undefined): Response;
598
- }
599
- /**
600
- * The vertical's `turnLock` seam on the shared DO: dual-scope single-flight
601
- * acquire (with one reconcile-then-retry pass when the product supplies a
602
- * stale-lock reconciler) and cooperative release on settle. The returned
603
- * object satisfies `createChatTurnRoutes`' `ChatTurnLock<TContext>`
604
- * structurally.
605
- */
606
- declare function createDurableTurnLock<TContext>(options: CreateDurableTurnLockOptions<TContext>): {
607
- acquire(args: TurnLockSeamArgs<TContext>): Promise<TurnLockSeamResult>;
608
- release(handle: unknown): Promise<void>;
609
- };
610
- /**
611
- * DEPRECATED for sandbox-backed interactive turns (drive on the session-message
612
- * lane + `SessionGatewayClient` instead) — fan a turn event out to the
613
- * per-thread channel. `executionId` groups events
614
- * into a per-turn segment with a monotonic seq, so a reconnecting client
615
- * replays only the active turn and resumes from a cursor. Callers MUST await
616
- * (the DO assigns seq on arrival — emission order matters); failures are
617
- * swallowed (fanout is best-effort and never breaks chat delivery).
618
- *
619
- * @deprecated For a SANDBOX-backed interactive turn this re-broadcasts events
620
- * the sandbox platform already fans out, at the cost of a worker hop. Drive
621
- * the turn on the session-MESSAGE lane instead —
622
- * `box.createSession({ sessionId, backend })` then
623
- * `box.session(id).sendMessage({ parts: [{ type: 'text', text }] })` — and let
624
- * the tab attach with `box.mintScopedToken({ scope: 'session', sessionId,
625
- * runtimeSessionId })` + `SessionGatewayClient`
626
- * (`@tangle-network/sandbox/session-gateway`). Measured on production
627
- * (4 arms, SDK 0.12.0): turns driven with `box.streamPrompt()` delivered
628
- * 0 of 71 / 0 of 527 / 0 of 408 turn events to a gateway client, because
629
- * `POST /agents/run/stream` publishes nothing to the session event bus;
630
- * the message lane delivered 297 of 297.
631
- *
632
- * Two things this deprecation does NOT cover, both still supported:
633
- * DETACHED runs (no gateway fanout at all — keep `runDetachedTurn` over the
634
- * durable turn-event rows) and the per-workspace signals
635
- * ({@link broadcastWorkspaceActivity} / {@link broadcastThreadCreated}).
636
- * A SANDBOX-FREE copilot that wants a second viewer should use `/stream`'s
637
- * `replayTurnEvents` (`GET /chat/stream/:turnId`), which follows a running
638
- * turn from a cursor without a second broadcast fabric.
639
- *
640
- * Kept for back-compat; removal is a major-version change.
641
- */
642
- declare function broadcastTurnStreamEvent(namespace: TurnStreamNamespaceLike, input: {
643
- workspaceId: string;
644
- threadId: string;
645
- executionId: string;
646
- event: {
647
- type: string;
648
- data?: Record<string, unknown>;
649
- };
650
- }): Promise<void>;
651
- /** Coarse per-workspace marker that a thread's turn started / ended — drives
652
- * a sidebar "agent responding" indicator subscribed once per workspace. */
653
- declare function broadcastWorkspaceActivity(namespace: TurnStreamNamespaceLike, workspaceId: string, threadId: string, phase: 'start' | 'end'): Promise<void>;
654
- /** Per-workspace marker that a new thread was created, so an already-open
655
- * history list prepends it without a reload. */
656
- declare function broadcastThreadCreated(namespace: TurnStreamNamespaceLike, workspaceId: string, thread: {
657
- threadId: string;
658
- title: string;
659
- }): Promise<void>;
660
- /** Represent success or failure of a TURN stream upgrade authorization with optional response data */
661
- type TurnStreamUpgradeAuthorization = {
662
- ok: true;
663
- } | {
664
- ok: false;
665
- response: Response;
666
- };
667
- /** Define options for creating a TURN stream upgrade handler including namespace, path, and authorization logic */
668
- interface CreateTurnStreamUpgradeHandlerOptions {
669
- namespace: TurnStreamNamespaceLike;
670
- /** The worker route serving the stream. Default `/api/session-stream`. */
671
- path?: string;
672
- /** Viewer access check (session cookie → workspace membership). */
673
- authorize(request: Request, target: {
674
- workspaceId: string;
675
- threadId: string | null;
676
- }): Promise<TurnStreamUpgradeAuthorization>;
677
- }
678
- /**
679
- * The worker-entry WebSocket forwarder. Call BEFORE the app router (a router
680
- * loader cannot return a 101); returns `null` for requests that are not a
681
- * WebSocket upgrade on the configured path.
682
- *
683
- * GET {path}?workspaceId=... → workspace channel (sidebar)
684
- * GET {path}?workspaceId=...&threadId=… → thread channel (turn resume)
685
- *
686
- * After the 101, the client sends `{type:'sync', afterSeq}` and receives the
687
- * replay-then-live stream (see {@link TurnStreamDO.webSocketMessage}).
688
- *
689
- * NOT deprecated — the workspace variant (no `threadId`) is the canonical
690
- * transport for the per-workspace signals, which the session gateway cannot
691
- * carry (it is per-session and read-only). The THREAD variant is the
692
- * deprecated half: for a sandbox-backed interactive turn the tab should
693
- * attach to the session gateway directly instead of to this socket. See
694
- * {@link broadcastTurnStreamEvent} for the measurement and the replacement
695
- * wiring.
696
- */
697
- declare function createTurnStreamUpgradeHandler(options: CreateTurnStreamUpgradeHandlerOptions): (request: Request) => Promise<Response | null>;
698
-
699
- /**
700
- * In-process turn-stream harness: a fake namespace that routes `idFromName`
701
- * to REAL {@link TurnStreamDO} instances over an in-memory storage/socket
702
- * state. The adapters and the DO run their production code paths — only the
703
- * Cloudflare runtime (isolation, hibernation, real sockets) is simulated.
704
- *
705
- * For vitest composition tests and keyless local dev (the same role
706
- * `createMemoryTurnEventStore` plays for the D1 store). Not for production:
707
- * state is per-process and evaporates on restart.
708
- */
709
-
710
- /** A test-side viewer socket: records frames sent by the DO and lets the
711
- * test drive the `sync` handshake. */
712
- interface MemoryTurnStreamSocket extends TurnStreamSocket {
713
- readonly frames: string[];
714
- readonly closed: boolean;
715
- }
716
- /** Define an in-memory channel for streaming turn-based data with viewer socket connection support */
717
- interface MemoryTurnStreamChannel {
718
- /** Attach a viewer socket to this channel (bypasses the HTTP 101 — the
719
- * upgrade handshake is Cloudflare-runtime-only) and run its `sync`. */
720
- connect(input: {
721
- sessionId: string;
722
- scope: 'thread' | 'workspace';
723
- afterSeq?: number;
724
- }): Promise<MemoryTurnStreamSocket>;
725
- readonly instance: TurnStreamDO;
726
- }
727
- /** Provide an interface to manage channels and namespaces for memory-based turn stream testing */
728
- interface MemoryTurnStreamHarness {
729
- namespace: TurnStreamNamespaceLike;
730
- /** The channel (creating its DO instance if needed) for a channel key —
731
- * e.g. `threadChannelKey(ws, thread)` — to connect test viewers. */
732
- channel(name: string): MemoryTurnStreamChannel;
733
- }
734
- /**
735
- * Build the harness. `createInstance` lets a product test run its own
736
- * `TurnStreamDO` subclass through the same wiring.
2
+ * `/turn-stream` — shared durable turn replay/broadcast/lock on a Cloudflare
3
+ * Durable Object (issue #221): the graduation of `createChatTurnRoutes`'
4
+ * `turnStore` seam from "bring your own DO" to a real implementation, plus
5
+ * the dual-scope single-flight turn lock and the live-viewer WebSocket
6
+ * channel every fleet app was hand-rolling.
7
+ *
8
+ * Subpath-only and server-only (like `/chat-routes`): never re-exported from
9
+ * the root barrel, never reachable from a client bundle. Cloudflare is
10
+ * STRUCTURAL throughout no `cloudflare:workers` import; a product binds
11
+ * the DO by re-exporting {@link TurnStreamDO} from its worker entry and
12
+ * declaring it in wrangler.
13
+ *
14
+ * Layout:
15
+ * ./core — pure segment/lock/wire logic (unit-testable)
16
+ * ./do — the DO transport shell + product extension seams
17
+ * ./adapters turnStore + turnLock seam implementations, broadcast
18
+ * helpers, WS upgrade forwarder
19
+ * ./memory — in-process harness for tests and keyless local dev
20
+ *
21
+ * What stays product-side, on purpose: WHICH scope a turn locks on, the
22
+ * sandbox/session probes for stale-lock recovery, viewer authorization, and
23
+ * any post-turn machinery that defers a lock release (the DO's protected
24
+ * seams exist for exactly that).
25
+ *
26
+ * ── What is still the right answer here, and what is not ─────────────────
27
+ *
28
+ * A production A/B (4 arms, sandbox.tangle.tools, SDK 0.12.0) showed that a
29
+ * browser attached to the sandbox session gateway sees a turn only when the
30
+ * turn is driven on the session-MESSAGE lane
31
+ * (`box.session(id).sendMessage()` 297 of 297 frames delivered), never on
32
+ * the run/stream lane (`box.streamPrompt()` → 0 of 71, 0 of 527, 0 of 408
33
+ * across three session-id strategies). `./core`'s header carries the full
34
+ * table.
35
+ *
36
+ * KEPT no SDK primitive replaces these:
37
+ * the dual-scope single-flight TURN LOCK (`createDurableTurnLock`,
38
+ * `reconcileStaleDurableTurnLock`) the gateway is a read-only fanout
39
+ * and ships no admission control;
40
+ * the per-workspace SIGNALS (`thread.created`, `thread.activity`, plus
41
+ * `productSyncEvents`) the gateway is per-session;
42
+ * the durable TURN-EVENT rows + running-turn index
43
+ * (`createDurableObjectTurnEventStore`) that `runDetachedTurn` streams
44
+ * into — a detached run (`dispatchPrompt({ detach: true })`,
45
+ * `driveTurn`) goes through `streamPrompt` internally, so it never
46
+ * reaches the gateway at all. Autonomous work a browser must tail has
47
+ * no other path today.
48
+ *
49
+ * DEPRECATED duplicates the SDK:
50
+ * the interactive per-turn REBROADCAST/replay on the thread channel
51
+ * (`broadcastTurnStreamEvent` + the segment functions in `./core`).
52
+ * Sandbox products: drive on the message lane and attach the tab with
53
+ * `box.mintScopedToken({ scope: 'session' })` + `SessionGatewayClient`;
54
+ * resume a worker-side read with
55
+ * `box.streamPrompt('', { executionId, lastEventId })`, which replays
56
+ * strictly after the cursor without re-dispatching.
57
+ *
58
+ * Nothing is removed: these are published exports and unknown consumers may
59
+ * hold them. Removal is a major-version change.
737
60
  */
738
- declare function createMemoryTurnStreamHarness(createInstance?: (state: TurnStreamDOState) => TurnStreamDO, _options?: TurnStreamDOOptions): MemoryTurnStreamHarness;
739
-
740
- export { ACTIVITY_TTL_MS, type AcquireDurableTurnLockInput, type CreateDurableTurnLockOptions, type CreateTurnStreamUpgradeHandlerOptions, type DurableTurnLock, MAX_RECENT_CREATED, MAX_SEGMENT_EVENTS, type MemoryTurnStreamChannel, type MemoryTurnStreamHarness, type MemoryTurnStreamSocket, type ReconcileStaleDurableTurnLockOptions, type ReleaseInterruptedDurableTurnLockInput, type SegmentStore, TURN_LOCK_TTL_MS, TURN_STREAM_PATHS, TURN_STREAM_STORAGE_KEYS, type TurnLockAcquireInput, type TurnLockAcquireResult, type TurnLockInterruptedReleaseInput, type TurnLockReleaseInput, type TurnLockScope, type TurnLockSeamArgs, type TurnLockSeamResult, type TurnSegment, TurnStreamDO, type TurnStreamDOOptions, type TurnStreamDOState, type TurnStreamEvent, type TurnStreamNamespaceLike, type TurnStreamSocket, type TurnStreamStorage, type TurnStreamStubLike, type TurnStreamUpgradeAuthorization, acquireDurableTurnLock, activeTurnLock, appendSegmentEvent, broadcastThreadCreated, broadcastTurnStreamEvent, broadcastWorkspaceActivity, createDurableObjectTurnEventStore, createDurableTurnLock, createMemoryTurnStreamHarness, createSegmentStore, createTurnLock, createTurnStreamUpgradeHandler, interruptedReleaseApplies, isTerminalRunEvent, pruneStaleThreads, reconcileStaleDurableTurnLock, releaseDurableTurnLock, releaseInterruptedDurableTurnLock, replayActiveSegment, scopeIndexChannelKey, threadChannelKey, turnEventStorageKey, turnLockChannelKey, turnLockMatchesRelease, turnStorageChannelKey, workspaceChannelKey };
61
+ export * from './core';
62
+ export * from './do';
63
+ export * from './adapters';
64
+ export * from './memory';