@herbertgao/pi-extensions 2026.9.11 → 2026.9.13
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 +4 -4
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +1 -1
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +8 -0
- package/node_modules/@herbertgao/pi-subagents/package.json +1 -1
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +5 -4
- package/node_modules/@herbertgao/pi-subagents/src/mention-clone.ts +39 -16
- package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +2 -2
- package/node_modules/@narumitw/pi-btw/README.md +21 -4
- package/node_modules/@narumitw/pi-btw/dist/index.ts +1668 -958
- package/node_modules/@narumitw/pi-btw/dist/index.ts.map +4 -4
- package/node_modules/@narumitw/pi-btw/docs/workflows.md +10 -2
- package/node_modules/@narumitw/pi-btw/package.json +1 -1
- package/node_modules/@narumitw/pi-btw/src/btw.ts +17 -79
- package/node_modules/@narumitw/pi-btw/src/conversation-context.ts +74 -0
- package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +196 -7
- package/node_modules/@narumitw/pi-btw/src/main-thread-updates.ts +40 -0
- package/node_modules/@narumitw/pi-btw/src/menu.ts +34 -2
- package/node_modules/@narumitw/pi-btw/src/settings.ts +49 -0
- package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +9 -1
- package/node_modules/@narumitw/pi-btw/src/workspace-layout.ts +559 -0
- package/node_modules/pi-mcp-adapter/CHANGELOG.md +62 -0
- package/node_modules/pi-mcp-adapter/README.md +75 -7
- package/node_modules/pi-mcp-adapter/bearer-command-resolver.ts +193 -0
- package/node_modules/pi-mcp-adapter/cli.js +56 -5
- package/node_modules/pi-mcp-adapter/commands.ts +96 -5
- package/node_modules/pi-mcp-adapter/config.ts +73 -6
- package/node_modules/pi-mcp-adapter/direct-tool-surface.ts +22 -28
- package/node_modules/pi-mcp-adapter/direct-tools.ts +13 -5
- package/node_modules/pi-mcp-adapter/dist/abort.d.ts +2 -0
- package/node_modules/pi-mcp-adapter/dist/abort.js +36 -0
- package/node_modules/pi-mcp-adapter/dist/abort.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.d.ts +6 -0
- package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.js +194 -0
- package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/config.d.ts +5 -0
- package/node_modules/pi-mcp-adapter/dist/config.js +75 -6
- package/node_modules/pi-mcp-adapter/dist/config.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/consent-manager.d.ts +18 -0
- package/node_modules/pi-mcp-adapter/dist/consent-manager.js +88 -0
- package/node_modules/pi-mcp-adapter/dist/consent-manager.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/elicitation-handler.d.ts +17 -0
- package/node_modules/pi-mcp-adapter/dist/elicitation-handler.js +316 -0
- package/node_modules/pi-mcp-adapter/dist/elicitation-handler.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/errors.d.ts +131 -0
- package/node_modules/pi-mcp-adapter/dist/errors.js +278 -0
- package/node_modules/pi-mcp-adapter/dist/errors.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/http-ca.d.ts +8 -0
- package/node_modules/pi-mcp-adapter/dist/http-ca.js +88 -0
- package/node_modules/pi-mcp-adapter/dist/http-ca.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/jev-client.d.ts +15 -0
- package/node_modules/pi-mcp-adapter/dist/jev-client.js +340 -0
- package/node_modules/pi-mcp-adapter/dist/jev-client.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/jev-contracts.d.ts +77 -0
- package/node_modules/pi-mcp-adapter/dist/jev-contracts.js +2 -0
- package/node_modules/pi-mcp-adapter/dist/jev-contracts.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/jev-key-store.d.ts +22 -0
- package/node_modules/pi-mcp-adapter/dist/jev-key-store.js +85 -0
- package/node_modules/pi-mcp-adapter/dist/jev-key-store.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/json-schema-validator.d.ts +2 -0
- package/node_modules/pi-mcp-adapter/dist/json-schema-validator.js +55 -0
- package/node_modules/pi-mcp-adapter/dist/json-schema-validator.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/lifecycle.d.ts +56 -0
- package/node_modules/pi-mcp-adapter/dist/lifecycle.js +410 -0
- package/node_modules/pi-mcp-adapter/dist/lifecycle.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/logger.d.ts +51 -0
- package/node_modules/pi-mcp-adapter/dist/logger.js +131 -0
- package/node_modules/pi-mcp-adapter/dist/logger.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.d.ts +26 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.js +103 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.d.ts +118 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.js +1098 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth.d.ts +168 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth.js +1117 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js +7 -140
- package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.d.ts +53 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.js +441 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.d.ts +148 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.js +689 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-probe.d.ts +6 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-probe.js +166 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-probe.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-tasks.d.ts +102 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-tasks.js +369 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-tasks.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-trace.d.ts +95 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-trace.js +242 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-trace.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/metadata-cache.js +2 -11
- package/node_modules/pi-mcp-adapter/dist/metadata-cache.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/npx-resolver.d.ts +6 -0
- package/node_modules/pi-mcp-adapter/dist/npx-resolver.js +505 -0
- package/node_modules/pi-mcp-adapter/dist/npx-resolver.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/request-headers-command.d.ts +10 -0
- package/node_modules/pi-mcp-adapter/dist/request-headers-command.js +312 -0
- package/node_modules/pi-mcp-adapter/dist/request-headers-command.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/runtime-owner.d.ts +13 -0
- package/node_modules/pi-mcp-adapter/dist/runtime-owner.js +97 -0
- package/node_modules/pi-mcp-adapter/dist/runtime-owner.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/sampling-handler.d.ts +17 -0
- package/node_modules/pi-mcp-adapter/dist/sampling-handler.js +203 -0
- package/node_modules/pi-mcp-adapter/dist/sampling-handler.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/secure-keyring.d.ts +11 -0
- package/node_modules/pi-mcp-adapter/dist/secure-keyring.js +172 -0
- package/node_modules/pi-mcp-adapter/dist/secure-keyring.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/server-manager.d.ts +157 -0
- package/node_modules/pi-mcp-adapter/dist/server-manager.js +1743 -0
- package/node_modules/pi-mcp-adapter/dist/server-manager.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/session-approvals.d.ts +34 -0
- package/node_modules/pi-mcp-adapter/dist/session-approvals.js +140 -0
- package/node_modules/pi-mcp-adapter/dist/session-approvals.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/session-recovery.d.ts +26 -0
- package/node_modules/pi-mcp-adapter/dist/session-recovery.js +142 -0
- package/node_modules/pi-mcp-adapter/dist/session-recovery.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/state.d.ts +73 -0
- package/node_modules/pi-mcp-adapter/dist/state.js +2 -0
- package/node_modules/pi-mcp-adapter/dist/state.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/types.d.ts +36 -0
- package/node_modules/pi-mcp-adapter/dist/types.js +18 -0
- package/node_modules/pi-mcp-adapter/dist/types.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.d.ts +17 -0
- package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.js +219 -0
- package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.d.ts +15 -0
- package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.js +85 -0
- package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/utils.d.ts +1 -0
- package/node_modules/pi-mcp-adapter/dist/utils.js +13 -0
- package/node_modules/pi-mcp-adapter/dist/utils.js.map +1 -1
- package/node_modules/pi-mcp-adapter/elicitation-handler.ts +29 -19
- package/node_modules/pi-mcp-adapter/examples/jev-accessibility-loop.mjs +85 -0
- package/node_modules/pi-mcp-adapter/examples/jev-semantic-filter.mjs +34 -0
- package/node_modules/pi-mcp-adapter/index.ts +129 -6
- package/node_modules/pi-mcp-adapter/init.ts +6 -19
- package/node_modules/pi-mcp-adapter/jev-client.ts +273 -0
- package/node_modules/pi-mcp-adapter/jev-contracts.ts +53 -0
- package/node_modules/pi-mcp-adapter/jev-key-store.ts +79 -0
- package/node_modules/pi-mcp-adapter/lifecycle.ts +14 -3
- package/node_modules/pi-mcp-adapter/mcp-bearer-store.ts +7 -142
- package/node_modules/pi-mcp-adapter/mcp-code.ts +119 -11
- package/node_modules/pi-mcp-adapter/mcp-output-guard.ts +4 -0
- package/node_modules/pi-mcp-adapter/mcp-references.ts +5 -3
- package/node_modules/pi-mcp-adapter/mcp-script-worker.mjs +5 -0
- package/node_modules/pi-mcp-adapter/mcp-tasks.ts +467 -0
- package/node_modules/pi-mcp-adapter/metadata-cache.ts +2 -13
- package/node_modules/pi-mcp-adapter/namespace-tools.ts +1 -1
- package/node_modules/pi-mcp-adapter/package.json +17 -9
- package/node_modules/pi-mcp-adapter/proxy-modes.ts +319 -166
- package/node_modules/pi-mcp-adapter/request-headers-command.ts +6 -3
- package/node_modules/pi-mcp-adapter/search-ranking.ts +38 -7
- package/node_modules/pi-mcp-adapter/secure-keyring.ts +170 -0
- package/node_modules/pi-mcp-adapter/semantic-search.ts +186 -0
- package/node_modules/pi-mcp-adapter/server-manager.ts +293 -50
- package/node_modules/pi-mcp-adapter/session-approvals.ts +14 -0
- package/node_modules/pi-mcp-adapter/skills/mcp-scripting/SKILL.md +2 -0
- package/node_modules/pi-mcp-adapter/state.ts +3 -1
- package/node_modules/pi-mcp-adapter/tool-approval.ts +26 -4
- package/node_modules/pi-mcp-adapter/tool-metadata.ts +6 -14
- package/node_modules/pi-mcp-adapter/tool-registrar.ts +8 -6
- package/node_modules/pi-mcp-adapter/tool-result-renderer.ts +4 -1
- package/node_modules/pi-mcp-adapter/types.ts +53 -0
- package/node_modules/pi-mcp-adapter/ui-server.ts +17 -9
- package/node_modules/pi-mcp-adapter/utils.ts +16 -0
- package/node_modules/pi-multi-account/CHANGELOG.md +23 -0
- package/node_modules/pi-multi-account/README.md +38 -11
- package/node_modules/pi-multi-account/index.ts +371 -96
- package/node_modules/pi-multi-account/package.json +5 -4
- package/node_modules/pi-multi-account/provider-payload-stream.ts +36 -28
- package/node_modules/pi-multi-account/usage.ts +31 -2
- package/node_modules/pi-typesafe/README.md +3 -1
- package/node_modules/pi-typesafe/dist/auth.d.ts +10 -3
- package/node_modules/pi-typesafe/dist/auth.js +13 -7
- package/node_modules/pi-typesafe/dist/backends.d.ts +31 -0
- package/node_modules/pi-typesafe/dist/backends.js +33 -0
- package/node_modules/pi-typesafe/dist/client.d.ts +3 -9
- package/node_modules/pi-typesafe/dist/client.js +63 -39
- package/node_modules/pi-typesafe/dist/credentials.d.ts +11 -5
- package/node_modules/pi-typesafe/dist/credentials.js +15 -8
- package/node_modules/pi-typesafe/dist/extension.js +4 -1
- package/node_modules/pi-typesafe/dist/index.d.ts +1 -1
- package/node_modules/pi-typesafe/dist/index.js +1 -1
- package/node_modules/pi-typesafe/dist/login.d.ts +13 -7
- package/node_modules/pi-typesafe/dist/login.js +17 -8
- package/node_modules/pi-typesafe/dist/schema.js +19 -13
- package/node_modules/pi-typesafe/package.json +1 -1
- package/package.json +11 -10
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { ProtocolError } from "@modelcontextprotocol/client";
|
|
2
|
+
import { createApplicationInputHandler, createTaskSessionEndpointId, createTaskSessionFromClient, DispatchError, JsonRpcResponseError, resultFromTaskOutcome, TaskCancelledError, TaskFailedError, } from "@modelcontextprotocol/ext-tasks/client";
|
|
3
|
+
import { logger } from "./logger.js";
|
|
4
|
+
export const TASKS_EXTENSION_ID = "io.modelcontextprotocol/tasks";
|
|
5
|
+
const RAW_REQUEST_ID_PREFIX = "pi-mcp-tasks-";
|
|
6
|
+
const DEFAULT_RAW_REQUEST_TIMEOUT_MS = 60_000;
|
|
7
|
+
const LATE_TASK_HANDLE_GRACE_MS = 60_000;
|
|
8
|
+
function abortError(signal) {
|
|
9
|
+
return signal.reason instanceof Error
|
|
10
|
+
? signal.reason
|
|
11
|
+
: new DOMException("This operation was aborted", "AbortError");
|
|
12
|
+
}
|
|
13
|
+
function isJsonRecord(value) {
|
|
14
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Raw JSON-RPC request channel chained onto a connected transport. Raw
|
|
18
|
+
* requests use string ids with a reserved prefix, which cannot collide with
|
|
19
|
+
* the SDK's numeric ids; their responses are consumed before the SDK client
|
|
20
|
+
* sees them. All other traffic passes through unchanged.
|
|
21
|
+
*
|
|
22
|
+
* Attach only after Client.connect has installed its transport handlers:
|
|
23
|
+
* attach() reads the current onmessage/onclose (through any wrapper
|
|
24
|
+
* accessors) and chains in front of them.
|
|
25
|
+
*/
|
|
26
|
+
export class RawRequestChannel {
|
|
27
|
+
transport;
|
|
28
|
+
pending = new Map();
|
|
29
|
+
requestCounter = 0;
|
|
30
|
+
defaultTimeoutMs;
|
|
31
|
+
attached = false;
|
|
32
|
+
constructor(transport, defaultTimeoutMs) {
|
|
33
|
+
this.transport = transport;
|
|
34
|
+
this.defaultTimeoutMs = defaultTimeoutMs ?? DEFAULT_RAW_REQUEST_TIMEOUT_MS;
|
|
35
|
+
}
|
|
36
|
+
attach() {
|
|
37
|
+
if (this.attached)
|
|
38
|
+
return;
|
|
39
|
+
this.attached = true;
|
|
40
|
+
const previousOnMessage = this.transport.onmessage;
|
|
41
|
+
this.transport.onmessage = (message, extra) => {
|
|
42
|
+
if (this.consumeRawResponse(message))
|
|
43
|
+
return;
|
|
44
|
+
previousOnMessage?.(message, extra);
|
|
45
|
+
};
|
|
46
|
+
const previousOnClose = this.transport.onclose;
|
|
47
|
+
this.transport.onclose = () => {
|
|
48
|
+
this.rejectAll("MCP connection closed");
|
|
49
|
+
previousOnClose?.();
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Sends a raw JSON-RPC request and resolves with its correlated response. */
|
|
53
|
+
rawDispatch = (request, options) => {
|
|
54
|
+
if (!isJsonRecord(request) || typeof request.method !== "string") {
|
|
55
|
+
return Promise.reject(new Error("Raw MCP request must be a JSON object with a string method"));
|
|
56
|
+
}
|
|
57
|
+
const params = request.params;
|
|
58
|
+
if (params !== undefined && !isJsonRecord(params)) {
|
|
59
|
+
return Promise.reject(new Error("Raw MCP request params must be a JSON object"));
|
|
60
|
+
}
|
|
61
|
+
const signal = options?.signal;
|
|
62
|
+
if (signal?.aborted)
|
|
63
|
+
return Promise.reject(abortError(signal));
|
|
64
|
+
const id = `${RAW_REQUEST_ID_PREFIX}${++this.requestCounter}`;
|
|
65
|
+
const message = {
|
|
66
|
+
jsonrpc: "2.0",
|
|
67
|
+
id,
|
|
68
|
+
method: request.method,
|
|
69
|
+
...(params === undefined ? {} : { params }),
|
|
70
|
+
};
|
|
71
|
+
const timeoutMs = options?.context?.requestTimeoutMs ?? this.defaultTimeoutMs;
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
const entry = {
|
|
74
|
+
id,
|
|
75
|
+
resolve,
|
|
76
|
+
reject,
|
|
77
|
+
state: "pending",
|
|
78
|
+
...(signal === undefined ? {} : { signal }),
|
|
79
|
+
...(message.method === "tools/call" ? { observationController: new AbortController() } : {}),
|
|
80
|
+
};
|
|
81
|
+
entry.requestTimer = setTimeout(() => {
|
|
82
|
+
this.terminateLocalWait(entry, new Error(`MCP task request "${message.method}" timed out after ${timeoutMs}ms`));
|
|
83
|
+
}, timeoutMs);
|
|
84
|
+
this.pending.set(id, entry);
|
|
85
|
+
if (signal) {
|
|
86
|
+
entry.onAbort = () => {
|
|
87
|
+
this.terminateLocalWait(entry, abortError(signal));
|
|
88
|
+
};
|
|
89
|
+
signal.addEventListener("abort", entry.onAbort, { once: true });
|
|
90
|
+
}
|
|
91
|
+
const fail = (error) => {
|
|
92
|
+
if (this.pending.get(id) !== entry)
|
|
93
|
+
return;
|
|
94
|
+
const wasPending = entry.state === "pending";
|
|
95
|
+
this.finishRequest(entry, true);
|
|
96
|
+
if (wasPending)
|
|
97
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
98
|
+
};
|
|
99
|
+
// ext-tasks supplies the SEP-2663 Mcp-Name routing header (and any
|
|
100
|
+
// host headers) via context.headers. A task-producing tools/call owns
|
|
101
|
+
// its transport observation independently from the caller's wait.
|
|
102
|
+
try {
|
|
103
|
+
Promise.resolve(this.transport.send(message, {
|
|
104
|
+
...(options?.context?.headers === undefined ? {} : { headers: options.context.headers }),
|
|
105
|
+
...(entry.observationController !== undefined
|
|
106
|
+
? { requestSignal: entry.observationController.signal }
|
|
107
|
+
: signal === undefined ? {} : { requestSignal: signal }),
|
|
108
|
+
})).catch(fail);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
fail(error);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
consumeRawResponse(message) {
|
|
116
|
+
if (!("id" in message) || typeof message.id !== "string")
|
|
117
|
+
return false;
|
|
118
|
+
if (!message.id.startsWith(RAW_REQUEST_ID_PREFIX))
|
|
119
|
+
return false;
|
|
120
|
+
// A server request may choose any string ID, including our client-side
|
|
121
|
+
// prefix. Method-bearing frames still belong to the SDK request handler.
|
|
122
|
+
if ("method" in message)
|
|
123
|
+
return false;
|
|
124
|
+
const entry = this.pending.get(message.id);
|
|
125
|
+
if (!entry)
|
|
126
|
+
return true; // ours, but already completed or its bounded observation expired
|
|
127
|
+
const wasObserving = entry.state === "observing";
|
|
128
|
+
this.finishRequest(entry, true);
|
|
129
|
+
if (wasObserving) {
|
|
130
|
+
this.cancelLateTask(message);
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
if ("error" in message) {
|
|
134
|
+
const { code, message: errorMessage, data } = message.error;
|
|
135
|
+
entry.resolve({ kind: "error", error: { code, message: errorMessage, ...(data === undefined ? {} : { data }) } });
|
|
136
|
+
}
|
|
137
|
+
else if ("result" in message) {
|
|
138
|
+
entry.resolve({ kind: "result", result: message.result });
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
entry.reject(new Error("MCP task response frame carried neither result nor error"));
|
|
142
|
+
}
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
terminateLocalWait(entry, error) {
|
|
146
|
+
if (this.pending.get(entry.id) !== entry || entry.state !== "pending")
|
|
147
|
+
return;
|
|
148
|
+
if (entry.observationController === undefined) {
|
|
149
|
+
this.finishRequest(entry, false);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
entry.state = "observing";
|
|
153
|
+
this.clearLocalWait(entry);
|
|
154
|
+
entry.observationTimer = setTimeout(() => {
|
|
155
|
+
this.finishRequest(entry, true);
|
|
156
|
+
}, LATE_TASK_HANDLE_GRACE_MS);
|
|
157
|
+
}
|
|
158
|
+
entry.reject(error);
|
|
159
|
+
}
|
|
160
|
+
clearLocalWait(entry) {
|
|
161
|
+
if (entry.requestTimer !== undefined)
|
|
162
|
+
clearTimeout(entry.requestTimer);
|
|
163
|
+
delete entry.requestTimer;
|
|
164
|
+
if (entry.signal !== undefined && entry.onAbort !== undefined) {
|
|
165
|
+
entry.signal.removeEventListener("abort", entry.onAbort);
|
|
166
|
+
}
|
|
167
|
+
delete entry.onAbort;
|
|
168
|
+
}
|
|
169
|
+
finishRequest(entry, abortObservation) {
|
|
170
|
+
if (this.pending.get(entry.id) !== entry)
|
|
171
|
+
return;
|
|
172
|
+
this.clearLocalWait(entry);
|
|
173
|
+
if (entry.observationTimer !== undefined)
|
|
174
|
+
clearTimeout(entry.observationTimer);
|
|
175
|
+
delete entry.observationTimer;
|
|
176
|
+
this.pending.delete(entry.id);
|
|
177
|
+
if (abortObservation)
|
|
178
|
+
entry.observationController?.abort();
|
|
179
|
+
}
|
|
180
|
+
cancelLateTask(message) {
|
|
181
|
+
if (!("result" in message) || !isJsonRecord(message.result))
|
|
182
|
+
return;
|
|
183
|
+
if (message.result.resultType !== "task" || typeof message.result.taskId !== "string")
|
|
184
|
+
return;
|
|
185
|
+
const taskId = message.result.taskId;
|
|
186
|
+
void this.rawDispatch({ method: "tasks/cancel", params: { taskId } }, { context: { headers: { "Mcp-Name": taskId } } }).catch(() => { });
|
|
187
|
+
}
|
|
188
|
+
rejectAll(reason) {
|
|
189
|
+
const entries = [...this.pending.values()];
|
|
190
|
+
for (const entry of entries) {
|
|
191
|
+
const wasPending = entry.state === "pending";
|
|
192
|
+
this.finishRequest(entry, true);
|
|
193
|
+
if (wasPending)
|
|
194
|
+
entry.reject(new Error(reason));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Whether a connected 2026-07-28 server advertises the tasks extension.
|
|
200
|
+
* ext-tasks requires the exact empty-object declaration; anything else
|
|
201
|
+
* downgrades the session, so mirror its check here.
|
|
202
|
+
*
|
|
203
|
+
* Legacy (2025-11-25) task servers are intentionally out of scope: driving
|
|
204
|
+
* their opt-in `task` parameter requires per-tool taskSupport declarations,
|
|
205
|
+
* which this integration does not supply.
|
|
206
|
+
*/
|
|
207
|
+
export function serverAdvertisesTasks(client) {
|
|
208
|
+
if (client.getProtocolEra?.() !== "modern")
|
|
209
|
+
return false;
|
|
210
|
+
const capabilities = client.getServerCapabilities();
|
|
211
|
+
const extension = capabilities?.extensions?.[TASKS_EXTENSION_ID];
|
|
212
|
+
return isJsonRecord(extension) && Object.keys(extension).length === 0;
|
|
213
|
+
}
|
|
214
|
+
/** Missing-handler errors carry the SDK's capability shape so call sites can classify them. */
|
|
215
|
+
function capabilityNotSupportedError(serverName, method, inputKey) {
|
|
216
|
+
const error = new Error(`MCP server ${serverName} requested ${method} during a task, but this session has no handler for it`);
|
|
217
|
+
Object.assign(error, {
|
|
218
|
+
code: "CAPABILITY_NOT_SUPPORTED",
|
|
219
|
+
data: { key: inputKey ?? "unknown", method },
|
|
220
|
+
});
|
|
221
|
+
return error;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Attaches an ext-tasks requester session to a connected client when the
|
|
225
|
+
* server advertises task support. Returns undefined otherwise, leaving the
|
|
226
|
+
* plain callTool path untouched.
|
|
227
|
+
*/
|
|
228
|
+
export async function attachTaskSession(options) {
|
|
229
|
+
const { client, serverName, definition } = options;
|
|
230
|
+
if (!serverAdvertisesTasks(client))
|
|
231
|
+
return undefined;
|
|
232
|
+
const protocolVersion = client.getNegotiatedProtocolVersion?.();
|
|
233
|
+
if (protocolVersion === undefined)
|
|
234
|
+
return undefined;
|
|
235
|
+
const endpointId = await createTaskSessionEndpointId("pi-mcp-adapter", {
|
|
236
|
+
server: serverName,
|
|
237
|
+
...(definition.command !== undefined
|
|
238
|
+
? { transport: { type: "stdio", command: definition.command, args: definition.args ?? [] } }
|
|
239
|
+
: definition.url !== undefined
|
|
240
|
+
? { transport: { type: "http", url: definition.url } }
|
|
241
|
+
: { transport: { type: "unix-socket", socket: definition.socket ?? null } }),
|
|
242
|
+
});
|
|
243
|
+
const onInputRequest = createApplicationInputHandler({
|
|
244
|
+
elicitation: async (request, context) => {
|
|
245
|
+
if (options.onElicitation === undefined) {
|
|
246
|
+
throw capabilityNotSupportedError(serverName, "elicitation/create", context.inputId);
|
|
247
|
+
}
|
|
248
|
+
const result = await options.onElicitation({ method: "elicitation/create", params: request.params }, context.signal);
|
|
249
|
+
return {
|
|
250
|
+
action: result.action,
|
|
251
|
+
...(result.content === undefined
|
|
252
|
+
? {}
|
|
253
|
+
: { content: result.content }),
|
|
254
|
+
};
|
|
255
|
+
},
|
|
256
|
+
sampling: async (request, context) => {
|
|
257
|
+
if (options.onSampling === undefined) {
|
|
258
|
+
throw capabilityNotSupportedError(serverName, "sampling/createMessage", context.inputId);
|
|
259
|
+
}
|
|
260
|
+
const result = await options.onSampling({ method: "sampling/createMessage", params: request.params }, context.signal);
|
|
261
|
+
return {
|
|
262
|
+
model: result.model,
|
|
263
|
+
role: result.role,
|
|
264
|
+
content: result.content,
|
|
265
|
+
};
|
|
266
|
+
},
|
|
267
|
+
roots: async () => ({ roots: [] }),
|
|
268
|
+
});
|
|
269
|
+
const channel = new RawRequestChannel(options.transport, options.requestTimeoutMs);
|
|
270
|
+
channel.attach();
|
|
271
|
+
const session = createTaskSessionFromClient(client, {
|
|
272
|
+
endpointId,
|
|
273
|
+
rawDispatch: channel.rawDispatch,
|
|
274
|
+
v2RequestFraming: {
|
|
275
|
+
protocolVersion,
|
|
276
|
+
clientInfo: options.clientInfo,
|
|
277
|
+
clientCapabilities: options.clientCapabilities,
|
|
278
|
+
},
|
|
279
|
+
// Tool declarations only add per-tool taskSupport hints; the adapter's
|
|
280
|
+
// cached tools/list is not threaded through here, and a miss is harmless.
|
|
281
|
+
tools: { currentTool: () => undefined },
|
|
282
|
+
onInputRequest,
|
|
283
|
+
onError: (error) => logger.warn(`ext-tasks background error for ${serverName}: ${String(error)}`),
|
|
284
|
+
});
|
|
285
|
+
// A downgraded session (server capability mismatch) would silently route
|
|
286
|
+
// plain tool calls through the generic request path, skipping callTool's
|
|
287
|
+
// output-schema validation. Refuse it and keep the plain path instead.
|
|
288
|
+
if (!session.capabilities.execution) {
|
|
289
|
+
await session.close().catch(() => { });
|
|
290
|
+
channel.rejectAll("Task session downgraded");
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
return { session, channel };
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Preserves error-shape parity with Client.callTool: JSON-RPC failures —
|
|
297
|
+
* immediate (JsonRpcResponseError) or terminal task errors (TaskFailedError
|
|
298
|
+
* with a code) — become the typed ProtocolError subclass for their code, so
|
|
299
|
+
* call-site handling (session recovery, URL elicitation) keeps working.
|
|
300
|
+
* Local failures rethrow their original cause instead of being relabeled.
|
|
301
|
+
*/
|
|
302
|
+
function toCallToolError(error, signal) {
|
|
303
|
+
if (error instanceof TaskCancelledError && signal?.aborted === true) {
|
|
304
|
+
return abortError(signal);
|
|
305
|
+
}
|
|
306
|
+
if (error instanceof JsonRpcResponseError) {
|
|
307
|
+
return ProtocolError.fromError(error.code, error.message, error.data);
|
|
308
|
+
}
|
|
309
|
+
if (error instanceof TaskFailedError && error.code !== undefined) {
|
|
310
|
+
return ProtocolError.fromError(error.code, error.message, error.data);
|
|
311
|
+
}
|
|
312
|
+
if (error instanceof DispatchError) {
|
|
313
|
+
return error.cause ?? error;
|
|
314
|
+
}
|
|
315
|
+
return error;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Calls a tool through a task session and blocks until settlement, preserving
|
|
319
|
+
* the plain callTool contract: an immediate result returns as-is, a
|
|
320
|
+
* task-backed execution is polled to completion, a failed task throws the
|
|
321
|
+
* underlying JSON-RPC error, and aborting cancels the remote task.
|
|
322
|
+
*/
|
|
323
|
+
export async function callToolViaTaskSession(session, options) {
|
|
324
|
+
const { signal } = options;
|
|
325
|
+
let execution;
|
|
326
|
+
try {
|
|
327
|
+
execution = await session.callTool(options.name, options.args, {
|
|
328
|
+
...(options.meta === undefined ? {} : { metadata: options.meta }),
|
|
329
|
+
...(signal === undefined ? {} : { signal }),
|
|
330
|
+
...(options.requestTimeoutMs === undefined ? {} : { requestTimeoutMs: options.requestTimeoutMs }),
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
throw toCallToolError(error, signal);
|
|
335
|
+
}
|
|
336
|
+
let onAbort;
|
|
337
|
+
if (signal !== undefined && execution.kind === "task") {
|
|
338
|
+
// settle({ signal }) only stops waiting locally; propagate the abort as a
|
|
339
|
+
// cooperative remote cancellation so the server can stop the work. The
|
|
340
|
+
// signal may have aborted while callTool was resolving, so fire directly
|
|
341
|
+
// for an abort the listener would miss.
|
|
342
|
+
onAbort = () => {
|
|
343
|
+
void execution.cancel().catch(() => { });
|
|
344
|
+
};
|
|
345
|
+
if (signal.aborted)
|
|
346
|
+
onAbort();
|
|
347
|
+
else
|
|
348
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
349
|
+
}
|
|
350
|
+
try {
|
|
351
|
+
const settlement = await execution.settle(signal === undefined ? {} : { signal });
|
|
352
|
+
const result = resultFromTaskOutcome(settlement.outcome);
|
|
353
|
+
if (!isJsonRecord(result)) {
|
|
354
|
+
throw new Error(`Task-backed tool ${options.name} settled with a non-object result`);
|
|
355
|
+
}
|
|
356
|
+
// Match Client.callTool's lifted shape, which strips the wire-only discriminator.
|
|
357
|
+
const { resultType: _resultType, ...lifted } = result;
|
|
358
|
+
return lifted;
|
|
359
|
+
}
|
|
360
|
+
catch (error) {
|
|
361
|
+
throw toCallToolError(error, signal);
|
|
362
|
+
}
|
|
363
|
+
finally {
|
|
364
|
+
if (signal !== undefined && onAbort !== undefined)
|
|
365
|
+
signal.removeEventListener("abort", onAbort);
|
|
366
|
+
await execution.close().catch(() => { });
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
//# sourceMappingURL=mcp-tasks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tasks.js","sourceRoot":"","sources":["../mcp-tasks.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,2BAA2B,EAC3B,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GAIhB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,CAAC,MAAM,kBAAkB,GAAG,+BAA+B,CAAC;AAElE,MAAM,qBAAqB,GAAG,eAAe,CAAC;AAE9C,MAAM,8BAA8B,GAAG,MAAM,CAAC;AAC9C,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAmBzC,SAAS,UAAU,CAAC,MAAmB;IACrC,OAAO,MAAM,CAAC,MAAM,YAAY,KAAK;QACnC,CAAC,CAAC,MAAM,CAAC,MAAM;QACf,CAAC,CAAC,IAAI,YAAY,CAAC,4BAA4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G,EAAE,GAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { Transport } from "@modelcontextprotocol/client";
|
|
2
|
+
import type { JSONRPCMessage } from "@modelcontextprotocol/client";
|
|
3
|
+
export declare const MCP_TRACE_SCHEMA_VERSION = 1;
|
|
4
|
+
export declare const DEFAULT_MCP_TRACE_MAX_BYTES: number;
|
|
5
|
+
export declare const DEFAULT_MCP_TRACE_MAX_EVENTS = 10000;
|
|
6
|
+
export type McpTraceDirection = "outbound" | "inbound";
|
|
7
|
+
export type McpTraceTransport = "stdio" | "unix-socket" | "sse" | "streamable-http" | "unknown";
|
|
8
|
+
export type McpTraceMessageKind = "request" | "response" | "notification";
|
|
9
|
+
export interface McpTraceSettings {
|
|
10
|
+
/** Enable metadata-only protocol tracing for all servers unless overridden. */
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
/** JSONL destination. Relative paths are resolved from the session cwd. */
|
|
13
|
+
file?: string;
|
|
14
|
+
/** Maximum bytes retained in the per-session JSONL file. */
|
|
15
|
+
maxBytes?: number;
|
|
16
|
+
/** Maximum events retained in the per-session JSONL file. */
|
|
17
|
+
maxEvents?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface McpTraceEvent {
|
|
20
|
+
version: typeof MCP_TRACE_SCHEMA_VERSION;
|
|
21
|
+
timestamp: string;
|
|
22
|
+
direction: McpTraceDirection;
|
|
23
|
+
server: string;
|
|
24
|
+
transport: McpTraceTransport;
|
|
25
|
+
kind: McpTraceMessageKind;
|
|
26
|
+
status: "sent" | "received" | "error";
|
|
27
|
+
method?: string;
|
|
28
|
+
id?: string | number | null;
|
|
29
|
+
relatedRequestId?: string | number;
|
|
30
|
+
errorCode?: number | string;
|
|
31
|
+
bytes?: number;
|
|
32
|
+
durationMs?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface McpTraceWriterOptions {
|
|
35
|
+
filePath: string;
|
|
36
|
+
maxBytes?: number;
|
|
37
|
+
maxEvents?: number;
|
|
38
|
+
appendFile?: (path: string, data: string, options: {
|
|
39
|
+
encoding: "utf8";
|
|
40
|
+
}) => Promise<void>;
|
|
41
|
+
writeFile?: (path: string, data: string, options: {
|
|
42
|
+
encoding: "utf8";
|
|
43
|
+
}) => Promise<void>;
|
|
44
|
+
mkdir?: (path: string, options: {
|
|
45
|
+
recursive: true;
|
|
46
|
+
}) => Promise<string | undefined>;
|
|
47
|
+
}
|
|
48
|
+
/** Redact strings before they can become durable trace metadata. */
|
|
49
|
+
export declare function redactTraceText(value: string, maxLength?: number): string;
|
|
50
|
+
export declare function createMcpTraceEvent(direction: McpTraceDirection, server: string, transport: McpTraceTransport, message: JSONRPCMessage, status: "sent" | "received" | "error", options?: {
|
|
51
|
+
relatedRequestId?: unknown;
|
|
52
|
+
durationMs?: number;
|
|
53
|
+
}): McpTraceEvent;
|
|
54
|
+
export declare class McpTraceWriter {
|
|
55
|
+
private readonly options;
|
|
56
|
+
private readonly maxBytes;
|
|
57
|
+
private readonly maxEvents;
|
|
58
|
+
private readonly append;
|
|
59
|
+
private readonly resetFile;
|
|
60
|
+
private readonly makeDirectory;
|
|
61
|
+
private bytesWritten;
|
|
62
|
+
private eventsWritten;
|
|
63
|
+
private queue;
|
|
64
|
+
private disabled;
|
|
65
|
+
private initializationFailed;
|
|
66
|
+
private readonly fileReady;
|
|
67
|
+
constructor(options: McpTraceWriterOptions);
|
|
68
|
+
get filePath(): string;
|
|
69
|
+
get isDisabled(): boolean;
|
|
70
|
+
get stats(): {
|
|
71
|
+
bytes: number;
|
|
72
|
+
events: number;
|
|
73
|
+
};
|
|
74
|
+
write(event: McpTraceEvent): void;
|
|
75
|
+
flush(): Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
export declare function createMcpTraceWriter(sessionCwd: string | undefined, settings?: McpTraceSettings, randomSuffix?: string): McpTraceWriter;
|
|
78
|
+
export interface McpTraceObserver {
|
|
79
|
+
record(event: McpTraceEvent): void;
|
|
80
|
+
}
|
|
81
|
+
export declare function isMcpTraceEnabled(definition: {
|
|
82
|
+
trace?: boolean;
|
|
83
|
+
}, settings?: McpTraceSettings): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Compose the SDK's transport callbacks in place instead of replacing the
|
|
86
|
+
* transport object. SDK v2 detects its base stdio transport before connect so
|
|
87
|
+
* it can run `server/discover` on a disposable sibling process; returning a
|
|
88
|
+
* wrapper hides that identity and makes tracing change negotiation behavior.
|
|
89
|
+
*/
|
|
90
|
+
export declare function wrapTransportWithMcpTrace(transport: Transport, server: string, transportKind: McpTraceTransport, observer: McpTraceObserver): Transport;
|
|
91
|
+
export declare function traceTransportKind(definition: {
|
|
92
|
+
command?: string;
|
|
93
|
+
url?: string;
|
|
94
|
+
socket?: string;
|
|
95
|
+
}, transport: Transport): McpTraceTransport;
|