@cmmd-center/forge 0.13.81 → 0.13.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.cjs CHANGED
@@ -66275,7 +66275,7 @@ function normalizeNumberish(value) {
66275
66275
  }
66276
66276
  //#endregion
66277
66277
  //#region package.json
66278
- var version$1 = "0.13.81";
66278
+ var version$1 = "0.13.83";
66279
66279
  //#endregion
66280
66280
  //#region src/sentry.ts
66281
66281
  const SERVER_APP_NAME = "forge-server";
@@ -80176,10 +80176,7 @@ function dedupeChecks(entries) {
80176
80176
  for (const entry of survivors) countsByName.set(entry.check.name, (countsByName.get(entry.check.name) ?? 0) + 1);
80177
80177
  return survivors.map((entry) => {
80178
80178
  const workflowName = entry.workflowName ?? "";
80179
- return workflowName.length > 0 && (countsByName.get(entry.check.name) ?? 0) > 1 ? {
80180
- ...entry.check,
80181
- name: `${workflowName} / ${entry.check.name}`
80182
- } : entry.check;
80179
+ return workflowName.length > 0 && (countsByName.get(entry.check.name) ?? 0) > 1 ? Object.assign({}, entry.check, { name: `${workflowName} / ${entry.check.name}` }) : entry.check;
80183
80180
  });
80184
80181
  }
80185
80182
  //#endregion
