omnius 1.0.889 → 1.0.891

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
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/index.js
3
- size: 38549280 bytes
4
- sha256: 20005028cf68d09b7b39d67f5f7c2f5a1c0d2439921afe103203f1d9beb9a324
3
+ size: 38569995 bytes
4
+ sha256: fbcac5a251ce2d03c36a693fd201e9a05f77be2d924498c008607626275592db
package/dist/library.js CHANGED
@@ -352353,9 +352353,9 @@ function sourceSpan(content, observation) {
352353
352353
  }
352354
352354
  function projectQualifiedSourceBodies(input) {
352355
352355
  const observations = new Map(input.observations.filter((observation) => issued5.has(observation) && observation.scope === input.scope).map((observation) => [observation.callId, observation]));
352356
- const calls = new Set(input.messages.flatMap((message) => {
352356
+ const calls = new Map(input.messages.flatMap((message) => {
352357
352357
  const value = message;
352358
- return value["role"] === "assistant" && Array.isArray(value["tool_calls"]) ? value["tool_calls"].flatMap((call2) => call2 && typeof call2 === "object" && call2.function?.name === "file_read" && typeof call2.id === "string" ? [call2.id] : []) : [];
352358
+ return value["role"] === "assistant" && Array.isArray(value["tool_calls"]) ? value["tool_calls"].flatMap((call2) => call2 && typeof call2 === "object" && ["file_read", "web_fetch"].includes(call2.function?.name) && typeof call2.id === "string" ? [[call2.id, call2.function.name]] : []) : [];
352359
352359
  }));
352360
352360
  const carriers = [];
352361
352361
  input.messages.forEach((message, index) => {
@@ -352364,7 +352364,7 @@ function projectQualifiedSourceBodies(input) {
352364
352364
  if (value["role"] !== "tool" || typeof value["content"] !== "string" || typeof callId !== "string" || !calls.has(callId))
352365
352365
  return;
352366
352366
  const observation = observations.get(callId);
352367
- if (!observation)
352367
+ if (!observation || calls.get(callId) !== (observation.toolName ?? "file_read"))
352368
352368
  return;
352369
352369
  const span = sourceSpan(value["content"], observation);
352370
352370
  if (!span)
@@ -352383,7 +352383,7 @@ function projectQualifiedSourceBodies(input) {
352383
352383
  if (carrier.protected)
352384
352384
  continue;
352385
352385
  const own = carrier.observation;
352386
- const covering = carriers.filter((candidate) => candidate.observation.path === own.path && candidate.observation.sourceHash === own.sourceHash && candidate.observation.startLine <= own.startLine && candidate.observation.endLine >= own.endLine).sort((a, b) => b.observation.endLine - b.observation.startLine - (a.observation.endLine - a.observation.startLine) || Number(b.protected) - Number(a.protected) || b.index - a.index);
352386
+ const covering = carriers.filter((candidate) => (candidate.observation.toolName ?? "file_read") === (own.toolName ?? "file_read") && candidate.observation.path === own.path && candidate.observation.sourceHash === own.sourceHash && candidate.observation.startLine <= own.startLine && candidate.observation.endLine >= own.endLine).sort((a, b) => b.observation.endLine - b.observation.startLine - (a.observation.endLine - a.observation.startLine) || Number(b.protected) - Number(a.protected) || b.index - a.index);
352387
352387
  const keeper = covering[0];
352388
352388
  if (!keeper || keeper === carrier)
352389
352389
  continue;
@@ -374365,7 +374365,11 @@ function normalizeCanonicalHistory(history, options = {}) {
374365
374365
  for (const group of transactions2.values()) {
374366
374366
  const raw = group.filter((entry) => entry.kind === "tool_transaction_raw");
374367
374367
  const receipts = group.filter((entry) => entry.kind === "evidence_receipt");
374368
- const keepRaw = raw.some((entry) => entry.transactionRelevance === "active") || receipts.length === 0 || options.historicalTransactionPolicy === "retain_raw" && completeRawToolTransaction(raw);
374368
+ const largeHistoricalResult = options.historicalToolInlineBytes !== void 0 && raw.some((entry) => {
374369
+ const message = entry.message;
374370
+ return message && message["role"] === "tool" && typeof message["content"] === "string" && Buffer.byteLength(message["content"], "utf8") > options.historicalToolInlineBytes;
374371
+ });
374372
+ const keepRaw = raw.some((entry) => entry.transactionRelevance === "active" || (entry.protection?.length ?? 0) > 0) || receipts.length === 0 || options.historicalTransactionPolicy === "retain_raw" && !largeHistoricalResult && completeRawToolTransaction(raw);
374369
374373
  const receiptWinner = receipts.length > 0 ? [...receipts].sort(compareHistoryNewest)[0] : void 0;
374370
374374
  const rejected = keepRaw ? receipts : [...raw, ...receipts.filter((entry) => entry !== receiptWinner)];
374371
374375
  for (const entry of rejected) {
@@ -374614,7 +374618,8 @@ function buildCanonicalModelRequest(input) {
374614
374618
  if (input.maxRequestBytes !== void 0)
374615
374619
  assertPositiveBudget(input.maxRequestBytes, "maxRequestBytes");
374616
374620
  const historyProjection = normalizeCanonicalHistory(input.history, {
374617
- historicalTransactionPolicy: input.historicalTransactionPolicy
374621
+ historicalTransactionPolicy: input.historicalTransactionPolicy,
374622
+ historicalToolInlineBytes: input.historicalToolInlineBytes
374618
374623
  });
374619
374624
  const frame = projectCanonicalTaskFrame({
374620
374625
  signals: input.signals,
@@ -389305,6 +389310,18 @@ var AgenticRunner = class _AgenticRunner {
389305
389310
  const freshHash = typeof result.beforeHash === "string" && /^[a-f0-9]{64}$/i.test(result.beforeHash) ? result.beforeHash : null;
389306
389311
  if (!path7 || !freshHash)
389307
389312
  return null;
389313
+ if (toolName !== "file_edit" || typeof args["old_string"] !== "string" || !args["old_string"].length) {
389314
+ return [
389315
+ "[STALE_HASH_RETRY]",
389316
+ "The file revision differs from the edit precondition. Read the current file and reconcile the intended change before retrying.",
389317
+ "Prefer a focused file_edit/file_patch built from the current text. Never reuse an old full-file replacement with only a refreshed hash.",
389318
+ JSON.stringify({
389319
+ failure_family: "stale_hash",
389320
+ guardrail: "reread_and_rebase",
389321
+ next_read: { tool: "file_read", args: { path: path7 } }
389322
+ })
389323
+ ].join("\n");
389324
+ }
389308
389325
  const retry = {
389309
389326
  failure_family: "stale_hash",
389310
389327
  guardrail: "one_assisted_refresh_only",
@@ -391712,6 +391729,7 @@ runtime_module_sha256=${record9.runtimeProvenance.module.sha256 ?? "unknown"}`
391712
391729
  },
391713
391730
  canonicalToolExposureContracts: options?.canonicalToolExposureContracts ?? [],
391714
391731
  canonicalMaxInputTokens: options?.canonicalMaxInputTokens === void 0 ? void 0 : Math.max(1, Math.floor(options.canonicalMaxInputTokens)),
391732
+ historicalToolInlineBytes: options?.historicalToolInlineBytes === void 0 ? 16 * 1024 : Number.isNaN(options.historicalToolInlineBytes) ? 16 * 1024 : Math.max(0, options.historicalToolInlineBytes),
391715
391733
  // A fixed 8k aggregate ceiling could reject a valid set of action tools
391716
391734
  // before inference (for example 9,479 chars of schemas for an 8k cap).
391717
391735
  // Progressive exposure still controls relevance, but selected schemas
@@ -393419,6 +393437,49 @@ ${read.content}`;
393419
393437
  atomicGroup: transactionId2
393420
393438
  });
393421
393439
  }
393440
+ for (let index = 0; index < messages2.length; index++) {
393441
+ const message = messages2[index];
393442
+ const calls = message.role === "assistant" ? message.tool_calls : void 0;
393443
+ const transactionId2 = transactionByIndex.get(index);
393444
+ if (!calls || calls.length < 2 || !transactionId2 || transactionId2 === activeTransactionId || new Set(calls.map((call2) => call2.id)).size !== calls.length)
393445
+ continue;
393446
+ const members = calls.map((call2) => {
393447
+ const receipt = this._canonicalAcceptedReceipts.get(call2.id);
393448
+ const results = messages2.filter((candidate) => candidate.role === "tool" && candidate.tool_call_id === call2.id);
393449
+ return receipt && results.length === 1 ? { transactionId: call2.id, ...receipt } : void 0;
393450
+ });
393451
+ if (members.some((member) => !member))
393452
+ continue;
393453
+ try {
393454
+ const content = JSON.stringify({ schema: "omnius.tool-batch-artifacts.v1", members });
393455
+ const stored = this._artifactStore().put({
393456
+ path: `tool-batch/${this.currentArtifactRunId()}/${transactionId2}`,
393457
+ revision: _createHash("sha256").update(content).digest("hex"),
393458
+ content,
393459
+ fidelity: "full"
393460
+ });
393461
+ this._artifactStore().flush(stored.reference);
393462
+ entries.push({
393463
+ id: `accepted-receipt:${transactionId2}`,
393464
+ kind: "evidence_receipt",
393465
+ ordinal: (transactionSpans.get(transactionId2)?.end ?? index) + 0.25,
393466
+ turn,
393467
+ revision: turn,
393468
+ priority: 700,
393469
+ transactionId: transactionId2,
393470
+ artifactLocator: stored.reference,
393471
+ atomicGroup: transactionId2,
393472
+ message: { role: "system", content: renderCanonicalEvidenceReceipt({
393473
+ transactionId: transactionId2,
393474
+ toolName: "tool_batch",
393475
+ artifactLocator: stored.reference,
393476
+ success: true,
393477
+ summary: `All ${members.length} results retained; artifact is a manifest of individual source artifacts. ` + members.map((member) => member.summary).join(" ")
393478
+ }) }
393479
+ });
393480
+ } catch {
393481
+ }
393482
+ }
393422
393483
  return entries;
393423
393484
  }
393424
393485
  /**
@@ -393540,6 +393601,7 @@ ${read.content}`;
393540
393601
  measureInputTokens: (candidate) => this._outboundRequestBudget(candidate).totalInputTokens,
393541
393602
  excludeMutableProjections,
393542
393603
  historicalTransactionPolicy,
393604
+ historicalToolInlineBytes: this.options.historicalToolInlineBytes,
393543
393605
  toolProjection
393544
393606
  });
393545
393607
  const original = build(signals);
@@ -393608,6 +393670,9 @@ ${read.content}`;
393608
393670
  if (hasPhysicalContextLimit && retainedBudget.compactionEligible || canonicalInputCeiling !== void 0 && retainedBudget.totalInputTokens > canonicalInputCeiling) {
393609
393671
  projection = materializeOwnedSourceProjections(buildProjection("receipt", canonicalInputCeiling));
393610
393672
  }
393673
+ if (canonicalInputCeiling !== void 0 && projection.trace.maxInputTokens === void 0) {
393674
+ projection = { ...projection, trace: { ...projection.trace, maxInputTokens: canonicalInputCeiling } };
393675
+ }
393611
393676
  if (schemaBytes > this.options.canonicalMaxToolSchemaChars || toolProjection.status !== "ok") {
393612
393677
  throw new Error(toolProjection.missingRequiredToolNames.length > 0 ? `canonical_tool_required_schema_missing:${toolProjection.missingRequiredToolNames.join(",")}` : `canonical_tool_schema_budget_overflow:${schemaBytes}/${this.options.canonicalMaxToolSchemaChars}`);
393613
393678
  }
@@ -393873,13 +393938,55 @@ ${read.content}`;
393873
393938
  });
393874
393939
  }
393875
393940
  } : outbound;
393876
- const ownedRequest = withManagedLocalAdmissionBudget(this.backend, { ...dispatchRequest, signal: AbortSignal.any([
393877
- inputWaitController.signal,
393878
- this._abortController.signal,
393879
- this._turnAbortController.signal,
393880
- ...dispatchRequest.signal ? [dispatchRequest.signal] : []
393881
- ]) }, this.options.requestTimeoutMs);
393882
- const response = await withInputWaitCancellation(inputWaitController.signal, () => backend.chatCompletion(ownedRequest));
393941
+ const selectedBackend = this.backend;
393942
+ const selectedScope = selectedBackend.transportContextScope?.() ?? selectedBackend;
393943
+ const taskBinding = this._sourceReadTaskBinding();
393944
+ const ownedRequest = withManagedLocalAdmissionBudget(this.backend, {
393945
+ ...dispatchRequest,
393946
+ logicalRequestId: dispatchRequest.logicalRequestId ?? crypto.randomUUID(),
393947
+ signal: AbortSignal.any([
393948
+ inputWaitController.signal,
393949
+ this._abortController.signal,
393950
+ this._turnAbortController.signal,
393951
+ ...dispatchRequest.signal ? [dispatchRequest.signal] : []
393952
+ ])
393953
+ }, this.options.requestTimeoutMs);
393954
+ let response;
393955
+ let readinessWaits = 0;
393956
+ for (; ; ) {
393957
+ assertCurrent();
393958
+ ownedRequest.signal.throwIfAborted();
393959
+ if (readinessWaits > 0 && (selectedBackend !== this.backend || selectedScope !== (this.backend.transportContextScope?.() ?? this.backend) || taskBinding !== this._sourceReadTaskBinding()))
393960
+ throw new Error("interruption_stale_model_dispatch");
393961
+ try {
393962
+ response = await withInputWaitCancellation(ownedRequest.signal, () => backend.chatCompletion(ownedRequest));
393963
+ break;
393964
+ } catch (error) {
393965
+ if (!(error instanceof LocalInferenceNotReadyError) || !operation.requiredForRun || (ownedRequest.workloadClass ?? this.options.workloadClass) !== "foreground")
393966
+ throw error;
393967
+ assertCurrent();
393968
+ ownedRequest.signal.throwIfAborted();
393969
+ if (readinessWaits++ === 0)
393970
+ this.emit({
393971
+ type: "status",
393972
+ inferenceWaiting: true,
393973
+ content: "Waiting for the selected local model.",
393974
+ visibility: "telemetry",
393975
+ turn: operation.turn,
393976
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
393977
+ });
393978
+ await this.waitForTransientRetry(Math.min(15e3, 1e3 * 2 ** Math.min(4, readinessWaits - 1)), ownedRequest.signal);
393979
+ }
393980
+ }
393981
+ if (readinessWaits > 0)
393982
+ this.emit({
393983
+ type: "status",
393984
+ inferenceWaiting: false,
393985
+ content: "Selected local model ready; resuming task.",
393986
+ visibility: "telemetry",
393987
+ turn: operation.turn,
393988
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
393989
+ });
393883
393990
  inputWaitController.signal.throwIfAborted();
393884
393991
  if (ticket && !this._interruptionLifecycle?.canCommit(ticket)) {
393885
393992
  throw new Error("interruption_stale_model_result");
@@ -395755,8 +395862,12 @@ ${workflowStatus}` } : {}
395755
395862
  });
395756
395863
  const tool = this.tools.get(input.toolName);
395757
395864
  const sourceEvidence = input.toolName === "file_read" ? qualifySourceReadEvidence({ cwd: this._workingDirectory || process.cwd(), args: input.args, result: input.result }) : void 0;
395865
+ if (sourceEvidence) {
395866
+ const receipt = this._canonicalAcceptedReceipts.get(input.toolCallId);
395867
+ receipt.summary += ` file_edit_precondition=${JSON.stringify({ path: this._normalizeEvidencePath(sourceEvidence.path), expected_hash: sourceEvidence.sourceHash })}`;
395868
+ }
395758
395869
  const identity4 = tool?.getHistoryObservationIdentity?.(input.args, input.result) ?? (sourceEvidence ? JSON.stringify({ tool: "file_read", cwd: this.authoritativeWorkingDirectory(), path: sourceEvidence.path, hash: sourceEvidence.sourceHash, range: sourceEvidence.coverage }) : null);
395759
- const sourceBody = sourceEvidence?.coverage && typeof sourceEvidence.coverage.endLine === "number" ? issueQualifiedSourceBodyObservation({
395870
+ const fileSourceBody = sourceEvidence?.coverage && typeof sourceEvidence.coverage.endLine === "number" ? issueQualifiedSourceBodyObservation({
395760
395871
  scope: this._sourceBodyProjectionScope(),
395761
395872
  callId: input.toolCallId,
395762
395873
  path: this._normalizeEvidencePath(sourceEvidence.path),
@@ -395767,7 +395878,23 @@ ${workflowStatus}` } : {}
395767
395878
  format: sourceEvidence.deliveryFormat,
395768
395879
  body: input.result.llmContent ?? input.result.output
395769
395880
  }) : null;
395770
- if (sourceBody && (input.result.fullReadAdmitted === true || [...this._inlineReadArtifacts.values()].some((artifact2) => artifact2.path === sourceBody.path && artifact2.contentHash === sourceBody.sourceHash && artifact2.sourceRange.startLine === sourceBody.startLine && artifact2.sourceRange.endLine === sourceBody.endLine))) {
395881
+ const admittedWeb = this._admittedWebSourceViews.get(input.result);
395882
+ const web = complete?.schema === "omnius.native-web-source.v1" ? complete : null;
395883
+ const webBody = web && (input.args["format"] === "raw_html" ? web.body : web.htmlEvidence?.article.text ?? web.body);
395884
+ const webSourceBody = web && webBody && admittedWeb?.source === web && admittedWeb.sourceCurrent() && admittedWeb.scopeId === this._sessionId && admittedWeb.runId === this.currentArtifactRunId() && admittedWeb.taskEpoch === this._taskEpoch && admittedWeb.modelContent === input.result.llmContent && admittedWeb.output === input.result.output && input.toolName === "web_fetch" ? issueQualifiedSourceBodyObservation({
395885
+ scope: this._sourceBodyProjectionScope(),
395886
+ callId: input.toolCallId,
395887
+ toolName: "web_fetch",
395888
+ path: JSON.stringify([web.receipt.requestedUrl, input.args["format"] === "raw_html" ? "raw_html" : "semantic"]),
395889
+ sourceHash: web.receipt.responseSha256,
395890
+ startLine: 1,
395891
+ endLine: webBody.split("\n").length,
395892
+ artifactLocator: stored.reference,
395893
+ format: "raw",
395894
+ body: webBody
395895
+ }) : null;
395896
+ const sourceBody = fileSourceBody ?? webSourceBody;
395897
+ if (fileSourceBody && sourceBody && (input.result.fullReadAdmitted === true || [...this._inlineReadArtifacts.values()].some((artifact2) => artifact2.path === sourceBody.path && artifact2.contentHash === sourceBody.sourceHash && artifact2.sourceRange.startLine === sourceBody.startLine && artifact2.sourceRange.endLine === sourceBody.endLine))) {
395771
395898
  this._inlineReadArtifacts.set(input.toolCallId, {
395772
395899
  callId: input.toolCallId,
395773
395900
  path: sourceBody.path,
@@ -395797,6 +395924,12 @@ ${workflowStatus}` } : {}
395797
395924
  ...sourceEvidence ? { sourceRead: { path: sourceEvidence.path, hash: sourceEvidence.sourceHash, ...sourceEvidence.coverage } } : {},
395798
395925
  ...sourceBody ? { sourceBody } : {}
395799
395926
  });
395927
+ } else if (webSourceBody) {
395928
+ this._historyObservations.set(input.toolCallId, {
395929
+ equivalenceKey: _createHash("sha256").update(`${webSourceBody.scope}:${input.toolCallId}`).digest("hex"),
395930
+ observedAt: web.receipt.fetchedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
395931
+ sourceBody: webSourceBody
395932
+ });
395800
395933
  }
395801
395934
  while (this._canonicalAcceptedReceipts.size > 128) {
395802
395935
  const oldest = this._canonicalAcceptedReceipts.keys().next().value;
@@ -396690,7 +396823,7 @@ ${content}`)].join("\n\n");
396690
396823
  const configuredTrigger = this.options.virtualContext?.triggerTokens;
396691
396824
  const triggerTokens = Number.isFinite(configuredTrigger) && (configuredTrigger ?? 0) > 0 ? Math.floor(configuredTrigger) : Number.isFinite(envTrigger) && envTrigger > 0 ? Math.floor(envTrigger) : Math.max(1, Math.floor(physicalInputBudget * 0.6));
396692
396825
  const configuredEvidenceBudget = this.options.virtualContext?.evidenceTokenBudget;
396693
- const evidenceTokenBudget = Math.max(1, Math.min(physicalInputBudget, Number.isFinite(configuredEvidenceBudget) && (configuredEvidenceBudget ?? 0) > 0 ? Math.floor(configuredEvidenceBudget) : adaptiveBudget.exactEvidence));
396826
+ const evidenceTokenBudget = Math.max(1, Math.min(physicalInputBudget, Number.isFinite(configuredEvidenceBudget) && (configuredEvidenceBudget ?? 0) > 0 ? Math.floor(configuredEvidenceBudget) : configuredEvidenceBudget === Number.POSITIVE_INFINITY ? adaptiveBudget.exactEvidence : Math.min(8192, adaptiveBudget.exactEvidence)));
396694
396827
  const configuredPinnedBudget = this.options.virtualContext?.pinnedMemoryTokenBudget;
396695
396828
  const pinnedTokenBudget = Math.max(0, Math.min(physicalInputBudget, Number.isFinite(configuredPinnedBudget) && (configuredPinnedBudget ?? 0) > 0 ? Math.floor(configuredPinnedBudget) : adaptiveBudget.pinnedState));
396696
396829
  const pinnedMessages = this._pinnedStructuredMemoryMessages(pinnedTokenBudget, physicalInputBudget, turn);
@@ -409471,10 +409604,19 @@ ${input.acceptedGoal}`);
409471
409604
  return brief;
409472
409605
  }
409473
409606
  _sourceReadTaskBinding() {
409607
+ const authority = (input) => ({
409608
+ inputId: input.inputId,
409609
+ content: input.content,
409610
+ intent: input.intent,
409611
+ source: input.source,
409612
+ receivedAt: input.receivedAt,
409613
+ taskEpoch: input.taskEpoch,
409614
+ allowTaskReplacement: input.allowTaskReplacement
409615
+ });
409474
409616
  return JSON.stringify({
409475
409617
  goal: this._taskState.originalGoal || this._taskState.goal,
409476
409618
  contract: this._taskObjectiveContract,
409477
- steering: this._activeSteering?.input
409619
+ steering: this._activeSteering ? [this._activeSteering.input, ...this._activeSteering.relatedInputs ?? []].map(authority) : void 0
409478
409620
  });
409479
409621
  }
409480
409622
  /** A successful remote primary may allocate only its own returned tool calls.
@@ -422306,7 +422448,12 @@ ${marker}` : marker);
422306
422448
  success: success !== false,
422307
422449
  identicalToPreviousRun: this._observationLedger.identicalRunsFor(fingerprint2) >= 2
422308
422450
  });
422309
- return this.buildToolMessage(this.compactDiscoveryOutputForModel(toolName, args, output, success, toolCallId, provenance2?.fullReadAdmitted), toolCallId, toolName);
422451
+ const compact4 = this.compactDiscoveryOutputForModel(toolName, args, output, success, toolCallId, provenance2?.fullReadAdmitted);
422452
+ const sourceRead = success === true && toolName === "file_read" ? this._historyObservations.get(toolCallId)?.sourceRead : void 0;
422453
+ const precondition = sourceRead ? `[FILE_EDIT_PRECONDITION]
422454
+ ${JSON.stringify({ path: this._normalizeEvidencePath(sourceRead.path), expected_hash: sourceRead.hash })}
422455
+ ` : "";
422456
+ return this.buildToolMessage(precondition + compact4, toolCallId, toolName);
422310
422457
  }
422311
422458
  compactDiscoveryOutputForModel(toolName, args, output, success, toolCallId, fullReadAdmitted) {
422312
422459
  if (success !== true)
@@ -422606,13 +422753,16 @@ ${marker}` : marker);
422606
422753
  return { args: { ...args, expected_hash: fresh.hash }, patchedCount: 1 };
422607
422754
  }
422608
422755
  if (toolName === "file_write" || toolName === "file_patch") {
422609
- if (this._normalizeExpectedHashValue(this._rawExpectedHashValue(args))) {
422610
- return { args, patchedCount: 0 };
422611
- }
422756
+ const supplied = this._normalizeExpectedHashValue(this._rawExpectedHashValue(args));
422612
422757
  const path7 = this.extractPrimaryToolPath(args);
422613
422758
  const fresh = path7 ? this._freshReadHashForEditPath(path7) : null;
422614
422759
  if (!fresh)
422615
422760
  return { args, patchedCount: 0 };
422761
+ if (supplied) {
422762
+ const readArtifact = [...this._historyObservations].some(([id5, observation]) => observation.sourceRead && this._normalizeEvidencePath(observation.sourceRead.path) === fresh.key && observation.sourceRead.hash === fresh.hash && this._canonicalAcceptedReceipts.get(id5)?.artifactLocator === `omnius-artifact://sha256/${supplied}`);
422763
+ if (supplied === fresh.hash || !readArtifact)
422764
+ return { args, patchedCount: 0 };
422765
+ }
422616
422766
  return { args: { ...args, expected_hash: fresh.hash }, patchedCount: 1 };
422617
422767
  }
422618
422768
  if (toolName !== "batch_edit" || !Array.isArray(args["edits"])) {
@@ -427795,11 +427945,12 @@ ${description}`
427795
427945
  * until recovery; other transient backend errors use bounded backoff.
427796
427946
  * Returns the response on success, or null if recovery did not apply.
427797
427947
  */
427798
- async waitForTransientRetry(delayMs) {
427948
+ async waitForTransientRetry(delayMs, operationSignal) {
427799
427949
  const signals = [
427800
427950
  this._abortController.signal,
427801
427951
  this._turnAbortController.signal,
427802
- this._inputWaitBoundaryController.signal
427952
+ this._inputWaitBoundaryController.signal,
427953
+ ...operationSignal ? [operationSignal] : []
427803
427954
  ];
427804
427955
  if (signals.some((signal) => signal.aborted))
427805
427956
  return;
@@ -1476,17 +1476,38 @@ function nativeCodeContent(source, language) {
1476
1476
  }
1477
1477
  return { content: source, language: selected };
1478
1478
  }
1479
- function nativeCodeHighlights(source) {
1479
+ function nativeCodeHighlights(source, language) {
1480
1480
  const highlights = [];
1481
+ const selected = nativeCodeLanguage(language);
1482
+ if (selected === "text" || selected === "plaintext") return highlights;
1483
+ if (selected === "diff" || selected === "patch") {
1484
+ for (const match of source.matchAll(/^(?:\+[^\n]*|-[^\n]*|@@[^\n]*|diff [^\n]*)/gm))
1485
+ highlights.push([
1486
+ match.index,
1487
+ match.index + match[0].length,
1488
+ match[0][0] === "+" ? "diff.add" : match[0][0] === "-" ? "diff.delete" : "diff.header"
1489
+ ]);
1490
+ return highlights;
1491
+ }
1481
1492
  const tokens = /("(?:\\.|[^"\\])*"?|'(?:\\.|[^'\\])*'?|`(?:\\.|[^`\\])*`?)|(\/\/[^\n]*|\/\*[\s\S]*?(?:\*\/|$)|\#[^\n]*)|\b(true|false|null|None|True|False|nil)\b|\b(const|let|var|function|class|def|return|if|else|elif|for|while|in|import|from|export|async|await|try|catch|except|throw|raise|new|public|private|static|void|int|bool|struct|enum|fn|pub|use|match|impl|package|func|select|switch|case|break|continue|end|do|then|fi|done)\b|(?<![\w])(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|([{}\[\](),:;])/g;
1482
1493
  for (const match of source.matchAll(tokens)) {
1483
1494
  const start = match.index, end = start + match[0].length;
1484
1495
  const group = match[1] ? /^\s*:/.test(source.slice(end)) ? "property" : "string" : match[2] ? "comment" : match[3] ? "constant" : match[4] ? "keyword" : match[5] ? "number" : "punctuation";
1485
1496
  highlights.push([start, end, group]);
1486
1497
  }
1487
- return highlights;
1498
+ if (selected === "bash" || selected === "zsh" || selected === "fish") {
1499
+ const add = (start, token, group) => {
1500
+ if (!highlights.some(([from, to]) => from < start + token.length && to > start))
1501
+ highlights.push([start, start + token.length, group]);
1502
+ };
1503
+ for (const match of source.matchAll(/(?:^|[\n;|&])\s*(?:\$\s+)?(?:[A-Za-z_]\w*=\S+\s+)*([A-Za-z_./][\w./:+-]*)/g))
1504
+ add(match.index + match[0].lastIndexOf(match[1]), match[1], "function");
1505
+ for (const match of source.matchAll(/(?:^|\s)(--?[A-Za-z][\w-]*)/g))
1506
+ add(match.index + match[0].indexOf(match[1]), match[1], "attribute");
1507
+ }
1508
+ return highlights.sort((a, b) => a[0] - b[0]);
1488
1509
  }
1489
- function installNativeSyntax(syntax, colors) {
1510
+ function installNativeSyntax(syntax, colors, nativeColor2) {
1490
1511
  const base = { fg: colors.foreground, bg: colors.background };
1491
1512
  for (const [name, attributes] of Object.entries({
1492
1513
  default: {},
@@ -1500,21 +1521,24 @@ function installNativeSyntax(syntax, colors) {
1500
1521
  "markup.list": { dim: true },
1501
1522
  "markup.quote": { dim: true },
1502
1523
  comment: { dim: true, italic: true },
1503
- keyword: { bold: true },
1504
- property: { bold: true },
1505
- "string.special.key": { bold: true },
1506
- string: { italic: true },
1507
- "string.escape": { bold: true },
1508
- number: { bold: true },
1509
- boolean: { bold: true },
1510
- constant: { bold: true },
1511
- function: { bold: true },
1512
- type: { underline: true },
1524
+ keyword: { fg: nativeColor2(5), bold: true },
1525
+ property: { fg: nativeColor2(6), bold: true },
1526
+ "string.special.key": { fg: nativeColor2(6), bold: true },
1527
+ string: { fg: nativeColor2(2) },
1528
+ "string.escape": { fg: nativeColor2(3), bold: true },
1529
+ number: { fg: nativeColor2(3), bold: true },
1530
+ boolean: { fg: nativeColor2(3), bold: true },
1531
+ constant: { fg: nativeColor2(3), bold: true },
1532
+ function: { fg: nativeColor2(4), bold: true },
1533
+ type: { fg: nativeColor2(6) },
1513
1534
  punctuation: { dim: true },
1514
1535
  operator: {},
1515
1536
  variable: {},
1516
- tag: { bold: true },
1517
- attribute: { italic: true }
1537
+ tag: { fg: nativeColor2(4), bold: true },
1538
+ attribute: { fg: nativeColor2(6) },
1539
+ "diff.add": { fg: nativeColor2(2) },
1540
+ "diff.delete": { fg: nativeColor2(1) },
1541
+ "diff.header": { fg: nativeColor2(6), bold: true }
1518
1542
  }))
1519
1543
  syntax.registerStyle(name, { ...base, ...attributes });
1520
1544
  }
@@ -1676,14 +1700,14 @@ var NativeBlockView = class {
1676
1700
  return this.spec;
1677
1701
  }
1678
1702
  get trailingSpace() {
1679
- return this.spec.kind === "markdown" && this.spec.presentation === "final-answer" ? 1 : 0;
1703
+ return this.spec.presentation === "final-answer" || this.spec.presentation === "action" && !this.spec.streaming ? 1 : 0;
1680
1704
  }
1681
1705
  get hasVisibleContent() {
1682
1706
  return this.spec.kind !== "column" && this.spec.kind !== "row" || Boolean(this.spec.title || this.spec.text !== void 0 || this.spec.actions?.length || [...this.children?.views.values() ?? []].some((view) => view.hasVisibleContent));
1683
1707
  }
1684
1708
  setTurnSeparation(separate, previousBottom = 0) {
1685
1709
  const answer = this.spec.kind === "markdown" && this.spec.presentation === "final-answer";
1686
- this.root.marginTop = separate ? Math.max(0, 1 - previousBottom) : answer ? 1 : 0;
1710
+ this.root.marginTop = separate || answer ? Math.max(0, 1 - previousBottom) : 0;
1687
1711
  }
1688
1712
  build() {
1689
1713
  const { renderer: renderer2, colors, syntax } = this.context;
@@ -1798,7 +1822,7 @@ var NativeBlockView = class {
1798
1822
  wrapMode: "word",
1799
1823
  selectable: true,
1800
1824
  streaming: this.spec.streaming ?? false,
1801
- onHighlight: (highlights, context) => highlights.length ? void 0 : nativeCodeHighlights(context.content)
1825
+ onHighlight: (highlights, context) => highlights.length ? void 0 : nativeCodeHighlights(context.content, value.language)
1802
1826
  });
1803
1827
  }
1804
1828
  });
@@ -1823,7 +1847,7 @@ var NativeBlockView = class {
1823
1847
  selectable: true,
1824
1848
  wrapMode: "word",
1825
1849
  drawUnstyledText: true,
1826
- onHighlight: (highlights, context) => highlights.length ? void 0 : nativeCodeHighlights(context.content)
1850
+ onHighlight: (highlights, context) => highlights.length ? void 0 : nativeCodeHighlights(context.content, this.spec.language)
1827
1851
  });
1828
1852
  this.body.add(this.text);
1829
1853
  } else if (spec.text !== void 0) {
@@ -1891,7 +1915,8 @@ var NativeBlockView = class {
1891
1915
  if (rebuild) this.reset();
1892
1916
  this.signature = signature;
1893
1917
  const finalAnswer = spec.kind === "markdown" && spec.presentation === "final-answer";
1894
- this.root.marginTop = this.root.marginBottom = finalAnswer ? 1 : 0;
1918
+ this.root.marginTop = finalAnswer ? 1 : 0;
1919
+ this.root.marginBottom = this.trailingSpace;
1895
1920
  if (spec.collapsed !== this.previousModelCollapsed) {
1896
1921
  this.collapsed = spec.collapsed ?? false;
1897
1922
  this.previousModelCollapsed = spec.collapsed;
@@ -3315,68 +3340,6 @@ import {
3315
3340
  TextRenderable as TextRenderable8
3316
3341
  } from "@opentui/core";
3317
3342
 
3318
- // packages/cli/src/tui/native/components/device-history.ts
3319
- var DeviceHistory = class {
3320
- samples = [];
3321
- append(sample) {
3322
- if (!Number.isFinite(sample.at) || sample.at <= (this.samples.at(-1)?.at ?? 0)) return;
3323
- this.samples.push(sample);
3324
- if (this.samples.length > 120) this.samples.splice(0, this.samples.length - 120);
3325
- }
3326
- };
3327
- function deviceHistorySparkline(samples, field, width) {
3328
- const columns = Math.max(0, Math.floor(width));
3329
- const latest = samples.at(-1)?.at;
3330
- const values = Array(columns).fill(void 0);
3331
- if (latest !== void 0) for (const sample of samples) {
3332
- const x = columns - 1 - Math.round((latest - sample.at) / 2e3);
3333
- if (x >= 0 && x < columns) values[x] = sample[field];
3334
- }
3335
- return values.map((value) => value === void 0 || !Number.isFinite(value) || value < 0 ? " " : "▁▂▃▄▅▆▇█"[Math.round(Math.min(100, value) * 7 / 100)]).join("");
3336
- }
3337
- function deviceHistoryGraph(samples, field, width) {
3338
- const columns = Math.max(0, Math.floor(width) - 5), pixels = columns * 2;
3339
- if (columns < 2) return "";
3340
- const cells = Array.from({ length: 3 }, () => Array(columns).fill(0));
3341
- const latest = samples.at(-1)?.at;
3342
- const dots = [[1, 8], [2, 16], [4, 32], [64, 128]];
3343
- const point = (x, y) => {
3344
- if (x < 0 || x >= pixels || y < 0 || y >= 12) return;
3345
- cells[Math.floor(y / 4)][Math.floor(x / 2)] |= dots[y % 4][x % 2];
3346
- };
3347
- let previous;
3348
- if (latest !== void 0) for (const sample of samples) {
3349
- const value = sample[field];
3350
- const x = pixels - 1 - Math.round((latest - sample.at) / 1e3);
3351
- if (x < 0) {
3352
- previous = void 0;
3353
- continue;
3354
- }
3355
- if (value === void 0 || !Number.isFinite(value) || value < 0) {
3356
- previous = void 0;
3357
- continue;
3358
- }
3359
- const y = Math.round(11 * (1 - Math.min(100, value) / 100));
3360
- if (previous && sample.at - previous.at <= 5e3) {
3361
- const distance = Math.max(1, Math.abs(x - previous.x), Math.abs(y - previous.y));
3362
- for (let step = 0; step <= distance; step++) point(Math.round(previous.x + (x - previous.x) * step / distance), Math.round(previous.y + (y - previous.y) * step / distance));
3363
- } else point(x, y);
3364
- previous = { x, y, at: sample.at };
3365
- }
3366
- const labels = ["100%│", " 50%│", " 0%└"];
3367
- return cells.map((row, y) => labels[y] + row.map((bits, x) => bits ? String.fromCodePoint(10240 + bits) : x % 4 === 0 ? "·" : " ").join("")).join("\n");
3368
- }
3369
-
3370
- // packages/cli/src/tui/native/components/task-notes.ts
3371
- import {
3372
- BoxRenderable as BoxRenderable6,
3373
- CliRenderEvents as CliRenderEvents4,
3374
- RenderableEvents as RenderableEvents3,
3375
- ScrollBoxRenderable as ScrollBoxRenderable3,
3376
- TextAttributes as TextAttributes5,
3377
- TextRenderable as TextRenderable5
3378
- } from "@opentui/core";
3379
-
3380
3343
  // packages/cli/src/tui/native/components/instrument-format.ts
3381
3344
  var graphemes2 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
3382
3345
  function formatSignalDivider(width, geometry = { direction: "top" }) {
@@ -3415,6 +3378,11 @@ function formatTelemetryRow(label3, value, width, reserved = 12) {
3415
3378
  function instrumentNumber(value, precision = 0, unit = "") {
3416
3379
  return value === void 0 || !Number.isFinite(value) || value < 0 ? "--" : `${value.toFixed(Math.max(0, Math.min(6, precision)))}${unit}`;
3417
3380
  }
3381
+ function utilizationColor(value, maximum = 100) {
3382
+ if (value === void 0 || !Number.isFinite(value) || value < 0 || !Number.isFinite(maximum) || maximum <= 0) return void 0;
3383
+ const percent = value / maximum * 100;
3384
+ return percent < 50 ? "index:2" : percent < 80 ? "index:3" : "index:1";
3385
+ }
3418
3386
  function formatSignalMeter(value, maximum, width = 8) {
3419
3387
  const cells = Math.max(1, Math.floor(width));
3420
3388
  if (value === void 0 || maximum === void 0 || !Number.isFinite(value) || !Number.isFinite(maximum) || value < 0 || maximum <= 0)
@@ -3442,7 +3410,72 @@ function instrumentStatus(value) {
3442
3410
  return status.toUpperCase();
3443
3411
  }
3444
3412
 
3413
+ // packages/cli/src/tui/native/components/device-history.ts
3414
+ var DeviceHistory = class {
3415
+ samples = [];
3416
+ append(sample) {
3417
+ if (!Number.isFinite(sample.at) || sample.at <= (this.samples.at(-1)?.at ?? 0)) return;
3418
+ this.samples.push(sample);
3419
+ if (this.samples.length > 120) this.samples.splice(0, this.samples.length - 120);
3420
+ }
3421
+ };
3422
+ function deviceHistorySparklineSpans(samples, field, width) {
3423
+ const columns = Math.max(0, Math.floor(width));
3424
+ const latest = samples.at(-1)?.at;
3425
+ const values = Array(columns).fill(void 0);
3426
+ if (latest !== void 0) for (const sample of samples) {
3427
+ const x = columns - 1 - Math.round((latest - sample.at) / 2e3);
3428
+ if (x >= 0 && x < columns) values[x] = sample[field];
3429
+ }
3430
+ return values.map((value) => ({ text: value === void 0 || !Number.isFinite(value) || value < 0 ? " " : "▁▂▃▄▅▆▇█"[Math.round(Math.min(100, value) * 7 / 100)], fg: utilizationColor(value) }));
3431
+ }
3432
+ function deviceHistoryGraphSpans(samples, field, width) {
3433
+ const columns = Math.max(0, Math.floor(width) - 5), pixels = columns * 2;
3434
+ if (columns < 2) return [];
3435
+ const cells = Array.from({ length: 3 }, () => Array(columns).fill(0));
3436
+ const levels = Array.from({ length: 3 }, () => Array(columns).fill(-1));
3437
+ const latest = samples.at(-1)?.at;
3438
+ const dots = [[1, 8], [2, 16], [4, 32], [64, 128]];
3439
+ const point = (x, y, value) => {
3440
+ if (x < 0 || x >= pixels || y < 0 || y >= 12) return;
3441
+ cells[Math.floor(y / 4)][Math.floor(x / 2)] |= dots[y % 4][x % 2];
3442
+ levels[Math.floor(y / 4)][Math.floor(x / 2)] = Math.max(levels[Math.floor(y / 4)][Math.floor(x / 2)], value);
3443
+ };
3444
+ let previous;
3445
+ if (latest !== void 0) for (const sample of samples) {
3446
+ const value = sample[field];
3447
+ const x = pixels - 1 - Math.round((latest - sample.at) / 1e3);
3448
+ if (x < 0) {
3449
+ previous = void 0;
3450
+ continue;
3451
+ }
3452
+ if (value === void 0 || !Number.isFinite(value) || value < 0) {
3453
+ previous = void 0;
3454
+ continue;
3455
+ }
3456
+ const y = Math.round(11 * (1 - Math.min(100, value) / 100));
3457
+ if (previous && sample.at - previous.at <= 5e3) {
3458
+ const distance = Math.max(1, Math.abs(x - previous.x), Math.abs(y - previous.y));
3459
+ for (let step = 0; step <= distance; step++) point(Math.round(previous.x + (x - previous.x) * step / distance), Math.round(previous.y + (y - previous.y) * step / distance), previous.value + (value - previous.value) * step / distance);
3460
+ } else point(x, y, value);
3461
+ previous = { x, y, at: sample.at, value };
3462
+ }
3463
+ const labels = ["100%│", " 50%│", " 0%└"];
3464
+ return cells.flatMap((row, y) => [{ text: (y ? "\n" : "") + labels[y] }, ...row.map((bits, x) => ({
3465
+ text: bits ? String.fromCodePoint(10240 + bits) : x % 4 === 0 ? "·" : " ",
3466
+ fg: bits ? utilizationColor(levels[y][x]) : void 0
3467
+ }))]);
3468
+ }
3469
+
3445
3470
  // packages/cli/src/tui/native/components/task-notes.ts
3471
+ import {
3472
+ BoxRenderable as BoxRenderable6,
3473
+ CliRenderEvents as CliRenderEvents4,
3474
+ RenderableEvents as RenderableEvents3,
3475
+ ScrollBoxRenderable as ScrollBoxRenderable3,
3476
+ TextAttributes as TextAttributes5,
3477
+ TextRenderable as TextRenderable5
3478
+ } from "@opentui/core";
3446
3479
  var marks = ["▨", "▧", "▥", "▦"];
3447
3480
  var reducedMotion = () => process.env["OMNIUS_TUI_REDUCE_MOTION"] === "1" || process.env["REDUCE_MOTION"] === "1";
3448
3481
  var safe = (value) => typeof value === "string" ? plainText(value) : "";
@@ -5020,13 +5053,15 @@ var TelemetryRow = class extends TextRenderable8 {
5020
5053
  reserved;
5021
5054
  label;
5022
5055
  value = "--";
5056
+ valueColor;
5023
5057
  onResize(width, height) {
5024
5058
  super.onResize(width, height);
5025
5059
  this.refresh();
5026
5060
  }
5027
- update(value, label3 = this.label) {
5061
+ update(value, label3 = this.label, utilization) {
5028
5062
  this.label = label3;
5029
5063
  this.value = value;
5064
+ this.valueColor = utilizationColor(utilization);
5030
5065
  this.refresh();
5031
5066
  }
5032
5067
  refresh() {
@@ -5036,7 +5071,8 @@ var TelemetryRow = class extends TextRenderable8 {
5036
5071
  this.width,
5037
5072
  this.reserved
5038
5073
  );
5039
- if (this.plainText !== next) this.content = next;
5074
+ const start = next.endsWith(this.value) ? next.length - this.value.length : 0;
5075
+ this.content = styledText([{ text: next.slice(0, start) }, { text: next.slice(start), fg: this.valueColor }]);
5040
5076
  }
5041
5077
  };
5042
5078
  var SignalMeter = class extends TelemetryRow {
@@ -5294,15 +5330,15 @@ var DeviceMonitor = class extends BoxRenderable9 {
5294
5330
  }
5295
5331
  return `${instrumentNumber(value, unit ? 1 : 0)} ${units[unit]}`;
5296
5332
  };
5297
- const set = (key, label3, value) => this.sections.get(key).readings.get(label3).update(value);
5298
- set("cpu", "LOAD", formatSignalMeter(system?.cpu.utilization, 100, 6));
5333
+ const set = (key, label3, value, utilization) => this.sections.get(key).readings.get(label3).update(value, label3, utilization);
5334
+ set("cpu", "LOAD", formatSignalMeter(system?.cpu.utilization, 100, 6), system?.cpu.utilization);
5299
5335
  set("cpu", "CORES", number(system?.cpu.cores));
5300
5336
  set("cpu", "SAMPLE", sample(system?.cpu.status));
5301
5337
  set("memory", "USED", ratio(system?.memory.usedGB, system?.memory.totalGB));
5302
5338
  const free = system?.memory.totalGB !== void 0 && system.memory.usedGB !== void 0 ? Math.max(0, system.memory.totalGB - system.memory.usedGB) : void 0;
5303
5339
  set("memory", "FREE", number(free, " GiB"));
5304
- set("memory", "LOAD", formatSignalMeter(system?.memory.utilization, 100, 6));
5305
- set("disk", "SPACE USED", number(system?.disk.utilization, "%"));
5340
+ set("memory", "LOAD", formatSignalMeter(system?.memory.utilization, 100, 6), system?.memory.utilization);
5341
+ set("disk", "SPACE USED", number(system?.disk.utilization, "%"), system?.disk.utilization);
5306
5342
  set("disk", "USED", ratio(system?.disk.usedGB, system?.disk.totalGB));
5307
5343
  set("disk", "FREE", number(system?.disk.freeGB, " GiB"));
5308
5344
  set("network", "RECEIVE", rate(system?.network.rxBytesPerSec));
@@ -5437,10 +5473,10 @@ var DeviceMonitor = class extends BoxRenderable9 {
5437
5473
  if (row.title.focused && !selectable) this.heading.focus();
5438
5474
  row.title.focusable = selectable;
5439
5475
  row.title.attributes = row.title.focused ? TextAttributes8.INVERSE : device.preferred ? TextAttributes8.BOLD : selectable ? 0 : TextAttributes8.DIM;
5440
- row.load.update(formatSignalMeter(device.utilization, 100, 6));
5476
+ row.load.update(formatSignalMeter(device.utilization, 100, 6), "LOAD", device.utilization);
5441
5477
  const used = device.memoryUsedMB === void 0 ? "--" : instrumentNumber(device.memoryUsedMB / 1024, 1);
5442
5478
  const total = device.memoryTotalMB === void 0 || device.memoryTotalMB <= 0 ? "--" : instrumentNumber(device.memoryTotalMB / 1024, 1);
5443
- row.memory.update(`${used}/${total} GiB`, device.unifiedMemory ? "UMA" : "VRAM");
5479
+ row.memory.update(`${used}/${total} GiB`, device.unifiedMemory ? "UMA" : "VRAM", device.memoryUsedMB !== void 0 && device.memoryTotalMB !== void 0 && device.memoryTotalMB > 0 ? device.memoryUsedMB / device.memoryTotalMB * 100 : void 0);
5444
5480
  row.reason.content = device.policyReason ?? "";
5445
5481
  row.reason.visible = Boolean(device.policyReason);
5446
5482
  }
@@ -5522,12 +5558,15 @@ var DeviceMonitor = class extends BoxRenderable9 {
5522
5558
  const value = instrumentNumber(current, 0, "%");
5523
5559
  const caption = `${label3}${primary?.index ?? "-"}`;
5524
5560
  const plotWidth = Math.max(0, this.width - caption.length - value.length - 2);
5525
- const next = `${caption} ${deviceHistorySparkline(compactHistory, field, plotWidth)} ${value}`;
5526
- if (element.plainText !== next) element.content = next;
5561
+ element.content = styledText([
5562
+ { text: `${caption} ` },
5563
+ ...deviceHistorySparklineSpans(compactHistory, field, plotWidth),
5564
+ { text: ` ${value}`, fg: utilizationColor(current) }
5565
+ ]);
5527
5566
  }
5528
5567
  if (!primary && data?.system) {
5529
- this.compactLoad.content = `CPU ${formatSignalMeter(data.system.cpu.utilization, 100, 6)}`;
5530
- this.compactMemory.content = `MEM ${formatSignalMeter(data.system.memory.utilization, 100, 6)}`;
5568
+ this.compactLoad.content = styledText([{ text: "CPU " }, { text: formatSignalMeter(data.system.cpu.utilization, 100, 6), fg: utilizationColor(data.system.cpu.utilization) }]);
5569
+ this.compactMemory.content = styledText([{ text: "MEM " }, { text: formatSignalMeter(data.system.memory.utilization, 100, 6), fg: utilizationColor(data.system.memory.utilization) }]);
5531
5570
  }
5532
5571
  for (const device of devices) {
5533
5572
  const row = this.rows.get(device.uuid);
@@ -5535,8 +5574,7 @@ var DeviceMonitor = class extends BoxRenderable9 {
5535
5574
  const state = device.enabled === void 0 ? "--" : device.enabled ? "ON" : "OFF";
5536
5575
  row.title.content = formatTelemetryRow(`GPU ${device.index} ${device.name}`, `${state}${device.preferred ? " *" : ""}`, row.root.width, 6);
5537
5576
  for (const [plot, field] of [[row.loadGraph, "load"], [row.memoryGraph, "memory"]]) {
5538
- const next = deviceHistoryGraph(row.history.samples, field, row.root.width);
5539
- if (plot.plainText !== next) plot.content = next;
5577
+ plot.content = styledText(deviceHistoryGraphSpans(row.history.samples, field, row.root.width));
5540
5578
  }
5541
5579
  }
5542
5580
  }
@@ -6046,6 +6084,7 @@ var InstrumentRail = class extends BoxRenderable9 {
6046
6084
 
6047
6085
  // packages/cli/src/tui/command-registry.ts
6048
6086
  var COMMAND_SIGNATURES = [
6087
+ ["/enhance <prompt>", "Enhance a prompt into the input editor"],
6049
6088
  ["/model", "Select from available models"],
6050
6089
  ["/model <name>", "Switch to a specific model"],
6051
6090
  ["/models", "List all available models"],
@@ -6722,6 +6761,7 @@ var PLANNED_SIGNATURES = [
6722
6761
  implementationStatus: "planned"
6723
6762
  }));
6724
6763
  var CATEGORY_OVERRIDES = {
6764
+ enhance: "ui",
6725
6765
  model: "model",
6726
6766
  models: "model",
6727
6767
  endpoint: "network",
@@ -6878,6 +6918,7 @@ var ALIASES = {
6878
6918
  platforms: ["gateway"]
6879
6919
  };
6880
6920
  var USER_ONLY = /* @__PURE__ */ new Set([
6921
+ "enhance",
6881
6922
  "provider",
6882
6923
  "fallback",
6883
6924
  "quit",
@@ -6972,6 +7013,7 @@ var DESTRUCTIVE = /* @__PURE__ */ new Set([
6972
7013
  "ollama"
6973
7014
  ]);
6974
7015
  var NETWORKED = /* @__PURE__ */ new Set([
7016
+ "enhance",
6975
7017
  "provider",
6976
7018
  "endpoint",
6977
7019
  "update",
@@ -7053,7 +7095,7 @@ var REST_BLOCKED = /* @__PURE__ */ new Set([
7053
7095
  "paste",
7054
7096
  "indicator"
7055
7097
  ]);
7056
- var LOCAL_TUI_ONLY = /* @__PURE__ */ new Set(["indicator", "compacted", "gpu", "memory", "provider"]);
7098
+ var LOCAL_TUI_ONLY = /* @__PURE__ */ new Set(["indicator", "compacted", "gpu", "memory", "provider", "enhance"]);
7057
7099
  var CANONICAL_BY_ALIAS = /* @__PURE__ */ new Map();
7058
7100
  for (const [canonical, aliases2] of Object.entries(ALIASES)) {
7059
7101
  for (const alias of aliases2) CANONICAL_BY_ALIAS.set(alias, canonical);
@@ -7684,6 +7726,8 @@ var NativeTabStrip = class extends BoxRenderable11 {
7684
7726
  syncing = false;
7685
7727
  reveal;
7686
7728
  colors;
7729
+ pulseTimer;
7730
+ pulseBright = true;
7687
7731
  naturalWidth = 0;
7688
7732
  update(items, activeId, busy = false) {
7689
7733
  const signature = JSON.stringify([items, activeId, busy]);
@@ -7780,7 +7824,8 @@ var NativeTabStrip = class extends BoxRenderable11 {
7780
7824
  this.renderer.requestRender();
7781
7825
  }
7782
7826
  style(entry) {
7783
- entry.button.attributes = (entry.active ? TextAttributes10.BOLD | TextAttributes10.UNDERLINE : entry.blocked ? TextAttributes10.DIM : 0) | (entry.button.focused ? TextAttributes10.INVERSE : 0);
7827
+ entry.button.attributes = (entry.active ? TextAttributes10.BOLD | TextAttributes10.UNDERLINE : entry.blocked ? TextAttributes10.DIM : 0) | (entry.action.running ? this.pulseBright ? TextAttributes10.BOLD : TextAttributes10.DIM : 0) | (entry.button.focused ? TextAttributes10.INVERSE : 0);
7828
+ entry.button.fg = entry.action.running ? nativeColor(6) : this.colors.foreground;
7784
7829
  if (entry.close) entry.close.attributes = (entry.closeBlocked || !entry.close.focused ? TextAttributes10.DIM : 0) | (entry.close.focused ? TextAttributes10.INVERSE : 0);
7785
7830
  }
7786
7831
  handleKey(entry, key, close2 = false) {
@@ -7802,6 +7847,7 @@ var NativeTabStrip = class extends BoxRenderable11 {
7802
7847
  key.stopPropagation();
7803
7848
  }
7804
7849
  syncScroll = () => {
7850
+ this.syncPulse();
7805
7851
  if (!this.visible || this.width < 1) return;
7806
7852
  const overflow = this.naturalWidth > this.width;
7807
7853
  if (this.rail.visible !== overflow) {
@@ -7818,6 +7864,27 @@ var NativeTabStrip = class extends BoxRenderable11 {
7818
7864
  this.rail.value = this.scroll.scrollLeft;
7819
7865
  this.syncing = false;
7820
7866
  };
7867
+ syncPulse() {
7868
+ let visible2 = this.visible && this.width > 0;
7869
+ for (let parent = this.parent; parent && visible2; parent = parent.parent) visible2 = parent.visible;
7870
+ const animate = visible2 && process.env["OMNIUS_TUI_REDUCE_MOTION"] !== "1" && process.env["REDUCE_MOTION"] !== "1" && [...this.buttons.values()].some((entry) => entry.action.running);
7871
+ if (animate && !this.pulseTimer) {
7872
+ this.pulseTimer = setInterval(() => {
7873
+ this.syncPulse();
7874
+ if (!this.pulseTimer) return;
7875
+ this.pulseBright = !this.pulseBright;
7876
+ for (const entry of this.buttons.values()) if (entry.action.running) this.style(entry);
7877
+ this.renderer.requestRender();
7878
+ }, 600);
7879
+ this.pulseTimer.unref?.();
7880
+ } else if (!animate && this.pulseTimer) {
7881
+ clearInterval(this.pulseTimer);
7882
+ this.pulseTimer = void 0;
7883
+ this.pulseBright = true;
7884
+ for (const entry of this.buttons.values()) this.style(entry);
7885
+ this.renderer.requestRender();
7886
+ }
7887
+ }
7821
7888
  applyTheme(colors) {
7822
7889
  this.colors = colors;
7823
7890
  for (const { button, close: close2 } of this.buttons.values()) {
@@ -7830,12 +7897,15 @@ var NativeTabStrip = class extends BoxRenderable11 {
7830
7897
  }
7831
7898
  styleNativeScrollbars(this.scroll, colors);
7832
7899
  styleNativeSlider(this.rail, colors);
7900
+ for (const entry of this.buttons.values()) this.style(entry);
7833
7901
  }
7834
7902
  restoreOffset(offset2) {
7835
7903
  this.reveal = void 0;
7836
7904
  this.scroll.scrollLeft = offset2;
7837
7905
  }
7838
7906
  destroySelf() {
7907
+ if (this.pulseTimer) clearInterval(this.pulseTimer);
7908
+ this.pulseTimer = void 0;
7839
7909
  this.renderer.off(CliRenderEvents7.FRAME, this.syncScroll);
7840
7910
  super.destroySelf();
7841
7911
  }
@@ -8074,7 +8144,6 @@ var NativeFrontend = class {
8074
8144
  this.sessionPicker.on("blurred", stylePicker);
8075
8145
  this.sessionRow.add(this.sessionPicker);
8076
8146
  this.routeWarning = new TextRenderable11(renderer2, { id: "omnius-route-warning", content: "", width: "100%", wrapMode: "word", fg: colors.warning, attributes: TextAttributes11.BOLD | TextAttributes11.UNDERLINE, visible: false, flexShrink: 0 });
8077
- this.root.add(this.routeWarning);
8078
8147
  this.taskPane = new BoxRenderable12(renderer2, { id: "omnius-tasks", width: "100%", flexDirection: "column", maxHeight: 6, flexShrink: 0, overflow: "hidden", visible: false });
8079
8148
  this.tasks = new NativeBlockList(this.context, this.taskPane);
8080
8149
  this.root.add(this.taskPane);
@@ -8090,6 +8159,7 @@ var NativeFrontend = class {
8090
8159
  this.root.add(this.body);
8091
8160
  this.transcriptPane = new BoxRenderable12(renderer2, { id: "omnius-transcript-pane", flexDirection: "column", flexGrow: 1, flexShrink: 1, minWidth: 0, minHeight: 1 });
8092
8161
  this.body.add(this.transcriptPane);
8162
+ this.transcriptPane.add(this.routeWarning);
8093
8163
  this.scroll = new ScrollBoxRenderable8(renderer2, {
8094
8164
  id: "omnius-conversation",
8095
8165
  flexGrow: 1,
@@ -8650,7 +8720,7 @@ var NativeFrontend = class {
8650
8720
  this.headerSignature = "";
8651
8721
  this.metricsActionsSignature = "";
8652
8722
  const colors = this.context.colors = palette(theme);
8653
- installNativeSyntax(this.context.syntax, colors);
8723
+ installNativeSyntax(this.context.syntax, colors, nativeColor);
8654
8724
  this.root.backgroundColor = colors.background;
8655
8725
  this.header.backgroundColor = this.footer.backgroundColor = colors.background;
8656
8726
  this.header.borderColor = this.footer.borderColor = this.embeddedPane.borderColor = colors.border;
@@ -23343,6 +23343,66 @@
23343
23343
  "Allowing an autonomous agent to invoke it without an explicit user action"
23344
23344
  ]
23345
23345
  },
23346
+ {
23347
+ "id": "command.enhance",
23348
+ "kind": "command",
23349
+ "title": "/enhance",
23350
+ "summary": "Enhance a prompt into the input editor",
23351
+ "aliases": [
23352
+ "/enhance",
23353
+ "enhance"
23354
+ ],
23355
+ "keywords": [
23356
+ "command",
23357
+ "ui",
23358
+ "enhance"
23359
+ ],
23360
+ "maturity": "stable",
23361
+ "layer": "interface",
23362
+ "audiences": [
23363
+ "user",
23364
+ "coding-agent",
23365
+ "integrator"
23366
+ ],
23367
+ "interfaces": [
23368
+ {
23369
+ "type": "tui",
23370
+ "target": "/enhance"
23371
+ }
23372
+ ],
23373
+ "references": [
23374
+ {
23375
+ "type": "source",
23376
+ "target": "packages/cli/src/tui/command-registry.ts",
23377
+ "relation": "registry"
23378
+ }
23379
+ ],
23380
+ "signatures": [
23381
+ {
23382
+ "signature": "/enhance <prompt>",
23383
+ "description": "Enhance a prompt into the input editor"
23384
+ }
23385
+ ],
23386
+ "subcommands": [],
23387
+ "implementation_status": "implemented",
23388
+ "surfaces": {
23389
+ "tui": true,
23390
+ "rest": false,
23391
+ "gateway": false,
23392
+ "agentTool": false
23393
+ },
23394
+ "safety": {
23395
+ "userOnly": true,
23396
+ "destructive": false,
23397
+ "networked": true,
23398
+ "secretBearing": false,
23399
+ "profileGated": false
23400
+ },
23401
+ "avoid_when": [
23402
+ "Calling it through the REST command proxy; this command is not REST-exposed",
23403
+ "Allowing an autonomous agent to invoke it without an explicit user action"
23404
+ ]
23405
+ },
23346
23406
  {
23347
23407
  "id": "command.evaluate",
23348
23408
  "kind": "command",
package/docs/DISCOVERY.md CHANGED
@@ -322,6 +322,7 @@ Daemon equivalents are `GET /v1/discovery/bootstrap`, `GET /v1/discovery?q=<inte
322
322
  | `command.dream` | /dream | Start dream mode - creative idle exploration (writes to .omnius/dreams/) |
323
323
  | `command.emojis` | /emojis | Toggle emoji rendering in TUI messages |
324
324
  | `command.endpoint` | /endpoint | Select an endpoint or provider |
325
+ | `command.enhance` | /enhance | Enhance a prompt into the input editor |
325
326
  | `command.evaluate` | /evaluate | Evaluate last completed task (LLM quality scoring) |
326
327
  | `command.expose` | /expose | Expose local inference via libp2p (default) |
327
328
  | `command.fallback` | /fallback | Show remote inference fallback mode |
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.889",
3
+ "version": "1.0.891",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "omnius",
9
- "version": "1.0.889",
9
+ "version": "1.0.891",
10
10
  "bundleDependencies": [
11
11
  "image-to-ascii"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.889",
3
+ "version": "1.0.891",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/library.js",