@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/dist/index.js CHANGED
@@ -152,11 +152,119 @@ var init_retired_storage_mode = __esm(() => {
152
152
  ];
153
153
  });
154
154
 
155
- // src/storage.ts
156
- import { Database } from "bun:sqlite";
157
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
155
+ // ../../node_modules/.bun/@hasna+paths@0.1.0/node_modules/@hasna/paths/dist/index.js
158
156
  import { homedir } from "os";
159
157
  import { join } from "path";
158
+ function assertApp(app) {
159
+ if (typeof app !== "string" || app.length === 0) {
160
+ throw new TypeError("paths: app must be a non-empty string");
161
+ }
162
+ if (!APP_SLUG_RE.test(app)) {
163
+ throw new TypeError(`paths: invalid app slug "${app}" \u2014 expected lowercase kebab-case ([a-z0-9]+(-[a-z0-9]+)*)`);
164
+ }
165
+ }
166
+ function envOf(options) {
167
+ return options.env ?? process.env;
168
+ }
169
+ function envValue(options, kind) {
170
+ const value = envOf(options)[KIND_ENV[kind]];
171
+ return typeof value === "string" && value.length > 0 ? value : undefined;
172
+ }
173
+ function isMacOS(platform) {
174
+ return platform === "darwin";
175
+ }
176
+ function baseDir(kind, options) {
177
+ const override = envValue(options, kind);
178
+ if (override)
179
+ return override;
180
+ const home = options.home ?? homedir();
181
+ const platform = options.platform ?? process.platform;
182
+ if (isMacOS(platform)) {
183
+ switch (kind) {
184
+ case "config":
185
+ case "data":
186
+ return join(home, "Library", "Application Support", "Hasna");
187
+ case "cache":
188
+ return join(home, "Library", "Caches", "Hasna");
189
+ case "state":
190
+ return join(home, "Library", "Logs", "Hasna");
191
+ }
192
+ }
193
+ switch (kind) {
194
+ case "config":
195
+ return join(home, ".config", "hasna");
196
+ case "data":
197
+ return join(home, ".local", "share", "hasna");
198
+ case "state":
199
+ return join(home, ".local", "state", "hasna");
200
+ case "cache":
201
+ return join(home, ".cache", "hasna");
202
+ }
203
+ }
204
+ function resolvePath(kind, options) {
205
+ assertApp(options.app);
206
+ const appSegment = options.internal === true ? join("internal", options.app) : options.app;
207
+ return join(baseDir(kind, options), appSegment);
208
+ }
209
+ function dataDir(options) {
210
+ return resolvePath("data", options);
211
+ }
212
+ var KIND_ENV, APP_SLUG_RE;
213
+ var init_dist = __esm(() => {
214
+ KIND_ENV = {
215
+ config: "HASNA_CONFIG_HOME",
216
+ data: "HASNA_DATA_HOME",
217
+ state: "HASNA_STATE_HOME",
218
+ cache: "HASNA_CACHE_HOME"
219
+ };
220
+ APP_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
221
+ });
222
+
223
+ // src/lib/paths.ts
224
+ import { existsSync } from "fs";
225
+ import { homedir as homedir2 } from "os";
226
+ import { join as join2, resolve } from "path";
227
+ function effectiveHome() {
228
+ return process.env["HOME"] || process.env["USERPROFILE"] || homedir2() || "/tmp";
229
+ }
230
+ function legacyDataRoot() {
231
+ return join2(effectiveHome(), ".hasna", "mementos");
232
+ }
233
+ function resolverDataRoot() {
234
+ return dataDir({
235
+ app: "mementos",
236
+ home: process.env["HOME"] || process.env["USERPROFILE"] || undefined
237
+ });
238
+ }
239
+ function adoptResolverDataRoot(resolved, env = process.env) {
240
+ const dataOverride = env.HASNA_DATA_HOME;
241
+ if (typeof dataOverride === "string" && dataOverride.trim().length > 0)
242
+ return true;
243
+ return existsSync(join2(resolved, "mementos.db"));
244
+ }
245
+ function exactDataRoot() {
246
+ for (const key of ["HASNA_MEMENTOS_HOME", "MEMENTOS_HOME"]) {
247
+ const dir = process.env[key]?.trim();
248
+ if (dir)
249
+ return resolve(dir);
250
+ }
251
+ return;
252
+ }
253
+ function getDataRoot() {
254
+ const exact = exactDataRoot();
255
+ if (exact)
256
+ return exact;
257
+ const resolved = resolverDataRoot();
258
+ return adoptResolverDataRoot(resolved) ? resolve(resolved) : resolve(legacyDataRoot());
259
+ }
260
+ var init_paths = __esm(() => {
261
+ init_dist();
262
+ });
263
+
264
+ // src/storage.ts
265
+ import { Database } from "bun:sqlite";
266
+ import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "fs";
267
+ import { join as join3 } from "path";
160
268
  import { fileURLToPath } from "url";
161
269
  import { Worker } from "worker_threads";
162
270
  import pg from "pg";
@@ -415,7 +523,7 @@ function readEnv(name) {
415
523
  return value ? value : null;
416
524
  }
