@fractaal/pi-goal-x 0.20.0 → 0.28.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 (95) hide show
  1. package/README.md +38 -293
  2. package/dist/goal-auditor.d.ts +7 -61
  3. package/dist/goal-auditor.js +98 -300
  4. package/dist/goal-auditor.js.map +1 -1
  5. package/dist/goal-contract.d.ts +205 -0
  6. package/dist/goal-contract.js +135 -0
  7. package/dist/goal-contract.js.map +1 -0
  8. package/dist/goal-transcript-events.d.ts +54 -0
  9. package/dist/goal-transcript-events.js +177 -0
  10. package/dist/goal-transcript-events.js.map +1 -0
  11. package/dist/goal-widget.d.ts +13 -0
  12. package/dist/goal-widget.js +45 -0
  13. package/dist/goal-widget.js.map +1 -0
  14. package/dist/goal.d.ts +8 -49
  15. package/dist/goal.js +582 -3644
  16. package/dist/goal.js.map +1 -1
  17. package/dist/legacy-migration.d.ts +61 -0
  18. package/dist/legacy-migration.js +306 -0
  19. package/dist/legacy-migration.js.map +1 -0
  20. package/docs/architecture.md +14 -232
  21. package/extensions/goal-auditor.ts +108 -363
  22. package/extensions/goal-contract.ts +149 -0
  23. package/extensions/goal-transcript-events.ts +194 -0
  24. package/extensions/goal-widget.ts +50 -0
  25. package/extensions/goal.ts +602 -3916
  26. package/extensions/legacy-migration.ts +340 -0
  27. package/package.json +46 -21
  28. package/dist/goal-compaction.d.ts +0 -10
  29. package/dist/goal-compaction.js +0 -104
  30. package/dist/goal-compaction.js.map +0 -1
  31. package/dist/goal-core.d.ts +0 -19
  32. package/dist/goal-core.js +0 -66
  33. package/dist/goal-core.js.map +0 -1
  34. package/dist/goal-draft.d.ts +0 -71
  35. package/dist/goal-draft.js +0 -201
  36. package/dist/goal-draft.js.map +0 -1
  37. package/dist/goal-ledger.d.ts +0 -139
  38. package/dist/goal-ledger.js +0 -306
  39. package/dist/goal-ledger.js.map +0 -1
  40. package/dist/goal-policy.d.ts +0 -127
  41. package/dist/goal-policy.js +0 -359
  42. package/dist/goal-policy.js.map +0 -1
  43. package/dist/goal-pool.d.ts +0 -17
  44. package/dist/goal-pool.js +0 -85
  45. package/dist/goal-pool.js.map +0 -1
  46. package/dist/goal-questionnaire.d.ts +0 -56
  47. package/dist/goal-questionnaire.js +0 -733
  48. package/dist/goal-questionnaire.js.map +0 -1
  49. package/dist/goal-record.d.ts +0 -94
  50. package/dist/goal-record.js +0 -155
  51. package/dist/goal-record.js.map +0 -1
  52. package/dist/goal-settings.d.ts +0 -56
  53. package/dist/goal-settings.js +0 -184
  54. package/dist/goal-settings.js.map +0 -1
  55. package/dist/goal-tool-names.d.ts +0 -20
  56. package/dist/goal-tool-names.js +0 -69
  57. package/dist/goal-tool-names.js.map +0 -1
  58. package/dist/prompts/goal-prompts.d.ts +0 -17
  59. package/dist/prompts/goal-prompts.js +0 -304
  60. package/dist/prompts/goal-prompts.js.map +0 -1
  61. package/dist/storage/goal-files.d.ts +0 -40
  62. package/dist/storage/goal-files.js +0 -320
  63. package/dist/storage/goal-files.js.map +0 -1
  64. package/dist/widgets/goal-escape-dialog.d.ts +0 -15
  65. package/dist/widgets/goal-escape-dialog.js +0 -118
  66. package/dist/widgets/goal-escape-dialog.js.map +0 -1
  67. package/dist/widgets/goal-notifications.d.ts +0 -5
  68. package/dist/widgets/goal-notifications.js +0 -9
  69. package/dist/widgets/goal-notifications.js.map +0 -1
  70. package/dist/widgets/goal-widget.d.ts +0 -58
  71. package/dist/widgets/goal-widget.js +0 -282
  72. package/dist/widgets/goal-widget.js.map +0 -1
  73. package/dist/widgets/task-list-overlay.d.ts +0 -8
  74. package/dist/widgets/task-list-overlay.js +0 -321
  75. package/dist/widgets/task-list-overlay.js.map +0 -1
  76. package/docs/agent-flow-design.md +0 -432
  77. package/docs/agentic-runtime-prd.md +0 -764
  78. package/docs/goal-ts-refactor-test-strategy.md +0 -82
  79. package/docs/pi-autoresearch-survey.md +0 -45
  80. package/extensions/goal-compaction.ts +0 -133
  81. package/extensions/goal-core.ts +0 -77
  82. package/extensions/goal-draft.ts +0 -263
  83. package/extensions/goal-ledger.ts +0 -354
  84. package/extensions/goal-policy.ts +0 -389
  85. package/extensions/goal-pool.ts +0 -98
  86. package/extensions/goal-questionnaire.ts +0 -779
  87. package/extensions/goal-record.ts +0 -256
  88. package/extensions/goal-settings.ts +0 -181
  89. package/extensions/goal-tool-names.ts +0 -76
  90. package/extensions/prompts/goal-prompts.ts +0 -308
  91. package/extensions/storage/goal-files.ts +0 -352
  92. package/extensions/widgets/goal-escape-dialog.ts +0 -146
  93. package/extensions/widgets/goal-notifications.ts +0 -9
  94. package/extensions/widgets/goal-widget.ts +0 -378
  95. package/extensions/widgets/task-list-overlay.ts +0 -389
