@parcha/agentrun-serve 0.1.0-beta.38 → 0.1.0-beta.39
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 +418 -0
- package/README.md +325 -124
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +0 -2
- package/dist/agents-store.d.ts +5 -5
- package/dist/agents-store.js +14 -14
- package/dist/bash-read-only.js +2 -1
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -10
- package/dist/cap.js +2 -5
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +1 -5
- package/dist/chatgpt-plan.d.ts +163 -0
- package/dist/chatgpt-plan.js +549 -0
- package/dist/cli.js +26 -6
- package/dist/composio-preset.d.ts +8 -0
- package/dist/composio-preset.js +8 -7
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.js +2 -2
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +7 -2
- package/dist/computer-live.js +9 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +3 -3
- package/dist/computer-setting.js +5 -5
- package/dist/computer-view.d.ts +15 -0
- package/dist/computer-view.js +16 -2
- package/dist/computer-viewer.js +14 -1
- package/dist/computers.d.ts +5 -2
- package/dist/computers.js +9 -5
- package/dist/console/assets/index-BNhZs-jp.css +1 -0
- package/dist/console/assets/index-BQv5aOGB.js +700 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.js +3 -3
- package/dist/decision-cap.d.ts +2 -5
- package/dist/decision-cap.js +3 -6
- package/dist/decision-rows.js +11 -11
- package/dist/email/account.d.ts +84 -0
- package/dist/email/account.js +159 -0
- package/dist/email/answer.d.ts +10 -0
- package/dist/email/answer.js +182 -0
- package/dist/email/email-faux.d.ts +95 -0
- package/dist/email/email-faux.js +849 -0
- package/dist/email/labels.d.ts +1 -0
- package/dist/email/labels.js +84 -0
- package/dist/email/mail.d.ts +186 -0
- package/dist/email/mail.js +380 -0
- package/dist/email/names.d.ts +20 -0
- package/dist/email/names.js +40 -0
- package/dist/email/routes.d.ts +9 -0
- package/dist/email/routes.js +50 -0
- package/dist/email/tools.d.ts +20 -0
- package/dist/email/tools.js +517 -0
- package/dist/environment.d.ts +17 -2
- package/dist/environment.js +36 -8
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +12 -0
- package/dist/eval-mailbox.d.ts +103 -0
- package/dist/eval-mailbox.js +236 -0
- package/dist/graph-view.d.ts +9 -2
- package/dist/graph-view.js +6 -2
- package/dist/harness-install.d.ts +28 -2
- package/dist/harness-install.js +147 -59
- package/dist/harness-opencode/adapter.js +2 -26
- package/dist/harness-opencode/facts.js +5 -2
- package/dist/harness-opencode/host/policy.d.ts +2 -0
- package/dist/harness-opencode/host/policy.js +10 -5
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/versions.d.ts +6 -0
- package/dist/harness-opencode/versions.js +6 -0
- package/dist/harness-table.js +8 -5
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/hosted-search.d.ts +3 -1
- package/dist/hosted-search.js +51 -11
- package/dist/import-sources.d.ts +1 -1
- package/dist/import-sources.js +3 -3
- package/dist/import.d.ts +21 -0
- package/dist/import.js +186 -1
- package/dist/key-check.d.ts +0 -2
- package/dist/key-check.js +3 -4
- package/dist/key-refusal.d.ts +8 -2
- package/dist/key-refusal.js +16 -13
- package/dist/learn/check.d.ts +18 -3
- package/dist/learn/check.js +328 -3
- package/dist/learn/compile.d.ts +9 -2
- package/dist/learn/compile.js +52 -16
- package/dist/learn/grade.d.ts +4 -0
- package/dist/learn/grade.js +4 -1
- package/dist/learn/promote.d.ts +106 -51
- package/dist/learn/promote.js +82 -189
- package/dist/learn/refit.d.ts +21 -12
- package/dist/learn/refit.js +51 -23
- package/dist/learn/replay-calls.js +1 -1
- package/dist/learn/skills.d.ts +2 -7
- package/dist/learn/skills.js +28 -14
- package/dist/learned-nodes.d.ts +15 -7
- package/dist/learned-nodes.js +29 -5
- package/dist/learned-workflow.d.ts +41 -31
- package/dist/learned-workflow.js +122 -63
- package/dist/learning-batch.js +3 -3
- package/dist/learning-cost.d.ts +26 -8
- package/dist/learning-cost.js +17 -7
- package/dist/learning-routes.d.ts +2 -4
- package/dist/learning-routes.js +20 -3
- package/dist/learning-words.d.ts +1 -1
- package/dist/learning-words.js +4 -1
- package/dist/learning.d.ts +5 -5
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/local-models.d.ts +33 -2
- package/dist/local-models.js +43 -5
- package/dist/mcp-pin-first.js +6 -0
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +25 -16
- package/dist/mcp-servers-store.js +23 -3
- package/dist/model-form.d.ts +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +26 -6
- package/dist/model.js +126 -18
- package/dist/monid.d.ts +26 -31
- package/dist/monid.js +84 -79
- package/dist/native/binding.d.ts +13 -0
- package/dist/native/binding.js +57 -0
- package/dist/native/cli.d.ts +2 -0
- package/dist/native/cli.js +48 -0
- package/dist/native/connection.d.ts +8 -0
- package/dist/native/connection.js +94 -0
- package/dist/native/context.d.ts +6 -0
- package/dist/native/context.js +22 -0
- package/dist/native/discovery.d.ts +27 -0
- package/dist/native/discovery.js +404 -0
- package/dist/native/environment.d.ts +4 -0
- package/dist/native/environment.js +18 -0
- package/dist/native/history.d.ts +20 -0
- package/dist/native/history.js +147 -0
- package/dist/native/instructions.d.ts +21 -0
- package/dist/native/instructions.js +173 -0
- package/dist/native/remote-worker-bridge.d.ts +3 -0
- package/dist/native/remote-worker-bridge.js +278 -0
- package/dist/native/remote.d.ts +187 -0
- package/dist/native/remote.js +492 -0
- package/dist/native/runtime.d.ts +17 -0
- package/dist/native/runtime.js +316 -0
- package/dist/native/runtimes.d.ts +66 -0
- package/dist/native/runtimes.js +41 -0
- package/dist/native/schema.d.ts +46 -0
- package/dist/native/schema.js +41 -0
- package/dist/native/types.d.ts +87 -0
- package/dist/native/types.js +1 -0
- package/dist/observation/http.d.ts +4 -0
- package/dist/observation/http.js +140 -0
- package/dist/observation/observer.d.ts +301 -0
- package/dist/observation/observer.js +919 -0
- package/dist/observation/schema.d.ts +52 -0
- package/dist/observation/schema.js +154 -0
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +394 -85
- package/dist/paid-calls.d.ts +8 -3
- package/dist/paid-calls.js +6 -2
- package/dist/place-offers.d.ts +4 -8
- package/dist/place-offers.js +4 -9
- package/dist/port-models.d.ts +7 -2
- package/dist/port-models.js +5 -2
- package/dist/print.d.ts +4 -2
- package/dist/print.js +4 -3
- package/dist/propose.d.ts +1 -2
- package/dist/propose.js +10 -1
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +8 -0
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +13 -2
- package/dist/run-launch.d.ts +10 -1
- package/dist/run-launch.js +11 -4
- package/dist/run-learning-served.d.ts +75 -2
- package/dist/run-manifest.d.ts +3 -0
- package/dist/run-manifest.js +13 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +8 -9
- package/dist/run-view.d.ts +42 -35
- package/dist/run-view.js +79 -44
- package/dist/runnable.d.ts +13 -5
- package/dist/runnable.js +69 -60
- package/dist/runner/adapter-loop.d.ts +42 -11
- package/dist/runner/adapter-loop.js +651 -247
- package/dist/runner/adapter-run-spec.d.ts +37 -12
- package/dist/runner/adapter-run-spec.js +139 -106
- package/dist/runner/adapters/pi.d.ts +24 -0
- package/dist/runner/adapters/pi.js +59 -9
- package/dist/runner/beside.d.ts +3 -1
- package/dist/runner/beside.js +24 -8
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +28 -4
- package/dist/runner/cli-run-spec.d.ts +30 -0
- package/dist/runner/cli-run-spec.js +94 -50
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +3 -2
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.js +6 -3
- package/dist/runner/end-of-run.d.ts +2 -0
- package/dist/runner/end-of-run.js +3 -1
- package/dist/runner/feedback-round.d.ts +40 -13
- package/dist/runner/feedback-round.js +64 -16
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +37 -13
- package/dist/runner/journal-kinds.js +9 -5
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +4 -0
- package/dist/runner/learning-end.js +64 -36
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +2 -0
- package/dist/runner/learning-loop.js +19 -4
- package/dist/runner/loop.d.ts +18 -0
- package/dist/runner/loop.js +34 -0
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-run.d.ts +4 -1
- package/dist/runner/mcp-run.js +11 -5
- package/dist/runner/meta-tools.d.ts +10 -3
- package/dist/runner/meta-tools.js +112 -36
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +114 -39
- package/dist/runner/model-route.d.ts +12 -3
- package/dist/runner/model-route.js +139 -18
- package/dist/runner/monid-run.d.ts +8 -6
- package/dist/runner/monid-run.js +117 -43
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +74 -8
- package/dist/runner/promotion.js +365 -124
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.js +9 -0
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +8 -4
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/workflow-first.d.ts +30 -20
- package/dist/runner/workflow-first.js +22 -32
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +18 -12
- package/dist/runner/workflow-spec.d.ts +4 -1
- package/dist/runner/workflow-spec.js +56 -45
- package/dist/runs-over-store.d.ts +30 -2
- package/dist/runs-over-store.js +46 -14
- package/dist/sdk/runs.d.ts +115 -0
- package/dist/sdk/runs.js +422 -0
- package/dist/sdk/schema.d.ts +175 -0
- package/dist/sdk/schema.js +138 -0
- package/dist/sdk/workflows.d.ts +22 -0
- package/dist/sdk/workflows.js +39 -0
- package/dist/secrets.d.ts +2 -0
- package/dist/secrets.js +19 -1
- package/dist/server.d.ts +48 -32
- package/dist/server.js +554 -130
- package/dist/skill-route.d.ts +3 -0
- package/dist/skill-route.js +16 -0
- package/dist/skills/agentrun-serve/SKILL.md +368 -0
- package/dist/stats.d.ts +10 -10
- package/dist/store/agent-body.d.ts +12 -8
- package/dist/store/agent-body.js +9 -4
- package/dist/store/index.d.ts +1 -1
- package/dist/store/native-command-owner.d.ts +10 -0
- package/dist/store/native-command-owner.js +47 -0
- package/dist/store/postgres/migrations/0012_revision_monid_pin.sql +4 -0
- package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
- package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
- package/dist/store/postgres/store.js +3 -0
- package/dist/store/schema.d.ts +7 -0
- package/dist/store/schema.js +20 -1
- package/dist/store/sqlite/run-patch.d.ts +8 -1
- package/dist/store/sqlite/run-patch.js +14 -3
- package/dist/store/sqlite/store.js +133 -18
- package/dist/store/store.d.ts +52 -7
- package/dist/store-reads/analytics.d.ts +7 -7
- package/dist/store-reads/analytics.js +23 -5
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/journal.d.ts +5 -0
- package/dist/store-reads/journal.js +85 -41
- package/dist/store-reads/learning.d.ts +85 -5
- package/dist/store-reads/learning.js +45 -17
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.js +75 -21
- package/dist/template-eval.d.ts +73 -11
- package/dist/template-eval.js +535 -75
- package/dist/templates.d.ts +70 -20
- package/dist/templates.js +191 -34
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/index.d.ts +3 -2
- package/dist/timeline/index.js +3 -2
- package/dist/timeline/labels.d.ts +5 -2
- package/dist/timeline/labels.js +29 -6
- package/dist/timeline/origin.d.ts +1 -1
- package/dist/timeline/origin.js +2 -2
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +66 -4
- package/dist/timeline/timeline.js +160 -30
- package/dist/timeline/util.d.ts +5 -0
- package/dist/timeline/util.js +44 -8
- package/dist/timeline/web-calls.d.ts +17 -0
- package/dist/timeline/web-calls.js +106 -0
- package/dist/tool-gate.d.ts +42 -42
- package/dist/tool-gate.js +97 -91
- package/dist/tool-list.d.ts +4 -1
- package/dist/tool-list.js +8 -1
- package/dist/tool-names.d.ts +18 -13
- package/dist/tool-names.js +19 -17
- package/dist/tool-plane.d.ts +17 -13
- package/dist/tool-plane.js +12 -5
- package/dist/tools.d.ts +44 -16
- package/dist/tools.js +28 -28
- package/dist/trigger-adapter.d.ts +85 -5
- package/dist/trigger-adapter.js +6 -0
- package/dist/trigger-adapters.js +3 -1
- package/dist/trigger-composio.d.ts +10 -0
- package/dist/trigger-composio.js +122 -0
- package/dist/trigger-email.d.ts +4 -0
- package/dist/trigger-email.js +228 -0
- package/dist/trigger-signatures.d.ts +6 -10
- package/dist/trigger-signatures.js +16 -16
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +4 -3
- package/dist/trigger-webhook.js +6 -4
- package/dist/triggers.d.ts +94 -9
- package/dist/triggers.js +263 -62
- package/dist/uploads.d.ts +9 -0
- package/dist/uploads.js +27 -0
- package/dist/validate.js +1 -7
- package/dist/web-fake.d.ts +56 -0
- package/dist/web-fake.js +102 -0
- package/dist/web-fetch-direct.d.ts +3 -0
- package/dist/web-fetch-direct.js +4 -1
- package/dist/web-fetch.d.ts +5 -1
- package/dist/web-fetch.js +8 -31
- package/dist/web-search.d.ts +51 -2
- package/dist/web-search.js +116 -18
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -1
- package/dist/workflow/node-runner.js +10 -2
- package/dist/workspace/archil-claim.d.ts +3 -0
- package/dist/workspace/archil-claim.js +9 -2
- package/dist/workspace/computer-deps.d.ts +22 -9
- package/dist/workspace/computer-deps.js +78 -37
- package/dist/workspace/computer-for-claim.d.ts +54 -4
- package/dist/workspace/computer-for-claim.js +179 -39
- package/dist/workspace/computer-janitor.d.ts +10 -3
- package/dist/workspace/computer-janitor.js +96 -29
- package/dist/workspace/computer-kept.d.ts +82 -0
- package/dist/workspace/computer-kept.js +147 -0
- package/dist/workspace/computer-mcp.js +4 -3
- package/dist/workspace/computer-ports.d.ts +23 -3
- package/dist/workspace/computer-ports.js +115 -5
- package/dist/workspace/index.d.ts +1 -2
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +25 -18
- package/dist/workspace/kind-skills/phone/SKILL.md +28 -17
- package/dist/workspace/resolve-computer.d.ts +15 -3
- package/dist/workspace/resolve-computer.js +10 -7
- package/dist/workspace/revision-skills.d.ts +6 -2
- package/dist/workspace/revision-skills.js +12 -5
- package/dist/workspace/run-end-computers.d.ts +30 -0
- package/dist/workspace/run-end-computers.js +137 -0
- package/dist/workspace/run-tools.d.ts +28 -29
- package/dist/workspace/run-tools.js +29 -30
- package/dist/wrap-up.d.ts +19 -5
- package/dist/wrap-up.js +31 -4
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +117 -23
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +18 -4
- package/templates/code-review/evals/mentions-defused/case.yaml +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
- package/templates/code-review/evals/other-repo/case.yaml +1 -1
- package/templates/code-review/evals/pasted-by-reference/case.yaml +5 -0
- package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
- package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
- package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -0
- package/templates/code-review/skills/review/DEEP.md +2 -2
- package/templates/code-review/skills/review/REVIEWER.md +2 -2
- package/templates/code-review/skills/review/SKILL.md +7 -3
- package/templates/release-notes/evals/draft-not-publish/case.yaml +1 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +1 -1
- package/templates/release-notes/evals/late-arrival/case.yaml +1 -1
- package/templates/release-notes/evals/other-repo/case.yaml +1 -1
- package/dist/console/assets/index-CjqQirbo.css +0 -1
- package/dist/console/assets/index-b6-XY5A9.js +0 -576
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -9
- package/dist/runner/adapters/pi-computer.js +0 -51
- package/dist/workspace/computer-script.d.ts +0 -53
- package/dist/workspace/computer-script.js +0 -172
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
// A grade's feedback round: what a run's grade (PUT /runs/{id}/grade, a person's feedback or an eval's label) asks of its
|
|
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
|
+
// the agent answer the job again:
|
|
4
|
+
// - a run its learned workflow answered alone (path `workflow`), graded right: the grade is kept (replay and refit
|
|
5
|
+
// read it) and nothing else happens: no turn, $0;
|
|
6
|
+
// - the same, graded wrong: a revision ask for that workflow. The run opens again on a feedback round: the grade's
|
|
7
|
+
// words are on its record, the agent is asked no turn of the job's, and the run goes straight to its end-of-run turn,
|
|
8
|
+
// whose look-back hears the job, the workflow's answer and the grade's words (notes), and whose compile turn asks for
|
|
9
|
+
// the workflow again, changed (learning-end.ts compileAskOf). Its spend is learning spend, and the run's path stays
|
|
10
|
+
// `workflow`;
|
|
11
|
+
// - a run the agent finished (path `agent` or `handed_back`) graded with words (`label`): a look-back round on them
|
|
12
|
+
// (#2579's later round, notes), the same way: no turn of the job's, the end-of-run turn reading the words.
|
|
13
|
+
// A grade with neither asks for nothing more. The server writes the round's steer (server.ts gradeRun, runs.reopen); the
|
|
14
|
+
// adapter loop takes it (adapter-loop.ts steer: a FEEDBACK entry, no turn), and the end-of-run step reads it
|
|
15
|
+
// (learning-end.ts: heard, never "nothing new"; adapter-loop.ts askEndOfRun: feedbackAsk before the prompt).
|
|
16
|
+
import { markGradeRound, putGrade } from "../learn/promote.js";
|
|
1
17
|
import { readLaunchBody } from "../run-launch.js";
|
|
2
18
|
import { RunFinal } from "../store/store.js";
|
|
3
19
|
import { KINDS } from "./journal-kinds.js";
|
|
20
|
+
import { commandRequest } from "./loop.js";
|
|
4
21
|
import { servedAnswerText } from "./workflow-first.js";
|
|
5
22
|
export const FEEDBACK_ROUNDS = ["revise", "look_back"];
|
|
6
|
-
/** The most characters a grade's words (`label`) may hold. */
|
|
7
|
-
export const LABEL_MAX = 4000;
|
|
8
23
|
/** What a grade asks for: `revise` for a wrong grade of a run its learned workflow answered alone, `look_back` for a
|
|
9
24
|
* graded run the agent finished when the grade has words, else none (undefined). A replay run is never graded. */
|
|
10
25
|
export function feedbackRoundOf(grade, label) {
|
|
@@ -14,14 +29,13 @@ export function feedbackRoundOf(grade, label) {
|
|
|
14
29
|
return label ? "look_back" : undefined;
|
|
15
30
|
return undefined;
|
|
16
31
|
}
|
|
17
|
-
/** The grade's words as the round says them: its `label`, else
|
|
18
|
-
*
|
|
19
|
-
|
|
32
|
+
/** The grade's words as the round says them: its `label`, else the fields a right answer holds (`expected`), else
|
|
33
|
+
* "(no words)". Never the verdict: feedbackAsk and the compile ask each say it once. (A right grade opens a round only
|
|
34
|
+
* with a label (feedbackRoundOf), so none reaches here without one.) */
|
|
35
|
+
export function feedbackWords(label, expected) {
|
|
20
36
|
if (label?.trim())
|
|
21
37
|
return label.trim();
|
|
22
|
-
|
|
23
|
-
return "A reviewer graded this run's answer right.";
|
|
24
|
-
return `A reviewer graded this run's answer wrong.${expected ? ` A right answer holds: ${JSON.stringify(expected)}` : ""}`;
|
|
38
|
+
return expected ? `A right answer holds: ${JSON.stringify(expected)}` : "(no words)";
|
|
25
39
|
}
|
|
26
40
|
/** The feedback round a steer's body asks for (`body.feedback`, the server's own: server.ts gradeRun writes it, and the
|
|
27
41
|
* message API never does), else undefined. */
|
|
@@ -48,12 +62,33 @@ export function feedbackAsk(feedback, seen) {
|
|
|
48
62
|
const graded = `A reviewer graded ${seen ? "that" : "this run's"} answer ${feedback.correct ? "right" : "wrong"}. What they said:`;
|
|
49
63
|
return [...(seen ? [seen.job, servedAnswerText(seen.served.workflow, seen.served.answer)] : []), graded, "", feedback.text].join("\n\n").replace(/\n{3,}/g, "\n\n");
|
|
50
64
|
}
|
|
65
|
+
/** How a feedback round stands (GET /runs/{id}/learning `graded.feedback_status`): `running` until it settles; `ended`,
|
|
66
|
+
* its run took the grade's words and ended after them; `not_run`, its run ended before it took them. */
|
|
67
|
+
export const FEEDBACK_STATUSES = ["running", "ended", "not_run"];
|
|
68
|
+
/** How the feedback round opened on steer `command` (store.runs.reopen's row, read now) stands, never by a clock:
|
|
69
|
+
* - `ended`: in its run's root `entries`, the FEEDBACK entry that took the steer (its requestId names the command) has
|
|
70
|
+
* the run's end entry after it, both in journal order (one writer, the run's runner);
|
|
71
|
+
* - `not_run`: no FEEDBACK entry took it and the row is refused. A runner writes nothing for the steer before that entry,
|
|
72
|
+
* so a reopened run that ends first (its claim refused, an end with nothing sent) leaves no trace of the round in its
|
|
73
|
+
* journal: its end's own commit refuses the row (the store's refuseLeftovers), in the same transaction as that end;
|
|
74
|
+
* - else `running`: the steer untaken (no runner took it yet; an end that left it so opened the run again with it), or
|
|
75
|
+
* taken with no end since, or a row that can't be read. */
|
|
76
|
+
export function feedbackStatus(entries, command) {
|
|
77
|
+
if (!command)
|
|
78
|
+
return "running";
|
|
79
|
+
const request = commandRequest(command.id);
|
|
80
|
+
const at = entries.findIndex((entry) => entry.kind === KINDS.feedback && entry.data?.requestId === request);
|
|
81
|
+
if (at >= 0)
|
|
82
|
+
return entries.slice(at + 1).some((entry) => entry.kind === KINDS.end) ? "ended" : "running";
|
|
83
|
+
return command.refused !== null ? "not_run" : "running";
|
|
84
|
+
}
|
|
51
85
|
/** Opens run `grade.run` again on the feedback round its grade asks for (feedbackRoundOf), with the grade's words
|
|
52
|
-
* (`label`, else feedbackWords'), and says which: only a run that learns (its launch's learning start,
|
|
53
|
-
* only uses what was learned, nor a notes-only run's revision ask),
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
86
|
+
* (`label`, else feedbackWords'), and says which, with its steer: only a run that learns (its launch's learning start,
|
|
87
|
+
* never one that only uses what was learned, nor a notes-only run's revision ask), whose runner supports managed
|
|
88
|
+
* feedback, neither archived nor of an archived
|
|
89
|
+
* agent (closed history: a grade of it starts no paid work), and one the store opens again (an agentic run that answered
|
|
90
|
+
* or that a person stopped). Null when the grade asks for nothing more, or the run can't be opened again (the grade is
|
|
91
|
+
* kept either way). */
|
|
57
92
|
export async function openFeedbackRound(store, grade, label) {
|
|
58
93
|
const words = label?.trim() ? label.trim() : undefined;
|
|
59
94
|
const round = feedbackRoundOf(grade, words);
|
|
@@ -63,13 +98,17 @@ export async function openFeedbackRound(store, grade, label) {
|
|
|
63
98
|
if (!run || run.archivedAt !== null || (await store.agents.get(run.agentId))?.archivedAt !== null)
|
|
64
99
|
return null;
|
|
65
100
|
const launched = await store.runs.launch(grade.run).catch(() => undefined);
|
|
66
|
-
const
|
|
101
|
+
const launch = launched ? readLaunchBody(launched.body) : undefined;
|
|
102
|
+
// Source sessions and application-owned SDK tasks cannot consume a managed feedback steer.
|
|
103
|
+
if (launch?.native || launch?.sdk)
|
|
104
|
+
return null;
|
|
105
|
+
const learning = launch?.learning;
|
|
67
106
|
if (!learning || learning.use || (round === "revise" && learning.notesOnly))
|
|
68
107
|
return null;
|
|
69
108
|
const feedback = { round, correct: grade.correct, ...(round === "revise" && grade.workflow ? { workflow: grade.workflow } : {}) };
|
|
70
109
|
try {
|
|
71
|
-
await store.runs.reopen(grade.run, { kind: "steer", body: { text: feedbackWords(
|
|
72
|
-
return round;
|
|
110
|
+
const steer = await store.runs.reopen(grade.run, { kind: "steer", body: { text: feedbackWords(words, grade.expected), feedback } });
|
|
111
|
+
return { round, command: steer.id };
|
|
73
112
|
}
|
|
74
113
|
catch (error) {
|
|
75
114
|
if (error instanceof RunFinal)
|
|
@@ -77,3 +116,12 @@ export async function openFeedbackRound(store, grade, label) {
|
|
|
77
116
|
throw error;
|
|
78
117
|
}
|
|
79
118
|
}
|
|
119
|
+
/** A grade's write (PUT /runs/{id}/grade): keeps `grade` for agent `agentId` naming no round, opens its run again on the
|
|
120
|
+
* round it asks for (openFeedbackRound), and only then marks the kept grade with that round and its steer. The grade is
|
|
121
|
+
* kept first, so the round's end reads it; the round is named last, so a reopen that fails (thrown, or a run that can't
|
|
122
|
+
* be opened again) leaves a grade naming none, never one claiming a round that didn't open. The grade as kept. */
|
|
123
|
+
export async function keepGrade(store, agentId, grade, label) {
|
|
124
|
+
const kept = await putGrade(store.settings, agentId, { ...grade, feedback: null });
|
|
125
|
+
const opened = await openFeedbackRound(store, kept, label);
|
|
126
|
+
return opened ? markGradeRound(store.settings, agentId, kept, opened) : kept;
|
|
127
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { createSdkLoop, sdkSourceInstructions } from "./sdk-loop.js";
|
|
2
|
+
import { sdkOf } from "../sdk/runs.js";
|
|
3
|
+
import { createNativeLoop, nativeLearningLoop, nativeSourceInstructions } from "./native-loop.js";
|
|
4
|
+
import { nativeOf } from "../native/binding.js";
|
|
1
5
|
// The runner's dispatch switch (design 2.1: "the runner takes every run"): which loop a claimed run runs, by its revision
|
|
2
6
|
// and the harness its launch names. The runner holds one dispatch loop (dispatch.ts) for every run; at the claim the
|
|
3
7
|
// dispatch reads the launch and asks this switch for the run's inner loop:
|
|
@@ -41,12 +45,25 @@ export function resolveRunnerLoop(deps) {
|
|
|
41
45
|
// store-secrets.ts), and every one the server keeps is held by the run's one redactor.
|
|
42
46
|
return createWorkflowLoop(workflowSpecOf({ store: deps.store, sealKey: deps.sealKey, data: deps.data, ...(deps.env ? { env: deps.env } : {}) }));
|
|
43
47
|
}
|
|
48
|
+
if (harness !== "learning" && launch.sdk)
|
|
49
|
+
return createSdkLoop(launch, deps, async () => {
|
|
50
|
+
const base = deps.env ?? process.env;
|
|
51
|
+
const env = withModelKeys(base, await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: base }));
|
|
52
|
+
return gradeRouteFor({ model: launch.learning.gradeModel, agentId: run.agentId }, env, deps.routeOf);
|
|
53
|
+
});
|
|
54
|
+
if (harness !== "learning" && launch.native)
|
|
55
|
+
return createNativeLoop(launch, deps);
|
|
44
56
|
if (harness === "learning") {
|
|
57
|
+
const native = nativeOf(revision?.body);
|
|
58
|
+
if (native && !launch.model)
|
|
59
|
+
return nativeLearningLoop(deps, native);
|
|
45
60
|
// A built-in learning run on the learning loop: its grade goes through the runner's one model route, on the grade
|
|
46
61
|
// model its launch names (none: the agent's own), at that route's price (learning-dispatch.ts).
|
|
47
62
|
return learningLoopOf({
|
|
48
63
|
store: deps.store,
|
|
49
64
|
data: deps.data,
|
|
65
|
+
...(sdkOf(revision?.body) ? { sourceInstructions: (runId) => sdkSourceInstructions(deps.store, runId) } : {}),
|
|
66
|
+
...(native ? { sourceInstructions: (runId) => nativeSourceInstructions(deps.store, runId) } : {}),
|
|
50
67
|
// The grader speaks the route's wire, as pi does (learning-ask.ts: pi.ts policyFor and port-models.ts
|
|
51
68
|
// sessionProvider), so its route is asked on pi's wires; a model on neither keeps the route's Messages translation.
|
|
52
69
|
// A grade model whose vendor this host reaches only through OpenRouter goes there as main's grade does
|
|
@@ -60,11 +60,6 @@ export declare const KINDS: {
|
|
|
60
60
|
* (adapter-loop.ts pauseFor), and a claim lost before that restores it from here (pendingPauseOf). No run patch, and
|
|
61
61
|
* neither a call nor a message, so the reader passes over it. */
|
|
62
62
|
readonly pausePending: "agentrun.pause.pending";
|
|
63
|
-
/** On the run's model session (resume log, never read as a call or a message): the session's recent requests as the
|
|
64
|
-
* cap's expected pricing reads them (the kernel's RecentRequest list, recentAfter), written each time one answers.
|
|
65
|
-
* A later claim or pass starts from the newest record, so its first request reads the cache a recent answer left warm
|
|
66
|
-
* when it ended under CACHE_WARM_MS ago by the cap's clock, and uncached after that (adapter-loop.ts recentIn). */
|
|
67
|
-
readonly capRecent: "agentrun.cap.recent";
|
|
68
63
|
/** A workflow call node's effect, as it starts and as it ends (pause.ts NodeLine: its path, item, tool, label, input,
|
|
69
64
|
* then its status and output or error), on the run's node-log session (NODE_LOG_SESSION): the run's graph lists its
|
|
70
65
|
* effects from these. Written as the effect runs, never for one the driver answers from its receipt. */
|
|
@@ -79,10 +74,19 @@ export declare const KINDS: {
|
|
|
79
74
|
* later claim that asks the same turn again reads the first ask's (the commit of main a compile turn was asked at among
|
|
80
75
|
* them), never its own. Neither a call nor a message: the reader passes over it. */
|
|
81
76
|
readonly endOfRunKept: "agentrun.end-of-run.kept";
|
|
77
|
+
/** How the run's job's own turn ended (JobEndData: the end it gives the run, a CLI's error answer), as the claim that
|
|
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
|
+
* open ends the run on the newest one, never working the job's end out again. Neither a call nor a message. */
|
|
80
|
+
readonly jobEnd: "agentrun.end-of-run.job";
|
|
82
81
|
/** What a learning run's claim laid of its seed: the learned skills it was given (`skills`, by name) and the learned
|
|
83
82
|
* workflows its learned_workflow tool runs (`workflows`, by name). Written once per claim, on the root; the newest is
|
|
84
83
|
* what the run was given. Neither a call nor a message. */
|
|
85
84
|
readonly learningLaid: "agentrun.learning.laid";
|
|
85
|
+
/** The claim made the run a computer of its own (`computer`: its kind, desktop, sandbox or phone; computer-for-claim.ts
|
|
86
|
+
* ClaimComputer.made): written on the root at the claim's first pass. A later claim's computer is a new one, and this
|
|
87
|
+
* entry is how that claim knows the run had one when nothing of the earlier claim's is left to let go (a server's
|
|
88
|
+
* stop, a park): computer-journal.ts hadComputer. Neither a call nor a message, and never on the Timeline. */
|
|
89
|
+
readonly computerMade: "agentrun.computer.made";
|
|
86
90
|
/** A grade's feedback round (runner/feedback-round.ts): the run opened again on a grade's words, asked no turn of the
|
|
87
91
|
* job's; its next end's end-of-run turn reads them (`text`, the `round`, whether the grade said right, the workflow a
|
|
88
92
|
* revision is asked of). Written on the root by the commit that takes the round's steer row. Neither a call nor a
|
|
@@ -162,19 +166,18 @@ export declare function capNowOf(launchCapUsd: number | undefined, entries: read
|
|
|
162
166
|
readonly kind: string;
|
|
163
167
|
readonly data?: unknown;
|
|
164
168
|
}[]): number | undefined;
|
|
165
|
-
/** What a run parked at its cap waits on (the kernel cap's parkOf): its cap, what
|
|
166
|
-
* refused request needs, the least cap that sends it and the raise offered, in the run's
|
|
169
|
+
/** What a run parked at its cap waits on (the kernel cap's parkOf): its cap, what it had spent, what it held for steps
|
|
170
|
+
* still running, the least the refused request needs, the least cap that sends it and the raise offered, in the run's
|
|
171
|
+
* money units (dollars). */
|
|
167
172
|
export interface BudgetData {
|
|
168
|
-
/** `bound_usd`: the most a cache miss could have added to the refused step (the refusal's boundUsd; 0 when none), the
|
|
169
|
-
* budget card's overshoot bound. */
|
|
170
173
|
readonly pending: {
|
|
171
174
|
readonly kind: "budget";
|
|
172
175
|
readonly cap_usd: number;
|
|
173
176
|
readonly spent_usd: number;
|
|
177
|
+
readonly held_usd: number;
|
|
174
178
|
readonly needs_usd: number;
|
|
175
179
|
readonly least_cap_usd: number;
|
|
176
180
|
readonly suggested_cap_usd: number;
|
|
177
|
-
readonly bound_usd: number;
|
|
178
181
|
};
|
|
179
182
|
/** The cap's words, as the run row's summary says them. */
|
|
180
183
|
readonly words: string;
|
|
@@ -184,6 +187,8 @@ export interface BudgetData {
|
|
|
184
187
|
}
|
|
185
188
|
export interface CallStartData {
|
|
186
189
|
readonly callId: string;
|
|
190
|
+
/** A checked SDK workflow callback's owning learned_workflow invocation. */
|
|
191
|
+
readonly parentCallId?: string;
|
|
187
192
|
readonly tool: string;
|
|
188
193
|
readonly input: unknown;
|
|
189
194
|
/** May run again after a crash (it changes nothing outside the run): the tool registry's own flag. */
|
|
@@ -193,8 +198,13 @@ export interface CallStartData {
|
|
|
193
198
|
* so no waiting result shows for it, as on pi. */
|
|
194
199
|
readonly parked?: true;
|
|
195
200
|
/** A tool that only nests calls (tools_call, codemode; HostTool.nests): its calls start after it, each its own, and it
|
|
196
|
-
* runs again whole after a crash, so a start a crash left open is never ended interrupted (adapter-loop.ts).
|
|
201
|
+
* runs again whole after a crash, so a start a crash left open is never ended interrupted (adapter-loop.ts). A call of
|
|
202
|
+
* a harness's own that calls nest in (Codex's code-mode `exec`, SessionIO.ownCalls) is marked so too: its harness ends
|
|
203
|
+
* it after the resume, from its CLI's answer to it. */
|
|
197
204
|
readonly nests?: true;
|
|
205
|
+
/** The call of the harness's own this one runs inside (Codex's code-mode `exec`, SessionIO.ownCalls): its rows sit under
|
|
206
|
+
* that call's, as a call a host tool that `nests` made sits under it by its id (`<callId>/<key>`). */
|
|
207
|
+
readonly parent?: string;
|
|
198
208
|
/** The harness's working directory (a CLI's), which an absolute path in `input` is built from: the run's rows name a
|
|
199
209
|
* path under it by its name in the workspace (store-reads/journal.ts runTimeline). */
|
|
200
210
|
readonly cwd?: string;
|
|
@@ -206,6 +216,9 @@ export interface CallEndData {
|
|
|
206
216
|
readonly callId: string;
|
|
207
217
|
readonly status: CallStatus;
|
|
208
218
|
readonly output?: unknown;
|
|
219
|
+
/** On an `interrupted` end the run's own end wrote (a call that only nests calls, still open: adapter-loop.ts openNests):
|
|
220
|
+
* nothing ended it, so it has no outcome. Its row reads interrupted, never failed (CALL_ENDED_WITH_RUN). */
|
|
221
|
+
readonly withRun?: true;
|
|
209
222
|
/** When it was written (ms, the loop's clock): the Timeline dates the result's row by it. */
|
|
210
223
|
readonly at?: number;
|
|
211
224
|
}
|
|
@@ -237,8 +250,9 @@ export interface MessageData {
|
|
|
237
250
|
/** When it was written (ms, the loop's clock): the Timeline dates the message's row by it. */
|
|
238
251
|
readonly at?: number;
|
|
239
252
|
}
|
|
240
|
-
/** What an approval costs, as main's card shows it (tool-gate.ts ApprovalPrice): dollars,
|
|
241
|
-
|
|
253
|
+
/** What an approval costs, as main's card shows it (tool-gate.ts ApprovalPrice): dollars, "not metered", or "priced by
|
|
254
|
+
* usage" for a monid endpoint priced by usage. */
|
|
255
|
+
export type ApprovalPrice = number | "not metered" | "priced by usage";
|
|
242
256
|
/** A call the gate asked a person about: what main's approval card shows (tool-gate.ts ApprovalRequest). A parked call
|
|
243
257
|
* has no call.start yet, so its input is here. Optional for an ask written before these fields. */
|
|
244
258
|
export interface AskData {
|
|
@@ -294,6 +308,10 @@ export interface EndData {
|
|
|
294
308
|
/** What the run cost, as its end knows it: null when unknown, which clears a cost an earlier end of the run stored (a
|
|
295
309
|
* follow-up's end). Absent: the stored cost is left as it is. */
|
|
296
310
|
readonly costUsd?: number | null;
|
|
311
|
+
/** Whether `costUsd` is the most the run can have cost, not its cost (RunPatch.costUpperBound; the row reads it back
|
|
312
|
+
* as RunRow.costAtMostUsd, its costUsd then null): it counts a
|
|
313
|
+
* request cut with no answer at what its cap held for it. Written with the cost; absent, false. */
|
|
314
|
+
readonly costUpperBound?: boolean;
|
|
297
315
|
/** The run's metrics (the old StoredMetrics JSON). */
|
|
298
316
|
readonly metrics?: unknown;
|
|
299
317
|
/** A completed workflow run's output: the value at its workflow's output path (readWorkflowRun's `output`, null when it
|
|
@@ -302,6 +320,12 @@ export interface EndData {
|
|
|
302
320
|
/** An escalated workflow run's review (outcome escalated): why it waits for a person, as its escalate node said it. */
|
|
303
321
|
readonly review?: EndReview;
|
|
304
322
|
}
|
|
323
|
+
/** How a run's job's own turn ended (KINDS.jobEnd): the end it gives the run (its summary cut of every secret the runner
|
|
324
|
+
* holds), and a CLI's error answer the end writes as its error row (`failedWith`). */
|
|
325
|
+
export interface JobEndData {
|
|
326
|
+
readonly end: EndData;
|
|
327
|
+
readonly failedWith?: string;
|
|
328
|
+
}
|
|
305
329
|
/** An escalated workflow run's review as its end keeps it: the escalation's kind, the escalate node's label (else the node
|
|
306
330
|
* it escalated at), and its summary (else the run's). Served as the run's `review`, `at` its end. */
|
|
307
331
|
export interface EndReview {
|
|
@@ -60,11 +60,6 @@ export const KINDS = {
|
|
|
60
60
|
* (adapter-loop.ts pauseFor), and a claim lost before that restores it from here (pendingPauseOf). No run patch, and
|
|
61
61
|
* neither a call nor a message, so the reader passes over it. */
|
|
62
62
|
pausePending: "agentrun.pause.pending",
|
|
63
|
-
/** On the run's model session (resume log, never read as a call or a message): the session's recent requests as the
|
|
64
|
-
* cap's expected pricing reads them (the kernel's RecentRequest list, recentAfter), written each time one answers.
|
|
65
|
-
* A later claim or pass starts from the newest record, so its first request reads the cache a recent answer left warm
|
|
66
|
-
* when it ended under CACHE_WARM_MS ago by the cap's clock, and uncached after that (adapter-loop.ts recentIn). */
|
|
67
|
-
capRecent: "agentrun.cap.recent",
|
|
68
63
|
/** A workflow call node's effect, as it starts and as it ends (pause.ts NodeLine: its path, item, tool, label, input,
|
|
69
64
|
* then its status and output or error), on the run's node-log session (NODE_LOG_SESSION): the run's graph lists its
|
|
70
65
|
* effects from these. Written as the effect runs, never for one the driver answers from its receipt. */
|
|
@@ -79,10 +74,19 @@ export const KINDS = {
|
|
|
79
74
|
* later claim that asks the same turn again reads the first ask's (the commit of main a compile turn was asked at among
|
|
80
75
|
* them), never its own. Neither a call nor a message: the reader passes over it. */
|
|
81
76
|
endOfRunKept: "agentrun.end-of-run.kept",
|
|
77
|
+
/** How the run's job's own turn ended (JobEndData: the end it gives the run, a CLI's error answer), as the claim that
|
|
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
|
+
* open ends the run on the newest one, never working the job's end out again. Neither a call nor a message. */
|
|
80
|
+
jobEnd: "agentrun.end-of-run.job",
|
|
82
81
|
/** What a learning run's claim laid of its seed: the learned skills it was given (`skills`, by name) and the learned
|
|
83
82
|
* workflows its learned_workflow tool runs (`workflows`, by name). Written once per claim, on the root; the newest is
|
|
84
83
|
* what the run was given. Neither a call nor a message. */
|
|
85
84
|
learningLaid: "agentrun.learning.laid",
|
|
85
|
+
/** The claim made the run a computer of its own (`computer`: its kind, desktop, sandbox or phone; computer-for-claim.ts
|
|
86
|
+
* ClaimComputer.made): written on the root at the claim's first pass. A later claim's computer is a new one, and this
|
|
87
|
+
* entry is how that claim knows the run had one when nothing of the earlier claim's is left to let go (a server's
|
|
88
|
+
* stop, a park): computer-journal.ts hadComputer. Neither a call nor a message, and never on the Timeline. */
|
|
89
|
+
computerMade: "agentrun.computer.made",
|
|
86
90
|
/** A grade's feedback round (runner/feedback-round.ts): the run opened again on a grade's words, asked no turn of the
|
|
87
91
|
* job's; its next end's end-of-run turn reads them (`text`, the `round`, whether the grade said right, the workflow a
|
|
88
92
|
* revision is asked of). Written on the root by the commit that takes the round's steer row. Neither a call nor a
|
|
@@ -19,6 +19,7 @@ export interface LearningDispatchDeps {
|
|
|
19
19
|
readonly store: Pick<Store, "runs" | "agents" | "learning">;
|
|
20
20
|
/** The server's data directory: each agent's learning folder. */
|
|
21
21
|
readonly data: string;
|
|
22
|
+
readonly sourceInstructions?: (runId: string) => Promise<string>;
|
|
22
23
|
/** The runner's one model route (its pi runs take the same): where a grade goes, on which model, at what price; under
|
|
23
24
|
* --faux, the faux model's. GraderRoute moves to runner/model-route.ts with the route. */
|
|
24
25
|
readonly routeOf: (grade: GradeRouteAsk) => GraderRoute | Promise<GraderRoute>;
|
|
@@ -44,12 +45,12 @@ export interface LearningDispatchDeps {
|
|
|
44
45
|
* dotted name dashed), as its harness's model selection names it (provider.ts modelOn), so the catalog finds it. */
|
|
45
46
|
export declare function gradeRouteOf(model: string | undefined, env: NodeJS.ProcessEnv, routeOf: (model: string | undefined) => GraderRoute | Promise<GraderRoute>): Promise<GraderRoute>;
|
|
46
47
|
/** The learning run's cap on its grade (`capUsd`), the kernel's one rule over its booking (bookedAsk's runBooking): each
|
|
47
|
-
* grader call on `route` judged at its worst case before it leaves, every input token uncached
|
|
48
|
+
* grader call on `route` judged at its worst case before it leaves, every input token uncached and its whole
|
|
48
49
|
* output bound as the least it may be sent with, so a grade never runs on a cut answer. Another model than the route's is
|
|
49
50
|
* priced by nothing here: refused. */
|
|
50
51
|
export declare function gradeCap(capUsd: number, route: GraderRoute): BeforeRequest;
|
|
51
52
|
/** The worst case of the generality check's requests to `jev` (learn/general.ts generalRequest, one a note), each held as a
|
|
52
|
-
* workflow's decision is under its run's cap (decision-cap.ts holdOf
|
|
53
|
+
* workflow's decision is under its run's cap (decision-cap.ts holdOf); unpriced when any one's price is not known
|
|
53
54
|
* here. */
|
|
54
55
|
export declare function generalHeld(jev: DecisionProvider, notes: readonly NoteText[], source: GeneralSource): Promise<{
|
|
55
56
|
usd: number;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// (beforeRequestOf, over the learning run's one booking) at its worst case: its input uncached and its whole output bound
|
|
9
9
|
// (GRADE_MAX_TOKENS), never cut down to fit, so a verdict is never lost to a short answer. A call that doesn't fit is
|
|
10
10
|
// never sent, and the grade is skipped, said so (learning-loop.ts GradeOverCap). The generality pre-check's Jev requests
|
|
11
|
-
// are the grade's spend too: before they leave, their worst case (decision-cap.ts holdOf
|
|
11
|
+
// are the grade's spend too: before they leave, their worst case (decision-cap.ts holdOf: the rule a workflow's
|
|
12
12
|
// decision is held at under its run's cap) is judged against the same cap, less what an earlier attempt's cut check may
|
|
13
13
|
// have spent; a check that doesn't fit is never sent, and is skipped, said so (learning-loop.ts GeneralOverCap), the
|
|
14
14
|
// grader then judged on its own. What the check spent is outside the grade's records, so each grader call's room is the
|
|
@@ -73,21 +73,21 @@ async function gradeOf(store, learningRunId) {
|
|
|
73
73
|
return { route, capUsd: typeof cap === "number" && Number.isFinite(cap) && cap > 0 ? cap : 0 };
|
|
74
74
|
}
|
|
75
75
|
/** The learning run's cap on its grade (`capUsd`), the kernel's one rule over its booking (bookedAsk's runBooking): each
|
|
76
|
-
* grader call on `route` judged at its worst case before it leaves, every input token uncached
|
|
76
|
+
* grader call on `route` judged at its worst case before it leaves, every input token uncached and its whole
|
|
77
77
|
* output bound as the least it may be sent with, so a grade never runs on a cut answer. Another model than the route's is
|
|
78
78
|
* priced by nothing here: refused. */
|
|
79
79
|
export function gradeCap(capUsd, route) {
|
|
80
80
|
const model = capModelOf(route);
|
|
81
|
-
const judge = beforeRequestOf({ capUsd: () => capUsd, modelOf: (id) => (id === route.model ? model : undefined)
|
|
81
|
+
const judge = beforeRequestOf({ capUsd: () => capUsd, modelOf: (id) => (id === route.model ? model : undefined) });
|
|
82
82
|
return (request) => judge({ ...request, ...(request.outputTokensAsked !== undefined ? { outputTokensLeast: request.outputTokensAsked } : {}) });
|
|
83
83
|
}
|
|
84
84
|
/** The worst case of the generality check's requests to `jev` (learn/general.ts generalRequest, one a note), each held as a
|
|
85
|
-
* workflow's decision is under its run's cap (decision-cap.ts holdOf
|
|
85
|
+
* workflow's decision is under its run's cap (decision-cap.ts holdOf); unpriced when any one's price is not known
|
|
86
86
|
* here. */
|
|
87
87
|
export async function generalHeld(jev, notes, source) {
|
|
88
88
|
let usd = 0;
|
|
89
89
|
for (const note of notes) {
|
|
90
|
-
const hold = await holdOf(jev, generalRequest(note, source)
|
|
90
|
+
const hold = await holdOf(jev, generalRequest(note, source));
|
|
91
91
|
if ("unpriced" in hold)
|
|
92
92
|
return hold;
|
|
93
93
|
usd += hold.usd;
|
|
@@ -129,7 +129,7 @@ export function learningLoopOf(deps) {
|
|
|
129
129
|
throw new GeneralOverCap(`its worst case of ${money(held.usd)} is over the ${money(room)} the cap leaves`, false);
|
|
130
130
|
return generalScores(jev, notes, source, signal, run, sending && (() => sending(held.usd)));
|
|
131
131
|
};
|
|
132
|
-
const loop = learningLoopFactory({ store: deps.store, data: deps.data, ask, ...(deps.jev ? { general } : {}), ...(deps.generalThreshold !== undefined ? { generalThreshold: deps.generalThreshold } : {}), ...(deps.log ? { log: deps.log } : {}), ...(deps.now ? { now: deps.now } : {}) })(loopDeps);
|
|
132
|
+
const loop = learningLoopFactory({ store: deps.store, data: deps.data, ask, ...(deps.sourceInstructions ? { sourceInstructions: deps.sourceInstructions } : {}), ...(deps.jev ? { general } : {}), ...(deps.generalThreshold !== undefined ? { generalThreshold: deps.generalThreshold } : {}), ...(deps.log ? { log: deps.log } : {}), ...(deps.now ? { now: deps.now } : {}) })(loopDeps);
|
|
133
133
|
return {
|
|
134
134
|
start: (claim) => {
|
|
135
135
|
claimed = claim.runId;
|
|
@@ -68,6 +68,10 @@ export declare const learningRunIdOf: (runId: string, round?: number) => string;
|
|
|
68
68
|
/** learned_workflow by every name a harness calls it: its own, and claude-agent's host-tool alias (`mcp__hands__<name>`).
|
|
69
69
|
* A harness that names it another way reads as another tool, so its run is asked as before. */
|
|
70
70
|
export declare const LEARNED_NAMES: ReadonlySet<string>;
|
|
71
|
+
/** Over a run's timeline `rows`: whether a row is a call the job's model made, or its result: one at the top, or one a
|
|
72
|
+
* script or tools_call made for it (a call nested in a META_TOOLS call, by any harness's name for it), never a
|
|
73
|
+
* subagent's row or a call another tool nested (a learned workflow's own). */
|
|
74
|
+
export declare function modelsOwn(rows: readonly TimelineEvent[]): (row: TimelineEvent) => boolean;
|
|
71
75
|
/** Whether a run's job, by its timeline `rows` (the end-of-run turn's own, labelled LEARNING_LABEL, left out), gave
|
|
72
76
|
* nothing new to look back on: it called tools, every one of them learned_workflow (a workflow's own nested calls are
|
|
73
77
|
* its), each answering; no tool result failed or was refused; no error, approval or wait; and one message, its first,
|