@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/learn/promote.d.ts
CHANGED
|
@@ -212,6 +212,18 @@ export declare function servingOf(records: readonly PromotionRecord[]): {
|
|
|
212
212
|
digest: string | null;
|
|
213
213
|
replaying: string | null;
|
|
214
214
|
}[];
|
|
215
|
+
/** Where a learned workflow stands, the one word both the promotions read (`serving[].state`) and the learning view
|
|
216
|
+
* (`workflows[].status`, a draft neither pending nor retired) say: `checking`, its newest record is a check at work, or
|
|
217
|
+
* it has no record yet (the first claim that lays it and takes its input starts its check; an older revision that
|
|
218
|
+
* serves keeps serving meanwhile, else the agent takes the runs); `serving`, a revision serves (championOf) and the
|
|
219
|
+
* money rule lets it run first; `stopped`, the money rule stopped its champion running first (`costStop`, at the
|
|
220
|
+
* champion's digest: no record says so, the agent takes its runs), or none serves and its newest record is a hold that
|
|
221
|
+
* stops it (a recompile's check, a second audit hold, nothing to check it on); `held`, else. */
|
|
222
|
+
export type ServingState = "serving" | "checking" | "held" | "stopped";
|
|
223
|
+
/** Whether the money rule stops `workflow` at `digest` from running first: runner/workflow-first.ts costStopOf over the
|
|
224
|
+
* agent's runs, the decision a run's claim reads (workflowFirstOf). */
|
|
225
|
+
export type CostStop = (workflow: string, digest: string) => boolean;
|
|
226
|
+
export declare function servingStateOf(records: readonly PromotionRecord[], workflow: string, costStop: CostStop): ServingState;
|
|
215
227
|
/** The promotions list as it leaves (GET /agents/{id}/learning/promotions): the records and what serves (servingOf), every
|
|
216
228
|
* text in them cut by `shown` (learning.ts secretsShown, as the other learning reads cut theirs), at any depth and under
|
|
217
229
|
* any field, so a field added later is cut too: a workflow's name whole (`shown.name`), any other text of its part
|
|
@@ -224,6 +236,12 @@ export declare function promotionsShown(records: readonly PromotionRecord[], sho
|
|
|
224
236
|
promotions: PromotionRecord[];
|
|
225
237
|
serving: ReturnType<typeof servingOf>;
|
|
226
238
|
};
|
|
239
|
+
/** `value` cut as the promotions read cuts its records (promotionsShown), at any depth and under any field: a workflow's
|
|
240
|
+
* name whole (`shown.name`), any other text of its part (`shown.text`). Numbers and the rest as they are. */
|
|
241
|
+
export declare function shownDeep(value: unknown, shown: {
|
|
242
|
+
readonly text: (text: string) => string;
|
|
243
|
+
readonly name: (name: string) => string;
|
|
244
|
+
}, key?: string): unknown;
|
|
227
245
|
/** What a guarded promotion write did: `won`, whether this write kept its record (else `still` did not hold when it
|
|
228
246
|
* wrote: another claim's decision came first); `record`, the newest record of its workflow at its digest after (the one
|
|
229
247
|
* written when won, else the one there, undefined when none). A claim acts on a decision (starts replay runs, cancels)
|
|
@@ -251,10 +269,10 @@ export declare const sameAnswer: (a: string | null, b: string | null) => boolean
|
|
|
251
269
|
export declare const gradeView: (grade: Grade) => {
|
|
252
270
|
source: "feedback" | "eval";
|
|
253
271
|
graded_at: string;
|
|
254
|
-
path: "agent" | "workflow" | "
|
|
272
|
+
path: "agent" | "workflow" | "replay" | "handed_back" | "audit";
|
|
255
273
|
workflow: string | null;
|
|
256
274
|
workflow_digest: string | null;
|
|
257
|
-
feedback: "
|
|
275
|
+
feedback: "correction" | null;
|
|
258
276
|
expected?: Readonly<Record<string, unknown>> | undefined;
|
|
259
277
|
run_id: string;
|
|
260
278
|
correct: boolean;
|
package/dist/learn/promote.js
CHANGED
|
@@ -131,17 +131,30 @@ export function servingOf(records) {
|
|
|
131
131
|
return { workflow, digest, replaying: replayingOf(records, workflow, digest)[0]?.digest ?? null };
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
+
export function servingStateOf(records, workflow, costStop) {
|
|
135
|
+
const newest = records.findLast((one) => one.workflow === workflow);
|
|
136
|
+
if (newest === undefined || newest.decided === "replaying")
|
|
137
|
+
return "checking";
|
|
138
|
+
const champion = championOf(records, workflow);
|
|
139
|
+
if (champion)
|
|
140
|
+
return costStop(workflow, champion.digest) ? "stopped" : "serving";
|
|
141
|
+
return newest.decided === "hold" && (newest.check?.stopped || newest.audit?.stopped) ? "stopped" : "held";
|
|
142
|
+
}
|
|
134
143
|
/** The promotions list as it leaves (GET /agents/{id}/learning/promotions): the records and what serves (servingOf), every
|
|
135
144
|
* text in them cut by `shown` (learning.ts secretsShown, as the other learning reads cut theirs), at any depth and under
|
|
136
145
|
* any field, so a field added later is cut too: a workflow's name whole (`shown.name`), any other text of its part
|
|
137
146
|
* (`shown.text`: a reason, a digest, a run id). Numbers and the rest as they are. A replaying record's `launch` (a run
|
|
138
147
|
* launch: its notes, model and plane) never leaves: aggregates only. */
|
|
139
148
|
export function promotionsShown(records, shown) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
149
|
+
return { promotions: records.map(({ launch: _, ...one }) => shownDeep(one, shown)), serving: servingOf(records).map((one) => shownDeep(one, shown)) };
|
|
150
|
+
}
|
|
151
|
+
/** `value` cut as the promotions read cuts its records (promotionsShown), at any depth and under any field: a workflow's
|
|
152
|
+
* name whole (`shown.name`), any other text of its part (`shown.text`). Numbers and the rest as they are. */
|
|
153
|
+
export function shownDeep(value, shown, key) {
|
|
154
|
+
return typeof value === "string" ? (key === "workflow" ? shown.name(value) : shown.text(value))
|
|
155
|
+
: Array.isArray(value) ? value.map((one) => shownDeep(one, shown))
|
|
156
|
+
: value !== null && typeof value === "object" ? Object.fromEntries(Object.entries(value).map(([field, one]) => [field, shownDeep(one, shown, field)]))
|
|
143
157
|
: value;
|
|
144
|
-
return { promotions: records.map(({ launch: _, ...one }) => cut(one)), serving: servingOf(records).map((one) => cut(one)) };
|
|
145
158
|
}
|
|
146
159
|
/** Keeps `record` as the newest of its workflow at its digest, when `still` holds of the one there now (none: undefined)
|
|
147
160
|
* and of every record kept (`items`: a check across revisions, one at a time, in the same guarded write): so of two
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import type { assertWorkflowCapabilities, desugarWorkflow, dryRunWorkflow, inspectWorkflow, resolveSchemaForWorkflow, validateWorkflow } from "@parcha/agentrun-dsl";
|
|
2
|
-
/** Where a
|
|
3
|
-
export declare const SKILLS_DIR = "skills";
|
|
2
|
+
/** Where a workflow draft lives in the folder. */
|
|
4
3
|
export declare const WORKFLOWS_DIR = "workflows";
|
|
5
|
-
/** The shared skills convention's name: lowercase letters, digits and single dashes, at most 64. */
|
|
6
|
-
export declare const SKILL_NAME: RegExp;
|
|
7
4
|
/** A workflow's name: lowercase letters, digits, dashes and underscores, at most 64, starting with a letter or digit. */
|
|
8
5
|
export declare const WORKFLOW_NAME: RegExp;
|
|
9
|
-
/** A
|
|
6
|
+
/** A workflow's `workflow.json` or its `README.md`, by the folder it names. */
|
|
10
7
|
export type LearnedPlace = {
|
|
11
|
-
readonly kind: "
|
|
8
|
+
readonly kind: "workflow" | "readme";
|
|
12
9
|
readonly name: string;
|
|
13
10
|
};
|
|
14
|
-
/** Where `path` sits among the
|
|
15
|
-
*
|
|
11
|
+
/** Where `path` sits among the workflows, its folder's name as written (unchecked); undefined when it is not a
|
|
12
|
+
* workflow's file. */
|
|
16
13
|
export declare function learnedPlace(path: string): LearnedPlace | undefined;
|
|
17
|
-
/** Whether `name` is a good name for a folder of `kind`. */
|
|
18
|
-
export declare const learnedName: (kind: LearnedPlace["kind"], name: string) => boolean;
|
|
19
14
|
/** Why a front matter does not read one way, by frontMatter: the words a refusal says. */
|
|
20
15
|
export declare const UNCLEAR_FRONT = "its front matter does not read one way: each line a `key: value` at its left edge, a comment, or a line of the value above it";
|
|
21
|
-
/** A
|
|
16
|
+
/** A draft README's front matter, read one way, as the one reader of what it says of itself (its keys,
|
|
22
17
|
* its name, its description, its status): each key to its value in order, or undefined when it does not read one way,
|
|
23
18
|
* since another reader (a harness's YAML) could then read a key, a status among them, this one does not. It reads one
|
|
24
19
|
* way when it starts the text (`---`), closes on a `---` line (the last line or not), and each line between is blank,
|
|
@@ -30,33 +25,30 @@ export declare const UNCLEAR_FRONT = "its front matter does not read one way: ea
|
|
|
30
25
|
* `key:` under a value, a list at the left edge, a key set twice, a YAML explicit key `? key`, which every writer here
|
|
31
26
|
* would have to edit in its own form) reads no way. */
|
|
32
27
|
export declare function frontMatter(text: string): ReadonlyMap<string, string> | undefined;
|
|
33
|
-
/** Every value a
|
|
28
|
+
/** Every value a draft README's front matter holds, as YAML reads it (frontMatter: escapes decoded):
|
|
34
29
|
* what a check for secrets reads beside the text as stored, since the decoded value is the one a harness is served
|
|
35
30
|
* (servedSkill). None for a text whose front matter does not read one way. */
|
|
36
31
|
export declare function frontValues(text: string): string[];
|
|
37
|
-
/** The keys a
|
|
32
|
+
/** The keys a draft README's front matter sets, in order (frontMatter's); undefined for a text whose
|
|
38
33
|
* front matter does not read one way. */
|
|
39
34
|
export declare function frontKeys(text: string): string[] | undefined;
|
|
40
|
-
/** The front matter keys a
|
|
35
|
+
/** The front matter keys a draft README may hold: its name and when to use it. Claude
|
|
41
36
|
* Code reads directives from more (hooks, allowed-tools, context, agent, model, ...): a hook is a shell command its CLI
|
|
42
37
|
* runs. `status` is the host's (a held one). */
|
|
43
38
|
export declare const LEARNED_KEYS: readonly string[];
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
*
|
|
39
|
+
/** Why a draft's `README.md` for the workflow `name` is out of shape; empty when it is not. Its front matter names the
|
|
40
|
+
* folder's name and a description. */
|
|
41
|
+
export declare function readmeProblems(text: string, name: string): string[];
|
|
42
|
+
/** `text`, a revision's SKILL.md, as OpenCode is handed it: front matter with its name and its description alone, as the
|
|
43
|
+
* one reader reads them (frontMatter), each quoted as JSON writes it, which every YAML reads back as that very string,
|
|
44
|
+
* then its body as it is. A text with no front matter, or one whose front matter reads no way, is as it is: the
|
|
45
|
+
* harness's to check, as its author wrote it. */
|
|
50
46
|
export declare function servedSkill(text: string): string;
|
|
51
|
-
/** Skills as
|
|
52
|
-
*
|
|
53
|
-
* (learning.ts chooseSkills) read this same form, so a set the check takes is never one that grew past its limit after. */
|
|
47
|
+
/** Skills as OpenCode is handed them (adapters.ts opencodeOf): each SKILL.md as servedSkill writes it, its other files as
|
|
48
|
+
* they are. Its table entry's check reads this same form. */
|
|
54
49
|
export declare const servedSkills: <T extends {
|
|
55
50
|
files: Record<string, string>;
|
|
56
51
|
}>(skills: readonly T[]) => T[];
|
|
57
|
-
/** Why a `SKILL.md` for the skill `name`, or a draft's `README.md` for the workflow `name`, is out of shape; empty when
|
|
58
|
-
* it is not. Its front matter names the folder's name and a description. */
|
|
59
|
-
export declare function skillProblems(text: string, name: string): string[];
|
|
60
52
|
/** A SKILL.md's or a draft README's front matter as a reader shows it (frontMatter): its name, description and status,
|
|
61
53
|
* each absent when it is not there; undefined for a text whose front matter does not read one way. */
|
|
62
54
|
export declare function learnedFront(text: string): {
|
|
@@ -64,10 +56,10 @@ export declare function learnedFront(text: string): {
|
|
|
64
56
|
description?: string;
|
|
65
57
|
status?: string;
|
|
66
58
|
} | undefined;
|
|
67
|
-
/** Whether a
|
|
59
|
+
/** Whether a draft's README.md sets `status`, which only the host does (`held`) (frontMatter). */
|
|
68
60
|
export declare const setsStatus: (text: string) => boolean;
|
|
69
|
-
/** A
|
|
70
|
-
*
|
|
61
|
+
/** A draft held for its owner's OK: its README.md says `status: pending` (learnedStatus). No run is given a held
|
|
62
|
+
* workflow until a person approves it. */
|
|
71
63
|
export declare const isHeld: (text: string) => boolean;
|
|
72
64
|
/** Whether `text`'s status, when it sets one, is one plain line, `status: <value>` with nothing of it on the lines after
|
|
73
65
|
* (no quoted value that runs on, no block, no wrapped line): the only status the host's writers (released,
|
|
@@ -75,27 +67,27 @@ export declare const isHeld: (text: string) => boolean;
|
|
|
75
67
|
* retired), never held or active, and no writer edits it, so a write never leaves part of it behind. The host writes
|
|
76
68
|
* only one-line statuses (held, retiredLearned). */
|
|
77
69
|
export declare const statusOnOneLine: (text: string) => boolean;
|
|
78
|
-
/** `text`, a
|
|
70
|
+
/** `text`, a draft's README.md, as the host merges one the grader held for its owner's OK: `status:
|
|
79
71
|
* pending` last in its front matter, with LF line ends. Throws on a text with no front matter, which the checker never
|
|
80
72
|
* passes. */
|
|
81
73
|
export declare function held(text: string): string;
|
|
82
|
-
/** `text`, a held
|
|
74
|
+
/** `text`, a held draft README.md, as the host leaves it when its owner approves it: its front matter with
|
|
83
75
|
* no `status` or `retired_from` line, so it is given to every later run. Throws on a text with no front matter. */
|
|
84
76
|
export declare function released(text: string): string;
|
|
85
|
-
/** The status a retired
|
|
77
|
+
/** The status a retired draft README.md goes back to when a person restores it (`retired_from`, which its
|
|
86
78
|
* retire recorded), read by the one reader (frontMatter: its quoting, its one-line rule): `active` only when it reads
|
|
87
79
|
* `active` one way, on one plain line; `pending` otherwise, a retire that recorded none or one that reads unclear among
|
|
88
|
-
* them (fail closed: only an approval makes a
|
|
80
|
+
* them (fail closed: only an approval makes a draft active). */
|
|
89
81
|
export declare function retiredFrom(text: string): "active" | "pending";
|
|
90
|
-
/** Whether a retired
|
|
82
|
+
/** Whether a retired draft README.md can be restored by the host's writer: its front matter reads one way
|
|
91
83
|
* (frontMatter), and its `status` and `retired_from` are each one plain line, the only ones the writer takes out whole.
|
|
92
84
|
* One that is not is refused until it is written so (a restore never edits half a value). */
|
|
93
85
|
export declare const restorable: (text: string) => boolean;
|
|
94
|
-
/** `text`, a retired
|
|
86
|
+
/** `text`, a retired draft README.md, as the host leaves it when a person restores it: back in the status its
|
|
95
87
|
* retire recorded (retiredFrom), active, or waiting for its owner's OK. Throws on a text whose front matter does not read
|
|
96
88
|
* one way, or whose status is not one plain line (released). */
|
|
97
89
|
export declare const restoredLearned: (text: string) => string;
|
|
98
|
-
/** What a
|
|
90
|
+
/** What a draft's README.md says of itself, the one reader of it (frontMatter), the server's and, through
|
|
99
91
|
* the folder's snapshot, the console's: `pending` while it waits for its owner's OK, `retired` once a person retired
|
|
100
92
|
* it, `active` when it sets no status or `active`. A front matter that does not read one way, or a status that is none
|
|
101
93
|
* of these, is `retired`: never active, since another reader could read it as held or retired; no run is given it, and
|
|
@@ -105,7 +97,7 @@ export declare function learnedStatus(text: string): "active" | "pending" | "ret
|
|
|
105
97
|
* is not one plain line, or its status is none the host writes. No one retired it: a view says the host could not read
|
|
106
98
|
* it, never that a run or a person retired it. */
|
|
107
99
|
export declare function unclearFront(text: string): boolean;
|
|
108
|
-
/** `text`, a
|
|
100
|
+
/** `text`, a draft's README.md, as a person's retire leaves it: `status: retired` and `retired_from`, the
|
|
109
101
|
* status it had (active, or pending while it waited for its owner's OK), last in its front matter (any such lines before
|
|
110
102
|
* them dropped), so no later run is given it and its restore gives that status back. Throws on a text with no front
|
|
111
103
|
* matter. */
|
|
@@ -173,7 +165,7 @@ export declare function synthesisProblems(doc: unknown, dsl: SchemaResolver): st
|
|
|
173
165
|
/** A draft's workflow.json `json` dry-run by the workflow DSL (dryRunWorkflow) on `example` (its block's `example:`
|
|
174
166
|
* line, one JSON object), else on an input synthesized from its input schema. Every model, Jev and tool-call answer is
|
|
175
167
|
* synthesized from the node's output schema: no request is sent, nothing is paid, no tool runs, and no code it holds
|
|
176
|
-
* runs in this process (refuseCode). Only a draft the static checks pass is dry-run (
|
|
168
|
+
* runs in this process (refuseCode). Only a draft the static checks pass is dry-run (runner/reflect-hook.ts). It checks the wiring
|
|
177
169
|
* at run time (the state each step reads, its output's path and schema), never the answers. With `outputSchema` (the
|
|
178
170
|
* agent's), the output of a run that passed is held to it as a run serving the draft serves it (answer-json.ts
|
|
179
171
|
* answerAsServed over the tool's text, learned-workflow.ts learnedOutput) as far as its placeholders can decide: its
|
|
@@ -267,6 +259,10 @@ export declare const DECODED_DEPTH = 100;
|
|
|
267
259
|
/** The most turns a learned workflow's model node runs (learned-workflow.ts hands its runner this cap): an agent node
|
|
268
260
|
* that asks for more is refused at learn time and before a call, never when it comes up after earlier nodes spent. */
|
|
269
261
|
export declare const LEARNED_MAX_TURNS = 8;
|
|
262
|
+
/** The first thing this release's workflow DSL refuses in a learned workflow's text on its own (`validateWorkflow`, no code
|
|
263
|
+
* run, no tool list: a refusal of the text, never of a host setting such as a tool gated, denied or missing), in the
|
|
264
|
+
* words a run's refusal gives it (draftProblems); undefined when the DSL takes it, or it is no JSON (no DSL issue). */
|
|
265
|
+
export declare function dslRefusalOf(dsl: DraftReader, text: string): string | undefined;
|
|
270
266
|
/** Why `workflows/<name>/workflow.json` is not a draft the host can run; empty when it is. The DSL's own
|
|
271
267
|
* `validateWorkflow` judges it, with `executeCode: false` so no code it holds is run (a code node is syntax-checked),
|
|
272
268
|
* and with `tools`, so a node that names a tool outside them is its error: a harness's own tool (Bash, exec_command,
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// A learned workflow draft: `workflows/<name>/workflow.json` with its `README.md`, their place in the learning folder, the
|
|
2
|
+
// shape each file must have, and what its dry run reads. check.ts checks a draft; nothing here reads a file, runs a draft
|
|
3
|
+
// or calls a model.
|
|
4
4
|
import { mcpNameOf } from "../tool-names.js";
|
|
5
5
|
import { repeatedLabels, workflowNodes } from "./workflow-nodes.js";
|
|
6
|
-
/** Where a
|
|
7
|
-
export const SKILLS_DIR = "skills";
|
|
6
|
+
/** Where a workflow draft lives in the folder. */
|
|
8
7
|
export const WORKFLOWS_DIR = "workflows";
|
|
9
|
-
/** The shared skills convention's name: lowercase letters, digits and single dashes, at most 64. */
|
|
10
|
-
export const SKILL_NAME = /^(?=.{1,64}$)[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
11
8
|
/** A workflow's name: lowercase letters, digits, dashes and underscores, at most 64, starting with a letter or digit. */
|
|
12
9
|
export const WORKFLOW_NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
13
10
|
const PLACES = [
|
|
14
|
-
[/^skills\/([^/]+)\/SKILL\.md$/, "skill"],
|
|
15
11
|
[/^workflows\/([^/]+)\/workflow\.json$/, "workflow"],
|
|
16
12
|
[/^workflows\/([^/]+)\/README\.md$/, "readme"],
|
|
17
13
|
];
|
|
18
|
-
/** Where `path` sits among the
|
|
19
|
-
*
|
|
14
|
+
/** Where `path` sits among the workflows, its folder's name as written (unchecked); undefined when it is not a
|
|
15
|
+
* workflow's file. */
|
|
20
16
|
export function learnedPlace(path) {
|
|
21
17
|
for (const [pattern, kind] of PLACES) {
|
|
22
18
|
const name = pattern.exec(path)?.[1];
|
|
@@ -25,9 +21,7 @@ export function learnedPlace(path) {
|
|
|
25
21
|
}
|
|
26
22
|
return undefined;
|
|
27
23
|
}
|
|
28
|
-
/**
|
|
29
|
-
export const learnedName = (kind, name) => (kind === "skill" ? SKILL_NAME : WORKFLOW_NAME).test(name);
|
|
30
|
-
/** Where a SKILL.md's or a draft README's front matter closes in `lf` (its text with LF line ends): the index of the
|
|
24
|
+
/** Where a draft README's front matter closes in `lf` (its text with LF line ends): the index of the
|
|
31
25
|
* `\n` before its closing `---` line, the last line or not; -1 when it has none. */
|
|
32
26
|
const closeOf = (lf) => {
|
|
33
27
|
const close = /\n---(?:\n|$)/.exec(lf.slice(3));
|
|
@@ -35,10 +29,9 @@ const closeOf = (lf) => {
|
|
|
35
29
|
};
|
|
36
30
|
/** YAML's double-quoted escapes, each to what it reads as (`\\x`, `\\u` and `\\U` take hex digits apart). */
|
|
37
31
|
const ESCAPES = { "0": "\0", a: "\x07", b: "\b", t: "\t", "\t": "\t", n: "\n", v: "\v", f: "\f", r: "\r", e: "\x1b", " ": " ", '"': '"', "/": "/", "\\": "\\", N: "\u0085", _: "\u00a0", L: "\u2028", P: "\u2029" };
|
|
38
|
-
/** A scalar's value as YAML reads it: a double-quoted one with its escapes decoded (JSON's, which
|
|
39
|
-
* and YAML's own), a single-quoted one with each `''` one `'`, a plain one as it is. So reading what
|
|
40
|
-
* gives back the very value it quoted,
|
|
41
|
-
* again): never an escape quoted twice. Undefined, never a throw, for a double-quoted value with an escape that does
|
|
32
|
+
/** A scalar's value as YAML reads it: a double-quoted one with its escapes decoded (JSON's, which frontLine writes,
|
|
33
|
+
* and YAML's own), a single-quoted one with each `''` one `'`, a plain one as it is. So reading what frontLine wrote
|
|
34
|
+
* gives back the very value it quoted: never an escape quoted twice. Undefined, never a throw, for a double-quoted value with an escape that does
|
|
42
35
|
* not decode cleanly (one YAML has not, a code point past U+10FFFF, a `\\` that ends it): what another reader makes of
|
|
43
36
|
* it is not known, so its front matter reads no way. The decoded value is the one every check reads (frontValues). */
|
|
44
37
|
function unquote(raw) {
|
|
@@ -62,7 +55,7 @@ function unquote(raw) {
|
|
|
62
55
|
});
|
|
63
56
|
return clean ? decoded : undefined;
|
|
64
57
|
}
|
|
65
|
-
/** A
|
|
58
|
+
/** A draft README's front matter, as the host edits it: its lines, where it closes (closeOf, in `lf`,
|
|
66
59
|
* the text with LF line ends) and each key's value, a folded or literal block value read as one line. A string is why
|
|
67
60
|
* there is none. What it says of itself (its keys, its status) is frontMatter's to read, never this. */
|
|
68
61
|
function frontOf(text) {
|
|
@@ -100,7 +93,7 @@ function frontOf(text) {
|
|
|
100
93
|
}
|
|
101
94
|
/** Why a front matter does not read one way, by frontMatter: the words a refusal says. */
|
|
102
95
|
export const UNCLEAR_FRONT = "its front matter does not read one way: each line a `key: value` at its left edge, a comment, or a line of the value above it";
|
|
103
|
-
/** A
|
|
96
|
+
/** A draft README's front matter, read one way, as the one reader of what it says of itself (its keys,
|
|
104
97
|
* its name, its description, its status): each key to its value in order, or undefined when it does not read one way,
|
|
105
98
|
* since another reader (a harness's YAML) could then read a key, a status among them, this one does not. It reads one
|
|
106
99
|
* way when it starts the text (`---`), closes on a `---` line (the last line or not), and each line between is blank,
|
|
@@ -219,45 +212,25 @@ function foldQuoted(lines) {
|
|
|
219
212
|
}
|
|
220
213
|
return out;
|
|
221
214
|
}
|
|
222
|
-
/** Every value a
|
|
215
|
+
/** Every value a draft README's front matter holds, as YAML reads it (frontMatter: escapes decoded):
|
|
223
216
|
* what a check for secrets reads beside the text as stored, since the decoded value is the one a harness is served
|
|
224
217
|
* (servedSkill). None for a text whose front matter does not read one way. */
|
|
225
218
|
export function frontValues(text) {
|
|
226
219
|
return [...(frontMatter(text)?.values() ?? [])];
|
|
227
220
|
}
|
|
228
|
-
/** The keys a
|
|
221
|
+
/** The keys a draft README's front matter sets, in order (frontMatter's); undefined for a text whose
|
|
229
222
|
* front matter does not read one way. */
|
|
230
223
|
export function frontKeys(text) {
|
|
231
224
|
const front = frontMatter(text);
|
|
232
225
|
return front ? [...front.keys()] : undefined;
|
|
233
226
|
}
|
|
234
|
-
/** The front matter keys a
|
|
227
|
+
/** The front matter keys a draft README may hold: its name and when to use it. Claude
|
|
235
228
|
* Code reads directives from more (hooks, allowed-tools, context, agent, model, ...): a hook is a shell command its CLI
|
|
236
229
|
* runs. `status` is the host's (a held one). */
|
|
237
230
|
export const LEARNED_KEYS = ["name", "description"];
|
|
238
|
-
/**
|
|
239
|
-
*
|
|
240
|
-
|
|
241
|
-
* one door a learned skill reaches a harness by), then its body as it is. A text with no front matter, or one whose front
|
|
242
|
-
* matter reads no way, is as it is: never served with its fields emptied. A learned one of those is never active, so
|
|
243
|
-
* never given; a revision's own is the harness's to check, as its author wrote it. */
|
|
244
|
-
export function servedSkill(text) {
|
|
245
|
-
const opened = frontOf(text);
|
|
246
|
-
if (typeof opened === "string")
|
|
247
|
-
return text;
|
|
248
|
-
const front = frontMatter(text);
|
|
249
|
-
if (!front)
|
|
250
|
-
return text;
|
|
251
|
-
const lines = [`name: ${JSON.stringify(front.get("name") ?? "")}`, `description: ${JSON.stringify(front.get("description") ?? "")}`];
|
|
252
|
-
return `---\n${lines.join("\n")}\n---\n${opened.lf.slice(opened.end + 5)}`;
|
|
253
|
-
}
|
|
254
|
-
/** Skills as a harness that loads them through servedSkill is handed them (OpenCode, adapters.ts opencodeOf): each
|
|
255
|
-
* SKILL.md as servedSkill writes it, its other files as they are. Its table entry's check and the learned skills' room
|
|
256
|
-
* (learning.ts chooseSkills) read this same form, so a set the check takes is never one that grew past its limit after. */
|
|
257
|
-
export const servedSkills = (skills) => skills.map((skill) => ({ ...skill, files: { ...skill.files, ...(skill.files["SKILL.md"] === undefined ? {} : { "SKILL.md": servedSkill(skill.files["SKILL.md"]) }) } }));
|
|
258
|
-
/** Why a `SKILL.md` for the skill `name`, or a draft's `README.md` for the workflow `name`, is out of shape; empty when
|
|
259
|
-
* it is not. Its front matter names the folder's name and a description. */
|
|
260
|
-
export function skillProblems(text, name) {
|
|
231
|
+
/** Why a draft's `README.md` for the workflow `name` is out of shape; empty when it is not. Its front matter names the
|
|
232
|
+
* folder's name and a description. */
|
|
233
|
+
export function readmeProblems(text, name) {
|
|
261
234
|
const opened = frontOf(text);
|
|
262
235
|
if (typeof opened === "string")
|
|
263
236
|
return [opened];
|
|
@@ -271,6 +244,23 @@ export function skillProblems(text, name) {
|
|
|
271
244
|
out.push("description is missing or empty");
|
|
272
245
|
return out;
|
|
273
246
|
}
|
|
247
|
+
/** `text`, a revision's SKILL.md, as OpenCode is handed it: front matter with its name and its description alone, as the
|
|
248
|
+
* one reader reads them (frontMatter), each quoted as JSON writes it, which every YAML reads back as that very string,
|
|
249
|
+
* then its body as it is. A text with no front matter, or one whose front matter reads no way, is as it is: the
|
|
250
|
+
* harness's to check, as its author wrote it. */
|
|
251
|
+
export function servedSkill(text) {
|
|
252
|
+
const opened = frontOf(text);
|
|
253
|
+
if (typeof opened === "string")
|
|
254
|
+
return text;
|
|
255
|
+
const front = frontMatter(text);
|
|
256
|
+
if (!front)
|
|
257
|
+
return text;
|
|
258
|
+
const lines = [`name: ${JSON.stringify(front.get("name") ?? "")}`, `description: ${JSON.stringify(front.get("description") ?? "")}`];
|
|
259
|
+
return `---\n${lines.join("\n")}\n---\n${opened.lf.slice(opened.end + 5)}`;
|
|
260
|
+
}
|
|
261
|
+
/** Skills as OpenCode is handed them (adapters.ts opencodeOf): each SKILL.md as servedSkill writes it, its other files as
|
|
262
|
+
* they are. Its table entry's check reads this same form. */
|
|
263
|
+
export const servedSkills = (skills) => skills.map((skill) => ({ ...skill, files: { ...skill.files, ...(skill.files["SKILL.md"] === undefined ? {} : { "SKILL.md": servedSkill(skill.files["SKILL.md"]) }) } }));
|
|
274
264
|
/** A SKILL.md's or a draft README's front matter as a reader shows it (frontMatter): its name, description and status,
|
|
275
265
|
* each absent when it is not there; undefined for a text whose front matter does not read one way. */
|
|
276
266
|
export function learnedFront(text) {
|
|
@@ -280,10 +270,10 @@ export function learnedFront(text) {
|
|
|
280
270
|
const [name, description, status] = ["name", "description", "status"].map((key) => front.get(key));
|
|
281
271
|
return { ...(name === undefined ? {} : { name }), ...(description === undefined ? {} : { description }), ...(status === undefined ? {} : { status }) };
|
|
282
272
|
}
|
|
283
|
-
/** Whether a
|
|
273
|
+
/** Whether a draft's README.md sets `status`, which only the host does (`held`) (frontMatter). */
|
|
284
274
|
export const setsStatus = (text) => frontMatter(text)?.has("status") ?? false;
|
|
285
|
-
/** A
|
|
286
|
-
*
|
|
275
|
+
/** A draft held for its owner's OK: its README.md says `status: pending` (learnedStatus). No run is given a held
|
|
276
|
+
* workflow until a person approves it. */
|
|
287
277
|
export const isHeld = (text) => learnedStatus(text) === "pending";
|
|
288
278
|
/** Whether `text`'s status, when it sets one, is one plain line, `status: <value>` with nothing of it on the lines after
|
|
289
279
|
* (no quoted value that runs on, no block, no wrapped line): the only status the host's writers (released,
|
|
@@ -304,7 +294,7 @@ function onOneLine(text, key) {
|
|
|
304
294
|
// A plain value that wraps onto the next lines reads longer than its own line.
|
|
305
295
|
return unquote(own) === front.get(key);
|
|
306
296
|
}
|
|
307
|
-
/** `text`, a
|
|
297
|
+
/** `text`, a draft's README.md, as the host merges one the grader held for its owner's OK: `status:
|
|
308
298
|
* pending` last in its front matter, with LF line ends. Throws on a text with no front matter, which the checker never
|
|
309
299
|
* passes. */
|
|
310
300
|
export function held(text) {
|
|
@@ -313,14 +303,14 @@ export function held(text) {
|
|
|
313
303
|
throw new Error(`it cannot be held: ${front}`);
|
|
314
304
|
return `${front.lf.slice(0, front.end)}\nstatus: pending${front.lf.slice(front.end)}`;
|
|
315
305
|
}
|
|
316
|
-
/** `text`, a held
|
|
306
|
+
/** `text`, a held draft README.md, as the host leaves it when its owner approves it: its front matter with
|
|
317
307
|
* no `status` or `retired_from` line, so it is given to every later run. Throws on a text with no front matter. */
|
|
318
308
|
export function released(text) {
|
|
319
309
|
const front = frontOf(text);
|
|
320
310
|
if (typeof front === "string")
|
|
321
311
|
throw new Error(`it cannot be approved: ${front}`);
|
|
322
312
|
// Its status and retired_from are taken out whole, so each must be one plain line; what is left reads back active, or
|
|
323
|
-
// the write fails: never an OK over a
|
|
313
|
+
// the write fails: never an OK over a workflow no run is given.
|
|
324
314
|
if (!statusOnOneLine(text) || !onOneLine(text, "retired_from"))
|
|
325
315
|
throw new Error("it cannot be approved: its status is not one plain line");
|
|
326
316
|
const kept = front.lf.slice(4, front.end).split("\n").filter((line) => !line.startsWith("status:") && !line.startsWith("retired_from:"));
|
|
@@ -329,22 +319,22 @@ export function released(text) {
|
|
|
329
319
|
throw new Error(`it cannot be approved: its status would read ${learnedStatus(out)}`);
|
|
330
320
|
return out;
|
|
331
321
|
}
|
|
332
|
-
/** The status a retired
|
|
322
|
+
/** The status a retired draft README.md goes back to when a person restores it (`retired_from`, which its
|
|
333
323
|
* retire recorded), read by the one reader (frontMatter: its quoting, its one-line rule): `active` only when it reads
|
|
334
324
|
* `active` one way, on one plain line; `pending` otherwise, a retire that recorded none or one that reads unclear among
|
|
335
|
-
* them (fail closed: only an approval makes a
|
|
325
|
+
* them (fail closed: only an approval makes a draft active). */
|
|
336
326
|
export function retiredFrom(text) {
|
|
337
327
|
return onOneLine(text, "retired_from") && frontMatter(text)?.get("retired_from") === "active" ? "active" : "pending";
|
|
338
328
|
}
|
|
339
|
-
/** Whether a retired
|
|
329
|
+
/** Whether a retired draft README.md can be restored by the host's writer: its front matter reads one way
|
|
340
330
|
* (frontMatter), and its `status` and `retired_from` are each one plain line, the only ones the writer takes out whole.
|
|
341
331
|
* One that is not is refused until it is written so (a restore never edits half a value). */
|
|
342
332
|
export const restorable = (text) => frontMatter(text) !== undefined && statusOnOneLine(text) && onOneLine(text, "retired_from");
|
|
343
|
-
/** `text`, a retired
|
|
333
|
+
/** `text`, a retired draft README.md, as the host leaves it when a person restores it: back in the status its
|
|
344
334
|
* retire recorded (retiredFrom), active, or waiting for its owner's OK. Throws on a text whose front matter does not read
|
|
345
335
|
* one way, or whose status is not one plain line (released). */
|
|
346
336
|
export const restoredLearned = (text) => (retiredFrom(text) === "active" ? released(text) : held(released(text)));
|
|
347
|
-
/** What a
|
|
337
|
+
/** What a draft's README.md says of itself, the one reader of it (frontMatter), the server's and, through
|
|
348
338
|
* the folder's snapshot, the console's: `pending` while it waits for its owner's OK, `retired` once a person retired
|
|
349
339
|
* it, `active` when it sets no status or `active`. A front matter that does not read one way, or a status that is none
|
|
350
340
|
* of these, is `retired`: never active, since another reader could read it as held or retired; no run is given it, and
|
|
@@ -365,7 +355,7 @@ export function unclearFront(text) {
|
|
|
365
355
|
const front = frontMatter(text);
|
|
366
356
|
return !front || !statusOnOneLine(text) || !["active", "pending", "retired"].includes(front.get("status") ?? "active");
|
|
367
357
|
}
|
|
368
|
-
/** `text`, a
|
|
358
|
+
/** `text`, a draft's README.md, as a person's retire leaves it: `status: retired` and `retired_from`, the
|
|
369
359
|
* status it had (active, or pending while it waited for its owner's OK), last in its front matter (any such lines before
|
|
370
360
|
* them dropped), so no later run is given it and its restore gives that status back. Throws on a text with no front
|
|
371
361
|
* matter. */
|
|
@@ -699,7 +689,7 @@ const valueAt = (value, path) => path === "" ? value : path.split("/").slice(1).
|
|
|
699
689
|
/** A draft's workflow.json `json` dry-run by the workflow DSL (dryRunWorkflow) on `example` (its block's `example:`
|
|
700
690
|
* line, one JSON object), else on an input synthesized from its input schema. Every model, Jev and tool-call answer is
|
|
701
691
|
* synthesized from the node's output schema: no request is sent, nothing is paid, no tool runs, and no code it holds
|
|
702
|
-
* runs in this process (refuseCode). Only a draft the static checks pass is dry-run (
|
|
692
|
+
* runs in this process (refuseCode). Only a draft the static checks pass is dry-run (runner/reflect-hook.ts). It checks the wiring
|
|
703
693
|
* at run time (the state each step reads, its output's path and schema), never the answers. With `outputSchema` (the
|
|
704
694
|
* agent's), the output of a run that passed is held to it as a run serving the draft serves it (answer-json.ts
|
|
705
695
|
* answerAsServed over the tool's text, learned-workflow.ts learnedOutput) as far as its placeholders can decide: its
|
|
@@ -972,6 +962,22 @@ const issuesOf = (dsl, doc, tools) => {
|
|
|
972
962
|
const valid = dsl.validateWorkflow(doc, { executeCode: false, ...(tools ? { tools } : {}) });
|
|
973
963
|
return valid.ok ? [] : valid.issues;
|
|
974
964
|
};
|
|
965
|
+
/** A DSL issue as a refusal says it: its code, where, and its words (cut at 200). */
|
|
966
|
+
const issueWords = (issue) => `${issue.code} at ${issue.path || "/"}: ${issue.message.slice(0, 200)}`;
|
|
967
|
+
/** The first thing this release's workflow DSL refuses in a learned workflow's text on its own (`validateWorkflow`, no code
|
|
968
|
+
* run, no tool list: a refusal of the text, never of a host setting such as a tool gated, denied or missing), in the
|
|
969
|
+
* words a run's refusal gives it (draftProblems); undefined when the DSL takes it, or it is no JSON (no DSL issue). */
|
|
970
|
+
export function dslRefusalOf(dsl, text) {
|
|
971
|
+
let doc;
|
|
972
|
+
try {
|
|
973
|
+
doc = JSON.parse(text);
|
|
974
|
+
}
|
|
975
|
+
catch {
|
|
976
|
+
return undefined;
|
|
977
|
+
}
|
|
978
|
+
const issue = issuesOf(dsl, doc)[0];
|
|
979
|
+
return issue ? issueWords(issue) : undefined;
|
|
980
|
+
}
|
|
975
981
|
/** Why `workflows/<name>/workflow.json` is not a draft the host can run; empty when it is. The DSL's own
|
|
976
982
|
* `validateWorkflow` judges it, with `executeCode: false` so no code it holds is run (a code node is syntax-checked),
|
|
977
983
|
* and with `tools`, so a node that names a tool outside them is its error: a harness's own tool (Bash, exec_command,
|
|
@@ -993,7 +999,7 @@ export function draftProblems(dsl, text, tools, gated = {}, deniedBy = {}, decis
|
|
|
993
999
|
const listed = tools ? [...tools, ...Object.keys(gated)] : undefined;
|
|
994
1000
|
const issues = issuesOf(dsl, doc, listed);
|
|
995
1001
|
if (issues.length)
|
|
996
|
-
return issues.slice(0, 5).map((issue) => ({ rule: "workflow", detail: `the workflow DSL refuses it: ${issue
|
|
1002
|
+
return issues.slice(0, 5).map((issue) => ({ rule: "workflow", detail: `the workflow DSL refuses it: ${issueWords(issue)}` }));
|
|
997
1003
|
let out;
|
|
998
1004
|
try {
|
|
999
1005
|
// A label names one step (workflow-nodes.ts repeatedLabels): its events and escalation read by it.
|
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
/** One node of a workflow document, with the prefix the DSL puts on its step's name when it runs: `parent/` for each
|
|
2
|
-
* `workflow` node it sits in (scopeDepsToChild), so a nested step's label reads `parent/child
|
|
2
|
+
* `workflow` node it sits in (scopeDepsToChild), so a nested step's label reads `parent/child`, and its place in the
|
|
3
|
+
* document (`path`: a chain's step by its index, any other child by the field that holds it, dot-joined; "" the root). */
|
|
3
4
|
export type WorkflowNodeAt = {
|
|
4
5
|
readonly node: Record<string, unknown>;
|
|
5
6
|
readonly prefix: string;
|
|
7
|
+
readonly path: string;
|
|
6
8
|
};
|
|
7
9
|
/** Every node of `doc` (a parsed workflow.json), in document order: its root, a chain's steps, a parallel's branches, a
|
|
8
10
|
* map's and a loop's body, a route's branches' bodies, a nested workflow's root, as the DSL's inspection visits them.
|
|
9
11
|
* Walked with a stack of its own, never the call stack, so no draft's nesting can throw here. */
|
|
10
12
|
export declare function workflowNodes(doc: unknown): WorkflowNodeAt[];
|
|
13
|
+
/** A check a node runs in code: on `when` (it runs only when the predicate holds) or `until` (a loop's stop). */
|
|
14
|
+
export type NodeCheck = {
|
|
15
|
+
readonly on: "when" | "until";
|
|
16
|
+
readonly predicate: unknown;
|
|
17
|
+
};
|
|
18
|
+
/** A node of a learned workflow as a person reads it (GET /agents/{id}/learning/promotions `serving[].champion.nodes`):
|
|
19
|
+
* where it is (`path`, as workflowNodes gives it; "root" for a root that is no chain), its kind and label (its kind
|
|
20
|
+
* when it has none), the tier its model step runs on (`fast`, or `agent` for the agent's own model; null for a node
|
|
21
|
+
* that calls no model tier), and its checks in code. */
|
|
22
|
+
export type WorkflowNode = {
|
|
23
|
+
readonly path: string;
|
|
24
|
+
readonly kind: string;
|
|
25
|
+
readonly label: string;
|
|
26
|
+
readonly tier: "fast" | "agent" | null;
|
|
27
|
+
readonly checks: readonly NodeCheck[];
|
|
28
|
+
};
|
|
29
|
+
/** Every node of workflow document `doc` (the one walk above), a chain left out (its steps are the nodes). Read off the
|
|
30
|
+
* document alone: nothing is run, and a document out of shape gives what of it is in shape. */
|
|
31
|
+
export declare function workflowNodesOf(doc: unknown): WorkflowNode[];
|
|
11
32
|
/** The labels of `doc` that name more than one node, each once, in document order, as the DSL names a step when it runs
|
|
12
33
|
* (`parent/child` in a child workflow). A label names one step: its events and its escalation read by it, and the durable runner refuses a workflow
|
|
13
34
|
* that repeats one (DUPLICATE_LABEL). */
|
|
@@ -1,30 +1,49 @@
|
|
|
1
|
-
// The one walk over a learned workflow's nodes (learn/
|
|
1
|
+
// The one walk over a learned workflow's nodes (learn/workflow-draft.ts callNodes): only the
|
|
2
2
|
// workflow's node positions, never an object in a call's args, a schema or any other data, however it is shaped.
|
|
3
|
+
import { TIERED_KINDS } from "./check.js";
|
|
4
|
+
const join = (path, key) => (path ? `${path}.${key}` : key);
|
|
3
5
|
const asNode = (value) => (value && typeof value === "object" && !Array.isArray(value) ? value : undefined);
|
|
4
6
|
/** Every node of `doc` (a parsed workflow.json), in document order: its root, a chain's steps, a parallel's branches, a
|
|
5
7
|
* map's and a loop's body, a route's branches' bodies, a nested workflow's root, as the DSL's inspection visits them.
|
|
6
8
|
* Walked with a stack of its own, never the call stack, so no draft's nesting can throw here. */
|
|
7
9
|
export function workflowNodes(doc) {
|
|
8
10
|
const out = [];
|
|
9
|
-
const stack = [{ value: asNode(doc)?.root, prefix: "" }];
|
|
11
|
+
const stack = [{ value: asNode(doc)?.root, prefix: "", path: "" }];
|
|
10
12
|
while (stack.length) {
|
|
11
|
-
const { value, prefix } = stack.pop();
|
|
13
|
+
const { value, prefix, path } = stack.pop();
|
|
12
14
|
const node = asNode(value);
|
|
13
15
|
if (!node)
|
|
14
16
|
continue;
|
|
15
|
-
out.push({ node, prefix });
|
|
16
|
-
const children = node.node === "chain" && Array.isArray(node.steps) ? node.steps
|
|
17
|
-
: node.node === "parallel" && Array.isArray(node.branches) ? node.branches
|
|
18
|
-
: (node.node === "map" || node.node === "loop") ? [node.body]
|
|
19
|
-
: node.node === "route" && asNode(node.branches) ? Object.
|
|
20
|
-
: node.node === "workflow" ? [asNode(node.workflow)?.root]
|
|
17
|
+
out.push({ node, prefix, path });
|
|
18
|
+
const children = node.node === "chain" && Array.isArray(node.steps) ? node.steps.map((step, i) => [String(i), step])
|
|
19
|
+
: node.node === "parallel" && Array.isArray(node.branches) ? node.branches.map((branch, i) => [`branches.${i}`, branch])
|
|
20
|
+
: (node.node === "map" || node.node === "loop") ? [["body", node.body]]
|
|
21
|
+
: node.node === "route" && asNode(node.branches) ? Object.entries(node.branches).map(([key, branch]) => [`branches.${key}.body`, asNode(branch)?.body])
|
|
22
|
+
: node.node === "workflow" ? [["workflow.root", asNode(node.workflow)?.root]]
|
|
21
23
|
: [];
|
|
22
24
|
const inner = node.node === "workflow" && typeof node.label === "string" ? `${prefix}${node.label}/` : prefix;
|
|
23
25
|
for (let i = children.length - 1; i >= 0; i--)
|
|
24
|
-
stack.push({ value: children[i], prefix: inner });
|
|
26
|
+
stack.push({ value: children[i][1], prefix: inner, path: join(path, children[i][0]) });
|
|
25
27
|
}
|
|
26
28
|
return out;
|
|
27
29
|
}
|
|
30
|
+
const CHECK_KEYS = ["when", "until"];
|
|
31
|
+
/** Every node of workflow document `doc` (the one walk above), a chain left out (its steps are the nodes). Read off the
|
|
32
|
+
* document alone: nothing is run, and a document out of shape gives what of it is in shape. */
|
|
33
|
+
export function workflowNodesOf(doc) {
|
|
34
|
+
return workflowNodes(doc).flatMap(({ node, path }) => {
|
|
35
|
+
const kind = typeof node.node === "string" ? node.node : "?";
|
|
36
|
+
if (kind === "chain")
|
|
37
|
+
return [];
|
|
38
|
+
return [{
|
|
39
|
+
path: path || "root",
|
|
40
|
+
kind,
|
|
41
|
+
label: typeof node.label === "string" ? node.label : kind,
|
|
42
|
+
tier: TIERED_KINDS.has(kind) ? (node.tier === "fast" ? "fast" : "agent") : null,
|
|
43
|
+
checks: CHECK_KEYS.filter((key) => asNode(node[key])).map((key) => ({ on: key, predicate: node[key] })),
|
|
44
|
+
}];
|
|
45
|
+
});
|
|
46
|
+
}
|
|
28
47
|
/** The labels of `doc` that name more than one node, each once, in document order, as the DSL names a step when it runs
|
|
29
48
|
* (`parent/child` in a child workflow). A label names one step: its events and its escalation read by it, and the durable runner refuses a workflow
|
|
30
49
|
* that repeats one (DUPLICATE_LABEL). */
|