@wjarka/cezarion 0.17.0-dev.5506 → 0.17.0-dev.5511

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.
@@ -27,18 +27,6 @@ export declare function delegationFailure(error: unknown): {
27
27
  export declare function createDelegationRoutes(service: DelegationService, credentials: CredentialRegistry): import("hono/hono-base").HonoBase<Env, {
28
28
  "/list": {
29
29
  $get: {
30
- output: {
31
- error: string;
32
- code?: "invalid_input" | undefined;
33
- };
34
- outputFormat: "json";
35
- status: 400;
36
- input: {
37
- query: {
38
- offset?: string | undefined;
39
- };
40
- };
41
- } | {
42
30
  output: {
43
31
  workers: {
44
32
  workerId: string;
@@ -76,6 +64,18 @@ export declare function createDelegationRoutes(service: DelegationService, crede
76
64
  offset?: string | undefined;
77
65
  };
78
66
  };
67
+ } | {
68
+ output: {
69
+ error: string;
70
+ code?: "invalid_input" | undefined;
71
+ };
72
+ outputFormat: "json";
73
+ status: 400;
74
+ input: {
75
+ query: {
76
+ offset?: string | undefined;
77
+ };
78
+ };
79
79
  };
80
80
  };
81
81
  } & {
@@ -613,18 +613,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
613
613
  } & {
614
614
  "/:workerId": {
615
615
  $get: {
616
- output: {
617
- error: string;
618
- code?: "invalid_input" | undefined;
619
- };
620
- outputFormat: "json";
621
- status: 400;
622
- input: {
623
- param: {
624
- workerId: string;
625
- };
626
- };
627
- } | {
628
616
  output: {
629
617
  workerId: string;
630
618
  parentRunId: string;
@@ -728,11 +716,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
728
716
  workerId: string;
729
717
  };
730
718
  };
731
- };
732
- };
733
- } & {
734
- "/:workerId/collect": {
735
- $post: {
719
+ } | {
736
720
  output: {
737
721
  error: string;
738
722
  code?: "invalid_input" | undefined;
@@ -743,10 +727,12 @@ export declare function createDelegationRoutes(service: DelegationService, crede
743
727
  param: {
744
728
  workerId: string;
745
729
  };
746
- } & {
747
- json: Record<string, never>;
748
730
  };
749
- } | {
731
+ };
732
+ };
733
+ } & {
734
+ "/:workerId/collect": {
735
+ $post: {
750
736
  output: {
751
737
  workerId: string;
752
738
  parentRunId: string;
@@ -848,11 +834,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
848
834
  } & {
849
835
  json: Record<string, never>;
850
836
  };
851
- };
852
- };
853
- } & {
854
- "/:workerId/steer": {
855
- $post: {
837
+ } | {
856
838
  output: {
857
839
  error: string;
858
840
  code?: "invalid_input" | undefined;
@@ -864,11 +846,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
864
846
  workerId: string;
865
847
  };
866
848
  } & {
867
- json: {
868
- text: string;
869
- };
849
+ json: Record<string, never>;
870
850
  };
871
- } | {
851
+ };
852
+ };
853
+ } & {
854
+ "/:workerId/steer": {
855
+ $post: {
872
856
  output: {
873
857
  workerId: string;
874
858
  state: "delivered" | "queued";
@@ -884,11 +868,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
884
868
  text: string;
885
869
  };
886
870
  };
887
- };
888
- };
889
- } & {
890
- "/:workerId/stop": {
891
- $post: {
871
+ } | {
892
872
  output: {
893
873
  error: string;
894
874
  code?: "invalid_input" | undefined;
@@ -900,9 +880,15 @@ export declare function createDelegationRoutes(service: DelegationService, crede
900
880
  workerId: string;
901
881
  };
902
882
  } & {
903
- json: Record<string, never>;
883
+ json: {
884
+ text: string;
885
+ };
904
886
  };
905
- } | {
887
+ };
888
+ };
889
+ } & {
890
+ "/:workerId/stop": {
891
+ $post: {
906
892
  output: {
907
893
  workerId: string;
908
894
  state: "stopping" | "terminated";
@@ -916,11 +902,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
916
902
  } & {
917
903
  json: Record<string, never>;
918
904
  };
919
- };
920
- };
921
- } & {
922
- "/:workerId/destroy": {
923
- $post: {
905
+ } | {
924
906
  output: {
925
907
  error: string;
926
908
  code?: "invalid_input" | undefined;
@@ -934,7 +916,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
934
916
  } & {
935
917
  json: Record<string, never>;
936
918
  };
937
- } | {
919
+ };
920
+ };
921
+ } & {
922
+ "/:workerId/destroy": {
923
+ $post: {
938
924
  output: {
939
925
  workerId: string;
940
926
  state: "complete" | "incomplete";
@@ -957,6 +943,20 @@ export declare function createDelegationRoutes(service: DelegationService, crede
957
943
  } & {
958
944
  json: Record<string, never>;
959
945
  };
946
+ } | {
947
+ output: {
948
+ error: string;
949
+ code?: "invalid_input" | undefined;
950
+ };
951
+ outputFormat: "json";
952
+ status: 400;
953
+ input: {
954
+ param: {
955
+ workerId: string;
956
+ };
957
+ } & {
958
+ json: Record<string, never>;
959
+ };
960
960
  } | {
961
961
  output: {
962
962
  workerId: string;
@@ -986,11 +986,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
986
986
  "/:workerId/diff": {
987
987
  $get: {
988
988
  output: {
989
- error: string;
990
- code?: "invalid_input" | undefined;
989
+ workerId: string;
990
+ baselineSha: string;
991
+ diff: string;
992
+ truncated: boolean;
991
993
  };
992
994
  outputFormat: "json";
993
- status: 400;
995
+ status: 200;
994
996
  input: {
995
997
  param: {
996
998
  workerId: string;
@@ -998,13 +1000,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
998
1000
  };
999
1001
  } | {
1000
1002
  output: {
1001
- workerId: string;
1002
- baselineSha: string;
1003
- diff: string;
1004
- truncated: boolean;
1003
+ error: string;
1004
+ code?: "invalid_input" | undefined;
1005
1005
  };
1006
1006
  outputFormat: "json";
1007
- status: 200;
1007
+ status: 400;
1008
1008
  input: {
1009
1009
  param: {
1010
1010
  workerId: string;
@@ -1,7 +1,5 @@
1
1
  import type { RunManager } from '../workflows/run.ts';
2
2
  import type { RunRecord, RunStore } from '../runs/store.ts';
3
- export declare const worktreeOf: (run: RunRecord) => string | null;
4
- export declare const workingDirectoryOf: (run: RunRecord, repoRoot: string) => string | null;
5
3
  export declare const NO_WORKTREE = "no worktree \u2014 this task ran directly in the repo working tree";
6
4
  export type CheckoutIntent = 'read' | 'mutate' | 'publish' | 'remove' | 'open';
7
5
  export interface RunCheckoutHost {
@@ -24,6 +22,7 @@ type ReadHandle<Rule extends ReadDirectoryRule> = {
24
22
  run: RunRecord;
25
23
  directory: Rule extends 'existing-worktree' ? string | null : string;
26
24
  };
27
- /** Read admission is synchronous and never claims, adopts or rebuilds a checkout. */
25
+ /** Read and mutate admission is synchronous and never claims, adopts or rebuilds a checkout. */
28
26
  export declare function runCheckout<Rule extends ReadDirectoryRule>(host: RunCheckoutHost, id: string, _intent: Extract<CheckoutIntent, 'read'>, options: ReadOptions<Rule>): CheckoutRefusal | ReadHandle<Rule>;
27
+ export declare function runCheckout(host: RunCheckoutHost, id: string, intent: Extract<CheckoutIntent, 'mutate'>): CheckoutRefusal | ReadHandle<'working-directory'>;
29
28
  export {};
@@ -5,12 +5,12 @@ import { autosaveCleanupBlocker } from '../autosave-cleanup.js';
5
5
  // protected surface). Isolated runs read their worktree; worktree-off runs
6
6
  // read the repo checkout they executed in. Every predictable git failure
7
7
  // degrades to 409 + human-readable reason, 404 only for unknown ids.
8
- export const worktreeOf = (run) => run.worktreePath && existsSync(run.worktreePath) ? run.worktreePath : null;
9
- export const workingDirectoryOf = (run, repoRoot) => run.worktree === false
8
+ const worktreeOf = (run) => run.worktreePath && existsSync(run.worktreePath) ? run.worktreePath : null;
9
+ const workingDirectoryOf = (run, repoRoot) => run.worktree === false
10
10
  ? repoRoot
11
11
  : worktreeOf(run);
12
12
  export const NO_WORKTREE = 'no worktree — this task ran directly in the repo working tree';
13
- export function runCheckout({ root, store }, id, _intent, options) {
13
+ export function runCheckout({ root, store }, id, intent, options = { checksAutosave: true, directory: 'existing-worktree' }) {
14
14
  const run = store.getRun(id);
15
15
  if (!run)
16
16
  return { status: 404, body: { error: 'not found' } };
@@ -23,7 +23,7 @@ export function runCheckout({ root, store }, id, _intent, options) {
23
23
  return { run, directory: run.worktreePath ?? root };
24
24
  }
25
25
  const directory = options.directory === 'existing-worktree' ? worktreeOf(run) : workingDirectoryOf(run, root);
26
- if (!directory && options.directory === 'working-directory') {
26
+ if (!directory && (intent === 'mutate' || options.directory === 'working-directory')) {
27
27
  return { status: 409, body: { error: NO_WORKTREE } };
28
28
  }
29
29
  return { run, directory };
@@ -1 +1 @@
1
- {"version":3,"file":"run-checkout.js","sourceRoot":"","sources":["../../src/server/run-checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAIhE,+EAA+E;AAC/E,wFAAwF;AACxF,2EAA2E;AAC3E,yEAAyE;AACzE,qEAAqE;AACrE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAc,EAAiB,EAAE,CAC1D,GAAG,CAAC,YAAY,IAAI,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAc,EAAE,QAAgB,EAAiB,EAAE,CACpF,GAAG,CAAC,QAAQ,KAAK,KAAK;IACpB,CAAC,CAAC,QAAQ;IACV,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACtB,MAAM,CAAC,MAAM,WAAW,GAAG,+DAA+D,CAAC;AA2B3F,MAAM,UAAU,WAAW,CACzB,EAAE,IAAI,EAAE,KAAK,EAAmB,EAChC,EAAU,EACV,OAAwC,EACxC,OAAuC;IAEvC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,CAAC;IAC/D,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,sBAAsB,CAAC,KAAK,CAAC,aAAa,C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,CAAC,EAAE,CAAC;QACrF,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,CAAC;IACvD,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;AAC5B,CAAC"}
@@ -19352,22 +19352,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
19352
19352
  error: string;
19353
19353
  };
19354
19354
  outputFormat: "json";
19355
- status: 404;
19356
- input: {
19357
- json: {
19358
- message: string;
19359
- };
19360
- } & {
19361
- param: {
19362
- id: string;
19363
- };
19364
- };
19365
- } | {
19366
- output: {
19367
- error: string;
19368
- };
19369
- outputFormat: "json";
19370
- status: 409;
19355
+ status: 404 | 409;
19371
19356
  input: {
19372
19357
  json: {
19373
19358
  message: string;
@@ -19402,18 +19387,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
19402
19387
  error: string;
19403
19388
  };
19404
19389
  outputFormat: "json";
19405
- status: 404;
19406
- input: {
19407
- param: {
19408
- id: string;
19409
- };
19410
- };
19411
- } | {
19412
- output: {
19413
- error: string;
19414
- };
19415
- outputFormat: "json";
19416
- status: 409;
19390
+ status: 404 | 409;
19417
19391
  input: {
19418
19392
  param: {
19419
19393
  id: string;
@@ -35322,22 +35296,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
35322
35296
  error: string;
35323
35297
  };
35324
35298
  outputFormat: "json";
35325
- status: 404;
35326
- input: {
35327
- json: {
35328
- message: string;
35329
- };
35330
- } & {
35331
- param: {
35332
- id: string;
35333
- };
35334
- };
35335
- } | {
35336
- output: {
35337
- error: string;
35338
- };
35339
- outputFormat: "json";
35340
- status: 409;
35299
+ status: 404 | 409;
35341
35300
  input: {
35342
35301
  json: {
35343
35302
  message: string;
@@ -35372,18 +35331,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
35372
35331
  error: string;
35373
35332
  };
35374
35333
  outputFormat: "json";
35375
- status: 404;
35376
- input: {
35377
- param: {
35378
- id: string;
35379
- };
35380
- };
35381
- } | {
35382
- output: {
35383
- error: string;
35384
- };
35385
- outputFormat: "json";
35386
- status: 409;
35334
+ status: 404 | 409;
35387
35335
  input: {
35388
35336
  param: {
35389
35337
  id: string;
@@ -1,4 +1,4 @@
1
- import { runCheckout, worktreeOf, NO_WORKTREE } from './run-checkout.js';
1
+ import { runCheckout, NO_WORKTREE } from './run-checkout.js';
2
2
  import { adoptFallbackControl, protectFallbackRun, runArtifactDirectory } from './project-run-files.js';
3
3
  import { deleteSavedWorkflow } from './workflow-files.js';
4
4
  import { projectPaths, fallbackProjectWriteError } from '../project-paths.js';
@@ -36,7 +36,6 @@ import { CompletionActionCoordinator } from './completion-actions.js';
36
36
  import { resolveArchiveOnMerge, resolveGlobalArchiveOnMerge } from '../archive-on-merge-setting.js';
37
37
  import { permissionDecisionSchema } from '../contract/index.js';
38
38
  import { runIdParamSchema as permissionRunIdParamSchema } from '../contract/index.js';
39
- import { autosaveCleanupBlocker } from '../autosave-cleanup.js';
40
39
  import { CheckoutProgressCache } from './checkout-progress.js';
41
40
  import { checkoutProgressParamsSchema, createProjectInputSchema } from '../contract/index.js';
42
41
  import { createWorkspaceLiveRoutes } from './workspace-live-routes.js';
@@ -3491,34 +3490,22 @@ export function createApp(deps) {
3491
3490
  });
3492
3491
  })
3493
3492
  .post('/runs/:id/git/commit', jsonZodValidator(gitCommitSchema), async (c) => {
3494
- const { store } = c.get('project');
3495
- const run = store.getRun(c.req.param('id'));
3496
- if (!run)
3497
- return c.json({ error: 'not found' }, 404);
3498
- const blocker = autosaveCleanupBlocker(store.sourceDataDir(run.id), run.id);
3499
- if (blocker)
3500
- return c.json({ error: blocker }, 409);
3501
- const worktree = worktreeOf(run);
3502
- if (!worktree)
3503
- return c.json({ error: NO_WORKTREE }, 409);
3493
+ const checkout = runCheckout(c.get('project'), c.req.param('id'), 'mutate');
3494
+ if ('status' in checkout)
3495
+ return c.json(checkout.body, checkout.status);
3504
3496
  const parsed = { data: c.req.valid('json') };
3505
- const result = await commitAll(worktree, parsed.data.message);
3497
+ const result = await commitAll(checkout.directory, parsed.data.message);
3506
3498
  if (!result.ok)
3507
3499
  return c.json({ error: result.error }, 409);
3508
3500
  return c.json({ committed: true, sha: result.sha });
3509
3501
  })
3510
3502
  .post('/runs/:id/git/push', async (c) => {
3511
- const { root: repoRoot, store } = c.get('project');
3512
- const run = store.getRun(c.req.param('id'));
3513
- if (!run)
3514
- return c.json({ error: 'not found' }, 404);
3515
- const blocker = autosaveCleanupBlocker(store.sourceDataDir(run.id), run.id);
3516
- if (blocker)
3517
- return c.json({ error: blocker }, 409);
3518
- const worktree = worktreeOf(run);
3519
- if (!worktree)
3520
- return c.json({ error: NO_WORKTREE }, 409);
3521
- const result = await pushCurrentBranch(worktree);
3503
+ const { root: repoRoot } = c.get('project');
3504
+ const checkout = runCheckout(c.get('project'), c.req.param('id'), 'mutate');
3505
+ if ('status' in checkout)
3506
+ return c.json(checkout.body, checkout.status);
3507
+ const { run } = checkout;
3508
+ const result = await pushCurrentBranch(checkout.directory);
3522
3509
  if (!result.ok)
3523
3510
  return c.json({ error: result.error }, 409);
3524
3511
  const repoBase = forgeWebRoot((await getRepoInfo(repoRoot))?.remote) ?? undefined;