zidane 6.4.4 → 6.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/acp-cli.js +7 -6
- package/dist/acp-cli.js.map +1 -1
- package/dist/{acp-BLO58K3F.js → acp-o-LQAjFw.js} +4 -5
- package/dist/{acp-BLO58K3F.js.map → acp-o-LQAjFw.js.map} +1 -1
- package/dist/acp.d.ts +1 -1
- package/dist/acp.js +1 -1
- package/dist/{agent-8sUadp5M.js → agent-BVNkC1h4.js} +886 -113
- package/dist/agent-BVNkC1h4.js.map +1 -0
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +1 -2
- package/dist/{anthropic-D3lkw5mv.js → anthropic-Dov2mC5e.js} +3 -3
- package/dist/{anthropic-D3lkw5mv.js.map → anthropic-Dov2mC5e.js.map} +1 -1
- package/dist/{auth-BzYbbdN_.js → auth-B8ZuBcKC.js} +5 -5
- package/dist/{auth-BzYbbdN_.js.map → auth-B8ZuBcKC.js.map} +1 -1
- package/dist/chat/pure.d.ts +3 -3
- package/dist/chat/pure.js +2 -2
- package/dist/chat.d.ts +13 -44
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +8 -7
- package/dist/chat.js.map +1 -1
- package/dist/{edit-utils-EGosADZq.js → context-breakdown-BLF10tOO.js} +154 -2
- package/dist/context-breakdown-BLF10tOO.js.map +1 -0
- package/dist/{context-transport-D29WvHcm.js → context-transport-D-daWOmp.js} +3 -3
- package/dist/{context-transport-D29WvHcm.js.map → context-transport-D-daWOmp.js.map} +1 -1
- package/dist/contexts/daytona.d.ts +1 -1
- package/dist/contexts/e2b.d.ts +1 -1
- package/dist/eval.d.ts +1 -1
- package/dist/eval.js +1 -1
- package/dist/extensions.d.ts +2 -2
- package/dist/extensions.js +2 -2
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +3 -3
- package/dist/{index-C-Nd2ZbV.d.ts → index-CWBSrqI6.d.ts} +676 -3
- package/dist/index-CWBSrqI6.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +13 -13
- package/dist/{login-CMVVnAHS.js → login-CR3fDHXh.js} +3 -3
- package/dist/{login-CMVVnAHS.js.map → login-CR3fDHXh.js.map} +1 -1
- package/dist/{mcp-3GXUBwur.js → mcp-C6IkXNOS.js} +87 -6
- package/dist/mcp-C6IkXNOS.js.map +1 -0
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +3 -2
- package/dist/{messages-C01kKGj0.js → messages-C_H9soi5.js} +2 -3
- package/dist/{messages-C01kKGj0.js.map → messages-C_H9soi5.js.map} +1 -1
- package/dist/{openai-compat-B3c_hzwf.js → openai-compat-CnHeo4Lz.js} +216 -3
- package/dist/openai-compat-CnHeo4Lz.js.map +1 -0
- package/dist/origin-pinned-fetch-CqG8VZIq.js +159 -0
- package/dist/origin-pinned-fetch-CqG8VZIq.js.map +1 -0
- package/dist/output/stream-json.d.ts +1 -1
- package/dist/output/terminal.d.ts +1 -1
- package/dist/plugins-2PMTVcp-.js +1174 -0
- package/dist/plugins-2PMTVcp-.js.map +1 -0
- package/dist/plugins.d.ts +2 -0
- package/dist/plugins.js +2 -0
- package/dist/presets.d.ts +1 -1
- package/dist/presets.js +1 -1
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +1 -1
- package/dist/providers/arcee.d.ts +1 -1
- package/dist/providers/arcee.js +1 -1
- package/dist/providers/baseten.d.ts +1 -1
- package/dist/providers/baseten.js +1 -1
- package/dist/providers/cerebras.d.ts +1 -1
- package/dist/providers/cerebras.js +1 -1
- package/dist/providers/local.d.ts +1 -1
- package/dist/providers/local.js +1 -1
- package/dist/providers/openai-compat.d.ts +1 -1
- package/dist/providers/openai-compat.js +1 -1
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/openai.js +2 -2
- package/dist/providers/openrouter.d.ts +1 -1
- package/dist/providers/openrouter.js +1 -1
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/xai.js +1 -1
- package/dist/{providers-z1vU0b2Q.js → providers-B6mFe7OD.js} +3 -3
- package/dist/{providers-z1vU0b2Q.js.map → providers-B6mFe7OD.js.map} +1 -1
- package/dist/providers.d.ts +1 -1
- package/dist/providers.js +4 -4
- package/dist/restate.d.ts +178 -2
- package/dist/restate.d.ts.map +1 -1
- package/dist/restate.js +463 -7
- package/dist/restate.js.map +1 -1
- package/dist/session/sqlite.d.ts +1 -1
- package/dist/{session-cr9VdoEO.js → session-VpLrNaFQ.js} +2 -2
- package/dist/{session-cr9VdoEO.js.map → session-VpLrNaFQ.js.map} +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/session.js +2 -2
- package/dist/{resolve-CZJxds85.js → skills-Cp9vnBwd.js} +1430 -1006
- package/dist/skills-Cp9vnBwd.js.map +1 -0
- package/dist/skills.d.ts +1 -1
- package/dist/skills.js +1 -2
- package/dist/{stdio-BvL8HGYW.js → stdio-DzUUkkhS.js} +2 -2
- package/dist/{stdio-BvL8HGYW.js.map → stdio-DzUUkkhS.js.map} +1 -1
- package/dist/{stdio-loader-CjfoqBle.js → stdio-loader-BILyUGmi.js} +2 -2
- package/dist/{stdio-loader-CjfoqBle.js.map → stdio-loader-BILyUGmi.js.map} +1 -1
- package/dist/{tool-formatters-DPQjso_C.d.ts → tool-formatters-gFqQbzPY.d.ts} +2 -2
- package/dist/{tool-formatters-DPQjso_C.d.ts.map → tool-formatters-gFqQbzPY.d.ts.map} +1 -1
- package/dist/tools/fetch-url.d.ts +1 -1
- package/dist/tools/web-search.d.ts +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +1 -2
- package/dist/{transcript-anchors-CgDzYin1.js → transcript-anchors-DEIr0tJC.js} +44 -7
- package/dist/transcript-anchors-DEIr0tJC.js.map +1 -0
- package/dist/{transcript-anchors-BCUpbNxc.d.ts → transcript-anchors-qCs3wZpu.d.ts} +98 -92
- package/dist/transcript-anchors-qCs3wZpu.d.ts.map +1 -0
- package/dist/tui.d.ts +38 -4
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +843 -109
- package/dist/tui.js.map +1 -1
- package/dist/{turn-operations-CAvi8NYt.js → turn-operations-C3IijXMW.js} +2 -2
- package/dist/{turn-operations-CAvi8NYt.js.map → turn-operations-C3IijXMW.js.map} +1 -1
- package/dist/{turn-operations-Bu2Hkinw.d.ts → turn-operations-M9-jUyDd.d.ts} +3 -3
- package/dist/{turn-operations-Bu2Hkinw.d.ts.map → turn-operations-M9-jUyDd.d.ts.map} +1 -1
- package/dist/types-BIarq1qE.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/{xai-BPwMQSuF.js → xai-Du6Wfnlb.js} +2 -2
- package/dist/{xai-BPwMQSuF.js.map → xai-Du6Wfnlb.js.map} +1 -1
- package/docs/PLUGINS.md +340 -0
- package/docs/RESTATE.md +168 -3
- package/docs/SKILL.md +24 -8
- package/package.json +6 -1
- package/dist/agent-8sUadp5M.js.map +0 -1
- package/dist/aliasing-lVFbm81n.js +0 -217
- package/dist/aliasing-lVFbm81n.js.map +0 -1
- package/dist/context-breakdown-Dzo25N45.js +0 -155
- package/dist/context-breakdown-Dzo25N45.js.map +0 -1
- package/dist/edit-utils-EGosADZq.js.map +0 -1
- package/dist/index-C-Nd2ZbV.d.ts.map +0 -1
- package/dist/mcp-3GXUBwur.js.map +0 -1
- package/dist/openai-compat-B3c_hzwf.js.map +0 -1
- package/dist/resolve-CZJxds85.js.map +0 -1
- package/dist/skills-Dd6XCi4s.js +0 -420
- package/dist/skills-Dd6XCi4s.js.map +0 -1
- package/dist/tool-state-DTs-3ZHH.js +0 -653
- package/dist/tool-state-DTs-3ZHH.js.map +0 -1
- package/dist/transcript-anchors-BCUpbNxc.d.ts.map +0 -1
- package/dist/transcript-anchors-CgDzYin1.js.map +0 -1
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
//#region src/mcp/origin-pinned-fetch.ts
|
|
2
|
+
/**
|
|
3
|
+
* `fetch` wrapper that refuses to carry configured headers across an origin
|
|
4
|
+
* boundary.
|
|
5
|
+
*
|
|
6
|
+
* Why this exists
|
|
7
|
+
* ---------------
|
|
8
|
+
* Agent Plugins requires a client to "never forward configured headers to a
|
|
9
|
+
* different origin". A plugin's `mcp.json` routinely puts a bearer token in
|
|
10
|
+
* `headers`, and the platform `fetch` follows redirects internally WITH those
|
|
11
|
+
* headers attached — so a server that answers `307` with
|
|
12
|
+
* `Location: https://attacker.example/` receives the token verbatim. The
|
|
13
|
+
* transport never sees the hop, so the check cannot live at the call site.
|
|
14
|
+
*
|
|
15
|
+
* The fix is to take redirect-following away from the platform: issue the
|
|
16
|
+
* request with `redirect: 'manual'` and walk the chain ourselves, dropping
|
|
17
|
+
* every configured header the instant a hop leaves the pinned origin.
|
|
18
|
+
*
|
|
19
|
+
* Scope
|
|
20
|
+
* -----
|
|
21
|
+
* The strip list is the configured header names PLUS `authorization`, which is
|
|
22
|
+
* always included: the SDK's OAuth provider injects that header per request
|
|
23
|
+
* rather than through `McpServerConfig.headers`, so a list derived only from
|
|
24
|
+
* the config would miss the one credential most worth protecting. See
|
|
25
|
+
* {@link originPinnedFetch} for why that case is the common one.
|
|
26
|
+
*
|
|
27
|
+
* The rest of the per-request plumbing (`content-type`, `accept`,
|
|
28
|
+
* `mcp-session-id`, …) is not credential material and survives — stripping it
|
|
29
|
+
* would break legitimate same-origin redirects for no security gain.
|
|
30
|
+
*
|
|
31
|
+
* A redirect to non-loopback cleartext is refused outright rather than
|
|
32
|
+
* stripped: continuing the session over plain HTTP exposes the MCP traffic
|
|
33
|
+
* itself, not just the token.
|
|
34
|
+
*
|
|
35
|
+
* Composes with {@link sseToJsonFetch}: pass that as `baseFetch` and this
|
|
36
|
+
* wrapper handles each hop through it.
|
|
37
|
+
*/
|
|
38
|
+
/** Redirect statuses the fetch standard defines. */
|
|
39
|
+
const REDIRECT_STATUSES = /* @__PURE__ */ new Set([
|
|
40
|
+
301,
|
|
41
|
+
302,
|
|
42
|
+
303,
|
|
43
|
+
307,
|
|
44
|
+
308
|
|
45
|
+
]);
|
|
46
|
+
/**
|
|
47
|
+
* Hosts whose plaintext HTTP is acceptable. Everything else must be HTTPS —
|
|
48
|
+
* a bearer token in cleartext is published to the local network.
|
|
49
|
+
*
|
|
50
|
+
* Lives here rather than in the Agent Plugins loader because both the
|
|
51
|
+
* load-time URL check and the per-hop redirect check need it, and they sit on
|
|
52
|
+
* opposite sides of that boundary.
|
|
53
|
+
*/
|
|
54
|
+
const LOOPBACK_HOSTS = /* @__PURE__ */ new Set([
|
|
55
|
+
"localhost",
|
|
56
|
+
"127.0.0.1",
|
|
57
|
+
"[::1]",
|
|
58
|
+
"::1"
|
|
59
|
+
]);
|
|
60
|
+
/** True when cleartext HTTP to this hostname stays on the machine. */
|
|
61
|
+
function isLoopbackHost(hostname) {
|
|
62
|
+
return LOOPBACK_HOSTS.has(hostname);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The transport-reachability rule for a remote MCP endpoint: HTTPS anywhere,
|
|
66
|
+
* plaintext HTTP only when it stays on the machine, nothing else.
|
|
67
|
+
*
|
|
68
|
+
* THE single encoding of that policy. It's enforced at two points on opposite
|
|
69
|
+
* sides of the plugin boundary — once when validating a plugin's `mcp.json`
|
|
70
|
+
* (`plugins/mcp.ts`), and again per redirect hop inside
|
|
71
|
+
* {@link originPinnedFetch} — and those two must never disagree. If they did,
|
|
72
|
+
* a URL the loader refused could still be reached by redirect, which is the
|
|
73
|
+
* exact hole the pinning exists to close. Relaxing the rule (private ranges,
|
|
74
|
+
* `*.localhost`, …) is then a one-line change that both sites inherit.
|
|
75
|
+
*
|
|
76
|
+
* Scheme and host only. Authoring rules that apply to a CONFIGURED url but
|
|
77
|
+
* have no meaning for a redirect target — no userinfo, no fragment — stay with
|
|
78
|
+
* the loader.
|
|
79
|
+
*/
|
|
80
|
+
function isAllowedRemoteUrl(url) {
|
|
81
|
+
if (url.protocol === "https:") return true;
|
|
82
|
+
return url.protocol === "http:" && isLoopbackHost(url.hostname);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Cap on hops. The platform default is 20; MCP endpoints legitimately
|
|
86
|
+
* redirect once or twice (http→https, path canonicalization, load-balancer
|
|
87
|
+
* hand-off), so 5 is generous while bounding a redirect loop.
|
|
88
|
+
*/
|
|
89
|
+
const MAX_REDIRECTS = 5;
|
|
90
|
+
/**
|
|
91
|
+
* Wrap `baseFetch` so `headerNames` are dropped on any hop that leaves the
|
|
92
|
+
* origin of `configuredUrl`, and so a redirect cannot downgrade the session
|
|
93
|
+
* to cleartext.
|
|
94
|
+
*
|
|
95
|
+
* `authorization` is ALWAYS protected, whether or not the caller listed it.
|
|
96
|
+
* The MCP SDK's OAuth provider injects that header per request rather than
|
|
97
|
+
* through `McpServerConfig.headers` — `bootstrapServer` attaches a provider to
|
|
98
|
+
* a flagless server whenever stored tokens exist — so a strip list derived
|
|
99
|
+
* only from the configured header names would leave the bearer token exposed
|
|
100
|
+
* on exactly the servers that have one.
|
|
101
|
+
*/
|
|
102
|
+
function originPinnedFetch(configuredUrl, headerNames, baseFetch = fetch) {
|
|
103
|
+
let pinnedOrigin;
|
|
104
|
+
try {
|
|
105
|
+
pinnedOrigin = new URL(configuredUrl).origin;
|
|
106
|
+
} catch {
|
|
107
|
+
return baseFetch;
|
|
108
|
+
}
|
|
109
|
+
const protected_ = [.../* @__PURE__ */ new Set(["authorization", ...headerNames.map((name) => name.toLowerCase())])];
|
|
110
|
+
return async function originPinnedWrappedFetch(input, init) {
|
|
111
|
+
let url = new URL(input.toString());
|
|
112
|
+
let currentInit = {
|
|
113
|
+
...init,
|
|
114
|
+
redirect: "manual"
|
|
115
|
+
};
|
|
116
|
+
let stripped = false;
|
|
117
|
+
for (let hop = 0; hop <= MAX_REDIRECTS; hop++) {
|
|
118
|
+
const response = await baseFetch(url, currentInit);
|
|
119
|
+
if (!REDIRECT_STATUSES.has(response.status)) return response;
|
|
120
|
+
const location = response.headers.get("location");
|
|
121
|
+
if (!location) return response;
|
|
122
|
+
let next;
|
|
123
|
+
try {
|
|
124
|
+
next = new URL(location, url);
|
|
125
|
+
} catch {
|
|
126
|
+
return response;
|
|
127
|
+
}
|
|
128
|
+
if (!isAllowedRemoteUrl(next)) throw new Error(`Refusing redirect from ${url.origin} to ${next.protocol}//${next.host || next.pathname}`);
|
|
129
|
+
if (next.origin !== pinnedOrigin && !stripped) {
|
|
130
|
+
currentInit = {
|
|
131
|
+
...currentInit,
|
|
132
|
+
headers: withoutHeaders(currentInit.headers, protected_)
|
|
133
|
+
};
|
|
134
|
+
stripped = true;
|
|
135
|
+
}
|
|
136
|
+
const method = (currentInit.method ?? "GET").toString().toUpperCase();
|
|
137
|
+
if (response.status === 303 || (response.status === 301 || response.status === 302) && method === "POST") currentInit = {
|
|
138
|
+
...currentInit,
|
|
139
|
+
method: "GET",
|
|
140
|
+
body: void 0
|
|
141
|
+
};
|
|
142
|
+
url = next;
|
|
143
|
+
}
|
|
144
|
+
throw new Error(`Too many redirects (>${MAX_REDIRECTS}) following ${configuredUrl}`);
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Copy a `HeadersInit` minus the named headers. Handles all three
|
|
149
|
+
* `HeadersInit` shapes the SDK may hand us (Headers, tuple array, record).
|
|
150
|
+
*/
|
|
151
|
+
function withoutHeaders(source, remove) {
|
|
152
|
+
const headers = new Headers(source);
|
|
153
|
+
for (const name of remove) headers.delete(name);
|
|
154
|
+
return headers;
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
export { originPinnedFetch as n, isAllowedRemoteUrl as t };
|
|
158
|
+
|
|
159
|
+
//# sourceMappingURL=origin-pinned-fetch-CqG8VZIq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"origin-pinned-fetch-CqG8VZIq.js","names":[],"sources":["../src/mcp/origin-pinned-fetch.ts"],"sourcesContent":["/**\n * `fetch` wrapper that refuses to carry configured headers across an origin\n * boundary.\n *\n * Why this exists\n * ---------------\n * Agent Plugins requires a client to \"never forward configured headers to a\n * different origin\". A plugin's `mcp.json` routinely puts a bearer token in\n * `headers`, and the platform `fetch` follows redirects internally WITH those\n * headers attached — so a server that answers `307` with\n * `Location: https://attacker.example/` receives the token verbatim. The\n * transport never sees the hop, so the check cannot live at the call site.\n *\n * The fix is to take redirect-following away from the platform: issue the\n * request with `redirect: 'manual'` and walk the chain ourselves, dropping\n * every configured header the instant a hop leaves the pinned origin.\n *\n * Scope\n * -----\n * The strip list is the configured header names PLUS `authorization`, which is\n * always included: the SDK's OAuth provider injects that header per request\n * rather than through `McpServerConfig.headers`, so a list derived only from\n * the config would miss the one credential most worth protecting. See\n * {@link originPinnedFetch} for why that case is the common one.\n *\n * The rest of the per-request plumbing (`content-type`, `accept`,\n * `mcp-session-id`, …) is not credential material and survives — stripping it\n * would break legitimate same-origin redirects for no security gain.\n *\n * A redirect to non-loopback cleartext is refused outright rather than\n * stripped: continuing the session over plain HTTP exposes the MCP traffic\n * itself, not just the token.\n *\n * Composes with {@link sseToJsonFetch}: pass that as `baseFetch` and this\n * wrapper handles each hop through it.\n */\n\n/** Redirect statuses the fetch standard defines. */\nconst REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308])\n\n/**\n * Hosts whose plaintext HTTP is acceptable. Everything else must be HTTPS —\n * a bearer token in cleartext is published to the local network.\n *\n * Lives here rather than in the Agent Plugins loader because both the\n * load-time URL check and the per-hop redirect check need it, and they sit on\n * opposite sides of that boundary.\n */\nconst LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1'])\n\n/** True when cleartext HTTP to this hostname stays on the machine. */\nexport function isLoopbackHost(hostname: string): boolean {\n return LOOPBACK_HOSTS.has(hostname)\n}\n\n/**\n * The transport-reachability rule for a remote MCP endpoint: HTTPS anywhere,\n * plaintext HTTP only when it stays on the machine, nothing else.\n *\n * THE single encoding of that policy. It's enforced at two points on opposite\n * sides of the plugin boundary — once when validating a plugin's `mcp.json`\n * (`plugins/mcp.ts`), and again per redirect hop inside\n * {@link originPinnedFetch} — and those two must never disagree. If they did,\n * a URL the loader refused could still be reached by redirect, which is the\n * exact hole the pinning exists to close. Relaxing the rule (private ranges,\n * `*.localhost`, …) is then a one-line change that both sites inherit.\n *\n * Scheme and host only. Authoring rules that apply to a CONFIGURED url but\n * have no meaning for a redirect target — no userinfo, no fragment — stay with\n * the loader.\n */\nexport function isAllowedRemoteUrl(url: URL): boolean {\n if (url.protocol === 'https:')\n return true\n return url.protocol === 'http:' && isLoopbackHost(url.hostname)\n}\n\n/**\n * Cap on hops. The platform default is 20; MCP endpoints legitimately\n * redirect once or twice (http→https, path canonicalization, load-balancer\n * hand-off), so 5 is generous while bounding a redirect loop.\n */\nconst MAX_REDIRECTS = 5\n\n/**\n * The fetch shape this wrapper supports — deliberately narrower than\n * `typeof fetch`, matching the MCP SDK's `FetchLike`.\n *\n * A `Request` input is NOT accepted: the wrapper rebuilds each hop from\n * `init`, so it would silently drop a Request's method, headers and body and\n * issue a bare credential-less GET. Narrowing the type makes that shape\n * unrepresentable rather than a quiet failure on a security-relevant helper.\n * Both SDK transports only ever pass a URL plus init.\n */\nexport type PinnedFetch = (url: string | URL, init?: RequestInit) => Promise<Response>\n\n/**\n * Wrap `baseFetch` so `headerNames` are dropped on any hop that leaves the\n * origin of `configuredUrl`, and so a redirect cannot downgrade the session\n * to cleartext.\n *\n * `authorization` is ALWAYS protected, whether or not the caller listed it.\n * The MCP SDK's OAuth provider injects that header per request rather than\n * through `McpServerConfig.headers` — `bootstrapServer` attaches a provider to\n * a flagless server whenever stored tokens exist — so a strip list derived\n * only from the configured header names would leave the bearer token exposed\n * on exactly the servers that have one.\n */\nexport function originPinnedFetch(\n configuredUrl: string,\n headerNames: readonly string[],\n baseFetch: PinnedFetch = fetch,\n): PinnedFetch {\n let pinnedOrigin: string\n try {\n pinnedOrigin = new URL(configuredUrl).origin\n }\n catch {\n // An unparseable URL fails at the transport anyway; don't mask that\n // error with one of ours.\n return baseFetch\n }\n\n // Lowercased for case-insensitive header matching (HTTP header names are\n // case-insensitive; `Headers.delete` already normalizes, but the manual\n // record path below does not). `authorization` is unconditional — see the\n // doc comment.\n const protected_ = [...new Set(['authorization', ...headerNames.map(name => name.toLowerCase())])]\n\n return async function originPinnedWrappedFetch(input, init) {\n let url = new URL(input.toString())\n let currentInit: RequestInit = { ...init, redirect: 'manual' }\n let stripped = false\n\n for (let hop = 0; hop <= MAX_REDIRECTS; hop++) {\n const response = await baseFetch(url, currentInit)\n if (!REDIRECT_STATUSES.has(response.status))\n return response\n\n const location = response.headers.get('location')\n if (!location)\n return response // redirect status with no target — hand it back as-is\n\n let next: URL\n try {\n next = new URL(location, url)\n }\n catch {\n return response\n }\n\n // A redirect must not reach a URL the configured one would have been\n // refused for — same predicate the loader validates `mcp.json` with, so\n // the two can't drift.\n //\n // Stripping credentials is not a sufficient response here — continuing\n // the session over cleartext exposes the MCP traffic itself, and a\n // non-http scheme (`file:`, `data:`) isn't a transport we ever intended\n // to hand `baseFetch`. The platform `fetch` happens to reject unsupported\n // protocols today, but this module exists precisely to stop delegating\n // redirect decisions to it, and `baseFetch` is injectable.\n if (!isAllowedRemoteUrl(next))\n throw new Error(`Refusing redirect from ${url.origin} to ${next.protocol}//${next.host || next.pathname}`)\n\n if (next.origin !== pinnedOrigin && !stripped) {\n currentInit = { ...currentInit, headers: withoutHeaders(currentInit.headers, protected_) }\n stripped = true\n }\n\n // Per the fetch standard: 303 always becomes GET, and 301/302 become\n // GET when the original request was a POST. A body cannot ride along\n // on a GET, so drop it too.\n const method = (currentInit.method ?? 'GET').toString().toUpperCase()\n if (response.status === 303 || ((response.status === 301 || response.status === 302) && method === 'POST'))\n currentInit = { ...currentInit, method: 'GET', body: undefined }\n\n url = next\n }\n\n throw new Error(`Too many redirects (>${MAX_REDIRECTS}) following ${configuredUrl}`)\n }\n}\n\n/**\n * Copy a `HeadersInit` minus the named headers. Handles all three\n * `HeadersInit` shapes the SDK may hand us (Headers, tuple array, record).\n */\nfunction withoutHeaders(source: HeadersInit | undefined, remove: readonly string[]): HeadersInit {\n const headers = new Headers(source)\n for (const name of remove)\n headers.delete(name)\n return headers\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,oCAAoB,IAAI,IAAI;CAAC;CAAK;CAAK;CAAK;CAAK;AAAG,CAAC;;;;;;;;;AAU3D,MAAM,iCAAiB,IAAI,IAAI;CAAC;CAAa;CAAa;CAAS;AAAK,CAAC;;AAGzE,SAAgB,eAAe,UAA2B;CACxD,OAAO,eAAe,IAAI,QAAQ;AACpC;;;;;;;;;;;;;;;;;AAkBA,SAAgB,mBAAmB,KAAmB;CACpD,IAAI,IAAI,aAAa,UACnB,OAAO;CACT,OAAO,IAAI,aAAa,WAAW,eAAe,IAAI,QAAQ;AAChE;;;;;;AAOA,MAAM,gBAAgB;;;;;;;;;;;;;AA0BtB,SAAgB,kBACd,eACA,aACA,YAAyB,OACZ;CACb,IAAI;CACJ,IAAI;EACF,eAAe,IAAI,IAAI,aAAa,CAAC,CAAC;CACxC,QACM;EAGJ,OAAO;CACT;CAMA,MAAM,aAAa,CAAC,mBAAG,IAAI,IAAI,CAAC,iBAAiB,GAAG,YAAY,KAAI,SAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC;CAEjG,OAAO,eAAe,yBAAyB,OAAO,MAAM;EAC1D,IAAI,MAAM,IAAI,IAAI,MAAM,SAAS,CAAC;EAClC,IAAI,cAA2B;GAAE,GAAG;GAAM,UAAU;EAAS;EAC7D,IAAI,WAAW;EAEf,KAAK,IAAI,MAAM,GAAG,OAAO,eAAe,OAAO;GAC7C,MAAM,WAAW,MAAM,UAAU,KAAK,WAAW;GACjD,IAAI,CAAC,kBAAkB,IAAI,SAAS,MAAM,GACxC,OAAO;GAET,MAAM,WAAW,SAAS,QAAQ,IAAI,UAAU;GAChD,IAAI,CAAC,UACH,OAAO;GAET,IAAI;GACJ,IAAI;IACF,OAAO,IAAI,IAAI,UAAU,GAAG;GAC9B,QACM;IACJ,OAAO;GACT;GAYA,IAAI,CAAC,mBAAmB,IAAI,GAC1B,MAAM,IAAI,MAAM,0BAA0B,IAAI,OAAO,MAAM,KAAK,SAAS,IAAI,KAAK,QAAQ,KAAK,UAAU;GAE3G,IAAI,KAAK,WAAW,gBAAgB,CAAC,UAAU;IAC7C,cAAc;KAAE,GAAG;KAAa,SAAS,eAAe,YAAY,SAAS,UAAU;IAAE;IACzF,WAAW;GACb;GAKA,MAAM,UAAU,YAAY,UAAU,MAAA,CAAO,SAAS,CAAC,CAAC,YAAY;GACpE,IAAI,SAAS,WAAW,QAAS,SAAS,WAAW,OAAO,SAAS,WAAW,QAAQ,WAAW,QACjG,cAAc;IAAE,GAAG;IAAa,QAAQ;IAAO,MAAM,KAAA;GAAU;GAEjE,MAAM;EACR;EAEA,MAAM,IAAI,MAAM,wBAAwB,cAAc,cAAc,eAAe;CACrF;AACF;;;;;AAMA,SAAS,eAAe,QAAiC,QAAwC;CAC/F,MAAM,UAAU,IAAI,QAAQ,MAAM;CAClC,KAAK,MAAM,QAAQ,QACjB,QAAQ,OAAO,IAAI;CACrB,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $n as HeadlessResult, Jn as FormattedHeadlessTurnEvent, Qn as HeadlessOutputFormat, Wi as Agent, Xn as HeadlessEvent, qn as FormattedHeadlessResult } from "../index-
|
|
1
|
+
import { $n as HeadlessResult, Jn as FormattedHeadlessTurnEvent, Qn as HeadlessOutputFormat, Wi as Agent, Xn as HeadlessEvent, qn as FormattedHeadlessResult } from "../index-CWBSrqI6.js";
|
|
2
2
|
|
|
3
3
|
//#region src/output/stream-json.d.ts
|
|
4
4
|
type StreamJsonOutputFormat = HeadlessOutputFormat;
|