@@ -87555,13 +87552,8 @@ const make$21 = require_Schema$1.gen(function* () {
87555
87552
  author: withAvatar(pullRequest.author, reviewThreads.avatarsByLogin, input.host),
87556
87553
  reviewers: reviewThreads.reviewers,
87557
87554
  reactions: reviewThreads.reactions,
87558
- commits: (reviewThreads.commits.length > 0 ? reviewThreads.commits : pullRequest.commits).map((commit) => ({
87559
- ...commit,
87560
- ...reviewThreads.commitStats.get(commit.oid),
87561
- authors: commit.authors?.map((author) => withAvatar(author, reviewThreads.avatarsByLogin, input.host) ?? author)
87562
- })),
87563
- comments: [...pullRequest.comments, ...reviewThreads.comments].map((comment) => ({
87564
- ...comment,
87555
+ commits: (reviewThreads.commits.length > 0 ? reviewThreads.commits : pullRequest.commits).map((commit) => Object.assign({}, commit, reviewThreads.commitStats.get(commit.oid), { authors: commit.authors?.map((author) => withAvatar(author, reviewThreads.avatarsByLogin, input.host) ?? author) })),
87556
+ comments: [...pullRequest.comments, ...reviewThreads.comments].map((comment) => Object.assign({}, comment, {
87565
87557
  body: comment.kind === "review" && comment.reviewState?.toUpperCase() === "DISMISSED" && rendersEmpty(comment.body) ? reviewThreads.dismissalsByReviewId.get(comment.id) ?? comment.body : comment.body,
87566
87558
  author: withAvatar(comment.author, reviewThreads.avatarsByLogin, input.host),
87567
87559
  reactions: comment.reactions ?? reviewThreads.reactionsById.get(comment.id) ?? []
@@ -151788,7 +151780,7 @@ const OPENAI_PROXY_ENV_KEYS = ["OPENAI_API_KEY", "OPENAI_BASE_URL"];
151788
151780
  function personalCodexServedByControlPlane(env = process.env) {
151789
151781
  return env.FORGE_CMMD_RUNTIME_MODE === "true" && env.FORGE_PERSONAL_CODEX_VIA_EGRESS === "true";
151790
151782
  }
151791
- function resolveCodexAccessMode(input) {
151783
+ function resolveCodexAccessMode$1(input) {
151792
151784
  if (clampWorkspaceAccessMode(input.accessMode) === "workspace") return "workspace";
151793
151785
  if (personalCodexServedByControlPlane(input.env ?? process.env)) return "workspace";
151794
151786
  if (!input.hasCodexChatGptLogin()) throw personalCodexAuthError("This runtime is not signed in to ChatGPT. Open Settings > Providers and connect ChatGPT on this runtime.");
@@ -153506,7 +153498,7 @@ var CodexAppServerManager = class extends node_events.EventEmitter {
153506
153498
  cwd: resolvedCwd,
153507
153499
  ...codexHomePath ? { homePath: codexHomePath } : {}
153508
153500
  });
153509
- const accessMode = resolveCodexAccessMode({
153501
+ const accessMode = resolveCodexAccessMode$1({
153510
153502
  accessMode: input.accessMode ?? "workspace",
153511
153503
  hasCodexChatGptLogin: () => hasCodexChatGptLogin({
153512
153504
  binaryPath: codexBinaryPath,
@@ -223465,6 +223457,9 @@ const makeTerminationError = (handle) => require_Schema$1.match(handle.exitCode,
223465
223457
  });
223466
223458
  //#endregion
223467
223459
  //#region ../../packages/effect-acp/src/client.ts
223460
+ function runNotificationHandlers(registration, notification) {
223461
+ return require_Schema$1.forEach(registration.handlers, (handler) => handler(notification).pipe(require_Schema$1.catch_(() => require_Schema$1.void_)), { discard: true });
223462
+ }
223468
223463
  var AcpClient = class extends require_Schema$1.Service()("effect-acp/AcpClient") {};
223469
223464
  const make$12 = require_Schema$1.fn("effect-acp/AcpClient.make")(function* (stdio, options = {}, terminationError) {
223470
223465
  const coreHandlers = {};
@@ -223482,7 +223477,6 @@ const make$12 = require_Schema$1.fn("effect-acp/AcpClient.make")(function* (stdi
223482
223477
  const extNotificationHandlers = /* @__PURE__ */ new Map();
223483
223478
  let unknownExtRequestHandler;
223484
223479
  let unknownExtNotificationHandler;
223485
- const runNotificationHandlers = (registration, notification) => require_Schema$1.forEach(registration.handlers, (handler) => handler(notification).pipe(require_Schema$1.catch_(() => require_Schema$1.void_)), { discard: true });
223486
223480
  const flushBufferedNotifications = (registration) => require_Schema$1.suspend$1(() => {
223487
223481
  if (registration.handlers.length === 0 || registration.pending.length === 0) return require_Schema$1.void_;
223488
223482
  const pending = registration.pending.splice(0, registration.pending.length);
@@ -237727,6 +237721,34 @@ const CodexProviderLive = require_Schema$1.effect(CodexProvider, require_Schema$
237727
237721
  //#region src/git/Layers/CodexTextGeneration.ts
237728
237722
  const CODEX_GIT_TEXT_GENERATION_REASONING_EFFORT = "low";
237729
237723
  const CODEX_TIMEOUT_MS = 18e4;
237724
+ const readCodexStreamAsString = (operation, stream) => stream.pipe(require_Path.decodeText(), require_Path.runFold(() => "", (acc, chunk) => acc + chunk), require_Schema$1.mapError((cause) => normalizeCliError("codex", operation, cause, "Failed to collect process output")));
237725
+ function buildCodexExecArgs(input) {
237726
+ return [
237727
+ "exec",
237728
+ "--ephemeral",
237729
+ "--skip-git-repo-check",
237730
+ "-s",
237731
+ "read-only",
237732
+ "--model",
237733
+ input.model,
237734
+ "--config",
237735
+ `model_reasoning_effort="${input.reasoningEffort}"`,
237736
+ "--config",
237737
+ `project_doc_max_bytes=${CODEX_PROJECT_DOC_MAX_BYTES}`,
237738
+ ...input.fastMode ? ["--config", `service_tier="fast"`] : [],
237739
+ "--output-schema",
237740
+ input.schemaPath,
237741
+ "--output-last-message",
237742
+ input.outputPath,
237743
+ "--json",
237744
+ ...input.imagePaths.flatMap((imagePath) => ["--image", imagePath]),
237745
+ "-"
237746
+ ];
237747
+ }
237748
+ function resolveCodexAccessMode(configuredAccessMode) {
237749
+ const accessMode = clampWorkspaceAccessMode(configuredAccessMode);
237750
+ return accessMode === "personal" && personalCodexServedByControlPlane() ? "workspace" : accessMode;
237751
+ }
237730
237752
  /**
237731
237753
  * Byte budget Codex spends on `AGENTS.md` when it builds project instructions.
237732
237754
  * The Codex config reference defines `project_doc_max_bytes` as "Maximum bytes
@@ -237748,7 +237770,6 @@ const makeCodexTextGeneration = require_Schema$1.gen(function* () {
237748
237770
  const serverConfig = yield* require_Schema$1.service(ServerConfig);
237749
237771
  const serverSettingsService = yield* require_Schema$1.service(ServerSettingsService);
237750
237772
  const textGenerationUsage = yield* require_Schema$1.service(TextGenerationUsage);
237751
- const readStreamAsString = (operation, stream) => stream.pipe(require_Path.decodeText(), require_Path.runFold(() => "", (acc, chunk) => acc + chunk), require_Schema$1.mapError((cause) => normalizeCliError("codex", operation, cause, "Failed to collect process output")));
237752
237773
  const writeTempFile = (operation, prefix, content) => {
237753
237774
  return fileSystem.makeTempFileScoped({ prefix: `forge-${prefix}-${process.pid}-${(0, node_crypto.randomUUID)()}.tmp` }).pipe(require_Schema$1.tap((filePath) => fileSystem.writeFileString(filePath, content)), require_Schema$1.mapError((cause) => new TextGenerationError({
237754
237775
  operation,
@@ -237836,39 +237857,47 @@ const makeCodexTextGeneration = require_Schema$1.gen(function* () {
237836
237857
  const outputPath = yield* writeTempFile(operation, "codex-output", "");
237837
237858
  const workingDirectory = yield* makeNeutralWorkingDirectory(operation);
237838
237859
  const codexSettings = yield* require_Schema$1.map(serverSettingsService.getSettings, (settings) => settings.providers.codex).pipe(require_Schema$1.catch_(() => require_Schema$1.undefined_));
237839
- const runCodexCommand = require_Schema$1.fn("runCodexJson.runCodexCommand")(function* () {
237860
+ const launchCodexCommand = (command) => require_Schema$1.gen(function* () {
237861
+ const child = yield* commandSpawner.spawn(command).pipe(require_Schema$1.mapError((cause) => normalizeCliError("codex", operation, cause, "Failed to spawn Codex CLI process")));
237862
+ const [stdout, stderr, exitCode] = yield* require_Schema$1.all([
237863
+ readCodexStreamAsString(operation, child.stdout),
237864
+ readCodexStreamAsString(operation, child.stderr),
237865
+ child.exitCode.pipe(require_Schema$1.mapError((cause) => normalizeCliError("codex", operation, cause, "Failed to read Codex CLI exit code")))
237866
+ ], { concurrency: "unbounded" });
237867
+ if (exitCode === 0) return stdout;
237868
+ const detail = stderr.trim() || stdout.trim();
237869
+ return yield* new TextGenerationError({
237870
+ operation,
237871
+ detail: detail.length > 0 ? `Codex CLI command failed: ${detail}` : `Codex CLI command failed with code ${exitCode}.`
237872
+ });
237873
+ });
237874
+ const resolveCodexCommandTarget = require_Schema$1.fn("runCodexJson.resolveCommandTarget")(function* () {
237840
237875
  const normalizedOptions = normalizeCodexModelOptionsWithCapabilities(getCodexModelCapabilities(modelSelection.model), modelSelection.options);
237841
237876
  const reasoningEffort = modelSelection.options?.reasoningEffort ?? CODEX_GIT_TEXT_GENERATION_REASONING_EFFORT;
237842
- const clampedAccessMode = clampWorkspaceAccessMode(codexSettings?.accessMode ?? "workspace");
237843
- const accessMode = clampedAccessMode === "personal" && personalCodexServedByControlPlane() ? "workspace" : clampedAccessMode;
237844
- const providerProxyToken = yield* resolveCodexProviderProxyToken({
237845
- operation,
237877
+ const accessMode = resolveCodexAccessMode(codexSettings?.accessMode ?? "workspace");
237878
+ return {
237879
+ normalizedOptions,
237880
+ reasoningEffort,
237846
237881
  accessMode,
237882
+ providerProxyToken: yield* resolveCodexProviderProxyToken({
237883
+ operation,
237884
+ accessMode,
237885
+ model: modelSelection.model,
237886
+ ...threadId ? { threadId } : {},
237887
+ authSessionId
237888
+ })
237889
+ };
237890
+ });
237891
+ const runCodexCommand = require_Schema$1.fn("runCodexJson.runCodexCommand")(function* () {
237892
+ const { normalizedOptions, reasoningEffort, accessMode, providerProxyToken } = yield* resolveCodexCommandTarget();
237893
+ return yield* launchCodexCommand(require_NodeTerminal.make$2(codexSettings?.binaryPath || "codex", buildCodexExecArgs({
237847
237894
  model: modelSelection.model,
237848
- ...threadId ? { threadId } : {},
237849
- authSessionId
237850
- });
237851
- const command = require_NodeTerminal.make$2(codexSettings?.binaryPath || "codex", [
237852
- "exec",
237853
- "--ephemeral",
237854
- "--skip-git-repo-check",
237855
- "-s",
237856
- "read-only",
237857
- "--model",
237858
- modelSelection.model,
237859
- "--config",
237860
- `model_reasoning_effort="${reasoningEffort}"`,
237861
- "--config",
237862
- `project_doc_max_bytes=${CODEX_PROJECT_DOC_MAX_BYTES}`,
237863
- ...normalizedOptions?.fastMode ? ["--config", `service_tier="fast"`] : [],
237864
- "--output-schema",
237895
+ reasoningEffort,
237896
+ fastMode: normalizedOptions?.fastMode,
237865
237897
  schemaPath,
237866
- "--output-last-message",
237867
237898
  outputPath,
237868
- "--json",
237869
- ...imagePaths.flatMap((imagePath) => ["--image", imagePath]),
237870
- "-"
237871
- ], {
237899
+ imagePaths
237900
+ }), {
237872
237901
  env: scrubForgeProviderChildEnvSecrets(buildCodexProcessEnv({
237873
237902
  baseEnv: process.env,
237874
237903
  accessMode,
@@ -237881,23 +237910,7 @@ const makeCodexTextGeneration = require_Schema$1.gen(function* () {
237881
237910
  cwd: workingDirectory,
237882
237911
  shell: process.platform === "win32",
237883
237912
  stdin: { stream: require_Path.encodeText(require_Path.make$1(prompt)) }
237884
- });
237885
- const child = yield* commandSpawner.spawn(command).pipe(require_Schema$1.mapError((cause) => normalizeCliError("codex", operation, cause, "Failed to spawn Codex CLI process")));
237886
- const [stdout, stderr, exitCode] = yield* require_Schema$1.all([
237887
- readStreamAsString(operation, child.stdout),
237888
- readStreamAsString(operation, child.stderr),
237889
- child.exitCode.pipe(require_Schema$1.mapError((cause) => normalizeCliError("codex", operation, cause, "Failed to read Codex CLI exit code")))
237890
- ], { concurrency: "unbounded" });
237891
- if (exitCode !== 0) {
237892
- const stderrDetail = stderr.trim();
237893
- const stdoutDetail = stdout.trim();
237894
- const detail = stderrDetail.length > 0 ? stderrDetail : stdoutDetail;
237895
- return yield* new TextGenerationError({
237896
- operation,
237897
- detail: detail.length > 0 ? `Codex CLI command failed: ${detail}` : `Codex CLI command failed with code ${exitCode}.`
237898
- });
237899
- }
237900
- return stdout;
237913
+ }));
237901
237914
  });
237902
237915
  const cleanup = require_Schema$1.all([...[
237903
237916
  schemaPath,
@@ -238037,6 +238050,7 @@ const CodexTextGenerationLive = require_Schema$1.effect(TextGeneration, makeCode
238037
238050
  * @module ClaudeTextGeneration
238038
238051
  */
238039
238052
  const CLAUDE_TIMEOUT_MS = 18e4;
238053
+ const readClaudeStreamAsString = (operation, stream) => stream.pipe(require_Path.decodeText(), require_Path.runFold(() => "", (acc, chunk) => acc + chunk), require_Schema$1.mapError((cause) => normalizeCliError("claude", operation, cause, "Failed to collect process output")));
238040
238054
  /**
238041
238055
  * Schema for the wrapper JSON returned by `claude -p --output-format json`.
238042
238056
  * We only care about `structured_output`.
@@ -238072,7 +238086,6 @@ const makeClaudeTextGeneration = require_Schema$1.gen(function* () {
238072
238086
  ...report.providerSessionId ? { providerSessionId: report.providerSessionId } : {}
238073
238087
  });
238074
238088
  });
238075
- const readStreamAsString = (operation, stream) => stream.pipe(require_Path.decodeText(), require_Path.runFold(() => "", (acc, chunk) => acc + chunk), require_Schema$1.mapError((cause) => normalizeCliError("claude", operation, cause, "Failed to collect process output")));
238076
238089
  /**
238077
238090
  * Spawn the Claude CLI with structured JSON output and return the parsed,
238078
238091
  * schema-validated result.
@@ -238105,8 +238118,8 @@ const makeClaudeTextGeneration = require_Schema$1.gen(function* () {
238105
238118
  });
238106
238119
  const child = yield* commandSpawner.spawn(command).pipe(require_Schema$1.mapError((cause) => normalizeCliError("claude", operation, cause, "Failed to spawn Claude CLI process")));
238107
238120
  const [stdout, stderr, exitCode] = yield* require_Schema$1.all([
238108
- readStreamAsString(operation, child.stdout),
238109
- readStreamAsString(operation, child.stderr),
238121
+ readClaudeStreamAsString(operation, child.stdout),
238122
+ readClaudeStreamAsString(operation, child.stderr),
238110
238123
  child.exitCode.pipe(require_Schema$1.mapError((cause) => normalizeCliError("claude", operation, cause, "Failed to read Claude CLI exit code")))
238111
238124
  ], { concurrency: "unbounded" });
238112
238125
  if (exitCode !== 0) {
@@ -238503,6 +238516,21 @@ var TerminalProcessSignalError = class extends require_Schema$1.TaggedErrorClass
238503
238516
  cause: require_Schema$1.optional(require_Schema$1.Defect),
238504
238517
  signal: require_Schema$1.Literals(["SIGTERM", "SIGKILL"])
238505
238518
  }) {};
238519
+ function toTerminalHistoryError(operation, threadId, terminalId) {
238520
+ return (cause) => new TerminalHistoryError({
238521
+ operation,
238522
+ threadId,
238523
+ terminalId,
238524
+ cause
238525
+ });
238526
+ }
238527
+ function requireRunningProcess(session) {
238528
+ if (session.process && session.status === "running") return require_Schema$1.succeed(session.process);
238529
+ return require_Schema$1.fail(new TerminalNotRunningError({
238530
+ threadId: session.threadId,
238531
+ terminalId: session.terminalId
238532
+ }));
238533
+ }
238506
238534
  const MAX_TERMINAL_CONTROL_RECEIPTS = 256;
238507
238535
  function terminalControlPayloadHash(method, payload) {
238508
238536
  return (0, node_crypto.createHash)("sha256").update(method).update("\0").update(payload).digest("base64url");
@@ -238948,12 +238976,6 @@ const makeTerminalManagerWithOptions = require_Schema$1.fn("makeTerminalManagerW
238948
238976
  return node_path.default.join(logsDir, `${threadPart}_${toSafeTerminalId(terminalId)}.log`);
238949
238977
  };
238950
238978
  const legacyHistoryPath = (threadId) => node_path.default.join(logsDir, `${legacySafeThreadId(threadId)}.log`);
238951
- const toTerminalHistoryError = (operation, threadId, terminalId) => (cause) => new TerminalHistoryError({
238952
- operation,
238953
- threadId,
238954
- terminalId,
238955
- cause
238956
- });
238957
238979
  const readManagerState = get$2(managerStateRef);
238958
238980
  const modifyManagerState = (f) => modify$2(managerStateRef, f);
238959
238981
  const getThreadSemaphore = (threadId) => modifyEffect(threadLocksRef, (current) => {
@@ -239616,13 +239638,6 @@ const makeTerminalManagerWithOptions = require_Schema$1.fn("makeTerminalManagerW
239616
239638
  transitionReceipts.delete(oldest);
239617
239639
  }
239618
239640
  };
239619
- const requireRunningProcess = (session) => {
239620
- if (session.process && session.status === "running") return require_Schema$1.succeed(session.process);
239621
- return require_Schema$1.fail(new TerminalNotRunningError({
239622
- threadId: session.threadId,
239623
- terminalId: session.terminalId
239624
- }));
239625
- };
239626
239641
  const write = require_Schema$1.fn("terminal.write")(function* (input) {
239627
239642
  const terminalId = input.terminalId ?? "default";
239628
239643
  const session = yield* requireSession(input.threadId, terminalId);
@@ -292599,7 +292614,7 @@ function mapProviderSessionStatusToOrchestrationStatus(status) {
292599
292614
  }
292600
292615
  }
292601
292616
  const turnStartKeyForEvent = (event) => event.commandId !== null ? `command:${event.commandId}` : `event:${event.eventId}`;
292602
- const serverCommandId$1 = (tag) => CommandId.make(`server:${tag}:${crypto.randomUUID()}`);
292617
+ const serverCommandId$2 = (tag) => CommandId.make(`server:${tag}:${crypto.randomUUID()}`);
292603
292618
  const HANDLED_TURN_START_KEY_MAX = 1e4;
292604
292619
  const HANDLED_TURN_START_KEY_TTL = require_Schema$1.minutes(30);
292605
292620
  const DEFAULT_RUNTIME_MODE = "full-access";
@@ -293021,7 +293036,7 @@ const make$8 = require_Schema$1.gen(function* () {
293021
293036
  const threadSessionAccountIds = /* @__PURE__ */ new Map();
293022
293037
  const appendProviderFailureActivity = (input) => orchestrationEngine.dispatch({
293023
293038
  type: "thread.activity.append",
293024
- commandId: serverCommandId$1("provider-failure-activity"),
293039
+ commandId: serverCommandId$2("provider-failure-activity"),
293025
293040
  threadId: input.threadId,
293026
293041
  activity: {
293027
293042
  id: EventId.make(crypto.randomUUID()),
@@ -293039,7 +293054,7 @@ const make$8 = require_Schema$1.gen(function* () {
293039
293054
  });
293040
293055
  const setThreadSession = (input) => orchestrationEngine.dispatch({
293041
293056
  type: "thread.session.set",
293042
- commandId: serverCommandId$1("provider-session-set"),
293057
+ commandId: serverCommandId$2("provider-session-set"),
293043
293058
  threadId: input.threadId,
293044
293059
  session: input.session,
293045
293060
  createdAt: input.createdAt
@@ -293071,7 +293086,7 @@ const make$8 = require_Schema$1.gen(function* () {
293071
293086
  const desiredRuntimeMode = thread.runtimeMode;
293072
293087
  const currentProvider = thread.session?.status !== "stopped" && isProviderKind(thread.session?.providerName) ? thread.session.providerName : void 0;
293073
293088
  const requestedModelSelection = options?.modelSelection;
293074
- const threadProvider = currentProvider ?? requestedModelSelection?.provider ?? thread.modelSelection.provider;
293089
+ const threadProvider = requestedModelSelection?.provider ?? currentProvider ?? thread.modelSelection.provider;
293075
293090
  const desiredModelSelection = requestedModelSelection ?? thread.modelSelection;
293076
293091
  const effectiveCwd = resolveThreadWorkspaceCwd({
293077
293092
  thread,
@@ -293322,7 +293337,7 @@ const make$8 = require_Schema$1.gen(function* () {
293322
293337
  });
293323
293338
  yield* orchestrationEngine.dispatch({
293324
293339
  type: "thread.meta.update",
293325
- commandId: serverCommandId$1("worktree-branch-rename"),
293340
+ commandId: serverCommandId$2("worktree-branch-rename"),
293326
293341
  threadId: input.threadId,
293327
293342
  branch: renamed.branch,
293328
293343
  worktreePath: cwd
@@ -293361,7 +293376,7 @@ const make$8 = require_Schema$1.gen(function* () {
293361
293376
  if (!canReplaceThreadTitle(thread.title, input.titleSeed)) return;
293362
293377
  yield* orchestrationEngine.dispatch({
293363
293378
  type: "thread.meta.update",
293364
- commandId: serverCommandId$1("thread-title-rename"),
293379
+ commandId: serverCommandId$2("thread-title-rename"),
293365
293380
  threadId: input.threadId,
293366
293381
  title: generated.title
293367
293382
  });
@@ -293424,7 +293439,7 @@ const make$8 = require_Schema$1.gen(function* () {
293424
293439
  const dispatchThreadTitleRegenerationCompletion = require_Schema$1.fn("dispatchThreadTitleRegenerationCompletion")(function* (input) {
293425
293440
  yield* orchestrationEngine.dispatch({
293426
293441
  type: "thread.title.regeneration.complete",
293427
- commandId: serverCommandId$1("thread-title-regeneration-complete"),
293442
+ commandId: serverCommandId$2("thread-title-regeneration-complete"),
293428
293443
  threadId: input.threadId,
293429
293444
  requestId: input.requestId,
293430
293445
  ...input.title !== void 0 ? { title: input.title } : {}
@@ -293733,7 +293748,7 @@ const make$8 = require_Schema$1.gen(function* () {
293733
293748
  });
293734
293749
  const appendRecoverableTurnStartTimeout = (event) => orchestrationEngine.dispatch({
293735
293750
  type: "thread.activity.append",
293736
- commandId: serverCommandId$1("provider-turn-start-timeout"),
293751
+ commandId: serverCommandId$2("provider-turn-start-timeout"),
293737
293752
  threadId: event.payload.threadId,
293738
293753
  activity: {
293739
293754
  id: EventId.make(crypto.randomUUID()),
@@ -294567,7 +294582,13 @@ function isGitOutputLimitError(error) {
294567
294582
  const text = `${"detail" in error && typeof error.detail === "string" ? error.detail : ""}\n${"message" in error && typeof error.message === "string" ? error.message : ""}`;
294568
294583
  return text.includes("output exceeded") && text.includes("bytes and was truncated");
294569
294584
  }
294570
- const serverCommandId = (tag) => CommandId.make(`server:${tag}:${crypto.randomUUID()}`);
294585
+ const serverCommandId$1 = (tag) => CommandId.make(`server:${tag}:${crypto.randomUUID()}`);
294586
+ function findSessionWithCwd(session) {
294587
+ return session?.cwd ? require_Schema$1.some({
294588
+ threadId: session.threadId,
294589
+ cwd: session.cwd
294590
+ }) : require_Schema$1.none();
294591
+ }
294571
294592
  const make$7 = require_Schema$1.gen(function* () {
294572
294593
  const orchestrationEngine = yield* OrchestrationEngineService;
294573
294594
  const providerService = yield* ProviderService;
@@ -294577,7 +294598,7 @@ const make$7 = require_Schema$1.gen(function* () {
294577
294598
  const gitStatusBroadcaster = yield* GitStatusBroadcaster;
294578
294599
  const appendRevertFailureActivity = (input) => orchestrationEngine.dispatch({
294579
294600
  type: "thread.activity.append",
294580
- commandId: serverCommandId("checkpoint-revert-failure"),
294601
+ commandId: serverCommandId$1("checkpoint-revert-failure"),
294581
294602
  threadId: input.threadId,
294582
294603
  activity: {
294583
294604
  id: EventId.make(crypto.randomUUID()),
@@ -294595,7 +294616,7 @@ const make$7 = require_Schema$1.gen(function* () {
294595
294616
  });
294596
294617
  const appendCaptureFailureActivity = (input) => orchestrationEngine.dispatch({
294597
294618
  type: "thread.activity.append",
294598
- commandId: serverCommandId("checkpoint-capture-failure"),
294619
+ commandId: serverCommandId$1("checkpoint-capture-failure"),
294599
294620
  threadId: input.threadId,
294600
294621
  activity: {
294601
294622
  id: EventId.make(crypto.randomUUID()),
@@ -294613,7 +294634,7 @@ const make$7 = require_Schema$1.gen(function* () {
294613
294634
  });
294614
294635
  const appendDiffSummarySkippedActivity = (input) => orchestrationEngine.dispatch({
294615
294636
  type: "thread.activity.append",
294616
- commandId: serverCommandId("checkpoint-diff-summary-skipped"),
294637
+ commandId: serverCommandId$1("checkpoint-diff-summary-skipped"),
294617
294638
  threadId: input.threadId,
294618
294639
  activity: {
294619
294640
  id: EventId.make(crypto.randomUUID()),
@@ -294629,20 +294650,12 @@ const make$7 = require_Schema$1.gen(function* () {
294629
294650
  const resolveSessionRuntimeForThread = require_Schema$1.fn("resolveSessionRuntimeForThread")(function* (threadId) {
294630
294651
  const thread = (yield* orchestrationEngine.getReadModel()).threads.find((entry) => entry.id === threadId);
294631
294652
  const sessions = yield* providerService.listSessions();
294632
- const findSessionWithCwd = (session) => {
294633
- if (!session?.cwd) return require_Schema$1.none();
294634
- return require_Schema$1.some({
294635
- threadId: session.threadId,
294636
- cwd: session.cwd
294637
- });
294638
- };
294639
294653
  if (thread) {
294640
294654
  const fromProjected = findSessionWithCwd(sessions.find((session) => session.threadId === thread.id));
294641
294655
  if (require_Schema$1.isSome(fromProjected)) return fromProjected;
294642
294656
  }
294643
294657
  return require_Schema$1.none();
294644
294658
  });
294645
- const isGitWorkspace = (cwd) => isGitRepository(cwd);
294646
294659
  const resolveCheckpointCwd = require_Schema$1.fn("resolveCheckpointCwd")(function* (input) {
294647
294660
  const fromSession = yield* resolveSessionRuntimeForThread(input.threadId);
294648
294661
  const fromThread = resolveThreadWorkspaceCwd({
@@ -294657,7 +294670,7 @@ const make$7 = require_Schema$1.gen(function* () {
294657
294670
  onSome: (runtime) => runtime.cwd
294658
294671
  });
294659
294672
  if (!cwd) return;
294660
- if (!isGitWorkspace(cwd)) return;
294673
+ if (!isGitRepository(cwd)) return;
294661
294674
  return cwd;
294662
294675
  });
294663
294676
  const captureAndDispatchCheckpoint = require_Schema$1.fn("captureAndDispatchCheckpoint")(function* (input) {
@@ -294717,7 +294730,7 @@ const make$7 = require_Schema$1.gen(function* () {
294717
294730
  const assistantMessageId = input.assistantMessageId ?? input.thread.messages.toReversed().find((entry) => entry.role === "assistant" && entry.turnId === input.turnId)?.id ?? MessageId.make(`assistant:${input.turnId}`);
294718
294731
  yield* orchestrationEngine.dispatch({
294719
294732
  type: "thread.turn.diff.complete",
294720
- commandId: serverCommandId("checkpoint-turn-diff-complete"),
294733
+ commandId: serverCommandId$1("checkpoint-turn-diff-complete"),
294721
294734
  threadId: input.threadId,
294722
294735
  turnId: input.turnId,
294723
294736
  completedAt: input.createdAt,
@@ -294746,7 +294759,7 @@ const make$7 = require_Schema$1.gen(function* () {
294746
294759
  });
294747
294760
  yield* orchestrationEngine.dispatch({
294748
294761
  type: "thread.activity.append",
294749
- commandId: serverCommandId("checkpoint-captured-activity"),
294762
+ commandId: serverCommandId$1("checkpoint-captured-activity"),
294750
294763
  threadId: input.threadId,
294751
294764
  activity: {
294752
294765
  id: EventId.make(crypto.randomUUID()),
@@ -294928,7 +294941,7 @@ const make$7 = require_Schema$1.gen(function* () {
294928
294941
  }).pipe(require_Schema$1.catch_(() => require_Schema$1.void_));
294929
294942
  return;
294930
294943
  }
294931
- if (!isGitWorkspace(sessionRuntime.value.cwd)) {
294944
+ if (!isGitRepository(sessionRuntime.value.cwd)) {
294932
294945
  yield* appendRevertFailureActivity({
294933
294946
  threadId: event.payload.threadId,
294934
294947
  turnCount: event.payload.turnCount,
@@ -294984,7 +294997,7 @@ const make$7 = require_Schema$1.gen(function* () {
294984
294997
  });
294985
294998
  yield* orchestrationEngine.dispatch({
294986
294999
  type: "thread.revert.complete",
294987
- commandId: serverCommandId("checkpoint-revert-complete"),
295000
+ commandId: serverCommandId$1("checkpoint-revert-complete"),
294988
295001
  threadId: event.payload.threadId,
294989
295002
  turnCount: event.payload.turnCount,
294990
295003
  createdAt: now
@@ -299323,7 +299336,7 @@ function resolveBuildCommitFromEnv(env) {
299323
299336
  * environment descriptor down instead of reporting an honest "unknown".
299324
299337
  */
299325
299338
  function readBakedBuildCommit() {
299326
- return "657f7114dd9dda1b9eda0962d4bafff6d35a928b";
299339
+ return "f79faf155154414eb732bc0ef180d7b98f2b7888";
299327
299340
  }
299328
299341
  async function resolveServerBuildCommit(input) {
299329
299342
  if (isFullCommitSha(input.baked)) return input.baked;
@@ -300720,6 +300733,15 @@ var AuthPairingLinkRepository = class extends require_Schema$1.Service()("forge/
300720
300733
  function toPersistenceSqlOrDecodeError$4(sqlOperation, decodeOperation) {
300721
300734
  return (cause) => require_Schema$1.isSchemaError(cause) ? toPersistenceDecodeError(decodeOperation)(cause) : toPersistenceSqlError(sqlOperation)(cause);
300722
300735
  }
300736
+ function decodeCredential(row) {
300737
+ return require_Schema$1.try_({
300738
+ try: () => ({
300739
+ ...row,
300740
+ credential: decodeSensitiveValue("auth-pairing-link", row.credential)
300741
+ }),
300742
+ catch: toPersistenceDecodeDefect("AuthPairingLinkRepository.decryptCredential")
300743
+ });
300744
+ }
300723
300745
  const makeAuthPairingLinkRepository = require_Schema$1.gen(function* () {
300724
300746
  const sql = yield* require_SqlError.SqlClient;
300725
300747
  const StoredCreateAuthPairingLinkInput = require_Schema$1.Struct({
@@ -300841,13 +300863,6 @@ const makeAuthPairingLinkRepository = require_Schema$1.gen(function* () {
300841
300863
  WHERE credential_lookup = ${credentialLookup}
300842
300864
  `
300843
300865
  });
300844
- const decodeCredential = (row) => require_Schema$1.try_({
300845
- try: () => ({
300846
- ...row,
300847
- credential: decodeSensitiveValue("auth-pairing-link", row.credential)
300848
- }),
300849
- catch: toPersistenceDecodeDefect("AuthPairingLinkRepository.decryptCredential")
300850
- });
300851
300866
  const create = (input) => createPairingLinkRow({
300852
300867
  ...input,
300853
300868
  credential: encodeSensitiveValue("auth-pairing-link", input.credential),
@@ -303277,8 +303292,10 @@ const decideOrchestrationCommand = require_Schema$1.fn("decideOrchestrationComma
303277
303292
  }
303278
303293
  };
303279
303294
  const shouldUpdateAnchor = targetThread.anchorKind !== nextAnchor.anchorKind || targetThread.anchorCmmdId !== nextAnchor.anchorCmmdId;
303295
+ const providerSwitchSelection = command.modelSelection !== void 0 && command.modelSelection.provider !== targetThread.modelSelection.provider ? command.modelSelection : void 0;
303280
303296
  const accountSelection = turnAccountSelection(targetThread.modelSelection, command.modelSelection);
303281
- if (!shouldUpdateAnchor && !accountSelection) return [userMessageEvent, turnStartRequestedEvent];
303297
+ const turnModelSelection = providerSwitchSelection ?? accountSelection;
303298
+ if (!shouldUpdateAnchor && !turnModelSelection) return [userMessageEvent, turnStartRequestedEvent];
303282
303299
  return [
303283
303300
  {
303284
303301
  ...withEventBase({
@@ -303292,7 +303309,7 @@ const decideOrchestrationCommand = require_Schema$1.fn("decideOrchestrationComma
303292
303309
  threadId: command.threadId,
303293
303310
  anchorKind: nextAnchor.anchorKind,
303294
303311
  anchorCmmdId: nextAnchor.anchorCmmdId,
303295
- ...accountSelection ? { modelSelection: accountSelection } : {},
303312
+ ...turnModelSelection ? { modelSelection: turnModelSelection } : {},
303296
303313
  updatedAt: command.createdAt
303297
303314
  }
303298
303315
  },
@@ -313776,14 +313793,8 @@ function buildRuntimeUsageRowBatch(rows, cursor, batchSize = 500) {
313776
313793
  previousHeadHash: cursor.headHash,
313777
313794
  rows: capped.map((row, index) => {
313778
313795
  const sequence = cursor.acknowledgedSequence + 1 + index;
313779
- return {
313780
- ...row,
313781
- sequence,
313782
- payloadHash: hashRuntimeUsageRow({
313783
- ...row,
313784
- sequence
313785
- })
313786
- };
313796
+ const sequencedRow = Object.assign({}, row, { sequence });
313797
+ return Object.assign(sequencedRow, { payloadHash: hashRuntimeUsageRow(sequencedRow) });
313787
313798
  })
313788
313799
  };
313789
313800
  }
@@ -316292,6 +316303,23 @@ const EXECUTABLE_STAGES = [
316292
316303
  ];
316293
316304
  const encoder = new TextEncoder();
316294
316305
  const decoder = new TextDecoder();
316306
+ function decodePersistedReport(item) {
316307
+ let value;
316308
+ try {
316309
+ value = JSON.parse(item.payloadJson);
316310
+ } catch {
316311
+ return null;
316312
+ }
316313
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
316314
+ const report = value;
316315
+ return [
316316
+ report.stage === item.stage,
316317
+ Number.isSafeInteger(report.attempt),
316318
+ (report.attempt ?? 0) > 0,
316319
+ Number.isSafeInteger(report.expectedLockVersion),
316320
+ (report.expectedLockVersion ?? -1) >= 0
316321
+ ].every(Boolean) ? report : null;
316322
+ }
316295
316323
  function isRecord$2(value) {
316296
316324
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
316297
316325
  }
@@ -317733,23 +317761,6 @@ const makePipelineRunCoordinator = require_Schema$1.gen(function* () {
317733
317761
  })).applied) return yield* coordinatorError("reconcileTerminalHandoff", "PIPELINE_RECONCILE_CONFLICT", "The pipeline binding changed before its terminal state could be reconciled.");
317734
317762
  yield* finalizeTerminalResources(binding, publicationGeneration);
317735
317763
  }).pipe(require_Schema$1.mapError((cause) => cause instanceof PipelineRunCoordinatorError ? cause : coordinatorError("reconcileTerminalHandoff", "PIPELINE_RECONCILE_FAILED", `Failed to reconcile terminal CMMD run ${input.runId}.`, cause)));
317736
- const decodePersistedReport = (item) => {
317737
- let value;
317738
- try {
317739
- value = JSON.parse(item.payloadJson);
317740
- } catch {
317741
- return null;
317742
- }
317743
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
317744
- const report = value;
317745
- return [
317746
- report.stage === item.stage,
317747
- Number.isSafeInteger(report.attempt),
317748
- (report.attempt ?? 0) > 0,
317749
- Number.isSafeInteger(report.expectedLockVersion),
317750
- (report.expectedLockVersion ?? -1) >= 0
317751
- ].every(Boolean) ? report : null;
317752
- };
317753
317764
  const synchronizeNonAppliedReport = (item, binding, authority, reportEpoch, currentEpoch) => require_Schema$1.gen(function* () {
317754
317765
  const snapshot = yield* client.read({
317755
317766
  runId: item.runId,
@@ -321679,6 +321690,9 @@ function requireMergeValue(value, message) {
321679
321690
  if (value === null || value === void 0) throw new Error(message);
321680
321691
  return value;
321681
321692
  }
321693
+ function serverCommandId(tag) {
321694
+ return CommandId.make(`server:agent-protocol:${tag}:${crypto.randomUUID()}`);
321695
+ }
321682
321696
  const make = require_Schema$1.gen(function* () {
321683
321697
  const orchestration = yield* OrchestrationEngineService;
321684
321698
  const projectionSnapshotQuery = yield* ProjectionSnapshotQuery;
@@ -321690,7 +321704,6 @@ const make = require_Schema$1.gen(function* () {
321690
321704
  const dispatch = (command) => runPromise(orchestration.dispatch(command).pipe(require_Schema$1.asVoid));
321691
321705
  const readThread = (threadId) => runPromise(readDurableWorkerDetail(projectionSnapshotQuery, threadId)).then(require_Schema$1.getOrNull);
321692
321706
  const readProject = (projectId) => runPromise(projectionSnapshotQuery.getProjectShellById(projectId)).then(require_Schema$1.getOrNull);
321693
- const serverCommandId = (tag) => CommandId.make(`server:agent-protocol:${tag}:${crypto.randomUUID()}`);
321694
321707
  const appendActivity = async (input) => {
321695
321708
  const createdAt = input.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
321696
321709
  await dispatch({