@openagt/agent-runner 0.0.1
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/bin/agent-runner +11 -0
- package/dist/cli.d.ts +19 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +208 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +62 -0
- package/dist/config.js.map +1 -0
- package/dist/ended.d.ts +66 -0
- package/dist/ended.d.ts.map +1 -0
- package/dist/ended.js +114 -0
- package/dist/ended.js.map +1 -0
- package/dist/git-host.d.ts +31 -0
- package/dist/git-host.d.ts.map +1 -0
- package/dist/git-host.js +26 -0
- package/dist/git-host.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +39 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +104 -0
- package/dist/init.js.map +1 -0
- package/dist/live-card.d.ts +27 -0
- package/dist/live-card.d.ts.map +1 -0
- package/dist/live-card.js +56 -0
- package/dist/live-card.js.map +1 -0
- package/dist/names.d.ts +12 -0
- package/dist/names.d.ts.map +1 -0
- package/dist/names.js +12 -0
- package/dist/names.js.map +1 -0
- package/dist/parent.d.ts +47 -0
- package/dist/parent.d.ts.map +1 -0
- package/dist/parent.js +52 -0
- package/dist/parent.js.map +1 -0
- package/dist/records.d.ts +81 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +89 -0
- package/dist/records.js.map +1 -0
- package/dist/run-lock.d.ts +29 -0
- package/dist/run-lock.d.ts.map +1 -0
- package/dist/run-lock.js +80 -0
- package/dist/run-lock.js.map +1 -0
- package/dist/run.d.ts +169 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +462 -0
- package/dist/run.js.map +1 -0
- package/dist/runner.d.ts +148 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +208 -0
- package/dist/runner.js.map +1 -0
- package/dist/sweep.d.ts +46 -0
- package/dist/sweep.d.ts.map +1 -0
- package/dist/sweep.js +83 -0
- package/dist/sweep.js.map +1 -0
- package/dist/test-repo.d.ts +18 -0
- package/dist/test-repo.d.ts.map +1 -0
- package/dist/test-repo.js +49 -0
- package/dist/test-repo.js.map +1 -0
- package/package.json +54 -0
package/dist/git-host.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { readProvidedCommand, runPackageCommand } from '@openagt/agent-data';
|
|
2
|
+
const NO_GIT_HOST = 'this project has no git host package';
|
|
3
|
+
/** The git host the project declares, run as a command. */
|
|
4
|
+
export const projectGitHost = {
|
|
5
|
+
async requestOfBranch(repo, branch) {
|
|
6
|
+
const command = await readProvidedCommand(repo, 'git-host').catch(() => undefined);
|
|
7
|
+
if (!command)
|
|
8
|
+
return undefined;
|
|
9
|
+
const result = await runPackageCommand(repo, command, ['requests', '--branch', branch]);
|
|
10
|
+
if (!result.ok || !Array.isArray(result.output))
|
|
11
|
+
return undefined;
|
|
12
|
+
const first = result.output[0];
|
|
13
|
+
return first && typeof first.number === 'number' && typeof first.url === 'string' ? { number: first.number, url: first.url } : undefined;
|
|
14
|
+
},
|
|
15
|
+
async mergeRequest(repo, number) {
|
|
16
|
+
const command = await readProvidedCommand(repo, 'git-host').catch(() => undefined);
|
|
17
|
+
if (!command)
|
|
18
|
+
return { outcome: 'failed', error: NO_GIT_HOST };
|
|
19
|
+
const result = await runPackageCommand(repo, command, ['merge', String(number)]);
|
|
20
|
+
if (!result.ok)
|
|
21
|
+
return { outcome: 'failed', error: result.error };
|
|
22
|
+
const outcome = result.output?.outcome;
|
|
23
|
+
return outcome === 'auto-armed' || outcome === 'merged' || outcome === 'watching' ? { outcome } : { outcome: 'failed', error: `the git host answered no outcome for pull request ${number}` };
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=git-host.js.map
|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,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,CAAA;QAC9D,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAChF,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAA;QACjE,MAAM,OAAO,GAAI,MAAM,CAAC,MAAuC,EAAE,OAAO,CAAA;QACxE,OAAO,OAAO,KAAK,YAAY,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,qDAAqD,MAAM,EAAE,EAAE,CAAA;IAC/L,CAAC;CACF,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { RUNNER_DIR, RUNS_DIR, RUNNER_CONFIG, DASHBOARD_DIR, DASHBOARD_HOOKS } from './names.js';
|
|
2
|
+
export { readConfig, readPersonal, configFile } from './config.js';
|
|
3
|
+
export { markerCard, writeMarker, withdrawMarker, recordRun, runnerMark, isPublish, PUBLISH_LEVELS, type Publish, type RunnerMark } from './records.js';
|
|
4
|
+
export { runCommand, resumeRun, runIdFrom, addedLine, HOLD_MERGE_LINE, PUBLISH_LINES, type RunOptions, type ResumeOptions, type RunOutcome } from './run.js';
|
|
5
|
+
export { sweep, type SweepDeps, type SweepResult } from './sweep.js';
|
|
6
|
+
export { childEndedLine, tellParent, type ChildEnd, type ParentDeps } from './parent.js';
|
|
7
|
+
export { runProject, resumeProject, detachRun, detachResume, readyToRun, spawnRun, spawnResume, resumeDetached, driverFor, isDriverName, DRIVER_NAMES, AGENT_ID_ENV, type DriverName, type SpawnedRun } from './runner.js';
|
|
8
|
+
export { isPidAlive, runLockPath, runStderrPath } from './run-lock.js';
|
|
9
|
+
export { projectGitHost, type GitHost, type BranchRequest, type MergeOutcome } from './git-host.js';
|
|
10
|
+
export { readLiveCard, readLiveDiary, endLiveCard, liveDir, inboxPath, LIVE_DIR, INBOX_FILE } from './live-card.js';
|
|
11
|
+
export { initHooks, writeHookLines, HOOK_LINES, type InitOutcome } from './init.js';
|
|
12
|
+
export { runCli, USAGE, type CliIo, type CliRefusal } from './cli.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAChG,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AACvJ,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAA;AAC5J,OAAO,EAAE,KAAK,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AACxF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AAC1N,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACtE,OAAO,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AACnG,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACnH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAA;AACnF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { RUNNER_DIR, RUNS_DIR, RUNNER_CONFIG, DASHBOARD_DIR, DASHBOARD_HOOKS } from './names.js';
|
|
2
|
+
export { readConfig, readPersonal, configFile } from './config.js';
|
|
3
|
+
export { markerCard, writeMarker, withdrawMarker, recordRun, runnerMark, isPublish, PUBLISH_LEVELS } from './records.js';
|
|
4
|
+
export { runCommand, resumeRun, runIdFrom, addedLine, HOLD_MERGE_LINE, PUBLISH_LINES } from './run.js';
|
|
5
|
+
export { sweep } from './sweep.js';
|
|
6
|
+
export { childEndedLine, tellParent } from './parent.js';
|
|
7
|
+
export { runProject, resumeProject, detachRun, detachResume, readyToRun, spawnRun, spawnResume, resumeDetached, driverFor, isDriverName, DRIVER_NAMES, AGENT_ID_ENV } from './runner.js';
|
|
8
|
+
export { isPidAlive, runLockPath, runStderrPath } from './run-lock.js';
|
|
9
|
+
export { projectGitHost } from './git-host.js';
|
|
10
|
+
export { readLiveCard, readLiveDiary, endLiveCard, liveDir, inboxPath, LIVE_DIR, INBOX_FILE } from './live-card.js';
|
|
11
|
+
export { initHooks, writeHookLines, HOOK_LINES } from './init.js';
|
|
12
|
+
export { runCli, USAGE } from './cli.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAChG,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAiC,MAAM,cAAc,CAAA;AACvJ,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAwD,MAAM,UAAU,CAAA;AAC5J,OAAO,EAAE,KAAK,EAAoC,MAAM,YAAY,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAkC,MAAM,aAAa,CAAA;AACxF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAoC,MAAM,aAAa,CAAA;AAC1N,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACtE,OAAO,EAAE,cAAc,EAAuD,MAAM,eAAe,CAAA;AACnG,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACnH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAoB,MAAM,WAAW,CAAA;AACnF,OAAO,EAAE,MAAM,EAAE,KAAK,EAA+B,MAAM,UAAU,CAAA"}
|
package/dist/init.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `init`: this tool's lines written into a dashboard's hooks file, so a project added to the
|
|
3
|
+
* dashboard can check, start and resume a run with nothing typed by hand. The tool writes its own
|
|
4
|
+
* lines: the dashboard runs `init` when a project is added (the package declares it under
|
|
5
|
+
* `framework.hooks` in its package.json) and holds no copy of them, and a project that wants
|
|
6
|
+
* another tool writes that tool's lines. The writer takes any tool's lines, so
|
|
7
|
+
* another tool's `init` (a scheduler's) writes its own through it.
|
|
8
|
+
*
|
|
9
|
+
* The lines name the tool bare, with no `npx`: the dashboard runs a line with the project's
|
|
10
|
+
* installed tools and then its built-in packages' on the PATH, so nothing is fetched from npm to run one.
|
|
11
|
+
*
|
|
12
|
+
* A person's file is never overwritten. A one-line key already there keeps its line, whatever
|
|
13
|
+
* it says; a list (`open`, `close`) gains a line only when it lacks it; comments and
|
|
14
|
+
* the other keys stay as they were.
|
|
15
|
+
*/
|
|
16
|
+
/** The lines, in the order a new file lists them: one line each. */
|
|
17
|
+
export declare const HOOK_LINES: Readonly<Record<string, string | readonly string[]>>;
|
|
18
|
+
export type InitOutcome = {
|
|
19
|
+
ok: true;
|
|
20
|
+
file: string;
|
|
21
|
+
added: string[];
|
|
22
|
+
kept: string[];
|
|
23
|
+
} | {
|
|
24
|
+
ok: false;
|
|
25
|
+
reason: 'no-dashboard' | 'unreadable';
|
|
26
|
+
file: string;
|
|
27
|
+
detail?: string;
|
|
28
|
+
};
|
|
29
|
+
/** This tool's lines into the dashboard's hooks file. */
|
|
30
|
+
export declare function initHooks(repo: string): Promise<InitOutcome>;
|
|
31
|
+
/**
|
|
32
|
+
* Write `lines` into `<repo>/.the-framework/hooks.yml`: a key is a one-line hook when its line is
|
|
33
|
+
* a string, a list (`open`, `close`) when it is an array. The dashboard's directory must be there
|
|
34
|
+
* already (the dashboard makes it when the project is added, and hides it from git); without it
|
|
35
|
+
* nothing is written. `added` names the keys that gained a line, `kept` the ones already set
|
|
36
|
+
* otherwise.
|
|
37
|
+
*/
|
|
38
|
+
export declare function writeHookLines(repo: string, lines: Readonly<Record<string, string | readonly string[]>>): Promise<InitOutcome>;
|
|
39
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;GAcG;AAEH,oEAAoE;AACpE,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC,CAI3E,CAAA;AAED,MAAM,MAAM,WAAW,GACnB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GAC3D;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,cAAc,GAAG,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvF,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAE5D;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CA+CpI"}
|
package/dist/init.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { mkdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { isMap, isSeq, parseDocument } from 'yaml';
|
|
4
|
+
import { DASHBOARD_DIR, DASHBOARD_HOOKS } from './names.js';
|
|
5
|
+
/**
|
|
6
|
+
* `init`: this tool's lines written into a dashboard's hooks file, so a project added to the
|
|
7
|
+
* dashboard can check, start and resume a run with nothing typed by hand. The tool writes its own
|
|
8
|
+
* lines: the dashboard runs `init` when a project is added (the package declares it under
|
|
9
|
+
* `framework.hooks` in its package.json) and holds no copy of them, and a project that wants
|
|
10
|
+
* another tool writes that tool's lines. The writer takes any tool's lines, so
|
|
11
|
+
* another tool's `init` (a scheduler's) writes its own through it.
|
|
12
|
+
*
|
|
13
|
+
* The lines name the tool bare, with no `npx`: the dashboard runs a line with the project's
|
|
14
|
+
* installed tools and then its built-in packages' on the PATH, so nothing is fetched from npm to run one.
|
|
15
|
+
*
|
|
16
|
+
* A person's file is never overwritten. A one-line key already there keeps its line, whatever
|
|
17
|
+
* it says; a list (`open`, `close`) gains a line only when it lacks it; comments and
|
|
18
|
+
* the other keys stay as they were.
|
|
19
|
+
*/
|
|
20
|
+
/** The lines, in the order a new file lists them: one line each. */
|
|
21
|
+
export const HOOK_LINES = {
|
|
22
|
+
start: 'agent-runner run --detach "$PROMPT" ${DRIVER:+--driver "$DRIVER"} ${MODEL:+--model "$MODEL"} ${THEN:+--then "$THEN"} ${PUBLISH:+--publish "$PUBLISH"} ${BASE:+--base "$BASE"}',
|
|
23
|
+
resume: 'agent-runner run --detach --resume "$RUN_ID" ${TEXT:+"$TEXT"} ${ANSWER:+--answer "$ANSWER"}',
|
|
24
|
+
check: 'agent-runner check ${DRIVER:+--driver "$DRIVER"}',
|
|
25
|
+
};
|
|
26
|
+
/** This tool's lines into the dashboard's hooks file. */
|
|
27
|
+
export function initHooks(repo) {
|
|
28
|
+
return writeHookLines(repo, HOOK_LINES);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Write `lines` into `<repo>/.the-framework/hooks.yml`: a key is a one-line hook when its line is
|
|
32
|
+
* a string, a list (`open`, `close`) when it is an array. The dashboard's directory must be there
|
|
33
|
+
* already (the dashboard makes it when the project is added, and hides it from git); without it
|
|
34
|
+
* nothing is written. `added` names the keys that gained a line, `kept` the ones already set
|
|
35
|
+
* otherwise.
|
|
36
|
+
*/
|
|
37
|
+
export async function writeHookLines(repo, lines) {
|
|
38
|
+
const file = join(repo, DASHBOARD_HOOKS);
|
|
39
|
+
if (!(await isDirectory(join(repo, DASHBOARD_DIR))))
|
|
40
|
+
return { ok: false, reason: 'no-dashboard', file };
|
|
41
|
+
let raw = '';
|
|
42
|
+
try {
|
|
43
|
+
raw = await readFile(file, 'utf8');
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// No file yet: every line is added.
|
|
47
|
+
}
|
|
48
|
+
const doc = parseDocument(raw);
|
|
49
|
+
const error = doc.errors[0];
|
|
50
|
+
if (error)
|
|
51
|
+
return { ok: false, reason: 'unreadable', file, detail: error.message.split('\n')[0] ?? error.message };
|
|
52
|
+
// An empty file, or one of comments only, is an empty map.
|
|
53
|
+
if (doc.contents === null)
|
|
54
|
+
doc.contents = doc.createNode({});
|
|
55
|
+
if (!isMap(doc.contents))
|
|
56
|
+
return { ok: false, reason: 'unreadable', file, detail: 'the file is not a YAML map' };
|
|
57
|
+
const added = [];
|
|
58
|
+
const kept = [];
|
|
59
|
+
for (const [key, line] of Object.entries(lines)) {
|
|
60
|
+
const present = doc.get(key, true);
|
|
61
|
+
if (typeof line === 'string') {
|
|
62
|
+
if (present == null) {
|
|
63
|
+
doc.set(key, line);
|
|
64
|
+
added.push(key);
|
|
65
|
+
}
|
|
66
|
+
else if (String(doc.get(key)).trim() !== line) {
|
|
67
|
+
kept.push(key);
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (present == null) {
|
|
72
|
+
doc.set(key, doc.createNode([...line]));
|
|
73
|
+
added.push(key);
|
|
74
|
+
}
|
|
75
|
+
else if (isSeq(present)) {
|
|
76
|
+
const lines = present.items.map(item => String(isScalarLike(item) ? item.value : item).trim());
|
|
77
|
+
const missing = line.filter(l => !lines.includes(l));
|
|
78
|
+
for (const l of missing)
|
|
79
|
+
present.add(doc.createNode(l));
|
|
80
|
+
if (missing.length > 0)
|
|
81
|
+
added.push(key);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
kept.push(key);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (added.length > 0) {
|
|
88
|
+
await mkdir(dirname(file), { recursive: true });
|
|
89
|
+
await writeFile(file, doc.toString({ lineWidth: 0 }));
|
|
90
|
+
}
|
|
91
|
+
return { ok: true, file, added, kept };
|
|
92
|
+
}
|
|
93
|
+
function isScalarLike(item) {
|
|
94
|
+
return typeof item === 'object' && item !== null && 'value' in item;
|
|
95
|
+
}
|
|
96
|
+
async function isDirectory(path) {
|
|
97
|
+
try {
|
|
98
|
+
return (await stat(path)).isDirectory();
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=init.js.map
|
package/dist/init.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAW,MAAM,MAAM,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE3D;;;;;;;;;;;;;;GAcG;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,UAAU,GAAyD;IAC9E,KAAK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2
|
+
/**
|
|
3
|
+
* A run's live record: the card and the diary agent-driver keeps under `.the-framework/` in the
|
|
4
|
+
* run's checkout, in the run record's shape, while the agent works. The dashboard reads them
|
|
5
|
+
* there; the run copies them onto the `agent-data` branch unchanged when it ends; the sweep
|
|
6
|
+
* reads them to find a run whose process died, and closes them from outside.
|
|
7
|
+
*/
|
|
8
|
+
/** The dashboard's directory in a checkout, where the two files live. */
|
|
9
|
+
export declare const LIVE_DIR = ".the-framework";
|
|
10
|
+
/** The inbox's file name under the live directory: what reaches the agent from outside. */
|
|
11
|
+
export declare const INBOX_FILE = "inbox.jsonl";
|
|
12
|
+
export declare function liveDir(checkout: string): string;
|
|
13
|
+
export declare function inboxPath(checkout: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Keep the live directory out of git in this checkout alone, so the tree stays clean for the
|
|
16
|
+
* reclaim: a `.gitignore` of `*` inside it. Never a rule in the repository's shared exclude file,
|
|
17
|
+
* which every checkout reads, the project's own included, where it would stop the dashboard from
|
|
18
|
+
* tracking its directory. A `.gitignore` already there is kept as it is.
|
|
19
|
+
*/
|
|
20
|
+
export declare function hideLiveDir(checkout: string): Promise<void>;
|
|
21
|
+
/** A checkout's live card, or `undefined` when it holds none, it does not parse, or it is not this tool's (no mark). */
|
|
22
|
+
export declare function readLiveCard(checkout: string, id: string): Promise<RunCard | undefined>;
|
|
23
|
+
/** A checkout's live diary, every line that parses. */
|
|
24
|
+
export declare function readLiveDiary(checkout: string, id: string): Promise<AnyDiaryLine[]>;
|
|
25
|
+
/** Close a checkout's live record from outside its process: the `ended` line appended, the card's status set. Best-effort. */
|
|
26
|
+
export declare function endLiveCard(checkout: string, card: RunCard, status: Exclude<RunStatus, 'running'>, detail: string, at: string): Promise<RunCard>;
|
|
27
|
+
//# sourceMappingURL=live-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-card.d.ts","sourceRoot":"","sources":["../src/live-card.ts"],"names":[],"mappings":"AAGA,OAAO,EAA4B,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAG/G;;;;;GAKG;AAEH,yEAAyE;AACzE,eAAO,MAAM,QAAQ,mBAAmB,CAAA;AAExC,2FAA2F;AAC3F,eAAO,MAAM,UAAU,gBAAgB,CAAA;AAEvC,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMjE;AAED,wHAAwH;AACxH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAK7F;AAED,uDAAuD;AACvD,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAGzF;AAED,8HAA8H;AAC9H,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAKtJ"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { appendFile, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { logCardFile, logDiaryFile } from '@openagt/agent-driver';
|
|
4
|
+
import { parseDiary, parseRunCard } from '@openagt/skill-logs';
|
|
5
|
+
import { runnerMark } from './records.js';
|
|
6
|
+
/**
|
|
7
|
+
* A run's live record: the card and the diary agent-driver keeps under `.the-framework/` in the
|
|
8
|
+
* run's checkout, in the run record's shape, while the agent works. The dashboard reads them
|
|
9
|
+
* there; the run copies them onto the `agent-data` branch unchanged when it ends; the sweep
|
|
10
|
+
* reads them to find a run whose process died, and closes them from outside.
|
|
11
|
+
*/
|
|
12
|
+
/** The dashboard's directory in a checkout, where the two files live. */
|
|
13
|
+
export const LIVE_DIR = '.the-framework';
|
|
14
|
+
/** The inbox's file name under the live directory: what reaches the agent from outside. */
|
|
15
|
+
export const INBOX_FILE = 'inbox.jsonl';
|
|
16
|
+
export function liveDir(checkout) {
|
|
17
|
+
return join(checkout, LIVE_DIR);
|
|
18
|
+
}
|
|
19
|
+
export function inboxPath(checkout) {
|
|
20
|
+
return join(liveDir(checkout), INBOX_FILE);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Keep the live directory out of git in this checkout alone, so the tree stays clean for the
|
|
24
|
+
* reclaim: a `.gitignore` of `*` inside it. Never a rule in the repository's shared exclude file,
|
|
25
|
+
* which every checkout reads, the project's own included, where it would stop the dashboard from
|
|
26
|
+
* tracking its directory. A `.gitignore` already there is kept as it is.
|
|
27
|
+
*/
|
|
28
|
+
export async function hideLiveDir(checkout) {
|
|
29
|
+
const dir = liveDir(checkout);
|
|
30
|
+
await mkdir(dir, { recursive: true });
|
|
31
|
+
await writeFile(join(dir, '.gitignore'), '*\n', { flag: 'wx' }).catch((err) => {
|
|
32
|
+
if (err.code !== 'EEXIST')
|
|
33
|
+
throw err;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/** A checkout's live card, or `undefined` when it holds none, it does not parse, or it is not this tool's (no mark). */
|
|
37
|
+
export async function readLiveCard(checkout, id) {
|
|
38
|
+
const raw = await readFile(join(liveDir(checkout), logCardFile(id)), 'utf8').catch(() => undefined);
|
|
39
|
+
if (raw === undefined)
|
|
40
|
+
return undefined;
|
|
41
|
+
const card = parseRunCard(raw);
|
|
42
|
+
return card && runnerMark(card) ? card : undefined;
|
|
43
|
+
}
|
|
44
|
+
/** A checkout's live diary, every line that parses. */
|
|
45
|
+
export async function readLiveDiary(checkout, id) {
|
|
46
|
+
const raw = await readFile(join(liveDir(checkout), logDiaryFile(id)), 'utf8').catch(() => '');
|
|
47
|
+
return parseDiary(raw);
|
|
48
|
+
}
|
|
49
|
+
/** Close a checkout's live record from outside its process: the `ended` line appended, the card's status set. Best-effort. */
|
|
50
|
+
export async function endLiveCard(checkout, card, status, detail, at) {
|
|
51
|
+
const ended = { ...card, status, endedAt: at };
|
|
52
|
+
await appendFile(join(liveDir(checkout), logDiaryFile(card.id)), JSON.stringify({ kind: 'ended', status, detail, at }) + '\n').catch(() => { });
|
|
53
|
+
await writeFile(join(liveDir(checkout), logCardFile(card.id)), JSON.stringify(ended, null, 2) + '\n').catch(() => { });
|
|
54
|
+
return ended;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=live-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-card.js","sourceRoot":"","sources":["../src/live-card.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAmD,MAAM,qBAAqB,CAAA;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;GAKG;AAEH,yEAAyE;AACzE,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CAAA;AAExC,2FAA2F;AAC3F,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAA;AAEvC,MAAM,UAAU,OAAO,CAAC,QAAgB;IACtC,OAAO,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACjC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,QAAgB;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,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;IAC7F,OAAO,UAAU,CAAC,GAAG,CAAC,CAAA;AACxB,CAAC;AAED,8HAA8H;AAC9H,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAgB,EAAE,IAAa,EAAE,MAAqC,EAAE,MAAc,EAAE,EAAU;IAClI,MAAM,KAAK,GAAY,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAA;IACvD,MAAM,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IAC9I,MAAM,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IACrH,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/dist/names.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The names the package hangs off. No node imports. */
|
|
2
|
+
/** The tool's own directory at the repository root, hidden from git by the tool itself. */
|
|
3
|
+
export declare const RUNNER_DIR = ".agent-runner";
|
|
4
|
+
/** Under the tool's directory: one lock and one stderr file per run. */
|
|
5
|
+
export declare const RUNS_DIR = "runs";
|
|
6
|
+
/** The dashboard's directory in a project it knows: made and hidden from git when the project is added. */
|
|
7
|
+
export declare const DASHBOARD_DIR = ".the-framework";
|
|
8
|
+
/** The dashboard's hooks file, the lines it runs for the project: where `init` writes this tool's. */
|
|
9
|
+
export declare const DASHBOARD_HOOKS = ".the-framework/hooks.yml";
|
|
10
|
+
/** Under the tool's directory: this machine's settings for the tool, the `ended:` line and the `personal:` parts. */
|
|
11
|
+
export declare const RUNNER_CONFIG = "config.yml";
|
|
12
|
+
//# sourceMappingURL=names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../src/names.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,2FAA2F;AAC3F,eAAO,MAAM,UAAU,kBAAkB,CAAA;AAEzC,wEAAwE;AACxE,eAAO,MAAM,QAAQ,SAAS,CAAA;AAE9B,2GAA2G;AAC3G,eAAO,MAAM,aAAa,mBAAmB,CAAA;AAE7C,sGAAsG;AACtG,eAAO,MAAM,eAAe,6BAA+B,CAAA;AAE3D,qHAAqH;AACrH,eAAO,MAAM,aAAa,eAAe,CAAA"}
|
package/dist/names.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The names the package hangs off. No node imports. */
|
|
2
|
+
/** The tool's own directory at the repository root, hidden from git by the tool itself. */
|
|
3
|
+
export const RUNNER_DIR = '.agent-runner';
|
|
4
|
+
/** Under the tool's directory: one lock and one stderr file per run. */
|
|
5
|
+
export const RUNS_DIR = 'runs';
|
|
6
|
+
/** The dashboard's directory in a project it knows: made and hidden from git when the project is added. */
|
|
7
|
+
export const DASHBOARD_DIR = '.the-framework';
|
|
8
|
+
/** The dashboard's hooks file, the lines it runs for the project: where `init` writes this tool's. */
|
|
9
|
+
export const DASHBOARD_HOOKS = `${DASHBOARD_DIR}/hooks.yml`;
|
|
10
|
+
/** Under the tool's directory: this machine's settings for the tool, the `ended:` line and the `personal:` parts. */
|
|
11
|
+
export const RUNNER_CONFIG = 'config.yml';
|
|
12
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../src/names.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAA;AAEzC,wEAAwE;AACxE,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAA;AAE9B,2GAA2G;AAC3G,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAA;AAE7C,sGAAsG;AACtG,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,aAAa,YAAY,CAAA;AAE3D,qHAAqH;AACrH,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAA"}
|
package/dist/parent.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A run started for another run, its parent (`run --parent <id>`), tells the parent when it ends:
|
|
3
|
+
* one line saying which run, how it ended, and its last words. The line reaches the parent the way
|
|
4
|
+
* a person's message reaches a run: into its inbox while it works, as a resume once it has ended.
|
|
5
|
+
* Nothing waits for a child: the parent's agent ends its turn, and the line is its next prompt.
|
|
6
|
+
*/
|
|
7
|
+
/** How a run ended, as its parent is told. */
|
|
8
|
+
export interface ChildEnd {
|
|
9
|
+
id: string;
|
|
10
|
+
status: string;
|
|
11
|
+
/** Why, when the run did not end well. */
|
|
12
|
+
detail?: string;
|
|
13
|
+
/** The question the run stopped on, when it ended waiting. */
|
|
14
|
+
question?: string;
|
|
15
|
+
/** The branch the run's work is on, when it still exists. */
|
|
16
|
+
branch?: string;
|
|
17
|
+
pr?: {
|
|
18
|
+
url: string;
|
|
19
|
+
};
|
|
20
|
+
/** The agent's answer on its last turn. */
|
|
21
|
+
lastWords?: string;
|
|
22
|
+
}
|
|
23
|
+
/** The line a parent gets: which run, how it ended, where its work is, and its last words. */
|
|
24
|
+
export declare function childEndedLine(end: ChildEnd): string;
|
|
25
|
+
export interface ParentDeps {
|
|
26
|
+
host: string;
|
|
27
|
+
/** Whether a pid is a live process here. */
|
|
28
|
+
isAlive: (pid: number) => boolean;
|
|
29
|
+
/** Continue an ended run in its own process, with a text or an answer. Absent, an ended parent is not told. */
|
|
30
|
+
resume?: (id: string, line: {
|
|
31
|
+
text: string;
|
|
32
|
+
} | {
|
|
33
|
+
answer: string;
|
|
34
|
+
}) => Promise<void>;
|
|
35
|
+
log: (line: string) => void;
|
|
36
|
+
/** Whether the parent is working; read off its live card when absent. */
|
|
37
|
+
isWorking?: (repo: string, id: string) => Promise<boolean>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Hand one line to the parent run. A parent that is working takes it from its inbox when its turn
|
|
41
|
+
* ends. A parent that has ended is continued with it. A parent that ends while the line is on its
|
|
42
|
+
* way would leave it in an inbox nobody reads, so the parent is looked at again after the write,
|
|
43
|
+
* and what is still in the inbox then is taken back and continues the parent instead. Never
|
|
44
|
+
* throws: whatever goes wrong is one line on `log`, and the child ends as it ended.
|
|
45
|
+
*/
|
|
46
|
+
export declare function tellParent(repo: string, parent: string, text: string, deps: ParentDeps): Promise<void>;
|
|
47
|
+
//# sourceMappingURL=parent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parent.d.ts","sourceRoot":"","sources":["../src/parent.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH,8CAA8C;AAC9C,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IACpB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,8FAA8F;AAC9F,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,CAQpD;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,4CAA4C;IAC5C,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;IACjC,+GAA+G;IAC/G,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACnF,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3B,yEAAyE;IACzE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAC3D;AASD;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAe5G"}
|
package/dist/parent.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { appendInbox, takeInbox } from '@openagt/agent-driver';
|
|
2
|
+
import { worktreePath } from '@openagt/skill-branches';
|
|
3
|
+
import { inboxPath, readLiveCard } from './live-card.js';
|
|
4
|
+
import { runnerMark } from './records.js';
|
|
5
|
+
/** The line a parent gets: which run, how it ended, where its work is, and its last words. */
|
|
6
|
+
export function childEndedLine(end) {
|
|
7
|
+
const lines = [`The run ${end.id}, started for this run, ended ${end.status}${end.detail ? `: ${end.detail}` : ''}.`];
|
|
8
|
+
if (end.question !== undefined)
|
|
9
|
+
lines.push(`It is waiting on a question: ${end.question.replace(/\s+/g, ' ').trim()}`);
|
|
10
|
+
if (end.branch !== undefined)
|
|
11
|
+
lines.push(`Its work is on the branch ${end.branch}.`);
|
|
12
|
+
if (end.pr)
|
|
13
|
+
lines.push(`Its pull request: ${end.pr.url}`);
|
|
14
|
+
const words = end.lastWords?.trim();
|
|
15
|
+
if (words)
|
|
16
|
+
lines.push('', 'Its last words:', words);
|
|
17
|
+
return lines.join('\n');
|
|
18
|
+
}
|
|
19
|
+
/** Whether the run's live card says it is working, on this machine, under a process that is alive. */
|
|
20
|
+
async function isRunWorking(repo, id, deps) {
|
|
21
|
+
const card = await readLiveCard(worktreePath(repo, id), id);
|
|
22
|
+
const mark = card && runnerMark(card);
|
|
23
|
+
return card?.status === 'running' && mark !== undefined && mark.host === deps.host && mark.pid !== undefined && deps.isAlive(mark.pid);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hand one line to the parent run. A parent that is working takes it from its inbox when its turn
|
|
27
|
+
* ends. A parent that has ended is continued with it. A parent that ends while the line is on its
|
|
28
|
+
* way would leave it in an inbox nobody reads, so the parent is looked at again after the write,
|
|
29
|
+
* and what is still in the inbox then is taken back and continues the parent instead. Never
|
|
30
|
+
* throws: whatever goes wrong is one line on `log`, and the child ends as it ended.
|
|
31
|
+
*/
|
|
32
|
+
export async function tellParent(repo, parent, text, deps) {
|
|
33
|
+
try {
|
|
34
|
+
const isWorking = deps.isWorking ?? ((r, id) => isRunWorking(r, id, deps));
|
|
35
|
+
let lines = [{ kind: 'message', text }];
|
|
36
|
+
if (await isWorking(repo, parent)) {
|
|
37
|
+
const inbox = inboxPath(worktreePath(repo, parent));
|
|
38
|
+
await appendInbox(inbox, lines[0]);
|
|
39
|
+
if (await isWorking(repo, parent))
|
|
40
|
+
return;
|
|
41
|
+
lines = await takeInbox(inbox);
|
|
42
|
+
}
|
|
43
|
+
if (!deps.resume)
|
|
44
|
+
return;
|
|
45
|
+
for (const stranded of lines)
|
|
46
|
+
await deps.resume(parent, stranded.kind === 'message' ? { text: stranded.text } : { answer: stranded.answer });
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
deps.log(`[agent-runner] the parent run ${parent} could not be told: ${err instanceof Error ? err.message : String(err)}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=parent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parent.js","sourceRoot":"","sources":["../src/parent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAkB,MAAM,uBAAuB,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAwBzC,8FAA8F;AAC9F,MAAM,UAAU,cAAc,CAAC,GAAa;IAC1C,MAAM,KAAK,GAAG,CAAC,WAAW,GAAG,CAAC,EAAE,iCAAiC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACrH,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,gCAAgC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IACtH,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,6BAA6B,GAAG,CAAC,MAAM,GAAG,CAAC,CAAA;IACpF,IAAI,GAAG,CAAC,EAAE;QAAE,KAAK,CAAC,IAAI,CAAC,qBAAqB,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAA;IACzD,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,CAAA;IACnC,IAAI,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,iBAAiB,EAAE,K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S,CAAC,KAAK,CAAC,CAAA;QAChC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAM;QACxB,KAAK,MAAM,QAAQ,IAAI,KAAK;YAAE,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;IAC9I,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,GAAG,CAAC,iCAAiC,MAAM,uBAAuB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAC5H,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { FileBranchWrite } from '@openagt/agent-data';
|
|
2
|
+
import { type AnyDiaryLine, type LogsDeps, type RunCard } from '@openagt/skill-logs';
|
|
3
|
+
/**
|
|
4
|
+
* A run in flight is a run record (#1774): the `logs` skill's card on the project's `agent-data`
|
|
5
|
+
* branch, written before the agent is spawned with `status: running` and this tool's own mark
|
|
6
|
+
* under `caller`, and written again when the run ends — same id, same file — with how it went.
|
|
7
|
+
* One file for the run's whole life, and every machine that shares the branch reads the same
|
|
8
|
+
* running cards (a scheduler counts them against its caps). No pid is held anywhere: a restart
|
|
9
|
+
* loses nothing.
|
|
10
|
+
*
|
|
11
|
+
* A running card from another machine is that machine's: only its own sweep, or a person, changes
|
|
12
|
+
* it. A machine that never comes back leaves its card running, on purpose: nothing here guesses that a run it cannot see is dead.
|
|
13
|
+
*/
|
|
14
|
+
/** How far a run takes its work when its agent finishes: a commit, its branch pushed, its pull request, or the request set to merge once its checks pass. */
|
|
15
|
+
export declare const PUBLISH_LEVELS: readonly ['commit', 'branch', 'pr', 'merge'];
|
|
16
|
+
export type Publish = (typeof PUBLISH_LEVELS)[number];
|
|
17
|
+
export declare function isPublish(value: unknown): value is Publish;
|
|
18
|
+
/** This tool's mark on a card, under `caller.runner`. */
|
|
19
|
+
export interface RunnerMark {
|
|
20
|
+
/** The machine that started it. */
|
|
21
|
+
host: string;
|
|
22
|
+
/** The run's process on that machine, while it runs. */
|
|
23
|
+
pid?: number;
|
|
24
|
+
/** The prompt a fresh agent is given once the run ends done with a pull request, the run's id after it (`run --then`). */
|
|
25
|
+
then?: string;
|
|
26
|
+
/** How far the run takes its work when its agent finishes (`run --publish`): a commit, the branch, its pull request, or the request set to merge; absent, only what its prompt asks. */
|
|
27
|
+
publish?: Publish;
|
|
28
|
+
/** The run this one was started for, told when this one ends (`run --parent`). */
|
|
29
|
+
parent?: string;
|
|
30
|
+
/** The branch this run's own branch started from (`run --base`); origin's default branch when absent. */
|
|
31
|
+
base?: string;
|
|
32
|
+
/** The commit this run's own branch was made at: where the run's own work begins. Absent for a run given a branch that existed. */
|
|
33
|
+
baseCommit?: string;
|
|
34
|
+
}
|
|
35
|
+
/** The mark a card carries, or `undefined` for a run this tool did not start. */
|
|
36
|
+
export declare function runnerMark(card: RunCard): RunnerMark | undefined;
|
|
37
|
+
/** What a mark keeps for the run's whole life, a resume included: its follow-up, its publish level, its parent, where it started. */
|
|
38
|
+
export declare function lasting(mark: {
|
|
39
|
+
then?: unknown;
|
|
40
|
+
publish?: unknown;
|
|
41
|
+
parent?: unknown;
|
|
42
|
+
base?: unknown;
|
|
43
|
+
baseCommit?: unknown;
|
|
44
|
+
}): Pick<RunnerMark, 'then' | 'publish' | 'parent' | 'base' | 'baseCommit'>;
|
|
45
|
+
/** The card a run starts with. */
|
|
46
|
+
export declare function markerCard(run: {
|
|
47
|
+
id: string;
|
|
48
|
+
startedAt: string;
|
|
49
|
+
prompt: string;
|
|
50
|
+
driver: string;
|
|
51
|
+
model?: string;
|
|
52
|
+
mark: RunnerMark;
|
|
53
|
+
}): RunCard;
|
|
54
|
+
/**
|
|
55
|
+
* What a reader of the card finds beside `host`, outside this tool's mark: the run's parent, the
|
|
56
|
+
* branch it was started from when it was told one, and the commit its own work begins at, which
|
|
57
|
+
* its changes are measured from.
|
|
58
|
+
*/
|
|
59
|
+
export declare function forReaders(mark: Pick<RunnerMark, 'parent' | 'base' | 'baseCommit'>): {
|
|
60
|
+
parent?: string;
|
|
61
|
+
base?: string;
|
|
62
|
+
baseCommit?: string;
|
|
63
|
+
};
|
|
64
|
+
/** What the reclaim of a run's checkout is told: the commit its branch was made at, when its mark names one. */
|
|
65
|
+
export declare function startOf(card: RunCard): {
|
|
66
|
+
from?: string;
|
|
67
|
+
};
|
|
68
|
+
/** Put the run's card on the branch before its agent exists. The outcome says whether it reached origin. */
|
|
69
|
+
export declare function writeMarker(repo: string, card: RunCard, deps?: LogsDeps): Promise<FileBranchWrite>;
|
|
70
|
+
/** Take a marker back: a scheduler lost a cap to another machine's marker, so this run never starts. */
|
|
71
|
+
export declare function withdrawMarker(repo: string, id: string, deps?: LogsDeps): Promise<FileBranchWrite>;
|
|
72
|
+
/** Record how a run went: its card and its diary, over the marker. */
|
|
73
|
+
export declare function recordRun(repo: string, card: RunCard, diary: readonly AnyDiaryLine[], deps?: LogsDeps): Promise<FileBranchWrite>;
|
|
74
|
+
/**
|
|
75
|
+
* Record a run again without its branch when the reclaim deleted that branch: one that held
|
|
76
|
+
* nothing goes with its checkout, and the record must not name a branch that is gone. Written
|
|
77
|
+
* after the reclaim rather than reclaiming first, so the record never says `running` with no
|
|
78
|
+
* checkout behind it. Nothing is written when the branch stayed.
|
|
79
|
+
*/
|
|
80
|
+
export declare function recordBranchGone(repo: string, card: RunCard, diary: readonly AnyDiaryLine[], deleted: readonly string[] | undefined, deps?: LogsDeps): Promise<FileBranchWrite | undefined>;
|
|
81
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","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