@parcha/agentrun-serve 0.1.0-beta.44 → 0.1.0-beta.46
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 +148 -5
- package/README.md +385 -305
- 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 +62 -19
- 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-C2MYaUBa.css +1 -0
- package/dist/console/assets/index-CZZeCReB.js +701 -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/import.d.ts +10 -0
- package/dist/import.js +28 -8
- 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 +89 -104
- 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 +23 -5
- package/dist/learn/promote.js +40 -2
- 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 +21 -10
- package/dist/learning-setting.js +47 -11
- 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 +273 -319
- 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 +30 -13
- 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 +35 -13
- package/dist/runner/conformance/subject.d.ts +6 -0
- 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 +82 -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 +12 -8
- package/dist/runner/promotion.js +37 -28
- 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 +1230 -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 +689 -322
- 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 +8 -4
- package/dist/templates.js +44 -6
- 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 +65 -6
- package/dist/triggers.js +125 -19
- package/dist/validate.js +1 -1
- package/dist/webhooks.d.ts +7 -2
- package/dist/webhooks.js +12 -5
- 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 +8 -8
- package/templates/inbound-lead/agent.md +5 -4
- 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/kyb/agent.md +2 -1
- 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/learning-run.d.ts
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import type { RunRow } from "./agent-rows.js";
|
|
2
2
|
import type { AnalyticsFilter } from "./store-reads/analytics.js";
|
|
3
3
|
import type { TimelineEvent } from "./timeline/index.js";
|
|
4
|
-
import { type Learning, type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* call whose result came back a success, matched to its call by id (claude-agent's rows can hold the result above the
|
|
9
|
-
* call), on any harness: pi's, claude-agent's (the host's `read`, served to its CLI as `mcp__hands__read`) and codex's
|
|
10
|
-
* (the same tool, as an app-server dynamic tool) rows all name it `read`, with the path as the model gave it. The
|
|
11
|
-
* end-of-run turn's reads are its own, not the job's, and are left out; so is a read that failed or never ended, and
|
|
12
|
-
* MEMORY.md, which is no note. Which of these files are notes the run started from is for its seed to say (noteUsed). */
|
|
13
|
-
export declare function notesRead(reflect: Reflect | undefined, rows: readonly TimelineEvent[]): string[];
|
|
14
|
-
/** The run's learning row, once its learning was proposed, merged or dropped (`seed_failed` included): its state, reason
|
|
15
|
-
* and detail, its summary the detail itself as the run's view says it (learning.ts detailShown: cut of the host's
|
|
16
|
-
* secrets now, `shown`, then cut short). One row, which says where the learning ended. */
|
|
4
|
+
import { type Learning, type Shown } from "./learning.js";
|
|
5
|
+
/** The run's learning row, once its learning merged or dropped (`seed_failed` included): its state, reason and detail,
|
|
6
|
+
* its summary the detail itself as the run's view says it (learning.ts detailShown: cut of the host's secrets now,
|
|
7
|
+
* `shown`, then cut short). One row, which says where the learning ended. */
|
|
17
8
|
export declare function withLearning(rows: readonly TimelineEvent[], learning: Learning | undefined, shown: Shown): TimelineEvent[];
|
|
18
9
|
/** How the runs that tried to learn fared, over the runs the analytics' `from`, `to` and `agent` pick (by when they
|
|
19
|
-
* started, unarchived): `runs` with a learning block, `merged`, `dropped` by reason, and `in_progress` (seeded
|
|
20
|
-
* reflecting
|
|
21
|
-
*
|
|
10
|
+
* started, unarchived): `runs` with a learning block, `merged`, `dropped` by reason, and `in_progress` (seeded or
|
|
11
|
+
* reflecting: a run this server holds). A run with learning off, a workflow's or an imported one, has none, and is not
|
|
12
|
+
* counted. */
|
|
22
13
|
export declare function learningStats(rows: readonly RunRow[], filter: AnalyticsFilter, learningOf: (row: RunRow) => {
|
|
23
14
|
state: string;
|
|
24
15
|
reason: string | null;
|
|
@@ -28,44 +19,32 @@ export declare function learningStats(rows: readonly RunRow[], filter: Analytics
|
|
|
28
19
|
dropped: Record<string, number>;
|
|
29
20
|
in_progress: number;
|
|
30
21
|
};
|
|
31
|
-
/** One side of an agent's impact: how many runs
|
|
32
|
-
*
|
|
33
|
-
*
|
|
22
|
+
/** One side of an agent's impact: how many runs and their median time to the answer. What a run costs is the cost
|
|
23
|
+
* read's all-in figure (learning-cost.ts: the takeover's before and after, learning included) and what learning cost
|
|
24
|
+
* is its bill's `learning_usd`: never a second cost here. */
|
|
34
25
|
export type ImpactSide = {
|
|
35
26
|
runs: number;
|
|
36
27
|
median_duration_s: number;
|
|
37
|
-
median_cost_usd: number | null;
|
|
38
|
-
cost_runs: number;
|
|
39
|
-
median_learning_usd: number | null;
|
|
40
28
|
};
|
|
41
29
|
export type Impact = {
|
|
42
30
|
before: ImpactSide;
|
|
43
31
|
after: ImpactSide;
|
|
44
32
|
} | null;
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
/** What a run's learning tells its impact (learning-run.ts ofAgent), from memory or from its ledger line: how it
|
|
49
|
-
* ended and when, how many notes it started from, when its answer was final and its costs; `grade_usd` once it ended
|
|
50
|
-
* (0 when nothing was graded), and `look_back_usd` 0 for a run that never looked back. */
|
|
33
|
+
/** What a run's learning tells its impact, from its learning end and its launch: how it ended and when, how many learned
|
|
34
|
+
* items it started from (its corrections' lines and the learned workflows its claims laid) and when its answer was
|
|
35
|
+
* final. */
|
|
51
36
|
export type ImpactLearning = {
|
|
52
37
|
state: string;
|
|
53
38
|
reason: string | null;
|
|
54
39
|
at: string;
|
|
55
|
-
|
|
56
|
-
seed_skills?: number;
|
|
40
|
+
seed_corrections?: number;
|
|
57
41
|
seed_workflows?: number;
|
|
58
42
|
answered_at?: string;
|
|
59
|
-
job_cost_usd?: number | null;
|
|
60
|
-
look_back_usd?: number | null;
|
|
61
|
-
grade_usd?: number | null;
|
|
62
43
|
};
|
|
63
44
|
/** What learning changed for an agent, from its run rows (`rows`) and what its runs' learning says (`learningOf`),
|
|
64
|
-
* never a run's files. `after`: its completed agentic runs that started from at least one learned item
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* An imported or archived run is on neither side, nor is a later one with learning off or seeded with no note (every
|
|
70
|
-
* note retired), nor one whose learning predates these figures. Null unless both sides hold 2 runs or more. */
|
|
45
|
+
* never a run's files. `after`: its completed agentic runs that started from at least one learned item (seededItems).
|
|
46
|
+
* `before`: its completed agentic runs that started before its first item, the earlier of its first merge's end and the
|
|
47
|
+
* start of its first run that started from one; none of them could have. Each side (sideOf, secondsOf): its median
|
|
48
|
+
* time to the answer in seconds to a tenth. An imported or archived run is on neither side, nor is a later one with
|
|
49
|
+
* learning off or seeded with nothing. Null unless both sides hold 2 runs or more. */
|
|
71
50
|
export declare function learningImpact(rows: readonly RunRow[], learningOf: (row: RunRow) => ImpactLearning | null | undefined): Impact;
|
package/dist/learning-run.js
CHANGED
|
@@ -1,36 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { posix } from "node:path";
|
|
6
|
-
import { INDEX_FILE } from "./learn/index.js";
|
|
7
|
-
import { detailShown, LEARNED_DIR, LEARNING_LABEL, LEARNING_REASONS } from "./learning.js";
|
|
8
|
-
import { reflects } from "./reflect-range.js";
|
|
9
|
-
/** A path that names a file at the top of a run's copy of the folder: `.learning/<file>` relative to its work, as a
|
|
10
|
-
* harness's file tools take it, or the same at the end of an absolute path (claude-agent's CLI joins its working
|
|
11
|
-
* directory; a box names its own). */
|
|
12
|
-
const IN_COPY = new RegExp(`(?:^|/)${LEARNED_DIR.replace(".", "\\.")}/([^/]+)$`);
|
|
13
|
-
/** The files of the run's copy of the folder its job read, in the order it first read them, each once: every `read`
|
|
14
|
-
* call whose result came back a success, matched to its call by id (claude-agent's rows can hold the result above the
|
|
15
|
-
* call), on any harness: pi's, claude-agent's (the host's `read`, served to its CLI as `mcp__hands__read`) and codex's
|
|
16
|
-
* (the same tool, as an app-server dynamic tool) rows all name it `read`, with the path as the model gave it. The
|
|
17
|
-
* end-of-run turn's reads are its own, not the job's, and are left out; so is a read that failed or never ended, and
|
|
18
|
-
* MEMORY.md, which is no note. Which of these files are notes the run started from is for its seed to say (noteUsed). */
|
|
19
|
-
export function notesRead(reflect, rows) {
|
|
20
|
-
const done = new Set(rows.flatMap((row) => (row.kind === "tool_result" && row.tool_status === "success" && row.tool_use_id ? [row.tool_use_id] : [])));
|
|
21
|
-
const read = new Set();
|
|
22
|
-
for (const row of rows) {
|
|
23
|
-
if (row.kind !== "tool_use" || row.tool_name !== "read" || !row.tool_use_id || !done.has(row.tool_use_id) || reflects(reflect, row.id))
|
|
24
|
-
continue;
|
|
25
|
-
const file = IN_COPY.exec(posix.normalize(row.tool_input_preview ?? ""))?.[1];
|
|
26
|
-
if (file && file !== INDEX_FILE)
|
|
27
|
-
read.add(file);
|
|
28
|
-
}
|
|
29
|
-
return [...read];
|
|
30
|
-
}
|
|
31
|
-
/** The run's learning row, once its learning was proposed, merged or dropped (`seed_failed` included): its state, reason
|
|
32
|
-
* and detail, its summary the detail itself as the run's view says it (learning.ts detailShown: cut of the host's
|
|
33
|
-
* secrets now, `shown`, then cut short). One row, which says where the learning ended. */
|
|
1
|
+
import { detailShown, LEARNING_LABEL, LEARNING_REASONS } from "./learning.js";
|
|
2
|
+
/** The run's learning row, once its learning merged or dropped (`seed_failed` included): its state, reason and detail,
|
|
3
|
+
* its summary the detail itself as the run's view says it (learning.ts detailShown: cut of the host's secrets now,
|
|
4
|
+
* `shown`, then cut short). One row, which says where the learning ended. */
|
|
34
5
|
export function withLearning(rows, learning, shown) {
|
|
35
6
|
if (!learning || learning.state === "seeded" || learning.state === "reflecting")
|
|
36
7
|
return [...rows];
|
|
@@ -45,9 +16,9 @@ export function withLearning(rows, learning, shown) {
|
|
|
45
16
|
return [...rows, row];
|
|
46
17
|
}
|
|
47
18
|
/** How the runs that tried to learn fared, over the runs the analytics' `from`, `to` and `agent` pick (by when they
|
|
48
|
-
* started, unarchived): `runs` with a learning block, `merged`, `dropped` by reason, and `in_progress` (seeded
|
|
49
|
-
* reflecting
|
|
50
|
-
*
|
|
19
|
+
* started, unarchived): `runs` with a learning block, `merged`, `dropped` by reason, and `in_progress` (seeded or
|
|
20
|
+
* reflecting: a run this server holds). A run with learning off, a workflow's or an imported one, has none, and is not
|
|
21
|
+
* counted. */
|
|
51
22
|
export function learningStats(rows, filter, learningOf) {
|
|
52
23
|
const from = filter.from === undefined ? -Infinity : Date.parse(filter.from);
|
|
53
24
|
const to = filter.to === undefined ? Infinity : Date.parse(filter.to);
|
|
@@ -57,7 +28,7 @@ export function learningStats(rows, filter, learningOf) {
|
|
|
57
28
|
if (row.kind !== "agentic" || row.importedFrom || row.archivedAt || !(at >= from && at < to) || (filter.agent !== undefined && row.agent !== filter.agent))
|
|
58
29
|
continue;
|
|
59
30
|
const learning = learningOf(row);
|
|
60
|
-
// A reason this server does not give
|
|
31
|
+
// A reason this server does not give is not counted.
|
|
61
32
|
if (!learning || (learning.reason !== null && !LEARNING_REASONS.includes(learning.reason)))
|
|
62
33
|
continue;
|
|
63
34
|
out.runs += 1;
|
|
@@ -70,68 +41,27 @@ export function learningStats(rows, filter, learningOf) {
|
|
|
70
41
|
}
|
|
71
42
|
return out;
|
|
72
43
|
}
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const out = new Map();
|
|
77
|
-
for (const files of runs) {
|
|
78
|
-
if (!files)
|
|
79
|
-
continue;
|
|
80
|
-
for (const key of ["given", "read"]) {
|
|
81
|
-
for (const file of new Set(files[key])) {
|
|
82
|
-
const counts = out.get(file) ?? { given: 0, read: 0 };
|
|
83
|
-
counts[key] += 1;
|
|
84
|
-
out.set(file, counts);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return out;
|
|
89
|
-
}
|
|
90
|
-
/** How many learned items a run started from: its notes, the learned skills it was offered and the learned workflows its
|
|
91
|
-
* learned_workflow tool could run. */
|
|
92
|
-
const seededItems = (learning) => (learning?.seed_notes ?? 0) + (learning?.seed_skills ?? 0) + (learning?.seed_workflows ?? 0);
|
|
93
|
-
/** The middle of `values` (the mean of the two middle ones when there is an even count); undefined for none. */
|
|
44
|
+
/** How many learned items a run started from. */
|
|
45
|
+
const seededItems = (learning) => (learning?.seed_corrections ?? 0) + (learning?.seed_workflows ?? 0);
|
|
46
|
+
/** The middle of `values` (the mean of the two middle ones when there is an even count). */
|
|
94
47
|
const median = (values) => {
|
|
95
|
-
if (!values.length)
|
|
96
|
-
return undefined;
|
|
97
48
|
const sorted = [...values].sort((a, b) => a - b);
|
|
98
49
|
const mid = sorted.length >> 1;
|
|
99
50
|
return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
100
51
|
};
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
median_cost_usd: usd(median(costs)),
|
|
108
|
-
cost_runs: costs.length,
|
|
109
|
-
median_learning_usd: usd(median(runs.flatMap((run) => (typeof run.learning === "number" ? [run.learning] : [])))),
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
/** Completed run `row` as its impact counts it, `learning` what its learning says. One that looked back answered when
|
|
113
|
-
* its job ended, and its job's cost is what it had cost by then; any other's are its row's end and cost, which no look
|
|
114
|
-
* back follows. Undefined for one whose learning a server before these figures kept (it says neither how many notes
|
|
115
|
-
* it started from nor when it answered): its row's end and cost hold its look-back too. */
|
|
116
|
-
function figuresOf(row, learning) {
|
|
117
|
-
if (learning && learning.seed_notes === undefined && learning.reason !== "seed_failed")
|
|
118
|
-
return undefined;
|
|
119
|
-
const looked = learning?.answered_at !== undefined;
|
|
120
|
-
const answered = looked ? Date.parse(learning.answered_at) : Date.parse(row.endedAt);
|
|
121
|
-
const cost = looked ? (learning.job_cost_usd ?? null) : (row.costUsd ?? null);
|
|
122
|
-
if (!learning)
|
|
123
|
-
return { seconds: (answered - Date.parse(row.startedAt)) / 1000, cost };
|
|
124
|
-
const { look_back_usd: back, grade_usd: grade } = learning;
|
|
125
|
-
return { seconds: (answered - Date.parse(row.startedAt)) / 1000, cost, learning: typeof back === "number" && typeof grade === "number" ? back + grade : null };
|
|
52
|
+
const sideOf = (seconds) => ({ runs: seconds.length, median_duration_s: Math.round(median(seconds) * 10) / 10 });
|
|
53
|
+
/** Completed run `row`'s seconds to its answer, `learning` what its learning says: one whose end-of-run step asked a
|
|
54
|
+
* model turn answered when its job ended; any other when its row ended. */
|
|
55
|
+
function secondsOf(row, learning) {
|
|
56
|
+
const answered = learning?.answered_at !== undefined ? Date.parse(learning.answered_at) : Date.parse(row.endedAt);
|
|
57
|
+
return (answered - Date.parse(row.startedAt)) / 1000;
|
|
126
58
|
}
|
|
127
59
|
/** What learning changed for an agent, from its run rows (`rows`) and what its runs' learning says (`learningOf`),
|
|
128
|
-
* never a run's files. `after`: its completed agentic runs that started from at least one learned item
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* An imported or archived run is on neither side, nor is a later one with learning off or seeded with no note (every
|
|
134
|
-
* note retired), nor one whose learning predates these figures. Null unless both sides hold 2 runs or more. */
|
|
60
|
+
* never a run's files. `after`: its completed agentic runs that started from at least one learned item (seededItems).
|
|
61
|
+
* `before`: its completed agentic runs that started before its first item, the earlier of its first merge's end and the
|
|
62
|
+
* start of its first run that started from one; none of them could have. Each side (sideOf, secondsOf): its median
|
|
63
|
+
* time to the answer in seconds to a tenth. An imported or archived run is on neither side, nor is a later one with
|
|
64
|
+
* learning off or seeded with nothing. Null unless both sides hold 2 runs or more. */
|
|
135
65
|
export function learningImpact(rows, learningOf) {
|
|
136
66
|
const done = rows.filter((row) => row.kind === "agentic" && !row.importedFrom && !row.archivedAt && row.state === "completed" && row.endedAt);
|
|
137
67
|
const after = done.filter((row) => seededItems(learningOf(row)) > 0);
|
|
@@ -140,7 +70,7 @@ export function learningImpact(rows, learningOf) {
|
|
|
140
70
|
return learning?.state === "merged" ? [Date.parse(learning.at)] : [];
|
|
141
71
|
});
|
|
142
72
|
const first = Math.min(...merges, ...after.map((row) => Date.parse(row.startedAt)));
|
|
143
|
-
const counted = (side) => side.
|
|
73
|
+
const counted = (side) => side.map((row) => secondsOf(row, learningOf(row)));
|
|
144
74
|
const [before, later] = [counted(done.filter((row) => Date.parse(row.startedAt) < first)), counted(after)];
|
|
145
75
|
return before.length >= 2 && later.length >= 2 ? { before: sideOf(before), after: sideOf(later) } : null;
|
|
146
76
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/** The loop's
|
|
1
|
+
/** The loop's settings as a definition may set them (each optional: its default stands in). */
|
|
2
2
|
export interface LearningLoop {
|
|
3
3
|
readonly compile_after?: number;
|
|
4
4
|
readonly agree_min?: number;
|
|
5
5
|
readonly alone_min?: number;
|
|
6
|
+
readonly agree_on?: readonly string[];
|
|
6
7
|
readonly audit_every?: number;
|
|
7
8
|
readonly audit_every_later?: number;
|
|
8
9
|
readonly audit_later_after?: number;
|
|
@@ -10,12 +11,13 @@ export interface LearningLoop {
|
|
|
10
11
|
readonly hold_disagree?: number;
|
|
11
12
|
readonly stop_window?: number;
|
|
12
13
|
}
|
|
13
|
-
/** The check's numbers (runner/promotion.ts): what a check record keeps of the loop
|
|
14
|
-
|
|
14
|
+
/** The check's numbers (runner/promotion.ts): what a check record keeps of the loop, with the paths it compares on (the
|
|
15
|
+
* definition's agree_on; absent, the whole answer). */
|
|
16
|
+
export type CheckLoop = Required<Pick<LearningLoop, "compile_after" | "agree_min" | "alone_min">> & Pick<LearningLoop, "agree_on">;
|
|
15
17
|
/** The audit's numbers (runner/audit.ts). */
|
|
16
18
|
export type AuditLoop = Required<Pick<LearningLoop, "audit_every" | "audit_every_later" | "audit_later_after" | "hold_window" | "hold_disagree" | "stop_window">>;
|
|
17
19
|
/** A definition's `learning`, as kept on an agentic revision. */
|
|
18
|
-
export type LearningSetting = boolean |
|
|
20
|
+
export type LearningSetting = boolean | LearningLoop;
|
|
19
21
|
export declare const COMPILE_AFTER_DEFAULT = 20;
|
|
20
22
|
export declare const AGREE_MIN_DEFAULT = 0.8;
|
|
21
23
|
export declare const ALONE_MIN_DEFAULT = 0.7;
|
|
@@ -24,15 +26,24 @@ export declare const COMPILE_AFTER_MAX = 200;
|
|
|
24
26
|
export declare const AUDIT_DEFAULTS: AuditLoop;
|
|
25
27
|
/** The most any audit number may be: 1 in 1,000 runs, a window of 1,000 (the ledger keeps more rows than that). */
|
|
26
28
|
export declare const AUDIT_MAX = 1000;
|
|
27
|
-
/**
|
|
28
|
-
export declare const
|
|
29
|
-
|
|
29
|
+
/** The most paths agree_on names, the most characters of each, and the most segments of each. */
|
|
30
|
+
export declare const AGREE_ON_MAX = 16;
|
|
31
|
+
export declare const AGREE_ON_PATH_MAX = 128;
|
|
32
|
+
export declare const AGREE_ON_SEGMENTS_MAX = 8;
|
|
33
|
+
/** An agree_on path's segments: each a key of an object, from the answer's top level down (a dot always splits). */
|
|
34
|
+
export declare const pathSegments: (path: string) => string[];
|
|
35
|
+
/** Whether `learning` has the agent's runs learn (true, or an object): never false or absent. */
|
|
36
|
+
export declare const learnsOf: (learning: unknown) => boolean;
|
|
37
|
+
/** The paths a revision's two answers are compared on: its `learning.agree_on`; undefined, the whole answer. */
|
|
38
|
+
export declare const agreeOnOf: (learning: unknown) => readonly string[] | undefined;
|
|
39
|
+
/** The loop's numbers for a revision's `learning`: its object's, each one it leaves out at its default, with its
|
|
40
|
+
* agree_on when set. */
|
|
30
41
|
export declare function loopOf(learning: unknown): CheckLoop;
|
|
31
42
|
/** The audit's numbers for a revision's `learning`: its object's, each one it leaves out at its default (AUDIT_DEFAULTS). */
|
|
32
43
|
export declare function auditLoopOf(learning: unknown): AuditLoop;
|
|
33
44
|
/** What is wrong with a definition's `learning`, in words naming the field (`at` its path), or undefined when it is one
|
|
34
|
-
* of true, false
|
|
45
|
+
* of true, false or an object of the loop's numbers. */
|
|
35
46
|
export declare function learningSettingIssue(value: unknown, at?: string): string | undefined;
|
|
36
|
-
/** A valid `learning` as a revision keeps it: an object's
|
|
37
|
-
* one body. */
|
|
47
|
+
/** A valid `learning` as a revision keeps it: an object's keys in one order, so two definitions that say the same are
|
|
48
|
+
* one body (agree_on's list as its owner gave it: its order is theirs). */
|
|
38
49
|
export declare function learningSettingOf(value: LearningSetting): LearningSetting;
|
package/dist/learning-setting.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// An agent definition's `learning`: true, false,
|
|
1
|
+
// An agent definition's `learning`: true, false, or an object, which is on (as true) with the loop's numbers set
|
|
2
2
|
// on it. Every number of the loop lives here, on the agent, each with a default: none is an engine constant.
|
|
3
3
|
// compile_after (N): the agent's job compiles into a workflow once it has this many completed agent runs;
|
|
4
4
|
// agree_min (A): the compiled draft is checked once on the inputs of those N runs, and promoted only when, of the inputs
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
// hold_window, hold_disagree: it stops serving (a hold) when its last hold_window audit rows hold at least
|
|
12
12
|
// hold_disagree disagreements;
|
|
13
13
|
// stop_window: a second hold within this many served runs of the first stops it for good.
|
|
14
|
+
// Both compare two answers (learn/promote.ts sameAnswer) on agree_on, the definition's dotted paths into the answer's
|
|
15
|
+
// JSON object that say the decision (`verdict.decision`); absent, the whole answer. Nothing is read off the output
|
|
16
|
+
// schema: its enum can be an echo of the owner's setting, not the decision, and a wrong field that promotes is worse than
|
|
17
|
+
// none.
|
|
14
18
|
export const COMPILE_AFTER_DEFAULT = 20;
|
|
15
19
|
export const AGREE_MIN_DEFAULT = 0.8;
|
|
16
20
|
export const ALONE_MIN_DEFAULT = 0.7;
|
|
@@ -20,7 +24,24 @@ export const AUDIT_DEFAULTS = { audit_every: 10, audit_every_later: 20, audit_la
|
|
|
20
24
|
/** The most any audit number may be: 1 in 1,000 runs, a window of 1,000 (the ledger keeps more rows than that). */
|
|
21
25
|
export const AUDIT_MAX = 1_000;
|
|
22
26
|
const AUDIT_KEYS = ["audit_every", "audit_every_later", "audit_later_after", "hold_window", "hold_disagree", "stop_window"];
|
|
23
|
-
const LOOP_KEYS = ["compile_after", "agree_min", "alone_min", ...AUDIT_KEYS];
|
|
27
|
+
const LOOP_KEYS = ["compile_after", "agree_min", "alone_min", "agree_on", ...AUDIT_KEYS];
|
|
28
|
+
/** The most paths agree_on names, the most characters of each, and the most segments of each. */
|
|
29
|
+
export const AGREE_ON_MAX = 16;
|
|
30
|
+
export const AGREE_ON_PATH_MAX = 128;
|
|
31
|
+
export const AGREE_ON_SEGMENTS_MAX = 8;
|
|
32
|
+
/** An agree_on path's segments: each a key of an object, from the answer's top level down (a dot always splits). */
|
|
33
|
+
export const pathSegments = (path) => path.split(".");
|
|
34
|
+
/** What is wrong with one agree_on path, in words, or undefined. */
|
|
35
|
+
function pathIssue(path) {
|
|
36
|
+
if (path.length > AGREE_ON_PATH_MAX)
|
|
37
|
+
return `over ${AGREE_ON_PATH_MAX} characters`;
|
|
38
|
+
const segments = pathSegments(path);
|
|
39
|
+
if (segments.some((segment) => !segment))
|
|
40
|
+
return "an empty segment";
|
|
41
|
+
if (segments.length > AGREE_ON_SEGMENTS_MAX)
|
|
42
|
+
return `more than ${AGREE_ON_SEGMENTS_MAX} segments`;
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
24
45
|
/** Each audit number's words, for its 422. */
|
|
25
46
|
const AUDIT_WORDS = {
|
|
26
47
|
audit_every: "audits 1 in this many served runs",
|
|
@@ -31,15 +52,20 @@ const AUDIT_WORDS = {
|
|
|
31
52
|
stop_window: "is the served runs within which a second hold stops the workflow",
|
|
32
53
|
};
|
|
33
54
|
const isLoop = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
34
|
-
/** Whether `learning` has the agent's runs learn
|
|
35
|
-
export const
|
|
36
|
-
/** The
|
|
55
|
+
/** Whether `learning` has the agent's runs learn (true, or an object): never false or absent. */
|
|
56
|
+
export const learnsOf = (learning) => learning === true || isLoop(learning);
|
|
57
|
+
/** The paths a revision's two answers are compared on: its `learning.agree_on`; undefined, the whole answer. */
|
|
58
|
+
export const agreeOnOf = (learning) => (isLoop(learning) && learning.agree_on?.length ? [...learning.agree_on] : undefined);
|
|
59
|
+
/** The loop's numbers for a revision's `learning`: its object's, each one it leaves out at its default, with its
|
|
60
|
+
* agree_on when set. */
|
|
37
61
|
export function loopOf(learning) {
|
|
38
62
|
const set = isLoop(learning) ? learning : {};
|
|
63
|
+
const on = agreeOnOf(learning);
|
|
39
64
|
return {
|
|
40
65
|
compile_after: set.compile_after ?? COMPILE_AFTER_DEFAULT,
|
|
41
66
|
agree_min: set.agree_min ?? AGREE_MIN_DEFAULT,
|
|
42
67
|
alone_min: set.alone_min ?? ALONE_MIN_DEFAULT,
|
|
68
|
+
...(on ? { agree_on: on } : {}),
|
|
43
69
|
};
|
|
44
70
|
}
|
|
45
71
|
/** The audit's numbers for a revision's `learning`: its object's, each one it leaves out at its default (AUDIT_DEFAULTS). */
|
|
@@ -48,15 +74,25 @@ export function auditLoopOf(learning) {
|
|
|
48
74
|
return Object.fromEntries(AUDIT_KEYS.map((key) => [key, set[key] ?? AUDIT_DEFAULTS[key]]));
|
|
49
75
|
}
|
|
50
76
|
/** What is wrong with a definition's `learning`, in words naming the field (`at` its path), or undefined when it is one
|
|
51
|
-
* of true, false
|
|
77
|
+
* of true, false or an object of the loop's numbers. */
|
|
52
78
|
export function learningSettingIssue(value, at = "learning") {
|
|
53
|
-
if (typeof value === "boolean"
|
|
79
|
+
if (typeof value === "boolean")
|
|
54
80
|
return undefined;
|
|
55
81
|
if (!isLoop(value))
|
|
56
|
-
return `${at} is true, false
|
|
82
|
+
return `${at} is true, false or an object of the loop's numbers ({${LOOP_KEYS.map((key) => `${key}?`).join(", ")}}, on with those set)`;
|
|
57
83
|
const other = Object.keys(value).find((key) => !LOOP_KEYS.includes(key));
|
|
58
84
|
if (other !== undefined)
|
|
59
85
|
return `${at}.${other} is not one of the loop's numbers: ${LOOP_KEYS.join(", ")}`;
|
|
86
|
+
const on = value.agree_on;
|
|
87
|
+
if (on !== undefined) {
|
|
88
|
+
if (!(Array.isArray(on) && on.length >= 1 && on.length <= AGREE_ON_MAX && on.every((one) => typeof one === "string") && new Set(on).size === on.length))
|
|
89
|
+
return `${at}.agree_on is a list of 1 to ${AGREE_ON_MAX} distinct dotted paths into the answer's JSON object (e.g. verdict.decision)`;
|
|
90
|
+
for (const [i, path] of on.entries()) {
|
|
91
|
+
const why = pathIssue(path);
|
|
92
|
+
if (why)
|
|
93
|
+
return `${at}.agree_on[${i}] is not a dotted path into the answer's JSON object (e.g. verdict.decision): ${why}`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
60
96
|
const { compile_after: after, agree_min: agree, alone_min: alone } = value;
|
|
61
97
|
if (after !== undefined && !(Number.isInteger(after) && after >= 1 && after <= COMPILE_AFTER_MAX))
|
|
62
98
|
return `${at}.compile_after is a whole number of completed runs from 1 to ${COMPILE_AFTER_MAX}`;
|
|
@@ -74,10 +110,10 @@ export function learningSettingIssue(value, at = "learning") {
|
|
|
74
110
|
return `${at}.hold_disagree is at most hold_window (${audit.hold_window}): the disagreements are counted in that many rows`;
|
|
75
111
|
return undefined;
|
|
76
112
|
}
|
|
77
|
-
/** A valid `learning` as a revision keeps it: an object's
|
|
78
|
-
* one body. */
|
|
113
|
+
/** A valid `learning` as a revision keeps it: an object's keys in one order, so two definitions that say the same are
|
|
114
|
+
* one body (agree_on's list as its owner gave it: its order is theirs). */
|
|
79
115
|
export function learningSettingOf(value) {
|
|
80
116
|
if (!isLoop(value))
|
|
81
117
|
return value;
|
|
82
|
-
return Object.fromEntries(LOOP_KEYS.flatMap((key) => (value[key] !== undefined ? [[key, value[key]]] : [])));
|
|
118
|
+
return Object.fromEntries(LOOP_KEYS.flatMap((key) => (value[key] !== undefined ? [[key, key === "agree_on" ? [...value.agree_on] : value[key]]] : [])));
|
|
83
119
|
}
|
package/dist/learning-words.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Problem
|
|
1
|
+
import { type Problem } from "./learn/index.js";
|
|
2
2
|
import type { LearnedFile, Learning } from "./learning.js";
|
|
3
3
|
/** `text` on one line, at most `max` characters, cut at a word with an ellipsis when it is longer. */
|
|
4
4
|
export declare function short(text: string, max: number): string;
|
|
@@ -6,99 +6,53 @@ export declare function short(text: string, max: number): string;
|
|
|
6
6
|
* cut of the host's secrets), and the most a run list's row says. */
|
|
7
7
|
export declare const DETAIL_MAX = 300;
|
|
8
8
|
export declare const LIST_DETAIL = 140;
|
|
9
|
-
/** The
|
|
10
|
-
*
|
|
11
|
-
export declare
|
|
9
|
+
/** The problem that says corrections.md had no room for the owner's correction (learn/corrections.ts' cap), if any: the
|
|
10
|
+
* one `too_large` that is not a workflow's. */
|
|
11
|
+
export declare const correctionsCapOf: <P extends Pick<Problem, "rule" | "path" | "detail">>(problems: readonly P[]) => P | undefined;
|
|
12
12
|
/** Why learning stopped, said plainly: the cause inside "Not kept: learning stopped (...)". */
|
|
13
13
|
export declare const STOPPED: {
|
|
14
|
-
readonly unreadable: "the agent
|
|
15
|
-
readonly notCopied: "the agent
|
|
16
|
-
readonly noSeed: "the run started without the agent
|
|
17
|
-
readonly serverStopped: "the server stopped while it set up the run's notes, so the run started without them";
|
|
14
|
+
readonly unreadable: "what the agent learned could not be read, so the run started without it";
|
|
15
|
+
readonly notCopied: "what the agent learned could not be handed to the run, so the run started without it";
|
|
16
|
+
readonly noSeed: "the run started without what the agent learned";
|
|
18
17
|
readonly cancelled: "the run was cancelled";
|
|
19
|
-
readonly cancelledLooking: "the run was cancelled while it
|
|
20
|
-
readonly crashed: "the run's process ended before it could
|
|
21
|
-
readonly
|
|
22
|
-
readonly
|
|
23
|
-
readonly notChecked: "
|
|
18
|
+
readonly cancelledLooking: "the run was cancelled while it wrote what it learned";
|
|
19
|
+
readonly crashed: "the run's process ended before it could keep what it learned";
|
|
20
|
+
readonly failed: "writing what it learned ended on an error";
|
|
21
|
+
readonly unanswered: "the turn that writes its workflow ended before it answered";
|
|
22
|
+
readonly notChecked: "what it learned could not be checked";
|
|
24
23
|
readonly refuseUnread: "what the run must never learn (its agent's browser sign-in, the server's secrets) could not be read back, so nothing it learned is kept";
|
|
25
|
-
readonly noReview: "the review of the new notes gave no answer";
|
|
26
|
-
readonly unread: "the review of the new notes gave an answer that could not be read";
|
|
27
|
-
readonly contradicted: "the review of the new notes contradicted itself: it kept them and said not to";
|
|
28
|
-
readonly contradictedTwice: "the review of the new notes contradicted itself twice: it kept them and said not to";
|
|
29
24
|
};
|
|
30
25
|
/** A run's learning, in words, by where it stands. */
|
|
31
26
|
export declare const said: {
|
|
32
|
-
seeded: (
|
|
27
|
+
seeded: (corrections: number, workflows?: number) => string;
|
|
33
28
|
reflecting: string;
|
|
34
|
-
/**
|
|
29
|
+
/** A message of the end-of-run turn, as a person reads it in the timeline: never the prompt the model is sent. */
|
|
35
30
|
asked: string;
|
|
36
|
-
/** The end-of-run turn asked again because a workflow draft failed its dry run (learn/reflect.ts reflectDryRun), as a
|
|
37
|
-
* person reads it in the timeline: never the ask, which holds the check's words. */
|
|
38
|
-
askedDryRun: string;
|
|
39
31
|
/** The compile turn's ask (learn/compile.ts askedForCompile): the job written as a workflow, or a revision of one, or
|
|
40
32
|
* an attempt the checks sent back. */
|
|
41
33
|
askedCompile: string;
|
|
42
34
|
askedCompileAgain: string;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* word on the first it dropped. A merge that only holds things for the OK says that alone. */
|
|
47
|
-
merged: (learned: readonly {
|
|
48
|
-
name: string;
|
|
49
|
-
supersedes: readonly string[];
|
|
50
|
-
}[], pending?: readonly {
|
|
51
|
-
name: string;
|
|
52
|
-
}[], files?: readonly Pick<LearnedFile, "file" | "name" | "pending">[], left?: readonly {
|
|
53
|
-
why: string;
|
|
54
|
-
}[], checked?: readonly Pick<Problem, "rule" | "path">[]) => string;
|
|
35
|
+
/** What it learned: its workflow by name and the corrections it added; then what waits for the owner's OK, by name;
|
|
36
|
+
* then what the checks refused beside it. A merge that only holds things for the OK says that alone. */
|
|
37
|
+
merged: (files?: readonly Pick<LearnedFile, "name" | "pending">[], corrections?: number, checked?: readonly Pick<Problem, "rule" | "path" | "detail">[]) => string;
|
|
55
38
|
empty: string;
|
|
56
|
-
/** A run whose only work was its learned workflows, each answering, with nothing said after its first message:
|
|
57
|
-
*
|
|
39
|
+
/** A run whose only work was its learned workflows, each answering, with nothing said after its first message: nothing
|
|
40
|
+
* to compile (runner/learning-end.ts onlyLearnedWorkflows). */
|
|
58
41
|
onlyWorkflow: string;
|
|
59
|
-
/** A run of an agent that learns workflows, with no feedback from its owner (no grade's words, no message after its
|
|
60
|
-
* first): it was not asked to look back (runner/learning-end.ts ownerSaid); its trace is what a compile reads. */
|
|
61
|
-
noFeedback: string;
|
|
62
42
|
/** A run started with `learning: "use"`: it read what its agent learned and kept nothing, as asked. */
|
|
63
43
|
use: string;
|
|
64
44
|
/** A merge whose every item the owner has since retired: nothing it learned is kept now. */
|
|
65
45
|
retiredSince: string;
|
|
66
|
-
/** The
|
|
67
|
-
|
|
68
|
-
/** The
|
|
69
|
-
|
|
70
|
-
/** The checks refused what the run wrote, at its end: its notes, or what it learned when a skill or a workflow is
|
|
71
|
-
* among what was refused. */
|
|
72
|
-
checker: (problems: readonly Pick<Problem, "rule" | "path">[]) => string;
|
|
73
|
-
/** The agent's notes as they are now no longer take what the run wrote (another run's or a person's change since). A
|
|
74
|
-
* note it would replace that is gone, or that a person changed after the grade read it, is the rule `supersedes`
|
|
75
|
-
* either way: said in one sentence true of both. */
|
|
76
|
-
stale: (problems: readonly Pick<Problem, "rule">[]) => string;
|
|
46
|
+
/** The checks refused what the run wrote, at its end. */
|
|
47
|
+
checker: (problems: readonly Pick<Problem, "rule">[]) => string;
|
|
48
|
+
/** The owner's correction would take corrections.md past its cap (learn/corrections.ts): `why`, the cap's words. */
|
|
49
|
+
correctionsFull: (why: string) => string;
|
|
77
50
|
noBudget: string;
|
|
78
|
-
/** The run's grade did not fit what its cap left (its learning run's cap): not run, so nothing it learned is kept. */
|
|
79
|
-
noRoomToGrade: string;
|
|
80
|
-
/** A grade under a cap whose cost can't be kept within it (its spend or the grade model's price unknown). */
|
|
81
|
-
gradeUncapped: string;
|
|
82
51
|
unknownCost: string;
|
|
83
|
-
/** A capped run whose spend under its cap is unknown once it looked back: its grade is not run (none could be kept
|
|
84
|
-
* within the cap), so nothing it learned is kept. */
|
|
85
|
-
gradeUnknownSpend: string;
|
|
86
52
|
stopped: (cause: string) => string;
|
|
87
53
|
};
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
|
|
93
|
-
* skill X: …"), any other as lost with it ("Not kept, with the skill X: …"). The caller cuts the line of the host's
|
|
94
|
-
* secrets: a name is the run's to choose. */
|
|
95
|
-
export declare function notKept(verdict: Pick<Verdict, "reason" | "items">, lost?: readonly Pick<LearnedFile, "file">[]): string;
|
|
96
|
-
/** The why of a note main already holds the same (a run's new note, or a skill re-filed as one: runner/learning-loop.ts
|
|
97
|
-
* takenOnMain): no change, so no words of a run's learning say it, the merge's own or a read's rebuilt from its verdict. */
|
|
98
|
-
export declare const SAME_NOTE = "The same rule is already one of the agent's notes.";
|
|
99
|
-
/** A run's learning in words as a read says them, whole: what it learned and what waits for the owner's OK, or why the
|
|
100
|
-
* grader kept nothing, said again from its parts (`learned`, `pending`, `verdict`) each cut by `cut` first (the host's
|
|
101
|
-
* secrets as they are now), and the whole line cut again, as notKept's is: a skill's or a workflow's file names it in
|
|
102
|
-
* the words, uncut until then; any other detail, the server's own sentence, cut as well. The caller cuts the words
|
|
103
|
-
* short after. */
|
|
104
|
-
export declare function wordsOf(learning: Pick<Learning, "state" | "reason" | "detail" | "learned" | "pending" | "verdict" | "skills" | "workflows" | "problems" | "lost">, cut: (text: string) => string): string | null;
|
|
54
|
+
/** A run's learning in words as a read says them, whole: what it learned and what waits for the owner's OK, said again
|
|
55
|
+
* from its parts (`workflows`, `corrections`, `problems`), each name cut by `cut` first (the host's secrets as they are
|
|
56
|
+
* now), and the whole line cut again; any other detail, the server's own sentence, cut as well. The caller cuts the
|
|
57
|
+
* words short after. */
|
|
58
|
+
export declare function wordsOf(learning: Pick<Learning, "state" | "detail" | "workflows" | "corrections" | "problems">, cut: (text: string) => string): string | null;
|