@re-cinq/floor-studio 0.0.0-stage → 0.6.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 (96) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +208 -2
  3. package/dist/backend/agent-file-text.d.ts +16 -0
  4. package/dist/backend/agent-file-text.js +37 -0
  5. package/dist/backend/agent-views.d.ts +8 -0
  6. package/dist/backend/agent-views.js +28 -0
  7. package/dist/backend/collection-view.d.ts +3 -0
  8. package/dist/backend/collection-view.js +108 -0
  9. package/dist/backend/environment-usage.d.ts +5 -0
  10. package/dist/backend/environment-usage.js +19 -0
  11. package/dist/backend/fixture-files.d.ts +4 -0
  12. package/dist/backend/fixture-files.js +14 -0
  13. package/dist/backend/fixture-requests.d.ts +12 -0
  14. package/dist/backend/fixture-requests.js +25 -0
  15. package/dist/backend/guard.d.ts +14 -0
  16. package/dist/backend/guard.js +20 -0
  17. package/dist/backend/index.d.ts +2 -0
  18. package/dist/backend/index.js +3 -0
  19. package/dist/backend/present.d.ts +2 -0
  20. package/dist/backend/present.js +5 -0
  21. package/dist/backend/read-line.d.ts +11 -0
  22. package/dist/backend/read-line.js +46 -0
  23. package/dist/backend/requests.d.ts +47 -0
  24. package/dist/backend/requests.js +74 -0
  25. package/dist/backend/run-cancel-request.d.ts +6 -0
  26. package/dist/backend/run-cancel-request.js +12 -0
  27. package/dist/backend/run-files.d.ts +5 -0
  28. package/dist/backend/run-files.js +15 -0
  29. package/dist/backend/run-preview-request.d.ts +15 -0
  30. package/dist/backend/run-preview-request.js +25 -0
  31. package/dist/backend/run-read-request.d.ts +6 -0
  32. package/dist/backend/run-read-request.js +12 -0
  33. package/dist/backend/run-start-request.d.ts +6 -0
  34. package/dist/backend/run-start-request.js +35 -0
  35. package/dist/backend/skill-names.d.ts +3 -0
  36. package/dist/backend/skill-names.js +20 -0
  37. package/dist/backend/sources-on-disk.d.ts +2 -0
  38. package/dist/backend/sources-on-disk.js +9 -0
  39. package/dist/backend/start-studio.d.ts +19 -0
  40. package/dist/backend/start-studio.js +93 -0
  41. package/dist/backend/store-folder.d.ts +1 -0
  42. package/dist/backend/store-folder.js +10 -0
  43. package/dist/backend/watcher.d.ts +6 -0
  44. package/dist/backend/watcher.js +33 -0
  45. package/dist/cli.d.ts +2 -0
  46. package/dist/cli.js +15 -0
  47. package/dist/protocol.d.ts +261 -0
  48. package/dist/protocol.js +79 -0
  49. package/dist/run/agent-command.d.ts +14 -0
  50. package/dist/run/agent-command.js +33 -0
  51. package/dist/run/prepare-workspace.d.ts +2 -0
  52. package/dist/run/prepare-workspace.js +14 -0
  53. package/dist/run/render-prompt.d.ts +1 -0
  54. package/dist/run/render-prompt.js +6 -0
  55. package/dist/run/run-edge.d.ts +8 -0
  56. package/dist/run/run-edge.js +8 -0
  57. package/dist/run/run-outcome.d.ts +12 -0
  58. package/dist/run/run-outcome.js +26 -0
  59. package/dist/run/run-preview.d.ts +29 -0
  60. package/dist/run/run-preview.js +31 -0
  61. package/dist/run/run-process.d.ts +16 -0
  62. package/dist/run/run-process.js +26 -0
  63. package/dist/run/run-produces.d.ts +12 -0
  64. package/dist/run/run-produces.js +13 -0
  65. package/dist/run/run-records.d.ts +22 -0
  66. package/dist/run/run-records.js +11 -0
  67. package/dist/run/run-result.d.ts +13 -0
  68. package/dist/run/run-result.js +10 -0
  69. package/dist/run/station-fixtures.d.ts +3 -0
  70. package/dist/run/station-fixtures.js +3 -0
  71. package/dist/run/vendor.d.ts +2 -0
  72. package/dist/run/vendor.js +11 -0
  73. package/dist/run/workspace.d.ts +21 -0
  74. package/dist/run/workspace.js +27 -0
  75. package/dist/shell/arguments.d.ts +15 -0
  76. package/dist/shell/arguments.js +32 -0
  77. package/dist/shell/open-browser.d.ts +7 -0
  78. package/dist/shell/open-browser.js +17 -0
  79. package/dist/shell/page-url.d.ts +6 -0
  80. package/dist/shell/page-url.js +5 -0
  81. package/dist/shell/static-files.d.ts +7 -0
  82. package/dist/shell/static-files.js +75 -0
  83. package/dist/shell/studio-command.d.ts +20 -0
  84. package/dist/shell/studio-command.js +48 -0
  85. package/dist/view.d.ts +100 -0
  86. package/dist/view.js +2 -0
  87. package/dist/web/assets/ibm-plex-sans-latin-300-b4i7YzLG.woff2 +0 -0
  88. package/dist/web/assets/ibm-plex-sans-latin-400-CDDApCn2.woff2 +0 -0
  89. package/dist/web/assets/ibm-plex-sans-latin-500-6ng42L7E.woff2 +0 -0
  90. package/dist/web/assets/ibm-plex-sans-latin-600-CuJfVYMP.woff2 +0 -0
  91. package/dist/web/assets/ibm-plex-sans-latin-700-Bxkt5Cjx.woff2 +0 -0
  92. package/dist/web/assets/index-Bb0f0ToW.css +1 -0
  93. package/dist/web/assets/index-bPZxSQCP.js +195 -0
  94. package/dist/web/assets/jetbrains-mono-latin-wght-B9CIFXIH.woff2 +0 -0
  95. package/dist/web/index.html +26 -0
  96. package/package.json +78 -4
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 re:cinq B.V.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,209 @@
1
- # Temporary Holding Version
1
+ # @re-cinq/floor-studio
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A local studio for a collection of assembly lines. A collection is a folder with one folder per assembly line, each holding `assembly-line.yaml` and `agents/<agent>.md`. The studio reads the folder and tells every client what it holds: each assembly line with its nodes, edges and problems, each agent with its settings and prompt, and each file it refused and why. A change to a file on disk reaches every client at once.
4
+
5
+ This package is the backend, the protocol, the command that starts them, and the page that draws the assembly lines (`web/`). It is published to npm, so this starts it without a checkout:
6
+
7
+ ```
8
+ npx @re-cinq/floor-studio path/to/collection
9
+ ```
10
+
11
+ ## The four parts
12
+
13
+ | part | where | what it does |
14
+ |---|---|---|
15
+ | Backend | `src/backend`, exported as `@re-cinq/floor-studio/backend` | Headless. `startStudio({ dir, port, hostKeys, origins })` listens on `127.0.0.1` and speaks WebSocket only. It serves no page and knows nothing about a browser |
16
+ | Protocol | `src/protocol.ts`, exported as `@re-cinq/floor-studio/protocol` | Every frame as a zod schema and its type. It imports nothing from Node, so a browser bundle can take it |
17
+ | Shell | `src/cli.ts`, the command `floor-studio` | Parses the arguments, starts the backend, serves the built page from `dist/web` over plain HTTP on `127.0.0.1`, and opens the browser. A desktop app would replace only this part |
18
+ | Page | `web/`, built into `dist/web` | A Vite and React app, one client of the backend. It takes the socket and the token from its address and draws the collection |
19
+
20
+ ## Run it from the checkout
21
+
22
+ ```
23
+ npm install
24
+ npm run build
25
+ node packages/studio/dist/cli.js path/to/collection
26
+ ```
27
+
28
+ ```
29
+ floor-studio [dir] [--port <n>] [--host-key <name>]... [--no-open]
30
+ ```
31
+
32
+ | option | meaning |
33
+ |---|---|
34
+ | `dir` | The collection. Default: the current directory. A directory that does not exist is an error, exit 1 |
35
+ | `--port <n>` | The port of the backend's socket on `127.0.0.1`. Default: a free one. The page's own port is always a free one |
36
+ | `--host-key <name>` | A frontmatter key the host owns, accepted in an agent file and left out of its settings. Repeat it as often as needed. The `host_keys` of the collection's `floor-collection.yaml` count too, and are read again when that file changes |
37
+ | `--no-open` | Print the url and do not open a browser. Without it the studio waits 3 seconds and opens the default browser with `xdg-open`, `open` or `start`. It skips that when a page has connected by then, such as a tab left open from before a restart. Failing to open a browser is not an error |
38
+ | `--help` | Print the usage and exit 0. A bad argument prints the usage to standard error and exits 2 |
39
+
40
+ It prints one line, `floor-studio: <url>`. The url is the page's. What the page needs is in the fragment, which a browser does not send to a server:
41
+
42
+ ```
43
+ http://127.0.0.1:<page port>/#socket=ws%3A%2F%2F127.0.0.1%3A<socket port>&token=<token>
44
+ ```
45
+
46
+ When `dist/web` does not exist the page server answers a plain page saying the page is not built. It serves only files under `dist/web`, with `Cache-Control: no-store`. It refuses a path that leaves the folder, by `..`, by a percent-encoded `..` or by a symlink.
47
+
48
+ ## The page
49
+
50
+ `web/` holds the page: Vite, React and TypeScript, styled with plain CSS custom properties and CSS Modules in lore's look. The tokens are in `web/src/theme/theme.css`, the fonts are IBM Plex Sans and JetBrains Mono as local files, and the theme is light, dark or auto. It draws the assembly lines with [`@re-cinq/floor-graph`](../graph/README.md) and loads nothing from another host. Everything the page needs is bundled, so React, Vite and the test tools are devDependencies and the published package needs none of them at run time.
51
+
52
+ | where | what |
53
+ |---|---|
54
+ | `npm run build -w @re-cinq/floor-studio` | `tsc` writes `dist` except `dist/web`, then `vite build` writes only `dist/web` (it empties that folder and nothing else), so the two steps do not depend on their order |
55
+ | `dist/web/index.html` | The built page, the one the command serves |
56
+ | `npm run dev:web -w @re-cinq/floor-studio` | The Vite dev server with hot reload |
57
+ | `npm run typecheck -w @re-cinq/floor-studio` | Checks `src` and `web` |
58
+
59
+ To work on the page, start a backend and give the dev server its address:
60
+
61
+ ```
62
+ node packages/studio/dist/cli.js path/to/collection --no-open # prints floor-studio: http://127.0.0.1:<page port>/#socket=...&token=...
63
+ npm run dev:web -w @re-cinq/floor-studio # serves http://localhost:5173/
64
+ ```
65
+
66
+ Open `http://localhost:5173/` with the fragment the command printed (`#socket=...&token=...`). The backend refuses a browser page whose origin it was not told. The command allows only its own page, as `127.0.0.1` or `localhost` on the page's port. To allow the dev server, start the backend from a script with `startStudio({ ..., origins: ["http://localhost:5173"] })`.
67
+
68
+ ### Selection
69
+
70
+ The page keeps the selected assembly line and node in the fragment (`&line=<id>&node=<id>&tab=<tab>`), so a reload keeps the place.
71
+
72
+ - Clicking an edge or its label selects that edge and drops the node (`&edge=<from>|<to>|<event>`). A Line inspector shows its stations, its event, whether it is on the main path and its iteration limit.
73
+ - Choosing another node keeps the tab, or falls back to the first tab when that node lacks it. Escape clears the node and the tab.
74
+ - A `collection` push redraws the page in place and keeps the selection while the assembly line and node still exist.
75
+
76
+ ### Screens
77
+
78
+ - No address.
79
+ - Connecting.
80
+ - Cannot connect. The page retries with backoff and reads the collection again once it is back.
81
+ - Refused: a wrong token or another protocol version. It is not retried.
82
+ - Unreadable: the collection could not be read, shown with the reason. An unasked `refused` push, such as the folder being deleted, replaces a collection already drawn.
83
+ - An empty folder.
84
+ - The line view.
85
+
86
+ ### The inspector tabs
87
+
88
+ The right-hand inspector shows the selected node's id and station, with tabs by kind. A marker has none. A station has Station and Events. An agent adds Prompt, Run and the five settings tabs. The arrow keys move between tabs and wrap, and Home and End go to the first and last.
89
+
90
+ | tab | what it shows |
91
+ |---|---|
92
+ | Station | The description, each need with a sentence on how it is covered, each produce with the downstream nodes that read it, and the outcomes |
93
+ | Events | What starts the node: an edge, an outside event, or the assembly line's own start, with its condition. The outside events that answer it, with the outcome each reports. What it raises: its events, each outcome with the node its edge starts (or that the run stops there), and the assembly lines a settled run starts |
94
+ | Prompt | The agent's prompt with each `{placeholder}` marked by its state, by the same name rule the lint uses (`placeholderPattern`). A table of the placeholders with their source, state and the nodes that fill them. The needs the prompt never uses. An editor when connected |
95
+ | Run | Runs this one station on your machine, see [Running one station](#running-one-station) |
96
+ | Model | `model`, `permission_mode`, `max_turns`, `model_secret_key` |
97
+ | Tools | `skills`, `skills_source`, `disallowed_tools` |
98
+ | MCP | `mcp_servers` |
99
+ | Pod | `image`, `timeout_minutes`, `env`, `pod_resources` |
100
+ | Other | `tags`, `prices` and the rest of `config` |
101
+
102
+ The settings tabs show each setting the agent file writes. Without a studio connection a settings tab is a read-only `key: value` list, with objects and lists as compact JSON.
103
+
104
+ ### Editing
105
+
106
+ Connected to a studio, the Prompt tab has an editor and "Save prompt". Each settings tab has a form and "Save settings", with a field per setting and nested ones such as `config` as YAML. Numbers stay numbers.
107
+
108
+ A save sends `agent.write` with the version of the file the edit started from. The backend refuses it when the file changed on disk since, or when the agent file it would write fails the same check the collection read uses. The tab shows the reason.
109
+
110
+ With no unsaved edits, a change on disk shows at once. With unsaved edits, the edits are kept and the tab offers "Take the version on disk" or "Keep my edits". A save before choosing is refused.
111
+
112
+ An agent extended by `<line>/agents/<agent>.extra.md` also gets an "Extra prompt" editor for that file's text on its own, saved with the same version check. The studio is told no shipped agents, so it shows no merged prompt and the collection still lists the extension as refused.
113
+
114
+ ### Running one station
115
+
116
+ The Run tab of an agent node runs that station alone, with the agent CLI on your machine. It runs `claude` or `codex`, by the agent's model. Any other model family is a blocker.
117
+
118
+ The tab has a field for each need:
119
+
120
+ | need | what you give | what the studio does |
121
+ |---|---|---|
122
+ | value | text | passes it as is |
123
+ | file | the path of a file | copies it to the need's path in the folder |
124
+ | git | the path of a checkout | links it at the need's path. It links the real checkout, so the agent's commits land in it |
125
+
126
+ Folder is where the run happens. Permission is `acceptEdits` or `bypass`, as in the pod.
127
+
128
+ Preview shows the rendered prompt, the command and the blockers. A blocker is a required need with no value, a source path that does not exist, or a model the studio cannot run. A run with blockers is refused.
129
+
130
+ Run starts it and Cancel stops it. The transcript streams in as what the agent said, each tool it called (`› Read tests.json`), each refusal in red, and the run's turns, time and cost. Raw shows the lines as `claude` printed them.
131
+
132
+ When the run ends the tab shows the agent's final answer under Answer. Its words are text, and any JSON object in it is laid out field by field, each list item a numbered block, with the `LORE_NODE_RESULT` line left out. Below it, each under its label:
133
+
134
+ - the outcome, which is the agent's verdict read from its final result
135
+ - the exit code, none when cancelled
136
+ - each produce as found or missing. A produce `from: output` is found when the agent gave a final answer
137
+ - the edge taken, which is also lit on the graph
138
+ - the events raised next
139
+
140
+ Two things match the pod. The run gets the agent's `config.env` over the studio's own environment, so `CLAUDE_CODE_DISABLE_CLAUDE_MDS` and the like apply. And `/workspace`, as the pod spells the working folder, is replaced by the picked folder in the prompt's text and in the `<name>_path` parameters.
141
+
142
+ The need values are saved in `.floor-studio/fixtures/<line>/<node>.json` and each run in `.floor-studio/runs/<id>.json`, both in the collection folder. The store folder gets a `.gitignore` of `*` on its first write. The run's id is kept in the page's fragment (`&run=<id>`), so after a reload the tab reads the transcript again with `run.read`, also for a run still going. Closing the studio cancels its runs.
143
+
144
+ ### The environment
145
+
146
+ The sidebar lists the variables the settings name as `${NAME}`, with the files using each. A setting written that way shows as a chip, `env: NAME`. The studio does not fill it.
147
+
148
+ Override opens the field to type a value in its place. Saved with nothing typed, the setting keeps its `${NAME}`.
149
+
150
+ The install that applies the collection fills the variable in once, and applying fails when it is not set. In Lore it is set on lore-api by its Helm chart, or in `.env.local` when Lore runs locally.
151
+
152
+ ## Use the backend on its own
153
+
154
+ ```ts
155
+ import { startStudio } from "@re-cinq/floor-studio/backend";
156
+
157
+ const studio = await startStudio({ dir: "collection", port: 0, hostKeys: ["review_required"], origins: [] });
158
+ // studio.url is ws://127.0.0.1:<port>; open it with ?token=<studio.token>
159
+ await studio.close();
160
+ ```
161
+
162
+ `startStudio` resolves to `{ url, token, close }`. `url` has the real port and not the token. `close()` closes the sockets, the server and the watcher. `startStudio` rejects when `dir` is not a directory.
163
+
164
+ ## The protocol
165
+
166
+ Every frame is JSON in one WebSocket message. A request carries an `id` the client chooses and is answered by one `result` or `refused` frame with that `id`. The backend also pushes frames nobody asked for.
167
+
168
+ | direction | frame | when |
169
+ |---|---|---|
170
+ | backend to client | `{ type: "hello", version }` | First, when a socket opens. `version` is `PROTOCOL_VERSION` |
171
+ | client to backend | `{ id, type: "collection.read" }` | The client wants the whole collection |
172
+ | client to backend | `{ id, type: "agent.write", line, agent, prompt, settings?, version }` | Rewrite an agent file. The body becomes `prompt`, and the frontmatter becomes `settings` when given, with comments and key order kept. `version` is the sha256 of the file as the client read it (each node's `agent.version`). Refused when the assembly line has no such agent, the file changed since, or the file it would write fails the agent-file check. The result is `{ written: <file> }` |
173
+ | client to backend | `{ id, type: "extra.write", line, agent, text, version }` | Replace the whole text of the agent's `.extra.md` (each node's `extra`). `version` is the sha256 of the file as read. Refused when the assembly line has no extra file for that agent or the file changed since. The text is saved ending in one newline. The result is `{ written: <file> }` |
174
+ | client to backend | `{ id, type: "fixture.write", line, node, needs }` | Save the need values (`needs`, a text for each need name) of a node in `.floor-studio/fixtures/<line>/<node>.json`. The result is `{ written: <file> }` |
175
+ | client to backend | `{ id, type: "fixture.read", line, node }` | Read the saved need values of a node. The result is `{ needs }`, empty when none were saved |
176
+ | client to backend | `{ id, type: "run.preview", line, node, fixture, folder, permission }` | What a run would do. The result is `{ prompt, command, copies, links, blockers }`. `permission` is `acceptEdits` or `bypass` |
177
+ | client to backend | `{ id, type: "run.start", line, node, fixture, folder, permission }` | Start a run of an agent node. Refused when the preview has blockers. The result is `{ run }`, the run's id |
178
+ | client to backend | `{ id, type: "run.cancel", run }` | Stop a running run. Refused when none runs under that id. The result is `{ cancelled: run }` |
179
+ | client to backend | `{ id, type: "run.read", run, after }` | The transcript of a run from line number `after` on, running or ended, also after a restart. The result is `{ lines, ended? }` |
180
+ | backend to client | `{ id, type: "result", result }` | The answer to a request. For `collection.read`, `result` is the collection view |
181
+ | backend to client | `{ id?, type: "refused", reason }` | A frame that is not JSON, fails its schema or has an unknown `type`, or a request that failed. The `id` is there when one could be read. Also pushed unasked, without an `id`, when a re-read after a change on disk fails, such as the folder being deleted. The socket stays open |
182
+ | backend to client | `{ type: "collection", collection }` | A file the collection reads changed on disk, whoever changed it. The whole view is sent again |
183
+ | backend to client | `{ type: "run.output", run, line: { stream, text } }` | One line a run wrote, on `stdout` or `stderr`, sent to every socket |
184
+ | backend to client | `{ type: "run.ended", run, exitCode, outcome?, produced?, edge? }` | A run ended. `exitCode` is `null` when it was cancelled, and then the rest is absent. Otherwise `outcome` is the agent's verdict, `produced` lists each file produce as `{ name, found }`, and `edge` is the `{ from, to, on }` the outcome takes (none from a terminal node) |
185
+
186
+ A new request type is one schema in `src/protocol.ts` and one handler in the table in `src/backend/requests.ts`.
187
+
188
+ ### The collection view
189
+
190
+ `collectionView(files, hostKeys)` is pure and takes `{ path, text }` values. It answers plain JSON: `lines`, `agents`, `refused` and `counts`. The backend adds `folder`, the name of the collection's folder, to what it sends. A node that names a `fanout` carries it as `fanout: { over, to }`. The types are in `src/view.ts` and exported from the protocol.
191
+
192
+ - An assembly line with problems is still shown. Each assembly line is read on its own, so one the collection's overlay would refuse appears with `problems` listing each one: `rule`, the `node` when there is one, and the `message`. The rules of the lint and the floor's own check of a line body are both there. A fault they both name is listed once, as the lint's rule.
193
+ - A file that cannot be read at all is in `refused` with its path and the reason. Examples are YAML that does not parse, an agent file with no frontmatter, or a `pipeline.yaml` beside an `assembly-line.yaml`. The other files still draw.
194
+ - Settings are shown as the file writes them. `${NAME}` is not filled from the environment.
195
+ - Each node holds its station's `kind`, `description`, `outcomes`, `needs` and `produces`. Each need has its `coverage` from `needCoverage`. Each produce has `readBy`, the nodes downstream of it (by `downstreamOf`) whose station needs it. The node has its `events` from `nodeEvents`. For an agent station whose agent a file defines, it also has `agent` and the `placeholders` of that agent's prompt from `promptPlaceholders`.
196
+
197
+ ## Security
198
+
199
+ The backend writes files and starts processes, so no web page may reach it. Three rules keep it shut.
200
+
201
+ - It listens on `127.0.0.1` and never on `0.0.0.0`.
202
+ - A random token of 256 bits is made at start. A socket is accepted only when its url carries `?token=<token>`, compared in constant time. Without it the upgrade is refused with 401.
203
+ - A browser always sends an `Origin`. A socket that has one is accepted only when it is in the `origins` list given to `startStudio`. The shell passes the origin of its own page, as `127.0.0.1` and as `localhost` on the same port. Any other origin is refused with 403, whatever the token. A client that sends no `Origin` is not a browser, and the token is enough.
204
+
205
+ A refused upgrade gets no socket at all.
206
+
207
+ ## Change watching
208
+
209
+ The backend watches `dir` with `fs.watch` and `recursive: true`. It ignores a path the collection does not read and anything under a dot folder. It waits about 100 ms for the changes to settle, then pushes one `collection` frame to every open socket, or one `refused` frame without an `id` when the read fails. A file that is deleted or renamed is handled the same way. A watcher error does not stop the backend.
@@ -0,0 +1,16 @@
1
+ /** The agent file with its body replaced by `prompt`, the frontmatter kept byte for byte. */
2
+ export declare function withPrompt(text: string, prompt: string): string;
3
+ /** `text` ending in a newline: added only when missing. */
4
+ export declare function withOneNewline(text: string): string;
5
+ /** The agent file with `settings` set in its frontmatter, comments and key order kept, the body byte for byte. */
6
+ export declare function withSettings(text: string, settings: Record<string, unknown>): string;
7
+ /** A rewrite of one agent file, refused unless `version` is still the version of the file. */
8
+ export interface AgentEdit {
9
+ prompt: string;
10
+ settings?: Record<string, unknown>;
11
+ version: string;
12
+ }
13
+ /** The text `current` of the agent file at `file` with `edit` applied: its settings, if any, then its prompt. */
14
+ export declare function editedAgentText(file: string, current: string, { prompt, settings, version }: AgentEdit): string;
15
+ /** The version of an agent file: a hash of its text as read. */
16
+ export declare function textVersion(text: string): string;
@@ -0,0 +1,37 @@
1
+ // The text of an agent file: YAML frontmatter between `---` lines, then the prompt.
2
+ import { createHash } from "node:crypto";
3
+ import { parseDocument } from "yaml";
4
+ import { enforce } from "@re-cinq/floor-assembly-lines";
5
+ const FRONTMATTER = /^---\r?\n[\s\S]*?\r?\n---\r?\n/;
6
+ /** The agent file with its body replaced by `prompt`, the frontmatter kept byte for byte. */
7
+ export function withPrompt(text, prompt) {
8
+ const frontmatter = FRONTMATTER.exec(text);
9
+ enforce(frontmatter, "the agent file has no frontmatter");
10
+ return `${frontmatter[0]}${withOneNewline(prompt)}`;
11
+ }
12
+ /** `text` ending in a newline: added only when missing. */
13
+ export function withOneNewline(text) {
14
+ return text.endsWith("\n") ? text : `${text}\n`;
15
+ }
16
+ /** The agent file with `settings` set in its frontmatter, comments and key order kept, the body byte for byte. */
17
+ export function withSettings(text, settings) {
18
+ const frontmatter = FRONTMATTER.exec(text);
19
+ enforce(frontmatter, "the agent file has no frontmatter");
20
+ const document = parseDocument(frontmatter[0].replace(/^---\r?\n|---\r?\n$/g, ""));
21
+ const droppedKeys = Object.keys(document.toJS() ?? {}).filter((key) => !(key in settings));
22
+ for (const key of droppedKeys)
23
+ document.delete(key);
24
+ for (const [key, value] of Object.entries(settings))
25
+ document.set(key, value);
26
+ return `---\n${document.toString()}---\n${text.slice(frontmatter[0].length)}`;
27
+ }
28
+ /** The text `current` of the agent file at `file` with `edit` applied: its settings, if any, then its prompt. */
29
+ export function editedAgentText(file, current, { prompt, settings, version }) {
30
+ enforce(version === textVersion(current), `${file} changed on disk since it was read`);
31
+ return withPrompt(settings ? withSettings(current, settings) : current, prompt);
32
+ }
33
+ /** The version of an agent file: a hash of its text as read. */
34
+ export function textVersion(text) {
35
+ return createHash("sha256").update(text).digest("hex");
36
+ }
37
+ //# sourceMappingURL=agent-file-text.js.map
@@ -0,0 +1,8 @@
1
+ import type { CollectionFile, OverlayAgent } from "@re-cinq/floor-pipeline";
2
+ import type { AgentView, LineView } from "../view.js";
3
+ export interface AgentFiles {
4
+ file?: string;
5
+ extraFile?: string;
6
+ }
7
+ export declare function agentViews(agents: ReadonlyMap<string, OverlayAgent>, filesOf: ReadonlyMap<string, AgentFiles>, lines: readonly LineView[]): AgentView[];
8
+ export declare function agentFilesByName(files: readonly CollectionFile[]): Map<string, AgentFiles>;
@@ -0,0 +1,28 @@
1
+ import { agentFileOf } from "@re-cinq/floor-pipeline";
2
+ import { present } from "./present.js";
3
+ export function agentViews(agents, filesOf, lines) {
4
+ return [...agents]
5
+ .sort(([left], [right]) => left.localeCompare(right))
6
+ .map(([name, { source, settings }]) => {
7
+ const { prompt, ...written } = settings;
8
+ const { file = "", extraFile } = filesOf.get(name) ?? {};
9
+ return { name, file, ...present({ extraFile }), source, settings: written, prompt, usedBy: usesOf(name, lines) };
10
+ });
11
+ }
12
+ export function agentFilesByName(files) {
13
+ const byName = new Map();
14
+ for (const { path } of files) {
15
+ const named = agentFileOf(path);
16
+ if (named)
17
+ byName.set(named.agent, { ...byName.get(named.agent), [named.isExtension ? "extraFile" : "file"]: path });
18
+ }
19
+ return byName;
20
+ }
21
+ function usesOf(agent, lines) {
22
+ return lines.flatMap((line) => usesInLine(agent, line));
23
+ }
24
+ function usesInLine(agent, { id, nodes }) {
25
+ const using = nodes.filter((node) => node.agent?.name === agent);
26
+ return using.map((node) => ({ line: id, node: node.id }));
27
+ }
28
+ //# sourceMappingURL=agent-views.js.map
@@ -0,0 +1,3 @@
1
+ import { type CollectionFile } from "@re-cinq/floor-pipeline";
2
+ import type { CollectionView } from "../view.js";
3
+ export declare function collectionView(files: readonly CollectionFile[], hostKeys: readonly string[]): CollectionView;
@@ -0,0 +1,108 @@
1
+ // The studio's picture of a collection: every line with its nodes, every agent, and what was refused. Pure and tolerant: a collection with problems still has a view, and nothing a person wrote makes it throw.
2
+ import { coverageContextOf, downstreamOf, needCoverage, nodeEvents, promptPlaceholders } from "@re-cinq/floor-assembly-lines";
3
+ import { attempt, collectionOverlay, pipelineFolderOf } from "@re-cinq/floor-pipeline";
4
+ import { textVersion } from "./agent-file-text.js";
5
+ import { agentFilesByName, agentViews } from "./agent-views.js";
6
+ import { present } from "./present.js";
7
+ import { readLine } from "./read-line.js";
8
+ /** `${NAME}` answers itself, so a setting is shown as the file wrote it. */
9
+ const AS_WRITTEN = new Proxy({}, { get: (...given) => `\${${String(given[1])}}` });
10
+ /** Nothing is shipped: the studio shows the collection on its own. */
11
+ const NOTHING_SHIPPED = { pipelines: [], agents: new Map() };
12
+ export function collectionView(files, hostKeys) {
13
+ const overlay = collectionOverlay({ files, shipped: NOTHING_SHIPPED, env: AS_WRITTEN, hostKeys });
14
+ const lineFiles = lineFilesOf(files);
15
+ const reads = lineFiles.map((file) => attempt(file.path, () => readLine(file, file.folder, promptsOf(overlay.agents))));
16
+ const read = reads.flatMap((result) => ("made" in result ? [result.made] : []));
17
+ const surroundings = { lines: read.map(({ id, body }) => ({ id, body })), agents: overlay.agents, agentFiles: agentFilesByName(files), files };
18
+ const views = read.map((line) => attempt(line.file, () => lineViewOf(line, surroundings)));
19
+ const lines = views.flatMap((result) => ("made" in result ? [result.made] : []));
20
+ const refused = refusedOf(overlay, { lineFiles, failures: [...reads, ...views] });
21
+ return { lines, agents: agentViews(overlay.agents, surroundings.agentFiles, lines), refused, counts: countsOf(lines, overlay, refused) };
22
+ }
23
+ /** The line files that are read: a folder's former `pipeline.yaml` beside its `assembly-line.yaml` is the overlay's to refuse. */
24
+ function lineFilesOf(files) {
25
+ const named = files.flatMap((file) => {
26
+ const folder = pipelineFolderOf(file.path);
27
+ return folder ? [{ ...file, folder }] : [];
28
+ });
29
+ const foldersWithCurrentName = new Set(named.filter((file) => file.path.endsWith("/assembly-line.yaml")).map((file) => file.folder));
30
+ return named.filter((file) => file.path.endsWith("/assembly-line.yaml") || !foldersWithCurrentName.has(file.folder)).sort((left, right) => left.path.localeCompare(right.path));
31
+ }
32
+ function promptsOf(agents) {
33
+ return new Map([...agents].map(([name, agent]) => [name, agent.settings.prompt]));
34
+ }
35
+ function lineViewOf(line, surroundings) {
36
+ const { body } = line;
37
+ const needContext = coverageContextOf(body, line.bodies);
38
+ return {
39
+ id: line.id,
40
+ file: line.file,
41
+ entry: body.entry,
42
+ exit: body.exit,
43
+ ...present({ fail: body.fail, start: body.start }),
44
+ args: body.args,
45
+ nodes: body.nodes.map((node) => nodeViewOf(node, line, surroundings, needContext)),
46
+ edges: body.edges,
47
+ problems: line.problems,
48
+ };
49
+ }
50
+ function nodeViewOf(node, line, surroundings, needContext) {
51
+ const station = node.station ? line.bodies.get(node.station) : undefined;
52
+ return {
53
+ id: node.id,
54
+ ...present({ station: node.station, fanout: node.fanout }),
55
+ ...stationFacts(station, { node, line, needContext }),
56
+ events: nodeEvents(line.body, node, surroundings.lines, line.bodies),
57
+ ...agentOf(node, { line, station }, surroundings),
58
+ ...extraOf(station?.agentDefinition, line, surroundings.files),
59
+ };
60
+ }
61
+ function extraOf(agentName, line, files) {
62
+ const file = `${pipelineFolderOf(line.file)}/agents/${agentName}.extra.md`;
63
+ const text = agentName === undefined ? undefined : files.find((candidate) => candidate.path === file)?.text;
64
+ return text === undefined ? {} : { extra: { file, text, version: textVersion(text) } };
65
+ }
66
+ function stationFacts(station, { node, line, needContext }) {
67
+ const { kind, description, agentDefinition, outcomes = [], needs = [], produces = [] } = station ?? {};
68
+ return {
69
+ ...present({ kind, description, agentDefinition }),
70
+ outcomes,
71
+ needs: needs.map((need) => ({ ...need, coverage: needCoverage(node, need, needContext) })),
72
+ produces: produces.map((produce) => ({ ...produce, readBy: readersOf(produce.name, node, line) })),
73
+ };
74
+ }
75
+ function readersOf(produceName, producer, { body, bodies }) {
76
+ const downstream = downstreamOf(producer.id, body.edges);
77
+ const readers = body.nodes.filter(({ id, station }) => station !== undefined && downstream.has(id) && needNamesOf(bodies.get(station)).includes(produceName));
78
+ return readers.map(({ id }) => id);
79
+ }
80
+ function needNamesOf(station) {
81
+ return (station?.needs ?? []).map(({ name }) => name);
82
+ }
83
+ function agentOf(node, { line, station }, surroundings) {
84
+ const name = station?.agentDefinition ?? "";
85
+ return station?.kind === "agent" && surroundings.agents.has(name) ? agentFacts(name, { node, line, station }, surroundings) : {};
86
+ }
87
+ function agentFacts(name, { node, line, station }, { agents, agentFiles, files }) {
88
+ const { prompt, ...settings } = agents.get(name)?.settings ?? { prompt: null };
89
+ const file = agentFiles.get(name)?.file ?? "";
90
+ return {
91
+ agent: { name, file, version: versionOf(file, files), prompt, settings },
92
+ placeholders: promptPlaceholders({ prompt: prompt ?? "", line: line.body, node, station, bodies: line.bodies }),
93
+ };
94
+ }
95
+ function versionOf(path, files) {
96
+ const text = files.find((file) => file.path === path)?.text;
97
+ return text === undefined ? null : textVersion(text);
98
+ }
99
+ function refusedOf(overlay, { lineFiles, failures }) {
100
+ const lineFilePaths = new Set(lineFiles.map((file) => file.path));
101
+ const refusedByOverlay = overlay.refused.filter(({ path }) => !lineFilePaths.has(path));
102
+ const refusedHere = failures.flatMap((result) => ("refusal" in result ? [result.refusal] : []));
103
+ return [...refusedByOverlay, ...refusedHere].sort((left, right) => left.path.localeCompare(right.path));
104
+ }
105
+ function countsOf(lines, overlay, refused) {
106
+ return { lines: lines.length, agents: overlay.counts.agents, refused: refused.length, problems: lines.reduce((total, line) => total + line.problems.length, 0) };
107
+ }
108
+ //# sourceMappingURL=collection-view.js.map
@@ -0,0 +1,5 @@
1
+ import { type CollectionFile } from "@re-cinq/floor-pipeline";
2
+ export declare function environmentOf(files: readonly CollectionFile[]): {
3
+ name: string;
4
+ files: string[];
5
+ }[];