@wjarka/cezarion 0.17.0-dev.5474 → 0.17.0-dev.5498

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 (100) hide show
  1. package/dist/data-gitignore.js +9 -4
  2. package/dist/data-gitignore.js.map +1 -1
  3. package/dist/git-worktree.d.ts +0 -2
  4. package/dist/git-worktree.js +4 -6
  5. package/dist/git-worktree.js.map +1 -1
  6. package/dist/project-migration/answer.d.ts +2 -0
  7. package/dist/project-migration/answer.js +8 -4
  8. package/dist/project-migration/answer.js.map +1 -1
  9. package/dist/project-migration/auto.js +3 -2
  10. package/dist/project-migration/auto.js.map +1 -1
  11. package/dist/project-migration/engine.d.ts +2 -0
  12. package/dist/project-migration/engine.js +3 -1
  13. package/dist/project-migration/engine.js.map +1 -1
  14. package/dist/project-migration/journal.d.ts +3 -1
  15. package/dist/project-migration/journal.js +2 -1
  16. package/dist/project-migration/journal.js.map +1 -1
  17. package/dist/project-migration/plan.d.ts +2 -0
  18. package/dist/project-migration/plan.js +29 -3
  19. package/dist/project-migration/plan.js.map +1 -1
  20. package/dist/project-migration/steps.js +23 -2
  21. package/dist/project-migration/steps.js.map +1 -1
  22. package/dist/project-paths.d.ts +25 -3
  23. package/dist/project-paths.js +93 -11
  24. package/dist/project-paths.js.map +1 -1
  25. package/dist/runs/retention.js +3 -4
  26. package/dist/runs/retention.js.map +1 -1
  27. package/dist/runs/store.d.ts +2 -2
  28. package/dist/runs/store.js +3 -3
  29. package/dist/runs/store.js.map +1 -1
  30. package/dist/server/project-context.js +3 -2
  31. package/dist/server/project-context.js.map +1 -1
  32. package/dist/server/reports-api.d.ts +2 -2
  33. package/dist/server/run-checkout.d.ts +29 -0
  34. package/dist/server/run-checkout.js +31 -0
  35. package/dist/server/run-checkout.js.map +1 -0
  36. package/dist/server/server.d.ts +60 -216
  37. package/dist/server/server.js +33 -59
  38. package/dist/server/server.js.map +1 -1
  39. package/dist/server/workflow-files.d.ts +1 -1
  40. package/dist/server/workflow-files.js +4 -3
  41. package/dist/server/workflow-files.js.map +1 -1
  42. package/dist/skills.d.ts +1 -1
  43. package/dist/skills.js +3 -2
  44. package/dist/skills.js.map +1 -1
  45. package/dist/ui-state.js +1 -1
  46. package/dist/ui-state.js.map +1 -1
  47. package/dist/workflows/run/compose.d.ts +0 -5
  48. package/dist/workflows/run/compose.js +32 -46
  49. package/dist/workflows/run/compose.js.map +1 -1
  50. package/dist/workflows/run/family-reconciler.d.ts +2 -6
  51. package/dist/workflows/run/family-reconciler.js +7 -9
  52. package/dist/workflows/run/family-reconciler.js.map +1 -1
  53. package/dist/workflows/run/human-waits.d.ts +0 -2
  54. package/dist/workflows/run/human-waits.js +10 -7
  55. package/dist/workflows/run/human-waits.js.map +1 -1
  56. package/dist/workflows/run/input-delivery.d.ts +2 -2
  57. package/dist/workflows/run/input-delivery.js +2 -2
  58. package/dist/workflows/run/input-delivery.js.map +1 -1
  59. package/dist/workflows/run/run-cancel.d.ts +4 -4
  60. package/dist/workflows/run/run-cancel.js +5 -5
  61. package/dist/workflows/run/run-cancel.js.map +1 -1
  62. package/dist/workflows/run/run-finish.d.ts +2 -2
  63. package/dist/workflows/run/run-finish.js +1 -1
  64. package/dist/workflows/run/run-finish.js.map +1 -1
  65. package/dist/workflows/run/run-recovery.d.ts +0 -4
  66. package/dist/workflows/run/run-recovery.js +10 -8
  67. package/dist/workflows/run/run-recovery.js.map +1 -1
  68. package/dist/workflows/run/step-loop.d.ts +2 -2
  69. package/dist/workflows/run/step-loop.js +1 -1
  70. package/dist/workflows/run/step-loop.js.map +1 -1
  71. package/dist/workflows/run/subagent-waits.d.ts +1 -6
  72. package/dist/workflows/run/subagent-waits.js +5 -17
  73. package/dist/workflows/run/subagent-waits.js.map +1 -1
  74. package/dist/workflows/run/turn-settler.d.ts +0 -2
  75. package/dist/workflows/run/turn-settler.js +3 -6
  76. package/dist/workflows/run/turn-settler.js.map +1 -1
  77. package/dist/workflows/run/wait-engine.d.ts +1186 -28
  78. package/dist/workflows/run/wait-engine.js +399 -50
  79. package/dist/workflows/run/wait-engine.js.map +1 -1
  80. package/dist/workflows/run/wait-kinds.d.ts +5 -3
  81. package/dist/workflows/run/wait-kinds.js +5 -6
  82. package/dist/workflows/run/wait-kinds.js.map +1 -1
  83. package/dist/workflows/run/wait-registry.d.ts +5 -7
  84. package/dist/workflows/run/wait-registry.js +61 -60
  85. package/dist/workflows/run/wait-registry.js.map +1 -1
  86. package/dist/workflows/run/wake-admission.d.ts +2 -4
  87. package/dist/workflows/run/wake-admission.js +4 -4
  88. package/dist/workflows/run/wake-admission.js.map +1 -1
  89. package/dist/workflows/run.js +3 -5
  90. package/dist/workflows/run.js.map +1 -1
  91. package/dist/workflows/wait-scope.d.ts +0 -5
  92. package/dist/workflows/wait-scope.js +1 -5
  93. package/dist/workflows/wait-scope.js.map +1 -1
  94. package/package.json +3 -3
  95. package/dist/workflows/run/wait-cancellation.d.ts +0 -34
  96. package/dist/workflows/run/wait-cancellation.js +0 -54
  97. package/dist/workflows/run/wait-cancellation.js.map +0 -1
  98. package/dist/workflows/run/wait-resolve.d.ts +0 -1139
  99. package/dist/workflows/run/wait-resolve.js +0 -313
  100. package/dist/workflows/run/wait-resolve.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { runCheckout, worktreeOf, NO_WORKTREE } from './run-checkout.js';
