@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 @@
|
|
|
1
|
+
{"version":3,"file":"decision-card-html.js","sourceRoot":"","sources":["../../../src/transports/mcp/decision-card-html.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,iCAAiC,CAAC;AAC9E,MAAM,CAAC,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;AAClE,MAAM,CAAC,MAAM,yBAAyB,GAAG,gCAAgC,CAAC;AAE1E,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuK/B,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA4LA,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAuYhB,4BAA4B;;sCAEnB,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoGjE,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* call answers Superblocks itself rather than handing the question back to the
|
|
9
9
|
* model.
|
|
10
10
|
*/
|
|
11
|
+
import { ElicitResultSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
11
12
|
import type { CapabilityResult, DecisionPayload } from "../../capabilities/types.js";
|
|
12
13
|
export type DecisionAnswer = {
|
|
13
14
|
kind: "answer";
|
|
@@ -53,6 +54,15 @@ export declare function clientSupportsFormElicitation(capabilities: {
|
|
|
53
54
|
} | undefined): boolean;
|
|
54
55
|
/** The decision a capability result is waiting on, if it is waiting on one. */
|
|
55
56
|
export declare function pendingDecision(result: CapabilityResult<unknown>): DecisionPayload | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* The application a capability result was about.
|
|
59
|
+
*
|
|
60
|
+
* A tool call that named none has it resolved to the caller's recent
|
|
61
|
+
* application inside the capability, so the id the result carries is the only
|
|
62
|
+
* one a follow-up can safely key on.
|
|
63
|
+
*/
|
|
64
|
+
export declare function resultApplicationId(result: CapabilityResult<unknown>): string | undefined;
|
|
65
|
+
export declare function resultBranch(result: CapabilityResult<unknown>): string | undefined;
|
|
56
66
|
export declare function decisionElicitationRequest(decision: DecisionPayload): DecisionElicitationRequest | undefined;
|
|
57
67
|
/**
|
|
58
68
|
* The answer a host collected, or undefined when there is nothing to send on —
|
|
@@ -60,6 +70,38 @@ export declare function decisionElicitationRequest(decision: DecisionPayload): D
|
|
|
60
70
|
* feedback). Undefined means the caller should leave the decision in chat.
|
|
61
71
|
*/
|
|
62
72
|
export declare function readDecisionAnswer(decision: DecisionPayload, outcome: ElicitationOutcome): DecisionAnswer | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* How long the user gets to answer the form.
|
|
75
|
+
*
|
|
76
|
+
* The SDK would otherwise apply its own DEFAULT_REQUEST_TIMEOUT_MSEC of 60s,
|
|
77
|
+
* which expires while the picker is still on screen: the elicitation rejects,
|
|
78
|
+
* the decision falls back to chat, and the user's eventual answer lands on a
|
|
79
|
+
* request nobody is waiting for. Ten minutes gives a user time to answer
|
|
80
|
+
* without leaving a host request open indefinitely.
|
|
81
|
+
*
|
|
82
|
+
* Kept well under 2^31-1, the point at which setTimeout clamps a delay to 1ms
|
|
83
|
+
* and a nominally "never" timeout would fire immediately.
|
|
84
|
+
*/
|
|
85
|
+
export declare const DECISION_ANSWER_TIMEOUT_MS = 600000;
|
|
86
|
+
/** The slice of a tool call's `extra` that carrying a decision to the host needs. */
|
|
87
|
+
type DecisionSender = {
|
|
88
|
+
sendRequest: (request: {
|
|
89
|
+
method: "elicitation/create";
|
|
90
|
+
params: DecisionElicitationRequest;
|
|
91
|
+
}, resultSchema: typeof ElicitResultSchema, options: {
|
|
92
|
+
signal: AbortSignal;
|
|
93
|
+
timeout: number;
|
|
94
|
+
}) => Promise<ElicitationOutcome>;
|
|
95
|
+
signal: AbortSignal;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Asks the host to show the form, on the tool call's own request stream.
|
|
99
|
+
*
|
|
100
|
+
* Riding that stream matters: a request the gateway raises on its own goes to
|
|
101
|
+
* the standalone stream instead, which a host that never opened one silently
|
|
102
|
+
* drops, leaving the tool call waiting for an answer that cannot arrive.
|
|
103
|
+
*/
|
|
104
|
+
export declare function elicitDecision(extra: DecisionSender): (request: DecisionElicitationRequest) => Promise<ElicitationOutcome>;
|
|
63
105
|
/**
|
|
64
106
|
* Puts a decision to the user as a form and sends their answer on, returning
|
|
65
107
|
* the follow-up turn. Returns undefined when the decision should stay in chat,
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* call answers Superblocks itself rather than handing the question back to the
|
|
9
9
|
* model.
|
|
10
10
|
*/
|
|
11
|
+
import { ElicitResultSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
11
12
|
import { gatewayDebug } from "../../debug.js";
|
|
12
13
|
/**
|
|
13
14
|
* True when the client advertised form elicitation at initialize.
|
|
@@ -65,7 +66,39 @@ export function pendingDecision(result) {
|
|
|
65
66
|
});
|
|
66
67
|
return decision;
|
|
67
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* The application a capability result was about.
|
|
71
|
+
*
|
|
72
|
+
* A tool call that named none has it resolved to the caller's recent
|
|
73
|
+
* application inside the capability, so the id the result carries is the only
|
|
74
|
+
* one a follow-up can safely key on.
|
|
75
|
+
*/
|
|
76
|
+
export function resultApplicationId(result) {
|
|
77
|
+
if (result.kind !== "ok" ||
|
|
78
|
+
!result.value ||
|
|
79
|
+
typeof result.value !== "object") {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const { applicationId } = result.value;
|
|
83
|
+
return typeof applicationId === "string" ? applicationId : undefined;
|
|
84
|
+
}
|
|
85
|
+
export function resultBranch(result) {
|
|
86
|
+
if (result.kind !== "ok" ||
|
|
87
|
+
!result.value ||
|
|
88
|
+
typeof result.value !== "object") {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
const { branch } = result.value;
|
|
92
|
+
return typeof branch === "string" ? branch : undefined;
|
|
93
|
+
}
|
|
68
94
|
export function decisionElicitationRequest(decision) {
|
|
95
|
+
if (decision.kind === "missing_integrations") {
|
|
96
|
+
gatewayDebug("decision request skipped", {
|
|
97
|
+
"decision.kind": decision.kind,
|
|
98
|
+
"decision.reason": "host_action",
|
|
99
|
+
});
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
69
102
|
if (decision.kind === "plan") {
|
|
70
103
|
gatewayDebug("decision request created", {
|
|
71
104
|
"decision.kind": decision.kind,
|
|
@@ -128,6 +161,9 @@ export function decisionElicitationRequest(decision) {
|
|
|
128
161
|
* feedback). Undefined means the caller should leave the decision in chat.
|
|
129
162
|
*/
|
|
130
163
|
export function readDecisionAnswer(decision, outcome) {
|
|
164
|
+
if (decision.kind === "missing_integrations") {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
131
167
|
if (outcome.action !== "accept" || !outcome.content) {
|
|
132
168
|
gatewayDebug("decision answer read", {
|
|
133
169
|
"decision.answer_kind": "none",
|
|
@@ -174,6 +210,29 @@ export function readDecisionAnswer(decision, outcome) {
|
|
|
174
210
|
});
|
|
175
211
|
return offered ? { kind: "answer", prompt: choice } : undefined;
|
|
176
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* How long the user gets to answer the form.
|
|
215
|
+
*
|
|
216
|
+
* The SDK would otherwise apply its own DEFAULT_REQUEST_TIMEOUT_MSEC of 60s,
|
|
217
|
+
* which expires while the picker is still on screen: the elicitation rejects,
|
|
218
|
+
* the decision falls back to chat, and the user's eventual answer lands on a
|
|
219
|
+
* request nobody is waiting for. Ten minutes gives a user time to answer
|
|
220
|
+
* without leaving a host request open indefinitely.
|
|
221
|
+
*
|
|
222
|
+
* Kept well under 2^31-1, the point at which setTimeout clamps a delay to 1ms
|
|
223
|
+
* and a nominally "never" timeout would fire immediately.
|
|
224
|
+
*/
|
|
225
|
+
export const DECISION_ANSWER_TIMEOUT_MS = 600_000;
|
|
226
|
+
/**
|
|
227
|
+
* Asks the host to show the form, on the tool call's own request stream.
|
|
228
|
+
*
|
|
229
|
+
* Riding that stream matters: a request the gateway raises on its own goes to
|
|
230
|
+
* the standalone stream instead, which a host that never opened one silently
|
|
231
|
+
* drops, leaving the tool call waiting for an answer that cannot arrive.
|
|
232
|
+
*/
|
|
233
|
+
export function elicitDecision(extra) {
|
|
234
|
+
return (request) => extra.sendRequest({ method: "elicitation/create", params: request }, ElicitResultSchema, { signal: extra.signal, timeout: DECISION_ANSWER_TIMEOUT_MS });
|
|
235
|
+
}
|
|
177
236
|
/**
|
|
178
237
|
* Puts a decision to the user as a form and sends their answer on, returning
|
|
179
238
|
* the follow-up turn. Returns undefined when the decision should stay in chat,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decision-elicitation.js","sourceRoot":"","sources":["../../../src/transports/mcp/decision-elicitation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"decision-elicitation.js","sourceRoot":"","sources":["../../../src/transports/mcp/decision-elicitation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAMxE,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,CAA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AAE,CAAC;QACZ,YAAY,CAAC,+BAA+B,EAAE;YAC5C,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;YACnC,iBAAiB,EAAE,oBAAoB;YACvC,mBAAmB,EAAE,KAAK;SAC3B,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,YAAY,CAAC,0BAA0B,EAAE;QACvC,sBAAsB,EAAE,MAAM,CAAC,IAAI;QACnC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;KACpC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACxC,YAAY,CAAC,+BAA+B,EAAE;QAC5C,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;QACnC,mBAAmB,EAAE,IAAI;QACzB,aAAa,EAAE,MAAM,CAAC,IAAI;KAC3B,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const EDITOR_DOCUMENT_DEADLINE_MS = 1_000;
|
|
2
|
+
export function createEditorDocumentProbe(options = {}) {
|
|
3
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
4
|
+
return async (editUrl, signal) => {
|
|
5
|
+
if (signal?.aborted) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const controller = new AbortController();
|
|
9
|
+
const abort = () => controller.abort(signal?.reason);
|
|
10
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
11
|
+
const deadline = setTimeout(() => controller.abort(), EDITOR_DOCUMENT_DEADLINE_MS);
|
|
12
|
+
deadline.unref?.();
|
|
13
|
+
try {
|
|
14
|
+
const response = await fetchImpl(new URL(editUrl), {
|
|
15
|
+
method: "GET",
|
|
16
|
+
redirect: "manual",
|
|
17
|
+
signal: controller.signal,
|
|
18
|
+
});
|
|
19
|
+
const available = response.ok ||
|
|
20
|
+
(response.status >= 300 && response.status < 400) ||
|
|
21
|
+
response.status === 401 ||
|
|
22
|
+
response.status === 403;
|
|
23
|
+
await response.body?.cancel().catch(() => undefined);
|
|
24
|
+
return available;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
clearTimeout(deadline);
|
|
31
|
+
signal?.removeEventListener("abort", abort);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=editor-document-probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-document-probe.js","sourceRoot":"","sources":["../../../src/transports/mcp/editor-document-probe.ts"],"names":[],"mappings":"AAKA,MAAM,2BAA2B,GAAG,KAAK,CAAC;AAE1C,MAAM,UAAU,yBAAyB,CACvC,UAAwC,EAAE;IAE1C,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;IAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;QAC/B,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACrD,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,MAAM,QAAQ,GAAG,UAAU,CACzB,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EACxB,2BAA2B,CAC5B,CAAC;QACF,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,EAAE;gBACjD,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,QAAQ;gBAClB,MAAM,EAAE,UAAU,CAAC,MAAM;aAC1B,CAAC,CAAC;YACH,MAAM,SAAS,GACb,QAAQ,CAAC,EAAE;gBACX,CAAC,QAAQ,CAAC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC;gBACjD,QAAQ,CAAC,MAAM,KAAK,GAAG;gBACvB,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC;YAC1B,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACrD,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,QAAQ,CAAC,CAAC;YACvB,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How recently the session must have worked on an application for it to count
|
|
3
|
+
* as the editor the user is still sitting in. Matches the held-session idle
|
|
4
|
+
* window, which is this process's existing notion of one working session.
|
|
5
|
+
*/
|
|
6
|
+
export declare const EDITOR_SETUP_RECENT_APP_WINDOW_MS: number;
|
|
7
|
+
export declare function editorIntegrationSetupUrl(input: {
|
|
8
|
+
applicationId: string;
|
|
9
|
+
branch?: string;
|
|
10
|
+
cowork?: boolean;
|
|
11
|
+
integrationId: string;
|
|
12
|
+
uiBaseUrl: string;
|
|
13
|
+
}): string;
|
|
14
|
+
export declare function isEditorIntegrationSetupUrl(url: string): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { URL_PARAMS } from "@superblocksteam/library-shared";
|
|
2
|
+
/**
|
|
3
|
+
* How recently the session must have worked on an application for it to count
|
|
4
|
+
* as the editor the user is still sitting in. Matches the held-session idle
|
|
5
|
+
* window, which is this process's existing notion of one working session.
|
|
6
|
+
*/
|
|
7
|
+
export const EDITOR_SETUP_RECENT_APP_WINDOW_MS = 30 * 60 * 1000;
|
|
8
|
+
export function editorIntegrationSetupUrl(input) {
|
|
9
|
+
const url = new URL(`${input.uiBaseUrl.replace(/\/$/, "")}/code-mode/applications/edit/${encodeURIComponent(input.applicationId)}`);
|
|
10
|
+
if (input.branch) {
|
|
11
|
+
url.searchParams.set("branch", input.branch);
|
|
12
|
+
}
|
|
13
|
+
url.searchParams.set(URL_PARAMS.integrationSetup, input.integrationId);
|
|
14
|
+
if (input.cowork) {
|
|
15
|
+
url.searchParams.set(URL_PARAMS.editorHost, "cowork");
|
|
16
|
+
}
|
|
17
|
+
return url.toString();
|
|
18
|
+
}
|
|
19
|
+
export function isEditorIntegrationSetupUrl(url) {
|
|
20
|
+
try {
|
|
21
|
+
const parsed = new URL(url);
|
|
22
|
+
return (parsed.pathname.includes("/applications/edit/") &&
|
|
23
|
+
parsed.searchParams.has(URL_PARAMS.integrationSetup));
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=editor-integration-setup-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-integration-setup-url.js","sourceRoot":"","sources":["../../../src/transports/mcp/editor-integration-setup-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhE,MAAM,UAAU,yBAAyB,CAAC,KAMzC;IACC,MAAM,GAAG,GAAG,IAAI,GAAG,CACjB,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,gCAAgC,kBAAkB,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAC/G,CAAC;IACF,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IACD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,gBAAgB,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IACvE,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,GAAW;IACrD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,CACL,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,qBAAqB,CAAC;YAC/C,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,gBAAgB,CAAC,CACrD,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -1,25 +1,20 @@
|
|
|
1
|
+
import type { ContentBlock } from "@modelcontextprotocol/sdk/types.js";
|
|
1
2
|
import type { CapabilityResult } from "../../capabilities/types.js";
|
|
2
|
-
type
|
|
3
|
-
type: "text";
|
|
4
|
-
text: string;
|
|
5
|
-
} | {
|
|
6
|
-
type: "image";
|
|
7
|
-
data: string;
|
|
8
|
-
mimeType: "image/jpeg";
|
|
9
|
-
};
|
|
3
|
+
import type { ClientProfile } from "./client-presentation.js";
|
|
10
4
|
/**
|
|
11
|
-
* Serializes a capability result
|
|
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.
|
|
5
|
+
* Serializes a capability result into MCP content blocks.
|
|
16
6
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
7
|
+
* Block order is important: callers read `content[0]` as the JSON body and
|
|
8
|
+
* `content.at(-1)` as the closing instruction.
|
|
9
|
+
*
|
|
10
|
+
* Screenshot bytes stay in the JSON as well as the image block, because Cursor
|
|
11
|
+
* CLI agents never see image blocks. A plan gets its own markdown block where a
|
|
12
|
+
* model renders the ask: in the JSON it is one escaped string, and a model that
|
|
13
|
+
* re-lays it out demotes headings and merges bullets. That block holds the plan
|
|
14
|
+
* and title only - an earlier version bundled instructions and option labels,
|
|
15
|
+
* which models pasted into the chat as a menu.
|
|
20
16
|
*/
|
|
21
17
|
export declare function formatMcpToolContent(result: CapabilityResult<unknown>, progress?: Array<{
|
|
22
18
|
type: string;
|
|
23
19
|
message: string;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
20
|
+
}>, profile?: ClientProfile): ContentBlock[];
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
+
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
2
|
+
import { gfmAutolinkLiteralFromMarkdown } from "mdast-util-gfm-autolink-literal";
|
|
3
|
+
import { gfmAutolinkLiteral } from "micromark-extension-gfm-autolink-literal";
|
|
4
|
+
import { isRecord, readResult } from "./instructions/result.js";
|
|
1
5
|
/**
|
|
2
|
-
* Serializes a capability result
|
|
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.
|
|
6
|
+
* Serializes a capability result into MCP content blocks.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Block order is important: callers read `content[0]` as the JSON body and
|
|
9
|
+
* `content.at(-1)` as the closing instruction.
|
|
10
|
+
*
|
|
11
|
+
* Screenshot bytes stay in the JSON as well as the image block, because Cursor
|
|
12
|
+
* CLI agents never see image blocks. A plan gets its own markdown block where a
|
|
13
|
+
* model renders the ask: in the JSON it is one escaped string, and a model that
|
|
14
|
+
* re-lays it out demotes headings and merges bullets. That block holds the plan
|
|
15
|
+
* and title only - an earlier version bundled instructions and option labels,
|
|
16
|
+
* which models pasted into the chat as a menu.
|
|
11
17
|
*/
|
|
12
|
-
export function formatMcpToolContent(result, progress = []) {
|
|
13
|
-
const
|
|
18
|
+
export function formatMcpToolContent(result, progress = [], profile) {
|
|
19
|
+
const displayed = withDisplayedMentions(result);
|
|
20
|
+
const { publishDetailsUrl, screenshotBase64, textResult } = extractRichContent(displayed);
|
|
14
21
|
const content = [];
|
|
15
22
|
// Every text block ends in a newline because hosts concatenate them: without
|
|
16
23
|
// it the trail read "}[progress] Creating application[progress] Connecting
|
|
@@ -20,6 +27,21 @@ export function formatMcpToolContent(result, progress = []) {
|
|
|
20
27
|
text: `${JSON.stringify(textResult, null, 2)}\n`,
|
|
21
28
|
type: "text",
|
|
22
29
|
});
|
|
30
|
+
if (profile?.hasNativeAskForm) {
|
|
31
|
+
const plan = planMarkdown(displayed);
|
|
32
|
+
if (plan) {
|
|
33
|
+
content.push({ text: `\n${plan}\n\n`, type: "text" });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (publishDetailsUrl) {
|
|
37
|
+
content.push({
|
|
38
|
+
description: "View publish details",
|
|
39
|
+
name: "publish-details",
|
|
40
|
+
title: "View publish details",
|
|
41
|
+
type: "resource_link",
|
|
42
|
+
uri: publishDetailsUrl,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
23
45
|
content.push(...progress.map((event) => ({
|
|
24
46
|
text: `[${event.type}] ${event.message}\n`,
|
|
25
47
|
type: "text",
|
|
@@ -33,16 +55,153 @@ export function formatMcpToolContent(result, progress = []) {
|
|
|
33
55
|
}
|
|
34
56
|
return content;
|
|
35
57
|
}
|
|
36
|
-
function
|
|
58
|
+
function planMarkdown(result) {
|
|
59
|
+
const flat = readResult(result);
|
|
60
|
+
if (flat.status !== "needs_decision" || flat.decisionKind !== "plan") {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
const decision = flat.value.decision;
|
|
64
|
+
if (!isRecord(decision)) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const plan = typeof decision.plan === "string" ? decision.plan.trim() : "";
|
|
68
|
+
if (!plan) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
const title = typeof decision.title === "string" ? decision.title.trim() : "";
|
|
72
|
+
return title ? `**${title}**\n\n${plan}` : plan;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* An integration mention as Superblocks writes it: `@Orders[id=<uuid>]`. The
|
|
76
|
+
* editor turns that into a pill, so it matches the decision card's pattern.
|
|
77
|
+
*/
|
|
78
|
+
const ENTITY_MENTION = /(\\*)@((?:(?!\[id=)[^@\r\n])+?(?<!\s))\[id=[^\]\r\n]+\]/gu;
|
|
79
|
+
/**
|
|
80
|
+
* Bolds integration names without changing the plan's authored Markdown.
|
|
81
|
+
*
|
|
82
|
+
* Only the MCP copy changes. The decision card reads `structuredContent`,
|
|
83
|
+
* which still carries the tags it renders as pills.
|
|
84
|
+
*/
|
|
85
|
+
function withDisplayedMentions(result) {
|
|
86
|
+
if (result.kind !== "ok" || !isRecord(result.value)) {
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
const value = result.value;
|
|
90
|
+
const decision = value.decision;
|
|
91
|
+
if (value.status !== "needs_decision" ||
|
|
92
|
+
!isRecord(decision) ||
|
|
93
|
+
decision.kind !== "plan" ||
|
|
94
|
+
typeof decision.plan !== "string") {
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
const plan = displayPlanMentions(decision.plan);
|
|
98
|
+
if (plan === decision.plan) {
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
...result,
|
|
103
|
+
value: { ...value, decision: { ...decision, plan } },
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function displayPlanMentions(source) {
|
|
107
|
+
let plan = source;
|
|
108
|
+
const masked = source.replace(ENTITY_MENTION, (mention, escapes) => escapes.length % 2 === 1
|
|
109
|
+
? mention
|
|
110
|
+
: `${escapes}@${"x".repeat(mention.length - escapes.length - 2)};`);
|
|
111
|
+
function visit(node, bold = false, before, after) {
|
|
112
|
+
if (node.type === "link" &&
|
|
113
|
+
source[node.position?.start.offset ?? -1] !== "[") {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (node.type === "text") {
|
|
117
|
+
const start = node.position?.start.offset;
|
|
118
|
+
const end = node.position?.end.offset;
|
|
119
|
+
if (start === undefined || end === undefined) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const original = source.slice(start, end);
|
|
123
|
+
let replacementStart = start;
|
|
124
|
+
let replacementEnd = end;
|
|
125
|
+
let text = "";
|
|
126
|
+
let cursor = 0;
|
|
127
|
+
let previousMentionEnd = -1;
|
|
128
|
+
for (const match of original.matchAll(ENTITY_MENTION)) {
|
|
129
|
+
const [mention, escapes = "", label] = match;
|
|
130
|
+
if (label === undefined || escapes.length % 2 === 1) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
text += original.slice(cursor, match.index);
|
|
134
|
+
const literal = label.replace(/[\\`*_[\]<>&~|]/g, "\\$&");
|
|
135
|
+
if (bold) {
|
|
136
|
+
text += escapes + literal;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
const joinsMention = escapes.length === 0 && previousMentionEnd === match.index;
|
|
140
|
+
const joinsStrong = escapes.length === 0 &&
|
|
141
|
+
match.index === 0 &&
|
|
142
|
+
before?.type === "strong" &&
|
|
143
|
+
before.position?.end.offset === start &&
|
|
144
|
+
source.slice(start - 2, start) === "**";
|
|
145
|
+
if (joinsMention) {
|
|
146
|
+
text = text.slice(0, -2);
|
|
147
|
+
}
|
|
148
|
+
if (joinsStrong) {
|
|
149
|
+
replacementStart -= 2;
|
|
150
|
+
}
|
|
151
|
+
text +=
|
|
152
|
+
escapes +
|
|
153
|
+
(joinsMention || joinsStrong ? "" : "**") +
|
|
154
|
+
literal +
|
|
155
|
+
"**";
|
|
156
|
+
}
|
|
157
|
+
cursor = match.index + mention.length;
|
|
158
|
+
previousMentionEnd = cursor;
|
|
159
|
+
}
|
|
160
|
+
if (!bold &&
|
|
161
|
+
previousMentionEnd === original.length &&
|
|
162
|
+
after?.type === "strong" &&
|
|
163
|
+
after.position?.start.offset === end &&
|
|
164
|
+
source.slice(end, end + 2) === "**") {
|
|
165
|
+
text = text.slice(0, -2);
|
|
166
|
+
replacementEnd += 2;
|
|
167
|
+
}
|
|
168
|
+
text += original.slice(cursor);
|
|
169
|
+
plan =
|
|
170
|
+
plan.slice(0, replacementStart) + text + plan.slice(replacementEnd);
|
|
171
|
+
}
|
|
172
|
+
else if ("children" in node) {
|
|
173
|
+
for (let index = node.children.length - 1; index >= 0; index--) {
|
|
174
|
+
const child = node.children[index];
|
|
175
|
+
if (!child) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
visit(child, bold || node.type === "strong", node.children[index - 1], node.children[index + 1]);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
visit(fromMarkdown(masked, {
|
|
183
|
+
extensions: [gfmAutolinkLiteral()],
|
|
184
|
+
mdastExtensions: [gfmAutolinkLiteralFromMarkdown()],
|
|
185
|
+
}));
|
|
186
|
+
return plan;
|
|
187
|
+
}
|
|
188
|
+
function extractRichContent(result) {
|
|
37
189
|
if (result.kind !== "ok" ||
|
|
38
190
|
!result.value ||
|
|
39
191
|
typeof result.value !== "object") {
|
|
40
|
-
return {
|
|
192
|
+
return {
|
|
193
|
+
publishDetailsUrl: undefined,
|
|
194
|
+
screenshotBase64: undefined,
|
|
195
|
+
textResult: result,
|
|
196
|
+
};
|
|
41
197
|
}
|
|
42
198
|
const value = result.value;
|
|
199
|
+
const publishDetailsUrl = typeof value.publishDetailsUrl === "string"
|
|
200
|
+
? value.publishDetailsUrl
|
|
201
|
+
: undefined;
|
|
43
202
|
const screenshotBase64 = typeof value.screenshotBase64 === "string"
|
|
44
203
|
? value.screenshotBase64
|
|
45
204
|
: undefined;
|
|
46
|
-
return { screenshotBase64, textResult: result };
|
|
205
|
+
return { publishDetailsUrl, screenshotBase64, textResult: result };
|
|
47
206
|
}
|
|
48
207
|
//# sourceMappingURL=format-tool-content.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-tool-content.js","sourceRoot":"","sources":["../../../src/transports/mcp/format-tool-content.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"format-tool-content.js","sourceRoot":"","sources":["../../../src/transports/mcp/format-tool-content.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAI9E,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAiC,EACjC,WAAqD,EAAE,EACvD,OAAuB;IAEvB,MAAM,SAAS,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,UAAU,EAAE,GACvD,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,6EAA6E;IAC7E,2EAA2E;IAC3E,4EAA4E;IAC5E,wBAAwB;IACxB,OAAO,CAAC,IAAI,CAAC;QACX,IAAI,EA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ools/` 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 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;
|