@parcha/agentrun-serve 0.1.0-beta.38 → 0.1.0-beta.40
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 +455 -0
- package/README.md +376 -125
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +0 -2
- package/dist/agents-store.d.ts +5 -5
- package/dist/agents-store.js +14 -14
- package/dist/bash-read-only.js +2 -1
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -10
- package/dist/cap.js +2 -5
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +1 -5
- package/dist/chatgpt-plan.d.ts +163 -0
- package/dist/chatgpt-plan.js +549 -0
- package/dist/cli.js +26 -6
- package/dist/composio-preset.d.ts +8 -0
- package/dist/composio-preset.js +8 -7
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.js +2 -2
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +7 -2
- package/dist/computer-live.js +9 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +3 -3
- package/dist/computer-setting.js +5 -5
- package/dist/computer-view.d.ts +15 -0
- package/dist/computer-view.js +16 -2
- package/dist/computer-viewer.js +14 -1
- package/dist/computers.d.ts +5 -2
- package/dist/computers.js +9 -5
- package/dist/console/assets/index-B8Zn1Iqn.css +1 -0
- package/dist/console/assets/index-Jbxjcmdp.js +705 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.js +3 -3
- package/dist/decision-cap.d.ts +2 -5
- package/dist/decision-cap.js +3 -6
- package/dist/decision-rows.js +11 -11
- package/dist/email/account.d.ts +83 -0
- package/dist/email/account.js +159 -0
- package/dist/email/answer.d.ts +15 -0
- package/dist/email/answer.js +217 -0
- package/dist/email/email-faux.d.ts +95 -0
- package/dist/email/email-faux.js +849 -0
- package/dist/email/labels.d.ts +1 -0
- package/dist/email/labels.js +84 -0
- package/dist/email/mail.d.ts +186 -0
- package/dist/email/mail.js +373 -0
- package/dist/email/names.d.ts +50 -0
- package/dist/email/names.js +74 -0
- package/dist/email/routes.d.ts +10 -0
- package/dist/email/routes.js +50 -0
- package/dist/email/tools.d.ts +27 -0
- package/dist/email/tools.js +562 -0
- package/dist/environment.d.ts +17 -2
- package/dist/environment.js +36 -8
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +12 -0
- package/dist/eval-mailbox.d.ts +103 -0
- package/dist/eval-mailbox.js +236 -0
- package/dist/graph-view.d.ts +9 -2
- package/dist/graph-view.js +6 -2
- package/dist/harness-install.d.ts +28 -2
- package/dist/harness-install.js +147 -59
- package/dist/harness-opencode/adapter.js +2 -26
- package/dist/harness-opencode/facts.js +5 -2
- package/dist/harness-opencode/host/policy.d.ts +2 -0
- package/dist/harness-opencode/host/policy.js +10 -5
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/versions.d.ts +6 -0
- package/dist/harness-opencode/versions.js +6 -0
- package/dist/harness-table.js +8 -5
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/hosted-search.d.ts +3 -1
- package/dist/hosted-search.js +51 -11
- package/dist/import-sources.d.ts +1 -1
- package/dist/import-sources.js +3 -3
- package/dist/import.d.ts +21 -0
- package/dist/import.js +186 -1
- package/dist/key-check.d.ts +0 -2
- package/dist/key-check.js +3 -4
- package/dist/key-refusal.d.ts +8 -2
- package/dist/key-refusal.js +16 -13
- package/dist/learn/check.d.ts +18 -3
- package/dist/learn/check.js +328 -3
- package/dist/learn/compile.d.ts +12 -4
- package/dist/learn/compile.js +57 -20
- package/dist/learn/grade.d.ts +4 -0
- package/dist/learn/grade.js +4 -1
- package/dist/learn/promote.d.ts +130 -64
- package/dist/learn/promote.js +113 -202
- package/dist/learn/refit.d.ts +21 -12
- package/dist/learn/refit.js +51 -23
- package/dist/learn/replay-calls.js +1 -1
- package/dist/learn/skills.d.ts +2 -7
- package/dist/learn/skills.js +28 -14
- package/dist/learned-nodes.d.ts +15 -7
- package/dist/learned-nodes.js +29 -5
- package/dist/learned-workflow.d.ts +41 -31
- package/dist/learned-workflow.js +122 -63
- package/dist/learning-batch.js +3 -3
- package/dist/learning-cost.d.ts +35 -8
- package/dist/learning-cost.js +27 -9
- package/dist/learning-routes.d.ts +2 -4
- package/dist/learning-routes.js +20 -3
- package/dist/learning-words.d.ts +1 -1
- package/dist/learning-words.js +4 -1
- package/dist/learning.d.ts +5 -5
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/local-models.d.ts +39 -2
- package/dist/local-models.js +49 -5
- package/dist/mcp-pin-first.js +6 -0
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +25 -16
- package/dist/mcp-servers-store.js +23 -3
- package/dist/model-form.d.ts +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +26 -6
- package/dist/model.js +126 -18
- package/dist/monid.d.ts +26 -31
- package/dist/monid.js +84 -79
- package/dist/native/binding.d.ts +13 -0
- package/dist/native/binding.js +57 -0
- package/dist/native/cli.d.ts +2 -0
- package/dist/native/cli.js +48 -0
- package/dist/native/connection.d.ts +8 -0
- package/dist/native/connection.js +94 -0
- package/dist/native/context.d.ts +6 -0
- package/dist/native/context.js +22 -0
- package/dist/native/discovery.d.ts +27 -0
- package/dist/native/discovery.js +404 -0
- package/dist/native/environment.d.ts +4 -0
- package/dist/native/environment.js +18 -0
- package/dist/native/history.d.ts +20 -0
- package/dist/native/history.js +147 -0
- package/dist/native/instructions.d.ts +21 -0
- package/dist/native/instructions.js +173 -0
- package/dist/native/remote-worker-bridge.d.ts +3 -0
- package/dist/native/remote-worker-bridge.js +278 -0
- package/dist/native/remote.d.ts +187 -0
- package/dist/native/remote.js +492 -0
- package/dist/native/runtime.d.ts +17 -0
- package/dist/native/runtime.js +316 -0
- package/dist/native/runtimes.d.ts +66 -0
- package/dist/native/runtimes.js +41 -0
- package/dist/native/schema.d.ts +46 -0
- package/dist/native/schema.js +41 -0
- package/dist/native/types.d.ts +87 -0
- package/dist/native/types.js +1 -0
- package/dist/observation/http.d.ts +4 -0
- package/dist/observation/http.js +140 -0
- package/dist/observation/observer.d.ts +301 -0
- package/dist/observation/observer.js +919 -0
- package/dist/observation/schema.d.ts +52 -0
- package/dist/observation/schema.js +154 -0
- package/dist/openapi.d.ts +2 -1
- package/dist/openapi.js +404 -93
- package/dist/paid-calls.d.ts +8 -3
- package/dist/paid-calls.js +6 -2
- package/dist/place-offers.d.ts +4 -8
- package/dist/place-offers.js +4 -9
- package/dist/port-models.d.ts +10 -2
- package/dist/port-models.js +6 -2
- package/dist/print.d.ts +4 -2
- package/dist/print.js +4 -3
- package/dist/propose.d.ts +1 -2
- package/dist/propose.js +10 -1
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +8 -0
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/refusal-words.d.ts +14 -0
- package/dist/refusal-words.js +16 -2
- package/dist/run-launch.d.ts +12 -1
- package/dist/run-launch.js +13 -4
- package/dist/run-learning-served.d.ts +75 -2
- package/dist/run-manifest.d.ts +3 -0
- package/dist/run-manifest.js +13 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +8 -9
- package/dist/run-view.d.ts +44 -38
- package/dist/run-view.js +93 -56
- package/dist/runnable.d.ts +13 -5
- package/dist/runnable.js +69 -60
- package/dist/runner/adapter-loop.d.ts +48 -13
- package/dist/runner/adapter-loop.js +691 -254
- package/dist/runner/adapter-run-spec.d.ts +38 -12
- package/dist/runner/adapter-run-spec.js +175 -106
- package/dist/runner/adapters/pi.d.ts +24 -0
- package/dist/runner/adapters/pi.js +59 -9
- package/dist/runner/beside.d.ts +3 -1
- package/dist/runner/beside.js +24 -8
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +28 -4
- package/dist/runner/cli-run-spec.d.ts +30 -0
- package/dist/runner/cli-run-spec.js +95 -50
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +3 -2
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.js +6 -3
- package/dist/runner/end-of-run.d.ts +2 -0
- package/dist/runner/end-of-run.js +3 -1
- package/dist/runner/feedback-round.d.ts +40 -13
- package/dist/runner/feedback-round.js +64 -16
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +59 -13
- package/dist/runner/journal-kinds.js +48 -5
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +4 -0
- package/dist/runner/learning-end.js +64 -36
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +2 -0
- package/dist/runner/learning-loop.js +19 -4
- package/dist/runner/loop.d.ts +18 -0
- package/dist/runner/loop.js +34 -0
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-run.d.ts +4 -1
- package/dist/runner/mcp-run.js +11 -5
- package/dist/runner/meta-tools.d.ts +10 -3
- package/dist/runner/meta-tools.js +112 -36
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +114 -39
- package/dist/runner/model-route.d.ts +14 -3
- package/dist/runner/model-route.js +155 -19
- package/dist/runner/monid-run.d.ts +8 -6
- package/dist/runner/monid-run.js +117 -43
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +76 -10
- package/dist/runner/promotion.js +476 -154
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.js +9 -0
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +8 -4
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/workflow-first.d.ts +30 -20
- package/dist/runner/workflow-first.js +22 -32
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +18 -12
- package/dist/runner/workflow-spec.d.ts +4 -1
- package/dist/runner/workflow-spec.js +56 -45
- package/dist/runs-over-store.d.ts +30 -2
- package/dist/runs-over-store.js +46 -14
- package/dist/sdk/runs.d.ts +115 -0
- package/dist/sdk/runs.js +422 -0
- package/dist/sdk/schema.d.ts +175 -0
- package/dist/sdk/schema.js +138 -0
- package/dist/sdk/workflows.d.ts +22 -0
- package/dist/sdk/workflows.js +39 -0
- package/dist/secrets.d.ts +2 -0
- package/dist/secrets.js +19 -1
- package/dist/server.d.ts +48 -32
- package/dist/server.js +568 -137
- package/dist/skill-route.d.ts +3 -0
- package/dist/skill-route.js +16 -0
- package/dist/skills/agentrun-serve/SKILL.md +368 -0
- package/dist/stats.d.ts +10 -10
- package/dist/store/agent-body.d.ts +12 -8
- package/dist/store/agent-body.js +9 -4
- package/dist/store/dialect.d.ts +3 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/native-command-owner.d.ts +10 -0
- package/dist/store/native-command-owner.js +47 -0
- package/dist/store/postgres/connection.d.ts +11 -5
- package/dist/store/postgres/connection.js +44 -17
- package/dist/store/postgres/dialect.js +5 -0
- package/dist/store/postgres/migrations/0012_revision_monid_pin.sql +4 -0
- package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
- package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
- package/dist/store/postgres/store.d.ts +7 -3
- package/dist/store/postgres/store.js +4 -0
- package/dist/store/schema.d.ts +7 -0
- package/dist/store/schema.js +20 -1
- package/dist/store/sqlite/connection.js +72 -8
- package/dist/store/sqlite/run-launch.d.ts +11 -0
- package/dist/store/sqlite/run-launch.js +8 -0
- package/dist/store/sqlite/run-patch.d.ts +8 -1
- package/dist/store/sqlite/run-patch.js +14 -3
- package/dist/store/sqlite/store.js +170 -34
- package/dist/store/sqlite/worker.d.ts +2 -0
- package/dist/store/sqlite/worker.js +13 -10
- package/dist/store/store.d.ts +67 -7
- package/dist/store-reads/analytics.d.ts +7 -7
- package/dist/store-reads/analytics.js +23 -5
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/journal.d.ts +5 -0
- package/dist/store-reads/journal.js +85 -41
- package/dist/store-reads/learning.d.ts +115 -18
- package/dist/store-reads/learning.js +170 -68
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.js +75 -21
- package/dist/template-eval.d.ts +73 -11
- package/dist/template-eval.js +535 -75
- package/dist/templates.d.ts +84 -21
- package/dist/templates.js +254 -47
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/index.d.ts +3 -2
- package/dist/timeline/index.js +3 -2
- package/dist/timeline/labels.d.ts +5 -2
- package/dist/timeline/labels.js +29 -6
- package/dist/timeline/origin.d.ts +1 -1
- package/dist/timeline/origin.js +2 -2
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +66 -4
- package/dist/timeline/timeline.js +160 -30
- package/dist/timeline/util.d.ts +5 -0
- package/dist/timeline/util.js +44 -8
- package/dist/timeline/web-calls.d.ts +17 -0
- package/dist/timeline/web-calls.js +106 -0
- package/dist/tool-gate.d.ts +46 -44
- package/dist/tool-gate.js +101 -92
- package/dist/tool-list.d.ts +4 -1
- package/dist/tool-list.js +8 -1
- package/dist/tool-names.d.ts +18 -13
- package/dist/tool-names.js +19 -17
- package/dist/tool-plane.d.ts +17 -13
- package/dist/tool-plane.js +12 -5
- package/dist/tools.d.ts +57 -16
- package/dist/tools.js +33 -28
- package/dist/trigger-adapter.d.ts +56 -5
- package/dist/trigger-adapter.js +6 -0
- package/dist/trigger-adapters.js +3 -1
- package/dist/trigger-composio.d.ts +10 -0
- package/dist/trigger-composio.js +122 -0
- package/dist/trigger-email.d.ts +4 -0
- package/dist/trigger-email.js +181 -0
- package/dist/trigger-signatures.d.ts +6 -10
- package/dist/trigger-signatures.js +16 -16
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +4 -3
- package/dist/trigger-webhook.js +6 -4
- package/dist/triggers.d.ts +105 -8
- package/dist/triggers.js +286 -62
- package/dist/uploads.d.ts +9 -0
- package/dist/uploads.js +27 -0
- package/dist/validate.js +1 -7
- package/dist/web-fake.d.ts +56 -0
- package/dist/web-fake.js +102 -0
- package/dist/web-fetch-direct.d.ts +3 -0
- package/dist/web-fetch-direct.js +4 -1
- package/dist/web-fetch.d.ts +5 -1
- package/dist/web-fetch.js +8 -31
- package/dist/web-search.d.ts +51 -2
- package/dist/web-search.js +116 -18
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -1
- package/dist/workflow/decision-recovery.js +5 -2
- package/dist/workflow/decisions.d.ts +7 -0
- package/dist/workflow/node-runner.js +10 -2
- package/dist/workspace/archil-claim.d.ts +3 -0
- package/dist/workspace/archil-claim.js +9 -2
- package/dist/workspace/computer-deps.d.ts +22 -9
- package/dist/workspace/computer-deps.js +78 -37
- package/dist/workspace/computer-for-claim.d.ts +54 -4
- package/dist/workspace/computer-for-claim.js +179 -39
- package/dist/workspace/computer-janitor.d.ts +10 -3
- package/dist/workspace/computer-janitor.js +96 -29
- package/dist/workspace/computer-kept.d.ts +82 -0
- package/dist/workspace/computer-kept.js +147 -0
- package/dist/workspace/computer-mcp.js +4 -3
- package/dist/workspace/computer-ports.d.ts +23 -3
- package/dist/workspace/computer-ports.js +115 -5
- package/dist/workspace/index.d.ts +1 -2
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +25 -18
- package/dist/workspace/kind-skills/phone/SKILL.md +28 -17
- package/dist/workspace/resolve-computer.d.ts +15 -3
- package/dist/workspace/resolve-computer.js +10 -7
- package/dist/workspace/revision-skills.d.ts +6 -2
- package/dist/workspace/revision-skills.js +12 -5
- package/dist/workspace/run-end-computers.d.ts +30 -0
- package/dist/workspace/run-end-computers.js +137 -0
- package/dist/workspace/run-tools.d.ts +28 -29
- package/dist/workspace/run-tools.js +29 -30
- package/dist/wrap-up.d.ts +19 -5
- package/dist/wrap-up.js +31 -4
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +117 -23
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +18 -4
- package/templates/code-review/evals/mentions-defused/case.yaml +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
- package/templates/code-review/evals/other-repo/case.yaml +1 -1
- package/templates/code-review/evals/pasted-by-reference/case.yaml +5 -0
- package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
- package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
- package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -0
- package/templates/code-review/skills/review/DEEP.md +2 -2
- package/templates/code-review/skills/review/REVIEWER.md +2 -2
- package/templates/code-review/skills/review/SKILL.md +7 -3
- package/templates/release-notes/evals/draft-not-publish/case.yaml +1 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +1 -1
- package/templates/release-notes/evals/late-arrival/case.yaml +1 -1
- package/templates/release-notes/evals/other-repo/case.yaml +1 -1
- package/dist/console/assets/index-CjqQirbo.css +0 -1
- package/dist/console/assets/index-b6-XY5A9.js +0 -576
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -9
- package/dist/runner/adapters/pi-computer.js +0 -51
- package/dist/workspace/computer-script.d.ts +0 -53
- package/dist/workspace/computer-script.js +0 -172
package/dist/host-calls.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/** A host tool's answer, as HostTool.call gives it. */
|
|
2
|
-
export type HostAnswer = {
|
|
3
|
-
text: string;
|
|
4
|
-
isError?: boolean;
|
|
5
|
-
};
|
|
6
|
-
/** What the loop lends a call it runs: an MCP tool of the run by its catalog name (`mcp:<server>/<tool>`), as the loop
|
|
7
|
-
* wrapped it, or undefined when the run has no such tool; and, when a person approved the call it runs, the arguments
|
|
8
|
-
* its approval card showed them (the call's ask as journaled: what they saw, never what the gate would show now);
|
|
9
|
-
* undefined when no person approved it. */
|
|
10
|
-
export type HostCalls = {
|
|
11
|
-
readonly mcp: (tool: string) => ((args: unknown, ctx: {
|
|
12
|
-
callId: string;
|
|
13
|
-
signal: AbortSignal;
|
|
14
|
-
}) => Promise<HostAnswer>) | undefined;
|
|
15
|
-
readonly approved: Readonly<Record<string, unknown>> | undefined;
|
|
16
|
-
};
|
|
17
|
-
/** `work` with `lent` as the calls its tool may make. */
|
|
18
|
-
export declare const withHostCalls: <T>(lent: HostCalls, work: () => Promise<T>) => Promise<T>;
|
|
19
|
-
/** The calls the tool running now may make; undefined outside a loop's call (a server-side run, a test calling a tool). */
|
|
20
|
-
export declare const hostCalls: () => HostCalls | undefined;
|
package/dist/host-calls.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// A call the run's own tools make of another tool of the run, through the same path the harness's calls take: the
|
|
2
|
-
// adapter loop sets it around each host tool's call (runner/adapter-loop.ts hosted), so a learned workflow's call node
|
|
3
|
-
// that names an MCP tool (learned-workflow.ts runEffect) runs that tool as the loop wrapped it: its flush before the side
|
|
4
|
-
// effect, its paid requests booked on the run's one ledger under the call id given, its record on a CLI's timeline, and
|
|
5
|
-
// the stop's abort. The gate is the caller's to ask first, with the run's own permissions; the loop says only what card
|
|
6
|
-
// a person approved the call it runs inside with (`approved`), so an approval covers what that card named and no more.
|
|
7
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
|
-
const calls = new AsyncLocalStorage();
|
|
9
|
-
/** `work` with `lent` as the calls its tool may make. */
|
|
10
|
-
export const withHostCalls = (lent, work) => calls.run(lent, work);
|
|
11
|
-
/** The calls the tool running now may make; undefined outside a loop's call (a server-side run, a test calling a tool). */
|
|
12
|
-
export const hostCalls = () => calls.getStore();
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Extension } from "@earendil-works/pi-durable";
|
|
2
|
-
import { type ScriptComputer } from "../../workspace/index.js";
|
|
3
|
-
/** The code mode tool's name, as the model calls it and the gate reads it. */
|
|
4
|
-
export declare const PI_CODEMODE_TOOL = "codemode";
|
|
5
|
-
/** pi's code mode extension with `computer` bound to `computer`'s surface: install it among the run's pi-native
|
|
6
|
-
* extensions (PiAdapterOptions.extensions). No `models.*` in scripts: a script's paid work is the run's own tools.
|
|
7
|
-
* Where no computer_script is listed (a code-only computer: `computer.declare`), the codemode tool's description
|
|
8
|
-
* declares `computer` as computer_script's would; otherwise computer_script's declares it once. */
|
|
9
|
-
export declare function computerCodemode(computer: ScriptComputer): Extension;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { CodemodeSandbox } from "@earendil-works/pi-codemode";
|
|
2
|
-
import { CODEMODE_TOOL_NAME, createCodemodeExtension } from "@earendil-works/pi-durable/codemode";
|
|
3
|
-
import { COMPUTER_CALL_GLOBAL } from "@parcha/agentrun-computer/surface";
|
|
4
|
-
import { computerDeclarations } from "@parcha/agentrun-kernel/kernel";
|
|
5
|
-
import { SCRIPT_MAX_MS } from "../../workspace/index.js";
|
|
6
|
-
/** The code mode tool's name, as the model calls it and the gate reads it. */
|
|
7
|
-
export const PI_CODEMODE_TOOL = CODEMODE_TOOL_NAME;
|
|
8
|
-
const MEMORY_BYTES = 256 * 1024 * 1024;
|
|
9
|
-
/** A sandbox whose every script starts with `prelude`: one line, so the script's own line numbers hold. A rerun after a
|
|
10
|
-
* restart starts from the same code, so its replay is the first run's. */
|
|
11
|
-
class PreludedSandbox extends CodemodeSandbox {
|
|
12
|
-
#prelude;
|
|
13
|
-
constructor(prelude, options) {
|
|
14
|
-
super(options);
|
|
15
|
-
this.#prelude = prelude;
|
|
16
|
-
}
|
|
17
|
-
execute(code, options) {
|
|
18
|
-
return super.execute(`${this.#prelude}\n${code}`, options);
|
|
19
|
-
}
|
|
20
|
-
start(code, options) {
|
|
21
|
-
return super.start(`${this.#prelude}\n${code}`, options);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/** pi's code mode extension with `computer` bound to `computer`'s surface: install it among the run's pi-native
|
|
25
|
-
* extensions (PiAdapterOptions.extensions). No `models.*` in scripts: a script's paid work is the run's own tools.
|
|
26
|
-
* Where no computer_script is listed (a code-only computer: `computer.declare`), the codemode tool's description
|
|
27
|
-
* declares `computer` as computer_script's would; otherwise computer_script's declares it once. */
|
|
28
|
-
export function computerCodemode(computer) {
|
|
29
|
-
const sandbox = new PreludedSandbox(computer.prelude, { timeoutMs: SCRIPT_MAX_MS, memoryLimitBytes: MEMORY_BYTES });
|
|
30
|
-
const extension = createCodemodeExtension({
|
|
31
|
-
sandbox,
|
|
32
|
-
models: false,
|
|
33
|
-
// No tool listed again in the system prompt's codemode section: every tool is offered as itself (code mode "on"),
|
|
34
|
-
// computer_script's description declares `computer` once (where none is listed, this tool's own, below), and a
|
|
35
|
-
// script finds any other with searchTools().
|
|
36
|
-
inlineBudget: 0,
|
|
37
|
-
globals: [{
|
|
38
|
-
name: COMPUTER_CALL_GLOBAL,
|
|
39
|
-
spread: true,
|
|
40
|
-
// The value whole, images and all: a script shows one with image(...).
|
|
41
|
-
execute: async (given, _api, context) => {
|
|
42
|
-
const [op, args] = given;
|
|
43
|
-
return (await computer.guard.call(String(op), args, (sent) => computer.port.call(String(op), sent ?? {}, context.abortSignal)));
|
|
44
|
-
},
|
|
45
|
-
}],
|
|
46
|
-
});
|
|
47
|
-
if (!computer.declare)
|
|
48
|
-
return extension;
|
|
49
|
-
const declared = `\n\nScripts have \`computer\` bound, the run's computer: many steps in one call. A refused step throws.\n\`\`\`ts\n${computerDeclarations(computer.card.groups)}\n\`\`\``;
|
|
50
|
-
return { ...extension, tools: (extension.tools ?? []).map((tool) => (tool.name === CODEMODE_TOOL_NAME ? { ...tool, description: `${tool.description}${declared}` } : tool)) };
|
|
51
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { type Card } from "@parcha/agentrun-computer/surface";
|
|
2
|
-
import type { Executor } from "@parcha/agentrun-kernel/kernel";
|
|
3
|
-
/** A script's longest run by default, and at most, in ms. */
|
|
4
|
-
export declare const SCRIPT_DEFAULT_MS = 120000;
|
|
5
|
-
export declare const SCRIPT_MAX_MS = 600000;
|
|
6
|
-
/** The run's tool gate's decision of one call, as a script's computer call is held to it: decided as on the run's
|
|
7
|
-
* computer, where the call runs (adapterRunGate's script). */
|
|
8
|
-
export type ScriptDecide = (tool: string, args: unknown) => Promise<"allow" | "ask" | {
|
|
9
|
-
deny: string;
|
|
10
|
-
}>;
|
|
11
|
-
/** What a script's `computer.shell` and `computer.files` are held to: the run's gate, which a person's settings (a denied
|
|
12
|
-
* bash, a read-only bash policy, a denied write) reach through the one decision the run's own tools get. A script can't
|
|
13
|
-
* stop to ask, so a call the gate would ask about is refused in words that send the model to the tool itself. Until a
|
|
14
|
-
* gate is installed (the spec installs it once built) every one of those calls is refused. */
|
|
15
|
-
export declare class ScriptGuard {
|
|
16
|
-
#private;
|
|
17
|
-
private readonly shell;
|
|
18
|
-
private readonly kind?;
|
|
19
|
-
/** `shell`: what the run's bash adds under its bash policy (bash-read-only.ts policyEnv, policyPrelude): the environment
|
|
20
|
-
* that locks git's config down, set over any a script gives, and the line that runs git only at the floor version.
|
|
21
|
-
* `kind`: the run's computer's kind, which a refusal names (the phone, the desktop). */
|
|
22
|
-
constructor(shell?: {
|
|
23
|
-
readonly env: Readonly<Record<string, string>>;
|
|
24
|
-
readonly prelude: string;
|
|
25
|
-
}, kind?: string | undefined);
|
|
26
|
-
/** `op`'s arguments as the computer is sent them: a script's shell command with the policy's safeguards, as the bash
|
|
27
|
-
* tool's own command has them, which no option of the script's overrides. */
|
|
28
|
-
shaped(op: string, args: unknown): unknown;
|
|
29
|
-
install(decide: ScriptDecide): void;
|
|
30
|
-
/** Why `op` with `args` may not run now, or undefined when the gate lets it. The words start with what could not be
|
|
31
|
-
* done, on which computer ("could not run a shell command on the phone"), as the Timeline's row shows them; an ask
|
|
32
|
-
* says why in a person's words and what to do instead. A phone's instead is its screen, named as the script's
|
|
33
|
-
* `computer` (script.ts bindComputer) and the run's tools name it: the run's bash tool does not run on a phone, so it
|
|
34
|
-
* is never offered there. */
|
|
35
|
-
refusal(op: string, args: unknown): Promise<string | undefined>;
|
|
36
|
-
/** `call` of the computer's port with a script's computer call held to the gate first: the refusal throws in the
|
|
37
|
-
* script, where its `await` is. */
|
|
38
|
-
call(op: string, args: unknown, send: (args: unknown) => Promise<{
|
|
39
|
-
value?: unknown;
|
|
40
|
-
}>): Promise<unknown>;
|
|
41
|
-
}
|
|
42
|
-
/** What a script that reaches for a shell is told when its agent's computer has exec off. */
|
|
43
|
-
export declare const NO_PROGRAMS_WORDS = "this agent's computer runs no programs: its exec setting is off, so its scripts have no computer.shell and no computer.processes. Drive it through what it shows: its screen, its input and its apps.";
|
|
44
|
-
/** The one line that binds `computer` in a script for a computer that is `card` (the surface's scriptPrelude). With
|
|
45
|
-
* `exec: false` (the agent's setting, run-tools.ts AgentComputer) the card has no exec or processes group, so
|
|
46
|
-
* `computer.shell` and `computer.processes` are absent, and reaching for either throws NO_PROGRAMS_WORDS instead of a
|
|
47
|
-
* bare TypeError: `computer` is the surface's own object behind a Proxy whose get refuses those two names. */
|
|
48
|
-
export declare function scriptPreludeOf(card: Card, options?: {
|
|
49
|
-
readonly exec?: false;
|
|
50
|
-
}): string;
|
|
51
|
-
/** computer_script's executor over the script `prelude` (scriptPreludeOf): each script in its own isolate, its
|
|
52
|
-
* computer calls through the call's hands, the shell's and the files' held to `guard`. */
|
|
53
|
-
export declare function computerScriptExecutor(prelude: string, guard: ScriptGuard): Executor;
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
// computer_script's run: the model's JavaScript in a QuickJS isolate here in serve (pi-codemode's CodemodeSandbox, a
|
|
2
|
-
// worker thread per script), whose only binding is the claim's computer. The script sees `computer` (the surface's
|
|
3
|
-
// script prelude builds it inside the isolate over one host function, __computerCall) and pi-codemode's output helpers
|
|
4
|
-
// (text, image, console); no network, no keys, no timers, no modules, no file of this machine. Each call of the computer
|
|
5
|
-
// goes through the run's hands (Hands.computer), so a person's hold parks and refuses it as it does a per-step tool's.
|
|
6
|
-
//
|
|
7
|
-
// The answer: the script's text and images in the order it made them, then its returned value as JSON (its images'
|
|
8
|
-
// data left out: they are the answer's images); `structured` is the value. A script that threw answers its words, with
|
|
9
|
-
// what it showed before.
|
|
10
|
-
import { CodemodeSandbox } from "@earendil-works/pi-codemode";
|
|
11
|
-
import { COMPUTER_CALL_GLOBAL, scriptPrelude, withoutImageData } from "@parcha/agentrun-computer/surface";
|
|
12
|
-
/** A script's longest run by default, and at most, in ms. */
|
|
13
|
-
export const SCRIPT_DEFAULT_MS = 120_000;
|
|
14
|
-
export const SCRIPT_MAX_MS = 600_000;
|
|
15
|
-
/** The isolate's memory. */
|
|
16
|
-
const SCRIPT_MEMORY_BYTES = 256 * 1024 * 1024;
|
|
17
|
-
/** The tool a script's computer call is held to, as the run's own tool of that name is: the shell is bash's, a program
|
|
18
|
-
* started to run on (processes.start) bash_background's (bash's setting, and a read-only bash policy refuses it), a
|
|
19
|
-
* file's write is write's, a file's read, listing or stat is read's. The other ops (looking, acting) are the computer
|
|
20
|
-
* kind's, which the call of computer_script or codemode was already held to. */
|
|
21
|
-
const HELD_AS = Object.freeze({ "shell.run": "bash", "processes.start": "bash_background", "files.write": "write", "files.read": "read", "files.list": "read", "files.stat": "read" });
|
|
22
|
-
/** The ops whose command runs in the computer's shell: each gets the bash policy's safeguards. */
|
|
23
|
-
const SHELL_OPS = new Set(["shell.run", "processes.start"]);
|
|
24
|
-
/** What each held op does, as a refusal says it could not. */
|
|
25
|
-
const DOES = Object.freeze({ "shell.run": "run a shell command", "processes.start": "start a program", "files.write": "write a file", "files.read": "read a file", "files.list": "list a folder", "files.stat": "look a file up" });
|
|
26
|
-
/** The setting a person sees for each held tool: bash_background is bash's. */
|
|
27
|
-
const SETTING = Object.freeze({ bash: "bash", bash_background: "bash", write: "write", read: "read" });
|
|
28
|
-
/** What waits for a person's OK under each setting, in a person's words. */
|
|
29
|
-
const WAITS = Object.freeze({ bash: "shell commands", write: "file writes", read: "file reads" });
|
|
30
|
-
/** What a script's `computer.shell` and `computer.files` are held to: the run's gate, which a person's settings (a denied
|
|
31
|
-
* bash, a read-only bash policy, a denied write) reach through the one decision the run's own tools get. A script can't
|
|
32
|
-
* stop to ask, so a call the gate would ask about is refused in words that send the model to the tool itself. Until a
|
|
33
|
-
* gate is installed (the spec installs it once built) every one of those calls is refused. */
|
|
34
|
-
export class ScriptGuard {
|
|
35
|
-
shell;
|
|
36
|
-
kind;
|
|
37
|
-
#decide;
|
|
38
|
-
/** `shell`: what the run's bash adds under its bash policy (bash-read-only.ts policyEnv, policyPrelude): the environment
|
|
39
|
-
* that locks git's config down, set over any a script gives, and the line that runs git only at the floor version.
|
|
40
|
-
* `kind`: the run's computer's kind, which a refusal names (the phone, the desktop). */
|
|
41
|
-
constructor(shell = { env: {}, prelude: "" }, kind) {
|
|
42
|
-
this.shell = shell;
|
|
43
|
-
this.kind = kind;
|
|
44
|
-
}
|
|
45
|
-
/** `op`'s arguments as the computer is sent them: a script's shell command with the policy's safeguards, as the bash
|
|
46
|
-
* tool's own command has them, which no option of the script's overrides. */
|
|
47
|
-
shaped(op, args) {
|
|
48
|
-
if (!SHELL_OPS.has(op))
|
|
49
|
-
return args;
|
|
50
|
-
const given = (args ?? {});
|
|
51
|
-
const env = { ...(given.env ?? {}), ...this.shell.env };
|
|
52
|
-
return { ...given, ...(Object.keys(env).length > 0 ? { env } : {}), ...(this.shell.prelude !== "" && typeof given.command === "string" ? { command: `${this.shell.prelude}${given.command}` } : {}) };
|
|
53
|
-
}
|
|
54
|
-
install(decide) {
|
|
55
|
-
this.#decide = decide;
|
|
56
|
-
}
|
|
57
|
-
/** Why `op` with `args` may not run now, or undefined when the gate lets it. The words start with what could not be
|
|
58
|
-
* done, on which computer ("could not run a shell command on the phone"), as the Timeline's row shows them; an ask
|
|
59
|
-
* says why in a person's words and what to do instead. A phone's instead is its screen, named as the script's
|
|
60
|
-
* `computer` (script.ts bindComputer) and the run's tools name it: the run's bash tool does not run on a phone, so it
|
|
61
|
-
* is never offered there. */
|
|
62
|
-
async refusal(op, args) {
|
|
63
|
-
const tool = HELD_AS[op];
|
|
64
|
-
if (tool === undefined)
|
|
65
|
-
return undefined;
|
|
66
|
-
const on = this.kind === "phone" ? "the phone" : this.kind === "desktop" ? "the desktop" : "the computer";
|
|
67
|
-
const couldNot = `could not ${DOES[op] ?? op} on ${on}`;
|
|
68
|
-
if (!this.#decide)
|
|
69
|
-
return `${couldNot}: this run's tool settings are not attached to its scripts yet`;
|
|
70
|
-
const given = (args ?? {});
|
|
71
|
-
const decision = await this.#decide(tool, SHELL_OPS.has(op) ? { command: given.command, ...(given.cwd !== undefined ? { cwd: given.cwd } : {}) } : { path: given.path });
|
|
72
|
-
if (decision === "allow")
|
|
73
|
-
return undefined;
|
|
74
|
-
if (decision !== "ask")
|
|
75
|
-
return `${couldNot}: ${decision.deny}`;
|
|
76
|
-
const setting = SETTING[tool] ?? tool;
|
|
77
|
-
const why = `this agent's ${WAITS[setting] ?? `${setting} calls`} wait for a person's OK (its ${setting} setting is ask), and a script can't stop to ask.`;
|
|
78
|
-
const instead = this.kind === "phone"
|
|
79
|
-
? `Do it on the phone's screen instead: in a script, computer.app(id).observe() reads it and its press, type and click act on it (or call the computer_observe and computer_act tools), or ask the agent's owner to set ${setting} to allow.`
|
|
80
|
-
: `Call the ${tool} tool itself, which can ask, or ask the agent's owner to set ${setting} to allow.`;
|
|
81
|
-
return `${couldNot}: ${why} ${instead}`;
|
|
82
|
-
}
|
|
83
|
-
/** `call` of the computer's port with a script's computer call held to the gate first: the refusal throws in the
|
|
84
|
-
* script, where its `await` is. */
|
|
85
|
-
async call(op, args, send) {
|
|
86
|
-
const refused = await this.refusal(op, args);
|
|
87
|
-
if (refused !== undefined)
|
|
88
|
-
throw new Error(refused);
|
|
89
|
-
return (await send(this.shaped(op, args ?? {}))).value ?? null;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/** Every image in `value` (`{ type: "image", data }`), in the order withImageData puts data back into them. */
|
|
93
|
-
function imagesIn(value) {
|
|
94
|
-
if (Array.isArray(value))
|
|
95
|
-
return value.flatMap(imagesIn);
|
|
96
|
-
if (value === null || typeof value !== "object")
|
|
97
|
-
return [];
|
|
98
|
-
const record = value;
|
|
99
|
-
if (record.type === "image" && typeof record.data === "string")
|
|
100
|
-
return [{ data: record.data, mimeType: typeof record.mimeType === "string" ? record.mimeType : "image/png" }];
|
|
101
|
-
return Object.values(record).flatMap(imagesIn);
|
|
102
|
-
}
|
|
103
|
-
/** The script's own output and its value, as the model reads them. The images come as the structured value wants them
|
|
104
|
-
* back (withImageData fills its data-less image objects in order): the returned value's own first, then the ones the
|
|
105
|
-
* script showed with image(...), so a returned image keeps its own pixels whatever was shown. */
|
|
106
|
-
function answerOf(output, value) {
|
|
107
|
-
const words = [];
|
|
108
|
-
const shown = [];
|
|
109
|
-
for (const item of output) {
|
|
110
|
-
if (item.type === "text")
|
|
111
|
-
words.push(item.text);
|
|
112
|
-
else
|
|
113
|
-
shown.push({ data: item.data, mimeType: item.mimeType });
|
|
114
|
-
}
|
|
115
|
-
if (value !== undefined)
|
|
116
|
-
words.push(typeof value === "string" ? value : JSON.stringify(withoutImageData(value)));
|
|
117
|
-
return { text: words.join("\n") || "(the script returned nothing and showed nothing)", images: [...imagesIn(value), ...shown] };
|
|
118
|
-
}
|
|
119
|
-
/** What a script that reaches for a shell is told when its agent's computer has exec off. */
|
|
120
|
-
export const NO_PROGRAMS_WORDS = "this agent's computer runs no programs: its exec setting is off, so its scripts have no computer.shell and no computer.processes. Drive it through what it shows: its screen, its input and its apps.";
|
|
121
|
-
/** The one line that binds `computer` in a script for a computer that is `card` (the surface's scriptPrelude). With
|
|
122
|
-
* `exec: false` (the agent's setting, run-tools.ts AgentComputer) the card has no exec or processes group, so
|
|
123
|
-
* `computer.shell` and `computer.processes` are absent, and reaching for either throws NO_PROGRAMS_WORDS instead of a
|
|
124
|
-
* bare TypeError: `computer` is the surface's own object behind a Proxy whose get refuses those two names. */
|
|
125
|
-
export function scriptPreludeOf(card, options = {}) {
|
|
126
|
-
const prelude = scriptPrelude(card);
|
|
127
|
-
if (options.exec !== false)
|
|
128
|
-
return prelude;
|
|
129
|
-
return `const computer = ((bound) => new Proxy(bound, { get(target, key, receiver) { if (key === "shell" || key === "processes") throw new Error(${JSON.stringify(NO_PROGRAMS_WORDS)}); return Reflect.get(target, key, receiver); } }))((() => { ${prelude} return computer; })());`;
|
|
130
|
-
}
|
|
131
|
-
/** computer_script's executor over the script `prelude` (scriptPreludeOf): each script in its own isolate, its
|
|
132
|
-
* computer calls through the call's hands, the shell's and the files' held to `guard`. */
|
|
133
|
-
export function computerScriptExecutor(prelude, guard) {
|
|
134
|
-
return async (args, call) => {
|
|
135
|
-
const { code, timeoutMs } = (args ?? {});
|
|
136
|
-
if (typeof code !== "string" || code.trim() === "")
|
|
137
|
-
return { text: "", error: "computer_script needs code: the body of an async function, with `computer` bound" };
|
|
138
|
-
const port = call.hands.computer;
|
|
139
|
-
if (!port)
|
|
140
|
-
return { text: "", error: "computer_script needs a desktop or a phone computer: this run has none" };
|
|
141
|
-
const limit = typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0 ? Math.min(timeoutMs, SCRIPT_MAX_MS) : SCRIPT_DEFAULT_MS;
|
|
142
|
-
const sandbox = new CodemodeSandbox({
|
|
143
|
-
timeoutMs: limit,
|
|
144
|
-
memoryLimitBytes: SCRIPT_MEMORY_BYTES,
|
|
145
|
-
globals: [{
|
|
146
|
-
name: COMPUTER_CALL_GLOBAL,
|
|
147
|
-
spread: true,
|
|
148
|
-
// The value whole, images and all: a script shows one with image(...). The JSON round trip is the isolate's.
|
|
149
|
-
execute: async (given, context) => {
|
|
150
|
-
const [op, opArgs] = given;
|
|
151
|
-
return (await guard.call(String(op), opArgs, (sent) => port.call(String(op), sent ?? {}, AbortSignal.any([context.signal, ...(call.signal ? [call.signal] : [])]))));
|
|
152
|
-
},
|
|
153
|
-
}],
|
|
154
|
-
});
|
|
155
|
-
try {
|
|
156
|
-
// The prelude is one line, so the script's own line numbers hold.
|
|
157
|
-
const result = await sandbox.execute(`${prelude}\n${code}`, call.signal ? { signal: call.signal } : {});
|
|
158
|
-
if (!result.ok) {
|
|
159
|
-
if (result.error.kind === "aborted" && call.signal?.aborted)
|
|
160
|
-
throw call.signal.reason ?? new Error(result.error.message);
|
|
161
|
-
const shown = answerOf(result.output, undefined);
|
|
162
|
-
const why = result.error.kind === "timeout" ? `the script ran past its ${limit} ms: ${result.error.message}` : result.error.message;
|
|
163
|
-
return { text: result.output.length > 0 ? shown.text : "", error: why, ...(shown.images.length > 0 ? { images: shown.images } : {}) };
|
|
164
|
-
}
|
|
165
|
-
const shown = answerOf(result.output, result.value);
|
|
166
|
-
return { text: shown.text, ...(shown.images.length > 0 ? { images: shown.images } : {}), ...(result.value === undefined ? {} : { structured: withoutImageData(result.value) }) };
|
|
167
|
-
}
|
|
168
|
-
finally {
|
|
169
|
-
await sandbox.close();
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
}
|