@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
package/surface.js ADDED
@@ -0,0 +1,631 @@
1
+ /**
2
+ * The studio as a surface: the draft's sections as nodes an agent can look at and set, its
3
+ * key slots as secret nodes it can point at and test, and the page's own actions (a new agent,
4
+ * a try in the preview, launch, export). The page supplies a host; the runtime does the rest.
5
+ */
6
+ import { fieldMeta, profileGraphFacet } from '@theoremjs/agents/schema';
7
+ import { defineAction, secretCard, } from '@theoremjs/agents/surface';
8
+ import { z } from 'zod';
9
+ import { compileStudio } from "./compile.js";
10
+ import { createBlankDraft, defaultModelBinding, defaultToolSpec, draftFacets, excludeFacet, includableFacets, includeFacet, newModelBinding, newToolSpec, removeModelBinding, STUDIO_PROFILE_TYPES, setProfileType, updateModelBinding, } from "./draft.js";
11
+ import { createConsoleExampleDraft, createDecisionExampleDraft, createExampleDraft, createLiveExampleDraft, createNarratorExampleDraft, } from "./example.js";
12
+ import { modelBindingViolation } from "./policy.js";
13
+ import { modelRoute } from "./providers.js";
14
+ import { bindingSlots } from "./requirements.js";
15
+ import { studioNodeRef, studioTree } from "./tree.js";
16
+ const SEND_CAP_MS = 60_000;
17
+ const KEY_NODE = 'key:';
18
+ const FACET_KEY = {
19
+ identity: 'identity',
20
+ models: 'models',
21
+ tools: 'tools',
22
+ inputs: 'inputs',
23
+ outputs: 'outputs',
24
+ turnBehaviour: 'turnBehaviour',
25
+ guardrails: 'guardrails',
26
+ observability: 'observability',
27
+ image: 'image',
28
+ speech: 'speech',
29
+ live: 'live',
30
+ decision: 'decision',
31
+ labels: 'labels',
32
+ };
33
+ /** Draft keys a change touched, as the nodes an agent knows. */
34
+ const SECTION_NODE = {
35
+ modelBindings: 'models',
36
+ toolSpecs: 'tools',
37
+ included: '',
38
+ };
39
+ const BLOCKED_FIELDS = {
40
+ 'identity.profileType': 'act setType on the studio',
41
+ 'modelBinding.key': 'a model keeps its own key',
42
+ 'toolSpec.key': 'a tool keeps its own key',
43
+ 'image.references': 'pinned images are added by the person',
44
+ };
45
+ /** How a tool's settings leave the page. */
46
+ const TOOL_FORMATS = {
47
+ endpoint: 'url',
48
+ serverUrl: 'url',
49
+ authRedirectUri: 'url',
50
+ headersJson: 'headers',
51
+ };
52
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
53
+ const facetOf = (nodeId) => nodeId.split(':', 1)[0] ?? nodeId;
54
+ /** The optional sections a type brings that the old one lacked, switched on. */
55
+ function withNewSections(before, after) {
56
+ const had = new Set(includableFacets(before));
57
+ return includableFacets(after)
58
+ .filter((facet) => !had.has(facet))
59
+ .reduce(includeFacet, after);
60
+ }
61
+ /** A node's own values, which `set` can change. */
62
+ function nodeValues(draft, nodeId) {
63
+ const ref = studioNodeRef(draft, nodeId);
64
+ if (!ref)
65
+ return undefined;
66
+ if (ref.facet === 'modelBinding') {
67
+ return { ...draft.modelBindings.find((binding) => binding.key === ref.key) };
68
+ }
69
+ if (ref.facet === 'toolSpec')
70
+ return { ...draft.toolSpecs.find((tool) => tool.key === ref.key) };
71
+ return { ...draft[FACET_KEY[ref.facet] ?? 'identity'] };
72
+ }
73
+ /** Where a value may be set: its kind must match the one there; a number field may also be null. */
74
+ function kindProblem(current, blank, value) {
75
+ if (value === null)
76
+ return current === null || blank === null ? undefined : 'cannot be empty';
77
+ if (current === null || current === undefined) {
78
+ return isRecord(value) ? 'must be a single value' : undefined;
79
+ }
80
+ if (Array.isArray(current))
81
+ return Array.isArray(value) ? undefined : 'must be a list';
82
+ if (isRecord(current))
83
+ return 'is a group; set its fields one by one, like "include.usage"';
84
+ return typeof current === typeof value ? undefined : `must be ${typeof current}`;
85
+ }
86
+ function setAtPath(target, blank, path, value) {
87
+ const [head = '', ...rest] = path.split('.');
88
+ if (!Object.hasOwn(target, head))
89
+ return { why: 'no such setting' };
90
+ if (rest.length === 0) {
91
+ const problem = kindProblem(target[head], blank?.[head], value);
92
+ return problem ? { why: problem } : { next: { ...target, [head]: value } };
93
+ }
94
+ const inner = target[head];
95
+ if (!isRecord(inner))
96
+ return { why: 'no such setting' };
97
+ const innerBlank = blank?.[head];
98
+ const set = setAtPath(inner, isRecord(innerBlank) ? innerBlank : undefined, rest.join('.'), value);
99
+ return 'why' in set ? set : { next: { ...target, [head]: set.next } };
100
+ }
101
+ function editNode(draft, nodeId, changes) {
102
+ const ref = studioNodeRef(draft, nodeId);
103
+ const rejected = [];
104
+ if (!ref)
105
+ return { next: draft, rejected };
106
+ const facet = ref.facet;
107
+ let current = nodeValues(draft, nodeId) ?? {};
108
+ const blank = facet === 'modelBinding'
109
+ ? { ...defaultModelBinding() }
110
+ : facet === 'toolSpec'
111
+ ? { ...defaultToolSpec() }
112
+ : createBlankDraft()[FACET_KEY[facet] ?? 'identity'];
113
+ for (const [path, value] of Object.entries(changes)) {
114
+ const blocked = BLOCKED_FIELDS[`${facet}.${path}`];
115
+ if (blocked) {
116
+ rejected.push({ field: path, why: blocked });
117
+ continue;
118
+ }
119
+ if (facet === 'labels') {
120
+ if (!fieldMeta(`labels.${path}`))
121
+ rejected.push({ field: path, why: 'no such line' });
122
+ else if (typeof value !== 'string')
123
+ rejected.push({ field: path, why: 'must be text' });
124
+ else
125
+ current = { ...current, [path]: value };
126
+ continue;
127
+ }
128
+ const set = setAtPath(current, blank, path, value);
129
+ if ('why' in set)
130
+ rejected.push({ field: path, why: set.why });
131
+ else
132
+ current = set.next;
133
+ }
134
+ if (rejected.length === Object.keys(changes).length)
135
+ return { next: draft, rejected };
136
+ if (ref.facet === 'modelBinding') {
137
+ const { key: _key, ...rest } = current;
138
+ return { next: updateModelBinding(draft, ref.key, rest), rejected };
139
+ }
140
+ if (ref.facet === 'toolSpec') {
141
+ return {
142
+ next: {
143
+ ...draft,
144
+ toolSpecs: draft.toolSpecs.map((tool) => tool.key === ref.key ? { ...tool, ...current } : tool),
145
+ },
146
+ rejected,
147
+ };
148
+ }
149
+ return { next: { ...draft, [FACET_KEY[ref.facet] ?? 'identity']: current }, rejected };
150
+ }
151
+ function describeReply(blocks) {
152
+ const reply = [];
153
+ const media = [];
154
+ const tools = [];
155
+ const errors = [];
156
+ for (const block of blocks) {
157
+ if (block.kind === 'text')
158
+ reply.push(block.text);
159
+ else if (block.kind === 'structured')
160
+ reply.push(JSON.stringify(block.value));
161
+ else if (block.kind === 'media')
162
+ media.push({ mimeType: block.mimeType });
163
+ else if (block.kind === 'tool')
164
+ tools.push({ name: block.tool.name, state: block.tool.state?.phase });
165
+ else if (block.kind === 'error')
166
+ errors.push(block.message);
167
+ }
168
+ return { reply: reply.join('\n'), media, tools, errors };
169
+ }
170
+ /** Each key slot the draft uses, and what uses it. */
171
+ /** `binding` as the run policy reads it: its protocol, its provider's definition, and whether the agent decides. */
172
+ function routed(draft, binding) {
173
+ return {
174
+ ...modelRoute(draft.providers, draft.identity.profileType, binding),
175
+ builtInTools: binding.builtInTools,
176
+ };
177
+ }
178
+ function keySlots(draft) {
179
+ const slots = new Map();
180
+ const use = (slot, by) => {
181
+ if (!slot)
182
+ return;
183
+ slots.set(slot, [...(slots.get(slot) ?? []), by]);
184
+ };
185
+ use(draft.models.key, 'every model, by default');
186
+ use(draft.models.fallbackKey, 'every model, as fallback');
187
+ for (const binding of draft.modelBindings) {
188
+ const name = binding.modelId || 'a model';
189
+ use(binding.keySlot, `model ${name}`);
190
+ use(binding.fallbackKeySlot, `model ${name}, as fallback`);
191
+ const { keySlot, fallbackKeySlot, given } = bindingSlots(draft, binding);
192
+ if (given.keySlot)
193
+ use(keySlot, `model ${name}, from its provider`);
194
+ if (given.fallbackKeySlot)
195
+ use(fallbackKeySlot, `model ${name}, from its provider as fallback`);
196
+ }
197
+ for (const tool of draft.toolSpecs)
198
+ use(tool.authSlot, `tool ${tool.toolName || 'unnamed'}`);
199
+ return slots;
200
+ }
201
+ const typeInput = z.enum(STUDIO_PROFILE_TYPES);
202
+ /** The worked examples one draft holds. The code architect is two agents, so the page loads it. */
203
+ const EXAMPLE_DRAFTS = {
204
+ travel: createExampleDraft,
205
+ live: createLiveExampleDraft,
206
+ narrator: createNarratorExampleDraft,
207
+ console: createConsoleExampleDraft,
208
+ decision: createDecisionExampleDraft,
209
+ };
210
+ const exampleInput = z.enum(Object.keys(EXAMPLE_DRAFTS));
211
+ /** The studio's surface, over a host the page (or a test) provides. */
212
+ export function studioSurface(host) {
213
+ const draft = () => host.getDraft();
214
+ /** The lent keys the page runs on, if any. */
215
+ const lent = () => {
216
+ const on = host.getRunsOn();
217
+ return on.mode === 'demo' ? on.keys : undefined;
218
+ };
219
+ const revision = () => host.getRevision();
220
+ const compileIssues = () => {
221
+ const compiled = compileStudio(draft(), host.getRunsOn());
222
+ return compiled.ok ? [] : compiled.issues;
223
+ };
224
+ const keyIssues = () => [...keySlots(draft())].flatMap(([slot]) => {
225
+ const card = secretCard(host.key(slot));
226
+ if (!card.set) {
227
+ return [{ node: `${KEY_NODE}${slot}`, field: 'value', message: `No key in ${slot}` }];
228
+ }
229
+ return card.problems.length
230
+ ? [
231
+ {
232
+ node: `${KEY_NODE}${slot}`,
233
+ field: 'value',
234
+ message: `The key has ${card.problems.join(', ')}`,
235
+ },
236
+ ]
237
+ : [];
238
+ });
239
+ const issues = () => [
240
+ ...compileIssues().map(({ nodeId, field, message }) => ({
241
+ node: nodeId,
242
+ ...(field ? { field } : {}),
243
+ message,
244
+ })),
245
+ ...keyIssues(),
246
+ ];
247
+ /**
248
+ * Selects a node so the person sees what the agent changed. Returns why the change is not made
249
+ * yet, when the person has to agree to it first.
250
+ */
251
+ const apply = (next, nodeId) => {
252
+ const waits = next !== draft() ? host.update(next) : undefined;
253
+ if (nodeId && studioNodeRef(draft(), nodeId))
254
+ host.select(nodeId);
255
+ return waits;
256
+ };
257
+ const refuse = (field, why) => ({
258
+ rejected: [{ field, why }],
259
+ });
260
+ const blocked = () => {
261
+ const found = compileIssues();
262
+ return found.length
263
+ ? {
264
+ result: {
265
+ ok: false,
266
+ why: `${String(found.length)} issues to fix first; look at the studio`,
267
+ },
268
+ }
269
+ : undefined;
270
+ };
271
+ const rootActions = {
272
+ newAgent: defineAction({
273
+ description: 'Start a new agent, replacing the draft (the person can undo). Ask first if they changed the current one.',
274
+ effect: 'write',
275
+ intent: true,
276
+ input: z.object({
277
+ type: typeInput.describe('The agent type'),
278
+ example: exampleInput.optional().describe('Start from a worked example'),
279
+ }),
280
+ run: async ({ type, example }) => {
281
+ const blank = createBlankDraft();
282
+ const next = example
283
+ ? await EXAMPLE_DRAFTS[example]()
284
+ : withNewSections(blank, setProfileType(blank, type, lent()));
285
+ host.replaceDraft(next, 'th30 started a new agent.');
286
+ return { node: 'identity' };
287
+ },
288
+ }),
289
+ setType: defineAction({
290
+ description: "Change the agent's type; sections the new type adds are turned on.",
291
+ effect: 'write',
292
+ input: z.object({ type: typeInput }),
293
+ run: ({ type }) => {
294
+ const before = draft();
295
+ apply(withNewSections(before, setProfileType(before, type, lent())), 'identity');
296
+ return { node: 'identity' };
297
+ },
298
+ }),
299
+ include: defineAction({
300
+ description: 'Turn on an optional section.',
301
+ effect: 'write',
302
+ input: z.object({ section: z.string() }),
303
+ run: ({ section }) => {
304
+ const can = includableFacets(draft());
305
+ if (!profileGraphFacet(section) || !can.includes(section)) {
306
+ return refuse('section', `can add: ${can.join(', ') || 'nothing for this type'}`);
307
+ }
308
+ apply(includeFacet(draft(), section), section);
309
+ return { node: section };
310
+ },
311
+ }),
312
+ exclude: defineAction({
313
+ description: 'Turn off an optional section.',
314
+ effect: 'write',
315
+ input: z.object({ section: z.string() }),
316
+ run: ({ section }) => {
317
+ const has = draft().included;
318
+ if (!has.includes(section))
319
+ return refuse('section', `can remove: ${has.join(', ') || 'nothing'}`);
320
+ apply(excludeFacet(draft(), section));
321
+ return {};
322
+ },
323
+ }),
324
+ addModel: defineAction({
325
+ description: 'Add a model; the first becomes the default.',
326
+ effect: 'write',
327
+ input: z.object({
328
+ modelId: z.string().optional().describe('Your name for it'),
329
+ provider: z.string().optional(),
330
+ apiId: z.string().optional().describe("The provider's model id"),
331
+ }),
332
+ run: (input) => {
333
+ const current = draft();
334
+ if (!current.identity.profileType)
335
+ return refuse('type', 'act setType first');
336
+ const binding = {
337
+ ...newModelBinding(current, lent()?.start),
338
+ ...Object.fromEntries(Object.entries(input).filter(([, value]) => value)),
339
+ };
340
+ const node = `modelBinding:${binding.key}`;
341
+ apply({
342
+ ...current,
343
+ models: {
344
+ ...current.models,
345
+ defaultModel: current.models.defaultModel || binding.modelId,
346
+ },
347
+ modelBindings: [...current.modelBindings, binding],
348
+ }, node);
349
+ const violation = modelBindingViolation(routed(draft(), binding), host.getRunsOn());
350
+ return {
351
+ node,
352
+ rejected: violation ? [{ field: violation.field, why: violation.message }] : [],
353
+ };
354
+ },
355
+ }),
356
+ addTool: defineAction({
357
+ description: 'Add a custom tool.',
358
+ effect: 'write',
359
+ input: z.object({ toolName: z.string().optional(), description: z.string().optional() }),
360
+ run: ({ toolName, description }) => {
361
+ const current = draft();
362
+ if (!current.identity.profileType)
363
+ return refuse('type', 'act setType first');
364
+ if (!draftFacets(current).includes('tools')) {
365
+ return refuse('tools', 'this agent type takes no tools');
366
+ }
367
+ const spec = {
368
+ ...newToolSpec(current),
369
+ ...(toolName ? { toolName } : {}),
370
+ ...(description ? { description } : {}),
371
+ };
372
+ const node = `toolSpec:${spec.key}`;
373
+ apply({ ...current, toolSpecs: [...current.toolSpecs, spec] }, node);
374
+ return { node };
375
+ },
376
+ }),
377
+ try: defineAction({
378
+ description: "Send a message to the agent in the preview and read its reply. It runs on the person's keys.",
379
+ effect: 'run',
380
+ input: z.object({ message: z.string().min(1) }),
381
+ run: async ({ message }) => {
382
+ const stop = blocked();
383
+ if (stop)
384
+ return stop;
385
+ let timer;
386
+ const timeout = new Promise((resolve) => {
387
+ timer = setTimeout(() => resolve('timeout'), SEND_CAP_MS);
388
+ });
389
+ const result = await Promise.race([host.send(message), timeout]);
390
+ clearTimeout(timer);
391
+ if (result === 'timeout') {
392
+ return {
393
+ result: { sent: true, note: 'Still running; the reply will show in the preview.' },
394
+ };
395
+ }
396
+ if (!result) {
397
+ return {
398
+ result: {
399
+ sent: false,
400
+ why: 'The preview cannot take a message: it is busy, or a key is missing. Look at the key nodes.',
401
+ },
402
+ };
403
+ }
404
+ return { result: { sent: true, ...describeReply(result.blocks) } };
405
+ },
406
+ }),
407
+ newConversation: defineAction({
408
+ description: 'Clear the preview conversation.',
409
+ effect: 'run',
410
+ run: () => {
411
+ host.newConversation();
412
+ return { result: { cleared: true } };
413
+ },
414
+ }),
415
+ launch: defineAction({
416
+ description: 'Open the agent on its own page in a new tab.',
417
+ effect: 'run',
418
+ run: () => {
419
+ const stop = blocked();
420
+ if (stop)
421
+ return stop;
422
+ host.launch();
423
+ return { result: { launched: true } };
424
+ },
425
+ }),
426
+ export: defineAction({
427
+ description: 'Download every agent as a .zip of source files, copy the files, or copy them with a brief for an LLM.',
428
+ effect: 'run',
429
+ input: z.object({ format: z.enum(['zip', 'copy', 'llm']) }),
430
+ run: async ({ format }) => {
431
+ const stop = blocked();
432
+ if (stop)
433
+ return stop;
434
+ return { result: { done: await host.exportAgent(format), format } };
435
+ },
436
+ }),
437
+ };
438
+ /** A tool that sends a credential gets the one typed into its test, as a secret. */
439
+ const credentialField = (nodeId) => {
440
+ const ref = studioNodeRef(draft(), nodeId);
441
+ if (ref?.facet !== 'toolSpec' || !host.toolCredential)
442
+ return {};
443
+ const tool = draft().toolSpecs.find((candidate) => candidate.key === ref.key);
444
+ if (!tool || (tool.authType ?? 'none') === 'none')
445
+ return {};
446
+ return {
447
+ credential: {
448
+ value: host.toolCredential(ref.key),
449
+ format: 'secret',
450
+ doc: "The credential the person typed into this tool's test. Used for tests only, never saved.",
451
+ usedBy: [`tool ${tool.toolName || 'unnamed'}, when tested`],
452
+ },
453
+ };
454
+ };
455
+ const sectionFields = (nodeId) => {
456
+ const values = nodeValues(draft(), nodeId) ?? {};
457
+ const facet = facetOf(nodeId);
458
+ const fields = Object.fromEntries(Object.entries(values).map(([name, value]) => {
459
+ const meta = fieldMeta(facet === 'labels' ? `labels.${name}` : `${facet}.${name}`);
460
+ const why = BLOCKED_FIELDS[`${facet}.${name}`];
461
+ const format = facet === 'toolSpec' ? TOOL_FORMATS[name] : undefined;
462
+ return [
463
+ name,
464
+ {
465
+ value,
466
+ ...(meta ? { type: meta.type, doc: meta.doc } : {}),
467
+ ...(meta?.options ? { options: meta.options } : {}),
468
+ ...(format ? { format } : {}),
469
+ ...(why ? { readOnly: why } : {}),
470
+ },
471
+ ];
472
+ }));
473
+ return { ...fields, ...credentialField(nodeId) };
474
+ };
475
+ const sectionNode = (tree, parent) => {
476
+ const id = tree.id;
477
+ const facet = facetOf(id);
478
+ const own = {};
479
+ if (facet === 'modelBinding') {
480
+ own.remove = defineAction({
481
+ description: 'Remove this model.',
482
+ effect: 'write',
483
+ run: () => {
484
+ const ref = studioNodeRef(draft(), id);
485
+ if (ref?.facet !== 'modelBinding')
486
+ return refuse('at', 'gone already');
487
+ apply(removeModelBinding(draft(), ref.key), 'models');
488
+ return { node: 'models' };
489
+ },
490
+ });
491
+ }
492
+ if (facet === 'toolSpec') {
493
+ const key = id.slice('toolSpec:'.length);
494
+ own.remove = defineAction({
495
+ description: 'Remove this tool.',
496
+ effect: 'write',
497
+ run: () => {
498
+ const waits = apply({
499
+ ...draft(),
500
+ toolSpecs: draft().toolSpecs.filter((tool) => tool.key !== key),
501
+ });
502
+ return waits ? refuse('at', waits) : { node: 'tools' };
503
+ },
504
+ });
505
+ const testTool = host.testTool;
506
+ if (testTool) {
507
+ own.test = defineAction({
508
+ description: 'Call this tool once for real, with sample input (or yours), and see what came back: status, errors, the reply.',
509
+ effect: 'run',
510
+ input: z.object({ input: z.record(z.string(), z.unknown()).optional() }),
511
+ run: async ({ input }) => ({ result: await testTool(key, input) }),
512
+ });
513
+ }
514
+ }
515
+ return {
516
+ id,
517
+ title: tree.label,
518
+ parent,
519
+ fields: () => sectionFields(id),
520
+ set: (changes) => {
521
+ const before = draft();
522
+ if (!studioNodeRef(before, id))
523
+ return { rejected: [{ field: 'at', why: 'gone' }] };
524
+ const { next, rejected } = editNode(before, id, changes);
525
+ const waits = apply(next, id);
526
+ if (waits) {
527
+ const refused = new Set(rejected.map(({ field }) => field));
528
+ const held = Object.keys(changes).filter((field) => !refused.has(field));
529
+ return { rejected: [...rejected, ...held.map((field) => ({ field, why: waits }))] };
530
+ }
531
+ if (facet === 'modelBinding') {
532
+ const binding = draft().modelBindings.find((candidate) => id === `modelBinding:${candidate.key}`);
533
+ const violation = binding
534
+ ? modelBindingViolation(routed(draft(), binding), host.getRunsOn())
535
+ : null;
536
+ if (violation)
537
+ rejected.push({ field: violation.field, why: violation.message });
538
+ }
539
+ return { rejected };
540
+ },
541
+ point: (field) => host.select(id, field),
542
+ ...(Object.keys(own).length ? { actions: own } : {}),
543
+ };
544
+ };
545
+ const keyNode = (slot, usedBy) => {
546
+ const testKey = host.testKey;
547
+ return {
548
+ id: `${KEY_NODE}${slot}`,
549
+ title: `Key ${slot}`,
550
+ parent: 'models',
551
+ summary: `Used by ${usedBy.join('; ')}`,
552
+ fields: () => ({
553
+ value: {
554
+ value: host.key(slot),
555
+ format: 'secret',
556
+ doc: 'An API key the person pastes into the Keys panel. Kept only in this tab.',
557
+ usedBy,
558
+ },
559
+ }),
560
+ point: () => host.openKeys(slot),
561
+ ...(testKey
562
+ ? {
563
+ actions: {
564
+ test: defineAction({
565
+ description: "Ask the key's provider whether it accepts the key.",
566
+ effect: 'run',
567
+ run: async () => ({ result: await testKey(slot) }),
568
+ }),
569
+ },
570
+ }
571
+ : {}),
572
+ };
573
+ };
574
+ const nodes = () => {
575
+ const current = draft();
576
+ const tree = studioTree(current);
577
+ const found = [
578
+ {
579
+ id: '',
580
+ title: 'Studio',
581
+ summary: 'The agent the person is building, its sections, keys, and preview.',
582
+ fields: () => ({
583
+ type: {
584
+ value: draft().identity.profileType || null,
585
+ options: STUDIO_PROFILE_TYPES,
586
+ readOnly: 'act setType',
587
+ },
588
+ canAdd: { value: includableFacets(draft()), readOnly: 'act include' },
589
+ included: { value: draft().included, readOnly: 'act exclude' },
590
+ }),
591
+ actions: rootActions,
592
+ },
593
+ sectionNode(tree, ''),
594
+ ];
595
+ const walk = (node, parent) => {
596
+ found.push(sectionNode(node, parent));
597
+ for (const child of node.children)
598
+ walk(child, node.id);
599
+ };
600
+ for (const child of tree.children)
601
+ walk(child, '');
602
+ for (const [slot, usedBy] of keySlots(current))
603
+ found.push(keyNode(slot, usedBy));
604
+ return found;
605
+ };
606
+ return {
607
+ id: 'studio',
608
+ title: 'Studio',
609
+ revision,
610
+ summary: () => {
611
+ const current = draft();
612
+ const count = issues().length;
613
+ return `${current.identity.profileType || 'no type'} agent ${current.identity.handle || current.identity.agentId || 'unnamed'}; ${String(count)} ${count === 1 ? 'issue' : 'issues'}`;
614
+ },
615
+ nodes,
616
+ issues,
617
+ changesSince: (since) => host.changesSince(since).map((change) => ({
618
+ revision: change.revision,
619
+ by: change.by,
620
+ nodes: [...new Set(change.sections.map((section) => SECTION_NODE[section] ?? section))],
621
+ })),
622
+ subscribe: (listener) => host.subscribe(listener),
623
+ secrets: () => ({
624
+ ...Object.fromEntries([...keySlots(draft()).keys()].map((slot) => [`key ${slot}`, host.key(slot)])),
625
+ ...Object.fromEntries(draft().toolSpecs.map((tool) => [
626
+ `credential ${tool.toolName || tool.key}`,
627
+ host.toolCredential?.(tool.key) ?? '',
628
+ ])),
629
+ }),
630
+ };
631
+ }
@@ -0,0 +1,20 @@
1
+ import type { SystemPrompt } from '@theoremjs/agents/kernel';
2
+ /**
3
+ * The studio's way to write a system prompt with private sections: the
4
+ * whole prompt as text, each private section wrapped as `{private: …}`.
5
+ */
6
+ type SystemMarkup = {
7
+ ok: true;
8
+ prompt: SystemPrompt | undefined;
9
+ } | {
10
+ ok: false;
11
+ message: string;
12
+ };
13
+ /**
14
+ * A section closes at the `}` that balances its `{`, so braces inside it pair
15
+ * up as written. Its text is trimmed; the text around it is kept as written,
16
+ * apart from the ends of the whole prompt.
17
+ */
18
+ declare function parseSystemMarkup(text: string): SystemMarkup;
19
+ export type { SystemMarkup };
20
+ export { parseSystemMarkup };