@superblocksteam/gateway 2.0.155-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +87 -0
- package/README.md +170 -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/import-prompt.d.ts +11 -0
- package/dist/capabilities/import-prompt.js +96 -0
- package/dist/capabilities/import-prompt.js.map +1 -0
- package/dist/capabilities/lifecycle.d.ts +73 -0
- package/dist/capabilities/lifecycle.js +2531 -0
- package/dist/capabilities/lifecycle.js.map +1 -0
- package/dist/capabilities/persisted-progress.d.ts +46 -0
- package/dist/capabilities/persisted-progress.js +246 -0
- package/dist/capabilities/persisted-progress.js.map +1 -0
- package/dist/capabilities/types.d.ts +446 -0
- package/dist/capabilities/types.js +47 -0
- package/dist/capabilities/types.js.map +1 -0
- package/dist/capture/browser-contract.d.ts +36 -0
- package/dist/capture/browser-contract.js +24 -0
- package/dist/capture/browser-contract.js.map +1 -0
- package/dist/capture/browser-instructions.d.ts +9 -0
- package/dist/capture/browser-instructions.js +17 -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 +34 -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 +22 -0
- package/dist/capture/mode.js +45 -0
- package/dist/capture/mode.js.map +1 -0
- package/dist/config.d.ts +141 -0
- package/dist/config.js +109 -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 +36 -0
- package/dist/deps.js +2 -0
- package/dist/deps.js.map +1 -0
- package/dist/events/cursor.d.ts +43 -0
- package/dist/events/cursor.js +78 -0
- package/dist/events/cursor.js.map +1 -0
- package/dist/events/memory-event-store.d.ts +34 -0
- package/dist/events/memory-event-store.js +110 -0
- package/dist/events/memory-event-store.js.map +1 -0
- package/dist/events/merge.d.ts +23 -0
- package/dist/events/merge.js +97 -0
- package/dist/events/merge.js.map +1 -0
- package/dist/events/normalized-collector.d.ts +62 -0
- package/dist/events/normalized-collector.js +156 -0
- package/dist/events/normalized-collector.js.map +1 -0
- package/dist/events/schema.d.ts +9 -0
- package/dist/events/schema.js +93 -0
- package/dist/events/schema.js.map +1 -0
- package/dist/events/snapshot.d.ts +32 -0
- package/dist/events/snapshot.js +57 -0
- package/dist/events/snapshot.js.map +1 -0
- package/dist/events/stream-key.d.ts +2 -0
- package/dist/events/stream-key.js +31 -0
- package/dist/events/stream-key.js.map +1 -0
- package/dist/events/types.d.ts +179 -0
- package/dist/events/types.js +66 -0
- package/dist/events/types.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 +10 -0
- package/dist/index.js +10 -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 +26 -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/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 +26 -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 +52 -0
- package/dist/preview/capture-screenshot.js +158 -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 +128 -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/resume/memory-progress-store.d.ts +39 -0
- package/dist/resume/memory-progress-store.js +82 -0
- package/dist/resume/memory-progress-store.js.map +1 -0
- package/dist/resume/memory-recent-app-store.d.ts +14 -0
- package/dist/resume/memory-recent-app-store.js +27 -0
- package/dist/resume/memory-recent-app-store.js.map +1 -0
- package/dist/resume/memory-turn-store.d.ts +18 -0
- package/dist/resume/memory-turn-store.js +73 -0
- package/dist/resume/memory-turn-store.js.map +1 -0
- package/dist/resume/progress-key.d.ts +21 -0
- package/dist/resume/progress-key.js +58 -0
- package/dist/resume/progress-key.js.map +1 -0
- package/dist/resume/stores.d.ts +14 -0
- package/dist/resume/stores.js +18 -0
- package/dist/resume/stores.js.map +1 -0
- package/dist/resume/types.d.ts +124 -0
- package/dist/resume/types.js +13 -0
- package/dist/resume/types.js.map +1 -0
- package/dist/sabs/agent-facing-text.d.ts +33 -0
- package/dist/sabs/agent-facing-text.js +125 -0
- package/dist/sabs/agent-facing-text.js.map +1 -0
- package/dist/sabs/browser-context.d.ts +53 -0
- package/dist/sabs/browser-context.js +91 -0
- package/dist/sabs/browser-context.js.map +1 -0
- package/dist/sabs/editor-client-methods.d.ts +147 -0
- package/dist/sabs/editor-client-methods.js +715 -0
- package/dist/sabs/editor-client-methods.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 +351 -0
- package/dist/sabs/session-peer.js +2 -0
- package/dist/sabs/session-peer.js.map +1 -0
- package/dist/sabs/turn-collector.d.ts +152 -0
- package/dist/sabs/turn-collector.js +573 -0
- package/dist/sabs/turn-collector.js.map +1 -0
- package/dist/sabs/websocket-session-peer.d.ts +514 -0
- package/dist/sabs/websocket-session-peer.js +2487 -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 +371 -0
- package/dist/server/client.js +572 -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 +14 -0
- package/dist/start.js +75 -0
- package/dist/start.js.map +1 -0
- package/dist/telemetry/metrics.d.ts +32 -0
- package/dist/telemetry/metrics.js +57 -0
- package/dist/telemetry/metrics.js.map +1 -0
- package/dist/transports/mcp/admin-tools.d.ts +47 -0
- package/dist/transports/mcp/admin-tools.js +164 -0
- package/dist/transports/mcp/admin-tools.js.map +1 -0
- package/dist/transports/mcp/app-status-html.d.ts +15 -0
- package/dist/transports/mcp/app-status-html.js +563 -0
- package/dist/transports/mcp/app-status-html.js.map +1 -0
- package/dist/transports/mcp/decision-elicitation.d.ts +74 -0
- package/dist/transports/mcp/decision-elicitation.js +233 -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/format-tool-content.d.ts +25 -0
- package/dist/transports/mcp/format-tool-content.js +48 -0
- package/dist/transports/mcp/format-tool-content.js.map +1 -0
- package/dist/transports/mcp/mount.d.ts +9 -0
- package/dist/transports/mcp/mount.js +469 -0
- package/dist/transports/mcp/mount.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/package.json +72 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP form elicitation for Superblocks decisions (plan approve/refine and
|
|
3
|
+
* multi_choice questions).
|
|
4
|
+
*
|
|
5
|
+
* Chat is the baseline: every decision is also returned as needs_decision +
|
|
6
|
+
* decision so a host without elicitation can ask the user in its own words. A
|
|
7
|
+
* host that declares form elicitation gets a real picker instead, and the tool
|
|
8
|
+
* call answers Superblocks itself rather than handing the question back to the
|
|
9
|
+
* model.
|
|
10
|
+
*/
|
|
11
|
+
import type { CapabilityResult, DecisionPayload } from "../../capabilities/types.js";
|
|
12
|
+
export type DecisionAnswer = {
|
|
13
|
+
kind: "answer";
|
|
14
|
+
prompt: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "approve";
|
|
17
|
+
} | {
|
|
18
|
+
feedback: string;
|
|
19
|
+
kind: "refine";
|
|
20
|
+
};
|
|
21
|
+
type EnumProperty = {
|
|
22
|
+
description?: string;
|
|
23
|
+
enum: string[];
|
|
24
|
+
enumNames?: string[];
|
|
25
|
+
title?: string;
|
|
26
|
+
type: "string";
|
|
27
|
+
};
|
|
28
|
+
type StringProperty = {
|
|
29
|
+
description?: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
type: "string";
|
|
32
|
+
};
|
|
33
|
+
export type DecisionElicitationRequest = {
|
|
34
|
+
message: string;
|
|
35
|
+
mode: "form";
|
|
36
|
+
requestedSchema: {
|
|
37
|
+
properties: Record<string, EnumProperty | StringProperty>;
|
|
38
|
+
required: string[];
|
|
39
|
+
type: "object";
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/** What a host returns from elicitation/create. */
|
|
43
|
+
type ElicitationOutcome = {
|
|
44
|
+
action: "accept" | "cancel" | "decline";
|
|
45
|
+
content?: Record<string, unknown>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* True when the client advertised form elicitation at initialize.
|
|
49
|
+
* Empty `elicitation: {}` means form-only per the 2025-11-25 spec.
|
|
50
|
+
*/
|
|
51
|
+
export declare function clientSupportsFormElicitation(capabilities: {
|
|
52
|
+
elicitation?: Record<string, unknown>;
|
|
53
|
+
} | undefined): boolean;
|
|
54
|
+
/** The decision a capability result is waiting on, if it is waiting on one. */
|
|
55
|
+
export declare function pendingDecision(result: CapabilityResult<unknown>): DecisionPayload | undefined;
|
|
56
|
+
export declare function decisionElicitationRequest(decision: DecisionPayload): DecisionElicitationRequest | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* The answer a host collected, or undefined when there is nothing to send on —
|
|
59
|
+
* a dismissed form, or an answer too incomplete to act on (refine with no
|
|
60
|
+
* feedback). Undefined means the caller should leave the decision in chat.
|
|
61
|
+
*/
|
|
62
|
+
export declare function readDecisionAnswer(decision: DecisionPayload, outcome: ElicitationOutcome): DecisionAnswer | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Puts a decision to the user as a form and sends their answer on, returning
|
|
65
|
+
* the follow-up turn. Returns undefined when the decision should stay in chat,
|
|
66
|
+
* including when the host rejects the elicitation outright — an older client
|
|
67
|
+
* that declared the capability but cannot serve it must not lose the decision.
|
|
68
|
+
*/
|
|
69
|
+
export declare function resolveDecisionByElicitation(args: {
|
|
70
|
+
apply: (answer: DecisionAnswer) => Promise<CapabilityResult<unknown>>;
|
|
71
|
+
decision: DecisionPayload;
|
|
72
|
+
elicit: (request: DecisionElicitationRequest) => Promise<ElicitationOutcome>;
|
|
73
|
+
}): Promise<CapabilityResult<unknown> | undefined>;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP form elicitation for Superblocks decisions (plan approve/refine and
|
|
3
|
+
* multi_choice questions).
|
|
4
|
+
*
|
|
5
|
+
* Chat is the baseline: every decision is also returned as needs_decision +
|
|
6
|
+
* decision so a host without elicitation can ask the user in its own words. A
|
|
7
|
+
* host that declares form elicitation gets a real picker instead, and the tool
|
|
8
|
+
* call answers Superblocks itself rather than handing the question back to the
|
|
9
|
+
* model.
|
|
10
|
+
*/
|
|
11
|
+
import { gatewayDebug } from "../../debug.js";
|
|
12
|
+
/**
|
|
13
|
+
* True when the client advertised form elicitation at initialize.
|
|
14
|
+
* Empty `elicitation: {}` means form-only per the 2025-11-25 spec.
|
|
15
|
+
*/
|
|
16
|
+
export function clientSupportsFormElicitation(capabilities) {
|
|
17
|
+
if (!capabilities?.elicitation) {
|
|
18
|
+
gatewayDebug("elicitation capability checked", {
|
|
19
|
+
"decision.form_supported": false,
|
|
20
|
+
"decision.reason": "capability_missing",
|
|
21
|
+
});
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const elicitation = capabilities.elicitation;
|
|
25
|
+
if (Object.keys(elicitation).length === 0) {
|
|
26
|
+
gatewayDebug("elicitation capability checked", {
|
|
27
|
+
"decision.form_supported": true,
|
|
28
|
+
"decision.reason": "empty_capability",
|
|
29
|
+
});
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
const result = "form" in elicitation;
|
|
33
|
+
gatewayDebug("elicitation capability checked", {
|
|
34
|
+
"decision.form_supported": result,
|
|
35
|
+
"decision.modes": Object.keys(elicitation),
|
|
36
|
+
"decision.reason": result ? "form_advertised" : "form_missing",
|
|
37
|
+
});
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
/** The decision a capability result is waiting on, if it is waiting on one. */
|
|
41
|
+
export function pendingDecision(result) {
|
|
42
|
+
if (result.kind !== "ok") {
|
|
43
|
+
gatewayDebug("pending decision checked", {
|
|
44
|
+
"decision.found": false,
|
|
45
|
+
"decision.reason": "result_error",
|
|
46
|
+
...("code" in result ? { "result.code": result.code } : {}),
|
|
47
|
+
"result.kind": result.kind,
|
|
48
|
+
});
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
if (!result.value || typeof result.value !== "object") {
|
|
52
|
+
gatewayDebug("pending decision checked", {
|
|
53
|
+
"decision.found": false,
|
|
54
|
+
"decision.reason": "result_has_no_object",
|
|
55
|
+
});
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const value = result.value;
|
|
59
|
+
const decision = value.status === "needs_decision" ? value.decision : undefined;
|
|
60
|
+
gatewayDebug("pending decision checked", {
|
|
61
|
+
"decision.found": Boolean(decision),
|
|
62
|
+
...(decision ? { "decision.kind": decision.kind } : {}),
|
|
63
|
+
"decision.reason": decision ? "waiting" : "status_not_waiting",
|
|
64
|
+
"result.status": value.status,
|
|
65
|
+
});
|
|
66
|
+
return decision;
|
|
67
|
+
}
|
|
68
|
+
export function decisionElicitationRequest(decision) {
|
|
69
|
+
if (decision.kind === "plan") {
|
|
70
|
+
gatewayDebug("decision request created", {
|
|
71
|
+
"decision.kind": decision.kind,
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
message: decision.title
|
|
75
|
+
? `Superblocks planned "${decision.title}". Build it, or say what to change?`
|
|
76
|
+
: "Superblocks has a plan. Build it, or say what to change?",
|
|
77
|
+
mode: "form",
|
|
78
|
+
requestedSchema: {
|
|
79
|
+
properties: {
|
|
80
|
+
action: {
|
|
81
|
+
description: "Approve the plan to build it, or refine it",
|
|
82
|
+
enum: ["approve", "refine"],
|
|
83
|
+
enumNames: ["Approve — build this plan", "Refine — change it"],
|
|
84
|
+
title: "Plan",
|
|
85
|
+
type: "string",
|
|
86
|
+
},
|
|
87
|
+
feedback: {
|
|
88
|
+
description: "What to change. Required when refining.",
|
|
89
|
+
title: "Changes",
|
|
90
|
+
type: "string",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
required: ["action"],
|
|
94
|
+
type: "object",
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (decision.options.length === 0) {
|
|
99
|
+
gatewayDebug("decision request skipped", {
|
|
100
|
+
"decision.kind": decision.kind,
|
|
101
|
+
"decision.reason": "no_options",
|
|
102
|
+
});
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
gatewayDebug("decision request created", {
|
|
106
|
+
"decision.kind": decision.kind,
|
|
107
|
+
"decision.option_count": decision.options.length,
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
message: decision.question,
|
|
111
|
+
mode: "form",
|
|
112
|
+
requestedSchema: {
|
|
113
|
+
properties: {
|
|
114
|
+
choice: {
|
|
115
|
+
enum: [...decision.options],
|
|
116
|
+
title: decision.question,
|
|
117
|
+
type: "string",
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
required: ["choice"],
|
|
121
|
+
type: "object",
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The answer a host collected, or undefined when there is nothing to send on —
|
|
127
|
+
* a dismissed form, or an answer too incomplete to act on (refine with no
|
|
128
|
+
* feedback). Undefined means the caller should leave the decision in chat.
|
|
129
|
+
*/
|
|
130
|
+
export function readDecisionAnswer(decision, outcome) {
|
|
131
|
+
if (outcome.action !== "accept" || !outcome.content) {
|
|
132
|
+
gatewayDebug("decision answer read", {
|
|
133
|
+
"decision.answer_kind": "none",
|
|
134
|
+
"decision.kind": decision.kind,
|
|
135
|
+
"decision.reason": outcome.action,
|
|
136
|
+
});
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
if (decision.kind === "plan") {
|
|
140
|
+
const action = outcome.content.action;
|
|
141
|
+
if (action === "approve") {
|
|
142
|
+
gatewayDebug("decision answer read", {
|
|
143
|
+
"decision.answer_kind": "approve",
|
|
144
|
+
"decision.kind": decision.kind,
|
|
145
|
+
});
|
|
146
|
+
return { kind: "approve" };
|
|
147
|
+
}
|
|
148
|
+
if (action !== "refine") {
|
|
149
|
+
gatewayDebug("decision answer read", {
|
|
150
|
+
"decision.answer_kind": "none",
|
|
151
|
+
"decision.kind": decision.kind,
|
|
152
|
+
"decision.reason": "invalid_plan_action",
|
|
153
|
+
});
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
const feedback = typeof outcome.content.feedback === "string"
|
|
157
|
+
? outcome.content.feedback.trim()
|
|
158
|
+
: "";
|
|
159
|
+
gatewayDebug("decision answer read", {
|
|
160
|
+
"decision.answer_kind": feedback ? "refine" : "none",
|
|
161
|
+
"decision.kind": decision.kind,
|
|
162
|
+
...(!feedback ? { "decision.reason": "missing_feedback" } : {}),
|
|
163
|
+
});
|
|
164
|
+
return feedback ? { feedback, kind: "refine" } : undefined;
|
|
165
|
+
}
|
|
166
|
+
const choice = outcome.content.choice;
|
|
167
|
+
// Only an option Superblocks offered: a free-typed answer would reach Clark
|
|
168
|
+
// as a prompt for a question it did not ask.
|
|
169
|
+
const offered = typeof choice === "string" && decision.options.includes(choice);
|
|
170
|
+
gatewayDebug("decision answer read", {
|
|
171
|
+
"decision.answer_kind": offered ? "answer" : "none",
|
|
172
|
+
"decision.kind": decision.kind,
|
|
173
|
+
...(!offered ? { "decision.reason": "choice_not_offered" } : {}),
|
|
174
|
+
});
|
|
175
|
+
return offered ? { kind: "answer", prompt: choice } : undefined;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Puts a decision to the user as a form and sends their answer on, returning
|
|
179
|
+
* the follow-up turn. Returns undefined when the decision should stay in chat,
|
|
180
|
+
* including when the host rejects the elicitation outright — an older client
|
|
181
|
+
* that declared the capability but cannot serve it must not lose the decision.
|
|
182
|
+
*/
|
|
183
|
+
export async function resolveDecisionByElicitation(args) {
|
|
184
|
+
const request = decisionElicitationRequest(args.decision);
|
|
185
|
+
if (!request) {
|
|
186
|
+
gatewayDebug("decision elicitation skipped", {
|
|
187
|
+
"decision.kind": args.decision.kind,
|
|
188
|
+
"decision.reason": "request_unavailable",
|
|
189
|
+
});
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
gatewayDebug("decision elicitation started", {
|
|
193
|
+
"decision.kind": args.decision.kind,
|
|
194
|
+
});
|
|
195
|
+
let outcome;
|
|
196
|
+
try {
|
|
197
|
+
outcome = await args.elicit(request);
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
console.error("gateway decision elicitation failed", error);
|
|
201
|
+
gatewayDebug("decision elicitation finished", {
|
|
202
|
+
"decision.kind": args.decision.kind,
|
|
203
|
+
"decision.reason": "host_error",
|
|
204
|
+
"decision.resolved": false,
|
|
205
|
+
});
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
gatewayDebug("decision elicitation response received", {
|
|
209
|
+
"decision.kind": args.decision.kind,
|
|
210
|
+
"decision.outcome": outcome.action,
|
|
211
|
+
});
|
|
212
|
+
const answer = readDecisionAnswer(args.decision, outcome);
|
|
213
|
+
if (!answer) {
|
|
214
|
+
gatewayDebug("decision elicitation finished", {
|
|
215
|
+
"decision.kind": args.decision.kind,
|
|
216
|
+
"decision.reason": "answer_unavailable",
|
|
217
|
+
"decision.resolved": false,
|
|
218
|
+
});
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
gatewayDebug("decision answer applying", {
|
|
222
|
+
"decision.answer_kind": answer.kind,
|
|
223
|
+
"decision.kind": args.decision.kind,
|
|
224
|
+
});
|
|
225
|
+
const result = await args.apply(answer);
|
|
226
|
+
gatewayDebug("decision elicitation finished", {
|
|
227
|
+
"decision.kind": args.decision.kind,
|
|
228
|
+
"decision.resolved": true,
|
|
229
|
+
"result.kind": result.kind,
|
|
230
|
+
});
|
|
231
|
+
return result;
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=decision-elicitation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision-elicitation.js","sourceRoot":"","sources":["../../../src/transports/mcp/decision-elicitation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAqC9C;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAC3C,YAAmE;IAEnE,IAAI,CAAC,YAAY,EAAE,WAAW,EAAE,CAAC;QAC/B,YAAY,CAAC,gCAAgC,EAAE;YAC7C,yBAAyB,EAAE,KAAK;YAChC,iBAAiB,EAAE,oBAAoB;SACxC,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC;IAC7C,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1C,YAAY,CAAC,gCAAgC,EAAE;YAC7C,yBAAyB,EAAE,IAAI;YAC/B,iBAAiB,EAAE,kBAAkB;SACtC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,IAAI,WAAW,CAAC;IACrC,YAAY,CAAC,gCAAgC,EAAE;QAC7C,yBAAyB,EAAE,MAAM;QACjC,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;QAC1C,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,cAAc;KAC/D,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,eAAe,CAC7B,MAAiC;IAEjC,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACzB,YAAY,CAAC,0BAA0B,EAAE;YACvC,gBAAgB,EAAE,KAAK;YACvB,iBAAiB,EAAE,cAAc;YACjC,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,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KAC3B,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { AppDeps } from "../../deps.js";
|
|
3
|
+
import type { DispatchProbe } from "../../health/readiness.js";
|
|
4
|
+
/**
|
|
5
|
+
* Proves the gateway can still serve a request end to end on its own tool
|
|
6
|
+
* surface.
|
|
7
|
+
*
|
|
8
|
+
* A route handler that answers `{"status":"ok"}` proves that express is
|
|
9
|
+
* listening. It does not prove that the MCP server builds, that its tools
|
|
10
|
+
* registered, or that a JSON-RPC request can be routed to one - which is
|
|
11
|
+
* exactly the gap ENG-5809 reported: `/health` green in 1ms while every tool
|
|
12
|
+
* call timed out. This runs the real `createMcpServer` over a linked in-memory
|
|
13
|
+
* transport and asks it to list its tools, so a break anywhere in construction,
|
|
14
|
+
* registration, framing, or routing shows up as a failed probe.
|
|
15
|
+
*
|
|
16
|
+
* It deliberately stops short of invoking a tool. Every tool needs the caller's
|
|
17
|
+
* credential and reaches the platform behind the gateway, and a liveness check
|
|
18
|
+
* that fails when the platform is slow is how a healthy gateway gets restarted
|
|
19
|
+
* during someone else's outage. Upstream reachability is reported separately
|
|
20
|
+
* (see {@link GatewayReadiness}).
|
|
21
|
+
*/
|
|
22
|
+
export declare function createMcpDispatchProbe(deps: AppDeps, options?: {
|
|
23
|
+
createServer?: () => McpServer;
|
|
24
|
+
}): DispatchProbe;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
3
|
+
import { createMcpServer } from "./mount.js";
|
|
4
|
+
/**
|
|
5
|
+
* Proves the gateway can still serve a request end to end on its own tool
|
|
6
|
+
* surface.
|
|
7
|
+
*
|
|
8
|
+
* A route handler that answers `{"status":"ok"}` proves that express is
|
|
9
|
+
* listening. It does not prove that the MCP server builds, that its tools
|
|
10
|
+
* registered, or that a JSON-RPC request can be routed to one - which is
|
|
11
|
+
* exactly the gap ENG-5809 reported: `/health` green in 1ms while every tool
|
|
12
|
+
* call timed out. This runs the real `createMcpServer` over a linked in-memory
|
|
13
|
+
* transport and asks it to list its tools, so a break anywhere in construction,
|
|
14
|
+
* registration, framing, or routing shows up as a failed probe.
|
|
15
|
+
*
|
|
16
|
+
* It deliberately stops short of invoking a tool. Every tool needs the caller's
|
|
17
|
+
* credential and reaches the platform behind the gateway, and a liveness check
|
|
18
|
+
* that fails when the platform is slow is how a healthy gateway gets restarted
|
|
19
|
+
* during someone else's outage. Upstream reachability is reported separately
|
|
20
|
+
* (see {@link GatewayReadiness}).
|
|
21
|
+
*/
|
|
22
|
+
export function createMcpDispatchProbe(deps, options = {}) {
|
|
23
|
+
const createServer = options.createServer ?? (() => createMcpServer(deps));
|
|
24
|
+
return async () => {
|
|
25
|
+
const server = createServer();
|
|
26
|
+
const client = new Client({
|
|
27
|
+
name: "gateway-dispatch-probe",
|
|
28
|
+
version: "0.0.1",
|
|
29
|
+
});
|
|
30
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
31
|
+
try {
|
|
32
|
+
await Promise.all([
|
|
33
|
+
server.connect(serverTransport),
|
|
34
|
+
client.connect(clientTransport),
|
|
35
|
+
]);
|
|
36
|
+
const { tools } = await client.listTools();
|
|
37
|
+
if (tools.length === 0) {
|
|
38
|
+
throw new Error("the gateway's MCP server registered no tools, so no call could be dispatched");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
// Every probe run gets its own server and session. Leaking either would
|
|
43
|
+
// turn a polled health endpoint into the gateway's largest consumer.
|
|
44
|
+
await Promise.allSettled([client.close(), server.close()]);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=dispatch-probe.js.map
|
|
@@ -0,0 +1 @@
|
|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D,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CapabilityResult } from "../../capabilities/types.js";
|
|
2
|
+
type ContentBlock = {
|
|
3
|
+
type: "text";
|
|
4
|
+
text: string;
|
|
5
|
+
} | {
|
|
6
|
+
type: "image";
|
|
7
|
+
data: string;
|
|
8
|
+
mimeType: "image/jpeg";
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Serializes a capability result for MCP. Screenshot bytes stay in the JSON
|
|
12
|
+
* (Cursor CLI agents never see the image content block) and are also emitted
|
|
13
|
+
* as an image block for hosts that render it. App URLs stay in the JSON for
|
|
14
|
+
* the model and MCP Apps openLink buttons — they are not duplicated as a
|
|
15
|
+
* markdown chat dump.
|
|
16
|
+
*
|
|
17
|
+
* Decisions travel as data too. Prepending a rendered plan plus instructions
|
|
18
|
+
* on how to offer the options made the model paste that scaffolding into the
|
|
19
|
+
* chat; the server instructions say how to ask.
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatMcpToolContent(result: CapabilityResult<unknown>, progress?: Array<{
|
|
22
|
+
type: string;
|
|
23
|
+
message: string;
|
|
24
|
+
}>): ContentBlock[];
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializes a capability result for MCP. Screenshot bytes stay in the JSON
|
|
3
|
+
* (Cursor CLI agents never see the image content block) and are also emitted
|
|
4
|
+
* as an image block for hosts that render it. App URLs stay in the JSON for
|
|
5
|
+
* the model and MCP Apps openLink buttons — they are not duplicated as a
|
|
6
|
+
* markdown chat dump.
|
|
7
|
+
*
|
|
8
|
+
* Decisions travel as data too. Prepending a rendered plan plus instructions
|
|
9
|
+
* on how to offer the options made the model paste that scaffolding into the
|
|
10
|
+
* chat; the server instructions say how to ask.
|
|
11
|
+
*/
|
|
12
|
+
export function formatMcpToolContent(result, progress = []) {
|
|
13
|
+
const { screenshotBase64, textResult } = extractScreenshot(result);
|
|
14
|
+
const content = [];
|
|
15
|
+
// Every text block ends in a newline because hosts concatenate them: without
|
|
16
|
+
// it the trail read "}[progress] Creating application[progress] Connecting
|
|
17
|
+
// live-edit session", running the JSON body into the first marker and every
|
|
18
|
+
// marker into the next.
|
|
19
|
+
content.push({
|
|
20
|
+
text: `${JSON.stringify(textResult, null, 2)}\n`,
|
|
21
|
+
type: "text",
|
|
22
|
+
});
|
|
23
|
+
content.push(...progress.map((event) => ({
|
|
24
|
+
text: `[${event.type}] ${event.message}\n`,
|
|
25
|
+
type: "text",
|
|
26
|
+
})));
|
|
27
|
+
if (screenshotBase64) {
|
|
28
|
+
content.push({
|
|
29
|
+
data: screenshotBase64,
|
|
30
|
+
mimeType: "image/jpeg",
|
|
31
|
+
type: "image",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return content;
|
|
35
|
+
}
|
|
36
|
+
function extractScreenshot(result) {
|
|
37
|
+
if (result.kind !== "ok" ||
|
|
38
|
+
!result.value ||
|
|
39
|
+
typeof result.value !== "object") {
|
|
40
|
+
return { screenshotBase64: undefined, textResult: result };
|
|
41
|
+
}
|
|
42
|
+
const value = result.value;
|
|
43
|
+
const screenshotBase64 = typeof value.screenshotBase64 === "string"
|
|
44
|
+
? value.screenshotBase64
|
|
45
|
+
: undefined;
|
|
46
|
+
return { screenshotBase64, textResult: result };
|
|
47
|
+
}
|
|
48
|
+
//# 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":"AAMA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAiC,EACjC,WAAqD,EAAE;IAEvD,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACnE,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,6EAA6E;IAC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from "../../deps.js";
|
|
3
|
+
/**
|
|
4
|
+
* The MCP server behind one stdio session.
|
|
5
|
+
*
|
|
6
|
+
* Tools run as the already-logged-in CLI user. There is no per-request OAuth
|
|
7
|
+
* token to expire independently of the process.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createMcpServer(deps: AppDeps): McpServer;
|