@multiplayer-app/agent 0.1.19 → 0.1.21

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 (308) hide show
  1. package/README.md +14 -7
  2. package/dist/agent/definition.d.ts +13 -0
  3. package/dist/agent/definition.d.ts.map +1 -1
  4. package/dist/agent/definition.test.js +8 -3
  5. package/dist/agent/definition.test.js.map +1 -1
  6. package/dist/agent/profiles/coding.d.ts +1 -1
  7. package/dist/agent/profiles/coding.d.ts.map +1 -1
  8. package/dist/agent/profiles/coding.js +21 -4
  9. package/dist/agent/profiles/coding.js.map +1 -1
  10. package/dist/agent/profiles/index.js +1 -1
  11. package/dist/agent/profiles/index.js.map +1 -1
  12. package/dist/agent/profiles/research.d.ts.map +1 -1
  13. package/dist/agent/profiles/research.js +23 -1
  14. package/dist/agent/profiles/research.js.map +1 -1
  15. package/dist/agent/turn-history.d.ts +40 -0
  16. package/dist/agent/turn-history.d.ts.map +1 -0
  17. package/dist/agent/turn-history.js +167 -0
  18. package/dist/agent/turn-history.js.map +1 -0
  19. package/dist/agent/turn-runner.d.ts +22 -1
  20. package/dist/agent/turn-runner.d.ts.map +1 -1
  21. package/dist/agent/turn-runner.js +162 -79
  22. package/dist/agent/turn-runner.js.map +1 -1
  23. package/dist/app/app-host.d.ts +57 -0
  24. package/dist/app/app-host.d.ts.map +1 -0
  25. package/dist/app/app-host.js +252 -0
  26. package/dist/app/app-host.js.map +1 -0
  27. package/dist/app/app-host.test.d.ts +2 -0
  28. package/dist/app/app-host.test.d.ts.map +1 -0
  29. package/dist/app/app-host.test.js +639 -0
  30. package/dist/app/app-host.test.js.map +1 -0
  31. package/dist/app/config.d.ts +196 -0
  32. package/dist/app/config.d.ts.map +1 -0
  33. package/dist/app/config.js +362 -0
  34. package/dist/app/config.js.map +1 -0
  35. package/dist/app/config.test.d.ts +2 -0
  36. package/dist/app/config.test.d.ts.map +1 -0
  37. package/dist/app/config.test.js +224 -0
  38. package/dist/app/config.test.js.map +1 -0
  39. package/dist/app/detect.d.ts +68 -0
  40. package/dist/app/detect.d.ts.map +1 -0
  41. package/dist/app/detect.js +449 -0
  42. package/dist/app/detect.js.map +1 -0
  43. package/dist/app/detect.test.d.ts +2 -0
  44. package/dist/app/detect.test.d.ts.map +1 -0
  45. package/dist/app/detect.test.js +267 -0
  46. package/dist/app/detect.test.js.map +1 -0
  47. package/dist/app/env.d.ts +5 -0
  48. package/dist/app/env.d.ts.map +1 -0
  49. package/dist/app/env.js +22 -0
  50. package/dist/app/env.js.map +1 -0
  51. package/dist/app/functions-cli.d.ts +3 -0
  52. package/dist/app/functions-cli.d.ts.map +1 -0
  53. package/dist/app/functions-cli.js +27 -0
  54. package/dist/app/functions-cli.js.map +1 -0
  55. package/dist/app/functions-host.d.ts +15 -0
  56. package/dist/app/functions-host.d.ts.map +1 -0
  57. package/dist/app/functions-host.js +276 -0
  58. package/dist/app/functions-host.js.map +1 -0
  59. package/dist/app/functions-host.test.d.ts +2 -0
  60. package/dist/app/functions-host.test.d.ts.map +1 -0
  61. package/dist/app/functions-host.test.js +117 -0
  62. package/dist/app/functions-host.test.js.map +1 -0
  63. package/dist/app/functions-routes.d.ts +23 -0
  64. package/dist/app/functions-routes.d.ts.map +1 -0
  65. package/dist/app/functions-routes.js +85 -0
  66. package/dist/app/functions-routes.js.map +1 -0
  67. package/dist/app/functions-routes.test.d.ts +2 -0
  68. package/dist/app/functions-routes.test.d.ts.map +1 -0
  69. package/dist/app/functions-routes.test.js +40 -0
  70. package/dist/app/functions-routes.test.js.map +1 -0
  71. package/dist/app/manifest.d.ts +17 -0
  72. package/dist/app/manifest.d.ts.map +1 -0
  73. package/dist/app/manifest.js +64 -0
  74. package/dist/app/manifest.js.map +1 -0
  75. package/dist/app/manifest.test.d.ts +2 -0
  76. package/dist/app/manifest.test.d.ts.map +1 -0
  77. package/dist/app/manifest.test.js +173 -0
  78. package/dist/app/manifest.test.js.map +1 -0
  79. package/dist/app/release-artifacts.d.ts +39 -0
  80. package/dist/app/release-artifacts.d.ts.map +1 -0
  81. package/dist/app/release-artifacts.js +229 -0
  82. package/dist/app/release-artifacts.js.map +1 -0
  83. package/dist/app/release-artifacts.test.d.ts +2 -0
  84. package/dist/app/release-artifacts.test.d.ts.map +1 -0
  85. package/dist/app/release-artifacts.test.js +295 -0
  86. package/dist/app/release-artifacts.test.js.map +1 -0
  87. package/dist/app/route-pattern.d.ts +23 -0
  88. package/dist/app/route-pattern.d.ts.map +1 -0
  89. package/dist/app/route-pattern.js +339 -0
  90. package/dist/app/route-pattern.js.map +1 -0
  91. package/dist/app/route-pattern.test.d.ts +2 -0
  92. package/dist/app/route-pattern.test.d.ts.map +1 -0
  93. package/dist/app/route-pattern.test.js +187 -0
  94. package/dist/app/route-pattern.test.js.map +1 -0
  95. package/dist/app/rules.d.ts +61 -0
  96. package/dist/app/rules.d.ts.map +1 -0
  97. package/dist/app/rules.js +90 -0
  98. package/dist/app/rules.js.map +1 -0
  99. package/dist/app/rules.test.d.ts +2 -0
  100. package/dist/app/rules.test.d.ts.map +1 -0
  101. package/dist/app/rules.test.js +69 -0
  102. package/dist/app/rules.test.js.map +1 -0
  103. package/dist/app/runner.d.ts +109 -0
  104. package/dist/app/runner.d.ts.map +1 -0
  105. package/dist/app/runner.js +429 -0
  106. package/dist/app/runner.js.map +1 -0
  107. package/dist/app/site.d.ts +73 -0
  108. package/dist/app/site.d.ts.map +1 -0
  109. package/dist/app/site.js +161 -0
  110. package/dist/app/site.js.map +1 -0
  111. package/dist/app/site.test.d.ts +2 -0
  112. package/dist/app/site.test.d.ts.map +1 -0
  113. package/dist/app/site.test.js +291 -0
  114. package/dist/app/site.test.js.map +1 -0
  115. package/dist/app/static-server.d.ts +20 -0
  116. package/dist/app/static-server.d.ts.map +1 -0
  117. package/dist/app/static-server.js +145 -0
  118. package/dist/app/static-server.js.map +1 -0
  119. package/dist/context-pruning.d.ts +2 -0
  120. package/dist/context-pruning.d.ts.map +1 -1
  121. package/dist/context-pruning.js +3 -2
  122. package/dist/context-pruning.js.map +1 -1
  123. package/dist/models/usage.d.ts +6 -0
  124. package/dist/models/usage.d.ts.map +1 -1
  125. package/dist/models/usage.js +13 -0
  126. package/dist/models/usage.js.map +1 -1
  127. package/dist/persistence/conversation-store.d.ts +21 -0
  128. package/dist/persistence/conversation-store.d.ts.map +1 -0
  129. package/dist/persistence/conversation-store.js +59 -0
  130. package/dist/persistence/conversation-store.js.map +1 -0
  131. package/dist/persistence/conversation-store.test.d.ts +2 -0
  132. package/dist/persistence/conversation-store.test.d.ts.map +1 -0
  133. package/dist/persistence/conversation-store.test.js +98 -0
  134. package/dist/persistence/conversation-store.test.js.map +1 -0
  135. package/dist/persistence/git-sync.d.ts +14 -1
  136. package/dist/persistence/git-sync.d.ts.map +1 -1
  137. package/dist/persistence/git-sync.js +73 -17
  138. package/dist/persistence/git-sync.js.map +1 -1
  139. package/dist/persistence/git-sync.test.js +155 -6
  140. package/dist/persistence/git-sync.test.js.map +1 -1
  141. package/dist/persistence/snapshot-sync.d.ts +19 -2
  142. package/dist/persistence/snapshot-sync.d.ts.map +1 -1
  143. package/dist/persistence/snapshot-sync.js +194 -83
  144. package/dist/persistence/snapshot-sync.js.map +1 -1
  145. package/dist/persistence/snapshot-sync.test.js +145 -27
  146. package/dist/persistence/snapshot-sync.test.js.map +1 -1
  147. package/dist/persistence/workspace.d.ts +3 -0
  148. package/dist/persistence/workspace.d.ts.map +1 -1
  149. package/dist/persistence/workspace.js +1 -0
  150. package/dist/persistence/workspace.js.map +1 -1
  151. package/dist/research/extract-texts.d.ts.map +1 -1
  152. package/dist/research/extract-texts.js +34 -16
  153. package/dist/research/extract-texts.js.map +1 -1
  154. package/dist/research/filingramp/attachment-tools.d.ts.map +1 -1
  155. package/dist/research/filingramp/attachment-tools.js +7 -4
  156. package/dist/research/filingramp/attachment-tools.js.map +1 -1
  157. package/dist/research/filingramp/shared.d.ts.map +1 -1
  158. package/dist/research/filingramp/shared.js +5 -5
  159. package/dist/research/filingramp/shared.js.map +1 -1
  160. package/dist/research/prompt.d.ts.map +1 -1
  161. package/dist/research/prompt.js +2 -1
  162. package/dist/research/prompt.js.map +1 -1
  163. package/dist/runtime/app-mode.d.ts +10 -0
  164. package/dist/runtime/app-mode.d.ts.map +1 -0
  165. package/dist/runtime/app-mode.js +172 -0
  166. package/dist/runtime/app-mode.js.map +1 -0
  167. package/dist/runtime/app-mode.test.d.ts +2 -0
  168. package/dist/runtime/app-mode.test.d.ts.map +1 -0
  169. package/dist/runtime/app-mode.test.js +130 -0
  170. package/dist/runtime/app-mode.test.js.map +1 -0
  171. package/dist/runtime/app-rehearsal.d.ts +2 -0
  172. package/dist/runtime/app-rehearsal.d.ts.map +1 -0
  173. package/dist/runtime/app-rehearsal.js +56 -0
  174. package/dist/runtime/app-rehearsal.js.map +1 -0
  175. package/dist/runtime/build-mode.d.ts +12 -0
  176. package/dist/runtime/build-mode.d.ts.map +1 -0
  177. package/dist/runtime/build-mode.js +116 -0
  178. package/dist/runtime/build-mode.js.map +1 -0
  179. package/dist/runtime/build-mode.test.d.ts +2 -0
  180. package/dist/runtime/build-mode.test.d.ts.map +1 -0
  181. package/dist/runtime/build-mode.test.js +121 -0
  182. package/dist/runtime/build-mode.test.js.map +1 -0
  183. package/dist/runtime/cli.js +7 -2
  184. package/dist/runtime/cli.js.map +1 -1
  185. package/dist/runtime/config.d.ts +4 -0
  186. package/dist/runtime/config.d.ts.map +1 -1
  187. package/dist/runtime/config.js +13 -2
  188. package/dist/runtime/config.js.map +1 -1
  189. package/dist/runtime/guest-server.d.ts +3 -0
  190. package/dist/runtime/guest-server.d.ts.map +1 -0
  191. package/dist/runtime/{lambda-microvm.js → guest-server.js} +49 -18
  192. package/dist/runtime/guest-server.js.map +1 -0
  193. package/dist/runtime/image-hooks.d.ts +5 -0
  194. package/dist/runtime/image-hooks.d.ts.map +1 -0
  195. package/dist/runtime/image-hooks.js +68 -0
  196. package/dist/runtime/image-hooks.js.map +1 -0
  197. package/dist/runtime/image-hooks.test.d.ts +2 -0
  198. package/dist/runtime/image-hooks.test.d.ts.map +1 -0
  199. package/dist/runtime/image-hooks.test.js +74 -0
  200. package/dist/runtime/image-hooks.test.js.map +1 -0
  201. package/dist/runtime/index.d.ts +8 -3
  202. package/dist/runtime/index.d.ts.map +1 -1
  203. package/dist/runtime/index.js +53 -35
  204. package/dist/runtime/index.js.map +1 -1
  205. package/dist/runtime/listening-ports.d.ts +13 -0
  206. package/dist/runtime/listening-ports.d.ts.map +1 -0
  207. package/dist/runtime/listening-ports.js +78 -0
  208. package/dist/runtime/listening-ports.js.map +1 -0
  209. package/dist/runtime/listening-ports.test.d.ts +2 -0
  210. package/dist/runtime/listening-ports.test.d.ts.map +1 -0
  211. package/dist/runtime/listening-ports.test.js +39 -0
  212. package/dist/runtime/listening-ports.test.js.map +1 -0
  213. package/dist/runtime/preview-proxy.d.ts +56 -0
  214. package/dist/runtime/preview-proxy.d.ts.map +1 -0
  215. package/dist/runtime/preview-proxy.js +302 -0
  216. package/dist/runtime/preview-proxy.js.map +1 -0
  217. package/dist/runtime/preview-proxy.test.d.ts +2 -0
  218. package/dist/runtime/preview-proxy.test.d.ts.map +1 -0
  219. package/dist/runtime/preview-proxy.test.js +122 -0
  220. package/dist/runtime/preview-proxy.test.js.map +1 -0
  221. package/dist/runtime/session-mode.d.ts +3 -0
  222. package/dist/runtime/session-mode.d.ts.map +1 -0
  223. package/dist/runtime/session-mode.js +60 -0
  224. package/dist/runtime/session-mode.js.map +1 -0
  225. package/dist/runtime/workload.d.ts +44 -0
  226. package/dist/runtime/workload.d.ts.map +1 -0
  227. package/dist/runtime/workload.js +222 -0
  228. package/dist/runtime/workload.js.map +1 -0
  229. package/dist/runtime/workload.test.d.ts +2 -0
  230. package/dist/runtime/workload.test.d.ts.map +1 -0
  231. package/dist/runtime/workload.test.js +235 -0
  232. package/dist/runtime/workload.test.js.map +1 -0
  233. package/dist/session/conversation.d.ts +10 -2
  234. package/dist/session/conversation.d.ts.map +1 -1
  235. package/dist/session/conversation.js +40 -12
  236. package/dist/session/conversation.js.map +1 -1
  237. package/dist/session/conversation.test.js +2 -3
  238. package/dist/session/conversation.test.js.map +1 -1
  239. package/dist/session/index.d.ts +1 -1
  240. package/dist/session/index.d.ts.map +1 -1
  241. package/dist/session/index.js +2 -1
  242. package/dist/session/index.js.map +1 -1
  243. package/dist/session/runtime.d.ts +20 -3
  244. package/dist/session/runtime.d.ts.map +1 -1
  245. package/dist/session/runtime.js +97 -16
  246. package/dist/session/runtime.js.map +1 -1
  247. package/dist/session/runtime.test.js +18 -7
  248. package/dist/session/runtime.test.js.map +1 -1
  249. package/dist/session/tools.d.ts.map +1 -1
  250. package/dist/session/tools.js +5 -4
  251. package/dist/session/tools.js.map +1 -1
  252. package/dist/task/loop.d.ts.map +1 -1
  253. package/dist/task/loop.js +6 -4
  254. package/dist/task/loop.js.map +1 -1
  255. package/dist/tools/exec-tools.d.ts +12 -0
  256. package/dist/tools/exec-tools.d.ts.map +1 -1
  257. package/dist/tools/exec-tools.js +46 -3
  258. package/dist/tools/exec-tools.js.map +1 -1
  259. package/dist/tools/exec-tools.test.d.ts +2 -0
  260. package/dist/tools/exec-tools.test.d.ts.map +1 -0
  261. package/dist/tools/exec-tools.test.js +48 -0
  262. package/dist/tools/exec-tools.test.js.map +1 -0
  263. package/dist/tools/fs-tools.d.ts.map +1 -1
  264. package/dist/tools/fs-tools.js +5 -5
  265. package/dist/tools/fs-tools.js.map +1 -1
  266. package/dist/transport/link.d.ts.map +1 -1
  267. package/dist/transport/link.js +16 -5
  268. package/dist/transport/link.js.map +1 -1
  269. package/dist/transport/link.test.js +24 -0
  270. package/dist/transport/link.test.js.map +1 -1
  271. package/dist/transport/protocol.d.ts +190 -3
  272. package/dist/transport/protocol.d.ts.map +1 -1
  273. package/dist/transport/protocol.js +147 -7
  274. package/dist/transport/protocol.js.map +1 -1
  275. package/dist/transport/protocol.test.js +41 -0
  276. package/dist/transport/protocol.test.js.map +1 -1
  277. package/dist/workspace-sync/eligibility.d.ts +14 -0
  278. package/dist/workspace-sync/eligibility.d.ts.map +1 -0
  279. package/dist/workspace-sync/eligibility.js +53 -0
  280. package/dist/workspace-sync/eligibility.js.map +1 -0
  281. package/dist/workspace-sync/merge.d.ts +15 -0
  282. package/dist/workspace-sync/merge.d.ts.map +1 -0
  283. package/dist/workspace-sync/merge.js +66 -0
  284. package/dist/workspace-sync/merge.js.map +1 -0
  285. package/dist/workspace-sync/merge.test.d.ts +2 -0
  286. package/dist/workspace-sync/merge.test.d.ts.map +1 -0
  287. package/dist/workspace-sync/merge.test.js +28 -0
  288. package/dist/workspace-sync/merge.test.js.map +1 -0
  289. package/dist/workspace-sync/workspace-sync.d.ts +48 -0
  290. package/dist/workspace-sync/workspace-sync.d.ts.map +1 -0
  291. package/dist/workspace-sync/workspace-sync.js +308 -0
  292. package/dist/workspace-sync/workspace-sync.js.map +1 -0
  293. package/dist/workspace-sync/workspace-sync.test.d.ts +2 -0
  294. package/dist/workspace-sync/workspace-sync.test.d.ts.map +1 -0
  295. package/dist/workspace-sync/workspace-sync.test.js +111 -0
  296. package/dist/workspace-sync/workspace-sync.test.js.map +1 -0
  297. package/dist/workspace-sync/write-drafts.d.ts +24 -0
  298. package/dist/workspace-sync/write-drafts.d.ts.map +1 -0
  299. package/dist/workspace-sync/write-drafts.js +87 -0
  300. package/dist/workspace-sync/write-drafts.js.map +1 -0
  301. package/dist/workspace-sync/write-drafts.test.d.ts +2 -0
  302. package/dist/workspace-sync/write-drafts.test.d.ts.map +1 -0
  303. package/dist/workspace-sync/write-drafts.test.js +36 -0
  304. package/dist/workspace-sync/write-drafts.test.js.map +1 -0
  305. package/package.json +12 -2
  306. package/dist/runtime/lambda-microvm.d.ts +0 -3
  307. package/dist/runtime/lambda-microvm.d.ts.map +0 -1
  308. package/dist/runtime/lambda-microvm.js.map +0 -1
