@orbit-build/cli 0.5.4 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -242916,10 +242916,7 @@ var DeepSeekAnthropicProvider = class {
242916
242916
  }
242917
242917
  }
242918
242918
  const chatController = new AbortController();
242919
- const chatSignal = chatController.signal;
242920
- const onExternalAbort = () => {
242921
- chatController.abort();
242922
- };
242919
+ const chatSignal = input.abortSignal ? AbortSignal.any([chatController.signal, input.abortSignal]) : chatController.signal;
242923
242920
  if (input.abortSignal) {
242924
242921
  if (input.abortSignal.aborted) {
242925
242922
  yield {
@@ -242931,7 +242928,6 @@ var DeepSeekAnthropicProvider = class {
242931
242928
  };
242932
242929
  return;
242933
242930
  }
242934
- input.abortSignal.addEventListener("abort", onExternalAbort);
242935
242931
  }
242936
242932
  let response;
242937
242933
  try {
@@ -242947,9 +242943,6 @@ var DeepSeekAnthropicProvider = class {
242947
242943
  this.options.maxRetries ?? 2
242948
242944
  );
242949
242945
  } catch (error) {
242950
- if (input.abortSignal) {
242951
- input.abortSignal.removeEventListener("abort", onExternalAbort);
242952
- }
242953
242946
  yield {
242954
242947
  type: "error",
242955
242948
  error: sanitizeProviderError(error, [key])
@@ -242967,9 +242960,6 @@ var DeepSeekAnthropicProvider = class {
242967
242960
  [key]
242968
242961
  )
242969
242962
  };
242970
- if (input.abortSignal) {
242971
- input.abortSignal.removeEventListener("abort", onExternalAbort);
242972
- }
242973
242963
  return;
242974
242964
  }
242975
242965
  if (!body.stream) {
@@ -242985,9 +242975,6 @@ var DeepSeekAnthropicProvider = class {
242985
242975
  `Invalid Anthropic-compatible response: ${sanitizeProviderErrorText(toError(error).message, [key])}`
242986
242976
  )
242987
242977
  };
242988
- if (input.abortSignal) {
242989
- input.abortSignal.removeEventListener("abort", onExternalAbort);
242990
- }
242991
242978
  return;
242992
242979
  }
242993
242980
  if (isDeepSeekV4) {
@@ -242998,9 +242985,6 @@ var DeepSeekAnthropicProvider = class {
242998
242985
  );
242999
242986
  } catch (error) {
243000
242987
  yield { type: "error", error: toError(error) };
243001
- if (input.abortSignal) {
243002
- input.abortSignal.removeEventListener("abort", onExternalAbort);
243003
- }
243004
242988
  return;
243005
242989
  }
243006
242990
  }
@@ -243040,16 +243024,10 @@ var DeepSeekAnthropicProvider = class {
243040
243024
  } else {
243041
243025
  yield { type: "done" };
243042
243026
  }
243043
- if (input.abortSignal) {
243044
- input.abortSignal.removeEventListener("abort", onExternalAbort);
243045
- }
243046
243027
  return;
243047
243028
  }
243048
243029
  const reader = response.body?.getReader();
243049
243030
  if (!reader) {
243050
- if (input.abortSignal) {
243051
- input.abortSignal.removeEventListener("abort", onExternalAbort);
243052
- }
243053
243031
  yield {
243054
243032
  type: "error",
243055
243033
  error: new Error("Response body is not readable")
@@ -243277,9 +243255,6 @@ var DeepSeekAnthropicProvider = class {
243277
243255
  };
243278
243256
  } finally {
243279
243257
  if (streamTimeoutId) clearTimeout(streamTimeoutId);
243280
- if (input.abortSignal) {
243281
- input.abortSignal.removeEventListener("abort", onExternalAbort);
243282
- }
243283
243258
  await reader.cancel().catch(() => {
243284
243259
  });
243285
243260
  reader.releaseLock();
@@ -244402,10 +244377,7 @@ var DeepSeekOpenAIProvider = class {
244402
244377
  delete body.response_format;
244403
244378
  }
244404
244379
  const chatController = new AbortController();
244405
- const chatSignal = chatController.signal;
244406
- const onExternalAbort = () => {
244407
- chatController.abort();
244408
- };
244380
+ const chatSignal = input.abortSignal ? AbortSignal.any([chatController.signal, input.abortSignal]) : chatController.signal;
244409
244381
  if (input.abortSignal) {
244410
244382
  if (input.abortSignal.aborted) {
244411
244383
  yield {
@@ -244417,7 +244389,6 @@ var DeepSeekOpenAIProvider = class {
244417
244389
  };
244418
244390
  return;
244419
244391
  }
244420
- input.abortSignal.addEventListener("abort", onExternalAbort);
244421
244392
  }
244422
244393
  let response;
244423
244394
  try {
@@ -244433,9 +244404,6 @@ var DeepSeekOpenAIProvider = class {
244433
244404
  this.options.maxRetries ?? 2
244434
244405
  );
244435
244406
  } catch (error) {
244436
- if (input.abortSignal) {
244437
- input.abortSignal.removeEventListener("abort", onExternalAbort);
244438
- }
244439
244407
  yield {
244440
244408
  type: "error",
244441
244409
  error: sanitizeProviderError(error, [key])
@@ -244448,9 +244416,6 @@ var DeepSeekOpenAIProvider = class {
244448
244416
  type: "error",
244449
244417
  error: providerHttpError("DeepSeek", response.status, errText, [key])
244450
244418
  };
244451
- if (input.abortSignal) {
244452
- input.abortSignal.removeEventListener("abort", onExternalAbort);
244453
- }
244454
244419
  return;
244455
244420
  }
244456
244421
  if (!body.stream) {
@@ -244466,9 +244431,6 @@ var DeepSeekOpenAIProvider = class {
244466
244431
  `Invalid OpenAI-compatible response: ${sanitizeProviderErrorText(toError(error).message, [key])}`
244467
244432
  )
244468
244433
  };
244469
- if (input.abortSignal) {
244470
- input.abortSignal.removeEventListener("abort", onExternalAbort);
244471
- }
244472
244434
  return;
244473
244435
  }
244474
244436
  if (data.error) {
@@ -244478,9 +244440,6 @@ var DeepSeekOpenAIProvider = class {
244478
244440
  `DeepSeek API error: ${sanitizeProviderErrorText(data.error.message, [key])}`
244479
244441
  )
244480
244442
  };
244481
- if (input.abortSignal) {
244482
- input.abortSignal.removeEventListener("abort", onExternalAbort);
244483
- }
244484
244443
  return;
244485
244444
  }
244486
244445
  const choice = data.choices?.[0];
@@ -244489,9 +244448,6 @@ var DeepSeekOpenAIProvider = class {
244489
244448
  type: "error",
244490
244449
  error: new Error("DeepSeek returned no completion choice.")
244491
244450
  };
244492
- if (input.abortSignal) {
244493
- input.abortSignal.removeEventListener("abort", onExternalAbort);
244494
- }
244495
244451
  return;
244496
244452
  }
244497
244453
  if (isDeepSeekV4) {
@@ -244502,9 +244458,6 @@ var DeepSeekOpenAIProvider = class {
244502
244458
  );
244503
244459
  } catch (error) {
244504
244460
  yield { type: "error", error: toError(error) };
244505
- if (input.abortSignal) {
244506
- input.abortSignal.removeEventListener("abort", onExternalAbort);
244507
- }
244508
244461
  return;
244509
244462
  }
244510
244463
  }
