@parcha/agentrun-serve 0.1.0-beta.33 → 0.1.0-beta.35
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 +368 -0
- package/README.md +341 -208
- package/dist/adapters.d.ts +3 -4
- package/dist/adapters.js +18 -15
- package/dist/agent-rows.d.ts +99 -0
- package/dist/agent-rows.js +1 -0
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +75 -25
- package/dist/agents.d.ts +9 -125
- package/dist/agents.js +15 -305
- package/dist/answer-json.d.ts +23 -0
- package/dist/answer-json.js +58 -0
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/archil-settings.d.ts +11 -1
- package/dist/archil-settings.js +10 -0
- package/dist/bash-read-only.d.ts +35 -0
- package/dist/bash-read-only.js +778 -0
- package/dist/box-settings.d.ts +3 -23
- package/dist/box-settings.js +7 -51
- package/dist/boxes.d.ts +17 -0
- package/dist/boxes.js +27 -20
- package/dist/browser-commands.d.ts +5 -2
- package/dist/browser-commands.js +4 -4
- package/dist/browser-computer.d.ts +5 -0
- package/dist/browser-computer.js +21 -0
- package/dist/browser-cost.d.ts +9 -6
- package/dist/browser-cost.js +95 -51
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -51
- package/dist/browser-person.js +94 -277
- package/dist/budget.d.ts +0 -5
- package/dist/budget.js +0 -5
- package/dist/cap.d.ts +14 -8
- package/dist/cap.js +19 -9
- package/dist/cli.js +71 -18
- package/dist/closed-pipes.d.ts +2 -0
- package/dist/closed-pipes.js +13 -0
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +2 -0
- package/dist/computer-keys.d.ts +20 -10
- package/dist/computer-keys.js +36 -54
- package/dist/computer-setting.d.ts +20 -3
- package/dist/computer-setting.js +58 -10
- package/dist/computers.d.ts +35 -2
- package/dist/computers.js +72 -11
- package/dist/confine.d.ts +120 -0
- package/dist/confine.js +436 -0
- package/dist/console/assets/index-B7NKTU8E.css +1 -0
- package/dist/console/assets/index-CXZMgJE7.js +550 -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/decision-rows.d.ts +1 -1
- package/dist/decision-rows.js +1 -1
- package/dist/docker-daemon.d.ts +31 -0
- package/dist/docker-daemon.js +56 -0
- package/dist/effort-guidance.js +4 -3
- package/dist/environment.d.ts +0 -3
- package/dist/environment.js +3 -5
- package/dist/errors.d.ts +1 -2
- package/dist/errors.js +9 -9
- package/dist/explain.js +3 -1
- package/dist/filed-answer.d.ts +32 -0
- package/dist/filed-answer.js +160 -0
- package/dist/files.d.ts +1 -3
- package/dist/files.js +2 -4
- package/dist/github-connection.d.ts +1 -1
- 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 +6 -2
- package/dist/github.js +5 -3
- package/dist/graph-served.d.ts +5 -3
- package/dist/graph-served.js +14 -6
- package/dist/graph-view.d.ts +3 -5
- package/dist/graph-view.js +9 -16
- package/dist/handed-values.d.ts +9 -0
- package/dist/handed-values.js +26 -0
- package/dist/harness-install.d.ts +1 -7
- package/dist/harness-install.js +1 -18
- package/dist/harness-opencode/adapter.d.ts +7 -0
- package/dist/harness-opencode/adapter.js +23 -6
- package/dist/harness-opencode/harness.js +0 -1
- package/dist/harness-opencode/host/policy.js +2 -2
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/verify.d.ts +17 -0
- package/dist/harness-opencode/verify.js +30 -10
- package/dist/harness-table.js +6 -1
- package/dist/heard.js +1 -1
- package/dist/held-fd.d.ts +5 -0
- package/dist/held-fd.js +14 -0
- package/dist/host-calls.d.ts +20 -0
- package/dist/host-calls.js +12 -0
- package/dist/host-tools.d.ts +4 -21
- package/dist/host-tools.js +4 -61
- package/dist/host.d.ts +2 -4
- package/dist/host.js +2 -7
- package/dist/import-summary.d.ts +1 -5
- package/dist/import-summary.js +0 -21
- package/dist/import.d.ts +6 -6
- package/dist/import.js +14 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/key-refusal.d.ts +5 -1
- package/dist/key-refusal.js +19 -4
- package/dist/learn/check.d.ts +8 -2
- package/dist/learn/check.js +85 -31
- package/dist/learn/folder.d.ts +11 -4
- package/dist/learn/folder.js +17 -19
- package/dist/learn/grade.d.ts +18 -1
- package/dist/learn/grade.js +108 -14
- package/dist/learn/index.d.ts +5 -5
- package/dist/learn/index.js +5 -5
- package/dist/learn/learning.sh +1 -14
- package/dist/learn/notes.d.ts +14 -3
- package/dist/learn/notes.js +16 -6
- package/dist/learn/reflect.d.ts +31 -2
- package/dist/learn/reflect.js +83 -6
- package/dist/learn/relevance.d.ts +24 -0
- package/dist/learn/relevance.js +91 -0
- package/dist/learn/secrets.d.ts +7 -1
- package/dist/learn/secrets.js +86 -19
- package/dist/learn/skills.d.ts +159 -18
- package/dist/learn/skills.js +644 -64
- package/dist/learned-nodes.d.ts +14 -0
- package/dist/learned-nodes.js +8 -0
- package/dist/learned-workflow.d.ts +41 -6
- package/dist/learned-workflow.js +153 -18
- package/dist/learning-routes.d.ts +49 -4
- package/dist/learning-routes.js +113 -31
- package/dist/learning-run.d.ts +16 -31
- package/dist/learning-run.js +31 -38
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +18 -9
- package/dist/learning.d.ts +91 -97
- package/dist/learning.js +176 -320
- package/dist/live/stream.js +1 -1
- package/dist/live/translate.js +12 -2
- package/dist/llm.d.ts +4 -1
- package/dist/llm.js +4 -2
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +17 -49
- package/dist/mcp-gateway.js +55 -136
- package/dist/mcp-oauth.d.ts +10 -14
- package/dist/mcp-oauth.js +14 -32
- package/dist/mcp-probe.d.ts +0 -7
- package/dist/mcp-probe.js +4 -10
- package/dist/mcp-servers-store.d.ts +18 -18
- package/dist/mcp-servers-store.js +12 -14
- package/dist/mcp-store.js +3 -4
- package/dist/mcp.js +4 -3
- package/dist/model.d.ts +9 -7
- package/dist/model.js +51 -27
- package/dist/monid.d.ts +0 -2
- package/dist/monid.js +3 -6
- package/dist/openapi.d.ts +8 -1
- package/dist/openapi.js +156 -58
- package/dist/page.d.ts +1 -3
- package/dist/page.js +6 -18
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +26 -61
- package/dist/pause.d.ts +2 -19
- package/dist/pause.js +5 -74
- package/dist/port-models.d.ts +10 -3
- package/dist/port-models.js +26 -6
- package/dist/propose.d.ts +2 -0
- package/dist/propose.js +80 -45
- package/dist/push-handler.d.ts +1 -1
- package/dist/reflect-range.d.ts +25 -0
- package/dist/reflect-range.js +30 -0
- package/dist/refusal-words.d.ts +5 -1
- package/dist/refusal-words.js +5 -1
- package/dist/rows.d.ts +1 -1
- package/dist/run-cut.d.ts +0 -6
- package/dist/run-cut.js +0 -6
- package/dist/run-db.d.ts +2 -11
- package/dist/run-db.js +2 -37
- package/dist/run-launch.d.ts +21 -2
- package/dist/run-launch.js +14 -5
- package/dist/run-learning-served.d.ts +21 -4
- package/dist/run-learning-served.js +23 -13
- package/dist/run-reads-over-store.d.ts +5 -3
- package/dist/run-reads-over-store.js +25 -14
- package/dist/run-secrets.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +27 -6
- package/dist/run-view.d.ts +37 -22
- package/dist/run-view.js +85 -38
- package/dist/runnable.d.ts +21 -10
- package/dist/runnable.js +35 -12
- package/dist/runner/adapter-loop.d.ts +36 -5
- package/dist/runner/adapter-loop.js +663 -69
- package/dist/runner/adapter-run-spec.d.ts +42 -8
- package/dist/runner/adapter-run-spec.js +186 -52
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +40 -2
- package/dist/runner/adapters/pi.js +110 -27
- package/dist/runner/beside.d.ts +38 -3
- package/dist/runner/beside.js +54 -5
- package/dist/runner/claim-secrets.d.ts +16 -1
- package/dist/runner/claim-secrets.js +62 -14
- package/dist/runner/cli-run-spec.d.ts +5 -0
- package/dist/runner/cli-run-spec.js +159 -41
- package/dist/runner/commands.js +1 -1
- package/dist/runner/computer-journal.d.ts +15 -2
- package/dist/runner/computer-journal.js +41 -5
- package/dist/runner/conformance/harness.d.ts +1 -0
- package/dist/runner/conformance/harness.js +123 -13
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/dispatch.d.ts +8 -1
- package/dist/runner/dispatch.js +81 -7
- package/dist/runner/end-of-run.d.ts +8 -2
- package/dist/runner/end-of-run.js +10 -4
- package/dist/runner/github-app.d.ts +7 -2
- package/dist/runner/github-app.js +47 -16
- package/dist/runner/harness-loops.d.ts +15 -2
- package/dist/runner/harness-loops.js +38 -2
- package/dist/runner/journal-kinds.d.ts +60 -6
- package/dist/runner/journal-kinds.js +43 -5
- package/dist/runner/journal-reader.d.ts +1 -1
- package/dist/runner/journal-reader.js +2 -2
- package/dist/runner/learning-ask.d.ts +4 -0
- package/dist/runner/learning-ask.js +15 -1
- package/dist/runner/learning-end.d.ts +18 -3
- package/dist/runner/learning-end.js +194 -20
- package/dist/runner/learning-loop.d.ts +7 -0
- package/dist/runner/learning-loop.js +36 -8
- package/dist/runner/learning-seed.d.ts +6 -0
- package/dist/runner/learning-seed.js +6 -0
- package/dist/runner/loop-contract.d.ts +4 -0
- package/dist/runner/main.d.ts +61 -9
- package/dist/runner/main.js +144 -20
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +7 -3
- package/dist/runner/mcp-github.d.ts +11 -2
- package/dist/runner/mcp-github.js +55 -4
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +16 -5
- package/dist/runner/memory-claim.d.ts +9 -0
- package/dist/runner/memory-claim.js +25 -0
- package/dist/runner/metrics.d.ts +46 -1
- package/dist/runner/metrics.js +156 -1
- package/dist/runner/model-route.d.ts +16 -0
- package/dist/runner/model-route.js +134 -10
- package/dist/runner/reflect-hook.d.ts +12 -1
- package/dist/runner/reflect-hook.js +33 -3
- package/dist/runner/runner.d.ts +20 -0
- package/dist/runner/runner.js +146 -18
- package/dist/runner/spec-holds.d.ts +7 -2
- package/dist/runner/spec-holds.js +4 -3
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +3 -3
- package/dist/runner/store-secrets.js +8 -12
- package/dist/runner/text-tools.d.ts +44 -0
- package/dist/runner/text-tools.js +237 -0
- package/dist/runner/workflow-host.d.ts +7 -2
- package/dist/runner/workflow-host.js +3 -1
- package/dist/runner/workflow-loop.d.ts +10 -1
- package/dist/runner/workflow-loop.js +14 -6
- package/dist/runner/workflow-spec.d.ts +21 -0
- package/dist/runner/workflow-spec.js +217 -93
- package/dist/runs-over-store.d.ts +14 -3
- package/dist/runs-over-store.js +100 -23
- package/dist/seal-key.d.ts +0 -2
- package/dist/seal-key.js +5 -45
- package/dist/sealed-settings-store.d.ts +19 -4
- package/dist/sealed-settings-store.js +9 -9
- package/dist/sealing.d.ts +4 -0
- package/dist/sealing.js +20 -0
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-name.d.ts +9 -0
- package/dist/secret-name.js +15 -0
- package/dist/secret-writes.d.ts +0 -1
- package/dist/secret-writes.js +0 -1
- package/dist/server-fs.d.ts +4 -0
- package/dist/server-fs.js +8 -2
- package/dist/server-lock.d.ts +0 -24
- package/dist/server-lock.js +5 -85
- package/dist/server-secrets-store.d.ts +4 -4
- package/dist/server-secrets-store.js +9 -31
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -36
- package/dist/server.d.ts +37 -56
- package/dist/server.js +322 -134
- package/dist/sign-ins-store.d.ts +34 -36
- package/dist/sign-ins-store.js +27 -38
- package/dist/sign-ins.d.ts +2 -119
- package/dist/sign-ins.js +5 -311
- package/dist/standard-webhooks.d.ts +1 -1
- package/dist/standard-webhooks.js +1 -1
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +1 -1
- package/dist/stop-signals.d.ts +4 -2
- package/dist/stop-signals.js +5 -3
- package/dist/store/agent-body.d.ts +12 -2
- package/dist/store/agent-body.js +22 -4
- package/dist/store/deadline.d.ts +18 -0
- package/dist/store/deadline.js +45 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +2 -2
- package/dist/store/open.d.ts +6 -3
- package/dist/store/open.js +2 -2
- package/dist/store/postgres/connection.d.ts +22 -2
- package/dist/store/postgres/connection.js +211 -41
- package/dist/store/postgres/migrate.d.ts +4 -0
- package/dist/store/postgres/migrate.js +9 -2
- package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
- package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
- package/dist/store/postgres/store.d.ts +9 -2
- package/dist/store/postgres/store.js +9 -0
- package/dist/store/schema.js +1 -1
- package/dist/store/seal.js +2 -2
- package/dist/store/sqlite/connection.js +14 -5
- package/dist/store/sqlite/run-patch.d.ts +3 -0
- package/dist/store/sqlite/run-patch.js +3 -0
- package/dist/store/sqlite/store.js +41 -12
- package/dist/store/store.d.ts +35 -6
- package/dist/store/store.js +12 -2
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +22 -4
- package/dist/store-reads/journal.d.ts +9 -6
- package/dist/store-reads/journal.js +129 -18
- package/dist/store-reads/learning.d.ts +82 -8
- package/dist/store-reads/learning.js +184 -11
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-reads/workflow.js +1 -1
- package/dist/store-view.d.ts +19 -1
- package/dist/store-view.js +95 -27
- package/dist/template-eval.d.ts +60 -4
- package/dist/template-eval.js +120 -54
- package/dist/templates.d.ts +33 -14
- package/dist/templates.js +82 -46
- package/dist/timeline/group.d.ts +33 -0
- package/dist/timeline/group.js +77 -0
- package/dist/timeline/index.d.ts +7 -0
- package/dist/timeline/index.js +7 -0
- package/dist/timeline/labels.d.ts +79 -0
- package/dist/timeline/labels.js +150 -0
- package/dist/timeline/origin.d.ts +56 -0
- package/dist/timeline/origin.js +92 -0
- package/dist/timeline/render-text.d.ts +11 -0
- package/dist/timeline/render-text.js +62 -0
- package/dist/timeline/timeline.d.ts +282 -0
- package/dist/timeline/timeline.js +1308 -0
- package/dist/timeline/util.d.ts +17 -0
- package/dist/timeline/util.js +49 -0
- package/dist/tool-budget.d.ts +18 -0
- package/dist/tool-budget.js +50 -0
- package/dist/tool-gate.d.ts +47 -218
- package/dist/tool-gate.js +87 -545
- package/dist/tool-keys-store.d.ts +11 -12
- package/dist/tool-keys-store.js +24 -31
- package/dist/tool-keys.d.ts +5 -101
- package/dist/tool-keys.js +8 -267
- package/dist/tool-plane.d.ts +23 -52
- package/dist/tool-plane.js +23 -81
- package/dist/tool-settings-store.d.ts +1 -2
- package/dist/tool-settings-store.js +5 -8
- package/dist/tools.d.ts +67 -25
- package/dist/tools.js +170 -119
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-targets.d.ts +13 -1
- package/dist/trigger-targets.js +31 -1
- package/dist/triggers.d.ts +2 -2
- package/dist/triggers.js +3 -3
- package/dist/turn-end.d.ts +1 -1
- package/dist/turn-end.js +1 -1
- package/dist/turns.d.ts +0 -6
- package/dist/turns.js +0 -19
- package/dist/uploads.d.ts +28 -5
- package/dist/uploads.js +83 -10
- package/dist/usage.d.ts +1 -49
- package/dist/usage.js +3 -84
- package/dist/validate.d.ts +4 -0
- package/dist/validate.js +33 -14
- package/dist/webhooks.d.ts +102 -76
- package/dist/webhooks.js +266 -233
- package/dist/workflow-run.d.ts +114 -0
- package/dist/workflow-run.js +144 -0
- package/dist/workspace/archil-claim.d.ts +2 -2
- package/dist/workspace/archil-claim.js +4 -3
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +4 -0
- package/dist/workspace/archil-exec.d.ts +12 -2
- package/dist/workspace/archil-exec.js +16 -0
- 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/beneath.d.ts +19 -0
- package/dist/workspace/beneath.js +106 -0
- package/dist/workspace/computer-deps.d.ts +26 -9
- package/dist/workspace/computer-deps.js +144 -43
- package/dist/workspace/computer-for-claim.d.ts +17 -14
- package/dist/workspace/computer-for-claim.js +99 -26
- package/dist/workspace/computer-hold.d.ts +6 -1
- package/dist/workspace/computer-hold.js +6 -1
- package/dist/workspace/computer-janitor.d.ts +47 -0
- package/dist/workspace/computer-janitor.js +182 -0
- package/dist/workspace/computer-ledger.d.ts +1 -8
- package/dist/workspace/computer-ledger.js +0 -3
- package/dist/workspace/computer-providers.d.ts +5 -3
- package/dist/workspace/computer-providers.js +11 -9
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/hands.d.ts +5 -2
- package/dist/workspace/hands.js +4 -3
- package/dist/workspace/index.d.ts +6 -5
- package/dist/workspace/index.js +4 -4
- package/dist/workspace/local.d.ts +14 -2
- package/dist/workspace/local.js +170 -43
- 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 +55 -10
- package/dist/workspace/resolve-computer.js +66 -14
- package/dist/workspace/run-tools.d.ts +15 -31
- package/dist/workspace/run-tools.js +19 -30
- package/dist/workspace/workspace.d.ts +5 -0
- package/dist/workspace-paths.d.ts +0 -17
- package/dist/workspace-paths.js +1 -41
- package/dist/workspace.d.ts +0 -17
- package/dist/workspace.js +4 -110
- package/package.json +14 -14
- package/skills/agentrun-serve/SKILL.md +1 -1
- package/templates/README.md +11 -5
- 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/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/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +11 -0
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/coding-tools.d.ts +0 -47
- package/dist/coding-tools.js +0 -189
- package/dist/computer-adb.d.ts +0 -12
- package/dist/computer-adb.js +0 -14
- package/dist/console/assets/index-Dn0ngwG9.js +0 -535
- package/dist/console/assets/index-DvW6Aled.css +0 -1
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/mcp-servers.d.ts +0 -269
- package/dist/mcp-servers.js +0 -456
- package/dist/packs.d.ts +0 -71
- package/dist/packs.js +0 -180
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -171
- package/dist/sessions.d.ts +0 -6
- package/dist/sessions.js +0 -109
- package/dist/workspace/computer-serves.d.ts +0 -12
- package/dist/workspace/computer-serves.js +0 -15
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// A tool's answer too long for the model to read whole: its start shown, the whole filed in the run's work folder,
|
|
2
|
+
// through its Workspace, where the run's read tool pages through it with offset and limit. No shell is needed, so a run
|
|
3
|
+
// with no computer (a template's agent on a hosted server, say) reads all of it.
|
|
4
|
+
//
|
|
5
|
+
// pi's read pages by line, at most 50 KB a call, and shows only the first 50 KB of a line longer than that (its note
|
|
6
|
+
// then asks for bash). So the file keeps the answer's lines, never one line of JSON around it: JSON is laid out a value
|
|
7
|
+
// a line (within a bound, past which it is filed as written), and a line longer than FILED_LINE_MAX characters is broken
|
|
8
|
+
// into pieces of that length, said in the note. The start shown is the file's first lines, whole, so the note's offset is
|
|
9
|
+
// where the file goes on.
|
|
10
|
+
import { workspaceErrorWords } from "./workspace/index.js";
|
|
11
|
+
/** The longest line a filed answer keeps: at three bytes of UTF-8 a character at most, well within the 50 KB pi's read
|
|
12
|
+
* shows of one line. */
|
|
13
|
+
export const FILED_LINE_MAX = 10_000;
|
|
14
|
+
/** The deepest indent a laid-out answer gets, in levels: a value nested deeper starts its own line at this indent. */
|
|
15
|
+
export const LAYOUT_DEPTH_MAX = 32;
|
|
16
|
+
/** The most a laid-out answer may grow to, in characters, for `text`: twice its length and 64 Ki more. Past it, the
|
|
17
|
+
* answer is filed as written (its lines broken at FILED_LINE_MAX), so no answer's layout costs more memory than that. */
|
|
18
|
+
export const layoutBound = (text) => 2 * text.length + 64 * 1024;
|
|
19
|
+
/** `text` as it is filed: JSON (an object or an array) laid out a value a line when that stays within layoutBound
|
|
20
|
+
* (`laid`), and each line past FILED_LINE_MAX characters broken into pieces of that length (never inside a surrogate
|
|
21
|
+
* pair); `broken`, how many lines were. */
|
|
22
|
+
export function fileable(text) {
|
|
23
|
+
let laid;
|
|
24
|
+
let json = false;
|
|
25
|
+
if (/^\s*[[{]/.test(text)) {
|
|
26
|
+
try {
|
|
27
|
+
JSON.parse(text);
|
|
28
|
+
json = true;
|
|
29
|
+
laid = laidOut(text);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Not JSON after all: filed as it is.
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const filed = laid ?? text;
|
|
36
|
+
let broken = 0;
|
|
37
|
+
const lines = filed.split("\n").flatMap((line) => {
|
|
38
|
+
if (line.length <= FILED_LINE_MAX)
|
|
39
|
+
return [line];
|
|
40
|
+
broken++;
|
|
41
|
+
const pieces = [];
|
|
42
|
+
for (let at = 0; at < line.length;) {
|
|
43
|
+
let end = Math.min(at + FILED_LINE_MAX, line.length);
|
|
44
|
+
// A high surrogate at the cut goes with its low one, to the next piece.
|
|
45
|
+
if (end < line.length && /[\uD800-\uDBFF]/.test(line[end - 1]))
|
|
46
|
+
end--;
|
|
47
|
+
pieces.push(line.slice(at, end));
|
|
48
|
+
at = end;
|
|
49
|
+
}
|
|
50
|
+
return pieces;
|
|
51
|
+
});
|
|
52
|
+
return { text: broken ? lines.join("\n") : filed, json, laid: laid !== undefined, broken };
|
|
53
|
+
}
|
|
54
|
+
/** Valid JSON `text` laid out a value a line, two spaces an indent, as JSON.stringify(value, null, 2) lays it out, but
|
|
55
|
+
* from the text's own tokens: a number is copied as written, never parsed, so an integer past 2^53 or a long decimal
|
|
56
|
+
* is filed exactly as the server sent it. The indent stops growing at LAYOUT_DEPTH_MAX levels, and undefined is the
|
|
57
|
+
* answer when the layout would pass layoutBound(text): deep or dense nesting is never padded without end. */
|
|
58
|
+
export function laidOut(text) {
|
|
59
|
+
const bound = layoutBound(text);
|
|
60
|
+
let out = "";
|
|
61
|
+
let depth = 0;
|
|
62
|
+
const pad = () => "\n" + " ".repeat(Math.min(depth, LAYOUT_DEPTH_MAX));
|
|
63
|
+
for (let i = 0; i < text.length; i++) {
|
|
64
|
+
if (out.length > bound)
|
|
65
|
+
return undefined;
|
|
66
|
+
const c = text[i];
|
|
67
|
+
if (c === '"') {
|
|
68
|
+
let j = i + 1;
|
|
69
|
+
while (j < text.length && text[j] !== '"')
|
|
70
|
+
j += text[j] === "\\" ? 2 : 1;
|
|
71
|
+
out += text.slice(i, j + 1);
|
|
72
|
+
i = j;
|
|
73
|
+
}
|
|
74
|
+
else if (c === "{" || c === "[") {
|
|
75
|
+
let j = i + 1;
|
|
76
|
+
while (j < text.length && /\s/.test(text[j]))
|
|
77
|
+
j++;
|
|
78
|
+
if (text[j] === (c === "{" ? "}" : "]")) {
|
|
79
|
+
out += c + text[j];
|
|
80
|
+
i = j;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
depth++;
|
|
84
|
+
out += c + pad();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else if (c === "}" || c === "]") {
|
|
88
|
+
depth--;
|
|
89
|
+
out += pad() + c;
|
|
90
|
+
}
|
|
91
|
+
else if (c === ",")
|
|
92
|
+
out += "," + pad();
|
|
93
|
+
else if (c === ":")
|
|
94
|
+
out += ": ";
|
|
95
|
+
else if (!/\s/.test(c))
|
|
96
|
+
out += c;
|
|
97
|
+
}
|
|
98
|
+
return out.length > bound ? undefined : out;
|
|
99
|
+
}
|
|
100
|
+
/** The model's text for `text`, longer than `clip` characters: the filed text's first lines, whole, within `clip`, then
|
|
101
|
+
* a note naming the file (`<folder>/<stem>.txt`, or `.json` for JSON) and the read offset that goes on. A file that
|
|
102
|
+
* cannot be written still answers its start, saying why in the Workspace's words (never an error's message, which
|
|
103
|
+
* names paths). `clip` is at least FILED_LINE_MAX, so the start holds at least one line. */
|
|
104
|
+
export async function filedAnswer(work, folder, stem, text, clip) {
|
|
105
|
+
const filed = fileable(text);
|
|
106
|
+
const lines = filed.text.split("\n");
|
|
107
|
+
// Lines as read counts them ("Showing lines 1-560 of <total>"): one more than the newlines.
|
|
108
|
+
const total = lines.length;
|
|
109
|
+
let shown = 0;
|
|
110
|
+
let chars = 0;
|
|
111
|
+
while (shown < total && chars + lines[shown].length + 1 <= clip)
|
|
112
|
+
chars += lines[shown++].length + 1;
|
|
113
|
+
if (shown === 0)
|
|
114
|
+
shown = 1;
|
|
115
|
+
const head = lines.slice(0, shown).join("\n");
|
|
116
|
+
const how = [
|
|
117
|
+
...(filed.laid ? ["its JSON laid out a value a line"] : []),
|
|
118
|
+
...(filed.broken ? [`${filed.broken} line${filed.broken > 1 ? "s" : ""} longer than ${FILED_LINE_MAX.toLocaleString("en-US")} characters broken into pieces of that length`] : []),
|
|
119
|
+
];
|
|
120
|
+
const cut = `\n[cut at line ${shown} of ${total} (${head.length} of ${filed.text.length} characters${how.length ? `; ${how.join("; ")}` : ""}); `;
|
|
121
|
+
const path = `${folder}/${stem}.${filed.json ? "json" : "txt"}`;
|
|
122
|
+
try {
|
|
123
|
+
await (typeof work === "function" ? work() : work).write(path, filed.text);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
return `${head}${cut}the whole answer could not be saved (${workspaceErrorWords(error) ?? error?.code ?? "write failed"})]`;
|
|
127
|
+
}
|
|
128
|
+
return `${head}${cut}the whole answer is in the run's files at ${path}: read it with offset=${shown + 1} to go on${diffIndex(lines, shown)}]`;
|
|
129
|
+
}
|
|
130
|
+
/** The most files a diff's index names, and the longest it runs. */
|
|
131
|
+
const INDEX_FILES = 300;
|
|
132
|
+
const INDEX_CHARS = 12_000;
|
|
133
|
+
/** For a unified diff (`diff --git a/... b/...` lines), where each file not wholly shown starts in the filed text and
|
|
134
|
+
* how many lines it runs, so a reader takes the files it needs by range (and passes a generated one by) rather than
|
|
135
|
+
* paging through all of it: "; files past the cut, from the line each starts at (its lines): a.ts 908 (120), ...". */
|
|
136
|
+
export function diffIndex(lines, shown) {
|
|
137
|
+
const starts = [];
|
|
138
|
+
lines.forEach((line, at) => {
|
|
139
|
+
const match = /^diff --git a\/(.*) b\/(.*)$/.exec(line);
|
|
140
|
+
if (match)
|
|
141
|
+
starts.push({ path: match[2], at: at + 1 });
|
|
142
|
+
});
|
|
143
|
+
if (starts.length === 0)
|
|
144
|
+
return "";
|
|
145
|
+
const rows = [];
|
|
146
|
+
let chars = 0;
|
|
147
|
+
for (let i = 0; i < starts.length; i++) {
|
|
148
|
+
const end = i + 1 < starts.length ? starts[i + 1].at - 1 : lines.length;
|
|
149
|
+
if (end <= shown)
|
|
150
|
+
continue;
|
|
151
|
+
const row = `${starts[i].path} ${starts[i].at} (${end - starts[i].at + 1})`;
|
|
152
|
+
if (rows.length >= INDEX_FILES || chars + row.length > INDEX_CHARS) {
|
|
153
|
+
rows.push("...");
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
rows.push(row);
|
|
157
|
+
chars += row.length + 2;
|
|
158
|
+
}
|
|
159
|
+
return rows.length ? `; files past the cut, from the line each starts at (its lines): ${rows.join(", ")}` : "";
|
|
160
|
+
}
|
package/dist/files.d.ts
CHANGED
|
@@ -14,12 +14,10 @@ export declare const RUN_DOOR_TOKEN = "door-token";
|
|
|
14
14
|
export declare const LAUNCH_LOST = "server_lost_at_launch";
|
|
15
15
|
/** Why a run fails that the store has running with no serve.json: its server went down before it set the run up. */
|
|
16
16
|
export declare const SETUP_LOST = "server_lost_at_setup";
|
|
17
|
-
/** The data directory a run's folder is in: `<data>/disk/agents/<agent>/runs/<run>` (pi-durable-agent runDirIn). */
|
|
18
|
-
export declare const dataOfRun: (runDir: string) => string;
|
|
19
17
|
export declare const HOMES_DIR = "homes";
|
|
20
18
|
/** Paths in an agent's home that only the host reads and writes (another component owns them): the home API reads and
|
|
21
19
|
* writes neither, and lists each by its name alone. `learning` (learning.ts, read through its own API) and `sign-ins`
|
|
22
|
-
* (sign-ins.ts: the agent's saved sign-ins, sealed pointers to its browser vendor's objects, shown without them on
|
|
20
|
+
* (sign-ins-store.ts: the agent's saved sign-ins, sealed pointers to its browser vendor's objects, shown without them on
|
|
23
21
|
* GET /agents/{id}). */
|
|
24
22
|
export declare const HOME_HOST_OWNED: string[];
|
|
25
23
|
/** An agent's home directory's name: its id in lower case, then 16 hex digits of the id's SHA-256. Ids that differ only
|
package/dist/files.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// The server-wide durable-file plumbing and the data-directory location moved to server-fs.ts; this module re-exports it
|
|
3
3
|
// so callers that still reach for it here keep working until they are pointed at server-fs.ts.
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
|
-
import { join
|
|
5
|
+
import { join } from "node:path";
|
|
6
6
|
export { DATA_ENV, SERVER_FILE, TOKEN_FILE, agentFolderOf, defaultData, readJson, removeOwnRecord, serialBy, syncDir, tempOf, writeDurable, writeDurableSync, writeWhole } from "./server-fs.js";
|
|
7
7
|
/** The server's own file in each run's directory: the run's title, input and how it was asked to run. */
|
|
8
8
|
export const RUN_META = "serve.json";
|
|
@@ -19,12 +19,10 @@ export const RUN_DOOR_TOKEN = "door-token";
|
|
|
19
19
|
export const LAUNCH_LOST = "server_lost_at_launch";
|
|
20
20
|
/** Why a run fails that the store has running with no serve.json: its server went down before it set the run up. */
|
|
21
21
|
export const SETUP_LOST = "server_lost_at_setup";
|
|
22
|
-
/** The data directory a run's folder is in: `<data>/disk/agents/<agent>/runs/<run>` (pi-durable-agent runDirIn). */
|
|
23
|
-
export const dataOfRun = (runDir) => resolve(runDir, "..", "..", "..", "..", "..");
|
|
24
22
|
export const HOMES_DIR = "homes";
|
|
25
23
|
/** Paths in an agent's home that only the host reads and writes (another component owns them): the home API reads and
|
|
26
24
|
* writes neither, and lists each by its name alone. `learning` (learning.ts, read through its own API) and `sign-ins`
|
|
27
|
-
* (sign-ins.ts: the agent's saved sign-ins, sealed pointers to its browser vendor's objects, shown without them on
|
|
25
|
+
* (sign-ins-store.ts: the agent's saved sign-ins, sealed pointers to its browser vendor's objects, shown without them on
|
|
28
26
|
* GET /agents/{id}). */
|
|
29
27
|
export const HOME_HOST_OWNED = ["learning", "sign-ins"];
|
|
30
28
|
/** An agent's home directory's name: its id in lower case, then 16 hex digits of the id's SHA-256. Ids that differ only
|
|
@@ -201,7 +201,7 @@ export declare class GitHubConnect {
|
|
|
201
201
|
private mint;
|
|
202
202
|
}
|
|
203
203
|
/** GitHub that did not answer a listing token's call: a 429, a 5xx, a rate limit's 403, or no answer at all. Nothing is
|
|
204
|
-
* learned from it, so nothing is refused for good: try again (mcp-servers.ts, 502 github_failed). */
|
|
204
|
+
* learned from it, so nothing is refused for good: try again (mcp-servers-store.ts, 502 github_failed). */
|
|
205
205
|
type Unanswered = {
|
|
206
206
|
failed: string;
|
|
207
207
|
};
|
|
@@ -210,7 +210,9 @@ export class GitHubConnect {
|
|
|
210
210
|
setup_on_update: true,
|
|
211
211
|
public: false,
|
|
212
212
|
default_permissions: { ...APP_PERMISSIONS },
|
|
213
|
-
|
|
213
|
+
// The events the templates' github triggers take: code-review's pull requests and comments, release-notes'
|
|
214
|
+
// published releases. A trigger takes only what the App is subscribed to.
|
|
215
|
+
default_events: ["pull_request", "issue_comment", "release"],
|
|
214
216
|
};
|
|
215
217
|
// GitHub reads the state from the form's URL; the form posts only the manifest.
|
|
216
218
|
return { action: `${page}?state=${encodeURIComponent(state)}`, manifest, state };
|
|
@@ -531,19 +533,35 @@ export class GitHubConnect {
|
|
|
531
533
|
return { unusable: "The GitHub App is not installed anywhere yet: install it on an account, then save the server." };
|
|
532
534
|
try {
|
|
533
535
|
const jwt = appJwt(credentials.appId, credentials.pem, this.options.now?.() ?? Date.now());
|
|
536
|
+
// Each installation in turn, until one gives a token: one that refuses, covers no repository or that GitHub did not
|
|
537
|
+
// answer for leaves the next to try.
|
|
534
538
|
const refusals = [];
|
|
539
|
+
// A refused narrowed mint: its installation covers a repository, so its refusal is the answer, never "none covers one".
|
|
540
|
+
let covered;
|
|
541
|
+
let unanswered;
|
|
535
542
|
for (const installation of installations) {
|
|
536
543
|
const refused = { unusable: `GitHub gave no token for the App's installation on ${installation.account}.` };
|
|
537
544
|
const found = await this.firstRepository(installation.id, jwt, refused, signal);
|
|
538
|
-
// GitHub that does not answer says nothing of the installations: tried again, never read as "no repository".
|
|
539
545
|
if ("failed" in found)
|
|
540
|
-
|
|
541
|
-
if ("unusable" in found)
|
|
546
|
+
unanswered = found;
|
|
547
|
+
else if ("unusable" in found)
|
|
542
548
|
refusals.push(found);
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
549
|
+
else if (found.repo !== undefined) {
|
|
550
|
+
// The least a listing needs: metadata read, of one repository; never the App's write permissions, never all of them.
|
|
551
|
+
const minted = await this.mint(installation.id, jwt, [found.repo], refused, signal, { metadata: "read" });
|
|
552
|
+
if ("token" in minted)
|
|
553
|
+
return minted;
|
|
554
|
+
if ("failed" in minted)
|
|
555
|
+
unanswered = minted;
|
|
556
|
+
else
|
|
557
|
+
covered ??= minted;
|
|
558
|
+
}
|
|
546
559
|
}
|
|
560
|
+
// GitHub that did not answer for one says nothing of it: tried again, never read as refused or as "no repository".
|
|
561
|
+
if (unanswered)
|
|
562
|
+
return unanswered;
|
|
563
|
+
if (covered)
|
|
564
|
+
return covered;
|
|
547
565
|
if (refusals.length === installations.length)
|
|
548
566
|
return refusals[0];
|
|
549
567
|
return installations.length === 1
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The file beside the data that tells a test the fake App's webhook secret, installation and repositories. */
|
|
2
|
+
export declare const FAUX_GITHUB_FILE = "faux-github.json";
|
|
3
|
+
/** The fake App's one installation and the repositories it covers. */
|
|
4
|
+
export declare const FAUX_GITHUB: {
|
|
5
|
+
appId: string;
|
|
6
|
+
slug: string;
|
|
7
|
+
installation: number;
|
|
8
|
+
account: string;
|
|
9
|
+
repositories: readonly string[];
|
|
10
|
+
};
|
|
11
|
+
export type FauxGitHub = {
|
|
12
|
+
/** Its API's base, which the server's Connect GitHub asks in place of GitHub's own; never a URL anyone gives. */
|
|
13
|
+
url: string;
|
|
14
|
+
/** The App as Connect GitHub keeps it (github-connection.ts GitHubConnection.save). */
|
|
15
|
+
app: {
|
|
16
|
+
id: string;
|
|
17
|
+
slug: string;
|
|
18
|
+
clientId: string;
|
|
19
|
+
pem: string;
|
|
20
|
+
webhookSecret: string;
|
|
21
|
+
settingsUrl: string;
|
|
22
|
+
};
|
|
23
|
+
close(): Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
/** Starts the fake GitHub API on loopback, with its App. */
|
|
26
|
+
export declare function startFauxGitHub(): Promise<FauxGitHub>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// A fake GitHub for a server started with --faux and --faux-github: an App already connected, served by GitHub's API as an
|
|
2
|
+
// in-process server on loopback, so the console's GitHub flows (Settings → GitHub connected, a github trigger made, a
|
|
3
|
+
// signed delivery fired) run in a real browser with nothing sent to GitHub. It answers the API calls the server makes of
|
|
4
|
+
// the App (github.ts, github-connection.ts): the App's installations, one installation's read, an installation token's
|
|
5
|
+
// mint narrowed to the repositories asked, that token's read of the repositories it covers and its revoke, and which
|
|
6
|
+
// installation covers a repository. The App, its private key and its webhook secret are made fresh at each start; a test
|
|
7
|
+
// signs a delivery with the webhook secret, kept beside the data (FAUX_GITHUB_FILE). Never on a server without --faux.
|
|
8
|
+
import { generateKeyPairSync, randomBytes } from "node:crypto";
|
|
9
|
+
import { createServer } from "node:http";
|
|
10
|
+
/** The file beside the data that tells a test the fake App's webhook secret, installation and repositories. */
|
|
11
|
+
export const FAUX_GITHUB_FILE = "faux-github.json";
|
|
12
|
+
/** The fake App's one installation and the repositories it covers. */
|
|
13
|
+
export const FAUX_GITHUB = { appId: "1", slug: "agentrun-faux", installation: 1, account: "faux-org", repositories: ["faux-org/demo"] };
|
|
14
|
+
const TOKEN_MS = 60 * 60_000;
|
|
15
|
+
/** Starts the fake GitHub API on loopback, with its App. */
|
|
16
|
+
export async function startFauxGitHub() {
|
|
17
|
+
const { privateKey } = generateKeyPairSync("rsa", { modulusLength: 2048, privateKeyEncoding: { type: "pkcs1", format: "pem" }, publicKeyEncoding: { type: "spki", format: "pem" } });
|
|
18
|
+
const app = { id: FAUX_GITHUB.appId, slug: FAUX_GITHUB.slug, clientId: `Iv1.faux${randomBytes(6).toString("hex")}`, pem: privateKey, webhookSecret: randomBytes(24).toString("hex"), settingsUrl: `https://github.com/organizations/${FAUX_GITHUB.account}/settings/apps/${FAUX_GITHUB.slug}` };
|
|
19
|
+
const installation = { id: FAUX_GITHUB.installation, account: { login: FAUX_GITHUB.account, type: "Organization" }, app_id: Number(FAUX_GITHUB.appId), suspended_at: null };
|
|
20
|
+
/** Each token minted, by its value: the repositories it was narrowed to (by name), or every one the installation covers. */
|
|
21
|
+
const tokens = new Map();
|
|
22
|
+
const covered = (names) => FAUX_GITHUB.repositories.filter((full) => !names || names.includes(full.split("/")[1]));
|
|
23
|
+
const answer = (res, status, doc) => {
|
|
24
|
+
res.writeHead(status, doc === undefined ? {} : { "content-type": "application/json" });
|
|
25
|
+
res.end(doc === undefined ? undefined : JSON.stringify(doc));
|
|
26
|
+
};
|
|
27
|
+
const handle = (req, res, body) => {
|
|
28
|
+
const path = (req.url ?? "/").split("?")[0];
|
|
29
|
+
if (req.method === "GET" && path === "/app/installations")
|
|
30
|
+
return answer(res, 200, [installation]);
|
|
31
|
+
if (req.method === "GET" && path === `/app/installations/${installation.id}`)
|
|
32
|
+
return answer(res, 200, installation);
|
|
33
|
+
if (req.method === "POST" && path === `/app/installations/${installation.id}/access_tokens`) {
|
|
34
|
+
let asked = {};
|
|
35
|
+
try {
|
|
36
|
+
asked = JSON.parse(body || "{}");
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return answer(res, 400, { message: "Problems parsing JSON" });
|
|
40
|
+
}
|
|
41
|
+
const names = Array.isArray(asked.repositories) ? asked.repositories.filter((name) => typeof name === "string") : undefined;
|
|
42
|
+
if (names && covered(names).length !== names.length)
|
|
43
|
+
return answer(res, 422, { message: "There is at least one repository that does not exist or is not accessible to the parent installation." });
|
|
44
|
+
const token = `faux-installation-token-${randomBytes(16).toString("hex")}`;
|
|
45
|
+
tokens.set(token, names);
|
|
46
|
+
return answer(res, 201, { token, expires_at: new Date(Date.now() + TOKEN_MS).toISOString(), permissions: { metadata: "read", contents: "read", pull_requests: "write", issues: "read" }, repository_selection: "selected" });
|
|
47
|
+
}
|
|
48
|
+
const bearer = String(req.headers.authorization ?? "").replace(/^Bearer /, "");
|
|
49
|
+
if (req.method === "GET" && path === "/installation/repositories") {
|
|
50
|
+
if (!tokens.has(bearer))
|
|
51
|
+
return answer(res, 401, { message: "Bad credentials" });
|
|
52
|
+
const full = covered(tokens.get(bearer));
|
|
53
|
+
return answer(res, 200, { total_count: full.length, repositories: full.map((name) => ({ name: name.split("/")[1], full_name: name })) });
|
|
54
|
+
}
|
|
55
|
+
if (req.method === "DELETE" && path === "/installation/token") {
|
|
56
|
+
if (!tokens.delete(bearer))
|
|
57
|
+
return answer(res, 401, { message: "Bad credentials" });
|
|
58
|
+
return answer(res, 204);
|
|
59
|
+
}
|
|
60
|
+
const repo = /^\/repos\/([^/]+)\/([^/]+)\/installation$/.exec(path);
|
|
61
|
+
if (req.method === "GET" && repo)
|
|
62
|
+
return FAUX_GITHUB.repositories.includes(`${repo[1]}/${repo[2]}`) ? answer(res, 200, installation) : answer(res, 404, { message: "Not Found" });
|
|
63
|
+
return answer(res, 404, { message: "Not Found" });
|
|
64
|
+
};
|
|
65
|
+
const server = createServer((req, res) => {
|
|
66
|
+
let body = "";
|
|
67
|
+
req.setEncoding("utf8").on("data", (chunk) => (body += chunk)).on("end", () => handle(req, res, body));
|
|
68
|
+
});
|
|
69
|
+
const host = "127.0.0.1";
|
|
70
|
+
await new Promise((resolve, reject) => server.once("error", reject).listen(0, host, () => resolve()));
|
|
71
|
+
return {
|
|
72
|
+
url: `http://${host}:${server.address().port}`,
|
|
73
|
+
app,
|
|
74
|
+
close: () => new Promise((resolve) => (server.close(() => resolve()), server.closeAllConnections())),
|
|
75
|
+
};
|
|
76
|
+
}
|
package/dist/github.d.ts
CHANGED
|
@@ -57,8 +57,12 @@ export declare const GITHUB_FIELDS: {
|
|
|
57
57
|
export declare const GITHUB_SCOPE = "server";
|
|
58
58
|
/** The repository a run is about, from its first message: the GitHub event it was started for (the server's own payload
|
|
59
59
|
* tag, the first one, with its installation and repository), else the first https://github.com/<owner>/<repo> its owner's
|
|
60
|
-
* words name, before any payload (a sender's text is never read for it). Undefined when it names none.
|
|
61
|
-
|
|
60
|
+
* words name, before any payload (a sender's text is never read for it). Undefined when it names none. The tag is read only
|
|
61
|
+
* for a run a github trigger started (`payload`, from its launch's inputOrigin): anyone may write the tag's text into a
|
|
62
|
+
* run of their own, and it names an installation. */
|
|
63
|
+
export declare function githubTargetOf(content: unknown, { payload }?: {
|
|
64
|
+
payload?: boolean;
|
|
65
|
+
}): {
|
|
62
66
|
installation?: number;
|
|
63
67
|
repo: string;
|
|
64
68
|
} | undefined;
|
package/dist/github.js
CHANGED
|
@@ -101,12 +101,14 @@ const unescapeAttr = (value) => value.replace(/"/g, '"').replace(/</g, "
|
|
|
101
101
|
const REPO_URL = /https:\/\/github\.com\/([A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38})\/([A-Za-z0-9._-]{1,100})/;
|
|
102
102
|
/** The repository a run is about, from its first message: the GitHub event it was started for (the server's own payload
|
|
103
103
|
* tag, the first one, with its installation and repository), else the first https://github.com/<owner>/<repo> its owner's
|
|
104
|
-
* words name, before any payload (a sender's text is never read for it). Undefined when it names none.
|
|
105
|
-
|
|
104
|
+
* words name, before any payload (a sender's text is never read for it). Undefined when it names none. The tag is read only
|
|
105
|
+
* for a run a github trigger started (`payload`, from its launch's inputOrigin): anyone may write the tag's text into a
|
|
106
|
+
* run of their own, and it names an installation. */
|
|
107
|
+
export function githubTargetOf(content, { payload = false } = {}) {
|
|
106
108
|
if (typeof content !== "string")
|
|
107
109
|
return undefined;
|
|
108
110
|
const at = content.indexOf("<trigger-payload ");
|
|
109
|
-
if (at >= 0) {
|
|
111
|
+
if (at >= 0 && payload) {
|
|
110
112
|
const tag = content.slice(at, content.indexOf(">", at) + 1);
|
|
111
113
|
const attrs = Object.fromEntries([...tag.matchAll(/ ([a-z][a-z0-9_-]*)="([^"]*)"/g)].map((m) => [m[1], unescapeAttr(m[2])]));
|
|
112
114
|
if (attrs.source === "github" && typeof attrs.repo === "string" && /^[^/\s]+\/[^/\s]+$/.test(attrs.repo))
|
package/dist/graph-served.d.ts
CHANGED
|
@@ -19,9 +19,11 @@ export declare const graphWalks: {
|
|
|
19
19
|
* - its nodes, each decision and each call through servedPart (a map item's label and an error cut short after);
|
|
20
20
|
* - every other top-level field (its run, its workflow, its structure `graph`, which echoes the workflow's nodes and their
|
|
21
21
|
* words, its totals, and any field added later) through redactedOutput, each by itself, its keys included;
|
|
22
|
-
* - `read_at`, which moves with every read
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* - `read_at`, which moves with every read: the server's clock as toISOString writes it, served as it is, never kept;
|
|
23
|
+
* anything else under the name is cut each read.
|
|
24
|
+
* Each part and each field, its name and its value, scalar or not, is cut once per content and held set and kept in
|
|
25
|
+
* `cache` as cut (never as read), so a poll that reads the same graph with the same values cuts nothing again, and a key
|
|
26
|
+
* saved since makes a new set, cut on the next read. What holds no held value (ids, times,
|
|
25
27
|
* statuses) comes through as it was. */
|
|
26
28
|
export declare function servedGraphView<T extends {
|
|
27
29
|
nodes: unknown;
|
package/dist/graph-served.js
CHANGED
|
@@ -38,14 +38,18 @@ export function servedPart(kind, value, values) {
|
|
|
38
38
|
* nothing, with no clock. */
|
|
39
39
|
export const graphWalks = { part: 0, rest: 0 };
|
|
40
40
|
const isRecordOrArray = (value) => typeof value === "object" && value !== null;
|
|
41
|
+
/** A time as Date's toISOString writes it, and nothing else: digits, its fixed separators and Z. */
|
|
42
|
+
const ISO_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
41
43
|
/** A graph view as GET /runs/{id}/graph serves it with `values` held, every field of it cut by the one rule (redactedOutput
|
|
42
44
|
* over the same values), the parts by the file path's rule on top:
|
|
43
45
|
* - its nodes, each decision and each call through servedPart (a map item's label and an error cut short after);
|
|
44
46
|
* - every other top-level field (its run, its workflow, its structure `graph`, which echoes the workflow's nodes and their
|
|
45
47
|
* words, its totals, and any field added later) through redactedOutput, each by itself, its keys included;
|
|
46
|
-
* - `read_at`, which moves with every read
|
|
47
|
-
*
|
|
48
|
-
*
|
|
48
|
+
* - `read_at`, which moves with every read: the server's clock as toISOString writes it, served as it is, never kept;
|
|
49
|
+
* anything else under the name is cut each read.
|
|
50
|
+
* Each part and each field, its name and its value, scalar or not, is cut once per content and held set and kept in
|
|
51
|
+
* `cache` as cut (never as read), so a poll that reads the same graph with the same values cuts nothing again, and a key
|
|
52
|
+
* saved since makes a new set, cut on the next read. What holds no held value (ids, times,
|
|
49
53
|
* statuses) comes through as it was. */
|
|
50
54
|
export function servedGraphView(view, values, cache) {
|
|
51
55
|
const digest = (value) => createHash("sha256").update(JSON.stringify(value) ?? "").digest("hex");
|
|
@@ -62,11 +66,15 @@ export function servedGraphView(view, values, cache) {
|
|
|
62
66
|
const { nodes, decisions, effects, read_at: readAt, ...rest } = view;
|
|
63
67
|
const fields = {};
|
|
64
68
|
for (const [name, value] of Object.entries(rest)) {
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
// A field's name and its value, scalar or not, each cut once per content and held set: a poll walks none again.
|
|
70
|
+
// (graphWalks.rest counts the walks of a field that holds more than one value, as before.)
|
|
71
|
+
const cutName = kept(`name:${keys}:${digest(name)}`, () => redactedOutput(name, values));
|
|
72
|
+
fields[cutName] = kept(`field:${keys}:${digest(name)}:${digest(value)}`, () => (isRecordOrArray(value) && graphWalks.rest++, redactedOutput(value, values)));
|
|
67
73
|
}
|
|
68
74
|
return {
|
|
69
|
-
|
|
75
|
+
// The read's own time, the server's clock as toISOString writes it, holds nothing of the run: served as it is. Any other
|
|
76
|
+
// value under the name is cut, each read, as before.
|
|
77
|
+
...(readAt === undefined ? {} : { read_at: typeof readAt === "string" && ISO_TIME.test(readAt) ? readAt : redactedOutput(readAt, values) }),
|
|
70
78
|
...fields,
|
|
71
79
|
nodes: part("nodes", nodes),
|
|
72
80
|
decisions: decisions.map((value) => part("decision", value)),
|
package/dist/graph-view.d.ts
CHANGED
|
@@ -28,7 +28,6 @@ export type GraphInput = {
|
|
|
28
28
|
/** The run has ended: a node it never reached is `not_run`, not `pending`, and its store is read, lock-free. */
|
|
29
29
|
ended: boolean;
|
|
30
30
|
workflow: unknown;
|
|
31
|
-
storeFile: string;
|
|
32
31
|
/** The run's directory: its node log is there. */
|
|
33
32
|
root: string;
|
|
34
33
|
/** The run's input: what a map's items are read from before its state has them. */
|
|
@@ -37,10 +36,9 @@ export type GraphInput = {
|
|
|
37
36
|
modelCost: number | null;
|
|
38
37
|
/** How many of its llm calls' answers its node log held when its rows were last read: their cost is in `modelCost`. */
|
|
39
38
|
llmRead?: number;
|
|
40
|
-
/** The one store and a context:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
context?: Context;
|
|
39
|
+
/** The one store and a context: an ended run's view, pin and decisions are read from its journal (store.readJournal). */
|
|
40
|
+
store: Store;
|
|
41
|
+
context: Context;
|
|
44
42
|
};
|
|
45
43
|
export declare function runGraph(given: GraphInput): Promise<{
|
|
46
44
|
read_at: string;
|
package/dist/graph-view.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { llmAnswers, readLiveView
|
|
1
|
+
import { llmAnswers, readLiveView } from "./pause.js";
|
|
2
|
+
import { KINDS } from "./runner/journal-kinds.js";
|
|
2
3
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3
4
|
const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4
5
|
const at = (state, path) => path.split(".").reduce((value, key) => (isObject(value) ? value[key] : undefined), state);
|
|
@@ -15,20 +16,16 @@ const labelOf = (item) => {
|
|
|
15
16
|
return typeof named === "string" || typeof named === "number" ? String(named) : undefined;
|
|
16
17
|
};
|
|
17
18
|
export async function runGraph(given) {
|
|
18
|
-
const
|
|
19
|
-
import("@parcha/agentrun-dsl/graph"),
|
|
20
|
-
import("@parcha/pi-durable-agent/workflow"),
|
|
21
|
-
import("@parcha/agentrun-pi/durable"),
|
|
22
|
-
]);
|
|
19
|
+
const { graphNodeOf, nodeStatus, workflowGraph } = await import("@parcha/agentrun-dsl/graph");
|
|
23
20
|
const { id } = given.run;
|
|
24
21
|
const graph = workflowGraph(given.workflow);
|
|
25
22
|
let view;
|
|
26
23
|
let pin;
|
|
27
24
|
let receipts;
|
|
28
25
|
let readAt = new Date().toISOString();
|
|
29
|
-
if (given.ended
|
|
30
|
-
// From the one store's journal (store.readJournal)
|
|
31
|
-
//
|
|
26
|
+
if (given.ended) {
|
|
27
|
+
// From the one store's journal (store.readJournal): the run's view and pin as readWorkflowRun reads them, and its
|
|
28
|
+
// decisions as receipts.
|
|
32
29
|
const { store, context } = given;
|
|
33
30
|
const [{ decisionsOverStore }, { readWorkflowRunOver }] = await Promise.all([import("./store-reads/decisions.js"), import("./store-reads/workflow.js")]);
|
|
34
31
|
// The one reader of a workflow run's view over A (node status, outcome, escalation): the workflow-loop builder's.
|
|
@@ -45,12 +42,6 @@ export async function runGraph(given) {
|
|
|
45
42
|
}
|
|
46
43
|
receipts = await decisionsOverStore(store, id, context);
|
|
47
44
|
}
|
|
48
|
-
else if (given.ended) {
|
|
49
|
-
// Lock-free, as every server read of a run's database (run-db.ts): nothing made beside it, never a lock to wait on.
|
|
50
|
-
view = await readWorkflowRun({ runId: id, storePath: given.storeFile, revision: { body: { workflow: given.workflow } } }, { unlocked: true });
|
|
51
|
-
pin = (readJournal(given.storeFile, id, { unlocked: true })?.state?.pin) ?? {};
|
|
52
|
-
receipts = durableDecisions(given.storeFile, { unlocked: true });
|
|
53
|
-
}
|
|
54
45
|
else {
|
|
55
46
|
const live = await readLiveView(given.root);
|
|
56
47
|
pin = live?.pin ?? {};
|
|
@@ -59,7 +50,9 @@ export async function runGraph(given) {
|
|
|
59
50
|
readAt = live.at;
|
|
60
51
|
view = { status: nodeStatus(graph, { pin: pin, result: null }) };
|
|
61
52
|
}
|
|
62
|
-
|
|
53
|
+
// The call nodes' effects, as the runner logged each one's start and end on the run's journal (KINDS.nodeEffect).
|
|
54
|
+
const { runEntries } = await import("./store-reads/journal.js");
|
|
55
|
+
const lines = (await runEntries(given.store, id, given.context)).filter((entry) => entry.kind === KINDS.nodeEffect).map((entry) => entry.data);
|
|
63
56
|
const nodeAt = (path) => (typeof path === "string" ? (graphNodeOf(graph, path)?.path ?? (graph.nodes.some((n) => n.path === path) ? path : undefined)) : undefined);
|
|
64
57
|
const kinds = new Map(graph.nodes.map((node) => [node.path, node.kind]));
|
|
65
58
|
// Each node's state, `not-run` read as pending until the run ends.
|
package/dist/handed-values.d.ts
CHANGED
|
@@ -21,3 +21,12 @@ export declare function handedValuesOf(deps: {
|
|
|
21
21
|
}): Promise<{
|
|
22
22
|
refs: string[];
|
|
23
23
|
} | "unreadable">;
|
|
24
|
+
/** Why what an agent learned is withheld (403): a pointer of its sign-in can't be read here, so the cut would be shorter
|
|
25
|
+
* than what a note may hold. */
|
|
26
|
+
export declare const WITHHELD_LEARNING = "This server can't read the agent's browser sign-in (its seal key changed or is missing, or the sign-in is damaged), so what it learned is not shown.";
|
|
27
|
+
/** Every sign-in pointer agent `agentId` ever held, live and forgotten (the store keeps every forgotten one, never only
|
|
28
|
+
* the newest), at each vendor that keeps one (each at least MIN_SECRET long, as every cut takes them): what the learning
|
|
29
|
+
* routes cut beside the server's secrets, so a note, a skill or a run's learning that wrote one never shows it. `unreadable` when one does not open under this server's key, or a read
|
|
30
|
+
* fails: what the agent learned may hold that pointer, so it is withheld (WITHHELD_LEARNING), never shown over a
|
|
31
|
+
* shorter list. */
|
|
32
|
+
export declare function agentPointers(signIns: SignInReader | undefined, agentId: string): Promise<string[] | "unreadable">;
|
package/dist/handed-values.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// sign-ins (live and forgotten) opened to find each pointer the mark names (run-view.ts handedPointers). One read for
|
|
4
4
|
// every place that must cut a run of what it was handed: the store-backed run view (store-view.ts) and the runner's
|
|
5
5
|
// learning end (runner/learning-end.ts), which refuses to learn it.
|
|
6
|
+
import { MIN_SECRET } from "./learn/secrets.js";
|
|
6
7
|
import { handedMark, handedPointers } from "./run-view.js";
|
|
7
8
|
import { readLaunchBody } from "./run-launch.js";
|
|
8
9
|
import { keptVendor } from "./tool-plane.js";
|
|
@@ -34,3 +35,28 @@ export async function handedValuesOf(deps, store, runId, known) {
|
|
|
34
35
|
const browser = launch?.plane ? keptVendor(launch.plane).browser : undefined;
|
|
35
36
|
return handedPointers(deps.signIns, runRow.agentId, browser, handedOf(runRow));
|
|
36
37
|
}
|
|
38
|
+
/** The browser vendors that keep a sign-in (sign-ins-store.ts vendorOf). */
|
|
39
|
+
const SIGN_IN_VENDORS = ["browserbase", "kernel"];
|
|
40
|
+
/** Why what an agent learned is withheld (403): a pointer of its sign-in can't be read here, so the cut would be shorter
|
|
41
|
+
* than what a note may hold. */
|
|
42
|
+
export const WITHHELD_LEARNING = "This server can't read the agent's browser sign-in (its seal key changed or is missing, or the sign-in is damaged), so what it learned is not shown.";
|
|
43
|
+
/** Every sign-in pointer agent `agentId` ever held, live and forgotten (the store keeps every forgotten one, never only
|
|
44
|
+
* the newest), at each vendor that keeps one (each at least MIN_SECRET long, as every cut takes them): what the learning
|
|
45
|
+
* routes cut beside the server's secrets, so a note, a skill or a run's learning that wrote one never shows it. `unreadable` when one does not open under this server's key, or a read
|
|
46
|
+
* fails: what the agent learned may hold that pointer, so it is withheld (WITHHELD_LEARNING), never shown over a
|
|
47
|
+
* shorter list. */
|
|
48
|
+
export async function agentPointers(signIns, agentId) {
|
|
49
|
+
if (!signIns)
|
|
50
|
+
return [];
|
|
51
|
+
const refs = [];
|
|
52
|
+
for (const vendor of SIGN_IN_VENDORS) {
|
|
53
|
+
const live = await signIns.peek(agentId, vendor).catch(() => "unreadable");
|
|
54
|
+
const gone = await signIns.forgotten(agentId, vendor).catch(() => "unreadable");
|
|
55
|
+
if (live === "unreadable" || gone === "unreadable" || gone.unreadable)
|
|
56
|
+
return "unreadable";
|
|
57
|
+
if (live)
|
|
58
|
+
refs.push(live.ref);
|
|
59
|
+
refs.push(...gone.refs);
|
|
60
|
+
}
|
|
61
|
+
return [...new Set(refs)].filter((ref) => ref.length >= MIN_SECRET);
|
|
62
|
+
}
|
|
@@ -83,11 +83,6 @@ export declare function npmInstall(entry: HarnessInstallEntry, dir: string, pins
|
|
|
83
83
|
signal?: AbortSignal;
|
|
84
84
|
onKilled?: () => void;
|
|
85
85
|
}): Promise<void>;
|
|
86
|
-
/** Removes Claude Code as an earlier build installed it, at the top of `harnesses` (read-only, as it left it), so the
|
|
87
|
-
* per-harness installs can go in beside nothing: only when the directory holds that layout and nothing else (any other
|
|
88
|
-
* entry, a per-harness install among them, and it is left as it is). Nothing of the old tree is read or kept. Resolves
|
|
89
|
-
* true when it removed one. */
|
|
90
|
-
export declare function removeFlatInstall(harnesses: string): Promise<boolean>;
|
|
91
86
|
/** How long npm has to exit after a SIGTERM before it gets SIGKILL. Once npm writes (its reify), a SIGTERM only marks
|
|
92
87
|
* it: npm finishes the step under way, which waits on every tarball, before it rolls back and exits, so a slow tarball
|
|
93
88
|
* would hold a server's close. npm writes only into the staging directory, which the install removes. */
|
|
@@ -97,8 +92,7 @@ export declare const NPM_KILLED_WAIT_MS = 5000;
|
|
|
97
92
|
/** The file an install of a harness into `dir` (`<data>/harnesses/<harness>`) keeps in the data directory while it runs,
|
|
98
93
|
* for every process on this data (a runner beside the server, one of its own, or one in another container on the same
|
|
99
94
|
* volume): the installing host and process, and since when. A failed install leaves why in it until the next install;
|
|
100
|
-
* one that lands removes it. In the data directory,
|
|
101
|
-
* its flat install in it, which the install removes first (removeFlatInstall) and which a file of ours would keep. */
|
|
95
|
+
* one that lands removes it. In the data directory, beside `<data>/harnesses`: that directory holds the installs alone. */
|
|
102
96
|
export declare const installMarkOf: (dir: string) => string;
|
|
103
97
|
/** Where a run's claim stands on a harness that installs on first use, in `dir`: "installed" once it is whole; while an
|
|
104
98
|
* install runs (its mark started within INSTALL_TIMEOUT_MS, by a live process when it names this host; another host's
|