@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,89 @@
|
|
|
1
|
+
import { isRecord, readResult } from "./instructions/result.js";
|
|
2
|
+
/**
|
|
3
|
+
* Serializes a capability result into MCP content blocks.
|
|
4
|
+
*
|
|
5
|
+
* Block order is important: callers read `content[0]` as the JSON body and
|
|
6
|
+
* `content.at(-1)` as the closing instruction.
|
|
7
|
+
*
|
|
8
|
+
* Screenshot bytes stay in the JSON as well as the image block, because Cursor
|
|
9
|
+
* CLI agents never see image blocks. A plan gets its own markdown block where a
|
|
10
|
+
* model renders the ask: in the JSON it is one escaped string, and a model that
|
|
11
|
+
* re-lays it out demotes headings and merges bullets. That block holds the plan
|
|
12
|
+
* and title only - an earlier version bundled instructions and option labels,
|
|
13
|
+
* which models pasted into the chat as a menu.
|
|
14
|
+
*/
|
|
15
|
+
export function formatMcpToolContent(result, progress = [], profile) {
|
|
16
|
+
const { publishDetailsUrl, screenshotBase64, textResult } = extractRichContent(result);
|
|
17
|
+
const content = [];
|
|
18
|
+
// Every text block ends in a newline because hosts concatenate them: without
|
|
19
|
+
// it the trail read "}[progress] Creating application[progress] Connecting
|
|
20
|
+
// live-edit session", running the JSON body into the first marker and every
|
|
21
|
+
// marker into the next.
|
|
22
|
+
content.push({
|
|
23
|
+
text: `${JSON.stringify(textResult, null, 2)}\n`,
|
|
24
|
+
type: "text",
|
|
25
|
+
});
|
|
26
|
+
if (profile?.hasNativeAskForm) {
|
|
27
|
+
const plan = planMarkdown(result);
|
|
28
|
+
if (plan) {
|
|
29
|
+
content.push({ text: `\n${plan}\n\n`, type: "text" });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (publishDetailsUrl) {
|
|
33
|
+
content.push({
|
|
34
|
+
description: "View publish details",
|
|
35
|
+
name: "publish-details",
|
|
36
|
+
title: "View publish details",
|
|
37
|
+
type: "resource_link",
|
|
38
|
+
uri: publishDetailsUrl,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
content.push(...progress.map((event) => ({
|
|
42
|
+
text: `[${event.type}] ${event.message}\n`,
|
|
43
|
+
type: "text",
|
|
44
|
+
})));
|
|
45
|
+
if (screenshotBase64) {
|
|
46
|
+
content.push({
|
|
47
|
+
data: screenshotBase64,
|
|
48
|
+
mimeType: "image/jpeg",
|
|
49
|
+
type: "image",
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return content;
|
|
53
|
+
}
|
|
54
|
+
function planMarkdown(result) {
|
|
55
|
+
const flat = readResult(result);
|
|
56
|
+
if (flat.status !== "needs_decision" || flat.decisionKind !== "plan") {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
const decision = flat.value.decision;
|
|
60
|
+
if (!isRecord(decision)) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
const plan = typeof decision.plan === "string" ? decision.plan.trim() : "";
|
|
64
|
+
if (!plan) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const title = typeof decision.title === "string" ? decision.title.trim() : "";
|
|
68
|
+
return title ? `**${title}**\n\n${plan}` : plan;
|
|
69
|
+
}
|
|
70
|
+
function extractRichContent(result) {
|
|
71
|
+
if (result.kind !== "ok" ||
|
|
72
|
+
!result.value ||
|
|
73
|
+
typeof result.value !== "object") {
|
|
74
|
+
return {
|
|
75
|
+
publishDetailsUrl: undefined,
|
|
76
|
+
screenshotBase64: undefined,
|
|
77
|
+
textResult: result,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const value = result.value;
|
|
81
|
+
const publishDetailsUrl = typeof value.publishDetailsUrl === "string"
|
|
82
|
+
? value.publishDetailsUrl
|
|
83
|
+
: undefined;
|
|
84
|
+
const screenshotBase64 = typeof value.screenshotBase64 === "string"
|
|
85
|
+
? value.screenshotBase64
|
|
86
|
+
: undefined;
|
|
87
|
+
return { publishDetailsUrl, screenshotBase64, textResult: result };
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=format-tool-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-tool-content.js","sourceRoot":"","sources":["../../../src/transports/mcp/format-tool-content.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAiC,EACjC,WAAqD,EAAE,EACvD,OAAuB;IAEvB,MAAM,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,UAAU,EAAE,GACvD,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,6EAA6E;IAC7E,2EAA2E;IAC3E,4EAA4E;IAC5E,wBAAwB;IACxB,OAAO,CAAC,IAAI,CAAC;QACX,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI;QAChD,IAAI,EAAE,MAAM;KACb,CAAC,CAAC;IACH,IAAI,OAAO,EAAE,gBAAgB,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,YAAY,CAAC,MAA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ules; `readResult`
|
|
5
|
+
* flattens a capability result so those rules read as a plain list of
|
|
6
|
+
* conditions. Callers only need the three functions below.
|
|
7
|
+
*/
|
|
8
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
9
|
+
import type { CapabilityResult } from "../../../capabilities/types.js";
|
|
10
|
+
import type { ClientProfile } from "../client-presentation.js";
|
|
11
|
+
import type { ToolName } from "../tool-names.js";
|
|
12
|
+
/** The agent's next step after `tool` returned `result`, if it needs one. */
|
|
13
|
+
export declare function instructionFor(tool: ToolName, result: CapabilityResult<unknown>, profile: ClientProfile): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Writes `agentInstructions` onto a capability result, leaving any the
|
|
16
|
+
* capability set itself in place (activity relay and similar).
|
|
17
|
+
*/
|
|
18
|
+
export declare function attachAgentInstructions(tool: ToolName, result: CapabilityResult<unknown>, profile: ClientProfile): CapabilityResult<unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* The same, for Admin tools: they return MCP `CallToolResult` JSON rather than
|
|
21
|
+
* a capability result, so the payload is parsed and rewritten.
|
|
22
|
+
*/
|
|
23
|
+
export declare function attachAdminAgentInstructions(tool: ToolName, result: CallToolResult, profile: ClientProfile): CallToolResult;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What to tell the calling agent after a tool call.
|
|
3
|
+
*
|
|
4
|
+
* One file per tool under `tools/` holds that tool's rules; `readResult`
|
|
5
|
+
* flattens a capability result so those rules read as a plain list of
|
|
6
|
+
* conditions. Callers only need the three functions below.
|
|
7
|
+
*/
|
|
8
|
+
import { isRecord, readResult } from "./result.js";
|
|
9
|
+
import { INSTRUCTIONS } from "./tools/index.js";
|
|
10
|
+
/** The agent's next step after `tool` returned `result`, if it needs one. */
|
|
11
|
+
export function instructionFor(tool, result, profile) {
|
|
12
|
+
return INSTRUCTIONS[tool]?.(readResult(result), profile);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Writes `agentInstructions` onto a capability result, leaving any the
|
|
16
|
+
* capability set itself in place (activity relay and similar).
|
|
17
|
+
*/
|
|
18
|
+
export function attachAgentInstructions(tool, result, profile) {
|
|
19
|
+
const agentInstructions = instructionFor(tool, result, profile);
|
|
20
|
+
if (!agentInstructions) {
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
if (result.kind === "error") {
|
|
24
|
+
return result.agentInstructions ? result : { ...result, agentInstructions };
|
|
25
|
+
}
|
|
26
|
+
if (result.kind !== "ok" || !isRecord(result.value)) {
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
if (typeof result.value.agentInstructions === "string" &&
|
|
30
|
+
result.value.agentInstructions) {
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
return { kind: "ok", value: { ...result.value, agentInstructions } };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The same, for Admin tools: they return MCP `CallToolResult` JSON rather than
|
|
37
|
+
* a capability result, so the payload is parsed and rewritten.
|
|
38
|
+
*/
|
|
39
|
+
export function attachAdminAgentInstructions(tool, result, profile) {
|
|
40
|
+
if (result.isError) {
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
const block = result.content[0];
|
|
44
|
+
if (!block || block.type !== "text") {
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
let parsed;
|
|
48
|
+
try {
|
|
49
|
+
parsed = JSON.parse(block.text);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
if (!isRecord(parsed)) {
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
if (typeof parsed.agentInstructions === "string" &&
|
|
58
|
+
parsed.agentInstructions) {
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
const agentInstructions = instructionFor(tool, { kind: "ok", value: parsed }, profile);
|
|
62
|
+
if (!agentInstructions) {
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
const nextValue = { ...parsed, agentInstructions };
|
|
66
|
+
const existingStructured = isRecord(result.structuredContent)
|
|
67
|
+
? result.structuredContent
|
|
68
|
+
: undefined;
|
|
69
|
+
return {
|
|
70
|
+
...result,
|
|
71
|
+
content: [
|
|
72
|
+
{ type: "text", text: JSON.stringify(nextValue) },
|
|
73
|
+
...result.content.slice(1),
|
|
74
|
+
],
|
|
75
|
+
structuredContent: {
|
|
76
|
+
...(existingStructured ?? nextValue),
|
|
77
|
+
agentInstructions,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/transports/mcp/instructions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,6EAA6E;AAC7E,MAAM,UAAU,cAAc,CAC5B,IAAc,EACd,MAAiC,EACjC,OAAsB;IAEtB,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,IAAc,EACd,MAAiC,EACjC,OAAsB;IAEtB,MAAM,iBAAiB,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAChE,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC9E,CAA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M,EAAE,EAC7B,OAAO,CACR,CAAC;IACF,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,MAAM,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,iBAAiB,EAAE,CAAC;IACnD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAC3D,CAAC,CAAC,MAAM,CAAC,iBAAiB;QAC1B,CAAC,CAAC,SAAS,CAAC;IACd,OAAO;QACL,GAAG,MAAM;QACT,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;YACjD,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;SAC3B;QACD,iBAAiB,EAAE;YACjB,GAAG,CAAC,kBAAkB,IAAI,SAAS,CAAC;YACpC,iBAAiB;SAClB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CapabilityResult, DecisionPayload, PendingAppAction } from "../../../capabilities/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A capability result flattened into the handful of fields the tool files
|
|
4
|
+
* branch on. Reading happens once here so no tool file digs through
|
|
5
|
+
* `CapabilityResult`'s ok/error split or a nested `decision` object.
|
|
6
|
+
*/
|
|
7
|
+
export type ToolResult = {
|
|
8
|
+
/** Error code, or undefined when the call succeeded. */
|
|
9
|
+
code?: string;
|
|
10
|
+
decisionKind?: DecisionPayload["kind"];
|
|
11
|
+
ok: boolean;
|
|
12
|
+
pendingAction?: PendingAppAction;
|
|
13
|
+
status?: string;
|
|
14
|
+
/** Remaining response fields, for the few tools with their own signals. */
|
|
15
|
+
value: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
export declare function readResult(result: CapabilityResult<unknown>): ToolResult;
|
|
18
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function readResult(result) {
|
|
2
|
+
if (result.kind === "error") {
|
|
3
|
+
return {
|
|
4
|
+
code: result.code,
|
|
5
|
+
ok: false,
|
|
6
|
+
...(result.pendingAction ? { pendingAction: result.pendingAction } : {}),
|
|
7
|
+
value: {},
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
// auth_required is the host's to resolve, not the agent's; it carries no fields to branch on.
|
|
11
|
+
if (result.kind !== "ok") {
|
|
12
|
+
return { ok: false, value: {} };
|
|
13
|
+
}
|
|
14
|
+
const value = isRecord(result.value) ? result.value : {};
|
|
15
|
+
const decisionKind = decisionKindOf(value);
|
|
16
|
+
const pendingAction = pendingActionOf(value);
|
|
17
|
+
const { status } = value;
|
|
18
|
+
return {
|
|
19
|
+
...(decisionKind ? { decisionKind } : {}),
|
|
20
|
+
ok: true,
|
|
21
|
+
...(pendingAction ? { pendingAction } : {}),
|
|
22
|
+
...(typeof status === "string" ? { status } : {}),
|
|
23
|
+
value,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function isRecord(value) {
|
|
27
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28
|
+
}
|
|
29
|
+
function decisionKindOf(value) {
|
|
30
|
+
const decision = value.decision;
|
|
31
|
+
if (!isRecord(decision)) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
switch (decision.kind) {
|
|
35
|
+
case "missing_integrations":
|
|
36
|
+
case "multi_choice":
|
|
37
|
+
case "plan":
|
|
38
|
+
return decision.kind;
|
|
39
|
+
default:
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function pendingActionOf(value) {
|
|
44
|
+
switch (value.pendingAction) {
|
|
45
|
+
case "answer_question":
|
|
46
|
+
case "approve_plan":
|
|
47
|
+
case "create_integration":
|
|
48
|
+
case "decide_in_editor":
|
|
49
|
+
case "open_editor":
|
|
50
|
+
case "retry_build":
|
|
51
|
+
case "start_new_app":
|
|
52
|
+
case "wait_for_build":
|
|
53
|
+
return value.pendingAction;
|
|
54
|
+
default:
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../../../src/transports/mcp/instructions/result.ts"],"names":[],"mappings":"AAsBA,MAAM,UAAU,UAAU,CAAC,MAAiC;IAC1D,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,EAAE,EAAE,KAAK;YACT,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACxE,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IACD,8FAA8F;IAC9F,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACzB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAClC,CAAC;IACD,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACzD,MAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACzB,OAAO;QACL,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,EAAE,EAAE,IAAI;QACR,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC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
|
|
6
|
+
if (result.decisionKind === "plan") {
|
|
7
|
+
return `Show this plan to the user. ${SHOW_PLAN_VERBATIM}`;
|
|
8
|
+
}
|
|
9
|
+
if (result.decisionKind === "multi_choice") {
|
|
10
|
+
return "Present `decision.question` and every entry of `decision.options`, none dropped or merged, as an affordance (picker/suggested replies) if your host supports one. Never type a numbered menu as a stand-in for a picker that's already showing the same options.";
|
|
11
|
+
}
|
|
12
|
+
if (!result.decisionKind) {
|
|
13
|
+
return "Nothing is waiting on the user right now. Follow the build instead: call `check_app_progress` or `get_app` rather than asking again.";
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ask-user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user.js","sourceRoot":"","sources":["../../../../../src/transports/mcp/instructions/tools/ask-user.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,UAAU,eAAe,CAAC,MAAkB;IAChD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,MAAM,CAAC,YAAY,KAAK,MAAM,EAAE,CAAC;QACnC,OAAO,+BAA+B,kBAAkB,EAAE,CAAC;IAC7D,CAAC;IACD,IAAI,MAAM,CAAC,YAAY,KAAK,cAAc,EAAE,CAAC;QAC3C,OAAO,kQAAkQ,CAAC;IAC5Q,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QACzB,OAAO,sIAAsI,CAAC;IAChJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { CHECKPOINT_FAILED, instructUserDecision, REPLACE_WEDGED_APP, } from "./copy.js";
|
|
2
|
+
export function instructCheckAppProgress(result, profile) {
|
|
3
|
+
const navigation = profile.hasNativeBrowser
|
|
4
|
+
? result.value.browserNavigation
|
|
5
|
+
: undefined;
|
|
6
|
+
if (!isBrowserNavigation(navigation)) {
|
|
7
|
+
return resultInstructions(result, profile);
|
|
8
|
+
}
|
|
9
|
+
const instructions = resultInstructions(result, profile);
|
|
10
|
+
const browserInstructions = `CRITICAL DO NOT IGNORE: viewStatus is ready, before any other action, ensure ${navigation.url} is open in Cowork's embedded Page browser and verify the app loaded.`;
|
|
11
|
+
return instructions
|
|
12
|
+
? `${browserInstructions}\n\n${instructions}`
|
|
13
|
+
: browserInstructions;
|
|
14
|
+
}
|
|
15
|
+
function resultInstructions(result, profile) {
|
|
16
|
+
if (result.decisionKind === "missing_integrations") {
|
|
17
|
+
return "Create every entry in `decision.integrations`; do not call `ask_user` or relay manual setup steps. Call `create_integration` with each entry's name, pluginId, and configuration. When `configurationSchema` is present, use it directly and skip `get_integration_config_schema`; when it is absent, call `get_integration_config_schema` first. Follow each `create_integration` result's agentInstructions for configuration and app wiring.";
|
|
18
|
+
}
|
|
19
|
+
const decisionInstructions = instructUserDecision(result, profile);
|
|
20
|
+
if (decisionInstructions) {
|
|
21
|
+
return decisionInstructions;
|
|
22
|
+
}
|
|
23
|
+
if (result.pendingAction === "start_new_app") {
|
|
24
|
+
return REPLACE_WEDGED_APP;
|
|
25
|
+
}
|
|
26
|
+
if (result.status === "checkpoint_failed") {
|
|
27
|
+
return CHECKPOINT_FAILED;
|
|
28
|
+
}
|
|
29
|
+
// A death the gateway judged unrecoverable arrives without `retry_build`:
|
|
30
|
+
// either as `start_new_app` above, or as no pendingAction at all.
|
|
31
|
+
if (result.status === "live_edit_terminated" &&
|
|
32
|
+
result.pendingAction !== "retry_build") {
|
|
33
|
+
return "This is terminal. Report the reply to the user and stop - do not retry `edit_app` or create another application for this turn.";
|
|
34
|
+
}
|
|
35
|
+
if (result.pendingAction === "retry_build" &&
|
|
36
|
+
(result.status === "cancelled" ||
|
|
37
|
+
result.status === "live_edit_terminated" ||
|
|
38
|
+
result.status === "no_changes" ||
|
|
39
|
+
result.status === "timeout")) {
|
|
40
|
+
return "Call `edit_app` again on this `applicationId` - the last turn ended without writing anything, but the application itself is fine to retry.";
|
|
41
|
+
}
|
|
42
|
+
if (result.status === "building") {
|
|
43
|
+
const lines = superblocksActivity(result);
|
|
44
|
+
if (lines.length > 0) {
|
|
45
|
+
const them = lines.length === 1 ? "it" : "all of them";
|
|
46
|
+
return `The build is still running. Superblocks sent ${lines.length} new activity ${lines.length === 1 ? "line" : "lines"} in this result. CRITICAL DO NOT IGNORE: Between polls, write ${them} into your own reply, oldest first, verbatim. Then, call check_app_progress again.`;
|
|
47
|
+
}
|
|
48
|
+
return `Superblocks is still working. This is a long poll, as soon as any activity is available it will be relayed to you. Do not sleep, immediately call check_app_progress again.`;
|
|
49
|
+
}
|
|
50
|
+
if (result.status === "unknown") {
|
|
51
|
+
return "Tell the user that Superblocks progress tracking was interrupted and ask whether they want to continue. Only if the user says to continue, call `edit_app` on the same `applicationId` with their instruction.";
|
|
52
|
+
}
|
|
53
|
+
if (result.status === "ready") {
|
|
54
|
+
return "The app is ready. Call get_app to get the editor and preview URLs. Do not call check_app_progress again.";
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
function isBrowserNavigation(value) {
|
|
59
|
+
return (typeof value === "object" &&
|
|
60
|
+
value !== null &&
|
|
61
|
+
"action" in value &&
|
|
62
|
+
value.action === "open_editor" &&
|
|
63
|
+
"url" in value &&
|
|
64
|
+
typeof value.url === "string" &&
|
|
65
|
+
value.url.length > 0);
|
|
66
|
+
}
|
|
67
|
+
/** Gateway heartbeats are not Superblocks chat and must not trigger a relay. */
|
|
68
|
+
function superblocksActivity(result) {
|
|
69
|
+
const activity = result.value.activity;
|
|
70
|
+
if (!Array.isArray(activity)) {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
return activity.filter((line) => typeof line === "string" && line !== "Superblocks is still generating");
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=check-app-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-app-progress.js","sourceRoot":"","sources":["../../../../../src/transports/mcp/instructions/tools/check-app-progress.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AAEnB,MAAM,UAAU,wBAAwB,CACtC,MAAkB,EAClB,OAAsB;IAEtB,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB;QACzC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB;QAChC,CAAC,CAAC,SAAS,CAAC;IACd,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE,CAAC;QACrC,OAAO,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IACD,MAAM,YAAY,GAAG,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,MAAM,mBAAmB,GAAG,gFAAgF,UAAU,CAAC,GAAG,uEAAuE,CAAC;IAClM,OAAO,YAAY;QACjB,CAAC,CAAC,GAAG,mBAAmB,OAAO,YAAY,EAAE;QAC7C,CAAC,CAAC,mBAAmB,CAAC;AAC1B,CAAC;AAED,SAAS,kBAAkB,CACzB,MAAkB,EAClB,OAAsB;IAEtB,IAAI,MAAM,CAAC,YAAY,KAAK,sBAAsB,EAAE,CAAC;QACnD,OAAO,ibAAib,CAAC;IAC3b,CAAC;IACD,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,IAAI,oBAAoB,EAAE,CAAC;QACzB,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IACD,IAAI,MAAM,CAAC,aAAa,KAAK,eAAe,EAAE,CAAC;QAC7C,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,mBAAmB,EAAE,CAAC;QAC1C,OAAO,iBAAiB,CAAC;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IAAI,KAAK;QACjB,KAAK,CAAC,MAAM,KAAK,aAAa;QAC9B,KAAK,IAAI,KAAK;QACd,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ;QAC7B,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CACrB,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,SAAS,mBAAmB,CAAC,MAAkB;IAC7C,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;IACvC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,QAAQ,CAAC,MAAM,CACpB,CAAC,IAAI,EAAkB,EAAE,CACvB,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,iCAAiC,CACzE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { instructPublishDetails } from "./copy.js";
|
|
2
|
+
export function instructCheckPublishProgress(result, profile) {
|
|
3
|
+
const instructions = resultInstructions(result);
|
|
4
|
+
const navigation = instructPublishDetails(result, profile);
|
|
5
|
+
if (!navigation) {
|
|
6
|
+
return instructions;
|
|
7
|
+
}
|
|
8
|
+
return instructions ? `${navigation}\n\n${instructions}` : navigation;
|
|
9
|
+
}
|
|
10
|
+
function resultInstructions(result) {
|
|
11
|
+
if (result.code === "publish_not_started") {
|
|
12
|
+
return "The publish cursor was not available. Retry `check_publish_progress` with both the `applicationId` and `commitId` returned by `publish_app`. Call `publish_app` only if nothing was ever queued.";
|
|
13
|
+
}
|
|
14
|
+
if (result.status === "publishing") {
|
|
15
|
+
const elapsedSeconds = result.value.elapsedSeconds;
|
|
16
|
+
const elapsed = typeof elapsedSeconds === "number" && Number.isFinite(elapsedSeconds)
|
|
17
|
+
? ` for ${Math.max(0, Math.floor(elapsedSeconds))} seconds`
|
|
18
|
+
: "";
|
|
19
|
+
return `The rollout is still running${elapsed}, so the app is not live yet - do not tell the user it is. Continue to call \`check_publish_progress\` until the app is live. Do not call \`publish_app\` again.`;
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=check-publish-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-publish-progress.js","sourceRoot":"","sources":["../../../../../src/transports/mcp/instructions/tools/check-publish-progress.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,MAAM,UAAU,4BAA4B,CAC1C,MAAkB,EAClB,OAAsB;IAEtB,MAAM,YAAY,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,UAAU,GAAG,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3D,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,YAAY,CAAC,CAAC,CAAC,GAAG,UAAU,OAAO,YAAY,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;AACxE,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAkB;IAC5C,IAAI,MAAM,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;QAC1C,OAAO,kMAAkM,CAAC;IAC5M,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;QACnC,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC;QACnD,MAAM,OAAO,GACX,OAAO,cAAc,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC;YACnE,CAAC,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,UAAU;YAC3D,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,+BAA+B,OAAO,kKAAkK,CAAC;IAClN,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Instructions shared verbatim by more than one tool. */
|
|
2
|
+
import type { ClientProfile } from "../../client-presentation.js";
|
|
3
|
+
import type { ToolResult } from "../result.js";
|
|
4
|
+
export declare const BUILDING_FOLLOW_UP = "Call `check_app_progress` with this `applicationId` to follow the turn. Relay each new activity line to the user as it arrives. CRITICAL: Load your embedded browser tools.";
|
|
5
|
+
export declare const CHECKPOINT_FAILED = "The build finished but did not save. Do not tell the user the app was saved, and do not poll again - open the editor via this result's `editUrl` and report that the checkpoint failed.";
|
|
6
|
+
export declare const REPLACE_WEDGED_APP = "This application is wedged and cannot be recovered. Call `start_app` once more with the same prompt and artifacts, and set `replacesApplicationId` to this result's `applicationId`. Do not upload the source again.";
|
|
7
|
+
export declare const RETRY_UNAVAILABLE_LIVE_EDIT = "Call `edit_app` again on this `applicationId` with the same prompt. The live-edit session was unavailable; the application itself is still there.";
|
|
8
|
+
export declare const SHOW_PLAN_VERBATIM = "Lead with `decision.title` when it is present, then show the entire `decision.plan` markdown, verbatim, laid out as markdown. Do not paraphrase, summarize, shorten, reorder, or re-level its headings - the user is approving exactly this text.";
|
|
9
|
+
/**
|
|
10
|
+
* The publish details page shows the rollout live, so Cowork opens it for the
|
|
11
|
+
* whole publish rather than at the end. Other hosts only ever show the link.
|
|
12
|
+
*/
|
|
13
|
+
export declare function instructPublishDetails(result: ToolResult, profile: ClientProfile): string | undefined;
|
|
14
|
+
export declare function instructUserDecision(result: ToolResult, profile: ClientProfile): string | undefined;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Instructions shared verbatim by more than one tool. */
|
|
2
|
+
import { withCoworkEditorHost } from "../../cowork-editor-url.js";
|
|
3
|
+
export const BUILDING_FOLLOW_UP = "Call `check_app_progress` with this `applicationId` to follow the turn. Relay each new activity line to the user as it arrives. CRITICAL: Load your embedded browser tools.";
|
|
4
|
+
export const CHECKPOINT_FAILED = "The build finished but did not save. Do not tell the user the app was saved, and do not poll again - open the editor via this result's `editUrl` and report that the checkpoint failed.";
|
|
5
|
+
export const REPLACE_WEDGED_APP = "This application is wedged and cannot be recovered. Call `start_app` once more with the same prompt and artifacts, and set `replacesApplicationId` to this result's `applicationId`. Do not upload the source again.";
|
|
6
|
+
export const RETRY_UNAVAILABLE_LIVE_EDIT = "Call `edit_app` again on this `applicationId` with the same prompt. The live-edit session was unavailable; the application itself is still there.";
|
|
7
|
+
export const SHOW_PLAN_VERBATIM = "Lead with `decision.title` when it is present, then show the entire `decision.plan` markdown, verbatim, laid out as markdown. Do not paraphrase, summarize, shorten, reorder, or re-level its headings - the user is approving exactly this text.";
|
|
8
|
+
/**
|
|
9
|
+
* The publish details page shows the rollout live, so Cowork opens it for the
|
|
10
|
+
* whole publish rather than at the end. Other hosts only ever show the link.
|
|
11
|
+
*/
|
|
12
|
+
export function instructPublishDetails(result, profile) {
|
|
13
|
+
const url = result.value.publishDetailsUrl;
|
|
14
|
+
if (!profile.hasNativeBrowser ||
|
|
15
|
+
(result.status !== "publishing" && result.status !== "deployed") ||
|
|
16
|
+
typeof url !== "string" ||
|
|
17
|
+
!url) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return `Before any other action, ensure ${withCoworkEditorHost(url)} is open in Cowork's embedded Page browser and verify the publish details loaded.`;
|
|
21
|
+
}
|
|
22
|
+
export function instructUserDecision(result, profile) {
|
|
23
|
+
if (result.decisionKind === "plan") {
|
|
24
|
+
return profile.hasNativeAskForm
|
|
25
|
+
? `Use your native ask form to put this plan decision to the user. Do not call ask_user. Output the plan markdown as text, not in the native form. ${SHOW_PLAN_VERBATIM} In your native form, present exactly two choices labeled \`Approve\` and \`Refine\`. In \`Refine\`'s description, refer to the form's built-in free-text field only as \`Something else\`. Do not answer the decision yourself and do not call check_app_progress again until they have answered. If the user chooses \`Approve\`, call edit_app with the applicationId from this result and planAction "approve" with no prompt. If the form returns text in its \`response\` field, call edit_app with that applicationId, planAction "refine", and the exact \`response\` as prompt. If the user chooses \`Refine\` without feedback, ask the user for further instructions`
|
|
26
|
+
: "Call ask_user now to put this plan decision to the user. Do not answer it yourself and do not call check_app_progress again until they have answered.";
|
|
27
|
+
}
|
|
28
|
+
if (result.decisionKind === "multi_choice") {
|
|
29
|
+
return profile.hasNativeAskForm
|
|
30
|
+
? "Use your native ask form to put this multi-choice decision to the user. Do not call ask_user. Present the available options and ask the user to choose one. Do not answer the decision yourself and do not call check_app_progress again until they have answered. Send their answer through edit_app, using the chosen option as the prompt. Provide their answer EXACTLY as they provided it to edit_app."
|
|
31
|
+
: "Call ask_user now to put this multi-choice decision to the user. Do not answer it yourself and do not call check_app_progress again until they have answered.";
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy.js","sourceRoot":"","sources":["../../../../../src/transports/mcp/instructions/tools/copy.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAG1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGlE,MAAM,CAAC,MAAM,kBAAkB,GAC7B,6KAA6K,CAAC;AAEhL,MAAM,CAAC,MAAM,iBAAiB,GAC5B,yLAAyL,CAAC;AAE5L,MAAM,CAAC,MAAM,kBAAkB,GAC7B,sNAAsN,CAAC;AAEzN,MAAM,CAAC,MAAM,2BAA2B,GACtC,mJAAmJ,CAAC;AAEtJ,MAAM,CAAC,MAAM,kBAAkB,GAC7B,mPAAmP,CAAC;AAEtP;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAkB,EAClB,OAAsB;IAEtB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAC3C,IACE,CAAC,OAAO,CAAC,gBAAgB;QACzB,CAAC,MAAM,CAAC,MAAM,KAAK,YAAY,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,CAAC;QAChE,OAAO,GAAG,KAAK,QAAQ;QACvB,CAAC,GAAG,EACJ,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,mCAAmC,oBAAoB,CAAC,GAAG,CAAC,mFAAmF,CAAC;AACzJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,MAAkB,EAClB,OAAsB;IAEtB,IAAI,MAAM,CAAC,YAAY,KAAK,MAAM,EAAE,CAAC;QACnC,OAAO,OAAO,CAAC,gBAAgB;YAC7B,CAAC,CAAC,mJAAmJ,kBAAkB,ipBAAipB;YACxzB,CAAC,CAAC,uJAAuJ,CAAC;IAC9J,CAAC;IACD,IAAI,MAAM,CAAC,YAAY,KAAK,cAAc,EAAE,CAAC;QAC3C,OAAO,OAAO,CAAC,gBAAgB;YAC7B,CAAC,CAAC,6YAA6Y;YAC/Y,CAAC,CAAC,+JAA+J,CAAC;IACtK,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ClientProfile } from "../../client-presentation.js";
|
|
2
|
+
import { type ToolResult } from "../result.js";
|
|
3
|
+
export declare function instructCreateIntegration(result: ToolResult, profile: ClientProfile): string | undefined;
|
|
4
|
+
export declare function isPublicIntegration(value: Record<string, unknown>): boolean;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isEditorIntegrationSetupUrl } from "../../editor-integration-setup-url.js";
|
|
2
|
+
import { isRecord } from "../result.js";
|
|
3
|
+
export function instructCreateIntegration(result, profile) {
|
|
4
|
+
const url = result.value.integration_url;
|
|
5
|
+
const integrationId = result.value.integration_id;
|
|
6
|
+
if (typeof integrationId !== "string" || !integrationId) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const editorSetup = typeof url === "string" && url ? isEditorIntegrationSetupUrl(url) : false;
|
|
10
|
+
const opening = typeof url === "string" && url
|
|
11
|
+
? profile.hasNativeBrowser
|
|
12
|
+
? editorSetup
|
|
13
|
+
? `Open the exact returned URL ${url} in Cowork's embedded browser side panel even if the app editor is already open. That URL opens the Integrations tab inside the editor so the user can enter credentials there. Do not navigate to the org Integrations page.`
|
|
14
|
+
: `Open the exact returned URL ${url} in Cowork's embedded browser side panel.`
|
|
15
|
+
: editorSetup
|
|
16
|
+
? "Show `integration_url` to the user and ask them to open it. It opens the Integrations tab in the editor so they can enter credentials there. Do not send them to the org Integrations page. Do not open it yourself."
|
|
17
|
+
: "Show `integration_url` to the user and ask them to open it in Superblocks. Do not open it yourself."
|
|
18
|
+
: "Tell the user to open the integration in Superblocks, but do not invent a URL.";
|
|
19
|
+
const stayInEditor = editorSetup
|
|
20
|
+
? " After they confirm, they are still in the editor."
|
|
21
|
+
: "";
|
|
22
|
+
const wiring = `Call \`edit_app\` with returned integration_id \`${integrationId}\` and tell Superblocks to wire it into every affected API, test those APIs, and remove temporary setup instructions.`;
|
|
23
|
+
if (isPublicIntegration(result.value)) {
|
|
24
|
+
return `${opening} This result confirms the integration uses public/no-auth access, so do not wait for credential confirmation. ${wiring}`;
|
|
25
|
+
}
|
|
26
|
+
return `${opening} Never ask the user to put passwords, API tokens, or other secrets in chat.${stayInEditor} Wait for the user to confirm configuration is complete, then ${wiring}`;
|
|
27
|
+
}
|
|
28
|
+
export function isPublicIntegration(value) {
|
|
29
|
+
const integration = value.integration;
|
|
30
|
+
if (!isRecord(integration) || !Array.isArray(integration.configurations)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return integration.configurations.some((entry) => {
|
|
34
|
+
if (!isRecord(entry) || !isRecord(entry.configuration)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const authType = entry.configuration.authType;
|
|
38
|
+
return typeof authType === "string" && authType.toLowerCase() === "none";
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=create-integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-integration.js","sourceR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CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAA8B;IAChE,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IACtC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE,CAAC;QACzE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QAC/C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC;YACvD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC;QAC9C,OAAO,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BUILDING_FOLLOW_UP, REPLACE_WEDGED_APP, RETRY_UNAVAILABLE_LIVE_EDIT, } from "./copy.js";
|
|
2
|
+
export function instructEditApp(result) {
|
|
3
|
+
if (result.pendingAction === "start_new_app") {
|
|
4
|
+
return REPLACE_WEDGED_APP;
|
|
5
|
+
}
|
|
6
|
+
if (result.code === "live_edit_unavailable" &&
|
|
7
|
+
result.pendingAction === "retry_build") {
|
|
8
|
+
return RETRY_UNAVAILABLE_LIVE_EDIT;
|
|
9
|
+
}
|
|
10
|
+
if (result.code === "live_edit_unavailable") {
|
|
11
|
+
return "This application's live-edit session is wedged, but it already has committed work - do not start a new application. Report to the user that this application needs manual recovery and stop.";
|
|
12
|
+
}
|
|
13
|
+
if (result.status === "building") {
|
|
14
|
+
return BUILDING_FOLLOW_UP;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=edit-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-app.js","sourceRoot":"","sources":["../../../../../src/transports/mcp/instructions/tools/edit-app.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,GAC5B,MAAM,WAAW,CAAC;AAEnB,MAAM,UAAU,eAAe,CAAC,MAAkB;IAChD,IAAI,MAAM,CAAC,aAAa,KAAK,eAAe,EAAE,CAAC;QAC7C,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,IACE,MAAM,CAAC,IAAI,KAAK,uBAAuB;QACvC,MAAM,CAAC,aAAa,KAAK,aAAa,EACtC,CAAC;QACD,OAAO,2BAA2B,CAAC;IACrC,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,uBAAuB,EAAE,CAAC;QAC5C,OAAO,8LAA8L,CAAC;IACxM,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|