@@ -1,71 +0,0 @@
1
- import type { GoalTask } from "./goal-record.ts";
2
- export type GoalDraftingFocus = "goal" | "sisyphus";
3
- export interface GoalConfirmationIntentLike {
4
- focus: GoalDraftingFocus;
5
- originalTopic: string;
6
- startedAt?: number;
7
- }
8
- export interface DraftProposalInput {
9
- intent: GoalConfirmationIntentLike | null;
10
- hasUnfinishedGoal: boolean;
11
- objective: string;
12
- sisyphus?: boolean;
13
- draftId?: string;
14
- }
15
- export type DraftProposalValidation = {
16
- ok: true;
17
- objective: string;
18
- expectedSisyphus: boolean;
19
- } | {
20
- ok: false;
21
- message: string;
22
- clearDrafting?: boolean;
23
- };
24
- export type ToolGateDecision = {
25
- block: false;
26
- } | {
27
- block: true;
28
- reason: string;
29
- };
30
- export declare function renderConfirmationTasks(tasks: GoalTask[], indent: number): string[];
31
- export declare function promptSafeObjective(objective: string): string;
32
- /**
33
- * Extract a `Verification contract:` section from a goal objective and return
34
- * the cleaned objective (without the contract section) and the contract text.
35
- *
36
- * The contract section is a single line matching:
37
- * Verification contract: <text>
38
- *
39
- * It can appear anywhere in the objective, but by convention it goes after
40
- * the other sections (like Success criteria, Boundaries, Constraints).
41
- *
42
- * If no contract section is found, `verificationContract` is undefined.
43
- */
44
- export declare function extractVerificationContract(objective: string): {
45
- objective: string;
46
- verificationContract?: string;
47
- };
48
- export declare function buildDraftConfirmationText(args: {
49
- focus: GoalDraftingFocus;
50
- originalTopic: string;
51
- objective: string;
52
- autoContinue: boolean;
53
- }): string;
54
- export declare function buildTweakConfirmationText(args: {
55
- currentObjective: string;
56
- newObjective: string;
57
- changeSummary: string;
58
- sisyphus: boolean;
59
- tasks?: GoalTask[];
60
- }): string;
61
- export declare function evaluateDraftingToolGate(args: {
62
- toolName: string;
63
- draftingFocus?: GoalDraftingFocus | null;
64
- tweakDraftingGoalId?: string | null;
65
- activeGoalId?: string | null;
66
- proposeToolName?: string;
67
- tweakApplyToolName?: string;
68
- getGoalToolName?: string;
69
- }): ToolGateDecision;
70
- export declare function validateGoalDraftProposal(input: DraftProposalInput): DraftProposalValidation;
71
- export declare function goalDraftingPrompt(topic: string, focus: GoalDraftingFocus): string;
@@ -1,201 +0,0 @@
1
- // ── Shared formatting helpers ──────────────────────────────────────────────
2
- function formatModeLabel(sisyphus) {
3
- return sisyphus ? "Sisyphus (prompt/criteria style)" : "Normal goal";
4
- }
5
- function formatPrefixedLines(content) {
6
- const lines = [];
7
- for (const rawLine of content.split("\n")) {
8
- const trimmed = rawLine.trim();
9
- if (!trimmed)
10
- continue;
11
- if (trimmed.startsWith("│")) {
12
- lines.push(rawLine);
13
- }
14
- else {
15
- lines.push(`│ ${rawLine}`);
16
- }
17
- }
18
- return lines;
19
- }
20
- function formatSection(title, content) {
21
- const body = formatPrefixedLines(content);
22
- return ["", `─── ${title} ───`, "", ...body];
23
- }
24
- export function renderConfirmationTasks(tasks, indent) {
25
- const prefix = " ".repeat(indent);
26
- const lines = [];
27
- for (const t of tasks) {
28
- const lw = t.lightweightSubtasks ? " (lightweight)" : "";
29
- const contract = t.verificationContract ? ` contract: ${t.verificationContract}` : "";
30
- lines.push(`${prefix}[ ] ${t.id}: ${t.title}${lw}${contract}`);
31
- if (t.subtasks && t.subtasks.length > 0) {
32
- lines.push(...renderConfirmationTasks(t.subtasks, indent + 1));
33
- }
34
- }
35
- return lines;
36
- }
37
- export function promptSafeObjective(objective) {
38
- return objective.replace(/<\/?untrusted_objective>/gi, (tag) => tag.replace(/</g, "&lt;").replace(/>/g, "&gt;"));
39
- }
40
- const VERIFICATION_CONTRACT_RE = /^Verification contract:\s*(.+)$/im;
41
- const CONVENTIONAL_SECTION_NAMES = [
42
- "success criteria",
43
- "boundaries",
44
- "constraints",
45
- "if blocked",
46
- "if blocked / unclear / failing",
47
- "don'ts",
48
- "sisyphus reminder",
49
- "objective",
50
- "目标",
51
- "ordered steps",
52
- "order rules",
53
- "steps",
54
- ];
55
- /**
56
- * Extract a `Verification contract:` section from a goal objective and return
57
- * the cleaned objective (without the contract section) and the contract text.
58
- *
59
- * The contract section is a single line matching:
60
- * Verification contract: <text>
61
- *
62
- * It can appear anywhere in the objective, but by convention it goes after
63
- * the other sections (like Success criteria, Boundaries, Constraints).
64
- *
65
- * If no contract section is found, `verificationContract` is undefined.
66
- */
67
- export function extractVerificationContract(objective) {
68
- const lines = objective.replace(/\r/g, "").split("\n");
69
- let contract;
70
- const filtered = [];
71
- for (const line of lines) {
72
- const trimmed = line.trim();
73
- const m = VERIFICATION_CONTRACT_RE.exec(trimmed);
74
- if (m) {
75
- contract = m[1].trim();
76
- // Skip this line — don't add it to the cleaned objective
77
- }
78
- else {
79
- filtered.push(line);
80
- }
81
- }
82
- return {
83
- objective: filtered.join("\n"),
84
- verificationContract: contract || undefined,
85
- };
86
- }
87
- export function buildDraftConfirmationText(args) {
88
- const lines = [];
89
- lines.push("● Goal draft ready for confirmation.");
90
- lines.push("");
91
- lines.push("─── Draft Details ───");
92
- lines.push(`│ Mode: ${formatModeLabel(args.focus === "sisyphus")}`);
93
- lines.push(`│ Auto-continue: ${args.autoContinue ? "yes" : "no"}`);
94
- lines.push(...formatSection("Original Topic", args.originalTopic.trim()));
95
- lines.push(...formatSection("Proposed Goal", args.objective));
96
- return lines.join("\n");
97
- }
98
- export function buildTweakConfirmationText(args) {
99
- const lines = [];
100
- lines.push("● Goal tweak ready for confirmation.");
101
- lines.push("");
102
- lines.push("─── Draft Details ───");
103
- lines.push(`│ Mode: ${formatModeLabel(args.sisyphus)}`);
104
- lines.push(...formatSection("Change", args.changeSummary));
105
- lines.push(...formatSection("Current Objective", args.currentObjective));
106
- lines.push(...formatSection("Proposed New Objective", args.newObjective));
107
- if (args.tasks && args.tasks.length > 0) {
108
- const taskLines = renderConfirmationTasks(args.tasks, 0);
109
- lines.push("");
110
- lines.push(`┌─ TASKS ─────────────────────────────────────┐`);
111
- for (const tl of taskLines)
112
- lines.push(tl);
113
- lines.push(`└──────────────────────────────────────────────┘`);
114
- }
115
- return lines.join("\n");
116
- }
117
- export function evaluateDraftingToolGate(args) {
118
- // Goal confirmation is prompt-guided, not runtime-enforced. The agent should
119
- // avoid substantive work before confirmation, but minimal reconnaissance is allowed.
120
- void args;
121
- return { block: false };
122
- }
123
- export function validateGoalDraftProposal(input) {
124
- if (input.intent === null) {
125
- return {
126
- ok: false,
127
- message: "propose_goal_draft REJECTED: no /goals or /sisyphus intent discussion is in progress. Tell the user to invoke /goals <topic> or /sisyphus <topic> first, or use /goals-set / /sisyphus-set for immediate creation.",
128
- };
129
- }
130
- const expectedSisyphus = input.intent.focus === "sisyphus";
131
- const actualSisyphus = input.sisyphus === true;
132
- if (actualSisyphus !== expectedSisyphus) {
133
- return {
134
- ok: false,
135
- message: `propose_goal_draft REJECTED (focus gate): confirmation focus is "${input.intent.focus}" (user invoked ${input.intent.focus === "sisyphus" ? "/sisyphus" : "/goals"}) but you passed sisyphus=${actualSisyphus}. Set sisyphus=${expectedSisyphus} to match the user's choice, then retry. Do NOT change the user's mode autonomously.`,
136
- };
137
- }
138
- const objective = input.objective.trim();
139
- if (!objective) {
140
- return { ok: false, message: "propose_goal_draft REJECTED: objective is empty." };
141
- }
142
- return { ok: true, objective, expectedSisyphus };
143
- }
144
- export function goalDraftingPrompt(topic, focus) {
145
- const safeTopic = promptSafeObjective(topic.trim() || "(no topic provided — ask the user what they want to accomplish)");
146
- const header = focus === "sisyphus"
147
- ? "[GOAL CONFIRMATION focus=sisyphus]\nThe user invoked Sisyphus intent discussion (/sisyphus). Help turn their request into a confirmed goal contract. Do NOT start substantive work yet."
148
- : "[GOAL CONFIRMATION focus=goal]\nThe user invoked goal intent discussion (/goals). Help turn their request into a confirmed goal contract. Do NOT start substantive work yet.";
149
- const commonProtocol = [
150
- "Confirmation protocol:",
151
- "- Treat this as a lightweight conversation with the user, not a separate long-running runtime phase.",
152
- "- If the topic is vague, ask one focused question with a recommended default. Use goal_question or goal_questionnaire when a structured answer would help, but plain conversation is acceptable.",
153
- "- Targeted read-only research is allowed when it helps define a better goal contract; do not start implementation before confirmation.",
154
- "- If the topic is already concrete, you may proceed directly to propose_goal_draft.",
155
- "- The goal contract should make the objective, success criteria, boundaries, constraints, and blocker rule explicit.",
156
- "- Keep grilling assumptions until the objective, success criteria, boundaries, constraints, and blocker rule are clear enough to confirm.",
157
- "- If the objective naturally decomposes into trackable milestones, you MUST include the task list in the `tasks` parameter of `propose_goal_draft` so the user can accept both goal and tasks in a single confirmation dialog. Do NOT propose the goal without tasks and then call `propose_task_list` separately.",
158
- "- For simple single-step goals, no task list is required. The `tasks` parameter can be omitted.",
159
- "- After goal creation, `propose_task_list` is still available for user-requested task additions or structural changes.",
160
- "- propose_goal_draft opens the user's Confirm / Continue Chatting dialog. Confirm creates and focuses the goal; Continue Chatting means keep refining through normal proposal cycles.",
161
- "- create_goal is not a shortcut. Direct create_goal calls are rejected so the user keeps explicit say in goal creation.",
162
- ];
163
- const goalFocusItems = [
164
- "For /goals, propose a normal goal in this shape when ready:",
165
- "=== Goal ===",
166
- "Objective: <one-sentence outcome>",
167
- "Success criteria: <observable evidence the goal is done>",
168
- "Boundaries: <in scope / out of scope>",
169
- "Constraints: <hard rules>",
170
- "Verification contract: <optional — what verification evidence is required before marking complete, e.g. 'Run npm test (0 failures), grep for remaining references, re-read requirements and confirm every item is addressed'>",
171
- "If blocked: <default = stop and ask the user>",
172
- "Call propose_goal_draft with sisyphus=false and autoContinue=true unless the user asked otherwise.",
173
- ];
174
- const sisyphusFocusItems = [
175
- "For /sisyphus, remember that Sisyphus is a prompt/criteria style, not a separate step-counter mechanism.",
176
- "Propose a Sisyphus goal in this shape when ready:",
177
- "=== Sisyphus Goal ===",
178
- "Objective: <one-sentence outcome>",
179
- "Success criteria: <observable evidence the whole ordered goal is done>",
180
- "Boundaries: <in scope / out of scope>",
181
- "Constraints: <hard rules, files not to touch, etc.>",
182
- "Verification contract: <optional — what verification evidence is required before marking complete>",
183
- "Ordered steps: <preserve the user's requested steps and ordering; do not add preflight or reconnaissance steps they did not ask for>",
184
- "If blocked / unclear / failing: <default = stop and ask the user>",
185
- "Sisyphus reminder: Work patiently and sequentially. No rushing, no unrequested preflight steps, no improvising around blockers.",
186
- "Call propose_goal_draft with sisyphus=true and autoContinue=true unless the user asked otherwise.",
187
- ];
188
- return [
189
- header,
190
- "",
191
- "Topic the user provided:",
192
- "<goal_topic>",
193
- safeTopic,
194
- "</goal_topic>",
195
- "",
196
- ...commonProtocol,
197
- "",
198
- ...(focus === "sisyphus" ? sisyphusFocusItems : goalFocusItems),
199
- ].join("\n");
200
- }
201
- //# sourceMappingURL=goal-draft.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"goal-draft.js","sourceRoot":"","sources":["../extensions/goal-draft.ts"],"names":[],"mappings":"AA0BA,8EAA8E;AAE9E,SAAS,eAAe,CAAC,QAAiB;IACzC,OAAO,QAAQ,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,aAAa,CAAC;AACtE,CAAC;AAED,SAAS,mBAAmB,CAAC,OAAe;IAC3C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,CAAC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nE,iIAAiI;QACjI,mGAAmG;KACnG,CAAC;IAEF,OAAO;QACN,MAAM;QACN,EAAE;QACF,0BAA0B;QAC1B,cAAc;QACd,SAAS;QACT,eAAe;QACf,EAAE;QACF,GAAG,cAAc;QACjB,EAAE;QACF,GAAG,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,cAAc,CAAC;KAC/D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC"}
@@ -1,139 +0,0 @@
1
- export declare const GOAL_LEDGER_FILE = ".pi/goals/goal_events.jsonl";
2
- export declare const SESSION_GOAL_LEDGER_DIR = ".pi/goals/sessions";
3
- export type GoalLedgerEvent = {
4
- type: "goal_created";
5
- goalId: string;
6
- objective: string;
7
- sisyphus: boolean;
8
- autoContinue: boolean;
9
- at: string;
10
- } | {
11
- type: "goal_focused";
12
- goalId: string;
13
- reason: string;
14
- at: string;
15
- } | {
16
- type: "goal_unfocused";
17
- reason: string;
18
- at: string;
19
- } | {
20
- type: "goal_paused";
21
- goalId: string;
22
- reason: string;
23
- suggestedAction?: string;
24
- status?: "paused";
25
- at: string;
26
- } | {
27
- type: "goal_resumed";
28
- goalId: string;
29
- reason: string;
30
- at: string;
31
- } | {
32
- type: "goal_tweaked";
33
- goalId: string;
34
- changeSummary: string;
35
- at: string;
36
- } | {
37
- type: "completion_requested";
38
- goalId: string;
39
- summary?: string;
40
- at: string;
41
- } | {
42
- type: "audit_started";
43
- goalId: string;
44
- provider?: string;
45
- model?: string;
46
- thinkingLevel?: string;
47
- at: string;
48
- } | {
49
- type: "audit_result";
50
- goalId: string;
51
- verdict: "approved" | "disapproved" | "error";
52
- report: string;
53
- at: string;
54
- } | {
55
- type: "audit_skipped";
56
- goalId: string;
57
- reason: "disabled" | "user_aborted";
58
- provider?: string;
59
- model?: string;
60
- thinkingLevel?: string;
61
- at: string;
62
- } | {
63
- type: "goal_completed";
64
- goalId: string;
65
- archivePath?: string;
66
- at: string;
67
- } | {
68
- type: "goal_aborted";
69
- goalId: string;
70
- reason: string;
71
- archivePath?: string;
72
- at: string;
73
- } | {
74
- type: "task_list_set";
75
- goalId: string;
76
- taskCount: number;
77
- blockCompletion: boolean;
78
- at: string;
79
- } | {
80
- type: "task_complete";
81
- goalId: string;
82
- taskId: string;
83
- evidence?: string;
84
- at: string;
85
- } | {
86
- type: "task_skipped";
87
- goalId: string;
88
- taskId: string;
89
- reason: string;
90
- at: string;
91
- };
92
- export interface GoalLedgerContext {
93
- cwd: string;
94
- /** Current Pi session id. When present, ledger storage is session-scoped. */
95
- sessionId?: string;
96
- /** Pi's runtime session manager; used when callers pass the full ExtensionContext. */
97
- sessionManager?: {
98
- getSessionId?: () => string;
99
- };
100
- }
101
- export interface GoalLedgerReadResult {
102
- events: GoalLedgerEvent[];
103
- malformed: number;
104
- }
105
- export interface ReconstructedGoalState {
106
- goalId: string;
107
- latestStatus: "active" | "paused" | "complete" | "aborted" | "unknown";
108
- latestFocus: boolean;
109
- latestPauseReason?: string;
110
- latestPauseSuggestedAction?: string;
111
- latestAuditorResult?: {
112
- verdict: "approved" | "disapproved" | "error";
113
- report: string;
114
- at: string;
115
- };
116
- createdAt?: string;
117
- completedAt?: string;
118
- abortedAt?: string;
119
- tweakedAt?: string;
120
- resumedAt?: string;
121
- }
122
- export interface ReconstructedLedgerState {
123
- focusedGoalId: string | null;
124
- goals: Map<string, ReconstructedGoalState>;
125
- terminalGoals: Map<string, ReconstructedGoalState>;
126
- }
127
- export declare function legacyGoalLedgerPath(ctx: GoalLedgerContext): string;
128
- export declare function goalLedgerPath(ctx: GoalLedgerContext): string;
129
- export declare function appendGoalEvent(ctx: GoalLedgerContext, event: GoalLedgerEvent): void;
130
- export declare function readGoalLedger(ctx: GoalLedgerContext): GoalLedgerReadResult;
131
- export declare function readLegacyGoalLedger(ctx: GoalLedgerContext): GoalLedgerReadResult;
132
- export declare function reconstructGoalLedger(events: GoalLedgerEvent[]): ReconstructedLedgerState;
133
- export declare function latestAuditorResultForGoal(events: GoalLedgerEvent[], goalId: string): {
134
- verdict: "approved" | "disapproved" | "error";
135
- report: string;
136
- at: string;
137
- } | undefined;
138
- export declare function latestEventsForGoal(events: GoalLedgerEvent[], goalId: string, limit?: number): GoalLedgerEvent[];
139
- export declare function latestGoalLifecycleEvent(events: GoalLedgerEvent[], goalId: string): GoalLedgerEvent | undefined;