rookery-agent 0.5.0 → 0.5.2
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/README.md +2 -0
- package/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/core/dist/org/controller.d.ts.map +1 -1
- package/packages/core/dist/org/controller.js +76 -4
- package/packages/core/dist/org/controller.js.map +1 -1
- package/packages/core/dist/providers/claude-tui.d.ts +82 -1
- package/packages/core/dist/providers/claude-tui.d.ts.map +1 -1
- package/packages/core/dist/providers/claude-tui.js +260 -13
- package/packages/core/dist/providers/claude-tui.js.map +1 -1
- package/packages/core/dist/util/interim-report.d.ts +12 -0
- package/packages/core/dist/util/interim-report.d.ts.map +1 -0
- package/packages/core/dist/util/interim-report.js +54 -0
- package/packages/core/dist/util/interim-report.js.map +1 -0
- package/packages/core/package.json +1 -1
- package/packages/server/package.json +1 -1
- package/packages/web/package.json +1 -1
package/README.md
CHANGED
|
@@ -311,6 +311,8 @@ Dormant memories remain in the database and can be woken. Sleep does not retire
|
|
|
311
311
|
|
|
312
312
|
A persistent agent is a stored role, not a permanently running provider process. Assignments launch fresh CLI processes. Delegation follows reporting relationships and is bounded by depth and concurrency limits. Defaults are four concurrent assignments, depth three, and a 45-minute timeout per assignment.
|
|
313
313
|
|
|
314
|
+
An assignment is done only when everything it started is done. Sub-agents, workflows and background commands an agent starts inside its Claude Code terminal hold the run open: when the agent stops while they still run, the run stays `running`, the task card notes what it is waiting for, and Claude Code picks the agent back up with each result. The report after the last one is the final report, and the requester hears about it once. An agent that leaves only background commands running is asked to stop or finish them. A report that says itself it is still waiting, with nothing left running, gets one request for the final report. If the assignment timeout (`org.assignmentTimeoutMs`) runs out while the run waits, it fails as `Incomplete: ...` with the last interim report, never as done. A `done` report that still reads like an interim note, or a file the task asked for that does not exist, is flagged with a warning on the card. Headless runs (`org.interactiveRuns: false`) get the card warnings only.
|
|
315
|
+
|
|
314
316
|
```bash
|
|
315
317
|
rookery org
|
|
316
318
|
rookery org hire --name Mara --title "Backend Engineer" --instructions "Maintain the server."
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@rookery/cli","version":"0.5.
|
|
1
|
+
{"name":"@rookery/cli","version":"0.5.2","type":"module"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/org/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,KAAK,EACV,KAAK,EACL,UAAU,EAEV,UAAU,EACV,kBAAkB,EAElB,qBAAqB,EAErB,cAAc,EAId,YAAY,EACZ,gBAAgB,EAEhB,YAAY,EAGZ,UAAU,EAIV,aAAa,EACb,aAAa,EACb,IAAI,EAIJ,UAAU,EAGX,MAAM,aAAa,CAAC;AAIrB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/org/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,KAAK,EACV,KAAK,EACL,UAAU,EAEV,UAAU,EACV,kBAAkB,EAElB,qBAAqB,EAErB,cAAc,EAId,YAAY,EACZ,gBAAgB,EAEhB,YAAY,EAGZ,UAAU,EAIV,aAAa,EACb,aAAa,EACb,IAAI,EAIJ,UAAU,EAGX,MAAM,aAAa,CAAC;AAIrB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,O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admitCandidates, linkEntities } from '../memory/gate.js';
|
|
14
14
|
import { clip, shorten, tail, titleFromBrief } from '../util/queue.js';
|
|
15
15
|
import { formatAge, formatDay, formatWhen } from '../util/time.js';
|
|
16
|
+
import { expectedArtifacts, looksInterim } from '../util/interim-report.js';
|
|
16
17
|
import { buildAgentPrompt, renderBoard, renderOrgOverview, renderSchedules, renderTaskActivity, } from './prompts.js';
|
|
17
18
|
import { draftHandover, draftNote, draftReconfig, draftReplacementProposal, judgeAssignment, } from './review.js';
|
|
18
19
|
import { buildTaskWaves, planTask } from './planner.js';
|
|
@@ -138,6 +139,8 @@ export function taskNotification(task, agent, question) {
|
|
|
138
139
|
class AttemptOutput {
|
|
139
140
|
text = '';
|
|
140
141
|
fatal = null;
|
|
142
|
+
/** Set while the agent's last stop was held back for background work; cleared by `done`. */
|
|
143
|
+
waitingOn = null;
|
|
141
144
|
#sinceProgress = 0;
|
|
142
145
|
/** Take in a streamed delta; true when enough has come in since the last progress line. */
|
|
143
146
|
append(delta) {
|
|
@@ -248,6 +251,13 @@ export class OrgController extends EventEmitter {
|
|
|
248
251
|
* run waits, then picks its own work back up with the results.
|
|
249
252
|
*/
|
|
250
253
|
#detached = new Map();
|
|
254
|
+
/**
|
|
255
|
+
* The last report-back each task sent, by task id. `runTask` reports from
|
|
256
|
+
* its `finally`, so a second invocation that never claimed the card (it
|
|
257
|
+
* was finished already) would tell the conversation the same ending again;
|
|
258
|
+
* only a notice that differs - a new question, a later run - goes out.
|
|
259
|
+
*/
|
|
260
|
+
#reportedBack = new Map();
|
|
251
261
|
constructor(options) {
|
|
252
262
|
super();
|
|
253
263
|
this.#store = options.store;
|
|
@@ -1842,14 +1852,22 @@ export class OrgController extends EventEmitter {
|
|
|
1842
1852
|
if (run.cancelled()) {
|
|
1843
1853
|
return record.finish({ status: 'cancelled', finishedAt: Date.now(), durationMs: Date.now() - started });
|
|
1844
1854
|
}
|
|
1845
|
-
if (abort.signal.aborted)
|
|
1846
|
-
|
|
1855
|
+
if (abort.signal.aborted) {
|
|
1856
|
+
// Timed out while its own sub-agents were still out: that is an
|
|
1857
|
+
// unfinished job, said as such - never a `done` with an interim text.
|
|
1858
|
+
return record.fail(outcome.waitingOn ? this.#incompleteReason(outcome) : 'Timed out.', started);
|
|
1859
|
+
}
|
|
1847
1860
|
if (outcome.fatal)
|
|
1848
1861
|
return record.fail(outcome.fatal, started);
|
|
1849
1862
|
if (!outcome.text.trim())
|
|
1850
1863
|
return record.fail('The agent produced no output.', started);
|
|
1851
1864
|
return this.#complete(run, outcome, started);
|
|
1852
1865
|
}
|
|
1866
|
+
#incompleteReason(outcome) {
|
|
1867
|
+
const minutes = Math.round(this.#config.org.assignmentTimeoutMs / 60000);
|
|
1868
|
+
return ('Incomplete: the run timed out after ' + minutes + ' min (' + outcome.waitingOn + ').' +
|
|
1869
|
+
(outcome.text.trim() ? ' Last interim report: ' + clip(outcome.text.trim(), NOTE_RESULT_BUDGET) : ''));
|
|
1870
|
+
}
|
|
1853
1871
|
/**
|
|
1854
1872
|
* Why no provider could take the run. A company parked entirely for quota
|
|
1855
1873
|
* says so: there is nothing to log in to, only windows to wait out.
|
|
@@ -1955,7 +1973,7 @@ export class OrgController extends EventEmitter {
|
|
|
1955
1973
|
provider = alternate;
|
|
1956
1974
|
tried.add(alternate);
|
|
1957
1975
|
}
|
|
1958
|
-
return { text: output.text, fatal: output.fatal, provider };
|
|
1976
|
+
return { text: output.text, fatal: output.fatal, provider, waitingOn: output.waitingOn };
|
|
1959
1977
|
}
|
|
1960
1978
|
/**
|
|
1961
1979
|
* Only a usage-limit death goes around once more, on a provider
|
|
@@ -2072,8 +2090,15 @@ export class OrgController extends EventEmitter {
|
|
|
2072
2090
|
record.announce({ lastActivity: { kind: 'tool', label: event.name, at: Date.now() } });
|
|
2073
2091
|
}
|
|
2074
2092
|
break;
|
|
2093
|
+
case 'status':
|
|
2094
|
+
if (event.label === 'waiting')
|
|
2095
|
+
this.#holdOpen(run, output, event.detail ?? 'waiting for background work');
|
|
2096
|
+
else if (event.label === 'resumed' && output.waitingOn)
|
|
2097
|
+
output.waitingOn = event.detail ?? output.waitingOn;
|
|
2098
|
+
break;
|
|
2075
2099
|
case 'done':
|
|
2076
2100
|
output.text = event.text || output.text;
|
|
2101
|
+
output.waitingOn = null;
|
|
2077
2102
|
break;
|
|
2078
2103
|
case 'error':
|
|
2079
2104
|
if (event.fatal) {
|
|
@@ -2083,6 +2108,28 @@ export class OrgController extends EventEmitter {
|
|
|
2083
2108
|
break;
|
|
2084
2109
|
}
|
|
2085
2110
|
}
|
|
2111
|
+
/**
|
|
2112
|
+
* The agent stopped, but the run is held open for the work it started in
|
|
2113
|
+
* the background (claude-tui `stopVerdict`). The live line and the card say
|
|
2114
|
+
* so, so a run that sits quiet for minutes reads as waiting, not stuck.
|
|
2115
|
+
*/
|
|
2116
|
+
#holdOpen(run, output, detail) {
|
|
2117
|
+
const { input, record } = run;
|
|
2118
|
+
const event = { type: 'status', label: 'waiting', detail };
|
|
2119
|
+
this.#logPush(record.id, event);
|
|
2120
|
+
input.emit(event);
|
|
2121
|
+
record.announce({ preview: shorten(detail, 110), lastActivity: { kind: 'status', label: 'waiting', at: Date.now() } });
|
|
2122
|
+
if (output.waitingOn !== detail && input.taskId) {
|
|
2123
|
+
this.#taskEvent({
|
|
2124
|
+
taskId: input.taskId,
|
|
2125
|
+
kind: 'note',
|
|
2126
|
+
actorKind: 'system',
|
|
2127
|
+
text: input.agent.name + ' stopped, but the run stays open: ' + detail + '.',
|
|
2128
|
+
assignmentId: record.id,
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
2131
|
+
output.waitingOn = detail;
|
|
2132
|
+
}
|
|
2086
2133
|
/** A run that produced a report: record it, and let the agent learn from it and be judged on it. */
|
|
2087
2134
|
#complete(run, outcome, started) {
|
|
2088
2135
|
const { input, record } = run;
|
|
@@ -2591,6 +2638,9 @@ export class OrgController extends EventEmitter {
|
|
|
2591
2638
|
status: task.status,
|
|
2592
2639
|
notice: reportBackNotice(task, agent, task.status === 'blocked' ? this.#questionFor(task) : undefined),
|
|
2593
2640
|
};
|
|
2641
|
+
if (this.#reportedBack.get(task.id) === event.notice)
|
|
2642
|
+
return;
|
|
2643
|
+
this.#reportedBack.set(task.id, event.notice);
|
|
2594
2644
|
this.emit('report-back', event);
|
|
2595
2645
|
}
|
|
2596
2646
|
/**
|
|
@@ -2880,6 +2930,7 @@ export class OrgController extends EventEmitter {
|
|
|
2880
2930
|
const note = context.taskNote ? '\n\n---\n\n' + context.taskNote : '';
|
|
2881
2931
|
let askedRequester = false;
|
|
2882
2932
|
const runNumber = this.#store.org.taskRunCount(task.id) + 1;
|
|
2933
|
+
const brief = briefFor(task);
|
|
2883
2934
|
const assignment = await this.run({
|
|
2884
2935
|
orgId: context.orgId,
|
|
2885
2936
|
agent,
|
|
@@ -2891,7 +2942,7 @@ export class OrgController extends EventEmitter {
|
|
|
2891
2942
|
// line, so heading the brief with it says the same thing twice - and
|
|
2892
2943
|
// the agent reads the repetition as emphasis that was never meant.
|
|
2893
2944
|
// Only a title that adds something gets a heading.
|
|
2894
|
-
task: dependencyResults(deps) +
|
|
2945
|
+
task: dependencyResults(deps) + brief + note,
|
|
2895
2946
|
projectId: task.projectId ?? context.projectId,
|
|
2896
2947
|
sessionId: context.sessionId,
|
|
2897
2948
|
parentId: context.parentAssignmentId,
|
|
@@ -2931,6 +2982,11 @@ export class OrgController extends EventEmitter {
|
|
|
2931
2982
|
text: runEndedNote(runNumber, assignment, askedRequester),
|
|
2932
2983
|
assignmentId: assignment.id,
|
|
2933
2984
|
});
|
|
2985
|
+
if (assignment.status === 'done') {
|
|
2986
|
+
for (const warning of completionWarnings(brief, assignment.result ?? '')) {
|
|
2987
|
+
this.#taskEvent({ taskId: task.id, kind: 'note', actorKind: 'system', text: warning, assignmentId: assignment.id });
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2934
2990
|
return {
|
|
2935
2991
|
status: assignment.status,
|
|
2936
2992
|
result: assignment.result,
|
|
@@ -3623,6 +3679,22 @@ function dependencyResults(deps) {
|
|
|
3623
3679
|
'\n\n---\n\n');
|
|
3624
3680
|
}
|
|
3625
3681
|
/** The card's line about one run of it ending. */
|
|
3682
|
+
/**
|
|
3683
|
+
* What looks wrong about a report that came back `done`: it says itself that
|
|
3684
|
+
* it is still waiting for something, or a file the task asked for is not
|
|
3685
|
+
* there. A warning on the card, not a verdict - both checks are heuristics.
|
|
3686
|
+
*/
|
|
3687
|
+
function completionWarnings(brief, result) {
|
|
3688
|
+
const warnings = [];
|
|
3689
|
+
if (looksInterim(result)) {
|
|
3690
|
+
warnings.push('Warning: the report reads like an interim note - it says it is still waiting for something.');
|
|
3691
|
+
}
|
|
3692
|
+
const missing = expectedArtifacts(brief).filter((path) => !existsSync(path));
|
|
3693
|
+
if (missing.length) {
|
|
3694
|
+
warnings.push('Warning: the task asked for ' + missing.join(', ') + ', which does not exist.');
|
|
3695
|
+
}
|
|
3696
|
+
return warnings;
|
|
3697
|
+
}
|
|
3626
3698
|
function runEndedNote(runNumber, assignment, askedRequester) {
|
|
3627
3699
|
const outcome = askedRequester && assignment.status === 'done' ? 'ended with a question' : assignment.status;
|
|
3628
3700
|
return ('Run ' + runNumber + ' ' + outcome +
|