@parcha/agentrun-serve 0.1.0-beta.44 → 0.1.0-beta.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +131 -5
- package/README.md +371 -300
- package/dist/acp-package.d.ts +28 -0
- package/dist/acp-package.js +23 -0
- package/dist/adapter-facts.d.ts +8 -1
- package/dist/adapter-facts.js +9 -1
- package/dist/adapters.d.ts +5 -0
- package/dist/adapters.js +36 -3
- package/dist/agent-delete.d.ts +50 -0
- package/dist/agent-delete.js +125 -0
- package/dist/agents-store.d.ts +9 -3
- package/dist/agents-store.js +22 -8
- package/dist/agents.d.ts +5 -1
- package/dist/agents.js +8 -4
- package/dist/api-only.d.ts +8 -3
- package/dist/api-only.js +10 -4
- package/dist/archil-routes.d.ts +5 -1
- package/dist/archil-routes.js +57 -2
- package/dist/browser-wait-ended.d.ts +2 -0
- package/dist/browser-wait-ended.js +2 -0
- package/dist/calendar/ics-faux.d.ts +3 -1
- package/dist/calendar/ics-faux.js +12 -2
- package/dist/calendar/tools.js +5 -2
- package/dist/chatgpt-plan.js +3 -1
- package/dist/claude-login.d.ts +135 -0
- package/dist/claude-login.js +244 -0
- package/dist/cli.js +52 -16
- package/dist/composio-preset.js +69 -7
- package/dist/composio-triggers.d.ts +14 -0
- package/dist/composio-triggers.js +79 -15
- package/dist/computer-attach.d.ts +40 -5
- package/dist/computer-attach.js +130 -15
- package/dist/computer-keys.d.ts +3 -0
- package/dist/computer-keys.js +7 -1
- package/dist/computer-live.js +3 -2
- package/dist/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
- package/dist/console/assets/index-DaFsZuzQ.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/dial-relay.d.ts +29 -0
- package/dist/dial-relay.js +94 -0
- package/dist/email/tools.js +10 -5
- package/dist/env-proxy.d.ts +2 -0
- package/dist/env-proxy.js +35 -0
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +7 -4
- package/dist/faux-computers.d.ts +8 -2
- package/dist/faux-computers.js +83 -6
- package/dist/harness-archive.d.ts +67 -0
- package/dist/harness-archive.js +177 -0
- package/dist/harness-goose.d.ts +34 -0
- package/dist/harness-goose.js +87 -0
- package/dist/harness-install.d.ts +21 -0
- package/dist/harness-install.js +24 -11
- package/dist/harness-opencode/adapter.js +1 -1
- package/dist/harness-table.d.ts +9 -1
- package/dist/harness-table.js +20 -3
- package/dist/harness.d.ts +1 -2
- package/dist/harness.js +3 -4
- package/dist/host.js +2 -1
- package/dist/key-check.js +3 -0
- package/dist/learn/audit.d.ts +6 -6
- package/dist/learn/audit.js +3 -7
- package/dist/learn/check.d.ts +23 -89
- package/dist/learn/check.js +57 -335
- package/dist/learn/commit.d.ts +63 -90
- package/dist/learn/commit.js +124 -316
- package/dist/learn/compile.d.ts +53 -50
- package/dist/learn/compile.js +87 -102
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +5 -5
- package/dist/learn/delete.js +8 -10
- package/dist/learn/folder.d.ts +35 -47
- package/dist/learn/folder.js +118 -134
- package/dist/learn/index.d.ts +3 -5
- package/dist/learn/index.js +6 -9
- package/dist/learn/learning.sh +45 -15
- package/dist/learn/promote.d.ts +13 -1
- package/dist/learn/promote.js +9 -0
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
- package/dist/learn/{skills.js → workflow-draft.js} +48 -58
- package/dist/learn/workflow-nodes.js +1 -1
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +38 -24
- package/dist/learning-cost.js +41 -24
- package/dist/learning-routes.d.ts +91 -170
- package/dist/learning-routes.js +183 -421
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +4 -4
- package/dist/learning-setting.js +6 -6
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +61 -392
- package/dist/learning.js +101 -651
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +1 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +4 -4
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +4 -0
- package/dist/model.js +26 -9
- package/dist/native/binding.js +1 -1
- package/dist/native/connection.js +1 -1
- package/dist/native/discovery.js +1 -1
- package/dist/native/instructions.d.ts +3 -0
- package/dist/native/instructions.js +5 -3
- package/dist/native/remote-worker-bridge.js +9 -43
- package/dist/native/remote.d.ts +8 -15
- package/dist/native/remote.js +3 -3
- package/dist/native/schema.js +1 -1
- package/dist/native/types.d.ts +2 -2
- package/dist/openapi.js +268 -316
- package/dist/paid-calls.d.ts +8 -0
- package/dist/paid-calls.js +20 -0
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +28 -11
- package/dist/print.d.ts +27 -0
- package/dist/print.js +21 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +15 -1
- package/dist/reflect-range.js +2 -3
- package/dist/run-launch.d.ts +14 -28
- package/dist/run-launch.js +9 -12
- package/dist/run-learning-served.d.ts +15 -89
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.js +1 -1
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-trace.d.ts +97 -0
- package/dist/run-trace.js +253 -0
- package/dist/run-view.d.ts +15 -0
- package/dist/run-view.js +9 -0
- package/dist/runnable.js +2 -1
- package/dist/runner/adapter-loop.d.ts +8 -6
- package/dist/runner/adapter-loop.js +16 -12
- package/dist/runner/adapter-run-spec.d.ts +16 -4
- package/dist/runner/adapter-run-spec.js +64 -58
- package/dist/runner/adapters/index.js +22 -0
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +1 -1
- package/dist/runner/audit.js +16 -8
- package/dist/runner/beside.d.ts +6 -2
- package/dist/runner/beside.js +38 -9
- package/dist/runner/claim-secrets.d.ts +18 -2
- package/dist/runner/claim-secrets.js +42 -18
- package/dist/runner/cli-run-spec.js +55 -51
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +16 -5
- package/dist/runner/dispatch.d.ts +2 -2
- package/dist/runner/end-of-run.d.ts +6 -14
- package/dist/runner/end-of-run.js +8 -33
- package/dist/runner/feedback-round.d.ts +2 -2
- package/dist/runner/feedback-round.js +7 -7
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +11 -59
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +2 -3
- package/dist/runner/journal-kinds.js +2 -3
- package/dist/runner/learned-first.d.ts +40 -0
- package/dist/runner/learned-first.js +32 -0
- package/dist/runner/learning-end.d.ts +77 -69
- package/dist/runner/learning-end.js +250 -303
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +2 -3
- package/dist/runner/main.d.ts +17 -9
- package/dist/runner/main.js +63 -20
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +10 -5
- package/dist/runner/memory-claim.js +12 -6
- package/dist/runner/model-route.d.ts +7 -4
- package/dist/runner/model-route.js +22 -10
- package/dist/runner/native-loop.d.ts +0 -7
- package/dist/runner/native-loop.js +9 -101
- package/dist/runner/promotion.d.ts +8 -6
- package/dist/runner/promotion.js +19 -12
- package/dist/runner/reflect-hook.d.ts +64 -95
- package/dist/runner/reflect-hook.js +112 -225
- package/dist/runner/run-channel.d.ts +43 -0
- package/dist/runner/run-channel.js +467 -0
- package/dist/runner/run-child-host.d.ts +169 -0
- package/dist/runner/run-child-host.js +1222 -0
- package/dist/runner/run-child.d.ts +1 -0
- package/dist/runner/run-child.js +254 -0
- package/dist/runner/run-errors.d.ts +2 -0
- package/dist/runner/run-errors.js +20 -0
- package/dist/runner/runner.js +1 -5
- package/dist/runner/sdk-ask.d.ts +78 -0
- package/dist/runner/sdk-ask.js +158 -0
- package/dist/runner/sdk-loop.d.ts +2 -4
- package/dist/runner/sdk-loop.js +29 -49
- package/dist/runner/store-secrets.d.ts +5 -3
- package/dist/runner/store-secrets.js +5 -1
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +7 -2
- package/dist/runs-over-store.d.ts +16 -28
- package/dist/runs-over-store.js +31 -38
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/seal-key.d.ts +5 -0
- package/dist/seal-key.js +7 -0
- package/dist/secrets.d.ts +3 -0
- package/dist/secrets.js +16 -3
- package/dist/server.d.ts +55 -33
- package/dist/server.js +685 -320
- package/dist/sign-ins-store.d.ts +8 -0
- package/dist/sign-ins-store.js +36 -1
- package/dist/skills.js +1 -1
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +3 -0
- package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
- package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
- package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
- package/dist/store/schema.d.ts +53 -4
- package/dist/store/schema.js +137 -6
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.js +246 -63
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +193 -36
- package/dist/store/store.js +25 -3
- package/dist/store-reads/learning.d.ts +102 -204
- package/dist/store-reads/learning.js +159 -321
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +29 -1
- package/dist/store-view.js +97 -31
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +2 -1
- package/dist/templates.js +6 -3
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -1
- package/dist/timeline/timeline.js +16 -0
- package/dist/tool-gate.d.ts +0 -7
- package/dist/tool-gate.js +1 -15
- package/dist/tool-keys-store.d.ts +1 -1
- package/dist/tool-keys.d.ts +6 -4
- package/dist/tool-keys.js +12 -6
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +11 -4
- package/dist/triggers.d.ts +60 -5
- package/dist/triggers.js +123 -18
- package/dist/validate.js +1 -1
- package/dist/webhooks.d.ts +4 -1
- package/dist/webhooks.js +11 -4
- package/dist/workspace/agent-computer.d.ts +2 -0
- package/dist/workspace/agent-computer.js +2 -0
- package/dist/workspace/archil-claim.d.ts +7 -0
- package/dist/workspace/archil-claim.js +29 -0
- package/dist/workspace/archil.d.ts +9 -1
- package/dist/workspace/archil.js +165 -3
- package/dist/workspace/attach.d.ts +3 -1
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/attached-computers.d.ts +16 -5
- package/dist/workspace/attached-computers.js +25 -9
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +7 -3
- package/dist/workspace/computer-for-claim.js +119 -22
- package/dist/workspace/computer-hold.js +2 -1
- package/dist/workspace/computer-kept.d.ts +11 -1
- package/dist/workspace/computer-kept.js +24 -3
- package/dist/workspace/resolve-computer.d.ts +33 -19
- package/dist/workspace/resolve-computer.js +172 -64
- package/dist/workspace/revision-skills.d.ts +1 -2
- package/dist/workspace/revision-skills.js +3 -4
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +5 -0
- package/dist/workspace/synced-folder.d.ts +85 -0
- package/dist/workspace/synced-folder.js +230 -0
- package/dist/workspace/workspace.d.ts +4 -0
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/templates/README.md +7 -7
- package/templates/inbound-lead/agent.md +3 -3
- package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
- package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
- package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
- package/templates/inbound-lead/lead.schema.json +6 -5
- package/templates/inbound-lead/rules/RUBRIC.md +4 -4
- package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
- package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
- package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
- package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
- package/templates/release-notes/evals/learned-style/case.yaml +4 -4
- package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
- package/templates/release-notes/evals/learned-style/prompt.md +1 -1
- package/dist/console/assets/index-BUktRvS-.css +0 -1
- package/dist/console/assets/index-nB9kTfIN.js +0 -711
- package/dist/learn/grade.d.ts +0 -138
- package/dist/learn/grade.js +0 -682
- package/dist/learn/notes.d.ts +0 -81
- package/dist/learn/notes.js +0 -178
- package/dist/learn/reflect.d.ts +0 -77
- package/dist/learn/reflect.js +0 -228
- package/dist/learn/relevance.d.ts +0 -24
- package/dist/learn/relevance.js +0 -91
- package/dist/learn/seed-check.d.ts +0 -74
- package/dist/learn/seed-check.js +0 -103
- package/dist/learning-batch.d.ts +0 -291
- package/dist/learning-batch.js +0 -600
- package/dist/learning-evals.d.ts +0 -35
- package/dist/learning-evals.js +0 -99
- package/dist/native/context.d.ts +0 -6
- package/dist/native/context.js +0 -22
- package/dist/propose.d.ts +0 -52
- package/dist/propose.js +0 -224
- package/dist/runner/learning-ask.d.ts +0 -47
- package/dist/runner/learning-ask.js +0 -128
- package/dist/runner/learning-dispatch.d.ts +0 -45
- package/dist/runner/learning-dispatch.js +0 -99
- package/dist/runner/learning-factory.d.ts +0 -16
- package/dist/runner/learning-factory.js +0 -50
- package/dist/runner/learning-loop.d.ts +0 -273
- package/dist/runner/learning-loop.js +0 -521
- package/dist/usage.d.ts +0 -11
- package/dist/usage.js +0 -11
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
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
|
|
@@ -260,7 +272,7 @@ export declare const gradeView: (grade: Grade) => {
|
|
|
260
272
|
path: "agent" | "workflow" | "replay" | "handed_back" | "audit";
|
|
261
273
|
workflow: string | null;
|
|
262
274
|
workflow_digest: string | null;
|
|
263
|
-
feedback: "
|
|
275
|
+
feedback: "correction" | null;
|
|
264
276
|
expected?: Readonly<Record<string, unknown>> | undefined;
|
|
265
277
|
run_id: string;
|
|
266
278
|
correct: boolean;
|
package/dist/learn/promote.js
CHANGED
|
@@ -131,6 +131,15 @@ 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
|
|
@@ -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
|
|
@@ -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
|
|
@@ -1,4 +1,4 @@
|
|
|
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
3
|
import { TIERED_KINDS } from "./check.js";
|
|
4
4
|
const join = (path, key) => (path ? `${path}.${key}` : key);
|
package/dist/learned-workflow.js
CHANGED
|
@@ -33,7 +33,7 @@ import { defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
|
33
33
|
import { registerLabel, registerOutcome } from "./timeline/index.js";
|
|
34
34
|
import { LEARNED_NODES, LEARNED_NODES_MAX } from "./learned-nodes.js";
|
|
35
35
|
import { draftProblems, LEARNED_MAX_TURNS } from "./learn/index.js";
|
|
36
|
-
import { decisionsAsked, deniedDecisionWords } from "./learn/
|
|
36
|
+
import { decisionsAsked, deniedDecisionWords } from "./learn/workflow-draft.js";
|
|
37
37
|
import { DEFAULT_DECISION_PROVIDER } from "./decisions.js";
|
|
38
38
|
import { workflowLine } from "./learning.js";
|
|
39
39
|
import { ledgerOf } from "./paid-calls.js";
|
|
@@ -478,7 +478,7 @@ export async function runLearned(run, flow, input, signal, ledger, nodes = [], n
|
|
|
478
478
|
* other node shares. Only letters, digits, `_` and `-`, so a `/` of its path never reads as another level of nesting
|
|
479
479
|
* and its call id passes whole through a URL (an approval's). */
|
|
480
480
|
const nestedKey = (label, executionPath, item) => `${label.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 40)}-${createHash("sha256").update(JSON.stringify([label, executionPath ?? "", item?.index ?? null])).digest("hex").slice(0, 16)}`;
|
|
481
|
-
/** The draft check's decisions for `run` (learn/
|
|
481
|
+
/** The draft check's decisions for `run` (learn/workflow-draft.ts DraftDecisions): its providers, and the gate's setting of each
|
|
482
482
|
* provider `text` asks (its bare id as the settings key) where it is not allow, with where a deny was set. A run handed
|
|
483
483
|
* no decisions (its claim was handed no key: none named, or each denied) has no provider, so a decision node is refused
|
|
484
484
|
* in the gate's words when its provider is denied, else as one the host does not have; never asked. */
|
package/dist/learning-cost.d.ts
CHANGED
|
@@ -21,30 +21,36 @@ export type CostLooked = {
|
|
|
21
21
|
* the run's cost here would read other than its usage row (A8). `+ 0` makes a noise-sized negative a plain 0, never -0. */
|
|
22
22
|
export declare const noiseOff: (value: number) => number;
|
|
23
23
|
/** A run's own cost and what learning added for it, from its row's cost (`rowUsd`: the job, its look-back and any turn a
|
|
24
|
-
* person asked of it after)
|
|
25
|
-
* grade spent (`gradeUsd`: its learning run's cost once that run ended, stopped or failed, 0 while it runs or when there
|
|
26
|
-
* is none, null when unknown):
|
|
24
|
+
* person asked of it after) and what it kept as it answered (`looked`, none for a run that did not look back):
|
|
27
25
|
* - `cost_usd`: the job's own $: its row's cost less its look-back, never under what it had cost when it answered (a
|
|
28
26
|
* later turn's spend is the job's too); its row's cost for a run that did not look back;
|
|
29
|
-
* - `learning_usd`: what learning cost for it: its look-back
|
|
30
|
-
*
|
|
27
|
+
* - `learning_usd`: what learning cost for it: its look-back (its compile turn) and what was spent beside it
|
|
28
|
+
* (`besideUsd`: its audit's shadow run), 0 for a run that does not learn; null when unknown (a turn stopped mid-ask
|
|
29
|
+
* spent what no one knows, or a shadow still running);
|
|
31
30
|
* - `total_usd`: their sum, the run's all-in $; null when either is. */
|
|
32
|
-
export declare function runCostOf(rowUsd: number | null, looked: CostLooked | null,
|
|
31
|
+
export declare function runCostOf(rowUsd: number | null, looked: CostLooked | null, besideUsd?: number | null): {
|
|
33
32
|
cost_usd: number | null;
|
|
34
33
|
learning_usd: number | null;
|
|
35
34
|
total_usd: number | null;
|
|
36
35
|
};
|
|
37
|
-
/** One run of the series, in the order the agent's runs started: `n` its number among
|
|
36
|
+
/** One run of the series, in the order the agent's runs started: `n` its number among the runs that do a job (JOB_PATHS,
|
|
37
|
+
* 1 the first: the bill's numbering), null for a replay, which checks a revision and does no job. */
|
|
38
38
|
export type CostRun = {
|
|
39
|
-
n: number;
|
|
39
|
+
n: number | null;
|
|
40
40
|
run_id: string;
|
|
41
41
|
started_at: string;
|
|
42
42
|
path: RunPath;
|
|
43
43
|
/** The learned workflow its job called last, by name; null when it called none. */
|
|
44
44
|
workflow: string | null;
|
|
45
|
-
/** The
|
|
46
|
-
*
|
|
47
|
-
|
|
45
|
+
/** The revision of that workflow that ran it (its record's metrics.workflow_digest: the first 16 hex characters of its
|
|
46
|
+
* workflow.json's sha256); null when no learned workflow ran. One value while one revision serves. */
|
|
47
|
+
digest: string | null;
|
|
48
|
+
/** The first run its revision (`workflow` at `digest`) served, over every run of the series (tookOverOf): where that
|
|
49
|
+
* revision took over, its promotion's flag on the chart. The first of them is the summary's takeover (a workflow that
|
|
50
|
+
* ran first always names its revision); false for a replay and a run no revision ran (`digest` null). */
|
|
51
|
+
took_over: boolean;
|
|
52
|
+
/** An audit's shadow run was started for it (runner/audit.ts): its cost is in `learning_usd`. */
|
|
53
|
+
audited: boolean;
|
|
48
54
|
cost_usd: number | null;
|
|
49
55
|
/** Its stored cost is only a bound (the run row's `costAtMostUsd`: a request cut at its cap hold): `cost_usd` and `total_usd` are null, the bound is never shown as a cost. */
|
|
50
56
|
cost_upper_bound: boolean;
|
|
@@ -75,11 +81,17 @@ export type CostReplay = {
|
|
|
75
81
|
/** The paths a learned workflow served a run on: it ran first and answered alone (`workflow`) or handed back
|
|
76
82
|
* (`handed_back`). A `replay` checks a new revision on a graded input and serves no one; an `agent` run is by hand. */
|
|
77
83
|
export declare const SERVED_PATHS: readonly RunPath[];
|
|
84
|
+
/** Each run of the series (every run, oldest first, before a read's limit) with `took_over`: true on the first run a
|
|
85
|
+
* revision (`workflow` at `digest`) served (SERVED_PATHS), never on a replay or a run no revision ran. A promotion is
|
|
86
|
+
* written as a run is claimed, after the runs queued before it started, so where a revision took over is read from the
|
|
87
|
+
* runs it served, never from start times. */
|
|
88
|
+
export declare function tookOverOf(runs: readonly Omit<CostRun, "took_over">[]): CostRun[];
|
|
78
89
|
/** Why the after side has a figure or not: `priced`, it has; `no_served_runs`, no learned workflow has taken over (a
|
|
79
90
|
* replay is no served run); `cost_unknown`, runs were served but none's all-in cost is known exactly. */
|
|
80
91
|
export declare const AFTER_STATES: readonly ["priced", "no_served_runs", "cost_unknown"];
|
|
81
92
|
export type AfterState = (typeof AFTER_STATES)[number];
|
|
82
|
-
/** What the series shows: `takeover`,
|
|
93
|
+
/** What the series shows: `takeover`, the first run a learned workflow served (SERVED_PATHS: it answered alone or handed
|
|
94
|
+
* back; the bill's `promoted`), null before one; `before`, the mean of the job's own $
|
|
83
95
|
* (learning left out) over its `agent` runs before the takeover (every one when there is none yet), whose cost is known
|
|
84
96
|
* exactly; `after`, the mean all-in $ (learning included) of the runs a learned workflow served from the takeover on
|
|
85
97
|
* (SERVED_PATHS: never a replay, which checks a revision and serves no one, nor a run by hand) whose total is known
|
|
@@ -131,7 +143,7 @@ export type BillPoint = {
|
|
|
131
143
|
/** A revision's learning spend and what its served runs carry of it (amortize): `compile_usd` the compile turns that
|
|
132
144
|
* drafted it (a recompile's turn is its recompiled revision's), `check_usd` its check's replay runs, `spend_usd` the
|
|
133
145
|
* two (each null when a part's cost is unknown), `k` the served runs it is spread over (its check's compile_after),
|
|
134
|
-
* `served`
|
|
146
|
+
* `served` every run it served (its first `k` carry its spend), `attributed_usd` what they carry, `unattributed_usd` the rest, and `state`:
|
|
135
147
|
* `checking` (its check is at work), `serving` (it is the champion) or `stopped` (held or replaced: nothing more will
|
|
136
148
|
* carry it). */
|
|
137
149
|
export type RevisionSpend = {
|
|
@@ -165,8 +177,10 @@ export type BillHold = {
|
|
|
165
177
|
* the first run from `promoted` on after which `actual_usd` never again exceeds `agent_usd`, the booked total past the
|
|
166
178
|
* last point included (null: not yet, or nothing served), and `gap_usd` the booked total less the line at the last point
|
|
167
179
|
* while there is none; `withheld` the runs (a replay among them) whose cost is unknown or only a bound, on neither line;
|
|
168
|
-
* `booked_usd` every priced run's $, spend booked after the last point included
|
|
169
|
-
*
|
|
180
|
+
* `booked_usd` every priced run's $, spend booked after the last point included, and `learning_usd` what of it learning
|
|
181
|
+
* booked: every priced job's learning (its compile turn and its audit's shadow run) and every priced replay. With the
|
|
182
|
+
* v2 split (amortize): `revisions`, `unattributed_usd` (the booked total less every run's all-in: what no run carries)
|
|
183
|
+
* and `holds`. */
|
|
170
184
|
export type Bill = {
|
|
171
185
|
baseline: {
|
|
172
186
|
runs: number;
|
|
@@ -185,18 +199,18 @@ export type Bill = {
|
|
|
185
199
|
gap_usd: number | null;
|
|
186
200
|
withheld: number;
|
|
187
201
|
booked_usd: number;
|
|
202
|
+
learning_usd: number;
|
|
188
203
|
revisions: RevisionShare[];
|
|
189
204
|
unattributed_usd: number | null;
|
|
190
205
|
holds: BillHold[];
|
|
191
206
|
};
|
|
192
|
-
/** The bill over `runs` (the cost series, oldest first, replays among them)
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
|
|
199
|
-
export declare function billOf(runs: readonly CostRun[], promotedAt: string | null): Omit<Bill, "revisions" | "unattributed_usd" | "holds">;
|
|
207
|
+
/** The bill over `runs` (the cost series, oldest first, replays among them): each run that does a job, all in (its own
|
|
208
|
+
* $, its compile turn and its audit shadow), with each replay's $ joining the run that does a job it followed (the first
|
|
209
|
+
* one when none did), cumulative; against the baseline times the runs shown so far. Spend booked with no point to join
|
|
210
|
+
* (a replay after a job of unknown cost) is carried to the next point, and with none after it is still booked: in the
|
|
211
|
+
* gap, and no break-even while it puts the bill over the line. Every sum and difference has its float noise rounded off
|
|
212
|
+
* (noiseOff), so a tie reads as a tie and a decision's sub-micro-dollar cost is booked as the usage row books it. */
|
|
213
|
+
export declare function billOf(runs: readonly CostRun[]): Omit<Bill, "revisions" | "unattributed_usd" | "holds">;
|
|
200
214
|
/** Each revision's spend split over its first `k` served runs (`served`: the runs a learned workflow served, oldest
|
|
201
215
|
* first, with the workflow and digest that served each: a revision is both, as two workflows of the same text share a
|
|
202
216
|
* digest), in whole micro-dollars: each carries spend/k, the first ones a micro-dollar more, and the k-th the
|
|
@@ -215,7 +229,7 @@ export declare function amortize(revisions: readonly RevisionSpend[], served: re
|
|
|
215
229
|
/** The series as CSV (RFC 4180, a header line, `\r\n` line ends): one row a run, an unknown figure empty. A text cell that
|
|
216
230
|
* a spreadsheet would read as a formula (one starting with =, +, -, @, a tab or a carriage return) starts with a `'`, so
|
|
217
231
|
* it opens as the text it is. */
|
|
218
|
-
export declare const COST_CSV_COLUMNS: readonly ["n", "run_id", "started_at", "path", "workflow", "
|
|
232
|
+
export declare const COST_CSV_COLUMNS: readonly ["n", "run_id", "started_at", "path", "workflow", "digest", "audited", "cost_usd", "cost_upper_bound", "learning_usd", "total_usd"];
|
|
219
233
|
export declare function costCsv(runs: readonly CostRun[]): string;
|
|
220
234
|
/** GET /agents/{id}/learning/cost's query: `limit`, an integer from 1 to COST_RUNS_MAX (COST_RUNS_DEFAULT when absent),
|
|
221
235
|
* and `format`, `json` (the default) or `csv`. Anything else is 400. */
|