@cmmd-center/forge 0.13.99 → 0.13.101

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.cjs CHANGED
@@ -66332,7 +66332,7 @@ function normalizeNumberish(value) {
66332
66332
  }
66333
66333
  //#endregion
66334
66334
  //#region package.json
66335
- var version$1 = "0.13.99";
66335
+ var version$1 = "0.13.101";
66336
66336
  //#endregion
66337
66337
  //#region src/sentry.ts
66338
66338
  const SERVER_APP_NAME = "forge-server";
@@ -103803,6 +103803,11 @@ const CLAUDE_IDENTITY_KEYS = new Set([
103803
103803
  "credentialGenerationId"
103804
103804
  ]);
103805
103805
  const CLAUDE_IDENTITY_OPTIONAL_KEYS = new Set(["providerAccountIdentity"]);
103806
+ const WORKSPACE_KEY_IDENTITY_KEYS = new Set([
103807
+ "kind",
103808
+ "provider",
103809
+ "organizationId"
103810
+ ]);
103806
103811
  function isRecord$16(value) {
103807
103812
  return typeof value === "object" && value !== null && !Array.isArray(value);
103808
103813
  }
@@ -103833,6 +103838,7 @@ function hasAllowedKeys(value, required, optional) {
103833
103838
  }
103834
103839
  function parseDeliveryIdentity(value, provider) {
103835
103840
  if (!isRecord$16(value)) return null;
103841
+ if (value.kind === "workspace_key") return parseWorkspaceKeyDeliveryIdentity(value, provider);
103836
103842
  if (provider === "openai") return parseCodexDeliveryIdentity(value);
103837
103843
  if (provider === "anthropic") return parseClaudeDeliveryIdentity(value);
103838
103844
  return null;
@@ -103866,6 +103872,33 @@ function parseClaudeDeliveryIdentity(value) {
103866
103872
  ...account
103867
103873
  };
103868
103874
  }
103875
+ /**
103876
+ * workspace_key is only valid on openai (codex) and anthropic (claude) token
103877
+ * providers. apex is never a workspace wallet provider.
103878
+ *
103879
+ * organizationId must be a positive integer (CMMD organizations.id).
103880
+ */
103881
+ function workspaceKeyProvider(tokenProvider) {
103882
+ if (tokenProvider === "openai") return "codex";
103883
+ if (tokenProvider === "anthropic") return "claude";
103884
+ return null;
103885
+ }
103886
+ function isValidOrganizationId(value) {
103887
+ return typeof value === "number" && Number.isInteger(value) && value > 0;
103888
+ }
103889
+ function parseWorkspaceKeyDeliveryIdentity(value, tokenProvider) {
103890
+ const expectedProvider = workspaceKeyProvider(tokenProvider);
103891
+ if (!expectedProvider) return null;
103892
+ if (!hasExactKeys$2(value, WORKSPACE_KEY_IDENTITY_KEYS)) return null;
103893
+ if (value.kind !== "workspace_key") return null;
103894
+ if (value.provider !== expectedProvider) return null;
103895
+ if (!isValidOrganizationId(value.organizationId)) return null;
103896
+ return {
103897
+ kind: "workspace_key",
103898
+ provider: expectedProvider,
103899
+ organizationId: value.organizationId
103900
+ };
103901
+ }
103869
103902
  function parseProviderRuntimeDeliveryReceipt(value, expected) {
103870
103903
  if (!isRecord$16(value) || !hasExactKeys$2(value, RECEIPT_KEYS)) return null;
103871
103904
  const identity = parseDeliveryIdentity(value.identity, expected.provider);
@@ -103902,17 +103935,28 @@ function readProviderDeliveryBinding(value) {
103902
103935
  identity
103903
103936
  };
103904
103937
  }
103905
- /** The Provider Account a delivery identity names, or null when it names none. */
103938
+ /**
103939
+ * The Provider Account a delivery identity names, or null when it names none.
103940
+ *
103941
+ * For workspace_key, returns a workspace-scoped string so that personal-to-
103942
+ * workspace crossings can be classified as account_switch in the drift
103943
+ * classifier. This string is NOT a personal account identifier (it does not
103944
+ * match pai_v1_) and is never used for credential lookup, only for drift
103945
+ * classification.
103946
+ */
103906
103947
  function providerDeliveryAccount(identity) {
103907
- return identity.kind === "provider_account" ? identity.providerAccountIdentity : identity.providerAccountIdentity ?? null;
103948
+ if (identity.kind === "provider_account") return identity.providerAccountIdentity;
103949
+ if (identity.kind === "credential_generation") return identity.providerAccountIdentity ?? null;
103950
+ return `workspace:${identity.organizationId}:${identity.provider}`;
103908
103951
  }
103909
103952
  function sameDeliveredCredential(left, right) {
103910
103953
  if (left.kind === "provider_account" && right.kind === "provider_account") return left.providerAccountIdentity === right.providerAccountIdentity;
103911
- return left.kind === "credential_generation" && right.kind === "credential_generation" && left.credentialGenerationId === right.credentialGenerationId;
103954
+ if (left.kind === "credential_generation" && right.kind === "credential_generation") return left.credentialGenerationId === right.credentialGenerationId;
103955
+ if (left.kind === "workspace_key" && right.kind === "workspace_key") return left.provider === right.provider && left.organizationId === right.organizationId;
103956
+ return false;
103912
103957
  }
