@superblocksteam/gateway 2.0.161 → 2.0.162-next.1
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/README.md +135 -39
- package/dist/agents/resolve-orchestrator-url.d.ts +18 -0
- package/dist/agents/resolve-orchestrator-url.js +64 -1
- package/dist/agents/resolve-orchestrator-url.js.map +1 -1
- package/dist/capabilities/lifecycle.d.ts +46 -29
- package/dist/capabilities/lifecycle.js +1731 -843
- package/dist/capabilities/lifecycle.js.map +1 -1
- 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 +197 -119
- package/dist/capabilities/types.js +45 -6
- package/dist/capabilities/types.js.map +1 -1
- package/dist/capture/browser-contract.d.ts +15 -5
- package/dist/capture/browser-contract.js +13 -3
- package/dist/capture/browser-contract.js.map +1 -1
- package/dist/capture/browser-instructions.d.ts +3 -2
- package/dist/capture/browser-instructions.js +3 -2
- package/dist/capture/browser-instructions.js.map +1 -1
- package/dist/capture/mode.d.ts +8 -1
- package/dist/capture/mode.js +22 -2
- package/dist/capture/mode.js.map +1 -1
- package/dist/config.d.ts +22 -23
- package/dist/config.js +13 -12
- package/dist/config.js.map +1 -1
- package/dist/deps.d.ts +7 -7
- package/dist/index.d.ts +2 -4
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- 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.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/playwright/ensure-chromium.d.ts +5 -7
- package/dist/playwright/ensure-chromium.js +13 -13
- package/dist/playwright/ensure-chromium.js.map +1 -1
- package/dist/preview/capture-screenshot.d.ts +30 -4
- package/dist/preview/capture-screenshot.js +67 -17
- package/dist/preview/capture-screenshot.js.map +1 -1
- package/dist/preview/viewer-url.js +3 -1
- package/dist/preview/viewer-url.js.map +1 -1
- package/dist/process/fault-barrier.js +1 -1
- package/dist/process/fault-barrier.js.map +1 -1
- package/dist/sabs/agent-facing-text.d.ts +2 -0
- package/dist/sabs/agent-facing-text.js +56 -2
- package/dist/sabs/agent-facing-text.js.map +1 -1
- 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 +49 -0
- package/dist/sabs/awaited-decision.js +129 -0
- package/dist/sabs/awaited-decision.js.map +1 -0
- package/dist/sabs/editor-client-methods.d.ts +23 -5
- package/dist/sabs/editor-client-methods.js +45 -4
- package/dist/sabs/editor-client-methods.js.map +1 -1
- package/dist/sabs/editor-socket.d.ts +85 -0
- package/dist/sabs/editor-socket.js +67 -0
- package/dist/sabs/editor-socket.js.map +1 -0
- package/dist/sabs/session-peer.d.ts +119 -82
- package/dist/sabs/session-peer.js +10 -1
- package/dist/sabs/session-peer.js.map +1 -1
- package/dist/sabs/streamed-reply.d.ts +45 -0
- package/dist/sabs/streamed-reply.js +125 -0
- package/dist/sabs/streamed-reply.js.map +1 -0
- package/dist/sabs/turn-collector.d.ts +50 -35
- package/dist/sabs/turn-collector.js +110 -176
- package/dist/sabs/turn-collector.js.map +1 -1
- package/dist/sabs/websocket-session-peer.d.ts +104 -69
- package/dist/sabs/websocket-session-peer.js +1333 -477
- package/dist/sabs/websocket-session-peer.js.map +1 -1
- package/dist/server/client.d.ts +41 -9
- package/dist/server/client.js +126 -21
- package/dist/server/client.js.map +1 -1
- package/dist/start.d.ts +1 -1
- package/dist/start.js +30 -8
- package/dist/start.js.map +1 -1
- package/dist/stores/memory.d.ts +46 -0
- package/dist/stores/memory.js +163 -0
- package/dist/stores/memory.js.map +1 -0
- package/dist/stores/types.d.ts +92 -0
- package/dist/stores/types.js +11 -0
- package/dist/stores/types.js.map +1 -0
- package/dist/telemetry/mcp-client.d.ts +6 -1
- package/dist/telemetry/mcp-client.js +100 -4
- package/dist/telemetry/mcp-client.js.map +1 -1
- package/dist/telemetry/metrics.d.ts +12 -3
- package/dist/telemetry/metrics.js +60 -14
- package/dist/telemetry/metrics.js.map +1 -1
- package/dist/telemetry/runtime.js +4 -6
- package/dist/telemetry/runtime.js.map +1 -1
- package/dist/transports/mcp/admin-tools.d.ts +8 -0
- package/dist/transports/mcp/admin-tools.js +115 -4
- package/dist/transports/mcp/admin-tools.js.map +1 -1
- package/dist/transports/mcp/app-status-html.d.ts +4 -8
- package/dist/transports/mcp/app-status-html.js +336 -128
- package/dist/transports/mcp/app-status-html.js.map +1 -1
- 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 +42 -0
- package/dist/transports/mcp/decision-elicitation.js +59 -0
- package/dist/transports/mcp/decision-elicitation.js.map +1 -1
- 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 +14 -0
- package/dist/transports/mcp/editor-integration-setup-url.js +29 -0
- package/dist/transports/mcp/editor-integration-setup-url.js.map +1 -0
- package/dist/transports/mcp/format-tool-content.d.ts +13 -18
- package/dist/transports/mcp/format-tool-content.js +172 -13
- package/dist/transports/mcp/format-tool-content.js.map +1 -1
- 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 +20 -0
- package/dist/transports/mcp/instructions/tools/ask-user.js.map +1 -0
- package/dist/transports/mcp/instructions/tools/build-app.d.ts +4 -0
- package/dist/transports/mcp/instructions/tools/build-app.js +54 -0
- package/dist/transports/mcp/instructions/tools/build-app.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 +79 -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 +18 -0
- package/dist/transports/mcp/instructions/tools/copy.js +49 -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 +3 -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 +49 -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 +31 -0
- package/dist/transports/mcp/instructions/tools/index.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 +3 -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 +14 -1
- package/dist/transports/mcp/mount.js +729 -172
- package/dist/transports/mcp/mount.js.map +1 -1
- 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 +44 -0
- package/dist/transports/mcp/plan-approval.js +179 -0
- package/dist/transports/mcp/plan-approval.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 +16 -7
- package/skills/superblocks-build/SKILL.md +59 -0
- package/skills/superblocks-import/SKILL.md +125 -0
- package/dist/capabilities/import-prompt.d.ts +0 -11
- package/dist/capabilities/import-prompt.js +0 -96
- package/dist/capabilities/import-prompt.js.map +0 -1
- package/dist/capabilities/persisted-progress.d.ts +0 -46
- package/dist/capabilities/persisted-progress.js +0 -246
- package/dist/capabilities/persisted-progress.js.map +0 -1
- package/dist/events/cursor.d.ts +0 -43
- package/dist/events/cursor.js +0 -78
- package/dist/events/cursor.js.map +0 -1
- package/dist/events/memory-event-store.d.ts +0 -34
- package/dist/events/memory-event-store.js +0 -110
- package/dist/events/memory-event-store.js.map +0 -1
- package/dist/events/merge.d.ts +0 -23
- package/dist/events/merge.js +0 -97
- package/dist/events/merge.js.map +0 -1
- package/dist/events/normalized-collector.d.ts +0 -62
- package/dist/events/normalized-collector.js +0 -156
- package/dist/events/normalized-collector.js.map +0 -1
- package/dist/events/schema.d.ts +0 -9
- package/dist/events/schema.js +0 -93
- package/dist/events/schema.js.map +0 -1
- package/dist/events/snapshot.d.ts +0 -32
- package/dist/events/snapshot.js +0 -57
- package/dist/events/snapshot.js.map +0 -1
- package/dist/events/stream-key.d.ts +0 -2
- package/dist/events/stream-key.js +0 -31
- package/dist/events/stream-key.js.map +0 -1
- package/dist/events/types.d.ts +0 -179
- package/dist/events/types.js +0 -66
- package/dist/events/types.js.map +0 -1
- package/dist/resume/memory-progress-store.d.ts +0 -39
- package/dist/resume/memory-progress-store.js +0 -82
- package/dist/resume/memory-progress-store.js.map +0 -1
- package/dist/resume/memory-recent-app-store.d.ts +0 -14
- package/dist/resume/memory-recent-app-store.js +0 -27
- package/dist/resume/memory-recent-app-store.js.map +0 -1
- package/dist/resume/memory-turn-store.d.ts +0 -18
- package/dist/resume/memory-turn-store.js +0 -73
- package/dist/resume/memory-turn-store.js.map +0 -1
- package/dist/resume/progress-key.d.ts +0 -21
- package/dist/resume/progress-key.js +0 -58
- package/dist/resume/progress-key.js.map +0 -1
- package/dist/resume/stores.d.ts +0 -14
- package/dist/resume/stores.js +0 -18
- package/dist/resume/stores.js.map +0 -1
- package/dist/resume/types.d.ts +0 -124
- package/dist/resume/types.js +0 -13
- package/dist/resume/types.js.map +0 -1
|
@@ -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,c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{ 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,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vB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CACtB,KAA8B;IAE9B,QAAQ,KAAK,CAAC,aAAa,EAAE,CAAC;QAC5B,KAAK,iBAAiB,CAAC;QACvB,KAAK,cAAc,CAAC;QACpB,KAAK,oBAAoB,CAAC;QAC1B,KAAK,kBAAkB,CAAC;QACxB,KAAK,aAAa,CAAC;QACnB,KAAK,aAAa,CAAC;QACnB,KAAK,eAAe,CAAC;QACrB,KAAK,gBAAgB;YACnB,OAAO,KAAK,CAAC,aAAa,CAAC;QAC7B;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DECIDE_IN_EDITOR, SHOW_PLAN_VERBATIM } from "./copy.js";
|
|
2
|
+
export function instructAskUser(result) {
|
|
3
|
+
if (!result.ok) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
if (result.pendingAction === "decide_in_editor") {
|
|
7
|
+
return DECIDE_IN_EDITOR;
|
|
8
|
+
}
|
|
9
|
+
if (result.decisionKind === "plan") {
|
|
10
|
+
return `Show this plan in the chat stream. ${SHOW_PLAN_VERBATIM} Do not put the plan in a question widget or ask form.`;
|
|
11
|
+
}
|
|
12
|
+
if (result.decisionKind === "multi_choice") {
|
|
13
|
+
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.";
|
|
14
|
+
}
|
|
15
|
+
if (!result.decisionKind) {
|
|
16
|
+
return "Nothing is waiting on the user right now. Follow the build instead: call `check_app_progress` or `get_app` rather than asking again.";
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
//# 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,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEjE,MAAM,UAAU,eAAe,CAAC,MAAkB;IAChD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,MAAM,CAAC,aAAa,KAAK,kBAAkB,EAAE,CAAC;QAChD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD,IAAI,MAAM,CAAC,YAAY,KAAK,MAAM,EAAE,CAAC;QACnC,OAAO,sCAAsC,kBAAkB,wDAAwD,CAAC;IAC1H,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,4 @@
|
|
|
1
|
+
import type { ClientProfile } from "../../client-presentation.js";
|
|
2
|
+
import type { ToolResult } from "../result.js";
|
|
3
|
+
export declare function instructBuildApp(result: ToolResult, profile: ClientProfile): string | undefined;
|
|
4
|
+
export declare function instructGetPreviewStatus(result: ToolResult, profile: ClientProfile): string | undefined;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const PRIVATE_PREVIEW = "This is an unpublished preview. Building it did not change app permissions; do not publish it or change permissions unless the user explicitly asks. The URL may carry a scoped preview credential, so give it only to the user or recipient who requested it and do not post it publicly.";
|
|
2
|
+
export function instructBuildApp(result, profile) {
|
|
3
|
+
if (result.status === "building") {
|
|
4
|
+
const cursor = previewStatusCursor(result);
|
|
5
|
+
if (!cursor) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
const previewUrl = result.value.previewUrl;
|
|
9
|
+
const savedUrl = typeof previewUrl === "string" && previewUrl
|
|
10
|
+
? ` Keep ${previewUrl} as the preview URL for this commit.`
|
|
11
|
+
: "";
|
|
12
|
+
return `The commit preview is still building.${savedUrl} Call \`get_preview_status\` with ${cursor} until it reports \`ready\` or \`failed\`. Do not call \`build_app\` again to poll because that would create another commit.`;
|
|
13
|
+
}
|
|
14
|
+
const previewUrl = result.value.previewUrl;
|
|
15
|
+
if (result.status !== "ready" ||
|
|
16
|
+
typeof previewUrl !== "string" ||
|
|
17
|
+
!previewUrl) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const action = profile.hasNativeBrowser
|
|
21
|
+
? `Before any other action, ensure ${previewUrl} is open in Cowork's embedded Page browser and verify only that the commit preview loaded.`
|
|
22
|
+
: `Give the user ${previewUrl}, the exact URL for this commit preview.`;
|
|
23
|
+
return `${action} ${PRIVATE_PREVIEW}`;
|
|
24
|
+
}
|
|
25
|
+
export function instructGetPreviewStatus(result, profile) {
|
|
26
|
+
if (result.status === "building") {
|
|
27
|
+
return instructBuildApp(result, profile);
|
|
28
|
+
}
|
|
29
|
+
if (result.status === "ready") {
|
|
30
|
+
const action = profile.hasNativeBrowser
|
|
31
|
+
? "Before any other action, open the exact `previewUrl` from the original `build_app` result in Cowork's embedded Page browser and verify only that the commit preview loaded."
|
|
32
|
+
: "Give the user the exact `previewUrl` from the original `build_app` result.";
|
|
33
|
+
return `${action} ${PRIVATE_PREVIEW}`;
|
|
34
|
+
}
|
|
35
|
+
if (result.status === "failed") {
|
|
36
|
+
return "The commit preview build failed. Tell the user it is not ready. Do not open the preview URL, call `build_app` again, or publish it; wait for the user to decide what to do next.";
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
function previewStatusCursor(result) {
|
|
41
|
+
const { applicationId, branch, commitId, directoryHash } = result.value;
|
|
42
|
+
if (typeof applicationId !== "string" ||
|
|
43
|
+
typeof commitId !== "string" ||
|
|
44
|
+
typeof directoryHash !== "string") {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return JSON.stringify({
|
|
48
|
+
applicationId,
|
|
49
|
+
...(typeof branch === "string" ? { branch } : {}),
|
|
50
|
+
commitId,
|
|
51
|
+
directoryHash,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=build-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-app.js","sourceRoot":"","sources":["../../../../../src/transports/mcp/instructions/tools/build-app.ts"],"names":[],"mappings":"AAGA,MAAM,eAAe,GACnB,4RAA4R,CAAC;AAE/R,MAAM,UAAU,gBAAgB,CAC9B,MAAkB,EAClB,OAAsB;IAEtB,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;QAC3C,MAAM,QAAQ,GACZ,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU;YAC1C,CAAC,CAAC,SAAS,UAAU,sCAAsC;YAC3D,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,wCAAwC,QAAQ,qCAAqC,MAAM,8HAA8H,CAAC;IACnO,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;IAC3C,IACE,MAAM,CAAC,MAAM,KAAK,OAAO;QACzB,OAAO,UAAU,KAAK,QAAQ;QAC9B,CAAC,UAAU,EACX,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB;QACrC,CAAC,CAAC,mCAAmC,UAAU,4FAA4F;QAC3I,CAAC,CAAC,iBAAiB,UAAU,0CAA0C,CAAC;IAC1E,OAAO,GAAG,MAAM,IAAI,eAAe,EAAE,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,MAAkB,EAClB,OAAsB;IAEtB,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,OAAO,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB;YACrC,CAAC,CAAC,6KAA6K;YAC/K,CAAC,CAAC,4EAA4E,CAAC;QACjF,OAAO,GAAG,MAAM,IAAI,eAAe,EAAE,CAAC;IACxC,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,kLAAkL,CAAC;IAC5L,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAkB;IAC7C,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;IACxE,IACE,OAAO,aAAa,KAAK,QAAQ;QACjC,OAAO,QAAQ,KAAK,QAAQ;QAC5B,OAAO,aAAa,KAAK,QAAQ,EACjC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,aAAa;QACb,GAAG,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,QAAQ;QACR,aAAa;KACd,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { APP_LOAD_CHECK, CHECKPOINT_FAILED, DECIDE_IN_EDITOR, 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 = result.pendingAction === "decide_in_editor"
|
|
11
|
+
? `CRITICAL DO NOT IGNORE: Before any other action, ensure ${navigation.url} is open in Cowork's embedded Page browser.`
|
|
12
|
+
: `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. ${APP_LOAD_CHECK}`;
|
|
13
|
+
return instructions
|
|
14
|
+
? `${browserInstructions}\n\n${instructions}`
|
|
15
|
+
: browserInstructions;
|
|
16
|
+
}
|
|
17
|
+
function resultInstructions(result, profile) {
|
|
18
|
+
if (result.decisionKind === "missing_integrations") {
|
|
19
|
+
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.";
|
|
20
|
+
}
|
|
21
|
+
const decisionInstructions = instructUserDecision(result, profile);
|
|
22
|
+
if (decisionInstructions) {
|
|
23
|
+
return decisionInstructions;
|
|
24
|
+
}
|
|
25
|
+
if (result.pendingAction === "decide_in_editor") {
|
|
26
|
+
return DECIDE_IN_EDITOR;
|
|
27
|
+
}
|
|
28
|
+
if (result.pendingAction === "start_new_app") {
|
|
29
|
+
return REPLACE_WEDGED_APP;
|
|
30
|
+
}
|
|
31
|
+
if (result.status === "checkpoint_failed") {
|
|
32
|
+
return CHECKPOINT_FAILED;
|
|
33
|
+
}
|
|
34
|
+
// A death the gateway judged unrecoverable arrives without `retry_build`:
|
|
35
|
+
// either as `start_new_app` above, or as no pendingAction at all.
|
|
36
|
+
if (result.status === "live_edit_terminated" &&
|
|
37
|
+
result.pendingAction !== "retry_build") {
|
|
38
|
+
return "This is terminal. Report the reply to the user and stop - do not retry `edit_app` or create another application for this turn.";
|
|
39
|
+
}
|
|
40
|
+
if (result.pendingAction === "retry_build" &&
|
|
41
|
+
(result.status === "cancelled" ||
|
|
42
|
+
result.status === "live_edit_terminated" ||
|
|
43
|
+
result.status === "no_changes" ||
|
|
44
|
+
result.status === "timeout")) {
|
|
45
|
+
return "Call `edit_app` again on this `applicationId` - the last turn ended without writing anything, but the application itself is fine to retry.";
|
|
46
|
+
}
|
|
47
|
+
if (result.status === "building") {
|
|
48
|
+
const lines = superblocksActivity(result);
|
|
49
|
+
if (lines.length > 0) {
|
|
50
|
+
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 each new activity line into your own reply as a separate paragraph, oldest first, verbatim. Then, call check_app_progress again.`;
|
|
51
|
+
}
|
|
52
|
+
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.`;
|
|
53
|
+
}
|
|
54
|
+
if (result.status === "unknown") {
|
|
55
|
+
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.";
|
|
56
|
+
}
|
|
57
|
+
if (result.status === "ready") {
|
|
58
|
+
return "The app is ready. Call get_app to get the editor and preview URLs. Do not call check_app_progress again.";
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
function isBrowserNavigation(value) {
|
|
63
|
+
return (typeof value === "object" &&
|
|
64
|
+
value !== null &&
|
|
65
|
+
"action" in value &&
|
|
66
|
+
value.action === "open_editor" &&
|
|
67
|
+
"url" in value &&
|
|
68
|
+
typeof value.url === "string" &&
|
|
69
|
+
value.url.length > 0);
|
|
70
|
+
}
|
|
71
|
+
/** Gateway heartbeats are not Superblocks chat and must not trigger a relay. */
|
|
72
|
+
function superblocksActivity(result) {
|
|
73
|
+
const activity = result.value.activity;
|
|
74
|
+
if (!Array.isArray(activity)) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
return activity.filter((line) => typeof line === "string" && line !== "Superblocks is still generating");
|
|
78
|
+
}
|
|
79
|
+
//# 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,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,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,GACvB,MAAM,CAAC,aAAa,KAAK,kBAAkB;QACzC,CAAC,CAAC,2DAA2D,UAAU,CAAC,GAAG,6CAA6C;QACxH,CAAC,CAAC,gFAAgF,UAAU,CAAC,GAAG,yEAAyE,cAAc,EAAE,CAAC;IAC9L,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;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,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,gNAAgN,CAAC;IAC1N,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QAC9B,OAAO,0GAA0G,CAAC;IACpH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,mBAAmB,CAC1B,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,QAAQ,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,18 @@
|
|
|
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 APP_LOAD_CHECK = "Your automatic verification is a load check and inspection of visible state, not a feature-by-feature test run. Run interactive feature tests only when the user requests testing. Do not click app controls or inspect API traffic as part of a load check; normal navigation and authentication are allowed. Keep relaying Superblocks' own test results. Do not claim features passed from a load check alone.";
|
|
5
|
+
export declare const APP_SHARING_CHOICE = "For an ambiguous sharing request, ask the user to choose live preview, an unpublished commit preview, or publishing. Present all three options without choosing one for them. Do not assume publishing is required because the app has not been deployed: live and commit previews use existing app permissions without publishing. Only publish or change access when the user explicitly requests that action.";
|
|
6
|
+
export declare const COWORK_BROWSER_TOOLSEARCH = "select:mcp__remote-devices__Claude_Browser__preview_start,mcp__remote-devices__Claude_Browser__navigate,mcp__remote-devices__Claude_Browser__tabs_context";
|
|
7
|
+
export declare function buildingFollowUp(profile: ClientProfile): string;
|
|
8
|
+
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.";
|
|
9
|
+
export declare const DECIDE_IN_EDITOR = "Open only the exact editor URL provided by this result so the user can answer in the Superblocks editor. When `browserNavigation` is present, follow its exact URL; otherwise use the exact URL in `editUrl`. Only the user may answer this decision. Do not click anything in the editor. Do not type anything in the editor. Do not switch between Plan and Build modes. Do not submit anything. Do not call `ask_user`. Stop and wait for the user.";
|
|
10
|
+
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.";
|
|
11
|
+
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.";
|
|
12
|
+
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 in the chat stream. Do not paraphrase, summarize, shorten, reorder, or re-level its headings - the user is approving exactly this text.";
|
|
13
|
+
/**
|
|
14
|
+
* The publish details page shows the rollout live, so Cowork opens it for the
|
|
15
|
+
* whole publish rather than at the end. Other hosts only ever show the link.
|
|
16
|
+
*/
|
|
17
|
+
export declare function instructPublishDetails(result: ToolResult, profile: ClientProfile): string | undefined;
|
|
18
|
+
export declare function instructUserDecision(result: ToolResult, profile: ClientProfile): string | undefined;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Instructions shared verbatim by more than one tool. */
|
|
2
|
+
import { withCoworkEditorHost } from "../../cowork-editor-url.js";
|
|
3
|
+
export const APP_LOAD_CHECK = "Your automatic verification is a load check and inspection of visible state, not a feature-by-feature test run. Run interactive feature tests only when the user requests testing. Do not click app controls or inspect API traffic as part of a load check; normal navigation and authentication are allowed. Keep relaying Superblocks' own test results. Do not claim features passed from a load check alone.";
|
|
4
|
+
export const APP_SHARING_CHOICE = "For an ambiguous sharing request, ask the user to choose live preview, an unpublished commit preview, or publishing. Present all three options without choosing one for them. Do not assume publishing is required because the app has not been deployed: live and commit previews use existing app permissions without publishing. Only publish or change access when the user explicitly requests that action.";
|
|
5
|
+
export const COWORK_BROWSER_TOOLSEARCH = "select:mcp__remote-devices__Claude_Browser__preview_start,mcp__remote-devices__Claude_Browser__navigate,mcp__remote-devices__Claude_Browser__tabs_context";
|
|
6
|
+
// Repeat the query on each build: initialize instructions are gone by then.
|
|
7
|
+
export function buildingFollowUp(profile) {
|
|
8
|
+
const followUp = "Call `check_app_progress` with this `applicationId` to follow the turn. Relay each new activity line to the user as it arrives.";
|
|
9
|
+
if (!profile.hasNativeBrowser) {
|
|
10
|
+
return followUp;
|
|
11
|
+
}
|
|
12
|
+
return `${followUp} CRITICAL: load your browser pane tools now, before the first poll - call ToolSearch with query ${COWORK_BROWSER_TOOLSEARCH}. Without them you cannot open the app when a later result carries browserNavigation.`;
|
|
13
|
+
}
|
|
14
|
+
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.";
|
|
15
|
+
export const DECIDE_IN_EDITOR = "Open only the exact editor URL provided by this result so the user can answer in the Superblocks editor. When `browserNavigation` is present, follow its exact URL; otherwise use the exact URL in `editUrl`. Only the user may answer this decision. Do not click anything in the editor. Do not type anything in the editor. Do not switch between Plan and Build modes. Do not submit anything. Do not call `ask_user`. Stop and wait for the user.";
|
|
16
|
+
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.";
|
|
17
|
+
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.";
|
|
18
|
+
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 in the chat stream. Do not paraphrase, summarize, shorten, reorder, or re-level its headings - the user is approving exactly this text.";
|
|
19
|
+
/**
|
|
20
|
+
* The publish details page shows the rollout live, so Cowork opens it for the
|
|
21
|
+
* whole publish rather than at the end. Other hosts only ever show the link.
|
|
22
|
+
*/
|
|
23
|
+
export function instructPublishDetails(result, profile) {
|
|
24
|
+
const url = result.value.publishDetailsUrl;
|
|
25
|
+
if (!profile.hasNativeBrowser ||
|
|
26
|
+
(result.status !== "publishing" && result.status !== "deployed") ||
|
|
27
|
+
typeof url !== "string" ||
|
|
28
|
+
!url) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return `Before any other action, ensure ${withCoworkEditorHost(url)} is open in Cowork's embedded Page browser and verify the publish details loaded.`;
|
|
32
|
+
}
|
|
33
|
+
export function instructUserDecision(result, profile) {
|
|
34
|
+
if (result.decisionKind === "plan") {
|
|
35
|
+
// ENG-6810: ask widgets vary (some are one-line, some do not render
|
|
36
|
+
// markdown). The plan always belongs in the chat stream; the form is only
|
|
37
|
+
// Approve or Refine.
|
|
38
|
+
return profile.hasNativeAskForm
|
|
39
|
+
? `Show this plan in the chat stream. Do not call ask_user. Output the plan markdown as text, not in the native form. ${SHOW_PLAN_VERBATIM} Do not put the plan in the form or any other question widget. Use your native ask form only to collect the choice: 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`
|
|
40
|
+
: "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.";
|
|
41
|
+
}
|
|
42
|
+
if (result.decisionKind === "multi_choice") {
|
|
43
|
+
return profile.hasNativeAskForm
|
|
44
|
+
? "Use your native ask form to put this multi-choice decision to the user. Do not call ask_user. Keep every native form field plain text, without Markdown markers. Use plain-text display labels but retain each original option string. 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. Map the selected plain-text label back to its original option string and send that original string through edit_app EXACTLY as Clark provided it."
|
|
45
|
+
: "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.";
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
//# 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,cAAc,GACzB,mZAAmZ,CAAC;AAEtZ,MAAM,CAAC,MAAM,kBAAkB,GAC7B,kZAAkZ,CAAC;AAErZ,MAAM,CAAC,MAAM,yBAAyB,GACpC,2JAA2J,CAAC;AAE9J,4EAA4E;AAC5E,MAAM,UAAU,gBAAgB,CAAC,OAAsB;IACrD,MAAM,QAAQ,GACZ,iIAAiI,CAAC;IACpI,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC9B,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,QAAQ,mGAAmG,yBAAyB,uFAAuF,CAAC;AACxO,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAC5B,yLAAyL,CAAC;AAE5L,MAAM,CAAC,MAAM,gBAAgB,GAC3B,wbAAwb,CAAC;AAE3b,MAAM,CAAC,MAAM,kBAAkB,GAC7B,sNAAsN,CAAC;AAEzN,MAAM,CAAC,MAAM,2BAA2B,GACtC,mJAAmJ,CAAC;AAEtJ,MAAM,CAAC,MAAM,kBAAkB,GAC7B,sQAAsQ,CAAC;AAEzQ;;;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,oEAAoE;QACpE,0EAA0E;QAC1E,qBAAqB;QACrB,OAAO,OAAO,CAAC,gBAAgB;YAC7B,CAAC,CAAC,sHAAsH,kBAAkB,+uBAA+uB;YACz3B,CAAC,CAAC,uJAAuJ,CAAC;IAC9J,CAAC;IACD,IAAI,MAAM,CAAC,YAAY,KAAK,cAAc,EAAE,CAAC;QAC3C,OAAO,OAAO,CAAC,gBAAgB;YAC7B,CAAC,CAAC,+hBAA+hB;YACjiB,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 browser pane 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 browser pane 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","sourceRoot":"","sources":["../../../../../src/transports/mcp/instructions/tools/create-integration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAmB,MAAM,cAAc,CAAC;AAEzD,MAAM,UAAU,yBAAyB,CACvC,MAAkB,EAClB,OAAsB;IAEtB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC;IACzC,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC;IAClD,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,CAAC,aAAa,EAAE,CAAC;QACxD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,WAAW,GACf,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAC,2BAA2B,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5E,MAAM,OAAO,GACX,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG;QAC5B,CAAC,CAAC,OAAO,CAAC,gBAAgB;YACxB,CAAC,CAAC,WAAW;gBACX,CAAC,CAAC,+BAA+B,GAAG,2NAA2N;gBAC/P,CAAC,CAAC,+BAA+B,GAAG,uCAAuC;YAC7E,CAAC,CAAC,WAAW;gBACX,CAAC,CAAC,sNAAsN;gBACxN,CAAC,CAAC,qGAAqG;QAC3G,CAAC,CAAC,gFAAgF,CAAC;IACvF,MAAM,YAAY,GAAG,WAAW;QAC9B,CAAC,CAAC,oDAAoD;QACtD,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,MAAM,GAAG,oDAAoD,aAAa,uHAAuH,CAAC;IAExM,IAAI,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,GAAG,OAAO,iHAAiH,MAAM,EAAE,CAAC;IAC7I,CAAC;IACD,OAAO,GAAG,OAAO,8EAA8E,YAAY,iEAAiE,MAAM,EAAE,CAAC;AACvL,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 { REPLACE_WEDGED_APP, RETRY_UNAVAILABLE_LIVE_EDIT, buildingFollowUp, } from "./copy.js";
|
|
2
|
+
export function instructEditApp(result, profile) {
|
|
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 buildingFollowUp(profile);
|
|
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":"AAEA,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAEnB,MAAM,UAAU,eAAe,CAC7B,MAAkB,EAClB,OAAsB;IAEtB,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,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { APP_LOAD_CHECK, CHECKPOINT_FAILED, DECIDE_IN_EDITOR, instructUserDecision, REPLACE_WEDGED_APP, } from "./copy.js";
|
|
2
|
+
export function instructGetApp(result, profile) {
|
|
3
|
+
const instructions = resultInstructions(result, profile);
|
|
4
|
+
const navigation = result.value.browserNavigation;
|
|
5
|
+
if (!profile.hasNativeBrowser || !isBrowserNavigation(navigation)) {
|
|
6
|
+
return instructions;
|
|
7
|
+
}
|
|
8
|
+
const browserInstructions = result.pendingAction === "decide_in_editor"
|
|
9
|
+
? `Before any other action, ensure ${navigation.url} is open in Cowork's embedded Page browser.`
|
|
10
|
+
: `Before any other action, ensure ${navigation.url} is open in Cowork's embedded Page browser and verify the app loaded. ${APP_LOAD_CHECK}`;
|
|
11
|
+
return instructions
|
|
12
|
+
? `${browserInstructions}\n\n${instructions}`
|
|
13
|
+
: browserInstructions;
|
|
14
|
+
}
|
|
15
|
+
function resultInstructions(result, profile) {
|
|
16
|
+
const screenshot = result.value.screenshotBase64;
|
|
17
|
+
if (result.status === "ready" &&
|
|
18
|
+
typeof screenshot === "string" &&
|
|
19
|
+
screenshot) {
|
|
20
|
+
return "Inspect the screenshot before telling the user the app looks correct. A skeleton, spinner, empty table/chart, or 'Loading...' is not a defect - call `get_app` again in a few seconds. Do not test, debug, or correct a visible problem unless the user requests it; report what you see.";
|
|
21
|
+
}
|
|
22
|
+
if (result.pendingAction === "start_new_app") {
|
|
23
|
+
return REPLACE_WEDGED_APP;
|
|
24
|
+
}
|
|
25
|
+
if (result.pendingAction === "open_editor") {
|
|
26
|
+
return CHECKPOINT_FAILED;
|
|
27
|
+
}
|
|
28
|
+
if (result.pendingAction === "decide_in_editor") {
|
|
29
|
+
return DECIDE_IN_EDITOR;
|
|
30
|
+
}
|
|
31
|
+
const decisionInstructions = instructUserDecision(result, profile);
|
|
32
|
+
if (decisionInstructions) {
|
|
33
|
+
return decisionInstructions;
|
|
34
|
+
}
|
|
35
|
+
if (result.status === "needs_decision") {
|
|
36
|
+
return "Call `ask_user` now - do not answer this decision yourself from `get_app`'s output.";
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
function isBrowserNavigation(value) {
|
|
41
|
+
return (typeof value === "object" &&
|
|
42
|
+
value !== null &&
|
|
43
|
+
"action" in value &&
|
|
44
|
+
value.action === "open_editor" &&
|
|
45
|
+
"url" in value &&
|
|
46
|
+
typeof value.url === "string" &&
|
|
47
|
+
value.url.length > 0);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=get-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-app.js","sourceRoot":"","sources":["../../../../../src/transports/mcp/inst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