@cmmd-center/forge 0.10.13 → 0.10.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/{BunHttpServer-CjwNydcy.cjs → BunHttpServer-BhE7Szci.cjs} +6 -6
  2. package/dist/{BunHttpServer-GM72b26K.mjs → BunHttpServer-VI75aqJw.mjs} +6 -6
  3. package/dist/{BunPTY-B4Ra6mph.cjs → BunPTY-86ttlTi6.cjs} +3 -3
  4. package/dist/{BunPTY-C_ONQ8rt.mjs → BunPTY-oVISucl_.mjs} +3 -3
  5. package/dist/{BunServices-CUeOgVUt.cjs → BunServices-BwE9KexF.cjs} +3 -3
  6. package/dist/{BunServices-B-6JkR0Q.mjs → BunServices-D0JTDujL.mjs} +3 -3
  7. package/dist/{Cache-D56wNKiH.cjs → Cache-CWlxNDbC.cjs} +6 -6
  8. package/dist/{Cache-da-A9JAa.mjs → Cache-p0X77SKw.mjs} +3 -3
  9. package/dist/{Config-D0zF6ChD.mjs → Config-AqUR_lhX.mjs} +2 -2
  10. package/dist/{Config-e5bi-5Ut.cjs → Config-CkEzdD9L.cjs} +2 -2
  11. package/dist/{HttpServer-B-QOc7bR.cjs → HttpServer-DGoLR-kU.cjs} +4 -4
  12. package/dist/{HttpServer-HhjqDZlB.mjs → HttpServer-DNGCTTdk.mjs} +3 -3
  13. package/dist/{NodeHttpServer-Cy1XvkSE.cjs → NodeHttpServer-BPjxt_DT.cjs} +7 -7
  14. package/dist/{NodeHttpServer-DmEyd0J4.mjs → NodeHttpServer-Dw7ivXfX.mjs} +7 -7
  15. package/dist/{NodePTY-DU_KoZdd.mjs → NodePTY-CVH2yNYl.mjs} +4 -4
  16. package/dist/{NodePTY-wATyTf3M.cjs → NodePTY-Cps0jsDA.cjs} +4 -4
  17. package/dist/{NodeServices-DeNLW36O.mjs → NodeServices-CBNXOYLG.mjs} +3 -3
  18. package/dist/{NodeServices-pfwgkiUu.cjs → NodeServices-Cw6SxEbl.cjs} +3 -3
  19. package/dist/{NodeServices-BqfcuvmN.cjs → NodeServices-Ddr-tYRu.cjs} +1 -1
  20. package/dist/{NodeSqliteClient-PZ6NN2gq.cjs → NodeSqliteClient-CmxPzcBf.cjs} +7 -7
  21. package/dist/{NodeSqliteClient-BqUcml1B.mjs → NodeSqliteClient-DGInbxQ3.mjs} +6 -6
  22. package/dist/{NodeTerminal-DfKMT-mE.cjs → NodeTerminal-5iWbO0B2.cjs} +6 -6
  23. package/dist/{NodeTerminal-DBDxXuu0.mjs → NodeTerminal-BEGtoMSS.mjs} +3 -3
  24. package/dist/{PTY-DB-DmqyE.cjs → PTY-BxYDiW3h.cjs} +2 -2
  25. package/dist/{PTY-DdjcAGrF.mjs → PTY-rIPf52QR.mjs} +2 -2
  26. package/dist/{Path-CHDjKLrB.cjs → Path-Be7zSwar.cjs} +281 -54
  27. package/dist/{Path-B0vKGzx2.mjs → Path-C6Zb2WHp.mjs} +271 -58
  28. package/dist/{Schema-BK7-mN_J.mjs → Schema-CJyk7ah1.mjs} +65 -3
  29. package/dist/{Schema-Cf_uEUQU.cjs → Schema-dLi7Qssy.cjs} +76 -2
  30. package/dist/{SqlError-Du_dEWbw.cjs → SqlError-Bt0Bcd5C.cjs} +4 -4
  31. package/dist/{SqlError-LFObCDir.mjs → SqlError-cyJT2IRY.mjs} +3 -3
  32. package/dist/{SqliteClient-D4Srj6O8.cjs → SqliteClient-B08FzZM4.cjs} +6 -6
  33. package/dist/{SqliteClient-DdItRZUr.mjs → SqliteClient-CIsITMoQ.mjs} +5 -5
  34. package/dist/bin.cjs +313 -152
  35. package/dist/bin.mjs +426 -265
  36. package/dist/client/assets/{DiffPanel-DGiCJd76.js → DiffPanel-CniKcSxk.js} +3 -3
  37. package/dist/client/assets/{DiffPanel.logic-Dd5YF6k3.js → DiffPanel.logic-UU4xEJJO.js} +2 -2
  38. package/dist/client/assets/{DiffPanelShell-C-nlQxal.js → DiffPanelShell-BpK-LVcn.js} +119 -119
  39. package/dist/client/assets/{DiffWorkerPoolProvider-CfmtkBLg.js → DiffWorkerPoolProvider-B6dAKEIU.js} +9 -9
  40. package/dist/client/assets/{PullRequestCodePanel-xkECqRzW.js → PullRequestCodePanel-DHZ0dDeb.js} +3 -3
  41. package/dist/client/assets/{Virtualizer-CVyQexgp.js → Virtualizer-BaXfuCj_.js} +2 -2
  42. package/dist/client/assets/{index-CUmbThfW.css → index-BMcOaHS_.css} +1 -1
  43. package/dist/client/assets/{index-BD9iZwyM.js → index-CpaFL0BH.js} +59 -59
  44. package/dist/client/index.html +5 -5
  45. package/dist/forge-build.json +1 -1
  46. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -2,18 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  const require_chunk = require("./chunk-BhaIgcZK.cjs");
5
- const require_Schema$1 = require("./Schema-Cf_uEUQU.cjs");
6
- const require_Path = require("./Path-CHDjKLrB.cjs");
7
- const require_NodeTerminal = require("./NodeTerminal-DfKMT-mE.cjs");
8
- const require_NodeServices = require("./NodeServices-pfwgkiUu.cjs");
9
- const require_HttpServer = require("./HttpServer-B-QOc7bR.cjs");
10
- const require_Config = require("./Config-e5bi-5Ut.cjs");
11
- const require_Cache = require("./Cache-D56wNKiH.cjs");
12
- const require_SqlError = require("./SqlError-Du_dEWbw.cjs");
5
+ const require_Schema$1 = require("./Schema-dLi7Qssy.cjs");
6
+ const require_Path = require("./Path-Be7zSwar.cjs");
7
+ const require_NodeTerminal = require("./NodeTerminal-5iWbO0B2.cjs");
8
+ const require_NodeServices = require("./NodeServices-Cw6SxEbl.cjs");
9
+ const require_HttpServer = require("./HttpServer-DGoLR-kU.cjs");
10
+ const require_Config = require("./Config-CkEzdD9L.cjs");
11
+ const require_Cache = require("./Cache-CWlxNDbC.cjs");
12
+ const require_SqlError = require("./SqlError-Bt0Bcd5C.cjs");
13
13
  const require_Mime = require("./Mime-Bilnh8zE.cjs");
14
14
  const require_esm = require("./esm-BZhXwX5p.cjs");
15
15
  const require_runtimeControlAuthority = require("./runtimeControlAuthority-BdIovv-r.cjs");
16
- const require_PTY = require("./PTY-DB-DmqyE.cjs");
16
+ const require_PTY = require("./PTY-BxYDiW3h.cjs");
17
17
  let node_child_process = require("node:child_process");
18
18
  node_child_process = require_chunk.__toESM(node_child_process);
19
19
  let node_stream = require("node:stream");
@@ -65775,7 +65775,7 @@ function normalizeNumberish(value) {
65775
65775
  }
65776
65776
  //#endregion
65777
65777
  //#region package.json
65778
- var version$1 = "0.10.13";
65778
+ var version$1 = "0.10.16";
65779
65779
  //#endregion
65780
65780
  //#region src/sentry.ts
65781
65781
  const SERVER_APP_NAME = "forge-server";
