@parcha/agentrun-serve 0.1.0-beta.33 → 0.1.0-beta.34
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 +233 -0
- package/README.md +266 -201
- package/dist/adapters.d.ts +0 -4
- package/dist/adapters.js +11 -15
- package/dist/agent-rows.d.ts +98 -0
- package/dist/agent-rows.js +1 -0
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +60 -25
- package/dist/agents.d.ts +9 -125
- package/dist/agents.js +15 -305
- package/dist/answer-json.d.ts +23 -0
- package/dist/answer-json.js +58 -0
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/bash-read-only.d.ts +22 -0
- package/dist/bash-read-only.js +701 -0
- package/dist/box-settings.d.ts +3 -23
- package/dist/box-settings.js +7 -51
- package/dist/boxes.d.ts +17 -0
- package/dist/boxes.js +27 -20
- package/dist/browser-commands.d.ts +5 -2
- package/dist/browser-commands.js +4 -4
- package/dist/browser-computer.d.ts +5 -0
- package/dist/browser-computer.js +21 -0
- package/dist/browser-cost.d.ts +9 -6
- package/dist/browser-cost.js +92 -50
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -51
- package/dist/browser-person.js +94 -277
- package/dist/cap.d.ts +8 -5
- package/dist/cap.js +12 -5
- package/dist/cli.js +39 -13
- package/dist/closed-pipes.d.ts +2 -0
- package/dist/closed-pipes.js +13 -0
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +2 -0
- package/dist/computer-keys.js +5 -2
- package/dist/computer-setting.d.ts +20 -4
- package/dist/computer-setting.js +25 -5
- package/dist/computers.d.ts +30 -2
- package/dist/computers.js +70 -11
- package/dist/confine.d.ts +120 -0
- package/dist/confine.js +436 -0
- package/dist/console/assets/index-RPHGlXmM.js +540 -0
- package/dist/console/assets/index-opTN5Naq.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/decision-rows.d.ts +1 -1
- package/dist/decision-rows.js +1 -1
- package/dist/docker-daemon.d.ts +31 -0
- package/dist/docker-daemon.js +56 -0
- package/dist/effort-guidance.js +4 -3
- package/dist/environment.d.ts +0 -3
- package/dist/environment.js +3 -5
- package/dist/errors.d.ts +0 -2
- package/dist/errors.js +6 -9
- package/dist/filed-answer.d.ts +32 -0
- package/dist/filed-answer.js +160 -0
- package/dist/files.d.ts +1 -3
- package/dist/files.js +2 -4
- package/dist/github-connection.d.ts +1 -1
- package/dist/graph-view.d.ts +3 -5
- package/dist/graph-view.js +4 -14
- package/dist/handed-values.d.ts +9 -0
- package/dist/handed-values.js +26 -0
- package/dist/harness-install.d.ts +1 -7
- package/dist/harness-install.js +1 -18
- package/dist/harness-opencode/adapter.d.ts +7 -0
- package/dist/harness-opencode/adapter.js +23 -6
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/verify.d.ts +17 -0
- package/dist/harness-opencode/verify.js +30 -10
- package/dist/harness-table.js +6 -1
- package/dist/heard.js +1 -1
- package/dist/held-fd.d.ts +5 -0
- package/dist/held-fd.js +14 -0
- package/dist/host-calls.d.ts +20 -0
- package/dist/host-calls.js +12 -0
- package/dist/host-tools.d.ts +4 -21
- package/dist/host-tools.js +4 -61
- package/dist/host.d.ts +2 -4
- package/dist/host.js +2 -7
- package/dist/import-summary.d.ts +1 -5
- package/dist/import-summary.js +0 -21
- package/dist/import.d.ts +6 -6
- package/dist/import.js +14 -15
- package/dist/key-refusal.d.ts +5 -1
- package/dist/key-refusal.js +19 -4
- package/dist/learn/check.d.ts +6 -2
- package/dist/learn/check.js +83 -29
- package/dist/learn/folder.d.ts +5 -1
- package/dist/learn/folder.js +10 -3
- package/dist/learn/grade.d.ts +14 -0
- package/dist/learn/grade.js +68 -12
- package/dist/learn/index.d.ts +4 -4
- package/dist/learn/index.js +4 -4
- package/dist/learn/reflect.d.ts +31 -2
- package/dist/learn/reflect.js +79 -4
- package/dist/learn/relevance.d.ts +24 -0
- package/dist/learn/relevance.js +91 -0
- package/dist/learn/secrets.d.ts +7 -1
- package/dist/learn/secrets.js +86 -19
- package/dist/learn/skills.d.ts +112 -14
- package/dist/learn/skills.js +556 -52
- package/dist/learned-workflow.d.ts +32 -1
- package/dist/learned-workflow.js +100 -9
- package/dist/learning-routes.d.ts +8 -4
- package/dist/learning-routes.js +23 -9
- package/dist/learning-run.d.ts +9 -26
- package/dist/learning-run.js +22 -32
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +18 -9
- package/dist/learning.d.ts +93 -77
- package/dist/learning.js +176 -304
- package/dist/live/stream.js +1 -1
- package/dist/live/translate.js +12 -2
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +11 -49
- package/dist/mcp-gateway.js +44 -135
- package/dist/mcp-oauth.d.ts +10 -14
- package/dist/mcp-oauth.js +14 -32
- package/dist/mcp-probe.d.ts +0 -7
- package/dist/mcp-probe.js +4 -10
- package/dist/mcp-servers-store.d.ts +6 -6
- package/dist/mcp-servers-store.js +12 -14
- package/dist/mcp-store.js +3 -4
- package/dist/mcp.js +4 -3
- package/dist/model.d.ts +6 -7
- package/dist/model.js +43 -27
- package/dist/monid.d.ts +0 -2
- package/dist/monid.js +3 -6
- package/dist/openapi.d.ts +8 -1
- package/dist/openapi.js +121 -47
- package/dist/page.d.ts +1 -3
- package/dist/page.js +6 -18
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +25 -60
- package/dist/propose.js +83 -39
- package/dist/push-handler.d.ts +1 -1
- package/dist/reflect-range.d.ts +25 -0
- package/dist/reflect-range.js +30 -0
- package/dist/refusal-words.d.ts +5 -1
- package/dist/refusal-words.js +5 -1
- package/dist/rows.d.ts +1 -1
- package/dist/run-cut.d.ts +0 -6
- package/dist/run-cut.js +0 -6
- package/dist/run-db.d.ts +2 -11
- package/dist/run-db.js +2 -37
- package/dist/run-launch.d.ts +19 -2
- package/dist/run-launch.js +13 -5
- package/dist/run-learning-served.d.ts +10 -4
- package/dist/run-learning-served.js +23 -13
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-reads-over-store.js +15 -6
- package/dist/run-secrets.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +15 -4
- package/dist/run-view.d.ts +7 -8
- package/dist/run-view.js +26 -7
- package/dist/runnable.d.ts +18 -10
- package/dist/runnable.js +21 -10
- package/dist/runner/adapter-loop.d.ts +6 -1
- package/dist/runner/adapter-loop.js +423 -53
- package/dist/runner/adapter-run-spec.d.ts +21 -8
- package/dist/runner/adapter-run-spec.js +90 -32
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +12 -2
- package/dist/runner/adapters/pi.js +16 -5
- package/dist/runner/beside.d.ts +30 -3
- package/dist/runner/beside.js +36 -5
- package/dist/runner/claim-secrets.d.ts +10 -1
- package/dist/runner/claim-secrets.js +48 -14
- package/dist/runner/cli-run-spec.d.ts +2 -0
- package/dist/runner/cli-run-spec.js +45 -16
- package/dist/runner/commands.js +1 -1
- package/dist/runner/computer-journal.d.ts +15 -2
- package/dist/runner/computer-journal.js +41 -5
- package/dist/runner/conformance/harness.js +118 -8
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/dispatch.d.ts +8 -1
- package/dist/runner/dispatch.js +81 -7
- package/dist/runner/end-of-run.d.ts +8 -2
- package/dist/runner/end-of-run.js +10 -4
- package/dist/runner/github-app.js +1 -1
- package/dist/runner/harness-loops.d.ts +9 -1
- package/dist/runner/harness-loops.js +15 -2
- package/dist/runner/journal-kinds.d.ts +24 -6
- package/dist/runner/journal-kinds.js +20 -5
- package/dist/runner/journal-reader.d.ts +1 -1
- package/dist/runner/journal-reader.js +2 -2
- package/dist/runner/learning-ask.d.ts +4 -0
- package/dist/runner/learning-ask.js +15 -1
- package/dist/runner/learning-end.d.ts +18 -3
- package/dist/runner/learning-end.js +113 -11
- package/dist/runner/learning-loop.d.ts +5 -0
- package/dist/runner/learning-loop.js +26 -6
- package/dist/runner/main.d.ts +56 -9
- package/dist/runner/main.js +127 -18
- package/dist/runner/mcp-claim.js +1 -2
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +15 -5
- package/dist/runner/memory-claim.d.ts +9 -0
- package/dist/runner/memory-claim.js +25 -0
- package/dist/runner/metrics.d.ts +33 -1
- package/dist/runner/metrics.js +85 -1
- package/dist/runner/model-route.d.ts +13 -0
- package/dist/runner/model-route.js +133 -9
- package/dist/runner/reflect-hook.d.ts +12 -1
- package/dist/runner/reflect-hook.js +33 -3
- package/dist/runner/runner.d.ts +20 -0
- package/dist/runner/runner.js +56 -10
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +3 -3
- package/dist/runner/store-secrets.js +8 -12
- package/dist/runner/text-tools.d.ts +44 -0
- package/dist/runner/text-tools.js +237 -0
- package/dist/runner/workflow-loop.d.ts +6 -0
- package/dist/runner/workflow-loop.js +6 -4
- package/dist/runner/workflow-spec.d.ts +18 -0
- package/dist/runner/workflow-spec.js +63 -17
- package/dist/runs-over-store.d.ts +7 -2
- package/dist/runs-over-store.js +60 -14
- package/dist/seal-key.js +5 -43
- package/dist/sealed-settings-store.d.ts +19 -4
- package/dist/sealed-settings-store.js +9 -9
- package/dist/sealing.d.ts +4 -0
- package/dist/sealing.js +20 -0
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-name.d.ts +9 -0
- package/dist/secret-name.js +15 -0
- package/dist/secret-writes.d.ts +0 -1
- package/dist/secret-writes.js +0 -1
- package/dist/server-fs.d.ts +4 -0
- package/dist/server-fs.js +8 -2
- package/dist/server-lock.d.ts +0 -24
- package/dist/server-lock.js +1 -80
- package/dist/server-secrets-store.d.ts +4 -4
- package/dist/server-secrets-store.js +9 -31
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -36
- package/dist/server.d.ts +16 -38
- package/dist/server.js +145 -106
- package/dist/sign-ins-store.d.ts +34 -36
- package/dist/sign-ins-store.js +27 -38
- package/dist/sign-ins.d.ts +2 -119
- package/dist/sign-ins.js +5 -311
- package/dist/standard-webhooks.d.ts +1 -1
- package/dist/standard-webhooks.js +1 -1
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.d.ts +8 -2
- package/dist/store/agent-body.js +16 -4
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +2 -2
- package/dist/store/open.d.ts +6 -3
- package/dist/store/open.js +2 -2
- package/dist/store/postgres/connection.d.ts +18 -2
- package/dist/store/postgres/connection.js +156 -32
- package/dist/store/postgres/migrate.d.ts +4 -0
- package/dist/store/postgres/migrate.js +9 -2
- package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
- package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
- package/dist/store/postgres/store.d.ts +9 -2
- package/dist/store/postgres/store.js +9 -0
- package/dist/store/schema.js +1 -1
- package/dist/store/seal.js +2 -2
- package/dist/store/sqlite/connection.js +49 -5
- package/dist/store/sqlite/run-patch.d.ts +3 -0
- package/dist/store/sqlite/run-patch.js +3 -0
- package/dist/store/sqlite/store.js +41 -12
- package/dist/store/store.d.ts +35 -6
- package/dist/store/store.js +12 -2
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +22 -4
- package/dist/store-reads/journal.d.ts +9 -6
- package/dist/store-reads/journal.js +93 -17
- package/dist/store-reads/learning.d.ts +26 -8
- package/dist/store-reads/learning.js +12 -4
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-reads/workflow.js +1 -1
- package/dist/store-view.d.ts +5 -1
- package/dist/store-view.js +53 -18
- package/dist/template-eval.d.ts +60 -4
- package/dist/template-eval.js +120 -54
- package/dist/templates.d.ts +24 -10
- package/dist/templates.js +69 -38
- package/dist/timeline/group.d.ts +33 -0
- package/dist/timeline/group.js +77 -0
- package/dist/timeline/index.d.ts +7 -0
- package/dist/timeline/index.js +7 -0
- package/dist/timeline/labels.d.ts +79 -0
- package/dist/timeline/labels.js +150 -0
- package/dist/timeline/origin.d.ts +56 -0
- package/dist/timeline/origin.js +92 -0
- package/dist/timeline/render-text.d.ts +11 -0
- package/dist/timeline/render-text.js +62 -0
- package/dist/timeline/timeline.d.ts +274 -0
- package/dist/timeline/timeline.js +1308 -0
- package/dist/timeline/util.d.ts +17 -0
- package/dist/timeline/util.js +49 -0
- package/dist/tool-gate.d.ts +41 -216
- package/dist/tool-gate.js +79 -540
- package/dist/tool-keys-store.d.ts +11 -12
- package/dist/tool-keys-store.js +24 -31
- package/dist/tool-keys.d.ts +5 -101
- package/dist/tool-keys.js +8 -267
- package/dist/tool-plane.d.ts +14 -42
- package/dist/tool-plane.js +23 -81
- package/dist/tool-settings-store.d.ts +1 -2
- package/dist/tool-settings-store.js +5 -8
- package/dist/tools.d.ts +30 -18
- package/dist/tools.js +97 -107
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-targets.d.ts +13 -1
- package/dist/trigger-targets.js +31 -1
- package/dist/triggers.d.ts +2 -2
- package/dist/triggers.js +3 -3
- package/dist/turn-end.d.ts +1 -1
- package/dist/turn-end.js +1 -1
- package/dist/turns.d.ts +0 -6
- package/dist/turns.js +0 -19
- package/dist/uploads.js +1 -1
- package/dist/usage.d.ts +0 -2
- package/dist/usage.js +0 -2
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +23 -14
- package/dist/webhooks.d.ts +102 -76
- package/dist/webhooks.js +266 -233
- package/dist/workflow-run.d.ts +114 -0
- package/dist/workflow-run.js +144 -0
- package/dist/workspace/beneath.d.ts +19 -0
- package/dist/workspace/beneath.js +106 -0
- package/dist/workspace/computer-deps.d.ts +24 -6
- package/dist/workspace/computer-deps.js +108 -20
- package/dist/workspace/computer-for-claim.d.ts +12 -11
- package/dist/workspace/computer-for-claim.js +76 -15
- package/dist/workspace/computer-hold.d.ts +6 -1
- package/dist/workspace/computer-hold.js +6 -1
- package/dist/workspace/computer-janitor.d.ts +47 -0
- package/dist/workspace/computer-janitor.js +182 -0
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/index.d.ts +3 -2
- package/dist/workspace/index.js +3 -3
- package/dist/workspace/local.d.ts +11 -2
- package/dist/workspace/local.js +161 -43
- package/dist/workspace/resolve-computer.d.ts +50 -10
- package/dist/workspace/resolve-computer.js +46 -11
- package/dist/workspace/run-tools.d.ts +13 -31
- package/dist/workspace/run-tools.js +10 -27
- package/dist/workspace-paths.d.ts +0 -17
- package/dist/workspace-paths.js +1 -41
- package/dist/workspace.d.ts +0 -14
- package/dist/workspace.js +3 -96
- package/package.json +13 -13
- package/templates/README.md +9 -3
- package/templates/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/coding-tools.d.ts +0 -47
- package/dist/coding-tools.js +0 -189
- package/dist/computer-adb.d.ts +0 -12
- package/dist/computer-adb.js +0 -14
- package/dist/console/assets/index-Dn0ngwG9.js +0 -535
- package/dist/console/assets/index-DvW6Aled.css +0 -1
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/mcp-servers.d.ts +0 -269
- package/dist/mcp-servers.js +0 -456
- package/dist/packs.d.ts +0 -71
- package/dist/packs.js +0 -180
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -171
- package/dist/sessions.d.ts +0 -6
- package/dist/sessions.js +0 -109
- package/dist/workspace/computer-serves.d.ts +0 -12
- package/dist/workspace/computer-serves.js +0 -15
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
// once at the run's start. A spec builder gives the adapter loop `endOfRun: learningEndOfRun(launch, deps)`. Each of the
|
|
4
4
|
// hook's reads is the server's own rule, over the store in place of the run's directory:
|
|
5
5
|
// - whether it looks back (learning-run.ts reflectSkip): its cap and its spend so far, read as its view reads them;
|
|
6
|
-
// - its prompt's facts: how many notes its seed held (launch seedNotes)
|
|
7
|
-
// (learning-run.ts draftTools);
|
|
6
|
+
// - its prompt's facts: how many notes its seed held (launch seedNotes), the tools a workflow draft may name
|
|
7
|
+
// (learning-run.ts draftTools), and the learned skill whose job it asks for as a workflow draft (draftForOf);
|
|
8
8
|
// - what the person said in the run and a trigger's input (heard.ts Hearing over its entries, the end-of-run turn's
|
|
9
9
|
// own left out), as learning-run.ts turnOf reads them;
|
|
10
|
+
// - whether the job gave nothing new to look back on (onlyLearnedWorkflows over its timeline): a run whose only tool
|
|
11
|
+
// work was its learned workflows, each answering, is not asked;
|
|
10
12
|
// - the checks: propose.ts proposeRun against the seed it started from, the server's one rule, which keeps the
|
|
11
13
|
// proposal the hook stores beside the run's end (learning_proposals);
|
|
12
14
|
// - what the run must never learn (learning-run.ts refused, the server's serverSecrets as far as the runner reads
|
|
@@ -21,14 +23,19 @@ import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
|
21
23
|
import { tmpdir } from "node:os";
|
|
22
24
|
import { join } from "node:path";
|
|
23
25
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
26
|
+
import { isMessageRow } from "../timeline/index.js";
|
|
24
27
|
import { Hearing } from "../heard.js";
|
|
28
|
+
import { readSnapshot } from "../learn/folder.js";
|
|
29
|
+
import { DRAFT_AFTER_RUNS } from "../learn/reflect.js";
|
|
30
|
+
import { SKILL_NAME } from "../learn/skills.js";
|
|
25
31
|
import { handedValuesOf } from "../handed-values.js";
|
|
26
32
|
import { MIN_SECRET } from "../learn/secrets.js";
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
33
|
+
import { LEARNED_WORKFLOW_TOOL } from "../learned-workflow.js";
|
|
34
|
+
import { LEARNING_LABEL, PROPOSAL } from "../learning.js";
|
|
35
|
+
import { reflects } from "../reflect-range.js";
|
|
29
36
|
import { said, STOPPED } from "../learning-words.js";
|
|
30
37
|
import { proposeRun } from "../propose.js";
|
|
31
|
-
import { learningStartOf } from "../run-launch.js";
|
|
38
|
+
import { learningStartOf, readLaunchBody, seedFailed } from "../run-launch.js";
|
|
32
39
|
import { costOf } from "../run-view.js";
|
|
33
40
|
import { runEntries, runReflect, runTimeline } from "../store-reads/journal.js";
|
|
34
41
|
import { createReflectHook } from "./reflect-hook.js";
|
|
@@ -40,7 +47,8 @@ export function learningEndOfRun(launch, deps) {
|
|
|
40
47
|
if (!start)
|
|
41
48
|
return undefined;
|
|
42
49
|
const env = deps.env ?? process.env;
|
|
43
|
-
|
|
50
|
+
// The grade model the server named at the run's start (its learning start's), none: the agent's own grades it.
|
|
51
|
+
const gradeModel = start.gradeModel;
|
|
44
52
|
const capUsd = launch.maxCostUsd;
|
|
45
53
|
const hookFor = (runId) => createReflectHook({
|
|
46
54
|
// reflectSkip's facts: a run its cap stopped has no room left, and one whose spend is unknown under a cap cannot be
|
|
@@ -49,7 +57,15 @@ export function learningEndOfRun(launch, deps) {
|
|
|
49
57
|
const costUsd = costOf(await runTimeline(deps.store, runId, BACKGROUND_CONTEXT, { settled: false }));
|
|
50
58
|
return { learns: true, costUsd, ...(capUsd !== undefined ? { capUsd, capReached: costUsd !== null && costUsd >= capUsd } : {}) };
|
|
51
59
|
},
|
|
52
|
-
|
|
60
|
+
nothingNew: async (runId) => onlyLearnedWorkflows(await runTimeline(deps.store, runId, BACKGROUND_CONTEXT, { settled: false })),
|
|
61
|
+
// A draft asked for or not never stops the turn: a count that can't be read asks for none.
|
|
62
|
+
promptFacts: async (runId, agentId) => {
|
|
63
|
+
const { tools } = await draftTools(deps, runId);
|
|
64
|
+
const draftFor = await draftForOf(deps, agentId, runId, start.skills ?? []).catch(() => []);
|
|
65
|
+
// With a draft asked for, what each tool its call nodes may run takes and gives, in the server's own words.
|
|
66
|
+
const described = draftFor.length ? await describedOf(tools) : [];
|
|
67
|
+
return { active: start.seedNotes ?? start.given.length, tools, draftFor, described };
|
|
68
|
+
},
|
|
53
69
|
asked: async (runId) => {
|
|
54
70
|
const [entries, reflect] = await Promise.all([runEntries(deps.store, runId, BACKGROUND_CONTEXT), runReflect(deps.store, runId, BACKGROUND_CONTEXT)]);
|
|
55
71
|
const hearing = new Hearing();
|
|
@@ -85,14 +101,100 @@ export function learningEndOfRun(launch, deps) {
|
|
|
85
101
|
...(gradeModel ? { gradeModel } : {}),
|
|
86
102
|
});
|
|
87
103
|
return async (input) => {
|
|
88
|
-
//
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
104
|
+
// No seed, no end-of-run turn (seedFailed): a run that started from no commit of main has nothing to propose against,
|
|
105
|
+
// so it is never asked to look back (no model request). Why, as its start recorded it: a folder that could not be
|
|
106
|
+
// read, or a start that could not be made from it; a start that records none names no reason.
|
|
107
|
+
if (seedFailed(start)) {
|
|
108
|
+
const failed = start.seedFailed;
|
|
109
|
+
const why = failed === "unreadable" ? STOPPED.unreadable : failed === "not_copied" ? STOPPED.notCopied : STOPPED.noSeed;
|
|
110
|
+
return { also: [{ table: "learning_proposals", row: { turn: null, proposal: { state: "dropped", reason: "seed_failed", detail: said.stopped(why) } } }] };
|
|
92
111
|
}
|
|
93
112
|
return hookFor(input.runId)(input);
|
|
94
113
|
};
|
|
95
114
|
}
|
|
115
|
+
/** learned_workflow by every name a harness calls it: its own, and claude-agent's host-tool alias (`mcp__hands__<name>`).
|
|
116
|
+
* A harness that names it another way reads as another tool, so its run is asked as before. */
|
|
117
|
+
const LEARNED_NAMES = new Set([LEARNED_WORKFLOW_TOOL, `mcp__hands__${LEARNED_WORKFLOW_TOOL}`]);
|
|
118
|
+
/** Whether a run's job, by its timeline `rows` (the end-of-run turn's own, labelled LEARNING_LABEL, left out), gave
|
|
119
|
+
* nothing new to look back on: it called tools, every one of them learned_workflow (a workflow's own nested calls are
|
|
120
|
+
* its), each answering; no tool result failed or was refused; no error, approval or wait; and one message, its first,
|
|
121
|
+
* came in. Anything else is asked its end-of-run turn. */
|
|
122
|
+
export function onlyLearnedWorkflows(rows) {
|
|
123
|
+
const own = rows.filter((row) => row.agent_label !== LEARNING_LABEL);
|
|
124
|
+
if (own.some((row) => row.kind === "error" || row.kind === "tool_approval_requested" || row.kind === "waiting"))
|
|
125
|
+
return false;
|
|
126
|
+
if (own.filter(isMessageRow).length !== 1)
|
|
127
|
+
return false;
|
|
128
|
+
const calls = own.filter((row) => row.kind === "tool_use" && !row.parent_tool_use_id);
|
|
129
|
+
if (!calls.length || calls.some((row) => !LEARNED_NAMES.has(row.tool_name ?? "")))
|
|
130
|
+
return false;
|
|
131
|
+
const results = own.filter((row) => row.kind === "tool_result");
|
|
132
|
+
if (results.some((row) => row.tool_status !== "success"))
|
|
133
|
+
return false;
|
|
134
|
+
const answered = new Set(results.filter((row) => !row.parent_tool_use_id).map((row) => row.tool_use_id));
|
|
135
|
+
return calls.every((row) => answered.has(row.tool_use_id));
|
|
136
|
+
}
|
|
137
|
+
/** What each of `tools` takes and gives a workflow's call node, in the server's own words for it (tools.ts ToolEntry's
|
|
138
|
+
* summary): the draft ask's `describe`. */
|
|
139
|
+
async function describedOf(tools) {
|
|
140
|
+
const { toolOf } = await import("../tools.js");
|
|
141
|
+
return tools.flatMap((name) => {
|
|
142
|
+
const does = toolOf(name)?.summary;
|
|
143
|
+
return does ? [{ name, does }] : [];
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/** How many of an agent's latest runs draftForOf reads at most: a skill offered to fewer than DRAFT_AFTER_RUNS of them is
|
|
147
|
+
* no repeated job. */
|
|
148
|
+
export const DRAFT_SCAN_RUNS = 200;
|
|
149
|
+
/** The learned skill whose job the end-of-run turn asks for as a workflow draft: of the skills run `runId` was offered
|
|
150
|
+
* (its launch's learning start), the first in the seed's order (the one changed last first) offered to DRAFT_AFTER_RUNS
|
|
151
|
+
* or more runs of agent `agentId` started before it (each run's launch says what it was offered; its latest
|
|
152
|
+
* DRAFT_SCAN_RUNS runs are read newest first, those after `runId` in that order counted, only until every skill has its
|
|
153
|
+
* count), with no learned workflow of its name on the agent's main, active or waiting for
|
|
154
|
+
* its owner's OK (the folder's snapshot). One at most: a turn keeps one workflow draft. None when no skill qualifies, or
|
|
155
|
+
* when the folder can't be read: a read that fails asks for nothing, never a draft that may be there already. */
|
|
156
|
+
export async function draftForOf(deps, agentId, runId, offered) {
|
|
157
|
+
// Only a skill's name reaches the prompt (reflectPrompt refuses anything else).
|
|
158
|
+
const served = new Map(offered.filter((name) => SKILL_NAME.test(name)).map((name) => [name, 0]));
|
|
159
|
+
if (!served.size)
|
|
160
|
+
return [];
|
|
161
|
+
// The list is newest first: only the runs after the ending one in it started before it, and count. A run started
|
|
162
|
+
// later (a long job's newer runs) never does, and an ending run past the latest DRAFT_SCAN_RUNS + 1 counts none.
|
|
163
|
+
let earlier = false;
|
|
164
|
+
for (const run of await deps.store.runs.list({ agentId, limit: DRAFT_SCAN_RUNS + 1 })) {
|
|
165
|
+
if (run.id === runId) {
|
|
166
|
+
earlier = true;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (!earlier || run.agentId !== agentId)
|
|
170
|
+
continue;
|
|
171
|
+
const row = await deps.store.runs.launch(run.id).catch(() => undefined);
|
|
172
|
+
const launch = row ? readLaunchBody(row.body) : undefined;
|
|
173
|
+
for (const name of (launch && learningStartOf(launch)?.skills) ?? [])
|
|
174
|
+
if (served.has(name))
|
|
175
|
+
served.set(name, served.get(name) + 1);
|
|
176
|
+
// Enough runs read once every skill has served its count.
|
|
177
|
+
if ([...served.values()].every((count) => count >= DRAFT_AFTER_RUNS))
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
const due = [...served].filter(([, count]) => count >= DRAFT_AFTER_RUNS);
|
|
181
|
+
if (!due.length)
|
|
182
|
+
return [];
|
|
183
|
+
let drafted;
|
|
184
|
+
const folder = deps.learningFolder(agentId);
|
|
185
|
+
try {
|
|
186
|
+
const snapshot = await readSnapshot(folder.workspace);
|
|
187
|
+
drafted = new Set((snapshot?.workflows ?? []).filter(({ status }) => status === "active" || status === "pending").map(({ name }) => name));
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return [];
|
|
191
|
+
}
|
|
192
|
+
finally {
|
|
193
|
+
await folder.end().catch(() => undefined);
|
|
194
|
+
}
|
|
195
|
+
const open = due.find(([name]) => !drafted.has(name));
|
|
196
|
+
return open ? [open[0]] : [];
|
|
197
|
+
}
|
|
96
198
|
/** The tools a workflow draft may name (learning-run.ts draftTools): the revision's own, as its run's gate reads them
|
|
97
199
|
* with the server's settings (from the store) and the agent's; none for a workflow revision. */
|
|
98
200
|
async function draftTools(deps, runId) {
|
|
@@ -12,6 +12,11 @@ export declare const UNAVAILABLE_BACKOFF_MS: readonly [30000, 120000, 600000, 18
|
|
|
12
12
|
export interface KeptProposal {
|
|
13
13
|
readonly notes: readonly NoteText[];
|
|
14
14
|
readonly files?: readonly NoteText[];
|
|
15
|
+
/** Each kept draft's dry run, by its workflow.json's path (learn/skills.ts draftDryRun), which the grader is told. */
|
|
16
|
+
readonly dryRuns?: Readonly<Record<string, {
|
|
17
|
+
readonly status: string;
|
|
18
|
+
readonly detail?: string;
|
|
19
|
+
}>>;
|
|
15
20
|
readonly asked?: readonly string[];
|
|
16
21
|
readonly triggered?: readonly {
|
|
17
22
|
readonly source: string;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// merge's call merges once.
|
|
14
14
|
import { BACKGROUND_CONTEXT, withAbortSignal } from "@earendil-works/chord/context";
|
|
15
15
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
16
|
-
import { gradedItems, gradePrompt, parseVerdict, UNREADABLE_REASON } from "../learn/grade.js";
|
|
16
|
+
import { CONTRADICTED_REASON, CONTRADICTED_TWICE_REASON, CONTRADICTION_ASK, gradedItems, gradePrompt, parseVerdict, UNREADABLE_REASON } from "../learn/grade.js";
|
|
17
17
|
import { mergedNote, parseNoteFile } from "../learn/notes.js";
|
|
18
18
|
import { learnedPlace } from "../learn/skills.js";
|
|
19
19
|
import { notKept, said, STOPPED } from "../learning-words.js";
|
|
@@ -101,16 +101,23 @@ export function createLearningLoop(learning) {
|
|
|
101
101
|
const context = withAbortSignal(deps.signal, BACKGROUND_CONTEXT);
|
|
102
102
|
const journal = deps.journal(claim);
|
|
103
103
|
let rooted = false;
|
|
104
|
+
/** What the grade spent, as the run's learning end reads it (store-reads/learning.ts runLearningEnd): the graded
|
|
105
|
+
* entry's, a failed or cut grade's (null: unknown), else nothing graded, 0. Kept as the learning run's cost when it
|
|
106
|
+
* ends ended, failed or stopped, so what learning spent reads from the run rows alone (store learning.spend): a
|
|
107
|
+
* stop seen after a paid grade never hides it. */
|
|
108
|
+
let spend = 0;
|
|
104
109
|
/** One entry on the root, committed; `end` stages the run's state with it (keyed to this entry, its effect), and
|
|
105
|
-
* `take` the stop row it applies. */
|
|
110
|
+
* `take` the stop row it applies. An end that ends, fails or stops the run keeps what the grade spent as its cost. */
|
|
106
111
|
const append = async (kind, data, end, take) => {
|
|
107
112
|
const writes = [];
|
|
113
|
+
if (kind === KINDS.learningDropped && data !== null && typeof data === "object" && "usd" in data)
|
|
114
|
+
spend = data.usd ?? null;
|
|
108
115
|
if (!rooted && !(await journal.conversation(ROOT, context)))
|
|
109
116
|
writes.push({ type: "conversation", value: { id: ROOT } });
|
|
110
117
|
const id = await journal.mintId();
|
|
111
118
|
writes.push({ type: "entry", value: { id, conversationId: ROOT, kind, data } });
|
|
112
119
|
if (end)
|
|
113
|
-
journal.stage({ run: { state: end }, effect: id, ...(take !== undefined ? { take: [{ command: take, effect: id }] } : {}) });
|
|
120
|
+
journal.stage({ run: { state: end, ...(end === "parked" ? {} : { costUsd: spend }) }, effect: id, ...(take !== undefined ? { take: [{ command: take, effect: id }] } : {}) });
|
|
114
121
|
const result = await journal.commit([writes], () => { }, context);
|
|
115
122
|
if (result.stored === 0)
|
|
116
123
|
throw result.refused;
|
|
@@ -152,6 +159,8 @@ export function createLearningLoop(learning) {
|
|
|
152
159
|
const unavailable = entries.filter((entry) => entry.kind === KINDS.learningUnavailable).length;
|
|
153
160
|
// The grade: once. A verdict already in the journal is the one the merge goes on.
|
|
154
161
|
let graded = entries.find((entry) => entry.kind === KINDS.learningGraded)?.data;
|
|
162
|
+
if (graded)
|
|
163
|
+
spend = graded.usd;
|
|
155
164
|
if (!graded) {
|
|
156
165
|
const main = await learning.readMain(ws, proposal);
|
|
157
166
|
if ("problems" in main) {
|
|
@@ -161,17 +170,18 @@ export function createLearningLoop(learning) {
|
|
|
161
170
|
const items = gradedItems(proposal.notes, (proposal.files ?? []));
|
|
162
171
|
const prompt = gradePrompt({
|
|
163
172
|
run: source.runId, ...(source.instructions ? { instructions: source.instructions } : {}), active: main.active, superseded: main.superseded, proposed: proposal.notes,
|
|
164
|
-
...(proposal.files?.length ? { files: proposal.files } : {}), ...(proposal.asked ? { asked: proposal.asked } : {}), ...(proposal.triggered ? { triggered: proposal.triggered } : {}),
|
|
173
|
+
...(proposal.files?.length ? { files: proposal.files } : {}), ...(proposal.dryRuns ? { dryRuns: proposal.dryRuns } : {}), ...(proposal.asked ? { asked: proposal.asked } : {}), ...(proposal.triggered ? { triggered: proposal.triggered } : {}),
|
|
165
174
|
});
|
|
166
175
|
// What the grade spends, as the server's grade counted it (grade.ts counter): each ask's dollars and tokens
|
|
167
176
|
// added, either unknown (null) once any ask's is, and an ask that fails spent what nobody knows.
|
|
168
177
|
let usd = 0;
|
|
169
178
|
let tokens = { input: 0, cache_read: 0, cache_write: 0, output: 0 };
|
|
170
|
-
|
|
179
|
+
// `again`: what the grade is told after its last answer, below the same prompt.
|
|
180
|
+
const ask = async (again) => {
|
|
171
181
|
const timer = AbortSignal.timeout(GRADE_TIMEOUT_MS);
|
|
172
182
|
let answer;
|
|
173
183
|
try {
|
|
174
|
-
answer = await learning.ask({ prompt, maxTokens: GRADE_MAX_TOKENS }, AbortSignal.any([deps.signal, timer]), { journal: () => deps.journal(claim), flush: () => deps.flush() });
|
|
184
|
+
answer = await learning.ask({ prompt: again ? `${prompt}\n\n${again}` : prompt, maxTokens: GRADE_MAX_TOKENS }, AbortSignal.any([deps.signal, timer]), { journal: () => deps.journal(claim), flush: () => deps.flush() });
|
|
175
185
|
}
|
|
176
186
|
catch (error) {
|
|
177
187
|
usd = null;
|
|
@@ -189,8 +199,17 @@ export function createLearningLoop(learning) {
|
|
|
189
199
|
// An answer the host cannot read is asked once more, as the server's grade did.
|
|
190
200
|
if (verdict.reason === UNREADABLE_REASON && !verdict.items.length)
|
|
191
201
|
verdict = parseVerdict(await ask(), items);
|
|
202
|
+
// One that kept every item and said no merge contradicts itself: asked once more, the contradiction named. A
|
|
203
|
+
// second contradiction stands as no merge, said in the host's words as twice (learning-words.ts notKept); a
|
|
204
|
+
// contradiction after an unreadable answer is one, and is said so.
|
|
205
|
+
else if (verdict.reason === CONTRADICTED_REASON) {
|
|
206
|
+
const again = parseVerdict(await ask(CONTRADICTION_ASK), items);
|
|
207
|
+
verdict = again.reason === CONTRADICTED_REASON ? { ...again, reason: CONTRADICTED_TWICE_REASON } : again;
|
|
208
|
+
}
|
|
192
209
|
}
|
|
193
210
|
catch (error) {
|
|
211
|
+
// What the asks spent: a cut one's unknown (null), kept on a stopped run's row as on a dropped one's.
|
|
212
|
+
spend = usd;
|
|
194
213
|
const end = await halted();
|
|
195
214
|
if (end)
|
|
196
215
|
return end;
|
|
@@ -199,6 +218,7 @@ export function createLearningLoop(learning) {
|
|
|
199
218
|
return { state: "ended" };
|
|
200
219
|
}
|
|
201
220
|
graded = { source: source.runId, verdict, usd, tokens, graded: main.graded };
|
|
221
|
+
spend = usd;
|
|
202
222
|
await append(KINDS.learningGraded, graded);
|
|
203
223
|
// The verdict is durable before the merge, its side effect.
|
|
204
224
|
await deps.flush();
|
package/dist/runner/main.d.ts
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { type Store } from "../store/index.js";
|
|
2
|
+
import { type ComputerDeps } from "../workspace/computer-deps.js";
|
|
2
3
|
import type { LoopFactory } from "./loop-contract.js";
|
|
3
|
-
import { type Runner, type RunnerEvent } from "./runner.js";
|
|
4
|
+
import { type Runner, type RunnerEvent, type RunnerMemory } from "./runner.js";
|
|
4
5
|
export { RUNNER_RENEW_EVERY_MS } from "./runner.js";
|
|
5
6
|
export interface RunnerProcessOptions {
|
|
6
7
|
/** The data directory (--data): the store is the store module's file in it; the runner never names it. */
|
|
7
8
|
dataDir: string;
|
|
8
9
|
/** Most runs held at once (--loops). */
|
|
9
10
|
loops?: number;
|
|
11
|
+
/** How long close() lets each busy run finish its turn (--drain-timeout; RunnerOptions.drainMs). Default 0. */
|
|
12
|
+
drainMs?: number;
|
|
13
|
+
/** Its memory budget and its runs' weights (RunnerOptions.memory). Default: this host's memory, each run weighed by its
|
|
14
|
+
* harness (memory-claim.ts runnerMemory). */
|
|
15
|
+
memory?: RunnerMemory;
|
|
10
16
|
/** This runner's name in the runs it claims, its lines and its heartbeat. Default runner.ts runnerName(). */
|
|
11
17
|
name?: string;
|
|
12
|
-
/** Each claimed run's loop; default the runner's dispatch over the store (runnerLoop). */
|
|
13
|
-
createLoop?: LoopFactory | ((store: Store, sealKey: Buffer) => LoopFactory);
|
|
18
|
+
/** Each claimed run's loop; default the runner's dispatch over the store (runnerLoop), with the computers it composed. */
|
|
19
|
+
createLoop?: LoopFactory | ((store: Store, sealKey: Buffer) => LoopFactory | RunnerParts);
|
|
20
|
+
/** Run the computer janitor (workspace/computer-janitor.ts) over the computers createLoop composed: at the start, then
|
|
21
|
+
* on its interval. Only the runner subcommand asks for it; a test that does not ask runs none. */
|
|
22
|
+
janitor?: boolean;
|
|
14
23
|
onEvent?: (event: RunnerEvent) => void;
|
|
15
24
|
/** For tests: the clock the heartbeat is written by. Default Date.now. */
|
|
16
25
|
now?: () => number;
|
|
@@ -59,7 +68,13 @@ export declare function besideRunEnv(env: NodeJS.ProcessEnv, switches: NodeJS.Pr
|
|
|
59
68
|
* its launch (harness-loops.ts resolveRunnerLoop), with the data directory, the run environment (runEnv), the store's
|
|
60
69
|
* journal, the seal key and the model route. `booted`: the seal key startRunnerProcess booted against the store (else
|
|
61
70
|
* this process's, as it was handed or booted). Refused in words with no seal key. */
|
|
62
|
-
export declare function runnerLoop(store: Store, dataDir: string, env?: NodeJS.ProcessEnv, booted?: Buffer):
|
|
71
|
+
export declare function runnerLoop(store: Store, dataDir: string, env?: NodeJS.ProcessEnv, booted?: Buffer): RunnerParts;
|
|
72
|
+
/** A runner's loop factory with the run's computers it composed and the runs' environment: what the janitor sweeps with. */
|
|
73
|
+
export type RunnerParts = {
|
|
74
|
+
readonly createLoop: LoopFactory;
|
|
75
|
+
readonly computers: ComputerDeps;
|
|
76
|
+
readonly env: NodeJS.ProcessEnv;
|
|
77
|
+
};
|
|
63
78
|
/** Where runner `name` writes its heartbeat in `dataDir`. */
|
|
64
79
|
export declare const heartbeatFile: (dataDir: string, name: string) => string;
|
|
65
80
|
/** Whether runner `name`'s heartbeat in `dataDir` is fresh: younger than twice the renew interval. */
|
|
@@ -76,13 +91,33 @@ export declare function checkRunner(options: {
|
|
|
76
91
|
/** Opens the store as a runner and starts claiming runs. */
|
|
77
92
|
export declare function startRunnerProcess(options: RunnerProcessOptions): Promise<RunnerProcess>;
|
|
78
93
|
/** Marks `make` as a function of the store (startRunnerProcess gives it the store it opens). */
|
|
79
|
-
export declare function ofStore(make: (store: Store, sealKey: Buffer) =>
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
94
|
+
export declare function ofStore<Made extends LoopFactory | RunnerParts>(make: (store: Store, sealKey: Buffer) => Made): (store: Store, sealKey: Buffer) => Made;
|
|
95
|
+
/** How long a runner process lets each busy run finish its turn on SIGTERM, unless --drain-timeout or
|
|
96
|
+
* AGENTRUN_DRAIN_TIMEOUT says: the image's server drain (its CMD's --drain-timeout 6s), so a runner beside a --no-runner
|
|
97
|
+
* server drains as the server's own runner would.
|
|
98
|
+
* BOUND: this drain plus the stuck-loop stop after it (runner.ts runnerCloseBoundMs: the claim's lease less its margin,
|
|
99
|
+
* 30 s - 5 s = 25 s) is 6 + 25 = 31 s, inside deploy/compose.yaml's 35 s stop_grace_period for its runners
|
|
100
|
+
* (runner-beside-flags.test.mjs pins it). Raise this default only with that grace. */
|
|
101
|
+
export declare const RUNNER_DRAIN_TIMEOUT = "6s";
|
|
102
|
+
/** The environment's drain for a runner process when --drain-timeout gives none. */
|
|
103
|
+
export declare const RUNNER_DRAIN_ENV = "AGENTRUN_DRAIN_TIMEOUT";
|
|
104
|
+
/** What a runner process holds, from its arguments and `env`: --loops, else the server's --max-runs default
|
|
105
|
+
* (AGENTRUN_MAX_RUNS, else as many pi runs as this host's memory holds; maxRunsOf); --drain-timeout, else
|
|
106
|
+
* AGENTRUN_DRAIN_TIMEOUT, else RUNNER_DRAIN_TIMEOUT. A bad AGENTRUN_MAX_RUNS or AGENTRUN_DRAIN_TIMEOUT is RunnerRefused. */
|
|
107
|
+
export declare function runnerHolds(args: {
|
|
108
|
+
loops?: number;
|
|
109
|
+
drainMs?: number;
|
|
110
|
+
}, env: NodeJS.ProcessEnv): {
|
|
111
|
+
loops: number;
|
|
112
|
+
drainMs: number;
|
|
113
|
+
};
|
|
114
|
+
/** The runner process's arguments: `--data D [--loops N] [--drain-timeout D] [--name N]`, or `--check --data D [--name
|
|
115
|
+
* N]`. Each option with a value is also taken as `--option=value` (the bin hands a data directory that starts with "-"
|
|
116
|
+
* so, never read as an option); an empty one is refused like a missing one. */
|
|
83
117
|
export declare function runnerArgs(argv: readonly string[]): {
|
|
84
118
|
dataDir: string;
|
|
85
119
|
loops?: number;
|
|
120
|
+
drainMs?: number;
|
|
86
121
|
name?: string;
|
|
87
122
|
check?: true;
|
|
88
123
|
};
|
|
@@ -90,7 +125,19 @@ export declare function runnerArgs(argv: readonly string[]): {
|
|
|
90
125
|
* says the runner is ready (on a pipe, written at once) may bring a SIGTERM back before the next statement runs, and one
|
|
91
126
|
* that came before the handlers would end the process unclosed. */
|
|
92
127
|
export declare function runUntilSignalled(process: RunnerProcess, signals?: readonly NodeJS.Signals[], ready?: () => void): Promise<void>;
|
|
128
|
+
/** The runner process's last resort (runnerMain installs it for unhandledRejection and uncaughtException): says what
|
|
129
|
+
* went wrong, in the runner's name with its stack, then exits 1 at once, closing nothing. A runner that went on after
|
|
130
|
+
* an error nothing handled could keep renewing the claim of a run whose loop is dead, and that run would hang claimed
|
|
131
|
+
* by a live runner. Exiting lets the claim lapse: another runner (or this one, started again) takes the run back at the
|
|
132
|
+
* next epoch, and the fence refuses the dead loop's late writes. The line is written to stderr synchronously
|
|
133
|
+
* (writeSync), so a pipe's slow reader still gets the whole stack before the exit. Exported for its test. */
|
|
134
|
+
export declare function lastResort(name: string, write?: (line: string) => void, exit?: (code: number) => void): (reason: unknown) => void;
|
|
93
135
|
/** `agentrun-serve runner ...`: the exit code. 2: bad arguments; 3: a store schema this runner does not know (or none
|
|
94
136
|
* set up yet); 1: anything else; 0: closed on a signal, or --check found a fresh heartbeat. AGENTRUN_RUNNER_NAME names
|
|
95
137
|
* it when --name does not. */
|
|
96
|
-
export declare function runnerMain(argv: readonly string[], env?: NodeJS.ProcessEnv): Promise<number>;
|
|
138
|
+
export declare function runnerMain(argv: readonly string[], env?: NodeJS.ProcessEnv, hooks?: RunnerMainHooks): Promise<number>;
|
|
139
|
+
/** A test's hooks into runnerMain: `started`, awaited once the runner has started claiming and before its stop handlers
|
|
140
|
+
* take over from the ones its start listened on (the window a stop must not fall through). */
|
|
141
|
+
export type RunnerMainHooks = {
|
|
142
|
+
readonly started?: (process: RunnerProcess) => void | Promise<void>;
|
|
143
|
+
};
|