@open-mercato/cezar 0.16.2 → 0.16.3-pr1706.3787

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 (132) hide show
  1. package/dist/api-origin.d.ts +6 -0
  2. package/dist/api-origin.js +32 -0
  3. package/dist/api-origin.js.map +1 -0
  4. package/dist/automations/github-poller.js +2 -0
  5. package/dist/automations/github-poller.js.map +1 -1
  6. package/dist/automations/pr-head.js +2 -1
  7. package/dist/automations/pr-head.js.map +1 -1
  8. package/dist/automations/schedule-runner.d.ts +1 -0
  9. package/dist/automations/schedule-runner.js +2 -2
  10. package/dist/automations/schedule-runner.js.map +1 -1
  11. package/dist/core/agent-errors.d.ts +5 -0
  12. package/dist/core/agent-errors.js +49 -0
  13. package/dist/core/agent-errors.js.map +1 -1
  14. package/dist/core/backend-detect.js +3 -2
  15. package/dist/core/backend-detect.js.map +1 -1
  16. package/dist/core/claude-cli-runner.d.ts +3 -0
  17. package/dist/core/claude-cli-runner.js +20 -4
  18. package/dist/core/claude-cli-runner.js.map +1 -1
  19. package/dist/core/codex-ui-mapper.js +4 -1
  20. package/dist/core/codex-ui-mapper.js.map +1 -1
  21. package/dist/core/copilot-acp-runner.d.ts +1 -1
  22. package/dist/core/copilot-acp-runner.js +26 -5
  23. package/dist/core/copilot-acp-runner.js.map +1 -1
  24. package/dist/core/gh-env.d.ts +20 -0
  25. package/dist/core/gh-env.js +25 -0
  26. package/dist/core/gh-env.js.map +1 -0
  27. package/dist/core/model-presets.d.ts +11 -0
  28. package/dist/core/model-presets.js +35 -1
  29. package/dist/core/model-presets.js.map +1 -1
  30. package/dist/core/opencode-model-catalog.js +3 -0
  31. package/dist/core/opencode-model-catalog.js.map +1 -1
  32. package/dist/core/opencode-server-runner.d.ts +7 -0
  33. package/dist/core/opencode-server-runner.js +36 -1
  34. package/dist/core/opencode-server-runner.js.map +1 -1
  35. package/dist/core/pi-runner.js +2 -0
  36. package/dist/core/pi-runner.js.map +1 -1
  37. package/dist/core/provider-auth.d.ts +6 -0
  38. package/dist/core/provider-auth.js +59 -13
  39. package/dist/core/provider-auth.js.map +1 -1
  40. package/dist/core/usage-limit.js +8 -2
  41. package/dist/core/usage-limit.js.map +1 -1
  42. package/dist/git-remotes.js +2 -1
  43. package/dist/git-remotes.js.map +1 -1
  44. package/dist/index.js +3 -19
  45. package/dist/index.js.map +1 -1
  46. package/dist/release/bump.d.ts +1 -1
  47. package/dist/release/bump.js +1 -1
  48. package/dist/release/stable.d.ts +21 -4
  49. package/dist/release/stable.js +48 -15
  50. package/dist/release/stable.js.map +1 -1
  51. package/dist/runs/agent-error-telemetry.js +4 -2
  52. package/dist/runs/agent-error-telemetry.js.map +1 -1
  53. package/dist/runs/store.d.ts +1 -1
  54. package/dist/runs/store.js +31 -4
  55. package/dist/runs/store.js.map +1 -1
  56. package/dist/self-update/pulls.js +2 -1
  57. package/dist/self-update/pulls.js.map +1 -1
  58. package/dist/server/checkout.js +2 -1
  59. package/dist/server/checkout.js.map +1 -1
  60. package/dist/server/create-project.js +2 -1
  61. package/dist/server/create-project.js.map +1 -1
  62. package/dist/server/dashboard.d.ts +54 -54
  63. package/dist/server/forge/github.js +3 -2
  64. package/dist/server/forge/github.js.map +1 -1
  65. package/dist/server/git-changes.d.ts +22 -0
  66. package/dist/server/git-changes.js +19 -1
  67. package/dist/server/git-changes.js.map +1 -1
  68. package/dist/server/open-in-app.js +14 -3
  69. package/dist/server/open-in-app.js.map +1 -1
  70. package/dist/server/preview/location-reporter.d.ts +12 -0
  71. package/dist/server/preview/location-reporter.js +45 -0
  72. package/dist/server/preview/location-reporter.js.map +1 -0
  73. package/dist/server/preview/picker-script.d.ts +0 -22
  74. package/dist/server/preview/picker-script.js +3 -1
  75. package/dist/server/preview/picker-script.js.map +1 -1
  76. package/dist/server/provider-telemetry.d.ts +3 -1
  77. package/dist/server/provider-telemetry.js +4 -2
  78. package/dist/server/provider-telemetry.js.map +1 -1
  79. package/dist/server/repo-sync.js +5 -10
  80. package/dist/server/repo-sync.js.map +1 -1
  81. package/dist/server/server.d.ts +1854 -1854
  82. package/dist/server/server.js +7 -2
  83. package/dist/server/server.js.map +1 -1
  84. package/dist/server/worktree-lifecycle.d.ts +90 -90
  85. package/dist/telemetry.js +3 -1
  86. package/dist/telemetry.js.map +1 -1
  87. package/dist/workflows/continuation-context.d.ts +3 -1
  88. package/dist/workflows/continuation-context.js +22 -3
  89. package/dist/workflows/continuation-context.js.map +1 -1
  90. package/dist/workflows/run.d.ts +20 -9
  91. package/dist/workflows/run.js +49 -11
  92. package/dist/workflows/run.js.map +1 -1
  93. package/package.json +3 -3
  94. package/scripts/mock-copilot-acp.mjs +4 -0
  95. package/web/dist/assets/{agent-task-pickers-DEW3Vgdv.js → agent-task-pickers-CNuwgeJL.js} +1 -1
  96. package/web/dist/assets/{automations-route-Cx7mzYhD.js → automations-route-Cs1tsu1W.js} +1 -1
  97. package/web/dist/assets/{commit-list-xMdmPYbz.js → commit-list-Ti2arrt8.js} +1 -1
  98. package/web/dist/assets/{compare-variants-B6ja1M4D.js → compare-variants-CdchlJMs.js} +1 -1
  99. package/web/dist/assets/{dashboard-ClEGBFFq.js → dashboard-wi0EQack.js} +2 -2
  100. package/web/dist/assets/{file-preview-iucr8WDo.js → file-preview-pS9i9ZDR.js} +1 -1
  101. package/web/dist/assets/git-tab-loading-BC6WP7W4.js +1 -0
  102. package/web/dist/assets/{git-toolbar-DU5Ca6RI.js → git-toolbar-Dra1QlHb.js} +1 -1
  103. package/web/dist/assets/github-DZcdhMzw.js +1 -0
  104. package/web/dist/assets/{host-usage-DjDYDU0A.js → host-usage-DnkXF0CT.js} +1 -1
  105. package/web/dist/assets/index-qeFtKZ4e.js +22 -0
  106. package/web/dist/assets/{layout-cards-Sur4EWtx.js → layout-cards-CXMlrDUf.js} +1 -1
  107. package/web/dist/assets/{project-router-DZsR9P9C.js → project-router-CZzr7lzN.js} +2 -2
  108. package/web/dist/assets/queries-Bn7zl9OU.js +1 -0
  109. package/web/dist/assets/{reference-chip-DnemrSPW.js → reference-chip-CScP5y_O.js} +1 -1
  110. package/web/dist/assets/repo-git-CV-yXaSx.js +1 -0
  111. package/web/dist/assets/{run-diff-BPZ85gAE.js → run-diff-GHEaeAio.js} +2 -2
  112. package/web/dist/assets/{skills-BgCN1gTp.js → skills-DuSNv5op.js} +1 -1
  113. package/web/dist/assets/{task-commits-W1ZZiEt4.js → task-commits-D_gLpFQo.js} +1 -1
  114. package/web/dist/assets/{task-graph-DI2fn5M8.js → task-graph-BgHk8Y3v.js} +1 -1
  115. package/web/dist/assets/{task-notes-lmvd1UM7.js → task-notes-BBp0rdzM.js} +1 -1
  116. package/web/dist/assets/task-workspace-Cr9AjTxP.js +27 -0
  117. package/web/dist/assets/{terminal-drawer-DAkquqSe.js → terminal-drawer-CcPOjWwP.js} +2 -2
  118. package/web/dist/assets/{tracker-Cqdpt9RN.js → tracker-BHwMGsDY.js} +2 -2
  119. package/web/dist/assets/use-automations-Dh3Wj-79.js +5 -0
  120. package/web/dist/assets/{use-now-pBdvhv13.js → use-now-BB7W0F--.js} +1 -1
  121. package/web/dist/assets/{workflow-graph-l7O50dsV.js → workflow-graph-CcOTCItr.js} +3 -3
  122. package/web/dist/assets/worktree-lifecycle-operation-vTgExKUM.js +18 -0
  123. package/web/dist/index.html +10 -10
  124. package/dist/telemetry-service.json +0 -1
  125. package/web/dist/assets/git-tab-loading-BfC2ir8N.js +0 -1
  126. package/web/dist/assets/github-CELdSmld.js +0 -1
  127. package/web/dist/assets/index-BBND6Sg3.js +0 -22
  128. package/web/dist/assets/queries-CI0EmEcH.js +0 -1
  129. package/web/dist/assets/repo-git-Bj0PBOjX.js +0 -1
  130. package/web/dist/assets/task-workspace-B8Fpho3e.js +0 -27
  131. package/web/dist/assets/use-automations-v77gHYDG.js +0 -5
  132. package/web/dist/assets/worktree-lifecycle-operation-DOTiqQFx.js +0 -18
