clawfast 1.0.2 → 1.0.3

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.
Files changed (2) hide show
  1. package/dist/clawfast.cjs +436 -222
  2. package/package.json +1 -1
package/dist/clawfast.cjs CHANGED
@@ -85,8 +85,8 @@ var init_boot_ui = __esm({
85
85
  var require_main = __commonJS({
86
86
  "../node_modules/.pnpm/dotenv@17.4.2/node_modules/dotenv/lib/main.js"(exports2, module2) {
87
87
  "use strict";
88
- var fs4 = require("fs");
89
- var path6 = require("path");
88
+ var fs6 = require("fs");
89
+ var path8 = require("path");
90
90
  var os5 = require("os");
91
91
  var crypto2 = require("crypto");
92
92
  var TIPS = [
@@ -217,7 +217,7 @@ var require_main = __commonJS({
217
217
  if (options && options.path && options.path.length > 0) {
218
218
  if (Array.isArray(options.path)) {
219
219
  for (const filepath of options.path) {
220
- if (fs4.existsSync(filepath)) {
220
+ if (fs6.existsSync(filepath)) {
221
221
  possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
222
222
  }
223
223
  }
@@ -225,15 +225,15 @@ var require_main = __commonJS({
225
225
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
226
226
  }
227
227
  } else {
228
- possibleVaultPath = path6.resolve(process.cwd(), ".env.vault");
228
+ possibleVaultPath = path8.resolve(process.cwd(), ".env.vault");
229
229
  }
230
- if (fs4.existsSync(possibleVaultPath)) {
230
+ if (fs6.existsSync(possibleVaultPath)) {
231
231
  return possibleVaultPath;
232
232
  }
233
233
  return null;
234
234
  }
235
235
  function _resolveHome(envPath) {
236
- return envPath[0] === "~" ? path6.join(os5.homedir(), envPath.slice(1)) : envPath;
236
+ return envPath[0] === "~" ? path8.join(os5.homedir(), envPath.slice(1)) : envPath;
237
237
  }
238
238
  function _configVault(options) {
239
239
  const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
@@ -250,7 +250,7 @@ var require_main = __commonJS({
250
250
  return { parsed };
251
251
  }
252
252
  function configDotenv(options) {
253
- const dotenvPath = path6.resolve(process.cwd(), ".env");
253
+ const dotenvPath = path8.resolve(process.cwd(), ".env");
254
254
  let encoding = "utf8";
255
255
  let processEnv = process.env;
256
256
  if (options && options.processEnv != null) {
@@ -278,13 +278,13 @@ var require_main = __commonJS({
278
278
  }
279
279
  let lastError;
280
280
  const parsedAll = {};
281
- for (const path7 of optionPaths) {
281
+ for (const path9 of optionPaths) {
282
282
  try {
283
- const parsed = DotenvModule.parse(fs4.readFileSync(path7, { encoding }));
283
+ const parsed = DotenvModule.parse(fs6.readFileSync(path9, { encoding }));
284
284
  DotenvModule.populate(parsedAll, parsed, options);
285
285
  } catch (e) {
286
286
  if (debug) {
287
- _debug(`failed to load ${path7} ${e.message}`);
287
+ _debug(`failed to load ${path9} ${e.message}`);
288
288
  }
289
289
  lastError = e;
290
290
  }
@@ -297,7 +297,7 @@ var require_main = __commonJS({
297
297
  const shortPaths = [];
298
298
  for (const filePath of optionPaths) {
299
299
  try {
300
- const relative2 = path6.relative(process.cwd(), filePath);
300
+ const relative2 = path8.relative(process.cwd(), filePath);
301
301
  shortPaths.push(relative2);
302
302
  } catch (e) {
303
303
  if (debug) {
@@ -497,6 +497,101 @@ var init_config = __esm({
497
497
  }
498
498
  });
499
499
 
500
+ // src/version.ts
501
+ var clawfastVersion, isDevVersion, isNewerVersion;
502
+ var init_version = __esm({
503
+ "src/version.ts"() {
504
+ "use strict";
505
+ clawfastVersion = () => true ? "1.0.3" : "0.0.0-dev";
506
+ isDevVersion = () => clawfastVersion().includes("-dev");
507
+ isNewerVersion = (a, b) => {
508
+ const parse3 = (v) => v.split("-")[0].split(".").map((n) => Number.parseInt(n, 10) || 0);
509
+ const pa = parse3(a);
510
+ const pb = parse3(b);
511
+ const len = Math.max(pa.length, pb.length);
512
+ for (let i = 0; i < len; i++) {
513
+ const da = pa[i] ?? 0;
514
+ const db = pb[i] ?? 0;
515
+ if (da > db) return true;
516
+ if (da < db) return false;
517
+ }
518
+ return false;
519
+ };
520
+ }
521
+ });
522
+
523
+ // src/update.ts
524
+ var import_node_fs2, import_node_path2, import_node_child_process, CHECK_INTERVAL_MS, REGISTRY_URL, cacheFile, readCache, writeCache, getUpdateNotice, refreshUpdateCacheInBackground, runSelfUpdate;
525
+ var init_update = __esm({
526
+ "src/update.ts"() {
527
+ "use strict";
528
+ import_node_fs2 = __toESM(require("node:fs"));
529
+ import_node_path2 = __toESM(require("node:path"));
530
+ import_node_child_process = require("node:child_process");
531
+ init_config();
532
+ init_version();
533
+ CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
534
+ REGISTRY_URL = "https://registry.npmjs.org/clawfast/latest";
535
+ cacheFile = () => import_node_path2.default.join(clawfastHome(), "update-check.json");
536
+ readCache = () => {
537
+ try {
538
+ const raw = import_node_fs2.default.readFileSync(cacheFile(), "utf8");
539
+ const parsed = JSON.parse(raw);
540
+ if (typeof parsed?.latest === "string" && typeof parsed?.lastCheck === "number") {
541
+ return parsed;
542
+ }
543
+ } catch {
544
+ }
545
+ return null;
546
+ };
547
+ writeCache = (cache) => {
548
+ try {
549
+ import_node_fs2.default.mkdirSync(clawfastHome(), { recursive: true });
550
+ import_node_fs2.default.writeFileSync(cacheFile(), JSON.stringify(cache), "utf8");
551
+ } catch {
552
+ }
553
+ };
554
+ getUpdateNotice = (current) => {
555
+ if (isDevVersion()) return null;
556
+ const cache = readCache();
557
+ if (cache && isNewerVersion(cache.latest, current)) {
558
+ return `nova versao ${cache.latest} disponivel (voce tem ${current}) \u2014 rode: clawfast update`;
559
+ }
560
+ return null;
561
+ };
562
+ refreshUpdateCacheInBackground = (current) => {
563
+ if (isDevVersion()) return;
564
+ const cache = readCache();
565
+ if (cache && Date.now() - cache.lastCheck < CHECK_INTERVAL_MS) return;
566
+ void (async () => {
567
+ try {
568
+ const controller = new AbortController();
569
+ const timer2 = setTimeout(() => controller.abort(), 3e3);
570
+ const res = await fetch(REGISTRY_URL, {
571
+ signal: controller.signal,
572
+ headers: { accept: "application/json" }
573
+ });
574
+ clearTimeout(timer2);
575
+ if (!res.ok) return;
576
+ const body = await res.json();
577
+ if (typeof body.version === "string") {
578
+ writeCache({ lastCheck: Date.now(), latest: body.version });
579
+ }
580
+ } catch {
581
+ }
582
+ })();
583
+ };
584
+ runSelfUpdate = () => new Promise((resolve2) => {
585
+ const child = (0, import_node_child_process.spawn)("npm install -g clawfast@latest", {
586
+ stdio: "inherit",
587
+ shell: true
588
+ });
589
+ child.on("close", (code) => resolve2(code ?? 1));
590
+ child.on("error", () => resolve2(1));
591
+ });
592
+ }
593
+ });
594
+
500
595
  // src/paste-input.ts
501
596
  function createPasteInput(opts = {}) {
502
597
  const input = new import_node_stream.PassThrough();
@@ -634,16 +729,16 @@ function listSkills() {
634
729
  const dir = skillsDir();
635
730
  let entries = [];
636
731
  try {
637
- entries = import_node_fs2.default.readdirSync(dir).filter((f) => f.endsWith(".md"));
732
+ entries = import_node_fs3.default.readdirSync(dir).filter((f) => f.endsWith(".md"));
638
733
  } catch {
639
734
  return [];
640
735
  }
641
736
  const skills = [];
642
737
  for (const entry of entries.sort()) {
643
- const file2 = import_node_path2.default.join(dir, entry);
738
+ const file2 = import_node_path3.default.join(dir, entry);
644
739
  let raw = "";
645
740
  try {
646
- raw = import_node_fs2.default.readFileSync(file2, "utf8");
741
+ raw = import_node_fs3.default.readFileSync(file2, "utf8");
647
742
  } catch {
648
743
  continue;
649
744
  }
@@ -668,9 +763,9 @@ function saveSkill(input) {
668
763
  throw new Error("nome de skill invalido (vazio apos normalizacao)");
669
764
  }
670
765
  const dir = skillsDir();
671
- import_node_fs2.default.mkdirSync(dir, { recursive: true });
672
- const file2 = import_node_path2.default.join(dir, `${slug}.md`);
673
- const overwritten = import_node_fs2.default.existsSync(file2);
766
+ import_node_fs3.default.mkdirSync(dir, { recursive: true });
767
+ const file2 = import_node_path3.default.join(dir, `${slug}.md`);
768
+ const overwritten = import_node_fs3.default.existsSync(file2);
674
769
  const triggers = (input.triggers ?? []).map((t) => t.trim().toLowerCase()).filter(Boolean);
675
770
  const frontmatter = [
676
771
  "---",
@@ -681,7 +776,7 @@ function saveSkill(input) {
681
776
  "---",
682
777
  ""
683
778
  ].join("\n");
684
- import_node_fs2.default.writeFileSync(file2, frontmatter + input.body.trim() + "\n", {
779
+ import_node_fs3.default.writeFileSync(file2, frontmatter + input.body.trim() + "\n", {
685
780
  encoding: "utf8"
686
781
  });
687
782
  return {
@@ -699,9 +794,9 @@ function saveSkill(input) {
699
794
  }
700
795
  function deleteSkill(name25) {
701
796
  const slug = slugify(name25);
702
- const file2 = import_node_path2.default.join(skillsDir(), `${slug}.md`);
797
+ const file2 = import_node_path3.default.join(skillsDir(), `${slug}.md`);
703
798
  try {
704
- import_node_fs2.default.unlinkSync(file2);
799
+ import_node_fs3.default.unlinkSync(file2);
705
800
  return true;
706
801
  } catch {
707
802
  return false;
@@ -745,14 +840,14 @@ As skills a seguir foram carregadas porque o pedido atual casou com elas (ou est
745
840
  ${blocks}
746
841
  </active_skills>`;
747
842
  }
748
- var import_node_fs2, import_node_path2, skillsDir, slugify, FRONTMATTER_RE, parseFrontmatter, parseTriggers, isTrue, escapeFrontmatterValue;
843
+ var import_node_fs3, import_node_path3, skillsDir, slugify, FRONTMATTER_RE, parseFrontmatter, parseTriggers, isTrue, escapeFrontmatterValue;
749
844
  var init_skills = __esm({
750
845
  "src/skills.ts"() {
751
846
  "use strict";
752
- import_node_fs2 = __toESM(require("node:fs"));
753
- import_node_path2 = __toESM(require("node:path"));
847
+ import_node_fs3 = __toESM(require("node:fs"));
848
+ import_node_path3 = __toESM(require("node:path"));
754
849
  init_config();
755
- skillsDir = () => import_node_path2.default.join(clawfastHome(), "skills");
850
+ skillsDir = () => import_node_path3.default.join(clawfastHome(), "skills");
756
851
  slugify = (name25) => name25.trim().toLowerCase().normalize("NFD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64);
757
852
  FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
758
853
  parseFrontmatter = (raw) => {
@@ -774,6 +869,70 @@ var init_skills = __esm({
774
869
  }
775
870
  });
776
871
 
872
+ // src/news.ts
873
+ var import_node_fs4, import_node_path4, NEWS, latestNewsVersion, renderNews, stateFile, readState, writeState, consumePostUpdateLaunch;
874
+ var init_news = __esm({
875
+ "src/news.ts"() {
876
+ "use strict";
877
+ import_node_fs4 = __toESM(require("node:fs"));
878
+ import_node_path4 = __toESM(require("node:path"));
879
+ init_config();
880
+ NEWS = {
881
+ "1.0.3": [
882
+ "Atualizacao: `clawfast update` atualiza o CLI e mostra as boas-vindas; aparece um aviso quando ha versao nova; /nov lista as novidades.",
883
+ "Skills: /skillcreator cria ou cola uma skill (de qualquer tamanho), /skills lista e /skill delete remove. As skills viram conhecimento disponivel para TODOS os modelos.",
884
+ "Modelos na NVIDIA build: minimax-m3, kimi-k2.6, glm-5.1 e qwen3.5-397b \u2014 todos com function calling de verdade (as ferramentas disparam).",
885
+ "Resiliencia a rate limit (429): cai para os outros modelos como contingencia e espera/retenta a cadeia automaticamente."
886
+ ]
887
+ };
888
+ latestNewsVersion = () => {
889
+ const keys = Object.keys(NEWS);
890
+ if (keys.length === 0) return null;
891
+ return keys.sort((a, b) => {
892
+ const pa = a.split(".").map(Number);
893
+ const pb = b.split(".").map(Number);
894
+ for (let i = 0; i < 3; i++) {
895
+ if ((pb[i] ?? 0) !== (pa[i] ?? 0)) return (pb[i] ?? 0) - (pa[i] ?? 0);
896
+ }
897
+ return 0;
898
+ })[0];
899
+ };
900
+ renderNews = (version3) => {
901
+ const key = NEWS[version3] ? version3 : latestNewsVersion();
902
+ if (!key || !NEWS[key]) {
903
+ return "Sem novidades registradas para esta versao.";
904
+ }
905
+ const lines = NEWS[key].map((item) => ` \u2022 ${item}`).join("\n");
906
+ return `Novidades da versao ${key}:
907
+ ${lines}`;
908
+ };
909
+ stateFile = () => import_node_path4.default.join(clawfastHome(), "state.json");
910
+ readState = () => {
911
+ try {
912
+ return JSON.parse(import_node_fs4.default.readFileSync(stateFile(), "utf8"));
913
+ } catch {
914
+ return {};
915
+ }
916
+ };
917
+ writeState = (state) => {
918
+ try {
919
+ import_node_fs4.default.mkdirSync(clawfastHome(), { recursive: true });
920
+ import_node_fs4.default.writeFileSync(stateFile(), JSON.stringify(state), "utf8");
921
+ } catch {
922
+ }
923
+ };
924
+ consumePostUpdateLaunch = (current) => {
925
+ const state = readState();
926
+ const previous = state.lastVersion;
927
+ if (previous !== current) {
928
+ writeState({ ...state, lastVersion: current });
929
+ return Boolean(previous);
930
+ }
931
+ return false;
932
+ };
933
+ }
934
+ });
935
+
777
936
  // ../node_modules/.pnpm/@ai-sdk+provider@3.0.10/node_modules/@ai-sdk/provider/dist/index.mjs
778
937
  function getErrorMessage(error51) {
779
938
  if (error51 == null) {
@@ -1346,10 +1505,10 @@ function mergeDefs(...defs) {
1346
1505
  function cloneDef(schema) {
1347
1506
  return mergeDefs(schema._zod.def);
1348
1507
  }
1349
- function getElementAtPath(obj, path6) {
1350
- if (!path6)
1508
+ function getElementAtPath(obj, path8) {
1509
+ if (!path8)
1351
1510
  return obj;
1352
- return path6.reduce((acc, key) => acc?.[key], obj);
1511
+ return path8.reduce((acc, key) => acc?.[key], obj);
1353
1512
  }
1354
1513
  function promiseAllObject(promisesObj) {
1355
1514
  const keys = Object.keys(promisesObj);
@@ -1677,11 +1836,11 @@ function explicitlyAborted(x, startIndex = 0) {
1677
1836
  }
1678
1837
  return false;
1679
1838
  }
1680
- function prefixIssues(path6, issues) {
1839
+ function prefixIssues(path8, issues) {
1681
1840
  return issues.map((iss) => {
1682
1841
  var _a25;
1683
1842
  (_a25 = iss).path ?? (_a25.path = []);
1684
- iss.path.unshift(path6);
1843
+ iss.path.unshift(path8);
1685
1844
  return iss;
1686
1845
  });
1687
1846
  }
@@ -1899,16 +2058,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1899
2058
  }
1900
2059
  function formatError(error51, mapper = (issue2) => issue2.message) {
1901
2060
  const fieldErrors = { _errors: [] };
1902
- const processError = (error52, path6 = []) => {
2061
+ const processError = (error52, path8 = []) => {
1903
2062
  for (const issue2 of error52.issues) {
1904
2063
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1905
- issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
2064
+ issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
1906
2065
  } else if (issue2.code === "invalid_key") {
1907
- processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
2066
+ processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1908
2067
  } else if (issue2.code === "invalid_element") {
1909
- processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
2068
+ processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1910
2069
  } else {
1911
- const fullpath = [...path6, ...issue2.path];
2070
+ const fullpath = [...path8, ...issue2.path];
1912
2071
  if (fullpath.length === 0) {
1913
2072
  fieldErrors._errors.push(mapper(issue2));
1914
2073
  } else {
@@ -1935,17 +2094,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1935
2094
  }
1936
2095
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1937
2096
  const result = { errors: [] };
1938
- const processError = (error52, path6 = []) => {
2097
+ const processError = (error52, path8 = []) => {
1939
2098
  var _a25, _b18;
1940
2099
  for (const issue2 of error52.issues) {
1941
2100
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1942
- issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
2101
+ issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
1943
2102
  } else if (issue2.code === "invalid_key") {
1944
- processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
2103
+ processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1945
2104
  } else if (issue2.code === "invalid_element") {
1946
- processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
2105
+ processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1947
2106
  } else {
1948
- const fullpath = [...path6, ...issue2.path];
2107
+ const fullpath = [...path8, ...issue2.path];
1949
2108
  if (fullpath.length === 0) {
1950
2109
  result.errors.push(mapper(issue2));
1951
2110
  continue;
@@ -1977,8 +2136,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1977
2136
  }
1978
2137
  function toDotPath(_path) {
1979
2138
  const segs = [];
1980
- const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1981
- for (const seg of path6) {
2139
+ const path8 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2140
+ for (const seg of path8) {
1982
2141
  if (typeof seg === "number")
1983
2142
  segs.push(`[${seg}]`);
1984
2143
  else if (typeof seg === "symbol")
@@ -15481,13 +15640,13 @@ function resolveRef(ref, ctx) {
15481
15640
  if (!ref.startsWith("#")) {
15482
15641
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
15483
15642
  }
15484
- const path6 = ref.slice(1).split("/").filter(Boolean);
15485
- if (path6.length === 0) {
15643
+ const path8 = ref.slice(1).split("/").filter(Boolean);
15644
+ if (path8.length === 0) {
15486
15645
  return ctx.rootSchema;
15487
15646
  }
15488
15647
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
15489
- if (path6[0] === defsKey) {
15490
- const key = path6[1];
15648
+ if (path8[0] === defsKey) {
15649
+ const key = path8[1];
15491
15650
  if (!key || !ctx.defs[key]) {
15492
15651
  throw new Error(`Reference not found: ${ref}`);
15493
15652
  }
@@ -16676,8 +16835,8 @@ var init_parseUtil = __esm({
16676
16835
  init_errors3();
16677
16836
  init_en2();
16678
16837
  makeIssue = (params) => {
16679
- const { data, path: path6, errorMaps, issueData } = params;
16680
- const fullPath = [...path6, ...issueData.path || []];
16838
+ const { data, path: path8, errorMaps, issueData } = params;
16839
+ const fullPath = [...path8, ...issueData.path || []];
16681
16840
  const fullIssue = {
16682
16841
  ...issueData,
16683
16842
  path: fullPath
@@ -16960,11 +17119,11 @@ var init_types = __esm({
16960
17119
  init_parseUtil();
16961
17120
  init_util2();
16962
17121
  ParseInputLazyPath = class {
16963
- constructor(parent, value, path6, key) {
17122
+ constructor(parent, value, path8, key) {
16964
17123
  this._cachedPath = [];
16965
17124
  this.parent = parent;
16966
17125
  this.data = value;
16967
- this._path = path6;
17126
+ this._path = path8;
16968
17127
  this._key = key;
16969
17128
  }
16970
17129
  get path() {
@@ -23003,8 +23162,8 @@ var require_auth_config = __commonJS({
23003
23162
  writeAuthConfig: () => writeAuthConfig
23004
23163
  });
23005
23164
  module2.exports = __toCommonJS(auth_config_exports);
23006
- var fs4 = __toESM2(require("fs"));
23007
- var path6 = __toESM2(require("path"));
23165
+ var fs6 = __toESM2(require("fs"));
23166
+ var path8 = __toESM2(require("path"));
23008
23167
  var import_token_util = require_token_util();
23009
23168
  function getAuthConfigPath() {
23010
23169
  const dataDir = (0, import_token_util.getVercelDataDir)();
@@ -23013,15 +23172,15 @@ var require_auth_config = __commonJS({
23013
23172
  `Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`
23014
23173
  );
23015
23174
  }
23016
- return path6.join(dataDir, "auth.json");
23175
+ return path8.join(dataDir, "auth.json");
23017
23176
  }
23018
23177
  function readAuthConfig() {
23019
23178
  try {
23020
23179
  const authPath = getAuthConfigPath();
23021
- if (!fs4.existsSync(authPath)) {
23180
+ if (!fs6.existsSync(authPath)) {
23022
23181
  return null;
23023
23182
  }
23024
- const content = fs4.readFileSync(authPath, "utf8");
23183
+ const content = fs6.readFileSync(authPath, "utf8");
23025
23184
  if (!content) {
23026
23185
  return null;
23027
23186
  }
@@ -23032,11 +23191,11 @@ var require_auth_config = __commonJS({
23032
23191
  }
23033
23192
  function writeAuthConfig(config3) {
23034
23193
  const authPath = getAuthConfigPath();
23035
- const authDir = path6.dirname(authPath);
23036
- if (!fs4.existsSync(authDir)) {
23037
- fs4.mkdirSync(authDir, { mode: 504, recursive: true });
23194
+ const authDir = path8.dirname(authPath);
23195
+ if (!fs6.existsSync(authDir)) {
23196
+ fs6.mkdirSync(authDir, { mode: 504, recursive: true });
23038
23197
  }
23039
- fs4.writeFileSync(authPath, JSON.stringify(config3, null, 2), { mode: 384 });
23198
+ fs6.writeFileSync(authPath, JSON.stringify(config3, null, 2), { mode: 384 });
23040
23199
  }
23041
23200
  function isValidAccessToken(authConfig, expirationBufferMs = 0) {
23042
23201
  if (!authConfig.token)
@@ -23227,8 +23386,8 @@ var require_token_util = __commonJS({
23227
23386
  saveToken: () => saveToken
23228
23387
  });
23229
23388
  module2.exports = __toCommonJS(token_util_exports);
23230
- var path6 = __toESM2(require("path"));
23231
- var fs4 = __toESM2(require("fs"));
23389
+ var path8 = __toESM2(require("path"));
23390
+ var fs6 = __toESM2(require("fs"));
23232
23391
  var import_token_error = require_token_error();
23233
23392
  var import_token_io = require_token_io();
23234
23393
  var import_auth_config = require_auth_config();
@@ -23240,7 +23399,7 @@ var require_token_util = __commonJS({
23240
23399
  if (!dataDir) {
23241
23400
  return null;
23242
23401
  }
23243
- return path6.join(dataDir, vercelFolder);
23402
+ return path8.join(dataDir, vercelFolder);
23244
23403
  }
23245
23404
  async function getVercelToken2(options) {
23246
23405
  const authConfig = (0, import_auth_config.readAuthConfig)();
@@ -23316,13 +23475,13 @@ var require_token_util = __commonJS({
23316
23475
  "Unable to find project root directory. Have you linked your project with `vc link?`"
23317
23476
  );
23318
23477
  }
23319
- const prjPath = path6.join(dir, ".vercel", "project.json");
23320
- if (!fs4.existsSync(prjPath)) {
23478
+ const prjPath = path8.join(dir, ".vercel", "project.json");
23479
+ if (!fs6.existsSync(prjPath)) {
23321
23480
  throw new import_token_error.VercelOidcTokenError(
23322
23481
  "project.json not found, have you linked your project with `vc link?`"
23323
23482
  );
23324
23483
  }
23325
- const prj = JSON.parse(fs4.readFileSync(prjPath, "utf8"));
23484
+ const prj = JSON.parse(fs6.readFileSync(prjPath, "utf8"));
23326
23485
  if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
23327
23486
  throw new TypeError(
23328
23487
  "Expected a string-valued projectId property. Try running `vc link` to re-link your project."
@@ -23337,11 +23496,11 @@ var require_token_util = __commonJS({
23337
23496
  "Unable to find user data directory. Please reach out to Vercel support."
23338
23497
  );
23339
23498
  }
23340
- const tokenPath = path6.join(dir, "com.vercel.token", `${projectId}.json`);
23499
+ const tokenPath = path8.join(dir, "com.vercel.token", `${projectId}.json`);
23341
23500
  const tokenJson = JSON.stringify(token);
23342
- fs4.mkdirSync(path6.dirname(tokenPath), { mode: 504, recursive: true });
23343
- fs4.writeFileSync(tokenPath, tokenJson);
23344
- fs4.chmodSync(tokenPath, 432);
23501
+ fs6.mkdirSync(path8.dirname(tokenPath), { mode: 504, recursive: true });
23502
+ fs6.writeFileSync(tokenPath, tokenJson);
23503
+ fs6.chmodSync(tokenPath, 432);
23345
23504
  return;
23346
23505
  }
23347
23506
  function loadToken(projectId) {
@@ -23351,11 +23510,11 @@ var require_token_util = __commonJS({
23351
23510
  "Unable to find user data directory. Please reach out to Vercel support."
23352
23511
  );
23353
23512
  }
23354
- const tokenPath = path6.join(dir, "com.vercel.token", `${projectId}.json`);
23355
- if (!fs4.existsSync(tokenPath)) {
23513
+ const tokenPath = path8.join(dir, "com.vercel.token", `${projectId}.json`);
23514
+ if (!fs6.existsSync(tokenPath)) {
23356
23515
  return null;
23357
23516
  }
23358
- const token = JSON.parse(fs4.readFileSync(tokenPath, "utf8"));
23517
+ const token = JSON.parse(fs6.readFileSync(tokenPath, "utf8"));
23359
23518
  assertVercelOidcTokenResponse(token);
23360
23519
  return token;
23361
23520
  }
@@ -25306,7 +25465,7 @@ var init_platform = __esm({
25306
25465
 
25307
25466
  // ../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/version.js
25308
25467
  var VERSION3;
25309
- var init_version = __esm({
25468
+ var init_version2 = __esm({
25310
25469
  "../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/version.js"() {
25311
25470
  "use strict";
25312
25471
  VERSION3 = "1.9.0";
@@ -25381,7 +25540,7 @@ var re, isCompatible;
25381
25540
  var init_semver = __esm({
25382
25541
  "../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/semver.js"() {
25383
25542
  "use strict";
25384
- init_version();
25543
+ init_version2();
25385
25544
  re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
25386
25545
  isCompatible = _makeCompatibilityCheck(VERSION3);
25387
25546
  }
@@ -25430,7 +25589,7 @@ var init_global_utils = __esm({
25430
25589
  "../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js"() {
25431
25590
  "use strict";
25432
25591
  init_platform();
25433
- init_version();
25592
+ init_version2();
25434
25593
  init_semver();
25435
25594
  major = VERSION3.split(".")[0];
25436
25595
  GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
@@ -35381,7 +35540,7 @@ function createOpenRouter(options = {}) {
35381
35540
  );
35382
35541
  const createChatModel = (modelId, settings = {}) => new OpenRouterChatLanguageModel(modelId, settings, {
35383
35542
  provider: "openrouter.chat",
35384
- url: ({ path: path6 }) => `${baseURL}${path6}`,
35543
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
35385
35544
  headers: getHeaders,
35386
35545
  compatibility,
35387
35546
  fetch: options.fetch,
@@ -35389,7 +35548,7 @@ function createOpenRouter(options = {}) {
35389
35548
  });
35390
35549
  const createCompletionModel = (modelId, settings = {}) => new OpenRouterCompletionLanguageModel(modelId, settings, {
35391
35550
  provider: "openrouter.completion",
35392
- url: ({ path: path6 }) => `${baseURL}${path6}`,
35551
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
35393
35552
  headers: getHeaders,
35394
35553
  compatibility,
35395
35554
  fetch: options.fetch,
@@ -35397,21 +35556,21 @@ function createOpenRouter(options = {}) {
35397
35556
  });
35398
35557
  const createEmbeddingModel = (modelId, settings = {}) => new OpenRouterEmbeddingModel(modelId, settings, {
35399
35558
  provider: "openrouter.embedding",
35400
- url: ({ path: path6 }) => `${baseURL}${path6}`,
35559
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
35401
35560
  headers: getHeaders,
35402
35561
  fetch: options.fetch,
35403
35562
  extraBody: options.extraBody
35404
35563
  });
35405
35564
  const createImageModel = (modelId, settings = {}) => new OpenRouterImageModel(modelId, settings, {
35406
35565
  provider: "openrouter.image",
35407
- url: ({ path: path6 }) => `${baseURL}${path6}`,
35566
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
35408
35567
  headers: getHeaders,
35409
35568
  fetch: options.fetch,
35410
35569
  extraBody: options.extraBody
35411
35570
  });
35412
35571
  const createVideoModel = (modelId, settings = {}) => new OpenRouterVideoModel(modelId, settings, {
35413
35572
  provider: "openrouter.video",
35414
- url: ({ path: path6 }) => `${baseURL}${path6}`,
35573
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
35415
35574
  headers: getHeaders,
35416
35575
  fetch: options.fetch,
35417
35576
  extraBody: options.extraBody
@@ -39947,37 +40106,37 @@ function createOpenAI(options = {}) {
39947
40106
  );
39948
40107
  const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
39949
40108
  provider: `${providerName}.chat`,
39950
- url: ({ path: path6 }) => `${baseURL}${path6}`,
40109
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
39951
40110
  headers: getHeaders,
39952
40111
  fetch: options.fetch
39953
40112
  });
39954
40113
  const createCompletionModel = (modelId) => new OpenAICompletionLanguageModel(modelId, {
39955
40114
  provider: `${providerName}.completion`,
39956
- url: ({ path: path6 }) => `${baseURL}${path6}`,
40115
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
39957
40116
  headers: getHeaders,
39958
40117
  fetch: options.fetch
39959
40118
  });
39960
40119
  const createEmbeddingModel = (modelId) => new OpenAIEmbeddingModel(modelId, {
39961
40120
  provider: `${providerName}.embedding`,
39962
- url: ({ path: path6 }) => `${baseURL}${path6}`,
40121
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
39963
40122
  headers: getHeaders,
39964
40123
  fetch: options.fetch
39965
40124
  });
39966
40125
  const createImageModel = (modelId) => new OpenAIImageModel(modelId, {
39967
40126
  provider: `${providerName}.image`,
39968
- url: ({ path: path6 }) => `${baseURL}${path6}`,
40127
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
39969
40128
  headers: getHeaders,
39970
40129
  fetch: options.fetch
39971
40130
  });
39972
40131
  const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
39973
40132
  provider: `${providerName}.transcription`,
39974
- url: ({ path: path6 }) => `${baseURL}${path6}`,
40133
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
39975
40134
  headers: getHeaders,
39976
40135
  fetch: options.fetch
39977
40136
  });
39978
40137
  const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
39979
40138
  provider: `${providerName}.speech`,
39980
- url: ({ path: path6 }) => `${baseURL}${path6}`,
40139
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
39981
40140
  headers: getHeaders,
39982
40141
  fetch: options.fetch
39983
40142
  });
@@ -39992,7 +40151,7 @@ function createOpenAI(options = {}) {
39992
40151
  const createResponsesModel = (modelId) => {
39993
40152
  return new OpenAIResponsesLanguageModel(modelId, {
39994
40153
  provider: `${providerName}.responses`,
39995
- url: ({ path: path6 }) => `${baseURL}${path6}`,
40154
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
39996
40155
  headers: getHeaders,
39997
40156
  fetch: options.fetch,
39998
40157
  fileIdPrefixes: ["file-"]
@@ -48528,8 +48687,8 @@ var init_background_process_tracker = __esm({
48528
48687
  /**
48529
48688
  * Normalize file path for comparison
48530
48689
  */
48531
- normalizePath(path6) {
48532
- let normalized = path6.trim().replace(/\/+/g, "/");
48690
+ normalizePath(path8) {
48691
+ let normalized = path8.trim().replace(/\/+/g, "/");
48533
48692
  if (normalized.startsWith("./")) {
48534
48693
  normalized = normalized.slice(2);
48535
48694
  }
@@ -48767,8 +48926,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
48767
48926
  return decodedFile;
48768
48927
  };
48769
48928
  }
48770
- function normalizeWindowsPath(path6) {
48771
- return path6.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
48929
+ function normalizeWindowsPath(path8) {
48930
+ return path8.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
48772
48931
  }
48773
48932
  var import_path;
48774
48933
  var init_module_node = __esm({
@@ -51657,9 +51816,9 @@ async function addSourceContext(frames) {
51657
51816
  LRU_FILE_CONTENTS_CACHE.reduce();
51658
51817
  return frames;
51659
51818
  }
51660
- function getContextLinesFromFile(path6, ranges, output) {
51819
+ function getContextLinesFromFile(path8, ranges, output) {
51661
51820
  return new Promise((resolve2) => {
51662
- const stream = (0, import_node_fs3.createReadStream)(path6);
51821
+ const stream = (0, import_node_fs5.createReadStream)(path8);
51663
51822
  const lineReaded = (0, import_node_readline2.createInterface)({
51664
51823
  input: stream
51665
51824
  });
@@ -51674,7 +51833,7 @@ function getContextLinesFromFile(path6, ranges, output) {
51674
51833
  let rangeStart = range[0];
51675
51834
  let rangeEnd = range[1];
51676
51835
  function onStreamError() {
51677
- LRU_FILE_CONTENTS_FS_READ_FAILED.set(path6, 1);
51836
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(path8, 1);
51678
51837
  lineReaded.close();
51679
51838
  lineReaded.removeAllListeners();
51680
51839
  destroyStreamAndResolve();
@@ -51735,8 +51894,8 @@ function clearLineContext(frame2) {
51735
51894
  delete frame2.context_line;
51736
51895
  delete frame2.post_context;
51737
51896
  }
51738
- function shouldSkipContextLinesForFile(path6) {
51739
- return path6.startsWith("node:") || path6.endsWith(".min.js") || path6.endsWith(".min.cjs") || path6.endsWith(".min.mjs") || path6.startsWith("data:");
51897
+ function shouldSkipContextLinesForFile(path8) {
51898
+ return path8.startsWith("node:") || path8.endsWith(".min.js") || path8.endsWith(".min.cjs") || path8.endsWith(".min.mjs") || path8.startsWith("data:");
51740
51899
  }
51741
51900
  function shouldSkipContextLinesForFrame(frame2) {
51742
51901
  if (void 0 !== frame2.lineno && frame2.lineno > MAX_CONTEXTLINES_LINENO) return true;
@@ -51807,12 +51966,12 @@ function snipLine(line, colno) {
51807
51966
  if (end < lineLength) newLine += "...";
51808
51967
  return newLine;
51809
51968
  }
51810
- var import_node_fs3, import_node_readline2, LRU_FILE_CONTENTS_CACHE, LRU_FILE_CONTENTS_FS_READ_FAILED, DEFAULT_LINES_OF_CONTEXT, MAX_CONTEXTLINES_COLNO, MAX_CONTEXTLINES_LINENO;
51969
+ var import_node_fs5, import_node_readline2, LRU_FILE_CONTENTS_CACHE, LRU_FILE_CONTENTS_FS_READ_FAILED, DEFAULT_LINES_OF_CONTEXT, MAX_CONTEXTLINES_COLNO, MAX_CONTEXTLINES_LINENO;
51811
51970
  var init_context_lines_node = __esm({
51812
51971
  "../node_modules/.pnpm/posthog-node@5.35.13_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs"() {
51813
51972
  "use strict";
51814
51973
  init_dist8();
51815
- import_node_fs3 = require("node:fs");
51974
+ import_node_fs5 = require("node:fs");
51816
51975
  import_node_readline2 = require("node:readline");
51817
51976
  LRU_FILE_CONTENTS_CACHE = new error_tracking_exports.ReduceableCache(25);
51818
51977
  LRU_FILE_CONTENTS_FS_READ_FAILED = new error_tracking_exports.ReduceableCache(20);
@@ -51844,7 +52003,7 @@ var init_relative_path_node = __esm({
51844
52003
 
51845
52004
  // ../node_modules/.pnpm/posthog-node@5.35.13_rxjs@7.8.2/node_modules/posthog-node/dist/version.mjs
51846
52005
  var version2;
51847
- var init_version2 = __esm({
52006
+ var init_version3 = __esm({
51848
52007
  "../node_modules/.pnpm/posthog-node@5.35.13_rxjs@7.8.2/node_modules/posthog-node/dist/version.mjs"() {
51849
52008
  "use strict";
51850
52009
  version2 = "5.35.13";
@@ -52962,7 +53121,7 @@ var MINIMUM_POLLING_INTERVAL, THIRTY_SECONDS, MAX_CACHE_SIZE, WAITUNTIL_DEBOUNCE
52962
53121
  var init_client = __esm({
52963
53122
  "../node_modules/.pnpm/posthog-node@5.35.13_rxjs@7.8.2/node_modules/posthog-node/dist/client.mjs"() {
52964
53123
  "use strict";
52965
- init_version2();
53124
+ init_version3();
52966
53125
  init_dist8();
52967
53126
  init_types5();
52968
53127
  init_feature_flag_evaluations();
@@ -67146,8 +67305,8 @@ var init_logger2 = __esm({
67146
67305
  });
67147
67306
 
67148
67307
  // ../lib/ai/tools/file.ts
67149
- function isSpritPath(path6) {
67150
- return path6.split(/[\\/]/).some((segment) => segment.toLowerCase() === "sprit");
67308
+ function isSpritPath(path8) {
67309
+ return path8.split(/[\\/]/).some((segment) => segment.toLowerCase() === "sprit");
67151
67310
  }
67152
67311
  function getViewSandboxType(sandbox) {
67153
67312
  return isCentrifugoSandbox(sandbox) ? "centrifugo" : "e2b";
@@ -67178,7 +67337,7 @@ function captureFileViewImageUsage(args) {
67178
67337
  const {
67179
67338
  context: context2,
67180
67339
  sandbox,
67181
- path: path6,
67340
+ path: path8,
67182
67341
  outcome,
67183
67342
  durationMs,
67184
67343
  mediaType,
@@ -67196,7 +67355,7 @@ function captureFileViewImageUsage(args) {
67196
67355
  model: getActiveModelName(context2),
67197
67356
  configured_model: context2.modelName,
67198
67357
  sandbox_type: getViewSandboxType(sandbox),
67199
- file_extension: getFileExtension(path6),
67358
+ file_extension: getFileExtension(path8),
67200
67359
  outcome,
67201
67360
  success: outcome === "success",
67202
67361
  duration_ms: durationMs,
@@ -67270,22 +67429,22 @@ async function runSandboxCommand(sandbox, command, envVars, timeoutMs = 6e4) {
67270
67429
  function isWindowsSandbox(sandbox) {
67271
67430
  return isCentrifugoSandbox(sandbox) && sandbox.isWindows();
67272
67431
  }
67273
- function getWindowsNativePath(path6) {
67274
- if (/^[A-Za-z]:[\\/]/.test(path6)) return path6;
67275
- if (path6.startsWith("/tmp/")) {
67276
- return `C:\\temp${path6.slice(4).replace(/\//g, "\\")}`;
67432
+ function getWindowsNativePath(path8) {
67433
+ if (/^[A-Za-z]:[\\/]/.test(path8)) return path8;
67434
+ if (path8.startsWith("/tmp/")) {
67435
+ return `C:\\temp${path8.slice(4).replace(/\//g, "\\")}`;
67277
67436
  }
67278
- return path6.replace(/\//g, "\\");
67437
+ return path8.replace(/\//g, "\\");
67279
67438
  }
67280
- function getPythonPathForSandbox(sandbox, path6) {
67281
- return isWindowsSandbox(sandbox) ? getWindowsNativePath(path6) : path6;
67439
+ function getPythonPathForSandbox(sandbox, path8) {
67440
+ return isWindowsSandbox(sandbox) ? getWindowsNativePath(path8) : path8;
67282
67441
  }
67283
- function toWindowsBashPath(path6) {
67284
- const drive = path6.match(/^([A-Za-z]):[\\/](.*)$/);
67442
+ function toWindowsBashPath(path8) {
67443
+ const drive = path8.match(/^([A-Za-z]):[\\/](.*)$/);
67285
67444
  if (drive) {
67286
67445
  return `/${drive[1].toLowerCase()}/${drive[2].replace(/\\/g, "/")}`;
67287
67446
  }
67288
- return path6.replace(/\\/g, "/");
67447
+ return path8.replace(/\\/g, "/");
67289
67448
  }
67290
67449
  async function detectSandboxShell(sandbox) {
67291
67450
  if (!isWindowsSandbox(sandbox)) return "bash";
@@ -67324,8 +67483,8 @@ PY`;
67324
67483
  }
67325
67484
  }
67326
67485
  }
67327
- async function getSandboxFileState(sandbox, path6) {
67328
- const pythonPath = getPythonPathForSandbox(sandbox, path6);
67486
+ async function getSandboxFileState(sandbox, path8) {
67487
+ const pythonPath = getPythonPathForSandbox(sandbox, path8);
67329
67488
  const result = await runPythonScript(
67330
67489
  sandbox,
67331
67490
  FILE_STATE_SCRIPT,
@@ -67342,23 +67501,23 @@ async function getSandboxFileState(sandbox, path6) {
67342
67501
  if (result.exitCode !== 0) {
67343
67502
  return {
67344
67503
  kind: "unknown",
67345
- path: path6,
67504
+ path: path8,
67346
67505
  error: result.stderr || result.stdout || "file state command failed"
67347
67506
  };
67348
67507
  }
67349
67508
  try {
67350
67509
  const payload = JSON.parse(result.stdout.trim());
67351
67510
  if (payload.kind === "file" && typeof payload.sizeBytes === "number" && Number.isFinite(payload.sizeBytes)) {
67352
- return { ...payload, path: path6 };
67511
+ return { ...payload, path: path8 };
67353
67512
  }
67354
67513
  if (payload.kind === "missing" || payload.kind === "not_file") {
67355
- return { ...payload, path: path6 };
67514
+ return { ...payload, path: path8 };
67356
67515
  }
67357
67516
  } catch {
67358
67517
  }
67359
67518
  return {
67360
67519
  kind: "unknown",
67361
- path: path6,
67520
+ path: path8,
67362
67521
  error: result.stderr || result.stdout || "invalid file state response"
67363
67522
  };
67364
67523
  }
@@ -67390,8 +67549,8 @@ ${numberedContent}${truncatedNotice}${footerNotice}`;
67390
67549
  })
67391
67550
  };
67392
67551
  }
67393
- async function readSandboxTextFile(sandbox, path6, range) {
67394
- const pythonPath = getPythonPathForSandbox(sandbox, path6);
67552
+ async function readSandboxTextFile(sandbox, path8, range) {
67553
+ const pythonPath = getPythonPathForSandbox(sandbox, path8);
67395
67554
  const envVars = {
67396
67555
  HACKERAI_FILE_READ_PATH: pythonPath,
67397
67556
  HACKERAI_FILE_READ_RANGE_START: String(range?.[0] ?? 0),
@@ -67419,40 +67578,40 @@ async function readSandboxTextFile(sandbox, path6, range) {
67419
67578
  }
67420
67579
  return payload;
67421
67580
  }
67422
- async function readSandboxTextFileWithFallback(sandbox, path6, range) {
67581
+ async function readSandboxTextFileWithFallback(sandbox, path8, range) {
67423
67582
  try {
67424
- return await readSandboxTextFile(sandbox, path6, range);
67583
+ return await readSandboxTextFile(sandbox, path8, range);
67425
67584
  } catch (error51) {
67426
67585
  const errorMessage = error51 instanceof Error ? error51.message : String(error51);
67427
67586
  if (errorMessage.startsWith("Invalid ") || errorMessage.includes("File not found")) {
67428
67587
  throw error51;
67429
67588
  }
67430
- const state = await getSandboxFileState(sandbox, path6);
67589
+ const state = await getSandboxFileState(sandbox, path8);
67431
67590
  if (state.kind === "unknown") {
67432
67591
  throw new Error(
67433
- `Unable to determine file size for ${path6}; refusing to load the file into memory. ${state.error}`
67592
+ `Unable to determine file size for ${path8}; refusing to load the file into memory. ${state.error}`
67434
67593
  );
67435
67594
  }
67436
67595
  if (state.kind === "missing") {
67437
- throw new Error(`File not found or is not a regular file: ${path6}`);
67596
+ throw new Error(`File not found or is not a regular file: ${path8}`);
67438
67597
  }
67439
67598
  if (state.kind === "not_file") {
67440
- throw new Error(`File is not a regular file: ${path6}`);
67599
+ throw new Error(`File is not a regular file: ${path8}`);
67441
67600
  }
67442
67601
  if (state.sizeBytes > MAX_TEXT_FILE_READ_BYTES) {
67443
67602
  if (range) {
67444
67603
  throw new Error(
67445
- `Unable to perform a bounded range read for ${path6}, and the file is too large to load safely (${formatBytes(state.sizeBytes)}). Use a targeted terminal command that writes a small result to a separate file.`
67604
+ `Unable to perform a bounded range read for ${path8}, and the file is too large to load safely (${formatBytes(state.sizeBytes)}). Use a targeted terminal command that writes a small result to a separate file.`
67446
67605
  );
67447
67606
  }
67448
67607
  return {
67449
- path: path6,
67608
+ path: path8,
67450
67609
  sizeBytes: state.sizeBytes,
67451
67610
  totalLines: 0,
67452
67611
  tooLarge: true
67453
67612
  };
67454
67613
  }
67455
- const fileContent = await sandbox.files.read(path6, {
67614
+ const fileContent = await sandbox.files.read(path8, {
67456
67615
  user: "user"
67457
67616
  });
67458
67617
  const lines = fileContent.split("\n");
@@ -67481,7 +67640,7 @@ async function readSandboxTextFileWithFallback(sandbox, path6, range) {
67481
67640
  const startIndex = start - 1;
67482
67641
  const endIndex = end === -1 ? lines.length : end;
67483
67642
  return {
67484
- path: path6,
67643
+ path: path8,
67485
67644
  sizeBytes: Buffer.byteLength(fileContent),
67486
67645
  totalLines: lines.length,
67487
67646
  content: lines.slice(startIndex, endIndex).join("\n"),
@@ -67489,7 +67648,7 @@ async function readSandboxTextFileWithFallback(sandbox, path6, range) {
67489
67648
  };
67490
67649
  }
67491
67650
  return {
67492
- path: path6,
67651
+ path: path8,
67493
67652
  sizeBytes: Buffer.byteLength(fileContent),
67494
67653
  totalLines: lines.length,
67495
67654
  content: fileContent,
@@ -67497,7 +67656,7 @@ async function readSandboxTextFileWithFallback(sandbox, path6, range) {
67497
67656
  };
67498
67657
  }
67499
67658
  }
67500
- async function appendSandboxTextFile(sandbox, path6, text2) {
67659
+ async function appendSandboxTextFile(sandbox, path8, text2) {
67501
67660
  const tempPath = `/tmp/hackerai_append_${Date.now()}_${Math.random().toString(36).slice(2)}.tmp`;
67502
67661
  await sandbox.files.write(tempPath, text2, {
67503
67662
  user: "user"
@@ -67506,7 +67665,7 @@ async function appendSandboxTextFile(sandbox, path6, text2) {
67506
67665
  sandbox,
67507
67666
  APPEND_TEXT_FILE_SCRIPT,
67508
67667
  {
67509
- HACKERAI_FILE_APPEND_TARGET_PATH: getPythonPathForSandbox(sandbox, path6),
67668
+ HACKERAI_FILE_APPEND_TARGET_PATH: getPythonPathForSandbox(sandbox, path8),
67510
67669
  HACKERAI_FILE_APPEND_SOURCE_PATH: getPythonPathForSandbox(
67511
67670
  sandbox,
67512
67671
  tempPath
@@ -67518,13 +67677,13 @@ async function appendSandboxTextFile(sandbox, path6, text2) {
67518
67677
  throw new Error(result.stderr || result.stdout || "Failed to append file");
67519
67678
  }
67520
67679
  }
67521
- async function readSandboxFileForView(sandbox, path6, includeData) {
67680
+ async function readSandboxFileForView(sandbox, path8, includeData) {
67522
67681
  if (isCentrifugoSandbox(sandbox) && sandbox.isWindows()) {
67523
67682
  throw new Error(
67524
67683
  "The view action is not available for Windows local sandboxes yet. Use a Linux/E2B sandbox or inspect the image manually."
67525
67684
  );
67526
67685
  }
67527
- const sandboxPath = getSandboxViewPath(sandbox, path6);
67686
+ const sandboxPath = getSandboxViewPath(sandbox, path8);
67528
67687
  const viewEnvVars = {
67529
67688
  HACKERAI_FILE_VIEW_PATH: sandboxPath,
67530
67689
  HACKERAI_FILE_VIEW_INCLUDE_DATA: includeData ? "1" : "0",
@@ -67867,19 +68026,19 @@ try:
67867
68026
  except OSError:
67868
68027
  pass
67869
68028
  `;
67870
- getFilename = (path6) => path6.split("/").pop() || path6;
67871
- getFileExtension = (path6) => {
67872
- const filename = getFilename(path6);
68029
+ getFilename = (path8) => path8.split("/").pop() || path8;
68030
+ getFileExtension = (path8) => {
68031
+ const filename = getFilename(path8);
67873
68032
  const dotIndex = filename.lastIndexOf(".");
67874
68033
  if (dotIndex <= 0 || dotIndex === filename.length - 1) return void 0;
67875
68034
  return filename.slice(dotIndex + 1).toLowerCase();
67876
68035
  };
67877
- getSandboxViewPath = (sandbox, path6) => {
68036
+ getSandboxViewPath = (sandbox, path8) => {
67878
68037
  const maybeSandbox = sandbox;
67879
- if (isCentrifugoSandbox(maybeSandbox) && maybeSandbox.isWindows() && path6.startsWith("/tmp/")) {
67880
- return `C:\\temp${path6.slice(4).replace(/\//g, "\\")}`;
68038
+ if (isCentrifugoSandbox(maybeSandbox) && maybeSandbox.isWindows() && path8.startsWith("/tmp/")) {
68039
+ return `C:\\temp${path8.slice(4).replace(/\//g, "\\")}`;
67881
68040
  }
67882
- return path6;
68041
+ return path8;
67883
68042
  };
67884
68043
  stripTrailingWs = (line) => line.replace(/[ \t]+$/u, "");
67885
68044
  editSchema = external_exports.object({
@@ -67953,7 +68112,7 @@ ${instructionsDescription}`,
67953
68112
  "A list of edits to be sequentially applied to the file. Required for `edit` action."
67954
68113
  )
67955
68114
  }),
67956
- execute: async ({ action, path: path6, text: text2, range, edits }) => {
68115
+ execute: async ({ action, path: path8, text: text2, range, edits }) => {
67957
68116
  try {
67958
68117
  const { sandbox } = await sandboxManager.getSandbox();
67959
68118
  switch (action) {
@@ -67963,7 +68122,7 @@ ${instructionsDescription}`,
67963
68122
  captureFileViewImageUsage({
67964
68123
  context: context2,
67965
68124
  sandbox,
67966
- path: path6,
68125
+ path: path8,
67967
68126
  outcome: "unsupported_model",
67968
68127
  durationMs: Date.now() - viewStartedAt,
67969
68128
  failureReason: "unsupported_model"
@@ -67972,26 +68131,26 @@ ${instructionsDescription}`,
67972
68131
  }
67973
68132
  let viewPayload;
67974
68133
  try {
67975
- viewPayload = await readSandboxFileForView(sandbox, path6, false);
68134
+ viewPayload = await readSandboxFileForView(sandbox, path8, false);
67976
68135
  } catch (error51) {
67977
68136
  captureFileViewImageUsage({
67978
68137
  context: context2,
67979
68138
  sandbox,
67980
- path: path6,
68139
+ path: path8,
67981
68140
  outcome: "inspection_failed",
67982
68141
  durationMs: Date.now() - viewStartedAt,
67983
68142
  failureReason: classifyFileViewError(error51)
67984
68143
  });
67985
68144
  throw error51;
67986
68145
  }
67987
- const filename = getFilename(path6);
68146
+ const filename = getFilename(path8);
67988
68147
  let previewFiles = [];
67989
68148
  let previewUploadError;
67990
68149
  try {
67991
68150
  previewFiles = await uploadViewPreviewFiles({
67992
68151
  context: context2,
67993
68152
  sandbox,
67994
- sourcePath: path6,
68153
+ sourcePath: path8,
67995
68154
  payload: viewPayload
67996
68155
  });
67997
68156
  } catch (error51) {
@@ -68005,7 +68164,7 @@ ${instructionsDescription}`,
68005
68164
  user_id: context2.userID,
68006
68165
  sandbox_type: getViewSandboxType(sandbox),
68007
68166
  file_name: filename,
68008
- source_path: path6,
68167
+ source_path: path8,
68009
68168
  kind: viewPayload.kind,
68010
68169
  media_type: viewPayload.mediaType,
68011
68170
  size_bytes: viewPayload.sizeBytes,
@@ -68016,7 +68175,7 @@ ${instructionsDescription}`,
68016
68175
  captureFileViewImageUsage({
68017
68176
  context: context2,
68018
68177
  sandbox,
68019
- path: path6,
68178
+ path: path8,
68020
68179
  outcome: "success",
68021
68180
  durationMs: Date.now() - viewStartedAt,
68022
68181
  mediaType: viewPayload.mediaType,
@@ -68026,7 +68185,7 @@ ${instructionsDescription}`,
68026
68185
  return {
68027
68186
  action: "view",
68028
68187
  content: `Viewing image file: ${filename} (${viewPayload.mediaType}, ${viewPayload.sizeBytes} bytes).`,
68029
- path: path6,
68188
+ path: path8,
68030
68189
  filename,
68031
68190
  mediaType: viewPayload.mediaType,
68032
68191
  sizeBytes: viewPayload.sizeBytes,
@@ -68036,8 +68195,8 @@ ${instructionsDescription}`,
68036
68195
  };
68037
68196
  }
68038
68197
  case "read": {
68039
- const filename = path6.split("/").pop() || path6;
68040
- const spritChunked = isSpritPath(path6);
68198
+ const filename = path8.split("/").pop() || path8;
68199
+ const spritChunked = isSpritPath(path8);
68041
68200
  let effectiveRange = range;
68042
68201
  if (spritChunked) {
68043
68202
  const start = range && range[0] > 0 ? range[0] : 1;
@@ -68050,7 +68209,7 @@ ${instructionsDescription}`,
68050
68209
  }
68051
68210
  const readPayload = await readSandboxTextFileWithFallback(
68052
68211
  sandbox,
68053
- path6,
68212
+ path8,
68054
68213
  effectiveRange
68055
68214
  );
68056
68215
  if (readPayload.tooLarge) {
@@ -68087,46 +68246,46 @@ File is too large to read in full (${formatBytes(readPayload.sizeBytes)}, ${tota
68087
68246
  if (text2 === void 0) {
68088
68247
  return { error: "text is required for write action" };
68089
68248
  }
68090
- await sandbox.files.write(path6, text2, {
68249
+ await sandbox.files.write(path8, text2, {
68091
68250
  user: "user"
68092
68251
  });
68093
- return `File written: ${path6}`;
68252
+ return `File written: ${path8}`;
68094
68253
  }
68095
68254
  case "append": {
68096
68255
  if (text2 === void 0) {
68097
68256
  return { error: "text is required for append action" };
68098
68257
  }
68099
- const existingState = await getSandboxFileState(sandbox, path6);
68258
+ const existingState = await getSandboxFileState(sandbox, path8);
68100
68259
  if (existingState.kind === "unknown") {
68101
68260
  return {
68102
- error: `Cannot append safely because the existing file size could not be determined for ${path6}. ${existingState.error}`
68261
+ error: `Cannot append safely because the existing file size could not be determined for ${path8}. ${existingState.error}`
68103
68262
  };
68104
68263
  }
68105
68264
  if (existingState.kind === "not_file") {
68106
68265
  return {
68107
- error: `Cannot append to ${path6} because it is not a file.`
68266
+ error: `Cannot append to ${path8} because it is not a file.`
68108
68267
  };
68109
68268
  }
68110
68269
  if (existingState.kind === "file" && existingState.sizeBytes > MAX_TEXT_FILE_READ_BYTES) {
68111
- await appendSandboxTextFile(sandbox, path6, text2);
68270
+ await appendSandboxTextFile(sandbox, path8, text2);
68112
68271
  return {
68113
- content: `File appended: ${path6}
68272
+ content: `File appended: ${path8}
68114
68273
  Existing file is ${formatBytes(existingState.sizeBytes)}, so the full diff preview was skipped to avoid loading the entire file into memory.`
68115
68274
  };
68116
68275
  }
68117
68276
  let existingContent = "";
68118
68277
  try {
68119
- existingContent = await sandbox.files.read(path6, {
68278
+ existingContent = await sandbox.files.read(path8, {
68120
68279
  user: "user"
68121
68280
  });
68122
68281
  } catch {
68123
68282
  }
68124
68283
  const newContent = existingContent + text2;
68125
- await sandbox.files.write(path6, newContent, {
68284
+ await sandbox.files.write(path8, newContent, {
68126
68285
  user: "user"
68127
68286
  });
68128
68287
  return {
68129
- content: `File appended: ${path6}`,
68288
+ content: `File appended: ${path8}`,
68130
68289
  originalContent: truncateOutput({
68131
68290
  content: existingContent,
68132
68291
  mode: "read-file"
@@ -68141,31 +68300,31 @@ Existing file is ${formatBytes(existingState.sizeBytes)}, so the full diff previ
68141
68300
  if (!edits || edits.length === 0) {
68142
68301
  return { error: "edits array is required for edit action" };
68143
68302
  }
68144
- const existingState = await getSandboxFileState(sandbox, path6);
68303
+ const existingState = await getSandboxFileState(sandbox, path8);
68145
68304
  if (existingState.kind === "unknown") {
68146
68305
  return {
68147
- error: `Cannot edit ${path6} safely because the file size could not be determined. ${existingState.error}`
68306
+ error: `Cannot edit ${path8} safely because the file size could not be determined. ${existingState.error}`
68148
68307
  };
68149
68308
  }
68150
68309
  if (existingState.kind === "missing") {
68151
68310
  return {
68152
- error: `Cannot edit file ${path6} - file is empty or does not exist`
68311
+ error: `Cannot edit file ${path8} - file is empty or does not exist`
68153
68312
  };
68154
68313
  }
68155
68314
  if (existingState.kind === "not_file") {
68156
- return { error: `Cannot edit ${path6} because it is not a file.` };
68315
+ return { error: `Cannot edit ${path8} because it is not a file.` };
68157
68316
  }
68158
68317
  if (existingState.sizeBytes > MAX_TEXT_FILE_READ_BYTES) {
68159
68318
  return {
68160
- error: `File ${path6} is too large for the edit action (${formatBytes(existingState.sizeBytes)}). Use a targeted shell command, restore the file from a clean source, or replace it with the write action instead of loading the whole file into memory.`
68319
+ error: `File ${path8} is too large for the edit action (${formatBytes(existingState.sizeBytes)}). Use a targeted shell command, restore the file from a clean source, or replace it with the write action instead of loading the whole file into memory.`
68161
68320
  };
68162
68321
  }
68163
- const originalContent = await sandbox.files.read(path6, {
68322
+ const originalContent = await sandbox.files.read(path8, {
68164
68323
  user: "user"
68165
68324
  });
68166
68325
  if (!originalContent) {
68167
68326
  return {
68168
- error: `Cannot edit file ${path6} - file is empty or does not exist`
68327
+ error: `Cannot edit file ${path8} - file is empty or does not exist`
68169
68328
  };
68170
68329
  }
68171
68330
  const resolvedEdits = [];
@@ -68210,7 +68369,7 @@ ${hint}` : "")
68210
68369
  }
68211
68370
  }
68212
68371
  }
68213
- await sandbox.files.write(path6, content, {
68372
+ await sandbox.files.write(path8, content, {
68214
68373
  user: "user"
68215
68374
  });
68216
68375
  const lines = content.split("\n");
@@ -68486,20 +68645,20 @@ var init_utils4 = __esm({
68486
68645
 
68487
68646
  // src/local-sandbox.ts
68488
68647
  function inferShellFlag(shell2) {
68489
- const base = import_node_path3.default.basename(shell2).toLowerCase();
68648
+ const base = import_node_path5.default.basename(shell2).toLowerCase();
68490
68649
  if (base === "cmd" || base === "cmd.exe") return "/C";
68491
68650
  if (base === "powershell" || base === "powershell.exe" || base === "pwsh") {
68492
68651
  return "-Command";
68493
68652
  }
68494
68653
  return "-c";
68495
68654
  }
68496
- var import_node_child_process, import_node_fs4, import_node_path3, import_node_os2, import_node_url, import_meta, LocalSandbox;
68655
+ var import_node_child_process2, import_node_fs6, import_node_path5, import_node_os2, import_node_url, import_meta, LocalSandbox;
68497
68656
  var init_local_sandbox = __esm({
68498
68657
  "src/local-sandbox.ts"() {
68499
68658
  "use strict";
68500
- import_node_child_process = require("node:child_process");
68501
- import_node_fs4 = require("node:fs");
68502
- import_node_path3 = __toESM(require("node:path"));
68659
+ import_node_child_process2 = require("node:child_process");
68660
+ import_node_fs6 = require("node:fs");
68661
+ import_node_path5 = __toESM(require("node:path"));
68503
68662
  import_node_os2 = __toESM(require("node:os"));
68504
68663
  import_node_url = require("node:url");
68505
68664
  init_utils4();
@@ -68523,7 +68682,7 @@ var init_local_sandbox = __esm({
68523
68682
  this.shellFlag,
68524
68683
  command
68525
68684
  );
68526
- child = (0, import_node_child_process.spawn)(this.shellBin, spawnSpec.args, {
68685
+ child = (0, import_node_child_process2.spawn)(this.shellBin, spawnSpec.args, {
68527
68686
  cwd,
68528
68687
  env,
68529
68688
  detached: !!opts?.background,
@@ -68597,15 +68756,15 @@ var init_local_sandbox = __esm({
68597
68756
  this.files = {
68598
68757
  write: async (filePath, content) => {
68599
68758
  const resolved = this.resolvePath(filePath);
68600
- await import_node_fs4.promises.mkdir(import_node_path3.default.dirname(resolved), { recursive: true });
68759
+ await import_node_fs6.promises.mkdir(import_node_path5.default.dirname(resolved), { recursive: true });
68601
68760
  const data = typeof content === "string" ? content : content instanceof ArrayBuffer ? Buffer.from(content) : content;
68602
- await import_node_fs4.promises.writeFile(resolved, data);
68761
+ await import_node_fs6.promises.writeFile(resolved, data);
68603
68762
  },
68604
68763
  read: async (filePath) => {
68605
- return import_node_fs4.promises.readFile(this.resolvePath(filePath), "utf8");
68764
+ return import_node_fs6.promises.readFile(this.resolvePath(filePath), "utf8");
68606
68765
  },
68607
68766
  remove: async (filePath) => {
68608
- await import_node_fs4.promises.rm(this.resolvePath(filePath), {
68767
+ await import_node_fs6.promises.rm(this.resolvePath(filePath), {
68609
68768
  recursive: true,
68610
68769
  force: true
68611
68770
  });
@@ -68613,8 +68772,8 @@ var init_local_sandbox = __esm({
68613
68772
  list: async (dirPath = ".") => {
68614
68773
  const resolved = this.resolvePath(dirPath);
68615
68774
  try {
68616
- const entries = await import_node_fs4.promises.readdir(resolved, { withFileTypes: true });
68617
- return entries.filter((e) => e.isFile()).map((e) => ({ name: import_node_path3.default.join(resolved, e.name) }));
68775
+ const entries = await import_node_fs6.promises.readdir(resolved, { withFileTypes: true });
68776
+ return entries.filter((e) => e.isFile()).map((e) => ({ name: import_node_path5.default.join(resolved, e.name) }));
68618
68777
  } catch {
68619
68778
  return [];
68620
68779
  }
@@ -68629,11 +68788,11 @@ var init_local_sandbox = __esm({
68629
68788
  this.shellBin = shell2.shell;
68630
68789
  this.shellFlag = shell2.shellFlag;
68631
68790
  }
68632
- const base = opts?.workdir || process.env.CLI_WORKDIR || import_node_path3.default.join(process.cwd(), "SPRIT");
68633
- this.workdir = import_node_path3.default.resolve(base).replace(/\\/g, "/");
68791
+ const base = opts?.workdir || process.env.CLI_WORKDIR || import_node_path5.default.join(process.cwd(), "SPRIT");
68792
+ this.workdir = import_node_path5.default.resolve(base).replace(/\\/g, "/");
68634
68793
  }
68635
68794
  async init() {
68636
- await import_node_fs4.promises.mkdir(this.workdir, { recursive: true });
68795
+ await import_node_fs6.promises.mkdir(this.workdir, { recursive: true });
68637
68796
  await this.seedReconToolkit();
68638
68797
  }
68639
68798
  /**
@@ -68649,8 +68808,8 @@ var init_local_sandbox = __esm({
68649
68808
  const assetsDir = (0, import_node_url.fileURLToPath)(
68650
68809
  new URL("../assets/recon", import_meta.url)
68651
68810
  );
68652
- const destDir = import_node_path3.default.join(this.workdir, "recon");
68653
- await import_node_fs4.promises.mkdir(destDir, { recursive: true });
68811
+ const destDir = import_node_path5.default.join(this.workdir, "recon");
68812
+ await import_node_fs6.promises.mkdir(destDir, { recursive: true });
68654
68813
  const files = [
68655
68814
  ["recon_deep.py", true],
68656
68815
  ["console_recon.js", true],
@@ -68658,17 +68817,17 @@ var init_local_sandbox = __esm({
68658
68817
  ["scope.txt", false]
68659
68818
  ];
68660
68819
  for (const [name25, overwrite] of files) {
68661
- const dest = import_node_path3.default.join(destDir, name25);
68820
+ const dest = import_node_path5.default.join(destDir, name25);
68662
68821
  if (!overwrite) {
68663
68822
  try {
68664
- await import_node_fs4.promises.access(dest);
68823
+ await import_node_fs6.promises.access(dest);
68665
68824
  continue;
68666
68825
  } catch {
68667
68826
  }
68668
68827
  }
68669
68828
  try {
68670
- const content = await import_node_fs4.promises.readFile(import_node_path3.default.join(assetsDir, name25));
68671
- await import_node_fs4.promises.writeFile(dest, content);
68829
+ const content = await import_node_fs6.promises.readFile(import_node_path5.default.join(assetsDir, name25));
68830
+ await import_node_fs6.promises.writeFile(dest, content);
68672
68831
  } catch {
68673
68832
  }
68674
68833
  }
@@ -68771,7 +68930,7 @@ EDITING SCRIPTS:
68771
68930
  const pid = child.pid;
68772
68931
  if (pid && import_node_os2.default.platform() === "win32") {
68773
68932
  try {
68774
- (0, import_node_child_process.spawn)("taskkill", ["/PID", String(pid), "/T", "/F"], {
68933
+ (0, import_node_child_process2.spawn)("taskkill", ["/PID", String(pid), "/T", "/F"], {
68775
68934
  windowsHide: true
68776
68935
  });
68777
68936
  return;
@@ -68784,15 +68943,15 @@ EDITING SCRIPTS:
68784
68943
  }
68785
68944
  }
68786
68945
  resolvePath(p) {
68787
- if (import_node_path3.default.isAbsolute(p)) return p;
68788
- return import_node_path3.default.join(this.workdir, p);
68946
+ if (import_node_path5.default.isAbsolute(p)) return p;
68947
+ return import_node_path5.default.join(this.workdir, p);
68789
68948
  }
68790
68949
  isBashLikeShell() {
68791
- const base = import_node_path3.default.basename(this.shellBin).toLowerCase();
68950
+ const base = import_node_path5.default.basename(this.shellBin).toLowerCase();
68792
68951
  return base === "bash" || base === "bash.exe" || base === "sh";
68793
68952
  }
68794
68953
  isCmdShell() {
68795
- const base = import_node_path3.default.basename(this.shellBin).toLowerCase();
68954
+ const base = import_node_path5.default.basename(this.shellBin).toLowerCase();
68796
68955
  return base === "cmd" || base === "cmd.exe";
68797
68956
  }
68798
68957
  getWindowsShellNotes() {
@@ -68996,7 +69155,7 @@ function formatToolCall(toolName, input) {
68996
69155
  return `${C2.cyan}executando${C2.reset} ${C2.bold}$ ${truncate3(cmd, 400)}${C2.reset}${bg}`;
68997
69156
  }
68998
69157
  case "file": {
68999
- const path6 = String(i.path ?? "");
69158
+ const path8 = String(i.path ?? "");
69000
69159
  const brief = i.brief ? `${C2.dim} - ${truncate3(String(i.brief))}${C2.reset}` : "";
69001
69160
  const map2 = {
69002
69161
  write: `${C2.green}criando arquivo${C2.reset}`,
@@ -69007,7 +69166,7 @@ function formatToolCall(toolName, input) {
69007
69166
  };
69008
69167
  const action = typeof i.action === "string" ? i.action : "";
69009
69168
  const label = map2[action] ?? (action ? `${C2.blue}arquivo (${action})${C2.reset}` : `${C2.blue}preparando operacao de arquivo${C2.reset}`);
69010
- const target = path6 ? ` ${C2.bold}${path6}${C2.reset}` : "";
69169
+ const target = path8 ? ` ${C2.bold}${path8}${C2.reset}` : "";
69011
69170
  return `${label}${target}${brief}`;
69012
69171
  }
69013
69172
  case "todo_write":
@@ -69083,7 +69242,7 @@ function killProxy(child) {
69083
69242
  started.delete(child);
69084
69243
  try {
69085
69244
  if (process.platform === "win32") {
69086
- (0, import_node_child_process2.spawnSync)("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
69245
+ (0, import_node_child_process3.spawnSync)("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
69087
69246
  stdio: "ignore"
69088
69247
  });
69089
69248
  } else {
@@ -69114,12 +69273,12 @@ async function ensureProxyReady(id, log2) {
69114
69273
  };
69115
69274
  }
69116
69275
  let freshSetup = false;
69117
- if (!(0, import_node_fs5.existsSync)(dir)) {
69276
+ if (!(0, import_node_fs7.existsSync)(dir)) {
69118
69277
  log2(`${def.label}: baixando o proxy (uma vez) em ${dir} \u2026`);
69119
69278
  const root = proxiesRoot();
69120
- (0, import_node_fs5.mkdirSync)(root, { recursive: true });
69279
+ (0, import_node_fs7.mkdirSync)(root, { recursive: true });
69121
69280
  const cloned = run("git", ["clone", def.repoUrl, dir], root);
69122
- if (!cloned.ok || !(0, import_node_fs5.existsSync)(dir)) {
69281
+ if (!cloned.ok || !(0, import_node_fs7.existsSync)(dir)) {
69123
69282
  return {
69124
69283
  ok: false,
69125
69284
  message: `${def.label}: falha ao clonar o proxy (git).`
@@ -69127,7 +69286,7 @@ async function ensureProxyReady(id, log2) {
69127
69286
  }
69128
69287
  freshSetup = true;
69129
69288
  }
69130
- if (!(0, import_node_fs5.existsSync)(import_node_path4.default.join(dir, "node_modules"))) {
69289
+ if (!(0, import_node_fs7.existsSync)(import_node_path6.default.join(dir, "node_modules"))) {
69131
69290
  log2(`${def.label}: instalando depend\xEAncias (pode demorar) \u2026`);
69132
69291
  if (!run("npm", ["install"], dir).ok) {
69133
69292
  return { ok: false, message: `${def.label}: 'npm install' falhou.` };
@@ -69145,7 +69304,7 @@ async function ensureProxyReady(id, log2) {
69145
69304
  }
69146
69305
  }
69147
69306
  log2(`${def.label}: iniciando o proxy\u2026`);
69148
- const child = (0, import_node_child_process2.spawn)(asShellCommand("npm", ["start"]), {
69307
+ const child = (0, import_node_child_process3.spawn)(asShellCommand("npm", ["start"]), {
69149
69308
  cwd: dir,
69150
69309
  shell: true,
69151
69310
  stdio: ["ignore", "ignore", "ignore"],
@@ -69172,14 +69331,14 @@ async function ensureProxyReady(id, log2) {
69172
69331
  message: `${def.label}: o proxy n\xE3o respondeu em 90s. Tente de novo, ou rode 'npm run login' em ${dir}.`
69173
69332
  };
69174
69333
  }
69175
- var import_node_os3, import_node_path4, import_node_fs5, import_node_child_process2, DEFS, PROXY_MODEL_KEYS, proxyIdForModelKey, proxiesRoot, dirFor, healthUrl, baseUrl, wait, started, exitHooksInstalled, quoteArg, asShellCommand, run, hasCommand;
69334
+ var import_node_os3, import_node_path6, import_node_fs7, import_node_child_process3, DEFS, PROXY_MODEL_KEYS, proxyIdForModelKey, proxiesRoot, dirFor, healthUrl, baseUrl, wait, started, exitHooksInstalled, quoteArg, asShellCommand, run, hasCommand;
69176
69335
  var init_proxy_manager2 = __esm({
69177
69336
  "src/proxy-manager.ts"() {
69178
69337
  "use strict";
69179
69338
  import_node_os3 = __toESM(require("node:os"));
69180
- import_node_path4 = __toESM(require("node:path"));
69181
- import_node_fs5 = require("node:fs");
69182
- import_node_child_process2 = require("node:child_process");
69339
+ import_node_path6 = __toESM(require("node:path"));
69340
+ import_node_fs7 = require("node:fs");
69341
+ import_node_child_process3 = require("node:child_process");
69183
69342
  DEFS = {
69184
69343
  deepseek: {
69185
69344
  id: "deepseek",
@@ -69211,11 +69370,11 @@ var init_proxy_manager2 = __esm({
69211
69370
  if (key === PROXY_MODEL_KEYS.kimi) return "kimi";
69212
69371
  return null;
69213
69372
  };
69214
- proxiesRoot = () => import_node_path4.default.join(
69215
- process.env.CLAWFAST_HOME?.trim() || import_node_path4.default.join(import_node_os3.default.homedir(), ".clawfast"),
69373
+ proxiesRoot = () => import_node_path6.default.join(
69374
+ process.env.CLAWFAST_HOME?.trim() || import_node_path6.default.join(import_node_os3.default.homedir(), ".clawfast"),
69216
69375
  "proxies"
69217
69376
  );
69218
- dirFor = (def) => process.env[def.dirEnv]?.trim() || import_node_path4.default.join(proxiesRoot(), def.folder);
69377
+ dirFor = (def) => process.env[def.dirEnv]?.trim() || import_node_path6.default.join(proxiesRoot(), def.folder);
69219
69378
  healthUrl = (def) => `http://localhost:${def.port}/health`;
69220
69379
  baseUrl = (def) => `http://localhost:${def.port}/v1`;
69221
69380
  wait = (ms) => new Promise((r) => setTimeout(r, ms));
@@ -69224,7 +69383,7 @@ var init_proxy_manager2 = __esm({
69224
69383
  quoteArg = (s) => /[\s"&|<>^()]/.test(s) ? `"${s.replace(/"/g, '\\"')}"` : s;
69225
69384
  asShellCommand = (cmd, args) => [cmd, ...args.map(quoteArg)].join(" ");
69226
69385
  run = (cmd, args, cwd) => {
69227
- const res = (0, import_node_child_process2.spawnSync)(asShellCommand(cmd, args), {
69386
+ const res = (0, import_node_child_process3.spawnSync)(asShellCommand(cmd, args), {
69228
69387
  cwd,
69229
69388
  shell: true,
69230
69389
  stdio: "inherit",
@@ -69234,7 +69393,7 @@ var init_proxy_manager2 = __esm({
69234
69393
  };
69235
69394
  hasCommand = (cmd) => {
69236
69395
  const probe = process.platform === "win32" ? "where" : "which";
69237
- return (0, import_node_child_process2.spawnSync)(asShellCommand(probe, [cmd]), {
69396
+ return (0, import_node_child_process3.spawnSync)(asShellCommand(probe, [cmd]), {
69238
69397
  stdio: "ignore",
69239
69398
  shell: true
69240
69399
  }).status === 0;
@@ -69857,13 +70016,13 @@ ${resultText}`
69857
70016
  close
69858
70017
  };
69859
70018
  }
69860
- var import_promises, import_node_path5, MAX_STEPS, MAX_OUTPUT_TOKENS, MAX_AUTO_CONTINUES, MAX_RATE_LIMIT_WAITS, isRateLimitError, sleep, UNFINISHED_TAIL_RE, BENIGN_CLOSER_RE, TOOL_CALL_NUDGE, MAX_BRIDGE_STEPS, BRIDGE_RESULT_PREAMBLE, truncateBridgeSummary, isWebSessionProxyModel, proxyToolProtocolPolicy, SYSTEM_PROMPT_SOURCE, REQUIRED_SYSTEM_PROMPT_MARKERS, MODEL_LABELS, labelFor, loginRequiredHint, CLI_PYTHON_ONLY_POLICY, pythonOnlyPolicy, scriptFilePolicy, deepReconPolicy, skillsScopePolicy, hasEnvValue2, envFlagEnabled, CLI_PERSONALITIES, buildCliUserCustomization, buildCliNotesSection, cliGuardrailsConfig, maybeDumpSystemPrompt, auditSystemPrompt, assertFullSystemPrompt;
70019
+ var import_promises, import_node_path7, MAX_STEPS, MAX_OUTPUT_TOKENS, MAX_AUTO_CONTINUES, MAX_RATE_LIMIT_WAITS, isRateLimitError, sleep, UNFINISHED_TAIL_RE, BENIGN_CLOSER_RE, TOOL_CALL_NUDGE, MAX_BRIDGE_STEPS, BRIDGE_RESULT_PREAMBLE, truncateBridgeSummary, isWebSessionProxyModel, proxyToolProtocolPolicy, SYSTEM_PROMPT_SOURCE, REQUIRED_SYSTEM_PROMPT_MARKERS, MODEL_LABELS, labelFor, loginRequiredHint, CLI_PYTHON_ONLY_POLICY, pythonOnlyPolicy, scriptFilePolicy, deepReconPolicy, skillsScopePolicy, hasEnvValue2, envFlagEnabled, CLI_PERSONALITIES, buildCliUserCustomization, buildCliNotesSection, cliGuardrailsConfig, maybeDumpSystemPrompt, auditSystemPrompt, assertFullSystemPrompt;
69861
70020
  var init_agent = __esm({
69862
70021
  "src/agent.ts"() {
69863
70022
  "use strict";
69864
70023
  init_dist5();
69865
70024
  import_promises = require("node:fs/promises");
69866
- import_node_path5 = __toESM(require("node:path"));
70025
+ import_node_path7 = __toESM(require("node:path"));
69867
70026
  init_providers();
69868
70027
  init_system_prompt();
69869
70028
  init_notes();
@@ -70086,7 +70245,7 @@ ${section}` : "";
70086
70245
  return null;
70087
70246
  }
70088
70247
  await (0, import_promises.mkdir)(workdir, { recursive: true });
70089
- const outputPath = import_node_path5.default.join(workdir, "system-prompt.txt");
70248
+ const outputPath = import_node_path7.default.join(workdir, "system-prompt.txt");
70090
70249
  await (0, import_promises.writeFile)(outputPath, system, "utf8");
70091
70250
  return outputPath;
70092
70251
  };
@@ -70138,7 +70297,7 @@ function asciiTitle(text2) {
70138
70297
  }
70139
70298
  return out2;
70140
70299
  }
70141
- function buildBanner(_systemPromptChars) {
70300
+ function buildBanner(_systemPromptChars, version3 = "1") {
70142
70301
  const user = (import_node_os4.default.userInfo().username || "hacker").toLowerCase();
70143
70302
  const host = (import_node_os4.default.hostname() || "localhost").split(".")[0].toLowerCase();
70144
70303
  const art = asciiTitle("CLAWFAST");
@@ -70162,7 +70321,7 @@ function buildBanner(_systemPromptChars) {
70162
70321
  { text: shortCwd() },
70163
70322
  { text: "" }
70164
70323
  ];
70165
- const title = `clawfast v1`;
70324
+ const title = `clawfast v${version3}`;
70166
70325
  const topFill = "\u2500".repeat(Math.max(0, BOX_W - vlen(title) - 5));
70167
70326
  const top = `${C3.green}\u256D\u2500 ${C3.greenB}${C3.bold}${title}${C3.reset}${C3.green} ${topFill}\u256E${C3.reset}`;
70168
70327
  const bottom = `${C3.green}\u2570${"\u2500".repeat(BOX_W - 2)}\u256F${C3.reset}`;
@@ -70246,7 +70405,22 @@ async function main() {
70246
70405
  const agent = await createAgent2();
70247
70406
  const sys = agent.getSystemPrompt();
70248
70407
  stopBootSpinner();
70249
- process.stdout.write(buildBanner2(sys.length));
70408
+ const version3 = clawfastVersion();
70409
+ process.stdout.write(buildBanner2(sys.length, version3));
70410
+ const updateNotice = getUpdateNotice(version3);
70411
+ if (updateNotice) {
70412
+ process.stdout.write(
70413
+ `${ui2.C.yellow}\u2191 ${updateNotice}${ui2.C.reset}
70414
+ `
70415
+ );
70416
+ }
70417
+ refreshUpdateCacheInBackground(version3);
70418
+ if (consumePostUpdateLaunch(version3)) {
70419
+ process.stdout.write(
70420
+ `${ui2.C.greenB}Seja bem vindo ao submundo.${ui2.C.reset} ${ui2.C.dim}clawfast atualizado para ${version3} \u2014 rode ${ui2.C.reset}${ui2.C.cyan}/nov${ui2.C.reset}${ui2.C.dim} para ver as novidades.${ui2.C.reset}
70421
+ `
70422
+ );
70423
+ }
70250
70424
  const pasteInput = createPasteInput();
70251
70425
  const rl = import_node_readline3.default.createInterface({
70252
70426
  input: pasteInput.input,
@@ -70605,6 +70779,13 @@ ${ui2.C.dim}selecao de modelo cancelada${ui2.C.reset}
70605
70779
  );
70606
70780
  process.stdout.write(sys2 + "\n");
70607
70781
  process.stdout.write(`\x1B[90m\u2500\u2500\u2500\u2500 fim do system prompt \u2500\u2500\u2500\u2500\x1B[0m
70782
+ `);
70783
+ if (!closing) prompt();
70784
+ return;
70785
+ }
70786
+ if (input === "/nov" || input === "/novidades") {
70787
+ process.stdout.write(`
70788
+ ${ui2.C.cyan}${renderNews(clawfastVersion())}${ui2.C.reset}
70608
70789
  `);
70609
70790
  if (!closing) prompt();
70610
70791
  return;
@@ -70716,6 +70897,9 @@ var init_index = __esm({
70716
70897
  init_boot_ui();
70717
70898
  init_config();
70718
70899
  init_skills();
70900
+ init_version();
70901
+ init_update();
70902
+ init_news();
70719
70903
  loadClawfastEnv();
70720
70904
  deepseekEnabled = /^(1|true|yes)$/i.test(process.env.DEEPSEEK_ENABLED?.trim() ?? "") || Boolean(process.env.DEEPSEEK_BASE_URL?.trim()) || Boolean(process.env.DEEPSEEK_API_KEY?.trim());
70721
70905
  configuredModelProviders = [
@@ -70740,8 +70924,38 @@ var init_index = __esm({
70740
70924
  // boot.ts
70741
70925
  init_boot_ui();
70742
70926
  init_config();
70927
+ init_version();
70928
+ init_update();
70743
70929
  loadClawfastEnv();
70930
+ async function handleSubcommand() {
70931
+ const arg = process.argv[2];
70932
+ if (arg === "--version" || arg === "-v" || arg === "version") {
70933
+ process.stdout.write(`clawfast ${clawfastVersion()}
70934
+ `);
70935
+ process.exit(0);
70936
+ }
70937
+ if (arg === "update" || arg === "upgrade") {
70938
+ process.stdout.write(`\x1B[92mAtualizando o clawfast\u2026\x1B[0m
70939
+ `);
70940
+ const code = await runSelfUpdate();
70941
+ if (code === 0) {
70942
+ process.stdout.write(
70943
+ `
70944
+ \x1B[92m\x1B[1mSeja bem vindo ao submundo.\x1B[0m
70945
+ `
70946
+ );
70947
+ } else {
70948
+ process.stdout.write(
70949
+ `
70950
+ \x1B[91mFalha ao atualizar (codigo ${code}).\x1B[0m Tente manualmente: \x1B[1mnpm install -g clawfast@latest\x1B[0m
70951
+ `
70952
+ );
70953
+ }
70954
+ process.exit(code === 0 ? 0 : 1);
70955
+ }
70956
+ }
70744
70957
  async function boot() {
70958
+ await handleSubcommand();
70745
70959
  const hasKey = await ensureProviderKey();
70746
70960
  if (!hasKey) process.exit(1);
70747
70961
  startBootSpinner();