@parcha/agentrun-serve 0.1.0-beta.43 → 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 +231 -0
- package/README.md +580 -320
- 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 +92 -22
- package/dist/composio-preset.d.ts +4 -3
- package/dist/composio-preset.js +81 -11
- package/dist/composio-triggers.d.ts +34 -2
- package/dist/composio-triggers.js +261 -31
- 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/computer-lost.d.ts +11 -0
- package/dist/computer-lost.js +19 -0
- package/dist/computer-record.d.ts +10 -2
- package/dist/computer-record.js +50 -18
- package/dist/computer-setting.d.ts +1 -0
- package/dist/computer-setting.js +2 -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 +4 -1
- package/dist/errors.js +10 -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 +59 -3
- package/dist/harness-table.js +119 -14
- package/dist/harness.d.ts +17 -1
- package/dist/harness.js +22 -11
- package/dist/host.d.ts +12 -10
- package/dist/host.js +19 -16
- package/dist/import-worker.d.ts +3 -0
- package/dist/import-worker.js +7 -5
- package/dist/import.d.ts +22 -1
- package/dist/import.js +141 -28
- 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 +26 -89
- package/dist/learn/check.js +58 -336
- 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 +88 -103
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +17 -0
- package/dist/learn/delete.js +42 -0
- 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 +20 -2
- package/dist/learn/promote.js +17 -4
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +34 -38
- package/dist/learn/{skills.js → workflow-draft.js} +65 -59
- package/dist/learn/workflow-nodes.d.ts +22 -1
- package/dist/learn/workflow-nodes.js +29 -10
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +127 -13
- package/dist/learning-cost.js +142 -10
- package/dist/learning-routes.d.ts +99 -170
- package/dist/learning-routes.js +199 -420
- 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 +62 -393
- package/dist/learning.js +101 -651
- package/dist/listen-first.d.ts +30 -0
- package/dist/listen-first.js +115 -0
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +2 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +16 -16
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +12 -4
- package/dist/model.js +41 -16
- 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 +375 -347
- package/dist/owner.d.ts +8 -0
- package/dist/owner.js +11 -0
- package/dist/paid-calls.d.ts +14 -0
- package/dist/paid-calls.js +31 -1
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/place.d.ts +8 -3
- package/dist/place.js +13 -9
- 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 +30 -2
- 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 +16 -90
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.d.ts +64 -0
- package/dist/run-model-key.js +147 -0
- 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 +14 -6
- package/dist/runner/adapter-loop.js +25 -14
- package/dist/runner/adapter-run-spec.d.ts +22 -7
- package/dist/runner/adapter-run-spec.js +130 -77
- package/dist/runner/adapters/index.d.ts +4 -2
- package/dist/runner/adapters/index.js +35 -4
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +5 -1
- package/dist/runner/audit.js +31 -12
- package/dist/runner/beside.d.ts +7 -2
- package/dist/runner/beside.js +41 -9
- package/dist/runner/claim-secrets.d.ts +66 -1
- package/dist/runner/claim-secrets.js +136 -3
- package/dist/runner/cli-run-spec.d.ts +2 -1
- package/dist/runner/cli-run-spec.js +82 -59
- package/dist/runner/commands.d.ts +3 -6
- 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 +5 -4
- package/dist/runner/feedback-round.js +14 -10
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +30 -56
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +7 -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 -66
- package/dist/runner/learning-end.js +250 -299
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +8 -3
- package/dist/runner/loop-contract.js +4 -0
- package/dist/runner/loop.js +6 -2
- package/dist/runner/main.d.ts +18 -9
- package/dist/runner/main.js +82 -22
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +14 -6
- package/dist/runner/memory-claim.js +18 -9
- 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 +13 -6
- package/dist/runner/promotion.js +63 -17
- package/dist/runner/reflect-hook.d.ts +64 -91
- package/dist/runner/reflect-hook.js +112 -206
- 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 +58 -9
- 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 +14 -6
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +17 -4
- package/dist/runs-over-store.d.ts +21 -32
- package/dist/runs-over-store.js +44 -41
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/sdk/workflows.d.ts +1 -1
- 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 +119 -83
- package/dist/server.js +1121 -419
- 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 +3 -3
- package/dist/store/index.js +2 -2
- 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/seal.d.ts +20 -2
- package/dist/store/seal.js +24 -8
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-launch.d.ts +4 -1
- package/dist/store/sqlite/run-launch.js +12 -0
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.d.ts +3 -2
- package/dist/store/sqlite/store.js +360 -75
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +231 -39
- package/dist/store/store.js +25 -3
- package/dist/store-reads/analytics.js +11 -1
- package/dist/store-reads/learning.d.ts +131 -194
- package/dist/store-reads/learning.js +292 -301
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-reads/stats.js +13 -3
- package/dist/store-view.d.ts +34 -2
- package/dist/store-view.js +108 -41
- package/dist/telemetry.d.ts +59 -0
- package/dist/telemetry.js +153 -0
- 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/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +13 -13
- package/dist/tools.js +29 -9
- package/dist/trigger-adapter.d.ts +3 -0
- package/dist/trigger-adapters.d.ts +4 -0
- package/dist/trigger-adapters.js +13 -0
- package/dist/trigger-composio.d.ts +58 -1
- package/dist/trigger-composio.js +160 -6
- package/dist/triggers.d.ts +64 -5
- package/dist/triggers.js +141 -17
- package/dist/validate.d.ts +11 -7
- package/dist/validate.js +9 -8
- 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 +22 -8
- package/dist/workspace/computer-for-claim.js +339 -46
- 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 +41 -21
- 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 -9
- 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-BrcDSBD8.css +0 -1
- package/dist/console/assets/index-Bz6IWncl.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 -33
- package/dist/learning-evals.js +0 -98
- 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
|
@@ -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. */
|
|
@@ -68,7 +68,7 @@ export function feedbackStatus(entries, command) {
|
|
|
68
68
|
* agent (closed history: a grade of it starts no paid work), and one the store opens again (an agentic run that answered
|
|
69
69
|
* or that a person stopped). Null when the grade asks for nothing more, or the run can't be opened again (the grade is
|
|
70
70
|
* kept either way). */
|
|
71
|
-
export async function openFeedbackRound(store, grade, label) {
|
|
71
|
+
export async function openFeedbackRound(store, grade, label, canTurn = () => true) {
|
|
72
72
|
const words = label?.trim() ? label.trim() : undefined;
|
|
73
73
|
const round = feedbackRoundOf(grade, words);
|
|
74
74
|
if (!round || !words)
|
|
@@ -84,6 +84,10 @@ export async function openFeedbackRound(store, grade, label) {
|
|
|
84
84
|
const learning = launch?.learning;
|
|
85
85
|
if (!learning || learning.use)
|
|
86
86
|
return null;
|
|
87
|
+
// The round is a turn of the run with no caller's model key (a grade hands none): where the server holds no key for the
|
|
88
|
+
// run's route (`canTurn` false), the grade is kept and the run is not opened again, never left to fail with no key.
|
|
89
|
+
if (launch && !canTurn(launch))
|
|
90
|
+
return null;
|
|
87
91
|
const feedback = { round, correct: grade.correct };
|
|
88
92
|
try {
|
|
89
93
|
const steer = await store.runs.reopen(grade.run, { kind: "steer", body: { text: words, feedback } });
|
|
@@ -99,8 +103,8 @@ export async function openFeedbackRound(store, grade, label) {
|
|
|
99
103
|
* round it asks for (openFeedbackRound), and only then marks the kept grade with that round and its steer. The grade is
|
|
100
104
|
* 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
|
|
101
105
|
* be opened again) leaves a grade naming none, never one claiming a round that didn't open. The grade as kept. */
|
|
102
|
-
export async function keepGrade(store, agentId, grade, label) {
|
|
106
|
+
export async function keepGrade(store, agentId, grade, label, canTurn) {
|
|
103
107
|
const kept = await putGrade(store.settings, agentId, { ...grade, feedback: null });
|
|
104
|
-
const opened = await openFeedbackRound(store, kept, label);
|
|
108
|
+
const opened = await openFeedbackRound(store, kept, label, canTurn);
|
|
105
109
|
return opened ? markGradeRound(store.settings, agentId, kept, opened) : kept;
|
|
106
110
|
}
|
|
@@ -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,24 +1,24 @@
|
|
|
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
|
-
// -
|
|
11
|
-
//
|
|
8
|
+
// - pi runs on the kernel's adapter loop with the run's pi spec (adapterRunSpecFromLaunch), and so does a harness a
|
|
9
|
+
// module adds with no adapter facts of its own, on its runner's adapter;
|
|
12
10
|
// - a CLI harness (claude-agent, codex, opencode) runs on the adapter loop with its own adapter;
|
|
13
11
|
// - anything else fails the run in words (the dispatch's UnknownHarness).
|
|
12
|
+
import { harnessOf } from "../harness-table.js";
|
|
14
13
|
import { hostMemory, neverFits } from "../host.js";
|
|
15
14
|
import { resolveHarness } from "./adapters/index.js";
|
|
16
15
|
import { adapterRunSpecFromLaunch, PI_WIRES } from "./adapter-run-spec.js";
|
|
17
16
|
import { createAdapterLoop } from "./adapter-loop.js";
|
|
18
17
|
import { savedModelKeys, withModelKeys } from "./claim-secrets.js";
|
|
18
|
+
import { noServerKeyFor } from "../run-model-key.js";
|
|
19
19
|
import { createDispatchLoop } from "./dispatch.js";
|
|
20
20
|
import { cliRunSpecFromLaunch } from "./cli-run-spec.js";
|
|
21
|
-
import {
|
|
21
|
+
import { askRouteOf } from "./sdk-ask.js";
|
|
22
22
|
import { ClaimRefused } from "./loop-contract.js";
|
|
23
23
|
import { createWorkflowLoop, isWorkflowRevision } from "./workflow-loop.js";
|
|
24
24
|
import { workflowSpecOf } from "./workflow-spec.js";
|
|
@@ -42,76 +42,50 @@ export function resolveRunnerLoop(deps) {
|
|
|
42
42
|
// store-secrets.ts), and every one the server keeps is held by the run's one redactor.
|
|
43
43
|
return createWorkflowLoop(workflowSpecOf({ store: deps.store, sealKey: deps.sealKey, data: deps.data, ...(deps.env ? { env: deps.env } : {}) }));
|
|
44
44
|
}
|
|
45
|
-
|
|
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)
|
|
46
48
|
return createSdkLoop(launch, deps, async () => {
|
|
47
49
|
const base = deps.env ?? process.env;
|
|
48
50
|
const env = withModelKeys(base, await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: base }));
|
|
49
|
-
|
|
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");
|
|
54
|
+
if (off) {
|
|
55
|
+
deps.log?.(off);
|
|
56
|
+
throw new Error(off);
|
|
57
|
+
}
|
|
58
|
+
return askRouteOf(launch.learning.model, env, (model) => deps.routeOf(model, env, "default", PI_WIRES));
|
|
50
59
|
});
|
|
51
|
-
if (
|
|
60
|
+
if (launch.native)
|
|
52
61
|
return createNativeLoop(launch, deps);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
store: deps.store,
|
|
61
|
-
data: deps.data,
|
|
62
|
-
...(sdkOf(revision?.body) ? { sourceInstructions: (runId) => sdkSourceInstructions(deps.store, runId) } : {}),
|
|
63
|
-
...(native ? { sourceInstructions: (runId) => nativeSourceInstructions(deps.store, runId) } : {}),
|
|
64
|
-
// The grader speaks the route's wire, as pi does (learning-ask.ts: pi.ts policyFor and port-models.ts
|
|
65
|
-
// sessionProvider), so its route is asked on pi's wires; a model on neither keeps the route's Messages translation.
|
|
66
|
-
// A grade model whose vendor this host reaches only through OpenRouter goes there as main's grade does
|
|
67
|
-
// (gradeRouteOf): OpenRouter's key its one credential, priced at OpenRouter's price.
|
|
68
|
-
// The grade's model, main's order (gradeModelFor): the grade model the server names, else the agent's own.
|
|
69
|
-
// Its model's key from the runner's environment, else the one saved in Settings → Model keys (savedModelKeys), read
|
|
70
|
-
// at each grade, so a key saved with no restart grades the next learning run.
|
|
71
|
-
routeOf: async (grade) => {
|
|
72
|
-
const base = deps.env ?? process.env;
|
|
73
|
-
const env = withModelKeys(base, await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: base }));
|
|
74
|
-
return gradeRouteFor(grade, env, deps.routeOf);
|
|
75
|
-
},
|
|
76
|
-
...(deps.log ? { log: deps.log } : {}),
|
|
77
|
-
...(deps.gradeBound ? { gradeBound: deps.gradeBound } : {}),
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
// The harness's own entry decides which spec builds the run, by the entry's facts and never the harness's name: an entry
|
|
81
|
-
// whose visible record the loop keeps (record: "loop") runs the CLI spec (cli-run-spec.ts), one that keeps its own (pi)
|
|
82
|
-
// runs the pi spec (adapterRunSpecFromLaunch). A harness with no entry is unknown here: the dispatch fails it in words.
|
|
83
|
-
const runner = resolveHarness(harness);
|
|
62
|
+
// The harness's own entry decides which spec builds the run, by what the entry gives and never the harness's name: an
|
|
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);
|
|
64
|
+
// any other (pi, or a harness module's entry that gives only the required members) runs the run spec
|
|
65
|
+
// (adapterRunSpecFromLaunch), whose adapter is its runner's (resolveHarness), with the record mode that runner names.
|
|
66
|
+
// A harness with no entry is unknown here: the dispatch fails it in words.
|
|
67
|
+
const env = deps.env ?? process.env;
|
|
68
|
+
const runner = resolveHarness(harness, env);
|
|
84
69
|
if (runner) {
|
|
85
70
|
// A run this host's memory never holds (host.ts neverFits: one run of its harness is more than the host has for runs)
|
|
86
71
|
// fails at its claim, in the words a start of it is refused in here (harness.ts harnessOffers): a run another host
|
|
87
72
|
// started, or one left before this host's memory shrank. Claimed alone (runner.ts claimByMemory), it would run past
|
|
88
73
|
// the host's memory and its OOM kill would take every run on it.
|
|
89
|
-
const tooBig = neverFits(harness, hostMemory());
|
|
74
|
+
const tooBig = neverFits(harness, hostMemory(), env);
|
|
90
75
|
if (tooBig)
|
|
91
76
|
throw new NeverFits(tooBig);
|
|
77
|
+
const entry = harnessOf(env, harness);
|
|
92
78
|
// A run that learns supplies its own end-of-run step (reflect + proposal over its store) from its spec builder now,
|
|
93
79
|
// where the run's Archil claim is: a Mode 2 run's learning folder is on its claim's disk, not this machine's local
|
|
94
80
|
// path (adapter-run-spec.ts / cli-run-spec.ts endOfRun). The loop prefers the spec's step over its deps' (stepOf); a
|
|
95
81
|
// run that does not learn supplies none. The same for the pi and the CLI spec.
|
|
96
|
-
return createAdapterLoop((claim, adapterRun) =>
|
|
82
|
+
return createAdapterLoop((claim, adapterRun) => entry?.facts && entry.adapter
|
|
97
83
|
? cliRunSpecFromLaunch(launch, adapterRun, deps, claim)
|
|
98
|
-
: adapterRunSpecFromLaunch(launch, adapterRun, deps, claim), deps.modelRetry ?? {});
|
|
84
|
+
: adapterRunSpecFromLaunch(launch, adapterRun, deps, claim, runner), deps.modelRetry ?? {});
|
|
99
85
|
}
|
|
100
86
|
return undefined;
|
|
101
87
|
};
|
|
102
88
|
}
|
|
103
|
-
/** The route a grade asks for (gradeModelFor: the grade model the server named, else the agent's own), from the runner's
|
|
104
|
-
* one route (`routeOf`), through gradeRouteOf. A grade model the server named (--grade-model, else AGENT_MODEL_STRONG)
|
|
105
|
-
* 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
|
|
106
|
-
* by AGENT_MODEL_GATEWAY_IDS) and priced at AGENT_MODEL_STRONG_PRICE. The agent's own model goes as its runs' does, on
|
|
107
|
-
* the default tier. */
|
|
108
|
-
export function gradeRouteFor(grade, env, routeOf) {
|
|
109
|
-
return gradeRouteOf(gradeModelFor(grade), env, (model) => (grade.model !== undefined && model === grade.model
|
|
110
|
-
// The runner's environment under the grader as its strong model: every key it holds read through it, a non-enumerable
|
|
111
|
-
// one (a launcher-held or Settings key) too, which a copy would drop.
|
|
112
|
-
? routeOf(undefined, Object.create(env, { AGENT_MODEL_STRONG: { value: model, enumerable: true } }), "strong", PI_WIRES)
|
|
113
|
-
: routeOf(model, env, "default", PI_WIRES)));
|
|
114
|
-
}
|
|
115
89
|
/** The loop factory the runner holds for every run (its createLoop), built from the runner's deps over the one store: the
|
|
116
90
|
* dispatch (dispatch.ts) reads each run's launch and asks resolveRunnerLoop for its harness loop. The server
|
|
117
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
|
|
@@ -240,6 +239,11 @@ export interface MessageData {
|
|
|
240
239
|
* answer's output tokens when known. The loop reads it as pi's stopReason (loop.ts cutLast). */
|
|
241
240
|
readonly stopReason?: "length";
|
|
242
241
|
readonly outputTokens?: number;
|
|
242
|
+
/** The limit it was cut at was the run's cap's (turn_end's capCut): the cap, and the least cap that finishes it. */
|
|
243
|
+
readonly capCut?: {
|
|
244
|
+
readonly capUsd: number;
|
|
245
|
+
readonly raiseToUsd: number;
|
|
246
|
+
};
|
|
243
247
|
/** When it was written (ms, the loop's clock): the Timeline dates the message's row by it. */
|
|
244
248
|
readonly at?: number;
|
|
245
249
|
}
|
|
@@ -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
|
+
}
|