@hasna/testers 0.0.33 → 0.0.34

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/cli/index.js CHANGED
@@ -19778,6 +19778,7 @@ var require_range = __commonJS((exports, module) => {
19778
19778
  return this.range;
19779
19779
  }
19780
19780
  parseRange(range) {
19781
+ range = range.replace(BUILDSTRIPRE, "");
19781
19782
  const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
19782
19783
  const memoKey = memoOpts + ":" + range;
19783
19784
  const cached = cache.get(memoKey);
@@ -19859,12 +19860,14 @@ var require_range = __commonJS((exports, module) => {
19859
19860
  var SemVer = require_semver();
19860
19861
  var {
19861
19862
  safeRe: re,
19863
+ src,
19862
19864
  t,
19863
19865
  comparatorTrimReplace,
19864
19866
  tildeTrimReplace,
19865
19867
  caretTrimReplace
19866
19868
  } = require_re();
19867
19869
  var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
19870
+ var BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
19868
19871
  var isNullSet = (c) => c.value === "<0.0.0-0";
19869
19872
  var isAny = (c) => c.value === "";
19870
19873
  var isSatisfiable = (comparators, options) => {
@@ -26020,52 +26023,54 @@ import { promises as fsPromises } from "fs";
26020
26023
  import { createHash as createHash2, createPrivateKey, createPublicKey, sign } from "crypto";
26021
26024
  import { promises as fs2 } from "fs";
26022
26025
  import { homedir as homedir22 } from "os";
26023
- import { dirname as dirname32, join as join52 } from "path";
26026
+ import { dirname as dirname32, join as join62 } from "path";
26024
26027
  import { exec } from "child_process";
26025
26028
  import { promisify } from "util";
26026
- import { readFileSync as readFileSync32 } from "fs";
26029
+ import { readFileSync as readFileSync42 } from "fs";
26027
26030
  import { webcrypto as crypto2 } from "crypto";
26028
- import { existsSync as existsSync42, writeFileSync as writeFileSync32, readFileSync as readFileSync22, mkdirSync as mkdirSync32 } from "fs";
26029
- import { join as join42 } from "path";
26031
+ import { existsSync as existsSync5, writeFileSync as writeFileSync42, readFileSync as readFileSync32, mkdirSync as mkdirSync32 } from "fs";
26032
+ import { join as join52 } from "path";
26030
26033
  import { Database as Database4 } from "bun:sqlite";
26031
26034
  import { existsSync as existsSync16, mkdirSync as mkdirSync13 } from "fs";
26032
26035
  import { dirname as dirname4, join as join18, resolve as resolve3 } from "path";
26033
26036
  import { existsSync as existsSync22, writeFileSync as writeFileSync6 } from "fs";
26034
26037
  import { join as join22 } from "path";
26035
- import { execSync as execSync3, execFileSync } from "child_process";
26036
- import { existsSync as existsSync32, readFileSync as readFileSync8, writeFileSync as writeFileSync22, mkdirSync as mkdirSync22 } from "fs";
26037
- import { homedir as homedir11 } from "os";
26038
- import { join as join32, dirname as dirname22 } from "path";
26038
+ import { execFileSync } from "child_process";
26039
+ import { writeFileSync as writeFileSync22, existsSync as existsSync32, readFileSync as readFileSync8 } from "fs";
26040
+ import { join as join32 } from "path";
26039
26041
  import { hostname } from "os";
26042
+ import { existsSync as existsSync42, readFileSync as readFileSync22, writeFileSync as writeFileSync32, mkdirSync as mkdirSync22 } from "fs";
26043
+ import { homedir as homedir11 } from "os";
26044
+ import { join as join42, dirname as dirname22 } from "path";
26040
26045
  import { Buffer as Buffer2 } from "buffer";
26041
26046
  import * as zlib from "zlib";
26042
26047
  import { Readable } from "stream";
26043
26048
  import { Writable } from "stream";
26044
26049
  import { createHash as createHash22 } from "crypto";
26045
- import { mkdirSync as mkdirSync4, statSync as statSync2, writeFileSync as writeFileSync42 } from "fs";
26046
- import { dirname as dirname42, join as join62, relative as relative3 } from "path";
26050
+ import { mkdirSync as mkdirSync4, statSync as statSync2, writeFileSync as writeFileSync52 } from "fs";
26051
+ import { dirname as dirname42, join as join72, relative as relative3 } from "path";
26047
26052
  import { readdir, readFile as readFile2 } from "fs/promises";
26048
- import { existsSync as existsSync62, readdirSync as readdirSync5, readFileSync as readFileSync42, statSync as statSync22 } from "fs";
26049
- import { basename as basename2, join as join72, resolve as resolve22 } from "path";
26053
+ import { existsSync as existsSync72, readdirSync as readdirSync5, readFileSync as readFileSync52, statSync as statSync22 } from "fs";
26054
+ import { basename as basename2, join as join82, resolve as resolve22 } from "path";
26050
26055
  import { execFileSync as execFileSync2 } from "child_process";
26051
- import { existsSync as existsSync72, readFileSync as readFileSync52, writeFileSync as writeFileSync52, mkdirSync as mkdirSync52 } from "fs";
26052
- import { dirname as dirname5, join as join82 } from "path";
26056
+ import { existsSync as existsSync82, readFileSync as readFileSync62, writeFileSync as writeFileSync62, mkdirSync as mkdirSync52 } from "fs";
26057
+ import { dirname as dirname5, join as join92 } from "path";
26053
26058
  import { execFileSync as execFileSync4 } from "child_process";
26054
- import { existsSync as existsSync102 } from "fs";
26055
- import { join as join112 } from "path";
26059
+ import { existsSync as existsSync112 } from "fs";
26060
+ import { join as join122 } from "path";
26056
26061
  import { execFileSync as execFileSync3 } from "child_process";
26057
- import { existsSync as existsSync82 } from "fs";
26058
- import { homedir as homedir32, hostname as hostname2, platform as platform2, type } from "os";
26059
- import { join as join92 } from "path";
26060
26062
  import { existsSync as existsSync92 } from "fs";
26061
- import { execSync as execSync22 } from "child_process";
26063
+ import { homedir as homedir32, hostname as hostname2, platform as platform2, type } from "os";
26062
26064
  import { join as join102 } from "path";
26063
- import { execSync as execSync32 } from "child_process";
26064
- import { readFileSync as readFileSync62 } from "fs";
26065
+ import { existsSync as existsSync102 } from "fs";
26066
+ import { execSync as execSync3 } from "child_process";
26067
+ import { join as join112 } from "path";
26068
+ import { execSync as execSync22 } from "child_process";
26069
+ import { readFileSync as readFileSync72 } from "fs";
26065
26070
  import { mkdirSync as mkdirSync62 } from "fs";
26066
- import { dirname as dirname6, join as join122 } from "path";
26071
+ import { dirname as dirname6, join as join132 } from "path";
26067
26072
  import { fileURLToPath } from "url";
26068
- import { existsSync as existsSync112 } from "fs";
26073
+ import { existsSync as existsSync122 } from "fs";
26069
26074
  function __accessProp3(key) {
26070
26075
  return this[key];
26071
26076
  }
@@ -26242,11 +26247,22 @@ function uuid2() {
26242
26247
  function isGitRepo(path) {
26243
26248
  return existsSync22(join22(path, ".git"));
26244
26249
  }
26250
+ function getCurrentBranch(path) {
26251
+ return execFileSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
26252
+ cwd: path,
26253
+ stdio: "pipe",
26254
+ encoding: "utf-8",
26255
+ env: process.env
26256
+ }).trim();
26257
+ }
26258
+ function bootstrapPathsToStage(path) {
26259
+ return BOOTSTRAP_PATHS.filter((entry) => existsSync22(join22(path, entry)));
26260
+ }
26245
26261
  function gitInit(project) {
26246
26262
  const { path, name, id, slug } = project;
26247
26263
  if (isGitRepo(path))
26248
26264
  return;
26249
- execSync3("git init", { cwd: path, stdio: "pipe" });
26265
+ execFileSync("git", ["init", "-b", "main"], { cwd: path, stdio: "pipe", env: process.env });
26250
26266
  const gitignorePath = join22(path, ".gitignore");
26251
26267
  if (!existsSync22(gitignorePath)) {
26252
26268
  writeFileSync6(gitignorePath, GITIGNORE_TEMPLATE, "utf-8");
@@ -26260,24 +26276,16 @@ function gitInit(project) {
26260
26276
  };
26261
26277
  writeFileSync6(join22(path, ".project.json"), JSON.stringify(projectJson, null, 2) + `
26262
26278
  `, "utf-8");
26263
- execSync3("git add .gitignore .project.json", { cwd: path, stdio: "pipe" });
26264
- execSync3(`git commit -m "chore: init project ${name}"`, {
26279
+ const staged = bootstrapPathsToStage(path);
26280
+ if (staged.length === 0)
26281
+ return;
26282
+ execFileSync("git", ["add", ...staged], { cwd: path, stdio: "pipe", env: process.env });
26283
+ execFileSync("git", ["commit", "-m", `chore: init project ${name}`], {
26265
26284
  cwd: path,
26266
26285
  stdio: "pipe",
26267
26286
  env: { ...process.env, GIT_AUTHOR_NAME: "open-projects", GIT_COMMITTER_NAME: "open-projects" }
26268
26287
  });
26269
26288
  }
26270
- function getConfig() {
26271
- if (existsSync32(CONFIG_PATH3)) {
26272
- try {
26273
- const user = JSON.parse(readFileSync8(CONFIG_PATH3, "utf-8"));
26274
- return { ...DEFAULTS, ...user };
26275
- } catch {
26276
- return { ...DEFAULTS };
26277
- }
26278
- }
26279
- return { ...DEFAULTS };
26280
- }
26281
26289
  function rowToWorkdir(row) {
26282
26290
  return {
26283
26291
  ...row,
@@ -26321,6 +26329,176 @@ function removeWorkdir(projectId, path, db2) {
26321
26329
  const d = db2 || getDatabase2();
26322
26330
  d.run("DELETE FROM project_workdirs WHERE project_id = ? AND path = ?", [projectId, path]);
26323
26331
  }
26332
+ function markWorkdirGenerated(projectId, path, db2) {
26333
+ const d = db2 || getDatabase2();
26334
+ d.run("UPDATE project_workdirs SET claude_md_generated = 1, agents_md_generated = 1 WHERE project_id = ? AND path = ?", [projectId, path]);
26335
+ }
26336
+ function buildWorkdirList(workdirs, currentPath) {
26337
+ return workdirs.map((w) => {
26338
+ const isCurrent = w.path === currentPath;
26339
+ const primary = w.is_primary ? " (primary)" : "";
26340
+ const current = isCurrent ? " \u2190 you are here" : "";
26341
+ return `- \`${w.path}\` [${w.label}]${primary}${current} *(machine: ${w.machine_id})*`;
26342
+ }).join(`
26343
+ `);
26344
+ }
26345
+ function claudeMdContent(project, workdir, allWorkdirs) {
26346
+ const otherDirs = allWorkdirs.filter((w) => w.path !== workdir.path);
26347
+ const otherSection = otherDirs.length ? `
26348
+ ## Other Working Directories
26349
+ ${buildWorkdirList(otherDirs, workdir.path)}
26350
+ ` : "";
26351
+ const integrations = Object.keys(project.integrations).length ? `
26352
+ ## Integrations
26353
+ ${Object.entries(project.integrations).filter(([, v]) => v).map(([k, v]) => `- **${k}:** \`${v}\``).join(`
26354
+ `)}
26355
+ ` : "";
26356
+ const tags = project.tags.length ? `
26357
+ **Tags:** ${project.tags.join(", ")}` : "";
26358
+ return `# Project: ${project.name}
26359
+
26360
+ > ${project.description ?? `Working directory for project **${project.name}**`}
26361
+ ${tags}
26362
+
26363
+ ## Working Directory
26364
+
26365
+ You are working in the **${workdir.label}** directory for this project:
26366
+
26367
+ \`\`\`
26368
+ ${workdir.path}
26369
+ \`\`\`
26370
+
26371
+ **Write all code to this directory.** Do not write to other project directories unless explicitly instructed.
26372
+
26373
+ ## Project Metadata
26374
+
26375
+ | Field | Value |
26376
+ |-------|-------|
26377
+ | ID | \`${project.id}\` |
26378
+ | Slug | \`${project.slug}\` |
26379
+ | Label | \`${workdir.label}\` |
26380
+ | Machine | \`${workdir.machine_id}\` |
26381
+ | Status | ${project.status} |
26382
+ ${project.git_remote ? `| Git Remote | ${project.git_remote} |` : ""}
26383
+ ${project.s3_bucket ? `| S3 Bucket | \`${project.s3_bucket}\` |` : ""}
26384
+ ${integrations}${otherSection}
26385
+ ## All Working Directories
26386
+
26387
+ ${buildWorkdirList(allWorkdirs, workdir.path)}
26388
+
26389
+ ## Instructions for AI Agents
26390
+
26391
+ 1. **Write code in \`${workdir.path}\`** \u2014 this is your working directory for this session.
26392
+ 2. Use \`projects sync ${project.slug}\` to push changes to S3.
26393
+ 3. Use \`projects git ${project.slug} <args>\` to run git commands.
26394
+ 4. If you need to switch to a different workdir, call \`projects_open\` with the project ID.
26395
+
26396
+ ---
26397
+ *Generated by open-projects. Regenerate: \`projects workdir generate ${project.slug}\`*
26398
+ `.trimStart();
26399
+ }
26400
+ function agentsMdContent(project, workdir, allWorkdirs) {
26401
+ const otherDirs = allWorkdirs.filter((w) => w.path !== workdir.path);
26402
+ return `---
26403
+ project_id: ${project.id}
26404
+ project_slug: ${project.slug}
26405
+ project_name: ${project.name}
26406
+ working_directory: ${workdir.path}
26407
+ label: ${workdir.label}
26408
+ machine_id: ${workdir.machine_id}
26409
+ is_primary: ${workdir.is_primary}
26410
+ ---
26411
+
26412
+ # ${project.name} \u2014 Agent Instructions
26413
+
26414
+ ## Scope
26415
+
26416
+ This agent session is scoped to the **${workdir.label}** working directory:
26417
+
26418
+ \`\`\`
26419
+ ${workdir.path}
26420
+ \`\`\`
26421
+
26422
+ **Only write files inside this directory** unless the user explicitly asks you to work elsewhere.
26423
+ ${otherDirs.length ? `
26424
+ ## Other workdirs for this project
26425
+
26426
+ ${otherDirs.map((w) => `- \`${w.path}\` [${w.label}] on ${w.machine_id}`).join(`
26427
+ `)}
26428
+ ` : ""}
26429
+ ## Quick Reference
26430
+
26431
+ \`\`\`bash
26432
+ # Open this project
26433
+ cd ${workdir.path}
26434
+
26435
+ # Sync to S3
26436
+ projects sync ${project.slug}
26437
+
26438
+ # Git operations
26439
+ projects git ${project.slug} status
26440
+ projects git ${project.slug} log --oneline -10
26441
+ \`\`\`
26442
+ ${Object.keys(project.integrations).length ? `
26443
+ ## Service IDs
26444
+
26445
+ ${Object.entries(project.integrations).filter(([, v]) => v).map(([k, v]) => `- **${k}:** \`${v}\``).join(`
26446
+ `)}
26447
+ ` : ""}
26448
+ ---
26449
+ *Generated by open-projects ${new Date().toISOString().slice(0, 10)}*
26450
+ `.trimStart();
26451
+ }
26452
+ function generateForWorkdir(project, workdir, allWorkdirs, options = {}) {
26453
+ const claudeMd = claudeMdContent(project, workdir, allWorkdirs);
26454
+ const agentsMd = agentsMdContent(project, workdir, allWorkdirs);
26455
+ const claudePath = join32(workdir.path, "CLAUDE.md");
26456
+ const agentsPath = join32(workdir.path, "AGENTS.md");
26457
+ let written = false;
26458
+ if (!options.dryRun && existsSync32(workdir.path)) {
26459
+ if (existsSync32(claudePath) && !options.force) {
26460
+ const existing = readFileSync8(claudePath, "utf-8");
26461
+ if (existing.includes("Generated by open-projects")) {
26462
+ writeFileSync22(claudePath, claudeMd, "utf-8");
26463
+ } else {
26464
+ const separator = `
26465
+
26466
+ ---
26467
+
26468
+ <!-- open-projects -->
26469
+ `;
26470
+ const marker = "<!-- open-projects -->";
26471
+ if (existing.includes(marker)) {
26472
+ const before = existing.slice(0, existing.indexOf(marker) - separator.length + 1);
26473
+ writeFileSync22(claudePath, before + separator + claudeMd, "utf-8");
26474
+ } else {
26475
+ writeFileSync22(claudePath, existing.trimEnd() + separator + claudeMd, "utf-8");
26476
+ }
26477
+ }
26478
+ } else {
26479
+ writeFileSync22(claudePath, claudeMd, "utf-8");
26480
+ }
26481
+ writeFileSync22(agentsPath, agentsMd, "utf-8");
26482
+ markWorkdirGenerated(project.id, workdir.path, options.db);
26483
+ written = true;
26484
+ }
26485
+ return { path: workdir.path, claude_md: claudeMd, agents_md: agentsMd, written };
26486
+ }
26487
+ function generateAllWorkdirs(project, options = {}) {
26488
+ const workdirs = listWorkdirs(project.id, options.db);
26489
+ return workdirs.map((w) => generateForWorkdir(project, w, workdirs, options));
26490
+ }
26491
+ function getConfig() {
26492
+ if (existsSync42(CONFIG_PATH3)) {
26493
+ try {
26494
+ const user = JSON.parse(readFileSync22(CONFIG_PATH3, "utf-8"));
26495
+ return { ...DEFAULTS, ...user };
26496
+ } catch {
26497
+ return { ...DEFAULTS };
26498
+ }
26499
+ }
26500
+ return { ...DEFAULTS };
26501
+ }
26324
26502
  function generateProjectId() {
26325
26503
  return `prj_${nanoid()}`;
26326
26504
  }
@@ -26328,12 +26506,10 @@ function slugify2(name) {
26328
26506
  return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
26329
26507
  }
26330
26508
  function scaffoldProject(path) {
26331
- if (existsSync42(path))
26332
- return;
26333
26509
  mkdirSync32(path, { recursive: true });
26334
26510
  const config = getConfig();
26335
26511
  for (const dir of config.scaffold_dirs || ["data", "scripts", "assets", "docs"]) {
26336
- mkdirSync32(join42(path, dir), { recursive: true });
26512
+ mkdirSync32(join52(path, dir), { recursive: true });
26337
26513
  }
26338
26514
  }
26339
26515
  function ensureUniqueSlug(base, db2, excludeId) {
@@ -26384,6 +26560,9 @@ function createProject2(input, db2) {
26384
26560
  try {
26385
26561
  addWorkdir({ project_id: id, path: input.path, label: "main", is_primary: true }, d);
26386
26562
  } catch {}
26563
+ try {
26564
+ generateAllWorkdirs(project, { db: d });
26565
+ } catch {}
26387
26566
  const shouldGitInit = input.git_init !== false;
26388
26567
  if (shouldGitInit) {
26389
26568
  try {
@@ -26489,10 +26668,10 @@ function setIntegrations(id, integrations, db2) {
26489
26668
  id
26490
26669
  ]);
26491
26670
  try {
26492
- const jsonPath = join42(project.path, ".project.json");
26493
- if (existsSync42(jsonPath)) {
26494
- const existing = JSON.parse(readFileSync22(jsonPath, "utf-8"));
26495
- writeFileSync32(jsonPath, JSON.stringify({ ...existing, integrations: merged }, null, 2) + `
26671
+ const jsonPath = join52(project.path, ".project.json");
26672
+ if (existsSync5(jsonPath)) {
26673
+ const existing = JSON.parse(readFileSync32(jsonPath, "utf-8"));
26674
+ writeFileSync42(jsonPath, JSON.stringify({ ...existing, integrations: merged }, null, 2) + `
26496
26675
  `, "utf-8");
26497
26676
  }
26498
26677
  } catch {}
@@ -27566,7 +27745,7 @@ async function collectLocalFiles(rootPath) {
27566
27745
  async function walk(dir) {
27567
27746
  const entries = await readdir(dir, { withFileTypes: true });
27568
27747
  for (const entry of entries) {
27569
- const fullPath = join62(dir, entry.name);
27748
+ const fullPath = join72(dir, entry.name);
27570
27749
  if (entry.isDirectory()) {
27571
27750
  await walk(fullPath);
27572
27751
  } else if (entry.isFile()) {
@@ -27638,7 +27817,7 @@ async function syncProject(project, options = {}) {
27638
27817
  continue;
27639
27818
  }
27640
27819
  try {
27641
- const data = await readFile2(join62(project.path, relPath));
27820
+ const data = await readFile2(join72(project.path, relPath));
27642
27821
  await client.send(new PutObjectCommand({
27643
27822
  Bucket: bucket,
27644
27823
  Key: s3Key,
@@ -27676,9 +27855,9 @@ async function syncProject(project, options = {}) {
27676
27855
  chunks.push(chunk);
27677
27856
  }
27678
27857
  const data = Buffer.concat(chunks);
27679
- const localPath = join62(project.path, relPath);
27858
+ const localPath = join72(project.path, relPath);
27680
27859
  mkdirSync4(dirname42(localPath), { recursive: true });
27681
- writeFileSync42(localPath, data);
27860
+ writeFileSync52(localPath, data);
27682
27861
  log(`pull: ${relPath} (${data.length}B)`);
27683
27862
  result.pulled++;
27684
27863
  result.bytes += data.length;
@@ -27699,18 +27878,18 @@ async function syncProject(project, options = {}) {
27699
27878
  return result;
27700
27879
  }
27701
27880
  function inferProjectName(projectPath) {
27702
- const pkgPath = join72(projectPath, "package.json");
27703
- if (existsSync62(pkgPath)) {
27881
+ const pkgPath = join82(projectPath, "package.json");
27882
+ if (existsSync72(pkgPath)) {
27704
27883
  try {
27705
- const pkg = JSON.parse(readFileSync42(pkgPath, "utf-8"));
27884
+ const pkg = JSON.parse(readFileSync52(pkgPath, "utf-8"));
27706
27885
  if (pkg.name)
27707
27886
  return pkg.name.replace(/^@[^/]+\//, "");
27708
27887
  } catch {}
27709
27888
  }
27710
- const projPath = join72(projectPath, ".project.json");
27711
- if (existsSync62(projPath)) {
27889
+ const projPath = join82(projectPath, ".project.json");
27890
+ if (existsSync72(projPath)) {
27712
27891
  try {
27713
- const p2 = JSON.parse(readFileSync42(projPath, "utf-8"));
27892
+ const p2 = JSON.parse(readFileSync52(projPath, "utf-8"));
27714
27893
  if (p2.name)
27715
27894
  return p2.name;
27716
27895
  } catch {}
@@ -27718,11 +27897,11 @@ function inferProjectName(projectPath) {
27718
27897
  return basename2(projectPath);
27719
27898
  }
27720
27899
  function inferGitRemote(projectPath) {
27721
- const gitConfigPath = join72(projectPath, ".git", "config");
27722
- if (!existsSync62(gitConfigPath))
27900
+ const gitConfigPath = join82(projectPath, ".git", "config");
27901
+ if (!existsSync72(gitConfigPath))
27723
27902
  return;
27724
27903
  try {
27725
- const config = readFileSync42(gitConfigPath, "utf-8");
27904
+ const config = readFileSync52(gitConfigPath, "utf-8");
27726
27905
  const match = config.match(/\[remote "origin"\][\s\S]*?url\s*=\s*(.+)/);
27727
27906
  return match?.[1]?.trim();
27728
27907
  } catch {
@@ -27732,7 +27911,7 @@ function inferGitRemote(projectPath) {
27732
27911
  async function importProject(projectPath, options = {}) {
27733
27912
  const absPath = resolve22(projectPath);
27734
27913
  const log = options.onProgress ?? (() => {});
27735
- if (!existsSync62(absPath)) {
27914
+ if (!existsSync72(absPath)) {
27736
27915
  return { error: `Path does not exist: ${absPath}` };
27737
27916
  }
27738
27917
  const stat = statSync22(absPath);
@@ -27767,7 +27946,7 @@ async function importBulk(dirPath, options = {}) {
27767
27946
  const absDir = resolve22(dirPath);
27768
27947
  const result = { imported: [], skipped: [], errors: [] };
27769
27948
  const log = options.onProgress ?? (() => {});
27770
- if (!existsSync62(absDir)) {
27949
+ if (!existsSync72(absDir)) {
27771
27950
  result.errors.push({ path: absDir, error: "Directory does not exist" });
27772
27951
  return result;
27773
27952
  }
@@ -27775,7 +27954,7 @@ async function importBulk(dirPath, options = {}) {
27775
27954
  const dirs = entries.filter((e2) => e2.isDirectory() && !e2.name.startsWith("."));
27776
27955
  log(`Found ${dirs.length} subdirectories in ${absDir}`);
27777
27956
  for (const entry of dirs) {
27778
- const subPath = join72(absDir, entry.name);
27957
+ const subPath = join82(absDir, entry.name);
27779
27958
  const res = await importProject(subPath, options);
27780
27959
  if (res.project) {
27781
27960
  result.imported.push(res.project);
@@ -27810,7 +27989,8 @@ function publishProject(name, path, options = {}) {
27810
27989
  } else {
27811
27990
  execFileSync2("git", ["remote", "add", "origin", remote], { cwd: path, stdio: "pipe", env: process.env });
27812
27991
  }
27813
- execFileSync2("git", ["push", "-u", "origin", "main", "--quiet"], { cwd: path, stdio: "pipe", env: process.env });
27992
+ const branch = getCurrentBranch(path);
27993
+ execFileSync2("git", ["push", "-u", "origin", branch, "--quiet"], { cwd: path, stdio: "pipe", env: process.env });
27814
27994
  pushed = true;
27815
27995
  } catch {}
27816
27996
  }
@@ -27836,14 +28016,14 @@ function getGitHubUrl(path) {
27836
28016
  }
27837
28017
  }
27838
28018
  function getScheduleConfig() {
27839
- if (!existsSync72(CONFIG_PATH22)) {
28019
+ if (!existsSync82(CONFIG_PATH22)) {
27840
28020
  return { enabled: false, interval: "daily", direction: "both" };
27841
28021
  }
27842
- return JSON.parse(readFileSync52(CONFIG_PATH22, "utf-8"));
28022
+ return JSON.parse(readFileSync62(CONFIG_PATH22, "utf-8"));
27843
28023
  }
27844
28024
  function saveScheduleConfig(config) {
27845
28025
  mkdirSync52(dirname5(CONFIG_PATH22), { recursive: true });
27846
- writeFileSync52(CONFIG_PATH22, JSON.stringify(config, null, 2) + `
28026
+ writeFileSync62(CONFIG_PATH22, JSON.stringify(config, null, 2) + `
27847
28027
  `, "utf-8");
27848
28028
  }
27849
28029
  async function syncAll(direction = "both", onProgress) {
@@ -27873,7 +28053,7 @@ async function syncAll(direction = "both", onProgress) {
27873
28053
  function getMachineProfile() {
27874
28054
  const host = (process.env["HOSTNAME"] || hostname2()).split(".")[0] || hostname2();
27875
28055
  const currentPlatform = platform2();
27876
- const workspaceRoot = currentPlatform === "darwin" ? join92(homedir32(), "Workspace") : join92(homedir32(), "workspace");
28056
+ const workspaceRoot = currentPlatform === "darwin" ? join102(homedir32(), "Workspace") : join102(homedir32(), "workspace");
27877
28057
  return {
27878
28058
  hostname: host,
27879
28059
  platform: currentPlatform,
@@ -27900,7 +28080,7 @@ function commandAvailability(command, versionArgs = ["--version"]) {
27900
28080
  return { command, available: true, path: commandPath, version };
27901
28081
  }
27902
28082
  function pathExists(path) {
27903
- return existsSync82(path);
28083
+ return existsSync92(path);
27904
28084
  }
27905
28085
  function classifyMachine(host, currentPlatform) {
27906
28086
  if (host === "apple01")
@@ -27914,10 +28094,10 @@ function classifyMachine(host, currentPlatform) {
27914
28094
  return "unknown";
27915
28095
  }
27916
28096
  function gitStatus(path) {
27917
- if (!existsSync92(join102(path, ".git")))
28097
+ if (!existsSync102(join112(path, ".git")))
27918
28098
  return "not a repo";
27919
28099
  try {
27920
- const out = execSync22("git status --porcelain", { cwd: path, stdio: "pipe", encoding: "utf-8" }).trim();
28100
+ const out = execSync3("git status --porcelain", { cwd: path, stdio: "pipe", encoding: "utf-8" }).trim();
27921
28101
  if (!out)
27922
28102
  return "clean";
27923
28103
  const n2 = out.split(`
@@ -27928,17 +28108,17 @@ function gitStatus(path) {
27928
28108
  }
27929
28109
  }
27930
28110
  function dirSize(path) {
27931
- if (!existsSync92(path))
28111
+ if (!existsSync102(path))
27932
28112
  return 0;
27933
28113
  try {
27934
- const out = execSync22(`du -sb -- "${path}" 2>/dev/null || du -sk -- "${path}" 2>/dev/null`, { stdio: "pipe", encoding: "utf-8" }).trim();
28114
+ const out = execSync3(`du -sb -- "${path}" 2>/dev/null || du -sk -- "${path}" 2>/dev/null`, { stdio: "pipe", encoding: "utf-8" }).trim();
27935
28115
  return parseInt(out.split("\t")[0] ?? "0", 10);
27936
28116
  } catch {
27937
28117
  return 0;
27938
28118
  }
27939
28119
  }
27940
28120
  function getProjectStatus(project) {
27941
- const pathExists2 = existsSync92(project.path);
28121
+ const pathExists2 = existsSync102(project.path);
27942
28122
  const workdirs = listWorkdirs(project.id);
27943
28123
  const lastSync = getDatabase2().query("SELECT completed_at FROM sync_log WHERE project_id = ? AND status = 'completed' ORDER BY completed_at DESC LIMIT 1").get(project.id)?.completed_at ?? null;
27944
28124
  return {
@@ -27951,18 +28131,21 @@ function getProjectStatus(project) {
27951
28131
  };
27952
28132
  }
27953
28133
  function run(cmd) {
27954
- return execSync32(cmd, { encoding: "utf-8", stdio: "pipe" }).trim();
28134
+ return execSync22(cmd, { encoding: "utf-8", stdio: "pipe" }).trim();
27955
28135
  }
27956
28136
  function getTmuxSessionName(project) {
27957
- const raw = project.slug || project.name;
27958
- if (project.path?.includes("opensourcedev")) {
27959
- const normalized = raw.replace(/^proj-/, "");
27960
- return normalized.startsWith("open-") ? normalized : `open-${normalized}`;
27961
- }
27962
- return raw;
28137
+ return project.slug || project.name;
27963
28138
  }
27964
28139
  function listSessions2() {
27965
- const output = run("tmux list-sessions -F '#{session_name}:#{session_group}:#{session_windows}:#{session_attached}'");
28140
+ let output = "";
28141
+ try {
28142
+ output = run("tmux list-sessions -F '#{session_name}:#{session_group}:#{session_windows}:#{session_attached}'");
28143
+ } catch (err) {
28144
+ const message = err instanceof Error ? err.message : String(err);
28145
+ if (message.includes("no server running"))
28146
+ return [];
28147
+ throw err;
28148
+ }
27966
28149
  return output.split(`
27967
28150
  `).filter(Boolean).map((line) => {
27968
28151
  const [name, group, windows, attached] = line.split(":");
@@ -28070,7 +28253,7 @@ function getProjectLocations(project) {
28070
28253
  const currentMachine = getMachineId();
28071
28254
  return listWorkdirs(project.id).map((workdir) => ({
28072
28255
  ...workdir,
28073
- exists: existsSync102(workdir.path),
28256
+ exists: existsSync112(workdir.path),
28074
28257
  currentMachine: workdir.machine_id === currentMachine,
28075
28258
  recommended: workdir.is_primary || workdir.path === project.path
28076
28259
  }));
@@ -28107,7 +28290,7 @@ function buildProjectContext(project) {
28107
28290
  };
28108
28291
  }
28109
28292
  function getGitContext(path) {
28110
- if (!existsSync102(join112(path, ".git"))) {
28293
+ if (!existsSync112(join122(path, ".git"))) {
28111
28294
  return { isRepo: false, branch: null, dirtyCount: null, remote: null };
28112
28295
  }
28113
28296
  return {
@@ -28150,7 +28333,7 @@ function setupMachineReport(options = {}) {
28150
28333
  const dryRun = options.dryRun !== false;
28151
28334
  const checks = [];
28152
28335
  const dbDir = dirname6(getDbPath2());
28153
- const cloudConfig = join122(process.env["HOME"] || "~", ".hasna", "cloud", "config.json");
28336
+ const cloudConfig = join132(process.env["HOME"] || "~", ".hasna", "cloud", "config.json");
28154
28337
  checks.push(pathCheck("PROJECTS_DATA_DIR", "projects data dir", dbDir, options));
28155
28338
  checks.push(pathCheck("WORKSPACE_ROOT", "workspace root", machine.workspaceRoot, options));
28156
28339
  checks.push(commandCheck("bun", ["--version"], "Bun runtime"));
@@ -28211,8 +28394,8 @@ function commandCheck(command, versionArgs, label, missingStatus = "error") {
28211
28394
  }
28212
28395
  function packageVersion() {
28213
28396
  try {
28214
- const pkgPath = join122(dirname6(fileURLToPath(import.meta.url)), "..", "..", "package.json");
28215
- return JSON.parse(readFileSync62(pkgPath, "utf-8")).version || "0.0.0";
28397
+ const pkgPath = join132(dirname6(fileURLToPath(import.meta.url)), "..", "..", "package.json");
28398
+ return JSON.parse(readFileSync72(pkgPath, "utf-8")).version || "0.0.0";
28216
28399
  } catch {
28217
28400
  return "0.0.0";
28218
28401
  }
@@ -28226,7 +28409,7 @@ function findStaleIssues(project) {
28226
28409
  const issues = [];
28227
28410
  const currentMachine = getMachineId();
28228
28411
  for (const p2 of projects) {
28229
- if (p2.status === "active" && !existsSync112(p2.path)) {
28412
+ if (p2.status === "active" && !existsSync122(p2.path)) {
28230
28413
  issues.push({
28231
28414
  code: "PROJECT_PATH_MISSING",
28232
28415
  severity: "error",
@@ -28237,7 +28420,7 @@ function findStaleIssues(project) {
28237
28420
  });
28238
28421
  }
28239
28422
  for (const workdir of listWorkdirs(p2.id)) {
28240
- if (workdir.machine_id === currentMachine && !existsSync112(workdir.path)) {
28423
+ if (workdir.machine_id === currentMachine && !existsSync122(workdir.path)) {
28241
28424
  issues.push({
28242
28425
  code: "WORKDIR_PATH_MISSING",
28243
28426
  severity: "warn",
@@ -29179,7 +29362,7 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
29179
29362
  }
29180
29363
  const credentials = await fromWebToken({
29181
29364
  ...init,
29182
- webIdentityToken: import_shared_ini_file_loader10.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ?? readFileSync32(webIdentityTokenFile, { encoding: "ascii" }),
29365
+ webIdentityToken: import_shared_ini_file_loader10.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ?? readFileSync42(webIdentityTokenFile, { encoding: "ascii" }),
29183
29366
  roleArn,
29184
29367
  roleSessionName
29185
29368
  })(awsIdentityProperties);
@@ -29266,7 +29449,7 @@ coverage/
29266
29449
  # Cache
29267
29450
  .cache/
29268
29451
  .turbo/
29269
- `, CONFIG_PATH3, DEFAULTS, nanoid, import_protocol_http, addExpectContinueMiddlewareOptions, getAddExpectContinuePlugin = (options) => ({
29452
+ `, BOOTSTRAP_PATHS, CONFIG_PATH3, DEFAULTS, nanoid, import_protocol_http, addExpectContinueMiddlewareOptions, getAddExpectContinuePlugin = (options) => ({
29270
29453
  applyToStack: (clientStack) => {
29271
29454
  clientStack.add(addExpectContinueMiddleware(options), addExpectContinueMiddlewareOptions);
29272
29455
  }
@@ -47077,7 +47260,7 @@ More information can be found at: https://a.co/c895JFp`);
47077
47260
  };
47078
47261
  });
47079
47262
  require_dist_cjs41 = __commonJS3((exports) => {
47080
- var __dirname2 = "/home/hasna/workspace/hasna/opensource/open-projects/node_modules/@aws-sdk/util-user-agent-node/dist-cjs";
47263
+ var __dirname2 = "/Users/hasna/Workspace/hasna/opensource/open-projects/node_modules/@aws-sdk/util-user-agent-node/dist-cjs";
47081
47264
  var node_os = __require3("os");
47082
47265
  var node_process = __require3("process");
47083
47266
  var utilConfigProvider = require_dist_cjs28();
@@ -50747,10 +50930,10 @@ More information can be found at: https://a.co/c895JFp`);
50747
50930
  await fs2.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
50748
50931
  }
50749
50932
  getTokenFilePath() {
50750
- const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join52(homedir22(), ".aws", "login", "cache");
50933
+ const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join62(homedir22(), ".aws", "login", "cache");
50751
50934
  const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
50752
50935
  const loginSessionSha256 = createHash2("sha256").update(loginSessionBytes).digest("hex");
50753
- return join52(directory, `${loginSessionSha256}.json`);
50936
+ return join62(directory, `${loginSessionSha256}.json`);
50754
50937
  }
50755
50938
  derToRawSignature(derSignature) {
50756
50939
  let offset = 2;
@@ -51051,7 +51234,18 @@ More information can be found at: https://a.co/c895JFp`);
51051
51234
  INSERT OR IGNORE INTO _migrations (id) VALUES (4);
51052
51235
  `
51053
51236
  ];
51054
- CONFIG_PATH3 = join32(homedir11(), ".hasna", "projects", "config.json");
51237
+ BOOTSTRAP_PATHS = [
51238
+ ".gitignore",
51239
+ ".project.json",
51240
+ "CLAUDE.md",
51241
+ "AGENTS.md",
51242
+ "README.md",
51243
+ "docs",
51244
+ "data",
51245
+ "scripts",
51246
+ "assets"
51247
+ ];
51248
+ CONFIG_PATH3 = join42(homedir11(), ".hasna", "projects", "config.json");
51055
51249
  DEFAULTS = {
51056
51250
  default_path: process.cwd(),
51057
51251
  default_github_org: "hasnaxyz",
@@ -56837,7 +57031,7 @@ More information can be found at: https://a.co/c895JFp`);
56837
57031
  }).s("AmazonS3", "PutObject", {}).n("S3Client", "PutObjectCommand").sc(PutObject$).build() {
56838
57032
  };
56839
57033
  MAX_FILE_SIZE = 100 * 1024 * 1024;
56840
- CONFIG_PATH22 = join82(process.env["HOME"] || "~", ".hasna", "projects", "scheduler.json");
57034
+ CONFIG_PATH22 = join92(process.env["HOME"] || "~", ".hasna", "projects", "scheduler.json");
56841
57035
  SPARK_MACHINES = new Set(["spark01", "spark02"]);
56842
57036
  });
56843
57037
 
@@ -74388,27 +74582,34 @@ var init_v3 = __esm(() => {
74388
74582
 
74389
74583
  // node_modules/@ai-sdk/provider-utils/node_modules/eventsource-parser/dist/index.js
74390
74584
  function noop(_arg) {}
74391
- function createParser(callbacks) {
74392
- if (typeof callbacks == "function")
74393
- throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");
74394
- const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
74395
- let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
74585
+ function createParser(config2) {
74586
+ if (typeof config2 == "function")
74587
+ throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");
74588
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config2, pendingFragments = [];
74589
+ let pendingFragmentsLength = 0, isFirstChunk = true, id, data = "", dataLines = 0, eventType, terminated = false;
74396
74590
  function feed(chunk) {
74591
+ if (terminated)
74592
+ throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");
74397
74593
  if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
74398
74594
  const trailing2 = processLines(chunk);
74399
- trailing2 !== "" && pendingFragments.push(trailing2);
74595
+ trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
74400
74596
  return;
74401
74597
  }
74402
74598
  if (chunk.indexOf(`
74403
74599
  `) === -1 && chunk.indexOf("\r") === -1) {
74404
- pendingFragments.push(chunk);
74600
+ pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
74405
74601
  return;
74406
74602
  }
74407
74603
  pendingFragments.push(chunk);
74408
74604
  const input = pendingFragments.join("");
74409
- pendingFragments.length = 0;
74605
+ pendingFragments.length = 0, pendingFragmentsLength = 0;
74410
74606
  const trailing = processLines(input);
74411
- trailing !== "" && pendingFragments.push(trailing);
74607
+ trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
74608
+ }
74609
+ function checkBufferSize() {
74610
+ maxBufferSize !== undefined && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = undefined, data = "", dataLines = 0, eventType = undefined, onError(new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
74611
+ type: "max-buffer-size-exceeded"
74612
+ }))));
74412
74613
  }
74413
74614
  function processLines(chunk) {
74414
74615
  let searchIndex = 0;
@@ -74520,7 +74721,7 @@ ${value}`, dataLines++;
74520
74721
  const incompleteLine = pendingFragments.join("");
74521
74722
  parseLine(incompleteLine, 0, incompleteLine.length);
74522
74723
  }
74523
- isFirstChunk = true, id = undefined, data = "", dataLines = 0, eventType = undefined, pendingFragments.length = 0;
74724
+ isFirstChunk = true, id = undefined, data = "", dataLines = 0, eventType = undefined, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
74524
74725
  }
74525
74726
  return { feed, reset };
74526
74727
  }
@@ -74544,7 +74745,7 @@ var EventSourceParserStream;
74544
74745
  var init_stream = __esm(() => {
74545
74746
  init_dist4();
74546
74747
  EventSourceParserStream = class EventSourceParserStream extends TransformStream {
74547
- constructor({ onError, onRetry, onComment } = {}) {
74748
+ constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
74548
74749
  let parser;
74549
74750
  super({
74550
74751
  start(controller) {
@@ -74553,10 +74754,11 @@ var init_stream = __esm(() => {
74553
74754
  controller.enqueue(event);
74554
74755
  },
74555
74756
  onError(error40) {
74556
- onError === "terminate" ? controller.error(error40) : typeof onError == "function" && onError(error40);
74757
+ typeof onError == "function" && onError(error40), (onError === "terminate" || error40.type === "max-buffer-size-exceeded") && controller.error(error40);
74557
74758
  },
74558
74759
  onRetry,
74559
- onComment
74760
+ onComment,
74761
+ maxBufferSize
74560
74762
  });
74561
74763
  },
74562
74764
  transform(chunk) {
@@ -75995,7 +76197,7 @@ var DelayedPromise = class {
75995
76197
  });
75996
76198
  }
75997
76199
  return () => `${prefix}${separator}${generator()}`;
75998
- }, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.26", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
76200
+ }, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.27", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
75999
76201
  url: url2,
76000
76202
  headers = {},
76001
76203
  successfulResponseHandler,
@@ -76661,19 +76863,19 @@ var require_token_io = __commonJS((exports, module) => {
76661
76863
  getUserDataDir: () => getUserDataDir
76662
76864
  });
76663
76865
  module.exports = __toCommonJS2(token_io_exports);
76664
- var import_path26 = __toESM4(__require("path"));
76665
- var import_fs30 = __toESM4(__require("fs"));
76866
+ var import_path27 = __toESM4(__require("path"));
76867
+ var import_fs31 = __toESM4(__require("fs"));
76666
76868
  var import_os13 = __toESM4(__require("os"));
76667
76869
  var import_token_error = require_token_error();
76668
76870
  function findRootDir() {
76669
76871
  try {
76670
76872
  let dir = process.cwd();
76671
- while (dir !== import_path26.default.dirname(dir)) {
76672
- const pkgPath = import_path26.default.join(dir, ".vercel");
76673
- if (import_fs30.default.existsSync(pkgPath)) {
76873
+ while (dir !== import_path27.default.dirname(dir)) {
76874
+ const pkgPath = import_path27.default.join(dir, ".vercel");
76875
+ if (import_fs31.default.existsSync(pkgPath)) {
76674
76876
  return dir;
76675
76877
  }
76676
- dir = import_path26.default.dirname(dir);
76878
+ dir = import_path27.default.dirname(dir);
76677
76879
  }
76678
76880
  } catch (e2) {
76679
76881
  throw new import_token_error.VercelOidcTokenError("Token refresh only supported in node server environments");
@@ -76686,9 +76888,9 @@ var require_token_io = __commonJS((exports, module) => {
76686
76888
  }
76687
76889
  switch (import_os13.default.platform()) {
76688
76890
  case "darwin":
76689
- return import_path26.default.join(import_os13.default.homedir(), "Library/Application Support");
76891
+ return import_path27.default.join(import_os13.default.homedir(), "Library/Application Support");
76690
76892
  case "linux":
76691
- return import_path26.default.join(import_os13.default.homedir(), ".local/share");
76893
+ return import_path27.default.join(import_os13.default.homedir(), ".local/share");
76692
76894
  case "win32":
76693
76895
  if (process.env.LOCALAPPDATA) {
76694
76896
  return process.env.LOCALAPPDATA;
@@ -78140,7 +78342,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
78140
78342
  "ai-model-id": this.modelId
78141
78343
  };
78142
78344
  }
78143
- }, gatewayRerankingResponseSchema, parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION2 = "3.0.110", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
78345
+ }, gatewayRerankingResponseSchema, parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION2 = "3.0.120", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
78144
78346
  var init_dist6 = __esm(() => {
78145
78347
  init_dist5();
78146
78348
  init_dist3();
@@ -78179,13 +78381,15 @@ var init_dist6 = __esm(() => {
78179
78381
  message,
78180
78382
  statusCode = 500,
78181
78383
  cause,
78182
- generationId
78384
+ generationId,
78385
+ isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500)
78183
78386
  }) {
78184
78387
  super(generationId ? `${message} [${generationId}]` : message);
78185
78388
  this[_a17] = true;
78186
78389
  this.statusCode = statusCode;
78187
78390
  this.cause = cause;
78188
78391
  this.generationId = generationId;
78392
+ this.isRetryable = isRetryable;
78189
78393
  }
78190
78394
  static isInstance(error40) {
78191
78395
  return _GatewayError.hasMarker(error40);
@@ -78708,62 +78912,11 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
78708
78912
  gateway = createGatewayProvider();
78709
78913
  });
78710
78914
 
78711
- // node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js
78712
- var require_globalThis = __commonJS((exports) => {
78713
- Object.defineProperty(exports, "__esModule", { value: true });
78714
- exports._globalThis = undefined;
78715
- exports._globalThis = typeof globalThis === "object" ? globalThis : global;
78716
- });
78717
-
78718
- // node_modules/@opentelemetry/api/build/src/platform/node/index.js
78719
- var require_node = __commonJS((exports) => {
78720
- var __createBinding2 = exports && exports.__createBinding || (Object.create ? function(o2, m2, k2, k22) {
78721
- if (k22 === undefined)
78722
- k22 = k2;
78723
- Object.defineProperty(o2, k22, { enumerable: true, get: function() {
78724
- return m2[k2];
78725
- } });
78726
- } : function(o2, m2, k2, k22) {
78727
- if (k22 === undefined)
78728
- k22 = k2;
78729
- o2[k22] = m2[k2];
78730
- });
78731
- var __exportStar2 = exports && exports.__exportStar || function(m2, exports2) {
78732
- for (var p2 in m2)
78733
- if (p2 !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p2))
78734
- __createBinding2(exports2, m2, p2);
78735
- };
78736
- Object.defineProperty(exports, "__esModule", { value: true });
78737
- __exportStar2(require_globalThis(), exports);
78738
- });
78739
-
78740
- // node_modules/@opentelemetry/api/build/src/platform/index.js
78741
- var require_platform = __commonJS((exports) => {
78742
- var __createBinding2 = exports && exports.__createBinding || (Object.create ? function(o2, m2, k2, k22) {
78743
- if (k22 === undefined)
78744
- k22 = k2;
78745
- Object.defineProperty(o2, k22, { enumerable: true, get: function() {
78746
- return m2[k2];
78747
- } });
78748
- } : function(o2, m2, k2, k22) {
78749
- if (k22 === undefined)
78750
- k22 = k2;
78751
- o2[k22] = m2[k2];
78752
- });
78753
- var __exportStar2 = exports && exports.__exportStar || function(m2, exports2) {
78754
- for (var p2 in m2)
78755
- if (p2 !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p2))
78756
- __createBinding2(exports2, m2, p2);
78757
- };
78758
- Object.defineProperty(exports, "__esModule", { value: true });
78759
- __exportStar2(require_node(), exports);
78760
- });
78761
-
78762
78915
  // node_modules/@opentelemetry/api/build/src/version.js
78763
78916
  var require_version = __commonJS((exports) => {
78764
78917
  Object.defineProperty(exports, "__esModule", { value: true });
78765
78918
  exports.VERSION = undefined;
78766
- exports.VERSION = "1.9.0";
78919
+ exports.VERSION = "1.9.1";
78767
78920
  });
78768
78921
 
78769
78922
  // node_modules/@opentelemetry/api/build/src/internal/semver.js
@@ -78841,12 +78994,11 @@ var require_semver2 = __commonJS((exports) => {
78841
78994
  var require_global_utils = __commonJS((exports) => {
78842
78995
  Object.defineProperty(exports, "__esModule", { value: true });
78843
78996
  exports.unregisterGlobal = exports.getGlobal = exports.registerGlobal = undefined;
78844
- var platform_1 = require_platform();
78845
78997
  var version_1 = require_version();
78846
78998
  var semver_1 = require_semver2();
78847
78999
  var major = version_1.VERSION.split(".")[0];
78848
79000
  var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(`opentelemetry.js.api.${major}`);
78849
- var _global = platform_1._globalThis;
79001
+ var _global = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
78850
79002
  function registerGlobal(type2, instance, diag, allowOverride = false) {
78851
79003
  var _a16;
78852
79004
  const api2 = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a16 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a16 !== undefined ? _a16 : {
@@ -78918,8 +79070,7 @@ var require_ComponentLogger = __commonJS((exports) => {
78918
79070
  if (!logger) {
78919
79071
  return;
78920
79072
  }
78921
- args.unshift(namespace);
78922
- return logger[funcName](...args);
79073
+ return logger[funcName](namespace, ...args);
78923
79074
  }
78924
79075
  });
78925
79076
 
@@ -78980,6 +79131,12 @@ var require_diag = __commonJS((exports) => {
78980
79131
  var API_NAME = "diag";
78981
79132
 
78982
79133
  class DiagAPI {
79134
+ static instance() {
79135
+ if (!this._instance) {
79136
+ this._instance = new DiagAPI;
79137
+ }
79138
+ return this._instance;
79139
+ }
78983
79140
  constructor() {
78984
79141
  function _logProxy(funcName) {
78985
79142
  return function(...args) {
@@ -79024,12 +79181,6 @@ var require_diag = __commonJS((exports) => {
79024
79181
  self2.warn = _logProxy("warn");
79025
79182
  self2.error = _logProxy("error");
79026
79183
  }
79027
- static instance() {
79028
- if (!this._instance) {
79029
- this._instance = new DiagAPI;
79030
- }
79031
- return this._instance;
79032
- }
79033
79184
  }
79034
79185
  exports.DiagAPI = DiagAPI;
79035
79186
  });
@@ -79051,7 +79202,7 @@ var require_baggage_impl = __commonJS((exports) => {
79051
79202
  return Object.assign({}, entry);
79052
79203
  }
79053
79204
  getAllEntries() {
79054
- return Array.from(this._entries.entries()).map(([k2, v2]) => [k2, v2]);
79205
+ return Array.from(this._entries.entries());
79055
79206
  }
79056
79207
  setEntry(key, entry) {
79057
79208
  const newBaggage = new BaggageImpl(this._entries);
@@ -79143,7 +79294,7 @@ var require_context = __commonJS((exports) => {
79143
79294
  // node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js
79144
79295
  var require_consoleLogger = __commonJS((exports) => {
79145
79296
  Object.defineProperty(exports, "__esModule", { value: true });
79146
- exports.DiagConsoleLogger = undefined;
79297
+ exports.DiagConsoleLogger = exports._originalConsoleMethods = undefined;
79147
79298
  var consoleMap = [
79148
79299
  { n: "error", c: "error" },
79149
79300
  { n: "warn", c: "warn" },
@@ -79151,19 +79302,39 @@ var require_consoleLogger = __commonJS((exports) => {
79151
79302
  { n: "debug", c: "debug" },
79152
79303
  { n: "verbose", c: "trace" }
79153
79304
  ];
79305
+ exports._originalConsoleMethods = {};
79306
+ if (typeof console !== "undefined") {
79307
+ const keys = [
79308
+ "error",
79309
+ "warn",
79310
+ "info",
79311
+ "debug",
79312
+ "trace",
79313
+ "log"
79314
+ ];
79315
+ for (const key of keys) {
79316
+ if (typeof console[key] === "function") {
79317
+ exports._originalConsoleMethods[key] = console[key];
79318
+ }
79319
+ }
79320
+ }
79154
79321
 
79155
79322
  class DiagConsoleLogger {
79156
79323
  constructor() {
79157
79324
  function _consoleFunc(funcName) {
79158
79325
  return function(...args) {
79159
- if (console) {
79160
- let theFunc = console[funcName];
79326
+ let theFunc = exports._originalConsoleMethods[funcName];
79327
+ if (typeof theFunc !== "function") {
79328
+ theFunc = exports._originalConsoleMethods["log"];
79329
+ }
79330
+ if (typeof theFunc !== "function" && console) {
79331
+ theFunc = console[funcName];
79161
79332
  if (typeof theFunc !== "function") {
79162
79333
  theFunc = console.log;
79163
79334
  }
79164
- if (typeof theFunc === "function") {
79165
- return theFunc.apply(console, args);
79166
- }
79335
+ }
79336
+ if (typeof theFunc === "function") {
79337
+ return theFunc.apply(console, args);
79167
79338
  }
79168
79339
  };
79169
79340
  }
@@ -79401,8 +79572,8 @@ var require_NonRecordingSpan = __commonJS((exports) => {
79401
79572
  var invalid_span_constants_1 = require_invalid_span_constants();
79402
79573
 
79403
79574
  class NonRecordingSpan {
79404
- constructor(_spanContext = invalid_span_constants_1.INVALID_SPAN_CONTEXT) {
79405
- this._spanContext = _spanContext;
79575
+ constructor(spanContext = invalid_span_constants_1.INVALID_SPAN_CONTEXT) {
79576
+ this._spanContext = spanContext;
79406
79577
  }
79407
79578
  spanContext() {
79408
79579
  return this._spanContext;
@@ -79478,14 +79649,126 @@ var require_spancontext_utils = __commonJS((exports) => {
79478
79649
  exports.wrapSpanContext = exports.isSpanContextValid = exports.isValidSpanId = exports.isValidTraceId = undefined;
79479
79650
  var invalid_span_constants_1 = require_invalid_span_constants();
79480
79651
  var NonRecordingSpan_1 = require_NonRecordingSpan();
79481
- var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
79482
- var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
79652
+ var isHex = new Uint8Array([
79653
+ 0,
79654
+ 0,
79655
+ 0,
79656
+ 0,
79657
+ 0,
79658
+ 0,
79659
+ 0,
79660
+ 0,
79661
+ 0,
79662
+ 0,
79663
+ 0,
79664
+ 0,
79665
+ 0,
79666
+ 0,
79667
+ 0,
79668
+ 0,
79669
+ 0,
79670
+ 0,
79671
+ 0,
79672
+ 0,
79673
+ 0,
79674
+ 0,
79675
+ 0,
79676
+ 0,
79677
+ 0,
79678
+ 0,
79679
+ 0,
79680
+ 0,
79681
+ 0,
79682
+ 0,
79683
+ 0,
79684
+ 0,
79685
+ 0,
79686
+ 0,
79687
+ 0,
79688
+ 0,
79689
+ 0,
79690
+ 0,
79691
+ 0,
79692
+ 0,
79693
+ 0,
79694
+ 0,
79695
+ 0,
79696
+ 0,
79697
+ 0,
79698
+ 0,
79699
+ 0,
79700
+ 0,
79701
+ 1,
79702
+ 1,
79703
+ 1,
79704
+ 1,
79705
+ 1,
79706
+ 1,
79707
+ 1,
79708
+ 1,
79709
+ 1,
79710
+ 1,
79711
+ 0,
79712
+ 0,
79713
+ 0,
79714
+ 0,
79715
+ 0,
79716
+ 0,
79717
+ 0,
79718
+ 1,
79719
+ 1,
79720
+ 1,
79721
+ 1,
79722
+ 1,
79723
+ 1,
79724
+ 0,
79725
+ 0,
79726
+ 0,
79727
+ 0,
79728
+ 0,
79729
+ 0,
79730
+ 0,
79731
+ 0,
79732
+ 0,
79733
+ 0,
79734
+ 0,
79735
+ 0,
79736
+ 0,
79737
+ 0,
79738
+ 0,
79739
+ 0,
79740
+ 0,
79741
+ 0,
79742
+ 0,
79743
+ 0,
79744
+ 0,
79745
+ 0,
79746
+ 0,
79747
+ 0,
79748
+ 0,
79749
+ 0,
79750
+ 1,
79751
+ 1,
79752
+ 1,
79753
+ 1,
79754
+ 1,
79755
+ 1
79756
+ ]);
79757
+ function isValidHex(id, length) {
79758
+ if (typeof id !== "string" || id.length !== length)
79759
+ return false;
79760
+ let r2 = 0;
79761
+ for (let i2 = 0;i2 < id.length; i2 += 4) {
79762
+ r2 += (isHex[id.charCodeAt(i2)] | 0) + (isHex[id.charCodeAt(i2 + 1)] | 0) + (isHex[id.charCodeAt(i2 + 2)] | 0) + (isHex[id.charCodeAt(i2 + 3)] | 0);
79763
+ }
79764
+ return r2 === length;
79765
+ }
79483
79766
  function isValidTraceId(traceId) {
79484
- return VALID_TRACEID_REGEX.test(traceId) && traceId !== invalid_span_constants_1.INVALID_TRACEID;
79767
+ return isValidHex(traceId, 32) && traceId !== invalid_span_constants_1.INVALID_TRACEID;
79485
79768
  }
79486
79769
  exports.isValidTraceId = isValidTraceId;
79487
79770
  function isValidSpanId(spanId) {
79488
- return VALID_SPANID_REGEX.test(spanId) && spanId !== invalid_span_constants_1.INVALID_SPANID;
79771
+ return isValidHex(spanId, 16) && spanId !== invalid_span_constants_1.INVALID_SPANID;
79489
79772
  }
79490
79773
  exports.isValidSpanId = isValidSpanId;
79491
79774
  function isSpanContextValid(spanContext) {
@@ -79545,7 +79828,7 @@ var require_NoopTracer = __commonJS((exports) => {
79545
79828
  }
79546
79829
  exports.NoopTracer = NoopTracer;
79547
79830
  function isSpanContext(spanContext) {
79548
- return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
79831
+ return spanContext !== null && typeof spanContext === "object" && "spanId" in spanContext && typeof spanContext["spanId"] === "string" && "traceId" in spanContext && typeof spanContext["traceId"] === "string" && "traceFlags" in spanContext && typeof spanContext["traceFlags"] === "number";
79549
79832
  }
79550
79833
  });
79551
79834
 
@@ -79557,8 +79840,8 @@ var require_ProxyTracer = __commonJS((exports) => {
79557
79840
  var NOOP_TRACER = new NoopTracer_1.NoopTracer;
79558
79841
 
79559
79842
  class ProxyTracer {
79560
- constructor(_provider, name15, version2, options) {
79561
- this._provider = _provider;
79843
+ constructor(provider, name15, version2, options) {
79844
+ this._provider = provider;
79562
79845
  this.name = name15;
79563
79846
  this.version = version2;
79564
79847
  this.options = options;
@@ -79718,7 +80001,7 @@ var require_tracestate_impl = __commonJS((exports) => {
79718
80001
  return this._internalState.get(key);
79719
80002
  }
79720
80003
  serialize() {
79721
- return this._keys().reduce((agg, key) => {
80004
+ return Array.from(this._internalState.keys()).reduceRight((agg, key) => {
79722
80005
  agg.push(key + LIST_MEMBER_KEY_VALUE_SPLITTER + this.get(key));
79723
80006
  return agg;
79724
80007
  }, []).join(LIST_MEMBERS_SEPARATOR);
@@ -79726,7 +80009,7 @@ var require_tracestate_impl = __commonJS((exports) => {
79726
80009
  _parse(rawTraceState) {
79727
80010
  if (rawTraceState.length > MAX_TRACE_STATE_LEN)
79728
80011
  return;
79729
- this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).reverse().reduce((agg, part) => {
80012
+ this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).reduceRight((agg, part) => {
79730
80013
  const listMember = part.trim();
79731
80014
  const i2 = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER);
79732
80015
  if (i2 !== -1) {
@@ -80826,7 +81109,10 @@ function convertToLanguageModelMessage({
80826
81109
  type: "tool-result",
80827
81110
  toolCallId: part.toolCallId,
80828
81111
  toolName: part.toolName,
80829
- output: mapToolResultOutput(part.output),
81112
+ output: mapToolResultOutput({
81113
+ output: part.output,
81114
+ downloadedAssets
81115
+ }),
80830
81116
  providerOptions
80831
81117
  };
80832
81118
  }
@@ -80845,7 +81131,10 @@ function convertToLanguageModelMessage({
80845
81131
  type: "tool-result",
80846
81132
  toolCallId: part.toolCallId,
80847
81133
  toolName: part.toolName,
80848
- output: mapToolResultOutput(part.output),
81134
+ output: mapToolResultOutput({
81135
+ output: part.output,
81136
+ downloadedAssets
81137
+ }),
80849
81138
  providerOptions: part.providerOptions
80850
81139
  };
80851
81140
  }
@@ -80869,15 +81158,44 @@ function convertToLanguageModelMessage({
80869
81158
  }
80870
81159
  }
80871
81160
  async function downloadAssets(messages, download2, supportedUrls) {
80872
- const plannedDownloads = messages.filter((message) => message.role === "user").map((message) => message.content).filter((content) => Array.isArray(content)).flat().filter((part) => part.type === "image" || part.type === "file").map((part) => {
80873
- var _a21;
80874
- const mediaType = (_a21 = part.mediaType) != null ? _a21 : part.type === "image" ? "image/*" : undefined;
80875
- let data = part.type === "image" ? part.image : part.data;
80876
- if (typeof data === "string") {
80877
- try {
80878
- data = new URL(data);
80879
- } catch (ignored) {}
81161
+ var _a21;
81162
+ const downloadableFiles = [];
81163
+ for (const message of messages) {
81164
+ if (message.role === "user" && Array.isArray(message.content)) {
81165
+ for (const part of message.content) {
81166
+ if (part.type === "image" || part.type === "file") {
81167
+ downloadableFiles.push({
81168
+ data: part.type === "image" ? part.image : part.data,
81169
+ mediaType: (_a21 = part.mediaType) != null ? _a21 : part.type === "image" ? "image/*" : undefined
81170
+ });
81171
+ }
81172
+ }
81173
+ }
81174
+ if (message.role === "tool" || message.role === "assistant") {
81175
+ if (!Array.isArray(message.content)) {
81176
+ continue;
81177
+ }
81178
+ for (const part of message.content) {
81179
+ if (part.type !== "tool-result") {
81180
+ continue;
81181
+ }
81182
+ if (part.output.type !== "content") {
81183
+ continue;
81184
+ }
81185
+ for (const contentPart of part.output.value) {
81186
+ if (contentPart.type === "image-url" || contentPart.type === "file-url") {
81187
+ downloadableFiles.push({
81188
+ data: new URL(contentPart.url),
81189
+ mediaType: contentPart.type === "image-url" ? "image/*" : undefined
81190
+ });
81191
+ }
81192
+ }
81193
+ }
80880
81194
  }
81195
+ }
81196
+ const plannedDownloads = downloadableFiles.map((part) => {
81197
+ const mediaType = part.mediaType;
81198
+ const { data } = convertToLanguageModelV3DataContent(part.data);
80881
81199
  return { mediaType, data };
80882
81200
  }).filter((part) => part.data instanceof URL).map((part) => ({
80883
81201
  url: part.data,
@@ -80951,13 +81269,41 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
80951
81269
  }
80952
81270
  }
80953
81271
  }
80954
- function mapToolResultOutput(output) {
81272
+ function mapToolResultOutput({
81273
+ output,
81274
+ downloadedAssets
81275
+ }) {
80955
81276
  if (output.type !== "content") {
80956
81277
  return output;
80957
81278
  }
80958
81279
  return {
80959
81280
  type: "content",
80960
81281
  value: output.value.map((item) => {
81282
+ var _a21, _b16;
81283
+ if (item.type === "image-url") {
81284
+ const downloadedFile = downloadedAssets[new URL(item.url).toString()];
81285
+ if (downloadedFile) {
81286
+ return {
81287
+ type: "image-data",
81288
+ data: convertDataContentToBase64String(downloadedFile.data),
81289
+ mediaType: (_a21 = downloadedFile.mediaType) != null ? _a21 : "image/*",
81290
+ providerOptions: item.providerOptions
81291
+ };
81292
+ }
81293
+ return item;
81294
+ }
81295
+ if (item.type === "file-url") {
81296
+ const downloadedFile = downloadedAssets[new URL(item.url).toString()];
81297
+ if (downloadedFile) {
81298
+ return {
81299
+ type: "file-data",
81300
+ data: convertDataContentToBase64String(downloadedFile.data),
81301
+ mediaType: (_b16 = downloadedFile.mediaType) != null ? _b16 : "application/octet-stream",
81302
+ providerOptions: item.providerOptions
81303
+ };
81304
+ }
81305
+ return item;
81306
+ }
80961
81307
  if (item.type !== "media") {
80962
81308
  return item;
80963
81309
  }
@@ -81510,7 +81856,7 @@ function getRetryDelayInMs({
81510
81856
  error: error40,
81511
81857
  exponentialBackoffDelay
81512
81858
  }) {
81513
- const headers = error40.responseHeaders;
81859
+ const headers = APICallError.isInstance(error40) ? error40.responseHeaders : APICallError.isInstance(error40.cause) ? error40.cause.responseHeaders : undefined;
81514
81860
  if (!headers)
81515
81861
  return exponentialBackoffDelay;
81516
81862
  let ms;
@@ -81560,7 +81906,7 @@ async function _retryWithExponentialBackoff(f2, {
81560
81906
  errors: newErrors
81561
81907
  });
81562
81908
  }
81563
- if (error40 instanceof Error && APICallError.isInstance(error40) && error40.isRetryable === true && tryNumber <= maxRetries) {
81909
+ if (error40 instanceof Error && (APICallError.isInstance(error40) && error40.isRetryable === true || GatewayError.isInstance(error40) && error40.isRetryable === true) && tryNumber <= maxRetries) {
81564
81910
  await delay(getRetryDelayInMs({
81565
81911
  error: error40,
81566
81912
  exponentialBackoffDelay: delayInMs
@@ -81778,7 +82124,8 @@ async function executeToolCall({
81778
82124
  input,
81779
82125
  error: error40,
81780
82126
  dynamic: tool2.type === "dynamic",
81781
- ...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {}
82127
+ ...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {},
82128
+ ...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
81782
82129
  };
81783
82130
  }
81784
82131
  const durationMs = now3() - startTime;
@@ -81808,7 +82155,8 @@ async function executeToolCall({
81808
82155
  input,
81809
82156
  output,
81810
82157
  dynamic: tool2.type === "dynamic",
81811
- ...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {}
82158
+ ...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {},
82159
+ ...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
81812
82160
  };
81813
82161
  }
81814
82162
  });
@@ -82173,15 +82521,6 @@ async function parsePartialJson(jsonText) {
82173
82521
  }
82174
82522
  return { value: undefined, state: "failed-parse" };
82175
82523
  }
82176
- function mergeToolProviderMetadata(toolMetadata, callMetadata) {
82177
- if (toolMetadata == null) {
82178
- return callMetadata;
82179
- }
82180
- if (callMetadata == null) {
82181
- return toolMetadata;
82182
- }
82183
- return { ...toolMetadata, ...callMetadata };
82184
- }
82185
82524
  async function parseToolCall({
82186
82525
  toolCall,
82187
82526
  tools,
@@ -82189,7 +82528,6 @@ async function parseToolCall({
82189
82528
  system,
82190
82529
  messages
82191
82530
  }) {
82192
- var _a21, _b16;
82193
82531
  try {
82194
82532
  if (tools == null) {
82195
82533
  if (toolCall.providerExecuted && toolCall.dynamic) {
@@ -82230,6 +82568,7 @@ async function parseToolCall({
82230
82568
  } catch (error40) {
82231
82569
  const parsedInput = await safeParseJSON({ text: toolCall.input });
82232
82570
  const input = parsedInput.success ? parsedInput.value : toolCall.input;
82571
+ const tool2 = tools == null ? undefined : tools[toolCall.toolName];
82233
82572
  return {
82234
82573
  type: "tool-call",
82235
82574
  toolCallId: toolCall.toolCallId,
@@ -82238,9 +82577,10 @@ async function parseToolCall({
82238
82577
  dynamic: true,
82239
82578
  invalid: true,
82240
82579
  error: error40,
82241
- title: (_a21 = tools == null ? undefined : tools[toolCall.toolName]) == null ? undefined : _a21.title,
82580
+ title: tool2 == null ? undefined : tool2.title,
82242
82581
  providerExecuted: toolCall.providerExecuted,
82243
- providerMetadata: mergeToolProviderMetadata((_b16 = tools == null ? undefined : tools[toolCall.toolName]) == null ? undefined : _b16.providerMetadata, toolCall.providerMetadata)
82582
+ providerMetadata: toolCall.providerMetadata,
82583
+ ...(tool2 == null ? undefined : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
82244
82584
  };
82245
82585
  }
82246
82586
  }
@@ -82287,14 +82627,14 @@ async function doParseToolCall({
82287
82627
  cause: parseResult.error
82288
82628
  });
82289
82629
  }
82290
- const mergedProviderMetadata = mergeToolProviderMetadata(tool2.providerMetadata, toolCall.providerMetadata);
82291
82630
  return tool2.type === "dynamic" ? {
82292
82631
  type: "tool-call",
82293
82632
  toolCallId: toolCall.toolCallId,
82294
82633
  toolName: toolCall.toolName,
82295
82634
  input: parseResult.value,
82296
82635
  providerExecuted: toolCall.providerExecuted,
82297
- providerMetadata: mergedProviderMetadata,
82636
+ providerMetadata: toolCall.providerMetadata,
82637
+ ...tool2.metadata != null ? { toolMetadata: tool2.metadata } : {},
82298
82638
  dynamic: true,
82299
82639
  title: tool2.title
82300
82640
  } : {
@@ -82303,7 +82643,8 @@ async function doParseToolCall({
82303
82643
  toolName,
82304
82644
  input: parseResult.value,
82305
82645
  providerExecuted: toolCall.providerExecuted,
82306
- providerMetadata: mergedProviderMetadata,
82646
+ providerMetadata: toolCall.providerMetadata,
82647
+ ...tool2.metadata != null ? { toolMetadata: tool2.metadata } : {},
82307
82648
  title: tool2.title
82308
82649
  };
82309
82650
  }
@@ -83135,7 +83476,8 @@ function asContent({
83135
83476
  error: part.result,
83136
83477
  providerExecuted: true,
83137
83478
  dynamic: part.dynamic,
83138
- ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
83479
+ ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
83480
+ ...(tool2 == null ? undefined : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
83139
83481
  });
83140
83482
  } else {
83141
83483
  contentParts.push({
@@ -83146,7 +83488,8 @@ function asContent({
83146
83488
  output: part.result,
83147
83489
  providerExecuted: true,
83148
83490
  dynamic: part.dynamic,
83149
- ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
83491
+ ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
83492
+ ...(tool2 == null ? undefined : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
83150
83493
  });
83151
83494
  }
83152
83495
  break;
@@ -83160,7 +83503,8 @@ function asContent({
83160
83503
  error: part.result,
83161
83504
  providerExecuted: true,
83162
83505
  dynamic: toolCall.dynamic,
83163
- ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
83506
+ ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
83507
+ ...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
83164
83508
  });
83165
83509
  } else {
83166
83510
  contentParts.push({
@@ -83171,7 +83515,8 @@ function asContent({
83171
83515
  output: part.result,
83172
83516
  providerExecuted: true,
83173
83517
  dynamic: toolCall.dynamic,
83174
- ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
83518
+ ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
83519
+ ...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
83175
83520
  });
83176
83521
  }
83177
83522
  break;
@@ -83385,6 +83730,9 @@ function processUIMessageStream({
83385
83730
  if (options.title !== undefined) {
83386
83731
  anyPart.title = options.title;
83387
83732
  }
83733
+ if (options.toolMetadata !== undefined) {
83734
+ anyPart.toolMetadata = options.toolMetadata;
83735
+ }
83388
83736
  anyPart.providerExecuted = (_a222 = anyOptions.providerExecuted) != null ? _a222 : part.providerExecuted;
83389
83737
  const providerMetadata = anyOptions.providerMetadata;
83390
83738
  if (providerMetadata != null) {
@@ -83401,6 +83749,7 @@ function processUIMessageStream({
83401
83749
  toolCallId: options.toolCallId,
83402
83750
  state: options.state,
83403
83751
  title: options.title,
83752
+ ...options.toolMetadata !== undefined ? { toolMetadata: options.toolMetadata } : {},
83404
83753
  input: anyOptions.input,
83405
83754
  output: anyOptions.output,
83406
83755
  rawInput: anyOptions.rawInput,
@@ -83428,6 +83777,9 @@ function processUIMessageStream({
83428
83777
  if (options.title !== undefined) {
83429
83778
  anyPart.title = options.title;
83430
83779
  }
83780
+ if (options.toolMetadata !== undefined) {
83781
+ anyPart.toolMetadata = options.toolMetadata;
83782
+ }
83431
83783
  anyPart.providerExecuted = (_b23 = anyOptions.providerExecuted) != null ? _b23 : part.providerExecuted;
83432
83784
  const providerMetadata = anyOptions.providerMetadata;
83433
83785
  if (providerMetadata != null) {
@@ -83450,6 +83802,7 @@ function processUIMessageStream({
83450
83802
  preliminary: anyOptions.preliminary,
83451
83803
  providerExecuted: anyOptions.providerExecuted,
83452
83804
  title: options.title,
83805
+ ...options.toolMetadata !== undefined ? { toolMetadata: options.toolMetadata } : {},
83453
83806
  ...anyOptions.providerMetadata != null && (options.state === "output-available" || options.state === "output-error") ? { resultProviderMetadata: anyOptions.providerMetadata } : {},
83454
83807
  ...anyOptions.providerMetadata != null && !(options.state === "output-available" || options.state === "output-error") ? { callProviderMetadata: anyOptions.providerMetadata } : {}
83455
83808
  });
@@ -83594,7 +83947,8 @@ function processUIMessageStream({
83594
83947
  toolName: chunk.toolName,
83595
83948
  index: toolInvocations.length,
83596
83949
  dynamic: chunk.dynamic,
83597
- title: chunk.title
83950
+ title: chunk.title,
83951
+ toolMetadata: chunk.toolMetadata
83598
83952
  };
83599
83953
  if (chunk.dynamic) {
83600
83954
  updateDynamicToolPart({
@@ -83604,6 +83958,7 @@ function processUIMessageStream({
83604
83958
  input: undefined,
83605
83959
  providerExecuted: chunk.providerExecuted,
83606
83960
  title: chunk.title,
83961
+ toolMetadata: chunk.toolMetadata,
83607
83962
  providerMetadata: chunk.providerMetadata
83608
83963
  });
83609
83964
  } else {
@@ -83614,6 +83969,7 @@ function processUIMessageStream({
83614
83969
  input: undefined,
83615
83970
  providerExecuted: chunk.providerExecuted,
83616
83971
  title: chunk.title,
83972
+ toolMetadata: chunk.toolMetadata,
83617
83973
  providerMetadata: chunk.providerMetadata
83618
83974
  });
83619
83975
  }
@@ -83637,7 +83993,8 @@ function processUIMessageStream({
83637
83993
  toolName: partialToolCall.toolName,
83638
83994
  state: "input-streaming",
83639
83995
  input: partialArgs,
83640
- title: partialToolCall.title
83996
+ title: partialToolCall.title,
83997
+ toolMetadata: partialToolCall.toolMetadata
83641
83998
  });
83642
83999
  } else {
83643
84000
  updateToolPart({
@@ -83645,7 +84002,8 @@ function processUIMessageStream({
83645
84002
  toolName: partialToolCall.toolName,
83646
84003
  state: "input-streaming",
83647
84004
  input: partialArgs,
83648
- title: partialToolCall.title
84005
+ title: partialToolCall.title,
84006
+ toolMetadata: partialToolCall.toolMetadata
83649
84007
  });
83650
84008
  }
83651
84009
  write();
@@ -83660,7 +84018,8 @@ function processUIMessageStream({
83660
84018
  input: chunk.input,
83661
84019
  providerExecuted: chunk.providerExecuted,
83662
84020
  providerMetadata: chunk.providerMetadata,
83663
- title: chunk.title
84021
+ title: chunk.title,
84022
+ toolMetadata: chunk.toolMetadata
83664
84023
  });
83665
84024
  } else {
83666
84025
  updateToolPart({
@@ -83670,7 +84029,8 @@ function processUIMessageStream({
83670
84029
  input: chunk.input,
83671
84030
  providerExecuted: chunk.providerExecuted,
83672
84031
  providerMetadata: chunk.providerMetadata,
83673
- title: chunk.title
84032
+ title: chunk.title,
84033
+ toolMetadata: chunk.toolMetadata
83674
84034
  });
83675
84035
  }
83676
84036
  write();
@@ -83692,7 +84052,8 @@ function processUIMessageStream({
83692
84052
  input: chunk.input,
83693
84053
  errorText: chunk.errorText,
83694
84054
  providerExecuted: chunk.providerExecuted,
83695
- providerMetadata: chunk.providerMetadata
84055
+ providerMetadata: chunk.providerMetadata,
84056
+ toolMetadata: chunk.toolMetadata
83696
84057
  });
83697
84058
  } else {
83698
84059
  updateToolPart({
@@ -83703,7 +84064,8 @@ function processUIMessageStream({
83703
84064
  rawInput: chunk.input,
83704
84065
  errorText: chunk.errorText,
83705
84066
  providerExecuted: chunk.providerExecuted,
83706
- providerMetadata: chunk.providerMetadata
84067
+ providerMetadata: chunk.providerMetadata,
84068
+ toolMetadata: chunk.toolMetadata
83707
84069
  });
83708
84070
  }
83709
84071
  write();
@@ -83734,7 +84096,8 @@ function processUIMessageStream({
83734
84096
  preliminary: chunk.preliminary,
83735
84097
  providerExecuted: chunk.providerExecuted,
83736
84098
  providerMetadata: chunk.providerMetadata,
83737
- title: toolInvocation.title
84099
+ title: toolInvocation.title,
84100
+ toolMetadata: toolInvocation.toolMetadata
83738
84101
  });
83739
84102
  } else {
83740
84103
  updateToolPart({
@@ -83746,7 +84109,8 @@ function processUIMessageStream({
83746
84109
  providerExecuted: chunk.providerExecuted,
83747
84110
  preliminary: chunk.preliminary,
83748
84111
  providerMetadata: chunk.providerMetadata,
83749
- title: toolInvocation.title
84112
+ title: toolInvocation.title,
84113
+ toolMetadata: toolInvocation.toolMetadata
83750
84114
  });
83751
84115
  }
83752
84116
  write();
@@ -83763,7 +84127,8 @@ function processUIMessageStream({
83763
84127
  errorText: chunk.errorText,
83764
84128
  providerExecuted: chunk.providerExecuted,
83765
84129
  providerMetadata: chunk.providerMetadata,
83766
- title: toolInvocation.title
84130
+ title: toolInvocation.title,
84131
+ toolMetadata: toolInvocation.toolMetadata
83767
84132
  });
83768
84133
  } else {
83769
84134
  updateToolPart({
@@ -83775,7 +84140,8 @@ function processUIMessageStream({
83775
84140
  errorText: chunk.errorText,
83776
84141
  providerExecuted: chunk.providerExecuted,
83777
84142
  providerMetadata: chunk.providerMetadata,
83778
- title: toolInvocation.title
84143
+ title: toolInvocation.title,
84144
+ toolMetadata: toolInvocation.toolMetadata
83779
84145
  });
83780
84146
  }
83781
84147
  write();
@@ -84233,7 +84599,8 @@ function runToolsTransformation({
84233
84599
  input: toolCall.input,
84234
84600
  error: getErrorMessage2(toolCall.error),
84235
84601
  dynamic: true,
84236
- title: toolCall.title
84602
+ title: toolCall.title,
84603
+ ...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
84237
84604
  });
84238
84605
  break;
84239
84606
  }
@@ -84301,6 +84668,7 @@ function runToolsTransformation({
84301
84668
  }
84302
84669
  case "tool-result": {
84303
84670
  const toolName = chunk.toolName;
84671
+ const toolCall = toolCallsByToolCallId.get(chunk.toolCallId);
84304
84672
  if (chunk.isError) {
84305
84673
  toolResultsStreamController.enqueue({
84306
84674
  type: "tool-error",
@@ -84310,7 +84678,8 @@ function runToolsTransformation({
84310
84678
  providerExecuted: true,
84311
84679
  error: chunk.result,
84312
84680
  dynamic: chunk.dynamic,
84313
- ...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
84681
+ ...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {},
84682
+ ...(toolCall == null ? undefined : toolCall.toolMetadata) != null ? { toolMetadata: toolCall.toolMetadata } : {}
84314
84683
  });
84315
84684
  } else {
84316
84685
  controller.enqueue({
@@ -84321,7 +84690,8 @@ function runToolsTransformation({
84321
84690
  output: chunk.result,
84322
84691
  providerExecuted: true,
84323
84692
  dynamic: chunk.dynamic,
84324
- ...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
84693
+ ...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {},
84694
+ ...(toolCall == null ? undefined : toolCall.toolMetadata) != null ? { toolMetadata: toolCall.toolMetadata } : {}
84325
84695
  });
84326
84696
  }
84327
84697
  break;
@@ -85104,7 +85474,7 @@ async function embed({
85104
85474
  }),
85105
85475
  tracer,
85106
85476
  fn: async (doEmbedSpan) => {
85107
- var _a21;
85477
+ var _a21, _b16;
85108
85478
  const modelResponse = await model.doEmbed({
85109
85479
  values: [value],
85110
85480
  abortSignal,
@@ -85125,7 +85495,7 @@ async function embed({
85125
85495
  return {
85126
85496
  embedding: embedding2,
85127
85497
  usage: usage2,
85128
- warnings: modelResponse.warnings,
85498
+ warnings: (_b16 = modelResponse.warnings) != null ? _b16 : [],
85129
85499
  providerMetadata: modelResponse.providerMetadata,
85130
85500
  response: modelResponse.response
85131
85501
  };
@@ -85221,7 +85591,7 @@ async function embedMany({
85221
85591
  }),
85222
85592
  tracer,
85223
85593
  fn: async (doEmbedSpan) => {
85224
- var _a222;
85594
+ var _a222, _b16;
85225
85595
  const modelResponse = await model.doEmbed({
85226
85596
  values,
85227
85597
  abortSignal,
@@ -85242,7 +85612,7 @@ async function embedMany({
85242
85612
  return {
85243
85613
  embeddings: embeddings3,
85244
85614
  usage: usage2,
85245
- warnings: modelResponse.warnings,
85615
+ warnings: (_b16 = modelResponse.warnings) != null ? _b16 : [],
85246
85616
  providerMetadata: modelResponse.providerMetadata,
85247
85617
  response: modelResponse.response
85248
85618
  };
@@ -85299,7 +85669,7 @@ async function embedMany({
85299
85669
  }),
85300
85670
  tracer,
85301
85671
  fn: async (doEmbedSpan) => {
85302
- var _a222;
85672
+ var _a222, _b16;
85303
85673
  const modelResponse = await model.doEmbed({
85304
85674
  values: chunk,
85305
85675
  abortSignal,
@@ -85320,7 +85690,7 @@ async function embedMany({
85320
85690
  return {
85321
85691
  embeddings: embeddings2,
85322
85692
  usage,
85323
- warnings: modelResponse.warnings,
85693
+ warnings: (_b16 = modelResponse.warnings) != null ? _b16 : [],
85324
85694
  providerMetadata: modelResponse.providerMetadata,
85325
85695
  response: modelResponse.response
85326
85696
  };
@@ -87434,7 +87804,7 @@ var import_api2, import_api3, __defProp4, __export4 = (target, all) => {
87434
87804
  const bytes = typeof data === "string" ? convertBase64ToUint8Array(data) : data;
87435
87805
  const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
87436
87806
  return bytes.slice(id3Size + 10);
87437
- }, VERSION3 = "6.0.175", download = async ({
87807
+ }, VERSION3 = "6.0.191", download = async ({
87438
87808
  url: url2,
87439
87809
  maxBytes,
87440
87810
  abortSignal
@@ -87942,7 +88312,7 @@ var import_api2, import_api3, __defProp4, __export4 = (target, all) => {
87942
88312
  }
87943
88313
  return this._output;
87944
88314
  }
87945
- }, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, DefaultStreamTextResult = class {
88315
+ }, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, toolMetadataSchema, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, DefaultStreamTextResult = class {
87946
88316
  constructor({
87947
88317
  model,
87948
88318
  telemetry,
@@ -89190,6 +89560,7 @@ var import_api2, import_api3, __defProp4, __export4 = (target, all) => {
89190
89560
  toolName: part.toolName,
89191
89561
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
89192
89562
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
89563
+ ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
89193
89564
  ...dynamic != null ? { dynamic } : {},
89194
89565
  ...part.title != null ? { title: part.title } : {}
89195
89566
  });
@@ -89213,6 +89584,7 @@ var import_api2, import_api3, __defProp4, __export4 = (target, all) => {
89213
89584
  input: part.input,
89214
89585
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
89215
89586
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
89587
+ ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
89216
89588
  ...dynamic != null ? { dynamic } : {},
89217
89589
  errorText: onError(part.error),
89218
89590
  ...part.title != null ? { title: part.title } : {}
@@ -89225,6 +89597,7 @@ var import_api2, import_api3, __defProp4, __export4 = (target, all) => {
89225
89597
  input: part.input,
89226
89598
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
89227
89599
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
89600
+ ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
89228
89601
  ...dynamic != null ? { dynamic } : {},
89229
89602
  ...part.title != null ? { title: part.title } : {}
89230
89603
  });
@@ -89247,6 +89620,7 @@ var import_api2, import_api3, __defProp4, __export4 = (target, all) => {
89247
89620
  output: part.output,
89248
89621
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
89249
89622
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
89623
+ ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
89250
89624
  ...part.preliminary != null ? { preliminary: part.preliminary } : {},
89251
89625
  ...dynamic != null ? { dynamic } : {}
89252
89626
  });
@@ -89260,6 +89634,7 @@ var import_api2, import_api3, __defProp4, __export4 = (target, all) => {
89260
89634
  errorText: part.providerExecuted ? typeof part.error === "string" ? part.error : JSON.stringify(part.error) : onError(part.error),
89261
89635
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
89262
89636
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
89637
+ ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
89263
89638
  ...dynamic != null ? { dynamic } : {}
89264
89639
  });
89265
89640
  break;
@@ -89433,10 +89808,21 @@ var import_api2, import_api3, __defProp4, __export4 = (target, all) => {
89433
89808
  ...options
89434
89809
  };
89435
89810
  const preparedCallArgs = (_d2 = await ((_c2 = (_b16 = this.settings).prepareCall) == null ? undefined : _c2.call(_b16, baseCallArgs))) != null ? _d2 : baseCallArgs;
89436
- const { instructions, messages, prompt, ...callArgs } = preparedCallArgs;
89811
+ const {
89812
+ instructions,
89813
+ allowSystemInMessages,
89814
+ messages,
89815
+ prompt,
89816
+ ...callArgs
89817
+ } = preparedCallArgs;
89437
89818
  return {
89438
89819
  ...callArgs,
89439
- ...{ system: instructions, messages, prompt }
89820
+ ...{
89821
+ system: instructions,
89822
+ allowSystemInMessages,
89823
+ messages,
89824
+ prompt
89825
+ }
89440
89826
  };
89441
89827
  }
89442
89828
  mergeOnStepFinishCallbacks(methodCallback) {
@@ -89477,7 +89863,7 @@ var import_api2, import_api3, __defProp4, __export4 = (target, all) => {
89477
89863
  onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
89478
89864
  });
89479
89865
  }
89480
- }, uiMessagesSchema, DefaultEmbedResult = class {
89866
+ }, toolMetadataSchema2, uiMessagesSchema, DefaultEmbedResult = class {
89481
89867
  constructor(options) {
89482
89868
  this.value = options.value;
89483
89869
  this.embedding = options.embedding;
@@ -90985,6 +91371,7 @@ var init_dist7 = __esm(() => {
90985
91371
  init_dist6();
90986
91372
  init_dist3();
90987
91373
  init_dist3();
91374
+ init_dist6();
90988
91375
  init_dist5();
90989
91376
  init_dist5();
90990
91377
  init_dist5();
@@ -91844,6 +92231,7 @@ var init_dist7 = __esm(() => {
91844
92231
  "x-vercel-ai-ui-message-stream": "v1",
91845
92232
  "x-accel-buffering": "no"
91846
92233
  };
92234
+ toolMetadataSchema = exports_external2.record(exports_external2.string(), jsonValueSchema.optional());
91847
92235
  uiMessageChunkSchema = lazySchema(() => zodSchema(exports_external2.union([
91848
92236
  exports_external2.strictObject({
91849
92237
  type: exports_external2.literal("text-start"),
@@ -91871,6 +92259,7 @@ var init_dist7 = __esm(() => {
91871
92259
  toolName: exports_external2.string(),
91872
92260
  providerExecuted: exports_external2.boolean().optional(),
91873
92261
  providerMetadata: providerMetadataSchema.optional(),
92262
+ toolMetadata: toolMetadataSchema.optional(),
91874
92263
  dynamic: exports_external2.boolean().optional(),
91875
92264
  title: exports_external2.string().optional()
91876
92265
  }),
@@ -91886,6 +92275,7 @@ var init_dist7 = __esm(() => {
91886
92275
  input: exports_external2.unknown(),
91887
92276
  providerExecuted: exports_external2.boolean().optional(),
91888
92277
  providerMetadata: providerMetadataSchema.optional(),
92278
+ toolMetadata: toolMetadataSchema.optional(),
91889
92279
  dynamic: exports_external2.boolean().optional(),
91890
92280
  title: exports_external2.string().optional()
91891
92281
  }),
@@ -91896,6 +92286,7 @@ var init_dist7 = __esm(() => {
91896
92286
  input: exports_external2.unknown(),
91897
92287
  providerExecuted: exports_external2.boolean().optional(),
91898
92288
  providerMetadata: providerMetadataSchema.optional(),
92289
+ toolMetadata: toolMetadataSchema.optional(),
91899
92290
  dynamic: exports_external2.boolean().optional(),
91900
92291
  errorText: exports_external2.string(),
91901
92292
  title: exports_external2.string().optional()
@@ -91911,6 +92302,7 @@ var init_dist7 = __esm(() => {
91911
92302
  output: exports_external2.unknown(),
91912
92303
  providerExecuted: exports_external2.boolean().optional(),
91913
92304
  providerMetadata: providerMetadataSchema.optional(),
92305
+ toolMetadata: toolMetadataSchema.optional(),
91914
92306
  dynamic: exports_external2.boolean().optional(),
91915
92307
  preliminary: exports_external2.boolean().optional()
91916
92308
  }),
@@ -91920,6 +92312,7 @@ var init_dist7 = __esm(() => {
91920
92312
  errorText: exports_external2.string(),
91921
92313
  providerExecuted: exports_external2.boolean().optional(),
91922
92314
  providerMetadata: providerMetadataSchema.optional(),
92315
+ toolMetadata: toolMetadataSchema.optional(),
91923
92316
  dynamic: exports_external2.boolean().optional()
91924
92317
  }),
91925
92318
  exports_external2.strictObject({
@@ -92007,6 +92400,7 @@ var init_dist7 = __esm(() => {
92007
92400
  prefix: "aitxt",
92008
92401
  size: 24
92009
92402
  });
92403
+ toolMetadataSchema2 = exports_external2.record(exports_external2.string(), jsonValueSchema.optional());
92010
92404
  uiMessagesSchema = lazySchema(() => zodSchema(exports_external2.array(exports_external2.object({
92011
92405
  id: exports_external2.string(),
92012
92406
  role: exports_external2.enum(["system", "user", "assistant"]),
@@ -92058,6 +92452,7 @@ var init_dist7 = __esm(() => {
92058
92452
  type: exports_external2.literal("dynamic-tool"),
92059
92453
  toolName: exports_external2.string(),
92060
92454
  toolCallId: exports_external2.string(),
92455
+ toolMetadata: toolMetadataSchema2.optional(),
92061
92456
  state: exports_external2.literal("input-streaming"),
92062
92457
  input: exports_external2.unknown().optional(),
92063
92458
  providerExecuted: exports_external2.boolean().optional(),
@@ -92070,6 +92465,7 @@ var init_dist7 = __esm(() => {
92070
92465
  type: exports_external2.literal("dynamic-tool"),
92071
92466
  toolName: exports_external2.string(),
92072
92467
  toolCallId: exports_external2.string(),
92468
+ toolMetadata: toolMetadataSchema2.optional(),
92073
92469
  state: exports_external2.literal("input-available"),
92074
92470
  input: exports_external2.unknown(),
92075
92471
  providerExecuted: exports_external2.boolean().optional(),
@@ -92082,6 +92478,7 @@ var init_dist7 = __esm(() => {
92082
92478
  type: exports_external2.literal("dynamic-tool"),
92083
92479
  toolName: exports_external2.string(),
92084
92480
  toolCallId: exports_external2.string(),
92481
+ toolMetadata: toolMetadataSchema2.optional(),
92085
92482
  state: exports_external2.literal("approval-requested"),
92086
92483
  input: exports_external2.unknown(),
92087
92484
  providerExecuted: exports_external2.boolean().optional(),
@@ -92098,6 +92495,7 @@ var init_dist7 = __esm(() => {
92098
92495
  type: exports_external2.literal("dynamic-tool"),
92099
92496
  toolName: exports_external2.string(),
92100
92497
  toolCallId: exports_external2.string(),
92498
+ toolMetadata: toolMetadataSchema2.optional(),
92101
92499
  state: exports_external2.literal("approval-responded"),
92102
92500
  input: exports_external2.unknown(),
92103
92501
  providerExecuted: exports_external2.boolean().optional(),
@@ -92114,6 +92512,7 @@ var init_dist7 = __esm(() => {
92114
92512
  type: exports_external2.literal("dynamic-tool"),
92115
92513
  toolName: exports_external2.string(),
92116
92514
  toolCallId: exports_external2.string(),
92515
+ toolMetadata: toolMetadataSchema2.optional(),
92117
92516
  state: exports_external2.literal("output-available"),
92118
92517
  input: exports_external2.unknown(),
92119
92518
  providerExecuted: exports_external2.boolean().optional(),
@@ -92132,8 +92531,9 @@ var init_dist7 = __esm(() => {
92132
92531
  type: exports_external2.literal("dynamic-tool"),
92133
92532
  toolName: exports_external2.string(),
92134
92533
  toolCallId: exports_external2.string(),
92534
+ toolMetadata: toolMetadataSchema2.optional(),
92135
92535
  state: exports_external2.literal("output-error"),
92136
- input: exports_external2.unknown(),
92536
+ input: exports_external2.unknown().optional(),
92137
92537
  rawInput: exports_external2.unknown().optional(),
92138
92538
  providerExecuted: exports_external2.boolean().optional(),
92139
92539
  output: exports_external2.never().optional(),
@@ -92150,6 +92550,7 @@ var init_dist7 = __esm(() => {
92150
92550
  type: exports_external2.literal("dynamic-tool"),
92151
92551
  toolName: exports_external2.string(),
92152
92552
  toolCallId: exports_external2.string(),
92553
+ toolMetadata: toolMetadataSchema2.optional(),
92153
92554
  state: exports_external2.literal("output-denied"),
92154
92555
  input: exports_external2.unknown(),
92155
92556
  providerExecuted: exports_external2.boolean().optional(),
@@ -92165,6 +92566,7 @@ var init_dist7 = __esm(() => {
92165
92566
  exports_external2.object({
92166
92567
  type: exports_external2.string().startsWith("tool-"),
92167
92568
  toolCallId: exports_external2.string(),
92569
+ toolMetadata: toolMetadataSchema2.optional(),
92168
92570
  state: exports_external2.literal("input-streaming"),
92169
92571
  providerExecuted: exports_external2.boolean().optional(),
92170
92572
  callProviderMetadata: providerMetadataSchema.optional(),
@@ -92176,6 +92578,7 @@ var init_dist7 = __esm(() => {
92176
92578
  exports_external2.object({
92177
92579
  type: exports_external2.string().startsWith("tool-"),
92178
92580
  toolCallId: exports_external2.string(),
92581
+ toolMetadata: toolMetadataSchema2.optional(),
92179
92582
  state: exports_external2.literal("input-available"),
92180
92583
  providerExecuted: exports_external2.boolean().optional(),
92181
92584
  input: exports_external2.unknown(),
@@ -92187,6 +92590,7 @@ var init_dist7 = __esm(() => {
92187
92590
  exports_external2.object({
92188
92591
  type: exports_external2.string().startsWith("tool-"),
92189
92592
  toolCallId: exports_external2.string(),
92593
+ toolMetadata: toolMetadataSchema2.optional(),
92190
92594
  state: exports_external2.literal("approval-requested"),
92191
92595
  input: exports_external2.unknown(),
92192
92596
  providerExecuted: exports_external2.boolean().optional(),
@@ -92202,6 +92606,7 @@ var init_dist7 = __esm(() => {
92202
92606
  exports_external2.object({
92203
92607
  type: exports_external2.string().startsWith("tool-"),
92204
92608
  toolCallId: exports_external2.string(),
92609
+ toolMetadata: toolMetadataSchema2.optional(),
92205
92610
  state: exports_external2.literal("approval-responded"),
92206
92611
  input: exports_external2.unknown(),
92207
92612
  providerExecuted: exports_external2.boolean().optional(),
@@ -92217,6 +92622,7 @@ var init_dist7 = __esm(() => {
92217
92622
  exports_external2.object({
92218
92623
  type: exports_external2.string().startsWith("tool-"),
92219
92624
  toolCallId: exports_external2.string(),
92625
+ toolMetadata: toolMetadataSchema2.optional(),
92220
92626
  state: exports_external2.literal("output-available"),
92221
92627
  providerExecuted: exports_external2.boolean().optional(),
92222
92628
  input: exports_external2.unknown(),
@@ -92234,9 +92640,10 @@ var init_dist7 = __esm(() => {
92234
92640
  exports_external2.object({
92235
92641
  type: exports_external2.string().startsWith("tool-"),
92236
92642
  toolCallId: exports_external2.string(),
92643
+ toolMetadata: toolMetadataSchema2.optional(),
92237
92644
  state: exports_external2.literal("output-error"),
92238
92645
  providerExecuted: exports_external2.boolean().optional(),
92239
- input: exports_external2.unknown(),
92646
+ input: exports_external2.unknown().optional(),
92240
92647
  rawInput: exports_external2.unknown().optional(),
92241
92648
  output: exports_external2.never().optional(),
92242
92649
  errorText: exports_external2.string(),
@@ -92251,6 +92658,7 @@ var init_dist7 = __esm(() => {
92251
92658
  exports_external2.object({
92252
92659
  type: exports_external2.string().startsWith("tool-"),
92253
92660
  toolCallId: exports_external2.string(),
92661
+ toolMetadata: toolMetadataSchema2.optional(),
92254
92662
  state: exports_external2.literal("output-denied"),
92255
92663
  providerExecuted: exports_external2.boolean().optional(),
92256
92664
  input: exports_external2.unknown(),