@orbit-build/cli 0.1.5 → 0.1.7

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 (3) hide show
  1. package/README.md +91 -57
  2. package/dist/index.js +1601 -1091
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ var require_windows = __commonJS({
43
43
  "use strict";
44
44
  module.exports = isexe;
45
45
  isexe.sync = sync;
46
- var fs4 = __require("fs");
46
+ var fs5 = __require("fs");
47
47
  function checkPathExt(path5, options) {
48
48
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
49
49
  if (!pathext) {
@@ -68,12 +68,12 @@ var require_windows = __commonJS({
68
68
  return checkPathExt(path5, options);
69
69
  }
70
70
  function isexe(path5, options, cb) {
71
- fs4.stat(path5, function(er, stat) {
71
+ fs5.stat(path5, function(er, stat) {
72
72
  cb(er, er ? false : checkStat(stat, path5, options));
73
73
  });
74
74
  }
75
75
  function sync(path5, options) {
76
- return checkStat(fs4.statSync(path5), path5, options);
76
+ return checkStat(fs5.statSync(path5), path5, options);
77
77
  }
78
78
  }
79
79
  });
@@ -84,14 +84,14 @@ var require_mode = __commonJS({
84
84
  "use strict";
85
85
  module.exports = isexe;
86
86
  isexe.sync = sync;
87
- var fs4 = __require("fs");
87
+ var fs5 = __require("fs");
88
88
  function isexe(path5, options, cb) {
89
- fs4.stat(path5, function(er, stat) {
89
+ fs5.stat(path5, function(er, stat) {
90
90
  cb(er, er ? false : checkStat(stat, options));
91
91
  });
92
92
  }
93
93
  function sync(path5, options) {
94
- return checkStat(fs4.statSync(path5), options);
94
+ return checkStat(fs5.statSync(path5), options);
95
95
  }
96
96
  function checkStat(stat, options) {
97
97
  return stat.isFile() && checkMode(stat, options);
@@ -116,7 +116,7 @@ var require_mode = __commonJS({
116
116
  var require_isexe = __commonJS({
117
117
  "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
118
118
  "use strict";
119
- var fs4 = __require("fs");
119
+ var fs5 = __require("fs");
120
120
  var core;
121
121
  if (process.platform === "win32" || global.TESTING_WINDOWS) {
122
122
  core = require_windows();
@@ -134,12 +134,12 @@ var require_isexe = __commonJS({
134
134
  if (typeof Promise !== "function") {
135
135
  throw new TypeError("callback not provided");
136
136
  }
137
- return new Promise(function(resolve13, reject) {
137
+ return new Promise(function(resolve15, reject) {
138
138
  isexe(path5, options || {}, function(er, is) {
139
139
  if (er) {
140
140
  reject(er);
141
141
  } else {
142
- resolve13(is);
142
+ resolve15(is);
143
143
  }
144
144
  });
145
145
  });
@@ -206,27 +206,27 @@ var require_which = __commonJS({
206
206
  opt = {};
207
207
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
208
208
  const found = [];
209
- const step = (i) => new Promise((resolve13, reject) => {
209
+ const step = (i) => new Promise((resolve15, reject) => {
210
210
  if (i === pathEnv.length)
211
- return opt.all && found.length ? resolve13(found) : reject(getNotFoundError(cmd));
211
+ return opt.all && found.length ? resolve15(found) : reject(getNotFoundError(cmd));
212
212
  const ppRaw = pathEnv[i];
213
213
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
214
214
  const pCmd = path5.join(pathPart, cmd);
215
215
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
216
- resolve13(subStep(p, i, 0));
216
+ resolve15(subStep(p, i, 0));
217
217
  });
218
- const subStep = (p, i, ii) => new Promise((resolve13, reject) => {
218
+ const subStep = (p, i, ii) => new Promise((resolve15, reject) => {
219
219
  if (ii === pathExt.length)
220
- return resolve13(step(i + 1));
220
+ return resolve15(step(i + 1));
221
221
  const ext = pathExt[ii];
222
222
  isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
223
223
  if (!er && is) {
224
224
  if (opt.all)
225
225
  found.push(p + ext);
226
226
  else
227
- return resolve13(p + ext);
227
+ return resolve15(p + ext);
228
228
  }
229
- return resolve13(subStep(p, i, ii + 1));
229
+ return resolve15(subStep(p, i, ii + 1));
230
230
  });
231
231
  });
232
232
  return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
@@ -381,16 +381,16 @@ var require_shebang_command = __commonJS({
381
381
  var require_readShebang = __commonJS({
382
382
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
383
383
  "use strict";
384
- var fs4 = __require("fs");
384
+ var fs5 = __require("fs");
385
385
  var shebangCommand = require_shebang_command();
386
386
  function readShebang(command) {
387
387
  const size = 150;
388
388
  const buffer = Buffer.alloc(size);
389
389
  let fd;
390
390
  try {
391
- fd = fs4.openSync(command, "r");
392
- fs4.readSync(fd, buffer, 0, size, 0);
393
- fs4.closeSync(fd);
391
+ fd = fs5.openSync(command, "r");
392
+ fs5.readSync(fd, buffer, 0, size, 0);
393
+ fs5.closeSync(fd);
394
394
  } catch (e2) {
395
395
  }
396
396
  return shebangCommand(buffer.toString());
@@ -438,7 +438,7 @@ var require_parse = __commonJS({
438
438
  }
439
439
  return parsed;
440
440
  }
441
- function parse5(command, args, options) {
441
+ function parse6(command, args, options) {
442
442
  if (args && !Array.isArray(args)) {
443
443
  options = args;
444
444
  args = null;
@@ -457,7 +457,7 @@ var require_parse = __commonJS({
457
457
  };
458
458
  return options.shell ? parsed : parseNonShell(parsed);
459
459
  }
460
- module.exports = parse5;
460
+ module.exports = parse6;
461
461
  }
462
462
  });
463
463
 
@@ -516,16 +516,16 @@ var require_cross_spawn = __commonJS({
516
516
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports, module) {
517
517
  "use strict";
518
518
  var cp = __require("child_process");
519
- var parse5 = require_parse();
519
+ var parse6 = require_parse();
520
520
  var enoent = require_enoent();
521
521
  function spawn4(command, args, options) {
522
- const parsed = parse5(command, args, options);
522
+ const parsed = parse6(command, args, options);
523
523
  const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
524
524
  enoent.hookChildProcess(spawned, parsed);
525
525
  return spawned;
526
526
  }
527
527
  function spawnSync(command, args, options) {
528
- const parsed = parse5(command, args, options);
528
+ const parsed = parse6(command, args, options);
529
529
  const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
530
530
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
531
531
  return result;
@@ -533,7 +533,7 @@ var require_cross_spawn = __commonJS({
533
533
  module.exports = spawn4;
534
534
  module.exports.spawn = spawn4;
535
535
  module.exports.sync = spawnSync;
536
- module.exports._parse = parse5;
536
+ module.exports._parse = parse6;
537
537
  module.exports._enoent = enoent;
538
538
  }
539
539
  });
@@ -4235,10 +4235,10 @@ var require_typescript = __commonJS({
4235
4235
  function and(f2, g2) {
4236
4236
  return (arg) => f2(arg) && g2(arg);
4237
4237
  }
4238
- function or(...fs4) {
4238
+ function or(...fs5) {
4239
4239
  return (...args) => {
4240
4240
  let lastResult;
4241
- for (const f2 of fs4) {
4241
+ for (const f2 of fs5) {
4242
4242
  lastResult = f2(...args);
4243
4243
  if (lastResult) {
4244
4244
  return lastResult;
@@ -5813,7 +5813,7 @@ ${lanes.join("\n")}
5813
5813
  var tracing;
5814
5814
  var tracingEnabled;
5815
5815
  ((tracingEnabled2) => {
5816
- let fs4;
5816
+ let fs5;
5817
5817
  let traceCount = 0;
5818
5818
  let traceFd = 0;
5819
5819
  let mode;
@@ -5822,9 +5822,9 @@ ${lanes.join("\n")}
5822
5822
  const legend = [];
5823
5823
  function startTracing2(tracingMode, traceDir, configFilePath) {
5824
5824
  Debug.assert(!tracing, "Tracing already started");
5825
- if (fs4 === void 0) {
5825
+ if (fs5 === void 0) {
5826
5826
  try {
5827
- fs4 = __require("fs");
5827
+ fs5 = __require("fs");
5828
5828
  } catch (e2) {
5829
5829
  throw new Error(`tracing requires having fs
5830
5830
  (original error: ${e2.message || e2})`);
@@ -5835,8 +5835,8 @@ ${lanes.join("\n")}
5835
5835
  if (legendPath === void 0) {
5836
5836
  legendPath = combinePaths(traceDir, "legend.json");
5837
5837
  }
5838
- if (!fs4.existsSync(traceDir)) {
5839
- fs4.mkdirSync(traceDir, { recursive: true });
5838
+ if (!fs5.existsSync(traceDir)) {
5839
+ fs5.mkdirSync(traceDir, { recursive: true });
5840
5840
  }
5841
5841
  const countPart = mode === "build" ? `.${process.pid}-${++traceCount}` : mode === "server" ? `.${process.pid}` : ``;
5842
5842
  const tracePath = combinePaths(traceDir, `trace${countPart}.json`);
@@ -5846,10 +5846,10 @@ ${lanes.join("\n")}
5846
5846
  tracePath,
5847
5847
  typesPath
5848
5848
  });
5849
- traceFd = fs4.openSync(tracePath, "w");
5849
+ traceFd = fs5.openSync(tracePath, "w");
5850
5850
  tracing = tracingEnabled2;
5851
5851
  const meta = { cat: "__metadata", ph: "M", ts: 1e3 * timestamp(), pid: 1, tid: 1 };
5852
- fs4.writeSync(
5852
+ fs5.writeSync(
5853
5853
  traceFd,
5854
5854
  "[\n" + [{ name: "process_name", args: { name: "tsc" }, ...meta }, { name: "thread_name", args: { name: "Main" }, ...meta }, { name: "TracingStartedInBrowser", ...meta, cat: "disabled-by-default-devtools.timeline" }].map((v2) => JSON.stringify(v2)).join(",\n")
5855
5855
  );
@@ -5858,10 +5858,10 @@ ${lanes.join("\n")}
5858
5858
  function stopTracing() {
5859
5859
  Debug.assert(tracing, "Tracing is not in progress");
5860
5860
  Debug.assert(!!typeCatalog.length === (mode !== "server"));
5861
- fs4.writeSync(traceFd, `
5861
+ fs5.writeSync(traceFd, `
5862
5862
  ]
5863
5863
  `);
5864
- fs4.closeSync(traceFd);
5864
+ fs5.closeSync(traceFd);
5865
5865
  tracing = void 0;
5866
5866
  if (typeCatalog.length) {
5867
5867
  dumpTypes(typeCatalog);
@@ -5933,11 +5933,11 @@ ${lanes.join("\n")}
5933
5933
  function writeEvent(eventType, phase, name, args, extras, time = 1e3 * timestamp()) {
5934
5934
  if (mode === "server" && phase === "checkTypes") return;
5935
5935
  mark("beginTracing");
5936
- fs4.writeSync(traceFd, `,
5936
+ fs5.writeSync(traceFd, `,
5937
5937
  {"pid":1,"tid":1,"ph":"${eventType}","cat":"${phase}","ts":${time},"name":"${name}"`);
5938
- if (extras) fs4.writeSync(traceFd, `,${extras}`);
5939
- if (args) fs4.writeSync(traceFd, `,"args":${JSON.stringify(args)}`);
5940
- fs4.writeSync(traceFd, `}`);
5938
+ if (extras) fs5.writeSync(traceFd, `,${extras}`);
5939
+ if (args) fs5.writeSync(traceFd, `,"args":${JSON.stringify(args)}`);
5940
+ fs5.writeSync(traceFd, `}`);
5941
5941
  mark("endTracing");
5942
5942
  measure("Tracing", "beginTracing", "endTracing");
5943
5943
  }
@@ -5959,9 +5959,9 @@ ${lanes.join("\n")}
5959
5959
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
5960
5960
  mark("beginDumpTypes");
5961
5961
  const typesPath = legend[legend.length - 1].typesPath;
5962
- const typesFd = fs4.openSync(typesPath, "w");
5962
+ const typesFd = fs5.openSync(typesPath, "w");
5963
5963
  const recursionIdentityMap = /* @__PURE__ */ new Map();
5964
- fs4.writeSync(typesFd, "[");
5964
+ fs5.writeSync(typesFd, "[");
5965
5965
  const numTypes = types.length;
5966
5966
  for (let i = 0; i < numTypes; i++) {
5967
5967
  const type = types[i];
@@ -6057,13 +6057,13 @@ ${lanes.join("\n")}
6057
6057
  flags: Debug.formatTypeFlags(type.flags).split("|"),
6058
6058
  display
6059
6059
  };
6060
- fs4.writeSync(typesFd, JSON.stringify(descriptor));
6060
+ fs5.writeSync(typesFd, JSON.stringify(descriptor));
6061
6061
  if (i < numTypes - 1) {
6062
- fs4.writeSync(typesFd, ",\n");
6062
+ fs5.writeSync(typesFd, ",\n");
6063
6063
  }
6064
6064
  }
6065
- fs4.writeSync(typesFd, "]\n");
6066
- fs4.closeSync(typesFd);
6065
+ fs5.writeSync(typesFd, "]\n");
6066
+ fs5.closeSync(typesFd);
6067
6067
  mark("endDumpTypes");
6068
6068
  measure("Dump types", "beginDumpTypes", "endDumpTypes");
6069
6069
  }
@@ -6071,7 +6071,7 @@ ${lanes.join("\n")}
6071
6071
  if (!legendPath) {
6072
6072
  return;
6073
6073
  }
6074
- fs4.writeFileSync(legendPath, JSON.stringify(legend));
6074
+ fs5.writeFileSync(legendPath, JSON.stringify(legend));
6075
6075
  }
6076
6076
  tracingEnabled2.dumpLegend = dumpLegend;
6077
6077
  })(tracingEnabled || (tracingEnabled = {}));
@@ -9218,7 +9218,7 @@ ${lanes.join("\n")}
9218
9218
  return process.memoryUsage().heapUsed;
9219
9219
  },
9220
9220
  getFileSize(path5) {
9221
- const stat = statSync9(path5);
9221
+ const stat = statSync8(path5);
9222
9222
  if (stat == null ? void 0 : stat.isFile()) {
9223
9223
  return stat.size;
9224
9224
  }
@@ -9262,7 +9262,7 @@ ${lanes.join("\n")}
9262
9262
  }
9263
9263
  };
9264
9264
  return nodeSystem;
9265
- function statSync9(path5) {
9265
+ function statSync8(path5) {
9266
9266
  try {
9267
9267
  return _fs.statSync(path5, statSyncOptions);
9268
9268
  } catch {
@@ -9321,7 +9321,7 @@ ${lanes.join("\n")}
9321
9321
  activeSession.post("Profiler.stop", (err, { profile }) => {
9322
9322
  var _a;
9323
9323
  if (!err) {
9324
- if ((_a = statSync9(profilePath)) == null ? void 0 : _a.isDirectory()) {
9324
+ if ((_a = statSync8(profilePath)) == null ? void 0 : _a.isDirectory()) {
9325
9325
  profilePath = _path.join(profilePath, `${(/* @__PURE__ */ new Date()).toISOString().replace(/:/g, "-")}+P${process.pid}.cpuprofile`);
9326
9326
  }
9327
9327
  try {
@@ -9441,7 +9441,7 @@ ${lanes.join("\n")}
9441
9441
  let stat;
9442
9442
  if (typeof dirent === "string" || dirent.isSymbolicLink()) {
9443
9443
  const name = combinePaths(path5, entry);
9444
- stat = statSync9(name);
9444
+ stat = statSync8(name);
9445
9445
  if (!stat) {
9446
9446
  continue;
9447
9447
  }
@@ -9465,7 +9465,7 @@ ${lanes.join("\n")}
9465
9465
  return matchFiles(path5, extensions, excludes, includes, useCaseSensitiveFileNames2, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
9466
9466
  }
9467
9467
  function fileSystemEntryExists(path5, entryKind) {
9468
- const stat = statSync9(path5);
9468
+ const stat = statSync8(path5);
9469
9469
  if (!stat) {
9470
9470
  return false;
9471
9471
  }
@@ -9507,7 +9507,7 @@ ${lanes.join("\n")}
9507
9507
  }
9508
9508
  function getModifiedTime3(path5) {
9509
9509
  var _a;
9510
- return (_a = statSync9(path5)) == null ? void 0 : _a.mtime;
9510
+ return (_a = statSync8(path5)) == null ? void 0 : _a.mtime;
9511
9511
  }
9512
9512
  function setModifiedTime(path5, time) {
9513
9513
  try {
@@ -124293,7 +124293,7 @@ ${lanes.join("\n")}
124293
124293
  }
124294
124294
  }
124295
124295
  function createImportCallExpressionAMD(arg, containsLexicalThis) {
124296
- const resolve13 = factory2.createUniqueName("resolve");
124296
+ const resolve15 = factory2.createUniqueName("resolve");
124297
124297
  const reject = factory2.createUniqueName("reject");
124298
124298
  const parameters = [
124299
124299
  factory2.createParameterDeclaration(
@@ -124302,7 +124302,7 @@ ${lanes.join("\n")}
124302
124302
  /*dotDotDotToken*/
124303
124303
  void 0,
124304
124304
  /*name*/
124305
- resolve13
124305
+ resolve15
124306
124306
  ),
124307
124307
  factory2.createParameterDeclaration(
124308
124308
  /*modifiers*/
@@ -124319,7 +124319,7 @@ ${lanes.join("\n")}
124319
124319
  factory2.createIdentifier("require"),
124320
124320
  /*typeArguments*/
124321
124321
  void 0,
124322
- [factory2.createArrayLiteralExpression([arg || factory2.createOmittedExpression()]), resolve13, reject]
124322
+ [factory2.createArrayLiteralExpression([arg || factory2.createOmittedExpression()]), resolve15, reject]
124323
124323
  )
124324
124324
  )
124325
124325
  ]);
@@ -137129,9 +137129,9 @@ ${lanes.join("\n")}
137129
137129
  /*ignoreCase*/
137130
137130
  false
137131
137131
  )) {
137132
- const basename7 = getBaseFileName(a3.fileName);
137133
- if (basename7 === "lib.d.ts" || basename7 === "lib.es6.d.ts") return 0;
137134
- const name = removeSuffix(removePrefix(basename7, "lib."), ".d.ts");
137132
+ const basename8 = getBaseFileName(a3.fileName);
137133
+ if (basename8 === "lib.d.ts" || basename8 === "lib.es6.d.ts") return 0;
137134
+ const name = removeSuffix(removePrefix(basename8, "lib."), ".d.ts");
137135
137135
  const index = libs.indexOf(name);
137136
137136
  if (index !== -1) return index + 1;
137137
137137
  }
@@ -187467,7 +187467,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
187467
187467
  return ts_textChanges_exports.ChangeTracker.with(
187468
187468
  { host, formatContext, preferences },
187469
187469
  (changeTracker) => {
187470
- const parsed = contents.map((c2) => parse5(sourceFile, c2));
187470
+ const parsed = contents.map((c2) => parse6(sourceFile, c2));
187471
187471
  const flattenedLocations = focusLocations && flatten(focusLocations);
187472
187472
  for (const nodes of parsed) {
187473
187473
  placeNodeGroup(
@@ -187480,7 +187480,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
187480
187480
  }
187481
187481
  );
187482
187482
  }
187483
- function parse5(sourceFile, content) {
187483
+ function parse6(sourceFile, content) {
187484
187484
  const nodeKinds = [
187485
187485
  {
187486
187486
  parse: () => createSourceFile(
@@ -200877,8 +200877,8 @@ ${options.prefix}` : "\n" : options.prefix
200877
200877
  }
200878
200878
  };
200879
200879
  for (const file of files) {
200880
- const basename7 = getBaseFileName(file);
200881
- if (basename7 === "package.json" || basename7 === "bower.json") {
200880
+ const basename8 = getBaseFileName(file);
200881
+ if (basename8 === "package.json" || basename8 === "bower.json") {
200882
200882
  createProjectWatcher(
200883
200883
  file,
200884
200884
  "FileWatcher"
@@ -204550,8 +204550,8 @@ All files are: ${JSON.stringify(names)}`,
204550
204550
  var _a;
204551
204551
  const fileOrDirectoryPath = removeIgnoredPath(this.toPath(fileOrDirectory));
204552
204552
  if (!fileOrDirectoryPath) return;
204553
- const basename7 = getBaseFileName(fileOrDirectoryPath);
204554
- if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (basename7 === "package.json" || basename7 === "node_modules")) {
204553
+ const basename8 = getBaseFileName(fileOrDirectoryPath);
204554
+ if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (basename8 === "package.json" || basename8 === "node_modules")) {
204555
204555
  result.affectedModuleSpecifierCacheProjects.forEach((project) => {
204556
204556
  var _a2;
204557
204557
  (_a2 = project.getModuleSpecifierCache()) == null ? void 0 : _a2.clear();
@@ -211037,8 +211037,8 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
211037
211037
  installPackage(options) {
211038
211038
  this.packageInstallId++;
211039
211039
  const request = { kind: "installPackage", ...options, id: this.packageInstallId };
211040
- const promise = new Promise((resolve13, reject) => {
211041
- (this.packageInstalledPromise ?? (this.packageInstalledPromise = /* @__PURE__ */ new Map())).set(this.packageInstallId, { resolve: resolve13, reject });
211040
+ const promise = new Promise((resolve15, reject) => {
211041
+ (this.packageInstalledPromise ?? (this.packageInstalledPromise = /* @__PURE__ */ new Map())).set(this.packageInstallId, { resolve: resolve15, reject });
211042
211042
  });
211043
211043
  this.installer.send(request);
211044
211044
  return promise;
@@ -211378,7 +211378,7 @@ var require_src = __commonJS({
211378
211378
 
211379
211379
  // src/index.ts
211380
211380
  import { Command } from "commander";
211381
- import picocolors23 from "picocolors";
211381
+ import picocolors25 from "picocolors";
211382
211382
 
211383
211383
  // ../shared/dist/index.js
211384
211384
  import { randomUUID } from "crypto";
@@ -211661,7 +211661,7 @@ import { homedir as homedir3 } from "os";
211661
211661
  import { join as join3 } from "path";
211662
211662
  import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
211663
211663
  import { parse } from "yaml";
211664
- import { execFileSync } from "child_process";
211664
+ import { execFileSync as execFileSync2 } from "child_process";
211665
211665
  import {
211666
211666
  chmodSync,
211667
211667
  existsSync as existsSync4,
@@ -211674,6 +211674,8 @@ import {
211674
211674
  import { join as join2 } from "path";
211675
211675
  import { homedir } from "os";
211676
211676
  import crypto from "crypto";
211677
+ import { z as z3 } from "zod";
211678
+ import { execFileSync } from "child_process";
211677
211679
  import { z as z2 } from "zod";
211678
211680
  import crypto2 from "crypto";
211679
211681
  import {
@@ -211689,7 +211691,7 @@ import {
211689
211691
  } from "fs";
211690
211692
  import { homedir as homedir2 } from "os";
211691
211693
  import { join as join22 } from "path";
211692
- import { z as z3 } from "zod";
211694
+ import { z as z4 } from "zod";
211693
211695
  var ORBIT_CONFIG_SCHEMA_VERSION = 1;
211694
211696
  var ModelKindSchema = z.enum([
211695
211697
  "chat",
@@ -212068,15 +212070,85 @@ var DEFAULT_CONFIG = {
212068
212070
  scrollSpeed: 50
212069
212071
  }
212070
212072
  };
212071
- var CredentialKeySchema = z2.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/).refine(
212073
+ var EncodedCredentialKeySchema = z2.string().trim().refine((value) => Buffer.from(value, "base64").length === 32);
212074
+ var MacOSKeychainKeyStore = class {
212075
+ service;
212076
+ account;
212077
+ run;
212078
+ constructor(options = {}) {
212079
+ this.service = options.service ?? "dev.hephaestus.orbit.credentials";
212080
+ this.account = options.account ?? "master-key";
212081
+ this.run = options.run ?? runSecurityCommand;
212082
+ }
212083
+ load() {
212084
+ try {
212085
+ const encoded = EncodedCredentialKeySchema.parse(
212086
+ this.run("security", [
212087
+ "find-generic-password",
212088
+ "-a",
212089
+ this.account,
212090
+ "-s",
212091
+ this.service,
212092
+ "-w"
212093
+ ])
212094
+ );
212095
+ return Buffer.from(encoded, "base64");
212096
+ } catch (error) {
212097
+ if (isMissingKeychainItem(error)) return null;
212098
+ throw new Error("Unable to read the Orbit credential key from Keychain.");
212099
+ }
212100
+ }
212101
+ store(key) {
212102
+ if (key.length !== 32) {
212103
+ throw new Error("Credential key must contain exactly 32 bytes.");
212104
+ }
212105
+ this.run("security", [
212106
+ "add-generic-password",
212107
+ "-U",
212108
+ "-a",
212109
+ this.account,
212110
+ "-s",
212111
+ this.service,
212112
+ "-w",
212113
+ key.toString("base64")
212114
+ ]);
212115
+ }
212116
+ delete() {
212117
+ try {
212118
+ this.run("security", [
212119
+ "delete-generic-password",
212120
+ "-a",
212121
+ this.account,
212122
+ "-s",
212123
+ this.service
212124
+ ]);
212125
+ } catch (error) {
212126
+ if (!isMissingKeychainItem(error)) {
212127
+ throw new Error(
212128
+ "Unable to remove the Orbit credential key from Keychain."
212129
+ );
212130
+ }
212131
+ }
212132
+ }
212133
+ };
212134
+ function runSecurityCommand(executable, args) {
212135
+ return execFileSync(executable, args, {
212136
+ encoding: "utf8",
212137
+ stdio: ["ignore", "pipe", "ignore"]
212138
+ });
212139
+ }
212140
+ function isMissingKeychainItem(error) {
212141
+ return typeof error === "object" && error !== null && ("status" in error && error.status === 44 || "code" in error && error.code === "ENOENT");
212142
+ }
212143
+ var CredentialKeySchema = z3.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/).refine(
212072
212144
  (value) => value !== "__proto__" && value !== "constructor" && value !== "prototype"
212073
212145
  );
212074
- var CredentialValueSchema = z2.string().min(1).max(16384).refine((value) => !/[\r\n]/.test(value));
212075
- var SecretsFileSchema = z2.record(CredentialKeySchema, z2.string());
212076
- var EncryptedSecretSchema = z2.object({
212077
- iv: z2.string().regex(/^[0-9a-f]{24}$/i),
212078
- encrypted: z2.string().regex(/^[0-9a-f]*$/i),
212079
- tag: z2.string().regex(/^[0-9a-f]{32}$/i)
212146
+ var CredentialValueSchema = z3.string().min(1).max(16384).refine((value) => !/[\r\n]/.test(value));
212147
+ var SecretsFileSchema = z3.record(CredentialKeySchema, z3.string());
212148
+ var EncryptedSecretSchema = z3.object({
212149
+ iv: z3.string().regex(/^[0-9a-f]{24}$/i),
212150
+ encrypted: z3.string().regex(/^[0-9a-f]*$/i),
212151
+ tag: z3.string().regex(/^[0-9a-f]{32}$/i)
212080
212152
  });
212081
212153
  function windowsPowerShellEnvironment() {
212082
212154
  const environment = { ...process.env };
@@ -212092,12 +212164,15 @@ var CredentialsManager = class {
212092
212164
  secretsPath;
212093
212165
  masterKeyPath;
212094
212166
  isWindows;
212167
+ keyStore;
212095
212168
  fallbackKey;
212096
212169
  constructor(options = {}) {
212097
212170
  this.orbitDir = options.orbitDir ?? join2(homedir(), ".orbit");
212098
212171
  this.secretsPath = join2(this.orbitDir, "secrets.json");
212099
212172
  this.masterKeyPath = join2(this.orbitDir, "master.key");
212100
- this.isWindows = (options.platform ?? process.platform) === "win32";
212173
+ const platform = options.platform ?? process.platform;
212174
+ this.isWindows = platform === "win32";
212175
+ this.keyStore = options.keyStore === void 0 ? platform === "darwin" ? new MacOSKeychainKeyStore() : null : options.keyStore;
212101
212176
  this.fallbackKey = options.fallbackKey;
212102
212177
  }
212103
212178
  /**
@@ -212147,6 +212222,13 @@ var CredentialsManager = class {
212147
212222
  validatedKey.data
212148
212223
  );
212149
212224
  }
212225
+ /** Remove encrypted credentials and their platform key without revealing data. */
212226
+ purge() {
212227
+ this.keyStore?.delete();
212228
+ this.removeFileIfPresent(this.secretsPath);
212229
+ this.removeFileIfPresent(this.masterKeyPath);
212230
+ this.fallbackKey = void 0;
212231
+ }
212150
212232
  loadSecretsFile() {
212151
212233
  if (!existsSync4(this.secretsPath)) {
212152
212234
  return {};
@@ -212182,7 +212264,7 @@ var CredentialsManager = class {
212182
212264
  encryptWindows(plainText) {
212183
212265
  try {
212184
212266
  const script = "$plain = [Console]::In.ReadLine(); if ($plain) { $plain | ConvertTo-SecureString -AsPlainText -Force -ErrorAction Stop | ConvertFrom-SecureString -ErrorAction Stop }";
212185
- const stdout = execFileSync(
212267
+ const stdout = execFileSync2(
212186
212268
  "powershell.exe",
212187
212269
  ["-NoProfile", "-NonInteractive", "-Command", script],
212188
212270
  {
@@ -212202,7 +212284,7 @@ var CredentialsManager = class {
212202
212284
  decryptWindows(cipherText) {
212203
212285
  try {
212204
212286
  const script = "$cipher = [Console]::In.ReadLine(); if ($cipher) { $secure = ConvertTo-SecureString $cipher -ErrorAction Stop; $pointer = [IntPtr]::Zero; try { $pointer = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure); [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($pointer) } finally { if ($pointer -ne [IntPtr]::Zero) { [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($pointer) } } }";
212205
- const stdout = execFileSync(
212287
+ const stdout = execFileSync2(
212206
212288
  "powershell.exe",
212207
212289
  ["-NoProfile", "-NonInteractive", "-Command", script],
212208
212290
  {
@@ -212262,19 +212344,30 @@ var CredentialsManager = class {
212262
212344
  }
212263
212345
  return this.fallbackKey;
212264
212346
  }
212265
- if (existsSync4(this.masterKeyPath)) {
212266
- const decoded = Buffer.from(
212267
- readFileSync(this.masterKeyPath, "utf8"),
212268
- "base64"
212269
- );
212270
- if (decoded.length !== 32) {
212271
- throw new Error("Credential master key is invalid.");
212347
+ const platformKey = this.keyStore?.load();
212348
+ if (platformKey) {
212349
+ this.fallbackKey = this.validateFallbackKey(platformKey);
212350
+ return this.fallbackKey;
212351
+ }
212352
+ const legacyKey = this.readMasterKeyFile();
212353
+ if (legacyKey) {
212354
+ if (this.keyStore) {
212355
+ this.keyStore.store(legacyKey);
212356
+ this.removeFileIfPresent(this.masterKeyPath);
212272
212357
  }
212273
- this.fallbackKey = decoded;
212274
- return decoded;
212358
+ this.fallbackKey = legacyKey;
212359
+ return legacyKey;
212275
212360
  }
212276
- this.ensureOrbitDir();
212277
212361
  const generated = crypto.randomBytes(32);
212362
+ if (this.keyStore) {
212363
+ try {
212364
+ this.keyStore.store(generated);
212365
+ this.fallbackKey = generated;
212366
+ return generated;
212367
+ } catch {
212368
+ }
212369
+ }
212370
+ this.ensureOrbitDir();
212278
212371
  writeFileSync2(this.masterKeyPath, generated.toString("base64"), {
212279
212372
  encoding: "utf8",
212280
212373
  mode: 384,
@@ -212284,23 +212377,44 @@ var CredentialsManager = class {
212284
212377
  this.fallbackKey = generated;
212285
212378
  return generated;
212286
212379
  }
212380
+ readMasterKeyFile() {
212381
+ if (!existsSync4(this.masterKeyPath)) return null;
212382
+ return this.validateFallbackKey(
212383
+ Buffer.from(readFileSync(this.masterKeyPath, "utf8"), "base64")
212384
+ );
212385
+ }
212386
+ validateFallbackKey(key) {
212387
+ if (key.length !== 32) {
212388
+ throw new Error("Credential master key is invalid.");
212389
+ }
212390
+ return key;
212391
+ }
212392
+ removeFileIfPresent(filePath) {
212393
+ try {
212394
+ unlinkSync(filePath);
212395
+ } catch (error) {
212396
+ if (typeof error !== "object" || error === null || !("code" in error) || error.code !== "ENOENT") {
212397
+ throw error;
212398
+ }
212399
+ }
212400
+ }
212287
212401
  restrictFilePermissions(filePath) {
212288
212402
  if (this.isWindows) return;
212289
212403
  chmodSync(filePath, 384);
212290
212404
  }
212291
212405
  };
212292
- var ProviderProfileIdSchema = z3.string().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/);
212293
- var ProviderProfileSchema = z3.object({
212406
+ var ProviderProfileIdSchema = z4.string().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/);
212407
+ var ProviderProfileSchema = z4.object({
212294
212408
  id: ProviderProfileIdSchema,
212295
- name: z3.string().trim().min(1).max(120),
212409
+ name: z4.string().trim().min(1).max(120),
212296
212410
  config: ProviderConfigSchema.omit({ apiKey: true }),
212297
- createdAt: z3.string().datetime(),
212298
- updatedAt: z3.string().datetime()
212411
+ createdAt: z4.string().datetime(),
212412
+ updatedAt: z4.string().datetime()
212299
212413
  });
212300
- var ProviderProfilesFileSchema = z3.object({
212301
- version: z3.literal(1).default(1),
212414
+ var ProviderProfilesFileSchema = z4.object({
212415
+ version: z4.literal(1).default(1),
212302
212416
  activeProvider: ProviderProfileIdSchema.optional(),
212303
- profiles: z3.array(ProviderProfileSchema).max(100)
212417
+ profiles: z4.array(ProviderProfileSchema).max(100)
212304
212418
  });
212305
212419
  var EMPTY_SNAPSHOT = {
212306
212420
  version: 1,
@@ -212863,10 +212977,10 @@ import { execSync as execSync2 } from "child_process";
212863
212977
  import { existsSync as existsSync8 } from "fs";
212864
212978
  import { basename, join as join7 } from "path";
212865
212979
  import picocolors5 from "picocolors";
212866
- import { z as z9 } from "zod";
212980
+ import { z as z10 } from "zod";
212867
212981
 
212868
212982
  // ../model-providers/dist/index.js
212869
- import { z as z4 } from "zod";
212983
+ import { z as z5 } from "zod";
212870
212984
  import { z as z22 } from "zod";
212871
212985
  var ProviderRegistry = class {
212872
212986
  providers = /* @__PURE__ */ new Map();
@@ -213097,11 +213211,11 @@ function modelFinishReasonError(reason) {
213097
213211
  return new Error(`Model generation stopped unexpectedly (${reason}).`);
213098
213212
  }
213099
213213
  function abortableDelay(delayMs, signal) {
213100
- return new Promise((resolve13, reject) => {
213214
+ return new Promise((resolve15, reject) => {
213101
213215
  const cleanup = () => signal?.removeEventListener("abort", onAbort);
213102
213216
  const timeoutId = setTimeout(() => {
213103
213217
  cleanup();
213104
- resolve13();
213218
+ resolve15();
213105
213219
  }, delayMs);
213106
213220
  timeoutId.unref?.();
213107
213221
  function onAbort() {
@@ -213188,52 +213302,52 @@ function getDeepSeekV4ModelProfile(model) {
213188
213302
  function getDeepSeekReasoningEffort(budgetTokens = 4096) {
213189
213303
  return budgetTokens >= 8192 ? "max" : "high";
213190
213304
  }
213191
- var AnthropicUsageSchema = z4.object({
213192
- input_tokens: z4.number().int().nonnegative().optional(),
213193
- output_tokens: z4.number().int().nonnegative().optional(),
213194
- cache_read_input_tokens: z4.number().int().nonnegative().optional(),
213195
- cache_creation_input_tokens: z4.number().int().nonnegative().optional()
213305
+ var AnthropicUsageSchema = z5.object({
213306
+ input_tokens: z5.number().int().nonnegative().optional(),
213307
+ output_tokens: z5.number().int().nonnegative().optional(),
213308
+ cache_read_input_tokens: z5.number().int().nonnegative().optional(),
213309
+ cache_creation_input_tokens: z5.number().int().nonnegative().optional()
213196
213310
  }).passthrough();
213197
- var AnthropicErrorSchema = z4.object({
213198
- message: z4.string(),
213199
- type: z4.string().optional()
213311
+ var AnthropicErrorSchema = z5.object({
213312
+ message: z5.string(),
213313
+ type: z5.string().optional()
213200
213314
  }).passthrough();
213201
- var AnthropicContentBlockSchema = z4.discriminatedUnion("type", [
213202
- z4.object({
213203
- type: z4.literal("text"),
213204
- text: z4.string()
213315
+ var AnthropicContentBlockSchema = z5.discriminatedUnion("type", [
213316
+ z5.object({
213317
+ type: z5.literal("text"),
213318
+ text: z5.string()
213205
213319
  }).passthrough(),
213206
- z4.object({
213207
- type: z4.literal("thinking"),
213208
- thinking: z4.string(),
213209
- signature: z4.string().optional()
213320
+ z5.object({
213321
+ type: z5.literal("thinking"),
213322
+ thinking: z5.string(),
213323
+ signature: z5.string().optional()
213210
213324
  }).passthrough(),
213211
- z4.object({
213212
- type: z4.literal("tool_use"),
213213
- id: z4.string().min(1),
213214
- name: z4.string().min(1),
213215
- input: z4.record(z4.unknown())
213325
+ z5.object({
213326
+ type: z5.literal("tool_use"),
213327
+ id: z5.string().min(1),
213328
+ name: z5.string().min(1),
213329
+ input: z5.record(z5.unknown())
213216
213330
  }).passthrough()
213217
213331
  ]);
213218
- var AnthropicMessageResponseSchema = z4.object({
213219
- content: z4.array(AnthropicContentBlockSchema),
213332
+ var AnthropicMessageResponseSchema = z5.object({
213333
+ content: z5.array(AnthropicContentBlockSchema),
213220
213334
  usage: AnthropicUsageSchema.optional(),
213221
- stop_reason: z4.string().nullable().optional()
213335
+ stop_reason: z5.string().nullable().optional()
213222
213336
  }).passthrough();
213223
- var OfficialDeepSeekUserIdSchema = z4.string().min(1).max(512).regex(/^[A-Za-z0-9_-]+$/);
213224
- var OfficialDeepSeekToolNameSchema = z4.string().min(1).max(64).regex(/^[A-Za-z0-9_-]+$/);
213225
- var AnthropicStreamEventSchema = z4.object({
213226
- type: z4.string(),
213227
- index: z4.number().int().nonnegative().optional(),
213228
- message: z4.object({ usage: AnthropicUsageSchema.optional() }).passthrough().optional(),
213337
+ var OfficialDeepSeekUserIdSchema = z5.string().min(1).max(512).regex(/^[A-Za-z0-9_-]+$/);
213338
+ var OfficialDeepSeekToolNameSchema = z5.string().min(1).max(64).regex(/^[A-Za-z0-9_-]+$/);
213339
+ var AnthropicStreamEventSchema = z5.object({
213340
+ type: z5.string(),
213341
+ index: z5.number().int().nonnegative().optional(),
213342
+ message: z5.object({ usage: AnthropicUsageSchema.optional() }).passthrough().optional(),
213229
213343
  content_block: AnthropicContentBlockSchema.optional(),
213230
- delta: z4.object({
213231
- type: z4.string().optional(),
213232
- text: z4.string().optional(),
213233
- thinking: z4.string().optional(),
213234
- signature: z4.string().optional(),
213235
- partial_json: z4.string().optional(),
213236
- stop_reason: z4.string().nullable().optional()
213344
+ delta: z5.object({
213345
+ type: z5.string().optional(),
213346
+ text: z5.string().optional(),
213347
+ thinking: z5.string().optional(),
213348
+ signature: z5.string().optional(),
213349
+ partial_json: z5.string().optional(),
213350
+ stop_reason: z5.string().nullable().optional()
213237
213351
  }).passthrough().optional(),
213238
213352
  usage: AnthropicUsageSchema.optional(),
213239
213353
  error: AnthropicErrorSchema.optional()
@@ -215015,22 +215129,22 @@ function normalizeOllamaOpenAiBaseUrl(baseUrl) {
215015
215129
  import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync4 } from "fs";
215016
215130
  import { join as join4 } from "path";
215017
215131
  import picocolors3 from "picocolors";
215018
- import { z as z5 } from "zod";
215019
- var CacheTelemetrySampleSchema = z5.object({
215020
- recordedAt: z5.string(),
215021
- inputTokens: z5.number().nonnegative(),
215022
- hitTokens: z5.number().nonnegative(),
215023
- missTokens: z5.number().nonnegative(),
215024
- hitRate: z5.number().min(0).max(1),
215025
- degraded: z5.boolean()
215132
+ import { z as z6 } from "zod";
215133
+ var CacheTelemetrySampleSchema = z6.object({
215134
+ recordedAt: z6.string(),
215135
+ inputTokens: z6.number().nonnegative(),
215136
+ hitTokens: z6.number().nonnegative(),
215137
+ missTokens: z6.number().nonnegative(),
215138
+ hitRate: z6.number().min(0).max(1),
215139
+ degraded: z6.boolean()
215026
215140
  }).passthrough();
215027
- var CacheSlabMetadataSchema = z5.object({
215028
- hash: z5.string().optional(),
215029
- model: z5.string().optional(),
215030
- tokenEstimate: z5.number().nonnegative().optional(),
215141
+ var CacheSlabMetadataSchema = z6.object({
215142
+ hash: z6.string().optional(),
215143
+ model: z6.string().optional(),
215144
+ tokenEstimate: z6.number().nonnegative().optional(),
215031
215145
  /** Read-only compatibility with cache metadata from pre-V4 releases. */
215032
- lastPrimedAt: z5.string().optional(),
215033
- telemetry: z5.array(CacheTelemetrySampleSchema).optional()
215146
+ lastPrimedAt: z6.string().optional(),
215147
+ telemetry: z6.array(CacheTelemetrySampleSchema).optional()
215034
215148
  }).passthrough();
215035
215149
  function readMetadata(filePath) {
215036
215150
  try {
@@ -215108,32 +215222,32 @@ import {
215108
215222
  import { createHash } from "crypto";
215109
215223
  import { dirname as dirname2, join as join5 } from "path";
215110
215224
  import picocolors4 from "picocolors";
215111
- import { z as z6 } from "zod";
215112
- var ProviderBenchmarkResultSchema = z6.object({
215113
- providerId: z6.string().min(1),
215114
- model: z6.string().min(1),
215115
- checkedAt: z6.string().min(1),
215116
- promptHash: z6.string().min(1),
215117
- promptChars: z6.number().int().nonnegative(),
215118
- maxTokens: z6.number().int().positive(),
215119
- firstDeltaMs: z6.number().nonnegative().optional(),
215120
- firstThinkingMs: z6.number().nonnegative().optional(),
215121
- firstTextMs: z6.number().nonnegative().optional(),
215122
- totalMs: z6.number().positive(),
215123
- outputTokens: z6.number().int().nonnegative(),
215124
- reasoningTokens: z6.number().int().nonnegative().optional(),
215125
- textChars: z6.number().int().nonnegative(),
215126
- reasoningChars: z6.number().int().nonnegative().optional(),
215127
- throughputTokensPerSec: z6.number().nonnegative(),
215128
- endToEndTokensPerSec: z6.number().nonnegative().optional(),
215129
- thinkingMode: z6.enum(["disabled", "high", "max"]).optional(),
215130
- cacheReadTokens: z6.number().int().nonnegative(),
215131
- cacheInputTokens: z6.number().int().nonnegative(),
215132
- cacheHitRate: z6.number().min(0).max(1),
215133
- error: z6.string().optional()
215225
+ import { z as z7 } from "zod";
215226
+ var ProviderBenchmarkResultSchema = z7.object({
215227
+ providerId: z7.string().min(1),
215228
+ model: z7.string().min(1),
215229
+ checkedAt: z7.string().min(1),
215230
+ promptHash: z7.string().min(1),
215231
+ promptChars: z7.number().int().nonnegative(),
215232
+ maxTokens: z7.number().int().positive(),
215233
+ firstDeltaMs: z7.number().nonnegative().optional(),
215234
+ firstThinkingMs: z7.number().nonnegative().optional(),
215235
+ firstTextMs: z7.number().nonnegative().optional(),
215236
+ totalMs: z7.number().positive(),
215237
+ outputTokens: z7.number().int().nonnegative(),
215238
+ reasoningTokens: z7.number().int().nonnegative().optional(),
215239
+ textChars: z7.number().int().nonnegative(),
215240
+ reasoningChars: z7.number().int().nonnegative().optional(),
215241
+ throughputTokensPerSec: z7.number().nonnegative(),
215242
+ endToEndTokensPerSec: z7.number().nonnegative().optional(),
215243
+ thinkingMode: z7.enum(["disabled", "high", "max"]).optional(),
215244
+ cacheReadTokens: z7.number().int().nonnegative(),
215245
+ cacheInputTokens: z7.number().int().nonnegative(),
215246
+ cacheHitRate: z7.number().min(0).max(1),
215247
+ error: z7.string().optional()
215134
215248
  }).passthrough();
215135
- var ProviderBenchmarkStoreSchema = z6.object({
215136
- results: z6.array(ProviderBenchmarkResultSchema)
215249
+ var ProviderBenchmarkStoreSchema = z7.object({
215250
+ results: z7.array(ProviderBenchmarkResultSchema)
215137
215251
  });
215138
215252
  function providerBenchmarkPath(cwd) {
215139
215253
  return join5(cwd, ".orbit", "provider-benchmarks.json");
@@ -215401,33 +215515,33 @@ import {
215401
215515
  writeFileSync as writeFileSync4
215402
215516
  } from "fs";
215403
215517
  import { dirname as dirname3, join as join6 } from "path";
215404
- import { z as z7 } from "zod";
215518
+ import { z as z8 } from "zod";
215405
215519
  var DEFAULT_PROVIDER_PROBE_TIMEOUT_MS = 15e3;
215406
- var ModelCapabilitiesSchema = z7.object({
215407
- streaming: z7.boolean(),
215408
- toolCalls: z7.boolean(),
215409
- jsonMode: z7.boolean(),
215410
- thinking: z7.boolean(),
215411
- vision: z7.boolean(),
215412
- promptCaching: z7.boolean(),
215413
- maxContextTokens: z7.number().int().positive().optional(),
215414
- maxOutputTokens: z7.number().int().positive().optional()
215520
+ var ModelCapabilitiesSchema = z8.object({
215521
+ streaming: z8.boolean(),
215522
+ toolCalls: z8.boolean(),
215523
+ jsonMode: z8.boolean(),
215524
+ thinking: z8.boolean(),
215525
+ vision: z8.boolean(),
215526
+ promptCaching: z8.boolean(),
215527
+ maxContextTokens: z8.number().int().positive().optional(),
215528
+ maxOutputTokens: z8.number().int().positive().optional()
215415
215529
  }).passthrough();
215416
- var ProviderProbeResultSchema = z7.object({
215417
- providerId: z7.string().min(1),
215418
- model: z7.string().min(1),
215419
- checkedAt: z7.string().min(1),
215530
+ var ProviderProbeResultSchema = z8.object({
215531
+ providerId: z8.string().min(1),
215532
+ model: z8.string().min(1),
215533
+ checkedAt: z8.string().min(1),
215420
215534
  declared: ModelCapabilitiesSchema,
215421
- observed: z7.object({
215422
- streamStarted: z7.boolean(),
215423
- usageReturned: z7.boolean(),
215424
- cacheUsageReturned: z7.boolean().optional(),
215425
- totalTokensReturned: z7.boolean().optional(),
215426
- error: z7.string().optional(),
215427
- firstDeltaMs: z7.number().nonnegative().optional()
215535
+ observed: z8.object({
215536
+ streamStarted: z8.boolean(),
215537
+ usageReturned: z8.boolean(),
215538
+ cacheUsageReturned: z8.boolean().optional(),
215539
+ totalTokensReturned: z8.boolean().optional(),
215540
+ error: z8.string().optional(),
215541
+ firstDeltaMs: z8.number().nonnegative().optional()
215428
215542
  }).passthrough()
215429
215543
  }).passthrough();
215430
- var ProviderProbeCacheSchema = z7.object({ results: z7.array(z7.unknown()) }).passthrough();
215544
+ var ProviderProbeCacheSchema = z8.object({ results: z8.array(z8.unknown()) }).passthrough();
215431
215545
  function providerProbeCachePath(cwd) {
215432
215546
  return join6(cwd, ".orbit", "provider-capabilities.json");
215433
215547
  }
@@ -215619,9 +215733,9 @@ function createProviderFromConfig(config) {
215619
215733
 
215620
215734
  // src/runtime/CliVersion.ts
215621
215735
  import { readFileSync as readFileSync7 } from "fs";
215622
- import { z as z8 } from "zod";
215623
- var CliPackageManifestSchema = z8.object({
215624
- version: z8.string().trim().regex(
215736
+ import { z as z9 } from "zod";
215737
+ var CliPackageManifestSchema = z9.object({
215738
+ version: z9.string().trim().regex(
215625
215739
  /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,
215626
215740
  "expected a semantic version"
215627
215741
  )
@@ -215649,57 +215763,57 @@ function readCliVersion() {
215649
215763
  }
215650
215764
 
215651
215765
  // src/commands/doctor.ts
215652
- var DoctorIssueSchema = z9.object({
215653
- severity: z9.enum(["warning", "error"]),
215654
- code: z9.string().regex(/^[a-z0-9_.-]+$/),
215655
- message: z9.string().min(1).max(2e3),
215656
- remediation: z9.string().min(1).max(2e3)
215766
+ var DoctorIssueSchema = z10.object({
215767
+ severity: z10.enum(["warning", "error"]),
215768
+ code: z10.string().regex(/^[a-z0-9_.-]+$/),
215769
+ message: z10.string().min(1).max(2e3),
215770
+ remediation: z10.string().min(1).max(2e3)
215657
215771
  });
215658
- var DoctorSnapshotSchema = z9.object({
215659
- schemaVersion: z9.literal(1),
215660
- generatedAt: z9.string().datetime(),
215661
- status: z9.enum(["ok", "warning", "error"]),
215662
- orbit: z9.object({
215663
- version: z9.string(),
215664
- configSchemaVersion: z9.number().int()
215772
+ var DoctorSnapshotSchema = z10.object({
215773
+ schemaVersion: z10.literal(1),
215774
+ generatedAt: z10.string().datetime(),
215775
+ status: z10.enum(["ok", "warning", "error"]),
215776
+ orbit: z10.object({
215777
+ version: z10.string(),
215778
+ configSchemaVersion: z10.number().int()
215665
215779
  }),
215666
- runtime: z9.object({
215667
- node: z9.string(),
215668
- nodeSupported: z9.boolean(),
215669
- platform: z9.string(),
215670
- architecture: z9.string(),
215671
- packageManager: z9.string(),
215672
- gitVersion: z9.string().nullable(),
215673
- ripgrepVersion: z9.string().nullable(),
215674
- gitDirty: z9.boolean().nullable()
215780
+ runtime: z10.object({
215781
+ node: z10.string(),
215782
+ nodeSupported: z10.boolean(),
215783
+ platform: z10.string(),
215784
+ architecture: z10.string(),
215785
+ packageManager: z10.string(),
215786
+ gitVersion: z10.string().nullable(),
215787
+ ripgrepVersion: z10.string().nullable(),
215788
+ gitDirty: z10.boolean().nullable()
215675
215789
  }),
215676
- workspace: z9.object({ name: z9.string(), pathRedacted: z9.literal(true) }),
215677
- provider: z9.object({
215678
- id: z9.string(),
215679
- type: z9.string().nullable(),
215680
- baseUrl: z9.string().nullable(),
215681
- apiKeyLoaded: z9.boolean(),
215682
- apiKeySource: z9.string(),
215683
- deepSeekProfile: z9.boolean(),
215684
- models: z9.record(z9.string()),
215685
- probe: z9.string().nullable()
215790
+ workspace: z10.object({ name: z10.string(), pathRedacted: z10.literal(true) }),
215791
+ provider: z10.object({
215792
+ id: z10.string(),
215793
+ type: z10.string().nullable(),
215794
+ baseUrl: z10.string().nullable(),
215795
+ apiKeyLoaded: z10.boolean(),
215796
+ apiKeySource: z10.string(),
215797
+ deepSeekProfile: z10.boolean(),
215798
+ models: z10.record(z10.string()),
215799
+ probe: z10.string().nullable()
215686
215800
  }),
215687
- features: z9.object({
215688
- webSearch: z9.boolean(),
215689
- mcp: z9.boolean(),
215690
- mcpServerCount: z9.number().int().nonnegative(),
215691
- skills: z9.boolean(),
215692
- automaticCompaction: z9.boolean()
215801
+ features: z10.object({
215802
+ webSearch: z10.boolean(),
215803
+ mcp: z10.boolean(),
215804
+ mcpServerCount: z10.number().int().nonnegative(),
215805
+ skills: z10.boolean(),
215806
+ automaticCompaction: z10.boolean()
215693
215807
  }),
215694
- safety: z9.object({
215695
- permissionMode: z9.enum(["strict", "normal", "auto", "plan"]),
215696
- writeApproval: z9.boolean(),
215697
- commandApproval: z9.boolean(),
215698
- dangerousCommandBlocking: z9.boolean(),
215699
- secretProtection: z9.boolean(),
215700
- projectExecutablesTrusted: z9.boolean()
215808
+ safety: z10.object({
215809
+ permissionMode: z10.enum(["strict", "normal", "auto", "plan"]),
215810
+ writeApproval: z10.boolean(),
215811
+ commandApproval: z10.boolean(),
215812
+ dangerousCommandBlocking: z10.boolean(),
215813
+ secretProtection: z10.boolean(),
215814
+ projectExecutablesTrusted: z10.boolean()
215701
215815
  }),
215702
- issues: z9.array(DoctorIssueSchema)
215816
+ issues: z10.array(DoctorIssueSchema)
215703
215817
  });
215704
215818
  function defaultExec(command, options = {}) {
215705
215819
  return execSync2(command, {
@@ -216199,22 +216313,22 @@ async function runDoctor(cwd, options = {}) {
216199
216313
  import picocolors6 from "picocolors";
216200
216314
  import { createHash as createHash2, randomUUID as randomUUID2 } from "crypto";
216201
216315
  import { resolve as resolve2 } from "path";
216202
- import { z as z10 } from "zod";
216203
- var BenchOptionsSchema = z10.object({
216204
- prompt: z10.string().optional(),
216205
- provider: z10.string().optional(),
216206
- model: z10.string().optional(),
216207
- models: z10.string().optional(),
216208
- repeat: z10.union([z10.number(), z10.string()]).optional(),
216209
- maxTokens: z10.union([z10.number(), z10.string()]).optional(),
216210
- cacheProfile: z10.boolean().optional(),
216211
- minCacheHit: z10.union([z10.number(), z10.string()]).optional(),
216212
- maxFirstDeltaMs: z10.union([z10.number(), z10.string()]).optional(),
216213
- maxFirstTextMs: z10.union([z10.number(), z10.string()]).optional(),
216214
- minThroughput: z10.union([z10.number(), z10.string()]).optional(),
216215
- maxErrorRate: z10.union([z10.number(), z10.string()]).optional(),
216216
- thinking: z10.string().optional(),
216217
- json: z10.boolean().optional()
216316
+ import { z as z11 } from "zod";
216317
+ var BenchOptionsSchema = z11.object({
216318
+ prompt: z11.string().optional(),
216319
+ provider: z11.string().optional(),
216320
+ model: z11.string().optional(),
216321
+ models: z11.string().optional(),
216322
+ repeat: z11.union([z11.number(), z11.string()]).optional(),
216323
+ maxTokens: z11.union([z11.number(), z11.string()]).optional(),
216324
+ cacheProfile: z11.boolean().optional(),
216325
+ minCacheHit: z11.union([z11.number(), z11.string()]).optional(),
216326
+ maxFirstDeltaMs: z11.union([z11.number(), z11.string()]).optional(),
216327
+ maxFirstTextMs: z11.union([z11.number(), z11.string()]).optional(),
216328
+ minThroughput: z11.union([z11.number(), z11.string()]).optional(),
216329
+ maxErrorRate: z11.union([z11.number(), z11.string()]).optional(),
216330
+ thinking: z11.string().optional(),
216331
+ json: z11.boolean().optional()
216218
216332
  });
216219
216333
  function parseBenchOptions(value) {
216220
216334
  return BenchOptionsSchema.parse(value);
@@ -216653,7 +216767,7 @@ import { z as z27 } from "zod";
216653
216767
  import { z as z28 } from "zod";
216654
216768
 
216655
216769
  // ../tools/dist/index.js
216656
- import { z as z11 } from "zod";
216770
+ import { z as z12 } from "zod";
216657
216771
  import { readFileSync as readFileSync9 } from "fs";
216658
216772
  import { z as z23 } from "zod";
216659
216773
  import { writeFileSync as writeFileSync5, mkdirSync as mkdirSync5 } from "fs";
@@ -217583,7 +217697,7 @@ var setupTimeout = (spawned, { timeout, killSignal = "SIGTERM" }, spawnedPromise
217583
217697
  return spawnedPromise;
217584
217698
  }
217585
217699
  let timeoutId;
217586
- const timeoutPromise = new Promise((resolve13, reject) => {
217700
+ const timeoutPromise = new Promise((resolve15, reject) => {
217587
217701
  timeoutId = setTimeout(() => {
217588
217702
  timeoutKill(spawned, killSignal, reject);
217589
217703
  }, timeout);
@@ -217949,9 +218063,9 @@ var mergePromise = (spawned, promise) => {
217949
218063
  Reflect.defineProperty(spawned, property, { ...descriptor, value });
217950
218064
  }
217951
218065
  };
217952
- var getSpawnedPromise = (spawned) => new Promise((resolve13, reject) => {
218066
+ var getSpawnedPromise = (spawned) => new Promise((resolve15, reject) => {
217953
218067
  spawned.on("exit", (exitCode, signal) => {
217954
- resolve13({ exitCode, signal });
218068
+ resolve15({ exitCode, signal });
217955
218069
  });
217956
218070
  spawned.on("error", (error) => {
217957
218071
  reject(error);
@@ -218264,7 +218378,7 @@ import { join as join8 } from "path";
218264
218378
  import { z as z92 } from "zod";
218265
218379
  import { z as z102 } from "zod";
218266
218380
  import { z as z112 } from "zod";
218267
- import { z as z12 } from "zod";
218381
+ import { z as z122 } from "zod";
218268
218382
  import { z as z13 } from "zod";
218269
218383
  import { existsSync as existsSync23, readFileSync as readFileSync52 } from "fs";
218270
218384
  import { join as join23 } from "path";
@@ -218295,10 +218409,10 @@ var ToolRegistry = class {
218295
218409
  }
218296
218410
  };
218297
218411
  var toolRegistry = new ToolRegistry();
218298
- var ReadFileInputSchema = z11.object({
218299
- path: z11.string(),
218300
- startLine: z11.number().optional(),
218301
- endLine: z11.number().optional()
218412
+ var ReadFileInputSchema = z12.object({
218413
+ path: z12.string(),
218414
+ startLine: z12.number().optional(),
218415
+ endLine: z12.number().optional()
218302
218416
  });
218303
218417
  var ReadFileTool = class {
218304
218418
  name = "read_file";
@@ -219254,8 +219368,8 @@ ${stdout}`
219254
219368
  }
219255
219369
  }
219256
219370
  };
219257
- var GitRestoreInputSchema = z12.object({
219258
- paths: z12.array(z12.string())
219371
+ var GitRestoreInputSchema = z122.object({
219372
+ paths: z122.array(z122.string())
219259
219373
  });
219260
219374
  var GitRestoreTool = class {
219261
219375
  name = "git_restore";
@@ -220561,7 +220675,7 @@ import {
220561
220675
  } from "fs";
220562
220676
  import { join as join9 } from "path";
220563
220677
  import { existsSync as existsSync24, writeFileSync as writeFileSync24, unlinkSync as unlinkSync3 } from "fs";
220564
- import { execFileSync as execFileSync2 } from "child_process";
220678
+ import { execFileSync as execFileSync3 } from "child_process";
220565
220679
  import fs from "fs";
220566
220680
  import path3 from "path";
220567
220681
  var CheckpointManager = class {
@@ -220849,7 +220963,7 @@ var WorktreeManager = class {
220849
220963
  snapshotWorkingTree(worktreePath) {
220850
220964
  const patch = this.gitBuffer(["diff", "HEAD", "--binary", "--no-ext-diff"]);
220851
220965
  if (patch.length > 0) {
220852
- execFileSync2("git", ["apply", "--whitespace=nowarn", "-"], {
220966
+ execFileSync3("git", ["apply", "--whitespace=nowarn", "-"], {
220853
220967
  cwd: worktreePath,
220854
220968
  input: patch,
220855
220969
  stdio: ["pipe", "pipe", "pipe"],
@@ -220898,7 +221012,7 @@ var WorktreeManager = class {
220898
221012
  session.path
220899
221013
  );
220900
221014
  if (delta.length === 0) return;
220901
- execFileSync2("git", ["apply", "--whitespace=nowarn", "-"], {
221015
+ execFileSync3("git", ["apply", "--whitespace=nowarn", "-"], {
220902
221016
  cwd: this.cwd,
220903
221017
  input: delta,
220904
221018
  stdio: ["pipe", "pipe", "pipe"],
@@ -220906,14 +221020,14 @@ var WorktreeManager = class {
220906
221020
  });
220907
221021
  }
220908
221022
  git(args, cwd = this.cwd) {
220909
- return execFileSync2("git", args, {
221023
+ return execFileSync3("git", args, {
220910
221024
  cwd,
220911
221025
  encoding: "utf8",
220912
221026
  stdio: ["ignore", "pipe", "pipe"]
220913
221027
  });
220914
221028
  }
220915
221029
  gitBuffer(args, cwd = this.cwd) {
220916
- return execFileSync2("git", args, {
221030
+ return execFileSync3("git", args, {
220917
221031
  cwd,
220918
221032
  encoding: "buffer",
220919
221033
  stdio: ["ignore", "pipe", "pipe"],
@@ -224954,7 +225068,7 @@ var Prompt = class {
224954
225068
  });
224955
225069
  }
224956
225070
  static async askTextWithAutocomplete(message, completerFn, promptPrefix) {
224957
- return new Promise((resolve13) => {
225071
+ return new Promise((resolve15) => {
224958
225072
  const promptStr = promptPrefix !== void 0 ? promptPrefix : `${picocolors22.cyan("?")} ${message} \u203A `;
224959
225073
  const rl = readline.createInterface({
224960
225074
  input: process.stdin,
@@ -225021,7 +225135,7 @@ var Prompt = class {
225021
225135
  clearSuggestions();
225022
225136
  rl.close();
225023
225137
  process.stdout.write("\n");
225024
- resolve13(null);
225138
+ resolve15(null);
225025
225139
  return;
225026
225140
  }
225027
225141
  if (currentSuggestion && key && (key.name === "tab" || key.name === "right")) {
@@ -225049,12 +225163,12 @@ var Prompt = class {
225049
225163
  clearSuggestions();
225050
225164
  rl.close();
225051
225165
  process.stdout.write("\n");
225052
- resolve13(null);
225166
+ resolve15(null);
225053
225167
  });
225054
225168
  rl.on("line", (line) => {
225055
225169
  clearSuggestions();
225056
225170
  rl.close();
225057
- resolve13(line);
225171
+ resolve15(line);
225058
225172
  });
225059
225173
  });
225060
225174
  }
@@ -225389,7 +225503,7 @@ var Renderer = class {
225389
225503
  };
225390
225504
 
225391
225505
  // ../core/dist/index.js
225392
- import { z as z63 } from "zod";
225506
+ import { z as z73 } from "zod";
225393
225507
  import { randomUUID as randomUUID5 } from "crypto";
225394
225508
  import {
225395
225509
  chmodSync as chmodSync4,
@@ -225407,12 +225521,11 @@ import { z as z34 } from "zod";
225407
225521
  import { EventEmitter } from "events";
225408
225522
  import { z as z44 } from "zod";
225409
225523
  import picocolors8 from "picocolors";
225410
- import path22 from "path";
225411
- import fs2 from "fs";
225412
- import { createHash as createHash23, randomUUID as randomUUID24 } from "crypto";
225413
- import { exec as exec2, execFile as execFile2 } from "child_process";
225414
- import { promisify as promisify2 } from "util";
225415
- import { createRequire } from "module";
225524
+ import path32 from "path";
225525
+ import fs3 from "fs";
225526
+ import { createHash as createHash32, randomUUID as randomUUID32 } from "crypto";
225527
+ import { exec as exec2, execFile as execFile3 } from "child_process";
225528
+ import { promisify as promisify3 } from "util";
225416
225529
 
225417
225530
  // ../mcp/dist/index.js
225418
225531
  import { spawn } from "child_process";
@@ -225566,7 +225679,7 @@ var MCPClient = class {
225566
225679
  await this.sendRequest("initialize", {
225567
225680
  protocolVersion: "2024-11-05",
225568
225681
  capabilities: {},
225569
- clientInfo: { name: "orbit-client", version: "0.1.5" }
225682
+ clientInfo: { name: "orbit-client", version: "0.1.6" }
225570
225683
  });
225571
225684
  this.sendNotification("notifications/initialized");
225572
225685
  }
@@ -225577,7 +225690,7 @@ var MCPClient = class {
225577
225690
  return result.tools;
225578
225691
  }
225579
225692
  sendRequest(method, params) {
225580
- return new Promise((resolve13, reject) => {
225693
+ return new Promise((resolve15, reject) => {
225581
225694
  const stdin = this.child?.stdin;
225582
225695
  if (!this.isConnected || !stdin || !stdin.writable) {
225583
225696
  reject(new Error("MCP server process is not running."));
@@ -225592,7 +225705,7 @@ var MCPClient = class {
225592
225705
  )
225593
225706
  );
225594
225707
  }, MCP_REQUEST_TIMEOUT_MS);
225595
- this.pendingRequests.set(id, { resolve: resolve13, reject, timeout });
225708
+ this.pendingRequests.set(id, { resolve: resolve15, reject, timeout });
225596
225709
  stdin.write(
225597
225710
  `${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
225598
225711
  `,
@@ -225703,15 +225816,23 @@ var DynamicMCPTool = class {
225703
225816
 
225704
225817
  // ../core/dist/index.js
225705
225818
  import { z as z53 } from "zod";
225706
- import fs3 from "fs";
225819
+ import fs2 from "fs";
225707
225820
  import path4 from "path";
225708
225821
  import { exec, execFile } from "child_process";
225709
225822
  import { promisify } from "util";
225710
- import fs32 from "fs";
225711
- import path32 from "path";
225823
+ import { createHash as createHash23 } from "crypto";
225824
+ import { randomUUID as randomUUID24 } from "crypto";
225825
+ import { z as z63 } from "zod";
225826
+ import fs22 from "fs";
225827
+ import path22 from "path";
225828
+ import { execFile as execFile2 } from "child_process";
225829
+ import { createRequire } from "module";
225830
+ import { promisify as promisify2 } from "util";
225831
+ import fs4 from "fs";
225832
+ import path42 from "path";
225712
225833
  import { existsSync as existsSync34, statSync as statSync4 } from "fs";
225713
- import { z as z73 } from "zod";
225714
225834
  import { z as z83 } from "zod";
225835
+ import { z as z93 } from "zod";
225715
225836
  function createInitialState(sessionId, task, maxAttempts = 8) {
225716
225837
  return {
225717
225838
  sessionId,
@@ -225996,11 +226117,11 @@ var PromptCacheSlabBuilder = class {
225996
226117
  } catch {
225997
226118
  }
225998
226119
  }
225999
- static readMetadata(path42) {
226000
- if (!existsSync13(path42)) return void 0;
226120
+ static readMetadata(path5) {
226121
+ if (!existsSync13(path5)) return void 0;
226001
226122
  try {
226002
226123
  return PromptCacheSlabMetadataSchema.parse(
226003
- JSON.parse(readFileSync13(path42, "utf8"))
226124
+ JSON.parse(readFileSync13(path5, "utf8"))
226004
226125
  );
226005
226126
  } catch {
226006
226127
  return void 0;
@@ -227009,9 +227130,9 @@ var VerificationContractManager = class {
227009
227130
  }
227010
227131
  loadContract() {
227011
227132
  const contractPath = path4.join(this.cwd, ".orbit", "verification.json");
227012
- if (fs3.existsSync(contractPath)) {
227133
+ if (fs2.existsSync(contractPath)) {
227013
227134
  try {
227014
- const content = fs3.readFileSync(contractPath, "utf8");
227135
+ const content = fs2.readFileSync(contractPath, "utf8");
227015
227136
  const parsed = JSON.parse(content);
227016
227137
  const validated = VerificationContractSchema.safeParse(parsed);
227017
227138
  if (validated.success) {
@@ -227125,7 +227246,7 @@ ${output}`
227125
227246
  });
227126
227247
  for (const requiredFile of this.contract.requiredFiles) {
227127
227248
  const filePath = resolveSafePath(this.cwd, requiredFile);
227128
- if (!fs3.existsSync(filePath)) {
227249
+ if (!fs2.existsSync(filePath)) {
227129
227250
  eventBus.emitEvent("verification_ended", {
227130
227251
  success: false,
227131
227252
  results: { missingRequiredFile: requiredFile }
@@ -227149,8 +227270,240 @@ ${output}`
227149
227270
  }
227150
227271
  }
227151
227272
  };
227152
- var execPromise2 = promisify2(exec2);
227273
+ var AUDIT_CONTENT_MAX_CHARS = 4e4;
227274
+ function isFileMutationTool(toolName) {
227275
+ return [
227276
+ "write_file",
227277
+ "edit_file",
227278
+ "replace_file_content",
227279
+ "multi_replace_file_content"
227280
+ ].includes(toolName);
227281
+ }
227282
+ function sha256(value) {
227283
+ return createHash23("sha256").update(value).digest("hex");
227284
+ }
227285
+ function buildAuditDiff(filePath, before, after) {
227286
+ const bounded = (value) => value.length <= AUDIT_CONTENT_MAX_CHARS ? value : `${value.slice(0, AUDIT_CONTENT_MAX_CHARS)}
227287
+ ... [truncated by Orbit audit]`;
227288
+ const beforeText = bounded(before ?? "").split("\n").map((line) => `-${line}`).join("\n");
227289
+ const afterText = bounded(after).split("\n").map((line) => `+${line}`).join("\n");
227290
+ return `--- a/${filePath}
227291
+ +++ b/${filePath}
227292
+ @@ Orbit recorded before/after @@
227293
+ ${beforeText}
227294
+ ${afterText}`;
227295
+ }
227296
+ function extractFilePathFromLine(line) {
227297
+ const windowsAbsolutePath = line.match(/([a-zA-Z]:[\\/][^`*\":#\s]+)/);
227298
+ if (windowsAbsolutePath) return windowsAbsolutePath[1];
227299
+ const unixAbsolutePath = line.match(/(?:^|\s)(\/[^`*\":#\s]+)/);
227300
+ if (unixAbsolutePath) return unixAbsolutePath[1];
227301
+ const relativePath = line.match(/([.\w\-+]+[\\/][^`*\":#\s]+)/);
227302
+ if (relativePath) return relativePath[1];
227303
+ return line.replace(/[`*:*#\-+]/g, "").trim();
227304
+ }
227305
+ function parseSearchReplaceBlocks(text) {
227306
+ const blocks = [];
227307
+ const blockPattern = /<<<<<<< SEARCH\r?\n([\s\S]*?)\r?\n=======\r?\n([\s\S]*?)\r?\n>>>>>>>/g;
227308
+ let match;
227309
+ while ((match = blockPattern.exec(text)) !== null) {
227310
+ const linesBeforeBlock = text.slice(0, match.index).split(/\r?\n/);
227311
+ const filePath = linesBeforeBlock.reverse().map((line) => extractFilePathFromLine(line.trim())).find(
227312
+ (candidate) => candidate.includes("/") || candidate.includes("\\") || /\.(?:js|ts|txt)$/.test(candidate)
227313
+ );
227314
+ if (filePath) {
227315
+ blocks.push({ filePath, oldText: match[1], newText: match[2] });
227316
+ }
227317
+ }
227318
+ return blocks;
227319
+ }
227320
+ function cleanAndTruncateTestLog(log) {
227321
+ const lines = log.replace(/\u001b\[\d+(;\d+)*m/g, "").replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").split(/\r?\n/);
227322
+ const filteredLines = [];
227323
+ let skippedFrames = 0;
227324
+ const flushSkippedFrames = () => {
227325
+ if (skippedFrames === 0) return;
227326
+ filteredLines.push(
227327
+ ` ... skipped ${skippedFrames} internal/library stack frames ...`
227328
+ );
227329
+ skippedFrames = 0;
227330
+ };
227331
+ for (const line of lines) {
227332
+ const trimmed = line.trim();
227333
+ if (trimmed.startsWith("at ") && (trimmed.includes("node_modules") || trimmed.includes("node:internal") || trimmed.includes("node:events"))) {
227334
+ skippedFrames++;
227335
+ continue;
227336
+ }
227337
+ flushSkippedFrames();
227338
+ filteredLines.push(line);
227339
+ }
227340
+ flushSkippedFrames();
227341
+ if (filteredLines.length <= 200) return filteredLines.join("\n");
227342
+ return [
227343
+ ...filteredLines.slice(0, 80),
227344
+ "\n[... WARNING: Log output truncated by Orbit for Token Optimization ...]\n",
227345
+ ...filteredLines.slice(-120)
227346
+ ].join("\n");
227347
+ }
227348
+ function generateXMLToolsPrompt(tools) {
227349
+ const lines = [
227350
+ "",
227351
+ "",
227352
+ "### Tool Use Instructions",
227353
+ "You can execute tasks by calling tools. To call a tool, wrap it in a <tool_call> XML block with the correct parameter tags.",
227354
+ "Format:",
227355
+ '<tool_call name="tool_name">',
227356
+ " <param_name>value</param_name>",
227357
+ "</tool_call>",
227358
+ "",
227359
+ "Crucial XML Rules:",
227360
+ "1. DO NOT escape special characters (like <, >, &) inside parameter tags (e.g. inside <content> or <newText>). Write them raw. The parser handles raw content.",
227361
+ "2. Ensure parameter tag names match the parameter names exactly (case-sensitive).",
227362
+ "3. You can execute multiple tool calls in a single turn.",
227363
+ "",
227364
+ "Available Tools:",
227365
+ ""
227366
+ ];
227367
+ for (const tool of tools) {
227368
+ lines.push(`- **${tool.name}**: ${tool.description}`, " Parameters:");
227369
+ if (tool.inputSchema instanceof z63.ZodObject) {
227370
+ for (const [key, property] of Object.entries(tool.inputSchema.shape)) {
227371
+ const field = describeZodPromptField(property);
227372
+ const values = field.values ? `, values: ${field.values}` : "";
227373
+ const description = field.description ? ` - ${field.description.replace(/\s+/g, " ").trim()}` : "";
227374
+ lines.push(
227375
+ ` - \`${key}\`: (type: ${field.typeName}${field.isOptional ? ", optional" : ""}${values})${description}`
227376
+ );
227377
+ }
227378
+ }
227379
+ lines.push("");
227380
+ }
227381
+ return lines.join("\n");
227382
+ }
227383
+ function generateNativeToolsPrompt(tools) {
227384
+ const names = tools.map((tool) => tool.name).sort().join(", ");
227385
+ return [
227386
+ "### Native Tool Use",
227387
+ "Use the provided native function tools when an operation requires workspace access.",
227388
+ "Validate every argument against the supplied schema, use exact tool names, and wait for tool results before claiming success.",
227389
+ "Do not print XML <tool_call> blocks or imitate tool calls in normal response text.",
227390
+ `Available tools: ${names || "none"}.`
227391
+ ].join("\n");
227392
+ }
227393
+ function describeZodPromptField(schema) {
227394
+ let current = schema;
227395
+ let isOptional = false;
227396
+ while (true) {
227397
+ if (current instanceof z63.ZodOptional) {
227398
+ isOptional = true;
227399
+ current = current.unwrap();
227400
+ } else if (current instanceof z63.ZodDefault) {
227401
+ isOptional = true;
227402
+ current = current.removeDefault();
227403
+ } else if (current instanceof z63.ZodNullable) {
227404
+ current = current.unwrap();
227405
+ } else if (current instanceof z63.ZodEffects) {
227406
+ current = current.innerType();
227407
+ } else {
227408
+ break;
227409
+ }
227410
+ }
227411
+ return {
227412
+ typeName: String(current._def.typeName).replace("Zod", "").toLowerCase(),
227413
+ isOptional,
227414
+ values: current instanceof z63.ZodEnum ? current.options.join(", ") : void 0,
227415
+ description: schema.description ?? current.description
227416
+ };
227417
+ }
227418
+ function parseXMLToolCalls(text) {
227419
+ const toolCalls = [];
227420
+ const toolCallPattern = /<tool_call\s+name="([^"]+)"\s*>([\s\S]*?)<\/tool_call>/g;
227421
+ let toolCallMatch;
227422
+ while ((toolCallMatch = toolCallPattern.exec(text)) !== null) {
227423
+ const argumentsRecord = {};
227424
+ const parameterPattern = /<([a-zA-Z0-9_]+)\s*>([\s\S]*?)<\/\1\s*>/g;
227425
+ let parameterMatch;
227426
+ while ((parameterMatch = parameterPattern.exec(toolCallMatch[2])) !== null) {
227427
+ argumentsRecord[parameterMatch[1]] = parseToolArgument(
227428
+ trimOneBoundaryNewline(parameterMatch[2])
227429
+ );
227430
+ }
227431
+ toolCalls.push({
227432
+ id: `xml_call_${randomUUID24()}`,
227433
+ name: toolCallMatch[1],
227434
+ arguments: JSON.stringify(argumentsRecord)
227435
+ });
227436
+ }
227437
+ return toolCalls;
227438
+ }
227439
+ function trimOneBoundaryNewline(value) {
227440
+ return value.replace(/^\r?\n/, "").replace(/\r?\n$/, "");
227441
+ }
227442
+ function parseToolArgument(value) {
227443
+ if (value === "true") return true;
227444
+ if (value === "false") return false;
227445
+ if (/^-?\d+$/.test(value)) return Number.parseInt(value, 10);
227446
+ if (/^-?\d+\.\d+$/.test(value)) return Number.parseFloat(value);
227447
+ if (value.startsWith("[") && value.endsWith("]") || value.startsWith("{") && value.endsWith("}")) {
227448
+ try {
227449
+ return JSON.parse(value);
227450
+ } catch {
227451
+ }
227452
+ }
227453
+ return value;
227454
+ }
227153
227455
  var execFilePromise2 = promisify2(execFile2);
227456
+ async function executeLocalPackageBinary(cwd, packageName, binaryName, args) {
227457
+ const binaryPath = resolveLocalPackageBinary(cwd, packageName, binaryName);
227458
+ const isJavaScript = /\.(?:cjs|mjs|js)$/i.test(binaryPath);
227459
+ const executable = isJavaScript ? process.execPath : binaryPath;
227460
+ const executableArgs = isJavaScript ? [binaryPath, ...args] : args;
227461
+ return execFilePromise2(executable, executableArgs, {
227462
+ cwd,
227463
+ encoding: "utf8",
227464
+ timeout: 12e4
227465
+ });
227466
+ }
227467
+ function resolveLocalPackageBinary(cwd, packageName, binaryName) {
227468
+ const workspaceRequire = createRequire(path22.join(cwd, "package.json"));
227469
+ const entryPath = workspaceRequire.resolve(packageName);
227470
+ let currentDirectory = path22.dirname(entryPath);
227471
+ while (true) {
227472
+ const manifestPath = path22.join(currentDirectory, "package.json");
227473
+ if (fs22.existsSync(manifestPath)) {
227474
+ const manifest = JSON.parse(fs22.readFileSync(manifestPath, "utf8"));
227475
+ if (manifest.name === packageName) {
227476
+ const relativeBinary = resolveManifestBinary(manifest.bin, binaryName);
227477
+ if (!relativeBinary) {
227478
+ throw new Error(
227479
+ `Package "${packageName}" does not expose binary "${binaryName}".`
227480
+ );
227481
+ }
227482
+ return path22.resolve(currentDirectory, relativeBinary);
227483
+ }
227484
+ }
227485
+ const parent = path22.dirname(currentDirectory);
227486
+ if (parent === currentDirectory) break;
227487
+ currentDirectory = parent;
227488
+ }
227489
+ throw new Error(
227490
+ `Unable to locate local package binary for "${packageName}".`
227491
+ );
227492
+ }
227493
+ function resolveManifestBinary(bin, binaryName) {
227494
+ if (typeof bin === "string") return bin;
227495
+ if (typeof bin !== "object" || bin === null) return void 0;
227496
+ const candidate = bin[binaryName];
227497
+ return typeof candidate === "string" ? candidate : void 0;
227498
+ }
227499
+ function isValidPackageName(packageName) {
227500
+ if (packageName.length === 0 || packageName.length > 214) return false;
227501
+ return /^(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*$/.test(
227502
+ packageName
227503
+ );
227504
+ }
227505
+ var execPromise2 = promisify3(exec2);
227506
+ var execFilePromise3 = promisify3(execFile3);
227154
227507
  var DEEPSEEK_CACHE_DEGRADED_HIT_RATE = 0.85;
227155
227508
  var DEEPSEEK_VERBOSE_CACHE_ENV = "ORBIT_DEEPSEEK_VERBOSE_CACHE";
227156
227509
  var NETWORK_TOOL_RESULT_MAX_RESULTS = 10;
@@ -227188,8 +227541,8 @@ var AgentLoop = class {
227188
227541
  cwd,
227189
227542
  config.session.store === "jsonl" ? config.session.path : ".orbit/sessions"
227190
227543
  );
227191
- const workspaceIdentity = path22.resolve(cwd).replace(/\\/g, "/");
227192
- this.userId = createHash23("sha256").update(
227544
+ const workspaceIdentity = path32.resolve(cwd).replace(/\\/g, "/");
227545
+ this.userId = createHash32("sha256").update(
227193
227546
  process.platform === "win32" ? workspaceIdentity.toLowerCase() : workspaceIdentity
227194
227547
  ).digest("hex");
227195
227548
  let session;
@@ -227559,8 +227912,8 @@ ${normalized}`);
227559
227912
  try {
227560
227913
  const indexer = new SymbolIndexer(this.cwd);
227561
227914
  const indexPath = indexer.indexPath;
227562
- if (fs2.existsSync(indexPath)) {
227563
- const stat = fs2.statSync(indexPath);
227915
+ if (fs3.existsSync(indexPath)) {
227916
+ const stat = fs3.statSync(indexPath);
227564
227917
  if (stat.mtimeMs === this.lastSymbolsMtime && this.cachedRepoMapText) {
227565
227918
  repoMapText = this.cachedRepoMapText;
227566
227919
  } else {
@@ -228193,7 +228546,7 @@ Please analyze this failure log, locate the files causing assertion or compile e
228193
228546
  if (tc.name === "write_file" || tc.name === "edit_file" || tc.name === "replace_file_content" || tc.name === "multi_replace_file_content") {
228194
228547
  const targetPath2 = evalArgs.path || evalArgs.TargetFile || evalArgs.filePath || evalArgs.file;
228195
228548
  if (targetPath2) {
228196
- const relPath = path22.relative(this.cwd, path22.resolve(this.cwd, targetPath2)).replace(/\\/g, "/");
228549
+ const relPath = path32.relative(this.cwd, path32.resolve(this.cwd, targetPath2)).replace(/\\/g, "/");
228197
228550
  const foundFile = this.state.relevantFiles.find(
228198
228551
  (f2) => f2.path === relPath
228199
228552
  );
@@ -228298,7 +228651,7 @@ Please analyze this failure log, locate the files causing assertion or compile e
228298
228651
  break;
228299
228652
  } else if (choice === "edit") {
228300
228653
  let edited = null;
228301
- const isObjectSchema = registeredTool?.inputSchema instanceof z63.ZodObject;
228654
+ const isObjectSchema = registeredTool?.inputSchema instanceof z73.ZodObject;
228302
228655
  if (isObjectSchema) {
228303
228656
  const editChoice = await Prompt.askSelect(
228304
228657
  "Choose edit mode:",
@@ -228642,7 +228995,7 @@ ${stdout.substring(0, 2e4)}`
228642
228995
  }
228643
228996
  if (finalResult.ok && targetPath && absoluteTargetPath && (tc.name === "write_file" || tc.name === "edit_file" || tc.name === "replace_file_content" || tc.name === "multi_replace_file_content")) {
228644
228997
  try {
228645
- if (fs2.existsSync(path22.join(this.cwd, "biome.json")) || fs2.existsSync(path22.join(this.cwd, "biome.jsonc"))) {
228998
+ if (fs3.existsSync(path32.join(this.cwd, "biome.json")) || fs3.existsSync(path32.join(this.cwd, "biome.jsonc"))) {
228646
228999
  this.interaction.showText(`\u25CF Running Biome Auto-Format...`);
228647
229000
  await executeLocalPackageBinary(
228648
229001
  this.cwd,
@@ -228661,7 +229014,7 @@ ${stdout.substring(0, 2e4)}`
228661
229014
  ];
228662
229015
  let hasPrettierConfig = false;
228663
229016
  for (const c2 of prettierCandidates) {
228664
- if (fs2.existsSync(path22.join(this.cwd, c2))) {
229017
+ if (fs3.existsSync(path32.join(this.cwd, c2))) {
228665
229018
  hasPrettierConfig = true;
228666
229019
  break;
228667
229020
  }
@@ -228686,7 +229039,7 @@ ${stdout.substring(0, 2e4)}`
228686
229039
  ];
228687
229040
  let hasEslintConfig = false;
228688
229041
  for (const c2 of eslintCandidates) {
228689
- if (fs2.existsSync(path22.join(this.cwd, c2))) {
229042
+ if (fs3.existsSync(path32.join(this.cwd, c2))) {
228690
229043
  hasEslintConfig = true;
228691
229044
  break;
228692
229045
  }
@@ -228704,7 +229057,7 @@ ${stdout.substring(0, 2e4)}`
228704
229057
  let lintPackage = "eslint";
228705
229058
  let lintBinary = "eslint";
228706
229059
  let lintArgs = ["--quiet", absoluteTargetPath];
228707
- if (fs2.existsSync(path22.join(this.cwd, "biome.json")) || fs2.existsSync(path22.join(this.cwd, "biome.jsonc"))) {
229060
+ if (fs3.existsSync(path32.join(this.cwd, "biome.json")) || fs3.existsSync(path32.join(this.cwd, "biome.jsonc"))) {
228708
229061
  lintPackage = "@biomejs/biome";
228709
229062
  lintBinary = "biome";
228710
229063
  lintArgs = ["lint", absoluteTargetPath];
@@ -228766,11 +229119,11 @@ ${stdout.substring(0, 2e4)}`
228766
229119
  );
228767
229120
  if (installPkg) {
228768
229121
  this.interaction.showText(`\u25CF Installing "${pkg}"...`);
228769
- const isPnpm = fs2.existsSync(
228770
- path22.join(this.cwd, "pnpm-lock.yaml")
229122
+ const isPnpm = fs3.existsSync(
229123
+ path32.join(this.cwd, "pnpm-lock.yaml")
228771
229124
  );
228772
- const isYarn = fs2.existsSync(
228773
- path22.join(this.cwd, "yarn.lock")
229125
+ const isYarn = fs3.existsSync(
229126
+ path32.join(this.cwd, "yarn.lock")
228774
229127
  );
228775
229128
  try {
228776
229129
  if (!isValidPackageName(pkg)) {
@@ -228780,7 +229133,7 @@ ${stdout.substring(0, 2e4)}`
228780
229133
  }
228781
229134
  const executable = isPnpm ? "pnpm" : isYarn ? "yarn" : "npm";
228782
229135
  const args = isPnpm || isYarn ? ["add", "-D", pkg] : ["install", "--save-dev", pkg];
228783
- await execFilePromise2(executable, args, {
229136
+ await execFilePromise3(executable, args, {
228784
229137
  cwd: this.cwd
228785
229138
  });
228786
229139
  this.interaction.showText(
@@ -228837,11 +229190,11 @@ ${stdout.substring(0, 2e4)}`
228837
229190
  }
228838
229191
  if (missingSymbols.length > 0) {
228839
229192
  const indexPath = new SymbolIndexer(this.cwd).indexPath;
228840
- if (fs2.existsSync(indexPath)) {
228841
- const raw = fs2.readFileSync(indexPath, "utf8");
229193
+ if (fs3.existsSync(indexPath)) {
229194
+ const raw = fs3.readFileSync(indexPath, "utf8");
228842
229195
  const index = JSON.parse(raw);
228843
229196
  if (index.files && typeof index.files === "object") {
228844
- const fileContent = fs2.readFileSync(
229197
+ const fileContent = fs3.readFileSync(
228845
229198
  absoluteTargetPath,
228846
229199
  "utf8"
228847
229200
  );
@@ -228862,12 +229215,12 @@ ${stdout.substring(0, 2e4)}`
228862
229215
  }
228863
229216
  }
228864
229217
  if (foundFile) {
228865
- const targetDir = path22.dirname(absoluteTargetPath);
228866
- const exportFileAbs = path22.resolve(
229218
+ const targetDir = path32.dirname(absoluteTargetPath);
229219
+ const exportFileAbs = path32.resolve(
228867
229220
  this.cwd,
228868
229221
  foundFile
228869
229222
  );
228870
- let relPath = path22.relative(
229223
+ let relPath = path32.relative(
228871
229224
  targetDir,
228872
229225
  exportFileAbs
228873
229226
  );
@@ -228884,7 +229237,7 @@ ${stdout.substring(0, 2e4)}`
228884
229237
  }
228885
229238
  }
228886
229239
  if (newImports) {
228887
- fs2.writeFileSync(
229240
+ fs3.writeFileSync(
228888
229241
  absoluteTargetPath,
228889
229242
  newImports + fileContent,
228890
229243
  "utf8"
@@ -228946,7 +229299,7 @@ ${stdout.substring(0, 2e4)}`
228946
229299
  if (finalResult.ok && targetPath && absoluteTargetPath && (tc.name === "write_file" || tc.name === "edit_file" || tc.name === "replace_file_content" || tc.name === "multi_replace_file_content")) {
228947
229300
  let afterContent = "";
228948
229301
  try {
228949
- afterContent = fs2.readFileSync(absoluteTargetPath, "utf8");
229302
+ afterContent = fs3.readFileSync(absoluteTargetPath, "utf8");
228950
229303
  } catch {
228951
229304
  try {
228952
229305
  const afterArgs = JSON.parse(tc.arguments);
@@ -229103,7 +229456,7 @@ ${stdout.substring(0, 2e4)}`
229103
229456
  lastB = hunk.endB;
229104
229457
  }
229105
229458
  mergedLines.push(...linesBefore.slice(lastB));
229106
- fs2.writeFileSync(
229459
+ fs3.writeFileSync(
229107
229460
  absoluteTargetPath,
229108
229461
  mergedLines.join("\n"),
229109
229462
  "utf8"
@@ -229140,9 +229493,9 @@ ${stdout.substring(0, 2e4)}`
229140
229493
  }
229141
229494
  if (finalResult.ok && targetPath && absoluteTargetPath && isFileMutationTool(tc.name)) {
229142
229495
  try {
229143
- const afterContent = fs2.readFileSync(absoluteTargetPath, "utf8");
229496
+ const afterContent = fs3.readFileSync(absoluteTargetPath, "utf8");
229144
229497
  this.sessionManager.recordFileModification(
229145
- path22.relative(this.cwd, absoluteTargetPath).replace(/\\/g, "/"),
229498
+ path32.relative(this.cwd, absoluteTargetPath).replace(/\\/g, "/"),
229146
229499
  buildAuditDiff(targetPath, beforeContent, afterContent),
229147
229500
  beforeContent === null ? void 0 : sha256(beforeContent),
229148
229501
  sha256(afterContent)
@@ -229236,11 +229589,11 @@ ${stdout.substring(0, 2e4)}`
229236
229589
  \u25CF Auto-committing changes...`);
229237
229590
  try {
229238
229591
  const uniqueFiles = Array.from(new Set(modifiedFiles));
229239
- const { execFileSync: execFileSync5 } = await import("child_process");
229592
+ const { execFileSync: execFileSync7 } = await import("child_process");
229240
229593
  for (const file of uniqueFiles) {
229241
- execFileSync5("git", ["add", file], { cwd: this.cwd });
229594
+ execFileSync7("git", ["add", file], { cwd: this.cwd });
229242
229595
  }
229243
- const diff = execFileSync5("git", ["diff", "--cached"], {
229596
+ const diff = execFileSync7("git", ["diff", "--cached"], {
229244
229597
  cwd: this.cwd
229245
229598
  }).toString().trim();
229246
229599
  if (diff) {
@@ -229275,7 +229628,7 @@ ${diff.substring(0, 2e4)}`
229275
229628
  this.interaction.showText(
229276
229629
  `\u25CF Committing: "${picocolors8.green(finalMsg)}"`
229277
229630
  );
229278
- execFileSync5("git", ["commit", "-m", finalMsg], {
229631
+ execFileSync7("git", ["commit", "-m", finalMsg], {
229279
229632
  cwd: this.cwd
229280
229633
  });
229281
229634
  this.interaction.showText(
@@ -229386,14 +229739,14 @@ ${diff.substring(0, 2e4)}`
229386
229739
  });
229387
229740
  this.sessionManager.saveHistory(this.state.history);
229388
229741
  }
229389
- addRelevantFile(path42, reason) {
229390
- if (!this.state.relevantFiles.some((f2) => f2.path === path42)) {
229391
- this.state.relevantFiles.push({ path: path42, reason });
229742
+ addRelevantFile(path5, reason) {
229743
+ if (!this.state.relevantFiles.some((f2) => f2.path === path5)) {
229744
+ this.state.relevantFiles.push({ path: path5, reason });
229392
229745
  }
229393
229746
  }
229394
229747
  async runHook(hookCommand, filePath) {
229395
- const absolutePath = path22.isAbsolute(filePath) ? filePath : path22.resolve(this.cwd, filePath);
229396
- const relativePath = path22.relative(this.cwd, absolutePath);
229748
+ const absolutePath = path32.isAbsolute(filePath) ? filePath : path32.resolve(this.cwd, filePath);
229749
+ const relativePath = path32.relative(this.cwd, absolutePath);
229397
229750
  if (hookCommand.includes("{file}")) {
229398
229751
  return {
229399
229752
  ok: false,
@@ -229453,7 +229806,7 @@ ${diff.substring(0, 2e4)}`
229453
229806
  const now = (/* @__PURE__ */ new Date()).toISOString();
229454
229807
  const plan = this.sessionManager.getTaskPlan();
229455
229808
  const item = {
229456
- id: `step_${randomUUID24()}`,
229809
+ id: `step_${randomUUID32()}`,
229457
229810
  text: text.trim(),
229458
229811
  status: "pending",
229459
229812
  createdAt: now,
@@ -229517,18 +229870,18 @@ ${diff.substring(0, 2e4)}`
229517
229870
  content: [{ type: "text", text: task }]
229518
229871
  });
229519
229872
  }
229520
- addRelevantFilePublic(path42, reason) {
229521
- this.addRelevantFile(path42, reason);
229873
+ addRelevantFilePublic(path5, reason) {
229874
+ this.addRelevantFile(path5, reason);
229522
229875
  }
229523
- addReadOnlyFilePublic(path42, reason) {
229524
- if (!this.state.relevantFiles.some((f2) => f2.path === path42)) {
229525
- this.state.relevantFiles.push({ path: path42, reason, readOnly: true });
229876
+ addReadOnlyFilePublic(path5, reason) {
229877
+ if (!this.state.relevantFiles.some((f2) => f2.path === path5)) {
229878
+ this.state.relevantFiles.push({ path: path5, reason, readOnly: true });
229526
229879
  }
229527
229880
  this.cachedContextPack = null;
229528
229881
  }
229529
- removeRelevantFilePublic(path42) {
229882
+ removeRelevantFilePublic(path5) {
229530
229883
  this.state.relevantFiles = this.state.relevantFiles.filter(
229531
- (f2) => f2.path !== path42
229884
+ (f2) => f2.path !== path5
229532
229885
  );
229533
229886
  this.cachedContextPack = null;
229534
229887
  }
@@ -229725,11 +230078,11 @@ ${diff.substring(0, 2e4)}`
229725
230078
  const safePath = resolveSafePath(this.cwd, backup.path);
229726
230079
  try {
229727
230080
  if (backup.originalContent === null) {
229728
- if (fs2.existsSync(safePath)) {
229729
- fs2.unlinkSync(safePath);
230081
+ if (fs3.existsSync(safePath)) {
230082
+ fs3.unlinkSync(safePath);
229730
230083
  }
229731
230084
  } else {
229732
- fs2.writeFileSync(safePath, backup.originalContent, "utf8");
230085
+ fs3.writeFileSync(safePath, backup.originalContent, "utf8");
229733
230086
  }
229734
230087
  return true;
229735
230088
  } catch {
@@ -229850,7 +230203,7 @@ ${diff.substring(0, 2e4)}`
229850
230203
  if (this.options?.nonInteractive) return null;
229851
230204
  try {
229852
230205
  const schema = registeredTool.inputSchema;
229853
- if (!(schema instanceof z63.ZodObject)) {
230206
+ if (!(schema instanceof z73.ZodObject)) {
229854
230207
  return null;
229855
230208
  }
229856
230209
  const currentArgs = JSON.parse(currentArgsStr);
@@ -229862,17 +230215,17 @@ ${diff.substring(0, 2e4)}`
229862
230215
  const description = fieldSchema.description || `Parameter "${key}"`;
229863
230216
  let result = null;
229864
230217
  let unwrapped = fieldSchema;
229865
- while (unwrapped instanceof z63.ZodOptional || unwrapped instanceof z63.ZodNullable || unwrapped instanceof z63.ZodEffects) {
230218
+ while (unwrapped instanceof z73.ZodOptional || unwrapped instanceof z73.ZodNullable || unwrapped instanceof z73.ZodEffects) {
229866
230219
  unwrapped = unwrapped._def.innerType || unwrapped._def.schema;
229867
230220
  }
229868
- if (unwrapped instanceof z63.ZodBoolean) {
230221
+ if (unwrapped instanceof z73.ZodBoolean) {
229869
230222
  const choice = await Prompt.askSelect(`${description} (boolean):`, [
229870
230223
  { value: "true", label: "true" },
229871
230224
  { value: "false", label: "false" }
229872
230225
  ]);
229873
230226
  if (choice === null) return null;
229874
230227
  result = choice === "true";
229875
- } else if (unwrapped instanceof z63.ZodEnum) {
230228
+ } else if (unwrapped instanceof z73.ZodEnum) {
229876
230229
  const options = unwrapped._def.values.map((v2) => ({
229877
230230
  value: v2,
229878
230231
  label: v2
@@ -229889,10 +230242,10 @@ ${diff.substring(0, 2e4)}`
229889
230242
  valStr
229890
230243
  );
229891
230244
  if (input === null) return null;
229892
- if (unwrapped instanceof z63.ZodNumber) {
230245
+ if (unwrapped instanceof z73.ZodNumber) {
229893
230246
  const num = Number(input);
229894
230247
  result = isNaN(num) ? input : num;
229895
- } else if (unwrapped instanceof z63.ZodArray || unwrapped instanceof z63.ZodObject) {
230248
+ } else if (unwrapped instanceof z73.ZodArray || unwrapped instanceof z73.ZodObject) {
229896
230249
  try {
229897
230250
  result = JSON.parse(input);
229898
230251
  } catch {
@@ -229982,286 +230335,9 @@ ${diff.substring(0, 2e4)}`
229982
230335
  }
229983
230336
  }
229984
230337
  };
229985
- function isFileMutationTool(toolName) {
229986
- return [
229987
- "write_file",
229988
- "edit_file",
229989
- "replace_file_content",
229990
- "multi_replace_file_content"
229991
- ].includes(toolName);
229992
- }
229993
- function sha256(value) {
229994
- return createHash23("sha256").update(value).digest("hex");
229995
- }
229996
- function buildAuditDiff(filePath, before, after) {
229997
- const maxChars = 4e4;
229998
- const bounded = (value) => value.length <= maxChars ? value : `${value.slice(0, maxChars)}
229999
- ... [truncated by Orbit audit]`;
230000
- const beforeText = bounded(before || "").split("\n").map((line) => `-${line}`).join("\n");
230001
- const afterText = bounded(after).split("\n").map((line) => `+${line}`).join("\n");
230002
- return `--- a/${filePath}
230003
- +++ b/${filePath}
230004
- @@ Orbit recorded before/after @@
230005
- ${beforeText}
230006
- ${afterText}`;
230007
- }
230008
- function generateXMLToolsPrompt(tools) {
230009
- let prompt = `
230010
-
230011
- ### Tool Use Instructions
230012
- `;
230013
- prompt += `You can execute tasks by calling tools. To call a tool, wrap it in a <tool_call> XML block with the correct parameter tags.
230014
- `;
230015
- prompt += `Format:
230016
- `;
230017
- prompt += `<tool_call name="tool_name">
230018
- `;
230019
- prompt += ` <param_name>value</param_name>
230020
- `;
230021
- prompt += `</tool_call>
230022
-
230023
- `;
230024
- prompt += `Crucial XML Rules:
230025
- `;
230026
- prompt += `1. DO NOT escape special characters (like <, >, &) inside parameter tags (e.g. inside <content> or <newText>). Write them raw. The parser handles raw content.
230027
- `;
230028
- prompt += `2. Ensure parameter tag names match the parameter names exactly (case-sensitive).
230029
- `;
230030
- prompt += `3. You can execute multiple tool calls in a single turn.
230031
-
230032
- `;
230033
- prompt += `Available Tools:
230034
-
230035
- `;
230036
- for (const tool of tools) {
230037
- prompt += `- **${tool.name}**: ${tool.description}
230038
- `;
230039
- prompt += ` Parameters:
230040
- `;
230041
- const schema = tool.inputSchema;
230042
- if (schema && schema.shape) {
230043
- for (const [key, prop] of Object.entries(schema.shape)) {
230044
- const field = describeZodPromptField(prop);
230045
- const values = field.values ? `, values: ${field.values}` : "";
230046
- const description = field.description ? ` - ${field.description.replace(/\s+/g, " ").trim()}` : "";
230047
- prompt += ` - \`${key}\`: (type: ${field.typeName}${field.isOptional ? ", optional" : ""}${values})${description}
230048
- `;
230049
- }
230050
- }
230051
- prompt += `
230052
- `;
230053
- }
230054
- return prompt;
230055
- }
230056
- function generateNativeToolsPrompt(tools) {
230057
- const names = tools.map((tool) => tool.name).sort().join(", ");
230058
- return [
230059
- "### Native Tool Use",
230060
- "Use the provided native function tools when an operation requires workspace access.",
230061
- "Validate every argument against the supplied schema, use exact tool names, and wait for tool results before claiming success.",
230062
- "Do not print XML <tool_call> blocks or imitate tool calls in normal response text.",
230063
- `Available tools: ${names || "none"}.`
230064
- ].join("\n");
230065
- }
230066
- function describeZodPromptField(schema) {
230067
- const description = schema?.description || schema?._def?.description;
230068
- let current = schema;
230069
- let isOptional = false;
230070
- while (current?._def) {
230071
- const typeName2 = current._def.typeName;
230072
- if (typeName2 === "ZodOptional" || typeName2 === "ZodDefault") {
230073
- isOptional = true;
230074
- current = current._def.innerType;
230075
- continue;
230076
- }
230077
- if (typeName2 === "ZodNullable" || typeName2 === "ZodEffects") {
230078
- current = current._def.innerType || current._def.schema;
230079
- continue;
230080
- }
230081
- break;
230082
- }
230083
- const typeName = String(current?._def?.typeName || "ZodString").replace("Zod", "").toLowerCase();
230084
- const values = current instanceof z63.ZodEnum ? current._def.values.join(", ") : void 0;
230085
- return {
230086
- typeName,
230087
- isOptional,
230088
- values,
230089
- description: description || current?.description || current?._def?.description
230090
- };
230091
- }
230092
- function parseXMLToolCalls(text) {
230093
- const toolCalls = [];
230094
- const toolCallRegex = /<tool_call\s+name="([^"]+)"\s*>([\s\S]*?)<\/tool_call>/g;
230095
- let match;
230096
- let idCounter = 1;
230097
- while ((match = toolCallRegex.exec(text)) !== null) {
230098
- const name = match[1];
230099
- const innerContent = match[2];
230100
- const paramRegex = /<([a-zA-Z0-9_]+)\s*>([\s\S]*?)<\/\1\s*>/g;
230101
- const args = {};
230102
- let paramMatch;
230103
- while ((paramMatch = paramRegex.exec(innerContent)) !== null) {
230104
- const paramName = paramMatch[1];
230105
- let paramValue = paramMatch[2];
230106
- if (paramValue.startsWith("\n")) {
230107
- paramValue = paramValue.substring(1);
230108
- }
230109
- if (paramValue.endsWith("\n")) {
230110
- paramValue = paramValue.substring(0, paramValue.length - 1);
230111
- } else if (paramValue.endsWith("\r\n")) {
230112
- paramValue = paramValue.substring(0, paramValue.length - 2);
230113
- }
230114
- let typedValue = paramValue;
230115
- if (paramValue === "true") {
230116
- typedValue = true;
230117
- } else if (paramValue === "false") {
230118
- typedValue = false;
230119
- } else if (/^-?\d+$/.test(paramValue)) {
230120
- typedValue = parseInt(paramValue, 10);
230121
- } else if (/^-?\d+\.\d+$/.test(paramValue)) {
230122
- typedValue = parseFloat(paramValue);
230123
- } else if (paramValue.startsWith("[") && paramValue.endsWith("]") || paramValue.startsWith("{") && paramValue.endsWith("}")) {
230124
- try {
230125
- typedValue = JSON.parse(paramValue);
230126
- } catch {
230127
- }
230128
- }
230129
- args[paramName] = typedValue;
230130
- }
230131
- toolCalls.push({
230132
- id: `xml_call_${idCounter++}_${Date.now()}`,
230133
- name,
230134
- arguments: JSON.stringify(args)
230135
- });
230136
- }
230137
- return toolCalls;
230138
- }
230139
- function extractFilePathFromLine(line) {
230140
- const winAbsMatch = line.match(/([a-zA-Z]:[\\/][^`*:"#\s]+)/);
230141
- if (winAbsMatch) {
230142
- return winAbsMatch[1];
230143
- }
230144
- const unixAbsMatch = line.match(/(?:^|\s)(\/[^`*:"#\s]+)/);
230145
- if (unixAbsMatch) {
230146
- return unixAbsMatch[1];
230147
- }
230148
- const pathMatch = line.match(/([.\w\-+]+[\\/][^`*:"#\s]+)/);
230149
- if (pathMatch) {
230150
- return pathMatch[1];
230151
- }
230152
- return line.replace(/[`*:*#\-+]/g, "").trim();
230153
- }
230154
- function parseSearchReplaceBlocks(text) {
230155
- const blocks = [];
230156
- const regex = /<<<<<<< SEARCH\r?\n([\s\S]*?)\r?\n=======\r?\n([\s\S]*?)\r?\n>>>>>>>/g;
230157
- let match;
230158
- while ((match = regex.exec(text)) !== null) {
230159
- const startIndex = match.index;
230160
- const oldText = match[1];
230161
- const newText = match[2];
230162
- const beforeText = text.substring(0, startIndex);
230163
- const lines = beforeText.split(/\r?\n/);
230164
- let filePath = "";
230165
- for (let i = lines.length - 1; i >= 0; i--) {
230166
- const line = lines[i].trim();
230167
- const extracted = extractFilePathFromLine(line);
230168
- if (extracted && (extracted.includes("/") || extracted.includes("\\") || extracted.endsWith(".ts") || extracted.endsWith(".js") || extracted.endsWith(".txt"))) {
230169
- filePath = extracted;
230170
- break;
230171
- }
230172
- }
230173
- if (filePath) {
230174
- blocks.push({
230175
- filePath,
230176
- oldText,
230177
- newText
230178
- });
230179
- }
230180
- }
230181
- return blocks;
230182
- }
230183
- function cleanAndTruncateTestLog(log) {
230184
- const cleaned = log.replace(/\u001b\[\d+(;\d+)*m/g, "").replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "");
230185
- const lines = cleaned.split(/\r?\n/);
230186
- const filteredLines = [];
230187
- let skipCount = 0;
230188
- for (const line of lines) {
230189
- const trimmed = line.trim();
230190
- if (trimmed.startsWith("at ") && (trimmed.includes("node_modules") || trimmed.includes("node:internal") || trimmed.includes("node:events"))) {
230191
- skipCount++;
230192
- continue;
230193
- }
230194
- if (skipCount > 0) {
230195
- filteredLines.push(
230196
- ` ... skipped ${skipCount} internal/library stack frames ...`
230197
- );
230198
- skipCount = 0;
230199
- }
230200
- filteredLines.push(line);
230201
- }
230202
- if (skipCount > 0) {
230203
- filteredLines.push(
230204
- ` ... skipped ${skipCount} internal/library stack frames ...`
230205
- );
230206
- }
230207
- if (filteredLines.length > 200) {
230208
- const top = filteredLines.slice(0, 80);
230209
- const bottom = filteredLines.slice(filteredLines.length - 120);
230210
- return [
230211
- ...top,
230212
- "\n[... WARNING: Log output truncated by Orbit for Token Optimization ...]\n",
230213
- ...bottom
230214
- ].join("\n");
230215
- }
230216
- return filteredLines.join("\n");
230217
- }
230218
- async function executeLocalPackageBinary(cwd, packageName, binaryName, args) {
230219
- const binaryPath = resolveLocalPackageBinary(cwd, packageName, binaryName);
230220
- const isJavaScript = /\.(?:cjs|mjs|js)$/i.test(binaryPath);
230221
- const executable = isJavaScript ? process.execPath : binaryPath;
230222
- const executableArgs = isJavaScript ? [binaryPath, ...args] : args;
230223
- return execFilePromise2(executable, executableArgs, {
230224
- cwd,
230225
- encoding: "utf8",
230226
- timeout: 12e4
230227
- });
230228
- }
230229
- function resolveLocalPackageBinary(cwd, packageName, binaryName) {
230230
- const workspaceRequire = createRequire(path22.join(cwd, "package.json"));
230231
- const entryPath = workspaceRequire.resolve(packageName);
230232
- let currentDirectory = path22.dirname(entryPath);
230233
- while (true) {
230234
- const manifestPath = path22.join(currentDirectory, "package.json");
230235
- if (fs2.existsSync(manifestPath)) {
230236
- const manifest = JSON.parse(fs2.readFileSync(manifestPath, "utf8"));
230237
- if (manifest.name === packageName) {
230238
- const bin = manifest.bin;
230239
- const relativeBinary = typeof bin === "string" ? bin : typeof bin === "object" && bin !== null && binaryName in bin && typeof bin[binaryName] === "string" ? bin[binaryName] : void 0;
230240
- if (!relativeBinary) {
230241
- throw new Error(
230242
- `Package "${packageName}" does not expose binary "${binaryName}".`
230243
- );
230244
- }
230245
- return path22.resolve(currentDirectory, relativeBinary);
230246
- }
230247
- }
230248
- const parent = path22.dirname(currentDirectory);
230249
- if (parent === currentDirectory) break;
230250
- currentDirectory = parent;
230251
- }
230252
- throw new Error(
230253
- `Unable to locate local package binary for "${packageName}".`
230254
- );
230255
- }
230256
- function isValidPackageName(packageName) {
230257
- if (packageName.length === 0 || packageName.length > 214) return false;
230258
- return /^(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*$/.test(
230259
- packageName
230260
- );
230261
- }
230262
- var ReviewVerdictSchema = z73.object({
230263
- verdict: z73.enum(["approved", "rejected"]),
230264
- feedback: z73.string().default("")
230338
+ var ReviewVerdictSchema = z83.object({
230339
+ verdict: z83.enum(["approved", "rejected"]),
230340
+ feedback: z83.string().default("")
230265
230341
  });
230266
230342
  var Orchestrator = class {
230267
230343
  constructor(cwd, config, provider, task, interaction) {
@@ -230560,9 +230636,9 @@ Your final response must be one JSON object with this exact shape:
230560
230636
  }
230561
230637
  persistPlan(plan) {
230562
230638
  try {
230563
- const planPath = path32.join(this.cwd, ".orbit", "task.md");
230564
- fs32.mkdirSync(path32.dirname(planPath), { recursive: true });
230565
- fs32.writeFileSync(planPath, plan, "utf8");
230639
+ const planPath = path42.join(this.cwd, ".orbit", "task.md");
230640
+ fs4.mkdirSync(path42.dirname(planPath), { recursive: true });
230641
+ fs4.writeFileSync(planPath, plan, "utf8");
230566
230642
  this.interaction.showText(" \u2714 Plan saved to .orbit/task.md");
230567
230643
  } catch (error) {
230568
230644
  this.interaction.showText(
@@ -230601,48 +230677,48 @@ function errorMessage(error) {
230601
230677
  const raw = error instanceof Error ? error.message : String(error);
230602
230678
  return redactSecrets(raw).replace(/[\u0000-\u001f\u007f-\u009f]/g, " ").replace(/\s+/g, " ").trim().slice(0, 2e3);
230603
230679
  }
230604
- var AcceptanceVerificationSchema = z83.object({
230605
- name: z83.string().trim().min(1).max(120),
230606
- command: z83.string().trim().min(1).max(4e3),
230607
- timeoutMs: z83.number().int().min(1e3).max(30 * 6e4).default(12e4)
230680
+ var AcceptanceVerificationSchema = z93.object({
230681
+ name: z93.string().trim().min(1).max(120),
230682
+ command: z93.string().trim().min(1).max(4e3),
230683
+ timeoutMs: z93.number().int().min(1e3).max(30 * 6e4).default(12e4)
230608
230684
  });
230609
- var AcceptanceTaskSchema = z83.object({
230610
- id: z83.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/),
230611
- prompt: z83.string().trim().min(1).max(2e4),
230612
- mode: z83.enum(["single", "multi"]).default("single"),
230613
- provider: z83.string().trim().min(1).optional(),
230614
- model: z83.string().trim().min(1).optional(),
230615
- verification: z83.array(AcceptanceVerificationSchema).max(20).default([]),
230616
- requiredChangedFiles: z83.array(z83.string().trim().min(1)).max(100).default([]),
230617
- forbiddenChangedFiles: z83.array(z83.string().trim().min(1)).max(100).default([]),
230618
- maxChangedFiles: z83.number().int().min(0).max(1e4).optional()
230685
+ var AcceptanceTaskSchema = z93.object({
230686
+ id: z93.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/),
230687
+ prompt: z93.string().trim().min(1).max(2e4),
230688
+ mode: z93.enum(["single", "multi"]).default("single"),
230689
+ provider: z93.string().trim().min(1).optional(),
230690
+ model: z93.string().trim().min(1).optional(),
230691
+ verification: z93.array(AcceptanceVerificationSchema).max(20).default([]),
230692
+ requiredChangedFiles: z93.array(z93.string().trim().min(1)).max(100).default([]),
230693
+ forbiddenChangedFiles: z93.array(z93.string().trim().min(1)).max(100).default([]),
230694
+ maxChangedFiles: z93.number().int().min(0).max(1e4).optional()
230619
230695
  });
230620
- var AcceptanceSuiteSchema = z83.object({
230621
- schemaVersion: z83.literal(1),
230622
- name: z83.string().trim().min(1).max(200),
230623
- description: z83.string().trim().max(2e3).optional(),
230624
- tasks: z83.array(AcceptanceTaskSchema).min(1).max(100)
230696
+ var AcceptanceSuiteSchema = z93.object({
230697
+ schemaVersion: z93.literal(1),
230698
+ name: z93.string().trim().min(1).max(200),
230699
+ description: z93.string().trim().max(2e3).optional(),
230700
+ tasks: z93.array(AcceptanceTaskSchema).min(1).max(100)
230625
230701
  });
230626
- var AcceptanceCheckResultSchema = z83.object({
230627
- name: z83.string(),
230628
- passed: z83.boolean(),
230629
- durationMs: z83.number().int().nonnegative(),
230630
- exitCode: z83.number().int().optional(),
230631
- summary: z83.string().max(4e3)
230702
+ var AcceptanceCheckResultSchema = z93.object({
230703
+ name: z93.string(),
230704
+ passed: z93.boolean(),
230705
+ durationMs: z93.number().int().nonnegative(),
230706
+ exitCode: z93.number().int().optional(),
230707
+ summary: z93.string().max(4e3)
230632
230708
  });
230633
- var AcceptanceTaskResultSchema = z83.object({
230634
- taskId: z83.string(),
230635
- sessionId: z83.string().optional(),
230636
- traceFile: z83.string().optional(),
230637
- passed: z83.boolean(),
230638
- agentStatus: z83.enum(["completed", "failed", "aborted"]),
230639
- durationMs: z83.number().int().nonnegative(),
230640
- requestedProvider: z83.string().optional(),
230641
- requestedModel: z83.string().optional(),
230642
- resolvedModels: z83.array(z83.string()).default([]),
230643
- changedFiles: z83.array(z83.string()),
230644
- checks: z83.array(AcceptanceCheckResultSchema),
230645
- failureReasons: z83.array(z83.string())
230709
+ var AcceptanceTaskResultSchema = z93.object({
230710
+ taskId: z93.string(),
230711
+ sessionId: z93.string().optional(),
230712
+ traceFile: z93.string().optional(),
230713
+ passed: z93.boolean(),
230714
+ agentStatus: z93.enum(["completed", "failed", "aborted"]),
230715
+ durationMs: z93.number().int().nonnegative(),
230716
+ requestedProvider: z93.string().optional(),
230717
+ requestedModel: z93.string().optional(),
230718
+ resolvedModels: z93.array(z93.string()).default([]),
230719
+ changedFiles: z93.array(z93.string()),
230720
+ checks: z93.array(AcceptanceCheckResultSchema),
230721
+ failureReasons: z93.array(z93.string())
230646
230722
  });
230647
230723
  function scoreAcceptanceTask(input) {
230648
230724
  const task = AcceptanceTaskSchema.parse(input.task);
@@ -230832,12 +230908,12 @@ var AutocompleteEngine = class {
230832
230908
  this.activeRequests.set(windowId, controller);
230833
230909
  const signal = controller.signal;
230834
230910
  const debounceMs = config.autocomplete?.debounceMs !== void 0 ? config.autocomplete.debounceMs : 150;
230835
- return new Promise((resolve13) => {
230836
- this.debounceResolvers.set(windowId, resolve13);
230911
+ return new Promise((resolve15) => {
230912
+ this.debounceResolvers.set(windowId, resolve15);
230837
230913
  const timer = setTimeout(async () => {
230838
230914
  this.debounceResolvers.delete(windowId);
230839
230915
  if (signal.aborted) {
230840
- resolve13("");
230916
+ resolve15("");
230841
230917
  return;
230842
230918
  }
230843
230919
  const providerId = config.autocomplete.provider || "ollama";
@@ -230845,7 +230921,7 @@ var AutocompleteEngine = class {
230845
230921
  try {
230846
230922
  const provider = this.getCachedProvider(providerId, config);
230847
230923
  if (typeof provider.complete !== "function") {
230848
- resolve13("");
230924
+ resolve15("");
230849
230925
  return;
230850
230926
  }
230851
230927
  const header = getPathCommentHeader(windowId, this.cwd);
@@ -230947,21 +231023,21 @@ var AutocompleteEngine = class {
230947
231023
  timeoutPromise
230948
231024
  ]);
230949
231025
  if (winner !== "__TIMEOUT__" && winner.trim() !== "") {
230950
- resolve13(winner);
231026
+ resolve15(winner);
230951
231027
  } else {
230952
231028
  const localResult = await localPromise;
230953
231029
  if (localResult.trim() !== "") {
230954
- resolve13(localResult);
231030
+ resolve15(localResult);
230955
231031
  } else {
230956
- resolve13(await cloudPromise.catch(() => ""));
231032
+ resolve15(await cloudPromise.catch(() => ""));
230957
231033
  }
230958
231034
  }
230959
231035
  } else {
230960
231036
  const completed = await cloudPromise;
230961
- resolve13(completed);
231037
+ resolve15(completed);
230962
231038
  }
230963
231039
  } catch {
230964
- resolve13("");
231040
+ resolve15("");
230965
231041
  } finally {
230966
231042
  if (this.activeRequests.get(windowId) === controller) {
230967
231043
  this.activeRequests.delete(windowId);
@@ -230974,7 +231050,7 @@ var AutocompleteEngine = class {
230974
231050
  /** Cancel outstanding completions and release timers held by the engine. */
230975
231051
  dispose() {
230976
231052
  for (const timer of this.debounceTimers.values()) clearTimeout(timer);
230977
- for (const resolve13 of this.debounceResolvers.values()) resolve13("");
231053
+ for (const resolve15 of this.debounceResolvers.values()) resolve15("");
230978
231054
  for (const controller of this.activeRequests.values()) controller.abort();
230979
231055
  this.debounceTimers.clear();
230980
231056
  this.debounceResolvers.clear();
@@ -230984,20 +231060,14 @@ var AutocompleteEngine = class {
230984
231060
  };
230985
231061
 
230986
231062
  // src/commands/run.ts
230987
- import picocolors19 from "picocolors";
230988
- import { existsSync as existsSync29, readFileSync as readFileSync19 } from "fs";
230989
- import { join as join18 } from "path";
231063
+ import picocolors20 from "picocolors";
231064
+ import { existsSync as existsSync28, readFileSync as readFileSync19 } from "fs";
231065
+ import { join as join17 } from "path";
230990
231066
 
230991
231067
  // src/tui/FullscreenTui.ts
230992
231068
  import { join as join14 } from "path";
230993
231069
  import { homedir as homedir7 } from "os";
230994
- import {
230995
- existsSync as existsSync15,
230996
- readFileSync as readFileSync15,
230997
- writeFileSync as writeFileSync11,
230998
- mkdirSync as mkdirSync11,
230999
- statSync as statSync5
231000
- } from "fs";
231070
+ import { existsSync as existsSync15, readFileSync as readFileSync15, writeFileSync as writeFileSync11, mkdirSync as mkdirSync11 } from "fs";
231001
231071
  import { exec as exec3 } from "child_process";
231002
231072
  import readline3 from "readline";
231003
231073
 
@@ -231054,7 +231124,7 @@ function buildSlashCommandHelp(isZh) {
231054
231124
  ` ${picocolors9.green("/config")} ${picocolors9.cyan("[k=v]")} - \u67E5\u770B\u6216\u76F4\u63A5\u4FEE\u6539\u914D\u7F6E\u53C2\u6570`,
231055
231125
  ` ${picocolors9.green("/model")} ${picocolors9.cyan("[name]")} - \u52A8\u6001\u67E5\u8BE2\u6216\u5207\u6362\u6B63\u5728\u4F7F\u7528\u7684\u8BED\u8A00\u5927\u6A21\u578B`,
231056
231126
  ` ${picocolors9.green("/mode")} ${picocolors9.cyan("[mode]")} - \u5207\u6362\u5B89\u5168\u786E\u8BA4\u6A21\u5F0F (strict, normal, auto, plan)`,
231057
- ` ${picocolors9.green("/update")} - \u68C0\u6D4B\u5E76\u66F4\u65B0\u9879\u76EE\u4F9D\u8D56\u5305`,
231127
+ ` ${picocolors9.green("/update")} - \u68C0\u67E5\u5E76\u66F4\u65B0 Orbit \u5230\u6700\u65B0 npm \u7248\u672C`,
231058
231128
  ` ${picocolors9.green("/webui")} ${picocolors9.cyan("[port]")} - \u542F\u52A8\u5E76\u6253\u5F00 Orbit \u56FE\u5F62\u63A7\u5236\u53F0`,
231059
231129
  "",
231060
231130
  picocolors9.bold(picocolors9.yellow("[ Git \u63D0\u4EA4 (Git) ]")),
@@ -231089,7 +231159,7 @@ function buildSlashCommandHelp(isZh) {
231089
231159
  ` ${picocolors9.green("/config")} ${picocolors9.cyan("[k=v]")} - View or modify configurations`,
231090
231160
  ` ${picocolors9.green("/model")} ${picocolors9.cyan("[name]")} - Show or switch active model`,
231091
231161
  ` ${picocolors9.green("/mode")} ${picocolors9.cyan("[mode]")} - Switch permission mode (strict, normal, auto, plan)`,
231092
- ` ${picocolors9.green("/update")} - Check and update dependencies`,
231162
+ ` ${picocolors9.green("/update")} - Check and update Orbit from npm`,
231093
231163
  ` ${picocolors9.green("/webui")} ${picocolors9.cyan("[port]")} - Start and open the Orbit graphical console`,
231094
231164
  "",
231095
231165
  picocolors9.bold(picocolors9.yellow("[ Git Version Control ]")),
@@ -231711,7 +231781,7 @@ var TuiPromptSession = class {
231711
231781
  this.requestRender();
231712
231782
  const wasRaw = !!this.stdin.isRaw;
231713
231783
  if (this.stdin.setRawMode) this.stdin.setRawMode(true);
231714
- return new Promise((resolve13) => {
231784
+ return new Promise((resolve15) => {
231715
231785
  const listener = (str, key = {}) => {
231716
231786
  const state = this.promptState;
231717
231787
  if (!state) {
@@ -231729,7 +231799,7 @@ var TuiPromptSession = class {
231729
231799
  this.requestRender();
231730
231800
  }
231731
231801
  };
231732
- this.active = { resolve: resolve13, wasRaw, listener };
231802
+ this.active = { resolve: resolve15, wasRaw, listener };
231733
231803
  this.stdin.on("keypress", listener);
231734
231804
  this.stdin.resume();
231735
231805
  });
@@ -231929,6 +231999,158 @@ function renderPromptScreen(state, viewport, theme = MORANDI) {
231929
231999
  return "\x1B[?25l\x1B[H" + lines.map((line) => line + "\x1B[K").join("\n") + "\x1B[J" + cursorSequence;
231930
232000
  }
231931
232001
 
232002
+ // src/runtime/UpdateManager.ts
232003
+ import { execFile as execFile4, execFileSync as execFileSync4 } from "child_process";
232004
+ import { z as z30 } from "zod";
232005
+ var SemanticVersionSchema = z30.string().trim().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/);
232006
+ var UpdateCheckSchema = z30.object({
232007
+ currentVersion: SemanticVersionSchema,
232008
+ latestVersion: SemanticVersionSchema,
232009
+ updateAvailable: z30.boolean()
232010
+ });
232011
+ var UpdateManager = class {
232012
+ executable;
232013
+ argumentPrefix;
232014
+ run;
232015
+ runAsync;
232016
+ timeoutMs;
232017
+ constructor(options = {}) {
232018
+ const platform = options.platform ?? process.platform;
232019
+ this.executable = platform === "win32" ? options.windowsCommandShell ?? process.env.ComSpec ?? "cmd.exe" : "npm";
232020
+ this.argumentPrefix = platform === "win32" ? ["/d", "/s", "/c", "npm.cmd"] : [];
232021
+ this.run = options.run ?? runNpmCommand;
232022
+ this.runAsync = options.runAsync ?? runNpmCommandAsync;
232023
+ this.timeoutMs = options.timeoutMs ?? 15e3;
232024
+ }
232025
+ check(currentVersion) {
232026
+ const validatedCurrentVersion = SemanticVersionSchema.parse(currentVersion);
232027
+ const raw = this.run(this.executable, this.latestVersionArguments(), {
232028
+ timeoutMs: this.timeoutMs,
232029
+ inheritOutput: false
232030
+ });
232031
+ return this.createUpdateCheck(validatedCurrentVersion, raw);
232032
+ }
232033
+ async checkAsync(currentVersion) {
232034
+ const validatedCurrentVersion = SemanticVersionSchema.parse(currentVersion);
232035
+ const raw = await this.runAsync(
232036
+ this.executable,
232037
+ this.latestVersionArguments(),
232038
+ this.timeoutMs
232039
+ );
232040
+ return this.createUpdateCheck(validatedCurrentVersion, raw);
232041
+ }
232042
+ latestVersionArguments() {
232043
+ return [
232044
+ ...this.argumentPrefix,
232045
+ "view",
232046
+ "@orbit-build/cli",
232047
+ "dist-tags.latest",
232048
+ "--json"
232049
+ ];
232050
+ }
232051
+ createUpdateCheck(validatedCurrentVersion, raw) {
232052
+ const latestVersion = SemanticVersionSchema.parse(parseNpmJsonString(raw));
232053
+ return {
232054
+ currentVersion: validatedCurrentVersion,
232055
+ latestVersion,
232056
+ updateAvailable: compareSemanticVersions(latestVersion, validatedCurrentVersion) > 0
232057
+ };
232058
+ }
232059
+ install(version, inheritOutput = true) {
232060
+ const validatedVersion = SemanticVersionSchema.parse(version);
232061
+ this.run(
232062
+ this.executable,
232063
+ [
232064
+ ...this.argumentPrefix,
232065
+ "install",
232066
+ "--global",
232067
+ `@orbit-build/cli@${validatedVersion}`,
232068
+ "--no-audit",
232069
+ "--no-fund"
232070
+ ],
232071
+ { timeoutMs: Math.max(this.timeoutMs, 12e4), inheritOutput }
232072
+ );
232073
+ }
232074
+ };
232075
+ function parseNpmJsonString(raw) {
232076
+ try {
232077
+ return JSON.parse(raw);
232078
+ } catch (error) {
232079
+ throw new Error("npm returned an invalid latest-version response.", {
232080
+ cause: error
232081
+ });
232082
+ }
232083
+ }
232084
+ function compareSemanticVersions(left, right) {
232085
+ const parse6 = (version) => {
232086
+ const withoutBuild = version.split("+", 1)[0] ?? version;
232087
+ const prereleaseSeparator = withoutBuild.indexOf("-");
232088
+ const corePart = prereleaseSeparator === -1 ? withoutBuild : withoutBuild.slice(0, prereleaseSeparator);
232089
+ const prereleasePart = prereleaseSeparator === -1 ? void 0 : withoutBuild.slice(prereleaseSeparator + 1);
232090
+ return {
232091
+ core: corePart.split(".").map(Number),
232092
+ prerelease: prereleasePart ? prereleasePart.split(".") : []
232093
+ };
232094
+ };
232095
+ const leftVersion = parse6(left);
232096
+ const rightVersion = parse6(right);
232097
+ for (let index = 0; index < 3; index++) {
232098
+ const difference = (leftVersion.core[index] ?? 0) - (rightVersion.core[index] ?? 0);
232099
+ if (difference !== 0) return Math.sign(difference);
232100
+ }
232101
+ if (leftVersion.prerelease.length === 0) {
232102
+ return rightVersion.prerelease.length === 0 ? 0 : 1;
232103
+ }
232104
+ if (rightVersion.prerelease.length === 0) return -1;
232105
+ const length = Math.max(
232106
+ leftVersion.prerelease.length,
232107
+ rightVersion.prerelease.length
232108
+ );
232109
+ for (let index = 0; index < length; index++) {
232110
+ const leftPart = leftVersion.prerelease[index];
232111
+ const rightPart = rightVersion.prerelease[index];
232112
+ if (leftPart === void 0) return -1;
232113
+ if (rightPart === void 0) return 1;
232114
+ if (leftPart === rightPart) continue;
232115
+ const leftNumber = /^\d+$/.test(leftPart) ? Number(leftPart) : null;
232116
+ const rightNumber = /^\d+$/.test(rightPart) ? Number(rightPart) : null;
232117
+ if (leftNumber !== null && rightNumber !== null) {
232118
+ return Math.sign(leftNumber - rightNumber);
232119
+ }
232120
+ if (leftNumber !== null) return -1;
232121
+ if (rightNumber !== null) return 1;
232122
+ return leftPart.localeCompare(rightPart);
232123
+ }
232124
+ return 0;
232125
+ }
232126
+ function runNpmCommand(executable, args, options) {
232127
+ return execFileSync4(executable, args, {
232128
+ encoding: "utf8",
232129
+ timeout: options.timeoutMs,
232130
+ stdio: options.inheritOutput ? ["ignore", "inherit", "inherit"] : ["ignore", "pipe", "pipe"]
232131
+ });
232132
+ }
232133
+ function runNpmCommandAsync(executable, args, timeoutMs) {
232134
+ return new Promise((resolve15, reject) => {
232135
+ execFile4(
232136
+ executable,
232137
+ args,
232138
+ {
232139
+ encoding: "utf8",
232140
+ timeout: timeoutMs,
232141
+ windowsHide: true
232142
+ },
232143
+ (error, stdout) => {
232144
+ if (error) {
232145
+ reject(error);
232146
+ return;
232147
+ }
232148
+ resolve15(stdout);
232149
+ }
232150
+ );
232151
+ });
232152
+ }
232153
+
231932
232154
  // src/tui/TextPager.ts
231933
232155
  import readline2 from "readline";
231934
232156
  async function pageText(text) {
@@ -231949,11 +232171,11 @@ async function pageText(text) {
231949
232171
  process.stdin.setRawMode(true);
231950
232172
  process.stdin.resume();
231951
232173
  readline2.emitKeypressEvents(process.stdin);
231952
- const waitForKeypress = () => new Promise((resolve13) => {
232174
+ const waitForKeypress = () => new Promise((resolve15) => {
231953
232175
  const onKeypress = (str, key) => {
231954
232176
  process.stdin.removeListener("keypress", onKeypress);
231955
- if (key?.ctrl && key.name === "c") return resolve13("interrupt");
231956
- resolve13(key?.name || str);
232177
+ if (key?.ctrl && key.name === "c") return resolve15("interrupt");
232178
+ resolve15(key?.name || str);
231957
232179
  };
231958
232180
  process.stdin.on("keypress", onKeypress);
231959
232181
  });
@@ -231983,11 +232205,12 @@ async function pageText(text) {
231983
232205
  // src/tui/FullscreenTui.ts
231984
232206
  var INPUT_PREFIX_WIDTH = 12;
231985
232207
  var FullscreenTui = class {
231986
- constructor(cwd, modelName, version, config) {
232208
+ constructor(cwd, modelName, version, config, dependencies = {}) {
231987
232209
  this.cwd = cwd;
231988
232210
  this.modelName = modelName;
231989
232211
  this.version = version;
231990
232212
  this.config = config;
232213
+ this.checkOrbitUpdate = dependencies.checkOrbitUpdate ?? (async (currentVersion) => (await new UpdateManager().checkAsync(currentVersion)).updateAvailable);
231991
232214
  }
231992
232215
  cwd;
231993
232216
  modelName;
@@ -232019,9 +232242,9 @@ var FullscreenTui = class {
232019
232242
  promptSession = new TuiPromptSession(() => this.render());
232020
232243
  isThinking = false;
232021
232244
  sessionCost = 0;
232022
- lastNpmCheckTime = 0;
232023
- isCheckingNpm = false;
232024
- npmNeedsUpdate = false;
232245
+ hasCheckedOrbitUpdate = false;
232246
+ isCheckingOrbitUpdate = false;
232247
+ orbitUpdateAvailable = false;
232025
232248
  totalInputTokens = 0;
232026
232249
  totalCacheReadTokens = 0;
232027
232250
  totalOutputTokens = 0;
@@ -232058,6 +232281,7 @@ var FullscreenTui = class {
232058
232281
  hasNewOutputWhileScrolled = false;
232059
232282
  inputHistoryStore = new InputHistoryStore();
232060
232283
  terminalInitialized = false;
232284
+ checkOrbitUpdate;
232061
232285
  getPlanLines() {
232062
232286
  const now = Date.now();
232063
232287
  if (now - this.lastPlanReadTime < 2e3) {
@@ -232368,72 +232592,30 @@ var FullscreenTui = class {
232368
232592
  }
232369
232593
  this.terminalInitialized = false;
232370
232594
  }
232371
- getNpmNeedsUpdate() {
232372
- const now = Date.now();
232373
- if (now - this.lastNpmCheckTime > 8e3) {
232374
- this.refreshNpmStatusAsync().catch(() => {
232375
- });
232595
+ getOrbitUpdateAvailable() {
232596
+ if (!this.hasCheckedOrbitUpdate && !this.isCheckingOrbitUpdate) {
232597
+ void this.refreshOrbitUpdateStatus();
232376
232598
  }
232377
- return this.npmNeedsUpdate;
232599
+ return this.orbitUpdateAvailable;
232378
232600
  }
232379
- async refreshNpmStatusAsync() {
232380
- if (this.isCheckingNpm) return;
232381
- this.isCheckingNpm = true;
232382
- this.lastNpmCheckTime = Date.now();
232601
+ setOrbitUpdateAvailable(updateAvailable) {
232602
+ this.hasCheckedOrbitUpdate = true;
232603
+ this.orbitUpdateAvailable = updateAvailable;
232604
+ if (this.isActive) this.render();
232605
+ }
232606
+ async refreshOrbitUpdateStatus() {
232607
+ if (this.hasCheckedOrbitUpdate || this.isCheckingOrbitUpdate) return;
232608
+ this.isCheckingOrbitUpdate = true;
232609
+ this.hasCheckedOrbitUpdate = true;
232383
232610
  try {
232384
- const packageJsonPath = join14(this.cwd, "package.json");
232385
- if (!existsSync15(packageJsonPath)) {
232386
- this.npmNeedsUpdate = false;
232387
- this.isCheckingNpm = false;
232388
- return;
232389
- }
232390
- const nodeModulesPath = join14(this.cwd, "node_modules");
232391
- if (!existsSync15(nodeModulesPath)) {
232392
- this.npmNeedsUpdate = true;
232393
- this.isCheckingNpm = false;
232394
- this.render();
232395
- return;
232396
- }
232397
- const lockfiles = [
232398
- "package-lock.json",
232399
- "pnpm-lock.yaml",
232400
- "yarn.lock",
232401
- "bun.lockb"
232402
- ];
232403
- let maxLockfileMtime = 0;
232404
- let hasLockfile = false;
232405
- for (const lf of lockfiles) {
232406
- const lfPath = join14(this.cwd, lf);
232407
- if (existsSync15(lfPath)) {
232408
- hasLockfile = true;
232409
- const stat = statSync5(lfPath);
232410
- if (stat.mtimeMs > maxLockfileMtime) {
232411
- maxLockfileMtime = stat.mtimeMs;
232412
- }
232413
- }
232414
- }
232415
- const configMtimeToCheck = hasLockfile ? maxLockfileMtime : statSync5(packageJsonPath).mtimeMs;
232416
- let maxInstallStateMtime = statSync5(nodeModulesPath).mtimeMs;
232417
- const stateFiles = [
232418
- join14(nodeModulesPath, ".modules.yaml"),
232419
- // pnpm
232420
- join14(nodeModulesPath, ".package-lock.json")
232421
- // npm
232422
- ];
232423
- for (const sf of stateFiles) {
232424
- if (existsSync15(sf)) {
232425
- const stat = statSync5(sf);
232426
- if (stat.mtimeMs > maxInstallStateMtime) {
232427
- maxInstallStateMtime = stat.mtimeMs;
232428
- }
232429
- }
232430
- }
232431
- this.npmNeedsUpdate = configMtimeToCheck > maxInstallStateMtime;
232611
+ this.orbitUpdateAvailable = await this.checkOrbitUpdate(
232612
+ this.version.replace(/^v/i, "")
232613
+ );
232432
232614
  } catch {
232433
- this.npmNeedsUpdate = false;
232615
+ this.orbitUpdateAvailable = false;
232434
232616
  } finally {
232435
- this.isCheckingNpm = false;
232436
- this.render();
232617
+ this.isCheckingOrbitUpdate = false;
232618
+ if (this.isActive) this.render();
232437
232619
  }
232438
232620
  }
232439
232621
  getGitSummary() {
@@ -232464,20 +232646,20 @@ var FullscreenTui = class {
232464
232646
  modified: 0,
232465
232647
  deleted: 0
232466
232648
  };
232467
- const branchPromise = new Promise((resolve13) => {
232649
+ const branchPromise = new Promise((resolve15) => {
232468
232650
  exec3(
232469
232651
  "git rev-parse --abbrev-ref HEAD",
232470
232652
  { cwd: this.cwd },
232471
232653
  (err, stdout) => {
232472
- if (err) resolve13("no-git");
232473
- else resolve13(stdout.trim());
232654
+ if (err) resolve15("no-git");
232655
+ else resolve15(stdout.trim());
232474
232656
  }
232475
232657
  );
232476
232658
  });
232477
- const statusPromise = new Promise((resolve13) => {
232659
+ const statusPromise = new Promise((resolve15) => {
232478
232660
  exec3("git status --porcelain", { cwd: this.cwd }, (err, stdout) => {
232479
- if (err) resolve13("");
232480
- else resolve13(stdout);
232661
+ if (err) resolve15("");
232662
+ else resolve15(stdout);
232481
232663
  });
232482
232664
  });
232483
232665
  const [branch, statusOutput] = await Promise.all([
@@ -232955,8 +233137,8 @@ var FullscreenTui = class {
232955
233137
  this.start(this.budgetLimit);
232956
233138
  }
232957
233139
  process.stdout.write("\x1B[?25h");
232958
- return new Promise((resolve13) => {
232959
- this.resolveInput = resolve13;
233140
+ return new Promise((resolve15) => {
233141
+ this.resolveInput = resolve15;
232960
233142
  this.inputBuffer = "";
232961
233143
  this.cursorPosition = 0;
232962
233144
  this.hideAutocomplete = false;
@@ -232991,7 +233173,7 @@ var FullscreenTui = class {
232991
233173
  cleanup();
232992
233174
  process.stdout.write("\x1B[?25l");
232993
233175
  this.resolveInput = null;
232994
- resolve13(null);
233176
+ resolve15(null);
232995
233177
  } else {
232996
233178
  this.ctrlCPressedOnce = true;
232997
233179
  if (this.ctrlCTimeout) clearTimeout(this.ctrlCTimeout);
@@ -233045,7 +233227,7 @@ var FullscreenTui = class {
233045
233227
  this.inputBuffer = "";
233046
233228
  this.cursorPosition = 0;
233047
233229
  this.render();
233048
- resolve13(submitted);
233230
+ resolve15(submitted);
233049
233231
  return;
233050
233232
  }
233051
233233
  if (key && key.ctrl && key.name === "j") {
@@ -233485,7 +233667,7 @@ var FullscreenTui = class {
233485
233667
  "/mode": "\u52A8\u6001\u5207\u6362\u7CFB\u7EDF\u5B89\u5168\u786E\u8BA4\u6A21\u5F0F (strict, normal, auto, plan)",
233486
233668
  "/copy": "\u62F7\u8D1D AI \u7684\u4E0A\u4E00\u6761\u56DE\u590D\u5230\u7CFB\u7EDF\u526A\u8D34\u677F",
233487
233669
  "/run": "\u6267\u884C\u4E00\u6761\u672C\u673A Shell \u547D\u4EE4\uFF0C\u4F1A\u5148\u8D70\u6743\u9650\u68C0\u67E5",
233488
- "/update": "\u68C0\u6D4B\u5E76\u66F4\u65B0\u5F53\u524D\u9879\u76EE\u4F9D\u8D56",
233670
+ "/update": "\u68C0\u67E5\u5E76\u66F4\u65B0 Orbit \u5230\u6700\u65B0 npm \u7248\u672C",
233489
233671
  "/webui": "\u542F\u52A8\u5E76\u6253\u5F00 Orbit \u56FE\u5F62\u63A7\u5236\u53F0\u9875\u9762"
233490
233672
  } : {
233491
233673
  "/help": "Display detailed help and commands reference",
@@ -233511,7 +233693,7 @@ var FullscreenTui = class {
233511
233693
  "/mode": "Switch permission mode (strict, normal, auto, plan)",
233512
233694
  "/copy": "Copy last assistant response to clipboard",
233513
233695
  "/run": "Run one local shell command after permission checks",
233514
- "/update": "Detect and update current project dependencies",
233696
+ "/update": "Check and update Orbit from npm",
233515
233697
  "/webui": "Start and open the Orbit graphical console"
233516
233698
  };
233517
233699
  const maxVisible = 5;
@@ -233690,7 +233872,7 @@ var FullscreenTui = class {
233690
233872
  const cleanModel = displayedModel.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "");
233691
233873
  const gitSummary = this.getGitSummary();
233692
233874
  const gitBranch = gitSummary.branch;
233693
- const heartColor = this.getNpmNeedsUpdate() ? `\x1B[5m\x1B[38;2;230;190;80m` : `\x1B[38;2;230;110;110m`;
233875
+ const heartColor = this.getOrbitUpdateAvailable() ? `\x1B[5m\x1B[38;2;230;190;80m` : `\x1B[38;2;230;110;110m`;
233694
233876
  const logoLines = [
233695
233877
  `\x1B[38;2;158;184;196m /\\___/\\ \x1B[0m`,
233696
233878
  `\x1B[38;2;158;184;196m ( o.o ) \x1B[0m`,
@@ -234106,9 +234288,9 @@ var FullscreenTui = class {
234106
234288
  };
234107
234289
 
234108
234290
  // src/runtime/ReplController.ts
234109
- import picocolors18 from "picocolors";
234291
+ import picocolors19 from "picocolors";
234110
234292
  import {
234111
- existsSync as existsSync28,
234293
+ existsSync as existsSync21,
234112
234294
  mkdirSync as mkdirSync13,
234113
234295
  readFileSync as readFileSync18,
234114
234296
  renameSync as renameSync8,
@@ -234120,23 +234302,21 @@ import { dirname as dirname9, resolve as resolve10 } from "path";
234120
234302
  import { homedir as homedir10 } from "os";
234121
234303
  import http2 from "http";
234122
234304
  import { randomBytes as randomBytes2, randomUUID as randomUUID8, timingSafeEqual as timingSafeEqual2 } from "crypto";
234123
- import { z as z41 } from "zod";
234305
+ import { z as z46 } from "zod";
234124
234306
 
234125
234307
  // src/runtime/CommandRouter.ts
234126
- import picocolors17 from "picocolors";
234127
- import { existsSync as existsSync21 } from "fs";
234128
- import { join as join17 } from "path";
234308
+ import picocolors18 from "picocolors";
234129
234309
 
234130
234310
  // src/commands/customCommands.ts
234131
234311
  import { existsSync as existsSync16, readFileSync as readFileSync16, readdirSync as readdirSync5 } from "fs";
234132
234312
  import { basename as basename5, extname, join as join15 } from "path";
234133
234313
  import { homedir as homedir8 } from "os";
234134
234314
  import { parse as parse3 } from "yaml";
234135
- import { z as z30 } from "zod";
234136
- var CommandMetadataSchema = z30.object({
234137
- description: z30.string().max(240).optional(),
234138
- argumentHint: z30.string().max(120).optional(),
234139
- "argument-hint": z30.string().max(120).optional()
234315
+ import { z as z31 } from "zod";
234316
+ var CommandMetadataSchema = z31.object({
234317
+ description: z31.string().max(240).optional(),
234318
+ argumentHint: z31.string().max(120).optional(),
234319
+ "argument-hint": z31.string().max(120).optional()
234140
234320
  });
234141
234321
  var VALID_COMMAND_NAME = /^[a-z0-9][a-z0-9-_]{0,47}$/i;
234142
234322
  var MAX_COMMAND_FILE_BYTES = 256 * 1024;
@@ -234282,20 +234462,20 @@ import { spawn as spawn2 } from "child_process";
234282
234462
  // src/runtime/webui/WebUiRuntime.ts
234283
234463
  import http from "http";
234284
234464
  import { randomBytes, randomUUID as randomUUID6 } from "crypto";
234285
- import { z as z36 } from "zod";
234465
+ import { z as z37 } from "zod";
234286
234466
 
234287
234467
  // src/runtime/AutocompleteCandidates.ts
234288
234468
  import glob6 from "fast-glob";
234289
234469
  import { existsSync as existsSync17, readFileSync as readFileSync17, readdirSync as readdirSync6 } from "fs";
234290
234470
  import { homedir as homedir9 } from "os";
234291
234471
  import { dirname as dirname8, join as join16, resolve as resolve7 } from "path";
234292
- import { z as z31 } from "zod";
234293
- var symbolIndexSchema = z31.object({
234294
- files: z31.record(
234295
- z31.object({
234296
- symbols: z31.array(
234297
- z31.object({
234298
- name: z31.string().min(1)
234472
+ import { z as z35 } from "zod";
234473
+ var symbolIndexSchema = z35.object({
234474
+ files: z35.record(
234475
+ z35.object({
234476
+ symbols: z35.array(
234477
+ z35.object({
234478
+ name: z35.string().min(1)
234299
234479
  })
234300
234480
  ).optional()
234301
234481
  })
@@ -237786,7 +237966,7 @@ var WEB_UI_FAVICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4
237786
237966
 
237787
237967
  // src/runtime/webui/WebUiSecurity.ts
237788
237968
  import { timingSafeEqual } from "crypto";
237789
- import { z as z35 } from "zod";
237969
+ import { z as z36 } from "zod";
237790
237970
  function sanitizeWebEventPayload(type, payload) {
237791
237971
  if (!isRecord3(payload)) return void 0;
237792
237972
  switch (type) {
@@ -237979,7 +238159,7 @@ function sanitizeBaseUrl(value) {
237979
238159
  }
237980
238160
  }
237981
238161
  function webRequestErrorStatus(error) {
237982
- if (error instanceof z35.ZodError) return 400;
238162
+ if (error instanceof z36.ZodError) return 400;
237983
238163
  if (error instanceof Error && error.message === "Request body too large.") {
237984
238164
  return 413;
237985
238165
  }
@@ -238087,12 +238267,12 @@ function normalizeSafeWebUiPath(value) {
238087
238267
  }
238088
238268
  function completionFileScore(file, query) {
238089
238269
  const lower = file.toLocaleLowerCase();
238090
- const basename7 = lower.slice(lower.lastIndexOf("/") + 1);
238270
+ const basename8 = lower.slice(lower.lastIndexOf("/") + 1);
238091
238271
  const depth = file.split("/").length - 1;
238092
238272
  if (!query) return depth * 100 + file.length;
238093
- if (basename7 === query) return 0;
238094
- if (basename7.startsWith(query)) return 100 + depth * 4 + file.length;
238095
- if (basename7.includes(query)) return 200 + depth * 4 + file.length;
238273
+ if (basename8 === query) return 0;
238274
+ if (basename8.startsWith(query)) return 100 + depth * 4 + file.length;
238275
+ if (basename8.includes(query)) return 200 + depth * 4 + file.length;
238096
238276
  if (lower.startsWith(query)) return 300 + depth * 4 + file.length;
238097
238277
  return 400 + lower.indexOf(query) + depth * 4 + file.length;
238098
238278
  }
@@ -244046,45 +244226,45 @@ var WEB_UI_STYLE_SECTIONS = [
244046
244226
  var WEB_UI_STYLES = WEB_UI_STYLE_SECTIONS.join("");
244047
244227
 
244048
244228
  // src/runtime/webui/WebUiRuntime.ts
244049
- var WebTurnIdSchema = z36.string().trim().min(8).max(100).regex(/^[a-zA-Z0-9_-]+$/);
244050
- var ChatRequestSchema = z36.object({
244051
- prompt: z36.string().trim().min(1).max(1e5),
244229
+ var WebTurnIdSchema = z37.string().trim().min(8).max(100).regex(/^[a-zA-Z0-9_-]+$/);
244230
+ var ChatRequestSchema = z37.object({
244231
+ prompt: z37.string().trim().min(1).max(1e5),
244052
244232
  turnId: WebTurnIdSchema.optional()
244053
244233
  }).strict();
244054
- var CancelRequestSchema = z36.object({ turnId: WebTurnIdSchema.nullish() }).strict();
244055
- var ApprovalDecisionSchema = z36.object({
244234
+ var CancelRequestSchema = z37.object({ turnId: WebTurnIdSchema.nullish() }).strict();
244235
+ var ApprovalDecisionSchema = z37.object({
244056
244236
  id: WebTurnIdSchema,
244057
- approved: z36.boolean()
244237
+ approved: z37.boolean()
244058
244238
  }).strict();
244059
- var SettingsPatchSchema = z36.object({
244060
- provider: z36.string().trim().min(1).max(256).optional(),
244061
- model: z36.string().trim().min(1).max(200).optional(),
244062
- permissionMode: z36.enum(["strict", "normal", "auto", "plan"]).optional(),
244063
- webSearchEnabled: z36.boolean().optional(),
244064
- webSearchProvider: z36.enum(["auto", "searxng", "tavily", "bing", "duckduckgo"]).optional(),
244065
- webSearchMaxResults: z36.number().int().min(1).max(20).optional()
244239
+ var SettingsPatchSchema = z37.object({
244240
+ provider: z37.string().trim().min(1).max(256).optional(),
244241
+ model: z37.string().trim().min(1).max(200).optional(),
244242
+ permissionMode: z37.enum(["strict", "normal", "auto", "plan"]).optional(),
244243
+ webSearchEnabled: z37.boolean().optional(),
244244
+ webSearchProvider: z37.enum(["auto", "searxng", "tavily", "bing", "duckduckgo"]).optional(),
244245
+ webSearchMaxResults: z37.number().int().min(1).max(20).optional()
244066
244246
  }).strict();
244067
- var SessionActionSchema = z36.discriminatedUnion("action", [
244068
- z36.object({ action: z36.literal("new") }).strict(),
244247
+ var SessionActionSchema = z37.discriminatedUnion("action", [
244248
+ z37.object({ action: z37.literal("new") }).strict(),
244069
244249
  ...["resume", "archive", "restore", "delete"].map(
244070
- (action) => z36.object({
244071
- action: z36.literal(action),
244072
- sessionId: z36.string().trim().min(1).max(200).regex(/^[a-zA-Z0-9_-]+$/)
244250
+ (action) => z37.object({
244251
+ action: z37.literal(action),
244252
+ sessionId: z37.string().trim().min(1).max(200).regex(/^[a-zA-Z0-9_-]+$/)
244073
244253
  }).strict()
244074
244254
  )
244075
244255
  ]);
244076
- var ProjectActionSchema = z36.discriminatedUnion("action", [
244077
- z36.object({ action: z36.literal("pick") }).strict(),
244078
- z36.object({
244079
- action: z36.enum(["open", "create"]),
244080
- path: z36.string().trim().min(1).max(4096)
244256
+ var ProjectActionSchema = z37.discriminatedUnion("action", [
244257
+ z37.object({ action: z37.literal("pick") }).strict(),
244258
+ z37.object({
244259
+ action: z37.enum(["open", "create"]),
244260
+ path: z37.string().trim().min(1).max(4096)
244081
244261
  }).strict(),
244082
- z36.object({
244083
- action: z36.literal("remove"),
244084
- projectId: z36.string().trim().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/)
244262
+ z37.object({
244263
+ action: z37.literal("remove"),
244264
+ projectId: z37.string().trim().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/)
244085
244265
  }).strict()
244086
244266
  ]);
244087
- var CompletionQuerySchema = z36.string().trim().max(200);
244267
+ var CompletionQuerySchema = z37.string().trim().max(200);
244088
244268
  function safeCall2(fn) {
244089
244269
  try {
244090
244270
  return fn();
@@ -244652,13 +244832,13 @@ var WebUiApprovalBroker = class {
244652
244832
  throw new Error("Another Web UI approval is already pending.");
244653
244833
  }
244654
244834
  const snapshot = sanitizeApprovalRequest(request);
244655
- return new Promise((resolve13) => {
244835
+ return new Promise((resolve15) => {
244656
244836
  const timeout = setTimeout(
244657
244837
  () => this.settle(false),
244658
244838
  WEB_APPROVAL_TIMEOUT_MS
244659
244839
  );
244660
244840
  timeout.unref();
244661
- this.pending = { snapshot, resolve: resolve13, timeout };
244841
+ this.pending = { snapshot, resolve: resolve15, timeout };
244662
244842
  eventBus.emitEvent("web_approval_requested", {
244663
244843
  approvalId: snapshot.id,
244664
244844
  kind: snapshot.kind,
@@ -245115,7 +245295,7 @@ async function handleWorkspaceConfigCommand(configArgument, dependencies) {
245115
245295
 
245116
245296
  // src/runtime/commands/ContextCommandHandler.ts
245117
245297
  import glob7 from "fast-glob";
245118
- import { existsSync as existsSync18, statSync as statSync6 } from "fs";
245298
+ import { existsSync as existsSync18, statSync as statSync5 } from "fs";
245119
245299
  import { isAbsolute as isAbsolute5, relative as relative3, resolve as resolve8 } from "path";
245120
245300
  import picocolors12 from "picocolors";
245121
245301
  function parseAddArgument(argument) {
@@ -245303,7 +245483,7 @@ ${matched.map((file) => ` \u2022 ${file}`).join("\n")}`
245303
245483
  }
245304
245484
  const relativePath = toWorkspaceRelative(cwd, absolutePath);
245305
245485
  try {
245306
- if (statSync6(absolutePath).isDirectory()) {
245486
+ if (statSync5(absolutePath).isDirectory()) {
245307
245487
  const files = await glob7("**/*", {
245308
245488
  cwd: absolutePath,
245309
245489
  onlyFiles: true,
@@ -245467,20 +245647,20 @@ async function handleContextCommand(command, argument, dependencies) {
245467
245647
  }
245468
245648
 
245469
245649
  // src/runtime/commands/RollbackCommandHandler.ts
245470
- import { execFileSync as execFileSync3 } from "child_process";
245650
+ import { execFileSync as execFileSync5 } from "child_process";
245471
245651
  import { existsSync as existsSync19, rmSync as rmSync5 } from "fs";
245472
245652
  import picocolors13 from "picocolors";
245473
- import { z as z37 } from "zod";
245474
- var GitStatusCodeSchema = z37.string().length(2).regex(/^[ MADRCU?!]{2}$/);
245475
- var GitStatusPathSchema = z37.string().min(1).max(32768);
245653
+ import { z as z38 } from "zod";
245654
+ var GitStatusCodeSchema = z38.string().length(2).regex(/^[ MADRCU?!]{2}$/);
245655
+ var GitStatusPathSchema = z38.string().min(1).max(32768);
245476
245656
  var defaultGitAdapter = {
245477
- status: (cwd) => execFileSync3("git", ["status", "--porcelain=v1", "-z"], {
245657
+ status: (cwd) => execFileSync5("git", ["status", "--porcelain=v1", "-z"], {
245478
245658
  cwd,
245479
245659
  encoding: "utf8",
245480
245660
  stdio: ["ignore", "pipe", "ignore"]
245481
245661
  }),
245482
245662
  checkout: (cwd, filePath) => {
245483
- execFileSync3("git", ["checkout", "--", filePath], {
245663
+ execFileSync5("git", ["checkout", "--", filePath], {
245484
245664
  cwd,
245485
245665
  stdio: "ignore"
245486
245666
  });
@@ -245903,32 +246083,32 @@ function ensureSessionTitle(loop, prompt) {
245903
246083
  }
245904
246084
 
245905
246085
  // src/runtime/ModelDiscovery.ts
245906
- import { z as z38 } from "zod";
245907
- var ModelEntrySchema = z38.object({
245908
- id: z38.unknown().optional(),
245909
- model: z38.unknown().optional(),
245910
- context_length: z38.unknown().optional(),
245911
- context_window: z38.unknown().optional(),
245912
- max_context_tokens: z38.unknown().optional(),
245913
- max_output_tokens: z38.unknown().optional(),
245914
- input_modalities: z38.unknown().optional(),
245915
- output_modalities: z38.unknown().optional(),
245916
- modalities: z38.unknown().optional(),
245917
- architecture: z38.unknown().optional(),
245918
- capabilities: z38.unknown().optional(),
245919
- supported_parameters: z38.unknown().optional(),
245920
- type: z38.unknown().optional(),
245921
- kind: z38.unknown().optional(),
245922
- task: z38.unknown().optional(),
245923
- endpoint: z38.unknown().optional(),
245924
- details: z38.unknown().optional()
246086
+ import { z as z39 } from "zod";
246087
+ var ModelEntrySchema = z39.object({
246088
+ id: z39.unknown().optional(),
246089
+ model: z39.unknown().optional(),
246090
+ context_length: z39.unknown().optional(),
246091
+ context_window: z39.unknown().optional(),
246092
+ max_context_tokens: z39.unknown().optional(),
246093
+ max_output_tokens: z39.unknown().optional(),
246094
+ input_modalities: z39.unknown().optional(),
246095
+ output_modalities: z39.unknown().optional(),
246096
+ modalities: z39.unknown().optional(),
246097
+ architecture: z39.unknown().optional(),
246098
+ capabilities: z39.unknown().optional(),
246099
+ supported_parameters: z39.unknown().optional(),
246100
+ type: z39.unknown().optional(),
246101
+ kind: z39.unknown().optional(),
246102
+ task: z39.unknown().optional(),
246103
+ endpoint: z39.unknown().optional(),
246104
+ details: z39.unknown().optional()
245925
246105
  }).passthrough();
245926
- var ModelListSchema = z38.union([
245927
- z38.object({ data: z38.array(ModelEntrySchema).max(1e3) }),
245928
- z38.object({ models: z38.array(ModelEntrySchema).max(1e3) }),
245929
- z38.array(ModelEntrySchema).max(1e3)
246106
+ var ModelListSchema = z39.union([
246107
+ z39.object({ data: z39.array(ModelEntrySchema).max(1e3) }),
246108
+ z39.object({ models: z39.array(ModelEntrySchema).max(1e3) }),
246109
+ z39.array(ModelEntrySchema).max(1e3)
245930
246110
  ]);
245931
- var DiscoveryUrlSchema = z38.string().url().max(4096).transform((value) => new URL(value));
246111
+ var DiscoveryUrlSchema = z39.string().url().max(4096).transform((value) => new URL(value));
245932
246112
  var MAX_MODEL_RESPONSE_BYTES = 2 * 1024 * 1024;
245933
246113
  async function discoverProviderModels(options) {
245934
246114
  const base = DiscoveryUrlSchema.parse(options.baseUrl.trim());
@@ -246095,9 +246275,9 @@ function normalizeModelEntries(entries) {
246095
246275
  }
246096
246276
  return { models, modelCapabilities };
246097
246277
  }
246098
- var OllamaShowSchema = z38.object({
246099
- capabilities: z38.array(z38.string().max(128)).max(64).optional(),
246100
- model_info: z38.record(z38.unknown()).optional()
246278
+ var OllamaShowSchema = z39.object({
246279
+ capabilities: z39.array(z39.string().max(128)).max(64).optional(),
246280
+ model_info: z39.record(z39.unknown()).optional()
246101
246281
  }).passthrough();
246102
246282
  async function enrichOllamaCapabilities(base, models, target, fetchImpl, signal) {
246103
246283
  const endpoint = new URL(base);
@@ -246235,7 +246415,7 @@ function copyBooleanCapability(source, sourceKey, target, targetKey) {
246235
246415
 
246236
246416
  // src/runtime/ProjectLauncher.ts
246237
246417
  import { spawn as spawn3 } from "child_process";
246238
- import { existsSync as existsSync20, mkdirSync as mkdirSync12, realpathSync as realpathSync3, statSync as statSync7 } from "fs";
246418
+ import { existsSync as existsSync20, mkdirSync as mkdirSync12, realpathSync as realpathSync3, statSync as statSync6 } from "fs";
246239
246419
  import { isAbsolute as isAbsolute6, parse as parse4, resolve as resolve9 } from "path";
246240
246420
  function launchOrbitProject(request, options = {}) {
246241
246421
  if (!isAbsolute6(request.path)) {
@@ -246251,7 +246431,7 @@ function launchOrbitProject(request, options = {}) {
246251
246431
  }
246252
246432
  mkdirSync12(requestedPath, { recursive: true });
246253
246433
  }
246254
- if (!statSync7(requestedPath).isDirectory()) {
246434
+ if (!statSync6(requestedPath).isDirectory()) {
246255
246435
  throw new Error("Project path must point to a directory.");
246256
246436
  }
246257
246437
  const projectPath = realpathSync3(requestedPath);
@@ -246276,9 +246456,9 @@ function launchOrbitProject(request, options = {}) {
246276
246456
  }
246277
246457
 
246278
246458
  // src/runtime/ProjectFolderPicker.ts
246279
- import { execFile as execFile3 } from "child_process";
246280
- import { promisify as promisify3 } from "util";
246281
- var execFileAsync = promisify3(execFile3);
246459
+ import { execFile as execFile5 } from "child_process";
246460
+ import { promisify as promisify4 } from "util";
246461
+ var execFileAsync = promisify4(execFile5);
246282
246462
  async function selectOrbitProjectFolder(options = {}) {
246283
246463
  const platform = options.platform ?? process.platform;
246284
246464
  const run = options.run ?? (async (executable, args) => execFileAsync(executable, args, {
@@ -246344,9 +246524,9 @@ function isPickerCancellation(error) {
246344
246524
 
246345
246525
  // src/runtime/commands/SessionMetadataCommandHandler.ts
246346
246526
  import picocolors15 from "picocolors";
246347
- import { z as z39 } from "zod";
246348
- var GoalSchema = z39.string().trim().min(1).max(4e3);
246349
- var SessionTitleSchema = z39.string().trim().min(1).max(160);
246527
+ import { z as z40 } from "zod";
246528
+ var GoalSchema = z40.string().trim().min(1).max(4e3);
246529
+ var SessionTitleSchema = z40.string().trim().min(1).max(160);
246350
246530
  function handleSessionMetadataCommand(command, argument, dependencies) {
246351
246531
  if (command === "/goal") {
246352
246532
  handleGoal(argument, dependencies);
@@ -246411,9 +246591,9 @@ function handleRename(argument, { loop, isZh, printOutput }) {
246411
246591
 
246412
246592
  // src/runtime/commands/WorkspaceStateCommandHandler.ts
246413
246593
  import picocolors16 from "picocolors";
246414
- import { z as z40 } from "zod";
246415
- var TextSchema = z40.string().trim().min(1).max(2e3);
246416
- var ItemReferenceSchema = z40.string().trim().min(1).max(100);
246594
+ import { z as z41 } from "zod";
246595
+ var TextSchema = z41.string().trim().min(1).max(2e3);
246596
+ var ItemReferenceSchema = z41.string().trim().min(1).max(100);
246417
246597
  function handleWorkspaceStateCommand(command, argument, dependencies) {
246418
246598
  if (command === "/memory") {
246419
246599
  handleMemory(argument, dependencies);
@@ -246586,13 +246766,90 @@ function resolveItemId(reference, items) {
246586
246766
  return items.find((item) => item.id === parsed.data)?.id;
246587
246767
  }
246588
246768
 
246769
+ // src/commands/update.ts
246770
+ import readline4 from "readline";
246771
+ import picocolors17 from "picocolors";
246772
+ import { z as z45 } from "zod";
246773
+ var UpdateCommandOptionsSchema = z45.object({
246774
+ check: z45.boolean().default(false),
246775
+ yes: z45.boolean().default(false),
246776
+ json: z45.boolean().default(false)
246777
+ }).strict();
246778
+ async function runUpdate(currentVersion, rawOptions, dependencies = {}) {
246779
+ const options = UpdateCommandOptionsSchema.parse(rawOptions);
246780
+ const manager = dependencies.manager ?? new UpdateManager();
246781
+ const write = dependencies.write ?? ((text) => console.log(text));
246782
+ const check = manager.check(currentVersion);
246783
+ if (!check.updateAvailable) {
246784
+ const result2 = { check, installed: false };
246785
+ write(
246786
+ options.json ? JSON.stringify({ schemaVersion: 1, ...result2 }) : picocolors17.green(
246787
+ `\u2714 Orbit ${check.currentVersion} is already up to date.`
246788
+ )
246789
+ );
246790
+ return result2;
246791
+ }
246792
+ if (options.check || options.json && !options.yes) {
246793
+ const result2 = { check, installed: false };
246794
+ write(
246795
+ options.json ? JSON.stringify({ schemaVersion: 1, ...result2 }) : `${picocolors17.yellow("\u25CF Update available:")} ${check.currentVersion} \u2192 ${check.latestVersion}
246796
+ Run ${picocolors17.cyan("orbit update --yes")} to install it.`
246797
+ );
246798
+ return result2;
246799
+ }
246800
+ let confirmed = options.yes;
246801
+ if (!confirmed) {
246802
+ const interactive = dependencies.interactive ?? Boolean(process.stdin.isTTY);
246803
+ if (!interactive) {
246804
+ throw new Error(
246805
+ "Updating requires an interactive confirmation or the explicit --yes flag."
246806
+ );
246807
+ }
246808
+ const confirm = dependencies.confirm ?? confirmUpdate;
246809
+ confirmed = await confirm(
246810
+ `Update Orbit ${check.currentVersion} \u2192 ${check.latestVersion}? [y/N] `
246811
+ );
246812
+ }
246813
+ if (!confirmed) {
246814
+ write(picocolors17.yellow("\u26A0 Update cancelled."));
246815
+ return { check, installed: false };
246816
+ }
246817
+ dependencies.beforeInstall?.();
246818
+ try {
246819
+ manager.install(check.latestVersion, !options.json);
246820
+ } finally {
246821
+ dependencies.afterInstall?.();
246822
+ }
246823
+ const result = { check, installed: true };
246824
+ write(
246825
+ options.json ? JSON.stringify({ schemaVersion: 1, ...result }) : picocolors17.green(
246826
+ `\u2714 Orbit ${check.latestVersion} installed. Restart Orbit to use the new version.`
246827
+ )
246828
+ );
246829
+ return result;
246830
+ }
246831
+ async function confirmUpdate(prompt) {
246832
+ const interfaceInstance = readline4.createInterface({
246833
+ input: process.stdin,
246834
+ output: process.stdout
246835
+ });
246836
+ try {
246837
+ const answer = await new Promise(
246838
+ (resolve15) => interfaceInstance.question(prompt, resolve15)
246839
+ );
246840
+ return /^(?:y|yes)$/i.test(answer.trim());
246841
+ } finally {
246842
+ interfaceInstance.close();
246843
+ }
246844
+ }
246845
+
246589
246846
  // src/runtime/CommandRouter.ts
246590
246847
  var require2 = createRequire2(import.meta.url);
246591
246848
  function stripAnsi4(value) {
246592
246849
  return value.replace(/\u001b\[[0-9;]*m/g, "");
246593
246850
  }
246594
246851
  var CommandRouter = class {
246595
- constructor(cwd, config, providerInstance, setProviderInstance, loop, tui, useFullscreenTui, getCandidates, setCandidates, getLocalState2, saveLocalState, tuiInteraction, multi) {
246852
+ constructor(cwd, config, providerInstance, setProviderInstance, loop, tui, useFullscreenTui, getCandidates, setCandidates, getLocalState2, saveLocalState, tuiInteraction, multi, updateOrbit = runUpdate) {
246596
246853
  this.cwd = cwd;
246597
246854
  this.config = config;
246598
246855
  this.providerInstance = providerInstance;
@@ -246606,6 +246863,7 @@ var CommandRouter = class {
246606
246863
  this.saveLocalState = saveLocalState;
246607
246864
  this.tuiInteraction = tuiInteraction;
246608
246865
  this.multi = multi;
246866
+ this.updateOrbit = updateOrbit;
246609
246867
  }
246610
246868
  cwd;
246611
246869
  config;
@@ -246620,6 +246878,7 @@ var CommandRouter = class {
246620
246878
  saveLocalState;
246621
246879
  tuiInteraction;
246622
246880
  multi;
246881
+ updateOrbit;
246623
246882
  runCoordinator = new RunCoordinator();
246624
246883
  webApprovalBroker = new WebUiApprovalBroker();
246625
246884
  webUiRunnable = null;
@@ -246712,7 +246971,7 @@ var CommandRouter = class {
246712
246971
  }
246713
246972
  if (command === "/exit" || command === "/quit") {
246714
246973
  this.printOutput(
246715
- picocolors17.yellow("Exiting Orbit Interactive Shell. Goodbye!")
246974
+ picocolors18.yellow("Exiting Orbit Interactive Shell. Goodbye!")
246716
246975
  );
246717
246976
  return { shouldExit: true, processed: true };
246718
246977
  }
@@ -246768,12 +247027,12 @@ var CommandRouter = class {
246768
247027
  const displayUrl = new URL(handle.url);
246769
247028
  displayUrl.hash = "";
246770
247029
  this.printOutput(
246771
- isZh ? picocolors17.green(`\u2714 Orbit Web UI \u5DF2\u542F\u52A8: ${displayUrl.href}`) : picocolors17.green(`\u2714 Orbit Web UI running: ${displayUrl.href}`)
247030
+ isZh ? picocolors18.green(`\u2714 Orbit Web UI \u5DF2\u542F\u52A8: ${displayUrl.href}`) : picocolors18.green(`\u2714 Orbit Web UI running: ${displayUrl.href}`)
246772
247031
  );
246773
247032
  } catch (error) {
246774
247033
  const message = error instanceof Error ? error.message : String(error);
246775
247034
  this.printOutput(
246776
- isZh ? picocolors17.red(`\u2716 \u65E0\u6CD5\u542F\u52A8 Orbit Web UI: ${message}`) : picocolors17.red(`\u2716 Failed to start Orbit Web UI: ${message}`)
247035
+ isZh ? picocolors18.red(`\u2716 \u65E0\u6CD5\u542F\u52A8 Orbit Web UI: ${message}`) : picocolors18.red(`\u2716 Failed to start Orbit Web UI: ${message}`)
246777
247036
  );
246778
247037
  }
246779
247038
  return { shouldExit: false, processed: true };
@@ -246781,53 +247040,32 @@ var CommandRouter = class {
246781
247040
  if (command === "/update") {
246782
247041
  const isZh = config.language === "zh";
246783
247042
  const wasActive = useFullscreenTui && tui.isActive;
246784
- const packageJsonPath = join17(cwd, "package.json");
246785
- if (!existsSync21(packageJsonPath)) {
247043
+ const requestedFromWebUi = this.runCoordinator.isActive("web");
247044
+ try {
247045
+ const updateResult = await this.updateOrbit(
247046
+ readCliVersion(),
247047
+ { check: requestedFromWebUi },
247048
+ {
247049
+ interactive: true,
247050
+ confirm: (prompt) => Prompt.askApproval(prompt),
247051
+ write: (text) => this.printOutput(text),
247052
+ beforeInstall: () => {
247053
+ if (wasActive) tui.stop();
247054
+ },
247055
+ afterInstall: () => {
247056
+ tui.syncFromLoop(loop);
247057
+ if (wasActive) tui.start(config.budgetLimit);
247058
+ }
247059
+ }
247060
+ );
247061
+ tui.setOrbitUpdateAvailable?.(
247062
+ updateResult.installed ? false : updateResult.check.updateAvailable
247063
+ );
247064
+ } catch (error) {
247065
+ const message = error instanceof Error ? error.message : String(error);
246786
247066
  this.printOutput(
246787
- isZh ? picocolors17.yellow(
246788
- "\u5F53\u524D\u5DE5\u4F5C\u533A\u6CA1\u6709\u68C0\u6D4B\u5230 package.json\uFF0C\u4E0D\u652F\u6301 npm \u66F4\u65B0\u3002"
246789
- ) : picocolors17.yellow(
246790
- "No package.json found in the workspace. npm update not supported."
246791
- )
247067
+ isZh ? picocolors18.red(`\u2716 Orbit \u66F4\u65B0\u5931\u8D25: ${message}`) : picocolors18.red(`\u2716 Orbit update failed: ${message}`)
246792
247068
  );
246793
- return { shouldExit: false, processed: true };
246794
- }
246795
- let installCmd = "npm install";
246796
- if (existsSync21(join17(cwd, "pnpm-lock.yaml"))) {
246797
- installCmd = "pnpm install";
246798
- } else if (existsSync21(join17(cwd, "yarn.lock"))) {
246799
- installCmd = "yarn install";
246800
- } else if (existsSync21(join17(cwd, "bun.lockb"))) {
246801
- installCmd = "bun install";
246802
- }
246803
- if (wasActive) tui.stop();
246804
- try {
246805
- const approved = await Prompt.askApproval(
246806
- isZh ? `\u68C0\u6D4B\u5230\u9879\u76EE\u4F9D\u8D56\u9700\u8981\u66F4\u65B0\uFF0C\u662F\u5426\u8FD0\u884C "${installCmd}"\uFF1F` : `NPM dependencies need update. Run "${installCmd}"?`
246807
- );
246808
- if (approved) {
246809
- console.log(picocolors17.cyan(`
246810
- \u25CF Running "${installCmd}"...`));
246811
- const { execSync: execSync3 } = await import("child_process");
246812
- execSync3(installCmd, { cwd, stdio: "inherit" });
246813
- console.log(
246814
- picocolors17.green(`\u2714 Dependencies updated successfully.
246815
- `)
246816
- );
246817
- tui.npmNeedsUpdate = false;
246818
- tui.lastNpmCheckTime = Date.now();
246819
- } else {
246820
- console.log(picocolors17.yellow(`
246821
- \u2716 Update cancelled by user.
246822
- `));
246823
- }
246824
- } catch (err) {
246825
- console.log(picocolors17.red(`
246826
- \u2716 Update failed: ${err.message}
246827
- `));
246828
- } finally {
246829
- tui.syncFromLoop(loop);
246830
- if (wasActive) tui.start(config.budgetLimit);
246831
247069
  }
246832
247070
  return { shouldExit: false, processed: true };
246833
247071
  }
@@ -246849,42 +247087,42 @@ var CommandRouter = class {
246849
247087
  const costPct = budgetLimit > 0 ? Math.min(100, currentCost / budgetLimit * 100).toFixed(1) : "N/A";
246850
247088
  const barLen = 24;
246851
247089
  const filledLen = budgetLimit > 0 ? Math.round(currentCost / budgetLimit * barLen) : 0;
246852
- const bar = picocolors17.green("\u2588".repeat(filledLen)) + picocolors17.gray("\u2591".repeat(Math.max(0, barLen - filledLen)));
247090
+ const bar = picocolors18.green("\u2588".repeat(filledLen)) + picocolors18.gray("\u2591".repeat(Math.max(0, barLen - filledLen)));
246853
247091
  const statusLines = isZh ? [
246854
- picocolors17.bold("\u4F1A\u8BDD\u6982\u51B5"),
247092
+ picocolors18.bold("\u4F1A\u8BDD\u6982\u51B5"),
246855
247093
  "",
246856
- ` \u{1F194} ${picocolors17.gray("\u4F1A\u8BDD")} ${picocolors17.cyan(loop.getSessionId())}`,
246857
- ` \u{1F50C} ${picocolors17.gray("\u63D0\u4F9B\u5546")} ${picocolors17.cyan(this.providerInstance.id)}`,
246858
- ` \u{1F916} ${picocolors17.gray("\u5F53\u524D\u6A21\u578B")} ${picocolors17.cyan(activeModel2)}`,
246859
- ` \u21AF ${picocolors17.gray("\u6A21\u578B\u8DEF\u7531")} ${picocolors17.cyan(routingMode)}`,
246860
- ` \u{1F6E1}\uFE0F ${picocolors17.gray("\u6743\u9650\u6A21\u5F0F")} ${picocolors17.green(mode.toUpperCase())}`,
246861
- ` \u25EB ${picocolors17.gray("\u8BA1\u5212/\u8BB0\u5FC6")} ${picocolors17.cyan(`${plan?.items.length || 0} / ${memory?.entries.length || 0}`)}`,
247094
+ ` \u{1F194} ${picocolors18.gray("\u4F1A\u8BDD")} ${picocolors18.cyan(loop.getSessionId())}`,
247095
+ ` \u{1F50C} ${picocolors18.gray("\u63D0\u4F9B\u5546")} ${picocolors18.cyan(this.providerInstance.id)}`,
247096
+ ` \u{1F916} ${picocolors18.gray("\u5F53\u524D\u6A21\u578B")} ${picocolors18.cyan(activeModel2)}`,
247097
+ ` \u21AF ${picocolors18.gray("\u6A21\u578B\u8DEF\u7531")} ${picocolors18.cyan(routingMode)}`,
247098
+ ` \u{1F6E1}\uFE0F ${picocolors18.gray("\u6743\u9650\u6A21\u5F0F")} ${picocolors18.green(mode.toUpperCase())}`,
247099
+ ` \u25EB ${picocolors18.gray("\u8BA1\u5212/\u8BB0\u5FC6")} ${picocolors18.cyan(`${plan?.items.length || 0} / ${memory?.entries.length || 0}`)}`,
246862
247100
  ...loop.getGoal() ? [
246863
- ` \u{1F3AF} ${picocolors17.gray("\u804A\u5929\u76EE\u6807")} ${picocolors17.cyan(loop.getGoal() || "")}`
247101
+ ` \u{1F3AF} ${picocolors18.gray("\u804A\u5929\u76EE\u6807")} ${picocolors18.cyan(loop.getGoal() || "")}`
246864
247102
  ] : [],
246865
- ` \u{1F9E0} ${picocolors17.gray("\u4E0A\u4E0B\u6587")} ${picocolors17.cyan(`~${contextStatus.estimatedHistoryTokens.toLocaleString()}`)} / ${contextStatus.maxContextTokens.toLocaleString()} tokens\uFF08${contextPct}% \u81EA\u52A8\u538B\u7F29\u7EBF\uFF09`,
247103
+ ` \u{1F9E0} ${picocolors18.gray("\u4E0A\u4E0B\u6587")} ${picocolors18.cyan(`~${contextStatus.estimatedHistoryTokens.toLocaleString()}`)} / ${contextStatus.maxContextTokens.toLocaleString()} tokens\uFF08${contextPct}% \u81EA\u52A8\u538B\u7F29\u7EBF\uFF09`,
246866
247104
  "",
246867
- picocolors17.bold("\u8D39\u7528\u4E0E\u9884\u7B97"),
247105
+ picocolors18.bold("\u8D39\u7528\u4E0E\u9884\u7B97"),
246868
247106
  "",
246869
- ` \u{1F4B0} $${picocolors17.yellow(currentCost.toFixed(4))} / $${picocolors17.gray(budgetLimit.toFixed(2))} (${costPct}%)`,
247107
+ ` \u{1F4B0} $${picocolors18.yellow(currentCost.toFixed(4))} / $${picocolors18.gray(budgetLimit.toFixed(2))} (${costPct}%)`,
246870
247108
  ` ${bar}`
246871
247109
  ] : [
246872
- picocolors17.bold("Session Overview"),
247110
+ picocolors18.bold("Session Overview"),
246873
247111
  "",
246874
- ` \u{1F194} ${picocolors17.gray("Session ID")} ${picocolors17.cyan(loop.getSessionId())}`,
246875
- ` \u{1F50C} ${picocolors17.gray("Provider")} ${picocolors17.cyan(this.providerInstance.id)}`,
246876
- ` \u{1F916} ${picocolors17.gray("Active Model")} ${picocolors17.cyan(activeModel2)}`,
246877
- ` \u21AF ${picocolors17.gray("Model Routing")} ${picocolors17.cyan(routingMode)}`,
246878
- ` \u{1F6E1}\uFE0F ${picocolors17.gray("Security Mode")} ${picocolors17.green(mode.toUpperCase())}`,
246879
- ` \u25EB ${picocolors17.gray("Plan / Memory")} ${picocolors17.cyan(`${plan?.items.length || 0} / ${memory?.entries.length || 0}`)}`,
247112
+ ` \u{1F194} ${picocolors18.gray("Session ID")} ${picocolors18.cyan(loop.getSessionId())}`,
247113
+ ` \u{1F50C} ${picocolors18.gray("Provider")} ${picocolors18.cyan(this.providerInstance.id)}`,
247114
+ ` \u{1F916} ${picocolors18.gray("Active Model")} ${picocolors18.cyan(activeModel2)}`,
247115
+ ` \u21AF ${picocolors18.gray("Model Routing")} ${picocolors18.cyan(routingMode)}`,
247116
+ ` \u{1F6E1}\uFE0F ${picocolors18.gray("Security Mode")} ${picocolors18.green(mode.toUpperCase())}`,
247117
+ ` \u25EB ${picocolors18.gray("Plan / Memory")} ${picocolors18.cyan(`${plan?.items.length || 0} / ${memory?.entries.length || 0}`)}`,
246880
247118
  ...loop.getGoal() ? [
246881
- ` \u{1F3AF} ${picocolors17.gray("Chat Goal")} ${picocolors17.cyan(loop.getGoal() || "")}`
247119
+ ` \u{1F3AF} ${picocolors18.gray("Chat Goal")} ${picocolors18.cyan(loop.getGoal() || "")}`
246882
247120
  ] : [],
246883
- ` \u{1F9E0} ${picocolors17.gray("Context")} ${picocolors17.cyan(`~${contextStatus.estimatedHistoryTokens.toLocaleString()}`)} / ${contextStatus.maxContextTokens.toLocaleString()} tokens (${contextPct}% of auto-compact threshold)`,
247121
+ ` \u{1F9E0} ${picocolors18.gray("Context")} ${picocolors18.cyan(`~${contextStatus.estimatedHistoryTokens.toLocaleString()}`)} / ${contextStatus.maxContextTokens.toLocaleString()} tokens (${contextPct}% of auto-compact threshold)`,
246884
247122
  "",
246885
- picocolors17.bold("Budget & Cost"),
247123
+ picocolors18.bold("Budget & Cost"),
246886
247124
  "",
246887
- ` \u{1F4B0} $${picocolors17.yellow(currentCost.toFixed(4))} / $${picocolors17.gray(budgetLimit.toFixed(2))} (${costPct}%)`,
247125
+ ` \u{1F4B0} $${picocolors18.yellow(currentCost.toFixed(4))} / $${picocolors18.gray(budgetLimit.toFixed(2))} (${costPct}%)`,
246888
247126
  ` ${bar}`
246889
247127
  ];
246890
247128
  this.printOutput(statusLines.join("\n"));
@@ -246906,7 +247144,7 @@ var CommandRouter = class {
246906
247144
  const isZh = activeConfig.language === "zh";
246907
247145
  const announceModel = (model) => {
246908
247146
  this.printOutput(
246909
- `${picocolors17.green("\u2714")} ${isZh ? `\u5F53\u524D\u6A21\u578B\u5DF2\u5207\u6362\u4E3A\uFF1A${picocolors17.green(model)}` : `Active model: ${picocolors17.green(model)}`}`
247147
+ `${picocolors18.green("\u2714")} ${isZh ? `\u5F53\u524D\u6A21\u578B\u5DF2\u5207\u6362\u4E3A\uFF1A${picocolors18.green(model)}` : `Active model: ${picocolors18.green(model)}`}`
246910
247148
  );
246911
247149
  };
246912
247150
  if (!modelArg) {
@@ -246968,7 +247206,7 @@ var CommandRouter = class {
246968
247206
  "__auto__"
246969
247207
  );
246970
247208
  if (!switched.ok) {
246971
- this.printOutput(picocolors17.red(`\u2716 ${switched.message}`));
247209
+ this.printOutput(picocolors18.red(`\u2716 ${switched.message}`));
246972
247210
  return { shouldExit: false, processed: true };
246973
247211
  }
246974
247212
  } else {
@@ -246977,7 +247215,7 @@ var CommandRouter = class {
246977
247215
  this.saveLocalState({ lastModel: "" });
246978
247216
  }
246979
247217
  this.printOutput(
246980
- picocolors17.green(
247218
+ picocolors18.green(
246981
247219
  isZh ? "\u2714 \u5DF2\u542F\u7528\u81EA\u52A8\u6A21\u578B\u8DEF\u7531\u3002" : "\u2714 Automatic model routing enabled."
246982
247220
  )
246983
247221
  );
@@ -246996,7 +247234,7 @@ var CommandRouter = class {
246996
247234
  allowUnlistedModel: selectedModel === "custom"
246997
247235
  });
246998
247236
  if (!switched.ok) {
246999
- this.printOutput(picocolors17.red(`\u2716 ${switched.message}`));
247237
+ this.printOutput(picocolors18.red(`\u2716 ${switched.message}`));
247000
247238
  return { shouldExit: false, processed: true };
247001
247239
  }
247002
247240
  } else {
@@ -247011,7 +247249,7 @@ var CommandRouter = class {
247011
247249
  loop.clearModelOverride();
247012
247250
  this.tui.syncFromLoop(loop);
247013
247251
  this.printOutput(
247014
- picocolors17.green(
247252
+ picocolors18.green(
247015
247253
  isZh ? "\u2714 \u5DF2\u542F\u7528\u81EA\u52A8\u6A21\u578B\u8DEF\u7531\u3002" : "\u2714 Automatic model routing enabled."
247016
247254
  )
247017
247255
  );
@@ -247027,14 +247265,14 @@ var CommandRouter = class {
247027
247265
  if (command === "/commit") {
247028
247266
  const commitMsg = parts.slice(1).join(" ").trim();
247029
247267
  const isZh = config.language === "zh";
247030
- const { execFileSync: execFileSync5, execSync: execSync3 } = await import("child_process");
247268
+ const { execFileSync: execFileSync7, execSync: execSync3 } = await import("child_process");
247031
247269
  try {
247032
247270
  let diff = execSync3("git diff --cached", { cwd }).toString().trim();
247033
247271
  if (!diff) {
247034
247272
  const unstaged = execSync3("git status --porcelain", { cwd }).toString().trim();
247035
247273
  if (!unstaged) {
247036
247274
  this.printOutput(
247037
- picocolors17.yellow(
247275
+ picocolors18.yellow(
247038
247276
  isZh ? "\u5DE5\u4F5C\u533A\u5E72\u51C0\uFF0C\u6CA1\u6709\u68C0\u6D4B\u5230\u4EFB\u4F55\u5DF2\u6682\u5B58\u6216\u672A\u6682\u5B58\u7684\u66F4\u6539\u3002" : "Workspace clean. No staged or unstaged changes found to commit."
247039
247277
  )
247040
247278
  );
@@ -247045,7 +247283,7 @@ var CommandRouter = class {
247045
247283
  );
247046
247284
  if (!autoStage) {
247047
247285
  this.printOutput(
247048
- picocolors17.yellow(
247286
+ picocolors18.yellow(
247049
247287
  isZh ? "\u64CD\u4F5C\u5DF2\u53D6\u6D88\u3002\u8BF7\u5148\u8FD0\u884C 'git add' \u6682\u5B58\u4F60\u7684\u4FEE\u6539\u3002" : "Operation cancelled. Please run 'git add' to stage your changes first."
247050
247288
  )
247051
247289
  );
@@ -247058,7 +247296,7 @@ var CommandRouter = class {
247058
247296
  diff = execSync3("git diff --cached", { cwd }).toString().trim();
247059
247297
  if (!diff) {
247060
247298
  this.printOutput(
247061
- picocolors17.red(
247299
+ picocolors18.red(
247062
247300
  isZh ? "\u2716 \u6682\u5B58\u5931\u8D25\u6216\u6682\u5B58\u540E\u4ECD\u65E0\u53D8\u66F4\u3002" : "\u2716 Staging failed or resulted in no diff."
247063
247301
  )
247064
247302
  );
@@ -247100,14 +247338,14 @@ ${diff.substring(0, 2e4)}`
247100
247338
  }
247101
247339
  }
247102
247340
  this.printOutput(
247103
- `Committing changes with message: "${picocolors17.green(finalMsg)}"`
247341
+ `Committing changes with message: "${picocolors18.green(finalMsg)}"`
247104
247342
  );
247105
- execFileSync5("git", ["commit", "-m", finalMsg], { cwd });
247343
+ execFileSync7("git", ["commit", "-m", finalMsg], { cwd });
247106
247344
  this.printOutput(
247107
- picocolors17.green("\u2714 Git commit created successfully.")
247345
+ picocolors18.green("\u2714 Git commit created successfully.")
247108
247346
  );
247109
247347
  } catch (err) {
247110
- this.printOutput(picocolors17.red(`\u2716 Commit failed: ${err.message}`));
247348
+ this.printOutput(picocolors18.red(`\u2716 Commit failed: ${err.message}`));
247111
247349
  }
247112
247350
  return { shouldExit: false, processed: true };
247113
247351
  }
@@ -247143,9 +247381,9 @@ ${diff.substring(0, 2e4)}`
247143
247381
  };
247144
247382
  if (!targetMode) {
247145
247383
  if (useFullscreenTui && tui.isActive) {
247146
- const question = isZh ? `\u5F53\u524D\u6A21\u5F0F: ${picocolors17.cyan(currentMode.toUpperCase())}
247384
+ const question = isZh ? `\u5F53\u524D\u6A21\u5F0F: ${picocolors18.cyan(currentMode.toUpperCase())}
247147
247385
 
247148
- \u9009\u62E9\u65B0\u7684\u5B89\u5168\u6A21\u5F0F:` : `Current mode: ${picocolors17.cyan(currentMode.toUpperCase())}
247386
+ \u9009\u62E9\u65B0\u7684\u5B89\u5168\u6A21\u5F0F:` : `Current mode: ${picocolors18.cyan(currentMode.toUpperCase())}
247149
247387
 
247150
247388
  Select a security mode:`;
247151
247389
  const choice = await Prompt.askSelect(question, [
@@ -247160,7 +247398,7 @@ Select a security mode:`;
247160
247398
  }
247161
247399
  } else {
247162
247400
  this.printOutput(
247163
- isZh ? picocolors17.yellow("\u7528\u6CD5: /mode <strict|normal|auto|plan>") : picocolors17.yellow("Usage: /mode <strict|normal|auto|plan>")
247401
+ isZh ? picocolors18.yellow("\u7528\u6CD5: /mode <strict|normal|auto|plan>") : picocolors18.yellow("Usage: /mode <strict|normal|auto|plan>")
247164
247402
  );
247165
247403
  }
247166
247404
  return { shouldExit: false, processed: true };
@@ -247168,9 +247406,9 @@ Select a security mode:`;
247168
247406
  const validModes = ["strict", "normal", "auto", "plan"];
247169
247407
  if (!validModes.includes(targetMode)) {
247170
247408
  this.printOutput(
247171
- isZh ? picocolors17.red(
247409
+ isZh ? picocolors18.red(
247172
247410
  `\u2716 \u65E0\u6548\u7684\u5B89\u5168\u6A21\u5F0F: ${targetMode}\u3002\u53EF\u9009\u6A21\u5F0F: ${validModes.join(", ")}`
247173
- ) : picocolors17.red(
247411
+ ) : picocolors18.red(
247174
247412
  `\u2716 Invalid security mode: ${targetMode}. Valid modes: ${validModes.join(", ")}`
247175
247413
  )
247176
247414
  );
@@ -247179,19 +247417,19 @@ Select a security mode:`;
247179
247417
  loop.getConfig().permissions.mode = targetMode;
247180
247418
  tui.syncFromLoop(loop);
247181
247419
  if (useFullscreenTui && tui.isActive) {
247182
- const msg = isZh ? `\u5F53\u524D\u6A21\u5F0F: ${picocolors17.cyan(currentMode.toUpperCase())}
247420
+ const msg = isZh ? `\u5F53\u524D\u6A21\u5F0F: ${picocolors18.cyan(currentMode.toUpperCase())}
247183
247421
 
247184
- ${picocolors17.green("\u2714")} \u5DF2\u5207\u6362\u5B89\u5168\u6A21\u5F0F\u81F3: ${picocolors17.green(targetMode.toUpperCase())}` : `Previous mode: ${picocolors17.cyan(currentMode.toUpperCase())}
247422
+ ${picocolors18.green("\u2714")} \u5DF2\u5207\u6362\u5B89\u5168\u6A21\u5F0F\u81F3: ${picocolors18.green(targetMode.toUpperCase())}` : `Previous mode: ${picocolors18.cyan(currentMode.toUpperCase())}
247185
247423
 
247186
- ${picocolors17.green("\u2714")} Switched security mode to: ${picocolors17.green(targetMode.toUpperCase())}`;
247424
+ ${picocolors18.green("\u2714")} Switched security mode to: ${picocolors18.green(targetMode.toUpperCase())}`;
247187
247425
  await Prompt.askSelect(msg, [
247188
247426
  { value: "ok", label: isZh ? "\u8FD4\u56DE\u5BF9\u8BDD" : "Return to Chat" }
247189
247427
  ]);
247190
247428
  } else {
247191
247429
  this.printOutput(
247192
- isZh ? picocolors17.green(
247430
+ isZh ? picocolors18.green(
247193
247431
  `\u2714 \u5DF2\u5207\u6362\u5B89\u5168\u6A21\u5F0F\u81F3: ${targetMode.toUpperCase()}`
247194
- ) : picocolors17.green(
247432
+ ) : picocolors18.green(
247195
247433
  `\u2714 Switched security mode to: ${targetMode.toUpperCase()}`
247196
247434
  )
247197
247435
  );
@@ -247204,7 +247442,7 @@ ${picocolors17.green("\u2714")} Switched security mode to: ${picocolors17.green(
247204
247442
  const lastAssistantMsg = [...history].reverse().find((msg) => msg.role === "assistant");
247205
247443
  if (!lastAssistantMsg) {
247206
247444
  this.printOutput(
247207
- isZh ? picocolors17.yellow("\u6CA1\u6709\u627E\u5230 AI \u7684\u6700\u8FD1\u56DE\u590D\u3002") : picocolors17.yellow(
247445
+ isZh ? picocolors18.yellow("\u6CA1\u6709\u627E\u5230 AI \u7684\u6700\u8FD1\u56DE\u590D\u3002") : picocolors18.yellow(
247208
247446
  "No recent assistant response found to copy."
247209
247447
  )
247210
247448
  );
@@ -247218,22 +247456,22 @@ ${picocolors17.green("\u2714")} Switched security mode to: ${picocolors17.green(
247218
247456
  }
247219
247457
  if (!textToCopy) {
247220
247458
  this.printOutput(
247221
- isZh ? picocolors17.yellow("AI \u7684\u6700\u8FD1\u56DE\u590D\u5185\u5BB9\u4E3A\u7A7A\u3002") : picocolors17.yellow("Recent assistant response is empty.")
247459
+ isZh ? picocolors18.yellow("AI \u7684\u6700\u8FD1\u56DE\u590D\u5185\u5BB9\u4E3A\u7A7A\u3002") : picocolors18.yellow("Recent assistant response is empty.")
247222
247460
  );
247223
247461
  return { shouldExit: false, processed: true };
247224
247462
  }
247225
247463
  const copied = this.copyToClipboard(textToCopy);
247226
247464
  if (copied) {
247227
247465
  this.printOutput(
247228
- isZh ? picocolors17.green("\u2714 \u5DF2\u6210\u529F\u590D\u5236 AI \u6700\u8FD1\u56DE\u590D\u5230\u526A\u8D34\u677F\uFF01") : picocolors17.green(
247466
+ isZh ? picocolors18.green("\u2714 \u5DF2\u6210\u529F\u590D\u5236 AI \u6700\u8FD1\u56DE\u590D\u5230\u526A\u8D34\u677F\uFF01") : picocolors18.green(
247229
247467
  "\u2714 Successfully copied recent AI response to clipboard!"
247230
247468
  )
247231
247469
  );
247232
247470
  } else {
247233
247471
  this.printOutput(
247234
- isZh ? picocolors17.red(
247472
+ isZh ? picocolors18.red(
247235
247473
  "\u2716 \u590D\u5236\u5230\u526A\u8D34\u677F\u5931\u8D25\uFF0C\u7CFB\u7EDF\u672A\u914D\u7F6E\u526A\u8D34\u677F\u5DE5\u5177\uFF08\u5982 pbcopy/clip/xclip\uFF09\u3002"
247236
- ) : picocolors17.red(
247474
+ ) : picocolors18.red(
247237
247475
  "\u2716 Failed to copy to clipboard. Ensure pbcopy/clip/xclip is installed."
247238
247476
  )
247239
247477
  );
@@ -247241,7 +247479,7 @@ ${picocolors17.green("\u2714")} Switched security mode to: ${picocolors17.green(
247241
247479
  return { shouldExit: false, processed: true };
247242
247480
  }
247243
247481
  this.printOutput(
247244
- picocolors17.red(
247482
+ picocolors18.red(
247245
247483
  `Unknown command: ${trimmed}. Type /help for available commands.`
247246
247484
  )
247247
247485
  );
@@ -247275,7 +247513,7 @@ ${picocolors17.green("\u2714")} Switched security mode to: ${picocolors17.green(
247275
247513
  if (this.tui.isActive) {
247276
247514
  this.tui.addUserMessage(trimmed);
247277
247515
  } else {
247278
- console.log(picocolors17.cyan(`web \u203A ${trimmed}`));
247516
+ console.log(picocolors18.cyan(`web \u203A ${trimmed}`));
247279
247517
  }
247280
247518
  this.loop.prepareUserTurn(trimmed);
247281
247519
  ensureSessionTitle(this.loop, trimmed);
@@ -247579,20 +247817,20 @@ ${picocolors17.green("\u2714")} Switched security mode to: ${picocolors17.green(
247579
247817
  };
247580
247818
 
247581
247819
  // src/runtime/ReplController.ts
247582
- var AutocompleteRequestSchema = z41.object({
247583
- prefix: z41.string().max(2e4),
247584
- suffix: z41.string().max(2e4),
247585
- windowId: z41.string().max(1e3).optional()
247820
+ var AutocompleteRequestSchema = z46.object({
247821
+ prefix: z46.string().max(2e4),
247822
+ suffix: z46.string().max(2e4),
247823
+ windowId: z46.string().max(1e3).optional()
247586
247824
  });
247587
247825
  var AUTOCOMPLETE_BODY_LIMIT_BYTES = 1e5;
247588
247826
  var AUTOCOMPLETE_MAX_CONCURRENCY = 4;
247589
- var LocalStateSchema = z41.object({
247590
- lastSessionId: z41.string().optional(),
247591
- lastModel: z41.string().optional()
247827
+ var LocalStateSchema = z46.object({
247828
+ lastSessionId: z46.string().optional(),
247829
+ lastModel: z46.string().optional()
247592
247830
  });
247593
- var AutocompleteEndpointSchema = z41.object({
247594
- port: z41.number().int().min(1).max(65535),
247595
- token: z41.string().min(32).max(256)
247831
+ var AutocompleteEndpointSchema = z46.object({
247832
+ port: z46.number().int().min(1).max(65535),
247833
+ token: z46.string().min(32).max(256)
247596
247834
  });
247597
247835
  function getRunOutcomeMessage(outcome) {
247598
247836
  if (!outcome || outcome.status === "completed") return void 0;
@@ -247623,7 +247861,7 @@ var ReplController = class {
247623
247861
  getLocalState() {
247624
247862
  try {
247625
247863
  const statePath = resolveSafePath(this.cwd, ".orbit/state.json");
247626
- if (!existsSync28(statePath)) return {};
247864
+ if (!existsSync21(statePath)) return {};
247627
247865
  const parsed = LocalStateSchema.safeParse(
247628
247866
  JSON.parse(readFileSync18(statePath, "utf8"))
247629
247867
  );
@@ -247636,7 +247874,7 @@ var ReplController = class {
247636
247874
  try {
247637
247875
  const statePath = resolveSafePath(this.cwd, ".orbit/state.json");
247638
247876
  const dir = dirname9(statePath);
247639
- if (!existsSync28(dir)) {
247877
+ if (!existsSync21(dir)) {
247640
247878
  mkdirSync13(dir, { recursive: true });
247641
247879
  }
247642
247880
  const current = this.getLocalState();
@@ -247780,7 +248018,7 @@ Confirm action?`;
247780
248018
  console.log(`
247781
248019
  Risk Warning: ${reason}`);
247782
248020
  if (preview) {
247783
- console.log(picocolors18.gray(`Parameters: ${preview}`));
248021
+ console.log(picocolors19.gray(`Parameters: ${preview}`));
247784
248022
  }
247785
248023
  const approved = await Prompt.askApproval("Confirm action?");
247786
248024
  if (wasActive) tui.start(this.config.budgetLimit);
@@ -247879,7 +248117,7 @@ Risk Warning: ${reason}`);
247879
248117
  if (useFullscreenTui) {
247880
248118
  tui.handleThinkingDelta(payload.text);
247881
248119
  } else {
247882
- process.stdout.write(picocolors18.gray(payload.text));
248120
+ process.stdout.write(picocolors19.gray(payload.text));
247883
248121
  }
247884
248122
  };
247885
248123
  eventBus.on("model_delta", onModelDelta);
@@ -247978,7 +248216,7 @@ Risk Warning: ${reason}`);
247978
248216
  input = await Prompt.askTextWithAutocomplete(
247979
248217
  "Type your task or command...",
247980
248218
  this.makeCompleter(),
247981
- `${picocolors18.bold(picocolors18.magenta("orbit"))}${picocolors18.gray(" \u276F ")}`
248219
+ `${picocolors19.bold(picocolors19.magenta("orbit"))}${picocolors19.gray(" \u276F ")}`
247982
248220
  );
247983
248221
  }
247984
248222
  if (input === null) {
@@ -247986,7 +248224,7 @@ Risk Warning: ${reason}`);
247986
248224
  tui.stop();
247987
248225
  } else {
247988
248226
  console.log(
247989
- picocolors18.yellow("Exiting Orbit Interactive Shell. Goodbye!")
248227
+ picocolors19.yellow("Exiting Orbit Interactive Shell. Goodbye!")
247990
248228
  );
247991
248229
  }
247992
248230
  break;
@@ -248195,8 +248433,8 @@ async function readLimitedBody(req, limitBytes) {
248195
248433
 
248196
248434
  // src/commands/run.ts
248197
248435
  function getLocalState(cwd) {
248198
- const statePath = join18(cwd, ".orbit", "state.json");
248199
- if (!existsSync29(statePath)) return {};
248436
+ const statePath = join17(cwd, ".orbit", "state.json");
248437
+ if (!existsSync28(statePath)) return {};
248200
248438
  try {
248201
248439
  return JSON.parse(readFileSync19(statePath, "utf8"));
248202
248440
  } catch {
@@ -248261,7 +248499,7 @@ async function runAgent(cwd, task, cliOverrides, multi, options) {
248261
248499
  const message = redactSecrets(
248262
248500
  error instanceof Error ? error.message : "Failed to create provider instance."
248263
248501
  );
248264
- console.error(picocolors19.red(message));
248502
+ console.error(picocolors20.red(message));
248265
248503
  const outcome = {
248266
248504
  status: "failed",
248267
248505
  sessionId: "",
@@ -248281,7 +248519,7 @@ async function runAgent(cwd, task, cliOverrides, multi, options) {
248281
248519
  console.error(`
248282
248520
  Risk Warning [Non-Interactive Mode]: ${reason}`);
248283
248521
  if (preview) {
248284
- console.error(picocolors19.gray(`Parameters: ${preview}`));
248522
+ console.error(picocolors20.gray(`Parameters: ${preview}`));
248285
248523
  }
248286
248524
  console.error(
248287
248525
  "Automatically denying action in non-interactive mode."
@@ -248301,7 +248539,7 @@ Risk Warning [Non-Interactive Mode]: ${reason}`);
248301
248539
  console.log(`
248302
248540
  Risk Warning: ${reason}`);
248303
248541
  if (preview) {
248304
- console.log(picocolors19.gray(`Parameters: ${preview}`));
248542
+ console.log(picocolors20.gray(`Parameters: ${preview}`));
248305
248543
  }
248306
248544
  return await Prompt.askApproval("Confirm action?");
248307
248545
  },
@@ -248450,36 +248688,36 @@ function isRecord6(value) {
248450
248688
  }
248451
248689
 
248452
248690
  // src/commands/LSPServer.ts
248453
- import { z as z45 } from "zod";
248691
+ import { z as z47 } from "zod";
248454
248692
  var MAX_LSP_HEADER_BYTES = 8 * 1024;
248455
248693
  var MAX_LSP_BODY_BYTES = 8 * 1024 * 1024;
248456
- var JsonRpcIdSchema = z45.union([z45.string(), z45.number(), z45.null()]);
248457
- var JSONRPCMessageSchema = z45.object({
248458
- jsonrpc: z45.literal("2.0"),
248694
+ var JsonRpcIdSchema = z47.union([z47.string(), z47.number(), z47.null()]);
248695
+ var JSONRPCMessageSchema = z47.object({
248696
+ jsonrpc: z47.literal("2.0"),
248459
248697
  id: JsonRpcIdSchema.optional(),
248460
- method: z45.string().min(1).max(512),
248461
- params: z45.unknown().optional()
248698
+ method: z47.string().min(1).max(512),
248699
+ params: z47.unknown().optional()
248462
248700
  }).strict();
248463
- var TextDocumentIdentifierSchema = z45.object({
248464
- uri: z45.string().min(1).max(16384)
248701
+ var TextDocumentIdentifierSchema = z47.object({
248702
+ uri: z47.string().min(1).max(16384)
248465
248703
  });
248466
- var DidOpenParamsSchema = z45.object({
248704
+ var DidOpenParamsSchema = z47.object({
248467
248705
  textDocument: TextDocumentIdentifierSchema.extend({
248468
- text: z45.string().max(MAX_LSP_BODY_BYTES)
248706
+ text: z47.string().max(MAX_LSP_BODY_BYTES)
248469
248707
  }).passthrough()
248470
248708
  });
248471
- var DidChangeParamsSchema = z45.object({
248709
+ var DidChangeParamsSchema = z47.object({
248472
248710
  textDocument: TextDocumentIdentifierSchema,
248473
- contentChanges: z45.array(z45.object({ text: z45.string().max(MAX_LSP_BODY_BYTES) }).passthrough()).min(1).max(100)
248711
+ contentChanges: z47.array(z47.object({ text: z47.string().max(MAX_LSP_BODY_BYTES) }).passthrough()).min(1).max(100)
248474
248712
  });
248475
- var DidCloseParamsSchema = z45.object({
248713
+ var DidCloseParamsSchema = z47.object({
248476
248714
  textDocument: TextDocumentIdentifierSchema
248477
248715
  });
248478
- var CompletionParamsSchema = z45.object({
248716
+ var CompletionParamsSchema = z47.object({
248479
248717
  textDocument: TextDocumentIdentifierSchema,
248480
- position: z45.object({
248481
- line: z45.number().int().nonnegative(),
248482
- character: z45.number().int().nonnegative()
248718
+ position: z47.object({
248719
+ line: z47.number().int().nonnegative(),
248720
+ character: z47.number().int().nonnegative()
248483
248721
  })
248484
248722
  });
248485
248723
  var JSONRPCReader = class {
@@ -248613,7 +248851,7 @@ async function runLSPServer(cwd) {
248613
248851
  const autocompleteEngine = new AutocompleteEngine(cwd);
248614
248852
  const documentCache = /* @__PURE__ */ new Map();
248615
248853
  let shutdownRequested = false;
248616
- await new Promise((resolve13) => {
248854
+ await new Promise((resolve15) => {
248617
248855
  let settled = false;
248618
248856
  const finish = () => {
248619
248857
  if (settled) return;
@@ -248622,7 +248860,7 @@ async function runLSPServer(cwd) {
248622
248860
  process.stdin.off("end", onEnd);
248623
248861
  autocompleteEngine.dispose();
248624
248862
  documentCache.clear();
248625
- resolve13();
248863
+ resolve15();
248626
248864
  };
248627
248865
  const handleMessage = async (message) => {
248628
248866
  try {
@@ -248725,7 +248963,7 @@ ${completion}
248725
248963
  );
248726
248964
  }
248727
248965
  } catch (error) {
248728
- if (error instanceof z45.ZodError) {
248966
+ if (error instanceof z47.ZodError) {
248729
248967
  sendError(message.id, -32602, "Invalid method parameters.");
248730
248968
  return;
248731
248969
  }
@@ -248747,8 +248985,8 @@ ${completion}
248747
248985
  }
248748
248986
 
248749
248987
  // src/commands/login.ts
248750
- import readline4 from "readline";
248751
- import picocolors20 from "picocolors";
248988
+ import readline5 from "readline";
248989
+ import picocolors21 from "picocolors";
248752
248990
  var PROVIDER_TEMPLATES = [
248753
248991
  {
248754
248992
  id: "ollama",
@@ -248801,19 +249039,19 @@ var PROVIDER_TEMPLATES = [
248801
249039
  }
248802
249040
  ];
248803
249041
  function askQuestion(query, defaultValue = "") {
248804
- const rl = readline4.createInterface({
249042
+ const rl = readline5.createInterface({
248805
249043
  input: process.stdin,
248806
249044
  output: process.stdout
248807
249045
  });
248808
- return new Promise((resolve13) => {
249046
+ return new Promise((resolve15) => {
248809
249047
  rl.question(query, (answer) => {
248810
249048
  rl.close();
248811
- resolve13(answer.trim() || defaultValue);
249049
+ resolve15(answer.trim() || defaultValue);
248812
249050
  });
248813
249051
  });
248814
249052
  }
248815
249053
  function askSecret(query) {
248816
- return new Promise((resolve13, reject) => {
249054
+ return new Promise((resolve15, reject) => {
248817
249055
  const stdin = process.stdin;
248818
249056
  const stdout = process.stdout;
248819
249057
  if (!stdin.isTTY || !stdout.isTTY || typeof stdin.setRawMode !== "function") {
@@ -248847,13 +249085,13 @@ function askSecret(query) {
248847
249085
  case "":
248848
249086
  cleanup();
248849
249087
  stdout.write("\n");
248850
- resolve13(input.trim());
249088
+ resolve15(input.trim());
248851
249089
  break;
248852
249090
  case "":
248853
249091
  cleanup();
248854
249092
  stdout.write("\n");
248855
249093
  process.exitCode = 130;
248856
- resolve13("");
249094
+ resolve15("");
248857
249095
  break;
248858
249096
  case "\b":
248859
249097
  case "\x7F":
@@ -248882,20 +249120,20 @@ function slugifyProviderId(value) {
248882
249120
  }
248883
249121
  function printProfiles(store, credentials) {
248884
249122
  const snapshot = store.read();
248885
- console.log(picocolors20.bold("\nSaved provider logins\n"));
249123
+ console.log(picocolors21.bold("\nSaved provider logins\n"));
248886
249124
  if (snapshot.profiles.length === 0) {
248887
- console.log(picocolors20.gray(" No saved provider profiles."));
249125
+ console.log(picocolors21.gray(" No saved provider profiles."));
248888
249126
  return;
248889
249127
  }
248890
249128
  for (const profile of snapshot.profiles) {
248891
249129
  const active = snapshot.activeProvider === profile.id ? "\u25CF" : "\u25CB";
248892
249130
  const credential = profile.config.apiKeyEnv ? credentials.hasSecret(profile.config.apiKeyEnv) : false;
248893
- const credentialStatus = profile.config.type === "ollama" ? picocolors20.cyan("local \xB7 no credential") : credential ? picocolors20.green("credential saved") : picocolors20.yellow("credential missing");
249131
+ const credentialStatus = profile.config.type === "ollama" ? picocolors21.cyan("local \xB7 no credential") : credential ? picocolors21.green("credential saved") : picocolors21.yellow("credential missing");
248894
249132
  console.log(
248895
- ` ${active} ${picocolors20.bold(profile.name)} ${picocolors20.gray(`(${profile.id})`)} ${credentialStatus}`
249133
+ ` ${active} ${picocolors21.bold(profile.name)} ${picocolors21.gray(`(${profile.id})`)} ${credentialStatus}`
248896
249134
  );
248897
249135
  console.log(
248898
- ` ${picocolors20.gray(profile.config.baseUrl || "default endpoint")} \xB7 ${profile.config.models?.length || 0} models`
249136
+ ` ${picocolors21.gray(profile.config.baseUrl || "default endpoint")} \xB7 ${profile.config.models?.length || 0} models`
248899
249137
  );
248900
249138
  }
248901
249139
  }
@@ -248912,14 +249150,14 @@ async function configureProvider(template, options, store, credentials) {
248912
249150
  const requiresApiKey = template.requiresApiKey !== false;
248913
249151
  const apiKey = requiresApiKey ? await askSecret("API key (input hidden): ") : void 0;
248914
249152
  if (requiresApiKey && !apiKey) {
248915
- console.log(picocolors20.yellow("\u26A0 Provider login cancelled."));
249153
+ console.log(picocolors21.yellow("\u26A0 Provider login cancelled."));
248916
249154
  return;
248917
249155
  }
248918
249156
  const baseUrl = requestedBaseUrl.replace(/\/$/, "");
248919
249157
  let models = existing?.config.models;
248920
249158
  let modelCapabilities = existing?.config.modelCapabilities;
248921
249159
  if (template.discoverModels || template.type.includes("openai")) {
248922
- console.log(picocolors20.cyan("\u25CF Scanning the provider model catalog\u2026"));
249160
+ console.log(picocolors21.cyan("\u25CF Scanning the provider model catalog\u2026"));
248923
249161
  const discovered = await discoverProviderModels({
248924
249162
  baseUrl: requestedBaseUrl,
248925
249163
  apiKey,
@@ -248928,7 +249166,7 @@ async function configureProvider(template, options, store, credentials) {
248928
249166
  models = discovered.models;
248929
249167
  modelCapabilities = discovered.modelCapabilities;
248930
249168
  console.log(
248931
- picocolors20.green(
249169
+ picocolors21.green(
248932
249170
  `\u2714 Found ${discovered.models.length} models at ${discovered.modelsEndpoint}`
248933
249171
  )
248934
249172
  );
@@ -248948,7 +249186,7 @@ async function configureProvider(template, options, store, credentials) {
248948
249186
  });
248949
249187
  if (options.activate !== false) store.setActive(template.id);
248950
249188
  console.log(
248951
- picocolors20.green(
249189
+ picocolors21.green(
248952
249190
  `\u2714 ${requestedName} ${requiresApiKey ? "saved securely" : "saved"}${options.activate === false ? "." : " and selected as the active provider."}`
248953
249191
  )
248954
249192
  );
@@ -248987,7 +249225,7 @@ async function chooseSavedProvider(profiles, prompt) {
248987
249225
  if (profiles.length === 0) return void 0;
248988
249226
  profiles.forEach((profile, index) => {
248989
249227
  console.log(
248990
- ` ${picocolors20.cyan(String(index + 1))}) ${profile.name} (${profile.id})`
249228
+ ` ${picocolors21.cyan(String(index + 1))}) ${profile.name} (${profile.id})`
248991
249229
  );
248992
249230
  });
248993
249231
  const selected = Number(await askQuestion(prompt));
@@ -249008,9 +249246,9 @@ async function runLogin(options = {}) {
249008
249246
  credentials
249009
249247
  );
249010
249248
  console.log(
249011
- deleted ? picocolors20.green(
249249
+ deleted ? picocolors21.green(
249012
249250
  `\u2714 Deleted provider login: ${options.deleteProvider}`
249013
- ) : picocolors20.yellow(
249251
+ ) : picocolors21.yellow(
249014
249252
  `\u26A0 Provider login not found: ${options.deleteProvider}`
249015
249253
  )
249016
249254
  );
@@ -249027,7 +249265,7 @@ async function runLogin(options = {}) {
249027
249265
  }
249028
249266
  return;
249029
249267
  }
249030
- console.log(picocolors20.bold("\nOrbit provider logins"));
249268
+ console.log(picocolors21.bold("\nOrbit provider logins"));
249031
249269
  printProfiles(store, credentials);
249032
249270
  console.log("\n 1) Scan or update local Ollama");
249033
249271
  console.log(" 2) Add or update TokenDance");
@@ -249068,7 +249306,7 @@ async function runLogin(options = {}) {
249068
249306
  );
249069
249307
  if (selected) {
249070
249308
  store.setActive(selected.id);
249071
- console.log(picocolors20.green(`\u2714 Active provider: ${selected.name}`));
249309
+ console.log(picocolors21.green(`\u2714 Active provider: ${selected.name}`));
249072
249310
  }
249073
249311
  } else if (action === "6") {
249074
249312
  const selected = await chooseSavedProvider(
@@ -249077,20 +249315,20 @@ async function runLogin(options = {}) {
249077
249315
  );
249078
249316
  if (selected && deleteProviderLogin(selected.id, store, credentials)) {
249079
249317
  console.log(
249080
- picocolors20.green(`\u2714 Deleted provider login: ${selected.name}`)
249318
+ picocolors21.green(`\u2714 Deleted provider login: ${selected.name}`)
249081
249319
  );
249082
249320
  }
249083
249321
  }
249084
249322
  } catch (error) {
249085
249323
  const message = error instanceof Error ? error.message : String(error);
249086
- console.log(picocolors20.red(`
249324
+ console.log(picocolors21.red(`
249087
249325
  \u2716 Provider login failed: ${message}`));
249088
249326
  }
249089
249327
  }
249090
249328
 
249091
249329
  // src/commands/trace.ts
249092
249330
  import {
249093
- existsSync as existsSync30,
249331
+ existsSync as existsSync29,
249094
249332
  lstatSync as lstatSync3,
249095
249333
  mkdirSync as mkdirSync14,
249096
249334
  renameSync as renameSync9,
@@ -249098,10 +249336,10 @@ import {
249098
249336
  writeFileSync as writeFileSync13
249099
249337
  } from "fs";
249100
249338
  import { dirname as dirname10, resolve as resolve11 } from "path";
249101
- import { z as z46 } from "zod";
249102
- var TraceOptionsSchema = z46.object({
249103
- full: z46.boolean().default(false),
249104
- out: z46.string().trim().min(1).max(4096).optional()
249339
+ import { z as z48 } from "zod";
249340
+ var TraceOptionsSchema = z48.object({
249341
+ full: z48.boolean().default(false),
249342
+ out: z48.string().trim().min(1).max(4096).optional()
249105
249343
  });
249106
249344
  function runTraceExport(cwd, sessionId, options = {}) {
249107
249345
  const value = TraceOptionsSchema.parse(options);
@@ -249117,7 +249355,7 @@ function runTraceExport(cwd, sessionId, options = {}) {
249117
249355
  }
249118
249356
  const outputPath = resolveSafePath(cwd, value.out);
249119
249357
  const directory = dirname10(outputPath);
249120
- if (existsSync30(directory)) {
249358
+ if (existsSync29(directory)) {
249121
249359
  const stats = lstatSync3(directory);
249122
249360
  if (stats.isSymbolicLink() || !stats.isDirectory()) {
249123
249361
  throw new Error("Trace output directory must be a real directory.");
@@ -249132,7 +249370,7 @@ function runTraceExport(cwd, sessionId, options = {}) {
249132
249370
  flag: "wx",
249133
249371
  mode: 384
249134
249372
  });
249135
- if (existsSync30(outputPath)) rmSync7(outputPath, { force: true });
249373
+ if (existsSync29(outputPath)) rmSync7(outputPath, { force: true });
249136
249374
  renameSync9(temporaryPath, outputPath);
249137
249375
  } finally {
249138
249376
  rmSync7(temporaryPath, { force: true });
@@ -249141,10 +249379,10 @@ function runTraceExport(cwd, sessionId, options = {}) {
249141
249379
  }
249142
249380
 
249143
249381
  // src/commands/eval.ts
249144
- import { exec as execCallback, execFileSync as execFileSync4 } from "child_process";
249382
+ import { exec as execCallback, execFileSync as execFileSync6 } from "child_process";
249145
249383
  import {
249146
249384
  copyFileSync as copyFileSync4,
249147
- existsSync as existsSync31,
249385
+ existsSync as existsSync30,
249148
249386
  lstatSync as lstatSync4,
249149
249387
  mkdirSync as mkdirSync15,
249150
249388
  readFileSync as readFileSync20,
@@ -249152,20 +249390,20 @@ import {
249152
249390
  rmSync as rmSync8,
249153
249391
  writeFileSync as writeFileSync14
249154
249392
  } from "fs";
249155
- import { basename as basename6, dirname as dirname11, join as join19 } from "path";
249156
- import { promisify as promisify4 } from "util";
249157
- import picocolors21 from "picocolors";
249393
+ import { basename as basename6, dirname as dirname11, join as join18 } from "path";
249394
+ import { promisify as promisify5 } from "util";
249395
+ import picocolors23 from "picocolors";
249158
249396
  import { parse as parseYaml } from "yaml";
249159
- import { z as z47 } from "zod";
249160
- var exec4 = promisify4(execCallback);
249397
+ import { z as z49 } from "zod";
249398
+ var exec4 = promisify5(execCallback);
249161
249399
  var MAX_SUITE_BYTES = 1024 * 1024;
249162
249400
  var MAX_VERIFICATION_OUTPUT = 4e3;
249163
- var EvalOptionsSchema = z47.object({
249164
- provider: z47.string().trim().min(1).optional(),
249165
- model: z47.string().trim().min(1).optional(),
249166
- task: z47.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/).optional(),
249167
- allowCommands: z47.boolean().default(false),
249168
- json: z47.boolean().default(false)
249401
+ var EvalOptionsSchema = z49.object({
249402
+ provider: z49.string().trim().min(1).optional(),
249403
+ model: z49.string().trim().min(1).optional(),
249404
+ task: z49.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/).optional(),
249405
+ allowCommands: z49.boolean().default(false),
249406
+ json: z49.boolean().default(false)
249169
249407
  });
249170
249408
  async function runEval(cwd, suiteFile, options = {}) {
249171
249409
  const value = EvalOptionsSchema.parse(options);
@@ -249188,7 +249426,7 @@ async function runEval(cwd, suiteFile, options = {}) {
249188
249426
  const results = [];
249189
249427
  for (const task of tasks) {
249190
249428
  if (!value.json) {
249191
- console.log(picocolors21.cyan(`\u25CF Evaluating ${task.id}...`));
249429
+ console.log(picocolors23.cyan(`\u25CF Evaluating ${task.id}...`));
249192
249430
  }
249193
249431
  let worktree;
249194
249432
  const taskStartedAt = Date.now();
@@ -249287,13 +249525,13 @@ async function runEval(cwd, suiteFile, options = {}) {
249287
249525
  console.log(JSON.stringify(report, null, 2));
249288
249526
  } else {
249289
249527
  console.log(
249290
- report.passed ? picocolors21.green(
249528
+ report.passed ? picocolors23.green(
249291
249529
  `\u2714 Acceptance passed: ${passedTasks}/${results.length} tasks.`
249292
- ) : picocolors21.red(
249530
+ ) : picocolors23.red(
249293
249531
  `\u2716 Acceptance failed: ${passedTasks}/${results.length} tasks passed.`
249294
249532
  )
249295
249533
  );
249296
- console.log(picocolors21.gray(`Report: ${reportPath}`));
249534
+ console.log(picocolors23.gray(`Report: ${reportPath}`));
249297
249535
  }
249298
249536
  if (!report.passed) process.exitCode = 1;
249299
249537
  return report;
@@ -249345,7 +249583,7 @@ ${result.stderr}`)
249345
249583
  }
249346
249584
  function readChangedFiles(cwd) {
249347
249585
  try {
249348
- const output = execFileSync4(
249586
+ const output = execFileSync6(
249349
249587
  "git",
249350
249588
  ["status", "--porcelain=v1", "-z", "--untracked-files=all"],
249351
249589
  { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
@@ -249356,7 +249594,7 @@ function readChangedFiles(cwd) {
249356
249594
  }
249357
249595
  }
249358
249596
  function snapshotWorkspaceIntoWorktree(sourceCwd, worktreeCwd) {
249359
- const patch = execFileSync4(
249597
+ const patch = execFileSync6(
249360
249598
  "git",
249361
249599
  ["diff", "HEAD", "--binary", "--no-ext-diff"],
249362
249600
  {
@@ -249367,14 +249605,14 @@ function snapshotWorkspaceIntoWorktree(sourceCwd, worktreeCwd) {
249367
249605
  }
249368
249606
  );
249369
249607
  if (patch.length > 0) {
249370
- execFileSync4("git", ["apply", "--whitespace=nowarn", "-"], {
249608
+ execFileSync6("git", ["apply", "--whitespace=nowarn", "-"], {
249371
249609
  cwd: worktreeCwd,
249372
249610
  input: patch,
249373
249611
  stdio: ["pipe", "pipe", "pipe"],
249374
249612
  maxBuffer: 64 * 1024 * 1024
249375
249613
  });
249376
249614
  }
249377
- const untracked = execFileSync4(
249615
+ const untracked = execFileSync6(
249378
249616
  "git",
249379
249617
  ["ls-files", "--others", "--exclude-standard", "-z"],
249380
249618
  {
@@ -249393,17 +249631,17 @@ function snapshotWorkspaceIntoWorktree(sourceCwd, worktreeCwd) {
249393
249631
  mkdirSync15(dirname11(targetPath), { recursive: true });
249394
249632
  copyFileSync4(sourcePath, targetPath);
249395
249633
  }
249396
- execFileSync4("git", ["add", "-A"], {
249634
+ execFileSync6("git", ["add", "-A"], {
249397
249635
  cwd: worktreeCwd,
249398
249636
  stdio: ["ignore", "pipe", "pipe"]
249399
249637
  });
249400
- const dirty = execFileSync4("git", ["status", "--porcelain"], {
249638
+ const dirty = execFileSync6("git", ["status", "--porcelain"], {
249401
249639
  cwd: worktreeCwd,
249402
249640
  encoding: "utf8",
249403
249641
  stdio: ["ignore", "pipe", "pipe"]
249404
249642
  }).trim();
249405
249643
  if (!dirty) return;
249406
- execFileSync4(
249644
+ execFileSync6(
249407
249645
  "git",
249408
249646
  [
249409
249647
  "-c",
@@ -249428,7 +249666,7 @@ function isSensitiveSnapshotPath2(filePath) {
249428
249666
  return normalized.startsWith(".orbit/") || normalized.includes("/.ssh/") || name === "id_rsa" || name === "id_ed25519" || name === ".npmrc" || name === ".pypirc" || name === ".env" || name.startsWith(".env.");
249429
249667
  }
249430
249668
  function writeEvaluationTrace(cwd, runId, taskId, trace) {
249431
- const relativePath = join19(
249669
+ const relativePath = join18(
249432
249670
  ".orbit",
249433
249671
  "evaluations",
249434
249672
  runId,
@@ -249440,14 +249678,14 @@ function writeEvaluationTrace(cwd, runId, taskId, trace) {
249440
249678
  function writeEvaluationReport(cwd, runId, report) {
249441
249679
  const filePath = resolveSafePath(
249442
249680
  cwd,
249443
- join19(".orbit", "evaluations", `${runId}.json`)
249681
+ join18(".orbit", "evaluations", `${runId}.json`)
249444
249682
  );
249445
249683
  writeJsonAtomically2(filePath, report);
249446
249684
  return filePath;
249447
249685
  }
249448
249686
  function writeJsonAtomically2(filePath, value) {
249449
249687
  const directory = dirname11(filePath);
249450
- if (existsSync31(directory)) {
249688
+ if (existsSync30(directory)) {
249451
249689
  const stats = lstatSync4(directory);
249452
249690
  if (stats.isSymbolicLink() || !stats.isDirectory()) {
249453
249691
  throw new Error("Evaluation output directory must be a real directory.");
@@ -249462,7 +249700,7 @@ function writeJsonAtomically2(filePath, value) {
249462
249700
  flag: "wx",
249463
249701
  mode: 384
249464
249702
  });
249465
- if (existsSync31(filePath)) rmSync8(filePath, { force: true });
249703
+ if (existsSync30(filePath)) rmSync8(filePath, { force: true });
249466
249704
  renameSync10(temporaryPath, filePath);
249467
249705
  } finally {
249468
249706
  rmSync8(temporaryPath, { force: true });
@@ -249473,9 +249711,262 @@ function safeSummary(value) {
249473
249711
  return redactSecrets(raw || "unknown error").replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ").replace(/\s+/g, " ").trim().slice(-MAX_VERIFICATION_OUTPUT);
249474
249712
  }
249475
249713
 
249714
+ // src/commands/clean.ts
249715
+ import readline6 from "readline";
249716
+ import picocolors24 from "picocolors";
249717
+ import { resolve as resolve13 } from "path";
249718
+ import { z as z51 } from "zod";
249719
+
249720
+ // src/runtime/CleanupManager.ts
249721
+ import { lstatSync as lstatSync5, readdirSync as readdirSync7, rmSync as rmSync9 } from "fs";
249722
+ import { homedir as homedir11 } from "os";
249723
+ import { basename as basename7, join as join19, parse as parse5, resolve as resolve12 } from "path";
249724
+ import { z as z50 } from "zod";
249725
+ var CleanupScopeSchema = z50.enum(["user", "project"]);
249726
+ function buildCleanupPlan(options) {
249727
+ const scopes = z50.array(CleanupScopeSchema).min(1).parse(options.scopes);
249728
+ const homeDirectory = resolve12(options.homeDirectory ?? homedir11());
249729
+ const projectDirectory = resolve12(options.projectDirectory ?? options.cwd);
249730
+ const candidates = scopes.map((scope) => ({
249731
+ scope,
249732
+ path: scope === "user" ? join19(homeDirectory, ".orbit") : join19(projectDirectory, ".orbit")
249733
+ }));
249734
+ const grouped = /* @__PURE__ */ new Map();
249735
+ for (const candidate of candidates) {
249736
+ assertSafeOrbitDataPath(candidate.path);
249737
+ const key = pathIdentity(candidate.path);
249738
+ const existing = grouped.get(key);
249739
+ if (existing) {
249740
+ if (!existing.scopes.includes(candidate.scope)) {
249741
+ existing.scopes.push(candidate.scope);
249742
+ }
249743
+ } else {
249744
+ grouped.set(key, { path: candidate.path, scopes: [candidate.scope] });
249745
+ }
249746
+ }
249747
+ const targets = [...grouped.values()].map((candidate) => ({
249748
+ ...candidate,
249749
+ ...inspectPath(candidate.path)
249750
+ }));
249751
+ return {
249752
+ targets,
249753
+ totals: targets.reduce(
249754
+ (totals, target) => ({
249755
+ files: totals.files + target.files,
249756
+ directories: totals.directories + target.directories,
249757
+ bytes: totals.bytes + target.bytes
249758
+ }),
249759
+ { files: 0, directories: 0, bytes: 0 }
249760
+ )
249761
+ };
249762
+ }
249763
+ function executeCleanupPlan(plan) {
249764
+ const result = { removed: [], skipped: [] };
249765
+ for (const target of plan.targets) {
249766
+ assertSafeOrbitDataPath(target.path);
249767
+ if (!pathExists(target.path)) {
249768
+ result.skipped.push(target.path);
249769
+ continue;
249770
+ }
249771
+ rmSync9(target.path, { recursive: true, force: true, maxRetries: 3 });
249772
+ result.removed.push(target.path);
249773
+ }
249774
+ return result;
249775
+ }
249776
+ function inspectPath(targetPath) {
249777
+ if (!pathExists(targetPath)) {
249778
+ return {
249779
+ exists: false,
249780
+ files: 0,
249781
+ directories: 0,
249782
+ bytes: 0,
249783
+ warnings: []
249784
+ };
249785
+ }
249786
+ const totals = { files: 0, directories: 0, bytes: 0 };
249787
+ const warnings = [];
249788
+ const visit = (currentPath) => {
249789
+ let stat;
249790
+ try {
249791
+ stat = lstatSync5(currentPath);
249792
+ } catch (error) {
249793
+ warnings.push(safeInventoryWarning(currentPath, error));
249794
+ return;
249795
+ }
249796
+ if (stat.isSymbolicLink()) {
249797
+ totals.files++;
249798
+ totals.bytes += stat.size;
249799
+ return;
249800
+ }
249801
+ if (!stat.isDirectory()) {
249802
+ totals.files++;
249803
+ totals.bytes += stat.size;
249804
+ return;
249805
+ }
249806
+ totals.directories++;
249807
+ try {
249808
+ for (const entry of readdirSync7(currentPath)) {
249809
+ visit(join19(currentPath, entry));
249810
+ }
249811
+ } catch (error) {
249812
+ warnings.push(safeInventoryWarning(currentPath, error));
249813
+ }
249814
+ };
249815
+ visit(targetPath);
249816
+ return { exists: true, ...totals, warnings };
249817
+ }
249818
+ function assertSafeOrbitDataPath(targetPath) {
249819
+ const absolutePath = resolve12(targetPath);
249820
+ if (absolutePath === parse5(absolutePath).root) {
249821
+ throw new Error("Refusing to clean a filesystem root.");
249822
+ }
249823
+ if (basename7(absolutePath).toLowerCase() !== ".orbit") {
249824
+ throw new Error("Cleanup targets must be an Orbit data directory.");
249825
+ }
249826
+ if (resolve12(absolutePath, "..") === parse5(absolutePath).root) {
249827
+ throw new Error(
249828
+ "Refusing to clean an Orbit directory directly under a filesystem root."
249829
+ );
249830
+ }
249831
+ }
249832
+ function pathIdentity(targetPath) {
249833
+ const normalized = resolve12(targetPath).replace(/\\/g, "/");
249834
+ return process.platform === "win32" ? normalized.toLowerCase() : normalized;
249835
+ }
249836
+ function pathExists(targetPath) {
249837
+ try {
249838
+ lstatSync5(targetPath);
249839
+ return true;
249840
+ } catch {
249841
+ return false;
249842
+ }
249843
+ }
249844
+ function safeInventoryWarning(targetPath, error) {
249845
+ const code = typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : "unreadable";
249846
+ return `${code}: ${targetPath}`;
249847
+ }
249848
+
249849
+ // src/commands/clean.ts
249850
+ var CleanCommandOptionsSchema = z51.object({
249851
+ user: z51.boolean().default(false),
249852
+ project: z51.union([z51.boolean(), z51.string().min(1).max(4096)]).optional(),
249853
+ all: z51.boolean().default(false),
249854
+ yes: z51.boolean().default(false),
249855
+ json: z51.boolean().default(false)
249856
+ }).strict();
249857
+ async function runClean(cwd, rawOptions, dependencies = {}) {
249858
+ const options = CleanCommandOptionsSchema.parse(rawOptions);
249859
+ const scopes = resolveScopes(options);
249860
+ const projectDirectory = typeof options.project === "string" ? resolve13(cwd, options.project) : cwd;
249861
+ const plan = buildCleanupPlan({
249862
+ cwd,
249863
+ scopes,
249864
+ homeDirectory: dependencies.homeDirectory,
249865
+ projectDirectory
249866
+ });
249867
+ const write = dependencies.write ?? ((text) => console.log(text));
249868
+ if (options.json && !options.yes) {
249869
+ write(JSON.stringify({ schemaVersion: 1, applied: false, plan }));
249870
+ return { applied: false, plan, removed: [], skipped: [] };
249871
+ }
249872
+ if (!options.json) {
249873
+ printCleanupPlan(plan, write);
249874
+ }
249875
+ if (plan.targets.every((target) => !target.exists)) {
249876
+ return { applied: false, plan, removed: [], skipped: [] };
249877
+ }
249878
+ let confirmed = options.yes;
249879
+ if (!confirmed) {
249880
+ const interactive = dependencies.interactive ?? Boolean(process.stdin.isTTY);
249881
+ if (!interactive) {
249882
+ throw new Error(
249883
+ "Cleanup requires an interactive confirmation or the explicit --yes flag."
249884
+ );
249885
+ }
249886
+ const confirm = dependencies.confirm ?? confirmDeletion;
249887
+ confirmed = await confirm(
249888
+ "Type DELETE to permanently remove the listed Orbit data: "
249889
+ );
249890
+ }
249891
+ if (!confirmed) {
249892
+ if (!options.json) write(picocolors24.yellow("\u26A0 Cleanup cancelled."));
249893
+ return { applied: false, plan, removed: [], skipped: [] };
249894
+ }
249895
+ const userTarget = plan.targets.find(
249896
+ (target) => target.scopes.includes("user")
249897
+ );
249898
+ if (userTarget?.exists) {
249899
+ const purgeUserCredentials = dependencies.purgeUserCredentials ?? ((orbitDirectory) => new CredentialsManager({ orbitDir: orbitDirectory }).purge());
249900
+ purgeUserCredentials(userTarget.path);
249901
+ }
249902
+ const result = executeCleanupPlan(plan);
249903
+ if (options.json) {
249904
+ write(
249905
+ JSON.stringify({
249906
+ schemaVersion: 1,
249907
+ applied: true,
249908
+ plan,
249909
+ ...result
249910
+ })
249911
+ );
249912
+ } else {
249913
+ write(
249914
+ picocolors24.green(
249915
+ `\u2714 Removed ${result.removed.length} Orbit data director${result.removed.length === 1 ? "y" : "ies"}.`
249916
+ )
249917
+ );
249918
+ }
249919
+ return { applied: true, plan, ...result };
249920
+ }
249921
+ function resolveScopes(options) {
249922
+ const scopes = [];
249923
+ if (options.all || options.user) scopes.push("user");
249924
+ if (options.all || options.project !== void 0) scopes.push("project");
249925
+ if (scopes.length === 0) {
249926
+ throw new Error("Choose --user, --project [path], or --all.");
249927
+ }
249928
+ return scopes;
249929
+ }
249930
+ function printCleanupPlan(plan, write) {
249931
+ write(picocolors24.bold("\nOrbit cleanup preview\n"));
249932
+ for (const target of plan.targets) {
249933
+ const scope = target.scopes.join(" + ");
249934
+ const status = target.exists ? `${target.files} files \xB7 ${target.directories} directories \xB7 ${formatBytes(target.bytes)}` : "not present";
249935
+ write(` ${target.exists ? "\u25CF" : "\u25CB"} ${scope}: ${target.path}`);
249936
+ write(` ${picocolors24.gray(status)}`);
249937
+ for (const warning of target.warnings) {
249938
+ write(` ${picocolors24.yellow(`\u26A0 ${warning}`)}`);
249939
+ }
249940
+ }
249941
+ write(
249942
+ picocolors24.gray(
249943
+ "\nOnly .orbit data directories are included. Project source, ORBIT.md, and orbit.config.yaml are preserved."
249944
+ )
249945
+ );
249946
+ }
249947
+ function formatBytes(bytes) {
249948
+ if (bytes < 1024) return `${bytes} B`;
249949
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KiB`;
249950
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MiB`;
249951
+ }
249952
+ async function confirmDeletion(prompt) {
249953
+ const interfaceInstance = readline6.createInterface({
249954
+ input: process.stdin,
249955
+ output: process.stdout
249956
+ });
249957
+ try {
249958
+ const answer = await new Promise(
249959
+ (resolve15) => interfaceInstance.question(prompt, resolve15)
249960
+ );
249961
+ return answer.trim() === "DELETE";
249962
+ } finally {
249963
+ interfaceInstance.close();
249964
+ }
249965
+ }
249966
+
249476
249967
  // src/index.ts
249477
- import { existsSync as existsSync35, realpathSync as realpathSync4, statSync as statSync8 } from "fs";
249478
- import { resolve as resolve12 } from "path";
249968
+ import { existsSync as existsSync31, realpathSync as realpathSync4, statSync as statSync7 } from "fs";
249969
+ import { resolve as resolve14 } from "path";
249479
249970
  var program = new Command();
249480
249971
  function applyOutcomeExitCode(outcome) {
249481
249972
  const currentExitCode = typeof process.exitCode === "number" ? process.exitCode : 0;
@@ -249505,6 +249996,25 @@ program.command("init").description("initialize ORBIT.md guidelines file").actio
249505
249996
  program.command("config").description("show resolved configurations").action(() => {
249506
249997
  runConfig(process.cwd());
249507
249998
  });
249999
+ program.command("clean").description("preview and remove Orbit-owned user or project data").option("--user", "include user data under ~/.orbit").option(
250000
+ "--project [path]",
250001
+ "include project data under <path>/.orbit (default: current directory)"
250002
+ ).option("--all", "include both user and current-project Orbit data").option("--yes", "apply without an interactive DELETE confirmation").option("--json", "print the versioned cleanup plan and result as JSON").action(async (options) => {
250003
+ await runClean(process.cwd(), {
250004
+ user: !!options.user,
250005
+ project: options.project,
250006
+ all: !!options.all,
250007
+ yes: !!options.yes,
250008
+ json: !!options.json
250009
+ });
250010
+ });
250011
+ program.command("update").description("check for and install the latest published Orbit CLI").option("--check", "check for an update without installing it").option("--yes", "install an available update without prompting").option("--json", "print a versioned machine-readable result").action(async (options) => {
250012
+ await runUpdate(readCliVersion(), {
250013
+ check: !!options.check,
250014
+ yes: !!options.yes,
250015
+ json: !!options.json
250016
+ });
250017
+ });
249508
250018
  program.command("login").description("manage secure provider logins and model catalogs").option("--list", "list saved provider logins").option("--delete <provider>", "delete a saved provider login").option("--service <provider>", "configure a provider profile").option("--name <name>", "set the provider display name").option(
249509
250019
  "--base-url <url>",
249510
250020
  "set the exact API base URL (include /v1 when required)"
@@ -249617,8 +250127,8 @@ program.command("webui").description("start Orbit as a browser-first local codin
249617
250127
  if (options.yes) {
249618
250128
  overrides.permissions = { mode: "auto" };
249619
250129
  }
249620
- const requestedCwd = resolve12(localOptions.cwd || process.cwd());
249621
- if (!existsSync35(requestedCwd) || !statSync8(requestedCwd).isDirectory()) {
250130
+ const requestedCwd = resolve14(localOptions.cwd || process.cwd());
250131
+ if (!existsSync31(requestedCwd) || !statSync7(requestedCwd).isDirectory()) {
249622
250132
  throw new Error(
249623
250133
  `Web UI project directory does not exist: ${requestedCwd}`
249624
250134
  );
@@ -249651,7 +250161,7 @@ try {
249651
250161
  } catch (error) {
249652
250162
  const message = error instanceof Error ? error.message : String(error);
249653
250163
  console.error(
249654
- picocolors23.red(`\u2716 Orbit command failed: ${redactSecrets(message)}`)
250164
+ picocolors25.red(`\u2716 Orbit command failed: ${redactSecrets(message)}`)
249655
250165
  );
249656
250166
  process.exitCode = 1;
249657
250167
  }