@cmmd-center/forge 0.13.15 → 0.13.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.mjs CHANGED
@@ -11,7 +11,7 @@ import { a as make$51, i as keys, n as getOption, o as makeWith$1, r as invalida
11
11
  import { S as layer$9, _ as defaultEscape, a as DeadlockError, b as makeCompiler$1, c as SqlError, d as UnknownError, g as custom, h as make$52, i as ConstraintError, l as SqlSyntaxError, m as SqlClient, n as AuthorizationError, o as LockTimeoutError, r as ConnectionError, s as SerializationError, t as AuthenticationError, u as StatementTimeoutError, v as defaultTransforms, y as fragment } from "./SqlError-BMBkezUO.mjs";
12
12
  import { r as wrapper_default, t as Mime_default } from "./Mime-Dq9IoNiV.mjs";
13
13
  import { a as diag, c as SpanKind$1, d as TraceFlags, f as ROOT_CONTEXT, i as propagation, l as isSpanContextValid, m as DiagLogLevel, n as init_esm$1, o as context$1, p as createContextKey, r as trace, s as SpanStatusCode, t as esm_exports$1 } from "./esm-wLIF-u3N.mjs";
14
- import { a as verifyCmmdAuthRuntimeTicket, c as verifyCmmdRuntimeTicket, d as runtimeGrantToken, f as setRuntimeGrantToken, i as sendRuntimeControlHeartbeat, l as verifyCmmdRuntimeTicketRefreshProof, n as bootstrapRuntimeControlAuthorityFromNarrowGrant, o as verifyCmmdClaudeReadinessTicket, p as createReadOnceFileTokenAccessor, r as readRuntimeControlAuthority, s as verifyCmmdClaudeUsageTicket, t as bootstrapRuntimeControlAuthority, u as verifyCmmdScopedRuntimePayload } from "./runtimeControlAuthority-E_kdeD_P.mjs";
14
+ import { a as verifyCmmdAuthRuntimeTicket, c as verifyCmmdRuntimeTicket, d as runtimeGrantToken, f as setRuntimeGrantToken, i as sendRuntimeControlHeartbeat, l as verifyCmmdRuntimeTicketRefreshProof, n as bootstrapRuntimeControlAuthorityFromNarrowGrant, o as verifyCmmdClaudeReadinessTicket, p as createReadOnceFileTokenAccessor, r as readRuntimeControlAuthority, s as verifyCmmdClaudeUsageTicket, t as bootstrapRuntimeControlAuthority, u as verifyCmmdScopedRuntimePayload } from "./runtimeControlAuthority-DpRIoWqP.mjs";
15
15
  import { n as PtySpawnError, t as PtyAdapter } from "./PTY-BzdbZ0Ym.mjs";
16
16
  import { createRequire } from "node:module";
17
17
  import * as HE from "node:child_process";
@@ -22,7 +22,7 @@ import { createCipheriv, createDecipheriv, createHash, createHmac, createPublicK
22
22
  import * as FS$1 from "node:fs";
23
23
  import fs, { accessSync, chmodSync, constants, createReadStream, existsSync, mkdirSync, mkdtempSync, promises, readFile, readFileSync, readdir, readdirSync, realpathSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
24
24
  import * as NodeOS from "node:os";
25
- import os, { homedir, networkInterfaces, tmpdir } from "node:os";
25
+ import $U, { homedir, networkInterfaces, tmpdir } from "node:os";
26
26
  import * as Path$1 from "node:path";
27
27
  import path, { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
28
28
  import { pathToFileURL } from "node:url";
@@ -50735,7 +50735,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
50735
50735
  const min = forceColor || 0;
50736
50736
  if (env.TERM === "dumb") return min;
50737
50737
  if (process$1.platform === "win32") {
50738
- const osRelease = os.release().split(".");
50738
+ const osRelease = $U.release().split(".");
50739
50739
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
50740
50740
  return 1;
50741
50741
  }
@@ -53178,7 +53178,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
53178
53178
  exports.processDetector = void 0;
53179
53179
  const api_1 = (init_esm$1(), __toCommonJS(esm_exports$1));
53180
53180
  const semconv_1 = require_semconv$1();
53181
- const os$4 = __require("os");
53181
+ const os$3 = __require("os");
53182
53182
  /**
53183
53183
  * ProcessDetector will be used to detect the resources related current process running
53184
53184
  * and being instrumented from the NodeJS Process module.
@@ -53200,7 +53200,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
53200
53200
  };
53201
53201
  if (process.argv.length > 1) attributes[semconv_1.ATTR_PROCESS_COMMAND] = process.argv[1];
53202
53202
  try {
53203
- const userInfo = os$4.userInfo();
53203
+ const userInfo = os$3.userInfo();
53204
53204
  attributes[semconv_1.ATTR_PROCESS_OWNER] = userInfo.username;
53205
53205
  } catch (e) {
53206
53206
  api_1.diag.debug(`error obtaining process owner: ${e}`);
@@ -66123,7 +66123,7 @@ function normalizeNumberish(value) {
66123
66123
  }
66124
66124
  //#endregion
66125
66125
  //#region package.json
66126
- var version$1 = "0.13.15";
66126
+ var version$1 = "0.13.16";
66127
66127
  //#endregion
66128
66128
  //#region src/sentry.ts
66129
66129
  const SERVER_APP_NAME = "forge-server";
@@ -75971,7 +75971,7 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
75971
75971
  var fs$6 = __require("fs");
75972
75972
  var path$5 = __require("path");
75973
75973
  var url$1 = __require("url");
75974
- var os$3 = __require("os");
75974
+ var os$2 = __require("os");
75975
75975
  var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
75976
75976
  var vars = process.config && process.config.variables || {};
75977
75977
  var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
@@ -75979,8 +75979,8 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
75979
75979
  var abi = versions.modules;
75980
75980
  if (versions.deno || process.isBun) abi = "unsupported";
75981
75981
  var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
75982
- var arch = process.env.npm_config_arch || os$3.arch();
75983
- var platform = process.env.npm_config_platform || os$3.platform();
75982
+ var arch = process.env.npm_config_arch || os$2.arch();
75983
+ var platform = process.env.npm_config_platform || os$2.platform();
75984
75984
  var libc = process.env.LIBC || (isMusl(platform) ? "musl" : "glibc");
75985
75985
  var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
75986
75986
  var uv = (versions.uv || "").split(".")[0];
@@ -94162,7 +94162,7 @@ const launchDetached = (launch) => gen(function* () {
94162
94162
  });
94163
94163
  const OpenLive = effect(Open, gen(function* () {
94164
94164
  const open = yield* tryPromise({
94165
- try: () => import("./open-FIgTDosf.mjs"),
94165
+ try: () => import("./open-D8mGyWmt.mjs"),
94166
94166
  catch: (cause) => new OpenError$1({
94167
94167
  message: "failed to load browser opener",
94168
94168
  cause
@@ -96683,6 +96683,7 @@ const registerCloudRuntimeForReplicaHydration = gen(function* () {
96683
96683
  credentialEpoch,
96684
96684
  activeTurnCount: 0,
96685
96685
  activeSessionCount: 0,
96686
+ acceptingTurns: false,
96686
96687
  ...forgeGitCommit !== void 0 ? { forgeGitCommit } : {},
96687
96688
  forgeServerVersion: installedForgeServerVersion
96688
96689
  }),
@@ -96719,6 +96720,128 @@ const hydrateCloudRuntimeReplica = gen(function* () {
96719
96720
  return yield* hydrateRuntimeReplica({ expectedRuntimeId: grant.runtimeId }, dependencies);
96720
96721
  });
96721
96722
  //#endregion
96723
+ //#region src/runtimeDrain/RuntimeDrainState.ts
96724
+ /**
96725
+ * The positive facts this process must observe before it can claim a turn.
96726
+ *
96727
+ * Every entry is required, so adding one here is the whole change: the
96728
+ * derivation below reads this list rather than naming fields, and the record
96729
+ * it indexes cannot be built with a member missing.
96730
+ */
96731
+ const RUNTIME_EXECUTION_PRECONDITIONS = ["orchestrationEngine", "providerLayer"];
96732
+ /**
96733
+ * The single definition of the accepting-turns fact.
96734
+ *
96735
+ * Exported so test stubs of this service derive it exactly as the live state
96736
+ * does. A stub that recomputed it by hand could disagree with production and
96737
+ * still pass.
96738
+ */
96739
+ function deriveAcceptingTurns(input) {
96740
+ return RUNTIME_EXECUTION_PRECONDITIONS.every((precondition) => input.preconditions[precondition]) && !input.draining && !input.shutdownRequested;
96741
+ }
96742
+ const initialState = {
96743
+ activeTurns: /* @__PURE__ */ new Set(),
96744
+ activeTurnCount: 0,
96745
+ activeSessionCount: 0,
96746
+ draining: false,
96747
+ drainReason: null,
96748
+ drainTargetImageRef: null,
96749
+ drainTargetImageVersion: null,
96750
+ drainForceRequired: false,
96751
+ preconditions: {
96752
+ orchestrationEngine: false,
96753
+ providerLayer: false
96754
+ },
96755
+ shutdownRequested: false
96756
+ };
96757
+ function snapshotFromState(state) {
96758
+ return {
96759
+ activeTurnCount: state.activeTurnCount,
96760
+ activeSessionCount: state.activeSessionCount,
96761
+ draining: state.draining,
96762
+ drainReason: state.drainReason,
96763
+ drainTargetImageRef: state.drainTargetImageRef,
96764
+ drainTargetImageVersion: state.drainTargetImageVersion,
96765
+ drainForceRequired: state.drainForceRequired,
96766
+ acceptingTurns: deriveAcceptingTurns(state)
96767
+ };
96768
+ }
96769
+ function turnKey(input) {
96770
+ return `${input.threadId}:${input.turnId ?? "unknown"}`;
96771
+ }
96772
+ function normalizeCount(count) {
96773
+ return Number.isFinite(count) ? Math.max(0, Math.floor(count)) : 0;
96774
+ }
96775
+ const makeRuntimeDrainState = gen(function* () {
96776
+ const stateRef = yield* make$50(initialState);
96777
+ const update = (f) => updateAndGet(stateRef, f).pipe(map$3(snapshotFromState));
96778
+ return {
96779
+ beginTurn: (input) => update((state) => {
96780
+ const activeTurns = new Set(state.activeTurns);
96781
+ activeTurns.add(turnKey(input));
96782
+ return {
96783
+ ...state,
96784
+ activeTurns,
96785
+ activeTurnCount: activeTurns.size
96786
+ };
96787
+ }),
96788
+ completeTurn: (input) => update((state) => {
96789
+ const activeTurns = new Set(state.activeTurns);
96790
+ activeTurns.delete(turnKey(input));
96791
+ return {
96792
+ ...state,
96793
+ activeTurns,
96794
+ activeTurnCount: activeTurns.size
96795
+ };
96796
+ }),
96797
+ clearActiveTurns: update((state) => ({
96798
+ ...state,
96799
+ activeTurns: /* @__PURE__ */ new Set(),
96800
+ activeTurnCount: 0
96801
+ })),
96802
+ setActiveSessionCount: (count) => update((state) => ({
96803
+ ...state,
96804
+ activeSessionCount: normalizeCount(count)
96805
+ })),
96806
+ reconcileProviderSessions: (sessions) => update((state) => {
96807
+ const activeSessions = sessions.filter((session) => session.status !== "closed");
96808
+ const activeTurns = new Set(activeSessions.flatMap((session) => session.activeTurnId === void 0 ? [] : [turnKey({
96809
+ threadId: session.threadId,
96810
+ turnId: session.activeTurnId
96811
+ })]));
96812
+ return {
96813
+ ...state,
96814
+ activeTurns,
96815
+ activeTurnCount: activeTurns.size,
96816
+ activeSessionCount: activeSessions.length
96817
+ };
96818
+ }),
96819
+ applyControlPlaneState: (input) => update((state) => ({
96820
+ ...state,
96821
+ draining: input.draining ?? state.draining,
96822
+ drainReason: input.drainReason ?? state.drainReason,
96823
+ drainTargetImageRef: input.drainTargetImageRef ?? state.drainTargetImageRef,
96824
+ drainTargetImageVersion: input.drainTargetImageVersion ?? state.drainTargetImageVersion,
96825
+ drainForceRequired: input.drainForceRequired ?? state.drainForceRequired
96826
+ })),
96827
+ markExecutionPrecondition: (precondition) => update((state) => ({
96828
+ ...state,
96829
+ preconditions: {
96830
+ ...state.preconditions,
96831
+ [precondition]: true
96832
+ }
96833
+ })),
96834
+ requestShutdown: update((state) => ({
96835
+ ...state,
96836
+ shutdownRequested: true
96837
+ })),
96838
+ snapshot: get$6(stateRef).pipe(map$3(snapshotFromState)),
96839
+ isDraining: get$6(stateRef).pipe(map$3((state) => state.draining))
96840
+ };
96841
+ });
96842
+ var RuntimeDrainState = class extends Service$1()("forge/runtimeDrain/RuntimeDrainState") {};
96843
+ const RuntimeDrainStateLive = effect(RuntimeDrainState, makeRuntimeDrainState);
96844
+ //#endregion
96722
96845
  //#region src/persistence/Services/LocalAutomations.ts
96723
96846
  const LocalAutomationStatus = Literals([
96724
96847
  "active",
@@ -100352,6 +100475,30 @@ const makeCommandGate = gen(function* () {
100352
100475
  })
100353
100476
  };
100354
100477
  });
100478
+ /**
100479
+ * Settle the command gate for a finished startup, and report whether commands
100480
+ * are now accepted.
100481
+ *
100482
+ * The success branch is the moment the orchestration engine can take work, so
100483
+ * it is where the engine half of the accepting-turns fact is marked. A failed
100484
+ * startup accepts nothing and must leave the fact untouched: absent must not
100485
+ * read as healthy.
100486
+ */
100487
+ const settleCommandReadiness = (input) => gen(function* () {
100488
+ if (isFailure(input.startupExit)) {
100489
+ const error = new ServerRuntimeStartupError({
100490
+ message: startupFailureMessage(input.startupExit.cause),
100491
+ cause: input.startupExit.cause
100492
+ });
100493
+ yield* logError("server runtime startup failed", { cause: describeStartupFailure(input.startupExit.cause) });
100494
+ yield* input.commandGate.failCommandReady(error);
100495
+ return false;
100496
+ }
100497
+ yield* logDebug("Accepting commands");
100498
+ yield* input.commandGate.signalCommandReady;
100499
+ yield* input.drainState.markExecutionPrecondition("orchestrationEngine");
100500
+ return true;
100501
+ });
100355
100502
  const launchStartupHeartbeat = gen(function* () {
100356
100503
  const analytics = yield* AnalyticsService;
100357
100504
  const { threadCount, projectCount } = yield* (yield* ProjectionSnapshotQuery).getCounts().pipe(catch_((cause) => logWarning$1("failed to gather startup projection counts for telemetry", { cause }).pipe(as$3({
@@ -100532,6 +100679,7 @@ const ServerRuntimeStartupLive = effect(ServerRuntimeStartup, gen(function* () {
100532
100679
  const serverSettings = yield* ServerSettingsService;
100533
100680
  const serverEnvironment = yield* ServerEnvironment;
100534
100681
  const usage = yield* UsageService;
100682
+ const drainState = yield* RuntimeDrainState;
100535
100683
  const commandGate = yield* makeCommandGate;
100536
100684
  const httpListening = yield* make$39();
100537
100685
  const reactorScope = yield* make$37("sequential");
@@ -100614,18 +100762,11 @@ const ServerRuntimeStartupLive = effect(ServerRuntimeStartup, gen(function* () {
100614
100762
  root: true
100615
100763
  }));
100616
100764
  yield* forkScoped(gen(function* () {
100617
- const startupExit = yield* exit(startup);
100618
- if (isFailure(startupExit)) {
100619
- const error = new ServerRuntimeStartupError({
100620
- message: startupFailureMessage(startupExit.cause),
100621
- cause: startupExit.cause
100622
- });
100623
- yield* logError("server runtime startup failed", { cause: describeStartupFailure(startupExit.cause) });
100624
- yield* commandGate.failCommandReady(error);
100625
- return;
100626
- }
100627
- yield* logDebug("Accepting commands");
100628
- yield* commandGate.signalCommandReady;
100765
+ if (!(yield* settleCommandReadiness({
100766
+ startupExit: yield* exit(startup),
100767
+ commandGate,
100768
+ drainState
100769
+ }))) return;
100629
100770
  yield* logDebug("startup phase: starting the usage scan warm-up");
100630
100771
  yield* forkScoped(runUsageScanWarmup({ readSummary: usage.readSummary }));
100631
100772
  yield* logDebug("startup phase: waiting for http listener");
@@ -153208,7 +153349,9 @@ var CodexAppServerManager = class extends EventEmitter$1 {
153208
153349
  scheduleProviderEgressTokenRefresh(context, delayMs) {
153209
153350
  if (context.tokenRefreshTimer) clearTimeout(context.tokenRefreshTimer);
153210
153351
  const tokenRefreshTimer = setTimeout(() => {
153211
- this.handleProviderEgressTokenRefresh(context.session.threadId).catch(() => void 0);
153352
+ this.handleProviderEgressTokenRefresh(context.session.threadId).catch((error) => {
153353
+ this.emitErrorEvent(context, "session/tokenRefreshFailed", error instanceof Error ? error.message : String(error));
153354
+ });
153212
153355
  }, delayMs);
153213
153356
  tokenRefreshTimer.unref?.();
153214
153357
  context.tokenRefreshTimer = tokenRefreshTimer;
@@ -191498,7 +191641,7 @@ var Vce = {
191498
191641
  function Ve() {
191499
191642
  return Vce;
191500
191643
  }
191501
- var Us = os.homedir(), lk = os.tmpdir(), { env: Vc } = process$1, Yce = (e) => {
191644
+ var Us = $U.homedir(), lk = $U.tmpdir(), { env: Vc } = process$1, Yce = (e) => {
191502
191645
  let t = path.join(Us, "Library");
191503
191646
  return {
191504
191647
  data: path.join(t, "Application Support", e),
@@ -201698,12 +201841,12 @@ function qZ(e, t) {
201698
201841
  }
201699
201842
  return n;
201700
201843
  }
201701
- var os$2 = "https://code.claude.com/docs/en", kKe = [
201844
+ var os$1 = "https://code.claude.com/docs/en", kKe = [
201702
201845
  {
201703
201846
  matches: (e) => e.path === "permissions.defaultMode" && e.code === "invalid_value",
201704
201847
  tip: {
201705
201848
  suggestion: "Valid modes: \"acceptEdits\" (ask before file changes), \"plan\" (analysis only), \"bypassPermissions\" (auto-accept all), or \"default\" (standard behavior)",
201706
- docLink: `${os$2}/iam#permission-modes`
201849
+ docLink: `${os$1}/iam#permission-modes`
201707
201850
  }
201708
201851
  },
201709
201852
  {
@@ -201718,7 +201861,7 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
201718
201861
  matches: (e) => e.path.startsWith("env.") && e.code === "invalid_type",
201719
201862
  tip: {
201720
201863
  suggestion: "Environment variables must be strings. Wrap numbers and booleans in quotes. Example: \"DEBUG\": \"true\", \"PORT\": \"3000\"",
201721
- docLink: `${os$2}/settings#environment-variables`
201864
+ docLink: `${os$1}/settings#environment-variables`
201722
201865
  }
201723
201866
  },
201724
201867
  {
@@ -201729,14 +201872,14 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
201729
201872
  matches: (e) => e.path.startsWith("hooks.") && e.code === "invalid_key",
201730
201873
  tip: {
201731
201874
  suggestion: "Not a recognized hook event. Common events: PreToolUse, PostToolUse, UserPromptSubmit, SessionStart, SessionEnd, Stop. Check spelling and capitalization.",
201732
- docLink: `${os$2}/hooks`
201875
+ docLink: `${os$1}/hooks`
201733
201876
  }
201734
201877
  },
201735
201878
  {
201736
201879
  matches: (e) => /\.hooks\.\d+\.command$/.test(e.path) && e.code === "invalid_type" && e.received === "undefined",
201737
201880
  tip: {
201738
201881
  suggestion: "Command hooks require `command`. For exec form (no shell), set `command` to the executable and `args` to its arguments: {\"type\": \"command\", \"command\": \"echo\", \"args\": [\"hi\"]}. For shell form, set `command` to the full shell string: {\"type\": \"command\", \"command\": \"echo hi\"}.",
201739
- docLink: `${os$2}/hooks#exec-form-and-shell-form`
201882
+ docLink: `${os$1}/hooks#exec-form-and-shell-form`
201740
201883
  }
201741
201884
  },
201742
201885
  {
@@ -201751,7 +201894,7 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
201751
201894
  matches: (e) => e.code === "unrecognized_keys",
201752
201895
  tip: {
201753
201896
  suggestion: "Check for typos or refer to the documentation for valid fields",
201754
- docLink: `${os$2}/settings`
201897
+ docLink: `${os$1}/settings`
201755
201898
  }
201756
201899
  },
201757
201900
  {
@@ -201766,13 +201909,13 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
201766
201909
  matches: (e) => e.path === "permissions.additionalDirectories" && e.code === "invalid_type",
201767
201910
  tip: {
201768
201911
  suggestion: "Must be an array of directory paths. Example: [\"~/projects\", \"/tmp/workspace\"]. You can also use --add-dir flag or /add-dir command",
201769
- docLink: `${os$2}/iam#working-directories`
201912
+ docLink: `${os$1}/iam#working-directories`
201770
201913
  }
201771
201914
  }
201772
201915
  ], AKe = {
201773
- permissions: `${os$2}/iam#configuring-permissions`,
201774
- env: `${os$2}/settings#environment-variables`,
201775
- hooks: `${os$2}/hooks`
201916
+ permissions: `${os$1}/iam#configuring-permissions`,
201917
+ env: `${os$1}/settings#environment-variables`,
201918
+ hooks: `${os$1}/hooks`
201776
201919
  };
201777
201920
  function GZ(e) {
201778
201921
  let t = kKe.find((r) => r.matches(e));
@@ -269082,7 +269225,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
269082
269225
  var dgram = __require("dgram");
269083
269226
  var thunky = require_thunky();
269084
269227
  var events = __require("events");
269085
- var os$1 = __require("os");
269228
+ var os = __require("os");
269086
269229
  var noop = function() {};
269087
269230
  module.exports = function(opts) {
269088
269231
  if (!opts) opts = {};
@@ -269213,14 +269356,14 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
269213
269356
  return that;
269214
269357
  };
269215
269358
  function defaultInterface() {
269216
- var networks = os$1.networkInterfaces();
269359
+ var networks = os.networkInterfaces();
269217
269360
  var names = Object.keys(networks);
269218
269361
  for (var i = 0; i < names.length; i++) {
269219
269362
  var net = networks[names[i]];
269220
269363
  for (var j = 0; j < net.length; j++) {
269221
269364
  var iface = net[j];
269222
269365
  if (isIPv4(iface.family) && !iface.internal) {
269223
- if (os$1.platform() === "darwin" && names[i] === "en0") return iface.address;
269366
+ if (os.platform() === "darwin" && names[i] === "en0") return iface.address;
269224
269367
  return "0.0.0.0";
269225
269368
  }
269226
269369
  }
@@ -269228,7 +269371,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
269228
269371
  return "127.0.0.1";
269229
269372
  }
269230
269373
  function allInterfaces() {
269231
- var networks = os$1.networkInterfaces();
269374
+ var networks = os.networkInterfaces();
269232
269375
  var names = Object.keys(networks);
269233
269376
  var res = [];
269234
269377
  for (var i = 0; i < names.length; i++) {
@@ -290471,93 +290614,6 @@ async function maybeRefreshRuntimeProvisioningGrant(input) {
290471
290614
  return "refreshed";
290472
290615
  }
290473
290616
  //#endregion
290474
- //#region src/runtimeDrain/RuntimeDrainState.ts
290475
- const initialState = {
290476
- activeTurns: /* @__PURE__ */ new Set(),
290477
- activeTurnCount: 0,
290478
- activeSessionCount: 0,
290479
- draining: false,
290480
- drainReason: null,
290481
- drainTargetImageRef: null,
290482
- drainTargetImageVersion: null,
290483
- drainForceRequired: false
290484
- };
290485
- function snapshotFromState(state) {
290486
- return {
290487
- activeTurnCount: state.activeTurnCount,
290488
- activeSessionCount: state.activeSessionCount,
290489
- draining: state.draining,
290490
- drainReason: state.drainReason,
290491
- drainTargetImageRef: state.drainTargetImageRef,
290492
- drainTargetImageVersion: state.drainTargetImageVersion,
290493
- drainForceRequired: state.drainForceRequired
290494
- };
290495
- }
290496
- function turnKey(input) {
290497
- return `${input.threadId}:${input.turnId ?? "unknown"}`;
290498
- }
290499
- function normalizeCount(count) {
290500
- return Number.isFinite(count) ? Math.max(0, Math.floor(count)) : 0;
290501
- }
290502
- const makeRuntimeDrainState = gen(function* () {
290503
- const stateRef = yield* make$50(initialState);
290504
- const update = (f) => updateAndGet(stateRef, f).pipe(map$3(snapshotFromState));
290505
- return {
290506
- beginTurn: (input) => update((state) => {
290507
- const activeTurns = new Set(state.activeTurns);
290508
- activeTurns.add(turnKey(input));
290509
- return {
290510
- ...state,
290511
- activeTurns,
290512
- activeTurnCount: activeTurns.size
290513
- };
290514
- }),
290515
- completeTurn: (input) => update((state) => {
290516
- const activeTurns = new Set(state.activeTurns);
290517
- activeTurns.delete(turnKey(input));
290518
- return {
290519
- ...state,
290520
- activeTurns,
290521
- activeTurnCount: activeTurns.size
290522
- };
290523
- }),
290524
- clearActiveTurns: update((state) => ({
290525
- ...state,
290526
- activeTurns: /* @__PURE__ */ new Set(),
290527
- activeTurnCount: 0
290528
- })),
290529
- setActiveSessionCount: (count) => update((state) => ({
290530
- ...state,
290531
- activeSessionCount: normalizeCount(count)
290532
- })),
290533
- reconcileProviderSessions: (sessions) => update((state) => {
290534
- const activeSessions = sessions.filter((session) => session.status !== "closed");
290535
- const activeTurns = new Set(activeSessions.flatMap((session) => session.activeTurnId === void 0 ? [] : [turnKey({
290536
- threadId: session.threadId,
290537
- turnId: session.activeTurnId
290538
- })]));
290539
- return {
290540
- ...state,
290541
- activeTurns,
290542
- activeTurnCount: activeTurns.size,
290543
- activeSessionCount: activeSessions.length
290544
- };
290545
- }),
290546
- applyControlPlaneState: (input) => update((state) => ({
290547
- ...state,
290548
- draining: input.draining ?? state.draining,
290549
- drainReason: input.drainReason ?? state.drainReason,
290550
- drainTargetImageRef: input.drainTargetImageRef ?? state.drainTargetImageRef,
290551
- drainTargetImageVersion: input.drainTargetImageVersion ?? state.drainTargetImageVersion,
290552
- drainForceRequired: input.drainForceRequired ?? state.drainForceRequired
290553
- })),
290554
- snapshot: get$6(stateRef).pipe(map$3(snapshotFromState)),
290555
- isDraining: get$6(stateRef).pipe(map$3((state) => state.draining))
290556
- };
290557
- });
290558
- var RuntimeDrainState = class extends Service$1()("forge/runtimeDrain/RuntimeDrainState") {};
290559
- const RuntimeDrainStateLive = effect(RuntimeDrainState, makeRuntimeDrainState);
290560
- //#endregion
290561
290617
  //#region src/runtimeDrain/RuntimeDrainReporter.ts
290562
290618
  const HEARTBEAT_INTERVAL = seconds(30);
290563
290619
  const HEARTBEAT_TICK_TIMEOUT = seconds(60);
@@ -290615,6 +290671,7 @@ const postRuntimeHeartbeat = (config, snapshot) => promise(async () => {
290615
290671
  ...config,
290616
290672
  activeTurnCount: snapshot.activeTurnCount,
290617
290673
  activeSessionCount: snapshot.activeSessionCount,
290674
+ acceptingTurns: snapshot.acceptingTurns,
290618
290675
  ...forgeGitCommit !== void 0 ? { forgeGitCommit } : {},
290619
290676
  forgeServerVersion: installedForgeServerVersion
290620
290677
  });
@@ -290723,6 +290780,7 @@ const makeRuntimeDrainReporter = gen(function* () {
290723
290780
  work: reportOnce,
290724
290781
  interval: HEARTBEAT_INTERVAL
290725
290782
  }));
290783
+ yield* addFinalizer$2(() => drainState.requestShutdown);
290726
290784
  })
290727
290785
  };
290728
290786
  });
@@ -290933,6 +290991,7 @@ function decodeCodexRateLimitWindows(raw) {
290933
290991
  function publicProviderRuntimeError(message) {
290934
290992
  return sanitizePublicProviderText(message, { fallback: DEFAULT_PUBLIC_PROVIDER_ERROR });
290935
290993
  }
290994
+ const processDomainEvent = (_event) => void_$1;
290936
290995
  function isAssistantTextDeltaEvent(event) {
290937
290996
  return event.type === "content.delta" && event.payload.streamKind === "assistant_text";
290938
290997
  }
@@ -291726,7 +291785,6 @@ const ProviderRuntimeIngestionLive = effect(ProviderRuntimeIngestionService, fn$
291726
291785
  yield* runtimeDrainReporter.reportOnce;
291727
291786
  }
291728
291787
  });
291729
- const processDomainEvent = (_event) => void_$1;
291730
291788
  const processInput = (input) => input.source === "runtime" ? processRuntimeEvent(input.event) : processDomainEvent(input.event);
291731
291789
  const processInputSafely = (input) => processInput(input).pipe(catchCause((cause) => {
291732
291790
  if (hasInterruptsOnly(cause)) return failCause$1(cause);
@@ -291777,6 +291835,7 @@ const ProviderRuntimeIngestionLive = effect(ProviderRuntimeIngestionService, fn$
291777
291835
  return {
291778
291836
  start: fn$1("start")(function* () {
291779
291837
  yield* reconcileOrphanedRunningSessions();
291838
+ yield* runtimeDrainState.markExecutionPrecondition("providerLayer");
291780
291839
  yield* runtimeDrainReporter.start;
291781
291840
  yield* forkScoped(runForEach(providerService.streamEvents, (event) => enqueueInput({
291782
291841
  source: "runtime",
@@ -292015,6 +292074,8 @@ const HANDLED_TURN_START_KEY_MAX = 1e4;
292015
292074
  const HANDLED_TURN_START_KEY_TTL = minutes(30);
292016
292075
  const DEFAULT_RUNTIME_MODE = "full-access";
292017
292076
  const DEFAULT_THREAD_TITLE = "New thread";
292077
+ const isProviderValidationError = is$1(ProviderValidationError);
292078
+ const isProviderKind = is$1(ProviderKind);
292018
292079
  function isPathInsideRoot(candidatePath, rootPath) {
292019
292080
  let resolvedCandidate;
292020
292081
  let resolvedRoot;
@@ -292051,6 +292112,38 @@ function resolveExistingWorkspaceCwd(input) {
292051
292112
  function publicProviderFailureDetail(detail) {
292052
292113
  return sanitizePublicProviderText(detail, { fallback: "CMMD is temporarily unavailable. Check the workspace AI connection and retry." }) ?? "CMMD is temporarily unavailable. Check the workspace AI connection and retry.";
292053
292114
  }
292115
+ /**
292116
+ * The failure detail a transcript shows, judged on the text and not the envelope.
292117
+ *
292118
+ * Forge writes its own validation copy, so `ProviderValidationError.issue` is
292119
+ * not raw provider output. Every envelope around it hides it, each in its own
292120
+ * way: `Cause.pretty` prints the error tag, and the sanitizer counts
292121
+ * "ProviderValidationError" as a provider leak, so a validation failure
292122
+ * rendered through `Cause.pretty` tripped the guard on its own wrapper. The
292123
+ * `message` getter spells the same tag out in prose. On 2026-09-16 the first of
292124
+ * those replaced "Reconnect the account and try again" with "CMMD is
292125
+ * temporarily unavailable" (#3337).
292126
+ *
292127
+ * The issue still goes through the sanitizer. `ProviderService` builds some
292128
+ * issues from a schema formatter, which echoes the decoded payload, so this is a
292129
+ * narrower input to the same guard rather than a way around it.
292130
+ */
292131
+ function publicProviderFailureDetailFromError(error) {
292132
+ if (isProviderValidationError(error)) return publicProviderFailureDetail(error.issue);
292133
+ return publicProviderFailureDetail(error instanceof Error ? error.message : String(error));
292134
+ }
292135
+ /**
292136
+ * The same judgement for a failure that arrives as a cause.
292137
+ *
292138
+ * Only the validation branch delegates. A cause carries what a bare error does
292139
+ * not: defects, interrupts, and more than one failure, all of which
292140
+ * `Cause.pretty` renders and `.message` would drop. Squashing every failure into
292141
+ * its message to reach one shared line would lose that.
292142
+ */
292143
+ function publicProviderFailureDetailFromCause(cause) {
292144
+ const error = squash(cause);
292145
+ return isProviderValidationError(error) ? publicProviderFailureDetailFromError(error) : publicProviderFailureDetail(pretty(cause));
292146
+ }
292054
292147
  function canReplaceThreadTitle(currentTitle, titleSeed) {
292055
292148
  const trimmedCurrentTitle = currentTitle.trim();
292056
292149
  if (trimmedCurrentTitle === DEFAULT_THREAD_TITLE) return true;
@@ -292206,7 +292299,7 @@ const ProviderCommandReactorLive = effect(ProviderCommandReactor, gen(function*
292206
292299
  const thread = readModel.threads.find((entry) => entry.id === threadId);
292207
292300
  if (!thread) return yield* die$1(/* @__PURE__ */ new Error(`Thread '${threadId}' was not found in read model.`));
292208
292301
  const desiredRuntimeMode = thread.runtimeMode;
292209
- const currentProvider = thread.session?.status !== "stopped" && is$1(ProviderKind)(thread.session?.providerName) ? thread.session.providerName : void 0;
292302
+ const currentProvider = thread.session?.status !== "stopped" && isProviderKind(thread.session?.providerName) ? thread.session.providerName : void 0;
292210
292303
  const rawRequestedModelSelection = options?.modelSelection;
292211
292304
  const threadProvider = currentProvider ?? thread.modelSelection.provider;
292212
292305
  const isStaleRequestedProvider = rawRequestedModelSelection !== void 0 && rawRequestedModelSelection.provider !== threadProvider;
@@ -292584,7 +292677,7 @@ const ProviderCommandReactorLive = effect(ProviderCommandReactor, gen(function*
292584
292677
  threadId: event.payload.threadId,
292585
292678
  kind: "provider.turn.start.failed",
292586
292679
  summary: "Provider turn start failed",
292587
- detail: publicProviderFailureDetail(pretty(cause)),
292680
+ detail: publicProviderFailureDetailFromCause(cause),
292588
292681
  turnId: null,
292589
292682
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
292590
292683
  })));
@@ -292600,7 +292693,14 @@ const ProviderCommandReactorLive = effect(ProviderCommandReactor, gen(function*
292600
292693
  turnId: event.payload.turnId ?? null,
292601
292694
  createdAt: event.payload.createdAt
292602
292695
  });
292603
- yield* providerService.interruptTurn({ threadId: event.payload.threadId });
292696
+ yield* providerService.interruptTurn({ threadId: event.payload.threadId }).pipe(catchCause((cause) => appendProviderFailureActivity({
292697
+ threadId: event.payload.threadId,
292698
+ kind: "provider.turn.interrupt.failed",
292699
+ summary: "Provider turn interrupt failed",
292700
+ detail: publicProviderFailureDetail(pretty(cause)),
292701
+ turnId: event.payload.turnId ?? null,
292702
+ createdAt: event.payload.createdAt
292703
+ })));
292604
292704
  });
292605
292705
  const processApprovalResponseRequested = fn$1("processApprovalResponseRequested")(function* (event) {
292606
292706
  const staged = peekThreadContinuationSession(event.commandId);
@@ -292637,7 +292737,7 @@ const ProviderCommandReactorLive = effect(ProviderCommandReactor, gen(function*
292637
292737
  threadId: event.payload.threadId,
292638
292738
  kind: "provider.approval.respond.failed",
292639
292739
  summary: "Provider approval response failed",
292640
- detail: isUnknownPendingApprovalRequestError(cause) ? stalePendingRequestDetail("approval", event.payload.requestId) : publicProviderFailureDetail(pretty(cause)),
292740
+ detail: isUnknownPendingApprovalRequestError(cause) ? stalePendingRequestDetail("approval", event.payload.requestId) : publicProviderFailureDetailFromCause(cause),
292641
292741
  turnId: null,
292642
292742
  createdAt: event.payload.createdAt,
292643
292743
  requestId: event.payload.requestId
@@ -292680,7 +292780,7 @@ const ProviderCommandReactorLive = effect(ProviderCommandReactor, gen(function*
292680
292780
  threadId: event.payload.threadId,
292681
292781
  kind: "provider.user-input.respond.failed",
292682
292782
  summary: "Provider user input response failed",
292683
- detail: isUnknownPendingUserInputRequestError(cause) ? stalePendingRequestDetail("user-input", event.payload.requestId) : publicProviderFailureDetail(pretty(cause)),
292783
+ detail: isUnknownPendingUserInputRequestError(cause) ? stalePendingRequestDetail("user-input", event.payload.requestId) : publicProviderFailureDetailFromCause(cause),
292684
292784
  turnId: null,
292685
292785
  createdAt: event.payload.createdAt,
292686
292786
  requestId: event.payload.requestId
@@ -292693,8 +292793,7 @@ const ProviderCommandReactorLive = effect(ProviderCommandReactor, gen(function*
292693
292793
  yield* providerService.stopSession({
292694
292794
  threadId: thread.id,
292695
292795
  ...event.payload.preserveResumeState === true ? { preserveResumeState: true } : {}
292696
- });
292697
- yield* setThreadSession({
292796
+ }).pipe(tap(() => setThreadSession({
292698
292797
  threadId: thread.id,
292699
292798
  session: {
292700
292799
  threadId: thread.id,
@@ -292706,7 +292805,14 @@ const ProviderCommandReactorLive = effect(ProviderCommandReactor, gen(function*
292706
292805
  updatedAt: now
292707
292806
  },
292708
292807
  createdAt: now
292709
- });
292808
+ })), catchCause((cause) => appendProviderFailureActivity({
292809
+ threadId: event.payload.threadId,
292810
+ kind: "provider.session.stop.failed",
292811
+ summary: "Provider session stop failed",
292812
+ detail: publicProviderFailureDetail(pretty(cause)),
292813
+ turnId: null,
292814
+ createdAt: now
292815
+ })));
292710
292816
  });
292711
292817
  const processDomainEvent = fn$1("processDomainEvent")(function* (event) {
292712
292818
  yield* annotateCurrentSpan({
@@ -292801,7 +292907,7 @@ const ProviderCommandReactorLive = effect(ProviderCommandReactor, gen(function*
292801
292907
  threadId: event.payload.threadId,
292802
292908
  kind: "provider.turn.start.failed",
292803
292909
  summary: "Provider turn start cleanup failed",
292804
- detail: publicProviderFailureDetail(cause instanceof Error ? cause.message : String(cause)),
292910
+ detail: publicProviderFailureDetailFromError(cause),
292805
292911
  turnId: null,
292806
292912
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
292807
292913
  })
@@ -298221,7 +298327,7 @@ function resolveBuildCommitFromEnv(env) {
298221
298327
  * environment descriptor down instead of reporting an honest "unknown".
298222
298328
  */
298223
298329
  function readBakedBuildCommit() {
298224
- return "78b0e072680ed734c4eb8337a6d38c87e7e34393";
298330
+ return "b06001f4e16f7a336e9108920f9250b366862f3d";
298225
298331
  }
298226
298332
  async function resolveServerBuildCommit(input) {
298227
298333
  if (isFullCommitSha(input.baked)) return input.baked;
@@ -321588,7 +321694,7 @@ const PlatformServicesLive = unwrap(gen(function* () {
321588
321694
  }));
321589
321695
  const RuntimeReplicationLayerLive = RuntimeReplicationLive.pipe(provideMerge(RuntimeReplicationClientLive), provideMerge(RuntimeReplicationOutboxLive), provideMerge(ActiveHourMeterLive.pipe(provide$1(RuntimeReplicationOutboxLive))));
321590
321696
  const RuntimeDrainLayerLive = RuntimeDrainReporterLive.pipe(provideMerge(RuntimeDrainStateLive));
321591
- const RuntimeAwareProviderReactorsLive = mergeAll(ProviderRuntimeIngestionLive, ProviderCommandReactorLive).pipe(provide$1(RuntimeDrainLayerLive), provide$1(ClaudeUsageTelemetryLive));
321697
+ const RuntimeAwareProviderReactorsLive = mergeAll(ProviderRuntimeIngestionLive, ProviderCommandReactorLive).pipe(provide$1(RuntimeDrainLayerLive), provideMerge(RuntimeDrainStateLive), provide$1(ClaudeUsageTelemetryLive));
321592
321698
  const PipelineWorkerCoordinatorLayerLive = PipelineWorkerCoordinatorLive.pipe(provideMerge(PipelineRunClientLive));
321593
321699
  const AgentProtocolReactorLayerLive = AgentProtocolReactorLive.pipe(provideMerge(PipelineRunStoreLive));
321594
321700
  const PipelineRunCoordinatorLayerLive = PipelineRunCoordinatorLive.pipe(provideMerge(PipelineProviderAuthorityInstallerLive), provideMerge(PipelineChangeInspectorLive), provideMerge(PipelineContextArtifactStoreLive), provideMerge(PipelineModelPolicyLive), provideMerge(PipelineRunClientLive), provideMerge(PipelineRunStoreLive), provideMerge(PipelineRunWorkspaceAllocatorLive), provideMerge(PipelineStagePolicyLive), provideMerge(PipelineWorkerCoordinatorLayerLive));
@@ -322577,7 +322683,7 @@ const connectLoginCommand = make$34("login", {
322577
322683
  })).json();
322578
322684
  },
322579
322685
  openBrowser: async (url) => {
322580
- const open = (await import("./open-FIgTDosf.mjs")).default;
322686
+ const open = (await import("./open-D8mGyWmt.mjs")).default;
322581
322687
  await open(url);
322582
322688
  return true;
322583
322689
  },