@wjarka/cezarion 0.17.0-dev.5648 → 0.17.0-dev.5666

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/contract/index.js +2 -2
  2. package/dist/core/backend-detect.d.ts +2 -1
  3. package/dist/core/backend-detect.js +11 -10
  4. package/dist/core/backend-detect.js.map +1 -1
  5. package/dist/core/claude-ui-mapper.js +5 -4
  6. package/dist/core/claude-ui-mapper.js.map +1 -1
  7. package/dist/core/provider-auth.d.ts +1 -1
  8. package/dist/core/provider-auth.js +2 -1
  9. package/dist/core/provider-auth.js.map +1 -1
  10. package/dist/core/runner-factory.js +5 -0
  11. package/dist/core/runner-factory.js.map +1 -1
  12. package/dist/delegation/execution-identity.js +2 -1
  13. package/dist/delegation/execution-identity.js.map +1 -1
  14. package/dist/delegation/transport.d.ts +62 -62
  15. package/dist/server/reports-api.d.ts +2 -2
  16. package/dist/server/server.d.ts +59 -59
  17. package/dist/voice/routes.d.ts +19 -19
  18. package/package.json +3 -3
  19. package/scripts/parity-rows.ts +160 -0
  20. package/web/dist/assets/{activity-motion-D-wNjCZO.js → activity-motion-CtVYvdRc.js} +1 -1
  21. package/web/dist/assets/{activity-route-CEhKA6LC.js → activity-route-BEZr6b9Y.js} +1 -1
  22. package/web/dist/assets/{agent-accounts-Ch7595Ik.js → agent-accounts-Ce9Q2wTj.js} +1 -1
  23. package/web/dist/assets/{cez-idle-Dchvb7zW.js → cez-idle-BT0U4GN_.js} +1 -1
  24. package/web/dist/assets/{commit-diff-panel-C5SEnKvj.js → commit-diff-panel-B30oa25e.js} +1 -1
  25. package/web/dist/assets/{control-locations-MdIf_g8c.js → control-locations-Cv_zRDaS.js} +1 -1
  26. package/web/dist/assets/{diff-DOKQG121.js → diff-CpkTjlLm.js} +2 -2
  27. package/web/dist/assets/{diff-view-Dlbaomc6.js → diff-view-Bf7YEIF1.js} +1 -1
  28. package/web/dist/assets/{file-preview-6Lhl8Dk0.js → file-preview-Bdw0qHJB.js} +1 -1
  29. package/web/dist/assets/{git-toolbar-B_lgnDi3.js → git-toolbar-DJi8-Bfp.js} +1 -1
  30. package/web/dist/assets/{github-89EDv5jm.js → github-DPa3UFus.js} +1 -1
  31. package/web/dist/assets/{github-sidebar-model-uibw-74Y.js → github-sidebar-model-DcgyXEtm.js} +1 -1
  32. package/web/dist/assets/{global-activity-route-2SM3xKBA.js → global-activity-route-CijiH9Gc.js} +1 -1
  33. package/web/dist/assets/index-BDNQ4NIe.js +14 -0
  34. package/web/dist/assets/{live-protocol-Dzoy6tBK.js → live-protocol-BDY7JJpT.js} +1 -1
  35. package/web/dist/assets/{live-refetch-B33V---w.js → live-refetch-XCxoSAGq.js} +1 -1
  36. package/web/dist/assets/{preview-pane-connected-B730Jv1e.js → preview-pane-connected-DJ3e7KtI.js} +1 -1
  37. package/web/dist/assets/{project-router-BXMyQwq8.js → project-router-DudcMzJa.js} +1 -1
  38. package/web/dist/assets/project-scope-context-DDZVS0W-.js +4 -0
  39. package/web/dist/assets/{queries-BJ37kLsM.js → queries-C6in05vw.js} +1 -1
  40. package/web/dist/assets/{repo-git-D6gQXbHu.js → repo-git-DwFyXJVP.js} +1 -1
  41. package/web/dist/assets/{report-reader-DP43jeNM.js → report-reader-DiG_FZRc.js} +1 -1
  42. package/web/dist/assets/{reports-DV8NzFp3.js → reports-CDhnbSD0.js} +1 -1
  43. package/web/dist/assets/{run-header-DjXPrh23.js → run-header-DGWkKFX-.js} +1 -1
  44. package/web/dist/assets/{skills-DuZYEbo5.js → skills-BvfGIWap.js} +1 -1
  45. package/web/dist/assets/{tab-link-C8fM6fJv.js → tab-link-ACcEPANz.js} +1 -1
  46. package/web/dist/assets/{task-changes-CUWFco57.js → task-changes-Duy_yoTa.js} +1 -1
  47. package/web/dist/assets/{task-commits-Cgoxt66y.js → task-commits-DsZjecLb.js} +1 -1
  48. package/web/dist/assets/{task-files-BmTRfJ5K.js → task-files-WSwRMISh.js} +1 -1
  49. package/web/dist/assets/{task-github-item-Cmro8m-6.js → task-github-item-B89c4yDz.js} +1 -1
  50. package/web/dist/assets/{task-thread-BTjoNRed.js → task-thread-BMa8FQJC.js} +1 -1
  51. package/web/dist/assets/thread-state-D_1f2_nG.js +4 -0
  52. package/web/dist/assets/{use-hand-to-agent-state-C2rQan6D.js → use-hand-to-agent-state-eVuuwFpt.js} +1 -1
  53. package/web/dist/assets/{useInfiniteQuery-DeA0njkn.js → useInfiniteQuery-DpLjNcbu.js} +1 -1
  54. package/web/dist/assets/useQuery-DSoTrqQG.js +1 -0
  55. package/web/dist/assets/{workflows-DemG2-He.js → workflows-iby-hm0Z.js} +1 -1
  56. package/web/dist/assets/{ws-DuLAdddm.js → ws-DKkrIJ6v.js} +1 -1
  57. package/web/dist/index.html +13 -13
  58. package/web/dist/live-worker.js +1 -1
  59. package/web/dist/assets/index-DKIv9VPA.js +0 -14
  60. package/web/dist/assets/project-scope-context-Cr5r5Den.js +0 -4
  61. package/web/dist/assets/thread-state-Cd3ERj1h.js +0 -4
  62. package/web/dist/assets/useQuery-CHXgZpuu.js +0 -1
