@orbit-build/cli 0.9.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +137 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -243792,7 +243792,13 @@ var AnthropicCompatibleProvider = class {
243792
243792
  signal: chatSignal,
243793
243793
  timeout: this.options.requestTimeoutMs
243794
243794
  },
243795
- this.options.maxRetries ?? (this.isOfficialDeepSeekEndpoint() ? 0 : 2)
243795
+ Math.max(
243796
+ 0,
243797
+ Math.min(
243798
+ 5,
243799
+ input.retryBudget ?? this.options.maxRetries ?? (this.isOfficialDeepSeekEndpoint() ? 0 : 2)
243800
+ )
243801
+ )
243796
243802
  );
243797
243803
  } catch (error) {
243798
243804
  const sanitized = sanitizeProviderError(error, [key]);
@@ -244839,7 +244845,10 @@ async function* chatWithDeepSeekResponses(input, options) {
244839
244845
  signal: controller.signal,
244840
244846
  timeout: options.runtime.requestTimeoutMs
244841
244847
  },
244842
- options.runtime.maxRetries ?? 0
244848
+ Math.max(
244849
+ 0,
244850
+ Math.min(5, input.retryBudget ?? options.runtime.maxRetries ?? 0)
244851
+ )
244843
244852
  );
244844
244853
  if (!response.ok) {
244845
244854
  const detail = await readProviderErrorText(response);
@@ -245534,7 +245543,13 @@ ${jsonInstruction}`;
245534
245543
  signal: chatSignal,
245535
245544
  timeout: this.options.requestTimeoutMs
245536
245545
  },
245537
- this.options.maxRetries ?? (isOfficialDeepSeek ? 0 : 2)
245546
+ Math.max(
245547
+ 0,
245548
+ Math.min(
245549
+ 5,
245550
+ input.retryBudget ?? this.options.maxRetries ?? (isOfficialDeepSeek ? 0 : 2)
245551
+ )
245552
+ )
245538
245553
  );
245539
245554
  } catch (error) {
245540
245555
  const sanitized = sanitizeProviderError(error, [key]);
@@ -252189,6 +252204,7 @@ var JSVectorStore = class {
252189
252204
  loaded = false;
252190
252205
  loading = null;
252191
252206
  cacheState = "uninitialized";
252207
+ persistenceError;
252192
252208
  async addDocuments(docs, persist = true) {
252193
252209
  if (!this.loaded) {
252194
252210
  await this.load();
@@ -252295,7 +252311,13 @@ var JSVectorStore = class {
252295
252311
  await fsPromises2.rm(tmpPath, { force: true }).catch(() => void 0);
252296
252312
  }
252297
252313
  this.cacheState = "valid";
252298
- } catch {
252314
+ this.persistenceError = void 0;
252315
+ } catch (error) {
252316
+ this.cacheState = "invalid";
252317
+ this.persistenceError = error instanceof Error ? error.message : String(error);
252318
+ throw new Error(
252319
+ `Failed to persist the Orbit vector cache: ${this.persistenceError}`
252320
+ );
252299
252321
  }
252300
252322
  }
252301
252323
  async load() {
@@ -252371,6 +252393,10 @@ var JSVectorStore = class {
252371
252393
  hasValidCache() {
252372
252394
  return this.cacheState === "valid";
252373
252395
  }
252396
+ /** Returns the last persistence failure without exposing filesystem details. */
252397
+ getPersistenceError() {
252398
+ return this.persistenceError;
252399
+ }
252374
252400
  initializeCachePath() {
252375
252401
  if (this.cachePathInitialized) return;
252376
252402
  this.dbPath = getOrbitCachePath(this.cwd, "vector_store.json");
@@ -260408,7 +260434,7 @@ var AgentRunStore = class {
260408
260434
  * The returned cleanup callback is idempotent and the timer never keeps the
260409
260435
  * process alive on its own.
260410
260436
  */
260411
- startLeaseHeartbeat(runId) {
260437
+ startLeaseHeartbeat(runId, options = {}) {
260412
260438
  this.renewLease(runId);
260413
260439
  let active = true;
260414
260440
  const heartbeat = setInterval(
@@ -260416,9 +260442,10 @@ var AgentRunStore = class {
260416
260442
  if (!active) return;
260417
260443
  try {
260418
260444
  this.renewLease(runId);
260419
- } catch {
260445
+ } catch (error) {
260420
260446
  active = false;
260421
260447
  clearInterval(heartbeat);
260448
+ options.onLeaseLost?.(error);
260422
260449
  }
260423
260450
  },
260424
260451
  Math.max(1e3, Math.floor(this.leaseDurationMs / 3))
@@ -261144,7 +261171,7 @@ function compactHistoryMessages(sourceHistory, options) {
261144
261171
  }
261145
261172
  var SEMANTIC_SUMMARY_MIN_DIGEST_CHARS = 400;
261146
261173
  var SEMANTIC_SUMMARY_DIGEST_TOKEN_BUDGET = 6e3;
261147
- async function buildSemanticCompactionSummary(dropped, provider, fastModel) {
261174
+ async function buildSemanticCompactionSummary(dropped, provider, fastModel, options = {}) {
261148
261175
  if (!fastModel || dropped.length === 0) return null;
261149
261176
  const digest = buildDroppedHistoryDigest(dropped);
261150
261177
  if (digest.length < SEMANTIC_SUMMARY_MIN_DIGEST_CHARS) return null;
@@ -261176,9 +261203,13 @@ async function buildSemanticCompactionSummary(dropped, provider, fastModel) {
261176
261203
  ],
261177
261204
  tools: [],
261178
261205
  thinking: { enabled: false },
261179
- maxTokens: 1024
261206
+ maxTokens: 1024,
261207
+ abortSignal: options.abortSignal,
261208
+ retryBudget: 0
261180
261209
  })) {
261210
+ if (options.abortSignal?.aborted) return null;
261181
261211
  if (event.type === "text_delta") text2 += event.text;
261212
+ if (event.type === "usage") options.onUsage?.(event.usage);
261182
261213
  if (event.type === "error") return null;
261183
261214
  }
261184
261215
  const cleaned = text2.trim();
@@ -264506,8 +264537,19 @@ var AgentLoop = class _AgentLoop {
264506
264537
  });
264507
264538
  this.verificationManager.initialize();
264508
264539
  this.sessionManager.saveHistory(this.state.history);
264509
- void this.provider.initialize?.().catch(() => {
264510
- });
264540
+ try {
264541
+ await this.provider.initialize?.();
264542
+ } catch (error) {
264543
+ const message2 = safeAgentLoopErrorMessage(error);
264544
+ this.sessionManager.logEvent("provider_initialization_failed", {
264545
+ provider: this.provider.id,
264546
+ message: message2
264547
+ });
264548
+ this.interaction.showText(
264549
+ picocolors3.red(`\u2716 Provider initialization failed: ${message2}`)
264550
+ );
264551
+ return this.createFailedOutcome("provider_error", message2);
264552
+ }
264511
264553
  if (isNewSession) {
264512
264554
  const sessionHooks = await this.runLifecycleHooks("sessionStart", {
264513
264555
  sessionId: this.state.sessionId,
@@ -264909,6 +264951,9 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
264909
264951
  maxTokens: this.getContextWindowStatus(activeModel2).reservedOutputTokens,
264910
264952
  userId: this.userId,
264911
264953
  abortSignal: this.abortController.signal,
264954
+ // The Agent owns the retry budget and fallback policy. Prevent a
264955
+ // provider transport from nesting its own retries inside the loop.
264956
+ retryBudget: 0,
264912
264957
  thinking: supportsThinking ? {
264913
264958
  enabled: thinkingEnabled,
264914
264959
  budgetTokens: thinkingBudget,
@@ -266039,9 +266084,9 @@ ${commandError}`,
266039
266084
  content: [
266040
266085
  {
266041
266086
  type: "text",
266042
- text: `Generate a concise, high-quality conventional git commit message (e.g. feat(cli): add autocomplete) for the following git diff. Output ONLY the commit message, no formatting, no markdown, no quotes, just the text:
266087
+ text: `Generate a concise, high-quality conventional git commit message (e.g. feat(cli): add autocomplete) from the following change summary. Output ONLY the commit message, no formatting, no markdown, no quotes, just the text:
266043
266088
 
266044
- ${stdout2.substring(0, 2e4)}`
266089
+ ${buildCommitContextForModel(stdout2)}`
266045
266090
  }
266046
266091
  ]
266047
266092
  }