417
525
  function readConfigFile() {
418
- if (!existsSync(STORAGE_CONFIG_PATH)) {
526
+ if (!existsSync2(STORAGE_CONFIG_PATH)) {
419
527
  return {};
420
528
  }
421
529
  try {
@@ -677,11 +785,7 @@ function saveStorageConfig(config) {
677
785
  function getConfiguredConnectionString() {
678
786
  return getStorageDatabaseUrl() ?? undefined;
679
787
  }
680
- function getStorageConnectionString(dbName = "mementos") {
681
- assertNoLegacyStorageMode2();
682
- if (!isServerContext()) {
683
- 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).");
684
- }
788
+ function resolveConfiguredConnectionString(dbName) {
685
789
  const envConnectionString = getConfiguredConnectionString();
686
790
  if (envConnectionString) {
687
791
  const validation = validatePostgresConnectionString(envConnectionString);
@@ -700,7 +804,7 @@ function getStorageConnectionString(dbName = "mementos") {
700
804
  missing.push("storage.rds.username");
701
805
  }
702
806
  if (missing.length > 0) {
703
- throw new Error(`Remote storage database is not configured. Missing ${missing.join(", ")}. Set HASNA_MEMENTOS_DATABASE_URL or configure ~/.hasna/mementos/storage/config.json.`);
807
+ throw new Error(`Remote storage database is not configured. Missing ${missing.join(", ")}. Set HASNA_MEMENTOS_DATABASE_URL or configure ${STORAGE_CONFIG_PATH}.`);
704
808
  }
705
809
  const password = process.env[password_env];
706
810
  if (!password) {
@@ -709,6 +813,17 @@ function getStorageConnectionString(dbName = "mementos") {
709
813
  const sslParam = ssl ? "?sslmode=require" : "";
710
814
  return `postgres://${username}:${encodeURIComponent(password)}@${host}:${port}/${dbName}${sslParam}`;
711
815
  }
816
+ function getStorageConnectionString(dbName = "mementos") {
817
+ assertNoLegacyStorageMode2();
818
+ if (!isServerContext()) {
819
+ 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).");
820
+ }
821
+ return resolveConfiguredConnectionString(dbName);
822
+ }
823
+ function getStorageConnectionStringForOperator(dbName = "mementos") {
824
+ assertNoLegacyStorageMode2();
825
+ return resolveConfiguredConnectionString(dbName);
826
+ }
712
827
  function isSyncExcludedTable(table) {
713
828
  return SYNC_EXCLUDED_TABLE_PATTERNS.some((pattern) => pattern.test(table));
714
829
  }
@@ -878,6 +993,7 @@ CREATE TABLE IF NOT EXISTS _sync_meta (
878
993
  var init_storage = __esm(() => {
879
994
  init_backend();
880
995
  init_retired_storage_mode();
996
+ init_paths();
881
997
  PgSyncPool = class PgSyncPool {
882
998
  worker;
883
999
  status;
@@ -895,12 +1011,12 @@ var init_storage = __esm(() => {
895
1011
  const ext = import.meta.url.endsWith(".ts") ? ".ts" : ".js";
896
1012
  const here = fileURLToPath(new URL(".", import.meta.url));
897
1013
  const candidates = [
898
- join(here, `pg-sync-worker${ext}`),
899
- join(here, "..", `pg-sync-worker${ext}`),
900
- join(here, "..", "..", `pg-sync-worker${ext}`)
1014
+ join3(here, `pg-sync-worker${ext}`),
1015
+ join3(here, "..", `pg-sync-worker${ext}`),
1016
+ join3(here, "..", "..", `pg-sync-worker${ext}`)
901
1017
  ];
902
1018
  for (const candidate of candidates) {
903
- if (existsSync(candidate))
1019
+ if (existsSync2(candidate))
904
1020
  return candidate;
905
1021
  }
906
1022
  return candidates[0];
@@ -988,7 +1104,7 @@ var init_storage = __esm(() => {
988
1104
  MEMENTOS_STORAGE_FALLBACK_ENV = {
989
1105
  databaseUrl: "MEMENTOS_DATABASE_URL"
990
1106
  };
991
- LOCAL_DATA_DIR = join(homedir(), ".hasna", "mementos");
1107
+ LOCAL_DATA_DIR = getDataRoot();
992
1108
  DEFAULT_STORAGE_CONFIG = {
993
1109
  rds: {
994
1110
  host: "",
@@ -1003,8 +1119,8 @@ var init_storage = __esm(() => {
1003
1119
  schedule_minutes: 0
1004
1120
  }
1005
1121
  };
1006
- STORAGE_CONFIG_DIR = join(LOCAL_DATA_DIR, "storage");
1007
- STORAGE_CONFIG_PATH = join(STORAGE_CONFIG_DIR, "config.json");
1122
+ STORAGE_CONFIG_DIR = join3(LOCAL_DATA_DIR, "storage");
1123
+ STORAGE_CONFIG_PATH = join3(STORAGE_CONFIG_DIR, "config.json");
1008
1124
  DATABASE_ENV_NAMES = [
1009
1125
  { name: MEMENTOS_STORAGE_ENV.databaseUrl, deprecated: false },
1010
1126
  { name: MEMENTOS_STORAGE_FALLBACK_ENV.databaseUrl, deprecated: false }
@@ -1030,7 +1146,7 @@ var init_storage = __esm(() => {
1030
1146
 
1031
1147
  // src/db/api-mode.ts
1032
1148
  import { tmpdir } from "os";
1033
- import { join as join2 } from "path";
1149
+ import { join as join4 } from "path";
1034
1150
  import { writeFileSync as writeFileSync2, unlinkSync } from "fs";
1035
1151
  import { randomUUID } from "crypto";
1036
1152
  function firstEnv2(keys) {
@@ -1140,7 +1256,7 @@ x-api-key: ${cfg.apiKey}
1140
1256
  ];
1141
1257
  let bodyFile;
1142
1258
  if (hasBody) {
1143
- bodyFile = join2(tmpdir(), `mem-req-${process.pid}-${randomUUID()}.json`);
1259
+ bodyFile = join4(tmpdir(), `mem-req-${process.pid}-${randomUUID()}.json`);
1144
1260
  writeFileSync2(bodyFile, JSON.stringify(body), { mode: 384 });
1145
1261
  args.push("--data-binary", `@${bodyFile}`);
1146
1262
  }
@@ -2660,18 +2776,18 @@ __export(exports_database, {
2660
2776
  escapeLikePrefix: () => escapeLikePrefix,
2661
2777
  closeDatabase: () => closeDatabase
2662
2778
  });
2663
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, cpSync } from "fs";
2664
- import { dirname, join as join3, resolve } from "path";
2779
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, cpSync } from "fs";
2780
+ import { dirname, join as join5, resolve as resolve2 } from "path";
2665
2781
  function isInMemoryDb(path) {
2666
2782
  return path === ":memory:" || path.startsWith("file::memory:");
2667
2783
  }
2668
2784
  function findNearestMementosDb(startDir) {
2669
- let dir = resolve(startDir);
2785
+ let dir = resolve2(startDir);
2670
2786
  const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
2671
- const legacyHomeDb = resolve(home, ".mementos", "mementos.db");
2787
+ const legacyHomeDb = resolve2(home, ".mementos", "mementos.db");
2672
2788
  while (true) {
2673
- const candidate = join3(dir, ".mementos", "mementos.db");
2674
- if (existsSync2(candidate) && resolve(candidate) !== legacyHomeDb)
2789
+ const candidate = join5(dir, ".mementos", "mementos.db");
2790
+ if (existsSync3(candidate) && resolve2(candidate) !== legacyHomeDb)
2675
2791
  return candidate;
2676
2792
  const parent = dirname(dir);
2677
2793
  if (parent === dir)
@@ -2681,9 +2797,9 @@ function findNearestMementosDb(startDir) {
2681
2797
  return null;
2682
2798
  }
2683
2799
  function findGitRoot(startDir) {
2684
- let dir = resolve(startDir);
2800
+ let dir = resolve2(startDir);
2685
2801
  while (true) {
2686
- if (existsSync2(join3(dir, ".git")))
2802
+ if (existsSync3(join5(dir, ".git")))
2687
2803
  return dir;
2688
2804
  const parent = dirname(dir);
2689
2805
  if (parent === dir)
@@ -2694,10 +2810,10 @@ function findGitRoot(startDir) {
2694
2810
  }
2695
2811
  function migrateGlobalDir() {
2696
2812
  const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
2697
- const newDir = join3(home, ".hasna", "mementos");
2698
- const oldDir = join3(home, ".mementos");
2699
- if (!existsSync2(newDir) && existsSync2(oldDir)) {
2700
- mkdirSync2(join3(home, ".hasna"), { recursive: true });
2813
+ const newDir = getDataRoot();
2814
+ const oldDir = join5(home, ".mementos");
2815
+ if (!existsSync3(newDir) && existsSync3(oldDir)) {
2816
+ mkdirSync2(dirname(newDir), { recursive: true });
2701
2817
  cpSync(oldDir, newDir, { recursive: true });
2702
2818
  }
2703
2819
  }
@@ -2714,18 +2830,17 @@ function getDbPath() {
2714
2830
  if (process.env["MEMENTOS_DB_SCOPE"] === "project") {
2715
2831
  const gitRoot = findGitRoot(cwd);
2716
2832
  if (gitRoot) {
2717
- return join3(gitRoot, ".mementos", "mementos.db");
2833
+ return join5(gitRoot, ".mementos", "mementos.db");
2718
2834
  }
2719
2835
  }
2720
2836
  migrateGlobalDir();
2721
- const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
2722
- return join3(home, ".hasna", "mementos", "mementos.db");
2837
+ return join5(getDataRoot(), "mementos.db");
2723
2838
  }
2724
2839
  function ensureDir(filePath) {
2725
2840
  if (isInMemoryDb(filePath))
2726
2841
  return;
2727
- const dir = dirname(resolve(filePath));
2728
- if (!existsSync2(dir)) {
2842
+ const dir = dirname(resolve2(filePath));
2843
+ if (!existsSync3(dir)) {
2729
2844
  mkdirSync2(dir, { recursive: true });
2730
2845
  }
2731
2846
  }
@@ -2863,6 +2978,7 @@ var init_database = __esm(() => {
2863
2978
  init_storage();
2864
2979
  init_api_mode();
2865
2980
  init_migrations();
2981
+ init_paths();
2866
2982
  ALLOWED_TABLES = new Set([
2867
2983
  "memories",
2868
2984
  "agents",
@@ -6846,7 +6962,7 @@ var init_zod = __esm(() => {
6846
6962
  init_external();
6847
6963
  });
6848
6964
 
6849
- // ../../node_modules/.bun/@ai-sdk+provider@3.0.14/node_modules/@ai-sdk/provider/dist/index.mjs
6965
+ // ../../node_modules/.bun/@ai-sdk+provider@3.0.15/node_modules/@ai-sdk/provider/dist/index.mjs
6850
6966
  function getErrorMessage(error) {
6851
6967
  if (error == null) {
6852
6968
  return "unknown error";
@@ -6878,7 +6994,7 @@ function isJSONObject(value) {
6878
6994
  return value != null && typeof value === "object" && Object.entries(value).every(([key, val]) => typeof key === "string" && (val === undefined || isJSONValue(val)));
6879
6995
  }
6880
6996
  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;
6881
- var init_dist = __esm(() => {
6997
+ var init_dist2 = __esm(() => {
6882
6998
  symbol = Symbol.for(marker);
6883
6999
  AISDKError = class _AISDKError extends (_b = Error, _a = symbol, _b) {
6884
7000
  constructor({
@@ -16462,7 +16578,7 @@ class JSONSchemaGenerator {
16462
16578
  if (val === undefined) {
16463
16579
  if (this.unrepresentable === "throw") {
16464
16580
  throw new Error("Literal `undefined` cannot be represented in JSON Schema");
16465
- } else {}
16581
+ }
16466
16582
  } else if (typeof val === "bigint") {
16467
16583
  if (this.unrepresentable === "throw") {
16468
16584
  throw new Error("BigInt literals cannot be represented in JSON Schema");
@@ -18511,7 +18627,7 @@ var init_v3 = __esm(() => {
18511
18627
  init_external();
18512
18628
  });
18513
18629
 
18514
- // ../../node_modules/.bun/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/index.js
18630
+ // ../../node_modules/.bun/eventsource-parser@3.1.1/node_modules/eventsource-parser/dist/index.js
18515
18631
  function noop(_arg) {}
18516
18632
  function createParser(config2) {
18517
18633
  if (typeof config2 == "function")
@@ -18598,7 +18714,7 @@ ${value2}`, dataLines++;
18598
18714
  }
18599
18715
  if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
18600
18716
  const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
18601
- id = value2.includes("\x00") ? undefined : value2;
18717
+ value2.includes("\x00") || (id = value2);
18602
18718
  return;
18603
18719
  }
18604
18720
  if (firstCharCode === 58) {
@@ -18626,7 +18742,7 @@ ${value2}`, dataLines++;
18626
18742
  ${value}`, dataLines++;
18627
18743
  break;
18628
18744
  case "id":
18629
- id = value.includes("\x00") ? undefined : value;
18745
+ value.includes("\x00") || (id = value);
18630
18746
  break;
18631
18747
  case "retry":
18632
18748
  /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(new ParseError(`Invalid \`retry\` value: "${value}"`, {
@@ -18663,7 +18779,7 @@ function isEventPrefix(chunk, i, firstCharCode) {
18663
18779
  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;
18664
18780
  }
18665
18781
  var ParseError, LF = 10, CR = 13, SPACE = 32;
18666
- var init_dist2 = __esm(() => {
18782
+ var init_dist3 = __esm(() => {
18667
18783
  ParseError = class ParseError extends Error {
18668
18784
  constructor(message, options) {
18669
18785
  super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
@@ -18671,10 +18787,10 @@ var init_dist2 = __esm(() => {
18671
18787
  };
18672
18788
  });
18673
18789
 
18674
- // ../../node_modules/.bun/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
18790
+ // ../../node_modules/.bun/eventsource-parser@3.1.1/node_modules/eventsource-parser/dist/stream.js
18675
18791
  var EventSourceParserStream;
18676
18792
  var init_stream = __esm(() => {
18677
- init_dist2();
18793
+ init_dist3();
18678
18794
  EventSourceParserStream = class EventSourceParserStream extends TransformStream {
18679
18795
  constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
18680
18796
  let parser;
@@ -18700,7 +18816,7 @@ var init_stream = __esm(() => {
18700
18816
  };
18701
18817
  });
18702
18818
 
18703
- // ../../node_modules/.bun/@ai-sdk+provider-utils@4.0.42+27912429049419a2/node_modules/@ai-sdk/provider-utils/dist/index.mjs
18819
+ // ../../node_modules/.bun/@ai-sdk+provider-utils@4.0.46+27912429049419a2/node_modules/@ai-sdk/provider-utils/dist/index.mjs
18704
18820
  function combineHeaders(...headers) {
18705
18821
  return headers.reduce((combinedHeaders, currentHeaders) => ({
18706
18822
  ...combinedHeaders,
@@ -19041,11 +19157,10 @@ async function loadNodeModule(id) {
19041
19157
  var _a22;
19042
19158
  const processWithBuiltins = globalThis.process;
19043
19159
  const builtinModule = (_a22 = processWithBuiltins == null ? undefined : processWithBuiltins.getBuiltinModule) == null ? undefined : _a22.call(processWithBuiltins, id);
19044
- return builtinModule == null ? await importNodeModule(id) : builtinModule;
19045
- }
19046
- function importNodeModule(id) {
19047
- dynamicImport != null || (dynamicImport = Function("specifier", "return import(specifier)"));
19048
- return dynamicImport(id);
19160
+ if (builtinModule == null) {
19161
+ throw new Error(`Node.js built-in module ${id} is unavailable`);
19162
+ }
19163
+ return builtinModule;
19049
19164
  }
19050
19165
  function getCurrentModulePath() {
19051
19166
  const originalPrepareStackTrace = Error.prepareStackTrace;
@@ -19144,7 +19259,7 @@ async function readResponseWithSizeLimit({
19144
19259
  } finally {
19145
19260
  try {
19146
19261
  await reader.cancel();
19147
- } finally {
19262
+ } catch (e) {} finally {
19148
19263
  reader.releaseLock();
19149
19264
  }
19150
19265
  }
@@ -20409,7 +20524,7 @@ function createProviderToolFactoryWithOutputSchema({
20409
20524
  supportsDeferredResults
20410
20525
  });
20411
20526
  }
20412
- async function resolve4(value) {
20527
+ async function resolve5(value) {
20413
20528
  if (typeof value === "function") {
20414
20529
  value = value();
20415
20530
  }
@@ -20544,7 +20659,7 @@ var DelayedPromise = class {
20544
20659
  isPending() {
20545
20660
  return this.status.type === "pending";
20546
20661
  }
20547
- }, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, safeNodeFetchPromise, initialGlobalFetch, initialGlobalFetchIsNodeDefault, dynamicImport, MAX_DOWNLOAD_REDIRECTS = 10, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
20662
+ }, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, safeNodeFetchPromise, initialGlobalFetch, initialGlobalFetchIsNodeDefault, MAX_DOWNLOAD_REDIRECTS = 10, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
20548
20663
  prefix,
20549
20664
  size = 16,
20550
20665
  alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
@@ -20568,7 +20683,7 @@ var DelayedPromise = class {
20568
20683
  });
20569
20684
  }
20570
20685
  return () => `${prefix}${separator}${generator()}`;
20571
- }, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.42", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
20686
+ }, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.46", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
20572
20687
  url: url2,
20573
20688
  headers = {},
20574
20689
  successfulResponseHandler,
@@ -21088,23 +21203,23 @@ var DelayedPromise = class {
21088
21203
  });
21089
21204
  }
21090
21205
  };
21091
- var init_dist3 = __esm(() => {
21092
- init_dist();
21093
- init_dist();
21094
- init_dist();
21095
- init_dist();
21096
- init_dist();
21097
- init_dist();
21098
- init_dist();
21099
- init_dist();
21206
+ var init_dist4 = __esm(() => {
21207
+ init_dist2();
21208
+ init_dist2();
21209
+ init_dist2();
21210
+ init_dist2();
21211
+ init_dist2();
21212
+ init_dist2();
21213
+ init_dist2();
21214
+ init_dist2();
21100
21215
  init_v4();
21101
21216
  init_v3();
21102
21217
  init_v3();
21103
21218
  init_v3();
21104
21219
  init_stream();
21105
- init_dist();
21106
- init_dist();
21107
- init_dist();
21220
+ init_dist2();
21221
+ init_dist2();
21222
+ init_dist2();
21108
21223
  ({ btoa, atob: atob2 } = globalThis);
21109
21224
  marker15 = `vercel.ai.error.${name14}`;
21110
21225
  symbol17 = Symbol.for(marker15);
@@ -21197,7 +21312,7 @@ var init_dist3 = __esm(() => {
21197
21312
  textDecoder = new TextDecoder;
21198
21313
  });
21199
21314
 
21200
- // ../../node_modules/.bun/@ai-sdk+anthropic@3.0.107+27912429049419a2/node_modules/@ai-sdk/anthropic/dist/index.mjs
21315
+ // ../../node_modules/.bun/@ai-sdk+anthropic@3.0.111+27912429049419a2/node_modules/@ai-sdk/anthropic/dist/index.mjs
21201
21316
  var exports_dist = {};
21202
21317
  __export(exports_dist, {
21203
21318
  forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep,
@@ -21655,7 +21770,7 @@ async function convertToAnthropicMessagesPrompt({
21655
21770
  cacheControlValidator,
21656
21771
  toolNameMapping
21657
21772
  }) {
21658
- var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
21773
+ var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
21659
21774
  const betas = /* @__PURE__ */ new Set;
21660
21775
  const blocks = groupIntoBlocks(prompt);
21661
21776
  const validator = cacheControlValidator || new CacheControlValidator;
@@ -22043,6 +22158,7 @@ async function convertToAnthropicMessagesPrompt({
22043
22158
  break;
22044
22159
  }
22045
22160
  case "tool-call": {
22161
+ const caller = getAnthropicCaller(part.providerOptions);
22046
22162
  if (part.providerExecuted) {
22047
22163
  const providerToolName = toolNameMapping.toProviderToolName(part.toolName);
22048
22164
  const isMcpToolUse = ((_l = (_k = part.providerOptions) == null ? undefined : _k.anthropic) == null ? undefined : _l.type) === "mcp-tool-use";
@@ -22071,6 +22187,7 @@ async function convertToAnthropicMessagesPrompt({
22071
22187
  id: part.toolCallId,
22072
22188
  name: subtoolName,
22073
22189
  input,
22190
+ ...caller && { caller },
22074
22191
  cache_control: cacheControl
22075
22192
  });
22076
22193
  } else if (providerToolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && part.input.type === "programmatic-tool-call") {
@@ -22080,6 +22197,7 @@ async function convertToAnthropicMessagesPrompt({
22080
22197
  id: part.toolCallId,
22081
22198
  name: "code_execution",
22082
22199
  input: inputWithoutType,
22200
+ ...caller && { caller },
22083
22201
  cache_control: cacheControl
22084
22202
  });
22085
22203
  } else {
@@ -22089,6 +22207,7 @@ async function convertToAnthropicMessagesPrompt({
22089
22207
  id: part.toolCallId,
22090
22208
  name: providerToolName,
22091
22209
  input: part.input,
22210
+ ...caller && { caller },
22092
22211
  cache_control: cacheControl
22093
22212
  });
22094
22213
  } else if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
@@ -22097,6 +22216,7 @@ async function convertToAnthropicMessagesPrompt({
22097
22216
  id: part.toolCallId,
22098
22217
  name: providerToolName,
22099
22218
  input: part.input,
22219
+ ...caller && { caller },
22100
22220
  cache_control: cacheControl
22101
22221
  });
22102
22222
  } else if (providerToolName === "advisor") {
@@ -22105,6 +22225,7 @@ async function convertToAnthropicMessagesPrompt({
22105
22225
  id: part.toolCallId,
22106
22226
  name: "advisor",
22107
22227
  input: {},
22228
+ ...caller && { caller },
22108
22229
  cache_control: cacheControl
22109
22230
  });
22110
22231
  } else {
@@ -22116,11 +22237,6 @@ async function convertToAnthropicMessagesPrompt({
22116
22237
  }
22117
22238
  break;
22118
22239
  }
22119
- const callerOptions = (_o = part.providerOptions) == null ? undefined : _o.anthropic;
22120
- const caller = (callerOptions == null ? undefined : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
22121
- type: callerOptions.caller.type,
22122
- tool_id: callerOptions.caller.toolId
22123
- } : callerOptions.caller.type === "direct" ? { type: "direct" } : undefined : undefined;
22124
22240
  anthropicContent.push({
22125
22241
  type: "tool_use",
22126
22242
  id: part.toolCallId,
@@ -22133,6 +22249,7 @@ async function convertToAnthropicMessagesPrompt({
22133
22249
  }
22134
22250
  case "tool-result": {
22135
22251
  const providerToolName = toolNameMapping.toProviderToolName(part.toolName);
22252
+ const caller = getAnthropicCaller(part.providerOptions);
22136
22253
  if (mcpToolUseIds.has(part.toolCallId)) {
22137
22254
  const output = part.output;
22138
22255
  if (output.type !== "json" && output.type !== "error-json") {
@@ -22166,7 +22283,7 @@ async function convertToAnthropicMessagesPrompt({
22166
22283
  tool_use_id: part.toolCallId,
22167
22284
  content: {
22168
22285
  type: "code_execution_tool_result_error",
22169
- error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
22286
+ error_code: (_o = errorInfo.errorCode) != null ? _o : "unknown"
22170
22287
  },
22171
22288
  cache_control: cacheControl
22172
22289
  });
@@ -22177,7 +22294,7 @@ async function convertToAnthropicMessagesPrompt({
22177
22294
  cache_control: cacheControl,
22178
22295
  content: {
22179
22296
  type: "bash_code_execution_tool_result_error",
22180
- error_code: (_q = errorInfo.errorCode) != null ? _q : "unknown"
22297
+ error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
22181
22298
  }
22182
22299
  });
22183
22300
  }
@@ -22210,7 +22327,7 @@ async function convertToAnthropicMessagesPrompt({
22210
22327
  stdout: codeExecutionOutput.stdout,
22211
22328
  stderr: codeExecutionOutput.stderr,
22212
22329
  return_code: codeExecutionOutput.return_code,
22213
- content: (_r = codeExecutionOutput.content) != null ? _r : []
22330
+ content: (_q = codeExecutionOutput.content) != null ? _q : []
22214
22331
  },
22215
22332
  cache_control: cacheControl
22216
22333
  });
@@ -22228,7 +22345,7 @@ async function convertToAnthropicMessagesPrompt({
22228
22345
  encrypted_stdout: codeExecutionOutput.encrypted_stdout,
22229
22346
  stderr: codeExecutionOutput.stderr,
22230
22347
  return_code: codeExecutionOutput.return_code,
22231
- content: (_s = codeExecutionOutput.content) != null ? _s : []
22348
+ content: (_r = codeExecutionOutput.content) != null ? _r : []
22232
22349
  },
22233
22350
  cache_control: cacheControl
22234
22351
  });
@@ -22247,7 +22364,7 @@ async function convertToAnthropicMessagesPrompt({
22247
22364
  stdout: codeExecutionOutput.stdout,
22248
22365
  stderr: codeExecutionOutput.stderr,
22249
22366
  return_code: codeExecutionOutput.return_code,
22250
- content: (_t = codeExecutionOutput.content) != null ? _t : []
22367
+ content: (_s = codeExecutionOutput.content) != null ? _s : []
22251
22368
  },
22252
22369
  cache_control: cacheControl
22253
22370
  });
@@ -22283,8 +22400,9 @@ async function convertToAnthropicMessagesPrompt({
22283
22400
  tool_use_id: part.toolCallId,
22284
22401
  content: {
22285
22402
  type: "web_fetch_tool_result_error",
22286
- error_code: (_u = (await extractErrorValue(output.value)).errorCode) != null ? _u : "unavailable"
22403
+ error_code: (_t = (await extractErrorValue(output.value)).errorCode) != null ? _t : "unavailable"
22287
22404
  },
22405
+ ...caller && { caller },
22288
22406
  cache_control: cacheControl
22289
22407
  });
22290
22408
  break;
@@ -22318,6 +22436,7 @@ async function convertToAnthropicMessagesPrompt({
22318
22436
  }
22319
22437
  }
22320
22438
  },
22439
+ ...caller && { caller },
22321
22440
  cache_control: cacheControl
22322
22441
  });
22323
22442
  break;
@@ -22330,8 +22449,9 @@ async function convertToAnthropicMessagesPrompt({
22330
22449
  tool_use_id: part.toolCallId,
22331
22450
  content: {
22332
22451
  type: "web_search_tool_result_error",
22333
- error_code: (_v = (await extractErrorValue(output.value)).errorCode) != null ? _v : "unavailable"
22452
+ error_code: (_u = (await extractErrorValue(output.value)).errorCode) != null ? _u : "unavailable"
22334
22453
  },
22454
+ ...caller && { caller },
22335
22455
  cache_control: cacheControl
22336
22456
  });
22337
22457
  break;
@@ -22357,6 +22477,7 @@ async function convertToAnthropicMessagesPrompt({
22357
22477
  encrypted_content: result.encryptedContent,
22358
22478
  type: result.type
22359
22479
  })),
22480
+ ...caller && { caller },
22360
22481
  cache_control: cacheControl
22361
22482
  });
22362
22483
  break;
@@ -22525,6 +22646,17 @@ function moveToolUseBlocksToEnd(content) {
22525
22646
  flushSegment();
22526
22647
  return result;
22527
22648
  }
22649
+ function getAnthropicCaller(providerOptions) {
22650
+ var _a16;
22651
+ const caller = (_a16 = providerOptions == null ? undefined : providerOptions.anthropic) == null ? undefined : _a16.caller;
22652
+ if (((caller == null ? undefined : caller.type) === "code_execution_20250825" || (caller == null ? undefined : caller.type) === "code_execution_20260120") && caller.toolId) {
22653
+ return {
22654
+ type: caller.type,
22655
+ tool_id: caller.toolId
22656
+ };
22657
+ }
22658
+ return (caller == null ? undefined : caller.type) === "direct" ? { type: "direct" } : undefined;
22659
+ }
22528
22660
  function mapAnthropicStopReason({
22529
22661
  finishReason,
22530
22662
  isJsonResponseFromTool
@@ -22701,6 +22833,16 @@ function createCitationSource(citation, citationDocuments, generateId3) {
22701
22833
  }
22702
22834
  };
22703
22835
  }
22836
+ function getAnthropicCallerInfo(caller) {
22837
+ return caller == null ? undefined : {
22838
+ type: caller.type,
22839
+ toolId: "tool_id" in caller ? caller.tool_id : undefined
22840
+ };
22841
+ }
22842
+ function getAnthropicCallerMetadata(caller) {
22843
+ const callerInfo = getAnthropicCallerInfo(caller);
22844
+ return callerInfo == null ? {} : { providerMetadata: { anthropic: { caller: callerInfo } } };
22845
+ }
22704
22846
  function getModelCapabilities(modelId) {
22705
22847
  if (modelId.includes("claude-opus-5")) {
22706
22848
  return {
@@ -22929,7 +23071,7 @@ function forwardAnthropicContainerIdFromLastStep({
22929
23071
  }
22930
23072
  return;
22931
23073
  }
22932
- var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicStopDetailsSchema, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicSystemMessageProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
23074
+ var VERSION2 = "3.0.111", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicStopDetailsSchema, anthropicToolCallCallerSchema, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicSystemMessageProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
22933
23075
  constructor() {
22934
23076
  this.breakpointCount = 0;
22935
23077
  this.warnings = [];
@@ -23437,11 +23579,11 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
23437
23579
  betas,
23438
23580
  headers
23439
23581
  }) {
23440
- return combineHeaders(await resolve4(this.config.headers), headers, betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {});
23582
+ return combineHeaders(await resolve5(this.config.headers), headers, betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {});
23441
23583
  }
23442
23584
  async getBetasFromHeaders(requestHeaders) {
23443
23585
  var _a16, _b16;
23444
- const configHeaders = await resolve4(this.config.headers);
23586
+ const configHeaders = await resolve5(this.config.headers);
23445
23587
  const configBetaHeader = (_a16 = configHeaders["anthropic-beta"]) != null ? _a16 : "";
23446
23588
  const requestBetaHeader = (_b16 = requestHeaders == null ? undefined : requestHeaders["anthropic-beta"]) != null ? _b16 : "";
23447
23589
  return new Set([
@@ -23588,23 +23730,12 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
23588
23730
  text: JSON.stringify(part.input)
23589
23731
  });
23590
23732
  } else {
23591
- const caller = part.caller;
23592
- const callerInfo = caller ? {
23593
- type: caller.type,
23594
- toolId: "tool_id" in caller ? caller.tool_id : undefined
23595
- } : undefined;
23596
23733
  content.push({
23597
23734
  type: "tool-call",
23598
23735
  toolCallId: part.id,
23599
23736
  toolName: part.name,
23600
23737
  input: JSON.stringify(part.input),
23601
- ...callerInfo && {
23602
- providerMetadata: {
23603
- anthropic: {
23604
- caller: callerInfo
23605
- }
23606
- }
23607
- }
23738
+ ...getAnthropicCallerMetadata(part.caller)
23608
23739
  });
23609
23740
  }
23610
23741
  break;
@@ -23618,7 +23749,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
23618
23749
  toolName: toolNameMapping.toCustomToolName("code_execution"),
23619
23750
  input: JSON.stringify({ type: part.name, ...part.input }),
23620
23751
  providerExecuted: true,
23621
- ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {}
23752
+ ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
23753
+ ...getAnthropicCallerMetadata(part.caller)
23622
23754
  });
23623
23755
  } else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
23624
23756
  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;
@@ -23628,7 +23760,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
23628
23760
  toolName: toolNameMapping.toCustomToolName(part.name),
23629
23761
  input: JSON.stringify(inputToSerialize),
23630
23762
  providerExecuted: true,
23631
- ...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {}
23763
+ ...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {},
23764
+ ...getAnthropicCallerMetadata(part.caller)
23632
23765
  });
23633
23766
  } else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
23634
23767
  serverToolCalls[part.id] = part.name;
@@ -23637,7 +23770,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
23637
23770
  toolCallId: part.id,
23638
23771
  toolName: toolNameMapping.toCustomToolName(part.name),
23639
23772
  input: JSON.stringify(part.input),
23640
- providerExecuted: true
23773
+ providerExecuted: true,
23774
+ ...getAnthropicCallerMetadata(part.caller)
23641
23775
  });
23642
23776
  } else if (part.name === "advisor") {
23643
23777
  content.push({
@@ -23645,7 +23779,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
23645
23779
  toolCallId: part.id,
23646
23780
  toolName: toolNameMapping.toCustomToolName("advisor"),
23647
23781
  input: JSON.stringify(part.input),
23648
- providerExecuted: true
23782
+ providerExecuted: true,
23783
+ ...getAnthropicCallerMetadata(part.caller)
23649
23784
  });
23650
23785
  }
23651
23786
  break;
@@ -23704,7 +23839,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
23704
23839
  data: part.content.content.source.data
23705
23840
  }
23706
23841
  }
23707
- }
23842
+ },
23843
+ ...getAnthropicCallerMetadata(part.caller)
23708
23844
  });
23709
23845
  } else if (part.content.type === "web_fetch_tool_result_error") {
23710
23846
  content.push({
@@ -23715,7 +23851,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
23715
23851
  result: {
23716
23852
  type: "web_fetch_tool_result_error",
23717
23853
  errorCode: part.content.error_code
23718
- }
23854
+ },
23855
+ ...getAnthropicCallerMetadata(part.caller)
23719
23856
  });
23720
23857
  }
23721
23858
  break;
@@ -23735,7 +23872,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
23735
23872
  encryptedContent: result.encrypted_content,
23736
23873
  type: result.type
23737
23874
  };
23738
- })
23875
+ }),
23876
+ ...getAnthropicCallerMetadata(part.caller)
23739
23877
  });
23740
23878
  for (const result of part.content) {
23741
23879
  content.push({
@@ -23760,7 +23898,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
23760
23898
  result: {
23761
23899
  type: "web_search_tool_result_error",
23762
23900
  errorCode: part.content.error_code
23763
- }
23901
+ },
23902
+ ...getAnthropicCallerMetadata(part.caller)
23764
23903
  });
23765
23904
  }
23766
23905
  break;
@@ -24101,11 +24240,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
24101
24240
  id: String(value.index)
24102
24241
  });
24103
24242
  } else {
24104
- const caller = part.caller;
24105
- const callerInfo = caller ? {
24106
- type: caller.type,
24107
- toolId: "tool_id" in caller ? caller.tool_id : undefined
24108
- } : undefined;
24243
+ const callerInfo = getAnthropicCallerInfo(part.caller);
24109
24244
  const hasNonEmptyInput = part.input && Object.keys(part.input).length > 0;
24110
24245
  const initialInput = hasNonEmptyInput ? JSON.stringify(part.input) : "";
24111
24246
  contentBlocks[value.index] = {
@@ -24125,6 +24260,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
24125
24260
  return;
24126
24261
  }
24127
24262
  case "server_tool_use": {
24263
+ const callerInfo = getAnthropicCallerInfo(part.caller);
24128
24264
  if ([
24129
24265
  "web_fetch",
24130
24266
  "web_search",
@@ -24145,7 +24281,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
24145
24281
  ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
24146
24282
  firstDelta: finalInput.length === 0,
24147
24283
  providerToolName,
24148
- providerToolInputType
24284
+ providerToolInputType,
24285
+ ...callerInfo && { caller: callerInfo }
24149
24286
  };
24150
24287
  controller.enqueue({
24151
24288
  type: "tool-input-start",
@@ -24164,7 +24301,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
24164
24301
  input: "",
24165
24302
  providerExecuted: true,
24166
24303
  firstDelta: true,
24167
- providerToolName: part.name
24304
+ providerToolName: part.name,
24305
+ ...callerInfo && { caller: callerInfo }
24168
24306
  };
24169
24307
  controller.enqueue({
24170
24308
  type: "tool-input-start",
@@ -24181,7 +24319,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
24181
24319
  input: "{}",
24182
24320
  providerExecuted: true,
24183
24321
  firstDelta: true,
24184
- providerToolName: part.name
24322
+ providerToolName: part.name,
24323
+ ...callerInfo && { caller: callerInfo }
24185
24324
  };
24186
24325
  controller.enqueue({
24187
24326
  type: "tool-input-start",
@@ -24216,7 +24355,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
24216
24355
  data: part.content.content.source.data
24217
24356
  }
24218
24357
  }
24219
- }
24358
+ },
24359
+ ...getAnthropicCallerMetadata(part.caller)
24220
24360
  });
24221
24361
  } else if (part.content.type === "web_fetch_tool_result_error") {
24222
24362
  controller.enqueue({
@@ -24227,7 +24367,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
24227
24367
  result: {
24228
24368
  type: "web_fetch_tool_result_error",
24229
24369
  errorCode: part.content.error_code
24230
- }
24370
+ },
24371
+ ...getAnthropicCallerMetadata(part.caller)
24231
24372
  });
24232
24373
  }
24233
24374
  return;
@@ -24247,7 +24388,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
24247
24388
  encryptedContent: result.encrypted_content,
24248
24389
  type: result.type
24249
24390
  };
24250
- })
24391
+ }),
24392
+ ...getAnthropicCallerMetadata(part.caller)
24251
24393
  });
24252
24394
  for (const result of part.content) {
24253
24395
  controller.enqueue({
@@ -24272,7 +24414,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
24272
24414
  result: {
24273
24415
  type: "web_search_tool_result_error",
24274
24416
  errorCode: part.content.error_code
24275
- }
24417
+ },
24418
+ ...getAnthropicCallerMetadata(part.caller)
24276
24419
  });
24277
24420
  }
24278
24421
  return;
@@ -24650,11 +24793,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
24650
24793
  for (let contentIndex = 0;contentIndex < value.message.content.length; contentIndex++) {
24651
24794
  const part = value.message.content[contentIndex];
24652
24795
  if (part.type === "tool_use") {
24653
- const caller = part.caller;
24654
- const callerInfo = caller ? {
24655
- type: caller.type,
24656
- toolId: "tool_id" in caller ? caller.tool_id : undefined
24657
- } : undefined;
24796
+ const callerInfo = getAnthropicCallerInfo(part.caller);
24658
24797
  controller.enqueue({
24659
24798
  type: "tool-input-start",
24660
24799
  id: part.id,
@@ -24814,59 +24953,59 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
24814
24953
  }, 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 = {}) => {
24815
24954
  return factory11(args);
24816
24955
  }, anthropicTools, ANTHROPIC_API_URL = "https://api.anthropic.com", ANTHROPIC_API_VERSIONED_URL, anthropic;
24817
- var init_dist4 = __esm(() => {
24818
- init_dist();
24819
- init_dist3();
24820
- init_dist();
24821
- init_dist3();
24822
- init_dist3();
24956
+ var init_dist5 = __esm(() => {
24957
+ init_dist2();
24958
+ init_dist4();
24959
+ init_dist2();
24960
+ init_dist4();
24961
+ init_dist4();
24823
24962
  init_v4();
24824
- init_dist3();
24963
+ init_dist4();
24825
24964
  init_v4();
24826
24965
  init_v4();
24827
- init_dist();
24828
- init_dist3();
24966
+ init_dist2();
24967
+ init_dist4();
24829
24968
  init_v4();
24830
- init_dist3();
24969
+ init_dist4();
24831
24970
  init_v4();
24832
- init_dist3();
24971
+ init_dist4();
24833
24972
  init_v4();
24834
- init_dist3();
24973
+ init_dist4();
24835
24974
  init_v4();
24836
- init_dist3();
24975
+ init_dist4();
24837
24976
  init_v4();
24838
- init_dist3();
24977
+ init_dist4();
24839
24978
  init_v4();
24840
- init_dist3();
24841
- init_dist();
24842
- init_dist3();
24843
- init_dist3();
24979
+ init_dist4();
24980
+ init_dist2();
24981
+ init_dist4();
24982
+ init_dist4();
24844
24983
  init_v4();
24845
- init_dist3();
24984
+ init_dist4();
24846
24985
  init_v4();
24847
- init_dist3();
24986
+ init_dist4();
24848
24987
  init_v4();
24849
- init_dist3();
24988
+ init_dist4();
24850
24989
  init_v4();
24851
- init_dist3();
24990
+ init_dist4();
24852
24991
  init_v4();
24853
- init_dist3();
24992
+ init_dist4();
24854
24993
  init_v4();
24855
- init_dist3();
24994
+ init_dist4();
24856
24995
  init_v4();
24857
- init_dist3();
24996
+ init_dist4();
24858
24997
  init_v4();
24859
- init_dist3();
24998
+ init_dist4();
24860
24999
  init_v4();
24861
- init_dist3();
25000
+ init_dist4();
24862
25001
  init_v4();
24863
- init_dist3();
25002
+ init_dist4();
24864
25003
  init_v4();
24865
- init_dist3();
25004
+ init_dist4();
24866
25005
  init_v4();
24867
- init_dist3();
25006
+ init_dist4();
24868
25007
  init_v4();
24869
- init_dist3();
25008
+ init_dist4();
24870
25009
  init_v4();
24871
25010
  anthropicErrorDataSchema = lazySchema(() => zodSchema(exports_external2.object({
24872
25011
  type: exports_external2.literal("error"),
@@ -24885,6 +25024,19 @@ var init_dist4 = __esm(() => {
24885
25024
  explanation: exports_external2.string().nullish(),
24886
25025
  recommended_model: exports_external2.string().nullish()
24887
25026
  });
25027
+ anthropicToolCallCallerSchema = exports_external2.union([
25028
+ exports_external2.object({
25029
+ type: exports_external2.literal("code_execution_20250825"),
25030
+ tool_id: exports_external2.string()
25031
+ }),
25032
+ exports_external2.object({
25033
+ type: exports_external2.literal("code_execution_20260120"),
25034
+ tool_id: exports_external2.string()
25035
+ }),
25036
+ exports_external2.object({
25037
+ type: exports_external2.literal("direct")
25038
+ })
25039
+ ]);
24888
25040
  anthropicMessagesResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
24889
25041
  type: exports_external2.literal("message"),
24890
25042
  id: exports_external2.string().nullish(),
@@ -24937,34 +25089,14 @@ var init_dist4 = __esm(() => {
24937
25089
  id: exports_external2.string(),
24938
25090
  name: exports_external2.string(),
24939
25091
  input: exports_external2.unknown(),
24940
- caller: exports_external2.union([
24941
- exports_external2.object({
24942
- type: exports_external2.literal("code_execution_20250825"),
24943
- tool_id: exports_external2.string()
24944
- }),
24945
- exports_external2.object({
24946
- type: exports_external2.literal("code_execution_20260120"),
24947
- tool_id: exports_external2.string()
24948
- }),
24949
- exports_external2.object({
24950
- type: exports_external2.literal("direct")
24951
- })
24952
- ]).optional()
25092
+ caller: anthropicToolCallCallerSchema.optional()
24953
25093
  }),
24954
25094
  exports_external2.object({
24955
25095
  type: exports_external2.literal("server_tool_use"),
24956
25096
  id: exports_external2.string(),
24957
25097
  name: exports_external2.string(),
24958
25098
  input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).nullish(),
24959
- caller: exports_external2.union([
24960
- exports_external2.object({
24961
- type: exports_external2.literal("code_execution_20260120"),
24962
- tool_id: exports_external2.string()
24963
- }),
24964
- exports_external2.object({
24965
- type: exports_external2.literal("direct")
24966
- })
24967
- ]).optional()
25099
+ caller: anthropicToolCallCallerSchema.optional()
24968
25100
  }),
24969
25101
  exports_external2.object({
24970
25102
  type: exports_external2.literal("mcp_tool_use"),
@@ -24985,6 +25117,7 @@ var init_dist4 = __esm(() => {
24985
25117
  exports_external2.object({
24986
25118
  type: exports_external2.literal("web_fetch_tool_result"),
24987
25119
  tool_use_id: exports_external2.string(),
25120
+ caller: anthropicToolCallCallerSchema.optional(),
24988
25121
  content: exports_external2.union([
24989
25122
  exports_external2.object({
24990
25123
  type: exports_external2.literal("web_fetch_result"),
@@ -25017,6 +25150,7 @@ var init_dist4 = __esm(() => {
25017
25150
  exports_external2.object({
25018
25151
  type: exports_external2.literal("web_search_tool_result"),
25019
25152
  tool_use_id: exports_external2.string(),
25153
+ caller: anthropicToolCallCallerSchema.optional(),
25020
25154
  content: exports_external2.union([
25021
25155
  exports_external2.array(exports_external2.object({
25022
25156
  type: exports_external2.literal("web_search_result"),
@@ -25220,19 +25354,7 @@ var init_dist4 = __esm(() => {
25220
25354
  id: exports_external2.string(),
25221
25355
  name: exports_external2.string(),
25222
25356
  input: exports_external2.unknown(),
25223
- caller: exports_external2.union([
25224
- exports_external2.object({
25225
- type: exports_external2.literal("code_execution_20250825"),
25226
- tool_id: exports_external2.string()
25227
- }),
25228
- exports_external2.object({
25229
- type: exports_external2.literal("code_execution_20260120"),
25230
- tool_id: exports_external2.string()
25231
- }),
25232
- exports_external2.object({
25233
- type: exports_external2.literal("direct")
25234
- })
25235
- ]).optional()
25357
+ caller: anthropicToolCallCallerSchema.optional()
25236
25358
  })
25237
25359
  ])).nullish(),
25238
25360
  stop_reason: exports_external2.string().nullish(),
@@ -25259,19 +25381,7 @@ var init_dist4 = __esm(() => {
25259
25381
  id: exports_external2.string(),
25260
25382
  name: exports_external2.string(),
25261
25383
  input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).optional(),
25262
- caller: exports_external2.union([
25263
- exports_external2.object({
25264
- type: exports_external2.literal("code_execution_20250825"),
25265
- tool_id: exports_external2.string()
25266
- }),
25267
- exports_external2.object({
25268
- type: exports_external2.literal("code_execution_20260120"),
25269
- tool_id: exports_external2.string()
25270
- }),
25271
- exports_external2.object({
25272
- type: exports_external2.literal("direct")
25273
- })
25274
- ]).optional()
25384
+ caller: anthropicToolCallCallerSchema.optional()
25275
25385
  }),
25276
25386
  exports_external2.object({
25277
25387
  type: exports_external2.literal("redacted_thinking"),
@@ -25286,15 +25396,7 @@ var init_dist4 = __esm(() => {
25286
25396
  id: exports_external2.string(),
25287
25397
  name: exports_external2.string(),
25288
25398
  input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).nullish(),
25289
- caller: exports_external2.union([
25290
- exports_external2.object({
25291
- type: exports_external2.literal("code_execution_20260120"),
25292
- tool_id: exports_external2.string()
25293
- }),
25294
- exports_external2.object({
25295
- type: exports_external2.literal("direct")
25296
- })
25297
- ]).optional()
25399
+ caller: anthropicToolCallCallerSchema.optional()
25298
25400
  }),
25299
25401
  exports_external2.object({
25300
25402
  type: exports_external2.literal("mcp_tool_use"),
@@ -25315,6 +25417,7 @@ var init_dist4 = __esm(() => {
25315
25417
  exports_external2.object({
25316
25418
  type: exports_external2.literal("web_fetch_tool_result"),
25317
25419
  tool_use_id: exports_external2.string(),
25420
+ caller: anthropicToolCallCallerSchema.optional(),
25318
25421
  content: exports_external2.union([
25319
25422
  exports_external2.object({
25320
25423
  type: exports_external2.literal("web_fetch_result"),
@@ -25347,6 +25450,7 @@ var init_dist4 = __esm(() => {
25347
25450
  exports_external2.object({
25348
25451
  type: exports_external2.literal("web_search_tool_result"),
25349
25452
  tool_use_id: exports_external2.string(),
25453
+ caller: anthropicToolCallCallerSchema.optional(),
25350
25454
  content: exports_external2.union([
25351
25455
  exports_external2.array(exports_external2.object({
25352
25456
  type: exports_external2.literal("web_search_result"),
@@ -26386,7 +26490,7 @@ var init_dist4 = __esm(() => {
26386
26490
  anthropic = createAnthropic();
26387
26491
  });
26388
26492
 
26389
- // ../../node_modules/.bun/@ai-sdk+openai@3.0.91+27912429049419a2/node_modules/@ai-sdk/openai/dist/index.mjs
26493
+ // ../../node_modules/.bun/@ai-sdk+openai@3.0.97+27912429049419a2/node_modules/@ai-sdk/openai/dist/index.mjs
26390
26494
  var exports_dist2 = {};
26391
26495
  __export(exports_dist2, {
26392
26496
  openai: () => openai,
@@ -27323,12 +27427,14 @@ async function convertToOpenAIResponsesInput({
27323
27427
  if (store && id != null) {
27324
27428
  input.push({ type: "item_reference", id });
27325
27429
  }
27326
- break;
27430
+ if (store || !hasShellTool || resolvedToolName !== "shell") {
27431
+ break;
27432
+ }
27327
27433
  }
27328
- if (hasPreviousResponseId && store && id != null) {
27434
+ const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
27435
+ if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
27329
27436
  break;
27330
27437
  }
27331
- const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
27332
27438
  if (store && id != null && isProviderDefinedToolCall) {
27333
27439
  input.push({ type: "item_reference", id });
27334
27440
  break;
@@ -27549,7 +27655,7 @@ async function convertToOpenAIResponsesInput({
27549
27655
  continue;
27550
27656
  }
27551
27657
  processedApprovalIds.add(approvalResponse.approvalId);
27552
- if (store) {
27658
+ if (store && !hasConversation && !hasPreviousResponseId) {
27553
27659
  input.push({
27554
27660
  type: "item_reference",
27555
27661
  id: approvalResponse.approvalId
@@ -28513,7 +28619,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
28513
28619
  });
28514
28620
  baseArgs.service_tier = undefined;
28515
28621
  }
28516
- if (openaiOptions.serviceTier === "priority" && !modelCapabilities.supportsPriorityProcessing) {
28622
+ if ((openaiOptions.serviceTier === "priority" || openaiOptions.serviceTier === "fast") && !modelCapabilities.supportsPriorityProcessing) {
28517
28623
  warnings.push({
28518
28624
  type: "unsupported",
28519
28625
  feature: "serviceTier",
@@ -29523,7 +29629,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
29523
29629
  });
29524
29630
  delete baseArgs.service_tier;
29525
29631
  }
29526
- if ((openaiOptions == null ? undefined : openaiOptions.serviceTier) === "priority" && !modelCapabilities.supportsPriorityProcessing) {
29632
+ if (((openaiOptions == null ? undefined : openaiOptions.serviceTier) === "priority" || (openaiOptions == null ? undefined : openaiOptions.serviceTier) === "fast") && !modelCapabilities.supportsPriorityProcessing) {
29527
29633
  warnings.push({
29528
29634
  type: "unsupported",
29529
29635
  feature: "serviceTier",
@@ -31103,78 +31209,78 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
31103
31209
  }
31104
31210
  };
31105
31211
  }
31106
- }, VERSION3 = "3.0.91", openai;
31107
- var init_dist5 = __esm(() => {
31108
- init_dist3();
31109
- init_dist();
31110
- init_dist3();
31212
+ }, VERSION3 = "3.0.97", openai;
31213
+ var init_dist6 = __esm(() => {
31214
+ init_dist4();
31215
+ init_dist2();
31216
+ init_dist4();
31111
31217
  init_v4();
31112
- init_dist3();
31113
- init_dist();
31114
- init_dist();
31115
- init_dist3();
31116
- init_dist3();
31218
+ init_dist4();
31219
+ init_dist2();
31220
+ init_dist2();
31221
+ init_dist4();
31222
+ init_dist4();
31117
31223
  init_v4();
31118
- init_dist3();
31224
+ init_dist4();
31119
31225
  init_v4();
31120
- init_dist();
31121
- init_dist3();
31122
- init_dist();
31226
+ init_dist2();
31227
+ init_dist4();
31228
+ init_dist2();
31123
31229
  init_v4();
31124
- init_dist3();
31125
- init_dist3();
31230
+ init_dist4();
31231
+ init_dist4();
31126
31232
  init_v4();
31127
- init_dist();
31128
- init_dist3();
31129
- init_dist3();
31233
+ init_dist2();
31234
+ init_dist4();
31235
+ init_dist4();
31130
31236
  init_v4();
31131
- init_dist3();
31237
+ init_dist4();
31132
31238
  init_v4();
31133
- init_dist3();
31134
- init_dist3();
31239
+ init_dist4();
31240
+ init_dist4();
31135
31241
  init_v4();
31136
- init_dist3();
31242
+ init_dist4();
31137
31243
  init_v4();
31138
- init_dist3();
31244
+ init_dist4();
31139
31245
  init_v4();
31140
- init_dist3();
31246
+ init_dist4();
31141
31247
  init_v4();
31142
- init_dist3();
31248
+ init_dist4();
31143
31249
  init_v4();
31144
- init_dist3();
31250
+ init_dist4();
31145
31251
  init_v4();
31146
- init_dist3();
31252
+ init_dist4();
31147
31253
  init_v4();
31148
- init_dist3();
31254
+ init_dist4();
31149
31255
  init_v4();
31150
- init_dist3();
31256
+ init_dist4();
31151
31257
  init_v4();
31152
- init_dist3();
31258
+ init_dist4();
31153
31259
  init_v4();
31154
- init_dist3();
31260
+ init_dist4();
31155
31261
  init_v4();
31156
- init_dist3();
31262
+ init_dist4();
31157
31263
  init_v4();
31158
- init_dist3();
31264
+ init_dist4();
31159
31265
  init_v4();
31160
- init_dist();
31161
- init_dist3();
31162
- init_dist();
31163
- init_dist3();
31266
+ init_dist2();
31267
+ init_dist4();
31268
+ init_dist2();
31269
+ init_dist4();
31164
31270
  init_v4();
31165
- init_dist3();
31271
+ init_dist4();
31166
31272
  init_v4();
31167
- init_dist3();
31273
+ init_dist4();
31168
31274
  init_v4();
31169
- init_dist();
31170
- init_dist3();
31171
- init_dist3();
31172
- init_dist3();
31275
+ init_dist2();
31276
+ init_dist4();
31277
+ init_dist4();
31278
+ init_dist4();
31173
31279
  init_v4();
31174
- init_dist3();
31175
- init_dist3();
31280
+ init_dist4();
31281
+ init_dist4();
31176
31282
  init_v4();
31177
- init_dist3();
31283
+ init_dist4();
31178
31284
  init_v4();
31179
31285
  openaiErrorDataSchema = exports_external2.object({
31180
31286
  error: exports_external2.object({
@@ -31310,7 +31416,7 @@ var init_dist5 = __esm(() => {
31310
31416
  store: exports_external2.boolean().optional(),
31311
31417
  metadata: exports_external2.record(exports_external2.string().max(64), exports_external2.string().max(512)).optional(),
31312
31418
  prediction: exports_external2.record(exports_external2.string(), exports_external2.any()).optional(),
31313
- serviceTier: exports_external2.enum(["auto", "flex", "priority", "default"]).optional(),
31419
+ serviceTier: exports_external2.enum(["auto", "flex", "priority", "fast", "default"]).optional(),
31314
31420
  strictJsonSchema: exports_external2.boolean().optional(),
31315
31421
  textVerbosity: exports_external2.enum(["low", "medium", "high"]).optional(),
31316
31422
  promptCacheKey: exports_external2.string().optional(),
@@ -32722,7 +32828,7 @@ var init_dist5 = __esm(() => {
32722
32828
  reasoningContext: exports_external2.enum(["auto", "current_turn", "all_turns"]).optional(),
32723
32829
  reasoningSummary: exports_external2.string().nullish(),
32724
32830
  safetyIdentifier: exports_external2.string().nullish(),
32725
- serviceTier: exports_external2.enum(["auto", "flex", "priority", "default"]).nullish(),
32831
+ serviceTier: exports_external2.enum(["auto", "flex", "priority", "fast", "default"]).nullish(),
32726
32832
  store: exports_external2.boolean().nullish(),
32727
32833
  passThroughUnsupportedFiles: exports_external2.boolean().optional(),
32728
32834
  strictJsonSchema: exports_external2.boolean().nullish(),
@@ -32831,7 +32937,7 @@ var init_dist5 = __esm(() => {
32831
32937
  openai = createOpenAI();
32832
32938
  });
32833
32939
 
32834
- // ../../node_modules/.bun/@ai-sdk+openai-compatible@2.0.64+27912429049419a2/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
32940
+ // ../../node_modules/.bun/@ai-sdk+openai-compatible@2.0.69+27912429049419a2/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
32835
32941
  var exports_dist3 = {};
32836
32942
  __export(exports_dist3, {
32837
32943
  createOpenAICompatible: () => createOpenAICompatible,
@@ -32882,7 +32988,7 @@ function convertOpenAICompatibleChatUsage(usage) {
32882
32988
  },
32883
32989
  outputTokens: {
32884
32990
  total: completionTokens,
32885
- text: completionTokens - reasoningTokens,
32991
+ text: Math.max(0, completionTokens - reasoningTokens),
32886
32992
  reasoning: reasoningTokens
32887
32993
  },
32888
32994
  raw: usage
@@ -34256,27 +34362,27 @@ var openaiCompatibleErrorDataSchema, defaultOpenAICompatibleErrorStructure, open
34256
34362
  }
34257
34363
  };
34258
34364
  }
34259
- }, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.64";
34260
- var init_dist6 = __esm(() => {
34261
- init_dist();
34262
- init_dist3();
34365
+ }, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.69";
34366
+ var init_dist7 = __esm(() => {
34367
+ init_dist2();
34368
+ init_dist4();
34263
34369
  init_v4();
34264
34370
  init_v4();
34265
- init_dist();
34266
- init_dist3();
34371
+ init_dist2();
34372
+ init_dist4();
34267
34373
  init_v4();
34268
- init_dist();
34269
- init_dist3();
34374
+ init_dist2();
34375
+ init_dist4();
34270
34376
  init_v4();
34271
- init_dist();
34377
+ init_dist2();
34272
34378
  init_v4();
34273
- init_dist();
34274
- init_dist3();
34379
+ init_dist2();
34380
+ init_dist4();
34275
34381
  init_v4();
34276
34382
  init_v4();
34277
- init_dist3();
34383
+ init_dist4();
34278
34384
  init_v4();
34279
- init_dist3();
34385
+ init_dist4();
34280
34386
  openaiCompatibleErrorDataSchema = exports_external2.object({
34281
34387
  error: exports_external2.object({
34282
34388
  message: exports_external2.string(),
@@ -34299,10 +34405,10 @@ var init_dist6 = __esm(() => {
34299
34405
  prompt_tokens: exports_external2.number().nullish(),
34300
34406
  completion_tokens: exports_external2.number().nullish(),
34301
34407
  total_tokens: exports_external2.number().nullish(),
34302
- prompt_tokens_details: exports_external2.object({
34408
+ prompt_tokens_details: exports_external2.looseObject({
34303
34409
  cached_tokens: exports_external2.number().nullish()
34304
34410
  }).nullish(),
34305
- completion_tokens_details: exports_external2.object({
34411
+ completion_tokens_details: exports_external2.looseObject({
34306
34412
  reasoning_tokens: exports_external2.number().nullish(),
34307
34413
  accepted_prediction_tokens: exports_external2.number().nullish(),
34308
34414
  rejected_prediction_tokens: exports_external2.number().nullish()
@@ -34369,7 +34475,7 @@ var init_dist6 = __esm(() => {
34369
34475
  suffix: exports_external2.string().optional(),
34370
34476
  user: exports_external2.string().optional()
34371
34477
  });
34372
- usageSchema = exports_external2.object({
34478
+ usageSchema = exports_external2.looseObject({
34373
34479
  prompt_tokens: exports_external2.number(),
34374
34480
  completion_tokens: exports_external2.number(),
34375
34481
  total_tokens: exports_external2.number()
@@ -34498,19 +34604,19 @@ var require_token_io = __commonJS((exports, module) => {
34498
34604
  getUserDataDir: () => getUserDataDir
34499
34605
  });
34500
34606
  module.exports = __toCommonJS(token_io_exports);
34501
- var import_path = __toESM2(__require("path"));
34607
+ var import_path2 = __toESM2(__require("path"));
34502
34608
  var import_fs = __toESM2(__require("fs"));
34503
- var import_os2 = __toESM2(__require("os"));
34609
+ var import_os3 = __toESM2(__require("os"));
34504
34610
  var import_token_error = require_token_error();
34505
34611
  function findRootDir() {
34506
34612
  try {
34507
34613
  let dir = process.cwd();
34508
- while (dir !== import_path.default.dirname(dir)) {
34509
- const pkgPath = import_path.default.join(dir, ".vercel");
34614
+ while (dir !== import_path2.default.dirname(dir)) {
34615
+ const pkgPath = import_path2.default.join(dir, ".vercel");
34510
34616
  if (import_fs.default.existsSync(pkgPath)) {
34511
34617
  return dir;
34512
34618
  }
34513
- dir = import_path.default.dirname(dir);
34619
+ dir = import_path2.default.dirname(dir);
34514
34620
  }
34515
34621
  } catch (e) {
34516
34622
  throw new import_token_error.VercelOidcTokenError("Token refresh only supported in node server environments");
@@ -34521,11 +34627,11 @@ var require_token_io = __commonJS((exports, module) => {
34521
34627
  if (process.env.XDG_DATA_HOME) {
34522
34628
  return process.env.XDG_DATA_HOME;
34523
34629
  }
34524
- switch (import_os2.default.platform()) {
34630
+ switch (import_os3.default.platform()) {
34525
34631
  case "darwin":
34526
- return import_path.default.join(import_os2.default.homedir(), "Library/Application Support");
34632
+ return import_path2.default.join(import_os3.default.homedir(), "Library/Application Support");
34527
34633
  case "linux":
34528
- return import_path.default.join(import_os2.default.homedir(), ".local/share");
34634
+ return import_path2.default.join(import_os3.default.homedir(), ".local/share");
34529
34635
  case "win32":
34530
34636
  if (process.env.LOCALAPPDATA) {
34531
34637
  return process.env.LOCALAPPDATA;
@@ -34570,11 +34676,11 @@ var require_auth_config = __commonJS((exports, module) => {
34570
34676
  var path = __toESM2(__require("path"));
34571
34677
  var import_token_util = require_token_util();
34572
34678
  function getAuthConfigPath() {
34573
- const dataDir = (0, import_token_util.getVercelDataDir)();
34574
- if (!dataDir) {
34679
+ const dataDir2 = (0, import_token_util.getVercelDataDir)();
34680
+ if (!dataDir2) {
34575
34681
  throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);
34576
34682
  }
34577
- return path.join(dataDir, "auth.json");
34683
+ return path.join(dataDir2, "auth.json");
34578
34684
  }
34579
34685
  function readAuthConfig() {
34580
34686
  try {
@@ -34635,10 +34741,10 @@ var require_oauth = __commonJS((exports, module) => {
34635
34741
  refreshTokenRequest: () => refreshTokenRequest
34636
34742
  });
34637
34743
  module.exports = __toCommonJS(oauth_exports);
34638
- var import_os2 = __require("os");
34744
+ var import_os3 = __require("os");
34639
34745
  var VERCEL_ISSUER = "https://vercel.com";
34640
34746
  var VERCEL_CLI_CLIENT_ID = "cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp";
34641
- var userAgent = `@vercel/oidc node-${process.version} ${(0, import_os2.platform)()} (${(0, import_os2.arch)()}) ${(0, import_os2.hostname)()}`;
34747
+ var userAgent = `@vercel/oidc node-${process.version} ${(0, import_os3.platform)()} (${(0, import_os3.arch)()}) ${(0, import_os3.hostname)()}`;
34642
34748
  var _tokenEndpoint = null;
34643
34749
  async function getTokenEndpoint() {
34644
34750
  if (_tokenEndpoint) {
@@ -34781,11 +34887,11 @@ var require_token_util = __commonJS((exports, module) => {
34781
34887
  var import_auth_errors = require_auth_errors();
34782
34888
  function getVercelDataDir() {
34783
34889
  const vercelFolder = "com.vercel.cli";
34784
- const dataDir = (0, import_token_io.getUserDataDir)();
34785
- if (!dataDir) {
34890
+ const dataDir2 = (0, import_token_io.getUserDataDir)();
34891
+ if (!dataDir2) {
34786
34892
  return null;
34787
34893
  }
34788
- return path.join(dataDir, vercelFolder);
34894
+ return path.join(dataDir2, vercelFolder);
34789
34895
  }
34790
34896
  async function getVercelToken2(options) {
34791
34897
  const authConfig = (0, import_auth_config.readAuthConfig)();
@@ -35060,7 +35166,7 @@ var require_dist = __commonJS((exports, module) => {
35060
35166
  var import_token_util = require_token_util();
35061
35167
  });
35062
35168
 
35063
- // ../../node_modules/.bun/@ai-sdk+gateway@3.0.166+27912429049419a2/node_modules/@ai-sdk/gateway/dist/index.mjs
35169
+ // ../../node_modules/.bun/@ai-sdk+gateway@3.0.175+27912429049419a2/node_modules/@ai-sdk/gateway/dist/index.mjs
35064
35170
  async function createGatewayErrorFromResponse({
35065
35171
  response,
35066
35172
  statusCode,
@@ -35467,11 +35573,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35467
35573
  try {
35468
35574
  const { value } = await getFromApi({
35469
35575
  url: `${this.config.baseURL}/config`,
35470
- headers: await resolve4(this.config.headers()),
35576
+ headers: await resolve5(this.config.headers()),
35471
35577
  successfulResponseHandler: createJsonResponseHandler(gatewayAvailableModelsResponseSchema),
35472
35578
  failedResponseHandler: createJsonErrorResponseHandler({
35473
35579
  errorSchema: exports_external2.any(),
35474
- errorToMessage: (data) => data
35580
+ errorToMessage: (data) => {
35581
+ var _a112;
35582
+ return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
35583
+ }
35475
35584
  }),
35476
35585
  fetch: this.config.fetch
35477
35586
  });
@@ -35485,11 +35594,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35485
35594
  const baseUrl = new URL(this.config.baseURL);
35486
35595
  const { value } = await getFromApi({
35487
35596
  url: `${baseUrl.origin}/v1/credits`,
35488
- headers: await resolve4(this.config.headers()),
35597
+ headers: await resolve5(this.config.headers()),
35489
35598
  successfulResponseHandler: createJsonResponseHandler(gatewayCreditsResponseSchema),
35490
35599
  failedResponseHandler: createJsonErrorResponseHandler({
35491
35600
  errorSchema: exports_external2.any(),
35492
- errorToMessage: (data) => data
35601
+ errorToMessage: (data) => {
35602
+ var _a112;
35603
+ return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
35604
+ }
35493
35605
  }),
35494
35606
  fetch: this.config.fetch
35495
35607
  });
@@ -35531,11 +35643,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35531
35643
  }
35532
35644
  const { value } = await getFromApi({
35533
35645
  url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
35534
- headers: await resolve4(this.config.headers()),
35646
+ headers: await resolve5(this.config.headers()),
35535
35647
  successfulResponseHandler: createJsonResponseHandler(gatewaySpendReportResponseSchema),
35536
35648
  failedResponseHandler: createJsonErrorResponseHandler({
35537
35649
  errorSchema: exports_external2.any(),
35538
- errorToMessage: (data) => data
35650
+ errorToMessage: (data) => {
35651
+ var _a112;
35652
+ return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
35653
+ }
35539
35654
  }),
35540
35655
  fetch: this.config.fetch
35541
35656
  });
@@ -35553,11 +35668,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35553
35668
  const baseUrl = new URL(this.config.baseURL);
35554
35669
  const { value } = await getFromApi({
35555
35670
  url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
35556
- headers: await resolve4(this.config.headers()),
35671
+ headers: await resolve5(this.config.headers()),
35557
35672
  successfulResponseHandler: createJsonResponseHandler(gatewayGenerationInfoResponseSchema),
35558
35673
  failedResponseHandler: createJsonErrorResponseHandler({
35559
35674
  errorSchema: exports_external2.any(),
35560
- errorToMessage: (data) => data
35675
+ errorToMessage: (data) => {
35676
+ var _a112;
35677
+ return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
35678
+ }
35561
35679
  }),
35562
35680
  fetch: this.config.fetch
35563
35681
  });
@@ -35586,7 +35704,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35586
35704
  async doGenerate(options) {
35587
35705
  const { args, warnings } = await this.getArgs(options);
35588
35706
  const { abortSignal } = options;
35589
- const resolvedHeaders = await resolve4(this.config.headers());
35707
+ const resolvedHeaders = await resolve5(this.config.headers());
35590
35708
  try {
35591
35709
  const {
35592
35710
  responseHeaders,
@@ -35594,12 +35712,15 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35594
35712
  rawValue: rawResponse
35595
35713
  } = await postJsonToApi({
35596
35714
  url: this.getUrl(),
35597
- headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await resolve4(this.config.o11yHeaders)),
35715
+ headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await resolve5(this.config.o11yHeaders)),
35598
35716
  body: args,
35599
35717
  successfulResponseHandler: createJsonResponseHandler(exports_external2.any()),
35600
35718
  failedResponseHandler: createJsonErrorResponseHandler({
35601
35719
  errorSchema: exports_external2.any(),
35602
- errorToMessage: (data) => data
35720
+ errorToMessage: (data) => {
35721
+ var _a112;
35722
+ return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
35723
+ }
35603
35724
  }),
35604
35725
  ...abortSignal && { abortSignal },
35605
35726
  fetch: this.config.fetch
@@ -35617,16 +35738,19 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35617
35738
  async doStream(options) {
35618
35739
  const { args, warnings } = await this.getArgs(options);
35619
35740
  const { abortSignal } = options;
35620
- const resolvedHeaders = await resolve4(this.config.headers());
35741
+ const resolvedHeaders = await resolve5(this.config.headers());
35621
35742
  try {
35622
35743
  const { value: response, responseHeaders } = await postJsonToApi({
35623
35744
  url: this.getUrl(),
35624
- headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await resolve4(this.config.o11yHeaders)),
35745
+ headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await resolve5(this.config.o11yHeaders)),
35625
35746
  body: args,
35626
35747
  successfulResponseHandler: createEventSourceResponseHandler(exports_external2.any()),
35627
35748
  failedResponseHandler: createJsonErrorResponseHandler({
35628
35749
  errorSchema: exports_external2.any(),
35629
- errorToMessage: (data) => data
35750
+ errorToMessage: (data) => {
35751
+ var _a112;
35752
+ return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
35753
+ }
35630
35754
  }),
35631
35755
  ...abortSignal && { abortSignal },
35632
35756
  fetch: this.config.fetch
@@ -35706,7 +35830,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35706
35830
  providerOptions
35707
35831
  }) {
35708
35832
  var _a112, _b112;
35709
- const resolvedHeaders = await resolve4(this.config.headers());
35833
+ const resolvedHeaders = await resolve5(this.config.headers());
35710
35834
  try {
35711
35835
  const {
35712
35836
  responseHeaders,
@@ -35714,7 +35838,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35714
35838
  rawValue
35715
35839
  } = await postJsonToApi({
35716
35840
  url: this.getUrl(),
35717
- headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve4(this.config.o11yHeaders)),
35841
+ headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders)),
35718
35842
  body: {
35719
35843
  values,
35720
35844
  ...providerOptions ? { providerOptions } : {}
@@ -35722,7 +35846,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35722
35846
  successfulResponseHandler: createJsonResponseHandler(gatewayEmbeddingResponseSchema),
35723
35847
  failedResponseHandler: createJsonErrorResponseHandler({
35724
35848
  errorSchema: exports_external2.any(),
35725
- errorToMessage: (data) => data
35849
+ errorToMessage: (data) => {
35850
+ var _a122;
35851
+ return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
35852
+ }
35726
35853
  }),
35727
35854
  ...abortSignal && { abortSignal },
35728
35855
  fetch: this.config.fetch
@@ -35770,7 +35897,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35770
35897
  abortSignal
35771
35898
  }) {
35772
35899
  var _a112, _b112, _c;
35773
- const resolvedHeaders = await resolve4(this.config.headers());
35900
+ const resolvedHeaders = await resolve5(this.config.headers());
35774
35901
  try {
35775
35902
  const {
35776
35903
  responseHeaders,
@@ -35778,7 +35905,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35778
35905
  rawValue
35779
35906
  } = await postJsonToApi({
35780
35907
  url: this.getUrl(),
35781
- headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve4(this.config.o11yHeaders)),
35908
+ headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders)),
35782
35909
  body: {
35783
35910
  prompt,
35784
35911
  n,
@@ -35794,7 +35921,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35794
35921
  successfulResponseHandler: createJsonResponseHandler(gatewayImageResponseSchema),
35795
35922
  failedResponseHandler: createJsonErrorResponseHandler({
35796
35923
  errorSchema: exports_external2.any(),
35797
- errorToMessage: (data) => data
35924
+ errorToMessage: (data) => {
35925
+ var _a122;
35926
+ return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
35927
+ }
35798
35928
  }),
35799
35929
  ...abortSignal && { abortSignal },
35800
35930
  fetch: this.config.fetch
@@ -35855,11 +35985,11 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35855
35985
  headers,
35856
35986
  abortSignal
35857
35987
  }) {
35858
- const resolvedHeaders = await resolve4(this.config.headers());
35988
+ const resolvedHeaders = await resolve5(this.config.headers());
35859
35989
  try {
35860
35990
  const { responseHeaders, value: responseBody } = await postJsonToApi({
35861
35991
  url: this.getUrl(),
35862
- headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve4(this.config.o11yHeaders), { accept: "text/event-stream" }),
35992
+ headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders), { accept: "text/event-stream" }),
35863
35993
  body: {
35864
35994
  prompt,
35865
35995
  n,
@@ -35947,7 +36077,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35947
36077
  },
35948
36078
  failedResponseHandler: createJsonErrorResponseHandler({
35949
36079
  errorSchema: exports_external2.any(),
35950
- errorToMessage: (data) => data
36080
+ errorToMessage: (data) => {
36081
+ var _a112;
36082
+ return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
36083
+ }
35951
36084
  }),
35952
36085
  ...abortSignal && { abortSignal },
35953
36086
  fetch: this.config.fetch
@@ -35993,7 +36126,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
35993
36126
  providerOptions
35994
36127
  }) {
35995
36128
  var _a112;
35996
- const resolvedHeaders = await resolve4(this.config.headers());
36129
+ const resolvedHeaders = await resolve5(this.config.headers());
35997
36130
  try {
35998
36131
  const {
35999
36132
  responseHeaders,
@@ -36001,7 +36134,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
36001
36134
  rawValue
36002
36135
  } = await postJsonToApi({
36003
36136
  url: this.getUrl(),
36004
- headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve4(this.config.o11yHeaders)),
36137
+ headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders)),
36005
36138
  body: {
36006
36139
  documents,
36007
36140
  query,
@@ -36011,7 +36144,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
36011
36144
  successfulResponseHandler: createJsonResponseHandler(gatewayRerankingResponseSchema),
36012
36145
  failedResponseHandler: createJsonErrorResponseHandler({
36013
36146
  errorSchema: exports_external2.any(),
36014
- errorToMessage: (data) => data
36147
+ errorToMessage: (data) => {
36148
+ var _a122;
36149
+ return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
36150
+ }
36015
36151
  }),
36016
36152
  ...abortSignal && { abortSignal },
36017
36153
  fetch: this.config.fetch
@@ -36055,7 +36191,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
36055
36191
  headers,
36056
36192
  abortSignal
36057
36193
  }) {
36058
- const resolvedHeaders = await resolve4(this.config.headers());
36194
+ const resolvedHeaders = await resolve5(this.config.headers());
36059
36195
  try {
36060
36196
  const {
36061
36197
  responseHeaders,
@@ -36063,7 +36199,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
36063
36199
  rawValue
36064
36200
  } = await postJsonToApi({
36065
36201
  url: this.getUrl(),
36066
- headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve4(this.config.o11yHeaders)),
36202
+ headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders)),
36067
36203
  body: {
36068
36204
  text,
36069
36205
  ...voice && { voice },
@@ -36076,7 +36212,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
36076
36212
  successfulResponseHandler: createJsonResponseHandler(gatewaySpeechResponseSchema),
36077
36213
  failedResponseHandler: createJsonErrorResponseHandler({
36078
36214
  errorSchema: exports_external2.any(),
36079
- errorToMessage: (data) => data
36215
+ errorToMessage: (data) => {
36216
+ var _a112;
36217
+ return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
36218
+ }
36080
36219
  }),
36081
36220
  ...abortSignal && { abortSignal },
36082
36221
  fetch: this.config.fetch
@@ -36122,7 +36261,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
36122
36261
  abortSignal
36123
36262
  }) {
36124
36263
  var _a112, _b112, _c;
36125
- const resolvedHeaders = await resolve4(this.config.headers());
36264
+ const resolvedHeaders = await resolve5(this.config.headers());
36126
36265
  try {
36127
36266
  const {
36128
36267
  responseHeaders,
@@ -36130,7 +36269,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
36130
36269
  rawValue
36131
36270
  } = await postJsonToApi({
36132
36271
  url: this.getUrl(),
36133
- headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve4(this.config.o11yHeaders)),
36272
+ headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders)),
36134
36273
  body: {
36135
36274
  audio: audio instanceof Uint8Array ? convertUint8ArrayToBase64(audio) : audio,
36136
36275
  mediaType,
@@ -36139,7 +36278,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
36139
36278
  successfulResponseHandler: createJsonResponseHandler(gatewayTranscriptionResponseSchema),
36140
36279
  failedResponseHandler: createJsonErrorResponseHandler({
36141
36280
  errorSchema: exports_external2.any(),
36142
- errorToMessage: (data) => data
36281
+ errorToMessage: (data) => {
36282
+ var _a122;
36283
+ return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
36284
+ }
36143
36285
  }),
36144
36286
  ...abortSignal && { abortSignal },
36145
36287
  fetch: this.config.fetch
@@ -36171,45 +36313,45 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
36171
36313
  "ai-model-id": this.modelId
36172
36314
  };
36173
36315
  }
36174
- }, 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.166", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
36175
- var init_dist7 = __esm(() => {
36176
- init_dist3();
36177
- init_dist();
36316
+ }, 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;
36317
+ var init_dist8 = __esm(() => {
36318
+ init_dist4();
36319
+ init_dist2();
36178
36320
  init_v4();
36179
36321
  init_v4();
36180
- init_dist3();
36322
+ init_dist4();
36181
36323
  init_v4();
36182
- init_dist3();
36183
- init_dist3();
36184
- init_dist3();
36324
+ init_dist4();
36325
+ init_dist4();
36326
+ init_dist4();
36185
36327
  init_v4();
36186
- init_dist3();
36187
- init_dist3();
36328
+ init_dist4();
36329
+ init_dist4();
36188
36330
  init_v4();
36189
- init_dist3();
36331
+ init_dist4();
36190
36332
  init_v4();
36191
- init_dist3();
36333
+ init_dist4();
36192
36334
  init_v4();
36193
- init_dist3();
36335
+ init_dist4();
36194
36336
  init_v4();
36195
- init_dist3();
36337
+ init_dist4();
36196
36338
  init_v4();
36197
- init_dist3();
36339
+ init_dist4();
36198
36340
  init_v4();
36199
- init_dist();
36200
- init_dist3();
36341
+ init_dist2();
36342
+ init_dist4();
36201
36343
  init_v4();
36202
- init_dist3();
36344
+ init_dist4();
36203
36345
  init_v4();
36204
- init_dist3();
36346
+ init_dist4();
36205
36347
  init_v4();
36206
- init_dist3();
36348
+ init_dist4();
36207
36349
  init_v4();
36208
- init_dist3();
36350
+ init_dist4();
36209
36351
  init_zod();
36210
- init_dist3();
36352
+ init_dist4();
36211
36353
  init_zod();
36212
- init_dist3();
36354
+ init_dist4();
36213
36355
  init_zod();
36214
36356
  import_oidc = __toESM(require_dist(), 1);
36215
36357
  import_oidc2 = __toESM(require_dist(), 1);
@@ -38112,7 +38254,7 @@ var require_tracestate_impl = __commonJS((exports) => {
38112
38254
  const value = listMember.slice(i + 1, part.length);
38113
38255
  if ((0, tracestate_validators_1.validateKey)(key) && (0, tracestate_validators_1.validateValue)(value)) {
38114
38256
  agg.set(key, value);
38115
- } else {}
38257
+ }
38116
38258
  }
38117
38259
  return agg;
38118
38260
  }, new Map);
@@ -38487,7 +38629,7 @@ var require_src = __commonJS((exports) => {
38487
38629
  };
38488
38630
  });
38489
38631
 
38490
- // ../../node_modules/.bun/ai@6.0.246+27912429049419a2/node_modules/ai/dist/index.mjs
38632
+ // ../../node_modules/.bun/ai@6.0.257+27912429049419a2/node_modules/ai/dist/index.mjs
38491
38633
  var exports_dist4 = {};
38492
38634
  __export(exports_dist4, {
38493
38635
  zodSchema: () => zodSchema,
@@ -39772,7 +39914,8 @@ async function recordSpan({
39772
39914
  tracer,
39773
39915
  attributes,
39774
39916
  fn,
39775
- endWhenDone = true
39917
+ endWhenDone = true,
39918
+ endOnError = endWhenDone
39776
39919
  }) {
39777
39920
  return tracer.startActiveSpan(name222, { attributes: await attributes }, async (span) => {
39778
39921
  const ctx = import_api3.context.active();
@@ -39786,7 +39929,9 @@ async function recordSpan({
39786
39929
  try {
39787
39930
  recordErrorOnSpan(span, error40);
39788
39931
  } finally {
39789
- span.end();
39932
+ if (endOnError) {
39933
+ span.end();
39934
+ }
39790
39935
  }
39791
39936
  throw error40;
39792
39937
  }
@@ -42256,6 +42401,7 @@ function processUIMessageStream({
42256
42401
  case "reasoning-start": {
42257
42402
  const reasoningPart = {
42258
42403
  type: "reasoning",
42404
+ id: chunk.id,
42259
42405
  text: "",
42260
42406
  providerMetadata: chunk.providerMetadata,
42261
42407
  state: "streaming"
@@ -42552,7 +42698,7 @@ function processUIMessageStream({
42552
42698
  }
42553
42699
  await updateMessageMetadata(chunk.messageMetadata);
42554
42700
  if (chunk.messageId != null || chunk.messageMetadata != null) {
42555
- write();
42701
+ write({ updateStatus: false });
42556
42702
  }
42557
42703
  break;
42558
42704
  }
@@ -42775,9 +42921,18 @@ function createAsyncIterableStream(source) {
42775
42921
  }
42776
42922
  async function consumeStream({
42777
42923
  stream,
42778
- onError
42924
+ onError,
42925
+ abortSignal
42779
42926
  }) {
42780
42927
  const reader = stream.getReader();
42928
+ const cancelOnAbort = () => {
42929
+ reader.cancel().catch(() => {});
42930
+ };
42931
+ if (abortSignal == null ? undefined : abortSignal.aborted) {
42932
+ cancelOnAbort();
42933
+ } else {
42934
+ abortSignal == null || abortSignal.addEventListener("abort", cancelOnAbort, { once: true });
42935
+ }
42781
42936
  try {
42782
42937
  while (true) {
42783
42938
  const { done } = await reader.read();
@@ -42787,6 +42942,7 @@ async function consumeStream({
42787
42942
  } catch (error40) {
42788
42943
  onError == null || onError(error40);
42789
42944
  } finally {
42945
+ abortSignal == null || abortSignal.removeEventListener("abort", cancelOnAbort);
42790
42946
  reader.releaseLock();
42791
42947
  }
42792
42948
  }
@@ -43387,6 +43543,27 @@ function createUIMessageStream({
43387
43543
  onError
43388
43544
  });
43389
43545
  }
43546
+ function createUIMessageSnapshot(message) {
43547
+ const textByPartIndex = /* @__PURE__ */ new Map;
43548
+ const messageWithoutText = {
43549
+ ...message,
43550
+ parts: message.parts.map((part, index) => {
43551
+ if (part.type === "text" || part.type === "reasoning") {
43552
+ textByPartIndex.set(index, part.text);
43553
+ return { ...part, text: "" };
43554
+ }
43555
+ return part;
43556
+ })
43557
+ };
43558
+ const snapshot2 = structuredClone(messageWithoutText);
43559
+ for (const [index, text2] of textByPartIndex) {
43560
+ const part = snapshot2.parts[index];
43561
+ if (part.type === "text" || part.type === "reasoning") {
43562
+ part.text = text2;
43563
+ }
43564
+ }
43565
+ return snapshot2;
43566
+ }
43390
43567
  function readUIMessageStream({
43391
43568
  message,
43392
43569
  stream,
@@ -43419,7 +43596,7 @@ function readUIMessageStream({
43419
43596
  return job({
43420
43597
  state,
43421
43598
  write: () => {
43422
- controller == null || controller.enqueue(structuredClone(state.message));
43599
+ controller == null || controller.enqueue(createUIMessageSnapshot(state.message));
43423
43600
  }
43424
43601
  });
43425
43602
  },
@@ -46302,7 +46479,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46302
46479
  }, imageMediaTypeSignatures, audioMediaTypeSignatures, videoMediaTypeSignatures, DEFAULT_SNIFF_BYTES = 18, MAX_SIGNATURE_BYTES = 12, MAX_ID3_TAG_BYTES, ID3_SCAN_BYTES, stripID3 = (bytes) => {
46303
46480
  const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
46304
46481
  return bytes.subarray(id3Size + 10);
46305
- }, VERSION6 = "6.0.246", download = async ({
46482
+ }, VERSION6 = "6.0.257", download = async ({
46306
46483
  url: url2,
46307
46484
  maxBytes,
46308
46485
  abortSignal
@@ -46397,7 +46574,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46397
46574
  const schema = asSchema(inputSchema);
46398
46575
  return {
46399
46576
  name: "object",
46400
- responseFormat: resolve4(schema.jsonSchema).then((jsonSchema2) => ({
46577
+ responseFormat: resolve5(schema.jsonSchema).then((jsonSchema2) => ({
46401
46578
  type: "json",
46402
46579
  schema: jsonSchema2,
46403
46580
  ...name222 != null && { name: name222 },
@@ -46458,7 +46635,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46458
46635
  const elementSchema = asSchema(inputElementSchema);
46459
46636
  return {
46460
46637
  name: "array",
46461
- responseFormat: resolve4(elementSchema.jsonSchema).then((jsonSchema2) => {
46638
+ responseFormat: resolve5(elementSchema.jsonSchema).then((jsonSchema2) => {
46462
46639
  const { $schema, ...itemSchema } = jsonSchema2;
46463
46640
  return {
46464
46641
  type: "json",
@@ -47501,6 +47678,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47501
47678
  }),
47502
47679
  tracer,
47503
47680
  endWhenDone: false,
47681
+ endOnError: true,
47504
47682
  fn: async (doStreamSpan2) => ({
47505
47683
  startTimestampMs: now22(),
47506
47684
  doStreamSpan: doStreamSpan2,
@@ -48420,10 +48598,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48420
48598
  onStepFinish,
48421
48599
  ...options
48422
48600
  }) {
48601
+ const preparedCall = await this.prepareCall(options);
48423
48602
  return generateText({
48424
- ...await this.prepareCall(options),
48603
+ ...preparedCall,
48425
48604
  abortSignal,
48426
- timeout,
48605
+ timeout: timeout != null ? timeout : preparedCall.timeout,
48427
48606
  onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
48428
48607
  });
48429
48608
  }
@@ -48434,10 +48613,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48434
48613
  onStepFinish,
48435
48614
  ...options
48436
48615
  }) {
48616
+ const preparedCall = await this.prepareCall(options);
48437
48617
  return streamText({
48438
- ...await this.prepareCall(options),
48618
+ ...preparedCall,
48439
48619
  abortSignal,
48440
- timeout,
48620
+ timeout: timeout != null ? timeout : preparedCall.timeout,
48441
48621
  experimental_transform,
48442
48622
  onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
48443
48623
  });
@@ -48794,6 +48974,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48794
48974
  }),
48795
48975
  tracer,
48796
48976
  endWhenDone: false,
48977
+ endOnError: true,
48797
48978
  fn: async (rootSpan) => {
48798
48979
  const standardizedPrompt = await standardizePrompt({
48799
48980
  system,
@@ -48863,6 +49044,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48863
49044
  }),
48864
49045
  tracer,
48865
49046
  endWhenDone: false,
49047
+ endOnError: true,
48866
49048
  fn: async (doStreamSpan2) => ({
48867
49049
  startTimestampMs: now22(),
48868
49050
  doStreamSpan: doStreamSpan2,
@@ -49449,9 +49631,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49449
49631
  ...options
49450
49632
  }) {
49451
49633
  var _a222, _b16, _c, _d, _e;
49452
- const resolvedBody = await resolve4(this.body);
49453
- const resolvedHeaders = await resolve4(this.headers);
49454
- const resolvedCredentials = await resolve4(this.credentials);
49634
+ const resolvedBody = await resolve5(this.body);
49635
+ const resolvedHeaders = await resolve5(this.headers);
49636
+ const resolvedCredentials = await resolve5(this.credentials);
49455
49637
  const baseHeaders = {
49456
49638
  ...normalizeHeaders(resolvedHeaders),
49457
49639
  ...normalizeHeaders(options.headers)
@@ -49499,9 +49681,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49499
49681
  }
49500
49682
  async reconnectToStream(options) {
49501
49683
  var _a222, _b16, _c, _d, _e;
49502
- const resolvedBody = await resolve4(this.body);
49503
- const resolvedHeaders = await resolve4(this.headers);
49504
- const resolvedCredentials = await resolve4(this.credentials);
49684
+ const resolvedBody = await resolve5(this.body);
49685
+ const resolvedHeaders = await resolve5(this.headers);
49686
+ const resolvedCredentials = await resolve5(this.credentials);
49505
49687
  const baseHeaders = {
49506
49688
  ...normalizeHeaders(resolvedHeaders),
49507
49689
  ...normalizeHeaders(options.headers)
@@ -49521,7 +49703,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49521
49703
  const response = await fetch2(api2, {
49522
49704
  method: "GET",
49523
49705
  headers,
49524
- credentials
49706
+ credentials,
49707
+ signal: options.abortSignal
49525
49708
  });
49526
49709
  if (response.status === 204) {
49527
49710
  return null;
@@ -49549,6 +49732,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49549
49732
  sendAutomaticallyWhen
49550
49733
  }) {
49551
49734
  this.activeResponse = undefined;
49735
+ this.activeResumeRequest = undefined;
49552
49736
  this.jobExecutor = new SerialJobExecutor;
49553
49737
  this.sendMessage = async (message, options) => {
49554
49738
  var _a222, _b16, _c, _d;
@@ -49690,12 +49874,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49690
49874
  });
49691
49875
  this.addToolResult = this.addToolOutput;
49692
49876
  this.stop = async () => {
49693
- var _a222;
49694
- if (this.status !== "streaming" && this.status !== "submitted")
49695
- return;
49696
- if ((_a222 = this.activeResponse) == null ? undefined : _a222.abortController) {
49697
- this.activeResponse.abortController.abort();
49698
- }
49877
+ var _a222, _b16;
49878
+ (_a222 = this.activeResumeRequest) == null || _a222.abortController.abort();
49879
+ (_b16 = this.activeResponse) == null || _b16.abortController.abort();
49699
49880
  };
49700
49881
  this.id = id;
49701
49882
  this.transport = transport;
@@ -49751,25 +49932,59 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49751
49932
  body,
49752
49933
  messageId
49753
49934
  }) {
49754
- var _a222, _b16;
49935
+ var _a222, _b16, _c;
49936
+ const abortController = new AbortController;
49937
+ const activeResumeRequest = trigger === "resume-stream" ? { abortController } : undefined;
49938
+ if (activeResumeRequest) {
49939
+ (_a222 = this.activeResumeRequest) == null || _a222.abortController.abort();
49940
+ this.activeResumeRequest = activeResumeRequest;
49941
+ }
49942
+ const isCurrentRequest = () => activeResumeRequest == null || this.activeResumeRequest === activeResumeRequest;
49943
+ const clearActiveResumeRequest = () => {
49944
+ if (this.activeResumeRequest === activeResumeRequest) {
49945
+ this.activeResumeRequest = undefined;
49946
+ }
49947
+ };
49755
49948
  let resumeStream;
49756
49949
  if (trigger === "resume-stream") {
49757
49950
  try {
49758
49951
  const reconnect = await this.transport.reconnectToStream({
49759
49952
  chatId: this.id,
49953
+ abortSignal: abortController.signal,
49760
49954
  metadata,
49761
49955
  headers,
49762
49956
  body
49763
49957
  });
49958
+ if (abortController.signal.aborted || !isCurrentRequest()) {
49959
+ await (reconnect == null ? undefined : reconnect.cancel().catch(() => {}));
49960
+ if (isCurrentRequest()) {
49961
+ this.setStatus({ status: "ready" });
49962
+ }
49963
+ clearActiveResumeRequest();
49964
+ return;
49965
+ }
49764
49966
  if (reconnect == null) {
49967
+ this.setStatus({ status: "ready" });
49968
+ clearActiveResumeRequest();
49765
49969
  return;
49766
49970
  }
49767
49971
  resumeStream = reconnect;
49768
49972
  } catch (err) {
49973
+ if (abortController.signal.aborted || err.name === "AbortError") {
49974
+ if (isCurrentRequest()) {
49975
+ this.setStatus({ status: "ready" });
49976
+ }
49977
+ clearActiveResumeRequest();
49978
+ return;
49979
+ }
49980
+ if (!isCurrentRequest()) {
49981
+ return;
49982
+ }
49769
49983
  if (this.onError && err instanceof Error) {
49770
49984
  this.onError(err);
49771
49985
  }
49772
49986
  this.setStatus({ status: "error", error: err });
49987
+ clearActiveResumeRequest();
49773
49988
  return;
49774
49989
  }
49775
49990
  }
@@ -49782,10 +49997,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49782
49997
  try {
49783
49998
  const response = {
49784
49999
  state: createStreamingUIMessageState({
49785
- lastMessage: trigger === "regenerate-message" ? undefined : this.state.snapshot(lastMessage),
50000
+ lastMessage: trigger === "resume-stream" || trigger === "regenerate-message" ? undefined : this.state.snapshot(lastMessage),
49786
50001
  messageId: this.generateId()
49787
50002
  }),
49788
- abortController: new AbortController
50003
+ abortController
49789
50004
  };
49790
50005
  activeResponse = response;
49791
50006
  response.abortController.signal.addEventListener("abort", () => {
@@ -49807,19 +50022,29 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49807
50022
  messageId
49808
50023
  });
49809
50024
  }
49810
- const runUpdateMessageJob = (job) => this.jobExecutor.run(() => job({
49811
- state: response.state,
49812
- write: () => {
49813
- var _a232;
49814
- this.setStatus({ status: "streaming" });
49815
- const replaceLastMessage = response.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
49816
- if (replaceLastMessage) {
49817
- this.state.replaceMessage(this.state.messages.length - 1, response.state.message);
49818
- } else {
49819
- this.state.pushMessage(response.state.message);
49820
- }
50025
+ const runUpdateMessageJob = (job) => this.jobExecutor.run(() => {
50026
+ if (response.abortController.signal.aborted) {
50027
+ return Promise.resolve();
49821
50028
  }
49822
- }));
50029
+ return job({
50030
+ state: response.state,
50031
+ write: ({ updateStatus = true } = {}) => {
50032
+ var _a232;
50033
+ if (response.abortController.signal.aborted) {
50034
+ return;
50035
+ }
50036
+ if (updateStatus) {
50037
+ this.setStatus({ status: "streaming" });
50038
+ }
50039
+ const replaceLastMessage = response.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
50040
+ if (replaceLastMessage) {
50041
+ this.state.replaceMessage(this.state.messages.length - 1, response.state.message);
50042
+ } else {
50043
+ this.state.pushMessage(response.state.message);
50044
+ }
50045
+ }
50046
+ });
50047
+ });
49823
50048
  await consumeStream({
49824
50049
  stream: processUIMessageStream({
49825
50050
  stream,
@@ -49832,15 +50057,29 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49832
50057
  throw error40;
49833
50058
  }
49834
50059
  }),
50060
+ abortSignal: response.abortController.signal,
49835
50061
  onError: (error40) => {
49836
50062
  throw error40;
49837
50063
  }
49838
50064
  });
49839
- this.setStatus({ status: "ready" });
50065
+ if (isAbort) {
50066
+ if (isCurrentRequest()) {
50067
+ this.setStatus({ status: "ready" });
50068
+ }
50069
+ return null;
50070
+ }
50071
+ if (isCurrentRequest()) {
50072
+ this.setStatus({ status: "ready" });
50073
+ }
49840
50074
  } catch (err) {
49841
50075
  if (isAbort || err.name === "AbortError") {
49842
50076
  isAbort = true;
49843
- this.setStatus({ status: "ready" });
50077
+ if (isCurrentRequest()) {
50078
+ this.setStatus({ status: "ready" });
50079
+ }
50080
+ return null;
50081
+ }
50082
+ if (!isCurrentRequest()) {
49844
50083
  return null;
49845
50084
  }
49846
50085
  isError = true;
@@ -49854,7 +50093,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49854
50093
  } finally {
49855
50094
  try {
49856
50095
  if (activeResponse) {
49857
- (_a222 = this.onFinish) == null || _a222.call(this, {
50096
+ (_b16 = this.onFinish) == null || _b16.call(this, {
49858
50097
  message: activeResponse.state.message,
49859
50098
  messages: this.state.messages,
49860
50099
  isAbort,
@@ -49863,17 +50102,17 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49863
50102
  finishReason: activeResponse.state.finishReason
49864
50103
  });
49865
50104
  }
49866
- } catch (err) {
49867
- console.error(err);
49868
- }
49869
- if (this.activeResponse === activeResponse) {
49870
- this.activeResponse = undefined;
50105
+ } finally {
50106
+ if (this.activeResponse === activeResponse) {
50107
+ this.activeResponse = undefined;
50108
+ }
50109
+ clearActiveResumeRequest();
49871
50110
  }
49872
50111
  }
49873
50112
  if (!isError && await this.shouldSendAutomatically()) {
49874
50113
  await this.makeRequest({
49875
50114
  trigger: "submit-message",
49876
- messageId: (_b16 = this.lastMessage) == null ? undefined : _b16.id,
50115
+ messageId: (_c = this.lastMessage) == null ? undefined : _c.id,
49877
50116
  metadata,
49878
50117
  headers,
49879
50118
  body
@@ -49912,96 +50151,96 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49912
50151
  return null;
49913
50152
  }
49914
50153
  }, TextStreamChatTransport;
49915
- var init_dist8 = __esm(() => {
49916
- init_dist7();
49917
- init_dist3();
49918
- init_dist3();
49919
- init_dist3();
49920
- init_dist();
49921
- init_dist();
49922
- init_dist();
49923
- init_dist();
49924
- init_dist();
49925
- init_dist();
49926
- init_dist();
49927
- init_dist();
49928
- init_dist();
49929
- init_dist();
49930
- init_dist();
49931
- init_dist();
49932
- init_dist();
49933
- init_dist();
49934
- init_dist();
49935
- init_dist();
49936
- init_dist();
49937
- init_dist();
49938
- init_dist();
49939
- init_dist();
49940
- init_dist();
49941
- init_dist3();
49942
- init_dist();
49943
- init_dist7();
49944
- init_dist3();
49945
- init_dist3();
49946
- init_dist3();
49947
- init_dist();
49948
- init_dist3();
50154
+ var init_dist9 = __esm(() => {
50155
+ init_dist8();
50156
+ init_dist4();
50157
+ init_dist4();
50158
+ init_dist4();
50159
+ init_dist2();
50160
+ init_dist2();
50161
+ init_dist2();
50162
+ init_dist2();
50163
+ init_dist2();
50164
+ init_dist2();
50165
+ init_dist2();
50166
+ init_dist2();
50167
+ init_dist2();
50168
+ init_dist2();
50169
+ init_dist2();
50170
+ init_dist2();
50171
+ init_dist2();
50172
+ init_dist2();
50173
+ init_dist2();
50174
+ init_dist2();
50175
+ init_dist2();
50176
+ init_dist2();
50177
+ init_dist2();
50178
+ init_dist2();
50179
+ init_dist2();
50180
+ init_dist4();
50181
+ init_dist2();
50182
+ init_dist8();
50183
+ init_dist4();
50184
+ init_dist4();
50185
+ init_dist4();
50186
+ init_dist2();
50187
+ init_dist4();
49949
50188
  init_v4();
49950
- init_dist();
49951
- init_dist3();
49952
- init_dist();
49953
- init_dist3();
50189
+ init_dist2();
50190
+ init_dist4();
50191
+ init_dist2();
50192
+ init_dist4();
49954
50193
  init_v4();
49955
50194
  init_v4();
49956
50195
  init_v4();
49957
50196
  init_v4();
49958
50197
  init_v4();
49959
- init_dist7();
49960
- init_dist();
49961
- init_dist();
49962
- init_dist7();
49963
- init_dist3();
49964
- init_dist3();
49965
- init_dist3();
49966
- init_dist3();
49967
- init_dist3();
49968
- init_dist();
49969
- init_dist3();
49970
- init_dist3();
49971
- init_dist3();
49972
- init_dist();
49973
- init_dist3();
49974
- init_dist3();
50198
+ init_dist8();
50199
+ init_dist2();
50200
+ init_dist2();
50201
+ init_dist8();
50202
+ init_dist4();
50203
+ init_dist4();
50204
+ init_dist4();
50205
+ init_dist4();
50206
+ init_dist4();
50207
+ init_dist2();
50208
+ init_dist4();
50209
+ init_dist4();
50210
+ init_dist4();
50211
+ init_dist2();
50212
+ init_dist4();
50213
+ init_dist4();
49975
50214
  init_v4();
49976
- init_dist3();
49977
- init_dist3();
49978
- init_dist3();
49979
- init_dist3();
49980
- init_dist();
49981
- init_dist3();
50215
+ init_dist4();
50216
+ init_dist4();
50217
+ init_dist4();
50218
+ init_dist4();
50219
+ init_dist2();
50220
+ init_dist4();
49982
50221
  init_v4();
49983
- init_dist3();
49984
- init_dist3();
49985
- init_dist3();
49986
- init_dist3();
49987
- init_dist();
49988
- init_dist3();
49989
- init_dist();
49990
- init_dist3();
49991
- init_dist3();
49992
- init_dist3();
49993
- init_dist3();
49994
- init_dist3();
49995
- init_dist();
49996
- init_dist3();
49997
- init_dist();
49998
- init_dist();
49999
- init_dist();
50000
- init_dist3();
50001
- init_dist3();
50002
- init_dist3();
50003
- init_dist3();
50004
- init_dist3();
50222
+ init_dist4();
50223
+ init_dist4();
50224
+ init_dist4();
50225
+ init_dist4();
50226
+ init_dist2();
50227
+ init_dist4();
50228
+ init_dist2();
50229
+ init_dist4();
50230
+ init_dist4();
50231
+ init_dist4();
50232
+ init_dist4();
50233
+ init_dist4();
50234
+ init_dist2();
50235
+ init_dist4();
50236
+ init_dist2();
50237
+ init_dist2();
50238
+ init_dist2();
50239
+ init_dist4();
50240
+ init_dist4();
50241
+ init_dist4();
50242
+ init_dist4();
50243
+ init_dist4();
50005
50244
  import_api2 = __toESM(require_src(), 1);
50006
50245
  import_api3 = __toESM(require_src(), 1);
50007
50246
  __defProp2 = Object.defineProperty;
@@ -51060,6 +51299,7 @@ var init_dist8 = __esm(() => {
51060
51299
  }),
51061
51300
  exports_external2.object({
51062
51301
  type: exports_external2.literal("reasoning"),
51302
+ id: exports_external2.string().optional(),
51063
51303
  text: exports_external2.string(),
51064
51304
  state: exports_external2.enum(["streaming", "done"]).optional(),
51065
51305
  providerMetadata: providerMetadataSchema.optional()
@@ -51982,12 +52222,22 @@ function createMemory(input, dedupeMode = "merge", db) {
51982
52222
  const effectiveMode = dedupeMode === "overwrite" ? "merge" : dedupeMode === "version-fork" ? "create" : dedupeMode;
51983
52223
  if (effectiveMode === "error") {
51984
52224
  const existing = d.query(`SELECT id, agent_id, updated_at FROM memories
51985
- WHERE key = ? AND scope = ? AND COALESCE(project_id, '') = ? AND status = 'active'
52225
+ WHERE key = ? AND scope = ? AND COALESCE(project_id, '') = ?
51986
52226
  LIMIT 1`).get(input.key, input.scope || "private", input.project_id || "");
51987
52227
  if (existing) {
51988
52228
  throw new MemoryConflictError(input.key, existing);
51989
52229
  }
51990
52230
  }
52231
+ if (effectiveMode === "create") {
52232
+ const existing = d.query(`SELECT id, agent_id, updated_at FROM memories
52233
+ WHERE key = ? AND scope = ?
52234
+ AND COALESCE(agent_id, '') = ?
52235
+ AND COALESCE(project_id, '') = ?
52236
+ AND COALESCE(session_id, '') = ?`).get(input.key, input.scope || "private", input.agent_id || "", input.project_id || "", input.session_id || "");
52237
+ if (existing) {
52238
+ throw new MemoryConflictError(input.key, existing);
52239
+ }
52240
+ }
51991
52241
  if (effectiveMode === "merge") {
51992
52242
  const existing = d.query(`SELECT id, version FROM memories
51993
52243
  WHERE key = ? AND scope = ?
@@ -52415,6 +52665,17 @@ function updateMemory(id, input, db) {
52415
52665
  if (existing.version !== input.version) {
52416
52666
  throw new VersionConflictError(id, input.version, existing.version);
52417
52667
  }
52668
+ if (input.scope !== undefined && input.scope !== existing.scope) {
52669
+ const conflict = d.query(`SELECT id, agent_id, updated_at FROM memories
52670
+ WHERE key = ? AND scope = ?
52671
+ AND COALESCE(agent_id, '') = ?
52672
+ AND COALESCE(project_id, '') = ?
52673
+ AND COALESCE(session_id, '') = ?
52674
+ AND id != ?`).get(existing.key, input.scope, existing.agent_id || "", existing.project_id || "", existing.session_id || "", memoryId);
52675
+ if (conflict) {
52676
+ throw new MemoryConflictError(existing.key, conflict);
52677
+ }
52678
+ }
52418
52679
  const sets = ["version = version + 1", "updated_at = ?"];
52419
52680
  const params = [now()];
52420
52681
  if (input.value !== undefined) {
@@ -52607,13 +52868,13 @@ import { createHash } from "crypto";
52607
52868
 
52608
52869
  // src/lib/package-version.ts
52609
52870
  import { readFileSync as readFileSync2 } from "fs";
52610
- import { dirname as dirname2, join as join4 } from "path";
52871
+ import { dirname as dirname2, join as join6 } from "path";
52611
52872
  import { fileURLToPath as fileURLToPath2 } from "url";
52612
52873
  function getMementosPackageVersion() {
52613
52874
  const here = dirname2(fileURLToPath2(import.meta.url));
52614
52875
  for (const candidate of [
52615
- join4(here, "..", "..", "package.json"),
52616
- join4(here, "..", "package.json")
52876
+ join6(here, "..", "..", "package.json"),
52877
+ join6(here, "..", "package.json")
52617
52878
  ]) {
52618
52879
  try {
52619
52880
  const parsed = JSON.parse(readFileSync2(candidate, "utf8"));
@@ -54366,7 +54627,7 @@ function getProjectUpdateReceipt(id, receiptId, identity = projectUpdateAuthorit
54366
54627
  }
54367
54628
  // src/project-registration/authority.ts
54368
54629
  import { createHash as createHash3 } from "crypto";
54369
- import { resolve as resolve2 } from "path";
54630
+ import { resolve as resolve3 } from "path";
54370
54631
 
54371
54632
  // src/project-registration/project-references.ts
54372
54633
  var MEMENTOS_PROJECT_REFERENCE_SURFACES = [
@@ -54543,7 +54804,7 @@ function ownedPath(target) {
54543
54804
  }
54544
54805
  const path = target.withOwnedPath((value) => value);
54545
54806
  requireString(path, "target path", { max: 4096 });
54546
- if (path !== resolve2(path)) {
54807
+ if (path !== resolve3(path)) {
54547
54808
  throw new MementosProjectRegistrationError("MEMENTOS_PROJECT_REGISTRATION_INVALID_INPUT", "target path must already be canonical and absolute");
54548
54809
  }
54549
54810
  return path;
@@ -56882,7 +57143,9 @@ function scoreResults(rows, queryLower, graphBoostedIds) {
56882
57143
  scored.sort((a, b) => {
56883
57144
  if (b.score !== a.score)
56884
57145
  return b.score - a.score;
56885
- return b.memory.importance - a.memory.importance;
57146
+ if (b.memory.importance !== a.memory.importance)
57147
+ return b.memory.importance - a.memory.importance;
57148
+ return a.memory.id.localeCompare(b.memory.id);
56886
57149
  });
56887
57150
  return scored;
56888
57151
  }
@@ -57154,14 +57417,15 @@ function formatMementosProjectPanel(panel) {
57154
57417
  `);
57155
57418
  }
57156
57419
  // src/lib/config.ts
57157
- import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, readdirSync, writeFileSync as writeFileSync3, unlinkSync as unlinkSync2, cpSync as cpSync2 } from "fs";
57158
- import { homedir as homedir2 } from "os";
57159
- import { basename, dirname as dirname3, join as join5, resolve as resolve3 } from "path";
57420
+ init_paths();
57421
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync3, readdirSync, writeFileSync as writeFileSync3, unlinkSync as unlinkSync2, cpSync as cpSync2 } from "fs";
57422
+ import { homedir as homedir3 } from "os";
57423
+ import { basename, dirname as dirname3, join as join7, resolve as resolve4 } from "path";
57160
57424
  function isInMemoryDb2(path) {
57161
57425
  return path === ":memory:" || path.startsWith("file::memory:");
57162
57426
  }
57163
57427
  function homeDir() {
57164
- return process.env["HOME"] || process.env["USERPROFILE"] || homedir2();
57428
+ return process.env["HOME"] || process.env["USERPROFILE"] || homedir3();
57165
57429
  }
57166
57430
  var DEFAULT_CONFIG = {
57167
57431
  default_scope: "private",
@@ -57219,9 +57483,9 @@ function isValidCategory(value) {
57219
57483
  return VALID_CATEGORIES.includes(value);
57220
57484
  }
57221
57485
  function loadConfig() {
57222
- const configPath = join5(homeDir(), ".hasna", "mementos", "config.json");
57486
+ const configPath = join7(getDataRoot(), "config.json");
57223
57487
  let fileConfig = {};
57224
- if (existsSync3(configPath)) {
57488
+ if (existsSync4(configPath)) {
57225
57489
  try {
57226
57490
  const raw = readFileSync3(configPath, "utf-8");
57227
57491
  fileConfig = JSON.parse(raw);
@@ -57247,10 +57511,10 @@ function loadConfig() {
57247
57511
  }
57248
57512
  function findFileWalkingUp(filename) {
57249
57513
  let dir = process.cwd();
57250
- const legacyHomeMementosDb = resolve3(homeDir(), ".mementos", "mementos.db");
57514
+ const legacyHomeMementosDb = resolve4(homeDir(), ".mementos", "mementos.db");
57251
57515
  while (true) {
57252
- const candidate = join5(dir, filename);
57253
- if (existsSync3(candidate) && resolve3(candidate) !== legacyHomeMementosDb) {
57516
+ const candidate = join7(dir, filename);
57517
+ if (existsSync4(candidate) && resolve4(candidate) !== legacyHomeMementosDb) {
57254
57518
  return candidate;
57255
57519
  }
57256
57520
  const parent = dirname3(dir);
@@ -57263,7 +57527,7 @@ function findFileWalkingUp(filename) {
57263
57527
  function findGitRoot2() {
57264
57528
  let dir = process.cwd();
57265
57529
  while (true) {
57266
- if (existsSync3(join5(dir, ".git"))) {
57530
+ if (existsSync4(join7(dir, ".git"))) {
57267
57531
  return dir;
57268
57532
  }
57269
57533
  const parent = dirname3(dir);
@@ -57274,14 +57538,14 @@ function findGitRoot2() {
57274
57538
  }
57275
57539
  }
57276
57540
  function profilesDir() {
57277
- return join5(homeDir(), ".hasna", "mementos", "profiles");
57541
+ return join7(getDataRoot(), "profiles");
57278
57542
  }
57279
57543
  function globalConfigPath() {
57280
- return join5(homeDir(), ".hasna", "mementos", "config.json");
57544
+ return join7(getDataRoot(), "config.json");
57281
57545
  }
57282
57546
  function readGlobalConfig() {
57283
57547
  const p = globalConfigPath();
57284
- if (!existsSync3(p))
57548
+ if (!existsSync4(p))
57285
57549
  return {};
57286
57550
  try {
57287
57551
  return JSON.parse(readFileSync3(p, "utf-8"));
@@ -57291,7 +57555,7 @@ function readGlobalConfig() {
57291
57555
  }
57292
57556
  function readGlobalConfigForWrite() {
57293
57557
  const p = globalConfigPath();
57294
- if (!existsSync3(p))
57558
+ if (!existsSync4(p))
57295
57559
  return {};
57296
57560
  try {
57297
57561
  const data = JSON.parse(readFileSync3(p, "utf-8"));
@@ -57327,13 +57591,13 @@ function setActiveProfile(name) {
57327
57591
  }
57328
57592
  function listProfiles() {
57329
57593
  const dir = profilesDir();
57330
- if (!existsSync3(dir))
57594
+ if (!existsSync4(dir))
57331
57595
  return [];
57332
57596
  return readdirSync(dir).filter((f) => f.endsWith(".db")).map((f) => basename(f, ".db")).sort();
57333
57597
  }
57334
57598
  function deleteProfile(name) {
57335
- const dbPath = join5(profilesDir(), `${name}.db`);
57336
- if (!existsSync3(dbPath))
57599
+ const dbPath = join7(profilesDir(), `${name}.db`);
57600
+ if (!existsSync4(dbPath))
57337
57601
  return false;
57338
57602
  unlinkSync2(dbPath);
57339
57603
  if (getActiveProfile() === name)
@@ -57342,10 +57606,10 @@ function deleteProfile(name) {
57342
57606
  }
57343
57607
  function getDbPath2() {
57344
57608
  const _home = homeDir();
57345
- const _newDir = join5(_home, ".hasna", "mementos");
57346
- const _oldDir = join5(_home, ".mementos");
57347
- if (!existsSync3(_newDir) && existsSync3(_oldDir)) {
57348
- mkdirSync3(join5(_home, ".hasna"), { recursive: true });
57609
+ const _newDir = getDataRoot();
57610
+ const _oldDir = join7(_home, ".mementos");
57611
+ if (!existsSync4(_newDir) && existsSync4(_oldDir)) {
57612
+ mkdirSync3(join7(_home, ".hasna"), { recursive: true });
57349
57613
  cpSync2(_oldDir, _newDir, { recursive: true });
57350
57614
  }
57351
57615
  const envDbPath = process.env["HASNA_MEMENTOS_DB_PATH"] ?? process.env["MEMENTOS_DB_PATH"];
@@ -57353,13 +57617,13 @@ function getDbPath2() {
57353
57617
  if (isInMemoryDb2(envDbPath)) {
57354
57618
  return envDbPath;
57355
57619
  }
57356
- const resolved = resolve3(envDbPath);
57620
+ const resolved = resolve4(envDbPath);
57357
57621
  ensureDir2(dirname3(resolved));
57358
57622
  return resolved;
57359
57623
  }
57360
57624
  const profile = getActiveProfile();
57361
57625
  if (profile) {
57362
- const profilePath = join5(profilesDir(), `${profile}.db`);
57626
+ const profilePath = join7(profilesDir(), `${profile}.db`);
57363
57627
  ensureDir2(dirname3(profilePath));
57364
57628
  return profilePath;
57365
57629
  }
@@ -57367,21 +57631,21 @@ function getDbPath2() {
57367
57631
  if (dbScope === "project") {
57368
57632
  const gitRoot = findGitRoot2();
57369
57633
  if (gitRoot) {
57370
- const dbPath = join5(gitRoot, ".mementos", "mementos.db");
57634
+ const dbPath = join7(gitRoot, ".mementos", "mementos.db");
57371
57635
  ensureDir2(dirname3(dbPath));
57372
57636
  return dbPath;
57373
57637
  }
57374
57638
  }
57375
- const found = findFileWalkingUp(join5(".mementos", "mementos.db"));
57639
+ const found = findFileWalkingUp(join7(".mementos", "mementos.db"));
57376
57640
  if (found) {
57377
57641
  return found;
57378
57642
  }
57379
- const fallback = join5(homeDir(), ".hasna", "mementos", "mementos.db");
57643
+ const fallback = join7(getDataRoot(), "mementos.db");
57380
57644
  ensureDir2(dirname3(fallback));
57381
57645
  return fallback;
57382
57646
  }
57383
57647
  function ensureDir2(dir) {
57384
- if (!existsSync3(dir)) {
57648
+ if (!existsSync4(dir)) {
57385
57649
  mkdirSync3(dir, { recursive: true });
57386
57650
  }
57387
57651
  }
@@ -57762,18 +58026,18 @@ function runCleanup(config, db) {
57762
58026
  return { expired, evicted, archived, unused_archived, deprioritized };
57763
58027
  }
57764
58028
  // src/lib/sync.ts
57765
- import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "fs";
57766
- import { homedir as homedir3 } from "os";
57767
- import { join as join6 } from "path";
58029
+ import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "fs";
58030
+ import { join as join8 } from "path";
58031
+ init_paths();
57768
58032
  function getAgentSyncDir(agentName) {
57769
- const dir = join6(homedir3(), ".hasna", "mementos", "agents", agentName);
57770
- if (!existsSync4(dir)) {
58033
+ const dir = join8(getDataRoot(), "agents", agentName);
58034
+ if (!existsSync5(dir)) {
57771
58035
  mkdirSync4(dir, { recursive: true });
57772
58036
  }
57773
58037
  return dir;
57774
58038
  }
57775
58039
  function setHighWaterMark(agentDir, timestamp2) {
57776
- const markFile = join6(agentDir, ".highwatermark");
58040
+ const markFile = join8(agentDir, ".highwatermark");
57777
58041
  writeFileSync4(markFile, timestamp2, "utf-8");
57778
58042
  }
57779
58043
  function resolveConflict(local, remote, resolution) {
@@ -57794,7 +58058,7 @@ function pushMemories(agentName, agentId, projectId, db) {
57794
58058
  status: "active",
57795
58059
  limit: 1e4
57796
58060
  }, db);
57797
- const outFile = join6(agentDir, "memories.json");
58061
+ const outFile = join8(agentDir, "memories.json");
57798
58062
  writeFileSync4(outFile, JSON.stringify(memories, null, 2), "utf-8");
57799
58063
  if (memories.length > 0) {
57800
58064
  const latest = memories.reduce((a, b) => new Date(a.updated_at).getTime() > new Date(b.updated_at).getTime() ? a : b);
@@ -57804,8 +58068,8 @@ function pushMemories(agentName, agentId, projectId, db) {
57804
58068
  }
57805
58069
  function pullMemories(agentName, conflictResolution = "prefer-newer", db) {
57806
58070
  const agentDir = getAgentSyncDir(agentName);
57807
- const inFile = join6(agentDir, "memories.json");
57808
- if (!existsSync4(inFile)) {
58071
+ const inFile = join8(agentDir, "memories.json");
58072
+ if (!existsSync5(inFile)) {
57809
58073
  return { pulled: 0, conflicts: 0 };
57810
58074
  }
57811
58075
  const raw = readFileSync4(inFile, "utf-8");
@@ -58297,7 +58561,7 @@ function resolveCurrentMachineId(local, requested) {
58297
58561
  function runStorageSync(direction, options = {}) {
58298
58562
  const backend = getStorageBackend();
58299
58563
  if (backend === "sqlite" && !options.remote) {
58300
- throw new Error("Remote storage is not configured. Set HASNA_MEMENTOS_DATABASE_URL or configure ~/.hasna/mementos/storage/config.json.");
58564
+ throw new Error(`Remote storage is not configured. Set HASNA_MEMENTOS_DATABASE_URL or configure ${getConfigPath()}.`);
58301
58565
  }
58302
58566
  return withManagedAdapters(options, (local, remote, currentMachineId) => {
58303
58567
  const tables = resolveTables(local, options.tables);
@@ -60184,7 +60448,7 @@ async function resolveAISDKModel(provider, model) {
60184
60448
  const key = process.env["ANTHROPIC_API_KEY"];
60185
60449
  if (!key)
60186
60450
  return null;
60187
- const mod = await Promise.resolve().then(() => (init_dist4(), exports_dist));
60451
+ const mod = await Promise.resolve().then(() => (init_dist5(), exports_dist));
60188
60452
  const anthropic2 = mod["anthropic"];
60189
60453
  return anthropic2 ? anthropic2(model) : null;
60190
60454
  }
@@ -60192,7 +60456,7 @@ async function resolveAISDKModel(provider, model) {
60192
60456
  const key = process.env["OPENAI_API_KEY"];
60193
60457
  if (!key)
60194
60458
  return null;
60195
- const mod = await Promise.resolve().then(() => (init_dist5(), exports_dist2));
60459
+ const mod = await Promise.resolve().then(() => (init_dist6(), exports_dist2));
60196
60460
  const openai2 = mod["openai"];
60197
60461
  return openai2 ? openai2(model) : null;
60198
60462
  }
@@ -60201,7 +60465,7 @@ async function resolveAISDKModel(provider, model) {
60201
60465
  if (!apiKey)
60202
60466
  return null;
60203
60467
  const baseURL = provider === "cerebras" ? "https://api.cerebras.ai/v1" : "https://api.x.ai/v1";
60204
- const mod = await Promise.resolve().then(() => (init_dist6(), exports_dist3));
60468
+ const mod = await Promise.resolve().then(() => (init_dist7(), exports_dist3));
60205
60469
  const createOpenAICompatible2 = mod["createOpenAICompatible"];
60206
60470
  if (!createOpenAICompatible2)
60207
60471
  return null;
@@ -60217,7 +60481,7 @@ function createAISDKReflectionCritic(options = {}) {
60217
60481
  if (!resolvedModel)
60218
60482
  return heuristicReflectionCritic(trajectory);
60219
60483
  try {
60220
- const ai = await Promise.resolve().then(() => (init_dist8(), exports_dist4));
60484
+ const ai = await Promise.resolve().then(() => (init_dist9(), exports_dist4));
60221
60485
  const generateObject2 = ai["generateObject"];
60222
60486
  if (!generateObject2)
60223
60487
  return heuristicReflectionCritic(trajectory);
@@ -60383,14 +60647,14 @@ var gatherTrainingData = async (options = {}) => {
60383
60647
  };
60384
60648
  };
60385
60649
  // src/lib/model-config.ts
60386
- import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync5 } from "fs";
60387
- import { homedir as homedir4 } from "os";
60388
- import { join as join7 } from "path";
60650
+ init_paths();
60651
+ import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync5 } from "fs";
60652
+ import { join as join9 } from "path";
60389
60653
  var DEFAULT_MODEL = "gpt-4o-mini";
60390
- var CONFIG_DIR = join7(homedir4(), ".hasna", "mementos");
60391
- var CONFIG_PATH = join7(CONFIG_DIR, "config.json");
60654
+ var CONFIG_DIR = getDataRoot();
60655
+ var CONFIG_PATH = join9(CONFIG_DIR, "config.json");
60392
60656
  function readConfig() {
60393
- if (!existsSync5(CONFIG_PATH))
60657
+ if (!existsSync6(CONFIG_PATH))
60394
60658
  return {};
60395
60659
  try {
60396
60660
  const raw = readFileSync5(CONFIG_PATH, "utf-8");
@@ -60400,7 +60664,7 @@ function readConfig() {
60400
60664
  }
60401
60665
  }
60402
60666
  function writeConfig(config2) {
60403
- if (!existsSync5(CONFIG_DIR)) {
60667
+ if (!existsSync6(CONFIG_DIR)) {
60404
60668
  mkdirSync5(CONFIG_DIR, { recursive: true });
60405
60669
  }
60406
60670
  writeFileSync5(CONFIG_PATH, JSON.stringify(config2, null, 2) + `
@@ -60920,6 +61184,7 @@ export {
60920
61184
  getStorageDatabaseUrl,
60921
61185
  getStorageDatabaseEnvName,
60922
61186
  getStorageDatabaseEnv,
61187
+ getStorageConnectionStringForOperator,
60923
61188
  getStorageConnectionString,
60924
61189
  getStorageConfig,
60925
61190
  getStorageBackendDatabaseUrl,