@cmmd-center/forge 0.10.6 → 0.10.7

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 (22) hide show
  1. package/dist/bin.cjs +1214 -761
  2. package/dist/bin.mjs +1214 -759
  3. package/dist/client/assets/{CanvasPanel-Dr4I7MnM.js → CanvasPanel-ECmvVI7T.js} +2 -2
  4. package/dist/client/assets/{CompositeItem-Cj6_oAlz.js → CompositeItem-8hzrVacr.js} +2 -2
  5. package/dist/client/assets/{DiffPanel-njtnlFro.js → DiffPanel-BqOO3dsl.js} +3 -3
  6. package/dist/client/assets/{DiffPanel.logic-BiWRNb4k.js → DiffPanel.logic-Bzm8oiCr.js} +2 -2
  7. package/dist/client/assets/DiffPanelShell-DVVw1mR3.js +2531 -0
  8. package/dist/client/assets/{DiffWorkerPoolProvider-DWrja16U.js → DiffWorkerPoolProvider-BsMgSHbg.js} +8 -8
  9. package/dist/client/assets/{PullRequestCodePanel-CAaq9dk8.js → PullRequestCodePanel-DNrNrubs.js} +3 -3
  10. package/dist/client/assets/{Virtualizer-BXpiamky.js → Virtualizer-RRV_x18w.js} +2 -2
  11. package/dist/client/assets/{canvasStateStore-DncdOQ4J.js → canvasStateStore-3EN8RaUf.js} +2 -2
  12. package/dist/client/assets/{cmmdAuthRedirect-DWiMDVzN.js → cmmdAuthRedirect-DwPtzhq9.js} +2 -2
  13. package/dist/client/assets/index-D22UpSjv.css +1 -0
  14. package/dist/client/assets/{index-DBIIL0ML.js → index-DCVtRkq1.js} +59 -59
  15. package/dist/client/assets/{src-CtyKlVph.js → src-DZBONdiY.js} +2 -2
  16. package/dist/client/assets/{toggle-pTm2fPLg.js → toggle-mQ7UG7Dd.js} +2 -2
  17. package/dist/client/assets/{useTriggerFocusGuards-B4Ejoaox.js → useTriggerFocusGuards-BUEnX8xa.js} +2 -2
  18. package/dist/client/index.html +11 -11
  19. package/dist/forge-build.json +1 -1
  20. package/package.json +1 -1
  21. package/dist/client/assets/DiffPanelShell-AKUK0L-g.js +0 -2531
  22. package/dist/client/assets/index-T36rURmx.css +0 -1
