@theoremjs/studio 0.0.0-stage → 0.3.2

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 (473) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +295 -2
  3. package/agreement.d.ts +14 -0
  4. package/agreement.js +80 -0
  5. package/asks.d.ts +47 -0
  6. package/asks.js +54 -0
  7. package/browser-connection.d.ts +49 -0
  8. package/browser-connection.js +215 -0
  9. package/browser-engine.d.ts +11 -0
  10. package/browser-engine.js +11 -0
  11. package/browser-execution.d.ts +6 -0
  12. package/browser-execution.js +18 -0
  13. package/browser-live.d.ts +4 -0
  14. package/browser-live.js +132 -0
  15. package/browser-transport.d.ts +33 -0
  16. package/browser-transport.js +229 -0
  17. package/browser.d.ts +4 -0
  18. package/browser.js +4 -0
  19. package/canonical.d.ts +10 -0
  20. package/canonical.js +25 -0
  21. package/compile-workspace.d.ts +28 -0
  22. package/compile-workspace.js +295 -0
  23. package/compile.d.ts +65 -0
  24. package/compile.js +1605 -0
  25. package/concierge-demo.d.ts +17 -0
  26. package/concierge-demo.js +1230 -0
  27. package/conversation-key.d.ts +5 -0
  28. package/conversation-key.js +10 -0
  29. package/decision-example-images.d.ts +30 -0
  30. package/decision-example-images.js +30 -0
  31. package/deno.json +3 -0
  32. package/draft.d.ts +407 -0
  33. package/draft.js +505 -0
  34. package/editors.d.ts +29 -0
  35. package/editors.js +51 -0
  36. package/example-embedding-files.d.ts +11 -0
  37. package/example-embedding-files.js +20 -0
  38. package/example.d.ts +36 -0
  39. package/example.js +357 -0
  40. package/guardrail-probe.d.ts +100 -0
  41. package/guardrail-probe.js +722 -0
  42. package/held-credentials.d.ts +28 -0
  43. package/held-credentials.js +87 -0
  44. package/installed.mjs +40 -0
  45. package/lent-keys.d.ts +122 -0
  46. package/lent-keys.js +47 -0
  47. package/line-diff.d.ts +15 -0
  48. package/line-diff.js +41 -0
  49. package/live-connection.d.ts +22 -0
  50. package/live-connection.js +27 -0
  51. package/live-session-bridge.d.ts +15 -0
  52. package/live-session-bridge.js +202 -0
  53. package/map-line.d.ts +19 -0
  54. package/map-line.js +42 -0
  55. package/map.d.ts +154 -0
  56. package/map.js +525 -0
  57. package/media-accept.d.ts +19 -0
  58. package/media-accept.js +65 -0
  59. package/mod.d.ts +39 -0
  60. package/mod.js +33 -0
  61. package/origins.d.ts +52 -0
  62. package/origins.js +165 -0
  63. package/package.json +85 -4
  64. package/page/assets/Banner-BISz3nXA.js +2 -0
  65. package/page/assets/BottomSheet-BwfBDtje.js +1 -0
  66. package/page/assets/Card-Lp-0P5eL.js +1 -0
  67. package/page/assets/CardWall-CBRLdDZW.js +1 -0
  68. package/page/assets/Center-nHS1JSux.js +1 -0
  69. package/page/assets/CheckboxInput-Cj5pk-KI.js +2 -0
  70. package/page/assets/CodeBlock-C7XJ4ioE.js +51 -0
  71. package/page/assets/CollapsibleGroup-N7_SOjbm.js +2 -0
  72. package/page/assets/ContextMenu-CBu9H-9H.js +2 -0
  73. package/page/assets/DateInput-BGrQ5tPC.js +1 -0
  74. package/page/assets/Dialog-DELWQo-v.js +1 -0
  75. package/page/assets/EmptyState-C8W4JKBZ.js +1 -0
  76. package/page/assets/HoverCard-D1Y1ltWQ.js +1 -0
  77. package/page/assets/Icon-JrysT8aU.js +3 -0
  78. package/page/assets/IconAlertTriangle-BqAEqqdU.js +1 -0
  79. package/page/assets/IconButton-DlOGzJIX.js +1 -0
  80. package/page/assets/IconEye-BB5aY-wQ.js +1 -0
  81. package/page/assets/IconFileText-6zOFKKrF.js +1 -0
  82. package/page/assets/IconSearch-BTx66a40.js +1 -0
  83. package/page/assets/IconShield-DDOh7Gr5.js +1 -0
  84. package/page/assets/ItemSwipeLayer-Ckn4X6h9.js +1 -0
  85. package/page/assets/PaneState-BvA2tLQg.js +1 -0
  86. package/page/assets/PaneState-eUzUkNE8.css +1 -0
  87. package/page/assets/ScrollableArea-Ckugdj1N.js +1 -0
  88. package/page/assets/Section-DJ97F7QE.js +1 -0
  89. package/page/assets/SegmentedControlItem-h-aaXzyS.js +1 -0
  90. package/page/assets/SidePanel-BL32abk8.js +1 -0
  91. package/page/assets/StackItem-CQviqAfM.js +1 -0
  92. package/page/assets/Text-bum6zWWx.js +2 -0
  93. package/page/assets/TimestampHoverCard-DQIG0RZF.js +1 -0
  94. package/page/assets/ToolResultCharts-CgshSv9Q.js +1 -0
  95. package/page/assets/Tooltip-BH9xiRMl.js +1 -0
  96. package/page/assets/TraceInspector-_yZiz05W.js +1 -0
  97. package/page/assets/TraceOverview-BPO-HIYK.js +57 -0
  98. package/page/assets/VStack-CkVMcNiK.js +1 -0
  99. package/page/assets/_virtual_studio-type-sources-ByxqQaOG.js +12936 -0
  100. package/page/assets/arrive-DvbqpeRS.js +1 -0
  101. package/page/assets/browser-engine-CYq9DQAM.js +9 -0
  102. package/page/assets/browser-transport-D-2jDYe7.js +47 -0
  103. package/page/assets/codicon-DF1abBS2.ttf +0 -0
  104. package/page/assets/compile-egress-BSxOdX4K.js +23 -0
  105. package/page/assets/container.stylex-BmOi-8DQ.js +1 -0
  106. package/page/assets/createReactComponent-CZwsv6DD.js +1 -0
  107. package/page/assets/decision-example-images-CZGr7YIT.js +1 -0
  108. package/page/assets/devWarning-DxuplmRl.js +1 -0
  109. package/page/assets/editor-DjpsE8to.css +1 -0
  110. package/page/assets/editor.api-Cd3ViPQa.js +908 -0
  111. package/page/assets/editor.worker-6GY8RhDc.js +1 -0
  112. package/page/assets/editor.worker-BmdWdrHZ.js +33 -0
  113. package/page/assets/editors-BJX_S59A.js +1 -0
  114. package/page/assets/egress-automata-B5ZGE1mT.js +1 -0
  115. package/page/assets/embedding-space-view-CfQBPDxD.js +140 -0
  116. package/page/assets/encode-files-Bc3HJyAh.js +1 -0
  117. package/page/assets/export-agent-C3yyzXH8.js +43 -0
  118. package/page/assets/figtree-latin-400-normal-BD4aNku5.woff +0 -0
  119. package/page/assets/figtree-latin-400-normal-g7Dtegnw.woff2 +0 -0
  120. package/page/assets/figtree-latin-500-normal-BWnGEVsr.woff2 +0 -0
  121. package/page/assets/figtree-latin-500-normal-B_yy1phn.woff +0 -0
  122. package/page/assets/figtree-latin-600-normal-BM_oTo4n.woff +0 -0
  123. package/page/assets/figtree-latin-600-normal-Cv_xCTDl.woff2 +0 -0
  124. package/page/assets/figtree-latin-700-normal-BCCt2T1q.woff +0 -0
  125. package/page/assets/figtree-latin-700-normal-th6qEP7c.woff2 +0 -0
  126. package/page/assets/focusOutline.stylex-BT0kfa4t.js +1 -0
  127. package/page/assets/focusableSelector-DXZeMU85.js +1 -0
  128. package/page/assets/groupStyles-C7Ter7zC.js +1 -0
  129. package/page/assets/guardrail-tester-Gut5xK4a.js +9 -0
  130. package/page/assets/host-patterns-C9RMP16Q.js +1 -0
  131. package/page/assets/index-CvvmFKgS.js +105 -0
  132. package/page/assets/index-DOaHlqBo.css +1 -0
  133. package/page/assets/isRtlElement-BG33-k_H.js +1 -0
  134. package/page/assets/labels-provider-4TIWDvsE.js +3 -0
  135. package/page/assets/lent-keys-C32ems-I.js +1 -0
  136. package/page/assets/live-ingress-lDUGPwth.js +1 -0
  137. package/page/assets/live-messages-CnkL4GWi.js +1 -0
  138. package/page/assets/mergeProps-ptS-gIMz.js +1 -0
  139. package/page/assets/padding.stylex-B76907Zf.js +1 -0
  140. package/page/assets/preload-helper-DpV6A1kQ.js +1 -0
  141. package/page/assets/reader-BOCCYaRp.js +7 -0
  142. package/page/assets/register-CDgivxvX.js +2 -0
  143. package/page/assets/rolldown-runtime-hePW80VL.js +1 -0
  144. package/page/assets/schemas-BQ9Jydzb.js +56 -0
  145. package/page/assets/shaped-data-BcarWqd5.js +16 -0
  146. package/page/assets/sharedResizeObserver-4U9Xq5Oq.js +1 -0
  147. package/page/assets/stub-DhdcU_Ew.js +471 -0
  148. package/page/assets/studio-code-pane-C_SAbcOa.js +8 -0
  149. package/page/assets/studio-console-DZwlEsvr.js +3 -0
  150. package/page/assets/studio-decision-B0FnCAXA.js +1 -0
  151. package/page/assets/studio-embedding-CmA51HVo.js +2 -0
  152. package/page/assets/studio-host-console-By7hqu2l.js +2 -0
  153. package/page/assets/studio-live-BrcVQcyV.js +1 -0
  154. package/page/assets/studio-map-B_xSia-z.js +1 -0
  155. package/page/assets/studio-map-Bb06Tw1F.css +1 -0
  156. package/page/assets/studio-monaco-CbKf90i6.css +1 -0
  157. package/page/assets/studio-monaco-xfyfezQS.js +34 -0
  158. package/page/assets/studio-ts.worker-B-EXG4Sv.js +67741 -0
  159. package/page/assets/studio-ts.worker-BXtW3z-O.js +1 -0
  160. package/page/assets/studio-type-checker-BOvxudki.js +23 -0
  161. package/page/assets/themeProps-3IqahpCr.js +1 -0
  162. package/page/assets/tokens.stylex-DkHf0P9C.js +1 -0
  163. package/page/assets/tool-schema-idaOe2nI.js +18 -0
  164. package/page/assets/trace-patterns-DnYJa0nI.js +1 -0
  165. package/page/assets/trace-record-C3zNksA_.js +1 -0
  166. package/page/assets/trace-schema-9CdEyG6Q.js +1 -0
  167. package/page/assets/tree-DqyAMsbI.js +3 -0
  168. package/page/assets/turn-client-Du3Um3Mg.js +2 -0
  169. package/page/assets/types-BhfXQCLx.js +1 -0
  170. package/page/assets/typescript-20GgZ8PJ.js +1 -0
  171. package/page/assets/use-one-call-Hcs8YBp1.js +1 -0
  172. package/page/assets/useAdaptivePresentation-BzmPCddb.js +1 -0
  173. package/page/assets/useClipboard-BgGRxRMJ.js +1 -0
  174. package/page/assets/useContainerReveal-BFy8N_QU.js +1 -0
  175. package/page/assets/useDevWarning-Z9SoixOP.js +1 -0
  176. package/page/assets/useLayerDismissal-B_G7IWpC.js +1 -0
  177. package/page/assets/useMediaQuery-BCT0NUeZ.js +1 -0
  178. package/page/assets/useScrollLock-Dyf6PHJt.js +1 -0
  179. package/page/assets/useScrollableArea-0NzdiBCq.js +1 -0
  180. package/page/assets/useTooltip-CJM_xhLB.js +1 -0
  181. package/page/assets/workspace-DZALqEDX.js +1 -0
  182. package/page/assets/zip-DTcEfps6.js +1 -0
  183. package/page/index.html +90 -0
  184. package/page.mjs +49 -0
  185. package/people.d.ts +87 -0
  186. package/people.js +110 -0
  187. package/policy.d.ts +43 -0
  188. package/policy.js +102 -0
  189. package/ports.d.mts +32 -0
  190. package/ports.mjs +85 -0
  191. package/probe-battery.d.ts +13 -0
  192. package/probe-battery.js +404 -0
  193. package/providers.d.ts +149 -0
  194. package/providers.js +306 -0
  195. package/read-source.d.ts +48 -0
  196. package/read-source.js +1301 -0
  197. package/read-steps.d.ts +23 -0
  198. package/read-steps.js +2 -0
  199. package/reader.d.ts +11 -0
  200. package/reader.js +11 -0
  201. package/registrations.d.ts +83 -0
  202. package/registrations.js +1 -0
  203. package/requirements.d.ts +22 -0
  204. package/requirements.js +38 -0
  205. package/run-payload-core.d.ts +28 -0
  206. package/run-payload-core.js +123 -0
  207. package/run-payload.d.ts +32 -0
  208. package/run-payload.js +26 -0
  209. package/runtime-scope.d.ts +84 -0
  210. package/runtime-scope.js +308 -0
  211. package/runtime.d.ts +84 -0
  212. package/runtime.js +387 -0
  213. package/section-notes.d.ts +33 -0
  214. package/section-notes.js +38 -0
  215. package/serve-page.mjs +96 -0
  216. package/server/draft-decide.d.ts +72 -0
  217. package/server/draft-decide.js +111 -0
  218. package/server/draft-embedding.d.ts +3 -0
  219. package/server/draft-embedding.js +35 -0
  220. package/server/draft-handler.d.ts +82 -0
  221. package/server/draft-handler.js +213 -0
  222. package/server/draft-probe.d.ts +14 -0
  223. package/server/draft-probe.js +61 -0
  224. package/server/draft-replies.d.ts +22 -0
  225. package/server/draft-replies.js +46 -0
  226. package/server/edited-session.d.ts +28 -0
  227. package/server/edited-session.js +83 -0
  228. package/server/edits.d.ts +38 -0
  229. package/server/edits.js +195 -0
  230. package/server/handler.d.ts +133 -0
  231. package/server/handler.js +598 -0
  232. package/server/lent-draft.d.ts +19 -0
  233. package/server/lent-draft.js +23 -0
  234. package/server/live.d.ts +15 -0
  235. package/server/live.js +96 -0
  236. package/server/open-editor.d.ts +63 -0
  237. package/server/open-editor.js +115 -0
  238. package/server/origins.d.ts +18 -0
  239. package/server/origins.js +330 -0
  240. package/server/project-source.d.ts +208 -0
  241. package/server/project-source.js +1042 -0
  242. package/server/project.d.ts +22 -0
  243. package/server/project.js +56 -0
  244. package/server/run-traces.d.ts +20 -0
  245. package/server/run-traces.js +96 -0
  246. package/server/save-new.d.ts +29 -0
  247. package/server/save-new.js +514 -0
  248. package/server/save-plan.d.ts +46 -0
  249. package/server/save-plan.js +1134 -0
  250. package/server/save-remove.d.ts +21 -0
  251. package/server/save-remove.js +528 -0
  252. package/server/save-session.d.ts +96 -0
  253. package/server/save-session.js +418 -0
  254. package/server/save-wire.d.ts +235 -0
  255. package/server/save-wire.js +8 -0
  256. package/server/save.d.ts +52 -0
  257. package/server/save.js +209 -0
  258. package/server/serve.d.ts +23 -0
  259. package/server/serve.js +413 -0
  260. package/server/test-connection.d.ts +17 -0
  261. package/server/test-connection.js +362 -0
  262. package/server/test-key.d.ts +2 -0
  263. package/server/test-key.js +83 -0
  264. package/server/watch.d.ts +28 -0
  265. package/server/watch.js +93 -0
  266. package/server/zod-edit.d.ts +74 -0
  267. package/server/zod-edit.js +558 -0
  268. package/server.d.ts +8 -0
  269. package/server.js +8 -0
  270. package/setups.mjs +170 -0
  271. package/shared-carry.d.ts +114 -0
  272. package/shared-carry.js +523 -0
  273. package/shared-settings.d.ts +34 -0
  274. package/shared-settings.js +70 -0
  275. package/source.d.ts +75 -0
  276. package/source.js +414 -0
  277. package/start.mjs +169 -0
  278. package/stream-lines.d.ts +9 -0
  279. package/stream-lines.js +27 -0
  280. package/stub.d.ts +6 -0
  281. package/stub.js +33 -0
  282. package/surface.d.ts +53 -0
  283. package/surface.js +631 -0
  284. package/system-markup.d.ts +20 -0
  285. package/system-markup.js +51 -0
  286. package/tool-schema.d.ts +23 -0
  287. package/tool-schema.js +69 -0
  288. package/tools.d.ts +16 -0
  289. package/tools.js +91 -0
  290. package/traces.d.ts +24 -0
  291. package/traces.js +29 -0
  292. package/transport.d.ts +57 -0
  293. package/transport.js +187 -0
  294. package/tree.d.ts +32 -0
  295. package/tree.js +83 -0
  296. package/types.d.ts +62 -0
  297. package/types.js +6 -0
  298. package/ui/acting-as-button.d.ts +2 -0
  299. package/ui/acting-as-button.js +16 -0
  300. package/ui/add-provider.d.ts +13 -0
  301. package/ui/add-provider.js +20 -0
  302. package/ui/boot-mark.css +53 -0
  303. package/ui/boot-mark.d.ts +19 -0
  304. package/ui/boot-mark.js +128 -0
  305. package/ui/boot-paint.d.ts +8 -0
  306. package/ui/boot-paint.js +8 -0
  307. package/ui/brand-icons.d.ts +57 -0
  308. package/ui/brand-icons.js +148 -0
  309. package/ui/built/theme.css +830 -0
  310. package/ui/built/theme.css.d.ts +9 -0
  311. package/ui/built/theorem-studio.d.ts +13 -0
  312. package/ui/built/theorem-studio.js +705 -0
  313. package/ui/built/theorem-studio.variants.d.ts +28 -0
  314. package/ui/code/monaco-contributions.d.ts +45 -0
  315. package/ui/code/studio-code.d.ts +7 -0
  316. package/ui/code/studio-code.js +253 -0
  317. package/ui/code/studio-monaco.d.ts +44 -0
  318. package/ui/code/studio-monaco.js +48 -0
  319. package/ui/code/studio-ts.worker.d.ts +1 -0
  320. package/ui/code/studio-ts.worker.js +16 -0
  321. package/ui/code/studio-type-checker.d.ts +12 -0
  322. package/ui/code/studio-type-checker.js +308 -0
  323. package/ui/code/studio-type-sources.d.ts +26 -0
  324. package/ui/confirm-write.d.ts +12 -0
  325. package/ui/confirm-write.js +45 -0
  326. package/ui/diff-block.d.ts +21 -0
  327. package/ui/diff-block.js +17 -0
  328. package/ui/figtree.css +59 -0
  329. package/ui/file-place.d.ts +4 -0
  330. package/ui/file-place.js +26 -0
  331. package/ui/guardrail-tester.d.ts +18 -0
  332. package/ui/guardrail-tester.js +248 -0
  333. package/ui/inspector-context.d.ts +119 -0
  334. package/ui/inspector-context.js +84 -0
  335. package/ui/inspector.d.ts +247 -0
  336. package/ui/inspector.js +284 -0
  337. package/ui/lib/acting-as.d.ts +25 -0
  338. package/ui/lib/acting-as.js +90 -0
  339. package/ui/lib/boot-sequence.d.ts +32 -0
  340. package/ui/lib/boot-sequence.js +57 -0
  341. package/ui/lib/export-agent.d.ts +11 -0
  342. package/ui/lib/export-agent.js +335 -0
  343. package/ui/lib/facet-icons.d.ts +20 -0
  344. package/ui/lib/facet-icons.js +21 -0
  345. package/ui/lib/panel-motion.d.ts +8 -0
  346. package/ui/lib/panel-motion.js +74 -0
  347. package/ui/lib/project-address.d.ts +14 -0
  348. package/ui/lib/project-address.js +24 -0
  349. package/ui/lib/project-starting.d.ts +13 -0
  350. package/ui/lib/project-starting.js +30 -0
  351. package/ui/lib/project-traces.d.ts +17 -0
  352. package/ui/lib/project-traces.js +54 -0
  353. package/ui/lib/read-map.d.ts +30 -0
  354. package/ui/lib/read-map.js +173 -0
  355. package/ui/lib/read-progress.d.ts +14 -0
  356. package/ui/lib/read-progress.js +12 -0
  357. package/ui/lib/refusal-lines.d.ts +3 -0
  358. package/ui/lib/refusal-lines.js +8 -0
  359. package/ui/lib/studio-activity.d.ts +5 -0
  360. package/ui/lib/studio-activity.js +17 -0
  361. package/ui/lib/studio-console.d.ts +27 -0
  362. package/ui/lib/studio-console.js +9 -0
  363. package/ui/lib/studio-conversation.d.ts +20 -0
  364. package/ui/lib/studio-conversation.js +130 -0
  365. package/ui/lib/studio-examples.d.ts +31 -0
  366. package/ui/lib/studio-examples.js +25 -0
  367. package/ui/lib/studio-labels.d.ts +6 -0
  368. package/ui/lib/studio-labels.js +13 -0
  369. package/ui/lib/studio-map-kept.d.ts +17 -0
  370. package/ui/lib/studio-map-kept.js +48 -0
  371. package/ui/lib/studio-open.d.ts +22 -0
  372. package/ui/lib/studio-open.js +54 -0
  373. package/ui/lib/studio-page.d.ts +33 -0
  374. package/ui/lib/studio-page.js +121 -0
  375. package/ui/lib/studio-prefs.d.ts +26 -0
  376. package/ui/lib/studio-prefs.js +87 -0
  377. package/ui/lib/studio-project.d.ts +106 -0
  378. package/ui/lib/studio-project.js +177 -0
  379. package/ui/lib/studio-restore.d.ts +49 -0
  380. package/ui/lib/studio-restore.js +251 -0
  381. package/ui/lib/studio-run-open.d.ts +15 -0
  382. package/ui/lib/studio-run-open.js +16 -0
  383. package/ui/lib/studio-session.d.ts +34 -0
  384. package/ui/lib/studio-session.js +17 -0
  385. package/ui/lib/studio-settings.d.ts +15 -0
  386. package/ui/lib/studio-settings.js +48 -0
  387. package/ui/lib/studio-store.d.ts +64 -0
  388. package/ui/lib/studio-store.js +391 -0
  389. package/ui/lib/studio-watch.d.ts +12 -0
  390. package/ui/lib/studio-watch.js +27 -0
  391. package/ui/lib/tab-fills.d.ts +6 -0
  392. package/ui/lib/tab-fills.js +14 -0
  393. package/ui/lib/tool-credentials.d.ts +3 -0
  394. package/ui/lib/tool-credentials.js +23 -0
  395. package/ui/lib/tool-probe.d.ts +19 -0
  396. package/ui/lib/tool-probe.js +104 -0
  397. package/ui/lib/type-icons.d.ts +35 -0
  398. package/ui/lib/type-icons.js +38 -0
  399. package/ui/lib/when-idle.d.ts +5 -0
  400. package/ui/lib/when-idle.js +14 -0
  401. package/ui/lib/zip.d.ts +5 -0
  402. package/ui/lib/zip.js +8 -0
  403. package/ui/map-token.css +11 -0
  404. package/ui/map-token.d.ts +17 -0
  405. package/ui/map-token.js +29 -0
  406. package/ui/mcp-icon.d.ts +6 -0
  407. package/ui/mcp-icon.js +8 -0
  408. package/ui/motion.css +113 -0
  409. package/ui/pan.d.ts +32 -0
  410. package/ui/pan.js +90 -0
  411. package/ui/profile-editor.d.ts +33 -0
  412. package/ui/profile-editor.js +2638 -0
  413. package/ui/provider-editor.d.ts +15 -0
  414. package/ui/provider-editor.js +92 -0
  415. package/ui/read-map.css +48 -0
  416. package/ui/read-map.d.ts +7 -0
  417. package/ui/read-map.js +163 -0
  418. package/ui/refusal-detail.d.ts +4 -0
  419. package/ui/refusal-detail.js +21 -0
  420. package/ui/shared-change.d.ts +9 -0
  421. package/ui/shared-change.js +28 -0
  422. package/ui/shell-motion.css +121 -0
  423. package/ui/shell-motion.d.ts +73 -0
  424. package/ui/shell-motion.js +194 -0
  425. package/ui/studio-code-pane.d.ts +19 -0
  426. package/ui/studio-code-pane.js +44 -0
  427. package/ui/studio-compare.d.ts +80 -0
  428. package/ui/studio-compare.js +326 -0
  429. package/ui/studio-conflicts.d.ts +17 -0
  430. package/ui/studio-conflicts.js +87 -0
  431. package/ui/studio-connection.d.ts +64 -0
  432. package/ui/studio-connection.js +286 -0
  433. package/ui/studio-decision.d.ts +6 -0
  434. package/ui/studio-decision.js +49 -0
  435. package/ui/studio-embedding.d.ts +6 -0
  436. package/ui/studio-embedding.js +30 -0
  437. package/ui/studio-host-console.d.ts +6 -0
  438. package/ui/studio-host-console.js +17 -0
  439. package/ui/studio-host.d.ts +73 -0
  440. package/ui/studio-host.js +12 -0
  441. package/ui/studio-live.d.ts +17 -0
  442. package/ui/studio-live.js +26 -0
  443. package/ui/studio-map.css +273 -0
  444. package/ui/studio-map.d.ts +17 -0
  445. package/ui/studio-map.js +397 -0
  446. package/ui/studio-nav.d.ts +24 -0
  447. package/ui/studio-nav.js +17 -0
  448. package/ui/studio-no-project.d.ts +5 -0
  449. package/ui/studio-no-project.js +9 -0
  450. package/ui/studio-run.css +76 -0
  451. package/ui/studio-run.d.ts +14 -0
  452. package/ui/studio-run.js +119 -0
  453. package/ui/studio-runner.d.ts +45 -0
  454. package/ui/studio-runner.js +187 -0
  455. package/ui/studio-save.d.ts +49 -0
  456. package/ui/studio-save.js +307 -0
  457. package/ui/studio-screen.d.ts +61 -0
  458. package/ui/studio-screen.js +2078 -0
  459. package/ui/studio-settings.d.ts +31 -0
  460. package/ui/studio-settings.js +288 -0
  461. package/ui/studio-shell.css +27 -0
  462. package/ui/studio-shell.d.ts +43 -0
  463. package/ui/studio-shell.js +87 -0
  464. package/ui/studio-theme.d.ts +7 -0
  465. package/ui/studio-theme.js +94 -0
  466. package/ui/studio.css +427 -0
  467. package/ui/theorem-mark.css +84 -0
  468. package/ui/theorem-mark.d.ts +22 -0
  469. package/ui/theorem-mark.js +21 -0
  470. package/vite.d.mts +30 -0
  471. package/vite.mjs +277 -0
  472. package/workspace.d.ts +230 -0
  473. package/workspace.js +1054 -0
