@hintergrund/ui 0.3.10 → 0.3.12
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 +6 -55
- package/dist/BuilderAgentPane-BEPxOdtX.js +1 -0
- package/dist/IntegrationHealth-DlJvUzAy.js +1 -0
- package/dist/Mail-CO8ofiRH.js +1 -0
- package/dist/admin.js +2 -23351
- package/dist/anthropic-messages-55IP99zJ.js +2 -0
- package/dist/builder.js +1 -28
- package/dist/config.types-D99vLLC0.js +1 -0
- package/dist/error-body-B13t5xBI.js +1 -0
- package/dist/github-copilot-headers-EfqOaQ0F.js +1 -0
- package/dist/global-CGDFyqFU.js +2 -0
- package/dist/google-generative-ai-CpvpostP.js +1 -0
- package/dist/invoice-pdf-BT1piHr5.js +5 -0
- package/dist/login.js +1 -133
- package/dist/mail.js +1 -698
- package/dist/node.browser-BA-G-7jw.js +1 -0
- package/dist/node.browser-DFm1vJzK.js +1 -0
- package/dist/openai-completions-BomoAgqc.js +1 -0
- package/dist/openai-decisions-D-Vz80po.js +1 -0
- package/dist/openai-prompt-cache-C4mUbgCW.js +1 -0
- package/dist/openai-responses-DmFfjUOu.js +1 -0
- package/dist/provider-retry-DNH2SSUZ.js +1 -0
- package/dist/rolldown-runtime-9urLBz53.js +1 -0
- package/dist/setup.js +1 -402
- package/dist/transform-messages-DBJvNMd6.js +1 -0
- package/package.json +7 -5
- package/dist/BuilderAgentPane-B6zkx8zw.js +0 -23164
- package/dist/IntegrationHealth-2p7QXJqB.js +0 -218
- package/dist/anthropic-messages-k-Bsbioz.js +0 -3772
- package/dist/azure-openai-responses-DZenJI-m.js +0 -168
- package/dist/config.types-DZ5yfeqq.js +0 -20
- package/dist/deferred-tools-nxpq94I4.js +0 -34
- package/dist/diagnostics-x5QOwca_.js +0 -91
- package/dist/error-body-pXgvw5vV.js +0 -68
- package/dist/font-pool/LICENSES.txt +0 -22
- package/dist/font-pool/inter.ttf +0 -0
- package/dist/font-pool/inter.woff2 +0 -0
- package/dist/font-pool/jetbrains-mono.ttf +0 -0
- package/dist/font-pool/jetbrains-mono.woff2 +0 -0
- package/dist/font-pool/lora.ttf +0 -0
- package/dist/font-pool/lora.woff2 +0 -0
- package/dist/font-pool/merriweather.ttf +0 -0
- package/dist/font-pool/merriweather.woff2 +0 -0
- package/dist/font-pool/montserrat.ttf +0 -0
- package/dist/font-pool/montserrat.woff2 +0 -0
- package/dist/font-pool/playfair-display.ttf +0 -0
- package/dist/font-pool/playfair-display.woff2 +0 -0
- package/dist/font-pool/poppins.ttf +0 -0
- package/dist/font-pool/poppins.woff2 +0 -0
- package/dist/font-pool/roboto.ttf +0 -0
- package/dist/font-pool/roboto.woff2 +0 -0
- package/dist/font-pool/space-grotesk.ttf +0 -0
- package/dist/font-pool/space-grotesk.woff2 +0 -0
- package/dist/font-pool/work-sans.ttf +0 -0
- package/dist/font-pool/work-sans.woff2 +0 -0
- package/dist/github-copilot-headers-pRo3v4t7.js +0 -27
- package/dist/global-DMXVTUMq.js +0 -33351
- package/dist/google-generative-ai-D2RQTVlL.js +0 -291
- package/dist/google-shared-CG2Lbh1z.js +0 -8746
- package/dist/google-vertex-BjniYIZ1.js +0 -329
- package/dist/hash-BixfZjoG.js +0 -21
- package/dist/headers-CnTiKpOL.js +0 -24
- package/dist/json-parse-CxjAnWaM.js +0 -231
- package/dist/legacy-C2ziK2Om.js +0 -14
- package/dist/mistral-conversations-CPZ7CuMx.js +0 -558
- package/dist/openai-ClxLHXsh.js +0 -5371
- package/dist/openai-codex-responses-CqmMU3UY.js +0 -909
- package/dist/openai-completions-Dc8OEKqJ.js +0 -730
- package/dist/openai-prompt-cache-Bm8Re6Vv.js +0 -17
- package/dist/openai-responses-DZ1U8uxZ.js +0 -192
- package/dist/openai-responses-shared-B0rkV1lD.js +0 -481
- package/dist/pi-messages-CRx0yqMp.js +0 -268
- package/dist/pi-user-agent-CsXkkH60.js +0 -20
- package/dist/provider-env-Cj6X7Wly.js +0 -35
- package/dist/provider-retry-BGImU1PV.js +0 -68
- package/dist/rolldown-runtime-nTTD767F.js +0 -37
- package/dist/transform-messages-DvxSeyBQ.js +0 -383
|
@@ -1,3772 +0,0 @@
|
|
|
1
|
-
globalThis.process === void 0 && (globalThis.process = {
|
|
2
|
-
env: {},
|
|
3
|
-
platform: "browser",
|
|
4
|
-
version: "",
|
|
5
|
-
versions: {},
|
|
6
|
-
browser: !0,
|
|
7
|
-
nextTick: function(e) {
|
|
8
|
-
return Promise.resolve().then(e);
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
import { p as e } from "./BuilderAgentPane-B6zkx8zw.js";
|
|
12
|
-
import { i as t } from "./diagnostics-x5QOwca_.js";
|
|
13
|
-
import { n, t as r } from "./json-parse-CxjAnWaM.js";
|
|
14
|
-
import { t as i } from "./provider-env-Cj6X7Wly.js";
|
|
15
|
-
import { t as a } from "./deferred-tools-nxpq94I4.js";
|
|
16
|
-
import { t as o } from "./headers-CnTiKpOL.js";
|
|
17
|
-
import { t as s } from "./pi-user-agent-CsXkkH60.js";
|
|
18
|
-
import { t as c } from "./provider-retry-BGImU1PV.js";
|
|
19
|
-
import { a as l, f as u, i as d, p as f, r as p, t as m, u as h } from "./transform-messages-DvxSeyBQ.js";
|
|
20
|
-
import { n as ee, t as te } from "./github-copilot-headers-pRo3v4t7.js";
|
|
21
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/tslib.mjs
|
|
22
|
-
function g(e, t, n, r, i) {
|
|
23
|
-
if (r === "m") throw TypeError("Private method is not writable");
|
|
24
|
-
if (r === "a" && !i) throw TypeError("Private accessor was defined without a setter");
|
|
25
|
-
if (typeof t == "function" ? e !== t || !i : !t.has(e)) throw TypeError("Cannot write private member to an object whose class did not declare it");
|
|
26
|
-
return r === "a" ? i.call(e, n) : i ? i.value = n : t.set(e, n), n;
|
|
27
|
-
}
|
|
28
|
-
function _(e, t, n, r) {
|
|
29
|
-
if (n === "a" && !r) throw TypeError("Private accessor was defined without a getter");
|
|
30
|
-
if (typeof t == "function" ? e !== t || !r : !t.has(e)) throw TypeError("Cannot read private member from an object whose class did not declare it");
|
|
31
|
-
return n === "m" ? r : n === "a" ? r.call(e) : r ? r.value : t.get(e);
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/utils/uuid.mjs
|
|
35
|
-
var ne = function() {
|
|
36
|
-
let { crypto: e } = globalThis;
|
|
37
|
-
if (e?.randomUUID) return ne = e.randomUUID.bind(e), e.randomUUID();
|
|
38
|
-
let t = /* @__PURE__ */ new Uint8Array(1), n = e ? () => e.getRandomValues(t)[0] : () => Math.random() * 255 & 255;
|
|
39
|
-
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (e) => (+e ^ n() & 15 >> e / 4).toString(16));
|
|
40
|
-
};
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/errors.mjs
|
|
43
|
-
function v(e) {
|
|
44
|
-
return typeof e == "object" && !!e && ("name" in e && e.name === "AbortError" || "message" in e && String(e.message).includes("FetchRequestCanceledException"));
|
|
45
|
-
}
|
|
46
|
-
var re = (e) => {
|
|
47
|
-
if (e instanceof Error) return e;
|
|
48
|
-
if (typeof e == "object" && e) {
|
|
49
|
-
try {
|
|
50
|
-
if (Object.prototype.toString.call(e) === "[object Error]") {
|
|
51
|
-
let t = Error(e.message, e.cause ? { cause: e.cause } : {});
|
|
52
|
-
return e.stack && (t.stack = e.stack), e.cause && !t.cause && (t.cause = e.cause), e.name && (t.name = e.name), t;
|
|
53
|
-
}
|
|
54
|
-
} catch {}
|
|
55
|
-
try {
|
|
56
|
-
return Error(JSON.stringify(e));
|
|
57
|
-
} catch {}
|
|
58
|
-
}
|
|
59
|
-
return Error(e);
|
|
60
|
-
}, y = class extends Error {}, b = class e extends y {
|
|
61
|
-
constructor(t, n, r, i, a) {
|
|
62
|
-
super(`${e.makeMessage(t, n, r)}`), this.status = t, this.headers = i, this.requestID = i?.get("request-id"), this.error = n, this.type = a ?? null;
|
|
63
|
-
}
|
|
64
|
-
static makeMessage(e, t, n) {
|
|
65
|
-
let r = t?.message ? typeof t.message == "string" ? t.message : JSON.stringify(t.message) : t ? JSON.stringify(t) : n;
|
|
66
|
-
return e && r ? `${e} ${r}` : e ? `${e} status code (no body)` : r || "(no status code or body)";
|
|
67
|
-
}
|
|
68
|
-
static generate(t, n, r, i) {
|
|
69
|
-
if (!t || !i) return new ie({
|
|
70
|
-
message: r,
|
|
71
|
-
cause: re(n)
|
|
72
|
-
});
|
|
73
|
-
let a = n, o = a?.error?.type;
|
|
74
|
-
return t === 400 ? new oe(t, a, r, i, o) : t === 401 ? new se(t, a, r, i, o) : t === 403 ? new ce(t, a, r, i, o) : t === 404 ? new le(t, a, r, i, o) : t === 409 ? new ue(t, a, r, i, o) : t === 422 ? new de(t, a, r, i, o) : t === 429 ? new fe(t, a, r, i, o) : t >= 500 ? new pe(t, a, r, i, o) : new e(t, a, r, i, o);
|
|
75
|
-
}
|
|
76
|
-
}, x = class extends b {
|
|
77
|
-
constructor({ message: e } = {}) {
|
|
78
|
-
super(void 0, void 0, e || "Request was aborted.", void 0);
|
|
79
|
-
}
|
|
80
|
-
}, ie = class extends b {
|
|
81
|
-
constructor({ message: e, cause: t }) {
|
|
82
|
-
super(void 0, void 0, e || "Connection error.", void 0), t && (this.cause = t);
|
|
83
|
-
}
|
|
84
|
-
}, ae = class extends ie {
|
|
85
|
-
constructor({ message: e } = {}) {
|
|
86
|
-
super({ message: e ?? "Request timed out." });
|
|
87
|
-
}
|
|
88
|
-
}, oe = class extends b {}, se = class extends b {}, ce = class extends b {}, le = class extends b {}, ue = class extends b {}, de = class extends b {}, fe = class extends b {}, pe = class extends b {}, me = /^[a-z][a-z0-9+.-]*:/i, he = (e) => me.test(e), ge = (e) => (ge = Array.isArray, ge(e)), _e = ge;
|
|
89
|
-
function ve(e) {
|
|
90
|
-
return typeof e == "object" ? e ?? {} : {};
|
|
91
|
-
}
|
|
92
|
-
function ye(e) {
|
|
93
|
-
if (!e) return !0;
|
|
94
|
-
for (let t in e) return !1;
|
|
95
|
-
return !0;
|
|
96
|
-
}
|
|
97
|
-
function be(e, t) {
|
|
98
|
-
return Object.prototype.hasOwnProperty.call(e, t);
|
|
99
|
-
}
|
|
100
|
-
var xe = (e, t) => {
|
|
101
|
-
if (typeof t != "number" || !Number.isInteger(t)) throw new y(`${e} must be an integer`);
|
|
102
|
-
if (t < 0) throw new y(`${e} must be a positive integer`);
|
|
103
|
-
return t;
|
|
104
|
-
}, Se = (e) => {
|
|
105
|
-
try {
|
|
106
|
-
return JSON.parse(e);
|
|
107
|
-
} catch {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
}, Ce = (e) => new Promise((t) => setTimeout(t, e)), S = "0.91.1", we = () => typeof window < "u" && window.document !== void 0 && typeof navigator < "u";
|
|
111
|
-
function Te() {
|
|
112
|
-
return typeof Deno < "u" && Deno.build != null ? "deno" : typeof EdgeRuntime < "u" ? "edge" : Object.prototype.toString.call(globalThis.process === void 0 ? 0 : globalThis.process) === "[object process]" ? "node" : "unknown";
|
|
113
|
-
}
|
|
114
|
-
var Ee = () => {
|
|
115
|
-
let e = Te();
|
|
116
|
-
if (e === "deno") return {
|
|
117
|
-
"X-Stainless-Lang": "js",
|
|
118
|
-
"X-Stainless-Package-Version": S,
|
|
119
|
-
"X-Stainless-OS": ke(Deno.build.os),
|
|
120
|
-
"X-Stainless-Arch": Oe(Deno.build.arch),
|
|
121
|
-
"X-Stainless-Runtime": "deno",
|
|
122
|
-
"X-Stainless-Runtime-Version": typeof Deno.version == "string" ? Deno.version : Deno.version?.deno ?? "unknown"
|
|
123
|
-
};
|
|
124
|
-
if (typeof EdgeRuntime < "u") return {
|
|
125
|
-
"X-Stainless-Lang": "js",
|
|
126
|
-
"X-Stainless-Package-Version": S,
|
|
127
|
-
"X-Stainless-OS": "Unknown",
|
|
128
|
-
"X-Stainless-Arch": `other:${EdgeRuntime}`,
|
|
129
|
-
"X-Stainless-Runtime": "edge",
|
|
130
|
-
"X-Stainless-Runtime-Version": globalThis.process.version
|
|
131
|
-
};
|
|
132
|
-
if (e === "node") return {
|
|
133
|
-
"X-Stainless-Lang": "js",
|
|
134
|
-
"X-Stainless-Package-Version": S,
|
|
135
|
-
"X-Stainless-OS": ke(globalThis.process.platform ?? "unknown"),
|
|
136
|
-
"X-Stainless-Arch": Oe(globalThis.process.arch ?? "unknown"),
|
|
137
|
-
"X-Stainless-Runtime": "node",
|
|
138
|
-
"X-Stainless-Runtime-Version": globalThis.process.version ?? "unknown"
|
|
139
|
-
};
|
|
140
|
-
let t = De();
|
|
141
|
-
return t ? {
|
|
142
|
-
"X-Stainless-Lang": "js",
|
|
143
|
-
"X-Stainless-Package-Version": S,
|
|
144
|
-
"X-Stainless-OS": "Unknown",
|
|
145
|
-
"X-Stainless-Arch": "unknown",
|
|
146
|
-
"X-Stainless-Runtime": `browser:${t.browser}`,
|
|
147
|
-
"X-Stainless-Runtime-Version": t.version
|
|
148
|
-
} : {
|
|
149
|
-
"X-Stainless-Lang": "js",
|
|
150
|
-
"X-Stainless-Package-Version": S,
|
|
151
|
-
"X-Stainless-OS": "Unknown",
|
|
152
|
-
"X-Stainless-Arch": "unknown",
|
|
153
|
-
"X-Stainless-Runtime": "unknown",
|
|
154
|
-
"X-Stainless-Runtime-Version": "unknown"
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
function De() {
|
|
158
|
-
if (typeof navigator > "u" || !navigator) return null;
|
|
159
|
-
for (let { key: e, pattern: t } of [
|
|
160
|
-
{
|
|
161
|
-
key: "edge",
|
|
162
|
-
pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
key: "ie",
|
|
166
|
-
pattern: /MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
key: "ie",
|
|
170
|
-
pattern: /Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
key: "chrome",
|
|
174
|
-
pattern: /Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
key: "firefox",
|
|
178
|
-
pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
key: "safari",
|
|
182
|
-
pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/
|
|
183
|
-
}
|
|
184
|
-
]) {
|
|
185
|
-
let n = t.exec(navigator.userAgent);
|
|
186
|
-
if (n) return {
|
|
187
|
-
browser: e,
|
|
188
|
-
version: `${n[1] || 0}.${n[2] || 0}.${n[3] || 0}`
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
var Oe = (e) => e === "x32" ? "x32" : e === "x86_64" || e === "x64" ? "x64" : e === "arm" ? "arm" : e === "aarch64" || e === "arm64" ? "arm64" : e ? `other:${e}` : "unknown", ke = (e) => (e = e.toLowerCase(), e.includes("ios") ? "iOS" : e === "android" ? "Android" : e === "darwin" ? "MacOS" : e === "win32" ? "Windows" : e === "freebsd" ? "FreeBSD" : e === "openbsd" ? "OpenBSD" : e === "linux" ? "Linux" : e ? `Other:${e}` : "Unknown"), Ae, je = () => Ae ??= Ee();
|
|
194
|
-
//#endregion
|
|
195
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/shims.mjs
|
|
196
|
-
function Me() {
|
|
197
|
-
if (typeof fetch < "u") return fetch;
|
|
198
|
-
throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`");
|
|
199
|
-
}
|
|
200
|
-
function Ne(...e) {
|
|
201
|
-
let t = globalThis.ReadableStream;
|
|
202
|
-
if (t === void 0) throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");
|
|
203
|
-
return new t(...e);
|
|
204
|
-
}
|
|
205
|
-
function Pe(e) {
|
|
206
|
-
let t = Symbol.asyncIterator in e ? e[Symbol.asyncIterator]() : e[Symbol.iterator]();
|
|
207
|
-
return Ne({
|
|
208
|
-
start() {},
|
|
209
|
-
async pull(e) {
|
|
210
|
-
let { done: n, value: r } = await t.next();
|
|
211
|
-
n ? e.close() : e.enqueue(r);
|
|
212
|
-
},
|
|
213
|
-
async cancel() {
|
|
214
|
-
await t.return?.();
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
function Fe(e) {
|
|
219
|
-
if (e[Symbol.asyncIterator]) return e;
|
|
220
|
-
let t = e.getReader();
|
|
221
|
-
return {
|
|
222
|
-
async next() {
|
|
223
|
-
try {
|
|
224
|
-
let e = await t.read();
|
|
225
|
-
return e?.done && t.releaseLock(), e;
|
|
226
|
-
} catch (e) {
|
|
227
|
-
throw t.releaseLock(), e;
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
async return() {
|
|
231
|
-
let e = t.cancel();
|
|
232
|
-
return t.releaseLock(), await e, {
|
|
233
|
-
done: !0,
|
|
234
|
-
value: void 0
|
|
235
|
-
};
|
|
236
|
-
},
|
|
237
|
-
[Symbol.asyncIterator]() {
|
|
238
|
-
return this;
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
async function Ie(e) {
|
|
243
|
-
if (typeof e != "object" || !e) return;
|
|
244
|
-
if (e[Symbol.asyncIterator]) {
|
|
245
|
-
await e[Symbol.asyncIterator]().return?.();
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
let t = e.getReader(), n = t.cancel();
|
|
249
|
-
t.releaseLock(), await n;
|
|
250
|
-
}
|
|
251
|
-
//#endregion
|
|
252
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/request-options.mjs
|
|
253
|
-
var Le = ({ headers: e, body: t }) => ({
|
|
254
|
-
bodyHeaders: { "content-type": "application/json" },
|
|
255
|
-
body: JSON.stringify(t)
|
|
256
|
-
});
|
|
257
|
-
//#endregion
|
|
258
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/utils/query.mjs
|
|
259
|
-
function Re(e) {
|
|
260
|
-
return Object.entries(e).filter(([e, t]) => t !== void 0).map(([e, t]) => {
|
|
261
|
-
if (typeof t == "string" || typeof t == "number" || typeof t == "boolean") return `${encodeURIComponent(e)}=${encodeURIComponent(t)}`;
|
|
262
|
-
if (t === null) return `${encodeURIComponent(e)}=`;
|
|
263
|
-
throw new y(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
|
|
264
|
-
}).join("&");
|
|
265
|
-
}
|
|
266
|
-
//#endregion
|
|
267
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/utils/bytes.mjs
|
|
268
|
-
function ze(e) {
|
|
269
|
-
let t = 0;
|
|
270
|
-
for (let n of e) t += n.length;
|
|
271
|
-
let n = new Uint8Array(t), r = 0;
|
|
272
|
-
for (let t of e) n.set(t, r), r += t.length;
|
|
273
|
-
return n;
|
|
274
|
-
}
|
|
275
|
-
var Be;
|
|
276
|
-
function Ve(e) {
|
|
277
|
-
let t;
|
|
278
|
-
return (Be ??= (t = new globalThis.TextEncoder(), t.encode.bind(t)))(e);
|
|
279
|
-
}
|
|
280
|
-
var He;
|
|
281
|
-
function Ue(e) {
|
|
282
|
-
let t;
|
|
283
|
-
return (He ??= (t = new globalThis.TextDecoder(), t.decode.bind(t)))(e);
|
|
284
|
-
}
|
|
285
|
-
//#endregion
|
|
286
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/decoders/line.mjs
|
|
287
|
-
var C, w, We = class {
|
|
288
|
-
constructor() {
|
|
289
|
-
C.set(this, void 0), w.set(this, void 0), g(this, C, /* @__PURE__ */ new Uint8Array(), "f"), g(this, w, null, "f");
|
|
290
|
-
}
|
|
291
|
-
decode(e) {
|
|
292
|
-
if (e == null) return [];
|
|
293
|
-
let t = e instanceof ArrayBuffer ? new Uint8Array(e) : typeof e == "string" ? Ve(e) : e;
|
|
294
|
-
g(this, C, ze([_(this, C, "f"), t]), "f");
|
|
295
|
-
let n = [], r;
|
|
296
|
-
for (; (r = Ge(_(this, C, "f"), _(this, w, "f"))) != null;) {
|
|
297
|
-
if (r.carriage && _(this, w, "f") == null) {
|
|
298
|
-
g(this, w, r.index, "f");
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
if (_(this, w, "f") != null && (r.index !== _(this, w, "f") + 1 || r.carriage)) {
|
|
302
|
-
n.push(Ue(_(this, C, "f").subarray(0, _(this, w, "f") - 1))), g(this, C, _(this, C, "f").subarray(_(this, w, "f")), "f"), g(this, w, null, "f");
|
|
303
|
-
continue;
|
|
304
|
-
}
|
|
305
|
-
let e = _(this, w, "f") === null ? r.preceding : r.preceding - 1, t = Ue(_(this, C, "f").subarray(0, e));
|
|
306
|
-
n.push(t), g(this, C, _(this, C, "f").subarray(r.index), "f"), g(this, w, null, "f");
|
|
307
|
-
}
|
|
308
|
-
return n;
|
|
309
|
-
}
|
|
310
|
-
flush() {
|
|
311
|
-
return _(this, C, "f").length ? this.decode("\n") : [];
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
C = /* @__PURE__ */ new WeakMap(), w = /* @__PURE__ */ new WeakMap(), We.NEWLINE_CHARS = /* @__PURE__ */ new Set(["\n", "\r"]), We.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
315
|
-
function Ge(e, t) {
|
|
316
|
-
for (let n = t ?? 0; n < e.length; n++) {
|
|
317
|
-
if (e[n] === 10) return {
|
|
318
|
-
preceding: n,
|
|
319
|
-
index: n + 1,
|
|
320
|
-
carriage: !1
|
|
321
|
-
};
|
|
322
|
-
if (e[n] === 13) return {
|
|
323
|
-
preceding: n,
|
|
324
|
-
index: n + 1,
|
|
325
|
-
carriage: !0
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
return null;
|
|
329
|
-
}
|
|
330
|
-
function Ke(e) {
|
|
331
|
-
for (let t = 0; t < e.length - 1; t++) {
|
|
332
|
-
if (e[t] === 10 && e[t + 1] === 10 || e[t] === 13 && e[t + 1] === 13) return t + 2;
|
|
333
|
-
if (e[t] === 13 && e[t + 1] === 10 && t + 3 < e.length && e[t + 2] === 13 && e[t + 3] === 10) return t + 4;
|
|
334
|
-
}
|
|
335
|
-
return -1;
|
|
336
|
-
}
|
|
337
|
-
//#endregion
|
|
338
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/utils/log.mjs
|
|
339
|
-
var qe = {
|
|
340
|
-
off: 0,
|
|
341
|
-
error: 200,
|
|
342
|
-
warn: 300,
|
|
343
|
-
info: 400,
|
|
344
|
-
debug: 500
|
|
345
|
-
}, Je = (e, t, n) => {
|
|
346
|
-
if (e) {
|
|
347
|
-
if (be(qe, e)) return e;
|
|
348
|
-
T(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(qe))}`);
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
function Ye() {}
|
|
352
|
-
function Xe(e, t, n) {
|
|
353
|
-
return !t || qe[e] > qe[n] ? Ye : t[e].bind(t);
|
|
354
|
-
}
|
|
355
|
-
var Ze = {
|
|
356
|
-
error: Ye,
|
|
357
|
-
warn: Ye,
|
|
358
|
-
info: Ye,
|
|
359
|
-
debug: Ye
|
|
360
|
-
}, Qe = /* @__PURE__ */ new WeakMap();
|
|
361
|
-
function T(e) {
|
|
362
|
-
let t = e.logger, n = e.logLevel ?? "off";
|
|
363
|
-
if (!t) return Ze;
|
|
364
|
-
let r = Qe.get(t);
|
|
365
|
-
if (r && r[0] === n) return r[1];
|
|
366
|
-
let i = {
|
|
367
|
-
error: Xe("error", t, n),
|
|
368
|
-
warn: Xe("warn", t, n),
|
|
369
|
-
info: Xe("info", t, n),
|
|
370
|
-
debug: Xe("debug", t, n)
|
|
371
|
-
};
|
|
372
|
-
return Qe.set(t, [n, i]), i;
|
|
373
|
-
}
|
|
374
|
-
var E = (e) => (e.options && (e.options = { ...e.options }, delete e.options.headers), e.headers &&= Object.fromEntries((e.headers instanceof Headers ? [...e.headers] : Object.entries(e.headers)).map(([e, t]) => [e, e.toLowerCase() === "x-api-key" || e.toLowerCase() === "authorization" || e.toLowerCase() === "cookie" || e.toLowerCase() === "set-cookie" ? "***" : t])), "retryOfRequestLogID" in e && (e.retryOfRequestLogID && (e.retryOf = e.retryOfRequestLogID), delete e.retryOfRequestLogID), e), $e, et = class e {
|
|
375
|
-
constructor(e, t, n) {
|
|
376
|
-
this.iterator = e, $e.set(this, void 0), this.controller = t, g(this, $e, n, "f");
|
|
377
|
-
}
|
|
378
|
-
static fromSSEResponse(t, n, r) {
|
|
379
|
-
let i = !1, a = r ? T(r) : console;
|
|
380
|
-
async function* o() {
|
|
381
|
-
if (i) throw new y("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
|
|
382
|
-
i = !0;
|
|
383
|
-
let e = !1;
|
|
384
|
-
try {
|
|
385
|
-
for await (let e of tt(t, n)) {
|
|
386
|
-
if (e.event === "completion") try {
|
|
387
|
-
yield JSON.parse(e.data);
|
|
388
|
-
} catch (t) {
|
|
389
|
-
throw a.error("Could not parse message into JSON:", e.data), a.error("From chunk:", e.raw), t;
|
|
390
|
-
}
|
|
391
|
-
if (e.event === "message_start" || e.event === "message_delta" || e.event === "message_stop" || e.event === "content_block_start" || e.event === "content_block_delta" || e.event === "content_block_stop" || e.event === "message" || e.event === "user.message" || e.event === "user.interrupt" || e.event === "user.tool_confirmation" || e.event === "user.custom_tool_result" || e.event === "agent.message" || e.event === "agent.thinking" || e.event === "agent.tool_use" || e.event === "agent.tool_result" || e.event === "agent.mcp_tool_use" || e.event === "agent.mcp_tool_result" || e.event === "agent.custom_tool_use" || e.event === "agent.thread_context_compacted" || e.event === "session.status_running" || e.event === "session.status_idle" || e.event === "session.status_rescheduled" || e.event === "session.status_terminated" || e.event === "session.error" || e.event === "session.deleted" || e.event === "span.model_request_start" || e.event === "span.model_request_end") try {
|
|
392
|
-
yield JSON.parse(e.data);
|
|
393
|
-
} catch (t) {
|
|
394
|
-
throw a.error("Could not parse message into JSON:", e.data), a.error("From chunk:", e.raw), t;
|
|
395
|
-
}
|
|
396
|
-
if (e.event !== "ping" && e.event === "error") {
|
|
397
|
-
let n = Se(e.data) ?? e.data, r = n?.error?.type;
|
|
398
|
-
throw new b(void 0, n, void 0, t.headers, r);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
e = !0;
|
|
402
|
-
} catch (e) {
|
|
403
|
-
if (v(e)) return;
|
|
404
|
-
throw e;
|
|
405
|
-
} finally {
|
|
406
|
-
e || n.abort();
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
return new e(o, n, r);
|
|
410
|
-
}
|
|
411
|
-
static fromReadableStream(t, n, r) {
|
|
412
|
-
let i = !1;
|
|
413
|
-
async function* a() {
|
|
414
|
-
let e = new We(), n = Fe(t);
|
|
415
|
-
for await (let t of n) for (let n of e.decode(t)) yield n;
|
|
416
|
-
for (let t of e.flush()) yield t;
|
|
417
|
-
}
|
|
418
|
-
async function* o() {
|
|
419
|
-
if (i) throw new y("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
|
|
420
|
-
i = !0;
|
|
421
|
-
let e = !1;
|
|
422
|
-
try {
|
|
423
|
-
for await (let t of a()) e || t && (yield JSON.parse(t));
|
|
424
|
-
e = !0;
|
|
425
|
-
} catch (e) {
|
|
426
|
-
if (v(e)) return;
|
|
427
|
-
throw e;
|
|
428
|
-
} finally {
|
|
429
|
-
e || n.abort();
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
return new e(o, n, r);
|
|
433
|
-
}
|
|
434
|
-
[($e = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
|
|
435
|
-
return this.iterator();
|
|
436
|
-
}
|
|
437
|
-
tee() {
|
|
438
|
-
let t = [], n = [], r = this.iterator(), i = (e) => ({ next: () => {
|
|
439
|
-
if (e.length === 0) {
|
|
440
|
-
let e = r.next();
|
|
441
|
-
t.push(e), n.push(e);
|
|
442
|
-
}
|
|
443
|
-
return e.shift();
|
|
444
|
-
} });
|
|
445
|
-
return [new e(() => i(t), this.controller, _(this, $e, "f")), new e(() => i(n), this.controller, _(this, $e, "f"))];
|
|
446
|
-
}
|
|
447
|
-
toReadableStream() {
|
|
448
|
-
let e = this, t;
|
|
449
|
-
return Ne({
|
|
450
|
-
async start() {
|
|
451
|
-
t = e[Symbol.asyncIterator]();
|
|
452
|
-
},
|
|
453
|
-
async pull(e) {
|
|
454
|
-
try {
|
|
455
|
-
let { value: n, done: r } = await t.next();
|
|
456
|
-
if (r) return e.close();
|
|
457
|
-
let i = Ve(JSON.stringify(n) + "\n");
|
|
458
|
-
e.enqueue(i);
|
|
459
|
-
} catch (t) {
|
|
460
|
-
e.error(t);
|
|
461
|
-
}
|
|
462
|
-
},
|
|
463
|
-
async cancel() {
|
|
464
|
-
await t.return?.();
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
async function* tt(e, t) {
|
|
470
|
-
if (!e.body) throw t.abort(), globalThis.navigator !== void 0 && globalThis.navigator.product === "ReactNative" ? new y("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api") : new y("Attempted to iterate over a response with no body");
|
|
471
|
-
let n = new rt(), r = new We(), i = Fe(e.body);
|
|
472
|
-
for await (let e of nt(i)) for (let t of r.decode(e)) {
|
|
473
|
-
let e = n.decode(t);
|
|
474
|
-
e && (yield e);
|
|
475
|
-
}
|
|
476
|
-
for (let e of r.flush()) {
|
|
477
|
-
let t = n.decode(e);
|
|
478
|
-
t && (yield t);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
async function* nt(e) {
|
|
482
|
-
let t = /* @__PURE__ */ new Uint8Array();
|
|
483
|
-
for await (let n of e) {
|
|
484
|
-
if (n == null) continue;
|
|
485
|
-
let e = n instanceof ArrayBuffer ? new Uint8Array(n) : typeof n == "string" ? Ve(n) : n, r = new Uint8Array(t.length + e.length);
|
|
486
|
-
r.set(t), r.set(e, t.length), t = r;
|
|
487
|
-
let i;
|
|
488
|
-
for (; (i = Ke(t)) !== -1;) yield t.slice(0, i), t = t.slice(i);
|
|
489
|
-
}
|
|
490
|
-
t.length > 0 && (yield t);
|
|
491
|
-
}
|
|
492
|
-
var rt = class {
|
|
493
|
-
constructor() {
|
|
494
|
-
this.event = null, this.data = [], this.chunks = [];
|
|
495
|
-
}
|
|
496
|
-
decode(e) {
|
|
497
|
-
if (e.endsWith("\r") && (e = e.substring(0, e.length - 1)), !e) {
|
|
498
|
-
if (!this.event && !this.data.length) return null;
|
|
499
|
-
let e = {
|
|
500
|
-
event: this.event,
|
|
501
|
-
data: this.data.join("\n"),
|
|
502
|
-
raw: this.chunks
|
|
503
|
-
};
|
|
504
|
-
return this.event = null, this.data = [], this.chunks = [], e;
|
|
505
|
-
}
|
|
506
|
-
if (this.chunks.push(e), e.startsWith(":")) return null;
|
|
507
|
-
let [t, n, r] = it(e, ":");
|
|
508
|
-
return r.startsWith(" ") && (r = r.substring(1)), t === "event" ? this.event = r : t === "data" && this.data.push(r), null;
|
|
509
|
-
}
|
|
510
|
-
};
|
|
511
|
-
function it(e, t) {
|
|
512
|
-
let n = e.indexOf(t);
|
|
513
|
-
return n === -1 ? [
|
|
514
|
-
e,
|
|
515
|
-
"",
|
|
516
|
-
""
|
|
517
|
-
] : [
|
|
518
|
-
e.substring(0, n),
|
|
519
|
-
t,
|
|
520
|
-
e.substring(n + t.length)
|
|
521
|
-
];
|
|
522
|
-
}
|
|
523
|
-
//#endregion
|
|
524
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/parse.mjs
|
|
525
|
-
async function at(e, t) {
|
|
526
|
-
let { response: n, requestLogID: r, retryOfRequestLogID: i, startTime: a } = t, o = await (async () => {
|
|
527
|
-
if (t.options.stream) return T(e).debug("response", n.status, n.url, n.headers, n.body), t.options.__streamClass ? t.options.__streamClass.fromSSEResponse(n, t.controller) : et.fromSSEResponse(n, t.controller);
|
|
528
|
-
if (n.status === 204) return null;
|
|
529
|
-
if (t.options.__binaryResponse) return n;
|
|
530
|
-
let r = n.headers.get("content-type")?.split(";")[0]?.trim();
|
|
531
|
-
return r?.includes("application/json") || r?.endsWith("+json") ? n.headers.get("content-length") === "0" ? void 0 : ot(await n.json(), n) : await n.text();
|
|
532
|
-
})();
|
|
533
|
-
return T(e).debug(`[${r}] response parsed`, E({
|
|
534
|
-
retryOfRequestLogID: i,
|
|
535
|
-
url: n.url,
|
|
536
|
-
status: n.status,
|
|
537
|
-
body: o,
|
|
538
|
-
durationMs: Date.now() - a
|
|
539
|
-
})), o;
|
|
540
|
-
}
|
|
541
|
-
function ot(e, t) {
|
|
542
|
-
return !e || typeof e != "object" || Array.isArray(e) ? e : Object.defineProperty(e, "_request_id", {
|
|
543
|
-
value: t.headers.get("request-id"),
|
|
544
|
-
enumerable: !1
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
//#endregion
|
|
548
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/core/api-promise.mjs
|
|
549
|
-
var st, ct = class e extends Promise {
|
|
550
|
-
constructor(e, t, n = at) {
|
|
551
|
-
super((e) => {
|
|
552
|
-
e(null);
|
|
553
|
-
}), this.responsePromise = t, this.parseResponse = n, st.set(this, void 0), g(this, st, e, "f");
|
|
554
|
-
}
|
|
555
|
-
_thenUnwrap(t) {
|
|
556
|
-
return new e(_(this, st, "f"), this.responsePromise, async (e, n) => ot(t(await this.parseResponse(e, n), n), n.response));
|
|
557
|
-
}
|
|
558
|
-
asResponse() {
|
|
559
|
-
return this.responsePromise.then((e) => e.response);
|
|
560
|
-
}
|
|
561
|
-
async withResponse() {
|
|
562
|
-
let [e, t] = await Promise.all([this.parse(), this.asResponse()]);
|
|
563
|
-
return {
|
|
564
|
-
data: e,
|
|
565
|
-
response: t,
|
|
566
|
-
request_id: t.headers.get("request-id")
|
|
567
|
-
};
|
|
568
|
-
}
|
|
569
|
-
parse() {
|
|
570
|
-
return this.parsedPromise ||= this.responsePromise.then((e) => this.parseResponse(_(this, st, "f"), e)), this.parsedPromise;
|
|
571
|
-
}
|
|
572
|
-
then(e, t) {
|
|
573
|
-
return this.parse().then(e, t);
|
|
574
|
-
}
|
|
575
|
-
catch(e) {
|
|
576
|
-
return this.parse().catch(e);
|
|
577
|
-
}
|
|
578
|
-
finally(e) {
|
|
579
|
-
return this.parse().finally(e);
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
st = /* @__PURE__ */ new WeakMap();
|
|
583
|
-
//#endregion
|
|
584
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/core/pagination.mjs
|
|
585
|
-
var lt, ut = class {
|
|
586
|
-
constructor(e, t, n, r) {
|
|
587
|
-
lt.set(this, void 0), g(this, lt, e, "f"), this.options = r, this.response = t, this.body = n;
|
|
588
|
-
}
|
|
589
|
-
hasNextPage() {
|
|
590
|
-
return this.getPaginatedItems().length ? this.nextPageRequestOptions() != null : !1;
|
|
591
|
-
}
|
|
592
|
-
async getNextPage() {
|
|
593
|
-
let e = this.nextPageRequestOptions();
|
|
594
|
-
if (!e) throw new y("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");
|
|
595
|
-
return await _(this, lt, "f").requestAPIList(this.constructor, e);
|
|
596
|
-
}
|
|
597
|
-
async *iterPages() {
|
|
598
|
-
let e = this;
|
|
599
|
-
for (yield e; e.hasNextPage();) e = await e.getNextPage(), yield e;
|
|
600
|
-
}
|
|
601
|
-
async *[(lt = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
|
|
602
|
-
for await (let e of this.iterPages()) for (let t of e.getPaginatedItems()) yield t;
|
|
603
|
-
}
|
|
604
|
-
}, dt = class extends ct {
|
|
605
|
-
constructor(e, t, n) {
|
|
606
|
-
super(e, t, async (e, t) => new n(e, t.response, await at(e, t), t.options));
|
|
607
|
-
}
|
|
608
|
-
async *[Symbol.asyncIterator]() {
|
|
609
|
-
let e = await this;
|
|
610
|
-
for await (let t of e) yield t;
|
|
611
|
-
}
|
|
612
|
-
}, ft = class extends ut {
|
|
613
|
-
constructor(e, t, n, r) {
|
|
614
|
-
super(e, t, n, r), this.data = n.data || [], this.has_more = n.has_more || !1, this.first_id = n.first_id || null, this.last_id = n.last_id || null;
|
|
615
|
-
}
|
|
616
|
-
getPaginatedItems() {
|
|
617
|
-
return this.data ?? [];
|
|
618
|
-
}
|
|
619
|
-
hasNextPage() {
|
|
620
|
-
return this.has_more !== !1 && super.hasNextPage();
|
|
621
|
-
}
|
|
622
|
-
nextPageRequestOptions() {
|
|
623
|
-
if (this.options.query?.before_id) {
|
|
624
|
-
let e = this.first_id;
|
|
625
|
-
return e ? {
|
|
626
|
-
...this.options,
|
|
627
|
-
query: {
|
|
628
|
-
...ve(this.options.query),
|
|
629
|
-
before_id: e
|
|
630
|
-
}
|
|
631
|
-
} : null;
|
|
632
|
-
}
|
|
633
|
-
let e = this.last_id;
|
|
634
|
-
return e ? {
|
|
635
|
-
...this.options,
|
|
636
|
-
query: {
|
|
637
|
-
...ve(this.options.query),
|
|
638
|
-
after_id: e
|
|
639
|
-
}
|
|
640
|
-
} : null;
|
|
641
|
-
}
|
|
642
|
-
}, D = class extends ut {
|
|
643
|
-
constructor(e, t, n, r) {
|
|
644
|
-
super(e, t, n, r), this.data = n.data || [], this.next_page = n.next_page || null;
|
|
645
|
-
}
|
|
646
|
-
getPaginatedItems() {
|
|
647
|
-
return this.data ?? [];
|
|
648
|
-
}
|
|
649
|
-
nextPageRequestOptions() {
|
|
650
|
-
let e = this.next_page;
|
|
651
|
-
return e ? {
|
|
652
|
-
...this.options,
|
|
653
|
-
query: {
|
|
654
|
-
...ve(this.options.query),
|
|
655
|
-
page: e
|
|
656
|
-
}
|
|
657
|
-
} : null;
|
|
658
|
-
}
|
|
659
|
-
}, pt = () => {
|
|
660
|
-
if (typeof File > "u") {
|
|
661
|
-
let { process: e } = globalThis, t = typeof e?.versions?.node == "string" && parseInt(e.versions.node.split(".")) < 20;
|
|
662
|
-
throw Error("`File` is not defined as a global, which is required for file uploads." + (t ? " Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`." : ""));
|
|
663
|
-
}
|
|
664
|
-
};
|
|
665
|
-
function O(e, t, n) {
|
|
666
|
-
return pt(), new File(e, t ?? "unknown_file", n);
|
|
667
|
-
}
|
|
668
|
-
function mt(e, t) {
|
|
669
|
-
let n = typeof e == "object" && !!e && ("name" in e && e.name && String(e.name) || "url" in e && e.url && String(e.url) || "filename" in e && e.filename && String(e.filename) || "path" in e && e.path && String(e.path)) || "";
|
|
670
|
-
return t ? n.split(/[\\/]/).pop() || void 0 : n;
|
|
671
|
-
}
|
|
672
|
-
var ht = (e) => typeof e == "object" && !!e && typeof e[Symbol.asyncIterator] == "function", gt = async (e, t, n = !0) => ({
|
|
673
|
-
...e,
|
|
674
|
-
body: await yt(e.body, t, n)
|
|
675
|
-
}), _t = /* @__PURE__ */ new WeakMap();
|
|
676
|
-
function vt(e) {
|
|
677
|
-
let t = typeof e == "function" ? e : e.fetch, n = _t.get(t);
|
|
678
|
-
if (n) return n;
|
|
679
|
-
let r = (async () => {
|
|
680
|
-
try {
|
|
681
|
-
let e = "Response" in t ? t.Response : (await t("data:,")).constructor, n = new FormData();
|
|
682
|
-
return n.toString() !== await new e(n).text();
|
|
683
|
-
} catch {
|
|
684
|
-
return !0;
|
|
685
|
-
}
|
|
686
|
-
})();
|
|
687
|
-
return _t.set(t, r), r;
|
|
688
|
-
}
|
|
689
|
-
var yt = async (e, t, n = !0) => {
|
|
690
|
-
if (!await vt(t)) throw TypeError("The provided fetch function does not support file uploads with the current global FormData class.");
|
|
691
|
-
let r = new FormData();
|
|
692
|
-
return await Promise.all(Object.entries(e || {}).map(([e, t]) => xt(r, e, t, n))), r;
|
|
693
|
-
}, bt = (e) => e instanceof Blob && "name" in e, xt = async (e, t, n, r) => {
|
|
694
|
-
if (n !== void 0) {
|
|
695
|
-
if (n == null) throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);
|
|
696
|
-
if (typeof n == "string" || typeof n == "number" || typeof n == "boolean") e.append(t, String(n));
|
|
697
|
-
else if (n instanceof Response) {
|
|
698
|
-
let i = {}, a = n.headers.get("Content-Type");
|
|
699
|
-
a && (i = { type: a }), e.append(t, O([await n.blob()], mt(n, r), i));
|
|
700
|
-
} else if (ht(n)) e.append(t, O([await new Response(Pe(n)).blob()], mt(n, r)));
|
|
701
|
-
else if (bt(n)) e.append(t, O([n], mt(n, r), { type: n.type }));
|
|
702
|
-
else if (Array.isArray(n)) await Promise.all(n.map((n) => xt(e, t + "[]", n, r)));
|
|
703
|
-
else if (typeof n == "object") await Promise.all(Object.entries(n).map(([n, i]) => xt(e, `${t}[${n}]`, i, r)));
|
|
704
|
-
else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`);
|
|
705
|
-
}
|
|
706
|
-
}, St = (e) => typeof e == "object" && !!e && typeof e.size == "number" && typeof e.type == "string" && typeof e.text == "function" && typeof e.slice == "function" && typeof e.arrayBuffer == "function", Ct = (e) => typeof e == "object" && !!e && typeof e.name == "string" && typeof e.lastModified == "number" && St(e), wt = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.blob == "function";
|
|
707
|
-
async function Tt(e, t, n) {
|
|
708
|
-
if (pt(), e = await e, t ||= mt(e, !0), Ct(e)) return e instanceof File && t == null && n == null ? e : O([await e.arrayBuffer()], t ?? e.name, {
|
|
709
|
-
type: e.type,
|
|
710
|
-
lastModified: e.lastModified,
|
|
711
|
-
...n
|
|
712
|
-
});
|
|
713
|
-
if (wt(e)) {
|
|
714
|
-
let r = await e.blob();
|
|
715
|
-
return t ||= new URL(e.url).pathname.split(/[\\/]/).pop(), O(await Et(r), t, n);
|
|
716
|
-
}
|
|
717
|
-
let r = await Et(e);
|
|
718
|
-
if (!n?.type) {
|
|
719
|
-
let e = r.find((e) => typeof e == "object" && "type" in e && e.type);
|
|
720
|
-
typeof e == "string" && (n = {
|
|
721
|
-
...n,
|
|
722
|
-
type: e
|
|
723
|
-
});
|
|
724
|
-
}
|
|
725
|
-
return O(r, t, n);
|
|
726
|
-
}
|
|
727
|
-
async function Et(e) {
|
|
728
|
-
let t = [];
|
|
729
|
-
if (typeof e == "string" || ArrayBuffer.isView(e) || e instanceof ArrayBuffer) t.push(e);
|
|
730
|
-
else if (St(e)) t.push(e instanceof Blob ? e : await e.arrayBuffer());
|
|
731
|
-
else if (ht(e)) for await (let n of e) t.push(...await Et(n));
|
|
732
|
-
else {
|
|
733
|
-
let t = e?.constructor?.name;
|
|
734
|
-
throw Error(`Unexpected data type: ${typeof e}${t ? `; constructor: ${t}` : ""}${Dt(e)}`);
|
|
735
|
-
}
|
|
736
|
-
return t;
|
|
737
|
-
}
|
|
738
|
-
function Dt(e) {
|
|
739
|
-
return typeof e != "object" || !e ? "" : `; props: [${Object.getOwnPropertyNames(e).map((e) => `"${e}"`).join(", ")}]`;
|
|
740
|
-
}
|
|
741
|
-
//#endregion
|
|
742
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/core/resource.mjs
|
|
743
|
-
var k = class {
|
|
744
|
-
constructor(e) {
|
|
745
|
-
this._client = e;
|
|
746
|
-
}
|
|
747
|
-
}, Ot = Symbol.for("brand.privateNullableHeaders");
|
|
748
|
-
function* kt(e) {
|
|
749
|
-
if (!e) return;
|
|
750
|
-
if (Ot in e) {
|
|
751
|
-
let { values: t, nulls: n } = e;
|
|
752
|
-
yield* t.entries();
|
|
753
|
-
for (let e of n) yield [e, null];
|
|
754
|
-
return;
|
|
755
|
-
}
|
|
756
|
-
let t = !1, n;
|
|
757
|
-
e instanceof Headers ? n = e.entries() : _e(e) ? n = e : (t = !0, n = Object.entries(e ?? {}));
|
|
758
|
-
for (let e of n) {
|
|
759
|
-
let n = e[0];
|
|
760
|
-
if (typeof n != "string") throw TypeError("expected header name to be a string");
|
|
761
|
-
let r = _e(e[1]) ? e[1] : [e[1]], i = !1;
|
|
762
|
-
for (let e of r) e !== void 0 && (t && !i && (i = !0, yield [n, null]), yield [n, e]);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
var A = (e) => {
|
|
766
|
-
let t = new Headers(), n = /* @__PURE__ */ new Set();
|
|
767
|
-
for (let r of e) {
|
|
768
|
-
let e = /* @__PURE__ */ new Set();
|
|
769
|
-
for (let [i, a] of kt(r)) {
|
|
770
|
-
let r = i.toLowerCase();
|
|
771
|
-
e.has(r) || (t.delete(i), e.add(r)), a === null ? (t.delete(i), n.add(r)) : (t.append(i, a), n.delete(r));
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
return {
|
|
775
|
-
[Ot]: !0,
|
|
776
|
-
values: t,
|
|
777
|
-
nulls: n
|
|
778
|
-
};
|
|
779
|
-
};
|
|
780
|
-
//#endregion
|
|
781
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/utils/path.mjs
|
|
782
|
-
function At(e) {
|
|
783
|
-
return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
784
|
-
}
|
|
785
|
-
var jt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null)), j = /* @__PURE__ */ ((e = At) => function(t, ...n) {
|
|
786
|
-
if (t.length === 1) return t[0];
|
|
787
|
-
let r = !1, i = [], a = t.reduce((t, a, o) => {
|
|
788
|
-
/[?#]/.test(a) && (r = !0);
|
|
789
|
-
let s = n[o], c = (r ? encodeURIComponent : e)("" + s);
|
|
790
|
-
return o !== n.length && (s == null || typeof s == "object" && s.toString === Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty ?? jt) ?? jt)?.toString) && (c = s + "", i.push({
|
|
791
|
-
start: t.length + a.length,
|
|
792
|
-
length: c.length,
|
|
793
|
-
error: `Value of type ${Object.prototype.toString.call(s).slice(8, -1)} is not a valid path parameter`
|
|
794
|
-
})), t + a + (o === n.length ? "" : c);
|
|
795
|
-
}, ""), o = a.split(/[?#]/, 1)[0], s = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi, c;
|
|
796
|
-
for (; (c = s.exec(o)) !== null;) i.push({
|
|
797
|
-
start: c.index,
|
|
798
|
-
length: c[0].length,
|
|
799
|
-
error: `Value "${c[0]}" can\'t be safely passed as a path parameter`
|
|
800
|
-
});
|
|
801
|
-
if (i.sort((e, t) => e.start - t.start), i.length > 0) {
|
|
802
|
-
let e = 0, t = i.reduce((t, n) => {
|
|
803
|
-
let r = " ".repeat(n.start - e), i = "^".repeat(n.length);
|
|
804
|
-
return e = n.start + n.length, t + r + i;
|
|
805
|
-
}, "");
|
|
806
|
-
throw new y(`Path parameters result in path with invalid segments:\n${i.map((e) => e.error).join("\n")}\n${a}\n${t}`);
|
|
807
|
-
}
|
|
808
|
-
return a;
|
|
809
|
-
})(At), Mt = class extends k {
|
|
810
|
-
create(e, t) {
|
|
811
|
-
let { betas: n, ...r } = e;
|
|
812
|
-
return this._client.post("/v1/environments?beta=true", {
|
|
813
|
-
body: r,
|
|
814
|
-
...t,
|
|
815
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "managed-agents-2026-04-01"].toString() }, t?.headers])
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
|
-
retrieve(e, t = {}, n) {
|
|
819
|
-
let { betas: r } = t ?? {};
|
|
820
|
-
return this._client.get(j`/v1/environments/${e}?beta=true`, {
|
|
821
|
-
...n,
|
|
822
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
823
|
-
});
|
|
824
|
-
}
|
|
825
|
-
update(e, t, n) {
|
|
826
|
-
let { betas: r, ...i } = t;
|
|
827
|
-
return this._client.post(j`/v1/environments/${e}?beta=true`, {
|
|
828
|
-
body: i,
|
|
829
|
-
...n,
|
|
830
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
list(e = {}, t) {
|
|
834
|
-
let { betas: n, ...r } = e ?? {};
|
|
835
|
-
return this._client.getAPIList("/v1/environments?beta=true", D, {
|
|
836
|
-
query: r,
|
|
837
|
-
...t,
|
|
838
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "managed-agents-2026-04-01"].toString() }, t?.headers])
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
delete(e, t = {}, n) {
|
|
842
|
-
let { betas: r } = t ?? {};
|
|
843
|
-
return this._client.delete(j`/v1/environments/${e}?beta=true`, {
|
|
844
|
-
...n,
|
|
845
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
archive(e, t = {}, n) {
|
|
849
|
-
let { betas: r } = t ?? {};
|
|
850
|
-
return this._client.post(j`/v1/environments/${e}/archive?beta=true`, {
|
|
851
|
-
...n,
|
|
852
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
853
|
-
});
|
|
854
|
-
}
|
|
855
|
-
}, Nt = Symbol("anthropic.sdk.stainlessHelper");
|
|
856
|
-
function Pt(e) {
|
|
857
|
-
return typeof e == "object" && !!e && Nt in e;
|
|
858
|
-
}
|
|
859
|
-
function Ft(e, t) {
|
|
860
|
-
let n = /* @__PURE__ */ new Set();
|
|
861
|
-
if (e) for (let t of e) Pt(t) && n.add(t[Nt]);
|
|
862
|
-
if (t) {
|
|
863
|
-
for (let e of t) if (Pt(e) && n.add(e[Nt]), Array.isArray(e.content)) for (let t of e.content) Pt(t) && n.add(t[Nt]);
|
|
864
|
-
}
|
|
865
|
-
return Array.from(n);
|
|
866
|
-
}
|
|
867
|
-
function It(e, t) {
|
|
868
|
-
let n = Ft(e, t);
|
|
869
|
-
return n.length === 0 ? {} : { "x-stainless-helper": n.join(", ") };
|
|
870
|
-
}
|
|
871
|
-
function Lt(e) {
|
|
872
|
-
return Pt(e) ? { "x-stainless-helper": e[Nt] } : {};
|
|
873
|
-
}
|
|
874
|
-
//#endregion
|
|
875
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/resources/beta/files.mjs
|
|
876
|
-
var Rt = class extends k {
|
|
877
|
-
list(e = {}, t) {
|
|
878
|
-
let { betas: n, ...r } = e ?? {};
|
|
879
|
-
return this._client.getAPIList("/v1/files?beta=true", ft, {
|
|
880
|
-
query: r,
|
|
881
|
-
...t,
|
|
882
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "files-api-2025-04-14"].toString() }, t?.headers])
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
delete(e, t = {}, n) {
|
|
886
|
-
let { betas: r } = t ?? {};
|
|
887
|
-
return this._client.delete(j`/v1/files/${e}?beta=true`, {
|
|
888
|
-
...n,
|
|
889
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "files-api-2025-04-14"].toString() }, n?.headers])
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
download(e, t = {}, n) {
|
|
893
|
-
let { betas: r } = t ?? {};
|
|
894
|
-
return this._client.get(j`/v1/files/${e}/content?beta=true`, {
|
|
895
|
-
...n,
|
|
896
|
-
headers: A([{
|
|
897
|
-
"anthropic-beta": [...r ?? [], "files-api-2025-04-14"].toString(),
|
|
898
|
-
Accept: "application/binary"
|
|
899
|
-
}, n?.headers]),
|
|
900
|
-
__binaryResponse: !0
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
retrieveMetadata(e, t = {}, n) {
|
|
904
|
-
let { betas: r } = t ?? {};
|
|
905
|
-
return this._client.get(j`/v1/files/${e}?beta=true`, {
|
|
906
|
-
...n,
|
|
907
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "files-api-2025-04-14"].toString() }, n?.headers])
|
|
908
|
-
});
|
|
909
|
-
}
|
|
910
|
-
upload(e, t) {
|
|
911
|
-
let { betas: n, ...r } = e;
|
|
912
|
-
return this._client.post("/v1/files?beta=true", gt({
|
|
913
|
-
body: r,
|
|
914
|
-
...t,
|
|
915
|
-
headers: A([
|
|
916
|
-
{ "anthropic-beta": [...n ?? [], "files-api-2025-04-14"].toString() },
|
|
917
|
-
Lt(r.file),
|
|
918
|
-
t?.headers
|
|
919
|
-
])
|
|
920
|
-
}, this._client));
|
|
921
|
-
}
|
|
922
|
-
}, zt = class extends k {
|
|
923
|
-
retrieve(e, t = {}, n) {
|
|
924
|
-
let { betas: r } = t ?? {};
|
|
925
|
-
return this._client.get(j`/v1/models/${e}?beta=true`, {
|
|
926
|
-
...n,
|
|
927
|
-
headers: A([{ ...r?.toString() == null ? void 0 : { "anthropic-beta": r?.toString() } }, n?.headers])
|
|
928
|
-
});
|
|
929
|
-
}
|
|
930
|
-
list(e = {}, t) {
|
|
931
|
-
let { betas: n, ...r } = e ?? {};
|
|
932
|
-
return this._client.getAPIList("/v1/models?beta=true", ft, {
|
|
933
|
-
query: r,
|
|
934
|
-
...t,
|
|
935
|
-
headers: A([{ ...n?.toString() == null ? void 0 : { "anthropic-beta": n?.toString() } }, t?.headers])
|
|
936
|
-
});
|
|
937
|
-
}
|
|
938
|
-
}, Bt = class extends k {
|
|
939
|
-
create(e, t) {
|
|
940
|
-
let { betas: n, ...r } = e;
|
|
941
|
-
return this._client.post("/v1/user_profiles?beta=true", {
|
|
942
|
-
body: r,
|
|
943
|
-
...t,
|
|
944
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "user-profiles-2026-03-24"].toString() }, t?.headers])
|
|
945
|
-
});
|
|
946
|
-
}
|
|
947
|
-
retrieve(e, t = {}, n) {
|
|
948
|
-
let { betas: r } = t ?? {};
|
|
949
|
-
return this._client.get(j`/v1/user_profiles/${e}?beta=true`, {
|
|
950
|
-
...n,
|
|
951
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "user-profiles-2026-03-24"].toString() }, n?.headers])
|
|
952
|
-
});
|
|
953
|
-
}
|
|
954
|
-
update(e, t, n) {
|
|
955
|
-
let { betas: r, ...i } = t;
|
|
956
|
-
return this._client.post(j`/v1/user_profiles/${e}?beta=true`, {
|
|
957
|
-
body: i,
|
|
958
|
-
...n,
|
|
959
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "user-profiles-2026-03-24"].toString() }, n?.headers])
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
|
-
list(e = {}, t) {
|
|
963
|
-
let { betas: n, ...r } = e ?? {};
|
|
964
|
-
return this._client.getAPIList("/v1/user_profiles?beta=true", D, {
|
|
965
|
-
query: r,
|
|
966
|
-
...t,
|
|
967
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "user-profiles-2026-03-24"].toString() }, t?.headers])
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
createEnrollmentURL(e, t = {}, n) {
|
|
971
|
-
let { betas: r } = t ?? {};
|
|
972
|
-
return this._client.post(j`/v1/user_profiles/${e}/enrollment_url?beta=true`, {
|
|
973
|
-
...n,
|
|
974
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "user-profiles-2026-03-24"].toString() }, n?.headers])
|
|
975
|
-
});
|
|
976
|
-
}
|
|
977
|
-
}, Vt = class extends k {
|
|
978
|
-
list(e, t = {}, n) {
|
|
979
|
-
let { betas: r, ...i } = t ?? {};
|
|
980
|
-
return this._client.getAPIList(j`/v1/agents/${e}/versions?beta=true`, D, {
|
|
981
|
-
query: i,
|
|
982
|
-
...n,
|
|
983
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
}, Ht = class extends k {
|
|
987
|
-
constructor() {
|
|
988
|
-
super(...arguments), this.versions = new Vt(this._client);
|
|
989
|
-
}
|
|
990
|
-
create(e, t) {
|
|
991
|
-
let { betas: n, ...r } = e;
|
|
992
|
-
return this._client.post("/v1/agents?beta=true", {
|
|
993
|
-
body: r,
|
|
994
|
-
...t,
|
|
995
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "managed-agents-2026-04-01"].toString() }, t?.headers])
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
retrieve(e, t = {}, n) {
|
|
999
|
-
let { betas: r, ...i } = t ?? {};
|
|
1000
|
-
return this._client.get(j`/v1/agents/${e}?beta=true`, {
|
|
1001
|
-
query: i,
|
|
1002
|
-
...n,
|
|
1003
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1004
|
-
});
|
|
1005
|
-
}
|
|
1006
|
-
update(e, t, n) {
|
|
1007
|
-
let { betas: r, ...i } = t;
|
|
1008
|
-
return this._client.post(j`/v1/agents/${e}?beta=true`, {
|
|
1009
|
-
body: i,
|
|
1010
|
-
...n,
|
|
1011
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1012
|
-
});
|
|
1013
|
-
}
|
|
1014
|
-
list(e = {}, t) {
|
|
1015
|
-
let { betas: n, ...r } = e ?? {};
|
|
1016
|
-
return this._client.getAPIList("/v1/agents?beta=true", D, {
|
|
1017
|
-
query: r,
|
|
1018
|
-
...t,
|
|
1019
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "managed-agents-2026-04-01"].toString() }, t?.headers])
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
archive(e, t = {}, n) {
|
|
1023
|
-
let { betas: r } = t ?? {};
|
|
1024
|
-
return this._client.post(j`/v1/agents/${e}/archive?beta=true`, {
|
|
1025
|
-
...n,
|
|
1026
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1027
|
-
});
|
|
1028
|
-
}
|
|
1029
|
-
};
|
|
1030
|
-
Ht.Versions = Vt;
|
|
1031
|
-
//#endregion
|
|
1032
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.mjs
|
|
1033
|
-
var Ut = class extends k {
|
|
1034
|
-
create(e, t, n) {
|
|
1035
|
-
let { view: r, betas: i, ...a } = t;
|
|
1036
|
-
return this._client.post(j`/v1/memory_stores/${e}/memories?beta=true`, {
|
|
1037
|
-
query: { view: r },
|
|
1038
|
-
body: a,
|
|
1039
|
-
...n,
|
|
1040
|
-
headers: A([{ "anthropic-beta": [...i ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1041
|
-
});
|
|
1042
|
-
}
|
|
1043
|
-
retrieve(e, t, n) {
|
|
1044
|
-
let { memory_store_id: r, betas: i, ...a } = t;
|
|
1045
|
-
return this._client.get(j`/v1/memory_stores/${r}/memories/${e}?beta=true`, {
|
|
1046
|
-
query: a,
|
|
1047
|
-
...n,
|
|
1048
|
-
headers: A([{ "anthropic-beta": [...i ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1049
|
-
});
|
|
1050
|
-
}
|
|
1051
|
-
update(e, t, n) {
|
|
1052
|
-
let { memory_store_id: r, view: i, betas: a, ...o } = t;
|
|
1053
|
-
return this._client.post(j`/v1/memory_stores/${r}/memories/${e}?beta=true`, {
|
|
1054
|
-
query: { view: i },
|
|
1055
|
-
body: o,
|
|
1056
|
-
...n,
|
|
1057
|
-
headers: A([{ "anthropic-beta": [...a ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
list(e, t = {}, n) {
|
|
1061
|
-
let { betas: r, ...i } = t ?? {};
|
|
1062
|
-
return this._client.getAPIList(j`/v1/memory_stores/${e}/memories?beta=true`, D, {
|
|
1063
|
-
query: i,
|
|
1064
|
-
...n,
|
|
1065
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1066
|
-
});
|
|
1067
|
-
}
|
|
1068
|
-
delete(e, t, n) {
|
|
1069
|
-
let { memory_store_id: r, expected_content_sha256: i, betas: a } = t;
|
|
1070
|
-
return this._client.delete(j`/v1/memory_stores/${r}/memories/${e}?beta=true`, {
|
|
1071
|
-
query: { expected_content_sha256: i },
|
|
1072
|
-
...n,
|
|
1073
|
-
headers: A([{ "anthropic-beta": [...a ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1074
|
-
});
|
|
1075
|
-
}
|
|
1076
|
-
}, Wt = class extends k {
|
|
1077
|
-
retrieve(e, t, n) {
|
|
1078
|
-
let { memory_store_id: r, betas: i, ...a } = t;
|
|
1079
|
-
return this._client.get(j`/v1/memory_stores/${r}/memory_versions/${e}?beta=true`, {
|
|
1080
|
-
query: a,
|
|
1081
|
-
...n,
|
|
1082
|
-
headers: A([{ "anthropic-beta": [...i ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1083
|
-
});
|
|
1084
|
-
}
|
|
1085
|
-
list(e, t = {}, n) {
|
|
1086
|
-
let { betas: r, ...i } = t ?? {};
|
|
1087
|
-
return this._client.getAPIList(j`/v1/memory_stores/${e}/memory_versions?beta=true`, D, {
|
|
1088
|
-
query: i,
|
|
1089
|
-
...n,
|
|
1090
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1091
|
-
});
|
|
1092
|
-
}
|
|
1093
|
-
redact(e, t, n) {
|
|
1094
|
-
let { memory_store_id: r, betas: i } = t;
|
|
1095
|
-
return this._client.post(j`/v1/memory_stores/${r}/memory_versions/${e}/redact?beta=true`, {
|
|
1096
|
-
...n,
|
|
1097
|
-
headers: A([{ "anthropic-beta": [...i ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1098
|
-
});
|
|
1099
|
-
}
|
|
1100
|
-
}, Gt = class extends k {
|
|
1101
|
-
constructor() {
|
|
1102
|
-
super(...arguments), this.memories = new Ut(this._client), this.memoryVersions = new Wt(this._client);
|
|
1103
|
-
}
|
|
1104
|
-
create(e, t) {
|
|
1105
|
-
let { betas: n, ...r } = e;
|
|
1106
|
-
return this._client.post("/v1/memory_stores?beta=true", {
|
|
1107
|
-
body: r,
|
|
1108
|
-
...t,
|
|
1109
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "managed-agents-2026-04-01"].toString() }, t?.headers])
|
|
1110
|
-
});
|
|
1111
|
-
}
|
|
1112
|
-
retrieve(e, t = {}, n) {
|
|
1113
|
-
let { betas: r } = t ?? {};
|
|
1114
|
-
return this._client.get(j`/v1/memory_stores/${e}?beta=true`, {
|
|
1115
|
-
...n,
|
|
1116
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1117
|
-
});
|
|
1118
|
-
}
|
|
1119
|
-
update(e, t, n) {
|
|
1120
|
-
let { betas: r, ...i } = t;
|
|
1121
|
-
return this._client.post(j`/v1/memory_stores/${e}?beta=true`, {
|
|
1122
|
-
body: i,
|
|
1123
|
-
...n,
|
|
1124
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1125
|
-
});
|
|
1126
|
-
}
|
|
1127
|
-
list(e = {}, t) {
|
|
1128
|
-
let { betas: n, ...r } = e ?? {};
|
|
1129
|
-
return this._client.getAPIList("/v1/memory_stores?beta=true", D, {
|
|
1130
|
-
query: r,
|
|
1131
|
-
...t,
|
|
1132
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "managed-agents-2026-04-01"].toString() }, t?.headers])
|
|
1133
|
-
});
|
|
1134
|
-
}
|
|
1135
|
-
delete(e, t = {}, n) {
|
|
1136
|
-
let { betas: r } = t ?? {};
|
|
1137
|
-
return this._client.delete(j`/v1/memory_stores/${e}?beta=true`, {
|
|
1138
|
-
...n,
|
|
1139
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1140
|
-
});
|
|
1141
|
-
}
|
|
1142
|
-
archive(e, t = {}, n) {
|
|
1143
|
-
let { betas: r } = t ?? {};
|
|
1144
|
-
return this._client.post(j`/v1/memory_stores/${e}/archive?beta=true`, {
|
|
1145
|
-
...n,
|
|
1146
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
1147
|
-
});
|
|
1148
|
-
}
|
|
1149
|
-
};
|
|
1150
|
-
Gt.Memories = Ut, Gt.MemoryVersions = Wt;
|
|
1151
|
-
//#endregion
|
|
1152
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/constants.mjs
|
|
1153
|
-
var Kt = {
|
|
1154
|
-
"claude-opus-4-20250514": 8192,
|
|
1155
|
-
"claude-opus-4-0": 8192,
|
|
1156
|
-
"claude-4-opus-20250514": 8192,
|
|
1157
|
-
"anthropic.claude-opus-4-20250514-v1:0": 8192,
|
|
1158
|
-
"claude-opus-4@20250514": 8192,
|
|
1159
|
-
"claude-opus-4-1-20250805": 8192,
|
|
1160
|
-
"anthropic.claude-opus-4-1-20250805-v1:0": 8192,
|
|
1161
|
-
"claude-opus-4-1@20250805": 8192
|
|
1162
|
-
};
|
|
1163
|
-
//#endregion
|
|
1164
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/lib/beta-parser.mjs
|
|
1165
|
-
function qt(e) {
|
|
1166
|
-
return e?.output_format ?? e?.output_config?.format;
|
|
1167
|
-
}
|
|
1168
|
-
function Jt(e, t, n) {
|
|
1169
|
-
let r = qt(t);
|
|
1170
|
-
return !t || !("parse" in (r ?? {})) ? {
|
|
1171
|
-
...e,
|
|
1172
|
-
content: e.content.map((e) => {
|
|
1173
|
-
if (e.type === "text") {
|
|
1174
|
-
let t = Object.defineProperty({ ...e }, "parsed_output", {
|
|
1175
|
-
value: null,
|
|
1176
|
-
enumerable: !1
|
|
1177
|
-
});
|
|
1178
|
-
return Object.defineProperty(t, "parsed", {
|
|
1179
|
-
get() {
|
|
1180
|
-
return n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."), null;
|
|
1181
|
-
},
|
|
1182
|
-
enumerable: !1
|
|
1183
|
-
});
|
|
1184
|
-
}
|
|
1185
|
-
return e;
|
|
1186
|
-
}),
|
|
1187
|
-
parsed_output: null
|
|
1188
|
-
} : Yt(e, t, n);
|
|
1189
|
-
}
|
|
1190
|
-
function Yt(e, t, n) {
|
|
1191
|
-
let r = null, i = e.content.map((e) => {
|
|
1192
|
-
if (e.type === "text") {
|
|
1193
|
-
let i = Xt(t, e.text);
|
|
1194
|
-
r === null && (r = i);
|
|
1195
|
-
let a = Object.defineProperty({ ...e }, "parsed_output", {
|
|
1196
|
-
value: i,
|
|
1197
|
-
enumerable: !1
|
|
1198
|
-
});
|
|
1199
|
-
return Object.defineProperty(a, "parsed", {
|
|
1200
|
-
get() {
|
|
1201
|
-
return n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."), i;
|
|
1202
|
-
},
|
|
1203
|
-
enumerable: !1
|
|
1204
|
-
});
|
|
1205
|
-
}
|
|
1206
|
-
return e;
|
|
1207
|
-
});
|
|
1208
|
-
return {
|
|
1209
|
-
...e,
|
|
1210
|
-
content: i,
|
|
1211
|
-
parsed_output: r
|
|
1212
|
-
};
|
|
1213
|
-
}
|
|
1214
|
-
function Xt(e, t) {
|
|
1215
|
-
let n = qt(e);
|
|
1216
|
-
if (n?.type !== "json_schema") return null;
|
|
1217
|
-
try {
|
|
1218
|
-
return "parse" in n ? n.parse(t) : JSON.parse(t);
|
|
1219
|
-
} catch (e) {
|
|
1220
|
-
throw new y(`Failed to parse structured output: ${e}`);
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
//#endregion
|
|
1224
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/_vendor/partial-json-parser/parser.mjs
|
|
1225
|
-
var Zt = (e) => {
|
|
1226
|
-
let t = 0, n = [];
|
|
1227
|
-
for (; t < e.length;) {
|
|
1228
|
-
let r = e[t];
|
|
1229
|
-
if (r === "\\") {
|
|
1230
|
-
t++;
|
|
1231
|
-
continue;
|
|
1232
|
-
}
|
|
1233
|
-
if (r === "{") {
|
|
1234
|
-
n.push({
|
|
1235
|
-
type: "brace",
|
|
1236
|
-
value: "{"
|
|
1237
|
-
}), t++;
|
|
1238
|
-
continue;
|
|
1239
|
-
}
|
|
1240
|
-
if (r === "}") {
|
|
1241
|
-
n.push({
|
|
1242
|
-
type: "brace",
|
|
1243
|
-
value: "}"
|
|
1244
|
-
}), t++;
|
|
1245
|
-
continue;
|
|
1246
|
-
}
|
|
1247
|
-
if (r === "[") {
|
|
1248
|
-
n.push({
|
|
1249
|
-
type: "paren",
|
|
1250
|
-
value: "["
|
|
1251
|
-
}), t++;
|
|
1252
|
-
continue;
|
|
1253
|
-
}
|
|
1254
|
-
if (r === "]") {
|
|
1255
|
-
n.push({
|
|
1256
|
-
type: "paren",
|
|
1257
|
-
value: "]"
|
|
1258
|
-
}), t++;
|
|
1259
|
-
continue;
|
|
1260
|
-
}
|
|
1261
|
-
if (r === ":") {
|
|
1262
|
-
n.push({
|
|
1263
|
-
type: "separator",
|
|
1264
|
-
value: ":"
|
|
1265
|
-
}), t++;
|
|
1266
|
-
continue;
|
|
1267
|
-
}
|
|
1268
|
-
if (r === ",") {
|
|
1269
|
-
n.push({
|
|
1270
|
-
type: "delimiter",
|
|
1271
|
-
value: ","
|
|
1272
|
-
}), t++;
|
|
1273
|
-
continue;
|
|
1274
|
-
}
|
|
1275
|
-
if (r === "\"") {
|
|
1276
|
-
let i = "", a = !1;
|
|
1277
|
-
for (r = e[++t]; r !== "\"";) {
|
|
1278
|
-
if (t === e.length) {
|
|
1279
|
-
a = !0;
|
|
1280
|
-
break;
|
|
1281
|
-
}
|
|
1282
|
-
if (r === "\\") {
|
|
1283
|
-
if (t++, t === e.length) {
|
|
1284
|
-
a = !0;
|
|
1285
|
-
break;
|
|
1286
|
-
}
|
|
1287
|
-
i += r + e[t], r = e[++t];
|
|
1288
|
-
} else i += r, r = e[++t];
|
|
1289
|
-
}
|
|
1290
|
-
r = e[++t], a || n.push({
|
|
1291
|
-
type: "string",
|
|
1292
|
-
value: i
|
|
1293
|
-
});
|
|
1294
|
-
continue;
|
|
1295
|
-
}
|
|
1296
|
-
if (r && /\s/.test(r)) {
|
|
1297
|
-
t++;
|
|
1298
|
-
continue;
|
|
1299
|
-
}
|
|
1300
|
-
let i = /[0-9]/;
|
|
1301
|
-
if (r && i.test(r) || r === "-" || r === ".") {
|
|
1302
|
-
let a = "";
|
|
1303
|
-
for (r === "-" && (a += r, r = e[++t]); r && i.test(r) || r === ".";) a += r, r = e[++t];
|
|
1304
|
-
n.push({
|
|
1305
|
-
type: "number",
|
|
1306
|
-
value: a
|
|
1307
|
-
});
|
|
1308
|
-
continue;
|
|
1309
|
-
}
|
|
1310
|
-
let a = /[a-z]/i;
|
|
1311
|
-
if (r && a.test(r)) {
|
|
1312
|
-
let i = "";
|
|
1313
|
-
for (; r && a.test(r) && t !== e.length;) i += r, r = e[++t];
|
|
1314
|
-
if (i == "true" || i == "false" || i === "null") n.push({
|
|
1315
|
-
type: "name",
|
|
1316
|
-
value: i
|
|
1317
|
-
});
|
|
1318
|
-
else {
|
|
1319
|
-
t++;
|
|
1320
|
-
continue;
|
|
1321
|
-
}
|
|
1322
|
-
continue;
|
|
1323
|
-
}
|
|
1324
|
-
t++;
|
|
1325
|
-
}
|
|
1326
|
-
return n;
|
|
1327
|
-
}, Qt = (e) => {
|
|
1328
|
-
if (e.length === 0) return e;
|
|
1329
|
-
let t = e[e.length - 1];
|
|
1330
|
-
switch (t.type) {
|
|
1331
|
-
case "separator": return e = e.slice(0, e.length - 1), Qt(e);
|
|
1332
|
-
case "number":
|
|
1333
|
-
let n = t.value[t.value.length - 1];
|
|
1334
|
-
if (n === "." || n === "-") return e = e.slice(0, e.length - 1), Qt(e);
|
|
1335
|
-
case "string":
|
|
1336
|
-
let r = e[e.length - 2];
|
|
1337
|
-
if (r?.type === "delimiter" || r?.type === "brace" && r.value === "{") return e = e.slice(0, e.length - 1), Qt(e);
|
|
1338
|
-
break;
|
|
1339
|
-
case "delimiter": return e = e.slice(0, e.length - 1), Qt(e);
|
|
1340
|
-
}
|
|
1341
|
-
return e;
|
|
1342
|
-
}, $t = (e) => {
|
|
1343
|
-
let t = [];
|
|
1344
|
-
return e.map((e) => {
|
|
1345
|
-
e.type === "brace" && (e.value === "{" ? t.push("}") : t.splice(t.lastIndexOf("}"), 1)), e.type === "paren" && (e.value === "[" ? t.push("]") : t.splice(t.lastIndexOf("]"), 1));
|
|
1346
|
-
}), t.length > 0 && t.reverse().map((t) => {
|
|
1347
|
-
t === "}" ? e.push({
|
|
1348
|
-
type: "brace",
|
|
1349
|
-
value: "}"
|
|
1350
|
-
}) : t === "]" && e.push({
|
|
1351
|
-
type: "paren",
|
|
1352
|
-
value: "]"
|
|
1353
|
-
});
|
|
1354
|
-
}), e;
|
|
1355
|
-
}, en = (e) => {
|
|
1356
|
-
let t = "";
|
|
1357
|
-
return e.map((e) => {
|
|
1358
|
-
switch (e.type) {
|
|
1359
|
-
case "string":
|
|
1360
|
-
t += "\"" + e.value + "\"";
|
|
1361
|
-
break;
|
|
1362
|
-
default: t += e.value;
|
|
1363
|
-
}
|
|
1364
|
-
}), t;
|
|
1365
|
-
}, tn = (e) => JSON.parse(en($t(Qt(Zt(e))))), M, N, P, F, nn, I, rn, an, on, L, sn, cn, ln, R, un, dn, fn, pn, mn, hn, gn, _n, vn, yn, bn = "__json_buf";
|
|
1366
|
-
function xn(e) {
|
|
1367
|
-
return e.type === "tool_use" || e.type === "server_tool_use" || e.type === "mcp_tool_use";
|
|
1368
|
-
}
|
|
1369
|
-
var Sn = class e {
|
|
1370
|
-
constructor(e, t) {
|
|
1371
|
-
M.add(this), this.messages = [], this.receivedMessages = [], N.set(this, void 0), P.set(this, null), this.controller = new AbortController(), F.set(this, void 0), nn.set(this, () => {}), I.set(this, () => {}), rn.set(this, void 0), an.set(this, () => {}), on.set(this, () => {}), L.set(this, {}), sn.set(this, !1), cn.set(this, !1), ln.set(this, !1), R.set(this, !1), un.set(this, void 0), dn.set(this, void 0), fn.set(this, void 0), hn.set(this, (e) => {
|
|
1372
|
-
if (g(this, cn, !0, "f"), v(e) && (e = new x()), e instanceof x) return g(this, ln, !0, "f"), this._emit("abort", e);
|
|
1373
|
-
if (e instanceof y) return this._emit("error", e);
|
|
1374
|
-
if (e instanceof Error) {
|
|
1375
|
-
let t = new y(e.message);
|
|
1376
|
-
return t.cause = e, this._emit("error", t);
|
|
1377
|
-
}
|
|
1378
|
-
return this._emit("error", new y(String(e)));
|
|
1379
|
-
}), g(this, F, new Promise((e, t) => {
|
|
1380
|
-
g(this, nn, e, "f"), g(this, I, t, "f");
|
|
1381
|
-
}), "f"), g(this, rn, new Promise((e, t) => {
|
|
1382
|
-
g(this, an, e, "f"), g(this, on, t, "f");
|
|
1383
|
-
}), "f"), _(this, F, "f").catch(() => {}), _(this, rn, "f").catch(() => {}), g(this, P, e, "f"), g(this, fn, t?.logger ?? console, "f");
|
|
1384
|
-
}
|
|
1385
|
-
get response() {
|
|
1386
|
-
return _(this, un, "f");
|
|
1387
|
-
}
|
|
1388
|
-
get request_id() {
|
|
1389
|
-
return _(this, dn, "f");
|
|
1390
|
-
}
|
|
1391
|
-
async withResponse() {
|
|
1392
|
-
g(this, R, !0, "f");
|
|
1393
|
-
let e = await _(this, F, "f");
|
|
1394
|
-
if (!e) throw Error("Could not resolve a `Response` object");
|
|
1395
|
-
return {
|
|
1396
|
-
data: this,
|
|
1397
|
-
response: e,
|
|
1398
|
-
request_id: e.headers.get("request-id")
|
|
1399
|
-
};
|
|
1400
|
-
}
|
|
1401
|
-
static fromReadableStream(t) {
|
|
1402
|
-
let n = new e(null);
|
|
1403
|
-
return n._run(() => n._fromReadableStream(t)), n;
|
|
1404
|
-
}
|
|
1405
|
-
static createMessage(t, n, r, { logger: i } = {}) {
|
|
1406
|
-
let a = new e(n, { logger: i });
|
|
1407
|
-
for (let e of n.messages) a._addMessageParam(e);
|
|
1408
|
-
return g(a, P, {
|
|
1409
|
-
...n,
|
|
1410
|
-
stream: !0
|
|
1411
|
-
}, "f"), a._run(() => a._createMessage(t, {
|
|
1412
|
-
...n,
|
|
1413
|
-
stream: !0
|
|
1414
|
-
}, {
|
|
1415
|
-
...r,
|
|
1416
|
-
headers: {
|
|
1417
|
-
...r?.headers,
|
|
1418
|
-
"X-Stainless-Helper-Method": "stream"
|
|
1419
|
-
}
|
|
1420
|
-
})), a;
|
|
1421
|
-
}
|
|
1422
|
-
_run(e) {
|
|
1423
|
-
e().then(() => {
|
|
1424
|
-
this._emitFinal(), this._emit("end");
|
|
1425
|
-
}, _(this, hn, "f"));
|
|
1426
|
-
}
|
|
1427
|
-
_addMessageParam(e) {
|
|
1428
|
-
this.messages.push(e);
|
|
1429
|
-
}
|
|
1430
|
-
_addMessage(e, t = !0) {
|
|
1431
|
-
this.receivedMessages.push(e), t && this._emit("message", e);
|
|
1432
|
-
}
|
|
1433
|
-
async _createMessage(e, t, n) {
|
|
1434
|
-
let r = n?.signal, i;
|
|
1435
|
-
r && (r.aborted && this.controller.abort(), i = this.controller.abort.bind(this.controller), r.addEventListener("abort", i));
|
|
1436
|
-
try {
|
|
1437
|
-
_(this, M, "m", gn).call(this);
|
|
1438
|
-
let { response: r, data: i } = await e.create({
|
|
1439
|
-
...t,
|
|
1440
|
-
stream: !0
|
|
1441
|
-
}, {
|
|
1442
|
-
...n,
|
|
1443
|
-
signal: this.controller.signal
|
|
1444
|
-
}).withResponse();
|
|
1445
|
-
this._connected(r);
|
|
1446
|
-
for await (let e of i) _(this, M, "m", _n).call(this, e);
|
|
1447
|
-
if (i.controller.signal?.aborted) throw new x();
|
|
1448
|
-
_(this, M, "m", vn).call(this);
|
|
1449
|
-
} finally {
|
|
1450
|
-
r && i && r.removeEventListener("abort", i);
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
_connected(e) {
|
|
1454
|
-
this.ended || (g(this, un, e, "f"), g(this, dn, e?.headers.get("request-id"), "f"), _(this, nn, "f").call(this, e), this._emit("connect"));
|
|
1455
|
-
}
|
|
1456
|
-
get ended() {
|
|
1457
|
-
return _(this, sn, "f");
|
|
1458
|
-
}
|
|
1459
|
-
get errored() {
|
|
1460
|
-
return _(this, cn, "f");
|
|
1461
|
-
}
|
|
1462
|
-
get aborted() {
|
|
1463
|
-
return _(this, ln, "f");
|
|
1464
|
-
}
|
|
1465
|
-
abort() {
|
|
1466
|
-
this.controller.abort();
|
|
1467
|
-
}
|
|
1468
|
-
on(e, t) {
|
|
1469
|
-
return (_(this, L, "f")[e] || (_(this, L, "f")[e] = [])).push({ listener: t }), this;
|
|
1470
|
-
}
|
|
1471
|
-
off(e, t) {
|
|
1472
|
-
let n = _(this, L, "f")[e];
|
|
1473
|
-
if (!n) return this;
|
|
1474
|
-
let r = n.findIndex((e) => e.listener === t);
|
|
1475
|
-
return r >= 0 && n.splice(r, 1), this;
|
|
1476
|
-
}
|
|
1477
|
-
once(e, t) {
|
|
1478
|
-
return (_(this, L, "f")[e] || (_(this, L, "f")[e] = [])).push({
|
|
1479
|
-
listener: t,
|
|
1480
|
-
once: !0
|
|
1481
|
-
}), this;
|
|
1482
|
-
}
|
|
1483
|
-
emitted(e) {
|
|
1484
|
-
return new Promise((t, n) => {
|
|
1485
|
-
g(this, R, !0, "f"), e !== "error" && this.once("error", n), this.once(e, t);
|
|
1486
|
-
});
|
|
1487
|
-
}
|
|
1488
|
-
async done() {
|
|
1489
|
-
g(this, R, !0, "f"), await _(this, rn, "f");
|
|
1490
|
-
}
|
|
1491
|
-
get currentMessage() {
|
|
1492
|
-
return _(this, N, "f");
|
|
1493
|
-
}
|
|
1494
|
-
async finalMessage() {
|
|
1495
|
-
return await this.done(), _(this, M, "m", pn).call(this);
|
|
1496
|
-
}
|
|
1497
|
-
async finalText() {
|
|
1498
|
-
return await this.done(), _(this, M, "m", mn).call(this);
|
|
1499
|
-
}
|
|
1500
|
-
_emit(e, ...t) {
|
|
1501
|
-
if (_(this, sn, "f")) return;
|
|
1502
|
-
e === "end" && (g(this, sn, !0, "f"), _(this, an, "f").call(this));
|
|
1503
|
-
let n = _(this, L, "f")[e];
|
|
1504
|
-
if (n && (_(this, L, "f")[e] = n.filter((e) => !e.once), n.forEach(({ listener: e }) => e(...t))), e === "abort") {
|
|
1505
|
-
let e = t[0];
|
|
1506
|
-
!_(this, R, "f") && !n?.length && Promise.reject(e), _(this, I, "f").call(this, e), _(this, on, "f").call(this, e), this._emit("end");
|
|
1507
|
-
return;
|
|
1508
|
-
}
|
|
1509
|
-
if (e === "error") {
|
|
1510
|
-
let e = t[0];
|
|
1511
|
-
!_(this, R, "f") && !n?.length && Promise.reject(e), _(this, I, "f").call(this, e), _(this, on, "f").call(this, e), this._emit("end");
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
_emitFinal() {
|
|
1515
|
-
this.receivedMessages.at(-1) && this._emit("finalMessage", _(this, M, "m", pn).call(this));
|
|
1516
|
-
}
|
|
1517
|
-
async _fromReadableStream(e, t) {
|
|
1518
|
-
let n = t?.signal, r;
|
|
1519
|
-
n && (n.aborted && this.controller.abort(), r = this.controller.abort.bind(this.controller), n.addEventListener("abort", r));
|
|
1520
|
-
try {
|
|
1521
|
-
_(this, M, "m", gn).call(this), this._connected(null);
|
|
1522
|
-
let t = et.fromReadableStream(e, this.controller);
|
|
1523
|
-
for await (let e of t) _(this, M, "m", _n).call(this, e);
|
|
1524
|
-
if (t.controller.signal?.aborted) throw new x();
|
|
1525
|
-
_(this, M, "m", vn).call(this);
|
|
1526
|
-
} finally {
|
|
1527
|
-
n && r && n.removeEventListener("abort", r);
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
[(N = /* @__PURE__ */ new WeakMap(), P = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), nn = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), rn = /* @__PURE__ */ new WeakMap(), an = /* @__PURE__ */ new WeakMap(), on = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), sn = /* @__PURE__ */ new WeakMap(), cn = /* @__PURE__ */ new WeakMap(), ln = /* @__PURE__ */ new WeakMap(), R = /* @__PURE__ */ new WeakMap(), un = /* @__PURE__ */ new WeakMap(), dn = /* @__PURE__ */ new WeakMap(), fn = /* @__PURE__ */ new WeakMap(), hn = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakSet(), pn = function() {
|
|
1531
|
-
if (this.receivedMessages.length === 0) throw new y("stream ended without producing a Message with role=assistant");
|
|
1532
|
-
return this.receivedMessages.at(-1);
|
|
1533
|
-
}, mn = function() {
|
|
1534
|
-
if (this.receivedMessages.length === 0) throw new y("stream ended without producing a Message with role=assistant");
|
|
1535
|
-
let e = this.receivedMessages.at(-1).content.filter((e) => e.type === "text").map((e) => e.text);
|
|
1536
|
-
if (e.length === 0) throw new y("stream ended without producing a content block with type=text");
|
|
1537
|
-
return e.join(" ");
|
|
1538
|
-
}, gn = function() {
|
|
1539
|
-
this.ended || g(this, N, void 0, "f");
|
|
1540
|
-
}, _n = function(e) {
|
|
1541
|
-
if (this.ended) return;
|
|
1542
|
-
let t = _(this, M, "m", yn).call(this, e);
|
|
1543
|
-
switch (this._emit("streamEvent", e, t), e.type) {
|
|
1544
|
-
case "content_block_delta": {
|
|
1545
|
-
let n = t.content.at(-1);
|
|
1546
|
-
switch (e.delta.type) {
|
|
1547
|
-
case "text_delta":
|
|
1548
|
-
n.type === "text" && this._emit("text", e.delta.text, n.text || "");
|
|
1549
|
-
break;
|
|
1550
|
-
case "citations_delta":
|
|
1551
|
-
n.type === "text" && this._emit("citation", e.delta.citation, n.citations ?? []);
|
|
1552
|
-
break;
|
|
1553
|
-
case "input_json_delta":
|
|
1554
|
-
xn(n) && n.input && this._emit("inputJson", e.delta.partial_json, n.input);
|
|
1555
|
-
break;
|
|
1556
|
-
case "thinking_delta":
|
|
1557
|
-
n.type === "thinking" && this._emit("thinking", e.delta.thinking, n.thinking);
|
|
1558
|
-
break;
|
|
1559
|
-
case "signature_delta":
|
|
1560
|
-
n.type === "thinking" && this._emit("signature", n.signature);
|
|
1561
|
-
break;
|
|
1562
|
-
case "compaction_delta":
|
|
1563
|
-
n.type === "compaction" && n.content && this._emit("compaction", n.content);
|
|
1564
|
-
break;
|
|
1565
|
-
default: e.delta;
|
|
1566
|
-
}
|
|
1567
|
-
break;
|
|
1568
|
-
}
|
|
1569
|
-
case "message_stop":
|
|
1570
|
-
this._addMessageParam(t), this._addMessage(Jt(t, _(this, P, "f"), { logger: _(this, fn, "f") }), !0);
|
|
1571
|
-
break;
|
|
1572
|
-
case "content_block_stop":
|
|
1573
|
-
this._emit("contentBlock", t.content.at(-1));
|
|
1574
|
-
break;
|
|
1575
|
-
case "message_start": g(this, N, t, "f");
|
|
1576
|
-
}
|
|
1577
|
-
}, vn = function() {
|
|
1578
|
-
if (this.ended) throw new y("stream has ended, this shouldn't happen");
|
|
1579
|
-
let e = _(this, N, "f");
|
|
1580
|
-
if (!e) throw new y("request ended without sending any chunks");
|
|
1581
|
-
return g(this, N, void 0, "f"), Jt(e, _(this, P, "f"), { logger: _(this, fn, "f") });
|
|
1582
|
-
}, yn = function(e) {
|
|
1583
|
-
let t = _(this, N, "f");
|
|
1584
|
-
if (e.type === "message_start") {
|
|
1585
|
-
if (t) throw new y(`Unexpected event order, got ${e.type} before receiving "message_stop"`);
|
|
1586
|
-
return e.message;
|
|
1587
|
-
}
|
|
1588
|
-
if (!t) throw new y(`Unexpected event order, got ${e.type} before "message_start"`);
|
|
1589
|
-
switch (e.type) {
|
|
1590
|
-
case "message_stop": return t;
|
|
1591
|
-
case "message_delta": return t.container = e.delta.container, t.stop_reason = e.delta.stop_reason, t.stop_sequence = e.delta.stop_sequence, t.usage.output_tokens = e.usage.output_tokens, t.context_management = e.context_management, e.usage.input_tokens != null && (t.usage.input_tokens = e.usage.input_tokens), e.usage.cache_creation_input_tokens != null && (t.usage.cache_creation_input_tokens = e.usage.cache_creation_input_tokens), e.usage.cache_read_input_tokens != null && (t.usage.cache_read_input_tokens = e.usage.cache_read_input_tokens), e.usage.server_tool_use != null && (t.usage.server_tool_use = e.usage.server_tool_use), e.usage.iterations != null && (t.usage.iterations = e.usage.iterations), t;
|
|
1592
|
-
case "content_block_start": return t.content.push(e.content_block), t;
|
|
1593
|
-
case "content_block_delta": {
|
|
1594
|
-
let n = t.content.at(e.index);
|
|
1595
|
-
switch (e.delta.type) {
|
|
1596
|
-
case "text_delta":
|
|
1597
|
-
n?.type === "text" && (t.content[e.index] = {
|
|
1598
|
-
...n,
|
|
1599
|
-
text: (n.text || "") + e.delta.text
|
|
1600
|
-
});
|
|
1601
|
-
break;
|
|
1602
|
-
case "citations_delta":
|
|
1603
|
-
n?.type === "text" && (t.content[e.index] = {
|
|
1604
|
-
...n,
|
|
1605
|
-
citations: [...n.citations ?? [], e.delta.citation]
|
|
1606
|
-
});
|
|
1607
|
-
break;
|
|
1608
|
-
case "input_json_delta":
|
|
1609
|
-
if (n && xn(n)) {
|
|
1610
|
-
let r = n[bn] || "";
|
|
1611
|
-
r += e.delta.partial_json;
|
|
1612
|
-
let i = { ...n };
|
|
1613
|
-
if (Object.defineProperty(i, bn, {
|
|
1614
|
-
value: r,
|
|
1615
|
-
enumerable: !1,
|
|
1616
|
-
writable: !0
|
|
1617
|
-
}), r) try {
|
|
1618
|
-
i.input = tn(r);
|
|
1619
|
-
} catch (e) {
|
|
1620
|
-
let t = new y(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${e}. JSON: ${r}`);
|
|
1621
|
-
_(this, hn, "f").call(this, t);
|
|
1622
|
-
}
|
|
1623
|
-
t.content[e.index] = i;
|
|
1624
|
-
}
|
|
1625
|
-
break;
|
|
1626
|
-
case "thinking_delta":
|
|
1627
|
-
n?.type === "thinking" && (t.content[e.index] = {
|
|
1628
|
-
...n,
|
|
1629
|
-
thinking: n.thinking + e.delta.thinking
|
|
1630
|
-
});
|
|
1631
|
-
break;
|
|
1632
|
-
case "signature_delta":
|
|
1633
|
-
n?.type === "thinking" && (t.content[e.index] = {
|
|
1634
|
-
...n,
|
|
1635
|
-
signature: e.delta.signature
|
|
1636
|
-
});
|
|
1637
|
-
break;
|
|
1638
|
-
case "compaction_delta":
|
|
1639
|
-
n?.type === "compaction" && (t.content[e.index] = {
|
|
1640
|
-
...n,
|
|
1641
|
-
content: (n.content || "") + e.delta.content
|
|
1642
|
-
});
|
|
1643
|
-
break;
|
|
1644
|
-
default: e.delta;
|
|
1645
|
-
}
|
|
1646
|
-
return t;
|
|
1647
|
-
}
|
|
1648
|
-
case "content_block_stop": return t;
|
|
1649
|
-
}
|
|
1650
|
-
}, Symbol.asyncIterator)]() {
|
|
1651
|
-
let e = [], t = [], n = !1;
|
|
1652
|
-
return this.on("streamEvent", (n) => {
|
|
1653
|
-
let r = t.shift();
|
|
1654
|
-
r ? r.resolve(n) : e.push(n);
|
|
1655
|
-
}), this.on("end", () => {
|
|
1656
|
-
n = !0;
|
|
1657
|
-
for (let e of t) e.resolve(void 0);
|
|
1658
|
-
t.length = 0;
|
|
1659
|
-
}), this.on("abort", (e) => {
|
|
1660
|
-
n = !0;
|
|
1661
|
-
for (let n of t) n.reject(e);
|
|
1662
|
-
t.length = 0;
|
|
1663
|
-
}), this.on("error", (e) => {
|
|
1664
|
-
n = !0;
|
|
1665
|
-
for (let n of t) n.reject(e);
|
|
1666
|
-
t.length = 0;
|
|
1667
|
-
}), {
|
|
1668
|
-
next: async () => e.length ? {
|
|
1669
|
-
value: e.shift(),
|
|
1670
|
-
done: !1
|
|
1671
|
-
} : n ? {
|
|
1672
|
-
value: void 0,
|
|
1673
|
-
done: !0
|
|
1674
|
-
} : new Promise((e, n) => t.push({
|
|
1675
|
-
resolve: e,
|
|
1676
|
-
reject: n
|
|
1677
|
-
})).then((e) => e ? {
|
|
1678
|
-
value: e,
|
|
1679
|
-
done: !1
|
|
1680
|
-
} : {
|
|
1681
|
-
value: void 0,
|
|
1682
|
-
done: !0
|
|
1683
|
-
}),
|
|
1684
|
-
return: async () => (this.abort(), {
|
|
1685
|
-
value: void 0,
|
|
1686
|
-
done: !0
|
|
1687
|
-
})
|
|
1688
|
-
};
|
|
1689
|
-
}
|
|
1690
|
-
toReadableStream() {
|
|
1691
|
-
return new et(this[Symbol.asyncIterator].bind(this), this.controller).toReadableStream();
|
|
1692
|
-
}
|
|
1693
|
-
}, Cn = class extends Error {
|
|
1694
|
-
constructor(e) {
|
|
1695
|
-
let t = typeof e == "string" ? e : e.map((e) => e.type === "text" ? e.text : `[${e.type}]`).join(" ");
|
|
1696
|
-
super(t), this.name = "ToolError", this.content = e;
|
|
1697
|
-
}
|
|
1698
|
-
}, wn = "You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:\n1. Task Overview\nThe user's core request and success criteria\nAny clarifications or constraints they specified\n2. Current State\nWhat has been completed so far\nFiles created, modified, or analyzed (with paths if relevant)\nKey outputs or artifacts produced\n3. Important Discoveries\nTechnical constraints or requirements uncovered\nDecisions made and their rationale\nErrors encountered and how they were resolved\nWhat approaches were tried that didn't work (and why)\n4. Next Steps\nSpecific actions needed to complete the task\nAny blockers or open questions to resolve\nPriority order if multiple steps remain\n5. Context to Preserve\nUser preferences or style requirements\nDomain-specific details that aren't obvious\nAny promises made to the user\nBe concise but complete—err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.\nWrap your summary in <summary></summary> tags.", Tn, z, B, V, H, U, W, G, En, Dn, On;
|
|
1699
|
-
function kn() {
|
|
1700
|
-
let e, t;
|
|
1701
|
-
return {
|
|
1702
|
-
promise: new Promise((n, r) => {
|
|
1703
|
-
e = n, t = r;
|
|
1704
|
-
}),
|
|
1705
|
-
resolve: e,
|
|
1706
|
-
reject: t
|
|
1707
|
-
};
|
|
1708
|
-
}
|
|
1709
|
-
var An = class {
|
|
1710
|
-
constructor(e, t, n) {
|
|
1711
|
-
Tn.add(this), this.client = e, z.set(this, !1), B.set(this, !1), V.set(this, void 0), H.set(this, void 0), U.set(this, void 0), W.set(this, void 0), G.set(this, void 0), En.set(this, 0), g(this, V, { params: {
|
|
1712
|
-
...t,
|
|
1713
|
-
messages: structuredClone(t.messages)
|
|
1714
|
-
} }, "f");
|
|
1715
|
-
let r = ["BetaToolRunner", ...Ft(t.tools, t.messages)].join(", ");
|
|
1716
|
-
g(this, H, {
|
|
1717
|
-
...n,
|
|
1718
|
-
headers: A([{ "x-stainless-helper": r }, n?.headers])
|
|
1719
|
-
}, "f"), g(this, G, kn(), "f"), t.compactionControl?.enabled && console.warn("Anthropic: The `compactionControl` parameter is deprecated and will be removed in a future version. Use server-side compaction instead by passing `edits: [{ type: \"compact_20260112\" }]` in the params passed to `toolRunner()`. See https://platform.claude.com/docs/en/build-with-claude/compaction");
|
|
1720
|
-
}
|
|
1721
|
-
async *[(z = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), En = /* @__PURE__ */ new WeakMap(), Tn = /* @__PURE__ */ new WeakSet(), Dn = async function() {
|
|
1722
|
-
let e = _(this, V, "f").params.compactionControl;
|
|
1723
|
-
if (!e || !e.enabled) return !1;
|
|
1724
|
-
let t = 0;
|
|
1725
|
-
if (_(this, U, "f") !== void 0) try {
|
|
1726
|
-
let e = await _(this, U, "f");
|
|
1727
|
-
t = e.usage.input_tokens + (e.usage.cache_creation_input_tokens ?? 0) + (e.usage.cache_read_input_tokens ?? 0) + e.usage.output_tokens;
|
|
1728
|
-
} catch {
|
|
1729
|
-
return !1;
|
|
1730
|
-
}
|
|
1731
|
-
let n = e.contextTokenThreshold ?? 1e5;
|
|
1732
|
-
if (t < n) return !1;
|
|
1733
|
-
let r = e.model ?? _(this, V, "f").params.model, i = e.summaryPrompt ?? wn, a = _(this, V, "f").params.messages;
|
|
1734
|
-
if (a[a.length - 1].role === "assistant") {
|
|
1735
|
-
let e = a[a.length - 1];
|
|
1736
|
-
if (Array.isArray(e.content)) {
|
|
1737
|
-
let t = e.content.filter((e) => e.type !== "tool_use");
|
|
1738
|
-
t.length === 0 ? a.pop() : e.content = t;
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
let o = await this.client.beta.messages.create({
|
|
1742
|
-
model: r,
|
|
1743
|
-
messages: [...a, {
|
|
1744
|
-
role: "user",
|
|
1745
|
-
content: [{
|
|
1746
|
-
type: "text",
|
|
1747
|
-
text: i
|
|
1748
|
-
}]
|
|
1749
|
-
}],
|
|
1750
|
-
max_tokens: _(this, V, "f").params.max_tokens
|
|
1751
|
-
}, {
|
|
1752
|
-
signal: _(this, H, "f").signal,
|
|
1753
|
-
headers: A([_(this, H, "f").headers, { "x-stainless-helper": "compaction" }])
|
|
1754
|
-
});
|
|
1755
|
-
if (o.content[0]?.type !== "text") throw new y("Expected text response for compaction");
|
|
1756
|
-
return _(this, V, "f").params.messages = [{
|
|
1757
|
-
role: "user",
|
|
1758
|
-
content: o.content
|
|
1759
|
-
}], !0;
|
|
1760
|
-
}, Symbol.asyncIterator)]() {
|
|
1761
|
-
var e;
|
|
1762
|
-
if (_(this, z, "f")) throw new y("Cannot iterate over a consumed stream");
|
|
1763
|
-
g(this, z, !0, "f"), g(this, B, !0, "f"), g(this, W, void 0, "f");
|
|
1764
|
-
try {
|
|
1765
|
-
for (;;) {
|
|
1766
|
-
let t;
|
|
1767
|
-
try {
|
|
1768
|
-
if (_(this, V, "f").params.max_iterations && _(this, En, "f") >= _(this, V, "f").params.max_iterations) break;
|
|
1769
|
-
g(this, B, !1, "f"), g(this, W, void 0, "f"), g(this, En, (e = _(this, En, "f"), e++, e), "f"), g(this, U, void 0, "f");
|
|
1770
|
-
let { max_iterations: n, compactionControl: r, ...i } = _(this, V, "f").params;
|
|
1771
|
-
if (i.stream ? (t = this.client.beta.messages.stream({ ...i }, _(this, H, "f")), g(this, U, t.finalMessage(), "f"), _(this, U, "f").catch(() => {}), yield t) : (g(this, U, this.client.beta.messages.create({
|
|
1772
|
-
...i,
|
|
1773
|
-
stream: !1
|
|
1774
|
-
}, _(this, H, "f")), "f"), yield _(this, U, "f")), !await _(this, Tn, "m", Dn).call(this)) {
|
|
1775
|
-
if (!_(this, B, "f")) {
|
|
1776
|
-
let { role: e, content: t } = await _(this, U, "f");
|
|
1777
|
-
_(this, V, "f").params.messages.push({
|
|
1778
|
-
role: e,
|
|
1779
|
-
content: t
|
|
1780
|
-
});
|
|
1781
|
-
}
|
|
1782
|
-
let e = await _(this, Tn, "m", On).call(this, _(this, V, "f").params.messages.at(-1));
|
|
1783
|
-
if (e) _(this, V, "f").params.messages.push(e);
|
|
1784
|
-
else if (!_(this, B, "f")) break;
|
|
1785
|
-
}
|
|
1786
|
-
} finally {
|
|
1787
|
-
t && t.abort();
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
if (!_(this, U, "f")) throw new y("ToolRunner concluded without a message from the server");
|
|
1791
|
-
_(this, G, "f").resolve(await _(this, U, "f"));
|
|
1792
|
-
} catch (e) {
|
|
1793
|
-
throw g(this, z, !1, "f"), _(this, G, "f").promise.catch(() => {}), _(this, G, "f").reject(e), g(this, G, kn(), "f"), e;
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
setMessagesParams(e) {
|
|
1797
|
-
typeof e == "function" ? _(this, V, "f").params = e(_(this, V, "f").params) : _(this, V, "f").params = e, g(this, B, !0, "f"), g(this, W, void 0, "f");
|
|
1798
|
-
}
|
|
1799
|
-
setRequestOptions(e) {
|
|
1800
|
-
typeof e == "function" ? g(this, H, e(_(this, H, "f")), "f") : g(this, H, {
|
|
1801
|
-
..._(this, H, "f"),
|
|
1802
|
-
...e
|
|
1803
|
-
}, "f");
|
|
1804
|
-
}
|
|
1805
|
-
async generateToolResponse(e = _(this, H, "f").signal) {
|
|
1806
|
-
let t = await _(this, U, "f") ?? this.params.messages.at(-1);
|
|
1807
|
-
return t ? _(this, Tn, "m", On).call(this, t, e) : null;
|
|
1808
|
-
}
|
|
1809
|
-
done() {
|
|
1810
|
-
return _(this, G, "f").promise;
|
|
1811
|
-
}
|
|
1812
|
-
async runUntilDone() {
|
|
1813
|
-
if (!_(this, z, "f")) for await (let e of this);
|
|
1814
|
-
return this.done();
|
|
1815
|
-
}
|
|
1816
|
-
get params() {
|
|
1817
|
-
return _(this, V, "f").params;
|
|
1818
|
-
}
|
|
1819
|
-
pushMessages(...e) {
|
|
1820
|
-
this.setMessagesParams((t) => ({
|
|
1821
|
-
...t,
|
|
1822
|
-
messages: [...t.messages, ...e]
|
|
1823
|
-
}));
|
|
1824
|
-
}
|
|
1825
|
-
then(e, t) {
|
|
1826
|
-
return this.runUntilDone().then(e, t);
|
|
1827
|
-
}
|
|
1828
|
-
};
|
|
1829
|
-
On = async function(e, t = _(this, H, "f").signal) {
|
|
1830
|
-
return _(this, W, "f") === void 0 && g(this, W, jn(_(this, V, "f").params, e, {
|
|
1831
|
-
..._(this, H, "f"),
|
|
1832
|
-
signal: t
|
|
1833
|
-
}), "f"), _(this, W, "f");
|
|
1834
|
-
};
|
|
1835
|
-
async function jn(e, t = e.messages.at(-1), n) {
|
|
1836
|
-
if (!t || t.role !== "assistant" || !t.content || typeof t.content == "string") return null;
|
|
1837
|
-
let r = t.content.filter((e) => e.type === "tool_use");
|
|
1838
|
-
return r.length === 0 ? null : {
|
|
1839
|
-
role: "user",
|
|
1840
|
-
content: await Promise.all(r.map(async (t) => {
|
|
1841
|
-
let r = e.tools.find((e) => ("name" in e ? e.name : e.mcp_server_name) === t.name);
|
|
1842
|
-
if (!r || !("run" in r)) return {
|
|
1843
|
-
type: "tool_result",
|
|
1844
|
-
tool_use_id: t.id,
|
|
1845
|
-
content: `Error: Tool '${t.name}' not found`,
|
|
1846
|
-
is_error: !0
|
|
1847
|
-
};
|
|
1848
|
-
try {
|
|
1849
|
-
let e = t.input;
|
|
1850
|
-
"parse" in r && r.parse && (e = r.parse(e));
|
|
1851
|
-
let i = await r.run(e, {
|
|
1852
|
-
toolUseBlock: t,
|
|
1853
|
-
signal: n?.signal
|
|
1854
|
-
});
|
|
1855
|
-
return {
|
|
1856
|
-
type: "tool_result",
|
|
1857
|
-
tool_use_id: t.id,
|
|
1858
|
-
content: i
|
|
1859
|
-
};
|
|
1860
|
-
} catch (e) {
|
|
1861
|
-
return {
|
|
1862
|
-
type: "tool_result",
|
|
1863
|
-
tool_use_id: t.id,
|
|
1864
|
-
content: e instanceof Cn ? e.content : `Error: ${e instanceof Error ? e.message : String(e)}`,
|
|
1865
|
-
is_error: !0
|
|
1866
|
-
};
|
|
1867
|
-
}
|
|
1868
|
-
}))
|
|
1869
|
-
};
|
|
1870
|
-
}
|
|
1871
|
-
//#endregion
|
|
1872
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/decoders/jsonl.mjs
|
|
1873
|
-
var Mn = class e {
|
|
1874
|
-
constructor(e, t) {
|
|
1875
|
-
this.iterator = e, this.controller = t;
|
|
1876
|
-
}
|
|
1877
|
-
async *decoder() {
|
|
1878
|
-
let e = new We();
|
|
1879
|
-
for await (let t of this.iterator) for (let n of e.decode(t)) yield JSON.parse(n);
|
|
1880
|
-
for (let t of e.flush()) yield JSON.parse(t);
|
|
1881
|
-
}
|
|
1882
|
-
[Symbol.asyncIterator]() {
|
|
1883
|
-
return this.decoder();
|
|
1884
|
-
}
|
|
1885
|
-
static fromResponse(t, n) {
|
|
1886
|
-
if (!t.body) throw n.abort(), globalThis.navigator !== void 0 && globalThis.navigator.product === "ReactNative" ? new y("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api") : new y("Attempted to iterate over a response with no body");
|
|
1887
|
-
return new e(Fe(t.body), n);
|
|
1888
|
-
}
|
|
1889
|
-
}, Nn = class extends k {
|
|
1890
|
-
create(e, t) {
|
|
1891
|
-
let { betas: n, ...r } = e;
|
|
1892
|
-
return this._client.post("/v1/messages/batches?beta=true", {
|
|
1893
|
-
body: r,
|
|
1894
|
-
...t,
|
|
1895
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "message-batches-2024-09-24"].toString() }, t?.headers])
|
|
1896
|
-
});
|
|
1897
|
-
}
|
|
1898
|
-
retrieve(e, t = {}, n) {
|
|
1899
|
-
let { betas: r } = t ?? {};
|
|
1900
|
-
return this._client.get(j`/v1/messages/batches/${e}?beta=true`, {
|
|
1901
|
-
...n,
|
|
1902
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "message-batches-2024-09-24"].toString() }, n?.headers])
|
|
1903
|
-
});
|
|
1904
|
-
}
|
|
1905
|
-
list(e = {}, t) {
|
|
1906
|
-
let { betas: n, ...r } = e ?? {};
|
|
1907
|
-
return this._client.getAPIList("/v1/messages/batches?beta=true", ft, {
|
|
1908
|
-
query: r,
|
|
1909
|
-
...t,
|
|
1910
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "message-batches-2024-09-24"].toString() }, t?.headers])
|
|
1911
|
-
});
|
|
1912
|
-
}
|
|
1913
|
-
delete(e, t = {}, n) {
|
|
1914
|
-
let { betas: r } = t ?? {};
|
|
1915
|
-
return this._client.delete(j`/v1/messages/batches/${e}?beta=true`, {
|
|
1916
|
-
...n,
|
|
1917
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "message-batches-2024-09-24"].toString() }, n?.headers])
|
|
1918
|
-
});
|
|
1919
|
-
}
|
|
1920
|
-
cancel(e, t = {}, n) {
|
|
1921
|
-
let { betas: r } = t ?? {};
|
|
1922
|
-
return this._client.post(j`/v1/messages/batches/${e}/cancel?beta=true`, {
|
|
1923
|
-
...n,
|
|
1924
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "message-batches-2024-09-24"].toString() }, n?.headers])
|
|
1925
|
-
});
|
|
1926
|
-
}
|
|
1927
|
-
async results(e, t = {}, n) {
|
|
1928
|
-
let r = await this.retrieve(e);
|
|
1929
|
-
if (!r.results_url) throw new y(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);
|
|
1930
|
-
let { betas: i } = t ?? {};
|
|
1931
|
-
return this._client.get(r.results_url, {
|
|
1932
|
-
...n,
|
|
1933
|
-
headers: A([{
|
|
1934
|
-
"anthropic-beta": [...i ?? [], "message-batches-2024-09-24"].toString(),
|
|
1935
|
-
Accept: "application/binary"
|
|
1936
|
-
}, n?.headers]),
|
|
1937
|
-
stream: !0,
|
|
1938
|
-
__binaryResponse: !0
|
|
1939
|
-
})._thenUnwrap((e, t) => Mn.fromResponse(t.response, t.controller));
|
|
1940
|
-
}
|
|
1941
|
-
}, Pn = {
|
|
1942
|
-
"claude-1.3": "November 6th, 2024",
|
|
1943
|
-
"claude-1.3-100k": "November 6th, 2024",
|
|
1944
|
-
"claude-instant-1.1": "November 6th, 2024",
|
|
1945
|
-
"claude-instant-1.1-100k": "November 6th, 2024",
|
|
1946
|
-
"claude-instant-1.2": "November 6th, 2024",
|
|
1947
|
-
"claude-3-sonnet-20240229": "July 21st, 2025",
|
|
1948
|
-
"claude-3-opus-20240229": "January 5th, 2026",
|
|
1949
|
-
"claude-2.1": "July 21st, 2025",
|
|
1950
|
-
"claude-2.0": "July 21st, 2025",
|
|
1951
|
-
"claude-3-7-sonnet-latest": "February 19th, 2026",
|
|
1952
|
-
"claude-3-7-sonnet-20250219": "February 19th, 2026"
|
|
1953
|
-
}, Fn = ["claude-mythos-preview", "claude-opus-4-6"], In = class extends k {
|
|
1954
|
-
constructor() {
|
|
1955
|
-
super(...arguments), this.batches = new Nn(this._client);
|
|
1956
|
-
}
|
|
1957
|
-
create(e, t) {
|
|
1958
|
-
let n = Ln(e), { betas: r, ...i } = n;
|
|
1959
|
-
i.model in Pn && console.warn(`The model '${i.model}' is deprecated and will reach end-of-life on ${Pn[i.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`), Fn.includes(i.model) && i.thinking && i.thinking.type === "enabled" && console.warn(`Using Claude with ${i.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);
|
|
1960
|
-
let a = this._client._options.timeout;
|
|
1961
|
-
if (!i.stream && a == null) {
|
|
1962
|
-
let e = Kt[i.model] ?? void 0;
|
|
1963
|
-
a = this._client.calculateNonstreamingTimeout(i.max_tokens, e);
|
|
1964
|
-
}
|
|
1965
|
-
let o = It(i.tools, i.messages);
|
|
1966
|
-
return this._client.post("/v1/messages?beta=true", {
|
|
1967
|
-
body: i,
|
|
1968
|
-
timeout: a ?? 6e5,
|
|
1969
|
-
...t,
|
|
1970
|
-
headers: A([
|
|
1971
|
-
{ ...r?.toString() == null ? void 0 : { "anthropic-beta": r?.toString() } },
|
|
1972
|
-
o,
|
|
1973
|
-
t?.headers
|
|
1974
|
-
]),
|
|
1975
|
-
stream: n.stream ?? !1
|
|
1976
|
-
});
|
|
1977
|
-
}
|
|
1978
|
-
parse(e, t) {
|
|
1979
|
-
return t = {
|
|
1980
|
-
...t,
|
|
1981
|
-
headers: A([{ "anthropic-beta": [...e.betas ?? [], "structured-outputs-2025-12-15"].toString() }, t?.headers])
|
|
1982
|
-
}, this.create(e, t).then((t) => Yt(t, e, { logger: this._client.logger ?? console }));
|
|
1983
|
-
}
|
|
1984
|
-
stream(e, t) {
|
|
1985
|
-
return Sn.createMessage(this, e, t);
|
|
1986
|
-
}
|
|
1987
|
-
countTokens(e, t) {
|
|
1988
|
-
let { betas: n, ...r } = Ln(e);
|
|
1989
|
-
return this._client.post("/v1/messages/count_tokens?beta=true", {
|
|
1990
|
-
body: r,
|
|
1991
|
-
...t,
|
|
1992
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "token-counting-2024-11-01"].toString() }, t?.headers])
|
|
1993
|
-
});
|
|
1994
|
-
}
|
|
1995
|
-
toolRunner(e, t) {
|
|
1996
|
-
return new An(this._client, e, t);
|
|
1997
|
-
}
|
|
1998
|
-
};
|
|
1999
|
-
function Ln(e) {
|
|
2000
|
-
if (!e.output_format) return e;
|
|
2001
|
-
if (e.output_config?.format) throw new y("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).");
|
|
2002
|
-
let { output_format: t, ...n } = e;
|
|
2003
|
-
return {
|
|
2004
|
-
...n,
|
|
2005
|
-
output_config: {
|
|
2006
|
-
...e.output_config,
|
|
2007
|
-
format: t
|
|
2008
|
-
}
|
|
2009
|
-
};
|
|
2010
|
-
}
|
|
2011
|
-
In.Batches = Nn, In.BetaToolRunner = An, In.ToolError = Cn;
|
|
2012
|
-
//#endregion
|
|
2013
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/resources/beta/sessions/events.mjs
|
|
2014
|
-
var Rn = class extends k {
|
|
2015
|
-
list(e, t = {}, n) {
|
|
2016
|
-
let { betas: r, ...i } = t ?? {};
|
|
2017
|
-
return this._client.getAPIList(j`/v1/sessions/${e}/events?beta=true`, D, {
|
|
2018
|
-
query: i,
|
|
2019
|
-
...n,
|
|
2020
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2021
|
-
});
|
|
2022
|
-
}
|
|
2023
|
-
send(e, t, n) {
|
|
2024
|
-
let { betas: r, ...i } = t;
|
|
2025
|
-
return this._client.post(j`/v1/sessions/${e}/events?beta=true`, {
|
|
2026
|
-
body: i,
|
|
2027
|
-
...n,
|
|
2028
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2029
|
-
});
|
|
2030
|
-
}
|
|
2031
|
-
stream(e, t = {}, n) {
|
|
2032
|
-
let { betas: r } = t ?? {};
|
|
2033
|
-
return this._client.get(j`/v1/sessions/${e}/events/stream?beta=true`, {
|
|
2034
|
-
...n,
|
|
2035
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers]),
|
|
2036
|
-
stream: !0
|
|
2037
|
-
});
|
|
2038
|
-
}
|
|
2039
|
-
}, zn = class extends k {
|
|
2040
|
-
retrieve(e, t, n) {
|
|
2041
|
-
let { session_id: r, betas: i } = t;
|
|
2042
|
-
return this._client.get(j`/v1/sessions/${r}/resources/${e}?beta=true`, {
|
|
2043
|
-
...n,
|
|
2044
|
-
headers: A([{ "anthropic-beta": [...i ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2045
|
-
});
|
|
2046
|
-
}
|
|
2047
|
-
update(e, t, n) {
|
|
2048
|
-
let { session_id: r, betas: i, ...a } = t;
|
|
2049
|
-
return this._client.post(j`/v1/sessions/${r}/resources/${e}?beta=true`, {
|
|
2050
|
-
body: a,
|
|
2051
|
-
...n,
|
|
2052
|
-
headers: A([{ "anthropic-beta": [...i ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2053
|
-
});
|
|
2054
|
-
}
|
|
2055
|
-
list(e, t = {}, n) {
|
|
2056
|
-
let { betas: r, ...i } = t ?? {};
|
|
2057
|
-
return this._client.getAPIList(j`/v1/sessions/${e}/resources?beta=true`, D, {
|
|
2058
|
-
query: i,
|
|
2059
|
-
...n,
|
|
2060
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2061
|
-
});
|
|
2062
|
-
}
|
|
2063
|
-
delete(e, t, n) {
|
|
2064
|
-
let { session_id: r, betas: i } = t;
|
|
2065
|
-
return this._client.delete(j`/v1/sessions/${r}/resources/${e}?beta=true`, {
|
|
2066
|
-
...n,
|
|
2067
|
-
headers: A([{ "anthropic-beta": [...i ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2068
|
-
});
|
|
2069
|
-
}
|
|
2070
|
-
add(e, t, n) {
|
|
2071
|
-
let { betas: r, ...i } = t;
|
|
2072
|
-
return this._client.post(j`/v1/sessions/${e}/resources?beta=true`, {
|
|
2073
|
-
body: i,
|
|
2074
|
-
...n,
|
|
2075
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2076
|
-
});
|
|
2077
|
-
}
|
|
2078
|
-
}, Bn = class extends k {
|
|
2079
|
-
constructor() {
|
|
2080
|
-
super(...arguments), this.events = new Rn(this._client), this.resources = new zn(this._client);
|
|
2081
|
-
}
|
|
2082
|
-
create(e, t) {
|
|
2083
|
-
let { betas: n, ...r } = e;
|
|
2084
|
-
return this._client.post("/v1/sessions?beta=true", {
|
|
2085
|
-
body: r,
|
|
2086
|
-
...t,
|
|
2087
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "managed-agents-2026-04-01"].toString() }, t?.headers])
|
|
2088
|
-
});
|
|
2089
|
-
}
|
|
2090
|
-
retrieve(e, t = {}, n) {
|
|
2091
|
-
let { betas: r } = t ?? {};
|
|
2092
|
-
return this._client.get(j`/v1/sessions/${e}?beta=true`, {
|
|
2093
|
-
...n,
|
|
2094
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2095
|
-
});
|
|
2096
|
-
}
|
|
2097
|
-
update(e, t, n) {
|
|
2098
|
-
let { betas: r, ...i } = t;
|
|
2099
|
-
return this._client.post(j`/v1/sessions/${e}?beta=true`, {
|
|
2100
|
-
body: i,
|
|
2101
|
-
...n,
|
|
2102
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2103
|
-
});
|
|
2104
|
-
}
|
|
2105
|
-
list(e = {}, t) {
|
|
2106
|
-
let { betas: n, ...r } = e ?? {};
|
|
2107
|
-
return this._client.getAPIList("/v1/sessions?beta=true", D, {
|
|
2108
|
-
query: r,
|
|
2109
|
-
...t,
|
|
2110
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "managed-agents-2026-04-01"].toString() }, t?.headers])
|
|
2111
|
-
});
|
|
2112
|
-
}
|
|
2113
|
-
delete(e, t = {}, n) {
|
|
2114
|
-
let { betas: r } = t ?? {};
|
|
2115
|
-
return this._client.delete(j`/v1/sessions/${e}?beta=true`, {
|
|
2116
|
-
...n,
|
|
2117
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2118
|
-
});
|
|
2119
|
-
}
|
|
2120
|
-
archive(e, t = {}, n) {
|
|
2121
|
-
let { betas: r } = t ?? {};
|
|
2122
|
-
return this._client.post(j`/v1/sessions/${e}/archive?beta=true`, {
|
|
2123
|
-
...n,
|
|
2124
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2125
|
-
});
|
|
2126
|
-
}
|
|
2127
|
-
};
|
|
2128
|
-
Bn.Events = Rn, Bn.Resources = zn;
|
|
2129
|
-
//#endregion
|
|
2130
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.mjs
|
|
2131
|
-
var Vn = class extends k {
|
|
2132
|
-
create(e, t = {}, n) {
|
|
2133
|
-
let { betas: r, ...i } = t ?? {};
|
|
2134
|
-
return this._client.post(j`/v1/skills/${e}/versions?beta=true`, gt({
|
|
2135
|
-
body: i,
|
|
2136
|
-
...n,
|
|
2137
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "skills-2025-10-02"].toString() }, n?.headers])
|
|
2138
|
-
}, this._client));
|
|
2139
|
-
}
|
|
2140
|
-
retrieve(e, t, n) {
|
|
2141
|
-
let { skill_id: r, betas: i } = t;
|
|
2142
|
-
return this._client.get(j`/v1/skills/${r}/versions/${e}?beta=true`, {
|
|
2143
|
-
...n,
|
|
2144
|
-
headers: A([{ "anthropic-beta": [...i ?? [], "skills-2025-10-02"].toString() }, n?.headers])
|
|
2145
|
-
});
|
|
2146
|
-
}
|
|
2147
|
-
list(e, t = {}, n) {
|
|
2148
|
-
let { betas: r, ...i } = t ?? {};
|
|
2149
|
-
return this._client.getAPIList(j`/v1/skills/${e}/versions?beta=true`, D, {
|
|
2150
|
-
query: i,
|
|
2151
|
-
...n,
|
|
2152
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "skills-2025-10-02"].toString() }, n?.headers])
|
|
2153
|
-
});
|
|
2154
|
-
}
|
|
2155
|
-
delete(e, t, n) {
|
|
2156
|
-
let { skill_id: r, betas: i } = t;
|
|
2157
|
-
return this._client.delete(j`/v1/skills/${r}/versions/${e}?beta=true`, {
|
|
2158
|
-
...n,
|
|
2159
|
-
headers: A([{ "anthropic-beta": [...i ?? [], "skills-2025-10-02"].toString() }, n?.headers])
|
|
2160
|
-
});
|
|
2161
|
-
}
|
|
2162
|
-
}, Hn = class extends k {
|
|
2163
|
-
constructor() {
|
|
2164
|
-
super(...arguments), this.versions = new Vn(this._client);
|
|
2165
|
-
}
|
|
2166
|
-
create(e = {}, t) {
|
|
2167
|
-
let { betas: n, ...r } = e ?? {};
|
|
2168
|
-
return this._client.post("/v1/skills?beta=true", gt({
|
|
2169
|
-
body: r,
|
|
2170
|
-
...t,
|
|
2171
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "skills-2025-10-02"].toString() }, t?.headers])
|
|
2172
|
-
}, this._client, !1));
|
|
2173
|
-
}
|
|
2174
|
-
retrieve(e, t = {}, n) {
|
|
2175
|
-
let { betas: r } = t ?? {};
|
|
2176
|
-
return this._client.get(j`/v1/skills/${e}?beta=true`, {
|
|
2177
|
-
...n,
|
|
2178
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "skills-2025-10-02"].toString() }, n?.headers])
|
|
2179
|
-
});
|
|
2180
|
-
}
|
|
2181
|
-
list(e = {}, t) {
|
|
2182
|
-
let { betas: n, ...r } = e ?? {};
|
|
2183
|
-
return this._client.getAPIList("/v1/skills?beta=true", D, {
|
|
2184
|
-
query: r,
|
|
2185
|
-
...t,
|
|
2186
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "skills-2025-10-02"].toString() }, t?.headers])
|
|
2187
|
-
});
|
|
2188
|
-
}
|
|
2189
|
-
delete(e, t = {}, n) {
|
|
2190
|
-
let { betas: r } = t ?? {};
|
|
2191
|
-
return this._client.delete(j`/v1/skills/${e}?beta=true`, {
|
|
2192
|
-
...n,
|
|
2193
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "skills-2025-10-02"].toString() }, n?.headers])
|
|
2194
|
-
});
|
|
2195
|
-
}
|
|
2196
|
-
};
|
|
2197
|
-
Hn.Versions = Vn;
|
|
2198
|
-
//#endregion
|
|
2199
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/resources/beta/vaults/credentials.mjs
|
|
2200
|
-
var Un = class extends k {
|
|
2201
|
-
create(e, t, n) {
|
|
2202
|
-
let { betas: r, ...i } = t;
|
|
2203
|
-
return this._client.post(j`/v1/vaults/${e}/credentials?beta=true`, {
|
|
2204
|
-
body: i,
|
|
2205
|
-
...n,
|
|
2206
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2207
|
-
});
|
|
2208
|
-
}
|
|
2209
|
-
retrieve(e, t, n) {
|
|
2210
|
-
let { vault_id: r, betas: i } = t;
|
|
2211
|
-
return this._client.get(j`/v1/vaults/${r}/credentials/${e}?beta=true`, {
|
|
2212
|
-
...n,
|
|
2213
|
-
headers: A([{ "anthropic-beta": [...i ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2214
|
-
});
|
|
2215
|
-
}
|
|
2216
|
-
update(e, t, n) {
|
|
2217
|
-
let { vault_id: r, betas: i, ...a } = t;
|
|
2218
|
-
return this._client.post(j`/v1/vaults/${r}/credentials/${e}?beta=true`, {
|
|
2219
|
-
body: a,
|
|
2220
|
-
...n,
|
|
2221
|
-
headers: A([{ "anthropic-beta": [...i ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2222
|
-
});
|
|
2223
|
-
}
|
|
2224
|
-
list(e, t = {}, n) {
|
|
2225
|
-
let { betas: r, ...i } = t ?? {};
|
|
2226
|
-
return this._client.getAPIList(j`/v1/vaults/${e}/credentials?beta=true`, D, {
|
|
2227
|
-
query: i,
|
|
2228
|
-
...n,
|
|
2229
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2230
|
-
});
|
|
2231
|
-
}
|
|
2232
|
-
delete(e, t, n) {
|
|
2233
|
-
let { vault_id: r, betas: i } = t;
|
|
2234
|
-
return this._client.delete(j`/v1/vaults/${r}/credentials/${e}?beta=true`, {
|
|
2235
|
-
...n,
|
|
2236
|
-
headers: A([{ "anthropic-beta": [...i ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2237
|
-
});
|
|
2238
|
-
}
|
|
2239
|
-
archive(e, t, n) {
|
|
2240
|
-
let { vault_id: r, betas: i } = t;
|
|
2241
|
-
return this._client.post(j`/v1/vaults/${r}/credentials/${e}/archive?beta=true`, {
|
|
2242
|
-
...n,
|
|
2243
|
-
headers: A([{ "anthropic-beta": [...i ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2244
|
-
});
|
|
2245
|
-
}
|
|
2246
|
-
}, Wn = class extends k {
|
|
2247
|
-
constructor() {
|
|
2248
|
-
super(...arguments), this.credentials = new Un(this._client);
|
|
2249
|
-
}
|
|
2250
|
-
create(e, t) {
|
|
2251
|
-
let { betas: n, ...r } = e;
|
|
2252
|
-
return this._client.post("/v1/vaults?beta=true", {
|
|
2253
|
-
body: r,
|
|
2254
|
-
...t,
|
|
2255
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "managed-agents-2026-04-01"].toString() }, t?.headers])
|
|
2256
|
-
});
|
|
2257
|
-
}
|
|
2258
|
-
retrieve(e, t = {}, n) {
|
|
2259
|
-
let { betas: r } = t ?? {};
|
|
2260
|
-
return this._client.get(j`/v1/vaults/${e}?beta=true`, {
|
|
2261
|
-
...n,
|
|
2262
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2263
|
-
});
|
|
2264
|
-
}
|
|
2265
|
-
update(e, t, n) {
|
|
2266
|
-
let { betas: r, ...i } = t;
|
|
2267
|
-
return this._client.post(j`/v1/vaults/${e}?beta=true`, {
|
|
2268
|
-
body: i,
|
|
2269
|
-
...n,
|
|
2270
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2271
|
-
});
|
|
2272
|
-
}
|
|
2273
|
-
list(e = {}, t) {
|
|
2274
|
-
let { betas: n, ...r } = e ?? {};
|
|
2275
|
-
return this._client.getAPIList("/v1/vaults?beta=true", D, {
|
|
2276
|
-
query: r,
|
|
2277
|
-
...t,
|
|
2278
|
-
headers: A([{ "anthropic-beta": [...n ?? [], "managed-agents-2026-04-01"].toString() }, t?.headers])
|
|
2279
|
-
});
|
|
2280
|
-
}
|
|
2281
|
-
delete(e, t = {}, n) {
|
|
2282
|
-
let { betas: r } = t ?? {};
|
|
2283
|
-
return this._client.delete(j`/v1/vaults/${e}?beta=true`, {
|
|
2284
|
-
...n,
|
|
2285
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2286
|
-
});
|
|
2287
|
-
}
|
|
2288
|
-
archive(e, t = {}, n) {
|
|
2289
|
-
let { betas: r } = t ?? {};
|
|
2290
|
-
return this._client.post(j`/v1/vaults/${e}/archive?beta=true`, {
|
|
2291
|
-
...n,
|
|
2292
|
-
headers: A([{ "anthropic-beta": [...r ?? [], "managed-agents-2026-04-01"].toString() }, n?.headers])
|
|
2293
|
-
});
|
|
2294
|
-
}
|
|
2295
|
-
};
|
|
2296
|
-
Wn.Credentials = Un;
|
|
2297
|
-
//#endregion
|
|
2298
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs
|
|
2299
|
-
var K = class extends k {
|
|
2300
|
-
constructor() {
|
|
2301
|
-
super(...arguments), this.models = new zt(this._client), this.messages = new In(this._client), this.agents = new Ht(this._client), this.environments = new Mt(this._client), this.sessions = new Bn(this._client), this.vaults = new Wn(this._client), this.memoryStores = new Gt(this._client), this.files = new Rt(this._client), this.skills = new Hn(this._client), this.userProfiles = new Bt(this._client);
|
|
2302
|
-
}
|
|
2303
|
-
};
|
|
2304
|
-
K.Models = zt, K.Messages = In, K.Agents = Ht, K.Environments = Mt, K.Sessions = Bn, K.Vaults = Wn, K.MemoryStores = Gt, K.Files = Rt, K.Skills = Hn, K.UserProfiles = Bt;
|
|
2305
|
-
//#endregion
|
|
2306
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/resources/completions.mjs
|
|
2307
|
-
var Gn = class extends k {
|
|
2308
|
-
create(e, t) {
|
|
2309
|
-
let { betas: n, ...r } = e;
|
|
2310
|
-
return this._client.post("/v1/complete", {
|
|
2311
|
-
body: r,
|
|
2312
|
-
timeout: this._client._options.timeout ?? 6e5,
|
|
2313
|
-
...t,
|
|
2314
|
-
headers: A([{ ...n?.toString() == null ? void 0 : { "anthropic-beta": n?.toString() } }, t?.headers]),
|
|
2315
|
-
stream: e.stream ?? !1
|
|
2316
|
-
});
|
|
2317
|
-
}
|
|
2318
|
-
};
|
|
2319
|
-
//#endregion
|
|
2320
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/lib/parser.mjs
|
|
2321
|
-
function Kn(e) {
|
|
2322
|
-
return e?.output_config?.format;
|
|
2323
|
-
}
|
|
2324
|
-
function qn(e, t, n) {
|
|
2325
|
-
let r = Kn(t);
|
|
2326
|
-
return !t || !("parse" in (r ?? {})) ? {
|
|
2327
|
-
...e,
|
|
2328
|
-
content: e.content.map((e) => e.type === "text" ? Object.defineProperty({ ...e }, "parsed_output", {
|
|
2329
|
-
value: null,
|
|
2330
|
-
enumerable: !1
|
|
2331
|
-
}) : e),
|
|
2332
|
-
parsed_output: null
|
|
2333
|
-
} : Jn(e, t, n);
|
|
2334
|
-
}
|
|
2335
|
-
function Jn(e, t, n) {
|
|
2336
|
-
let r = null, i = e.content.map((e) => {
|
|
2337
|
-
if (e.type === "text") {
|
|
2338
|
-
let n = Yn(t, e.text);
|
|
2339
|
-
return r === null && (r = n), Object.defineProperty({ ...e }, "parsed_output", {
|
|
2340
|
-
value: n,
|
|
2341
|
-
enumerable: !1
|
|
2342
|
-
});
|
|
2343
|
-
}
|
|
2344
|
-
return e;
|
|
2345
|
-
});
|
|
2346
|
-
return {
|
|
2347
|
-
...e,
|
|
2348
|
-
content: i,
|
|
2349
|
-
parsed_output: r
|
|
2350
|
-
};
|
|
2351
|
-
}
|
|
2352
|
-
function Yn(e, t) {
|
|
2353
|
-
let n = Kn(e);
|
|
2354
|
-
if (n?.type !== "json_schema") return null;
|
|
2355
|
-
try {
|
|
2356
|
-
return "parse" in n ? n.parse(t) : JSON.parse(t);
|
|
2357
|
-
} catch (e) {
|
|
2358
|
-
throw new y(`Failed to parse structured output: ${e}`);
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
//#endregion
|
|
2362
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs
|
|
2363
|
-
var q, J, Y, Xn, Zn, Qn, $n, er, tr, X, nr, rr, ir, Z, ar, or, sr, cr, lr, ur, dr, fr, pr, mr, hr = "__json_buf";
|
|
2364
|
-
function gr(e) {
|
|
2365
|
-
return e.type === "tool_use" || e.type === "server_tool_use";
|
|
2366
|
-
}
|
|
2367
|
-
var _r = class e {
|
|
2368
|
-
constructor(e, t) {
|
|
2369
|
-
q.add(this), this.messages = [], this.receivedMessages = [], J.set(this, void 0), Y.set(this, null), this.controller = new AbortController(), Xn.set(this, void 0), Zn.set(this, () => {}), Qn.set(this, () => {}), $n.set(this, void 0), er.set(this, () => {}), tr.set(this, () => {}), X.set(this, {}), nr.set(this, !1), rr.set(this, !1), ir.set(this, !1), Z.set(this, !1), ar.set(this, void 0), or.set(this, void 0), sr.set(this, void 0), ur.set(this, (e) => {
|
|
2370
|
-
if (g(this, rr, !0, "f"), v(e) && (e = new x()), e instanceof x) return g(this, ir, !0, "f"), this._emit("abort", e);
|
|
2371
|
-
if (e instanceof y) return this._emit("error", e);
|
|
2372
|
-
if (e instanceof Error) {
|
|
2373
|
-
let t = new y(e.message);
|
|
2374
|
-
return t.cause = e, this._emit("error", t);
|
|
2375
|
-
}
|
|
2376
|
-
return this._emit("error", new y(String(e)));
|
|
2377
|
-
}), g(this, Xn, new Promise((e, t) => {
|
|
2378
|
-
g(this, Zn, e, "f"), g(this, Qn, t, "f");
|
|
2379
|
-
}), "f"), g(this, $n, new Promise((e, t) => {
|
|
2380
|
-
g(this, er, e, "f"), g(this, tr, t, "f");
|
|
2381
|
-
}), "f"), _(this, Xn, "f").catch(() => {}), _(this, $n, "f").catch(() => {}), g(this, Y, e, "f"), g(this, sr, t?.logger ?? console, "f");
|
|
2382
|
-
}
|
|
2383
|
-
get response() {
|
|
2384
|
-
return _(this, ar, "f");
|
|
2385
|
-
}
|
|
2386
|
-
get request_id() {
|
|
2387
|
-
return _(this, or, "f");
|
|
2388
|
-
}
|
|
2389
|
-
async withResponse() {
|
|
2390
|
-
g(this, Z, !0, "f");
|
|
2391
|
-
let e = await _(this, Xn, "f");
|
|
2392
|
-
if (!e) throw Error("Could not resolve a `Response` object");
|
|
2393
|
-
return {
|
|
2394
|
-
data: this,
|
|
2395
|
-
response: e,
|
|
2396
|
-
request_id: e.headers.get("request-id")
|
|
2397
|
-
};
|
|
2398
|
-
}
|
|
2399
|
-
static fromReadableStream(t) {
|
|
2400
|
-
let n = new e(null);
|
|
2401
|
-
return n._run(() => n._fromReadableStream(t)), n;
|
|
2402
|
-
}
|
|
2403
|
-
static createMessage(t, n, r, { logger: i } = {}) {
|
|
2404
|
-
let a = new e(n, { logger: i });
|
|
2405
|
-
for (let e of n.messages) a._addMessageParam(e);
|
|
2406
|
-
return g(a, Y, {
|
|
2407
|
-
...n,
|
|
2408
|
-
stream: !0
|
|
2409
|
-
}, "f"), a._run(() => a._createMessage(t, {
|
|
2410
|
-
...n,
|
|
2411
|
-
stream: !0
|
|
2412
|
-
}, {
|
|
2413
|
-
...r,
|
|
2414
|
-
headers: {
|
|
2415
|
-
...r?.headers,
|
|
2416
|
-
"X-Stainless-Helper-Method": "stream"
|
|
2417
|
-
}
|
|
2418
|
-
})), a;
|
|
2419
|
-
}
|
|
2420
|
-
_run(e) {
|
|
2421
|
-
e().then(() => {
|
|
2422
|
-
this._emitFinal(), this._emit("end");
|
|
2423
|
-
}, _(this, ur, "f"));
|
|
2424
|
-
}
|
|
2425
|
-
_addMessageParam(e) {
|
|
2426
|
-
this.messages.push(e);
|
|
2427
|
-
}
|
|
2428
|
-
_addMessage(e, t = !0) {
|
|
2429
|
-
this.receivedMessages.push(e), t && this._emit("message", e);
|
|
2430
|
-
}
|
|
2431
|
-
async _createMessage(e, t, n) {
|
|
2432
|
-
let r = n?.signal, i;
|
|
2433
|
-
r && (r.aborted && this.controller.abort(), i = this.controller.abort.bind(this.controller), r.addEventListener("abort", i));
|
|
2434
|
-
try {
|
|
2435
|
-
_(this, q, "m", dr).call(this);
|
|
2436
|
-
let { response: r, data: i } = await e.create({
|
|
2437
|
-
...t,
|
|
2438
|
-
stream: !0
|
|
2439
|
-
}, {
|
|
2440
|
-
...n,
|
|
2441
|
-
signal: this.controller.signal
|
|
2442
|
-
}).withResponse();
|
|
2443
|
-
this._connected(r);
|
|
2444
|
-
for await (let e of i) _(this, q, "m", fr).call(this, e);
|
|
2445
|
-
if (i.controller.signal?.aborted) throw new x();
|
|
2446
|
-
_(this, q, "m", pr).call(this);
|
|
2447
|
-
} finally {
|
|
2448
|
-
r && i && r.removeEventListener("abort", i);
|
|
2449
|
-
}
|
|
2450
|
-
}
|
|
2451
|
-
_connected(e) {
|
|
2452
|
-
this.ended || (g(this, ar, e, "f"), g(this, or, e?.headers.get("request-id"), "f"), _(this, Zn, "f").call(this, e), this._emit("connect"));
|
|
2453
|
-
}
|
|
2454
|
-
get ended() {
|
|
2455
|
-
return _(this, nr, "f");
|
|
2456
|
-
}
|
|
2457
|
-
get errored() {
|
|
2458
|
-
return _(this, rr, "f");
|
|
2459
|
-
}
|
|
2460
|
-
get aborted() {
|
|
2461
|
-
return _(this, ir, "f");
|
|
2462
|
-
}
|
|
2463
|
-
abort() {
|
|
2464
|
-
this.controller.abort();
|
|
2465
|
-
}
|
|
2466
|
-
on(e, t) {
|
|
2467
|
-
return (_(this, X, "f")[e] || (_(this, X, "f")[e] = [])).push({ listener: t }), this;
|
|
2468
|
-
}
|
|
2469
|
-
off(e, t) {
|
|
2470
|
-
let n = _(this, X, "f")[e];
|
|
2471
|
-
if (!n) return this;
|
|
2472
|
-
let r = n.findIndex((e) => e.listener === t);
|
|
2473
|
-
return r >= 0 && n.splice(r, 1), this;
|
|
2474
|
-
}
|
|
2475
|
-
once(e, t) {
|
|
2476
|
-
return (_(this, X, "f")[e] || (_(this, X, "f")[e] = [])).push({
|
|
2477
|
-
listener: t,
|
|
2478
|
-
once: !0
|
|
2479
|
-
}), this;
|
|
2480
|
-
}
|
|
2481
|
-
emitted(e) {
|
|
2482
|
-
return new Promise((t, n) => {
|
|
2483
|
-
g(this, Z, !0, "f"), e !== "error" && this.once("error", n), this.once(e, t);
|
|
2484
|
-
});
|
|
2485
|
-
}
|
|
2486
|
-
async done() {
|
|
2487
|
-
g(this, Z, !0, "f"), await _(this, $n, "f");
|
|
2488
|
-
}
|
|
2489
|
-
get currentMessage() {
|
|
2490
|
-
return _(this, J, "f");
|
|
2491
|
-
}
|
|
2492
|
-
async finalMessage() {
|
|
2493
|
-
return await this.done(), _(this, q, "m", cr).call(this);
|
|
2494
|
-
}
|
|
2495
|
-
async finalText() {
|
|
2496
|
-
return await this.done(), _(this, q, "m", lr).call(this);
|
|
2497
|
-
}
|
|
2498
|
-
_emit(e, ...t) {
|
|
2499
|
-
if (_(this, nr, "f")) return;
|
|
2500
|
-
e === "end" && (g(this, nr, !0, "f"), _(this, er, "f").call(this));
|
|
2501
|
-
let n = _(this, X, "f")[e];
|
|
2502
|
-
if (n && (_(this, X, "f")[e] = n.filter((e) => !e.once), n.forEach(({ listener: e }) => e(...t))), e === "abort") {
|
|
2503
|
-
let e = t[0];
|
|
2504
|
-
!_(this, Z, "f") && !n?.length && Promise.reject(e), _(this, Qn, "f").call(this, e), _(this, tr, "f").call(this, e), this._emit("end");
|
|
2505
|
-
return;
|
|
2506
|
-
}
|
|
2507
|
-
if (e === "error") {
|
|
2508
|
-
let e = t[0];
|
|
2509
|
-
!_(this, Z, "f") && !n?.length && Promise.reject(e), _(this, Qn, "f").call(this, e), _(this, tr, "f").call(this, e), this._emit("end");
|
|
2510
|
-
}
|
|
2511
|
-
}
|
|
2512
|
-
_emitFinal() {
|
|
2513
|
-
this.receivedMessages.at(-1) && this._emit("finalMessage", _(this, q, "m", cr).call(this));
|
|
2514
|
-
}
|
|
2515
|
-
async _fromReadableStream(e, t) {
|
|
2516
|
-
let n = t?.signal, r;
|
|
2517
|
-
n && (n.aborted && this.controller.abort(), r = this.controller.abort.bind(this.controller), n.addEventListener("abort", r));
|
|
2518
|
-
try {
|
|
2519
|
-
_(this, q, "m", dr).call(this), this._connected(null);
|
|
2520
|
-
let t = et.fromReadableStream(e, this.controller);
|
|
2521
|
-
for await (let e of t) _(this, q, "m", fr).call(this, e);
|
|
2522
|
-
if (t.controller.signal?.aborted) throw new x();
|
|
2523
|
-
_(this, q, "m", pr).call(this);
|
|
2524
|
-
} finally {
|
|
2525
|
-
n && r && n.removeEventListener("abort", r);
|
|
2526
|
-
}
|
|
2527
|
-
}
|
|
2528
|
-
[(J = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), Xn = /* @__PURE__ */ new WeakMap(), Zn = /* @__PURE__ */ new WeakMap(), Qn = /* @__PURE__ */ new WeakMap(), $n = /* @__PURE__ */ new WeakMap(), er = /* @__PURE__ */ new WeakMap(), tr = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), nr = /* @__PURE__ */ new WeakMap(), rr = /* @__PURE__ */ new WeakMap(), ir = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(), ar = /* @__PURE__ */ new WeakMap(), or = /* @__PURE__ */ new WeakMap(), sr = /* @__PURE__ */ new WeakMap(), ur = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakSet(), cr = function() {
|
|
2529
|
-
if (this.receivedMessages.length === 0) throw new y("stream ended without producing a Message with role=assistant");
|
|
2530
|
-
return this.receivedMessages.at(-1);
|
|
2531
|
-
}, lr = function() {
|
|
2532
|
-
if (this.receivedMessages.length === 0) throw new y("stream ended without producing a Message with role=assistant");
|
|
2533
|
-
let e = this.receivedMessages.at(-1).content.filter((e) => e.type === "text").map((e) => e.text);
|
|
2534
|
-
if (e.length === 0) throw new y("stream ended without producing a content block with type=text");
|
|
2535
|
-
return e.join(" ");
|
|
2536
|
-
}, dr = function() {
|
|
2537
|
-
this.ended || g(this, J, void 0, "f");
|
|
2538
|
-
}, fr = function(e) {
|
|
2539
|
-
if (this.ended) return;
|
|
2540
|
-
let t = _(this, q, "m", mr).call(this, e);
|
|
2541
|
-
switch (this._emit("streamEvent", e, t), e.type) {
|
|
2542
|
-
case "content_block_delta": {
|
|
2543
|
-
let n = t.content.at(-1);
|
|
2544
|
-
switch (e.delta.type) {
|
|
2545
|
-
case "text_delta":
|
|
2546
|
-
n.type === "text" && this._emit("text", e.delta.text, n.text || "");
|
|
2547
|
-
break;
|
|
2548
|
-
case "citations_delta":
|
|
2549
|
-
n.type === "text" && this._emit("citation", e.delta.citation, n.citations ?? []);
|
|
2550
|
-
break;
|
|
2551
|
-
case "input_json_delta":
|
|
2552
|
-
gr(n) && n.input && this._emit("inputJson", e.delta.partial_json, n.input);
|
|
2553
|
-
break;
|
|
2554
|
-
case "thinking_delta":
|
|
2555
|
-
n.type === "thinking" && this._emit("thinking", e.delta.thinking, n.thinking);
|
|
2556
|
-
break;
|
|
2557
|
-
case "signature_delta":
|
|
2558
|
-
n.type === "thinking" && this._emit("signature", n.signature);
|
|
2559
|
-
break;
|
|
2560
|
-
default: e.delta;
|
|
2561
|
-
}
|
|
2562
|
-
break;
|
|
2563
|
-
}
|
|
2564
|
-
case "message_stop":
|
|
2565
|
-
this._addMessageParam(t), this._addMessage(qn(t, _(this, Y, "f"), { logger: _(this, sr, "f") }), !0);
|
|
2566
|
-
break;
|
|
2567
|
-
case "content_block_stop":
|
|
2568
|
-
this._emit("contentBlock", t.content.at(-1));
|
|
2569
|
-
break;
|
|
2570
|
-
case "message_start": g(this, J, t, "f");
|
|
2571
|
-
}
|
|
2572
|
-
}, pr = function() {
|
|
2573
|
-
if (this.ended) throw new y("stream has ended, this shouldn't happen");
|
|
2574
|
-
let e = _(this, J, "f");
|
|
2575
|
-
if (!e) throw new y("request ended without sending any chunks");
|
|
2576
|
-
return g(this, J, void 0, "f"), qn(e, _(this, Y, "f"), { logger: _(this, sr, "f") });
|
|
2577
|
-
}, mr = function(e) {
|
|
2578
|
-
let t = _(this, J, "f");
|
|
2579
|
-
if (e.type === "message_start") {
|
|
2580
|
-
if (t) throw new y(`Unexpected event order, got ${e.type} before receiving "message_stop"`);
|
|
2581
|
-
return e.message;
|
|
2582
|
-
}
|
|
2583
|
-
if (!t) throw new y(`Unexpected event order, got ${e.type} before "message_start"`);
|
|
2584
|
-
switch (e.type) {
|
|
2585
|
-
case "message_stop": return t;
|
|
2586
|
-
case "message_delta": return t.stop_reason = e.delta.stop_reason, t.stop_sequence = e.delta.stop_sequence, t.usage.output_tokens = e.usage.output_tokens, e.usage.input_tokens != null && (t.usage.input_tokens = e.usage.input_tokens), e.usage.cache_creation_input_tokens != null && (t.usage.cache_creation_input_tokens = e.usage.cache_creation_input_tokens), e.usage.cache_read_input_tokens != null && (t.usage.cache_read_input_tokens = e.usage.cache_read_input_tokens), e.usage.server_tool_use != null && (t.usage.server_tool_use = e.usage.server_tool_use), t;
|
|
2587
|
-
case "content_block_start": return t.content.push({ ...e.content_block }), t;
|
|
2588
|
-
case "content_block_delta": {
|
|
2589
|
-
let n = t.content.at(e.index);
|
|
2590
|
-
switch (e.delta.type) {
|
|
2591
|
-
case "text_delta":
|
|
2592
|
-
n?.type === "text" && (t.content[e.index] = {
|
|
2593
|
-
...n,
|
|
2594
|
-
text: (n.text || "") + e.delta.text
|
|
2595
|
-
});
|
|
2596
|
-
break;
|
|
2597
|
-
case "citations_delta":
|
|
2598
|
-
n?.type === "text" && (t.content[e.index] = {
|
|
2599
|
-
...n,
|
|
2600
|
-
citations: [...n.citations ?? [], e.delta.citation]
|
|
2601
|
-
});
|
|
2602
|
-
break;
|
|
2603
|
-
case "input_json_delta":
|
|
2604
|
-
if (n && gr(n)) {
|
|
2605
|
-
let r = n[hr] || "";
|
|
2606
|
-
r += e.delta.partial_json;
|
|
2607
|
-
let i = { ...n };
|
|
2608
|
-
Object.defineProperty(i, hr, {
|
|
2609
|
-
value: r,
|
|
2610
|
-
enumerable: !1,
|
|
2611
|
-
writable: !0
|
|
2612
|
-
}), r && (i.input = tn(r)), t.content[e.index] = i;
|
|
2613
|
-
}
|
|
2614
|
-
break;
|
|
2615
|
-
case "thinking_delta":
|
|
2616
|
-
n?.type === "thinking" && (t.content[e.index] = {
|
|
2617
|
-
...n,
|
|
2618
|
-
thinking: n.thinking + e.delta.thinking
|
|
2619
|
-
});
|
|
2620
|
-
break;
|
|
2621
|
-
case "signature_delta":
|
|
2622
|
-
n?.type === "thinking" && (t.content[e.index] = {
|
|
2623
|
-
...n,
|
|
2624
|
-
signature: e.delta.signature
|
|
2625
|
-
});
|
|
2626
|
-
break;
|
|
2627
|
-
default: e.delta;
|
|
2628
|
-
}
|
|
2629
|
-
return t;
|
|
2630
|
-
}
|
|
2631
|
-
case "content_block_stop": return t;
|
|
2632
|
-
}
|
|
2633
|
-
}, Symbol.asyncIterator)]() {
|
|
2634
|
-
let e = [], t = [], n = !1;
|
|
2635
|
-
return this.on("streamEvent", (n) => {
|
|
2636
|
-
let r = t.shift();
|
|
2637
|
-
r ? r.resolve(n) : e.push(n);
|
|
2638
|
-
}), this.on("end", () => {
|
|
2639
|
-
n = !0;
|
|
2640
|
-
for (let e of t) e.resolve(void 0);
|
|
2641
|
-
t.length = 0;
|
|
2642
|
-
}), this.on("abort", (e) => {
|
|
2643
|
-
n = !0;
|
|
2644
|
-
for (let n of t) n.reject(e);
|
|
2645
|
-
t.length = 0;
|
|
2646
|
-
}), this.on("error", (e) => {
|
|
2647
|
-
n = !0;
|
|
2648
|
-
for (let n of t) n.reject(e);
|
|
2649
|
-
t.length = 0;
|
|
2650
|
-
}), {
|
|
2651
|
-
next: async () => e.length ? {
|
|
2652
|
-
value: e.shift(),
|
|
2653
|
-
done: !1
|
|
2654
|
-
} : n ? {
|
|
2655
|
-
value: void 0,
|
|
2656
|
-
done: !0
|
|
2657
|
-
} : new Promise((e, n) => t.push({
|
|
2658
|
-
resolve: e,
|
|
2659
|
-
reject: n
|
|
2660
|
-
})).then((e) => e ? {
|
|
2661
|
-
value: e,
|
|
2662
|
-
done: !1
|
|
2663
|
-
} : {
|
|
2664
|
-
value: void 0,
|
|
2665
|
-
done: !0
|
|
2666
|
-
}),
|
|
2667
|
-
return: async () => (this.abort(), {
|
|
2668
|
-
value: void 0,
|
|
2669
|
-
done: !0
|
|
2670
|
-
})
|
|
2671
|
-
};
|
|
2672
|
-
}
|
|
2673
|
-
toReadableStream() {
|
|
2674
|
-
return new et(this[Symbol.asyncIterator].bind(this), this.controller).toReadableStream();
|
|
2675
|
-
}
|
|
2676
|
-
}, vr = class extends k {
|
|
2677
|
-
create(e, t) {
|
|
2678
|
-
return this._client.post("/v1/messages/batches", {
|
|
2679
|
-
body: e,
|
|
2680
|
-
...t
|
|
2681
|
-
});
|
|
2682
|
-
}
|
|
2683
|
-
retrieve(e, t) {
|
|
2684
|
-
return this._client.get(j`/v1/messages/batches/${e}`, t);
|
|
2685
|
-
}
|
|
2686
|
-
list(e = {}, t) {
|
|
2687
|
-
return this._client.getAPIList("/v1/messages/batches", ft, {
|
|
2688
|
-
query: e,
|
|
2689
|
-
...t
|
|
2690
|
-
});
|
|
2691
|
-
}
|
|
2692
|
-
delete(e, t) {
|
|
2693
|
-
return this._client.delete(j`/v1/messages/batches/${e}`, t);
|
|
2694
|
-
}
|
|
2695
|
-
cancel(e, t) {
|
|
2696
|
-
return this._client.post(j`/v1/messages/batches/${e}/cancel`, t);
|
|
2697
|
-
}
|
|
2698
|
-
async results(e, t) {
|
|
2699
|
-
let n = await this.retrieve(e);
|
|
2700
|
-
if (!n.results_url) throw new y(`No batch \`results_url\`; Has it finished processing? ${n.processing_status} - ${n.id}`);
|
|
2701
|
-
return this._client.get(n.results_url, {
|
|
2702
|
-
...t,
|
|
2703
|
-
headers: A([{ Accept: "application/binary" }, t?.headers]),
|
|
2704
|
-
stream: !0,
|
|
2705
|
-
__binaryResponse: !0
|
|
2706
|
-
})._thenUnwrap((e, t) => Mn.fromResponse(t.response, t.controller));
|
|
2707
|
-
}
|
|
2708
|
-
}, yr = class extends k {
|
|
2709
|
-
constructor() {
|
|
2710
|
-
super(...arguments), this.batches = new vr(this._client);
|
|
2711
|
-
}
|
|
2712
|
-
create(e, t) {
|
|
2713
|
-
e.model in br && console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${br[e.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`), xr.includes(e.model) && e.thinking && e.thinking.type === "enabled" && console.warn(`Using Claude with ${e.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);
|
|
2714
|
-
let n = this._client._options.timeout;
|
|
2715
|
-
if (!e.stream && n == null) {
|
|
2716
|
-
let t = Kt[e.model] ?? void 0;
|
|
2717
|
-
n = this._client.calculateNonstreamingTimeout(e.max_tokens, t);
|
|
2718
|
-
}
|
|
2719
|
-
let r = It(e.tools, e.messages);
|
|
2720
|
-
return this._client.post("/v1/messages", {
|
|
2721
|
-
body: e,
|
|
2722
|
-
timeout: n ?? 6e5,
|
|
2723
|
-
...t,
|
|
2724
|
-
headers: A([r, t?.headers]),
|
|
2725
|
-
stream: e.stream ?? !1
|
|
2726
|
-
});
|
|
2727
|
-
}
|
|
2728
|
-
parse(e, t) {
|
|
2729
|
-
return this.create(e, t).then((t) => Jn(t, e, { logger: this._client.logger ?? console }));
|
|
2730
|
-
}
|
|
2731
|
-
stream(e, t) {
|
|
2732
|
-
return _r.createMessage(this, e, t, { logger: this._client.logger ?? console });
|
|
2733
|
-
}
|
|
2734
|
-
countTokens(e, t) {
|
|
2735
|
-
return this._client.post("/v1/messages/count_tokens", {
|
|
2736
|
-
body: e,
|
|
2737
|
-
...t
|
|
2738
|
-
});
|
|
2739
|
-
}
|
|
2740
|
-
}, br = {
|
|
2741
|
-
"claude-1.3": "November 6th, 2024",
|
|
2742
|
-
"claude-1.3-100k": "November 6th, 2024",
|
|
2743
|
-
"claude-instant-1.1": "November 6th, 2024",
|
|
2744
|
-
"claude-instant-1.1-100k": "November 6th, 2024",
|
|
2745
|
-
"claude-instant-1.2": "November 6th, 2024",
|
|
2746
|
-
"claude-3-sonnet-20240229": "July 21st, 2025",
|
|
2747
|
-
"claude-3-opus-20240229": "January 5th, 2026",
|
|
2748
|
-
"claude-2.1": "July 21st, 2025",
|
|
2749
|
-
"claude-2.0": "July 21st, 2025",
|
|
2750
|
-
"claude-3-7-sonnet-latest": "February 19th, 2026",
|
|
2751
|
-
"claude-3-7-sonnet-20250219": "February 19th, 2026",
|
|
2752
|
-
"claude-3-5-haiku-latest": "February 19th, 2026",
|
|
2753
|
-
"claude-3-5-haiku-20241022": "February 19th, 2026",
|
|
2754
|
-
"claude-opus-4-0": "June 15th, 2026",
|
|
2755
|
-
"claude-opus-4-20250514": "June 15th, 2026",
|
|
2756
|
-
"claude-sonnet-4-0": "June 15th, 2026",
|
|
2757
|
-
"claude-sonnet-4-20250514": "June 15th, 2026"
|
|
2758
|
-
}, xr = ["claude-mythos-preview", "claude-opus-4-6"];
|
|
2759
|
-
yr.Batches = vr;
|
|
2760
|
-
//#endregion
|
|
2761
|
-
//#region ../../../../node_modules/.pnpm/@anthropic-ai+sdk@0.91.1_zod@4.4.3/node_modules/@anthropic-ai/sdk/resources/models.mjs
|
|
2762
|
-
var Sr = class extends k {
|
|
2763
|
-
retrieve(e, t = {}, n) {
|
|
2764
|
-
let { betas: r } = t ?? {};
|
|
2765
|
-
return this._client.get(j`/v1/models/${e}`, {
|
|
2766
|
-
...n,
|
|
2767
|
-
headers: A([{ ...r?.toString() == null ? void 0 : { "anthropic-beta": r?.toString() } }, n?.headers])
|
|
2768
|
-
});
|
|
2769
|
-
}
|
|
2770
|
-
list(e = {}, t) {
|
|
2771
|
-
let { betas: n, ...r } = e ?? {};
|
|
2772
|
-
return this._client.getAPIList("/v1/models", ft, {
|
|
2773
|
-
query: r,
|
|
2774
|
-
...t,
|
|
2775
|
-
headers: A([{ ...n?.toString() == null ? void 0 : { "anthropic-beta": n?.toString() } }, t?.headers])
|
|
2776
|
-
});
|
|
2777
|
-
}
|
|
2778
|
-
}, Cr = (e) => {
|
|
2779
|
-
if (globalThis.process !== void 0) return globalThis.process.env?.[e]?.trim() || void 0;
|
|
2780
|
-
if (globalThis.Deno !== void 0) return globalThis.Deno.env?.get?.(e)?.trim() || void 0;
|
|
2781
|
-
}, wr, Tr, Er, Dr, Or = "\\n\\nHuman:", kr = "\\n\\nAssistant:", Q = class {
|
|
2782
|
-
constructor({ baseURL: e = Cr("ANTHROPIC_BASE_URL"), apiKey: t = Cr("ANTHROPIC_API_KEY") ?? null, authToken: n = Cr("ANTHROPIC_AUTH_TOKEN") ?? null, ...r } = {}) {
|
|
2783
|
-
wr.add(this), Er.set(this, void 0);
|
|
2784
|
-
let i = {
|
|
2785
|
-
apiKey: t,
|
|
2786
|
-
authToken: n,
|
|
2787
|
-
...r,
|
|
2788
|
-
baseURL: e || "https://api.anthropic.com"
|
|
2789
|
-
};
|
|
2790
|
-
if (!i.dangerouslyAllowBrowser && we()) throw new y("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew Anthropic({ apiKey, dangerouslyAllowBrowser: true });\n");
|
|
2791
|
-
this.baseURL = i.baseURL, this.timeout = i.timeout ?? Tr.DEFAULT_TIMEOUT, this.logger = i.logger ?? console;
|
|
2792
|
-
let a = "warn";
|
|
2793
|
-
this.logLevel = a, this.logLevel = Je(i.logLevel, "ClientOptions.logLevel", this) ?? Je(Cr("ANTHROPIC_LOG"), "process.env['ANTHROPIC_LOG']", this) ?? a, this.fetchOptions = i.fetchOptions, this.maxRetries = i.maxRetries ?? 2, this.fetch = i.fetch ?? Me(), g(this, Er, Le, "f"), this._options = i, this.apiKey = typeof t == "string" ? t : null, this.authToken = n;
|
|
2794
|
-
}
|
|
2795
|
-
withOptions(e) {
|
|
2796
|
-
return new this.constructor({
|
|
2797
|
-
...this._options,
|
|
2798
|
-
baseURL: this.baseURL,
|
|
2799
|
-
maxRetries: this.maxRetries,
|
|
2800
|
-
timeout: this.timeout,
|
|
2801
|
-
logger: this.logger,
|
|
2802
|
-
logLevel: this.logLevel,
|
|
2803
|
-
fetch: this.fetch,
|
|
2804
|
-
fetchOptions: this.fetchOptions,
|
|
2805
|
-
apiKey: this.apiKey,
|
|
2806
|
-
authToken: this.authToken,
|
|
2807
|
-
...e
|
|
2808
|
-
});
|
|
2809
|
-
}
|
|
2810
|
-
defaultQuery() {
|
|
2811
|
-
return this._options.defaultQuery;
|
|
2812
|
-
}
|
|
2813
|
-
validateHeaders({ values: e, nulls: t }) {
|
|
2814
|
-
if (!(e.get("x-api-key") || e.get("authorization")) && !(this.apiKey && e.get("x-api-key")) && !t.has("x-api-key") && !(this.authToken && e.get("authorization")) && !t.has("authorization")) throw Error("Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the \"X-Api-Key\" or \"Authorization\" headers to be explicitly omitted");
|
|
2815
|
-
}
|
|
2816
|
-
async authHeaders(e) {
|
|
2817
|
-
return A([await this.apiKeyAuth(e), await this.bearerAuth(e)]);
|
|
2818
|
-
}
|
|
2819
|
-
async apiKeyAuth(e) {
|
|
2820
|
-
if (this.apiKey != null) return A([{ "X-Api-Key": this.apiKey }]);
|
|
2821
|
-
}
|
|
2822
|
-
async bearerAuth(e) {
|
|
2823
|
-
if (this.authToken != null) return A([{ Authorization: `Bearer ${this.authToken}` }]);
|
|
2824
|
-
}
|
|
2825
|
-
stringifyQuery(e) {
|
|
2826
|
-
return Re(e);
|
|
2827
|
-
}
|
|
2828
|
-
getUserAgent() {
|
|
2829
|
-
return `${this.constructor.name}/JS ${S}`;
|
|
2830
|
-
}
|
|
2831
|
-
defaultIdempotencyKey() {
|
|
2832
|
-
return `stainless-node-retry-${ne()}`;
|
|
2833
|
-
}
|
|
2834
|
-
makeStatusError(e, t, n, r) {
|
|
2835
|
-
return b.generate(e, t, n, r);
|
|
2836
|
-
}
|
|
2837
|
-
buildURL(e, t, n) {
|
|
2838
|
-
let r = !_(this, wr, "m", Dr).call(this) && n || this.baseURL, i = he(e) ? new URL(e) : new URL(r + (r.endsWith("/") && e.startsWith("/") ? e.slice(1) : e)), a = this.defaultQuery(), o = Object.fromEntries(i.searchParams);
|
|
2839
|
-
return (!ye(a) || !ye(o)) && (t = {
|
|
2840
|
-
...o,
|
|
2841
|
-
...a,
|
|
2842
|
-
...t
|
|
2843
|
-
}), typeof t == "object" && t && !Array.isArray(t) && (i.search = this.stringifyQuery(t)), i.toString();
|
|
2844
|
-
}
|
|
2845
|
-
_calculateNonstreamingTimeout(e) {
|
|
2846
|
-
if (3600 * e / 128e3 > 600) throw new y("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");
|
|
2847
|
-
return 6e5;
|
|
2848
|
-
}
|
|
2849
|
-
async prepareOptions(e) {}
|
|
2850
|
-
async prepareRequest(e, { url: t, options: n }) {}
|
|
2851
|
-
get(e, t) {
|
|
2852
|
-
return this.methodRequest("get", e, t);
|
|
2853
|
-
}
|
|
2854
|
-
post(e, t) {
|
|
2855
|
-
return this.methodRequest("post", e, t);
|
|
2856
|
-
}
|
|
2857
|
-
patch(e, t) {
|
|
2858
|
-
return this.methodRequest("patch", e, t);
|
|
2859
|
-
}
|
|
2860
|
-
put(e, t) {
|
|
2861
|
-
return this.methodRequest("put", e, t);
|
|
2862
|
-
}
|
|
2863
|
-
delete(e, t) {
|
|
2864
|
-
return this.methodRequest("delete", e, t);
|
|
2865
|
-
}
|
|
2866
|
-
methodRequest(e, t, n) {
|
|
2867
|
-
return this.request(Promise.resolve(n).then((n) => ({
|
|
2868
|
-
method: e,
|
|
2869
|
-
path: t,
|
|
2870
|
-
...n
|
|
2871
|
-
})));
|
|
2872
|
-
}
|
|
2873
|
-
request(e, t = null) {
|
|
2874
|
-
return new ct(this, this.makeRequest(e, t, void 0));
|
|
2875
|
-
}
|
|
2876
|
-
async makeRequest(e, t, n) {
|
|
2877
|
-
let r = await e, i = r.maxRetries ?? this.maxRetries;
|
|
2878
|
-
t ??= i, await this.prepareOptions(r);
|
|
2879
|
-
let { req: a, url: o, timeout: s } = await this.buildRequest(r, { retryCount: i - t });
|
|
2880
|
-
await this.prepareRequest(a, {
|
|
2881
|
-
url: o,
|
|
2882
|
-
options: r
|
|
2883
|
-
});
|
|
2884
|
-
let c = "log_" + (Math.random() * (1 << 24) | 0).toString(16).padStart(6, "0"), l = n === void 0 ? "" : `, retryOf: ${n}`, u = Date.now();
|
|
2885
|
-
if (T(this).debug(`[${c}] sending request`, E({
|
|
2886
|
-
retryOfRequestLogID: n,
|
|
2887
|
-
method: r.method,
|
|
2888
|
-
url: o,
|
|
2889
|
-
options: r,
|
|
2890
|
-
headers: a.headers
|
|
2891
|
-
})), r.signal?.aborted) throw new x();
|
|
2892
|
-
let d = new AbortController(), f = await this.fetchWithTimeout(o, a, s, d).catch(re), p = Date.now();
|
|
2893
|
-
if (f instanceof globalThis.Error) {
|
|
2894
|
-
let e = `retrying, ${t} attempts remaining`;
|
|
2895
|
-
if (r.signal?.aborted) throw new x();
|
|
2896
|
-
let i = v(f) || /timed? ?out/i.test(String(f) + ("cause" in f ? String(f.cause) : ""));
|
|
2897
|
-
if (t) return T(this).info(`[${c}] connection ${i ? "timed out" : "failed"} - ${e}`), T(this).debug(`[${c}] connection ${i ? "timed out" : "failed"} (${e})`, E({
|
|
2898
|
-
retryOfRequestLogID: n,
|
|
2899
|
-
url: o,
|
|
2900
|
-
durationMs: p - u,
|
|
2901
|
-
message: f.message
|
|
2902
|
-
})), this.retryRequest(r, t, n ?? c);
|
|
2903
|
-
throw T(this).info(`[${c}] connection ${i ? "timed out" : "failed"} - error; no more retries left`), T(this).debug(`[${c}] connection ${i ? "timed out" : "failed"} (error; no more retries left)`, E({
|
|
2904
|
-
retryOfRequestLogID: n,
|
|
2905
|
-
url: o,
|
|
2906
|
-
durationMs: p - u,
|
|
2907
|
-
message: f.message
|
|
2908
|
-
})), i ? new ae() : new ie({ cause: f });
|
|
2909
|
-
}
|
|
2910
|
-
let m = `[${c}${l}${[...f.headers.entries()].filter(([e]) => e === "request-id").map(([e, t]) => ", " + e + ": " + JSON.stringify(t)).join("")}] ${a.method} ${o} ${f.ok ? "succeeded" : "failed"} with status ${f.status} in ${p - u}ms`;
|
|
2911
|
-
if (!f.ok) {
|
|
2912
|
-
let e = await this.shouldRetry(f);
|
|
2913
|
-
if (t && e) {
|
|
2914
|
-
let e = `retrying, ${t} attempts remaining`;
|
|
2915
|
-
return await Ie(f.body), T(this).info(`${m} - ${e}`), T(this).debug(`[${c}] response error (${e})`, E({
|
|
2916
|
-
retryOfRequestLogID: n,
|
|
2917
|
-
url: f.url,
|
|
2918
|
-
status: f.status,
|
|
2919
|
-
headers: f.headers,
|
|
2920
|
-
durationMs: p - u
|
|
2921
|
-
})), this.retryRequest(r, t, n ?? c, f.headers);
|
|
2922
|
-
}
|
|
2923
|
-
let i = e ? "error; no more retries left" : "error; not retryable";
|
|
2924
|
-
T(this).info(`${m} - ${i}`);
|
|
2925
|
-
let a = await f.text().catch((e) => re(e).message), o = Se(a), s = o ? void 0 : a;
|
|
2926
|
-
throw T(this).debug(`[${c}] response error (${i})`, E({
|
|
2927
|
-
retryOfRequestLogID: n,
|
|
2928
|
-
url: f.url,
|
|
2929
|
-
status: f.status,
|
|
2930
|
-
headers: f.headers,
|
|
2931
|
-
message: s,
|
|
2932
|
-
durationMs: Date.now() - u
|
|
2933
|
-
})), this.makeStatusError(f.status, o, s, f.headers);
|
|
2934
|
-
}
|
|
2935
|
-
return T(this).info(m), T(this).debug(`[${c}] response start`, E({
|
|
2936
|
-
retryOfRequestLogID: n,
|
|
2937
|
-
url: f.url,
|
|
2938
|
-
status: f.status,
|
|
2939
|
-
headers: f.headers,
|
|
2940
|
-
durationMs: p - u
|
|
2941
|
-
})), {
|
|
2942
|
-
response: f,
|
|
2943
|
-
options: r,
|
|
2944
|
-
controller: d,
|
|
2945
|
-
requestLogID: c,
|
|
2946
|
-
retryOfRequestLogID: n,
|
|
2947
|
-
startTime: u
|
|
2948
|
-
};
|
|
2949
|
-
}
|
|
2950
|
-
getAPIList(e, t, n) {
|
|
2951
|
-
return this.requestAPIList(t, n && "then" in n ? n.then((t) => ({
|
|
2952
|
-
method: "get",
|
|
2953
|
-
path: e,
|
|
2954
|
-
...t
|
|
2955
|
-
})) : {
|
|
2956
|
-
method: "get",
|
|
2957
|
-
path: e,
|
|
2958
|
-
...n
|
|
2959
|
-
});
|
|
2960
|
-
}
|
|
2961
|
-
requestAPIList(e, t) {
|
|
2962
|
-
let n = this.makeRequest(t, null, void 0);
|
|
2963
|
-
return new dt(this, n, e);
|
|
2964
|
-
}
|
|
2965
|
-
async fetchWithTimeout(e, t, n, r) {
|
|
2966
|
-
let { signal: i, method: a, ...o } = t || {}, s = this._makeAbort(r);
|
|
2967
|
-
i && i.addEventListener("abort", s, { once: !0 });
|
|
2968
|
-
let c = setTimeout(s, n), l = globalThis.ReadableStream && o.body instanceof globalThis.ReadableStream || typeof o.body == "object" && o.body !== null && Symbol.asyncIterator in o.body, u = {
|
|
2969
|
-
signal: r.signal,
|
|
2970
|
-
...l ? { duplex: "half" } : {},
|
|
2971
|
-
method: "GET",
|
|
2972
|
-
...o
|
|
2973
|
-
};
|
|
2974
|
-
a && (u.method = a.toUpperCase());
|
|
2975
|
-
try {
|
|
2976
|
-
return await this.fetch.call(void 0, e, u);
|
|
2977
|
-
} finally {
|
|
2978
|
-
clearTimeout(c);
|
|
2979
|
-
}
|
|
2980
|
-
}
|
|
2981
|
-
async shouldRetry(e) {
|
|
2982
|
-
let t = e.headers.get("x-should-retry");
|
|
2983
|
-
return t === "true" ? !0 : t === "false" ? !1 : e.status === 408 || e.status === 409 || e.status === 429 || e.status >= 500;
|
|
2984
|
-
}
|
|
2985
|
-
async retryRequest(e, t, n, r) {
|
|
2986
|
-
let i, a = r?.get("retry-after-ms");
|
|
2987
|
-
if (a) {
|
|
2988
|
-
let e = parseFloat(a);
|
|
2989
|
-
Number.isNaN(e) || (i = e);
|
|
2990
|
-
}
|
|
2991
|
-
let o = r?.get("retry-after");
|
|
2992
|
-
if (o && !i) {
|
|
2993
|
-
let e = parseFloat(o);
|
|
2994
|
-
i = Number.isNaN(e) ? Date.parse(o) - Date.now() : e * 1e3;
|
|
2995
|
-
}
|
|
2996
|
-
if (i === void 0) {
|
|
2997
|
-
let n = e.maxRetries ?? this.maxRetries;
|
|
2998
|
-
i = this.calculateDefaultRetryTimeoutMillis(t, n);
|
|
2999
|
-
}
|
|
3000
|
-
return await Ce(i), this.makeRequest(e, t - 1, n);
|
|
3001
|
-
}
|
|
3002
|
-
calculateDefaultRetryTimeoutMillis(e, t) {
|
|
3003
|
-
let n = t - e;
|
|
3004
|
-
return Math.min(.5 * 2 ** n, 8) * (1 - Math.random() * .25) * 1e3;
|
|
3005
|
-
}
|
|
3006
|
-
calculateNonstreamingTimeout(e, t) {
|
|
3007
|
-
let n = 6e5;
|
|
3008
|
-
if (36e5 * e / 128e3 > n || t != null && e > t) throw new y("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");
|
|
3009
|
-
return n;
|
|
3010
|
-
}
|
|
3011
|
-
async buildRequest(e, { retryCount: t = 0 } = {}) {
|
|
3012
|
-
let n = { ...e }, { method: r, path: i, query: a, defaultBaseURL: o } = n, s = this.buildURL(i, a, o);
|
|
3013
|
-
"timeout" in n && xe("timeout", n.timeout), n.timeout = n.timeout ?? this.timeout;
|
|
3014
|
-
let { bodyHeaders: c, body: l } = this.buildBody({ options: n });
|
|
3015
|
-
return {
|
|
3016
|
-
req: {
|
|
3017
|
-
method: r,
|
|
3018
|
-
headers: await this.buildHeaders({
|
|
3019
|
-
options: e,
|
|
3020
|
-
method: r,
|
|
3021
|
-
bodyHeaders: c,
|
|
3022
|
-
retryCount: t
|
|
3023
|
-
}),
|
|
3024
|
-
...n.signal && { signal: n.signal },
|
|
3025
|
-
...globalThis.ReadableStream && l instanceof globalThis.ReadableStream && { duplex: "half" },
|
|
3026
|
-
...l && { body: l },
|
|
3027
|
-
...this.fetchOptions ?? {},
|
|
3028
|
-
...n.fetchOptions ?? {}
|
|
3029
|
-
},
|
|
3030
|
-
url: s,
|
|
3031
|
-
timeout: n.timeout
|
|
3032
|
-
};
|
|
3033
|
-
}
|
|
3034
|
-
async buildHeaders({ options: e, method: t, bodyHeaders: n, retryCount: r }) {
|
|
3035
|
-
let i = {};
|
|
3036
|
-
this.idempotencyHeader && t !== "get" && (e.idempotencyKey ||= this.defaultIdempotencyKey(), i[this.idempotencyHeader] = e.idempotencyKey);
|
|
3037
|
-
let a = A([
|
|
3038
|
-
i,
|
|
3039
|
-
{
|
|
3040
|
-
Accept: "application/json",
|
|
3041
|
-
"User-Agent": this.getUserAgent(),
|
|
3042
|
-
"X-Stainless-Retry-Count": String(r),
|
|
3043
|
-
...e.timeout ? { "X-Stainless-Timeout": String(Math.trunc(e.timeout / 1e3)) } : {},
|
|
3044
|
-
...je(),
|
|
3045
|
-
...this._options.dangerouslyAllowBrowser ? { "anthropic-dangerous-direct-browser-access": "true" } : void 0,
|
|
3046
|
-
"anthropic-version": "2023-06-01"
|
|
3047
|
-
},
|
|
3048
|
-
await this.authHeaders(e),
|
|
3049
|
-
this._options.defaultHeaders,
|
|
3050
|
-
n,
|
|
3051
|
-
e.headers
|
|
3052
|
-
]);
|
|
3053
|
-
return this.validateHeaders(a), a.values;
|
|
3054
|
-
}
|
|
3055
|
-
_makeAbort(e) {
|
|
3056
|
-
return () => e.abort();
|
|
3057
|
-
}
|
|
3058
|
-
buildBody({ options: { body: e, headers: t } }) {
|
|
3059
|
-
if (!e) return {
|
|
3060
|
-
bodyHeaders: void 0,
|
|
3061
|
-
body: void 0
|
|
3062
|
-
};
|
|
3063
|
-
let n = A([t]);
|
|
3064
|
-
return ArrayBuffer.isView(e) || e instanceof ArrayBuffer || e instanceof DataView || typeof e == "string" && n.values.has("content-type") || globalThis.Blob && e instanceof globalThis.Blob || e instanceof FormData || e instanceof URLSearchParams || globalThis.ReadableStream && e instanceof globalThis.ReadableStream ? {
|
|
3065
|
-
bodyHeaders: void 0,
|
|
3066
|
-
body: e
|
|
3067
|
-
} : typeof e == "object" && (Symbol.asyncIterator in e || Symbol.iterator in e && "next" in e && typeof e.next == "function") ? {
|
|
3068
|
-
bodyHeaders: void 0,
|
|
3069
|
-
body: Pe(e)
|
|
3070
|
-
} : typeof e == "object" && n.values.get("content-type") === "application/x-www-form-urlencoded" ? {
|
|
3071
|
-
bodyHeaders: { "content-type": "application/x-www-form-urlencoded" },
|
|
3072
|
-
body: this.stringifyQuery(e)
|
|
3073
|
-
} : _(this, Er, "f").call(this, {
|
|
3074
|
-
body: e,
|
|
3075
|
-
headers: n
|
|
3076
|
-
});
|
|
3077
|
-
}
|
|
3078
|
-
};
|
|
3079
|
-
Tr = Q, Er = /* @__PURE__ */ new WeakMap(), wr = /* @__PURE__ */ new WeakSet(), Dr = function() {
|
|
3080
|
-
return this.baseURL !== "https://api.anthropic.com";
|
|
3081
|
-
}, Q.Anthropic = Tr, Q.HUMAN_PROMPT = Or, Q.AI_PROMPT = kr, Q.DEFAULT_TIMEOUT = 6e5, Q.AnthropicError = y, Q.APIError = b, Q.APIConnectionError = ie, Q.APIConnectionTimeoutError = ae, Q.APIUserAbortError = x, Q.NotFoundError = le, Q.ConflictError = ue, Q.RateLimitError = fe, Q.BadRequestError = oe, Q.AuthenticationError = se, Q.InternalServerError = pe, Q.PermissionDeniedError = ce, Q.UnprocessableEntityError = de, Q.toFile = Tt;
|
|
3082
|
-
var $ = class extends Q {
|
|
3083
|
-
constructor() {
|
|
3084
|
-
super(...arguments), this.completions = new Gn(this), this.messages = new yr(this), this.models = new Sr(this), this.beta = new K(this);
|
|
3085
|
-
}
|
|
3086
|
-
};
|
|
3087
|
-
$.Completions = Gn, $.Messages = yr, $.Models = Sr, $.Beta = K;
|
|
3088
|
-
//#endregion
|
|
3089
|
-
//#region ../../../../node_modules/.pnpm/@earendil-works+pi-ai@0.84.2_supports-color@10.2.2_ws@8.21.3_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js
|
|
3090
|
-
function Ar(e, t) {
|
|
3091
|
-
return e || (i("PI_CACHE_RETENTION", t) === "long" ? "long" : "short");
|
|
3092
|
-
}
|
|
3093
|
-
function jr(e, t, n) {
|
|
3094
|
-
let r = Ar(t, n);
|
|
3095
|
-
if (r === "none") return { retention: r };
|
|
3096
|
-
let i = r === "long" && zr(e).supportsLongCacheRetention ? "1h" : void 0;
|
|
3097
|
-
return {
|
|
3098
|
-
retention: r,
|
|
3099
|
-
cacheControl: {
|
|
3100
|
-
type: "ephemeral",
|
|
3101
|
-
...i && { ttl: i }
|
|
3102
|
-
}
|
|
3103
|
-
};
|
|
3104
|
-
}
|
|
3105
|
-
var Mr = "2.1.75", Nr = new Map([
|
|
3106
|
-
"Read",
|
|
3107
|
-
"Write",
|
|
3108
|
-
"Edit",
|
|
3109
|
-
"Bash",
|
|
3110
|
-
"Grep",
|
|
3111
|
-
"Glob",
|
|
3112
|
-
"AskUserQuestion",
|
|
3113
|
-
"EnterPlanMode",
|
|
3114
|
-
"ExitPlanMode",
|
|
3115
|
-
"KillShell",
|
|
3116
|
-
"NotebookEdit",
|
|
3117
|
-
"Skill",
|
|
3118
|
-
"Task",
|
|
3119
|
-
"TaskOutput",
|
|
3120
|
-
"TodoWrite",
|
|
3121
|
-
"WebFetch",
|
|
3122
|
-
"WebSearch"
|
|
3123
|
-
].map((e) => [e.toLowerCase(), e])), Pr = (e) => Nr.get(e.toLowerCase()) ?? e, Fr = (e, t) => {
|
|
3124
|
-
if (t && t.length > 0) {
|
|
3125
|
-
let n = e.toLowerCase(), r = t.find((e) => e.name.toLowerCase() === n);
|
|
3126
|
-
if (r) return r.name;
|
|
3127
|
-
}
|
|
3128
|
-
return e;
|
|
3129
|
-
};
|
|
3130
|
-
function Ir(e) {
|
|
3131
|
-
if (!e.some((e) => e.type === "image")) return f(e.map((e) => e.text).join("\n"));
|
|
3132
|
-
let t = e.map((e) => e.type === "text" ? {
|
|
3133
|
-
type: "text",
|
|
3134
|
-
text: f(e.text)
|
|
3135
|
-
} : {
|
|
3136
|
-
type: "image",
|
|
3137
|
-
source: {
|
|
3138
|
-
type: "base64",
|
|
3139
|
-
media_type: e.mimeType,
|
|
3140
|
-
data: e.data
|
|
3141
|
-
}
|
|
3142
|
-
});
|
|
3143
|
-
return t.some((e) => e.type === "text") || t.unshift({
|
|
3144
|
-
type: "text",
|
|
3145
|
-
text: "(see attached image)"
|
|
3146
|
-
}), t;
|
|
3147
|
-
}
|
|
3148
|
-
var Lr = "fine-grained-tool-streaming-2025-05-14", Rr = "interleaved-thinking-2025-05-14";
|
|
3149
|
-
function zr(e) {
|
|
3150
|
-
return {
|
|
3151
|
-
supportsEagerToolInputStreaming: e.compat?.supportsEagerToolInputStreaming ?? !0,
|
|
3152
|
-
supportsLongCacheRetention: e.compat?.supportsLongCacheRetention ?? !0,
|
|
3153
|
-
sendSessionAffinityHeaders: e.compat?.sendSessionAffinityHeaders ?? !1,
|
|
3154
|
-
supportsCacheControlOnTools: e.compat?.supportsCacheControlOnTools ?? !0,
|
|
3155
|
-
supportsTemperature: e.compat?.supportsTemperature ?? !0,
|
|
3156
|
-
allowEmptySignature: e.compat?.allowEmptySignature ?? !1,
|
|
3157
|
-
supportsStrictTools: e.compat?.supportsStrictTools ?? !1,
|
|
3158
|
-
supportsToolReferences: e.compat?.supportsToolReferences ?? Br(e)
|
|
3159
|
-
};
|
|
3160
|
-
}
|
|
3161
|
-
function Br(e) {
|
|
3162
|
-
if (e.provider !== "anthropic" || e.id.includes("haiku")) return !1;
|
|
3163
|
-
let t = e.id.match(/^claude-(?:opus|sonnet|fable)-(\d+)(?:-(\d+))?(?:-|$)/);
|
|
3164
|
-
if (!t) return !1;
|
|
3165
|
-
let n = Number(t[1]), r = t[2] && t[2].length < 8 ? Number(t[2]) : 0;
|
|
3166
|
-
return n > 4 || n === 4 && r >= 5;
|
|
3167
|
-
}
|
|
3168
|
-
function Vr(...e) {
|
|
3169
|
-
let t = {};
|
|
3170
|
-
for (let n of e) n && Object.assign(t, n);
|
|
3171
|
-
return t;
|
|
3172
|
-
}
|
|
3173
|
-
function Hr(e, ...t) {
|
|
3174
|
-
let n = Vr(...t);
|
|
3175
|
-
if (e.provider === "kimi-coding") {
|
|
3176
|
-
for (let e of Object.keys(n)) e.toLowerCase() === "user-agent" && delete n[e];
|
|
3177
|
-
n["User-Agent"] = s();
|
|
3178
|
-
}
|
|
3179
|
-
return n;
|
|
3180
|
-
}
|
|
3181
|
-
function Ur(e, t) {
|
|
3182
|
-
if (!e) return !1;
|
|
3183
|
-
let n = t.toLowerCase();
|
|
3184
|
-
for (let [t, r] of Object.entries(e)) if (t.toLowerCase() === n && r !== null && r.trim().length > 0) return !0;
|
|
3185
|
-
return !1;
|
|
3186
|
-
}
|
|
3187
|
-
function Wr(e, t, n) {
|
|
3188
|
-
if (!t && !(Ur(n, "authorization") || Ur(n, "x-api-key") || Ur(n, "cf-aig-authorization"))) throw Error(`No API key for provider: ${e}`);
|
|
3189
|
-
}
|
|
3190
|
-
var Gr = /* @__PURE__ */ new Set([
|
|
3191
|
-
"message_start",
|
|
3192
|
-
"message_delta",
|
|
3193
|
-
"message_stop",
|
|
3194
|
-
"content_block_start",
|
|
3195
|
-
"content_block_delta",
|
|
3196
|
-
"content_block_stop"
|
|
3197
|
-
]);
|
|
3198
|
-
function Kr(e) {
|
|
3199
|
-
if (!e.event && e.data.length === 0) return null;
|
|
3200
|
-
let t = {
|
|
3201
|
-
event: e.event,
|
|
3202
|
-
data: e.data.join("\n"),
|
|
3203
|
-
raw: [...e.raw]
|
|
3204
|
-
};
|
|
3205
|
-
return e.event = null, e.data = [], e.raw = [], t;
|
|
3206
|
-
}
|
|
3207
|
-
function qr(e, t) {
|
|
3208
|
-
if (e === "") return Kr(t);
|
|
3209
|
-
if (t.raw.push(e), e.startsWith(":")) return null;
|
|
3210
|
-
let n = e.indexOf(":"), r = n === -1 ? e : e.slice(0, n), i = n === -1 ? "" : e.slice(n + 1);
|
|
3211
|
-
return i.startsWith(" ") && (i = i.slice(1)), r === "event" ? t.event = i : r === "data" && t.data.push(i), null;
|
|
3212
|
-
}
|
|
3213
|
-
function Jr(e) {
|
|
3214
|
-
let t = e.indexOf("\r"), n = e.indexOf("\n");
|
|
3215
|
-
return t === -1 ? n : n === -1 ? t : Math.min(t, n);
|
|
3216
|
-
}
|
|
3217
|
-
function Yr(e) {
|
|
3218
|
-
let t = Jr(e);
|
|
3219
|
-
if (t === -1) return null;
|
|
3220
|
-
let n = t + 1;
|
|
3221
|
-
return e[t] === "\r" && e[n] === "\n" && (n += 1), {
|
|
3222
|
-
line: e.slice(0, t),
|
|
3223
|
-
rest: e.slice(n)
|
|
3224
|
-
};
|
|
3225
|
-
}
|
|
3226
|
-
async function* Xr(e, t) {
|
|
3227
|
-
let n = e.getReader(), r = new TextDecoder(), i = {
|
|
3228
|
-
event: null,
|
|
3229
|
-
data: [],
|
|
3230
|
-
raw: []
|
|
3231
|
-
}, a = "";
|
|
3232
|
-
try {
|
|
3233
|
-
for (;;) {
|
|
3234
|
-
if (t?.aborted) throw Error("Request was aborted");
|
|
3235
|
-
let { value: e, done: o } = await n.read();
|
|
3236
|
-
if (o) break;
|
|
3237
|
-
a += r.decode(e, { stream: !0 });
|
|
3238
|
-
let s = Yr(a);
|
|
3239
|
-
for (; s;) {
|
|
3240
|
-
a = s.rest;
|
|
3241
|
-
let e = qr(s.line, i);
|
|
3242
|
-
e && (yield e), s = Yr(a);
|
|
3243
|
-
}
|
|
3244
|
-
}
|
|
3245
|
-
a += r.decode();
|
|
3246
|
-
let e = Yr(a);
|
|
3247
|
-
for (; e;) {
|
|
3248
|
-
a = e.rest;
|
|
3249
|
-
let t = qr(e.line, i);
|
|
3250
|
-
t && (yield t), e = Yr(a);
|
|
3251
|
-
}
|
|
3252
|
-
if (a.length > 0) {
|
|
3253
|
-
let e = qr(a, i);
|
|
3254
|
-
e && (yield e);
|
|
3255
|
-
}
|
|
3256
|
-
let o = Kr(i);
|
|
3257
|
-
o && (yield o);
|
|
3258
|
-
} finally {
|
|
3259
|
-
n.releaseLock();
|
|
3260
|
-
}
|
|
3261
|
-
}
|
|
3262
|
-
async function* Zr(e, t) {
|
|
3263
|
-
if (!e.body) throw Error("Attempted to iterate over an Anthropic response with no body");
|
|
3264
|
-
let n = !1, i = !1;
|
|
3265
|
-
for await (let a of Xr(e.body, t)) {
|
|
3266
|
-
if (a.event === "error") throw Error(a.data);
|
|
3267
|
-
if (Gr.has(a.event ?? "")) try {
|
|
3268
|
-
let e = r(a.data);
|
|
3269
|
-
e.type === "message_start" ? n = !0 : e.type === "message_stop" && (i = !0), yield e;
|
|
3270
|
-
} catch (e) {
|
|
3271
|
-
let t = e instanceof Error ? e.message : String(e);
|
|
3272
|
-
throw Error(`Could not parse Anthropic SSE event ${a.event}: ${t}; data=${a.data}; raw=${a.raw.join("\\n")}`);
|
|
3273
|
-
}
|
|
3274
|
-
}
|
|
3275
|
-
if (n && !i) throw Error("Anthropic stream ended before message_stop");
|
|
3276
|
-
}
|
|
3277
|
-
var Qr = (r, i, a) => {
|
|
3278
|
-
let s = new t();
|
|
3279
|
-
return (async () => {
|
|
3280
|
-
let t = {
|
|
3281
|
-
role: "assistant",
|
|
3282
|
-
content: [],
|
|
3283
|
-
api: r.api,
|
|
3284
|
-
provider: r.provider,
|
|
3285
|
-
model: r.id,
|
|
3286
|
-
usage: {
|
|
3287
|
-
input: 0,
|
|
3288
|
-
output: 0,
|
|
3289
|
-
cacheRead: 0,
|
|
3290
|
-
cacheWrite: 0,
|
|
3291
|
-
totalTokens: 0,
|
|
3292
|
-
cost: {
|
|
3293
|
-
input: 0,
|
|
3294
|
-
output: 0,
|
|
3295
|
-
cacheRead: 0,
|
|
3296
|
-
cacheWrite: 0,
|
|
3297
|
-
total: 0
|
|
3298
|
-
}
|
|
3299
|
-
},
|
|
3300
|
-
stopReason: "pending",
|
|
3301
|
-
timestamp: Date.now()
|
|
3302
|
-
};
|
|
3303
|
-
try {
|
|
3304
|
-
let l, u;
|
|
3305
|
-
if (a?.client) l = a.client, u = !1;
|
|
3306
|
-
else {
|
|
3307
|
-
let e = a?.apiKey;
|
|
3308
|
-
Wr(r.provider, e, a?.headers);
|
|
3309
|
-
let t;
|
|
3310
|
-
if (r.provider === "github-copilot") {
|
|
3311
|
-
let e = ee(i.messages);
|
|
3312
|
-
t = te({
|
|
3313
|
-
messages: i.messages,
|
|
3314
|
-
hasImages: e
|
|
3315
|
-
});
|
|
3316
|
-
}
|
|
3317
|
-
let n = Ar(a?.cacheRetention, a?.env) === "none" ? void 0 : a?.sessionId, o = ni(r, e, a?.interleavedThinking ?? !0, si(r, i), a?.headers, a?.fetch, t, n);
|
|
3318
|
-
l = o.client, u = o.isOAuthToken;
|
|
3319
|
-
}
|
|
3320
|
-
let d = ri(r, i, u, a), f = await a?.onPayload?.(d, r);
|
|
3321
|
-
f !== void 0 && (d = f);
|
|
3322
|
-
let p = {
|
|
3323
|
-
...a?.signal ? { signal: a.signal } : {},
|
|
3324
|
-
...a?.timeoutMs === void 0 ? {} : { timeout: a.timeoutMs },
|
|
3325
|
-
maxRetries: 0
|
|
3326
|
-
}, m = await c(() => l.messages.create({
|
|
3327
|
-
...d,
|
|
3328
|
-
stream: !0
|
|
3329
|
-
}, p).asResponse(), {
|
|
3330
|
-
maxRetries: a?.maxRetries,
|
|
3331
|
-
maxRetryDelayMs: a?.maxRetryDelayMs,
|
|
3332
|
-
signal: a?.signal
|
|
3333
|
-
});
|
|
3334
|
-
await a?.onResponse?.({
|
|
3335
|
-
status: m.status,
|
|
3336
|
-
headers: o(m.headers)
|
|
3337
|
-
}, r), s.push({
|
|
3338
|
-
type: "start",
|
|
3339
|
-
partial: t
|
|
3340
|
-
});
|
|
3341
|
-
let h = t.content;
|
|
3342
|
-
for await (let o of Zr(m, a?.signal)) if (o.type === "message_start") t.responseId = o.message.id, t.usage.input = o.message.usage.input_tokens || 0, t.usage.output = o.message.usage.output_tokens || 0, t.usage.cacheRead = o.message.usage.cache_read_input_tokens || 0, t.usage.cacheWrite = o.message.usage.cache_creation_input_tokens || 0, t.usage.cacheWrite1h = o.message.usage.cache_creation?.ephemeral_1h_input_tokens || 0, t.usage.totalTokens = t.usage.input + t.usage.output + t.usage.cacheRead + t.usage.cacheWrite, e(r, t.usage);
|
|
3343
|
-
else if (o.type === "content_block_start") {
|
|
3344
|
-
if (o.content_block.type === "text") {
|
|
3345
|
-
let e = {
|
|
3346
|
-
type: "text",
|
|
3347
|
-
text: o.content_block.text ?? "",
|
|
3348
|
-
index: o.index
|
|
3349
|
-
};
|
|
3350
|
-
t.content.push(e), s.push({
|
|
3351
|
-
type: "text_start",
|
|
3352
|
-
contentIndex: t.content.length - 1,
|
|
3353
|
-
partial: t
|
|
3354
|
-
});
|
|
3355
|
-
} else if (o.content_block.type === "thinking") {
|
|
3356
|
-
let e = {
|
|
3357
|
-
type: "thinking",
|
|
3358
|
-
thinking: o.content_block.thinking ?? "",
|
|
3359
|
-
thinkingSignature: o.content_block.signature ?? "",
|
|
3360
|
-
index: o.index
|
|
3361
|
-
};
|
|
3362
|
-
t.content.push(e), s.push({
|
|
3363
|
-
type: "thinking_start",
|
|
3364
|
-
contentIndex: t.content.length - 1,
|
|
3365
|
-
partial: t
|
|
3366
|
-
});
|
|
3367
|
-
} else if (o.content_block.type === "redacted_thinking") {
|
|
3368
|
-
let e = {
|
|
3369
|
-
type: "thinking",
|
|
3370
|
-
thinking: "[Reasoning redacted]",
|
|
3371
|
-
thinkingSignature: o.content_block.data,
|
|
3372
|
-
redacted: !0,
|
|
3373
|
-
index: o.index
|
|
3374
|
-
};
|
|
3375
|
-
t.content.push(e), s.push({
|
|
3376
|
-
type: "thinking_start",
|
|
3377
|
-
contentIndex: t.content.length - 1,
|
|
3378
|
-
partial: t
|
|
3379
|
-
});
|
|
3380
|
-
} else if (o.content_block.type === "tool_use") {
|
|
3381
|
-
let e = {
|
|
3382
|
-
type: "toolCall",
|
|
3383
|
-
id: o.content_block.id,
|
|
3384
|
-
name: u ? Fr(o.content_block.name, i.tools) : o.content_block.name,
|
|
3385
|
-
arguments: o.content_block.input ?? {},
|
|
3386
|
-
partialJson: "",
|
|
3387
|
-
index: o.index
|
|
3388
|
-
};
|
|
3389
|
-
t.content.push(e), s.push({
|
|
3390
|
-
type: "toolcall_start",
|
|
3391
|
-
contentIndex: t.content.length - 1,
|
|
3392
|
-
partial: t
|
|
3393
|
-
});
|
|
3394
|
-
}
|
|
3395
|
-
} else if (o.type === "content_block_delta") {
|
|
3396
|
-
if (o.delta.type === "text_delta") {
|
|
3397
|
-
let e = h.findIndex((e) => e.index === o.index), n = h[e];
|
|
3398
|
-
n && n.type === "text" && (n.text += o.delta.text, s.push({
|
|
3399
|
-
type: "text_delta",
|
|
3400
|
-
contentIndex: e,
|
|
3401
|
-
delta: o.delta.text,
|
|
3402
|
-
partial: t
|
|
3403
|
-
}));
|
|
3404
|
-
} else if (o.delta.type === "thinking_delta") {
|
|
3405
|
-
let e = h.findIndex((e) => e.index === o.index), n = h[e];
|
|
3406
|
-
n && n.type === "thinking" && (n.thinking += o.delta.thinking, s.push({
|
|
3407
|
-
type: "thinking_delta",
|
|
3408
|
-
contentIndex: e,
|
|
3409
|
-
delta: o.delta.thinking,
|
|
3410
|
-
partial: t
|
|
3411
|
-
}));
|
|
3412
|
-
} else if (o.delta.type === "input_json_delta") {
|
|
3413
|
-
let e = h.findIndex((e) => e.index === o.index), r = h[e];
|
|
3414
|
-
r && r.type === "toolCall" && (r.partialJson += o.delta.partial_json, r.arguments = n(r.partialJson), s.push({
|
|
3415
|
-
type: "toolcall_delta",
|
|
3416
|
-
contentIndex: e,
|
|
3417
|
-
delta: o.delta.partial_json,
|
|
3418
|
-
partial: t
|
|
3419
|
-
}));
|
|
3420
|
-
} else if (o.delta.type === "signature_delta") {
|
|
3421
|
-
let e = h[h.findIndex((e) => e.index === o.index)];
|
|
3422
|
-
e && e.type === "thinking" && (e.thinkingSignature = e.thinkingSignature || "", e.thinkingSignature += o.delta.signature);
|
|
3423
|
-
}
|
|
3424
|
-
} else if (o.type === "content_block_stop") {
|
|
3425
|
-
let e = h.findIndex((e) => e.index === o.index), r = h[e];
|
|
3426
|
-
r && (delete r.index, r.type === "text" ? s.push({
|
|
3427
|
-
type: "text_end",
|
|
3428
|
-
contentIndex: e,
|
|
3429
|
-
content: r.text,
|
|
3430
|
-
partial: t
|
|
3431
|
-
}) : r.type === "thinking" ? s.push({
|
|
3432
|
-
type: "thinking_end",
|
|
3433
|
-
contentIndex: e,
|
|
3434
|
-
content: r.thinking,
|
|
3435
|
-
partial: t
|
|
3436
|
-
}) : r.type === "toolCall" && (r.arguments = n(r.partialJson), delete r.partialJson, s.push({
|
|
3437
|
-
type: "toolcall_end",
|
|
3438
|
-
contentIndex: e,
|
|
3439
|
-
toolCall: r,
|
|
3440
|
-
partial: t
|
|
3441
|
-
})));
|
|
3442
|
-
} else if (o.type === "message_delta") {
|
|
3443
|
-
if (o.delta.stop_reason) {
|
|
3444
|
-
t.rawStopReason = o.delta.stop_reason;
|
|
3445
|
-
let e = li(o.delta.stop_reason, o.delta.stop_details);
|
|
3446
|
-
t.stopReason = e.stopReason, e.errorMessage && (t.errorMessage = e.errorMessage);
|
|
3447
|
-
}
|
|
3448
|
-
if (o.usage) {
|
|
3449
|
-
o.usage.input_tokens != null && (t.usage.input = o.usage.input_tokens), o.usage.output_tokens != null && (t.usage.output = o.usage.output_tokens), o.usage.cache_read_input_tokens != null && (t.usage.cacheRead = o.usage.cache_read_input_tokens), o.usage.cache_creation_input_tokens != null && (t.usage.cacheWrite = o.usage.cache_creation_input_tokens);
|
|
3450
|
-
let e = o.usage.output_tokens_details?.thinking_tokens;
|
|
3451
|
-
e != null && (t.usage.reasoning = e);
|
|
3452
|
-
}
|
|
3453
|
-
t.usage.totalTokens = t.usage.input + t.usage.output + t.usage.cacheRead + t.usage.cacheWrite, e(r, t.usage);
|
|
3454
|
-
}
|
|
3455
|
-
if (a?.signal?.aborted) throw Error("Request was aborted");
|
|
3456
|
-
if (t.stopReason === "pending") throw Error("Anthropic stream ended without a stop reason");
|
|
3457
|
-
if (t.stopReason === "aborted" || t.stopReason === "error") throw Error(t.errorMessage || "An unknown error occurred");
|
|
3458
|
-
s.push({
|
|
3459
|
-
type: "done",
|
|
3460
|
-
reason: t.stopReason,
|
|
3461
|
-
message: t
|
|
3462
|
-
}), s.end();
|
|
3463
|
-
} catch (e) {
|
|
3464
|
-
for (let e of t.content) delete e.index, delete e.partialJson;
|
|
3465
|
-
t.stopReason = a?.signal?.aborted ? "aborted" : "error", t.errorMessage = e instanceof Error ? e.message : JSON.stringify(e), s.push({
|
|
3466
|
-
type: "error",
|
|
3467
|
-
reason: t.stopReason,
|
|
3468
|
-
error: t
|
|
3469
|
-
}), s.end();
|
|
3470
|
-
}
|
|
3471
|
-
})(), s;
|
|
3472
|
-
};
|
|
3473
|
-
function $r(e, t) {
|
|
3474
|
-
let n = t ? e.thinkingLevelMap?.[t] : void 0;
|
|
3475
|
-
if (typeof n == "string") return n;
|
|
3476
|
-
switch (t) {
|
|
3477
|
-
case "minimal":
|
|
3478
|
-
case "low": return "low";
|
|
3479
|
-
case "medium": return "medium";
|
|
3480
|
-
case "high": return "high";
|
|
3481
|
-
default: return "high";
|
|
3482
|
-
}
|
|
3483
|
-
}
|
|
3484
|
-
var ei = (e, t, n) => {
|
|
3485
|
-
Wr(e.provider, n?.apiKey, n?.headers);
|
|
3486
|
-
let r = d(e, t, n, n?.apiKey);
|
|
3487
|
-
if (!n?.reasoning) return Qr(e, t, {
|
|
3488
|
-
...r,
|
|
3489
|
-
thinkingEnabled: !1
|
|
3490
|
-
});
|
|
3491
|
-
if (e.compat?.forceAdaptiveThinking === !0) {
|
|
3492
|
-
let i = $r(e, n.reasoning);
|
|
3493
|
-
return Qr(e, t, {
|
|
3494
|
-
...r,
|
|
3495
|
-
thinkingEnabled: !0,
|
|
3496
|
-
effort: i
|
|
3497
|
-
});
|
|
3498
|
-
}
|
|
3499
|
-
let i = p(r.maxTokens, e.maxTokens, n.reasoning, n.thinkingBudgets), a = l(e, t, i.maxTokens);
|
|
3500
|
-
return Qr(e, t, {
|
|
3501
|
-
...r,
|
|
3502
|
-
maxTokens: a,
|
|
3503
|
-
thinkingEnabled: !0,
|
|
3504
|
-
thinkingBudgetTokens: Math.min(i.thinkingBudget, Math.max(0, a - 1024))
|
|
3505
|
-
});
|
|
3506
|
-
};
|
|
3507
|
-
function ti(e) {
|
|
3508
|
-
return e.includes("sk-ant-oat");
|
|
3509
|
-
}
|
|
3510
|
-
function ni(e, t, n, r, i, a, o, s) {
|
|
3511
|
-
let c = n && e.compat?.forceAdaptiveThinking !== !0, l = [];
|
|
3512
|
-
if (r && l.push(Lr), c && l.push(Rr), e.provider === "github-copilot") return {
|
|
3513
|
-
client: new $({
|
|
3514
|
-
apiKey: null,
|
|
3515
|
-
authToken: t ?? null,
|
|
3516
|
-
baseURL: e.baseUrl,
|
|
3517
|
-
dangerouslyAllowBrowser: !0,
|
|
3518
|
-
fetch: a,
|
|
3519
|
-
defaultHeaders: Hr(e, {
|
|
3520
|
-
accept: "application/json",
|
|
3521
|
-
"anthropic-dangerous-direct-browser-access": "true",
|
|
3522
|
-
...l.length > 0 ? { "anthropic-beta": l.join(",") } : {}
|
|
3523
|
-
}, e.headers, o, i)
|
|
3524
|
-
}),
|
|
3525
|
-
isOAuthToken: !1
|
|
3526
|
-
};
|
|
3527
|
-
if (t && ti(t)) return {
|
|
3528
|
-
client: new $({
|
|
3529
|
-
apiKey: null,
|
|
3530
|
-
authToken: t,
|
|
3531
|
-
baseURL: e.baseUrl,
|
|
3532
|
-
dangerouslyAllowBrowser: !0,
|
|
3533
|
-
fetch: a,
|
|
3534
|
-
defaultHeaders: Hr(e, {
|
|
3535
|
-
accept: "application/json",
|
|
3536
|
-
"anthropic-dangerous-direct-browser-access": "true",
|
|
3537
|
-
"anthropic-beta": [
|
|
3538
|
-
"claude-code-20250219",
|
|
3539
|
-
"oauth-2025-04-20",
|
|
3540
|
-
...l
|
|
3541
|
-
].join(","),
|
|
3542
|
-
"user-agent": `claude-cli/${Mr}`,
|
|
3543
|
-
"x-app": "cli"
|
|
3544
|
-
}, e.headers, i)
|
|
3545
|
-
}),
|
|
3546
|
-
isOAuthToken: !0
|
|
3547
|
-
};
|
|
3548
|
-
let u = s && zr(e).sendSessionAffinityHeaders ? { "x-session-affinity": s } : {}, d = Hr(e, {
|
|
3549
|
-
accept: "application/json",
|
|
3550
|
-
"anthropic-dangerous-direct-browser-access": "true",
|
|
3551
|
-
...l.length > 0 ? { "anthropic-beta": l.join(",") } : {}
|
|
3552
|
-
}, u, e.headers, i);
|
|
3553
|
-
return {
|
|
3554
|
-
client: new $({
|
|
3555
|
-
apiKey: t ?? null,
|
|
3556
|
-
authToken: null,
|
|
3557
|
-
baseURL: e.baseUrl,
|
|
3558
|
-
dangerouslyAllowBrowser: !0,
|
|
3559
|
-
fetch: a,
|
|
3560
|
-
defaultHeaders: d
|
|
3561
|
-
}),
|
|
3562
|
-
isOAuthToken: !1
|
|
3563
|
-
};
|
|
3564
|
-
}
|
|
3565
|
-
function ri(e, t, n, r) {
|
|
3566
|
-
let { cacheControl: i } = jr(e, r?.cacheRetention, r?.env), o = zr(e), s = m(t.messages, e, ii), c = n ? Pr : (e) => e, l = a({
|
|
3567
|
-
...t,
|
|
3568
|
-
messages: s
|
|
3569
|
-
}, o.supportsToolReferences, c), u = l.immediate, d = [...l.deferred.values()];
|
|
3570
|
-
u.length === 0 && d.length > 0 && (u = d, d = []);
|
|
3571
|
-
let p = new Set(d.map((e) => c(e.name))), h = {
|
|
3572
|
-
model: e.id,
|
|
3573
|
-
messages: oi(s, n, i, o.allowEmptySignature, p, c),
|
|
3574
|
-
max_tokens: r?.maxTokens ?? e.maxTokens,
|
|
3575
|
-
stream: !0
|
|
3576
|
-
};
|
|
3577
|
-
if (n ? (h.system = [{
|
|
3578
|
-
type: "text",
|
|
3579
|
-
text: "You are Claude Code, Anthropic's official CLI for Claude.",
|
|
3580
|
-
...i ? { cache_control: i } : {}
|
|
3581
|
-
}], t.systemPrompt && h.system.push({
|
|
3582
|
-
type: "text",
|
|
3583
|
-
text: f(t.systemPrompt),
|
|
3584
|
-
...i ? { cache_control: i } : {}
|
|
3585
|
-
})) : t.systemPrompt && (h.system = [{
|
|
3586
|
-
type: "text",
|
|
3587
|
-
text: f(t.systemPrompt),
|
|
3588
|
-
...i ? { cache_control: i } : {}
|
|
3589
|
-
}]), r?.temperature !== void 0 && !r?.thinkingEnabled && o.supportsTemperature && (h.temperature = r.temperature), (u.length > 0 || d.length > 0) && (h.tools = [...ci(u, n, o.supportsEagerToolInputStreaming, o.supportsStrictTools, o.supportsCacheControlOnTools ? i : void 0), ...ci(d, n, o.supportsEagerToolInputStreaming, o.supportsStrictTools, void 0, !0)]), e.reasoning) {
|
|
3590
|
-
if (r?.thinkingEnabled) {
|
|
3591
|
-
let t = r.thinkingDisplay ?? "summarized";
|
|
3592
|
-
e.compat?.forceAdaptiveThinking === !0 ? (h.thinking = {
|
|
3593
|
-
type: "adaptive",
|
|
3594
|
-
display: t
|
|
3595
|
-
}, r.effort && (h.output_config = (r.effort, { effort: r.effort }))) : h.thinking = {
|
|
3596
|
-
type: "enabled",
|
|
3597
|
-
budget_tokens: r.thinkingBudgetTokens || 1024,
|
|
3598
|
-
display: t
|
|
3599
|
-
};
|
|
3600
|
-
} else r?.thinkingEnabled === !1 && e.thinkingLevelMap?.off !== null && (h.thinking = { type: "disabled" });
|
|
3601
|
-
}
|
|
3602
|
-
if (r?.metadata) {
|
|
3603
|
-
let e = r.metadata.user_id;
|
|
3604
|
-
typeof e == "string" && (h.metadata = { user_id: e });
|
|
3605
|
-
}
|
|
3606
|
-
return r?.toolChoice && (h.tool_choice = typeof r.toolChoice == "string" ? { type: r.toolChoice } : r.toolChoice), h;
|
|
3607
|
-
}
|
|
3608
|
-
function ii(e) {
|
|
3609
|
-
return e.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
|
|
3610
|
-
}
|
|
3611
|
-
function ai(e, t, n, r, i) {
|
|
3612
|
-
let a = [];
|
|
3613
|
-
for (let o of e.addedToolNames ?? []) {
|
|
3614
|
-
let e = i(o);
|
|
3615
|
-
n.has(e) && !r.has(e) && (r.add(e), a.push({
|
|
3616
|
-
type: "tool_reference",
|
|
3617
|
-
tool_name: t ? Pr(o) : o
|
|
3618
|
-
}));
|
|
3619
|
-
}
|
|
3620
|
-
let o = Ir(e.content);
|
|
3621
|
-
return {
|
|
3622
|
-
toolResult: {
|
|
3623
|
-
type: "tool_result",
|
|
3624
|
-
tool_use_id: e.toolCallId,
|
|
3625
|
-
content: a.length > 0 ? a : o,
|
|
3626
|
-
is_error: e.isError
|
|
3627
|
-
},
|
|
3628
|
-
siblingContent: a.length === 0 ? [] : typeof o == "string" ? [{
|
|
3629
|
-
type: "text",
|
|
3630
|
-
text: o
|
|
3631
|
-
}] : o
|
|
3632
|
-
};
|
|
3633
|
-
}
|
|
3634
|
-
function oi(e, t, n, r = !1, i = /* @__PURE__ */ new Set(), a = (e) => e) {
|
|
3635
|
-
let o = [], s = /* @__PURE__ */ new Set();
|
|
3636
|
-
for (let n = 0; n < e.length; n++) {
|
|
3637
|
-
let c = e[n];
|
|
3638
|
-
if (c.role === "user") {
|
|
3639
|
-
if (typeof c.content == "string") c.content.trim().length > 0 && o.push({
|
|
3640
|
-
role: "user",
|
|
3641
|
-
content: f(c.content)
|
|
3642
|
-
});
|
|
3643
|
-
else {
|
|
3644
|
-
let e = c.content.map((e) => e.type === "text" ? {
|
|
3645
|
-
type: "text",
|
|
3646
|
-
text: f(e.text)
|
|
3647
|
-
} : {
|
|
3648
|
-
type: "image",
|
|
3649
|
-
source: {
|
|
3650
|
-
type: "base64",
|
|
3651
|
-
media_type: e.mimeType,
|
|
3652
|
-
data: e.data
|
|
3653
|
-
}
|
|
3654
|
-
}).filter((e) => e.type !== "text" || e.text.trim().length > 0);
|
|
3655
|
-
if (e.length === 0) continue;
|
|
3656
|
-
o.push({
|
|
3657
|
-
role: "user",
|
|
3658
|
-
content: e
|
|
3659
|
-
});
|
|
3660
|
-
}
|
|
3661
|
-
} else if (c.role === "assistant") {
|
|
3662
|
-
let e = [];
|
|
3663
|
-
for (let n of c.content) if (n.type === "text") {
|
|
3664
|
-
if (n.text.trim().length === 0) continue;
|
|
3665
|
-
e.push({
|
|
3666
|
-
type: "text",
|
|
3667
|
-
text: f(n.text)
|
|
3668
|
-
});
|
|
3669
|
-
} else if (n.type === "thinking") {
|
|
3670
|
-
if (n.redacted) {
|
|
3671
|
-
e.push({
|
|
3672
|
-
type: "redacted_thinking",
|
|
3673
|
-
data: n.thinkingSignature
|
|
3674
|
-
});
|
|
3675
|
-
continue;
|
|
3676
|
-
}
|
|
3677
|
-
let t = n.thinkingSignature, i = !!t && t.trim().length > 0;
|
|
3678
|
-
if (n.thinking.trim().length === 0 && !i) continue;
|
|
3679
|
-
i ? e.push({
|
|
3680
|
-
type: "thinking",
|
|
3681
|
-
thinking: f(n.thinking),
|
|
3682
|
-
signature: t
|
|
3683
|
-
}) : e.push(r ? {
|
|
3684
|
-
type: "thinking",
|
|
3685
|
-
thinking: f(n.thinking),
|
|
3686
|
-
signature: ""
|
|
3687
|
-
} : {
|
|
3688
|
-
type: "text",
|
|
3689
|
-
text: f(n.thinking)
|
|
3690
|
-
});
|
|
3691
|
-
} else n.type === "toolCall" && e.push({
|
|
3692
|
-
type: "tool_use",
|
|
3693
|
-
id: n.id,
|
|
3694
|
-
name: t ? Pr(n.name) : n.name,
|
|
3695
|
-
input: n.arguments ?? {}
|
|
3696
|
-
});
|
|
3697
|
-
if (e.length === 0) continue;
|
|
3698
|
-
o.push({
|
|
3699
|
-
role: "assistant",
|
|
3700
|
-
content: e
|
|
3701
|
-
});
|
|
3702
|
-
} else if (c.role === "toolResult") {
|
|
3703
|
-
let r = [], c = [], l = n;
|
|
3704
|
-
for (; l < e.length && e[l].role === "toolResult";) {
|
|
3705
|
-
let n = ai(e[l], t, i, s, a);
|
|
3706
|
-
r.push(n.toolResult), c.push(...n.siblingContent), l++;
|
|
3707
|
-
}
|
|
3708
|
-
n = l - 1, o.push({
|
|
3709
|
-
role: "user",
|
|
3710
|
-
content: [...r, ...c]
|
|
3711
|
-
});
|
|
3712
|
-
}
|
|
3713
|
-
}
|
|
3714
|
-
if (n && o.length > 0) {
|
|
3715
|
-
let e = o[o.length - 1];
|
|
3716
|
-
if (e.role === "user") {
|
|
3717
|
-
if (Array.isArray(e.content)) {
|
|
3718
|
-
let t = e.content[e.content.length - 1];
|
|
3719
|
-
t && (t.type === "text" || t.type === "image" || t.type === "tool_result") && (t.cache_control = n);
|
|
3720
|
-
} else typeof e.content == "string" && (e.content = [{
|
|
3721
|
-
type: "text",
|
|
3722
|
-
text: e.content,
|
|
3723
|
-
cache_control: n
|
|
3724
|
-
}]);
|
|
3725
|
-
}
|
|
3726
|
-
}
|
|
3727
|
-
return o;
|
|
3728
|
-
}
|
|
3729
|
-
function si(e, t) {
|
|
3730
|
-
return !!t.tools?.length && !zr(e).supportsEagerToolInputStreaming;
|
|
3731
|
-
}
|
|
3732
|
-
function ci(e, t, n, r, i, a = !1) {
|
|
3733
|
-
return e ? e.map((o, s) => {
|
|
3734
|
-
let c = u(o, r), l = h(o, c), d = l, f = {
|
|
3735
|
-
type: "object",
|
|
3736
|
-
properties: d.properties ?? {},
|
|
3737
|
-
required: d.required ?? []
|
|
3738
|
-
}, p = c === !0 ? {
|
|
3739
|
-
...l,
|
|
3740
|
-
...f
|
|
3741
|
-
} : f;
|
|
3742
|
-
return {
|
|
3743
|
-
name: t ? Pr(o.name) : o.name,
|
|
3744
|
-
description: o.description,
|
|
3745
|
-
...n ? { eager_input_streaming: !0 } : {},
|
|
3746
|
-
...c === !0 ? { strict: !0 } : {},
|
|
3747
|
-
input_schema: p,
|
|
3748
|
-
...a ? { defer_loading: !0 } : {},
|
|
3749
|
-
...i && s === e.length - 1 ? { cache_control: i } : {}
|
|
3750
|
-
};
|
|
3751
|
-
}) : [];
|
|
3752
|
-
}
|
|
3753
|
-
function li(e, t) {
|
|
3754
|
-
switch (e) {
|
|
3755
|
-
case "end_turn": return { stopReason: "stop" };
|
|
3756
|
-
case "max_tokens": return { stopReason: "length" };
|
|
3757
|
-
case "tool_use": return { stopReason: "toolUse" };
|
|
3758
|
-
case "refusal": return {
|
|
3759
|
-
stopReason: "error",
|
|
3760
|
-
errorMessage: t?.explanation || "The model refused to complete the request"
|
|
3761
|
-
};
|
|
3762
|
-
case "pause_turn": return { stopReason: "stop" };
|
|
3763
|
-
case "stop_sequence": return { stopReason: "stop" };
|
|
3764
|
-
case "sensitive": return {
|
|
3765
|
-
stopReason: "error",
|
|
3766
|
-
errorMessage: "Provider stopped with: sensitive"
|
|
3767
|
-
};
|
|
3768
|
-
default: throw Error(`Unhandled stop reason: ${e}`);
|
|
3769
|
-
}
|
|
3770
|
-
}
|
|
3771
|
-
//#endregion
|
|
3772
|
-
export { Qr as stream, ei as streamSimple };
|