package/dist/bin.cjs CHANGED
@@ -24457,6 +24457,7 @@ const UsageBucket = require_Schema$1.Struct({
24457
24457
  costSource: UsageCostSource,
24458
24458
  records: NonNegativeInt,
24459
24459
  unpricedRecords: NonNegativeInt,
24460
+ unreportedRecords: require_Schema$1.optional(NonNegativeInt),
24460
24461
  sessions: NonNegativeInt,
24461
24462
  runtimeId: require_Schema$1.optional(TrimmedNonEmptyString),
24462
24463
  origin: require_Schema$1.optional(UsageBucketOrigin),
@@ -65378,7 +65379,7 @@ function normalizeNumberish(value) {
65378
65379
  }
65379
65380
  //#endregion
65380
65381
  //#region package.json
65381
- var version$1 = "0.10.6";
65382
+ var version$1 = "0.10.7";
65382
65383
  //#endregion
65383
65384
  //#region src/sentry.ts
65384
65385
  const SERVER_APP_NAME = "forge-server";
@@ -70304,6 +70305,14 @@ function invalidateCachedCmmdWorkIntakeForIdentity(identityKey) {
70304
70305
  *
70305
70306
  * Bespoke routes (MCP/PAT transport, hybrid fallback, multipart) stay in
70306
70307
  * http.ts and are NOT migrated here.
70308
+ *
70309
+ * A second, narrower entry point — `registerProxyHandler` / `ProxyHandlerRoute`
70310
+ * — covers routes whose middle (request parsing, the actual gateway call,
70311
+ * success shaping) cannot be expressed by the five `ProxyRoute` fields above,
70312
+ * while still sharing the same prologue: session auth, the CMMD-connection
70313
+ * gate, and the same `buildProxyErrorResponse` error mapping plus
70314
+ * `clearUnrecoverableCmmdAuthForSession` on an auth failure. See the type doc
70315
+ * below for the exact contract.
70307
70316
  */
70308
70317
  /** Substitutes ":paramName" tokens in a path template from a params record. */
70309
70318
  function substitutePath(template, params) {
@@ -70353,6 +70362,29 @@ function buildProxyErrorResponse(error) {
70353
70362
  }
70354
70363
  return require_HttpServer.jsonUnsafe({ error: "CMMD REST request failed." }, { status: 502 });
70355
70364
  }
70365
+ /**
70366
+ * Clears every unrecoverable CMMD credential tied to this session, logging a
70367
+ * warning rather than failing the request if the clear itself errors — a
70368
+ * session that already has no usable credential must still get its 401,
70369
+ * not a 500 from a failed best-effort cleanup.
70370
+ */
70371
+ function clearCmmdAuthAfterFailure(sessionId) {
70372
+ return clearUnrecoverableCmmdAuthForSession(sessionId).pipe(require_Schema$1.catch_((error) => require_Schema$1.logWarning("Failed to clear unrecoverable CMMD auth after CMMD auth failure.", {
70373
+ cause: error,
70374
+ sessionId
70375
+ })));
70376
+ }
70377
+ /**
70378
+ * The single "no usable CMMD credential" response: clears whatever
70379
+ * unrecoverable auth state this session is holding, then returns the
70380
+ * canonical `CMMD_AUTH_REQUIRED` body. Every prologue path that decides the
70381
+ * session has no way to reach CMMD — a missing PAT, a JWT that fails to
70382
+ * resolve, a bespoke gate elsewhere in http.ts — emits this same response so
70383
+ * the Shell only ever has one `CMMD_AUTH_REQUIRED` body to branch on.
70384
+ */
70385
+ function respondCmmdConnectionRequired(sessionId) {
70386
+ return clearCmmdAuthAfterFailure(sessionId).pipe(require_Schema$1.as(buildProxyErrorResponse(new CmmdProxyAuthenticationRequiredError("CMMD connection required. Reconnect CMMD to continue."))));
70387
+ }
70356
70388
  async function dispatchToProxy(method, jwt, cmmdPath, rawBody, orgId, searchParams) {
70357
70389
  return cmmdGateway.request({
70358
70390
  method,
@@ -70383,12 +70415,27 @@ function buildProxySearchParams(input) {
70383
70415
  return Object.keys(result).length > 0 ? result : void 0;
70384
70416
  }
70385
70417
  const _registeredRoutes = [];
70386
- /**
70387
- * Generates an Effect HttpRouter layer for the given route.
70388
- * The returned layer registers one handler at forgePath.
70389
- */
70390
- function registerProxyRoute(route) {
70391
- _registeredRoutes.push(route);
70418
+ const _registeredLayers = [];
70419
+ /**
70420
+ * Layers produced by every registerProxyRoute call so far, in registration
70421
+ * order. Callers that want only the routes registered by their own module
70422
+ * should snapshot `.length` before their own registerProxyRoute calls run and
70423
+ * slice from that index — see command/http.ts's `cmmdProxyRouteLayers`.
70424
+ *
70425
+ * Typed via `ReturnType<typeof buildProxyRouteLayer>` (not `HttpRouter.add`
70426
+ * directly, and not `registerProxyRoute` itself — that would be circular
70427
+ * since registerProxyRoute pushes onto this same array): `buildProxyRouteLayer`
70428
+ * takes a concrete, non-generic `ProxyRoute` argument and never references
70429
+ * this array, so its return type is fully resolved independently. Referencing
70430
+ * the generic `HttpRouter.add` on its own instead collapses its unresolved E/R
70431
+ * type parameters to `unknown`, which then leaks into makeRoutesLayer's
70432
+ * requirements channel everywhere this array is spread.
70433
+ */
70434
+ function registeredProxyRouteLayers() {
70435
+ return Object.freeze([..._registeredLayers]);
70436
+ }
70437
+ /** Builds the Effect HttpRouter layer for one route, with no registry side effects. */
70438
+ function buildProxyRouteLayer(route) {
70392
70439
  const handler = require_Schema$1.gen(function* () {
70393
70440
  const req = yield* require_HttpServer.HttpServerRequest;
70394
70441
  const session = yield* (yield* ServerAuth).authenticateHttpRequest(req);
@@ -70411,23 +70458,14 @@ function registerProxyRoute(route) {
70411
70458
  forceRefresh
70412
70459
  });
70413
70460
  const jwt = yield* resolveJwt();
70414
- if (!jwt) {
70415
- yield* clearUnrecoverableCmmdAuthForSession(session.sessionId).pipe(require_Schema$1.catch_((error) => require_Schema$1.logWarning("Failed to clear unrecoverable CMMD auth after missing JWT.", {
70416
- cause: error,
70417
- sessionId: session.sessionId
70418
- })));
70419
- return buildProxyErrorResponse(new CmmdProxyAuthenticationRequiredError("CMMD connection required. Reconnect CMMD to continue."));
70420
- }
70461
+ if (!jwt) return yield* respondCmmdConnectionRequired(session.sessionId);
70421
70462
  let outcome = yield* require_Schema$1.promise(() => runProxy(() => dispatchToProxy(route.method, jwt, cmmdPath, rawBody, orgId, searchParams)));
70422
70463
  if (!outcome.ok && outcome.error instanceof CmmdProxyAuthError) {
70423
70464
  const refreshedJwt = yield* resolveJwt(true);
70424
70465
  if (refreshedJwt && refreshedJwt !== jwt) outcome = yield* require_Schema$1.promise(() => runProxy(() => dispatchToProxy(route.method, refreshedJwt, cmmdPath, rawBody, orgId, searchParams)));
70425
70466
  }
70426
70467
  if (!outcome.ok) {
70427
- if (outcome.error instanceof CmmdProxyAuthError || outcome.error instanceof CmmdProxyAuthenticationRequiredError) yield* clearUnrecoverableCmmdAuthForSession(session.sessionId).pipe(require_Schema$1.catch_((error) => require_Schema$1.logWarning("Failed to clear unrecoverable CMMD auth after REST 401.", {
70428
- cause: error,
70429
- sessionId: session.sessionId
70430
- })));
70468
+ if (outcome.error instanceof CmmdProxyAuthError || outcome.error instanceof CmmdProxyAuthenticationRequiredError) yield* clearCmmdAuthAfterFailure(session.sessionId);
70431
70469
  return buildProxyErrorResponse(outcome.error);
70432
70470
  }
70433
70471
  const payload = route.responseShape === "passthrough" ? outcome.value : unwrapEnvelope$1(outcome.value);
@@ -70438,6 +70476,59 @@ function registerProxyRoute(route) {
70438
70476
  }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error)));
70439
70477
  return add$1(route.method, route.forgePath, handler);
70440
70478
  }
70479
+ /**
70480
+ * Generates an Effect HttpRouter layer for the given route and records it in
70481
+ * the registry (for auditing / tests, and so command/http.ts's
70482
+ * `cmmdProxyRouteLayers` can pick it up). The returned layer registers one
70483
+ * handler at forgePath.
70484
+ */
70485
+ function registerProxyRoute(route) {
70486
+ _registeredRoutes.push(route);
70487
+ const layer = buildProxyRouteLayer(route);
70488
+ _registeredLayers.push(layer);
70489
+ return layer;
70490
+ }
70491
+ /**
70492
+ * Builds the bare handler Effect for one handler route (no `HttpRouter.add`
70493
+ * wrapping, no registry side effects) — exposed on its own so tests can
70494
+ * exercise it the same way they exercise every other bespoke handler in
70495
+ * http.ts: providing `HttpServerRequest` / `ServerAuth` directly and running
70496
+ * the Effect, without standing up a router.
70497
+ */
70498
+ function buildProxyHandlerEffect(route) {
70499
+ return require_Schema$1.gen(function* () {
70500
+ const req = yield* require_HttpServer.HttpServerRequest;
70501
+ const session = yield* (yield* ServerAuth).authenticateHttpRequest(req);
70502
+ if (!readCommandAccessTokenForSession(session.sessionId)) return yield* respondCmmdConnectionRequired(session.sessionId);
70503
+ const parsed = yield* route.parse(req);
70504
+ if (!parsed.ok) return require_HttpServer.jsonUnsafe(parsed.body, { status: parsed.status });
70505
+ const result$4 = yield* route.run(parsed.value, { session }).pipe(require_Schema$1.result);
70506
+ if (require_Schema$1.isFailure$1(result$4)) {
70507
+ const error = result$4.failure;
70508
+ if (error instanceof CmmdProxyAuthError || error instanceof CmmdProxyAuthenticationRequiredError) yield* clearCmmdAuthAfterFailure(session.sessionId);
70509
+ return buildProxyErrorResponse(error);
70510
+ }
70511
+ return require_HttpServer.jsonUnsafe(result$4.success.body, { status: result$4.success.status });
70512
+ }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error)));
70513
+ }
70514
+ const _registeredHandlerRoutes = [];
70515
+ /**
70516
+ * Builds the handler Effect for one route, mounts it via `HttpRouter.add` and
70517
+ * records that layer in the same registry `registerProxyRoute` uses (so
70518
+ * command/http.ts's `cmmdProxyRouteLayers` picks it up without a separate
70519
+ * mount list) — then returns the bare handler Effect rather than the layer,
70520
+ * so the caller can keep a single `__xHandlerForTests`-style export that
70521
+ * doubles as both the thing under test and the thing that gets mounted.
70522
+ */
70523
+ function registerProxyHandler(route) {
70524
+ _registeredHandlerRoutes.push({
70525
+ method: route.method,
70526
+ forgePath: route.forgePath
70527
+ });
70528
+ const handler = buildProxyHandlerEffect(route);
70529
+ _registeredLayers.push(add$1(route.method, route.forgePath, handler));
70530
+ return handler;
70531
+ }
70441
70532
  //#endregion
70442
70533
  //#region src/connect/credentialRefresh.ts
70443
70534
  async function refreshConnectCredential(deps) {
@@ -92611,6 +92702,172 @@ function classifyRuntimeReplicationHttpFailure(failure) {
92611
92702
  };
92612
92703
  }
92613
92704
  //#endregion
92705
+ //#region src/runtimeReplication/runtimeLane.ts
92706
+ /**
92707
+ * Read a grant-lane response the way the gateway reads an owner-lane one: a
92708
+ * non-2xx becomes a `CmmdProxyRequestError` carrying the status and CMMD's
92709
+ * error code, so a caller can classify either lane's failure with one rule.
92710
+ */
92711
+ async function parseRuntimeLaneResponse(response) {
92712
+ const text = await response.text();
92713
+ let body = null;
92714
+ if (text) try {
92715
+ body = JSON.parse(text);
92716
+ } catch {
92717
+ body = null;
92718
+ }
92719
+ if (!response.ok) {
92720
+ const code = readRuntimeReplicationErrorCode(body);
92721
+ throw new CmmdProxyRequestError(`CMMD runtime replication failed (${response.status})`, response.status, null, code ? { code } : null);
92722
+ }
92723
+ if (body === null) throw new Error("CMMD runtime replication returned an empty or invalid JSON response.");
92724
+ return body;
92725
+ }
92726
+ /**
92727
+ * One request on whichever lane the runtime holds. The caller has already
92728
+ * built the path for `lane.kind`; this only decides the transport and the
92729
+ * credential header, and normalises failures to the gateway's error classes.
92730
+ */
92731
+ async function requestOnRuntimeLane(lane, request, transport = {}) {
92732
+ if (lane.kind === "owner-session") return (transport.gateway ?? cmmdGateway).request({
92733
+ method: request.method,
92734
+ jwt: lane.jwt,
92735
+ path: request.path,
92736
+ ...request.body === void 0 ? {} : { body: request.body }
92737
+ });
92738
+ return parseRuntimeLaneResponse(await (transport.fetchImpl ?? fetch)(new URL(request.path, `${lane.controlPlaneUrl}/`), {
92739
+ method: request.method,
92740
+ headers: {
92741
+ authorization: `Bearer ${lane.grantToken}`,
92742
+ accept: "application/json",
92743
+ ...request.body === void 0 ? {} : { "content-type": "application/json" }
92744
+ },
92745
+ ...request.body === void 0 ? {} : { body: JSON.stringify(request.body) },
92746
+ ...request.signal === void 0 ? {} : { signal: request.signal }
92747
+ }));
92748
+ }
92749
+ function mapRuntimeReplicationClientError(error, operation) {
92750
+ if (error instanceof CmmdProxyAuthError) return new RuntimeReplicationClientError({
92751
+ kind: "auth",
92752
+ code: "CMMD_AUTH_REQUIRED",
92753
+ detail: error.message
92754
+ });
92755
+ if (error instanceof CmmdProxyAuthenticationRequiredError) return new RuntimeReplicationClientError({
92756
+ kind: "auth",
92757
+ code: "CMMD_AUTH_REQUIRED",
92758
+ detail: error.message
92759
+ });
92760
+ if (error instanceof CmmdProxyPermissionError) return new RuntimeReplicationClientError({
92761
+ kind: "permanent",
92762
+ code: "CMMD_PERMISSION_DENIED",
92763
+ detail: error.message
92764
+ });
92765
+ if (error instanceof CmmdProxyRequestError) return new RuntimeReplicationClientError(classifyRuntimeReplicationHttpFailure({
92766
+ status: error.status,
92767
+ body: error.body,
92768
+ detail: error.detail ?? error.message,
92769
+ ...operation ? { operation } : {}
92770
+ }));
92771
+ return new RuntimeReplicationClientError({
92772
+ kind: "retryable",
92773
+ code: "CMMD_UNAVAILABLE",
92774
+ detail: error instanceof Error ? error.message : String(error)
92775
+ });
92776
+ }
92777
+ //#endregion
92778
+ //#region src/runtimeReplication/lifecycleIntentClient.ts
92779
+ /**
92780
+ * The runtime half of a lifecycle intent: a settle or un-settle a person asked
92781
+ * for while this runtime was offline, held by CMMD until the runtime lists it,
92782
+ * applies it through its own orchestration, and acknowledges it.
92783
+ *
92784
+ * Both lanes carry the same envelope (pinned equal in the contracts package),
92785
+ * so one client serves the desktop's owner-session lane and the cloud
92786
+ * runtime's grant lane; only the path family differs.
92787
+ */
92788
+ const LIFECYCLE_INTENT_TIMEOUT = "10 seconds";
92789
+ const LifecycleIntentListEnvelope = require_Schema$1.Struct({ data: require_Schema$1.Struct({ intents: require_Schema$1.ArraySchema(require_Schema$1.Struct({
92790
+ runtimeId: require_Schema$1.String,
92791
+ threadId: require_Schema$1.String,
92792
+ action: require_Schema$1.Literals(["settle", "unsettle"]),
92793
+ requestedAt: require_Schema$1.String
92794
+ })) }) });
92795
+ const LifecycleIntentAcknowledgementEnvelope = require_Schema$1.Struct({ data: require_Schema$1.Struct({ acknowledged: require_Schema$1.Number }) });
92796
+ const decodeListEnvelope = require_Schema$1.decodeUnknownSync(LifecycleIntentListEnvelope);
92797
+ const decodeAcknowledgementEnvelope = require_Schema$1.decodeUnknownSync(LifecycleIntentAcknowledgementEnvelope);
92798
+ function decodeLifecycleIntentListResponse(response) {
92799
+ return decodeListEnvelope(response).data;
92800
+ }
92801
+ function decodeLifecycleIntentAcknowledgementResponse(response) {
92802
+ return decodeAcknowledgementEnvelope(response).data;
92803
+ }
92804
+ /**
92805
+ * Ids arrive from runtime rows, not constrained to path-safe characters, so
92806
+ * they are encoded the way every other runtime-lane path builder encodes them.
92807
+ */
92808
+ function lifecycleIntentPath(lane, operation) {
92809
+ const base = `/api/forge/context/${lane.kind === "grant" ? "runtime-replication" : "devices"}/runtimes/${encodeURIComponent(lane.runtimeId)}/thread-lifecycle-intents`;
92810
+ return operation === "ack" ? `${base}/ack` : base;
92811
+ }
92812
+ function timedOut(operation) {
92813
+ return new RuntimeReplicationClientError({
92814
+ kind: "retryable",
92815
+ code: "CMMD_TIMEOUT",
92816
+ detail: `CMMD lifecycle intent ${operation} timed out.`
92817
+ });
92818
+ }
92819
+ function decodeOrFail(response, decode, label) {
92820
+ return require_Schema$1.try_({
92821
+ try: () => decode(response),
92822
+ catch: (cause) => new RuntimeReplicationClientError({
92823
+ kind: "permanent",
92824
+ code: "CMMD_PROTOCOL_INVALID_RESPONSE",
92825
+ detail: `CMMD returned an invalid lifecycle intent ${label}: ${cause instanceof Error ? cause.message : String(cause)}`
92826
+ })
92827
+ });
92828
+ }
92829
+ /**
92830
+ * Every pending intent for this runtime, or an empty list.
92831
+ *
92832
+ * 404 is an ordinary answer, not a failure: a CMMD that predates the route
92833
+ * has nothing pending for anyone, and a runtime it has not registered yet has
92834
+ * nothing pending either. Every other non-2xx is a typed error -- a signed-out
92835
+ * owner (auth) is the caller's to skip, an outage is the next tick's to retry.
92836
+ */
92837
+ function listPendingLifecycleIntents(lane, transport) {
92838
+ return require_Schema$1.tryPromise({
92839
+ try: (signal) => requestOnRuntimeLane(lane, {
92840
+ method: "GET",
92841
+ path: lifecycleIntentPath(lane, "list"),
92842
+ signal
92843
+ }, transport),
92844
+ catch: (cause) => cause instanceof CmmdProxyRequestError && cause.status === 404 ? null : mapRuntimeReplicationClientError(cause)
92845
+ }).pipe(require_Schema$1.catch_((cause) => cause === null ? require_Schema$1.succeed(null) : require_Schema$1.fail(cause)), require_Schema$1.flatMap((response) => response === null ? require_Schema$1.succeed([]) : decodeOrFail(response, decodeLifecycleIntentListResponse, "list").pipe(require_Schema$1.map((list) => list.intents))), require_Schema$1.timeoutOrElse({
92846
+ duration: LIFECYCLE_INTENT_TIMEOUT,
92847
+ orElse: () => require_Schema$1.fail(timedOut("list"))
92848
+ }));
92849
+ }
92850
+ /**
92851
+ * Tell CMMD which intents were applied (or deliberately skipped), by thread
92852
+ * and requested time. CMMD drops only an intent whose requested time matches,
92853
+ * so a newer request recorded while this one was being applied survives.
92854
+ */
92855
+ function acknowledgeLifecycleIntents(lane, intents, transport) {
92856
+ const body = { intents };
92857
+ return require_Schema$1.tryPromise({
92858
+ try: (signal) => requestOnRuntimeLane(lane, {
92859
+ method: "POST",
92860
+ path: lifecycleIntentPath(lane, "ack"),
92861
+ body,
92862
+ signal
92863
+ }, transport),
92864
+ catch: mapRuntimeReplicationClientError
92865
+ }).pipe(require_Schema$1.flatMap((response) => decodeOrFail(response, decodeLifecycleIntentAcknowledgementResponse, "acknowledgement")), require_Schema$1.timeoutOrElse({
92866
+ duration: LIFECYCLE_INTENT_TIMEOUT,
92867
+ orElse: () => require_Schema$1.fail(timedOut("ack"))
92868
+ }));
92869
+ }
92870
+ //#endregion
92614
92871
  //#region src/runtimeReplication/runtimeReplicationGrantPolicy.ts
92615
92872
  /**
92616
92873
  * Chooses which CMMD grant a replication send should use: the in-memory
@@ -92716,26 +92973,11 @@ function runtimeReplicationDevicePath(input) {
92716
92973
  const threadId = input.streamKey.slice(7);
92717
92974
  return `${devicePath}/threads/${encodeURIComponent(threadId)}/events`;
92718
92975
  }
92719
- async function parseRuntimeReplicationResponse(response) {
92720
- const text = await response.text();
92721
- let body = null;
92722
- if (text) try {
92723
- body = JSON.parse(text);
92724
- } catch {
92725
- body = null;
92726
- }
92727
- if (!response.ok) {
92728
- const code = readRuntimeReplicationErrorCode(body);
92729
- throw new CmmdProxyRequestError(`CMMD runtime replication failed (${response.status})`, response.status, null, code ? { code } : null);
92730
- }
92731
- if (body === null) throw new Error("CMMD runtime replication returned an empty or invalid JSON response.");
92732
- return body;
92733
- }
92734
92976
  async function requestRuntimeReplicationWithGrant(input, fetchImpl = fetch) {
92735
92977
  const abortController = new AbortController();
92736
92978
  const timeout = setTimeout(() => abortController.abort(), RUNTIME_REPLICATION_TIMEOUT_MS);
92737
92979
  try {
92738
- return await parseRuntimeReplicationResponse(await fetchImpl(new URL(runtimeReplicationGrantPath(input), `${input.controlPlaneUrl}/`), {
92980
+ return await parseRuntimeLaneResponse(await fetchImpl(new URL(runtimeReplicationGrantPath(input), `${input.controlPlaneUrl}/`), {
92739
92981
  method: input.operation === "inventory" ? "PUT" : "POST",
92740
92982
  headers: {
92741
92983
  authorization: `Bearer ${input.grantToken}`,
@@ -92748,34 +92990,6 @@ async function requestRuntimeReplicationWithGrant(input, fetchImpl = fetch) {
92748
92990
  clearTimeout(timeout);
92749
92991
  }
92750
92992
  }
92751
- function mapRuntimeReplicationClientError(error, operation) {
92752
- if (error instanceof CmmdProxyAuthError) return new RuntimeReplicationClientError({
92753
- kind: "auth",
92754
- code: "CMMD_AUTH_REQUIRED",
92755
- detail: error.message
92756
- });
92757
- if (error instanceof CmmdProxyAuthenticationRequiredError) return new RuntimeReplicationClientError({
92758
- kind: "auth",
92759
- code: "CMMD_AUTH_REQUIRED",
92760
- detail: error.message
92761
- });
92762
- if (error instanceof CmmdProxyPermissionError) return new RuntimeReplicationClientError({
92763
- kind: "permanent",
92764
- code: "CMMD_PERMISSION_DENIED",
92765
- detail: error.message
92766
- });
92767
- if (error instanceof CmmdProxyRequestError) return new RuntimeReplicationClientError(classifyRuntimeReplicationHttpFailure({
92768
- status: error.status,
92769
- body: error.body,
92770
- detail: error.detail ?? error.message,
92771
- ...operation ? { operation } : {}
92772
- }));
92773
- return new RuntimeReplicationClientError({
92774
- kind: "retryable",
92775
- code: "CMMD_UNAVAILABLE",
92776
- detail: error instanceof Error ? error.message : String(error)
92777
- });
92778
- }
92779
92993
  function decodeRuntimeThreadAcknowledgementResponse(response) {
92780
92994
  return decodeThreadAcknowledgement(response).data.acknowledgement;
92781
92995
  }
@@ -92851,9 +93065,12 @@ function replicateWithOwnerSession(sql, input) {
92851
93065
  const jwt = owner.jwt;
92852
93066
  const path = runtimeReplicationDevicePath(input);
92853
93067
  const response = yield* require_Schema$1.tryPromise({
92854
- try: () => cmmdGateway.request({
93068
+ try: () => requestOnRuntimeLane({
93069
+ kind: "owner-session",
93070
+ runtimeId: input.runtimeId,
93071
+ jwt
93072
+ }, {
92855
93073
  method: input.operation === "inventory" ? "PUT" : "POST",
92856
- jwt,
92857
93074
  path,
92858
93075
  body: input.payload
92859
93076
  }),
@@ -92864,11 +93081,63 @@ function replicateWithOwnerSession(sql, input) {
92864
93081
  return yield* decodeAcknowledgementOrFail(response, decodeRuntimeThreadAcknowledgementResponse, "transcript");
92865
93082
  });
92866
93083
  }
93084
+ /**
93085
+ * The lane this runtime holds right now, resolved per call because both
93086
+ * credentials rotate: the cloud grant is re-read from the control authority,
93087
+ * and the owner session is whichever sign-in is newest on this desktop.
93088
+ */
93089
+ function resolveRuntimeLane(config, sql, input) {
93090
+ return require_Schema$1.gen(function* () {
93091
+ if (config.forgeCmmdRuntimeMode === true) {
93092
+ const cloudGrant = resolveCloudRuntimeReplicationGrant(config);
93093
+ if (!cloudGrant) return yield* new RuntimeReplicationClientError({
93094
+ kind: "auth",
93095
+ code: "CMMD_RUNTIME_GRANT_REQUIRED",
93096
+ detail: "Cloud runtime replication requires a canonical runtime ID, CMMD URL, and scoped runtime grant."
93097
+ });
93098
+ if (input.runtimeId !== cloudGrant.runtimeId) return yield* new RuntimeReplicationClientError({
93099
+ kind: "permanent",
93100
+ code: "CMMD_RUNTIME_ID_MISMATCH",
93101
+ detail: "The requested runtime does not match this cloud runtime identity."
93102
+ });
93103
+ return {
93104
+ kind: "grant",
93105
+ controlPlaneUrl: cloudGrant.controlPlaneUrl,
93106
+ runtimeId: cloudGrant.runtimeId,
93107
+ grantToken: cloudGrant.grantToken
93108
+ };
93109
+ }
93110
+ const owner = yield* resolveCmmdOwnerSessionCredential(sql, { logPrefix: input.logPrefix });
93111
+ if (owner.kind === "no-session") return yield* new RuntimeReplicationClientError({
93112
+ kind: "auth",
93113
+ code: "CMMD_AUTH_REQUIRED",
93114
+ detail: "CMMD sign-in is required for runtime replication."
93115
+ });
93116
+ if (owner.kind === "no-credential") return yield* new RuntimeReplicationClientError({
93117
+ kind: "auth",
93118
+ code: "CMMD_AUTH_REQUIRED",
93119
+ detail: "CMMD REST credentials are unavailable for runtime replication."
93120
+ });
93121
+ return {
93122
+ kind: "owner-session",
93123
+ runtimeId: input.runtimeId,
93124
+ jwt: owner.jwt
93125
+ };
93126
+ });
93127
+ }
92867
93128
  const RuntimeReplicationClientLive = require_Schema$1.effect(RuntimeReplicationClient, require_Schema$1.gen(function* () {
92868
93129
  const sql = yield* require_SqlError.SqlClient;
92869
93130
  const config = yield* ServerConfig;
92870
93131
  const send = (input) => config.forgeCmmdRuntimeMode === true ? replicateWithRuntimeGrant(config, input) : replicateWithOwnerSession(sql, input);
92871
- return RuntimeReplicationClient.of({ send });
93132
+ const lane = (runtimeId) => resolveRuntimeLane(config, sql, {
93133
+ runtimeId,
93134
+ logPrefix: "lifecycle-intents"
93135
+ });
93136
+ return RuntimeReplicationClient.of({
93137
+ send,
93138
+ listPendingLifecycleIntents: ({ runtimeId }) => lane(runtimeId).pipe(require_Schema$1.flatMap((l) => listPendingLifecycleIntents(l))),
93139
+ acknowledgeLifecycleIntents: ({ runtimeId, intents }) => lane(runtimeId).pipe(require_Schema$1.flatMap((l) => acknowledgeLifecycleIntents(l, intents)))
93140
+ });
92872
93141
  }));
92873
93142
  //#endregion
92874
93143
  //#region src/runtimeReplication/Services/RuntimeReplicationOutbox.ts
@@ -93186,6 +93455,14 @@ function stableReplicaDigest(...values) {
93186
93455
  function replicaHydrationCommandId(runtimeId, generationId, threadId) {
93187
93456
  return CommandId.make("runtime-replica-hydration:" + stableReplicaDigest(runtimeId, generationId, threadId));
93188
93457
  }
93458
+ /**
93459
+ * One id per (runtime, thread, requested time): a restart between dispatch and
93460
+ * acknowledgement re-lists the same intent, and the engine's command receipts
93461
+ * turn the second dispatch into a no-op instead of a second settle.
93462
+ */
93463
+ function lifecycleIntentCommandId(runtimeId, threadId, requestedAt) {
93464
+ return CommandId.make("lifecycle-intent:" + stableReplicaDigest(runtimeId, threadId, requestedAt));
93465
+ }
93189
93466
  //#endregion
93190
93467
  //#region src/runtimeReplication/protocol.ts
93191
93468
  const EMPTY_RUNTIME_THREAD_HEAD_HASH = "sha256:47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU";
@@ -94136,6 +94413,21 @@ function totalTokens(totals) {
94136
94413
  return totals.uncachedInputTokens + totals.cachedInputTokens + totals.cacheCreationTokens + totals.outputTokens;
94137
94414
  }
94138
94415
  /**
94416
+ * What a transcript record's own on-disk facts say it is a row of.
94417
+ *
94418
+ * Reuses exactly the facts `usageDrivers.ts`'s `isForgeAgent` reads to route a
94419
+ * record to the Forge agents lane, minus the "is this one of this
94420
+ * environment's own threads" gate: a Claude sidechain or a Codex subagent
94421
+ * rollout is a Subagent row regardless of which thread (if any) it hangs
94422
+ * under, so a subagent driven from outside Forge is still `subagent`, not a
94423
+ * plain Recorded-turn-shaped `turn`. Exported so the scan cache can recompute
94424
+ * the same value on decode instead of storing it as a redundant column.
94425
+ */
94426
+ function transcriptRecordKind(provider, sidechain, rootSessionId) {
94427
+ if (provider === "claude") return sidechain === true ? "subagent" : "turn";
94428
+ return rootSessionId !== void 0 ? "subagent" : "turn";
94429
+ }
94430
+ /**
94139
94431
  * Cheap substring gate applied before `JSON.parse`.
94140
94432
  *
94141
94433
  * Transcripts are mostly tool output; only a minority of lines carry usage. On
@@ -94204,6 +94496,7 @@ function parseClaudeLine(line, diagnostics) {
94204
94496
  const dedupeKey = claudeDedupeKey(stringAt(messageRecord, "id"), stringAt(record, "requestId"));
94205
94497
  const cost = record["costUSD"];
94206
94498
  const launcher = stringAt(record, "entrypoint");
94499
+ const sidechain = record["isSidechain"] === true;
94207
94500
  return {
94208
94501
  provider: "claude",
94209
94502
  timestampMs,
@@ -94212,8 +94505,9 @@ function parseClaudeLine(line, diagnostics) {
94212
94505
  totals: claudeTokenBuckets(usageRecord) ?? EMPTY_TOTALS,
94213
94506
  reportedCostUsd: typeof cost === "number" && Number.isFinite(cost) ? cost : null,
94214
94507
  dedupeKey,
94508
+ kind: transcriptRecordKind("claude", sidechain, void 0),
94215
94509
  ...launcher === null ? {} : { launcher },
94216
- ...record["isSidechain"] === true ? { sidechain: true } : {}
94510
+ ...sidechain ? { sidechain: true } : {}
94217
94511
  };
94218
94512
  }
94219
94513
  function initialCodexScanState() {
@@ -94330,6 +94624,7 @@ function parseCodexTokenCount(record, payloadRecord, state) {
94330
94624
  totals,
94331
94625
  reportedCostUsd: null,
94332
94626
  dedupeKey: null,
94627
+ kind: transcriptRecordKind("codex", void 0, state.rootSessionId),
94333
94628
  ...codexSessionFields(state)
94334
94629
  };
94335
94630
  }
@@ -94598,7 +94893,8 @@ var UsageAggregator = class {
94598
94893
  origin,
94599
94894
  sync,
94600
94895
  runtimeId,
94601
- driver
94896
+ driver,
94897
+ record.kind
94602
94898
  ].join("\0");
94603
94899
  const existing = this.#buckets.get(key);
94604
94900
  if (existing !== void 0) return existing;
@@ -94636,7 +94932,7 @@ var UsageAggregator = class {
94636
94932
  finish() {
94637
94933
  const buckets = [];
94638
94934
  for (const [key, bucket] of this.#buckets) {
94639
- const [day = "", hourStart = "", provider = "", model = "", origin = "", sync = "", runtimeId = "", driver = ""] = key.split("\0");
94935
+ const [day = "", hourStart = "", provider = "", model = "", origin = "", sync = "", runtimeId = "", driver = "", kind = ""] = key.split("\0");
94640
94936
  buckets.push({
94641
94937
  day,
94642
94938
  ...hourStart === "" ? {} : { hourStart },
@@ -94652,10 +94948,15 @@ var UsageAggregator = class {
94652
94948
  origin,
94653
94949
  ...sync === "" ? {} : { sync },
94654
94950
  ...runtimeId === "" ? {} : { runtimeId },
94655
- ...driver === "" ? {} : { driver }
94951
+ ...driver === "" ? {} : { driver },
94952
+ kind
94656
94953
  });
94657
94954
  }
94658
- buckets.sort((a, b) => bucketSortKey(a).localeCompare(bucketSortKey(b)));
94955
+ buckets.sort((a, b) => {
94956
+ const left = bucketSortKey(a);
94957
+ const right = bucketSortKey(b);
94958
+ return left < right ? -1 : left > right ? 1 : 0;
94959
+ });
94659
94960
  return {
94660
94961
  buckets,
94661
94962
  duplicatesDropped: this.#duplicatesDropped,
@@ -94673,7 +94974,8 @@ function bucketSortKey(bucket) {
94673
94974
  bucket.origin ?? "",
94674
94975
  bucket.sync ?? "",
94675
94976
  bucket.runtimeId ?? "",
94676
- bucket.driver ?? ""
94977
+ bucket.driver ?? "",
94978
+ bucket.kind ?? ""
94677
94979
  ].join("\0");
94678
94980
  }
94679
94981
  /**
@@ -95662,6 +95964,7 @@ function syncOf(sequence, options, threadId, events) {
95662
95964
  return sequence <= cursor.acknowledgedSequence ? "acknowledged" : "pending";
95663
95965
  }
95664
95966
  function recordOf(event, provider, sync, threadId, runtimeId) {
95967
+ const kind = event.usageKind ?? "turn";
95665
95968
  return {
95666
95969
  provider,
95667
95970
  timestampMs: Date.parse(event.occurredAt),
@@ -95670,6 +95973,7 @@ function recordOf(event, provider, sync, threadId, runtimeId) {
95670
95973
  totals: event.usage ?? EMPTY_TOTALS,
95671
95974
  reportedCostUsd: null,
95672
95975
  dedupeKey: `recorded:${threadId}:${event.turnId}:${event.usageKind ?? "turn"}:${event.subagentId ?? ""}:${event.model}`,
95976
+ kind,
95673
95977
  origin: "recorded",
95674
95978
  ...sync === void 0 ? {} : { sync },
95675
95979
  ...runtimeId === void 0 ? {} : { runtimeId },
@@ -96391,6 +96695,22 @@ async function readTranscriptRecords(filePath, provider) {
96391
96695
  //#endregion
96392
96696
  //#region src/usage/usageScanCache.ts
96393
96697
  /**
96698
+ * Durable per-file scan cache.
96699
+ *
96700
+ * Transcripts are append-only and a file that has not changed can never yield
96701
+ * different usage, so parsed records are keyed by `(size, mtime)` and reused.
96702
+ * Without this every server restart re-parses the whole window: seconds for a
96703
+ * 30-day scan, against milliseconds to reload this cache.
96704
+ *
96705
+ * Caching *per file* rather than per day is deliberate. It is timezone
96706
+ * independent, so changing the reporting zone does not invalidate anything, and
96707
+ * it keeps cross-file de-duplication exact: cached entries are de-duplicated
96708
+ * within their own file only, and the aggregator still applies the global
96709
+ * dedupe pass over the small surviving key set.
96710
+ *
96711
+ * @module usageScanCache
96712
+ */
96713
+ /**
96394
96714
  * Bumped whenever cached records could differ from what a fresh parse produces.
96395
96715
  *
96396
96716
  * Version 1 was written before `parseCodexLine` suppressed the parent history a
@@ -96536,6 +96856,7 @@ function decodeRecord(row, provider, tables) {
96536
96856
  },
96537
96857
  reportedCostUsd: finiteNumber(reportedCostUsd),
96538
96858
  dedupeKey: typeof dedupeKey === "string" ? dedupeKey : null,
96859
+ kind: transcriptRecordKind(provider, session.sidechain, session.rootSessionId),
96539
96860
  ...session
96540
96861
  };
96541
96862
  }
@@ -99508,144 +99829,6 @@ function claudeWriteToken(env = process.env) {
99508
99829
  return accessor.read(env);
99509
99830
  }
99510
99831
  //#endregion
99511
- //#region src/usage/providerRateLimits.ts
99512
- /**
99513
- * In-process cache of the latest Claude 5h/7d rate-limit telemetry, decoded
99514
- * from the genuine Claude Agent SDK's own `rate_limit_event` messages
99515
- * (see ClaudeAdapter.ts). This is intentionally NOT a CMMD call site: CMMD
99516
- * must never replay a personal Claude OAuth token against api.anthropic.com
99517
- * from its own backend (see CMMD's personal-claude-delivery.ts) - the only
99518
- * legitimate source for this data is the real in-VM SDK session reporting it
99519
- * as a side effect of a real turn.
99520
- *
99521
- * Snapshots are fenced by the exact non-secret credential-generation hash.
99522
- * A Forge process can outlive an account reconnect, so a process-wide singleton
99523
- * without that fence can leak account A's windows into account B's session.
99524
- * The request-scoped route that reads this
99525
- * cache (apps/server/src/command/http.ts) is what actually forwards it to
99526
- * CMMD, using the request's own authenticated session - a background event
99527
- * pipeline has no such session to reuse safely.
99528
- */
99529
- /**
99530
- * The SDK only ever reports ONE window per event. Only `five_hour` and
99531
- * `seven_day` map to the two windows the Usage page shows; the
99532
- * per-model/overage variants (seven_day_opus, overage, ...) are ignored here
99533
- * on purpose rather than silently overwriting the plain 7-day figure.
99534
- */
99535
- function mapClaudeRateLimitInfo(info) {
99536
- if (typeof info.utilization !== "number" || typeof info.resetsAt !== "number" || !info.status) return null;
99537
- const kind = info.rateLimitType === "five_hour" ? "fiveHour" : info.rateLimitType === "seven_day" ? "sevenDay" : null;
99538
- if (!kind) return null;
99539
- return {
99540
- kind,
99541
- window: {
99542
- usedPercent: Math.round(info.utilization * 100),
99543
- resetsAt: (/* @__PURE__ */ new Date(info.resetsAt * 1e3)).toISOString(),
99544
- status: info.status
99545
- }
99546
- };
99547
- }
99548
- const SEVEN_DAY_MODEL_PREFIX = "seven_day_";
99549
- const SEVEN_DAY_OVERAGE_SUFFIX = "overage_included";
99550
- function capitalizeModelSuffix(suffix) {
99551
- return suffix.length === 0 ? suffix : suffix.charAt(0).toUpperCase() + suffix.slice(1);
99552
- }
99553
- /**
99554
- * Maps a per-model weekly SDKRateLimitInfo (`seven_day_<model>`, e.g.
99555
- * `seven_day_opus`) into a `ProviderUsageModelWindow`. `seven_day_overage_included`
99556
- * is not a per-model window (it reports overage-inclusive quota, not a
99557
- * specific model) and stays ignored here, same as plain `overage`.
99558
- */
99559
- function mapClaudeModelRateLimitInfo(info) {
99560
- if (typeof info.utilization !== "number" || typeof info.resetsAt !== "number" || !info.status) return null;
99561
- if (!info.rateLimitType?.startsWith(SEVEN_DAY_MODEL_PREFIX)) return null;
99562
- const suffix = info.rateLimitType.slice(10);
99563
- if (suffix.length === 0 || suffix === SEVEN_DAY_OVERAGE_SUFFIX) return null;
99564
- return {
99565
- model: capitalizeModelSuffix(suffix),
99566
- window: {
99567
- usedPercent: Math.round(info.utilization * 100),
99568
- resetsAt: (/* @__PURE__ */ new Date(info.resetsAt * 1e3)).toISOString(),
99569
- status: info.status
99570
- }
99571
- };
99572
- }
99573
- const cachedSnapshots = /* @__PURE__ */ new Map();
99574
- let localClaudeGenerationHash = null;
99575
- function setLocalClaudeUsageGeneration(generationId) {
99576
- localClaudeGenerationHash = (0, node_crypto.createHash)("sha256").update(generationId).digest("hex");
99577
- }
99578
- function currentClaudeUsageGenerationHash() {
99579
- const value = process.env.FORGE_PERSONAL_CLAUDE_GENERATION_HASH?.trim() ?? "";
99580
- return /^[a-f0-9]{64}$/.test(value) ? value : localClaudeGenerationHash;
99581
- }
99582
- function cacheKeyFor(generationHash, providerAccountId) {
99583
- return providerAccountId ? `${providerAccountId}:${generationHash}` : generationHash;
99584
- }
99585
- /**
99586
- * `observedAt` here is a placeholder, not an observation — it becomes
99587
- * meaningful only once a standard (five_hour/seven_day) window actually
99588
- * lands via `withStandardWindow`, which recomputes it from the retained
99589
- * windows' own observation times. A per-model-only cache (no standard window
99590
- * yet) still carries this placeholder, so callers should treat `observedAt`
99591
- * as trustworthy only once `fiveHour` or `sevenDay` is non-null.
99592
- */
99593
- function emptyCachedSnapshot(observedAt) {
99594
- return {
99595
- fiveHour: null,
99596
- sevenDay: null,
99597
- modelWindowsByModel: {},
99598
- observedAt,
99599
- fiveHourObservedAt: null,
99600
- sevenDayObservedAt: null
99601
- };
99602
- }
99603
- /** Oldest observation among the retained standard windows, so one fresh event cannot mask stale data. */
99604
- function oldestObservedAt(fiveHourObservedAt, sevenDayObservedAt) {
99605
- return [fiveHourObservedAt, sevenDayObservedAt].filter((value) => value !== null).toSorted()[0];
99606
- }
99607
- function withStandardWindow(previous, mapped, observedAt) {
99608
- const isFiveHour = mapped.kind === "fiveHour";
99609
- const fiveHourObservedAt = isFiveHour ? observedAt : previous.fiveHourObservedAt;
99610
- const sevenDayObservedAt = isFiveHour ? previous.sevenDayObservedAt : observedAt;
99611
- return {
99612
- ...previous,
99613
- fiveHour: isFiveHour ? mapped.window : previous.fiveHour,
99614
- sevenDay: isFiveHour ? previous.sevenDay : mapped.window,
99615
- fiveHourObservedAt,
99616
- sevenDayObservedAt,
99617
- observedAt: oldestObservedAt(fiveHourObservedAt, sevenDayObservedAt)
99618
- };
99619
- }
99620
- function withModelWindow(previous, mapped) {
99621
- return {
99622
- ...previous,
99623
- modelWindowsByModel: {
99624
- ...previous.modelWindowsByModel,
99625
- [mapped.model]: mapped.window
99626
- }
99627
- };
99628
- }
99629
- /**
99630
- * Merges a single-window update into the cached snapshot without clobbering
99631
- * the other windows. A per-model weekly report (`seven_day_<model>`) merges
99632
- * into `modelWindowsByModel` keyed by model, leaving every other model and
99633
- * the plain five_hour/seven_day windows untouched.
99634
- */
99635
- function recordClaudeRateLimitTelemetry(info, generationHash = currentClaudeUsageGenerationHash(), providerAccountId) {
99636
- if (generationHash === null) return;
99637
- const cacheKey = cacheKeyFor(generationHash, providerAccountId);
99638
- const observedAt = (/* @__PURE__ */ new Date()).toISOString();
99639
- const previous = cachedSnapshots.get(cacheKey) ?? emptyCachedSnapshot(observedAt);
99640
- const standard = mapClaudeRateLimitInfo(info);
99641
- if (standard) {
99642
- cachedSnapshots.set(cacheKey, withStandardWindow(previous, standard, observedAt));
99643
- return;
99644
- }
99645
- const model = mapClaudeModelRateLimitInfo(info);
99646
- if (model) cachedSnapshots.set(cacheKey, withModelWindow(previous, model));
99647
- }
99648
- //#endregion
99649
99832
  //#region src/providerAuth/ClaudeDeviceAuth.ts
99650
99833
  const AUTHORIZE_URL_PATTERN = /https:\/\/[^\s]*\/oauth\/authorize\?[^\s]+/u;
99651
99834
  const ANSI_ESCAPE_PATTERN$1 = new RegExp(String.raw`\x1B\[[0-?]*[ -/]*[@-~]`, "gu");
@@ -100160,7 +100343,6 @@ async function finalizeClaudeCredentialSync(input) {
100160
100343
  const providerAccountId = extractClaudeProviderAccountId(input.response);
100161
100344
  const credentialGenerationId = extractClaudeCredentialGenerationId(input.response);
100162
100345
  if (providerAccountId === null || credentialGenerationId === null) return null;
100163
- if (input.auth.path === USER_CLAUDE_CREDENTIAL_PATH) setLocalClaudeUsageGeneration(credentialGenerationId);
100164
100346
  return publishClaudeUsageAfterSync({
100165
100347
  auth: input.auth,
100166
100348
  providerAccountId,
@@ -147276,137 +147458,6 @@ const LocalAutomationRepositoryLive = require_Schema$1.effect(LocalAutomationRep
147276
147458
  */
147277
147459
  var CodexAdapter = class extends require_Schema$1.Service()("forge/provider/Services/CodexAdapter") {};
147278
147460
  //#endregion
147279
- //#region ../../packages/shared/src/model.ts
147280
- /** Check whether a capabilities object includes a given effort value. */
147281
- function hasEffortLevel(caps, value) {
147282
- return caps.reasoningEffortLevels.some((l) => l.value === value);
147283
- }
147284
- /** Return the default effort value for a capabilities object, or null if none. */
147285
- function getDefaultEffort(caps) {
147286
- return caps.reasoningEffortLevels.find((l) => l.isDefault)?.value ?? null;
147287
- }
147288
- /**
147289
- * Resolve a raw effort option against capabilities.
147290
- *
147291
- * Returns the effective effort value — the explicit value if supported and not
147292
- * prompt-injected, otherwise the model's default. Returns `undefined` only
147293
- * when the model has no effort levels at all.
147294
- *
147295
- * Prompt-injected efforts (e.g. "ultrathink") are excluded because they are
147296
- * applied via prompt text, not the effort API parameter.
147297
- */
147298
- function resolveEffort(caps, raw) {
147299
- const defaultValue = getDefaultEffort(caps);
147300
- const trimmed = typeof raw === "string" ? raw.trim() : null;
147301
- if (trimmed && !caps.promptInjectedEffortLevels.includes(trimmed) && hasEffortLevel(caps, trimmed)) return trimmed;
147302
- return defaultValue ?? void 0;
147303
- }
147304
- /** Check whether a capabilities object includes a given context window value. */
147305
- function hasContextWindowOption(caps, value) {
147306
- return caps.contextWindowOptions.some((o) => o.value === value);
147307
- }
147308
- /** Return the default context window value, or `null` if none is defined. */
147309
- function getDefaultContextWindow(caps) {
147310
- return caps.contextWindowOptions.find((o) => o.isDefault)?.value ?? null;
147311
- }
147312
- /**
147313
- * Resolve a raw `contextWindow` option against capabilities.
147314
- *
147315
- * Returns the effective context window value — the explicit value if supported,
147316
- * otherwise the model's default. Returns `undefined` only when the model has
147317
- * no context window options at all.
147318
- *
147319
- * Unlike effort levels (where the API has matching defaults), the context
147320
- * window requires an explicit API suffix (e.g. `[1m]`), so we always preserve
147321
- * the resolved value to avoid ambiguity between "user chose the default" and
147322
- * "not specified".
147323
- */
147324
- function resolveContextWindow(caps, raw) {
147325
- const defaultValue = getDefaultContextWindow(caps);
147326
- if (!raw) return defaultValue ?? void 0;
147327
- return hasContextWindowOption(caps, raw) ? raw : defaultValue ?? void 0;
147328
- }
147329
- function normalizeCodexModelOptionsWithCapabilities(caps, modelOptions) {
147330
- const reasoningEffort = resolveEffort(caps, modelOptions?.reasoningEffort);
147331
- const fastMode = caps.supportsFastMode ? modelOptions?.fastMode : void 0;
147332
- const nextOptions = {
147333
- ...reasoningEffort ? { reasoningEffort } : {},
147334
- ...fastMode !== void 0 ? { fastMode } : {}
147335
- };
147336
- return Object.keys(nextOptions).length > 0 ? nextOptions : void 0;
147337
- }
147338
- function normalizeClaudeModelOptionsWithCapabilities(caps, modelOptions) {
147339
- const effort = resolveEffort(caps, modelOptions?.effort);
147340
- const thinking = caps.supportsThinkingToggle ? modelOptions?.thinking : void 0;
147341
- const fastMode = caps.supportsFastMode ? modelOptions?.fastMode : void 0;
147342
- const contextWindow = resolveContextWindow(caps, modelOptions?.contextWindow);
147343
- const nextOptions = {
147344
- ...thinking !== void 0 ? { thinking } : {},
147345
- ...effort ? { effort } : {},
147346
- ...fastMode !== void 0 ? { fastMode } : {},
147347
- ...contextWindow !== void 0 ? { contextWindow } : {}
147348
- };
147349
- return Object.keys(nextOptions).length > 0 ? nextOptions : void 0;
147350
- }
147351
- function normalizeModelSlug(model, provider = "codex") {
147352
- if (typeof model !== "string") return null;
147353
- const trimmed = model.trim();
147354
- if (!trimmed) return null;
147355
- const aliases = MODEL_SLUG_ALIASES_BY_PROVIDER[provider];
147356
- const aliased = Object.prototype.hasOwnProperty.call(aliases, trimmed) ? aliases[trimmed] : void 0;
147357
- return typeof aliased === "string" ? aliased : trimmed;
147358
- }
147359
- /** Trim a string, returning null for empty/missing values. */
147360
- function trimOrNull(value) {
147361
- if (typeof value !== "string") return null;
147362
- return value.trim() || null;
147363
- }
147364
- /**
147365
- * Resolve the actual API model identifier from a model selection.
147366
- *
147367
- * Provider-aware: each provider can map `contextWindow` (or other options)
147368
- * to whatever the API requires — a model-id suffix, a separate parameter, etc.
147369
- * The canonical slug stored in the selection stays unchanged so the
147370
- * capabilities system keeps working.
147371
- *
147372
- * Expects `contextWindow` to already be resolved (via `resolveContextWindow`)
147373
- * to the effective value, not stripped to `undefined` for defaults.
147374
- */
147375
- function resolveApiModelId(modelSelection) {
147376
- switch (modelSelection.provider) {
147377
- case "claudeAgent": switch (modelSelection.options?.contextWindow) {
147378
- case "1m": return `${modelSelection.model}[1m]`;
147379
- default: return modelSelection.model;
147380
- }
147381
- default: return modelSelection.model;
147382
- }
147383
- }
147384
- function applyClaudePromptEffortPrefix(text, effort) {
147385
- const trimmed = text.trim();
147386
- if (!trimmed) return trimmed;
147387
- if (effort !== "ultrathink") return trimmed;
147388
- if (trimmed.startsWith("Ultrathink:")) return trimmed;
147389
- return `Ultrathink:\n${trimmed}`;
147390
- }
147391
- function getRawProviderOptionSelectionValue(selections, id) {
147392
- return selections?.find((candidate) => candidate.id === id)?.value;
147393
- }
147394
- function getProviderOptionSelectionValue(selections, id) {
147395
- return getRawProviderOptionSelectionValue(selections, id);
147396
- }
147397
- function getProviderOptionStringSelectionValue(selections, id) {
147398
- const value = getProviderOptionSelectionValue(selections, id);
147399
- return typeof value === "string" ? value : void 0;
147400
- }
147401
- function flatProviderOptions(selection) {
147402
- if (!selection) return void 0;
147403
- if (selection.provider !== "cursor" && selection.provider !== "opencode") return void 0;
147404
- return selection.options;
147405
- }
147406
- function getModelSelectionStringOptionValue(selection, id) {
147407
- return getProviderOptionStringSelectionValue(flatProviderOptions(selection), id);
147408
- }
147409
- //#endregion
147410
147461
  //#region src/provider/codexCliVersion.ts
147411
147462
  const CODEX_VERSION_PATTERN = /\bv?(\d+\.\d+(?:\.\d+)?(?:-[0-9A-Za-z.-]+)?)\b/;
147412
147463
  const MINIMUM_CODEX_CLI_VERSION = "0.37.0";
@@ -148061,6 +148112,213 @@ async function probeCodexDiscovery(input) {
148061
148112
  });
148062
148113
  }
148063
148114
  //#endregion
148115
+ //#region ../../packages/shared/src/model.ts
148116
+ /** Check whether a capabilities object includes a given effort value. */
148117
+ function hasEffortLevel(caps, value) {
148118
+ return caps.reasoningEffortLevels.some((l) => l.value === value);
148119
+ }
148120
+ /** Return the default effort value for a capabilities object, or null if none. */
148121
+ function getDefaultEffort(caps) {
148122
+ return caps.reasoningEffortLevels.find((l) => l.isDefault)?.value ?? null;
148123
+ }
148124
+ /**
148125
+ * Resolve a raw effort option against capabilities.
148126
+ *
148127
+ * Returns the effective effort value — the explicit value if supported and not
148128
+ * prompt-injected, otherwise the model's default. Returns `undefined` only
148129
+ * when the model has no effort levels at all.
148130
+ *
148131
+ * Prompt-injected efforts (e.g. "ultrathink") are excluded because they are
148132
+ * applied via prompt text, not the effort API parameter.
148133
+ */
148134
+ function resolveEffort(caps, raw) {
148135
+ const defaultValue = getDefaultEffort(caps);
148136
+ const trimmed = typeof raw === "string" ? raw.trim() : null;
148137
+ if (trimmed && !caps.promptInjectedEffortLevels.includes(trimmed) && hasEffortLevel(caps, trimmed)) return trimmed;
148138
+ return defaultValue ?? void 0;
148139
+ }
148140
+ /** Check whether a capabilities object includes a given context window value. */
148141
+ function hasContextWindowOption(caps, value) {
148142
+ return caps.contextWindowOptions.some((o) => o.value === value);
148143
+ }
148144
+ /** Return the default context window value, or `null` if none is defined. */
148145
+ function getDefaultContextWindow(caps) {
148146
+ return caps.contextWindowOptions.find((o) => o.isDefault)?.value ?? null;
148147
+ }
148148
+ /**
148149
+ * Resolve a raw `contextWindow` option against capabilities.
148150
+ *
148151
+ * Returns the effective context window value — the explicit value if supported,
148152
+ * otherwise the model's default. Returns `undefined` only when the model has
148153
+ * no context window options at all.
148154
+ *
148155
+ * Unlike effort levels (where the API has matching defaults), the context
148156
+ * window requires an explicit API suffix (e.g. `[1m]`), so we always preserve
148157
+ * the resolved value to avoid ambiguity between "user chose the default" and
148158
+ * "not specified".
148159
+ */
148160
+ function resolveContextWindow(caps, raw) {
148161
+ const defaultValue = getDefaultContextWindow(caps);
148162
+ if (!raw) return defaultValue ?? void 0;
148163
+ return hasContextWindowOption(caps, raw) ? raw : defaultValue ?? void 0;
148164
+ }
148165
+ function normalizeCodexModelOptionsWithCapabilities(caps, modelOptions) {
148166
+ const reasoningEffort = resolveEffort(caps, modelOptions?.reasoningEffort);
148167
+ const fastMode = caps.supportsFastMode ? modelOptions?.fastMode : void 0;
148168
+ const nextOptions = {
148169
+ ...reasoningEffort ? { reasoningEffort } : {},
148170
+ ...fastMode !== void 0 ? { fastMode } : {}
148171
+ };
148172
+ return Object.keys(nextOptions).length > 0 ? nextOptions : void 0;
148173
+ }
148174
+ function normalizeClaudeModelOptionsWithCapabilities(caps, modelOptions) {
148175
+ const effort = resolveEffort(caps, modelOptions?.effort);
148176
+ const thinking = caps.supportsThinkingToggle ? modelOptions?.thinking : void 0;
148177
+ const fastMode = caps.supportsFastMode ? modelOptions?.fastMode : void 0;
148178
+ const contextWindow = resolveContextWindow(caps, modelOptions?.contextWindow);
148179
+ const nextOptions = {
148180
+ ...thinking !== void 0 ? { thinking } : {},
148181
+ ...effort ? { effort } : {},
148182
+ ...fastMode !== void 0 ? { fastMode } : {},
148183
+ ...contextWindow !== void 0 ? { contextWindow } : {}
148184
+ };
148185
+ return Object.keys(nextOptions).length > 0 ? nextOptions : void 0;
148186
+ }
148187
+ function normalizeModelSlug(model, provider = "codex") {
148188
+ if (typeof model !== "string") return null;
148189
+ const trimmed = model.trim();
148190
+ if (!trimmed) return null;
148191
+ const aliases = MODEL_SLUG_ALIASES_BY_PROVIDER[provider];
148192
+ const aliased = Object.prototype.hasOwnProperty.call(aliases, trimmed) ? aliases[trimmed] : void 0;
148193
+ return typeof aliased === "string" ? aliased : trimmed;
148194
+ }
148195
+ /** Trim a string, returning null for empty/missing values. */
148196
+ function trimOrNull(value) {
148197
+ if (typeof value !== "string") return null;
148198
+ return value.trim() || null;
148199
+ }
148200
+ /**
148201
+ * Resolve the actual API model identifier from a model selection.
148202
+ *
148203
+ * Provider-aware: each provider can map `contextWindow` (or other options)
148204
+ * to whatever the API requires — a model-id suffix, a separate parameter, etc.
148205
+ * The canonical slug stored in the selection stays unchanged so the
148206
+ * capabilities system keeps working.
148207
+ *
148208
+ * Expects `contextWindow` to already be resolved (via `resolveContextWindow`)
148209
+ * to the effective value, not stripped to `undefined` for defaults.
148210
+ */
148211
+ function resolveApiModelId(modelSelection) {
148212
+ switch (modelSelection.provider) {
148213
+ case "claudeAgent": switch (modelSelection.options?.contextWindow) {
148214
+ case "1m": return `${modelSelection.model}[1m]`;
148215
+ default: return modelSelection.model;
148216
+ }
148217
+ default: return modelSelection.model;
148218
+ }
148219
+ }
148220
+ function applyClaudePromptEffortPrefix(text, effort) {
148221
+ const trimmed = text.trim();
148222
+ if (!trimmed) return trimmed;
148223
+ if (effort !== "ultrathink") return trimmed;
148224
+ if (trimmed.startsWith("Ultrathink:")) return trimmed;
148225
+ return `Ultrathink:\n${trimmed}`;
148226
+ }
148227
+ function getRawProviderOptionSelectionValue(selections, id) {
148228
+ return selections?.find((candidate) => candidate.id === id)?.value;
148229
+ }
148230
+ function getProviderOptionSelectionValue(selections, id) {
148231
+ return getRawProviderOptionSelectionValue(selections, id);
148232
+ }
148233
+ function getProviderOptionStringSelectionValue(selections, id) {
148234
+ const value = getProviderOptionSelectionValue(selections, id);
148235
+ return typeof value === "string" ? value : void 0;
148236
+ }
148237
+ function flatProviderOptions(selection) {
148238
+ if (!selection) return void 0;
148239
+ if (selection.provider !== "cursor" && selection.provider !== "opencode") return void 0;
148240
+ return selection.options;
148241
+ }
148242
+ function getModelSelectionStringOptionValue(selection, id) {
148243
+ return getProviderOptionStringSelectionValue(flatProviderOptions(selection), id);
148244
+ }
148245
+ function acceptableModelSlug(value) {
148246
+ const trimmed = value?.trim();
148247
+ if (!trimmed || trimmed.length > 120) return;
148248
+ return trimmed;
148249
+ }
148250
+ /**
148251
+ * Order the credential's model scope: selected model first, then the catalog,
148252
+ * deduplicated and capped.
148253
+ *
148254
+ * Returns `undefined` when there is no catalog to widen to, which is the signal
148255
+ * to send the old single-model body. A slug CMMD would refuse is dropped rather
148256
+ * than sent, because one bad entry 400s the whole mint and takes the session
148257
+ * with it.
148258
+ */
148259
+ function providerEgressModelScope(model, models) {
148260
+ const catalog = (models ?? []).map(acceptableModelSlug).filter((slug) => slug !== void 0);
148261
+ if (catalog.length === 0) return;
148262
+ const selected = acceptableModelSlug(model);
148263
+ const ordered = new Set(selected ? [selected] : []);
148264
+ for (const slug of catalog) {
148265
+ if (ordered.size >= 32) break;
148266
+ ordered.add(slug);
148267
+ }
148268
+ return [...ordered];
148269
+ }
148270
+ //#endregion
148271
+ //#region src/provider/codexCredentialModelScope.ts
148272
+ /**
148273
+ * Which Codex models one workspace egress credential has to cover.
148274
+ *
148275
+ * FOR-36501: the credential was scoped to the model the user picked, and the
148276
+ * Codex app-server holds one credential for the whole process. A turn on
148277
+ * gpt-6-astra that called `spawn_agent` with gpt-5.6-terra therefore lost the
148278
+ * child to a 401 before it spent a token. The subagent model is the model's own
148279
+ * choice in the tool arguments, so Forge cannot predict it and has to scope the
148280
+ * credential to the catalog a spawn can pick from.
148281
+ *
148282
+ * The catalog is the built-in Codex list, which is what the picker offers. It
148283
+ * includes the Spark model even though only a Pro account may call it: the
148284
+ * account snapshot is not resolved at issue time in workspace mode, and CMMD
148285
+ * still decides per call which models the account may use, so a slug in the
148286
+ * scope is permission to ask, never permission to spend.
148287
+ */
148288
+ /**
148289
+ * Normalize a Codex model slug to the one the app-server and the mint route use.
148290
+ *
148291
+ * Lives here rather than in codexAppServerManager.ts so the catalog builder can
148292
+ * use it without importing the manager back. The manager re-exports it, which is
148293
+ * where every existing caller still reads it from.
148294
+ */
148295
+ function normalizeCodexModelSlug(model, preferredId) {
148296
+ const normalized = normalizeModelSlug(model);
148297
+ if (!normalized) return;
148298
+ if (preferredId?.endsWith("-codex") && preferredId !== normalized) return preferredId;
148299
+ return normalized;
148300
+ }
148301
+ /** The model a proxy token is minted for when the thread names none. */
148302
+ function resolveCodexProviderProxyTokenModel(model) {
148303
+ const displaySlug = model?.trim().toLowerCase().replace(/\s+/g, "-");
148304
+ return normalizeCodexModelSlug(displaySlug) ?? "gpt-6-astra";
148305
+ }
148306
+ /** Every built-in Codex slug a `spawn_agent` call can name. */
148307
+ function codexCredentialModelCatalog() {
148308
+ return CODEX_BUILT_IN_MODELS.map((model) => normalizeCodexModelSlug(model.slug) ?? model.slug);
148309
+ }
148310
+ /**
148311
+ * The `models` list to mint a Codex session credential with.
148312
+ *
148313
+ * `undefined` means the catalog is unknown, and the caller then sends `model`
148314
+ * alone, exactly as before this card. That is the only safe answer: an empty
148315
+ * list would narrow the credential rather than widen it.
148316
+ */
148317
+ function buildCodexCredentialModelScope(input) {
148318
+ const catalog = (input.catalogModels ?? codexCredentialModelCatalog()).map((slug) => normalizeCodexModelSlug(slug) ?? slug).filter((slug) => slug.trim().length > 0);
148319
+ return providerEgressModelScope(input.selectedModel, catalog);
148320
+ }
148321
+ //#endregion
148064
148322
  //#region src/egress/providerDeliveryReceipt.ts
148065
148323
  const PROVIDER_ACCOUNT_IDENTITY$2 = /^pai_v1_[A-Za-z0-9_-]{43}$/;
148066
148324
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
@@ -148312,6 +148570,21 @@ function runtimeProviderEgressBaseUrl(provider, controlPlaneUrl) {
148312
148570
  anthropic: "/api/provider-egress/anthropic"
148313
148571
  }[provider]}`;
148314
148572
  }
148573
+ /**
148574
+ * The model fields of a mint body.
148575
+ *
148576
+ * `model` stays the single selected model, which is what CMMD runs its
148577
+ * post-mint constraint check on. `models` appears only when the caller knows a
148578
+ * catalog, so a caller that does not know one sends exactly the body it sent
148579
+ * before FOR-36501.
148580
+ */
148581
+ function providerEgressModelBodyFields(input) {
148582
+ const scope = providerEgressModelScope(input.model, input.models);
148583
+ return {
148584
+ ...input.model ? { model: input.model } : {},
148585
+ ...scope ? { models: scope } : {}
148586
+ };
148587
+ }
148315
148588
  const issueProviderEgressToken = (input) => issueProviderEgressCredential(input).pipe(require_Schema$1.map((credential) => credential.token));
148316
148589
  const issueProviderEgressCredential = (input) => require_Schema$1.tryPromise({
148317
148590
  try: async () => {
@@ -148335,7 +148608,7 @@ async function issueCmmdRuntimeProviderEgressCredential(input) {
148335
148608
  token: runtimeGrantToken,
148336
148609
  body: JSON.stringify({
148337
148610
  provider: input.provider,
148338
- ...input.model ? { model: input.model } : {},
148611
+ ...providerEgressModelBodyFields(input),
148339
148612
  ...input.provider === "openai" && input.providerAccountId ? { provider_account_id: input.providerAccountId } : {}
148340
148613
  })
148341
148614
  });
@@ -148451,7 +148724,7 @@ function issueCmmdLocalUserProviderEgressCredential(input) {
148451
148724
  },
148452
148725
  body: JSON.stringify({
148453
148726
  provider: input.provider,
148454
- ...input.model ? { model: input.model } : {},
148727
+ ...providerEgressModelBodyFields(input),
148455
148728
  ...input.provider === "openai" && input.providerAccountId ? { provider_account_id: input.providerAccountId } : {},
148456
148729
  client: "local-desktop",
148457
148730
  sessionId,
@@ -148834,16 +149107,6 @@ function mapCodexRuntimeMode(runtimeMode) {
148834
149107
  async function killChildTree(child) {
148835
149108
  await killCodexChildProcess(child);
148836
149109
  }
148837
- function normalizeCodexModelSlug(model, preferredId) {
148838
- const normalized = normalizeModelSlug(model);
148839
- if (!normalized) return;
148840
- if (preferredId?.endsWith("-codex") && preferredId !== normalized) return preferredId;
148841
- return normalized;
148842
- }
148843
- function resolveCodexProviderProxyTokenModel(model) {
148844
- const displaySlug = model?.trim().toLowerCase().replace(/\s+/g, "-");
148845
- return normalizeCodexModelSlug(displaySlug) ?? "gpt-6-astra";
148846
- }
148847
149110
  function buildCodexCollaborationMode(input) {
148848
149111
  if (input.interactionMode === void 0) return;
148849
149112
  const model = normalizeCodexModelSlug(input.model) ?? "gpt-6-astra";
@@ -149394,9 +149657,11 @@ var CodexAppServerManager = class extends node_events.EventEmitter {
149394
149657
  const proxyConfig = getOpenAiProviderEgressProxyConfig({ allowLocalUser: true });
149395
149658
  if (proxyConfig.mode === "disabled") return null;
149396
149659
  if (proxyConfig.mode === "misconfigured") throw new ProviderEgressTokenError({ message: proxyConfig.message });
149660
+ const models = buildCodexCredentialModelScope({ selectedModel: input.model });
149397
149661
  return await require_Schema$1.runPromise(issueProviderEgressCredential({
149398
149662
  provider: "openai",
149399
149663
  model: input.model,
149664
+ ...models ? { models } : {},
149400
149665
  threadId: input.threadId,
149401
149666
  ...input.providerAccountId ? { providerAccountId: input.providerAccountId } : {}
149402
149667
  }));
@@ -207583,36 +207848,23 @@ function mapCodexThreadNameUpdatedEvent(event, canonicalThreadId, payload) {
207583
207848
  }
207584
207849
  }];
207585
207850
  }
207586
- /** One provider call's spend, from Codex's `last_token_usage`. */
207587
- function codexTurnUsageDelta(value) {
207588
- const usage = asObject$2(value);
207589
- return codexUsageBuckets(usage?.last_token_usage ?? usage?.last, "call-delta");
207590
- }
207591
207851
  /**
207592
- * One Codex token report in Forge's disjoint buckets. Codex reports
207593
- * `input_tokens` inclusive of the cached and cache-write portions, so the
207594
- * uncached bucket is the remainder; reasoning is reported inside output and is
207595
- * surfaced separately without being added again. Mirrors `parseCodexLine` in
207852
+ * One provider call's spend, from Codex's `last_token_usage`. Reads the
207853
+ * buckets via `codexTokenBuckets`, the shared home of the Claude/Codex
207854
+ * disjointness rule (providerTokenBuckets.ts): Codex reports `input_tokens`
207855
+ * inclusive of the cached and cache-write portions, so the uncached bucket is
207856
+ * the remainder, and reasoning is reported inside output and surfaced
207857
+ * separately without being added again. Mirrors `parseCodexLine` in
207596
207858
  * usage/usageTranscripts.ts so a Recorded turn and a scanned transcript agree
207597
207859
  * on the same numbers.
207598
207860
  */
207599
- function codexUsageBuckets(value, scope) {
207600
- const lastUsage = asObject$2(value);
207601
- if (!lastUsage) return void 0;
207602
- const int = (key, alt) => Math.max(0, Math.trunc(asNumber(lastUsage[key]) ?? asNumber(lastUsage[alt]) ?? 0));
207603
- const inputTokens = int("input_tokens", "inputTokens");
207604
- const cachedInputTokens = int("cached_input_tokens", "cachedInputTokens");
207605
- const cacheCreationTokens = int("cache_write_input_tokens", "cacheWriteInputTokens");
207606
- const outputTokens = int("output_tokens", "outputTokens");
207607
- if (inputTokens + cachedInputTokens + cacheCreationTokens + outputTokens === 0) return void 0;
207608
- return {
207609
- scope,
207610
- uncachedInputTokens: Math.max(0, inputTokens - cachedInputTokens - cacheCreationTokens),
207611
- cachedInputTokens,
207612
- cacheCreationTokens,
207613
- outputTokens,
207614
- reasoningTokens: Math.min(outputTokens, int("reasoning_output_tokens", "reasoningOutputTokens"))
207615
- };
207861
+ function codexTurnUsageDelta(value) {
207862
+ const usage = asObject$2(value);
207863
+ const buckets = codexTokenBuckets(usage?.last_token_usage ?? usage?.last);
207864
+ return buckets ? {
207865
+ scope: "call-delta",
207866
+ ...buckets
207867
+ } : void 0;
207616
207868
  }
207617
207869
  function mapCodexThreadTokenUsageEvent(event, canonicalThreadId, payload) {
207618
207870
  const tokenUsage = asObject$2(payload?.tokenUsage);
@@ -208306,6 +208558,7 @@ const DEFAULT_PUBLIC_PROVIDER_ERROR = "CMMD is temporarily unavailable. Check th
208306
208558
  function categorizePublicProviderError(message) {
208307
208559
  if (!message) return null;
208308
208560
  const m = message.toLowerCase();
208561
+ if (/\bforge_provider_model_not_allowed\b/.test(m) || /\bnot\s+scoped\s+to\s+the\s+requested\s+model\b/.test(m)) return "The workspace AI credential does not cover the model this turn asked for. Retry, or pick that model for the thread.";
208309
208562
  if (/\bmodel\b[\s\S]*\b(not\s+(found|available|supported)|does\s+not\s+exist|unsupported|invalid|unknown)\b/.test(m) || /\b(unsupported|unknown|invalid)\b[\s\S]*\bmodel\b/.test(m) || /\b(model_not_found|invalid_model|model_not_supported)\b/.test(m)) return "The selected model isn't available right now. Pick a different model and retry.";
208310
208563
  if (/\b(rate[\s-]?limit|too\s+many\s+requests|quota|insufficient_quota)\b/.test(m) || /\b429\b/.test(m)) return "The AI service is rate-limited or out of quota. Wait a moment and retry.";
208311
208564
  if (/\b(unauthorized|forbidden|authentication\s+(failed|error|required)|invalid\s+api\s+key|expired\s+(token|credential))\b/.test(m) || /\b40[13]\b/.test(m)) return "Workspace AI authentication failed. Reconnect the workspace and retry.";
@@ -210157,9 +210410,6 @@ function buildClaudeSessionContext(input) {
210157
210410
  query: input.queryRuntime,
210158
210411
  streamFiber: void 0,
210159
210412
  startedAt: input.startedAt,
210160
- recordsPersonalUsageTelemetry: input.recordsPersonalUsageTelemetry,
210161
- personalUsageGenerationHash: input.personalUsageGenerationHash,
210162
- personalUsageProviderAccountId: input.personalUsageProviderAccountId,
210163
210413
  basePermissionMode: input.permissionMode,
210164
210414
  resumeSessionId: input.sessionId,
210165
210415
  pendingApprovals: input.pendingApprovals,
@@ -210517,26 +210767,18 @@ function finiteNumberFieldOrZero(usage, key) {
210517
210767
  }
210518
210768
  /**
210519
210769
  * The whole turn's spend from the SDK result message, cache split intact.
210520
- * Claude reports `input_tokens` exclusive of the cached and cache-creation
210521
- * portions, so the buckets are already disjoint. Claude does not report
210522
- * reasoning separately.
210770
+ * Reads the buckets via `claudeTokenBuckets`, the shared home of the
210771
+ * Claude/Codex disjointness rule (providerTokenBuckets.ts): Claude reports
210772
+ * `input_tokens` exclusive of the cached and cache-creation portions, so the
210773
+ * buckets are already disjoint, and Claude does not report reasoning
210774
+ * separately.
210523
210775
  */
210524
210776
  function claudeTurnUsageTotal(value) {
210525
- const usage = asClaudeUsageRecord(value);
210526
- if (!usage) return void 0;
210527
- const uncachedInputTokens = finiteNumberFieldOrZero(usage, "input_tokens");
210528
- const cachedInputTokens = finiteNumberFieldOrZero(usage, "cache_read_input_tokens");
210529
- const cacheCreationTokens = finiteNumberFieldOrZero(usage, "cache_creation_input_tokens");
210530
- const outputTokens = finiteNumberFieldOrZero(usage, "output_tokens");
210531
- if (uncachedInputTokens + cachedInputTokens + cacheCreationTokens + outputTokens <= 0) return;
210532
- return {
210777
+ const buckets = claudeTokenBuckets(value);
210778
+ return buckets ? {
210533
210779
  scope: "turn-total",
210534
- uncachedInputTokens: Math.trunc(uncachedInputTokens),
210535
- cachedInputTokens: Math.trunc(cachedInputTokens),
210536
- cacheCreationTokens: Math.trunc(cacheCreationTokens),
210537
- outputTokens: Math.trunc(outputTokens),
210538
- reasoningTokens: 0
210539
- };
210780
+ ...buckets
210781
+ } : void 0;
210540
210782
  }
210541
210783
  const EMPTY_MODEL_USAGE_BUCKETS = {
210542
210784
  uncachedInputTokens: 0,
@@ -210549,20 +210791,14 @@ function bucketsTotal(buckets) {
210549
210791
  return buckets.uncachedInputTokens + buckets.cachedInputTokens + buckets.cacheCreationTokens + buckets.outputTokens;
210550
210792
  }
210551
210793
  /**
210552
- * One `ModelUsage` entry as buckets. `ModelUsage` names its fields in
210553
- * camelCase, unlike `result.usage`, so this cannot share `claudeTurnUsageTotal`.
210554
- * Claude reports `inputTokens` exclusive of the cached and cache-creation
210555
- * portions, so the buckets are already disjoint, and it reports no reasoning.
210794
+ * One `ModelUsage` entry as buckets, via `claudeTokenBuckets`. `ModelUsage`
210795
+ * names its fields in camelCase, unlike `result.usage`, but `claudeTokenBuckets`
210796
+ * already reads both spellings. Claude reports `inputTokens` exclusive of the
210797
+ * cached and cache-creation portions, so the buckets are already disjoint, and
210798
+ * it reports no reasoning.
210556
210799
  */
210557
210800
  function claudeModelUsageBuckets(usage) {
210558
- const record = usage;
210559
- return {
210560
- uncachedInputTokens: Math.trunc(finiteNumberFieldOrZero(record, "inputTokens")),
210561
- cachedInputTokens: Math.trunc(finiteNumberFieldOrZero(record, "cacheReadInputTokens")),
210562
- cacheCreationTokens: Math.trunc(finiteNumberFieldOrZero(record, "cacheCreationInputTokens")),
210563
- outputTokens: Math.trunc(finiteNumberFieldOrZero(record, "outputTokens")),
210564
- reasoningTokens: 0
210565
- };
210801
+ return claudeTokenBuckets(usage) ?? EMPTY_MODEL_USAGE_BUCKETS;
210566
210802
  }
210567
210803
  /**
210568
210804
  * What each model spent during THIS turn, from the SDK's per-model totals.
@@ -211906,7 +212142,6 @@ const makeClaudeAdapter = require_Schema$1.fn("makeClaudeAdapter")(function* (op
211906
212142
  return;
211907
212143
  }
211908
212144
  if (message.type === "rate_limit_event") {
211909
- if (context.recordsPersonalUsageTelemetry) recordClaudeRateLimitTelemetry(message.rate_limit_info, context.personalUsageGenerationHash, context.personalUsageProviderAccountId);
211910
212145
  yield* offerRuntimeEvent({
211911
212146
  ...base,
211912
212147
  type: "account.rate-limits.updated",
@@ -212404,10 +212639,7 @@ const makeClaudeAdapter = require_Schema$1.fn("makeClaudeAdapter")(function* (op
212404
212639
  inFlightTools,
212405
212640
  resumeSessionAt: resumeState?.resumeSessionAt,
212406
212641
  effectiveApiModelId: modelConfig.effectiveApiModelId,
212407
- effectiveEffort: modelConfig.effectiveEffort,
212408
- recordsPersonalUsageTelemetry: sessionProvider === PROVIDER$11 && modelConfig.endpointProfile === void 0 && providerProxyCredential === null && !claudeSettings.anthropicBaseUrl && !claudeSettings.anthropicApiKey,
212409
- personalUsageGenerationHash: currentClaudeUsageGenerationHash(),
212410
- personalUsageProviderAccountId: modelConfig.modelSelection?.provider === "claudeAgent" ? modelConfig.modelSelection.providerAccountId : void 0
212642
+ effectiveEffort: modelConfig.effectiveEffort
212411
212643
  });
212412
212644
  yield* require_HttpServer.set(contextRef, context$4);
212413
212645
  sessions.set(threadId, context$4);
@@ -284699,6 +284931,27 @@ const makeRuntimeDrainReporter = require_Schema$1.gen(function* () {
284699
284931
  var RuntimeDrainReporter = class extends require_Schema$1.Service()("forge/runtimeDrain/RuntimeDrainReporter") {};
284700
284932
  const RuntimeDrainReporterLive = require_Schema$1.effect(RuntimeDrainReporter, makeRuntimeDrainReporter);
284701
284933
  //#endregion
284934
+ //#region src/usage/providerRateLimits.ts
284935
+ /**
284936
+ * The SDK only ever reports ONE window per event. Only `five_hour` and
284937
+ * `seven_day` map to the two windows the Usage page shows; the
284938
+ * per-model/overage variants (seven_day_opus, overage, ...) are ignored here
284939
+ * on purpose rather than silently overwriting the plain 7-day figure.
284940
+ */
284941
+ function mapClaudeRateLimitInfo(info) {
284942
+ if (typeof info.utilization !== "number" || typeof info.resetsAt !== "number" || !info.status) return null;
284943
+ const kind = info.rateLimitType === "five_hour" ? "fiveHour" : info.rateLimitType === "seven_day" ? "sevenDay" : null;
284944
+ if (!kind) return null;
284945
+ return {
284946
+ kind,
284947
+ window: {
284948
+ usedPercent: Math.round(info.utilization * 100),
284949
+ resetsAt: (/* @__PURE__ */ new Date(info.resetsAt * 1e3)).toISOString(),
284950
+ status: info.status
284951
+ }
284952
+ };
284953
+ }
284954
+ //#endregion
284702
284955
  //#region src/orchestration/Layers/ProviderRuntimeIngestion.ts
284703
284956
  const providerTurnKey = (threadId, turnId) => `${threadId}:${turnId}`;
284704
284957
  const providerCommandId = (event, tag) => CommandId.make(`provider:${event.eventId}:${tag}:${crypto.randomUUID()}`);
@@ -291765,7 +292018,7 @@ function resolveBuildCommitFromEnv(env) {
291765
292018
  * environment descriptor down instead of reporting an honest "unknown".
291766
292019
  */
291767
292020
  function readBakedBuildCommit() {
291768
- return "5f0060a9696edd41f61f06cbf24450a5994fed33";
292021
+ return "9e352ae66ea610fd1916726270fce8a1ab138a3b";
291769
292022
  }
291770
292023
  async function resolveServerBuildCommit(input) {
291771
292024
  if (isFullCommitSha(input.baked)) return input.baked;
@@ -301020,6 +301273,7 @@ function resolveWsUrl(baseUrl) {
301020
301273
  const callCmmdTool = legacyCmmdToolBridge.callTool;
301021
301274
  const extractMcpToolText = legacyCmmdToolBridge.extractText;
301022
301275
  const isCmmdMcpAuthError = legacyCmmdToolBridge.isAuthError;
301276
+ const __cmmdProxyRouteLayersStartIndex = registeredProxyRouteLayers().length;
301023
301277
  /**
301024
301278
  * CMMD-side path for the PROJECT-keyed Forge Cloud catalog. Shared by the list
301025
301279
  * proxy, the SSE poll-and-emit proxy, and the register/unregister proxies so the
@@ -301029,8 +301283,9 @@ const CMMD_CLOUD_PROJECTS_PATH = "/api/forge/context/cloud-projects";
301029
301283
  const CMMD_RUNTIMES_PATH = "/api/forge/context/runtimes";
301030
301284
  /**
301031
301285
  * Authenticate the browser session and resolve the CMMD JWT to forward
301032
- * upstream. Returns null when no token could be resolved, which every caller
301033
- * turns into a CMMD_AUTH_REQUIRED response.
301286
+ * upstream. `jwt` is null when none could be resolved, which every caller
301287
+ * turns into `respondCmmdConnectionRequired(session.sessionId)` — the same
301288
+ * unified `CMMD_AUTH_REQUIRED` body and auth-clear the registry uses.
301034
301289
  *
301035
301290
  * Shared so the auth preamble is written once rather than once per proxy route.
301036
301291
  */
@@ -301038,11 +301293,14 @@ function makeCmmdProxyAccessTokenEffect(logPrefix) {
301038
301293
  return require_Schema$1.gen(function* () {
301039
301294
  const request = yield* require_HttpServer.HttpServerRequest;
301040
301295
  const session = yield* (yield* ServerAuth).authenticateHttpRequest(request);
301041
- return yield* resolveCmmdJwtForSession({
301042
- sessionId: session.sessionId,
301043
- subject: session.subject,
301044
- logPrefix
301045
- });
301296
+ return {
301297
+ session,
301298
+ jwt: yield* resolveCmmdJwtForSession({
301299
+ sessionId: session.sessionId,
301300
+ subject: session.subject,
301301
+ logPrefix
301302
+ })
301303
+ };
301046
301304
  });
301047
301305
  }
301048
301306
  var WorkIntakeSnapshotReadError = class extends require_Schema$1.TaggedErrorClass()("WorkIntakeSnapshotReadError", {
@@ -301122,32 +301380,19 @@ const cmmdProfileRouteLayer = add$1("GET", "/api/cmmd/profile", require_Schema$1
301122
301380
  * `resolution`/`sinceTime`/`untilTime` when the page is drawing hours, which is
301123
301381
  * what lets CMMD cut hour buckets rather than only days.
301124
301382
  */
301125
- const cmmdUsageSummaryRouteLayer = registerProxyRoute({
301383
+ registerProxyRoute({
301126
301384
  forgePath: "/api/cmmd/usage/summary",
301127
301385
  method: "GET",
301128
301386
  cmmdPath: "/api/forge/context/usage/summary",
301129
301387
  orgIdSource: "none"
301130
301388
  });
301131
- /**
301132
- * The workspace's CMMD plan: entitlements, the current period, and how much of
301133
- * each metered allowance is left. This is subscription consumption, which is a
301134
- * different question from the API-equivalent estimate the usage summary above
301135
- * computes from transcripts.
301136
- *
301137
- * `orgIdSource` is `query` (FOR-36406): a plan belongs to an organization, and
301138
- * without one CMMD answers for the user's default organization, which is their
301139
- * personal space rather than the workspace their Environment runs in. The web
301140
- * passes the Environment's organization as `?orgId=` and the registry turns it
301141
- * into `X-Organization-ID`; without it CMMD still answers, for the default.
301142
- */
301143
- const cmmdBillingRouteLayer = registerProxyRoute({
301389
+ registerProxyRoute({
301144
301390
  forgePath: "/api/cmmd/billing",
301145
301391
  method: "GET",
301146
301392
  cmmdPath: "/api/forge/context/billing",
301147
301393
  orgIdSource: "query"
301148
301394
  });
301149
- /** Per-day consumption across that period, so the remaining figure gets a shape. */
301150
- const cmmdBillingSeriesRouteLayer = registerProxyRoute({
301395
+ registerProxyRoute({
301151
301396
  forgePath: "/api/cmmd/billing/series",
301152
301397
  method: "GET",
301153
301398
  cmmdPath: "/api/forge/context/billing/series",
@@ -301185,6 +301430,15 @@ function runCmmdRestProxy(session, proxy, dependencies = {}) {
301185
301430
  });
301186
301431
  }
301187
301432
  /**
301433
+ * Adapts `runCmmdRestProxy`'s `{ ok, value | error }` outcome into a
301434
+ * `ProxyHandlerRoute.run` result: the shared shape every converted handler's
301435
+ * `run` uses so it stays the three or so lines of the actual gateway call
301436
+ * plus response shaping, with resolve-and-retry left to `runCmmdRestProxy`.
301437
+ */
301438
+ function runCmmdRestProxyAsHandlerResult(session, proxy, shape) {
301439
+ return runCmmdRestProxy(session, proxy).pipe(require_Schema$1.flatMap((outcome) => outcome.ok ? require_Schema$1.succeed(shape(outcome.value)) : require_Schema$1.fail(outcome.error)));
301440
+ }
301441
+ /**
301188
301442
  * Forge-context REST responses wrap their payload in `{ data, meta, pagination? }`
301189
301443
  * (see CMMD `sendForgeEnvelope`). Unwrap to the bare payload so handler response
301190
301444
  * shapes match what the web client expected from the prior MCP text path.
@@ -301349,22 +301603,34 @@ function buildCreateBrainDocumentInput(payload) {
301349
301603
  ...payload.tags && payload.tags.length > 0 ? { tags: payload.tags } : {}
301350
301604
  };
301351
301605
  }
301352
- const cmmdCreateBrainDocRouteLayer = add$1("POST", "/api/cmmd/brain-docs", require_Schema$1.gen(function* () {
301353
- const request = yield* require_HttpServer.HttpServerRequest;
301354
- const session = yield* (yield* ServerAuth).authenticateHttpRequest(request);
301355
- if (!readCommandAccessTokenForSession(session.sessionId)) return require_HttpServer.jsonUnsafe({ error: "CMMD account not connected. Log in via the connections panel." }, { status: 401 });
301356
- const payload = parseBrainDocPayload(yield* request.json);
301357
- if (!payload) return require_HttpServer.jsonUnsafe({ error: "Invalid request: title (1-500 chars) and content (1-100k chars) are required." }, { status: 400 });
301358
- const restOutcome = yield* runCmmdRestProxy(session, (jwt) => cmmdGateway.createBrainDocument({
301606
+ function parseCreateBrainDocRequest(request) {
301607
+ return request.json.pipe(require_Schema$1.orElseSucceed(() => null), require_Schema$1.map((rawBody) => {
301608
+ const payload = parseBrainDocPayload(rawBody);
301609
+ return payload ? {
301610
+ ok: true,
301611
+ value: payload
301612
+ } : {
301613
+ ok: false,
301614
+ status: 400,
301615
+ body: { error: "Invalid request: title (1-500 chars) and content (1-100k chars) are required." }
301616
+ };
301617
+ }));
301618
+ }
301619
+ registerProxyHandler({
301620
+ forgePath: "/api/cmmd/brain-docs",
301621
+ method: "POST",
301622
+ parse: parseCreateBrainDocRequest,
301623
+ run: (payload, { session }) => runCmmdRestProxyAsHandlerResult(session, (jwt) => cmmdGateway.createBrainDocument({
301359
301624
  jwt,
301360
301625
  document: buildCreateBrainDocumentInput(payload)
301361
- }));
301362
- if (restOutcome.ok) return require_HttpServer.jsonUnsafe({
301363
- success: true,
301364
- doc: unwrapForgeEnvelope(restOutcome.value)
301365
- }, { status: 201 });
301366
- return buildProxyErrorResponse(restOutcome.error);
301367
- }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error))));
301626
+ }), (value) => ({
301627
+ status: 201,
301628
+ body: {
301629
+ success: true,
301630
+ doc: unwrapForgeEnvelope(value)
301631
+ }
301632
+ }))
301633
+ });
301368
301634
  function normalizeOptionalNullableString(value, options) {
301369
301635
  if (value === void 0) return void 0;
301370
301636
  if (value === null) return null;
@@ -301418,46 +301684,77 @@ function buildUpdateTaskToolInput(payload) {
301418
301684
  ...payload.labels !== void 0 ? { tags: payload.labels } : {}
301419
301685
  };
301420
301686
  }
301421
- const updateCmmdTaskHandler = require_Schema$1.gen(function* () {
301422
- const request = yield* require_HttpServer.HttpServerRequest;
301423
- const session = yield* (yield* ServerAuth).authenticateHttpRequest(request);
301424
- if (!readCommandAccessTokenForSession(session.sessionId)) return require_HttpServer.jsonUnsafe({ error: "CMMD account not connected. Log in via the connections panel." }, { status: 401 });
301425
- const payload = parseUpdateTaskPayload(yield* request.json);
301426
- if (!payload) return require_HttpServer.jsonUnsafe({ error: "Invalid request: taskId is required and at least one update field must be provided." }, { status: 400 });
301687
+ function parseUpdateCmmdTaskRequest(request) {
301688
+ return request.json.pipe(require_Schema$1.orElseSucceed(() => null), require_Schema$1.map((rawBody) => {
301689
+ const payload = parseUpdateTaskPayload(rawBody);
301690
+ return payload ? {
301691
+ ok: true,
301692
+ value: payload
301693
+ } : {
301694
+ ok: false,
301695
+ status: 400,
301696
+ body: { error: "Invalid request: taskId is required and at least one update field must be provided." }
301697
+ };
301698
+ }));
301699
+ }
301700
+ function runUpdateCmmdTask(payload, { session }) {
301427
301701
  const { taskId, ...patch } = buildUpdateTaskToolInput(payload);
301428
- const restOutcome = yield* runCmmdRestProxy(session, (jwt) => cmmdGateway.updateTask({
301702
+ return runCmmdRestProxyAsHandlerResult(session, (jwt) => cmmdGateway.updateTask({
301429
301703
  jwt,
301430
301704
  taskId: String(taskId),
301431
301705
  patch
301432
- }));
301433
- if (restOutcome.ok) {
301706
+ }), (value) => {
301434
301707
  invalidateCachedCmmdWorkIntakeForSession(session.sessionId);
301435
- return require_HttpServer.jsonUnsafe({
301436
- success: true,
301437
- details: unwrapForgeEnvelope(restOutcome.value)
301438
- }, { status: 200 });
301439
- }
301440
- return buildProxyErrorResponse(restOutcome.error);
301441
- }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error)));
301442
- const cmmdUpdateTaskRouteLayer = add$1("POST", "/api/cmmd/tasks/update", updateCmmdTaskHandler);
301443
- const commandUpdateTaskRouteLayer = add$1("POST", "/api/command/tasks/update", updateCmmdTaskHandler);
301444
- const cmmdAddTaskCommentRouteLayer = add$1("POST", "/api/cmmd/tasks/comment", require_Schema$1.gen(function* () {
301445
- const request = yield* require_HttpServer.HttpServerRequest;
301446
- const session = yield* (yield* ServerAuth).authenticateHttpRequest(request);
301447
- const payload = parseTaskCommentPayload(yield* request.json);
301448
- if (!payload) return require_HttpServer.jsonUnsafe({ error: "taskId and content (max 2000 chars) are required." }, { status: 400 });
301449
- if (!readCommandAccessTokenForSession(session.sessionId)) return require_HttpServer.jsonUnsafe({ error: "CMMD account not connected. Log in via the connections panel." }, { status: 401 });
301450
- const restOutcome = yield* runCmmdRestProxy(session, (jwt) => cmmdGateway.addTaskComment({
301708
+ return {
301709
+ status: 200,
301710
+ body: {
301711
+ success: true,
301712
+ details: unwrapForgeEnvelope(value)
301713
+ }
301714
+ };
301715
+ });
301716
+ }
301717
+ registerProxyHandler({
301718
+ forgePath: "/api/cmmd/tasks/update",
301719
+ method: "POST",
301720
+ parse: parseUpdateCmmdTaskRequest,
301721
+ run: runUpdateCmmdTask
301722
+ });
301723
+ registerProxyHandler({
301724
+ forgePath: "/api/command/tasks/update",
301725
+ method: "POST",
301726
+ parse: parseUpdateCmmdTaskRequest,
301727
+ run: runUpdateCmmdTask
301728
+ });
301729
+ function parseAddCmmdTaskCommentRequest(request) {
301730
+ return request.json.pipe(require_Schema$1.orElseSucceed(() => null), require_Schema$1.map((rawBody) => {
301731
+ const payload = parseTaskCommentPayload(rawBody);
301732
+ return payload ? {
301733
+ ok: true,
301734
+ value: payload
301735
+ } : {
301736
+ ok: false,
301737
+ status: 400,
301738
+ body: { error: "taskId and content (max 2000 chars) are required." }
301739
+ };
301740
+ }));
301741
+ }
301742
+ registerProxyHandler({
301743
+ forgePath: "/api/cmmd/tasks/comment",
301744
+ method: "POST",
301745
+ parse: parseAddCmmdTaskCommentRequest,
301746
+ run: (payload, { session }) => runCmmdRestProxyAsHandlerResult(session, (jwt) => cmmdGateway.addTaskComment({
301451
301747
  jwt,
301452
301748
  taskId: payload.taskId,
301453
301749
  content: payload.content
301454
- }));
301455
- if (restOutcome.ok) return require_HttpServer.jsonUnsafe({
301456
- success: true,
301457
- details: unwrapForgeEnvelope(restOutcome.value)
301458
- }, { status: 201 });
301459
- return buildProxyErrorResponse(restOutcome.error);
301460
- }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error))));
301750
+ }), (value) => ({
301751
+ status: 201,
301752
+ body: {
301753
+ success: true,
301754
+ details: unwrapForgeEnvelope(value)
301755
+ }
301756
+ }))
301757
+ });
301461
301758
  function parseTaskCommentPayload(body) {
301462
301759
  if (typeof body !== "object" || body === null) return null;
301463
301760
  const b = body;
@@ -301486,24 +301783,38 @@ function normalizeTaskSearchParams(url) {
301486
301783
  limit: Math.min(Number(url.searchParams.get("limit") ?? "20"), 50)
301487
301784
  };
301488
301785
  }
301489
- const cmmdSearchTasksRouteLayer = add$1("GET", "/api/cmmd/tasks/search", require_Schema$1.gen(function* () {
301490
- const request = yield* require_HttpServer.HttpServerRequest;
301491
- const accessToken = readCommandAccessTokenForSession((yield* (yield* ServerAuth).authenticateHttpRequest(request)).sessionId);
301492
- if (!accessToken) return require_HttpServer.jsonUnsafe({ error: "CMMD account not connected. Log in via the connections panel." }, { status: 401 });
301493
- const search = normalizeTaskSearchParams(new URL(request.url, "http://localhost"));
301494
- if (!search) return require_HttpServer.jsonUnsafe({
301495
- tasks: [],
301496
- total: 0
301497
- }, { status: 200 });
301498
- const parsed = parseJsonObjectText(extractMcpToolText(yield* require_Schema$1.promise(() => callCmmdTool(accessToken, "search_tasks", {
301786
+ function parseSearchCmmdTasksRequest(request) {
301787
+ return require_Schema$1.sync(() => ({
301788
+ ok: true,
301789
+ value: normalizeTaskSearchParams(new URL(request.url, "http://localhost"))
301790
+ }));
301791
+ }
301792
+ function runSearchCmmdTasks(search, { session }) {
301793
+ if (!search) return require_Schema$1.succeed({
301794
+ status: 200,
301795
+ body: {
301796
+ tasks: [],
301797
+ total: 0
301798
+ }
301799
+ });
301800
+ const accessToken = readCommandAccessTokenForSession(session.sessionId) ?? "";
301801
+ return require_Schema$1.promise(() => callCmmdTool(accessToken, "search_tasks", {
301499
301802
  query: search.query,
301500
301803
  limit: search.limit
301501
- }))));
301502
- return require_HttpServer.jsonUnsafe(parsed ?? {
301503
- tasks: [],
301504
- total: 0
301505
- }, { status: 200 });
301506
- }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error))));
301804
+ })).pipe(require_Schema$1.map((result) => ({
301805
+ status: 200,
301806
+ body: parseJsonObjectText(extractMcpToolText(result)) ?? {
301807
+ tasks: [],
301808
+ total: 0
301809
+ }
301810
+ })));
301811
+ }
301812
+ registerProxyHandler({
301813
+ forgePath: "/api/cmmd/tasks/search",
301814
+ method: "GET",
301815
+ parse: parseSearchCmmdTasksRequest,
301816
+ run: runSearchCmmdTasks
301817
+ });
301507
301818
  function parseJsonObjectText(text) {
301508
301819
  if (!text) return null;
301509
301820
  try {
@@ -301517,23 +301828,47 @@ function parsePositiveIntegerId(value) {
301517
301828
  const numericId = Number(value);
301518
301829
  return Number.isInteger(numericId) && numericId > 0 ? numericId : null;
301519
301830
  }
301520
- const cmmdGetTaskRouteLayer = add$1("GET", "/api/cmmd/tasks/:id", require_Schema$1.gen(function* () {
301521
- const request = yield* require_HttpServer.HttpServerRequest;
301522
- const session = yield* (yield* ServerAuth).authenticateHttpRequest(request);
301523
- if (!readCommandAccessTokenForSession(session.sessionId)) return require_HttpServer.jsonUnsafe({ error: "CMMD account not connected. Log in via the connections panel." }, { status: 401 });
301524
- const taskId = extractIdFromPath(new URL(request.url, "http://localhost").pathname, 1);
301525
- if (!taskId) return require_HttpServer.jsonUnsafe({ error: "Task ID is required." }, { status: 400 });
301526
- const numericId = parsePositiveIntegerId(taskId);
301527
- if (!numericId) return require_HttpServer.jsonUnsafe({ error: "Invalid task ID." }, { status: 400 });
301528
- const restOutcome = yield* runCmmdRestProxy(session, (jwt) => cmmdGateway.getTask({
301831
+ function parseGetCmmdTaskRequest(request) {
301832
+ return require_Schema$1.sync(() => {
301833
+ const taskId = extractIdFromPath(new URL(request.url, "http://localhost").pathname, 1);
301834
+ if (!taskId) return {
301835
+ ok: false,
301836
+ status: 400,
301837
+ body: { error: "Task ID is required." }
301838
+ };
301839
+ const numericId = parsePositiveIntegerId(taskId);
301840
+ if (!numericId) return {
301841
+ ok: false,
301842
+ status: 400,
301843
+ body: { error: "Invalid task ID." }
301844
+ };
301845
+ return {
301846
+ ok: true,
301847
+ value: numericId
301848
+ };
301849
+ });
301850
+ }
301851
+ function runGetCmmdTask(numericId, { session }) {
301852
+ return runCmmdRestProxyAsHandlerResult(session, (jwt) => cmmdGateway.getTask({
301529
301853
  jwt,
301530
301854
  taskId: String(numericId)
301531
- }));
301532
- if (!restOutcome.ok) return buildProxyErrorResponse(restOutcome.error);
301533
- const task = unwrapForgeEnvelope(restOutcome.value);
301534
- if (task === null || task === void 0) return require_HttpServer.jsonUnsafe({ error: "Task not found." }, { status: 404 });
301535
- return require_HttpServer.jsonUnsafe(task, { status: 200 });
301536
- }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error))));
301855
+ }), (value) => {
301856
+ const task = unwrapForgeEnvelope(value);
301857
+ return task === null || task === void 0 ? {
301858
+ status: 404,
301859
+ body: { error: "Task not found." }
301860
+ } : {
301861
+ status: 200,
301862
+ body: task
301863
+ };
301864
+ });
301865
+ }
301866
+ registerProxyHandler({
301867
+ forgePath: "/api/cmmd/tasks/:id",
301868
+ method: "GET",
301869
+ parse: parseGetCmmdTaskRequest,
301870
+ run: runGetCmmdTask
301871
+ });
301537
301872
  function extractIdFromPath(pathname, fromEnd) {
301538
301873
  const parts = pathname.split("/").filter(Boolean);
301539
301874
  return parts[parts.length - fromEnd];
@@ -301545,23 +301880,37 @@ function decodePathSegment(segment) {
301545
301880
  return null;
301546
301881
  }
301547
301882
  }
301548
- const cmmdGetTaskCommentsRouteLayer = add$1("GET", "/api/cmmd/tasks/:id/comments", require_Schema$1.gen(function* () {
301549
- const request = yield* require_HttpServer.HttpServerRequest;
301550
- const session = yield* (yield* ServerAuth).authenticateHttpRequest(request);
301551
- const taskId = extractIdFromPath(new URL(request.url, "http://localhost").pathname, 2);
301552
- if (!taskId) return require_HttpServer.jsonUnsafe({ error: "Task ID is required." }, { status: 400 });
301553
- if (!readCommandAccessTokenForSession(session.sessionId)) return require_HttpServer.jsonUnsafe({ error: "CMMD account not connected. Log in via the connections panel." }, { status: 401 });
301554
- const restOutcome = yield* runCmmdRestProxy(session, (jwt) => cmmdGateway.listTaskComments({
301883
+ function parseGetCmmdTaskCommentsRequest(request) {
301884
+ return require_Schema$1.sync(() => {
301885
+ const taskId = extractIdFromPath(new URL(request.url, "http://localhost").pathname, 2);
301886
+ return taskId ? {
301887
+ ok: true,
301888
+ value: taskId
301889
+ } : {
301890
+ ok: false,
301891
+ status: 400,
301892
+ body: { error: "Task ID is required." }
301893
+ };
301894
+ });
301895
+ }
301896
+ function runGetCmmdTaskComments(taskId, { session }) {
301897
+ return runCmmdRestProxyAsHandlerResult(session, (jwt) => cmmdGateway.listTaskComments({
301555
301898
  jwt,
301556
301899
  taskId
301557
- }));
301558
- if (restOutcome.ok) {
301559
- const data = unwrapForgeEnvelope(restOutcome.value);
301560
- const comments = Array.isArray(data) ? data : [];
301561
- return require_HttpServer.jsonUnsafe({ comments }, { status: 200 });
301562
- }
301563
- return buildProxyErrorResponse(restOutcome.error);
301564
- }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error))));
301900
+ }), (value) => {
301901
+ const data = unwrapForgeEnvelope(value);
301902
+ return {
301903
+ status: 200,
301904
+ body: { comments: Array.isArray(data) ? data : [] }
301905
+ };
301906
+ });
301907
+ }
301908
+ registerProxyHandler({
301909
+ forgePath: "/api/cmmd/tasks/:id/comments",
301910
+ method: "GET",
301911
+ parse: parseGetCmmdTaskCommentsRequest,
301912
+ run: runGetCmmdTaskComments
301913
+ });
301565
301914
  function normalizeCommentList(value) {
301566
301915
  if (Array.isArray(value)) return value;
301567
301916
  if (!value || typeof value !== "object") return [];
@@ -301667,55 +302016,54 @@ const cmmdUpdateProjectRouteLayer = add$1("PATCH", "/api/cmmd/projects/:id", req
301667
302016
  project: outcome.value
301668
302017
  }, { status: 200 });
301669
302018
  }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error))));
301670
- const cmmdGetProjectRepositoryRouteLayer = registerProxyRoute({
302019
+ registerProxyRoute({
301671
302020
  forgePath: "/api/cmmd/projects/:id/repository",
301672
302021
  method: "GET",
301673
302022
  cmmdPath: "/api/forge/context/projects/:id/repository",
301674
302023
  orgIdSource: "none",
301675
302024
  responseShape: "unwrapData"
301676
302025
  });
301677
- /** Canonical repository identity; unlike the singular route above, this is not execution-link state. */
301678
- const cmmdListProjectRepositoriesRouteLayer = registerProxyRoute({
302026
+ registerProxyRoute({
301679
302027
  forgePath: "/api/cmmd/projects/:projectId/repositories",
301680
302028
  method: "GET",
301681
302029
  cmmdPath: "/api/forge/context/projects/:projectId/repositories",
301682
302030
  orgIdSource: "none",
301683
302031
  responseShape: "unwrapData"
301684
302032
  });
301685
- const cmmdGetOrgMembersRouteLayer = registerProxyRoute({
302033
+ registerProxyRoute({
301686
302034
  forgePath: "/api/cmmd/organizations/:id/members",
301687
302035
  method: "GET",
301688
302036
  cmmdPath: "/api/organizations/:id/members",
301689
302037
  orgIdSource: "none",
301690
302038
  responseShape: "unwrapData"
301691
302039
  });
301692
- const cmmdSimHostsRouteLayer = registerProxyRoute({
302040
+ registerProxyRoute({
301693
302041
  forgePath: "/api/cmmd/sim-host/hosts",
301694
302042
  method: "GET",
301695
302043
  cmmdPath: "/api/forge/context/sim-host/hosts",
301696
302044
  responseShape: "unwrapData"
301697
302045
  });
301698
- const cmmdSimLeaseReadRouteLayer = registerProxyRoute({
302046
+ registerProxyRoute({
301699
302047
  forgePath: "/api/cmmd/sim-host/leases",
301700
302048
  method: "GET",
301701
302049
  cmmdPath: "/api/forge/context/sim-host/leases",
301702
302050
  responseShape: "unwrapData"
301703
302051
  });
301704
- const cmmdSimLeaseClaimRouteLayer = registerProxyRoute({
302052
+ registerProxyRoute({
301705
302053
  forgePath: "/api/cmmd/sim-host/leases",
301706
302054
  method: "POST",
301707
302055
  cmmdPath: "/api/forge/context/sim-host/leases",
301708
302056
  responseShape: "unwrapData",
301709
302057
  successStatus: 200
301710
302058
  });
301711
- const cmmdSimLeaseReleaseRouteLayer = registerProxyRoute({
302059
+ registerProxyRoute({
301712
302060
  forgePath: "/api/cmmd/sim-host/leases/:leaseId/release",
301713
302061
  method: "POST",
301714
302062
  cmmdPath: "/api/forge/context/sim-host/leases/:leaseId/release",
301715
302063
  responseShape: "unwrapData",
301716
302064
  successStatus: 200
301717
302065
  });
301718
- const cmmdSimLeaseRenewRouteLayer = registerProxyRoute({
302066
+ registerProxyRoute({
301719
302067
  forgePath: "/api/cmmd/sim-host/leases/:leaseId/renew",
301720
302068
  method: "POST",
301721
302069
  cmmdPath: "/api/forge/context/sim-host/leases/:leaseId/renew",
@@ -301739,7 +302087,7 @@ function getMultipartContentType(headers) {
301739
302087
  const contentType = headers["content-type"] ?? "";
301740
302088
  return contentType.includes("multipart/form-data") ? contentType : null;
301741
302089
  }
301742
- const cmmdGetTaskAttachmentsRouteLayer = registerProxyRoute({
302090
+ registerProxyRoute({
301743
302091
  forgePath: "/api/cmmd/tasks/:id/attachments",
301744
302092
  method: "GET",
301745
302093
  cmmdPath: "/api/forge/context/tasks/:id/attachments",
@@ -301774,150 +302122,150 @@ const cmmdUpdateTaskCommentRouteLayer = add$1("PATCH", "/api/cmmd/tasks/:taskId/
301774
302122
  ...outcome.value
301775
302123
  }, { status: 200 });
301776
302124
  }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error))));
301777
- const cmmdDeleteTaskCommentRouteLayer = registerProxyRoute({
302125
+ registerProxyRoute({
301778
302126
  forgePath: "/api/cmmd/tasks/:taskId/comments/:commentId",
301779
302127
  method: "DELETE",
301780
302128
  cmmdPath: "/api/forge/context/tasks/:taskId/comments/:commentId",
301781
302129
  orgIdSource: "none",
301782
302130
  requestBody: "json"
301783
302131
  });
301784
- const cmmdListProjectAgentMembersRouteLayer = registerProxyRoute({
302132
+ registerProxyRoute({
301785
302133
  forgePath: "/api/cmmd/projects/:projectId/agent-members",
301786
302134
  method: "GET",
301787
302135
  cmmdPath: "/api/forge/context/projects/:projectId/agent-members",
301788
302136
  orgIdSource: "none",
301789
302137
  responseShape: "unwrapData"
301790
302138
  });
301791
- const cmmdCreateProjectAgentMemberRouteLayer = registerProxyRoute({
302139
+ registerProxyRoute({
301792
302140
  forgePath: "/api/cmmd/projects/:projectId/agent-members",
301793
302141
  method: "POST",
301794
302142
  cmmdPath: "/api/forge/context/projects/:projectId/agent-members",
301795
302143
  orgIdSource: "none",
301796
302144
  responseShape: "unwrapData"
301797
302145
  });
301798
- const cmmdGetProjectAgentMemberRouteLayer = registerProxyRoute({
302146
+ registerProxyRoute({
301799
302147
  forgePath: "/api/cmmd/projects/:projectId/agent-members/:memberId",
301800
302148
  method: "GET",
301801
302149
  cmmdPath: "/api/forge/context/projects/:projectId/agent-members/:memberId",
301802
302150
  orgIdSource: "none",
301803
302151
  responseShape: "unwrapData"
301804
302152
  });
301805
- const cmmdRenameProjectAgentMemberRouteLayer = registerProxyRoute({
302153
+ registerProxyRoute({
301806
302154
  forgePath: "/api/cmmd/projects/:projectId/agent-members/:memberId",
301807
302155
  method: "PATCH",
301808
302156
  cmmdPath: "/api/forge/context/projects/:projectId/agent-members/:memberId",
301809
302157
  orgIdSource: "none",
301810
302158
  responseShape: "unwrapData"
301811
302159
  });
301812
- const cmmdRetireProjectAgentMemberRouteLayer = registerProxyRoute({
302160
+ registerProxyRoute({
301813
302161
  forgePath: "/api/cmmd/projects/:projectId/agent-members/:memberId/retire",
301814
302162
  method: "POST",
301815
302163
  cmmdPath: "/api/forge/context/projects/:projectId/agent-members/:memberId/retire",
301816
302164
  orgIdSource: "none",
301817
302165
  responseShape: "unwrapData"
301818
302166
  });
301819
- const cmmdListProjectAgentMemberInstancesRouteLayer = registerProxyRoute({
302167
+ registerProxyRoute({
301820
302168
  forgePath: "/api/cmmd/projects/:projectId/agent-members/:memberId/instances",
301821
302169
  method: "GET",
301822
302170
  cmmdPath: "/api/forge/context/projects/:projectId/agent-members/:memberId/instances",
301823
302171
  orgIdSource: "none",
301824
302172
  responseShape: "unwrapData"
301825
302173
  });
301826
- const cmmdPreviewProjectAgentMemberConsolidationRouteLayer = registerProxyRoute({
302174
+ registerProxyRoute({
301827
302175
  forgePath: "/api/cmmd/projects/:projectId/agent-members/consolidation/preview",
301828
302176
  method: "POST",
301829
302177
  cmmdPath: "/api/forge/context/projects/:projectId/agent-members/consolidation/preview",
301830
302178
  orgIdSource: "none",
301831
302179
  responseShape: "unwrapData"
301832
302180
  });
301833
- const cmmdApplyProjectAgentMemberConsolidationRouteLayer = registerProxyRoute({
302181
+ registerProxyRoute({
301834
302182
  forgePath: "/api/cmmd/projects/:projectId/agent-members/consolidation/apply",
301835
302183
  method: "POST",
301836
302184
  cmmdPath: "/api/forge/context/projects/:projectId/agent-members/consolidation/apply",
301837
302185
  orgIdSource: "none",
301838
302186
  responseShape: "unwrapData"
301839
302187
  });
301840
- const cmmdPutProjectTaskAssignmentRouteLayer = registerProxyRoute({
302188
+ registerProxyRoute({
301841
302189
  forgePath: "/api/cmmd/projects/:projectId/tasks/:taskId/assignment",
301842
302190
  method: "PUT",
301843
302191
  cmmdPath: "/api/forge/context/projects/:projectId/tasks/:taskId/assignment",
301844
302192
  orgIdSource: "none",
301845
302193
  responseShape: "unwrapData"
301846
302194
  });
301847
- const cmmdListTasksRouteLayer = registerProxyRoute({
302195
+ registerProxyRoute({
301848
302196
  forgePath: "/api/cmmd/tasks",
301849
302197
  method: "GET",
301850
302198
  cmmdPath: "/api/forge/context/tasks"
301851
302199
  });
301852
- const cmmdCreateTaskRouteLayer = registerProxyRoute({
302200
+ registerProxyRoute({
301853
302201
  forgePath: "/api/cmmd/tasks",
301854
302202
  method: "POST",
301855
302203
  cmmdPath: "/api/forge/context/tasks"
301856
302204
  });
301857
- const cmmdArchiveTaskRouteLayer = registerProxyRoute({
302205
+ registerProxyRoute({
301858
302206
  forgePath: "/api/cmmd/tasks/:id/archive",
301859
302207
  method: "POST",
301860
302208
  cmmdPath: "/api/forge/context/tasks/:id/archive",
301861
302209
  orgIdSource: "none"
301862
302210
  });
301863
- const cmmdUnarchiveTaskRouteLayer = registerProxyRoute({
302211
+ registerProxyRoute({
301864
302212
  forgePath: "/api/cmmd/tasks/:id/unarchive",
301865
302213
  method: "POST",
301866
302214
  cmmdPath: "/api/forge/context/tasks/:id/unarchive",
301867
302215
  orgIdSource: "none"
301868
302216
  });
301869
- const cmmdListSavedViewsRouteLayer = registerProxyRoute({
302217
+ registerProxyRoute({
301870
302218
  forgePath: "/api/cmmd/saved-views",
301871
302219
  method: "GET",
301872
302220
  cmmdPath: "/api/forge/context/saved-views",
301873
302221
  orgIdSource: "none"
301874
302222
  });
301875
- const cmmdCreateSavedViewRouteLayer = registerProxyRoute({
302223
+ registerProxyRoute({
301876
302224
  forgePath: "/api/cmmd/saved-views",
301877
302225
  method: "POST",
301878
302226
  cmmdPath: "/api/forge/context/saved-views",
301879
302227
  orgIdSource: "none",
301880
302228
  successStatus: 201
301881
302229
  });
301882
- const cmmdImportSavedViewRouteLayer = registerProxyRoute({
302230
+ registerProxyRoute({
301883
302231
  forgePath: "/api/cmmd/saved-views/import",
301884
302232
  method: "POST",
301885
302233
  cmmdPath: "/api/forge/context/saved-views/import",
301886
302234
  orgIdSource: "none"
301887
302235
  });
301888
- const cmmdUpdateSavedViewRouteLayer = registerProxyRoute({
302236
+ registerProxyRoute({
301889
302237
  forgePath: "/api/cmmd/saved-views/:viewId",
301890
302238
  method: "PATCH",
301891
302239
  cmmdPath: "/api/forge/context/saved-views/:viewId",
301892
302240
  orgIdSource: "none"
301893
302241
  });
301894
- const cmmdDeleteSavedViewRouteLayer = registerProxyRoute({
302242
+ registerProxyRoute({
301895
302243
  forgePath: "/api/cmmd/saved-views/:viewId",
301896
302244
  method: "DELETE",
301897
302245
  cmmdPath: "/api/forge/context/saved-views/:viewId",
301898
302246
  orgIdSource: "none",
301899
302247
  forwardSearchParams: true
301900
302248
  });
301901
- const cmmdListProjectsRouteLayer = registerProxyRoute({
302249
+ registerProxyRoute({
301902
302250
  forgePath: "/api/cmmd/projects",
301903
302251
  method: "GET",
301904
302252
  cmmdPath: "/api/forge/context/projects",
301905
302253
  responseShape: "passthrough"
301906
302254
  });
301907
- const cmmdGetProjectRouteLayer = registerProxyRoute({
302255
+ registerProxyRoute({
301908
302256
  forgePath: "/api/cmmd/projects/:id",
301909
302257
  method: "GET",
301910
302258
  cmmdPath: "/api/forge/context/projects/:id",
301911
302259
  orgIdSource: "none",
301912
302260
  responseShape: "passthrough"
301913
302261
  });
301914
- const cmmdCreateProjectRouteLayer = registerProxyRoute({
302262
+ registerProxyRoute({
301915
302263
  forgePath: "/api/cmmd/projects",
301916
302264
  method: "POST",
301917
302265
  cmmdPath: "/api/projects",
301918
302266
  responseShape: "passthrough"
301919
302267
  });
301920
- const cmmdDeleteProjectRouteLayer = registerProxyRoute({
302268
+ registerProxyRoute({
301921
302269
  forgePath: "/api/cmmd/projects/:id",
301922
302270
  method: "DELETE",
301923
302271
  cmmdPath: "/api/forge/context/projects/:id",
@@ -301925,78 +302273,78 @@ const cmmdDeleteProjectRouteLayer = registerProxyRoute({
301925
302273
  fixedSearchParams: { soft: "false" },
301926
302274
  workIntakeInvalidation: "always"
301927
302275
  });
301928
- const cmmdMoveProjectRouteLayer = registerProxyRoute({
302276
+ registerProxyRoute({
301929
302277
  forgePath: "/api/cmmd/projects/:id/move",
301930
302278
  method: "POST",
301931
302279
  cmmdPath: "/api/forge/context/projects/:id/move",
301932
302280
  orgIdSource: "none",
301933
302281
  responseShape: "unwrapData"
301934
302282
  });
301935
- const cmmdGetProjectMembersRouteLayer = registerProxyRoute({
302283
+ registerProxyRoute({
301936
302284
  forgePath: "/api/cmmd/projects/:id/members",
301937
302285
  method: "GET",
301938
302286
  cmmdPath: "/api/forge/context/projects/:id/team"
301939
302287
  });
301940
- const cmmdGetProjectMilestonesRouteLayer = registerProxyRoute({
302288
+ registerProxyRoute({
301941
302289
  forgePath: "/api/cmmd/projects/:id/milestones",
301942
302290
  method: "GET",
301943
302291
  cmmdPath: "/api/forge/context/projects/:id/milestones"
301944
302292
  });
301945
- const cmmdCreateProjectMilestoneRouteLayer = registerProxyRoute({
302293
+ registerProxyRoute({
301946
302294
  forgePath: "/api/cmmd/projects/:id/milestones",
301947
302295
  method: "POST",
301948
302296
  cmmdPath: "/api/forge/context/projects/:id/milestones",
301949
302297
  orgIdSource: "none",
301950
302298
  responseShape: "unwrapData"
301951
302299
  });
301952
- const cmmdUpdateProjectMilestoneRouteLayer = registerProxyRoute({
302300
+ registerProxyRoute({
301953
302301
  forgePath: "/api/cmmd/projects/:id/milestones/:milestoneId",
301954
302302
  method: "PATCH",
301955
302303
  cmmdPath: "/api/forge/context/projects/:id/milestones/:milestoneId",
301956
302304
  orgIdSource: "none",
301957
302305
  responseShape: "unwrapData"
301958
302306
  });
301959
- const cmmdDeleteProjectMilestoneRouteLayer = registerProxyRoute({
302307
+ registerProxyRoute({
301960
302308
  forgePath: "/api/cmmd/projects/:id/milestones/:milestoneId",
301961
302309
  method: "DELETE",
301962
302310
  cmmdPath: "/api/forge/context/projects/:id/milestones/:milestoneId",
301963
302311
  orgIdSource: "none"
301964
302312
  });
301965
- const cmmdGetProjectUpdatesRouteLayer = registerProxyRoute({
302313
+ registerProxyRoute({
301966
302314
  forgePath: "/api/cmmd/projects/:id/updates",
301967
302315
  method: "GET",
301968
302316
  cmmdPath: "/api/forge/context/projects/:id/updates",
301969
302317
  orgIdSource: "none",
301970
302318
  responseShape: "passthrough"
301971
302319
  });
301972
- const cmmdCreateProjectUpdateRouteLayer = registerProxyRoute({
302320
+ registerProxyRoute({
301973
302321
  forgePath: "/api/cmmd/projects/:id/updates",
301974
302322
  method: "POST",
301975
302323
  cmmdPath: "/api/forge/context/projects/:id/updates",
301976
302324
  orgIdSource: "none",
301977
302325
  responseShape: "unwrapData"
301978
302326
  });
301979
- const cmmdUpdateProjectUpdateRouteLayer = registerProxyRoute({
302327
+ registerProxyRoute({
301980
302328
  forgePath: "/api/cmmd/projects/:id/updates/:updateId",
301981
302329
  method: "PATCH",
301982
302330
  cmmdPath: "/api/forge/context/projects/:id/updates/:updateId",
301983
302331
  orgIdSource: "none",
301984
302332
  responseShape: "unwrapData"
301985
302333
  });
301986
- const cmmdDeleteProjectUpdateRouteLayer = registerProxyRoute({
302334
+ registerProxyRoute({
301987
302335
  forgePath: "/api/cmmd/projects/:id/updates/:updateId",
301988
302336
  method: "DELETE",
301989
302337
  cmmdPath: "/api/forge/context/projects/:id/updates/:updateId",
301990
302338
  orgIdSource: "none"
301991
302339
  });
301992
- const cmmdImproveProjectContentRouteLayer = registerProxyRoute({
302340
+ registerProxyRoute({
301993
302341
  forgePath: "/api/cmmd/projects/:id/content/readability",
301994
302342
  method: "POST",
301995
302343
  cmmdPath: "/api/forge/context/projects/:id/content/readability",
301996
302344
  orgIdSource: "none",
301997
302345
  responseShape: "unwrapData"
301998
302346
  });
301999
- const cmmdCreateProjectTaskDraftRouteLayer = registerProxyRoute({
302347
+ registerProxyRoute({
302000
302348
  forgePath: "/api/cmmd/projects/:projectId/task-drafts",
302001
302349
  method: "POST",
302002
302350
  cmmdPath: "/api/forge/context/projects/:projectId/task-drafts",
@@ -302004,7 +302352,7 @@ const cmmdCreateProjectTaskDraftRouteLayer = registerProxyRoute({
302004
302352
  responseShape: "unwrapData",
302005
302353
  successStatus: 201
302006
302354
  });
302007
- const cmmdGetProjectTaskDraftRouteLayer = registerProxyRoute({
302355
+ registerProxyRoute({
302008
302356
  forgePath: "/api/cmmd/projects/:projectId/task-drafts/:draftId",
302009
302357
  method: "GET",
302010
302358
  cmmdPath: "/api/forge/context/projects/:projectId/task-drafts/:draftId",
@@ -302012,7 +302360,7 @@ const cmmdGetProjectTaskDraftRouteLayer = registerProxyRoute({
302012
302360
  responseShape: "unwrapData",
302013
302361
  successStatus: 200
302014
302362
  });
302015
- const cmmdUpdateProjectTaskDraftRouteLayer = registerProxyRoute({
302363
+ registerProxyRoute({
302016
302364
  forgePath: "/api/cmmd/projects/:projectId/task-drafts/:draftId",
302017
302365
  method: "PATCH",
302018
302366
  cmmdPath: "/api/forge/context/projects/:projectId/task-drafts/:draftId",
@@ -302020,7 +302368,7 @@ const cmmdUpdateProjectTaskDraftRouteLayer = registerProxyRoute({
302020
302368
  responseShape: "unwrapData",
302021
302369
  successStatus: 200
302022
302370
  });
302023
- const cmmdPreviewProjectTaskDraftRouteLayer = registerProxyRoute({
302371
+ registerProxyRoute({
302024
302372
  forgePath: "/api/cmmd/projects/:projectId/task-drafts/:draftId/preview",
302025
302373
  method: "POST",
302026
302374
  cmmdPath: "/api/forge/context/projects/:projectId/task-drafts/:draftId/preview",
@@ -302028,7 +302376,7 @@ const cmmdPreviewProjectTaskDraftRouteLayer = registerProxyRoute({
302028
302376
  responseShape: "unwrapData",
302029
302377
  successStatus: 200
302030
302378
  });
302031
- const cmmdCommitProjectTaskDraftRouteLayer = registerProxyRoute({
302379
+ registerProxyRoute({
302032
302380
  forgePath: "/api/cmmd/projects/:projectId/task-drafts/:draftId/commit",
302033
302381
  method: "POST",
302034
302382
  cmmdPath: "/api/forge/context/projects/:projectId/task-drafts/:draftId/commit",
@@ -302036,7 +302384,7 @@ const cmmdCommitProjectTaskDraftRouteLayer = registerProxyRoute({
302036
302384
  responseShape: "unwrapData",
302037
302385
  successStatus: 200
302038
302386
  });
302039
- const cmmdDiscardProjectTaskDraftRouteLayer = registerProxyRoute({
302387
+ registerProxyRoute({
302040
302388
  forgePath: "/api/cmmd/projects/:projectId/task-drafts/:draftId/discard",
302041
302389
  method: "POST",
302042
302390
  cmmdPath: "/api/forge/context/projects/:projectId/task-drafts/:draftId/discard",
@@ -302044,352 +302392,352 @@ const cmmdDiscardProjectTaskDraftRouteLayer = registerProxyRoute({
302044
302392
  responseShape: "unwrapData",
302045
302393
  successStatus: 200
302046
302394
  });
302047
- const cmmdGetProjectLeadPlanRouteLayer = registerProxyRoute({
302395
+ registerProxyRoute({
302048
302396
  forgePath: "/api/cmmd/projects/:projectId/project-lead/plan",
302049
302397
  method: "GET",
302050
302398
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/plan",
302051
302399
  orgIdSource: "none"
302052
302400
  });
302053
- const cmmdActivateProjectLeadAuthorityRouteLayer = registerProxyRoute({
302401
+ registerProxyRoute({
302054
302402
  forgePath: "/api/cmmd/projects/:projectId/project-lead/authority/activate",
302055
302403
  method: "POST",
302056
302404
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/authority/activate",
302057
302405
  orgIdSource: "none",
302058
302406
  responseShape: "unwrapData"
302059
302407
  });
302060
- const cmmdGetProjectLeadReadinessRouteLayer = registerProxyRoute({
302408
+ registerProxyRoute({
302061
302409
  forgePath: "/api/cmmd/projects/:projectId/project-lead/readiness",
302062
302410
  method: "GET",
302063
302411
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/readiness",
302064
302412
  orgIdSource: "none"
302065
302413
  });
302066
- const cmmdGetProjectLeadCapabilitiesRouteLayer = registerProxyRoute({
302414
+ registerProxyRoute({
302067
302415
  forgePath: "/api/cmmd/projects/:projectId/project-lead/capabilities",
302068
302416
  method: "GET",
302069
302417
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/capabilities",
302070
302418
  orgIdSource: "none"
302071
302419
  });
302072
- const cmmdGetProjectLeadSummaryRouteLayer = registerProxyRoute({
302420
+ registerProxyRoute({
302073
302421
  forgePath: "/api/cmmd/projects/:projectId/project-lead/summary",
302074
302422
  method: "GET",
302075
302423
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/summary",
302076
302424
  orgIdSource: "none"
302077
302425
  });
302078
- const cmmdGetProjectLeadDetailRouteLayer = registerProxyRoute({
302426
+ registerProxyRoute({
302079
302427
  forgePath: "/api/cmmd/projects/:projectId/project-lead/detail",
302080
302428
  method: "GET",
302081
302429
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/detail",
302082
302430
  orgIdSource: "none"
302083
302431
  });
302084
- const cmmdGetProjectLeadBriefingRouteLayer = registerProxyRoute({
302432
+ registerProxyRoute({
302085
302433
  forgePath: "/api/cmmd/projects/:projectId/project-lead/briefing",
302086
302434
  method: "GET",
302087
302435
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/briefing",
302088
302436
  orgIdSource: "none"
302089
302437
  });
302090
- const cmmdListProjectLeadEventsRouteLayer = registerProxyRoute({
302438
+ registerProxyRoute({
302091
302439
  forgePath: "/api/cmmd/projects/:projectId/project-lead/events",
302092
302440
  method: "GET",
302093
302441
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/events",
302094
302442
  orgIdSource: "none"
302095
302443
  });
302096
- const cmmdExplainProjectLeadRouteLayer = registerProxyRoute({
302444
+ registerProxyRoute({
302097
302445
  forgePath: "/api/cmmd/projects/:projectId/project-lead/explain",
302098
302446
  method: "GET",
302099
302447
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/explain",
302100
302448
  orgIdSource: "none"
302101
302449
  });
302102
- const cmmdPauseProjectLeadRouteLayer = registerProxyRoute({
302450
+ registerProxyRoute({
302103
302451
  forgePath: "/api/cmmd/projects/:projectId/project-lead/pause",
302104
302452
  method: "POST",
302105
302453
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/pause",
302106
302454
  orgIdSource: "none"
302107
302455
  });
302108
- const cmmdResumeProjectLeadRouteLayer = registerProxyRoute({
302456
+ registerProxyRoute({
302109
302457
  forgePath: "/api/cmmd/projects/:projectId/project-lead/resume",
302110
302458
  method: "POST",
302111
302459
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/resume",
302112
302460
  orgIdSource: "none"
302113
302461
  });
302114
- const cmmdReserveProjectLeadTaskRouteLayer = registerProxyRoute({
302462
+ registerProxyRoute({
302115
302463
  forgePath: "/api/cmmd/projects/:projectId/project-lead/tasks/:taskId/reservations",
302116
302464
  method: "POST",
302117
302465
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/tasks/:taskId/reservations",
302118
302466
  orgIdSource: "none"
302119
302467
  });
302120
- const cmmdReleaseProjectLeadReservationRouteLayer = registerProxyRoute({
302468
+ registerProxyRoute({
302121
302469
  forgePath: "/api/cmmd/projects/:projectId/project-lead/reservations/:reservationId/release",
302122
302470
  method: "POST",
302123
302471
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/reservations/:reservationId/release",
302124
302472
  orgIdSource: "none"
302125
302473
  });
302126
- const cmmdReconcileProjectLeadRouteLayer = registerProxyRoute({
302474
+ registerProxyRoute({
302127
302475
  forgePath: "/api/cmmd/projects/:projectId/project-lead/reconcile",
302128
302476
  method: "POST",
302129
302477
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/reconcile",
302130
302478
  orgIdSource: "none"
302131
302479
  });
302132
- const cmmdResolveProjectLeadAttentionRouteLayer = registerProxyRoute({
302480
+ registerProxyRoute({
302133
302481
  forgePath: "/api/cmmd/projects/:projectId/project-lead/attention/:attentionId/resolve",
302134
302482
  method: "POST",
302135
302483
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/attention/:attentionId/resolve",
302136
302484
  orgIdSource: "none"
302137
302485
  });
302138
- const cmmdClaimProjectLeadControllerRouteLayer = registerProxyRoute({
302486
+ registerProxyRoute({
302139
302487
  forgePath: "/api/cmmd/projects/:projectId/project-lead/controller/claim",
302140
302488
  method: "POST",
302141
302489
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/controller/claim",
302142
302490
  orgIdSource: "none"
302143
302491
  });
302144
- const cmmdRenewProjectLeadControllerClaimRouteLayer = registerProxyRoute({
302492
+ registerProxyRoute({
302145
302493
  forgePath: "/api/cmmd/projects/:projectId/project-lead/controller/claim/renew",
302146
302494
  method: "POST",
302147
302495
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/controller/claim/renew",
302148
302496
  orgIdSource: "none"
302149
302497
  });
302150
- const cmmdYieldProjectLeadControllerClaimRouteLayer = registerProxyRoute({
302498
+ registerProxyRoute({
302151
302499
  forgePath: "/api/cmmd/projects/:projectId/project-lead/controller/claim/yield",
302152
302500
  method: "POST",
302153
302501
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/controller/claim/yield",
302154
302502
  orgIdSource: "none"
302155
302503
  });
302156
- const cmmdAcknowledgeProjectLeadControllerEventRouteLayer = registerProxyRoute({
302504
+ registerProxyRoute({
302157
302505
  forgePath: "/api/cmmd/projects/:projectId/project-lead/controller/events/:eventId/acknowledge",
302158
302506
  method: "POST",
302159
302507
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/controller/events/:eventId/acknowledge",
302160
302508
  orgIdSource: "none"
302161
302509
  });
302162
- const cmmdRecordProjectLeadControllerDecisionRouteLayer = registerProxyRoute({
302510
+ registerProxyRoute({
302163
302511
  forgePath: "/api/cmmd/projects/:projectId/project-lead/controller/decisions",
302164
302512
  method: "POST",
302165
302513
  cmmdPath: "/api/forge/context/projects/:projectId/project-lead/controller/decisions",
302166
302514
  orgIdSource: "none"
302167
302515
  });
302168
- const cmmdListForgeAutomationPresetsRouteLayer = registerProxyRoute({
302516
+ registerProxyRoute({
302169
302517
  forgePath: "/api/cmmd/automations/presets",
302170
302518
  method: "GET",
302171
302519
  cmmdPath: "/api/forge/context/automations/presets",
302172
302520
  orgIdSource: "none",
302173
302521
  responseShape: "unwrapData"
302174
302522
  });
302175
- const cmmdListUserForgeAutomationRulesRouteLayer = registerProxyRoute({
302523
+ registerProxyRoute({
302176
302524
  forgePath: "/api/cmmd/automations/user/rules",
302177
302525
  method: "GET",
302178
302526
  cmmdPath: "/api/forge/context/automations/user/rules",
302179
302527
  orgIdSource: "none",
302180
302528
  responseShape: "unwrapData"
302181
302529
  });
302182
- const cmmdCreateUserForgeAutomationRuleRouteLayer = registerProxyRoute({
302530
+ registerProxyRoute({
302183
302531
  forgePath: "/api/cmmd/automations/user/rules",
302184
302532
  method: "POST",
302185
302533
  cmmdPath: "/api/forge/context/automations/user/rules",
302186
302534
  orgIdSource: "none",
302187
302535
  responseShape: "unwrapData"
302188
302536
  });
302189
- const cmmdUpdateUserForgeAutomationRuleRouteLayer = registerProxyRoute({
302537
+ registerProxyRoute({
302190
302538
  forgePath: "/api/cmmd/automations/user/rules/:ruleId",
302191
302539
  method: "PATCH",
302192
302540
  cmmdPath: "/api/forge/context/automations/user/rules/:ruleId",
302193
302541
  orgIdSource: "none",
302194
302542
  responseShape: "unwrapData"
302195
302543
  });
302196
- const cmmdListUserForgeAutomationRunsRouteLayer = registerProxyRoute({
302544
+ registerProxyRoute({
302197
302545
  forgePath: "/api/cmmd/automations/user/rules/:ruleId/runs",
302198
302546
  method: "GET",
302199
302547
  cmmdPath: "/api/forge/context/automations/user/rules/:ruleId/runs",
302200
302548
  orgIdSource: "none",
302201
302549
  responseShape: "unwrapData"
302202
302550
  });
302203
- const cmmdStartUserForgeAutomationRunRouteLayer = registerProxyRoute({
302551
+ registerProxyRoute({
302204
302552
  forgePath: "/api/cmmd/automations/user/rules/:ruleId/runs",
302205
302553
  method: "POST",
302206
302554
  cmmdPath: "/api/forge/context/automations/user/rules/:ruleId/runs",
302207
302555
  orgIdSource: "none",
302208
302556
  responseShape: "unwrapData"
302209
302557
  });
302210
- const cmmdListForgeAutomationRulesRouteLayer = registerProxyRoute({
302558
+ registerProxyRoute({
302211
302559
  forgePath: "/api/cmmd/automations/projects/:projectId/rules",
302212
302560
  method: "GET",
302213
302561
  cmmdPath: "/api/forge/context/automations/projects/:projectId/rules",
302214
302562
  orgIdSource: "query",
302215
302563
  responseShape: "unwrapData"
302216
302564
  });
302217
- const cmmdCreateForgeAutomationRuleRouteLayer = registerProxyRoute({
302565
+ registerProxyRoute({
302218
302566
  forgePath: "/api/cmmd/automations/projects/:projectId/rules",
302219
302567
  method: "POST",
302220
302568
  cmmdPath: "/api/forge/context/automations/projects/:projectId/rules",
302221
302569
  orgIdSource: "query",
302222
302570
  responseShape: "unwrapData"
302223
302571
  });
302224
- const cmmdUpdateForgeAutomationRuleRouteLayer = registerProxyRoute({
302572
+ registerProxyRoute({
302225
302573
  forgePath: "/api/cmmd/automations/projects/:projectId/rules/:ruleId",
302226
302574
  method: "PATCH",
302227
302575
  cmmdPath: "/api/forge/context/automations/projects/:projectId/rules/:ruleId",
302228
302576
  orgIdSource: "query",
302229
302577
  responseShape: "unwrapData"
302230
302578
  });
302231
- const cmmdListForgeAutomationRunsRouteLayer = registerProxyRoute({
302579
+ registerProxyRoute({
302232
302580
  forgePath: "/api/cmmd/automations/projects/:projectId/runs",
302233
302581
  method: "GET",
302234
302582
  cmmdPath: "/api/forge/context/automations/projects/:projectId/runs",
302235
302583
  orgIdSource: "query",
302236
302584
  responseShape: "unwrapData"
302237
302585
  });
302238
- const cmmdStartForgeAutomationRunRouteLayer = registerProxyRoute({
302586
+ registerProxyRoute({
302239
302587
  forgePath: "/api/cmmd/automations/projects/:projectId/tasks/:taskId/runs",
302240
302588
  method: "POST",
302241
302589
  cmmdPath: "/api/forge/context/automations/projects/:projectId/tasks/:taskId/runs",
302242
302590
  orgIdSource: "query",
302243
302591
  responseShape: "unwrapData"
302244
302592
  });
302245
- const cmmdGetForgeAutomationRunRouteLayer = registerProxyRoute({
302593
+ registerProxyRoute({
302246
302594
  forgePath: "/api/cmmd/automations/runs/:runId",
302247
302595
  method: "GET",
302248
302596
  cmmdPath: "/api/forge/context/automations/runs/:runId",
302249
302597
  orgIdSource: "query",
302250
302598
  responseShape: "unwrapData"
302251
302599
  });
302252
- const cmmdRetryForgeAutomationRunRouteLayer = registerProxyRoute({
302600
+ registerProxyRoute({
302253
302601
  forgePath: "/api/cmmd/automations/runs/:runId/retry",
302254
302602
  method: "POST",
302255
302603
  cmmdPath: "/api/forge/context/automations/runs/:runId/retry",
302256
302604
  orgIdSource: "query",
302257
302605
  responseShape: "unwrapData"
302258
302606
  });
302259
- const cmmdCancelForgeAutomationRunRouteLayer = registerProxyRoute({
302607
+ registerProxyRoute({
302260
302608
  forgePath: "/api/cmmd/automations/runs/:runId/cancel",
302261
302609
  method: "POST",
302262
302610
  cmmdPath: "/api/forge/context/automations/runs/:runId/cancel",
302263
302611
  orgIdSource: "query",
302264
302612
  responseShape: "unwrapData"
302265
302613
  });
302266
- const cmmdApproveForgeAutomationEscalationRouteLayer = registerProxyRoute({
302614
+ registerProxyRoute({
302267
302615
  forgePath: "/api/cmmd/automations/runs/:runId/escalations/approve",
302268
302616
  method: "POST",
302269
302617
  cmmdPath: "/api/forge/context/automations/runs/:runId/escalations/approve",
302270
302618
  orgIdSource: "query",
302271
302619
  responseShape: "unwrapData"
302272
302620
  });
302273
- const cmmdRejectForgeAutomationEscalationRouteLayer = registerProxyRoute({
302621
+ registerProxyRoute({
302274
302622
  forgePath: "/api/cmmd/automations/runs/:runId/escalations/reject",
302275
302623
  method: "POST",
302276
302624
  cmmdPath: "/api/forge/context/automations/runs/:runId/escalations/reject",
302277
302625
  orgIdSource: "query",
302278
302626
  responseShape: "unwrapData"
302279
302627
  });
302280
- const cmmdListProjectBoardRouteLayer = registerProxyRoute({
302628
+ registerProxyRoute({
302281
302629
  forgePath: "/api/cmmd/projects/:id/board",
302282
302630
  method: "GET",
302283
302631
  cmmdPath: "/api/forge/context/projects/:id/board",
302284
302632
  orgIdSource: "none",
302285
302633
  responseShape: "unwrapData"
302286
302634
  });
302287
- const cmmdGetProjectTaskWorkflowRouteLayer = registerProxyRoute({
302635
+ registerProxyRoute({
302288
302636
  forgePath: "/api/cmmd/projects/:id/task-workflow",
302289
302637
  method: "GET",
302290
302638
  cmmdPath: "/api/forge/context/projects/:id/task-workflow",
302291
302639
  orgIdSource: "none",
302292
302640
  responseShape: "unwrapData"
302293
302641
  });
302294
- const cmmdUpdateProjectTaskWorkflowRouteLayer = registerProxyRoute({
302642
+ registerProxyRoute({
302295
302643
  forgePath: "/api/cmmd/projects/:id/task-workflow",
302296
302644
  method: "PUT",
302297
302645
  cmmdPath: "/api/forge/context/projects/:id/task-workflow",
302298
302646
  orgIdSource: "none",
302299
302647
  responseShape: "unwrapData"
302300
302648
  });
302301
- const cmmdCreateProjectBoardTaskRouteLayer = registerProxyRoute({
302649
+ registerProxyRoute({
302302
302650
  forgePath: "/api/cmmd/projects/:id/board",
302303
302651
  method: "POST",
302304
302652
  cmmdPath: "/api/forge/context/projects/:id/board",
302305
302653
  orgIdSource: "none",
302306
302654
  responseShape: "unwrapData"
302307
302655
  });
302308
- const cmmdUpdateProjectBoardTaskRouteLayer = registerProxyRoute({
302656
+ registerProxyRoute({
302309
302657
  forgePath: "/api/cmmd/projects/:id/board/:taskId",
302310
302658
  method: "PATCH",
302311
302659
  cmmdPath: "/api/forge/context/projects/:id/board/:taskId",
302312
302660
  orgIdSource: "none",
302313
302661
  responseShape: "unwrapData"
302314
302662
  });
302315
- const cmmdUpdateProjectBoardTaskStatusRouteLayer = registerProxyRoute({
302663
+ registerProxyRoute({
302316
302664
  forgePath: "/api/cmmd/projects/:id/board/:taskId/status",
302317
302665
  method: "PATCH",
302318
302666
  cmmdPath: "/api/forge/context/projects/:id/board/:taskId/status",
302319
302667
  orgIdSource: "none",
302320
302668
  responseShape: "unwrapData"
302321
302669
  });
302322
- const cmmdListTaskExecutionOptionsRouteLayer = registerProxyRoute({
302670
+ registerProxyRoute({
302323
302671
  forgePath: "/api/cmmd/projects/:id/board/:taskId/execution-options",
302324
302672
  method: "GET",
302325
302673
  cmmdPath: "/api/forge/context/projects/:id/board/:taskId/execution-options",
302326
302674
  orgIdSource: "none",
302327
302675
  responseShape: "unwrapData"
302328
302676
  });
302329
- const cmmdCreateTaskWorkSessionRouteLayer = registerProxyRoute({
302677
+ registerProxyRoute({
302330
302678
  forgePath: "/api/cmmd/projects/:id/board/:taskId/work-sessions",
302331
302679
  method: "POST",
302332
302680
  cmmdPath: "/api/forge/context/projects/:id/board/:taskId/work-sessions",
302333
302681
  orgIdSource: "none",
302334
302682
  responseShape: "unwrapData"
302335
302683
  });
302336
- const cmmdListProjectWorkSessionsRouteLayer = registerProxyRoute({
302684
+ registerProxyRoute({
302337
302685
  forgePath: "/api/cmmd/projects/:id/work-sessions",
302338
302686
  method: "GET",
302339
302687
  cmmdPath: "/api/forge/context/projects/:id/work-sessions",
302340
302688
  orgIdSource: "none",
302341
302689
  responseShape: "unwrapData"
302342
302690
  });
302343
- const cmmdGetWorkSessionRouteLayer = registerProxyRoute({
302691
+ registerProxyRoute({
302344
302692
  forgePath: "/api/cmmd/work-sessions/:workSessionId",
302345
302693
  method: "GET",
302346
302694
  cmmdPath: "/api/forge/context/work-sessions/:workSessionId",
302347
302695
  orgIdSource: "none",
302348
302696
  responseShape: "unwrapData"
302349
302697
  });
302350
- const cmmdUpdateWorkSessionRouteLayer = registerProxyRoute({
302698
+ registerProxyRoute({
302351
302699
  forgePath: "/api/cmmd/work-sessions/:workSessionId",
302352
302700
  method: "PATCH",
302353
302701
  cmmdPath: "/api/forge/context/work-sessions/:workSessionId",
302354
302702
  orgIdSource: "none",
302355
302703
  responseShape: "unwrapData"
302356
302704
  });
302357
- const cmmdAttachWorkSessionThreadRouteLayer = registerProxyRoute({
302705
+ registerProxyRoute({
302358
302706
  forgePath: "/api/cmmd/work-sessions/:workSessionId/threads",
302359
302707
  method: "POST",
302360
302708
  cmmdPath: "/api/forge/context/work-sessions/:workSessionId/threads",
302361
302709
  orgIdSource: "none",
302362
302710
  responseShape: "unwrapData"
302363
302711
  });
302364
- const cmmdListTaskConversationsRouteLayer = registerProxyRoute({
302712
+ registerProxyRoute({
302365
302713
  forgePath: "/api/cmmd/tasks/:taskId/conversations",
302366
302714
  method: "GET",
302367
302715
  cmmdPath: "/api/forge/context/tasks/:taskId/conversations",
302368
302716
  orgIdSource: "none",
302369
302717
  responseShape: "unwrapData"
302370
302718
  });
302371
- const cmmdLinkTaskConversationRouteLayer = registerProxyRoute({
302719
+ registerProxyRoute({
302372
302720
  forgePath: "/api/cmmd/tasks/:taskId/conversations",
302373
302721
  method: "POST",
302374
302722
  cmmdPath: "/api/forge/context/tasks/:taskId/conversations",
302375
302723
  orgIdSource: "none",
302376
302724
  responseShape: "unwrapData"
302377
302725
  });
302378
- const cmmdGetTaskHistoryRouteLayer = registerProxyRoute({
302726
+ registerProxyRoute({
302379
302727
  forgePath: "/api/cmmd/tasks/:taskId/history",
302380
302728
  method: "GET",
302381
302729
  cmmdPath: "/api/forge/context/tasks/:taskId/history",
302382
302730
  orgIdSource: "none",
302383
302731
  responseShape: "unwrapData"
302384
302732
  });
302385
- const cmmdUpsertTaskPullRequestRouteLayer = registerProxyRoute({
302733
+ registerProxyRoute({
302386
302734
  forgePath: "/api/cmmd/tasks/:taskId/pull-requests",
302387
302735
  method: "PUT",
302388
302736
  cmmdPath: "/api/forge/context/tasks/:taskId/pull-requests",
302389
302737
  orgIdSource: "none",
302390
302738
  responseShape: "unwrapData"
302391
302739
  });
302392
- const cmmdPullRequestRouteLayers = [
302740
+ for (const path of [
302393
302741
  "list",
302394
302742
  "list-stats",
302395
302743
  "detail",
@@ -302407,70 +302755,70 @@ const cmmdPullRequestRouteLayers = [
302407
302755
  "thread/resolution",
302408
302756
  "reviewers",
302409
302757
  "reaction"
302410
- ].map((path) => registerProxyRoute({
302758
+ ]) registerProxyRoute({
302411
302759
  forgePath: `/api/cmmd/pull-requests/${path}`,
302412
302760
  method: "POST",
302413
302761
  cmmdPath: `/api/forge/context/pull-requests/${path}`,
302414
302762
  orgIdSource: "none",
302415
302763
  responseShape: "unwrapData"
302416
- }));
302417
- const cmmdGetTaskConversationRouteLayer = registerProxyRoute({
302764
+ });
302765
+ registerProxyRoute({
302418
302766
  forgePath: "/api/cmmd/tasks/:taskId/conversations/:conversationId",
302419
302767
  method: "GET",
302420
302768
  cmmdPath: "/api/forge/context/tasks/:taskId/conversations/:conversationId",
302421
302769
  orgIdSource: "none",
302422
302770
  responseShape: "unwrapData"
302423
302771
  });
302424
- const cmmdSpawnForgeThreadFromBoardTaskRouteLayer = registerProxyRoute({
302772
+ registerProxyRoute({
302425
302773
  forgePath: "/api/cmmd/projects/:id/board/:taskId/spawn-forge-thread",
302426
302774
  method: "POST",
302427
302775
  cmmdPath: "/api/forge/context/projects/:id/board/:taskId/spawn-forge-thread",
302428
302776
  orgIdSource: "none",
302429
302777
  responseShape: "unwrapData"
302430
302778
  });
302431
- const cmmdListCenterBoardRouteLayer = registerProxyRoute({
302779
+ registerProxyRoute({
302432
302780
  forgePath: "/api/cmmd/work-items/board",
302433
302781
  method: "GET",
302434
302782
  cmmdPath: "/api/forge/context/work-items/board",
302435
302783
  orgIdSource: "none",
302436
302784
  responseShape: "unwrapData"
302437
302785
  });
302438
- const cmmdCreateCenterBoardTaskRouteLayer = registerProxyRoute({
302786
+ registerProxyRoute({
302439
302787
  forgePath: "/api/cmmd/work-items/board",
302440
302788
  method: "POST",
302441
302789
  cmmdPath: "/api/forge/context/work-items/board",
302442
302790
  orgIdSource: "none",
302443
302791
  responseShape: "unwrapData"
302444
302792
  });
302445
- const cmmdCreateFeedbackRouteLayer = registerProxyRoute({
302793
+ registerProxyRoute({
302446
302794
  forgePath: "/api/cmmd/feedback",
302447
302795
  method: "POST",
302448
302796
  cmmdPath: "/api/forge/context/feedback",
302449
302797
  orgIdSource: "none",
302450
302798
  responseShape: "unwrapData"
302451
302799
  });
302452
- const cmmdUpdateCenterBoardTaskRouteLayer = registerProxyRoute({
302800
+ registerProxyRoute({
302453
302801
  forgePath: "/api/cmmd/work-items/board/:taskId",
302454
302802
  method: "PATCH",
302455
302803
  cmmdPath: "/api/forge/context/work-items/board/:taskId",
302456
302804
  orgIdSource: "none",
302457
302805
  responseShape: "unwrapData"
302458
302806
  });
302459
- const cmmdMoveCenterBoardTaskRouteLayer = registerProxyRoute({
302807
+ registerProxyRoute({
302460
302808
  forgePath: "/api/cmmd/work-items/board/:taskId/move",
302461
302809
  method: "PATCH",
302462
302810
  cmmdPath: "/api/forge/context/work-items/board/:taskId/move",
302463
302811
  orgIdSource: "none",
302464
302812
  responseShape: "unwrapData"
302465
302813
  });
302466
- const cmmdMoveProjectBoardTaskRouteLayer = registerProxyRoute({
302814
+ registerProxyRoute({
302467
302815
  forgePath: "/api/cmmd/projects/:projectId/board/:taskId/move",
302468
302816
  method: "PATCH",
302469
302817
  cmmdPath: "/api/forge/context/projects/:projectId/board/:taskId/move",
302470
302818
  orgIdSource: "none",
302471
302819
  responseShape: "unwrapData"
302472
302820
  });
302473
- const cmmdArchiveProjectBoardTaskRouteLayer = registerProxyRoute({
302821
+ registerProxyRoute({
302474
302822
  forgePath: "/api/cmmd/projects/:projectId/board/:taskId/archive",
302475
302823
  method: "POST",
302476
302824
  cmmdPath: "/api/forge/context/projects/:projectId/board/:taskId/archive",
@@ -302478,7 +302826,7 @@ const cmmdArchiveProjectBoardTaskRouteLayer = registerProxyRoute({
302478
302826
  responseShape: "unwrapData",
302479
302827
  requestBody: "none"
302480
302828
  });
302481
- const cmmdUnarchiveProjectBoardTaskRouteLayer = registerProxyRoute({
302829
+ registerProxyRoute({
302482
302830
  forgePath: "/api/cmmd/projects/:projectId/board/:taskId/unarchive",
302483
302831
  method: "POST",
302484
302832
  cmmdPath: "/api/forge/context/projects/:projectId/board/:taskId/unarchive",
@@ -302486,7 +302834,7 @@ const cmmdUnarchiveProjectBoardTaskRouteLayer = registerProxyRoute({
302486
302834
  responseShape: "unwrapData",
302487
302835
  requestBody: "none"
302488
302836
  });
302489
- const cmmdArchiveCenterBoardTaskRouteLayer = registerProxyRoute({
302837
+ registerProxyRoute({
302490
302838
  forgePath: "/api/cmmd/work-items/board/:taskId/archive",
302491
302839
  method: "POST",
302492
302840
  cmmdPath: "/api/forge/context/work-items/board/:taskId/archive",
@@ -302494,7 +302842,7 @@ const cmmdArchiveCenterBoardTaskRouteLayer = registerProxyRoute({
302494
302842
  responseShape: "unwrapData",
302495
302843
  requestBody: "none"
302496
302844
  });
302497
- const cmmdUnarchiveCenterBoardTaskRouteLayer = registerProxyRoute({
302845
+ registerProxyRoute({
302498
302846
  forgePath: "/api/cmmd/work-items/board/:taskId/unarchive",
302499
302847
  method: "POST",
302500
302848
  cmmdPath: "/api/forge/context/work-items/board/:taskId/unarchive",
@@ -302502,109 +302850,109 @@ const cmmdUnarchiveCenterBoardTaskRouteLayer = registerProxyRoute({
302502
302850
  responseShape: "unwrapData",
302503
302851
  requestBody: "none"
302504
302852
  });
302505
- const cmmdListCampaignsRouteLayer = registerProxyRoute({
302853
+ registerProxyRoute({
302506
302854
  forgePath: "/api/cmmd/campaigns",
302507
302855
  method: "GET",
302508
302856
  cmmdPath: "/api/forge/context/campaigns",
302509
302857
  orgIdSource: "none",
302510
302858
  responseShape: "passthrough"
302511
302859
  });
302512
- const cmmdGetCampaignRouteLayer = registerProxyRoute({
302860
+ registerProxyRoute({
302513
302861
  forgePath: "/api/cmmd/campaigns/:id",
302514
302862
  method: "GET",
302515
302863
  cmmdPath: "/api/forge/context/campaigns/:id",
302516
302864
  orgIdSource: "none",
302517
302865
  responseShape: "passthrough"
302518
302866
  });
302519
- const cmmdCreateCampaignRouteLayer = registerProxyRoute({
302867
+ registerProxyRoute({
302520
302868
  forgePath: "/api/cmmd/campaigns",
302521
302869
  method: "POST",
302522
302870
  cmmdPath: "/api/projects/campaigns",
302523
302871
  responseShape: "passthrough"
302524
302872
  });
302525
- const cmmdUpdateCampaignRouteLayer = registerProxyRoute({
302873
+ registerProxyRoute({
302526
302874
  forgePath: "/api/cmmd/campaigns/:id",
302527
302875
  method: "PUT",
302528
302876
  cmmdPath: "/api/projects/campaigns/:id",
302529
302877
  responseShape: "passthrough"
302530
302878
  });
302531
- const cmmdDeleteCampaignRouteLayer = registerProxyRoute({
302879
+ registerProxyRoute({
302532
302880
  forgePath: "/api/cmmd/campaigns/:id",
302533
302881
  method: "DELETE",
302534
302882
  cmmdPath: "/api/projects/campaigns/:id",
302535
302883
  orgIdSource: "none"
302536
302884
  });
302537
- const cmmdBootstrapRouteLayer = registerProxyRoute({
302885
+ registerProxyRoute({
302538
302886
  forgePath: "/api/cmmd/bootstrap",
302539
302887
  method: "GET",
302540
302888
  cmmdPath: "/api/forge/context/bootstrap",
302541
302889
  orgIdSource: "none",
302542
302890
  responseShape: "passthrough"
302543
302891
  });
302544
- const cmmdGetAccountPreferencesRouteLayer = registerProxyRoute({
302892
+ registerProxyRoute({
302545
302893
  forgePath: "/api/cmmd/account/preferences",
302546
302894
  method: "GET",
302547
302895
  cmmdPath: "/api/forge/context/account/preferences",
302548
302896
  orgIdSource: "none",
302549
302897
  responseShape: "unwrapData"
302550
302898
  });
302551
- const cmmdUpdateAccountPreferencesRouteLayer = registerProxyRoute({
302899
+ registerProxyRoute({
302552
302900
  forgePath: "/api/cmmd/account/preferences",
302553
302901
  method: "PATCH",
302554
302902
  cmmdPath: "/api/forge/context/account/preferences",
302555
302903
  orgIdSource: "none",
302556
302904
  responseShape: "unwrapData"
302557
302905
  });
302558
- const cmmdGetOrgProviderPolicyRouteLayer = registerProxyRoute({
302906
+ registerProxyRoute({
302559
302907
  forgePath: "/api/cmmd/org/provider-policy",
302560
302908
  method: "GET",
302561
302909
  cmmdPath: "/api/forge/context/org/provider-policy",
302562
302910
  orgIdSource: "none",
302563
302911
  responseShape: "unwrapData"
302564
302912
  });
302565
- const cmmdListChatsRouteLayer = registerProxyRoute({
302913
+ registerProxyRoute({
302566
302914
  forgePath: "/api/cmmd/chats",
302567
302915
  method: "GET",
302568
302916
  cmmdPath: "/api/forge/context/chats",
302569
302917
  orgIdSource: "none",
302570
302918
  responseShape: "unwrapData"
302571
302919
  });
302572
- const cmmdGetChatRouteLayer = registerProxyRoute({
302920
+ registerProxyRoute({
302573
302921
  forgePath: "/api/cmmd/chats/:threadId",
302574
302922
  method: "GET",
302575
302923
  cmmdPath: "/api/forge/context/chats/:threadId",
302576
302924
  orgIdSource: "none",
302577
302925
  responseShape: "unwrapData"
302578
302926
  });
302579
- const cmmdListDevicesRouteLayer = registerProxyRoute({
302927
+ registerProxyRoute({
302580
302928
  forgePath: "/api/cmmd/devices",
302581
302929
  method: "GET",
302582
302930
  cmmdPath: "/api/forge/context/devices",
302583
302931
  orgIdSource: "none",
302584
302932
  responseShape: "unwrapData"
302585
302933
  });
302586
- const cmmdRegisterDeviceRouteLayer = registerProxyRoute({
302934
+ registerProxyRoute({
302587
302935
  forgePath: "/api/cmmd/devices/register",
302588
302936
  method: "POST",
302589
302937
  cmmdPath: "/api/forge/context/devices/register",
302590
302938
  orgIdSource: "none",
302591
302939
  responseShape: "unwrapData"
302592
302940
  });
302593
- const cmmdHeartbeatRuntimeRouteLayer = registerProxyRoute({
302941
+ registerProxyRoute({
302594
302942
  forgePath: "/api/cmmd/devices/runtimes/:runtimeId/heartbeat",
302595
302943
  method: "POST",
302596
302944
  cmmdPath: "/api/forge/context/devices/runtimes/:runtimeId/heartbeat",
302597
302945
  orgIdSource: "none",
302598
302946
  responseShape: "unwrapData"
302599
302947
  });
302600
- const cmmdGrantRuntimeAccessRouteLayer = registerProxyRoute({
302948
+ registerProxyRoute({
302601
302949
  forgePath: "/api/cmmd/devices/runtimes/:runtimeId/access-grants",
302602
302950
  method: "POST",
302603
302951
  cmmdPath: "/api/forge/context/devices/runtimes/:runtimeId/access-grants",
302604
302952
  orgIdSource: "none",
302605
302953
  responseShape: "unwrapData"
302606
302954
  });
302607
- const cmmdRevokeRuntimeAccessRouteLayer = registerProxyRoute({
302955
+ registerProxyRoute({
302608
302956
  forgePath: "/api/cmmd/devices/runtimes/:runtimeId/access-grants/:grantId/revoke",
302609
302957
  method: "POST",
302610
302958
  cmmdPath: "/api/forge/context/devices/runtimes/:runtimeId/access-grants/:grantId/revoke",
@@ -302612,46 +302960,60 @@ const cmmdRevokeRuntimeAccessRouteLayer = registerProxyRoute({
302612
302960
  responseShape: "unwrapData",
302613
302961
  successStatus: 200
302614
302962
  });
302615
- const cmmdCreateRelayControlRouteLayer = registerProxyRoute({
302963
+ registerProxyRoute({
302616
302964
  forgePath: "/api/cmmd/devices/runtimes/:runtimeId/relay-routes",
302617
302965
  method: "POST",
302618
302966
  cmmdPath: "/api/forge/context/devices/runtimes/:runtimeId/relay-routes",
302619
302967
  orgIdSource: "none",
302620
302968
  responseShape: "unwrapData"
302621
302969
  });
302622
- const cmmdCreateRelayActionGrantRouteLayer = registerProxyRoute({
302970
+ registerProxyRoute({
302623
302971
  forgePath: "/api/cmmd/devices/runtimes/:runtimeId/relay-action-grants",
302624
302972
  method: "POST",
302625
302973
  cmmdPath: "/api/forge/context/devices/runtimes/:runtimeId/relay-action-grants",
302626
302974
  orgIdSource: "none",
302627
302975
  responseShape: "unwrapData"
302628
302976
  });
302629
- const cmmdReplaceRuntimeInventoryRouteLayer = registerProxyRoute({
302977
+ registerProxyRoute({
302630
302978
  forgePath: "/api/cmmd/devices/runtimes/:runtimeId/inventory",
302631
302979
  method: "PUT",
302632
302980
  cmmdPath: "/api/forge/context/devices/runtimes/:runtimeId/inventory",
302633
302981
  orgIdSource: "none",
302634
302982
  responseShape: "unwrapData"
302635
302983
  });
302636
- const cmmdListRuntimeInventoryRouteLayer = registerProxyRoute({
302984
+ registerProxyRoute({
302637
302985
  forgePath: "/api/cmmd/runtime-inventory",
302638
302986
  method: "GET",
302639
302987
  cmmdPath: "/api/forge/context/runtime-inventory",
302640
302988
  orgIdSource: "none",
302641
302989
  responseShape: "unwrapData"
302642
302990
  });
302991
+ registerProxyRoute({
302992
+ forgePath: "/api/cmmd/threads/:runtimeId/:threadId/lifecycle-intent",
302993
+ method: "PUT",
302994
+ cmmdPath: "/api/forge/context/threads/:runtimeId/:threadId/lifecycle-intent",
302995
+ orgIdSource: "none",
302996
+ requestBody: "json",
302997
+ responseShape: "unwrapData"
302998
+ });
302999
+ registerProxyRoute({
303000
+ forgePath: "/api/cmmd/threads/:runtimeId/:threadId/lifecycle-intent",
303001
+ method: "DELETE",
303002
+ cmmdPath: "/api/forge/context/threads/:runtimeId/:threadId/lifecycle-intent",
303003
+ orgIdSource: "none"
303004
+ });
302643
303005
  /**
302644
303006
  * Owner-scoped, bounded control-plane observation. This is intentionally
302645
303007
  * separate from the runtime inventory publisher and never wakes a runtime.
302646
303008
  */
302647
- const cmmdGetRuntimeDiagnosticsRouteLayer = registerProxyRoute({
303009
+ registerProxyRoute({
302648
303010
  forgePath: "/api/cmmd/runtime-diagnostics/v2/runtimes/:runtimeId",
302649
303011
  method: "GET",
302650
303012
  cmmdPath: "/api/forge/context/runtime-diagnostics/v2/runtimes/:runtimeId",
302651
303013
  orgIdSource: "none",
302652
303014
  responseShape: "unwrapData"
302653
303015
  });
302654
- const cmmdProvisionAuthRuntimeRouteLayer = registerProxyRoute({
303016
+ registerProxyRoute({
302655
303017
  forgePath: "/api/cmmd/auth-runtime",
302656
303018
  method: "POST",
302657
303019
  cmmdPath: "/api/forge/context/auth-runtime",
@@ -302659,21 +303021,21 @@ const cmmdProvisionAuthRuntimeRouteLayer = registerProxyRoute({
302659
303021
  responseShape: "unwrapData",
302660
303022
  requestBody: "none"
302661
303023
  });
302662
- const cmmdGetAuthRuntimeRouteLayer = registerProxyRoute({
303024
+ registerProxyRoute({
302663
303025
  forgePath: "/api/cmmd/auth-runtime",
302664
303026
  method: "GET",
302665
303027
  cmmdPath: "/api/forge/context/auth-runtime",
302666
303028
  orgIdSource: "none",
302667
303029
  responseShape: "unwrapData"
302668
303030
  });
302669
- const cmmdDestroyAuthRuntimeRouteLayer = registerProxyRoute({
303031
+ registerProxyRoute({
302670
303032
  forgePath: "/api/cmmd/auth-runtime",
302671
303033
  method: "DELETE",
302672
303034
  cmmdPath: "/api/forge/context/auth-runtime",
302673
303035
  orgIdSource: "none",
302674
303036
  responseShape: "unwrapData"
302675
303037
  });
302676
- const cmmdConnectAuthRuntimeRouteLayer = registerProxyRoute({
303038
+ registerProxyRoute({
302677
303039
  forgePath: "/api/cmmd/auth-runtime/connect",
302678
303040
  method: "POST",
302679
303041
  cmmdPath: "/api/forge/context/auth-runtime/connect",
@@ -302681,14 +303043,14 @@ const cmmdConnectAuthRuntimeRouteLayer = registerProxyRoute({
302681
303043
  responseShape: "unwrapData",
302682
303044
  requestBody: "none"
302683
303045
  });
302684
- const cmmdGetProviderAccountsRouteLayer = registerProxyRoute({
303046
+ registerProxyRoute({
302685
303047
  forgePath: "/api/cmmd/providers/accounts",
302686
303048
  method: "GET",
302687
303049
  cmmdPath: "/api/forge/context/providers/accounts",
302688
303050
  orgIdSource: "none",
302689
303051
  responseShape: "unwrapData"
302690
303052
  });
302691
- const cmmdDeleteProviderAccountRouteLayer = registerProxyRoute({
303053
+ registerProxyRoute({
302692
303054
  forgePath: "/api/cmmd/providers/accounts/:id",
302693
303055
  method: "DELETE",
302694
303056
  cmmdPath: "/api/forge/context/providers/accounts/:id",
@@ -302696,23 +303058,29 @@ const cmmdDeleteProviderAccountRouteLayer = registerProxyRoute({
302696
303058
  responseShape: "unwrapData",
302697
303059
  requestBody: "none"
302698
303060
  });
302699
- const cmmdSetProviderAccountDefaultRouteLayer = registerProxyRoute({
303061
+ registerProxyRoute({
302700
303062
  forgePath: "/api/cmmd/providers/accounts/default",
302701
303063
  method: "PUT",
302702
303064
  cmmdPath: "/api/forge/context/providers/accounts/default",
302703
303065
  orgIdSource: "none",
302704
303066
  responseShape: "unwrapData"
302705
303067
  });
302706
- const cmmdGetProviderUsageRouteLayer = add$1("GET", "/api/cmmd/providers/usage", require_Schema$1.gen(function* () {
302707
- const request = yield* require_HttpServer.HttpServerRequest;
302708
- const outcome = yield* runCmmdRestProxy(yield* (yield* ServerAuth).authenticateHttpRequest(request), (jwt) => cmmdGateway.request({
303068
+ registerProxyHandler({
303069
+ forgePath: "/api/cmmd/providers/usage",
303070
+ method: "GET",
303071
+ parse: () => require_Schema$1.succeed({
303072
+ ok: true,
303073
+ value: void 0
303074
+ }),
303075
+ run: (_parsed, { session }) => runCmmdRestProxyAsHandlerResult(session, (jwt) => cmmdGateway.request({
302709
303076
  method: "GET",
302710
303077
  jwt,
302711
303078
  path: "/api/forge/context/providers/usage"
302712
- }));
302713
- if (!outcome.ok) return buildProxyErrorResponse(outcome.error);
302714
- return require_HttpServer.jsonUnsafe(unwrapForgeEnvelope(outcome.value), { status: 200 });
302715
- }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error))));
303079
+ }), (value) => ({
303080
+ status: 200,
303081
+ body: unwrapForgeEnvelope(value)
303082
+ }))
303083
+ });
302716
303084
  function parseProviderUsageRefreshInput(rawBody) {
302717
303085
  if (rawBody === null || typeof rawBody !== "object") return null;
302718
303086
  const body = rawBody;
@@ -302794,56 +303162,56 @@ function makeRefreshProviderUsageHandler(dependencies = {}) {
302794
303162
  }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error)));
302795
303163
  }
302796
303164
  const cmmdRefreshProviderUsageRouteLayer = add$1("POST", "/api/cmmd/providers/usage/refresh", makeRefreshProviderUsageHandler());
302797
- const cmmdGetUserCodexCredentialRouteLayer = registerProxyRoute({
303165
+ registerProxyRoute({
302798
303166
  forgePath: "/api/cmmd/providers/codex/credential",
302799
303167
  method: "GET",
302800
303168
  cmmdPath: "/api/forge/context/providers/codex/credential",
302801
303169
  orgIdSource: "none",
302802
303170
  responseShape: "unwrapData"
302803
303171
  });
302804
- const cmmdDeleteUserCodexCredentialRouteLayer = registerProxyRoute({
303172
+ registerProxyRoute({
302805
303173
  forgePath: "/api/cmmd/providers/codex/credential",
302806
303174
  method: "DELETE",
302807
303175
  cmmdPath: "/api/forge/context/providers/codex/credential",
302808
303176
  orgIdSource: "none",
302809
303177
  responseShape: "unwrapData"
302810
303178
  });
302811
- const cmmdGetUserClaudeCredentialRouteLayer = registerProxyRoute({
303179
+ registerProxyRoute({
302812
303180
  forgePath: "/api/cmmd/providers/claude/credential",
302813
303181
  method: "GET",
302814
303182
  cmmdPath: "/api/forge/context/providers/claude/credential",
302815
303183
  orgIdSource: "none",
302816
303184
  responseShape: "unwrapData"
302817
303185
  });
302818
- const cmmdDeleteUserClaudeCredentialRouteLayer = registerProxyRoute({
303186
+ registerProxyRoute({
302819
303187
  forgePath: "/api/cmmd/providers/claude/credential",
302820
303188
  method: "DELETE",
302821
303189
  cmmdPath: "/api/forge/context/providers/claude/credential",
302822
303190
  orgIdSource: "none",
302823
303191
  responseShape: "unwrapData"
302824
303192
  });
302825
- const cmmdGetClaudeRuntimeReadinessRouteLayer = registerProxyRoute({
303193
+ registerProxyRoute({
302826
303194
  forgePath: "/api/cmmd/providers/claude/runtime-readiness/:runtimeId",
302827
303195
  method: "GET",
302828
303196
  cmmdPath: "/api/forge/context/providers/claude/runtime-readiness/:runtimeId",
302829
303197
  orgIdSource: "none",
302830
303198
  responseShape: "unwrapData"
302831
303199
  });
302832
- const cmmdAppendRuntimeThreadEventsRouteLayer = registerProxyRoute({
303200
+ registerProxyRoute({
302833
303201
  forgePath: "/api/cmmd/devices/runtimes/:runtimeId/threads/:threadId/events",
302834
303202
  method: "POST",
302835
303203
  cmmdPath: "/api/forge/context/devices/runtimes/:runtimeId/threads/:threadId/events",
302836
303204
  orgIdSource: "none",
302837
303205
  responseShape: "unwrapData"
302838
303206
  });
302839
- const cmmdGetRuntimeThreadReplicaRouteLayer = registerProxyRoute({
303207
+ registerProxyRoute({
302840
303208
  forgePath: "/api/cmmd/threads/:runtimeId/:threadId",
302841
303209
  method: "GET",
302842
303210
  cmmdPath: "/api/forge/context/threads/:runtimeId/:threadId",
302843
303211
  orgIdSource: "none",
302844
303212
  responseShape: "unwrapData"
302845
303213
  });
302846
- const cmmdRenameDeviceRouteLayer = registerProxyRoute({
303214
+ registerProxyRoute({
302847
303215
  forgePath: "/api/cmmd/devices/:deviceId/rename",
302848
303216
  method: "POST",
302849
303217
  cmmdPath: "/api/forge/context/devices/:deviceId/rename",
@@ -302859,7 +303227,7 @@ const cmmdRenameDeviceRouteLayer = registerProxyRoute({
302859
303227
  * the status and the code reach the browser unchanged, which is what lets the
302860
303228
  * rename field say something specific instead of "something went wrong".
302861
303229
  */
302862
- const cmmdRenameForgeRuntimeRouteLayer = registerProxyRoute({
303230
+ registerProxyRoute({
302863
303231
  forgePath: "/api/cmmd/forge-runtimes/:runtimeId/rename",
302864
303232
  method: "POST",
302865
303233
  cmmdPath: "/api/forge/context/runtimes/:runtimeId/rename",
@@ -302867,7 +303235,7 @@ const cmmdRenameForgeRuntimeRouteLayer = registerProxyRoute({
302867
303235
  responseShape: "unwrapData",
302868
303236
  successStatus: 200
302869
303237
  });
302870
- const cmmdRevokeDeviceRouteLayer = registerProxyRoute({
303238
+ registerProxyRoute({
302871
303239
  forgePath: "/api/cmmd/devices/:deviceId/revoke",
302872
303240
  method: "POST",
302873
303241
  cmmdPath: "/api/forge/context/devices/:deviceId/revoke",
@@ -302876,24 +303244,21 @@ const cmmdRevokeDeviceRouteLayer = registerProxyRoute({
302876
303244
  requestBody: "none",
302877
303245
  successStatus: 200
302878
303246
  });
302879
- const cmmdListConnectorsRouteLayer = registerProxyRoute({
303247
+ registerProxyRoute({
302880
303248
  forgePath: "/api/cmmd/connectors",
302881
303249
  method: "GET",
302882
303250
  cmmdPath: "/api/forge/context/connectors",
302883
303251
  orgIdSource: "none"
302884
303252
  });
302885
- const cmmdInstallConnectorRouteLayer = registerProxyRoute({
303253
+ registerProxyRoute({
302886
303254
  forgePath: "/api/cmmd/connectors/:connectorId/install",
302887
303255
  method: "POST",
302888
303256
  cmmdPath: "/api/forge/context/connectors/:connectorId/install",
302889
303257
  orgIdSource: "none"
302890
303258
  });
302891
303259
  const cmmdForgeCloudProjectsListRouteLayer = add$1("GET", "/api/cmmd/forge-cloud-projects", require_Schema$1.gen(function* () {
302892
- const accessToken = yield* makeCmmdProxyAccessTokenEffect("forge-cloud-projects");
302893
- if (!accessToken) return buildCmmdAuthErrorResponse({
302894
- code: "CMMD_AUTH_REQUIRED",
302895
- message: "CMMD authentication is required. Sign in again to continue."
302896
- });
303260
+ const { session, jwt: accessToken } = yield* makeCmmdProxyAccessTokenEffect("forge-cloud-projects");
303261
+ if (!accessToken) return yield* respondCmmdConnectionRequired(session.sessionId);
302897
303262
  const upstreamUrl = `${resolveCommandAppUrl()}${CMMD_CLOUD_PROJECTS_PATH}`;
302898
303263
  const upstreamOrError = yield* fetchCmmdUpstreamWithRetry(() => fetch(upstreamUrl, { headers: {
302899
303264
  Authorization: `Bearer ${accessToken}`,
@@ -302904,10 +303269,7 @@ const cmmdForgeCloudProjectsListRouteLayer = add$1("GET", "/api/cmmd/forge-cloud
302904
303269
  code: "CMMD_UNAVAILABLE"
302905
303270
  }, { status: 503 });
302906
303271
  const upstream = upstreamOrError.res;
302907
- if (upstream.status === 401 || upstream.status === 403) return buildCmmdAuthErrorResponse({
302908
- code: "CMMD_AUTH_REQUIRED",
302909
- message: "CMMD authentication expired. Sign in again to continue."
302910
- });
303272
+ if (upstream.status === 401 || upstream.status === 403) return yield* respondCmmdConnectionRequired(session.sessionId);
302911
303273
  const bodyOrError = yield* require_Schema$1.tryPromise(() => upstream.text()).pipe(require_Schema$1.map((text) => ({
302912
303274
  ok: true,
302913
303275
  text
@@ -302929,35 +303291,35 @@ const cmmdForgeCloudProjectsListRouteLayer = add$1("GET", "/api/cmmd/forge-cloud
302929
303291
  headers: { "content-type": "application/json" }
302930
303292
  });
302931
303293
  }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error))));
302932
- const cmmdForgeCloudProjectRegisterRouteLayer = registerProxyRoute({
303294
+ registerProxyRoute({
302933
303295
  forgePath: "/api/cmmd/forge-cloud-projects",
302934
303296
  method: "POST",
302935
303297
  cmmdPath: CMMD_CLOUD_PROJECTS_PATH,
302936
303298
  orgIdSource: "none",
302937
303299
  responseShape: "unwrapData"
302938
303300
  });
302939
- const cmmdForgeCloudProjectUnregisterRouteLayer = registerProxyRoute({
303301
+ registerProxyRoute({
302940
303302
  forgePath: "/api/cmmd/forge-cloud-projects/:projectId",
302941
303303
  method: "DELETE",
302942
303304
  cmmdPath: `${CMMD_CLOUD_PROJECTS_PATH}/:projectId`,
302943
303305
  orgIdSource: "none",
302944
303306
  responseShape: "unwrapData"
302945
303307
  });
302946
- const cmmdForgeCloudProjectLifecyclePreflightRouteLayer = registerProxyRoute({
303308
+ registerProxyRoute({
302947
303309
  forgePath: "/api/cmmd/forge-cloud-projects/:projectId/lifecycle-preflight",
302948
303310
  method: "GET",
302949
303311
  cmmdPath: `${CMMD_CLOUD_PROJECTS_PATH}/:projectId/lifecycle-preflight`,
302950
303312
  orgIdSource: "none",
302951
303313
  responseShape: "unwrapData"
302952
303314
  });
302953
- const cmmdForgeCloudProjectRemovalPreviewRouteLayer = registerProxyRoute({
303315
+ registerProxyRoute({
302954
303316
  forgePath: "/api/cmmd/forge-cloud-projects/:projectId/removal-preview",
302955
303317
  method: "GET",
302956
303318
  cmmdPath: `${CMMD_CLOUD_PROJECTS_PATH}/:projectId/removal-preview`,
302957
303319
  orgIdSource: "none",
302958
303320
  responseShape: "unwrapData"
302959
303321
  });
302960
- const cmmdForgeCloudProjectRemovalRouteLayer = registerProxyRoute({
303322
+ registerProxyRoute({
302961
303323
  forgePath: "/api/cmmd/forge-cloud-projects/:projectId/removal",
302962
303324
  method: "POST",
302963
303325
  cmmdPath: `${CMMD_CLOUD_PROJECTS_PATH}/:projectId/removal`,
@@ -302966,7 +303328,7 @@ const cmmdForgeCloudProjectRemovalRouteLayer = registerProxyRoute({
302966
303328
  successStatus: 202,
302967
303329
  workIntakeInvalidation: "completedPermanentRemoval"
302968
303330
  });
302969
- const cmmdForgeCloudProjectRemovalReceiptRouteLayer = registerProxyRoute({
303331
+ registerProxyRoute({
302970
303332
  forgePath: "/api/cmmd/forge-cloud-project-removals/:operationId",
302971
303333
  method: "GET",
302972
303334
  cmmdPath: `${CMMD_CLOUD_PROJECTS_PATH}/removals/:operationId`,
@@ -303030,11 +303392,8 @@ function makeFetchCloudProjectsFrameEffect(upstreamUrl, accessToken) {
303030
303392
  })).pipe(require_Schema$1.catch_(() => require_Schema$1.succeed(null)));
303031
303393
  }
303032
303394
  const cmmdForgeCloudProjectsEventsRouteLayer = add$1("GET", "/api/cmmd/forge-cloud-projects/events", require_Schema$1.gen(function* () {
303033
- const accessToken = yield* makeCmmdProxyAccessTokenEffect("forge-cloud-projects/events");
303034
- if (!accessToken) return buildCmmdAuthErrorResponse({
303035
- code: "CMMD_AUTH_REQUIRED",
303036
- message: "CMMD authentication is required. Sign in again to continue."
303037
- });
303395
+ const { session, jwt: accessToken } = yield* makeCmmdProxyAccessTokenEffect("forge-cloud-projects/events");
303396
+ if (!accessToken) return yield* respondCmmdConnectionRequired(session.sessionId);
303038
303397
  const fetchCloudProjectsFrame = makeFetchCloudProjectsFrameEffect(`${resolveCommandAppUrl()}${CMMD_CLOUD_PROJECTS_PATH}`, accessToken);
303039
303398
  const dataStream = require_Path.concat(require_Path.fromEffect(fetchCloudProjectsFrame), require_Path.tick(FORGE_RUNTIMES_POLL_INTERVAL).pipe(require_Path.mapEffect(() => fetchCloudProjectsFrame))).pipe(require_Path.filter((frame) => frame !== null));
303040
303399
  const keepaliveStream = require_Path.tick(FORGE_RUNTIMES_KEEPALIVE_INTERVAL).pipe(require_Path.map(() => FORGE_RUNTIMES_KEEPALIVE_FRAME));
@@ -303107,11 +303466,8 @@ function fetchCmmdUpstreamWithRetry(send, policy = "idempotent") {
303107
303466
  }
303108
303467
  const cmmdForgeRuntimesEnsureRouteLayer = add$1("POST", "/api/cmmd/forge-runtimes/ensure", require_Schema$1.gen(function* () {
303109
303468
  const request = yield* require_HttpServer.HttpServerRequest;
303110
- const accessToken = yield* makeCmmdProxyAccessTokenEffect("forge-runtimes/ensure");
303111
- if (!accessToken) return buildCmmdAuthErrorResponse({
303112
- code: "CMMD_AUTH_REQUIRED",
303113
- message: "CMMD authentication is required. Sign in again to continue."
303114
- });
303469
+ const { session, jwt: accessToken } = yield* makeCmmdProxyAccessTokenEffect("forge-runtimes/ensure");
303470
+ if (!accessToken) return yield* respondCmmdConnectionRequired(session.sessionId);
303115
303471
  const scopedBody = splitCmmdRuntimeOrganizationScope(yield* request.json.pipe(require_Schema$1.catch_(() => require_Schema$1.succeed({}))));
303116
303472
  if (!scopedBody) return require_HttpServer.jsonUnsafe({ error: "A valid organizationId is required when organization scope is provided." }, { status: 400 });
303117
303473
  const upstreamUrl = `${resolveCommandAppUrl()}/api/forge/context/runtimes/ensure`;
@@ -303130,10 +303486,7 @@ const cmmdForgeRuntimesEnsureRouteLayer = add$1("POST", "/api/cmmd/forge-runtime
303130
303486
  code: "CMMD_UNAVAILABLE"
303131
303487
  }, { status: 503 });
303132
303488
  const upstream = upstreamOrError.res;
303133
- if (upstream.status === 401 || upstream.status === 403) return buildCmmdAuthErrorResponse({
303134
- code: "CMMD_AUTH_REQUIRED",
303135
- message: "CMMD authentication expired. Sign in again to continue."
303136
- });
303489
+ if (upstream.status === 401 || upstream.status === 403) return yield* respondCmmdConnectionRequired(session.sessionId);
303137
303490
  const bodyOrError = yield* require_Schema$1.tryPromise(() => upstream.text()).pipe(require_Schema$1.map((text) => ({
303138
303491
  ok: true,
303139
303492
  text
@@ -303157,11 +303510,8 @@ const cmmdForgeRuntimesEnsureRouteLayer = add$1("POST", "/api/cmmd/forge-runtime
303157
303510
  }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error))));
303158
303511
  const cmmdForgeRuntimesConnectRouteLayer = add$1("POST", "/api/cmmd/forge-runtimes/:runtimeId/connect", require_Schema$1.gen(function* () {
303159
303512
  const request = yield* require_HttpServer.HttpServerRequest;
303160
- const accessToken = yield* makeCmmdProxyAccessTokenEffect("forge-runtimes/connect");
303161
- if (!accessToken) return buildCmmdAuthErrorResponse({
303162
- code: "CMMD_AUTH_REQUIRED",
303163
- message: "CMMD authentication is required. Sign in again to continue."
303164
- });
303513
+ const { session, jwt: accessToken } = yield* makeCmmdProxyAccessTokenEffect("forge-runtimes/connect");
303514
+ if (!accessToken) return yield* respondCmmdConnectionRequired(session.sessionId);
303165
303515
  const runtimeId = extractIdFromPath(new URL(request.url, "http://localhost").pathname, 2);
303166
303516
  if (!runtimeId) return require_HttpServer.jsonUnsafe({ error: "Runtime ID is required." }, { status: 400 });
303167
303517
  const scopedBody = splitCmmdRuntimeOrganizationScope(yield* request.json.pipe(require_Schema$1.catch_(() => require_Schema$1.succeed({}))));
@@ -303182,10 +303532,7 @@ const cmmdForgeRuntimesConnectRouteLayer = add$1("POST", "/api/cmmd/forge-runtim
303182
303532
  code: "CMMD_UNAVAILABLE"
303183
303533
  }, { status: 503 });
303184
303534
  const upstream = upstreamOrError.res;
303185
- if (upstream.status === 401 || upstream.status === 403) return buildCmmdAuthErrorResponse({
303186
- code: "CMMD_AUTH_REQUIRED",
303187
- message: "CMMD authentication expired. Sign in again to continue."
303188
- });
303535
+ if (upstream.status === 401 || upstream.status === 403) return yield* respondCmmdConnectionRequired(session.sessionId);
303189
303536
  const bodyOrError = yield* require_Schema$1.tryPromise(() => upstream.text()).pipe(require_Schema$1.map((text) => ({
303190
303537
  ok: true,
303191
303538
  text
@@ -303209,11 +303556,8 @@ const cmmdForgeRuntimesConnectRouteLayer = add$1("POST", "/api/cmmd/forge-runtim
303209
303556
  }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error))));
303210
303557
  const cmmdForgeRuntimesStatusRouteLayer = add$1("GET", "/api/cmmd/forge-runtimes/:runtimeId/status", require_Schema$1.gen(function* () {
303211
303558
  const request = yield* require_HttpServer.HttpServerRequest;
303212
- const accessToken = yield* makeCmmdProxyAccessTokenEffect("forge-runtimes/status");
303213
- if (!accessToken) return buildCmmdAuthErrorResponse({
303214
- code: "CMMD_AUTH_REQUIRED",
303215
- message: "CMMD authentication is required. Sign in again to continue."
303216
- });
303559
+ const { session, jwt: accessToken } = yield* makeCmmdProxyAccessTokenEffect("forge-runtimes/status");
303560
+ if (!accessToken) return yield* respondCmmdConnectionRequired(session.sessionId);
303217
303561
  const runtimeId = extractIdFromPath(new URL(request.url, "http://localhost").pathname, 2);
303218
303562
  if (!runtimeId) return require_HttpServer.jsonUnsafe({ error: "Runtime ID is required." }, { status: 400 });
303219
303563
  const upstreamUrl = `${resolveCommandAppUrl()}/api/forge/context/runtimes/${encodeURIComponent(runtimeId)}/status`;
@@ -303229,10 +303573,7 @@ const cmmdForgeRuntimesStatusRouteLayer = add$1("GET", "/api/cmmd/forge-runtimes
303229
303573
  code: "CMMD_UNAVAILABLE"
303230
303574
  }, { status: 503 });
303231
303575
  const upstream = upstreamOrError.res;
303232
- if (upstream.status === 401 || upstream.status === 403) return buildCmmdAuthErrorResponse({
303233
- code: "CMMD_AUTH_REQUIRED",
303234
- message: "CMMD authentication expired. Sign in again to continue."
303235
- });
303576
+ if (upstream.status === 401 || upstream.status === 403) return yield* respondCmmdConnectionRequired(session.sessionId);
303236
303577
  const bodyOrError = yield* require_Schema$1.tryPromise(() => upstream.text()).pipe(require_Schema$1.map((text) => ({
303237
303578
  ok: true,
303238
303579
  text
@@ -303263,10 +303604,7 @@ function makeCmmdForgeRuntimesLifecycleHandler(action) {
303263
303604
  subject: session.subject,
303264
303605
  logPrefix: `forge-runtimes/${action}`
303265
303606
  });
303266
- if (!accessToken) return buildCmmdAuthErrorResponse({
303267
- code: "CMMD_AUTH_REQUIRED",
303268
- message: "CMMD authentication is required. Sign in again to continue."
303269
- });
303607
+ if (!accessToken) return yield* respondCmmdConnectionRequired(session.sessionId);
303270
303608
  const runtimeId = extractIdFromPath(new URL(request.url, "http://localhost").pathname, 2);
303271
303609
  if (!runtimeId) return require_HttpServer.jsonUnsafe({ error: "Runtime ID is required." }, { status: 400 });
303272
303610
  const scopedBody = splitCmmdRuntimeOrganizationScope(yield* request.json.pipe(require_Schema$1.catch_(() => require_Schema$1.succeed({}))));
@@ -303287,10 +303625,7 @@ function makeCmmdForgeRuntimesLifecycleHandler(action) {
303287
303625
  code: "CMMD_UNAVAILABLE"
303288
303626
  }, { status: 503 });
303289
303627
  const upstream = upstreamOrError.res;
303290
- if (upstream.status === 401 || upstream.status === 403) return buildCmmdAuthErrorResponse({
303291
- code: "CMMD_AUTH_REQUIRED",
303292
- message: "CMMD authentication expired. Sign in again to continue."
303293
- });
303628
+ if (upstream.status === 401 || upstream.status === 403) return yield* respondCmmdConnectionRequired(session.sessionId);
303294
303629
  const bodyOrError = yield* require_Schema$1.tryPromise(() => upstream.text()).pipe(require_Schema$1.map((text) => ({
303295
303630
  ok: true,
303296
303631
  text
@@ -303323,11 +303658,8 @@ const cmmdForgeRuntimesRecycleRouteLayer = add$1("POST", "/api/cmmd/forge-runtim
303323
303658
  const cmmdForgeRuntimesUpdateCommitRouteLayer = add$1("POST", "/api/cmmd/forge-runtimes/:runtimeId/update-commit", __cmmdForgeRuntimesUpdateCommitHandlerForTests);
303324
303659
  const cmmdForgeRuntimesDestroyRouteLayer = add$1("POST", "/api/cmmd/forge-runtimes/:runtimeId/destroy", require_Schema$1.gen(function* () {
303325
303660
  const request = yield* require_HttpServer.HttpServerRequest;
303326
- const accessToken = yield* makeCmmdProxyAccessTokenEffect("forge-runtimes/destroy");
303327
- if (!accessToken) return buildCmmdAuthErrorResponse({
303328
- code: "CMMD_AUTH_REQUIRED",
303329
- message: "CMMD authentication is required. Sign in again to continue."
303330
- });
303661
+ const { session, jwt: accessToken } = yield* makeCmmdProxyAccessTokenEffect("forge-runtimes/destroy");
303662
+ if (!accessToken) return yield* respondCmmdConnectionRequired(session.sessionId);
303331
303663
  const runtimeId = extractIdFromPath(new URL(request.url, "http://localhost").pathname, 2);
303332
303664
  if (!runtimeId) return require_HttpServer.jsonUnsafe({ error: "Runtime ID is required." }, { status: 400 });
303333
303665
  const scopedBody = splitCmmdRuntimeOrganizationScope(yield* request.json.pipe(require_Schema$1.catch_(() => require_Schema$1.succeed({}))));
@@ -303348,10 +303680,7 @@ const cmmdForgeRuntimesDestroyRouteLayer = add$1("POST", "/api/cmmd/forge-runtim
303348
303680
  code: "CMMD_UNAVAILABLE"
303349
303681
  }, { status: 503 });
303350
303682
  const upstream = upstreamOrError.res;
303351
- if (upstream.status === 401 || upstream.status === 403) return buildCmmdAuthErrorResponse({
303352
- code: "CMMD_AUTH_REQUIRED",
303353
- message: "CMMD authentication expired. Sign in again to continue."
303354
- });
303683
+ if (upstream.status === 401 || upstream.status === 403) return yield* respondCmmdConnectionRequired(session.sessionId);
303355
303684
  const bodyOrError = yield* require_Schema$1.tryPromise(() => upstream.text()).pipe(require_Schema$1.map((text) => ({
303356
303685
  ok: true,
303357
303686
  text
@@ -303373,6 +303702,7 @@ const cmmdForgeRuntimesDestroyRouteLayer = add$1("POST", "/api/cmmd/forge-runtim
303373
303702
  headers: { "content-type": "application/json" }
303374
303703
  });
303375
303704
  }).pipe(require_Schema$1.catchTag("AuthError", (error) => respondToAuthError(error))));
303705
+ const cmmdProxyRouteLayers = registeredProxyRouteLayers().slice(__cmmdProxyRouteLayersStartIndex);
303376
303706
  //#endregion
303377
303707
  //#region src/cmmdData/projectTeamProxyRoutes.ts
303378
303708
  const cmmdListWorkspaceMembersRouteLayer = registerProxyRoute({
@@ -304615,6 +304945,103 @@ function recordRuntimeReplicationOutboxDiagnostics(diagnostics, now = Date.now()
304615
304945
  ]).pipe(require_Schema$1.asVoid);
304616
304946
  }
304617
304947
  //#endregion
304948
+ //#region src/runtimeReplication/pendingLifecycleIntents.ts
304949
+ /**
304950
+ * The newest moment a person or a turn touched this thread, mirroring the
304951
+ * client's `threadLastActivityAt` over the full thread rather than its shell:
304952
+ * the shell's `latestUserMessageAt` is projected from exactly these messages.
304953
+ */
304954
+ function readModelThreadLastActivityAt(thread) {
304955
+ const candidates = [
304956
+ ...thread.messages.filter((message) => message.role === "user").map((m) => m.createdAt),
304957
+ thread.latestTurn?.requestedAt,
304958
+ thread.latestTurn?.startedAt,
304959
+ thread.latestTurn?.completedAt
304960
+ ];
304961
+ let latest = null;
304962
+ let latestTimestamp = Number.NEGATIVE_INFINITY;
304963
+ for (const candidate of candidates) {
304964
+ if (candidate === null || candidate === void 0) continue;
304965
+ const timestamp = Date.parse(candidate);
304966
+ if (timestamp > latestTimestamp) {
304967
+ latest = candidate;
304968
+ latestTimestamp = timestamp;
304969
+ }
304970
+ }
304971
+ return latest;
304972
+ }
304973
+ function intentIsSpent(thread, intent) {
304974
+ const lastActivityAt = readModelThreadLastActivityAt(thread);
304975
+ if (lastActivityAt === null) return false;
304976
+ const activity = Date.parse(lastActivityAt);
304977
+ const requested = Date.parse(intent.requestedAt);
304978
+ return Number.isFinite(activity) && Number.isFinite(requested) && activity > requested;
304979
+ }
304980
+ function commandFor(runtimeId, intent) {
304981
+ const commandId = lifecycleIntentCommandId(runtimeId, intent.threadId, intent.requestedAt);
304982
+ const threadId = ThreadId.make(intent.threadId);
304983
+ return intent.action === "settle" ? {
304984
+ type: "thread.settle",
304985
+ commandId,
304986
+ threadId,
304987
+ settledOverride: "settled"
304988
+ } : {
304989
+ type: "thread.unsettle",
304990
+ commandId,
304991
+ threadId
304992
+ };
304993
+ }
304994
+ const applyOne = require_Schema$1.fn("applyLifecycleIntent")(function* (runtimeId, intent, dependencies) {
304995
+ const base = {
304996
+ runtimeId,
304997
+ threadId: intent.threadId,
304998
+ action: intent.action,
304999
+ requestedAt: intent.requestedAt
305000
+ };
305001
+ const report = (outcome, detail) => dependencies.log({
305002
+ ...base,
305003
+ outcome,
305004
+ ...detail === void 0 ? {} : { detail }
305005
+ }).pipe(require_Schema$1.as(outcome));
305006
+ const thread = (yield* dependencies.getReadModel()).threads.find((candidate) => candidate.id === intent.threadId);
305007
+ if (thread === void 0) return yield* report("missing-thread");
305008
+ if (intentIsSpent(thread, intent)) return yield* report("spent");
305009
+ return yield* dependencies.dispatch(commandFor(runtimeId, intent)).pipe(require_Schema$1.flatMap(() => report("applied")), require_Schema$1.catch_((error) => error._tag === "OrchestrationCommandInvariantError" || error._tag === "OrchestrationCommandPreviouslyRejectedError" ? report("refused", error.detail) : report("failed", error.message)));
305010
+ });
305011
+ /**
305012
+ * One tick: list, apply each, acknowledge everything that got an answer.
305013
+ *
305014
+ * A signed-out owner is not an error to retry into the log every five
305015
+ * minutes; it is a state the desktop leaves when someone signs in, so it is
305016
+ * logged once at info and the tick ends. Any other listing or acknowledgement
305017
+ * failure is returned typed, and the intents stay pending on CMMD.
305018
+ */
305019
+ function applyPendingLifecycleIntents(input, dependencies) {
305020
+ return require_Schema$1.gen(function* () {
305021
+ const intents = yield* dependencies.listPending();
305022
+ if (intents.length === 0) return;
305023
+ const answered = [];
305024
+ for (const intent of intents) if ((yield* applyOne(input.runtimeId, intent, dependencies)) !== "failed") answered.push({
305025
+ threadId: intent.threadId,
305026
+ requestedAt: intent.requestedAt
305027
+ });
305028
+ if (answered.length === 0) return;
305029
+ yield* dependencies.acknowledge(answered);
305030
+ }).pipe(require_Schema$1.catch_((error) => error.kind === "auth" ? require_Schema$1.logInfo("Lifecycle intents skipped: CMMD sign-in is required.", {
305031
+ runtimeId: input.runtimeId,
305032
+ code: error.code
305033
+ }) : require_Schema$1.fail(error)));
305034
+ }
305035
+ /**
305036
+ * One structured line per intent, so a row that "came back" after a wake can
305037
+ * be explained from the log: applied, refused by the decider, or spent by
305038
+ * newer activity.
305039
+ */
305040
+ function logLifecycleIntentOutcome(outcome) {
305041
+ const message = `Lifecycle intent ${outcome.outcome}.`;
305042
+ return outcome.outcome === "refused" || outcome.outcome === "failed" ? require_Schema$1.logWarning(message, outcome) : require_Schema$1.logInfo(message, outcome);
305043
+ }
305044
+ //#endregion
304618
305045
  //#region src/runtimeReplication/processOutboxItem.ts
304619
305046
  function publicationMetricAttributes(item, outcome, failure) {
304620
305047
  return {
@@ -304811,6 +305238,31 @@ const RuntimeReplicationLive = require_Schema$1.effect(RuntimeReplication, requi
304811
305238
  }).pipe(require_Schema$1.asVoid, require_Schema$1.catchCause((cause) => require_Schema$1.logError("Runtime replication reconciliation failed.", { cause })));
304812
305239
  const heartbeat = enqueueAll.pipe(require_Schema$1.repeat(require_Schema$1.spaced("5 minutes")), require_Schema$1.forkScoped);
304813
305240
  /**
305241
+ * Settle and un-settle requests a person recorded in CMMD while this
305242
+ * runtime was offline. The first tick runs at once, which is the
305243
+ * startup case (this phase starts after the orchestration reactors);
305244
+ * every heartbeat after that picks up requests made while awake. The
305245
+ * tick handles its own expected failures; the supervisor restarts the
305246
+ * schedule if it ever dies between ticks.
305247
+ */
305248
+ const lifecycleIntents = runSupervisedRepeat({
305249
+ label: "Lifecycle intent applier",
305250
+ work: applyPendingLifecycleIntents({ runtimeId }, {
305251
+ listPending: () => client.listPendingLifecycleIntents({ runtimeId }),
305252
+ acknowledge: (intents) => client.acknowledgeLifecycleIntents({
305253
+ runtimeId,
305254
+ intents
305255
+ }),
305256
+ dispatch: engine.dispatch,
305257
+ getReadModel: engine.getReadModel,
305258
+ log: logLifecycleIntentOutcome
305259
+ }).pipe(require_Schema$1.catchCause((cause) => require_Schema$1.logError("Lifecycle intent tick failed.", {
305260
+ cause,
305261
+ runtimeId
305262
+ }))),
305263
+ interval: "5 minutes"
305264
+ }).pipe(require_Schema$1.forkScoped);
305265
+ /**
304814
305266
  * Closes and reports whatever Active Hour interval is currently open,
304815
305267
  * every 5 minutes -- the same cadence as the inventory heartbeat, not
304816
305268
  * because the two are related, but because it is a reasonable default
@@ -304865,6 +305317,7 @@ const RuntimeReplicationLive = require_Schema$1.effect(RuntimeReplication, requi
304865
305317
  reactor,
304866
305318
  providerReactor,
304867
305319
  heartbeat,
305320
+ lifecycleIntents,
304868
305321
  activeHourFlush,
304869
305322
  worker,
304870
305323
  observeOutbox
@@ -314280,7 +314733,7 @@ const MiscRuntimeLayerLive = require_Schema$1.mergeAll(AnalyticsServiceLayerLive
314280
314733
  const RuntimeDependenciesWithoutPullRequestsLive = ReactorLayerLive.pipe(require_Schema$1.provideMerge(CheckpointingLayerLive), require_Schema$1.provideMerge(GitLayerLive), require_Schema$1.provideMerge(OrchestrationLayerLive), require_Schema$1.provideMerge(ProviderLayerLive), require_Schema$1.provideMerge(TerminalLayerLive), require_Schema$1.provideMerge(AgentBrowserManagerLive), require_Schema$1.provideMerge(require_Schema$1.mergeAll(ThreadDevRuntimeLive, DevTunnelLive.pipe(require_Schema$1.provide$1(ThreadDevRuntimeLive)))), require_Schema$1.provideMerge(PersistenceLayerLive), require_Schema$1.provideMerge(KeybindingsLive), require_Schema$1.provideMerge(ProviderRegistryLive), require_Schema$1.provideMerge(require_Schema$1.mergeAll(ServerSettingsLive, UsageServiceLive.pipe(require_Schema$1.provide$1(ServerSettingsLive), require_Schema$1.provide$1(UsageSessionLookupLive), require_Schema$1.provide$1(UsageRecordedSourceLive.pipe(require_Schema$1.provide$1(OrchestrationLayerLive), require_Schema$1.provide$1(RuntimeReplicationOutboxLive), require_Schema$1.provide$1(ProviderSessionRuntimeRepositoryLive), require_Schema$1.provide$1(TextGenerationSessionRepositoryLive)))))), require_Schema$1.provideMerge(WorkspaceLayerLive), require_Schema$1.provideMerge(WorkspaceReadinessStateLive), require_Schema$1.provideMerge(ProjectFaviconResolverLive), require_Schema$1.provideMerge(RepositoryIdentityResolverLive), require_Schema$1.provideMerge(ServerEnvironmentLive), require_Schema$1.provideMerge(AuthLayerLive), require_Schema$1.provideMerge(ServerSecretStoreLayerLive), require_Schema$1.provideMerge(require_Schema$1.mergeAll(CloudRedisCoordinationLive, CloudStateSyncLive.pipe(require_Schema$1.provide$1(PersistenceLayerLive)))), require_Schema$1.provideMerge(MiscRuntimeLayerLive));
314281
314734
  const RuntimeDependenciesLive = pullRequestServiceFactoryLayer.pipe(require_Schema$1.provideMerge(RuntimeDependenciesWithoutPullRequestsLive), require_Schema$1.provideMerge(cmmdProjectIdentityResolverLive.pipe(require_Schema$1.provide$1(RuntimeDependenciesWithoutPullRequestsLive))), require_Schema$1.provideMerge(pullRequestProviderRuntimeLive));
314282
314735
  const RuntimeServicesLive = ServerRuntimeStartupLive.pipe(require_Schema$1.provideMerge(RuntimeDependenciesLive));
314283
- const makeRoutesLayer = require_Schema$1.mergeAll(authBearerBootstrapRouteLayer, authBootstrapRouteLayer, authCommandBearerBootstrapRouteLayer, authCommandBootstrapRouteLayer, authOAuthTokenExchangeRouteLayer, authWebSocketTicketRouteLayer, authCmmdOAuthDeviceRouteLayer, authCmmdOAuthTokenRouteLayer, authCmmdPasswordTokenRouteLayer, authClientsRevokeOthersRouteLayer, authClientsRevokeRouteLayer, authClientsRouteLayer, authLogoutRouteLayer, authPairingLinksRevokeRouteLayer, authPairingLinksRouteLayer, authPairingCredentialRouteLayer, authSessionRouteLayer, authWebSocketTokenRouteLayer, authWebLoginRouteLayer, authWebCallbackRouteLayer, desktopLocalWebBridgePublishRouteLayer, desktopLocalWebBridgeBootstrapRouteLayer, desktopRelayControlPlaneRouteLayer, apiDocsHtmlRouteLayer, apiDocsOpenApiRouteLayer, pulseSignalStateListRouteLayer, pulseSignalStateUpsertRouteLayer, cmmdProfileRouteLayer, cmmdCreateBrainDocRouteLayer, cmmdUpdateTaskRouteLayer, cmmdUpsertTaskPullRequestRouteLayer, ...cmmdPullRequestRouteLayers, cmmdAddTaskCommentRouteLayer, cmmdWorkIntakeRouteLayer, cmmdWsTokenRouteLayer, cmmdSearchTasksRouteLayer, cmmdGetTaskCommentsRouteLayer, cmmdGetProjectCommentsRouteLayer, cmmdAddProjectCommentRouteLayer, cmmdUpdateProjectRouteLayer, cmmdGetOrgMembersRouteLayer, cmmdSimHostsRouteLayer, cmmdSimLeaseReadRouteLayer, cmmdSimLeaseClaimRouteLayer, cmmdSimLeaseReleaseRouteLayer, cmmdSimLeaseRenewRouteLayer, cmmdUploadTaskAttachmentRouteLayer, cmmdGetTaskAttachmentsRouteLayer, cmmdUpdateTaskCommentRouteLayer, cmmdDeleteTaskCommentRouteLayer, cmmdGetProjectRepositoryRouteLayer, cmmdListProjectRepositoriesRouteLayer, cmmdArchiveTaskRouteLayer, cmmdUnarchiveTaskRouteLayer, cmmdListTasksRouteLayer, cmmdCreateTaskRouteLayer, cmmdListCampaignsRouteLayer, cmmdGetCampaignRouteLayer, cmmdCreateCampaignRouteLayer, cmmdUpdateCampaignRouteLayer, cmmdDeleteCampaignRouteLayer, cmmdListSavedViewsRouteLayer, cmmdCreateSavedViewRouteLayer, cmmdImportSavedViewRouteLayer, cmmdUpdateSavedViewRouteLayer, cmmdDeleteSavedViewRouteLayer, cmmdListProjectsRouteLayer, cmmdGetProjectRouteLayer, cmmdCreateProjectRouteLayer, cmmdDeleteProjectRouteLayer, cmmdMoveProjectRouteLayer, cmmdGetProjectMembersRouteLayer, cmmdListWorkspaceMembersRouteLayer, cmmdAddProjectMemberRouteLayer, cmmdGetProjectMilestonesRouteLayer, cmmdCreateProjectMilestoneRouteLayer, cmmdUpdateProjectMilestoneRouteLayer, cmmdDeleteProjectMilestoneRouteLayer, cmmdGetProjectUpdatesRouteLayer, cmmdCreateProjectUpdateRouteLayer, cmmdUpdateProjectUpdateRouteLayer, cmmdDeleteProjectUpdateRouteLayer, cmmdImproveProjectContentRouteLayer, cmmdCreateProjectTaskDraftRouteLayer, cmmdGetProjectTaskDraftRouteLayer, cmmdUpdateProjectTaskDraftRouteLayer, cmmdPreviewProjectTaskDraftRouteLayer, cmmdCommitProjectTaskDraftRouteLayer, cmmdDiscardProjectTaskDraftRouteLayer, cmmdGetProjectLeadPlanRouteLayer, cmmdActivateProjectLeadAuthorityRouteLayer, cmmdGetProjectLeadReadinessRouteLayer, cmmdGetProjectLeadCapabilitiesRouteLayer, cmmdGetProjectLeadSummaryRouteLayer, cmmdGetProjectLeadDetailRouteLayer, cmmdGetProjectLeadBriefingRouteLayer, cmmdListProjectLeadEventsRouteLayer, cmmdExplainProjectLeadRouteLayer, cmmdPauseProjectLeadRouteLayer, cmmdResumeProjectLeadRouteLayer, cmmdReserveProjectLeadTaskRouteLayer, cmmdReleaseProjectLeadReservationRouteLayer, cmmdReconcileProjectLeadRouteLayer, cmmdResolveProjectLeadAttentionRouteLayer, cmmdClaimProjectLeadControllerRouteLayer, cmmdRenewProjectLeadControllerClaimRouteLayer, cmmdYieldProjectLeadControllerClaimRouteLayer, cmmdAcknowledgeProjectLeadControllerEventRouteLayer, cmmdRecordProjectLeadControllerDecisionRouteLayer, cmmdListForgeAutomationPresetsRouteLayer, cmmdListUserForgeAutomationRulesRouteLayer, cmmdCreateUserForgeAutomationRuleRouteLayer, cmmdUpdateUserForgeAutomationRuleRouteLayer, cmmdListUserForgeAutomationRunsRouteLayer, cmmdStartUserForgeAutomationRunRouteLayer, cmmdListForgeAutomationRulesRouteLayer, cmmdCreateForgeAutomationRuleRouteLayer, cmmdUpdateForgeAutomationRuleRouteLayer, cmmdListForgeAutomationRunsRouteLayer, cmmdStartForgeAutomationRunRouteLayer, cmmdGetForgeAutomationRunRouteLayer, cmmdRetryForgeAutomationRunRouteLayer, cmmdCancelForgeAutomationRunRouteLayer, cmmdApproveForgeAutomationEscalationRouteLayer, cmmdRejectForgeAutomationEscalationRouteLayer, cmmdListProjectAgentMembersRouteLayer, cmmdCreateProjectAgentMemberRouteLayer, cmmdGetProjectAgentMemberRouteLayer, cmmdRenameProjectAgentMemberRouteLayer, cmmdRetireProjectAgentMemberRouteLayer, cmmdUpdateProjectAgentMemberAvatarRouteLayer, cmmdListProjectAgentMemberInstancesRouteLayer, cmmdPreviewProjectAgentMemberConsolidationRouteLayer, cmmdApplyProjectAgentMemberConsolidationRouteLayer, cmmdPutProjectTaskAssignmentRouteLayer, cmmdListProjectBoardRouteLayer, cmmdGetProjectTaskWorkflowRouteLayer, cmmdUpdateProjectTaskWorkflowRouteLayer, cmmdCreateProjectBoardTaskRouteLayer, cmmdUpdateProjectBoardTaskRouteLayer, cmmdUpdateProjectBoardTaskStatusRouteLayer, cmmdListTaskExecutionOptionsRouteLayer, cmmdCreateTaskWorkSessionRouteLayer, cmmdListProjectWorkSessionsRouteLayer, cmmdGetWorkSessionRouteLayer, cmmdUpdateWorkSessionRouteLayer, cmmdAttachWorkSessionThreadRouteLayer, cmmdListTaskConversationsRouteLayer, cmmdLinkTaskConversationRouteLayer, cmmdGetTaskHistoryRouteLayer, cmmdGetTaskConversationRouteLayer, cmmdSpawnForgeThreadFromBoardTaskRouteLayer, cmmdListCenterBoardRouteLayer, cmmdCreateCenterBoardTaskRouteLayer, cmmdCreateFeedbackRouteLayer, cmmdUpdateCenterBoardTaskRouteLayer, cmmdMoveCenterBoardTaskRouteLayer, cmmdMoveProjectBoardTaskRouteLayer, cmmdArchiveProjectBoardTaskRouteLayer, cmmdUnarchiveProjectBoardTaskRouteLayer, cmmdArchiveCenterBoardTaskRouteLayer, cmmdUnarchiveCenterBoardTaskRouteLayer, cmmdBootstrapRouteLayer, cmmdGetAccountPreferencesRouteLayer, cmmdUpdateAccountPreferencesRouteLayer, cmmdGetOrgProviderPolicyRouteLayer, cmmdListChatsRouteLayer, cmmdGetChatRouteLayer, cmmdListDevicesRouteLayer, runtimeReplicationStatusRouteLayer, cmmdRegisterDeviceRouteLayer, cmmdHeartbeatRuntimeRouteLayer, cmmdGrantRuntimeAccessRouteLayer, cmmdRevokeRuntimeAccessRouteLayer, cmmdCreateRelayControlRouteLayer, cmmdCreateRelayActionGrantRouteLayer, cmmdReplaceRuntimeInventoryRouteLayer, cmmdListRuntimeInventoryRouteLayer, cmmdGetRuntimeDiagnosticsRouteLayer, cmmdProvisionAuthRuntimeRouteLayer, cmmdGetAuthRuntimeRouteLayer, cmmdDestroyAuthRuntimeRouteLayer, cmmdConnectAuthRuntimeRouteLayer, cmmdGetProviderAccountsRouteLayer, cmmdDeleteProviderAccountRouteLayer, cmmdSetProviderAccountDefaultRouteLayer, cmmdGetProviderUsageRouteLayer, cmmdRefreshProviderUsageRouteLayer, cmmdGetUserCodexCredentialRouteLayer, cmmdDeleteUserCodexCredentialRouteLayer, cmmdGetUserClaudeCredentialRouteLayer, cmmdDeleteUserClaudeCredentialRouteLayer, cmmdGetClaudeRuntimeReadinessRouteLayer, cmmdAppendRuntimeThreadEventsRouteLayer, cmmdGetRuntimeThreadReplicaRouteLayer, cmmdRenameDeviceRouteLayer, cmmdRevokeDeviceRouteLayer, cmmdInstallConnectorRouteLayer, cmmdListConnectorsRouteLayer, cmmdForgeCloudProjectsListRouteLayer, cmmdForgeCloudProjectsEventsRouteLayer, cmmdForgeCloudProjectRegisterRouteLayer, cmmdForgeCloudProjectUnregisterRouteLayer, cmmdForgeCloudProjectLifecyclePreflightRouteLayer, cmmdForgeCloudProjectRemovalRouteLayer, cmmdForgeCloudProjectRemovalPreviewRouteLayer, cmmdForgeCloudProjectRemovalReceiptRouteLayer, cmmdForgeRuntimesEnsureRouteLayer, cmmdForgeRuntimesConnectRouteLayer, ownerRuntimeCodexReadinessRouteLayer, cmmdForgeRuntimesStatusRouteLayer, cmmdForgeRuntimesStartRouteLayer, cmmdForgeRuntimesStopRouteLayer, cmmdForgeRuntimesRecycleRouteLayer, cmmdForgeRuntimesUpdateCommitRouteLayer, cmmdForgeRuntimesDestroyRouteLayer, cmmdRenameForgeRuntimeRouteLayer, cmmdGetTaskRouteLayer, commandUpdateTaskRouteLayer, mobileProviderCatalogRouteLayer, cmmdUsageSummaryRouteLayer, cmmdBillingRouteLayer, cmmdBillingSeriesRouteLayer, attachmentsRouteLayer, orchestrationDispatchRouteLayer, orchestrationCmmdWorkRunEventRouteLayer, orchestrationAutomationStartThreadRouteLayer, orchestrationAutomationRebindRouteLayer, orchestrationAutomationTerminalReconcileRouteLayer, mobileGitRunStackedActionRouteLayer, pullRequestDiffRouteLayer, orchestrationSnapshotRouteLayer, localAutomationListRouteLayer, localAutomationCreateRouteLayer, localAutomationUpdateRouteLayer, localAutomationDeleteRouteLayer, localAutomationRunRouteLayer, otlpTracesProxyRouteLayer, devTunnelProxyRouteLayer, devTunnelLocalPortProxyRouteLayer, projectFaviconRouteLayer, serverEnvironmentRouteLayer, browserWebRtcReadinessRouteLayer, staticAndDevRouteLayer, githubStatusRouteLayer, githubAuthorizeUrlRouteLayer, githubDisconnectRouteLayer, githubReposRouteLayer, githubCloneRouteLayer, githubCloneJobStartRouteLayer, githubCloneJobStatusRouteLayer, githubRefreshCredentialsRouteLayer, githubToolConfirmationApproveRouteLayer, projectLinkGetRouteLayer, projectLinkListRouteLayer, projectLinkSetRouteLayer, projectLinkDeleteRouteLayer, cmmdWorkspacesRouteLayer, cmmdCampaignsRouteLayer, cmmdProjectLinksRouteLayer, cmmdEnsureGitHubProjectContextRouteLayer, cmmdProjectRepositoryEnsureRouteLayer, cmmdProjectsGetRouteLayer, cmmdProjectsCreateRouteLayer, workspaceReadinessRouteLayer, runtimeLivenessRouteLayer, claudeNativeGenerationProofRouteLayer, claudeUsageRouteLayer, codexRuntimeProviderReadinessRouteLayer, runtimeDiagnosticsRouteLayer, cloudFoldersRouteLayer, cloudProjectCreateRouteLayer, gitUrlCloneRouteLayer, websocketRpcRouteLayer).pipe(require_Schema$1.provide$1(browserApiCorsLayer));
314736
+ const makeRoutesLayer = require_Schema$1.mergeAll(authBearerBootstrapRouteLayer, authBootstrapRouteLayer, authCommandBearerBootstrapRouteLayer, authCommandBootstrapRouteLayer, authOAuthTokenExchangeRouteLayer, authWebSocketTicketRouteLayer, authCmmdOAuthDeviceRouteLayer, authCmmdOAuthTokenRouteLayer, authCmmdPasswordTokenRouteLayer, authClientsRevokeOthersRouteLayer, authClientsRevokeRouteLayer, authClientsRouteLayer, authLogoutRouteLayer, authPairingLinksRevokeRouteLayer, authPairingLinksRouteLayer, authPairingCredentialRouteLayer, authSessionRouteLayer, authWebSocketTokenRouteLayer, authWebLoginRouteLayer, authWebCallbackRouteLayer, desktopLocalWebBridgePublishRouteLayer, desktopLocalWebBridgeBootstrapRouteLayer, desktopRelayControlPlaneRouteLayer, apiDocsHtmlRouteLayer, apiDocsOpenApiRouteLayer, pulseSignalStateListRouteLayer, pulseSignalStateUpsertRouteLayer, cmmdProfileRouteLayer, ...cmmdProxyRouteLayers, cmmdWorkIntakeRouteLayer, cmmdWsTokenRouteLayer, cmmdGetProjectCommentsRouteLayer, cmmdAddProjectCommentRouteLayer, cmmdUpdateProjectRouteLayer, cmmdUploadTaskAttachmentRouteLayer, cmmdUpdateTaskCommentRouteLayer, cmmdListWorkspaceMembersRouteLayer, cmmdAddProjectMemberRouteLayer, cmmdUpdateProjectAgentMemberAvatarRouteLayer, runtimeReplicationStatusRouteLayer, cmmdRefreshProviderUsageRouteLayer, cmmdForgeCloudProjectsListRouteLayer, cmmdForgeCloudProjectsEventsRouteLayer, cmmdForgeRuntimesEnsureRouteLayer, cmmdForgeRuntimesConnectRouteLayer, ownerRuntimeCodexReadinessRouteLayer, cmmdForgeRuntimesStatusRouteLayer, cmmdForgeRuntimesStartRouteLayer, cmmdForgeRuntimesStopRouteLayer, cmmdForgeRuntimesRecycleRouteLayer, cmmdForgeRuntimesUpdateCommitRouteLayer, cmmdForgeRuntimesDestroyRouteLayer, mobileProviderCatalogRouteLayer, attachmentsRouteLayer, orchestrationDispatchRouteLayer, orchestrationCmmdWorkRunEventRouteLayer, orchestrationAutomationStartThreadRouteLayer, orchestrationAutomationRebindRouteLayer, orchestrationAutomationTerminalReconcileRouteLayer, mobileGitRunStackedActionRouteLayer, pullRequestDiffRouteLayer, orchestrationSnapshotRouteLayer, localAutomationListRouteLayer, localAutomationCreateRouteLayer, localAutomationUpdateRouteLayer, localAutomationDeleteRouteLayer, localAutomationRunRouteLayer, otlpTracesProxyRouteLayer, devTunnelProxyRouteLayer, devTunnelLocalPortProxyRouteLayer, projectFaviconRouteLayer, serverEnvironmentRouteLayer, browserWebRtcReadinessRouteLayer, staticAndDevRouteLayer, githubStatusRouteLayer, githubAuthorizeUrlRouteLayer, githubDisconnectRouteLayer, githubReposRouteLayer, githubCloneRouteLayer, githubCloneJobStartRouteLayer, githubCloneJobStatusRouteLayer, githubRefreshCredentialsRouteLayer, githubToolConfirmationApproveRouteLayer, projectLinkGetRouteLayer, projectLinkListRouteLayer, projectLinkSetRouteLayer, projectLinkDeleteRouteLayer, cmmdWorkspacesRouteLayer, cmmdCampaignsRouteLayer, cmmdProjectLinksRouteLayer, cmmdEnsureGitHubProjectContextRouteLayer, cmmdProjectRepositoryEnsureRouteLayer, cmmdProjectsGetRouteLayer, cmmdProjectsCreateRouteLayer, workspaceReadinessRouteLayer, runtimeLivenessRouteLayer, claudeNativeGenerationProofRouteLayer, claudeUsageRouteLayer, codexRuntimeProviderReadinessRouteLayer, runtimeDiagnosticsRouteLayer, cloudFoldersRouteLayer, cloudProjectCreateRouteLayer, gitUrlCloneRouteLayer, websocketRpcRouteLayer).pipe(require_Schema$1.provide$1(browserApiCorsLayer));
314284
314737
  const makeServerLayer = require_Schema$1.unwrap(require_Schema$1.gen(function* () {
314285
314738
  const config = yield* ServerConfig;
314286
314739
  fixPath({ preferProcessPath: config.forgeCmmdRuntimeMode === true });