@superblocksteam/gateway 2.0.161-next.0 → 2.0.162-next.0

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 (232) hide show
  1. package/README.md +135 -39
  2. package/dist/capabilities/lifecycle.d.ts +46 -29
  3. package/dist/capabilities/lifecycle.js +1731 -843
  4. package/dist/capabilities/lifecycle.js.map +1 -1
  5. package/dist/capabilities/query-integration.d.ts +14 -0
  6. package/dist/capabilities/query-integration.js +172 -0
  7. package/dist/capabilities/query-integration.js.map +1 -0
  8. package/dist/capabilities/source-files-archive.d.ts +11 -0
  9. package/dist/capabilities/source-files-archive.js +54 -0
  10. package/dist/capabilities/source-files-archive.js.map +1 -0
  11. package/dist/capabilities/types.d.ts +197 -119
  12. package/dist/capabilities/types.js +45 -6
  13. package/dist/capabilities/types.js.map +1 -1
  14. package/dist/capture/browser-contract.d.ts +15 -5
  15. package/dist/capture/browser-contract.js +13 -3
  16. package/dist/capture/browser-contract.js.map +1 -1
  17. package/dist/capture/browser-instructions.d.ts +3 -2
  18. package/dist/capture/browser-instructions.js +3 -2
  19. package/dist/capture/browser-instructions.js.map +1 -1
  20. package/dist/capture/mode.d.ts +8 -1
  21. package/dist/capture/mode.js +22 -2
  22. package/dist/capture/mode.js.map +1 -1
  23. package/dist/config.d.ts +22 -23
  24. package/dist/config.js +13 -12
  25. package/dist/config.js.map +1 -1
  26. package/dist/deps.d.ts +7 -7
  27. package/dist/index.d.ts +2 -4
  28. package/dist/index.js +2 -4
  29. package/dist/index.js.map +1 -1
  30. package/dist/integrations/read-only-postgres-query.d.ts +2 -0
  31. package/dist/integrations/read-only-postgres-query.js +164 -0
  32. package/dist/integrations/read-only-postgres-query.js.map +1 -0
  33. package/dist/main.js +1 -1
  34. package/dist/main.js.map +1 -1
  35. package/dist/playwright/ensure-chromium.d.ts +5 -7
  36. package/dist/playwright/ensure-chromium.js +13 -13
  37. package/dist/playwright/ensure-chromium.js.map +1 -1
  38. package/dist/preview/capture-screenshot.d.ts +30 -4
  39. package/dist/preview/capture-screenshot.js +67 -17
  40. package/dist/preview/capture-screenshot.js.map +1 -1
  41. package/dist/preview/viewer-url.js +3 -1
  42. package/dist/preview/viewer-url.js.map +1 -1
  43. package/dist/process/fault-barrier.js +1 -1
  44. package/dist/process/fault-barrier.js.map +1 -1
  45. package/dist/sabs/agent-facing-text.d.ts +2 -0
  46. package/dist/sabs/agent-facing-text.js +56 -2
  47. package/dist/sabs/agent-facing-text.js.map +1 -1
  48. package/dist/sabs/app-state.d.ts +126 -0
  49. package/dist/sabs/app-state.js +332 -0
  50. package/dist/sabs/app-state.js.map +1 -0
  51. package/dist/sabs/awaited-decision.d.ts +49 -0
  52. package/dist/sabs/awaited-decision.js +129 -0
  53. package/dist/sabs/awaited-decision.js.map +1 -0
  54. package/dist/sabs/editor-client-methods.d.ts +23 -5
  55. package/dist/sabs/editor-client-methods.js +45 -4
  56. package/dist/sabs/editor-client-methods.js.map +1 -1
  57. package/dist/sabs/editor-socket.d.ts +85 -0
  58. package/dist/sabs/editor-socket.js +67 -0
  59. package/dist/sabs/editor-socket.js.map +1 -0
  60. package/dist/sabs/session-peer.d.ts +119 -82
  61. package/dist/sabs/session-peer.js +10 -1
  62. package/dist/sabs/session-peer.js.map +1 -1
  63. package/dist/sabs/streamed-reply.d.ts +45 -0
  64. package/dist/sabs/streamed-reply.js +125 -0
  65. package/dist/sabs/streamed-reply.js.map +1 -0
  66. package/dist/sabs/turn-collector.d.ts +50 -35
  67. package/dist/sabs/turn-collector.js +110 -176
  68. package/dist/sabs/turn-collector.js.map +1 -1
  69. package/dist/sabs/websocket-session-peer.d.ts +104 -69
  70. package/dist/sabs/websocket-session-peer.js +1329 -475
  71. package/dist/sabs/websocket-session-peer.js.map +1 -1
  72. package/dist/server/client.d.ts +41 -9
  73. package/dist/server/client.js +126 -21
  74. package/dist/server/client.js.map +1 -1
  75. package/dist/start.d.ts +1 -1
  76. package/dist/start.js +30 -8
  77. package/dist/start.js.map +1 -1
  78. package/dist/stores/memory.d.ts +46 -0
  79. package/dist/stores/memory.js +163 -0
  80. package/dist/stores/memory.js.map +1 -0
  81. package/dist/stores/types.d.ts +92 -0
  82. package/dist/stores/types.js +11 -0
  83. package/dist/stores/types.js.map +1 -0
  84. package/dist/telemetry/mcp-client.d.ts +6 -1
  85. package/dist/telemetry/mcp-client.js +100 -4
  86. package/dist/telemetry/mcp-client.js.map +1 -1
  87. package/dist/telemetry/metrics.d.ts +12 -3
  88. package/dist/telemetry/metrics.js +60 -14
  89. package/dist/telemetry/metrics.js.map +1 -1
  90. package/dist/telemetry/runtime.js +4 -6
  91. package/dist/telemetry/runtime.js.map +1 -1
  92. package/dist/transports/mcp/admin-tools.d.ts +8 -0
  93. package/dist/transports/mcp/admin-tools.js +115 -4
  94. package/dist/transports/mcp/admin-tools.js.map +1 -1
  95. package/dist/transports/mcp/app-status-html.d.ts +4 -8
  96. package/dist/transports/mcp/app-status-html.js +336 -128
  97. package/dist/transports/mcp/app-status-html.js.map +1 -1
  98. package/dist/transports/mcp/client-presentation.d.ts +16 -0
  99. package/dist/transports/mcp/client-presentation.js +13 -0
  100. package/dist/transports/mcp/client-presentation.js.map +1 -0
  101. package/dist/transports/mcp/cowork-editor-url.d.ts +6 -0
  102. package/dist/transports/mcp/cowork-editor-url.js +10 -0
  103. package/dist/transports/mcp/cowork-editor-url.js.map +1 -0
  104. package/dist/transports/mcp/decision-card-html.d.ts +26 -0
  105. package/dist/transports/mcp/decision-card-html.js +876 -0
  106. package/dist/transports/mcp/decision-card-html.js.map +1 -0
  107. package/dist/transports/mcp/decision-elicitation.d.ts +42 -0
  108. package/dist/transports/mcp/decision-elicitation.js +59 -0
  109. package/dist/transports/mcp/decision-elicitation.js.map +1 -1
  110. package/dist/transports/mcp/editor-document-probe.d.ts +4 -0
  111. package/dist/transports/mcp/editor-document-probe.js +35 -0
  112. package/dist/transports/mcp/editor-document-probe.js.map +1 -0
  113. package/dist/transports/mcp/editor-integration-setup-url.d.ts +14 -0
  114. package/dist/transports/mcp/editor-integration-setup-url.js +29 -0
  115. package/dist/transports/mcp/editor-integration-setup-url.js.map +1 -0
  116. package/dist/transports/mcp/format-tool-content.d.ts +13 -18
  117. package/dist/transports/mcp/format-tool-content.js +172 -13
  118. package/dist/transports/mcp/format-tool-content.js.map +1 -1
  119. package/dist/transports/mcp/instructions/index.d.ts +23 -0
  120. package/dist/transports/mcp/instructions/index.js +81 -0
  121. package/dist/transports/mcp/instructions/index.js.map +1 -0
  122. package/dist/transports/mcp/instructions/result.d.ts +18 -0
  123. package/dist/transports/mcp/instructions/result.js +58 -0
  124. package/dist/transports/mcp/instructions/result.js.map +1 -0
  125. package/dist/transports/mcp/instructions/tools/ask-user.d.ts +2 -0
  126. package/dist/transports/mcp/instructions/tools/ask-user.js +20 -0
  127. package/dist/transports/mcp/instructions/tools/ask-user.js.map +1 -0
  128. package/dist/transports/mcp/instructions/tools/build-app.d.ts +4 -0
  129. package/dist/transports/mcp/instructions/tools/build-app.js +54 -0
  130. package/dist/transports/mcp/instructions/tools/build-app.js.map +1 -0
  131. package/dist/transports/mcp/instructions/tools/check-app-progress.d.ts +3 -0
  132. package/dist/transports/mcp/instructions/tools/check-app-progress.js +79 -0
  133. package/dist/transports/mcp/instructions/tools/check-app-progress.js.map +1 -0
  134. package/dist/transports/mcp/instructions/tools/check-publish-progress.d.ts +3 -0
  135. package/dist/transports/mcp/instructions/tools/check-publish-progress.js +23 -0
  136. package/dist/transports/mcp/instructions/tools/check-publish-progress.js.map +1 -0
  137. package/dist/transports/mcp/instructions/tools/copy.d.ts +18 -0
  138. package/dist/transports/mcp/instructions/tools/copy.js +49 -0
  139. package/dist/transports/mcp/instructions/tools/copy.js.map +1 -0
  140. package/dist/transports/mcp/instructions/tools/create-integration.d.ts +4 -0
  141. package/dist/transports/mcp/instructions/tools/create-integration.js +41 -0
  142. package/dist/transports/mcp/instructions/tools/create-integration.js.map +1 -0
  143. package/dist/transports/mcp/instructions/tools/edit-app.d.ts +3 -0
  144. package/dist/transports/mcp/instructions/tools/edit-app.js +18 -0
  145. package/dist/transports/mcp/instructions/tools/edit-app.js.map +1 -0
  146. package/dist/transports/mcp/instructions/tools/get-app.d.ts +3 -0
  147. package/dist/transports/mcp/instructions/tools/get-app.js +49 -0
  148. package/dist/transports/mcp/instructions/tools/get-app.js.map +1 -0
  149. package/dist/transports/mcp/instructions/tools/get-integration-metadata.d.ts +2 -0
  150. package/dist/transports/mcp/instructions/tools/get-integration-metadata.js +13 -0
  151. package/dist/transports/mcp/instructions/tools/get-integration-metadata.js.map +1 -0
  152. package/dist/transports/mcp/instructions/tools/index.d.ts +7 -0
  153. package/dist/transports/mcp/instructions/tools/index.js +31 -0
  154. package/dist/transports/mcp/instructions/tools/index.js.map +1 -0
  155. package/dist/transports/mcp/instructions/tools/publish-app.d.ts +3 -0
  156. package/dist/transports/mcp/instructions/tools/publish-app.js +23 -0
  157. package/dist/transports/mcp/instructions/tools/publish-app.js.map +1 -0
  158. package/dist/transports/mcp/instructions/tools/start-app.d.ts +3 -0
  159. package/dist/transports/mcp/instructions/tools/start-app.js +22 -0
  160. package/dist/transports/mcp/instructions/tools/start-app.js.map +1 -0
  161. package/dist/transports/mcp/instructions/tools/upload-artifact.d.ts +2 -0
  162. package/dist/transports/mcp/instructions/tools/upload-artifact.js +13 -0
  163. package/dist/transports/mcp/instructions/tools/upload-artifact.js.map +1 -0
  164. package/dist/transports/mcp/mcp-app-brand-css.d.ts +1 -0
  165. package/dist/transports/mcp/mcp-app-brand-css.js +180 -0
  166. package/dist/transports/mcp/mcp-app-brand-css.js.map +1 -0
  167. package/dist/transports/mcp/mount.d.ts +14 -1
  168. package/dist/transports/mcp/mount.js +729 -172
  169. package/dist/transports/mcp/mount.js.map +1 -1
  170. package/dist/transports/mcp/native-browser-presence.d.ts +45 -0
  171. package/dist/transports/mcp/native-browser-presence.js +158 -0
  172. package/dist/transports/mcp/native-browser-presence.js.map +1 -0
  173. package/dist/transports/mcp/plan-approval.d.ts +44 -0
  174. package/dist/transports/mcp/plan-approval.js +179 -0
  175. package/dist/transports/mcp/plan-approval.js.map +1 -0
  176. package/dist/transports/mcp/session-directory.d.ts +7 -0
  177. package/dist/transports/mcp/session-directory.js +18 -0
  178. package/dist/transports/mcp/session-directory.js.map +1 -0
  179. package/dist/transports/mcp/tool-names.d.ts +2 -0
  180. package/dist/transports/mcp/tool-names.js +2 -0
  181. package/dist/transports/mcp/tool-names.js.map +1 -0
  182. package/package.json +16 -7
  183. package/skills/superblocks-build/SKILL.md +59 -0
  184. package/skills/superblocks-import/SKILL.md +125 -0
  185. package/dist/capabilities/import-prompt.d.ts +0 -11
  186. package/dist/capabilities/import-prompt.js +0 -96
  187. package/dist/capabilities/import-prompt.js.map +0 -1
  188. package/dist/capabilities/persisted-progress.d.ts +0 -46
  189. package/dist/capabilities/persisted-progress.js +0 -246
  190. package/dist/capabilities/persisted-progress.js.map +0 -1
  191. package/dist/events/cursor.d.ts +0 -43
  192. package/dist/events/cursor.js +0 -78
  193. package/dist/events/cursor.js.map +0 -1
  194. package/dist/events/memory-event-store.d.ts +0 -34
  195. package/dist/events/memory-event-store.js +0 -110
  196. package/dist/events/memory-event-store.js.map +0 -1
  197. package/dist/events/merge.d.ts +0 -23
  198. package/dist/events/merge.js +0 -97
  199. package/dist/events/merge.js.map +0 -1
  200. package/dist/events/normalized-collector.d.ts +0 -62
  201. package/dist/events/normalized-collector.js +0 -156
  202. package/dist/events/normalized-collector.js.map +0 -1
  203. package/dist/events/schema.d.ts +0 -9
  204. package/dist/events/schema.js +0 -93
  205. package/dist/events/schema.js.map +0 -1
  206. package/dist/events/snapshot.d.ts +0 -32
  207. package/dist/events/snapshot.js +0 -57
  208. package/dist/events/snapshot.js.map +0 -1
  209. package/dist/events/stream-key.d.ts +0 -2
  210. package/dist/events/stream-key.js +0 -31
  211. package/dist/events/stream-key.js.map +0 -1
  212. package/dist/events/types.d.ts +0 -179
  213. package/dist/events/types.js +0 -66
  214. package/dist/events/types.js.map +0 -1
  215. package/dist/resume/memory-progress-store.d.ts +0 -39
  216. package/dist/resume/memory-progress-store.js +0 -82
  217. package/dist/resume/memory-progress-store.js.map +0 -1
  218. package/dist/resume/memory-recent-app-store.d.ts +0 -14
  219. package/dist/resume/memory-recent-app-store.js +0 -27
  220. package/dist/resume/memory-recent-app-store.js.map +0 -1
  221. package/dist/resume/memory-turn-store.d.ts +0 -18
  222. package/dist/resume/memory-turn-store.js +0 -73
  223. package/dist/resume/memory-turn-store.js.map +0 -1
  224. package/dist/resume/progress-key.d.ts +0 -21
  225. package/dist/resume/progress-key.js +0 -58
  226. package/dist/resume/progress-key.js.map +0 -1
  227. package/dist/resume/stores.d.ts +0 -14
  228. package/dist/resume/stores.js +0 -18
  229. package/dist/resume/stores.js.map +0 -1
  230. package/dist/resume/types.d.ts +0 -124
  231. package/dist/resume/types.js +0 -13
  232. package/dist/resume/types.js.map +0 -1
