@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,47 @@
|
|
|
1
|
+
import type { TurnDecision } from "./session-peer.js";
|
|
2
|
+
/**
|
|
3
|
+
* What Clark is waiting on a human for, assembled from the pushes that carry
|
|
4
|
+
* it.
|
|
5
|
+
*
|
|
6
|
+
* Neither shape arrives whole. A plan opens with one message and streams in
|
|
7
|
+
* deltas, and the caller only has something to approve once the pieces are
|
|
8
|
+
* joined; a question arrives with its options in one of two different push
|
|
9
|
+
* types. Keeping that assembly here is what lets the turn ask a single
|
|
10
|
+
* question - "is Clark waiting on anyone?" - instead of tracking four fields
|
|
11
|
+
* to work it out.
|
|
12
|
+
*/
|
|
13
|
+
export declare class AwaitedDecision {
|
|
14
|
+
private readonly integrations;
|
|
15
|
+
private planChunks;
|
|
16
|
+
private planMessageId;
|
|
17
|
+
private planTitle;
|
|
18
|
+
private choice;
|
|
19
|
+
/** A `plan` push: the start of a plan, replacing any plan before it. */
|
|
20
|
+
openPlan(input: {
|
|
21
|
+
messageId?: string;
|
|
22
|
+
title?: string;
|
|
23
|
+
}): void;
|
|
24
|
+
/** A `plan` or `plan-delta` push carrying more of the plan's text. */
|
|
25
|
+
appendPlan(content: string): void;
|
|
26
|
+
/** A `multi_choice` or `searchable_dropdown` push. */
|
|
27
|
+
askChoice(input: {
|
|
28
|
+
messageId?: string;
|
|
29
|
+
options: string[];
|
|
30
|
+
question: string;
|
|
31
|
+
}): void;
|
|
32
|
+
/** A headless integration setup request for the MCP host to fulfill. */
|
|
33
|
+
requireIntegration(input: {
|
|
34
|
+
configuration: Record<string, unknown>;
|
|
35
|
+
name?: string;
|
|
36
|
+
pluginId: string;
|
|
37
|
+
}): void;
|
|
38
|
+
/** True once a plan has streamed any text, whether or not it has finished. */
|
|
39
|
+
hasPlan(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The decision to report, preferring a plan over a question when both
|
|
42
|
+
* arrived in the same turn: a plan is what approve/refine acts on, and a
|
|
43
|
+
* question Clark asked on the way to it is not the turn's outcome.
|
|
44
|
+
*/
|
|
45
|
+
decision(): TurnDecision | undefined;
|
|
46
|
+
private plan;
|
|
47
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { getPluginConfigurationSchema } from "@superblocksteam/mcp-server";
|
|
3
|
+
/** Matches library-shared AI_PLAN_STREAMING_END_MARKER. */
|
|
4
|
+
const PLAN_STREAMING_END_MARKER = "[__SUPERBLOCKS_PLAN_DONE__]";
|
|
5
|
+
/**
|
|
6
|
+
* The plugin's configuration form, from the schema bundled in the MCP server.
|
|
7
|
+
*
|
|
8
|
+
* Carrying it with the request is what keeps the host from having to ask for
|
|
9
|
+
* it: a separate schema tool call is a second approval prompt for a lookup
|
|
10
|
+
* that touches nothing. Superblocks can name a plugin the bundle has no
|
|
11
|
+
* schema for, and a missing form is no reason to drop the whole request.
|
|
12
|
+
*/
|
|
13
|
+
function pluginConfigurationForm(pluginId) {
|
|
14
|
+
try {
|
|
15
|
+
return getPluginConfigurationSchema(pluginId);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (error instanceof McpError) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* What Clark is waiting on a human for, assembled from the pushes that carry
|
|
26
|
+
* it.
|
|
27
|
+
*
|
|
28
|
+
* Neither shape arrives whole. A plan opens with one message and streams in
|
|
29
|
+
* deltas, and the caller only has something to approve once the pieces are
|
|
30
|
+
* joined; a question arrives with its options in one of two different push
|
|
31
|
+
* types. Keeping that assembly here is what lets the turn ask a single
|
|
32
|
+
* question - "is Clark waiting on anyone?" - instead of tracking four fields
|
|
33
|
+
* to work it out.
|
|
34
|
+
*/
|
|
35
|
+
export class AwaitedDecision {
|
|
36
|
+
integrations = [];
|
|
37
|
+
planChunks = [];
|
|
38
|
+
planMessageId;
|
|
39
|
+
planTitle;
|
|
40
|
+
choice;
|
|
41
|
+
/** A `plan` push: the start of a plan, replacing any plan before it. */
|
|
42
|
+
openPlan(input) {
|
|
43
|
+
this.planChunks = [];
|
|
44
|
+
if (input.messageId) {
|
|
45
|
+
this.planMessageId = input.messageId;
|
|
46
|
+
}
|
|
47
|
+
if (input.title?.trim()) {
|
|
48
|
+
this.planTitle = input.title.trim();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** A `plan` or `plan-delta` push carrying more of the plan's text. */
|
|
52
|
+
appendPlan(content) {
|
|
53
|
+
if (content) {
|
|
54
|
+
this.planChunks.push(content);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** A `multi_choice` or `searchable_dropdown` push. */
|
|
58
|
+
askChoice(input) {
|
|
59
|
+
this.choice = {
|
|
60
|
+
...(input.messageId ? { messageId: input.messageId } : {}),
|
|
61
|
+
options: input.options,
|
|
62
|
+
question: input.question,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** A headless integration setup request for the MCP host to fulfill. */
|
|
66
|
+
requireIntegration(input) {
|
|
67
|
+
const pluginId = input.pluginId === "restapi" ? "restapiintegration" : input.pluginId;
|
|
68
|
+
const { baseUrl, ...restConfiguration } = input.configuration;
|
|
69
|
+
const configuration = input.pluginId === "restapi"
|
|
70
|
+
? {
|
|
71
|
+
...restConfiguration,
|
|
72
|
+
...(baseUrl !== undefined && restConfiguration.urlBase === undefined
|
|
73
|
+
? { urlBase: baseUrl }
|
|
74
|
+
: {}),
|
|
75
|
+
}
|
|
76
|
+
: input.configuration;
|
|
77
|
+
const configurationSchema = pluginConfigurationForm(pluginId);
|
|
78
|
+
this.integrations.push({
|
|
79
|
+
...input,
|
|
80
|
+
configuration,
|
|
81
|
+
pluginId,
|
|
82
|
+
...(configurationSchema ? { configurationSchema } : {}),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/** True once a plan has streamed any text, whether or not it has finished. */
|
|
86
|
+
hasPlan() {
|
|
87
|
+
return this.plan() !== undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The decision to report, preferring a plan over a question when both
|
|
91
|
+
* arrived in the same turn: a plan is what approve/refine acts on, and a
|
|
92
|
+
* question Clark asked on the way to it is not the turn's outcome.
|
|
93
|
+
*/
|
|
94
|
+
decision() {
|
|
95
|
+
if (this.integrations.length > 0) {
|
|
96
|
+
return {
|
|
97
|
+
integrations: [...this.integrations],
|
|
98
|
+
kind: "missing_integrations",
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const plan = this.plan();
|
|
102
|
+
if (plan) {
|
|
103
|
+
return {
|
|
104
|
+
kind: "plan",
|
|
105
|
+
...(this.planMessageId ? { messageId: this.planMessageId } : {}),
|
|
106
|
+
plan,
|
|
107
|
+
...(this.planTitle ? { title: this.planTitle } : {}),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return this.choice ? { kind: "multi_choice", ...this.choice } : undefined;
|
|
111
|
+
}
|
|
112
|
+
plan() {
|
|
113
|
+
if (this.planChunks.length === 0) {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
const plan = this.planChunks
|
|
117
|
+
.join("")
|
|
118
|
+
.split(PLAN_STREAMING_END_MARKER)
|
|
119
|
+
.join("")
|
|
120
|
+
.trimEnd();
|
|
121
|
+
return plan || undefined;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=awaited-decision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"awaited-decision.js","sourceRoot":"","sources":["../../src/sabs/awaited-decision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAE9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAI3E,2DAA2D;AAC3D,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AAEhE;;;;;;;GAOG;AACH,SAAS,uBAAuB,CAC9B,QAAgB;IAEhB,IAAI,CAAC;QACH,OAAO,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;YAC9B,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,OAAO,eAAe;IACT,YAAY,GAKxB,EAAE,CAAC;IACA,UAAU,GAAa,EAAE,CAAC;IAC1B,aAAa,CAAqB;IAClC,SAAS,CAAqB;IAC9B,MAAM,CAEA;IAEd,wEAAwE;IACxE,QAAQ,CAAC,KAA6C;QACpD,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,SAAS,CAAC;QACvC,CAAC;QACD,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;YACxB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,K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AS,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the `browserContext` the ai-service needs before it will register
|
|
3
|
+
* Clark's Playwright tools.
|
|
4
|
+
*
|
|
5
|
+
* Opt-in: the sandbox launches Chromium, mocks `window.parent`, and
|
|
6
|
+
* replays `initData` / `bootstrapData` to the app shell as `sb-init` and
|
|
7
|
+
* `sb-bootstrap-response`. The gateway only supplies the same context the
|
|
8
|
+
* browser editor assembles from Redux. Gateway preview screenshots use
|
|
9
|
+
* laptop Chromium instead and do not call this.
|
|
10
|
+
*/
|
|
11
|
+
import type { BrowserContext } from "@superblocksteam/library-shared/types";
|
|
12
|
+
/**
|
|
13
|
+
* An org profile as the Superblocks API returns it. `key` is what selects the
|
|
14
|
+
* profile; `id` and `displayName` round out the `Profile` shape the app shell
|
|
15
|
+
* types against.
|
|
16
|
+
*/
|
|
17
|
+
export type BrowserContextProfile = {
|
|
18
|
+
allowedInEditor?: boolean;
|
|
19
|
+
displayName?: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
key: string;
|
|
22
|
+
};
|
|
23
|
+
export type BrowserContextInput = {
|
|
24
|
+
applicationId: string;
|
|
25
|
+
/**
|
|
26
|
+
* Personal API key sent as library `token` / `Authorization`. The
|
|
27
|
+
* orchestrator forwards that header to the code-bundle route, which
|
|
28
|
+
* checks `apps:view` and rejects the live-edit `apps:update` JWT.
|
|
29
|
+
*/
|
|
30
|
+
apiKey?: string;
|
|
31
|
+
/** Sandbox origin from `connectLiveEdit`; the editor iframe's own base URL. */
|
|
32
|
+
liveEditUrl: string;
|
|
33
|
+
orchestratorUrl: string;
|
|
34
|
+
organizationId?: string;
|
|
35
|
+
/** Held-session peer id, so the app shell reuses this editor's socket. */
|
|
36
|
+
peerId: string;
|
|
37
|
+
/** Profile key already resolved for this session's orchestrator calls. */
|
|
38
|
+
profileKey?: string;
|
|
39
|
+
profiles?: BrowserContextProfile[];
|
|
40
|
+
/** Scoped `apps:update` JWT the live-edit session was opened with. */
|
|
41
|
+
sessionToken: string;
|
|
42
|
+
uiBaseUrl: string;
|
|
43
|
+
userEmail?: string;
|
|
44
|
+
userId: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Returns the context, or `undefined` when the sandbox URL is unusable.
|
|
48
|
+
*
|
|
49
|
+
* Undefined rather than a throw: browser testing is an enhancement to a turn,
|
|
50
|
+
* so a sandbox we cannot address should cost Clark its Playwright tools, not
|
|
51
|
+
* the whole prompt.
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildBrowserContext(input: BrowserContextInput): BrowserContext | undefined;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the `browserContext` the ai-service needs before it will register
|
|
3
|
+
* Clark's Playwright tools.
|
|
4
|
+
*
|
|
5
|
+
* Opt-in: the sandbox launches Chromium, mocks `window.parent`, and
|
|
6
|
+
* replays `initData` / `bootstrapData` to the app shell as `sb-init` and
|
|
7
|
+
* `sb-bootstrap-response`. The gateway only supplies the same context the
|
|
8
|
+
* browser editor assembles from Redux. Gateway preview screenshots use
|
|
9
|
+
* laptop Chromium instead and do not call this.
|
|
10
|
+
*/
|
|
11
|
+
import { Profile, ProfileType } from "@superblocksteam/shared";
|
|
12
|
+
function toProfile(row) {
|
|
13
|
+
return new Profile({
|
|
14
|
+
allowedInEditor: row.allowedInEditor,
|
|
15
|
+
description: "",
|
|
16
|
+
displayName: row.displayName ?? row.key,
|
|
17
|
+
id: row.id ?? row.key,
|
|
18
|
+
key: row.key,
|
|
19
|
+
type: ProfileType.RESERVED,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function selectProfiles(input) {
|
|
23
|
+
const rows = input.profiles ?? [];
|
|
24
|
+
if (rows.length === 0) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const chosen = rows.find((row) => row.key === input.profileKey) ?? rows[0];
|
|
28
|
+
if (!chosen) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
const selected = toProfile(chosen);
|
|
32
|
+
return {
|
|
33
|
+
available: rows.map(toProfile),
|
|
34
|
+
default: selected,
|
|
35
|
+
selected,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the context, or `undefined` when the sandbox URL is unusable.
|
|
40
|
+
*
|
|
41
|
+
* Undefined rather than a throw: browser testing is an enhancement to a turn,
|
|
42
|
+
* so a sandbox we cannot address should cost Clark its Playwright tools, not
|
|
43
|
+
* the whole prompt.
|
|
44
|
+
*/
|
|
45
|
+
export function buildBrowserContext(input) {
|
|
46
|
+
let iframeBaseUrl;
|
|
47
|
+
try {
|
|
48
|
+
iframeBaseUrl = new URL(input.liveEditUrl);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
if (iframeBaseUrl.protocol !== "http:" &&
|
|
54
|
+
iframeBaseUrl.protocol !== "https:") {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
// The editor's iframe carries this too. Without it the app shell boots in
|
|
58
|
+
// its viewer mode, where the editing affordances Clark's tests drive are
|
|
59
|
+
// absent.
|
|
60
|
+
iframeBaseUrl.searchParams.set("app_mode", "EDIT");
|
|
61
|
+
const profiles = selectProfiles(input);
|
|
62
|
+
return {
|
|
63
|
+
bootstrapData: {
|
|
64
|
+
accessToken: input.sessionToken,
|
|
65
|
+
agents: [],
|
|
66
|
+
agentUrls: [input.orchestratorUrl],
|
|
67
|
+
appId: input.applicationId,
|
|
68
|
+
devServerAuthorization: `Bearer ${input.sessionToken}`,
|
|
69
|
+
featureFlags: {
|
|
70
|
+
"clark.sdk-api.enabled": true,
|
|
71
|
+
},
|
|
72
|
+
orgId: input.organizationId,
|
|
73
|
+
...(profiles ? { profiles } : {}),
|
|
74
|
+
// Library fetch: Authorization = this token, x-superblocks-authorization
|
|
75
|
+
// = accessToken. The API key belongs on Authorization; the scoped JWT
|
|
76
|
+
// does not carry apps:view for the orchestrator's code-bundle fetch.
|
|
77
|
+
token: input.apiKey ?? input.sessionToken,
|
|
78
|
+
userEmail: input.userEmail,
|
|
79
|
+
userId: input.userId,
|
|
80
|
+
windowOriginUrl: input.uiBaseUrl,
|
|
81
|
+
},
|
|
82
|
+
iframeBaseUrl: iframeBaseUrl.toString(),
|
|
83
|
+
initData: {
|
|
84
|
+
appId: input.applicationId,
|
|
85
|
+
devServerAuthorization: `Bearer ${input.sessionToken}`,
|
|
86
|
+
peerId: input.peerId,
|
|
87
|
+
userId: input.userId,
|
|
88
|
+
windowOriginUrl: input.uiBaseUrl,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=browser-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-context.js","sourceRoot":"","sources":["../../src/sabs/browser-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AA4C/D,SAAS,SAAS,CAAC,GAA0B;IAC3C,OAAO,IAAI,OAAO,CAAC;QACjB,eAAe,EAAE,GAAG,CAAC,eAAe;QACpC,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,GAAG;QACvC,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG;QACrB,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,IAAI,EAAE,WAAW,CAAC,QAAQ;KAC3B,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CACrB,KAA0B;IAE1B,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;IAClC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAA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;YAC3B,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjC,yEAAyE;YACzE,sEAAsE;YACtE,qEAAqE;YACrE,KAAK,EAAE,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,YAAY;YACzC,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,eAAe,EAAE,KAAK,CAAC,SAAS;SACjC;QACD,aAAa,EAAE,aAAa,CAAC,QAAQ,EAAE;QACvC,QAAQ,EAAE;YACR,KAAK,EAAE,KAAK,CAAC,aAAa;YAC1B,sBAAsB,EAAE,UAAU,KAAK,CAAC,YAAY,EAAE;YACtD,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,eAAe,EAAE,KAAK,CAAC,SAAS;SACjC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { EditorHasDefaultStructure, PromptContextIntegration, SdkApiExecutionResult } from "@superblocksteam/library-shared/types";
|
|
2
|
+
import { type MethodHandlers, type RequestContextBase } from "@superblocksteam/shared";
|
|
3
|
+
import type { OrchestratorClient } from "../orchestrator/client.js";
|
|
4
|
+
import type { SuperblocksServerClient } from "../server/client.js";
|
|
5
|
+
export type IntegrationExecuteResult = {
|
|
6
|
+
error?: string;
|
|
7
|
+
response?: string;
|
|
8
|
+
};
|
|
9
|
+
export type IntegrationExecutePayload = {
|
|
10
|
+
integrationHint?: {
|
|
11
|
+
displayName?: string;
|
|
12
|
+
name: string;
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
15
|
+
integrationId: string;
|
|
16
|
+
request: Record<string, unknown>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The subset of library-shared's AiChatMessage the gateway reads. Test-run
|
|
20
|
+
* fields are flattened in here because Clark reports a whole test run through
|
|
21
|
+
* ordinary `aiPushMessage` pushes, distinguished only by `type`.
|
|
22
|
+
*/
|
|
23
|
+
export type ClarkMessage = {
|
|
24
|
+
choices?: Array<string | {
|
|
25
|
+
text: string;
|
|
26
|
+
subText?: string;
|
|
27
|
+
}>;
|
|
28
|
+
content?: string;
|
|
29
|
+
gatewayObserverSource?: "browser";
|
|
30
|
+
header?: string;
|
|
31
|
+
id?: string;
|
|
32
|
+
name?: string;
|
|
33
|
+
options?: Array<string | {
|
|
34
|
+
label?: string;
|
|
35
|
+
value?: string;
|
|
36
|
+
}>;
|
|
37
|
+
role?: string;
|
|
38
|
+
summary?: string;
|
|
39
|
+
testCaseId?: string;
|
|
40
|
+
testCaseStatus?: string;
|
|
41
|
+
testCases?: Array<{
|
|
42
|
+
id?: string;
|
|
43
|
+
name?: string;
|
|
44
|
+
status?: string;
|
|
45
|
+
}>;
|
|
46
|
+
testRunId?: string;
|
|
47
|
+
testStatus?: string;
|
|
48
|
+
title?: string;
|
|
49
|
+
type?: string;
|
|
50
|
+
};
|
|
51
|
+
export type ClarkPeerEvent = {
|
|
52
|
+
kind: "message";
|
|
53
|
+
message: ClarkMessage;
|
|
54
|
+
} | {
|
|
55
|
+
configuration: Record<string, unknown>;
|
|
56
|
+
kind: "missing_integration";
|
|
57
|
+
name?: string;
|
|
58
|
+
pluginId: string;
|
|
59
|
+
} | {
|
|
60
|
+
kind: "change_info";
|
|
61
|
+
label: string;
|
|
62
|
+
} | {
|
|
63
|
+
kind: "draft_state";
|
|
64
|
+
hasDraft: boolean;
|
|
65
|
+
} | {
|
|
66
|
+
hasDefaultStructure: EditorHasDefaultStructure;
|
|
67
|
+
kind: "editor_structure";
|
|
68
|
+
} | {
|
|
69
|
+
kind: "generation_state";
|
|
70
|
+
/**
|
|
71
|
+
* The generation this state is about. Absent from dev servers that
|
|
72
|
+
* predate the field, which is why a turn cannot require it.
|
|
73
|
+
*/
|
|
74
|
+
generationId?: string;
|
|
75
|
+
gatewayObserverSource?: "browser";
|
|
76
|
+
hasError?: boolean;
|
|
77
|
+
hasSuggestions?: boolean;
|
|
78
|
+
state: string;
|
|
79
|
+
} | {
|
|
80
|
+
kind: "reload_iframe";
|
|
81
|
+
} | {
|
|
82
|
+
kind: "sync_status";
|
|
83
|
+
status?: string;
|
|
84
|
+
} | {
|
|
85
|
+
kind: "task_status";
|
|
86
|
+
label: string;
|
|
87
|
+
};
|
|
88
|
+
export type ClarkPeerListener = (event: ClarkPeerEvent) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Credentials and clients the held gateway peer needs to answer Clark's
|
|
91
|
+
* discovery and testApi RPCs without a browser tab.
|
|
92
|
+
*/
|
|
93
|
+
export type EditorSessionContext = {
|
|
94
|
+
apiKey: string;
|
|
95
|
+
applicationId: string;
|
|
96
|
+
branchName?: string;
|
|
97
|
+
organizationId: string;
|
|
98
|
+
orchestrator: OrchestratorClient;
|
|
99
|
+
profileKey: string;
|
|
100
|
+
server: SuperblocksServerClient;
|
|
101
|
+
sessionToken: string;
|
|
102
|
+
waitUntilFilesSynced: () => Promise<boolean>;
|
|
103
|
+
};
|
|
104
|
+
export type IntegrationExecutionContext = Pick<EditorSessionContext, "apiKey" | "orchestrator" | "organizationId" | "profileKey" | "server" | "sessionToken"> & {
|
|
105
|
+
applicationId?: string;
|
|
106
|
+
};
|
|
107
|
+
export type EditorClientMethodDeps = {
|
|
108
|
+
getContext: () => EditorSessionContext | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Records a mid-turn testApi / testIntegration outcome for MCP progress and
|
|
111
|
+
* needs_decision payloads.
|
|
112
|
+
*/
|
|
113
|
+
onToolRun?: (run: {
|
|
114
|
+
detail?: unknown;
|
|
115
|
+
kind: "test_api" | "test_integration";
|
|
116
|
+
name: string;
|
|
117
|
+
success: boolean;
|
|
118
|
+
}) => void;
|
|
119
|
+
/**
|
|
120
|
+
* Forwards a tool-permission decision to the ai-service via
|
|
121
|
+
* `editor.aiRespondToToolPermission` on the held socket. Headless sessions
|
|
122
|
+
* auto-approve only the allowlisted Clark agent tools; other tools deny.
|
|
123
|
+
*/
|
|
124
|
+
respondToToolPermission: (payload: {
|
|
125
|
+
approved: boolean;
|
|
126
|
+
messageId: string;
|
|
127
|
+
requestId?: string;
|
|
128
|
+
}) => Promise<void>;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Runs Clark's executeRequestToIntegration the same way the browser editor
|
|
132
|
+
* does: one inline V2 API step against the orchestrator. Username/password and
|
|
133
|
+
* other stored-credential integrations execute here; interactive IdP auth
|
|
134
|
+
* surfaces as an error asking the user to authenticate in the editor.
|
|
135
|
+
*/
|
|
136
|
+
export declare function executeRequestToIntegrationViaOrchestrator(context: IntegrationExecutionContext, payload: IntegrationExecutePayload): Promise<IntegrationExecuteResult>;
|
|
137
|
+
/**
|
|
138
|
+
* Prefills Clark's promptContext.integrations the same way the editor does.
|
|
139
|
+
*/
|
|
140
|
+
export declare function loadIntegrationsForPrompt(context: Pick<EditorSessionContext, "apiKey" | "applicationId" | "organizationId" | "server">): Promise<Omit<PromptContextIntegration, "metadata">[]>;
|
|
141
|
+
export declare function mapSdkExecutionResponse(response: unknown): SdkApiExecutionResult;
|
|
142
|
+
/**
|
|
143
|
+
* Server -> editor calls the dev server makes into the peer driving a turn,
|
|
144
|
+
* whether that peer negotiated protocol "editor" or "gateway".
|
|
145
|
+
*
|
|
146
|
+
* Leaving these unimplemented is not inert. ISocket answers an unknown method
|
|
147
|
+
* with `{ code: 2, message: "unknown method <name>" }`, and the dev server does
|
|
148
|
+
* not catch every one of those rejections — `resetScope` in particular escalates
|
|
149
|
+
* to `unhandledRejection`, which exits the sandbox with "Dev server fatal exit"
|
|
150
|
+
* and takes the in-flight Clark build down with it. A browser editor answers
|
|
151
|
+
* all of them, so a held gateway socket has to as well.
|
|
152
|
+
*
|
|
153
|
+
* Keyed on `GatewayClientMethods` rather than a hand-kept list so that a method
|
|
154
|
+
* added to the protocol upstream fails this package's typecheck instead of
|
|
155
|
+
* reaching a sandbox and crashing it. Same handler surface as
|
|
156
|
+
* `createEditorHandlers` in vite-plugin-file-sync's dev-server-ws-smoke-client,
|
|
157
|
+
* the other non-browser peer that speaks this protocol; it is not imported from
|
|
158
|
+
* there because the gateway does not depend on the vite plugin.
|
|
159
|
+
*
|
|
160
|
+
* When a listener is provided, chat, generation-state, task/change, and
|
|
161
|
+
* preview-ready pushes are forwarded so the gateway can wait for Clark's turn
|
|
162
|
+
* and surface progress over MCP.
|
|
163
|
+
*/
|
|
164
|
+
export declare function createEditorClientMethods(getListener?: () => ClarkPeerListener | undefined, onInbound?: (method: string) => void, deps?: EditorClientMethodDeps): MethodHandlers<Record<string, never>, Record<string, never>, RequestContextBase>;
|