@wjarka/cezarion 0.17.0-dev.5661 → 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.
@@ -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;
@@ -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.5661",
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.5661",
64
- "@open-mercato/cezar-contract": "0.17.0-dev.5661",
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();