@@ -32,12 +32,17 @@ export interface AgentSessionFile {
32
32
  content: string;
33
33
  }
34
34
  export type AgentSessionCommand =
35
- /** A new user turn. `messageId` is the chat message id the platform already persisted. */
35
+ /**
36
+ * A new user turn. `messageId` is the chat message id the platform already persisted. `profile`
37
+ * is the kind of work it is — deep research, or building apps and code; without one the turn
38
+ * continues the previous turn's (an answer to its question, a "continue").
39
+ */
36
40
  {
37
41
  type: 'message';
38
42
  messageId: string;
39
43
  text: string;
40
44
  attachments?: AgentSessionAttachment[];
45
+ profile?: 'research' | 'coding';
41
46
  }
42
47
  /** Stop the running turn (the user pressed stop, or the session is being shut down). */
43
48
  | {
@@ -49,6 +54,22 @@ export type AgentSessionCommand =
49
54
  requestId?: string;
50
55
  waitForTurn?: boolean;
51
56
  onlyIfIdleForMs?: number;
57
+ }
58
+ /**
59
+ * Workspace live sync: the session's copy of `path` is now `content` (people edited it, or the
60
+ * guest's change was built on an older version), which the guest merges into its file. Without
61
+ * `content`, the session took the guest's own version `hash` as-is.
62
+ */
63
+ | {
64
+ type: 'file_state';
65
+ path: string;
66
+ hash: string;
67
+ content?: string;
68
+ }
69
+ /** Someone deleted `path` in the session. */
70
+ | {
71
+ type: 'file_delete';
72
+ path: string;
52
73
  };
