@parcha/agentrun-serve 0.1.0-beta.34 → 0.1.0-beta.36
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 +263 -0
- package/README.md +339 -179
- package/dist/adapters.d.ts +15 -2
- package/dist/adapters.js +34 -2
- package/dist/agent-rows.d.ts +3 -1
- package/dist/agents-store.d.ts +2 -0
- package/dist/agents-store.js +25 -5
- package/dist/api-only.d.ts +2 -1
- package/dist/api-only.js +3 -1
- package/dist/archil-routes.d.ts +40 -7
- package/dist/archil-routes.js +167 -54
- package/dist/archil-settings.d.ts +90 -8
- package/dist/archil-settings.js +150 -14
- package/dist/attach-images.d.ts +15 -0
- package/dist/attach-images.js +59 -0
- package/dist/background.d.ts +0 -6
- package/dist/background.js +0 -28
- package/dist/bash-read-only.d.ts +13 -0
- package/dist/bash-read-only.js +77 -0
- package/dist/box-image.d.ts +1 -97
- package/dist/box-image.js +4 -284
- package/dist/box-paths.d.ts +2 -7
- package/dist/box-paths.js +7 -13
- package/dist/box-settings.d.ts +0 -11
- package/dist/box-settings.js +4 -29
- package/dist/browser-commands.js +1 -1
- package/dist/browser-computer.d.ts +47 -3
- package/dist/browser-computer.js +286 -18
- package/dist/browser-cost.d.ts +2 -2
- package/dist/browser-cost.js +6 -4
- package/dist/browser-person.d.ts +19 -2
- package/dist/browser-person.js +55 -6
- package/dist/browser-wait-ended.d.ts +23 -0
- package/dist/browser-wait-ended.js +42 -0
- package/dist/cap.d.ts +19 -44
- package/dist/cap.js +31 -77
- package/dist/cli.js +36 -27
- package/dist/computer-keys.d.ts +20 -10
- package/dist/computer-keys.js +36 -57
- package/dist/computer-routes.d.ts +1 -4
- package/dist/computer-routes.js +3 -5
- package/dist/computer-setting.d.ts +8 -5
- package/dist/computer-setting.js +91 -26
- package/dist/computer-view.d.ts +11 -2
- package/dist/computer-view.js +2 -1
- package/dist/computers.d.ts +54 -8
- package/dist/computers.js +101 -22
- package/dist/console/assets/index-BI4Byidu.js +550 -0
- package/dist/console/assets/index-C19gUF2n.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-cap.d.ts +7 -29
- package/dist/decision-cap.js +3 -94
- package/dist/docker-daemon.d.ts +2 -2
- package/dist/docker-daemon.js +2 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +8 -5
- package/dist/explain.js +3 -1
- package/dist/faux-computers.js +4 -0
- package/dist/files.d.ts +1 -9
- package/dist/files.js +1 -9
- package/dist/github-connection.js +25 -7
- package/dist/github-faux.d.ts +26 -0
- package/dist/github-faux.js +76 -0
- package/dist/github.d.ts +28 -4
- package/dist/github.js +46 -10
- package/dist/gpu-words.d.ts +14 -0
- package/dist/gpu-words.js +21 -0
- package/dist/graph-served.d.ts +5 -3
- package/dist/graph-served.js +14 -6
- package/dist/graph-view.d.ts +2 -0
- package/dist/graph-view.js +29 -2
- package/dist/handed-values.d.ts +1 -1
- package/dist/handed-values.js +1 -1
- package/dist/harness-install.d.ts +60 -3
- package/dist/harness-install.js +322 -34
- package/dist/harness-opencode/harness.js +0 -1
- package/dist/harness-opencode/host/policy.js +2 -2
- package/dist/harness.js +1 -1
- package/dist/host-tools.d.ts +8 -9
- package/dist/host-tools.js +7 -7
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -2
- package/dist/key-refusal.d.ts +1 -1
- package/dist/key-refusal.js +2 -2
- package/dist/learn/check.d.ts +10 -2
- package/dist/learn/check.js +126 -8
- package/dist/learn/commit.d.ts +40 -6
- package/dist/learn/commit.js +164 -20
- package/dist/learn/folder.d.ts +11 -3
- package/dist/learn/folder.js +40 -16
- package/dist/learn/grade.d.ts +22 -2
- package/dist/learn/grade.js +127 -19
- package/dist/learn/index.d.ts +2 -2
- package/dist/learn/index.js +2 -2
- package/dist/learn/learning.sh +11 -13
- package/dist/learn/notes.d.ts +17 -3
- package/dist/learn/notes.js +19 -6
- package/dist/learn/reflect.d.ts +5 -2
- package/dist/learn/reflect.js +48 -32
- package/dist/learn/skills.d.ts +52 -5
- package/dist/learn/skills.js +104 -21
- package/dist/learned-nodes.d.ts +18 -0
- package/dist/learned-nodes.js +8 -0
- package/dist/learned-workflow.d.ts +27 -13
- package/dist/learned-workflow.js +110 -38
- package/dist/learning-cost.d.ts +79 -0
- package/dist/learning-cost.js +69 -0
- package/dist/learning-routes.d.ts +48 -2
- package/dist/learning-routes.js +99 -28
- package/dist/learning-run.d.ts +7 -5
- package/dist/learning-run.js +9 -6
- package/dist/learning-words.d.ts +3 -0
- package/dist/learning-words.js +6 -2
- package/dist/learning.d.ts +13 -28
- package/dist/learning.js +4 -18
- package/dist/llm.d.ts +4 -1
- package/dist/llm.js +4 -2
- package/dist/mcp-gateway.d.ts +6 -0
- package/dist/mcp-gateway.js +11 -1
- package/dist/mcp-probe.d.ts +8 -1
- package/dist/mcp-probe.js +62 -20
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.d.ts +12 -12
- package/dist/mcp-servers-store.js +8 -3
- package/dist/model.d.ts +8 -5
- package/dist/model.js +14 -6
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +236 -55
- package/dist/owner.d.ts +0 -1
- package/dist/owner.js +0 -2
- package/dist/pause.d.ts +2 -19
- package/dist/pause.js +5 -74
- package/dist/place-offers.d.ts +97 -0
- package/dist/place-offers.js +206 -0
- package/dist/place.d.ts +9 -13
- package/dist/place.js +22 -32
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +31 -9
- package/dist/print.d.ts +1 -8
- package/dist/print.js +1 -14
- package/dist/propose.d.ts +3 -0
- package/dist/propose.js +25 -19
- package/dist/run-cut.d.ts +5 -0
- package/dist/run-cut.js +19 -0
- package/dist/run-db.js +3 -3
- package/dist/run-launch.d.ts +18 -3
- package/dist/run-launch.js +11 -5
- package/dist/run-learning-served.d.ts +12 -1
- package/dist/run-manifest.d.ts +2 -2
- package/dist/run-manifest.js +2 -2
- package/dist/run-reads-over-store.d.ts +4 -2
- package/dist/run-reads-over-store.js +10 -8
- package/dist/run-secrets.js +3 -3
- package/dist/run-timeline-served.js +60 -38
- package/dist/run-view.d.ts +35 -16
- package/dist/run-view.js +64 -35
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +20 -4
- package/dist/runner/adapter-loop.d.ts +46 -5
- package/dist/runner/adapter-loop.js +381 -56
- package/dist/runner/adapter-run-spec.d.ts +46 -4
- package/dist/runner/adapter-run-spec.js +200 -45
- package/dist/runner/adapters/pi.d.ts +39 -3
- package/dist/runner/adapters/pi.js +124 -29
- package/dist/runner/beside.d.ts +8 -0
- package/dist/runner/beside.js +24 -2
- package/dist/runner/claim-secrets.d.ts +6 -0
- package/dist/runner/claim-secrets.js +15 -1
- package/dist/runner/cli-run-spec.d.ts +10 -0
- package/dist/runner/cli-run-spec.js +207 -64
- package/dist/runner/commands.d.ts +5 -1
- package/dist/runner/commands.js +3 -3
- package/dist/runner/conformance/harness.d.ts +1 -1
- package/dist/runner/conformance/harness.js +13 -10
- package/dist/runner/github-app.d.ts +7 -2
- package/dist/runner/github-app.js +46 -15
- package/dist/runner/harness-loops.d.ts +6 -1
- package/dist/runner/harness-loops.js +24 -1
- package/dist/runner/journal-kinds.d.ts +53 -7
- package/dist/runner/journal-kinds.js +29 -1
- package/dist/runner/learning-end.d.ts +15 -0
- package/dist/runner/learning-end.js +113 -20
- package/dist/runner/learning-factory.js +6 -2
- package/dist/runner/learning-loop.d.ts +75 -1
- package/dist/runner/learning-loop.js +215 -22
- package/dist/runner/learning-seed.d.ts +8 -0
- package/dist/runner/learning-seed.js +7 -1
- package/dist/runner/loop-contract.d.ts +12 -0
- package/dist/runner/loop-contract.js +6 -0
- package/dist/runner/loop.d.ts +5 -1
- package/dist/runner/loop.js +20 -0
- package/dist/runner/main.d.ts +9 -4
- package/dist/runner/main.js +38 -13
- package/dist/runner/mcp-claim.d.ts +7 -0
- package/dist/runner/mcp-claim.js +35 -2
- package/dist/runner/mcp-github.d.ts +15 -4
- package/dist/runner/mcp-github.js +55 -11
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +2 -0
- package/dist/runner/metrics.d.ts +18 -1
- package/dist/runner/metrics.js +81 -1
- package/dist/runner/model-route.d.ts +6 -0
- package/dist/runner/model-route.js +5 -2
- package/dist/runner/pr-checkout.d.ts +59 -0
- package/dist/runner/pr-checkout.js +176 -0
- package/dist/runner/reflect-hook.d.ts +1 -0
- package/dist/runner/reflect-hook.js +3 -3
- package/dist/runner/runner.js +136 -19
- package/dist/runner/spec-holds.d.ts +13 -3
- package/dist/runner/spec-holds.js +13 -10
- package/dist/runner/store-port.d.ts +4 -1
- package/dist/runner/store-secrets.js +17 -1
- package/dist/runner/subagent.d.ts +44 -0
- package/dist/runner/subagent.js +188 -0
- package/dist/runner/workflow-host.d.ts +25 -4
- package/dist/runner/workflow-host.js +26 -4
- package/dist/runner/workflow-loop.d.ts +9 -3
- package/dist/runner/workflow-loop.js +17 -10
- package/dist/runner/workflow-spec.d.ts +28 -13
- package/dist/runner/workflow-spec.js +247 -102
- package/dist/runs-over-store.d.ts +18 -7
- package/dist/runs-over-store.js +149 -31
- package/dist/seal-key.d.ts +0 -2
- package/dist/seal-key.js +0 -2
- package/dist/sealing.js +1 -2
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/server-lock.js +4 -5
- package/dist/server.d.ts +49 -63
- package/dist/server.js +429 -230
- package/dist/stop-signals.d.ts +4 -2
- package/dist/stop-signals.js +5 -3
- package/dist/store/agent-body.d.ts +14 -3
- package/dist/store/agent-body.js +22 -8
- package/dist/store/deadline.d.ts +18 -0
- package/dist/store/deadline.js +49 -0
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.js +2 -1
- package/dist/store/postgres/connection.d.ts +4 -0
- package/dist/store/postgres/connection.js +64 -13
- package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +11 -8
- package/dist/store/seal.d.ts +13 -0
- package/dist/store/seal.js +19 -0
- package/dist/store/sqlite/connection.d.ts +5 -0
- package/dist/store/sqlite/connection.js +88 -82
- package/dist/store/sqlite/run-patch.d.ts +18 -2
- package/dist/store/sqlite/run-patch.js +31 -2
- package/dist/store/sqlite/store.js +65 -11
- package/dist/store/store.d.ts +62 -12
- package/dist/store/store.js +22 -1
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +1 -3
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +3 -6
- package/dist/store-reads/journal.js +83 -15
- package/dist/store-reads/learning.d.ts +73 -3
- package/dist/store-reads/learning.js +232 -9
- package/dist/store-reads/runs.d.ts +6 -4
- package/dist/store-reads/runs.js +17 -10
- package/dist/store-reads/stats.js +5 -1
- package/dist/store-view.d.ts +15 -1
- package/dist/store-view.js +88 -29
- package/dist/template-eval.js +2 -1
- package/dist/templates.d.ts +73 -4
- package/dist/templates.js +113 -23
- package/dist/timeline/timeline.d.ts +11 -1
- package/dist/timeline/timeline.js +19 -4
- package/dist/tool-blurbs.js +1 -0
- package/dist/tool-budget.d.ts +26 -0
- package/dist/tool-budget.js +56 -0
- package/dist/tool-gate.d.ts +13 -3
- package/dist/tool-gate.js +15 -7
- package/dist/tool-plane.d.ts +42 -29
- package/dist/tool-plane.js +64 -27
- package/dist/tools.d.ts +53 -39
- package/dist/tools.js +174 -79
- package/dist/trigger-signatures.d.ts +1 -0
- package/dist/trigger-signatures.js +3 -1
- package/dist/triggers.d.ts +3 -3
- package/dist/triggers.js +2 -2
- package/dist/turn-end.d.ts +0 -3
- package/dist/turn-end.js +0 -3
- package/dist/uploads.d.ts +28 -5
- package/dist/uploads.js +82 -9
- package/dist/usage-lines.d.ts +1 -1
- package/dist/usage.d.ts +1 -47
- package/dist/usage.js +3 -82
- package/dist/validate.d.ts +8 -0
- package/dist/validate.js +40 -3
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -2
- package/dist/workflow/decision-recovery.d.ts +23 -0
- package/dist/workflow/decision-recovery.js +80 -0
- package/dist/workflow/decisions.d.ts +134 -0
- package/dist/workflow/decisions.js +46 -0
- package/dist/workflow/host-session.d.ts +5 -0
- package/dist/workflow/host-session.js +85 -0
- package/dist/workflow/host-tools.d.ts +3 -0
- package/dist/workflow/host-tools.js +3 -0
- package/dist/workflow/node-runner.d.ts +112 -0
- package/dist/workflow/node-runner.js +270 -0
- package/dist/workflow/node.d.ts +88 -0
- package/dist/workflow/node.js +99 -0
- package/dist/workflow/operator-error.d.ts +4 -0
- package/dist/workflow/operator-error.js +4 -0
- package/dist/workflow/pi-versions.d.ts +9 -0
- package/dist/workflow/pi-versions.js +8 -0
- package/dist/workflow/readers.d.ts +36 -0
- package/dist/workflow/readers.js +145 -0
- package/dist/workflow/record-file.d.ts +10 -0
- package/dist/workflow/record-file.js +56 -0
- package/dist/workflow/record-tool.d.ts +76 -0
- package/dist/workflow/record-tool.js +126 -0
- package/dist/workflow/record.d.ts +151 -0
- package/dist/workflow/record.js +401 -0
- package/dist/workflow/run-error.d.ts +16 -0
- package/dist/workflow/run-error.js +26 -0
- package/dist/workflow/runner.d.ts +6 -0
- package/dist/workflow/runner.js +240 -0
- package/dist/workflow/store.d.ts +23 -0
- package/dist/workflow/store.js +242 -0
- package/dist/workflow/task.d.ts +133 -0
- package/dist/workflow/task.js +411 -0
- package/dist/workflow/thinking.d.ts +3 -0
- package/dist/workflow/thinking.js +7 -0
- package/dist/workflow/tool-context.d.ts +21 -0
- package/dist/workflow/tool-context.js +13 -0
- package/dist/workflow/types.d.ts +126 -0
- package/dist/workflow/types.js +1 -0
- package/dist/workflow/wal.d.ts +11 -0
- package/dist/workflow/wal.js +106 -0
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/agent-computer.d.ts +137 -0
- package/dist/workspace/agent-computer.js +292 -0
- package/dist/workspace/archil-claim.d.ts +13 -2
- package/dist/workspace/archil-claim.js +22 -13
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +4 -0
- package/dist/workspace/archil-disks.d.ts +49 -0
- package/dist/workspace/archil-disks.js +185 -0
- package/dist/workspace/archil-exec.d.ts +12 -2
- package/dist/workspace/archil-exec.js +18 -3
- package/dist/workspace/archil-mount-credential.d.ts +20 -4
- package/dist/workspace/archil-mount-credential.js +13 -4
- package/dist/workspace/archil.d.ts +2 -2
- package/dist/workspace/archil.js +25 -5
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/computer-deps.d.ts +18 -11
- package/dist/workspace/computer-deps.js +64 -40
- package/dist/workspace/computer-for-claim.d.ts +47 -9
- package/dist/workspace/computer-for-claim.js +236 -24
- package/dist/workspace/computer-janitor.d.ts +3 -2
- package/dist/workspace/computer-janitor.js +43 -9
- package/dist/workspace/computer-ledger.d.ts +3 -8
- package/dist/workspace/computer-ledger.js +7 -3
- package/dist/workspace/computer-providers.d.ts +5 -3
- package/dist/workspace/computer-providers.js +11 -9
- package/dist/workspace/hands.d.ts +5 -2
- package/dist/workspace/hands.js +4 -3
- package/dist/workspace/index.d.ts +5 -4
- package/dist/workspace/index.js +2 -1
- package/dist/workspace/local.d.ts +3 -0
- package/dist/workspace/local.js +9 -0
- package/dist/workspace/paths.js +3 -2
- package/dist/workspace/pi-env.d.ts +4 -0
- package/dist/workspace/pi-env.js +3 -2
- package/dist/workspace/resolve-computer.d.ts +48 -12
- package/dist/workspace/resolve-computer.js +88 -19
- package/dist/workspace/run-disk.d.ts +34 -0
- package/dist/workspace/run-disk.js +91 -0
- package/dist/workspace/run-tools.d.ts +6 -4
- package/dist/workspace/run-tools.js +17 -9
- package/dist/workspace/server-run-workspace.d.ts +3 -2
- package/dist/workspace/server-run-workspace.js +17 -4
- package/dist/workspace/workspace.d.ts +5 -0
- package/dist/workspace.d.ts +0 -3
- package/dist/workspace.js +2 -15
- package/package.json +11 -16
- package/skills/agentrun-serve/SKILL.md +1 -1
- package/templates/README.md +11 -8
- package/templates/code-review/agent.md +27 -11
- package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
- package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
- package/templates/code-review/evals/injection/graders/ignores.md +1 -1
- package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
- package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
- package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
- package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
- package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
- package/templates/code-review/evals/never-flag/case.yaml +3 -0
- package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
- package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
- package/templates/code-review/evals/never-flag/prompt.md +30 -0
- package/templates/code-review/evals/null-name/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
- package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
- package/templates/code-review/evals/re-review/prompt.md +1 -1
- package/templates/code-review/evals/re-review-open/case.yaml +3 -0
- package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
- package/templates/code-review/evals/re-review-open/prompt.md +27 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
- package/templates/code-review/evals/two-defects/case.yaml +3 -0
- package/templates/code-review/evals/two-defects/graders/both.md +4 -0
- package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
- package/templates/code-review/evals/two-defects/prompt.md +25 -0
- package/templates/code-review/findings.schema.json +131 -27
- package/templates/code-review/rules/CODEREVIEW.md +76 -0
- package/templates/code-review/skills/review/DEEP.md +130 -0
- package/templates/code-review/skills/review/REVIEWER.md +116 -0
- package/templates/code-review/skills/review/SKILL.md +104 -154
- package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
- package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
- package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
- package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
- package/templates/release-notes/agent.md +11 -0
- package/dist/box/record.d.ts +0 -6
- package/dist/box/record.js +0 -41
- package/dist/box/sweep.d.ts +0 -53
- package/dist/box/sweep.js +0 -193
- package/dist/box-egress-vm.d.ts +0 -118
- package/dist/box-egress-vm.js +0 -354
- package/dist/box-egress.d.ts +0 -105
- package/dist/box-egress.js +0 -256
- package/dist/box-relay-vm.d.ts +0 -84
- package/dist/box-relay-vm.js +0 -437
- package/dist/box-relay.d.ts +0 -36
- package/dist/box-relay.js +0 -207
- package/dist/boxes.d.ts +0 -109
- package/dist/boxes.js +0 -249
- package/dist/budget.d.ts +0 -76
- package/dist/budget.js +0 -204
- package/dist/console/assets/index-RPHGlXmM.js +0 -540
- package/dist/console/assets/index-opTN5Naq.css +0 -1
- package/dist/daytona-api.d.ts +0 -10
- package/dist/daytona-api.js +0 -20
- package/dist/egress-proxy.d.ts +0 -45
- package/dist/egress-proxy.js +0 -416
- package/dist/egress-table.d.ts +0 -24
- package/dist/egress-table.js +0 -165
- package/templates/code-review/rules/REVIEW.md +0 -41
|
@@ -17,7 +17,11 @@ export interface KeptProposal {
|
|
|
17
17
|
readonly status: string;
|
|
18
18
|
readonly detail?: string;
|
|
19
19
|
}>>;
|
|
20
|
+
/** The skill of each draft's name as the folder held it at the seed, which the grader is shown beside the draft. */
|
|
21
|
+
readonly drafted?: readonly NoteText[];
|
|
20
22
|
readonly asked?: readonly string[];
|
|
23
|
+
/** Why each draft waits for its owner's OK whatever the grade (the learning end's: skills.ts unpricedCalls). */
|
|
24
|
+
readonly held?: Readonly<Record<string, readonly string[]>>;
|
|
21
25
|
readonly triggered?: readonly {
|
|
22
26
|
readonly source: string;
|
|
23
27
|
readonly text: string;
|
|
@@ -31,6 +35,12 @@ export interface GradeMain {
|
|
|
31
35
|
readonly active: readonly IndexEntry[];
|
|
32
36
|
readonly superseded: readonly NoteText[];
|
|
33
37
|
readonly graded: Readonly<Record<string, string>>;
|
|
38
|
+
/** The proposal's notes named like a note main holds, left out of the grade and settled alone (learn/commit.ts
|
|
39
|
+
* readMain): `same` when main's note says its rule, else `taken`. */
|
|
40
|
+
readonly taken?: readonly {
|
|
41
|
+
readonly path: string;
|
|
42
|
+
readonly reason: "same" | "taken";
|
|
43
|
+
}[];
|
|
34
44
|
}
|
|
35
45
|
export type Problem = {
|
|
36
46
|
readonly rule: string;
|
|
@@ -50,12 +60,24 @@ export interface MergeChange {
|
|
|
50
60
|
readonly graded: Readonly<Record<string, string>>;
|
|
51
61
|
/** The run's seed: a skill's or a draft's file not on main as it was on it is a conflict, never written over. */
|
|
52
62
|
readonly seed?: string;
|
|
63
|
+
/** New notes written over main's note of the same name, each superseding it by name (takenOnMain). */
|
|
64
|
+
readonly replace?: readonly string[];
|
|
65
|
+
/** Each skill re-filed as a note, retired on main in the same write (its SKILL.md, and the note that replaces it). */
|
|
66
|
+
readonly retire?: readonly {
|
|
67
|
+
readonly skill: string;
|
|
68
|
+
readonly note: string;
|
|
69
|
+
}[];
|
|
53
70
|
}
|
|
54
71
|
export type LearningCommitResult = {
|
|
55
72
|
readonly ok: true;
|
|
56
73
|
readonly main: string;
|
|
57
74
|
readonly commit: string;
|
|
58
75
|
readonly files: readonly string[];
|
|
76
|
+
readonly left?: readonly {
|
|
77
|
+
readonly path: string;
|
|
78
|
+
readonly reason: "same" | "taken";
|
|
79
|
+
}[];
|
|
80
|
+
readonly already?: true;
|
|
59
81
|
} | {
|
|
60
82
|
readonly ok: false;
|
|
61
83
|
readonly reason: "conflict" | "refused";
|
|
@@ -102,6 +124,15 @@ export interface LearningLoopDeps {
|
|
|
102
124
|
}>;
|
|
103
125
|
/** The folder's one write. */
|
|
104
126
|
commit(ws: unknown, change: MergeChange): Promise<LearningCommitResult>;
|
|
127
|
+
/** The texts main holds at these note paths (learn/commit.ts mainTexts): a note the merge keeps whose name main
|
|
128
|
+
* already holds is settled alone (takenOnMain). */
|
|
129
|
+
mainTexts(ws: unknown, paths: readonly string[]): Promise<Readonly<Record<string, string>>>;
|
|
130
|
+
/** Run `runId`'s merge, when it is on main already (learn/folder.ts readRunDiff: its diff file, named by the run as its
|
|
131
|
+
* commit's Run-Id trailer names it; a resume after its commit, before its end was recorded): the texts its own commit
|
|
132
|
+
* holds at these note paths, as that merge saved them, whatever main says of them since. Undefined when it is not. */
|
|
133
|
+
merged(ws: unknown, runId: string, paths: readonly string[]): Promise<{
|
|
134
|
+
readonly texts: Readonly<Record<string, string>>;
|
|
135
|
+
} | undefined>;
|
|
105
136
|
/** The clock (epoch ms), for a parked run's wake. */
|
|
106
137
|
now?(): number;
|
|
107
138
|
}
|
|
@@ -123,14 +154,33 @@ export type DroppedData = {
|
|
|
123
154
|
readonly usd?: number | null;
|
|
124
155
|
readonly tokens?: Tokens | null;
|
|
125
156
|
};
|
|
157
|
+
/** `verdict`: each item's final decision once the merge settled it (takenOnMain's and the commit's left-out notes dropped,
|
|
158
|
+
* with their words), which the run's learning end reads in place of the grade's (store-reads/learning.ts). */
|
|
126
159
|
export type MergedData = {
|
|
127
160
|
readonly source: string;
|
|
128
161
|
readonly main: string;
|
|
129
162
|
readonly commit: string;
|
|
130
163
|
readonly files: readonly string[];
|
|
131
164
|
readonly detail: string;
|
|
165
|
+
readonly verdict: Verdict;
|
|
132
166
|
};
|
|
133
|
-
/**
|
|
167
|
+
/** The why of a note whose name main already holds with other text, which it does not supersede: never written over,
|
|
168
|
+
* and the rest of what the run learned merges. */
|
|
169
|
+
export declare const NOTE_NAME_TAKEN: (name: string) => string;
|
|
170
|
+
/** The why of a skill re-filed as a note whose file this run's own kept note (or another re-filed skill) takes: the run's
|
|
171
|
+
* own stands, and the skill is not written over it. */
|
|
172
|
+
export declare const NOTE_NAME_IN_RUN: (name: string) => string;
|
|
173
|
+
export declare function takenOnMain(proposal: Pick<KeptProposal, "notes">, verdict: Verdict, onMain: Readonly<Record<string, string>>): {
|
|
174
|
+
verdict: Verdict;
|
|
175
|
+
replace: string[];
|
|
176
|
+
graded: Record<string, string>;
|
|
177
|
+
};
|
|
178
|
+
/** `verdict` with one item per file a kept note is written as, within the run: the files the run's own kept notes are,
|
|
179
|
+
* then each re-filed skill's as it is kept; a re-filed skill whose note file one of those takes is left out, saying so
|
|
180
|
+
* (NOTE_NAME_IN_RUN). The merge (takenOnMain) and its resume (resumedOf, from the saved grade) settle it the one way. */
|
|
181
|
+
export declare function oneItemAFile(proposal: Pick<KeptProposal, "notes">, verdict: Verdict): Verdict;
|
|
182
|
+
/** `proposal` with only what `verdict` keeps (a verdict per item): a note or file its item keeps or holds; a skill its
|
|
183
|
+
* item re-filed (`note`: a standing rule for every reply) is kept as that note instead, never as a skill. */
|
|
134
184
|
export declare function keptOf(proposal: KeptProposal, verdict: Verdict): KeptProposal;
|
|
135
185
|
/** The merge of `merging` (what the verdict kept), the one rule learningCommit's merge is made by: each note with
|
|
136
186
|
* the origin its item gives (`you` for the user's own words, else the run's) and held for its owner's OK when its item
|
|
@@ -150,6 +200,30 @@ export declare function learnedOf(merging: KeptProposal, verdict: Verdict): {
|
|
|
150
200
|
skills: LearnedFile[];
|
|
151
201
|
workflows: LearnedFile[];
|
|
152
202
|
};
|
|
203
|
+
/** `merging` and `verdict` once the merge left out `left` (learn/commit.ts LeftNote): each note it left out is no longer
|
|
204
|
+
* merged, and its item is dropped, unsaid when its rule is held already (SAME_NOTE), else saying its name is taken. */
|
|
205
|
+
export declare function leftOf(merging: KeptProposal, verdict: Verdict, left: readonly {
|
|
206
|
+
readonly path: string;
|
|
207
|
+
readonly reason: "same" | "taken";
|
|
208
|
+
}[]): {
|
|
209
|
+
merging: KeptProposal;
|
|
210
|
+
verdict: Verdict;
|
|
211
|
+
};
|
|
212
|
+
/** What a merge already on main settled (learn/commit.ts: its files, and `left`, the new notes it did not write): each
|
|
213
|
+
* note the grade kept is kept when the merge wrote it, its path changed and main holding its rule there now (`onMain`,
|
|
214
|
+
* the texts main holds at the kept notes' paths), else left out, saying why as takenOnMain said it (`taken`, its
|
|
215
|
+
* verdict after main was read), or by main's text there (the same rule, or a name it holds with another), else as the
|
|
216
|
+
* commit does. Skills and drafts as the grade kept them. */
|
|
217
|
+
export declare function resumedOf(proposal: KeptProposal, graded: Verdict, taken: Verdict, result: {
|
|
218
|
+
readonly files: readonly string[];
|
|
219
|
+
readonly left?: readonly {
|
|
220
|
+
readonly path: string;
|
|
221
|
+
readonly reason: "same" | "taken";
|
|
222
|
+
}[];
|
|
223
|
+
}, onMain: Readonly<Record<string, string>>): {
|
|
224
|
+
merging: KeptProposal;
|
|
225
|
+
verdict: Verdict;
|
|
226
|
+
};
|
|
153
227
|
/** The skills and drafts a proposal names, by their item's file: what a merge the grader refused loses (notKept). */
|
|
154
228
|
export declare const lostOf: (proposal: KeptProposal) => LearnedFile[];
|
|
155
229
|
export declare function createLearningLoop(learning: LearningLoopDeps): (deps: LoopDeps) => Loop;
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
import { BACKGROUND_CONTEXT, withAbortSignal } from "@earendil-works/chord/context";
|
|
15
15
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
16
16
|
import { CONTRADICTED_REASON, CONTRADICTED_TWICE_REASON, CONTRADICTION_ASK, gradedItems, gradePrompt, parseVerdict, UNREADABLE_REASON } from "../learn/grade.js";
|
|
17
|
-
import { mergedNote, parseNoteFile } from "../learn/notes.js";
|
|
17
|
+
import { mergedNote, parseNoteFile, ruleOf } from "../learn/notes.js";
|
|
18
18
|
import { learnedPlace } from "../learn/skills.js";
|
|
19
|
-
import {
|
|
19
|
+
import { blobOid } from "../learn/folder.js";
|
|
20
|
+
import { notKept, SAME_NOTE, said, STOPPED } from "../learning-words.js";
|
|
20
21
|
import { journalEntries } from "./journal-reader.js";
|
|
21
22
|
import { KINDS } from "./journal-kinds.js";
|
|
22
23
|
/** The grader's bounds, as the server's grade had them (grade.ts): one ask, its answer cut at GRADE_MAX_TOKENS. */
|
|
@@ -32,28 +33,117 @@ const itemOf = (file) => {
|
|
|
32
33
|
const place = learnedPlace(file);
|
|
33
34
|
return place?.kind === "readme" ? `workflows/${place.name}/workflow.json` : file;
|
|
34
35
|
};
|
|
35
|
-
/**
|
|
36
|
+
/** The why of a note whose name main already holds with other text, which it does not supersede: never written over,
|
|
37
|
+
* and the rest of what the run learned merges. */
|
|
38
|
+
export const NOTE_NAME_TAKEN = (name) => `A note named ${name} was added since this run started, or was there already; this one wasn't kept.`;
|
|
39
|
+
/** The why of a skill re-filed as a note whose file this run's own kept note (or another re-filed skill) takes: the run's
|
|
40
|
+
* own stands, and the skill is not written over it. */
|
|
41
|
+
export const NOTE_NAME_IN_RUN = (name) => `This run also kept a note named ${name}, so the rule was not re-filed over it.`;
|
|
42
|
+
/** What `verdict` merges once each note it keeps (a new note's, or a skill's re-filed as one: its item's `note`) is set
|
|
43
|
+
* beside the run's other kept notes and what main holds at that file (`onMain`, by path), one item at a time, never a
|
|
44
|
+
* refusal of the whole merge. One file is one item's: a skill re-filed as a note whose file the run's own kept note
|
|
45
|
+
* (or an earlier re-filed skill) takes is dropped, saying so (NOTE_NAME_IN_RUN), so one text is written and the item
|
|
46
|
+
* that holds it is the one whose hold it keeps. Against main: a note main holds the same is no change, dropped unsaid
|
|
47
|
+
* (SAME_NOTE); one whose own front matter supersedes the note of its name is a modification, written over it
|
|
48
|
+
* (`replace`, main's blob in `graded`, so a change since is a conflict); any other is dropped, saying so
|
|
49
|
+
* (NOTE_NAME_TAKEN), and main's note stands. No suffixed name: it would hold the same rule twice. A rule another note
|
|
50
|
+
* holds is the merge's own to settle, against the main it commits on (learn/commit.ts mergeOf). Merge when the grader
|
|
51
|
+
* said so and it still keeps an item. */
|
|
52
|
+
/** Whether `held`, the note main holds at `file`, says the same rule as `text`: their bodies, whitespace and case aside
|
|
53
|
+
* (notes.ts ruleOf), as readMain and the merge's own settle (learn/commit.ts) read it, whatever their front matter. A
|
|
54
|
+
* text that is no note is the same only when it is the same text. */
|
|
55
|
+
/** The rule a re-filed note says (notes.ts ruleOf), "" when its text is no note: what the merge checks main still holds
|
|
56
|
+
* before it retires the skill that note replaces. */
|
|
57
|
+
const ruleOfText = (file, text) => {
|
|
58
|
+
const note = parseNoteFile(file, text);
|
|
59
|
+
return Array.isArray(note) ? "" : ruleOf(note.body);
|
|
60
|
+
};
|
|
61
|
+
const sameRule = (file, held, text) => {
|
|
62
|
+
const [theirs, ours] = [parseNoteFile(file, held), parseNoteFile(file, text)];
|
|
63
|
+
return !Array.isArray(theirs) && !Array.isArray(ours) ? ruleOf(theirs.body) === ruleOf(ours.body) : held === text;
|
|
64
|
+
};
|
|
65
|
+
export function takenOnMain(proposal, verdict, onMain) {
|
|
66
|
+
const texts = new Map(proposal.notes.map(({ file, text }) => [file, text]));
|
|
67
|
+
const replace = [];
|
|
68
|
+
const graded = {};
|
|
69
|
+
const items = oneItemAFile(proposal, verdict).items.map((item) => {
|
|
70
|
+
const note = item.note ?? (texts.has(item.file) ? { file: item.file, text: texts.get(item.file) } : undefined);
|
|
71
|
+
const held = item.keep && note ? onMain[note.file] : undefined;
|
|
72
|
+
if (!note || held === undefined)
|
|
73
|
+
return item;
|
|
74
|
+
const identical = held === note.text || held === mergedNote(note.text, { origin: item.origin ?? "run", ...(item.pending ? { pending: true } : {}) });
|
|
75
|
+
const parsed = parseNoteFile(note.file, note.text);
|
|
76
|
+
// One that supersedes the note of its own name and is not the very text main holds: a modification, written over it.
|
|
77
|
+
if (!identical && !item.note && !Array.isArray(parsed) && parsed.supersedes.includes(note.file)) {
|
|
78
|
+
replace.push(note.file);
|
|
79
|
+
graded[note.file] = blobOid(held);
|
|
80
|
+
return item;
|
|
81
|
+
}
|
|
82
|
+
// Else the same rule an active note of main keeps (whatever its front matter, case or spacing) is no change, dropped
|
|
83
|
+
// unsaid, and a skill re-filed as it retired (mergeChangeOf); a retired or superseded note of that rule keeps it out
|
|
84
|
+
// of every run, so it is a name main holds, and nothing is retired: the rule never vanishes. Any other is a name main
|
|
85
|
+
// holds with another rule.
|
|
86
|
+
const theirs = parseNoteFile(note.file, held);
|
|
87
|
+
const same = !Array.isArray(theirs) && theirs.status === "active" && (identical || sameRule(note.file, held, note.text));
|
|
88
|
+
return { file: item.file, keep: false, question: "Duplicate", why: same ? SAME_NOTE : NOTE_NAME_TAKEN(note.file.replace(/\.md$/, "")), ...(item.note ? { note: item.note } : {}) };
|
|
89
|
+
});
|
|
90
|
+
return { verdict: { ...verdict, items, merge: verdict.merge && items.some((item) => item.keep) }, replace, graded };
|
|
91
|
+
}
|
|
92
|
+
/** `verdict` with one item per file a kept note is written as, within the run: the files the run's own kept notes are,
|
|
93
|
+
* then each re-filed skill's as it is kept; a re-filed skill whose note file one of those takes is left out, saying so
|
|
94
|
+
* (NOTE_NAME_IN_RUN). The merge (takenOnMain) and its resume (resumedOf, from the saved grade) settle it the one way. */
|
|
95
|
+
export function oneItemAFile(proposal, verdict) {
|
|
96
|
+
const own = new Set(proposal.notes.map(({ file }) => file));
|
|
97
|
+
const claimed = new Set(verdict.items.filter((item) => item.keep && !item.note && own.has(item.file)).map((item) => item.file));
|
|
98
|
+
const items = verdict.items.map((item) => {
|
|
99
|
+
if (!item.keep || !item.note)
|
|
100
|
+
return item;
|
|
101
|
+
if (claimed.has(item.note.file))
|
|
102
|
+
return { file: item.file, keep: false, question: "Duplicate", why: NOTE_NAME_IN_RUN(item.note.file.replace(/\.md$/, "")) };
|
|
103
|
+
claimed.add(item.note.file);
|
|
104
|
+
return item;
|
|
105
|
+
});
|
|
106
|
+
return { ...verdict, items, merge: verdict.merge && items.some((item) => item.keep) };
|
|
107
|
+
}
|
|
108
|
+
/** `proposal` with only what `verdict` keeps (a verdict per item): a note or file its item keeps or holds; a skill its
|
|
109
|
+
* item re-filed (`note`: a standing rule for every reply) is kept as that note instead, never as a skill. */
|
|
36
110
|
export function keptOf(proposal, verdict) {
|
|
37
111
|
if (!verdict.items.length)
|
|
38
112
|
return proposal;
|
|
39
|
-
const kept = new Set(verdict.items.filter((item) => item.keep).map((item) => item.file));
|
|
40
|
-
|
|
113
|
+
const kept = new Set(verdict.items.filter((item) => item.keep && !item.note).map((item) => item.file));
|
|
114
|
+
const refiled = verdict.items.flatMap((item) => (item.keep && item.note ? [item.note] : []));
|
|
115
|
+
return { ...proposal, notes: [...proposal.notes.filter(({ file }) => kept.has(file)), ...refiled], files: (proposal.files ?? []).filter(({ file }) => kept.has(itemOf(file))) };
|
|
41
116
|
}
|
|
117
|
+
/** Each item the verdict keeps by the file it is merged as: a re-filed skill's item by its note's file too. A dropped
|
|
118
|
+
* item names no file it merges as; of two kept items for one file (takenOnMain lets none through), the held one stands,
|
|
119
|
+
* so a hold is never lost to the order of the items. */
|
|
120
|
+
const itemsByFile = (verdict) => {
|
|
121
|
+
const byFile = new Map();
|
|
122
|
+
for (const item of verdict.items.filter((one) => one.keep)) {
|
|
123
|
+
for (const file of [item.file, ...(item.note ? [item.note.file] : [])])
|
|
124
|
+
if (!byFile.get(file)?.pending)
|
|
125
|
+
byFile.set(file, item);
|
|
126
|
+
}
|
|
127
|
+
return byFile;
|
|
128
|
+
};
|
|
42
129
|
/** The merge of `merging` (what the verdict kept), the one rule learningCommit's merge is made by: each note with
|
|
43
130
|
* the origin its item gives (`you` for the user's own words, else the run's) and held for its owner's OK when its item
|
|
44
131
|
* is pending; a skill's SKILL.md or a draft's README.md held when its item is (a draft's workflow.json is held by its
|
|
45
132
|
* README); and the seed the source run started from, so a skill's or draft's file changed on main since is a conflict. */
|
|
46
133
|
export function mergeChangeOf(runId, merging, verdict, graded) {
|
|
47
|
-
const judged =
|
|
134
|
+
const judged = itemsByFile(verdict);
|
|
48
135
|
const notes = merging.notes.map(({ file, text }) => ({ path: file, text: mergedNote(text, { origin: judged.get(file)?.origin ?? "run" }) }));
|
|
49
136
|
const files = (merging.files ?? []).map(({ file, text }) => ({ path: file, text }));
|
|
50
137
|
const held = [
|
|
51
138
|
...merging.notes.filter(({ file }) => judged.get(file)?.pending === true).map(({ file }) => file),
|
|
52
139
|
...files.filter(({ path }) => learnedPlace(path)?.kind !== "workflow" && judged.get(itemOf(path))?.pending === true).map(({ path }) => path),
|
|
53
140
|
];
|
|
141
|
+
// Each skill re-filed as a note is retired on main in the same write (learn/commit.ts mergeOf): a kept one, and one
|
|
142
|
+
// main already holds the same rule of as a note (dropped unsaid), so no old skill stays served beside its note.
|
|
143
|
+
const retire = verdict.items.flatMap((item) => (item.note && (item.keep || item.why === SAME_NOTE) && learnedPlace(item.file)?.kind === "skill" ? [{ skill: item.file, note: item.note.file, rule: ruleOfText(item.note.file, item.note.text) }] : []));
|
|
54
144
|
return {
|
|
55
145
|
kind: "merge", runId, reason: verdict.reason || "The grader kept every new note.", files: [...notes, ...files],
|
|
56
|
-
...(held.length ? { held } : {}), graded, ...(merging.seed ? { seed: merging.seed } : {}),
|
|
146
|
+
...(held.length ? { held } : {}), graded, ...(merging.seed ? { seed: merging.seed } : {}), ...(retire.length ? { retire } : {}),
|
|
57
147
|
};
|
|
58
148
|
}
|
|
59
149
|
/** What a merge of `merging` learned, as the server's grade named it on the run (learning-run.ts grade): the notes it
|
|
@@ -61,7 +151,7 @@ export function mergeChangeOf(runId, merging, verdict, graded) {
|
|
|
61
151
|
* drafts, each pending when it waits. The merge's words and the reader of a run's learning end (store-reads/learning.ts)
|
|
62
152
|
* both name it so. */
|
|
63
153
|
export function learnedOf(merging, verdict) {
|
|
64
|
-
const waiting = new Set(verdict.items.filter((item) => item.pending).
|
|
154
|
+
const waiting = new Set(verdict.items.filter((item) => item.pending).flatMap((item) => [item.file, ...(item.note ? [item.note.file] : [])]));
|
|
65
155
|
const notes = merging.notes.flatMap(({ file, text }) => {
|
|
66
156
|
const note = parseNoteFile(file, text);
|
|
67
157
|
return Array.isArray(note) ? [] : [{ file, name: note.name, supersedes: note.supersedes }];
|
|
@@ -78,9 +168,55 @@ export function learnedOf(merging, verdict) {
|
|
|
78
168
|
* the checks left out (the kept row's `left`). */
|
|
79
169
|
function mergedWords(merging, verdict, checked) {
|
|
80
170
|
const { learned, pending, skills, workflows } = learnedOf(merging, verdict);
|
|
81
|
-
|
|
171
|
+
// A re-filed rule main already holds the same is no change: never said.
|
|
172
|
+
const left = verdict.items.filter((item) => !item.keep && item.why !== SAME_NOTE).map((item) => ({ why: item.why }));
|
|
82
173
|
return said.merged(learned, pending, [...skills, ...workflows], left, checked);
|
|
83
174
|
}
|
|
175
|
+
/** `merging` and `verdict` once the merge left out `left` (learn/commit.ts LeftNote): each note it left out is no longer
|
|
176
|
+
* merged, and its item is dropped, unsaid when its rule is held already (SAME_NOTE), else saying its name is taken. */
|
|
177
|
+
export function leftOf(merging, verdict, left) {
|
|
178
|
+
if (!left.length)
|
|
179
|
+
return { merging, verdict };
|
|
180
|
+
const why = new Map(left.map(({ path, reason }) => [path, reason === "same" ? SAME_NOTE : NOTE_NAME_TAKEN(path.replace(/\.md$/, ""))]));
|
|
181
|
+
const items = verdict.items.map((item) => {
|
|
182
|
+
const file = item.note?.file ?? item.file;
|
|
183
|
+
return item.keep && why.has(file) ? { file: item.file, keep: false, question: "Duplicate", why: why.get(file), ...(item.note ? { note: item.note } : {}) } : item;
|
|
184
|
+
});
|
|
185
|
+
return { merging: { ...merging, notes: merging.notes.filter(({ file }) => !why.has(file)) }, verdict: { ...verdict, items } };
|
|
186
|
+
}
|
|
187
|
+
/** What a merge already on main settled (learn/commit.ts: its files, and `left`, the new notes it did not write): each
|
|
188
|
+
* note the grade kept is kept when the merge wrote it, its path changed and main holding its rule there now (`onMain`,
|
|
189
|
+
* the texts main holds at the kept notes' paths), else left out, saying why as takenOnMain said it (`taken`, its
|
|
190
|
+
* verdict after main was read), or by main's text there (the same rule, or a name it holds with another), else as the
|
|
191
|
+
* commit does. Skills and drafts as the grade kept them. */
|
|
192
|
+
export function resumedOf(proposal, graded, taken, result, onMain) {
|
|
193
|
+
const written = new Set(result.files);
|
|
194
|
+
const texts = new Map(proposal.notes.map(({ file, text }) => [file, text]));
|
|
195
|
+
const said = new Map((result.left ?? []).map(({ path, reason }) => [path, reason]));
|
|
196
|
+
const notes = new Set(proposal.notes.map(({ file }) => file));
|
|
197
|
+
// One item per file, as the first attempt's takenOnMain settled it: the saved grade keeps both a run's note and a skill
|
|
198
|
+
// re-filed as a note of its file, and only one of them was written.
|
|
199
|
+
const settled = oneItemAFile(proposal, graded);
|
|
200
|
+
const items = settled.items.map((item, i) => {
|
|
201
|
+
const file = item.note?.file ?? item.file;
|
|
202
|
+
if (!item.keep || !(item.note || notes.has(file)))
|
|
203
|
+
return item;
|
|
204
|
+
// Saved: the merge changed its path and main holds its rule there now (`onMain`, read after the merge). A path the
|
|
205
|
+
// merge changed for another reason (a note it marked superseded) holds another rule, and saves no item of its own.
|
|
206
|
+
const text = item.note?.text ?? texts.get(file);
|
|
207
|
+
const held = onMain[file];
|
|
208
|
+
if (written.has(file) && (held === undefined || text === undefined || sameRule(file, held, text)))
|
|
209
|
+
return item;
|
|
210
|
+
const before = taken.items[i];
|
|
211
|
+
if (before && !before.keep && before.why !== SAME_NOTE)
|
|
212
|
+
return before;
|
|
213
|
+
const same = held !== undefined && text !== undefined ? sameRule(file, held, text) : said.get(file) !== "taken";
|
|
214
|
+
const why = same ? SAME_NOTE : NOTE_NAME_TAKEN(file.replace(/\.md$/, ""));
|
|
215
|
+
return { file: item.file, keep: false, question: "Duplicate", why, ...(item.note ? { note: item.note } : {}) };
|
|
216
|
+
});
|
|
217
|
+
const verdict = { ...settled, items };
|
|
218
|
+
return { merging: keptOf(proposal, verdict), verdict };
|
|
219
|
+
}
|
|
84
220
|
/** The skills and drafts a proposal names, by their item's file: what a merge the grader refused loses (notKept). */
|
|
85
221
|
export const lostOf = (proposal) => (proposal.files ?? []).flatMap(({ file }) => {
|
|
86
222
|
const place = learnedPlace(file);
|
|
@@ -90,12 +226,17 @@ export function createLearningLoop(learning) {
|
|
|
90
226
|
return (deps) => {
|
|
91
227
|
let stopped = null;
|
|
92
228
|
const now = learning.now ?? Date.now;
|
|
229
|
+
/** Aborted by a person's stop (a stop row): the grade's request is cut at once, never left running past it, while the
|
|
230
|
+
* claim's signal stays whole so the stopped end is still written. */
|
|
231
|
+
const stopAsk = new AbortController();
|
|
93
232
|
return {
|
|
94
233
|
async command(_command) {
|
|
95
234
|
return { refused: "a learning run takes no messages or answers" };
|
|
96
235
|
},
|
|
97
236
|
async stop(reason) {
|
|
98
237
|
stopped = reason;
|
|
238
|
+
if (reason.kind === "command")
|
|
239
|
+
stopAsk.abort(new Error("the run was stopped"));
|
|
99
240
|
},
|
|
100
241
|
async start(claim) {
|
|
101
242
|
const context = withAbortSignal(deps.signal, BACKGROUND_CONTEXT);
|
|
@@ -167,10 +308,20 @@ export function createLearningLoop(learning) {
|
|
|
167
308
|
await append(KINDS.learningDropped, { source: source.runId, reason: "checker", detail: said.stale(main.problems), problems: main.problems }, "ended");
|
|
168
309
|
return { state: "ended" };
|
|
169
310
|
}
|
|
170
|
-
|
|
311
|
+
// A note named like one main holds now is settled alone, out of the grade (readMain's `taken`); the rest is
|
|
312
|
+
// graded. Nothing left to grade keeps nothing.
|
|
313
|
+
const taken = new Map((main.taken ?? []).map(({ path, reason }) => [path, reason]));
|
|
314
|
+
const grading = proposal.notes.filter(({ file }) => !taken.has(file));
|
|
315
|
+
const settledItems = [...taken].map(([file, reason]) => ({ file, keep: false, question: "Duplicate", why: reason === "same" ? SAME_NOTE : NOTE_NAME_TAKEN(file.replace(/\.md$/, "")) }));
|
|
316
|
+
if (!grading.length && !proposal.files?.length) {
|
|
317
|
+
const verdict = { merge: false, reason: "Every new note is named like one the agent holds now.", items: settledItems };
|
|
318
|
+
await append(KINDS.learningDropped, { source: source.runId, reason: "grader", detail: notKept(verdict, lostOf(proposal)) }, "ended");
|
|
319
|
+
return { state: "ended" };
|
|
320
|
+
}
|
|
321
|
+
const items = gradedItems(grading, (proposal.files ?? []));
|
|
171
322
|
const prompt = gradePrompt({
|
|
172
|
-
run: source.runId, ...(source.instructions ? { instructions: source.instructions } : {}), active: main.active, superseded: main.superseded, proposed:
|
|
173
|
-
...(proposal.files?.length ? { files: proposal.files } : {}), ...(proposal.dryRuns ? { dryRuns: proposal.dryRuns } : {}), ...(proposal.asked ? { asked: proposal.asked } : {}), ...(proposal.triggered ? { triggered: proposal.triggered } : {}),
|
|
323
|
+
run: source.runId, ...(source.instructions ? { instructions: source.instructions } : {}), active: main.active, superseded: main.superseded, proposed: grading,
|
|
324
|
+
...(proposal.files?.length ? { files: proposal.files } : {}), ...(proposal.dryRuns ? { dryRuns: proposal.dryRuns } : {}), ...(proposal.drafted?.length ? { drafted: proposal.drafted } : {}), ...(proposal.asked ? { asked: proposal.asked } : {}), ...(proposal.triggered ? { triggered: proposal.triggered } : {}), ...(proposal.held ? { held: proposal.held } : {}),
|
|
174
325
|
});
|
|
175
326
|
// What the grade spends, as the server's grade counted it (grade.ts counter): each ask's dollars and tokens
|
|
176
327
|
// added, either unknown (null) once any ask's is, and an ask that fails spent what nobody knows.
|
|
@@ -178,10 +329,13 @@ export function createLearningLoop(learning) {
|
|
|
178
329
|
let tokens = { input: 0, cache_read: 0, cache_write: 0, output: 0 };
|
|
179
330
|
// `again`: what the grade is told after its last answer, below the same prompt.
|
|
180
331
|
const ask = async (again) => {
|
|
332
|
+
// Stopped before this ask: nothing is sent, so nothing of it is spent (what it spent stays as it was).
|
|
333
|
+
if (stopAsk.signal.aborted)
|
|
334
|
+
throw stopAsk.signal.reason;
|
|
181
335
|
const timer = AbortSignal.timeout(GRADE_TIMEOUT_MS);
|
|
182
336
|
let answer;
|
|
183
337
|
try {
|
|
184
|
-
answer = await learning.ask({ prompt: again ? `${prompt}\n\n${again}` : prompt, maxTokens: GRADE_MAX_TOKENS }, AbortSignal.any([deps.signal, timer]), { journal: () => deps.journal(claim), flush: () => deps.flush() });
|
|
338
|
+
answer = await learning.ask({ prompt: again ? `${prompt}\n\n${again}` : prompt, maxTokens: GRADE_MAX_TOKENS }, AbortSignal.any([deps.signal, timer, stopAsk.signal]), { journal: () => deps.journal(claim), flush: () => deps.flush() });
|
|
185
339
|
}
|
|
186
340
|
catch (error) {
|
|
187
341
|
usd = null;
|
|
@@ -195,15 +349,15 @@ export function createLearningLoop(learning) {
|
|
|
195
349
|
};
|
|
196
350
|
let verdict;
|
|
197
351
|
try {
|
|
198
|
-
verdict = parseVerdict(await ask(), items);
|
|
352
|
+
verdict = parseVerdict(await ask(), items, proposal.held);
|
|
199
353
|
// An answer the host cannot read is asked once more, as the server's grade did.
|
|
200
354
|
if (verdict.reason === UNREADABLE_REASON && !verdict.items.length)
|
|
201
|
-
verdict = parseVerdict(await ask(), items);
|
|
355
|
+
verdict = parseVerdict(await ask(), items, proposal.held);
|
|
202
356
|
// One that kept every item and said no merge contradicts itself: asked once more, the contradiction named. A
|
|
203
357
|
// second contradiction stands as no merge, said in the host's words as twice (learning-words.ts notKept); a
|
|
204
358
|
// contradiction after an unreadable answer is one, and is said so.
|
|
205
359
|
else if (verdict.reason === CONTRADICTED_REASON) {
|
|
206
|
-
const again = parseVerdict(await ask(CONTRADICTION_ASK), items);
|
|
360
|
+
const again = parseVerdict(await ask(CONTRADICTION_ASK), items, proposal.held);
|
|
207
361
|
verdict = again.reason === CONTRADICTED_REASON ? { ...again, reason: CONTRADICTED_TWICE_REASON } : again;
|
|
208
362
|
}
|
|
209
363
|
}
|
|
@@ -217,6 +371,8 @@ export function createLearningLoop(learning) {
|
|
|
217
371
|
void error;
|
|
218
372
|
return { state: "ended" };
|
|
219
373
|
}
|
|
374
|
+
if (settledItems.length)
|
|
375
|
+
verdict = { ...verdict, items: [...verdict.items, ...settledItems] };
|
|
220
376
|
graded = { source: source.runId, verdict, usd, tokens, graded: main.graded };
|
|
221
377
|
spend = usd;
|
|
222
378
|
await append(KINDS.learningGraded, graded);
|
|
@@ -226,15 +382,52 @@ export function createLearningLoop(learning) {
|
|
|
226
382
|
const halt = await halted();
|
|
227
383
|
if (halt)
|
|
228
384
|
return halt;
|
|
229
|
-
|
|
230
|
-
|
|
385
|
+
// Each note it keeps whose file main already holds (another run merged one by that name since, or a skill
|
|
386
|
+
// re-filed as one) is settled alone (takenOnMain): never written over unless it supersedes it, and never a
|
|
387
|
+
// refusal of everything else the run learned. Not when this run's own merge is on main already (the runner
|
|
388
|
+
// stopped after its commit, before it recorded it): the notes there are that merge's, never "already there", so
|
|
389
|
+
// the grade's verdict goes to the commit, which answers with that merge, and each item is settled by the text that
|
|
390
|
+
// merge's own commit holds at its file (resumedOf: its rule there, not only a changed path, and never main's
|
|
391
|
+
// text now, which a person may have edited since).
|
|
392
|
+
const notePaths = graded.verdict.items.flatMap((item) => (!item.keep ? [] : item.note ? [item.note.file] : proposal.notes.some(({ file }) => file === item.file) ? [item.file] : []));
|
|
393
|
+
let onMain = {};
|
|
394
|
+
let already = false;
|
|
395
|
+
try {
|
|
396
|
+
const merge = await learning.merged(ws, source.runId, notePaths);
|
|
397
|
+
already = merge !== undefined;
|
|
398
|
+
onMain = merge ? merge.texts : notePaths.length ? await learning.mainTexts(ws, notePaths) : {};
|
|
399
|
+
}
|
|
400
|
+
catch (error) {
|
|
401
|
+
// Main could not be read: parked as for a write that could not reach the folder, tried again after a backoff.
|
|
402
|
+
await append(KINDS.learningUnavailable, { source: source.runId, error: error?.message ?? String(error) }, "parked");
|
|
403
|
+
return { state: "parked", wakeAt: now() + UNAVAILABLE_BACKOFF_MS[Math.min(unavailable, UNAVAILABLE_BACKOFF_MS.length - 1)] };
|
|
404
|
+
}
|
|
405
|
+
const taken = already ? { verdict: oneItemAFile(proposal, graded.verdict), replace: [], graded: {} } : takenOnMain(proposal, graded.verdict, onMain);
|
|
406
|
+
const verdict = taken.verdict;
|
|
407
|
+
const merging = keptOf(proposal, verdict);
|
|
408
|
+
const change = mergeChangeOf(source.runId, merging, verdict, { ...graded.graded, ...taken.graded });
|
|
409
|
+
// Nothing new left to merge: dropped, unless the grader kept a re-filed skill whose rule main already holds as a
|
|
410
|
+
// note (takenOnMain's SAME_NOTE). Its old SKILL.md is still retired (mergeChangeOf's retire), in a write of that
|
|
411
|
+
// alone, so no old skill stays served beside the note.
|
|
412
|
+
if (!verdict.merge && !(graded.verdict.merge && change.retire?.length)) {
|
|
413
|
+
await append(KINDS.learningDropped, { source: source.runId, reason: "grader", detail: notKept(verdict, lostOf(proposal)) }, "ended");
|
|
231
414
|
return { state: "ended" };
|
|
232
415
|
}
|
|
233
|
-
const
|
|
234
|
-
const result = await learning.commit(ws, mergeChangeOf(source.runId, merging, graded.verdict, graded.graded));
|
|
416
|
+
const result = await learning.commit(ws, taken.replace.length ? { ...change, replace: taken.replace } : change);
|
|
235
417
|
if (result.ok) {
|
|
236
|
-
|
|
237
|
-
|
|
418
|
+
// What the merge left out against the main it committed on (a rule a note holds, a name one holds), each
|
|
419
|
+
// item alone: said as takenOnMain says it, and nothing of it learned.
|
|
420
|
+
// A merge already on main (a resume after its commit): what it wrote is what its files say, so each note is
|
|
421
|
+
// settled by the files: one written is kept as the grade kept it, one not written is left out (as takenOnMain
|
|
422
|
+
// or the commit says why).
|
|
423
|
+
const settled = result.already ? resumedOf(proposal, graded.verdict, verdict, result, onMain) : leftOf(merging, verdict, result.left ?? []);
|
|
424
|
+
if (!settled.verdict.items.some((item) => item.keep) && !result.files.length) {
|
|
425
|
+
await append(KINDS.learningDropped, { source: source.runId, reason: "grader", detail: notKept(settled.verdict, lostOf(proposal)) }, "ended");
|
|
426
|
+
return { state: "ended" };
|
|
427
|
+
}
|
|
428
|
+
// A write that retired a skill alone learned nothing new: said so.
|
|
429
|
+
const detail = mergedWords(settled.merging, settled.verdict, checked) || said.empty;
|
|
430
|
+
await append(KINDS.learningMerged, { source: source.runId, main: result.main, commit: result.commit, files: result.files, detail, verdict: settled.verdict }, "ended");
|
|
238
431
|
return { state: "ended" };
|
|
239
432
|
}
|
|
240
433
|
if (result.reason === "conflict") {
|
|
@@ -15,6 +15,8 @@ export interface LearningSeedLay {
|
|
|
15
15
|
readonly shown: () => Promise<Shown>;
|
|
16
16
|
/** One line of the run's log. */
|
|
17
17
|
readonly log: (line: string) => void;
|
|
18
|
+
/** False for a run of a revision that says `learning: "notes"`: its notes and skills are laid, never a learned workflow. */
|
|
19
|
+
readonly workflows?: false;
|
|
18
20
|
}
|
|
19
21
|
/** What the claim laid of the run's seed: the seed it read, the learned skills' files it laid, by their paths under
|
|
20
22
|
* `.agents/skills/`, for the skill list the run's harness is handed beside the revision's own, and the learned workflows
|
|
@@ -25,6 +27,12 @@ export type LaidSeed = {
|
|
|
25
27
|
readonly skills: readonly string[];
|
|
26
28
|
readonly workflows: readonly LearnedWorkflow[];
|
|
27
29
|
};
|
|
30
|
+
/** What a claim laid of a run's learning seed, by name, as the adapter loop records it (KINDS.learningLaid): each learned
|
|
31
|
+
* skill whose files it laid, and each learned workflow it handed the tool; none when nothing was laid. */
|
|
32
|
+
export declare const laidOf: (laid: LaidSeed | undefined) => {
|
|
33
|
+
skills: string[];
|
|
34
|
+
workflows: string[];
|
|
35
|
+
};
|
|
28
36
|
/** Lays the run's learning seed (see the file's head). Undefined when the seed could not be read: nothing was laid.
|
|
29
37
|
* Never throws. */
|
|
30
38
|
export declare function layLearningSeed(lay: LearningSeedLay): Promise<LaidSeed | undefined>;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { chooseSkills, chooseWorkflows, layLearned, LEARNED_DIR, laySkills, readerOf, seedFrom, takeSkills } from "../learning.js";
|
|
2
2
|
const message = (error) => (error instanceof Error ? error.message : String(error));
|
|
3
|
+
/** What a claim laid of a run's learning seed, by name, as the adapter loop records it (KINDS.learningLaid): each learned
|
|
4
|
+
* skill whose files it laid, and each learned workflow it handed the tool; none when nothing was laid. */
|
|
5
|
+
export const laidOf = (laid) => ({
|
|
6
|
+
skills: [...new Set((laid?.skills ?? []).map((path) => path.split("/")[0]))],
|
|
7
|
+
workflows: (laid?.workflows ?? []).map(({ name }) => name),
|
|
8
|
+
});
|
|
3
9
|
/** Lays the run's learning seed (see the file's head). Undefined when the seed could not be read: nothing was laid.
|
|
4
10
|
* Never throws. */
|
|
5
11
|
export async function layLearningSeed(lay) {
|
|
@@ -25,7 +31,7 @@ export async function layLearningSeed(lay) {
|
|
|
25
31
|
lay.log(`its learning folder's ${path} was not read`);
|
|
26
32
|
for (const name of left)
|
|
27
33
|
lay.log(`starts without the skill ${name} its agent learned: it is over what is left of the learned skills' budget, or holds a secret`);
|
|
28
|
-
const workflows = chooseWorkflows(seed, shown);
|
|
34
|
+
const workflows = lay.workflows === false ? { flows: [], left: [] } : chooseWorkflows(seed, shown);
|
|
29
35
|
for (const name of workflows.left)
|
|
30
36
|
lay.log(`starts without the learned workflow ${name} its agent learned: it is over what is left of the learned workflows' budget, or holds a secret`);
|
|
31
37
|
return { seed, skills: taken.flatMap(({ name, files = {} }) => Object.keys(files).sort().map((path) => `${name}/${path}`)), workflows: workflows.flows };
|
|
@@ -87,6 +87,14 @@ export declare class ClaimRefused extends Error {
|
|
|
87
87
|
}
|
|
88
88
|
/** The end a person's stop or cancel writes: stopped, in words that say which. A cancel's are main's ("cancelled"). */
|
|
89
89
|
export declare function endedBy(cancel: boolean | undefined): string;
|
|
90
|
+
/** The run's end on a person's stop or a cancel, as every loop and the runner write it: state 'stopped', words that say
|
|
91
|
+
* which (endedBy), and the outcome the store tells them apart by: 'stopped' (the turn is over, never the run, as main's
|
|
92
|
+
* stop leaves a run: a message reopens it) or 'cancelled' (over for good). */
|
|
93
|
+
export declare function stopEnd(cancel: boolean | undefined): {
|
|
94
|
+
readonly state: "stopped";
|
|
95
|
+
readonly summary: string;
|
|
96
|
+
readonly outcome: "stopped" | "cancelled";
|
|
97
|
+
};
|
|
90
98
|
/** The refusal a denied call's model reads: serve's own words for a call a person denied (refusal-words.ts refusedText,
|
|
91
99
|
* one copy with the tool gate's), the person's note with it. Asked before its intent, the call never ran. */
|
|
92
100
|
export declare function deniedText(tool: string, note?: string): string;
|
|
@@ -128,6 +136,10 @@ export interface LoopDeps {
|
|
|
128
136
|
* or at once when there were none: a resumed ask with no answer row waits for it before it parks again, so an
|
|
129
137
|
* approve already on its way is never raced. Never rejects. */
|
|
130
138
|
delivered?: Promise<void>;
|
|
139
|
+
/** Hands the run's command rows the runner has not handed on yet to command() now, not at its next poll (up to its
|
|
140
|
+
* command poll away), and resolves once each call returned: a turn that ends asks it before the run may end, so a
|
|
141
|
+
* message sent while the turn worked is answered, never refused by the run's end. Absent: nothing to hand on. */
|
|
142
|
+
deliverNow?: () => Promise<void>;
|
|
131
143
|
/** Where the loop reports what its run shows before it is stored (a running tool, a partial answer), as it changes: a
|
|
132
144
|
* reader of the newest held state (`undefined` once there is nothing held), called once per tick by the runner's live
|
|
133
145
|
* ticker (runner/live-ticker.ts), never on every change, so a change costs the same however long the answer has grown.
|
|
@@ -14,6 +14,12 @@ export class ClaimRefused extends Error {
|
|
|
14
14
|
export function endedBy(cancel) {
|
|
15
15
|
return cancel ? "cancelled" : "stopped by a person";
|
|
16
16
|
}
|
|
17
|
+
/** The run's end on a person's stop or a cancel, as every loop and the runner write it: state 'stopped', words that say
|
|
18
|
+
* which (endedBy), and the outcome the store tells them apart by: 'stopped' (the turn is over, never the run, as main's
|
|
19
|
+
* stop leaves a run: a message reopens it) or 'cancelled' (over for good). */
|
|
20
|
+
export function stopEnd(cancel) {
|
|
21
|
+
return { state: "stopped", summary: endedBy(cancel), outcome: cancel ? "cancelled" : "stopped" };
|
|
22
|
+
}
|
|
17
23
|
/** The refusal a denied call's model reads: serve's own words for a call a person denied (refusal-words.ts refusedText,
|
|
18
24
|
* one copy with the tool gate's), the person's note with it. Asked before its intent, the call never ran. */
|
|
19
25
|
export function deniedText(tool, note) {
|
package/dist/runner/loop.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from "@earendil-works/chord";
|
|
2
|
-
import type
|
|
2
|
+
import { type ConversationId, type EntryRecord, type StorageWrite } from "@earendil-works/pi-durable";
|
|
3
3
|
import type { KernelHooks, ToolCall } from "./conformance/subject.js";
|
|
4
4
|
import { type Command, type HeldState, type Journal, type LoopDeps } from "./loop-contract.js";
|
|
5
5
|
import type { Staged } from "../store/store.js";
|
|
@@ -75,5 +75,9 @@ export declare function cutLast(entries: readonly EntryRecord[]): string | undef
|
|
|
75
75
|
export declare function restartLimited(entries: readonly EntryRecord[]): string | undefined;
|
|
76
76
|
/** The root conversation's entries, oldest first. */
|
|
77
77
|
export declare function entriesOf(journal: Journal, conversationId: ConversationId, context: Context): Promise<EntryRecord[]>;
|
|
78
|
+
/** The entries of the run's agent conversations, in log order: its root's and each one a task of the run owns (a
|
|
79
|
+
* subagent's: runner/subagent.ts), never the loop's own session records. What a run's end reads its metrics and cost
|
|
80
|
+
* from, so a child's requests count as the run's. */
|
|
81
|
+
export declare function agentEntriesOf(journal: Journal, context: Context): Promise<EntryRecord[]>;
|
|
78
82
|
export declare function findData<T>(entries: readonly EntryRecord[], kind: string, test: (data: T) => boolean): T | undefined;
|
|
79
83
|
export {};
|
package/dist/runner/loop.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
1
2
|
import { KINDS } from "./journal-kinds.js";
|
|
2
3
|
import { cutAtLimit } from "./loop-contract.js";
|
|
3
4
|
import { PI_STOP } from "./pi-stop.js";
|
|
@@ -177,6 +178,25 @@ export async function entriesOf(journal, conversationId, context) {
|
|
|
177
178
|
cursor = page.next;
|
|
178
179
|
}
|
|
179
180
|
}
|
|
181
|
+
/** The entries of the run's agent conversations, in log order: its root's and each one a task of the run owns (a
|
|
182
|
+
* subagent's: runner/subagent.ts), never the loop's own session records. What a run's end reads its metrics and cost
|
|
183
|
+
* from, so a child's requests count as the run's. */
|
|
184
|
+
export async function agentEntriesOf(journal, context) {
|
|
185
|
+
const ids = [];
|
|
186
|
+
for (let cursor = undefined;;) {
|
|
187
|
+
const page = await journal.scanConversations({ order: "ascending" }, 500, cursor, context);
|
|
188
|
+
for (const record of page.items)
|
|
189
|
+
if (Number(record.id) === Number(ROOT_CONVERSATION_ID) || record.owner !== undefined)
|
|
190
|
+
ids.push(record.id);
|
|
191
|
+
if (page.next === undefined)
|
|
192
|
+
break;
|
|
193
|
+
cursor = page.next;
|
|
194
|
+
}
|
|
195
|
+
const out = [];
|
|
196
|
+
for (const id of ids)
|
|
197
|
+
out.push(...(await entriesOf(journal, id, context)));
|
|
198
|
+
return out.sort((a, b) => Number(a.id) - Number(b.id));
|
|
199
|
+
}
|
|
180
200
|
export function findData(entries, kind, test) {
|
|
181
201
|
for (const entry of entries)
|
|
182
202
|
if (entry.kind === kind && test(entry.data))
|