103913
103958
  /**
103914
- * Names how one thread's delivery binding moved, which is the question the
103915
- * delivery layer could not answer while Claude's identity carried no account.
103959
+ * Names how one thread's delivery binding moved.
103916
103960
  *
103917
103961
  * `account_switch` needs both sides to name an account, the accounts to differ,
103918
103962
  * the delivered credential to change with them, and the runtime, machine and
@@ -103927,13 +103971,22 @@ function sameDeliveredCredential(left, right) {
103927
103971
  * names no account is `unknown` rather than guessed at, which keeps an
103928
103972
  * account-less binding compared on exactly the fields it was compared on before.
103929
103973
  *
103974
+ * For workspace_key:
103975
+ * - Same org, same provider, same epoch: `unchanged`.
103976
+ * - Cross-org workspace transitions: `unknown`. A workspace key for one org
103977
+ * must never resume a thread bound to another org, and no account transition
103978
+ * can authorize that crossing.
103979
+ * - Personal to workspace (and back): `account_switch`. The drift check blocks
103980
+ * this unless an explicit account transition is present.
103981
+ *
103930
103982
  * `providerDeliveryBindingsEqual` asks only whether the answer is `unchanged`.
103931
103983
  * `permitsProviderAccountTransition` in `provider/providerAccountTransition.ts`
103932
103984
  * asks whether it is `account_switch`, and is the Codex resume gate's rule
103933
103985
  * today. #3055 wires the Claude resume gate onto it.
103934
103986
  */
