ai-agentmanager 1.62.0 → 1.64.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/CHANGELOG.md +40 -0
- package/README.md +109 -0
- package/package.json +1 -1
- package/public/acceptance.js +194 -0
- package/public/app.js +84 -3
- package/public/attach.js +4 -0
- package/public/autonomy.js +144 -0
- package/public/boardcols.js +1 -0
- package/public/dropzone.js +203 -0
- package/public/groups.js +2 -0
- package/public/index.html +63 -0
- package/public/machine.js +2 -0
- package/public/menu.js +20 -0
- package/public/proof.js +114 -0
- package/public/scorecard.js +1 -1
- package/public/standup.js +1 -0
- package/public/style.css +61 -2
- package/src/acceptance.js +123 -0
- package/src/advisor.js +30 -8
- package/src/autonomy.js +684 -0
- package/src/autopilot.js +9 -1
- package/src/backlog.js +16 -3
- package/src/brief.js +24 -3
- package/src/bughunt.js +1 -0
- package/src/cli.js +171 -3
- package/src/config.js +5 -0
- package/src/decisions.js +5 -1
- package/src/engines/claude.js +4 -2
- package/src/groundrules.js +97 -0
- package/src/inbox.js +48 -0
- package/src/judge.js +1 -1
- package/src/manager.js +184 -7
- package/src/notify.js +16 -0
- package/src/prereview.js +7 -2
- package/src/proof.js +255 -0
- package/src/scorecard.js +40 -10
- package/src/server.js +66 -4
- package/src/service.js +24 -3
- package/src/standup.js +1 -0
package/src/scorecard.js
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
// plan ticks, the spec's criteria) cap and correct it, and the recommendation follows fixed rules,
|
|
5
5
|
// so a confident-sounding model can't talk a change into "ready".
|
|
6
6
|
|
|
7
|
+
import { proofFacts } from './proof.js';
|
|
8
|
+
|
|
7
9
|
export const DIMENSIONS = [
|
|
8
10
|
['intent', 'Intent', 'Does it do what was asked?'],
|
|
9
11
|
['spec', 'Spec', 'Are the acceptance criteria met?'],
|
|
@@ -16,7 +18,7 @@ const WEIGHTS = { intent: 25, spec: 20, tests: 20, safety: 15, scope: 10, plan:
|
|
|
16
18
|
const TEST_FILE = /(^|\/)(tests?|__tests__|spec|specs)\/|[._-](test|spec)\.[a-z]+$|_test\.go$|Test\.java$/i;
|
|
17
19
|
|
|
18
20
|
/** Facts the app knows without a model: CI, test files touched, the agent's checks, plan and spec progress. */
|
|
19
|
-
export function facts({ files = [], prs = [], brief = null, plan = '', spec = '', standards = null }) {
|
|
21
|
+
export function facts({ files = [], prs = [], brief = null, plan = '', spec = '', standards = null, agreed = null, proof = null }) {
|
|
20
22
|
const paths = files.map((f) => f.path);
|
|
21
23
|
const tests = paths.filter((p) => TEST_FILE.test(p));
|
|
22
24
|
const code = paths.filter((p) => !TEST_FILE.test(p) && !/\.(md|txt|rst|adoc)$/i.test(p) && !/(^|\/)docs?\//i.test(p));
|
|
@@ -37,6 +39,11 @@ export function facts({ files = [], prs = [], brief = null, plan = '', spec = ''
|
|
|
37
39
|
plan: steps.length ? { steps: steps.length, done: steps.filter((s) => s === 'x').length } : null,
|
|
38
40
|
criteria: criteriaBlock.split('\n').filter((l) => /^\s*[-*\d]/.test(l) && /\w/.test(l)).length,
|
|
39
41
|
hasSpec: Boolean(String(spec).trim()),
|
|
42
|
+
// Its proof (proof.js): what it recorded, what the app ran again, and what it says it left out.
|
|
43
|
+
proof: proof ? { doc: proof.doc, rerun: proof.rerun ?? null } : null,
|
|
44
|
+
notDone: brief?.results?.notDone ?? [],
|
|
45
|
+
// What done means, agreed with the person (acceptance.js): these are checked, whatever the spec says now.
|
|
46
|
+
agreed: agreed?.length ? agreed.map((p) => ({ id: p.id, text: p.text })) : null,
|
|
40
47
|
// The repository's standards (standards.js): high-risk files touched, and the bar the app ran.
|
|
41
48
|
risk: (standards?.risk ?? []).map((r) => r.path),
|
|
42
49
|
bar: standards?.bar ? { passed: standards.bar.results.filter((r) => r.ok).length, failed: standards.bar.results.filter((r) => !r.ok).map((r) => r.name) } : null,
|
|
@@ -50,11 +57,14 @@ export const factLines = (f) =>
|
|
|
50
57
|
`the agent's own checks (from its brief): ${f.checks.passed} passed, ${f.checks.failed} failed, ${f.checks.pending} pending`,
|
|
51
58
|
`plan: ${f.plan ? `${f.plan.done} of ${f.plan.steps} steps ticked` : 'no plan written'}`,
|
|
52
59
|
`spec: ${f.hasSpec ? `${f.criteria} acceptance criteria` : 'no spec written'}`,
|
|
60
|
+
...(f.agreed ? [`acceptance agreed with the person: ${f.agreed.length} point${f.agreed.length === 1 ? '' : 's'}`] : []),
|
|
53
61
|
...(f.bar ? [`the repository's quality bar, run by the app: ${f.bar.passed} passed, ${f.bar.failed.length} failed${f.bar.failed.length ? ` (${f.bar.failed.join(', ')})` : ''}`] : []),
|
|
54
62
|
...(f.risk?.length ? [`files under paths the person marked high risk: ${f.risk.join(', ')}`] : []),
|
|
63
|
+
...(f.proof ? proofFacts(f.proof.doc, f.proof.rerun) : []),
|
|
64
|
+
...(f.notDone?.length ? [`the agent lists as not done: ${f.notDone.join('; ')}`] : []),
|
|
55
65
|
].join('\n');
|
|
56
66
|
|
|
57
|
-
export function scorecardPrompt({ intent, status, digest, briefMarkdown, intentDoc, specDoc, planDoc, hunks, facts: f, lessons = [] }) {
|
|
67
|
+
export function scorecardPrompt({ intent, status, digest, briefMarkdown, intentDoc, specDoc, planDoc, proofDoc = '', hunks, facts: f, lessons = [] }) {
|
|
58
68
|
return [
|
|
59
69
|
"You score an AI coding agent's changes for a reviewer who wants to approve with confidence and read as little as possible.",
|
|
60
70
|
'Be skeptical: a claim without evidence in the diff, the tests or the checks counts as unverified. Base everything on the material below.',
|
|
@@ -62,7 +72,9 @@ export function scorecardPrompt({ intent, status, digest, briefMarkdown, intentD
|
|
|
62
72
|
'Reply with one JSON object only:',
|
|
63
73
|
'{"summary": "<two sentences: what the change does and how sure you are>",',
|
|
64
74
|
' "scores": {"intent": {"score": 0-100, "why": "<one sentence>"}, "scope": {...}, "plan": {...}, "tests": {...}, "safety": {...}},',
|
|
65
|
-
|
|
75
|
+
f.agreed
|
|
76
|
+
? ' "criteria": [{"id": "A1", "criterion": "<the point, as written>", "status": "met|not_met|unverified", "evidence": "<where: file, test, check>"}],'
|
|
77
|
+
: ' "criteria": [{"criterion": "<an acceptance criterion from the spec>", "status": "met|not_met|unverified", "evidence": "<where: file, test, check>"}],',
|
|
66
78
|
` "look": [{"id": "H3", "reason": "<why a person should read this hunk>"}]${lessons.length ? ',' : '}'}`,
|
|
67
79
|
...(lessons.length ? [' "lessons": [{"id": "L1", "status": "followed|broken|not_applicable", "evidence": "<where in the diff>"}]}'] : []),
|
|
68
80
|
'',
|
|
@@ -72,7 +84,9 @@ export function scorecardPrompt({ intent, status, digest, briefMarkdown, intentD
|
|
|
72
84
|
'- plan: how closely the change follows PLAN (steps done, departures explained). Without a plan, judge whether the work is coherent.',
|
|
73
85
|
'- tests: whether the changed behavior is verified: tests added or updated for it, CI, checks the agent ran. Code changes with no tests and no passing checks score low.',
|
|
74
86
|
'- safety: 100 when nothing risky is touched or risks are handled; lower for security, auth, data loss, migrations, concurrency, money, new dependencies or public API changes without care.',
|
|
75
|
-
|
|
87
|
+
f.agreed
|
|
88
|
+
? '- criteria: one entry per point in AGREED_ACCEPTANCE, with its id, in its order. The person agreed on these with the agent, so judge the work against them as written, not against the criteria in SPEC. "met" only when the diff, a test or a check shows it; "not_met" when the change does not do it or goes against it; otherwise "unverified".'
|
|
89
|
+
: '- criteria: one entry per acceptance criterion in SPEC, in its order; leave the list empty if there is no spec.',
|
|
76
90
|
'- look: at most 5 hunks a person must read (the risky, subtle or unverified ones), most important first. Not the obvious ones.',
|
|
77
91
|
...(lessons.length ? ['- lessons: one entry per lesson in LESSONS. "broken" only when the diff shows the change going against it; "not_applicable" when the change has nothing to do with it.'] : []),
|
|
78
92
|
'',
|
|
@@ -85,6 +99,7 @@ export function scorecardPrompt({ intent, status, digest, briefMarkdown, intentD
|
|
|
85
99
|
'<spec>',
|
|
86
100
|
specDoc || '(no spec written)',
|
|
87
101
|
'</spec>',
|
|
102
|
+
...(f.agreed ? ['<agreed_acceptance>', ...f.agreed.map((p) => `${p.id}: ${p.text}`), '</agreed_acceptance>'] : []),
|
|
88
103
|
'<plan>',
|
|
89
104
|
planDoc || '(no plan written)',
|
|
90
105
|
'</plan>',
|
|
@@ -98,6 +113,8 @@ export function scorecardPrompt({ intent, status, digest, briefMarkdown, intentD
|
|
|
98
113
|
'<brief>',
|
|
99
114
|
briefMarkdown || '(none)',
|
|
100
115
|
'</brief>',
|
|
116
|
+
// Its own record of what it ran: evidence for a check when the output shown fits the claim, but not run by the app unless the facts say so.
|
|
117
|
+
...(proofDoc ? ['<proof_recorded_by_the_agent>', proofDoc, '</proof_recorded_by_the_agent>'] : []),
|
|
101
118
|
'<hunks>',
|
|
102
119
|
...hunks.map((h) => `<hunk id="${h.id}" file="${h.file}">\n${h.head}\n${h.text}\n</hunk>`),
|
|
103
120
|
'</hunks>',
|
|
@@ -105,6 +122,8 @@ export function scorecardPrompt({ intent, status, digest, briefMarkdown, intentD
|
|
|
105
122
|
}
|
|
106
123
|
|
|
107
124
|
const clamp = (n) => Math.max(0, Math.min(100, Math.round(Number(n) || 0)));
|
|
125
|
+
const plain = (s) => String(s ?? '').toLowerCase().replace(/[^\p{L}\p{N}]+/gu, ' ').trim();
|
|
126
|
+
const sameText = (a, b) => plain(a) === plain(b);
|
|
108
127
|
|
|
109
128
|
/**
|
|
110
129
|
* The scorecard from the model's reply and the facts: scores capped by what was measured, the spec
|
|
@@ -127,20 +146,31 @@ export function combine(reply, f, hunks, { lessons = [], bar = null } = {}) {
|
|
|
127
146
|
// The repository's quality bar, run by the app: a failed check is not verified, whatever else passed.
|
|
128
147
|
const barFailed = (bar?.results ?? []).filter((r) => !r.ok);
|
|
129
148
|
if (barFailed.length) cap('tests', 30, `the quality bar is not met (${barFailed.map((r) => r.name).join(', ')})`);
|
|
149
|
+
// Its recorded commands, run again by the app at the person's request: one that now gives another result is not verified.
|
|
150
|
+
const differs = f.proof?.rerun && !f.proof.rerun.stale ? f.proof.rerun.results.filter((r) => r.status === 'differs') : [];
|
|
151
|
+
if (differs.length) cap('tests', 40, `${differs.length} of its recorded commands gave a different result when run again (${differs.map((r) => r.title).join('; ').slice(0, 200)})`);
|
|
152
|
+
if (f.notDone?.length && out.intent) out.intent.notes.push(`the agent lists ${f.notDone.length} thing${f.notDone.length === 1 ? '' : 's'} as not done`);
|
|
130
153
|
// Plan: bounded by the steps ticked.
|
|
131
154
|
if (f.plan && out.plan) cap('plan', Math.round(40 + (60 * f.plan.done) / f.plan.steps), `${f.plan.done} of ${f.plan.steps} plan steps ticked`);
|
|
132
155
|
if (!f.plan && out.plan) out.plan.notes.push('no plan written');
|
|
133
156
|
// Spec: computed from the criteria (met 1, unverified ½, not met 0); none without a spec.
|
|
134
|
-
const
|
|
135
|
-
.filter((c) => c?.criterion)
|
|
157
|
+
const told = (Array.isArray(reply?.criteria) ? reply.criteria : [])
|
|
158
|
+
.filter((c) => c?.criterion || c?.id)
|
|
136
159
|
.slice(0, 20)
|
|
137
|
-
.map((c) => ({ criterion: String(c.criterion).slice(0, 300), status: ['met', 'not_met', 'unverified'].includes(c.status) ? c.status : 'unverified', evidence: String(c.evidence ?? '').slice(0, 300) }));
|
|
160
|
+
.map((c) => ({ id: String(c.id ?? '').trim().toUpperCase(), criterion: String(c.criterion ?? '').slice(0, 300), status: ['met', 'not_met', 'unverified'].includes(c.status) ? c.status : 'unverified', evidence: String(c.evidence ?? '').slice(0, 300) }));
|
|
161
|
+
// Points agreed with the person: exactly those, in their words; one the model skipped is unverified.
|
|
162
|
+
const criteria = f.agreed
|
|
163
|
+
? f.agreed.map((p) => {
|
|
164
|
+
const c = told.find((t) => t.id === p.id) ?? told.find((t) => !t.id && sameText(t.criterion, p.text));
|
|
165
|
+
return { id: p.id, criterion: p.text, status: c?.status ?? 'unverified', evidence: c?.evidence ?? '', agreed: true };
|
|
166
|
+
})
|
|
167
|
+
: told.filter((c) => c.criterion).map(({ id, ...c }) => c);
|
|
138
168
|
// A spec with criteria the model didn't assess: they count as unverified, not as passed.
|
|
139
|
-
if (f.hasSpec && f.criteria && !criteria.length) out.spec = { score: 50, why: `${f.criteria} acceptance criteri${f.criteria === 1 ? 'on' : 'a'} not assessed`, notes: ['treated as unverified'] };
|
|
140
|
-
if (f.hasSpec && criteria.length) {
|
|
169
|
+
if (!f.agreed && f.hasSpec && f.criteria && !criteria.length) out.spec = { score: 50, why: `${f.criteria} acceptance criteri${f.criteria === 1 ? 'on' : 'a'} not assessed`, notes: ['treated as unverified'] };
|
|
170
|
+
if ((f.hasSpec || f.agreed) && criteria.length) {
|
|
141
171
|
const pts = criteria.reduce((n, c) => n + (c.status === 'met' ? 1 : c.status === 'unverified' ? 0.5 : 0), 0);
|
|
142
172
|
const met = criteria.filter((c) => c.status === 'met').length;
|
|
143
|
-
out.spec = { score: clamp((100 * pts) / criteria.length), why: `${met} of ${criteria.length} acceptance criteri${criteria.length === 1 ? 'on' : 'a'} met${criteria.some((c) => c.status === 'not_met') ? ', some not met' : ''}`, notes: [] };
|
|
173
|
+
out.spec = { score: clamp((100 * pts) / criteria.length), why: `${met} of ${criteria.length} acceptance criteri${criteria.length === 1 ? 'on' : 'a'} met${criteria.some((c) => c.status === 'not_met') ? ', some not met' : ''}`, notes: f.agreed ? ['the points agreed with the person'] : [] };
|
|
144
174
|
}
|
|
145
175
|
// Overall: weighted over the scores there are.
|
|
146
176
|
const have = Object.entries(WEIGHTS).filter(([k]) => out[k]);
|
package/src/server.js
CHANGED
|
@@ -22,6 +22,7 @@ import { Screen } from './screen.js';
|
|
|
22
22
|
import { Awake } from './awake.js';
|
|
23
23
|
import { Files } from './files.js';
|
|
24
24
|
import { Announcer } from './announce.js';
|
|
25
|
+
import { Autonomy, LEVELS as AUTONOMY_LEVELS, parseLevel } from './autonomy.js';
|
|
25
26
|
import { Autopilot } from './autopilot.js';
|
|
26
27
|
import { Goals, goalMarkdown } from './goals.js';
|
|
27
28
|
import { Budgets } from './budgets.js';
|
|
@@ -56,7 +57,8 @@ import { Builder } from './builder.js';
|
|
|
56
57
|
import { Standup } from './standup.js';
|
|
57
58
|
import { Value, valueSlack } from './value.js';
|
|
58
59
|
import { Quality } from './quality.js';
|
|
59
|
-
import { Standards } from './standards.js';
|
|
60
|
+
import { Standards, runCheck } from './standards.js';
|
|
61
|
+
import { Proof, proofMarkdown } from './proof.js';
|
|
60
62
|
import { News } from './news.js';
|
|
61
63
|
import { System } from './system.js';
|
|
62
64
|
import { Advisor } from './advisor.js';
|
|
@@ -235,12 +237,21 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
235
237
|
manager,
|
|
236
238
|
config,
|
|
237
239
|
ship: shipAgent,
|
|
238
|
-
managed: (id) => backlog.items().some((it) => it.agentId === id && ['active', 'review'].includes(it.status) && backlog.
|
|
240
|
+
managed: (id) => backlog.items().some((it) => it.agentId === id && ['active', 'review'].includes(it.status) && backlog.levelFor(it) !== 'off'),
|
|
239
241
|
log: (m) => console.log(`[agentmgr] ${m}`),
|
|
240
242
|
});
|
|
241
243
|
// Backlog work the scorecard calls ready goes on to a pull request (and merged) by itself.
|
|
242
244
|
const autopilot = new Autopilot({ manager, store, backlog, review, landing, config });
|
|
243
245
|
manager.inboxSources.push(() => autopilot.inbox());
|
|
246
|
+
// Agents that run without you (autonomy.js): routine questions answered from what is decided,
|
|
247
|
+
// nudges and follow-ups sent, and at "merge" the pull request merged when everything says ready.
|
|
248
|
+
const autonomy = new Autonomy({ manager, store, config, review, landing, backlog });
|
|
249
|
+
manager.proof = new Proof({ manager, store, run: runCheck, log: (m) => console.log(`[agentmgr] ${m}`) });
|
|
250
|
+
manager.inboxSources.push(() => autonomy.inbox());
|
|
251
|
+
// How far an agent goes without the person is the person's to set: never an agent's own call.
|
|
252
|
+
const yourLevel = (req) => {
|
|
253
|
+
if (req.headers['x-agentmgr-agent']) throw fail(403, 'How far an agent goes without the person is set by the person, not by an agent');
|
|
254
|
+
};
|
|
244
255
|
// Daily or weekly goals across projects, planned into backlog tasks and seen through (goals.js).
|
|
245
256
|
const goals = new Goals({ manager, store, backlog, config });
|
|
246
257
|
// What agents got done, appended to a CSV for reviews (worklog.js).
|
|
@@ -357,7 +368,7 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
357
368
|
return {
|
|
358
369
|
working: views.filter((v) => ['planning', 'working', 'blocked'].includes(v.brief?.status) || (v.runtime.running && v.brief?.status !== 'done')),
|
|
359
370
|
backlog: backlog.view().items.filter((it) => it.projectKey === p.key && ['queued', 'active', 'review', 'blocked'].includes(it.status)),
|
|
360
|
-
waiting: views.filter((v) => v.runtime.attention || v.runtime.waiting || v.planReview?.status === 'review' || (v.questions ?? []).some((q) => !q.answer)),
|
|
371
|
+
waiting: views.filter((v) => v.runtime.attention || v.runtime.waiting || v.planReview?.status === 'review' || (v.acceptance?.status === 'review' && v.acceptance.wait) || (v.questions ?? []).some((q) => !q.answer)),
|
|
361
372
|
prs,
|
|
362
373
|
failing: prs.filter((x) => x.checks?.state === 'failed'),
|
|
363
374
|
bugs: openFindings(p).filter((f) => ['critical', 'high'].includes(f.severity)),
|
|
@@ -390,6 +401,11 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
390
401
|
questions: (a) => (NO_REPO.has(a.kind) ? [] : loadQuestions(a.id)),
|
|
391
402
|
bugs: (key) => hunts.list().findings.filter((f) => ['open', 'fixing', 'pr'].includes(f.status) && ['critical', 'high'].includes(f.severity) && manager.resolveProject(f.project)?.key === key).length,
|
|
392
403
|
enabled: () => config.decide?.enabled !== false,
|
|
404
|
+
// Agents that run without you (autonomy.js): "most things" may be decided for them, never what cannot be taken back.
|
|
405
|
+
autonomous: (id) => autonomy.autonomous(id),
|
|
406
|
+
guard: (item) => (autonomy.autonomous(item.agentId) ? autonomy.guard(item) : null),
|
|
407
|
+
context: (item) => autonomy.briefContext(item),
|
|
408
|
+
onAuto: (h) => autonomy.decided(h),
|
|
393
409
|
onChange: () => pushAdvisor(),
|
|
394
410
|
notify: async (text, plain) => {
|
|
395
411
|
const n = loadNotify();
|
|
@@ -586,6 +602,7 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
586
602
|
wrap((req) => {
|
|
587
603
|
const { intents, intent, startedBy, ...opts } = req.body ?? {};
|
|
588
604
|
if (opts.kind === 'assistant') throw fail(400, 'Start the assistant with POST /assistant/start');
|
|
605
|
+
if (opts.autonomy) yourLevel(req);
|
|
589
606
|
const list = (Array.isArray(intents) ? intents : [intent]).map((i) => String(i ?? '').trim()).filter(Boolean);
|
|
590
607
|
// Agents the assistant's own session starts: its limits apply, and they are marked as its.
|
|
591
608
|
const extra = assistant.admit(req.headers['x-agentmgr-agent'], list, opts);
|
|
@@ -673,6 +690,42 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
673
690
|
api.post('/agents/:id/plan/approve', wrap((req) => manager.approvePlan(req.params.id, req.body?.note)));
|
|
674
691
|
api.post('/agents/:id/plan/changes', wrap((req) => manager.requestPlanChanges(req.params.id, req.body?.note)));
|
|
675
692
|
api.post('/agents/:id/plan/review', wrap((req) => manager.setPlanReview(req.params.id, req.body?.on === true)));
|
|
693
|
+
// Acceptance: what done means, agreed with the person; the scorecard checks each point (acceptance.js).
|
|
694
|
+
api.get('/agents/:id/acceptance', wrap((req) => manager.acceptanceOf(req.params.id)));
|
|
695
|
+
// The points are the person's to agree on: an agent's own calls can read them, not set or skip them.
|
|
696
|
+
const person = (req) => {
|
|
697
|
+
if (req.headers['x-agentmgr-agent']) throw fail(403, 'What done means is agreed by the person, not by an agent');
|
|
698
|
+
};
|
|
699
|
+
api.post('/agents/:id/acceptance/agree', wrap((req) => (person(req), manager.agreeAcceptance(req.params.id, req.body?.points))));
|
|
700
|
+
api.post('/agents/:id/acceptance/skip', wrap((req) => (person(req), manager.skipAcceptance(req.params.id))));
|
|
701
|
+
// Proof (proof.js): what the agent recorded of its checks. Running the commands again is the
|
|
702
|
+
// person's call: they were written by the agent, and here they run without its permission prompts.
|
|
703
|
+
api.get('/agents/:id/proof', wrap((req) => {
|
|
704
|
+
const v = manager.proof.view(req.params.id);
|
|
705
|
+
return req.query.format === 'md' ? { markdown: proofMarkdown(v) } : v;
|
|
706
|
+
}));
|
|
707
|
+
api.post('/agents/:id/proof/run', wrap((req) => {
|
|
708
|
+
if (req.headers['x-agentmgr-agent']) throw fail(403, 'Running the proof again is asked by the person, not by an agent');
|
|
709
|
+
return manager.proof.rerun(req.params.id);
|
|
710
|
+
}));
|
|
711
|
+
// Autonomy (autonomy.js): the default level and the models its calls run on; one agent's level;
|
|
712
|
+
// and what was done for the person: seen ("ack"), or an answer changed to their own ("correct").
|
|
713
|
+
api.get('/autonomy', wrap(() => autonomy.status()));
|
|
714
|
+
api.put('/autonomy', wrap((req) => {
|
|
715
|
+
yourLevel(req);
|
|
716
|
+
saveConfig({ autonomy: autonomy.change(req.body ?? {}) });
|
|
717
|
+
return autonomy.status();
|
|
718
|
+
}));
|
|
719
|
+
api.post('/agents/:id/autonomy', wrap((req) => (yourLevel(req), autonomy.setLevel(req.params.id, req.body?.level))));
|
|
720
|
+
api.post('/agents/:id/autonomy/ack', wrap((req) => (yourLevel(req), autonomy.ack(req.params.id, String(req.body?.entry ?? '')))));
|
|
721
|
+
api.post('/agents/:id/autonomy/correct', wrap((req) => (yourLevel(req), autonomy.correct(req.params.id, String(req.body?.entry ?? ''), req.body?.text))));
|
|
722
|
+
// Ground rules: the person's own rules for every session (groundrules.js). Agents can read them, not change them.
|
|
723
|
+
api.get('/ground-rules', wrap(() => manager.groundRules.view()));
|
|
724
|
+
api.put('/ground-rules', wrap((req) => {
|
|
725
|
+
if (req.headers['x-agentmgr-agent']) throw fail(403, 'Ground rules are set by the person, not by an agent');
|
|
726
|
+
const b = req.body ?? {};
|
|
727
|
+
return manager.setGroundRules(b.rules ?? b.text ?? '', { tell: b.tell === true });
|
|
728
|
+
}));
|
|
676
729
|
api.post('/agents/:id/handoff', wrap((req) => manager.maybeHandoff(manager.mustGet(req.params.id).id, { force: true })));
|
|
677
730
|
// ---------------------------------------------------------- studio: files and editor
|
|
678
731
|
api.get('/agents/:id/files', wrap((req) => studio.list(req.params.id, req.query.dir ?? '')));
|
|
@@ -743,7 +796,10 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
743
796
|
return agent;
|
|
744
797
|
}),
|
|
745
798
|
);
|
|
746
|
-
api.patch('/agents/:id', wrap((req) =>
|
|
799
|
+
api.patch('/agents/:id', wrap((req) => {
|
|
800
|
+
if ('autonomy' in (req.body ?? {})) yourLevel(req);
|
|
801
|
+
return manager.update(req.params.id, req.body ?? {});
|
|
802
|
+
}));
|
|
747
803
|
api.post('/agents/:id/browsers', wrap((req) => manager.addBrowser(req.params.id, req.body?.url, { mode: req.body?.mode })));
|
|
748
804
|
api.patch(
|
|
749
805
|
'/agents/:id/browsers/:n',
|
|
@@ -900,6 +956,11 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
900
956
|
'/backlog',
|
|
901
957
|
wrap((req) => {
|
|
902
958
|
const { items, item, ...opts } = req.body ?? {};
|
|
959
|
+
if (opts.autonomy) {
|
|
960
|
+
yourLevel(req);
|
|
961
|
+
opts.autonomy = parseLevel(opts.autonomy);
|
|
962
|
+
if (!opts.autonomy) throw fail(400, `autonomy is one of ${AUTONOMY_LEVELS.join(', ')}`);
|
|
963
|
+
}
|
|
903
964
|
const added = backlog.add(Array.isArray(items) ? items : [item], opts);
|
|
904
965
|
repeats.record(added.map((it) => ({ text: it.title, projectKey: it.projectKey })));
|
|
905
966
|
return added;
|
|
@@ -2018,6 +2079,7 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
|
|
|
2018
2079
|
benches.close();
|
|
2019
2080
|
evals.close();
|
|
2020
2081
|
autopilot.close();
|
|
2082
|
+
autonomy.close();
|
|
2021
2083
|
goals.close();
|
|
2022
2084
|
worklog.close();
|
|
2023
2085
|
triggers.close();
|
package/src/service.js
CHANGED
|
@@ -43,6 +43,19 @@ export function passEnv(source = process.env) {
|
|
|
43
43
|
return env;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Whether the service file's daemon is the one this process talks to: the same home and port. A
|
|
48
|
+
* second daemon (another home or port, as in a trial or a test) is not the login service's.
|
|
49
|
+
*/
|
|
50
|
+
export function serviceIsOurs(text, source = process.env) {
|
|
51
|
+
const of = (key) => new RegExp(`<key>${key}</key><string>([^<]*)</string>|^Environment=${key}=(.*)$`, 'm').exec(String(text ?? ''));
|
|
52
|
+
const unxml = (v) => v.replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&');
|
|
53
|
+
return ['AGENTMGR_HOME', 'AGENTMGR_PORT'].every((key) => {
|
|
54
|
+
const m = of(key);
|
|
55
|
+
return (m ? unxml(m[1] ?? m[2]) : '') === (source[key] ?? '');
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
46
59
|
const xml = (s) => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
47
60
|
|
|
48
61
|
export function plist() {
|
|
@@ -128,18 +141,26 @@ export async function uninstall() {
|
|
|
128
141
|
throw new Error(`Login service is not supported on ${process.platform}`);
|
|
129
142
|
}
|
|
130
143
|
|
|
144
|
+
const ours = (file) => {
|
|
145
|
+
try {
|
|
146
|
+
return serviceIsOurs(fs.readFileSync(file, 'utf8'));
|
|
147
|
+
} catch {
|
|
148
|
+
return true; // loaded without a file we can read: as before
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
131
152
|
export async function status() {
|
|
132
153
|
if (process.platform === 'darwin') {
|
|
133
154
|
const installed = fs.existsSync(PLIST);
|
|
134
155
|
const loaded = await run('launchctl', ['print', `gui/${uid()}/${LABEL}`]).then(() => true, () => false);
|
|
135
|
-
return { installed, loaded, file: PLIST };
|
|
156
|
+
return { installed, loaded, ours: ours(PLIST), file: PLIST };
|
|
136
157
|
}
|
|
137
158
|
if (process.platform === 'linux') {
|
|
138
159
|
const installed = fs.existsSync(UNIT);
|
|
139
160
|
const loaded = await run('systemctl', ['--user', 'is-active', UNIT_NAME]).then(() => true, () => false);
|
|
140
|
-
return { installed, loaded, file: UNIT };
|
|
161
|
+
return { installed, loaded, ours: ours(UNIT), file: UNIT };
|
|
141
162
|
}
|
|
142
|
-
return { installed: false, loaded: false, file: null };
|
|
163
|
+
return { installed: false, loaded: false, ours: false, file: null };
|
|
143
164
|
}
|
|
144
165
|
|
|
145
166
|
/** Start the service-managed daemon now (after "agentmgr shutdown", launchd won't on its own). */
|
package/src/standup.js
CHANGED
|
@@ -28,6 +28,7 @@ export function needsOf(v) {
|
|
|
28
28
|
if (rt.attention) out.push({ kind: 'prompt', text: clip(rt.prompt?.tool?.text ? `${rt.prompt.tool.name} ${rt.prompt.tool.text}` : rt.prompt?.question || rt.attention) });
|
|
29
29
|
if (rt.waiting) out.push({ kind: 'waiting', text: clip(rt.waiting.summary) });
|
|
30
30
|
if (v.planReview?.status === 'review') out.push({ kind: 'plan', text: 'its plan is waiting for your review' });
|
|
31
|
+
if (v.acceptance?.status === 'review' && v.acceptance.wait) out.push({ kind: 'acceptance', text: 'what done means is waiting for you to agree' });
|
|
31
32
|
for (const q of v.questions ?? []) if (!q.answer) out.push({ kind: 'question', text: clip(q.question) });
|
|
32
33
|
for (const f of v.stuck ?? []) out.push({ kind: 'stuck', text: clip(f.title) });
|
|
33
34
|
for (const g of v.conflicts ?? []) if (g.mergeFirst !== v.id) out.push({ kind: 'conflict', text: `changes the same files as ${g.agent?.name ?? 'another agent'}` });
|