@orbit-build/cli 0.2.0 → 0.2.2

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 +6 -4
  2. package/dist/index.js +1359 -565
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -518,7 +518,7 @@ var require_cross_spawn = __commonJS({
518
518
  var cp = __require("child_process");
519
519
  var parse6 = require_parse();
520
520
  var enoent = require_enoent();
521
- function spawn4(command, args, options) {
521
+ function spawn3(command, args, options) {
522
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);
@@ -530,8 +530,8 @@ var require_cross_spawn = __commonJS({
530
530
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
531
531
  return result;
532
532
  }
533
- module.exports = spawn4;
534
- module.exports.spawn = spawn4;
533
+ module.exports = spawn3;
534
+ module.exports.spawn = spawn3;
535
535
  module.exports.sync = spawnSync;
536
536
  module.exports._parse = parse6;
537
537
  module.exports._enoent = enoent;
@@ -58417,8 +58417,8 @@ ${lanes.join("\n")}
58417
58417
  }
58418
58418
  function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) {
58419
58419
  const isClassic = getEmitModuleResolutionKind(compilerOptions) === 1;
58420
- const errorMessage3 = isClassic ? Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option : Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
58421
- return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? void 0 : errorMessage3, ignoreErrors);
58420
+ const errorMessage4 = isClassic ? Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option : Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
58421
+ return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? void 0 : errorMessage4, ignoreErrors);
58422
58422
  }
58423
58423
  function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, ignoreErrors = false, isForAugmentation = false) {
58424
58424
  return isStringLiteralLike(moduleReferenceExpression) ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, !ignoreErrors ? moduleReferenceExpression : void 0, isForAugmentation) : void 0;
@@ -72788,8 +72788,8 @@ ${lanes.join("\n")}
72788
72788
  if (moduleSymbol.flags & targetMeaning) {
72789
72789
  links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning);
72790
72790
  } else {
72791
- const errorMessage3 = targetMeaning === 111551 ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0;
72792
- error2(node, errorMessage3, node.argument.literal.text);
72791
+ const errorMessage4 = targetMeaning === 111551 ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0;
72792
+ error2(node, errorMessage4, node.argument.literal.text);
72793
72793
  links.resolvedSymbol = unknownSymbol;
72794
72794
  links.resolvedType = errorType;
72795
72795
  }
@@ -74074,7 +74074,7 @@ ${lanes.join("\n")}
74074
74074
  function elaborateElementwise(iterator, source, target, relation, containingMessageChain, errorOutputContainer) {
74075
74075
  let reportedError = false;
74076
74076
  for (const value of iterator) {
74077
- const { errorNode: prop, innerExpression: next, nameType, errorMessage: errorMessage3 } = value;
74077
+ const { errorNode: prop, innerExpression: next, nameType, errorMessage: errorMessage4 } = value;
74078
74078
  let targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType);
74079
74079
  if (!targetPropType || targetPropType.flags & 8388608) continue;
74080
74080
  let sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType);
@@ -74114,9 +74114,9 @@ ${lanes.join("\n")}
74114
74114
  const sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216);
74115
74115
  targetPropType = removeMissingType(targetPropType, targetIsOptional);
74116
74116
  sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional);
74117
- const result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage3, containingMessageChain, resultObj);
74117
+ const result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage4, containingMessageChain, resultObj);
74118
74118
  if (result && specificSource !== sourcePropType) {
74119
- checkTypeRelatedTo(sourcePropType, targetPropType, relation, prop, errorMessage3, containingMessageChain, resultObj);
74119
+ checkTypeRelatedTo(sourcePropType, targetPropType, relation, prop, errorMessage4, containingMessageChain, resultObj);
74120
74120
  }
74121
74121
  }
74122
74122
  if (resultObj.errors) {
@@ -74163,7 +74163,7 @@ ${lanes.join("\n")}
74163
74163
  ) : void 0;
74164
74164
  let reportedError = false;
74165
74165
  for (let status = iterator.next(); !status.done; status = iterator.next()) {
74166
- const { errorNode: prop, innerExpression: next, nameType, errorMessage: errorMessage3 } = status.value;
74166
+ const { errorNode: prop, innerExpression: next, nameType, errorMessage: errorMessage4 } = status.value;
74167
74167
  let targetPropType = iterationType;
74168
74168
  const targetIndexedPropType = tupleOrArrayLikeTargetParts !== neverType2 ? getBestMatchIndexedAccessTypeOrUndefined(source, tupleOrArrayLikeTargetParts, nameType) : void 0;
74169
74169
  if (targetIndexedPropType && !(targetIndexedPropType.flags & 8388608)) {
@@ -74207,9 +74207,9 @@ ${lanes.join("\n")}
74207
74207
  const sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216);
74208
74208
  targetPropType = removeMissingType(targetPropType, targetIsOptional);
74209
74209
  sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional);
74210
- const result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage3, containingMessageChain, resultObj);
74210
+ const result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage4, containingMessageChain, resultObj);
74211
74211
  if (result && specificSource !== sourcePropType) {
74212
- checkTypeRelatedTo(sourcePropType, targetPropType, relation, prop, errorMessage3, containingMessageChain, resultObj);
74212
+ checkTypeRelatedTo(sourcePropType, targetPropType, relation, prop, errorMessage4, containingMessageChain, resultObj);
74213
74213
  }
74214
74214
  }
74215
74215
  }
@@ -85196,9 +85196,9 @@ ${lanes.join("\n")}
85196
85196
  return void 0;
85197
85197
  }
85198
85198
  const isClassic = getEmitModuleResolutionKind(compilerOptions) === 1;
85199
- const errorMessage3 = isClassic ? Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option : Diagnostics.This_JSX_tag_requires_the_module_path_0_to_exist_but_none_could_be_found_Make_sure_you_have_types_for_the_appropriate_package_installed;
85199
+ const errorMessage4 = isClassic ? Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option : Diagnostics.This_JSX_tag_requires_the_module_path_0_to_exist_but_none_could_be_found_Make_sure_you_have_types_for_the_appropriate_package_installed;
85200
85200
  const specifier = getJSXRuntimeImportSpecifier(file, runtimeImportSpecifier);
85201
- const mod = resolveExternalModule(specifier || location, runtimeImportSpecifier, errorMessage3, location);
85201
+ const mod = resolveExternalModule(specifier || location, runtimeImportSpecifier, errorMessage4, location);
85202
85202
  const result = mod && mod !== unknownSymbol ? getMergedSymbol(resolveSymbol(mod)) : void 0;
85203
85203
  if (links) {
85204
85204
  links.jsxImplicitImportContainer = result || false;
@@ -96832,7 +96832,7 @@ ${lanes.join("\n")}
96832
96832
  if (baseDeclarationFlags & 2 || derivedDeclarationFlags & 2) {
96833
96833
  continue;
96834
96834
  }
96835
- let errorMessage3;
96835
+ let errorMessage4;
96836
96836
  const basePropertyFlags = base.flags & 98308;
96837
96837
  const derivedPropertyFlags = derived.flags & 98308;
96838
96838
  if (basePropertyFlags && derivedPropertyFlags) {
@@ -96861,14 +96861,14 @@ ${lanes.join("\n")}
96861
96861
  continue;
96862
96862
  } else {
96863
96863
  Debug.assert(!!(derived.flags & 98304));
96864
- errorMessage3 = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
96864
+ errorMessage4 = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
96865
96865
  }
96866
96866
  } else if (base.flags & 98304) {
96867
- errorMessage3 = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
96867
+ errorMessage4 = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
96868
96868
  } else {
96869
- errorMessage3 = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
96869
+ errorMessage4 = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
96870
96870
  }
96871
- error2(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage3, typeToString(baseType), symbolToString(base), typeToString(type));
96871
+ error2(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage4, typeToString(baseType), symbolToString(base), typeToString(type));
96872
96872
  }
96873
96873
  }
96874
96874
  for (const [errorNode, memberInfo] of notImplementedInfo) {
@@ -97871,10 +97871,10 @@ ${lanes.join("\n")}
97871
97871
  }
97872
97872
  return false;
97873
97873
  }
97874
- function checkGrammarModuleElementContext(node, errorMessage3) {
97874
+ function checkGrammarModuleElementContext(node, errorMessage4) {
97875
97875
  const isInAppropriateContext = node.parent.kind === 308 || node.parent.kind === 269 || node.parent.kind === 268;
97876
97876
  if (!isInAppropriateContext) {
97877
- grammarErrorOnFirstToken(node, errorMessage3);
97877
+ grammarErrorOnFirstToken(node, errorMessage4);
97878
97878
  }
97879
97879
  return !isInAppropriateContext;
97880
97880
  }
@@ -136060,14 +136060,14 @@ ${lanes.join("\n")}
136060
136060
  return output;
136061
136061
  }
136062
136062
  function formatDiagnostic(diagnostic, host) {
136063
- const errorMessage3 = `${diagnosticCategoryName(diagnostic)} TS${diagnostic.code}: ${flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())}${host.getNewLine()}`;
136063
+ const errorMessage4 = `${diagnosticCategoryName(diagnostic)} TS${diagnostic.code}: ${flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())}${host.getNewLine()}`;
136064
136064
  if (diagnostic.file) {
136065
136065
  const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
136066
136066
  const fileName = diagnostic.file.fileName;
136067
136067
  const relativeFileName = convertToRelativePath(fileName, host.getCurrentDirectory(), (fileName2) => host.getCanonicalFileName(fileName2));
136068
- return `${relativeFileName}(${line + 1},${character + 1}): ` + errorMessage3;
136068
+ return `${relativeFileName}(${line + 1},${character + 1}): ` + errorMessage4;
136069
136069
  }
136070
- return errorMessage3;
136070
+ return errorMessage4;
136071
136071
  }
136072
136072
  var ForegroundColorEscapeSequences = /* @__PURE__ */ ((ForegroundColorEscapeSequences2) => {
136073
136073
  ForegroundColorEscapeSequences2["Grey"] = "\x1B[90m";
@@ -211377,7 +211377,7 @@ var require_src = __commonJS({
211377
211377
  });
211378
211378
 
211379
211379
  // src/index.ts
211380
- import { Command } from "commander";
211380
+ import { Command, Option } from "commander";
211381
211381
  import picocolors27 from "picocolors";
211382
211382
 
211383
211383
  // ../shared/dist/index.js
@@ -212115,15 +212115,15 @@ var makeIssue = (params) => {
212115
212115
  message: issueData.message
212116
212116
  };
212117
212117
  }
212118
- let errorMessage3 = "";
212118
+ let errorMessage4 = "";
212119
212119
  const maps = errorMaps.filter((m2) => !!m2).slice().reverse();
212120
212120
  for (const map of maps) {
212121
- errorMessage3 = map(fullIssue, { data, defaultError: errorMessage3 }).message;
212121
+ errorMessage4 = map(fullIssue, { data, defaultError: errorMessage4 }).message;
212122
212122
  }
212123
212123
  return {
212124
212124
  ...issueData,
212125
212125
  path: fullPath,
212126
- message: errorMessage3
212126
+ message: errorMessage4
212127
212127
  };
212128
212128
  };
212129
212129
  var EMPTY_PATH = [];
