@cmmd-center/forge 0.13.1 → 0.13.3

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/bin.mjs CHANGED
@@ -22,7 +22,7 @@ import { createCipheriv, createDecipheriv, createHash, createHmac, createPublicK
22
22
  import * as FS$1 from "node:fs";
23
23
  import fs, { accessSync, chmodSync, constants, createReadStream, existsSync, mkdirSync, mkdtempSync, promises, readFile, readFileSync, readdir, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
24
24
  import * as NodeOS from "node:os";
25
- import $U, { homedir, networkInterfaces, tmpdir } from "node:os";
25
+ import os, { homedir, networkInterfaces, tmpdir } from "node:os";
26
26
  import * as Path$1 from "node:path";
27
27
  import path, { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
28
28
  import { pathToFileURL } from "node:url";
@@ -16520,7 +16520,7 @@ function makeNetServiceShape(createServer = Net.createServer) {
16520
16520
  }
16521
16521
  //#endregion
16522
16522
  //#region ../../packages/shared/src/releaseInfo.generated.ts
16523
- const FORGE_RELEASE_VERSION = "0.13.1";
16523
+ const FORGE_RELEASE_VERSION = "0.13.3";
16524
16524
  //#endregion
16525
16525
  //#region ../../packages/shared/src/hostProcess.ts
16526
16526
  /**
@@ -50194,7 +50194,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
50194
50194
  const min = forceColor || 0;
50195
50195
  if (env.TERM === "dumb") return min;
50196
50196
  if (process$1.platform === "win32") {
50197
- const osRelease = $U.release().split(".");
50197
+ const osRelease = os.release().split(".");
50198
50198
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
50199
50199
  return 1;
50200
50200
  }
@@ -52637,7 +52637,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
52637
52637
  exports.processDetector = void 0;
52638
52638
  const api_1 = (init_esm$1(), __toCommonJS(esm_exports$1));
52639
52639
  const semconv_1 = require_semconv$1();
52640
- const os$3 = __require("os");
52640
+ const os$4 = __require("os");
52641
52641
  /**
52642
52642
  * ProcessDetector will be used to detect the resources related current process running
52643
52643
  * and being instrumented from the NodeJS Process module.
@@ -52659,7 +52659,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
52659
52659
  };
52660
52660
  if (process.argv.length > 1) attributes[semconv_1.ATTR_PROCESS_COMMAND] = process.argv[1];
52661
52661
  try {
52662
- const userInfo = os$3.userInfo();
52662
+ const userInfo = os$4.userInfo();
52663
52663
  attributes[semconv_1.ATTR_PROCESS_OWNER] = userInfo.username;
52664
52664
  } catch (e) {
52665
52665
  api_1.diag.debug(`error obtaining process owner: ${e}`);
@@ -65582,7 +65582,7 @@ function normalizeNumberish(value) {
65582
65582
  }
65583
65583
  //#endregion
65584
65584
  //#region package.json
65585
- var version$1 = "0.13.1";
65585
+ var version$1 = "0.13.3";
65586
65586
  //#endregion
65587
65587
  //#region src/sentry.ts
65588
65588
  const SERVER_APP_NAME = "forge-server";
@@ -74334,7 +74334,7 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
74334
74334
  var fs$6 = __require("fs");
74335
74335
  var path$5 = __require("path");
74336
74336
  var url$1 = __require("url");
74337
- var os$2 = __require("os");
74337
+ var os$3 = __require("os");
74338
74338
  var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
74339
74339
  var vars = process.config && process.config.variables || {};
74340
74340
  var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
@@ -74342,8 +74342,8 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
74342
74342
  var abi = versions.modules;
74343
74343
  if (versions.deno || process.isBun) abi = "unsupported";
74344
74344
  var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
74345
- var arch = process.env.npm_config_arch || os$2.arch();
74346
- var platform = process.env.npm_config_platform || os$2.platform();
74345
+ var arch = process.env.npm_config_arch || os$3.arch();
74346
+ var platform = process.env.npm_config_platform || os$3.platform();
74347
74347
  var libc = process.env.LIBC || (isMusl(platform) ? "musl" : "glibc");
74348
74348
  var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
74349
74349
  var uv = (versions.uv || "").split(".")[0];
@@ -92073,7 +92073,7 @@ const launchDetached = (launch) => gen(function* () {
92073
92073
  });
92074
92074
  const OpenLive = effect(Open, gen(function* () {
92075
92075
  const open = yield* tryPromise({
92076
- try: () => import("./open-D8mGyWmt.mjs"),
92076
+ try: () => import("./open-FIgTDosf.mjs"),
92077
92077
  catch: (cause) => new OpenError$1({
92078
92078
  message: "failed to load browser opener",
92079
92079
  cause
@@ -95829,33 +95829,34 @@ function serializeNativeToolActivity(activity) {
95829
95829
  }
95830
95830
  };
95831
95831
  }
95832
- /** The failure activities `appendProviderFailureActivity` emits, all `provider.*.failed`. */
95833
- function isProviderFailureActivity(activity) {
95834
- return activity.kind.startsWith("provider.") && activity.kind.endsWith(".failed");
95832
+ function isReplicatedFailureActivity(activity) {
95833
+ return activity.kind === "runtime.error" || activity.kind.startsWith("provider.") && activity.kind.endsWith(".failed");
95835
95834
  }
95836
95835
  function failureDetail(activity) {
95837
95836
  const payload = activity.payload;
95838
- if (!payload || typeof payload !== "object" || !("detail" in payload)) return null;
95839
- const detail = payload.detail;
95840
- return typeof detail === "string" && detail.trim() ? detail.trim() : null;
95837
+ if (!payload || typeof payload !== "object") return null;
95838
+ const record = payload;
95839
+ const detail = typeof record.detail === "string" ? record.detail.trim() : "";
95840
+ if (detail) return detail;
95841
+ return (typeof record.message === "string" ? record.message.trim() : "") || null;
95841
95842
  }
95842
95843
  /**
95843
95844
  * Replicates why a turn failed.
95844
95845
  *
95845
- * Without this a failure never crossed the replication boundary — only `tool.`
95846
- * activities were serialized — so durable history could not show one and every
95846
+ * Without this a failure never crossed the replication boundary. Only `tool.`
95847
+ * activities were serialized, so durable history could not show one and every
95847
95848
  * failure reached the user as an endless "Working" spinner. Measured in
95848
95849
  * production on 2026-08-30: zero failure events had EVER been recorded against
95849
95850
  * 652 tool_call rows, which is how a workspace-path block, a broker-token
95850
95851
  * refusal and a dispatch into a deleted directory all looked identical.
95851
95852
  *
95852
- * `error_summary` is used rather than a new kind because both the Forge
95853
- * protocol and CMMD's ingest schema already accept it; nothing here needed a
95854
- * contract change. The detail carries the actionable sentence, so it is joined
95855
- * onto the summary — the event has no separate detail field.
95853
+ * `error_summary` is used because both the Forge protocol and CMMD's ingest
95854
+ * schema already accept it. Provider startup failures store `detail`, while
95855
+ * active runtime failures store `message`. The event has no separate detail
95856
+ * field, so either value is joined onto the summary.
95856
95857
  */
95857
- function serializeProviderFailureActivity(activity) {
95858
- if (!isProviderFailureActivity(activity)) return null;
95858
+ function serializeFailureActivity(activity) {
95859
+ if (!isReplicatedFailureActivity(activity)) return null;
95859
95860
  const summary = text(activity.summary, 4e3);
95860
95861
  if (summary === null) return null;
95861
95862
  const detail = failureDetail(activity);
@@ -96197,7 +96198,7 @@ function isTurnUsageTokens(value) {
96197
96198
  function serializeRuntimeThreadEvents(thread) {
96198
96199
  const messages = thread.messages.flatMap(serializeThreadMessage);
96199
96200
  const failureActivities = thread.activities.flatMap((activity) => {
96200
- const event = serializeProviderFailureActivity(activity);
96201
+ const event = serializeFailureActivity(activity);
96201
96202
  return event === null ? [] : [event];
96202
96203
  });
96203
96204
  const replicaActivities = thread.activities.flatMap((activity) => {
@@ -100459,6 +100460,31 @@ function claudeWriteToken(env = process.env) {
100459
100460
  return accessor.read(env);
100460
100461
  }
100461
100462
  //#endregion
100463
+ //#region ../../packages/shared/src/claudeReadinessReason.ts
100464
+ /**
100465
+ * The reason literals Forge acts on, confirmed against CMMD-36441's readiness
100466
+ * service. If the route renames one, the rename lands here as a fall-through
100467
+ * to null, never as the wrong kind.
100468
+ *
100469
+ * Reading the reason is what makes `stale` legible. CMMD-36441 answers
100470
+ * `credential_reconnect_required` on a `stale` answer that still reports
100471
+ * `connected: true`, and the older `credential_generation_not_applied` on a
100472
+ * `stale` answer that simply has not landed yet. Those want opposite
100473
+ * handling, and both used to get "Reconnect Claude in Settings" because the
100474
+ * guard read only the delivery status.
100475
+ */
100476
+ const CODE_BY_UPSTREAM_REASON$1 = {
100477
+ credential_expired_refreshing: "CREDENTIAL_EXPIRED_REFRESHING",
100478
+ credential_reconnect_required: "CREDENTIAL_RECONNECT_REQUIRED",
100479
+ credential_not_connected: "CREDENTIAL_RECONNECT_REQUIRED",
100480
+ credential_generation_not_applied: "CREDENTIAL_GENERATION_NOT_APPLIED",
100481
+ runtime_unavailable: "RUNTIME_UNAVAILABLE"
100482
+ };
100483
+ function claudeReadinessReasonCode(reason) {
100484
+ if (typeof reason !== "string" || !Object.hasOwn(CODE_BY_UPSTREAM_REASON$1, reason)) return null;
100485
+ return CODE_BY_UPSTREAM_REASON$1[reason] ?? null;
100486
+ }
100487
+ //#endregion
100462
100488
  //#region src/egress/providerDeliveryReceipt.ts
100463
100489
  const PROVIDER_ACCOUNT_IDENTITY$2 = /^pai_v1_[A-Za-z0-9_-]{43}$/;
100464
100490
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
@@ -100633,82 +100659,6 @@ function providerDeliveryBindingsEqual(left, right) {
100633
100659
  return classifyProviderDeliveryBindingChange(left, right) === "unchanged";
100634
100660
  }
100635
100661
  //#endregion
100636
- //#region src/provider/claudeReadinessReason.ts
100637
- /**
100638
- * The reason literals Forge has copy for, confirmed against CMMD-36441's
100639
- * readiness service. If the route renames one, the rename lands here as a
100640
- * fall-through to the generic sentence, never as a wrong sentence.
100641
- *
100642
- * Reading the reason is what makes `stale` legible. CMMD-36441 answers
100643
- * `credential_reconnect_required` on a `stale` answer that still reports
100644
- * `connected: true`, and the older `credential_generation_not_applied` on a
100645
- * `stale` answer that simply has not landed yet. Those want opposite
100646
- * sentences, and both used to get "Reconnect Claude in Settings" because the
100647
- * guard read only the delivery status.
100648
- */
100649
- const CODE_BY_UPSTREAM_REASON$1 = {
100650
- credential_expired_refreshing: "CREDENTIAL_EXPIRED_REFRESHING",
100651
- credential_reconnect_required: "CREDENTIAL_RECONNECT_REQUIRED",
100652
- credential_not_connected: "CREDENTIAL_RECONNECT_REQUIRED",
100653
- credential_generation_not_applied: "CREDENTIAL_GENERATION_NOT_APPLIED",
100654
- runtime_unavailable: "RUNTIME_UNAVAILABLE"
100655
- };
100656
- const CLAUDE_NATIVE_CREDENTIAL_UNUSABLE_COPY = "The delivered Claude credential is unavailable or unusable in this runtime.";
100657
- /**
100658
- * An ISO 8601 instant, with or without fractional seconds, UTC or offset.
100659
- * Anchored to nothing on purpose: CMMD wraps the time in a sentence, and the
100660
- * time is the only part of that sentence Forge repeats.
100661
- */
100662
- const ISO_INSTANT_PATTERN = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})/;
100663
- function claudeReadinessReasonCode(reason) {
100664
- if (typeof reason !== "string" || !Object.hasOwn(CODE_BY_UPSTREAM_REASON$1, reason)) return null;
100665
- return CODE_BY_UPSTREAM_REASON$1[reason] ?? null;
100666
- }
100667
- function expiredAtFromReadinessMessage(message) {
100668
- if (typeof message !== "string") return null;
100669
- return ISO_INSTANT_PATTERN.exec(message)?.[0] ?? null;
100670
- }
100671
- function claudeCredentialExpiredTurnCopy(expiredAt) {
100672
- return `The delivered Claude credential expired at ${expiredAt}. CMMD is delivering a refreshed one, so retry this turn in a moment.`;
100673
- }
100674
- function claudeCredentialExpiredCardCopy(expiredAt) {
100675
- return `The delivered Claude credential expired at ${expiredAt}. CMMD is delivering a refreshed one to this runtime.`;
100676
- }
100677
- /**
100678
- * The last allowlisted readiness reason this process saw.
100679
- *
100680
- * A server process serves exactly one runtime, so one slot is the whole store.
100681
- * It holds a reason code and a timestamp, never credential bytes. The provider
100682
- * catalog reads a local credential file and cannot tell an expired snapshot
100683
- * from a blank one, so without this the card can only offer the generic
100684
- * sentence while the guard already knows better.
100685
- */
100686
- let latestVerdict = null;
100687
- /**
100688
- * Remember, or clear, what the readiness answer said.
100689
- *
100690
- * An answer carrying no allowlisted reason clears the slot, which is what makes
100691
- * the card go back to the generic sentence the moment CMMD applies a
100692
- * credential: an applied answer carries no reason.
100693
- */
100694
- function recordClaudeReadinessVerdict(readiness) {
100695
- const code = claudeReadinessReasonCode(readiness.reason);
100696
- latestVerdict = code === null ? null : {
100697
- code,
100698
- expiredAt: expiredAtFromReadinessMessage(readiness.lastErrorMessage)
100699
- };
100700
- }
100701
- /**
100702
- * What the provider status card says about a delivered credential it cannot
100703
- * use. Names the expiry only when a readiness answer supplied the time; a
100704
- * guessed time would be worse than the generic sentence.
100705
- */
100706
- function claudeNativeCredentialUnusableMessage() {
100707
- const verdict = latestVerdict;
100708
- if (verdict?.code === "CREDENTIAL_EXPIRED_REFRESHING" && verdict.expiredAt !== null) return claudeCredentialExpiredCardCopy(verdict.expiredAt);
100709
- return CLAUDE_NATIVE_CREDENTIAL_UNUSABLE_COPY;
100710
- }
100711
- //#endregion
100712
100662
  //#region src/provider/providerReadiness.ts
100713
100663
  const GENERATION_HASH_PATTERN$1 = /^[a-f0-9]{64}$/;
100714
100664
  const STILL_APPLYING_STATUSES = new Set([
@@ -100753,10 +100703,18 @@ async function queryProviderReadiness(input) {
100753
100703
  }
100754
100704
  return classifyClaudeSnapshot(snapshot, sprite);
100755
100705
  }
100756
- function isAppliedClaudeSnapshot(snapshot) {
100757
- return snapshot.connected === true && snapshot.deliveryStatus === "applied" && snapshot.nativeExecutable === true && typeof snapshot.generationId === "string" && snapshot.generationId.trim().length > 0;
100706
+ /**
100707
+ * Whether CMMD allows a turn to start on this runtime. The delivery status is
100708
+ * not part of it: a refresh that failed over a credential the guest verified
100709
+ * and that has not expired reads as failed with nativeExecutable true, and the
100710
+ * turn is the probe (FOR-3085). The generation fence and the receipt below
100711
+ * still bind the answer.
100712
+ */
100713
+ function claudeSnapshotAllowsTurn(snapshot) {
100714
+ return snapshot.connected === true && snapshot.nativeExecutable === true && typeof snapshot.generationId === "string" && snapshot.generationId.trim().length > 0;
100758
100715
  }
100759
- function classifyUnappliedClaudeSnapshot(snapshot) {
100716
+ /** Why a turn may not start, for an answer that does not allow one. */
100717
+ function classifyClaudeTurnRefusal(snapshot) {
100760
100718
  const code = claudeReadinessReasonCode(snapshot.reason);
100761
100719
  if (code === "RUNTIME_UNAVAILABLE") return {
100762
100720
  kind: "not_ready",
@@ -100784,7 +100742,7 @@ function classifyUnappliedClaudeSnapshot(snapshot) {
100784
100742
  };
100785
100743
  }
100786
100744
  function classifyClaudeSnapshot(snapshot, sprite) {
100787
- if (!isAppliedClaudeSnapshot(snapshot)) return classifyUnappliedClaudeSnapshot(snapshot);
100745
+ if (!claudeSnapshotAllowsTurn(snapshot)) return classifyClaudeTurnRefusal(snapshot);
100788
100746
  const generationId = snapshot.generationId.trim();
100789
100747
  if (createHash("sha256").update(generationId).digest("hex") !== sprite.localGenerationHash) return {
100790
100748
  kind: "not_ready",
@@ -188985,7 +188943,7 @@ var Vce = {
188985
188943
  function Ve() {
188986
188944
  return Vce;
188987
188945
  }
188988
- var Us = $U.homedir(), lk = $U.tmpdir(), { env: Vc } = process$1, Yce = (e) => {
188946
+ var Us = os.homedir(), lk = os.tmpdir(), { env: Vc } = process$1, Yce = (e) => {
188989
188947
  let t = path.join(Us, "Library");
188990
188948
  return {
188991
188949
  data: path.join(t, "Application Support", e),
@@ -199185,12 +199143,12 @@ function qZ(e, t) {
199185
199143
  }
199186
199144
  return n;
199187
199145
  }
199188
- var os$1 = "https://code.claude.com/docs/en", kKe = [
199146
+ var os$2 = "https://code.claude.com/docs/en", kKe = [
199189
199147
  {
199190
199148
  matches: (e) => e.path === "permissions.defaultMode" && e.code === "invalid_value",
199191
199149
  tip: {
199192
199150
  suggestion: "Valid modes: \"acceptEdits\" (ask before file changes), \"plan\" (analysis only), \"bypassPermissions\" (auto-accept all), or \"default\" (standard behavior)",
199193
- docLink: `${os$1}/iam#permission-modes`
199151
+ docLink: `${os$2}/iam#permission-modes`
199194
199152
  }
199195
199153
  },
199196
199154
  {
@@ -199205,7 +199163,7 @@ var os$1 = "https://code.claude.com/docs/en", kKe = [
199205
199163
  matches: (e) => e.path.startsWith("env.") && e.code === "invalid_type",
199206
199164
  tip: {
199207
199165
  suggestion: "Environment variables must be strings. Wrap numbers and booleans in quotes. Example: \"DEBUG\": \"true\", \"PORT\": \"3000\"",
199208
- docLink: `${os$1}/settings#environment-variables`
199166
+ docLink: `${os$2}/settings#environment-variables`
199209
199167
  }
199210
199168
  },
199211
199169
  {
@@ -199216,14 +199174,14 @@ var os$1 = "https://code.claude.com/docs/en", kKe = [
199216
199174
  matches: (e) => e.path.startsWith("hooks.") && e.code === "invalid_key",
199217
199175
  tip: {
199218
199176
  suggestion: "Not a recognized hook event. Common events: PreToolUse, PostToolUse, UserPromptSubmit, SessionStart, SessionEnd, Stop. Check spelling and capitalization.",
199219
- docLink: `${os$1}/hooks`
199177
+ docLink: `${os$2}/hooks`
199220
199178
  }
199221
199179
  },
199222
199180
  {
199223
199181
  matches: (e) => /\.hooks\.\d+\.command$/.test(e.path) && e.code === "invalid_type" && e.received === "undefined",
199224
199182
  tip: {
199225
199183
  suggestion: "Command hooks require `command`. For exec form (no shell), set `command` to the executable and `args` to its arguments: {\"type\": \"command\", \"command\": \"echo\", \"args\": [\"hi\"]}. For shell form, set `command` to the full shell string: {\"type\": \"command\", \"command\": \"echo hi\"}.",
199226
- docLink: `${os$1}/hooks#exec-form-and-shell-form`
199184
+ docLink: `${os$2}/hooks#exec-form-and-shell-form`
199227
199185
  }
199228
199186
  },
199229
199187
  {
@@ -199238,7 +199196,7 @@ var os$1 = "https://code.claude.com/docs/en", kKe = [
199238
199196
  matches: (e) => e.code === "unrecognized_keys",
199239
199197
  tip: {
199240
199198
  suggestion: "Check for typos or refer to the documentation for valid fields",
199241
- docLink: `${os$1}/settings`
199199
+ docLink: `${os$2}/settings`
199242
199200
  }
199243
199201
  },
199244
199202
  {
@@ -199253,13 +199211,13 @@ var os$1 = "https://code.claude.com/docs/en", kKe = [
199253
199211
  matches: (e) => e.path === "permissions.additionalDirectories" && e.code === "invalid_type",
199254
199212
  tip: {
199255
199213
  suggestion: "Must be an array of directory paths. Example: [\"~/projects\", \"/tmp/workspace\"]. You can also use --add-dir flag or /add-dir command",
199256
- docLink: `${os$1}/iam#working-directories`
199214
+ docLink: `${os$2}/iam#working-directories`
199257
199215
  }
199258
199216
  }
199259
199217
  ], AKe = {
199260
- permissions: `${os$1}/iam#configuring-permissions`,
199261
- env: `${os$1}/settings#environment-variables`,
199262
- hooks: `${os$1}/hooks`
199218
+ permissions: `${os$2}/iam#configuring-permissions`,
199219
+ env: `${os$2}/settings#environment-variables`,
199220
+ hooks: `${os$2}/hooks`
199263
199221
  };
199264
199222
  function GZ(e) {
199265
199223
  let t = kKe.find((r) => r.matches(e));
@@ -211320,6 +211278,83 @@ const makeProviderAuthProvenance = (input) => {
211320
211278
  };
211321
211279
  };
211322
211280
  //#endregion
211281
+ //#region src/provider/claudeReadinessReason.ts
211282
+ /**
211283
+ * What Forge says about a delivered Claude credential that expired.
211284
+ *
211285
+ * CMMD's credential authority rotates the refresh token on every refresh, and a
211286
+ * runtime holds a one-time snapshot, so the snapshot's refresh token dies at
211287
+ * the next rotation. Nothing re-delivers on its own, and on 2026-09-04 23:07Z
211288
+ * the turn met a dead credential: the CLI said "OAuth session expired and could
211289
+ * not be refreshed", the thread said Claude was unavailable on this
211290
+ * Environment, and the provider card said the credential was "unavailable or
211291
+ * unusable". Three sentences, none of them the fact, which is that the
211292
+ * credential expired at a known time and a replacement is on its way.
211293
+ *
211294
+ * CMMD-36441 now answers the pre-turn readiness read with a typed reason and
211295
+ * queues a same-generation re-delivery. This module is the one place that
211296
+ * turns those reasons into words.
211297
+ *
211298
+ * Which kind of answer a reason names comes from
211299
+ * `@cmmd-forge/shared/claudeReadinessReason`, which the browser readiness poll
211300
+ * reads too, so the two cannot disagree about a reason (FOR-3085). A reason
211301
+ * that maps to nothing falls through to the generic copy, and every sentence a
211302
+ * person reads is written here rather than forwarded from upstream. Only an
211303
+ * ISO timestamp is ever lifted out of CMMD's message, so no credential detail
211304
+ * in an upstream string can reach a browser.
211305
+ */
211306
+ const CLAUDE_NATIVE_CREDENTIAL_UNUSABLE_COPY = "The delivered Claude credential is unavailable or unusable in this runtime.";
211307
+ /**
211308
+ * An ISO 8601 instant, with or without fractional seconds, UTC or offset.
211309
+ * Anchored to nothing on purpose: CMMD wraps the time in a sentence, and the
211310
+ * time is the only part of that sentence Forge repeats.
211311
+ */
211312
+ const ISO_INSTANT_PATTERN = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})/;
211313
+ function expiredAtFromReadinessMessage(message) {
211314
+ if (typeof message !== "string") return null;
211315
+ return ISO_INSTANT_PATTERN.exec(message)?.[0] ?? null;
211316
+ }
211317
+ function claudeCredentialExpiredTurnCopy(expiredAt) {
211318
+ return `The delivered Claude credential expired at ${expiredAt}. CMMD is delivering a refreshed one, so retry this turn in a moment.`;
211319
+ }
211320
+ function claudeCredentialExpiredCardCopy(expiredAt) {
211321
+ return `The delivered Claude credential expired at ${expiredAt}. CMMD is delivering a refreshed one to this runtime.`;
211322
+ }
211323
+ /**
211324
+ * The last allowlisted readiness reason this process saw.
211325
+ *
211326
+ * A server process serves exactly one runtime, so one slot is the whole store.
211327
+ * It holds a reason code and a timestamp, never credential bytes. The provider
211328
+ * catalog reads a local credential file and cannot tell an expired snapshot
211329
+ * from a blank one, so without this the card can only offer the generic
211330
+ * sentence while the guard already knows better.
211331
+ */
211332
+ let latestVerdict = null;
211333
+ /**
211334
+ * Remember, or clear, what the readiness answer said.
211335
+ *
211336
+ * An answer carrying no allowlisted reason clears the slot, which is what makes
211337
+ * the card go back to the generic sentence the moment CMMD applies a
211338
+ * credential: an applied answer carries no reason.
211339
+ */
211340
+ function recordClaudeReadinessVerdict(readiness) {
211341
+ const code = claudeReadinessReasonCode(readiness.reason);
211342
+ latestVerdict = code === null ? null : {
211343
+ code,
211344
+ expiredAt: expiredAtFromReadinessMessage(readiness.lastErrorMessage)
211345
+ };
211346
+ }
211347
+ /**
211348
+ * What the provider status card says about a delivered credential it cannot
211349
+ * use. Names the expiry only when a readiness answer supplied the time; a
211350
+ * guessed time would be worse than the generic sentence.
211351
+ */
211352
+ function claudeNativeCredentialUnusableMessage() {
211353
+ const verdict = latestVerdict;
211354
+ if (verdict?.code === "CREDENTIAL_EXPIRED_REFRESHING" && verdict.expiredAt !== null) return claudeCredentialExpiredCardCopy(verdict.expiredAt);
211355
+ return CLAUDE_NATIVE_CREDENTIAL_UNUSABLE_COPY;
211356
+ }
211357
+ //#endregion
211323
211358
  //#region src/provider/claudeCredentialStore.ts
211324
211359
  /**
211325
211360
  * Which Credential Store the Claude CLI uses on this machine, read the way the
@@ -265879,7 +265914,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
265879
265914
  var dgram = __require("dgram");
265880
265915
  var thunky = require_thunky();
265881
265916
  var events = __require("events");
265882
- var os = __require("os");
265917
+ var os$1 = __require("os");
265883
265918
  var noop = function() {};
265884
265919
  module.exports = function(opts) {
265885
265920
  if (!opts) opts = {};
@@ -266010,14 +266045,14 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
266010
266045
  return that;
266011
266046
  };
266012
266047
  function defaultInterface() {
266013
- var networks = os.networkInterfaces();
266048
+ var networks = os$1.networkInterfaces();
266014
266049
  var names = Object.keys(networks);
266015
266050
  for (var i = 0; i < names.length; i++) {
266016
266051
  var net = networks[names[i]];
266017
266052
  for (var j = 0; j < net.length; j++) {
266018
266053
  var iface = net[j];
266019
266054
  if (isIPv4(iface.family) && !iface.internal) {
266020
- if (os.platform() === "darwin" && names[i] === "en0") return iface.address;
266055
+ if (os$1.platform() === "darwin" && names[i] === "en0") return iface.address;
266021
266056
  return "0.0.0.0";
266022
266057
  }
266023
266058
  }
@@ -266025,7 +266060,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
266025
266060
  return "127.0.0.1";
266026
266061
  }
266027
266062
  function allInterfaces() {
266028
- var networks = os.networkInterfaces();
266063
+ var networks = os$1.networkInterfaces();
266029
266064
  var names = Object.keys(networks);
266030
266065
  var res = [];
266031
266066
  for (var i = 0; i < names.length; i++) {
@@ -294724,7 +294759,7 @@ function resolveBuildCommitFromEnv(env) {
294724
294759
  * environment descriptor down instead of reporting an honest "unknown".
294725
294760
  */
294726
294761
  function readBakedBuildCommit() {
294727
- return "9243995fc67ca68aa610fabccbf48bba35a5ffd1";
294762
+ return "1881e36c16315be6322e1a109dd4a331b484b963";
294728
294763
  }
294729
294764
  async function resolveServerBuildCommit(input) {
294730
294765
  if (isFullCommitSha(input.baked)) return input.baked;
@@ -318813,7 +318848,7 @@ const connectLoginCommand = make$34("login", {
318813
318848
  })).json();
318814
318849
  },
318815
318850
  openBrowser: async (url) => {
318816
- const open = (await import("./open-D8mGyWmt.mjs")).default;
318851
+ const open = (await import("./open-FIgTDosf.mjs")).default;
318817
318852
  await open(url);
318818
318853
  return true;
318819
318854
  },
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ba as t,Va as n,ki as r,za as i}from"./Stream-C4tOsbfQ.js";import{Ca as a,Gi as o,Gr as s,Hs as c,Ln as l,Ls as u,Mn as d,Ms as f,On as p,Sr as m,Vn as h,Vs as g,Xt as _,Yi as v,_ as y,aa as b,d as x,hn as S,i as C,kr as w,l as T,m as E,n as D,qn as O,r as k,u as A,wc as j,wr as M,zs as N}from"./DiffPanelShell-C14W3dyR.js";import{xn as P}from"./CompositeItem-BNZfMUvm.js";import{a as F,c as I,f as L,i as R,l as z,m as B,n as V,o as H,p as U,r as W,s as G,t as K}from"./Virtualizer-CU3LnU6A.js";import{Sn as q,U as J,W as ee}from"./src-CFqnisEM.js";import{a as te,c as ne,d as re,h as ie,i as ae,l as oe,m as se,n as ce,o as Y,p as le,r as ue,s as de,t as fe,u as pe}from"./DiffPanel.logic-Ce-amvoZ.js";var X=e(n(),1),me=typeof window>`u`?X.useEffect:X.useLayoutEffect;function he({fileDiff:e,options:t,editorOptions:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:a,metrics:o,hasGutterRenderUtility:s,hasCustomHeader:c,disableWorkerPool:l,edit:u}){let d=V(),f=i!==void 0,p=(0,X.useContext)(C),m=A(),h=(0,X.useRef)(null),g=x(n=>{if(n!=null){if(h.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);d==null?h.current=new re(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),l?void 0:p,!0):h.current=new pe(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),d,o,l?void 0:p,!0),h.current.hydrate({fileDiff:e,fileContainer:n,lineAnnotations:r,prerenderedHTML:a})}else{if(h.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);h.current.cleanUp(),h.current=null}});return me(()=>{let{current:n}=h;if(n==null)return;let a=Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),o=a!==void 0&&!_(n.options,a);n.setOptions(a),n.render({forceRender:o,fileDiff:e,lineAnnotations:r}),i!==void 0&&n.setSelectedLines(i)}),me(()=>{if(u&&h.current!=null){if(m===void 0)throw Error(`FileDiff: EditContext is not attached`);let e=m(n??{});if(e==null)throw Error(`FileDiff: EditProvider.createEditor must return an editor instance`);try{return e.edit(h.current)}catch(t){throw e.cleanUp(),t}}},[u]),{ref:g,getHoveredLine:(0,X.useCallback)(()=>h.current?.getHoveredLine(),[])}}function Z({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return t||r||n?{...e,controlledSelection:t,renderCustomHeader:n?T:e?.renderCustomHeader,renderGutterUtility:r?T:e?.renderGutterUtility}:e}var Q=t();function ge({fileDiff:e,options:t,editorOptions:n,metrics:r,lineAnnotations:i,selectedLines:a,className:o,style:s,prerenderedHTML:c,renderAnnotation:l,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,renderGutterUtility:m,disableWorkerPool:h=!1,edit:g=!1}){let{ref:_,getHoveredLine:v}=he({fileDiff:e,options:t,editorOptions:n,metrics:r,lineAnnotations:i,selectedLines:a,prerenderedHTML:c,hasGutterRenderUtility:m!=null,hasCustomHeader:u!=null,disableWorkerPool:h,edit:g});return(0,Q.jsx)(S,{ref:_,className:o,style:s,children:W(oe({fileDiff:e,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,renderAnnotation:l,renderGutterUtility:m,lineAnnotations:i,getHoveredLine:v}),c)})}var $=i();function _e(e){return e.fromTurnCount===0?q(J)({threadId:e.threadId,toTurnCount:e.toTurnCount}).pipe(r(e=>({kind:`fullThreadDiff`,input:e}))):q(ee)({threadId:e.threadId,fromTurnCount:e.fromTurnCount,toTurnCount:e.toTurnCount}).pipe(r(e=>({kind:`turnDiff`,input:e})))}function ve(e){return e instanceof Error?e.message:typeof e==`string`?e:``}function ye(e){let t=ve(e).trim();if(t.length===0)return`Failed to load checkpoint diff.`;let n=t.toLowerCase();if(n.includes(`not a git repository`))return`Turn diffs are unavailable because this project is not a git repository.`;if(n.includes(`checkpoint unavailable for thread`)||n.includes(`checkpoint invariant violation`)){let e=t.indexOf(`:`);if(e>=0){let n=t.slice(e+1).trim();if(n.length>0)return n}}return t}function be(e){let t=ve(e).toLowerCase();return t.includes(`exceeds current turn count`)||t.includes(`checkpoint is unavailable for turn`)||t.includes(`filesystem checkpoint is unavailable`)}function xe(e){let t=_e(e);return g({queryKey:o.checkpointDiff(e),queryFn:async({signal:n})=>{if(!e.environmentId||!e.threadId||t._tag===`None`)throw Error(`Checkpoint diff is unavailable.`);let r=O(e.environmentId);try{return t.value.kind===`fullThreadDiff`?await r.orchestration.getFullThreadDiff(t.value.input,{signal:n}):await r.orchestration.getTurnDiff(t.value.input,{signal:n})}catch(e){throw Error(ye(e),{cause:e})}},enabled:(e.enabled??!0)&&!!e.environmentId&&!!e.threadId&&t._tag===`Some`,staleTime:1/0,retry:(e,t)=>be(t)?e<12:e<3,retryDelay:(e,t)=>be(t)?Math.min(5e3,250*2**(e-1)):Math.min(1e3,100*2**(e-1))})}function Se(e){if(!(!e.canScrollLeft&&!e.canScrollRight))return{maskImage:`linear-gradient(to right, ${e.canScrollLeft?`transparent 24px, black 72px`:`black`}, ${e.canScrollRight?`black calc(100% - 72px), transparent calc(100% - 24px)`:`black`})`}}function Ce(e){return e instanceof Error?e.message:e?`Failed to load checkpoint diff.`:null}function we(e){return{environmentId:e.environmentId??null,threadId:e.threadId,fromTurnCount:e.range?.fromTurnCount??null,toTurnCount:e.range?.toTurnCount??null,cacheScope:e.selectedTurnId?`turn:${e.selectedTurnId}`:e.conversationCacheScope,enabled:e.enabled}}function Te(){let e=(0,$.c)(8),t=(0,X.useRef)(null),[n,r]=(0,X.useState)(!1),[i,a]=(0,X.useState)(!1),o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=t.current;if(!e){r(!1),a(!1);return}let n=de({scrollLeft:e.scrollLeft,scrollWidth:e.scrollWidth,clientWidth:e.clientWidth});r(n.canScrollLeft),a(n.canScrollRight)},e[0]=o):o=e[0];let s=o,c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{t.current?.scrollBy({left:e,behavior:`smooth`})},e[1]=c):c=e[1];let l=c,u;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>{let n=t.current;n&&ne({scrollWidth:n.scrollWidth,clientWidth:n.clientWidth,deltaX:e.deltaX,deltaY:e.deltaY})&&(e.preventDefault(),n.scrollBy({left:e.deltaY,behavior:`auto`}))},e[2]=u):u=e[2];let d=u,f,p;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=t.current;if(!e)return;let n=window.requestAnimationFrame(s),r=()=>s();e.addEventListener(`scroll`,r,{passive:!0});let i=new ResizeObserver(()=>s());return i.observe(e),()=>{window.cancelAnimationFrame(n),e.removeEventListener(`scroll`,r),i.disconnect()}},p=[s],e[3]=f,e[4]=p):(f=e[3],p=e[4]),(0,X.useEffect)(f,p);let m;return e[5]!==n||e[6]!==i?(m={ref:t,canScrollLeft:n,canScrollRight:i,scrollBy:l,onWheel:d,remeasure:s},e[5]=n,e[6]=i,e[7]=m):m=e[7],m}function Ee(e,t){let n=(0,$.c)(5),r;n[0]===e.current?r=n[1]:(r=()=>{(e.current?.querySelector(`[data-turn-chip-selected='true']`))?.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:`smooth`})},n[0]=e.current,n[1]=r);let i;n[2]!==e||n[3]!==t?(i=[e,t],n[2]=e,n[3]=t,n[4]=i):i=n[4],(0,X.useEffect)(r,i)}var De=`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ba as t,Va as n,ki as r,za as i}from"./Stream-C4tOsbfQ.js";import{Ca as a,Gi as o,Gr as s,Hs as c,Ln as l,Ls as u,Mn as d,Ms as f,On as p,Sr as m,Vn as h,Vs as g,Xt as _,Yi as v,_ as y,aa as b,d as x,hn as S,i as C,kr as w,l as T,m as E,n as D,qn as O,r as k,u as A,wc as j,wr as M,zs as N}from"./DiffPanelShell-DmjIQbsj.js";import{xn as P}from"./CompositeItem-BNZfMUvm.js";import{a as F,c as I,f as L,i as R,l as z,m as B,n as V,o as H,p as U,r as W,s as G,t as K}from"./diffTargetResolution-IthQ5nAw.js";import{Sn as q,U as J,W as ee}from"./src-CFqnisEM.js";import{a as te,c as ne,d as re,h as ie,i as ae,l as oe,m as se,n as ce,o as Y,p as le,r as ue,s as de,t as fe,u as pe}from"./DiffPanel.logic-_zUBJ9_7.js";var X=e(n(),1),me=typeof window>`u`?X.useEffect:X.useLayoutEffect;function he({fileDiff:e,options:t,editorOptions:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:a,metrics:o,hasGutterRenderUtility:s,hasCustomHeader:c,disableWorkerPool:l,edit:u}){let d=R(),f=i!==void 0,p=(0,X.useContext)(C),m=A(),h=(0,X.useRef)(null),g=x(n=>{if(n!=null){if(h.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);d==null?h.current=new re(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),l?void 0:p,!0):h.current=new pe(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),d,o,l?void 0:p,!0),h.current.hydrate({fileDiff:e,fileContainer:n,lineAnnotations:r,prerenderedHTML:a})}else{if(h.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);h.current.cleanUp(),h.current=null}});return me(()=>{let{current:n}=h;if(n==null)return;let a=Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),o=a!==void 0&&!_(n.options,a);n.setOptions(a),n.render({forceRender:o,fileDiff:e,lineAnnotations:r}),i!==void 0&&n.setSelectedLines(i)}),me(()=>{if(u&&h.current!=null){if(m===void 0)throw Error(`FileDiff: EditContext is not attached`);let e=m(n??{});if(e==null)throw Error(`FileDiff: EditProvider.createEditor must return an editor instance`);try{return e.edit(h.current)}catch(t){throw e.cleanUp(),t}}},[u]),{ref:g,getHoveredLine:(0,X.useCallback)(()=>h.current?.getHoveredLine(),[])}}function Z({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return t||r||n?{...e,controlledSelection:t,renderCustomHeader:n?T:e?.renderCustomHeader,renderGutterUtility:r?T:e?.renderGutterUtility}:e}var Q=t();function ge({fileDiff:e,options:t,editorOptions:n,metrics:r,lineAnnotations:i,selectedLines:a,className:o,style:s,prerenderedHTML:c,renderAnnotation:l,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,renderGutterUtility:m,disableWorkerPool:h=!1,edit:g=!1}){let{ref:_,getHoveredLine:v}=he({fileDiff:e,options:t,editorOptions:n,metrics:r,lineAnnotations:i,selectedLines:a,prerenderedHTML:c,hasGutterRenderUtility:m!=null,hasCustomHeader:u!=null,disableWorkerPool:h,edit:g});return(0,Q.jsx)(S,{ref:_,className:o,style:s,children:F(oe({fileDiff:e,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,renderAnnotation:l,renderGutterUtility:m,lineAnnotations:i,getHoveredLine:v}),c)})}var $=i();function _e(e){return e.fromTurnCount===0?q(J)({threadId:e.threadId,toTurnCount:e.toTurnCount}).pipe(r(e=>({kind:`fullThreadDiff`,input:e}))):q(ee)({threadId:e.threadId,fromTurnCount:e.fromTurnCount,toTurnCount:e.toTurnCount}).pipe(r(e=>({kind:`turnDiff`,input:e})))}function ve(e){return e instanceof Error?e.message:typeof e==`string`?e:``}function ye(e){let t=ve(e).trim();if(t.length===0)return`Failed to load checkpoint diff.`;let n=t.toLowerCase();if(n.includes(`not a git repository`))return`Turn diffs are unavailable because this project is not a git repository.`;if(n.includes(`checkpoint unavailable for thread`)||n.includes(`checkpoint invariant violation`)){let e=t.indexOf(`:`);if(e>=0){let n=t.slice(e+1).trim();if(n.length>0)return n}}return t}function be(e){let t=ve(e).toLowerCase();return t.includes(`exceeds current turn count`)||t.includes(`checkpoint is unavailable for turn`)||t.includes(`filesystem checkpoint is unavailable`)}function xe(e){let t=_e(e);return g({queryKey:o.checkpointDiff(e),queryFn:async({signal:n})=>{if(!e.environmentId||!e.threadId||t._tag===`None`)throw Error(`Checkpoint diff is unavailable.`);let r=O(e.environmentId);try{return t.value.kind===`fullThreadDiff`?await r.orchestration.getFullThreadDiff(t.value.input,{signal:n}):await r.orchestration.getTurnDiff(t.value.input,{signal:n})}catch(e){throw Error(ye(e),{cause:e})}},enabled:(e.enabled??!0)&&!!e.environmentId&&!!e.threadId&&t._tag===`Some`,staleTime:1/0,retry:(e,t)=>be(t)?e<12:e<3,retryDelay:(e,t)=>be(t)?Math.min(5e3,250*2**(e-1)):Math.min(1e3,100*2**(e-1))})}function Se(e){if(!(!e.canScrollLeft&&!e.canScrollRight))return{maskImage:`linear-gradient(to right, ${e.canScrollLeft?`transparent 24px, black 72px`:`black`}, ${e.canScrollRight?`black calc(100% - 72px), transparent calc(100% - 24px)`:`black`})`}}function Ce(e){return e instanceof Error?e.message:e?`Failed to load checkpoint diff.`:null}function we(e){return{environmentId:e.environmentId??null,threadId:e.threadId,fromTurnCount:e.range?.fromTurnCount??null,toTurnCount:e.range?.toTurnCount??null,cacheScope:e.selectedTurnId?`turn:${e.selectedTurnId}`:e.conversationCacheScope,enabled:e.enabled}}function Te(){let e=(0,$.c)(8),t=(0,X.useRef)(null),[n,r]=(0,X.useState)(!1),[i,a]=(0,X.useState)(!1),o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=t.current;if(!e){r(!1),a(!1);return}let n=de({scrollLeft:e.scrollLeft,scrollWidth:e.scrollWidth,clientWidth:e.clientWidth});r(n.canScrollLeft),a(n.canScrollRight)},e[0]=o):o=e[0];let s=o,c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{t.current?.scrollBy({left:e,behavior:`smooth`})},e[1]=c):c=e[1];let l=c,u;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>{let n=t.current;n&&ne({scrollWidth:n.scrollWidth,clientWidth:n.clientWidth,deltaX:e.deltaX,deltaY:e.deltaY})&&(e.preventDefault(),n.scrollBy({left:e.deltaY,behavior:`auto`}))},e[2]=u):u=e[2];let d=u,f,p;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=t.current;if(!e)return;let n=window.requestAnimationFrame(s),r=()=>s();e.addEventListener(`scroll`,r,{passive:!0});let i=new ResizeObserver(()=>s());return i.observe(e),()=>{window.cancelAnimationFrame(n),e.removeEventListener(`scroll`,r),i.disconnect()}},p=[s],e[3]=f,e[4]=p):(f=e[3],p=e[4]),(0,X.useEffect)(f,p);let m;return e[5]!==n||e[6]!==i?(m={ref:t,canScrollLeft:n,canScrollRight:i,scrollBy:l,onWheel:d,remeasure:s},e[5]=n,e[6]=i,e[7]=m):m=e[7],m}function Ee(e,t){let n=(0,$.c)(5),r;n[0]===e.current?r=n[1]:(r=()=>{(e.current?.querySelector(`[data-turn-chip-selected='true']`))?.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:`smooth`})},n[0]=e.current,n[1]=r);let i;n[2]!==e||n[3]!==t?(i=[e,t],n[2]=e,n[3]=t,n[4]=i):i=n[4],(0,X.useEffect)(r,i)}var De=`
2
2
  [data-diffs-header],
3
3
  [data-diff],
4
4
  [data-file],
@@ -60,5 +60,5 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ba as t,Va as n,ki as
60
60
  color: color-mix(in srgb, var(--foreground) 84%, var(--primary)) !important;
61
61
  text-decoration-color: currentColor;
62
62
  }
63
- `;function Oe(e){let t=(0,$.c)(44),{mode:n}=e,r=n===void 0?`inline`:n,{resolvedTheme:i}=E(),a=M(),[o,s]=(0,X.useState)(`stacked`),[c,l]=(0,X.useState)(a.diffWordWrap),f=(0,X.useRef)(null),m=(0,X.useRef)(!1),g=Te(),{activeCwd:_,activeThread:v,bodyState:y,diffOpen:b,inferredCheckpointTurnCountByTurnId:x,orderedTurnDiffSummaries:S,renderableFiles:C,renderablePatch:T,selectedFilePath:D,selectedTurn:O,selectedTurnId:A}=Le(i),j,P;t[0]!==b||t[1]!==a.diffWordWrap?(j=()=>{b&&!m.current&&l(a.diffWordWrap),m.current=b},P=[b,a.diffWordWrap],t[0]=b,t[1]=a.diffWordWrap,t[2]=j,t[3]=P):(j=t[2],P=t[3]),(0,X.useEffect)(j,P);let F;t[4]===D?F=t[5]:(F=()=>{!D||!f.current||Array.from(f.current.querySelectorAll(`[data-diff-file-path]`)).find(e=>e.dataset.diffFilePath===D)?.scrollIntoView({block:`nearest`})},t[4]=D,t[5]=F);let I;t[6]!==C||t[7]!==D?(I=[D,C],t[6]=C,t[7]=D,t[8]=I):I=t[8],(0,X.useEffect)(F,I);let L;t[9]===_?L=t[10]:(L=e=>{let t=w();if(!t)return;let n=_?p(e,_):e;d(t,n).catch(ke)},t[9]=_,t[10]=L);let R=L,z;t[11]===v?z=t[12]:(z=e=>{v&&h.getState().openDiff(N(u(v.environmentId,v.id)),e)},t[11]=v,t[12]=z);let B=z,V;t[13]===v?V=t[14]:(V=()=>{v&&h.getState().openDiff(N(u(v.environmentId,v.id)))},t[13]=v,t[14]=V);let H=V,U;t[15]===g.remeasure?U=t[16]:(U=()=>{let e=window.requestAnimationFrame(g.remeasure);return()=>window.cancelAnimationFrame(e)},t[15]=g.remeasure,t[16]=U);let W;t[17]!==S||t[18]!==A||t[19]!==g.remeasure?(W=[S,A,g.remeasure],t[17]=S,t[18]=A,t[19]=g.remeasure,t[20]=W):W=t[20],(0,X.useEffect)(U,W),Ee(g.ref,O?.turnId??A);let G;t[21]!==o||t[22]!==c||t[23]!==x||t[24]!==S||t[25]!==B||t[26]!==H||t[27]!==O||t[28]!==A||t[29]!==a||t[30]!==g?(G=(0,Q.jsx)(Ae,{diffRenderMode:o,diffWordWrap:c,inferredCheckpointTurnCountByTurnId:x,orderedTurnDiffSummaries:S,selectTurn:B,selectWholeConversation:H,selectedTurn:O,selectedTurnId:A,setDiffRenderMode:s,setDiffWordWrap:l,settings:a,turnStrip:g}),t[21]=o,t[22]=c,t[23]=x,t[24]=S,t[25]=B,t[26]=H,t[27]=O,t[28]=A,t[29]=a,t[30]=g,t[31]=G):G=t[31];let K=G,q;t[32]!==y||t[33]!==o||t[34]!==c||t[35]!==R||t[36]!==C||t[37]!==T||t[38]!==i?(q=(0,Q.jsx)(je,{bodyState:y,diffRenderMode:o,diffWordWrap:c,openDiffFileInEditor:R,patchViewportRef:f,renderableFiles:C,renderablePatch:T,resolvedTheme:i}),t[32]=y,t[33]=o,t[34]=c,t[35]=R,t[36]=C,t[37]=T,t[38]=i,t[39]=q):q=t[39];let J;return t[40]!==K||t[41]!==r||t[42]!==q?(J=(0,Q.jsx)(k,{mode:r,header:K,children:q}),t[40]=K,t[41]=r,t[42]=q,t[43]=J):J=t[43],J}function ke(e){console.warn(`Failed to open diff file in editor.`,e)}function Ae(e){let t=(0,$.c)(59),{diffRenderMode:n,diffWordWrap:r,inferredCheckpointTurnCountByTurnId:i,orderedTurnDiffSummaries:a,selectTurn:o,selectWholeConversation:s,selectedTurn:c,selectedTurnId:l,setDiffRenderMode:u,setDiffWordWrap:d,settings:f,turnStrip:p}=e,m,h;t[0]===p?(m=t[1],h=t[2]):(m=(0,Q.jsx)(Be,{direction:`left`,strip:p}),h=(0,Q.jsx)(Be,{direction:`right`,strip:p}),t[0]=p,t[1]=m,t[2]=h);let g=p.ref,_;t[3]!==p.canScrollLeft||t[4]!==p.canScrollRight?(_=Se({canScrollLeft:p.canScrollLeft,canScrollRight:p.canScrollRight}),t[3]=p.canScrollLeft,t[4]=p.canScrollRight,t[5]=_):_=t[5];let v=p.onWheel,y=l===null,b=l===null?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`,x;t[6]===b?x=t[7]:(x=P(`rounded-md border px-2 py-1 text-left transition-colors`,b),t[6]=b,t[7]=x);let S;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(`div`,{className:`text-[10px] leading-tight font-medium`,children:`All turns`}),t[8]=S):S=t[8];let C;t[9]===x?C=t[10]:(C=(0,Q.jsx)(`div`,{className:x,children:S}),t[9]=x,t[10]=C);let w;t[11]!==s||t[12]!==C||t[13]!==y?(w=(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:s,"data-turn-chip-selected":y,children:C}),t[11]=s,t[12]=C,t[13]=y,t[14]=w):w=t[14];let T;if(t[15]!==i||t[16]!==a||t[17]!==o||t[18]!==c?.turnId||t[19]!==f){let e;t[21]!==i||t[22]!==o||t[23]!==c?.turnId||t[24]!==f?(e=e=>(0,Q.jsx)(Ve,{summary:e,selected:e.turnId===c?.turnId,turnCount:e.checkpointTurnCount??i[e.turnId],timestampFormat:f.timestampFormat,onSelect:o},e.turnId),t[21]=i,t[22]=o,t[23]=c?.turnId,t[24]=f,t[25]=e):e=t[25],T=a.map(e),t[15]=i,t[16]=a,t[17]=o,t[18]=c?.turnId,t[19]=f,t[20]=T}else T=t[20];let E;t[26]!==w||t[27]!==T||t[28]!==_||t[29]!==p.onWheel||t[30]!==p.ref?(E=(0,Q.jsxs)(`div`,{ref:g,className:`turn-chip-strip flex gap-1 overflow-x-auto px-8 py-0.5`,style:_,onWheel:v,children:[w,T]}),t[26]=w,t[27]=T,t[28]=_,t[29]=p.onWheel,t[30]=p.ref,t[31]=E):E=t[31];let D;t[32]!==m||t[33]!==E||t[34]!==h?(D=(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 [-webkit-app-region:no-drag]`,children:[m,h,E]}),t[32]=m,t[33]=E,t[34]=h,t[35]=D):D=t[35];let O;t[36]===n?O=t[37]:(O=[n],t[36]=n,t[37]=O);let k;t[38]===u?k=t[39]:(k=e=>{let t=e[0];(t===`stacked`||t===`split`)&&u(t)},t[38]=u,t[39]=k);let A;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(H,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,Q.jsx)(se,{className:`size-3`})}),t[40]=A):A=t[40];let j;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(H,{"aria-label":`Split diff view`,value:`split`,children:(0,Q.jsx)(ie,{className:`size-3`})}),t[41]=j):j=t[41];let M;t[42]!==O||t[43]!==k?(M=(0,Q.jsxs)(G,{className:`shrink-0`,variant:`outline`,size:`xs`,value:O,onValueChange:k,children:[A,j]}),t[42]=O,t[43]=k,t[44]=M):M=t[44];let N=r?`Disable diff line wrapping`:`Enable diff line wrapping`,F=r?`Disable line wrapping`:`Enable line wrapping`,I;t[45]===d?I=t[46]:(I=e=>{d(!!e)},t[45]=d,t[46]=I);let L;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(le,{className:`size-3`}),t[47]=L):L=t[47];let R;t[48]!==r||t[49]!==N||t[50]!==F||t[51]!==I?(R=(0,Q.jsx)(H,{"aria-label":N,title:F,variant:`outline`,size:`xs`,pressed:r,onPressedChange:I,children:L}),t[48]=r,t[49]=N,t[50]=F,t[51]=I,t[52]=R):R=t[52];let z;t[53]!==M||t[54]!==R?(z=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[M,R]}),t[53]=M,t[54]=R,t[55]=z):z=t[55];let B;return t[56]!==D||t[57]!==z?(B=(0,Q.jsxs)(Q.Fragment,{children:[D,z]}),t[56]=D,t[57]=z,t[58]=B):B=t[58],B}function je(e){let t=(0,$.c)(18),{bodyState:n,diffRenderMode:r,diffWordWrap:i,openDiffFileInEditor:a,patchViewportRef:o,renderableFiles:s,renderablePatch:c,resolvedTheme:l}=e;if(n.kind===`no-thread`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ne,{children:`Select a thread to inspect turn diffs.`}),t[0]=e):e=t[0],e}if(n.kind===`not-git-repo`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ne,{children:`Turn diffs are unavailable because this project is not a git repository.`}),t[1]=e):e=t[1],e}if(n.kind===`no-completed-turns`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ne,{children:`No completed turns yet.`}),t[2]=e):e=t[2],e}let u;t[3]!==n.error||t[4]!==c?(u=n.error&&!c&&(0,Q.jsx)(`div`,{className:`px-3`,children:(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] text-destructive-foreground`,children:n.error})}),t[3]=n.error,t[4]=c,t[5]=u):u=t[5];let d;t[6]!==n||t[7]!==r||t[8]!==i||t[9]!==a||t[10]!==s||t[11]!==c||t[12]!==l?(d=c?c.kind===`files`?(0,Q.jsx)(K,{className:`diff-render-surface h-full min-h-0 overflow-auto px-2 pb-2`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:s.map(e=>{let t=Y(e),n=`${fe(e)}:${l}`;return(0,Q.jsx)(`div`,{"data-diff-file-path":t,className:`diff-render-file mb-2 rounded-md first:mt-2 last:mb-0`,onClickCapture:e=>{(e.nativeEvent.composedPath?.()??[]).some(Me)&&a(t)},children:(0,Q.jsx)(ge,{fileDiff:e,options:{diffStyle:r===`split`?`split`:`unified`,lineDiffType:`none`,overflow:i?`wrap`:`scroll`,theme:y(l),themeType:l,unsafeCSS:De}})},n)})}):(0,Q.jsx)(`div`,{className:`h-full overflow-auto p-2`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:c.reason}),(0,Q.jsx)(`pre`,{className:P(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,i?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:c.text})]})}):(0,Q.jsx)(Re,{bodyState:n}),t[6]=n,t[7]=r,t[8]=i,t[9]=a,t[10]=s,t[11]=c,t[12]=l,t[13]=d):d=t[13];let f;return t[14]!==o||t[15]!==u||t[16]!==d?(f=(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsxs)(`div`,{ref:o,className:`diff-panel-viewport min-h-0 min-w-0 flex-1 overflow-hidden`,children:[u,d]})}),t[14]=o,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function Me(e){return e instanceof Element&&e.hasAttribute(`data-title`)}function Ne(e){let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:n}),t[0]=n,t[1]=r),r}function Pe(){let e=(0,$.c)(19),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={strict:!1,select:Ie},e[0]=t):t=e[0];let n=j(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r={strict:!1,select:Fe},e[1]=r):r=e[1];let i=B(r),a=i.rightPanel===`diff`,o=n?.threadId??null,c,u;e[2]===n?u=e[3]:(u=l(n),e[2]=n,e[3]=u),c=u;let d=b(c),f=He(d),p=d?.worktreePath,m=f?.cwd,h;e[4]!==p||e[5]!==m?(h=R({threadWorktreePath:p,projectCwd:m}),e[4]=p,e[5]=m,e[6]=h):h=e[6];let g=h,_=d?.environmentId??null,v=g??null,y;e[7]!==_||e[8]!==v?(y={environmentId:_,cwd:v},e[7]=_,e[8]=v,e[9]=y):y=e[9];let x=s(y),S;e[10]===x.data?S=e[11]:(S=F(x.data),e[10]=x.data,e[11]=S);let C=S,w;return e[12]!==g||e[13]!==d||e[14]!==o||e[15]!==a||e[16]!==i||e[17]!==C?(w={activeThread:d,activeThreadId:o,activeCwd:g,isGitRepo:C,diffSearch:i,diffOpen:a},e[12]=g,e[13]=d,e[14]=o,e[15]=a,e[16]=i,e[17]=C,e[18]=w):w=e[18],w}function Fe(e){return z(e)}function Ie(e){return a(e)}function Le(e){let{activeThread:t,activeThreadId:n,activeCwd:r,isGitRepo:i,diffSearch:a,diffOpen:o}=Pe(),{turnDiffSummaries:s,inferredCheckpointTurnCountByTurnId:l}=I(t),u=a.diffTurnId??null,d=u===null?null:a.diffFilePath??null,{activeCheckpointRange:f,conversationCacheScope:p,orderedTurnDiffSummaries:m,selectedTurn:h}=(0,X.useMemo)(()=>te({summaries:s,inferredCheckpointTurnCountByTurnId:l,selectedTurnId:u}),[l,u,s]),g=c(xe(we({environmentId:t?.environmentId,threadId:n,range:f,selectedTurnId:h?.turnId,conversationCacheScope:p,enabled:i}))),_=g.isLoading,v=Ce(g.error),y=g.data?.diff,b=typeof y==`string`&&y.trim().length===0,{emptyDiffMessage:x}=(0,X.useMemo)(()=>ae(h),[h]),S=(0,X.useMemo)(()=>ce(y,`diff-panel:${e}`),[e,y]),C=(0,X.useMemo)(()=>Ue(S),[S]);return{activeCwd:r,activeThread:t,bodyState:ue({hasActiveThread:!!t,isGitRepo:i,turnSummaryCount:m.length,checkpointDiffError:v,hasRenderablePatch:!!S,isLoadingCheckpointDiff:_,hasNoNetChanges:b,emptyDiffMessage:x}),diffOpen:o,inferredCheckpointTurnCountByTurnId:l,orderedTurnDiffSummaries:m,renderableFiles:C,renderablePatch:S,selectedFilePath:d,selectedTurn:h,selectedTurnId:u}}function Re(e){let t=(0,$.c)(4),{bodyState:n}=e;if(n.kind===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(D,{label:`Loading checkpoint diff...`}),t[0]=e):e=t[0],e}let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(L,{className:`size-7 text-muted-foreground/25`}),t[1]=r):r=t[1];let i=n.kind===`empty`?n.message:`No diff is available for this range.`,a;return t[2]===i?a=t[3]:(a=(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 px-5 py-2 text-center`,children:[r,(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:i})]}),t[2]=i,t[3]=a),a}var ze=180;function Be(e){let t=(0,$.c)(14),{direction:n,strip:r}=e,i=n===`left`,a=i?r.canScrollLeft:r.canScrollRight,o=i?U:f,s=i?`left-0`:`right-0`,c=a?`border-border/70 hover:border-border hover:text-foreground`:`cursor-not-allowed border-border/40 text-muted-foreground/40`,l;t[0]!==s||t[1]!==c?(l=P(`absolute top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors`,s,c),t[0]=s,t[1]=c,t[2]=l):l=t[2];let u;t[3]!==i||t[4]!==r?(u=()=>r.scrollBy(i?-180:ze),t[3]=i,t[4]=r,t[5]=u):u=t[5];let d=!a,p=`Scroll turn list ${n}`,m;t[6]===o?m=t[7]:(m=(0,Q.jsx)(o,{className:`size-3.5`}),t[6]=o,t[7]=m);let h;return t[8]!==l||t[9]!==u||t[10]!==d||t[11]!==p||t[12]!==m?(h=(0,Q.jsx)(`button`,{type:`button`,className:l,onClick:u,disabled:d,"aria-label":p,children:m}),t[8]=l,t[9]=u,t[10]=d,t[11]=p,t[12]=m,t[13]=h):h=t[13],h}function Ve(e){let t=(0,$.c)(23),{summary:n,selected:r,turnCount:i,timestampFormat:a,onSelect:o}=e,s;t[0]!==o||t[1]!==n.turnId?(s=()=>o(n.turnId),t[0]=o,t[1]=n.turnId,t[2]=s):s=t[2];let c=n.turnId,l=r?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`,u;t[3]===l?u=t[4]:(u=P(`rounded-md border px-2 py-1 text-left transition-colors`,l),t[3]=l,t[4]=u);let d=i??`?`,f;t[5]===d?f=t[6]:(f=(0,Q.jsxs)(`span`,{className:`text-[10px] leading-tight font-medium`,children:[`Turn `,d]}),t[5]=d,t[6]=f);let p;t[7]!==n.completedAt||t[8]!==a?(p=m(n.completedAt,a),t[7]=n.completedAt,t[8]=a,t[9]=p):p=t[9];let h;t[10]===p?h=t[11]:(h=(0,Q.jsx)(`span`,{className:`text-[9px] leading-tight opacity-70`,children:p}),t[10]=p,t[11]=h);let g;t[12]!==f||t[13]!==h?(g=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[f,h]}),t[12]=f,t[13]=h,t[14]=g):g=t[14];let _;t[15]!==u||t[16]!==g?(_=(0,Q.jsx)(`div`,{className:u,children:g}),t[15]=u,t[16]=g,t[17]=_):_=t[17];let v;return t[18]!==r||t[19]!==n.turnId||t[20]!==s||t[21]!==_?(v=(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:s,title:c,"data-turn-chip-selected":r,children:_}),t[18]=r,t[19]=n.turnId,t[20]=s,t[21]=_,t[22]=v):v=t[22],v}function He(e){let t=(0,$.c)(3),n=e?.environmentId,r=e?.projectId,i;return t[0]!==n||t[1]!==r?(i=e=>n&&r?v(e,{environmentId:n,projectId:r}):void 0,t[0]=n,t[1]=r,t[2]=i):i=t[2],b(i)}function Ue(e){return!e||e.kind!==`files`?[]:e.files.toSorted((e,t)=>Y(e).localeCompare(Y(t),void 0,{numeric:!0,sensitivity:`base`}))}export{Oe as default};
64
- //# sourceMappingURL=DiffPanel-tnITsSoL.js.map
63
+ `;function Oe(e){let t=(0,$.c)(44),{mode:n}=e,r=n===void 0?`inline`:n,{resolvedTheme:i}=E(),a=M(),[o,s]=(0,X.useState)(`stacked`),[c,l]=(0,X.useState)(a.diffWordWrap),f=(0,X.useRef)(null),m=(0,X.useRef)(!1),g=Te(),{activeCwd:_,activeThread:v,bodyState:y,diffOpen:b,inferredCheckpointTurnCountByTurnId:x,orderedTurnDiffSummaries:S,renderableFiles:C,renderablePatch:T,selectedFilePath:D,selectedTurn:O,selectedTurnId:A}=Le(i),j,P;t[0]!==b||t[1]!==a.diffWordWrap?(j=()=>{b&&!m.current&&l(a.diffWordWrap),m.current=b},P=[b,a.diffWordWrap],t[0]=b,t[1]=a.diffWordWrap,t[2]=j,t[3]=P):(j=t[2],P=t[3]),(0,X.useEffect)(j,P);let F;t[4]===D?F=t[5]:(F=()=>{!D||!f.current||Array.from(f.current.querySelectorAll(`[data-diff-file-path]`)).find(e=>e.dataset.diffFilePath===D)?.scrollIntoView({block:`nearest`})},t[4]=D,t[5]=F);let I;t[6]!==C||t[7]!==D?(I=[D,C],t[6]=C,t[7]=D,t[8]=I):I=t[8],(0,X.useEffect)(F,I);let L;t[9]===_?L=t[10]:(L=e=>{let t=w();if(!t)return;let n=_?p(e,_):e;d(t,n).catch(ke)},t[9]=_,t[10]=L);let R=L,z;t[11]===v?z=t[12]:(z=e=>{v&&h.getState().openDiff(N(u(v.environmentId,v.id)),e)},t[11]=v,t[12]=z);let B=z,V;t[13]===v?V=t[14]:(V=()=>{v&&h.getState().openDiff(N(u(v.environmentId,v.id)))},t[13]=v,t[14]=V);let H=V,U;t[15]===g.remeasure?U=t[16]:(U=()=>{let e=window.requestAnimationFrame(g.remeasure);return()=>window.cancelAnimationFrame(e)},t[15]=g.remeasure,t[16]=U);let W;t[17]!==S||t[18]!==A||t[19]!==g.remeasure?(W=[S,A,g.remeasure],t[17]=S,t[18]=A,t[19]=g.remeasure,t[20]=W):W=t[20],(0,X.useEffect)(U,W),Ee(g.ref,O?.turnId??A);let G;t[21]!==o||t[22]!==c||t[23]!==x||t[24]!==S||t[25]!==B||t[26]!==H||t[27]!==O||t[28]!==A||t[29]!==a||t[30]!==g?(G=(0,Q.jsx)(Ae,{diffRenderMode:o,diffWordWrap:c,inferredCheckpointTurnCountByTurnId:x,orderedTurnDiffSummaries:S,selectTurn:B,selectWholeConversation:H,selectedTurn:O,selectedTurnId:A,setDiffRenderMode:s,setDiffWordWrap:l,settings:a,turnStrip:g}),t[21]=o,t[22]=c,t[23]=x,t[24]=S,t[25]=B,t[26]=H,t[27]=O,t[28]=A,t[29]=a,t[30]=g,t[31]=G):G=t[31];let K=G,q;t[32]!==y||t[33]!==o||t[34]!==c||t[35]!==R||t[36]!==C||t[37]!==T||t[38]!==i?(q=(0,Q.jsx)(je,{bodyState:y,diffRenderMode:o,diffWordWrap:c,openDiffFileInEditor:R,patchViewportRef:f,renderableFiles:C,renderablePatch:T,resolvedTheme:i}),t[32]=y,t[33]=o,t[34]=c,t[35]=R,t[36]=C,t[37]=T,t[38]=i,t[39]=q):q=t[39];let J;return t[40]!==K||t[41]!==r||t[42]!==q?(J=(0,Q.jsx)(k,{mode:r,header:K,children:q}),t[40]=K,t[41]=r,t[42]=q,t[43]=J):J=t[43],J}function ke(e){console.warn(`Failed to open diff file in editor.`,e)}function Ae(e){let t=(0,$.c)(59),{diffRenderMode:n,diffWordWrap:r,inferredCheckpointTurnCountByTurnId:i,orderedTurnDiffSummaries:a,selectTurn:o,selectWholeConversation:s,selectedTurn:c,selectedTurnId:l,setDiffRenderMode:u,setDiffWordWrap:d,settings:f,turnStrip:p}=e,m,h;t[0]===p?(m=t[1],h=t[2]):(m=(0,Q.jsx)(Be,{direction:`left`,strip:p}),h=(0,Q.jsx)(Be,{direction:`right`,strip:p}),t[0]=p,t[1]=m,t[2]=h);let g=p.ref,_;t[3]!==p.canScrollLeft||t[4]!==p.canScrollRight?(_=Se({canScrollLeft:p.canScrollLeft,canScrollRight:p.canScrollRight}),t[3]=p.canScrollLeft,t[4]=p.canScrollRight,t[5]=_):_=t[5];let v=p.onWheel,y=l===null,b=l===null?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`,x;t[6]===b?x=t[7]:(x=P(`rounded-md border px-2 py-1 text-left transition-colors`,b),t[6]=b,t[7]=x);let S;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(`div`,{className:`text-[10px] leading-tight font-medium`,children:`All turns`}),t[8]=S):S=t[8];let C;t[9]===x?C=t[10]:(C=(0,Q.jsx)(`div`,{className:x,children:S}),t[9]=x,t[10]=C);let w;t[11]!==s||t[12]!==C||t[13]!==y?(w=(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:s,"data-turn-chip-selected":y,children:C}),t[11]=s,t[12]=C,t[13]=y,t[14]=w):w=t[14];let T;if(t[15]!==i||t[16]!==a||t[17]!==o||t[18]!==c?.turnId||t[19]!==f){let e;t[21]!==i||t[22]!==o||t[23]!==c?.turnId||t[24]!==f?(e=e=>(0,Q.jsx)(Ve,{summary:e,selected:e.turnId===c?.turnId,turnCount:e.checkpointTurnCount??i[e.turnId],timestampFormat:f.timestampFormat,onSelect:o},e.turnId),t[21]=i,t[22]=o,t[23]=c?.turnId,t[24]=f,t[25]=e):e=t[25],T=a.map(e),t[15]=i,t[16]=a,t[17]=o,t[18]=c?.turnId,t[19]=f,t[20]=T}else T=t[20];let E;t[26]!==w||t[27]!==T||t[28]!==_||t[29]!==p.onWheel||t[30]!==p.ref?(E=(0,Q.jsxs)(`div`,{ref:g,className:`turn-chip-strip flex gap-1 overflow-x-auto px-8 py-0.5`,style:_,onWheel:v,children:[w,T]}),t[26]=w,t[27]=T,t[28]=_,t[29]=p.onWheel,t[30]=p.ref,t[31]=E):E=t[31];let D;t[32]!==m||t[33]!==E||t[34]!==h?(D=(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 [-webkit-app-region:no-drag]`,children:[m,h,E]}),t[32]=m,t[33]=E,t[34]=h,t[35]=D):D=t[35];let O;t[36]===n?O=t[37]:(O=[n],t[36]=n,t[37]=O);let k;t[38]===u?k=t[39]:(k=e=>{let t=e[0];(t===`stacked`||t===`split`)&&u(t)},t[38]=u,t[39]=k);let A;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(H,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,Q.jsx)(se,{className:`size-3`})}),t[40]=A):A=t[40];let j;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(H,{"aria-label":`Split diff view`,value:`split`,children:(0,Q.jsx)(ie,{className:`size-3`})}),t[41]=j):j=t[41];let M;t[42]!==O||t[43]!==k?(M=(0,Q.jsxs)(G,{className:`shrink-0`,variant:`outline`,size:`xs`,value:O,onValueChange:k,children:[A,j]}),t[42]=O,t[43]=k,t[44]=M):M=t[44];let N=r?`Disable diff line wrapping`:`Enable diff line wrapping`,F=r?`Disable line wrapping`:`Enable line wrapping`,I;t[45]===d?I=t[46]:(I=e=>{d(!!e)},t[45]=d,t[46]=I);let L;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(le,{className:`size-3`}),t[47]=L):L=t[47];let R;t[48]!==r||t[49]!==N||t[50]!==F||t[51]!==I?(R=(0,Q.jsx)(H,{"aria-label":N,title:F,variant:`outline`,size:`xs`,pressed:r,onPressedChange:I,children:L}),t[48]=r,t[49]=N,t[50]=F,t[51]=I,t[52]=R):R=t[52];let z;t[53]!==M||t[54]!==R?(z=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[M,R]}),t[53]=M,t[54]=R,t[55]=z):z=t[55];let B;return t[56]!==D||t[57]!==z?(B=(0,Q.jsxs)(Q.Fragment,{children:[D,z]}),t[56]=D,t[57]=z,t[58]=B):B=t[58],B}function je(e){let t=(0,$.c)(18),{bodyState:n,diffRenderMode:r,diffWordWrap:i,openDiffFileInEditor:a,patchViewportRef:o,renderableFiles:s,renderablePatch:c,resolvedTheme:l}=e;if(n.kind===`no-thread`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ne,{children:`Select a thread to inspect turn diffs.`}),t[0]=e):e=t[0],e}if(n.kind===`not-git-repo`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ne,{children:`Turn diffs are unavailable because this project is not a git repository.`}),t[1]=e):e=t[1],e}if(n.kind===`no-completed-turns`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ne,{children:`No completed turns yet.`}),t[2]=e):e=t[2],e}let u;t[3]!==n.error||t[4]!==c?(u=n.error&&!c&&(0,Q.jsx)(`div`,{className:`px-3`,children:(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] text-destructive-foreground`,children:n.error})}),t[3]=n.error,t[4]=c,t[5]=u):u=t[5];let d;t[6]!==n||t[7]!==r||t[8]!==i||t[9]!==a||t[10]!==s||t[11]!==c||t[12]!==l?(d=c?c.kind===`files`?(0,Q.jsx)(W,{className:`diff-render-surface h-full min-h-0 overflow-auto px-2 pb-2`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:s.map(e=>{let t=Y(e),n=`${fe(e)}:${l}`;return(0,Q.jsx)(`div`,{"data-diff-file-path":t,className:`diff-render-file mb-2 rounded-md first:mt-2 last:mb-0`,onClickCapture:e=>{(e.nativeEvent.composedPath?.()??[]).some(Me)&&a(t)},children:(0,Q.jsx)(ge,{fileDiff:e,options:{diffStyle:r===`split`?`split`:`unified`,lineDiffType:`none`,overflow:i?`wrap`:`scroll`,theme:y(l),themeType:l,unsafeCSS:De}})},n)})}):(0,Q.jsx)(`div`,{className:`h-full overflow-auto p-2`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:c.reason}),(0,Q.jsx)(`pre`,{className:P(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,i?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:c.text})]})}):(0,Q.jsx)(Re,{bodyState:n}),t[6]=n,t[7]=r,t[8]=i,t[9]=a,t[10]=s,t[11]=c,t[12]=l,t[13]=d):d=t[13];let f;return t[14]!==o||t[15]!==u||t[16]!==d?(f=(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsxs)(`div`,{ref:o,className:`diff-panel-viewport min-h-0 min-w-0 flex-1 overflow-hidden`,children:[u,d]})}),t[14]=o,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function Me(e){return e instanceof Element&&e.hasAttribute(`data-title`)}function Ne(e){let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:n}),t[0]=n,t[1]=r),r}function Pe(){let e=(0,$.c)(19),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={strict:!1,select:Ie},e[0]=t):t=e[0];let n=j(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r={strict:!1,select:Fe},e[1]=r):r=e[1];let i=B(r),a=i.rightPanel===`diff`,o=n?.threadId??null,c,u;e[2]===n?u=e[3]:(u=l(n),e[2]=n,e[3]=u),c=u;let d=b(c),f=He(d),p=d?.worktreePath,m=f?.cwd,h;e[4]!==p||e[5]!==m?(h=K({threadWorktreePath:p,projectCwd:m}),e[4]=p,e[5]=m,e[6]=h):h=e[6];let g=h,_=d?.environmentId??null,v=g??null,y;e[7]!==_||e[8]!==v?(y={environmentId:_,cwd:v},e[7]=_,e[8]=v,e[9]=y):y=e[9];let x=s(y),S;e[10]===x.data?S=e[11]:(S=V(x.data),e[10]=x.data,e[11]=S);let C=S,w;return e[12]!==g||e[13]!==d||e[14]!==o||e[15]!==a||e[16]!==i||e[17]!==C?(w={activeThread:d,activeThreadId:o,activeCwd:g,isGitRepo:C,diffSearch:i,diffOpen:a},e[12]=g,e[13]=d,e[14]=o,e[15]=a,e[16]=i,e[17]=C,e[18]=w):w=e[18],w}function Fe(e){return z(e)}function Ie(e){return a(e)}function Le(e){let{activeThread:t,activeThreadId:n,activeCwd:r,isGitRepo:i,diffSearch:a,diffOpen:o}=Pe(),{turnDiffSummaries:s,inferredCheckpointTurnCountByTurnId:l}=I(t),u=a.diffTurnId??null,d=u===null?null:a.diffFilePath??null,{activeCheckpointRange:f,conversationCacheScope:p,orderedTurnDiffSummaries:m,selectedTurn:h}=(0,X.useMemo)(()=>te({summaries:s,inferredCheckpointTurnCountByTurnId:l,selectedTurnId:u}),[l,u,s]),g=c(xe(we({environmentId:t?.environmentId,threadId:n,range:f,selectedTurnId:h?.turnId,conversationCacheScope:p,enabled:i}))),_=g.isLoading,v=Ce(g.error),y=g.data?.diff,b=typeof y==`string`&&y.trim().length===0,{emptyDiffMessage:x}=(0,X.useMemo)(()=>ae(h),[h]),S=(0,X.useMemo)(()=>ce(y,`diff-panel:${e}`),[e,y]),C=(0,X.useMemo)(()=>Ue(S),[S]);return{activeCwd:r,activeThread:t,bodyState:ue({hasActiveThread:!!t,isGitRepo:i,turnSummaryCount:m.length,checkpointDiffError:v,hasRenderablePatch:!!S,isLoadingCheckpointDiff:_,hasNoNetChanges:b,emptyDiffMessage:x}),diffOpen:o,inferredCheckpointTurnCountByTurnId:l,orderedTurnDiffSummaries:m,renderableFiles:C,renderablePatch:S,selectedFilePath:d,selectedTurn:h,selectedTurnId:u}}function Re(e){let t=(0,$.c)(4),{bodyState:n}=e;if(n.kind===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(D,{label:`Loading checkpoint diff...`}),t[0]=e):e=t[0],e}let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(L,{className:`size-7 text-muted-foreground/25`}),t[1]=r):r=t[1];let i=n.kind===`empty`?n.message:`No diff is available for this range.`,a;return t[2]===i?a=t[3]:(a=(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 px-5 py-2 text-center`,children:[r,(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:i})]}),t[2]=i,t[3]=a),a}var ze=180;function Be(e){let t=(0,$.c)(14),{direction:n,strip:r}=e,i=n===`left`,a=i?r.canScrollLeft:r.canScrollRight,o=i?U:f,s=i?`left-0`:`right-0`,c=a?`border-border/70 hover:border-border hover:text-foreground`:`cursor-not-allowed border-border/40 text-muted-foreground/40`,l;t[0]!==s||t[1]!==c?(l=P(`absolute top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors`,s,c),t[0]=s,t[1]=c,t[2]=l):l=t[2];let u;t[3]!==i||t[4]!==r?(u=()=>r.scrollBy(i?-180:ze),t[3]=i,t[4]=r,t[5]=u):u=t[5];let d=!a,p=`Scroll turn list ${n}`,m;t[6]===o?m=t[7]:(m=(0,Q.jsx)(o,{className:`size-3.5`}),t[6]=o,t[7]=m);let h;return t[8]!==l||t[9]!==u||t[10]!==d||t[11]!==p||t[12]!==m?(h=(0,Q.jsx)(`button`,{type:`button`,className:l,onClick:u,disabled:d,"aria-label":p,children:m}),t[8]=l,t[9]=u,t[10]=d,t[11]=p,t[12]=m,t[13]=h):h=t[13],h}function Ve(e){let t=(0,$.c)(23),{summary:n,selected:r,turnCount:i,timestampFormat:a,onSelect:o}=e,s;t[0]!==o||t[1]!==n.turnId?(s=()=>o(n.turnId),t[0]=o,t[1]=n.turnId,t[2]=s):s=t[2];let c=n.turnId,l=r?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`,u;t[3]===l?u=t[4]:(u=P(`rounded-md border px-2 py-1 text-left transition-colors`,l),t[3]=l,t[4]=u);let d=i??`?`,f;t[5]===d?f=t[6]:(f=(0,Q.jsxs)(`span`,{className:`text-[10px] leading-tight font-medium`,children:[`Turn `,d]}),t[5]=d,t[6]=f);let p;t[7]!==n.completedAt||t[8]!==a?(p=m(n.completedAt,a),t[7]=n.completedAt,t[8]=a,t[9]=p):p=t[9];let h;t[10]===p?h=t[11]:(h=(0,Q.jsx)(`span`,{className:`text-[9px] leading-tight opacity-70`,children:p}),t[10]=p,t[11]=h);let g;t[12]!==f||t[13]!==h?(g=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[f,h]}),t[12]=f,t[13]=h,t[14]=g):g=t[14];let _;t[15]!==u||t[16]!==g?(_=(0,Q.jsx)(`div`,{className:u,children:g}),t[15]=u,t[16]=g,t[17]=_):_=t[17];let v;return t[18]!==r||t[19]!==n.turnId||t[20]!==s||t[21]!==_?(v=(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:s,title:c,"data-turn-chip-selected":r,children:_}),t[18]=r,t[19]=n.turnId,t[20]=s,t[21]=_,t[22]=v):v=t[22],v}function He(e){let t=(0,$.c)(3),n=e?.environmentId,r=e?.projectId,i;return t[0]!==n||t[1]!==r?(i=e=>n&&r?v(e,{environmentId:n,projectId:r}):void 0,t[0]=n,t[1]=r,t[2]=i):i=t[2],b(i)}function Ue(e){return!e||e.kind!==`files`?[]:e.files.toSorted((e,t)=>Y(e).localeCompare(Y(t),void 0,{numeric:!0,sensitivity:`base`}))}export{Oe as default};
64
+ //# sourceMappingURL=DiffPanel-B_HjSs6Q.js.map