@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/server/index.js
CHANGED
|
@@ -65,6 +65,115 @@ var __export = (target, all) => {
|
|
|
65
65
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
66
66
|
var __require = import.meta.require;
|
|
67
67
|
|
|
68
|
+
// ../../node_modules/.bun/@hasna+paths@0.1.0/node_modules/@hasna/paths/dist/index.js
|
|
69
|
+
import { homedir } from "os";
|
|
70
|
+
import { join } from "path";
|
|
71
|
+
function assertApp(app) {
|
|
72
|
+
if (typeof app !== "string" || app.length === 0) {
|
|
73
|
+
throw new TypeError("paths: app must be a non-empty string");
|
|
74
|
+
}
|
|
75
|
+
if (!APP_SLUG_RE.test(app)) {
|
|
76
|
+
throw new TypeError(`paths: invalid app slug "${app}" \u2014 expected lowercase kebab-case ([a-z0-9]+(-[a-z0-9]+)*)`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function envOf(options) {
|
|
80
|
+
return options.env ?? process.env;
|
|
81
|
+
}
|
|
82
|
+
function envValue(options, kind) {
|
|
83
|
+
const value = envOf(options)[KIND_ENV[kind]];
|
|
84
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
85
|
+
}
|
|
86
|
+
function isMacOS(platform) {
|
|
87
|
+
return platform === "darwin";
|
|
88
|
+
}
|
|
89
|
+
function baseDir(kind, options) {
|
|
90
|
+
const override = envValue(options, kind);
|
|
91
|
+
if (override)
|
|
92
|
+
return override;
|
|
93
|
+
const home = options.home ?? homedir();
|
|
94
|
+
const platform = options.platform ?? process.platform;
|
|
95
|
+
if (isMacOS(platform)) {
|
|
96
|
+
switch (kind) {
|
|
97
|
+
case "config":
|
|
98
|
+
case "data":
|
|
99
|
+
return join(home, "Library", "Application Support", "Hasna");
|
|
100
|
+
case "cache":
|
|
101
|
+
return join(home, "Library", "Caches", "Hasna");
|
|
102
|
+
case "state":
|
|
103
|
+
return join(home, "Library", "Logs", "Hasna");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
switch (kind) {
|
|
107
|
+
case "config":
|
|
108
|
+
return join(home, ".config", "hasna");
|
|
109
|
+
case "data":
|
|
110
|
+
return join(home, ".local", "share", "hasna");
|
|
111
|
+
case "state":
|
|
112
|
+
return join(home, ".local", "state", "hasna");
|
|
113
|
+
case "cache":
|
|
114
|
+
return join(home, ".cache", "hasna");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function resolvePath(kind, options) {
|
|
118
|
+
assertApp(options.app);
|
|
119
|
+
const appSegment = options.internal === true ? join("internal", options.app) : options.app;
|
|
120
|
+
return join(baseDir(kind, options), appSegment);
|
|
121
|
+
}
|
|
122
|
+
function dataDir(options) {
|
|
123
|
+
return resolvePath("data", options);
|
|
124
|
+
}
|
|
125
|
+
var KIND_ENV, APP_SLUG_RE;
|
|
126
|
+
var init_dist = __esm(() => {
|
|
127
|
+
KIND_ENV = {
|
|
128
|
+
config: "HASNA_CONFIG_HOME",
|
|
129
|
+
data: "HASNA_DATA_HOME",
|
|
130
|
+
state: "HASNA_STATE_HOME",
|
|
131
|
+
cache: "HASNA_CACHE_HOME"
|
|
132
|
+
};
|
|
133
|
+
APP_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// src/lib/paths.ts
|
|
137
|
+
import { existsSync } from "fs";
|
|
138
|
+
import { homedir as homedir2 } from "os";
|
|
139
|
+
import { join as join2, resolve } from "path";
|
|
140
|
+
function effectiveHome() {
|
|
141
|
+
return process.env["HOME"] || process.env["USERPROFILE"] || homedir2() || "/tmp";
|
|
142
|
+
}
|
|
143
|
+
function legacyDataRoot() {
|
|
144
|
+
return join2(effectiveHome(), ".hasna", "mementos");
|
|
145
|
+
}
|
|
146
|
+
function resolverDataRoot() {
|
|
147
|
+
return dataDir({
|
|
148
|
+
app: "mementos",
|
|
149
|
+
home: process.env["HOME"] || process.env["USERPROFILE"] || undefined
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function adoptResolverDataRoot(resolved, env = process.env) {
|
|
153
|
+
const dataOverride = env.HASNA_DATA_HOME;
|
|
154
|
+
if (typeof dataOverride === "string" && dataOverride.trim().length > 0)
|
|
155
|
+
return true;
|
|
156
|
+
return existsSync(join2(resolved, "mementos.db"));
|
|
157
|
+
}
|
|
158
|
+
function exactDataRoot() {
|
|
159
|
+
for (const key of ["HASNA_MEMENTOS_HOME", "MEMENTOS_HOME"]) {
|
|
160
|
+
const dir = process.env[key]?.trim();
|
|
161
|
+
if (dir)
|
|
162
|
+
return resolve(dir);
|
|
163
|
+
}
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
function getDataRoot() {
|
|
167
|
+
const exact = exactDataRoot();
|
|
168
|
+
if (exact)
|
|
169
|
+
return exact;
|
|
170
|
+
const resolved = resolverDataRoot();
|
|
171
|
+
return adoptResolverDataRoot(resolved) ? resolve(resolved) : resolve(legacyDataRoot());
|
|
172
|
+
}
|
|
173
|
+
var init_paths = __esm(() => {
|
|
174
|
+
init_dist();
|
|
175
|
+
});
|
|
176
|
+
|
|
68
177
|
// src/generated/storage-kit/own.ts
|
|
69
178
|
function ownProp(source, key) {
|
|
70
179
|
if (source === null || source === undefined)
|
|
@@ -168,9 +277,8 @@ var init_retired_storage_mode = __esm(() => {
|
|
|
168
277
|
|
|
169
278
|
// src/storage.ts
|
|
170
279
|
import { Database } from "bun:sqlite";
|
|
171
|
-
import { existsSync as
|
|
172
|
-
import {
|
|
173
|
-
import { join as join2 } from "path";
|
|
280
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
281
|
+
import { join as join4 } from "path";
|
|
174
282
|
import { fileURLToPath } from "url";
|
|
175
283
|
import { Worker } from "worker_threads";
|
|
176
284
|
import pg from "pg";
|
|
@@ -378,7 +486,7 @@ function readEnv(name) {
|
|
|
378
486
|
return value ? value : null;
|
|
379
487
|
}
|
|
380
488
|
function readConfigFile() {
|
|
381
|
-
if (!
|
|
489
|
+
if (!existsSync3(STORAGE_CONFIG_PATH)) {
|
|
382
490
|
return {};
|
|
383
491
|
}
|
|
384
492
|
try {
|
|
@@ -483,11 +591,7 @@ function validatePostgresConnectionString(value) {
|
|
|
483
591
|
function getConfiguredConnectionString() {
|
|
484
592
|
return getStorageDatabaseUrl() ?? undefined;
|
|
485
593
|
}
|
|
486
|
-
function
|
|
487
|
-
assertNoLegacyStorageMode2();
|
|
488
|
-
if (!isServerContext()) {
|
|
489
|
-
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).");
|
|
490
|
-
}
|
|
594
|
+
function resolveConfiguredConnectionString(dbName) {
|
|
491
595
|
const envConnectionString = getConfiguredConnectionString();
|
|
492
596
|
if (envConnectionString) {
|
|
493
597
|
const validation = validatePostgresConnectionString(envConnectionString);
|
|
@@ -506,7 +610,7 @@ function getStorageConnectionString(dbName = "mementos") {
|
|
|
506
610
|
missing.push("storage.rds.username");
|
|
507
611
|
}
|
|
508
612
|
if (missing.length > 0) {
|
|
509
|
-
throw new Error(`Remote storage database is not configured. Missing ${missing.join(", ")}. Set HASNA_MEMENTOS_DATABASE_URL or configure
|
|
613
|
+
throw new Error(`Remote storage database is not configured. Missing ${missing.join(", ")}. Set HASNA_MEMENTOS_DATABASE_URL or configure ${STORAGE_CONFIG_PATH}.`);
|
|
510
614
|
}
|
|
511
615
|
const password = process.env[password_env];
|
|
512
616
|
if (!password) {
|
|
@@ -515,10 +619,18 @@ function getStorageConnectionString(dbName = "mementos") {
|
|
|
515
619
|
const sslParam = ssl ? "?sslmode=require" : "";
|
|
516
620
|
return `postgres://${username}:${encodeURIComponent(password)}@${host}:${port}/${dbName}${sslParam}`;
|
|
517
621
|
}
|
|
622
|
+
function getStorageConnectionString(dbName = "mementos") {
|
|
623
|
+
assertNoLegacyStorageMode2();
|
|
624
|
+
if (!isServerContext()) {
|
|
625
|
+
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).");
|
|
626
|
+
}
|
|
627
|
+
return resolveConfiguredConnectionString(dbName);
|
|
628
|
+
}
|
|
518
629
|
var _serverContext = false, PgSyncPool, MEMENTOS_STORAGE_ENV, MEMENTOS_STORAGE_FALLBACK_ENV, LOCAL_DATA_DIR, DEFAULT_STORAGE_CONFIG, STORAGE_CONFIG_DIR, STORAGE_CONFIG_PATH, DATABASE_ENV_NAMES, SECRET_QUERY_PARAMS;
|
|
519
630
|
var init_storage = __esm(() => {
|
|
520
631
|
init_backend();
|
|
521
632
|
init_retired_storage_mode();
|
|
633
|
+
init_paths();
|
|
522
634
|
PgSyncPool = class PgSyncPool {
|
|
523
635
|
worker;
|
|
524
636
|
status;
|
|
@@ -536,12 +648,12 @@ var init_storage = __esm(() => {
|
|
|
536
648
|
const ext = import.meta.url.endsWith(".ts") ? ".ts" : ".js";
|
|
537
649
|
const here = fileURLToPath(new URL(".", import.meta.url));
|
|
538
650
|
const candidates = [
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
651
|
+
join4(here, `pg-sync-worker${ext}`),
|
|
652
|
+
join4(here, "..", `pg-sync-worker${ext}`),
|
|
653
|
+
join4(here, "..", "..", `pg-sync-worker${ext}`)
|
|
542
654
|
];
|
|
543
655
|
for (const candidate of candidates) {
|
|
544
|
-
if (
|
|
656
|
+
if (existsSync3(candidate))
|
|
545
657
|
return candidate;
|
|
546
658
|
}
|
|
547
659
|
return candidates[0];
|
|
@@ -612,7 +724,7 @@ var init_storage = __esm(() => {
|
|
|
612
724
|
MEMENTOS_STORAGE_FALLBACK_ENV = {
|
|
613
725
|
databaseUrl: "MEMENTOS_DATABASE_URL"
|
|
614
726
|
};
|
|
615
|
-
LOCAL_DATA_DIR =
|
|
727
|
+
LOCAL_DATA_DIR = getDataRoot();
|
|
616
728
|
DEFAULT_STORAGE_CONFIG = {
|
|
617
729
|
rds: {
|
|
618
730
|
host: "",
|
|
@@ -627,8 +739,8 @@ var init_storage = __esm(() => {
|
|
|
627
739
|
schedule_minutes: 0
|
|
628
740
|
}
|
|
629
741
|
};
|
|
630
|
-
STORAGE_CONFIG_DIR =
|
|
631
|
-
STORAGE_CONFIG_PATH =
|
|
742
|
+
STORAGE_CONFIG_DIR = join4(LOCAL_DATA_DIR, "storage");
|
|
743
|
+
STORAGE_CONFIG_PATH = join4(STORAGE_CONFIG_DIR, "config.json");
|
|
632
744
|
DATABASE_ENV_NAMES = [
|
|
633
745
|
{ name: MEMENTOS_STORAGE_ENV.databaseUrl, deprecated: false },
|
|
634
746
|
{ name: MEMENTOS_STORAGE_FALLBACK_ENV.databaseUrl, deprecated: false }
|
|
@@ -646,7 +758,7 @@ var init_storage = __esm(() => {
|
|
|
646
758
|
|
|
647
759
|
// src/db/api-mode.ts
|
|
648
760
|
import { tmpdir } from "os";
|
|
649
|
-
import { join as
|
|
761
|
+
import { join as join5 } from "path";
|
|
650
762
|
import { writeFileSync as writeFileSync3, unlinkSync as unlinkSync2 } from "fs";
|
|
651
763
|
import { randomUUID } from "crypto";
|
|
652
764
|
function firstEnv2(keys) {
|
|
@@ -756,7 +868,7 @@ x-api-key: ${cfg.apiKey}
|
|
|
756
868
|
];
|
|
757
869
|
let bodyFile;
|
|
758
870
|
if (hasBody) {
|
|
759
|
-
bodyFile =
|
|
871
|
+
bodyFile = join5(tmpdir(), `mem-req-${process.pid}-${randomUUID()}.json`);
|
|
760
872
|
writeFileSync3(bodyFile, JSON.stringify(body), { mode: 384 });
|
|
761
873
|
args.push("--data-binary", `@${bodyFile}`);
|
|
762
874
|
}
|
|
@@ -2048,18 +2160,18 @@ __export(exports_database, {
|
|
|
2048
2160
|
escapeLikePrefix: () => escapeLikePrefix,
|
|
2049
2161
|
closeDatabase: () => closeDatabase
|
|
2050
2162
|
});
|
|
2051
|
-
import { existsSync as
|
|
2052
|
-
import { dirname as dirname2, join as
|
|
2163
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, cpSync as cpSync2 } from "fs";
|
|
2164
|
+
import { dirname as dirname2, join as join6, resolve as resolve3 } from "path";
|
|
2053
2165
|
function isInMemoryDb2(path) {
|
|
2054
2166
|
return path === ":memory:" || path.startsWith("file::memory:");
|
|
2055
2167
|
}
|
|
2056
2168
|
function findNearestMementosDb(startDir) {
|
|
2057
|
-
let dir =
|
|
2169
|
+
let dir = resolve3(startDir);
|
|
2058
2170
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
2059
|
-
const legacyHomeDb =
|
|
2171
|
+
const legacyHomeDb = resolve3(home, ".mementos", "mementos.db");
|
|
2060
2172
|
while (true) {
|
|
2061
|
-
const candidate =
|
|
2062
|
-
if (
|
|
2173
|
+
const candidate = join6(dir, ".mementos", "mementos.db");
|
|
2174
|
+
if (existsSync4(candidate) && resolve3(candidate) !== legacyHomeDb)
|
|
2063
2175
|
return candidate;
|
|
2064
2176
|
const parent = dirname2(dir);
|
|
2065
2177
|
if (parent === dir)
|
|
@@ -2069,9 +2181,9 @@ function findNearestMementosDb(startDir) {
|
|
|
2069
2181
|
return null;
|
|
2070
2182
|
}
|
|
2071
2183
|
function findGitRoot2(startDir) {
|
|
2072
|
-
let dir =
|
|
2184
|
+
let dir = resolve3(startDir);
|
|
2073
2185
|
while (true) {
|
|
2074
|
-
if (
|
|
2186
|
+
if (existsSync4(join6(dir, ".git")))
|
|
2075
2187
|
return dir;
|
|
2076
2188
|
const parent = dirname2(dir);
|
|
2077
2189
|
if (parent === dir)
|
|
@@ -2082,10 +2194,10 @@ function findGitRoot2(startDir) {
|
|
|
2082
2194
|
}
|
|
2083
2195
|
function migrateGlobalDir() {
|
|
2084
2196
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
2085
|
-
const newDir =
|
|
2086
|
-
const oldDir =
|
|
2087
|
-
if (!
|
|
2088
|
-
mkdirSync3(
|
|
2197
|
+
const newDir = getDataRoot();
|
|
2198
|
+
const oldDir = join6(home, ".mementos");
|
|
2199
|
+
if (!existsSync4(newDir) && existsSync4(oldDir)) {
|
|
2200
|
+
mkdirSync3(dirname2(newDir), { recursive: true });
|
|
2089
2201
|
cpSync2(oldDir, newDir, { recursive: true });
|
|
2090
2202
|
}
|
|
2091
2203
|
}
|
|
@@ -2102,18 +2214,17 @@ function getDbPath2() {
|
|
|
2102
2214
|
if (process.env["MEMENTOS_DB_SCOPE"] === "project") {
|
|
2103
2215
|
const gitRoot = findGitRoot2(cwd);
|
|
2104
2216
|
if (gitRoot) {
|
|
2105
|
-
return
|
|
2217
|
+
return join6(gitRoot, ".mementos", "mementos.db");
|
|
2106
2218
|
}
|
|
2107
2219
|
}
|
|
2108
2220
|
migrateGlobalDir();
|
|
2109
|
-
|
|
2110
|
-
return join4(home, ".hasna", "mementos", "mementos.db");
|
|
2221
|
+
return join6(getDataRoot(), "mementos.db");
|
|
2111
2222
|
}
|
|
2112
2223
|
function ensureDir2(filePath) {
|
|
2113
2224
|
if (isInMemoryDb2(filePath))
|
|
2114
2225
|
return;
|
|
2115
|
-
const dir = dirname2(
|
|
2116
|
-
if (!
|
|
2226
|
+
const dir = dirname2(resolve3(filePath));
|
|
2227
|
+
if (!existsSync4(dir)) {
|
|
2117
2228
|
mkdirSync3(dir, { recursive: true });
|
|
2118
2229
|
}
|
|
2119
2230
|
}
|
|
@@ -2251,6 +2362,7 @@ var init_database = __esm(() => {
|
|
|
2251
2362
|
init_storage();
|
|
2252
2363
|
init_api_mode();
|
|
2253
2364
|
init_migrations();
|
|
2365
|
+
init_paths();
|
|
2254
2366
|
ALLOWED_TABLES = new Set([
|
|
2255
2367
|
"memories",
|
|
2256
2368
|
"agents",
|
|
@@ -2841,12 +2953,22 @@ function createMemory(input, dedupeMode = "merge", db) {
|
|
|
2841
2953
|
const effectiveMode = dedupeMode === "overwrite" ? "merge" : dedupeMode === "version-fork" ? "create" : dedupeMode;
|
|
2842
2954
|
if (effectiveMode === "error") {
|
|
2843
2955
|
const existing = d.query(`SELECT id, agent_id, updated_at FROM memories
|
|
2844
|
-
WHERE key = ? AND scope = ? AND COALESCE(project_id, '') = ?
|
|
2956
|
+
WHERE key = ? AND scope = ? AND COALESCE(project_id, '') = ?
|
|
2845
2957
|
LIMIT 1`).get(input.key, input.scope || "private", input.project_id || "");
|
|
2846
2958
|
if (existing) {
|
|
2847
2959
|
throw new MemoryConflictError(input.key, existing);
|
|
2848
2960
|
}
|
|
2849
2961
|
}
|
|
2962
|
+
if (effectiveMode === "create") {
|
|
2963
|
+
const existing = d.query(`SELECT id, agent_id, updated_at FROM memories
|
|
2964
|
+
WHERE key = ? AND scope = ?
|
|
2965
|
+
AND COALESCE(agent_id, '') = ?
|
|
2966
|
+
AND COALESCE(project_id, '') = ?
|
|
2967
|
+
AND COALESCE(session_id, '') = ?`).get(input.key, input.scope || "private", input.agent_id || "", input.project_id || "", input.session_id || "");
|
|
2968
|
+
if (existing) {
|
|
2969
|
+
throw new MemoryConflictError(input.key, existing);
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2850
2972
|
if (effectiveMode === "merge") {
|
|
2851
2973
|
const existing = d.query(`SELECT id, version FROM memories
|
|
2852
2974
|
WHERE key = ? AND scope = ?
|
|
@@ -3498,6 +3620,17 @@ function updateMemory(id, input, db) {
|
|
|
3498
3620
|
if (existing.version !== input.version) {
|
|
3499
3621
|
throw new VersionConflictError(id, input.version, existing.version);
|
|
3500
3622
|
}
|
|
3623
|
+
if (input.scope !== undefined && input.scope !== existing.scope) {
|
|
3624
|
+
const conflict = d.query(`SELECT id, agent_id, updated_at FROM memories
|
|
3625
|
+
WHERE key = ? AND scope = ?
|
|
3626
|
+
AND COALESCE(agent_id, '') = ?
|
|
3627
|
+
AND COALESCE(project_id, '') = ?
|
|
3628
|
+
AND COALESCE(session_id, '') = ?
|
|
3629
|
+
AND id != ?`).get(existing.key, input.scope, existing.agent_id || "", existing.project_id || "", existing.session_id || "", memoryId);
|
|
3630
|
+
if (conflict) {
|
|
3631
|
+
throw new MemoryConflictError(existing.key, conflict);
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3501
3634
|
const sets = ["version = version + 1", "updated_at = ?"];
|
|
3502
3635
|
const params = [now()];
|
|
3503
3636
|
if (input.value !== undefined) {
|
|
@@ -4538,7 +4671,9 @@ function scoreResults(rows, queryLower, graphBoostedIds) {
|
|
|
4538
4671
|
scored.sort((a, b) => {
|
|
4539
4672
|
if (b.score !== a.score)
|
|
4540
4673
|
return b.score - a.score;
|
|
4541
|
-
|
|
4674
|
+
if (b.memory.importance !== a.memory.importance)
|
|
4675
|
+
return b.memory.importance - a.memory.importance;
|
|
4676
|
+
return a.memory.id.localeCompare(b.memory.id);
|
|
4542
4677
|
});
|
|
4543
4678
|
return scored;
|
|
4544
4679
|
}
|
|
@@ -10432,7 +10567,7 @@ var init_zod = __esm(() => {
|
|
|
10432
10567
|
init_external();
|
|
10433
10568
|
});
|
|
10434
10569
|
|
|
10435
|
-
// ../../node_modules/.bun/@ai-sdk+provider@3.0.
|
|
10570
|
+
// ../../node_modules/.bun/@ai-sdk+provider@3.0.15/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
10436
10571
|
function getErrorMessage(error) {
|
|
10437
10572
|
if (error == null) {
|
|
10438
10573
|
return "unknown error";
|
|
@@ -10464,7 +10599,7 @@ function isJSONObject(value) {
|
|
|
10464
10599
|
return value != null && typeof value === "object" && Object.entries(value).every(([key, val]) => typeof key === "string" && (val === undefined || isJSONValue(val)));
|
|
10465
10600
|
}
|
|
10466
10601
|
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;
|
|
10467
|
-
var
|
|
10602
|
+
var init_dist2 = __esm(() => {
|
|
10468
10603
|
symbol = Symbol.for(marker);
|
|
10469
10604
|
AISDKError = class _AISDKError extends (_b = Error, _a = symbol, _b) {
|
|
10470
10605
|
constructor({
|
|
@@ -20048,7 +20183,7 @@ class JSONSchemaGenerator {
|
|
|
20048
20183
|
if (val === undefined) {
|
|
20049
20184
|
if (this.unrepresentable === "throw") {
|
|
20050
20185
|
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
20051
|
-
}
|
|
20186
|
+
}
|
|
20052
20187
|
} else if (typeof val === "bigint") {
|
|
20053
20188
|
if (this.unrepresentable === "throw") {
|
|
20054
20189
|
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
@@ -22097,7 +22232,7 @@ var init_v3 = __esm(() => {
|
|
|
22097
22232
|
init_external();
|
|
22098
22233
|
});
|
|
22099
22234
|
|
|
22100
|
-
// ../../node_modules/.bun/eventsource-parser@3.1.
|
|
22235
|
+
// ../../node_modules/.bun/eventsource-parser@3.1.1/node_modules/eventsource-parser/dist/index.js
|
|
22101
22236
|
function noop(_arg) {}
|
|
22102
22237
|
function createParser(config2) {
|
|
22103
22238
|
if (typeof config2 == "function")
|
|
@@ -22184,7 +22319,7 @@ ${value2}`, dataLines++;
|
|
|
22184
22319
|
}
|
|
22185
22320
|
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
22186
22321
|
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
22187
|
-
|
|
22322
|
+
value2.includes("\x00") || (id = value2);
|
|
22188
22323
|
return;
|
|
22189
22324
|
}
|
|
22190
22325
|
if (firstCharCode === 58) {
|
|
@@ -22212,7 +22347,7 @@ ${value2}`, dataLines++;
|
|
|
22212
22347
|
${value}`, dataLines++;
|
|
22213
22348
|
break;
|
|
22214
22349
|
case "id":
|
|
22215
|
-
|
|
22350
|
+
value.includes("\x00") || (id = value);
|
|
22216
22351
|
break;
|
|
22217
22352
|
case "retry":
|
|
22218
22353
|
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
@@ -22249,7 +22384,7 @@ function isEventPrefix(chunk, i, firstCharCode) {
|
|
|
22249
22384
|
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;
|
|
22250
22385
|
}
|
|
22251
22386
|
var ParseError, LF = 10, CR = 13, SPACE = 32;
|
|
22252
|
-
var
|
|
22387
|
+
var init_dist3 = __esm(() => {
|
|
22253
22388
|
ParseError = class ParseError extends Error {
|
|
22254
22389
|
constructor(message, options) {
|
|
22255
22390
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
@@ -22257,10 +22392,10 @@ var init_dist2 = __esm(() => {
|
|
|
22257
22392
|
};
|
|
22258
22393
|
});
|
|
22259
22394
|
|
|
22260
|
-
// ../../node_modules/.bun/eventsource-parser@3.1.
|
|
22395
|
+
// ../../node_modules/.bun/eventsource-parser@3.1.1/node_modules/eventsource-parser/dist/stream.js
|
|
22261
22396
|
var EventSourceParserStream;
|
|
22262
22397
|
var init_stream = __esm(() => {
|
|
22263
|
-
|
|
22398
|
+
init_dist3();
|
|
22264
22399
|
EventSourceParserStream = class EventSourceParserStream extends TransformStream {
|
|
22265
22400
|
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
22266
22401
|
let parser;
|
|
@@ -22286,7 +22421,7 @@ var init_stream = __esm(() => {
|
|
|
22286
22421
|
};
|
|
22287
22422
|
});
|
|
22288
22423
|
|
|
22289
|
-
// ../../node_modules/.bun/@ai-sdk+provider-utils@4.0.
|
|
22424
|
+
// ../../node_modules/.bun/@ai-sdk+provider-utils@4.0.46+27912429049419a2/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
22290
22425
|
function combineHeaders(...headers) {
|
|
22291
22426
|
return headers.reduce((combinedHeaders, currentHeaders) => ({
|
|
22292
22427
|
...combinedHeaders,
|
|
@@ -22627,11 +22762,10 @@ async function loadNodeModule(id) {
|
|
|
22627
22762
|
var _a22;
|
|
22628
22763
|
const processWithBuiltins = globalThis.process;
|
|
22629
22764
|
const builtinModule = (_a22 = processWithBuiltins == null ? undefined : processWithBuiltins.getBuiltinModule) == null ? undefined : _a22.call(processWithBuiltins, id);
|
|
22630
|
-
|
|
22631
|
-
}
|
|
22632
|
-
|
|
22633
|
-
|
|
22634
|
-
return dynamicImport(id);
|
|
22765
|
+
if (builtinModule == null) {
|
|
22766
|
+
throw new Error(`Node.js built-in module ${id} is unavailable`);
|
|
22767
|
+
}
|
|
22768
|
+
return builtinModule;
|
|
22635
22769
|
}
|
|
22636
22770
|
function getCurrentModulePath() {
|
|
22637
22771
|
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
@@ -22730,7 +22864,7 @@ async function readResponseWithSizeLimit({
|
|
|
22730
22864
|
} finally {
|
|
22731
22865
|
try {
|
|
22732
22866
|
await reader.cancel();
|
|
22733
|
-
} finally {
|
|
22867
|
+
} catch (e) {} finally {
|
|
22734
22868
|
reader.releaseLock();
|
|
22735
22869
|
}
|
|
22736
22870
|
}
|
|
@@ -23995,7 +24129,7 @@ function createProviderToolFactoryWithOutputSchema({
|
|
|
23995
24129
|
supportsDeferredResults
|
|
23996
24130
|
});
|
|
23997
24131
|
}
|
|
23998
|
-
async function
|
|
24132
|
+
async function resolve5(value) {
|
|
23999
24133
|
if (typeof value === "function") {
|
|
24000
24134
|
value = value();
|
|
24001
24135
|
}
|
|
@@ -24130,7 +24264,7 @@ var DelayedPromise = class {
|
|
|
24130
24264
|
isPending() {
|
|
24131
24265
|
return this.status.type === "pending";
|
|
24132
24266
|
}
|
|
24133
|
-
}, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, safeNodeFetchPromise, initialGlobalFetch, initialGlobalFetchIsNodeDefault,
|
|
24267
|
+
}, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, safeNodeFetchPromise, initialGlobalFetch, initialGlobalFetchIsNodeDefault, MAX_DOWNLOAD_REDIRECTS = 10, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
|
|
24134
24268
|
prefix,
|
|
24135
24269
|
size = 16,
|
|
24136
24270
|
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
@@ -24154,7 +24288,7 @@ var DelayedPromise = class {
|
|
|
24154
24288
|
});
|
|
24155
24289
|
}
|
|
24156
24290
|
return () => `${prefix}${separator}${generator()}`;
|
|
24157
|
-
}, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.
|
|
24291
|
+
}, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.46", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
|
|
24158
24292
|
url: url2,
|
|
24159
24293
|
headers = {},
|
|
24160
24294
|
successfulResponseHandler,
|
|
@@ -24674,23 +24808,23 @@ var DelayedPromise = class {
|
|
|
24674
24808
|
});
|
|
24675
24809
|
}
|
|
24676
24810
|
};
|
|
24677
|
-
var
|
|
24678
|
-
|
|
24679
|
-
|
|
24680
|
-
|
|
24681
|
-
|
|
24682
|
-
|
|
24683
|
-
|
|
24684
|
-
|
|
24685
|
-
|
|
24811
|
+
var init_dist4 = __esm(() => {
|
|
24812
|
+
init_dist2();
|
|
24813
|
+
init_dist2();
|
|
24814
|
+
init_dist2();
|
|
24815
|
+
init_dist2();
|
|
24816
|
+
init_dist2();
|
|
24817
|
+
init_dist2();
|
|
24818
|
+
init_dist2();
|
|
24819
|
+
init_dist2();
|
|
24686
24820
|
init_v4();
|
|
24687
24821
|
init_v3();
|
|
24688
24822
|
init_v3();
|
|
24689
24823
|
init_v3();
|
|
24690
24824
|
init_stream();
|
|
24691
|
-
|
|
24692
|
-
|
|
24693
|
-
|
|
24825
|
+
init_dist2();
|
|
24826
|
+
init_dist2();
|
|
24827
|
+
init_dist2();
|
|
24694
24828
|
({ btoa, atob: atob2 } = globalThis);
|
|
24695
24829
|
marker15 = `vercel.ai.error.${name14}`;
|
|
24696
24830
|
symbol17 = Symbol.for(marker15);
|
|
@@ -24783,7 +24917,7 @@ var init_dist3 = __esm(() => {
|
|
|
24783
24917
|
textDecoder = new TextDecoder;
|
|
24784
24918
|
});
|
|
24785
24919
|
|
|
24786
|
-
// ../../node_modules/.bun/@ai-sdk+anthropic@3.0.
|
|
24920
|
+
// ../../node_modules/.bun/@ai-sdk+anthropic@3.0.111+27912429049419a2/node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
24787
24921
|
var exports_dist = {};
|
|
24788
24922
|
__export(exports_dist, {
|
|
24789
24923
|
forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep,
|
|
@@ -25241,7 +25375,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25241
25375
|
cacheControlValidator,
|
|
25242
25376
|
toolNameMapping
|
|
25243
25377
|
}) {
|
|
25244
|
-
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u
|
|
25378
|
+
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
25245
25379
|
const betas = /* @__PURE__ */ new Set;
|
|
25246
25380
|
const blocks = groupIntoBlocks(prompt);
|
|
25247
25381
|
const validator = cacheControlValidator || new CacheControlValidator;
|
|
@@ -25629,6 +25763,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25629
25763
|
break;
|
|
25630
25764
|
}
|
|
25631
25765
|
case "tool-call": {
|
|
25766
|
+
const caller = getAnthropicCaller(part.providerOptions);
|
|
25632
25767
|
if (part.providerExecuted) {
|
|
25633
25768
|
const providerToolName = toolNameMapping.toProviderToolName(part.toolName);
|
|
25634
25769
|
const isMcpToolUse = ((_l = (_k = part.providerOptions) == null ? undefined : _k.anthropic) == null ? undefined : _l.type) === "mcp-tool-use";
|
|
@@ -25657,6 +25792,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25657
25792
|
id: part.toolCallId,
|
|
25658
25793
|
name: subtoolName,
|
|
25659
25794
|
input,
|
|
25795
|
+
...caller && { caller },
|
|
25660
25796
|
cache_control: cacheControl
|
|
25661
25797
|
});
|
|
25662
25798
|
} else if (providerToolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && part.input.type === "programmatic-tool-call") {
|
|
@@ -25666,6 +25802,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25666
25802
|
id: part.toolCallId,
|
|
25667
25803
|
name: "code_execution",
|
|
25668
25804
|
input: inputWithoutType,
|
|
25805
|
+
...caller && { caller },
|
|
25669
25806
|
cache_control: cacheControl
|
|
25670
25807
|
});
|
|
25671
25808
|
} else {
|
|
@@ -25675,6 +25812,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25675
25812
|
id: part.toolCallId,
|
|
25676
25813
|
name: providerToolName,
|
|
25677
25814
|
input: part.input,
|
|
25815
|
+
...caller && { caller },
|
|
25678
25816
|
cache_control: cacheControl
|
|
25679
25817
|
});
|
|
25680
25818
|
} else if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
|
|
@@ -25683,6 +25821,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25683
25821
|
id: part.toolCallId,
|
|
25684
25822
|
name: providerToolName,
|
|
25685
25823
|
input: part.input,
|
|
25824
|
+
...caller && { caller },
|
|
25686
25825
|
cache_control: cacheControl
|
|
25687
25826
|
});
|
|
25688
25827
|
} else if (providerToolName === "advisor") {
|
|
@@ -25691,6 +25830,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25691
25830
|
id: part.toolCallId,
|
|
25692
25831
|
name: "advisor",
|
|
25693
25832
|
input: {},
|
|
25833
|
+
...caller && { caller },
|
|
25694
25834
|
cache_control: cacheControl
|
|
25695
25835
|
});
|
|
25696
25836
|
} else {
|
|
@@ -25702,11 +25842,6 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25702
25842
|
}
|
|
25703
25843
|
break;
|
|
25704
25844
|
}
|
|
25705
|
-
const callerOptions = (_o = part.providerOptions) == null ? undefined : _o.anthropic;
|
|
25706
|
-
const caller = (callerOptions == null ? undefined : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
|
|
25707
|
-
type: callerOptions.caller.type,
|
|
25708
|
-
tool_id: callerOptions.caller.toolId
|
|
25709
|
-
} : callerOptions.caller.type === "direct" ? { type: "direct" } : undefined : undefined;
|
|
25710
25845
|
anthropicContent.push({
|
|
25711
25846
|
type: "tool_use",
|
|
25712
25847
|
id: part.toolCallId,
|
|
@@ -25719,6 +25854,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25719
25854
|
}
|
|
25720
25855
|
case "tool-result": {
|
|
25721
25856
|
const providerToolName = toolNameMapping.toProviderToolName(part.toolName);
|
|
25857
|
+
const caller = getAnthropicCaller(part.providerOptions);
|
|
25722
25858
|
if (mcpToolUseIds.has(part.toolCallId)) {
|
|
25723
25859
|
const output = part.output;
|
|
25724
25860
|
if (output.type !== "json" && output.type !== "error-json") {
|
|
@@ -25752,7 +25888,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25752
25888
|
tool_use_id: part.toolCallId,
|
|
25753
25889
|
content: {
|
|
25754
25890
|
type: "code_execution_tool_result_error",
|
|
25755
|
-
error_code: (
|
|
25891
|
+
error_code: (_o = errorInfo.errorCode) != null ? _o : "unknown"
|
|
25756
25892
|
},
|
|
25757
25893
|
cache_control: cacheControl
|
|
25758
25894
|
});
|
|
@@ -25763,7 +25899,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25763
25899
|
cache_control: cacheControl,
|
|
25764
25900
|
content: {
|
|
25765
25901
|
type: "bash_code_execution_tool_result_error",
|
|
25766
|
-
error_code: (
|
|
25902
|
+
error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
|
|
25767
25903
|
}
|
|
25768
25904
|
});
|
|
25769
25905
|
}
|
|
@@ -25796,7 +25932,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25796
25932
|
stdout: codeExecutionOutput.stdout,
|
|
25797
25933
|
stderr: codeExecutionOutput.stderr,
|
|
25798
25934
|
return_code: codeExecutionOutput.return_code,
|
|
25799
|
-
content: (
|
|
25935
|
+
content: (_q = codeExecutionOutput.content) != null ? _q : []
|
|
25800
25936
|
},
|
|
25801
25937
|
cache_control: cacheControl
|
|
25802
25938
|
});
|
|
@@ -25814,7 +25950,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25814
25950
|
encrypted_stdout: codeExecutionOutput.encrypted_stdout,
|
|
25815
25951
|
stderr: codeExecutionOutput.stderr,
|
|
25816
25952
|
return_code: codeExecutionOutput.return_code,
|
|
25817
|
-
content: (
|
|
25953
|
+
content: (_r = codeExecutionOutput.content) != null ? _r : []
|
|
25818
25954
|
},
|
|
25819
25955
|
cache_control: cacheControl
|
|
25820
25956
|
});
|
|
@@ -25833,7 +25969,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25833
25969
|
stdout: codeExecutionOutput.stdout,
|
|
25834
25970
|
stderr: codeExecutionOutput.stderr,
|
|
25835
25971
|
return_code: codeExecutionOutput.return_code,
|
|
25836
|
-
content: (
|
|
25972
|
+
content: (_s = codeExecutionOutput.content) != null ? _s : []
|
|
25837
25973
|
},
|
|
25838
25974
|
cache_control: cacheControl
|
|
25839
25975
|
});
|
|
@@ -25869,8 +26005,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25869
26005
|
tool_use_id: part.toolCallId,
|
|
25870
26006
|
content: {
|
|
25871
26007
|
type: "web_fetch_tool_result_error",
|
|
25872
|
-
error_code: (
|
|
26008
|
+
error_code: (_t = (await extractErrorValue(output.value)).errorCode) != null ? _t : "unavailable"
|
|
25873
26009
|
},
|
|
26010
|
+
...caller && { caller },
|
|
25874
26011
|
cache_control: cacheControl
|
|
25875
26012
|
});
|
|
25876
26013
|
break;
|
|
@@ -25904,6 +26041,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25904
26041
|
}
|
|
25905
26042
|
}
|
|
25906
26043
|
},
|
|
26044
|
+
...caller && { caller },
|
|
25907
26045
|
cache_control: cacheControl
|
|
25908
26046
|
});
|
|
25909
26047
|
break;
|
|
@@ -25916,8 +26054,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25916
26054
|
tool_use_id: part.toolCallId,
|
|
25917
26055
|
content: {
|
|
25918
26056
|
type: "web_search_tool_result_error",
|
|
25919
|
-
error_code: (
|
|
26057
|
+
error_code: (_u = (await extractErrorValue(output.value)).errorCode) != null ? _u : "unavailable"
|
|
25920
26058
|
},
|
|
26059
|
+
...caller && { caller },
|
|
25921
26060
|
cache_control: cacheControl
|
|
25922
26061
|
});
|
|
25923
26062
|
break;
|
|
@@ -25943,6 +26082,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
25943
26082
|
encrypted_content: result.encryptedContent,
|
|
25944
26083
|
type: result.type
|
|
25945
26084
|
})),
|
|
26085
|
+
...caller && { caller },
|
|
25946
26086
|
cache_control: cacheControl
|
|
25947
26087
|
});
|
|
25948
26088
|
break;
|
|
@@ -26111,6 +26251,17 @@ function moveToolUseBlocksToEnd(content) {
|
|
|
26111
26251
|
flushSegment();
|
|
26112
26252
|
return result;
|
|
26113
26253
|
}
|
|
26254
|
+
function getAnthropicCaller(providerOptions) {
|
|
26255
|
+
var _a16;
|
|
26256
|
+
const caller = (_a16 = providerOptions == null ? undefined : providerOptions.anthropic) == null ? undefined : _a16.caller;
|
|
26257
|
+
if (((caller == null ? undefined : caller.type) === "code_execution_20250825" || (caller == null ? undefined : caller.type) === "code_execution_20260120") && caller.toolId) {
|
|
26258
|
+
return {
|
|
26259
|
+
type: caller.type,
|
|
26260
|
+
tool_id: caller.toolId
|
|
26261
|
+
};
|
|
26262
|
+
}
|
|
26263
|
+
return (caller == null ? undefined : caller.type) === "direct" ? { type: "direct" } : undefined;
|
|
26264
|
+
}
|
|
26114
26265
|
function mapAnthropicStopReason({
|
|
26115
26266
|
finishReason,
|
|
26116
26267
|
isJsonResponseFromTool
|
|
@@ -26287,6 +26438,16 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
26287
26438
|
}
|
|
26288
26439
|
};
|
|
26289
26440
|
}
|
|
26441
|
+
function getAnthropicCallerInfo(caller) {
|
|
26442
|
+
return caller == null ? undefined : {
|
|
26443
|
+
type: caller.type,
|
|
26444
|
+
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
26445
|
+
};
|
|
26446
|
+
}
|
|
26447
|
+
function getAnthropicCallerMetadata(caller) {
|
|
26448
|
+
const callerInfo = getAnthropicCallerInfo(caller);
|
|
26449
|
+
return callerInfo == null ? {} : { providerMetadata: { anthropic: { caller: callerInfo } } };
|
|
26450
|
+
}
|
|
26290
26451
|
function getModelCapabilities(modelId) {
|
|
26291
26452
|
if (modelId.includes("claude-opus-5")) {
|
|
26292
26453
|
return {
|
|
@@ -26515,7 +26676,7 @@ function forwardAnthropicContainerIdFromLastStep({
|
|
|
26515
26676
|
}
|
|
26516
26677
|
return;
|
|
26517
26678
|
}
|
|
26518
|
-
var VERSION2 = "3.0.
|
|
26679
|
+
var VERSION2 = "3.0.111", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicStopDetailsSchema, anthropicToolCallCallerSchema, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicSystemMessageProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
|
|
26519
26680
|
constructor() {
|
|
26520
26681
|
this.breakpointCount = 0;
|
|
26521
26682
|
this.warnings = [];
|
|
@@ -27023,11 +27184,11 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27023
27184
|
betas,
|
|
27024
27185
|
headers
|
|
27025
27186
|
}) {
|
|
27026
|
-
return combineHeaders(await
|
|
27187
|
+
return combineHeaders(await resolve5(this.config.headers), headers, betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {});
|
|
27027
27188
|
}
|
|
27028
27189
|
async getBetasFromHeaders(requestHeaders) {
|
|
27029
27190
|
var _a16, _b16;
|
|
27030
|
-
const configHeaders = await
|
|
27191
|
+
const configHeaders = await resolve5(this.config.headers);
|
|
27031
27192
|
const configBetaHeader = (_a16 = configHeaders["anthropic-beta"]) != null ? _a16 : "";
|
|
27032
27193
|
const requestBetaHeader = (_b16 = requestHeaders == null ? undefined : requestHeaders["anthropic-beta"]) != null ? _b16 : "";
|
|
27033
27194
|
return new Set([
|
|
@@ -27174,23 +27335,12 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27174
27335
|
text: JSON.stringify(part.input)
|
|
27175
27336
|
});
|
|
27176
27337
|
} else {
|
|
27177
|
-
const caller = part.caller;
|
|
27178
|
-
const callerInfo = caller ? {
|
|
27179
|
-
type: caller.type,
|
|
27180
|
-
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
27181
|
-
} : undefined;
|
|
27182
27338
|
content.push({
|
|
27183
27339
|
type: "tool-call",
|
|
27184
27340
|
toolCallId: part.id,
|
|
27185
27341
|
toolName: part.name,
|
|
27186
27342
|
input: JSON.stringify(part.input),
|
|
27187
|
-
...
|
|
27188
|
-
providerMetadata: {
|
|
27189
|
-
anthropic: {
|
|
27190
|
-
caller: callerInfo
|
|
27191
|
-
}
|
|
27192
|
-
}
|
|
27193
|
-
}
|
|
27343
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
27194
27344
|
});
|
|
27195
27345
|
}
|
|
27196
27346
|
break;
|
|
@@ -27204,7 +27354,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27204
27354
|
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
27205
27355
|
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
27206
27356
|
providerExecuted: true,
|
|
27207
|
-
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {}
|
|
27357
|
+
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
27358
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
27208
27359
|
});
|
|
27209
27360
|
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
27210
27361
|
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;
|
|
@@ -27214,7 +27365,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27214
27365
|
toolName: toolNameMapping.toCustomToolName(part.name),
|
|
27215
27366
|
input: JSON.stringify(inputToSerialize),
|
|
27216
27367
|
providerExecuted: true,
|
|
27217
|
-
...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {}
|
|
27368
|
+
...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {},
|
|
27369
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
27218
27370
|
});
|
|
27219
27371
|
} else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
|
|
27220
27372
|
serverToolCalls[part.id] = part.name;
|
|
@@ -27223,7 +27375,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27223
27375
|
toolCallId: part.id,
|
|
27224
27376
|
toolName: toolNameMapping.toCustomToolName(part.name),
|
|
27225
27377
|
input: JSON.stringify(part.input),
|
|
27226
|
-
providerExecuted: true
|
|
27378
|
+
providerExecuted: true,
|
|
27379
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
27227
27380
|
});
|
|
27228
27381
|
} else if (part.name === "advisor") {
|
|
27229
27382
|
content.push({
|
|
@@ -27231,7 +27384,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27231
27384
|
toolCallId: part.id,
|
|
27232
27385
|
toolName: toolNameMapping.toCustomToolName("advisor"),
|
|
27233
27386
|
input: JSON.stringify(part.input),
|
|
27234
|
-
providerExecuted: true
|
|
27387
|
+
providerExecuted: true,
|
|
27388
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
27235
27389
|
});
|
|
27236
27390
|
}
|
|
27237
27391
|
break;
|
|
@@ -27290,7 +27444,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27290
27444
|
data: part.content.content.source.data
|
|
27291
27445
|
}
|
|
27292
27446
|
}
|
|
27293
|
-
}
|
|
27447
|
+
},
|
|
27448
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
27294
27449
|
});
|
|
27295
27450
|
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
27296
27451
|
content.push({
|
|
@@ -27301,7 +27456,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27301
27456
|
result: {
|
|
27302
27457
|
type: "web_fetch_tool_result_error",
|
|
27303
27458
|
errorCode: part.content.error_code
|
|
27304
|
-
}
|
|
27459
|
+
},
|
|
27460
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
27305
27461
|
});
|
|
27306
27462
|
}
|
|
27307
27463
|
break;
|
|
@@ -27321,7 +27477,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27321
27477
|
encryptedContent: result.encrypted_content,
|
|
27322
27478
|
type: result.type
|
|
27323
27479
|
};
|
|
27324
|
-
})
|
|
27480
|
+
}),
|
|
27481
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
27325
27482
|
});
|
|
27326
27483
|
for (const result of part.content) {
|
|
27327
27484
|
content.push({
|
|
@@ -27346,7 +27503,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27346
27503
|
result: {
|
|
27347
27504
|
type: "web_search_tool_result_error",
|
|
27348
27505
|
errorCode: part.content.error_code
|
|
27349
|
-
}
|
|
27506
|
+
},
|
|
27507
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
27350
27508
|
});
|
|
27351
27509
|
}
|
|
27352
27510
|
break;
|
|
@@ -27687,11 +27845,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27687
27845
|
id: String(value.index)
|
|
27688
27846
|
});
|
|
27689
27847
|
} else {
|
|
27690
|
-
const
|
|
27691
|
-
const callerInfo = caller ? {
|
|
27692
|
-
type: caller.type,
|
|
27693
|
-
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
27694
|
-
} : undefined;
|
|
27848
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
27695
27849
|
const hasNonEmptyInput = part.input && Object.keys(part.input).length > 0;
|
|
27696
27850
|
const initialInput = hasNonEmptyInput ? JSON.stringify(part.input) : "";
|
|
27697
27851
|
contentBlocks[value.index] = {
|
|
@@ -27711,6 +27865,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27711
27865
|
return;
|
|
27712
27866
|
}
|
|
27713
27867
|
case "server_tool_use": {
|
|
27868
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
27714
27869
|
if ([
|
|
27715
27870
|
"web_fetch",
|
|
27716
27871
|
"web_search",
|
|
@@ -27731,7 +27886,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27731
27886
|
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
27732
27887
|
firstDelta: finalInput.length === 0,
|
|
27733
27888
|
providerToolName,
|
|
27734
|
-
providerToolInputType
|
|
27889
|
+
providerToolInputType,
|
|
27890
|
+
...callerInfo && { caller: callerInfo }
|
|
27735
27891
|
};
|
|
27736
27892
|
controller.enqueue({
|
|
27737
27893
|
type: "tool-input-start",
|
|
@@ -27750,7 +27906,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27750
27906
|
input: "",
|
|
27751
27907
|
providerExecuted: true,
|
|
27752
27908
|
firstDelta: true,
|
|
27753
|
-
providerToolName: part.name
|
|
27909
|
+
providerToolName: part.name,
|
|
27910
|
+
...callerInfo && { caller: callerInfo }
|
|
27754
27911
|
};
|
|
27755
27912
|
controller.enqueue({
|
|
27756
27913
|
type: "tool-input-start",
|
|
@@ -27767,7 +27924,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27767
27924
|
input: "{}",
|
|
27768
27925
|
providerExecuted: true,
|
|
27769
27926
|
firstDelta: true,
|
|
27770
|
-
providerToolName: part.name
|
|
27927
|
+
providerToolName: part.name,
|
|
27928
|
+
...callerInfo && { caller: callerInfo }
|
|
27771
27929
|
};
|
|
27772
27930
|
controller.enqueue({
|
|
27773
27931
|
type: "tool-input-start",
|
|
@@ -27802,7 +27960,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27802
27960
|
data: part.content.content.source.data
|
|
27803
27961
|
}
|
|
27804
27962
|
}
|
|
27805
|
-
}
|
|
27963
|
+
},
|
|
27964
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
27806
27965
|
});
|
|
27807
27966
|
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
27808
27967
|
controller.enqueue({
|
|
@@ -27813,7 +27972,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27813
27972
|
result: {
|
|
27814
27973
|
type: "web_fetch_tool_result_error",
|
|
27815
27974
|
errorCode: part.content.error_code
|
|
27816
|
-
}
|
|
27975
|
+
},
|
|
27976
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
27817
27977
|
});
|
|
27818
27978
|
}
|
|
27819
27979
|
return;
|
|
@@ -27833,7 +27993,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27833
27993
|
encryptedContent: result.encrypted_content,
|
|
27834
27994
|
type: result.type
|
|
27835
27995
|
};
|
|
27836
|
-
})
|
|
27996
|
+
}),
|
|
27997
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
27837
27998
|
});
|
|
27838
27999
|
for (const result of part.content) {
|
|
27839
28000
|
controller.enqueue({
|
|
@@ -27858,7 +28019,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
27858
28019
|
result: {
|
|
27859
28020
|
type: "web_search_tool_result_error",
|
|
27860
28021
|
errorCode: part.content.error_code
|
|
27861
|
-
}
|
|
28022
|
+
},
|
|
28023
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
27862
28024
|
});
|
|
27863
28025
|
}
|
|
27864
28026
|
return;
|
|
@@ -28236,11 +28398,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
28236
28398
|
for (let contentIndex = 0;contentIndex < value.message.content.length; contentIndex++) {
|
|
28237
28399
|
const part = value.message.content[contentIndex];
|
|
28238
28400
|
if (part.type === "tool_use") {
|
|
28239
|
-
const
|
|
28240
|
-
const callerInfo = caller ? {
|
|
28241
|
-
type: caller.type,
|
|
28242
|
-
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
28243
|
-
} : undefined;
|
|
28401
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
28244
28402
|
controller.enqueue({
|
|
28245
28403
|
type: "tool-input-start",
|
|
28246
28404
|
id: part.id,
|
|
@@ -28400,59 +28558,59 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
28400
28558
|
}, 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 = {}) => {
|
|
28401
28559
|
return factory11(args);
|
|
28402
28560
|
}, anthropicTools, ANTHROPIC_API_URL = "https://api.anthropic.com", ANTHROPIC_API_VERSIONED_URL, anthropic;
|
|
28403
|
-
var
|
|
28404
|
-
|
|
28405
|
-
|
|
28406
|
-
|
|
28407
|
-
|
|
28408
|
-
|
|
28561
|
+
var init_dist5 = __esm(() => {
|
|
28562
|
+
init_dist2();
|
|
28563
|
+
init_dist4();
|
|
28564
|
+
init_dist2();
|
|
28565
|
+
init_dist4();
|
|
28566
|
+
init_dist4();
|
|
28409
28567
|
init_v4();
|
|
28410
|
-
|
|
28568
|
+
init_dist4();
|
|
28411
28569
|
init_v4();
|
|
28412
28570
|
init_v4();
|
|
28413
|
-
|
|
28414
|
-
|
|
28571
|
+
init_dist2();
|
|
28572
|
+
init_dist4();
|
|
28415
28573
|
init_v4();
|
|
28416
|
-
|
|
28574
|
+
init_dist4();
|
|
28417
28575
|
init_v4();
|
|
28418
|
-
|
|
28576
|
+
init_dist4();
|
|
28419
28577
|
init_v4();
|
|
28420
|
-
|
|
28578
|
+
init_dist4();
|
|
28421
28579
|
init_v4();
|
|
28422
|
-
|
|
28580
|
+
init_dist4();
|
|
28423
28581
|
init_v4();
|
|
28424
|
-
|
|
28582
|
+
init_dist4();
|
|
28425
28583
|
init_v4();
|
|
28426
|
-
|
|
28427
|
-
|
|
28428
|
-
|
|
28429
|
-
|
|
28584
|
+
init_dist4();
|
|
28585
|
+
init_dist2();
|
|
28586
|
+
init_dist4();
|
|
28587
|
+
init_dist4();
|
|
28430
28588
|
init_v4();
|
|
28431
|
-
|
|
28589
|
+
init_dist4();
|
|
28432
28590
|
init_v4();
|
|
28433
|
-
|
|
28591
|
+
init_dist4();
|
|
28434
28592
|
init_v4();
|
|
28435
|
-
|
|
28593
|
+
init_dist4();
|
|
28436
28594
|
init_v4();
|
|
28437
|
-
|
|
28595
|
+
init_dist4();
|
|
28438
28596
|
init_v4();
|
|
28439
|
-
|
|
28597
|
+
init_dist4();
|
|
28440
28598
|
init_v4();
|
|
28441
|
-
|
|
28599
|
+
init_dist4();
|
|
28442
28600
|
init_v4();
|
|
28443
|
-
|
|
28601
|
+
init_dist4();
|
|
28444
28602
|
init_v4();
|
|
28445
|
-
|
|
28603
|
+
init_dist4();
|
|
28446
28604
|
init_v4();
|
|
28447
|
-
|
|
28605
|
+
init_dist4();
|
|
28448
28606
|
init_v4();
|
|
28449
|
-
|
|
28607
|
+
init_dist4();
|
|
28450
28608
|
init_v4();
|
|
28451
|
-
|
|
28609
|
+
init_dist4();
|
|
28452
28610
|
init_v4();
|
|
28453
|
-
|
|
28611
|
+
init_dist4();
|
|
28454
28612
|
init_v4();
|
|
28455
|
-
|
|
28613
|
+
init_dist4();
|
|
28456
28614
|
init_v4();
|
|
28457
28615
|
anthropicErrorDataSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
28458
28616
|
type: exports_external2.literal("error"),
|
|
@@ -28471,6 +28629,19 @@ var init_dist4 = __esm(() => {
|
|
|
28471
28629
|
explanation: exports_external2.string().nullish(),
|
|
28472
28630
|
recommended_model: exports_external2.string().nullish()
|
|
28473
28631
|
});
|
|
28632
|
+
anthropicToolCallCallerSchema = exports_external2.union([
|
|
28633
|
+
exports_external2.object({
|
|
28634
|
+
type: exports_external2.literal("code_execution_20250825"),
|
|
28635
|
+
tool_id: exports_external2.string()
|
|
28636
|
+
}),
|
|
28637
|
+
exports_external2.object({
|
|
28638
|
+
type: exports_external2.literal("code_execution_20260120"),
|
|
28639
|
+
tool_id: exports_external2.string()
|
|
28640
|
+
}),
|
|
28641
|
+
exports_external2.object({
|
|
28642
|
+
type: exports_external2.literal("direct")
|
|
28643
|
+
})
|
|
28644
|
+
]);
|
|
28474
28645
|
anthropicMessagesResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
28475
28646
|
type: exports_external2.literal("message"),
|
|
28476
28647
|
id: exports_external2.string().nullish(),
|
|
@@ -28523,34 +28694,14 @@ var init_dist4 = __esm(() => {
|
|
|
28523
28694
|
id: exports_external2.string(),
|
|
28524
28695
|
name: exports_external2.string(),
|
|
28525
28696
|
input: exports_external2.unknown(),
|
|
28526
|
-
caller:
|
|
28527
|
-
exports_external2.object({
|
|
28528
|
-
type: exports_external2.literal("code_execution_20250825"),
|
|
28529
|
-
tool_id: exports_external2.string()
|
|
28530
|
-
}),
|
|
28531
|
-
exports_external2.object({
|
|
28532
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
28533
|
-
tool_id: exports_external2.string()
|
|
28534
|
-
}),
|
|
28535
|
-
exports_external2.object({
|
|
28536
|
-
type: exports_external2.literal("direct")
|
|
28537
|
-
})
|
|
28538
|
-
]).optional()
|
|
28697
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
28539
28698
|
}),
|
|
28540
28699
|
exports_external2.object({
|
|
28541
28700
|
type: exports_external2.literal("server_tool_use"),
|
|
28542
28701
|
id: exports_external2.string(),
|
|
28543
28702
|
name: exports_external2.string(),
|
|
28544
28703
|
input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).nullish(),
|
|
28545
|
-
caller:
|
|
28546
|
-
exports_external2.object({
|
|
28547
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
28548
|
-
tool_id: exports_external2.string()
|
|
28549
|
-
}),
|
|
28550
|
-
exports_external2.object({
|
|
28551
|
-
type: exports_external2.literal("direct")
|
|
28552
|
-
})
|
|
28553
|
-
]).optional()
|
|
28704
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
28554
28705
|
}),
|
|
28555
28706
|
exports_external2.object({
|
|
28556
28707
|
type: exports_external2.literal("mcp_tool_use"),
|
|
@@ -28571,6 +28722,7 @@ var init_dist4 = __esm(() => {
|
|
|
28571
28722
|
exports_external2.object({
|
|
28572
28723
|
type: exports_external2.literal("web_fetch_tool_result"),
|
|
28573
28724
|
tool_use_id: exports_external2.string(),
|
|
28725
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
28574
28726
|
content: exports_external2.union([
|
|
28575
28727
|
exports_external2.object({
|
|
28576
28728
|
type: exports_external2.literal("web_fetch_result"),
|
|
@@ -28603,6 +28755,7 @@ var init_dist4 = __esm(() => {
|
|
|
28603
28755
|
exports_external2.object({
|
|
28604
28756
|
type: exports_external2.literal("web_search_tool_result"),
|
|
28605
28757
|
tool_use_id: exports_external2.string(),
|
|
28758
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
28606
28759
|
content: exports_external2.union([
|
|
28607
28760
|
exports_external2.array(exports_external2.object({
|
|
28608
28761
|
type: exports_external2.literal("web_search_result"),
|
|
@@ -28806,19 +28959,7 @@ var init_dist4 = __esm(() => {
|
|
|
28806
28959
|
id: exports_external2.string(),
|
|
28807
28960
|
name: exports_external2.string(),
|
|
28808
28961
|
input: exports_external2.unknown(),
|
|
28809
|
-
caller:
|
|
28810
|
-
exports_external2.object({
|
|
28811
|
-
type: exports_external2.literal("code_execution_20250825"),
|
|
28812
|
-
tool_id: exports_external2.string()
|
|
28813
|
-
}),
|
|
28814
|
-
exports_external2.object({
|
|
28815
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
28816
|
-
tool_id: exports_external2.string()
|
|
28817
|
-
}),
|
|
28818
|
-
exports_external2.object({
|
|
28819
|
-
type: exports_external2.literal("direct")
|
|
28820
|
-
})
|
|
28821
|
-
]).optional()
|
|
28962
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
28822
28963
|
})
|
|
28823
28964
|
])).nullish(),
|
|
28824
28965
|
stop_reason: exports_external2.string().nullish(),
|
|
@@ -28845,19 +28986,7 @@ var init_dist4 = __esm(() => {
|
|
|
28845
28986
|
id: exports_external2.string(),
|
|
28846
28987
|
name: exports_external2.string(),
|
|
28847
28988
|
input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).optional(),
|
|
28848
|
-
caller:
|
|
28849
|
-
exports_external2.object({
|
|
28850
|
-
type: exports_external2.literal("code_execution_20250825"),
|
|
28851
|
-
tool_id: exports_external2.string()
|
|
28852
|
-
}),
|
|
28853
|
-
exports_external2.object({
|
|
28854
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
28855
|
-
tool_id: exports_external2.string()
|
|
28856
|
-
}),
|
|
28857
|
-
exports_external2.object({
|
|
28858
|
-
type: exports_external2.literal("direct")
|
|
28859
|
-
})
|
|
28860
|
-
]).optional()
|
|
28989
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
28861
28990
|
}),
|
|
28862
28991
|
exports_external2.object({
|
|
28863
28992
|
type: exports_external2.literal("redacted_thinking"),
|
|
@@ -28872,15 +29001,7 @@ var init_dist4 = __esm(() => {
|
|
|
28872
29001
|
id: exports_external2.string(),
|
|
28873
29002
|
name: exports_external2.string(),
|
|
28874
29003
|
input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).nullish(),
|
|
28875
|
-
caller:
|
|
28876
|
-
exports_external2.object({
|
|
28877
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
28878
|
-
tool_id: exports_external2.string()
|
|
28879
|
-
}),
|
|
28880
|
-
exports_external2.object({
|
|
28881
|
-
type: exports_external2.literal("direct")
|
|
28882
|
-
})
|
|
28883
|
-
]).optional()
|
|
29004
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
28884
29005
|
}),
|
|
28885
29006
|
exports_external2.object({
|
|
28886
29007
|
type: exports_external2.literal("mcp_tool_use"),
|
|
@@ -28901,6 +29022,7 @@ var init_dist4 = __esm(() => {
|
|
|
28901
29022
|
exports_external2.object({
|
|
28902
29023
|
type: exports_external2.literal("web_fetch_tool_result"),
|
|
28903
29024
|
tool_use_id: exports_external2.string(),
|
|
29025
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
28904
29026
|
content: exports_external2.union([
|
|
28905
29027
|
exports_external2.object({
|
|
28906
29028
|
type: exports_external2.literal("web_fetch_result"),
|
|
@@ -28933,6 +29055,7 @@ var init_dist4 = __esm(() => {
|
|
|
28933
29055
|
exports_external2.object({
|
|
28934
29056
|
type: exports_external2.literal("web_search_tool_result"),
|
|
28935
29057
|
tool_use_id: exports_external2.string(),
|
|
29058
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
28936
29059
|
content: exports_external2.union([
|
|
28937
29060
|
exports_external2.array(exports_external2.object({
|
|
28938
29061
|
type: exports_external2.literal("web_search_result"),
|
|
@@ -29972,7 +30095,7 @@ var init_dist4 = __esm(() => {
|
|
|
29972
30095
|
anthropic = createAnthropic();
|
|
29973
30096
|
});
|
|
29974
30097
|
|
|
29975
|
-
// ../../node_modules/.bun/@ai-sdk+openai@3.0.
|
|
30098
|
+
// ../../node_modules/.bun/@ai-sdk+openai@3.0.97+27912429049419a2/node_modules/@ai-sdk/openai/dist/index.mjs
|
|
29976
30099
|
var exports_dist2 = {};
|
|
29977
30100
|
__export(exports_dist2, {
|
|
29978
30101
|
openai: () => openai,
|
|
@@ -30909,12 +31032,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
30909
31032
|
if (store && id != null) {
|
|
30910
31033
|
input.push({ type: "item_reference", id });
|
|
30911
31034
|
}
|
|
30912
|
-
|
|
31035
|
+
if (store || !hasShellTool || resolvedToolName !== "shell") {
|
|
31036
|
+
break;
|
|
31037
|
+
}
|
|
30913
31038
|
}
|
|
30914
|
-
|
|
31039
|
+
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
|
|
31040
|
+
if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
|
|
30915
31041
|
break;
|
|
30916
31042
|
}
|
|
30917
|
-
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
|
|
30918
31043
|
if (store && id != null && isProviderDefinedToolCall) {
|
|
30919
31044
|
input.push({ type: "item_reference", id });
|
|
30920
31045
|
break;
|
|
@@ -31135,7 +31260,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
31135
31260
|
continue;
|
|
31136
31261
|
}
|
|
31137
31262
|
processedApprovalIds.add(approvalResponse.approvalId);
|
|
31138
|
-
if (store) {
|
|
31263
|
+
if (store && !hasConversation && !hasPreviousResponseId) {
|
|
31139
31264
|
input.push({
|
|
31140
31265
|
type: "item_reference",
|
|
31141
31266
|
id: approvalResponse.approvalId
|
|
@@ -32099,7 +32224,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
32099
32224
|
});
|
|
32100
32225
|
baseArgs.service_tier = undefined;
|
|
32101
32226
|
}
|
|
32102
|
-
if (openaiOptions.serviceTier === "priority" && !modelCapabilities.supportsPriorityProcessing) {
|
|
32227
|
+
if ((openaiOptions.serviceTier === "priority" || openaiOptions.serviceTier === "fast") && !modelCapabilities.supportsPriorityProcessing) {
|
|
32103
32228
|
warnings.push({
|
|
32104
32229
|
type: "unsupported",
|
|
32105
32230
|
feature: "serviceTier",
|
|
@@ -33109,7 +33234,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
33109
33234
|
});
|
|
33110
33235
|
delete baseArgs.service_tier;
|
|
33111
33236
|
}
|
|
33112
|
-
if ((openaiOptions == null ? undefined : openaiOptions.serviceTier) === "priority" && !modelCapabilities.supportsPriorityProcessing) {
|
|
33237
|
+
if (((openaiOptions == null ? undefined : openaiOptions.serviceTier) === "priority" || (openaiOptions == null ? undefined : openaiOptions.serviceTier) === "fast") && !modelCapabilities.supportsPriorityProcessing) {
|
|
33113
33238
|
warnings.push({
|
|
33114
33239
|
type: "unsupported",
|
|
33115
33240
|
feature: "serviceTier",
|
|
@@ -34689,78 +34814,78 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
34689
34814
|
}
|
|
34690
34815
|
};
|
|
34691
34816
|
}
|
|
34692
|
-
}, VERSION3 = "3.0.
|
|
34693
|
-
var
|
|
34694
|
-
|
|
34695
|
-
|
|
34696
|
-
|
|
34817
|
+
}, VERSION3 = "3.0.97", openai;
|
|
34818
|
+
var init_dist6 = __esm(() => {
|
|
34819
|
+
init_dist4();
|
|
34820
|
+
init_dist2();
|
|
34821
|
+
init_dist4();
|
|
34697
34822
|
init_v4();
|
|
34698
|
-
|
|
34699
|
-
|
|
34700
|
-
|
|
34701
|
-
|
|
34702
|
-
|
|
34823
|
+
init_dist4();
|
|
34824
|
+
init_dist2();
|
|
34825
|
+
init_dist2();
|
|
34826
|
+
init_dist4();
|
|
34827
|
+
init_dist4();
|
|
34703
34828
|
init_v4();
|
|
34704
|
-
|
|
34829
|
+
init_dist4();
|
|
34705
34830
|
init_v4();
|
|
34706
|
-
|
|
34707
|
-
|
|
34708
|
-
|
|
34831
|
+
init_dist2();
|
|
34832
|
+
init_dist4();
|
|
34833
|
+
init_dist2();
|
|
34709
34834
|
init_v4();
|
|
34710
|
-
|
|
34711
|
-
|
|
34835
|
+
init_dist4();
|
|
34836
|
+
init_dist4();
|
|
34712
34837
|
init_v4();
|
|
34713
|
-
|
|
34714
|
-
|
|
34715
|
-
|
|
34838
|
+
init_dist2();
|
|
34839
|
+
init_dist4();
|
|
34840
|
+
init_dist4();
|
|
34716
34841
|
init_v4();
|
|
34717
|
-
|
|
34842
|
+
init_dist4();
|
|
34718
34843
|
init_v4();
|
|
34719
|
-
|
|
34720
|
-
|
|
34844
|
+
init_dist4();
|
|
34845
|
+
init_dist4();
|
|
34721
34846
|
init_v4();
|
|
34722
|
-
|
|
34847
|
+
init_dist4();
|
|
34723
34848
|
init_v4();
|
|
34724
|
-
|
|
34849
|
+
init_dist4();
|
|
34725
34850
|
init_v4();
|
|
34726
|
-
|
|
34851
|
+
init_dist4();
|
|
34727
34852
|
init_v4();
|
|
34728
|
-
|
|
34853
|
+
init_dist4();
|
|
34729
34854
|
init_v4();
|
|
34730
|
-
|
|
34855
|
+
init_dist4();
|
|
34731
34856
|
init_v4();
|
|
34732
|
-
|
|
34857
|
+
init_dist4();
|
|
34733
34858
|
init_v4();
|
|
34734
|
-
|
|
34859
|
+
init_dist4();
|
|
34735
34860
|
init_v4();
|
|
34736
|
-
|
|
34861
|
+
init_dist4();
|
|
34737
34862
|
init_v4();
|
|
34738
|
-
|
|
34863
|
+
init_dist4();
|
|
34739
34864
|
init_v4();
|
|
34740
|
-
|
|
34865
|
+
init_dist4();
|
|
34741
34866
|
init_v4();
|
|
34742
|
-
|
|
34867
|
+
init_dist4();
|
|
34743
34868
|
init_v4();
|
|
34744
|
-
|
|
34869
|
+
init_dist4();
|
|
34745
34870
|
init_v4();
|
|
34746
|
-
|
|
34747
|
-
|
|
34748
|
-
|
|
34749
|
-
|
|
34871
|
+
init_dist2();
|
|
34872
|
+
init_dist4();
|
|
34873
|
+
init_dist2();
|
|
34874
|
+
init_dist4();
|
|
34750
34875
|
init_v4();
|
|
34751
|
-
|
|
34876
|
+
init_dist4();
|
|
34752
34877
|
init_v4();
|
|
34753
|
-
|
|
34878
|
+
init_dist4();
|
|
34754
34879
|
init_v4();
|
|
34755
|
-
|
|
34756
|
-
|
|
34757
|
-
|
|
34758
|
-
|
|
34880
|
+
init_dist2();
|
|
34881
|
+
init_dist4();
|
|
34882
|
+
init_dist4();
|
|
34883
|
+
init_dist4();
|
|
34759
34884
|
init_v4();
|
|
34760
|
-
|
|
34761
|
-
|
|
34885
|
+
init_dist4();
|
|
34886
|
+
init_dist4();
|
|
34762
34887
|
init_v4();
|
|
34763
|
-
|
|
34888
|
+
init_dist4();
|
|
34764
34889
|
init_v4();
|
|
34765
34890
|
openaiErrorDataSchema = exports_external2.object({
|
|
34766
34891
|
error: exports_external2.object({
|
|
@@ -34896,7 +35021,7 @@ var init_dist5 = __esm(() => {
|
|
|
34896
35021
|
store: exports_external2.boolean().optional(),
|
|
34897
35022
|
metadata: exports_external2.record(exports_external2.string().max(64), exports_external2.string().max(512)).optional(),
|
|
34898
35023
|
prediction: exports_external2.record(exports_external2.string(), exports_external2.any()).optional(),
|
|
34899
|
-
serviceTier: exports_external2.enum(["auto", "flex", "priority", "default"]).optional(),
|
|
35024
|
+
serviceTier: exports_external2.enum(["auto", "flex", "priority", "fast", "default"]).optional(),
|
|
34900
35025
|
strictJsonSchema: exports_external2.boolean().optional(),
|
|
34901
35026
|
textVerbosity: exports_external2.enum(["low", "medium", "high"]).optional(),
|
|
34902
35027
|
promptCacheKey: exports_external2.string().optional(),
|
|
@@ -36308,7 +36433,7 @@ var init_dist5 = __esm(() => {
|
|
|
36308
36433
|
reasoningContext: exports_external2.enum(["auto", "current_turn", "all_turns"]).optional(),
|
|
36309
36434
|
reasoningSummary: exports_external2.string().nullish(),
|
|
36310
36435
|
safetyIdentifier: exports_external2.string().nullish(),
|
|
36311
|
-
serviceTier: exports_external2.enum(["auto", "flex", "priority", "default"]).nullish(),
|
|
36436
|
+
serviceTier: exports_external2.enum(["auto", "flex", "priority", "fast", "default"]).nullish(),
|
|
36312
36437
|
store: exports_external2.boolean().nullish(),
|
|
36313
36438
|
passThroughUnsupportedFiles: exports_external2.boolean().optional(),
|
|
36314
36439
|
strictJsonSchema: exports_external2.boolean().nullish(),
|
|
@@ -36417,7 +36542,7 @@ var init_dist5 = __esm(() => {
|
|
|
36417
36542
|
openai = createOpenAI();
|
|
36418
36543
|
});
|
|
36419
36544
|
|
|
36420
|
-
// ../../node_modules/.bun/@ai-sdk+openai-compatible@2.0.
|
|
36545
|
+
// ../../node_modules/.bun/@ai-sdk+openai-compatible@2.0.69+27912429049419a2/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
|
|
36421
36546
|
var exports_dist3 = {};
|
|
36422
36547
|
__export(exports_dist3, {
|
|
36423
36548
|
createOpenAICompatible: () => createOpenAICompatible,
|
|
@@ -36468,7 +36593,7 @@ function convertOpenAICompatibleChatUsage(usage) {
|
|
|
36468
36593
|
},
|
|
36469
36594
|
outputTokens: {
|
|
36470
36595
|
total: completionTokens,
|
|
36471
|
-
text: completionTokens - reasoningTokens,
|
|
36596
|
+
text: Math.max(0, completionTokens - reasoningTokens),
|
|
36472
36597
|
reasoning: reasoningTokens
|
|
36473
36598
|
},
|
|
36474
36599
|
raw: usage
|
|
@@ -37842,27 +37967,27 @@ var openaiCompatibleErrorDataSchema, defaultOpenAICompatibleErrorStructure, open
|
|
|
37842
37967
|
}
|
|
37843
37968
|
};
|
|
37844
37969
|
}
|
|
37845
|
-
}, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.
|
|
37846
|
-
var
|
|
37847
|
-
|
|
37848
|
-
|
|
37970
|
+
}, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.69";
|
|
37971
|
+
var init_dist7 = __esm(() => {
|
|
37972
|
+
init_dist2();
|
|
37973
|
+
init_dist4();
|
|
37849
37974
|
init_v4();
|
|
37850
37975
|
init_v4();
|
|
37851
|
-
|
|
37852
|
-
|
|
37976
|
+
init_dist2();
|
|
37977
|
+
init_dist4();
|
|
37853
37978
|
init_v4();
|
|
37854
|
-
|
|
37855
|
-
|
|
37979
|
+
init_dist2();
|
|
37980
|
+
init_dist4();
|
|
37856
37981
|
init_v4();
|
|
37857
|
-
|
|
37982
|
+
init_dist2();
|
|
37858
37983
|
init_v4();
|
|
37859
|
-
|
|
37860
|
-
|
|
37984
|
+
init_dist2();
|
|
37985
|
+
init_dist4();
|
|
37861
37986
|
init_v4();
|
|
37862
37987
|
init_v4();
|
|
37863
|
-
|
|
37988
|
+
init_dist4();
|
|
37864
37989
|
init_v4();
|
|
37865
|
-
|
|
37990
|
+
init_dist4();
|
|
37866
37991
|
openaiCompatibleErrorDataSchema = exports_external2.object({
|
|
37867
37992
|
error: exports_external2.object({
|
|
37868
37993
|
message: exports_external2.string(),
|
|
@@ -37885,10 +38010,10 @@ var init_dist6 = __esm(() => {
|
|
|
37885
38010
|
prompt_tokens: exports_external2.number().nullish(),
|
|
37886
38011
|
completion_tokens: exports_external2.number().nullish(),
|
|
37887
38012
|
total_tokens: exports_external2.number().nullish(),
|
|
37888
|
-
prompt_tokens_details: exports_external2.
|
|
38013
|
+
prompt_tokens_details: exports_external2.looseObject({
|
|
37889
38014
|
cached_tokens: exports_external2.number().nullish()
|
|
37890
38015
|
}).nullish(),
|
|
37891
|
-
completion_tokens_details: exports_external2.
|
|
38016
|
+
completion_tokens_details: exports_external2.looseObject({
|
|
37892
38017
|
reasoning_tokens: exports_external2.number().nullish(),
|
|
37893
38018
|
accepted_prediction_tokens: exports_external2.number().nullish(),
|
|
37894
38019
|
rejected_prediction_tokens: exports_external2.number().nullish()
|
|
@@ -37955,7 +38080,7 @@ var init_dist6 = __esm(() => {
|
|
|
37955
38080
|
suffix: exports_external2.string().optional(),
|
|
37956
38081
|
user: exports_external2.string().optional()
|
|
37957
38082
|
});
|
|
37958
|
-
usageSchema = exports_external2.
|
|
38083
|
+
usageSchema = exports_external2.looseObject({
|
|
37959
38084
|
prompt_tokens: exports_external2.number(),
|
|
37960
38085
|
completion_tokens: exports_external2.number(),
|
|
37961
38086
|
total_tokens: exports_external2.number()
|
|
@@ -38084,19 +38209,19 @@ var require_token_io = __commonJS((exports, module) => {
|
|
|
38084
38209
|
getUserDataDir: () => getUserDataDir
|
|
38085
38210
|
});
|
|
38086
38211
|
module.exports = __toCommonJS2(token_io_exports);
|
|
38087
|
-
var
|
|
38212
|
+
var import_path2 = __toESM2(__require("path"));
|
|
38088
38213
|
var import_fs = __toESM2(__require("fs"));
|
|
38089
|
-
var
|
|
38214
|
+
var import_os3 = __toESM2(__require("os"));
|
|
38090
38215
|
var import_token_error = require_token_error();
|
|
38091
38216
|
function findRootDir() {
|
|
38092
38217
|
try {
|
|
38093
38218
|
let dir = process.cwd();
|
|
38094
|
-
while (dir !==
|
|
38095
|
-
const pkgPath =
|
|
38219
|
+
while (dir !== import_path2.default.dirname(dir)) {
|
|
38220
|
+
const pkgPath = import_path2.default.join(dir, ".vercel");
|
|
38096
38221
|
if (import_fs.default.existsSync(pkgPath)) {
|
|
38097
38222
|
return dir;
|
|
38098
38223
|
}
|
|
38099
|
-
dir =
|
|
38224
|
+
dir = import_path2.default.dirname(dir);
|
|
38100
38225
|
}
|
|
38101
38226
|
} catch (e) {
|
|
38102
38227
|
throw new import_token_error.VercelOidcTokenError("Token refresh only supported in node server environments");
|
|
@@ -38107,11 +38232,11 @@ var require_token_io = __commonJS((exports, module) => {
|
|
|
38107
38232
|
if (process.env.XDG_DATA_HOME) {
|
|
38108
38233
|
return process.env.XDG_DATA_HOME;
|
|
38109
38234
|
}
|
|
38110
|
-
switch (
|
|
38235
|
+
switch (import_os3.default.platform()) {
|
|
38111
38236
|
case "darwin":
|
|
38112
|
-
return
|
|
38237
|
+
return import_path2.default.join(import_os3.default.homedir(), "Library/Application Support");
|
|
38113
38238
|
case "linux":
|
|
38114
|
-
return
|
|
38239
|
+
return import_path2.default.join(import_os3.default.homedir(), ".local/share");
|
|
38115
38240
|
case "win32":
|
|
38116
38241
|
if (process.env.LOCALAPPDATA) {
|
|
38117
38242
|
return process.env.LOCALAPPDATA;
|
|
@@ -38156,11 +38281,11 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
38156
38281
|
var path = __toESM2(__require("path"));
|
|
38157
38282
|
var import_token_util = require_token_util();
|
|
38158
38283
|
function getAuthConfigPath() {
|
|
38159
|
-
const
|
|
38160
|
-
if (!
|
|
38284
|
+
const dataDir2 = (0, import_token_util.getVercelDataDir)();
|
|
38285
|
+
if (!dataDir2) {
|
|
38161
38286
|
throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);
|
|
38162
38287
|
}
|
|
38163
|
-
return path.join(
|
|
38288
|
+
return path.join(dataDir2, "auth.json");
|
|
38164
38289
|
}
|
|
38165
38290
|
function readAuthConfig() {
|
|
38166
38291
|
try {
|
|
@@ -38221,10 +38346,10 @@ var require_oauth = __commonJS((exports, module) => {
|
|
|
38221
38346
|
refreshTokenRequest: () => refreshTokenRequest
|
|
38222
38347
|
});
|
|
38223
38348
|
module.exports = __toCommonJS2(oauth_exports);
|
|
38224
|
-
var
|
|
38349
|
+
var import_os3 = __require("os");
|
|
38225
38350
|
var VERCEL_ISSUER = "https://vercel.com";
|
|
38226
38351
|
var VERCEL_CLI_CLIENT_ID = "cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp";
|
|
38227
|
-
var userAgent = `@vercel/oidc node-${process.version} ${(0,
|
|
38352
|
+
var userAgent = `@vercel/oidc node-${process.version} ${(0, import_os3.platform)()} (${(0, import_os3.arch)()}) ${(0, import_os3.hostname)()}`;
|
|
38228
38353
|
var _tokenEndpoint = null;
|
|
38229
38354
|
async function getTokenEndpoint() {
|
|
38230
38355
|
if (_tokenEndpoint) {
|
|
@@ -38367,11 +38492,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
38367
38492
|
var import_auth_errors = require_auth_errors();
|
|
38368
38493
|
function getVercelDataDir() {
|
|
38369
38494
|
const vercelFolder = "com.vercel.cli";
|
|
38370
|
-
const
|
|
38371
|
-
if (!
|
|
38495
|
+
const dataDir2 = (0, import_token_io.getUserDataDir)();
|
|
38496
|
+
if (!dataDir2) {
|
|
38372
38497
|
return null;
|
|
38373
38498
|
}
|
|
38374
|
-
return path.join(
|
|
38499
|
+
return path.join(dataDir2, vercelFolder);
|
|
38375
38500
|
}
|
|
38376
38501
|
async function getVercelToken2(options) {
|
|
38377
38502
|
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
@@ -38646,7 +38771,7 @@ var require_dist = __commonJS((exports, module) => {
|
|
|
38646
38771
|
var import_token_util = require_token_util();
|
|
38647
38772
|
});
|
|
38648
38773
|
|
|
38649
|
-
// ../../node_modules/.bun/@ai-sdk+gateway@3.0.
|
|
38774
|
+
// ../../node_modules/.bun/@ai-sdk+gateway@3.0.175+27912429049419a2/node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
38650
38775
|
async function createGatewayErrorFromResponse({
|
|
38651
38776
|
response,
|
|
38652
38777
|
statusCode,
|
|
@@ -39053,11 +39178,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39053
39178
|
try {
|
|
39054
39179
|
const { value } = await getFromApi({
|
|
39055
39180
|
url: `${this.config.baseURL}/config`,
|
|
39056
|
-
headers: await
|
|
39181
|
+
headers: await resolve5(this.config.headers()),
|
|
39057
39182
|
successfulResponseHandler: createJsonResponseHandler(gatewayAvailableModelsResponseSchema),
|
|
39058
39183
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
39059
39184
|
errorSchema: exports_external2.any(),
|
|
39060
|
-
errorToMessage: (data) =>
|
|
39185
|
+
errorToMessage: (data) => {
|
|
39186
|
+
var _a112;
|
|
39187
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
39188
|
+
}
|
|
39061
39189
|
}),
|
|
39062
39190
|
fetch: this.config.fetch
|
|
39063
39191
|
});
|
|
@@ -39071,11 +39199,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39071
39199
|
const baseUrl = new URL(this.config.baseURL);
|
|
39072
39200
|
const { value } = await getFromApi({
|
|
39073
39201
|
url: `${baseUrl.origin}/v1/credits`,
|
|
39074
|
-
headers: await
|
|
39202
|
+
headers: await resolve5(this.config.headers()),
|
|
39075
39203
|
successfulResponseHandler: createJsonResponseHandler(gatewayCreditsResponseSchema),
|
|
39076
39204
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
39077
39205
|
errorSchema: exports_external2.any(),
|
|
39078
|
-
errorToMessage: (data) =>
|
|
39206
|
+
errorToMessage: (data) => {
|
|
39207
|
+
var _a112;
|
|
39208
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
39209
|
+
}
|
|
39079
39210
|
}),
|
|
39080
39211
|
fetch: this.config.fetch
|
|
39081
39212
|
});
|
|
@@ -39117,11 +39248,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39117
39248
|
}
|
|
39118
39249
|
const { value } = await getFromApi({
|
|
39119
39250
|
url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
|
|
39120
|
-
headers: await
|
|
39251
|
+
headers: await resolve5(this.config.headers()),
|
|
39121
39252
|
successfulResponseHandler: createJsonResponseHandler(gatewaySpendReportResponseSchema),
|
|
39122
39253
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
39123
39254
|
errorSchema: exports_external2.any(),
|
|
39124
|
-
errorToMessage: (data) =>
|
|
39255
|
+
errorToMessage: (data) => {
|
|
39256
|
+
var _a112;
|
|
39257
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
39258
|
+
}
|
|
39125
39259
|
}),
|
|
39126
39260
|
fetch: this.config.fetch
|
|
39127
39261
|
});
|
|
@@ -39139,11 +39273,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39139
39273
|
const baseUrl = new URL(this.config.baseURL);
|
|
39140
39274
|
const { value } = await getFromApi({
|
|
39141
39275
|
url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
|
|
39142
|
-
headers: await
|
|
39276
|
+
headers: await resolve5(this.config.headers()),
|
|
39143
39277
|
successfulResponseHandler: createJsonResponseHandler(gatewayGenerationInfoResponseSchema),
|
|
39144
39278
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
39145
39279
|
errorSchema: exports_external2.any(),
|
|
39146
|
-
errorToMessage: (data) =>
|
|
39280
|
+
errorToMessage: (data) => {
|
|
39281
|
+
var _a112;
|
|
39282
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
39283
|
+
}
|
|
39147
39284
|
}),
|
|
39148
39285
|
fetch: this.config.fetch
|
|
39149
39286
|
});
|
|
@@ -39172,7 +39309,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39172
39309
|
async doGenerate(options) {
|
|
39173
39310
|
const { args, warnings } = await this.getArgs(options);
|
|
39174
39311
|
const { abortSignal } = options;
|
|
39175
|
-
const resolvedHeaders = await
|
|
39312
|
+
const resolvedHeaders = await resolve5(this.config.headers());
|
|
39176
39313
|
try {
|
|
39177
39314
|
const {
|
|
39178
39315
|
responseHeaders,
|
|
@@ -39180,12 +39317,15 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39180
39317
|
rawValue: rawResponse
|
|
39181
39318
|
} = await postJsonToApi({
|
|
39182
39319
|
url: this.getUrl(),
|
|
39183
|
-
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await
|
|
39320
|
+
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await resolve5(this.config.o11yHeaders)),
|
|
39184
39321
|
body: args,
|
|
39185
39322
|
successfulResponseHandler: createJsonResponseHandler(exports_external2.any()),
|
|
39186
39323
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
39187
39324
|
errorSchema: exports_external2.any(),
|
|
39188
|
-
errorToMessage: (data) =>
|
|
39325
|
+
errorToMessage: (data) => {
|
|
39326
|
+
var _a112;
|
|
39327
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
39328
|
+
}
|
|
39189
39329
|
}),
|
|
39190
39330
|
...abortSignal && { abortSignal },
|
|
39191
39331
|
fetch: this.config.fetch
|
|
@@ -39203,16 +39343,19 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39203
39343
|
async doStream(options) {
|
|
39204
39344
|
const { args, warnings } = await this.getArgs(options);
|
|
39205
39345
|
const { abortSignal } = options;
|
|
39206
|
-
const resolvedHeaders = await
|
|
39346
|
+
const resolvedHeaders = await resolve5(this.config.headers());
|
|
39207
39347
|
try {
|
|
39208
39348
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
39209
39349
|
url: this.getUrl(),
|
|
39210
|
-
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await
|
|
39350
|
+
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await resolve5(this.config.o11yHeaders)),
|
|
39211
39351
|
body: args,
|
|
39212
39352
|
successfulResponseHandler: createEventSourceResponseHandler(exports_external2.any()),
|
|
39213
39353
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
39214
39354
|
errorSchema: exports_external2.any(),
|
|
39215
|
-
errorToMessage: (data) =>
|
|
39355
|
+
errorToMessage: (data) => {
|
|
39356
|
+
var _a112;
|
|
39357
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
39358
|
+
}
|
|
39216
39359
|
}),
|
|
39217
39360
|
...abortSignal && { abortSignal },
|
|
39218
39361
|
fetch: this.config.fetch
|
|
@@ -39292,7 +39435,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39292
39435
|
providerOptions
|
|
39293
39436
|
}) {
|
|
39294
39437
|
var _a112, _b112;
|
|
39295
|
-
const resolvedHeaders = await
|
|
39438
|
+
const resolvedHeaders = await resolve5(this.config.headers());
|
|
39296
39439
|
try {
|
|
39297
39440
|
const {
|
|
39298
39441
|
responseHeaders,
|
|
@@ -39300,7 +39443,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39300
39443
|
rawValue
|
|
39301
39444
|
} = await postJsonToApi({
|
|
39302
39445
|
url: this.getUrl(),
|
|
39303
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
39446
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders)),
|
|
39304
39447
|
body: {
|
|
39305
39448
|
values,
|
|
39306
39449
|
...providerOptions ? { providerOptions } : {}
|
|
@@ -39308,7 +39451,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39308
39451
|
successfulResponseHandler: createJsonResponseHandler(gatewayEmbeddingResponseSchema),
|
|
39309
39452
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
39310
39453
|
errorSchema: exports_external2.any(),
|
|
39311
|
-
errorToMessage: (data) =>
|
|
39454
|
+
errorToMessage: (data) => {
|
|
39455
|
+
var _a122;
|
|
39456
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
39457
|
+
}
|
|
39312
39458
|
}),
|
|
39313
39459
|
...abortSignal && { abortSignal },
|
|
39314
39460
|
fetch: this.config.fetch
|
|
@@ -39356,7 +39502,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39356
39502
|
abortSignal
|
|
39357
39503
|
}) {
|
|
39358
39504
|
var _a112, _b112, _c;
|
|
39359
|
-
const resolvedHeaders = await
|
|
39505
|
+
const resolvedHeaders = await resolve5(this.config.headers());
|
|
39360
39506
|
try {
|
|
39361
39507
|
const {
|
|
39362
39508
|
responseHeaders,
|
|
@@ -39364,7 +39510,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39364
39510
|
rawValue
|
|
39365
39511
|
} = await postJsonToApi({
|
|
39366
39512
|
url: this.getUrl(),
|
|
39367
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
39513
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders)),
|
|
39368
39514
|
body: {
|
|
39369
39515
|
prompt,
|
|
39370
39516
|
n,
|
|
@@ -39380,7 +39526,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39380
39526
|
successfulResponseHandler: createJsonResponseHandler(gatewayImageResponseSchema),
|
|
39381
39527
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
39382
39528
|
errorSchema: exports_external2.any(),
|
|
39383
|
-
errorToMessage: (data) =>
|
|
39529
|
+
errorToMessage: (data) => {
|
|
39530
|
+
var _a122;
|
|
39531
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
39532
|
+
}
|
|
39384
39533
|
}),
|
|
39385
39534
|
...abortSignal && { abortSignal },
|
|
39386
39535
|
fetch: this.config.fetch
|
|
@@ -39441,11 +39590,11 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39441
39590
|
headers,
|
|
39442
39591
|
abortSignal
|
|
39443
39592
|
}) {
|
|
39444
|
-
const resolvedHeaders = await
|
|
39593
|
+
const resolvedHeaders = await resolve5(this.config.headers());
|
|
39445
39594
|
try {
|
|
39446
39595
|
const { responseHeaders, value: responseBody } = await postJsonToApi({
|
|
39447
39596
|
url: this.getUrl(),
|
|
39448
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
39597
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders), { accept: "text/event-stream" }),
|
|
39449
39598
|
body: {
|
|
39450
39599
|
prompt,
|
|
39451
39600
|
n,
|
|
@@ -39533,7 +39682,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39533
39682
|
},
|
|
39534
39683
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
39535
39684
|
errorSchema: exports_external2.any(),
|
|
39536
|
-
errorToMessage: (data) =>
|
|
39685
|
+
errorToMessage: (data) => {
|
|
39686
|
+
var _a112;
|
|
39687
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
39688
|
+
}
|
|
39537
39689
|
}),
|
|
39538
39690
|
...abortSignal && { abortSignal },
|
|
39539
39691
|
fetch: this.config.fetch
|
|
@@ -39579,7 +39731,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39579
39731
|
providerOptions
|
|
39580
39732
|
}) {
|
|
39581
39733
|
var _a112;
|
|
39582
|
-
const resolvedHeaders = await
|
|
39734
|
+
const resolvedHeaders = await resolve5(this.config.headers());
|
|
39583
39735
|
try {
|
|
39584
39736
|
const {
|
|
39585
39737
|
responseHeaders,
|
|
@@ -39587,7 +39739,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39587
39739
|
rawValue
|
|
39588
39740
|
} = await postJsonToApi({
|
|
39589
39741
|
url: this.getUrl(),
|
|
39590
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
39742
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders)),
|
|
39591
39743
|
body: {
|
|
39592
39744
|
documents,
|
|
39593
39745
|
query,
|
|
@@ -39597,7 +39749,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39597
39749
|
successfulResponseHandler: createJsonResponseHandler(gatewayRerankingResponseSchema),
|
|
39598
39750
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
39599
39751
|
errorSchema: exports_external2.any(),
|
|
39600
|
-
errorToMessage: (data) =>
|
|
39752
|
+
errorToMessage: (data) => {
|
|
39753
|
+
var _a122;
|
|
39754
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
39755
|
+
}
|
|
39601
39756
|
}),
|
|
39602
39757
|
...abortSignal && { abortSignal },
|
|
39603
39758
|
fetch: this.config.fetch
|
|
@@ -39641,7 +39796,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39641
39796
|
headers,
|
|
39642
39797
|
abortSignal
|
|
39643
39798
|
}) {
|
|
39644
|
-
const resolvedHeaders = await
|
|
39799
|
+
const resolvedHeaders = await resolve5(this.config.headers());
|
|
39645
39800
|
try {
|
|
39646
39801
|
const {
|
|
39647
39802
|
responseHeaders,
|
|
@@ -39649,7 +39804,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39649
39804
|
rawValue
|
|
39650
39805
|
} = await postJsonToApi({
|
|
39651
39806
|
url: this.getUrl(),
|
|
39652
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
39807
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders)),
|
|
39653
39808
|
body: {
|
|
39654
39809
|
text,
|
|
39655
39810
|
...voice && { voice },
|
|
@@ -39662,7 +39817,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39662
39817
|
successfulResponseHandler: createJsonResponseHandler(gatewaySpeechResponseSchema),
|
|
39663
39818
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
39664
39819
|
errorSchema: exports_external2.any(),
|
|
39665
|
-
errorToMessage: (data) =>
|
|
39820
|
+
errorToMessage: (data) => {
|
|
39821
|
+
var _a112;
|
|
39822
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
39823
|
+
}
|
|
39666
39824
|
}),
|
|
39667
39825
|
...abortSignal && { abortSignal },
|
|
39668
39826
|
fetch: this.config.fetch
|
|
@@ -39708,7 +39866,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39708
39866
|
abortSignal
|
|
39709
39867
|
}) {
|
|
39710
39868
|
var _a112, _b112, _c;
|
|
39711
|
-
const resolvedHeaders = await
|
|
39869
|
+
const resolvedHeaders = await resolve5(this.config.headers());
|
|
39712
39870
|
try {
|
|
39713
39871
|
const {
|
|
39714
39872
|
responseHeaders,
|
|
@@ -39716,7 +39874,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39716
39874
|
rawValue
|
|
39717
39875
|
} = await postJsonToApi({
|
|
39718
39876
|
url: this.getUrl(),
|
|
39719
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
39877
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders)),
|
|
39720
39878
|
body: {
|
|
39721
39879
|
audio: audio instanceof Uint8Array ? convertUint8ArrayToBase64(audio) : audio,
|
|
39722
39880
|
mediaType,
|
|
@@ -39725,7 +39883,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39725
39883
|
successfulResponseHandler: createJsonResponseHandler(gatewayTranscriptionResponseSchema),
|
|
39726
39884
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
39727
39885
|
errorSchema: exports_external2.any(),
|
|
39728
|
-
errorToMessage: (data) =>
|
|
39886
|
+
errorToMessage: (data) => {
|
|
39887
|
+
var _a122;
|
|
39888
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
39889
|
+
}
|
|
39729
39890
|
}),
|
|
39730
39891
|
...abortSignal && { abortSignal },
|
|
39731
39892
|
fetch: this.config.fetch
|
|
@@ -39757,45 +39918,45 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
39757
39918
|
"ai-model-id": this.modelId
|
|
39758
39919
|
};
|
|
39759
39920
|
}
|
|
39760
|
-
}, 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.
|
|
39761
|
-
var
|
|
39762
|
-
|
|
39763
|
-
|
|
39921
|
+
}, 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;
|
|
39922
|
+
var init_dist8 = __esm(() => {
|
|
39923
|
+
init_dist4();
|
|
39924
|
+
init_dist2();
|
|
39764
39925
|
init_v4();
|
|
39765
39926
|
init_v4();
|
|
39766
|
-
|
|
39927
|
+
init_dist4();
|
|
39767
39928
|
init_v4();
|
|
39768
|
-
|
|
39769
|
-
|
|
39770
|
-
|
|
39929
|
+
init_dist4();
|
|
39930
|
+
init_dist4();
|
|
39931
|
+
init_dist4();
|
|
39771
39932
|
init_v4();
|
|
39772
|
-
|
|
39773
|
-
|
|
39933
|
+
init_dist4();
|
|
39934
|
+
init_dist4();
|
|
39774
39935
|
init_v4();
|
|
39775
|
-
|
|
39936
|
+
init_dist4();
|
|
39776
39937
|
init_v4();
|
|
39777
|
-
|
|
39938
|
+
init_dist4();
|
|
39778
39939
|
init_v4();
|
|
39779
|
-
|
|
39940
|
+
init_dist4();
|
|
39780
39941
|
init_v4();
|
|
39781
|
-
|
|
39942
|
+
init_dist4();
|
|
39782
39943
|
init_v4();
|
|
39783
|
-
|
|
39944
|
+
init_dist4();
|
|
39784
39945
|
init_v4();
|
|
39785
|
-
|
|
39786
|
-
|
|
39946
|
+
init_dist2();
|
|
39947
|
+
init_dist4();
|
|
39787
39948
|
init_v4();
|
|
39788
|
-
|
|
39949
|
+
init_dist4();
|
|
39789
39950
|
init_v4();
|
|
39790
|
-
|
|
39951
|
+
init_dist4();
|
|
39791
39952
|
init_v4();
|
|
39792
|
-
|
|
39953
|
+
init_dist4();
|
|
39793
39954
|
init_v4();
|
|
39794
|
-
|
|
39955
|
+
init_dist4();
|
|
39795
39956
|
init_zod();
|
|
39796
|
-
|
|
39957
|
+
init_dist4();
|
|
39797
39958
|
init_zod();
|
|
39798
|
-
|
|
39959
|
+
init_dist4();
|
|
39799
39960
|
init_zod();
|
|
39800
39961
|
import_oidc = __toESM(require_dist(), 1);
|
|
39801
39962
|
import_oidc2 = __toESM(require_dist(), 1);
|
|
@@ -41698,7 +41859,7 @@ var require_tracestate_impl = __commonJS((exports) => {
|
|
|
41698
41859
|
const value = listMember.slice(i + 1, part.length);
|
|
41699
41860
|
if ((0, tracestate_validators_1.validateKey)(key) && (0, tracestate_validators_1.validateValue)(value)) {
|
|
41700
41861
|
agg.set(key, value);
|
|
41701
|
-
}
|
|
41862
|
+
}
|
|
41702
41863
|
}
|
|
41703
41864
|
return agg;
|
|
41704
41865
|
}, new Map);
|
|
@@ -42073,7 +42234,7 @@ var require_src = __commonJS((exports) => {
|
|
|
42073
42234
|
};
|
|
42074
42235
|
});
|
|
42075
42236
|
|
|
42076
|
-
// ../../node_modules/.bun/ai@6.0.
|
|
42237
|
+
// ../../node_modules/.bun/ai@6.0.257+27912429049419a2/node_modules/ai/dist/index.mjs
|
|
42077
42238
|
var exports_dist4 = {};
|
|
42078
42239
|
__export(exports_dist4, {
|
|
42079
42240
|
zodSchema: () => zodSchema,
|
|
@@ -43358,7 +43519,8 @@ async function recordSpan({
|
|
|
43358
43519
|
tracer,
|
|
43359
43520
|
attributes,
|
|
43360
43521
|
fn,
|
|
43361
|
-
endWhenDone = true
|
|
43522
|
+
endWhenDone = true,
|
|
43523
|
+
endOnError = endWhenDone
|
|
43362
43524
|
}) {
|
|
43363
43525
|
return tracer.startActiveSpan(name222, { attributes: await attributes }, async (span) => {
|
|
43364
43526
|
const ctx = import_api3.context.active();
|
|
@@ -43372,7 +43534,9 @@ async function recordSpan({
|
|
|
43372
43534
|
try {
|
|
43373
43535
|
recordErrorOnSpan(span, error40);
|
|
43374
43536
|
} finally {
|
|
43375
|
-
|
|
43537
|
+
if (endOnError) {
|
|
43538
|
+
span.end();
|
|
43539
|
+
}
|
|
43376
43540
|
}
|
|
43377
43541
|
throw error40;
|
|
43378
43542
|
}
|
|
@@ -45842,6 +46006,7 @@ function processUIMessageStream({
|
|
|
45842
46006
|
case "reasoning-start": {
|
|
45843
46007
|
const reasoningPart = {
|
|
45844
46008
|
type: "reasoning",
|
|
46009
|
+
id: chunk.id,
|
|
45845
46010
|
text: "",
|
|
45846
46011
|
providerMetadata: chunk.providerMetadata,
|
|
45847
46012
|
state: "streaming"
|
|
@@ -46138,7 +46303,7 @@ function processUIMessageStream({
|
|
|
46138
46303
|
}
|
|
46139
46304
|
await updateMessageMetadata(chunk.messageMetadata);
|
|
46140
46305
|
if (chunk.messageId != null || chunk.messageMetadata != null) {
|
|
46141
|
-
write();
|
|
46306
|
+
write({ updateStatus: false });
|
|
46142
46307
|
}
|
|
46143
46308
|
break;
|
|
46144
46309
|
}
|
|
@@ -46361,9 +46526,18 @@ function createAsyncIterableStream(source) {
|
|
|
46361
46526
|
}
|
|
46362
46527
|
async function consumeStream({
|
|
46363
46528
|
stream,
|
|
46364
|
-
onError
|
|
46529
|
+
onError,
|
|
46530
|
+
abortSignal
|
|
46365
46531
|
}) {
|
|
46366
46532
|
const reader = stream.getReader();
|
|
46533
|
+
const cancelOnAbort = () => {
|
|
46534
|
+
reader.cancel().catch(() => {});
|
|
46535
|
+
};
|
|
46536
|
+
if (abortSignal == null ? undefined : abortSignal.aborted) {
|
|
46537
|
+
cancelOnAbort();
|
|
46538
|
+
} else {
|
|
46539
|
+
abortSignal == null || abortSignal.addEventListener("abort", cancelOnAbort, { once: true });
|
|
46540
|
+
}
|
|
46367
46541
|
try {
|
|
46368
46542
|
while (true) {
|
|
46369
46543
|
const { done } = await reader.read();
|
|
@@ -46373,6 +46547,7 @@ async function consumeStream({
|
|
|
46373
46547
|
} catch (error40) {
|
|
46374
46548
|
onError == null || onError(error40);
|
|
46375
46549
|
} finally {
|
|
46550
|
+
abortSignal == null || abortSignal.removeEventListener("abort", cancelOnAbort);
|
|
46376
46551
|
reader.releaseLock();
|
|
46377
46552
|
}
|
|
46378
46553
|
}
|
|
@@ -46973,6 +47148,27 @@ function createUIMessageStream({
|
|
|
46973
47148
|
onError
|
|
46974
47149
|
});
|
|
46975
47150
|
}
|
|
47151
|
+
function createUIMessageSnapshot(message) {
|
|
47152
|
+
const textByPartIndex = /* @__PURE__ */ new Map;
|
|
47153
|
+
const messageWithoutText = {
|
|
47154
|
+
...message,
|
|
47155
|
+
parts: message.parts.map((part, index) => {
|
|
47156
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
47157
|
+
textByPartIndex.set(index, part.text);
|
|
47158
|
+
return { ...part, text: "" };
|
|
47159
|
+
}
|
|
47160
|
+
return part;
|
|
47161
|
+
})
|
|
47162
|
+
};
|
|
47163
|
+
const snapshot2 = structuredClone(messageWithoutText);
|
|
47164
|
+
for (const [index, text2] of textByPartIndex) {
|
|
47165
|
+
const part = snapshot2.parts[index];
|
|
47166
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
47167
|
+
part.text = text2;
|
|
47168
|
+
}
|
|
47169
|
+
}
|
|
47170
|
+
return snapshot2;
|
|
47171
|
+
}
|
|
46976
47172
|
function readUIMessageStream({
|
|
46977
47173
|
message,
|
|
46978
47174
|
stream,
|
|
@@ -47005,7 +47201,7 @@ function readUIMessageStream({
|
|
|
47005
47201
|
return job({
|
|
47006
47202
|
state,
|
|
47007
47203
|
write: () => {
|
|
47008
|
-
controller == null || controller.enqueue(
|
|
47204
|
+
controller == null || controller.enqueue(createUIMessageSnapshot(state.message));
|
|
47009
47205
|
}
|
|
47010
47206
|
});
|
|
47011
47207
|
},
|
|
@@ -49888,7 +50084,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
49888
50084
|
}, imageMediaTypeSignatures, audioMediaTypeSignatures, videoMediaTypeSignatures, DEFAULT_SNIFF_BYTES = 18, MAX_SIGNATURE_BYTES = 12, MAX_ID3_TAG_BYTES, ID3_SCAN_BYTES, stripID3 = (bytes) => {
|
|
49889
50085
|
const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
|
|
49890
50086
|
return bytes.subarray(id3Size + 10);
|
|
49891
|
-
}, VERSION6 = "6.0.
|
|
50087
|
+
}, VERSION6 = "6.0.257", download = async ({
|
|
49892
50088
|
url: url2,
|
|
49893
50089
|
maxBytes,
|
|
49894
50090
|
abortSignal
|
|
@@ -49983,7 +50179,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
49983
50179
|
const schema = asSchema(inputSchema);
|
|
49984
50180
|
return {
|
|
49985
50181
|
name: "object",
|
|
49986
|
-
responseFormat:
|
|
50182
|
+
responseFormat: resolve5(schema.jsonSchema).then((jsonSchema2) => ({
|
|
49987
50183
|
type: "json",
|
|
49988
50184
|
schema: jsonSchema2,
|
|
49989
50185
|
...name222 != null && { name: name222 },
|
|
@@ -50044,7 +50240,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
50044
50240
|
const elementSchema = asSchema(inputElementSchema);
|
|
50045
50241
|
return {
|
|
50046
50242
|
name: "array",
|
|
50047
|
-
responseFormat:
|
|
50243
|
+
responseFormat: resolve5(elementSchema.jsonSchema).then((jsonSchema2) => {
|
|
50048
50244
|
const { $schema, ...itemSchema } = jsonSchema2;
|
|
50049
50245
|
return {
|
|
50050
50246
|
type: "json",
|
|
@@ -51087,6 +51283,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
51087
51283
|
}),
|
|
51088
51284
|
tracer,
|
|
51089
51285
|
endWhenDone: false,
|
|
51286
|
+
endOnError: true,
|
|
51090
51287
|
fn: async (doStreamSpan2) => ({
|
|
51091
51288
|
startTimestampMs: now22(),
|
|
51092
51289
|
doStreamSpan: doStreamSpan2,
|
|
@@ -52006,10 +52203,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
52006
52203
|
onStepFinish,
|
|
52007
52204
|
...options
|
|
52008
52205
|
}) {
|
|
52206
|
+
const preparedCall = await this.prepareCall(options);
|
|
52009
52207
|
return generateText({
|
|
52010
|
-
...
|
|
52208
|
+
...preparedCall,
|
|
52011
52209
|
abortSignal,
|
|
52012
|
-
timeout,
|
|
52210
|
+
timeout: timeout != null ? timeout : preparedCall.timeout,
|
|
52013
52211
|
onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
|
|
52014
52212
|
});
|
|
52015
52213
|
}
|
|
@@ -52020,10 +52218,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
52020
52218
|
onStepFinish,
|
|
52021
52219
|
...options
|
|
52022
52220
|
}) {
|
|
52221
|
+
const preparedCall = await this.prepareCall(options);
|
|
52023
52222
|
return streamText({
|
|
52024
|
-
...
|
|
52223
|
+
...preparedCall,
|
|
52025
52224
|
abortSignal,
|
|
52026
|
-
timeout,
|
|
52225
|
+
timeout: timeout != null ? timeout : preparedCall.timeout,
|
|
52027
52226
|
experimental_transform,
|
|
52028
52227
|
onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
|
|
52029
52228
|
});
|
|
@@ -52380,6 +52579,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
52380
52579
|
}),
|
|
52381
52580
|
tracer,
|
|
52382
52581
|
endWhenDone: false,
|
|
52582
|
+
endOnError: true,
|
|
52383
52583
|
fn: async (rootSpan) => {
|
|
52384
52584
|
const standardizedPrompt = await standardizePrompt({
|
|
52385
52585
|
system,
|
|
@@ -52449,6 +52649,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
52449
52649
|
}),
|
|
52450
52650
|
tracer,
|
|
52451
52651
|
endWhenDone: false,
|
|
52652
|
+
endOnError: true,
|
|
52452
52653
|
fn: async (doStreamSpan2) => ({
|
|
52453
52654
|
startTimestampMs: now22(),
|
|
52454
52655
|
doStreamSpan: doStreamSpan2,
|
|
@@ -53035,9 +53236,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53035
53236
|
...options
|
|
53036
53237
|
}) {
|
|
53037
53238
|
var _a222, _b16, _c, _d, _e;
|
|
53038
|
-
const resolvedBody = await
|
|
53039
|
-
const resolvedHeaders = await
|
|
53040
|
-
const resolvedCredentials = await
|
|
53239
|
+
const resolvedBody = await resolve5(this.body);
|
|
53240
|
+
const resolvedHeaders = await resolve5(this.headers);
|
|
53241
|
+
const resolvedCredentials = await resolve5(this.credentials);
|
|
53041
53242
|
const baseHeaders = {
|
|
53042
53243
|
...normalizeHeaders(resolvedHeaders),
|
|
53043
53244
|
...normalizeHeaders(options.headers)
|
|
@@ -53085,9 +53286,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53085
53286
|
}
|
|
53086
53287
|
async reconnectToStream(options) {
|
|
53087
53288
|
var _a222, _b16, _c, _d, _e;
|
|
53088
|
-
const resolvedBody = await
|
|
53089
|
-
const resolvedHeaders = await
|
|
53090
|
-
const resolvedCredentials = await
|
|
53289
|
+
const resolvedBody = await resolve5(this.body);
|
|
53290
|
+
const resolvedHeaders = await resolve5(this.headers);
|
|
53291
|
+
const resolvedCredentials = await resolve5(this.credentials);
|
|
53091
53292
|
const baseHeaders = {
|
|
53092
53293
|
...normalizeHeaders(resolvedHeaders),
|
|
53093
53294
|
...normalizeHeaders(options.headers)
|
|
@@ -53107,7 +53308,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53107
53308
|
const response = await fetch2(api2, {
|
|
53108
53309
|
method: "GET",
|
|
53109
53310
|
headers,
|
|
53110
|
-
credentials
|
|
53311
|
+
credentials,
|
|
53312
|
+
signal: options.abortSignal
|
|
53111
53313
|
});
|
|
53112
53314
|
if (response.status === 204) {
|
|
53113
53315
|
return null;
|
|
@@ -53135,6 +53337,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53135
53337
|
sendAutomaticallyWhen
|
|
53136
53338
|
}) {
|
|
53137
53339
|
this.activeResponse = undefined;
|
|
53340
|
+
this.activeResumeRequest = undefined;
|
|
53138
53341
|
this.jobExecutor = new SerialJobExecutor;
|
|
53139
53342
|
this.sendMessage = async (message, options) => {
|
|
53140
53343
|
var _a222, _b16, _c, _d;
|
|
@@ -53276,12 +53479,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53276
53479
|
});
|
|
53277
53480
|
this.addToolResult = this.addToolOutput;
|
|
53278
53481
|
this.stop = async () => {
|
|
53279
|
-
var _a222;
|
|
53280
|
-
|
|
53281
|
-
|
|
53282
|
-
if ((_a222 = this.activeResponse) == null ? undefined : _a222.abortController) {
|
|
53283
|
-
this.activeResponse.abortController.abort();
|
|
53284
|
-
}
|
|
53482
|
+
var _a222, _b16;
|
|
53483
|
+
(_a222 = this.activeResumeRequest) == null || _a222.abortController.abort();
|
|
53484
|
+
(_b16 = this.activeResponse) == null || _b16.abortController.abort();
|
|
53285
53485
|
};
|
|
53286
53486
|
this.id = id;
|
|
53287
53487
|
this.transport = transport;
|
|
@@ -53337,25 +53537,59 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53337
53537
|
body,
|
|
53338
53538
|
messageId
|
|
53339
53539
|
}) {
|
|
53340
|
-
var _a222, _b16;
|
|
53540
|
+
var _a222, _b16, _c;
|
|
53541
|
+
const abortController = new AbortController;
|
|
53542
|
+
const activeResumeRequest = trigger === "resume-stream" ? { abortController } : undefined;
|
|
53543
|
+
if (activeResumeRequest) {
|
|
53544
|
+
(_a222 = this.activeResumeRequest) == null || _a222.abortController.abort();
|
|
53545
|
+
this.activeResumeRequest = activeResumeRequest;
|
|
53546
|
+
}
|
|
53547
|
+
const isCurrentRequest = () => activeResumeRequest == null || this.activeResumeRequest === activeResumeRequest;
|
|
53548
|
+
const clearActiveResumeRequest = () => {
|
|
53549
|
+
if (this.activeResumeRequest === activeResumeRequest) {
|
|
53550
|
+
this.activeResumeRequest = undefined;
|
|
53551
|
+
}
|
|
53552
|
+
};
|
|
53341
53553
|
let resumeStream;
|
|
53342
53554
|
if (trigger === "resume-stream") {
|
|
53343
53555
|
try {
|
|
53344
53556
|
const reconnect = await this.transport.reconnectToStream({
|
|
53345
53557
|
chatId: this.id,
|
|
53558
|
+
abortSignal: abortController.signal,
|
|
53346
53559
|
metadata,
|
|
53347
53560
|
headers,
|
|
53348
53561
|
body
|
|
53349
53562
|
});
|
|
53563
|
+
if (abortController.signal.aborted || !isCurrentRequest()) {
|
|
53564
|
+
await (reconnect == null ? undefined : reconnect.cancel().catch(() => {}));
|
|
53565
|
+
if (isCurrentRequest()) {
|
|
53566
|
+
this.setStatus({ status: "ready" });
|
|
53567
|
+
}
|
|
53568
|
+
clearActiveResumeRequest();
|
|
53569
|
+
return;
|
|
53570
|
+
}
|
|
53350
53571
|
if (reconnect == null) {
|
|
53572
|
+
this.setStatus({ status: "ready" });
|
|
53573
|
+
clearActiveResumeRequest();
|
|
53351
53574
|
return;
|
|
53352
53575
|
}
|
|
53353
53576
|
resumeStream = reconnect;
|
|
53354
53577
|
} catch (err) {
|
|
53578
|
+
if (abortController.signal.aborted || err.name === "AbortError") {
|
|
53579
|
+
if (isCurrentRequest()) {
|
|
53580
|
+
this.setStatus({ status: "ready" });
|
|
53581
|
+
}
|
|
53582
|
+
clearActiveResumeRequest();
|
|
53583
|
+
return;
|
|
53584
|
+
}
|
|
53585
|
+
if (!isCurrentRequest()) {
|
|
53586
|
+
return;
|
|
53587
|
+
}
|
|
53355
53588
|
if (this.onError && err instanceof Error) {
|
|
53356
53589
|
this.onError(err);
|
|
53357
53590
|
}
|
|
53358
53591
|
this.setStatus({ status: "error", error: err });
|
|
53592
|
+
clearActiveResumeRequest();
|
|
53359
53593
|
return;
|
|
53360
53594
|
}
|
|
53361
53595
|
}
|
|
@@ -53368,10 +53602,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53368
53602
|
try {
|
|
53369
53603
|
const response = {
|
|
53370
53604
|
state: createStreamingUIMessageState({
|
|
53371
|
-
lastMessage: trigger === "regenerate-message" ? undefined : this.state.snapshot(lastMessage),
|
|
53605
|
+
lastMessage: trigger === "resume-stream" || trigger === "regenerate-message" ? undefined : this.state.snapshot(lastMessage),
|
|
53372
53606
|
messageId: this.generateId()
|
|
53373
53607
|
}),
|
|
53374
|
-
abortController
|
|
53608
|
+
abortController
|
|
53375
53609
|
};
|
|
53376
53610
|
activeResponse = response;
|
|
53377
53611
|
response.abortController.signal.addEventListener("abort", () => {
|
|
@@ -53393,19 +53627,29 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53393
53627
|
messageId
|
|
53394
53628
|
});
|
|
53395
53629
|
}
|
|
53396
|
-
const runUpdateMessageJob = (job) => this.jobExecutor.run(() =>
|
|
53397
|
-
|
|
53398
|
-
|
|
53399
|
-
var _a232;
|
|
53400
|
-
this.setStatus({ status: "streaming" });
|
|
53401
|
-
const replaceLastMessage = response.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
|
|
53402
|
-
if (replaceLastMessage) {
|
|
53403
|
-
this.state.replaceMessage(this.state.messages.length - 1, response.state.message);
|
|
53404
|
-
} else {
|
|
53405
|
-
this.state.pushMessage(response.state.message);
|
|
53406
|
-
}
|
|
53630
|
+
const runUpdateMessageJob = (job) => this.jobExecutor.run(() => {
|
|
53631
|
+
if (response.abortController.signal.aborted) {
|
|
53632
|
+
return Promise.resolve();
|
|
53407
53633
|
}
|
|
53408
|
-
|
|
53634
|
+
return job({
|
|
53635
|
+
state: response.state,
|
|
53636
|
+
write: ({ updateStatus = true } = {}) => {
|
|
53637
|
+
var _a232;
|
|
53638
|
+
if (response.abortController.signal.aborted) {
|
|
53639
|
+
return;
|
|
53640
|
+
}
|
|
53641
|
+
if (updateStatus) {
|
|
53642
|
+
this.setStatus({ status: "streaming" });
|
|
53643
|
+
}
|
|
53644
|
+
const replaceLastMessage = response.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
|
|
53645
|
+
if (replaceLastMessage) {
|
|
53646
|
+
this.state.replaceMessage(this.state.messages.length - 1, response.state.message);
|
|
53647
|
+
} else {
|
|
53648
|
+
this.state.pushMessage(response.state.message);
|
|
53649
|
+
}
|
|
53650
|
+
}
|
|
53651
|
+
});
|
|
53652
|
+
});
|
|
53409
53653
|
await consumeStream({
|
|
53410
53654
|
stream: processUIMessageStream({
|
|
53411
53655
|
stream,
|
|
@@ -53418,15 +53662,29 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53418
53662
|
throw error40;
|
|
53419
53663
|
}
|
|
53420
53664
|
}),
|
|
53665
|
+
abortSignal: response.abortController.signal,
|
|
53421
53666
|
onError: (error40) => {
|
|
53422
53667
|
throw error40;
|
|
53423
53668
|
}
|
|
53424
53669
|
});
|
|
53425
|
-
|
|
53670
|
+
if (isAbort) {
|
|
53671
|
+
if (isCurrentRequest()) {
|
|
53672
|
+
this.setStatus({ status: "ready" });
|
|
53673
|
+
}
|
|
53674
|
+
return null;
|
|
53675
|
+
}
|
|
53676
|
+
if (isCurrentRequest()) {
|
|
53677
|
+
this.setStatus({ status: "ready" });
|
|
53678
|
+
}
|
|
53426
53679
|
} catch (err) {
|
|
53427
53680
|
if (isAbort || err.name === "AbortError") {
|
|
53428
53681
|
isAbort = true;
|
|
53429
|
-
|
|
53682
|
+
if (isCurrentRequest()) {
|
|
53683
|
+
this.setStatus({ status: "ready" });
|
|
53684
|
+
}
|
|
53685
|
+
return null;
|
|
53686
|
+
}
|
|
53687
|
+
if (!isCurrentRequest()) {
|
|
53430
53688
|
return null;
|
|
53431
53689
|
}
|
|
53432
53690
|
isError = true;
|
|
@@ -53440,7 +53698,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53440
53698
|
} finally {
|
|
53441
53699
|
try {
|
|
53442
53700
|
if (activeResponse) {
|
|
53443
|
-
(
|
|
53701
|
+
(_b16 = this.onFinish) == null || _b16.call(this, {
|
|
53444
53702
|
message: activeResponse.state.message,
|
|
53445
53703
|
messages: this.state.messages,
|
|
53446
53704
|
isAbort,
|
|
@@ -53449,17 +53707,17 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53449
53707
|
finishReason: activeResponse.state.finishReason
|
|
53450
53708
|
});
|
|
53451
53709
|
}
|
|
53452
|
-
}
|
|
53453
|
-
|
|
53454
|
-
|
|
53455
|
-
|
|
53456
|
-
|
|
53710
|
+
} finally {
|
|
53711
|
+
if (this.activeResponse === activeResponse) {
|
|
53712
|
+
this.activeResponse = undefined;
|
|
53713
|
+
}
|
|
53714
|
+
clearActiveResumeRequest();
|
|
53457
53715
|
}
|
|
53458
53716
|
}
|
|
53459
53717
|
if (!isError && await this.shouldSendAutomatically()) {
|
|
53460
53718
|
await this.makeRequest({
|
|
53461
53719
|
trigger: "submit-message",
|
|
53462
|
-
messageId: (
|
|
53720
|
+
messageId: (_c = this.lastMessage) == null ? undefined : _c.id,
|
|
53463
53721
|
metadata,
|
|
53464
53722
|
headers,
|
|
53465
53723
|
body
|
|
@@ -53498,96 +53756,96 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53498
53756
|
return null;
|
|
53499
53757
|
}
|
|
53500
53758
|
}, TextStreamChatTransport;
|
|
53501
|
-
var
|
|
53502
|
-
|
|
53503
|
-
|
|
53504
|
-
|
|
53505
|
-
|
|
53506
|
-
|
|
53507
|
-
|
|
53508
|
-
|
|
53509
|
-
|
|
53510
|
-
|
|
53511
|
-
|
|
53512
|
-
|
|
53513
|
-
|
|
53514
|
-
|
|
53515
|
-
|
|
53516
|
-
|
|
53517
|
-
|
|
53518
|
-
|
|
53519
|
-
|
|
53520
|
-
|
|
53521
|
-
|
|
53522
|
-
|
|
53523
|
-
|
|
53524
|
-
|
|
53525
|
-
|
|
53526
|
-
|
|
53527
|
-
|
|
53528
|
-
|
|
53529
|
-
|
|
53530
|
-
|
|
53531
|
-
|
|
53532
|
-
|
|
53533
|
-
|
|
53534
|
-
|
|
53759
|
+
var init_dist9 = __esm(() => {
|
|
53760
|
+
init_dist8();
|
|
53761
|
+
init_dist4();
|
|
53762
|
+
init_dist4();
|
|
53763
|
+
init_dist4();
|
|
53764
|
+
init_dist2();
|
|
53765
|
+
init_dist2();
|
|
53766
|
+
init_dist2();
|
|
53767
|
+
init_dist2();
|
|
53768
|
+
init_dist2();
|
|
53769
|
+
init_dist2();
|
|
53770
|
+
init_dist2();
|
|
53771
|
+
init_dist2();
|
|
53772
|
+
init_dist2();
|
|
53773
|
+
init_dist2();
|
|
53774
|
+
init_dist2();
|
|
53775
|
+
init_dist2();
|
|
53776
|
+
init_dist2();
|
|
53777
|
+
init_dist2();
|
|
53778
|
+
init_dist2();
|
|
53779
|
+
init_dist2();
|
|
53780
|
+
init_dist2();
|
|
53781
|
+
init_dist2();
|
|
53782
|
+
init_dist2();
|
|
53783
|
+
init_dist2();
|
|
53784
|
+
init_dist2();
|
|
53785
|
+
init_dist4();
|
|
53786
|
+
init_dist2();
|
|
53787
|
+
init_dist8();
|
|
53788
|
+
init_dist4();
|
|
53789
|
+
init_dist4();
|
|
53790
|
+
init_dist4();
|
|
53791
|
+
init_dist2();
|
|
53792
|
+
init_dist4();
|
|
53535
53793
|
init_v4();
|
|
53536
|
-
|
|
53537
|
-
|
|
53538
|
-
|
|
53539
|
-
|
|
53794
|
+
init_dist2();
|
|
53795
|
+
init_dist4();
|
|
53796
|
+
init_dist2();
|
|
53797
|
+
init_dist4();
|
|
53540
53798
|
init_v4();
|
|
53541
53799
|
init_v4();
|
|
53542
53800
|
init_v4();
|
|
53543
53801
|
init_v4();
|
|
53544
53802
|
init_v4();
|
|
53545
|
-
|
|
53546
|
-
|
|
53547
|
-
|
|
53548
|
-
|
|
53549
|
-
|
|
53550
|
-
|
|
53551
|
-
|
|
53552
|
-
|
|
53553
|
-
|
|
53554
|
-
|
|
53555
|
-
|
|
53556
|
-
|
|
53557
|
-
|
|
53558
|
-
|
|
53559
|
-
|
|
53560
|
-
|
|
53803
|
+
init_dist8();
|
|
53804
|
+
init_dist2();
|
|
53805
|
+
init_dist2();
|
|
53806
|
+
init_dist8();
|
|
53807
|
+
init_dist4();
|
|
53808
|
+
init_dist4();
|
|
53809
|
+
init_dist4();
|
|
53810
|
+
init_dist4();
|
|
53811
|
+
init_dist4();
|
|
53812
|
+
init_dist2();
|
|
53813
|
+
init_dist4();
|
|
53814
|
+
init_dist4();
|
|
53815
|
+
init_dist4();
|
|
53816
|
+
init_dist2();
|
|
53817
|
+
init_dist4();
|
|
53818
|
+
init_dist4();
|
|
53561
53819
|
init_v4();
|
|
53562
|
-
|
|
53563
|
-
|
|
53564
|
-
|
|
53565
|
-
|
|
53566
|
-
|
|
53567
|
-
|
|
53820
|
+
init_dist4();
|
|
53821
|
+
init_dist4();
|
|
53822
|
+
init_dist4();
|
|
53823
|
+
init_dist4();
|
|
53824
|
+
init_dist2();
|
|
53825
|
+
init_dist4();
|
|
53568
53826
|
init_v4();
|
|
53569
|
-
|
|
53570
|
-
|
|
53571
|
-
|
|
53572
|
-
|
|
53573
|
-
|
|
53574
|
-
|
|
53575
|
-
|
|
53576
|
-
|
|
53577
|
-
|
|
53578
|
-
|
|
53579
|
-
|
|
53580
|
-
|
|
53581
|
-
|
|
53582
|
-
|
|
53583
|
-
|
|
53584
|
-
|
|
53585
|
-
|
|
53586
|
-
|
|
53587
|
-
|
|
53588
|
-
|
|
53589
|
-
|
|
53590
|
-
|
|
53827
|
+
init_dist4();
|
|
53828
|
+
init_dist4();
|
|
53829
|
+
init_dist4();
|
|
53830
|
+
init_dist4();
|
|
53831
|
+
init_dist2();
|
|
53832
|
+
init_dist4();
|
|
53833
|
+
init_dist2();
|
|
53834
|
+
init_dist4();
|
|
53835
|
+
init_dist4();
|
|
53836
|
+
init_dist4();
|
|
53837
|
+
init_dist4();
|
|
53838
|
+
init_dist4();
|
|
53839
|
+
init_dist2();
|
|
53840
|
+
init_dist4();
|
|
53841
|
+
init_dist2();
|
|
53842
|
+
init_dist2();
|
|
53843
|
+
init_dist2();
|
|
53844
|
+
init_dist4();
|
|
53845
|
+
init_dist4();
|
|
53846
|
+
init_dist4();
|
|
53847
|
+
init_dist4();
|
|
53848
|
+
init_dist4();
|
|
53591
53849
|
import_api2 = __toESM(require_src(), 1);
|
|
53592
53850
|
import_api3 = __toESM(require_src(), 1);
|
|
53593
53851
|
__defProp2 = Object.defineProperty;
|
|
@@ -54646,6 +54904,7 @@ var init_dist8 = __esm(() => {
|
|
|
54646
54904
|
}),
|
|
54647
54905
|
exports_external2.object({
|
|
54648
54906
|
type: exports_external2.literal("reasoning"),
|
|
54907
|
+
id: exports_external2.string().optional(),
|
|
54649
54908
|
text: exports_external2.string(),
|
|
54650
54909
|
state: exports_external2.enum(["streaming", "done"]).optional(),
|
|
54651
54910
|
providerMetadata: providerMetadataSchema.optional()
|
|
@@ -55256,19 +55515,20 @@ var init_openapi = __esm(() => {
|
|
|
55256
55515
|
});
|
|
55257
55516
|
|
|
55258
55517
|
// src/server/index.ts
|
|
55259
|
-
import { existsSync as
|
|
55518
|
+
import { existsSync as existsSync6 } from "fs";
|
|
55260
55519
|
import { createRequire } from "module";
|
|
55261
|
-
import { join as
|
|
55520
|
+
import { join as join9, resolve as resolve6, sep } from "path";
|
|
55262
55521
|
|
|
55263
55522
|
// src/lib/config.ts
|
|
55264
|
-
|
|
55265
|
-
import {
|
|
55266
|
-
import {
|
|
55523
|
+
init_paths();
|
|
55524
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync, readdirSync, writeFileSync, unlinkSync, cpSync } from "fs";
|
|
55525
|
+
import { homedir as homedir3 } from "os";
|
|
55526
|
+
import { basename, dirname, join as join3, resolve as resolve2 } from "path";
|
|
55267
55527
|
function isInMemoryDb(path) {
|
|
55268
55528
|
return path === ":memory:" || path.startsWith("file::memory:");
|
|
55269
55529
|
}
|
|
55270
55530
|
function homeDir() {
|
|
55271
|
-
return process.env["HOME"] || process.env["USERPROFILE"] ||
|
|
55531
|
+
return process.env["HOME"] || process.env["USERPROFILE"] || homedir3();
|
|
55272
55532
|
}
|
|
55273
55533
|
var DEFAULT_CONFIG = {
|
|
55274
55534
|
default_scope: "private",
|
|
@@ -55326,9 +55586,9 @@ function isValidCategory(value) {
|
|
|
55326
55586
|
return VALID_CATEGORIES.includes(value);
|
|
55327
55587
|
}
|
|
55328
55588
|
function loadConfig() {
|
|
55329
|
-
const configPath =
|
|
55589
|
+
const configPath = join3(getDataRoot(), "config.json");
|
|
55330
55590
|
let fileConfig = {};
|
|
55331
|
-
if (
|
|
55591
|
+
if (existsSync2(configPath)) {
|
|
55332
55592
|
try {
|
|
55333
55593
|
const raw = readFileSync(configPath, "utf-8");
|
|
55334
55594
|
fileConfig = JSON.parse(raw);
|
|
@@ -55354,10 +55614,10 @@ function loadConfig() {
|
|
|
55354
55614
|
}
|
|
55355
55615
|
function findFileWalkingUp(filename) {
|
|
55356
55616
|
let dir = process.cwd();
|
|
55357
|
-
const legacyHomeMementosDb =
|
|
55617
|
+
const legacyHomeMementosDb = resolve2(homeDir(), ".mementos", "mementos.db");
|
|
55358
55618
|
while (true) {
|
|
55359
|
-
const candidate =
|
|
55360
|
-
if (
|
|
55619
|
+
const candidate = join3(dir, filename);
|
|
55620
|
+
if (existsSync2(candidate) && resolve2(candidate) !== legacyHomeMementosDb) {
|
|
55361
55621
|
return candidate;
|
|
55362
55622
|
}
|
|
55363
55623
|
const parent = dirname(dir);
|
|
@@ -55370,7 +55630,7 @@ function findFileWalkingUp(filename) {
|
|
|
55370
55630
|
function findGitRoot() {
|
|
55371
55631
|
let dir = process.cwd();
|
|
55372
55632
|
while (true) {
|
|
55373
|
-
if (
|
|
55633
|
+
if (existsSync2(join3(dir, ".git"))) {
|
|
55374
55634
|
return dir;
|
|
55375
55635
|
}
|
|
55376
55636
|
const parent = dirname(dir);
|
|
@@ -55381,14 +55641,14 @@ function findGitRoot() {
|
|
|
55381
55641
|
}
|
|
55382
55642
|
}
|
|
55383
55643
|
function profilesDir() {
|
|
55384
|
-
return
|
|
55644
|
+
return join3(getDataRoot(), "profiles");
|
|
55385
55645
|
}
|
|
55386
55646
|
function globalConfigPath() {
|
|
55387
|
-
return
|
|
55647
|
+
return join3(getDataRoot(), "config.json");
|
|
55388
55648
|
}
|
|
55389
55649
|
function readGlobalConfig() {
|
|
55390
55650
|
const p = globalConfigPath();
|
|
55391
|
-
if (!
|
|
55651
|
+
if (!existsSync2(p))
|
|
55392
55652
|
return {};
|
|
55393
55653
|
try {
|
|
55394
55654
|
return JSON.parse(readFileSync(p, "utf-8"));
|
|
@@ -55405,16 +55665,16 @@ function getActiveProfile() {
|
|
|
55405
55665
|
}
|
|
55406
55666
|
function listProfiles() {
|
|
55407
55667
|
const dir = profilesDir();
|
|
55408
|
-
if (!
|
|
55668
|
+
if (!existsSync2(dir))
|
|
55409
55669
|
return [];
|
|
55410
55670
|
return readdirSync(dir).filter((f) => f.endsWith(".db")).map((f) => basename(f, ".db")).sort();
|
|
55411
55671
|
}
|
|
55412
55672
|
function getDbPath() {
|
|
55413
55673
|
const _home = homeDir();
|
|
55414
|
-
const _newDir =
|
|
55415
|
-
const _oldDir =
|
|
55416
|
-
if (!
|
|
55417
|
-
mkdirSync(
|
|
55674
|
+
const _newDir = getDataRoot();
|
|
55675
|
+
const _oldDir = join3(_home, ".mementos");
|
|
55676
|
+
if (!existsSync2(_newDir) && existsSync2(_oldDir)) {
|
|
55677
|
+
mkdirSync(join3(_home, ".hasna"), { recursive: true });
|
|
55418
55678
|
cpSync(_oldDir, _newDir, { recursive: true });
|
|
55419
55679
|
}
|
|
55420
55680
|
const envDbPath = process.env["HASNA_MEMENTOS_DB_PATH"] ?? process.env["MEMENTOS_DB_PATH"];
|
|
@@ -55422,13 +55682,13 @@ function getDbPath() {
|
|
|
55422
55682
|
if (isInMemoryDb(envDbPath)) {
|
|
55423
55683
|
return envDbPath;
|
|
55424
55684
|
}
|
|
55425
|
-
const resolved =
|
|
55685
|
+
const resolved = resolve2(envDbPath);
|
|
55426
55686
|
ensureDir(dirname(resolved));
|
|
55427
55687
|
return resolved;
|
|
55428
55688
|
}
|
|
55429
55689
|
const profile = getActiveProfile();
|
|
55430
55690
|
if (profile) {
|
|
55431
|
-
const profilePath =
|
|
55691
|
+
const profilePath = join3(profilesDir(), `${profile}.db`);
|
|
55432
55692
|
ensureDir(dirname(profilePath));
|
|
55433
55693
|
return profilePath;
|
|
55434
55694
|
}
|
|
@@ -55436,21 +55696,21 @@ function getDbPath() {
|
|
|
55436
55696
|
if (dbScope === "project") {
|
|
55437
55697
|
const gitRoot = findGitRoot();
|
|
55438
55698
|
if (gitRoot) {
|
|
55439
|
-
const dbPath =
|
|
55699
|
+
const dbPath = join3(gitRoot, ".mementos", "mementos.db");
|
|
55440
55700
|
ensureDir(dirname(dbPath));
|
|
55441
55701
|
return dbPath;
|
|
55442
55702
|
}
|
|
55443
55703
|
}
|
|
55444
|
-
const found = findFileWalkingUp(
|
|
55704
|
+
const found = findFileWalkingUp(join3(".mementos", "mementos.db"));
|
|
55445
55705
|
if (found) {
|
|
55446
55706
|
return found;
|
|
55447
55707
|
}
|
|
55448
|
-
const fallback =
|
|
55708
|
+
const fallback = join3(getDataRoot(), "mementos.db");
|
|
55449
55709
|
ensureDir(dirname(fallback));
|
|
55450
55710
|
return fallback;
|
|
55451
55711
|
}
|
|
55452
55712
|
function ensureDir(dir) {
|
|
55453
|
-
if (!
|
|
55713
|
+
if (!existsSync2(dir)) {
|
|
55454
55714
|
mkdirSync(dir, { recursive: true });
|
|
55455
55715
|
}
|
|
55456
55716
|
}
|
|
@@ -57444,8 +57704,8 @@ function getMemoryHealth(filter = {}, db) {
|
|
|
57444
57704
|
init_router();
|
|
57445
57705
|
|
|
57446
57706
|
// src/server/helpers.ts
|
|
57447
|
-
import { existsSync as
|
|
57448
|
-
import { dirname as dirname3, extname, join as
|
|
57707
|
+
import { existsSync as existsSync5 } from "fs";
|
|
57708
|
+
import { dirname as dirname3, extname, join as join7 } from "path";
|
|
57449
57709
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
57450
57710
|
var CORS_HEADERS = {
|
|
57451
57711
|
"Access-Control-Allow-Origin": process.env["MEMENTOS_CORS_ORIGIN"] ?? "http://localhost:19428",
|
|
@@ -57453,6 +57713,43 @@ var CORS_HEADERS = {
|
|
|
57453
57713
|
"Access-Control-Allow-Headers": "Content-Type, Authorization",
|
|
57454
57714
|
"Access-Control-Max-Age": "86400"
|
|
57455
57715
|
};
|
|
57716
|
+
var STATE_CHANGING_METHODS = new Set(["POST", "PATCH", "PUT", "DELETE"]);
|
|
57717
|
+
function isStateChangingMethod(method) {
|
|
57718
|
+
return STATE_CHANGING_METHODS.has(method);
|
|
57719
|
+
}
|
|
57720
|
+
function getAllowedOrigins() {
|
|
57721
|
+
const raw = process.env["MEMENTOS_CORS_ORIGIN"] ?? "http://localhost:19428";
|
|
57722
|
+
return raw.split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
57723
|
+
}
|
|
57724
|
+
function hostOf(entry) {
|
|
57725
|
+
try {
|
|
57726
|
+
return new URL(entry).host;
|
|
57727
|
+
} catch {
|
|
57728
|
+
return entry;
|
|
57729
|
+
}
|
|
57730
|
+
}
|
|
57731
|
+
function checkOriginOrHost(req, method) {
|
|
57732
|
+
if (!isStateChangingMethod(method))
|
|
57733
|
+
return null;
|
|
57734
|
+
return checkWriteOriginOrHost(req);
|
|
57735
|
+
}
|
|
57736
|
+
function checkWriteOriginOrHost(req) {
|
|
57737
|
+
const allowlist = getAllowedOrigins();
|
|
57738
|
+
const allowedHosts = allowlist.map(hostOf);
|
|
57739
|
+
const origin = req.headers.get("origin");
|
|
57740
|
+
if (origin !== null) {
|
|
57741
|
+
if (allowlist.includes(origin))
|
|
57742
|
+
return null;
|
|
57743
|
+
return json({ error: "Forbidden. Origin is not allowed." }, 403);
|
|
57744
|
+
}
|
|
57745
|
+
const host = req.headers.get("host");
|
|
57746
|
+
if (host !== null) {
|
|
57747
|
+
if (allowedHosts.includes(host))
|
|
57748
|
+
return null;
|
|
57749
|
+
return json({ error: "Forbidden. Host is not allowed." }, 403);
|
|
57750
|
+
}
|
|
57751
|
+
return json({ error: "Forbidden. Missing Origin or Host header." }, 403);
|
|
57752
|
+
}
|
|
57456
57753
|
var MIME_TYPES = {
|
|
57457
57754
|
".html": "text/html; charset=utf-8",
|
|
57458
57755
|
".js": "application/javascript",
|
|
@@ -57499,9 +57796,9 @@ async function readJson(req) {
|
|
|
57499
57796
|
}
|
|
57500
57797
|
}
|
|
57501
57798
|
function getCorsHeaders(req) {
|
|
57502
|
-
const
|
|
57799
|
+
const allowlist = getAllowedOrigins();
|
|
57503
57800
|
const origin = req?.headers.get("origin");
|
|
57504
|
-
const finalOrigin = origin ===
|
|
57801
|
+
const finalOrigin = typeof origin === "string" && allowlist.includes(origin) ? origin : allowlist[0] ?? "http://localhost:19428";
|
|
57505
57802
|
return {
|
|
57506
57803
|
"Access-Control-Allow-Origin": finalOrigin,
|
|
57507
57804
|
"Access-Control-Allow-Methods": "GET, POST, PATCH, DELETE, OPTIONS",
|
|
@@ -57540,23 +57837,23 @@ function resolveDashboardDir() {
|
|
|
57540
57837
|
const candidates = [];
|
|
57541
57838
|
try {
|
|
57542
57839
|
const scriptDir = dirname3(fileURLToPath2(import.meta.url));
|
|
57543
|
-
candidates.push(
|
|
57544
|
-
candidates.push(
|
|
57840
|
+
candidates.push(join7(scriptDir, "..", "dashboard", "dist"));
|
|
57841
|
+
candidates.push(join7(scriptDir, "..", "..", "dashboard", "dist"));
|
|
57545
57842
|
} catch {}
|
|
57546
57843
|
if (process.argv[1]) {
|
|
57547
57844
|
const mainDir = dirname3(process.argv[1]);
|
|
57548
|
-
candidates.push(
|
|
57549
|
-
candidates.push(
|
|
57845
|
+
candidates.push(join7(mainDir, "..", "dashboard", "dist"));
|
|
57846
|
+
candidates.push(join7(mainDir, "..", "..", "dashboard", "dist"));
|
|
57550
57847
|
}
|
|
57551
|
-
candidates.push(
|
|
57848
|
+
candidates.push(join7(process.cwd(), "dashboard", "dist"));
|
|
57552
57849
|
for (const c of candidates) {
|
|
57553
|
-
if (
|
|
57850
|
+
if (existsSync5(c))
|
|
57554
57851
|
return c;
|
|
57555
57852
|
}
|
|
57556
|
-
return
|
|
57853
|
+
return join7(process.cwd(), "dashboard", "dist");
|
|
57557
57854
|
}
|
|
57558
57855
|
function serveStaticFile(filePath) {
|
|
57559
|
-
if (!
|
|
57856
|
+
if (!existsSync5(filePath))
|
|
57560
57857
|
return null;
|
|
57561
57858
|
const ct = MIME_TYPES[extname(filePath)] || "application/octet-stream";
|
|
57562
57859
|
return new Response(Bun.file(filePath), {
|
|
@@ -57628,6 +57925,9 @@ function getApiKeyVerifier() {
|
|
|
57628
57925
|
async function checkApiKey(req, method, path, requiredScopes) {
|
|
57629
57926
|
const verifier = getApiKeyVerifier();
|
|
57630
57927
|
if (!verifier) {
|
|
57928
|
+
if (isStateChangingMethod(method) && !unauthenticatedWritesAllowed()) {
|
|
57929
|
+
return json({ error: "Unauthorized. No API key is configured; state-changing requests are refused." }, 401);
|
|
57930
|
+
}
|
|
57631
57931
|
return authenticateRequest(req);
|
|
57632
57932
|
}
|
|
57633
57933
|
if (_schemaReady)
|
|
@@ -57637,6 +57937,10 @@ async function checkApiKey(req, method, path, requiredScopes) {
|
|
|
57637
57937
|
return null;
|
|
57638
57938
|
return json({ error: decision.message, reason: decision.reason }, decision.status);
|
|
57639
57939
|
}
|
|
57940
|
+
function unauthenticatedWritesAllowed() {
|
|
57941
|
+
const raw = process.env["MEMENTOS_ALLOW_UNAUTHENTICATED_WRITES"]?.trim().toLowerCase();
|
|
57942
|
+
return raw === "1" || raw === "true" || raw === "yes";
|
|
57943
|
+
}
|
|
57640
57944
|
|
|
57641
57945
|
// src/server/routes/memories-crud.ts
|
|
57642
57946
|
init_memories();
|
|
@@ -57785,10 +58089,16 @@ addRoute("POST", "/api/memories", async (req) => {
|
|
|
57785
58089
|
if (e instanceof DuplicateMemoryError) {
|
|
57786
58090
|
return errorResponse(e.message, 409);
|
|
57787
58091
|
}
|
|
58092
|
+
if (e instanceof MemoryConflictError) {
|
|
58093
|
+
return errorResponse(e.message, 409);
|
|
58094
|
+
}
|
|
57788
58095
|
throw e;
|
|
57789
58096
|
}
|
|
57790
58097
|
});
|
|
57791
|
-
addRoute("GET", "/api/memories/:id", (
|
|
58098
|
+
addRoute("GET", "/api/memories/:id", (req, _url, params) => {
|
|
58099
|
+
const gate = checkWriteOriginOrHost(req);
|
|
58100
|
+
if (gate)
|
|
58101
|
+
return gate;
|
|
57792
58102
|
const memory = getMemory(params["id"]);
|
|
57793
58103
|
if (!memory) {
|
|
57794
58104
|
return errorResponse("Memory not found", 404);
|
|
@@ -57832,6 +58142,9 @@ addRoute("PATCH", "/api/memories/:id", async (req, _url, params) => {
|
|
|
57832
58142
|
actual: e.actual
|
|
57833
58143
|
});
|
|
57834
58144
|
}
|
|
58145
|
+
if (e instanceof MemoryConflictError) {
|
|
58146
|
+
return errorResponse(e.message, 409);
|
|
58147
|
+
}
|
|
57835
58148
|
throw e;
|
|
57836
58149
|
}
|
|
57837
58150
|
});
|
|
@@ -58857,7 +59170,10 @@ addRoute("POST", "/api/maintenance/cleanup", () => {
|
|
|
58857
59170
|
const result = runCleanup(loadConfig());
|
|
58858
59171
|
return json(result);
|
|
58859
59172
|
});
|
|
58860
|
-
addRoute("GET", "/api/inject", (
|
|
59173
|
+
addRoute("GET", "/api/inject", (req, url) => {
|
|
59174
|
+
const gate = checkWriteOriginOrHost(req);
|
|
59175
|
+
if (gate)
|
|
59176
|
+
return gate;
|
|
58861
59177
|
const q = getSearchParams(url);
|
|
58862
59178
|
const maxTokens = q["max_tokens"] ? parseInt(q["max_tokens"], 10) : 500;
|
|
58863
59179
|
const minImportance = 3;
|
|
@@ -58965,13 +59281,13 @@ import { createHash } from "crypto";
|
|
|
58965
59281
|
|
|
58966
59282
|
// src/lib/package-version.ts
|
|
58967
59283
|
import { readFileSync as readFileSync3 } from "fs";
|
|
58968
|
-
import { dirname as dirname4, join as
|
|
59284
|
+
import { dirname as dirname4, join as join8 } from "path";
|
|
58969
59285
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
58970
59286
|
function getMementosPackageVersion() {
|
|
58971
59287
|
const here = dirname4(fileURLToPath3(import.meta.url));
|
|
58972
59288
|
for (const candidate of [
|
|
58973
|
-
|
|
58974
|
-
|
|
59289
|
+
join8(here, "..", "..", "package.json"),
|
|
59290
|
+
join8(here, "..", "package.json")
|
|
58975
59291
|
]) {
|
|
58976
59292
|
try {
|
|
58977
59293
|
const parsed = JSON.parse(readFileSync3(candidate, "utf8"));
|
|
@@ -60735,7 +61051,7 @@ function getProjectUpdateReceipt(id, receiptId, identity = projectUpdateAuthorit
|
|
|
60735
61051
|
|
|
60736
61052
|
// src/project-registration/authority.ts
|
|
60737
61053
|
import { createHash as createHash3 } from "crypto";
|
|
60738
|
-
import { resolve as
|
|
61054
|
+
import { resolve as resolve4 } from "path";
|
|
60739
61055
|
|
|
60740
61056
|
// src/project-registration/project-references.ts
|
|
60741
61057
|
var MEMENTOS_PROJECT_REFERENCE_SURFACES = [
|
|
@@ -60912,7 +61228,7 @@ function ownedPath(target) {
|
|
|
60912
61228
|
}
|
|
60913
61229
|
const path = target.withOwnedPath((value) => value);
|
|
60914
61230
|
requireString(path, "target path", { max: 4096 });
|
|
60915
|
-
if (path !==
|
|
61231
|
+
if (path !== resolve4(path)) {
|
|
60916
61232
|
throw new MementosProjectRegistrationError("MEMENTOS_PROJECT_REGISTRATION_INVALID_INPUT", "target path must already be canonical and absolute");
|
|
60917
61233
|
}
|
|
60918
61234
|
return path;
|
|
@@ -63762,13 +64078,13 @@ function registerSystemSynthesisRoutes() {
|
|
|
63762
64078
|
return json({ error: e instanceof Error ? e.message : String(e) }, 500);
|
|
63763
64079
|
}
|
|
63764
64080
|
});
|
|
63765
|
-
addRoute("
|
|
63766
|
-
const
|
|
64081
|
+
addRoute("POST", "/api/profile/synthesize", async (req) => {
|
|
64082
|
+
const body = await readJson(req) ?? {};
|
|
63767
64083
|
try {
|
|
63768
64084
|
const result = await synthesizeProfile({
|
|
63769
|
-
project_id:
|
|
63770
|
-
agent_id:
|
|
63771
|
-
force_refresh:
|
|
64085
|
+
project_id: body["project_id"],
|
|
64086
|
+
agent_id: body["agent_id"],
|
|
64087
|
+
force_refresh: body["force_refresh"] === true
|
|
63772
64088
|
});
|
|
63773
64089
|
if (!result) {
|
|
63774
64090
|
return json({ profile: null, message: "No preference/fact memories found to synthesize" });
|
|
@@ -64828,7 +65144,7 @@ async function resolveAISDKModel(provider, model) {
|
|
|
64828
65144
|
const key = process.env["ANTHROPIC_API_KEY"];
|
|
64829
65145
|
if (!key)
|
|
64830
65146
|
return null;
|
|
64831
|
-
const mod = await Promise.resolve().then(() => (
|
|
65147
|
+
const mod = await Promise.resolve().then(() => (init_dist5(), exports_dist));
|
|
64832
65148
|
const anthropic2 = mod["anthropic"];
|
|
64833
65149
|
return anthropic2 ? anthropic2(model) : null;
|
|
64834
65150
|
}
|
|
@@ -64836,7 +65152,7 @@ async function resolveAISDKModel(provider, model) {
|
|
|
64836
65152
|
const key = process.env["OPENAI_API_KEY"];
|
|
64837
65153
|
if (!key)
|
|
64838
65154
|
return null;
|
|
64839
|
-
const mod = await Promise.resolve().then(() => (
|
|
65155
|
+
const mod = await Promise.resolve().then(() => (init_dist6(), exports_dist2));
|
|
64840
65156
|
const openai2 = mod["openai"];
|
|
64841
65157
|
return openai2 ? openai2(model) : null;
|
|
64842
65158
|
}
|
|
@@ -64845,7 +65161,7 @@ async function resolveAISDKModel(provider, model) {
|
|
|
64845
65161
|
if (!apiKey)
|
|
64846
65162
|
return null;
|
|
64847
65163
|
const baseURL = provider === "cerebras" ? "https://api.cerebras.ai/v1" : "https://api.x.ai/v1";
|
|
64848
|
-
const mod = await Promise.resolve().then(() => (
|
|
65164
|
+
const mod = await Promise.resolve().then(() => (init_dist7(), exports_dist3));
|
|
64849
65165
|
const createOpenAICompatible2 = mod["createOpenAICompatible"];
|
|
64850
65166
|
if (!createOpenAICompatible2)
|
|
64851
65167
|
return null;
|
|
@@ -64861,7 +65177,7 @@ function createAISDKReflectionCritic(options = {}) {
|
|
|
64861
65177
|
if (!resolvedModel)
|
|
64862
65178
|
return heuristicReflectionCritic(trajectory);
|
|
64863
65179
|
try {
|
|
64864
|
-
const ai = await Promise.resolve().then(() => (
|
|
65180
|
+
const ai = await Promise.resolve().then(() => (init_dist9(), exports_dist4));
|
|
64865
65181
|
const generateObject2 = ai["generateObject"];
|
|
64866
65182
|
if (!generateObject2)
|
|
64867
65183
|
return heuristicReflectionCritic(trajectory);
|
|
@@ -65127,18 +65443,18 @@ function pkgVersion() {
|
|
|
65127
65443
|
}
|
|
65128
65444
|
async function findFreePort(start) {
|
|
65129
65445
|
const net = await import("net");
|
|
65130
|
-
return new Promise((
|
|
65446
|
+
return new Promise((resolve7) => {
|
|
65131
65447
|
const server = net.createServer();
|
|
65132
65448
|
server.unref();
|
|
65133
65449
|
server.on("error", () => {
|
|
65134
|
-
|
|
65450
|
+
resolve7(findFreePort(start + 1));
|
|
65135
65451
|
});
|
|
65136
65452
|
server.listen(start, () => {
|
|
65137
65453
|
const address = server.address();
|
|
65138
65454
|
if (address && typeof address === "object") {
|
|
65139
|
-
server.close(() =>
|
|
65455
|
+
server.close(() => resolve7(address.port));
|
|
65140
65456
|
} else {
|
|
65141
|
-
|
|
65457
|
+
resolve7(start);
|
|
65142
65458
|
}
|
|
65143
65459
|
});
|
|
65144
65460
|
});
|
|
@@ -65220,12 +65536,14 @@ function startServer(port) {
|
|
|
65220
65536
|
const { pathname } = url2;
|
|
65221
65537
|
if (req.method === "OPTIONS") {
|
|
65222
65538
|
const origin = req.headers.get("origin");
|
|
65223
|
-
|
|
65224
|
-
if (origin && origin !== allowedOrigin) {
|
|
65539
|
+
if (origin && !getAllowedOrigins().includes(origin)) {
|
|
65225
65540
|
return new Response(null, { status: 403 });
|
|
65226
65541
|
}
|
|
65227
65542
|
return new Response(null, { status: 204, headers: getCorsHeaders(req) });
|
|
65228
65543
|
}
|
|
65544
|
+
const originGate = checkOriginOrHost(req, req.method);
|
|
65545
|
+
if (originGate)
|
|
65546
|
+
return originGate;
|
|
65229
65547
|
const backend = getStorageBackend();
|
|
65230
65548
|
if (pathname === "/version" || pathname === "/api/version" || pathname === "/v1/version") {
|
|
65231
65549
|
return json({ status: "ok", version: pkgVersion(), backend });
|
|
@@ -65309,17 +65627,17 @@ function startServer(port) {
|
|
|
65309
65627
|
return errorResponse("Not found", 404);
|
|
65310
65628
|
}
|
|
65311
65629
|
const dashDir = resolveDashboardDir();
|
|
65312
|
-
if (
|
|
65630
|
+
if (existsSync6(dashDir) && (req.method === "GET" || req.method === "HEAD")) {
|
|
65313
65631
|
if (pathname !== "/") {
|
|
65314
|
-
const resolvedDash =
|
|
65315
|
-
const requestedPath =
|
|
65632
|
+
const resolvedDash = resolve6(dashDir) + sep;
|
|
65633
|
+
const requestedPath = resolve6(join9(dashDir, pathname));
|
|
65316
65634
|
if (requestedPath.startsWith(resolvedDash)) {
|
|
65317
65635
|
const staticRes = serveStaticFile(requestedPath);
|
|
65318
65636
|
if (staticRes)
|
|
65319
65637
|
return staticRes;
|
|
65320
65638
|
}
|
|
65321
65639
|
}
|
|
65322
|
-
const indexRes = serveStaticFile(
|
|
65640
|
+
const indexRes = serveStaticFile(join9(dashDir, "index.html"));
|
|
65323
65641
|
if (indexRes)
|
|
65324
65642
|
return indexRes;
|
|
65325
65643
|
}
|