@@ -13,7 +13,7 @@ import { loadPrivateMcp, PRIVATE_MCP_FILE, skippedServersNote, supportsPrivateMc
13
13
  import { onUsage, registerRunProcess, unregisterRunProcess } from '../core/process-usage.js';
14
14
  import { parseUsageLimit } from '../core/usage-limit.js';
15
15
  import { createRunner } from '../core/runner-factory.js';
16
- import { modelConflictsWithRunner } from '../core/model-presets.js';
16
+ import { modelConflictsWithRunner, modelNativeToRunner } from '../core/model-presets.js';
17
17
  import { AGENT_MODELS_LOCKED_ERROR, agentModelsLocked } from '../core/agent-model-policy.js';
18
18
  import { ModelIdentityError, formatModelIdentity, normalizeModelForBackend, } from '../core/model-identity.js';
19
19
  import { HANDOFF_ONLY_INSTRUCTIONS, HANDOFF_INSTRUCTIONS, appendHandoffHeartbeat, followupsEnabled, handoffPath, readHandoff, seedHandoffFile, } from '../handoff.js';
@@ -316,6 +316,7 @@ export function repositoryRootLockDisabled(env = process.env) {
316
316
  return env.CEZ_DISABLE_REPO_LOCK === '1';
317
317
  }
318
318
  const REPOSITORY_ROOT_LOCK_DISABLED_NOTE = 'repository-root lock disabled by CEZ_DISABLE_REPO_LOCK=1 (shared checkout is unsafe)';
319
+ const CONTINUABLE_STATUSES = ['done', 'failed', 'cancelled', 'review'];
319
320
  /** Safety cap on autonomous auto-continues per run — stops a stuck agent from nudging forever.
320
321
  * Exported so the tests assert against the real cap instead of restating `40`. */
321
322
  export const MAX_AUTO_CONTINUES = 40;
@@ -1668,7 +1669,10 @@ export class RunManager {
1668
1669
  // promise reaches finally; never let stale cleanup release the newer owner's slot.
1669
1670
  if (expectedState !== undefined && state !== expectedState)
1670
1671
  return;
1671
- if (state?.acceptReviewOnDrop && !state.cancelled && this.store.getRun(runId)?.status === 'review') {
1672
+ const queuedContinue = state && !state.cancelled ? state.continueOnDrop : undefined;
1673
+ // A Continue taken in the same teardown window sends the review back, so it supersedes an accept.
1674
+ const acceptReview = !queuedContinue && state?.acceptReviewOnDrop && !state.cancelled && this.store.getRun(runId)?.status === 'review';
1675
+ if (acceptReview) {
1672
1676
  this.store.updateRun(runId, { status: 'done' });
1673
1677
  this.store.appendEvent(runId, { type: 'lifecycle', message: 'review accepted — finished without a PR' });
1674
1678
  }
@@ -1722,6 +1726,13 @@ export class RunManager {
1722
1726
  // there is no keep-count to respect and nothing left to recover from it. A
1723
1727
  // Continue (or an auto-resume) re-creates it through `agentEnv`.
1724
1728
  removeAgentTmpDir(this.dataDir, runId);
1729
+ // Last, so the Continue starts from exactly the state a Continue posted just after the drop would.
1730
+ if (queuedContinue) {
1731
+ const resumed = this.continueRun(runId, queuedContinue.opts, queuedContinue.deferForCapacity);
1732
+ if (!resumed.ok) {
1733
+ this.store.appendEvent(runId, { type: 'lifecycle', message: `continue could not start — ${resumed.error}` });
1734
+ }
1735
+ }
1725
1736
  }
1726
1737
  // ---- task dispatch (spec 2026-09-10-dispatch) ----------------------------------------------
1727
1738
  /** Is dispatch on at all? One read, so the gate cannot drift between the sites below. */
@@ -2950,6 +2961,10 @@ export class RunManager {
2950
2961
  persistedAttachments: persisted.attachments,
2951
2962
  };
2952
2963
  }
2964
+ /** Where `persistAttachment` writes a run's pasted files. */
2965
+ attachmentsDir(runId) {
2966
+ return join(this.dataDir, 'runs', `${runId}-images`);
2967
+ }
2953
2968
  /**
2954
2969
  * Re-read persisted attachments at dequeue/restart (#472): an image comes back as a viewable
2955
2970
  * block AND a path, a file (#950) as a path only. The branch is on the NAME's extension, never
@@ -2966,7 +2981,7 @@ export class RunManager {
2966
2981
  const name = url.split('/').pop();
2967
2982
  if (!name || name.includes('..') || name.includes('/') || name.includes('\\'))
2968
2983
  continue;
2969
- const path = join(this.dataDir, 'runs', `${runId}-images`, name);
2984
+ const path = join(this.attachmentsDir(runId), name);
2970
2985
  try {
2971
2986
  if (isImageAttachmentName(name)) {
2972
2987
  const data = readFileSync(path);
@@ -3372,13 +3387,27 @@ export class RunManager {
3372
3387
  if (agentModelsLocked(this.repoRoot) && opts.model?.trim()) {
3373
3388
  return { ok: false, error: AGENT_MODELS_LOCKED_ERROR };
3374
3389
  }
3375
- if (this.active.has(runId) || this.starting.has(runId))
3376
- return { ok: false, error: 'run is still active' };
3377
3390
  const run = this.store.getRun(runId);
3391
+ if (this.active.has(runId) || this.starting.has(runId)) {
3392
+ // The record already reads settled, but the turn-end autosave is still unwinding: take the
3393
+ // Continue now and start it from `dropActive`, the way Finish does (telemetry 77117b95).
3394
+ const unwinding = this.active.get(runId);
3395
+ const settledTurn = unwinding?.turnSettled && !unwinding.cancelled && !unwinding.continueOnDrop
3396
+ && !this.starting.has(runId) && run !== undefined && CONTINUABLE_STATUSES.includes(run.status)
3397
+ && run.steps.some((s) => s.sessionId);
3398
+ if (!settledTurn)
3399
+ return { ok: false, error: 'run is still active' };
3400
+ const runner = opts.runner ?? run.runner ?? 'claude';
3401
+ if (opts.model && modelConflictsWithRunner(opts.model, runner)) {
3402
+ return { ok: false, error: `model '${opts.model}' is not a ${runner} model` };
3403
+ }
3404
+ unwinding.continueOnDrop = { opts, deferForCapacity };
3405
+ return { ok: true };
3406
+ }
3378
3407
  if (!run)
3379
3408
  return { ok: false, error: 'not found' };
3380
3409
  // `review` is continuable too — that's the "Send back" path (spec 009).
3381
- if (!['done', 'failed', 'cancelled', 'review'].includes(run.status)) {
3410
+ if (!CONTINUABLE_STATUSES.includes(run.status)) {
3382
3411
  return { ok: false, error: `cannot continue a ${run.status} run` };
3383
3412
  }
3384
3413
  const sessionStep = [...run.steps].reverse().find((s) => s.sessionId);
@@ -3428,10 +3457,14 @@ export class RunManager {
3428
3457
  // `opus` would survive a switch to codex and `runContinuation` would hand it to the codex
3429
3458
  // runner. Clearing (not rejecting) is right — the pin belonged to the old backend and is
3430
3459
  // meaningless for the new one, which is exactly what the composer already displays (auto).
3431
- // Only a recognizably foreign preset is cleared; a free-form/custom id is left alone.
3460
+ // On a real switch only a pin native to the target survives: Claude accepts gateway ids, so
3461
+ // the conflict guard alone let OpenCode's `openai/gpt-5.1` reach `claude --model` (8e1173b1).
3462
+ const runnerSwitched = targetRunner !== (run.runner ?? 'claude');
3432
3463
  const inheritedPinIsForeign = opts.model === undefined &&
3433
3464
  run.model !== undefined &&
3434
- modelConflictsWithRunner(run.model, targetRunner);
3465
+ (runnerSwitched
3466
+ ? !modelNativeToRunner(run.model, targetRunner)
3467
+ : modelConflictsWithRunner(run.model, targetRunner));
3435
3468
  // An account belongs to ONE agent, so a runner switch that names no account must not leave
3436
3469
  // the previous backend's login on the record. It is inert immediately (resolution applies
3437
3470
  // the run's account only to steps on the run's own runner) and wrong later, when a further
@@ -3550,7 +3583,7 @@ export class RunManager {
3550
3583
  // portable context from Cezar's durable record + redacted event stream before this new turn's
3551
3584
  // user-message is appended. This works even when the interrupted agent never wrote HANDOFF.md.
3552
3585
  const portableContext = record && sessionId === undefined
3553
- ? freshContinuationContext(record, this.store.readEvents(runId))
3586
+ ? freshContinuationContext(record, this.store.readEvents(runId), this.attachmentsDir(runId))
3554
3587
  : undefined;
3555
3588
  // The record is mutated in place below; a missing-session fallback needs it as it was.
3556
3589
  const recordBeforeTurn = record && sessionId !== undefined
@@ -4020,7 +4053,7 @@ export class RunManager {
4020
4053
  const freshId = randomUUID();
4021
4054
  this.store.updateStep(runId, stepId, { sessionId: freshId });
4022
4055
  this.store.appendEvent(runId, { type: 'note', stepId, message: MISSING_SESSION_NOTE });
4023
- const context = freshContinuationContext({ ...recordBeforeTurn, steps: recordBeforeTurn.steps.filter((step) => step.id !== stepId) }, this.store.readEvents(runId).filter((event) => event.stepId !== stepId));
4056
+ const context = freshContinuationContext({ ...recordBeforeTurn, steps: recordBeforeTurn.steps.filter((step) => step.id !== stepId) }, this.store.readEvents(runId).filter((event) => event.stepId !== stepId), this.attachmentsDir(runId));
4024
4057
  await trackFallbackOutcome(() => {
4025
4058
  session = launch(freshId, false, context);
4026
4059
  for (const content of replay)
@@ -4033,6 +4066,8 @@ export class RunManager {
4033
4066
  if (sessionError)
4034
4067
  throw new Error(sessionError);
4035
4068
  }
4069
+ // Before any branch below publishes a terminal status: the finally's autosave comes after it.
4070
+ state.turnSettled = true;
4036
4071
  sink.sessionEnded(state.cancelled ? 'cancelled' : 'end_turn');
4037
4072
  if (state.cancelled && this.active.get(runId) === state) {
4038
4073
  this.store.updateStep(runId, stepId, { status: 'cancelled', finishedAt: finishedAt() });
@@ -4077,6 +4112,7 @@ export class RunManager {
4077
4112
  }
4078
4113
  catch (err) {
4079
4114
  const message = err instanceof Error ? err.message : String(err);
4115
+ state.turnSettled = true;
4080
4116
  sink.sessionEnded('error', message);
4081
4117
  if (!state.cancelled && this.active.get(runId) === state) {
4082
4118
  this.store.updateStep(runId, stepId, { status: 'failed', error: message, finishedAt: finishedAt() });
@@ -4427,6 +4463,8 @@ export class RunManager {
4427
4463
  // No settlement branch below may touch that newer owner.
4428
4464
  if (this.active.get(runId) !== state)
4429
4465
  return;
4466
+ // Same window as `runContinuation`'s: whatever settles below is final once teardown lets go.
4467
+ state.turnSettled = true;
4430
4468
  const finishedAt = new Date().toISOString();
4431
4469
  if (state.cancelled && this.active.get(runId) === state) {
4432
4470
  const run = this.store.getRun(runId);
@@ -5991,7 +6029,7 @@ export class RunManager {
5991
6029
  const freshId = randomUUID();
5992
6030
  this.store.updateStep(runId, step.id, { sessionId: freshId, backend });
5993
6031
  emit({ type: 'note', stepId: step.id, message: MISSING_SESSION_NOTE });
5994
- const context = freshContinuationContext(record, this.store.readEvents(runId));
6032
+ const context = freshContinuationContext(record, this.store.readEvents(runId), this.attachmentsDir(runId));
5995
6033
  result = await trackFallbackOutcome(() => {
5996
6034
  session = attach(launch(freshId, false, `${context}\n\n---\n\n## New user instruction\n${userPrompt}`), false);
5997
6035
  for (const content of replay)