@@ -66248,7 +66248,7 @@ function readCmmdAvatarUrl(raw) {
66248
66248
  function readTrimmedString$2(value) {
66249
66249
  return typeof value === "string" ? value.trim() || null : null;
66250
66250
  }
66251
- function asRecord$13(value) {
66251
+ function asRecord$14(value) {
66252
66252
  return value && typeof value === "object" ? value : null;
66253
66253
  }
66254
66254
  function readDirectPlanLabelFromRecord(obj) {
@@ -66260,26 +66260,26 @@ function readNestedPlanLabelFromRecord(obj) {
66260
66260
  function readCmmdPlanLabel(obj) {
66261
66261
  const direct = readDirectPlanLabelFromRecord(obj);
66262
66262
  if (direct) return direct;
66263
- const plan = asRecord$13(obj["plan"]);
66263
+ const plan = asRecord$14(obj["plan"]);
66264
66264
  if (plan) {
66265
66265
  const label = readNestedPlanLabelFromRecord(plan);
66266
66266
  if (label) return label;
66267
66267
  }
66268
- const subscription = asRecord$13(obj["subscription"]);
66268
+ const subscription = asRecord$14(obj["subscription"]);
66269
66269
  if (subscription) {
66270
66270
  const label = readNestedPlanLabelFromRecord(subscription);
66271
66271
  if (label) return label;
66272
- const subscriptionPlan = asRecord$13(subscription["plan"]);
66272
+ const subscriptionPlan = asRecord$14(subscription["plan"]);
66273
66273
  if (subscriptionPlan) {
66274
66274
  const nestedLabel = readNestedPlanLabelFromRecord(subscriptionPlan);
66275
66275
  if (nestedLabel) return nestedLabel;
66276
66276
  }
66277
66277
  }
66278
- const billing = asRecord$13(obj["billing"]);
66278
+ const billing = asRecord$14(obj["billing"]);
66279
66279
  if (billing) {
66280
66280
  const label = readNestedPlanLabelFromRecord(billing);
66281
66281
  if (label) return label;
66282
- const billingPlan = asRecord$13(billing["plan"]);
66282
+ const billingPlan = asRecord$14(billing["plan"]);
66283
66283
  if (billingPlan) return readNestedPlanLabelFromRecord(billingPlan);
66284
66284
  }
66285
66285
  return null;
@@ -70094,22 +70094,22 @@ const EMPTY_PARSED_ERROR = {
70094
70094
  message: null,
70095
70095
  raw: null
70096
70096
  };
70097
- function asRecord$12(value) {
70097
+ function asRecord$13(value) {
70098
70098
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
70099
70099
  }
70100
70100
  function readTrimmedString$1(value) {
70101
70101
  return (typeof value === "string" ? value.trim() : "") || null;
70102
70102
  }
70103
70103
  function readErrorEnvelope(record) {
70104
- return asRecord$12(record["error"]);
70104
+ return asRecord$13(record["error"]);
70105
70105
  }
70106
70106
  function readUpstreamErrorCode(body) {
70107
- const record = asRecord$12(body);
70107
+ const record = asRecord$13(body);
70108
70108
  if (record === null) return null;
70109
70109
  return readTrimmedString$1(record["code"]) ?? readTrimmedString$1(readErrorEnvelope(record)?.["code"]);
70110
70110
  }
70111
70111
  function readErrorMessage$2(raw) {
70112
- const record = asRecord$12(raw);
70112
+ const record = asRecord$13(raw);
70113
70113
  if (record === null) return null;
70114
70114
  const error = record["error"];
70115
70115
  const nestedMessage = readErrorEnvelope(record)?.["message"];
@@ -72197,7 +72197,7 @@ function readStringJS(length) {
72197
72197
  if (units.length > 0) result += fromCharCode.apply(String, units);
72198
72198
  return result;
72199
72199
  }
72200
- function readString$4(source, start, length) {
72200
+ function readString$5(source, start, length) {
72201
72201
  let existingSrc = src;
72202
72202
  src = source;
72203
72203
  position$1 = start;
@@ -74062,7 +74062,7 @@ function readStruct(src, position, srcEnd, unpackr) {
74062
74062
  }
74063
74063
  if (end == null) end = source.bytesEnd - refStart;
74064
74064
  if (source.srcString) return source.srcString.slice(ref, end);
74065
- return readString$4(src, ref + refStart, end - ref);
74065
+ return readString$5(src, ref + refStart, end - ref);
74066
74066
  };
74067
74067
  break;
74068
74068
  case UTF8:
@@ -75409,7 +75409,7 @@ const makeNoSerialization = /* @__PURE__ */ require_Schema$1.fnUntraced(function
75409
75409
  const services = yield* require_Schema$1.context();
75410
75410
  const scope = require_Schema$1.get(services, require_Schema$1.Scope);
75411
75411
  const trackFiber = require_Path.runIn(require_Schema$1.forkUnsafe(scope, "parallel"));
75412
- const concurrencySemaphore = concurrency === "unbounded" ? void 0 : yield* require_Path.make$4(concurrency);
75412
+ const concurrencySemaphore = concurrency === "unbounded" ? void 0 : yield* require_Path.make$5(concurrency);
75413
75413
  const clients = /* @__PURE__ */ new Map();
75414
75414
  let isShutdown = false;
75415
75415
  const shutdownLatch = require_Path.makeUnsafe$1(false);
@@ -75818,7 +75818,7 @@ const toHttpEffectWebsocket = /* @__PURE__ */ require_Schema$1.fnUntraced(functi
75818
75818
  });
75819
75819
  const makeSocketProtocol = /* @__PURE__ */ require_Schema$1.gen(function* () {
75820
75820
  const serialization = yield* RpcSerialization;
75821
- const disconnects = yield* require_Path.make$5();
75821
+ const disconnects = yield* require_Path.make$6();
75822
75822
  let clientId = 0;
75823
75823
  const clients = /* @__PURE__ */ new Map();
75824
75824
  const clientIds = /* @__PURE__ */ new Set();
@@ -77414,7 +77414,7 @@ require_Schema$1.succeed$1(TraceDiagnostics, TraceDiagnostics.of({ read: (option
77414
77414
  * through the server is what lets it ask at all.
77415
77415
  */
77416
77416
  const RUNTIMES_PATH = "/api/forge/context/runtimes";
77417
- function asRecord$11(value) {
77417
+ function asRecord$12(value) {
77418
77418
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
77419
77419
  }
77420
77420
  /** A trimmed string, or null. Empty and whitespace are the same as absent. */
@@ -77429,7 +77429,7 @@ function text$1(value) {
77429
77429
  * something that cannot work.
77430
77430
  */
77431
77431
  function toSummary(value) {
77432
- const row = asRecord$11(value);
77432
+ const row = asRecord$12(value);
77433
77433
  if (!row) return null;
77434
77434
  const runtimeId = text$1(row["runtimeId"]);
77435
77435
  const organizationId = row["organizationId"];
@@ -77453,7 +77453,7 @@ function listCloudRuntimes(input) {
77453
77453
  return require_Schema$1.gen(function* () {
77454
77454
  const jwt = input.jwt;
77455
77455
  if (jwt === null || jwt.trim().length === 0) return yield* require_Schema$1.fail(new CloudRuntimeListError({ failure: "not_signed_in" }));
77456
- const runtimes = asRecord$11(asRecord$11(yield* require_Schema$1.tryPromise({
77456
+ const runtimes = asRecord$12(asRecord$12(yield* require_Schema$1.tryPromise({
77457
77457
  try: () => input.request({
77458
77458
  method: "GET",
77459
77459
  jwt,
@@ -83008,7 +83008,7 @@ const makeServerSettings = require_Schema$1.gen(function* () {
83008
83008
  const { settingsPath } = yield* ServerConfig;
83009
83009
  const fs = yield* require_Path.FileSystem;
83010
83010
  const pathService = yield* require_Path.Path;
83011
- const writeSemaphore = yield* require_Path.make$4(1);
83011
+ const writeSemaphore = yield* require_Path.make$5(1);
83012
83012
  const cacheKey = "settings";
83013
83013
  const changesPubSub = yield* require_Path.unbounded$1();
83014
83014
  const startedRef = yield* require_HttpServer.make$3(false);
@@ -91856,7 +91856,7 @@ const makeKeybindings = require_Schema$1.gen(function* () {
91856
91856
  const { keybindingsConfigPath } = yield* ServerConfig;
91857
91857
  const fs = yield* require_Path.FileSystem;
91858
91858
  const path = yield* require_Path.Path;
91859
- const upsertSemaphore = yield* require_Path.make$4(1);
91859
+ const upsertSemaphore = yield* require_Path.make$5(1);
91860
91860
  const resolvedConfigCacheKey = "resolved";
91861
91861
  const changesPubSub = yield* require_Path.unbounded$1();
91862
91862
  const startedRef = yield* require_HttpServer.make$3(false);
@@ -97761,7 +97761,7 @@ const make$15 = (hooks) => require_Schema$1.gen(function* () {
97761
97761
  const selfRuntimeId = resolveRuntimeReplicationRuntimeId(config);
97762
97762
  const scanScope = yield* require_Schema$1.make$3("sequential");
97763
97763
  yield* require_Schema$1.addFinalizer(() => require_Schema$1.close(scanScope, require_Schema$1.void_$1));
97764
- const scanSemaphore = yield* require_Path.make$4(1);
97764
+ const scanSemaphore = yield* require_Path.make$5(1);
97765
97765
  const inFlight = /* @__PURE__ */ new Map();
97766
97766
  const ratesCachePath = path.join(config.stateDir, RATES_CACHE_FILE);
97767
97767
  const scanCachePath = path.join(config.stateDir, SCAN_CACHE_FILE);
@@ -98698,7 +98698,7 @@ const makeWorkspaceBulkTransfer = (options = {}) => require_Schema$1.gen(functio
98698
98698
  const workspacePaths = yield* WorkspacePaths;
98699
98699
  const workspaceEntries = yield* WorkspaceEntries;
98700
98700
  const fault = options.fault ?? (() => require_Schema$1.void_);
98701
- const transferLocks = yield* require_Schema$1.forEach(Array.from({ length: TRANSFER_LOCK_STRIPE_COUNT }), () => require_Path.make$4(1));
98701
+ const transferLocks = yield* require_Schema$1.forEach(Array.from({ length: TRANSFER_LOCK_STRIPE_COUNT }), () => require_Path.make$5(1));
98702
98702
  const withTransferLock = (transferId, effect) => transferLocks[transferLockStripe(transferId)].withPermit(effect);
98703
98703
  const findTransfer = (transferId) => sql`
98704
98704
  SELECT transfer_id AS "transferId", workspace_root AS "workspaceRoot",
@@ -100880,7 +100880,7 @@ const EMPTY_PLAN_VALUES = new Set([
100880
100880
  "none",
100881
100881
  "null"
100882
100882
  ]);
100883
- function asRecord$10(value) {
100883
+ function asRecord$11(value) {
100884
100884
  if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
100885
100885
  return value;
100886
100886
  }
@@ -100897,7 +100897,7 @@ function decodeJwtClaims(token) {
100897
100897
  try {
100898
100898
  const decoded = Buffer.from(payload, "base64url");
100899
100899
  if (decoded.byteLength > MAX_CLAIMS_BYTES) return void 0;
100900
- return asRecord$10(JSON.parse(decoded.toString("utf8")));
100900
+ return asRecord$11(JSON.parse(decoded.toString("utf8")));
100901
100901
  } catch {
100902
100902
  return;
100903
100903
  }
@@ -100919,7 +100919,7 @@ function findPlanType(claims) {
100919
100919
  const direct = fromRecord(claims);
100920
100920
  if (direct) return direct;
100921
100921
  for (const value of Object.values(claims)) {
100922
- const nested = asRecord$10(value);
100922
+ const nested = asRecord$11(value);
100923
100923
  if (!nested) continue;
100924
100924
  const found = fromRecord(nested);
100925
100925
  if (found) return found;
@@ -100936,7 +100936,7 @@ function readCodexAuthIdentity(authJson) {
100936
100936
  } catch {
100937
100937
  return {};
100938
100938
  }
100939
- const claims = decodeJwtClaims(asRecord$10(asRecord$10(parsed)?.tokens)?.id_token);
100939
+ const claims = decodeJwtClaims(asRecord$11(asRecord$11(parsed)?.tokens)?.id_token);
100940
100940
  if (!claims) return {};
100941
100941
  const email = findEmail(claims);
100942
100942
  const planType = findPlanType(claims);
@@ -116557,8 +116557,8 @@ require_Schema$1.effectDiscard(runMigrations());
116557
116557
  //#endregion
116558
116558
  //#region src/persistence/Layers/Sqlite.ts
116559
116559
  const defaultSqliteClientLoaders = {
116560
- bun: () => Promise.resolve().then(() => require("./SqliteClient-D4Srj6O8.cjs")),
116561
- node: () => Promise.resolve().then(() => require("./NodeSqliteClient-PZ6NN2gq.cjs"))
116560
+ bun: () => Promise.resolve().then(() => require("./SqliteClient-B08FzZM4.cjs")),
116561
+ node: () => Promise.resolve().then(() => require("./NodeSqliteClient-CmxPzcBf.cjs"))
116562
116562
  };
116563
116563
  const makeRuntimeSqliteLayer = require_Schema$1.fn("makeRuntimeSqliteLayer")(function* (config) {
116564
116564
  const loader = defaultSqliteClientLoaders[process.versions.bun !== void 0 ? "bun" : "node"];
@@ -149409,11 +149409,11 @@ function readObject(value) {
149409
149409
  function readArray(value) {
149410
149410
  return Array.isArray(value) ? value : void 0;
149411
149411
  }
149412
- function readString$3(value) {
149412
+ function readString$4(value) {
149413
149413
  return typeof value === "string" ? value : void 0;
149414
149414
  }
149415
149415
  function nonEmptyTrimmed$1(value) {
149416
- const candidate = readString$3(value)?.trim();
149416
+ const candidate = readString$4(value)?.trim();
149417
149417
  return candidate ? candidate : void 0;
149418
149418
  }
149419
149419
  function readBoolean$2(value) {
@@ -150195,6 +150195,23 @@ function issueCmmdLocalUserProviderEgressCredential(input) {
150195
150195
  });
150196
150196
  }
150197
150197
  //#endregion
150198
+ //#region src/provider/codexAccountTransition.ts
150199
+ function explicitProviderAccountTransition(fromAccountId, toAccountId) {
150200
+ if (!fromAccountId || !toAccountId || fromAccountId === toAccountId) return void 0;
150201
+ return {
150202
+ fromAccountId,
150203
+ toAccountId
150204
+ };
150205
+ }
150206
+ function permitsCodexAccountTransition(input) {
150207
+ const { transition, requestedAccountId, prior, current } = input;
150208
+ if (!transition || transition.fromAccountId === transition.toAccountId || transition.toAccountId !== requestedAccountId || prior.identity.kind !== "provider_account" || current.identity.kind !== "provider_account" || prior.identity.provider !== "codex" || current.identity.provider !== "codex") return false;
150209
+ return providerDeliveryBindingsEqual({
150210
+ ...prior,
150211
+ identity: current.identity
150212
+ }, current);
150213
+ }
150214
+ //#endregion
150198
150215
  //#region src/providerAuth/codexLocalAccountIdentity.ts
150199
150216
  const ACCOUNT_IDENTITY_PATH = "/api/forge/context/providers/codex/account-identity";
150200
150217
  const PROVIDER_ACCOUNT_IDENTITY$1 = /^pai_v1_[A-Za-z0-9_-]{43}$/;
@@ -150692,7 +150709,12 @@ var CodexAppServerManager = class extends node_events.EventEmitter {
150692
150709
  const rawPriorDeliveryBinding = input.resumeCursor.providerDeliveryBinding;
150693
150710
  const priorDeliveryBinding = readProviderDeliveryBinding(rawPriorDeliveryBinding);
150694
150711
  if (rawPriorDeliveryBinding !== void 0 && rawPriorDeliveryBinding !== null && !priorDeliveryBinding) throw new Error("Existing Codex history cannot resume because its persisted delivered provider account binding is unreadable.");
150695
- if (priorDeliveryBinding && !providerDeliveryBindingsEqual(priorDeliveryBinding, currentDeliveryBinding)) throw new Error("Existing Codex history cannot resume because the delivered provider account changed.");
150712
+ if (priorDeliveryBinding && !providerDeliveryBindingsEqual(priorDeliveryBinding, currentDeliveryBinding) && !permitsCodexAccountTransition({
150713
+ transition: input.accountTransition,
150714
+ requestedAccountId: input.providerAccountId,
150715
+ prior: priorDeliveryBinding,
150716
+ current: currentDeliveryBinding
150717
+ })) throw new Error("Existing Codex history cannot resume because the delivered provider account changed.");
150696
150718
  }
150697
150719
  const initialResumeCursor = initialCodexResumeCursor({
150698
150720
  resumeCursor: input.resumeCursor,
@@ -206906,7 +206928,7 @@ function createCodexBrowserDynamicTools() {
206906
206928
  function readArgs$3(value) {
206907
206929
  return value && typeof value === "object" ? value : {};
206908
206930
  }
206909
- function readString$2(args, key) {
206931
+ function readString$3(args, key) {
206910
206932
  const value = args[key];
206911
206933
  return typeof value === "string" && value.trim().length > 0 ? value : void 0;
206912
206934
  }
@@ -206935,27 +206957,27 @@ function createCodexBrowserDynamicToolHandler(browserManager, options = {}) {
206935
206957
  const toolScope = options.environmentId === void 0 ? {} : { environmentId: options.environmentId };
206936
206958
  const handlers = makeBrowserHandlers(browserManager, ThreadId.make(input.threadId), toolScope);
206937
206959
  const args = readArgs$3(input.arguments);
206938
- const tabId = readString$2(args, "tabId");
206960
+ const tabId = readString$3(args, "tabId");
206939
206961
  switch (input.tool) {
206940
206962
  case "forge_browser_list_sessions": return toCodexDynamicToolResult$2(await handlers.listSessions());
206941
206963
  case "forge_browser_name_session": {
206942
- const name = readString$2(args, "name");
206964
+ const name = readString$3(args, "name");
206943
206965
  if (!name) throw new Error("forge_browser_name_session requires a name.");
206944
206966
  return toCodexDynamicToolResult$2(await handlers.nameSession(name));
206945
206967
  }
206946
206968
  case "forge_browser_set_visibility": {
206947
- const visibility = readString$2(args, "visibility");
206969
+ const visibility = readString$3(args, "visibility");
206948
206970
  if (visibility !== "hidden" && visibility !== "visible") throw new Error("forge_browser_set_visibility requires visibility hidden or visible.");
206949
206971
  return toCodexDynamicToolResult$2(await handlers.setVisibility(visibility));
206950
206972
  }
206951
206973
  case "forge_browser_close_session":
206952
206974
  case "forge_browser_reset_session": return toCodexDynamicToolResult$2(await handlers.closeSession());
206953
206975
  case "forge_browser_navigate": {
206954
- const url = readString$2(args, "url");
206976
+ const url = readString$3(args, "url");
206955
206977
  if (!url) throw new Error("forge_browser_navigate requires a URL.");
206956
206978
  return toCodexDynamicToolResult$2(await handlers.navigate(url, tabId));
206957
206979
  }
206958
- case "forge_browser_new_tab": return toCodexDynamicToolResult$2(await handlers.newTab(readString$2(args, "url")));
206980
+ case "forge_browser_new_tab": return toCodexDynamicToolResult$2(await handlers.newTab(readString$3(args, "url")));
206959
206981
  case "forge_browser_close_tab":
206960
206982
  if (!tabId) throw new Error("forge_browser_close_tab requires a tabId.");
206961
206983
  return toCodexDynamicToolResult$2(await handlers.closeTab(tabId));
@@ -206966,33 +206988,33 @@ function createCodexBrowserDynamicToolHandler(browserManager, options = {}) {
206966
206988
  case "forge_browser_go_forward": return toCodexDynamicToolResult$2(await handlers.goForward(tabId));
206967
206989
  case "forge_browser_reload": return toCodexDynamicToolResult$2(await handlers.reload(tabId));
206968
206990
  case "forge_browser_click": {
206969
- const selector = readString$2(args, "selector");
206991
+ const selector = readString$3(args, "selector");
206970
206992
  if (!selector) throw new Error("forge_browser_click requires a selector.");
206971
206993
  return toCodexDynamicToolResult$2(await handlers.click(selector, tabId));
206972
206994
  }
206973
206995
  case "forge_browser_click_point": {
206974
206996
  const x = readNumber$2(args, "x");
206975
206997
  const y = readNumber$2(args, "y");
206976
- const button = readString$2(args, "button");
206998
+ const button = readString$3(args, "button");
206977
206999
  const clickCount = readNumber$2(args, "clickCount");
206978
207000
  if (x === void 0 || y === void 0) throw new Error("forge_browser_click_point requires x and y.");
206979
207001
  if (button !== void 0 && button !== "left" && button !== "middle" && button !== "right") throw new Error("forge_browser_click_point requires button left, middle, or right.");
206980
207002
  return toCodexDynamicToolResult$2(await handlers.clickPoint(x, y, button, clickCount, tabId));
206981
207003
  }
206982
207004
  case "forge_browser_type": {
206983
- const selector = readString$2(args, "selector");
207005
+ const selector = readString$3(args, "selector");
206984
207006
  if (!selector) throw new Error("forge_browser_type requires a selector.");
206985
- const text = readString$2(args, "text");
207007
+ const text = readString$3(args, "text");
206986
207008
  if (text === void 0) throw new Error("forge_browser_type requires text.");
206987
207009
  return toCodexDynamicToolResult$2(await handlers.type(selector, text, readBoolean$1(args, "append"), tabId));
206988
207010
  }
206989
207011
  case "forge_browser_type_text": {
206990
- const text = readString$2(args, "text");
207012
+ const text = readString$3(args, "text");
206991
207013
  if (text === void 0) throw new Error("forge_browser_type_text requires text.");
206992
207014
  return toCodexDynamicToolResult$2(await handlers.typeText(text, readBoolean$1(args, "pressEnter"), tabId));
206993
207015
  }
206994
207016
  case "forge_browser_press_key": {
206995
- const key = readString$2(args, "key");
207017
+ const key = readString$3(args, "key");
206996
207018
  if (!key) throw new Error("forge_browser_press_key requires a key.");
206997
207019
  return toCodexDynamicToolResult$2(await handlers.pressKey(key, tabId));
206998
207020
  }
@@ -207306,7 +207328,7 @@ function createCodexComputerDynamicToolHandler(computerManager) {
207306
207328
  function readArgs$1(value) {
207307
207329
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
207308
207330
  }
207309
- function readString$1(args, key) {
207331
+ function readString$2(args, key) {
207310
207332
  const value = args[key];
207311
207333
  return typeof value === "string" ? value : void 0;
207312
207334
  }
@@ -207326,7 +207348,7 @@ function readStringArray(args, key) {
207326
207348
  return value.filter((entry) => typeof entry === "string");
207327
207349
  }
207328
207350
  function readRequiredString(args, key, toolName) {
207329
- const value = readString$1(args, key)?.trim();
207351
+ const value = readString$2(args, key)?.trim();
207330
207352
  if (!value) throw new Error(`${toolName} requires ${key}.`);
207331
207353
  return value;
207332
207354
  }
@@ -207361,7 +207383,7 @@ async function runGitHubLifecycleTool(toolName, context) {
207361
207383
  action,
207362
207384
  args: lifecycleArgs,
207363
207385
  mode
207364
- }), mode === "write" ? readString$1(args, "confirmationId") : void 0);
207386
+ }), mode === "write" ? readString$2(args, "confirmationId") : void 0);
207365
207387
  }
207366
207388
  //#endregion
207367
207389
  //#region src/github/GitHubCodexPullRequestTools.ts
@@ -207371,8 +207393,8 @@ async function runGitHubPullRequestTool(toolName, context) {
207371
207393
  case "forge_github_create_pull_request": {
207372
207394
  const cwd = readRequiredString(args, "cwd", toolName);
207373
207395
  const title = readRequiredString(args, "title", toolName);
207374
- const body = readString$1(args, "body");
207375
- const headBranch = readString$1(args, "headBranch")?.trim();
207396
+ const body = readString$2(args, "body");
207397
+ const headBranch = readString$2(args, "headBranch")?.trim();
207376
207398
  if (body === void 0) throw new Error("forge_github_create_pull_request requires body.");
207377
207399
  const request = {
207378
207400
  cwd,
@@ -207381,7 +207403,7 @@ async function runGitHubPullRequestTool(toolName, context) {
207381
207403
  baseBranch: readRequiredString(args, "baseBranch", toolName),
207382
207404
  ...headBranch ? { headBranch } : {}
207383
207405
  };
207384
- return runTool(request, () => broker.createPullRequest(auth, request), readString$1(args, "confirmationId"));
207406
+ return runTool(request, () => broker.createPullRequest(auth, request), readString$2(args, "confirmationId"));
207385
207407
  }
207386
207408
  case "forge_github_get_pull_request": {
207387
207409
  const cwd = readRequiredString(args, "cwd", toolName);
@@ -207403,29 +207425,29 @@ function runStatus$1({ auth, broker, runTool }) {
207403
207425
  return runTool({}, () => broker.status(auth));
207404
207426
  }
207405
207427
  function runListRepositories({ args, auth, broker, runTool }) {
207406
- const search = readString$1(args, "search");
207428
+ const search = readString$2(args, "search");
207407
207429
  return runTool({ search: search ?? null }, () => broker.listRepositories(auth, { search }));
207408
207430
  }
207409
207431
  function runCloneRepository({ args, auth, broker, runTool }) {
207410
207432
  const toolName = "forge_github_clone_repository";
207411
207433
  const repoFullName = readRequiredString(args, "repoFullName", toolName);
207412
207434
  const destination = readRequiredString(args, "destination", toolName);
207413
- const branch = readString$1(args, "branch");
207435
+ const branch = readString$2(args, "branch");
207414
207436
  const request = {
207415
207437
  repoFullName,
207416
207438
  destination,
207417
207439
  ...branch ? { branch } : {}
207418
207440
  };
207419
- return runTool(request, () => broker.cloneRepository(auth, request), readString$1(args, "confirmationId"));
207441
+ return runTool(request, () => broker.cloneRepository(auth, request), readString$2(args, "confirmationId"));
207420
207442
  }
207421
207443
  function runCreateRepository({ args, auth, broker, runTool }) {
207422
207444
  const toolName = "forge_github_create_repository";
207423
207445
  const owner = readRequiredString(args, "owner", toolName);
207424
207446
  const name = readRequiredString(args, "name", toolName);
207425
- const visibility = readString$1(args, "visibility");
207447
+ const visibility = readString$2(args, "visibility");
207426
207448
  if (visibility !== void 0 && visibility !== "private" && visibility !== "public") throw new Error("forge_github_create_repository visibility must be private or public.");
207427
207449
  const repositoryVisibility = visibility;
207428
- const description = readString$1(args, "description");
207450
+ const description = readString$2(args, "description");
207429
207451
  const request = {
207430
207452
  owner,
207431
207453
  name,
@@ -207433,32 +207455,32 @@ function runCreateRepository({ args, auth, broker, runTool }) {
207433
207455
  ...repositoryVisibility ? { visibility: repositoryVisibility } : {},
207434
207456
  ...description !== void 0 ? { description } : {}
207435
207457
  };
207436
- return runTool(request, () => broker.createRepository(auth, request), readString$1(args, "confirmationId"));
207458
+ return runTool(request, () => broker.createRepository(auth, request), readString$2(args, "confirmationId"));
207437
207459
  }
207438
207460
  function runLinkProjectRepository({ args, auth, broker, runTool }) {
207439
207461
  const toolName = "forge_github_link_project_repository";
207440
207462
  const cwd = readRequiredString(args, "cwd", toolName);
207441
207463
  const repoFullName = readRequiredString(args, "repoFullName", toolName);
207442
- const branch = readString$1(args, "branch");
207464
+ const branch = readString$2(args, "branch");
207443
207465
  const request = {
207444
207466
  cwd,
207445
207467
  repoFullName,
207446
207468
  ...branch ? { branch } : {}
207447
207469
  };
207448
- return runTool(request, () => broker.linkProjectRepository(auth, request), readString$1(args, "confirmationId"));
207470
+ return runTool(request, () => broker.linkProjectRepository(auth, request), readString$2(args, "confirmationId"));
207449
207471
  }
207450
207472
  function runPushBranch({ args, auth, broker, runTool }) {
207451
207473
  const cwd = readRequiredString(args, "cwd", "forge_github_push_branch");
207452
- const branch = readString$1(args, "branch");
207474
+ const branch = readString$2(args, "branch");
207453
207475
  const request = {
207454
207476
  cwd,
207455
207477
  ...branch ? { branch } : {}
207456
207478
  };
207457
- return runTool(request, () => broker.pushProjectBranch(auth, request), readString$1(args, "confirmationId"));
207479
+ return runTool(request, () => broker.pushProjectBranch(auth, request), readString$2(args, "confirmationId"));
207458
207480
  }
207459
207481
  function runRefreshCredentials({ args, auth, broker, runTool }) {
207460
207482
  const request = { cwd: readRequiredString(args, "cwd", "forge_github_refresh_credentials") };
207461
- return runTool(request, () => broker.refreshProjectCredentials(auth, request), readString$1(args, "confirmationId"));
207483
+ return runTool(request, () => broker.refreshProjectCredentials(auth, request), readString$2(args, "confirmationId"));
207462
207484
  }
207463
207485
  const repositoryToolHandlers = {
207464
207486
  forge_github_status: runStatus$1,
@@ -207496,7 +207518,7 @@ async function runGitHubWorkflowTool(toolName, context) {
207496
207518
  }
207497
207519
  function listWorkflowRuns({ args, auth, broker, runTool }) {
207498
207520
  const cwd = readRequiredString(args, "cwd", "forge_github_list_workflow_runs");
207499
- const branch = readString$1(args, "branch")?.trim();
207521
+ const branch = readString$2(args, "branch")?.trim();
207500
207522
  const limit = readNumber$1(args, "limit");
207501
207523
  const request = {
207502
207524
  cwd,
@@ -207515,7 +207537,7 @@ function watchWorkflowRun({ args, auth, broker, runTool }) {
207515
207537
  }
207516
207538
  function getWorkflowRunLogs({ args, auth, broker, runTool }) {
207517
207539
  const { cwd, runId } = readWorkflowRunRequest(args, "forge_github_get_workflow_run_logs");
207518
- const jobId = readString$1(args, "jobId")?.trim();
207540
+ const jobId = readString$2(args, "jobId")?.trim();
207519
207541
  const request = {
207520
207542
  cwd,
207521
207543
  runId,
@@ -207525,16 +207547,16 @@ function getWorkflowRunLogs({ args, auth, broker, runTool }) {
207525
207547
  }
207526
207548
  function downloadWorkflowArtifacts({ args, auth, broker, runTool }) {
207527
207549
  const cwd = readRequiredString(args, "cwd", "forge_github_download_workflow_artifacts");
207528
- const runId = readString$1(args, "runId")?.trim();
207529
- const artifactName = readString$1(args, "artifactName")?.trim();
207530
- const destinationDir = readString$1(args, "destinationDir")?.trim();
207550
+ const runId = readString$2(args, "runId")?.trim();
207551
+ const artifactName = readString$2(args, "artifactName")?.trim();
207552
+ const destinationDir = readString$2(args, "destinationDir")?.trim();
207531
207553
  const request = {
207532
207554
  cwd,
207533
207555
  ...runId ? { runId } : {},
207534
207556
  ...artifactName ? { artifactName } : {},
207535
207557
  ...destinationDir ? { destinationDir } : {}
207536
207558
  };
207537
- return runTool(request, () => broker.downloadWorkflowArtifacts(auth, request), readString$1(args, "confirmationId"));
207559
+ return runTool(request, () => broker.downloadWorkflowArtifacts(auth, request), readString$2(args, "confirmationId"));
207538
207560
  }
207539
207561
  function listWorkflows({ args, auth, broker, runTool }) {
207540
207562
  const cwd = readRequiredString(args, "cwd", "forge_github_list_workflows");
@@ -207553,7 +207575,7 @@ function getWorkflow({ args, auth, broker, runTool }) {
207553
207575
  }
207554
207576
  function runWorkflow({ args, auth, broker, runTool }) {
207555
207577
  const { cwd, workflow } = readWorkflowRequest(args, "forge_github_run_workflow");
207556
- const ref = readString$1(args, "ref")?.trim();
207578
+ const ref = readString$2(args, "ref")?.trim();
207557
207579
  const fields = readStringRecord(args, "fields");
207558
207580
  const request = {
207559
207581
  cwd,
@@ -207561,7 +207583,7 @@ function runWorkflow({ args, auth, broker, runTool }) {
207561
207583
  ...ref ? { ref } : {},
207562
207584
  ...fields && Object.keys(fields).length > 0 ? { fields } : {}
207563
207585
  };
207564
- return runTool(request, () => broker.runWorkflow(auth, request), readString$1(args, "confirmationId"));
207586
+ return runTool(request, () => broker.runWorkflow(auth, request), readString$2(args, "confirmationId"));
207565
207587
  }
207566
207588
  function enableWorkflow(context) {
207567
207589
  return runWorkflowToggle("forge_github_enable_workflow", context, "enableWorkflow");
@@ -207584,12 +207606,12 @@ function readWorkflowRequest(args, toolName) {
207584
207606
  async function runWorkflowRunMutation(toolName, context, brokerMethod) {
207585
207607
  const { args, auth, broker, runTool } = context;
207586
207608
  const request = readWorkflowRunRequest(args, toolName);
207587
- return runTool(request, () => broker[brokerMethod](auth, request), readString$1(args, "confirmationId"));
207609
+ return runTool(request, () => broker[brokerMethod](auth, request), readString$2(args, "confirmationId"));
207588
207610
  }
207589
207611
  function runWorkflowToggle(toolName, context, brokerMethod) {
207590
207612
  const { args, auth, broker, runTool } = context;
207591
207613
  const request = readWorkflowRequest(args, toolName);
207592
- return runTool(request, () => broker[brokerMethod](auth, request), readString$1(args, "confirmationId"));
207614
+ return runTool(request, () => broker[brokerMethod](auth, request), readString$2(args, "confirmationId"));
207593
207615
  }
207594
207616
  //#endregion
207595
207617
  //#region src/github/GitHubCodexWorkspaceGitTools.ts
@@ -207606,7 +207628,7 @@ async function runWorkspaceGitTool(toolName, context) {
207606
207628
  case "forge_git_commit": return runCommit("forge_git_commit", context);
207607
207629
  case "forge_git_reset_hard": return runResetHard("forge_git_reset_hard", context);
207608
207630
  case "forge_git": {
207609
- const operation = readString$1(args, "operation")?.trim();
207631
+ const operation = readString$2(args, "operation")?.trim();
207610
207632
  switch (operation) {
207611
207633
  case "status": return runStatus(toolName, context, "status");
207612
207634
  case "log": return runLog(toolName, context);
@@ -207635,7 +207657,7 @@ function runLog(toolName, { args, broker, runTool }) {
207635
207657
  }
207636
207658
  function runStash(toolName, { args, broker, runTool }, operation) {
207637
207659
  const cwd = readRequiredString(args, "cwd", toolName);
207638
- const message = readString$1(args, "message")?.trim();
207660
+ const message = readString$2(args, "message")?.trim();
207639
207661
  return runTool({
207640
207662
  cwd,
207641
207663
  ...operation ? { operation } : {},
@@ -207643,12 +207665,12 @@ function runStash(toolName, { args, broker, runTool }, operation) {
207643
207665
  }, () => broker.stashWorkspace({
207644
207666
  cwd,
207645
207667
  ...message ? { message } : {}
207646
- }), readString$1(args, "confirmationId"));
207668
+ }), readString$2(args, "confirmationId"));
207647
207669
  }
207648
207670
  function runCommit(toolName, { args, broker, runTool }, operation) {
207649
207671
  const cwd = readRequiredString(args, "cwd", toolName);
207650
207672
  const message = readRequiredString(args, "message", operation ? `${toolName} operation=commit` : toolName);
207651
- const branch = readString$1(args, "branch")?.trim();
207673
+ const branch = readString$2(args, "branch")?.trim();
207652
207674
  return runTool({
207653
207675
  cwd,
207654
207676
  ...operation ? { operation } : {},
@@ -207658,11 +207680,11 @@ function runCommit(toolName, { args, broker, runTool }, operation) {
207658
207680
  cwd,
207659
207681
  message,
207660
207682
  ...branch ? { branch } : {}
207661
- }), readString$1(args, "confirmationId"));
207683
+ }), readString$2(args, "confirmationId"));
207662
207684
  }
207663
207685
  function runResetHard(toolName, { args, broker, runTool }, operation) {
207664
207686
  const cwd = readRequiredString(args, "cwd", toolName);
207665
- const ref = readString$1(args, "ref")?.trim();
207687
+ const ref = readString$2(args, "ref")?.trim();
207666
207688
  return runTool({
207667
207689
  cwd,
207668
207690
  ...operation ? { operation } : {},
@@ -207670,7 +207692,7 @@ function runResetHard(toolName, { args, broker, runTool }, operation) {
207670
207692
  }, () => broker.resetWorkspaceHard({
207671
207693
  cwd,
207672
207694
  ...ref ? { ref } : {}
207673
- }), readString$1(args, "confirmationId"));
207695
+ }), readString$2(args, "confirmationId"));
207674
207696
  }
207675
207697
  //#endregion
207676
207698
  //#region src/github/GitHubCodexToolRunner.ts
@@ -208304,7 +208326,7 @@ function createCodexGitHubDynamicToolHandler(options = {}) {
208304
208326
  error: "Forge could not resolve the authenticated user session for this thread. Send a new turn from the Forge UI and retry."
208305
208327
  }, false);
208306
208328
  const args = readArgs$1(input.arguments);
208307
- const dispatchOperation = input.tool === "forge_git" ? readString$1(args, "operation")?.trim() : void 0;
208329
+ const dispatchOperation = input.tool === "forge_git" ? readString$2(args, "operation")?.trim() : void 0;
208308
208330
  const operation = dispatchOperation ?? operationForTool(input.tool);
208309
208331
  const requiresConfirmation = !bypassWriteConfirmation && (isGitHubWriteTool(input.tool) || dispatchOperation !== void 0 && FORGE_GIT_WRITE_OPERATIONS.has(dispatchOperation));
208310
208332
  const runTool = async (request, execute, confirmationId) => {
@@ -208826,7 +208848,7 @@ function createCodexDevServerDynamicTools() {
208826
208848
  function readArgs(value) {
208827
208849
  return value && typeof value === "object" ? value : {};
208828
208850
  }
208829
- function readString(args, key) {
208851
+ function readString$1(args, key) {
208830
208852
  const value = args[key];
208831
208853
  return typeof value === "string" && value.trim().length > 0 ? value : void 0;
208832
208854
  }
@@ -208839,8 +208861,8 @@ function readBoolean(args, key) {
208839
208861
  return typeof value === "boolean" ? value : void 0;
208840
208862
  }
208841
208863
  function runDevServerStart(handlers, args) {
208842
- const command = readString(args, "command");
208843
- const cwd = readString(args, "cwd");
208864
+ const command = readString$1(args, "command");
208865
+ const cwd = readString$1(args, "cwd");
208844
208866
  const port = readNumber(args, "port");
208845
208867
  const readyTimeoutMs = readNumber(args, "readyTimeoutMs");
208846
208868
  const openPreview = readBoolean(args, "openPreview");
@@ -208996,7 +209018,7 @@ function readConnectorParams(tool, args) {
208996
209018
  switch (tool.tool) {
208997
209019
  case "forge_gmail_search": return {
208998
209020
  ...params,
208999
- query: readString$1(args, "query") ?? ""
209021
+ query: readString$2(args, "query") ?? ""
209000
209022
  };
209001
209023
  case "forge_gmail_list_recent": return {
209002
209024
  ...params,
@@ -209008,7 +209030,7 @@ function readConnectorParams(tool, args) {
209008
209030
  }
209009
209031
  }
209010
209032
  function appendString(target, args, key) {
209011
- const value = readString$1(args, key);
209033
+ const value = readString$2(args, key);
209012
209034
  if (value !== void 0) target[key] = value;
209013
209035
  }
209014
209036
  function appendNumber(target, args, key) {
@@ -209597,7 +209619,7 @@ const collectStreamAsString = (stream) => stream.pipe(require_Path.decodeText(),
209597
209619
  //#region src/orchestration/WorkerPlanCodexTools.ts
209598
209620
  const FORGE_PROPOSE_WORKER_TASKS_TOOL = "forge_propose_worker_tasks";
209599
209621
  const MAX_WORKER_PLAN_ITEMS = 5;
209600
- function asRecord$9(value) {
209622
+ function asRecord$10(value) {
209601
209623
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
209602
209624
  }
209603
209625
  function readTrimmedString(value) {
@@ -209613,7 +209635,7 @@ function isValidWorkerSummary(value) {
209613
209635
  return value !== void 0 && value.length > 0 && value.length <= 4e3;
209614
209636
  }
209615
209637
  function decodeWorkerPlanItem(value) {
209616
- const item = asRecord$9(value);
209638
+ const item = asRecord$10(value);
209617
209639
  const slug = readTrimmedString(item?.slug);
209618
209640
  const title = readTrimmedString(item?.title);
209619
209641
  const summary = readTrimmedString(item?.summary);
@@ -209677,7 +209699,7 @@ function createWorkerPlanDynamicTools() {
209677
209699
  function createWorkerPlanDynamicToolHandler() {
209678
209700
  return async (input) => {
209679
209701
  if (input.tool !== "forge_propose_worker_tasks") throw new Error(`Unsupported worker-plan tool: ${input.tool}`);
209680
- if (!decodeWorkerPlanItems(asRecord$9(input.arguments)?.items)) throw new Error("Worker plans require one to five unique, fully described items.");
209702
+ if (!decodeWorkerPlanItems(asRecord$10(input.arguments)?.items)) throw new Error("Worker plans require one to five unique, fully described items.");
209681
209703
  return {
209682
209704
  success: true,
209683
209705
  contentItems: [{
@@ -210841,6 +210863,7 @@ const makeCodexAdapter = require_Schema$1.fn("makeCodexAdapter")(function* (opti
210841
210863
  ...browserToolEnvironmentId !== void 0 ? { environmentId: browserToolEnvironmentId } : {}
210842
210864
  };
210843
210865
  const managerInput = {
210866
+ ...input.accountTransition ? { accountTransition: input.accountTransition } : {},
210844
210867
  threadId: input.threadId,
210845
210868
  provider: "codex",
210846
210869
  ...input.cwd !== void 0 ? { cwd: input.cwd } : {},
@@ -211171,7 +211194,7 @@ function withoutInheritedAnthropicCredentials(env, options) {
211171
211194
  //#endregion
211172
211195
  //#region src/provider/makeManagedServerProvider.ts
211173
211196
  const makeManagedServerProvider = require_Schema$1.fn("makeManagedServerProvider")(function* (input) {
211174
- const refreshSemaphore = yield* require_Path.make$4(1);
211197
+ const refreshSemaphore = yield* require_Path.make$5(1);
211175
211198
  const changesPubSub = yield* require_Schema$1.acquireRelease(require_Path.unbounded$1(), require_Path.shutdown$1);
211176
211199
  const initialSettings = yield* input.getSettings;
211177
211200
  const initialSnapshot = input.initialSnapshot(initialSettings);
@@ -211497,25 +211520,25 @@ const AUTH_METHOD_CONTAINER_KEYS = [
211497
211520
  /** Lift an unknown value into `Option<string>` if it is a non-empty string. */
211498
211521
  const asNonEmptyString = (v) => typeof v === "string" && v.length > 0 ? require_Schema$1.some(v) : require_Schema$1.none();
211499
211522
  /** Lift an unknown value into `Option<Record>` if it is a plain object. */
211500
- const asRecord$8 = (v) => typeof v === "object" && v !== null && !globalThis.Array.isArray(v) ? require_Schema$1.some(v) : require_Schema$1.none();
211523
+ const asRecord$9 = (v) => typeof v === "object" && v !== null && !globalThis.Array.isArray(v) ? require_Schema$1.some(v) : require_Schema$1.none();
211501
211524
  /**
211502
211525
  * Walk an unknown parsed JSON value looking for a subscription/plan
211503
211526
  * identifier, returning the first match as an `Option`.
211504
211527
  */
211505
211528
  function findSubscriptionType(value) {
211506
211529
  if (globalThis.Array.isArray(value)) return require_Schema$1.firstSomeOf(value.map(findSubscriptionType));
211507
- return asRecord$8(value).pipe(require_Schema$1.flatMap$2((record) => {
211530
+ return asRecord$9(value).pipe(require_Schema$1.flatMap$2((record) => {
211508
211531
  const direct = require_Schema$1.firstSomeOf(SUBSCRIPTION_TYPE_KEYS.map((key) => asNonEmptyString(record[key])));
211509
211532
  if (require_Schema$1.isSome(direct)) return direct;
211510
- return require_Schema$1.firstSomeOf(SUBSCRIPTION_CONTAINER_KEYS.map((key) => asRecord$8(record[key]).pipe(require_Schema$1.flatMap$2(findSubscriptionType))));
211533
+ return require_Schema$1.firstSomeOf(SUBSCRIPTION_CONTAINER_KEYS.map((key) => asRecord$9(record[key]).pipe(require_Schema$1.flatMap$2(findSubscriptionType))));
211511
211534
  }));
211512
211535
  }
211513
211536
  function findAuthMethod(value) {
211514
211537
  if (globalThis.Array.isArray(value)) return require_Schema$1.firstSomeOf(value.map(findAuthMethod));
211515
- return asRecord$8(value).pipe(require_Schema$1.flatMap$2((record) => {
211538
+ return asRecord$9(value).pipe(require_Schema$1.flatMap$2((record) => {
211516
211539
  const direct = require_Schema$1.firstSomeOf(AUTH_METHOD_KEYS.map((key) => asNonEmptyString(record[key])));
211517
211540
  if (require_Schema$1.isSome(direct)) return direct;
211518
- return require_Schema$1.firstSomeOf(AUTH_METHOD_CONTAINER_KEYS.map((key) => asRecord$8(record[key]).pipe(require_Schema$1.flatMap$2(findAuthMethod))));
211541
+ return require_Schema$1.firstSomeOf(AUTH_METHOD_CONTAINER_KEYS.map((key) => asRecord$9(record[key]).pipe(require_Schema$1.flatMap$2(findAuthMethod))));
211519
211542
  }));
211520
211543
  }
211521
211544
  /**
@@ -212761,7 +212784,7 @@ function userInputQuestionsFromToolInput(toolInput) {
212761
212784
  return (Array.isArray(toolInput.questions) ? toolInput.questions : []).map((question, idx) => userInputQuestionFromUnknown(question, idx));
212762
212785
  }
212763
212786
  function userInputQuestionFromUnknown(question, idx) {
212764
- const value = asRecord$7(question) ?? {};
212787
+ const value = asRecord$8(question) ?? {};
212765
212788
  return {
212766
212789
  id: typeof value.header === "string" ? value.header : `q-${idx}`,
212767
212790
  header: typeof value.header === "string" ? value.header : `Question ${idx + 1}`,
@@ -212771,13 +212794,13 @@ function userInputQuestionFromUnknown(question, idx) {
212771
212794
  };
212772
212795
  }
212773
212796
  function userInputOptionFromUnknown(option) {
212774
- const value = asRecord$7(option) ?? {};
212797
+ const value = asRecord$8(option) ?? {};
212775
212798
  return {
212776
212799
  label: typeof value.label === "string" ? value.label : "",
212777
212800
  description: typeof value.description === "string" ? value.description : ""
212778
212801
  };
212779
212802
  }
212780
- function asRecord$7(value) {
212803
+ function asRecord$8(value) {
212781
212804
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
212782
212805
  }
212783
212806
  function permissionResultFromDecision(decision, toolInput, suggestions) {
@@ -213682,7 +213705,7 @@ const makeClaudeAdapter = require_Schema$1.fn("makeClaudeAdapter")(function* (op
213682
213705
  const updateResumeCursor = require_Schema$1.fn("updateResumeCursor")(function* (context) {
213683
213706
  const threadId = context.session.threadId;
213684
213707
  if (!threadId) return;
213685
- const providerDeliveryBinding = readProviderDeliveryBinding(asRecord$7(context.session.resumeCursor)?.providerDeliveryBinding);
213708
+ const providerDeliveryBinding = readProviderDeliveryBinding(asRecord$8(context.session.resumeCursor)?.providerDeliveryBinding);
213686
213709
  const resumeCursor = {
213687
213710
  threadId,
213688
213711
  ...context.resumeSessionId ? { resume: context.resumeSessionId } : {},
@@ -218760,7 +218783,7 @@ function makeAcpContentDeltaEvent(input) {
218760
218783
  }
218761
218784
  //#endregion
218762
218785
  //#region ../../packages/shared/src/toolActivity.ts
218763
- function asRecord$6(value) {
218786
+ function asRecord$7(value) {
218764
218787
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
218765
218788
  }
218766
218789
  function asTrimmedString(value) {
@@ -218786,10 +218809,10 @@ function extractCommandFromTitle$1(title) {
218786
218809
  return /`([^`]+)`/u.exec(title)?.[1]?.trim() || void 0;
218787
218810
  }
218788
218811
  function extractToolCommand(data, title) {
218789
- const item = asRecord$6(data?.item);
218790
- const itemInput = asRecord$6(item?.input);
218791
- const itemResult = asRecord$6(item?.result);
218792
- const rawInput = asRecord$6(data?.rawInput);
218812
+ const item = asRecord$7(data?.item);
218813
+ const itemInput = asRecord$7(item?.input);
218814
+ const itemResult = asRecord$7(item?.result);
218815
+ const rawInput = asRecord$7(data?.rawInput);
218793
218816
  const direct = [
218794
218817
  normalizeCommandValue$1(item?.command),
218795
218818
  normalizeCommandValue$1(itemInput?.command),
@@ -218817,7 +218840,7 @@ function collectPaths(value, paths, seen, depth) {
218817
218840
  }
218818
218841
  return;
218819
218842
  }
218820
- const record = asRecord$6(value);
218843
+ const record = asRecord$7(value);
218821
218844
  if (!record) return;
218822
218845
  for (const key of [
218823
218846
  "path",
@@ -218876,7 +218899,7 @@ function deriveToolActivityPresentation(input) {
218876
218899
  const title = asTrimmedString(input.title);
218877
218900
  const detail = stripTrailingExitCode(asTrimmedString(input.detail));
218878
218901
  const fallbackSummary = asTrimmedString(input.fallbackSummary) ?? "Tool";
218879
- const data = asRecord$6(input.data);
218902
+ const data = asRecord$7(input.data);
218880
218903
  const command = extractToolCommand(data, title);
218881
218904
  const primaryPath = extractPrimaryPath(data);
218882
218905
  const action = classifyToolAction({
@@ -218900,7 +218923,7 @@ function deriveToolActivityPresentation(input) {
218900
218923
  ...primaryPath ? { detail: primaryPath } : {}
218901
218924
  };
218902
218925
  if (action === "search") {
218903
- const query = asTrimmedString(asRecord$6(data?.rawInput)?.query) ?? asTrimmedString(asRecord$6(data?.rawInput)?.pattern) ?? asTrimmedString(asRecord$6(data?.rawInput)?.searchTerm);
218926
+ const query = asTrimmedString(asRecord$7(data?.rawInput)?.query) ?? asTrimmedString(asRecord$7(data?.rawInput)?.pattern) ?? asTrimmedString(asRecord$7(data?.rawInput)?.searchTerm);
218904
218927
  return {
218905
218928
  summary: "Searched files",
218906
218929
  ...query ? { detail: query } : {}
@@ -220911,7 +220934,7 @@ function makeCursorAdapter(cursorSettings, options) {
220911
220934
  const getThreadSemaphore = (threadId) => modifyEffect(threadLocksRef, (current) => {
220912
220935
  const existing = require_Schema$1.fromNullishOr(current.get(threadId));
220913
220936
  return require_Schema$1.match$2(existing, {
220914
- onNone: () => require_Path.make$4(1).pipe(require_Schema$1.map((semaphore) => {
220937
+ onNone: () => require_Path.make$5(1).pipe(require_Schema$1.map((semaphore) => {
220915
220938
  const next = new Map(current);
220916
220939
  next.set(threadId, semaphore);
220917
220940
  return [semaphore, next];
@@ -229321,6 +229344,8 @@ const makeProviderService = require_Schema$1.fn("makeProviderService")(function*
229321
229344
  const canonicalEventLogger = options?.canonicalEventLogger ?? (options?.canonicalEventLogPath !== void 0 ? yield* makeEventNdjsonLogger(options.canonicalEventLogPath, { stream: "canonical" }) : void 0);
229322
229345
  const registry = yield* ProviderAdapterRegistry;
229323
229346
  const directory = yield* ProviderSessionDirectory;
229347
+ const sessionLocks = yield* require_Path.make$3({ lookup: (_threadId) => require_Path.make$5(1) });
229348
+ const withSessionLock = (threadId, effect) => require_Path.get$1(sessionLocks, threadId).pipe(require_Schema$1.flatMap((lock) => lock.withPermit(effect)), require_Schema$1.scoped);
229324
229349
  const runtimeEventPubSub = yield* require_Path.unbounded$1();
229325
229350
  const assertProviderExecutable = options?.assertProviderExecutable ?? (() => require_Schema$1.succeed(null));
229326
229351
  const assertCurrentProviderDelivery = require_Schema$1.fn("assertCurrentProviderDelivery")(function* (input) {
@@ -229495,18 +229520,19 @@ const makeProviderService = require_Schema$1.fn("makeProviderService")(function*
229495
229520
  "provider.runtime_mode": input.runtimeMode
229496
229521
  });
229497
229522
  const persistedBinding = require_Schema$1.getOrUndefined$1(yield* directory.getBinding(threadId));
229498
- yield* assertProviderAccountBoundary({
229523
+ const adapter = yield* registry.getByProvider(effectiveProvider);
229524
+ const priorAccountId = readPersistedProviderAccountId(persistedBinding?.runtimePayload);
229525
+ const requestedAccountId = readProviderAccountIdFromModelSelection(input.modelSelection);
229526
+ if (effectiveProvider !== "codex" || persistedBinding?.provider !== effectiveProvider || (yield* adapter.hasSession(threadId))) yield* assertProviderAccountBoundary({
229499
229527
  operation: "ProviderService.startSession",
229500
229528
  threadId,
229501
- persistedAccountId: readPersistedProviderAccountId(persistedBinding?.runtimePayload),
229502
- requestedAccountId: readProviderAccountIdFromModelSelection(input.modelSelection)
229529
+ persistedAccountId: priorAccountId,
229530
+ requestedAccountId
229503
229531
  });
229504
- const effectiveResumeCursor = input.resumeCursor ?? (persistedBinding?.provider === effectiveProvider ? persistedBinding.resumeCursor : void 0);
229505
- const adapter = yield* registry.getByProvider(effectiveProvider);
229506
229532
  const boundResumeCursor = yield* bindProviderDeliveryToResumeCursor({
229507
229533
  operation: "ProviderService.startSession",
229508
229534
  provider: effectiveProvider,
229509
- resumeCursor: effectiveResumeCursor,
229535
+ resumeCursor: input.resumeCursor ?? (persistedBinding?.provider === effectiveProvider ? persistedBinding.resumeCursor : void 0),
229510
229536
  currentBinding: yield* assertProviderExecutable({
229511
229537
  threadId,
229512
229538
  provider: effectiveProvider,
@@ -229515,6 +229541,7 @@ const makeProviderService = require_Schema$1.fn("makeProviderService")(function*
229515
229541
  });
229516
229542
  const session = yield* adapter.startSession({
229517
229543
  ...input,
229544
+ accountTransition: explicitProviderAccountTransition(priorAccountId, requestedAccountId),
229518
229545
  ...boundResumeCursor !== void 0 ? { resumeCursor: boundResumeCursor } : {}
229519
229546
  });
229520
229547
  if (session.provider !== adapter.provider) return yield* toValidationError("ProviderService.startSession", `Adapter/provider mismatch: requested '${adapter.provider}', received '${session.provider}'.`);
@@ -229816,15 +229843,15 @@ const makeProviderService = require_Schema$1.fn("makeProviderService")(function*
229816
229843
  });
229817
229844
  yield* require_Schema$1.addFinalizer(() => require_Schema$1.catch_(runStopAll(), (cause) => require_Schema$1.logWarning("failed to stop provider service", { cause })));
229818
229845
  return {
229819
- startSession,
229820
- sendTurn,
229821
- interruptTurn,
229822
- respondToRequest,
229823
- respondToUserInput,
229824
- stopSession,
229846
+ startSession: (threadId, input) => withSessionLock(threadId, startSession(threadId, input)),
229847
+ sendTurn: (input) => withSessionLock(input?.threadId, sendTurn(input)),
229848
+ interruptTurn: (input) => withSessionLock(input?.threadId, interruptTurn(input)),
229849
+ respondToRequest: (input) => withSessionLock(input?.threadId, respondToRequest(input)),
229850
+ respondToUserInput: (input) => withSessionLock(input?.threadId, respondToUserInput(input)),
229851
+ stopSession: (input) => withSessionLock(input?.threadId, stopSession(input)),
229825
229852
  listSessions,
229826
229853
  getCapabilities,
229827
- rollbackConversation,
229854
+ rollbackConversation: (input) => withSessionLock(input?.threadId, rollbackConversation(input)),
229828
229855
  get streamEvents() {
229829
229856
  return require_Path.fromPubSub(runtimeEventPubSub);
229830
229857
  }
@@ -231071,7 +231098,7 @@ const createTrace2Monitor = require_Schema$1.fn("createTrace2Monitor")(function*
231071
231098
  });
231072
231099
  }
231073
231100
  });
231074
- const readTraceDelta = (yield* require_Path.make$4(1)).withPermit(fs.readFileString(traceFilePath).pipe(require_Schema$1.flatMap((contents) => require_Schema$1.uninterruptible(require_HttpServer.modify(traceTailState, ({ processedChars, remainder }) => {
231101
+ const readTraceDelta = (yield* require_Path.make$5(1)).withPermit(fs.readFileString(traceFilePath).pipe(require_Schema$1.flatMap((contents) => require_Schema$1.uninterruptible(require_HttpServer.modify(traceTailState, ({ processedChars, remainder }) => {
231075
231102
  if (contents.length <= processedChars) return [[], {
231076
231103
  processedChars,
231077
231104
  remainder
@@ -234690,7 +234717,7 @@ const makeTerminalManagerWithOptions = require_Schema$1.fn("makeTerminalManagerW
234690
234717
  const getThreadSemaphore = (threadId) => modifyEffect(threadLocksRef, (current) => {
234691
234718
  const existing = require_Schema$1.fromNullishOr(current.get(threadId));
234692
234719
  return require_Schema$1.match$2(existing, {
234693
- onNone: () => require_Path.make$4(1).pipe(require_Schema$1.map((semaphore) => {
234720
+ onNone: () => require_Path.make$5(1).pipe(require_Schema$1.map((semaphore) => {
234694
234721
  const next = new Map(current);
234695
234722
  next.set(threadId, semaphore);
234696
234723
  return [semaphore, next];
@@ -285756,7 +285783,7 @@ function makeApprovedWorkerPlanEventState() {
285756
285783
  function promptKey(masterThreadId, promptId) {
285757
285784
  return `${masterThreadId}\n${promptId}`;
285758
285785
  }
285759
- function asRecord$5(value) {
285786
+ function asRecord$6(value) {
285760
285787
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
285761
285788
  }
285762
285789
  function exactMaterializedTaskIds(value, expectedCount) {
@@ -285766,7 +285793,7 @@ function exactMaterializedTaskIds(value, expectedCount) {
285766
285793
  }
285767
285794
  function readyBatchFromActivity(state, event) {
285768
285795
  if (event.payload.activity.kind !== "plan.task-creation.batch-succeeded") return null;
285769
- const payload = asRecord$5(event.payload.activity.payload);
285796
+ const payload = asRecord$6(event.payload.activity.payload);
285770
285797
  const promptId = payload?.["promptId"];
285771
285798
  if (typeof promptId !== "string") return null;
285772
285799
  const key = promptKey(event.payload.threadId, promptId);
@@ -285848,7 +285875,7 @@ const make$10 = require_Schema$1.gen(function* () {
285848
285875
  const runtimeContext = yield* require_Schema$1.context();
285849
285876
  const runPromise = require_Schema$1.runPromiseWith(runtimeContext);
285850
285877
  const eventState = makeApprovedWorkerPlanEventState();
285851
- const reconcileSemaphore = yield* require_Path.make$4(1);
285878
+ const reconcileSemaphore = yield* require_Path.make$5(1);
285852
285879
  const dispatch = (command) => runPromise(orchestration.dispatch(command).pipe(require_Schema$1.asVoid));
285853
285880
  const readMasterContext = async (prompt) => {
285854
285881
  const thread = require_Schema$1.getOrNull(await runPromise(readDurableWorkerDetail(projectionSnapshotQuery, ThreadId.make(prompt.masterThreadId))));
@@ -286966,7 +286993,7 @@ function runtimeGrantNeedsRefresh(token, identity, nowSeconds = Math.floor(Date.
286966
286993
  return claims.expiresAtSeconds - nowSeconds <= RUNTIME_GRANT_REFRESH_SKEW_SECONDS;
286967
286994
  }
286968
286995
  /** Narrow an unknown to a plain object, or null. */
286969
- function asRecord$4(value) {
286996
+ function asRecord$5(value) {
286970
286997
  return value !== null && typeof value === "object" ? value : null;
286971
286998
  }
286972
286999
  /** The raw (untrimmed) string when it is present and not blank, else null. */
@@ -286978,7 +287005,7 @@ function asTimestamp(value) {
286978
287005
  return typeof value === "string" && Number.isFinite(Date.parse(value)) ? value : null;
286979
287006
  }
286980
287007
  function parseRuntimeGrantRefreshResponse(runtimeId, value) {
286981
- const data = asRecord$4(asRecord$4(value)?.data);
287008
+ const data = asRecord$5(asRecord$5(value)?.data);
286982
287009
  if (!data || data.runtimeId !== runtimeId) return null;
286983
287010
  const grantToken = asNonBlankString(data.grantToken);
286984
287011
  const expiresAt = asTimestamp(data.expiresAt);
@@ -287039,7 +287066,6 @@ async function refreshRuntimeProvisioningGrant(input) {
287039
287066
  async function maybeRefreshRuntimeProvisioningGrant(input) {
287040
287067
  const current = require_runtimeControlAuthority.runtimeGrantToken();
287041
287068
  if (!current) return "skipped";
287042
- if (!runtimeGrantNeedsRefresh(current, input)) return "skipped";
287043
287069
  const exactIdentity = exactRuntimeControlIdentity(input);
287044
287070
  const currentClaims = currentGrantClaimsForRefresh({
287045
287071
  currentGrant: current,
@@ -287048,6 +287074,11 @@ async function maybeRefreshRuntimeProvisioningGrant(input) {
287048
287074
  });
287049
287075
  if (!currentClaims) throw invalidRefreshResponse("Current runtime provisioning grant is unverifiable.");
287050
287076
  const currentAuthorityClass = currentGrantAuthorityClass(currentClaims, exactIdentity);
287077
+ const controlAuthorityMissing = currentAuthorityClass === "exact" && exactIdentity !== null && require_runtimeControlAuthority.readRuntimeControlAuthority({
287078
+ runtimeId: input.runtimeId,
287079
+ ...exactIdentity
287080
+ }) === null;
287081
+ if (!runtimeGrantNeedsRefresh(current, input) && !controlAuthorityMissing) return "skipped";
287051
287082
  const refreshed = await refreshRuntimeProvisioningGrant({
287052
287083
  runtimeId: input.runtimeId,
287053
287084
  currentGrant: current,
@@ -287244,7 +287275,7 @@ const makeRuntimeDrainReporter = require_Schema$1.gen(function* () {
287244
287275
  const providerService = yield* ProviderService;
287245
287276
  const serverConfig = yield* ServerConfig;
287246
287277
  const spriteTaskHoldReactor = yield* SpriteTaskHoldReactor;
287247
- const reportSemaphore = yield* require_Path.make$4(1);
287278
+ const reportSemaphore = yield* require_Path.make$5(1);
287248
287279
  let heartbeatSilent = false;
287249
287280
  const postHeartbeat = (config, snapshot) => require_Schema$1.promise(async () => {
287250
287281
  const forgeGitCommit = await resolveForgeGitCommit();
@@ -294041,7 +294072,7 @@ function resolveBuildCommitFromEnv(env) {
294041
294072
  * environment descriptor down instead of reporting an honest "unknown".
294042
294073
  */
294043
294074
  function readBakedBuildCommit() {
294044
- return "75c8e9532c9e35e71d4da1d8d45474fa2855ff1d";
294075
+ return "7f0d765bc59cb837f8aa8025b9b2f855df3fd36d";
294045
294076
  }
294046
294077
  async function resolveServerBuildCommit(input) {
294047
294078
  if (isFullCommitSha(input.baked)) return input.baked;
@@ -303144,7 +303175,7 @@ const LocalAutomationSchedulerLive = require_Schema$1.effectDiscard(require_Sche
303144
303175
  }));
303145
303176
  //#endregion
303146
303177
  //#region src/command/providerUsageEnvironment.ts
303147
- function asRecord$3(value) {
303178
+ function asRecord$4(value) {
303148
303179
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
303149
303180
  }
303150
303181
  function positiveInteger(value) {
@@ -303164,7 +303195,7 @@ function readRuntimeId(row) {
303164
303195
  return typeof runtimeId === "string" && runtimeId.trim() !== "" ? runtimeId : null;
303165
303196
  }
303166
303197
  function readCandidate(runtime, ownerUserId) {
303167
- const row = asRecord$3(runtime);
303198
+ const row = asRecord$4(runtime);
303168
303199
  if (row === null || !isOwnedRuntime(row, ownerUserId) || row["desiredState"] !== "running") return null;
303169
303200
  const organizationId = positiveInteger(row["organizationId"]);
303170
303201
  const environmentId = readEnvironmentId(row["environmentId"]);
@@ -303199,15 +303230,17 @@ function deduplicateCandidates(candidates) {
303199
303230
  * organization from browser input.
303200
303231
  */
303201
303232
  function selectProviderUsageEnvironment(rawCatalog, ownerUserId) {
303202
- const runtimes = asRecord$3(asRecord$3(rawCatalog)?.["data"])?.["runtimes"];
303233
+ const runtimes = asRecord$4(asRecord$4(rawCatalog)?.["data"])?.["runtimes"];
303203
303234
  if (!Array.isArray(runtimes)) return { kind: "unavailable" };
303204
303235
  const candidates = deduplicateCandidates(runtimes.map((runtime) => readCandidate(runtime, ownerUserId)).filter((candidate) => candidate !== null));
303205
303236
  const bestRank = Math.min(...candidates.map((candidate) => statusRank(candidate.status)));
303206
303237
  const bestCandidates = candidates.filter((candidate) => statusRank(candidate.status) === bestRank);
303207
303238
  if (bestCandidates.length !== 1) return { kind: "unavailable" };
303239
+ const selected = bestCandidates[0];
303208
303240
  return {
303209
303241
  kind: "ready",
303210
- organizationId: bestCandidates[0].organizationId
303242
+ organizationId: selected.organizationId,
303243
+ runtimeId: selected.runtimeId
303211
303244
  };
303212
303245
  }
303213
303246
  //#endregion
@@ -303228,13 +303261,22 @@ function selectProviderUsageEnvironment(rawCatalog, ownerUserId) {
303228
303261
  const FAILURE_TEXT = {
303229
303262
  CLAUDE_USAGE_ENVIRONMENT_UNAVAILABLE: "Refresh needs your Environment running.",
303230
303263
  CLAUDE_USAGE_CREDENTIAL_NOT_READY: "The Claude credential is not applied to your Environment yet.",
303264
+ CLAUDE_USAGE_CREDENTIAL_APPLY_FAILED: "Your Environment rejected the delivered Claude credential.",
303265
+ CLAUDE_USAGE_CREDENTIAL_REFRESHING: "The delivered Claude credential expired. CMMD is sending a replacement.",
303231
303266
  CLAUDE_USAGE_REFRESH_IN_PROGRESS: "A refresh for this account is already running.",
303232
303267
  CLAUDE_USAGE_PROBE_FAILED: "Your Environment could not read Claude usage.",
303233
303268
  CLAUDE_USAGE_RECONNECT_REQUIRED: "Reconnect this Claude account to refresh usage.",
303234
303269
  CLAUDE_USAGE_ACCOUNT_NOT_FOUND: "This Claude account is no longer connected.",
303235
303270
  CLAUDE_USAGE_REFRESH_UNAVAILABLE: "Claude usage refresh is unavailable."
303236
303271
  };
303237
- /** Verbatim from CMMD `personal-claude-usage.ts` and `provider-usage-service.ts`. */
303272
+ /**
303273
+ * Verbatim from CMMD `personal-claude-usage.ts` and `provider-usage-service.ts`.
303274
+ *
303275
+ * Three reasons land on `CLAUDE_USAGE_CREDENTIAL_NOT_READY` because the refresh
303276
+ * response cannot tell them apart. `claudeUsageCredentialReadiness.ts` splits
303277
+ * them afterwards by reading the runtime's readiness, which is the only place
303278
+ * that knows whether a delivery is on its way or has already failed.
303279
+ */
303238
303280
  const CODE_BY_UPSTREAM_REASON = {
303239
303281
  runtime_not_active: "CLAUDE_USAGE_ENVIRONMENT_UNAVAILABLE",
303240
303282
  claude_native_delivery_disabled: "CLAUDE_USAGE_ENVIRONMENT_UNAVAILABLE",
@@ -303247,7 +303289,12 @@ const CODE_BY_UPSTREAM_REASON = {
303247
303289
  usage_receipt_invalid: "CLAUDE_USAGE_PROBE_FAILED",
303248
303290
  usage_output_invalid: "CLAUDE_USAGE_PROBE_FAILED"
303249
303291
  };
303250
- function failure(code, status) {
303292
+ /**
303293
+ * The one place a failure body is built, so every sentence a browser reads is
303294
+ * written in `FAILURE_TEXT` above. `claudeUsageCredentialReadiness.ts` calls it
303295
+ * to reach the two codes no upstream reason maps to.
303296
+ */
303297
+ function describeClaudeUsageRefreshFailureCode(code, status) {
303251
303298
  return {
303252
303299
  status,
303253
303300
  body: {
@@ -303256,6 +303303,9 @@ function failure(code, status) {
303256
303303
  }
303257
303304
  };
303258
303305
  }
303306
+ function failure(code, status) {
303307
+ return describeClaudeUsageRefreshFailureCode(code, status);
303308
+ }
303259
303309
  /**
303260
303310
  * CMMD sends the reason as `{ "error": "<reason>" }`. Anything else, including
303261
303311
  * a longer sentence that happens to start with an allowlisted word, is treated
@@ -303276,6 +303326,77 @@ function describeClaudeUsageRefreshFailure(error) {
303276
303326
  return failure("CLAUDE_USAGE_REFRESH_UNAVAILABLE", error.status === 503 ? 503 : 502);
303277
303327
  }
303278
303328
  //#endregion
303329
+ //#region src/command/claudeUsageCredentialReadiness.ts
303330
+ /**
303331
+ * Which "credential not ready" a Claude usage refresh actually hit.
303332
+ *
303333
+ * CMMD answers a blocked refresh with one reason for three different worlds:
303334
+ * a delivery still travelling, a delivery CMMD cannot produce, and a delivery
303335
+ * the Environment already ran and rejected. `claudeUsageRefreshFailure.ts` has
303336
+ * to collapse all three into `CLAUDE_USAGE_CREDENTIAL_NOT_READY`, because the
303337
+ * refresh response carries nothing that separates them. The card then says
303338
+ * "not applied yet", which asks the user to wait even when waiting can never
303339
+ * work: on 2026-09-08 CMMD's reconciler failed native credential validation on
303340
+ * runtime 523cd771 forty-three times in seventy-two minutes, and the card said
303341
+ * "yet" through all of it.
303342
+ *
303343
+ * The runtime readiness read is the one source that separates the worlds, so
303344
+ * the handler makes that read only for the collapsed code and hands the answer
303345
+ * here. Every sentence is written in `claudeUsageRefreshFailure.ts`; nothing
303346
+ * from CMMD's `lastErrorCode` or `lastErrorMessage` is repeated to a browser.
303347
+ */
303348
+ const CMMD_READINESS_PATH_PREFIX = "/api/forge/context/providers/claude/runtime-readiness/";
303349
+ /** Typed as the gateway's absolute-path shape so the call site needs no cast. */
303350
+ function claudeUsageReadinessPath(runtimeId) {
303351
+ return `${CMMD_READINESS_PATH_PREFIX}${encodeURIComponent(runtimeId)}`;
303352
+ }
303353
+ /**
303354
+ * Whether a readiness read would tell the caller anything it does not know.
303355
+ *
303356
+ * Only the collapsed code is ambiguous. Every other failure already names its
303357
+ * own cause, so asking CMMD again would cost a round trip on the error path
303358
+ * and could only produce a less specific answer.
303359
+ */
303360
+ function claudeUsageFailureWantsReadiness(failure) {
303361
+ return failure.body.code === "CLAUDE_USAGE_CREDENTIAL_NOT_READY";
303362
+ }
303363
+ function asRecord$3(value) {
303364
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
303365
+ }
303366
+ function readString(value) {
303367
+ return typeof value === "string" && value !== "" ? value : null;
303368
+ }
303369
+ /**
303370
+ * Refines the collapsed credential failure using the runtime's readiness.
303371
+ *
303372
+ * The ranking is by what the user can act on, not by which field looks most
303373
+ * severe:
303374
+ *
303375
+ * 1. A reason of `credential_reconnect_required` or `credential_not_connected`
303376
+ * means CMMD holds no usable grant. That is upstream of delivery, so it wins
303377
+ * even when the delivery it caused also failed. No re-delivery helps; only a
303378
+ * reconnect does.
303379
+ * 2. `deliveryStatus: "failed"` means CMMD had a credential, sent it, and the
303380
+ * Environment rejected it. Waiting cannot fix that, which is exactly what
303381
+ * the collapsed sentence tells the user to do.
303382
+ * 3. `credential_expired_refreshing` means a replacement is already in flight,
303383
+ * so the honest instruction is to retry shortly.
303384
+ *
303385
+ * Anything else, including a readiness read that failed or answered a shape
303386
+ * this module does not recognise, keeps the collapsed failure. A refinement
303387
+ * that guessed would be worse than the vague sentence it replaced.
303388
+ */
303389
+ function refineClaudeUsageRefreshFailure(failure, rawReadiness) {
303390
+ if (!claudeUsageFailureWantsReadiness(failure)) return failure;
303391
+ const readiness = asRecord$3(asRecord$3(rawReadiness)?.["data"]);
303392
+ if (readiness === null) return failure;
303393
+ const reasonCode = claudeReadinessReasonCode(readString(readiness["reason"]));
303394
+ if (reasonCode === "CREDENTIAL_RECONNECT_REQUIRED") return describeClaudeUsageRefreshFailureCode("CLAUDE_USAGE_RECONNECT_REQUIRED", 409);
303395
+ if (readiness["deliveryStatus"] === "failed") return describeClaudeUsageRefreshFailureCode("CLAUDE_USAGE_CREDENTIAL_APPLY_FAILED", 503);
303396
+ if (reasonCode === "CREDENTIAL_EXPIRED_REFRESHING") return describeClaudeUsageRefreshFailureCode("CLAUDE_USAGE_CREDENTIAL_REFRESHING", 503);
303397
+ return failure;
303398
+ }
303399
+ //#endregion
303279
303400
  //#region src/command/wsToken.ts
303280
303401
  /**
303281
303402
  * Build the WS token response given an optional PAT and the configured CMMD
@@ -305141,6 +305262,25 @@ function buildClaudeUsageRefreshErrorResponse(error) {
305141
305262
  const failure = describeClaudeUsageRefreshFailure(error);
305142
305263
  return require_HttpServer.jsonUnsafe(failure.body, { status: failure.status });
305143
305264
  }
305265
+ /**
305266
+ * Answers a refresh CMMD refused, asking the selected runtime what state its
305267
+ * Claude credential is in when the refusal alone cannot say. Only the collapsed
305268
+ * credential code costs the extra read, and a readiness read that itself fails
305269
+ * leaves the original answer untouched.
305270
+ */
305271
+ function answerBlockedClaudeUsageRefresh(input) {
305272
+ return require_Schema$1.gen(function* () {
305273
+ const failure = describeClaudeUsageRefreshFailure(input.error);
305274
+ if (!claudeUsageFailureWantsReadiness(failure)) return require_HttpServer.jsonUnsafe(failure.body, { status: failure.status });
305275
+ const readinessOutcome = yield* runCmmdRestProxy(input.session, (jwt) => cmmdGateway.request({
305276
+ method: "GET",
305277
+ jwt,
305278
+ path: claudeUsageReadinessPath(input.runtimeId)
305279
+ }), { jwt: input.requestJwt });
305280
+ const refined = refineClaudeUsageRefreshFailure(failure, readinessOutcome.ok ? readinessOutcome.value : null);
305281
+ return require_HttpServer.jsonUnsafe(refined.body, { status: refined.status });
305282
+ });
305283
+ }
305144
305284
  function makeRefreshProviderUsageHandler(dependencies = {}) {
305145
305285
  return require_Schema$1.gen(function* () {
305146
305286
  const request = yield* require_HttpServer.HttpServerRequest;
@@ -305177,7 +305317,12 @@ function makeRefreshProviderUsageHandler(dependencies = {}) {
305177
305317
  body: { providerAccountId: input.providerAccountId },
305178
305318
  orgId: String(target.organizationId)
305179
305319
  }), { jwt: requestJwt });
305180
- if (!refreshOutcome.ok) return buildClaudeUsageRefreshErrorResponse(refreshOutcome.error);
305320
+ if (!refreshOutcome.ok) return yield* answerBlockedClaudeUsageRefresh({
305321
+ session,
305322
+ requestJwt,
305323
+ runtimeId: target.runtimeId,
305324
+ error: refreshOutcome.error
305325
+ });
305181
305326
  const snapshotOutcome = yield* runCmmdRestProxy(session, (jwt) => cmmdGateway.request({
305182
305327
  method: "GET",
305183
305328
  jwt,
@@ -305276,6 +305421,22 @@ registerProxyRoute({
305276
305421
  responseShape: "unwrapData",
305277
305422
  successStatus: 200
305278
305423
  });
305424
+ registerProxyRoute({
305425
+ forgePath: "/api/cmmd/forge-runtimes/:runtimeId/execution-intents",
305426
+ method: "POST",
305427
+ cmmdPath: "/api/forge/context/runtimes/:runtimeId/execution-intents",
305428
+ orgIdSource: "none",
305429
+ responseShape: "unwrapData",
305430
+ successStatus: 200
305431
+ });
305432
+ registerProxyRoute({
305433
+ forgePath: "/api/cmmd/forge-runtimes/:runtimeId/execution-intents/:intentId/dispatched",
305434
+ method: "POST",
305435
+ cmmdPath: "/api/forge/context/runtimes/:runtimeId/execution-intents/:intentId/dispatched",
305436
+ orgIdSource: "none",
305437
+ responseShape: "unwrapData",
305438
+ successStatus: 200
305439
+ });
305279
305440
  registerProxyRoute({
305280
305441
  forgePath: "/api/cmmd/devices/:deviceId/revoke",
305281
305442
  method: "POST",
@@ -311106,7 +311267,7 @@ const makePipelineRunCoordinator = require_Schema$1.gen(function* () {
311106
311267
  preparation: preparedHandoff.providerAuthorityPreparation
311107
311268
  });
311108
311269
  const acceptingHeartbeatRef = yield* require_HttpServer.make$3(true);
311109
- const heartbeatPublicationSemaphore = yield* require_Path.make$4(1);
311270
+ const heartbeatPublicationSemaphore = yield* require_Path.make$5(1);
311110
311271
  if ((yield* store.getByRunId(input.runId)) !== null) return yield* coordinatorError("registerHandoff", "PIPELINE_HANDOFF_ALREADY_BOUND", "The CMMD run already has a Forge task thread and must use the authority rebind contract.");
311111
311272
  const snapshot = preparedHandoff.snapshot;
311112
311273
  const readModel = yield* orchestration.getReadModel();
@@ -314992,7 +315153,7 @@ function makeProjectLeadSchedulerLive(options = {}) {
314992
315153
  return require_Schema$1.effect(ProjectLeadScheduler, require_Schema$1.gen(function* () {
314993
315154
  const client = yield* ProjectLeadControllerClient;
314994
315155
  const dispatcher = yield* ProjectLeadReservationDispatcher;
314995
- const semaphore = yield* require_Path.make$4(1);
315156
+ const semaphore = yield* require_Path.make$5(1);
314996
315157
  const leaseSeconds = options.leaseSeconds ?? DEFAULT_LEASE_SECONDS;
314997
315158
  const batchSize = options.batchSize ?? DEFAULT_BATCH_SIZE;
314998
315159
  const projectLimit = options.projectLimit ?? DEFAULT_PROJECT_LIMIT;
@@ -317011,13 +317172,13 @@ const gitUrlCloneRouteLayer = add$1("POST", "/api/cloud/git/clone-url", require_
317011
317172
  //#endregion
317012
317173
  //#region src/server.ts
317013
317174
  const PtyAdapterLive = require_Schema$1.unwrap(require_Schema$1.gen(function* () {
317014
- if (typeof Bun !== "undefined") return (yield* require_Schema$1.promise(() => Promise.resolve().then(() => require("./BunPTY-B4Ra6mph.cjs")))).layer;
317015
- else return (yield* require_Schema$1.promise(() => Promise.resolve().then(() => require("./NodePTY-wATyTf3M.cjs")))).layer;
317175
+ if (typeof Bun !== "undefined") return (yield* require_Schema$1.promise(() => Promise.resolve().then(() => require("./BunPTY-86ttlTi6.cjs")))).layer;
317176
+ else return (yield* require_Schema$1.promise(() => Promise.resolve().then(() => require("./NodePTY-Cps0jsDA.cjs")))).layer;
317016
317177
  }));
317017
317178
  const HttpServerLive = require_Schema$1.unwrap(require_Schema$1.gen(function* () {
317018
317179
  const config = yield* ServerConfig;
317019
- if (typeof Bun !== "undefined") return (yield* require_Schema$1.promise(() => Promise.resolve().then(() => require("./BunHttpServer-CjwNydcy.cjs")))).layer(bunHttpServerOptions(config));
317020
- const [NodeHttpServer, NodeHttp] = yield* require_Schema$1.all([require_Schema$1.promise(() => Promise.resolve().then(() => require("./NodeHttpServer-Cy1XvkSE.cjs"))), require_Schema$1.promise(() => import("node:http"))]);
317180
+ if (typeof Bun !== "undefined") return (yield* require_Schema$1.promise(() => Promise.resolve().then(() => require("./BunHttpServer-BhE7Szci.cjs")))).layer(bunHttpServerOptions(config));
317181
+ const [NodeHttpServer, NodeHttp] = yield* require_Schema$1.all([require_Schema$1.promise(() => Promise.resolve().then(() => require("./NodeHttpServer-BPjxt_DT.cjs"))), require_Schema$1.promise(() => import("node:http"))]);
317021
317182
  return NodeHttpServer.layer(NodeHttp.createServer, {
317022
317183
  host: config.host,
317023
317184
  port: config.port
@@ -317025,10 +317186,10 @@ const HttpServerLive = require_Schema$1.unwrap(require_Schema$1.gen(function* ()
317025
317186
  }));
317026
317187
  const PlatformServicesLive = require_Schema$1.unwrap(require_Schema$1.gen(function* () {
317027
317188
  if (typeof Bun !== "undefined") {
317028
- const { layer } = yield* require_Schema$1.promise(() => Promise.resolve().then(() => require("./BunServices-CUeOgVUt.cjs")));
317189
+ const { layer } = yield* require_Schema$1.promise(() => Promise.resolve().then(() => require("./BunServices-BwE9KexF.cjs")));
317029
317190
  return layer;
317030
317191
  } else {
317031
- const { layer } = yield* require_Schema$1.promise(() => Promise.resolve().then(() => require("./NodeServices-BqfcuvmN.cjs")));
317192
+ const { layer } = yield* require_Schema$1.promise(() => Promise.resolve().then(() => require("./NodeServices-Ddr-tYRu.cjs")));
317032
317193
  return layer;
317033
317194
  }
317034
317195
  }));