@agimon-ai/po-cloudflare 0.0.2-alpha.13 → 0.0.2-alpha.14
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/dist/{agent-DYFqCLl2.js → agent-DTjnYFAN.js} +1 -1
- package/dist/{apiContracts-CDJ9sPkE.js → apiContracts-DepyzMNr.js} +80 -80
- package/dist/{approval-BSX-MRTE.js → approval-Biq3NCWj.js} +2 -2
- package/dist/{approvalPrompt-1FPgNwMA.js → approvalPrompt-DoHlIPkU.js} +2 -2
- package/dist/assets/plugins/compositions.json +1 -1
- package/dist/{atomicJson-BF1fVXy1.js → atomicJson-DCIsEywH.js} +3 -3
- package/dist/{backgroundWork-BaczP3Z1.js → backgroundWork-Bswjs1av.js} +1 -1
- package/dist/{codemode-CZ_eYTwm.js → codemode-CgVosRtU.js} +1 -1
- package/dist/{contracts-CnRs-Twx.js → contracts-CylyLZC8.js} +1 -1
- package/dist/{domains-Bl6T2dKV.js → domains-BqChtBLN.js} +23 -5
- package/dist/{exports-DlcCEAe3.js → exports-DERO0cQf.js} +760 -147
- package/dist/{exports-CxkWsXI9.js → exports-DX8LJfSj.js} +9 -9
- package/dist/{extensionFile-D7wk8tFr.js → extensionFile-Ds7RCpnb.js} +1 -1
- package/dist/{harnessStore-flLz1I0F.js → harnessStore-BectazJQ.js} +4 -4
- package/dist/harnessStore-C0Zwvny8.js +1 -0
- package/dist/{help-DjybmnPW.js → help-Dpm82qDr.js} +2 -2
- package/dist/{hubChannel-Bi3PQrfD.js → hubChannel-COvmdWGO.js} +4 -2
- package/dist/{index.edge-CJ2TFpgF.js → index.edge-B0D_Lgbx.js} +2 -2
- package/dist/{index.edge-C9_xuXyy.js → index.edge-BLmsRNW8.js} +2 -2
- package/dist/{layeredConfig-B4s0eZ5o.js → layeredConfig-pQGjhAks.js} +92 -6
- package/dist/{majorModes-IygGmbb8.js → majorModes-BrL4EtzH.js} +5 -14
- package/dist/majorModes-WXt22_km.js +1 -0
- package/dist/{mcpProjection-BA6baFpi.js → mcpProjection-pbPBBuvs.js} +2 -2
- package/dist/{notification-bGq1frYG.js → notification-CINsJWDL.js} +7 -4
- package/dist/{piConfig-CcoMX-1L.js → piConfig-BDUpA6w0.js} +5 -5
- package/dist/piSettings-tdui0CZI.js +1 -0
- package/dist/{platform-CyvF7X-b.js → platform-yhQXrrM_.js} +1 -1
- package/dist/{platformFiles-Ccj9HCvA.js → platformFiles-DB3Cw1l_.js} +1 -1
- package/dist/{protocol-Q7TFrOIs.js → protocol-B6LbEIe6.js} +2 -2
- package/dist/{server-4CmqIbH2.js → server-2o-hl3o0.js} +55 -14
- package/dist/{server-DSu_uLDX.js → server-B-br6deK.js} +6 -6
- package/dist/{server-C9gff7gU.js → server-B2G-c0hg.js} +5 -5
- package/dist/{server-CIhwIcbA.js → server-B3RgnYiZ.js} +13 -4
- package/dist/{server-C8HyW7wN.js → server-BBNCtQtl.js} +7 -7
- package/dist/{server-C_34VM3M.js → server-BmIU37Ei.js} +3 -3
- package/dist/{server-ClsNJwdv.js → server-Bqm5R8kV.js} +13 -13
- package/dist/{server-Co57A8MH.js → server-Bt6Zsqo8.js} +2 -2
- package/dist/{server-il_s2Ycz.js → server-BvYolSs9.js} +339 -43
- package/dist/{server-CpJNq249.js → server-C1x2LoKK.js} +10 -10
- package/dist/{server-CjsKNdSN.js → server-CCwwnpH0.js} +5 -5
- package/dist/{server-CxGGQFJs.js → server-CRPxNGv6.js} +6 -6
- package/dist/{server-COE7BKSa.js → server-Ci_BGVwd.js} +3 -3
- package/dist/{server-CTSvwoDy.js → server-CyYesT-G.js} +9 -9
- package/dist/{server-ziNfBZ2M.js → server-CzJjYgVk.js} +3 -3
- package/dist/{server-C_3jK2WM.js → server-D9qM5XCP.js} +23 -11
- package/dist/{server-C82Qzoh3.js → server-DE3Gzgfb.js} +10 -10
- package/dist/{server-CMaTba5B.js → server-DL6UyXfJ.js} +8 -8
- package/dist/{server-5vLvBTTs.js → server-DPTp6GXS.js} +4 -4
- package/dist/{server-CcNMwEFQ.js → server-Dgn4el5K.js} +5 -5
- package/dist/{server-CQXqMpeC.js → server-DuDp9MhD.js} +116 -54
- package/dist/{server-DeSuziRK.js → server-OerXqXJT.js} +4 -4
- package/dist/{server-ZsazKk-n.js → server-V8W5mcGu.js} +6 -6
- package/dist/{server-Bm6pAAw8.js → server-_0288DYR.js} +4 -4
- package/dist/{server-BHhb0oir.js → server-cStfn1Yv.js} +4 -4
- package/dist/{serverPlugin-pCqlBqQG.js → serverPlugin-OOfjB8tm.js} +1114 -1111
- package/dist/{sessionConfig-DzAs6Pt-.js → sessionConfig-C-zJI72k.js} +242 -54
- package/dist/{validation-CkjZwpf-.js → validation-DuOGOKEi.js} +2 -2
- package/dist/{value-DGT5IoiK.js → value-DyVsxCwZ.js} +1 -1
- package/dist/{vaultSettings-BRr8n821.js → vaultSettings-BFCRCBM3.js} +1 -1
- package/dist/web-cN41ySs9.js +3 -0
- package/dist/worker.js +15822 -1103
- package/dist/workflow-BgwWq0nq.js +79 -0
- package/package.json +32 -32
- package/dist/contextProjection-DlB6wzhm.js +0 -209
- package/dist/harnessStore-Bap8lsAg.js +0 -1
- package/dist/majorModes-xpLK9HpD.js +0 -1
- package/dist/piSettings-B6fsgIBA.js +0 -1
- package/dist/web-Cfvbn9H1.js +0 -3
- package/dist/workflow-w5JPZXgc.js +0 -23
- /package/dist/assets/plugins/slots/{approval.8b3f37d9-CqQk6XG_.js → approval.293d9a00-CqQk6XG_.js} +0 -0
- /package/dist/assets/plugins/slots/{artifacts.47d00f81-D-vQ-7Iz.js → artifacts.24567664-D-vQ-7Iz.js} +0 -0
- /package/dist/assets/plugins/slots/{autocompact.9a92993d-B3KTYwW1.js → autocompact.dd97d013-B3KTYwW1.js} +0 -0
- /package/dist/assets/plugins/slots/{builtin-tools.939bbfff-CZRYQVIP.js → builtin-tools.36d7400b-CZRYQVIP.js} +0 -0
- /package/dist/assets/plugins/slots/{codemode.782e5bb1-Bzl_K_vt.js → codemode.8eaee717-Bzl_K_vt.js} +0 -0
- /package/dist/assets/plugins/slots/{domain.21790b66-CvnpuKCY.js → domain.5e95fc37-CvnpuKCY.js} +0 -0
- /package/dist/assets/plugins/slots/{edit.c7c85129-kaxIknZ-.js → edit.385c9aa9-kaxIknZ-.js} +0 -0
- /package/dist/assets/plugins/slots/{files.bbcef824-wuB8gcQA.js → files.daf34ed8-wuB8gcQA.js} +0 -0
- /package/dist/assets/plugins/slots/{grep.3dfd3214-3FnU8p-d.js → grep.02052cdc-3FnU8p-d.js} +0 -0
- /package/dist/assets/plugins/slots/{log.33bc7d38-C0PXQ0O1.js → log.a86eb6d0-C0PXQ0O1.js} +0 -0
- /package/dist/assets/plugins/slots/{mcp.59c68bcb-D0CkHnIw.js → mcp.974af249-D0CkHnIw.js} +0 -0
- /package/dist/assets/plugins/slots/{profile.ea55f5e1-BSY3iYfJ.js → profile.48851a1d-BSY3iYfJ.js} +0 -0
- /package/dist/assets/plugins/slots/{prompts.9957cc84-xdCkNkoA.js → prompts.723d7748-xdCkNkoA.js} +0 -0
- /package/dist/assets/plugins/slots/{read.30a617e7-qqaxVlEX.js → read.46bf6536-qqaxVlEX.js} +0 -0
- /package/dist/assets/plugins/slots/{runner.9f3559b0-DfO2Z9HG.js → runner.53e9bd76-DfO2Z9HG.js} +0 -0
- /package/dist/assets/plugins/slots/{skill.f506a5ea-CL_n-l4h.js → skill.086701a4-CL_n-l4h.js} +0 -0
- /package/dist/assets/plugins/slots/{vault.01657352-DbG3F_on.js → vault.ac9935c8-DbG3F_on.js} +0 -0
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { Bn as BACKGROUND_CONTEXT, pn as poHomeDirectory, rr as defineServiceContract } from "./serverPlugin-OOfjB8tm.js";
|
|
2
|
+
import { i as readTextIfExists, s as writeFileAtomic } from "./platformFiles-DB3Cw1l_.js";
|
|
3
|
+
import "./platform-yhQXrrM_.js";
|
|
4
|
+
import "./piSettings-tdui0CZI.js";
|
|
5
|
+
import { n as Check } from "./value-DyVsxCwZ.js";
|
|
6
|
+
import { A as string$1, C as looseObject, D as preprocess, E as optional, F as safeParse, I as toJSONSchema, L as _coercedBoolean, M as unknown, N as url, O as record$2, R as _coercedNumber, S as literal, T as object, U as NEVER, _ as intersection, c as _enum, d as any, f as array, g as email, h as discriminatedUnion, i as ZodNumber, j as union, l as _null, p as boolean$1, s as ZodString, t as ZodBoolean, w as number$1, x as lazy, z as _coercedString } from "./schemas-Vj8-rCR4.js";
|
|
4
7
|
import { n as datetime, t as date$1 } from "./iso-BPQViXM8.js";
|
|
5
|
-
import {
|
|
8
|
+
import { r as PO_USER_MCP_CONFIG_FILE } from "./mcpProjection-pbPBBuvs.js";
|
|
9
|
+
import { a as assertRevision, i as assertEntryName, l as VAULT_ACCOUNT_OPERATIONS, n as VaultError, o as serializeValue } from "./vaultSettings-BFCRCBM3.js";
|
|
6
10
|
import { createHash } from "node:crypto";
|
|
7
|
-
import "node:path";
|
|
11
|
+
import { join } from "node:path";
|
|
8
12
|
//#region ../../core/po-web-security/src/services/outboundHost/index.ts
|
|
9
13
|
/** Cloud metadata endpoints reachable by name. Their IP forms are refused as IP literals. */
|
|
10
14
|
const METADATA_HOSTS = /* @__PURE__ */ new Set([
|
|
@@ -98,69 +102,6 @@ function guardedFetch(options) {
|
|
|
98
102
|
};
|
|
99
103
|
}
|
|
100
104
|
//#endregion
|
|
101
|
-
//#region ../../../node_modules/.pnpm/@modelcontextprotocol+client@2.3.1/node_modules/@modelcontextprotocol/client/dist/chunk-Br0eD_fh.mjs
|
|
102
|
-
var __create = Object.create;
|
|
103
|
-
var __defProp = Object.defineProperty;
|
|
104
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
105
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
106
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
107
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
108
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
109
|
-
var __exportAll = (all, symbols) => {
|
|
110
|
-
let target = {};
|
|
111
|
-
for (var name in all) __defProp(target, name, {
|
|
112
|
-
get: all[name],
|
|
113
|
-
enumerable: true
|
|
114
|
-
});
|
|
115
|
-
if (symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
116
|
-
return target;
|
|
117
|
-
};
|
|
118
|
-
var __copyProps = (to, from, except, desc) => {
|
|
119
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
120
|
-
key = keys[i];
|
|
121
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
122
|
-
get: ((k) => from[k]).bind(null, key),
|
|
123
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
return to;
|
|
127
|
-
};
|
|
128
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
129
|
-
value: mod,
|
|
130
|
-
enumerable: true
|
|
131
|
-
}) : target, mod));
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region ../../../node_modules/.pnpm/@modelcontextprotocol+client@2.3.1/node_modules/@modelcontextprotocol/client/dist/dialects-BOhdv1Fc.mjs
|
|
134
|
-
/**
|
|
135
|
-
* Canonical `$schema` URIs per supported dialect (http + https variants, trailing-`#` stripped).
|
|
136
|
-
*/
|
|
137
|
-
const DRAFT_2020_12_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2020-12/schema", "http://json-schema.org/draft/2020-12/schema"]);
|
|
138
|
-
const DRAFT_2019_09_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2019-09/schema", "http://json-schema.org/draft/2019-09/schema"]);
|
|
139
|
-
const DRAFT_07_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft-07/schema", "http://json-schema.org/draft-07/schema"]);
|
|
140
|
-
const DRAFT_06_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft-06/schema", "http://json-schema.org/draft-06/schema"]);
|
|
141
|
-
/**
|
|
142
|
-
* Whether a `$schema` value declares the 2019-09 dialect — the only supported dialect with
|
|
143
|
-
* `$recursiveRef`/`$recursiveAnchor`. Non-throwing (unlike {@linkcode declaredDialect}) so
|
|
144
|
-
* wire-layer callers can consult it for documents whose dialect may be unsupported.
|
|
145
|
-
*/
|
|
146
|
-
function declares2019Dialect($schema) {
|
|
147
|
-
return typeof $schema === "string" && DRAFT_2019_09_URIS.has($schema.replace(/#$/, ""));
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Classify a schema's declared `$schema` dialect. No `$schema` (or a non-string one) means
|
|
151
|
-
* 2020-12. Any other dialect throws a plain `Error` with a clear message rather than letting the
|
|
152
|
-
* engine crash on an opaque internal error or silently mis-validate; `remedy` names the calling
|
|
153
|
-
* provider's escape hatch in that message.
|
|
154
|
-
*/
|
|
155
|
-
function declaredDialect(schema, remedy) {
|
|
156
|
-
if (!("$schema" in schema) || typeof schema.$schema !== "string") return "2020-12";
|
|
157
|
-
const declared = schema.$schema.replace(/#$/, "");
|
|
158
|
-
if (DRAFT_2020_12_URIS.has(declared)) return "2020-12";
|
|
159
|
-
if (DRAFT_2019_09_URIS.has(declared)) return "2019-09";
|
|
160
|
-
if (DRAFT_07_URIS.has(declared) || DRAFT_06_URIS.has(declared)) return "draft-7";
|
|
161
|
-
throw new Error(`JSON Schema declares an unsupported dialect ("$schema": "${schema.$schema.slice(0, 200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${remedy}`);
|
|
162
|
-
}
|
|
163
|
-
//#endregion
|
|
164
105
|
//#region ../../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/compat.js
|
|
165
106
|
/** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
|
|
166
107
|
const ZodIssueCode = {
|
|
@@ -193,6 +134,7 @@ function boolean(params) {
|
|
|
193
134
|
//#endregion
|
|
194
135
|
//#region ../../../node_modules/.pnpm/@modelcontextprotocol+core@2.3.1/node_modules/@modelcontextprotocol/core/dist/auth-BNDyLTqp.mjs
|
|
195
136
|
const LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
137
|
+
const DEFAULT_NEGOTIATED_PROTOCOL_VERSION = "2025-03-26";
|
|
196
138
|
const SUPPORTED_PROTOCOL_VERSIONS = [
|
|
197
139
|
LATEST_PROTOCOL_VERSION,
|
|
198
140
|
"2025-06-18",
|
|
@@ -262,10 +204,10 @@ const JSONValueSchema = lazy(() => union([
|
|
|
262
204
|
number$1(),
|
|
263
205
|
boolean$1(),
|
|
264
206
|
_null(),
|
|
265
|
-
record$
|
|
207
|
+
record$2(string$1(), JSONValueSchema),
|
|
266
208
|
array(JSONValueSchema)
|
|
267
209
|
]));
|
|
268
|
-
const JSONObjectSchema = record$
|
|
210
|
+
const JSONObjectSchema = record$2(string$1(), JSONValueSchema);
|
|
269
211
|
const JSONArraySchema = array(JSONValueSchema);
|
|
270
212
|
/**
|
|
271
213
|
* A progress token, used to associate progress notifications with the original request.
|
|
@@ -453,7 +395,7 @@ const ServerTasksCapabilitySchema = looseObject({
|
|
|
453
395
|
* Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities.
|
|
454
396
|
*/
|
|
455
397
|
const ClientCapabilitiesSchema = object({
|
|
456
|
-
experimental: record$
|
|
398
|
+
experimental: record$2(string$1(), JSONObjectSchema).optional(),
|
|
457
399
|
sampling: object({
|
|
458
400
|
context: JSONObjectSchema.optional(),
|
|
459
401
|
tools: JSONObjectSchema.optional()
|
|
@@ -461,7 +403,7 @@ const ClientCapabilitiesSchema = object({
|
|
|
461
403
|
elicitation: ElicitationCapabilitySchema.optional(),
|
|
462
404
|
roots: object({ listChanged: boolean$1().optional() }).optional(),
|
|
463
405
|
tasks: ClientTasksCapabilitySchema.optional(),
|
|
464
|
-
extensions: record$
|
|
406
|
+
extensions: record$2(string$1(), JSONObjectSchema).optional()
|
|
465
407
|
});
|
|
466
408
|
const InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
467
409
|
protocolVersion: string$1(),
|
|
@@ -479,7 +421,7 @@ const InitializeRequestSchema = RequestSchema.extend({
|
|
|
479
421
|
* Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities.
|
|
480
422
|
*/
|
|
481
423
|
const ServerCapabilitiesSchema = object({
|
|
482
|
-
experimental: record$
|
|
424
|
+
experimental: record$2(string$1(), JSONObjectSchema).optional(),
|
|
483
425
|
logging: JSONObjectSchema.optional(),
|
|
484
426
|
completions: JSONObjectSchema.optional(),
|
|
485
427
|
prompts: object({ listChanged: boolean$1().optional() }).optional(),
|
|
@@ -489,7 +431,7 @@ const ServerCapabilitiesSchema = object({
|
|
|
489
431
|
}).optional(),
|
|
490
432
|
tools: object({ listChanged: boolean$1().optional() }).optional(),
|
|
491
433
|
tasks: ServerTasksCapabilitySchema.optional(),
|
|
492
|
-
extensions: record$
|
|
434
|
+
extensions: record$2(string$1(), JSONObjectSchema).optional()
|
|
493
435
|
});
|
|
494
436
|
/**
|
|
495
437
|
* After receiving an initialize request from the client, the server sends this response.
|
|
@@ -560,7 +502,7 @@ const PaginatedResultSchema = ResultSchema.extend({ nextCursor: CursorSchema.opt
|
|
|
560
502
|
const ResourceContentsSchema = object({
|
|
561
503
|
uri: string$1(),
|
|
562
504
|
mimeType: optional(string$1()),
|
|
563
|
-
_meta: record$
|
|
505
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
564
506
|
});
|
|
565
507
|
const TextResourceContentsSchema = ResourceContentsSchema.extend({ text: string$1() });
|
|
566
508
|
/**
|
|
@@ -758,7 +700,7 @@ const ListPromptsResultSchema = PaginatedResultSchema.extend({ prompts: array(Pr
|
|
|
758
700
|
*/
|
|
759
701
|
const GetPromptRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
760
702
|
name: string$1(),
|
|
761
|
-
arguments: record$
|
|
703
|
+
arguments: record$2(string$1(), string$1()).optional()
|
|
762
704
|
});
|
|
763
705
|
/**
|
|
764
706
|
* Used by the client to get a prompt provided by the server.
|
|
@@ -774,7 +716,7 @@ const TextContentSchema = object({
|
|
|
774
716
|
type: literal("text"),
|
|
775
717
|
text: string$1(),
|
|
776
718
|
annotations: AnnotationsSchema.optional(),
|
|
777
|
-
_meta: record$
|
|
719
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
778
720
|
});
|
|
779
721
|
/**
|
|
780
722
|
* An image provided to or from an LLM.
|
|
@@ -784,7 +726,7 @@ const ImageContentSchema = object({
|
|
|
784
726
|
data: Base64Schema,
|
|
785
727
|
mimeType: string$1(),
|
|
786
728
|
annotations: AnnotationsSchema.optional(),
|
|
787
|
-
_meta: record$
|
|
729
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
788
730
|
});
|
|
789
731
|
/**
|
|
790
732
|
* Audio content provided to or from an LLM.
|
|
@@ -794,7 +736,7 @@ const AudioContentSchema = object({
|
|
|
794
736
|
data: Base64Schema,
|
|
795
737
|
mimeType: string$1(),
|
|
796
738
|
annotations: AnnotationsSchema.optional(),
|
|
797
|
-
_meta: record$
|
|
739
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
798
740
|
});
|
|
799
741
|
/**
|
|
800
742
|
* A tool call request from an assistant (LLM).
|
|
@@ -808,8 +750,8 @@ const ToolUseContentSchema = object({
|
|
|
808
750
|
type: literal("tool_use"),
|
|
809
751
|
name: string$1(),
|
|
810
752
|
id: string$1(),
|
|
811
|
-
input: record$
|
|
812
|
-
_meta: record$
|
|
753
|
+
input: record$2(string$1(), unknown()),
|
|
754
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
813
755
|
});
|
|
814
756
|
/**
|
|
815
757
|
* The contents of a resource, embedded into a prompt or tool call result.
|
|
@@ -818,7 +760,7 @@ const EmbeddedResourceSchema = object({
|
|
|
818
760
|
type: literal("resource"),
|
|
819
761
|
resource: union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
820
762
|
annotations: AnnotationsSchema.optional(),
|
|
821
|
-
_meta: record$
|
|
763
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
822
764
|
});
|
|
823
765
|
/**
|
|
824
766
|
* A resource that the server is capable of reading, included in a prompt or tool call result.
|
|
@@ -891,13 +833,13 @@ const ToolSchema = object({
|
|
|
891
833
|
description: string$1().optional(),
|
|
892
834
|
inputSchema: object({
|
|
893
835
|
type: literal("object"),
|
|
894
|
-
properties: record$
|
|
836
|
+
properties: record$2(string$1(), JSONValueSchema).optional(),
|
|
895
837
|
required: array(string$1()).optional()
|
|
896
838
|
}).catchall(unknown()),
|
|
897
839
|
outputSchema: looseObject({ $schema: string$1().optional() }).optional(),
|
|
898
840
|
annotations: ToolAnnotationsSchema.optional(),
|
|
899
841
|
execution: ToolExecutionSchema.optional(),
|
|
900
|
-
_meta: record$
|
|
842
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
901
843
|
});
|
|
902
844
|
/**
|
|
903
845
|
* Sent from the client to request a list of tools the server has.
|
|
@@ -924,7 +866,7 @@ const CompatibilityCallToolResultSchema = CallToolResultSchema.or(ResultSchema.e
|
|
|
924
866
|
*/
|
|
925
867
|
const CallToolRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
926
868
|
name: string$1(),
|
|
927
|
-
arguments: record$
|
|
869
|
+
arguments: record$2(string$1(), unknown()).optional()
|
|
928
870
|
});
|
|
929
871
|
/**
|
|
930
872
|
* Used by the client to invoke a tool provided by the server.
|
|
@@ -1054,7 +996,7 @@ const ToolResultContentSchema = object({
|
|
|
1054
996
|
content: array(ContentBlockSchema),
|
|
1055
997
|
structuredContent: unknown().optional(),
|
|
1056
998
|
isError: boolean$1().optional(),
|
|
1057
|
-
_meta: record$
|
|
999
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
1058
1000
|
});
|
|
1059
1001
|
/**
|
|
1060
1002
|
* Basic content types for sampling responses (without tool use).
|
|
@@ -1094,7 +1036,7 @@ const SamplingMessageContentBlockSchema = discriminatedUnion("type", [
|
|
|
1094
1036
|
const SamplingMessageSchema = object({
|
|
1095
1037
|
role: RoleSchema,
|
|
1096
1038
|
content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)]),
|
|
1097
|
-
_meta: record$
|
|
1039
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
1098
1040
|
});
|
|
1099
1041
|
/**
|
|
1100
1042
|
* Parameters for a `sampling/createMessage` request.
|
|
@@ -1300,7 +1242,7 @@ const ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
|
1300
1242
|
message: string$1(),
|
|
1301
1243
|
requestedSchema: object({
|
|
1302
1244
|
type: literal("object"),
|
|
1303
|
-
properties: record$
|
|
1245
|
+
properties: record$2(string$1(), PrimitiveSchemaDefinitionSchema),
|
|
1304
1246
|
required: array(string$1()).optional()
|
|
1305
1247
|
}).catchall(unknown())
|
|
1306
1248
|
});
|
|
@@ -1358,7 +1300,7 @@ const ElicitResultSchema = ResultSchema.extend({
|
|
|
1358
1300
|
"decline",
|
|
1359
1301
|
"cancel"
|
|
1360
1302
|
]),
|
|
1361
|
-
content: preprocess((val) => val === null ? void 0 : val, record$
|
|
1303
|
+
content: preprocess((val) => val === null ? void 0 : val, record$2(string$1(), union([
|
|
1362
1304
|
string$1(),
|
|
1363
1305
|
number$1(),
|
|
1364
1306
|
boolean$1(),
|
|
@@ -1388,7 +1330,7 @@ const CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
1388
1330
|
name: string$1(),
|
|
1389
1331
|
value: string$1()
|
|
1390
1332
|
}),
|
|
1391
|
-
context: object({ arguments: record$
|
|
1333
|
+
context: object({ arguments: record$2(string$1(), string$1()).optional() }).optional()
|
|
1392
1334
|
});
|
|
1393
1335
|
/**
|
|
1394
1336
|
* A request from the client to the server, to ask for completion options.
|
|
@@ -1415,7 +1357,7 @@ const CompleteResultSchema = ResultSchema.extend({ completion: looseObject({
|
|
|
1415
1357
|
const RootSchema = object({
|
|
1416
1358
|
uri: string$1().startsWith("file://"),
|
|
1417
1359
|
name: string$1().optional(),
|
|
1418
|
-
_meta: record$
|
|
1360
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
1419
1361
|
});
|
|
1420
1362
|
/**
|
|
1421
1363
|
* Sent from the server to request a list of root URIs from the client.
|
|
@@ -1827,6 +1769,69 @@ const OAuthTokenRevocationRequestSchema = object({
|
|
|
1827
1769
|
token_type_hint: string$1().optional()
|
|
1828
1770
|
}).strip();
|
|
1829
1771
|
//#endregion
|
|
1772
|
+
//#region ../../../node_modules/.pnpm/@modelcontextprotocol+client@2.3.1/node_modules/@modelcontextprotocol/client/dist/chunk-Br0eD_fh.mjs
|
|
1773
|
+
var __create = Object.create;
|
|
1774
|
+
var __defProp = Object.defineProperty;
|
|
1775
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
1776
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
1777
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
1778
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1779
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
1780
|
+
var __exportAll = (all, symbols) => {
|
|
1781
|
+
let target = {};
|
|
1782
|
+
for (var name in all) __defProp(target, name, {
|
|
1783
|
+
get: all[name],
|
|
1784
|
+
enumerable: true
|
|
1785
|
+
});
|
|
1786
|
+
if (symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
1787
|
+
return target;
|
|
1788
|
+
};
|
|
1789
|
+
var __copyProps = (to, from, except, desc) => {
|
|
1790
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
1791
|
+
key = keys[i];
|
|
1792
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
1793
|
+
get: ((k) => from[k]).bind(null, key),
|
|
1794
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
return to;
|
|
1798
|
+
};
|
|
1799
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
1800
|
+
value: mod,
|
|
1801
|
+
enumerable: true
|
|
1802
|
+
}) : target, mod));
|
|
1803
|
+
//#endregion
|
|
1804
|
+
//#region ../../../node_modules/.pnpm/@modelcontextprotocol+client@2.3.1/node_modules/@modelcontextprotocol/client/dist/dialects-BOhdv1Fc.mjs
|
|
1805
|
+
/**
|
|
1806
|
+
* Canonical `$schema` URIs per supported dialect (http + https variants, trailing-`#` stripped).
|
|
1807
|
+
*/
|
|
1808
|
+
const DRAFT_2020_12_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2020-12/schema", "http://json-schema.org/draft/2020-12/schema"]);
|
|
1809
|
+
const DRAFT_2019_09_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2019-09/schema", "http://json-schema.org/draft/2019-09/schema"]);
|
|
1810
|
+
const DRAFT_07_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft-07/schema", "http://json-schema.org/draft-07/schema"]);
|
|
1811
|
+
const DRAFT_06_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft-06/schema", "http://json-schema.org/draft-06/schema"]);
|
|
1812
|
+
/**
|
|
1813
|
+
* Whether a `$schema` value declares the 2019-09 dialect — the only supported dialect with
|
|
1814
|
+
* `$recursiveRef`/`$recursiveAnchor`. Non-throwing (unlike {@linkcode declaredDialect}) so
|
|
1815
|
+
* wire-layer callers can consult it for documents whose dialect may be unsupported.
|
|
1816
|
+
*/
|
|
1817
|
+
function declares2019Dialect($schema) {
|
|
1818
|
+
return typeof $schema === "string" && DRAFT_2019_09_URIS.has($schema.replace(/#$/, ""));
|
|
1819
|
+
}
|
|
1820
|
+
/**
|
|
1821
|
+
* Classify a schema's declared `$schema` dialect. No `$schema` (or a non-string one) means
|
|
1822
|
+
* 2020-12. Any other dialect throws a plain `Error` with a clear message rather than letting the
|
|
1823
|
+
* engine crash on an opaque internal error or silently mis-validate; `remedy` names the calling
|
|
1824
|
+
* provider's escape hatch in that message.
|
|
1825
|
+
*/
|
|
1826
|
+
function declaredDialect(schema, remedy) {
|
|
1827
|
+
if (!("$schema" in schema) || typeof schema.$schema !== "string") return "2020-12";
|
|
1828
|
+
const declared = schema.$schema.replace(/#$/, "");
|
|
1829
|
+
if (DRAFT_2020_12_URIS.has(declared)) return "2020-12";
|
|
1830
|
+
if (DRAFT_2019_09_URIS.has(declared)) return "2019-09";
|
|
1831
|
+
if (DRAFT_07_URIS.has(declared) || DRAFT_06_URIS.has(declared)) return "draft-7";
|
|
1832
|
+
throw new Error(`JSON Schema declares an unsupported dialect ("$schema": "${schema.$schema.slice(0, 200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${remedy}`);
|
|
1833
|
+
}
|
|
1834
|
+
//#endregion
|
|
1830
1835
|
//#region ../../../node_modules/.pnpm/@modelcontextprotocol+client@2.3.1/node_modules/@modelcontextprotocol/client/dist/src-WCy6ifGf.mjs
|
|
1831
1836
|
/**
|
|
1832
1837
|
* Cross-bundle `instanceof` support for the SDK error classes.
|
|
@@ -2383,10 +2388,10 @@ function build$1() {
|
|
|
2383
2388
|
number$1(),
|
|
2384
2389
|
boolean$1(),
|
|
2385
2390
|
_null(),
|
|
2386
|
-
record$
|
|
2391
|
+
record$2(string$1(), JSONValueSchema$1),
|
|
2387
2392
|
array(JSONValueSchema$1)
|
|
2388
2393
|
]));
|
|
2389
|
-
const JSONObjectSchema$1 = record$
|
|
2394
|
+
const JSONObjectSchema$1 = record$2(string$1(), JSONValueSchema$1);
|
|
2390
2395
|
/**
|
|
2391
2396
|
* A progress token, used to associate progress notifications with the original request.
|
|
2392
2397
|
*/
|
|
@@ -2519,7 +2524,7 @@ function build$1() {
|
|
|
2519
2524
|
* Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities.
|
|
2520
2525
|
*/
|
|
2521
2526
|
const ClientCapabilitiesSchema$1 = object({
|
|
2522
|
-
experimental: record$
|
|
2527
|
+
experimental: record$2(string$1(), JSONObjectSchema$1).optional(),
|
|
2523
2528
|
sampling: object({
|
|
2524
2529
|
context: JSONObjectSchema$1.optional(),
|
|
2525
2530
|
tools: JSONObjectSchema$1.optional()
|
|
@@ -2527,7 +2532,7 @@ function build$1() {
|
|
|
2527
2532
|
elicitation: ElicitationCapabilitySchema.optional(),
|
|
2528
2533
|
roots: object({ listChanged: boolean$1().optional() }).optional(),
|
|
2529
2534
|
tasks: ClientTasksCapabilitySchema$1.optional(),
|
|
2530
|
-
extensions: record$
|
|
2535
|
+
extensions: record$2(string$1(), JSONObjectSchema$1).optional()
|
|
2531
2536
|
});
|
|
2532
2537
|
const InitializeRequestParamsSchema$1 = BaseRequestParamsSchema$1.extend({
|
|
2533
2538
|
protocolVersion: string$1(),
|
|
@@ -2545,7 +2550,7 @@ function build$1() {
|
|
|
2545
2550
|
* Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities.
|
|
2546
2551
|
*/
|
|
2547
2552
|
const ServerCapabilitiesSchema$1 = object({
|
|
2548
|
-
experimental: record$
|
|
2553
|
+
experimental: record$2(string$1(), JSONObjectSchema$1).optional(),
|
|
2549
2554
|
logging: JSONObjectSchema$1.optional(),
|
|
2550
2555
|
completions: JSONObjectSchema$1.optional(),
|
|
2551
2556
|
prompts: object({ listChanged: boolean$1().optional() }).optional(),
|
|
@@ -2555,7 +2560,7 @@ function build$1() {
|
|
|
2555
2560
|
}).optional(),
|
|
2556
2561
|
tools: object({ listChanged: boolean$1().optional() }).optional(),
|
|
2557
2562
|
tasks: ServerTasksCapabilitySchema$1.optional(),
|
|
2558
|
-
extensions: record$
|
|
2563
|
+
extensions: record$2(string$1(), JSONObjectSchema$1).optional()
|
|
2559
2564
|
});
|
|
2560
2565
|
/**
|
|
2561
2566
|
* After receiving an initialize request from the client, the server sends this response.
|
|
@@ -2608,7 +2613,7 @@ function build$1() {
|
|
|
2608
2613
|
const ResourceContentsSchema$1 = object({
|
|
2609
2614
|
uri: string$1(),
|
|
2610
2615
|
mimeType: optional(string$1()),
|
|
2611
|
-
_meta: record$
|
|
2616
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
2612
2617
|
});
|
|
2613
2618
|
const TextResourceContentsSchema$1 = ResourceContentsSchema$1.extend({ text: string$1() });
|
|
2614
2619
|
/**
|
|
@@ -2759,7 +2764,7 @@ function build$1() {
|
|
|
2759
2764
|
*/
|
|
2760
2765
|
const GetPromptRequestParamsSchema$1 = BaseRequestParamsSchema$1.extend({
|
|
2761
2766
|
name: string$1(),
|
|
2762
|
-
arguments: record$
|
|
2767
|
+
arguments: record$2(string$1(), string$1()).optional()
|
|
2763
2768
|
});
|
|
2764
2769
|
/**
|
|
2765
2770
|
* Used by the client to get a prompt provided by the server.
|
|
@@ -2775,7 +2780,7 @@ function build$1() {
|
|
|
2775
2780
|
type: literal("text"),
|
|
2776
2781
|
text: string$1(),
|
|
2777
2782
|
annotations: AnnotationsSchema$1.optional(),
|
|
2778
|
-
_meta: record$
|
|
2783
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
2779
2784
|
});
|
|
2780
2785
|
/**
|
|
2781
2786
|
* An image provided to or from an LLM.
|
|
@@ -2785,7 +2790,7 @@ function build$1() {
|
|
|
2785
2790
|
data: Base64Schema,
|
|
2786
2791
|
mimeType: string$1(),
|
|
2787
2792
|
annotations: AnnotationsSchema$1.optional(),
|
|
2788
|
-
_meta: record$
|
|
2793
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
2789
2794
|
});
|
|
2790
2795
|
/**
|
|
2791
2796
|
* Audio content provided to or from an LLM.
|
|
@@ -2795,7 +2800,7 @@ function build$1() {
|
|
|
2795
2800
|
data: Base64Schema,
|
|
2796
2801
|
mimeType: string$1(),
|
|
2797
2802
|
annotations: AnnotationsSchema$1.optional(),
|
|
2798
|
-
_meta: record$
|
|
2803
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
2799
2804
|
});
|
|
2800
2805
|
/**
|
|
2801
2806
|
* A tool call request from an assistant (LLM).
|
|
@@ -2809,8 +2814,8 @@ function build$1() {
|
|
|
2809
2814
|
type: literal("tool_use"),
|
|
2810
2815
|
name: string$1(),
|
|
2811
2816
|
id: string$1(),
|
|
2812
|
-
input: record$
|
|
2813
|
-
_meta: record$
|
|
2817
|
+
input: record$2(string$1(), unknown()),
|
|
2818
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
2814
2819
|
});
|
|
2815
2820
|
/**
|
|
2816
2821
|
* The contents of a resource, embedded into a prompt or tool call result.
|
|
@@ -2819,7 +2824,7 @@ function build$1() {
|
|
|
2819
2824
|
type: literal("resource"),
|
|
2820
2825
|
resource: union([TextResourceContentsSchema$1, BlobResourceContentsSchema$1]),
|
|
2821
2826
|
annotations: AnnotationsSchema$1.optional(),
|
|
2822
|
-
_meta: record$
|
|
2827
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
2823
2828
|
});
|
|
2824
2829
|
/**
|
|
2825
2830
|
* A resource that the server is capable of reading, included in a prompt or tool call result.
|
|
@@ -2892,17 +2897,17 @@ function build$1() {
|
|
|
2892
2897
|
description: string$1().optional(),
|
|
2893
2898
|
inputSchema: object({
|
|
2894
2899
|
type: literal("object"),
|
|
2895
|
-
properties: record$
|
|
2900
|
+
properties: record$2(string$1(), JSONValueSchema$1).optional(),
|
|
2896
2901
|
required: array(string$1()).optional()
|
|
2897
2902
|
}).catchall(unknown()),
|
|
2898
2903
|
outputSchema: object({
|
|
2899
2904
|
type: literal("object"),
|
|
2900
|
-
properties: record$
|
|
2905
|
+
properties: record$2(string$1(), JSONValueSchema$1).optional(),
|
|
2901
2906
|
required: array(string$1()).optional()
|
|
2902
2907
|
}).catchall(unknown()).optional(),
|
|
2903
2908
|
annotations: ToolAnnotationsSchema$1.optional(),
|
|
2904
2909
|
execution: ToolExecutionSchema$1.optional(),
|
|
2905
|
-
_meta: record$
|
|
2910
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
2906
2911
|
});
|
|
2907
2912
|
/**
|
|
2908
2913
|
* Sent from the client to request a list of tools the server has.
|
|
@@ -2917,7 +2922,7 @@ function build$1() {
|
|
|
2917
2922
|
*/
|
|
2918
2923
|
const CallToolResultSchema$1 = ResultSchema$1.extend({
|
|
2919
2924
|
content: array(ContentBlockSchema$1),
|
|
2920
|
-
structuredContent: record$
|
|
2925
|
+
structuredContent: record$2(string$1(), unknown()).optional(),
|
|
2921
2926
|
isError: boolean$1().optional()
|
|
2922
2927
|
});
|
|
2923
2928
|
/**
|
|
@@ -2925,7 +2930,7 @@ function build$1() {
|
|
|
2925
2930
|
*/
|
|
2926
2931
|
const CallToolRequestParamsSchema$1 = TaskAugmentedRequestParamsSchema$1.extend({
|
|
2927
2932
|
name: string$1(),
|
|
2928
|
-
arguments: record$
|
|
2933
|
+
arguments: record$2(string$1(), unknown()).optional()
|
|
2929
2934
|
});
|
|
2930
2935
|
/**
|
|
2931
2936
|
* Used by the client to invoke a tool provided by the server.
|
|
@@ -3047,7 +3052,7 @@ function build$1() {
|
|
|
3047
3052
|
content: array(ContentBlockSchema$1),
|
|
3048
3053
|
structuredContent: object({}).loose().optional(),
|
|
3049
3054
|
isError: boolean$1().optional(),
|
|
3050
|
-
_meta: record$
|
|
3055
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
3051
3056
|
});
|
|
3052
3057
|
/**
|
|
3053
3058
|
* Basic content types for sampling responses (without tool use).
|
|
@@ -3087,7 +3092,7 @@ function build$1() {
|
|
|
3087
3092
|
const SamplingMessageSchema$1 = object({
|
|
3088
3093
|
role: RoleSchema$1,
|
|
3089
3094
|
content: union([SamplingMessageContentBlockSchema$1, array(SamplingMessageContentBlockSchema$1)]),
|
|
3090
|
-
_meta: record$
|
|
3095
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
3091
3096
|
});
|
|
3092
3097
|
/**
|
|
3093
3098
|
* Parameters for a `sampling/createMessage` request.
|
|
@@ -3293,7 +3298,7 @@ function build$1() {
|
|
|
3293
3298
|
message: string$1(),
|
|
3294
3299
|
requestedSchema: object({
|
|
3295
3300
|
type: literal("object"),
|
|
3296
|
-
properties: record$
|
|
3301
|
+
properties: record$2(string$1(), PrimitiveSchemaDefinitionSchema$1),
|
|
3297
3302
|
required: array(string$1()).optional()
|
|
3298
3303
|
}).catchall(unknown())
|
|
3299
3304
|
});
|
|
@@ -3343,7 +3348,7 @@ function build$1() {
|
|
|
3343
3348
|
"decline",
|
|
3344
3349
|
"cancel"
|
|
3345
3350
|
]),
|
|
3346
|
-
content: preprocess((val) => val === null ? void 0 : val, record$
|
|
3351
|
+
content: preprocess((val) => val === null ? void 0 : val, record$2(string$1(), union([
|
|
3347
3352
|
string$1(),
|
|
3348
3353
|
number$1(),
|
|
3349
3354
|
boolean$1(),
|
|
@@ -3373,7 +3378,7 @@ function build$1() {
|
|
|
3373
3378
|
name: string$1(),
|
|
3374
3379
|
value: string$1()
|
|
3375
3380
|
}),
|
|
3376
|
-
context: object({ arguments: record$
|
|
3381
|
+
context: object({ arguments: record$2(string$1(), string$1()).optional() }).optional()
|
|
3377
3382
|
});
|
|
3378
3383
|
/**
|
|
3379
3384
|
* A request from the client to the server, to ask for completion options.
|
|
@@ -3400,7 +3405,7 @@ function build$1() {
|
|
|
3400
3405
|
const RootSchema$1 = object({
|
|
3401
3406
|
uri: string$1().startsWith("file://"),
|
|
3402
3407
|
name: string$1().optional(),
|
|
3403
|
-
_meta: record$
|
|
3408
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
3404
3409
|
});
|
|
3405
3410
|
/**
|
|
3406
3411
|
* Sent from the server to request a list of root URIs from the client.
|
|
@@ -4164,10 +4169,10 @@ function build() {
|
|
|
4164
4169
|
number$1(),
|
|
4165
4170
|
boolean$1(),
|
|
4166
4171
|
_null(),
|
|
4167
|
-
record$
|
|
4172
|
+
record$2(string$1(), JSONValueSchema$1),
|
|
4168
4173
|
array(JSONValueSchema$1)
|
|
4169
4174
|
]));
|
|
4170
|
-
const JSONObjectSchema$1 = record$
|
|
4175
|
+
const JSONObjectSchema$1 = record$2(string$1(), JSONValueSchema$1);
|
|
4171
4176
|
/**
|
|
4172
4177
|
* A progress token, used to associate progress notifications with the original request.
|
|
4173
4178
|
*/
|
|
@@ -4268,7 +4273,7 @@ function build() {
|
|
|
4268
4273
|
requests: looseObject({ tools: looseObject({ call: JSONObjectSchema$1.optional() }).optional() }).optional()
|
|
4269
4274
|
});
|
|
4270
4275
|
const ClientCapabilitiesSchema$1 = object({
|
|
4271
|
-
experimental: record$
|
|
4276
|
+
experimental: record$2(string$1(), JSONObjectSchema$1).optional(),
|
|
4272
4277
|
sampling: object({
|
|
4273
4278
|
context: JSONObjectSchema$1.optional(),
|
|
4274
4279
|
tools: JSONObjectSchema$1.optional()
|
|
@@ -4276,10 +4281,10 @@ function build() {
|
|
|
4276
4281
|
elicitation: ElicitationCapabilitySchema.optional(),
|
|
4277
4282
|
roots: object({ listChanged: boolean$1().optional() }).optional(),
|
|
4278
4283
|
tasks: ClientTasksCapabilitySchema$1.optional(),
|
|
4279
|
-
extensions: record$
|
|
4284
|
+
extensions: record$2(string$1(), JSONObjectSchema$1).optional()
|
|
4280
4285
|
});
|
|
4281
4286
|
const ServerCapabilitiesSchema$1 = object({
|
|
4282
|
-
experimental: record$
|
|
4287
|
+
experimental: record$2(string$1(), JSONObjectSchema$1).optional(),
|
|
4283
4288
|
logging: JSONObjectSchema$1.optional(),
|
|
4284
4289
|
completions: JSONObjectSchema$1.optional(),
|
|
4285
4290
|
prompts: object({ listChanged: boolean$1().optional() }).optional(),
|
|
@@ -4289,7 +4294,7 @@ function build() {
|
|
|
4289
4294
|
}).optional(),
|
|
4290
4295
|
tools: object({ listChanged: boolean$1().optional() }).optional(),
|
|
4291
4296
|
tasks: ServerTasksCapabilitySchema$1.optional(),
|
|
4292
|
-
extensions: record$
|
|
4297
|
+
extensions: record$2(string$1(), JSONObjectSchema$1).optional()
|
|
4293
4298
|
});
|
|
4294
4299
|
const ProgressSchema$1 = object({
|
|
4295
4300
|
progress: number$1(),
|
|
@@ -4317,7 +4322,7 @@ function build() {
|
|
|
4317
4322
|
const ResourceContentsSchema$1 = object({
|
|
4318
4323
|
uri: string$1(),
|
|
4319
4324
|
mimeType: optional(string$1()),
|
|
4320
|
-
_meta: record$
|
|
4325
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
4321
4326
|
});
|
|
4322
4327
|
const TextResourceContentsSchema$1 = ResourceContentsSchema$1.extend({ text: string$1() });
|
|
4323
4328
|
const BlobResourceContentsSchema$1 = ResourceContentsSchema$1.extend({ blob: Base64Schema });
|
|
@@ -4374,34 +4379,34 @@ function build() {
|
|
|
4374
4379
|
type: literal("text"),
|
|
4375
4380
|
text: string$1(),
|
|
4376
4381
|
annotations: AnnotationsSchema$1.optional(),
|
|
4377
|
-
_meta: record$
|
|
4382
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
4378
4383
|
});
|
|
4379
4384
|
const ImageContentSchema$1 = object({
|
|
4380
4385
|
type: literal("image"),
|
|
4381
4386
|
data: Base64Schema,
|
|
4382
4387
|
mimeType: string$1(),
|
|
4383
4388
|
annotations: AnnotationsSchema$1.optional(),
|
|
4384
|
-
_meta: record$
|
|
4389
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
4385
4390
|
});
|
|
4386
4391
|
const AudioContentSchema$1 = object({
|
|
4387
4392
|
type: literal("audio"),
|
|
4388
4393
|
data: Base64Schema,
|
|
4389
4394
|
mimeType: string$1(),
|
|
4390
4395
|
annotations: AnnotationsSchema$1.optional(),
|
|
4391
|
-
_meta: record$
|
|
4396
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
4392
4397
|
});
|
|
4393
4398
|
const ToolUseContentSchema$1 = object({
|
|
4394
4399
|
type: literal("tool_use"),
|
|
4395
4400
|
name: string$1(),
|
|
4396
4401
|
id: string$1(),
|
|
4397
|
-
input: record$
|
|
4398
|
-
_meta: record$
|
|
4402
|
+
input: record$2(string$1(), unknown()),
|
|
4403
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
4399
4404
|
});
|
|
4400
4405
|
const EmbeddedResourceSchema$1 = object({
|
|
4401
4406
|
type: literal("resource"),
|
|
4402
4407
|
resource: union([TextResourceContentsSchema$1, BlobResourceContentsSchema$1]),
|
|
4403
4408
|
annotations: AnnotationsSchema$1.optional(),
|
|
4404
|
-
_meta: record$
|
|
4409
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
4405
4410
|
});
|
|
4406
4411
|
const ResourceLinkSchema$1 = ResourceSchema$1.extend({ type: literal("resource_link") });
|
|
4407
4412
|
const ContentBlockSchema$1 = union([
|
|
@@ -4533,7 +4538,7 @@ function build() {
|
|
|
4533
4538
|
message: string$1(),
|
|
4534
4539
|
requestedSchema: object({
|
|
4535
4540
|
type: literal("object"),
|
|
4536
|
-
properties: record$
|
|
4541
|
+
properties: record$2(string$1(), PrimitiveSchemaDefinitionSchema$1),
|
|
4537
4542
|
required: array(string$1()).optional()
|
|
4538
4543
|
}).catchall(unknown())
|
|
4539
4544
|
});
|
|
@@ -4548,7 +4553,7 @@ function build() {
|
|
|
4548
4553
|
const RootSchema$1 = object({
|
|
4549
4554
|
uri: string$1().startsWith("file://"),
|
|
4550
4555
|
name: string$1().optional(),
|
|
4551
|
-
_meta: record$
|
|
4556
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
4552
4557
|
});
|
|
4553
4558
|
const sharedClientCapabilityShape = ClientCapabilitiesSchema$1.shape;
|
|
4554
4559
|
const ClientCapabilities2026Schema = object({
|
|
@@ -4597,7 +4602,7 @@ function build() {
|
|
|
4597
4602
|
}),
|
|
4598
4603
|
outputSchema: looseObject({ $schema: string$1().optional() }).optional(),
|
|
4599
4604
|
annotations: ToolAnnotationsSchema$1.optional(),
|
|
4600
|
-
_meta: record$
|
|
4605
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
4601
4606
|
});
|
|
4602
4607
|
/** 2026-era ToolResultContent (anchor-exact: `structuredContent?: unknown`). */
|
|
4603
4608
|
const ToolResultContentSchema$1 = object({
|
|
@@ -4606,7 +4611,7 @@ function build() {
|
|
|
4606
4611
|
content: array(ContentBlockSchema$1),
|
|
4607
4612
|
structuredContent: unknown().optional(),
|
|
4608
4613
|
isError: boolean$1().optional(),
|
|
4609
|
-
_meta: record$
|
|
4614
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
4610
4615
|
});
|
|
4611
4616
|
/** 2026-era sampling content union (composes the forked tool-result shape). */
|
|
4612
4617
|
const SamplingMessageContentBlockSchema$1 = union([
|
|
@@ -4620,7 +4625,7 @@ function build() {
|
|
|
4620
4625
|
const SamplingMessageSchema$1 = object({
|
|
4621
4626
|
role: RoleSchema$1,
|
|
4622
4627
|
content: union([SamplingMessageContentBlockSchema$1, array(SamplingMessageContentBlockSchema$1)]),
|
|
4623
|
-
_meta: record$
|
|
4628
|
+
_meta: record$2(string$1(), unknown()).optional()
|
|
4624
4629
|
});
|
|
4625
4630
|
/** Open union per the anchor: 'complete' | 'input_required' | string. */
|
|
4626
4631
|
const ResultTypeSchema = string$1();
|
|
@@ -4724,7 +4729,7 @@ function build() {
|
|
|
4724
4729
|
*/
|
|
4725
4730
|
const ListRootsRequestSchema$1 = object({
|
|
4726
4731
|
method: literal("roots/list"),
|
|
4727
|
-
params: object({ _meta: record$
|
|
4732
|
+
params: object({ _meta: record$2(string$1(), unknown()).optional() }).optional()
|
|
4728
4733
|
});
|
|
4729
4734
|
/** 2026-era embedded sampling response (anchor-exact: extends the forked SamplingMessage). */
|
|
4730
4735
|
const CreateMessageResultSchema$1 = object({
|
|
@@ -4741,7 +4746,7 @@ function build() {
|
|
|
4741
4746
|
"decline",
|
|
4742
4747
|
"cancel"
|
|
4743
4748
|
]),
|
|
4744
|
-
content: record$
|
|
4749
|
+
content: record$2(string$1(), union([
|
|
4745
4750
|
string$1(),
|
|
4746
4751
|
number$1(),
|
|
4747
4752
|
boolean$1(),
|
|
@@ -4779,9 +4784,9 @@ function build() {
|
|
|
4779
4784
|
ElicitResultSchema$1
|
|
4780
4785
|
]);
|
|
4781
4786
|
/** Map of embedded input requests, keyed by server-assigned identifiers. */
|
|
4782
|
-
const InputRequestsSchema = record$
|
|
4787
|
+
const InputRequestsSchema = record$2(string$1(), InputRequestSchema);
|
|
4783
4788
|
/** Map of embedded input responses, keyed by the corresponding request identifiers. */
|
|
4784
|
-
const InputResponsesSchema = record$
|
|
4789
|
+
const InputResponsesSchema = record$2(string$1(), InputResponseSchema);
|
|
4785
4790
|
/**
|
|
4786
4791
|
* The wire InputRequiredResult: `resultType: 'input_required'` plus at least
|
|
4787
4792
|
* one of `inputRequests` / `requestState` (the at-least-one rule is enforced
|
|
@@ -4823,7 +4828,7 @@ function build() {
|
|
|
4823
4828
|
}
|
|
4824
4829
|
const callToolParamsShape = {
|
|
4825
4830
|
name: string$1(),
|
|
4826
|
-
arguments: record$
|
|
4831
|
+
arguments: record$2(string$1(), unknown()).optional(),
|
|
4827
4832
|
...retryParamsShape
|
|
4828
4833
|
};
|
|
4829
4834
|
const paginatedParamsShape = { cursor: CursorSchema$1.optional() };
|
|
@@ -4832,7 +4837,7 @@ function build() {
|
|
|
4832
4837
|
const ListPromptsRequestSchema$1 = wireRequest("prompts/list", paginatedParamsShape);
|
|
4833
4838
|
const GetPromptRequestSchema$1 = wireRequest("prompts/get", {
|
|
4834
4839
|
name: string$1(),
|
|
4835
|
-
arguments: record$
|
|
4840
|
+
arguments: record$2(string$1(), string$1()).optional(),
|
|
4836
4841
|
...retryParamsShape
|
|
4837
4842
|
});
|
|
4838
4843
|
const ListResourcesRequestSchema$1 = wireRequest("resources/list", paginatedParamsShape);
|
|
@@ -4847,7 +4852,7 @@ function build() {
|
|
|
4847
4852
|
name: string$1(),
|
|
4848
4853
|
value: string$1()
|
|
4849
4854
|
}),
|
|
4850
|
-
context: object({ arguments: record$
|
|
4855
|
+
context: object({ arguments: record$2(string$1(), string$1()).optional() }).optional()
|
|
4851
4856
|
};
|
|
4852
4857
|
const CompleteRequestSchema$1 = wireRequest("completion/complete", completeParamsShape);
|
|
4853
4858
|
const DiscoverRequestSchema$1 = wireRequest("server/discover", {});
|
|
@@ -4882,7 +4887,7 @@ function build() {
|
|
|
4882
4887
|
"tools/list": dispatchRequest("tools/list", paginatedParamsShape),
|
|
4883
4888
|
"prompts/get": dispatchRequest("prompts/get", {
|
|
4884
4889
|
name: string$1(),
|
|
4885
|
-
arguments: record$
|
|
4890
|
+
arguments: record$2(string$1(), string$1()).optional()
|
|
4886
4891
|
}),
|
|
4887
4892
|
"prompts/list": dispatchRequest("prompts/list", paginatedParamsShape),
|
|
4888
4893
|
"resources/list": dispatchRequest("resources/list", paginatedParamsShape),
|
|
@@ -14301,13 +14306,13 @@ function toPiToolName(serverName, toolName) {
|
|
|
14301
14306
|
/** ChatGPT Apps metadata naming the top-level arguments that carry a file. */
|
|
14302
14307
|
const FILE_PARAMS_META_KEY = "openai/fileParams";
|
|
14303
14308
|
const MAX_FILE_PARAMS = 16;
|
|
14304
|
-
function record(value) {
|
|
14309
|
+
function record$1(value) {
|
|
14305
14310
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
14306
14311
|
}
|
|
14307
14312
|
/** Declared file parameters that the input schema really has at its top level. */
|
|
14308
14313
|
function fileParamNames(tool) {
|
|
14309
14314
|
const declared = tool._meta?.[FILE_PARAMS_META_KEY];
|
|
14310
|
-
const properties = record(tool.inputSchema.properties);
|
|
14315
|
+
const properties = record$1(tool.inputSchema.properties);
|
|
14311
14316
|
if (!Array.isArray(declared) || properties === void 0) return [];
|
|
14312
14317
|
const names = declared.filter((name) => typeof name === "string" && Object.hasOwn(properties, name));
|
|
14313
14318
|
return [...new Set(names)].slice(0, MAX_FILE_PARAMS);
|
|
@@ -14320,9 +14325,9 @@ function modelInputSchema(tool) {
|
|
|
14320
14325
|
};
|
|
14321
14326
|
const names = fileParamNames(tool);
|
|
14322
14327
|
if (names.length === 0) return tool.inputSchema;
|
|
14323
|
-
const properties = { ...record(tool.inputSchema.properties) };
|
|
14328
|
+
const properties = { ...record$1(tool.inputSchema.properties) };
|
|
14324
14329
|
for (const name of names) {
|
|
14325
|
-
const description = record(properties[name])?.description;
|
|
14330
|
+
const description = record$1(properties[name])?.description;
|
|
14326
14331
|
properties[name] = {
|
|
14327
14332
|
type: "object",
|
|
14328
14333
|
description: `${typeof description === "string" ? description : "A file."} Pass {"path": "<file in the working directory, or the path from an Attached file note>"}.`,
|
|
@@ -14351,14 +14356,26 @@ const USER_MCP_SCOPE = "user";
|
|
|
14351
14356
|
*/
|
|
14352
14357
|
const MCP_SECRET_NAMESPACE = "mcp.secret";
|
|
14353
14358
|
const SECRET_NAME = /^[A-Za-z0-9._-]{1,64}$/u;
|
|
14359
|
+
const SLUG_INVALID = /[^A-Za-z0-9._-]/gu;
|
|
14360
|
+
const MAX_SECRET_VALUE = 4096;
|
|
14361
|
+
const MAX_SECRET_FIELDS = 64;
|
|
14362
|
+
const VAULT_REF_MARKER$1 = "${vault:";
|
|
14354
14363
|
/** `${scope}/${name}`: one secret per name per scope. */
|
|
14355
14364
|
function mcpSecretVaultKey(scope, name) {
|
|
14356
14365
|
return `${scope}/${name}`;
|
|
14357
14366
|
}
|
|
14367
|
+
/** The reference written into configuration in place of a secret value. */
|
|
14368
|
+
function vaultReference(name) {
|
|
14369
|
+
return `\${vault:${name}}`;
|
|
14370
|
+
}
|
|
14358
14371
|
/** True for a name a `${vault:NAME}` reference accepts. */
|
|
14359
14372
|
function isSecretName(value) {
|
|
14360
14373
|
return typeof value === "string" && SECRET_NAME.test(value);
|
|
14361
14374
|
}
|
|
14375
|
+
/** A secret value the vault keeps: one line, at most 4 KiB. */
|
|
14376
|
+
function isSecretValue(value) {
|
|
14377
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_SECRET_VALUE && !/[\r\n\0]/u.test(value) && !value.includes(VAULT_REF_MARKER$1);
|
|
14378
|
+
}
|
|
14362
14379
|
/** The sha256 of `JSON.stringify([command, args])`, so a changed argument list reads as a new destination. */
|
|
14363
14380
|
function argsDigest(command, args) {
|
|
14364
14381
|
return createHash("sha256").update(JSON.stringify([command, args])).digest("hex");
|
|
@@ -14419,6 +14436,125 @@ function createSecretResolver(options) {
|
|
|
14419
14436
|
return stored.value;
|
|
14420
14437
|
};
|
|
14421
14438
|
}
|
|
14439
|
+
/** Writes one secret, last write wins. */
|
|
14440
|
+
async function storeSecret(vault, scope, write) {
|
|
14441
|
+
const value = {
|
|
14442
|
+
value: write.value,
|
|
14443
|
+
boundTo: write.boundTo
|
|
14444
|
+
};
|
|
14445
|
+
await vault.put(MCP_SECRET_NAMESPACE, mcpSecretVaultKey(scope, write.name), {
|
|
14446
|
+
...value,
|
|
14447
|
+
boundTo: { ...value.boundTo }
|
|
14448
|
+
});
|
|
14449
|
+
}
|
|
14450
|
+
/**
|
|
14451
|
+
* Writes every secret of one add-server request and returns how to undo them.
|
|
14452
|
+
*
|
|
14453
|
+
* A name that already held a secret is restored on undo rather than deleted, so a failed add never
|
|
14454
|
+
* erases a secret another server still references. A failed write undoes the earlier ones before
|
|
14455
|
+
* rethrowing.
|
|
14456
|
+
*/
|
|
14457
|
+
async function writeSecrets(vault, scope, writes) {
|
|
14458
|
+
const undo = [];
|
|
14459
|
+
const rollback = async () => {
|
|
14460
|
+
for (const step of undo.reverse()) await step().catch(() => void 0);
|
|
14461
|
+
};
|
|
14462
|
+
try {
|
|
14463
|
+
for (const write of writes) {
|
|
14464
|
+
const key = mcpSecretVaultKey(scope, write.name);
|
|
14465
|
+
const previous = await vault.get(MCP_SECRET_NAMESPACE, key);
|
|
14466
|
+
await storeSecret(vault, scope, write);
|
|
14467
|
+
undo.push(() => previous ? vault.put(MCP_SECRET_NAMESPACE, key, previous.value).then(() => void 0) : vault.delete(MCP_SECRET_NAMESPACE, key));
|
|
14468
|
+
}
|
|
14469
|
+
} catch (error) {
|
|
14470
|
+
await rollback();
|
|
14471
|
+
throw error;
|
|
14472
|
+
}
|
|
14473
|
+
return rollback;
|
|
14474
|
+
}
|
|
14475
|
+
function refuse$1(error) {
|
|
14476
|
+
return {
|
|
14477
|
+
ok: false,
|
|
14478
|
+
status: 400,
|
|
14479
|
+
error
|
|
14480
|
+
};
|
|
14481
|
+
}
|
|
14482
|
+
function isCredentialOrigin(url) {
|
|
14483
|
+
return url.protocol === "https:" || url.protocol === "http:" && [
|
|
14484
|
+
"localhost",
|
|
14485
|
+
"127.0.0.1",
|
|
14486
|
+
"[::1]"
|
|
14487
|
+
].includes(url.hostname);
|
|
14488
|
+
}
|
|
14489
|
+
/**
|
|
14490
|
+
* Moves the named header or env values of an add-server request into vault writes, leaving
|
|
14491
|
+
* `${vault:<server>-<field>}` in the entry. Every field is untrusted input.
|
|
14492
|
+
*/
|
|
14493
|
+
function prepareSecretAddition(addition, secretFields) {
|
|
14494
|
+
if (secretFields === void 0) return {
|
|
14495
|
+
ok: true,
|
|
14496
|
+
value: {
|
|
14497
|
+
addition,
|
|
14498
|
+
secrets: []
|
|
14499
|
+
}
|
|
14500
|
+
};
|
|
14501
|
+
if (!Array.isArray(secretFields) || secretFields.length > MAX_SECRET_FIELDS || !secretFields.every((field) => typeof field === "string") || new Set(secretFields).size !== secretFields.length) return refuse$1("Name each secret field once.");
|
|
14502
|
+
if (secretFields.length === 0) return {
|
|
14503
|
+
ok: true,
|
|
14504
|
+
value: {
|
|
14505
|
+
addition,
|
|
14506
|
+
secrets: []
|
|
14507
|
+
}
|
|
14508
|
+
};
|
|
14509
|
+
const { entry } = addition;
|
|
14510
|
+
let boundTo;
|
|
14511
|
+
let values;
|
|
14512
|
+
if ("command" in entry) {
|
|
14513
|
+
boundTo = {
|
|
14514
|
+
command: entry.command,
|
|
14515
|
+
argsDigest: argsDigest(entry.command, entry.args)
|
|
14516
|
+
};
|
|
14517
|
+
values = { ...entry.env };
|
|
14518
|
+
} else {
|
|
14519
|
+
const url = new URL(entry.url);
|
|
14520
|
+
if (!isCredentialOrigin(url) || url.username || url.password) return refuse$1("A secret is only sent over https, or over plain http to this machine.");
|
|
14521
|
+
boundTo = { origin: url.origin };
|
|
14522
|
+
values = { ...entry.headers };
|
|
14523
|
+
}
|
|
14524
|
+
const secrets = [];
|
|
14525
|
+
for (const field of secretFields) {
|
|
14526
|
+
const value = Object.hasOwn(values, field) ? values[field] : void 0;
|
|
14527
|
+
if (!isSecretValue(value)) return refuse$1("Each secret field needs a value you entered.");
|
|
14528
|
+
const name = `${addition.name}-${field.replace(SLUG_INVALID, "_")}`;
|
|
14529
|
+
if (!isSecretName(name)) return refuse$1("Shorten the server or field name so the secret name fits in 64 characters.");
|
|
14530
|
+
if (secrets.some((secret) => secret.name === name)) return refuse$1("Two secret fields map to the same vault name.");
|
|
14531
|
+
secrets.push({
|
|
14532
|
+
name,
|
|
14533
|
+
value,
|
|
14534
|
+
boundTo
|
|
14535
|
+
});
|
|
14536
|
+
values[field] = vaultReference(name);
|
|
14537
|
+
}
|
|
14538
|
+
const next = "command" in entry ? {
|
|
14539
|
+
command: entry.command,
|
|
14540
|
+
args: [...entry.args],
|
|
14541
|
+
env: values
|
|
14542
|
+
} : {
|
|
14543
|
+
type: "http",
|
|
14544
|
+
url: entry.url,
|
|
14545
|
+
headers: values
|
|
14546
|
+
};
|
|
14547
|
+
return {
|
|
14548
|
+
ok: true,
|
|
14549
|
+
value: {
|
|
14550
|
+
addition: {
|
|
14551
|
+
name: addition.name,
|
|
14552
|
+
entry: next
|
|
14553
|
+
},
|
|
14554
|
+
secrets
|
|
14555
|
+
}
|
|
14556
|
+
};
|
|
14557
|
+
}
|
|
14422
14558
|
//#endregion
|
|
14423
14559
|
//#region ../../default/po-mcp/src/services/remoteMcp/index.ts
|
|
14424
14560
|
const PO_MCP_REMOTE_SERVERS_SERVICE = "po/mcp-remote-servers";
|
|
@@ -14681,6 +14817,483 @@ async function connectRemoteMcpServers(service, signal, approval, vault = () =>
|
|
|
14681
14817
|
};
|
|
14682
14818
|
}
|
|
14683
14819
|
//#endregion
|
|
14820
|
+
//#region ../../default/po-mcp/src/services/mcpGlobalSettings/index.ts
|
|
14821
|
+
/** Beside `mcp.json` in Po's home, kept separate so MCP clients that read `mcp.json` never see it. */
|
|
14822
|
+
const MCP_SETTINGS_FILE = "mcp-settings.json";
|
|
14823
|
+
const AUTO_APPROVE_KEY = "autoApproveDestructiveTools";
|
|
14824
|
+
function record(value) {
|
|
14825
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
14826
|
+
}
|
|
14827
|
+
/** The file's object, or an empty one when it is missing. A malformed file is refused rather than overwritten. */
|
|
14828
|
+
async function readDocument(fs, filePath) {
|
|
14829
|
+
const text = await readTextIfExists(fs, filePath, BACKGROUND_CONTEXT);
|
|
14830
|
+
if (text === void 0) return {};
|
|
14831
|
+
let parsed;
|
|
14832
|
+
try {
|
|
14833
|
+
parsed = JSON.parse(text);
|
|
14834
|
+
} catch (error) {
|
|
14835
|
+
throw new Error(`${MCP_SETTINGS_FILE} is not valid JSON.`, { cause: error });
|
|
14836
|
+
}
|
|
14837
|
+
const document = record(parsed);
|
|
14838
|
+
if (!document) throw new Error(`${MCP_SETTINGS_FILE} must hold a JSON object.`);
|
|
14839
|
+
return document;
|
|
14840
|
+
}
|
|
14841
|
+
function createMcpGlobalSettings(getFs) {
|
|
14842
|
+
let autoApprove = false;
|
|
14843
|
+
let loaded;
|
|
14844
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
14845
|
+
const removalListeners = /* @__PURE__ */ new Set();
|
|
14846
|
+
const requireFs = () => {
|
|
14847
|
+
const fs = getFs();
|
|
14848
|
+
if (!fs) throw new Error("MCP settings need the host filesystem.");
|
|
14849
|
+
return fs;
|
|
14850
|
+
};
|
|
14851
|
+
const set = (enabled) => {
|
|
14852
|
+
if (autoApprove === enabled) return;
|
|
14853
|
+
autoApprove = enabled;
|
|
14854
|
+
for (const listener of listeners) listener();
|
|
14855
|
+
};
|
|
14856
|
+
return {
|
|
14857
|
+
autoApprove: () => autoApprove,
|
|
14858
|
+
load(filePath) {
|
|
14859
|
+
if (loaded?.path === filePath) return loaded.read;
|
|
14860
|
+
const read = (async () => {
|
|
14861
|
+
const document = await readDocument(requireFs(), filePath);
|
|
14862
|
+
set(document[AUTO_APPROVE_KEY] === true);
|
|
14863
|
+
return autoApprove;
|
|
14864
|
+
})();
|
|
14865
|
+
loaded = {
|
|
14866
|
+
path: filePath,
|
|
14867
|
+
read
|
|
14868
|
+
};
|
|
14869
|
+
read.catch(() => {
|
|
14870
|
+
if (loaded?.read === read) loaded = void 0;
|
|
14871
|
+
});
|
|
14872
|
+
return read;
|
|
14873
|
+
},
|
|
14874
|
+
async setAutoApprove(filePath, enabled) {
|
|
14875
|
+
const fs = requireFs();
|
|
14876
|
+
const document = await readDocument(fs, filePath);
|
|
14877
|
+
await writeFileAtomic(fs, filePath, `${JSON.stringify({
|
|
14878
|
+
...document,
|
|
14879
|
+
[AUTO_APPROVE_KEY]: enabled
|
|
14880
|
+
}, null, 2)}\n`, BACKGROUND_CONTEXT);
|
|
14881
|
+
loaded = {
|
|
14882
|
+
path: filePath,
|
|
14883
|
+
read: Promise.resolve(enabled)
|
|
14884
|
+
};
|
|
14885
|
+
set(enabled);
|
|
14886
|
+
},
|
|
14887
|
+
onChange(listener) {
|
|
14888
|
+
listeners.add(listener);
|
|
14889
|
+
return () => {
|
|
14890
|
+
listeners.delete(listener);
|
|
14891
|
+
};
|
|
14892
|
+
},
|
|
14893
|
+
serverRemoved(removal) {
|
|
14894
|
+
for (const listener of removalListeners) listener(removal);
|
|
14895
|
+
},
|
|
14896
|
+
onServerRemoved(listener) {
|
|
14897
|
+
removalListeners.add(listener);
|
|
14898
|
+
return () => {
|
|
14899
|
+
removalListeners.delete(listener);
|
|
14900
|
+
};
|
|
14901
|
+
}
|
|
14902
|
+
};
|
|
14903
|
+
}
|
|
14904
|
+
//#endregion
|
|
14905
|
+
//#region ../../default/po-mcp/src/constants/mcp.ts
|
|
14906
|
+
const SERVER_COMMAND_DESCRIPTION = "Show MCP configuration or begin an authorization request.";
|
|
14907
|
+
/** Matched by the hub API, which answers 503. */
|
|
14908
|
+
const VAULT_UNAVAILABLE = "Po's vault is unavailable, so MCP sign-ins cannot be saved.";
|
|
14909
|
+
new RegExp(`${String.fromCharCode(27)}\\[[0-?]*[ -/]*[@-~]`, "gu");
|
|
14910
|
+
/** Session route for one reachable tool's description and schema. */
|
|
14911
|
+
const MCP_SESSION_TOOL_API_PATH = "/tool";
|
|
14912
|
+
const MCP_SESSION_TOOL_SERVER_QUERY = "server";
|
|
14913
|
+
const MCP_SESSION_TOOL_NAME_QUERY = "tool";
|
|
14914
|
+
/** Session route that stores a `${vault:NAME}` secret the session reported missing. */
|
|
14915
|
+
const MCP_SESSION_SECRETS_API_PATH = "/secrets";
|
|
14916
|
+
/** Hub API paths for repository-scoped MCP management. */
|
|
14917
|
+
const MCP_REPOSITORY_API_PATH = "/repository";
|
|
14918
|
+
const MCP_DISCOVERY_API_PATH = "/repository/discover";
|
|
14919
|
+
const MCP_AUTHORIZATION_API_PATH = "/repository/authorize";
|
|
14920
|
+
/** The repository every route is asked about, and the flow segment the two flow routes carry. */
|
|
14921
|
+
const MCP_REPOSITORY_ID_QUERY = "repositoryId";
|
|
14922
|
+
const MCP_FLOW_ID_PARAM = "flowId";
|
|
14923
|
+
/** Adds one server to the repository's `.mcp.json` or to the person's own config. */
|
|
14924
|
+
const MCP_SERVERS_API_PATH = "/servers";
|
|
14925
|
+
/** Lists the servers in the person's own config. */
|
|
14926
|
+
const MCP_GLOBAL_SERVERS_API_PATH = "/servers/global";
|
|
14927
|
+
/** Reads and saves Po-wide MCP preferences. */
|
|
14928
|
+
const MCP_SETTINGS_API_PATH = "/settings";
|
|
14929
|
+
//#endregion
|
|
14930
|
+
//#region ../../default/po-mcp/src/types/apiRoutes.ts
|
|
14931
|
+
/** One authorization flow, addressed by id below the flow collection. */
|
|
14932
|
+
const AUTHORIZATION_FLOW_PATH = `${MCP_AUTHORIZATION_API_PATH}/:${MCP_FLOW_ID_PARAM}`;
|
|
14933
|
+
/**
|
|
14934
|
+
* This package's routes, as data.
|
|
14935
|
+
*
|
|
14936
|
+
* No scope and no base path. The build reads both off
|
|
14937
|
+
* `src/extensions/(backend)/api/mcp/`, so the mount is stated once, by the
|
|
14938
|
+
* folder that creates it. The sub-paths come from `webMcp`, which already owned
|
|
14939
|
+
* them, so this table names where a route sits and nothing else.
|
|
14940
|
+
*
|
|
14941
|
+
* This is the one file the hub handler and the settings panel both read, so a
|
|
14942
|
+
* path cannot move on one side alone. The handler matches on these strings
|
|
14943
|
+
* rather than parsing its own copies of them.
|
|
14944
|
+
*
|
|
14945
|
+
* `:flowId` is the client's parameter syntax; the handler reads the segment off
|
|
14946
|
+
* the same path, so the two cannot disagree about where the id sits.
|
|
14947
|
+
*/
|
|
14948
|
+
const routes = {
|
|
14949
|
+
catalog: {
|
|
14950
|
+
method: "GET",
|
|
14951
|
+
path: MCP_REPOSITORY_API_PATH,
|
|
14952
|
+
query: [MCP_REPOSITORY_ID_QUERY],
|
|
14953
|
+
response: void 0
|
|
14954
|
+
},
|
|
14955
|
+
discover: {
|
|
14956
|
+
method: "POST",
|
|
14957
|
+
path: MCP_DISCOVERY_API_PATH,
|
|
14958
|
+
response: void 0
|
|
14959
|
+
},
|
|
14960
|
+
authorize: {
|
|
14961
|
+
method: "POST",
|
|
14962
|
+
path: MCP_AUTHORIZATION_API_PATH,
|
|
14963
|
+
response: void 0
|
|
14964
|
+
},
|
|
14965
|
+
readAuthorization: {
|
|
14966
|
+
method: "GET",
|
|
14967
|
+
path: AUTHORIZATION_FLOW_PATH,
|
|
14968
|
+
query: [MCP_REPOSITORY_ID_QUERY],
|
|
14969
|
+
response: void 0
|
|
14970
|
+
},
|
|
14971
|
+
/** The same path as `readAuthorization`; the method is the whole of the difference. */
|
|
14972
|
+
cancelAuthorization: {
|
|
14973
|
+
method: "DELETE",
|
|
14974
|
+
path: AUTHORIZATION_FLOW_PATH,
|
|
14975
|
+
query: [MCP_REPOSITORY_ID_QUERY],
|
|
14976
|
+
response: void 0
|
|
14977
|
+
},
|
|
14978
|
+
/** Adds one server to the repository's `.mcp.json` or the person's own config, by the body's scope. */
|
|
14979
|
+
addServer: {
|
|
14980
|
+
method: "POST",
|
|
14981
|
+
path: MCP_SERVERS_API_PATH,
|
|
14982
|
+
response: void 0
|
|
14983
|
+
},
|
|
14984
|
+
editServer: {
|
|
14985
|
+
method: "PATCH",
|
|
14986
|
+
path: MCP_SERVERS_API_PATH,
|
|
14987
|
+
response: void 0
|
|
14988
|
+
},
|
|
14989
|
+
removeServer: {
|
|
14990
|
+
method: "DELETE",
|
|
14991
|
+
path: MCP_SERVERS_API_PATH,
|
|
14992
|
+
response: void 0
|
|
14993
|
+
},
|
|
14994
|
+
globalServers: {
|
|
14995
|
+
method: "GET",
|
|
14996
|
+
path: MCP_GLOBAL_SERVERS_API_PATH,
|
|
14997
|
+
response: void 0
|
|
14998
|
+
},
|
|
14999
|
+
readSettings: {
|
|
15000
|
+
method: "GET",
|
|
15001
|
+
path: MCP_SETTINGS_API_PATH,
|
|
15002
|
+
response: void 0
|
|
15003
|
+
},
|
|
15004
|
+
/** The same path as `readSettings`; saves the body and answers with what was saved. */
|
|
15005
|
+
saveSettings: {
|
|
15006
|
+
method: "PUT",
|
|
15007
|
+
path: MCP_SETTINGS_API_PATH,
|
|
15008
|
+
response: void 0
|
|
15009
|
+
},
|
|
15010
|
+
/** Session scope: one available tool's registered name, description and schema. */
|
|
15011
|
+
sessionTool: {
|
|
15012
|
+
method: "GET",
|
|
15013
|
+
path: MCP_SESSION_TOOL_API_PATH,
|
|
15014
|
+
query: [MCP_SESSION_TOOL_SERVER_QUERY, MCP_SESSION_TOOL_NAME_QUERY],
|
|
15015
|
+
response: void 0
|
|
15016
|
+
},
|
|
15017
|
+
/** Session scope: stores a secret the session reported missing. Owner-only; the value is never echoed. */
|
|
15018
|
+
sessionSecret: {
|
|
15019
|
+
method: "POST",
|
|
15020
|
+
path: MCP_SESSION_SECRETS_API_PATH,
|
|
15021
|
+
response: void 0
|
|
15022
|
+
}
|
|
15023
|
+
};
|
|
15024
|
+
//#endregion
|
|
15025
|
+
//#region ../../default/po-mcp/src/services/mcpHubApi/http.ts
|
|
15026
|
+
/**
|
|
15027
|
+
* What the Node hub API and the edge global API share: JSON bodies and answers, the person's own config
|
|
15028
|
+
* paths, and the approval settings route. None of it touches a filesystem or a process, so both hosts run it.
|
|
15029
|
+
*/
|
|
15030
|
+
const JSON_HEADERS = { "content-type": "application/json" };
|
|
15031
|
+
const MAX_BODY_BYTES = 8192;
|
|
15032
|
+
const MAX_SERVER_NAME = 160;
|
|
15033
|
+
function json(body, status = 200) {
|
|
15034
|
+
return new Response(JSON.stringify(body), {
|
|
15035
|
+
status,
|
|
15036
|
+
headers: JSON_HEADERS
|
|
15037
|
+
});
|
|
15038
|
+
}
|
|
15039
|
+
function isRecord$1(value) {
|
|
15040
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15041
|
+
}
|
|
15042
|
+
async function bodyOf(request) {
|
|
15043
|
+
const text = await request.text();
|
|
15044
|
+
if (text.length > MAX_BODY_BYTES) return void 0;
|
|
15045
|
+
try {
|
|
15046
|
+
const parsed = JSON.parse(text);
|
|
15047
|
+
return isRecord$1(parsed) ? parsed : void 0;
|
|
15048
|
+
} catch {
|
|
15049
|
+
return;
|
|
15050
|
+
}
|
|
15051
|
+
}
|
|
15052
|
+
function serverNameOf(value) {
|
|
15053
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_SERVER_NAME && !Array.from(value).some((character) => character.charCodeAt(0) <= 31) ? value : void 0;
|
|
15054
|
+
}
|
|
15055
|
+
/**
|
|
15056
|
+
* The person's own MCP files under Po's home: their servers and their Po-wide preferences. The hub API writes
|
|
15057
|
+
* them and the saved-state reader reads them, so both take the paths from here. Undefined when the host gave no home.
|
|
15058
|
+
*/
|
|
15059
|
+
function userMcpFilePaths(homeDirectory, environment = {}) {
|
|
15060
|
+
if (!homeDirectory) return void 0;
|
|
15061
|
+
const poHome = poHomeDirectory(homeDirectory, environment);
|
|
15062
|
+
return {
|
|
15063
|
+
config: join(poHome, PO_USER_MCP_CONFIG_FILE),
|
|
15064
|
+
settings: join(poHome, MCP_SETTINGS_FILE)
|
|
15065
|
+
};
|
|
15066
|
+
}
|
|
15067
|
+
/** `<po home>/mcp.json` for the person this hub runs as, or undefined when the host gave no home. */
|
|
15068
|
+
function userConfigPath(context) {
|
|
15069
|
+
return userMcpFilePaths(context.homeDirectory, context.environment)?.config;
|
|
15070
|
+
}
|
|
15071
|
+
function settingsPath(context) {
|
|
15072
|
+
return userMcpFilePaths(context.homeDirectory, context.environment)?.settings;
|
|
15073
|
+
}
|
|
15074
|
+
/** A missing vault, or a VaultError the store raised (matched by code, never by class). */
|
|
15075
|
+
function isVaultUnavailable(error) {
|
|
15076
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "unavailable") return true;
|
|
15077
|
+
return error instanceof Error && error.message === "Po's vault is unavailable, so MCP sign-ins cannot be saved.";
|
|
15078
|
+
}
|
|
15079
|
+
/** Reads or saves the approval setting. A file that cannot be read or written is a 500, never an `off` answer. */
|
|
15080
|
+
async function handleSettings(settings, request, context) {
|
|
15081
|
+
const filePath = settingsPath(context);
|
|
15082
|
+
if (!filePath) return json({ error: "Po couldn't find your home directory on this hub." }, 503);
|
|
15083
|
+
try {
|
|
15084
|
+
if (request.method === routes.saveSettings.method) {
|
|
15085
|
+
const body = await bodyOf(request);
|
|
15086
|
+
if (!body || Object.keys(body).length !== 1 || typeof body.autoApproveDestructiveTools !== "boolean") return json({ error: "Send { \"autoApproveDestructiveTools\": true | false }." }, 400);
|
|
15087
|
+
await settings.setAutoApprove(filePath, body.autoApproveDestructiveTools);
|
|
15088
|
+
} else await settings.load(filePath);
|
|
15089
|
+
return json({ autoApproveDestructiveTools: settings.autoApprove() });
|
|
15090
|
+
} catch (error) {
|
|
15091
|
+
return json({ error: `Po couldn't use ${MCP_SETTINGS_FILE}: ${error instanceof Error ? error.message : String(error)}` }, 500);
|
|
15092
|
+
}
|
|
15093
|
+
}
|
|
15094
|
+
/** Every name a client may give the wrapper entry. */
|
|
15095
|
+
const PROXY_SERVER_ALIASES = /* @__PURE__ */ new Set(["mcp-proxy", "agiflow-proxy"]);
|
|
15096
|
+
/** Whether a server name is the proxy wrapper, which Po strips on load instead of connecting. */
|
|
15097
|
+
function isProxyWrapper(name) {
|
|
15098
|
+
return PROXY_SERVER_ALIASES.has(name);
|
|
15099
|
+
}
|
|
15100
|
+
//#endregion
|
|
15101
|
+
//#region ../../default/po-mcp/src/services/mcpServerConfig/index.ts
|
|
15102
|
+
const NAME = /^[A-Za-z0-9_-]{1,64}$/u;
|
|
15103
|
+
const HEADER_NAME = /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/u;
|
|
15104
|
+
const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/u;
|
|
15105
|
+
const MAX_URL = 2048;
|
|
15106
|
+
const MAX_COMMAND = 1024;
|
|
15107
|
+
const MAX_VALUE = 4096;
|
|
15108
|
+
const MAX_ARGS = 64;
|
|
15109
|
+
const MAX_PAIRS = 64;
|
|
15110
|
+
function isRecord(value) {
|
|
15111
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15112
|
+
}
|
|
15113
|
+
function refuse(error, status = 400) {
|
|
15114
|
+
return {
|
|
15115
|
+
ok: false,
|
|
15116
|
+
status,
|
|
15117
|
+
error
|
|
15118
|
+
};
|
|
15119
|
+
}
|
|
15120
|
+
function hasControl(value) {
|
|
15121
|
+
return Array.from(value).some((character) => character.charCodeAt(0) <= 31 || character.charCodeAt(0) === 127);
|
|
15122
|
+
}
|
|
15123
|
+
/** Header values and environment values may hold anything but a line break or NUL. */
|
|
15124
|
+
function isPlainValue(value) {
|
|
15125
|
+
return typeof value === "string" && value.length <= MAX_VALUE && !/[\r\n\0]/u.test(value);
|
|
15126
|
+
}
|
|
15127
|
+
function stringPairs(value, keyPattern) {
|
|
15128
|
+
if (value === void 0) return void 0;
|
|
15129
|
+
if (!isRecord(value)) return null;
|
|
15130
|
+
const entries = Object.entries(value);
|
|
15131
|
+
if (entries.length > MAX_PAIRS) return null;
|
|
15132
|
+
for (const [key, item] of entries) if (!keyPattern.test(key) || !isPlainValue(item)) return null;
|
|
15133
|
+
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
15134
|
+
}
|
|
15135
|
+
function remoteEntry(value) {
|
|
15136
|
+
const url = value.url;
|
|
15137
|
+
if (typeof url !== "string" || url.length > MAX_URL) return refuse("Enter an http or https address.");
|
|
15138
|
+
let protocol;
|
|
15139
|
+
try {
|
|
15140
|
+
protocol = new URL(url).protocol;
|
|
15141
|
+
} catch {
|
|
15142
|
+
return refuse("Enter an http or https address.");
|
|
15143
|
+
}
|
|
15144
|
+
if (protocol !== "https:" && protocol !== "http:") return refuse("Enter an http or https address.");
|
|
15145
|
+
const headers = stringPairs(value.headers, HEADER_NAME);
|
|
15146
|
+
if (headers === null) return refuse("Each header needs a plain name and a one-line value.");
|
|
15147
|
+
return {
|
|
15148
|
+
ok: true,
|
|
15149
|
+
value: {
|
|
15150
|
+
type: "http",
|
|
15151
|
+
url,
|
|
15152
|
+
...headers ? { headers } : {}
|
|
15153
|
+
}
|
|
15154
|
+
};
|
|
15155
|
+
}
|
|
15156
|
+
function localEntry(value, trusted) {
|
|
15157
|
+
const command = typeof value.command === "string" ? value.command.trim() : "";
|
|
15158
|
+
if (command === "" || command.length > MAX_COMMAND || hasControl(command)) return refuse("Enter the command to run.");
|
|
15159
|
+
const args = value.args ?? [];
|
|
15160
|
+
if (!Array.isArray(args) || args.length > MAX_ARGS || !args.every((arg) => typeof arg === "string" && arg.length <= MAX_VALUE && !arg.includes("\0"))) return refuse("Arguments must be plain text, one per line.");
|
|
15161
|
+
const env = stringPairs(value.env, ENV_NAME);
|
|
15162
|
+
if (env === null) return refuse("Each environment variable needs a NAME and a one-line value.");
|
|
15163
|
+
if (!trusted) return refuse("Confirm that you trust this command before adding it.");
|
|
15164
|
+
return {
|
|
15165
|
+
ok: true,
|
|
15166
|
+
value: {
|
|
15167
|
+
command,
|
|
15168
|
+
args,
|
|
15169
|
+
...env ? { env } : {}
|
|
15170
|
+
}
|
|
15171
|
+
};
|
|
15172
|
+
}
|
|
15173
|
+
/** Checks a server name and entry from the settings UI. Every field is untrusted input. */
|
|
15174
|
+
function parseMcpServerAddition(name, entry, trusted) {
|
|
15175
|
+
if (typeof name !== "string" || !NAME.test(name)) return refuse("Use letters, numbers, dashes or underscores.");
|
|
15176
|
+
if (isProxyWrapper(name)) return refuse(`${name} is reserved for Po's MCP proxy. Choose another name.`);
|
|
15177
|
+
if (!isRecord(entry)) return refuse("Enter a server URL or a command.");
|
|
15178
|
+
const parsed = "command" in entry ? localEntry(entry, trusted === true) : remoteEntry(entry);
|
|
15179
|
+
return parsed.ok ? {
|
|
15180
|
+
ok: true,
|
|
15181
|
+
value: {
|
|
15182
|
+
name,
|
|
15183
|
+
entry: parsed.value
|
|
15184
|
+
}
|
|
15185
|
+
} : parsed;
|
|
15186
|
+
}
|
|
15187
|
+
/**
|
|
15188
|
+
* The document with one server added, every other key kept as it was.
|
|
15189
|
+
* Refuses rather than replaces: a name that exists already stays as the person wrote it.
|
|
15190
|
+
*/
|
|
15191
|
+
function addMcpServer(document, addition, fileLabel) {
|
|
15192
|
+
const config = document === void 0 ? {} : document;
|
|
15193
|
+
if (!isRecord(config)) return refuse(`${fileLabel} isn't a JSON object, so Po left it alone.`, 409);
|
|
15194
|
+
const servers = config.mcpServers ?? {};
|
|
15195
|
+
if (!isRecord(servers)) return refuse(`mcpServers in ${fileLabel} isn't an object, so Po left it alone.`, 409);
|
|
15196
|
+
if (Object.hasOwn(servers, addition.name)) return refuse(`A server named ${addition.name} already exists in ${fileLabel}.`, 409);
|
|
15197
|
+
return {
|
|
15198
|
+
ok: true,
|
|
15199
|
+
value: {
|
|
15200
|
+
...config,
|
|
15201
|
+
mcpServers: {
|
|
15202
|
+
...servers,
|
|
15203
|
+
[addition.name]: addition.entry
|
|
15204
|
+
}
|
|
15205
|
+
}
|
|
15206
|
+
};
|
|
15207
|
+
}
|
|
15208
|
+
/** The servers a config document names, without their headers or environment. */
|
|
15209
|
+
function listMcpServers(document) {
|
|
15210
|
+
const servers = isRecord(document) && isRecord(document.mcpServers) ? document.mcpServers : {};
|
|
15211
|
+
return Object.entries(servers).filter(([name]) => !isProxyWrapper(name)).map(([name, definition]) => {
|
|
15212
|
+
const record = isRecord(definition) ? definition : {};
|
|
15213
|
+
return typeof record.command === "string" ? {
|
|
15214
|
+
name,
|
|
15215
|
+
kind: "local",
|
|
15216
|
+
target: record.command
|
|
15217
|
+
} : {
|
|
15218
|
+
name,
|
|
15219
|
+
kind: "remote",
|
|
15220
|
+
target: safeMcpTarget(record.url)
|
|
15221
|
+
};
|
|
15222
|
+
}).sort((left, right) => left.name.localeCompare(right.name));
|
|
15223
|
+
}
|
|
15224
|
+
/**
|
|
15225
|
+
* The servers a config document names, each with what the person may do to it. A definition that is not an
|
|
15226
|
+
* object is listed but read-only, and an edit that would move a remote server to a new URL is not offered.
|
|
15227
|
+
*/
|
|
15228
|
+
function listManagedMcpServers(document) {
|
|
15229
|
+
const servers = isRecord(document) && isRecord(document.mcpServers) ? document.mcpServers : {};
|
|
15230
|
+
return listMcpServers(document).map((server) => {
|
|
15231
|
+
const definition = servers[server.name];
|
|
15232
|
+
const writable = isRecord(definition);
|
|
15233
|
+
return {
|
|
15234
|
+
...server,
|
|
15235
|
+
management: {
|
|
15236
|
+
owner: writable ? "global" : "read-only",
|
|
15237
|
+
target: server.target,
|
|
15238
|
+
kind: server.kind,
|
|
15239
|
+
canEdit: writable && (server.kind === "local" || server.target === definition.url),
|
|
15240
|
+
canRemove: writable,
|
|
15241
|
+
...writable ? { revision: mcpServerRevision(definition) } : {}
|
|
15242
|
+
}
|
|
15243
|
+
};
|
|
15244
|
+
});
|
|
15245
|
+
}
|
|
15246
|
+
/** Opaque optimistic concurrency identity, including fields never returned to the browser. */
|
|
15247
|
+
function mcpServerRevision(entry) {
|
|
15248
|
+
return createHash("sha256").update(JSON.stringify(entry) ?? "undefined").digest("hex");
|
|
15249
|
+
}
|
|
15250
|
+
/** Changes only one existing entry. Credentials and unknown saved fields stay in place. */
|
|
15251
|
+
function mutateMcpServer(document, name, revision, addition, preserveArgs = false) {
|
|
15252
|
+
if (isProxyWrapper(name) || !isRecord(document) || !isRecord(document.mcpServers)) return refuse("That saved server is not writable. Refresh settings.", 409);
|
|
15253
|
+
const servers = document.mcpServers;
|
|
15254
|
+
if (!Object.hasOwn(servers, name) || !isRecord(servers[name]) || mcpServerRevision(servers[name]) !== revision) return refuse("That saved server changed. Refresh settings before trying again.", 409);
|
|
15255
|
+
const old = servers[name];
|
|
15256
|
+
const next = { ...servers };
|
|
15257
|
+
if (addition) {
|
|
15258
|
+
const entry = addition.entry;
|
|
15259
|
+
if (addition.name !== name) return refuse("A saved server name cannot be changed.");
|
|
15260
|
+
if (("command" in entry ? entry.command !== old.command : entry.url !== old.url || "command" in old) || "command" in entry && (!("command" in old) || !preserveArgs && JSON.stringify(entry.args) !== JSON.stringify(old.args ?? [])) || !("command" in entry) && old.type !== void 0 && old.type !== "http") return refuse("Changing endpoint, transport, command or arguments needs a separate credential decision. Po left the server and credentials unchanged.", 409);
|
|
15261
|
+
const pairs = "command" in entry ? "env" : "headers";
|
|
15262
|
+
const values = entry[pairs];
|
|
15263
|
+
next[name] = {
|
|
15264
|
+
...old,
|
|
15265
|
+
...entry,
|
|
15266
|
+
..."command" in entry && preserveArgs && Array.isArray(old.args) ? { args: old.args } : {},
|
|
15267
|
+
...isRecord(old[pairs]) || isRecord(values) ? { [pairs]: {
|
|
15268
|
+
...isRecord(old[pairs]) ? old[pairs] : {},
|
|
15269
|
+
...isRecord(values) ? values : {}
|
|
15270
|
+
} } : {}
|
|
15271
|
+
};
|
|
15272
|
+
} else delete next[name];
|
|
15273
|
+
return {
|
|
15274
|
+
ok: true,
|
|
15275
|
+
value: {
|
|
15276
|
+
...document,
|
|
15277
|
+
mcpServers: next
|
|
15278
|
+
}
|
|
15279
|
+
};
|
|
15280
|
+
}
|
|
15281
|
+
/** URLs can embed credentials. A read projection never returns userinfo, query or fragment. */
|
|
15282
|
+
function safeMcpTarget(value) {
|
|
15283
|
+
if (typeof value !== "string") return "";
|
|
15284
|
+
try {
|
|
15285
|
+
const url = new URL(value);
|
|
15286
|
+
if (url.username === "" && url.password === "" && url.search === "" && url.hash === "") return value;
|
|
15287
|
+
url.username = "";
|
|
15288
|
+
url.password = "";
|
|
15289
|
+
url.search = "";
|
|
15290
|
+
url.hash = "";
|
|
15291
|
+
return url.toString();
|
|
15292
|
+
} catch {
|
|
15293
|
+
return "";
|
|
15294
|
+
}
|
|
15295
|
+
}
|
|
15296
|
+
//#endregion
|
|
14684
15297
|
//#region ../../foundations/po-vault/src/services/localLock/index.ts
|
|
14685
15298
|
/**
|
|
14686
15299
|
* `Vault.withLock` for a vault whose lock only has to hold inside this process: calls on one name
|
|
@@ -14794,4 +15407,4 @@ function createAccountVault(call, connected = () => true) {
|
|
|
14794
15407
|
};
|
|
14795
15408
|
}
|
|
14796
15409
|
//#endregion
|
|
14797
|
-
export {
|
|
15410
|
+
export { ClientRequestSchema as $, RequestMetaSchema as $n, ToolListChangedNotificationSchema as $r, LegacyTitledEnumSchemaSchema as $t, modelInputSchema as A, OAuthTokensSchema as An, SubscribeRequestParamsSchema as Ar, GetTaskPayloadResultSchema as At, BlobResourceContentsSchema as B, ProgressNotificationSchema as Bn, TaskCreationParamsSchema as Br, InitializeResultSchema as Bt, PO_MCP_REMOTE_SERVERS_CONTRACT as C, OAuthClientInformationSchema as Cn, ServerRequestSchema as Cr, EmbeddedResourceSchema as Ct, prepareSecretAddition as D, OAuthMetadataSchema as Dn, SetLevelRequestSchema as Dr, GetPromptRequestSchema as Dt, readPoMcpRemoteServers as E, OAuthErrorResponseSchema as En, SetLevelRequestParamsSchema as Er, GetPromptRequestParamsSchema as Et, mcpToolApproval as F, PaginatedRequestSchema as Fn, SubscriptionsListenRequestParamsSchema as Fr, IdJagTokenExchangeResponseSchema as Ft, CallToolRequestSchema as G, PromptMessageSchema as Gn, TaskStatusSchema as Gr, JSONRPCMessageSchema as Gt, CLIENT_CAPABILITIES_META_KEY as H, ProgressTokenSchema as Hn, TaskSchema as Hr, JSONArraySchema as Ht, AnnotationsSchema as I, PaginatedResultSchema as In, SubscriptionsListenRequestSchema as Ir, ImageContentSchema as It, CancelTaskResultSchema as J, ReadResourceRequestParamsSchema as Jn, TitledMultiSelectEnumSchemaSchema as Jr, JSONRPCResponseSchema as Jt, CallToolResultSchema as K, PromptReferenceSchema as Kn, TextContentSchema as Kr, JSONRPCNotificationSchema as Kt, AudioContentSchema as L, PingRequestSchema as Ln, SubscriptionsListenResultMetaSchema as Lr, ImplementationSchema as Lt, normalizeMcpAppMetadata as M, OpenIdProviderMetadataSchema as Mn, SubscriptionFilterSchema as Mr, GetTaskResultSchema as Mt, createMcpApprovalState as N, PROTOCOL_VERSION_META_KEY as Nn, SubscriptionsAcknowledgedNotificationParamsSchema as Nr, IconSchema as Nt, writeSecrets as O, OAuthProtectedResourceMetadataSchema as On, SingleSelectEnumSchemaSchema as Or, GetPromptResultSchema as Ot, isDestructiveMcpTool as P, PaginatedRequestParamsSchema as Pn, SubscriptionsAcknowledgedNotificationSchema as Pr, IconsSchema as Pt, ClientNotificationSchema as Q, RequestIdSchema as Qn, ToolExecutionSchema as Qr, LOG_LEVEL_META_KEY as Qt, BaseMetadataSchema as R, PrimitiveSchemaDefinitionSchema as Rn, SubscriptionsListenResultSchema as Rr, InitializeRequestParamsSchema as Rt, createMcpGlobalSettings as S, OAuthClientInformationFullSchema as Sn, ServerNotificationSchema as Sr, ElicitationCompleteNotificationSchema as St, connectRemoteMcpServers as T, OAuthClientRegistrationErrorSchema as Tn, ServerTasksCapabilitySchema as Tr, EnumSchemaSchema as Tt, CLIENT_INFO_META_KEY as U, PromptArgumentSchema as Un, TaskStatusNotificationParamsSchema as Ur, JSONObjectSchema as Ut, BooleanSchemaSchema as V, ProgressSchema as Vn, TaskMetadataSchema as Vr, InitializedNotificationSchema as Vt, CallToolRequestParamsSchema as W, PromptListChangedNotificationSchema as Wn, TaskStatusNotificationSchema as Wr, JSONRPCErrorResponseSchema as Wt, CancelledNotificationSchema as X, ReadResourceResultSchema as Xn, ToolAnnotationsSchema as Xr, JSONValueSchema as Xt, CancelledNotificationParamsSchema as Y, ReadResourceRequestSchema as Yn, TitledSingleSelectEnumSchemaSchema as Yr, JSONRPCResultResponseSchema as Yt, ClientCapabilitiesSchema as Z, RelatedTaskMetadataSchema as Zn, ToolChoiceSchema as Zr, LATEST_PROTOCOL_VERSION as Zt, userMcpFilePaths as _, ModelPreferencesSchema as _n, SUPPORTED_PROTOCOL_VERSIONS as _r, ElicitRequestParamsSchema as _t, listManagedMcpServers as a, UntitledMultiSelectEnumSchemaSchema as ai, ListResourcesRequestSchema as an, ResourceSchema as ar, CompleteResultSchema as at, SERVER_COMMAND_DESCRIPTION as b, NotificationsParamsSchema as bn, SamplingMessageSchema as br, ElicitResultSchema as bt, parseMcpServerAddition as c, string as ci, ListRootsResultSchema as cn, ResourceUpdatedNotificationParamsSchema as cr, CreateMessageRequestSchema as ct, handleSettings as d, ownZone as di, ListToolsRequestSchema as dn, ResultSchema as dr, CreateTaskResultSchema as dt, ToolResultContentSchema as ei, ListChangedOptionsBaseSchema as en, RequestSchema as er, ClientResultSchema as et, isRecord$1 as f, ListToolsResultSchema as fn, RoleSchema as fr, CursorSchema as ft, userConfigPath as g, ModelHintSchema as gn, SUBSCRIPTION_ID_META_KEY as gr, ElicitRequestFormParamsSchema as gt, serverNameOf as h, LoggingMessageNotificationSchema as hn, SERVER_INFO_META_KEY as hr, DiscoverResultSchema as ht, addMcpServer as i, UnsubscribeRequestSchema as ii, ListResourceTemplatesResultSchema as in, ResourceRequestParamsSchema as ir, CompleteRequestSchema as it, isModelVisibleMcpTool as j, OpenIdProviderDiscoveryMetadataSchema as jn, SubscribeRequestSchema as jr, GetTaskRequestSchema as jt, USER_MCP_SCOPE as k, OAuthTokenRevocationRequestSchema as kn, StringSchemaSchema as kr, GetTaskPayloadRequestSchema as kt, isProxyWrapper as l, OutboundRefusedError as li, ListTasksRequestSchema as ln, ResourceUpdatedNotificationSchema as lr, CreateMessageResultSchema as lt, json as m, LoggingMessageNotificationParamsSchema as mn, RootsListChangedNotificationSchema as mr, DiscoverRequestSchema as mt, isVaultAccountOperation as n, ToolUseContentSchema as ni, ListPromptsResultSchema as nn, ResourceLinkSchema as nr, CompatibilityCallToolResultSchema as nt, mcpServerRevision as o, UntitledSingleSelectEnumSchemaSchema as oi, ListResourcesResultSchema as on, ResourceTemplateReferenceSchema as or, ContentBlockSchema as ot, isVaultUnavailable as p, LoggingLevelSchema as pn, RootSchema as pr, DEFAULT_NEGOTIATED_PROTOCOL_VERSION as pt, CancelTaskRequestSchema as q, PromptSchema as qn, TextResourceContentsSchema as qr, JSONRPCRequestSchema as qt, createLocalLock as r, UnsubscribeRequestParamsSchema as ri, ListResourceTemplatesRequestSchema as rn, ResourceListChangedNotificationSchema as rr, CompleteRequestParamsSchema as rt, mutateMcpServer as s, boolean as si, ListRootsRequestSchema as sn, ResourceTemplateSchema as sr, CreateMessageRequestParamsSchema as st, createAccountVault as t, ToolSchema as ti, ListPromptsRequestSchema as tn, ResourceContentsSchema as tr, ClientTasksCapabilitySchema as tt, bodyOf as u, outboundHostRefusal as ui, ListTasksResultSchema as un, ResultMetaObjectSchema as ur, CreateMessageResultWithToolsSchema as ut, routes as v, MultiSelectEnumSchemaSchema as vn, SamplingContentSchema as vr, ElicitRequestSchema as vt, PO_MCP_REMOTE_SERVERS_SERVICE as w, OAuthClientMetadataSchema as wn, ServerResultSchema as wr, EmptyResultSchema as wt, VAULT_UNAVAILABLE as x, NumberSchemaSchema as xn, ServerCapabilitiesSchema as xr, ElicitationCompleteNotificationParamsSchema as xt, MCP_FLOW_ID_PARAM as y, NotificationSchema as yn, SamplingMessageContentBlockSchema as yr, ElicitRequestURLParamsSchema as yt, BaseRequestParamsSchema as z, ProgressNotificationParamsSchema as zn, TaskAugmentedRequestParamsSchema as zr, InitializeRequestSchema as zt };
|