53
74
  export interface AgentSessionCommandAck {
54
75
  ok: boolean;
@@ -117,12 +138,58 @@ export type AgentSessionEvent = BaseEvent & (
117
138
  messageId: string;
118
139
  usage: AgentUsage;
119
140
  }
120
- /** Text files to store as session artifacts. */
141
+ /** Text files to store as session artifacts (guests without workspace live sync). */
121
142
  | {
122
143
  type: 'files';
123
144
  messageId?: string;
124
145
  files: AgentSessionFile[];
125
146
  }
147
+ /**
148
+ * Workspace live sync (src/workspace-sync): a workspace text file changed. `base` is the
149
+ * workspaceFileHash of the session's version this content was built on — absent when the
150
+ * guest has none (a new file, or any file right after a restart). `final` ends a draft: the
151
+ * content replaces the drafted text as-is.
152
+ */
153
+ | {
154
+ type: 'file_changed';
155
+ path: string;
156
+ content: string;
157
+ base?: string;
158
+ final?: boolean;
159
+ } | {
160
+ type: 'file_deleted';
161
+ path: string;
162
+ }
163
+ /** What the model has written so far of a file it is still writing: shown live, not yet on disk. */
164
+ | {
165
+ type: 'file_draft';
166
+ path: string;
167
+ content: string;
168
+ }
169
+ /** The guest wrote the session's version `hash` of `path` (a file_state) to disk unchanged. */
170
+ | {
171
+ type: 'file_synced';
172
+ path: string;
173
+ hash: string;
174
+ }
175
+ /**
176
+ * Every TCP port something in the guest listens on, ascending (minus the guest's own
177
+ * GUEST_RESERVED_PORTS). Sent on startup, on every change and after a reconnect; the
178
+ * platform offers each one as a live preview.
179
+ */
180
+ | {
181
+ type: 'ports';
182
+ ports: number[];
183
+ }
184
+ /**
185
+ * The workspace's app (detected, with builder.json's overrides), as the guest runs it
186
+ * (src/app): sent on every change and after a reconnect; null once no app runs. Its URL
187
+ * routes through it.
188
+ */
189
+ | {
190
+ type: 'app';
191
+ app: AgentAppStatus | null;
192
+ }
126
193
  /** Conversation + workspace persisted (project Git commit or session snapshot). */
127
194
  | {
128
195
  type: 'checkpointed';
@@ -150,11 +217,127 @@ export type AgentSessionEvent = BaseEvent & (
150
217
  export type AgentSessionEventType = AgentSessionEvent['type'];
151
218
  export declare function agentSessionEventKey(event: AgentSessionEvent): string;
152
219
  export declare const AGENT_SESSION_EVENT_TYPES: readonly AgentSessionEventType[];
220
+ export declare const PREVIEW_PORT_HEADER: "x-builder-preview-port";
221
+ /**
222
+ * On what the gateway asks the api about a session's URL. A browser can't set it on a navigation, so
223
+ * a link to the api's route for that never runs a session's page on the api's own origin.
224
+ */
225
+ export declare const SESSION_SITE_HEADER: "x-builder-session-site";
226
+ /**
227
+ * Whether a URL path holds a dotfile or dot-folder at any depth (.env, .git, the platform's own
228
+ * .builder), or a `.`/`..` segment. An app's URL never serves one from its files; .well-known is
229
+ * the exception.
230
+ */
231
+ /**
232
+ * A request's target as a URL, to read its path and query. Anyone can send any target, and
233
+ * `new URL(target, base)` throws on `//` and reads `//host/path` as a host: this does neither,
234
+ * so leading slashes collapse as most servers treat them.
235
+ */
236
+ export declare function requestUrl(target: string | undefined): URL;
237
+ export declare function isHiddenSitePath(pathname: string): boolean;
238
+ /** The guest's own listeners: the hook/preview server, dropbear, and Lambda's shell agent. */
239
+ export declare const GUEST_RESERVED_PORTS: readonly number[];
240
+ /**
241
+ * The port apps are told to listen on ($PORT for the agent's commands). A session's own URL
242
+ * (<sessionId>.apps.<domain>) opens this one when it listens, else the lowest port that does.
243
+ */
244
+ export declare const DEFAULT_APP_PORT = 3000;
245
+ /**
246
+ * PREVIEW_PORT_HEADER's value for a session's own URL (no port in it): the guest picks the target
247
+ * itself, by the app's rewrites when the workspace holds one, else DEFAULT_APP_PORT or the
248
+ * lowest listening port. Never parsed from a hostname.
249
+ */
250
+ export declare const APP_PREVIEW_TARGET: "app";
251
+ /** A header value as a previewable port, or undefined. */
252
+ export declare function parsePreviewPort(value: unknown): number | undefined;
253
+ /** A PREVIEW_PORT_HEADER value: a previewable port, APP_PREVIEW_TARGET, or undefined. */
254
+ export declare function parsePreviewTarget(value: unknown): number | typeof APP_PREVIEW_TARGET | undefined;
255
+ /** The port a session's own URL opens without an app: DEFAULT_APP_PORT when it listens, else the lowest. */
256
+ export declare function defaultAppPort(ports: readonly number[]): number | undefined;
257
+ /**
258
+ * The app manifest, in the workspace's .builder folder; a session VM
259
+ * writes it. The one file of .builder that people see and edit as a session file.
260
+ */
261
+ export declare const APP_CONFIG_FILE: ".builder/builder.json";
262
+ /** Which of a session's stored files are executable: object storage keeps no mode. */
263
+ /**
264
+ * Where a session's conversation used to be saved, in its workspace and so in its branch. It's kept
265
+ * in the runtime's state directory now (persistence/conversation-store.ts), but repos still hold old
266
+ * copies: they stay off main when a session merges, and out of what a new session starts from.
267
+ */
268
+ export declare const SESSION_CONVERSATION_FILE = ".builder/conversation.json";
269
+ export declare const WORKSPACE_EXECUTABLES_FILE: ".builder/executables.json";
270
+ /** Dependencies and build output: saved with a workspace, but not files people open. */
271
+ export declare const WORKSPACE_GENERATED_DIRECTORIES: readonly string[];
272
+ /** Guest-only: a deployment's app status as JSON. `/internal/*` is never routed publicly. */
273
+ export declare const APP_STATUS_PATH: "/internal/app/status";
274
+ /** A built release's record of what it holds; written last, so a release that has one is complete. */
275
+ export declare const RELEASE_MANIFEST_FILE: "manifest.json";
276
+ /** The compressed copies of a built release's static files, best first. */
277
+ export declare const SITE_ENCODINGS: readonly ["br", "gzip"];
278
+ export type SiteEncoding = (typeof SITE_ENCODINGS)[number];
279
+ /** What a built release's VM runs: its folders as they were built, dependencies and all. */
280
+ export declare const RELEASE_ARCHIVE_FILE: "run.tar.zst";
281
+ /** How far a release's build has got, on a build VM's APP_STATUS_PATH as `{ build }`. */
282
+ export type AgentBuildPhase = 'fetching' | 'installing' | 'building' | 'uploading' | 'done' | 'failed';
283
+ export interface AgentBuildStatus {
284
+ phase: AgentBuildPhase;
285
+ /** Why it failed. */
286
+ error?: string;
287
+ /** The end of the log of the step running, or of the one that failed. */
288
+ log?: string;
289
+ /** What the finished release answers with: files from storage, processes on a VM, or some of each. */
290
+ serves?: 'files' | 'processes' | 'both';
291
+ }
292
+ /** Where the app is: installing and building come before its processes start. */
293
+ export type AgentAppPhase = 'installing' | 'building' | 'starting' | 'running' | 'failed';
294
+ export interface AgentAppProcess {
295
+ name: string;
296
+ kind: 'service' | 'daemon';
297
+ /** A static service is served by the guest itself and always 'running'. */
298
+ state: 'starting' | 'running' | 'crashed' | 'stopped';
299
+ port?: number;
300
+ restarts: number;
301
+ exitCode?: number | null;
302
+ signal?: string | null;
303
+ /** Workspace-relative log file. */
304
+ log?: string;
305
+ }
306
+ export interface AgentAppStatus {
307
+ phase: AgentAppPhase;
308
+ /** Why the app can't run: an invalid builder.json, or the install or build that failed. */
309
+ error?: string;
310
+ processes: AgentAppProcess[];
311
+ /** The framework it runs as (a Vercel slug); null for none: a package's own scripts, static files. */
312
+ framework?: string | null;
313
+ /** Whether builder.json said how it runs, or it was only detected. */
314
+ source?: 'detected' | 'builder.json';
315
+ }
316
+ /** How both sides of workspace live sync name a version of a file. */
317
+ export declare function workspaceFileHash(content: string): string;
153
318
  export declare function isAgentSessionEvent(value: unknown): value is AgentSessionEvent;
154
319
  export declare const AGENT_ENV: {
155
320
  readonly SESSION_ID: "SESSION_ID";
156
- /** 'task' (one AGENT_TASK run, then exit) or 'session' (stay up, serve chat turns). */
321
+ /**
322
+ * 'task' (one AGENT_TASK run, then exit), 'session' (stay up, serve chat turns), 'app' (a
323
+ * deployment: run the release's app on GUEST_HTTP_PORT, no agent) or 'build' (build a release
324
+ * and upload its output, no agent).
325
+ */
157
326
  readonly AGENT_MODE: "AGENT_MODE";
327
+ /** 'build' mode: where the release's output goes (the git service's route for that release). */
328
+ readonly RELEASE_UPLOAD_URL: "RELEASE_UPLOAD_URL";
329
+ /** secret, 'build' mode: may write only that release's output. */
330
+ readonly RELEASE_UPLOAD_TOKEN: "RELEASE_UPLOAD_TOKEN";
331
+ /** 'app' mode: a release built ahead of time: where the files its VM runs are, read with ACCESS_TOKEN. */
332
+ readonly RELEASE_ARTIFACTS_URL: "RELEASE_ARTIFACTS_URL";
333
+ /** 'app' mode: the release being run, so a VM restarted on its own disk skips install and build. */
334
+ readonly APP_RELEASE_ID: "APP_RELEASE_ID";
335
+ /** 'app' and build modes: the app's directory in the release's repository. */
336
+ readonly APP_ROOT_DIR: "APP_ROOT_DIR";
337
+ /** 'app' and build modes: the commit to check out. */
338
+ readonly GIT_COMMIT: "GIT_COMMIT";
339
+ /** The JSON schema the builder.json a session VM writes names as its `$schema`; written down, never fetched. */
340
+ readonly APP_SCHEMA_URL: "APP_SCHEMA_URL";
158
341
  /** 'coding' (default) or 'research'. */
159
342
  readonly AGENT_PROFILE: "AGENT_PROFILE";
160
343
  readonly AGENT_TASK: "AGENT_TASK";
@@ -164,6 +347,8 @@ export declare const AGENT_ENV: {
164
347
  /** Total tokens the session may spend before it pauses and asks whether to continue. */
165
348
  readonly AGENT_TOKEN_BUDGET: "AGENT_TOKEN_BUDGET";
166
349
  readonly AGENT_WORKSPACE_DIR: "AGENT_WORKSPACE_DIR";
350
+ /** The runtime's own files (its conversation, its git data), which nothing it runs can read. */
351
+ readonly AGENT_STATE_DIR: "AGENT_STATE_DIR";
167
352
  /** The gateway's agent socket; the guest authenticates to it with ACCESS_TOKEN (session-scoped). */
168
353
  readonly AGENT_SOCKET_URL: "AGENT_SOCKET_URL";
169
354
  /** secret: model provider keys (one of them) */
@@ -194,6 +379,8 @@ export declare const AGENT_ENV: {
194
379
  */
195
380
  readonly ACCESS_TOKEN: "ACCESS_TOKEN";
196
381
  };
382
+ /** The settings that deliver a release to its VM; the rest of a deployed VM's env is the app's own. */
383
+ export declare const RELEASE_DELIVERY_ENV: readonly string[];
197
384
  export declare const AGENT_SECRET_ENV_KEYS: readonly string[];
198
385
  export {};
199
386
  //# sourceMappingURL=protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/transport/protocol.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,mBAAmB,EAAG,qBAA8B,CAAA;AACjE,eAAO,MAAM,qBAAqB,EAAG,uBAAgC,CAAA;AAErE,kGAAkG;AAClG,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,gGAAgG;AAChG,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAA;IAChD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAA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AQ9E;AAOD,eAAO,MAAM,SAAS;;IAEpB;;;;OAIG;;IAEH,gGAAgG;;IAEhG,kEAAkE;;IAElE,0GAA0G;;IAE1G,oGAAoG;;IAEpG,8EAA8E;;IAE9E,sDAAsD;;IAEtD,gHAAgH;;IAEhH,wCAAwC;;;;IAIxC,6DAA6D;;IAE7D,wFAAwF;;;IAGxF,gGAAgG;;IAEhG,oGAAoG;;IAEpG,gDAAgD;;;IAGhD,2CAA2C;;;IAG3C,wFAAwF;;IAExF,qFAAqF;;IAErF,aAAa;;IAEb,mEAAmE;;IAEnE,uDAAuD;;;;;IAKvD,oFAAoF;;;IAGpF;;;OAGG;;CAEK,CAAA;AAEV,uGAAuG;AACvG,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAgBjD,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAOlD,CAAA"}
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AGENT_SECRET_ENV_KEYS = exports.RELEASE_DELIVERY_ENV = exports.AGENT_ENV = exports.RELEASE_ARCHIVE_FILE = exports.SITE_ENCODINGS = exports.RELEASE_MANIFEST_FILE = exports.APP_STATUS_PATH = exports.WORKSPACE_GENERATED_DIRECTORIES = exports.WORKSPACE_EXECUTABLES_FILE = exports.SESSION_CONVERSATION_FILE = exports.APP_CONFIG_FILE = exports.APP_PREVIEW_TARGET = exports.DEFAULT_APP_PORT = exports.GUEST_RESERVED_PORTS = exports.SESSION_SITE_HEADER = exports.PREVIEW_PORT_HEADER = exports.AGENT_SESSION_EVENT_TYPES = exports.AGENT_SESSION_COMMAND = exports.AGENT_SESSION_EVENT = void 0;
4
+ exports.agentSessionRoom = agentSessionRoom;
5
+ exports.agentSessionEventKey = agentSessionEventKey;
6
+ exports.requestUrl = requestUrl;
7
+ exports.isHiddenSitePath = isHiddenSitePath;
8
+ exports.parsePreviewPort = parsePreviewPort;
9
+ exports.parsePreviewTarget = parsePreviewTarget;
10
+ exports.defaultAppPort = defaultAppPort;
11
+ exports.workspaceFileHash = workspaceFileHash;
12
+ exports.isAgentSessionEvent = isAgentSessionEvent;
2
13
  // Wire contract between the in-VM agent and the platform. The guest is the owner of this
3
14
  // format: the gateway (services/gateway/src/services/sessions/agent-socket-server.ts) forwards it and
4
15
  // the API (services/api/src/services/sessions/agent-session-relay.service.ts) turns it into chat
@@ -8,11 +19,7 @@
8
19
  // Two directions on one Socket.IO connection:
9
20
  // guest -> platform AGENT_SESSION_EVENT (fire-and-forget, ordered by `seq`)
10
21
  // platform -> guest AGENT_SESSION_COMMAND (acknowledged)
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AGENT_SECRET_ENV_KEYS = exports.AGENT_ENV = exports.AGENT_SESSION_EVENT_TYPES = exports.AGENT_SESSION_COMMAND = exports.AGENT_SESSION_EVENT = void 0;
13
- exports.agentSessionRoom = agentSessionRoom;
14
- exports.agentSessionEventKey = agentSessionEventKey;
15
- exports.isAgentSessionEvent = isAgentSessionEvent;
22
+ const crypto_1 = require("crypto");
16
23
  exports.AGENT_SESSION_EVENT = 'agent-session:event';
17
24
  exports.AGENT_SESSION_COMMAND = 'agent-session:command';
18
25
  /** Socket.IO room the gateway joins every guest socket to, so the API can address one session. */
@@ -35,12 +42,107 @@ exports.AGENT_SESSION_EVENT_TYPES = [
35
42
  'question',
36
43
  'usage',
37
44
  'files',
45
+ 'file_changed',
46
+ 'file_deleted',
47
+ 'file_draft',
48
+ 'file_synced',
49
+ 'ports',
50
+ 'app',
38
51
  'checkpointed',
39
52
  'done',
40
53
  'error',
41
54
  'tool_call',
42
55
  'message',
43
56
  ];
57
+ // ── Live preview (gateway → guest :8080 → guest app port) ────────────────────────────────────
58
+ // Every engine reaches only the guest's port 8080, where the agent serves its lifecycle hooks and
59
+ // the preview proxy (runtime/preview-proxy.ts). The gateway sets this header on traffic for
60
+ // <vmId>-<port>.apps.<domain>; the proxy forwards such a request to localhost:<port> instead.
61
+ exports.PREVIEW_PORT_HEADER = 'x-builder-preview-port';
62
+ /**
63
+ * On what the gateway asks the api about a session's URL. A browser can't set it on a navigation, so
64
+ * a link to the api's route for that never runs a session's page on the api's own origin.
65
+ */
66
+ exports.SESSION_SITE_HEADER = 'x-builder-session-site';
67
+ /**
68
+ * Whether a URL path holds a dotfile or dot-folder at any depth (.env, .git, the platform's own
69
+ * .builder), or a `.`/`..` segment. An app's URL never serves one from its files; .well-known is
70
+ * the exception.
71
+ */
72
+ /**
73
+ * A request's target as a URL, to read its path and query. Anyone can send any target, and
74
+ * `new URL(target, base)` throws on `//` and reads `//host/path` as a host: this does neither,
75
+ * so leading slashes collapse as most servers treat them.
76
+ */
77
+ function requestUrl(target) {
78
+ return new URL(`http://request.invalid/${(target !== null && target !== void 0 ? target : '').replace(/^[/\\]+/, '')}`);
79
+ }
80
+ function isHiddenSitePath(pathname) {
81
+ return pathname.split('/').some((part) => part.startsWith('.') && part !== '.well-known');
82
+ }
83
+ /** The guest's own listeners: the hook/preview server, dropbear, and Lambda's shell agent. */
84
+ exports.GUEST_RESERVED_PORTS = [8080, 2222, 8022];
85
+ /**
86
+ * The port apps are told to listen on ($PORT for the agent's commands). A session's own URL
87
+ * (<sessionId>.apps.<domain>) opens this one when it listens, else the lowest port that does.
88
+ */
89
+ exports.DEFAULT_APP_PORT = 3000;
90
+ /**
91
+ * PREVIEW_PORT_HEADER's value for a session's own URL (no port in it): the guest picks the target
92
+ * itself, by the app's rewrites when the workspace holds one, else DEFAULT_APP_PORT or the
93
+ * lowest listening port. Never parsed from a hostname.
94
+ */
95
+ exports.APP_PREVIEW_TARGET = 'app';
96
+ /** A header value as a previewable port, or undefined. */
97
+ function parsePreviewPort(value) {
98
+ if (typeof value !== 'string' || !/^\d{1,5}$/.test(value))
99
+ return undefined;
100
+ const port = Number(value);
101
+ return port >= 1 && port <= 65535 && !exports.GUEST_RESERVED_PORTS.includes(port) ? port : undefined;
102
+ }
103
+ /** A PREVIEW_PORT_HEADER value: a previewable port, APP_PREVIEW_TARGET, or undefined. */
104
+ function parsePreviewTarget(value) {
105
+ return value === exports.APP_PREVIEW_TARGET ? exports.APP_PREVIEW_TARGET : parsePreviewPort(value);
106
+ }
107
+ /** The port a session's own URL opens without an app: DEFAULT_APP_PORT when it listens, else the lowest. */
108
+ function defaultAppPort(ports) {
109
+ if (ports.includes(exports.DEFAULT_APP_PORT))
110
+ return exports.DEFAULT_APP_PORT;
111
+ return ports.length ? Math.min(...ports) : undefined;
112
+ }
113
+ // ── App (builder.json) ─────────────────────────────────────────────────────────────────────
114
+ // The app a workspace holds — detected as Vercel does, with builder.json's overrides — is run by
115
+ // the guest (src/app): in a session VM with its dev commands, in a deployment (AGENT_MODE=app)
116
+ // built and started.
117
+ /**
118
+ * The app manifest, in the workspace's .builder folder; a session VM
119
+ * writes it. The one file of .builder that people see and edit as a session file.
120
+ */
121
+ exports.APP_CONFIG_FILE = '.builder/builder.json';
122
+ /** Which of a session's stored files are executable: object storage keeps no mode. */
123
+ /**
124
+ * Where a session's conversation used to be saved, in its workspace and so in its branch. It's kept
125
+ * in the runtime's state directory now (persistence/conversation-store.ts), but repos still hold old
126
+ * copies: they stay off main when a session merges, and out of what a new session starts from.
127
+ */
128
+ exports.SESSION_CONVERSATION_FILE = '.builder/conversation.json';
129
+ exports.WORKSPACE_EXECUTABLES_FILE = '.builder/executables.json';
130
+ /** Dependencies and build output: saved with a workspace, but not files people open. */
131
+ exports.WORKSPACE_GENERATED_DIRECTORIES = [
132
+ 'node_modules', '.venv', '__pycache__', '.next', '.nuxt', '.cache', '.turbo', 'dist', 'build', 'coverage',
133
+ ];
134
+ /** Guest-only: a deployment's app status as JSON. `/internal/*` is never routed publicly. */
135
+ exports.APP_STATUS_PATH = '/internal/app/status';
136
+ /** A built release's record of what it holds; written last, so a release that has one is complete. */
137
+ exports.RELEASE_MANIFEST_FILE = 'manifest.json';
138
+ /** The compressed copies of a built release's static files, best first. */
139
+ exports.SITE_ENCODINGS = ['br', 'gzip'];
140
+ /** What a built release's VM runs: its folders as they were built, dependencies and all. */
141
+ exports.RELEASE_ARCHIVE_FILE = 'run.tar.zst';
142
+ /** How both sides of workspace live sync name a version of a file. */
143
+ function workspaceFileHash(content) {
144
+ return (0, crypto_1.createHash)('sha256').update(content, 'utf8').digest('hex');
145
+ }
44
146
  function isAgentSessionEvent(value) {
45
147
  if (!value || typeof value !== 'object')
46
148
  return false;
@@ -50,13 +152,31 @@ function isAgentSessionEvent(value) {
50
152
  exports.AGENT_SESSION_EVENT_TYPES.includes(event.type));
51
153
  }
52
154
  // ── Environment contract (VM env → guest) ──────────────────────────────────────────────────
53
- // Documented here so the API's env builder (services/api/src/services/sessions/research-vm-env.ts) and
155
+ // Documented here so the API's env builder (services/api/src/services/sessions/session-vm-env.ts) and
54
156
  // the guest's config.ts agree on names. Values marked secret must never be persisted on the VM
55
157
  // record; the API sends them to the worker only.
56
158
  exports.AGENT_ENV = {
57
159
  SESSION_ID: 'SESSION_ID',
58
- /** 'task' (one AGENT_TASK run, then exit) or 'session' (stay up, serve chat turns). */
160
+ /**
161
+ * 'task' (one AGENT_TASK run, then exit), 'session' (stay up, serve chat turns), 'app' (a
162
+ * deployment: run the release's app on GUEST_HTTP_PORT, no agent) or 'build' (build a release
163
+ * and upload its output, no agent).
164
+ */
59
165
  AGENT_MODE: 'AGENT_MODE',
166
+ /** 'build' mode: where the release's output goes (the git service's route for that release). */
167
+ RELEASE_UPLOAD_URL: 'RELEASE_UPLOAD_URL',
168
+ /** secret, 'build' mode: may write only that release's output. */
169
+ RELEASE_UPLOAD_TOKEN: 'RELEASE_UPLOAD_TOKEN',
170
+ /** 'app' mode: a release built ahead of time: where the files its VM runs are, read with ACCESS_TOKEN. */
171
+ RELEASE_ARTIFACTS_URL: 'RELEASE_ARTIFACTS_URL',
172
+ /** 'app' mode: the release being run, so a VM restarted on its own disk skips install and build. */
173
+ APP_RELEASE_ID: 'APP_RELEASE_ID',
174
+ /** 'app' and build modes: the app's directory in the release's repository. */
175
+ APP_ROOT_DIR: 'APP_ROOT_DIR',
176
+ /** 'app' and build modes: the commit to check out. */
177
+ GIT_COMMIT: 'GIT_COMMIT',
178
+ /** The JSON schema the builder.json a session VM writes names as its `$schema`; written down, never fetched. */
179
+ APP_SCHEMA_URL: 'APP_SCHEMA_URL',
60
180
  /** 'coding' (default) or 'research'. */
61
181
  AGENT_PROFILE: 'AGENT_PROFILE',
62
182
  AGENT_TASK: 'AGENT_TASK',
@@ -66,6 +186,8 @@ exports.AGENT_ENV = {
66
186
  /** Total tokens the session may spend before it pauses and asks whether to continue. */
67
187
  AGENT_TOKEN_BUDGET: 'AGENT_TOKEN_BUDGET',
68
188
  AGENT_WORKSPACE_DIR: 'AGENT_WORKSPACE_DIR',
189
+ /** The runtime's own files (its conversation, its git data), which nothing it runs can read. */
190
+ AGENT_STATE_DIR: 'AGENT_STATE_DIR',
69
191
  /** The gateway's agent socket; the guest authenticates to it with ACCESS_TOKEN (session-scoped). */
70
192
  AGENT_SOCKET_URL: 'AGENT_SOCKET_URL',
71
193
  /** secret: model provider keys (one of them) */
@@ -96,6 +218,24 @@ exports.AGENT_ENV = {
96
218
  */
97
219
  ACCESS_TOKEN: 'ACCESS_TOKEN',
98
220
  };
221
+ /** The settings that deliver a release to its VM; the rest of a deployed VM's env is the app's own. */
222
+ exports.RELEASE_DELIVERY_ENV = [
223
+ exports.AGENT_ENV.ACCESS_TOKEN,
224
+ exports.AGENT_ENV.AGENT_MODE,
225
+ exports.AGENT_ENV.AGENT_WORKSPACE_DIR,
226
+ exports.AGENT_ENV.SESSION_STORAGE_URL,
227
+ exports.AGENT_ENV.GIT_SERVER_URL,
228
+ exports.AGENT_ENV.GIT_REPOSITORY,
229
+ exports.AGENT_ENV.GIT_REPOSITORY_DIR,
230
+ exports.AGENT_ENV.GIT_BRANCH,
231
+ exports.AGENT_ENV.GIT_COMMIT,
232
+ exports.AGENT_ENV.APP_ROOT_DIR,
233
+ exports.AGENT_ENV.APP_RELEASE_ID,
234
+ exports.AGENT_ENV.RELEASE_UPLOAD_URL,
235
+ exports.AGENT_ENV.RELEASE_UPLOAD_TOKEN,
236
+ exports.AGENT_ENV.RELEASE_ARTIFACTS_URL,
237
+ 'APP_WORK_DIR',
238
+ ];
99
239
  exports.AGENT_SECRET_ENV_KEYS = [
100
240
  exports.AGENT_ENV.OPENROUTER_API_KEY,
101
241
  exports.AGENT_ENV.ANTHROPIC_API_KEY,
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/transport/protocol.ts"],"names":[],"mappings":";AAAA,yFAAyF;AACzF,sGAAsG;AACtG,iGAAiG;AACjG,8FAA8F;AAC9F,wEAAwE;AACxE,EAAE;AACF,8CAA8C;AAC9C,kFAAkF;AAClF,6DAA6D;;;AAM7D,4CAEC;AAyFD,oDAGC;AAoBD,kDAQC;AA9HY,QAAA,mBAAmB,GAAG,qBAA8B,CAAA;AACpD,QAAA,qBAAqB,GAAG,uBAAgC,CAAA;AAErE,kGAAkG;AAClG,SAAgB,gBAAgB,CAAC,SAAiB;IAChD,OAAO,iBAAiB,SAAS,EAAE,CAAA;AACrC,CAAC;AAyFD,SAAgB,oBAAoB,CAAC,KAAwB;;IAC3D,mFAAmF;IACnF,OAAO,qBAAqB,KAAK,CAAC,SAAS,IAAI,MAAA,KAAK,CAAC,UAAU,mCAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,GAAG,EAAE,CAAA;AACnG,CAAC;AAEY,QAAA,yBAAyB,GAAqC;IACzE,OAAO;IACP,YAAY;IACZ,YAAY;IACZ,iBAAiB;IACjB,iBAAiB;IACjB,kBAAkB;IAClB,UAAU;IACV,UAAU;IACV,OAAO;IACP,OAAO;IACP,cAAc;IACd,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;CACV,CAAA;AAED,SAAgB,mBAAmB,CAAC,KAAc;IAChD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CA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;IAC5B,iBAAS,CAAC,iBAAiB;IAC3B,iBAAS,CAAC,qBAAqB;IAC/B,iBAAS,CAAC,wBAAwB;IAClC,iBAAS,CAAC,YAAY;IACtB,iBAAS,CAAC,gBAAgB;CAC3B,CAAA"}
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/transport/protocol.ts"],"names":[],"mappings":";;;AAeA,4CAEC;AA6HD,oDAGC;AA+CD,gCAEC;AAED,4CAEC;AAiBD,4CAIC;AAGD,gDAEC;AAGD,wCAGC;AA4ED,8CAEC;AAED,kDAQC;AA9TD,yFAAyF;AACzF,sGAAsG;AACtG,iGAAiG;AACjG,8FAA8F;AAC9F,wEAAwE;AACxE,EAAE;AACF,8CAA8C;AAC9C,kFAAkF;AAClF,6DAA6D;AAC7D,mCAAmC;AAEtB,QAAA,mBAAmB,GAAG,qBAA8B,CAAA;AACpD,QAAA,qBAAqB,GAAG,uBAAgC,CAAA;AAErE,kGAAkG;AAClG,SAAgB,gBAAgB,CAAC,SAAiB;IAChD,OAAO,iBAAiB,SAAS,EAAE,CAAA;AACrC,CAAC;AA6HD,SAAgB,oBAAoB,CAAC,KAAwB;;IAC3D,mFAAmF;IACnF,OAAO,qBAAqB,KAAK,CAAC,SAAS,IAAI,MAAA,KAAK,CAAC,UAAU,mCAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,GAAG,EAAE,CAAA;AACnG,CAAC;AAEY,QAAA,yBAAyB,GAAqC;IACzE,OAAO;IACP,YAAY;IACZ,YAAY;IACZ,iBAAiB;IACjB,iBAAiB;IACjB,kBAAkB;IAClB,UAAU;IACV,UAAU;IACV,OAAO;IACP,OAAO;IACP,cAAc;IACd,cAAc;IACd,YAAY;IACZ,aAAa;IACb,OAAO;IACP,KAAK;IACL,cAAc;IACd,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;CACV,CAAA;AAED,gGAAgG;AAChG,kGAAkG;AAClG,4FAA4F;AAC5F,8FAA8F;AAEjF,QAAA,mBAA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A0B;IACpD,mEAAmE;IACnE,wBAAwB,EAAE,0BAA0B;IACpD,uDAAuD;IACvD,8BAA8B,EAAE,gCAAgC;IAChE,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,kBAAkB,EAAE,oBAAoB;IACxC,oFAAoF;IACpF,UAAU,EAAE,YAAY;IACxB,mBAAmB,EAAE,qBAAqB;IAC1C;;;OAGG;IACH,YAAY,EAAE,cAAc;CACpB,CAAA;AAEV,uGAAuG;AAC1F,QAAA,oBAAoB,GAAsB;IACrD,iBAAS,CAAC,YAAY;IACtB,iBAAS,CAAC,UAAU;IACpB,iBAAS,CAAC,mBAAmB;IAC7B,iBAAS,CAAC,mBAAmB;IAC7B,iBAAS,CAAC,cAAc;IACxB,iBAAS,CAAC,cAAc;IACxB,iBAAS,CAAC,kBAAkB;IAC5B,iBAAS,CAAC,UAAU;IACpB,iBAAS,CAAC,UAAU;IACpB,iBAAS,CAAC,YAAY;IACtB,iBAAS,CAAC,cAAc;IACxB,iBAAS,CAAC,kBAAkB;IAC5B,iBAAS,CAAC,oBAAoB;IAC9B,iBAAS,CAAC,qBAAqB;IAC/B,cAAc;CACf,CAAA;AAEY,QAAA,qBAAqB,GAAsB;IACtD,iBAAS,CAAC,kBAAkB;IAC5B,iBAAS,CAAC,iBAAiB;IAC3B,iBAAS,CAAC,qBAAqB;IAC/B,iBAAS,CAAC,wBAAwB;IAClC,iBAAS,CAAC,YAAY;IACtB,iBAAS,CAAC,gBAAgB;CAC3B,CAAA"}
@@ -19,6 +19,18 @@ const protocol_1 = require("./protocol");
19
19
  strict_1.default.equal((0, protocol_1.isAgentSessionEvent)({ type: 'done' }), false);
20
20
  strict_1.default.equal((0, protocol_1.isAgentSessionEvent)(null), false);
21
21
  });
22
+ (0, node_test_1.it)('accepts the app as a preview target only by name, never from a hostname port', () => {
23
+ strict_1.default.equal((0, protocol_1.parsePreviewTarget)('app'), 'app');
24
+ strict_1.default.equal((0, protocol_1.parsePreviewTarget)('5173'), 5173);
25
+ strict_1.default.equal((0, protocol_1.parsePreviewTarget)('8080'), undefined);
26
+ strict_1.default.equal((0, protocol_1.parsePreviewTarget)('apps'), undefined);
27
+ strict_1.default.equal((0, protocol_1.parsePreviewPort)('app'), undefined);
28
+ });
29
+ (0, node_test_1.it)("opens a session URL on the default app port when it listens, else the lowest", () => {
30
+ strict_1.default.equal((0, protocol_1.defaultAppPort)([5173, 3000]), 3000);
31
+ strict_1.default.equal((0, protocol_1.defaultAppPort)([5173, 4000]), 4000);
32
+ strict_1.default.equal((0, protocol_1.defaultAppPort)([]), undefined);
33
+ });
22
34
  (0, node_test_1.it)('names the per-session room the gateway joins guests to', () => {
23
35
  strict_1.default.equal((0, protocol_1.agentSessionRoom)('abc'), 'agent-session:abc');
24
36
  });
@@ -28,4 +40,33 @@ const protocol_1 = require("./protocol");
28
40
  }
29
41
  });
30
42
  });
43
+ (0, node_test_1.describe)('a request target', () => {
44
+ const read = (target) => {
45
+ const { pathname, search } = (0, protocol_1.requestUrl)(target);
46
+ return `${pathname}${search}`;
47
+ };
48
+ (0, node_test_1.it)('reads as itself when it\'s an ordinary one', () => {
49
+ strict_1.default.equal(read('/'), '/');
50
+ strict_1.default.equal(read('/a/b?x=1&y=2'), '/a/b?x=1&y=2');
51
+ strict_1.default.equal(read('/a%20b'), '/a%20b');
52
+ strict_1.default.equal(read(undefined), '/');
53
+ });
54
+ (0, node_test_1.it)('never throws, whatever is sent: new URL throws on these or reads a host from them', () => {
55
+ for (const target of ['//', '///', '//[', '//foo:bar', '//:', 'http://[', '\\\\', '/%', '/%zz', '*', '', ' ', '//\u0000', '/?', '#']) {
56
+ strict_1.default.doesNotThrow(() => (0, protocol_1.requestUrl)(target), target);
57
+ }
58
+ });
59
+ (0, node_test_1.it)('never takes a host from it, so routing and what\'s hidden see the real path', () => {
60
+ strict_1.default.equal(read('//'), '/');
61
+ strict_1.default.equal(read('//foo/bar?x=1'), '/foo/bar?x=1');
62
+ strict_1.default.equal(read('///foo'), '/foo');
63
+ strict_1.default.equal(read('\\\\foo/bar'), '/foo/bar');
64
+ strict_1.default.equal(read('//.builder/builder.json'), '/.builder/builder.json');
65
+ strict_1.default.equal((0, protocol_1.requestUrl)('//evil.example/x').host, 'request.invalid');
66
+ });
67
+ (0, node_test_1.it)('still resolves dot segments, which is what path checks rely on', () => {
68
+ strict_1.default.equal(read('/a/../.builder/x'), '/.builder/x');
69
+ strict_1.default.equal(read('/a/./b'), '/a/b');
70
+ });
71
+ });
31
72
  //# sourceMappingURL=protocol.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.test.js","sourceRoot":"","sources":["../../src/transport/protocol.test.ts"],"names":[],"mappings":";;;;;AAAA,gEAAuC;AACvC,yCAAwC;AACxC,yCAAkJ;AAElJ,IAAA,oBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,IAAA,cAAE,EAAC,sFAAsF,EAAE,GAAG,EAAE;QAC9F,MAAM,KAAK,GAAsB,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;QAC9K,gBAAM,CAAC,KAAK,CAAC,IAAA,+BAAoB,EAAC,KAAK,CAAC,EAAE,IAAA,+BAAoB,EAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAA;QAC7E,gBAAM,CAAC,QAAQ,CAAC,IAAA,+BAAoB,EAAC,KAAK,CAAC,EAAE,IAAA,+BAAoB,EAAC,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC,CAAC,CAAA;QAC5G,gBAAM,CAAC,QAAQ,CAAC,IAAA,+BAAoB,EAAC,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,EAAE,IAAA,+BAA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AAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAA;IACtC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,14 @@
1
+ /** Same cap as publish_results: past it a file is no longer mirrored (its last copy stays). */
2
+ export declare const MAX_SYNCED_FILE_BYTES: number;
3
+ /** Files mirrored per session; later ones are left out. */
4
+ export declare const MAX_SYNCED_FILES = 2000;
5
+ /** A workspace-relative POSIX path, without a leading ./ or /. */
6
+ export declare function normalizeSyncPath(relative: string): string;
7
+ /** Whether a directory's contents can be mirrored at all (it is also never watched otherwise). */
8
+ export declare function isSyncableDirectory(relative: string): boolean;
9
+ /** Whether live sync watches a directory: one it mirrors, or one holding a mirrored state file (.builder). */
10
+ export declare function isWatchedDirectory(relative: string): boolean;
11
+ export declare function isSyncablePath(relative: string): boolean;
12
+ /** The file as text, or undefined when it is binary (has a NUL byte) or too large to mirror. */
13
+ export declare function syncableText(buffer: Buffer): string | undefined;
14
+ //# sourceMappingURL=eligibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eligibility.d.ts","sourceRoot":"","sources":["../../src/workspace-sync/eligibility.ts"],"names":[],"mappings":"AAYA,+FAA+F;AAC/F,eAAO,MAAM,qBAAqB,QAAa,CAAA;AAC/C,2DAA2D;AAC3D,eAAO,MAAM,gBAAgB,OAAQ,CAAA;AAErC,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,kGAAkG;AAClG,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAI7D;AAED,8GAA8G;AAC9G,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG5D;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMxD;AAED,gGAAgG;AAChG,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG/D"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_SYNCED_FILES = exports.MAX_SYNCED_FILE_BYTES = void 0;
4
+ exports.normalizeSyncPath = normalizeSyncPath;
5
+ exports.isSyncableDirectory = isSyncableDirectory;
6
+ exports.isWatchedDirectory = isWatchedDirectory;
7
+ exports.isSyncablePath = isSyncablePath;
8
+ exports.syncableText = syncableText;
9
+ // Which workspace files live sync mirrors into the session: the text people would open, not
10
+ // dependencies, build output, VCS internals, logs or the agent's own state — but for the app
11
+ // manifest in that state, which people read and may edit.
12
+ const node_path_1 = require("node:path");
13
+ const protocol_1 = require("../transport/protocol");
14
+ /** Files under an excluded directory that are mirrored all the same. */
15
+ const MIRRORED_STATE_FILES = new Set([protocol_1.APP_CONFIG_FILE]);
16
+ const EXCLUDED_DIRECTORIES = new Set(['.git', '.builder', ...protocol_1.WORKSPACE_GENERATED_DIRECTORIES]);
17
+ const EXCLUDED_FILES = /(\.sqlite(-journal)?|\.log|^nohup\.out)$/;
18
+ /** Same cap as publish_results: past it a file is no longer mirrored (its last copy stays). */
19
+ exports.MAX_SYNCED_FILE_BYTES = 512 * 1024;
20
+ /** Files mirrored per session; later ones are left out. */
21
+ exports.MAX_SYNCED_FILES = 2000;
22
+ /** A workspace-relative POSIX path, without a leading ./ or /. */
23
+ function normalizeSyncPath(relative) {
24
+ return relative.split(/[\\/]+/).filter((part) => part && part !== '.').join('/');
25
+ }
26
+ /** Whether a directory's contents can be mirrored at all (it is also never watched otherwise). */
27
+ function isSyncableDirectory(relative) {
28
+ const path = normalizeSyncPath(relative);
29
+ if (path === 'data/attachments' || path.startsWith('data/attachments/'))
30
+ return false;
31
+ return !path.split('/').some((part) => EXCLUDED_DIRECTORIES.has(part));
32
+ }
33
+ /** Whether live sync watches a directory: one it mirrors, or one holding a mirrored state file (.builder). */
34
+ function isWatchedDirectory(relative) {
35
+ const path = normalizeSyncPath(relative);
36
+ return isSyncableDirectory(path) || [...MIRRORED_STATE_FILES].some((file) => node_path_1.posix.dirname(file) === path);
37
+ }
38
+ function isSyncablePath(relative) {
39
+ const path = normalizeSyncPath(relative);
40
+ if (!path || path.split('/').includes('..'))
41
+ return false;
42
+ if (MIRRORED_STATE_FILES.has(path))
43
+ return true;
44
+ const parts = path.split('/');
45
+ return isSyncableDirectory(parts.slice(0, -1).join('/')) && !EXCLUDED_FILES.test(parts[parts.length - 1]);
46
+ }
47
+ /** The file as text, or undefined when it is binary (has a NUL byte) or too large to mirror. */
48
+ function syncableText(buffer) {
49
+ if (buffer.byteLength > exports.MAX_SYNCED_FILE_BYTES || buffer.includes(0))
50
+ return undefined;
51
+ return buffer.toString('utf8');
52
+ }
53
+ //# sourceMappingURL=eligibility.js.map