@hasna/mementos 0.14.87 → 0.14.88
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/bun.lock +3 -0
- package/dist/cli/brains.d.ts.map +1 -1
- package/dist/cli/commands/io-backup.d.ts.map +1 -1
- package/dist/cli/commands/io-restore.d.ts.map +1 -1
- package/dist/cli/commands/system-profile.d.ts.map +1 -1
- package/dist/cli/helpers.d.ts.map +1 -1
- package/dist/cli/index.js +952 -681
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/memories.d.ts.map +1 -1
- package/dist/db/pg-migrate.d.ts.map +1 -1
- package/dist/diagnostics/historical-project-registration-receipt.js +116 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +808 -543
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/model-config.d.ts +1 -1
- package/dist/lib/paths.d.ts +51 -0
- package/dist/lib/paths.d.ts.map +1 -0
- package/dist/lib/profile-sync.d.ts.map +1 -1
- package/dist/lib/search.d.ts.map +1 -1
- package/dist/lib/storage-sync.d.ts.map +1 -1
- package/dist/lib/sync.d.ts.map +1 -1
- package/dist/mcp/index.js +815 -548
- package/dist/project-registration.js +179 -42
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/helpers.d.ts +31 -0
- package/dist/server/helpers.d.ts.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +872 -554
- package/dist/server/routes/system-synthesis.d.ts.map +1 -1
- package/dist/storage.d.ts +18 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +134 -17
- package/package.json +5 -3
- package/postinstall.mjs +34 -0
package/dist/mcp/index.js
CHANGED
|
@@ -246,11 +246,119 @@ var init_retired_storage_mode = __esm(() => {
|
|
|
246
246
|
];
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
-
//
|
|
250
|
-
import { Database } from "bun:sqlite";
|
|
251
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
249
|
+
// ../../node_modules/.bun/@hasna+paths@0.1.0/node_modules/@hasna/paths/dist/index.js
|
|
252
250
|
import { homedir } from "os";
|
|
253
251
|
import { join } from "path";
|
|
252
|
+
function assertApp(app) {
|
|
253
|
+
if (typeof app !== "string" || app.length === 0) {
|
|
254
|
+
throw new TypeError("paths: app must be a non-empty string");
|
|
255
|
+
}
|
|
256
|
+
if (!APP_SLUG_RE.test(app)) {
|
|
257
|
+
throw new TypeError(`paths: invalid app slug "${app}" \u2014 expected lowercase kebab-case ([a-z0-9]+(-[a-z0-9]+)*)`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function envOf(options) {
|
|
261
|
+
return options.env ?? process.env;
|
|
262
|
+
}
|
|
263
|
+
function envValue(options, kind) {
|
|
264
|
+
const value = envOf(options)[KIND_ENV[kind]];
|
|
265
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
266
|
+
}
|
|
267
|
+
function isMacOS(platform) {
|
|
268
|
+
return platform === "darwin";
|
|
269
|
+
}
|
|
270
|
+
function baseDir(kind, options) {
|
|
271
|
+
const override = envValue(options, kind);
|
|
272
|
+
if (override)
|
|
273
|
+
return override;
|
|
274
|
+
const home = options.home ?? homedir();
|
|
275
|
+
const platform = options.platform ?? process.platform;
|
|
276
|
+
if (isMacOS(platform)) {
|
|
277
|
+
switch (kind) {
|
|
278
|
+
case "config":
|
|
279
|
+
case "data":
|
|
280
|
+
return join(home, "Library", "Application Support", "Hasna");
|
|
281
|
+
case "cache":
|
|
282
|
+
return join(home, "Library", "Caches", "Hasna");
|
|
283
|
+
case "state":
|
|
284
|
+
return join(home, "Library", "Logs", "Hasna");
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
switch (kind) {
|
|
288
|
+
case "config":
|
|
289
|
+
return join(home, ".config", "hasna");
|
|
290
|
+
case "data":
|
|
291
|
+
return join(home, ".local", "share", "hasna");
|
|
292
|
+
case "state":
|
|
293
|
+
return join(home, ".local", "state", "hasna");
|
|
294
|
+
case "cache":
|
|
295
|
+
return join(home, ".cache", "hasna");
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function resolvePath(kind, options) {
|
|
299
|
+
assertApp(options.app);
|
|
300
|
+
const appSegment = options.internal === true ? join("internal", options.app) : options.app;
|
|
301
|
+
return join(baseDir(kind, options), appSegment);
|
|
302
|
+
}
|
|
303
|
+
function dataDir(options) {
|
|
304
|
+
return resolvePath("data", options);
|
|
305
|
+
}
|
|
306
|
+
var KIND_ENV, APP_SLUG_RE;
|
|
307
|
+
var init_dist = __esm(() => {
|
|
308
|
+
KIND_ENV = {
|
|
309
|
+
config: "HASNA_CONFIG_HOME",
|
|
310
|
+
data: "HASNA_DATA_HOME",
|
|
311
|
+
state: "HASNA_STATE_HOME",
|
|
312
|
+
cache: "HASNA_CACHE_HOME"
|
|
313
|
+
};
|
|
314
|
+
APP_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// src/lib/paths.ts
|
|
318
|
+
import { existsSync } from "fs";
|
|
319
|
+
import { homedir as homedir2 } from "os";
|
|
320
|
+
import { join as join2, resolve } from "path";
|
|
321
|
+
function effectiveHome() {
|
|
322
|
+
return process.env["HOME"] || process.env["USERPROFILE"] || homedir2() || "/tmp";
|
|
323
|
+
}
|
|
324
|
+
function legacyDataRoot() {
|
|
325
|
+
return join2(effectiveHome(), ".hasna", "mementos");
|
|
326
|
+
}
|
|
327
|
+
function resolverDataRoot() {
|
|
328
|
+
return dataDir({
|
|
329
|
+
app: "mementos",
|
|
330
|
+
home: process.env["HOME"] || process.env["USERPROFILE"] || undefined
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
function adoptResolverDataRoot(resolved, env = process.env) {
|
|
334
|
+
const dataOverride = env.HASNA_DATA_HOME;
|
|
335
|
+
if (typeof dataOverride === "string" && dataOverride.trim().length > 0)
|
|
336
|
+
return true;
|
|
337
|
+
return existsSync(join2(resolved, "mementos.db"));
|
|
338
|
+
}
|
|
339
|
+
function exactDataRoot() {
|
|
340
|
+
for (const key of ["HASNA_MEMENTOS_HOME", "MEMENTOS_HOME"]) {
|
|
341
|
+
const dir = process.env[key]?.trim();
|
|
342
|
+
if (dir)
|
|
343
|
+
return resolve(dir);
|
|
344
|
+
}
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
function getDataRoot() {
|
|
348
|
+
const exact = exactDataRoot();
|
|
349
|
+
if (exact)
|
|
350
|
+
return exact;
|
|
351
|
+
const resolved = resolverDataRoot();
|
|
352
|
+
return adoptResolverDataRoot(resolved) ? resolve(resolved) : resolve(legacyDataRoot());
|
|
353
|
+
}
|
|
354
|
+
var init_paths = __esm(() => {
|
|
355
|
+
init_dist();
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// src/storage.ts
|
|
359
|
+
import { Database } from "bun:sqlite";
|
|
360
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
361
|
+
import { join as join3 } from "path";
|
|
254
362
|
import { fileURLToPath } from "url";
|
|
255
363
|
import { Worker } from "worker_threads";
|
|
256
364
|
import pg from "pg";
|
|
@@ -500,7 +608,7 @@ function readEnv(name) {
|
|
|
500
608
|
return value ? value : null;
|
|
501
609
|
}
|
|
502
610
|
function readConfigFile() {
|
|
503
|
-
if (!
|
|
611
|
+
if (!existsSync2(STORAGE_CONFIG_PATH)) {
|
|
504
612
|
return {};
|
|
505
613
|
}
|
|
506
614
|
try {
|
|
@@ -509,6 +617,9 @@ function readConfigFile() {
|
|
|
509
617
|
return {};
|
|
510
618
|
}
|
|
511
619
|
}
|
|
620
|
+
function getConfigPath() {
|
|
621
|
+
return STORAGE_CONFIG_PATH;
|
|
622
|
+
}
|
|
512
623
|
function getStorageDatabaseEnv() {
|
|
513
624
|
for (const env of DATABASE_ENV_NAMES) {
|
|
514
625
|
if (readEnv(env.name))
|
|
@@ -745,11 +856,7 @@ function getStorageStatus() {
|
|
|
745
856
|
function getConfiguredConnectionString() {
|
|
746
857
|
return getStorageDatabaseUrl() ?? undefined;
|
|
747
858
|
}
|
|
748
|
-
function
|
|
749
|
-
assertNoLegacyStorageMode2();
|
|
750
|
-
if (!isServerContext()) {
|
|
751
|
-
throw new Error("Refusing to construct an RDS Postgres DSN outside the mementos-serve server. " + "The raw database DSN is NEVER distributed to client machines. " + "Clients must use the HTTP API: set HASNA_MEMENTOS_API_URL and " + "HASNA_MEMENTOS_API_KEY (and unset HASNA_MEMENTOS_DATABASE_URL).");
|
|
752
|
-
}
|
|
859
|
+
function resolveConfiguredConnectionString(dbName) {
|
|
753
860
|
const envConnectionString = getConfiguredConnectionString();
|
|
754
861
|
if (envConnectionString) {
|
|
755
862
|
const validation = validatePostgresConnectionString(envConnectionString);
|
|
@@ -768,7 +875,7 @@ function getStorageConnectionString(dbName = "mementos") {
|
|
|
768
875
|
missing.push("storage.rds.username");
|
|
769
876
|
}
|
|
770
877
|
if (missing.length > 0) {
|
|
771
|
-
throw new Error(`Remote storage database is not configured. Missing ${missing.join(", ")}. Set HASNA_MEMENTOS_DATABASE_URL or configure
|
|
878
|
+
throw new Error(`Remote storage database is not configured. Missing ${missing.join(", ")}. Set HASNA_MEMENTOS_DATABASE_URL or configure ${STORAGE_CONFIG_PATH}.`);
|
|
772
879
|
}
|
|
773
880
|
const password = process.env[password_env];
|
|
774
881
|
if (!password) {
|
|
@@ -777,6 +884,17 @@ function getStorageConnectionString(dbName = "mementos") {
|
|
|
777
884
|
const sslParam = ssl ? "?sslmode=require" : "";
|
|
778
885
|
return `postgres://${username}:${encodeURIComponent(password)}@${host}:${port}/${dbName}${sslParam}`;
|
|
779
886
|
}
|
|
887
|
+
function getStorageConnectionString(dbName = "mementos") {
|
|
888
|
+
assertNoLegacyStorageMode2();
|
|
889
|
+
if (!isServerContext()) {
|
|
890
|
+
throw new Error("Refusing to construct an RDS Postgres DSN outside the mementos-serve server. " + "The raw database DSN is NEVER distributed to client machines. " + "Clients must use the HTTP API: set HASNA_MEMENTOS_API_URL and " + "HASNA_MEMENTOS_API_KEY (and unset HASNA_MEMENTOS_DATABASE_URL).");
|
|
891
|
+
}
|
|
892
|
+
return resolveConfiguredConnectionString(dbName);
|
|
893
|
+
}
|
|
894
|
+
function getStorageConnectionStringForOperator(dbName = "mementos") {
|
|
895
|
+
assertNoLegacyStorageMode2();
|
|
896
|
+
return resolveConfiguredConnectionString(dbName);
|
|
897
|
+
}
|
|
780
898
|
function isSyncExcludedTable(table) {
|
|
781
899
|
return SYNC_EXCLUDED_TABLE_PATTERNS.some((pattern) => pattern.test(table));
|
|
782
900
|
}
|
|
@@ -935,6 +1053,7 @@ CREATE TABLE IF NOT EXISTS _sync_meta (
|
|
|
935
1053
|
var init_storage = __esm(() => {
|
|
936
1054
|
init_backend();
|
|
937
1055
|
init_retired_storage_mode();
|
|
1056
|
+
init_paths();
|
|
938
1057
|
PgSyncPool = class PgSyncPool {
|
|
939
1058
|
worker;
|
|
940
1059
|
status;
|
|
@@ -952,12 +1071,12 @@ var init_storage = __esm(() => {
|
|
|
952
1071
|
const ext = import.meta.url.endsWith(".ts") ? ".ts" : ".js";
|
|
953
1072
|
const here = fileURLToPath(new URL(".", import.meta.url));
|
|
954
1073
|
const candidates = [
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1074
|
+
join3(here, `pg-sync-worker${ext}`),
|
|
1075
|
+
join3(here, "..", `pg-sync-worker${ext}`),
|
|
1076
|
+
join3(here, "..", "..", `pg-sync-worker${ext}`)
|
|
958
1077
|
];
|
|
959
1078
|
for (const candidate of candidates) {
|
|
960
|
-
if (
|
|
1079
|
+
if (existsSync2(candidate))
|
|
961
1080
|
return candidate;
|
|
962
1081
|
}
|
|
963
1082
|
return candidates[0];
|
|
@@ -1044,7 +1163,7 @@ var init_storage = __esm(() => {
|
|
|
1044
1163
|
MEMENTOS_STORAGE_FALLBACK_ENV = {
|
|
1045
1164
|
databaseUrl: "MEMENTOS_DATABASE_URL"
|
|
1046
1165
|
};
|
|
1047
|
-
LOCAL_DATA_DIR =
|
|
1166
|
+
LOCAL_DATA_DIR = getDataRoot();
|
|
1048
1167
|
DEFAULT_STORAGE_CONFIG = {
|
|
1049
1168
|
rds: {
|
|
1050
1169
|
host: "",
|
|
@@ -1059,8 +1178,8 @@ var init_storage = __esm(() => {
|
|
|
1059
1178
|
schedule_minutes: 0
|
|
1060
1179
|
}
|
|
1061
1180
|
};
|
|
1062
|
-
STORAGE_CONFIG_DIR =
|
|
1063
|
-
STORAGE_CONFIG_PATH =
|
|
1181
|
+
STORAGE_CONFIG_DIR = join3(LOCAL_DATA_DIR, "storage");
|
|
1182
|
+
STORAGE_CONFIG_PATH = join3(STORAGE_CONFIG_DIR, "config.json");
|
|
1064
1183
|
DATABASE_ENV_NAMES = [
|
|
1065
1184
|
{ name: MEMENTOS_STORAGE_ENV.databaseUrl, deprecated: false },
|
|
1066
1185
|
{ name: MEMENTOS_STORAGE_FALLBACK_ENV.databaseUrl, deprecated: false }
|
|
@@ -1085,7 +1204,7 @@ var init_storage = __esm(() => {
|
|
|
1085
1204
|
|
|
1086
1205
|
// src/db/api-mode.ts
|
|
1087
1206
|
import { tmpdir } from "os";
|
|
1088
|
-
import { join as
|
|
1207
|
+
import { join as join4 } from "path";
|
|
1089
1208
|
import { writeFileSync as writeFileSync2, unlinkSync } from "fs";
|
|
1090
1209
|
import { randomUUID } from "crypto";
|
|
1091
1210
|
function firstEnv2(keys) {
|
|
@@ -1195,7 +1314,7 @@ x-api-key: ${cfg.apiKey}
|
|
|
1195
1314
|
];
|
|
1196
1315
|
let bodyFile;
|
|
1197
1316
|
if (hasBody) {
|
|
1198
|
-
bodyFile =
|
|
1317
|
+
bodyFile = join4(tmpdir(), `mem-req-${process.pid}-${randomUUID()}.json`);
|
|
1199
1318
|
writeFileSync2(bodyFile, JSON.stringify(body), { mode: 384 });
|
|
1200
1319
|
args.push("--data-binary", `@${bodyFile}`);
|
|
1201
1320
|
}
|
|
@@ -2680,18 +2799,18 @@ __export(exports_database, {
|
|
|
2680
2799
|
escapeLikePrefix: () => escapeLikePrefix,
|
|
2681
2800
|
closeDatabase: () => closeDatabase
|
|
2682
2801
|
});
|
|
2683
|
-
import { existsSync as
|
|
2684
|
-
import { dirname, join as
|
|
2802
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, cpSync } from "fs";
|
|
2803
|
+
import { dirname, join as join5, resolve as resolve2 } from "path";
|
|
2685
2804
|
function isInMemoryDb(path) {
|
|
2686
2805
|
return path === ":memory:" || path.startsWith("file::memory:");
|
|
2687
2806
|
}
|
|
2688
2807
|
function findNearestMementosDb(startDir) {
|
|
2689
|
-
let dir =
|
|
2808
|
+
let dir = resolve2(startDir);
|
|
2690
2809
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
2691
|
-
const legacyHomeDb =
|
|
2810
|
+
const legacyHomeDb = resolve2(home, ".mementos", "mementos.db");
|
|
2692
2811
|
while (true) {
|
|
2693
|
-
const candidate =
|
|
2694
|
-
if (
|
|
2812
|
+
const candidate = join5(dir, ".mementos", "mementos.db");
|
|
2813
|
+
if (existsSync3(candidate) && resolve2(candidate) !== legacyHomeDb)
|
|
2695
2814
|
return candidate;
|
|
2696
2815
|
const parent = dirname(dir);
|
|
2697
2816
|
if (parent === dir)
|
|
@@ -2701,9 +2820,9 @@ function findNearestMementosDb(startDir) {
|
|
|
2701
2820
|
return null;
|
|
2702
2821
|
}
|
|
2703
2822
|
function findGitRoot(startDir) {
|
|
2704
|
-
let dir =
|
|
2823
|
+
let dir = resolve2(startDir);
|
|
2705
2824
|
while (true) {
|
|
2706
|
-
if (
|
|
2825
|
+
if (existsSync3(join5(dir, ".git")))
|
|
2707
2826
|
return dir;
|
|
2708
2827
|
const parent = dirname(dir);
|
|
2709
2828
|
if (parent === dir)
|
|
@@ -2714,10 +2833,10 @@ function findGitRoot(startDir) {
|
|
|
2714
2833
|
}
|
|
2715
2834
|
function migrateGlobalDir() {
|
|
2716
2835
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
2717
|
-
const newDir =
|
|
2718
|
-
const oldDir =
|
|
2719
|
-
if (!
|
|
2720
|
-
mkdirSync2(
|
|
2836
|
+
const newDir = getDataRoot();
|
|
2837
|
+
const oldDir = join5(home, ".mementos");
|
|
2838
|
+
if (!existsSync3(newDir) && existsSync3(oldDir)) {
|
|
2839
|
+
mkdirSync2(dirname(newDir), { recursive: true });
|
|
2721
2840
|
cpSync(oldDir, newDir, { recursive: true });
|
|
2722
2841
|
}
|
|
2723
2842
|
}
|
|
@@ -2734,18 +2853,17 @@ function getDbPath() {
|
|
|
2734
2853
|
if (process.env["MEMENTOS_DB_SCOPE"] === "project") {
|
|
2735
2854
|
const gitRoot = findGitRoot(cwd);
|
|
2736
2855
|
if (gitRoot) {
|
|
2737
|
-
return
|
|
2856
|
+
return join5(gitRoot, ".mementos", "mementos.db");
|
|
2738
2857
|
}
|
|
2739
2858
|
}
|
|
2740
2859
|
migrateGlobalDir();
|
|
2741
|
-
|
|
2742
|
-
return join3(home, ".hasna", "mementos", "mementos.db");
|
|
2860
|
+
return join5(getDataRoot(), "mementos.db");
|
|
2743
2861
|
}
|
|
2744
2862
|
function ensureDir(filePath) {
|
|
2745
2863
|
if (isInMemoryDb(filePath))
|
|
2746
2864
|
return;
|
|
2747
|
-
const dir = dirname(
|
|
2748
|
-
if (!
|
|
2865
|
+
const dir = dirname(resolve2(filePath));
|
|
2866
|
+
if (!existsSync3(dir)) {
|
|
2749
2867
|
mkdirSync2(dir, { recursive: true });
|
|
2750
2868
|
}
|
|
2751
2869
|
}
|
|
@@ -2883,6 +3001,7 @@ var init_database = __esm(() => {
|
|
|
2883
3001
|
init_storage();
|
|
2884
3002
|
init_api_mode();
|
|
2885
3003
|
init_migrations();
|
|
3004
|
+
init_paths();
|
|
2886
3005
|
ALLOWED_TABLES = new Set([
|
|
2887
3006
|
"memories",
|
|
2888
3007
|
"agents",
|
|
@@ -3406,12 +3525,22 @@ function createMemory(input, dedupeMode = "merge", db) {
|
|
|
3406
3525
|
const effectiveMode = dedupeMode === "overwrite" ? "merge" : dedupeMode === "version-fork" ? "create" : dedupeMode;
|
|
3407
3526
|
if (effectiveMode === "error") {
|
|
3408
3527
|
const existing = d.query(`SELECT id, agent_id, updated_at FROM memories
|
|
3409
|
-
WHERE key = ? AND scope = ? AND COALESCE(project_id, '') = ?
|
|
3528
|
+
WHERE key = ? AND scope = ? AND COALESCE(project_id, '') = ?
|
|
3410
3529
|
LIMIT 1`).get(input.key, input.scope || "private", input.project_id || "");
|
|
3411
3530
|
if (existing) {
|
|
3412
3531
|
throw new MemoryConflictError(input.key, existing);
|
|
3413
3532
|
}
|
|
3414
3533
|
}
|
|
3534
|
+
if (effectiveMode === "create") {
|
|
3535
|
+
const existing = d.query(`SELECT id, agent_id, updated_at FROM memories
|
|
3536
|
+
WHERE key = ? AND scope = ?
|
|
3537
|
+
AND COALESCE(agent_id, '') = ?
|
|
3538
|
+
AND COALESCE(project_id, '') = ?
|
|
3539
|
+
AND COALESCE(session_id, '') = ?`).get(input.key, input.scope || "private", input.agent_id || "", input.project_id || "", input.session_id || "");
|
|
3540
|
+
if (existing) {
|
|
3541
|
+
throw new MemoryConflictError(input.key, existing);
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3415
3544
|
if (effectiveMode === "merge") {
|
|
3416
3545
|
const existing = d.query(`SELECT id, version FROM memories
|
|
3417
3546
|
WHERE key = ? AND scope = ?
|
|
@@ -4063,6 +4192,17 @@ function updateMemory(id, input, db) {
|
|
|
4063
4192
|
if (existing.version !== input.version) {
|
|
4064
4193
|
throw new VersionConflictError(id, input.version, existing.version);
|
|
4065
4194
|
}
|
|
4195
|
+
if (input.scope !== undefined && input.scope !== existing.scope) {
|
|
4196
|
+
const conflict = d.query(`SELECT id, agent_id, updated_at FROM memories
|
|
4197
|
+
WHERE key = ? AND scope = ?
|
|
4198
|
+
AND COALESCE(agent_id, '') = ?
|
|
4199
|
+
AND COALESCE(project_id, '') = ?
|
|
4200
|
+
AND COALESCE(session_id, '') = ?
|
|
4201
|
+
AND id != ?`).get(existing.key, input.scope, existing.agent_id || "", existing.project_id || "", existing.session_id || "", memoryId);
|
|
4202
|
+
if (conflict) {
|
|
4203
|
+
throw new MemoryConflictError(existing.key, conflict);
|
|
4204
|
+
}
|
|
4205
|
+
}
|
|
4066
4206
|
const sets = ["version = version + 1", "updated_at = ?"];
|
|
4067
4207
|
const params = [now()];
|
|
4068
4208
|
if (input.value !== undefined) {
|
|
@@ -5547,7 +5687,9 @@ function scoreResults(rows, queryLower, graphBoostedIds) {
|
|
|
5547
5687
|
scored.sort((a, b) => {
|
|
5548
5688
|
if (b.score !== a.score)
|
|
5549
5689
|
return b.score - a.score;
|
|
5550
|
-
|
|
5690
|
+
if (b.memory.importance !== a.memory.importance)
|
|
5691
|
+
return b.memory.importance - a.memory.importance;
|
|
5692
|
+
return a.memory.id.localeCompare(b.memory.id);
|
|
5551
5693
|
});
|
|
5552
5694
|
return scored;
|
|
5553
5695
|
}
|
|
@@ -11761,14 +11903,14 @@ var init_export_v1 = __esm(() => {
|
|
|
11761
11903
|
});
|
|
11762
11904
|
|
|
11763
11905
|
// src/lib/config.ts
|
|
11764
|
-
import { existsSync as
|
|
11765
|
-
import { homedir as
|
|
11766
|
-
import { basename as basename2, dirname as dirname4, join as
|
|
11906
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync3, readdirSync as readdirSync2, writeFileSync as writeFileSync3, unlinkSync as unlinkSync2, cpSync as cpSync2 } from "fs";
|
|
11907
|
+
import { homedir as homedir3 } from "os";
|
|
11908
|
+
import { basename as basename2, dirname as dirname4, join as join9, resolve as resolve4 } from "path";
|
|
11767
11909
|
function isInMemoryDb2(path) {
|
|
11768
11910
|
return path === ":memory:" || path.startsWith("file::memory:");
|
|
11769
11911
|
}
|
|
11770
11912
|
function homeDir() {
|
|
11771
|
-
return process.env["HOME"] || process.env["USERPROFILE"] ||
|
|
11913
|
+
return process.env["HOME"] || process.env["USERPROFILE"] || homedir3();
|
|
11772
11914
|
}
|
|
11773
11915
|
function deepMerge(target, source) {
|
|
11774
11916
|
const result = { ...target };
|
|
@@ -11790,9 +11932,9 @@ function isValidCategory(value) {
|
|
|
11790
11932
|
return VALID_CATEGORIES.includes(value);
|
|
11791
11933
|
}
|
|
11792
11934
|
function loadConfig() {
|
|
11793
|
-
const configPath =
|
|
11935
|
+
const configPath = join9(getDataRoot(), "config.json");
|
|
11794
11936
|
let fileConfig = {};
|
|
11795
|
-
if (
|
|
11937
|
+
if (existsSync7(configPath)) {
|
|
11796
11938
|
try {
|
|
11797
11939
|
const raw = readFileSync3(configPath, "utf-8");
|
|
11798
11940
|
fileConfig = JSON.parse(raw);
|
|
@@ -11818,10 +11960,10 @@ function loadConfig() {
|
|
|
11818
11960
|
}
|
|
11819
11961
|
function findFileWalkingUp(filename) {
|
|
11820
11962
|
let dir = process.cwd();
|
|
11821
|
-
const legacyHomeMementosDb =
|
|
11963
|
+
const legacyHomeMementosDb = resolve4(homeDir(), ".mementos", "mementos.db");
|
|
11822
11964
|
while (true) {
|
|
11823
|
-
const candidate =
|
|
11824
|
-
if (
|
|
11965
|
+
const candidate = join9(dir, filename);
|
|
11966
|
+
if (existsSync7(candidate) && resolve4(candidate) !== legacyHomeMementosDb) {
|
|
11825
11967
|
return candidate;
|
|
11826
11968
|
}
|
|
11827
11969
|
const parent = dirname4(dir);
|
|
@@ -11834,7 +11976,7 @@ function findFileWalkingUp(filename) {
|
|
|
11834
11976
|
function findGitRoot3() {
|
|
11835
11977
|
let dir = process.cwd();
|
|
11836
11978
|
while (true) {
|
|
11837
|
-
if (
|
|
11979
|
+
if (existsSync7(join9(dir, ".git"))) {
|
|
11838
11980
|
return dir;
|
|
11839
11981
|
}
|
|
11840
11982
|
const parent = dirname4(dir);
|
|
@@ -11845,14 +11987,14 @@ function findGitRoot3() {
|
|
|
11845
11987
|
}
|
|
11846
11988
|
}
|
|
11847
11989
|
function profilesDir() {
|
|
11848
|
-
return
|
|
11990
|
+
return join9(getDataRoot(), "profiles");
|
|
11849
11991
|
}
|
|
11850
11992
|
function globalConfigPath() {
|
|
11851
|
-
return
|
|
11993
|
+
return join9(getDataRoot(), "config.json");
|
|
11852
11994
|
}
|
|
11853
11995
|
function readGlobalConfig() {
|
|
11854
11996
|
const p = globalConfigPath();
|
|
11855
|
-
if (!
|
|
11997
|
+
if (!existsSync7(p))
|
|
11856
11998
|
return {};
|
|
11857
11999
|
try {
|
|
11858
12000
|
return JSON.parse(readFileSync3(p, "utf-8"));
|
|
@@ -11869,10 +12011,10 @@ function getActiveProfile() {
|
|
|
11869
12011
|
}
|
|
11870
12012
|
function getDbPath2() {
|
|
11871
12013
|
const _home = homeDir();
|
|
11872
|
-
const _newDir =
|
|
11873
|
-
const _oldDir =
|
|
11874
|
-
if (!
|
|
11875
|
-
mkdirSync4(
|
|
12014
|
+
const _newDir = getDataRoot();
|
|
12015
|
+
const _oldDir = join9(_home, ".mementos");
|
|
12016
|
+
if (!existsSync7(_newDir) && existsSync7(_oldDir)) {
|
|
12017
|
+
mkdirSync4(join9(_home, ".hasna"), { recursive: true });
|
|
11876
12018
|
cpSync2(_oldDir, _newDir, { recursive: true });
|
|
11877
12019
|
}
|
|
11878
12020
|
const envDbPath = process.env["HASNA_MEMENTOS_DB_PATH"] ?? process.env["MEMENTOS_DB_PATH"];
|
|
@@ -11880,13 +12022,13 @@ function getDbPath2() {
|
|
|
11880
12022
|
if (isInMemoryDb2(envDbPath)) {
|
|
11881
12023
|
return envDbPath;
|
|
11882
12024
|
}
|
|
11883
|
-
const resolved =
|
|
12025
|
+
const resolved = resolve4(envDbPath);
|
|
11884
12026
|
ensureDir2(dirname4(resolved));
|
|
11885
12027
|
return resolved;
|
|
11886
12028
|
}
|
|
11887
12029
|
const profile = getActiveProfile();
|
|
11888
12030
|
if (profile) {
|
|
11889
|
-
const profilePath =
|
|
12031
|
+
const profilePath = join9(profilesDir(), `${profile}.db`);
|
|
11890
12032
|
ensureDir2(dirname4(profilePath));
|
|
11891
12033
|
return profilePath;
|
|
11892
12034
|
}
|
|
@@ -11894,26 +12036,27 @@ function getDbPath2() {
|
|
|
11894
12036
|
if (dbScope === "project") {
|
|
11895
12037
|
const gitRoot = findGitRoot3();
|
|
11896
12038
|
if (gitRoot) {
|
|
11897
|
-
const dbPath =
|
|
12039
|
+
const dbPath = join9(gitRoot, ".mementos", "mementos.db");
|
|
11898
12040
|
ensureDir2(dirname4(dbPath));
|
|
11899
12041
|
return dbPath;
|
|
11900
12042
|
}
|
|
11901
12043
|
}
|
|
11902
|
-
const found = findFileWalkingUp(
|
|
12044
|
+
const found = findFileWalkingUp(join9(".mementos", "mementos.db"));
|
|
11903
12045
|
if (found) {
|
|
11904
12046
|
return found;
|
|
11905
12047
|
}
|
|
11906
|
-
const fallback =
|
|
12048
|
+
const fallback = join9(getDataRoot(), "mementos.db");
|
|
11907
12049
|
ensureDir2(dirname4(fallback));
|
|
11908
12050
|
return fallback;
|
|
11909
12051
|
}
|
|
11910
12052
|
function ensureDir2(dir) {
|
|
11911
|
-
if (!
|
|
12053
|
+
if (!existsSync7(dir)) {
|
|
11912
12054
|
mkdirSync4(dir, { recursive: true });
|
|
11913
12055
|
}
|
|
11914
12056
|
}
|
|
11915
12057
|
var DEFAULT_CONFIG2, VALID_SCOPES, VALID_CATEGORIES;
|
|
11916
12058
|
var init_config = __esm(() => {
|
|
12059
|
+
init_paths();
|
|
11917
12060
|
DEFAULT_CONFIG2 = {
|
|
11918
12061
|
default_scope: "private",
|
|
11919
12062
|
default_category: "knowledge",
|
|
@@ -13863,7 +14006,7 @@ function getPgMigrationDiagnostics(connectionString) {
|
|
|
13863
14006
|
const issues = [];
|
|
13864
14007
|
if (!resolvedConnectionString) {
|
|
13865
14008
|
try {
|
|
13866
|
-
resolvedConnectionString =
|
|
14009
|
+
resolvedConnectionString = getStorageConnectionStringForOperator("mementos");
|
|
13867
14010
|
} catch (error) {
|
|
13868
14011
|
issues.push(error instanceof Error ? error.message : String(error));
|
|
13869
14012
|
}
|
|
@@ -13934,7 +14077,7 @@ var init_pg_migrate = __esm(() => {
|
|
|
13934
14077
|
init_pg_migrations();
|
|
13935
14078
|
});
|
|
13936
14079
|
|
|
13937
|
-
// ../../node_modules/.bun/@ai-sdk+provider@3.0.
|
|
14080
|
+
// ../../node_modules/.bun/@ai-sdk+provider@3.0.15/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
13938
14081
|
function getErrorMessage(error) {
|
|
13939
14082
|
if (error == null) {
|
|
13940
14083
|
return "unknown error";
|
|
@@ -13966,7 +14109,7 @@ function isJSONObject(value) {
|
|
|
13966
14109
|
return value != null && typeof value === "object" && Object.entries(value).every(([key, val]) => typeof key === "string" && (val === undefined || isJSONValue(val)));
|
|
13967
14110
|
}
|
|
13968
14111
|
var marker = "vercel.ai.error", symbol, _a, _b, AISDKError, name = "AI_APICallError", marker2, symbol2, _a2, _b2, APICallError, name2 = "AI_EmptyResponseBodyError", marker3, symbol3, _a3, _b3, EmptyResponseBodyError, name3 = "AI_InvalidArgumentError", marker4, symbol4, _a4, _b4, InvalidArgumentError, name4 = "AI_InvalidPromptError", marker5, symbol5, _a5, _b5, InvalidPromptError, name5 = "AI_InvalidResponseDataError", marker6, symbol6, _a6, _b6, InvalidResponseDataError, name6 = "AI_JSONParseError", marker7, symbol7, _a7, _b7, JSONParseError, name7 = "AI_LoadAPIKeyError", marker8, symbol8, _a8, _b8, LoadAPIKeyError, name8 = "AI_LoadSettingError", marker9, symbol9, _a9, _b9, LoadSettingError, name9 = "AI_NoContentGeneratedError", marker10, symbol10, _a10, _b10, NoContentGeneratedError, name10 = "AI_NoSuchModelError", marker11, symbol11, _a11, _b11, NoSuchModelError, name11 = "AI_TooManyEmbeddingValuesForCallError", marker12, symbol12, _a12, _b12, TooManyEmbeddingValuesForCallError, name12 = "AI_TypeValidationError", marker13, symbol13, _a13, _b13, TypeValidationError, name13 = "AI_UnsupportedFunctionalityError", marker14, symbol14, _a14, _b14, UnsupportedFunctionalityError;
|
|
13969
|
-
var
|
|
14112
|
+
var init_dist2 = __esm(() => {
|
|
13970
14113
|
symbol = Symbol.for(marker);
|
|
13971
14114
|
AISDKError = class _AISDKError extends (_b = Error, _a = symbol, _b) {
|
|
13972
14115
|
constructor({
|
|
@@ -23550,7 +23693,7 @@ class JSONSchemaGenerator {
|
|
|
23550
23693
|
if (val === undefined) {
|
|
23551
23694
|
if (this.unrepresentable === "throw") {
|
|
23552
23695
|
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
23553
|
-
}
|
|
23696
|
+
}
|
|
23554
23697
|
} else if (typeof val === "bigint") {
|
|
23555
23698
|
if (this.unrepresentable === "throw") {
|
|
23556
23699
|
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
@@ -25599,7 +25742,7 @@ var init_v3 = __esm(() => {
|
|
|
25599
25742
|
init_external();
|
|
25600
25743
|
});
|
|
25601
25744
|
|
|
25602
|
-
// ../../node_modules/.bun/eventsource-parser@3.1.
|
|
25745
|
+
// ../../node_modules/.bun/eventsource-parser@3.1.1/node_modules/eventsource-parser/dist/index.js
|
|
25603
25746
|
function noop(_arg) {}
|
|
25604
25747
|
function createParser(config2) {
|
|
25605
25748
|
if (typeof config2 == "function")
|
|
@@ -25686,7 +25829,7 @@ ${value2}`, dataLines++;
|
|
|
25686
25829
|
}
|
|
25687
25830
|
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
25688
25831
|
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
25689
|
-
|
|
25832
|
+
value2.includes("\x00") || (id = value2);
|
|
25690
25833
|
return;
|
|
25691
25834
|
}
|
|
25692
25835
|
if (firstCharCode === 58) {
|
|
@@ -25714,7 +25857,7 @@ ${value2}`, dataLines++;
|
|
|
25714
25857
|
${value}`, dataLines++;
|
|
25715
25858
|
break;
|
|
25716
25859
|
case "id":
|
|
25717
|
-
|
|
25860
|
+
value.includes("\x00") || (id = value);
|
|
25718
25861
|
break;
|
|
25719
25862
|
case "retry":
|
|
25720
25863
|
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
@@ -25751,7 +25894,7 @@ function isEventPrefix(chunk, i, firstCharCode) {
|
|
|
25751
25894
|
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
25752
25895
|
}
|
|
25753
25896
|
var ParseError, LF = 10, CR = 13, SPACE = 32;
|
|
25754
|
-
var
|
|
25897
|
+
var init_dist3 = __esm(() => {
|
|
25755
25898
|
ParseError = class ParseError extends Error {
|
|
25756
25899
|
constructor(message, options) {
|
|
25757
25900
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
@@ -25759,10 +25902,10 @@ var init_dist2 = __esm(() => {
|
|
|
25759
25902
|
};
|
|
25760
25903
|
});
|
|
25761
25904
|
|
|
25762
|
-
// ../../node_modules/.bun/eventsource-parser@3.1.
|
|
25905
|
+
// ../../node_modules/.bun/eventsource-parser@3.1.1/node_modules/eventsource-parser/dist/stream.js
|
|
25763
25906
|
var EventSourceParserStream;
|
|
25764
25907
|
var init_stream = __esm(() => {
|
|
25765
|
-
|
|
25908
|
+
init_dist3();
|
|
25766
25909
|
EventSourceParserStream = class EventSourceParserStream extends TransformStream {
|
|
25767
25910
|
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
25768
25911
|
let parser;
|
|
@@ -25788,7 +25931,7 @@ var init_stream = __esm(() => {
|
|
|
25788
25931
|
};
|
|
25789
25932
|
});
|
|
25790
25933
|
|
|
25791
|
-
// ../../node_modules/.bun/@ai-sdk+provider-utils@4.0.
|
|
25934
|
+
// ../../node_modules/.bun/@ai-sdk+provider-utils@4.0.46+27912429049419a2/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
25792
25935
|
function combineHeaders(...headers) {
|
|
25793
25936
|
return headers.reduce((combinedHeaders, currentHeaders) => ({
|
|
25794
25937
|
...combinedHeaders,
|
|
@@ -26129,11 +26272,10 @@ async function loadNodeModule(id) {
|
|
|
26129
26272
|
var _a22;
|
|
26130
26273
|
const processWithBuiltins = globalThis.process;
|
|
26131
26274
|
const builtinModule = (_a22 = processWithBuiltins == null ? undefined : processWithBuiltins.getBuiltinModule) == null ? undefined : _a22.call(processWithBuiltins, id);
|
|
26132
|
-
|
|
26133
|
-
}
|
|
26134
|
-
|
|
26135
|
-
|
|
26136
|
-
return dynamicImport(id);
|
|
26275
|
+
if (builtinModule == null) {
|
|
26276
|
+
throw new Error(`Node.js built-in module ${id} is unavailable`);
|
|
26277
|
+
}
|
|
26278
|
+
return builtinModule;
|
|
26137
26279
|
}
|
|
26138
26280
|
function getCurrentModulePath() {
|
|
26139
26281
|
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
@@ -26232,7 +26374,7 @@ async function readResponseWithSizeLimit({
|
|
|
26232
26374
|
} finally {
|
|
26233
26375
|
try {
|
|
26234
26376
|
await reader.cancel();
|
|
26235
|
-
} finally {
|
|
26377
|
+
} catch (e) {} finally {
|
|
26236
26378
|
reader.releaseLock();
|
|
26237
26379
|
}
|
|
26238
26380
|
}
|
|
@@ -27497,7 +27639,7 @@ function createProviderToolFactoryWithOutputSchema({
|
|
|
27497
27639
|
supportsDeferredResults
|
|
27498
27640
|
});
|
|
27499
27641
|
}
|
|
27500
|
-
async function
|
|
27642
|
+
async function resolve6(value) {
|
|
27501
27643
|
if (typeof value === "function") {
|
|
27502
27644
|
value = value();
|
|
27503
27645
|
}
|
|
@@ -27632,7 +27774,7 @@ var DelayedPromise = class {
|
|
|
27632
27774
|
isPending() {
|
|
27633
27775
|
return this.status.type === "pending";
|
|
27634
27776
|
}
|
|
27635
|
-
}, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, safeNodeFetchPromise, initialGlobalFetch, initialGlobalFetchIsNodeDefault,
|
|
27777
|
+
}, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, safeNodeFetchPromise, initialGlobalFetch, initialGlobalFetchIsNodeDefault, MAX_DOWNLOAD_REDIRECTS = 10, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
|
|
27636
27778
|
prefix,
|
|
27637
27779
|
size = 16,
|
|
27638
27780
|
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
@@ -27656,7 +27798,7 @@ var DelayedPromise = class {
|
|
|
27656
27798
|
});
|
|
27657
27799
|
}
|
|
27658
27800
|
return () => `${prefix}${separator}${generator()}`;
|
|
27659
|
-
}, generateId2, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.
|
|
27801
|
+
}, generateId2, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.46", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
|
|
27660
27802
|
url: url2,
|
|
27661
27803
|
headers = {},
|
|
27662
27804
|
successfulResponseHandler,
|
|
@@ -28176,23 +28318,23 @@ var DelayedPromise = class {
|
|
|
28176
28318
|
});
|
|
28177
28319
|
}
|
|
28178
28320
|
};
|
|
28179
|
-
var
|
|
28180
|
-
|
|
28181
|
-
|
|
28182
|
-
|
|
28183
|
-
|
|
28184
|
-
|
|
28185
|
-
|
|
28186
|
-
|
|
28187
|
-
|
|
28321
|
+
var init_dist4 = __esm(() => {
|
|
28322
|
+
init_dist2();
|
|
28323
|
+
init_dist2();
|
|
28324
|
+
init_dist2();
|
|
28325
|
+
init_dist2();
|
|
28326
|
+
init_dist2();
|
|
28327
|
+
init_dist2();
|
|
28328
|
+
init_dist2();
|
|
28329
|
+
init_dist2();
|
|
28188
28330
|
init_v4();
|
|
28189
28331
|
init_v3();
|
|
28190
28332
|
init_v3();
|
|
28191
28333
|
init_v3();
|
|
28192
28334
|
init_stream();
|
|
28193
|
-
|
|
28194
|
-
|
|
28195
|
-
|
|
28335
|
+
init_dist2();
|
|
28336
|
+
init_dist2();
|
|
28337
|
+
init_dist2();
|
|
28196
28338
|
({ btoa, atob: atob2 } = globalThis);
|
|
28197
28339
|
marker15 = `vercel.ai.error.${name14}`;
|
|
28198
28340
|
symbol17 = Symbol.for(marker15);
|
|
@@ -28285,7 +28427,7 @@ var init_dist3 = __esm(() => {
|
|
|
28285
28427
|
textDecoder = new TextDecoder;
|
|
28286
28428
|
});
|
|
28287
28429
|
|
|
28288
|
-
// ../../node_modules/.bun/@ai-sdk+anthropic@3.0.
|
|
28430
|
+
// ../../node_modules/.bun/@ai-sdk+anthropic@3.0.111+27912429049419a2/node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
28289
28431
|
var exports_dist = {};
|
|
28290
28432
|
__export(exports_dist, {
|
|
28291
28433
|
forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep,
|
|
@@ -28743,7 +28885,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
28743
28885
|
cacheControlValidator,
|
|
28744
28886
|
toolNameMapping
|
|
28745
28887
|
}) {
|
|
28746
|
-
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u
|
|
28888
|
+
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
28747
28889
|
const betas = /* @__PURE__ */ new Set;
|
|
28748
28890
|
const blocks = groupIntoBlocks(prompt);
|
|
28749
28891
|
const validator = cacheControlValidator || new CacheControlValidator;
|
|
@@ -29131,6 +29273,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29131
29273
|
break;
|
|
29132
29274
|
}
|
|
29133
29275
|
case "tool-call": {
|
|
29276
|
+
const caller = getAnthropicCaller(part.providerOptions);
|
|
29134
29277
|
if (part.providerExecuted) {
|
|
29135
29278
|
const providerToolName = toolNameMapping.toProviderToolName(part.toolName);
|
|
29136
29279
|
const isMcpToolUse = ((_l = (_k = part.providerOptions) == null ? undefined : _k.anthropic) == null ? undefined : _l.type) === "mcp-tool-use";
|
|
@@ -29159,6 +29302,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29159
29302
|
id: part.toolCallId,
|
|
29160
29303
|
name: subtoolName,
|
|
29161
29304
|
input,
|
|
29305
|
+
...caller && { caller },
|
|
29162
29306
|
cache_control: cacheControl
|
|
29163
29307
|
});
|
|
29164
29308
|
} else if (providerToolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && part.input.type === "programmatic-tool-call") {
|
|
@@ -29168,6 +29312,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29168
29312
|
id: part.toolCallId,
|
|
29169
29313
|
name: "code_execution",
|
|
29170
29314
|
input: inputWithoutType,
|
|
29315
|
+
...caller && { caller },
|
|
29171
29316
|
cache_control: cacheControl
|
|
29172
29317
|
});
|
|
29173
29318
|
} else {
|
|
@@ -29177,6 +29322,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29177
29322
|
id: part.toolCallId,
|
|
29178
29323
|
name: providerToolName,
|
|
29179
29324
|
input: part.input,
|
|
29325
|
+
...caller && { caller },
|
|
29180
29326
|
cache_control: cacheControl
|
|
29181
29327
|
});
|
|
29182
29328
|
} else if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
|
|
@@ -29185,6 +29331,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29185
29331
|
id: part.toolCallId,
|
|
29186
29332
|
name: providerToolName,
|
|
29187
29333
|
input: part.input,
|
|
29334
|
+
...caller && { caller },
|
|
29188
29335
|
cache_control: cacheControl
|
|
29189
29336
|
});
|
|
29190
29337
|
} else if (providerToolName === "advisor") {
|
|
@@ -29193,6 +29340,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29193
29340
|
id: part.toolCallId,
|
|
29194
29341
|
name: "advisor",
|
|
29195
29342
|
input: {},
|
|
29343
|
+
...caller && { caller },
|
|
29196
29344
|
cache_control: cacheControl
|
|
29197
29345
|
});
|
|
29198
29346
|
} else {
|
|
@@ -29204,11 +29352,6 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29204
29352
|
}
|
|
29205
29353
|
break;
|
|
29206
29354
|
}
|
|
29207
|
-
const callerOptions = (_o = part.providerOptions) == null ? undefined : _o.anthropic;
|
|
29208
|
-
const caller = (callerOptions == null ? undefined : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
|
|
29209
|
-
type: callerOptions.caller.type,
|
|
29210
|
-
tool_id: callerOptions.caller.toolId
|
|
29211
|
-
} : callerOptions.caller.type === "direct" ? { type: "direct" } : undefined : undefined;
|
|
29212
29355
|
anthropicContent.push({
|
|
29213
29356
|
type: "tool_use",
|
|
29214
29357
|
id: part.toolCallId,
|
|
@@ -29221,6 +29364,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29221
29364
|
}
|
|
29222
29365
|
case "tool-result": {
|
|
29223
29366
|
const providerToolName = toolNameMapping.toProviderToolName(part.toolName);
|
|
29367
|
+
const caller = getAnthropicCaller(part.providerOptions);
|
|
29224
29368
|
if (mcpToolUseIds.has(part.toolCallId)) {
|
|
29225
29369
|
const output = part.output;
|
|
29226
29370
|
if (output.type !== "json" && output.type !== "error-json") {
|
|
@@ -29254,7 +29398,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29254
29398
|
tool_use_id: part.toolCallId,
|
|
29255
29399
|
content: {
|
|
29256
29400
|
type: "code_execution_tool_result_error",
|
|
29257
|
-
error_code: (
|
|
29401
|
+
error_code: (_o = errorInfo.errorCode) != null ? _o : "unknown"
|
|
29258
29402
|
},
|
|
29259
29403
|
cache_control: cacheControl
|
|
29260
29404
|
});
|
|
@@ -29265,7 +29409,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29265
29409
|
cache_control: cacheControl,
|
|
29266
29410
|
content: {
|
|
29267
29411
|
type: "bash_code_execution_tool_result_error",
|
|
29268
|
-
error_code: (
|
|
29412
|
+
error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
|
|
29269
29413
|
}
|
|
29270
29414
|
});
|
|
29271
29415
|
}
|
|
@@ -29298,7 +29442,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29298
29442
|
stdout: codeExecutionOutput.stdout,
|
|
29299
29443
|
stderr: codeExecutionOutput.stderr,
|
|
29300
29444
|
return_code: codeExecutionOutput.return_code,
|
|
29301
|
-
content: (
|
|
29445
|
+
content: (_q = codeExecutionOutput.content) != null ? _q : []
|
|
29302
29446
|
},
|
|
29303
29447
|
cache_control: cacheControl
|
|
29304
29448
|
});
|
|
@@ -29316,7 +29460,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29316
29460
|
encrypted_stdout: codeExecutionOutput.encrypted_stdout,
|
|
29317
29461
|
stderr: codeExecutionOutput.stderr,
|
|
29318
29462
|
return_code: codeExecutionOutput.return_code,
|
|
29319
|
-
content: (
|
|
29463
|
+
content: (_r = codeExecutionOutput.content) != null ? _r : []
|
|
29320
29464
|
},
|
|
29321
29465
|
cache_control: cacheControl
|
|
29322
29466
|
});
|
|
@@ -29335,7 +29479,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29335
29479
|
stdout: codeExecutionOutput.stdout,
|
|
29336
29480
|
stderr: codeExecutionOutput.stderr,
|
|
29337
29481
|
return_code: codeExecutionOutput.return_code,
|
|
29338
|
-
content: (
|
|
29482
|
+
content: (_s = codeExecutionOutput.content) != null ? _s : []
|
|
29339
29483
|
},
|
|
29340
29484
|
cache_control: cacheControl
|
|
29341
29485
|
});
|
|
@@ -29371,8 +29515,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29371
29515
|
tool_use_id: part.toolCallId,
|
|
29372
29516
|
content: {
|
|
29373
29517
|
type: "web_fetch_tool_result_error",
|
|
29374
|
-
error_code: (
|
|
29518
|
+
error_code: (_t = (await extractErrorValue(output.value)).errorCode) != null ? _t : "unavailable"
|
|
29375
29519
|
},
|
|
29520
|
+
...caller && { caller },
|
|
29376
29521
|
cache_control: cacheControl
|
|
29377
29522
|
});
|
|
29378
29523
|
break;
|
|
@@ -29406,6 +29551,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29406
29551
|
}
|
|
29407
29552
|
}
|
|
29408
29553
|
},
|
|
29554
|
+
...caller && { caller },
|
|
29409
29555
|
cache_control: cacheControl
|
|
29410
29556
|
});
|
|
29411
29557
|
break;
|
|
@@ -29418,8 +29564,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29418
29564
|
tool_use_id: part.toolCallId,
|
|
29419
29565
|
content: {
|
|
29420
29566
|
type: "web_search_tool_result_error",
|
|
29421
|
-
error_code: (
|
|
29567
|
+
error_code: (_u = (await extractErrorValue(output.value)).errorCode) != null ? _u : "unavailable"
|
|
29422
29568
|
},
|
|
29569
|
+
...caller && { caller },
|
|
29423
29570
|
cache_control: cacheControl
|
|
29424
29571
|
});
|
|
29425
29572
|
break;
|
|
@@ -29445,6 +29592,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29445
29592
|
encrypted_content: result.encryptedContent,
|
|
29446
29593
|
type: result.type
|
|
29447
29594
|
})),
|
|
29595
|
+
...caller && { caller },
|
|
29448
29596
|
cache_control: cacheControl
|
|
29449
29597
|
});
|
|
29450
29598
|
break;
|
|
@@ -29613,6 +29761,17 @@ function moveToolUseBlocksToEnd(content) {
|
|
|
29613
29761
|
flushSegment();
|
|
29614
29762
|
return result;
|
|
29615
29763
|
}
|
|
29764
|
+
function getAnthropicCaller(providerOptions) {
|
|
29765
|
+
var _a16;
|
|
29766
|
+
const caller = (_a16 = providerOptions == null ? undefined : providerOptions.anthropic) == null ? undefined : _a16.caller;
|
|
29767
|
+
if (((caller == null ? undefined : caller.type) === "code_execution_20250825" || (caller == null ? undefined : caller.type) === "code_execution_20260120") && caller.toolId) {
|
|
29768
|
+
return {
|
|
29769
|
+
type: caller.type,
|
|
29770
|
+
tool_id: caller.toolId
|
|
29771
|
+
};
|
|
29772
|
+
}
|
|
29773
|
+
return (caller == null ? undefined : caller.type) === "direct" ? { type: "direct" } : undefined;
|
|
29774
|
+
}
|
|
29616
29775
|
function mapAnthropicStopReason({
|
|
29617
29776
|
finishReason,
|
|
29618
29777
|
isJsonResponseFromTool
|
|
@@ -29789,6 +29948,16 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
29789
29948
|
}
|
|
29790
29949
|
};
|
|
29791
29950
|
}
|
|
29951
|
+
function getAnthropicCallerInfo(caller) {
|
|
29952
|
+
return caller == null ? undefined : {
|
|
29953
|
+
type: caller.type,
|
|
29954
|
+
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
29955
|
+
};
|
|
29956
|
+
}
|
|
29957
|
+
function getAnthropicCallerMetadata(caller) {
|
|
29958
|
+
const callerInfo = getAnthropicCallerInfo(caller);
|
|
29959
|
+
return callerInfo == null ? {} : { providerMetadata: { anthropic: { caller: callerInfo } } };
|
|
29960
|
+
}
|
|
29792
29961
|
function getModelCapabilities(modelId) {
|
|
29793
29962
|
if (modelId.includes("claude-opus-5")) {
|
|
29794
29963
|
return {
|
|
@@ -30017,7 +30186,7 @@ function forwardAnthropicContainerIdFromLastStep({
|
|
|
30017
30186
|
}
|
|
30018
30187
|
return;
|
|
30019
30188
|
}
|
|
30020
|
-
var VERSION2 = "3.0.
|
|
30189
|
+
var VERSION2 = "3.0.111", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicStopDetailsSchema, anthropicToolCallCallerSchema, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicSystemMessageProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
|
|
30021
30190
|
constructor() {
|
|
30022
30191
|
this.breakpointCount = 0;
|
|
30023
30192
|
this.warnings = [];
|
|
@@ -30525,11 +30694,11 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30525
30694
|
betas,
|
|
30526
30695
|
headers
|
|
30527
30696
|
}) {
|
|
30528
|
-
return combineHeaders(await
|
|
30697
|
+
return combineHeaders(await resolve6(this.config.headers), headers, betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {});
|
|
30529
30698
|
}
|
|
30530
30699
|
async getBetasFromHeaders(requestHeaders) {
|
|
30531
30700
|
var _a16, _b16;
|
|
30532
|
-
const configHeaders = await
|
|
30701
|
+
const configHeaders = await resolve6(this.config.headers);
|
|
30533
30702
|
const configBetaHeader = (_a16 = configHeaders["anthropic-beta"]) != null ? _a16 : "";
|
|
30534
30703
|
const requestBetaHeader = (_b16 = requestHeaders == null ? undefined : requestHeaders["anthropic-beta"]) != null ? _b16 : "";
|
|
30535
30704
|
return new Set([
|
|
@@ -30676,23 +30845,12 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30676
30845
|
text: JSON.stringify(part.input)
|
|
30677
30846
|
});
|
|
30678
30847
|
} else {
|
|
30679
|
-
const caller = part.caller;
|
|
30680
|
-
const callerInfo = caller ? {
|
|
30681
|
-
type: caller.type,
|
|
30682
|
-
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
30683
|
-
} : undefined;
|
|
30684
30848
|
content.push({
|
|
30685
30849
|
type: "tool-call",
|
|
30686
30850
|
toolCallId: part.id,
|
|
30687
30851
|
toolName: part.name,
|
|
30688
30852
|
input: JSON.stringify(part.input),
|
|
30689
|
-
...
|
|
30690
|
-
providerMetadata: {
|
|
30691
|
-
anthropic: {
|
|
30692
|
-
caller: callerInfo
|
|
30693
|
-
}
|
|
30694
|
-
}
|
|
30695
|
-
}
|
|
30853
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30696
30854
|
});
|
|
30697
30855
|
}
|
|
30698
30856
|
break;
|
|
@@ -30706,7 +30864,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30706
30864
|
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
30707
30865
|
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
30708
30866
|
providerExecuted: true,
|
|
30709
|
-
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {}
|
|
30867
|
+
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
30868
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30710
30869
|
});
|
|
30711
30870
|
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
30712
30871
|
const inputToSerialize = part.name === "code_execution" && part.input != null && typeof part.input === "object" && "code" in part.input && !("type" in part.input) ? { type: "programmatic-tool-call", ...part.input } : part.input;
|
|
@@ -30716,7 +30875,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30716
30875
|
toolName: toolNameMapping.toCustomToolName(part.name),
|
|
30717
30876
|
input: JSON.stringify(inputToSerialize),
|
|
30718
30877
|
providerExecuted: true,
|
|
30719
|
-
...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {}
|
|
30878
|
+
...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {},
|
|
30879
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30720
30880
|
});
|
|
30721
30881
|
} else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
|
|
30722
30882
|
serverToolCalls[part.id] = part.name;
|
|
@@ -30725,7 +30885,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30725
30885
|
toolCallId: part.id,
|
|
30726
30886
|
toolName: toolNameMapping.toCustomToolName(part.name),
|
|
30727
30887
|
input: JSON.stringify(part.input),
|
|
30728
|
-
providerExecuted: true
|
|
30888
|
+
providerExecuted: true,
|
|
30889
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30729
30890
|
});
|
|
30730
30891
|
} else if (part.name === "advisor") {
|
|
30731
30892
|
content.push({
|
|
@@ -30733,7 +30894,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30733
30894
|
toolCallId: part.id,
|
|
30734
30895
|
toolName: toolNameMapping.toCustomToolName("advisor"),
|
|
30735
30896
|
input: JSON.stringify(part.input),
|
|
30736
|
-
providerExecuted: true
|
|
30897
|
+
providerExecuted: true,
|
|
30898
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30737
30899
|
});
|
|
30738
30900
|
}
|
|
30739
30901
|
break;
|
|
@@ -30792,7 +30954,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30792
30954
|
data: part.content.content.source.data
|
|
30793
30955
|
}
|
|
30794
30956
|
}
|
|
30795
|
-
}
|
|
30957
|
+
},
|
|
30958
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30796
30959
|
});
|
|
30797
30960
|
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
30798
30961
|
content.push({
|
|
@@ -30803,7 +30966,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30803
30966
|
result: {
|
|
30804
30967
|
type: "web_fetch_tool_result_error",
|
|
30805
30968
|
errorCode: part.content.error_code
|
|
30806
|
-
}
|
|
30969
|
+
},
|
|
30970
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30807
30971
|
});
|
|
30808
30972
|
}
|
|
30809
30973
|
break;
|
|
@@ -30823,7 +30987,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30823
30987
|
encryptedContent: result.encrypted_content,
|
|
30824
30988
|
type: result.type
|
|
30825
30989
|
};
|
|
30826
|
-
})
|
|
30990
|
+
}),
|
|
30991
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30827
30992
|
});
|
|
30828
30993
|
for (const result of part.content) {
|
|
30829
30994
|
content.push({
|
|
@@ -30848,7 +31013,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30848
31013
|
result: {
|
|
30849
31014
|
type: "web_search_tool_result_error",
|
|
30850
31015
|
errorCode: part.content.error_code
|
|
30851
|
-
}
|
|
31016
|
+
},
|
|
31017
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30852
31018
|
});
|
|
30853
31019
|
}
|
|
30854
31020
|
break;
|
|
@@ -31189,11 +31355,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31189
31355
|
id: String(value.index)
|
|
31190
31356
|
});
|
|
31191
31357
|
} else {
|
|
31192
|
-
const
|
|
31193
|
-
const callerInfo = caller ? {
|
|
31194
|
-
type: caller.type,
|
|
31195
|
-
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
31196
|
-
} : undefined;
|
|
31358
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
31197
31359
|
const hasNonEmptyInput = part.input && Object.keys(part.input).length > 0;
|
|
31198
31360
|
const initialInput = hasNonEmptyInput ? JSON.stringify(part.input) : "";
|
|
31199
31361
|
contentBlocks[value.index] = {
|
|
@@ -31213,6 +31375,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31213
31375
|
return;
|
|
31214
31376
|
}
|
|
31215
31377
|
case "server_tool_use": {
|
|
31378
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
31216
31379
|
if ([
|
|
31217
31380
|
"web_fetch",
|
|
31218
31381
|
"web_search",
|
|
@@ -31233,7 +31396,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31233
31396
|
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
31234
31397
|
firstDelta: finalInput.length === 0,
|
|
31235
31398
|
providerToolName,
|
|
31236
|
-
providerToolInputType
|
|
31399
|
+
providerToolInputType,
|
|
31400
|
+
...callerInfo && { caller: callerInfo }
|
|
31237
31401
|
};
|
|
31238
31402
|
controller.enqueue({
|
|
31239
31403
|
type: "tool-input-start",
|
|
@@ -31252,7 +31416,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31252
31416
|
input: "",
|
|
31253
31417
|
providerExecuted: true,
|
|
31254
31418
|
firstDelta: true,
|
|
31255
|
-
providerToolName: part.name
|
|
31419
|
+
providerToolName: part.name,
|
|
31420
|
+
...callerInfo && { caller: callerInfo }
|
|
31256
31421
|
};
|
|
31257
31422
|
controller.enqueue({
|
|
31258
31423
|
type: "tool-input-start",
|
|
@@ -31269,7 +31434,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31269
31434
|
input: "{}",
|
|
31270
31435
|
providerExecuted: true,
|
|
31271
31436
|
firstDelta: true,
|
|
31272
|
-
providerToolName: part.name
|
|
31437
|
+
providerToolName: part.name,
|
|
31438
|
+
...callerInfo && { caller: callerInfo }
|
|
31273
31439
|
};
|
|
31274
31440
|
controller.enqueue({
|
|
31275
31441
|
type: "tool-input-start",
|
|
@@ -31304,7 +31470,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31304
31470
|
data: part.content.content.source.data
|
|
31305
31471
|
}
|
|
31306
31472
|
}
|
|
31307
|
-
}
|
|
31473
|
+
},
|
|
31474
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
31308
31475
|
});
|
|
31309
31476
|
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
31310
31477
|
controller.enqueue({
|
|
@@ -31315,7 +31482,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31315
31482
|
result: {
|
|
31316
31483
|
type: "web_fetch_tool_result_error",
|
|
31317
31484
|
errorCode: part.content.error_code
|
|
31318
|
-
}
|
|
31485
|
+
},
|
|
31486
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
31319
31487
|
});
|
|
31320
31488
|
}
|
|
31321
31489
|
return;
|
|
@@ -31335,7 +31503,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31335
31503
|
encryptedContent: result.encrypted_content,
|
|
31336
31504
|
type: result.type
|
|
31337
31505
|
};
|
|
31338
|
-
})
|
|
31506
|
+
}),
|
|
31507
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
31339
31508
|
});
|
|
31340
31509
|
for (const result of part.content) {
|
|
31341
31510
|
controller.enqueue({
|
|
@@ -31360,7 +31529,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31360
31529
|
result: {
|
|
31361
31530
|
type: "web_search_tool_result_error",
|
|
31362
31531
|
errorCode: part.content.error_code
|
|
31363
|
-
}
|
|
31532
|
+
},
|
|
31533
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
31364
31534
|
});
|
|
31365
31535
|
}
|
|
31366
31536
|
return;
|
|
@@ -31738,11 +31908,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31738
31908
|
for (let contentIndex = 0;contentIndex < value.message.content.length; contentIndex++) {
|
|
31739
31909
|
const part = value.message.content[contentIndex];
|
|
31740
31910
|
if (part.type === "tool_use") {
|
|
31741
|
-
const
|
|
31742
|
-
const callerInfo = caller ? {
|
|
31743
|
-
type: caller.type,
|
|
31744
|
-
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
31745
|
-
} : undefined;
|
|
31911
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
31746
31912
|
controller.enqueue({
|
|
31747
31913
|
type: "tool-input-start",
|
|
31748
31914
|
id: part.id,
|
|
@@ -31902,59 +32068,59 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31902
32068
|
}, bash_20241022InputSchema, bash_20241022, bash_20250124InputSchema, bash_20250124, computer_20241022InputSchema, computer_20241022, computer_20250124InputSchema, computer_20250124, computer_20251124InputSchema, computer_20251124, memory_20250818InputSchema, memory_20250818, textEditor_20241022InputSchema, textEditor_20241022, textEditor_20250124InputSchema, textEditor_20250124, textEditor_20250429InputSchema, textEditor_20250429, toolSearchBm25_20251119OutputSchema, toolSearchBm25_20251119InputSchema, factory11, toolSearchBm25_20251119 = (args = {}) => {
|
|
31903
32069
|
return factory11(args);
|
|
31904
32070
|
}, anthropicTools, ANTHROPIC_API_URL = "https://api.anthropic.com", ANTHROPIC_API_VERSIONED_URL, anthropic;
|
|
31905
|
-
var
|
|
31906
|
-
|
|
31907
|
-
|
|
31908
|
-
|
|
31909
|
-
|
|
31910
|
-
|
|
32071
|
+
var init_dist5 = __esm(() => {
|
|
32072
|
+
init_dist2();
|
|
32073
|
+
init_dist4();
|
|
32074
|
+
init_dist2();
|
|
32075
|
+
init_dist4();
|
|
32076
|
+
init_dist4();
|
|
31911
32077
|
init_v4();
|
|
31912
|
-
|
|
32078
|
+
init_dist4();
|
|
31913
32079
|
init_v4();
|
|
31914
32080
|
init_v4();
|
|
31915
|
-
|
|
31916
|
-
|
|
32081
|
+
init_dist2();
|
|
32082
|
+
init_dist4();
|
|
31917
32083
|
init_v4();
|
|
31918
|
-
|
|
32084
|
+
init_dist4();
|
|
31919
32085
|
init_v4();
|
|
31920
|
-
|
|
32086
|
+
init_dist4();
|
|
31921
32087
|
init_v4();
|
|
31922
|
-
|
|
32088
|
+
init_dist4();
|
|
31923
32089
|
init_v4();
|
|
31924
|
-
|
|
32090
|
+
init_dist4();
|
|
31925
32091
|
init_v4();
|
|
31926
|
-
|
|
32092
|
+
init_dist4();
|
|
31927
32093
|
init_v4();
|
|
31928
|
-
|
|
31929
|
-
|
|
31930
|
-
|
|
31931
|
-
|
|
32094
|
+
init_dist4();
|
|
32095
|
+
init_dist2();
|
|
32096
|
+
init_dist4();
|
|
32097
|
+
init_dist4();
|
|
31932
32098
|
init_v4();
|
|
31933
|
-
|
|
32099
|
+
init_dist4();
|
|
31934
32100
|
init_v4();
|
|
31935
|
-
|
|
32101
|
+
init_dist4();
|
|
31936
32102
|
init_v4();
|
|
31937
|
-
|
|
32103
|
+
init_dist4();
|
|
31938
32104
|
init_v4();
|
|
31939
|
-
|
|
32105
|
+
init_dist4();
|
|
31940
32106
|
init_v4();
|
|
31941
|
-
|
|
32107
|
+
init_dist4();
|
|
31942
32108
|
init_v4();
|
|
31943
|
-
|
|
32109
|
+
init_dist4();
|
|
31944
32110
|
init_v4();
|
|
31945
|
-
|
|
32111
|
+
init_dist4();
|
|
31946
32112
|
init_v4();
|
|
31947
|
-
|
|
32113
|
+
init_dist4();
|
|
31948
32114
|
init_v4();
|
|
31949
|
-
|
|
32115
|
+
init_dist4();
|
|
31950
32116
|
init_v4();
|
|
31951
|
-
|
|
32117
|
+
init_dist4();
|
|
31952
32118
|
init_v4();
|
|
31953
|
-
|
|
32119
|
+
init_dist4();
|
|
31954
32120
|
init_v4();
|
|
31955
|
-
|
|
32121
|
+
init_dist4();
|
|
31956
32122
|
init_v4();
|
|
31957
|
-
|
|
32123
|
+
init_dist4();
|
|
31958
32124
|
init_v4();
|
|
31959
32125
|
anthropicErrorDataSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
31960
32126
|
type: exports_external2.literal("error"),
|
|
@@ -31973,6 +32139,19 @@ var init_dist4 = __esm(() => {
|
|
|
31973
32139
|
explanation: exports_external2.string().nullish(),
|
|
31974
32140
|
recommended_model: exports_external2.string().nullish()
|
|
31975
32141
|
});
|
|
32142
|
+
anthropicToolCallCallerSchema = exports_external2.union([
|
|
32143
|
+
exports_external2.object({
|
|
32144
|
+
type: exports_external2.literal("code_execution_20250825"),
|
|
32145
|
+
tool_id: exports_external2.string()
|
|
32146
|
+
}),
|
|
32147
|
+
exports_external2.object({
|
|
32148
|
+
type: exports_external2.literal("code_execution_20260120"),
|
|
32149
|
+
tool_id: exports_external2.string()
|
|
32150
|
+
}),
|
|
32151
|
+
exports_external2.object({
|
|
32152
|
+
type: exports_external2.literal("direct")
|
|
32153
|
+
})
|
|
32154
|
+
]);
|
|
31976
32155
|
anthropicMessagesResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
31977
32156
|
type: exports_external2.literal("message"),
|
|
31978
32157
|
id: exports_external2.string().nullish(),
|
|
@@ -32025,34 +32204,14 @@ var init_dist4 = __esm(() => {
|
|
|
32025
32204
|
id: exports_external2.string(),
|
|
32026
32205
|
name: exports_external2.string(),
|
|
32027
32206
|
input: exports_external2.unknown(),
|
|
32028
|
-
caller:
|
|
32029
|
-
exports_external2.object({
|
|
32030
|
-
type: exports_external2.literal("code_execution_20250825"),
|
|
32031
|
-
tool_id: exports_external2.string()
|
|
32032
|
-
}),
|
|
32033
|
-
exports_external2.object({
|
|
32034
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
32035
|
-
tool_id: exports_external2.string()
|
|
32036
|
-
}),
|
|
32037
|
-
exports_external2.object({
|
|
32038
|
-
type: exports_external2.literal("direct")
|
|
32039
|
-
})
|
|
32040
|
-
]).optional()
|
|
32207
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
32041
32208
|
}),
|
|
32042
32209
|
exports_external2.object({
|
|
32043
32210
|
type: exports_external2.literal("server_tool_use"),
|
|
32044
32211
|
id: exports_external2.string(),
|
|
32045
32212
|
name: exports_external2.string(),
|
|
32046
32213
|
input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).nullish(),
|
|
32047
|
-
caller:
|
|
32048
|
-
exports_external2.object({
|
|
32049
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
32050
|
-
tool_id: exports_external2.string()
|
|
32051
|
-
}),
|
|
32052
|
-
exports_external2.object({
|
|
32053
|
-
type: exports_external2.literal("direct")
|
|
32054
|
-
})
|
|
32055
|
-
]).optional()
|
|
32214
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
32056
32215
|
}),
|
|
32057
32216
|
exports_external2.object({
|
|
32058
32217
|
type: exports_external2.literal("mcp_tool_use"),
|
|
@@ -32073,6 +32232,7 @@ var init_dist4 = __esm(() => {
|
|
|
32073
32232
|
exports_external2.object({
|
|
32074
32233
|
type: exports_external2.literal("web_fetch_tool_result"),
|
|
32075
32234
|
tool_use_id: exports_external2.string(),
|
|
32235
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
32076
32236
|
content: exports_external2.union([
|
|
32077
32237
|
exports_external2.object({
|
|
32078
32238
|
type: exports_external2.literal("web_fetch_result"),
|
|
@@ -32105,6 +32265,7 @@ var init_dist4 = __esm(() => {
|
|
|
32105
32265
|
exports_external2.object({
|
|
32106
32266
|
type: exports_external2.literal("web_search_tool_result"),
|
|
32107
32267
|
tool_use_id: exports_external2.string(),
|
|
32268
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
32108
32269
|
content: exports_external2.union([
|
|
32109
32270
|
exports_external2.array(exports_external2.object({
|
|
32110
32271
|
type: exports_external2.literal("web_search_result"),
|
|
@@ -32308,19 +32469,7 @@ var init_dist4 = __esm(() => {
|
|
|
32308
32469
|
id: exports_external2.string(),
|
|
32309
32470
|
name: exports_external2.string(),
|
|
32310
32471
|
input: exports_external2.unknown(),
|
|
32311
|
-
caller:
|
|
32312
|
-
exports_external2.object({
|
|
32313
|
-
type: exports_external2.literal("code_execution_20250825"),
|
|
32314
|
-
tool_id: exports_external2.string()
|
|
32315
|
-
}),
|
|
32316
|
-
exports_external2.object({
|
|
32317
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
32318
|
-
tool_id: exports_external2.string()
|
|
32319
|
-
}),
|
|
32320
|
-
exports_external2.object({
|
|
32321
|
-
type: exports_external2.literal("direct")
|
|
32322
|
-
})
|
|
32323
|
-
]).optional()
|
|
32472
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
32324
32473
|
})
|
|
32325
32474
|
])).nullish(),
|
|
32326
32475
|
stop_reason: exports_external2.string().nullish(),
|
|
@@ -32347,19 +32496,7 @@ var init_dist4 = __esm(() => {
|
|
|
32347
32496
|
id: exports_external2.string(),
|
|
32348
32497
|
name: exports_external2.string(),
|
|
32349
32498
|
input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).optional(),
|
|
32350
|
-
caller:
|
|
32351
|
-
exports_external2.object({
|
|
32352
|
-
type: exports_external2.literal("code_execution_20250825"),
|
|
32353
|
-
tool_id: exports_external2.string()
|
|
32354
|
-
}),
|
|
32355
|
-
exports_external2.object({
|
|
32356
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
32357
|
-
tool_id: exports_external2.string()
|
|
32358
|
-
}),
|
|
32359
|
-
exports_external2.object({
|
|
32360
|
-
type: exports_external2.literal("direct")
|
|
32361
|
-
})
|
|
32362
|
-
]).optional()
|
|
32499
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
32363
32500
|
}),
|
|
32364
32501
|
exports_external2.object({
|
|
32365
32502
|
type: exports_external2.literal("redacted_thinking"),
|
|
@@ -32374,15 +32511,7 @@ var init_dist4 = __esm(() => {
|
|
|
32374
32511
|
id: exports_external2.string(),
|
|
32375
32512
|
name: exports_external2.string(),
|
|
32376
32513
|
input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).nullish(),
|
|
32377
|
-
caller:
|
|
32378
|
-
exports_external2.object({
|
|
32379
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
32380
|
-
tool_id: exports_external2.string()
|
|
32381
|
-
}),
|
|
32382
|
-
exports_external2.object({
|
|
32383
|
-
type: exports_external2.literal("direct")
|
|
32384
|
-
})
|
|
32385
|
-
]).optional()
|
|
32514
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
32386
32515
|
}),
|
|
32387
32516
|
exports_external2.object({
|
|
32388
32517
|
type: exports_external2.literal("mcp_tool_use"),
|
|
@@ -32403,6 +32532,7 @@ var init_dist4 = __esm(() => {
|
|
|
32403
32532
|
exports_external2.object({
|
|
32404
32533
|
type: exports_external2.literal("web_fetch_tool_result"),
|
|
32405
32534
|
tool_use_id: exports_external2.string(),
|
|
32535
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
32406
32536
|
content: exports_external2.union([
|
|
32407
32537
|
exports_external2.object({
|
|
32408
32538
|
type: exports_external2.literal("web_fetch_result"),
|
|
@@ -32435,6 +32565,7 @@ var init_dist4 = __esm(() => {
|
|
|
32435
32565
|
exports_external2.object({
|
|
32436
32566
|
type: exports_external2.literal("web_search_tool_result"),
|
|
32437
32567
|
tool_use_id: exports_external2.string(),
|
|
32568
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
32438
32569
|
content: exports_external2.union([
|
|
32439
32570
|
exports_external2.array(exports_external2.object({
|
|
32440
32571
|
type: exports_external2.literal("web_search_result"),
|
|
@@ -33474,7 +33605,7 @@ var init_dist4 = __esm(() => {
|
|
|
33474
33605
|
anthropic = createAnthropic();
|
|
33475
33606
|
});
|
|
33476
33607
|
|
|
33477
|
-
// ../../node_modules/.bun/@ai-sdk+openai@3.0.
|
|
33608
|
+
// ../../node_modules/.bun/@ai-sdk+openai@3.0.97+27912429049419a2/node_modules/@ai-sdk/openai/dist/index.mjs
|
|
33478
33609
|
var exports_dist2 = {};
|
|
33479
33610
|
__export(exports_dist2, {
|
|
33480
33611
|
openai: () => openai,
|
|
@@ -34411,12 +34542,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
34411
34542
|
if (store && id != null) {
|
|
34412
34543
|
input.push({ type: "item_reference", id });
|
|
34413
34544
|
}
|
|
34414
|
-
|
|
34545
|
+
if (store || !hasShellTool || resolvedToolName !== "shell") {
|
|
34546
|
+
break;
|
|
34547
|
+
}
|
|
34415
34548
|
}
|
|
34416
|
-
|
|
34549
|
+
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
|
|
34550
|
+
if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
|
|
34417
34551
|
break;
|
|
34418
34552
|
}
|
|
34419
|
-
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
|
|
34420
34553
|
if (store && id != null && isProviderDefinedToolCall) {
|
|
34421
34554
|
input.push({ type: "item_reference", id });
|
|
34422
34555
|
break;
|
|
@@ -34637,7 +34770,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
34637
34770
|
continue;
|
|
34638
34771
|
}
|
|
34639
34772
|
processedApprovalIds.add(approvalResponse.approvalId);
|
|
34640
|
-
if (store) {
|
|
34773
|
+
if (store && !hasConversation && !hasPreviousResponseId) {
|
|
34641
34774
|
input.push({
|
|
34642
34775
|
type: "item_reference",
|
|
34643
34776
|
id: approvalResponse.approvalId
|
|
@@ -35601,7 +35734,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
35601
35734
|
});
|
|
35602
35735
|
baseArgs.service_tier = undefined;
|
|
35603
35736
|
}
|
|
35604
|
-
if (openaiOptions.serviceTier === "priority" && !modelCapabilities.supportsPriorityProcessing) {
|
|
35737
|
+
if ((openaiOptions.serviceTier === "priority" || openaiOptions.serviceTier === "fast") && !modelCapabilities.supportsPriorityProcessing) {
|
|
35605
35738
|
warnings.push({
|
|
35606
35739
|
type: "unsupported",
|
|
35607
35740
|
feature: "serviceTier",
|
|
@@ -36611,7 +36744,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
36611
36744
|
});
|
|
36612
36745
|
delete baseArgs.service_tier;
|
|
36613
36746
|
}
|
|
36614
|
-
if ((openaiOptions == null ? undefined : openaiOptions.serviceTier) === "priority" && !modelCapabilities.supportsPriorityProcessing) {
|
|
36747
|
+
if (((openaiOptions == null ? undefined : openaiOptions.serviceTier) === "priority" || (openaiOptions == null ? undefined : openaiOptions.serviceTier) === "fast") && !modelCapabilities.supportsPriorityProcessing) {
|
|
36615
36748
|
warnings.push({
|
|
36616
36749
|
type: "unsupported",
|
|
36617
36750
|
feature: "serviceTier",
|
|
@@ -38191,78 +38324,78 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
38191
38324
|
}
|
|
38192
38325
|
};
|
|
38193
38326
|
}
|
|
38194
|
-
}, VERSION3 = "3.0.
|
|
38195
|
-
var
|
|
38196
|
-
|
|
38197
|
-
|
|
38198
|
-
|
|
38327
|
+
}, VERSION3 = "3.0.97", openai;
|
|
38328
|
+
var init_dist6 = __esm(() => {
|
|
38329
|
+
init_dist4();
|
|
38330
|
+
init_dist2();
|
|
38331
|
+
init_dist4();
|
|
38199
38332
|
init_v4();
|
|
38200
|
-
|
|
38201
|
-
|
|
38202
|
-
|
|
38203
|
-
|
|
38204
|
-
|
|
38333
|
+
init_dist4();
|
|
38334
|
+
init_dist2();
|
|
38335
|
+
init_dist2();
|
|
38336
|
+
init_dist4();
|
|
38337
|
+
init_dist4();
|
|
38205
38338
|
init_v4();
|
|
38206
|
-
|
|
38339
|
+
init_dist4();
|
|
38207
38340
|
init_v4();
|
|
38208
|
-
|
|
38209
|
-
|
|
38210
|
-
|
|
38341
|
+
init_dist2();
|
|
38342
|
+
init_dist4();
|
|
38343
|
+
init_dist2();
|
|
38211
38344
|
init_v4();
|
|
38212
|
-
|
|
38213
|
-
|
|
38345
|
+
init_dist4();
|
|
38346
|
+
init_dist4();
|
|
38214
38347
|
init_v4();
|
|
38215
|
-
|
|
38216
|
-
|
|
38217
|
-
|
|
38348
|
+
init_dist2();
|
|
38349
|
+
init_dist4();
|
|
38350
|
+
init_dist4();
|
|
38218
38351
|
init_v4();
|
|
38219
|
-
|
|
38352
|
+
init_dist4();
|
|
38220
38353
|
init_v4();
|
|
38221
|
-
|
|
38222
|
-
|
|
38354
|
+
init_dist4();
|
|
38355
|
+
init_dist4();
|
|
38223
38356
|
init_v4();
|
|
38224
|
-
|
|
38357
|
+
init_dist4();
|
|
38225
38358
|
init_v4();
|
|
38226
|
-
|
|
38359
|
+
init_dist4();
|
|
38227
38360
|
init_v4();
|
|
38228
|
-
|
|
38361
|
+
init_dist4();
|
|
38229
38362
|
init_v4();
|
|
38230
|
-
|
|
38363
|
+
init_dist4();
|
|
38231
38364
|
init_v4();
|
|
38232
|
-
|
|
38365
|
+
init_dist4();
|
|
38233
38366
|
init_v4();
|
|
38234
|
-
|
|
38367
|
+
init_dist4();
|
|
38235
38368
|
init_v4();
|
|
38236
|
-
|
|
38369
|
+
init_dist4();
|
|
38237
38370
|
init_v4();
|
|
38238
|
-
|
|
38371
|
+
init_dist4();
|
|
38239
38372
|
init_v4();
|
|
38240
|
-
|
|
38373
|
+
init_dist4();
|
|
38241
38374
|
init_v4();
|
|
38242
|
-
|
|
38375
|
+
init_dist4();
|
|
38243
38376
|
init_v4();
|
|
38244
|
-
|
|
38377
|
+
init_dist4();
|
|
38245
38378
|
init_v4();
|
|
38246
|
-
|
|
38379
|
+
init_dist4();
|
|
38247
38380
|
init_v4();
|
|
38248
|
-
|
|
38249
|
-
|
|
38250
|
-
|
|
38251
|
-
|
|
38381
|
+
init_dist2();
|
|
38382
|
+
init_dist4();
|
|
38383
|
+
init_dist2();
|
|
38384
|
+
init_dist4();
|
|
38252
38385
|
init_v4();
|
|
38253
|
-
|
|
38386
|
+
init_dist4();
|
|
38254
38387
|
init_v4();
|
|
38255
|
-
|
|
38388
|
+
init_dist4();
|
|
38256
38389
|
init_v4();
|
|
38257
|
-
|
|
38258
|
-
|
|
38259
|
-
|
|
38260
|
-
|
|
38390
|
+
init_dist2();
|
|
38391
|
+
init_dist4();
|
|
38392
|
+
init_dist4();
|
|
38393
|
+
init_dist4();
|
|
38261
38394
|
init_v4();
|
|
38262
|
-
|
|
38263
|
-
|
|
38395
|
+
init_dist4();
|
|
38396
|
+
init_dist4();
|
|
38264
38397
|
init_v4();
|
|
38265
|
-
|
|
38398
|
+
init_dist4();
|
|
38266
38399
|
init_v4();
|
|
38267
38400
|
openaiErrorDataSchema = exports_external2.object({
|
|
38268
38401
|
error: exports_external2.object({
|
|
@@ -38398,7 +38531,7 @@ var init_dist5 = __esm(() => {
|
|
|
38398
38531
|
store: exports_external2.boolean().optional(),
|
|
38399
38532
|
metadata: exports_external2.record(exports_external2.string().max(64), exports_external2.string().max(512)).optional(),
|
|
38400
38533
|
prediction: exports_external2.record(exports_external2.string(), exports_external2.any()).optional(),
|
|
38401
|
-
serviceTier: exports_external2.enum(["auto", "flex", "priority", "default"]).optional(),
|
|
38534
|
+
serviceTier: exports_external2.enum(["auto", "flex", "priority", "fast", "default"]).optional(),
|
|
38402
38535
|
strictJsonSchema: exports_external2.boolean().optional(),
|
|
38403
38536
|
textVerbosity: exports_external2.enum(["low", "medium", "high"]).optional(),
|
|
38404
38537
|
promptCacheKey: exports_external2.string().optional(),
|
|
@@ -39810,7 +39943,7 @@ var init_dist5 = __esm(() => {
|
|
|
39810
39943
|
reasoningContext: exports_external2.enum(["auto", "current_turn", "all_turns"]).optional(),
|
|
39811
39944
|
reasoningSummary: exports_external2.string().nullish(),
|
|
39812
39945
|
safetyIdentifier: exports_external2.string().nullish(),
|
|
39813
|
-
serviceTier: exports_external2.enum(["auto", "flex", "priority", "default"]).nullish(),
|
|
39946
|
+
serviceTier: exports_external2.enum(["auto", "flex", "priority", "fast", "default"]).nullish(),
|
|
39814
39947
|
store: exports_external2.boolean().nullish(),
|
|
39815
39948
|
passThroughUnsupportedFiles: exports_external2.boolean().optional(),
|
|
39816
39949
|
strictJsonSchema: exports_external2.boolean().nullish(),
|
|
@@ -39919,7 +40052,7 @@ var init_dist5 = __esm(() => {
|
|
|
39919
40052
|
openai = createOpenAI();
|
|
39920
40053
|
});
|
|
39921
40054
|
|
|
39922
|
-
// ../../node_modules/.bun/@ai-sdk+openai-compatible@2.0.
|
|
40055
|
+
// ../../node_modules/.bun/@ai-sdk+openai-compatible@2.0.69+27912429049419a2/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
|
|
39923
40056
|
var exports_dist3 = {};
|
|
39924
40057
|
__export(exports_dist3, {
|
|
39925
40058
|
createOpenAICompatible: () => createOpenAICompatible,
|
|
@@ -39970,7 +40103,7 @@ function convertOpenAICompatibleChatUsage(usage) {
|
|
|
39970
40103
|
},
|
|
39971
40104
|
outputTokens: {
|
|
39972
40105
|
total: completionTokens,
|
|
39973
|
-
text: completionTokens - reasoningTokens,
|
|
40106
|
+
text: Math.max(0, completionTokens - reasoningTokens),
|
|
39974
40107
|
reasoning: reasoningTokens
|
|
39975
40108
|
},
|
|
39976
40109
|
raw: usage
|
|
@@ -41344,27 +41477,27 @@ var openaiCompatibleErrorDataSchema, defaultOpenAICompatibleErrorStructure, open
|
|
|
41344
41477
|
}
|
|
41345
41478
|
};
|
|
41346
41479
|
}
|
|
41347
|
-
}, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.
|
|
41348
|
-
var
|
|
41349
|
-
|
|
41350
|
-
|
|
41480
|
+
}, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.69";
|
|
41481
|
+
var init_dist7 = __esm(() => {
|
|
41482
|
+
init_dist2();
|
|
41483
|
+
init_dist4();
|
|
41351
41484
|
init_v4();
|
|
41352
41485
|
init_v4();
|
|
41353
|
-
|
|
41354
|
-
|
|
41486
|
+
init_dist2();
|
|
41487
|
+
init_dist4();
|
|
41355
41488
|
init_v4();
|
|
41356
|
-
|
|
41357
|
-
|
|
41489
|
+
init_dist2();
|
|
41490
|
+
init_dist4();
|
|
41358
41491
|
init_v4();
|
|
41359
|
-
|
|
41492
|
+
init_dist2();
|
|
41360
41493
|
init_v4();
|
|
41361
|
-
|
|
41362
|
-
|
|
41494
|
+
init_dist2();
|
|
41495
|
+
init_dist4();
|
|
41363
41496
|
init_v4();
|
|
41364
41497
|
init_v4();
|
|
41365
|
-
|
|
41498
|
+
init_dist4();
|
|
41366
41499
|
init_v4();
|
|
41367
|
-
|
|
41500
|
+
init_dist4();
|
|
41368
41501
|
openaiCompatibleErrorDataSchema = exports_external2.object({
|
|
41369
41502
|
error: exports_external2.object({
|
|
41370
41503
|
message: exports_external2.string(),
|
|
@@ -41387,10 +41520,10 @@ var init_dist6 = __esm(() => {
|
|
|
41387
41520
|
prompt_tokens: exports_external2.number().nullish(),
|
|
41388
41521
|
completion_tokens: exports_external2.number().nullish(),
|
|
41389
41522
|
total_tokens: exports_external2.number().nullish(),
|
|
41390
|
-
prompt_tokens_details: exports_external2.
|
|
41523
|
+
prompt_tokens_details: exports_external2.looseObject({
|
|
41391
41524
|
cached_tokens: exports_external2.number().nullish()
|
|
41392
41525
|
}).nullish(),
|
|
41393
|
-
completion_tokens_details: exports_external2.
|
|
41526
|
+
completion_tokens_details: exports_external2.looseObject({
|
|
41394
41527
|
reasoning_tokens: exports_external2.number().nullish(),
|
|
41395
41528
|
accepted_prediction_tokens: exports_external2.number().nullish(),
|
|
41396
41529
|
rejected_prediction_tokens: exports_external2.number().nullish()
|
|
@@ -41457,7 +41590,7 @@ var init_dist6 = __esm(() => {
|
|
|
41457
41590
|
suffix: exports_external2.string().optional(),
|
|
41458
41591
|
user: exports_external2.string().optional()
|
|
41459
41592
|
});
|
|
41460
|
-
usageSchema = exports_external2.
|
|
41593
|
+
usageSchema = exports_external2.looseObject({
|
|
41461
41594
|
prompt_tokens: exports_external2.number(),
|
|
41462
41595
|
completion_tokens: exports_external2.number(),
|
|
41463
41596
|
total_tokens: exports_external2.number()
|
|
@@ -41586,19 +41719,19 @@ var require_token_io = __commonJS((exports, module) => {
|
|
|
41586
41719
|
getUserDataDir: () => getUserDataDir
|
|
41587
41720
|
});
|
|
41588
41721
|
module.exports = __toCommonJS2(token_io_exports);
|
|
41589
|
-
var
|
|
41722
|
+
var import_path3 = __toESM2(__require("path"));
|
|
41590
41723
|
var import_fs2 = __toESM2(__require("fs"));
|
|
41591
|
-
var
|
|
41724
|
+
var import_os3 = __toESM2(__require("os"));
|
|
41592
41725
|
var import_token_error = require_token_error();
|
|
41593
41726
|
function findRootDir() {
|
|
41594
41727
|
try {
|
|
41595
41728
|
let dir = process.cwd();
|
|
41596
|
-
while (dir !==
|
|
41597
|
-
const pkgPath =
|
|
41729
|
+
while (dir !== import_path3.default.dirname(dir)) {
|
|
41730
|
+
const pkgPath = import_path3.default.join(dir, ".vercel");
|
|
41598
41731
|
if (import_fs2.default.existsSync(pkgPath)) {
|
|
41599
41732
|
return dir;
|
|
41600
41733
|
}
|
|
41601
|
-
dir =
|
|
41734
|
+
dir = import_path3.default.dirname(dir);
|
|
41602
41735
|
}
|
|
41603
41736
|
} catch (e) {
|
|
41604
41737
|
throw new import_token_error.VercelOidcTokenError("Token refresh only supported in node server environments");
|
|
@@ -41609,11 +41742,11 @@ var require_token_io = __commonJS((exports, module) => {
|
|
|
41609
41742
|
if (process.env.XDG_DATA_HOME) {
|
|
41610
41743
|
return process.env.XDG_DATA_HOME;
|
|
41611
41744
|
}
|
|
41612
|
-
switch (
|
|
41745
|
+
switch (import_os3.default.platform()) {
|
|
41613
41746
|
case "darwin":
|
|
41614
|
-
return
|
|
41747
|
+
return import_path3.default.join(import_os3.default.homedir(), "Library/Application Support");
|
|
41615
41748
|
case "linux":
|
|
41616
|
-
return
|
|
41749
|
+
return import_path3.default.join(import_os3.default.homedir(), ".local/share");
|
|
41617
41750
|
case "win32":
|
|
41618
41751
|
if (process.env.LOCALAPPDATA) {
|
|
41619
41752
|
return process.env.LOCALAPPDATA;
|
|
@@ -41658,11 +41791,11 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
41658
41791
|
var path = __toESM2(__require("path"));
|
|
41659
41792
|
var import_token_util = require_token_util();
|
|
41660
41793
|
function getAuthConfigPath() {
|
|
41661
|
-
const
|
|
41662
|
-
if (!
|
|
41794
|
+
const dataDir2 = (0, import_token_util.getVercelDataDir)();
|
|
41795
|
+
if (!dataDir2) {
|
|
41663
41796
|
throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);
|
|
41664
41797
|
}
|
|
41665
|
-
return path.join(
|
|
41798
|
+
return path.join(dataDir2, "auth.json");
|
|
41666
41799
|
}
|
|
41667
41800
|
function readAuthConfig() {
|
|
41668
41801
|
try {
|
|
@@ -41723,10 +41856,10 @@ var require_oauth = __commonJS((exports, module) => {
|
|
|
41723
41856
|
refreshTokenRequest: () => refreshTokenRequest
|
|
41724
41857
|
});
|
|
41725
41858
|
module.exports = __toCommonJS2(oauth_exports);
|
|
41726
|
-
var
|
|
41859
|
+
var import_os3 = __require("os");
|
|
41727
41860
|
var VERCEL_ISSUER = "https://vercel.com";
|
|
41728
41861
|
var VERCEL_CLI_CLIENT_ID = "cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp";
|
|
41729
|
-
var userAgent = `@vercel/oidc node-${process.version} ${(0,
|
|
41862
|
+
var userAgent = `@vercel/oidc node-${process.version} ${(0, import_os3.platform)()} (${(0, import_os3.arch)()}) ${(0, import_os3.hostname)()}`;
|
|
41730
41863
|
var _tokenEndpoint = null;
|
|
41731
41864
|
async function getTokenEndpoint() {
|
|
41732
41865
|
if (_tokenEndpoint) {
|
|
@@ -41869,11 +42002,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
41869
42002
|
var import_auth_errors = require_auth_errors();
|
|
41870
42003
|
function getVercelDataDir() {
|
|
41871
42004
|
const vercelFolder = "com.vercel.cli";
|
|
41872
|
-
const
|
|
41873
|
-
if (!
|
|
42005
|
+
const dataDir2 = (0, import_token_io.getUserDataDir)();
|
|
42006
|
+
if (!dataDir2) {
|
|
41874
42007
|
return null;
|
|
41875
42008
|
}
|
|
41876
|
-
return path.join(
|
|
42009
|
+
return path.join(dataDir2, vercelFolder);
|
|
41877
42010
|
}
|
|
41878
42011
|
async function getVercelToken2(options) {
|
|
41879
42012
|
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
@@ -42148,7 +42281,7 @@ var require_dist = __commonJS((exports, module) => {
|
|
|
42148
42281
|
var import_token_util = require_token_util();
|
|
42149
42282
|
});
|
|
42150
42283
|
|
|
42151
|
-
// ../../node_modules/.bun/@ai-sdk+gateway@3.0.
|
|
42284
|
+
// ../../node_modules/.bun/@ai-sdk+gateway@3.0.175+27912429049419a2/node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
42152
42285
|
async function createGatewayErrorFromResponse({
|
|
42153
42286
|
response,
|
|
42154
42287
|
statusCode,
|
|
@@ -42555,11 +42688,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42555
42688
|
try {
|
|
42556
42689
|
const { value } = await getFromApi({
|
|
42557
42690
|
url: `${this.config.baseURL}/config`,
|
|
42558
|
-
headers: await
|
|
42691
|
+
headers: await resolve6(this.config.headers()),
|
|
42559
42692
|
successfulResponseHandler: createJsonResponseHandler(gatewayAvailableModelsResponseSchema),
|
|
42560
42693
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42561
42694
|
errorSchema: exports_external2.any(),
|
|
42562
|
-
errorToMessage: (data) =>
|
|
42695
|
+
errorToMessage: (data) => {
|
|
42696
|
+
var _a112;
|
|
42697
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
42698
|
+
}
|
|
42563
42699
|
}),
|
|
42564
42700
|
fetch: this.config.fetch
|
|
42565
42701
|
});
|
|
@@ -42573,11 +42709,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42573
42709
|
const baseUrl = new URL(this.config.baseURL);
|
|
42574
42710
|
const { value } = await getFromApi({
|
|
42575
42711
|
url: `${baseUrl.origin}/v1/credits`,
|
|
42576
|
-
headers: await
|
|
42712
|
+
headers: await resolve6(this.config.headers()),
|
|
42577
42713
|
successfulResponseHandler: createJsonResponseHandler(gatewayCreditsResponseSchema),
|
|
42578
42714
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42579
42715
|
errorSchema: exports_external2.any(),
|
|
42580
|
-
errorToMessage: (data) =>
|
|
42716
|
+
errorToMessage: (data) => {
|
|
42717
|
+
var _a112;
|
|
42718
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
42719
|
+
}
|
|
42581
42720
|
}),
|
|
42582
42721
|
fetch: this.config.fetch
|
|
42583
42722
|
});
|
|
@@ -42619,11 +42758,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42619
42758
|
}
|
|
42620
42759
|
const { value } = await getFromApi({
|
|
42621
42760
|
url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
|
|
42622
|
-
headers: await
|
|
42761
|
+
headers: await resolve6(this.config.headers()),
|
|
42623
42762
|
successfulResponseHandler: createJsonResponseHandler(gatewaySpendReportResponseSchema),
|
|
42624
42763
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42625
42764
|
errorSchema: exports_external2.any(),
|
|
42626
|
-
errorToMessage: (data) =>
|
|
42765
|
+
errorToMessage: (data) => {
|
|
42766
|
+
var _a112;
|
|
42767
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
42768
|
+
}
|
|
42627
42769
|
}),
|
|
42628
42770
|
fetch: this.config.fetch
|
|
42629
42771
|
});
|
|
@@ -42641,11 +42783,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42641
42783
|
const baseUrl = new URL(this.config.baseURL);
|
|
42642
42784
|
const { value } = await getFromApi({
|
|
42643
42785
|
url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
|
|
42644
|
-
headers: await
|
|
42786
|
+
headers: await resolve6(this.config.headers()),
|
|
42645
42787
|
successfulResponseHandler: createJsonResponseHandler(gatewayGenerationInfoResponseSchema),
|
|
42646
42788
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42647
42789
|
errorSchema: exports_external2.any(),
|
|
42648
|
-
errorToMessage: (data) =>
|
|
42790
|
+
errorToMessage: (data) => {
|
|
42791
|
+
var _a112;
|
|
42792
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
42793
|
+
}
|
|
42649
42794
|
}),
|
|
42650
42795
|
fetch: this.config.fetch
|
|
42651
42796
|
});
|
|
@@ -42674,7 +42819,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42674
42819
|
async doGenerate(options) {
|
|
42675
42820
|
const { args, warnings } = await this.getArgs(options);
|
|
42676
42821
|
const { abortSignal } = options;
|
|
42677
|
-
const resolvedHeaders = await
|
|
42822
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
42678
42823
|
try {
|
|
42679
42824
|
const {
|
|
42680
42825
|
responseHeaders,
|
|
@@ -42682,12 +42827,15 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42682
42827
|
rawValue: rawResponse
|
|
42683
42828
|
} = await postJsonToApi({
|
|
42684
42829
|
url: this.getUrl(),
|
|
42685
|
-
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await
|
|
42830
|
+
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await resolve6(this.config.o11yHeaders)),
|
|
42686
42831
|
body: args,
|
|
42687
42832
|
successfulResponseHandler: createJsonResponseHandler(exports_external2.any()),
|
|
42688
42833
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42689
42834
|
errorSchema: exports_external2.any(),
|
|
42690
|
-
errorToMessage: (data) =>
|
|
42835
|
+
errorToMessage: (data) => {
|
|
42836
|
+
var _a112;
|
|
42837
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
42838
|
+
}
|
|
42691
42839
|
}),
|
|
42692
42840
|
...abortSignal && { abortSignal },
|
|
42693
42841
|
fetch: this.config.fetch
|
|
@@ -42705,16 +42853,19 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42705
42853
|
async doStream(options) {
|
|
42706
42854
|
const { args, warnings } = await this.getArgs(options);
|
|
42707
42855
|
const { abortSignal } = options;
|
|
42708
|
-
const resolvedHeaders = await
|
|
42856
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
42709
42857
|
try {
|
|
42710
42858
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
42711
42859
|
url: this.getUrl(),
|
|
42712
|
-
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await
|
|
42860
|
+
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await resolve6(this.config.o11yHeaders)),
|
|
42713
42861
|
body: args,
|
|
42714
42862
|
successfulResponseHandler: createEventSourceResponseHandler(exports_external2.any()),
|
|
42715
42863
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42716
42864
|
errorSchema: exports_external2.any(),
|
|
42717
|
-
errorToMessage: (data) =>
|
|
42865
|
+
errorToMessage: (data) => {
|
|
42866
|
+
var _a112;
|
|
42867
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
42868
|
+
}
|
|
42718
42869
|
}),
|
|
42719
42870
|
...abortSignal && { abortSignal },
|
|
42720
42871
|
fetch: this.config.fetch
|
|
@@ -42794,7 +42945,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42794
42945
|
providerOptions
|
|
42795
42946
|
}) {
|
|
42796
42947
|
var _a112, _b112;
|
|
42797
|
-
const resolvedHeaders = await
|
|
42948
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
42798
42949
|
try {
|
|
42799
42950
|
const {
|
|
42800
42951
|
responseHeaders,
|
|
@@ -42802,7 +42953,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42802
42953
|
rawValue
|
|
42803
42954
|
} = await postJsonToApi({
|
|
42804
42955
|
url: this.getUrl(),
|
|
42805
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
42956
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve6(this.config.o11yHeaders)),
|
|
42806
42957
|
body: {
|
|
42807
42958
|
values,
|
|
42808
42959
|
...providerOptions ? { providerOptions } : {}
|
|
@@ -42810,7 +42961,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42810
42961
|
successfulResponseHandler: createJsonResponseHandler(gatewayEmbeddingResponseSchema),
|
|
42811
42962
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42812
42963
|
errorSchema: exports_external2.any(),
|
|
42813
|
-
errorToMessage: (data) =>
|
|
42964
|
+
errorToMessage: (data) => {
|
|
42965
|
+
var _a122;
|
|
42966
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
42967
|
+
}
|
|
42814
42968
|
}),
|
|
42815
42969
|
...abortSignal && { abortSignal },
|
|
42816
42970
|
fetch: this.config.fetch
|
|
@@ -42858,7 +43012,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42858
43012
|
abortSignal
|
|
42859
43013
|
}) {
|
|
42860
43014
|
var _a112, _b112, _c;
|
|
42861
|
-
const resolvedHeaders = await
|
|
43015
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
42862
43016
|
try {
|
|
42863
43017
|
const {
|
|
42864
43018
|
responseHeaders,
|
|
@@ -42866,7 +43020,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42866
43020
|
rawValue
|
|
42867
43021
|
} = await postJsonToApi({
|
|
42868
43022
|
url: this.getUrl(),
|
|
42869
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
43023
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve6(this.config.o11yHeaders)),
|
|
42870
43024
|
body: {
|
|
42871
43025
|
prompt,
|
|
42872
43026
|
n,
|
|
@@ -42882,7 +43036,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42882
43036
|
successfulResponseHandler: createJsonResponseHandler(gatewayImageResponseSchema),
|
|
42883
43037
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42884
43038
|
errorSchema: exports_external2.any(),
|
|
42885
|
-
errorToMessage: (data) =>
|
|
43039
|
+
errorToMessage: (data) => {
|
|
43040
|
+
var _a122;
|
|
43041
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
43042
|
+
}
|
|
42886
43043
|
}),
|
|
42887
43044
|
...abortSignal && { abortSignal },
|
|
42888
43045
|
fetch: this.config.fetch
|
|
@@ -42943,11 +43100,11 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42943
43100
|
headers,
|
|
42944
43101
|
abortSignal
|
|
42945
43102
|
}) {
|
|
42946
|
-
const resolvedHeaders = await
|
|
43103
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
42947
43104
|
try {
|
|
42948
43105
|
const { responseHeaders, value: responseBody } = await postJsonToApi({
|
|
42949
43106
|
url: this.getUrl(),
|
|
42950
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
43107
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve6(this.config.o11yHeaders), { accept: "text/event-stream" }),
|
|
42951
43108
|
body: {
|
|
42952
43109
|
prompt,
|
|
42953
43110
|
n,
|
|
@@ -43035,7 +43192,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43035
43192
|
},
|
|
43036
43193
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
43037
43194
|
errorSchema: exports_external2.any(),
|
|
43038
|
-
errorToMessage: (data) =>
|
|
43195
|
+
errorToMessage: (data) => {
|
|
43196
|
+
var _a112;
|
|
43197
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
43198
|
+
}
|
|
43039
43199
|
}),
|
|
43040
43200
|
...abortSignal && { abortSignal },
|
|
43041
43201
|
fetch: this.config.fetch
|
|
@@ -43081,7 +43241,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43081
43241
|
providerOptions
|
|
43082
43242
|
}) {
|
|
43083
43243
|
var _a112;
|
|
43084
|
-
const resolvedHeaders = await
|
|
43244
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
43085
43245
|
try {
|
|
43086
43246
|
const {
|
|
43087
43247
|
responseHeaders,
|
|
@@ -43089,7 +43249,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43089
43249
|
rawValue
|
|
43090
43250
|
} = await postJsonToApi({
|
|
43091
43251
|
url: this.getUrl(),
|
|
43092
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
43252
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve6(this.config.o11yHeaders)),
|
|
43093
43253
|
body: {
|
|
43094
43254
|
documents,
|
|
43095
43255
|
query,
|
|
@@ -43099,7 +43259,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43099
43259
|
successfulResponseHandler: createJsonResponseHandler(gatewayRerankingResponseSchema),
|
|
43100
43260
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
43101
43261
|
errorSchema: exports_external2.any(),
|
|
43102
|
-
errorToMessage: (data) =>
|
|
43262
|
+
errorToMessage: (data) => {
|
|
43263
|
+
var _a122;
|
|
43264
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
43265
|
+
}
|
|
43103
43266
|
}),
|
|
43104
43267
|
...abortSignal && { abortSignal },
|
|
43105
43268
|
fetch: this.config.fetch
|
|
@@ -43143,7 +43306,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43143
43306
|
headers,
|
|
43144
43307
|
abortSignal
|
|
43145
43308
|
}) {
|
|
43146
|
-
const resolvedHeaders = await
|
|
43309
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
43147
43310
|
try {
|
|
43148
43311
|
const {
|
|
43149
43312
|
responseHeaders,
|
|
@@ -43151,7 +43314,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43151
43314
|
rawValue
|
|
43152
43315
|
} = await postJsonToApi({
|
|
43153
43316
|
url: this.getUrl(),
|
|
43154
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
43317
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve6(this.config.o11yHeaders)),
|
|
43155
43318
|
body: {
|
|
43156
43319
|
text: text2,
|
|
43157
43320
|
...voice && { voice },
|
|
@@ -43164,7 +43327,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43164
43327
|
successfulResponseHandler: createJsonResponseHandler(gatewaySpeechResponseSchema),
|
|
43165
43328
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
43166
43329
|
errorSchema: exports_external2.any(),
|
|
43167
|
-
errorToMessage: (data) =>
|
|
43330
|
+
errorToMessage: (data) => {
|
|
43331
|
+
var _a112;
|
|
43332
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
43333
|
+
}
|
|
43168
43334
|
}),
|
|
43169
43335
|
...abortSignal && { abortSignal },
|
|
43170
43336
|
fetch: this.config.fetch
|
|
@@ -43210,7 +43376,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43210
43376
|
abortSignal
|
|
43211
43377
|
}) {
|
|
43212
43378
|
var _a112, _b112, _c;
|
|
43213
|
-
const resolvedHeaders = await
|
|
43379
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
43214
43380
|
try {
|
|
43215
43381
|
const {
|
|
43216
43382
|
responseHeaders,
|
|
@@ -43218,7 +43384,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43218
43384
|
rawValue
|
|
43219
43385
|
} = await postJsonToApi({
|
|
43220
43386
|
url: this.getUrl(),
|
|
43221
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
43387
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve6(this.config.o11yHeaders)),
|
|
43222
43388
|
body: {
|
|
43223
43389
|
audio: audio instanceof Uint8Array ? convertUint8ArrayToBase64(audio) : audio,
|
|
43224
43390
|
mediaType,
|
|
@@ -43227,7 +43393,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43227
43393
|
successfulResponseHandler: createJsonResponseHandler(gatewayTranscriptionResponseSchema),
|
|
43228
43394
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
43229
43395
|
errorSchema: exports_external2.any(),
|
|
43230
|
-
errorToMessage: (data) =>
|
|
43396
|
+
errorToMessage: (data) => {
|
|
43397
|
+
var _a122;
|
|
43398
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
43399
|
+
}
|
|
43231
43400
|
}),
|
|
43232
43401
|
...abortSignal && { abortSignal },
|
|
43233
43402
|
fetch: this.config.fetch
|
|
@@ -43259,45 +43428,45 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43259
43428
|
"ai-model-id": this.modelId
|
|
43260
43429
|
};
|
|
43261
43430
|
}
|
|
43262
|
-
}, providerMetadataEntrySchema4, gatewayTranscriptionWarningSchema, gatewayTranscriptionResponseSchema, exaSearchInputSchema, exaSearchOutputSchema, exaSearchToolFactory, exaSearch = (config2 = {}) => exaSearchToolFactory(config2), parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION5 = "3.0.
|
|
43263
|
-
var
|
|
43264
|
-
|
|
43265
|
-
|
|
43431
|
+
}, providerMetadataEntrySchema4, gatewayTranscriptionWarningSchema, gatewayTranscriptionResponseSchema, exaSearchInputSchema, exaSearchOutputSchema, exaSearchToolFactory, exaSearch = (config2 = {}) => exaSearchToolFactory(config2), parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION5 = "3.0.175", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
|
|
43432
|
+
var init_dist8 = __esm(() => {
|
|
43433
|
+
init_dist4();
|
|
43434
|
+
init_dist2();
|
|
43266
43435
|
init_v4();
|
|
43267
43436
|
init_v4();
|
|
43268
|
-
|
|
43437
|
+
init_dist4();
|
|
43269
43438
|
init_v4();
|
|
43270
|
-
|
|
43271
|
-
|
|
43272
|
-
|
|
43439
|
+
init_dist4();
|
|
43440
|
+
init_dist4();
|
|
43441
|
+
init_dist4();
|
|
43273
43442
|
init_v4();
|
|
43274
|
-
|
|
43275
|
-
|
|
43443
|
+
init_dist4();
|
|
43444
|
+
init_dist4();
|
|
43276
43445
|
init_v4();
|
|
43277
|
-
|
|
43446
|
+
init_dist4();
|
|
43278
43447
|
init_v4();
|
|
43279
|
-
|
|
43448
|
+
init_dist4();
|
|
43280
43449
|
init_v4();
|
|
43281
|
-
|
|
43450
|
+
init_dist4();
|
|
43282
43451
|
init_v4();
|
|
43283
|
-
|
|
43452
|
+
init_dist4();
|
|
43284
43453
|
init_v4();
|
|
43285
|
-
|
|
43454
|
+
init_dist4();
|
|
43286
43455
|
init_v4();
|
|
43287
|
-
|
|
43288
|
-
|
|
43456
|
+
init_dist2();
|
|
43457
|
+
init_dist4();
|
|
43289
43458
|
init_v4();
|
|
43290
|
-
|
|
43459
|
+
init_dist4();
|
|
43291
43460
|
init_v4();
|
|
43292
|
-
|
|
43461
|
+
init_dist4();
|
|
43293
43462
|
init_v4();
|
|
43294
|
-
|
|
43463
|
+
init_dist4();
|
|
43295
43464
|
init_v4();
|
|
43296
|
-
|
|
43465
|
+
init_dist4();
|
|
43297
43466
|
init_zod();
|
|
43298
|
-
|
|
43467
|
+
init_dist4();
|
|
43299
43468
|
init_zod();
|
|
43300
|
-
|
|
43469
|
+
init_dist4();
|
|
43301
43470
|
init_zod();
|
|
43302
43471
|
import_oidc = __toESM(require_dist(), 1);
|
|
43303
43472
|
import_oidc2 = __toESM(require_dist(), 1);
|
|
@@ -45200,7 +45369,7 @@ var require_tracestate_impl = __commonJS((exports) => {
|
|
|
45200
45369
|
const value = listMember.slice(i + 1, part.length);
|
|
45201
45370
|
if ((0, tracestate_validators_1.validateKey)(key) && (0, tracestate_validators_1.validateValue)(value)) {
|
|
45202
45371
|
agg.set(key, value);
|
|
45203
|
-
}
|
|
45372
|
+
}
|
|
45204
45373
|
}
|
|
45205
45374
|
return agg;
|
|
45206
45375
|
}, new Map);
|
|
@@ -45575,7 +45744,7 @@ var require_src = __commonJS((exports) => {
|
|
|
45575
45744
|
};
|
|
45576
45745
|
});
|
|
45577
45746
|
|
|
45578
|
-
// ../../node_modules/.bun/ai@6.0.
|
|
45747
|
+
// ../../node_modules/.bun/ai@6.0.257+27912429049419a2/node_modules/ai/dist/index.mjs
|
|
45579
45748
|
var exports_dist4 = {};
|
|
45580
45749
|
__export(exports_dist4, {
|
|
45581
45750
|
zodSchema: () => zodSchema,
|
|
@@ -46860,7 +47029,8 @@ async function recordSpan({
|
|
|
46860
47029
|
tracer,
|
|
46861
47030
|
attributes,
|
|
46862
47031
|
fn,
|
|
46863
|
-
endWhenDone = true
|
|
47032
|
+
endWhenDone = true,
|
|
47033
|
+
endOnError = endWhenDone
|
|
46864
47034
|
}) {
|
|
46865
47035
|
return tracer.startActiveSpan(name222, { attributes: await attributes }, async (span) => {
|
|
46866
47036
|
const ctx = import_api3.context.active();
|
|
@@ -46874,7 +47044,9 @@ async function recordSpan({
|
|
|
46874
47044
|
try {
|
|
46875
47045
|
recordErrorOnSpan(span, error40);
|
|
46876
47046
|
} finally {
|
|
46877
|
-
|
|
47047
|
+
if (endOnError) {
|
|
47048
|
+
span.end();
|
|
47049
|
+
}
|
|
46878
47050
|
}
|
|
46879
47051
|
throw error40;
|
|
46880
47052
|
}
|
|
@@ -49344,6 +49516,7 @@ function processUIMessageStream({
|
|
|
49344
49516
|
case "reasoning-start": {
|
|
49345
49517
|
const reasoningPart = {
|
|
49346
49518
|
type: "reasoning",
|
|
49519
|
+
id: chunk.id,
|
|
49347
49520
|
text: "",
|
|
49348
49521
|
providerMetadata: chunk.providerMetadata,
|
|
49349
49522
|
state: "streaming"
|
|
@@ -49640,7 +49813,7 @@ function processUIMessageStream({
|
|
|
49640
49813
|
}
|
|
49641
49814
|
await updateMessageMetadata(chunk.messageMetadata);
|
|
49642
49815
|
if (chunk.messageId != null || chunk.messageMetadata != null) {
|
|
49643
|
-
write();
|
|
49816
|
+
write({ updateStatus: false });
|
|
49644
49817
|
}
|
|
49645
49818
|
break;
|
|
49646
49819
|
}
|
|
@@ -49863,9 +50036,18 @@ function createAsyncIterableStream(source) {
|
|
|
49863
50036
|
}
|
|
49864
50037
|
async function consumeStream({
|
|
49865
50038
|
stream,
|
|
49866
|
-
onError
|
|
50039
|
+
onError,
|
|
50040
|
+
abortSignal
|
|
49867
50041
|
}) {
|
|
49868
50042
|
const reader = stream.getReader();
|
|
50043
|
+
const cancelOnAbort = () => {
|
|
50044
|
+
reader.cancel().catch(() => {});
|
|
50045
|
+
};
|
|
50046
|
+
if (abortSignal == null ? undefined : abortSignal.aborted) {
|
|
50047
|
+
cancelOnAbort();
|
|
50048
|
+
} else {
|
|
50049
|
+
abortSignal == null || abortSignal.addEventListener("abort", cancelOnAbort, { once: true });
|
|
50050
|
+
}
|
|
49869
50051
|
try {
|
|
49870
50052
|
while (true) {
|
|
49871
50053
|
const { done } = await reader.read();
|
|
@@ -49875,6 +50057,7 @@ async function consumeStream({
|
|
|
49875
50057
|
} catch (error40) {
|
|
49876
50058
|
onError == null || onError(error40);
|
|
49877
50059
|
} finally {
|
|
50060
|
+
abortSignal == null || abortSignal.removeEventListener("abort", cancelOnAbort);
|
|
49878
50061
|
reader.releaseLock();
|
|
49879
50062
|
}
|
|
49880
50063
|
}
|
|
@@ -50475,6 +50658,27 @@ function createUIMessageStream({
|
|
|
50475
50658
|
onError
|
|
50476
50659
|
});
|
|
50477
50660
|
}
|
|
50661
|
+
function createUIMessageSnapshot(message) {
|
|
50662
|
+
const textByPartIndex = /* @__PURE__ */ new Map;
|
|
50663
|
+
const messageWithoutText = {
|
|
50664
|
+
...message,
|
|
50665
|
+
parts: message.parts.map((part, index) => {
|
|
50666
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
50667
|
+
textByPartIndex.set(index, part.text);
|
|
50668
|
+
return { ...part, text: "" };
|
|
50669
|
+
}
|
|
50670
|
+
return part;
|
|
50671
|
+
})
|
|
50672
|
+
};
|
|
50673
|
+
const snapshot = structuredClone(messageWithoutText);
|
|
50674
|
+
for (const [index, text22] of textByPartIndex) {
|
|
50675
|
+
const part = snapshot.parts[index];
|
|
50676
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
50677
|
+
part.text = text22;
|
|
50678
|
+
}
|
|
50679
|
+
}
|
|
50680
|
+
return snapshot;
|
|
50681
|
+
}
|
|
50478
50682
|
function readUIMessageStream({
|
|
50479
50683
|
message,
|
|
50480
50684
|
stream,
|
|
@@ -50507,7 +50711,7 @@ function readUIMessageStream({
|
|
|
50507
50711
|
return job({
|
|
50508
50712
|
state,
|
|
50509
50713
|
write: () => {
|
|
50510
|
-
controller == null || controller.enqueue(
|
|
50714
|
+
controller == null || controller.enqueue(createUIMessageSnapshot(state.message));
|
|
50511
50715
|
}
|
|
50512
50716
|
});
|
|
50513
50717
|
},
|
|
@@ -53390,7 +53594,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53390
53594
|
}, imageMediaTypeSignatures, audioMediaTypeSignatures, videoMediaTypeSignatures, DEFAULT_SNIFF_BYTES = 18, MAX_SIGNATURE_BYTES = 12, MAX_ID3_TAG_BYTES, ID3_SCAN_BYTES, stripID3 = (bytes) => {
|
|
53391
53595
|
const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
|
|
53392
53596
|
return bytes.subarray(id3Size + 10);
|
|
53393
|
-
}, VERSION6 = "6.0.
|
|
53597
|
+
}, VERSION6 = "6.0.257", download = async ({
|
|
53394
53598
|
url: url2,
|
|
53395
53599
|
maxBytes,
|
|
53396
53600
|
abortSignal
|
|
@@ -53485,7 +53689,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53485
53689
|
const schema = asSchema(inputSchema);
|
|
53486
53690
|
return {
|
|
53487
53691
|
name: "object",
|
|
53488
|
-
responseFormat:
|
|
53692
|
+
responseFormat: resolve6(schema.jsonSchema).then((jsonSchema2) => ({
|
|
53489
53693
|
type: "json",
|
|
53490
53694
|
schema: jsonSchema2,
|
|
53491
53695
|
...name222 != null && { name: name222 },
|
|
@@ -53546,7 +53750,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53546
53750
|
const elementSchema = asSchema(inputElementSchema);
|
|
53547
53751
|
return {
|
|
53548
53752
|
name: "array",
|
|
53549
|
-
responseFormat:
|
|
53753
|
+
responseFormat: resolve6(elementSchema.jsonSchema).then((jsonSchema2) => {
|
|
53550
53754
|
const { $schema, ...itemSchema } = jsonSchema2;
|
|
53551
53755
|
return {
|
|
53552
53756
|
type: "json",
|
|
@@ -54589,6 +54793,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
54589
54793
|
}),
|
|
54590
54794
|
tracer,
|
|
54591
54795
|
endWhenDone: false,
|
|
54796
|
+
endOnError: true,
|
|
54592
54797
|
fn: async (doStreamSpan2) => ({
|
|
54593
54798
|
startTimestampMs: now22(),
|
|
54594
54799
|
doStreamSpan: doStreamSpan2,
|
|
@@ -55508,10 +55713,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
55508
55713
|
onStepFinish,
|
|
55509
55714
|
...options
|
|
55510
55715
|
}) {
|
|
55716
|
+
const preparedCall = await this.prepareCall(options);
|
|
55511
55717
|
return generateText({
|
|
55512
|
-
...
|
|
55718
|
+
...preparedCall,
|
|
55513
55719
|
abortSignal,
|
|
55514
|
-
timeout,
|
|
55720
|
+
timeout: timeout != null ? timeout : preparedCall.timeout,
|
|
55515
55721
|
onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
|
|
55516
55722
|
});
|
|
55517
55723
|
}
|
|
@@ -55522,10 +55728,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
55522
55728
|
onStepFinish,
|
|
55523
55729
|
...options
|
|
55524
55730
|
}) {
|
|
55731
|
+
const preparedCall = await this.prepareCall(options);
|
|
55525
55732
|
return streamText({
|
|
55526
|
-
...
|
|
55733
|
+
...preparedCall,
|
|
55527
55734
|
abortSignal,
|
|
55528
|
-
timeout,
|
|
55735
|
+
timeout: timeout != null ? timeout : preparedCall.timeout,
|
|
55529
55736
|
experimental_transform,
|
|
55530
55737
|
onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
|
|
55531
55738
|
});
|
|
@@ -55882,6 +56089,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
55882
56089
|
}),
|
|
55883
56090
|
tracer,
|
|
55884
56091
|
endWhenDone: false,
|
|
56092
|
+
endOnError: true,
|
|
55885
56093
|
fn: async (rootSpan) => {
|
|
55886
56094
|
const standardizedPrompt = await standardizePrompt({
|
|
55887
56095
|
system,
|
|
@@ -55951,6 +56159,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
55951
56159
|
}),
|
|
55952
56160
|
tracer,
|
|
55953
56161
|
endWhenDone: false,
|
|
56162
|
+
endOnError: true,
|
|
55954
56163
|
fn: async (doStreamSpan2) => ({
|
|
55955
56164
|
startTimestampMs: now22(),
|
|
55956
56165
|
doStreamSpan: doStreamSpan2,
|
|
@@ -56537,9 +56746,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56537
56746
|
...options
|
|
56538
56747
|
}) {
|
|
56539
56748
|
var _a222, _b16, _c, _d, _e;
|
|
56540
|
-
const resolvedBody = await
|
|
56541
|
-
const resolvedHeaders = await
|
|
56542
|
-
const resolvedCredentials = await
|
|
56749
|
+
const resolvedBody = await resolve6(this.body);
|
|
56750
|
+
const resolvedHeaders = await resolve6(this.headers);
|
|
56751
|
+
const resolvedCredentials = await resolve6(this.credentials);
|
|
56543
56752
|
const baseHeaders = {
|
|
56544
56753
|
...normalizeHeaders(resolvedHeaders),
|
|
56545
56754
|
...normalizeHeaders(options.headers)
|
|
@@ -56587,9 +56796,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56587
56796
|
}
|
|
56588
56797
|
async reconnectToStream(options) {
|
|
56589
56798
|
var _a222, _b16, _c, _d, _e;
|
|
56590
|
-
const resolvedBody = await
|
|
56591
|
-
const resolvedHeaders = await
|
|
56592
|
-
const resolvedCredentials = await
|
|
56799
|
+
const resolvedBody = await resolve6(this.body);
|
|
56800
|
+
const resolvedHeaders = await resolve6(this.headers);
|
|
56801
|
+
const resolvedCredentials = await resolve6(this.credentials);
|
|
56593
56802
|
const baseHeaders = {
|
|
56594
56803
|
...normalizeHeaders(resolvedHeaders),
|
|
56595
56804
|
...normalizeHeaders(options.headers)
|
|
@@ -56609,7 +56818,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56609
56818
|
const response = await fetch2(api2, {
|
|
56610
56819
|
method: "GET",
|
|
56611
56820
|
headers,
|
|
56612
|
-
credentials
|
|
56821
|
+
credentials,
|
|
56822
|
+
signal: options.abortSignal
|
|
56613
56823
|
});
|
|
56614
56824
|
if (response.status === 204) {
|
|
56615
56825
|
return null;
|
|
@@ -56637,6 +56847,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56637
56847
|
sendAutomaticallyWhen
|
|
56638
56848
|
}) {
|
|
56639
56849
|
this.activeResponse = undefined;
|
|
56850
|
+
this.activeResumeRequest = undefined;
|
|
56640
56851
|
this.jobExecutor = new SerialJobExecutor;
|
|
56641
56852
|
this.sendMessage = async (message, options) => {
|
|
56642
56853
|
var _a222, _b16, _c, _d;
|
|
@@ -56778,12 +56989,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56778
56989
|
});
|
|
56779
56990
|
this.addToolResult = this.addToolOutput;
|
|
56780
56991
|
this.stop = async () => {
|
|
56781
|
-
var _a222;
|
|
56782
|
-
|
|
56783
|
-
|
|
56784
|
-
if ((_a222 = this.activeResponse) == null ? undefined : _a222.abortController) {
|
|
56785
|
-
this.activeResponse.abortController.abort();
|
|
56786
|
-
}
|
|
56992
|
+
var _a222, _b16;
|
|
56993
|
+
(_a222 = this.activeResumeRequest) == null || _a222.abortController.abort();
|
|
56994
|
+
(_b16 = this.activeResponse) == null || _b16.abortController.abort();
|
|
56787
56995
|
};
|
|
56788
56996
|
this.id = id;
|
|
56789
56997
|
this.transport = transport;
|
|
@@ -56839,25 +57047,59 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56839
57047
|
body,
|
|
56840
57048
|
messageId
|
|
56841
57049
|
}) {
|
|
56842
|
-
var _a222, _b16;
|
|
57050
|
+
var _a222, _b16, _c;
|
|
57051
|
+
const abortController = new AbortController;
|
|
57052
|
+
const activeResumeRequest = trigger === "resume-stream" ? { abortController } : undefined;
|
|
57053
|
+
if (activeResumeRequest) {
|
|
57054
|
+
(_a222 = this.activeResumeRequest) == null || _a222.abortController.abort();
|
|
57055
|
+
this.activeResumeRequest = activeResumeRequest;
|
|
57056
|
+
}
|
|
57057
|
+
const isCurrentRequest = () => activeResumeRequest == null || this.activeResumeRequest === activeResumeRequest;
|
|
57058
|
+
const clearActiveResumeRequest = () => {
|
|
57059
|
+
if (this.activeResumeRequest === activeResumeRequest) {
|
|
57060
|
+
this.activeResumeRequest = undefined;
|
|
57061
|
+
}
|
|
57062
|
+
};
|
|
56843
57063
|
let resumeStream;
|
|
56844
57064
|
if (trigger === "resume-stream") {
|
|
56845
57065
|
try {
|
|
56846
57066
|
const reconnect = await this.transport.reconnectToStream({
|
|
56847
57067
|
chatId: this.id,
|
|
57068
|
+
abortSignal: abortController.signal,
|
|
56848
57069
|
metadata,
|
|
56849
57070
|
headers,
|
|
56850
57071
|
body
|
|
56851
57072
|
});
|
|
57073
|
+
if (abortController.signal.aborted || !isCurrentRequest()) {
|
|
57074
|
+
await (reconnect == null ? undefined : reconnect.cancel().catch(() => {}));
|
|
57075
|
+
if (isCurrentRequest()) {
|
|
57076
|
+
this.setStatus({ status: "ready" });
|
|
57077
|
+
}
|
|
57078
|
+
clearActiveResumeRequest();
|
|
57079
|
+
return;
|
|
57080
|
+
}
|
|
56852
57081
|
if (reconnect == null) {
|
|
57082
|
+
this.setStatus({ status: "ready" });
|
|
57083
|
+
clearActiveResumeRequest();
|
|
56853
57084
|
return;
|
|
56854
57085
|
}
|
|
56855
57086
|
resumeStream = reconnect;
|
|
56856
57087
|
} catch (err) {
|
|
57088
|
+
if (abortController.signal.aborted || err.name === "AbortError") {
|
|
57089
|
+
if (isCurrentRequest()) {
|
|
57090
|
+
this.setStatus({ status: "ready" });
|
|
57091
|
+
}
|
|
57092
|
+
clearActiveResumeRequest();
|
|
57093
|
+
return;
|
|
57094
|
+
}
|
|
57095
|
+
if (!isCurrentRequest()) {
|
|
57096
|
+
return;
|
|
57097
|
+
}
|
|
56857
57098
|
if (this.onError && err instanceof Error) {
|
|
56858
57099
|
this.onError(err);
|
|
56859
57100
|
}
|
|
56860
57101
|
this.setStatus({ status: "error", error: err });
|
|
57102
|
+
clearActiveResumeRequest();
|
|
56861
57103
|
return;
|
|
56862
57104
|
}
|
|
56863
57105
|
}
|
|
@@ -56870,10 +57112,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56870
57112
|
try {
|
|
56871
57113
|
const response = {
|
|
56872
57114
|
state: createStreamingUIMessageState({
|
|
56873
|
-
lastMessage: trigger === "regenerate-message" ? undefined : this.state.snapshot(lastMessage),
|
|
57115
|
+
lastMessage: trigger === "resume-stream" || trigger === "regenerate-message" ? undefined : this.state.snapshot(lastMessage),
|
|
56874
57116
|
messageId: this.generateId()
|
|
56875
57117
|
}),
|
|
56876
|
-
abortController
|
|
57118
|
+
abortController
|
|
56877
57119
|
};
|
|
56878
57120
|
activeResponse = response;
|
|
56879
57121
|
response.abortController.signal.addEventListener("abort", () => {
|
|
@@ -56895,19 +57137,29 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56895
57137
|
messageId
|
|
56896
57138
|
});
|
|
56897
57139
|
}
|
|
56898
|
-
const runUpdateMessageJob = (job) => this.jobExecutor.run(() =>
|
|
56899
|
-
|
|
56900
|
-
|
|
56901
|
-
var _a232;
|
|
56902
|
-
this.setStatus({ status: "streaming" });
|
|
56903
|
-
const replaceLastMessage = response.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
|
|
56904
|
-
if (replaceLastMessage) {
|
|
56905
|
-
this.state.replaceMessage(this.state.messages.length - 1, response.state.message);
|
|
56906
|
-
} else {
|
|
56907
|
-
this.state.pushMessage(response.state.message);
|
|
56908
|
-
}
|
|
57140
|
+
const runUpdateMessageJob = (job) => this.jobExecutor.run(() => {
|
|
57141
|
+
if (response.abortController.signal.aborted) {
|
|
57142
|
+
return Promise.resolve();
|
|
56909
57143
|
}
|
|
56910
|
-
|
|
57144
|
+
return job({
|
|
57145
|
+
state: response.state,
|
|
57146
|
+
write: ({ updateStatus = true } = {}) => {
|
|
57147
|
+
var _a232;
|
|
57148
|
+
if (response.abortController.signal.aborted) {
|
|
57149
|
+
return;
|
|
57150
|
+
}
|
|
57151
|
+
if (updateStatus) {
|
|
57152
|
+
this.setStatus({ status: "streaming" });
|
|
57153
|
+
}
|
|
57154
|
+
const replaceLastMessage = response.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
|
|
57155
|
+
if (replaceLastMessage) {
|
|
57156
|
+
this.state.replaceMessage(this.state.messages.length - 1, response.state.message);
|
|
57157
|
+
} else {
|
|
57158
|
+
this.state.pushMessage(response.state.message);
|
|
57159
|
+
}
|
|
57160
|
+
}
|
|
57161
|
+
});
|
|
57162
|
+
});
|
|
56911
57163
|
await consumeStream({
|
|
56912
57164
|
stream: processUIMessageStream({
|
|
56913
57165
|
stream,
|
|
@@ -56920,15 +57172,29 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56920
57172
|
throw error40;
|
|
56921
57173
|
}
|
|
56922
57174
|
}),
|
|
57175
|
+
abortSignal: response.abortController.signal,
|
|
56923
57176
|
onError: (error40) => {
|
|
56924
57177
|
throw error40;
|
|
56925
57178
|
}
|
|
56926
57179
|
});
|
|
56927
|
-
|
|
57180
|
+
if (isAbort) {
|
|
57181
|
+
if (isCurrentRequest()) {
|
|
57182
|
+
this.setStatus({ status: "ready" });
|
|
57183
|
+
}
|
|
57184
|
+
return null;
|
|
57185
|
+
}
|
|
57186
|
+
if (isCurrentRequest()) {
|
|
57187
|
+
this.setStatus({ status: "ready" });
|
|
57188
|
+
}
|
|
56928
57189
|
} catch (err) {
|
|
56929
57190
|
if (isAbort || err.name === "AbortError") {
|
|
56930
57191
|
isAbort = true;
|
|
56931
|
-
|
|
57192
|
+
if (isCurrentRequest()) {
|
|
57193
|
+
this.setStatus({ status: "ready" });
|
|
57194
|
+
}
|
|
57195
|
+
return null;
|
|
57196
|
+
}
|
|
57197
|
+
if (!isCurrentRequest()) {
|
|
56932
57198
|
return null;
|
|
56933
57199
|
}
|
|
56934
57200
|
isError = true;
|
|
@@ -56942,7 +57208,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56942
57208
|
} finally {
|
|
56943
57209
|
try {
|
|
56944
57210
|
if (activeResponse) {
|
|
56945
|
-
(
|
|
57211
|
+
(_b16 = this.onFinish) == null || _b16.call(this, {
|
|
56946
57212
|
message: activeResponse.state.message,
|
|
56947
57213
|
messages: this.state.messages,
|
|
56948
57214
|
isAbort,
|
|
@@ -56951,17 +57217,17 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56951
57217
|
finishReason: activeResponse.state.finishReason
|
|
56952
57218
|
});
|
|
56953
57219
|
}
|
|
56954
|
-
}
|
|
56955
|
-
|
|
56956
|
-
|
|
56957
|
-
|
|
56958
|
-
|
|
57220
|
+
} finally {
|
|
57221
|
+
if (this.activeResponse === activeResponse) {
|
|
57222
|
+
this.activeResponse = undefined;
|
|
57223
|
+
}
|
|
57224
|
+
clearActiveResumeRequest();
|
|
56959
57225
|
}
|
|
56960
57226
|
}
|
|
56961
57227
|
if (!isError && await this.shouldSendAutomatically()) {
|
|
56962
57228
|
await this.makeRequest({
|
|
56963
57229
|
trigger: "submit-message",
|
|
56964
|
-
messageId: (
|
|
57230
|
+
messageId: (_c = this.lastMessage) == null ? undefined : _c.id,
|
|
56965
57231
|
metadata,
|
|
56966
57232
|
headers,
|
|
56967
57233
|
body
|
|
@@ -57000,96 +57266,96 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
57000
57266
|
return null;
|
|
57001
57267
|
}
|
|
57002
57268
|
}, TextStreamChatTransport;
|
|
57003
|
-
var
|
|
57004
|
-
|
|
57005
|
-
|
|
57006
|
-
|
|
57007
|
-
|
|
57008
|
-
|
|
57009
|
-
|
|
57010
|
-
|
|
57011
|
-
|
|
57012
|
-
|
|
57013
|
-
|
|
57014
|
-
|
|
57015
|
-
|
|
57016
|
-
|
|
57017
|
-
|
|
57018
|
-
|
|
57019
|
-
|
|
57020
|
-
|
|
57021
|
-
|
|
57022
|
-
|
|
57023
|
-
|
|
57024
|
-
|
|
57025
|
-
|
|
57026
|
-
|
|
57027
|
-
|
|
57028
|
-
|
|
57029
|
-
|
|
57030
|
-
|
|
57031
|
-
|
|
57032
|
-
|
|
57033
|
-
|
|
57034
|
-
|
|
57035
|
-
|
|
57036
|
-
|
|
57269
|
+
var init_dist9 = __esm(() => {
|
|
57270
|
+
init_dist8();
|
|
57271
|
+
init_dist4();
|
|
57272
|
+
init_dist4();
|
|
57273
|
+
init_dist4();
|
|
57274
|
+
init_dist2();
|
|
57275
|
+
init_dist2();
|
|
57276
|
+
init_dist2();
|
|
57277
|
+
init_dist2();
|
|
57278
|
+
init_dist2();
|
|
57279
|
+
init_dist2();
|
|
57280
|
+
init_dist2();
|
|
57281
|
+
init_dist2();
|
|
57282
|
+
init_dist2();
|
|
57283
|
+
init_dist2();
|
|
57284
|
+
init_dist2();
|
|
57285
|
+
init_dist2();
|
|
57286
|
+
init_dist2();
|
|
57287
|
+
init_dist2();
|
|
57288
|
+
init_dist2();
|
|
57289
|
+
init_dist2();
|
|
57290
|
+
init_dist2();
|
|
57291
|
+
init_dist2();
|
|
57292
|
+
init_dist2();
|
|
57293
|
+
init_dist2();
|
|
57294
|
+
init_dist2();
|
|
57295
|
+
init_dist4();
|
|
57296
|
+
init_dist2();
|
|
57297
|
+
init_dist8();
|
|
57298
|
+
init_dist4();
|
|
57299
|
+
init_dist4();
|
|
57300
|
+
init_dist4();
|
|
57301
|
+
init_dist2();
|
|
57302
|
+
init_dist4();
|
|
57037
57303
|
init_v4();
|
|
57038
|
-
|
|
57039
|
-
|
|
57040
|
-
|
|
57041
|
-
|
|
57304
|
+
init_dist2();
|
|
57305
|
+
init_dist4();
|
|
57306
|
+
init_dist2();
|
|
57307
|
+
init_dist4();
|
|
57042
57308
|
init_v4();
|
|
57043
57309
|
init_v4();
|
|
57044
57310
|
init_v4();
|
|
57045
57311
|
init_v4();
|
|
57046
57312
|
init_v4();
|
|
57047
|
-
|
|
57048
|
-
|
|
57049
|
-
|
|
57050
|
-
|
|
57051
|
-
|
|
57052
|
-
|
|
57053
|
-
|
|
57054
|
-
|
|
57055
|
-
|
|
57056
|
-
|
|
57057
|
-
|
|
57058
|
-
|
|
57059
|
-
|
|
57060
|
-
|
|
57061
|
-
|
|
57062
|
-
|
|
57313
|
+
init_dist8();
|
|
57314
|
+
init_dist2();
|
|
57315
|
+
init_dist2();
|
|
57316
|
+
init_dist8();
|
|
57317
|
+
init_dist4();
|
|
57318
|
+
init_dist4();
|
|
57319
|
+
init_dist4();
|
|
57320
|
+
init_dist4();
|
|
57321
|
+
init_dist4();
|
|
57322
|
+
init_dist2();
|
|
57323
|
+
init_dist4();
|
|
57324
|
+
init_dist4();
|
|
57325
|
+
init_dist4();
|
|
57326
|
+
init_dist2();
|
|
57327
|
+
init_dist4();
|
|
57328
|
+
init_dist4();
|
|
57063
57329
|
init_v4();
|
|
57064
|
-
|
|
57065
|
-
|
|
57066
|
-
|
|
57067
|
-
|
|
57068
|
-
|
|
57069
|
-
|
|
57330
|
+
init_dist4();
|
|
57331
|
+
init_dist4();
|
|
57332
|
+
init_dist4();
|
|
57333
|
+
init_dist4();
|
|
57334
|
+
init_dist2();
|
|
57335
|
+
init_dist4();
|
|
57070
57336
|
init_v4();
|
|
57071
|
-
|
|
57072
|
-
|
|
57073
|
-
|
|
57074
|
-
|
|
57075
|
-
|
|
57076
|
-
|
|
57077
|
-
|
|
57078
|
-
|
|
57079
|
-
|
|
57080
|
-
|
|
57081
|
-
|
|
57082
|
-
|
|
57083
|
-
|
|
57084
|
-
|
|
57085
|
-
|
|
57086
|
-
|
|
57087
|
-
|
|
57088
|
-
|
|
57089
|
-
|
|
57090
|
-
|
|
57091
|
-
|
|
57092
|
-
|
|
57337
|
+
init_dist4();
|
|
57338
|
+
init_dist4();
|
|
57339
|
+
init_dist4();
|
|
57340
|
+
init_dist4();
|
|
57341
|
+
init_dist2();
|
|
57342
|
+
init_dist4();
|
|
57343
|
+
init_dist2();
|
|
57344
|
+
init_dist4();
|
|
57345
|
+
init_dist4();
|
|
57346
|
+
init_dist4();
|
|
57347
|
+
init_dist4();
|
|
57348
|
+
init_dist4();
|
|
57349
|
+
init_dist2();
|
|
57350
|
+
init_dist4();
|
|
57351
|
+
init_dist2();
|
|
57352
|
+
init_dist2();
|
|
57353
|
+
init_dist2();
|
|
57354
|
+
init_dist4();
|
|
57355
|
+
init_dist4();
|
|
57356
|
+
init_dist4();
|
|
57357
|
+
init_dist4();
|
|
57358
|
+
init_dist4();
|
|
57093
57359
|
import_api2 = __toESM(require_src(), 1);
|
|
57094
57360
|
import_api3 = __toESM(require_src(), 1);
|
|
57095
57361
|
__defProp2 = Object.defineProperty;
|
|
@@ -58148,6 +58414,7 @@ var init_dist8 = __esm(() => {
|
|
|
58148
58414
|
}),
|
|
58149
58415
|
exports_external2.object({
|
|
58150
58416
|
type: exports_external2.literal("reasoning"),
|
|
58417
|
+
id: exports_external2.string().optional(),
|
|
58151
58418
|
text: exports_external2.string(),
|
|
58152
58419
|
state: exports_external2.enum(["streaming", "done"]).optional(),
|
|
58153
58420
|
providerMetadata: providerMetadataSchema.optional()
|
|
@@ -58914,12 +59181,12 @@ init_machines();
|
|
|
58914
59181
|
// src/lib/project-detect.ts
|
|
58915
59182
|
init_database();
|
|
58916
59183
|
init_api_mode();
|
|
58917
|
-
import { existsSync as
|
|
58918
|
-
import { basename, dirname as dirname2, join as
|
|
59184
|
+
import { existsSync as existsSync4 } from "fs";
|
|
59185
|
+
import { basename, dirname as dirname2, join as join6, resolve as resolve3 } from "path";
|
|
58919
59186
|
function findGitRoot2(startDir) {
|
|
58920
|
-
let dir =
|
|
59187
|
+
let dir = resolve3(startDir);
|
|
58921
59188
|
while (true) {
|
|
58922
|
-
if (
|
|
59189
|
+
if (existsSync4(join6(dir, ".git")))
|
|
58923
59190
|
return dir;
|
|
58924
59191
|
const parent = dirname2(dir);
|
|
58925
59192
|
if (parent === dir)
|
|
@@ -58939,7 +59206,7 @@ function detectProject(db) {
|
|
|
58939
59206
|
return null;
|
|
58940
59207
|
}
|
|
58941
59208
|
const repoName = basename(gitRoot);
|
|
58942
|
-
const absPath =
|
|
59209
|
+
const absPath = resolve3(gitRoot);
|
|
58943
59210
|
const d = db ?? (isApiMode() ? undefined : getDatabase());
|
|
58944
59211
|
const existing = getProject(absPath, d);
|
|
58945
59212
|
if (existing) {
|
|
@@ -58955,23 +59222,23 @@ function detectProject(db) {
|
|
|
58955
59222
|
init_built_in_hooks();
|
|
58956
59223
|
|
|
58957
59224
|
// src/lib/session-watcher.ts
|
|
58958
|
-
import { watch, existsSync as
|
|
58959
|
-
import { join as
|
|
59225
|
+
import { watch, existsSync as existsSync5, statSync, readFileSync as readFileSync2 } from "fs";
|
|
59226
|
+
import { join as join7 } from "path";
|
|
58960
59227
|
import { readdirSync } from "fs";
|
|
58961
59228
|
function encodeCwd(cwd) {
|
|
58962
59229
|
return cwd.replace(/\//g, "-");
|
|
58963
59230
|
}
|
|
58964
59231
|
function getProjectsDir() {
|
|
58965
59232
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
58966
|
-
return
|
|
59233
|
+
return join7(home, ".claude", "projects");
|
|
58967
59234
|
}
|
|
58968
59235
|
function findActiveSession(projectDir) {
|
|
58969
|
-
if (!
|
|
59236
|
+
if (!existsSync5(projectDir))
|
|
58970
59237
|
return null;
|
|
58971
59238
|
const files = readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).map((f) => ({
|
|
58972
59239
|
name: f,
|
|
58973
|
-
path:
|
|
58974
|
-
mtime: statSync(
|
|
59240
|
+
path: join7(projectDir, f),
|
|
59241
|
+
mtime: statSync(join7(projectDir, f)).mtimeMs
|
|
58975
59242
|
})).sort((a, b) => b.mtime - a.mtime);
|
|
58976
59243
|
return files[0]?.path || null;
|
|
58977
59244
|
}
|
|
@@ -59014,7 +59281,7 @@ function processNewLines(filePath, callback) {
|
|
|
59014
59281
|
}
|
|
59015
59282
|
function startSessionWatcher(cwd, callback) {
|
|
59016
59283
|
stopSessionWatcher();
|
|
59017
|
-
const projectDir =
|
|
59284
|
+
const projectDir = join7(getProjectsDir(), encodeCwd(cwd));
|
|
59018
59285
|
const sessionFile = findActiveSession(projectDir);
|
|
59019
59286
|
if (!sessionFile) {
|
|
59020
59287
|
return { sessionFile: null };
|
|
@@ -59248,15 +59515,15 @@ function getRecentlyPushedCount() {
|
|
|
59248
59515
|
|
|
59249
59516
|
// src/lib/session-registry.ts
|
|
59250
59517
|
init_storage();
|
|
59251
|
-
import { existsSync as
|
|
59252
|
-
import { dirname as dirname3, join as
|
|
59253
|
-
var DB_PATH =
|
|
59518
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync3 } from "fs";
|
|
59519
|
+
import { dirname as dirname3, join as join8 } from "path";
|
|
59520
|
+
var DB_PATH = join8(process.env["HOME"] || process.env["USERPROFILE"] || "~", ".open-sessions-registry.db");
|
|
59254
59521
|
var _db2 = null;
|
|
59255
59522
|
function getDb() {
|
|
59256
59523
|
if (_db2)
|
|
59257
59524
|
return _db2;
|
|
59258
59525
|
const dir = dirname3(DB_PATH);
|
|
59259
|
-
if (!
|
|
59526
|
+
if (!existsSync6(dir))
|
|
59260
59527
|
mkdirSync3(dir, { recursive: true });
|
|
59261
59528
|
_db2 = new SqliteAdapter(DB_PATH);
|
|
59262
59529
|
_db2.run("PRAGMA journal_mode = WAL");
|
|
@@ -62671,8 +62938,8 @@ init_entities();
|
|
|
62671
62938
|
init_database();
|
|
62672
62939
|
init_entities();
|
|
62673
62940
|
init_relations();
|
|
62674
|
-
import { readdirSync as readdirSync3, readFileSync as readFileSync4, statSync as statSync2, existsSync as
|
|
62675
|
-
import { join as
|
|
62941
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync4, statSync as statSync2, existsSync as existsSync8 } from "fs";
|
|
62942
|
+
import { join as join10, resolve as resolve5, relative, dirname as dirname5, extname, basename as basename3 } from "path";
|
|
62676
62943
|
var DEFAULT_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".py", ".go", ".rs"];
|
|
62677
62944
|
var DEFAULT_EXCLUDES = ["node_modules", ".git", "dist", "build", ".next", "__pycache__", "target", "vendor"];
|
|
62678
62945
|
function parseImports(_filePath, content) {
|
|
@@ -62702,14 +62969,14 @@ function parseImports(_filePath, content) {
|
|
|
62702
62969
|
}
|
|
62703
62970
|
function resolveImport(fromFile, importPath, allFiles) {
|
|
62704
62971
|
const dir = dirname5(fromFile);
|
|
62705
|
-
const base =
|
|
62972
|
+
const base = resolve5(dir, importPath);
|
|
62706
62973
|
if (allFiles.has(base))
|
|
62707
62974
|
return base;
|
|
62708
62975
|
for (const ext of [".ts", ".tsx", ".js", ".jsx", ".mjs"]) {
|
|
62709
62976
|
const withExt = base + ext;
|
|
62710
62977
|
if (allFiles.has(withExt))
|
|
62711
62978
|
return withExt;
|
|
62712
|
-
const index =
|
|
62979
|
+
const index = join10(base, `index${ext}`);
|
|
62713
62980
|
if (allFiles.has(index))
|
|
62714
62981
|
return index;
|
|
62715
62982
|
}
|
|
@@ -62727,7 +62994,7 @@ function collectFiles(dir, extensions, excludes) {
|
|
|
62727
62994
|
for (const entry of entries) {
|
|
62728
62995
|
if (excludes.some((e) => entry === e || current.includes(`/${e}/`)))
|
|
62729
62996
|
continue;
|
|
62730
|
-
const full =
|
|
62997
|
+
const full = join10(current, entry);
|
|
62731
62998
|
let stat;
|
|
62732
62999
|
try {
|
|
62733
63000
|
stat = statSync2(full);
|
|
@@ -62741,7 +63008,7 @@ function collectFiles(dir, extensions, excludes) {
|
|
|
62741
63008
|
}
|
|
62742
63009
|
}
|
|
62743
63010
|
}
|
|
62744
|
-
walk(
|
|
63011
|
+
walk(resolve5(dir));
|
|
62745
63012
|
return files;
|
|
62746
63013
|
}
|
|
62747
63014
|
async function buildFileDependencyGraph(opts, db) {
|
|
@@ -62749,8 +63016,8 @@ async function buildFileDependencyGraph(opts, db) {
|
|
|
62749
63016
|
const result = { files_scanned: 0, entities_created: 0, entities_updated: 0, relations_created: 0, errors: [] };
|
|
62750
63017
|
const extensions = opts.extensions ?? DEFAULT_EXTENSIONS;
|
|
62751
63018
|
const excludes = opts.exclude_patterns ?? DEFAULT_EXCLUDES;
|
|
62752
|
-
const rootDir =
|
|
62753
|
-
if (!
|
|
63019
|
+
const rootDir = resolve5(opts.root_dir);
|
|
63020
|
+
if (!existsSync8(rootDir)) {
|
|
62754
63021
|
result.errors.push(`Directory not found: ${rootDir}`);
|
|
62755
63022
|
return result;
|
|
62756
63023
|
}
|
|
@@ -63612,7 +63879,7 @@ function resolveCurrentMachineId(local, requested) {
|
|
|
63612
63879
|
function runStorageSync(direction, options = {}) {
|
|
63613
63880
|
const backend = getStorageBackend();
|
|
63614
63881
|
if (backend === "sqlite" && !options.remote) {
|
|
63615
|
-
throw new Error(
|
|
63882
|
+
throw new Error(`Remote storage is not configured. Set HASNA_MEMENTOS_DATABASE_URL or configure ${getConfigPath()}.`);
|
|
63616
63883
|
}
|
|
63617
63884
|
return withManagedAdapters(options, (local, remote, currentMachineId) => {
|
|
63618
63885
|
const tables = resolveTables(local, options.tables);
|
|
@@ -67209,7 +67476,7 @@ function registerSystemEventTools({ server, z, createMemory: createMemory2, save
|
|
|
67209
67476
|
if (connection_string) {
|
|
67210
67477
|
connStr = connection_string;
|
|
67211
67478
|
} else {
|
|
67212
|
-
connStr =
|
|
67479
|
+
connStr = getStorageConnectionStringForOperator("mementos");
|
|
67213
67480
|
}
|
|
67214
67481
|
const result = await applyPgMigrations2(connStr);
|
|
67215
67482
|
const lines = [];
|
|
@@ -68234,7 +68501,7 @@ async function resolveAISDKModel(provider, model) {
|
|
|
68234
68501
|
const key = process.env["ANTHROPIC_API_KEY"];
|
|
68235
68502
|
if (!key)
|
|
68236
68503
|
return null;
|
|
68237
|
-
const mod = await Promise.resolve().then(() => (
|
|
68504
|
+
const mod = await Promise.resolve().then(() => (init_dist5(), exports_dist));
|
|
68238
68505
|
const anthropic2 = mod["anthropic"];
|
|
68239
68506
|
return anthropic2 ? anthropic2(model) : null;
|
|
68240
68507
|
}
|
|
@@ -68242,7 +68509,7 @@ async function resolveAISDKModel(provider, model) {
|
|
|
68242
68509
|
const key = process.env["OPENAI_API_KEY"];
|
|
68243
68510
|
if (!key)
|
|
68244
68511
|
return null;
|
|
68245
|
-
const mod = await Promise.resolve().then(() => (
|
|
68512
|
+
const mod = await Promise.resolve().then(() => (init_dist6(), exports_dist2));
|
|
68246
68513
|
const openai2 = mod["openai"];
|
|
68247
68514
|
return openai2 ? openai2(model) : null;
|
|
68248
68515
|
}
|
|
@@ -68251,7 +68518,7 @@ async function resolveAISDKModel(provider, model) {
|
|
|
68251
68518
|
if (!apiKey)
|
|
68252
68519
|
return null;
|
|
68253
68520
|
const baseURL = provider === "cerebras" ? "https://api.cerebras.ai/v1" : "https://api.x.ai/v1";
|
|
68254
|
-
const mod = await Promise.resolve().then(() => (
|
|
68521
|
+
const mod = await Promise.resolve().then(() => (init_dist7(), exports_dist3));
|
|
68255
68522
|
const createOpenAICompatible2 = mod["createOpenAICompatible"];
|
|
68256
68523
|
if (!createOpenAICompatible2)
|
|
68257
68524
|
return null;
|
|
@@ -68267,7 +68534,7 @@ function createAISDKReflectionCritic(options = {}) {
|
|
|
68267
68534
|
if (!resolvedModel)
|
|
68268
68535
|
return heuristicReflectionCritic(trajectory);
|
|
68269
68536
|
try {
|
|
68270
|
-
const ai = await Promise.resolve().then(() => (
|
|
68537
|
+
const ai = await Promise.resolve().then(() => (init_dist9(), exports_dist4));
|
|
68271
68538
|
const generateObject2 = ai["generateObject"];
|
|
68272
68539
|
if (!generateObject2)
|
|
68273
68540
|
return heuristicReflectionCritic(trajectory);
|
|
@@ -68503,9 +68770,9 @@ async function startMcpHttpServer(buildServer, options) {
|
|
|
68503
68770
|
}
|
|
68504
68771
|
}
|
|
68505
68772
|
});
|
|
68506
|
-
await new Promise((
|
|
68773
|
+
await new Promise((resolve7, reject) => {
|
|
68507
68774
|
httpServer.once("error", reject);
|
|
68508
|
-
httpServer.listen(requestedPort, host, () =>
|
|
68775
|
+
httpServer.listen(requestedPort, host, () => resolve7());
|
|
68509
68776
|
});
|
|
68510
68777
|
const addr = httpServer.address();
|
|
68511
68778
|
const port = typeof addr === "object" && addr ? addr.port : requestedPort;
|
|
@@ -68513,8 +68780,8 @@ async function startMcpHttpServer(buildServer, options) {
|
|
|
68513
68780
|
return {
|
|
68514
68781
|
port,
|
|
68515
68782
|
host,
|
|
68516
|
-
close: () => new Promise((
|
|
68517
|
-
httpServer.close((err) => err ? reject(err) :
|
|
68783
|
+
close: () => new Promise((resolve7, reject) => {
|
|
68784
|
+
httpServer.close((err) => err ? reject(err) : resolve7());
|
|
68518
68785
|
})
|
|
68519
68786
|
};
|
|
68520
68787
|
}
|