@wjarka/cezarion 0.17.0-dev.5487 → 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 (62) hide show
  1. package/dist/ci-wait/controller.d.ts +37 -37
  2. package/dist/server/run-checkout.d.ts +29 -0
  3. package/dist/server/run-checkout.js +31 -0
  4. package/dist/server/run-checkout.js.map +1 -0
  5. package/dist/server/self-update-routes.d.ts +19 -19
  6. package/dist/server/server.d.ts +60 -216
  7. package/dist/server/server.js +28 -54
  8. package/dist/server/server.js.map +1 -1
  9. package/dist/workflows/run/compose.d.ts +0 -5
  10. package/dist/workflows/run/compose.js +32 -46
  11. package/dist/workflows/run/compose.js.map +1 -1
  12. package/dist/workflows/run/family-reconciler.d.ts +2 -6
  13. package/dist/workflows/run/family-reconciler.js +7 -9
  14. package/dist/workflows/run/family-reconciler.js.map +1 -1
  15. package/dist/workflows/run/human-waits.d.ts +0 -2
  16. package/dist/workflows/run/human-waits.js +10 -7
  17. package/dist/workflows/run/human-waits.js.map +1 -1
  18. package/dist/workflows/run/input-delivery.d.ts +2 -2
  19. package/dist/workflows/run/input-delivery.js +2 -2
  20. package/dist/workflows/run/input-delivery.js.map +1 -1
  21. package/dist/workflows/run/run-cancel.d.ts +4 -4
  22. package/dist/workflows/run/run-cancel.js +5 -5
  23. package/dist/workflows/run/run-cancel.js.map +1 -1
  24. package/dist/workflows/run/run-finish.d.ts +2 -2
  25. package/dist/workflows/run/run-finish.js +1 -1
  26. package/dist/workflows/run/run-finish.js.map +1 -1
  27. package/dist/workflows/run/run-recovery.d.ts +0 -4
  28. package/dist/workflows/run/run-recovery.js +10 -8
  29. package/dist/workflows/run/run-recovery.js.map +1 -1
  30. package/dist/workflows/run/step-loop.d.ts +2 -2
  31. package/dist/workflows/run/step-loop.js +1 -1
  32. package/dist/workflows/run/step-loop.js.map +1 -1
  33. package/dist/workflows/run/subagent-waits.d.ts +1 -6
  34. package/dist/workflows/run/subagent-waits.js +5 -17
  35. package/dist/workflows/run/subagent-waits.js.map +1 -1
  36. package/dist/workflows/run/turn-settler.d.ts +0 -2
  37. package/dist/workflows/run/turn-settler.js +3 -6
  38. package/dist/workflows/run/turn-settler.js.map +1 -1
  39. package/dist/workflows/run/wait-engine.d.ts +1186 -28
  40. package/dist/workflows/run/wait-engine.js +399 -50
  41. package/dist/workflows/run/wait-engine.js.map +1 -1
  42. package/dist/workflows/run/wait-kinds.d.ts +5 -3
  43. package/dist/workflows/run/wait-kinds.js +5 -6
  44. package/dist/workflows/run/wait-kinds.js.map +1 -1
  45. package/dist/workflows/run/wait-registry.d.ts +5 -7
  46. package/dist/workflows/run/wait-registry.js +61 -60
  47. package/dist/workflows/run/wait-registry.js.map +1 -1
  48. package/dist/workflows/run/wake-admission.d.ts +2 -4
  49. package/dist/workflows/run/wake-admission.js +4 -4
  50. package/dist/workflows/run/wake-admission.js.map +1 -1
  51. package/dist/workflows/run.js +3 -5
  52. package/dist/workflows/run.js.map +1 -1
  53. package/dist/workflows/wait-scope.d.ts +0 -5
  54. package/dist/workflows/wait-scope.js +1 -5
  55. package/dist/workflows/wait-scope.js.map +1 -1
  56. package/package.json +3 -3
  57. package/dist/workflows/run/wait-cancellation.d.ts +0 -34
  58. package/dist/workflows/run/wait-cancellation.js +0 -54
  59. package/dist/workflows/run/wait-cancellation.js.map +0 -1
  60. package/dist/workflows/run/wait-resolve.d.ts +0 -1139
  61. package/dist/workflows/run/wait-resolve.js +0 -313
  62. package/dist/workflows/run/wait-resolve.js.map +0 -1
