harnery 0.16.0 → 0.17.0

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 (40) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/supervisor.d.ts.map +1 -1
  3. package/dist/commands/supervisor.js +184 -3
  4. package/dist/core/supervisor/index.d.ts +3 -0
  5. package/dist/core/supervisor/index.d.ts.map +1 -1
  6. package/dist/core/supervisor/index.js +3 -0
  7. package/dist/core/supervisor/plan-api.d.ts +16 -0
  8. package/dist/core/supervisor/plan-api.d.ts.map +1 -0
  9. package/dist/core/supervisor/plan-api.js +34 -0
  10. package/dist/core/supervisor/plan-read.d.ts +4 -0
  11. package/dist/core/supervisor/plan-read.d.ts.map +1 -0
  12. package/dist/core/supervisor/plan-read.js +269 -0
  13. package/dist/core/supervisor/plan-types.d.ts +113 -0
  14. package/dist/core/supervisor/plan-types.d.ts.map +1 -0
  15. package/dist/core/supervisor/plan-types.js +14 -0
  16. package/dist/core/supervisor/planning.d.ts +26 -0
  17. package/dist/core/supervisor/planning.d.ts.map +1 -0
  18. package/dist/core/supervisor/planning.js +486 -0
  19. package/dist/core/supervisor/read.d.ts +2 -0
  20. package/dist/core/supervisor/read.d.ts.map +1 -1
  21. package/dist/core/supervisor/read.js +2 -0
  22. package/dist/core/supervisor/runner.d.ts +3 -0
  23. package/dist/core/supervisor/runner.d.ts.map +1 -1
  24. package/dist/core/supervisor/runner.js +37 -7
  25. package/dist/core/supervisor/service.d.ts.map +1 -1
  26. package/dist/core/supervisor/service.js +7 -0
  27. package/dist/core/supervisor/state.d.ts +11 -1
  28. package/dist/core/supervisor/state.d.ts.map +1 -1
  29. package/dist/core/supervisor/state.js +186 -7
  30. package/package.json +1 -1
  31. package/src/commands/supervisor.ts +229 -2
  32. package/src/core/supervisor/index.ts +18 -0
  33. package/src/core/supervisor/plan-api.ts +47 -0
  34. package/src/core/supervisor/plan-read.ts +299 -0
  35. package/src/core/supervisor/plan-types.ts +144 -0
  36. package/src/core/supervisor/planning.ts +576 -0
  37. package/src/core/supervisor/read.ts +15 -0
  38. package/src/core/supervisor/runner.ts +39 -2
  39. package/src/core/supervisor/service.ts +7 -0
  40. package/src/core/supervisor/state.ts +235 -6
@@ -0,0 +1,144 @@
1
+ export const SUPERVISOR_PLAN_SCHEMA_VERSION = 1 as const;
2
+
3
+ export interface SupervisorPlanTemplate {
4
+ workflow: { path: string; sha256: string };
5
+ max_attempts: number;
6
+ root: boolean;
7
+ }
8
+
9
+ export interface SupervisorReplanningPolicy {
10
+ planner_specialist: string;
11
+ auto_apply: boolean;
12
+ max_replans: number;
13
+ max_work_items_per_plan: number;
14
+ max_total_work_items: number;
15
+ templates: Record<string, SupervisorPlanTemplate>;
16
+ }
17
+
18
+ export interface CreateSupervisorPlanTemplateInput {
19
+ workflowPath: string;
20
+ maxAttempts?: number;
21
+ root?: boolean;
22
+ }
23
+
24
+ export interface CreateSupervisorReplanningInput {
25
+ plannerSpecialist: string;
26
+ autoApply?: boolean;
27
+ maxReplans?: number;
28
+ maxWorkItemsPerPlan?: number;
29
+ maxTotalWorkItems?: number;
30
+ templates: Readonly<Record<string, CreateSupervisorPlanTemplateInput>>;
31
+ }
32
+
33
+ export interface SupervisorPlanRequest {
34
+ schema_version: typeof SUPERVISOR_PLAN_SCHEMA_VERSION;
35
+ id: string;
36
+ goal_id: string;
37
+ sequence: number;
38
+ trigger_fingerprint: string;
39
+ prior_root_work_id: string;
40
+ workflow_run_id: string;
41
+ created_at: string;
42
+ }
43
+
44
+ export interface SupervisorPlanWorkSpec {
45
+ key: string;
46
+ title: string;
47
+ objective: string;
48
+ acceptance: string[];
49
+ dependencies: string[];
50
+ template: string;
51
+ }
52
+
53
+ export interface SupervisorPlanProposal {
54
+ schema_version: typeof SUPERVISOR_PLAN_SCHEMA_VERSION;
55
+ plan_id: string;
56
+ decision: "apply" | "attention";
57
+ rationale: string;
58
+ root: string;
59
+ work: SupervisorPlanWorkSpec[];
60
+ proposed_at: string;
61
+ }
62
+
63
+ export type SupervisorPlanEventType =
64
+ | "plan.awaiting_approval"
65
+ | "plan.resumed"
66
+ | "plan.proposed"
67
+ | "plan.applied"
68
+ | "plan.rejected"
69
+ | "plan.attention"
70
+ | "plan.failed";
71
+
72
+ export interface SupervisorPlanEvent {
73
+ schema_version: typeof SUPERVISOR_PLAN_SCHEMA_VERSION;
74
+ plan_id: string;
75
+ seq: number;
76
+ ts: string;
77
+ event: SupervisorPlanEventType;
78
+ actor: string;
79
+ reason: string;
80
+ approval_id?: string;
81
+ root_work_id?: string;
82
+ work_ids?: string[];
83
+ }
84
+
85
+ export type SupervisorPlanStatus =
86
+ | "interrupted"
87
+ | "awaiting_approval"
88
+ | "resumable"
89
+ | "proposed"
90
+ | "applied"
91
+ | "rejected"
92
+ | "attention"
93
+ | "failed";
94
+
95
+ export interface SupervisorPlanRecord {
96
+ request: SupervisorPlanRequest;
97
+ proposal?: SupervisorPlanProposal;
98
+ events: SupervisorPlanEvent[];
99
+ status: SupervisorPlanStatus;
100
+ approval_id?: string;
101
+ root_work_id?: string;
102
+ work_ids: string[];
103
+ reason?: string;
104
+ }
105
+
106
+ export interface SupervisorPlanHistory {
107
+ plans: SupervisorPlanRecord[];
108
+ active_root_work_id: string;
109
+ generation: number;
110
+ applied_work_ids: string[];
111
+ materialized_work_ids: string[];
112
+ latest?: SupervisorPlanRecord;
113
+ }
114
+
115
+ export interface SupervisorPlanOutcome {
116
+ plan_id: string;
117
+ status: SupervisorPlanStatus;
118
+ workflow_run_id: string;
119
+ reason?: string;
120
+ root_work_id?: string;
121
+ work_ids: string[];
122
+ }
123
+
124
+ export function supervisorGraphFingerprint(input: {
125
+ rootWorkId: string;
126
+ generation: number;
127
+ work: ReadonlyArray<{
128
+ intent: { id: string };
129
+ projection: { state: string; next_action: string; attempts_used: number };
130
+ events: readonly unknown[];
131
+ }>;
132
+ }): string {
133
+ return JSON.stringify([
134
+ input.rootWorkId,
135
+ input.generation,
136
+ input.work.map((work) => [
137
+ work.intent.id,
138
+ work.projection.state,
139
+ work.projection.next_action,
140
+ work.projection.attempts_used,
141
+ work.events.length,
142
+ ]),
143
+ ]);
144
+ }