@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,418 @@
1
+ /**
2
+ * Save for one open project: the review of what would change, the write with
3
+ * its three proofs, and the undo. It reaches the disk and the project's process
4
+ * only through the host it is given, so the rules can be run without either.
5
+ *
6
+ * @module
7
+ */
8
+ import { relative, resolve } from 'node:path';
9
+ import { sourceOrigins } from "./origins.js";
10
+ import { projectOf, providerNamed, readProjectSource, sharedSettings, walkProject, writtenType, } from "./project-source.js";
11
+ import { projectDiffers, projectNames, saveSubjects } from "./save.js";
12
+ import { planNew } from "./save-new.js";
13
+ import { applyEdits, diffHunks, planSave } from "./save-plan.js";
14
+ import { planRemoved } from "./save-remove.js";
15
+ const other = (side) => (side === 'before' ? 'after' : 'before');
16
+ /** Why nothing was done, with what to show for it. */
17
+ export const refusal = (reason, detail = []) => ({
18
+ ok: false,
19
+ reason,
20
+ detail,
21
+ });
22
+ /** What a thrown value says. */
23
+ export const message = (error) => (error instanceof Error ? error.message : String(error));
24
+ /** A name for a value that changes when the value does. */
25
+ export async function stampOf(value) {
26
+ const bytes = new TextEncoder().encode(JSON.stringify(value));
27
+ const digest = new Uint8Array(await crypto.subtle.digest('SHA-256', bytes));
28
+ return [...digest].map((byte) => byte.toString(16).padStart(2, '0')).join('');
29
+ }
30
+ /** Whether a body is a Save request, or one for the edited load: a workspace with its starts. */
31
+ export function isSaveRequest(body) {
32
+ const workspace = body?.workspace;
33
+ return (Array.isArray(workspace?.agents) &&
34
+ Array.isArray(workspace.toolSpecs) &&
35
+ typeof workspace.starts?.agents === 'object' &&
36
+ typeof workspace.starts.tools === 'object');
37
+ }
38
+ /**
39
+ * What Save answers a request with, as a status and a body: the review or the write at `base`, and
40
+ * the undo at `base/undo`. Undefined when the request is not Save's.
41
+ */
42
+ export async function answerSave(session, base, request) {
43
+ if (request.method !== 'POST')
44
+ return undefined;
45
+ const path = new URL(request.url).pathname;
46
+ if (path === `${base}/undo`)
47
+ return { status: 200, body: await session.undo() };
48
+ if (path !== base)
49
+ return undefined;
50
+ const body = await request.json().catch(() => null);
51
+ return isSaveRequest(body)
52
+ ? { status: 200, body: await session.save(body) }
53
+ : { status: 400, body: {} };
54
+ }
55
+ /** Each profile and tool the files define that the project did not register, in the files' order. */
56
+ function unregisteredIn(source, names, inRoot) {
57
+ const idle = (kind, defined, registered) => [...defined].flatMap(([name, [at]]) => {
58
+ if (!at || registered.includes(name))
59
+ return [];
60
+ const { line } = at.source.getLineAndCharacterOfPosition(at.options.getStart(at.source));
61
+ return [{ kind, name, file: inRoot(at.file), line: line + 1 }];
62
+ });
63
+ return [
64
+ ...idle('profile', source.profiles, names.profiles),
65
+ ...idle('tool', source.tools, names.tools),
66
+ ];
67
+ }
68
+ /** Where the files define each provider the project registered: one written once, in the files' order. */
69
+ function providerPlaces(source, names, inRoot) {
70
+ return [...source.providers].flatMap(([id, targets]) => {
71
+ const [at] = targets;
72
+ if (!at || targets.length > 1 || !names.providers.includes(id))
73
+ return [];
74
+ const named = providerNamed(source, id);
75
+ const { line } = at.source.getLineAndCharacterOfPosition(at.options.getStart(at.source));
76
+ return [
77
+ {
78
+ id,
79
+ ...(named ? { name: named.name } : {}),
80
+ ...(named?.exported ? { exported: true } : {}),
81
+ file: inRoot(at.file),
82
+ line: line + 1,
83
+ },
84
+ ];
85
+ });
86
+ }
87
+ /**
88
+ * A project's origins as the page reads them: each file from the project's folder, and each
89
+ * profile and tool the project registers that no file defines marked as one the studio cannot find.
90
+ */
91
+ export function pageOrigins(found, names, source, inRoot) {
92
+ const read = (origins, registered, defined) => {
93
+ const placed = Object.entries(origins).map(([name, held]) => [
94
+ name,
95
+ held.map((origin) => (origin.file ? { ...origin, file: inRoot(origin.file) } : origin)),
96
+ ]);
97
+ const unfound = registered
98
+ .filter((name) => !defined.has(name))
99
+ .map((name) => [name, [{ path: [], kind: 'unfound' }]]);
100
+ return Object.fromEntries([...placed, ...unfound]);
101
+ };
102
+ const placed = (sites) => Object.fromEntries(Object.entries(sites).map(([name, held]) => [
103
+ name,
104
+ held.map((site) => ({
105
+ ...site,
106
+ file: inRoot(site.file),
107
+ ...(site.readBy
108
+ ? { readBy: site.readBy.map((each) => ({ ...each, file: inRoot(each.file) })) }
109
+ : {}),
110
+ })),
111
+ ]));
112
+ return {
113
+ profiles: read(found.profiles, names.profiles, source.profiles),
114
+ tools: read(found.tools, names.tools, source.tools),
115
+ providers: read(found.providers, names.providers, source.providers),
116
+ ...(found.sites
117
+ ? { sites: { profiles: placed(found.sites.profiles), tools: placed(found.sites.tools) } }
118
+ : {}),
119
+ };
120
+ }
121
+ /** How long the walk runs before it pauses to let what it said go out. */
122
+ const PAUSE_EVERY_MS = 12;
123
+ /** Starts Save for a project that `first` loaded. */
124
+ export function createSaveSession(host, first) {
125
+ const { root } = host;
126
+ const inRoot = (file) => relative(root, file);
127
+ let project = first;
128
+ /** The last Save's files, until another Save or an undo. */
129
+ let lastSave;
130
+ const source = () => readProjectSource(host.setupFile, root, host.read);
131
+ /** The text of every file the setup reads, which changes when the builder's editor writes one. */
132
+ const heldIn = (read) => JSON.stringify([...read.files].map(([file, each]) => [file, each.text]));
133
+ const held = () => heldIn(source());
134
+ /** What the files held when the load that answers started. */
135
+ let loadedFrom = held();
136
+ /** The files that did not load, and what the project printed. */
137
+ let unloaded;
138
+ /** What the builder changed, or why it cannot be read. */
139
+ const subjectsOf = (workspace) => {
140
+ try {
141
+ return saveSubjects(workspace, projectNames(host.opened(project)));
142
+ }
143
+ catch (error) {
144
+ return { ok: false, issues: [message(error)] };
145
+ }
146
+ };
147
+ /** The review of a workspace's changes, with the files they would write. */
148
+ const review = async (workspace) => {
149
+ const subjects = subjectsOf(workspace);
150
+ if (!subjects.ok)
151
+ return refusal('issues', subjects.issues);
152
+ const source = readProjectSource(host.setupFile, root, host.read);
153
+ const plan = planSave(source, subjects.subjects);
154
+ const added = planNew(source, subjects.added, (path) => host.read(path) !== undefined);
155
+ const files = new Map();
156
+ const view = [];
157
+ const taken = planRemoved(source, subjects.removed);
158
+ const whole = taken.gone.map((file) => ({
159
+ file,
160
+ start: 0,
161
+ end: source.files.get(file)?.text.length ?? 0,
162
+ text: '',
163
+ }));
164
+ const edits = [...plan.edits, ...added.edits, ...taken.edits].filter((edit) => !taken.gone.includes(edit.file));
165
+ for (const [file, held] of Map.groupBy([...edits, ...whole], (edit) => edit.file)) {
166
+ const opened = source.files.get(file);
167
+ const before = opened?.text ?? '';
168
+ const removed = taken.gone.includes(file);
169
+ let after;
170
+ try {
171
+ after = applyEdits(before, held);
172
+ }
173
+ catch (error) {
174
+ return refusal('unwritable', [`${inRoot(file)}: ${message(error)}`]);
175
+ }
176
+ files.set(file, { before, after, created: !opened, removed });
177
+ const marked = removed
178
+ ? { removed: true }
179
+ : opened
180
+ ? {}
181
+ : { created: true };
182
+ view.push({ file: inRoot(file), hunks: diffHunks(before, held), ...marked });
183
+ }
184
+ const changes = [...subjects.changes, ...plan.changes, ...added.changes, ...taken.changes].map((change) => (change.file ? { ...change, file: inRoot(change.file) } : change));
185
+ const writable = files.size > 0 && changes.every((change) => change.status === 'written');
186
+ return {
187
+ files,
188
+ view: { ok: true, changes, files: view, stamp: await stampOf([...files]), writable },
189
+ };
190
+ };
191
+ /** What a file holds on `side`: undefined where it is not there. */
192
+ const textOn = (change, side) => side === 'before'
193
+ ? change.created
194
+ ? undefined
195
+ : change.before
196
+ : change.removed
197
+ ? undefined
198
+ : change.after;
199
+ /** Writes a file as it was or as Save makes it. A file that is not there on that side is taken away, not emptied. */
200
+ const putFile = (file, change, side) => {
201
+ const text = textOn(change, side);
202
+ if (text === undefined)
203
+ host.remove(file);
204
+ else
205
+ host.write(file, text);
206
+ };
207
+ /**
208
+ * Writes each file to `side`. When one can't be written, the files already written, and that one,
209
+ * are put back to the other side, and the refusal says which file and why.
210
+ */
211
+ const put = (files, side) => {
212
+ const done = new Map();
213
+ for (const [file, change] of files) {
214
+ try {
215
+ putFile(file, change, side);
216
+ }
217
+ catch (error) {
218
+ const back = other(side);
219
+ const kept = putBack(done, back);
220
+ if (host.read(file) !== textOn(change, back)) {
221
+ try {
222
+ putFile(file, change, back);
223
+ }
224
+ catch {
225
+ kept.push(inRoot(file));
226
+ }
227
+ }
228
+ const refused = refusal('write', [`${inRoot(file)}: ${message(error)}`]);
229
+ return kept.length ? { ...refused, kept } : refused;
230
+ }
231
+ done.set(file, change);
232
+ }
233
+ return undefined;
234
+ };
235
+ /**
236
+ * Puts `files` back to `side`, but for a file that no longer holds what the other side wrote:
237
+ * someone changed it meanwhile, so it is left as it is now. One that can't be written is left too.
238
+ * Answers with those it left.
239
+ */
240
+ const putBack = (files, side) => {
241
+ const left = [];
242
+ for (const [file, change] of files) {
243
+ if (host.read(file) !== textOn(change, other(side))) {
244
+ left.push(inRoot(file));
245
+ continue;
246
+ }
247
+ try {
248
+ putFile(file, change, side);
249
+ }
250
+ catch {
251
+ left.push(inRoot(file));
252
+ }
253
+ }
254
+ return left;
255
+ };
256
+ /** A write taken back, with the files it left as they are now. */
257
+ const takenBack = (refused, files, side) => {
258
+ const kept = putBack(files, side);
259
+ return kept.length ? { ...refused, kept } : refused;
260
+ };
261
+ /** Loads the project from disk and answers with it from now on. */
262
+ const reload = async (keep, from = held()) => {
263
+ let next;
264
+ try {
265
+ next = await host.load();
266
+ }
267
+ catch (error) {
268
+ return refusal('load', [message(error)]);
269
+ }
270
+ const differs = keep(next);
271
+ if (differs.length) {
272
+ await host.stop(next);
273
+ return refusal('differs', differs);
274
+ }
275
+ const old = project;
276
+ project = next;
277
+ loadedFrom = from;
278
+ unloaded = undefined;
279
+ await host.stop(old);
280
+ return undefined;
281
+ };
282
+ /** Loads the project again when `files` are not the ones the load that answers was read from. Whether it did. */
283
+ const refresh = async (files, said) => {
284
+ const now = heldIn(files);
285
+ if (now === loadedFrom)
286
+ unloaded = undefined;
287
+ // Files that did not load are not tried again until they change.
288
+ else if (unloaded?.from !== now) {
289
+ said?.({ again: true });
290
+ const refused = await reload(() => [], now);
291
+ if (refused)
292
+ unloaded = { from: now, printed: refused.detail.join('\n') };
293
+ return true;
294
+ }
295
+ return false;
296
+ };
297
+ /** The same walk as `source`, pausing so each step said reaches the page while the walk goes on. */
298
+ const sourceSaying = async (said) => {
299
+ const walk = walkProject(host.setupFile, root, host.read);
300
+ let paused = performance.now();
301
+ let step = walk.next();
302
+ while (!step.done) {
303
+ const { file, from } = step.value;
304
+ said({ file: inRoot(file), ...(from === undefined ? {} : { from: inRoot(from) }) });
305
+ if (performance.now() - paused > PAUSE_EVERY_MS) {
306
+ await new Promise((resume) => setTimeout(resume, 0));
307
+ paused = performance.now();
308
+ }
309
+ step = walk.next();
310
+ }
311
+ const files = projectOf(step.value, host.setupFile, root);
312
+ for (const [found, made] of [
313
+ ['profile', files.profiles],
314
+ ['tool', files.tools],
315
+ ]) {
316
+ for (const [name, targets] of made) {
317
+ const at = targets[0];
318
+ if (!at)
319
+ continue;
320
+ const type = writtenType(files, at);
321
+ said({ found, name, file: inRoot(at.file), ...(type === undefined ? {} : { type }) });
322
+ }
323
+ }
324
+ return files;
325
+ };
326
+ const read = async (said) => {
327
+ const first = said ? await sourceSaying(said) : source();
328
+ // A load takes time, so the files are read again after one: the answer is what they say now.
329
+ const loaded = await refresh(first, said);
330
+ const files = loaded ? source() : first;
331
+ const opened = host.opened(project);
332
+ const decisions = opened.agents
333
+ .filter((agent) => agent.identity.profileType === 'decision')
334
+ .map((agent) => agent.identity.agentId);
335
+ return {
336
+ shared: sharedSettings(files).map((setting) => ({ ...setting, file: inRoot(setting.file) })),
337
+ origins: pageOrigins(sourceOrigins(files, decisions), projectNames(opened), files, inRoot),
338
+ unregistered: unregisteredIn(files, projectNames(opened), inRoot),
339
+ providerPlaces: providerPlaces(files, projectNames(opened), inRoot),
340
+ ...(unloaded === undefined ? {} : { unloaded: unloaded.printed }),
341
+ };
342
+ };
343
+ /** Proves the files as written: the project type-checks, loads, and is what was tested. */
344
+ const proven = async (tested) => {
345
+ const check = await host.typeChecks().catch((error) => ({ ok: false, output: message(error) }));
346
+ if (!check.ok)
347
+ return refusal('check', [check.output]);
348
+ return reload((next) => projectDiffers(host.opened(next), tested));
349
+ };
350
+ const write = async (files, view, request) => {
351
+ if (view.stamp !== request.stamp)
352
+ return refusal('stale');
353
+ if (!view.writable)
354
+ return refusal('unwritable');
355
+ const astray = [...files.keys()].filter((file) => !host.landsInside(file));
356
+ if (astray.length)
357
+ return refusal('unwritable', astray.map(inRoot));
358
+ const failed = put(files, 'after');
359
+ if (failed)
360
+ return failed;
361
+ const refused = await proven(request.workspace);
362
+ if (refused)
363
+ return takenBack(refused, files, 'before');
364
+ lastSave = files;
365
+ return { ok: true, written: [...files.keys()].map(inRoot) };
366
+ };
367
+ const save = async (request) => {
368
+ const reviewed = await review(request.workspace);
369
+ if ('reason' in reviewed)
370
+ return reviewed;
371
+ return request.stamp === undefined
372
+ ? reviewed.view
373
+ : write(reviewed.files, reviewed.view, request);
374
+ };
375
+ const undo = async () => {
376
+ if (!lastSave)
377
+ return refusal('nothing');
378
+ const files = lastSave;
379
+ const moved = [...files].filter(([file, change]) => host.read(file) !== (change.removed ? undefined : change.after));
380
+ if (moved.length)
381
+ return refusal('stale', moved.map(([file]) => inRoot(file)));
382
+ const failed = put(files, 'before');
383
+ if (failed)
384
+ return failed;
385
+ const refused = await reload(() => []);
386
+ if (refused)
387
+ return takenBack(refused, files, 'after');
388
+ lastSave = undefined;
389
+ return { ok: true, written: [...files.keys()].map(inRoot) };
390
+ };
391
+ /** One write at a time: a second waits for the first. */
392
+ let writing = Promise.resolve();
393
+ const inTurn = (work) => {
394
+ const next = writing.then(work, work);
395
+ writing = next.catch(() => { });
396
+ return next;
397
+ };
398
+ return {
399
+ project: () => project,
400
+ place: (file) => {
401
+ const path = resolve(root, file);
402
+ return source().files.has(path) ? path : undefined;
403
+ },
404
+ save: (request) => inTurn(() => save(request)),
405
+ undo: () => inTurn(undo),
406
+ read: (said) => inTurn(() => read(said)),
407
+ watched: () => [...source().files.keys()],
408
+ // In turn, so a Save that is still proving its files is not taken for the builder's editor.
409
+ changed: () => inTurn(() => {
410
+ const now = held();
411
+ if (now === loadedFrom)
412
+ return Promise.resolve([]);
413
+ const [was, is] = [loadedFrom, now].map((text) => new Map(JSON.parse(text)));
414
+ const files = [...new Set([...(was?.keys() ?? []), ...(is?.keys() ?? [])])];
415
+ return Promise.resolve(files.filter((file) => was?.get(file) !== is?.get(file)).map(inRoot));
416
+ }),
417
+ };
418
+ }
@@ -0,0 +1,235 @@
1
+ /**
2
+ * What the page and the studio's server say to each other about the project's
3
+ * files: its shared settings, and Save. Types only: the page imports this
4
+ * without the server's code.
5
+ *
6
+ * @module
7
+ */
8
+ import type { StudioWorkspace } from '../workspace.ts';
9
+ /** A constant that more than one profile or tool reads: one value, set in one place. */
10
+ export interface SharedSetting {
11
+ /** The constant's name where it is declared. */
12
+ name: string;
13
+ /** The name as words: `STANDARD_GUARDRAILS` is "Standard guardrails". */
14
+ label: string;
15
+ /** Where it is declared: the path and the one-based line. */
16
+ file: string;
17
+ line: number;
18
+ /**
19
+ * The profile key it fills, when every profile reads it as the whole of that key and no tool
20
+ * reads it. The studio opens these at that key; any other is edited where a profile or tool shows it.
21
+ */
22
+ key?: string;
23
+ /** The profiles it reaches, by id, and the tools, by name. */
24
+ profiles: string[];
25
+ tools: string[];
26
+ /** Code that is not a profile or a tool reads it too. */
27
+ readByCode: boolean;
28
+ }
29
+ /**
30
+ * A profile or tool the project's files define that the project did not register when it loaded:
31
+ * one it registers only on a condition that did not hold. The studio shows what is registered, so
32
+ * it names these and does not open them.
33
+ */
34
+ export interface Unregistered {
35
+ kind: 'profile' | 'tool';
36
+ /** The profile's id, or the tool's name. */
37
+ name: string;
38
+ /** Where the files define it: the path and the one-based line. */
39
+ file: string;
40
+ line: number;
41
+ }
42
+ /**
43
+ * A setting the project's files do not write out as a plain value, so the studio shows it and
44
+ * does not change it.
45
+ * - `code`: code computes it: a call, a name the studio cannot follow, a method.
46
+ * - `constant`: a named constant holds an id (the profile's, a provider's), and code that is not a profile or a tool reads the constant too.
47
+ * - `spread`: the object spreads another into itself, so the studio writes only the keys in `written`.
48
+ * - `twice`: the files define the profile or tool more than once.
49
+ * - `unfound`: no place in the project's files defines the profile or tool.
50
+ */
51
+ export interface SettingOrigin {
52
+ /** The keys that lead to the setting: `['models', 'fast', 'apiId']`. Empty for the whole profile or tool. */
53
+ path: string[];
54
+ kind: 'code' | 'constant' | 'spread' | 'twice' | 'unfound';
55
+ /** What the file says there, on one line: `bonsaiInputs()`. */
56
+ text?: string;
57
+ /** Where it says it: the path and the one-based line. */
58
+ file?: string;
59
+ line?: number;
60
+ /** For a `spread`: the keys written after it, which the studio still writes. */
61
+ written?: string[];
62
+ }
63
+ /**
64
+ * Where the files write one setting's value. Two settings with the same `site` are one value in
65
+ * the files: a constant several profiles read, what a function they all call returns, the call a
66
+ * function makes for each of them.
67
+ */
68
+ export interface SettingSite {
69
+ /** The keys that lead to the setting. Empty for the whole profile or tool. */
70
+ path: string[];
71
+ /** The place, as a number the project gives it for this read. */
72
+ site: number;
73
+ /** Another setting has the same site. False for a value a profile sets apart inside a shared one. */
74
+ shared: boolean;
75
+ /** The constant or function that holds the place. */
76
+ name?: string;
77
+ /** Where it is: the path and the one-based line. */
78
+ file: string;
79
+ line: number;
80
+ /** Set when code that is not a profile or a tool reads the place too: each line that reads it. */
81
+ readBy?: SourcePlace[];
82
+ }
83
+ /** A line of one of the project's files. */
84
+ export interface SourcePlace {
85
+ file: string;
86
+ line: number;
87
+ }
88
+ /** Each profile's, tool's and provider's settings that are set in code, by profile id, tool name, and provider id. */
89
+ export interface ProjectOrigins {
90
+ profiles: Record<string, SettingOrigin[]>;
91
+ tools: Record<string, SettingOrigin[]>;
92
+ providers: Record<string, SettingOrigin[]>;
93
+ /** Where each value others read too is written, by profile id and tool name. Only those that hold one are listed. */
94
+ sites?: {
95
+ profiles: Record<string, SettingSite[]>;
96
+ tools: Record<string, SettingSite[]>;
97
+ };
98
+ }
99
+ /**
100
+ * Where the project's files define a provider. `name` is the constant it is defined under, when
101
+ * it has one; `exported` says another file can import that name.
102
+ */
103
+ export interface ProviderPlace {
104
+ id: string;
105
+ name?: string;
106
+ exported?: true;
107
+ /** The path and the one-based line. */
108
+ file: string;
109
+ line: number;
110
+ }
111
+ /** What the page asks to see in the builder's editor: a project file, from the project's folder. */
112
+ export interface OpenRequest {
113
+ file: string;
114
+ line?: number;
115
+ /** The editor to open it in, by a command the studio lists. Without one, the editor the studio started with. */
116
+ editor?: string;
117
+ }
118
+ /**
119
+ * Whether the builder's editor was started on the line. `byDefault` is the machine's own default
120
+ * editor, started on the file when the named one did not start; it opens at the top.
121
+ * - `file`: the project's setup does not read that file.
122
+ * - `editor`: the studio does not know how to start the editor on a line.
123
+ * - `failed`: the editor did not start.
124
+ */
125
+ export type OpenAnswer = {
126
+ ok: true;
127
+ editor: string;
128
+ byDefault?: true;
129
+ } | {
130
+ ok: false;
131
+ reason: 'file' | 'editor' | 'failed';
132
+ editor?: string;
133
+ place?: string;
134
+ };
135
+ /**
136
+ * What happens to one changed value.
137
+ * - `written`: Save rewrites it in the file.
138
+ * - `constant`: a named constant holds it, and something else that reads the constant does not make this change.
139
+ * - `code`: code computes it, or the file sets it in a way the studio cannot follow.
140
+ * - `changed`: the file no longer holds the value the studio opened.
141
+ * - `unfound`: no place in the project's files sets it.
142
+ * - `unused`: a tool the studio added that no agent allows, so it was never run.
143
+ * - `taken`: the file a new profile or tool would be written to is already there.
144
+ * - `setup`: the studio cannot tell how the project's setup registers things, so it cannot add one.
145
+ * - `owed`: a new profile holds a rule whose check is code, which the studio does not have to write.
146
+ * - `removed`: a profile or tool the studio took away, registered in a way the studio cannot follow.
147
+ */
148
+ export type SaveStatus = 'written' | 'constant' | 'code' | 'changed' | 'unfound' | 'unused' | 'taken' | 'setup' | 'owed' | 'removed';
149
+ export interface SaveChange {
150
+ kind: 'profile' | 'tool' | 'provider';
151
+ /** The profile's id, the tool's name or the provider's id, as the project has it. */
152
+ of: string;
153
+ /** The setting, as a path: `tools.allow`. Empty for the whole profile or tool. */
154
+ setting: string;
155
+ status: SaveStatus;
156
+ /** Where the value is set: the absolute path and the one-based line. */
157
+ file?: string;
158
+ line?: number;
159
+ /** The constant that holds it. */
160
+ name?: string;
161
+ /** The other profiles and tools that read the constant, by id and name. Save writes it when each makes the same change. */
162
+ sharedWith?: string[];
163
+ /** Code that is not a profile or a tool reads the constant too. */
164
+ readByCode?: boolean;
165
+ }
166
+ /** A run of changed lines in one file, with the lines around it. */
167
+ export interface DiffHunk {
168
+ /** The one-based line the removed lines start on. */
169
+ line: number;
170
+ lead: string[];
171
+ removed: string[];
172
+ added: string[];
173
+ trail: string[];
174
+ }
175
+ /** The page's workspace, and for a write the stamp of the review the builder read. */
176
+ export interface SaveRequest {
177
+ workspace: StudioWorkspace;
178
+ /** Present to write. It must match the review's, so what is written is what was read. */
179
+ stamp?: string;
180
+ }
181
+ /** One file Save changes, with its path from the project's folder. */
182
+ export interface SaveFile {
183
+ file: string;
184
+ hunks: DiffHunk[];
185
+ /** Save creates the file: its one hunk is the whole of it. */
186
+ created?: true;
187
+ /** Save takes the file away: nothing of its own is left in it. Its one hunk is the whole of it. */
188
+ removed?: true;
189
+ }
190
+ /** The review before a write: every change, where it lands, and whether Save can write them all. */
191
+ export interface SaveReview {
192
+ ok: true;
193
+ /** Each change, with `file` from the project's folder. */
194
+ changes: SaveChange[];
195
+ files: SaveFile[];
196
+ stamp: string;
197
+ /** True when there is something to write and every change can be written. */
198
+ writable: boolean;
199
+ }
200
+ /** Files written, or put back by an undo. */
201
+ export interface SaveDone {
202
+ ok: true;
203
+ written: string[];
204
+ }
205
+ /**
206
+ * The load that runs the builder's unsaved edits is up, and which edits it holds: `stamp` changes
207
+ * when they do. A refusal says why there is none: the edits have `issues`, the project did not
208
+ * `load` with them, or it loaded as something that `differs` from them. Either way, `saved` is the
209
+ * ids of the profiles the files hold: the ones the files' own load can run beside it.
210
+ */
211
+ export type EditedAnswer = ({
212
+ ok: true;
213
+ stamp: string;
214
+ } | SaveRefusal) & {
215
+ saved: string[];
216
+ };
217
+ /**
218
+ * Why nothing was written, or why a write was taken back.
219
+ * - `issues`: the workspace does not compile.
220
+ * - `stale`: the files changed after the review was read.
221
+ * - `unwritable`: a change cannot be written.
222
+ * - `write`: a file could not be written or taken away, so those already written were put back.
223
+ * - `check`: the project did not type-check with the change.
224
+ * - `load`: the project did not load with the change.
225
+ * - `differs`: the project loaded, but not as the builder tested it.
226
+ * - `nothing`: there is no Save to undo.
227
+ * - `unanswered`: the page's own: the studio's server did not answer, so what the files hold is not known.
228
+ */
229
+ export interface SaveRefusal {
230
+ ok: false;
231
+ reason: 'issues' | 'stale' | 'unwritable' | 'write' | 'check' | 'load' | 'differs' | 'nothing' | 'unanswered';
232
+ detail: string[];
233
+ /** Files a write taken back left as they are now: they changed while Save checked them. */
234
+ kept?: string[];
235
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * What the page and the studio's server say to each other about the project's
3
+ * files: its shared settings, and Save. Types only: the page imports this
4
+ * without the server's code.
5
+ *
6
+ * @module
7
+ */
8
+ export {};