@@ -244526,9 +244479,6 @@ var DeepSeekOpenAIProvider = class {
244526
244479
  type: "error",
244527
244480
  error: sanitizeProviderError(error, [key])
244528
244481
  };
244529
- if (input.abortSignal) {
244530
- input.abortSignal.removeEventListener("abort", onExternalAbort);
244531
- }
244532
244482
  return;
244533
244483
  }
244534
244484
  yield {
@@ -244575,16 +244525,10 @@ var DeepSeekOpenAIProvider = class {
244575
244525
  } else {
244576
244526
  yield { type: "done" };
244577
244527
  }
244578
- if (input.abortSignal) {
244579
- input.abortSignal.removeEventListener("abort", onExternalAbort);
244580
- }
244581
244528
  return;
244582
244529
  }
244583
244530
  const reader = response.body?.getReader();
244584
244531
  if (!reader) {
244585
- if (input.abortSignal) {
244586
- input.abortSignal.removeEventListener("abort", onExternalAbort);
244587
- }
244588
244532
  yield {
244589
244533
  type: "error",
244590
244534
  error: new Error("Response body is not readable")
@@ -244829,9 +244773,6 @@ var DeepSeekOpenAIProvider = class {
244829
244773
  };
244830
244774
  } finally {
244831
244775
  if (streamTimeoutId) clearTimeout(streamTimeoutId);
244832
- if (input.abortSignal) {
244833
- input.abortSignal.removeEventListener("abort", onExternalAbort);
244834
- }
244835
244776
  await reader.cancel().catch(() => {
244836
244777
  });
244837
244778
  reader.releaseLock();
@@ -248341,20 +248282,20 @@ function readProcessFailureMessage(result) {
248341
248282
  const message2 = typeof record.shortMessage === "string" ? record.shortMessage : typeof record.message === "string" ? record.message : "The child process failed.";
248342
248283
  return safeProcessFailureMessage(message2);
248343
248284
  }
248344
- function firstExistingPath(candidates, pathExists2 = existsSync6) {
248285
+ function firstExistingPath(candidates, pathExists = existsSync6) {
248345
248286
  for (const candidate of candidates) {
248346
- if (candidate && pathExists2(candidate)) return candidate;
248287
+ if (candidate && pathExists(candidate)) return candidate;
248347
248288
  }
248348
248289
  return null;
248349
248290
  }
248350
248291
  function resolveCommandShellInvocation(command, options = {}) {
248351
248292
  const platform = options.platform ?? process.platform;
248352
248293
  const environment = options.environment ?? process.env;
248353
- const pathExists2 = options.pathExists ?? existsSync6;
248294
+ const pathExists = options.pathExists ?? existsSync6;
248354
248295
  if (platform !== "win32") {
248355
248296
  const bash2 = firstExistingPath(
248356
248297
  [environment.ORBIT_BASH_PATH, "/bin/bash", "/usr/bin/bash"],
248357
- pathExists2
248298
+ pathExists
248358
248299
  );
248359
248300
  if (bash2) {
248360
248301
  return {
@@ -248375,7 +248316,7 @@ function resolveCommandShellInvocation(command, options = {}) {
248375
248316
  environment.LOCALAPPDATA ? join32(environment.LOCALAPPDATA, "Programs", "Git", "bin", "bash.exe") : void 0,
248376
248317
  environment.LOCALAPPDATA ? join32(environment.LOCALAPPDATA, "hermes", "git", "bin", "bash.exe") : void 0
248377
248318
  ],
248378
- pathExists2
248319
+ pathExists
248379
248320
  );
248380
248321
  if (bash) {
248381
248322
  return {
@@ -257622,41 +257563,40 @@ var SessionManager = class {
257622
257563
  resumeSession(id) {
257623
257564
  const session = this.store.getSession(id);
257624
257565
  this.recoveryReport = void 0;
257625
- if (session) {
257626
- this.currentSession = { ...session, status: "active" };
257627
- this.store.updateSession(this.currentSession);
257628
- const previousRun = this.store.getRunJournal(id);
257629
- const recoverable = previousRun?.state === "running" || previousRun?.state === "awaiting_approval" || previousRun?.state === "verifying";
257630
- if (recoverable && previousRun) {
257631
- const recoveredAt = (/* @__PURE__ */ new Date()).toISOString();
257632
- const repairedToolCalls = this.repairInterruptedToolCalls(recoveredAt);
257633
- const resetPlanItems = this.resetInterruptedPlanItems(recoveredAt);
257634
- const recoveryCount = previousRun.recoveryCount + 1;
257635
- this.store.saveRunJournal(id, {
257636
- ...previousRun,
257637
- state: "interrupted",
257638
- phase: `Recovered after interruption during ${previousRun.phase}`,
257639
- activeToolCallId: void 0,
257640
- updatedAt: recoveredAt,
257641
- recoveryCount
257642
- });
257643
- this.recoveryReport = SessionRecoveryReportSchema.parse({
257644
- sessionId: id,
257645
- previousState: previousRun.state,
257646
- previousPhase: previousRun.phase,
257647
- attempt: previousRun.attempt,
257648
- recoveryCount,
257649
- repairedToolCalls,
257650
- resetPlanItems,
257651
- recoveredAt
257652
- });
257653
- }
257654
- this.logEvent("session_resume", {
257655
- id,
257656
- recoverable,
257657
- recovery: this.recoveryReport || null
257566
+ if (!session) return void 0;
257567
+ this.currentSession = { ...session, status: "active" };
257568
+ this.store.updateSession(this.currentSession);
257569
+ const previousRun = this.store.getRunJournal(id);
257570
+ const recoverable = previousRun?.state === "running" || previousRun?.state === "awaiting_approval" || previousRun?.state === "verifying";
257571
+ if (recoverable && previousRun) {
257572
+ const recoveredAt = (/* @__PURE__ */ new Date()).toISOString();
257573
+ const repairedToolCalls = this.repairInterruptedToolCalls(recoveredAt);
257574
+ const resetPlanItems = this.resetInterruptedPlanItems(recoveredAt);
257575
+ const recoveryCount = previousRun.recoveryCount + 1;
257576
+ this.store.saveRunJournal(id, {
257577
+ ...previousRun,
257578
+ state: "interrupted",
257579
+ phase: `Recovered after interruption during ${previousRun.phase}`,
257580
+ activeToolCallId: void 0,
257581
+ updatedAt: recoveredAt,
257582
+ recoveryCount
257583
+ });
257584
+ this.recoveryReport = SessionRecoveryReportSchema.parse({
257585
+ sessionId: id,
257586
+ previousState: previousRun.state,
257587
+ previousPhase: previousRun.phase,
257588
+ attempt: previousRun.attempt,
257589
+ recoveryCount,
257590
+ repairedToolCalls,
257591
+ resetPlanItems,
257592
+ recoveredAt
257658
257593
  });
257659
257594
  }
257595
+ this.logEvent("session_resume", {
257596
+ id,
257597
+ recoverable,
257598
+ recovery: this.recoveryReport || null
257599
+ });
257660
257600
  return this.currentSession;
257661
257601
  }
257662
257602
  getActiveSession() {
@@ -257995,7 +257935,7 @@ var ProjectRecordSchema = z210.object({
257995
257935
  name: z210.string().trim().min(1).max(200),
257996
257936
  createdAt: z210.string().datetime(),
257997
257937
  lastOpenedAt: z210.string().datetime(),
257998
- lastSessionId: z210.string().min(1).optional(),
257938
+ lastSessionId: z210.string().min(1).max(1e3).optional(),
257999
257939
  archivedAt: z210.string().datetime().optional()
258000
257940
  });
258001
257941
  var ProjectRegistrySnapshotSchema = z210.object({
@@ -258299,6 +258239,7 @@ var AgentRunStore = class {
258299
258239
  processAlive;
258300
258240
  initialized = false;
258301
258241
  initialize() {
258242
+ this.assertRunDirectoryWithinWorkspace();
258302
258243
  mkdirSync23(this.directory, { recursive: true, mode: 448 });
258303
258244
  this.assertRunDirectorySafe();
258304
258245
  this.initialized = true;
@@ -258414,7 +258355,7 @@ var AgentRunStore = class {
258414
258355
  this.assertInitialized();
258415
258356
  let recovered = 0;
258416
258357
  const now = this.now().toISOString();
258417
- for (const snapshot of this.listRuns(100)) {
258358
+ for (const snapshot of this.readRuns()) {
258418
258359
  if (snapshot.status !== "running") continue;
258419
258360
  const didRecover = this.withRunLock(snapshot.id, () => {
258420
258361
  const run = this.requireRun(snapshot.id);
@@ -258538,6 +258479,9 @@ var AgentRunStore = class {
258538
258479
  return this.read(file);
258539
258480
  }
258540
258481
  listRuns(limit = 20) {
258482
+ return this.readRuns().slice(0, Math.max(1, Math.min(100, limit)));
258483
+ }
258484
+ readRuns() {
258541
258485
  if (!existsSync26(this.directory)) return [];
258542
258486
  this.assertRunDirectorySafe();
258543
258487
  return readdirSync22(this.directory).filter((name) => /^run_[a-z0-9-]+\.json$/.test(name)).flatMap((name) => {
@@ -258550,7 +258494,7 @@ var AgentRunStore = class {
258550
258494
  } catch {
258551
258495
  return [];
258552
258496
  }
258553
- }).sort((left, right) => right.updatedAt.localeCompare(left.updatedAt)).slice(0, Math.max(1, Math.min(100, limit)));
258497
+ }).sort((left, right) => right.updatedAt.localeCompare(left.updatedAt));
258554
258498
  }
258555
258499
  requireRun(runId) {
258556
258500
  this.assertInitialized();
@@ -258594,11 +258538,21 @@ var AgentRunStore = class {
258594
258538
  }
258595
258539
  }
258596
258540
  assertRunDirectorySafe() {
258541
+ this.assertRunDirectoryWithinWorkspace();
258597
258542
  const stats = lstatSync32(this.directory);
258598
258543
  if (stats.isSymbolicLink() || !stats.isDirectory()) {
258599
258544
  throw new Error("Orbit agent-run directory must be a real directory.");
258600
258545
  }
258601
258546
  }
258547
+ assertRunDirectoryWithinWorkspace() {
258548
+ const safeDirectory = resolveSafePath(
258549
+ this.cwd,
258550
+ join34(".orbit", "agent-runs")
258551
+ );
258552
+ if (resolve32(safeDirectory) !== this.directory) {
258553
+ throw new Error("Orbit agent-run directory escaped the workspace.");
258554
+ }
258555
+ }
258602
258556
  /** Serialize read-check-write mutations across Orbit processes. */
258603
258557
  withRunLock(runId, operation) {
258604
258558
  this.assertInitialized();
@@ -274777,7 +274731,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
274777
274731
  elements.activityTab.addEventListener('keydown', handleInspectorTabKeydown);
274778
274732
  elements.changesTab.addEventListener('keydown', handleInspectorTabKeydown);
274779
274733
  elements.settingsTab.addEventListener('keydown', handleInspectorTabKeydown);
274780
- byId('clearActivity').addEventListener('click', clearActivity);
274734
+ elements.clearActivity.addEventListener('click', clearActivity);
274781
274735
  elements.memoryReview.addEventListener('click', (event) => {
274782
274736
  const button = event.target.closest('[data-memory-remove]');
274783
274737
  if (!button || state.busy) return;
@@ -275228,10 +275182,35 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
275228
275182
  applySettings({ model: elements.modelSelect.value }, true).catch(() => {});
275229
275183
  });
275230
275184
 
275231
- byId('applyModel').addEventListener('click', () => {
275185
+ async function submitCustomModel() {
275232
275186
  const model = elements.customModel.value.trim();
275233
- if (!model) return;
275234
- applySettings({ model }).then(() => { elements.customModel.value = ''; }).catch(() => {});
275187
+ if (!model || state.busy || state.customModelPending) return;
275188
+ state.customModelPending = true;
275189
+ syncCustomModelAction();
275190
+ try {
275191
+ await applySettings({ model });
275192
+ elements.customModel.value = '';
275193
+ } catch {}
275194
+ finally {
275195
+ state.customModelPending = false;
275196
+ syncCustomModelAction();
275197
+ }
275198
+ }
275199
+
275200
+ elements.customModel.addEventListener('input', syncCustomModelAction);
275201
+ elements.customModel.addEventListener('keydown', (event) => {
275202
+ if (event.key !== 'Enter' || event.isComposing) return;
275203
+ event.preventDefault();
275204
+ void submitCustomModel();
275205
+ });
275206
+ elements.applyModel.addEventListener('click', () => void submitCustomModel());
275207
+ syncCustomModelAction();
275208
+
275209
+ elements.settingsPanel.addEventListener('click', (event) => {
275210
+ const button = event.target.closest('[data-settings-target]');
275211
+ if (!button) return;
275212
+ const target = byId(button.dataset.settingsTarget);
275213
+ if (target) target.scrollIntoView({ block: 'start' });
275235
275214
  });
275236
275215
 
275237
275216
  elements.permissionSelect.addEventListener('change', () => {
@@ -276299,6 +276278,10 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
276299
276278
  restored: '已恢复工作区',
276300
276279
  traceExported: '诊断包已导出',
276301
276280
  noChanges: '当前对话还没有文件改动。',
276281
+ noActivity: 'Orbit 工作时,步骤和工具状态会显示在这里。',
276282
+ noToolCalls: '当前对话还没有工具调用。',
276283
+ noMatchingChats: '没有匹配的对话',
276284
+ noRecentTasks: '还没有对话',
276302
276285
  noCheckpoints: '暂无可恢复检查点。',
276303
276286
  noVerification: '暂无验证结果。',
276304
276287
  noAgents: '当前工作区还没有委派智能体。',
@@ -276445,6 +276428,10 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
276445
276428
  restored: 'Workspace restored',
276446
276429
  traceExported: 'Diagnostics exported',
276447
276430
  noChanges: 'No file changes in this chat.',
276431
+ noActivity: 'Activity will appear here while Orbit works.',
276432
+ noToolCalls: 'No tool calls in this chat.',
276433
+ noMatchingChats: 'No matching chats',
276434
+ noRecentTasks: 'No chats yet',
276448
276435
  noCheckpoints: 'No restorable checkpoints.',
276449
276436
  noVerification: 'No verification results.',
276450
276437
  noAgents: 'No delegated agents for this workspace.',
@@ -276533,6 +276520,10 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
276533
276520
  restoreFile: '復原檔案',
276534
276521
  traceExported: '診斷包已匯出',
276535
276522
  noChanges: '目前對話尚未有檔案變更。',
276523
+ noActivity: 'Orbit 工作時,步驟和工具狀態會顯示在這裡。',
276524
+ noToolCalls: '目前對話尚未有工具呼叫。',
276525
+ noMatchingChats: '沒有相符的對話',
276526
+ noRecentTasks: '尚未有對話',
276536
276527
  queued: '已加入待傳送佇列',
276537
276528
  queueMessage: '加入佇列',
276538
276529
  removeQueued: '移除待傳送訊息',
@@ -276689,6 +276680,7 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
276689
276680
  providerSelect: byId('providerSelect'),
276690
276681
  modelSelect: byId('modelSelect'),
276691
276682
  customModel: byId('customModel'),
276683
+ applyModel: byId('applyModel'),
276692
276684
  permissionSelect: byId('permissionSelect'),
276693
276685
  permissionSegments: byId('permissionSegments'),
276694
276686
  permissionSummary: byId('permissionSummary'),
@@ -276727,6 +276719,7 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
276727
276719
  events: byId('events'),
276728
276720
  activityEmpty: byId('activityEmpty'),
276729
276721
  activityFilters: byId('activityFilters'),
276722
+ clearActivity: byId('clearActivity'),
276730
276723
  runtime: byId('runtime'),
276731
276724
  taskOverview: byId('taskOverview'),
276732
276725
  buildPlanButton: byId('buildPlanButton'),
@@ -276782,6 +276775,7 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
276782
276775
  streamingTools: new Map(),
276783
276776
  statusRefresh: null,
276784
276777
  settingsPromise: null,
276778
+ customModelPending: false,
276785
276779
  skills: null,
276786
276780
  skillsPromise: null,
276787
276781
  skillRequestId: 0,
@@ -277161,12 +277155,22 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
277161
277155
  ? state.skills.enabled
277162
277156
  : state.status && state.status.skills && state.status.skills.enabled
277163
277157
  ));
277158
+ syncCustomModelAction();
277164
277159
  elements.turnStatus.classList.toggle('is-working', busy);
277165
277160
  elements.turnStatus.textContent = label || (busy ? copy.thinking : '');
277166
277161
  updateSendButtonState();
277167
277162
  renderPromptQueue();
277168
277163
  }
277169
277164
 
277165
+ function syncCustomModelAction() {
277166
+ const pending = state.customModelPending;
277167
+ elements.customModel.disabled = state.busy || pending;
277168
+ elements.applyModel.disabled = state.busy || pending || !elements.customModel.value.trim();
277169
+ elements.applyModel.setAttribute('aria-busy', pending ? 'true' : 'false');
277170
+ if (pending) elements.applyModel.setAttribute('aria-label', copy.settingsSaving);
277171
+ else elements.applyModel.removeAttribute('aria-label');
277172
+ }
277173
+
277170
277174
  function updateSendButtonState() {
277171
277175
  const hasPrompt = Boolean(elements.prompt.value.trim());
277172
277176
  elements.buildPlanButton.disabled = state.busy || !state.ready;
@@ -278885,7 +278889,7 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
278885
278889
  if (!tools.length) {
278886
278890
  const empty = document.createElement('p');
278887
278891
  empty.className = 'review-empty';
278888
- empty.textContent = copy.noActivity;
278892
+ empty.textContent = copy.noToolCalls;
278889
278893
  elements.toolHistory.append(empty);
278890
278894
  return;
278891
278895
  }
@@ -279502,6 +279506,10 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
279502
279506
  return refresh;
279503
279507
  }
279504
279508
 
279509
+ function syncActivityControls() {
279510
+ elements.clearActivity.disabled = state.activityRows === 0;
279511
+ }
279512
+
279505
279513
  function addActivity(message, kind, key) {
279506
279514
  elements.activityEmpty.hidden = true;
279507
279515
  if (key) {
@@ -279537,6 +279545,7 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
279537
279545
  first.remove();
279538
279546
  state.activityRows -= 1;
279539
279547
  }
279548
+ syncActivityControls();
279540
279549
  applyActivityFilter();
279541
279550
  return row;
279542
279551
  }
@@ -279561,6 +279570,7 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
279561
279570
  state.activityRows = 0;
279562
279571
  state.currentThinkingRow = null;
279563
279572
  state.toolRows.clear();
279573
+ syncActivityControls();
279564
279574
  }
279565
279575
 
279566
279576
  async function applySettings(patch, quiet) {
@@ -281841,6 +281851,10 @@ var BASE_COPY = {
281841
281851
  parallelImprove: "Parallel improve",
281842
281852
  parallelImproveBody: "Plan, implement, and review with Git worktree isolation when available.",
281843
281853
  settings: "Settings",
281854
+ settingsSections: "Settings sections",
281855
+ settingsGeneral: "General",
281856
+ settingsCapabilities: "Capabilities",
281857
+ settingsAppearance: "Appearance",
281844
281858
  language: "Language",
281845
281859
  languageDescription: "Used by this project in both WebUI and terminal.",
281846
281860
  languageEnglish: "English",
@@ -281871,6 +281885,7 @@ var BASE_COPY = {
281871
281885
  noMemory: "No explicit project memory.",
281872
281886
  noPlan: "No plan steps for this chat.",
281873
281887
  noActivity: "Activity will appear here while Orbit works.",
281888
+ noToolCalls: "No tool calls in this chat.",
281874
281889
  clearActivity: "Clear",
281875
281890
  activityAll: "All",
281876
281891
  activityRunning: "Running",
@@ -282017,6 +282032,10 @@ var BASE_COPY = {
282017
282032
  parallelImprove: "\u5E76\u884C\u6539\u8FDB",
282018
282033
  parallelImproveBody: "\u5B8C\u6210\u89C4\u5212\u3001\u5B9E\u73B0\u4E0E\u5BA1\u67E5\uFF0C\u5E76\u5728\u53EF\u7528\u65F6\u901A\u8FC7 Git \u5DE5\u4F5C\u6811\u9694\u79BB\u6539\u52A8\u3002",
282019
282034
  settings: "\u8BBE\u7F6E",
282035
+ settingsSections: "\u8BBE\u7F6E\u5206\u533A",
282036
+ settingsGeneral: "\u5E38\u89C4",
282037
+ settingsCapabilities: "\u80FD\u529B",
282038
+ settingsAppearance: "\u5916\u89C2",
282020
282039
  language: "\u8BED\u8A00",
282021
282040
  languageDescription: "\u5F53\u524D\u5DE5\u7A0B\u7684 WebUI \u4E0E\u7EC8\u7AEF\u5C06\u4F7F\u7528\u540C\u4E00\u8BED\u8A00\u3002",
282022
282041
  languageEnglish: "English",
@@ -282047,6 +282066,7 @@ var BASE_COPY = {
282047
282066
  noMemory: "\u6682\u65E0\u663E\u5F0F\u9879\u76EE\u8BB0\u5FC6\u3002",
282048
282067
  noPlan: "\u5F53\u524D\u5BF9\u8BDD\u6682\u65E0\u8BA1\u5212\u6B65\u9AA4\u3002",
282049
282068
  noActivity: "Orbit \u5DE5\u4F5C\u65F6\uFF0C\u6B65\u9AA4\u548C\u5DE5\u5177\u72B6\u6001\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002",
282069
+ noToolCalls: "\u5F53\u524D\u5BF9\u8BDD\u8FD8\u6CA1\u6709\u5DE5\u5177\u8C03\u7528\u3002",
282050
282070
  clearActivity: "\u6E05\u7A7A",
282051
282071
  activityAll: "\u5168\u90E8",
282052
282072
  activityRunning: "\u8FDB\u884C\u4E2D",
@@ -282187,6 +282207,10 @@ var COPY = {
282187
282207
  parallelImprove: "\u5E73\u884C\u6539\u9032",
282188
282208
  parallelImproveBody: "\u5B8C\u6210\u898F\u5283\u3001\u5BE6\u4F5C\u8207\u5BE9\u67E5\uFF0C\u4E26\u5728\u53EF\u7528\u6642\u900F\u904E Git \u5DE5\u4F5C\u6A39\u9694\u96E2\u8B8A\u66F4\u3002",
282189
282209
  settings: "\u8A2D\u5B9A",
282210
+ settingsSections: "\u8A2D\u5B9A\u5206\u5340",
282211
+ settingsGeneral: "\u4E00\u822C",
282212
+ settingsCapabilities: "\u80FD\u529B",
282213
+ settingsAppearance: "\u5916\u89C0",
282190
282214
  changedFiles: "\u6A94\u6848\u8B8A\u66F4",
282191
282215
  toolCalls: "\u5DE5\u5177\u547C\u53EB",
282192
282216
  verification: "\u9A57\u8B49\u7D50\u679C",
@@ -282197,6 +282221,7 @@ var COPY = {
282197
282221
  projectMemory: "\u5C08\u6848\u8A18\u61B6",
282198
282222
  taskPlan: "\u4EFB\u52D9\u8A08\u756B",
282199
282223
  noActivity: "Orbit \u5DE5\u4F5C\u6642\uFF0C\u6B65\u9A5F\u548C\u5DE5\u5177\u72C0\u614B\u6703\u986F\u793A\u5728\u9019\u88E1\u3002",
282224
+ noToolCalls: "\u76EE\u524D\u5C0D\u8A71\u5C1A\u672A\u6709\u5DE5\u5177\u547C\u53EB\u3002",
282200
282225
  clearActivity: "\u6E05\u9664",
282201
282226
  activityAll: "\u5168\u90E8",
282202
282227
  activityRunning: "\u9032\u884C\u4E2D",
@@ -282614,10 +282639,10 @@ function renderWebUiPage(language) {
282614
282639
  </section>
282615
282640
  <section class="detail-section">
282616
282641
  <div class="section-heading"><h3>${copy.toolCalls}</h3><span id="toolHistoryCount">0</span></div>
282617
- <div class="tool-history-list" id="toolHistory"><p class="review-empty">${copy.noActivity}</p></div>
282642
+ <div class="tool-history-list" id="toolHistory"><p class="review-empty">${copy.noToolCalls}</p></div>
282618
282643
  </section>
282619
282644
  <section class="detail-section activity-section">
282620
- <div class="section-heading"><h3>${copy.activity}</h3><button class="text-button" id="clearActivity" type="button">${copy.clearActivity}</button></div>
282645
+ <div class="section-heading"><h3>${copy.activity}</h3><button class="text-button" id="clearActivity" type="button" disabled>${copy.clearActivity}</button></div>
282621
282646
  <div class="compact-filter-bar segmented" id="activityFilters" aria-label="${copy.activity}">
282622
282647
  <button type="button" data-activity-filter="all" aria-pressed="true">${copy.activityAll}</button>
282623
282648
  <button type="button" data-activity-filter="running" aria-pressed="false">${copy.activityRunning}</button>
@@ -282662,7 +282687,12 @@ function renderWebUiPage(language) {
282662
282687
  </section>
282663
282688
 
282664
282689
  <section class="tab-panel" id="settingsPanel" role="tabpanel" aria-labelledby="settingsTab" hidden>
282665
- <section class="settings-group">
282690
+ <nav class="settings-index" aria-label="${copy.settingsSections}">
282691
+ <button type="button" data-settings-target="settingsGeneral">${copy.settingsGeneral}</button>
282692
+ <button type="button" data-settings-target="settingsCapabilities">${copy.settingsCapabilities}</button>
282693
+ <button type="button" data-settings-target="settingsAppearance">${copy.settingsAppearance}</button>
282694
+ </nav>
282695
+ <section class="settings-group" id="settingsGeneral">
282666
282696
  <div class="setting-row setting-row-stacked">
282667
282697
  <div><h3>${copy.language}</h3><p>${copy.languageDescription}</p></div>
282668
282698
  <div class="segmented language-options" id="languageOptions">
@@ -282677,7 +282707,7 @@ function renderWebUiPage(language) {
282677
282707
  <label class="field-label" for="customModel">${copy.customModel}</label>
282678
282708
  <div class="inline-field">
282679
282709
  <input id="customModel" type="text" maxlength="200" placeholder="deepseek-v4-pro" />
282680
- <button class="secondary-button" id="applyModel" type="button">${copy.apply}</button>
282710
+ <button class="secondary-button" id="applyModel" type="button" disabled>${copy.apply}</button>
282681
282711
  </div>
282682
282712
  </section>
282683
282713
  <section class="settings-group">
@@ -282716,7 +282746,7 @@ function renderWebUiPage(language) {
282716
282746
  <input class="field-control" id="searchMax" type="number" min="1" max="20" />
282717
282747
  </div>
282718
282748
  </section>
282719
- <section class="settings-group skill-settings">
282749
+ <section class="settings-group skill-settings" id="settingsCapabilities">
282720
282750
  <div class="setting-row">
282721
282751
  <div><h3>${copy.skills}</h3><p>${copy.skillsDescription}</p></div>
282722
282752
  <label class="switch"><input id="skillsEnabled" type="checkbox" aria-label="${copy.skills}" /><span class="switch-track" aria-hidden="true"></span></label>
@@ -282786,7 +282816,7 @@ function renderWebUiPage(language) {
282786
282816
  <div class="skill-diagnostics" id="skillDiagnostics"></div>
282787
282817
  </div>
282788
282818
  </section>
282789
- <section class="settings-group">
282819
+ <section class="settings-group" id="settingsAppearance">
282790
282820
  <h3>${copy.theme}</h3>
282791
282821
  <div class="theme-options" id="themeOptions">
282792
282822
  <button type="button" data-theme-value="system" aria-pressed="false">${copy.system}</button>
@@ -285480,7 +285510,7 @@ var WEB_UI_FOUNDATION_STYLES = String.raw`
285480
285510
  --sidebar: #eef0ed;
285481
285511
  --sidebar-ink: #202824;
285482
285512
  --sidebar-muted: #59645f;
285483
- --sidebar-faint: #76817c;
285513
+ --sidebar-faint: #64706a;
285484
285514
  --sidebar-border: rgba(29, 43, 37, 0.11);
285485
285515
  --sidebar-surface: rgba(255, 255, 255, 0.5);
285486
285516
  --sidebar-active: rgba(255, 255, 255, 0.78);
@@ -285492,7 +285522,7 @@ var WEB_UI_FOUNDATION_STYLES = String.raw`
285492
285522
  --ink: #2c3834;
285493
285523
  --ink-strong: #111d19;
285494
285524
  --muted: #596761;
285495
- --faint: #6c7974;
285525
+ --faint: #64716c;
285496
285526
  --border: rgba(28, 49, 42, 0.105);
285497
285527
  --border-strong: rgba(28, 49, 42, 0.18);
285498
285528
  --accent: #4f857b;
@@ -285543,7 +285573,7 @@ var WEB_UI_FOUNDATION_STYLES = String.raw`
285543
285573
  --ink: #d8e0e4;
285544
285574
  --ink-strong: #f1f5f6;
285545
285575
  --muted: #a5b1b8;
285546
- --faint: #74838d;
285576
+ --faint: #81919b;
285547
285577
  --border: rgba(220, 231, 236, 0.1);
285548
285578
  --border-strong: rgba(220, 231, 236, 0.18);
285549
285579
  --accent: #83aca4;
@@ -285586,7 +285616,7 @@ var WEB_UI_FOUNDATION_STYLES = String.raw`
285586
285616
  --ink: #d8e0e4;
285587
285617
  --ink-strong: #f1f5f6;
285588
285618
  --muted: #a5b1b8;
285589
- --faint: #74838d;
285619
+ --faint: #81919b;
285590
285620
  --border: rgba(220, 231, 236, 0.1);
285591
285621
  --border-strong: rgba(220, 231, 236, 0.18);
285592
285622
  --accent: #83aca4;
@@ -286715,6 +286745,45 @@ var WEB_UI_INSPECTOR_STYLES = String.raw`
286715
286745
  gap: 10px;
286716
286746
  }
286717
286747
 
286748
+ .settings-index {
286749
+ position: sticky;
286750
+ top: -4px;
286751
+ z-index: 2;
286752
+ display: grid;
286753
+ grid-template-columns: repeat(3, minmax(0, 1fr));
286754
+ gap: 4px;
286755
+ margin: 0 -4px;
286756
+ padding: 8px 4px 7px;
286757
+ background: color-mix(in srgb, var(--surface) 92%, transparent);
286758
+ border-bottom: 1px solid var(--border);
286759
+ backdrop-filter: blur(12px);
286760
+ }
286761
+
286762
+ .settings-index button {
286763
+ min-width: 0;
286764
+ height: 32px;
286765
+ padding: 0 6px;
286766
+ overflow: hidden;
286767
+ color: var(--muted);
286768
+ background: var(--surface-subtle);
286769
+ border: 1px solid transparent;
286770
+ border-radius: 8px;
286771
+ font-size: 10px;
286772
+ font-weight: 600;
286773
+ text-overflow: ellipsis;
286774
+ white-space: nowrap;
286775
+ }
286776
+
286777
+ .settings-index button:hover {
286778
+ color: var(--ink-strong);
286779
+ background: var(--surface-hover);
286780
+ border-color: var(--border);
286781
+ }
286782
+
286783
+ .settings-group[id] {
286784
+ scroll-margin-top: 52px;
286785
+ }
286786
+
286718
286787
  .settings-group > h3 {
286719
286788
  margin-bottom: 2px;
286720
286789
  }
@@ -286734,7 +286803,7 @@ var WEB_UI_INSPECTOR_STYLES = String.raw`
286734
286803
  gap: 10px;
286735
286804
  }
286736
286805
 
286737
- .language-options {
286806
+ .segmented.language-options {
286738
286807
  width: 100%;
286739
286808
  grid-template-columns: repeat(3, minmax(0, 1fr));
286740
286809
  }
@@ -286786,6 +286855,27 @@ var WEB_UI_INSPECTOR_STYLES = String.raw`
286786
286855
  background: var(--surface-hover);
286787
286856
  }
286788
286857
 
286858
+ #applyModel[aria-busy="true"] {
286859
+ position: relative;
286860
+ color: transparent;
286861
+ cursor: progress;
286862
+ opacity: 1;
286863
+ }
286864
+
286865
+ #applyModel[aria-busy="true"]::after {
286866
+ position: absolute;
286867
+ top: 50%;
286868
+ left: 50%;
286869
+ width: 14px;
286870
+ height: 14px;
286871
+ border: 2px solid color-mix(in srgb, var(--accent) 34%, transparent);
286872
+ border-top-color: var(--accent-strong);
286873
+ border-radius: 50%;
286874
+ content: "";
286875
+ animation: spin 0.72s linear infinite;
286876
+ translate: -50% -50%;
286877
+ }
286878
+
286789
286879
  .segmented,
286790
286880
  .theme-options {
286791
286881
  display: grid;
@@ -287670,6 +287760,11 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
287670
287760
  padding: 0 6px;
287671
287761
  }
287672
287762
 
287763
+ .composer-chip,
287764
+ .composer-select-trigger {
287765
+ height: 36px;
287766
+ }
287767
+
287673
287768
  .context-shelf {
287674
287769
  padding: 7px;
287675
287770
  }
@@ -287761,18 +287856,6 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
287761
287856
  gap: 8px;
287762
287857
  }
287763
287858
 
287764
- #contextPickerButton,
287765
- #attachmentButton {
287766
- min-width: 29px;
287767
- justify-content: center;
287768
- padding-inline: 6px;
287769
- }
287770
-
287771
- #contextPickerButton > span:not(.context-chip-count),
287772
- #attachmentButton > span:not(.context-chip-count) {
287773
- display: none;
287774
- }
287775
-
287776
287859
  .task-overview-stats {
287777
287860
  grid-template-columns: minmax(0, 1fr);
287778
287861
  }
@@ -287793,9 +287876,6 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
287793
287876
  max-width: 34ch;
287794
287877
  }
287795
287878
 
287796
- .language-options {
287797
- grid-template-columns: minmax(0, 1fr);
287798
- }
287799
287879
  }
287800
287880
 
287801
287881
  @media (prefers-reduced-motion: reduce) {
@@ -289248,6 +289328,9 @@ function normalizePath4(path9) {
289248
289328
 
289249
289329
  // src/runtime/webui/WebUiRuntime.ts
289250
289330
  var WebTurnIdSchema = z55.string().trim().min(8).max(100).regex(/^[a-zA-Z0-9_-]+$/);
289331
+ var AttachmentIdsSchema = z55.array(WebTurnIdSchema).max(4).refine((ids) => new Set(ids).size === ids.length, {
289332
+ message: "Attachment IDs must be unique."
289333
+ });
289251
289334
  var MessagePageQuerySchema = z55.object({
289252
289335
  before: z55.coerce.number().int().min(1).max(1e7).optional(),
289253
289336
  limit: z55.coerce.number().int().min(20).max(100).optional()
@@ -289255,7 +289338,7 @@ var MessagePageQuerySchema = z55.object({
289255
289338
  var ChatRequestSchema = z55.object({
289256
289339
  prompt: z55.string().trim().min(1).max(1e5),
289257
289340
  turnId: WebTurnIdSchema.optional(),
289258
- attachmentIds: z55.array(WebTurnIdSchema).max(4).optional()
289341
+ attachmentIds: AttachmentIdsSchema.optional()
289259
289342
  }).strict();
289260
289343
  var InputQueueIdSchema = z55.string().trim().regex(/^input_[a-zA-Z0-9_-]+$/).max(200);
289261
289344
  var InputQueueActionSchema = z55.discriminatedUnion("action", [
@@ -289263,7 +289346,7 @@ var InputQueueActionSchema = z55.discriminatedUnion("action", [
289263
289346
  action: z55.literal("enqueue"),
289264
289347
  prompt: z55.string().trim().min(1).max(1e5),
289265
289348
  mode: z55.enum(["follow_up", "steer"]).default("follow_up"),
289266
- attachmentIds: z55.array(WebTurnIdSchema).max(4).optional()
289349
+ attachmentIds: AttachmentIdsSchema.optional()
289267
289350
  }).strict(),
289268
289351
  z55.object({
289269
289352
  action: z55.literal("update"),
@@ -289422,6 +289505,7 @@ var OrbitWebUiRuntime = class {
289422
289505
  completionCandidatesPromise;
289423
289506
  completionCandidatesCachedAt = 0;
289424
289507
  attachments = /* @__PURE__ */ new Map();
289508
+ pendingAttachmentUploads = 0;
289425
289509
  constructor(options) {
289426
289510
  this.options = options;
289427
289511
  this.events = new WebUiEventStream(() => this.activeTurn);
@@ -289511,7 +289595,6 @@ var OrbitWebUiRuntime = class {
289511
289595
  this.state = "stopping";
289512
289596
  this.events.stop();
289513
289597
  this.activeTurn = void 0;
289514
- this.attachments.clear();
289515
289598
  this.token = void 0;
289516
289599
  this.handle = void 0;
289517
289600
  const server2 = this.server;
@@ -289521,6 +289604,8 @@ var OrbitWebUiRuntime = class {
289521
289604
  server2.close(() => resolveClose());
289522
289605
  });
289523
289606
  }
289607
+ this.attachments.clear();
289608
+ this.pendingAttachmentUploads = 0;
289524
289609
  this.state = "stopped";
289525
289610
  }
289526
289611
  async handleRequest(req, res) {
@@ -289700,6 +289785,7 @@ var OrbitWebUiRuntime = class {
289700
289785
  sendJson(res, 404, { error: "Not found" });
289701
289786
  }
289702
289787
  async handleAttachmentUpload(req, res, url) {
289788
+ let slotReserved = false;
289703
289789
  try {
289704
289790
  const mediaType = String(req.headers["content-type"] || "").split(";", 1)[0].trim().toLowerCase();
289705
289791
  if (!ALLOWED_IMAGE_TYPES.has(mediaType)) {
@@ -289709,13 +289795,15 @@ var OrbitWebUiRuntime = class {
289709
289795
  });
289710
289796
  return;
289711
289797
  }
289712
- if (this.attachments.size >= IMAGE_ATTACHMENT_STORE_LIMIT) {
289798
+ if (this.attachments.size + this.pendingAttachmentUploads >= IMAGE_ATTACHMENT_STORE_LIMIT) {
289713
289799
  sendJson(res, 429, {
289714
289800
  ok: false,
289715
289801
  message: "Too many pending attachments. Remove an image or retry later."
289716
289802
  });
289717
289803
  return;
289718
289804
  }
289805
+ this.pendingAttachmentUploads += 1;
289806
+ slotReserved = true;
289719
289807
  const body = await readBinaryBody(req, IMAGE_ATTACHMENT_LIMIT_BYTES);
289720
289808
  if (body.length === 0) {
289721
289809
  sendJson(res, 400, { ok: false, message: "Attachment is empty." });
@@ -289748,6 +289836,8 @@ var OrbitWebUiRuntime = class {
289748
289836
  ok: false,
289749
289837
  message: safeWebMessage(error)
289750
289838
  });
289839
+ } finally {
289840
+ if (slotReserved) this.pendingAttachmentUploads -= 1;
289751
289841
  }
289752
289842
  }
289753
289843
  async handleReview(req, res, options) {
@@ -293086,6 +293176,9 @@ function parseReviewCommand(rawArguments) {
293086
293176
  const [first = "", ...rest] = input.split(/\s+/);
293087
293177
  const preset = ReviewPresetSchema.safeParse(first);
293088
293178
  if (preset.success) {
293179
+ if (rest.length > 0) {
293180
+ throw new Error("Too many /review arguments.");
293181
+ }
293089
293182
  return {
293090
293183
  preset: preset.data,
293091
293184
  scope: { kind: "working-tree" }
@@ -297284,7 +297377,13 @@ import { resolve as resolve17 } from "path";
297284
297377
  import { z as z71 } from "zod";
297285
297378
 
297286
297379
  // src/runtime/CleanupManager.ts
297287
- import { lstatSync as lstatSync10, readdirSync as readdirSync9, rmSync as rmSync9 } from "fs";
297380
+ import {
297381
+ lstatSync as lstatSync10,
297382
+ readdirSync as readdirSync9,
297383
+ realpathSync as realpathSync4,
297384
+ rmSync as rmSync9,
297385
+ unlinkSync as unlinkSync6
297386
+ } from "fs";
297288
297387
  import { homedir as homedir11 } from "os";
297289
297388
  import { basename as basename6, join as join20, parse as parse5, resolve as resolve16 } from "path";
297290
297389
  import { z as z70 } from "zod";
@@ -297330,17 +297429,42 @@ function executeCleanupPlan(plan) {
297330
297429
  const result = { removed: [], skipped: [] };
297331
297430
  for (const target of plan.targets) {
297332
297431
  assertSafeOrbitDataPath(target.path);
297333
- if (!pathExists(target.path)) {
297432
+ let stat;
297433
+ try {
297434
+ stat = lstatSync10(target.path);
297435
+ } catch (error) {
297436
+ if (!isMissingPathError(error)) {
297437
+ throw new Error(
297438
+ `Unable to verify cleanup target (${safeInventoryWarning(target.path, error)}).`,
297439
+ { cause: error }
297440
+ );
297441
+ }
297334
297442
  result.skipped.push(target.path);
297335
297443
  continue;
297336
297444
  }
297337
- rmSync9(target.path, { recursive: true, force: true, maxRetries: 3 });
297445
+ if (stat.isSymbolicLink()) {
297446
+ unlinkSync6(target.path);
297447
+ } else {
297448
+ rmSync9(target.path, { recursive: true, force: true, maxRetries: 3 });
297449
+ }
297338
297450
  result.removed.push(target.path);
297339
297451
  }
297340
297452
  return result;
297341
297453
  }
297342
297454
  function inspectPath(targetPath) {
297343
- if (!pathExists(targetPath)) {
297455
+ let targetStat;
297456
+ try {
297457
+ targetStat = lstatSync10(targetPath);
297458
+ } catch (error) {
297459
+ if (!isMissingPathError(error)) {
297460
+ return {
297461
+ exists: true,
297462
+ files: 0,
297463
+ directories: 0,
297464
+ bytes: 0,
297465
+ warnings: [safeInventoryWarning(targetPath, error)]
297466
+ };
297467
+ }
297344
297468
  return {
297345
297469
  exists: false,
297346
297470
  files: 0,
@@ -297351,13 +297475,17 @@ function inspectPath(targetPath) {
297351
297475
  }
297352
297476
  const totals = { files: 0, directories: 0, bytes: 0 };
297353
297477
  const warnings = [];
297354
- const visit = (currentPath) => {
297478
+ const visit = (currentPath, knownStat) => {
297355
297479
  let stat;
297356
- try {
297357
- stat = lstatSync10(currentPath);
297358
- } catch (error) {
297359
- warnings.push(safeInventoryWarning(currentPath, error));
297360
- return;
297480
+ if (knownStat) {
297481
+ stat = knownStat;
297482
+ } else {
297483
+ try {
297484
+ stat = lstatSync10(currentPath);
297485
+ } catch (error) {
297486
+ warnings.push(safeInventoryWarning(currentPath, error));
297487
+ return;
297488
+ }
297361
297489
  }
297362
297490
  if (stat.isSymbolicLink()) {
297363
297491
  totals.files++;
@@ -297378,7 +297506,7 @@ function inspectPath(targetPath) {
297378
297506
  warnings.push(safeInventoryWarning(currentPath, error));
297379
297507
  }
297380
297508
  };
297381
- visit(targetPath);
297509
+ visit(targetPath, targetStat);
297382
297510
  return { exists: true, ...totals, warnings };
297383
297511
  }
297384
297512
  function assertSafeOrbitDataPath(targetPath) {
@@ -297389,23 +297517,29 @@ function assertSafeOrbitDataPath(targetPath) {
297389
297517
  if (basename6(absolutePath).toLowerCase() !== ".orbit") {
297390
297518
  throw new Error("Cleanup targets must be an Orbit data directory.");
297391
297519
  }
297392
- if (resolve16(absolutePath, "..") === parse5(absolutePath).root) {
297520
+ const parentPath = resolve16(absolutePath, "..");
297521
+ if (parentPath === parse5(absolutePath).root) {
297393
297522
  throw new Error(
297394
297523
  "Refusing to clean an Orbit directory directly under a filesystem root."
297395
297524
  );
297396
297525
  }
297526
+ try {
297527
+ const canonicalParent = realpathSync4.native(parentPath);
297528
+ if (canonicalParent === parse5(canonicalParent).root) {
297529
+ throw new Error(
297530
+ "Refusing to clean an Orbit directory through a filesystem-root link."
297531
+ );
297532
+ }
297533
+ } catch (error) {
297534
+ if (!isMissingPathError(error)) throw error;
297535
+ }
297397
297536
  }
297398
297537
  function pathIdentity(targetPath) {
297399
297538
  const normalized = resolve16(targetPath).replace(/\\/g, "/");
297400
297539
  return process.platform === "win32" ? normalized.toLowerCase() : normalized;
297401
297540
  }
297402
- function pathExists(targetPath) {
297403
- try {
297404
- lstatSync10(targetPath);
297405
- return true;
297406
- } catch {
297407
- return false;
297408
- }
297541
+ function isMissingPathError(error) {
297542
+ return typeof error === "object" && error !== null && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
297409
297543
  }
297410
297544
  function safeInventoryWarning(targetPath, error) {
297411
297545
  const code = typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : "unreadable";
@@ -298391,7 +298525,7 @@ function removeExtension(id) {
298391
298525
  }
298392
298526
 
298393
298527
  // src/index.ts
298394
- import { existsSync as existsSync31, realpathSync as realpathSync4, statSync as statSync5 } from "fs";
298528
+ import { existsSync as existsSync31, realpathSync as realpathSync5, statSync as statSync5 } from "fs";
298395
298529
  import { resolve as resolve21 } from "path";
298396
298530
 
298397
298531
  // src/runtime/CliRunOverrides.ts
@@ -298626,7 +298760,7 @@ program.command("webui").description("start Orbit as a browser-first local codin
298626
298760
  `Web UI project directory does not exist: ${requestedCwd}`
298627
298761
  );
298628
298762
  }
298629
- const cwd = realpathSync4.native(requestedCwd);
298763
+ const cwd = realpathSync5.native(requestedCwd);
298630
298764
  const outcome = await runAgent(cwd, void 0, overrides, false, {
298631
298765
  webUi: { port }
298632
298766
  });