@@ -2,6 +2,18 @@ import type { DelegationRoutes } from './routes.ts';
2
2
  export declare function createDelegationApp(routes: DelegationRoutes): import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, import("hono/types").BlankSchema | import("hono/types").MergeSchemaPath<{
3
3
  "/list": {
4
4
  $get: {
5
+ output: {
6
+ error: string;
7
+ code?: "invalid_input" | undefined;
8
+ };
9
+ outputFormat: "json";
10
+ status: 400;
11
+ input: {
12
+ query: {
13
+ offset?: string | undefined;
14
+ };
15
+ };
16
+ } | {
5
17
  output: {
6
18
  workers: {
7
19
  workerId: string;
@@ -39,18 +51,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
39
51
  offset?: string | undefined;
40
52
  };
41
53
  };
42
- } | {
43
- output: {
44
- error: string;
45
- code?: "invalid_input" | undefined;
46
- };
47
- outputFormat: "json";
48
- status: 400;
49
- input: {
50
- query: {
51
- offset?: string | undefined;
52
- };
53
- };
54
54
  };
55
55
  };
56
56
  } & {
@@ -588,6 +588,18 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
588
588
  } & {
589
589
  "/:workerId": {
590
590
  $get: {
591
+ output: {
592
+ error: string;
593
+ code?: "invalid_input" | undefined;
594
+ };
595
+ outputFormat: "json";
596
+ status: 400;
597
+ input: {
598
+ param: {
599
+ workerId: string;
600
+ };
601
+ };
602
+ } | {
591
603
  output: {
592
604
  workerId: string;
593
605
  parentRunId: string;
@@ -691,7 +703,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
691
703
  workerId: string;
692
704
  };
693
705
  };
694
- } | {
706
+ };
707
+ };
708
+ } & {
709
+ "/:workerId/collect": {
710
+ $post: {
695
711
  output: {
696
712
  error: string;
697
713
  code?: "invalid_input" | undefined;
@@ -702,12 +718,10 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
702
718
  param: {
703
719
  workerId: string;
704
720
  };
721
+ } & {
722
+ json: Record<string, never>;
705
723
  };
706
- };
707
- };
708
- } & {
709
- "/:workerId/collect": {
710
- $post: {
724
+ } | {
711
725
  output: {
712
726
  workerId: string;
713
727
  parentRunId: string;
@@ -809,7 +823,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
809
823
  } & {
810
824
  json: Record<string, never>;
811
825
  };
812
- } | {
826
+ };
827
+ };
828
+ } & {
829
+ "/:workerId/steer": {
830
+ $post: {
813
831
  output: {
814
832
  error: string;
815
833
  code?: "invalid_input" | undefined;
@@ -821,13 +839,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
821
839
  workerId: string;
822
840
  };
823
841
  } & {
824
- json: Record<string, never>;
842
+ json: {
843
+ text: string;
844
+ };
825
845
  };
826
- };
827
- };
828
- } & {
829
- "/:workerId/steer": {
830
- $post: {
846
+ } | {
831
847
  output: {
832
848
  workerId: string;
833
849
  state: "delivered" | "queued";
@@ -843,7 +859,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
843
859
  text: string;
844
860
  };
845
861
  };
846
- } | {
862
+ };
863
+ };
864
+ } & {
865
+ "/:workerId/stop": {
866
+ $post: {
847
867
  output: {
848
868
  error: string;
849
869
  code?: "invalid_input" | undefined;
@@ -855,15 +875,9 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
855
875
  workerId: string;
856
876
  };
857
877
  } & {
858
- json: {
859
- text: string;
860
- };
878
+ json: Record<string, never>;
861
879
  };
862
- };
863
- };
864
- } & {
865
- "/:workerId/stop": {
866
- $post: {
880
+ } | {
867
881
  output: {
868
882
  workerId: string;
869
883
  state: "stopping" | "terminated";
@@ -877,7 +891,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
877
891
  } & {
878
892
  json: Record<string, never>;
879
893
  };
880
- } | {
894
+ };
895
+ };
896
+ } & {
897
+ "/:workerId/destroy": {
898
+ $post: {
881
899
  output: {
882
900
  error: string;
883
901
  code?: "invalid_input" | undefined;
@@ -891,11 +909,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
891
909
  } & {
892
910
  json: Record<string, never>;
893
911
  };
894
- };
895
- };
896
- } & {
897
- "/:workerId/destroy": {
898
- $post: {
912
+ } | {
899
913
  output: {
900
914
  workerId: string;
901
915
  state: "complete" | "incomplete";
@@ -918,20 +932,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
918
932
  } & {
919
933
  json: Record<string, never>;
920
934
  };
921
- } | {
922
- output: {
923
- error: string;
924
- code?: "invalid_input" | undefined;
925
- };
926
- outputFormat: "json";
927
- status: 400;
928
- input: {
929
- param: {
930
- workerId: string;
931
- };
932
- } & {
933
- json: Record<string, never>;
934
- };
935
935
  } | {
936
936
  output: {
937
937
  workerId: string;
@@ -961,13 +961,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
961
961
  "/:workerId/diff": {
962
962
  $get: {
963
963
  output: {
964
- workerId: string;
965
- baselineSha: string;
966
- diff: string;
967
- truncated: boolean;
964
+ error: string;
965
+ code?: "invalid_input" | undefined;
968
966
  };
969
967
  outputFormat: "json";
970
- status: 200;
968
+ status: 400;
971
969
  input: {
972
970
  param: {
973
971
  workerId: string;
@@ -975,11 +973,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
975
973
  };
976
974
  } | {
977
975
  output: {
978
- error: string;
979
- code?: "invalid_input" | undefined;
976
+ workerId: string;
977
+ baselineSha: string;
978
+ diff: string;
979
+ truncated: boolean;
980
980
  };
981
981
  outputFormat: "json";
982
- status: 400;
982
+ status: 200;
983
983
  input: {
984
984
  param: {
985
985
  workerId: string;
@@ -40,7 +40,7 @@ export declare const reportsRoutes: import("hono/hono-base").HonoBase<ProjectApi
40
40
  error: string;
41
41
  };
42
42
  outputFormat: "json";
43
- status: 409;
43
+ status: 400;
44
44
  input: {
45
45
  query: {
46
46
  q?: string | undefined;
@@ -53,7 +53,7 @@ export declare const reportsRoutes: import("hono/hono-base").HonoBase<ProjectApi
53
53
  error: string;
54
54
  };
55
55
  outputFormat: "json";
56
- status: 400;
56
+ status: 409;
57
57
  input: {
58
58
  query: {
59
59
  q?: string | undefined;
@@ -456,7 +456,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
456
456
  remote?: string | undefined;
457
457
  } | null;
458
458
  checks: {
459
- name: 'claude' | 'codex' | 'opencode' | 'pi' | 'cursor' | 'omp' | 'gh' | 'git';
459
+ name: import("../core/agent-runner.ts").RunnerId | 'gh' | 'git';
460
460
  available: boolean;
461
461
  version?: string;
462
462
  hint?: string;
@@ -5289,6 +5289,19 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
5289
5289
  } & {
5290
5290
  "/repo/commit/:sha": {
5291
5291
  $get: {
5292
+ output: string;
5293
+ outputFormat: "text";
5294
+ status: import("hono/utils/http-status").ContentfulStatusCode;
5295
+ input: {
5296
+ query: {
5297
+ structured?: string | undefined;
5298
+ };
5299
+ } & {
5300
+ param: {
5301
+ sha: string;
5302
+ };
5303
+ };
5304
+ } | {
5292
5305
  output: {
5293
5306
  error: string;
5294
5307
  code?: "invalid_input" | undefined;
@@ -5352,19 +5365,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
5352
5365
  sha: string;
5353
5366
  };
5354
5367
  };
5355
- } | {
5356
- output: string;
5357
- outputFormat: "text";
5358
- status: import("hono/utils/http-status").ContentfulStatusCode;
5359
- input: {
5360
- query: {
5361
- structured?: string | undefined;
5362
- };
5363
- } & {
5364
- param: {
5365
- sha: string;
5366
- };
5367
- };
5368
5368
  };
5369
5369
  };
5370
5370
  } & {
@@ -18687,20 +18687,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
18687
18687
  } & {
18688
18688
  "/runs/:id/handoff": {
18689
18689
  $get: {
18690
- output: {
18691
- error: string;
18692
- };
18693
- outputFormat: "json";
18694
- status: 404;
18690
+ output: string;
18691
+ outputFormat: "text";
18692
+ status: 200;
18695
18693
  input: {
18696
18694
  param: {
18697
18695
  id: string;
18698
18696
  };
18699
18697
  };
18700
18698
  } | {
18701
- output: string;
18702
- outputFormat: "text";
18703
- status: 200;
18699
+ output: {
18700
+ error: string;
18701
+ };
18702
+ outputFormat: "json";
18703
+ status: 404;
18704
18704
  input: {
18705
18705
  param: {
18706
18706
  id: string;
@@ -18738,20 +18738,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
18738
18738
  } & {
18739
18739
  "/runs/:id/diff": {
18740
18740
  $get: {
18741
- output: {
18742
- error: string;
18743
- };
18744
- outputFormat: "json";
18745
- status: 404 | 409;
18741
+ output: string;
18742
+ outputFormat: "text";
18743
+ status: import("hono/utils/http-status").ContentfulStatusCode;
18746
18744
  input: {
18747
18745
  param: {
18748
18746
  id: string;
18749
18747
  };
18750
18748
  };
18751
18749
  } | {
18752
- output: string;
18753
- outputFormat: "text";
18754
- status: import("hono/utils/http-status").ContentfulStatusCode;
18750
+ output: {
18751
+ error: string;
18752
+ };
18753
+ outputFormat: "json";
18754
+ status: 404 | 409;
18755
18755
  input: {
18756
18756
  param: {
18757
18757
  id: string;
@@ -21151,6 +21151,19 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
21151
21151
  } & {
21152
21152
  "/repo/commit/:sha": {
21153
21153
  $get: {
21154
+ output: string;
21155
+ outputFormat: "text";
21156
+ status: import("hono/utils/http-status").ContentfulStatusCode;
21157
+ input: {
21158
+ query: {
21159
+ structured?: string | undefined;
21160
+ };
21161
+ } & {
21162
+ param: {
21163
+ sha: string;
21164
+ };
21165
+ };
21166
+ } | {
21154
21167
  output: {
21155
21168
  error: string;
21156
21169
  code?: "invalid_input" | undefined;
@@ -21214,19 +21227,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
21214
21227
  sha: string;
21215
21228
  };
21216
21229
  };
21217
- } | {
21218
- output: string;
21219
- outputFormat: "text";
21220
- status: import("hono/utils/http-status").ContentfulStatusCode;
21221
- input: {
21222
- query: {
21223
- structured?: string | undefined;
21224
- };
21225
- } & {
21226
- param: {
21227
- sha: string;
21228
- };
21229
- };
21230
21230
  };
21231
21231
  };
21232
21232
  } & {
@@ -34549,20 +34549,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
34549
34549
  } & {
34550
34550
  "/runs/:id/handoff": {
34551
34551
  $get: {
34552
- output: {
34553
- error: string;
34554
- };
34555
- outputFormat: "json";
34556
- status: 404;
34552
+ output: string;
34553
+ outputFormat: "text";
34554
+ status: 200;
34557
34555
  input: {
34558
34556
  param: {
34559
34557
  id: string;
34560
34558
  };
34561
34559
  };
34562
34560
  } | {
34563
- output: string;
34564
- outputFormat: "text";
34565
- status: 200;
34561
+ output: {
34562
+ error: string;
34563
+ };
34564
+ outputFormat: "json";
34565
+ status: 404;
34566
34566
  input: {
34567
34567
  param: {
34568
34568
  id: string;
@@ -34600,20 +34600,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
34600
34600
  } & {
34601
34601
  "/runs/:id/diff": {
34602
34602
  $get: {
34603
- output: {
34604
- error: string;
34605
- };
34606
- outputFormat: "json";
34607
- status: 404 | 409;
34603
+ output: string;
34604
+ outputFormat: "text";
34605
+ status: import("hono/utils/http-status").ContentfulStatusCode;
34608
34606
  input: {
34609
34607
  param: {
34610
34608
  id: string;
34611
34609
  };
34612
34610
  };
34613
34611
  } | {
34614
- output: string;
34615
- outputFormat: "text";
34616
- status: import("hono/utils/http-status").ContentfulStatusCode;
34612
+ output: {
34613
+ error: string;
34614
+ };
34615
+ outputFormat: "json";
34616
+ status: 404 | 409;
34617
34617
  input: {
34618
34618
  param: {
34619
34619
  id: string;
@@ -18,6 +18,25 @@ export interface VoiceRouteDeps {
18
18
  export declare function createVoiceRoutes(deps: VoiceRouteDeps): import("hono/hono-base").HonoBase<ProjectApiEnv, {
19
19
  "/voice/decide": {
20
20
  $post: {
21
+ output: {
22
+ error: string;
23
+ };
24
+ outputFormat: "json";
25
+ status: 503;
26
+ input: {
27
+ json: {
28
+ text: string;
29
+ sidebarView: "active" | "automations";
30
+ openRunId?: string | undefined;
31
+ view?: "automations" | "git" | "github" | "inbox" | "new-task" | "other" | "settings" | "task" | undefined;
32
+ askRequestId?: string | null | undefined;
33
+ proposal?: {
34
+ decisionId: string;
35
+ action: "answer" | "tell";
36
+ } | undefined;
37
+ };
38
+ };
39
+ } | {
21
40
  output: {
22
41
  action: "open";
23
42
  decisionId: string;
@@ -75,25 +94,6 @@ export declare function createVoiceRoutes(deps: VoiceRouteDeps): import("hono/ho
75
94
  } | undefined;
76
95
  };
77
96
  };
78
- } | {
79
- output: {
80
- error: string;
81
- };
82
- outputFormat: "json";
83
- status: 503;
84
- input: {
85
- json: {
86
- text: string;
87
- sidebarView: "active" | "automations";
88
- openRunId?: string | undefined;
89
- view?: "automations" | "git" | "github" | "inbox" | "new-task" | "other" | "settings" | "task" | undefined;
90
- askRequestId?: string | null | undefined;
91
- proposal?: {
92
- decisionId: string;
93
- action: "answer" | "tell";
94
- } | undefined;
95
- };
96
- };
97
97
  };
98
98
  };
99
99
  } & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wjarka/cezarion",
3
- "version": "0.17.0-dev.5648",
3
+ "version": "0.17.0-dev.5666",
4
4
  "description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -60,8 +60,8 @@
60
60
  "devDependencies": {
61
61
  "@babel/parser": "^8.0.8",
62
62
  "@babel/types": "^8.0.8",
63
- "@open-mercato/cezar-api-client": "0.17.0-dev.5648",
64
- "@open-mercato/cezar-contract": "0.17.0-dev.5648",
63
+ "@open-mercato/cezar-api-client": "0.17.0-dev.5666",
64
+ "@open-mercato/cezar-contract": "0.17.0-dev.5666",
65
65
  "@types/node": "^24.19.1",
66
66
  "@types/ws": "^8.18.1",
67
67
  "esbuild": "^0.28.1",
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Prints the parity row index: every row the parity kits declare, and the runners exempt from it.
3
+ *
4
+ * node packages/cezar/scripts/parity-rows.ts [--row <id>] [--runner <id>] [--json]
5
+ *
6
+ * `--row` prints one row id; `--runner` prints the rows that runner is exempt from.
7
+ *
8
+ * The index is read from the lists the kits export. This file names the kit modules and holds no
9
+ * row and no exemption. `src/core/parity-rows.test.ts` fails when a kit declares a row id that is
10
+ * missing here.
11
+ */
12
+ import { parseArgs } from 'node:util';
13
+
14
+ import { RUNNER_IDS } from '../src/core/agent-runner.ts';
15
+ import * as harnessCore from '../src/core/harness-parity-core.testkit.ts';
16
+ import * as harnessRows from '../src/core/harness-parity-rows.testkit.ts';
17
+ import { PARITY_ROW_ID } from '../src/core/parity-classes.testkit.ts';
18
+ import * as seamContract from '../src/core/seam-contract.testkit.ts';
19
+ import * as monitoringTurn from '../src/workflows/monitoring-turn.testkit.ts';
20
+ import * as waits from '../src/workflows/waits-parity.testkit.ts';
21
+ import * as subagents from '../src/workflows/waits-subagents-rows.testkit.ts';
22
+
23
+ /** The kit modules that declare rows, by path under `packages/cezar/src`. */
24
+ const KITS: Readonly<Record<string, object>> = {
25
+ 'core/harness-parity-core.testkit.ts': harnessCore,
26
+ 'core/harness-parity-rows.testkit.ts': harnessRows,
27
+ 'core/seam-contract.testkit.ts': seamContract,
28
+ 'workflows/monitoring-turn.testkit.ts': monitoringTurn,
29
+ 'workflows/waits-parity.testkit.ts': waits,
30
+ 'workflows/waits-subagents-rows.testkit.ts': subagents,
31
+ };
32
+
33
+ export interface IndexedExemption {
34
+ readonly runner: string;
35
+ /** Absent where the kit's exemption list declares no kind. */
36
+ readonly kind?: string;
37
+ readonly reason: string;
38
+ }
39
+
40
+ /** One row id of one kit. Two kits that declare the same id give two rows. */
41
+ export interface IndexedRow {
42
+ readonly id: string;
43
+ readonly kit: string;
44
+ /** The exported lists that declare it. */
45
+ readonly lists: readonly string[];
46
+ /** More than one where a list declares the id once for each variant. */
47
+ readonly names: readonly string[];
48
+ readonly scenarios: readonly string[];
49
+ /** Exemption lists name a row by id only, so two kits' rows with one id show the same ones. */
50
+ readonly exemptions: readonly IndexedExemption[];
51
+ }
52
+
53
+ type Entry = Readonly<Record<string, unknown>>;
54
+ const isEntry = (value: unknown): value is Entry => typeof value === 'object' && value !== null;
55
+ const text = (value: unknown): string | undefined => typeof value === 'string' ? value : undefined;
56
+
57
+ /** Every exported list of a kit whose entries all pass `match`. */
58
+ function exportedLists(kit: object, match: (entry: Entry) => boolean): [string, readonly Entry[]][] {
59
+ return Object.entries(kit).filter((pair): pair is [string, Entry[]] => {
60
+ const list: unknown = pair[1];
61
+ return Array.isArray(list) && list.length > 0 && list.every(entry => isEntry(entry) && match(entry));
62
+ });
63
+ }
64
+
65
+ const isRow = (entry: Entry) => PARITY_ROW_ID.test(text(entry.id) ?? '');
66
+ const isExemption = (entry: Entry) => text(entry.criterion) !== undefined && text(entry.reason) !== undefined
67
+ && text(entry.backend ?? entry.runner) !== undefined;
68
+
69
+ export function parityRowIndex(): IndexedRow[] {
70
+ const exemptions = new Map<string, IndexedExemption[]>();
71
+ for (const kit of Object.values(KITS)) {
72
+ for (const [, list] of exportedLists(kit, isExemption)) {
73
+ for (const entry of list) {
74
+ const kind = text(entry.kind);
75
+ const exemption = { runner: text(entry.backend ?? entry.runner)!, ...(kind === undefined ? {} : { kind }), reason: text(entry.reason)! };
76
+ exemptions.set(text(entry.criterion)!, [...(exemptions.get(text(entry.criterion)!) ?? []), exemption]);
77
+ }
78
+ }
79
+ }
80
+ const rows = new Map<string, { id: string; kit: string; lists: Set<string>; names: Set<string>; scenarios: Set<string> }>();
81
+ for (const [kit, module] of Object.entries(KITS)) {
82
+ for (const [list, entries] of exportedLists(module, isRow)) {
83
+ for (const entry of entries) {
84
+ const id = text(entry.id)!;
85
+ const row = rows.get(`${kit} ${id}`) ?? { id, kit, lists: new Set(), names: new Set(), scenarios: new Set() };
86
+ rows.set(`${kit} ${id}`, row);
87
+ row.lists.add(list);
88
+ if (text(entry.name) !== undefined) row.names.add(text(entry.name)!);
89
+ if (text(entry.scenario) !== undefined) row.scenarios.add(text(entry.scenario)!);
90
+ }
91
+ }
92
+ }
93
+ return [...rows.values()].map(row => ({
94
+ id: row.id, kit: row.kit, lists: [...row.lists], names: [...row.names], scenarios: [...row.scenarios],
95
+ exemptions: exemptions.get(row.id) ?? [],
96
+ }));
97
+ }
98
+
99
+ /** The exemption ids that name no indexed row. */
100
+ export function unmatchedExemptions(index: readonly IndexedRow[]): string[] {
101
+ const ids = new Set(index.map(row => row.id));
102
+ return Object.values(KITS).flatMap(kit => exportedLists(kit, isExemption))
103
+ .flatMap(([, list]) => list.map(entry => text(entry.criterion)!)).filter(id => !ids.has(id));
104
+ }
105
+
106
+ /** The lines that print one row. */
107
+ export function formatRow(row: IndexedRow): string[] {
108
+ // Some kits start a name with the row id; the id is already the first column.
109
+ const names = row.names.map(name => name.startsWith(`${row.id} `) ? name.slice(row.id.length + 1) : name);
110
+ return [
111
+ `${row.id} ${names[0] ?? '(no name: its cells carry it in their titles)'}`,
112
+ ...names.slice(1).map(name => ` also: ${name}`),
113
+ ` scenario: ${row.scenarios.join(', ') || '(none declared)'}`,
114
+ ` kit: ${row.kit} (${row.lists.join(', ')})`,
115
+ ...row.exemptions.map(({ runner, kind, reason }) => ` exempt: ${runner}${kind === undefined ? '' : ` (${kind})`}: ${reason}`),
116
+ ];
117
+ }
118
+
119
+ const count = (n: number, word: string) => `${n} ${word}${n === 1 ? '' : 's'}`;
120
+
121
+ export interface RowQuery { readonly row?: string; readonly runner?: string; readonly json?: boolean }
122
+
123
+ /** What the command prints for a query: `out` on stdout, `error` on stderr with exit code 1. */
124
+ export function renderRows(index: readonly IndexedRow[], query: RowQuery): { out: string[]; error?: string } {
125
+ if (query.runner !== undefined && !(RUNNER_IDS as readonly string[]).includes(query.runner)) {
126
+ return { out: [], error: `unknown runner "${query.runner}"; the runners are ${RUNNER_IDS.join(', ')}` };
127
+ }
128
+ const named = index.filter(row => query.row === undefined || row.id === query.row);
129
+ const rows = named
130
+ .map(row => query.runner === undefined ? row : { ...row, exemptions: row.exemptions.filter(exemption => exemption.runner === query.runner) })
131
+ .filter(row => query.runner === undefined || row.exemptions.length > 0);
132
+ const out = query.json
133
+ ? [JSON.stringify(rows, null, 2)]
134
+ : [...rows.flatMap(formatRow), `${count(rows.length, 'row')} in ${count(new Set(rows.map(row => row.kit)).size, 'kit')}`];
135
+ return named.length === 0 && query.row !== undefined ? { out, error: `no kit declares row "${query.row}"` } : { out };
136
+ }
137
+
138
+ const USAGE = 'usage: node packages/cezar/scripts/parity-rows.ts [--row <id>] [--runner <id>] [--json]';
139
+
140
+ /** What the command prints for its arguments. A flag `parseArgs` refuses is an error with the usage line. */
141
+ export function runParityRows(args: readonly string[]): { out: string[]; error?: string } {
142
+ let query: RowQuery;
143
+ try {
144
+ query = parseArgs({ args: [...args], options: { row: { type: 'string' }, runner: { type: 'string' }, json: { type: 'boolean' } } }).values;
145
+ } catch (error) {
146
+ return { out: [], error: `${(error as Error).message}\n${USAGE}` };
147
+ }
148
+ return renderRows(parityRowIndex(), query);
149
+ }
150
+
151
+ function main(): void {
152
+ const { out, error } = runParityRows(process.argv.slice(2));
153
+ for (const line of out) console.log(line);
154
+ if (error !== undefined) {
155
+ console.error(error);
156
+ process.exitCode = 1;
157
+ }
158
+ }
159
+
160
+ if (import.meta.main) main();