@pinet/agent-goal 0.2.6
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.
- package/LICENSE +21 -0
- package/README.md +130 -0
- package/dist/dashboard.d.ts +3 -0
- package/dist/dashboard.js +42 -0
- package/dist/domain.d.ts +199 -0
- package/dist/domain.js +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +337 -0
- package/dist/memory-storage.d.ts +25 -0
- package/dist/memory-storage.js +164 -0
- package/dist/pi-evaluator.d.ts +8 -0
- package/dist/pi-evaluator.js +74 -0
- package/dist/progress.d.ts +18 -0
- package/dist/progress.js +34 -0
- package/dist/runtime.d.ts +49 -0
- package/dist/runtime.js +629 -0
- package/dist/sqlite-storage.d.ts +23 -0
- package/dist/sqlite-storage.js +420 -0
- package/dist/wake-scheduler.d.ts +10 -0
- package/dist/wake-scheduler.js +34 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Will Porcellini
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# @pinet/agent-goal
|
|
2
|
+
|
|
3
|
+
A standalone Pi extension that keeps one agent session working toward one durable, bounded goal. It does not require Pinet, the Pinet broker, RALPH, or Slack.
|
|
4
|
+
|
|
5
|
+
The worker runs normally and stops when its current pass is finished. Ordinary settled runs continue automatically without spending a second model call. Independent evaluation runs only when the worker requests `complete` or `blocked`, at an optional periodic checkpoint, or on the final budget turn. Completed, blocked, budget-limited, paused, and cleared goals do not continue.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pi install npm:@pinet/agent-goal
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
For local development:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pi -e ./agent-goal/index.ts
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Commands and UI
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
/goal <objective> Create and immediately start a goal
|
|
23
|
+
/goal Inspect this session's goal
|
|
24
|
+
/goal pause Pause automatic evaluation and continuation
|
|
25
|
+
/goal resume Resume and immediately continue
|
|
26
|
+
/goal complete Mark complete manually
|
|
27
|
+
/goal clear Delete the goal
|
|
28
|
+
/goal hide Hide the persistent goal dashboard
|
|
29
|
+
/goal show Show the persistent goal dashboard
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Pi's footer shows the status and budget usage. A compact widget below the editor shows the objective, turns, tokens, last evaluator decision, continuation state, and available commands. `/goal` remains a textual fallback in headless sessions.
|
|
33
|
+
|
|
34
|
+
Only one goal may exist per Pi session. Clear the existing goal before creating another.
|
|
35
|
+
|
|
36
|
+
The agent also receives three model-visible tools:
|
|
37
|
+
|
|
38
|
+
- `create_goal` — create its own bounded, user-aligned durable goal
|
|
39
|
+
- `get_goal` — inspect the current objective, status, and budget
|
|
40
|
+
- `update_goal` — submit `complete` or `blocked` as a candidate for independent verification
|
|
41
|
+
|
|
42
|
+
An agent-created goal cannot replace an existing goal. Its first automatic continuation starts after the creating run settles, so work performed before goal creation is not incorrectly charged to the goal budget.
|
|
43
|
+
|
|
44
|
+
## Budgets
|
|
45
|
+
|
|
46
|
+
Goals default to 25 settled iterations. Optional token and runtime limits are supported:
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
PI_AGENT_GOAL_MAX_ITERATIONS=25
|
|
50
|
+
PI_AGENT_GOAL_MAX_TOKENS=200000
|
|
51
|
+
PI_AGENT_GOAL_MAX_RUNTIME_MS=14400000
|
|
52
|
+
PI_AGENT_GOAL_EVALUATION_INTERVAL=0
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Iteration and runtime limits are always reliable. Token accounting uses usage reported by Pi providers. `PI_AGENT_GOAL_EVALUATION_INTERVAL` defaults to `0`, which disables periodic checkpoints; set it to a positive number to evaluate every N settled runs. The evaluator always reviews the final allowed turn so a completed goal is not incorrectly classified as budget-limited; only another continuation is prevented.
|
|
56
|
+
|
|
57
|
+
## Persistence and recovery
|
|
58
|
+
|
|
59
|
+
The default adapter stores goals and continuation claims in SQLite at:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
~/.pi/agent/agent-goals.sqlite
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Set `PI_AGENT_GOAL_DB` to use another path. The stable Pi session ID is the storage scope, so resuming a session restores its goal. Optimistic goal versions reject stale mutations.
|
|
66
|
+
|
|
67
|
+
Every continuation first acquires a durable, idempotent per-session claim. Busy sessions persist a deferred claim and schedule an in-process wake for their retry time. Started claims schedule an expiry wake, remain until the next agent run begins, and recover safely after interruption or session resume. Evaluator and continuation failures use bounded exponential retries; exhausted retries block the goal with a diagnostic reason.
|
|
68
|
+
|
|
69
|
+
Settlements that arrive during an in-flight evaluation are atomically aggregated in storage. Every settled iteration and token delta is charged, while the evaluator receives the newest bounded progress and any preserved terminal candidate.
|
|
70
|
+
|
|
71
|
+
## Architecture
|
|
72
|
+
|
|
73
|
+
The domain and runtime depend on ports rather than Pi, Pinet, or SQLite:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
interface GoalEvaluator {
|
|
77
|
+
evaluate(goal: AgentGoal, progress: GoalProgress): Promise<GoalEvaluation>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface GoalContinuation {
|
|
81
|
+
continueIfIdle(
|
|
82
|
+
goal: AgentGoal,
|
|
83
|
+
request: GoalContinuationRequest,
|
|
84
|
+
): Promise<GoalContinuationResult>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface GoalEventSink {
|
|
88
|
+
record(event: GoalEvent): Promise<void> | void;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface GoalWakeScheduler {
|
|
92
|
+
schedule(scopeId: string, wakeAt: string, wake: () => void): void;
|
|
93
|
+
cancel(scopeId: string): void;
|
|
94
|
+
close(): void;
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`GoalStorage` includes optimistic goal mutation, atomic pending-settlement aggregation, and durable continuation-claim operations. `TimerGoalWakeScheduler` is the default process-local wake adapter and can be replaced through `GoalRuntimeOptions`. The package exports `GoalRuntime`, both storage adapters, the wake adapter, `PiGoalEvaluator`, dashboard formatters, lifecycle event types, and `registerAgentGoal`.
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { registerAgentGoal } from "@pinet/agent-goal";
|
|
102
|
+
|
|
103
|
+
registerAgentGoal(pi, {
|
|
104
|
+
storage: myStorage,
|
|
105
|
+
evaluator: myEvaluator,
|
|
106
|
+
continuation: myAtomicContinuationAdapter,
|
|
107
|
+
eventSink: myEventSink,
|
|
108
|
+
defaultBudget: { maxIterations: 20, maxTokens: 150_000 },
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The continuation adapter owns the final idle check and idempotent enqueue. Pi's current API does not expose Codex's exact `start_turn_if_idle` primitive, so the default adapter performs the closest safe operation: it rechecks session identity, idle state, and pending messages immediately before submitting a follow-up. A future Pi or Pinet adapter can provide a truly atomic implementation without changing `GoalRuntime`.
|
|
113
|
+
|
|
114
|
+
A future Pinet integration can use broker storage and evaluation plus RALPH recovery through these ports, without introducing multi-agent decomposition.
|
|
115
|
+
|
|
116
|
+
## Worker-directed evaluation
|
|
117
|
+
|
|
118
|
+
The extension registers model-visible `create_goal`, `get_goal`, and `update_goal` tools. The worker can establish its own user-aligned goal, inspect it, and call `update_goal` with `complete` only after verifying the full objective or with `blocked` for a genuine external impasse. `update_goal` records a terminal candidate rather than mutating goal state directly. When the run reaches `agent_settled`, the independent evaluator verifies that candidate. If the worker stops without calling `update_goal`, the runtime accounts the run and continues the same session without an evaluator call.
|
|
119
|
+
|
|
120
|
+
Evaluation is also forced at configured periodic checkpoints and on the final budget turn. The evaluator returns one of:
|
|
121
|
+
|
|
122
|
+
- `continue` with the next required work
|
|
123
|
+
- `complete` with completion evidence
|
|
124
|
+
- `blocked` with a specific unavailable external dependency
|
|
125
|
+
|
|
126
|
+
The standalone in-process evaluator receives bounded recent assistant and tool evidence plus any terminal candidate. Its output is strictly parsed. Newer settled progress supersedes an older in-flight result. Invalid output and provider failures are retried within policy, then recorded as a blocked goal rather than allowing an unverified terminal decision.
|
|
127
|
+
|
|
128
|
+
The standalone evaluator intentionally remains a zero-process, zero-runtime-dependency baseline. A future Pinet broker adapter can replace storage, evaluation, continuation, and events to add authoritative evidence inspection, atomic wake scheduling, and watchdog recovery. Subagent evaluators remain optional adapters; tmux and spawned Pi processes are not required.
|
|
129
|
+
|
|
130
|
+
Continuation prompts explicitly treat the objective as user-provided task data, never as higher-priority instructions.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
function displayText(value, maxLength) {
|
|
2
|
+
const normalized = value
|
|
3
|
+
.replaceAll("\n", " ")
|
|
4
|
+
.replaceAll("\r", " ")
|
|
5
|
+
.replaceAll("\u001b", "")
|
|
6
|
+
.trim();
|
|
7
|
+
return normalized.length > maxLength ? `${normalized.slice(0, maxLength - 3)}...` : normalized;
|
|
8
|
+
}
|
|
9
|
+
export function formatGoalStatus(goal) {
|
|
10
|
+
const iterations = `${goal.usage.iterations}/${goal.budget.maxIterations}`;
|
|
11
|
+
const tokens = goal.budget.maxTokens
|
|
12
|
+
? ` · ${goal.usage.tokens}/${goal.budget.maxTokens} tok`
|
|
13
|
+
: "";
|
|
14
|
+
return `goal: ${goal.status} · ${iterations} turns${tokens}`;
|
|
15
|
+
}
|
|
16
|
+
export function formatGoalDashboard(goal, claim) {
|
|
17
|
+
const usage = [
|
|
18
|
+
`Turns ${goal.usage.iterations}/${goal.budget.maxIterations}`,
|
|
19
|
+
goal.budget.maxTokens === undefined
|
|
20
|
+
? `Tokens ${goal.usage.tokens}`
|
|
21
|
+
: `Tokens ${goal.usage.tokens}/${goal.budget.maxTokens}`,
|
|
22
|
+
goal.budget.maxRuntimeMs === undefined
|
|
23
|
+
? undefined
|
|
24
|
+
: `Runtime limit ${Math.round(goal.budget.maxRuntimeMs / 60_000)}m`,
|
|
25
|
+
]
|
|
26
|
+
.filter((value) => value !== undefined)
|
|
27
|
+
.join(" · ");
|
|
28
|
+
const lines = [
|
|
29
|
+
`Goal · ${goal.status} · v${goal.version}`,
|
|
30
|
+
displayText(goal.objective, 120),
|
|
31
|
+
usage,
|
|
32
|
+
];
|
|
33
|
+
if (goal.lastEvaluation) {
|
|
34
|
+
lines.push(`Last ${goal.lastEvaluation.outcome.toUpperCase()}: ${displayText(goal.lastEvaluation.reason, 100)}`);
|
|
35
|
+
}
|
|
36
|
+
if (goal.blockedReason)
|
|
37
|
+
lines.push(`Reason: ${displayText(goal.blockedReason, 100)}`);
|
|
38
|
+
if (claim)
|
|
39
|
+
lines.push(`Continuation: ${claim.state} · attempt ${claim.attempt}`);
|
|
40
|
+
lines.push("/goal pause · resume · complete · clear · hide");
|
|
41
|
+
return lines;
|
|
42
|
+
}
|
package/dist/domain.d.ts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
export type GoalStatus = "active" | "paused" | "blocked" | "budget_limited" | "complete";
|
|
2
|
+
export interface GoalBudget {
|
|
3
|
+
maxIterations: number;
|
|
4
|
+
maxTokens?: number;
|
|
5
|
+
maxRuntimeMs?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface GoalUsage {
|
|
8
|
+
iterations: number;
|
|
9
|
+
tokens: number;
|
|
10
|
+
}
|
|
11
|
+
export interface GoalEvaluationRecord {
|
|
12
|
+
id: string;
|
|
13
|
+
outcome: GoalEvaluation["outcome"];
|
|
14
|
+
reason: string;
|
|
15
|
+
at: string;
|
|
16
|
+
}
|
|
17
|
+
export interface AgentGoal {
|
|
18
|
+
id: string;
|
|
19
|
+
scopeId: string;
|
|
20
|
+
objective: string;
|
|
21
|
+
status: GoalStatus;
|
|
22
|
+
blockedReason?: string;
|
|
23
|
+
budget: GoalBudget;
|
|
24
|
+
usage: GoalUsage;
|
|
25
|
+
lastSettledAt?: string;
|
|
26
|
+
lastEvaluation?: GoalEvaluationRecord;
|
|
27
|
+
version: number;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
updatedAt: string;
|
|
30
|
+
}
|
|
31
|
+
export type GoalEvaluation = {
|
|
32
|
+
outcome: "continue";
|
|
33
|
+
reason: string;
|
|
34
|
+
} | {
|
|
35
|
+
outcome: "complete";
|
|
36
|
+
reason: string;
|
|
37
|
+
} | {
|
|
38
|
+
outcome: "blocked";
|
|
39
|
+
reason: string;
|
|
40
|
+
};
|
|
41
|
+
export interface GoalTerminalCandidate {
|
|
42
|
+
outcome: "complete" | "blocked";
|
|
43
|
+
reason: string;
|
|
44
|
+
}
|
|
45
|
+
export interface GoalTerminalCandidateRecord extends GoalTerminalCandidate {
|
|
46
|
+
scopeId: string;
|
|
47
|
+
goalId: string;
|
|
48
|
+
goalVersion: number;
|
|
49
|
+
candidateId: string;
|
|
50
|
+
createdAt: string;
|
|
51
|
+
}
|
|
52
|
+
export interface GoalProgress {
|
|
53
|
+
latestOutput: string;
|
|
54
|
+
tokenDelta?: number;
|
|
55
|
+
terminalCandidate?: GoalTerminalCandidate;
|
|
56
|
+
}
|
|
57
|
+
export type GoalContinuationClaimState = "claimed" | "deferred" | "started";
|
|
58
|
+
export interface GoalPendingEvaluation {
|
|
59
|
+
scopeId: string;
|
|
60
|
+
goalId: string;
|
|
61
|
+
goalVersion: number;
|
|
62
|
+
evaluationId: string;
|
|
63
|
+
iterationsDelta: number;
|
|
64
|
+
progress: GoalProgress;
|
|
65
|
+
attempt: number;
|
|
66
|
+
availableAt: string;
|
|
67
|
+
lastError?: string;
|
|
68
|
+
createdAt: string;
|
|
69
|
+
updatedAt: string;
|
|
70
|
+
}
|
|
71
|
+
export interface GoalContinuationClaim {
|
|
72
|
+
scopeId: string;
|
|
73
|
+
goalId: string;
|
|
74
|
+
goalVersion: number;
|
|
75
|
+
claimId: string;
|
|
76
|
+
state: GoalContinuationClaimState;
|
|
77
|
+
reason: string;
|
|
78
|
+
attempt: number;
|
|
79
|
+
availableAt: string;
|
|
80
|
+
expiresAt: string;
|
|
81
|
+
lastError?: string;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
updatedAt: string;
|
|
84
|
+
}
|
|
85
|
+
export interface GoalStorage {
|
|
86
|
+
get(scopeId: string): Promise<AgentGoal | undefined>;
|
|
87
|
+
create(goal: AgentGoal): Promise<void>;
|
|
88
|
+
replace(goal: AgentGoal, expectedVersion: number): Promise<boolean>;
|
|
89
|
+
delete(scopeId: string, expectedVersion: number): Promise<boolean>;
|
|
90
|
+
getPendingEvaluation(scopeId: string): Promise<GoalPendingEvaluation | undefined>;
|
|
91
|
+
appendPendingEvaluation(pending: GoalPendingEvaluation): Promise<boolean>;
|
|
92
|
+
putPendingEvaluation(pending: GoalPendingEvaluation): Promise<boolean>;
|
|
93
|
+
replacePendingEvaluation(pending: GoalPendingEvaluation, expectedEvaluationId: string): Promise<boolean>;
|
|
94
|
+
deletePendingEvaluation(scopeId: string, expectedEvaluationId: string): Promise<boolean>;
|
|
95
|
+
commitEvaluation(goal: AgentGoal, expectedGoalVersion: number, expectedEvaluationId: string): Promise<boolean>;
|
|
96
|
+
getTerminalCandidate(scopeId: string): Promise<GoalTerminalCandidateRecord | undefined>;
|
|
97
|
+
putTerminalCandidate(candidate: GoalTerminalCandidateRecord): Promise<boolean>;
|
|
98
|
+
deleteTerminalCandidate(scopeId: string, expectedCandidateId: string): Promise<boolean>;
|
|
99
|
+
getContinuationClaim(scopeId: string): Promise<GoalContinuationClaim | undefined>;
|
|
100
|
+
createContinuationClaim(claim: GoalContinuationClaim): Promise<boolean>;
|
|
101
|
+
replaceContinuationClaim(claim: GoalContinuationClaim, expectedClaimId: string): Promise<boolean>;
|
|
102
|
+
deleteContinuationClaim(scopeId: string, expectedClaimId: string): Promise<boolean>;
|
|
103
|
+
close(): void;
|
|
104
|
+
}
|
|
105
|
+
export interface GoalEvaluator {
|
|
106
|
+
evaluate(goal: AgentGoal, progress: GoalProgress): Promise<GoalEvaluation>;
|
|
107
|
+
}
|
|
108
|
+
export type GoalContinuationResult = {
|
|
109
|
+
status: "started";
|
|
110
|
+
continuationId?: string;
|
|
111
|
+
} | {
|
|
112
|
+
status: "busy" | "unavailable" | "rejected";
|
|
113
|
+
reason: string;
|
|
114
|
+
retryAfterMs?: number;
|
|
115
|
+
};
|
|
116
|
+
export interface GoalContinuationRequest {
|
|
117
|
+
claimId: string;
|
|
118
|
+
idempotencyKey: string;
|
|
119
|
+
expectedGoalVersion: number;
|
|
120
|
+
reason: string;
|
|
121
|
+
}
|
|
122
|
+
export interface GoalContinuation {
|
|
123
|
+
continueIfIdle(goal: AgentGoal, request: GoalContinuationRequest): Promise<GoalContinuationResult>;
|
|
124
|
+
}
|
|
125
|
+
export interface GoalRetryPolicy {
|
|
126
|
+
maxAttempts: number;
|
|
127
|
+
baseDelayMs: number;
|
|
128
|
+
maxDelayMs: number;
|
|
129
|
+
}
|
|
130
|
+
export interface GoalWakeScheduler {
|
|
131
|
+
schedule(scopeId: string, wakeAt: string, wake: () => void): void;
|
|
132
|
+
cancel(scopeId: string): void;
|
|
133
|
+
close(): void;
|
|
134
|
+
}
|
|
135
|
+
export type GoalEvent = {
|
|
136
|
+
type: "goal.created";
|
|
137
|
+
goal: AgentGoal;
|
|
138
|
+
} | {
|
|
139
|
+
type: "goal.status_changed";
|
|
140
|
+
goal: AgentGoal;
|
|
141
|
+
previousStatus: GoalStatus;
|
|
142
|
+
} | {
|
|
143
|
+
type: "goal.progress_accounted";
|
|
144
|
+
goal: AgentGoal;
|
|
145
|
+
tokenDelta: number;
|
|
146
|
+
} | {
|
|
147
|
+
type: "goal.evaluated";
|
|
148
|
+
goal: AgentGoal;
|
|
149
|
+
evaluation: GoalEvaluation;
|
|
150
|
+
} | {
|
|
151
|
+
type: "goal.auto_continued";
|
|
152
|
+
goal: AgentGoal;
|
|
153
|
+
} | {
|
|
154
|
+
type: "goal.terminal_candidate_requested";
|
|
155
|
+
goal: AgentGoal;
|
|
156
|
+
candidate: GoalTerminalCandidateRecord;
|
|
157
|
+
} | {
|
|
158
|
+
type: "goal.continuation_claimed";
|
|
159
|
+
goal: AgentGoal;
|
|
160
|
+
claim: GoalContinuationClaim;
|
|
161
|
+
} | {
|
|
162
|
+
type: "goal.continuation_started";
|
|
163
|
+
goal: AgentGoal;
|
|
164
|
+
claim: GoalContinuationClaim;
|
|
165
|
+
} | {
|
|
166
|
+
type: "goal.continuation_deferred";
|
|
167
|
+
goal: AgentGoal;
|
|
168
|
+
claim: GoalContinuationClaim;
|
|
169
|
+
} | {
|
|
170
|
+
type: "goal.retry_scheduled";
|
|
171
|
+
scopeId: string;
|
|
172
|
+
goalId: string;
|
|
173
|
+
operation: "evaluator" | "continuation";
|
|
174
|
+
attempt: number;
|
|
175
|
+
availableAt: string;
|
|
176
|
+
error: string;
|
|
177
|
+
claimId?: string;
|
|
178
|
+
} | {
|
|
179
|
+
type: "goal.retry_exhausted";
|
|
180
|
+
scopeId: string;
|
|
181
|
+
goalId: string;
|
|
182
|
+
operation: "evaluator" | "continuation";
|
|
183
|
+
attempt: number;
|
|
184
|
+
error: string;
|
|
185
|
+
claimId?: string;
|
|
186
|
+
} | {
|
|
187
|
+
type: "goal.recovered";
|
|
188
|
+
goal: AgentGoal;
|
|
189
|
+
} | {
|
|
190
|
+
type: "goal.cleared";
|
|
191
|
+
goal: AgentGoal;
|
|
192
|
+
} | {
|
|
193
|
+
type: "goal.error";
|
|
194
|
+
operation: string;
|
|
195
|
+
error: string;
|
|
196
|
+
};
|
|
197
|
+
export interface GoalEventSink {
|
|
198
|
+
record(event: GoalEvent): Promise<void> | void;
|
|
199
|
+
}
|
package/dist/domain.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { GoalBudget, GoalContinuation, GoalEvaluator, GoalEventSink, GoalRetryPolicy, GoalStorage, GoalWakeScheduler } from "./domain.js";
|
|
3
|
+
export type { AgentGoal, GoalBudget, GoalContinuation, GoalContinuationClaim, GoalContinuationRequest, GoalContinuationResult, GoalEvaluation, GoalEvaluationRecord, GoalEvaluator, GoalEvent, GoalEventSink, GoalPendingEvaluation, GoalProgress, GoalRetryPolicy, GoalStatus, GoalStorage, GoalTerminalCandidate, GoalTerminalCandidateRecord, GoalUsage, GoalWakeScheduler, } from "./domain.js";
|
|
4
|
+
export { formatGoalDashboard, formatGoalStatus } from "./dashboard.js";
|
|
5
|
+
export { MemoryGoalStorage } from "./memory-storage.js";
|
|
6
|
+
export { parseGoalEvaluation, PiGoalEvaluator } from "./pi-evaluator.js";
|
|
7
|
+
export { countGoalProgressTokens, formatGoalProgress, type GoalProgressMessage, } from "./progress.js";
|
|
8
|
+
export { GoalRuntime, type GoalRuntimeOptions } from "./runtime.js";
|
|
9
|
+
export { SqliteGoalStorage } from "./sqlite-storage.js";
|
|
10
|
+
export { TimerGoalWakeScheduler } from "./wake-scheduler.js";
|
|
11
|
+
export interface AgentGoalExtensionOptions {
|
|
12
|
+
storage?: GoalStorage;
|
|
13
|
+
evaluator?: GoalEvaluator;
|
|
14
|
+
continuation?: GoalContinuation;
|
|
15
|
+
eventSink?: GoalEventSink;
|
|
16
|
+
defaultBudget?: GoalBudget;
|
|
17
|
+
retryPolicy?: GoalRetryPolicy;
|
|
18
|
+
databasePath?: string;
|
|
19
|
+
evaluationInterval?: number;
|
|
20
|
+
wakeScheduler?: GoalWakeScheduler;
|
|
21
|
+
}
|
|
22
|
+
export declare function registerAgentGoal(pi: ExtensionAPI, options?: AgentGoalExtensionOptions): void;
|
|
23
|
+
export default function agentGoal(pi: ExtensionAPI): void;
|