tryassay 0.1.1 → 0.2.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.
- package/dist/cli.js +17 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/assess.js +49 -10
- package/dist/commands/assess.js.map +1 -1
- package/dist/commands/runtime.d.ts +11 -0
- package/dist/commands/runtime.js +63 -0
- package/dist/commands/runtime.js.map +1 -0
- package/dist/lib/code-verifier.js +4 -2
- package/dist/lib/code-verifier.js.map +1 -1
- package/dist/lib/requirements-generator.js +7 -3
- package/dist/lib/requirements-generator.js.map +1 -1
- package/dist/runtime/agent-loop.d.ts +46 -0
- package/dist/runtime/agent-loop.js +419 -0
- package/dist/runtime/agent-loop.js.map +1 -0
- package/dist/runtime/executor.d.ts +37 -0
- package/dist/runtime/executor.js +518 -0
- package/dist/runtime/executor.js.map +1 -0
- package/dist/runtime/observer.d.ts +44 -0
- package/dist/runtime/observer.js +247 -0
- package/dist/runtime/observer.js.map +1 -0
- package/dist/runtime/planner.d.ts +4 -0
- package/dist/runtime/planner.js +299 -0
- package/dist/runtime/planner.js.map +1 -0
- package/dist/runtime/reasoner.d.ts +4 -0
- package/dist/runtime/reasoner.js +227 -0
- package/dist/runtime/reasoner.js.map +1 -0
- package/dist/runtime/reflector.d.ts +67 -0
- package/dist/runtime/reflector.js +393 -0
- package/dist/runtime/reflector.js.map +1 -0
- package/dist/runtime/types.d.ts +317 -0
- package/dist/runtime/types.js +6 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/runtime/verifier.d.ts +46 -0
- package/dist/runtime/verifier.js +404 -0
- package/dist/runtime/verifier.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Assay Verified Agent Runtime — Observer Component
|
|
3
|
+
// Watches external signals and converts them to Observations
|
|
4
|
+
// ============================================================
|
|
5
|
+
import { EventEmitter } from 'node:events';
|
|
6
|
+
import { watch } from 'node:fs';
|
|
7
|
+
import { createServer } from 'node:http';
|
|
8
|
+
import { randomUUID } from 'node:crypto';
|
|
9
|
+
import { resolve } from 'node:path';
|
|
10
|
+
// ── FileWatcherAdapter ────────────────────────────────────────
|
|
11
|
+
export class FileWatcherAdapter {
|
|
12
|
+
type = 'filesystem';
|
|
13
|
+
watchers = [];
|
|
14
|
+
config;
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
}
|
|
18
|
+
async start(emit) {
|
|
19
|
+
for (const dirPath of this.config.paths) {
|
|
20
|
+
const resolved = resolve(dirPath);
|
|
21
|
+
const watcher = watch(resolved, { recursive: true }, (eventType, filename) => {
|
|
22
|
+
if (!filename)
|
|
23
|
+
return;
|
|
24
|
+
if (this.config.ignorePatterns?.some(p => filename.includes(p))) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const event = eventType === 'rename' ? 'create' : 'modify';
|
|
28
|
+
const payload = {
|
|
29
|
+
type: 'file_change',
|
|
30
|
+
event,
|
|
31
|
+
path: `${resolved}/${filename}`,
|
|
32
|
+
};
|
|
33
|
+
const obs = {
|
|
34
|
+
id: randomUUID(),
|
|
35
|
+
source: 'filesystem',
|
|
36
|
+
urgency: 'normal',
|
|
37
|
+
timestamp: new Date().toISOString(),
|
|
38
|
+
payload,
|
|
39
|
+
};
|
|
40
|
+
emit(obs);
|
|
41
|
+
});
|
|
42
|
+
this.watchers.push(watcher);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async stop() {
|
|
46
|
+
for (const watcher of this.watchers) {
|
|
47
|
+
watcher.close();
|
|
48
|
+
}
|
|
49
|
+
this.watchers = [];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// ── WebhookAdapter ────────────────────────────────────────────
|
|
53
|
+
export class WebhookAdapter {
|
|
54
|
+
type = 'webhook';
|
|
55
|
+
server = null;
|
|
56
|
+
config;
|
|
57
|
+
constructor(config) {
|
|
58
|
+
this.config = config;
|
|
59
|
+
}
|
|
60
|
+
async start(emit) {
|
|
61
|
+
this.server = createServer((req, res) => {
|
|
62
|
+
if (req.method !== 'POST' || req.url !== this.config.path) {
|
|
63
|
+
res.writeHead(404);
|
|
64
|
+
res.end('Not Found');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (this.config.secret) {
|
|
68
|
+
const provided = req.headers['x-webhook-secret'];
|
|
69
|
+
if (provided !== this.config.secret) {
|
|
70
|
+
res.writeHead(401);
|
|
71
|
+
res.end('Unauthorized');
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const chunks = [];
|
|
76
|
+
req.on('data', (chunk) => chunks.push(chunk));
|
|
77
|
+
req.on('end', () => {
|
|
78
|
+
const rawBody = Buffer.concat(chunks).toString('utf-8');
|
|
79
|
+
let body;
|
|
80
|
+
try {
|
|
81
|
+
body = JSON.parse(rawBody);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
body = rawBody;
|
|
85
|
+
}
|
|
86
|
+
const headers = {};
|
|
87
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
88
|
+
if (typeof value === 'string') {
|
|
89
|
+
headers[key] = value;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const payload = {
|
|
93
|
+
type: 'webhook',
|
|
94
|
+
method: req.method ?? 'POST',
|
|
95
|
+
path: req.url ?? this.config.path,
|
|
96
|
+
headers,
|
|
97
|
+
body,
|
|
98
|
+
};
|
|
99
|
+
const obs = {
|
|
100
|
+
id: randomUUID(),
|
|
101
|
+
source: 'webhook',
|
|
102
|
+
urgency: 'high',
|
|
103
|
+
timestamp: new Date().toISOString(),
|
|
104
|
+
payload,
|
|
105
|
+
};
|
|
106
|
+
emit(obs);
|
|
107
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
108
|
+
res.end(JSON.stringify({ received: true, observationId: obs.id }));
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
await new Promise((resolve, reject) => {
|
|
112
|
+
this.server.listen(this.config.port, () => resolve());
|
|
113
|
+
this.server.on('error', reject);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async stop() {
|
|
117
|
+
if (!this.server)
|
|
118
|
+
return;
|
|
119
|
+
await new Promise((resolve, reject) => {
|
|
120
|
+
this.server.close((err) => {
|
|
121
|
+
if (err)
|
|
122
|
+
reject(err);
|
|
123
|
+
else
|
|
124
|
+
resolve();
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
this.server = null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// ── ScheduleAdapter ───────────────────────────────────────────
|
|
131
|
+
export class ScheduleAdapter {
|
|
132
|
+
type = 'schedule';
|
|
133
|
+
timer = null;
|
|
134
|
+
tickCount = 0;
|
|
135
|
+
config;
|
|
136
|
+
constructor(config) {
|
|
137
|
+
this.config = config;
|
|
138
|
+
}
|
|
139
|
+
async start(emit) {
|
|
140
|
+
this.tickCount = 0;
|
|
141
|
+
this.timer = setInterval(() => {
|
|
142
|
+
this.tickCount++;
|
|
143
|
+
const payload = {
|
|
144
|
+
type: 'schedule_tick',
|
|
145
|
+
label: this.config.label,
|
|
146
|
+
tickNumber: this.tickCount,
|
|
147
|
+
};
|
|
148
|
+
const obs = {
|
|
149
|
+
id: randomUUID(),
|
|
150
|
+
source: 'schedule',
|
|
151
|
+
urgency: 'low',
|
|
152
|
+
timestamp: new Date().toISOString(),
|
|
153
|
+
payload,
|
|
154
|
+
};
|
|
155
|
+
emit(obs);
|
|
156
|
+
}, this.config.intervalMs);
|
|
157
|
+
}
|
|
158
|
+
async stop() {
|
|
159
|
+
if (this.timer !== null) {
|
|
160
|
+
clearInterval(this.timer);
|
|
161
|
+
this.timer = null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// ── Priority Queue ────────────────────────────────────────────
|
|
166
|
+
const URGENCY_ORDER = {
|
|
167
|
+
critical: 0,
|
|
168
|
+
high: 1,
|
|
169
|
+
normal: 2,
|
|
170
|
+
low: 3,
|
|
171
|
+
};
|
|
172
|
+
class PriorityQueue {
|
|
173
|
+
items = [];
|
|
174
|
+
enqueue(obs) {
|
|
175
|
+
this.items.push(obs);
|
|
176
|
+
this.items.sort((a, b) => URGENCY_ORDER[a.urgency] - URGENCY_ORDER[b.urgency]);
|
|
177
|
+
}
|
|
178
|
+
dequeue() {
|
|
179
|
+
return this.items.shift();
|
|
180
|
+
}
|
|
181
|
+
get length() {
|
|
182
|
+
return this.items.length;
|
|
183
|
+
}
|
|
184
|
+
drain() {
|
|
185
|
+
const all = this.items.splice(0);
|
|
186
|
+
return all;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// ── Observer ──────────────────────────────────────────────────
|
|
190
|
+
export class Observer extends EventEmitter {
|
|
191
|
+
adapters = [];
|
|
192
|
+
queue = new PriorityQueue();
|
|
193
|
+
running = false;
|
|
194
|
+
waitResolve = null;
|
|
195
|
+
register(adapter) {
|
|
196
|
+
this.adapters.push(adapter);
|
|
197
|
+
}
|
|
198
|
+
async start() {
|
|
199
|
+
if (this.running)
|
|
200
|
+
return;
|
|
201
|
+
this.running = true;
|
|
202
|
+
const emitFn = (obs) => {
|
|
203
|
+
if (!this.running)
|
|
204
|
+
return;
|
|
205
|
+
if (this.waitResolve) {
|
|
206
|
+
const resolve = this.waitResolve;
|
|
207
|
+
this.waitResolve = null;
|
|
208
|
+
resolve(obs);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
this.queue.enqueue(obs);
|
|
212
|
+
}
|
|
213
|
+
this.emit('observation', obs);
|
|
214
|
+
};
|
|
215
|
+
await Promise.all(this.adapters.map(a => a.start(emitFn)));
|
|
216
|
+
}
|
|
217
|
+
async stop() {
|
|
218
|
+
this.running = false;
|
|
219
|
+
if (this.waitResolve) {
|
|
220
|
+
const resolve = this.waitResolve;
|
|
221
|
+
this.waitResolve = null;
|
|
222
|
+
resolve(null);
|
|
223
|
+
}
|
|
224
|
+
await Promise.all(this.adapters.map(a => a.stop()));
|
|
225
|
+
}
|
|
226
|
+
async dequeue() {
|
|
227
|
+
const immediate = this.queue.dequeue();
|
|
228
|
+
if (immediate)
|
|
229
|
+
return immediate;
|
|
230
|
+
if (!this.running)
|
|
231
|
+
return null;
|
|
232
|
+
return new Promise((resolve) => {
|
|
233
|
+
if (!this.running) {
|
|
234
|
+
resolve(null);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
this.waitResolve = resolve;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
get queueDepth() {
|
|
241
|
+
return this.queue.length;
|
|
242
|
+
}
|
|
243
|
+
get isRunning() {
|
|
244
|
+
return this.running;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=observer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observer.js","sourceRoot":"","sources":["../../src/runtime/observer.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,oDAAoD;AACpD,6DAA6D;AAC7D,+DAA+D;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAkB,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsBpC,iEAAiE;AAEjE,MAAM,OAAO,kBAAkB;IACpB,IAAI,GAAqB,YAAY,CAAC;IACvC,QAAQ,GAAgB,EAAE,CAAC;IAC3B,MAAM,CAAyB;IAEvC,YAAY,MAA8B;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,IAAgC;QAC1C,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACxC,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,OAAO;QACX,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACvC,IAAI,SAAS;YAAE,OAAO,SAAS,CAAC;QAEhC,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAE/B,OAAO,IAAI,OAAO,CAAqB,CAAC,OAAO,EAAE,EAAE;YACjD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,OAAO,CAAC,IAAI,CAAC,CAAC;gBACd,OAAO;YACT,CAAC;YAED,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Assay Verified Agent Runtime — Planner
|
|
3
|
+
// Decomposes a Decision into concrete, verifiable ActionSteps
|
|
4
|
+
// ============================================================
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
6
|
+
import { getClient, MODEL } from '../lib/anthropic.js';
|
|
7
|
+
// ── Approval level ranking (for comparison) ─────────────────
|
|
8
|
+
const APPROVAL_RANK = {
|
|
9
|
+
auto: 0,
|
|
10
|
+
single: 1,
|
|
11
|
+
escalate: 2,
|
|
12
|
+
};
|
|
13
|
+
function highestApproval(a, b) {
|
|
14
|
+
return APPROVAL_RANK[a] >= APPROVAL_RANK[b] ? a : b;
|
|
15
|
+
}
|
|
16
|
+
// ── System prompt ───────────────────────────────────────────
|
|
17
|
+
function buildSystemPrompt(config) {
|
|
18
|
+
return `You are an operational planner for a verified agent runtime.
|
|
19
|
+
|
|
20
|
+
Your job: decompose a high-level decision into concrete, ordered action steps.
|
|
21
|
+
|
|
22
|
+
## Agent scope
|
|
23
|
+
- Name: ${config.name}
|
|
24
|
+
- Allowed directories: ${config.scope.allowedDirectories.join(', ')}
|
|
25
|
+
- Allowed commands: ${config.scope.allowedCommands.join(', ')}
|
|
26
|
+
- Allowed URLs: ${config.scope.allowedUrls.join(', ')}
|
|
27
|
+
- Blocked patterns: ${config.scope.blockedPatterns.join(', ')}
|
|
28
|
+
- Max plan steps: ${config.limits.maxPlanSteps}
|
|
29
|
+
- Command timeout: ${config.limits.commandTimeoutMs}ms
|
|
30
|
+
|
|
31
|
+
## Rules
|
|
32
|
+
1. Each step must have ONE operation (code_write, code_run, api_call, git, or message).
|
|
33
|
+
2. Every step needs preConditions (what must be true before) and postConditions (what must be true after).
|
|
34
|
+
3. Use dependsOn (array of step indices) to express ordering constraints.
|
|
35
|
+
4. Stay within the agent's allowed scope. Never produce steps that violate blocked patterns.
|
|
36
|
+
5. Be concrete — file paths, exact commands, real URLs. No placeholders.
|
|
37
|
+
6. Keep the total number of steps at or below ${config.limits.maxPlanSteps}.
|
|
38
|
+
|
|
39
|
+
## Output format
|
|
40
|
+
Respond with ONLY a JSON array of steps. No markdown, no explanation, no wrapping.
|
|
41
|
+
|
|
42
|
+
Each step object:
|
|
43
|
+
{
|
|
44
|
+
"index": 0,
|
|
45
|
+
"description": "Human-readable description",
|
|
46
|
+
"operation": { "type": "code_write"|"code_run"|"api_call"|"git"|"message", ...fields },
|
|
47
|
+
"preConditions": [{ "description": "...", "check": "..." }],
|
|
48
|
+
"postConditions": [{ "description": "...", "check": "..." }],
|
|
49
|
+
"dependsOn": [],
|
|
50
|
+
"estimatedDurationMs": 5000
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
Operation schemas:
|
|
54
|
+
- code_write: { type: "code_write", filePath: string, content: string, mode: "create"|"edit"|"append", editTarget?: string }
|
|
55
|
+
- code_run: { type: "code_run", command: string, cwd?: string, timeoutMs: number, env?: Record<string,string> }
|
|
56
|
+
- api_call: { type: "api_call", method: "GET"|"POST"|"PUT"|"DELETE"|"PATCH", url: string, headers?: Record<string,string>, body?: any, expectedStatus?: number }
|
|
57
|
+
- git: { type: "git", command: "add"|"commit"|"push"|"branch"|"checkout", args: string[], cwd?: string }
|
|
58
|
+
- message: { type: "message", channel: "console"|"slack"|"email", recipient?: string, subject?: string, content: string }`;
|
|
59
|
+
}
|
|
60
|
+
// ── User prompt ─────────────────────────────────────────────
|
|
61
|
+
function buildUserPrompt(decision) {
|
|
62
|
+
const actions = decision.proposedActions
|
|
63
|
+
.map((a, i) => `${i + 1}. [${a.operationType}] ${a.description}\n Target: ${a.target}\n Details: ${a.details}`)
|
|
64
|
+
.join('\n');
|
|
65
|
+
return `Decompose this decision into concrete action steps.
|
|
66
|
+
|
|
67
|
+
## Decision
|
|
68
|
+
ID: ${decision.id}
|
|
69
|
+
Reasoning: ${decision.reasoning}
|
|
70
|
+
Confidence: ${decision.confidence}
|
|
71
|
+
Risks: ${decision.risks.join('; ')}
|
|
72
|
+
|
|
73
|
+
## Proposed actions
|
|
74
|
+
${actions}
|
|
75
|
+
|
|
76
|
+
Produce the JSON array of steps now.`;
|
|
77
|
+
}
|
|
78
|
+
// ── Parse helpers ───────────────────────────────────────────
|
|
79
|
+
function extractJsonArray(raw) {
|
|
80
|
+
// Try direct parse first
|
|
81
|
+
const trimmed = raw.trim();
|
|
82
|
+
try {
|
|
83
|
+
const parsed = JSON.parse(trimmed);
|
|
84
|
+
if (Array.isArray(parsed))
|
|
85
|
+
return parsed;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// fall through
|
|
89
|
+
}
|
|
90
|
+
// Try extracting from markdown code block
|
|
91
|
+
const fenceMatch = trimmed.match(/```(?:json)?\s*\n?([\s\S]*?)\n?\s*```/);
|
|
92
|
+
if (fenceMatch) {
|
|
93
|
+
try {
|
|
94
|
+
const parsed = JSON.parse(fenceMatch[1].trim());
|
|
95
|
+
if (Array.isArray(parsed))
|
|
96
|
+
return parsed;
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// fall through
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Try finding array boundaries
|
|
103
|
+
const start = trimmed.indexOf('[');
|
|
104
|
+
const end = trimmed.lastIndexOf(']');
|
|
105
|
+
if (start !== -1 && end > start) {
|
|
106
|
+
try {
|
|
107
|
+
const parsed = JSON.parse(trimmed.slice(start, end + 1));
|
|
108
|
+
if (Array.isArray(parsed))
|
|
109
|
+
return parsed;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// fall through
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
throw new Error('Failed to extract JSON array from Claude response');
|
|
116
|
+
}
|
|
117
|
+
function isValidOperationType(t) {
|
|
118
|
+
return typeof t === 'string' && ['code_write', 'code_run', 'api_call', 'git', 'message'].includes(t);
|
|
119
|
+
}
|
|
120
|
+
function parseConditions(raw) {
|
|
121
|
+
if (!Array.isArray(raw))
|
|
122
|
+
return [];
|
|
123
|
+
return raw
|
|
124
|
+
.filter((c) => c !== null && typeof c === 'object')
|
|
125
|
+
.map((c) => ({
|
|
126
|
+
description: typeof c.description === 'string' ? c.description : 'unknown',
|
|
127
|
+
check: typeof c.check === 'string' ? c.check : '',
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
function parseOperation(raw) {
|
|
131
|
+
if (raw === null || typeof raw !== 'object')
|
|
132
|
+
return null;
|
|
133
|
+
const op = raw;
|
|
134
|
+
if (!isValidOperationType(op.type))
|
|
135
|
+
return null;
|
|
136
|
+
switch (op.type) {
|
|
137
|
+
case 'code_write':
|
|
138
|
+
return {
|
|
139
|
+
type: 'code_write',
|
|
140
|
+
filePath: typeof op.filePath === 'string' ? op.filePath : '',
|
|
141
|
+
content: typeof op.content === 'string' ? op.content : '',
|
|
142
|
+
mode: op.mode === 'create' || op.mode === 'edit' || op.mode === 'append'
|
|
143
|
+
? op.mode
|
|
144
|
+
: 'create',
|
|
145
|
+
editTarget: typeof op.editTarget === 'string' ? op.editTarget : undefined,
|
|
146
|
+
};
|
|
147
|
+
case 'code_run':
|
|
148
|
+
return {
|
|
149
|
+
type: 'code_run',
|
|
150
|
+
command: typeof op.command === 'string' ? op.command : '',
|
|
151
|
+
cwd: typeof op.cwd === 'string' ? op.cwd : undefined,
|
|
152
|
+
timeoutMs: typeof op.timeoutMs === 'number' ? op.timeoutMs : 30_000,
|
|
153
|
+
env: op.env !== null && typeof op.env === 'object' ? op.env : undefined,
|
|
154
|
+
};
|
|
155
|
+
case 'api_call':
|
|
156
|
+
return {
|
|
157
|
+
type: 'api_call',
|
|
158
|
+
method: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'].includes(op.method)
|
|
159
|
+
? op.method
|
|
160
|
+
: 'GET',
|
|
161
|
+
url: typeof op.url === 'string' ? op.url : '',
|
|
162
|
+
headers: op.headers !== null && typeof op.headers === 'object' ? op.headers : undefined,
|
|
163
|
+
body: op.body,
|
|
164
|
+
expectedStatus: typeof op.expectedStatus === 'number' ? op.expectedStatus : undefined,
|
|
165
|
+
};
|
|
166
|
+
case 'git':
|
|
167
|
+
return {
|
|
168
|
+
type: 'git',
|
|
169
|
+
command: ['add', 'commit', 'push', 'branch', 'checkout'].includes(op.command)
|
|
170
|
+
? op.command
|
|
171
|
+
: 'add',
|
|
172
|
+
args: Array.isArray(op.args) ? op.args.filter((a) => typeof a === 'string') : [],
|
|
173
|
+
cwd: typeof op.cwd === 'string' ? op.cwd : undefined,
|
|
174
|
+
};
|
|
175
|
+
case 'message':
|
|
176
|
+
return {
|
|
177
|
+
type: 'message',
|
|
178
|
+
channel: op.channel === 'console' || op.channel === 'slack' || op.channel === 'email'
|
|
179
|
+
? op.channel
|
|
180
|
+
: 'console',
|
|
181
|
+
recipient: typeof op.recipient === 'string' ? op.recipient : undefined,
|
|
182
|
+
subject: typeof op.subject === 'string' ? op.subject : undefined,
|
|
183
|
+
content: typeof op.content === 'string' ? op.content : '',
|
|
184
|
+
};
|
|
185
|
+
default:
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function parseRawStep(raw) {
|
|
190
|
+
if (raw === null || typeof raw !== 'object')
|
|
191
|
+
return null;
|
|
192
|
+
const obj = raw;
|
|
193
|
+
const operation = parseOperation(obj.operation);
|
|
194
|
+
if (!operation)
|
|
195
|
+
return null;
|
|
196
|
+
return {
|
|
197
|
+
index: typeof obj.index === 'number' ? obj.index : 0,
|
|
198
|
+
description: typeof obj.description === 'string' ? obj.description : 'unnamed step',
|
|
199
|
+
operation,
|
|
200
|
+
preConditions: parseConditions(obj.preConditions),
|
|
201
|
+
postConditions: parseConditions(obj.postConditions),
|
|
202
|
+
dependsOn: Array.isArray(obj.dependsOn)
|
|
203
|
+
? obj.dependsOn.filter((d) => typeof d === 'number')
|
|
204
|
+
: [],
|
|
205
|
+
estimatedDurationMs: typeof obj.estimatedDurationMs === 'number' ? obj.estimatedDurationMs : 5000,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
// ── Planner ─────────────────────────────────────────────────
|
|
209
|
+
export class Planner {
|
|
210
|
+
async plan(decision, config) {
|
|
211
|
+
const planId = randomUUID();
|
|
212
|
+
const client = getClient();
|
|
213
|
+
const systemPrompt = buildSystemPrompt(config);
|
|
214
|
+
const userPrompt = buildUserPrompt(decision);
|
|
215
|
+
// Stream the response and collect content
|
|
216
|
+
let content = '';
|
|
217
|
+
let inputTokens = 0;
|
|
218
|
+
let outputTokens = 0;
|
|
219
|
+
const stream = client.messages.stream({
|
|
220
|
+
model: config.modelId || MODEL,
|
|
221
|
+
max_tokens: 8_000,
|
|
222
|
+
system: systemPrompt,
|
|
223
|
+
messages: [{ role: 'user', content: userPrompt }],
|
|
224
|
+
});
|
|
225
|
+
stream.on('text', (text) => {
|
|
226
|
+
content += text;
|
|
227
|
+
});
|
|
228
|
+
const finalMessage = await stream.finalMessage();
|
|
229
|
+
inputTokens = finalMessage.usage.input_tokens;
|
|
230
|
+
outputTokens = finalMessage.usage.output_tokens;
|
|
231
|
+
// Parse the response into steps
|
|
232
|
+
let rawSteps;
|
|
233
|
+
try {
|
|
234
|
+
const parsed = extractJsonArray(content);
|
|
235
|
+
rawSteps = parsed
|
|
236
|
+
.map(parseRawStep)
|
|
237
|
+
.filter((s) => s !== null);
|
|
238
|
+
}
|
|
239
|
+
catch (err) {
|
|
240
|
+
// Graceful fallback: return a single-step plan that logs the failure
|
|
241
|
+
rawSteps = [{
|
|
242
|
+
index: 0,
|
|
243
|
+
description: `Plan generation failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
244
|
+
operation: {
|
|
245
|
+
type: 'message',
|
|
246
|
+
channel: 'console',
|
|
247
|
+
content: `Planner could not parse Claude response. Raw output length: ${content.length} chars.`,
|
|
248
|
+
},
|
|
249
|
+
preConditions: [],
|
|
250
|
+
postConditions: [],
|
|
251
|
+
dependsOn: [],
|
|
252
|
+
estimatedDurationMs: 0,
|
|
253
|
+
}];
|
|
254
|
+
}
|
|
255
|
+
// Enforce max plan steps
|
|
256
|
+
if (rawSteps.length > config.limits.maxPlanSteps) {
|
|
257
|
+
rawSteps = rawSteps.slice(0, config.limits.maxPlanSteps);
|
|
258
|
+
}
|
|
259
|
+
// Build index-to-ID map for dependsOn resolution
|
|
260
|
+
const stepIds = new Map();
|
|
261
|
+
for (const raw of rawSteps) {
|
|
262
|
+
stepIds.set(raw.index, randomUUID());
|
|
263
|
+
}
|
|
264
|
+
// Convert raw steps to ActionSteps
|
|
265
|
+
let overallRisk = 'auto';
|
|
266
|
+
const steps = rawSteps.map((raw, i) => {
|
|
267
|
+
const stepId = stepIds.get(raw.index) ?? randomUUID();
|
|
268
|
+
const opType = raw.operation.type;
|
|
269
|
+
const approvalLevel = config.approvalDefaults[opType] ?? 'single';
|
|
270
|
+
overallRisk = highestApproval(overallRisk, approvalLevel);
|
|
271
|
+
// Resolve dependsOn indices to step IDs
|
|
272
|
+
const dependsOn = raw.dependsOn
|
|
273
|
+
.map((depIndex) => stepIds.get(depIndex))
|
|
274
|
+
.filter((id) => id !== undefined);
|
|
275
|
+
return {
|
|
276
|
+
id: stepId,
|
|
277
|
+
planId,
|
|
278
|
+
index: i,
|
|
279
|
+
description: raw.description,
|
|
280
|
+
operation: raw.operation,
|
|
281
|
+
preConditions: raw.preConditions,
|
|
282
|
+
postConditions: raw.postConditions,
|
|
283
|
+
approvalLevel,
|
|
284
|
+
dependsOn,
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
const estimatedDurationMs = rawSteps.reduce((sum, s) => sum + (s.estimatedDurationMs ?? 5000), 0);
|
|
288
|
+
return {
|
|
289
|
+
id: planId,
|
|
290
|
+
decisionId: decision.id,
|
|
291
|
+
steps,
|
|
292
|
+
totalSteps: steps.length,
|
|
293
|
+
estimatedDurationMs,
|
|
294
|
+
overallRisk,
|
|
295
|
+
timestamp: new Date().toISOString(),
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=planner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner.js","sourceRoot":"","sources":["../../src/runtime/planner.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,yCAAyC;AACzC,8DAA8D;AAC9D,+DAA+D;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAYvD,+DAA+D;AAE/D,MAAM,aAAa,GAAkC;IACnD,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,SAAS,eAAe,CAAC,CAAgB,EAAE,CAAgB;IACzD,OAAO,aAAa,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAcD,+DAA+D;AAE/D,SAAS,iBAAiB,CAAC,MAAmB;IAC5C,OAAO;;;;;UAKC,MAAM,CA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