@@ -266871,9 +266916,9 @@ ${guardNudge.message}` : ""),
266871
266916
  content: [
266872
266917
  {
266873
266918
  type: "text",
266874
- text: `Generate a concise, high-quality conventional git commit message (e.g. feat(cli): add autocomplete) for the following git diff. Output ONLY the commit message, no formatting, no markdown, no quotes, just the text:
266919
+ text: `Generate a concise, high-quality conventional git commit message (e.g. feat(cli): add autocomplete) from the following change summary. Output ONLY the commit message, no formatting, no markdown, no quotes, just the text:
266875
266920
 
266876
- ${diff.substring(0, 2e4)}`
266921
+ ${buildCommitContextForModel(diff)}`
266877
266922
  }
266878
266923
  ]
266879
266924
  }
@@ -267739,7 +267784,11 @@ ${diff.substring(0, 2e4)}`
267739
267784
  const semanticSummary = await buildSemanticCompactionSummary(
267740
267785
  droppedHistory,
267741
267786
  this.provider,
267742
- this.config.models.fast
267787
+ this.config.models.fast,
267788
+ {
267789
+ abortSignal: this.abortController?.signal,
267790
+ onUsage: (usage2) => this.accumulateCost(this.config.models.fast, usage2)
267791
+ }
267743
267792
  );
