@parcha/agentrun-serve 0.1.0-beta.44 → 0.1.0-beta.45
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 +131 -5
- package/README.md +371 -300
- package/dist/acp-package.d.ts +28 -0
- package/dist/acp-package.js +23 -0
- package/dist/adapter-facts.d.ts +8 -1
- package/dist/adapter-facts.js +9 -1
- package/dist/adapters.d.ts +5 -0
- package/dist/adapters.js +36 -3
- package/dist/agent-delete.d.ts +50 -0
- package/dist/agent-delete.js +125 -0
- package/dist/agents-store.d.ts +9 -3
- package/dist/agents-store.js +22 -8
- package/dist/agents.d.ts +5 -1
- package/dist/agents.js +8 -4
- package/dist/api-only.d.ts +8 -3
- package/dist/api-only.js +10 -4
- package/dist/archil-routes.d.ts +5 -1
- package/dist/archil-routes.js +57 -2
- package/dist/browser-wait-ended.d.ts +2 -0
- package/dist/browser-wait-ended.js +2 -0
- package/dist/calendar/ics-faux.d.ts +3 -1
- package/dist/calendar/ics-faux.js +12 -2
- package/dist/calendar/tools.js +5 -2
- package/dist/chatgpt-plan.js +3 -1
- package/dist/claude-login.d.ts +135 -0
- package/dist/claude-login.js +244 -0
- package/dist/cli.js +52 -16
- package/dist/composio-preset.js +69 -7
- package/dist/composio-triggers.d.ts +14 -0
- package/dist/composio-triggers.js +79 -15
- package/dist/computer-attach.d.ts +40 -5
- package/dist/computer-attach.js +130 -15
- package/dist/computer-keys.d.ts +3 -0
- package/dist/computer-keys.js +7 -1
- package/dist/computer-live.js +3 -2
- package/dist/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
- package/dist/console/assets/index-DaFsZuzQ.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/dial-relay.d.ts +29 -0
- package/dist/dial-relay.js +94 -0
- package/dist/email/tools.js +10 -5
- package/dist/env-proxy.d.ts +2 -0
- package/dist/env-proxy.js +35 -0
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +7 -4
- package/dist/faux-computers.d.ts +8 -2
- package/dist/faux-computers.js +83 -6
- package/dist/harness-archive.d.ts +67 -0
- package/dist/harness-archive.js +177 -0
- package/dist/harness-goose.d.ts +34 -0
- package/dist/harness-goose.js +87 -0
- package/dist/harness-install.d.ts +21 -0
- package/dist/harness-install.js +24 -11
- package/dist/harness-opencode/adapter.js +1 -1
- package/dist/harness-table.d.ts +9 -1
- package/dist/harness-table.js +20 -3
- package/dist/harness.d.ts +1 -2
- package/dist/harness.js +3 -4
- package/dist/host.js +2 -1
- package/dist/key-check.js +3 -0
- package/dist/learn/audit.d.ts +6 -6
- package/dist/learn/audit.js +3 -7
- package/dist/learn/check.d.ts +23 -89
- package/dist/learn/check.js +57 -335
- package/dist/learn/commit.d.ts +63 -90
- package/dist/learn/commit.js +124 -316
- package/dist/learn/compile.d.ts +53 -50
- package/dist/learn/compile.js +87 -102
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +5 -5
- package/dist/learn/delete.js +8 -10
- package/dist/learn/folder.d.ts +35 -47
- package/dist/learn/folder.js +118 -134
- package/dist/learn/index.d.ts +3 -5
- package/dist/learn/index.js +6 -9
- package/dist/learn/learning.sh +45 -15
- package/dist/learn/promote.d.ts +13 -1
- package/dist/learn/promote.js +9 -0
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
- package/dist/learn/{skills.js → workflow-draft.js} +48 -58
- package/dist/learn/workflow-nodes.js +1 -1
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +38 -24
- package/dist/learning-cost.js +41 -24
- package/dist/learning-routes.d.ts +91 -170
- package/dist/learning-routes.js +183 -421
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +4 -4
- package/dist/learning-setting.js +6 -6
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +61 -392
- package/dist/learning.js +101 -651
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +1 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +4 -4
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +4 -0
- package/dist/model.js +26 -9
- package/dist/native/binding.js +1 -1
- package/dist/native/connection.js +1 -1
- package/dist/native/discovery.js +1 -1
- package/dist/native/instructions.d.ts +3 -0
- package/dist/native/instructions.js +5 -3
- package/dist/native/remote-worker-bridge.js +9 -43
- package/dist/native/remote.d.ts +8 -15
- package/dist/native/remote.js +3 -3
- package/dist/native/schema.js +1 -1
- package/dist/native/types.d.ts +2 -2
- package/dist/openapi.js +268 -316
- package/dist/paid-calls.d.ts +8 -0
- package/dist/paid-calls.js +20 -0
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +28 -11
- package/dist/print.d.ts +27 -0
- package/dist/print.js +21 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +15 -1
- package/dist/reflect-range.js +2 -3
- package/dist/run-launch.d.ts +14 -28
- package/dist/run-launch.js +9 -12
- package/dist/run-learning-served.d.ts +15 -89
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.js +1 -1
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-trace.d.ts +97 -0
- package/dist/run-trace.js +253 -0
- package/dist/run-view.d.ts +15 -0
- package/dist/run-view.js +9 -0
- package/dist/runnable.js +2 -1
- package/dist/runner/adapter-loop.d.ts +8 -6
- package/dist/runner/adapter-loop.js +16 -12
- package/dist/runner/adapter-run-spec.d.ts +16 -4
- package/dist/runner/adapter-run-spec.js +64 -58
- package/dist/runner/adapters/index.js +22 -0
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +1 -1
- package/dist/runner/audit.js +16 -8
- package/dist/runner/beside.d.ts +6 -2
- package/dist/runner/beside.js +38 -9
- package/dist/runner/claim-secrets.d.ts +18 -2
- package/dist/runner/claim-secrets.js +42 -18
- package/dist/runner/cli-run-spec.js +55 -51
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +16 -5
- package/dist/runner/dispatch.d.ts +2 -2
- package/dist/runner/end-of-run.d.ts +6 -14
- package/dist/runner/end-of-run.js +8 -33
- package/dist/runner/feedback-round.d.ts +2 -2
- package/dist/runner/feedback-round.js +7 -7
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +11 -59
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +2 -3
- package/dist/runner/journal-kinds.js +2 -3
- package/dist/runner/learned-first.d.ts +40 -0
- package/dist/runner/learned-first.js +32 -0
- package/dist/runner/learning-end.d.ts +77 -69
- package/dist/runner/learning-end.js +250 -303
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +2 -3
- package/dist/runner/main.d.ts +17 -9
- package/dist/runner/main.js +63 -20
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +10 -5
- package/dist/runner/memory-claim.js +12 -6
- package/dist/runner/model-route.d.ts +7 -4
- package/dist/runner/model-route.js +22 -10
- package/dist/runner/native-loop.d.ts +0 -7
- package/dist/runner/native-loop.js +9 -101
- package/dist/runner/promotion.d.ts +8 -6
- package/dist/runner/promotion.js +19 -12
- package/dist/runner/reflect-hook.d.ts +64 -95
- package/dist/runner/reflect-hook.js +112 -225
- package/dist/runner/run-channel.d.ts +43 -0
- package/dist/runner/run-channel.js +467 -0
- package/dist/runner/run-child-host.d.ts +169 -0
- package/dist/runner/run-child-host.js +1222 -0
- package/dist/runner/run-child.d.ts +1 -0
- package/dist/runner/run-child.js +254 -0
- package/dist/runner/run-errors.d.ts +2 -0
- package/dist/runner/run-errors.js +20 -0
- package/dist/runner/runner.js +1 -5
- package/dist/runner/sdk-ask.d.ts +78 -0
- package/dist/runner/sdk-ask.js +158 -0
- package/dist/runner/sdk-loop.d.ts +2 -4
- package/dist/runner/sdk-loop.js +29 -49
- package/dist/runner/store-secrets.d.ts +5 -3
- package/dist/runner/store-secrets.js +5 -1
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +7 -2
- package/dist/runs-over-store.d.ts +16 -28
- package/dist/runs-over-store.js +31 -38
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/seal-key.d.ts +5 -0
- package/dist/seal-key.js +7 -0
- package/dist/secrets.d.ts +3 -0
- package/dist/secrets.js +16 -3
- package/dist/server.d.ts +55 -33
- package/dist/server.js +685 -320
- package/dist/sign-ins-store.d.ts +8 -0
- package/dist/sign-ins-store.js +36 -1
- package/dist/skills.js +1 -1
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +3 -0
- package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
- package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
- package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
- package/dist/store/schema.d.ts +53 -4
- package/dist/store/schema.js +137 -6
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.js +246 -63
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +193 -36
- package/dist/store/store.js +25 -3
- package/dist/store-reads/learning.d.ts +102 -204
- package/dist/store-reads/learning.js +159 -321
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +29 -1
- package/dist/store-view.js +97 -31
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +2 -1
- package/dist/templates.js +6 -3
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -1
- package/dist/timeline/timeline.js +16 -0
- package/dist/tool-gate.d.ts +0 -7
- package/dist/tool-gate.js +1 -15
- package/dist/tool-keys-store.d.ts +1 -1
- package/dist/tool-keys.d.ts +6 -4
- package/dist/tool-keys.js +12 -6
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +11 -4
- package/dist/triggers.d.ts +60 -5
- package/dist/triggers.js +123 -18
- package/dist/validate.js +1 -1
- package/dist/webhooks.d.ts +4 -1
- package/dist/webhooks.js +11 -4
- package/dist/workspace/agent-computer.d.ts +2 -0
- package/dist/workspace/agent-computer.js +2 -0
- package/dist/workspace/archil-claim.d.ts +7 -0
- package/dist/workspace/archil-claim.js +29 -0
- package/dist/workspace/archil.d.ts +9 -1
- package/dist/workspace/archil.js +165 -3
- package/dist/workspace/attach.d.ts +3 -1
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/attached-computers.d.ts +16 -5
- package/dist/workspace/attached-computers.js +25 -9
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +7 -3
- package/dist/workspace/computer-for-claim.js +119 -22
- package/dist/workspace/computer-hold.js +2 -1
- package/dist/workspace/computer-kept.d.ts +11 -1
- package/dist/workspace/computer-kept.js +24 -3
- package/dist/workspace/resolve-computer.d.ts +33 -19
- package/dist/workspace/resolve-computer.js +172 -64
- package/dist/workspace/revision-skills.d.ts +1 -2
- package/dist/workspace/revision-skills.js +3 -4
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +5 -0
- package/dist/workspace/synced-folder.d.ts +85 -0
- package/dist/workspace/synced-folder.js +230 -0
- package/dist/workspace/workspace.d.ts +4 -0
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/templates/README.md +7 -7
- package/templates/inbound-lead/agent.md +3 -3
- package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
- package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
- package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
- package/templates/inbound-lead/lead.schema.json +6 -5
- package/templates/inbound-lead/rules/RUBRIC.md +4 -4
- package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
- package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
- package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
- package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
- package/templates/release-notes/evals/learned-style/case.yaml +4 -4
- package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
- package/templates/release-notes/evals/learned-style/prompt.md +1 -1
- package/dist/console/assets/index-BUktRvS-.css +0 -1
- package/dist/console/assets/index-nB9kTfIN.js +0 -711
- package/dist/learn/grade.d.ts +0 -138
- package/dist/learn/grade.js +0 -682
- package/dist/learn/notes.d.ts +0 -81
- package/dist/learn/notes.js +0 -178
- package/dist/learn/reflect.d.ts +0 -77
- package/dist/learn/reflect.js +0 -228
- package/dist/learn/relevance.d.ts +0 -24
- package/dist/learn/relevance.js +0 -91
- package/dist/learn/seed-check.d.ts +0 -74
- package/dist/learn/seed-check.js +0 -103
- package/dist/learning-batch.d.ts +0 -291
- package/dist/learning-batch.js +0 -600
- package/dist/learning-evals.d.ts +0 -35
- package/dist/learning-evals.js +0 -99
- package/dist/native/context.d.ts +0 -6
- package/dist/native/context.js +0 -22
- package/dist/propose.d.ts +0 -52
- package/dist/propose.js +0 -224
- package/dist/runner/learning-ask.d.ts +0 -47
- package/dist/runner/learning-ask.js +0 -128
- package/dist/runner/learning-dispatch.d.ts +0 -45
- package/dist/runner/learning-dispatch.js +0 -99
- package/dist/runner/learning-factory.d.ts +0 -16
- package/dist/runner/learning-factory.js +0 -50
- package/dist/runner/learning-loop.d.ts +0 -273
- package/dist/runner/learning-loop.js +0 -521
- package/dist/usage.d.ts +0 -11
- package/dist/usage.js +0 -11
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
// The runner's half of the end-of-run turn (the learning lane's
|
|
2
|
-
//
|
|
3
|
-
// answer's note blocks, never from a file it writes there. The words and the rule are the tool gate's own
|
|
4
|
-
// (tool-gate.ts NOTE_ONLY_TEXT, underLearning), kept equal by a test.
|
|
5
|
-
import { posix, resolve, sep, join } from "node:path";
|
|
1
|
+
// The runner's half of the end-of-run turn (the learning lane's compile turn): its request id, and where its rounds are
|
|
2
|
+
// in a run's journal.
|
|
6
3
|
import { KINDS } from "./journal-kinds.js";
|
|
7
4
|
/** The prefix of the end-of-run turn's request id: the server's own (turns.ts REFLECT_REQUEST). */
|
|
8
5
|
export const REFLECT_PREFIX = "learn-reflect-";
|
|
9
6
|
/** The label a reader puts on the end-of-run turn's rows and messages: the server's (learning.ts LEARNING_LABEL). */
|
|
10
7
|
export const REFLECT_LABEL = "learning";
|
|
11
|
-
/** The end-of-run turn's request id, one per round of a run, and one per `step` of a round (
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
8
|
+
/** The end-of-run turn's request id, one per round of a run, and one per `step` of a round (the compile turn's attempts,
|
|
9
|
+
* `compile-<n>`): pi answers a repeat of it from its submission, so a turn asked again on a later claim is never asked of
|
|
10
|
+
* the model twice. A run's first end is round 1; an end after a follow-up opened the run again is the next round, whose
|
|
11
|
+
* turn is asked of the model anew under an id of its own. The server's own prefix, so the run's readers tell the turn's
|
|
12
|
+
* rows apart by it (reflectRanges). */
|
|
16
13
|
export const reflectRequestId = (runId, again = false, round = 1, step) => `${REFLECT_PREFIX}${runId}${round > 1 ? `${REFLECT_ROUND}${round}` : ""}${step !== undefined ? `:${step}` : again ? REFLECT_AGAIN : ""}`;
|
|
17
14
|
/** The suffix of the end-of-run turn's re-ask's request id (EndOfRunTurn ask's `again`): one per round too, so a repeat
|
|
18
15
|
* is answered from its submission, never asked of the model twice. */
|
|
@@ -21,7 +18,7 @@ export const REFLECT_AGAIN = ":again";
|
|
|
21
18
|
const REFLECT_ROUND = ":round-";
|
|
22
19
|
/** What a round's re-ask or step adds to its request id (reflectRequestId): the round is the id without it. */
|
|
23
20
|
const REFLECT_STEP = /:(?:again|compile-\d+)$/;
|
|
24
|
-
/** The round shared by its
|
|
21
|
+
/** The round shared by its re-ask and compile attempts, for range and durable accounting reads. */
|
|
25
22
|
export const reflectRoundId = (requestId) => requestId.replace(REFLECT_STEP, "");
|
|
26
23
|
/** Each round of the end-of-run turn in a run's journal, oldest first: each begins at the entry its input placed, from the
|
|
27
24
|
* input submissions under its request ids (its re-ask's within it); else, on a CLI harness, at the turn's prompt the CLI
|
|
@@ -54,28 +51,6 @@ export function reflectRanges(submissions, entries = []) {
|
|
|
54
51
|
}
|
|
55
52
|
/** Whether entry `entry` (a number) is one of `ranges`' end-of-run turns. */
|
|
56
53
|
export const inReflect = (ranges, entry) => ranges.some(({ from, until }) => entry >= from && (until === undefined || entry <= until));
|
|
57
|
-
/** The refusal of the end-of-run turn's write or edit under work/.learning/: the tool gate's one text (NOTE_ONLY_TEXT), so
|
|
58
|
-
* the adapter loop's refusal and the gate's are the same words. */
|
|
59
|
-
export { NOTE_ONLY_TEXT as REFLECT_NOTE_ONLY } from "../tool-gate.js";
|
|
60
|
-
/** The folder of a run's copy of what its agent learned, relative to its work. */
|
|
61
|
-
const LEARNED_DIR = ".learning";
|
|
62
|
-
/** A computer's work folder, as a box names it. */
|
|
63
|
-
const BOX_WORK = "/workspace";
|
|
64
|
-
/** The work a relative path resolves against when the run's own work folder is not known to the loop. */
|
|
65
|
-
const NO_WORK = "/.agentrun-run-work";
|
|
66
|
-
/** Whether `args.path`, as a file tool resolves it (a leading `@` dropped, Unicode spaces made plain, then lexically),
|
|
67
|
-
* names work/.learning/ or a path under it: by the run's `work` (when the loop knows it), or the box's. */
|
|
68
|
-
export function underLearning(work, args) {
|
|
69
|
-
const path = args?.path;
|
|
70
|
-
if (typeof path !== "string")
|
|
71
|
-
return false;
|
|
72
|
-
const plain = path.replace(/[ - ]/g, " ").replace(/^@/, "");
|
|
73
|
-
const under = (base, at) => at === join(base, LEARNED_DIR) || at.startsWith(`${join(base, LEARNED_DIR)}${sep}`);
|
|
74
|
-
const root = work ?? NO_WORK;
|
|
75
|
-
return under(resolve(root), resolve(root, plain)) || under(BOX_WORK, posix.resolve(BOX_WORK, plain));
|
|
76
|
-
}
|
|
77
|
-
/** The tools whose write the end-of-run turn is refused under work/.learning/. */
|
|
78
|
-
export const WRITES = new Set(["write", "edit"]);
|
|
79
54
|
/** The text an answer entry gave (pi's assistant entry): the text parts of the messages it adds to the model's context,
|
|
80
55
|
* joined. */
|
|
81
56
|
export function answerText(entry) {
|
|
@@ -2,7 +2,7 @@ import { type Grade } from "../learn/promote.js";
|
|
|
2
2
|
import type { RunPath } from "../learning-cost.js";
|
|
3
3
|
import { type RunLaunch } from "../run-launch.js";
|
|
4
4
|
import { type Command, type Store } from "../store/store.js";
|
|
5
|
-
export declare const FEEDBACK_ROUNDS: readonly ["
|
|
5
|
+
export declare const FEEDBACK_ROUNDS: readonly ["correction"];
|
|
6
6
|
export type FeedbackRound = (typeof FEEDBACK_ROUNDS)[number];
|
|
7
7
|
/** A feedback round, as its steer's body carries it (`feedback`) and its FEEDBACK entry keeps it: the round, whether the
|
|
8
8
|
* grade said right, and the grade's words (`text`). */
|
|
@@ -11,7 +11,7 @@ export interface FeedbackData {
|
|
|
11
11
|
readonly correct: boolean;
|
|
12
12
|
readonly text: string;
|
|
13
13
|
}
|
|
14
|
-
/** What a grade asks for: `
|
|
14
|
+
/** What a grade asks for: `correction` for a graded run the agent finished when the grade has words, else none
|
|
15
15
|
* (undefined): a run its learned workflow answered alone opens none, right or wrong (its grade is kept). A replay run
|
|
16
16
|
* is never graded. */
|
|
17
17
|
export declare function feedbackRoundOf(grade: {
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// learning, and how the run's next end reads it. The run's path is who wrote its final answer, so a grade never makes
|
|
3
3
|
// the agent answer the job again:
|
|
4
4
|
// - a run its learned workflow answered alone (path `workflow`), graded right or wrong: the grade is kept and nothing else happens: no round, no turn, $0. One wrong answer is one sample;
|
|
5
|
-
// - a run the agent finished (path `agent` or `handed_back`) graded with words (`label`): a
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// spend.
|
|
5
|
+
// - a run the agent finished (path `agent` or `handed_back`) graded with words (`label`): a correction round on them.
|
|
6
|
+
// The run opens again on it: the grade's words are on its record, the agent is asked no turn of the job's, and the
|
|
7
|
+
// run goes straight to its end-of-run step, which appends the words to corrections.md as one line (and compiles, when
|
|
8
|
+
// a compile is due). Its spend is learning spend.
|
|
9
9
|
// A grade with neither asks for nothing more. The server writes the round's steer (server.ts gradeRun, runs.reopen); the
|
|
10
10
|
// adapter loop takes it (adapter-loop.ts steer: a FEEDBACK entry, no turn), and the end-of-run step reads it
|
|
11
11
|
// (learning-end.ts: heard, never "nothing new"; adapter-loop.ts askEndOfRun: feedbackAsk before the prompt).
|
|
@@ -14,12 +14,12 @@ import { readLaunchBody } from "../run-launch.js";
|
|
|
14
14
|
import { RunFinal } from "../store/store.js";
|
|
15
15
|
import { KINDS } from "./journal-kinds.js";
|
|
16
16
|
import { commandRequest } from "./loop.js";
|
|
17
|
-
export const FEEDBACK_ROUNDS = ["
|
|
18
|
-
/** What a grade asks for: `
|
|
17
|
+
export const FEEDBACK_ROUNDS = ["correction"];
|
|
18
|
+
/** What a grade asks for: `correction` for a graded run the agent finished when the grade has words, else none
|
|
19
19
|
* (undefined): a run its learned workflow answered alone opens none, right or wrong (its grade is kept). A replay run
|
|
20
20
|
* is never graded. */
|
|
21
21
|
export function feedbackRoundOf(grade, label) {
|
|
22
|
-
return (grade.path === "agent" || grade.path === "handed_back") && label ? "
|
|
22
|
+
return (grade.path === "agent" || grade.path === "handed_back") && label ? "correction" : undefined;
|
|
23
23
|
}
|
|
24
24
|
/** The feedback round a steer's body asks for (`body.feedback`, the server's own: server.ts gradeRun writes it, and the
|
|
25
25
|
* message API never does), else undefined. */
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { unseal } from "../sealing.js";
|
|
9
9
|
import { GITHUB_API, GITHUB_FIELDS, GITHUB_SCOPE, githubCall, githubTargetOf, mintInstallationToken } from "../github.js";
|
|
10
10
|
import { isObject } from "../validate.js";
|
|
11
|
+
import { held } from "./held.js";
|
|
11
12
|
const ADAPTER = "github";
|
|
12
13
|
const aad = (field) => `trigger_settings|${ADAPTER}|${GITHUB_SCOPE}|${field}`;
|
|
13
14
|
/** The server's App as the store holds it now, opened with `sealKey`: its id and private key, or undefined when there is none
|
|
@@ -37,8 +38,9 @@ async function appOf(store, sealKey) {
|
|
|
37
38
|
* the repository and installation; any other run's tag is never read, only its owner's words. `hold`: each token minted
|
|
38
39
|
* joins the run's redactor (its `cut`), the first and every one after. */
|
|
39
40
|
export async function githubAppAccess(store, sealKey, firstInput, { api = GITHUB_API, now = Date.now, fromGitHub = false, hold, repo } = {}) {
|
|
41
|
+
// A run's own process holds no seal key: its runner's access for the claim's own launch, which mints there (held.ts).
|
|
40
42
|
if (!sealKey)
|
|
41
|
-
return
|
|
43
|
+
return held()?.githubAppAccess();
|
|
42
44
|
const app = await appOf(store, sealKey);
|
|
43
45
|
if (!app)
|
|
44
46
|
return undefined;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { RunLaunch } from "../run-launch.js";
|
|
2
2
|
import { type AdapterSpecDeps } from "./adapter-run-spec.js";
|
|
3
|
-
import { type GradeRouteAsk } from "./learning-dispatch.js";
|
|
4
|
-
import type { GraderRoute } from "./learning-ask.js";
|
|
5
3
|
import { ClaimRefused, type LoopFactory } from "./loop-contract.js";
|
|
6
4
|
/** A claimed run whose harness this host's memory never holds: its message is the host's words (neverFits). A claim
|
|
7
5
|
* refused for good, so a parked run it wakes fails too, never retried as a resume (runner.ts finish). */
|
|
@@ -11,12 +9,6 @@ export declare class NeverFits extends ClaimRefused {
|
|
|
11
9
|
/** The dispatch's `resolve`, built from the runner's deps: it reads the run's revision (for a workflow revision) and
|
|
12
10
|
* returns the loop the run runs on, or undefined when this runner does not run it (the dispatch fails it in words). */
|
|
13
11
|
export declare function resolveRunnerLoop(deps: AdapterSpecDeps): (harness: string, launch: RunLaunch, runId: string) => Promise<LoopFactory | undefined>;
|
|
14
|
-
/** The route a grade asks for (gradeModelFor: the grade model the server named, else the agent's own), from the runner's
|
|
15
|
-
* one route (`routeOf`), through gradeRouteOf. A grade model the server named (--grade-model, else AGENT_MODEL_STRONG)
|
|
16
|
-
* is the strong tier's: it goes with that tier's settings, sent whole as AGENT_MODEL_STRONG is (never cut to its bare id
|
|
17
|
-
* by AGENT_MODEL_GATEWAY_IDS) and priced at AGENT_MODEL_STRONG_PRICE. The agent's own model goes as its runs' does, on
|
|
18
|
-
* the default tier. */
|
|
19
|
-
export declare function gradeRouteFor(grade: GradeRouteAsk, env: NodeJS.ProcessEnv, routeOf: AdapterSpecDeps["routeOf"]): Promise<GraderRoute>;
|
|
20
12
|
/** The loop factory the runner holds for every run (its createLoop), built from the runner's deps over the one store: the
|
|
21
13
|
* dispatch (dispatch.ts) reads each run's launch and asks resolveRunnerLoop for its harness loop. The server
|
|
22
14
|
* start and the test server pass this to startRunner. */
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { createSdkLoop
|
|
2
|
-
import {
|
|
3
|
-
import { createNativeLoop, nativeLearningLoop, nativeSourceInstructions } from "./native-loop.js";
|
|
4
|
-
import { nativeOf } from "../native/binding.js";
|
|
1
|
+
import { createSdkLoop } from "./sdk-loop.js";
|
|
2
|
+
import { createNativeLoop } from "./native-loop.js";
|
|
5
3
|
// The runner's dispatch switch (design 2.1: "the runner takes every run"): which loop a claimed run runs, by its revision
|
|
6
4
|
// and the harness its launch names. The runner holds one dispatch loop (dispatch.ts) for every run; at the claim the
|
|
7
5
|
// dispatch reads the launch and asks this switch for the run's inner loop:
|
|
8
6
|
// - a workflow revision runs on the workflow loop (createWorkflowLoop), whatever its harness name (a workflow's default
|
|
9
7
|
// harness is pi), so the revision is read here to tell it from an agentic pi run;
|
|
10
|
-
// - a built-in learning run (its launch names harness "learning") runs on the learning loop;
|
|
11
8
|
// - pi runs on the kernel's adapter loop with the run's pi spec (adapterRunSpecFromLaunch), and so does a harness a
|
|
12
9
|
// module adds with no adapter facts of its own, on its runner's adapter;
|
|
13
10
|
// - a CLI harness (claude-agent, codex, opencode) runs on the adapter loop with its own adapter;
|
|
@@ -21,7 +18,7 @@ import { savedModelKeys, withModelKeys } from "./claim-secrets.js";
|
|
|
21
18
|
import { noServerKeyFor } from "../run-model-key.js";
|
|
22
19
|
import { createDispatchLoop } from "./dispatch.js";
|
|
23
20
|
import { cliRunSpecFromLaunch } from "./cli-run-spec.js";
|
|
24
|
-
import {
|
|
21
|
+
import { askRouteOf } from "./sdk-ask.js";
|
|
25
22
|
import { ClaimRefused } from "./loop-contract.js";
|
|
26
23
|
import { createWorkflowLoop, isWorkflowRevision } from "./workflow-loop.js";
|
|
27
24
|
import { workflowSpecOf } from "./workflow-spec.js";
|
|
@@ -45,56 +42,23 @@ export function resolveRunnerLoop(deps) {
|
|
|
45
42
|
// store-secrets.ts), and every one the server keeps is held by the run's one redactor.
|
|
46
43
|
return createWorkflowLoop(workflowSpecOf({ store: deps.store, sealKey: deps.sealKey, data: deps.data, ...(deps.env ? { env: deps.env } : {}) }));
|
|
47
44
|
}
|
|
48
|
-
|
|
45
|
+
// A backend SDK run's compile turn is asked on the runner's one model route, on the agent's own model (its learning
|
|
46
|
+
// start's), its key from the runner's environment, else the one saved in Settings → Model keys, read at each ask.
|
|
47
|
+
if (launch.sdk)
|
|
49
48
|
return createSdkLoop(launch, deps, async () => {
|
|
50
49
|
const base = deps.env ?? process.env;
|
|
51
|
-
// An SDK run's look-back runs after its backend reported it complete, on no run's key: on a server that holds no
|
|
52
|
-
// gateway key it is skipped in words (run-model-key.ts noServerKeyFor), nothing sent.
|
|
53
50
|
const env = withModelKeys(base, await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: base }));
|
|
54
|
-
|
|
51
|
+
// It runs after its backend reported the run complete, on no run's key: on a server that holds no gateway key it is
|
|
52
|
+
// skipped in words (run-model-key.ts noServerKeyFor), nothing sent.
|
|
53
|
+
const off = noServerKeyFor(env, "An SDK run's compile turn");
|
|
55
54
|
if (off) {
|
|
56
55
|
deps.log?.(off);
|
|
57
56
|
throw new Error(off);
|
|
58
57
|
}
|
|
59
|
-
return
|
|
58
|
+
return askRouteOf(launch.learning.model, env, (model) => deps.routeOf(model, env, "default", PI_WIRES));
|
|
60
59
|
});
|
|
61
|
-
if (
|
|
60
|
+
if (launch.native)
|
|
62
61
|
return createNativeLoop(launch, deps);
|
|
63
|
-
if (harness === "learning") {
|
|
64
|
-
const native = nativeOf(revision?.body);
|
|
65
|
-
if (native && !launch.model)
|
|
66
|
-
return nativeLearningLoop(deps, native);
|
|
67
|
-
// A built-in learning run on the learning loop: its grade goes through the runner's one model route, on the grade
|
|
68
|
-
// model its launch names (none: the agent's own), at that route's price (learning-dispatch.ts).
|
|
69
|
-
return learningLoopOf({
|
|
70
|
-
store: deps.store,
|
|
71
|
-
data: deps.data,
|
|
72
|
-
...(sdkOf(revision?.body) ? { sourceInstructions: (runId) => sdkSourceInstructions(deps.store, runId) } : {}),
|
|
73
|
-
...(native ? { sourceInstructions: (runId) => nativeSourceInstructions(deps.store, runId) } : {}),
|
|
74
|
-
// The grader speaks the route's wire, as pi does (learning-ask.ts: pi.ts policyFor and port-models.ts
|
|
75
|
-
// sessionProvider), so its route is asked on pi's wires; a model on neither keeps the route's Messages translation.
|
|
76
|
-
// A grade model whose vendor this host reaches only through OpenRouter goes there as main's grade does
|
|
77
|
-
// (gradeRouteOf): OpenRouter's key its one credential, priced at OpenRouter's price.
|
|
78
|
-
// The grade's model, main's order (gradeModelFor): the grade model the server names, else the agent's own.
|
|
79
|
-
// Its model's key from the runner's environment, else the one saved in Settings → Model keys (savedModelKeys), read
|
|
80
|
-
// at each grade, so a key saved with no restart grades the next learning run.
|
|
81
|
-
routeOf: async (grade) => {
|
|
82
|
-
const base = deps.env ?? process.env;
|
|
83
|
-
// A learning run grades after its source run's turn ended, on no run's key (a run that brought its own queues no
|
|
84
|
-
// grade: learning-end.ts spendOff): on a server that holds no gateway key it is skipped in words
|
|
85
|
-
// (run-model-key.ts noServerKeyFor). Nothing is sent; the learning run ends dropped.
|
|
86
|
-
const env = withModelKeys(base, await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: base }));
|
|
87
|
-
const off = noServerKeyFor(env, "A learning run's grade");
|
|
88
|
-
if (off) {
|
|
89
|
-
deps.log?.(off);
|
|
90
|
-
throw new Error(off);
|
|
91
|
-
}
|
|
92
|
-
return gradeRouteFor(grade, env, deps.routeOf);
|
|
93
|
-
},
|
|
94
|
-
...(deps.log ? { log: deps.log } : {}),
|
|
95
|
-
...(deps.gradeBound ? { gradeBound: deps.gradeBound } : {}),
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
62
|
// The harness's own entry decides which spec builds the run, by what the entry gives and never the harness's name: an
|
|
99
63
|
// entry with an adapter's facts and serve's own adapter for it (the CLI harnesses) runs the CLI spec (cli-run-spec.ts);
|
|
100
64
|
// any other (pi, or a harness module's entry that gives only the required members) runs the run spec
|
|
@@ -122,18 +86,6 @@ export function resolveRunnerLoop(deps) {
|
|
|
122
86
|
return undefined;
|
|
123
87
|
};
|
|
124
88
|
}
|
|
125
|
-
/** The route a grade asks for (gradeModelFor: the grade model the server named, else the agent's own), from the runner's
|
|
126
|
-
* one route (`routeOf`), through gradeRouteOf. A grade model the server named (--grade-model, else AGENT_MODEL_STRONG)
|
|
127
|
-
* is the strong tier's: it goes with that tier's settings, sent whole as AGENT_MODEL_STRONG is (never cut to its bare id
|
|
128
|
-
* by AGENT_MODEL_GATEWAY_IDS) and priced at AGENT_MODEL_STRONG_PRICE. The agent's own model goes as its runs' does, on
|
|
129
|
-
* the default tier. */
|
|
130
|
-
export function gradeRouteFor(grade, env, routeOf) {
|
|
131
|
-
return gradeRouteOf(gradeModelFor(grade), env, (model) => (grade.model !== undefined && model === grade.model
|
|
132
|
-
// The runner's environment under the grader as its strong model: every key it holds read through it, a non-enumerable
|
|
133
|
-
// one (a launcher-held or Settings key) too, which a copy would drop.
|
|
134
|
-
? routeOf(undefined, Object.create(env, { AGENT_MODEL_STRONG: { value: model, enumerable: true } }), "strong", PI_WIRES)
|
|
135
|
-
: routeOf(model, env, "default", PI_WIRES)));
|
|
136
|
-
}
|
|
137
89
|
/** The loop factory the runner holds for every run (its createLoop), built from the runner's deps over the one store: the
|
|
138
90
|
* dispatch (dispatch.ts) reads each run's launch and asks resolveRunnerLoop for its harness loop. The server
|
|
139
91
|
* start and the test server pass this to startRunner. */
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { PlanReader } from "../chatgpt-plan.js";
|
|
2
|
+
import type { Tier } from "../model.js";
|
|
3
|
+
import type { RunSignIn } from "../sign-ins-store.js";
|
|
4
|
+
import type { LiveHandover } from "../browser-live.js";
|
|
5
|
+
import type { ApprovalPrice, ToolEffect } from "../tool-gate.js";
|
|
6
|
+
import type { OpenedAccount } from "../email/account.js";
|
|
7
|
+
import type { SavedCalendar } from "../calendar/address.js";
|
|
8
|
+
import type { Workspace } from "../workspace/workspace.js";
|
|
9
|
+
import type { GithubAppAccessAt } from "./github-app.js";
|
|
10
|
+
import type { HarnessInstallEntry, HarnessPins } from "../harness-install.js";
|
|
11
|
+
import type { AlsoRow } from "../store/store.js";
|
|
12
|
+
import type { RunModelKey } from "../store/seal.js";
|
|
13
|
+
import type { EndOfRunKept, EndOfRunTurn } from "./loop-contract.js";
|
|
14
|
+
import type { LearnedFirst } from "./learned-first.js";
|
|
15
|
+
/** One MCP tool of the claim, its call made by the runner (mcp-run.ts mcpForClaim), with what the gate reads of it. */
|
|
16
|
+
export interface HeldMcpTool {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly description: string;
|
|
19
|
+
readonly inputSchema: unknown;
|
|
20
|
+
readonly catalog: string;
|
|
21
|
+
readonly arguments?: readonly string[];
|
|
22
|
+
readonly price?: ApprovalPrice;
|
|
23
|
+
readonly effect?: ToolEffect;
|
|
24
|
+
call(args: unknown, context: {
|
|
25
|
+
readonly signal?: AbortSignal;
|
|
26
|
+
readonly callId?: string;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
text: string;
|
|
29
|
+
isError?: true;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
/** The claim's MCP as the runner holds it: its tools, and its credentials' refresh and release. */
|
|
33
|
+
export interface HeldMcp {
|
|
34
|
+
readonly tools: readonly HeldMcpTool[];
|
|
35
|
+
fresh(): Promise<void>;
|
|
36
|
+
release(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
/** What the run's process gives mcpForClaim on the runner: its grants and harness are its revision's, which the runner
|
|
39
|
+
* reads itself. */
|
|
40
|
+
export interface HeldMcpAsk {
|
|
41
|
+
/** The run's journal commit, for a call's record on the run's root (mcp-gateway.ts commit): an entry appended. */
|
|
42
|
+
readonly appendRoot: (entry: unknown) => Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
/** What the run's process gives the runner's computerForClaim (workspace/computer-for-claim.ts): its callbacks only. The
|
|
45
|
+
* run, its epoch, its folder, its mode and its revision are the runner's own reads of the claim. */
|
|
46
|
+
export interface HeldComputerAsk {
|
|
47
|
+
readonly hadComputer: () => Promise<boolean>;
|
|
48
|
+
readonly signal?: AbortSignal;
|
|
49
|
+
readonly say?: (words: string) => void;
|
|
50
|
+
readonly onImageWait?: (making: boolean, image: string) => void;
|
|
51
|
+
readonly onStarting?: (said: string) => void;
|
|
52
|
+
readonly onConnected?: (said: string) => void;
|
|
53
|
+
readonly onComputerNote?: (words: string) => void;
|
|
54
|
+
}
|
|
55
|
+
export interface Held {
|
|
56
|
+
/** The ChatGPT sign-in's reader (chatgpt-plan.ts planReaderOf), for a run whose models reach the plan; else none. */
|
|
57
|
+
plan(): Promise<PlanReader | undefined>;
|
|
58
|
+
/** Whether a browser sign-in handed to the run reads back here (sign-ins-store.ts handedSignInReadsBack). */
|
|
59
|
+
signInReadsBack(): Promise<boolean>;
|
|
60
|
+
/** The run's browser sign-in for vendor `resolution` (sign-ins-store.ts runSignIn). */
|
|
61
|
+
runSignIn(resolution: string): Promise<RunSignIn | undefined>;
|
|
62
|
+
/** The run's kept sign-in marked verified at `at` (sign-ins-store.ts verifyRunSignIn). */
|
|
63
|
+
verifySignIn(kept: RunSignIn, at: number): Promise<boolean>;
|
|
64
|
+
/** The claim's MCP (mcp-run.ts mcpForClaim); none when its revision grants no MCP tool. */
|
|
65
|
+
mcp(ask: HeldMcpAsk): Promise<HeldMcp | undefined>;
|
|
66
|
+
/** The GitHub App's access for the run's pull-request checkout (pr-checkout.ts): none unless its revision checks one
|
|
67
|
+
* out and its launch's payload names the pull request. Its mint makes a token of that repository alone, contents
|
|
68
|
+
* read, whatever the process names; its MCP mints on the runner (mcp). */
|
|
69
|
+
githubAppAccess(): Promise<GithubAppAccessAt | undefined>;
|
|
70
|
+
/** Every saved model key, for a run whose routes have no revision to scope them by (a subagent's tiers, a grade). */
|
|
71
|
+
savedModelKeys(): Promise<Record<string, string>>;
|
|
72
|
+
/** The model keys the host's models of `tiers` need (claim-secrets.ts tierModelKeys), the plan's reader with them: of
|
|
73
|
+
* the tiers the claim's learned workflows name, as the runner chose them (learnedFirst), alone. */
|
|
74
|
+
tierModelKeys(tiers: readonly Tier[]): Promise<{
|
|
75
|
+
readonly keys: Record<string, string>;
|
|
76
|
+
readonly plan?: PlanReader;
|
|
77
|
+
}>;
|
|
78
|
+
/** The run's own model key, opened from the claim's run's launch (claim-secrets.ts claimModelKey): none where it holds
|
|
79
|
+
* none; throws, in words, where the launch does not open under the runner's seal key. Asked again for each message's
|
|
80
|
+
* key (ClaimModelKey.fresh). */
|
|
81
|
+
runModelKey(): Promise<RunModelKey | undefined>;
|
|
82
|
+
/** Whether the server has a gateway and holds no key for it (claim-secrets.ts serverKeyless): a boolean, never a key. */
|
|
83
|
+
serverKeyless(): Promise<boolean>;
|
|
84
|
+
/** The zone the claim's run's day is told in (environment.ts runZone): its trigger's, read by the runner from the
|
|
85
|
+
* claim's own launch, else the server's. A zone's name, never the trigger's row. */
|
|
86
|
+
runZone(): Promise<string>;
|
|
87
|
+
/** The host's keys of the decision providers `providers` (claim-secrets.ts hostDecisionKeys): of the providers the
|
|
88
|
+
* claim's learned workflows' questions name, as the runner chose them (learnedFirst), alone. */
|
|
89
|
+
decisionKeys(providers: readonly string[]): Promise<Record<string, string>>;
|
|
90
|
+
/** A browser session's viewer handed over, and taken back (browser-live.ts). */
|
|
91
|
+
liveViewerPut(handover: LiveHandover): Promise<boolean>;
|
|
92
|
+
liveViewerDrop(tag?: string): Promise<void>;
|
|
93
|
+
/** The MCP credentials run `from` was handed, sealed again for run `id`, a run this one starts (promotion.ts,
|
|
94
|
+
* audit.ts): none unless `from` is the claim's own run. */
|
|
95
|
+
handOn(from: string, id: string): Promise<Uint8Array | undefined>;
|
|
96
|
+
/** The run's agent's live sign-in pointer for `resolution`, and its forgotten ones (sign-ins-store.ts signInReads): what
|
|
97
|
+
* its learning end holds to refuse a pointer in what the run learned. */
|
|
98
|
+
signInPeek(resolution: string): Promise<unknown>;
|
|
99
|
+
signInForgotten(resolution: string): Promise<unknown>;
|
|
100
|
+
/** The server's email account, opened, for a run whose revision grants an email tool; else none. */
|
|
101
|
+
emailAccount(): Promise<OpenedAccount | undefined>;
|
|
102
|
+
/** The server's calendar, opened, for a run whose revision grants calendar_events; else none. */
|
|
103
|
+
calendar(): Promise<SavedCalendar | undefined>;
|
|
104
|
+
/** A call of the run's agent's learning folder (learn/folder.ts), the runner's own Workspace of it, held to what a
|
|
105
|
+
* run's learning does there (run-child-host.ts learningCall). */
|
|
106
|
+
learning(method: string, args: readonly unknown[]): Promise<unknown>;
|
|
107
|
+
/** The harness `name`'s install for the claim (harness-install.ts installForClaim), run by the runner. */
|
|
108
|
+
install(name: string, signal?: AbortSignal): Promise<void>;
|
|
109
|
+
/** The claim's computer (workspace/computer-for-claim.ts), made and held by the runner. */
|
|
110
|
+
computer(ask: HeldComputerAsk): Promise<unknown>;
|
|
111
|
+
/** A Mode 2 claim: the run's folder on its Archil disk, as the runner opens it; its mount credential's revoke. */
|
|
112
|
+
archil(): Promise<{
|
|
113
|
+
readonly workspace: Workspace;
|
|
114
|
+
revoke(): Promise<void>;
|
|
115
|
+
inherit(): Promise<void>;
|
|
116
|
+
release(): Promise<void>;
|
|
117
|
+
} | undefined>;
|
|
118
|
+
/** The claim's end-of-run step (learning-end.ts learningEndOfRun), run by the runner over its own reads of the claim:
|
|
119
|
+
* what the run's learning must never keep is every secret the runner holds, which no run's process is given. Its
|
|
120
|
+
* turns are asked through `input.ask`, the run's own session; `input.keptOf` is read once, for the round the runner
|
|
121
|
+
* reads. */
|
|
122
|
+
endOfRun(input: HeldEndOfRunInput): Promise<{
|
|
123
|
+
readonly also: readonly AlsoRow[];
|
|
124
|
+
} | undefined>;
|
|
125
|
+
/** The claim's learned first choice (learned-first.ts learnedFirst), run by the runner over the workflows it reads at the
|
|
126
|
+
* claim's seed: `laid` says only whether the process's seed lay laid any (false: none is laid). Its audits, promotion
|
|
127
|
+
* and replay reads are the runner's. */
|
|
128
|
+
learnedFirst(ask: {
|
|
129
|
+
readonly laid: boolean;
|
|
130
|
+
}): Promise<LearnedFirst>;
|
|
131
|
+
/** The runner's live address (live-reach.ts runnerLiveOf) with the claim's own proof key (liveForRun): what proves a
|
|
132
|
+
* request for this run's viewers alone. None on a runner on its server's machine. */
|
|
133
|
+
liveAt(): Promise<{
|
|
134
|
+
readonly host: string;
|
|
135
|
+
readonly bind: string;
|
|
136
|
+
readonly key: Uint8Array;
|
|
137
|
+
} | undefined>;
|
|
138
|
+
}
|
|
139
|
+
/** What a run's process hands its runner for the end-of-run step: EndOfRunTurn's input, its keptOf asked over the
|
|
140
|
+
* channel (so answered later). */
|
|
141
|
+
export type HeldEndOfRunInput = Omit<Parameters<EndOfRunTurn>[0], "keptOf"> & {
|
|
142
|
+
readonly keptOf?: (round: number) => Promise<EndOfRunKept | undefined>;
|
|
143
|
+
};
|
|
144
|
+
/** Sets this process's runner seam: run-child.ts, once, before the run's loop starts. */
|
|
145
|
+
export declare function setHeld(held: Held): void;
|
|
146
|
+
/** This process's runner seam: set in a run's own process, never in a runner or a server. */
|
|
147
|
+
export declare function held(): Held | undefined;
|
|
148
|
+
/** This process's runner seam, where a caller with no seal key needs one: a runner or a server that reaches here with
|
|
149
|
+
* no key is a bug, said in words, never a quiet answer of nothing. */
|
|
150
|
+
export declare function heldOrThrow(what: string): Held;
|
|
151
|
+
/** signInReads (sign-ins-store.ts) in a run's own process: the claim's agent's, read by its runner. */
|
|
152
|
+
export declare function heldSignInReads(): {
|
|
153
|
+
peek(agentId: string, resolution: string): Promise<never>;
|
|
154
|
+
forgotten(agentId: string, resolution: string): Promise<never>;
|
|
155
|
+
};
|
|
156
|
+
/** The agent's learning folder in a run's own process (learn/folder.ts learningWorkspace): each call made by its runner on
|
|
157
|
+
* the folder of the claim's agent (Held.learning), whatever place this process names. No background program, mount or
|
|
158
|
+
* attach: a learning folder has none. */
|
|
159
|
+
export declare function heldLearningFolder(): {
|
|
160
|
+
readonly workspace: Workspace;
|
|
161
|
+
end(): Promise<void>;
|
|
162
|
+
};
|
|
163
|
+
/** A learning run's end-of-run step in a run's own process (learning-end.ts learningEndOfRun): its runner's
|
|
164
|
+
* (Held.endOfRun), whatever deps the process would have built it with. */
|
|
165
|
+
export declare function heldEndOfRun(): EndOfRunTurn;
|
|
166
|
+
/** A runner's install of a harness, as a run's process asks it (AdapterSpecDeps.installForClaim): the harness's name
|
|
167
|
+
* alone crosses; the runner reads its entry, folder and pins itself. */
|
|
168
|
+
export declare const heldInstall: (entry: HarnessInstallEntry, _dir: string, _pins: () => Promise<HarnessPins>, given?: {
|
|
169
|
+
signal?: AbortSignal;
|
|
170
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
let current;
|
|
2
|
+
/** Sets this process's runner seam: run-child.ts, once, before the run's loop starts. */
|
|
3
|
+
export function setHeld(held) {
|
|
4
|
+
current = held;
|
|
5
|
+
}
|
|
6
|
+
/** This process's runner seam: set in a run's own process, never in a runner or a server. */
|
|
7
|
+
export function held() {
|
|
8
|
+
return current;
|
|
9
|
+
}
|
|
10
|
+
/** This process's runner seam, where a caller with no seal key needs one: a runner or a server that reaches here with
|
|
11
|
+
* no key is a bug, said in words, never a quiet answer of nothing. */
|
|
12
|
+
export function heldOrThrow(what) {
|
|
13
|
+
if (!current)
|
|
14
|
+
throw new Error(`${what} needs the server's seal key, and this process has neither it nor a runner to ask`);
|
|
15
|
+
return current;
|
|
16
|
+
}
|
|
17
|
+
/** signInReads (sign-ins-store.ts) in a run's own process: the claim's agent's, read by its runner. */
|
|
18
|
+
export function heldSignInReads() {
|
|
19
|
+
const at = heldOrThrow("a run's sign-in reads");
|
|
20
|
+
return {
|
|
21
|
+
peek: (_agentId, resolution) => at.signInPeek(resolution),
|
|
22
|
+
forgotten: (_agentId, resolution) => at.signInForgotten(resolution),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** The agent's learning folder in a run's own process (learn/folder.ts learningWorkspace): each call made by its runner on
|
|
26
|
+
* the folder of the claim's agent (Held.learning), whatever place this process names. No background program, mount or
|
|
27
|
+
* attach: a learning folder has none. */
|
|
28
|
+
export function heldLearningFolder() {
|
|
29
|
+
const at = heldOrThrow("a run's learning folder");
|
|
30
|
+
const call = (method) => (...args) => at.learning(method, args);
|
|
31
|
+
const none = (what) => async () => {
|
|
32
|
+
throw new Error(`a learning folder has no ${what} in a run's own process`);
|
|
33
|
+
};
|
|
34
|
+
const workspace = {
|
|
35
|
+
read: call("read"),
|
|
36
|
+
write: call("write"),
|
|
37
|
+
append: call("append"),
|
|
38
|
+
stat: call("stat"),
|
|
39
|
+
list: call("list"),
|
|
40
|
+
mkdir: call("mkdir"),
|
|
41
|
+
grep: call("grep"),
|
|
42
|
+
remove: call("remove"),
|
|
43
|
+
exec: call("exec"),
|
|
44
|
+
process: { start: none("background program"), list: none("background program"), output: none("background program"), signal: none("background program"), wait: none("background program") },
|
|
45
|
+
mountSpec: none("mount"),
|
|
46
|
+
attach: none("attach"),
|
|
47
|
+
};
|
|
48
|
+
return { workspace, end: async () => { } };
|
|
49
|
+
}
|
|
50
|
+
/** A learning run's end-of-run step in a run's own process (learning-end.ts learningEndOfRun): its runner's
|
|
51
|
+
* (Held.endOfRun), whatever deps the process would have built it with. */
|
|
52
|
+
export function heldEndOfRun() {
|
|
53
|
+
return async ({ keptOf, ...input }) => heldOrThrow("a run's end-of-run step").endOfRun({ ...input, ...(keptOf ? { keptOf: async (round) => keptOf(round) } : {}) });
|
|
54
|
+
}
|
|
55
|
+
/** A runner's install of a harness, as a run's process asks it (AdapterSpecDeps.installForClaim): the harness's name
|
|
56
|
+
* alone crosses; the runner reads its entry, folder and pins itself. */
|
|
57
|
+
export const heldInstall = async (entry, _dir, _pins, given = {}) => heldOrThrow("a harness's install").install(entry.id, given.signal);
|
|
@@ -78,9 +78,8 @@ export declare const KINDS: {
|
|
|
78
78
|
* read it decided, written on the root before the end-of-run step asks its first turn. A claim that finds that turn
|
|
79
79
|
* open ends the run on the newest one, never working the job's end out again. Neither a call nor a message. */
|
|
80
80
|
readonly jobEnd: "agentrun.end-of-run.job";
|
|
81
|
-
/** What a learning run's claim laid of its seed: the learned
|
|
82
|
-
*
|
|
83
|
-
* what the run was given. Neither a call nor a message. */
|
|
81
|
+
/** What a learning run's claim laid of its seed: the learned workflows its learned_workflow tool runs (`workflows`, by
|
|
82
|
+
* name). Written once per claim, on the root; the newest is what the run was given. Neither a call nor a message. */
|
|
84
83
|
readonly learningLaid: "agentrun.learning.laid";
|
|
85
84
|
/** The claim made the run a computer of its own (`computer`: its kind, desktop, sandbox or phone; computer-for-claim.ts
|
|
86
85
|
* ClaimComputer.made): written on the root at the claim's first pass. A later claim's computer is a new one, and this
|
|
@@ -78,9 +78,8 @@ export const KINDS = {
|
|
|
78
78
|
* read it decided, written on the root before the end-of-run step asks its first turn. A claim that finds that turn
|
|
79
79
|
* open ends the run on the newest one, never working the job's end out again. Neither a call nor a message. */
|
|
80
80
|
jobEnd: "agentrun.end-of-run.job",
|
|
81
|
-
/** What a learning run's claim laid of its seed: the learned
|
|
82
|
-
*
|
|
83
|
-
* what the run was given. Neither a call nor a message. */
|
|
81
|
+
/** What a learning run's claim laid of its seed: the learned workflows its learned_workflow tool runs (`workflows`, by
|
|
82
|
+
* name). Written once per claim, on the root; the newest is what the run was given. Neither a call nor a message. */
|
|
84
83
|
learningLaid: "agentrun.learning.laid",
|
|
85
84
|
/** The claim made the run a computer of its own (`computer`: its kind, desktop, sandbox or phone; computer-for-claim.ts
|
|
86
85
|
* ClaimComputer.made): written on the root at the claim's first pass. A later claim's computer is a new one, and this
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
|
+
import type { LearnedWorkflow, Shown } from "../learning.js";
|
|
3
|
+
import type { LearningFolder } from "../learn/folder.js";
|
|
4
|
+
import type { Recorded } from "../learn/replay-calls.js";
|
|
5
|
+
import type { RunLaunch } from "../run-launch.js";
|
|
6
|
+
import type { Store } from "../store/store.js";
|
|
7
|
+
import { type FirstChoice } from "./workflow-first.js";
|
|
8
|
+
/** The claim, as the runner read it, for learnedFirst. */
|
|
9
|
+
export interface LearnedFirstDeps {
|
|
10
|
+
readonly store: Store;
|
|
11
|
+
readonly sealKey?: Buffer;
|
|
12
|
+
readonly agentId: string;
|
|
13
|
+
readonly runId: string;
|
|
14
|
+
readonly revisionId: string;
|
|
15
|
+
/** The revision's kind and its output schema (workflowFirstOf). */
|
|
16
|
+
readonly kind: string;
|
|
17
|
+
readonly outputSchema?: unknown;
|
|
18
|
+
readonly launch: RunLaunch;
|
|
19
|
+
readonly context: Context;
|
|
20
|
+
readonly log: (line: string) => void;
|
|
21
|
+
readonly folder: () => LearningFolder;
|
|
22
|
+
readonly shown: () => Promise<Shown>;
|
|
23
|
+
readonly spendOff?: (what: string) => string | undefined;
|
|
24
|
+
}
|
|
25
|
+
/** What the claim starts with: its first choice, the workflows its learned_workflow tool runs, and a replay run's
|
|
26
|
+
* recorded calls (by learn/replay-calls.ts callKey; none for any other run). Data alone. */
|
|
27
|
+
export interface LearnedFirst {
|
|
28
|
+
readonly choice: FirstChoice;
|
|
29
|
+
readonly workflows: LearnedWorkflow[];
|
|
30
|
+
readonly recorded?: [string, Recorded][];
|
|
31
|
+
}
|
|
32
|
+
/** The claim's learned first choice over `laid`, the workflows its seed lay laid (see the file's head). A replay run's
|
|
33
|
+
* claim that is refused throws ClaimRefused, as replayClaimed does. */
|
|
34
|
+
export declare function learnedFirst(deps: LearnedFirstDeps, laid: readonly LearnedWorkflow[]): Promise<LearnedFirst>;
|
|
35
|
+
/** learnedFirst where the claim is held: a runner's own (its seal key), else, in a run's own process, its runner's
|
|
36
|
+
* (held.ts learnedFirst), told only whether `laid` holds any workflow. */
|
|
37
|
+
export declare function learnedFirstWhereHeld(deps: {
|
|
38
|
+
readonly store: Store;
|
|
39
|
+
readonly sealKey?: Buffer | undefined;
|
|
40
|
+
}, claim: Omit<LearnedFirstDeps, "store" | "sealKey">, laid: readonly LearnedWorkflow[]): Promise<LearnedFirst>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { pastRunsOverStore } from "../store-reads/learning.js";
|
|
2
|
+
import { learnsWorkflows } from "./adapter-run-spec.js";
|
|
3
|
+
import { settleAudits } from "./audit.js";
|
|
4
|
+
import { held } from "./held.js";
|
|
5
|
+
import { claimPromotion, promotionGate, replayClaimed, replayLaid, replayRecordedFor, toolFlowsFor } from "./promotion.js";
|
|
6
|
+
import { workflowFirstOf } from "./workflow-first.js";
|
|
7
|
+
/** The claim's learned first choice over `laid`, the workflows its seed lay laid (see the file's head). A replay run's
|
|
8
|
+
* claim that is refused throws ClaimRefused, as replayClaimed does. */
|
|
9
|
+
export async function learnedFirst(deps, laid) {
|
|
10
|
+
const { store, agentId, runId, revisionId, launch, context, log, folder, shown } = deps;
|
|
11
|
+
const own = { ...(deps.sealKey ? { sealKey: deps.sealKey } : {}), ...(deps.spendOff ? { spendOff: deps.spendOff } : {}) };
|
|
12
|
+
// A replay run lays only the workflow it replays (promotion.ts replayLaid).
|
|
13
|
+
const laidFlows = replayLaid(launch, laid);
|
|
14
|
+
if (launch.learning && !launch.replay && !launch.audit)
|
|
15
|
+
await settleAudits({ store, agentId, revisionId, context, log, folder, shown, ...own });
|
|
16
|
+
const promotion = claimPromotion({ store, agentId, runId, revisionId, launch, context, log, folder, shown, ...own });
|
|
17
|
+
const choice = learnsWorkflows(deps.kind, laidFlows) ? await workflowFirstOf(deps.kind, laidFlows, launch, log, () => pastRunsOverStore(store, agentId), promotionGate(promotion), deps.outputSchema) : {};
|
|
18
|
+
// A replay run runs only its revision, while it still replays: else its claim is refused (the run ends failed, no agent).
|
|
19
|
+
await replayClaimed(store, agentId, runId, launch, choice);
|
|
20
|
+
const recorded = await replayRecordedFor(store, launch, context);
|
|
21
|
+
// The tool runs what serves, never a revision not promoted (promotion.ts toolFlowsFor).
|
|
22
|
+
const workflows = await toolFlowsFor(promotion, launch, laidFlows, choice);
|
|
23
|
+
return { choice, workflows, ...(recorded ? { recorded: [...recorded] } : {}) };
|
|
24
|
+
}
|
|
25
|
+
/** learnedFirst where the claim is held: a runner's own (its seal key), else, in a run's own process, its runner's
|
|
26
|
+
* (held.ts learnedFirst), told only whether `laid` holds any workflow. */
|
|
27
|
+
export async function learnedFirstWhereHeld(deps, claim, laid) {
|
|
28
|
+
const at = deps.sealKey ? undefined : held();
|
|
29
|
+
if (at)
|
|
30
|
+
return at.learnedFirst({ laid: laid.length > 0 });
|
|
31
|
+
return learnedFirst({ ...claim, store: deps.store, ...(deps.sealKey ? { sealKey: deps.sealKey } : {}) }, laid);
|
|
32
|
+
}
|