103935
103987
  function classifyProviderDeliveryBindingChange(prior, current) {
103936
- if (prior.runtimeId !== current.runtimeId || prior.machineId !== current.machineId || prior.identity.kind !== current.identity.kind || prior.identity.provider !== current.identity.provider) return "unknown";
103988
+ if (prior.runtimeId !== current.runtimeId || prior.machineId !== current.machineId || prior.identity.provider !== current.identity.provider) return "unknown";
103989
+ if (prior.identity.kind === "workspace_key" && current.identity.kind === "workspace_key" && prior.identity.organizationId !== current.identity.organizationId) return "unknown";
103937
103990
  const sameEpoch = prior.credentialEpoch === current.credentialEpoch;
103938
103991
  const sameCredential = sameDeliveredCredential(prior.identity, current.identity);
103939
103992
  const priorAccount = providerDeliveryAccount(prior.identity);
@@ -300230,7 +300283,7 @@ function resolveBuildCommitFromEnv(env) {
300230
300283
  * environment descriptor down instead of reporting an honest "unknown".
300231
300284
  */
300232
300285
  function readBakedBuildCommit() {
300233
- return "9bfc78a1e75f30a6ca72c10b29f06b31c2ac84ce";
300286
+ return "e239ee13358f33b5f81150389886a69cdd4d6c6b";
300234
300287
  }
300235
300288
  async function resolveServerBuildCommit(input) {
300236
300289
  if (isFullCommitSha(input.baked)) return input.baked;
package/dist/bin.mjs CHANGED
@@ -23,7 +23,7 @@ import { createCipheriv, createDecipheriv, createHash, createHmac, createPublicK
23
23
  import * as FS$1 from "node:fs";
24
24
  import fs, { accessSync, chmodSync, constants, createReadStream, existsSync, mkdirSync, mkdtempSync, promises, readFile, readFileSync, readdir, readdirSync, realpathSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
25
25
  import * as NodeOS from "node:os";
26
- import os, { homedir, networkInterfaces, tmpdir } from "node:os";
26
+ import $U, { homedir, networkInterfaces, tmpdir } from "node:os";
27
27
  import * as Path$1 from "node:path";
28
28
  import path, { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
29
29
  import { pathToFileURL } from "node:url";
@@ -50653,7 +50653,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
50653
50653
  const min = forceColor || 0;
50654
50654
  if (env.TERM === "dumb") return min;
50655
50655
  if (process$1.platform === "win32") {
50656
- const osRelease = os.release().split(".");
50656
+ const osRelease = $U.release().split(".");
50657
50657
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
50658
50658
  return 1;
50659
50659
  }
@@ -53096,7 +53096,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
53096
53096
  exports.processDetector = void 0;
53097
53097
  const api_1 = (init_esm$1(), __toCommonJS(esm_exports$1));
53098
53098
  const semconv_1 = require_semconv$1();
53099
- const os$4 = __require("os");
53099
+ const os$3 = __require("os");
53100
53100
  /**
53101
53101
  * ProcessDetector will be used to detect the resources related current process running
53102
53102
  * and being instrumented from the NodeJS Process module.
@@ -53118,7 +53118,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
53118
53118
  };
53119
53119
  if (process.argv.length > 1) attributes[semconv_1.ATTR_PROCESS_COMMAND] = process.argv[1];
53120
53120
  try {
53121
- const userInfo = os$4.userInfo();
53121
+ const userInfo = os$3.userInfo();
53122
53122
  attributes[semconv_1.ATTR_PROCESS_OWNER] = userInfo.username;
53123
53123
  } catch (e) {
53124
53124
  api_1.diag.debug(`error obtaining process owner: ${e}`);
@@ -66041,7 +66041,7 @@ function normalizeNumberish(value) {
66041
66041
  }
66042
66042
  //#endregion
66043
66043
  //#region package.json
66044
- var version$1 = "0.13.99";
66044
+ var version$1 = "0.13.101";
66045
66045
  //#endregion
66046
66046
  //#region src/sentry.ts
66047
66047
  const SERVER_APP_NAME = "forge-server";
@@ -76111,7 +76111,7 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
76111
76111
  var fs$6 = __require("fs");
76112
76112
  var path$5 = __require("path");
76113
76113
  var url$1 = __require("url");
76114
- var os$3 = __require("os");
76114
+ var os$2 = __require("os");
76115
76115
  var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
76116
76116
  var vars = process.config && process.config.variables || {};
76117
76117
  var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
@@ -76119,8 +76119,8 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
76119
76119
  var abi = versions.modules;
76120
76120
  if (versions.deno || process.isBun) abi = "unsupported";
76121
76121
  var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
76122
- var arch = process.env.npm_config_arch || os$3.arch();
76123
- var platform = process.env.npm_config_platform || os$3.platform();
76122
+ var arch = process.env.npm_config_arch || os$2.arch();
76123
+ var platform = process.env.npm_config_platform || os$2.platform();
76124
76124
  var libc = process.env.LIBC || (isMusl(platform) ? "musl" : "glibc");
76125
76125
  var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
76126
76126
  var uv = (versions.uv || "").split(".")[0];
@@ -93964,7 +93964,7 @@ const launchDetached = (launch) => gen(function* () {
93964
93964
  });
93965
93965
  const OpenLive = effect(Open, gen(function* () {
93966
93966
  const open = yield* tryPromise({
93967
- try: () => import("./open-yHTUkd2Y.mjs"),
93967
+ try: () => import("./open-2-reBrpv.mjs"),
93968
93968
  catch: (cause) => new OpenError$1({
93969
93969
  message: "failed to load browser opener",
93970
93970
  cause
@@ -103407,6 +103407,11 @@ const CLAUDE_IDENTITY_KEYS = new Set([
103407
103407
  "credentialGenerationId"
103408
103408
  ]);
103409
103409
  const CLAUDE_IDENTITY_OPTIONAL_KEYS = new Set(["providerAccountIdentity"]);
103410
+ const WORKSPACE_KEY_IDENTITY_KEYS = new Set([
103411
+ "kind",
103412
+ "provider",
103413
+ "organizationId"
103414
+ ]);
103410
103415
  function isRecord$16(value) {
103411
103416
  return typeof value === "object" && value !== null && !Array.isArray(value);
103412
103417
  }
@@ -103437,6 +103442,7 @@ function hasAllowedKeys(value, required, optional) {
103437
103442
  }
103438
103443
  function parseDeliveryIdentity(value, provider) {
103439
103444
  if (!isRecord$16(value)) return null;
103445
+ if (value.kind === "workspace_key") return parseWorkspaceKeyDeliveryIdentity(value, provider);
103440
103446
  if (provider === "openai") return parseCodexDeliveryIdentity(value);
103441
103447
  if (provider === "anthropic") return parseClaudeDeliveryIdentity(value);
103442
103448
  return null;
@@ -103470,6 +103476,33 @@ function parseClaudeDeliveryIdentity(value) {
103470
103476
  ...account
103471
103477
  };
103472
103478
  }
103479
+ /**
103480
+ * workspace_key is only valid on openai (codex) and anthropic (claude) token
103481
+ * providers. apex is never a workspace wallet provider.
103482
+ *
103483
+ * organizationId must be a positive integer (CMMD organizations.id).
103484
+ */
103485
+ function workspaceKeyProvider(tokenProvider) {
103486
+ if (tokenProvider === "openai") return "codex";
103487
+ if (tokenProvider === "anthropic") return "claude";
103488
+ return null;
103489
+ }
103490
+ function isValidOrganizationId(value) {
103491
+ return typeof value === "number" && Number.isInteger(value) && value > 0;
103492
+ }
103493
+ function parseWorkspaceKeyDeliveryIdentity(value, tokenProvider) {
103494
+ const expectedProvider = workspaceKeyProvider(tokenProvider);
103495
+ if (!expectedProvider) return null;
103496
+ if (!hasExactKeys$2(value, WORKSPACE_KEY_IDENTITY_KEYS)) return null;
103497
+ if (value.kind !== "workspace_key") return null;
103498
+ if (value.provider !== expectedProvider) return null;
103499
+ if (!isValidOrganizationId(value.organizationId)) return null;
103500
+ return {
103501
+ kind: "workspace_key",
103502
+ provider: expectedProvider,
103503
+ organizationId: value.organizationId
103504
+ };
103505
+ }
103473
103506
  function parseProviderRuntimeDeliveryReceipt(value, expected) {
103474
103507
  if (!isRecord$16(value) || !hasExactKeys$2(value, RECEIPT_KEYS)) return null;
103475
103508
  const identity = parseDeliveryIdentity(value.identity, expected.provider);
@@ -103506,17 +103539,28 @@ function readProviderDeliveryBinding(value) {
103506
103539
  identity
103507
103540
  };
103508
103541
  }
103509
- /** The Provider Account a delivery identity names, or null when it names none. */
103542
+ /**
103543
+ * The Provider Account a delivery identity names, or null when it names none.
103544
+ *
103545
+ * For workspace_key, returns a workspace-scoped string so that personal-to-
103546
+ * workspace crossings can be classified as account_switch in the drift
103547
+ * classifier. This string is NOT a personal account identifier (it does not
103548
+ * match pai_v1_) and is never used for credential lookup, only for drift
103549
+ * classification.
103550
+ */
103510
103551
  function providerDeliveryAccount(identity) {
103511
- return identity.kind === "provider_account" ? identity.providerAccountIdentity : identity.providerAccountIdentity ?? null;
103552
+ if (identity.kind === "provider_account") return identity.providerAccountIdentity;
103553
+ if (identity.kind === "credential_generation") return identity.providerAccountIdentity ?? null;
103554
+ return `workspace:${identity.organizationId}:${identity.provider}`;
103512
103555
  }
103513
103556
  function sameDeliveredCredential(left, right) {
103514
103557
  if (left.kind === "provider_account" && right.kind === "provider_account") return left.providerAccountIdentity === right.providerAccountIdentity;
103515
- return left.kind === "credential_generation" && right.kind === "credential_generation" && left.credentialGenerationId === right.credentialGenerationId;
103558
+ if (left.kind === "credential_generation" && right.kind === "credential_generation") return left.credentialGenerationId === right.credentialGenerationId;
103559
+ if (left.kind === "workspace_key" && right.kind === "workspace_key") return left.provider === right.provider && left.organizationId === right.organizationId;
103560
+ return false;
103516
103561
  }
103517
103562
  /**
103518
- * Names how one thread's delivery binding moved, which is the question the
103519
- * delivery layer could not answer while Claude's identity carried no account.
103563
+ * Names how one thread's delivery binding moved.
103520
103564
  *
103521
103565
  * `account_switch` needs both sides to name an account, the accounts to differ,
103522
103566
  * the delivered credential to change with them, and the runtime, machine and
@@ -103531,13 +103575,22 @@ function sameDeliveredCredential(left, right) {
103531
103575
  * names no account is `unknown` rather than guessed at, which keeps an
103532
103576
  * account-less binding compared on exactly the fields it was compared on before.
103533
103577
  *
103578
+ * For workspace_key:
103579
+ * - Same org, same provider, same epoch: `unchanged`.
103580
+ * - Cross-org workspace transitions: `unknown`. A workspace key for one org
103581
+ * must never resume a thread bound to another org, and no account transition
103582
+ * can authorize that crossing.
103583
+ * - Personal to workspace (and back): `account_switch`. The drift check blocks
103584
+ * this unless an explicit account transition is present.
103585
+ *
103534
103586
  * `providerDeliveryBindingsEqual` asks only whether the answer is `unchanged`.
103535
103587
  * `permitsProviderAccountTransition` in `provider/providerAccountTransition.ts`
103536
103588
  * asks whether it is `account_switch`, and is the Codex resume gate's rule
103537
103589
  * today. #3055 wires the Claude resume gate onto it.
103538
103590
  */
103539
103591
  function classifyProviderDeliveryBindingChange(prior, current) {
103540
- if (prior.runtimeId !== current.runtimeId || prior.machineId !== current.machineId || prior.identity.kind !== current.identity.kind || prior.identity.provider !== current.identity.provider) return "unknown";
103592
+ if (prior.runtimeId !== current.runtimeId || prior.machineId !== current.machineId || prior.identity.provider !== current.identity.provider) return "unknown";
103593
+ if (prior.identity.kind === "workspace_key" && current.identity.kind === "workspace_key" && prior.identity.organizationId !== current.identity.organizationId) return "unknown";
103541
103594
  const sameEpoch = prior.credentialEpoch === current.credentialEpoch;
103542
103595
  const sameCredential = sameDeliveredCredential(prior.identity, current.identity);
103543
103596
  const priorAccount = providerDeliveryAccount(prior.identity);
@@ -192161,7 +192214,7 @@ var Vce = {
192161
192214
  function Ve() {
192162
192215
  return Vce;
192163
192216
  }
192164
- var Us = os.homedir(), lk = os.tmpdir(), { env: Vc } = process$1, Yce = (e) => {
192217
+ var Us = $U.homedir(), lk = $U.tmpdir(), { env: Vc } = process$1, Yce = (e) => {
192165
192218
  let t = path.join(Us, "Library");
192166
192219
  return {
192167
192220
  data: path.join(t, "Application Support", e),
@@ -202361,12 +202414,12 @@ function qZ(e, t) {
202361
202414
  }
202362
202415
  return n;
202363
202416
  }
202364
- var os$2 = "https://code.claude.com/docs/en", kKe = [
202417
+ var os$1 = "https://code.claude.com/docs/en", kKe = [
202365
202418
  {
202366
202419
  matches: (e) => e.path === "permissions.defaultMode" && e.code === "invalid_value",
202367
202420
  tip: {
202368
202421
  suggestion: "Valid modes: \"acceptEdits\" (ask before file changes), \"plan\" (analysis only), \"bypassPermissions\" (auto-accept all), or \"default\" (standard behavior)",
202369
- docLink: `${os$2}/iam#permission-modes`
202422
+ docLink: `${os$1}/iam#permission-modes`
202370
202423
  }
202371
202424
  },
202372
202425
  {
@@ -202381,7 +202434,7 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
202381
202434
  matches: (e) => e.path.startsWith("env.") && e.code === "invalid_type",
202382
202435
  tip: {
202383
202436
  suggestion: "Environment variables must be strings. Wrap numbers and booleans in quotes. Example: \"DEBUG\": \"true\", \"PORT\": \"3000\"",
202384
- docLink: `${os$2}/settings#environment-variables`
202437
+ docLink: `${os$1}/settings#environment-variables`
202385
202438
  }
202386
202439
  },
202387
202440
  {
@@ -202392,14 +202445,14 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
202392
202445
  matches: (e) => e.path.startsWith("hooks.") && e.code === "invalid_key",
202393
202446
  tip: {
202394
202447
  suggestion: "Not a recognized hook event. Common events: PreToolUse, PostToolUse, UserPromptSubmit, SessionStart, SessionEnd, Stop. Check spelling and capitalization.",
202395
- docLink: `${os$2}/hooks`
202448
+ docLink: `${os$1}/hooks`
202396
202449
  }
202397
202450
  },
202398
202451
  {
202399
202452
  matches: (e) => /\.hooks\.\d+\.command$/.test(e.path) && e.code === "invalid_type" && e.received === "undefined",
202400
202453
  tip: {
202401
202454
  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\"}.",
202402
- docLink: `${os$2}/hooks#exec-form-and-shell-form`
202455
+ docLink: `${os$1}/hooks#exec-form-and-shell-form`
202403
202456
  }
202404
202457
  },
202405
202458
  {
@@ -202414,7 +202467,7 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
202414
202467
  matches: (e) => e.code === "unrecognized_keys",
202415
202468
  tip: {
202416
202469
  suggestion: "Check for typos or refer to the documentation for valid fields",
202417
- docLink: `${os$2}/settings`
202470
+ docLink: `${os$1}/settings`
202418
202471
  }
202419
202472
  },
202420
202473
  {
@@ -202429,13 +202482,13 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
202429
202482
  matches: (e) => e.path === "permissions.additionalDirectories" && e.code === "invalid_type",
202430
202483
  tip: {
202431
202484
  suggestion: "Must be an array of directory paths. Example: [\"~/projects\", \"/tmp/workspace\"]. You can also use --add-dir flag or /add-dir command",
202432
- docLink: `${os$2}/iam#working-directories`
202485
+ docLink: `${os$1}/iam#working-directories`
202433
202486
  }
202434
202487
  }
202435
202488
  ], AKe = {
202436
- permissions: `${os$2}/iam#configuring-permissions`,
202437
- env: `${os$2}/settings#environment-variables`,
202438
- hooks: `${os$2}/hooks`
202489
+ permissions: `${os$1}/iam#configuring-permissions`,
202490
+ env: `${os$1}/settings#environment-variables`,
202491
+ hooks: `${os$1}/hooks`
202439
202492
  };
202440
202493
  function GZ(e) {
202441
202494
  let t = kKe.find((r) => r.matches(e));
@@ -270960,7 +271013,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
270960
271013
  var dgram = __require("dgram");
270961
271014
  var thunky = require_thunky();
270962
271015
  var events = __require("events");
270963
- var os$1 = __require("os");
271016
+ var os = __require("os");
270964
271017
  var noop = function() {};
270965
271018
  module.exports = function(opts) {
270966
271019
  if (!opts) opts = {};
@@ -271091,14 +271144,14 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
271091
271144
  return that;
271092
271145
  };
271093
271146
  function defaultInterface() {
271094
- var networks = os$1.networkInterfaces();
271147
+ var networks = os.networkInterfaces();
271095
271148
  var names = Object.keys(networks);
271096
271149
  for (var i = 0; i < names.length; i++) {
271097
271150
  var net = networks[names[i]];
271098
271151
  for (var j = 0; j < net.length; j++) {
271099
271152
  var iface = net[j];
271100
271153
  if (isIPv4(iface.family) && !iface.internal) {
271101
- if (os$1.platform() === "darwin" && names[i] === "en0") return iface.address;
271154
+ if (os.platform() === "darwin" && names[i] === "en0") return iface.address;
271102
271155
  return "0.0.0.0";
271103
271156
  }
271104
271157
  }
@@ -271106,7 +271159,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
271106
271159
  return "127.0.0.1";
271107
271160
  }
271108
271161
  function allInterfaces() {
271109
- var networks = os$1.networkInterfaces();
271162
+ var networks = os.networkInterfaces();
271110
271163
  var names = Object.keys(networks);
271111
271164
  var res = [];
271112
271165
  for (var i = 0; i < names.length; i++) {
@@ -299677,7 +299730,7 @@ function resolveBuildCommitFromEnv(env) {
299677
299730
  * environment descriptor down instead of reporting an honest "unknown".
299678
299731
  */
299679
299732
  function readBakedBuildCommit() {
299680
- return "9bfc78a1e75f30a6ca72c10b29f06b31c2ac84ce";
299733
+ return "e239ee13358f33b5f81150389886a69cdd4d6c6b";
299681
299734
  }
299682
299735
  async function resolveServerBuildCommit(input) {
299683
299736
  if (isFullCommitSha(input.baked)) return input.baked;
@@ -324640,7 +324693,7 @@ const connectLoginCommand = make$33("login", {
324640
324693
  })).json();
324641
324694
  },
324642
324695
  openBrowser: async (url) => {
324643
- const open = (await import("./open-yHTUkd2Y.mjs")).default;
324696
+ const open = (await import("./open-2-reBrpv.mjs")).default;
324644
324697
  await open(url);
324645
324698
  return true;
324646
324699
  },
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ha as t,Mi as n,Ua as r,Wa as i}from"./Stream-mUTFnSY9.js";import{$l as a,Er as o,Fn as s,Hs as c,Rr as l,Sr as u,Tn as d,Tr as f,_l as p,c as m,d as h,ei as g,fi as _,fl as v,fn as y,gl as b,ii as x,is as S,jn as C,m as w,mi as T,ml as E,ms as D,o as O,qt as k,s as A,t as j,ti as M,u as N}from"./WorkerPoolContext-CvG3Ar57.js";import{hn as P}from"./CompositeItem-DNkNENOR.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-BIft5TIL.js";import{Dn as q,at as J,it as ee}from"./src-DFTFXdyK.js";import"./cmmdAuthRedirect-DCgS12fq.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-Bwhg79_3.js";var X=e(i(),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)(j),h=A(),g=(0,X.useRef)(null),_=m(n=>{if(n!=null){if(g.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);d==null?g.current=new re(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),l?void 0:p,!0):g.current=new pe(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),d,o,l?void 0:p,!0),g.current.hydrate({fileDiff:e,fileContainer:n,lineAnnotations:r,prerenderedHTML:a})}else{if(g.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);g.current.cleanUp(),g.current=null}});return me(()=>{let{current:n}=g;if(n==null)return;let a=Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),o=a!==void 0&&!k(n.options,a);n.setOptions(a),n.render({forceRender:o,fileDiff:e,lineAnnotations:r}),i!==void 0&&n.setSelectedLines(i)}),me(()=>{if(u&&g.current!=null){if(h===void 0)throw Error(`FileDiff: EditContext is not attached`);let e=h(n??{});if(e==null)throw Error(`FileDiff: EditProvider.createEditor must return an editor instance`);try{return e.edit(g.current)}catch(t){throw e.cleanUp(),t}}},[u]),{ref:_,getHoveredLine:(0,X.useCallback)(()=>g.current?.getHoveredLine(),[])}}function Z({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return t||r||n?{...e,controlledSelection:t,renderCustomHeader:n?O:e?.renderCustomHeader,renderGutterUtility:r?O:e?.renderGutterUtility}:e}var Q=r();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)(y,{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 $=t();function _e(e){return e.fromTurnCount===0?q(ee)({threadId:e.threadId,toTurnCount:e.toTurnCount}).pipe(n(e=>({kind:`fullThreadDiff`,input:e}))):q(J)({threadId:e.threadId,fromTurnCount:e.fromTurnCount,toTurnCount:e.toTurnCount}).pipe(n(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 b({queryKey:c.checkpointDiff(e),queryFn:async({signal:n})=>{if(!e.environmentId||!e.threadId||t._tag===`None`)throw Error(`Checkpoint diff is unavailable.`);let r=x(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{Ha as t,Mi as n,Ua as r,Wa as i}from"./Stream-mUTFnSY9.js";import{$l as a,Er as o,Fn as s,Hs as c,Rr as l,Sr as u,Tn as d,Tr as f,_l as p,c as m,d as h,ei as g,fi as _,fl as v,fn as y,gl as b,ii as x,is as S,jn as C,m as w,mi as T,ml as E,ms as D,o as O,qt as k,s as A,t as j,ti as M,u as N}from"./WorkerPoolContext-BUT5KWaW.js";import{hn as P}from"./CompositeItem-DNkNENOR.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-DGjaQEMH.js";import{Dn as q,at as J,it as ee}from"./src-DFTFXdyK.js";import"./cmmdAuthRedirect-DCgS12fq.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-BVcZbNTB.js";var X=e(i(),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)(j),h=A(),g=(0,X.useRef)(null),_=m(n=>{if(n!=null){if(g.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);d==null?g.current=new re(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),l?void 0:p,!0):g.current=new pe(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),d,o,l?void 0:p,!0),g.current.hydrate({fileDiff:e,fileContainer:n,lineAnnotations:r,prerenderedHTML:a})}else{if(g.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);g.current.cleanUp(),g.current=null}});return me(()=>{let{current:n}=g;if(n==null)return;let a=Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),o=a!==void 0&&!k(n.options,a);n.setOptions(a),n.render({forceRender:o,fileDiff:e,lineAnnotations:r}),i!==void 0&&n.setSelectedLines(i)}),me(()=>{if(u&&g.current!=null){if(h===void 0)throw Error(`FileDiff: EditContext is not attached`);let e=h(n??{});if(e==null)throw Error(`FileDiff: EditProvider.createEditor must return an editor instance`);try{return e.edit(g.current)}catch(t){throw e.cleanUp(),t}}},[u]),{ref:_,getHoveredLine:(0,X.useCallback)(()=>g.current?.getHoveredLine(),[])}}function Z({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return t||r||n?{...e,controlledSelection:t,renderCustomHeader:n?O:e?.renderCustomHeader,renderGutterUtility:r?O:e?.renderGutterUtility}:e}var Q=r();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)(y,{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 $=t();function _e(e){return e.fromTurnCount===0?q(ee)({threadId:e.threadId,toTurnCount:e.toTurnCount}).pipe(n(e=>({kind:`fullThreadDiff`,input:e}))):q(J)({threadId:e.threadId,fromTurnCount:e.fromTurnCount,toTurnCount:e.toTurnCount}).pipe(n(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 b({queryKey:c.checkpointDiff(e),queryFn:async({signal:n})=>{if(!e.environmentId||!e.threadId||t._tag===`None`)throw Error(`Checkpoint diff is unavailable.`);let r=x(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],
@@ -61,4 +61,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ha as t,Mi as n,Ua as
61
61
  text-decoration-color: currentColor;
62
62
  }
63
63
  `;function Oe(e){let t=(0,$.c)(44),{mode:n}=e,r=n===void 0?`inline`:n,{resolvedTheme:i}=f(),a=o(),[c,u]=(0,X.useState)(`stacked`),[p,m]=(0,X.useState)(a.diffWordWrap),g=(0,X.useRef)(null),_=(0,X.useRef)(!1),y=Te(),{activeCwd:b,activeThread:x,bodyState:S,diffOpen:C,inferredCheckpointTurnCountByTurnId:w,orderedTurnDiffSummaries:T,renderableFiles:D,renderablePatch:O,selectedFilePath:k,selectedTurn:A,selectedTurnId:j}=Le(i),N,P;t[0]!==C||t[1]!==a.diffWordWrap?(N=()=>{C&&!_.current&&m(a.diffWordWrap),_.current=C},P=[C,a.diffWordWrap],t[0]=C,t[1]=a.diffWordWrap,t[2]=N,t[3]=P):(N=t[2],P=t[3]),(0,X.useEffect)(N,P);let F;t[4]===k?F=t[5]:(F=()=>{!k||!g.current||Array.from(g.current.querySelectorAll(`[data-diff-file-path]`)).find(e=>e.dataset.diffFilePath===k)?.scrollIntoView({block:`nearest`})},t[4]=k,t[5]=F);let I;t[6]!==D||t[7]!==k?(I=[k,D],t[6]=D,t[7]=k,t[8]=I):I=t[8],(0,X.useEffect)(F,I);let L;t[9]===b?L=t[10]:(L=e=>{let t=l();if(!t)return;let n=b?d(e,b):e;M(t,n).catch(ke)},t[9]=b,t[10]=L);let R=L,z;t[11]===x?z=t[12]:(z=e=>{x&&s.getState().openDiff(E(v(x.environmentId,x.id)),e)},t[11]=x,t[12]=z);let B=z,V;t[13]===x?V=t[14]:(V=()=>{x&&s.getState().openDiff(E(v(x.environmentId,x.id)))},t[13]=x,t[14]=V);let H=V,U;t[15]===y.remeasure?U=t[16]:(U=()=>{let e=window.requestAnimationFrame(y.remeasure);return()=>window.cancelAnimationFrame(e)},t[15]=y.remeasure,t[16]=U);let W;t[17]!==T||t[18]!==j||t[19]!==y.remeasure?(W=[T,j,y.remeasure],t[17]=T,t[18]=j,t[19]=y.remeasure,t[20]=W):W=t[20],(0,X.useEffect)(U,W),Ee(y.ref,A?.turnId??j);let G;t[21]!==c||t[22]!==p||t[23]!==w||t[24]!==T||t[25]!==B||t[26]!==H||t[27]!==A||t[28]!==j||t[29]!==a||t[30]!==y?(G=(0,Q.jsx)(Ae,{diffRenderMode:c,diffWordWrap:p,inferredCheckpointTurnCountByTurnId:w,orderedTurnDiffSummaries:T,selectTurn:B,selectWholeConversation:H,selectedTurn:A,selectedTurnId:j,setDiffRenderMode:u,setDiffWordWrap:m,settings:a,turnStrip:y}),t[21]=c,t[22]=p,t[23]=w,t[24]=T,t[25]=B,t[26]=H,t[27]=A,t[28]=j,t[29]=a,t[30]=y,t[31]=G):G=t[31];let K=G,q;t[32]!==S||t[33]!==c||t[34]!==p||t[35]!==R||t[36]!==D||t[37]!==O||t[38]!==i?(q=(0,Q.jsx)(je,{bodyState:S,diffRenderMode:c,diffWordWrap:p,openDiffFileInEditor:R,patchViewportRef:g,renderableFiles:D,renderablePatch:O,resolvedTheme:i}),t[32]=S,t[33]=c,t[34]=p,t[35]=R,t[36]=D,t[37]=O,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)(h,{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)(R,{"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)(R,{"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)(F,{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`,I=r?`Disable line wrapping`:`Enable line wrapping`,L;t[45]===d?L=t[46]:(L=e=>{d(!!e)},t[45]=d,t[46]=L);let z;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Q.jsx)(le,{className:`size-3`}),t[47]=z):z=t[47];let B;t[48]!==r||t[49]!==N||t[50]!==I||t[51]!==L?(B=(0,Q.jsx)(R,{"aria-label":N,title:I,variant:`outline`,size:`xs`,pressed:r,onPressedChange:L,children:z}),t[48]=r,t[49]=N,t[50]=I,t[51]=L,t[52]=B):B=t[52];let V;t[53]!==M||t[54]!==B?(V=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[M,B]}),t[53]=M,t[54]=B,t[55]=V):V=t[55];let H;return t[56]!==D||t[57]!==V?(H=(0,Q.jsxs)(Q.Fragment,{children:[D,V]}),t[56]=D,t[57]=V,t[58]=H):H=t[58],H}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:w(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=a(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),o=i.rightPanel===`diff`,s=n?.threadId??null,c,l;e[2]===n?l=e[3]:(l=C(n),e[2]=n,e[3]=l),c=l;let u=D(c),d=He(u),f=u?.worktreePath,p=d?.cwd,m;e[4]!==f||e[5]!==p?(m=I({threadWorktreePath:f,projectCwd:p}),e[4]=f,e[5]=p,e[6]=m):m=e[6];let h=m,_=u?.environmentId??null,v=h??null,y;e[7]!==_||e[8]!==v?(y={environmentId:_,cwd:v},e[7]=_,e[8]=v,e[9]=y):y=e[9];let b=g(y),x;e[10]===b.data?x=e[11]:(x=z(b.data),e[10]=b.data,e[11]=x);let S=x,w;return e[12]!==h||e[13]!==u||e[14]!==s||e[15]!==o||e[16]!==i||e[17]!==S?(w={activeThread:u,activeThreadId:s,activeCwd:h,isGitRepo:S,diffSearch:i,diffOpen:o},e[12]=h,e[13]=u,e[14]=s,e[15]=o,e[16]=i,e[17]=S,e[18]=w):w=e[18],w}function Fe(e){return G(e)}function Ie(e){return _(e)}function Le(e){let{activeThread:t,activeThreadId:n,activeCwd:r,isGitRepo:i,diffSearch:a,diffOpen:o}=Pe(),{turnDiffSummaries:s,inferredCheckpointTurnCountByTurnId:c}=H(t),l=a.diffTurnId??null,u=l===null?null:a.diffFilePath??null,{activeCheckpointRange:d,conversationCacheScope:f,orderedTurnDiffSummaries:m,selectedTurn:h}=(0,X.useMemo)(()=>te({summaries:s,inferredCheckpointTurnCountByTurnId:c,selectedTurnId:l}),[c,l,s]),g=p(xe(we({environmentId:t?.environmentId,threadId:n,range:d,selectedTurnId:h?.turnId,conversationCacheScope:f,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:c,orderedTurnDiffSummaries:m,renderableFiles:C,renderablePatch:S,selectedFilePath:u,selectedTurn:h,selectedTurnId:l}}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)(N,{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:T,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,f=`Scroll turn list ${n}`,p;t[6]===o?p=t[7]:(p=(0,Q.jsx)(o,{className:`size-3.5`}),t[6]=o,t[7]=p);let m;return t[8]!==l||t[9]!==u||t[10]!==d||t[11]!==f||t[12]!==p?(m=(0,Q.jsx)(`button`,{type:`button`,className:l,onClick:u,disabled:d,"aria-label":f,children:p}),t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m):m=t[13],m}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`,d;t[3]===l?d=t[4]:(d=P(`rounded-md border px-2 py-1 text-left transition-colors`,l),t[3]=l,t[4]=d);let f=i??`?`,p;t[5]===f?p=t[6]:(p=(0,Q.jsxs)(`span`,{className:`text-[10px] leading-tight font-medium`,children:[`Turn `,f]}),t[5]=f,t[6]=p);let m;t[7]!==n.completedAt||t[8]!==a?(m=u(n.completedAt,a),t[7]=n.completedAt,t[8]=a,t[9]=m):m=t[9];let h;t[10]===m?h=t[11]:(h=(0,Q.jsx)(`span`,{className:`text-[9px] leading-tight opacity-70`,children:m}),t[10]=m,t[11]=h);let g;t[12]!==p||t[13]!==h?(g=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[p,h]}),t[12]=p,t[13]=h,t[14]=g):g=t[14];let _;t[15]!==d||t[16]!==g?(_=(0,Q.jsx)(`div`,{className:d,children:g}),t[15]=d,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?S(e,{environmentId:n,projectId:r}):void 0,t[0]=n,t[1]=r,t[2]=i):i=t[2],D(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-BfpDITGT.js.map
64
+ //# sourceMappingURL=DiffPanel-B1O5esHH.js.map