@@ -0,0 +1,51 @@
1
+ const OPEN = /\{\s*private\s*:/g;
2
+ function lineAt(text, index) {
3
+ return text.slice(0, index).split('\n').length;
4
+ }
5
+ /**
6
+ * A section closes at the `}` that balances its `{`, so braces inside it pair
7
+ * up as written. Its text is trimmed; the text around it is kept as written,
8
+ * apart from the ends of the whole prompt.
9
+ */
10
+ function parseSystemMarkup(text) {
11
+ const parts = [];
12
+ let at = 0;
13
+ for (const open of text.matchAll(OPEN)) {
14
+ if (open.index < at)
15
+ continue;
16
+ let depth = 1;
17
+ let close = open.index + open[0].length;
18
+ for (; close < text.length && depth > 0; close++) {
19
+ if (text[close] === '{')
20
+ depth++;
21
+ else if (text[close] === '}')
22
+ depth--;
23
+ }
24
+ if (depth > 0) {
25
+ return {
26
+ ok: false,
27
+ message: `The {private: section on line ${String(lineAt(text, open.index))} has no closing }.`,
28
+ };
29
+ }
30
+ const secret = text.slice(open.index + open[0].length, close - 1).trim();
31
+ if (!secret) {
32
+ return {
33
+ ok: false,
34
+ message: `The {private: section on line ${String(lineAt(text, open.index))} is empty.`,
35
+ };
36
+ }
37
+ parts.push(text.slice(at, open.index), { private: secret });
38
+ at = close;
39
+ }
40
+ parts.push(text.slice(at));
41
+ if (parts.length === 1)
42
+ return { ok: true, prompt: text.trim() || undefined };
43
+ const first = parts[0];
44
+ const last = parts.at(-1);
45
+ if (typeof first === 'string')
46
+ parts[0] = first.trimStart();
47
+ if (typeof last === 'string')
48
+ parts[parts.length - 1] = last.trimEnd();
49
+ return { ok: true, prompt: parts.filter((part) => part !== '') };
50
+ }
51
+ export { parseSystemMarkup };
@@ -0,0 +1,23 @@
1
+ import { type JsonSchema } from '@theoremjs/react/client';
2
+ import { type ZodType } from 'zod';
3
+ export declare const DEFAULT_TOOL_INPUT_SCHEMA = "{\n \"type\": \"object\",\n \"properties\": {\n \"query\": { \"type\": \"string\" }\n },\n \"required\": [\"query\"]\n}";
4
+ export declare const DEFAULT_TOOL_OUTPUT_SCHEMA = "{\n \"type\": \"object\",\n \"properties\": {\n \"result\": { \"type\": \"string\" }\n },\n \"required\": [\"result\"]\n}";
5
+ export type { JsonSchema };
6
+ /**
7
+ * A tool's zod schema, read from its JSON Schema exactly as a file Save writes reads it, so a
8
+ * studio run checks a tool's input and output by the same contract the saved code does.
9
+ */
10
+ export declare function zodFromJsonSchema(schema: JsonSchema): ZodType;
11
+ /** Required fields, and optional ones with an example; the package's form fills a tool's request the same way. */
12
+ export declare function sampleFromJsonSchema(schema: JsonSchema): Record<string, unknown>;
13
+ export declare function quoteSource(text: string): string;
14
+ /** Bare when the key is an identifier. */
15
+ export declare function keySource(key: string, quote?: (text: string) => string): string;
16
+ /** `label` names the schema in the error. */
17
+ export declare function parseJsonSchema(raw: string, label: string): {
18
+ ok: true;
19
+ schema: JsonSchema;
20
+ } | {
21
+ ok: false;
22
+ error: string;
23
+ };
package/tool-schema.js ADDED
@@ -0,0 +1,69 @@
1
+ import { sampleFromSchema } from '@theoremjs/react/client';
2
+ import { z } from 'zod';
3
+ export const DEFAULT_TOOL_INPUT_SCHEMA = `{
4
+ "type": "object",
5
+ "properties": {
6
+ "query": { "type": "string" }
7
+ },
8
+ "required": ["query"]
9
+ }`;
10
+ export const DEFAULT_TOOL_OUTPUT_SCHEMA = `{
11
+ "type": "object",
12
+ "properties": {
13
+ "result": { "type": "string" }
14
+ },
15
+ "required": ["result"]
16
+ }`;
17
+ /**
18
+ * A tool's zod schema, read from its JSON Schema exactly as a file Save writes reads it, so a
19
+ * studio run checks a tool's input and output by the same contract the saved code does.
20
+ */
21
+ export function zodFromJsonSchema(schema) {
22
+ return z.fromJSONSchema(schema);
23
+ }
24
+ /** Required fields, and optional ones with an example; the package's form fills a tool's request the same way. */
25
+ export function sampleFromJsonSchema(schema) {
26
+ return sampleFromSchema(schema);
27
+ }
28
+ /** Characters escaped even inside a string literal, so pasted source can't close a `<script>` or break a line. */
29
+ const UNSAFE_SOURCE_CHARS = {
30
+ '<': '\\u003C',
31
+ '>': '\\u003E',
32
+ '\u2028': '\\u2028',
33
+ '\u2029': '\\u2029',
34
+ };
35
+ export function quoteSource(text) {
36
+ const body = JSON.stringify(text)
37
+ .slice(1, -1)
38
+ .replaceAll('\\"', '"')
39
+ .replaceAll("'", "\\'")
40
+ .replace(/[<>\u2028\u2029]/g, (char) => UNSAFE_SOURCE_CHARS[char] ?? char);
41
+ return `'${body}'`;
42
+ }
43
+ /** Bare when the key is an identifier. */
44
+ export function keySource(key, quote = quoteSource) {
45
+ return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : quote(key);
46
+ }
47
+ /** `label` names the schema in the error. */
48
+ export function parseJsonSchema(raw, label) {
49
+ const trimmed = raw.trim();
50
+ if (!trimmed)
51
+ return { ok: false, error: `${label} JSON Schema is required.` };
52
+ try {
53
+ const parsed = JSON.parse(trimmed);
54
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
55
+ return { ok: false, error: `${label} JSON Schema must be an object.` };
56
+ }
57
+ // Read here as the saved file reads it, so a schema zod can't read is this field's issue.
58
+ try {
59
+ zodFromJsonSchema(parsed);
60
+ }
61
+ catch (err) {
62
+ return { ok: false, error: `${label} JSON Schema can't be read: ${err.message}.` };
63
+ }
64
+ return { ok: true, schema: parsed };
65
+ }
66
+ catch {
67
+ return { ok: false, error: `${label} JSON Schema is not valid JSON.` };
68
+ }
69
+ }
package/tools.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Function tools answer with the builder's sample reply, else the handler the host gives for their
3
+ * name, else a stub shaped by their output schema.
4
+ */
5
+ import type { KernelRegistry, Profile } from '@theoremjs/agents';
6
+ import type { ToolRegistry } from '@theoremjs/agents/kernel';
7
+ import type { StructuredRegistration, ToolRegistration } from './registrations.ts';
8
+ /** Answers a function tool's call, for a host that runs its own tools in the studio. */
9
+ export type StudioToolHandler = (input: Record<string, unknown>) => Record<string, unknown>;
10
+ /** The host's handlers, by tool name. */
11
+ export type StudioToolHandlers = Readonly<Record<string, StudioToolHandler>>;
12
+ /** Registers one studio tool, its schemas read as the file Save writes reads them. */
13
+ export declare function registerCustomTool(tools: ToolRegistry, tool: ToolRegistration, handlers?: StudioToolHandlers): void;
14
+ export declare function registerStudioTools(tools: ToolRegistry, customTools: readonly ToolRegistration[], handlers?: StudioToolHandlers): void;
15
+ /** Registers a draft's tools and schema, then its profile, into `registry`. */
16
+ export declare function registerDefined(registry: KernelRegistry, profile: Profile, customTools: readonly ToolRegistration[], structured: StructuredRegistration | undefined, handlers?: StudioToolHandlers): Profile;
package/tools.js ADDED
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Function tools answer with the builder's sample reply, else the handler the host gives for their
3
+ * name, else a stub shaped by their output schema.
4
+ */
5
+ import { GOOGLE_BUILTIN_TOOLS } from '@theoremjs/agents/presets/google';
6
+ import { stubOutputFromSchema } from "./stub.js";
7
+ import { zodFromJsonSchema } from "./tool-schema.js";
8
+ /** Registers one studio tool, its schemas read as the file Save writes reads them. */
9
+ export function registerCustomTool(tools, tool, handlers = {}) {
10
+ const base = {
11
+ name: tool.name,
12
+ description: tool.description,
13
+ category: tool.category,
14
+ access: tool.access,
15
+ paths: tool.paths,
16
+ loadTier: tool.loadTier,
17
+ permission: tool.permission,
18
+ ...(tool.labels ? { labels: tool.labels } : {}),
19
+ };
20
+ if (tool.type === 'agent') {
21
+ tools.register({
22
+ ...base,
23
+ type: 'agent',
24
+ profile: tool.profile,
25
+ ...(tool.maxCallsPerTurn !== undefined ? { maxCallsPerTurn: tool.maxCallsPerTurn } : {}),
26
+ });
27
+ return;
28
+ }
29
+ const shared = {
30
+ ...base,
31
+ input: zodFromJsonSchema(tool.inputSchema),
32
+ output: zodFromJsonSchema(tool.outputSchema),
33
+ };
34
+ if (tool.type === 'http') {
35
+ tools.register({
36
+ ...shared,
37
+ type: 'http',
38
+ endpoint: tool.endpoint,
39
+ method: tool.method,
40
+ headers: tool.headers,
41
+ mapping: tool.mapping,
42
+ auth: tool.auth,
43
+ });
44
+ return;
45
+ }
46
+ if (tool.type === 'mcp') {
47
+ tools.register({
48
+ ...shared,
49
+ type: 'mcp',
50
+ serverUrl: tool.serverUrl,
51
+ mcpToolName: tool.mcpToolName,
52
+ headers: tool.headers,
53
+ auth: tool.auth,
54
+ });
55
+ return;
56
+ }
57
+ if (tool.answeredBy === 'page') {
58
+ tools.register({ ...shared, type: 'function', answeredBy: 'page' });
59
+ return;
60
+ }
61
+ const handler = tool.stubResponse || !Object.hasOwn(handlers, tool.name) ? undefined : handlers[tool.name];
62
+ const stub = tool.stubResponse ?? stubOutputFromSchema(tool.outputSchema);
63
+ tools.register({
64
+ ...shared,
65
+ type: 'function',
66
+ handler: handler
67
+ ? (input) => {
68
+ try {
69
+ return Promise.resolve(handler(input));
70
+ }
71
+ catch (err) {
72
+ return Promise.reject(err instanceof Error ? err : new Error(String(err)));
73
+ }
74
+ }
75
+ : () => Promise.resolve(stub),
76
+ });
77
+ }
78
+ export function registerStudioTools(tools, customTools, handlers) {
79
+ tools.registerMany(GOOGLE_BUILTIN_TOOLS);
80
+ for (const tool of customTools)
81
+ registerCustomTool(tools, tool, handlers);
82
+ }
83
+ /** Registers a draft's tools and schema, then its profile, into `registry`. */
84
+ export function registerDefined(registry, profile, customTools, structured, handlers) {
85
+ registerStudioTools(registry.tools, customTools, handlers);
86
+ if (structured && profile.type !== 'live') {
87
+ registry.schemas.register(structured.id, structured.spec);
88
+ }
89
+ registry.profiles.register(profile);
90
+ return profile;
91
+ }
package/traces.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The kernel copies request metadata into every record, so one router `sink` hands each record
3
+ * to the run that wrote it. Recording, sampling, and scrubbing stay the profile's observability
4
+ * policy: a record the policy does not write never reaches the router.
5
+ */
6
+ import type { TraceRecord, TraceSink } from '@theoremjs/agents/observability';
7
+ export declare const STUDIO_RUN_METADATA_KEY = "studioRun";
8
+ /** A trace record on the studio's run stream (NDJSON line or Live socket message). */
9
+ export type StudioTraceLine = {
10
+ type: 'trace';
11
+ record: TraceRecord;
12
+ };
13
+ /** One run's route: pass `metadata` on its request, `close` when the run ends. */
14
+ export interface StudioTraceRoute {
15
+ metadata: Record<string, string>;
16
+ close(): void;
17
+ }
18
+ export interface StudioTraceRouter {
19
+ /** Register for `STUDIO_TRACE_DESTINATION`. */
20
+ sink: TraceSink;
21
+ /** Open a route; `onRecord` receives each record the run writes while it is open. */
22
+ route(onRecord: (record: TraceRecord) => void): StudioTraceRoute;
23
+ }
24
+ export declare function createStudioTraceRouter(): StudioTraceRouter;
package/traces.js ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The kernel copies request metadata into every record, so one router `sink` hands each record
3
+ * to the run that wrote it. Recording, sampling, and scrubbing stay the profile's observability
4
+ * policy: a record the policy does not write never reaches the router.
5
+ */
6
+ export const STUDIO_RUN_METADATA_KEY = 'studioRun';
7
+ export function createStudioTraceRouter() {
8
+ const routes = new Map();
9
+ return {
10
+ sink: {
11
+ write: (record) => {
12
+ const run = record.metadata?.[STUDIO_RUN_METADATA_KEY];
13
+ if (typeof run === 'string')
14
+ routes.get(run)?.(record);
15
+ return Promise.resolve();
16
+ },
17
+ },
18
+ route(onRecord) {
19
+ const run = globalThis.crypto.randomUUID();
20
+ routes.set(run, onRecord);
21
+ return {
22
+ metadata: { [STUDIO_RUN_METADATA_KEY]: run },
23
+ close: () => {
24
+ routes.delete(run);
25
+ },
26
+ };
27
+ },
28
+ };
29
+ }
package/transport.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Every request carries the compiled payload and the client-held `replay` state (permissions,
3
+ * paused call). That is safe only because the studio user owns the whole profile and its
4
+ * tools; product hosts keep the profile on the server (`createHttpTransport` with
5
+ * `createTheoremHandler`).
6
+ */
7
+ import { type TurnEvent } from '@theoremjs/agents';
8
+ import { type ProfileInterface } from '@theoremjs/agents/interface';
9
+ import { type ChatLineSink, type ConversationLine, type DecisionTransport, type EmbeddingTransport, type HostTransport, type HttpOptions, type MalformedEvent, type TheoremTransport, type TraceFeed, type TurnEventSink, type UnsupportedEvent } from '@theoremjs/react/client';
10
+ import { z } from 'zod';
11
+ import { type StudioRunPayload } from './run-payload.ts';
12
+ import type { StudioTraceLine } from './traces.ts';
13
+ export declare function studioInterface(payload: StudioRunPayload): ProfileInterface;
14
+ /** False for a run kept by a package whose settings this one no longer takes. */
15
+ export declare function studioRunDefines(payload: StudioRunPayload): boolean;
16
+ /** Clears every kept run this package no longer defines. */
17
+ export declare function clearStaleStudioRuns(store?: Storage | null): void;
18
+ /** The server picks the id, so a steer reaches only a run this browser started. */
19
+ export type StudioSteerLine = {
20
+ type: 'steer_inbox';
21
+ inbox: string;
22
+ };
23
+ type StudioLine = TurnEvent | ConversationLine | StudioTraceLine | StudioSteerLine;
24
+ /** A trace record's line on a run's stream, as the page reads it. */
25
+ export declare const studioTraceLine: z.ZodObject<{
26
+ type: z.ZodLiteral<"trace">;
27
+ record: z.ZodType<import("@theoremjs/agents").TraceRecord, unknown, z.core.$ZodTypeInternals<import("@theoremjs/agents").TraceRecord, unknown>>;
28
+ }, z.core.$strip>;
29
+ /** A chat's lines go to the sink; a host draft's call streams turn events alone. */
30
+ export declare function routeStudioLines(onLine: ChatLineSink, traces: TraceFeed, onSteerInbox: (inbox: string) => void): (line: StudioLine | UnsupportedEvent | MalformedEvent) => void;
31
+ /**
32
+ * A host draft's call as the chat router reads it. Its wire leaves conversation
33
+ * lines out, so one reaching the call is a fault in the studio, not a line to drop.
34
+ */
35
+ export declare function hostCallLines(onEvent: TurnEventSink): ChatLineSink;
36
+ /**
37
+ * How a studio transport reaches the server. `traces` is the feed its trace records land in:
38
+ * pass one feed to every transport of a conversation so a recompiled draft keeps the earlier
39
+ * turns' traces beside the transcript that kept them.
40
+ */
41
+ export type StudioTransportOptions = HttpOptions & {
42
+ traces?: TraceFeed;
43
+ };
44
+ export declare function createStudioEmbeddingTransport(payload: StudioRunPayload, options?: StudioTransportOptions): EmbeddingTransport;
45
+ export declare function createStudioTransport(payload: StudioRunPayload, options?: StudioTransportOptions): TheoremTransport;
46
+ /**
47
+ * A decision draft's transport: the page describes the profile itself, and every decision posts
48
+ * the draft's profile and questions beside the state, since the studio user authors both.
49
+ */
50
+ export declare function createStudioDecisionTransport(payload: StudioRunPayload, options?: StudioTransportOptions): DecisionTransport;
51
+ /**
52
+ * A host draft's transport: the page describes the tools from the draft's own schemas, and every
53
+ * call posts the draft's profile and tools beside it. The server retains operation authority;
54
+ * permission answers remain explicit request data.
55
+ */
56
+ export declare function createStudioHostTransport(payload: StudioRunPayload, options?: StudioTransportOptions): HostTransport;
57
+ export {};
package/transport.js ADDED
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Every request carries the compiled payload and the client-held `replay` state (permissions,
3
+ * paused call). That is safe only because the studio user owns the whole profile and its
4
+ * tools; product hosts keep the profile on the server (`createHttpTransport` with
5
+ * `createTheoremHandler`).
6
+ */
7
+ import { defineProfile, TheoremError, TURN_EVENT_SCHEMAS, traceRecordSchema, } from '@theoremjs/agents';
8
+ import { interfaceFromProfile } from '@theoremjs/agents/interface';
9
+ import { createToolRegistry } from '@theoremjs/agents/kernel';
10
+ import { CHAT_LINES, createTraceFeed, decisionAssets, decisionInterface, embeddingInterface, fetchConversation, fetchRewound, hostInterface, postDecision, postEmbedding, postJson, postNdjson, } from '@theoremjs/react/client';
11
+ import { z } from 'zod';
12
+ import { uncompiled } from "./compile.js";
13
+ import { clearStudioRunPayload, keptStudioRunIds, loadStudioRunPayload, } from "./run-payload.js";
14
+ import { registerStudioTools } from "./tools.js";
15
+ /**
16
+ * The agents the payload's agent names come first, so its agent tools find them. The patterns
17
+ * are left out, as `compileStudio` checks them: only the run's server compiles them.
18
+ */
19
+ function defineStudioRun(payload) {
20
+ const profiles = new Map();
21
+ const tools = createToolRegistry((id) => profiles.get(id));
22
+ for (const dependency of payload.dependencies ?? []) {
23
+ registerStudioTools(tools, dependency.customTools);
24
+ const profile = defineProfile(uncompiled(dependency.profile));
25
+ profiles.set(profile.id, profile);
26
+ }
27
+ registerStudioTools(tools, payload.customTools);
28
+ return { profile: defineProfile(uncompiled(payload.profile)), tools };
29
+ }
30
+ export function studioInterface(payload) {
31
+ const { profile, tools } = defineStudioRun(payload);
32
+ return interfaceFromProfile(profile, tools);
33
+ }
34
+ /** False for a run kept by a package whose settings this one no longer takes. */
35
+ export function studioRunDefines(payload) {
36
+ try {
37
+ defineStudioRun(payload);
38
+ return true;
39
+ }
40
+ catch (err) {
41
+ if (err instanceof TheoremError)
42
+ return false;
43
+ throw err;
44
+ }
45
+ }
46
+ /** Clears every kept run this package no longer defines. */
47
+ export function clearStaleStudioRuns(store) {
48
+ for (const id of keptStudioRunIds(store)) {
49
+ const payload = loadStudioRunPayload(id, store);
50
+ if (!payload || !studioRunDefines(payload))
51
+ clearStudioRunPayload(id, store);
52
+ }
53
+ }
54
+ /** A trace record's line on a run's stream, as the page reads it. */
55
+ export const studioTraceLine = z.object({ type: z.literal('trace'), record: traceRecordSchema });
56
+ true;
57
+ const studioSteerLine = z.object({ type: z.literal('steer_inbox'), inbox: z.string().min(1) });
58
+ true;
59
+ const studioLines = {
60
+ ...CHAT_LINES,
61
+ trace: studioTraceLine,
62
+ steer_inbox: studioSteerLine,
63
+ };
64
+ /** A host draft's call keeps no conversation and takes no steers: its stream is turn events and traces. */
65
+ const hostLines = {
66
+ ...TURN_EVENT_SCHEMAS,
67
+ trace: studioTraceLine,
68
+ };
69
+ /** A chat's lines go to the sink; a host draft's call streams turn events alone. */
70
+ export function routeStudioLines(onLine, traces, onSteerInbox) {
71
+ return (line) => {
72
+ if (line.type === 'trace')
73
+ traces.push(line.record);
74
+ else if (line.type === 'steer_inbox')
75
+ onSteerInbox(line.inbox);
76
+ else
77
+ onLine(line);
78
+ };
79
+ }
80
+ function ignoreSteerInbox() { }
81
+ /**
82
+ * A host draft's call as the chat router reads it. Its wire leaves conversation
83
+ * lines out, so one reaching the call is a fault in the studio, not a line to drop.
84
+ */
85
+ export function hostCallLines(onEvent) {
86
+ return (line) => {
87
+ if (line.type === 'conversation') {
88
+ // labels-exempt: internal diagnostic; the user reads error.internal
89
+ throw new TheoremError('internal', 'a host call streamed a conversation line');
90
+ }
91
+ onEvent(line);
92
+ };
93
+ }
94
+ export function createStudioEmbeddingTransport(payload, options = {}) {
95
+ const traces = options.traces ?? createTraceFeed();
96
+ return {
97
+ describe: () => Promise.resolve(embeddingInterface(defineProfile(payload.profile))),
98
+ embed: (input, embed, signal) => postEmbedding('/api/studio/embedding/embed', { profile: payload.profile, input, ...embed }, signal, options),
99
+ traces,
100
+ };
101
+ }
102
+ export function createStudioTransport(payload, options = {}) {
103
+ const compiled = {
104
+ profile: payload.profile,
105
+ customTools: payload.customTools,
106
+ structured: payload.structured,
107
+ dependencies: payload.dependencies,
108
+ };
109
+ const traces = options.traces ?? createTraceFeed();
110
+ /** The server's steer inbox for each turn, by the client's turn id. */
111
+ const inboxes = new Map();
112
+ return {
113
+ pageResult: (body, signal) => postJson('/api/studio/page-result', body, { ...options, signal }),
114
+ describe: () => Promise.resolve(studioInterface(payload)),
115
+ turn: async (request, onEvent, signal) => {
116
+ try {
117
+ await postNdjson('/api/studio/turn', { ...compiled, ...request }, studioLines, routeStudioLines(onEvent, traces, (inbox) => {
118
+ if (request.turnId)
119
+ inboxes.set(request.turnId, inbox);
120
+ }), { ...options, signal });
121
+ }
122
+ finally {
123
+ if (request.turnId)
124
+ inboxes.delete(request.turnId);
125
+ }
126
+ },
127
+ invoke: (request, onEvent, signal) => postNdjson('/api/studio/invoke',
128
+ // `replay` carries the paused call.
129
+ { ...compiled, ...request }, studioLines, routeStudioLines(onEvent, traces, ignoreSteerInbox), { ...options, signal }),
130
+ conversation: (request, signal) => fetchConversation('/api/studio/conversation', { ...compiled, ...request }, { ...options, signal }),
131
+ rewind: (request, signal) => fetchRewound('/api/studio/rewind', { ...compiled, ...request }, { ...options, signal }),
132
+ async steer({ turnId, id, inject }) {
133
+ const inbox = inboxes.get(turnId);
134
+ if (!inbox) {
135
+ // labels-exempt: internal diagnostic; the user reads session.turn_ended
136
+ throw new TheoremError('request', 'steer: the turn has not opened its inbox', {
137
+ copy: { key: 'session.turn_ended' },
138
+ });
139
+ }
140
+ // The server's inbox is the turn it steers, so the body is a `TheoremSteerRequest`.
141
+ await postJson('/api/studio/turn/steer', { turnId: inbox, id, inject }, options);
142
+ },
143
+ traces,
144
+ };
145
+ }
146
+ /**
147
+ * A decision draft's transport: the page describes the profile itself, and every decision posts
148
+ * the draft's profile and questions beside the state, since the studio user authors both.
149
+ */
150
+ export function createStudioDecisionTransport(payload, options = {}) {
151
+ const questions = payload.questions ?? {};
152
+ const traces = options.traces ?? createTraceFeed();
153
+ return {
154
+ describe: () => Promise.resolve(decisionInterface(defineProfile(payload.profile), questions, payload.images)),
155
+ decide: (state, signal, page) => {
156
+ const assets = decisionAssets(payload.images, page);
157
+ return postDecision('/api/studio/decide', { profile: payload.profile, questions, state, ...(assets ? { assets } : {}) }, signal, options);
158
+ },
159
+ traces,
160
+ };
161
+ }
162
+ /**
163
+ * A host draft's transport: the page describes the tools from the draft's own schemas, and every
164
+ * call posts the draft's profile and tools beside it. The server retains operation authority;
165
+ * permission answers remain explicit request data.
166
+ */
167
+ export function createStudioHostTransport(payload, options = {}) {
168
+ const compiled = {
169
+ profile: payload.profile,
170
+ customTools: payload.customTools,
171
+ dependencies: payload.dependencies,
172
+ };
173
+ const traces = options.traces ?? createTraceFeed();
174
+ let sessionPermissions = [];
175
+ return {
176
+ pageResult: (body, signal) => postJson('/api/studio/page-result', body, { ...options, signal }),
177
+ describe: () => Promise.resolve(hostInterface(defineProfile(payload.profile), (name) => payload.customTools.find((tool) => tool.name === name))),
178
+ call: (request, onEvent, signal) => postNdjson('/api/studio/call', { ...compiled, ...request, sessionPermissions }, hostLines, routeStudioLines(hostCallLines(onEvent), traces, ignoreSteerInbox), { ...options, signal }),
179
+ invoke: (request, onEvent, signal) => {
180
+ sessionPermissions = request.replay?.sessionPermissions ?? sessionPermissions;
181
+ return postNdjson('/api/studio/invoke',
182
+ // `replay` carries the paused call.
183
+ { ...compiled, ...request }, hostLines, routeStudioLines(hostCallLines(onEvent), traces, ignoreSteerInbox), { ...options, signal });
184
+ },
185
+ traces,
186
+ };
187
+ }
package/tree.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ /** Node ids are what compile issues point at, so a tree, a graph, or a form can place an issue. */
2
+ import { type ProfileGraphFacetId } from '@theoremjs/agents/schema';
3
+ import { type StudioDraft } from './draft.ts';
4
+ export declare function modelBindingNodeId(key: string): string;
5
+ export declare function toolSpecNodeId(key: string): string;
6
+ /** The inverse of `toolSpecNodeId`; `undefined` for any other id. */
7
+ export declare function toolSpecKeyOf(id: string): string | undefined;
8
+ /** The node a provider's own settings open at. */
9
+ export declare function providerNodeId(id: string): string;
10
+ /** The inverse of `providerNodeId`; `undefined` for any other id. */
11
+ export declare function providerIdOf(id: string): string | undefined;
12
+ export type StudioNodeRef = {
13
+ facet: 'modelBinding';
14
+ key: string;
15
+ } | {
16
+ facet: 'toolSpec';
17
+ key: string;
18
+ } | {
19
+ facet: Exclude<ProfileGraphFacetId, 'modelBinding' | 'toolSpec'>;
20
+ };
21
+ export interface StudioTreeNode {
22
+ id: string;
23
+ ref: StudioNodeRef;
24
+ label: string;
25
+ children: StudioTreeNode[];
26
+ }
27
+ /** `undefined` when the id names nothing. */
28
+ export declare function studioNodeRef(draft: StudioDraft, id: string): StudioNodeRef | undefined;
29
+ /** One leaf per tool, as the Tools facet lists them. */
30
+ export declare function toolSpecNodes(toolSpecs: StudioDraft['toolSpecs']): StudioTreeNode[];
31
+ /** The root is labelled with the profile id; its children are the compiled facets in `PROFILE_GRAPH` order. */
32
+ export declare function studioTree(draft: StudioDraft): StudioTreeNode;
package/tree.js ADDED
@@ -0,0 +1,83 @@
1
+ /** Node ids are what compile issues point at, so a tree, a graph, or a form can place an issue. */
2
+ import { PROFILE_GRAPH } from '@theoremjs/agents/schema';
3
+ import { draftFacets } from "./draft.js";
4
+ export function modelBindingNodeId(key) {
5
+ return `modelBinding:${key}`;
6
+ }
7
+ const TOOL_SPEC_PREFIX = 'toolSpec:';
8
+ export function toolSpecNodeId(key) {
9
+ return `${TOOL_SPEC_PREFIX}${key}`;
10
+ }
11
+ /** The inverse of `toolSpecNodeId`; `undefined` for any other id. */
12
+ export function toolSpecKeyOf(id) {
13
+ return id.startsWith(TOOL_SPEC_PREFIX) ? id.slice(TOOL_SPEC_PREFIX.length) : undefined;
14
+ }
15
+ const PROVIDER_PREFIX = 'provider:';
16
+ /** The node a provider's own settings open at. */
17
+ export function providerNodeId(id) {
18
+ return `${PROVIDER_PREFIX}${id}`;
19
+ }
20
+ /** The inverse of `providerNodeId`; `undefined` for any other id. */
21
+ export function providerIdOf(id) {
22
+ return id.startsWith(PROVIDER_PREFIX) ? id.slice(PROVIDER_PREFIX.length) : undefined;
23
+ }
24
+ const FACET_LABEL = new Map(PROFILE_GRAPH.map((facet) => [facet.id, facet.label]));
25
+ function facetLabel(id) {
26
+ return FACET_LABEL.get(id) ?? id;
27
+ }
28
+ /** `undefined` when the id names nothing. */
29
+ export function studioNodeRef(draft, id) {
30
+ const [facet, key] = id.split(':', 2);
31
+ if (facet === 'modelBinding' && key !== undefined) {
32
+ return draft.modelBindings.some((binding) => binding.key === key) ? { facet, key } : undefined;
33
+ }
34
+ const tool = toolSpecKeyOf(id);
35
+ if (tool !== undefined) {
36
+ return draft.toolSpecs.some((spec) => spec.key === tool)
37
+ ? { facet: 'toolSpec', key: tool }
38
+ : undefined;
39
+ }
40
+ const facets = draftFacets(draft);
41
+ if (key !== undefined || !facets.includes(id))
42
+ return undefined;
43
+ return { facet: id };
44
+ }
45
+ function branchNodes(draft, facet) {
46
+ if (facet === 'models') {
47
+ return draft.modelBindings.map((binding) => ({
48
+ id: modelBindingNodeId(binding.key),
49
+ ref: { facet: 'modelBinding', key: binding.key },
50
+ label: binding.modelId.trim() || facetLabel('modelBinding'),
51
+ children: [],
52
+ }));
53
+ }
54
+ if (facet === 'tools')
55
+ return toolSpecNodes(draft.toolSpecs);
56
+ return [];
57
+ }
58
+ /** One leaf per tool, as the Tools facet lists them. */
59
+ export function toolSpecNodes(toolSpecs) {
60
+ return toolSpecs.map((tool) => ({
61
+ id: toolSpecNodeId(tool.key),
62
+ ref: { facet: 'toolSpec', key: tool.key },
63
+ label: tool.toolName.trim() || facetLabel('toolSpec'),
64
+ children: [],
65
+ }));
66
+ }
67
+ /** The root is labelled with the profile id; its children are the compiled facets in `PROFILE_GRAPH` order. */
68
+ export function studioTree(draft) {
69
+ const children = draftFacets(draft)
70
+ .filter((facet) => facet !== 'identity')
71
+ .map((facet) => ({
72
+ id: facet,
73
+ ref: { facet: facet },
74
+ label: facetLabel(facet),
75
+ children: branchNodes(draft, facet),
76
+ }));
77
+ return {
78
+ id: 'identity',
79
+ ref: { facet: 'identity' },
80
+ label: draft.identity.agentId.trim() || facetLabel('identity'),
81
+ children,
82
+ };
83
+ }