@superblocksteam/gateway 2.0.0-SNAPSHOT.1d4c72c0ab174c21
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.
- package/LICENSE.txt +87 -0
- package/README.md +291 -0
- package/dist/agents/resolve-orchestrator-url.d.ts +22 -0
- package/dist/agents/resolve-orchestrator-url.js +38 -0
- package/dist/agents/resolve-orchestrator-url.js.map +1 -0
- package/dist/capabilities/integration-metadata.d.ts +28 -0
- package/dist/capabilities/integration-metadata.js +174 -0
- package/dist/capabilities/integration-metadata.js.map +1 -0
- package/dist/capabilities/lifecycle.d.ts +93 -0
- package/dist/capabilities/lifecycle.js +3450 -0
- package/dist/capabilities/lifecycle.js.map +1 -0
- package/dist/capabilities/query-integration.d.ts +14 -0
- package/dist/capabilities/query-integration.js +172 -0
- package/dist/capabilities/query-integration.js.map +1 -0
- package/dist/capabilities/source-files-archive.d.ts +11 -0
- package/dist/capabilities/source-files-archive.js +54 -0
- package/dist/capabilities/source-files-archive.js.map +1 -0
- package/dist/capabilities/types.d.ts +542 -0
- package/dist/capabilities/types.js +86 -0
- package/dist/capabilities/types.js.map +1 -0
- package/dist/capture/browser-contract.d.ts +46 -0
- package/dist/capture/browser-contract.js +34 -0
- package/dist/capture/browser-contract.js.map +1 -0
- package/dist/capture/browser-instructions.d.ts +10 -0
- package/dist/capture/browser-instructions.js +18 -0
- package/dist/capture/browser-instructions.js.map +1 -0
- package/dist/capture/capture-library-probe.d.ts +55 -0
- package/dist/capture/capture-library-probe.js +177 -0
- package/dist/capture/capture-library-probe.js.map +1 -0
- package/dist/capture/capture-library.d.ts +52 -0
- package/dist/capture/capture-library.js +249 -0
- package/dist/capture/capture-library.js.map +1 -0
- package/dist/capture/classify-library-paint.d.ts +21 -0
- package/dist/capture/classify-library-paint.js +13 -0
- package/dist/capture/classify-library-paint.js.map +1 -0
- package/dist/capture/host-mcp-scan.d.ts +16 -0
- package/dist/capture/host-mcp-scan.js +64 -0
- package/dist/capture/host-mcp-scan.js.map +1 -0
- package/dist/capture/library-parent-script.d.ts +35 -0
- package/dist/capture/library-parent-script.js +82 -0
- package/dist/capture/library-parent-script.js.map +1 -0
- package/dist/capture/mode.d.ts +29 -0
- package/dist/capture/mode.js +65 -0
- package/dist/capture/mode.js.map +1 -0
- package/dist/config.d.ts +148 -0
- package/dist/config.js +111 -0
- package/dist/config.js.map +1 -0
- package/dist/debug.d.ts +2 -0
- package/dist/debug.js +9 -0
- package/dist/debug.js.map +1 -0
- package/dist/deps.d.ts +38 -0
- package/dist/deps.js +2 -0
- package/dist/deps.js.map +1 -0
- package/dist/health/readiness.d.ts +99 -0
- package/dist/health/readiness.js +202 -0
- package/dist/health/readiness.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/filters.d.ts +8 -0
- package/dist/integrations/filters.js +40 -0
- package/dist/integrations/filters.js.map +1 -0
- package/dist/integrations/map.d.ts +27 -0
- package/dist/integrations/map.js +43 -0
- package/dist/integrations/map.js.map +1 -0
- package/dist/integrations/profile-key.d.ts +19 -0
- package/dist/integrations/profile-key.js +35 -0
- package/dist/integrations/profile-key.js.map +1 -0
- package/dist/integrations/read-only-postgres-query.d.ts +2 -0
- package/dist/integrations/read-only-postgres-query.js +164 -0
- package/dist/integrations/read-only-postgres-query.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +5 -0
- package/dist/main.js.map +1 -0
- package/dist/orchestrator/client.d.ts +62 -0
- package/dist/orchestrator/client.js +160 -0
- package/dist/orchestrator/client.js.map +1 -0
- package/dist/playwright/ensure-chromium.d.ts +24 -0
- package/dist/playwright/ensure-chromium.js +60 -0
- package/dist/playwright/ensure-chromium.js.map +1 -0
- package/dist/preview/capture-screenshot.d.ts +67 -0
- package/dist/preview/capture-screenshot.js +179 -0
- package/dist/preview/capture-screenshot.js.map +1 -0
- package/dist/preview/viewer-url.d.ts +82 -0
- package/dist/preview/viewer-url.js +130 -0
- package/dist/preview/viewer-url.js.map +1 -0
- package/dist/process/fault-barrier.d.ts +55 -0
- package/dist/process/fault-barrier.js +113 -0
- package/dist/process/fault-barrier.js.map +1 -0
- package/dist/sabs/agent-facing-text.d.ts +35 -0
- package/dist/sabs/agent-facing-text.js +165 -0
- package/dist/sabs/agent-facing-text.js.map +1 -0
- package/dist/sabs/app-state.d.ts +126 -0
- package/dist/sabs/app-state.js +332 -0
- package/dist/sabs/app-state.js.map +1 -0
- package/dist/sabs/awaited-decision.d.ts +47 -0
- package/dist/sabs/awaited-decision.js +124 -0
- package/dist/sabs/awaited-decision.js.map +1 -0
- package/dist/sabs/browser-context.d.ts +53 -0
- package/dist/sabs/browser-context.js +92 -0
- package/dist/sabs/browser-context.js.map +1 -0
- package/dist/sabs/editor-client-methods.d.ts +164 -0
- package/dist/sabs/editor-client-methods.js +750 -0
- package/dist/sabs/editor-client-methods.js.map +1 -0
- package/dist/sabs/editor-socket.d.ts +84 -0
- package/dist/sabs/editor-socket.js +64 -0
- package/dist/sabs/editor-socket.js.map +1 -0
- package/dist/sabs/recent-tool-runs.d.ts +14 -0
- package/dist/sabs/recent-tool-runs.js +61 -0
- package/dist/sabs/recent-tool-runs.js.map +1 -0
- package/dist/sabs/session-peer.d.ts +392 -0
- package/dist/sabs/session-peer.js +11 -0
- package/dist/sabs/session-peer.js.map +1 -0
- package/dist/sabs/streamed-reply.d.ts +42 -0
- package/dist/sabs/streamed-reply.js +110 -0
- package/dist/sabs/streamed-reply.js.map +1 -0
- package/dist/sabs/turn-collector.d.ts +169 -0
- package/dist/sabs/turn-collector.js +506 -0
- package/dist/sabs/turn-collector.js.map +1 -0
- package/dist/sabs/websocket-session-peer.d.ts +540 -0
- package/dist/sabs/websocket-session-peer.js +3289 -0
- package/dist/sabs/websocket-session-peer.js.map +1 -0
- package/dist/security/constant-time.d.ts +9 -0
- package/dist/security/constant-time.js +13 -0
- package/dist/security/constant-time.js.map +1 -0
- package/dist/server/client.d.ts +405 -0
- package/dist/server/client.js +684 -0
- package/dist/server/client.js.map +1 -0
- package/dist/server/identity-reads.d.ts +76 -0
- package/dist/server/identity-reads.js +209 -0
- package/dist/server/identity-reads.js.map +1 -0
- package/dist/start.d.ts +24 -0
- package/dist/start.js +81 -0
- package/dist/start.js.map +1 -0
- package/dist/stores/memory.d.ts +42 -0
- package/dist/stores/memory.js +121 -0
- package/dist/stores/memory.js.map +1 -0
- package/dist/stores/types.d.ts +74 -0
- package/dist/stores/types.js +11 -0
- package/dist/stores/types.js.map +1 -0
- package/dist/telemetry/mcp-client.d.ts +22 -0
- package/dist/telemetry/mcp-client.js +140 -0
- package/dist/telemetry/mcp-client.js.map +1 -0
- package/dist/telemetry/metrics.d.ts +41 -0
- package/dist/telemetry/metrics.js +103 -0
- package/dist/telemetry/metrics.js.map +1 -0
- package/dist/telemetry/runtime.d.ts +9 -0
- package/dist/telemetry/runtime.js +118 -0
- package/dist/telemetry/runtime.js.map +1 -0
- package/dist/transports/mcp/admin-tools.d.ts +56 -0
- package/dist/transports/mcp/admin-tools.js +252 -0
- package/dist/transports/mcp/admin-tools.js.map +1 -0
- package/dist/transports/mcp/app-status-html.d.ts +11 -0
- package/dist/transports/mcp/app-status-html.js +899 -0
- package/dist/transports/mcp/app-status-html.js.map +1 -0
- package/dist/transports/mcp/client-presentation.d.ts +16 -0
- package/dist/transports/mcp/client-presentation.js +13 -0
- package/dist/transports/mcp/client-presentation.js.map +1 -0
- package/dist/transports/mcp/cowork-editor-url.d.ts +6 -0
- package/dist/transports/mcp/cowork-editor-url.js +10 -0
- package/dist/transports/mcp/cowork-editor-url.js.map +1 -0
- package/dist/transports/mcp/decision-card-html.d.ts +26 -0
- package/dist/transports/mcp/decision-card-html.js +876 -0
- package/dist/transports/mcp/decision-card-html.js.map +1 -0
- package/dist/transports/mcp/decision-elicitation.d.ts +116 -0
- package/dist/transports/mcp/decision-elicitation.js +292 -0
- package/dist/transports/mcp/decision-elicitation.js.map +1 -0
- package/dist/transports/mcp/dispatch-probe.d.ts +24 -0
- package/dist/transports/mcp/dispatch-probe.js +48 -0
- package/dist/transports/mcp/dispatch-probe.js.map +1 -0
- package/dist/transports/mcp/editor-document-probe.d.ts +4 -0
- package/dist/transports/mcp/editor-document-probe.js +35 -0
- package/dist/transports/mcp/editor-document-probe.js.map +1 -0
- package/dist/transports/mcp/editor-integration-setup-url.d.ts +8 -0
- package/dist/transports/mcp/editor-integration-setup-url.js +23 -0
- package/dist/transports/mcp/editor-integration-setup-url.js.map +1 -0
- package/dist/transports/mcp/format-tool-content.d.ts +20 -0
- package/dist/transports/mcp/format-tool-content.js +89 -0
- package/dist/transports/mcp/format-tool-content.js.map +1 -0
- package/dist/transports/mcp/instructions/index.d.ts +23 -0
- package/dist/transports/mcp/instructions/index.js +81 -0
- package/dist/transports/mcp/instructions/index.js.map +1 -0
- package/dist/transports/mcp/instructions/result.d.ts +18 -0
- package/dist/transports/mcp/instructions/result.js +58 -0
- package/dist/transports/mcp/instructions/result.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/ask-user.d.ts +2 -0
- package/dist/transports/mcp/instructions/tools/ask-user.js +17 -0
- package/dist/transports/mcp/instructions/tools/ask-user.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/check-app-progress.d.ts +3 -0
- package/dist/transports/mcp/instructions/tools/check-app-progress.js +75 -0
- package/dist/transports/mcp/instructions/tools/check-app-progress.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/check-publish-progress.d.ts +3 -0
- package/dist/transports/mcp/instructions/tools/check-publish-progress.js +23 -0
- package/dist/transports/mcp/instructions/tools/check-publish-progress.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/copy.d.ts +14 -0
- package/dist/transports/mcp/instructions/tools/copy.js +35 -0
- package/dist/transports/mcp/instructions/tools/copy.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/create-integration.d.ts +4 -0
- package/dist/transports/mcp/instructions/tools/create-integration.js +41 -0
- package/dist/transports/mcp/instructions/tools/create-integration.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/edit-app.d.ts +2 -0
- package/dist/transports/mcp/instructions/tools/edit-app.js +18 -0
- package/dist/transports/mcp/instructions/tools/edit-app.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/get-app.d.ts +3 -0
- package/dist/transports/mcp/instructions/tools/get-app.js +47 -0
- package/dist/transports/mcp/instructions/tools/get-app.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/get-integration-metadata.d.ts +2 -0
- package/dist/transports/mcp/instructions/tools/get-integration-metadata.js +13 -0
- package/dist/transports/mcp/instructions/tools/get-integration-metadata.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/index.d.ts +7 -0
- package/dist/transports/mcp/instructions/tools/index.js +26 -0
- package/dist/transports/mcp/instructions/tools/index.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/preview-app.d.ts +3 -0
- package/dist/transports/mcp/instructions/tools/preview-app.js +14 -0
- package/dist/transports/mcp/instructions/tools/preview-app.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/publish-app.d.ts +3 -0
- package/dist/transports/mcp/instructions/tools/publish-app.js +23 -0
- package/dist/transports/mcp/instructions/tools/publish-app.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/start-app.d.ts +2 -0
- package/dist/transports/mcp/instructions/tools/start-app.js +22 -0
- package/dist/transports/mcp/instructions/tools/start-app.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/upload-artifact.d.ts +2 -0
- package/dist/transports/mcp/instructions/tools/upload-artifact.js +13 -0
- package/dist/transports/mcp/instructions/tools/upload-artifact.js.map +1 -0
- package/dist/transports/mcp/mcp-app-brand-css.d.ts +1 -0
- package/dist/transports/mcp/mcp-app-brand-css.js +180 -0
- package/dist/transports/mcp/mcp-app-brand-css.js.map +1 -0
- package/dist/transports/mcp/mount.d.ts +22 -0
- package/dist/transports/mcp/mount.js +1040 -0
- package/dist/transports/mcp/mount.js.map +1 -0
- package/dist/transports/mcp/native-browser-presence.d.ts +45 -0
- package/dist/transports/mcp/native-browser-presence.js +158 -0
- package/dist/transports/mcp/native-browser-presence.js.map +1 -0
- package/dist/transports/mcp/plan-approval.d.ts +38 -0
- package/dist/transports/mcp/plan-approval.js +175 -0
- package/dist/transports/mcp/plan-approval.js.map +1 -0
- package/dist/transports/mcp/progress-notifier.d.ts +39 -0
- package/dist/transports/mcp/progress-notifier.js +52 -0
- package/dist/transports/mcp/progress-notifier.js.map +1 -0
- package/dist/transports/mcp/session-directory.d.ts +7 -0
- package/dist/transports/mcp/session-directory.js +18 -0
- package/dist/transports/mcp/session-directory.js.map +1 -0
- package/dist/transports/mcp/tool-names.d.ts +2 -0
- package/dist/transports/mcp/tool-names.js +2 -0
- package/dist/transports/mcp/tool-names.js.map +1 -0
- package/package.json +78 -0
- package/skills/superblocks-build/SKILL.md +59 -0
- package/skills/superblocks-import/SKILL.md +88 -0
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
11
|
+
//# sourceMappingURL=session-peer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,42 @@
|
|
|
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
|
+
constructor(onLine: (line: string) => void, options?: StreamedReplyOptions);
|
|
22
|
+
/** The reply so far, whether or not all of it has been shown. */
|
|
23
|
+
text(): string;
|
|
24
|
+
/** A `text-delta` push: more of the message Clark is still writing. */
|
|
25
|
+
appendDelta(delta: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* A final assistant message, which replaces the deltas for the same turn.
|
|
28
|
+
*
|
|
29
|
+
* When it finalizes text already shown, only the tail is new; when it is a
|
|
30
|
+
* fresh message, all of it is.
|
|
31
|
+
*/
|
|
32
|
+
finalize(content: string): void;
|
|
33
|
+
/** Show whatever is still unreported, e.g. when the turn ends. */
|
|
34
|
+
flush(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Single door for every progress line: blank lines and a line identical to
|
|
37
|
+
* the one before it are dropped, because the dev server repeats status
|
|
38
|
+
* pushes many times per build and repetition buries the text that matters.
|
|
39
|
+
*/
|
|
40
|
+
emit(line: string): void;
|
|
41
|
+
private maybeEmit;
|
|
42
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
constructor(onLine, options = {}) {
|
|
27
|
+
this.onLine = onLine;
|
|
28
|
+
this.now = options.now ?? (() => Date.now());
|
|
29
|
+
}
|
|
30
|
+
/** The reply so far, whether or not all of it has been shown. */
|
|
31
|
+
text() {
|
|
32
|
+
return this.deltas.join("");
|
|
33
|
+
}
|
|
34
|
+
/** A `text-delta` push: more of the message Clark is still writing. */
|
|
35
|
+
appendDelta(delta) {
|
|
36
|
+
this.deltas.push(delta);
|
|
37
|
+
this.maybeEmit();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A final assistant message, which replaces the deltas for the same turn.
|
|
41
|
+
*
|
|
42
|
+
* When it finalizes text already shown, only the tail is new; when it is a
|
|
43
|
+
* fresh message, all of it is.
|
|
44
|
+
*/
|
|
45
|
+
finalize(content) {
|
|
46
|
+
const alreadyStreamed = this.text().slice(0, this.streamedLen);
|
|
47
|
+
this.deltas.length = 0;
|
|
48
|
+
this.deltas.push(content);
|
|
49
|
+
if (!alreadyStreamed || !content.startsWith(alreadyStreamed)) {
|
|
50
|
+
this.streamedLen = 0;
|
|
51
|
+
}
|
|
52
|
+
this.flush();
|
|
53
|
+
}
|
|
54
|
+
/** Show whatever is still unreported, e.g. when the turn ends. */
|
|
55
|
+
flush() {
|
|
56
|
+
const pending = this.text().slice(this.streamedLen);
|
|
57
|
+
if (!pending.trim()) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.streamedLen += pending.length;
|
|
61
|
+
this.emit(pending);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Single door for every progress line: blank lines and a line identical to
|
|
65
|
+
* the one before it are dropped, because the dev server repeats status
|
|
66
|
+
* pushes many times per build and repetition buries the text that matters.
|
|
67
|
+
*/
|
|
68
|
+
emit(line) {
|
|
69
|
+
const trimmed = line.trim();
|
|
70
|
+
if (!trimmed || trimmed === this.lastLine) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.lastLine = trimmed;
|
|
74
|
+
this.onLine(trimmed);
|
|
75
|
+
}
|
|
76
|
+
maybeEmit() {
|
|
77
|
+
const pending = this.text().slice(this.streamedLen);
|
|
78
|
+
const now = this.now();
|
|
79
|
+
if (pending.length < PROGRESS_CHAR_CHUNK &&
|
|
80
|
+
now - this.lastProgressAt < PROGRESS_MS_CHUNK) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// Waiting for a sentence to end keeps lines readable, but Clark can stop
|
|
84
|
+
// mid-sentence for a long tool call. Once a line has been held that long,
|
|
85
|
+
// showing it unfinished beats showing nothing.
|
|
86
|
+
const cut = sentenceCut(pending) ||
|
|
87
|
+
(now - this.lastProgressAt >= PROGRESS_STALE_MS ? pending.length : 0);
|
|
88
|
+
if (cut === 0) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.lastProgressAt = now;
|
|
92
|
+
this.streamedLen += cut;
|
|
93
|
+
this.emit(pending.slice(0, cut));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function sentenceCut(text) {
|
|
97
|
+
const boundary = Math.max(text.lastIndexOf(". "), text.lastIndexOf(".\n"), text.lastIndexOf("! "), text.lastIndexOf("? "), text.lastIndexOf(":\n"), text.lastIndexOf("\n"));
|
|
98
|
+
if (boundary >= 0) {
|
|
99
|
+
return boundary + 1;
|
|
100
|
+
}
|
|
101
|
+
if (text.trimEnd().endsWith(".")) {
|
|
102
|
+
return text.length;
|
|
103
|
+
}
|
|
104
|
+
if (text.length < PROGRESS_CHAR_CHUNK) {
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
107
|
+
const space = text.lastIndexOf(" ");
|
|
108
|
+
return space > 0 ? space : text.length;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=streamed-reply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamed-reply.js","sourceRoot":"","sources":["../../src/sabs/streamed-reply.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC,2EAA2E;AAC3E,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEhC,kFAAkF;AAClF,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAOhC;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAa;IAQL;IAPF,MAAM,GAAa,EAAE,CAAC;IACtB,GAAG,CAAe;IAC3B,WAAW,GAAG,CAAC,CAAC;IAChB,cAAc,GAAG,CAAC,CAAC;IACnB,QAAQ,CAAqB;IAErC,YACmB,MAA8B,EAC/C,UAAgC,EAAE;QADjB,WAAM,GAAN,M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C,WAAW,CAAC,KAAK,CAAC,EACvB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CACvB,CAAC;IACF,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;QAClB,OAAO,QAAQ,GAAG,CAAC,CAAC;IACtB,CAAC;IACD,IAAI,IAAI,CAAC,OAAO,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"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { ClarkPeerEvent } from "./editor-client-methods.js";
|
|
2
|
+
import type { GenerationStatus, ViewStatus } from "./session-peer.js";
|
|
3
|
+
/** Default quiet window after completed/idle before treating the job as done. */
|
|
4
|
+
export declare const DEFAULT_SETTLE_MS = 12000;
|
|
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
|
+
} | {
|
|
15
|
+
kind: "multi_choice";
|
|
16
|
+
messageId?: string;
|
|
17
|
+
options: string[];
|
|
18
|
+
question: string;
|
|
19
|
+
} | {
|
|
20
|
+
kind: "plan";
|
|
21
|
+
messageId?: string;
|
|
22
|
+
plan: string;
|
|
23
|
+
title?: string;
|
|
24
|
+
};
|
|
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;
|
|
35
|
+
initialSyncStatus?: string;
|
|
36
|
+
settleMs?: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Collects Clark chat and generation-state pushes for one MCP turn wait.
|
|
40
|
+
*
|
|
41
|
+
* `completed` / `idle` start a settle window so an acknowledgment turn that
|
|
42
|
+
* resumes generating is coalesced into the same tool call. `awaiting_user_input`
|
|
43
|
+
* returns `needs_decision` immediately so Claude can answer via `edit_app`.
|
|
44
|
+
*/
|
|
45
|
+
export declare class TurnCollector {
|
|
46
|
+
private readonly onProgress?;
|
|
47
|
+
private readonly labels;
|
|
48
|
+
private readonly states;
|
|
49
|
+
private readonly settleMs;
|
|
50
|
+
private seenGenerating;
|
|
51
|
+
private terminal;
|
|
52
|
+
private viewStatus;
|
|
53
|
+
private draftPending;
|
|
54
|
+
private syncStatus;
|
|
55
|
+
private syncPending;
|
|
56
|
+
private readonly signals;
|
|
57
|
+
/** Case id to name, so a later per-case update can be reported by name. */
|
|
58
|
+
private readonly testCaseNames;
|
|
59
|
+
private readonly awaited;
|
|
60
|
+
/**
|
|
61
|
+
* Whether anything has arrived on the channel the dev server binds to a
|
|
62
|
+
* single editor peer (Clark's messages and generation states). Draft and sync
|
|
63
|
+
* pushes go to every attached editor, so they say nothing about the binding.
|
|
64
|
+
*/
|
|
65
|
+
private clarkPushSeen;
|
|
66
|
+
private lastEventReceivedAt;
|
|
67
|
+
private notifyClarkPush;
|
|
68
|
+
private settleTimer;
|
|
69
|
+
private syncTimer;
|
|
70
|
+
private notifySettled;
|
|
71
|
+
private notifyInSync;
|
|
72
|
+
private generationId;
|
|
73
|
+
private readonly stream;
|
|
74
|
+
constructor(onProgress?: ((message: string) => void) | undefined, options?: TurnCollectorOptions);
|
|
75
|
+
/**
|
|
76
|
+
* Names the generation this turn is collecting, once the prompt has been
|
|
77
|
+
* acknowledged.
|
|
78
|
+
*
|
|
79
|
+
* Set after the fact because the collector has to be listening before the
|
|
80
|
+
* prompt goes out - the session starts pushing as soon as it accepts it, and
|
|
81
|
+
* a collector attached afterwards would miss the opening of its own turn.
|
|
82
|
+
* Until it is named, every state is taken as this turn's, which is the
|
|
83
|
+
* behavior from before generations were named at all.
|
|
84
|
+
*/
|
|
85
|
+
nameGeneration(generationId: string | undefined): void;
|
|
86
|
+
/**
|
|
87
|
+
* Whether a generation state is about the generation this turn started.
|
|
88
|
+
*
|
|
89
|
+
* Unnamed states are this turn's by default: a dev server from before the
|
|
90
|
+
* field says nothing about whose generation it is, and treating that silence
|
|
91
|
+
* as someone else's would leave every turn against an older sandbox waiting
|
|
92
|
+
* for a terminal state that never arrives.
|
|
93
|
+
*/
|
|
94
|
+
private belongsToThisTurn;
|
|
95
|
+
handle(event: ClarkPeerEvent): void;
|
|
96
|
+
reply(): string;
|
|
97
|
+
/**
|
|
98
|
+
* Structured decision Clark is waiting on (plan card or multi_choice).
|
|
99
|
+
* Prefer plan over multi_choice when both arrived in the same turn.
|
|
100
|
+
*/
|
|
101
|
+
decision(): TurnDecision | undefined;
|
|
102
|
+
lastEventAt(): number;
|
|
103
|
+
status(): GenerationStatus | undefined;
|
|
104
|
+
isSettling(): boolean;
|
|
105
|
+
viewableStatus(): ViewStatus;
|
|
106
|
+
/**
|
|
107
|
+
* Whether Clark left a draft the gateway still has to accept. Mirrors the
|
|
108
|
+
* browser editor's `hasAiSuggestedDraft`, which is what gates its
|
|
109
|
+
* auto-accept.
|
|
110
|
+
*/
|
|
111
|
+
needsDraftAccept(): boolean;
|
|
112
|
+
stateSequence(): string[];
|
|
113
|
+
/**
|
|
114
|
+
* Which pushes this turn used to decide it built something. Diagnostic: a
|
|
115
|
+
* headless peer that receives none of them cannot tell an empty job from a
|
|
116
|
+
* successful one, and that is a session-protocol problem, not a Clark one.
|
|
117
|
+
*/
|
|
118
|
+
workSignals(): string[];
|
|
119
|
+
/**
|
|
120
|
+
* Resolves true once Clark has pushed anything on the single-peer channel, or
|
|
121
|
+
* false when the budget expires having heard nothing.
|
|
122
|
+
*
|
|
123
|
+
* A turn that hears nothing is not a slow turn: `generating` lands within a
|
|
124
|
+
* second of the prompt being acknowledged. Silence means this peer is not the
|
|
125
|
+
* one the sandbox is pushing to, and no amount of waiting fixes that.
|
|
126
|
+
*/
|
|
127
|
+
waitForClarkPush(input: {
|
|
128
|
+
signal?: AbortSignal;
|
|
129
|
+
timeoutMs: number;
|
|
130
|
+
}): Promise<boolean>;
|
|
131
|
+
waitUntilTerminal(input: {
|
|
132
|
+
signal?: AbortSignal;
|
|
133
|
+
timeoutMs: number;
|
|
134
|
+
}): Promise<GenerationStatus>;
|
|
135
|
+
/**
|
|
136
|
+
* Resolves once the dev server has flushed Clark's files. An unreported sync
|
|
137
|
+
* status counts as in sync, matching the browser editor's `isOutOfSync`,
|
|
138
|
+
* which blocks on every status where the files have not reached both sides.
|
|
139
|
+
*
|
|
140
|
+
* Resolves false when the budget expires with the sync still pending, so the
|
|
141
|
+
* caller can decline to checkpoint a half-uploaded app.
|
|
142
|
+
*/
|
|
143
|
+
waitUntilInSync(input: {
|
|
144
|
+
timeoutMs: number;
|
|
145
|
+
}): Promise<boolean>;
|
|
146
|
+
/** Records that the gateway committed Clark's draft into a checkpoint. */
|
|
147
|
+
markCheckpointed(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Drops pending timers and releases anyone still waiting, so a turn that
|
|
150
|
+
* timed out or threw leaves nothing armed behind it.
|
|
151
|
+
*/
|
|
152
|
+
dispose(): void;
|
|
153
|
+
private endSyncWait;
|
|
154
|
+
/**
|
|
155
|
+
* Turns a test run into activity lines. Clark names each case only once, in
|
|
156
|
+
* the run's opening plan, so the names are kept to label the per-case
|
|
157
|
+
* updates that follow — an update carries an id and nothing else.
|
|
158
|
+
*/
|
|
159
|
+
private onTestMessage;
|
|
160
|
+
private onSyncStatus;
|
|
161
|
+
private onGenerationState;
|
|
162
|
+
private armSettle;
|
|
163
|
+
private clearSettleTimer;
|
|
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
|
+
*/
|