@@ -1,2 +1,11 @@
1
- export {};
1
+ export class PromptNotSentError extends Error {
2
+ recoveryAction;
3
+ retryable;
4
+ constructor(message, cause, options = {}) {
5
+ super(message, cause === undefined ? undefined : { cause });
6
+ this.name = "PromptNotSentError";
7
+ this.recoveryAction = options.recoveryAction;
8
+ this.retryable = options.retryable;
9
+ }
10
+ }
2
11
  //# sourceMappingURL=session-peer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-peer.js","sourceRoot":"","sources":["../../src/sabs/session-peer.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"session-peer.js","sourceRoot":"","sources":["../../src/sabs/session-peer.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,cAAc,CAA8B;IAC5C,SAAS,CAAoB;IAEtC,YACE,OAAe,EACf,KAAe,EACf,UAGI,EAAE;QAEN,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACrC,CAAC;CACF"}
@@ -0,0 +1,45 @@
1
+ export type StreamedReplyOptions = {
2
+ /** Injected so the chunking windows are testable without real time. */
3
+ now?: () => number;
4
+ };
5
+ /**
6
+ * Clark's reply as it streams, turned into lines a person can read.
7
+ *
8
+ * Two jobs, both about presentation rather than about the turn: accumulate the
9
+ * text deltas into the reply the turn will report, and decide when enough of
10
+ * it has arrived to be worth showing. It holds a partial sentence back so
11
+ * lines read as sentences, but never for so long that a slow tool call looks
12
+ * like a hang.
13
+ */
14
+ export declare class StreamedReply {
15
+ private readonly onLine;
16
+ private readonly deltas;
17
+ private readonly now;
18
+ private streamedLen;
19
+ private lastProgressAt;
20
+ private lastLine;
21
+ private startsNewBlock;
22
+ constructor(onLine: (line: string) => void, options?: StreamedReplyOptions);
23
+ /** The reply so far, whether or not all of it has been shown. */
24
+ text(): string;
25
+ /** A `text-delta` push: more of the message Clark is still writing. */
26
+ appendDelta(delta: string): void;
27
+ /** Finish the current text block before the next streamed block starts. */
28
+ finishBlock(): void;
29
+ /**
30
+ * A final assistant message, which replaces the deltas for the same turn.
31
+ *
32
+ * When it finalizes text already shown, only the tail is new; when it is a
33
+ * fresh message, all of it is.
34
+ */
35
+ finalize(content: string): void;
36
+ /** Show whatever is still unreported, e.g. when the turn ends. */
37
+ flush(): void;
38
+ /**
39
+ * Single door for every progress line: blank lines and a line identical to
40
+ * the one before it are dropped, because the dev server repeats status
41
+ * pushes many times per build and repetition buries the text that matters.
42
+ */
43
+ emit(line: string): void;
44
+ private maybeEmit;
45
+ }
@@ -0,0 +1,125 @@
1
+ /**
2
+ * How much unshown text is enough to show on its own, without waiting for a
3
+ * sentence to finish.
4
+ */
5
+ const PROGRESS_CHAR_CHUNK = 400;
6
+ /** How long between progress lines before a short one is worth showing. */
7
+ const PROGRESS_MS_CHUNK = 1_500;
8
+ /** How long an unfinished sentence may be held back before it is shown anyway. */
9
+ const PROGRESS_STALE_MS = 4_000;
10
+ /**
11
+ * Clark's reply as it streams, turned into lines a person can read.
12
+ *
13
+ * Two jobs, both about presentation rather than about the turn: accumulate the
14
+ * text deltas into the reply the turn will report, and decide when enough of
15
+ * it has arrived to be worth showing. It holds a partial sentence back so
16
+ * lines read as sentences, but never for so long that a slow tool call looks
17
+ * like a hang.
18
+ */
19
+ export class StreamedReply {
20
+ onLine;
21
+ deltas = [];
22
+ now;
23
+ streamedLen = 0;
24
+ lastProgressAt = 0;
25
+ lastLine;
26
+ startsNewBlock = false;
27
+ constructor(onLine, options = {}) {
28
+ this.onLine = onLine;
29
+ this.now = options.now ?? (() => Date.now());
30
+ }
31
+ /** The reply so far, whether or not all of it has been shown. */
32
+ text() {
33
+ return this.deltas.join("");
34
+ }
35
+ /** A `text-delta` push: more of the message Clark is still writing. */
36
+ appendDelta(delta) {
37
+ if (this.startsNewBlock) {
38
+ this.startsNewBlock = false;
39
+ const text = this.text();
40
+ if (text && !text.endsWith("\n") && !delta.startsWith("\n")) {
41
+ this.deltas.push("\n");
42
+ this.streamedLen += 1;
43
+ }
44
+ }
45
+ this.deltas.push(delta);
46
+ this.maybeEmit();
47
+ }
48
+ /** Finish the current text block before the next streamed block starts. */
49
+ finishBlock() {
50
+ this.flush();
51
+ this.startsNewBlock = true;
52
+ }
53
+ /**
54
+ * A final assistant message, which replaces the deltas for the same turn.
55
+ *
56
+ * When it finalizes text already shown, only the tail is new; when it is a
57
+ * fresh message, all of it is.
58
+ */
59
+ finalize(content) {
60
+ this.startsNewBlock = false;
61
+ const alreadyStreamed = this.text().slice(0, this.streamedLen);
62
+ this.deltas.length = 0;
63
+ this.deltas.push(content);
64
+ if (!alreadyStreamed || !content.startsWith(alreadyStreamed)) {
65
+ this.streamedLen = 0;
66
+ }
67
+ this.flush();
68
+ }
69
+ /** Show whatever is still unreported, e.g. when the turn ends. */
70
+ flush() {
71
+ const pending = this.text().slice(this.streamedLen);
72
+ if (!pending.trim()) {
73
+ return;
74
+ }
75
+ this.streamedLen += pending.length;
76
+ this.emit(pending);
77
+ }
78
+ /**
79
+ * Single door for every progress line: blank lines and a line identical to
80
+ * the one before it are dropped, because the dev server repeats status
81
+ * pushes many times per build and repetition buries the text that matters.
82
+ */
83
+ emit(line) {
84
+ const trimmed = line.trim();
85
+ if (!trimmed || trimmed === this.lastLine) {
86
+ return;
87
+ }
88
+ this.lastLine = trimmed;
89
+ this.onLine(trimmed);
90
+ }
91
+ maybeEmit() {
92
+ const pending = this.text().slice(this.streamedLen);
93
+ const now = this.now();
94
+ if (pending.length < PROGRESS_CHAR_CHUNK &&
95
+ now - this.lastProgressAt < PROGRESS_MS_CHUNK) {
96
+ return;
97
+ }
98
+ // Waiting for a sentence to end keeps lines readable, but Clark can stop
99
+ // mid-sentence for a long tool call. Once a line has been held that long,
100
+ // showing it unfinished beats showing nothing.
101
+ const cut = sentenceCut(pending) ||
102
+ (now - this.lastProgressAt >= PROGRESS_STALE_MS ? pending.length : 0);
103
+ if (cut === 0) {
104
+ return;
105
+ }
106
+ this.lastProgressAt = now;
107
+ this.streamedLen += cut;
108
+ this.emit(pending.slice(0, cut));
109
+ }
110
+ }
111
+ function sentenceCut(text) {
112
+ const boundary = Math.max(text.lastIndexOf(". "), text.lastIndexOf(".\n"), text.lastIndexOf("! "), text.lastIndexOf("? "), text.lastIndexOf(":\n"), text.lastIndexOf("\n"));
113
+ if (boundary >= 0) {
114
+ return boundary + 1;
115
+ }
116
+ if (text.trimEnd().endsWith(".")) {
117
+ return text.length;
118
+ }
119
+ if (text.length < PROGRESS_CHAR_CHUNK) {
120
+ return 0;
121
+ }
122
+ const space = text.lastIndexOf(" ");
123
+ return space > 0 ? space : text.length;
124
+ }
125
+ //# sourceMappingURL=streamed-reply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streamed-reply.js","source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,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,GAAG,mBAAmB,EAAE,CAAC;QACtC,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACpC,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;AACzC,CAAC"}
@@ -3,6 +3,15 @@ import type { GenerationStatus, ViewStatus } from "./session-peer.js";
3
3
  /** Default quiet window after completed/idle before treating the job as done. */