@@ -5300,19 +5300,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
5300
5300
  } & {
5301
5301
  "/repo/commit/:sha": {
5302
5302
  $get: {
5303
- output: string;
5304
- outputFormat: "text";
5305
- status: import("hono/utils/http-status").ContentfulStatusCode;
5306
- input: {
5307
- query: {
5308
- structured?: string | undefined;
5309
- };
5310
- } & {
5311
- param: {
5312
- sha: string;
5313
- };
5314
- };
5315
- } | {
5316
5303
  output: {
5317
5304
  error: string;
5318
5305
  code?: "invalid_input" | undefined;
@@ -5376,6 +5363,19 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
5376
5363
  sha: string;
5377
5364
  };
5378
5365
  };
5366
+ } | {
5367
+ output: string;
5368
+ outputFormat: "text";
5369
+ status: import("hono/utils/http-status").ContentfulStatusCode;
5370
+ input: {
5371
+ query: {
5372
+ structured?: string | undefined;
5373
+ };
5374
+ } & {
5375
+ param: {
5376
+ sha: string;
5377
+ };
5378
+ };
5379
5379
  };
5380
5380
  };
5381
5381
  } & {
@@ -18725,20 +18725,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
18725
18725
  } & {
18726
18726
  "/runs/:id/handoff": {
18727
18727
  $get: {
18728
- output: string;
18729
- outputFormat: "text";
18730
- status: 200;
18728
+ output: {
18729
+ error: string;
18730
+ };
18731
+ outputFormat: "json";
18732
+ status: 404;
18731
18733
  input: {
18732
18734
  param: {
18733
18735
  id: string;
18734
18736
  };
18735
18737
  };
18736
18738
  } | {
18737
- output: {
18738
- error: string;
18739
- };
18740
- outputFormat: "json";
18741
- status: 404;
18739
+ output: string;
18740
+ outputFormat: "text";
18741
+ status: 200;
18742
18742
  input: {
18743
18743
  param: {
18744
18744
  id: string;
@@ -18776,31 +18776,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
18776
18776
  } & {
18777
18777
  "/runs/:id/diff": {
18778
18778
  $get: {
18779
- output: string;
18780
- outputFormat: "text";
18781
- status: import("hono/utils/http-status").ContentfulStatusCode;
18782
- input: {
18783
- param: {
18784
- id: string;
18785
- };
18786
- };
18787
- } | {
18788
18779
  output: {
18789
18780
  error: string;
18790
18781
  };
18791
18782
  outputFormat: "json";
18792
- status: 404;
18783
+ status: 404 | 409;
18793
18784
  input: {
18794
18785
  param: {
18795
18786
  id: string;
18796
18787
  };
18797
18788
  };
18798
18789
  } | {
18799
- output: {
18800
- error: string;
18801
- };
18802
- outputFormat: "json";
18803
- status: 409;
18790
+ output: string;
18791
+ outputFormat: "text";
18792
+ status: import("hono/utils/http-status").ContentfulStatusCode;
18804
18793
  input: {
18805
18794
  param: {
18806
18795
  id: string;
@@ -18815,18 +18804,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
18815
18804
  error: string;
18816
18805
  };
18817
18806
  outputFormat: "json";
18818
- status: 404;
18819
- input: {
18820
- param: {
18821
- id: string;
18822
- };
18823
- };
18824
- } | {
18825
- output: {
18826
- error: string;
18827
- };
18828
- outputFormat: "json";
18829
- status: 409;
18807
+ status: 404 | 409;
18830
18808
  input: {
18831
18809
  param: {
18832
18810
  id: string;
@@ -18870,18 +18848,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
18870
18848
  error: string;
18871
18849
  };
18872
18850
  outputFormat: "json";
18873
- status: 404;
18874
- input: {
18875
- param: {
18876
- id: string;
18877
- };
18878
- };
18879
- } | {
18880
- output: {
18881
- error: string;
18882
- };
18883
- outputFormat: "json";
18884
- status: 409;
18851
+ status: 404 | 409;
18885
18852
  input: {
18886
18853
  param: {
18887
18854
  id: string;
@@ -18912,20 +18879,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
18912
18879
  error: string;
18913
18880
  };
18914
18881
  outputFormat: "json";
18915
- status: 404;
18916
- input: {
18917
- param: {
18918
- id: string;
18919
- } & {
18920
- sha: string;
18921
- };
18922
- };
18923
- } | {
18924
- output: {
18925
- error: string;
18926
- };
18927
- outputFormat: "json";
18928
- status: 409;
18882
+ status: 404 | 409;
18929
18883
  input: {
18930
18884
  param: {
18931
18885
  id: string;
@@ -19004,23 +18958,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
19004
18958
  error: string;
19005
18959
  };
19006
18960
  outputFormat: "json";
19007
- status: 404;
19008
- input: {
19009
- param: {
19010
- id: string;
19011
- };
19012
- } & {
19013
- query: {
19014
- path: string | string[];
19015
- raw?: "1" | undefined;
19016
- };
19017
- };
19018
- } | {
19019
- output: {
19020
- error: string;
19021
- };
19022
- outputFormat: "json";
19023
- status: 409;
18961
+ status: 404 | 409;
19024
18962
  input: {
19025
18963
  param: {
19026
18964
  id: string;
@@ -19351,23 +19289,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
19351
19289
  error: string;
19352
19290
  };
19353
19291
  outputFormat: "json";
19354
- status: 404;
19355
- input: {
19356
- query: {
19357
- path?: string | undefined;
19358
- raw?: string | undefined;
19359
- };
19360
- } & {
19361
- param: {
19362
- id: string;
19363
- };
19364
- };
19365
- } | {
19366
- output: {
19367
- error: string;
19368
- };
19369
- outputFormat: "json";
19370
- status: 409;
19292
+ status: 404 | 409;
19371
19293
  input: {
19372
19294
  query: {
19373
19295
  path?: string | undefined;
@@ -21348,19 +21270,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
21348
21270
  } & {
21349
21271
  "/repo/commit/:sha": {
21350
21272
  $get: {
21351
- output: string;
21352
- outputFormat: "text";
21353
- status: import("hono/utils/http-status").ContentfulStatusCode;
21354
- input: {
21355
- query: {
21356
- structured?: string | undefined;
21357
- };
21358
- } & {
21359
- param: {
21360
- sha: string;
21361
- };
21362
- };
21363
- } | {
21364
21273
  output: {
21365
21274
  error: string;
21366
21275
  code?: "invalid_input" | undefined;
@@ -21424,6 +21333,19 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
21424
21333
  sha: string;
21425
21334
  };
21426
21335
  };
21336
+ } | {
21337
+ output: string;
21338
+ outputFormat: "text";
21339
+ status: import("hono/utils/http-status").ContentfulStatusCode;
21340
+ input: {
21341
+ query: {
21342
+ structured?: string | undefined;
21343
+ };
21344
+ } & {
21345
+ param: {
21346
+ sha: string;
21347
+ };
21348
+ };
21427
21349
  };
21428
21350
  };
21429
21351
  } & {
@@ -34773,20 +34695,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
34773
34695
  } & {
34774
34696
  "/runs/:id/handoff": {
34775
34697
  $get: {
34776
- output: string;
34777
- outputFormat: "text";
34778
- status: 200;
34698
+ output: {
34699
+ error: string;
34700
+ };
34701
+ outputFormat: "json";
34702
+ status: 404;
34779
34703
  input: {
34780
34704
  param: {
34781
34705
  id: string;
34782
34706
  };
34783
34707
  };
34784
34708
  } | {
34785
- output: {
34786
- error: string;
34787
- };
34788
- outputFormat: "json";
34789
- status: 404;
34709
+ output: string;
34710
+ outputFormat: "text";
34711
+ status: 200;
34790
34712
  input: {
34791
34713
  param: {
34792
34714
  id: string;
@@ -34824,31 +34746,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
34824
34746
  } & {
34825
34747
  "/runs/:id/diff": {
34826
34748
  $get: {
34827
- output: string;
34828
- outputFormat: "text";
34829
- status: import("hono/utils/http-status").ContentfulStatusCode;
34830
- input: {
34831
- param: {
34832
- id: string;
34833
- };
34834
- };
34835
- } | {
34836
34749
  output: {
34837
34750
  error: string;
34838
34751
  };
34839
34752
  outputFormat: "json";
34840
- status: 404;
34753
+ status: 404 | 409;
34841
34754
  input: {
34842
34755
  param: {
34843
34756
  id: string;
34844
34757
  };
34845
34758
  };
34846
34759
  } | {
34847
- output: {
34848
- error: string;
34849
- };
34850
- outputFormat: "json";
34851
- status: 409;
34760
+ output: string;
34761
+ outputFormat: "text";
34762
+ status: import("hono/utils/http-status").ContentfulStatusCode;
34852
34763
  input: {
34853
34764
  param: {
34854
34765
  id: string;
@@ -34863,18 +34774,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
34863
34774
  error: string;
34864
34775
  };
34865
34776
  outputFormat: "json";
34866
- status: 404;
34867
- input: {
34868
- param: {
34869
- id: string;
34870
- };
34871
- };
34872
- } | {
34873
- output: {
34874
- error: string;
34875
- };
34876
- outputFormat: "json";
34877
- status: 409;
34777
+ status: 404 | 409;
34878
34778
  input: {
34879
34779
  param: {
34880
34780
  id: string;
@@ -34918,18 +34818,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
34918
34818
  error: string;
34919
34819
  };
34920
34820
  outputFormat: "json";
34921
- status: 404;
34922
- input: {
34923
- param: {
34924
- id: string;
34925
- };
34926
- };
34927
- } | {
34928
- output: {
34929
- error: string;
34930
- };
34931
- outputFormat: "json";
34932
- status: 409;
34821
+ status: 404 | 409;
34933
34822
  input: {
34934
34823
  param: {
34935
34824
  id: string;
@@ -34960,20 +34849,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
34960
34849
  error: string;
34961
34850
  };
34962
34851
  outputFormat: "json";
34963
- status: 404;
34964
- input: {
34965
- param: {
34966
- id: string;
34967
- } & {
34968
- sha: string;
34969
- };
34970
- };
34971
- } | {
34972
- output: {
34973
- error: string;
34974
- };
34975
- outputFormat: "json";
34976
- status: 409;
34852
+ status: 404 | 409;
34977
34853
  input: {
34978
34854
  param: {
34979
34855
  id: string;
@@ -35052,23 +34928,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
35052
34928
  error: string;
35053
34929
  };
35054
34930
  outputFormat: "json";
35055
- status: 404;
35056
- input: {
35057
- param: {
35058
- id: string;
35059
- };
35060
- } & {
35061
- query: {
35062
- path: string | string[];
35063
- raw?: "1" | undefined;
35064
- };
35065
- };
35066
- } | {
35067
- output: {
35068
- error: string;
35069
- };
35070
- outputFormat: "json";
35071
- status: 409;
34931
+ status: 404 | 409;
35072
34932
  input: {
35073
34933
  param: {
35074
34934
  id: string;
@@ -35399,23 +35259,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
35399
35259
  error: string;
35400
35260
  };
35401
35261
  outputFormat: "json";
35402
- status: 404;
35403
- input: {
35404
- query: {
35405
- path?: string | undefined;
35406
- raw?: string | undefined;
35407
- };
35408
- } & {
35409
- param: {
35410
- id: string;
35411
- };
35412
- };
35413
- } | {
35414
- output: {
35415
- error: string;
35416
- };
35417
- outputFormat: "json";
35418
- status: 409;
35262
+ status: 404 | 409;
35419
35263
  input: {
35420
35264
  query: {
35421
35265
  path?: string | undefined;
@@ -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';
@@ -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) => {