267744
267793
  const summaryBlock = semanticSummary ? history.find((message2) => message2.id === summaryMessageId)?.content.find((block2) => block2.type === "text") : void 0;
267745
267794
  if (semanticSummary && summaryBlock?.type === "text") {
@@ -267952,6 +268001,29 @@ ${diff.substring(0, 2e4)}`
267952
268001
  }
267953
268002
  }
267954
268003
  };
268004
+ function buildCommitContextForModel(diff) {
268005
+ const files = /* @__PURE__ */ new Set();
268006
+ let additions = 0;
268007
+ let deletions = 0;
268008
+ for (const line of diff.split(/\r?\n/)) {
268009
+ if (line.startsWith("diff --git ")) {
268010
+ const match = line.match(/ b\/(.+)$/);
268011
+ if (match?.[1]) files.add(match[1]);
268012
+ } else if (line.startsWith("+") && !line.startsWith("+++")) {
268013
+ additions += 1;
268014
+ } else if (line.startsWith("-") && !line.startsWith("---")) {
268015
+ deletions += 1;
268016
+ }
268017
+ }
268018
+ const fileList = [...files].slice(0, 100);
268019
+ return redactSecrets(
268020
+ [
268021
+ `Files changed (${files.size}): ${fileList.join(", ") || "unknown"}`,
268022
+ `Line changes: +${additions} / -${deletions}.`,
268023
+ "Infer the scope from paths and counts only; do not invent implementation details."
268024
+ ].join("\n")
268025
+ ).slice(0, 8e3);
268026
+ }
267955
268027
  function toUnknownRecord(value) {
267956
268028
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
267957
268029
  }
@@ -268332,7 +268404,11 @@ var AgentRunTracker = class {
268332
268404
  task: this.task,
268333
268405
  budgetUsd: this.budgetUsd
268334
268406
  });
268335
- this.stopLeaseHeartbeat = store.startLeaseHeartbeat(this.run.id);
268407
+ this.stopLeaseHeartbeat = store.startLeaseHeartbeat(this.run.id, {
268408
+ onLeaseLost: (error) => this.warn(
268409
+ `Agent run lease was lost; durable state is no longer being renewed: ${errorMessage2(error)}`
268410
+ )
268411
+ });
268336
268412
  } catch (error) {
268337
268413
  this.warn(`Agent run state will be memory-only: ${errorMessage2(error)}`);
268338
268414
  }
@@ -283853,6 +283929,25 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
283853
283929
  state.ready = true;
283854
283930
  updateSendButtonState();
283855
283931
  setConnection('connected', copy.connected);
283932
+ } else if (event.kind === 'replay_gap') {
283933
+ // The server retained only a bounded replay window. Reconcile the
283934
+ // authoritative snapshot immediately so a reconnect never leaves the
283935
+ // UI presenting a silently incomplete turn or session history.
283936
+ state.ready = false;
283937
+ updateSendButtonState();
283938
+ setConnection(
283939
+ 'connecting',
283940
+ language === 'en'
283941
+ ? 'Some events expired; syncing the latest state…'
283942
+ : chinese('部分事件已过期,正在同步最新状态…', '部分事件已過期,正在同步最新狀態…'),
283943
+ );
283944
+ void reconcileStatus().finally(() => {
283945
+ if (state.eventSource === source && state.ready === false) {
283946
+ state.ready = true;
283947
+ updateSendButtonState();
283948
+ setConnection('connected', copy.connected);
283949
+ }
283950
+ });
283856
283951
  } else if (event.kind === 'turn_started') {
283857
283952
  state.activeTurnId = event.turnId;
283858
283953
  setBusy(true, copy.working);
@@ -285379,13 +285474,14 @@ var WebUiEventStream = class {
285379
285474
  const payload = sanitizeWebEventPayload(event.type, event.payload);
285380
285475
  if (payload === void 0) return;
285381
285476
  const turn = this.getActiveTurn();
285477
+ const eventSessionId = extractSessionId(payload);
285382
285478
  this.broadcast({
285383
285479
  kind: "orbit_event",
285384
285480
  schemaVersion: event.schemaVersion,
285385
285481
  id: event.eventId,
285386
285482
  timestamp: event.timestamp,
285387
285483
  turnId: turn?.id,
285388
- sessionId: turn?.sessionId,
285484
+ sessionId: eventSessionId || turn?.sessionId,
285389
285485
  type: event.type,
285390
285486
  payload
285391
285487
  });
@@ -285445,6 +285541,19 @@ var WebUiEventStream = class {
285445
285541
  );
285446
285542
  const lastEventId = parseLastEventId(req.headers?.["last-event-id"]);
285447
285543
  if (lastEventId !== void 0) {
285544
+ const firstBufferedId = this.replayBuffer[0]?.id;
285545
+ if (firstBufferedId !== void 0 && lastEventId + 1 < firstBufferedId) {
285546
+ res.write(
285547
+ formatSseEvent({
285548
+ id: firstBufferedId - 1,
285549
+ event: {
285550
+ kind: "replay_gap",
285551
+ afterEventId: lastEventId,
285552
+ firstAvailableEventId: firstBufferedId
285553
+ }
285554
+ })
285555
+ );
285556
+ }
285448
285557
  for (const entry of this.replayBuffer) {
285449
285558
  if (entry.id > lastEventId) res.write(formatSseEvent(entry));
285450
285559
  }
@@ -285501,6 +285610,17 @@ var WebUiEventStream = class {
285501
285610
  if (destroy && !client.destroyed) client.destroy();
285502
285611
  }
285503
285612
  };
285613
+ function extractSessionId(payload) {
285614
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
285615
+ return void 0;
285616
+ }
285617
+ const record = payload;
285618
+ for (const key of ["sessionId", "taskId", "agentId"]) {
285619
+ const value = record[key];
285620
+ if (typeof value === "string" && value.trim()) return value;
285621
+ }
285622
+ return void 0;
285623
+ }
285504
285624
  function parseLastEventId(value) {
285505
285625
  const text2 = Array.isArray(value) ? value[0] : value;
285506
285626
  if (!text2 || !/^\d+$/.test(text2)) return void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbit-build/cli",
3
- "version": "0.9.0",
3
+ "version": "1.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Local-first AI coding agent CLI, TUI, Web UI, diagnostics, and LSP runtime",
6
6
  "keywords": [