1
2
  import { adoptFallbackControl, protectFallbackRun, runArtifactDirectory } from './project-run-files.js';
2
3
  import { deleteSavedWorkflow } from './workflow-files.js';
3
4
  import { projectPaths, fallbackProjectWriteError } from '../project-paths.js';
@@ -94,7 +95,7 @@ import { AGENT_MODELS_LOCKED_ERROR, agentModelsLocked } from '../core/agent-mode
94
95
  import { PROVIDER_IDS } from '../core/provider-auth.js';
95
96
  import { applyProviderEnablement } from '../core/provider-availability.js';
96
97
  import { allUsage, currentUsage, onUsage } from '../core/process-usage.js';
97
- import { WORKFLOWS_DIR, loadWorkflows } from '../workflows/load.js';
98
+ import { loadWorkflows } from '../workflows/load.js';
98
99
  import { normalizeWorkflowDoc, skillStackOf, skillsToSteps, stepsIssue, workflowFileSchema, } from '../workflows/types.js';
99
100
  import { planChain, slugify } from '../planner.js';
100
101
  import { discoverSkills } from '../skills.js';
@@ -135,7 +136,7 @@ import { defaultWorkspaceConfig, loadWorkspaceConfig, mergeWriteWorkspaceConfig,
135
136
  import { CONTROL_CHARS_RE, DEFAULT_AGENT_ACCOUNT_ID, defaultAgentAccountStore, isAbsoluteConfigDir, loadAgentAccounts, mergeWriteAgentAccounts, } from '../workspace/agent-accounts.js';
136
137
  import { defaultAgentProfile, listAgentProfiles, namedAccountUnavailable, ompProfileDirError, profileDirState, resolveStoredProfile, sameProfileDir, } from '../workspace/agent-profiles.js';
137
138
  import { PROFILE_CAPABLE_PROVIDERS, profileAgentDir, profileEnv, supportsProfiles } from '../core/agent-profiles.js';
138
- import { quoteExecutable, withEnvPrefix } from '../core/shell-env.js';
139
+ import { quoteExecutable, shellQuote, withEnvPrefix } from '../core/shell-env.js';
139
140
  import { resolveCursorExecutable } from '../core/cursor-model-catalog.js';
140
141
  import { resolveOmpExecutable } from '../core/omp-model-catalog.js';
141
142
  import { allocateProjectSlug, normalizeProjectTags, probeProjectStatus, toProjectListEntry, registerProject, removeProject, shouldRegisterProject, } from '../workspace/projects.js';
@@ -986,10 +987,10 @@ export function createApp(deps) {
986
987
  return unavailable !== null ? { error: unavailable } : { env: profileEnv(provider, profile.path) };
987
988
  };
988
989
  /** The copy-paste fallback shown when no terminal could be opened — same account, spelled for
989
- * this platform's shell. `null` when the dir cannot be embedded safely, which is a refusal. */
990
+ * this platform's shell. `null` when the account environment cannot be embedded safely. */
990
991
  const handoffFallbackCommand = (cwd, command, env) => {
991
992
  const prefixed = withEnvPrefix(command, env, process.platform);
992
- return prefixed === null ? null : `cd '${cwd}' && ${prefixed}`;
993
+ return prefixed === null ? null : `cd ${shellQuote(cwd)} && ${prefixed}`;
993
994
  };
994
995
  /** A registered project's realpath'd root, or null when the id is unknown. */
995
996
  const projectRootFor = async (projectId) => {
@@ -2405,7 +2406,7 @@ export function createApp(deps) {
2405
2406
  if (issue)
2406
2407
  return c.json({ error: issue }, 400);
2407
2408
  const slug = slugify(parsed.data.name) || 'chain';
2408
- const dir = join(repoRoot, WORKFLOWS_DIR);
2409
+ const dir = join(projectPaths(repoRoot).write, 'workflows');
2409
2410
  const path = join(dir, `${slug}.yaml`);
2410
2411
  // Pure skill stacks are written in the portable compact form (spec 012) —
2411
2412
  // `name` + `skills:` — so the file imports cleanly in any repo.
@@ -3301,29 +3302,20 @@ export function createApp(deps) {
3301
3302
  })
3302
3303
  // Task diff (spec 006): what this run changed — its worktree vs its base.
3303
3304
  .get('/runs/:id/diff', async (c) => {
3304
- const { store } = c.get('project');
3305
- const run = store.getRun(c.req.param('id'));
3306
- if (!run)
3307
- return c.json({ error: 'not found' }, 404);
3308
- const blocker = autosaveCleanupBlocker(store.sourceDataDir(run.id), run.id);
3309
- if (blocker)
3310
- return c.json({ error: blocker }, 409);
3311
- if (!run.worktreePath || !existsSync(run.worktreePath)) {
3305
+ const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { checksAutosave: true, directory: 'existing-worktree' });
3306
+ if ('body' in checkout)
3307
+ return c.json(checkout.body, checkout.status);
3308
+ const { run, directory: workingDirectory } = checkout;
3309
+ if (!workingDirectory) {
3312
3310
  return c.text('(no worktree — this task ran directly in the repo working tree)');
3313
3311
  }
3314
- return c.text(await worktreeDiff(run.worktreePath, run.baseBranch ?? 'HEAD'));
3312
+ return c.text(await worktreeDiff(workingDirectory, run.baseBranch ?? 'HEAD'));
3315
3313
  })
3316
3314
  .get('/runs/:id/changes', async (c) => {
3317
- const { root: repoRoot, store } = c.get('project');
3318
- const run = store.getRun(c.req.param('id'));
3319
- if (!run)
3320
- return c.json({ error: 'not found' }, 404);
3321
- const blocker = autosaveCleanupBlocker(store.sourceDataDir(run.id), run.id);
3322
- if (blocker)
3323
- return c.json({ error: blocker }, 409);
3324
- const workingDirectory = workingDirectoryOf(run, repoRoot);
3325
- if (!workingDirectory)
3326
- return c.json({ error: NO_WORKTREE }, 409);
3315
+ const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { checksAutosave: true, directory: 'working-directory' });
3316
+ if ('body' in checkout)
3317
+ return c.json(checkout.body, checkout.status);
3318
+ const { run, directory: workingDirectory } = checkout;
3327
3319
  const result = await collectChanges(workingDirectory, run.baseBranch ?? 'HEAD', {
3328
3320
  taskBranch: run.branch,
3329
3321
  // Anchors a repointed worktree at the branch as this run found it (#751).
@@ -3337,13 +3329,10 @@ export function createApp(deps) {
3337
3329
  })
3338
3330
  // The run's own commits (<base>..HEAD on the worktree branch) — the Commits tab.
3339
3331
  .get('/runs/:id/commits', async (c) => {
3340
- const { root: repoRoot, store } = c.get('project');
3341
- const run = store.getRun(c.req.param('id'));
3342
- if (!run)
3343
- return c.json({ error: 'not found' }, 404);
3344
- const workingDirectory = workingDirectoryOf(run, repoRoot);
3345
- if (!workingDirectory)
3346
- return c.json({ error: NO_WORKTREE }, 409);
3332
+ const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { checksAutosave: false, directory: 'working-directory' });
3333
+ if ('body' in checkout)
3334
+ return c.json(checkout.body, checkout.status);
3335
+ const { run, directory: workingDirectory } = checkout;
3347
3336
  const result = await collectRunCommits(workingDirectory, run.baseBranch ?? 'HEAD');
3348
3337
  if (!result.ok)
3349
3338
  return c.json({ error: result.error }, 409);
@@ -3351,13 +3340,10 @@ export function createApp(deps) {
3351
3340
  })
3352
3341
  // One of the run's commits, structured like the Changes tab (reuses collectCommitChanges).
3353
3342
  .get('/runs/:id/commit/:sha', async (c) => {
3354
- const { root: repoRoot, store } = c.get('project');
3355
- const run = store.getRun(c.req.param('id'));
3356
- if (!run)
3357
- return c.json({ error: 'not found' }, 404);
3358
- const workingDirectory = workingDirectoryOf(run, repoRoot);
3359
- if (!workingDirectory)
3360
- return c.json({ error: NO_WORKTREE }, 409);
3343
+ const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { checksAutosave: false, directory: 'working-directory' });
3344
+ if ('body' in checkout)
3345
+ return c.json(checkout.body, checkout.status);
3346
+ const { directory: workingDirectory } = checkout;
3361
3347
  const result = await collectCommitChanges(workingDirectory, c.req.param('sha'));
3362
3348
  if (!result.ok)
3363
3349
  return c.json({ error: result.error }, 409);
@@ -3365,11 +3351,12 @@ export function createApp(deps) {
3365
3351
  })
3366
3352
  .get('/runs/:id/file-link', paramZodValidator(artifactParamsSchema.omit({ artifactId: true })), queryZodValidator(fileLinkQuerySchema), async (c) => {
3367
3353
  const { root, store } = c.get('project');
3368
- const run = store.getRun(c.req.valid('param').id);
3369
- if (!run)
3370
- return c.json({ error: 'not found' }, 404);
3354
+ const checkout = runCheckout(c.get('project'), c.req.valid('param').id, 'read', { checksAutosave: false, directory: 'recorded-path-or-root' });
3355
+ if ('body' in checkout)
3356
+ return c.json(checkout.body, checkout.status);
3357
+ const { run, directory: workingDirectory } = checkout;
3371
3358
  const query = c.req.valid('query');
3372
- const loaded = await loadFileLink({ dataDir: store.sourceDataDir(run.id), runId: run.id, projectRoot: root, workingDirectory: run.worktreePath ?? root, path: query.path });
3359
+ const loaded = await loadFileLink({ dataDir: store.sourceDataDir(run.id), runId: run.id, projectRoot: root, workingDirectory, path: query.path });
3373
3360
  if (query.raw === '1') {
3374
3361
  if (!loaded.imageBytes || loaded.preview.type !== 'file')
3375
3362
  return c.json({ error: 'Only bounded raster images can be served inline.' }, 409);
@@ -3448,18 +3435,15 @@ export function createApp(deps) {
3448
3435
  // what an `<img>` sends — while the flag still wins whenever it is present and `*<slash>*`
3449
3436
  // (every `fetch`) still gets the JSON listing. See `negotiate`.
3450
3437
  .get('/runs/:id/files', queryZodValidator(worktreeFilesQuerySchema), async (c) => {
3451
- const { root: repoRoot, store } = c.get('project');
3452
3438
  const query = c.req.valid('query');
3453
3439
  c.header('vary', 'Accept');
3454
3440
  const wantsRaw = query.raw !== undefined
3455
3441
  ? query.raw === '1'
3456
3442
  : negotiate(c.req.header('accept'), FILE_FORMATS) === 'image/*';
3457
- const run = store.getRun(c.req.param('id'));
3458
- if (!run)
3459
- return c.json({ error: 'not found' }, 404);
3460
- const workingDirectory = workingDirectoryOf(run, repoRoot);
3461
- if (!workingDirectory)
3462
- return c.json({ error: NO_WORKTREE }, 409);
3443
+ const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { checksAutosave: false, directory: 'working-directory' });
3444
+ if ('body' in checkout)
3445
+ return c.json(checkout.body, checkout.status);
3446
+ const { directory: workingDirectory } = checkout;
3463
3447
  const result = await readWorktreePath(workingDirectory, query.path ?? '');
3464
3448
  if (result.kind === 'invalid' || result.kind === 'missing') {
3465
3449
  return c.json({ error: result.error }, 409);
@@ -3693,16 +3677,6 @@ export function createApp(deps) {
3693
3677
  txt: 'text/plain; charset=utf-8',
3694
3678
  md: 'text/plain; charset=utf-8',
3695
3679
  };
3696
- // ---- session git view (redesign R5 Step 1.2 — §"Git/session API additions").
3697
- // Structured sibling of the text-blob /diff above (which stays untouched —
3698
- // protected surface). Isolated runs read their worktree; worktree-off runs
3699
- // read the repo checkout they executed in. Every predictable git failure
3700
- // degrades to 409 + human-readable reason, 404 only for unknown ids.
3701
- const worktreeOf = (run) => run.worktreePath && existsSync(run.worktreePath) ? run.worktreePath : null;
3702
- const workingDirectoryOf = (run, repoRoot) => run.worktree === false
3703
- ? repoRoot
3704
- : worktreeOf(run);
3705
- const NO_WORKTREE = 'no worktree — this task ran directly in the repo working tree';
3706
3680
  // ---- chained family: worktrees (project-scoped) ----
3707
3681
  const worktreesRoutes = new Hono()
3708
3682
  .get('/worktrees', async (c) => {