4
4
  export declare const DEFAULT_SETTLE_MS = 12000;
5
5
  export type TurnDecision = {
6
+ integrations: Array<{
7
+ configuration: Record<string, unknown>;
8
+ /** The plugin's configuration form, so the host needs no lookup. */
9
+ configurationSchema?: Record<string, unknown>;
10
+ name?: string;
11
+ pluginId: string;
12
+ }>;
13
+ kind: "missing_integrations";
14
+ } | {
6
15
  kind: "multi_choice";
7
16
  messageId?: string;
8
17
  options: string[];
@@ -14,6 +23,15 @@ export type TurnDecision = {
14
23
  title?: string;
15
24
  };
16
25
  export type TurnCollectorOptions = {
26
+ /**
27
+ * The generation this turn started, as `aiGenerateWithQueue` named it.
28
+ *
29
+ * The ai-service runs generations of its own — the v2->v3 migration turn,
30
+ * the run an interrupt continues with — and each ends with its own terminal
31
+ * state on the same socket. Without this, one of those ends this turn and a
32
+ * build that is still running is reported finished. (APPS-5161)
33
+ */
34
+ generationId?: string;
17
35
  initialSyncStatus?: string;
18
36
  settleMs?: number;
19
37
  };
@@ -26,7 +44,6 @@ export type TurnCollectorOptions = {
26
44
  */
27
45
  export declare class TurnCollector {
28
46
  private readonly onProgress?;
29
- private readonly deltas;
30
47
  private readonly labels;
31
48
  private readonly states;
32
49
  private readonly settleMs;
@@ -39,10 +56,7 @@ export declare class TurnCollector {
39
56
  private readonly signals;
40
57
  /** Case id to name, so a later per-case update can be reported by name. */
41
58
  private readonly testCaseNames;
42
- private planChunks;
43
- private planMessageId;
44
- private planTitle;
45
- private multiChoice;
59
+ private readonly awaited;
46
60
  /**
47
61
  * Whether anything has arrived on the channel the dev server binds to a
48
62
  * single editor peer (Clark's messages and generation states). Draft and sync
@@ -51,14 +65,34 @@ export declare class TurnCollector {
51
65
  private clarkPushSeen;
52
66
  private lastEventReceivedAt;
53
67
  private notifyClarkPush;
54
- private lastProgressAt;
55
- private streamedLen;
56
- private lastLine;
57
68
  private settleTimer;
58
69
  private syncTimer;
59
70
  private notifySettled;
60
71
  private notifyInSync;
72
+ private generationId;
73
+ private readonly stream;
74
+ private streamedMessageType;
61
75
  constructor(onProgress?: ((message: string) => void) | undefined, options?: TurnCollectorOptions);
76
+ /**
77
+ * Names the generation this turn is collecting, once the prompt has been
78
+ * acknowledged.
79
+ *
80
+ * Set after the fact because the collector has to be listening before the
81
+ * prompt goes out - the session starts pushing as soon as it accepts it, and
82
+ * a collector attached afterwards would miss the opening of its own turn.
83
+ * Until it is named, every state is taken as this turn's, which is the
84
+ * behavior from before generations were named at all.
85
+ */
86
+ nameGeneration(generationId: string | undefined): void;
87
+ /**
88
+ * Whether a generation state is about the generation this turn started.
89
+ *
90
+ * Unnamed states are this turn's by default: a dev server from before the
91
+ * field says nothing about whose generation it is, and treating that silence
92
+ * as someone else's would leave every turn against an older sandbox waiting
93
+ * for a terminal state that never arrives.
94
+ */
95
+ private belongsToThisTurn;
62
96
  handle(event: ClarkPeerEvent): void;
63
97
  reply(): string;
64
98
  /**
@@ -66,18 +100,9 @@ export declare class TurnCollector {
66
100
  * Prefer plan over multi_choice when both arrived in the same turn.
67
101
  */
68
102
  decision(): TurnDecision | undefined;
69
- /**
70
- * When something last reached this turn, from either transport.
71
- *
72
- * The held socket is one of two ways a turn hears from its live edit - SABS
73
- * relays the same events - so a socket the gateway cannot get back is not
74
- * proof that nothing is reporting. This is what separates the two.
75
- *
76
- * Zero until the first event, which reads as "nothing has arrived yet"
77
- * against any later comparison.
78
- */
79
103
  lastEventAt(): number;
80
104
  status(): GenerationStatus | undefined;
105
+ isSettling(): boolean;
81
106
  viewableStatus(): ViewStatus;
82
107
  /**
83
108
  * Whether Clark left a draft the gateway still has to accept. Mirrors the
@@ -106,7 +131,6 @@ export declare class TurnCollector {
106
131
  }): Promise<boolean>;
107
132
  waitUntilTerminal(input: {
108
133
  signal?: AbortSignal;
109
- timeoutMs: number;
110
134
  }): Promise<GenerationStatus>;
111
135
  /**
112
136
  * Resolves once the dev server has flushed Clark's files. An unreported sync
@@ -122,8 +146,8 @@ export declare class TurnCollector {
122
146
  /** Records that the gateway committed Clark's draft into a checkpoint. */
123
147
  markCheckpointed(): void;
124
148
  /**
125
- * Drops pending timers and releases anyone still waiting, so a turn that
126
- * timed out or threw leaves nothing armed behind it.
149
+ * Drops pending timers and releases anyone still waiting, so a cancelled or
150
+ * failed turn leaves nothing armed behind it.
127
151
  */
128
152
  dispose(): void;
129
153
  private endSyncWait;
@@ -137,18 +161,9 @@ export declare class TurnCollector {
137
161
  private onGenerationState;
138
162
  private armSettle;
139
163
  private clearSettleTimer;
140
- /**
141
- * Reports the text Clark has streamed since the previous report, cut at the
142
- * last sentence end so nothing arrives mid-word and nothing arrives twice.
143
- */
144
- private maybeProgressText;
145
- /** Flushes whatever text is still unreported, e.g. when the turn ends. */
146
- private flushProgressText;
147
- /**
148
- * Single door for every progress line: blank lines and a line identical to
149
- * the one before it are dropped, because the dev server repeats status
150
- * pushes many times per build and repetition buries the text that matters.
151
- */
152
- private emit;
153
- private assembledPlan;
154
164
  }
165
+ /**
166
+ * Length of the leading part of `text` that ends on a sentence or line break,
167
+ * falling back to a word boundary once the text outgrows one chunk. Returns 0
168
+ * when there is no good place to cut yet.
169
+ */