@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
package/dist/runner/promotion.js
CHANGED
|
@@ -15,7 +15,9 @@ import { ClaimRefused } from "./loop-contract.js";
|
|
|
15
15
|
import { readSnapshot } from "../learn/folder.js";
|
|
16
16
|
import { fits, laidFor, servedOf, workflowDigest } from "./workflow-first.js";
|
|
17
17
|
import { excerptShown } from "../learn/secrets.js";
|
|
18
|
+
import { dslRefusalOf } from "../learn/workflow-draft.js";
|
|
18
19
|
import { workflowsAt } from "./learning-seed.js";
|
|
20
|
+
import { held } from "./held.js";
|
|
19
21
|
/** A replay run still not ended this long after its replay started counts as failed (no evidence), and is cancelled once
|
|
20
22
|
* the replay is decided without it. */
|
|
21
23
|
export const REPLAY_DEADLINE_MS = 60 * 60 * 1000;
|
|
@@ -134,7 +136,7 @@ export const promotionGate = (deps) => {
|
|
|
134
136
|
if (kept)
|
|
135
137
|
return { workflow: kept };
|
|
136
138
|
await decide(deps, workflow, digest);
|
|
137
|
-
return await servingNow(deps, workflow, digest, true);
|
|
139
|
+
return await holdRefused(deps, await servingNow(deps, workflow, digest, true));
|
|
138
140
|
}
|
|
139
141
|
catch (error) {
|
|
140
142
|
return failed(workflow, error);
|
|
@@ -144,7 +146,7 @@ export const promotionGate = (deps) => {
|
|
|
144
146
|
const champion = async (workflow, digest) => {
|
|
145
147
|
try {
|
|
146
148
|
const kept = await keptFor(deps, workflow, digest);
|
|
147
|
-
return kept ? { workflow: kept } : await servingNow(deps, workflow, digest, false);
|
|
149
|
+
return kept ? { workflow: kept } : await holdRefused(deps, await servingNow(deps, workflow, digest, false));
|
|
148
150
|
}
|
|
149
151
|
catch (error) {
|
|
150
152
|
return failed(workflow, error);
|
|
@@ -178,6 +180,35 @@ async function servingNow(deps, workflow, digest, laid) {
|
|
|
178
180
|
deps.log(`workflow-first: ${workflow.name}'s champion at ${champion.digest} serves this run while ${digest} ${own?.decided === "promote" ? "is a revision promoted before it" : "is not promoted"}`);
|
|
179
181
|
return { workflow: text };
|
|
180
182
|
}
|
|
183
|
+
/** The words a hold of a serving revision this release's workflow DSL refuses starts with (holdRefused). */
|
|
184
|
+
export const DSL_REFUSES = "this release's workflow DSL refuses it";
|
|
185
|
+
/** `serving` as it serves this run, once a serving revision this release's workflow DSL refuses is held. The refusal is of
|
|
186
|
+
* the text alone (learn/workflow-draft.ts dslRefusalOf: the DSL's own validation, no tool list), never of a host setting (a tool
|
|
187
|
+
* gated, denied or missing, no adapter), which the run's own check still refuses as before. The hold is a promotion
|
|
188
|
+
* record of its digest, `hold` by its reason alone ("this release's workflow DSL refuses it: <code> at <path>: <its
|
|
189
|
+
* words>", cut of the host's secrets as a check's texts are), written only while the digest's newest record is still the
|
|
190
|
+
* promotion this claim read: of two claims at once one writes it, and a later claim finds it (nothing serves). The run
|
|
191
|
+
* still runs it, refused before any node runs, and hands back as before: the agent answers. The hold follows compile
|
|
192
|
+
* once as a check's does: the agent's next due run asks the one recompile with the reason as data (learn/compile.ts
|
|
193
|
+
* heldNamesOf), and that revision's check is the compile's second (attemptOf). */
|
|
194
|
+
async function holdRefused(deps, serving) {
|
|
195
|
+
if (!serving)
|
|
196
|
+
return serving;
|
|
197
|
+
const refused = dslRefusalOf(await import("@parcha/agentrun-dsl"), serving.workflow.workflow);
|
|
198
|
+
if (refused === undefined)
|
|
199
|
+
return serving;
|
|
200
|
+
const { name } = serving.workflow;
|
|
201
|
+
const digest = workflowDigest(serving.workflow);
|
|
202
|
+
const current = promotionOf(await promotionsOf(deps.store.settings, deps.agentId), name, digest);
|
|
203
|
+
if (current?.decided !== "promote")
|
|
204
|
+
return serving;
|
|
205
|
+
const reason = excerptShown(`${DSL_REFUSES}: ${refused}`, await deps.shown(), CHECK_TEXT_MAX);
|
|
206
|
+
const record = { workflow: name, digest, at: iso((deps.now ?? Date.now)()), decided: "hold", reason, ...(current.commit ? { commit: current.commit } : {}) };
|
|
207
|
+
const kept = await recordPromotion(deps.store.settings, deps.agentId, record, (was) => was?.decided === "promote" && was.at === current.at);
|
|
208
|
+
if (kept.won)
|
|
209
|
+
deps.log(`workflow-first: ${name} at ${digest} is held: ${reason}; the agent's next run recompiles it once`);
|
|
210
|
+
return serving;
|
|
211
|
+
}
|
|
181
212
|
/** A run already executing keeps its revision: when an earlier claim of it served `workflow` first (its WORKFLOW_FIRST
|
|
182
213
|
* entry, answered or handed back: `deps.kept`), a re-claim serves the same digest, whoever the champion is now (the loop
|
|
183
214
|
* recovers that outcome as it is, never runs it again). The laid text at that digest, else its text at its record's
|
|
@@ -230,17 +261,19 @@ async function loopOfRevision(deps) {
|
|
|
230
261
|
}
|
|
231
262
|
}
|
|
232
263
|
/** Which check of a compile a new revision's is: 2 when the workflow's newest record of another revision is a first
|
|
233
|
-
* check's hold
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
* compile's recompile too. */
|
|
264
|
+
* check's hold, an audit's hold or a hold by its reason alone (holdRefused: the DSL refuses a serving revision), or a
|
|
265
|
+
* first compile's failed draft (this revision is its one recompile), else 1. A stop with nothing checked
|
|
266
|
+
* (stopUnchecked) is no first check's hold: it spends no recompile. A workflow's first revision after a first compile
|
|
267
|
+
* whose drafts failed under another name (learn/compile.ts newCompileAttempt) is that compile's recompile too. */
|
|
237
268
|
function attemptOf(records, name, digest) {
|
|
238
269
|
const before = records.findLast((one) => one.workflow === name && one.digest !== digest);
|
|
239
270
|
if (!before)
|
|
240
271
|
return newCompileAttempt(records.filter((one) => one.digest !== digest));
|
|
241
272
|
if (before.decided !== "hold")
|
|
242
273
|
return 1;
|
|
243
|
-
|
|
274
|
+
if (before.audit)
|
|
275
|
+
return before.audit.stopped ? 1 : 2;
|
|
276
|
+
return !before.check || (before.check.attempt === 1 && !before.check.stopped) ? 2 : 1;
|
|
244
277
|
}
|
|
245
278
|
/** The shadow runs a recompile's check runs on beside the agent's last runs: the disagreeing audit rows the workflow's
|
|
246
279
|
* newest audit hold names (a grade's row has no answer of the agent's to check against), when that hold is the
|
|
@@ -291,6 +324,11 @@ async function checkInputs(deps, workflow, pick, audited = []) {
|
|
|
291
324
|
* it fits), it is decided at once: never promoted, it stops with nothing checked (stopUnchecked). */
|
|
292
325
|
async function startCheck(deps, workflow, digest) {
|
|
293
326
|
const { store, agentId, log } = deps;
|
|
327
|
+
// Its replay runs are runs the runner starts, on no caller's key: skipped where the claimed run brought its own key or
|
|
328
|
+
// the server holds none (claimSpendOff).
|
|
329
|
+
const off = deps.spendOff?.("A learned workflow's replay check");
|
|
330
|
+
if (off)
|
|
331
|
+
return void log(`workflow-first: ${off} ${workflow.name} at ${digest} is not checked and does not serve this run`);
|
|
294
332
|
// Only the learning folder's newest revision is checked: a run pinned to an older commit lays an older text.
|
|
295
333
|
const newest = deps.newest ? await deps.newest(workflow.name) : undefined;
|
|
296
334
|
if (newest !== undefined && newest !== digest) {
|
|
@@ -508,7 +546,7 @@ function replayLaunchOf(deps) {
|
|
|
508
546
|
...(launch.learning ? { learning: launch.learning } : {}),
|
|
509
547
|
...(launch.archilDisk ? { archilDisk: launch.archilDisk } : {}),
|
|
510
548
|
};
|
|
511
|
-
return { revision: deps.revisionId, body: launchBody(base), ...(deps.sealKey && deps.runId ? { handed_from: deps.runId } : {}) };
|
|
549
|
+
return { revision: deps.revisionId, body: launchBody(base), ...((deps.sealKey || held()) && deps.runId ? { handed_from: deps.runId } : {}) };
|
|
512
550
|
}
|
|
513
551
|
/** Whether `was`, a digest's newest record now, is still the replay `record` reserved: replaying, under the same replay
|
|
514
552
|
* id. A replay settled meanwhile, and a newer replay of the same revision its owner started since (a held revision may
|
|
@@ -543,8 +581,11 @@ async function cancelUnended(deps, record) {
|
|
|
543
581
|
* logged. */
|
|
544
582
|
async function handedTo(deps, launch, id) {
|
|
545
583
|
const from = launch.handed_from;
|
|
546
|
-
if (!
|
|
584
|
+
if (!from)
|
|
547
585
|
return undefined;
|
|
586
|
+
// A run's own process holds no seal key: its runner seals them again, from its own run alone (held.ts handOn).
|
|
587
|
+
if (!deps.sealKey)
|
|
588
|
+
return held()?.handOn(from, id);
|
|
548
589
|
const sealed = await deps.store.runs.launch(from).then((one) => one.sealed ?? null, () => null);
|
|
549
590
|
const handed = sealed === null ? undefined : openRunMcpAuth(deps.sealKey, from, sealed);
|
|
550
591
|
return handed && Object.keys(handed).length ? sealRunMcpAuth(deps.sealKey, id, handed) : undefined;
|
|
@@ -578,6 +619,8 @@ async function startReplay(deps, workflow, digest, of, from, id, launch) {
|
|
|
578
619
|
* this claim created. */
|
|
579
620
|
async function relaunch(deps, workflow, digest, record) {
|
|
580
621
|
const { store } = deps;
|
|
622
|
+
if (deps.spendOff?.("A replay"))
|
|
623
|
+
return 0;
|
|
581
624
|
const since = (deps.now ?? Date.now)() - Date.parse(record.at);
|
|
582
625
|
const launch = record.launch;
|
|
583
626
|
if (!launch || since <= REPLAY_LAUNCH_GRACE_MS || since > REPLAY_DEADLINE_MS)
|
|
@@ -721,8 +764,8 @@ export async function askReplay(ask, name, digest, inputs) {
|
|
|
721
764
|
if (!picked.length)
|
|
722
765
|
throw new ReplayRefused("conflict", `${name} at ${digest} has no input to replay on: none of ${typeof inputs === "number" ? `the agent's newest ${plural(inputs, "completed run")}` : last ? "the runs it was last checked on" : "the agent's last completed runs"} has an input it fits. Nothing was started.`);
|
|
723
766
|
const { launch, revisionId } = await ask.launchOf(picked[0].launch.input);
|
|
724
|
-
if (!launch.learning || launch.learning.
|
|
725
|
-
throw new ReplayRefused("conflict", `A replay runs ${name} as a run of the agent that learns does, and the agent's runs do not take learned workflows here (its learning is off,
|
|
767
|
+
if (!launch.learning || launch.learning.noWorkflows)
|
|
768
|
+
throw new ReplayRefused("conflict", `A replay runs ${name} as a run of the agent that learns does, and the agent's runs do not take learned workflows here (its learning is off, it takes no workflows, or this server's is off).`);
|
|
726
769
|
const deps = { store: ask.store, agentId: ask.agentId, revisionId, launch: { ...launch, learning: { ...launch.learning, seed: found.commit } }, context: ask.context, log: ask.log, shown: ask.shown, ...(ask.now ? { now: ask.now } : {}) };
|
|
727
770
|
const bar = { compile_after: loop.compile_after, agree_min: loop.agree_min, alone_min: loop.alone_min, attempt: attemptOf(records, name, digest) };
|
|
728
771
|
const said = `checking it on ${plural(picked.length, "input")} of the agent's own runs, as its owner asked`;
|
|
@@ -779,15 +822,18 @@ export async function replayView(ask, name, digest, id) {
|
|
|
779
822
|
}
|
|
780
823
|
return checkView(ask, record, id, name, digest);
|
|
781
824
|
}
|
|
782
|
-
/** A replay run's
|
|
783
|
-
* (a CLI's record shaped as pi's
|
|
784
|
-
*
|
|
785
|
-
|
|
786
|
-
export async function replayCallsFor(store, runId, launch, context) {
|
|
825
|
+
/** A replay run's recording (launch.replay; learn/replay-calls.ts): the agent run's recorded calls, read from its journal
|
|
826
|
+
* (a CLI's record shaped as pi's; another run's, which only a runner reads: learned-first.ts). Undefined for any other
|
|
827
|
+
* run. A recording that cannot be read is an empty one: every write is then skipped, never run. */
|
|
828
|
+
export async function replayRecordedFor(store, launch, context) {
|
|
787
829
|
if (!launch.replay)
|
|
788
830
|
return undefined;
|
|
789
831
|
const entries = await runEntries(store, launch.replay.of, context).catch(() => []);
|
|
790
|
-
|
|
832
|
+
return recordedCalls(isCliRecord(entries) ? piShaped(entries) : entries);
|
|
833
|
+
}
|
|
834
|
+
/** The replay's call nodes over `recorded`, each tool classed by run `runId`'s own MCP pin (its servers' annotations as
|
|
835
|
+
* they listed them) or the built-in list. */
|
|
836
|
+
export async function replayCallsOver(store, runId, recorded) {
|
|
791
837
|
const pin = (await store.mcp.pin(runId).catch(() => undefined))?.body;
|
|
792
838
|
const annotations = pinAnnotations(pin);
|
|
793
839
|
return replayCalls(recorded, (tool) => toolClassOf(tool, annotations));
|
|
@@ -1,56 +1,38 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Problem } from "../learn/index.js";
|
|
2
|
+
import { type CompileAsk, type DraftChecked } from "../learn/compile.js";
|
|
2
3
|
import type { EndOfRunTurn } from "./loop-contract.js";
|
|
3
|
-
/** How long a run's end-of-run turn may take before it is aborted and the run ends without it. */
|
|
4
|
-
export declare const REFLECT_TIMEOUT_MS: number;
|
|
5
4
|
/** A turn the spend cap refused (the cap's refusal words, cap.ts CAP_REFUSAL_PREFIX). */
|
|
6
5
|
export declare const CAP_REFUSAL: RegExp;
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
readonly
|
|
11
|
-
readonly
|
|
12
|
-
readonly
|
|
6
|
+
/** A draft the checks passed, as it is committed: its files whole, the README held for its owner's OK when it calls an
|
|
7
|
+
* unpriced tool (`held`), and the commit a revision was read at (`bases`, its conflict base). */
|
|
8
|
+
export type DraftCommit = {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly files: readonly {
|
|
11
|
+
readonly path: string;
|
|
13
12
|
readonly text: string;
|
|
14
13
|
}[];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
readonly
|
|
22
|
-
readonly
|
|
23
|
-
readonly
|
|
24
|
-
} | {
|
|
25
|
-
readonly state: "dropped";
|
|
26
|
-
readonly reason: "empty";
|
|
27
|
-
} | {
|
|
28
|
-
readonly state: "dropped";
|
|
29
|
-
readonly reason: "unparsed";
|
|
30
|
-
readonly detail: string;
|
|
14
|
+
readonly held?: readonly string[];
|
|
15
|
+
readonly bases?: Readonly<Record<string, string>>;
|
|
16
|
+
};
|
|
17
|
+
/** What a merge landed: the commit (and the correction it left out beside its draft, learn/commit.ts
|
|
18
|
+
* LearningCommitResult `refusedCorrection`), or why it did not. */
|
|
19
|
+
export type Committed = {
|
|
20
|
+
readonly ok: true;
|
|
21
|
+
readonly commit: string;
|
|
22
|
+
readonly refusedCorrection?: readonly Problem[];
|
|
31
23
|
} | {
|
|
32
|
-
readonly
|
|
33
|
-
readonly reason: "
|
|
34
|
-
readonly problems: readonly
|
|
35
|
-
readonly rule: string;
|
|
36
|
-
readonly path?: string;
|
|
37
|
-
}[];
|
|
24
|
+
readonly ok: false;
|
|
25
|
+
readonly reason: "conflict" | "refused" | "unavailable";
|
|
26
|
+
readonly problems: readonly Problem[];
|
|
38
27
|
};
|
|
39
|
-
/** What the
|
|
28
|
+
/** What the step reads of the run and the host. */
|
|
40
29
|
export interface ReflectDeps {
|
|
41
|
-
/** Whether the run's job gave nothing new to
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* said.onlyWorkflow's words. Absent, or a read that throws: every run is asked. */
|
|
30
|
+
/** Whether the run's job gave nothing new to learn from: its only tool work was its learned workflows, each answering,
|
|
31
|
+
* with nothing said after its first message. Such a run compiles nothing unless a compile is due, and its learning is
|
|
32
|
+
* dropped `empty` in said.onlyWorkflow's words. Absent, or a read that throws: none. */
|
|
45
33
|
readonly nothingNew?: (runId: string) => Promise<boolean>;
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* back), and its compile turn, when one is due, is asked alone; with nothing due its learning is dropped `empty` in
|
|
49
|
-
* said.noFeedback's words. Absent (a notes job), or a read that throws: the run is asked its look-back. */
|
|
50
|
-
readonly ownerSaid?: (runId: string) => Promise<boolean>;
|
|
51
|
-
/** The run's facts for reflectSkip: whether it learns, a person's cancel, its cap reached, its cap, its cost so far as a
|
|
52
|
-
* person is shown it (`costUsd`, kept as the job's), and under a cap its spend as the cap's gates read it (`spentUsd`,
|
|
53
|
-
* learning-end.ts capSpendOf: a request with no price of its own at its held figure; null: unknown). */
|
|
34
|
+
/** The run's facts: whether it learns, a person's cancel, its cap reached, its cap, its cost so far as a person is shown
|
|
35
|
+
* it (`costUsd`, kept as the job's), and under a cap its spend as the cap's gates read it (`spentUsd`; null: unknown). */
|
|
54
36
|
readonly facts: (runId: string) => Promise<{
|
|
55
37
|
learns: boolean;
|
|
56
38
|
cancelled?: boolean;
|
|
@@ -62,18 +44,25 @@ export interface ReflectDeps {
|
|
|
62
44
|
capUsd: number;
|
|
63
45
|
spentUsd: number | null;
|
|
64
46
|
})>;
|
|
65
|
-
/**
|
|
66
|
-
readonly
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
47
|
+
/** What the run's owner said of it: a grade's words, and each message they sent after its first, in order. */
|
|
48
|
+
readonly feedback: (runId: string) => Promise<readonly string[]>;
|
|
49
|
+
/** Why the owner's words would be refused as a line of corrections.md on main now (learn/commit.ts correctionRefused);
|
|
50
|
+
* empty when they would be taken. */
|
|
51
|
+
readonly correctionRefused: (input: {
|
|
52
|
+
runId: string;
|
|
53
|
+
agentId: string;
|
|
54
|
+
round: number;
|
|
55
|
+
text: string;
|
|
56
|
+
refuse: readonly string[];
|
|
57
|
+
}) => Promise<readonly Problem[]>;
|
|
58
|
+
/** The compile turn's facts (learn/compile.ts CompileAsk), `refuse` cut from what they quote: undefined when the run
|
|
59
|
+
* compiles nothing (its job not due, a workflow that answered). Absent, or a read that throws: no compile turn. */
|
|
72
60
|
readonly compileFacts?: (input: {
|
|
73
61
|
runId: string;
|
|
74
62
|
agentId: string;
|
|
75
63
|
outcome: "completed" | "failed";
|
|
76
64
|
refuse: readonly string[];
|
|
65
|
+
round: number;
|
|
77
66
|
}) => Promise<CompileAsk | undefined>;
|
|
78
67
|
/** Compile once: a compile turn whose drafts all failed their checks (one answered, none passed) is the compile's
|
|
79
68
|
* attempt, kept on a promotion record (learning-end.ts recordDraftFailed) that compileFacts reads. Its `workflow` and
|
|
@@ -87,55 +76,39 @@ export interface ReflectDeps {
|
|
|
87
76
|
}) => Promise<void>;
|
|
88
77
|
/** The compile turn's deadline, every attempt in it. Default learn/compile.ts COMPILE_TIMEOUT_MS. */
|
|
89
78
|
readonly compileDeadlineMs?: number;
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
triggered?: ReflectTurn["triggered"];
|
|
94
|
-
}>;
|
|
95
|
-
/** Every value the run must never learn (learning-run.ts refused): the host's secrets and what the run was handed, its
|
|
96
|
-
* sign-in pointer among them; `unreadable` when what it was handed can't be read back, and the run learns nothing.
|
|
97
|
-
* Absent, none. */
|
|
98
|
-
readonly refuse?: (runId: string) => Promise<readonly string[] | "unreadable">;
|
|
99
|
-
/** proposeRun's checks over the turn, against the seed the run started from, refusing `refuse`. `revised`: in the
|
|
100
|
-
* compile turn's checks, the workflow it revises from main's text and the commit of main it was first asked at (its
|
|
101
|
-
* CompileAsk's `base`, as the turn's first ask kept it), that workflow's conflict base. */
|
|
102
|
-
readonly check: (input: {
|
|
79
|
+
/** One compile draft through the checks (learning-end.ts checkDraftOf): its errors, else what is committed and its
|
|
80
|
+
* digest. `revised`: a revision's workflow and the commit of main it was read at, its conflict base. */
|
|
81
|
+
readonly checkDraft: (input: {
|
|
103
82
|
runId: string;
|
|
104
83
|
agentId: string;
|
|
105
|
-
|
|
106
|
-
|
|
84
|
+
draft: {
|
|
85
|
+
name: string;
|
|
86
|
+
text: string;
|
|
87
|
+
};
|
|
107
88
|
refuse: readonly string[];
|
|
108
89
|
revised?: {
|
|
109
90
|
readonly workflow: string;
|
|
110
91
|
readonly base: string;
|
|
111
92
|
};
|
|
112
|
-
}) => Promise<
|
|
113
|
-
/**
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
93
|
+
}) => Promise<DraftChecked<DraftCommit>>;
|
|
94
|
+
/** The round's merge on the agent's learning folder (learning-end.ts commitDirect): its draft and its owner's
|
|
95
|
+
* correction, one commit by the run. */
|
|
96
|
+
readonly commit: (input: {
|
|
97
|
+
runId: string;
|
|
98
|
+
agentId: string;
|
|
99
|
+
round: number;
|
|
100
|
+
draft?: DraftCommit;
|
|
101
|
+
correction?: string;
|
|
102
|
+
refuse: readonly string[];
|
|
103
|
+
}) => Promise<Committed>;
|
|
104
|
+
/** Every value the run must never learn: the host's secrets and what the run was handed, its sign-in pointer among
|
|
105
|
+
* them; `unreadable` when what it was handed can't be read back, and the run learns nothing. Absent, none. */
|
|
106
|
+
readonly refuse?: (runId: string) => Promise<readonly string[] | "unreadable">;
|
|
107
|
+
/** For tests: the clock. Default Date.now. */
|
|
121
108
|
readonly now?: () => number;
|
|
122
|
-
/** The cap the learning run's grade runs under, read once the turn closed (learning-end.ts gradeCapOf): what the run's
|
|
123
|
-
* cap leaves once everything the run spent is counted, carried on the learning run's launch as its own cap, so the
|
|
124
|
-
* grade never takes the run past its cap. Null when what the run spent under its cap is unknown: the grade is not
|
|
125
|
-
* run, said so (said.gradeUnknownSpend). Undefined for an uncapped run: its grade is capped by nothing. */
|
|
126
|
-
readonly gradeCap?: (runId: string) => Promise<number | null | undefined>;
|
|
127
109
|
/** Which end of the run this is: 1, its first (the default); an end after a follow-up opened the run again is the next
|
|
128
|
-
* round,
|
|
129
|
-
* (every row the hook gives carries it), graded and merged by a learning run of its own. */
|
|
110
|
+
* round, kept beside the earlier rounds' (every row the step gives carries it), with a merge of its own. */
|
|
130
111
|
readonly round?: number;
|
|
131
|
-
/** A later round's: what the round before it kept of the run's spend (its job's and its look-back's), so the follow-up's
|
|
132
|
-
* own share, between that look-back and this one, is kept apart (`follow_up_usd`); and whether it was asked its turn
|
|
133
|
-
* (`looked`: a round cut before it was asked says nothing of looking back before). */
|
|
134
|
-
readonly before?: {
|
|
135
|
-
readonly job_cost_usd?: number | null;
|
|
136
|
-
readonly look_back_usd?: number | null;
|
|
137
|
-
readonly looked?: boolean;
|
|
138
|
-
};
|
|
139
112
|
}
|
|
140
|
-
/** The end-of-run
|
|
113
|
+
/** The end-of-run step for runs that learn. */
|
|
141
114
|
export declare function createReflectHook(deps: ReflectDeps): EndOfRunTurn;
|