@@ -228987,11 +228987,11 @@ var Renderer = class {
228987
228987
  // ../core/dist/index.js
228988
228988
  import { z as z73 } from "zod";
228989
228989
  import { EventEmitter } from "events";
228990
- import { z as z34 } from "zod";
228990
+ import { z as z35 } from "zod";
228991
228991
  import picocolors8 from "picocolors";
228992
228992
  import path4 from "path";
228993
228993
  import fs3 from "fs";
228994
- import { randomUUID as randomUUID32 } from "crypto";
228994
+ import { randomUUID as randomUUID33 } from "crypto";
228995
228995
  import { exec as exec2, execFile as execFile3 } from "child_process";
228996
228996
  import { promisify as promisify3 } from "util";
228997
228997
  import { createHash as createHash23 } from "crypto";
@@ -229875,6 +229875,18 @@ import {
229875
229875
  import { homedir as homedir5 } from "os";
229876
229876
  import { basename as basename4, isAbsolute as isAbsolute22, join as join25, parse as parse2, resolve as resolve24 } from "path";
229877
229877
  import { z as z29 } from "zod";
229878
+ import {
229879
+ existsSync as existsSync35,
229880
+ mkdirSync as mkdirSync32,
229881
+ readFileSync as readFileSync33,
229882
+ readdirSync as readdirSync22,
229883
+ renameSync as renameSync32,
229884
+ rmSync as rmSync32,
229885
+ writeFileSync as writeFileSync32
229886
+ } from "fs";
229887
+ import { basename as basename22, join as join33, resolve as resolve33 } from "path";
229888
+ import { randomUUID as randomUUID32 } from "crypto";
229889
+ import { z as z34 } from "zod";
229878
229890
  var SafeObjectKeySchema = z28.string().refine(
229879
229891
  (key) => !["__proto__", "constructor", "prototype"].includes(key),
229880
229892
  "Unsafe object key."
@@ -231155,6 +231167,192 @@ function isDirectory(targetPath) {
231155
231167
  return false;
231156
231168
  }
231157
231169
  }
231170
+ var AgentIdSchema = z34.string().regex(/^agent_[a-z0-9-]+$/, "Invalid agent id.");
231171
+ var AgentRunIdSchema = z34.string().regex(/^run_[a-z0-9-]+$/, "Invalid agent run id.");
231172
+ var DurableAgentStateSchema = z34.object({
231173
+ id: AgentIdSchema,
231174
+ role: z34.string().min(1).max(80),
231175
+ task: z34.string().min(1).max(8e3),
231176
+ status: z34.enum([
231177
+ "pending",
231178
+ "running",
231179
+ "completed",
231180
+ "failed",
231181
+ "aborted",
231182
+ "blocked"
231183
+ ]),
231184
+ model: z34.string().min(1).max(200),
231185
+ budgetUsd: z34.number().finite().nonnegative(),
231186
+ costUsd: z34.number().finite().nonnegative().default(0),
231187
+ access: z34.object({
231188
+ mode: z34.enum(["read", "write"]),
231189
+ scopes: z34.array(z34.string().min(1).max(1e3)).min(1).max(100)
231190
+ }),
231191
+ startedAt: z34.string().datetime().optional(),
231192
+ endedAt: z34.string().datetime().optional(),
231193
+ error: z34.string().max(4e3).optional()
231194
+ });
231195
+ var AgentRunSchema = z34.object({
231196
+ schemaVersion: z34.literal(1),
231197
+ id: AgentRunIdSchema,
231198
+ task: z34.string().min(1).max(2e4),
231199
+ status: z34.enum(["running", "completed", "failed", "aborted"]),
231200
+ budgetUsd: z34.number().finite().nonnegative(),
231201
+ costUsd: z34.number().finite().nonnegative().default(0),
231202
+ createdAt: z34.string().datetime(),
231203
+ updatedAt: z34.string().datetime(),
231204
+ agents: z34.array(DurableAgentStateSchema).max(128)
231205
+ });
231206
+ var AgentRunStore = class {
231207
+ constructor(cwd) {
231208
+ this.cwd = cwd;
231209
+ this.directory = resolve33(cwd, ".orbit", "agent-runs");
231210
+ }
231211
+ cwd;
231212
+ directory;
231213
+ initialized = false;
231214
+ initialize() {
231215
+ mkdirSync32(this.directory, { recursive: true, mode: 448 });
231216
+ this.initialized = true;
231217
+ }
231218
+ createRun(input) {
231219
+ this.assertInitialized();
231220
+ const now = (/* @__PURE__ */ new Date()).toISOString();
231221
+ const run = AgentRunSchema.parse({
231222
+ schemaVersion: 1,
231223
+ id: generateId("run"),
231224
+ task: input.task,
231225
+ status: "running",
231226
+ budgetUsd: input.budgetUsd,
231227
+ costUsd: 0,
231228
+ createdAt: now,
231229
+ updatedAt: now,
231230
+ agents: []
231231
+ });
231232
+ this.write(run);
231233
+ return run;
231234
+ }
231235
+ addAgent(runId, input) {
231236
+ const run = this.requireRun(runId);
231237
+ const agent = DurableAgentStateSchema.parse({
231238
+ id: generateId("agent"),
231239
+ ...input,
231240
+ status: "pending",
231241
+ costUsd: 0
231242
+ });
231243
+ this.write({
231244
+ ...run,
231245
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
231246
+ agents: [...run.agents, agent]
231247
+ });
231248
+ return agent;
231249
+ }
231250
+ updateAgent(runId, agentId, patch) {
231251
+ AgentIdSchema.parse(agentId);
231252
+ const run = this.requireRun(runId);
231253
+ let updated;
231254
+ const agents = run.agents.map((agent) => {
231255
+ if (agent.id !== agentId) return agent;
231256
+ updated = DurableAgentStateSchema.parse({ ...agent, ...patch });
231257
+ return updated;
231258
+ });
231259
+ if (!updated) throw new Error(`Agent not found: ${agentId}`);
231260
+ this.write({
231261
+ ...run,
231262
+ costUsd: agents.reduce((sum, agent) => sum + agent.costUsd, 0),
231263
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
231264
+ agents
231265
+ });
231266
+ return updated;
231267
+ }
231268
+ finishRun(runId, status) {
231269
+ const run = this.requireRun(runId);
231270
+ const updated = AgentRunSchema.parse({
231271
+ ...run,
231272
+ status,
231273
+ costUsd: run.agents.reduce((sum, agent) => sum + agent.costUsd, 0),
231274
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
231275
+ });
231276
+ this.write(updated);
231277
+ return updated;
231278
+ }
231279
+ getRun(runId) {
231280
+ AgentRunIdSchema.parse(runId);
231281
+ const file = this.resolveRunFile(runId);
231282
+ if (!existsSync35(file)) return void 0;
231283
+ return this.read(file);
231284
+ }
231285
+ listRuns(limit = 20) {
231286
+ if (!existsSync35(this.directory)) return [];
231287
+ return readdirSync22(this.directory).filter((name) => /^run_[a-z0-9-]+\.json$/.test(name)).flatMap((name) => {
231288
+ try {
231289
+ return [
231290
+ this.read(
231291
+ resolveSafePath(this.cwd, join33(".orbit", "agent-runs", name))
231292
+ )
231293
+ ];
231294
+ } catch {
231295
+ return [];
231296
+ }
231297
+ }).sort((left, right) => right.updatedAt.localeCompare(left.updatedAt)).slice(0, Math.max(1, Math.min(100, limit)));
231298
+ }
231299
+ requireRun(runId) {
231300
+ this.assertInitialized();
231301
+ const run = this.getRun(runId);
231302
+ if (!run) throw new Error(`Agent run not found: ${runId}`);
231303
+ return run;
231304
+ }
231305
+ read(file) {
231306
+ try {
231307
+ return AgentRunSchema.parse(JSON.parse(readFileSync33(file, "utf8")));
231308
+ } catch (error) {
231309
+ throw new Error(
231310
+ `Invalid agent run ${basename22(file)}: ${error instanceof Error ? error.message : String(error)}`
231311
+ );
231312
+ }
231313
+ }
231314
+ write(run) {
231315
+ this.assertInitialized();
231316
+ const validated = AgentRunSchema.parse(run);
231317
+ const file = this.resolveRunFile(validated.id);
231318
+ const temporary = `${file}.${process.pid}.${randomUUID32()}.tmp`;
231319
+ const previous = `${file}.${process.pid}.${randomUUID32()}.bak`;
231320
+ writeFileSync32(temporary, JSON.stringify(validated, null, 2), {
231321
+ encoding: "utf8",
231322
+ mode: 384,
231323
+ flag: "wx"
231324
+ });
231325
+ let movedPrevious = false;
231326
+ try {
231327
+ if (existsSync35(file)) {
231328
+ renameSync32(file, previous);
231329
+ movedPrevious = true;
231330
+ }
231331
+ renameSync32(temporary, file);
231332
+ if (movedPrevious) rmSync32(previous, { force: true });
231333
+ } catch (error) {
231334
+ if (movedPrevious && !existsSync35(file) && existsSync35(previous)) {
231335
+ renameSync32(previous, file);
231336
+ }
231337
+ throw error;
231338
+ } finally {
231339
+ rmSync32(temporary, { force: true });
231340
+ if (existsSync35(file)) rmSync32(previous, { force: true });
231341
+ }
231342
+ }
231343
+ resolveRunFile(runId) {
231344
+ AgentRunIdSchema.parse(runId);
231345
+ return resolveSafePath(
231346
+ this.cwd,
231347
+ join33(".orbit", "agent-runs", `${runId}.json`)
231348
+ );
231349
+ }
231350
+ assertInitialized() {
231351
+ if (!this.initialized) {
231352
+ throw new Error("AgentRunStore.initialize() must be called first.");
231353
+ }
231354
+ }
231355
+ };
231158
231356
 
231159
231357
  // ../core/dist/index.js
231160
231358
  import { randomUUID as randomUUID24 } from "crypto";
@@ -231179,7 +231377,7 @@ import { promisify as promisify2 } from "util";
231179
231377
  import { z as z83 } from "zod";
231180
231378
  import fs4 from "fs";
231181
231379
  import path52 from "path";
231182
- import { existsSync as existsSync35, statSync as statSync4 } from "fs";
231380
+ import { existsSync as existsSync36, statSync as statSync4 } from "fs";
231183
231381
  import { z as z93 } from "zod";
231184
231382
  import { z as z103 } from "zod";
231185
231383
  function createInitialState(sessionId, task, maxAttempts = 8) {
@@ -232042,234 +232240,234 @@ function cleanRuntimeLabel(value, fallback) {
232042
232240
  return clean || fallback;
232043
232241
  }
232044
232242
  var ORBIT_EVENT_SCHEMA_VERSION = 1;
232045
- var ModelRequestEventSchema = z34.object({
232046
- type: z34.literal("model_request"),
232047
- payload: z34.object({
232048
- model: z34.string(),
232049
- messages: z34.array(z34.unknown())
232243
+ var ModelRequestEventSchema = z35.object({
232244
+ type: z35.literal("model_request"),
232245
+ payload: z35.object({
232246
+ model: z35.string(),
232247
+ messages: z35.array(z35.unknown())
232050
232248
  })
232051
232249
  });
232052
- var ModelResponseEventSchema = z34.object({
232053
- type: z34.literal("model_response"),
232054
- payload: z34.object({
232055
- model: z34.string(),
232056
- requestedModel: z34.string().optional(),
232057
- resolvedModel: z34.string().optional(),
232058
- providerRequestId: z34.string().optional(),
232059
- text: z34.string().optional(),
232060
- reasoning_content: z34.string().optional(),
232061
- usage: z34.object({
232062
- inputTokens: z34.number(),
232063
- outputTokens: z34.number(),
232064
- cacheReadTokens: z34.number().optional(),
232065
- cacheWriteTokens: z34.number().optional()
232250
+ var ModelResponseEventSchema = z35.object({
232251
+ type: z35.literal("model_response"),
232252
+ payload: z35.object({
232253
+ model: z35.string(),
232254
+ requestedModel: z35.string().optional(),
232255
+ resolvedModel: z35.string().optional(),
232256
+ providerRequestId: z35.string().optional(),
232257
+ text: z35.string().optional(),
232258
+ reasoning_content: z35.string().optional(),
232259
+ usage: z35.object({
232260
+ inputTokens: z35.number(),
232261
+ outputTokens: z35.number(),
232262
+ cacheReadTokens: z35.number().optional(),
232263
+ cacheWriteTokens: z35.number().optional()
232066
232264
  }).optional(),
232067
- toolCalls: z34.array(z34.unknown()).optional()
232265
+ toolCalls: z35.array(z35.unknown()).optional()
232068
232266
  })
232069
232267
  });
232070
- var AgentStartEventSchema = z34.object({
232071
- type: z34.literal("agent_start"),
232072
- payload: z34.object({
232073
- taskId: z34.string(),
232074
- task: z34.string()
232268
+ var AgentStartEventSchema = z35.object({
232269
+ type: z35.literal("agent_start"),
232270
+ payload: z35.object({
232271
+ taskId: z35.string(),
232272
+ task: z35.string()
232075
232273
  })
232076
232274
  });
232077
- var AgentSpawnEventSchema = z34.object({
232078
- type: z34.literal("agent_spawn"),
232079
- payload: z34.object({
232080
- parentId: z34.string(),
232081
- childId: z34.string(),
232082
- role: z34.string(),
232083
- task: z34.string()
232275
+ var AgentSpawnEventSchema = z35.object({
232276
+ type: z35.literal("agent_spawn"),
232277
+ payload: z35.object({
232278
+ parentId: z35.string(),
232279
+ childId: z35.string(),
232280
+ role: z35.string(),
232281
+ task: z35.string()
232084
232282
  })
232085
232283
  });
232086
- var AgentStatusEventSchema = z34.object({
232087
- type: z34.literal("agent_status"),
232088
- payload: z34.object({
232089
- taskId: z34.string(),
232090
- status: z34.string(),
232091
- detail: z34.string().optional()
232284
+ var AgentStatusEventSchema = z35.object({
232285
+ type: z35.literal("agent_status"),
232286
+ payload: z35.object({
232287
+ taskId: z35.string(),
232288
+ status: z35.string(),
232289
+ detail: z35.string().optional()
232092
232290
  })
232093
232291
  });
232094
- var AgentCompletedEventSchema = z34.object({
232095
- type: z34.literal("agent_completed"),
232096
- payload: z34.object({
232097
- taskId: z34.string(),
232098
- success: z34.boolean(),
232099
- result: z34.unknown().optional(),
232100
- error: z34.string().optional()
232292
+ var AgentCompletedEventSchema = z35.object({
232293
+ type: z35.literal("agent_completed"),
232294
+ payload: z35.object({
232295
+ taskId: z35.string(),
232296
+ success: z35.boolean(),
232297
+ result: z35.unknown().optional(),
232298
+ error: z35.string().optional()
232101
232299
  })
232102
232300
  });
232103
- var UiTurnStartedEventSchema = z34.object({
232104
- type: z34.literal("ui_turn_started"),
232105
- payload: z34.object({
232106
- turnId: z34.string(),
232107
- source: z34.enum(["terminal", "web"]),
232108
- prompt: z34.string()
232301
+ var UiTurnStartedEventSchema = z35.object({
232302
+ type: z35.literal("ui_turn_started"),
232303
+ payload: z35.object({
232304
+ turnId: z35.string(),
232305
+ source: z35.enum(["terminal", "web"]),
232306
+ prompt: z35.string()
232109
232307
  })
232110
232308
  });
232111
- var UiTurnCompletedEventSchema = z34.object({
232112
- type: z34.literal("ui_turn_completed"),
232113
- payload: z34.object({
232114
- turnId: z34.string(),
232115
- source: z34.enum(["terminal", "web"]),
232116
- status: z34.enum(["completed", "failed", "aborted"]),
232117
- message: z34.string().optional()
232309
+ var UiTurnCompletedEventSchema = z35.object({
232310
+ type: z35.literal("ui_turn_completed"),
232311
+ payload: z35.object({
232312
+ turnId: z35.string(),
232313
+ source: z35.enum(["terminal", "web"]),
232314
+ status: z35.enum(["completed", "failed", "aborted"]),
232315
+ message: z35.string().optional()
232118
232316
  })
232119
232317
  });
232120
- var LoopStartEventSchema = z34.object({
232121
- type: z34.literal("loop_start"),
232122
- payload: z34.object({
232123
- attempt: z34.number()
232318
+ var LoopStartEventSchema = z35.object({
232319
+ type: z35.literal("loop_start"),
232320
+ payload: z35.object({
232321
+ attempt: z35.number()
232124
232322
  })
232125
232323
  });
232126
- var ModelDeltaEventSchema = z34.object({
232127
- type: z34.literal("model_delta"),
232128
- payload: z34.object({
232129
- text: z34.string()
232324
+ var ModelDeltaEventSchema = z35.object({
232325
+ type: z35.literal("model_delta"),
232326
+ payload: z35.object({
232327
+ text: z35.string()
232130
232328
  })
232131
232329
  });
232132
- var ThinkingDeltaEventSchema = z34.object({
232133
- type: z34.literal("thinking_delta"),
232134
- payload: z34.object({
232135
- text: z34.string()
232330
+ var ThinkingDeltaEventSchema = z35.object({
232331
+ type: z35.literal("thinking_delta"),
232332
+ payload: z35.object({
232333
+ text: z35.string()
232136
232334
  })
232137
232335
  });
232138
- var CostUpdateEventSchema = z34.object({
232139
- type: z34.literal("cost_update"),
232140
- payload: z34.object({
232141
- turnCost: z34.number(),
232142
- sessionCost: z34.number(),
232143
- totalInputTokens: z34.number(),
232144
- totalCacheReadTokens: z34.number(),
232145
- totalOutputTokens: z34.number()
232336
+ var CostUpdateEventSchema = z35.object({
232337
+ type: z35.literal("cost_update"),
232338
+ payload: z35.object({
232339
+ turnCost: z35.number(),
232340
+ sessionCost: z35.number(),
232341
+ totalInputTokens: z35.number(),
232342
+ totalCacheReadTokens: z35.number(),
232343
+ totalOutputTokens: z35.number()
232146
232344
  })
232147
232345
  });
232148
- var CacheUpdateEventSchema = z34.object({
232149
- type: z34.literal("cache_update"),
232150
- payload: z34.object({
232151
- slabHash: z34.string(),
232152
- slabTokenEstimate: z34.number(),
232153
- hitTokens: z34.number(),
232154
- missTokens: z34.number(),
232155
- inputTokens: z34.number(),
232156
- hitRate: z34.number(),
232157
- degraded: z34.boolean()
232346
+ var CacheUpdateEventSchema = z35.object({
232347
+ type: z35.literal("cache_update"),
232348
+ payload: z35.object({
232349
+ slabHash: z35.string(),
232350
+ slabTokenEstimate: z35.number(),
232351
+ hitTokens: z35.number(),
232352
+ missTokens: z35.number(),
232353
+ inputTokens: z35.number(),
232354
+ hitRate: z35.number(),
232355
+ degraded: z35.boolean()
232158
232356
  })
232159
232357
  });
232160
- var ModelRoutingEventSchema = z34.object({
232161
- type: z34.literal("model_routing"),
232162
- payload: z34.object({
232163
- model: z34.string(),
232164
- lane: z34.enum(["locked", "fallback", "fast", "balanced", "quality"]),
232165
- reason: z34.string(),
232166
- confidence: z34.enum(["high", "medium"])
232358
+ var ModelRoutingEventSchema = z35.object({
232359
+ type: z35.literal("model_routing"),
232360
+ payload: z35.object({
232361
+ model: z35.string(),
232362
+ lane: z35.enum(["locked", "fallback", "fast", "balanced", "quality"]),
232363
+ reason: z35.string(),
232364
+ confidence: z35.enum(["high", "medium"])
232167
232365
  })
232168
232366
  });
232169
- var ToolProposalEventSchema = z34.object({
232170
- type: z34.literal("tool_proposal"),
232171
- payload: z34.object({
232172
- toolCallId: z34.string().optional(),
232173
- toolName: z34.string(),
232174
- arguments: z34.unknown(),
232175
- explanation: z34.string().optional()
232367
+ var ToolProposalEventSchema = z35.object({
232368
+ type: z35.literal("tool_proposal"),
232369
+ payload: z35.object({
232370
+ toolCallId: z35.string().optional(),
232371
+ toolName: z35.string(),
232372
+ arguments: z35.unknown(),
232373
+ explanation: z35.string().optional()
232176
232374
  })
232177
232375
  });
232178
- var ToolApprovalEventSchema = z34.object({
232179
- type: z34.literal("tool_approval"),
232180
- payload: z34.object({
232181
- toolCallId: z34.string().optional(),
232182
- approved: z34.boolean(),
232183
- reason: z34.string().optional()
232376
+ var ToolApprovalEventSchema = z35.object({
232377
+ type: z35.literal("tool_approval"),
232378
+ payload: z35.object({
232379
+ toolCallId: z35.string().optional(),
232380
+ approved: z35.boolean(),
232381
+ reason: z35.string().optional()
232184
232382
  })
232185
232383
  });
232186
- var ToolResultEventSchema = z34.object({
232187
- type: z34.literal("tool_result"),
232188
- payload: z34.object({
232189
- toolCallId: z34.string().optional(),
232190
- toolName: z34.string(),
232191
- result: z34.unknown().optional(),
232192
- error: z34.string().optional()
232384
+ var ToolResultEventSchema = z35.object({
232385
+ type: z35.literal("tool_result"),
232386
+ payload: z35.object({
232387
+ toolCallId: z35.string().optional(),
232388
+ toolName: z35.string(),
232389
+ result: z35.unknown().optional(),
232390
+ error: z35.string().optional()
232193
232391
  })
232194
232392
  });
232195
- var WebApprovalRequestedEventSchema = z34.object({
232196
- type: z34.literal("web_approval_requested"),
232197
- payload: z34.object({
232198
- approvalId: z34.string(),
232199
- kind: z34.enum(["tool", "change", "action"]),
232200
- title: z34.string(),
232201
- toolCallId: z34.string().optional()
232393
+ var WebApprovalRequestedEventSchema = z35.object({
232394
+ type: z35.literal("web_approval_requested"),
232395
+ payload: z35.object({
232396
+ approvalId: z35.string(),
232397
+ kind: z35.enum(["tool", "change", "action"]),
232398
+ title: z35.string(),
232399
+ toolCallId: z35.string().optional()
232202
232400
  })
232203
232401
  });
232204
- var WebApprovalResolvedEventSchema = z34.object({
232205
- type: z34.literal("web_approval_resolved"),
232206
- payload: z34.object({
232207
- approvalId: z34.string(),
232208
- approved: z34.boolean()
232402
+ var WebApprovalResolvedEventSchema = z35.object({
232403
+ type: z35.literal("web_approval_resolved"),
232404
+ payload: z35.object({
232405
+ approvalId: z35.string(),
232406
+ approved: z35.boolean()
232209
232407
  })
232210
232408
  });
232211
- var FileChangeEventSchema = z34.object({
232212
- type: z34.literal("file_change"),
232213
- payload: z34.object({
232214
- filePath: z34.string(),
232215
- type: z34.enum(["write", "edit", "create", "delete"]),
232216
- explanation: z34.string().optional()
232409
+ var FileChangeEventSchema = z35.object({
232410
+ type: z35.literal("file_change"),
232411
+ payload: z35.object({
232412
+ filePath: z35.string(),
232413
+ type: z35.enum(["write", "edit", "create", "delete"]),
232414
+ explanation: z35.string().optional()
232217
232415
  })
232218
232416
  });
232219
- var CheckpointCreatedEventSchema = z34.object({
232220
- type: z34.literal("checkpoint_created"),
232221
- payload: z34.object({
232222
- checkpointId: z34.string(),
232223
- timestamp: z34.string(),
232224
- message: z34.string().optional()
232417
+ var CheckpointCreatedEventSchema = z35.object({
232418
+ type: z35.literal("checkpoint_created"),
232419
+ payload: z35.object({
232420
+ checkpointId: z35.string(),
232421
+ timestamp: z35.string(),
232422
+ message: z35.string().optional()
232225
232423
  })
232226
232424
  });
232227
- var VerificationStartedEventSchema = z34.object({
232228
- type: z34.literal("verification_started"),
232229
- payload: z34.object({
232230
- type: z34.string()
232425
+ var VerificationStartedEventSchema = z35.object({
232426
+ type: z35.literal("verification_started"),
232427
+ payload: z35.object({
232428
+ type: z35.string()
232231
232429
  })
232232
232430
  });
232233
- var VerificationEndedEventSchema = z34.object({
232234
- type: z34.literal("verification_ended"),
232235
- payload: z34.object({
232236
- success: z34.boolean(),
232237
- results: z34.unknown().optional()
232431
+ var VerificationEndedEventSchema = z35.object({
232432
+ type: z35.literal("verification_ended"),
232433
+ payload: z35.object({
232434
+ success: z35.boolean(),
232435
+ results: z35.unknown().optional()
232238
232436
  })
232239
232437
  });
232240
- var SessionForkEventSchema = z34.object({
232241
- type: z34.literal("session_fork"),
232242
- payload: z34.object({
232243
- parentSessionId: z34.string(),
232244
- childSessionId: z34.string()
232438
+ var SessionForkEventSchema = z35.object({
232439
+ type: z35.literal("session_fork"),
232440
+ payload: z35.object({
232441
+ parentSessionId: z35.string(),
232442
+ childSessionId: z35.string()
232245
232443
  })
232246
232444
  });
232247
- var SessionEndedEventSchema = z34.object({
232248
- type: z34.literal("session_ended"),
232249
- payload: z34.object({
232250
- sessionId: z34.string()
232445
+ var SessionEndedEventSchema = z35.object({
232446
+ type: z35.literal("session_ended"),
232447
+ payload: z35.object({
232448
+ sessionId: z35.string()
232251
232449
  })
232252
232450
  });
232253
- var InfoEventSchema = z34.object({
232254
- type: z34.literal("info"),
232255
- payload: z34.object({
232256
- message: z34.string()
232451
+ var InfoEventSchema = z35.object({
232452
+ type: z35.literal("info"),
232453
+ payload: z35.object({
232454
+ message: z35.string()
232257
232455
  })
232258
232456
  });
232259
- var WarningEventSchema = z34.object({
232260
- type: z34.literal("warning"),
232261
- payload: z34.object({
232262
- message: z34.string()
232457
+ var WarningEventSchema = z35.object({
232458
+ type: z35.literal("warning"),
232459
+ payload: z35.object({
232460
+ message: z35.string()
232263
232461
  })
232264
232462
  });
232265
- var ErrorEventSchema = z34.object({
232266
- type: z34.literal("error"),
232267
- payload: z34.object({
232268
- message: z34.string(),
232269
- stack: z34.string().optional()
232463
+ var ErrorEventSchema = z35.object({
232464
+ type: z35.literal("error"),
232465
+ payload: z35.object({
232466
+ message: z35.string(),
232467
+ stack: z35.string().optional()
232270
232468
  })
232271
232469
  });
232272
- var OrbitEventSchema = z34.discriminatedUnion("type", [
232470
+ var OrbitEventSchema = z35.discriminatedUnion("type", [
232273
232471
  ModelRequestEventSchema,
232274
232472
  ModelResponseEventSchema,
232275
232473
  AgentStartEventSchema,
@@ -232299,10 +232497,10 @@ var OrbitEventSchema = z34.discriminatedUnion("type", [
232299
232497
  WarningEventSchema,
232300
232498
  ErrorEventSchema
232301
232499
  ]);
232302
- var OrbitEventEnvelopeSchema = z34.object({
232303
- schemaVersion: z34.literal(ORBIT_EVENT_SCHEMA_VERSION),
232304
- eventId: z34.string().min(1),
232305
- timestamp: z34.string().datetime()
232500
+ var OrbitEventEnvelopeSchema = z35.object({
232501
+ schemaVersion: z35.literal(ORBIT_EVENT_SCHEMA_VERSION),
232502
+ eventId: z35.string().min(1),
232503
+ timestamp: z35.string().datetime()
232306
232504
  }).and(OrbitEventSchema);
232307
232505
  var EventBus = class extends EventEmitter {
232308
232506
  sequence = 0;
@@ -235389,7 +235587,7 @@ ${diff.substring(0, 2e4)}`
235389
235587
  output: 'Unsafe hook placeholder "{file}" is no longer supported. Read the ORBIT_FILE environment variable instead.'
235390
235588
  };
235391
235589
  }
235392
- const toolCallId = `hook_${randomUUID32()}`;
235590
+ const toolCallId = `hook_${randomUUID33()}`;
235393
235591
  eventBus.emitEvent("tool_proposal", {
235394
235592
  toolCallId,
235395
235593
  toolName: "hook",
@@ -235503,7 +235701,7 @@ ${diff.substring(0, 2e4)}`
235503
235701
  const now = (/* @__PURE__ */ new Date()).toISOString();
235504
235702
  const plan = this.sessionManager.getTaskPlan();
235505
235703
  const item = {
235506
- id: `step_${randomUUID32()}`,
235704
+ id: `step_${randomUUID33()}`,
235507
235705
  text: text.trim(),
235508
235706
  status: "pending",
235509
235707
  createdAt: now,
@@ -236299,6 +236497,90 @@ function abortError(signal) {
236299
236497
  function toError2(error) {
236300
236498
  return error instanceof Error ? error : new Error(String(error));
236301
236499
  }
236500
+ var AgentRunTracker = class {
236501
+ constructor(cwd, task, budgetUsd, warn) {
236502
+ this.cwd = cwd;
236503
+ this.task = task;
236504
+ this.budgetUsd = budgetUsd;
236505
+ this.warn = warn;
236506
+ }
236507
+ cwd;
236508
+ task;
236509
+ budgetUsd;
236510
+ warn;
236511
+ store;
236512
+ run;
236513
+ initialize() {
236514
+ try {
236515
+ const store = new AgentRunStore(this.cwd);
236516
+ store.initialize();
236517
+ this.store = store;
236518
+ this.run = store.createRun({
236519
+ task: this.task,
236520
+ budgetUsd: this.budgetUsd
236521
+ });
236522
+ } catch (error) {
236523
+ this.warn(`Agent run state will be memory-only: ${errorMessage(error)}`);
236524
+ }
236525
+ }
236526
+ add(input) {
236527
+ if (!this.store || !this.run) return void 0;
236528
+ try {
236529
+ return this.store.addAgent(this.run.id, {
236530
+ role: input.role,
236531
+ task: input.task,
236532
+ model: input.model,
236533
+ budgetUsd: this.budgetUsd * input.budgetFraction,
236534
+ access: { mode: input.mode, scopes: input.scopes }
236535
+ });
236536
+ } catch (error) {
236537
+ this.warn(
236538
+ `Failed to persist ${input.role} state: ${errorMessage(error)}`
236539
+ );
236540
+ return void 0;
236541
+ }
236542
+ }
236543
+ markRunning(agent) {
236544
+ this.update(agent, {
236545
+ status: "running",
236546
+ startedAt: (/* @__PURE__ */ new Date()).toISOString()
236547
+ });
236548
+ }
236549
+ markFinished(agent, costUsd, outcome) {
236550
+ this.update(agent, {
236551
+ status: outcome.status === "completed" ? "completed" : outcome.status === "aborted" ? "aborted" : "failed",
236552
+ costUsd,
236553
+ endedAt: (/* @__PURE__ */ new Date()).toISOString(),
236554
+ error: outcome.status === "failed" ? outcome.error.message : outcome.status === "aborted" ? outcome.message : void 0
236555
+ });
236556
+ }
236557
+ markFailed(agent, costUsd, error) {
236558
+ this.update(agent, {
236559
+ status: "failed",
236560
+ costUsd,
236561
+ endedAt: (/* @__PURE__ */ new Date()).toISOString(),
236562
+ error: errorMessage(error)
236563
+ });
236564
+ }
236565
+ finish(outcome) {
236566
+ if (!this.store || !this.run) return;
236567
+ const status = outcome.status === "completed" ? "completed" : outcome.status === "aborted" ? "aborted" : "failed";
236568
+ try {
236569
+ this.run = this.store.finishRun(this.run.id, status);
236570
+ } catch {
236571
+ }
236572
+ }
236573
+ update(agent, patch) {
236574
+ if (!agent || !this.store || !this.run) return;
236575
+ try {
236576
+ this.store.updateAgent(this.run.id, agent.id, patch);
236577
+ } catch {
236578
+ }
236579
+ }
236580
+ };
236581
+ function errorMessage(error) {
236582
+ return error instanceof Error ? error.message : String(error);
236583
+ }
236302
236584
  var ReviewVerdictSchema = z93.object({
236303
236585
  verdict: z93.enum(["approved", "rejected"]),
236304
236586
  feedback: z93.string().default("")
@@ -236310,19 +236592,33 @@ var Orchestrator = class {
236310
236592
  this.provider = provider;
236311
236593
  this.task = task;
236312
236594
  this.interaction = interaction;
236595
+ this.agentRunTracker = new AgentRunTracker(
236596
+ cwd,
236597
+ task,
236598
+ config.budgetLimit,
236599
+ (message) => this.interaction.showText(` \u26A0\uFE0F ${message}`)
236600
+ );
236313
236601
  }
236314
236602
  cwd;
236315
236603
  config;
236316
236604
  provider;
236317
236605
  task;
236318
236606
  interaction;
236319
- activeLoops = /* @__PURE__ */ new Set();
236607
+ activeLoops = /* @__PURE__ */ new Map();
236320
236608
  activeTaskScheduler;
236609
+ agentRunTracker;
236321
236610
  aborted = false;
236322
236611
  abort(mode = "prompt") {
236323
236612
  this.aborted = true;
236324
236613
  this.activeTaskScheduler?.abort("Orchestration was interrupted.");
236325
- for (const loop of this.activeLoops) loop.abort(mode);
236614
+ for (const loop of this.activeLoops.values()) loop.abort(mode);
236615
+ }
236616
+ /** Cancel one active child without discarding unrelated agent state. */
236617
+ abortAgent(agentId) {
236618
+ const loop = this.activeLoops.get(agentId);
236619
+ if (!loop) return false;
236620
+ loop.abort("immediate");
236621
+ return true;
236326
236622
  }
236327
236623
  async run() {
236328
236624
  if (this.aborted) {
@@ -236335,11 +236631,16 @@ var Orchestrator = class {
236335
236631
  taskId: "multi-agent-session",
236336
236632
  task: this.task
236337
236633
  });
236634
+ this.agentRunTracker.initialize();
236338
236635
  this.interaction.showText("\n\u25CF Starting Multi-Agent Orchestration Flow...");
236339
236636
  const planner = await this.runPlanner();
236340
- if (planner.outcome.status !== "completed") return planner.outcome;
236637
+ if (planner.outcome.status !== "completed") {
236638
+ return this.finalizeOutcome(planner.outcome);
236639
+ }
236341
236640
  if (this.aborted) {
236342
- return this.abortedOutcome(0, "Orchestration was interrupted.");
236641
+ return this.finalizeOutcome(
236642
+ this.abortedOutcome(0, "Orchestration was interrupted.")
236643
+ );
236343
236644
  }
236344
236645
  const planText = planner.plan;
236345
236646
  this.persistPlan(planText);
@@ -236356,7 +236657,7 @@ var Orchestrator = class {
236356
236657
  worktree = worktrees.createWorktree(worktreeId, {
236357
236658
  snapshotWorkingTree: true
236358
236659
  });
236359
- if (!existsSync35(worktree.path) || !statSync4(worktree.path).isDirectory()) {
236660
+ if (!existsSync36(worktree.path) || !statSync4(worktree.path).isDirectory()) {
236360
236661
  throw new Error(
236361
236662
  `Worktree manager returned a missing directory: ${worktree.path}`
236362
236663
  );
@@ -236375,7 +236676,7 @@ var Orchestrator = class {
236375
236676
  }
236376
236677
  agentCwd = this.cwd;
236377
236678
  this.interaction.showText(
236378
- ` \u26A0\uFE0F Worktree unavailable; falling back to the main workspace: ${errorMessage(error)}`
236679
+ ` \u26A0\uFE0F Worktree unavailable; falling back to the main workspace: ${errorMessage2(error)}`
236379
236680
  );
236380
236681
  }
236381
236682
  } else {
@@ -236395,10 +236696,14 @@ var Orchestrator = class {
236395
236696
  attempt,
236396
236697
  maxAttempts
236397
236698
  );
236398
- if (coderOutcome.status !== "completed") return coderOutcome;
236699
+ if (coderOutcome.status !== "completed") {
236700
+ return this.finalizeOutcome(coderOutcome);
236701
+ }
236399
236702
  if (this.aborted) break;
236400
236703
  const review = await this.runReviewer(agentCwd, attempt, maxAttempts);
236401
- if (review.outcome.status !== "completed") return review.outcome;
236704
+ if (review.outcome.status !== "completed") {
236705
+ return this.finalizeOutcome(review.outcome);
236706
+ }
236402
236707
  if (review.verdict !== "approved") {
236403
236708
  feedback = review.feedback || "Reviewer rejected the implementation.";
236404
236709
  this.interaction.showText(
@@ -236416,7 +236721,7 @@ var Orchestrator = class {
236416
236721
  mergeFailed = true;
236417
236722
  mergeFailureMessage = mergeResult.error || mergeResult.conflictFiles?.join(", ") || "unknown merge error";
236418
236723
  this.interaction.showText(
236419
- ` \u2716 Merge failed; worktree was preserved at ${worktree.path}: ${errorMessage(mergeFailureMessage)}`
236724
+ ` \u2716 Merge failed; worktree was preserved at ${worktree.path}: ${errorMessage2(mergeFailureMessage)}`
236420
236725
  );
236421
236726
  break;
236422
236727
  }
@@ -236436,7 +236741,7 @@ var Orchestrator = class {
236436
236741
  worktrees.discardWorktree(worktree);
236437
236742
  } catch (error) {
236438
236743
  this.interaction.showText(
236439
- ` \u26A0\uFE0F Failed to clean temporary worktree: ${errorMessage(error)}`
236744
+ ` \u26A0\uFE0F Failed to clean temporary worktree: ${errorMessage2(error)}`
236440
236745
  );
236441
236746
  }
236442
236747
  }
@@ -236448,27 +236753,39 @@ var Orchestrator = class {
236448
236753
  );
236449
236754
  }
236450
236755
  if (completed) {
236451
- return {
236756
+ return this.finalizeOutcome({
236452
236757
  status: "completed",
236453
236758
  sessionId: "multi-agent-session",
236454
236759
  attempts: completedAttempts
236455
- };
236760
+ });
236456
236761
  }
236457
236762
  if (this.aborted) {
236458
- return this.abortedOutcome(
236459
- completedAttempts,
236460
- "Orchestration was interrupted."
236763
+ return this.finalizeOutcome(
236764
+ this.abortedOutcome(
236765
+ completedAttempts,
236766
+ "Orchestration was interrupted."
236767
+ )
236461
236768
  );
236462
236769
  }
236463
- return this.failedOutcome(
236464
- completedAttempts || maxAttempts,
236465
- mergeFailed ? `Failed to merge the reviewed worktree: ${errorMessage(mergeFailureMessage)}` : `Orchestration stopped after ${maxAttempts} rejected review attempts.`
236770
+ return this.finalizeOutcome(
236771
+ this.failedOutcome(
236772
+ completedAttempts || maxAttempts,
236773
+ mergeFailed ? `Failed to merge the reviewed worktree: ${errorMessage2(mergeFailureMessage)}` : `Orchestration stopped after ${maxAttempts} rejected review attempts.`
236774
+ )
236466
236775
  );
236467
236776
  }
236468
236777
  async runPlanner() {
236469
236778
  this.interaction.showText(
236470
236779
  "\n[Phase 1: Planning] Initializing Planner Agent..."
236471
236780
  );
236781
+ const tracked = this.addTrackedAgent(
236782
+ "planner",
236783
+ `Plan: ${this.task}`,
236784
+ this.config.models.planner,
236785
+ 0.15,
236786
+ "read",
236787
+ ["workspace"]
236788
+ );
236472
236789
  const loop = AgentLoop.initialize(
236473
236790
  this.cwd,
236474
236791
  this.config,
@@ -236493,15 +236810,22 @@ Do not modify files. Return the plan as plain text.`,
236493
236810
  disableMcp: true
236494
236811
  }
236495
236812
  );
236496
- this.activeLoops.add(loop);
236813
+ const activeId = tracked?.id || "planner";
236814
+ this.activeLoops.set(activeId, loop);
236815
+ this.markAgentRunning(tracked);
236816
+ let outcome;
236497
236817
  try {
236498
- const outcome = await loop.run();
236818
+ outcome = await loop.run();
236499
236819
  return {
236500
236820
  plan: lastAssistantText(loop) || "No plan generated.",
236501
236821
  outcome
236502
236822
  };
236823
+ } catch (error) {
236824
+ this.markAgentFailed(tracked, loop, error);
236825
+ throw error;
236503
236826
  } finally {
236504
- this.activeLoops.delete(loop);
236827
+ if (outcome) this.markAgentFinished(tracked, loop, outcome);
236828
+ this.activeLoops.delete(activeId);
236505
236829
  }
236506
236830
  }
236507
236831
  async runCoder(cwd, plan, feedback, attempt, maxAttempts) {
@@ -236515,6 +236839,14 @@ ${feedback}
236515
236839
  Original plan:
236516
236840
  ${plan}` : `Implement the following plan:
236517
236841
  ${plan}`;
236842
+ const tracked = this.addTrackedAgent(
236843
+ `coder:${attempt}`,
236844
+ prompt,
236845
+ this.config.models.coder,
236846
+ 0.45 / maxAttempts,
236847
+ "write",
236848
+ ["workspace"]
236849
+ );
236518
236850
  const loop = AgentLoop.initialize(
236519
236851
  cwd,
236520
236852
  this.config,
@@ -236538,11 +236870,19 @@ Make precise changes in the current isolated workspace. Do not commit or merge.`
236538
236870
  disableMcp: true
236539
236871
  }
236540
236872
  );
236541
- this.activeLoops.add(loop);
236873
+ const activeId = tracked?.id || `coder-${attempt}`;
236874
+ this.activeLoops.set(activeId, loop);
236875
+ this.markAgentRunning(tracked);
236876
+ let outcome;
236542
236877
  try {
236543
- return await loop.run();
236878
+ outcome = await loop.run();
236879
+ return outcome;
236880
+ } catch (error) {
236881
+ this.markAgentFailed(tracked, loop, error);
236882
+ throw error;
236544
236883
  } finally {
236545
- this.activeLoops.delete(loop);
236884
+ if (outcome) this.markAgentFinished(tracked, loop, outcome);
236885
+ this.activeLoops.delete(activeId);
236546
236886
  }
236547
236887
  }
236548
236888
  async runReviewer(cwd, attempt, maxAttempts) {
@@ -236565,6 +236905,7 @@ Make precise changes in the current isolated workspace. Do not commit or merge.`
236565
236905
  cwd,
236566
236906
  "correctness",
236567
236907
  "Review correctness, regressions, tests, and verification evidence.",
236908
+ maxAttempts,
236568
236909
  signal
236569
236910
  )
236570
236911
  },
@@ -236576,6 +236917,7 @@ Make precise changes in the current isolated workspace. Do not commit or merge.`
236576
236917
  cwd,
236577
236918
  "security",
236578
236919
  "Review security, workspace boundaries, credential handling, and destructive edge cases.",
236920
+ maxAttempts,
236579
236921
  signal
236580
236922
  )
236581
236923
  }
@@ -236621,8 +236963,16 @@ Make precise changes in the current isolated workspace. Do not commit or merge.`
236621
236963
  )
236622
236964
  );
236623
236965
  }
236624
- async runReviewerPerspective(cwd, perspective, instruction, signal) {
236625
- const childId = generateId(`review-${perspective}`);
236966
+ async runReviewerPerspective(cwd, perspective, instruction, maxAttempts, signal) {
236967
+ const tracked = this.addTrackedAgent(
236968
+ `reviewer:${perspective}`,
236969
+ instruction,
236970
+ this.config.models.reviewer,
236971
+ 0.2 / maxAttempts,
236972
+ "read",
236973
+ ["workspace"]
236974
+ );
236975
+ const childId = tracked?.id || generateId(`review-${perspective}`);
236626
236976
  eventBus.emitEvent("agent_spawn", {
236627
236977
  parentId: "multi-agent-session",
236628
236978
  childId,
@@ -236657,9 +237007,11 @@ Your final response must be one JSON object with this exact shape:
236657
237007
  const abortLoop = () => loop.abort("immediate");
236658
237008
  if (signal?.aborted) abortLoop();
236659
237009
  signal?.addEventListener("abort", abortLoop, { once: true });
236660
- this.activeLoops.add(loop);
237010
+ this.activeLoops.set(childId, loop);
237011
+ this.markAgentRunning(tracked);
237012
+ let outcome;
236661
237013
  try {
236662
- const outcome = await loop.run();
237014
+ outcome = await loop.run();
236663
237015
  eventBus.emitEvent("agent_completed", {
236664
237016
  taskId: childId,
236665
237017
  success: outcome.status === "completed",
@@ -236667,17 +237019,42 @@ Your final response must be one JSON object with this exact shape:
236667
237019
  });
236668
237020
  return { ...parseReviewVerdict(lastAssistantText(loop)), outcome };
236669
237021
  } catch (error) {
237022
+ this.markAgentFailed(tracked, loop, error);
236670
237023
  eventBus.emitEvent("agent_completed", {
236671
237024
  taskId: childId,
236672
237025
  success: false,
236673
- error: errorMessage(error)
237026
+ error: errorMessage2(error)
236674
237027
  });
236675
237028
  throw error;
236676
237029
  } finally {
237030
+ if (outcome) this.markAgentFinished(tracked, loop, outcome);
236677
237031
  signal?.removeEventListener("abort", abortLoop);
236678
- this.activeLoops.delete(loop);
237032
+ this.activeLoops.delete(childId);
236679
237033
  }
236680
237034
  }
237035
+ addTrackedAgent(role, task, model, budgetFraction, mode, scopes) {
237036
+ return this.agentRunTracker.add({
237037
+ role,
237038
+ task,
237039
+ model,
237040
+ budgetFraction,
237041
+ mode,
237042
+ scopes
237043
+ });
237044
+ }
237045
+ markAgentRunning(agent) {
237046
+ this.agentRunTracker.markRunning(agent);
237047
+ }
237048
+ markAgentFinished(agent, loop, outcome) {
237049
+ this.agentRunTracker.markFinished(agent, loop.getSessionCost(), outcome);
237050
+ }
237051
+ markAgentFailed(agent, loop, error) {
237052
+ this.agentRunTracker.markFailed(agent, loop.getSessionCost(), error);
237053
+ }
237054
+ finalizeOutcome(outcome) {
237055
+ this.agentRunTracker.finish(outcome);
237056
+ return outcome;
237057
+ }
236681
237058
  abortedOutcome(attempts, message) {
236682
237059
  return {
236683
237060
  status: "aborted",
@@ -236694,7 +237071,7 @@ Your final response must be one JSON object with this exact shape:
236694
237071
  attempts,
236695
237072
  error: {
236696
237073
  code: "execution_error",
236697
- message: errorMessage(message)
237074
+ message: errorMessage2(message)
236698
237075
  }
236699
237076
  };
236700
237077
  }
@@ -236706,7 +237083,7 @@ Your final response must be one JSON object with this exact shape:
236706
237083
  this.interaction.showText(" \u2714 Plan saved to .orbit/task.md");
236707
237084
  } catch (error) {
236708
237085
  this.interaction.showText(
236709
- ` \u26A0\uFE0F Failed to persist plan: ${errorMessage(error)}`
237086
+ ` \u26A0\uFE0F Failed to persist plan: ${errorMessage2(error)}`
236710
237087
  );
236711
237088
  }
236712
237089
  }
@@ -236733,11 +237110,11 @@ function parseReviewVerdict(text) {
236733
237110
  } catch (error) {
236734
237111
  return {
236735
237112
  verdict: "rejected",
236736
- feedback: `Invalid reviewer JSON: ${errorMessage(error)}`
237113
+ feedback: `Invalid reviewer JSON: ${errorMessage2(error)}`
236737
237114
  };
236738
237115
  }
236739
237116
  }
236740
- function errorMessage(error) {
237117
+ function errorMessage2(error) {
236741
237118
  const raw = error instanceof Error ? error.message : String(error);
236742
237119
  return redactSecrets(raw).replace(/[\u0000-\u001f\u007f-\u009f]/g, " ").replace(/\s+/g, " ").trim().slice(0, 2e3);
236743
237120
  }
@@ -237301,6 +237678,16 @@ var SLASH_COMMAND_DEFINITIONS = [
237301
237678
  },
237302
237679
  webSuggested: true
237303
237680
  },
237681
+ {
237682
+ command: "/review",
237683
+ usage: "[preset|commit <ref>|branch <ref>|custom <policy>]",
237684
+ category: "git",
237685
+ description: {
237686
+ en: "Run an evidence-first code review with focused presets",
237687
+ zh: "\u4F7F\u7528\u4E13\u9879\u9884\u8BBE\u6267\u884C\u57FA\u4E8E\u8BC1\u636E\u7684\u4EE3\u7801\u5BA1\u67E5"
237688
+ },
237689
+ webSuggested: true
237690
+ },
237304
237691
  {
237305
237692
  command: "/exit",
237306
237693
  usage: "",
@@ -237473,9 +237860,10 @@ function buildSlashCommandHelp(isZh) {
237473
237860
  }
237474
237861
 
237475
237862
  // src/tui/TerminalText.ts
237476
- var ANSI_PATTERN = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
237863
+ var TERMINAL_CONTROL_PATTERN = /(?:[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;;[^\u0007]*(?:\u0007|\u001b\\))/g;
237864
+ var HYPERLINK_CLOSE = "\x1B]8;;\x07";
237477
237865
  function stripAnsiCodes(str) {
237478
- return str.replace(ANSI_PATTERN, "");
237866
+ return str.replace(TERMINAL_CONTROL_PATTERN, "");
237479
237867
  }
237480
237868
  function isFullWidth(codePoint) {
237481
237869
  if (Number.isNaN(codePoint)) return false;
@@ -237518,19 +237906,22 @@ function wrapAnsiLine(line, maxWidth) {
237518
237906
  let currentLine = "";
237519
237907
  let currentWidth = 0;
237520
237908
  let activeColor = "";
237909
+ let activeHyperlink = "";
237521
237910
  let index = 0;
237522
237911
  while (index < line.length) {
237523
- ANSI_PATTERN.lastIndex = index;
237524
- const match = ANSI_PATTERN.exec(line);
237912
+ TERMINAL_CONTROL_PATTERN.lastIndex = index;
237913
+ const match = TERMINAL_CONTROL_PATTERN.exec(line);
237525
237914
  if (match?.index === index) {
237526
- const ansiCode = match[0];
237527
- currentLine += ansiCode;
237528
- if (ansiCode.includes("m") && !ansiCode.includes("[0m")) {
237529
- activeColor = ansiCode;
237530
- } else if (ansiCode.includes("[0m")) {
237915
+ const controlSequence = match[0];
237916
+ currentLine += controlSequence;
237917
+ if (controlSequence.startsWith("\x1B]8;;")) {
237918
+ activeHyperlink = controlSequence === HYPERLINK_CLOSE ? "" : controlSequence;
237919
+ } else if (controlSequence.includes("m") && !controlSequence.includes("[0m")) {
237920
+ activeColor = controlSequence;
237921
+ } else if (controlSequence.includes("[0m")) {
237531
237922
  activeColor = "";
237532
237923
  }
237533
- index += ansiCode.length;
237924
+ index += controlSequence.length;
237534
237925
  continue;
237535
237926
  }
237536
237927
  const code = line.codePointAt(index) ?? 0;
@@ -237539,8 +237930,9 @@ function wrapAnsiLine(line, maxWidth) {
237539
237930
  const charWidth = isFullWidth(code) ? 2 : 1;
237540
237931
  if (currentWidth + charWidth > maxWidth) {
237541
237932
  if (activeColor) currentLine += "\x1B[0m";
237933
+ if (activeHyperlink) currentLine += HYPERLINK_CLOSE;
237542
237934
  lines.push(currentLine);
237543
- currentLine = activeColor + char;
237935
+ currentLine = activeColor + activeHyperlink + char;
237544
237936
  currentWidth = charWidth;
237545
237937
  } else {
237546
237938
  currentLine += char;
@@ -238301,13 +238693,13 @@ function renderPromptScreen(state, viewport, theme = MORANDI) {
238301
238693
 
238302
238694
  // src/runtime/UpdateManager.ts
238303
238695
  import { execFile as execFile4, execFileSync as execFileSync4 } from "child_process";
238304
- import { z as z35 } from "zod";
238305
- var SemanticVersionSchema = z35.string().trim().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/);
238306
- var UpdateChannelSchema = z35.enum(["stable", "beta"]);
238307
- var UpdateCheckSchema = z35.object({
238696
+ import { z as z36 } from "zod";
238697
+ var SemanticVersionSchema = z36.string().trim().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/);
238698
+ var UpdateChannelSchema = z36.enum(["stable", "beta"]);
238699
+ var UpdateCheckSchema = z36.object({
238308
238700
  currentVersion: SemanticVersionSchema,
238309
238701
  latestVersion: SemanticVersionSchema,
238310
- updateAvailable: z35.boolean()
238702
+ updateAvailable: z36.boolean()
238311
238703
  });
238312
238704
  var UpdateManager = class {
238313
238705
  executable;
@@ -238391,9 +238783,9 @@ var UpdateManager = class {
238391
238783
  ],
238392
238784
  { timeoutMs: this.timeoutMs, inheritOutput: false }
238393
238785
  );
238394
- const parsed = z35.object({
238395
- dependencies: z35.object({
238396
- "@orbit-build/cli": z35.object({ version: SemanticVersionSchema })
238786
+ const parsed = z36.object({
238787
+ dependencies: z36.object({
238788
+ "@orbit-build/cli": z36.object({ version: SemanticVersionSchema })
238397
238789
  })
238398
238790
  }).parse(JSON.parse(raw));
238399
238791
  return parsed.dependencies["@orbit-build/cli"].version;
@@ -238592,6 +238984,9 @@ async function pageText(text) {
238592
238984
 
238593
238985
  // src/tui/FullscreenTui.ts
238594
238986
  var INPUT_PREFIX_WIDTH = 12;
238987
+ function terminalHyperlink(label, url) {
238988
+ return `\x1B]8;;${url}\x07${label}\x1B]8;;\x07`;
238989
+ }
238595
238990
  var FullscreenTui = class {
238596
238991
  constructor(cwd, modelName, version, config, dependencies = {}) {
238597
238992
  this.cwd = cwd;
@@ -238620,7 +239015,6 @@ var FullscreenTui = class {
238620
239015
  cachedStaticLinesCount = 0;
238621
239016
  cachedStaticContent = "";
238622
239017
  lastRenderedBottomHeight = 0;
238623
- pinnedNotice = null;
238624
239018
  // DeepSeek real-time thinking
238625
239019
  currentThinking = "";
238626
239020
  // Timers and metrics
@@ -238749,7 +239143,7 @@ var FullscreenTui = class {
238749
239143
  this.inputHistory = this.inputHistoryStore.load();
238750
239144
  this.terminalInitialized = true;
238751
239145
  }
238752
- formatSystemStatusLine(rawLine, prefixUnknown) {
239146
+ formatSystemStatusLine(rawLine, prefixUnknown, actionLink) {
238753
239147
  const morandi2 = MORANDI;
238754
239148
  const plain = stripAnsiCodes(rawLine.trim()).trim();
238755
239149
  if (!plain) return "";
@@ -238757,7 +239151,11 @@ var FullscreenTui = class {
238757
239151
  return "";
238758
239152
  }
238759
239153
  if (plain.startsWith("\u2714")) {
238760
- return morandi2.completed("completed") + morandi2.gray(plain.substring(1));
239154
+ const renderedLink = actionLink ? ` ${terminalHyperlink(
239155
+ morandi2.accent(actionLink.label),
239156
+ actionLink.url
239157
+ )} ${morandi2.dim("\xB7")}` : "";
239158
+ return morandi2.completed("completed") + renderedLink + morandi2.gray(plain.substring(1));
238761
239159
  }
238762
239160
  if (plain.startsWith("\u2716")) {
238763
239161
  return morandi2.failed("failed") + morandi2.gray(plain.substring(1));
@@ -238799,6 +239197,7 @@ var FullscreenTui = class {
238799
239197
  lastLiveLookupQuery = "";
238800
239198
  };
238801
239199
  for (const sys of system) {
239200
+ let pendingActionLink = sys.actionLink;
238802
239201
  const rawLines = sys.text.split("\n");
238803
239202
  for (const rawLine of rawLines) {
238804
239203
  const plain = stripAnsiCodes(rawLine.trim()).trim();
@@ -238837,10 +239236,12 @@ var FullscreenTui = class {
238837
239236
  flushLiveLookupSummary();
238838
239237
  const formatted = this.formatSystemStatusLine(
238839
239238
  rawLine,
238840
- options.prefixUnknown
239239
+ options.prefixUnknown,
239240
+ pendingActionLink
238841
239241
  );
238842
239242
  if (formatted) {
238843
239243
  lines.push(formatted);
239244
+ pendingActionLink = void 0;
238844
239245
  }
238845
239246
  }
238846
239247
  }
@@ -238862,20 +239263,15 @@ var FullscreenTui = class {
238862
239263
  saveInputHistory() {
238863
239264
  this.inputHistoryStore.save(this.inputHistory);
238864
239265
  }
238865
- addSystemMessage(text, _raw = false) {
239266
+ addSystemMessage(text, _raw = false, actionLink) {
238866
239267
  if (!text) return;
238867
239268
  this.history.push({
238868
239269
  role: "system",
238869
- text
239270
+ text,
239271
+ actionLink
238870
239272
  });
238871
239273
  this.render();
238872
239274
  }
238873
- /** Keep one important action visible immediately above the terminal status row. */
238874
- setPinnedNotice(text, url) {
238875
- const normalized = text?.trim();
238876
- this.pinnedNotice = normalized ? { text: normalized, url } : null;
238877
- if (this.isActive) this.render();
238878
- }
238879
239275
  /** Mirror a prompt submitted by another local UI into this conversation. */
238880
239276
  addUserMessage(text) {
238881
239277
  const trimmed = text.trim();
@@ -240264,15 +240660,6 @@ var FullscreenTui = class {
240264
240660
  1,
240265
240661
  columns - 6 - statusTextLength - keybindingsLength
240266
240662
  );
240267
- if (this.pinnedNotice) {
240268
- const availableWidth2 = Math.max(12, columns - 7);
240269
- const noticeText = truncatePlainToWidth(
240270
- this.pinnedNotice.text,
240271
- availableWidth2
240272
- );
240273
- const renderedNotice = this.pinnedNotice.url ? `\x1B]8;;${this.pinnedNotice.url}\x07${morandi2.accent(noticeText)}\x1B]8;;\x07` : morandi2.accent(noticeText);
240274
- bottomLines.push(" " + morandi2.completed("\u25CF") + " " + renderedNotice);
240275
- }
240276
240663
  bottomLines.push(" " + statusText + " ".repeat(spacing) + keybindings);
240277
240664
  const bottomHeight = bottomLines.length;
240278
240665
  const displayedModel = environment.activeModelName || this.modelNameGetter();
@@ -240689,7 +241076,7 @@ import { dirname as dirname10, resolve as resolve10 } from "path";
240689
241076
  import { homedir as homedir10 } from "os";
240690
241077
  import http2 from "http";
240691
241078
  import { randomBytes as randomBytes2, randomUUID as randomUUID9, timingSafeEqual as timingSafeEqual2 } from "crypto";
240692
- import { z as z48 } from "zod";
241079
+ import { z as z50 } from "zod";
240693
241080
 
240694
241081
  // src/runtime/CommandRouter.ts
240695
241082
  import picocolors18 from "picocolors";
@@ -240699,11 +241086,11 @@ import { existsSync as existsSync16, readFileSync as readFileSync19, readdirSync
240699
241086
  import { basename as basename5, extname as extname2, join as join16 } from "path";
240700
241087
  import { homedir as homedir8 } from "os";
240701
241088
  import { parse as parse3 } from "yaml";
240702
- import { z as z36 } from "zod";
240703
- var CommandMetadataSchema = z36.object({
240704
- description: z36.string().max(240).optional(),
240705
- argumentHint: z36.string().max(120).optional(),
240706
- "argument-hint": z36.string().max(120).optional()
241089
+ import { z as z37 } from "zod";
241090
+ var CommandMetadataSchema = z37.object({
241091
+ description: z37.string().max(240).optional(),
241092
+ argumentHint: z37.string().max(120).optional(),
241093
+ "argument-hint": z37.string().max(120).optional()
240707
241094
  });
240708
241095
  var VALID_COMMAND_NAME = /^[a-z0-9][a-z0-9-_]{0,47}$/i;
240709
241096
  var MAX_COMMAND_FILE_BYTES = 256 * 1024;
@@ -240843,26 +241230,23 @@ ${args}`;
240843
241230
  // src/runtime/CommandRouter.ts
240844
241231
  import { createRequire as createRequire2 } from "module";
240845
241232
 
240846
- // src/runtime/webui/WebUiServer.ts
240847
- import { spawn as spawn2 } from "child_process";
240848
-
240849
241233
  // src/runtime/webui/WebUiRuntime.ts
240850
241234
  import http from "http";
240851
241235
  import { randomBytes, randomUUID as randomUUID7 } from "crypto";
240852
- import { z as z39 } from "zod";
241236
+ import { z as z40 } from "zod";
240853
241237
 
240854
241238
  // src/runtime/AutocompleteCandidates.ts
240855
241239
  import glob6 from "fast-glob";
240856
241240
  import { existsSync as existsSync17, readFileSync as readFileSync20, readdirSync as readdirSync7 } from "fs";
240857
241241
  import { homedir as homedir9 } from "os";
240858
241242
  import { dirname as dirname9, join as join17, resolve as resolve7 } from "path";
240859
- import { z as z37 } from "zod";
240860
- var symbolIndexSchema = z37.object({
240861
- files: z37.record(
240862
- z37.object({
240863
- symbols: z37.array(
240864
- z37.object({
240865
- name: z37.string().min(1)
241243
+ import { z as z38 } from "zod";
241244
+ var symbolIndexSchema = z38.object({
241245
+ files: z38.record(
241246
+ z38.object({
241247
+ symbols: z38.array(
241248
+ z38.object({
241249
+ name: z38.string().min(1)
240866
241250
  })
240867
241251
  ).optional()
240868
241252
  })
@@ -241064,6 +241448,34 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
241064
241448
  if (!button || state.busy) return;
241065
241449
  void submitTurn('/memory remove ' + button.dataset.memoryRemove);
241066
241450
  });
241451
+ elements.reviewPresets.addEventListener('click', (event) => {
241452
+ const button = event.target.closest('[data-review-preset]');
241453
+ if (!button) return;
241454
+ const command = '/review ' + button.dataset.reviewPreset;
241455
+ setInspector(false);
241456
+ if (state.busy) {
241457
+ queuePrompt(command);
241458
+ return;
241459
+ }
241460
+ void submitTurn(command);
241461
+ });
241462
+ elements.agentRunList.addEventListener('click', async (event) => {
241463
+ const button = event.target.closest('[data-agent-abort]');
241464
+ if (!button || button.disabled) return;
241465
+ button.disabled = true;
241466
+ try {
241467
+ await api('/api/agent', {
241468
+ method: 'POST',
241469
+ headers: { 'Content-Type': 'application/json' },
241470
+ body: JSON.stringify({ action: 'abort', agentId: button.dataset.agentAbort }),
241471
+ });
241472
+ showToast(copy.agentAborted, 'success');
241473
+ await loadStatus();
241474
+ } catch (error) {
241475
+ button.disabled = false;
241476
+ showToast(error.message || String(error), 'error');
241477
+ }
241478
+ });
241067
241479
  elements.changesList.addEventListener('click', (event) => {
241068
241480
  const button = event.target.closest('[data-rollback-file]');
241069
241481
  if (!button) return;
@@ -241993,6 +242405,9 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
241993
242405
  noChanges: '当前对话还没有文件改动。',
241994
242406
  noCheckpoints: '暂无可恢复检查点。',
241995
242407
  noVerification: '暂无验证结果。',
242408
+ noAgents: '当前工作区还没有委派智能体。',
242409
+ abortAgent: '终止智能体',
242410
+ agentAborted: '已发送智能体终止请求',
241996
242411
  queued: '已加入待发送队列',
241997
242412
  queueMessage: '加入队列',
241998
242413
  removeQueued: '移除待发送消息',
@@ -242096,6 +242511,9 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
242096
242511
  noChanges: 'No file changes in this chat.',
242097
242512
  noCheckpoints: 'No restorable checkpoints.',
242098
242513
  noVerification: 'No verification results.',
242514
+ noAgents: 'No delegated agents for this workspace.',
242515
+ abortAgent: 'Abort agent',
242516
+ agentAborted: 'Agent abort requested',
242099
242517
  queued: 'Added to follow-up queue',
242100
242518
  queueMessage: 'Queue message',
242101
242519
  removeQueued: 'Remove queued message',
@@ -242246,6 +242664,9 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
242246
242664
  runtime: byId('runtime'),
242247
242665
  planReview: byId('planReview'),
242248
242666
  planCount: byId('planCount'),
242667
+ agentRunList: byId('agentRunList'),
242668
+ agentRunCount: byId('agentRunCount'),
242669
+ reviewPresets: byId('reviewPresets'),
242249
242670
  memoryReview: byId('memoryReview'),
242250
242671
  memoryCount: byId('memoryCount'),
242251
242672
  toolHistory: byId('toolHistory'),
@@ -243845,10 +244266,63 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
243845
244266
  elements.contextMeter.title = meterDetail;
243846
244267
  elements.contextMeter.setAttribute('aria-label', copy.contextWindow + ': ' + meterDetail);
243847
244268
  renderWorkspaceState(data);
244269
+ renderAgentRuns(data.agentRuns);
243848
244270
  renderChangeReview(data.review || {});
243849
244271
  renderToolHistory(data.review || {});
243850
244272
  }
243851
244273
 
244274
+ function renderAgentRuns(value) {
244275
+ const runs = Array.isArray(value) ? value : [];
244276
+ const agents = runs.flatMap((run) =>
244277
+ (Array.isArray(run.agents) ? run.agents : []).map((agent) => ({
244278
+ ...agent,
244279
+ runStatus: run.status,
244280
+ })),
244281
+ );
244282
+ elements.agentRunCount.textContent = String(agents.length);
244283
+ elements.agentRunList.replaceChildren();
244284
+ if (!agents.length) {
244285
+ const empty = document.createElement('p');
244286
+ empty.className = 'review-empty';
244287
+ empty.textContent = copy.noAgents;
244288
+ elements.agentRunList.append(empty);
244289
+ return;
244290
+ }
244291
+ for (const agent of agents.slice(0, 24)) {
244292
+ const card = document.createElement('article');
244293
+ card.className = 'agent-card is-' + String(agent.status || 'pending');
244294
+ const heading = document.createElement('div');
244295
+ heading.className = 'agent-card-heading';
244296
+ const title = document.createElement('strong');
244297
+ title.textContent = agent.role || 'agent';
244298
+ const status = document.createElement('span');
244299
+ status.className = 'agent-status';
244300
+ status.textContent = agent.status || 'pending';
244301
+ heading.append(title, status);
244302
+ const task = document.createElement('p');
244303
+ task.textContent = agent.task || '';
244304
+ task.title = agent.task || '';
244305
+ const meta = document.createElement('div');
244306
+ meta.className = 'agent-meta';
244307
+ meta.textContent = [
244308
+ agent.model,
244309
+ agent.access,
244310
+ '$' + Number(agent.costUsd || 0).toFixed(4) + ' / $' + Number(agent.budgetUsd || 0).toFixed(2),
244311
+ ].filter(Boolean).join(' · ');
244312
+ card.append(heading, task, meta);
244313
+ if (agent.status === 'running') {
244314
+ const abort = document.createElement('button');
244315
+ abort.type = 'button';
244316
+ abort.className = 'agent-abort';
244317
+ abort.dataset.agentAbort = agent.id;
244318
+ abort.textContent = copy.abortAgent;
244319
+ abort.setAttribute('aria-label', copy.abortAgent + ': ' + (agent.role || 'agent'));
244320
+ card.append(abort);
244321
+ }
244322
+ elements.agentRunList.append(card);
244323
+ }
244324
+ }
244325
+
243852
244326
  function renderToolHistory(review) {
243853
244327
  const tools = Array.isArray(review.toolCalls) ? review.toolCalls : [];
243854
244328
  elements.toolHistoryCount.textContent = String(tools.length);
@@ -245057,7 +245531,7 @@ var WEB_UI_FAVICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4
245057
245531
 
245058
245532
  // src/runtime/webui/WebUiSecurity.ts
245059
245533
  import { timingSafeEqual } from "crypto";
245060
- import { z as z38 } from "zod";
245534
+ import { z as z39 } from "zod";
245061
245535
  function sanitizeWebEventPayload(type, payload) {
245062
245536
  if (!isRecord3(payload)) return void 0;
245063
245537
  switch (type) {
@@ -245250,7 +245724,7 @@ function sanitizeBaseUrl(value) {
245250
245724
  }
245251
245725
  }
245252
245726
  function webRequestErrorStatus(error) {
245253
- if (error instanceof z38.ZodError) return 400;
245727
+ if (error instanceof z39.ZodError) return 400;
245254
245728
  if (error instanceof Error && error.message === "Request body too large.") {
245255
245729
  return 413;
245256
245730
  }
@@ -245311,6 +245785,71 @@ function isRecord3(value) {
245311
245785
  return typeof value === "object" && value !== null;
245312
245786
  }
245313
245787
 
245788
+ // src/runtime/webui/WebUiAgentData.ts
245789
+ function summarizeWebUiAgentRuns(value) {
245790
+ if (!Array.isArray(value)) return [];
245791
+ return value.slice(0, 12).flatMap((candidate) => {
245792
+ if (!isRecord4(candidate) || !Array.isArray(candidate.agents)) return [];
245793
+ const id = boundedString(candidate.id, 128);
245794
+ if (!/^run_[a-z0-9-]+$/.test(id)) return [];
245795
+ return [
245796
+ {
245797
+ id,
245798
+ task: redactSecrets(boundedString(candidate.task, 2e3)),
245799
+ status: boundedEnum(candidate.status, [
245800
+ "running",
245801
+ "completed",
245802
+ "failed",
245803
+ "aborted"
245804
+ ]),
245805
+ budgetUsd: finiteNumber(candidate.budgetUsd),
245806
+ costUsd: finiteNumber(candidate.costUsd),
245807
+ updatedAt: boundedString(candidate.updatedAt, 64),
245808
+ agents: candidate.agents.slice(0, 64).flatMap((agent) => {
245809
+ if (!isRecord4(agent)) return [];
245810
+ const agentId = boundedString(agent.id, 128);
245811
+ if (!/^agent_[a-z0-9-]+$/.test(agentId)) return [];
245812
+ return [
245813
+ {
245814
+ id: agentId,
245815
+ role: redactSecrets(boundedString(agent.role, 80)),
245816
+ task: redactSecrets(boundedString(agent.task, 1e3)),
245817
+ status: boundedEnum(agent.status, [
245818
+ "pending",
245819
+ "running",
245820
+ "completed",
245821
+ "failed",
245822
+ "aborted",
245823
+ "blocked"
245824
+ ]),
245825
+ model: redactSecrets(boundedString(agent.model, 200)),
245826
+ budgetUsd: finiteNumber(agent.budgetUsd),
245827
+ costUsd: finiteNumber(agent.costUsd),
245828
+ access: isRecord4(agent.access) && agent.access.mode === "write" ? "write" : "read",
245829
+ scopes: isRecord4(agent.access) && Array.isArray(agent.access.scopes) ? agent.access.scopes.slice(0, 20).map((scope) => redactSecrets(boundedString(scope, 300))) : [],
245830
+ startedAt: boundedString(agent.startedAt, 64),
245831
+ endedAt: boundedString(agent.endedAt, 64),
245832
+ error: redactSecrets(boundedString(agent.error, 1e3))
245833
+ }
245834
+ ];
245835
+ })
245836
+ }
245837
+ ];
245838
+ });
245839
+ }
245840
+ function finiteNumber(value) {
245841
+ return typeof value === "number" && Number.isFinite(value) ? value : 0;
245842
+ }
245843
+ function boundedString(value, maxLength) {
245844
+ return typeof value === "string" ? value.slice(0, maxLength) : "";
245845
+ }
245846
+ function boundedEnum(value, values) {
245847
+ return typeof value === "string" && values.includes(value) ? value : "unknown";
245848
+ }
245849
+ function isRecord4(value) {
245850
+ return typeof value === "object" && value !== null;
245851
+ }
245852
+
245314
245853
  // src/runtime/webui/WebUiData.ts
245315
245854
  function filterWebUiCompletionFiles(files, rawQuery, limit = 60) {
245316
245855
  const query = rawQuery.trim().toLocaleLowerCase();
@@ -245334,7 +245873,7 @@ function summarizeWebUiContextFiles(value, limit = 24) {
245334
245873
  const seen = /* @__PURE__ */ new Set();
245335
245874
  if (Array.isArray(value)) {
245336
245875
  for (const candidate of value) {
245337
- if (!isRecord4(candidate)) continue;
245876
+ if (!isRecord5(candidate)) continue;
245338
245877
  const path6 = normalizeSafeWebUiPath(candidate.path);
245339
245878
  if (!path6 || seen.has(path6)) continue;
245340
245879
  seen.add(path6);
@@ -245401,9 +245940,13 @@ function collectWebUiStatus(options, activeTurn) {
245401
245940
  lastOpenedAt: typeof project.lastOpenedAt === "string" ? project.lastOpenedAt.slice(0, 64) : "",
245402
245941
  available: project.available === true
245403
245942
  }));
245943
+ const agentRuns = summarizeWebUiAgentRuns(
245944
+ safeCall(() => options.getAgentRuns?.()) || []
245945
+ );
245404
245946
  return {
245405
245947
  workspace: cwd,
245406
245948
  projects,
245949
+ agentRuns,
245407
245950
  provider: {
245408
245951
  id: providerId,
245409
245952
  type: provider.type || "unknown",
@@ -245488,12 +246031,12 @@ function collectWebUiStatus(options, activeTurn) {
245488
246031
  maxFiles: config.context.maxFilesToIndex,
245489
246032
  compactThreshold: config.context.compactThreshold,
245490
246033
  model: contextStatus?.model || activeModel2,
245491
- maxContextTokens: finiteNumber(contextStatus?.maxContextTokens),
245492
- compactAtTokens: finiteNumber(contextStatus?.compactAtTokens),
245493
- estimatedHistoryTokens: finiteNumber(
246034
+ maxContextTokens: finiteNumber2(contextStatus?.maxContextTokens),
246035
+ compactAtTokens: finiteNumber2(contextStatus?.compactAtTokens),
246036
+ estimatedHistoryTokens: finiteNumber2(
245494
246037
  contextStatus?.estimatedHistoryTokens
245495
246038
  ),
245496
- utilization: finiteNumber(contextStatus?.utilization)
246039
+ utilization: finiteNumber2(contextStatus?.utilization)
245497
246040
  },
245498
246041
  turn: activeTurn ? {
245499
246042
  active: true,
@@ -245510,12 +246053,12 @@ function collectWebUiStatus(options, activeTurn) {
245510
246053
  };
245511
246054
  }
245512
246055
  function summarizeWebUiReview(value) {
245513
- const record = isRecord4(value) ? value : {};
246056
+ const record = isRecord5(value) ? value : {};
245514
246057
  const rawChanges = Array.isArray(record.fileChanges) ? record.fileChanges : [];
245515
246058
  const rawToolCalls = Array.isArray(record.toolCalls) ? record.toolCalls : [];
245516
246059
  const rawCheckpoints = Array.isArray(record.checkpoints) ? record.checkpoints : [];
245517
246060
  const rawVerification = Array.isArray(record.verification) ? record.verification : [];
245518
- const fileChanges = rawChanges.filter(isRecord4).slice(-80).reverse().map((change) => ({
246061
+ const fileChanges = rawChanges.filter(isRecord5).slice(-80).reverse().map((change) => ({
245519
246062
  id: safeLabel(typeof change.id === "string" ? change.id : "", 200),
245520
246063
  path: normalizeSafeWebUiPath(change.path) || "unknown",
245521
246064
  diff: redactSecrets(stripAnsi3(String(change.diff || ""))).slice(
@@ -245527,7 +246070,7 @@ function summarizeWebUiReview(value) {
245527
246070
  100
245528
246071
  )
245529
246072
  })).filter((change) => change.id && change.path !== "unknown");
245530
- const checkpoints = rawCheckpoints.filter(isRecord4).slice(-40).reverse().map((checkpoint) => ({
246073
+ const checkpoints = rawCheckpoints.filter(isRecord5).slice(-40).reverse().map((checkpoint) => ({
245531
246074
  id: safeLabel(
245532
246075
  typeof checkpoint.id === "string" ? checkpoint.id : "",
245533
246076
  200
@@ -245542,7 +246085,7 @@ function summarizeWebUiReview(value) {
245542
246085
  ),
245543
246086
  files: (Array.isArray(checkpoint.files) ? checkpoint.files : []).map((path6) => normalizeSafeWebUiPath(path6)).filter((path6) => Boolean(path6)).slice(0, 50)
245544
246087
  })).filter((checkpoint) => checkpoint.id);
245545
- const verification = rawVerification.filter(isRecord4).slice(-20).reverse().map((entry) => ({
246088
+ const verification = rawVerification.filter(isRecord5).slice(-20).reverse().map((entry) => ({
245546
246089
  timestamp: safeLabel(
245547
246090
  typeof entry.timestamp === "string" ? entry.timestamp : "",
245548
246091
  100
@@ -245550,7 +246093,7 @@ function summarizeWebUiReview(value) {
245550
246093
  success: typeof entry.success === "boolean" ? entry.success : void 0,
245551
246094
  detail: typeof entry.detail === "string" ? redactSecrets(stripAnsi3(entry.detail)).slice(0, 2e3) : void 0
245552
246095
  }));
245553
- const toolCalls = rawToolCalls.filter(isRecord4).slice(-100).reverse().map((tool) => {
246096
+ const toolCalls = rawToolCalls.filter(isRecord5).slice(-100).reverse().map((tool) => {
245554
246097
  const startedAt = safeLabel(
245555
246098
  typeof tool.startedAt === "string" ? tool.startedAt : "",
245556
246099
  100
@@ -245583,7 +246126,7 @@ function summarizeWebUiReview(value) {
245583
246126
  return { fileChanges, toolCalls, checkpoints, verification };
245584
246127
  }
245585
246128
  function collectWebUiApproval(value) {
245586
- if (!isRecord4(value)) return void 0;
246129
+ if (!isRecord5(value)) return void 0;
245587
246130
  if (typeof value.id !== "string" || !["tool", "change", "action"].includes(String(value.kind))) {
245588
246131
  return void 0;
245589
246132
  }
@@ -245610,7 +246153,7 @@ function safeApprovalText(value, maxLength, preserveLines) {
245610
246153
  }
245611
246154
  function normalizeSessions(sessions, activeId) {
245612
246155
  if (!Array.isArray(sessions)) return [];
245613
- return sessions.filter(isRecord4).map((session) => ({
246156
+ return sessions.filter(isRecord5).map((session) => ({
245614
246157
  id: typeof session.id === "string" ? session.id : "",
245615
246158
  title: typeof session.title === "string" && session.title.trim() ? redactSecrets(session.title.trim()).slice(0, 160) : "Untitled task",
245616
246159
  model: typeof session.model === "string" ? session.model : "",
@@ -245663,8 +246206,8 @@ function buildModelOptions(options, activeModel2) {
245663
246206
  return safeCall(() => options.loop?.getModelOverride?.()) ? [discovered[0], automatic, ...discovered.slice(1)] : [automatic, ...discovered];
245664
246207
  }
245665
246208
  function normalizeMessage(message, index) {
245666
- const record = isRecord4(message) ? message : {};
245667
- const metadata = isRecord4(record.metadata) ? record.metadata : {};
246209
+ const record = isRecord5(message) ? message : {};
246210
+ const metadata = isRecord5(record.metadata) ? record.metadata : {};
245668
246211
  const role = record.role === "user" || record.role === "assistant" || record.role === "tool" ? record.role : "assistant";
245669
246212
  const blocks = normalizeMessageBlocks(record.content);
245670
246213
  return {
@@ -245683,7 +246226,7 @@ function normalizeMessageBlocks(content) {
245683
246226
  if (!Array.isArray(content)) return [];
245684
246227
  const blocks = [];
245685
246228
  for (const candidate of content) {
245686
- if (!isRecord4(candidate)) continue;
246229
+ if (!isRecord5(candidate)) continue;
245687
246230
  if (candidate.type === "text" && typeof candidate.text === "string") {
245688
246231
  blocks.push({ type: "text", text: candidate.text });
245689
246232
  continue;
@@ -245700,7 +246243,7 @@ function normalizeMessageBlocks(content) {
245700
246243
  });
245701
246244
  continue;
245702
246245
  }
245703
- if (candidate.type === "tool_call" && isRecord4(candidate.toolCall)) {
246246
+ if (candidate.type === "tool_call" && isRecord5(candidate.toolCall)) {
245704
246247
  blocks.push({
245705
246248
  type: "tool",
245706
246249
  id: typeof candidate.toolCall.id === "string" ? candidate.toolCall.id : "",
@@ -245710,7 +246253,7 @@ function normalizeMessageBlocks(content) {
245710
246253
  });
245711
246254
  continue;
245712
246255
  }
245713
- if (candidate.type === "tool_result" && isRecord4(candidate.toolResult)) {
246256
+ if (candidate.type === "tool_result" && isRecord5(candidate.toolResult)) {
245714
246257
  const isError = candidate.toolResult.isError === true;
245715
246258
  blocks.push({
245716
246259
  type: "tool",
@@ -245778,9 +246321,9 @@ function toolDetail(value, options = {}) {
245778
246321
  return detail ? { detail } : {};
245779
246322
  }
245780
246323
  function isInternalWebMessage(message) {
245781
- if (!isRecord4(message)) return true;
246324
+ if (!isRecord5(message)) return true;
245782
246325
  if (message.role === "system") return true;
245783
- const metadata = isRecord4(message.metadata) ? message.metadata : {};
246326
+ const metadata = isRecord5(message.metadata) ? message.metadata : {};
245784
246327
  return metadata.kind === "orbit_volatile_context" || metadata.kind === "history_compaction_summary";
245785
246328
  }
245786
246329
  function safeCall(fn) {
@@ -245790,13 +246333,13 @@ function safeCall(fn) {
245790
246333
  return void 0;
245791
246334
  }
245792
246335
  }
245793
- function finiteNumber(value) {
246336
+ function finiteNumber2(value) {
245794
246337
  return typeof value === "number" && Number.isFinite(value) ? value : 0;
245795
246338
  }
245796
246339
  function stripAnsi3(value) {
245797
246340
  return value.replace(/\u001b\[[0-9;]*m/g, "");
245798
246341
  }
245799
- function isRecord4(value) {
246342
+ function isRecord5(value) {
245800
246343
  return typeof value === "object" && value !== null;
245801
246344
  }
245802
246345
 
@@ -246112,6 +246655,16 @@ var COPY = {
246112
246655
  runtime: "Runtime",
246113
246656
  projectMemory: "Project memory",
246114
246657
  taskPlan: "Task plan",
246658
+ agentRuns: "Agent runs",
246659
+ noAgents: "No delegated agents for this workspace.",
246660
+ abortAgent: "Abort agent",
246661
+ reviewProject: "Review project",
246662
+ reviewProjectBody: "Launch an evidence-first, read-only review with a focused preset.",
246663
+ reviewComprehensive: "Comprehensive",
246664
+ reviewSecurity: "Security",
246665
+ reviewTests: "Tests",
246666
+ reviewPerformance: "Performance",
246667
+ reviewAccessibility: "Accessibility",
246115
246668
  noMemory: "No explicit project memory.",
246116
246669
  noPlan: "No plan steps for this chat.",
246117
246670
  noActivity: "Activity will appear here while Orbit works.",
@@ -246225,6 +246778,16 @@ var COPY = {
246225
246778
  runtime: "\u8FD0\u884C\u72B6\u6001",
246226
246779
  projectMemory: "\u9879\u76EE\u8BB0\u5FC6",
246227
246780
  taskPlan: "\u4EFB\u52A1\u8BA1\u5212",
246781
+ agentRuns: "\u667A\u80FD\u4F53\u8FD0\u884C",
246782
+ noAgents: "\u5F53\u524D\u5DE5\u4F5C\u533A\u8FD8\u6CA1\u6709\u59D4\u6D3E\u667A\u80FD\u4F53\u3002",
246783
+ abortAgent: "\u7EC8\u6B62\u667A\u80FD\u4F53",
246784
+ reviewProject: "\u9879\u76EE\u5BA1\u67E5",
246785
+ reviewProjectBody: "\u9009\u62E9\u91CD\u70B9\uFF0C\u542F\u52A8\u57FA\u4E8E\u8BC1\u636E\u7684\u53EA\u8BFB\u5BA1\u67E5\u3002",
246786
+ reviewComprehensive: "\u5168\u9762",
246787
+ reviewSecurity: "\u5B89\u5168",
246788
+ reviewTests: "\u6D4B\u8BD5",
246789
+ reviewPerformance: "\u6027\u80FD",
246790
+ reviewAccessibility: "\u65E0\u969C\u788D",
246228
246791
  noMemory: "\u6682\u65E0\u663E\u5F0F\u9879\u76EE\u8BB0\u5FC6\u3002",
246229
246792
  noPlan: "\u5F53\u524D\u5BF9\u8BDD\u6682\u65E0\u8BA1\u5212\u6B65\u9AA4\u3002",
246230
246793
  noActivity: "Orbit \u5DE5\u4F5C\u65F6\uFF0C\u6B65\u9AA4\u548C\u5DE5\u5177\u72B6\u6001\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002",
@@ -246569,6 +247132,10 @@ function renderWebUiPage(language) {
246569
247132
  <div class="section-heading"><h3>${copy.taskPlan}</h3><span id="planCount">0</span></div>
246570
247133
  <div class="review-list" id="planReview"><p class="review-empty">${copy.noPlan}</p></div>
246571
247134
  </section>
247135
+ <section class="detail-section">
247136
+ <div class="section-heading"><h3>${copy.agentRuns}</h3><span id="agentRunCount">0</span></div>
247137
+ <div class="agent-run-list" id="agentRunList"><p class="review-empty">${copy.noAgents}</p></div>
247138
+ </section>
246572
247139
  <section class="detail-section">
246573
247140
  <div class="section-heading"><h3>${copy.projectMemory}</h3><span id="memoryCount">0</span></div>
246574
247141
  <div class="review-list" id="memoryReview"><p class="review-empty">${copy.noMemory}</p></div>
@@ -246590,6 +247157,17 @@ function renderWebUiPage(language) {
246590
247157
  </section>
246591
247158
 
246592
247159
  <section class="tab-panel" id="changesPanel" role="tabpanel" aria-labelledby="changesTab" hidden>
247160
+ <section class="detail-section review-launcher">
247161
+ <div class="section-heading"><h3>${copy.reviewProject}</h3><span>READ ONLY</span></div>
247162
+ <p>${copy.reviewProjectBody}</p>
247163
+ <div class="review-preset-grid" id="reviewPresets">
247164
+ <button type="button" data-review-preset="comprehensive">${copy.reviewComprehensive}</button>
247165
+ <button type="button" data-review-preset="security">${copy.reviewSecurity}</button>
247166
+ <button type="button" data-review-preset="tests">${copy.reviewTests}</button>
247167
+ <button type="button" data-review-preset="performance">${copy.reviewPerformance}</button>
247168
+ <button type="button" data-review-preset="accessibility">${copy.reviewAccessibility}</button>
247169
+ </div>
247170
+ </section>
246593
247171
  <section class="detail-section changes-summary-section">
246594
247172
  <div class="section-heading"><h3>${copy.changedFiles}</h3><span id="changeCount">0</span></div>
246595
247173
  <div class="changes-list" id="changesList" data-testid="changes-list"><p class="review-empty">${copy.noChanges}</p></div>
@@ -249498,6 +250076,123 @@ var WEB_UI_INSPECTOR_STYLES = String.raw`
249498
250076
  background: var(--danger-soft);
249499
250077
  }
249500
250078
 
250079
+ .review-launcher > p {
250080
+ margin: -4px 0 11px;
250081
+ color: var(--muted);
250082
+ font-size: 10px;
250083
+ line-height: 1.5;
250084
+ }
250085
+
250086
+ .review-preset-grid {
250087
+ display: grid;
250088
+ grid-template-columns: repeat(2, minmax(0, 1fr));
250089
+ gap: 6px;
250090
+ }
250091
+
250092
+ .review-preset-grid button {
250093
+ min-height: 34px;
250094
+ padding: 7px 9px;
250095
+ color: var(--ink-strong);
250096
+ background: var(--surface-subtle);
250097
+ border: 1px solid var(--border);
250098
+ border-radius: 8px;
250099
+ font-size: 10px;
250100
+ font-weight: 650;
250101
+ text-align: left;
250102
+ }
250103
+
250104
+ .review-preset-grid button:first-child {
250105
+ grid-column: 1 / -1;
250106
+ color: var(--accent-strong);
250107
+ border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
250108
+ }
250109
+
250110
+ .review-preset-grid button:hover {
250111
+ background: var(--surface-hover);
250112
+ border-color: var(--border-strong);
250113
+ }
250114
+
250115
+ .agent-run-list {
250116
+ display: grid;
250117
+ gap: 7px;
250118
+ }
250119
+
250120
+ .agent-card {
250121
+ display: grid;
250122
+ gap: 5px;
250123
+ padding: 9px;
250124
+ background: var(--surface-subtle);
250125
+ border: 1px solid var(--border);
250126
+ border-radius: 9px;
250127
+ }
250128
+
250129
+ .agent-card.is-running {
250130
+ border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
250131
+ }
250132
+
250133
+ .agent-card-heading {
250134
+ display: flex;
250135
+ align-items: center;
250136
+ justify-content: space-between;
250137
+ gap: 8px;
250138
+ }
250139
+
250140
+ .agent-card-heading strong {
250141
+ overflow: hidden;
250142
+ color: var(--ink-strong);
250143
+ font-size: 10px;
250144
+ text-overflow: ellipsis;
250145
+ white-space: nowrap;
250146
+ }
250147
+
250148
+ .agent-status {
250149
+ color: var(--faint);
250150
+ font: 8px/1.4 var(--font-mono);
250151
+ letter-spacing: 0.05em;
250152
+ text-transform: uppercase;
250153
+ }
250154
+
250155
+ .agent-card.is-running .agent-status {
250156
+ color: var(--accent-strong);
250157
+ }
250158
+
250159
+ .agent-card.is-failed .agent-status,
250160
+ .agent-card.is-aborted .agent-status {
250161
+ color: var(--danger);
250162
+ }
250163
+
250164
+ .agent-card p {
250165
+ margin: 0;
250166
+ overflow: hidden;
250167
+ color: var(--muted);
250168
+ font-size: 10px;
250169
+ line-height: 1.45;
250170
+ text-overflow: ellipsis;
250171
+ white-space: nowrap;
250172
+ }
250173
+
250174
+ .agent-meta {
250175
+ overflow: hidden;
250176
+ color: var(--faint);
250177
+ font: 8px/1.45 var(--font-mono);
250178
+ text-overflow: ellipsis;
250179
+ white-space: nowrap;
250180
+ }
250181
+
250182
+ .agent-abort {
250183
+ justify-self: start;
250184
+ padding: 4px 7px;
250185
+ color: var(--danger);
250186
+ background: var(--danger-soft);
250187
+ border: 0;
250188
+ border-radius: 6px;
250189
+ font-size: 9px;
250190
+ }
250191
+
250192
+ .agent-abort:disabled {
250193
+ opacity: 0.45;
250194
+ }
250195
+
249501
250196
  .text-button {
249502
250197
  padding: 3px 0;
249503
250198
  color: var(--faint);
@@ -251930,56 +252625,60 @@ var WEB_UI_STYLE_SECTIONS = [
251930
252625
  var WEB_UI_STYLES = WEB_UI_STYLE_SECTIONS.join("");
251931
252626
 
251932
252627
  // src/runtime/webui/WebUiRuntime.ts
251933
- var WebTurnIdSchema = z39.string().trim().min(8).max(100).regex(/^[a-zA-Z0-9_-]+$/);
251934
- var ChatRequestSchema = z39.object({
251935
- prompt: z39.string().trim().min(1).max(1e5),
252628
+ var WebTurnIdSchema = z40.string().trim().min(8).max(100).regex(/^[a-zA-Z0-9_-]+$/);
252629
+ var ChatRequestSchema = z40.object({
252630
+ prompt: z40.string().trim().min(1).max(1e5),
251936
252631
  turnId: WebTurnIdSchema.optional(),
251937
- attachmentIds: z39.array(WebTurnIdSchema).max(4).optional()
252632
+ attachmentIds: z40.array(WebTurnIdSchema).max(4).optional()
251938
252633
  }).strict();
251939
- var CancelRequestSchema = z39.object({ turnId: WebTurnIdSchema.nullish() }).strict();
251940
- var ApprovalDecisionSchema = z39.object({
252634
+ var CancelRequestSchema = z40.object({ turnId: WebTurnIdSchema.nullish() }).strict();
252635
+ var ApprovalDecisionSchema = z40.object({
251941
252636
  id: WebTurnIdSchema,
251942
- approved: z39.boolean()
252637
+ approved: z40.boolean()
251943
252638
  }).strict();
251944
- var SettingsPatchSchema = z39.object({
251945
- provider: z39.string().trim().min(1).max(256).optional(),
251946
- model: z39.string().trim().min(1).max(200).optional(),
251947
- permissionMode: z39.enum(["strict", "normal", "auto", "plan"]).optional(),
251948
- webSearchEnabled: z39.boolean().optional(),
251949
- webSearchProvider: z39.enum(["auto", "searxng", "tavily", "bing", "duckduckgo"]).optional(),
251950
- webSearchMaxResults: z39.number().int().min(1).max(20).optional()
252639
+ var SettingsPatchSchema = z40.object({
252640
+ provider: z40.string().trim().min(1).max(256).optional(),
252641
+ model: z40.string().trim().min(1).max(200).optional(),
252642
+ permissionMode: z40.enum(["strict", "normal", "auto", "plan"]).optional(),
252643
+ webSearchEnabled: z40.boolean().optional(),
252644
+ webSearchProvider: z40.enum(["auto", "searxng", "tavily", "bing", "duckduckgo"]).optional(),
252645
+ webSearchMaxResults: z40.number().int().min(1).max(20).optional()
251951
252646
  }).strict();
251952
- var SessionActionSchema = z39.discriminatedUnion("action", [
251953
- z39.object({ action: z39.literal("new") }).strict(),
252647
+ var SessionActionSchema = z40.discriminatedUnion("action", [
252648
+ z40.object({ action: z40.literal("new") }).strict(),
251954
252649
  ...["resume", "archive", "restore", "delete"].map(
251955
- (action) => z39.object({
251956
- action: z39.literal(action),
251957
- sessionId: z39.string().trim().min(1).max(200).regex(/^[a-zA-Z0-9_-]+$/)
252650
+ (action) => z40.object({
252651
+ action: z40.literal(action),
252652
+ sessionId: z40.string().trim().min(1).max(200).regex(/^[a-zA-Z0-9_-]+$/)
251958
252653
  }).strict()
251959
252654
  )
251960
252655
  ]);
251961
- var ProjectActionSchema = z39.discriminatedUnion("action", [
251962
- z39.object({ action: z39.literal("pick") }).strict(),
251963
- z39.object({
251964
- action: z39.enum(["open", "create"]),
251965
- path: z39.string().trim().min(1).max(4096)
252656
+ var ProjectActionSchema = z40.discriminatedUnion("action", [
252657
+ z40.object({ action: z40.literal("pick") }).strict(),
252658
+ z40.object({
252659
+ action: z40.enum(["open", "create"]),
252660
+ path: z40.string().trim().min(1).max(4096)
251966
252661
  }).strict(),
251967
- z39.object({
251968
- action: z39.literal("remove"),
251969
- projectId: z39.string().trim().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/)
252662
+ z40.object({
252663
+ action: z40.literal("remove"),
252664
+ projectId: z40.string().trim().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/)
251970
252665
  }).strict()
251971
252666
  ]);
251972
- var ReviewActionSchema = z39.discriminatedUnion("action", [
251973
- z39.object({
251974
- action: z39.literal("rollback-file"),
251975
- path: z39.string().trim().min(1).max(4096)
252667
+ var ReviewActionSchema = z40.discriminatedUnion("action", [
252668
+ z40.object({
252669
+ action: z40.literal("rollback-file"),
252670
+ path: z40.string().trim().min(1).max(4096)
251976
252671
  }).strict(),
251977
- z39.object({
251978
- action: z39.literal("rewind"),
251979
- checkpointId: z39.string().trim().min(1).max(200).regex(/^[a-zA-Z0-9_-]+$/)
252672
+ z40.object({
252673
+ action: z40.literal("rewind"),
252674
+ checkpointId: z40.string().trim().min(1).max(200).regex(/^[a-zA-Z0-9_-]+$/)
251980
252675
  }).strict()
251981
252676
  ]);
251982
- var CompletionQuerySchema = z39.string().trim().max(200);
252677
+ var AgentActionSchema = z40.object({
252678
+ action: z40.literal("abort"),
252679
+ agentId: z40.string().regex(/^agent_[a-z0-9-]+$/).max(128)
252680
+ }).strict();
252681
+ var CompletionQuerySchema = z40.string().trim().max(200);
251983
252682
  var IMAGE_ATTACHMENT_LIMIT_BYTES = 5 * 1024 * 1024;
251984
252683
  var IMAGE_ATTACHMENT_STORE_LIMIT = 16;
251985
252684
  var ALLOWED_IMAGE_TYPES = /* @__PURE__ */ new Set([
@@ -252081,6 +252780,7 @@ var OrbitWebUiRuntime = class {
252081
252780
  const handle = {
252082
252781
  port: actualPort,
252083
252782
  url: `http://127.0.0.1:${actualPort}/#token=${encodeURIComponent(token)}`,
252783
+ browserOpened: false,
252084
252784
  close: () => this.stop()
252085
252785
  };
252086
252786
  this.handle = handle;
@@ -252267,6 +252967,10 @@ var OrbitWebUiRuntime = class {
252267
252967
  await this.handleReview(req, res, options);
252268
252968
  return;
252269
252969
  }
252970
+ if (req.method === "POST" && url.pathname === "/api/agent") {
252971
+ await this.handleAgentAction(req, res, options);
252972
+ return;
252973
+ }
252270
252974
  if (req.method === "POST" && url.pathname === "/api/cancel") {
252271
252975
  await this.handleCancel(req, res, options);
252272
252976
  return;
@@ -252361,6 +253065,25 @@ var OrbitWebUiRuntime = class {
252361
253065
  });
252362
253066
  }
252363
253067
  }
253068
+ async handleAgentAction(req, res, options) {
253069
+ if (!options.controlAgent) {
253070
+ sendJson(res, 409, {
253071
+ ok: false,
253072
+ message: "Agent controls are not available."
253073
+ });
253074
+ return;
253075
+ }
253076
+ try {
253077
+ const action = AgentActionSchema.parse(await readJsonBody(req));
253078
+ const result = sanitizeActionResult(await options.controlAgent(action));
253079
+ sendJson(res, result.ok ? 200 : 409, result);
253080
+ } catch (error) {
253081
+ sendJson(res, webRequestErrorStatus(error), {
253082
+ ok: false,
253083
+ message: safeWebMessage(error)
253084
+ });
253085
+ }
253086
+ }
252364
253087
  async handleApproval(req, res, options) {
252365
253088
  if (!options.respondToApproval) {
252366
253089
  sendJson(res, 409, {
@@ -252619,13 +253342,8 @@ var activeRuntime;
252619
253342
  function parseWebUiArgs(rawArgs) {
252620
253343
  const args = rawArgs.split(/\s+/).map((item) => item.trim()).filter(Boolean);
252621
253344
  let port;
252622
- let open = true;
252623
253345
  for (let index = 0; index < args.length; index++) {
252624
253346
  const arg = args[index];
252625
- if (arg === "--no-open") {
252626
- open = false;
252627
- continue;
252628
- }
252629
253347
  if (arg === "--port") {
252630
253348
  const next = args[index + 1];
252631
253349
  if (/^\d+$/.test(next || "")) {
@@ -252646,46 +253364,13 @@ function parseWebUiArgs(rawArgs) {
252646
253364
  }
252647
253365
  }
252648
253366
  }
252649
- return { port, open };
252650
- }
252651
- async function openBrowser(url) {
252652
- const { command, args } = resolveBrowserLaunch(url);
252653
- return new Promise((resolve18) => {
252654
- const child = spawn2(command, args, {
252655
- detached: true,
252656
- stdio: "ignore",
252657
- windowsHide: true
252658
- });
252659
- let settled = false;
252660
- const finish = (opened) => {
252661
- if (settled) return;
252662
- settled = true;
252663
- clearTimeout(timeout);
252664
- resolve18(opened);
252665
- };
252666
- const timeout = setTimeout(() => finish(false), 2e3);
252667
- child.once("spawn", () => finish(true));
252668
- child.once("error", () => finish(false));
252669
- child.unref();
252670
- });
252671
- }
252672
- function resolveBrowserLaunch(url, platform = process.platform) {
252673
- if (platform === "win32") {
252674
- return { command: "explorer.exe", args: [url] };
252675
- }
252676
- return {
252677
- command: platform === "darwin" ? "open" : "xdg-open",
252678
- args: [url]
252679
- };
253367
+ return { port, open: false };
252680
253368
  }
252681
253369
  async function startOrbitWebUi(options) {
252682
253370
  const current = activeRuntime;
252683
253371
  if (current?.canReuse(options.port)) {
252684
253372
  current.updateOptions(options);
252685
- const handle2 = current.getHandle();
252686
- const browserOpened2 = options.open !== false ? await openBrowser(handle2.url) : false;
252687
- handle2.browserOpened = browserOpened2;
252688
- return handle2;
253373
+ return current.getHandle();
252689
253374
  }
252690
253375
  if (current?.hasActiveTurn) {
252691
253376
  throw new Error(
@@ -252699,8 +253384,6 @@ async function startOrbitWebUi(options) {
252699
253384
  const runtime = new OrbitWebUiRuntime(options);
252700
253385
  const handle = await runtime.start();
252701
253386
  activeRuntime = runtime;
252702
- const browserOpened = options.open !== false ? await openBrowser(handle.url) : false;
252703
- handle.browserOpened = browserOpened;
252704
253387
  return handle;
252705
253388
  }
252706
253389
  async function stopOrbitWebUi() {
@@ -252903,7 +253586,7 @@ Running shell command: ${shellCommand}...`)
252903
253586
  import picocolors11 from "picocolors";
252904
253587
 
252905
253588
  // src/runtime/ConfigObjectPath.ts
252906
- function isRecord5(value) {
253589
+ function isRecord6(value) {
252907
253590
  return typeof value === "object" && value !== null && !Array.isArray(value);
252908
253591
  }
252909
253592
  var blockedSegments = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
@@ -252919,7 +253602,7 @@ function getNestedProperty(root, path6) {
252919
253602
  if (!parts) return void 0;
252920
253603
  let current = root;
252921
253604
  for (const part of parts) {
252922
- if (!isRecord5(current) || !Object.hasOwn(current, part)) return void 0;
253605
+ if (!isRecord6(current) || !Object.hasOwn(current, part)) return void 0;
252923
253606
  current = current[part];
252924
253607
  }
252925
253608
  return current;
@@ -252930,7 +253613,7 @@ function setNestedProperty(root, path6, value) {
252930
253613
  let current = root;
252931
253614
  for (const part of parts.slice(0, -1)) {
252932
253615
  const child = current[part];
252933
- if (!isRecord5(child)) {
253616
+ if (!isRecord6(child)) {
252934
253617
  current[part] = {};
252935
253618
  }
252936
253619
  current = current[part];
@@ -253215,7 +253898,7 @@ function wildcardExpression(pattern) {
253215
253898
  const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "__DOUBLE_STAR__").replace(/\*/g, "[^/]*").replace(/__DOUBLE_STAR__\/?/g, "(?:|.*/)");
253216
253899
  return new RegExp(`^${escaped}$`, "i");
253217
253900
  }
253218
- function errorMessage2(error) {
253901
+ function errorMessage3(error) {
253219
253902
  return error instanceof Error ? error.message : String(error);
253220
253903
  }
253221
253904
  function addContextFile(loop, path6, readOnly, reason) {
@@ -253280,7 +253963,7 @@ async function handleInteractiveAdd(readOnly, dependencies, candidateFiles) {
253280
253963
  );
253281
253964
  } catch (error) {
253282
253965
  printOutput(
253283
- isZh ? picocolors12.red(`\u9009\u62E9\u6587\u4EF6\u5931\u8D25: ${errorMessage2(error)}`) : picocolors12.red(`Failed to select files: ${errorMessage2(error)}`)
253966
+ isZh ? picocolors12.red(`\u9009\u62E9\u6587\u4EF6\u5931\u8D25: ${errorMessage3(error)}`) : picocolors12.red(`Failed to select files: ${errorMessage3(error)}`)
253284
253967
  );
253285
253968
  } finally {
253286
253969
  tui.syncFromLoop(loop);
@@ -253330,7 +254013,7 @@ async function handleAdd(argument, dependencies) {
253330
254013
  } catch (error) {
253331
254014
  printOutput(
253332
254015
  picocolors12.red(
253333
- isZh ? `\u8DEF\u5F84\u5DF2\u88AB\u5B89\u5168\u7B56\u7565\u963B\u6B62: ${errorMessage2(error)}` : `Path blocked by workspace safety policy: ${errorMessage2(error)}`
254016
+ isZh ? `\u8DEF\u5F84\u5DF2\u88AB\u5B89\u5168\u7B56\u7565\u963B\u6B62: ${errorMessage3(error)}` : `Path blocked by workspace safety policy: ${errorMessage3(error)}`
253334
254017
  )
253335
254018
  );
253336
254019
  return HANDLED_COMMAND;
@@ -253411,7 +254094,7 @@ ${matched.map((file) => ` \u2022 ${file}`).join("\n")}`
253411
254094
  tui.syncFromLoop(loop);
253412
254095
  } catch (error) {
253413
254096
  printOutput(
253414
- isZh ? picocolors12.red(`\u6DFB\u52A0\u5931\u8D25: ${errorMessage2(error)}`) : picocolors12.red(`Failed to add: ${errorMessage2(error)}`)
254097
+ isZh ? picocolors12.red(`\u6DFB\u52A0\u5931\u8D25: ${errorMessage3(error)}`) : picocolors12.red(`Failed to add: ${errorMessage3(error)}`)
253415
254098
  );
253416
254099
  }
253417
254100
  return HANDLED_COMMAND;
@@ -253447,7 +254130,7 @@ async function handleDrop(argument, dependencies) {
253447
254130
  }
253448
254131
  } catch (error) {
253449
254132
  printOutput(
253450
- isZh ? picocolors12.red(`\u79FB\u9664\u6587\u4EF6\u5931\u8D25: ${errorMessage2(error)}`) : picocolors12.red(`Failed to remove files: ${errorMessage2(error)}`)
254133
+ isZh ? picocolors12.red(`\u79FB\u9664\u6587\u4EF6\u5931\u8D25: ${errorMessage3(error)}`) : picocolors12.red(`Failed to remove files: ${errorMessage3(error)}`)
253451
254134
  );
253452
254135
  } finally {
253453
254136
  tui.syncFromLoop(loop);
@@ -253511,7 +254194,7 @@ async function handleCompact(dependencies) {
253511
254194
  } catch (error) {
253512
254195
  printOutput(
253513
254196
  picocolors12.red(
253514
- isZh ? `\u2716 \u4E0A\u4E0B\u6587\u538B\u7F29\u5931\u8D25\uFF1A${errorMessage2(error)}` : `\u2716 Context compaction failed: ${errorMessage2(error)}`
254197
+ isZh ? `\u2716 \u4E0A\u4E0B\u6587\u538B\u7F29\u5931\u8D25\uFF1A${errorMessage3(error)}` : `\u2716 Context compaction failed: ${errorMessage3(error)}`
253515
254198
  )
253516
254199
  );
253517
254200
  } finally {
@@ -253540,9 +254223,9 @@ async function handleContextCommand(command, argument, dependencies) {
253540
254223
  import { execFileSync as execFileSync5 } from "child_process";
253541
254224
  import { existsSync as existsSync19, rmSync as rmSync5 } from "fs";
253542
254225
  import picocolors13 from "picocolors";
253543
- import { z as z40 } from "zod";
253544
- var GitStatusCodeSchema = z40.string().length(2).regex(/^[ MADRCU?!]{2}$/);
253545
- var GitStatusPathSchema = z40.string().min(1).max(32768);
254226
+ import { z as z41 } from "zod";
254227
+ var GitStatusCodeSchema = z41.string().length(2).regex(/^[ MADRCU?!]{2}$/);
254228
+ var GitStatusPathSchema = z41.string().min(1).max(32768);
253546
254229
  var defaultGitAdapter = {
253547
254230
  status: (cwd) => execFileSync5("git", ["status", "--porcelain=v1", "-z"], {
253548
254231
  cwd,
@@ -254040,32 +254723,32 @@ function ensureSessionTitle(loop, prompt) {
254040
254723
  }
254041
254724
 
254042
254725
  // src/runtime/ModelDiscovery.ts
254043
- import { z as z41 } from "zod";
254044
- var ModelEntrySchema = z41.object({
254045
- id: z41.unknown().optional(),
254046
- model: z41.unknown().optional(),
254047
- context_length: z41.unknown().optional(),
254048
- context_window: z41.unknown().optional(),
254049
- max_context_tokens: z41.unknown().optional(),
254050
- max_output_tokens: z41.unknown().optional(),
254051
- input_modalities: z41.unknown().optional(),
254052
- output_modalities: z41.unknown().optional(),
254053
- modalities: z41.unknown().optional(),
254054
- architecture: z41.unknown().optional(),
254055
- capabilities: z41.unknown().optional(),
254056
- supported_parameters: z41.unknown().optional(),
254057
- type: z41.unknown().optional(),
254058
- kind: z41.unknown().optional(),
254059
- task: z41.unknown().optional(),
254060
- endpoint: z41.unknown().optional(),
254061
- details: z41.unknown().optional()
254726
+ import { z as z45 } from "zod";
254727
+ var ModelEntrySchema = z45.object({
254728
+ id: z45.unknown().optional(),
254729
+ model: z45.unknown().optional(),
254730
+ context_length: z45.unknown().optional(),
254731
+ context_window: z45.unknown().optional(),
254732
+ max_context_tokens: z45.unknown().optional(),
254733
+ max_output_tokens: z45.unknown().optional(),
254734
+ input_modalities: z45.unknown().optional(),
254735
+ output_modalities: z45.unknown().optional(),
254736
+ modalities: z45.unknown().optional(),
254737
+ architecture: z45.unknown().optional(),
254738
+ capabilities: z45.unknown().optional(),
254739
+ supported_parameters: z45.unknown().optional(),
254740
+ type: z45.unknown().optional(),
254741
+ kind: z45.unknown().optional(),
254742
+ task: z45.unknown().optional(),
254743
+ endpoint: z45.unknown().optional(),
254744
+ details: z45.unknown().optional()
254062
254745
  }).passthrough();
254063
- var ModelListSchema = z41.union([
254064
- z41.object({ data: z41.array(ModelEntrySchema).max(1e3) }),
254065
- z41.object({ models: z41.array(ModelEntrySchema).max(1e3) }),
254066
- z41.array(ModelEntrySchema).max(1e3)
254746
+ var ModelListSchema = z45.union([
254747
+ z45.object({ data: z45.array(ModelEntrySchema).max(1e3) }),
254748
+ z45.object({ models: z45.array(ModelEntrySchema).max(1e3) }),
254749
+ z45.array(ModelEntrySchema).max(1e3)
254067
254750
  ]);
254068
- var DiscoveryUrlSchema = z41.string().url().max(4096).transform((value) => new URL(value));
254751
+ var DiscoveryUrlSchema = z45.string().url().max(4096).transform((value) => new URL(value));
254069
254752
  var MAX_MODEL_RESPONSE_BYTES = 2 * 1024 * 1024;
254070
254753
  async function discoverProviderModels(options) {
254071
254754
  const base = DiscoveryUrlSchema.parse(options.baseUrl.trim());
@@ -254232,9 +254915,9 @@ function normalizeModelEntries(entries) {
254232
254915
  }
254233
254916
  return { models, modelCapabilities };
254234
254917
  }
254235
- var OllamaShowSchema = z41.object({
254236
- capabilities: z41.array(z41.string().max(128)).max(64).optional(),
254237
- model_info: z41.record(z41.unknown()).optional()
254918
+ var OllamaShowSchema = z45.object({
254919
+ capabilities: z45.array(z45.string().max(128)).max(64).optional(),
254920
+ model_info: z45.record(z45.unknown()).optional()
254238
254921
  }).passthrough();
254239
254922
  async function enrichOllamaCapabilities(base, models, target, fetchImpl, signal) {
254240
254923
  const endpoint = new URL(base);
@@ -254371,7 +255054,7 @@ function copyBooleanCapability(source, sourceKey, target, targetKey) {
254371
255054
  }
254372
255055
 
254373
255056
  // src/runtime/ProjectLauncher.ts
254374
- import { spawn as spawn3 } from "child_process";
255057
+ import { spawn as spawn2 } from "child_process";
254375
255058
  import { existsSync as existsSync20, mkdirSync as mkdirSync12, realpathSync as realpathSync3, statSync as statSync6 } from "fs";
254376
255059
  import { isAbsolute as isAbsolute6, parse as parse4, resolve as resolve9 } from "path";
254377
255060
  function launchOrbitProject(request, options = {}) {
@@ -254395,7 +255078,7 @@ function launchOrbitProject(request, options = {}) {
254395
255078
  (options.registry || new ProjectRegistry()).register(projectPath);
254396
255079
  const entryPoint = options.entryPoint || process.argv[1];
254397
255080
  if (!entryPoint) throw new Error("Orbit CLI entry point is unavailable.");
254398
- const launch = options.launch || spawn3;
255081
+ const launch = options.launch || spawn2;
254399
255082
  const child = launch(
254400
255083
  options.executable || process.execPath,
254401
255084
  [entryPoint, "webui", "--cwd", projectPath],
@@ -254481,9 +255164,9 @@ function isPickerCancellation(error) {
254481
255164
 
254482
255165
  // src/runtime/commands/SessionMetadataCommandHandler.ts
254483
255166
  import picocolors15 from "picocolors";
254484
- import { z as z45 } from "zod";
254485
- var GoalSchema = z45.string().trim().min(1).max(4e3);
254486
- var SessionTitleSchema = z45.string().trim().min(1).max(160);
255167
+ import { z as z46 } from "zod";
255168
+ var GoalSchema = z46.string().trim().min(1).max(4e3);
255169
+ var SessionTitleSchema = z46.string().trim().min(1).max(160);
254487
255170
  function handleSessionMetadataCommand(command, argument, dependencies) {
254488
255171
  if (command === "/goal") {
254489
255172
  handleGoal(argument, dependencies);
@@ -254548,9 +255231,9 @@ function handleRename(argument, { loop, isZh, printOutput }) {
254548
255231
 
254549
255232
  // src/runtime/commands/WorkspaceStateCommandHandler.ts
254550
255233
  import picocolors16 from "picocolors";
254551
- import { z as z46 } from "zod";
254552
- var TextSchema = z46.string().trim().min(1).max(2e3);
254553
- var ItemReferenceSchema = z46.string().trim().min(1).max(100);
255234
+ import { z as z47 } from "zod";
255235
+ var TextSchema = z47.string().trim().min(1).max(2e3);
255236
+ var ItemReferenceSchema = z47.string().trim().min(1).max(100);
254554
255237
  function handleWorkspaceStateCommand(command, argument, dependencies) {
254555
255238
  if (command === "/memory") {
254556
255239
  handleMemory(argument, dependencies);
@@ -254726,11 +255409,11 @@ function resolveItemId(reference, items) {
254726
255409
  // src/commands/update.ts
254727
255410
  import readline4 from "readline";
254728
255411
  import picocolors17 from "picocolors";
254729
- import { z as z47 } from "zod";
254730
- var UpdateCommandOptionsSchema = z47.object({
254731
- check: z47.boolean().default(false),
254732
- yes: z47.boolean().default(false),
254733
- json: z47.boolean().default(false),
255412
+ import { z as z48 } from "zod";
255413
+ var UpdateCommandOptionsSchema = z48.object({
255414
+ check: z48.boolean().default(false),
255415
+ yes: z48.boolean().default(false),
255416
+ json: z48.boolean().default(false),
254734
255417
  channel: UpdateChannelSchema.default("stable")
254735
255418
  }).strict();
254736
255419
  async function runUpdate(currentVersion, rawOptions, dependencies = {}) {
@@ -254862,12 +255545,98 @@ async function confirmUpdate(prompt) {
254862
255545
  }
254863
255546
  }
254864
255547
 
255548
+ // src/runtime/review/ReviewCommand.ts
255549
+ import { z as z49 } from "zod";
255550
+ var ReviewPresetSchema = z49.enum([
255551
+ "comprehensive",
255552
+ "security",
255553
+ "tests",
255554
+ "performance",
255555
+ "accessibility"
255556
+ ]);
255557
+ var ReviewScopeSchema = z49.discriminatedUnion("kind", [
255558
+ z49.object({ kind: z49.literal("working-tree") }),
255559
+ z49.object({ kind: z49.literal("commit"), ref: z49.string().min(1).max(200) }),
255560
+ z49.object({ kind: z49.literal("branch"), ref: z49.string().min(1).max(200) })
255561
+ ]);
255562
+ var SAFE_GIT_REF = /^[A-Za-z0-9][A-Za-z0-9._/@{}~^:+-]{0,199}$/;
255563
+ function parseReviewCommand(rawArguments) {
255564
+ const input = rawArguments.trim();
255565
+ if (!input) {
255566
+ return {
255567
+ preset: "comprehensive",
255568
+ scope: { kind: "working-tree" }
255569
+ };
255570
+ }
255571
+ const [first = "", ...rest] = input.split(/\s+/);
255572
+ const preset = ReviewPresetSchema.safeParse(first);
255573
+ if (preset.success) {
255574
+ return {
255575
+ preset: preset.data,
255576
+ scope: { kind: "working-tree" }
255577
+ };
255578
+ }
255579
+ if (first === "commit" || first === "branch") {
255580
+ const ref = rest.shift() || "";
255581
+ if (!SAFE_GIT_REF.test(ref)) {
255582
+ throw new Error(
255583
+ "Review refs may only contain standard Git ref characters."
255584
+ );
255585
+ }
255586
+ const requestedPreset = rest.shift() || "comprehensive";
255587
+ if (rest.length > 0) {
255588
+ throw new Error("Too many /review arguments.");
255589
+ }
255590
+ return {
255591
+ preset: ReviewPresetSchema.parse(requestedPreset),
255592
+ scope: ReviewScopeSchema.parse({ kind: first, ref })
255593
+ };
255594
+ }
255595
+ if (first === "custom") {
255596
+ const customInstructions = input.slice("custom".length).trim();
255597
+ if (!customInstructions || customInstructions.length > 4e3) {
255598
+ throw new Error(
255599
+ "Custom review instructions must contain 1 to 4000 characters."
255600
+ );
255601
+ }
255602
+ return {
255603
+ preset: "comprehensive",
255604
+ scope: { kind: "working-tree" },
255605
+ customInstructions
255606
+ };
255607
+ }
255608
+ throw new Error(
255609
+ "Usage: /review [comprehensive|security|tests|performance|accessibility|commit <ref> [preset]|branch <ref> [preset]|custom <instructions>]"
255610
+ );
255611
+ }
255612
+ function buildReviewPrompt(request) {
255613
+ const scope = request.scope.kind === "working-tree" ? "the current uncommitted working tree against HEAD" : request.scope.kind === "commit" ? `commit ${request.scope.ref}` : `the current branch against ${request.scope.ref}`;
255614
+ const focus = {
255615
+ comprehensive: "correctness, security, regressions, tests, maintainability, performance, and accessibility where applicable",
255616
+ security: "exploitable security defects, unsafe trust boundaries, credential exposure, path traversal, injection, and permission bypasses",
255617
+ tests: "missing coverage, false-positive tests, flaky behavior, unverified failure paths, and release-contract gaps",
255618
+ performance: "startup latency, repeated I/O, memory growth, hot-loop work, cache invalidation, and avoidable serialization",
255619
+ accessibility: "keyboard navigation, focus management, semantic roles, readable status announcements, contrast assumptions, and responsive interaction"
255620
+ };
255621
+ const custom2 = request.customInstructions ? `
255622
+ Additional review policy:
255623
+ ${request.customInstructions}` : "";
255624
+ return [
255625
+ `Perform a dedicated ${request.preset} code review of ${scope}.`,
255626
+ `Prioritize ${focus[request.preset]}.`,
255627
+ "Inspect the relevant diff and surrounding code before reaching conclusions.",
255628
+ "Report only actionable findings. For each finding include severity (P0-P3), file and line, evidence, impact, and a precise remediation.",
255629
+ "Then provide a concise verification plan. Do not modify files unless the user explicitly asks for fixes.",
255630
+ custom2
255631
+ ].filter(Boolean).join("\n");
255632
+ }
255633
+
254865
255634
  // src/runtime/CommandRouter.ts
254866
255635
  var require2 = createRequire2(import.meta.url);
254867
255636
  function stripAnsi4(value) {
254868
255637
  return value.replace(/\u001b\[[0-9;]*m/g, "");
254869
255638
  }
254870
- function terminalHyperlink(label, url) {
255639
+ function terminalHyperlink2(label, url) {
254871
255640
  return `\x1B]8;;${url}\x07${label}\x1B]8;;\x07`;
254872
255641
  }
254873
255642
  var CommandRouter = class {
@@ -254942,6 +255711,23 @@ var CommandRouter = class {
254942
255711
  );
254943
255712
  }
254944
255713
  }
255714
+ if (/^\/review(?:\s|$)/i.test(trimmed)) {
255715
+ try {
255716
+ const rawArguments = trimmed.replace(/^\/review\b/i, "").trim();
255717
+ const request = parseReviewCommand(rawArguments);
255718
+ trimmed = buildReviewPrompt(request);
255719
+ tui.addLog(
255720
+ config.language === "zh" ? `\u5DF2\u542F\u52A8 ${request.preset} \u4EE3\u7801\u5BA1\u67E5` : `Started ${request.preset} code review`
255721
+ );
255722
+ } catch (error) {
255723
+ this.printOutput(
255724
+ picocolors18.red(
255725
+ `\u2716 ${error instanceof Error ? error.message : String(error)}`
255726
+ )
255727
+ );
255728
+ return { shouldExit: false, processed: true };
255729
+ }
255730
+ }
254945
255731
  const shellResult = await handleShellCommand(trimmed, {
254946
255732
  cwd,
254947
255733
  config,
@@ -255011,7 +255797,7 @@ var CommandRouter = class {
255011
255797
  }
255012
255798
  if (command === "/webui") {
255013
255799
  const isZh = config.language === "zh";
255014
- const { port, open } = parseWebUiArgs(parts.slice(1).join(" "));
255800
+ const { port } = parseWebUiArgs(parts.slice(1).join(" "));
255015
255801
  try {
255016
255802
  await this.refreshProviderModels(config.provider.default);
255017
255803
  const handle = await startOrbitWebUi({
@@ -255019,8 +255805,8 @@ var CommandRouter = class {
255019
255805
  config,
255020
255806
  loop,
255021
255807
  port,
255022
- open,
255023
255808
  getProjects: () => new ProjectRegistry().list().slice(0, 20),
255809
+ getAgentRuns: () => new AgentRunStore(cwd).listRuns(12),
255024
255810
  submitPrompt: (prompt, attachments) => this.submitWebPrompt(prompt, attachments),
255025
255811
  cancelPrompt: () => this.cancelWebPrompt(),
255026
255812
  updateSettings: (patch) => this.updateWebUiSettings(patch),
@@ -255041,6 +255827,16 @@ var CommandRouter = class {
255041
255827
  message: ok ? `Restored ${action.path}.` : `No restorable checkpoint was found for ${action.path}.`
255042
255828
  };
255043
255829
  },
255830
+ controlAgent: (action) => {
255831
+ const runnable = this.webUiRunnable;
255832
+ if (action.action === "abort" && runnable instanceof Orchestrator && runnable.abortAgent(action.agentId)) {
255833
+ return { ok: true, message: "Agent cancellation requested." };
255834
+ }
255835
+ return {
255836
+ ok: false,
255837
+ message: "The selected agent is no longer running."
255838
+ };
255839
+ },
255044
255840
  exportTrace: (includeHistory) => loop.exportSessionTrace(includeHistory),
255045
255841
  openProject: async (action) => {
255046
255842
  if (action.action === "pick") {
@@ -255065,20 +255861,20 @@ var CommandRouter = class {
255065
255861
  });
255066
255862
  const displayUrl = new URL(handle.url);
255067
255863
  displayUrl.hash = "";
255068
- const browserOpened = handle.browserOpened === true;
255069
- const statusText = browserOpened ? isZh ? "\u2714 Orbit Web UI \u5DF2\u542F\u52A8\u5E76\u81EA\u52A8\u6253\u5F00\u6D4F\u89C8\u5668" : "\u2714 Orbit Web UI started and opened in your browser" : isZh ? "\u26A0\uFE0F Orbit Web UI \u5DF2\u542F\u52A8\uFF1B\u6D4F\u89C8\u5668\u672A\u80FD\u81EA\u52A8\u6253\u5F00" : "\u26A0\uFE0F Orbit Web UI started; the browser did not open automatically";
255070
- const linkLabel = isZh ? `\u6253\u5F00 Web UI \xB7 ${displayUrl.href}` : `Open Web UI \xB7 ${displayUrl.href}`;
255864
+ const statusText = isZh ? "\u2714 Orbit Web UI \u5DF2\u542F\u52A8" : "\u2714 Orbit Web UI started";
255071
255865
  if (this.tui?.isActive) {
255072
- this.tui.addSystemMessage(
255073
- browserOpened ? picocolors18.green(statusText) : picocolors18.yellow(statusText)
255074
- );
255075
- this.tui.setPinnedNotice(linkLabel, handle.url);
255866
+ this.tui.addSystemMessage(picocolors18.green(statusText), false, {
255867
+ label: displayUrl.href,
255868
+ url: handle.url
255869
+ });
255076
255870
  } else {
255077
255871
  console.log(
255078
- browserOpened ? picocolors18.green(statusText) : picocolors18.yellow(statusText)
255079
- );
255080
- console.log(
255081
- ` ${terminalHyperlink(picocolors18.cyan(linkLabel), handle.url)}`
255872
+ [
255873
+ picocolors18.green("\u2714"),
255874
+ terminalHyperlink2(picocolors18.cyan(displayUrl.href), handle.url),
255875
+ picocolors18.dim("\xB7"),
255876
+ picocolors18.green(statusText.substring(1).trim())
255877
+ ].join(" ")
255082
255878
  );
255083
255879
  }
255084
255880
  eventBus.emitEvent("info", {
@@ -255086,7 +255882,6 @@ var CommandRouter = class {
255086
255882
  });
255087
255883
  } catch (error) {
255088
255884
  const message = error instanceof Error ? error.message : String(error);
255089
- this.tui?.setPinnedNotice?.(null);
255090
255885
  this.printOutput(
255091
255886
  isZh ? picocolors18.red(`\u2716 \u65E0\u6CD5\u542F\u52A8 Orbit Web UI: ${message}`) : picocolors18.red(`\u2716 Failed to start Orbit Web UI: ${message}`)
255092
255887
  );
@@ -255935,20 +256730,20 @@ ${picocolors18.green("\u2714")} Switched security mode to: ${picocolors18.green(
255935
256730
  };
255936
256731
 
255937
256732
  // src/runtime/ReplController.ts
255938
- var AutocompleteRequestSchema = z48.object({
255939
- prefix: z48.string().max(2e4),
255940
- suffix: z48.string().max(2e4),
255941
- windowId: z48.string().max(1e3).optional()
256733
+ var AutocompleteRequestSchema = z50.object({
256734
+ prefix: z50.string().max(2e4),
256735
+ suffix: z50.string().max(2e4),
256736
+ windowId: z50.string().max(1e3).optional()
255942
256737
  });
255943
256738
  var AUTOCOMPLETE_BODY_LIMIT_BYTES = 1e5;
255944
256739
  var AUTOCOMPLETE_MAX_CONCURRENCY = 4;
255945
- var LocalStateSchema = z48.object({
255946
- lastSessionId: z48.string().optional(),
255947
- lastModel: z48.string().optional()
256740
+ var LocalStateSchema = z50.object({
256741
+ lastSessionId: z50.string().optional(),
256742
+ lastModel: z50.string().optional()
255948
256743
  });
255949
- var AutocompleteEndpointSchema = z48.object({
255950
- port: z48.number().int().min(1).max(65535),
255951
- token: z48.string().min(32).max(256)
256744
+ var AutocompleteEndpointSchema = z50.object({
256745
+ port: z50.number().int().min(1).max(65535),
256746
+ token: z50.string().min(32).max(256)
255952
256747
  });
255953
256748
  function getRunOutcomeMessage(outcome) {
255954
256749
  if (!outcome || outcome.status === "completed") return void 0;
@@ -256321,8 +257116,7 @@ Risk Warning: ${reason}`);
256321
257116
  if (this.webUiOnly) {
256322
257117
  const command = [
256323
257118
  "/webui",
256324
- this.webUiOnly.port !== void 0 ? `--port ${this.webUiOnly.port}` : "",
256325
- this.webUiOnly.open ? "" : "--no-open"
257119
+ this.webUiOnly.port !== void 0 ? `--port ${this.webUiOnly.port}` : ""
256326
257120
  ].filter(Boolean).join(" ");
256327
257121
  const result = await commandRouter.route(command);
256328
257122
  if (!result.processed) {
@@ -256760,7 +257554,7 @@ function configureJsonlOutput() {
256760
257554
  schemaVersion: ORBIT_EVENT_SCHEMA_VERSION,
256761
257555
  sequence: ++sequence,
256762
257556
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
256763
- ...isRecord6(sanitized) ? sanitized : { type: "unknown", payload: {} }
257557
+ ...isRecord7(sanitized) ? sanitized : { type: "unknown", payload: {} }
256764
257558
  })
256765
257559
  );
256766
257560
  };
@@ -256774,8 +257568,8 @@ function configureJsonlOutput() {
256774
257568
  };
256775
257569
  }
256776
257570
  function sanitizeJsonlEvent(event) {
256777
- if (!isRecord6(event) || typeof event.type !== "string") return {};
256778
- const payload = isRecord6(event.payload) ? event.payload : {};
257571
+ if (!isRecord7(event) || typeof event.type !== "string") return {};
257572
+ const payload = isRecord7(event.payload) ? event.payload : {};
256779
257573
  const metadata = {
256780
257574
  ...typeof event.eventId === "string" ? { eventId: event.eventId } : {},
256781
257575
  ...typeof event.timestamp === "string" ? { timestamp: event.timestamp } : {}
@@ -256820,46 +257614,46 @@ function sanitizeJsonlEvent(event) {
256820
257614
  function redactJsonValue(value) {
256821
257615
  if (typeof value === "string") return redactSecrets(value);
256822
257616
  if (Array.isArray(value)) return value.map(redactJsonValue);
256823
- if (!isRecord6(value)) return value;
257617
+ if (!isRecord7(value)) return value;
256824
257618
  return Object.fromEntries(
256825
257619
  Object.entries(value).map(([key, item]) => [key, redactJsonValue(item)])
256826
257620
  );
256827
257621
  }
256828
- function isRecord6(value) {
257622
+ function isRecord7(value) {
256829
257623
  return typeof value === "object" && value !== null;
256830
257624
  }
256831
257625
 
256832
257626
  // src/commands/LSPServer.ts
256833
- import { z as z49 } from "zod";
257627
+ import { z as z51 } from "zod";
256834
257628
  var MAX_LSP_HEADER_BYTES = 8 * 1024;
256835
257629
  var MAX_LSP_BODY_BYTES = 8 * 1024 * 1024;
256836
- var JsonRpcIdSchema = z49.union([z49.string(), z49.number(), z49.null()]);
256837
- var JSONRPCMessageSchema = z49.object({
256838
- jsonrpc: z49.literal("2.0"),
257630
+ var JsonRpcIdSchema = z51.union([z51.string(), z51.number(), z51.null()]);
257631
+ var JSONRPCMessageSchema = z51.object({
257632
+ jsonrpc: z51.literal("2.0"),
256839
257633
  id: JsonRpcIdSchema.optional(),
256840
- method: z49.string().min(1).max(512),
256841
- params: z49.unknown().optional()
257634
+ method: z51.string().min(1).max(512),
257635
+ params: z51.unknown().optional()
256842
257636
  }).strict();
256843
- var TextDocumentIdentifierSchema = z49.object({
256844
- uri: z49.string().min(1).max(16384)
257637
+ var TextDocumentIdentifierSchema = z51.object({
257638
+ uri: z51.string().min(1).max(16384)
256845
257639
  });
256846
- var DidOpenParamsSchema = z49.object({
257640
+ var DidOpenParamsSchema = z51.object({
256847
257641
  textDocument: TextDocumentIdentifierSchema.extend({
256848
- text: z49.string().max(MAX_LSP_BODY_BYTES)
257642
+ text: z51.string().max(MAX_LSP_BODY_BYTES)
256849
257643
  }).passthrough()
256850
257644
  });
256851
- var DidChangeParamsSchema = z49.object({
257645
+ var DidChangeParamsSchema = z51.object({
256852
257646
  textDocument: TextDocumentIdentifierSchema,
256853
- contentChanges: z49.array(z49.object({ text: z49.string().max(MAX_LSP_BODY_BYTES) }).passthrough()).min(1).max(100)
257647
+ contentChanges: z51.array(z51.object({ text: z51.string().max(MAX_LSP_BODY_BYTES) }).passthrough()).min(1).max(100)
256854
257648
  });
256855
- var DidCloseParamsSchema = z49.object({
257649
+ var DidCloseParamsSchema = z51.object({
256856
257650
  textDocument: TextDocumentIdentifierSchema
256857
257651
  });
256858
- var CompletionParamsSchema = z49.object({
257652
+ var CompletionParamsSchema = z51.object({
256859
257653
  textDocument: TextDocumentIdentifierSchema,
256860
- position: z49.object({
256861
- line: z49.number().int().nonnegative(),
256862
- character: z49.number().int().nonnegative()
257654
+ position: z51.object({
257655
+ line: z51.number().int().nonnegative(),
257656
+ character: z51.number().int().nonnegative()
256863
257657
  })
256864
257658
  });
256865
257659
  var JSONRPCReader = class {
@@ -257105,7 +257899,7 @@ ${completion}
257105
257899
  );
257106
257900
  }
257107
257901
  } catch (error) {
257108
- if (error instanceof z49.ZodError) {
257902
+ if (error instanceof z51.ZodError) {
257109
257903
  sendError(message.id, -32602, "Invalid method parameters.");
257110
257904
  return;
257111
257905
  }
@@ -257478,10 +258272,10 @@ import {
257478
258272
  writeFileSync as writeFileSync13
257479
258273
  } from "fs";
257480
258274
  import { dirname as dirname11, resolve as resolve11 } from "path";
257481
- import { z as z50 } from "zod";
257482
- var TraceOptionsSchema = z50.object({
257483
- full: z50.boolean().default(false),
257484
- out: z50.string().trim().min(1).max(4096).optional()
258275
+ import { z as z54 } from "zod";
258276
+ var TraceOptionsSchema = z54.object({
258277
+ full: z54.boolean().default(false),
258278
+ out: z54.string().trim().min(1).max(4096).optional()
257485
258279
  });
257486
258280
  function runTraceExport(cwd, sessionId, options = {}) {
257487
258281
  const value = TraceOptionsSchema.parse(options);
@@ -257536,16 +258330,16 @@ import { basename as basename6, dirname as dirname12, join as join19 } from "pat
257536
258330
  import { promisify as promisify5 } from "util";
257537
258331
  import picocolors23 from "picocolors";
257538
258332
  import { parse as parseYaml3 } from "yaml";
257539
- import { z as z51 } from "zod";
258333
+ import { z as z55 } from "zod";
257540
258334
  var exec4 = promisify5(execCallback);
257541
258335
  var MAX_SUITE_BYTES = 1024 * 1024;
257542
258336
  var MAX_VERIFICATION_OUTPUT = 4e3;
257543
- var EvalOptionsSchema = z51.object({
257544
- provider: z51.string().trim().min(1).optional(),
257545
- model: z51.string().trim().min(1).optional(),
257546
- task: z51.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/).optional(),
257547
- allowCommands: z51.boolean().default(false),
257548
- json: z51.boolean().default(false)
258337
+ var EvalOptionsSchema = z55.object({
258338
+ provider: z55.string().trim().min(1).optional(),
258339
+ model: z55.string().trim().min(1).optional(),
258340
+ task: z55.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/).optional(),
258341
+ allowCommands: z55.boolean().default(false),
258342
+ json: z55.boolean().default(false)
257549
258343
  });
257550
258344
  async function runEval(cwd, suiteFile, options = {}) {
257551
258345
  const value = EvalOptionsSchema.parse(options);
@@ -257868,16 +258662,16 @@ function safeSummary(value) {
257868
258662
  import readline6 from "readline";
257869
258663
  import picocolors24 from "picocolors";
257870
258664
  import { resolve as resolve13 } from "path";
257871
- import { z as z55 } from "zod";
258665
+ import { z as z57 } from "zod";
257872
258666
 
257873
258667
  // src/runtime/CleanupManager.ts
257874
258668
  import { lstatSync as lstatSync8, readdirSync as readdirSync8, rmSync as rmSync9 } from "fs";
257875
258669
  import { homedir as homedir11 } from "os";
257876
258670
  import { basename as basename7, join as join20, parse as parse5, resolve as resolve12 } from "path";
257877
- import { z as z54 } from "zod";
257878
- var CleanupScopeSchema = z54.enum(["user", "project"]);
258671
+ import { z as z56 } from "zod";
258672
+ var CleanupScopeSchema = z56.enum(["user", "project"]);
257879
258673
  function buildCleanupPlan(options) {
257880
- const scopes = z54.array(CleanupScopeSchema).min(1).parse(options.scopes);
258674
+ const scopes = z56.array(CleanupScopeSchema).min(1).parse(options.scopes);
257881
258675
  const homeDirectory = resolve12(options.homeDirectory ?? homedir11());
257882
258676
  const projectDirectory = resolve12(options.projectDirectory ?? options.cwd);
257883
258677
  const candidates = scopes.map((scope) => ({
@@ -258000,12 +258794,12 @@ function safeInventoryWarning(targetPath, error) {
258000
258794
  }
258001
258795
 
258002
258796
  // src/commands/clean.ts
258003
- var CleanCommandOptionsSchema = z55.object({
258004
- user: z55.boolean().default(false),
258005
- project: z55.union([z55.boolean(), z55.string().min(1).max(4096)]).optional(),
258006
- all: z55.boolean().default(false),
258007
- yes: z55.boolean().default(false),
258008
- json: z55.boolean().default(false)
258797
+ var CleanCommandOptionsSchema = z57.object({
258798
+ user: z57.boolean().default(false),
258799
+ project: z57.union([z57.boolean(), z57.string().min(1).max(4096)]).optional(),
258800
+ all: z57.boolean().default(false),
258801
+ yes: z57.boolean().default(false),
258802
+ json: z57.boolean().default(false)
258009
258803
  }).strict();
258010
258804
  async function runClean(cwd, rawOptions, dependencies = {}) {
258011
258805
  const options = CleanCommandOptionsSchema.parse(rawOptions);
@@ -258120,7 +258914,7 @@ async function confirmDeletion(prompt) {
258120
258914
  // src/commands/backup.ts
258121
258915
  import { basename as basename8, resolve as resolve15 } from "path";
258122
258916
  import picocolors25 from "picocolors";
258123
- import { z as z57 } from "zod";
258917
+ import { z as z59 } from "zod";
258124
258918
 
258125
258919
  // src/runtime/ProjectBackup.ts
258126
258920
  import {
@@ -258136,23 +258930,23 @@ import {
258136
258930
  } from "fs";
258137
258931
  import { createHash as createHash8, randomUUID as randomUUID10 } from "crypto";
258138
258932
  import { dirname as dirname13, isAbsolute as isAbsolute7, join as join21, relative as relative5, resolve as resolve14, sep as sep2 } from "path";
258139
- import { z as z56 } from "zod";
258933
+ import { z as z58 } from "zod";
258140
258934
  var MAX_BACKUP_BYTES = 64 * 1024 * 1024;
258141
258935
  var MAX_SERIALIZED_BACKUP_BYTES = 96 * 1024 * 1024;
258142
258936
  var MAX_BACKUP_FILES = 1e4;
258143
258937
  var SHA256_PATTERN = /^[a-f0-9]{64}$/;
258144
- var BackupFileSchema = z56.object({
258145
- path: z56.string().min(1).max(4096),
258146
- size: z56.number().int().min(0).max(MAX_BACKUP_BYTES),
258147
- sha256: z56.string().regex(SHA256_PATTERN),
258148
- content: z56.string().max(Math.ceil(MAX_BACKUP_BYTES * 4 / 3) + 8)
258938
+ var BackupFileSchema = z58.object({
258939
+ path: z58.string().min(1).max(4096),
258940
+ size: z58.number().int().min(0).max(MAX_BACKUP_BYTES),
258941
+ sha256: z58.string().regex(SHA256_PATTERN),
258942
+ content: z58.string().max(Math.ceil(MAX_BACKUP_BYTES * 4 / 3) + 8)
258149
258943
  });
258150
- var ProjectBackupBundleSchema = z56.object({
258151
- schemaVersion: z56.literal(1),
258152
- kind: z56.literal("orbit-project-backup"),
258153
- createdAt: z56.string().datetime(),
258154
- sourceName: z56.string().min(1).max(512),
258155
- files: z56.array(BackupFileSchema).max(MAX_BACKUP_FILES)
258944
+ var ProjectBackupBundleSchema = z58.object({
258945
+ schemaVersion: z58.literal(1),
258946
+ kind: z58.literal("orbit-project-backup"),
258947
+ createdAt: z58.string().datetime(),
258948
+ sourceName: z58.string().min(1).max(512),
258949
+ files: z58.array(BackupFileSchema).max(MAX_BACKUP_FILES)
258156
258950
  }).superRefine((bundle, context) => {
258157
258951
  let totalBytes = 0;
258158
258952
  const seen = /* @__PURE__ */ new Set();
@@ -258160,7 +258954,7 @@ var ProjectBackupBundleSchema = z56.object({
258160
258954
  totalBytes += file.size;
258161
258955
  if (totalBytes > MAX_BACKUP_BYTES) {
258162
258956
  context.addIssue({
258163
- code: z56.ZodIssueCode.custom,
258957
+ code: z58.ZodIssueCode.custom,
258164
258958
  message: `Backup exceeds ${MAX_BACKUP_BYTES} bytes.`
258165
258959
  });
258166
258960
  break;
@@ -258168,14 +258962,14 @@ var ProjectBackupBundleSchema = z56.object({
258168
258962
  const normalized = normalizeBundlePath(file.path);
258169
258963
  if (!normalized || normalized !== file.path) {
258170
258964
  context.addIssue({
258171
- code: z56.ZodIssueCode.custom,
258965
+ code: z58.ZodIssueCode.custom,
258172
258966
  message: `Unsafe backup path: ${file.path}`
258173
258967
  });
258174
258968
  continue;
258175
258969
  }
258176
258970
  if (seen.has(normalized.toLowerCase())) {
258177
258971
  context.addIssue({
258178
- code: z56.ZodIssueCode.custom,
258972
+ code: z58.ZodIssueCode.custom,
258179
258973
  message: `Duplicate backup path: ${file.path}`
258180
258974
  });
258181
258975
  }
@@ -258385,9 +259179,9 @@ function formatBytes2(bytes) {
258385
259179
  }
258386
259180
 
258387
259181
  // src/commands/backup.ts
258388
- var BackupOptionsSchema = z57.object({
258389
- output: z57.string().min(1).max(4096).optional(),
258390
- json: z57.boolean().default(false)
259182
+ var BackupOptionsSchema = z59.object({
259183
+ output: z59.string().min(1).max(4096).optional(),
259184
+ json: z59.boolean().default(false)
258391
259185
  }).strict();
258392
259186
  function runBackupCreate(cwd, rawOptions = {}) {
258393
259187
  const options = BackupOptionsSchema.parse(rawOptions);
@@ -258476,7 +259270,7 @@ import picocolors26 from "picocolors";
258476
259270
 
258477
259271
  // src/runtime/ExtensionManager.ts
258478
259272
  import {
258479
- existsSync as existsSync36,
259273
+ existsSync as existsSync37,
258480
259274
  lstatSync as lstatSync10,
258481
259275
  mkdirSync as mkdirSync17,
258482
259276
  readFileSync as readFileSync30,
@@ -258488,20 +259282,20 @@ import {
258488
259282
  import { createHash as createHash9, randomUUID as randomUUID11 } from "crypto";
258489
259283
  import { dirname as dirname14, join as join26, relative as relative6, resolve as resolve16 } from "path";
258490
259284
  import { homedir as homedir12 } from "os";
258491
- import { z as z58 } from "zod";
258492
- var InstalledExtensionSchema2 = z58.object({
258493
- id: z58.string(),
258494
- displayName: z58.string(),
258495
- version: z58.string(),
258496
- digest: z58.string().regex(/^[a-f0-9]{64}$/),
258497
- installedAt: z58.string().datetime(),
258498
- trusted: z58.boolean(),
258499
- path: z58.string(),
258500
- manifestFile: z58.string().default("extension.yaml")
259285
+ import { z as z60 } from "zod";
259286
+ var InstalledExtensionSchema2 = z60.object({
259287
+ id: z60.string(),
259288
+ displayName: z60.string(),
259289
+ version: z60.string(),
259290
+ digest: z60.string().regex(/^[a-f0-9]{64}$/),
259291
+ installedAt: z60.string().datetime(),
259292
+ trusted: z60.boolean(),
259293
+ path: z60.string(),
259294
+ manifestFile: z60.string().default("extension.yaml")
258501
259295
  });
258502
- var ExtensionRegistrySchema2 = z58.object({
258503
- schemaVersion: z58.literal(1),
258504
- extensions: z58.array(InstalledExtensionSchema2).default([])
259296
+ var ExtensionRegistrySchema2 = z60.object({
259297
+ schemaVersion: z60.literal(1),
259298
+ extensions: z60.array(InstalledExtensionSchema2).default([])
258505
259299
  });
258506
259300
  var ExtensionManager = class {
258507
259301
  orbitDir;
@@ -258513,12 +259307,12 @@ var ExtensionManager = class {
258513
259307
  this.registryPath = join26(this.orbitDir, "extensions.json");
258514
259308
  }
258515
259309
  list() {
258516
- if (!existsSync36(this.registryPath)) return [];
259310
+ if (!existsSync37(this.registryPath)) return [];
258517
259311
  try {
258518
259312
  return ExtensionRegistrySchema2.parse(
258519
259313
  JSON.parse(readFileSync30(this.registryPath, "utf8"))
258520
259314
  ).extensions.filter(
258521
- (extension) => this.isManagedExtensionPath(extension) && existsSync36(extension.path) && !lstatSync10(extension.path).isSymbolicLink()
259315
+ (extension) => this.isManagedExtensionPath(extension) && existsSync37(extension.path) && !lstatSync10(extension.path).isSymbolicLink()
258522
259316
  );
258523
259317
  } catch {
258524
259318
  return [];
@@ -258545,7 +259339,7 @@ var ExtensionManager = class {
258545
259339
  try {
258546
259340
  copyDirectorySafely(sourceRoot, staging);
258547
259341
  const digest = hashDirectory2(staging);
258548
- if (existsSync36(target)) rmSync11(target, { recursive: true, force: true });
259342
+ if (existsSync37(target)) rmSync11(target, { recursive: true, force: true });
258549
259343
  renameSync12(staging, target);
258550
259344
  materializePromptContributions(target, manifest, this.orbitDir);
258551
259345
  const installed = {
@@ -258566,7 +259360,7 @@ var ExtensionManager = class {
258566
259360
  this.writeRegistry(registry);
258567
259361
  return installed;
258568
259362
  } finally {
258569
- if (existsSync36(staging))
259363
+ if (existsSync37(staging))
258570
259364
  rmSync11(staging, { recursive: true, force: true });
258571
259365
  }
258572
259366
  }
@@ -258669,7 +259463,7 @@ function validateContributionFiles(root, manifest) {
258669
259463
  `Invalid extension contribution path: ${contribution.path}`
258670
259464
  );
258671
259465
  }
258672
- if (!existsSync36(target) || lstatSync10(target).isSymbolicLink()) {
259466
+ if (!existsSync37(target) || lstatSync10(target).isSymbolicLink()) {
258673
259467
  throw new Error(
258674
259468
  `Extension contribution is missing or unsafe: ${contribution.path}`
258675
259469
  );
@@ -258808,7 +259602,7 @@ function removeExtension(id) {
258808
259602
  }
258809
259603
 
258810
259604
  // src/index.ts
258811
- import { existsSync as existsSync37, realpathSync as realpathSync4, statSync as statSync8 } from "fs";
259605
+ import { existsSync as existsSync38, realpathSync as realpathSync4, statSync as statSync8 } from "fs";
258812
259606
  import { resolve as resolve17 } from "path";
258813
259607
  var program = new Command();
258814
259608
  function applyOutcomeExitCode(outcome) {
@@ -258985,7 +259779,7 @@ program.command("trace").description("export a redacted, versioned session audit
258985
259779
  program.command("lsp").description("start the local LSP autocomplete server").action(async () => {
258986
259780
  await runLSPServer(process.cwd());
258987
259781
  });
258988
- program.command("webui").description("start Orbit as a browser-first local coding workspace").option("--port <port>", "preferred loopback port (default: 6047)").option("--cwd <path>", "open a specific project directory").option("--no-open", "start without opening the default browser").action(async (localOptions, command) => {
259782
+ program.command("webui").description("start Orbit as a browser-first local coding workspace").option("--port <port>", "preferred loopback port (default: 6047)").option("--cwd <path>", "open a specific project directory").addOption(new Option("--no-open").hideHelp()).action(async (localOptions, command) => {
258989
259783
  const options = command.optsWithGlobals();
258990
259784
  const rawPort = localOptions.port;
258991
259785
  const port = rawPort === void 0 ? void 0 : Number(rawPort);
@@ -259003,14 +259797,14 @@ program.command("webui").description("start Orbit as a browser-first local codin
259003
259797
  overrides.permissions = { mode: "auto" };
259004
259798
  }
259005
259799
  const requestedCwd = resolve17(localOptions.cwd || process.cwd());
259006
- if (!existsSync37(requestedCwd) || !statSync8(requestedCwd).isDirectory()) {
259800
+ if (!existsSync38(requestedCwd) || !statSync8(requestedCwd).isDirectory()) {
259007
259801
  throw new Error(
259008
259802
  `Web UI project directory does not exist: ${requestedCwd}`
259009
259803
  );
259010
259804
  }
259011
259805
  const cwd = realpathSync4.native(requestedCwd);
259012
259806
  const outcome = await runAgent(cwd, void 0, overrides, false, {
259013
- webUi: { port, open: localOptions.open !== false }
259807
+ webUi: { port }
259014
259808
  });
259015
259809
  applyOutcomeExitCode(outcome);
259016
259810
  });