@parcha/agentrun-serve 0.1.0-beta.37 → 0.1.0-beta.39
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 +700 -0
- package/README.md +441 -177
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +1 -3
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +48 -23
- package/dist/answer-json.d.ts +34 -1
- package/dist/answer-json.js +91 -9
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/bash-read-only.js +2 -1
- package/dist/browser-cost.js +52 -93
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -400
- package/dist/cap.js +6 -942
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +2 -6
- 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 +25 -0
- package/dist/composio-preset.js +51 -8
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.d.ts +36 -24
- package/dist/computer-calls.js +110 -27
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +12 -2
- package/dist/computer-live.js +21 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +18 -2
- package/dist/computer-view.js +21 -6
- package/dist/computer-viewer.js +40 -13
- package/dist/computers.d.ts +8 -2
- package/dist/computers.js +18 -8
- package/dist/console/assets/index-BNhZs-jp.css +1 -0
- package/dist/console/assets/index-BQv5aOGB.js +700 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +6 -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/decisions.js +4 -0
- package/dist/email/account.d.ts +84 -0
- package/dist/email/account.js +159 -0
- package/dist/email/answer.d.ts +10 -0
- package/dist/email/answer.js +182 -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 +380 -0
- package/dist/email/names.d.ts +20 -0
- package/dist/email/names.js +40 -0
- package/dist/email/routes.d.ts +9 -0
- package/dist/email/routes.js +50 -0
- package/dist/email/tools.d.ts +20 -0
- package/dist/email/tools.js +517 -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/faux-computers.js +4 -2
- 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 -22
- package/dist/harness-opencode/facts.js +5 -4
- package/dist/harness-opencode/host/policy.d.ts +4 -5
- package/dist/harness-opencode/host/policy.js +14 -33
- 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.d.ts +0 -2
- package/dist/harness-table.js +8 -7
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/host-tools.d.ts +1 -5
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +3 -3
- package/dist/hosted-search.js +51 -32
- 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/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +24 -4
- package/dist/learn/check.js +340 -7
- package/dist/learn/commit.d.ts +10 -0
- package/dist/learn/commit.js +18 -4
- package/dist/learn/compile.d.ts +250 -0
- package/dist/learn/compile.js +507 -0
- package/dist/learn/general.d.ts +3 -0
- package/dist/learn/general.js +4 -2
- package/dist/learn/grade.d.ts +5 -1
- package/dist/learn/grade.js +11 -7
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +308 -0
- package/dist/learn/promote.js +321 -0
- package/dist/learn/refit.d.ts +48 -0
- package/dist/learn/refit.js +264 -0
- package/dist/learn/reflect.d.ts +5 -25
- package/dist/learn/reflect.js +14 -131
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +19 -16
- package/dist/learn/skills.js +157 -53
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +58 -2
- package/dist/learned-nodes.js +68 -5
- package/dist/learned-workflow.d.ts +58 -32
- package/dist/learned-workflow.js +215 -77
- package/dist/learning-batch.d.ts +2 -2
- package/dist/learning-batch.js +4 -4
- package/dist/learning-cost.d.ts +41 -11
- package/dist/learning-cost.js +31 -13
- package/dist/learning-routes.d.ts +12 -2
- package/dist/learning-routes.js +34 -6
- package/dist/learning-words.d.ts +8 -1
- package/dist/learning-words.js +11 -1
- package/dist/learning.d.ts +26 -1
- package/dist/learning.js +7 -4
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/llm.js +0 -3
- package/dist/local-models.d.ts +33 -2
- package/dist/local-models.js +43 -5
- package/dist/mcp-gateway.d.ts +12 -20
- package/dist/mcp-gateway.js +16 -44
- package/dist/mcp-oauth.d.ts +5 -0
- package/dist/mcp-oauth.js +1 -1
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +113 -0
- package/dist/mcp-probe.d.ts +8 -9
- package/dist/mcp-probe.js +16 -33
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +102 -26
- package/dist/mcp-servers-store.js +151 -25
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +11 -0
- package/dist/mcp-store.js +16 -2
- package/dist/mcp-wire.d.ts +22 -0
- package/dist/mcp-wire.js +36 -0
- package/dist/mcp.js +3 -3
- package/dist/meta-tool-names.d.ts +1 -0
- package/dist/meta-tool-names.js +3 -0
- package/dist/model-form.d.ts +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +39 -6
- package/dist/model.js +171 -32
- package/dist/monid.d.ts +50 -29
- package/dist/monid.js +234 -143
- 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 +1 -0
- package/dist/openapi.js +705 -126
- package/dist/paid-calls.d.ts +34 -32
- package/dist/paid-calls.js +52 -104
- package/dist/place-offers.d.ts +4 -8
- package/dist/place-offers.js +4 -9
- package/dist/port-models.d.ts +7 -2
- package/dist/port-models.js +5 -2
- package/dist/print.d.ts +4 -2
- package/dist/print.js +4 -3
- package/dist/propose.d.ts +8 -3
- package/dist/propose.js +28 -7
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +17 -2
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/reflect-range.js +2 -1
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +13 -2
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +23 -1
- package/dist/run-launch.js +17 -4
- package/dist/run-learning-served.d.ts +84 -0
- package/dist/run-manifest.d.ts +8 -0
- package/dist/run-manifest.js +33 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +12 -10
- package/dist/run-view.d.ts +59 -41
- package/dist/run-view.js +128 -64
- package/dist/runnable.d.ts +13 -8
- package/dist/runnable.js +77 -60
- package/dist/runner/adapter-loop.d.ts +60 -15
- package/dist/runner/adapter-loop.js +1406 -464
- package/dist/runner/adapter-run-spec.d.ts +45 -14
- package/dist/runner/adapter-run-spec.js +200 -116
- package/dist/runner/adapters/pi.d.ts +40 -7
- package/dist/runner/adapters/pi.js +149 -38
- 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 +150 -66
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +5 -3
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +149 -5
- package/dist/runner/conformance/subject.d.ts +11 -4
- package/dist/runner/end-of-run.d.ts +8 -5
- package/dist/runner/end-of-run.js +11 -6
- package/dist/runner/feedback-round.d.ts +79 -0
- package/dist/runner/feedback-round.js +127 -0
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +55 -13
- package/dist/runner/journal-kinds.js +19 -0
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +58 -19
- package/dist/runner/learning-end.js +316 -115
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +21 -1
- package/dist/runner/learning-loop.js +24 -6
- package/dist/runner/learning-seed.d.ts +4 -0
- package/dist/runner/learning-seed.js +14 -0
- package/dist/runner/loop-contract.d.ts +19 -3
- package/dist/runner/loop.d.ts +34 -1
- package/dist/runner/loop.js +55 -1
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-claim.d.ts +5 -1
- package/dist/runner/mcp-claim.js +66 -50
- package/dist/runner/mcp-run.d.ts +20 -53
- package/dist/runner/mcp-run.js +22 -88
- package/dist/runner/meta-tools.d.ts +44 -0
- package/dist/runner/meta-tools.js +344 -0
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +128 -42
- package/dist/runner/model-route.d.ts +12 -3
- package/dist/runner/model-route.js +149 -19
- package/dist/runner/monid-run.d.ts +18 -0
- package/dist/runner/monid-run.js +170 -0
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +146 -0
- package/dist/runner/promotion.js +803 -0
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.d.ts +36 -21
- package/dist/runner/reflect-hook.js +147 -49
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +34 -8
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/sessions.d.ts +8 -3
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +7 -12
- package/dist/runner/workflow-first.d.ts +226 -0
- package/dist/runner/workflow-first.js +293 -0
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +32 -19
- package/dist/runner/workflow-spec.d.ts +5 -1
- package/dist/runner/workflow-spec.js +63 -48
- package/dist/runs-over-store.d.ts +41 -4
- package/dist/runs-over-store.js +64 -22
- 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 +108 -20
- package/dist/server.js +874 -157
- package/dist/settings-wake.d.ts +8 -6
- package/dist/settings-wake.js +13 -7
- 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 +22 -7
- package/dist/store/agent-body.js +23 -14
- package/dist/store/command-wake.d.ts +3 -2
- package/dist/store/command-wake.js +4 -4
- 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.js +3 -1
- package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
- package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -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.js +3 -0
- package/dist/store/schema.d.ts +16 -0
- package/dist/store/schema.js +47 -8
- package/dist/store/sqlite/connection.d.ts +2 -2
- package/dist/store/sqlite/connection.js +2 -2
- package/dist/store/sqlite/run-patch.d.ts +8 -1
- package/dist/store/sqlite/run-patch.js +33 -10
- package/dist/store/sqlite/store.js +184 -28
- package/dist/store/store.d.ts +98 -21
- 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 +30 -1
- package/dist/store-reads/journal.js +141 -83
- package/dist/store-reads/learning.d.ts +179 -13
- package/dist/store-reads/learning.js +230 -68
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.d.ts +3 -2
- package/dist/store-view.js +109 -37
- package/dist/template-eval.d.ts +87 -16
- package/dist/template-eval.js +605 -120
- package/dist/template-github-permissions.d.ts +2 -2
- package/dist/template-github-permissions.js +2 -1
- package/dist/template-import.d.ts +31 -0
- package/dist/template-import.js +121 -0
- package/dist/template-source.d.ts +51 -0
- package/dist/template-source.js +371 -0
- package/dist/templates.d.ts +274 -52
- package/dist/templates.js +670 -201
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +7 -5
- package/dist/timeline/index.js +7 -5
- package/dist/timeline/labels.d.ts +11 -4
- package/dist/timeline/labels.js +122 -8
- package/dist/timeline/origin.d.ts +20 -6
- package/dist/timeline/origin.js +13 -6
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +76 -20
- package/dist/timeline/timeline.js +184 -39
- 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 +103 -76
- package/dist/tool-gate.js +200 -127
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +29 -0
- package/dist/tool-list.js +50 -0
- package/dist/tool-names.d.ts +76 -0
- package/dist/tool-names.js +101 -0
- package/dist/tool-plane.d.ts +34 -28
- package/dist/tool-plane.js +72 -37
- package/dist/tools.d.ts +59 -15
- package/dist/tools.js +46 -42
- package/dist/trigger-adapter.d.ts +85 -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 +228 -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 +94 -9
- package/dist/triggers.js +263 -62
- package/dist/uploads.d.ts +9 -0
- package/dist/uploads.js +27 -0
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +91 -50
- 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 +6 -8
- package/dist/web-fetch.js +10 -53
- 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/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 +25 -9
- package/dist/workspace/computer-deps.js +82 -38
- package/dist/workspace/computer-for-claim.d.ts +60 -4
- package/dist/workspace/computer-for-claim.js +203 -45
- package/dist/workspace/computer-hold.js +7 -1
- 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 +2 -3
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +31 -11
- package/dist/workspace/kind-skills/phone/SKILL.md +29 -14
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +33 -1
- package/dist/workspace/resolve-computer.js +37 -16
- 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 +40 -23
- package/dist/workspace/run-tools.js +46 -19
- package/dist/wrap-up.d.ts +35 -0
- package/dist/wrap-up.js +48 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +220 -60
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +46 -16
- package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
- package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
- package/templates/code-review/evals/injection/case.yaml +2 -1
- package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
- package/templates/code-review/evals/mentions-defused/case.yaml +3 -3
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
- package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
- package/templates/code-review/evals/never-flag/case.yaml +2 -1
- package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
- package/templates/code-review/evals/null-name/case.yaml +2 -1
- package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/case.yaml +2 -1
- package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
- package/templates/code-review/evals/other-repo/case.yaml +16 -0
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
- package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/code-review/evals/other-repo/prompt.md +10 -0
- 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/evals/re-review/case.yaml +2 -1
- package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
- package/templates/code-review/evals/re-review-open/case.yaml +2 -1
- package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
- package/templates/code-review/evals/repo-rule/case.yaml +2 -1
- package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
- package/templates/code-review/evals/two-defects/case.yaml +2 -1
- package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
- package/templates/code-review/rules/CODEREVIEW.md +1 -1
- package/templates/code-review/skills/review/DEEP.md +5 -4
- package/templates/code-review/skills/review/REVIEWER.md +5 -4
- package/templates/code-review/skills/review/SKILL.md +11 -6
- package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
- package/templates/inbound-lead/agent.md +26 -16
- package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
- package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
- package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
- package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
- package/templates/kyb/agent.md +15 -5
- package/templates/kyb/evals/adverse-media/prompt.md +2 -7
- package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
- package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
- package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
- package/templates/kyb/evals/name-collision/prompt.md +2 -6
- package/templates/kyb/evals/no-invention/prompt.md +2 -6
- package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
- package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
- package/templates/kyb/kyb.schema.json +8 -7
- package/templates/kyb/skills/kyb/SKILL.md +9 -6
- package/templates/market-monitor/agent.md +19 -12
- package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +32 -10
- package/templates/release-notes/evals/draft-not-publish/case.yaml +5 -4
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +5 -4
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/learned-style/case.yaml +2 -1
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
- package/templates/release-notes/evals/other-repo/case.yaml +24 -0
- package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
- package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
- package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/release-notes/evals/other-repo/prompt.md +32 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
- package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
- package/templates/release-notes/notes.schema.json +1 -1
- package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
- package/dist/console/assets/index-Cn6JX1uH.js +0 -563
- package/dist/console/assets/index-DRN62V5v.css +0 -1
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -7
- package/dist/runner/adapters/pi-computer.js +0 -43
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.d.ts +0 -38
- package/dist/tool-budget.js +0 -62
- package/dist/workspace/computer-script.d.ts +0 -37
- package/dist/workspace/computer-script.js +0 -138
- package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
- package/templates/code-review/evals/injection/graders/schema.md +0 -5
- package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
- package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
- package/templates/code-review/evals/null-name/graders/schema.md +0 -5
- package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
- package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
- package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
- package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
- package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
- package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
- package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
- package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
- package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
- package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
- package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
// The email trigger: a source on a clock that polls (trigger-adapter.ts `poll`). Every every_s seconds, on a grid from the
|
|
2
|
+
// epoch, it reads the server's email account's mailbox (INBOX by default) over IMAP, read-only, and each message that
|
|
3
|
+
// came since its cursor is one firing through the path a pushed event takes (triggers.ts): its accept filter, a run per
|
|
4
|
+
// message, max_active_runs, its key kept for its day. The cursor is the account it was read on (its user, IMAP host and
|
|
5
|
+
// port: nothing secret), the mailbox, its UIDVALIDITY and the last UID read, in the trigger's own settings, kept only once
|
|
6
|
+
// the poll's firings are recorded, so a restart goes on from it. Its start
|
|
7
|
+
// (the engine's start hook) is taken when the trigger is made, when an edit changes its mailbox or account, and when it
|
|
8
|
+
// is turned on again: mail from before then starts no run, and that is said; any other edit keeps the cursor. A start
|
|
9
|
+
// that can't sign in is taken at the first poll that does, and said; a UIDVALIDITY the server changed the same, and so
|
|
10
|
+
// another account saved in its place (PUT /v2/settings/email). A message's key is its Message-ID (else UIDVALIDITY:UID), so
|
|
11
|
+
// one seen twice fires once; its attrs say where it was found (mailbox, UIDVALIDITY, UID), which a run's thread is read
|
|
12
|
+
// from (email/tools.ts). At most POLL_TAKES messages a poll, oldest first. A
|
|
13
|
+
// message this server sent (X-AgentRun-Sent, email/tools.ts email_send) is left, and said. An unreachable server is said
|
|
14
|
+
// on the trigger and tried at the next time; a refused sign-in counts (the engine turns the trigger off at the third).
|
|
15
|
+
import { DEFAULT_ACCOUNT, NO_ACCOUNT } from "./email/account.js";
|
|
16
|
+
import { ACCEPT_SCHEMA, acceptOf, acceptRefusal } from "./trigger-accept.js";
|
|
17
|
+
import { closedSchema, PAYLOAD_KEPT_BYTES, unknownSourceFields } from "./trigger-adapter.js";
|
|
18
|
+
import { MAX_EVERY_S, MIN_EVERY_S } from "./trigger-schedule.js";
|
|
19
|
+
/** The most messages one poll takes: the rest wait for the next. */
|
|
20
|
+
export const POLL_TAKES = 20;
|
|
21
|
+
/** The one event an email trigger's accept names. */
|
|
22
|
+
const EVENT = "message";
|
|
23
|
+
/** The trigger's own settings: its cursor and its last check, no secret (public). */
|
|
24
|
+
const CURSOR = "cursor";
|
|
25
|
+
/** Which account a cursor was read on: its user, IMAP host and port, nothing secret (the cursor is a public setting). */
|
|
26
|
+
const accountKey = (account) => `${account.user.trim().toLowerCase()}@${account.imap.host.toLowerCase()}:${account.imap.port}`;
|
|
27
|
+
/** The source's own fields, checked: each issue through `bad`. Undefined when one does not read. */
|
|
28
|
+
function fieldsOf(value, bad) {
|
|
29
|
+
let failed = false;
|
|
30
|
+
const fail = (field, reason, message) => ((failed = true), bad(field, reason, message));
|
|
31
|
+
const account = value.account ?? DEFAULT_ACCOUNT;
|
|
32
|
+
if (account !== DEFAULT_ACCOUNT)
|
|
33
|
+
fail("account", "not_an_option", `account is "${DEFAULT_ACCOUNT}": this server has one email account`);
|
|
34
|
+
const mailbox = value.mailbox ?? "INBOX";
|
|
35
|
+
if (typeof mailbox !== "string" || !mailbox.trim() || mailbox.length > 300 || /[\u0000-\u001f]/.test(mailbox))
|
|
36
|
+
fail("mailbox", "invalid", "mailbox is a mailbox's name: INBOX (the default), or a folder's");
|
|
37
|
+
const every = value.every_s ?? MIN_EVERY_S;
|
|
38
|
+
if (!Number.isSafeInteger(every) || every < MIN_EVERY_S || every > MAX_EVERY_S)
|
|
39
|
+
fail("every_s", "invalid", `every_s is a whole number of seconds, ${MIN_EVERY_S} to ${MAX_EVERY_S}`);
|
|
40
|
+
const accept = value.accept === undefined ? undefined : acceptOf(value.accept, fail);
|
|
41
|
+
accept?.forEach((rule, i) => {
|
|
42
|
+
if (rule.event !== EVENT)
|
|
43
|
+
fail(`accept[${i}].event`, "not_an_option", `An email trigger's one event is "${EVENT}"`);
|
|
44
|
+
if (rule.actions !== undefined)
|
|
45
|
+
fail(`accept[${i}].actions`, "not_allowed", "An email has no action: take it by its fields with where");
|
|
46
|
+
});
|
|
47
|
+
if (failed)
|
|
48
|
+
return undefined;
|
|
49
|
+
return { kind: "email", account: account, mailbox: mailbox.trim(), every_s: every, ...(accept ? { accept } : {}) };
|
|
50
|
+
}
|
|
51
|
+
/** The cursor kept, when it reads. */
|
|
52
|
+
function cursorOf(text) {
|
|
53
|
+
if (!text)
|
|
54
|
+
return undefined;
|
|
55
|
+
try {
|
|
56
|
+
const value = JSON.parse(text);
|
|
57
|
+
return (value.account === undefined || typeof value.account === "string") && typeof value.mailbox === "string" && typeof value.uidvalidity === "string" && Number.isSafeInteger(value.uid) ? value : undefined;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const kept = (cursor) => ({ [CURSOR]: JSON.stringify(cursor) });
|
|
64
|
+
/** Whether `payload`'s JSON is within the engine's bound, measured as the engine does: bytes of UTF-8, escapes counted. */
|
|
65
|
+
const fits = (payload) => Buffer.byteLength(JSON.stringify(payload), "utf8") <= PAYLOAD_KEPT_BYTES;
|
|
66
|
+
/** The first `n` characters (code points) of `text`, ending in `…` when cut. */
|
|
67
|
+
const clipped = (text, n) => (typeof text === "string" && [...text].length > n ? `${[...text].slice(0, n).join("")}…` : text);
|
|
68
|
+
/** A message's payload whole, its JSON within PAYLOAD_KEPT_BYTES, so the engine never cuts it mid-string. When it is over,
|
|
69
|
+
* the text is cut, the longest prefix that fits found by halving (a character's start, escapes counted), said in it and
|
|
70
|
+
* marked `text_truncated: true`; when its other fields alone are over, the subject, the names and the lists are cut too,
|
|
71
|
+
* shorter until it fits. */
|
|
72
|
+
function fittedPayload(whole) {
|
|
73
|
+
if (fits(whole))
|
|
74
|
+
return whole;
|
|
75
|
+
const text = typeof whole.text === "string" ? whole.text : "";
|
|
76
|
+
// No more characters than the bound has bytes can fit: the halving reads at most that many.
|
|
77
|
+
const chars = [...text.slice(0, 2 * PAYLOAD_KEPT_BYTES)].slice(0, PAYLOAD_KEPT_BYTES);
|
|
78
|
+
const said = `\n[cut: the message's text was ${Buffer.byteLength(text, "utf8")} bytes]`;
|
|
79
|
+
let rest = whole;
|
|
80
|
+
const withText = (n) => ({ ...rest, text: `${chars.slice(0, n).join("")}${said}`, text_truncated: true });
|
|
81
|
+
for (let room = 1000; !fits(withText(0)); room = Math.floor(room / 2)) {
|
|
82
|
+
const list = (value) => (Array.isArray(value) ? value.slice(0, Math.max(1, Math.floor(room / 20))).map((one) => (typeof one === "string" ? clipped(one, Math.min(320, room)) : one)) : value);
|
|
83
|
+
const attachments = Array.isArray(whole.attachments) ? whole.attachments.slice(0, Math.max(0, Math.floor(room / 20))).map((a) => ({ ...a, name: clipped(a?.name, Math.min(200, room)) })) : whole.attachments;
|
|
84
|
+
rest = { ...whole, from: clipped(whole.from, Math.min(998, room)), message_id: clipped(whole.message_id, Math.min(998, room)), in_reply_to: clipped(whole.in_reply_to, Math.min(998, room)), subject: clipped(whole.subject, room), from_name: clipped(whole.from_name, Math.min(320, room)), to: list(whole.to), cc: list(whole.cc), attachments };
|
|
85
|
+
if (room === 0)
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
let lo = 0;
|
|
89
|
+
let hi = chars.length;
|
|
90
|
+
while (lo < hi) {
|
|
91
|
+
const mid = Math.ceil((lo + hi) / 2);
|
|
92
|
+
if (fits(withText(mid)))
|
|
93
|
+
lo = mid;
|
|
94
|
+
else
|
|
95
|
+
hi = mid - 1;
|
|
96
|
+
}
|
|
97
|
+
return withText(lo);
|
|
98
|
+
}
|
|
99
|
+
/** A message as the event its trigger fires: its payload (JSON, untrusted, whole within the engine's bound), its attrs
|
|
100
|
+
* (who, what, and where it was found: the run's thread is read from there), keyed by its Message-ID. */
|
|
101
|
+
function eventOf(m, cursor, payloadOf) {
|
|
102
|
+
const payload = fittedPayload(payloadOf(m));
|
|
103
|
+
return {
|
|
104
|
+
key: m.message_id ?? `${cursor.uidvalidity}:${m.uid}`,
|
|
105
|
+
text: JSON.stringify(payload),
|
|
106
|
+
attrs: { from: m.from, subject: m.subject, ...(m.message_id ? { message_id: m.message_id } : {}), mailbox: cursor.mailbox, uidvalidity: cursor.uidvalidity, uid: String(m.uid) },
|
|
107
|
+
event: EVENT,
|
|
108
|
+
body: payload,
|
|
109
|
+
cursor: kept(cursor),
|
|
110
|
+
...(m.sent_here !== undefined ? { left: "Left: this server sent that message (it carries X-AgentRun-Sent), so it starts no run." } : {}),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** `n` messages, in words. */
|
|
114
|
+
const messages = (n) => `${n} message${n === 1 ? "" : "s"}`;
|
|
115
|
+
/** The cursor at the end of `source`'s mailbox on `account` as it is now, and how many messages it holds: where watching
|
|
116
|
+
* starts. */
|
|
117
|
+
async function endOf(session, source, account) {
|
|
118
|
+
const path = await session.resolve(source.mailbox);
|
|
119
|
+
const box = await session.open(path);
|
|
120
|
+
// The newest UID there: UIDNEXT's one before, else the highest a search finds.
|
|
121
|
+
const uid = box.uidNext > 0 ? box.uidNext - 1 : Math.max(0, ...(await session.uids({ all: true })));
|
|
122
|
+
return { cursor: { account: accountKey(account), mailbox: path, uidvalidity: box.uidValidity, uid }, exists: box.exists };
|
|
123
|
+
}
|
|
124
|
+
/** The history line of a start taken for `why`, with `exists` messages left. */
|
|
125
|
+
const watching = (source, exists, why) => why === "enabled"
|
|
126
|
+
? `Watching ${source.mailbox} from now, on again: the ${messages(exists)} already there, any that came while it was off among them, won't start runs.`
|
|
127
|
+
: `Watching ${source.mailbox} from now: the ${messages(exists)} already there won't start runs.`;
|
|
128
|
+
/** The history line of a start that could not read the mailbox. */
|
|
129
|
+
const unchecked = (source, why) => `Couldn't check ${String(source.mailbox ?? "INBOX")} when it was ${why === "created" ? "created" : why === "edited" ? "changed" : "turned on again"}; watching from the first check that signs in.`;
|
|
130
|
+
/** `source`'s start, on `account`: the cursor at its mailbox's end now. */
|
|
131
|
+
async function start(source, account, why) {
|
|
132
|
+
const { MailError, withImap } = await import("./email/mail.js");
|
|
133
|
+
return withImap(account, async (session) => {
|
|
134
|
+
const end = await endOf(session, source, account);
|
|
135
|
+
return { check: { ok: true, message: `Watching ${source.mailbox}.` }, note: watching(source, end.exists, why), cursor: kept(end.cursor) };
|
|
136
|
+
}).catch((error) => {
|
|
137
|
+
const failure = error instanceof MailError ? error : new MailError("failed", String(error?.message ?? error));
|
|
138
|
+
return { check: { ok: false, message: failure.message }, note: unchecked(source, why) };
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/** One poll of `source`'s mailbox from `cursor`, on `account`. The mail libraries load at the first poll, never with the
|
|
142
|
+
* registry (every process that reads the sources). */
|
|
143
|
+
async function poll(source, account, cursor) {
|
|
144
|
+
const { MailError, payloadOf, READ_BYTES, withImap } = await import("./email/mail.js");
|
|
145
|
+
return withImap(account, async (session) => {
|
|
146
|
+
const end = await endOf(session, source, account);
|
|
147
|
+
const path = end.cursor.mailbox;
|
|
148
|
+
// No start yet (one that could not sign in, or a cursor kept before starts were taken): this check takes it.
|
|
149
|
+
if (!cursor || cursor.mailbox !== path)
|
|
150
|
+
return { check: { ok: true, message: `Watching ${source.mailbox}.` }, note: watching(source, end.exists, "created"), cursor: kept(end.cursor) };
|
|
151
|
+
// Another account saved in its place (or a cursor that names none): its UIDs are another mailbox's, so it starts over.
|
|
152
|
+
if (cursor.account !== end.cursor.account) {
|
|
153
|
+
return { check: { ok: true, message: `Watching ${source.mailbox} again: the email account changed.` }, note: `The email account changed: watching ${source.mailbox} from now; the ${messages(end.exists)} there won't start runs.`, cursor: kept(end.cursor) };
|
|
154
|
+
}
|
|
155
|
+
if (cursor.uidvalidity !== end.cursor.uidvalidity) {
|
|
156
|
+
return { check: { ok: true, message: `Watching ${source.mailbox} again: the mail server rebuilt it.` }, note: `${source.mailbox} was rebuilt on the mail server (its UIDVALIDITY changed): watching it from now; the ${messages(end.exists)} there won't start runs.`, cursor: kept(end.cursor) };
|
|
157
|
+
}
|
|
158
|
+
// `n:*` names the highest UID even when it is below n: only those past the cursor count.
|
|
159
|
+
const fresh = (await session.uids({ uid: `${cursor.uid + 1}:*` })).filter((uid) => uid > cursor.uid);
|
|
160
|
+
const taken = fresh.slice(0, POLL_TAKES);
|
|
161
|
+
const read = await session.fetch(path, taken, READ_BYTES);
|
|
162
|
+
const events = read.map((m) => eventOf(m, { ...cursor, uid: m.uid }, payloadOf));
|
|
163
|
+
const last = taken.at(-1) ?? cursor.uid;
|
|
164
|
+
const more = fresh.length - taken.length;
|
|
165
|
+
return { check: { ok: true, message: `Read ${source.mailbox}: ${messages(events.length)} new${more > 0 ? `, ${more} more at the next check` : ""}.` }, events, cursor: kept({ ...cursor, uid: last }) };
|
|
166
|
+
}).catch((error) => {
|
|
167
|
+
const failure = error instanceof MailError ? error : new MailError("failed", String(error?.message ?? error));
|
|
168
|
+
if (failure.kind === "refused")
|
|
169
|
+
return { check: { ok: false, message: failure.message }, refused: { detail: "The mail server refused the sign-in 3 times in a row: check the account in Settings → Email, then turn this trigger on again." } };
|
|
170
|
+
return { check: { ok: false, message: failure.message } };
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
export const email = {
|
|
174
|
+
id: "email",
|
|
175
|
+
label: "email trigger",
|
|
176
|
+
delivery: "clock",
|
|
177
|
+
owner: false,
|
|
178
|
+
// Each message is its sender's: one run's answer (to alice) is never handed to the next (bob's).
|
|
179
|
+
previousResult: false,
|
|
180
|
+
settings: { scope: "trigger", fields: { [CURSOR]: { public: true }, last_check: { public: true } } },
|
|
181
|
+
describe: `{kind: "email", account?: "${DEFAULT_ACCOUNT}", mailbox?: "INBOX", every_s?: ${MIN_EVERY_S}, accept?: [{event: "${EVENT}", where?}]}`,
|
|
182
|
+
fires: "each new message in the server's email account's mailbox (`email`), read every every_s seconds, that its `accept` takes",
|
|
183
|
+
firedBy: "`email`: a message found in the email account's mailbox, its key from the trigger and the message's Message-ID (else its UIDVALIDITY and UID).",
|
|
184
|
+
schemas: [
|
|
185
|
+
closedSchema({ kind: { const: "email" } }, {
|
|
186
|
+
account: { const: DEFAULT_ACCOUNT, default: DEFAULT_ACCOUNT, description: "The email account it reads (Settings → Email): the server's one, \"default\"." },
|
|
187
|
+
mailbox: { type: "string", minLength: 1, maxLength: 300, default: "INBOX", description: "The mailbox it reads: INBOX, \"Drafts\" or \"Sent\" (the account's own), or a folder's name." },
|
|
188
|
+
every_s: { type: "integer", minimum: MIN_EVERY_S, maximum: MAX_EVERY_S, default: MIN_EVERY_S, description: "How often it reads the mailbox, in seconds, on a grid from the epoch." },
|
|
189
|
+
accept: { ...ACCEPT_SCHEMA, description: `The messages that start a run: each rule's event is "${EVENT}", its where reads the payload (/from, /to, /subject, /text, ...). None: every message.` },
|
|
190
|
+
}),
|
|
191
|
+
],
|
|
192
|
+
sent: [
|
|
193
|
+
closedSchema({ kind: { const: "email" }, account: { const: DEFAULT_ACCOUNT }, mailbox: { type: "string" }, every_s: { type: "integer", minimum: MIN_EVERY_S, maximum: MAX_EVERY_S } }, { accept: ACCEPT_SCHEMA }),
|
|
194
|
+
],
|
|
195
|
+
parse(value, _now, bad, issues) {
|
|
196
|
+
issues.push(...unknownSourceFields(value, ["kind", "account", "mailbox", "every_s", "accept"]));
|
|
197
|
+
return fieldsOf(value, bad);
|
|
198
|
+
},
|
|
199
|
+
wellFormed: (source) => fieldsOf(source, () => { }) !== undefined,
|
|
200
|
+
clock(source) {
|
|
201
|
+
const step = source.every_s * 1000;
|
|
202
|
+
return { next: (after) => (Math.floor(after / step) + 1) * step, latest: (first, now) => first + Math.floor((now - first) / step) * step, step };
|
|
203
|
+
},
|
|
204
|
+
problem: (source) => (typeof source.every_s === "number" && (source.every_s < MIN_EVERY_S || source.every_s > MAX_EVERY_S) ? `every_s ${source.every_s} is not ${MIN_EVERY_S} to ${MAX_EVERY_S} seconds` : undefined),
|
|
205
|
+
// Each message is its own work: a run per message, max_active_runs bounding how many at once.
|
|
206
|
+
concurrent: () => true,
|
|
207
|
+
takes: (source, event) => {
|
|
208
|
+
const rules = source.accept;
|
|
209
|
+
return rules ? acceptRefusal(rules, event.event, event.body) : undefined;
|
|
210
|
+
},
|
|
211
|
+
async poll(source, ctx) {
|
|
212
|
+
const account = (await ctx.credentials());
|
|
213
|
+
if (!account)
|
|
214
|
+
return { check: { ok: false, message: NO_ACCOUNT } };
|
|
215
|
+
return poll(source, account, cursorOf(ctx.setting(CURSOR)));
|
|
216
|
+
},
|
|
217
|
+
start: {
|
|
218
|
+
on: ["account", "mailbox"],
|
|
219
|
+
async take(source, ctx) {
|
|
220
|
+
const account = (await ctx.credentials());
|
|
221
|
+
if (!account)
|
|
222
|
+
return { check: { ok: false, message: NO_ACCOUNT }, note: unchecked(source, ctx.why) };
|
|
223
|
+
return start(source, account, ctx.why);
|
|
224
|
+
},
|
|
225
|
+
unchecked,
|
|
226
|
+
},
|
|
227
|
+
title: (attrs) => `${attrs.from ?? ""} — ${attrs.subject ?? ""}`,
|
|
228
|
+
};
|
|
@@ -2,10 +2,8 @@ import { headersRefusal } from "./standard-webhooks.js";
|
|
|
2
2
|
type Headers = Record<string, string | string[] | undefined>;
|
|
3
3
|
export type Scheme = {
|
|
4
4
|
/** The header its signature comes in: a request that carries it, and no other header's, is checked by a scheme that
|
|
5
|
-
* names it
|
|
5
|
+
* names it. */
|
|
6
6
|
signatureHeader: string;
|
|
7
|
-
/** Its secret is the sender's own, given at the trigger's create and rotation, never one this server mints. */
|
|
8
|
-
givenSecret?: true;
|
|
9
7
|
/** How a sender signs under it, for the OpenAPI document. */
|
|
10
8
|
describe: string;
|
|
11
9
|
/** Why the headers alone are refused, before a byte of the body is read. */
|
|
@@ -49,7 +47,6 @@ export declare const SIGNATURE_SCHEMES: {
|
|
|
49
47
|
};
|
|
50
48
|
composio: {
|
|
51
49
|
signatureHeader: string;
|
|
52
|
-
givenSecret: true;
|
|
53
50
|
describe: string;
|
|
54
51
|
precheck: typeof headersRefusal;
|
|
55
52
|
verify: (key: string, headers: Headers, body: Buffer<ArrayBufferLike>, nowMs: number) => string | undefined;
|
|
@@ -62,13 +59,12 @@ export declare const SIGNATURE_SCHEMES: {
|
|
|
62
59
|
};
|
|
63
60
|
};
|
|
64
61
|
export type SchemeName = keyof typeof SIGNATURE_SCHEMES;
|
|
65
|
-
|
|
62
|
+
/** The schemes a webhook trigger's `signature` may name: every one but `composio`, a Composio trigger's. */
|
|
63
|
+
export declare const SCHEME_NAMES: readonly SchemeName[];
|
|
66
64
|
export declare const DEFAULT_SCHEME: SchemeName;
|
|
67
|
-
/** The scheme a request asks for: the one whose signature header it carries.
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* read, where the headers' check is the same for both) the first of them stands in. `refusal` when it carries no
|
|
71
|
-
* signature header, or the headers of more than one. */
|
|
65
|
+
/** The webhook scheme a request asks for: the one of SCHEME_NAMES whose signature header it carries. Were two to share a
|
|
66
|
+
* header, the trigger's own (`wanted`, its `signature`) would pick, and with no `wanted` (before the trigger is read) the
|
|
67
|
+
* first of them. `refusal` when it carries no signature header, or the headers of more than one. */
|
|
72
68
|
export declare function schemeOf(headers: Headers, wanted?: string): {
|
|
73
69
|
name: SchemeName;
|
|
74
70
|
scheme: Scheme;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
// The signature schemes
|
|
1
|
+
// The signature schemes, in one table: each names the header its signature comes in, checks a
|
|
2
2
|
// request's headers before its body is read, verifies the request under the trigger's secret, and reads the request's
|
|
3
3
|
// firing key (from what its signature covers, so a replay under a new id is the same firing) and its event (what a
|
|
4
|
-
// trigger's accept rules match). A request is checked by
|
|
5
|
-
//
|
|
6
|
-
//
|
|
4
|
+
// trigger's accept rules match). A webhook trigger's `signature` names one of SCHEME_NAMES, and its request is checked by
|
|
5
|
+
// the one of those whose signature header it carries. `composio` is a Composio trigger's alone (trigger-composio.ts
|
|
6
|
+
// checks the project's deliveries with it): a webhook trigger never takes it. A new webhook scheme is one entry here and
|
|
7
|
+
// its name in SCHEME_NAMES: the webhook source's schema and its check read that list.
|
|
7
8
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
8
9
|
import { HOOK_TOLERANCE_S, headersRefusal, HOOK_ID, MIN_KEY_BYTES, verify as verifyStandard, verifyWithKey } from "./standard-webhooks.js";
|
|
9
10
|
import { isObject } from "./validate.js";
|
|
@@ -70,14 +71,14 @@ export const SIGNATURE_SCHEMES = {
|
|
|
70
71
|
};
|
|
71
72
|
},
|
|
72
73
|
},
|
|
73
|
-
// Composio's (docs.composio.dev webhooks, @composio/core's verifyWebhook)
|
|
74
|
-
// ("{id}.{timestamp}.{body}", `v1,<base64 HMAC-SHA256>`), but keyed by the UTF-8
|
|
75
|
-
// Composio minted, not by a base64-decoded `whsec_` key.
|
|
76
|
-
// the event is the body's metadata.trigger_slug, and `where`
|
|
74
|
+
// Composio's (docs.composio.dev webhooks, @composio/core's verifyWebhook), for a Composio trigger's deliveries alone: the
|
|
75
|
+
// Standard Webhooks headers and message ("{id}.{timestamp}.{body}", `v1,<base64 HMAC-SHA256>`), but keyed by the UTF-8
|
|
76
|
+
// bytes of the whole secret string Composio minted for the project's subscription, not by a base64-decoded `whsec_` key.
|
|
77
|
+
// Every event of the project comes to its one route, so the event is the body's metadata.trigger_slug, and `where`
|
|
78
|
+
// reads the trigger's own data under /data.
|
|
77
79
|
composio: {
|
|
78
80
|
signatureHeader: "webhook-signature",
|
|
79
|
-
|
|
80
|
-
describe: `\`composio\` takes a Composio trigger's delivery (the webhook subscription whose URL is the trigger's hook_url): the Standard Webhooks headers and message, \`v1,<base64 HMAC-SHA256 of "{webhook-id}.{webhook-timestamp}.{body}">\`, keyed by the UTF-8 bytes of the whole secret string Composio gave the subscription (make the trigger first, register its hook_url as Composio's webhook subscription, then \`POST /v2/triggers/{id}/secret\` with \`{secret}\`; until then every request is refused, and this server never makes one), with the same ${HOOK_TOLERANCE_S} s window and firing key (\`webhook-id\`). Its event is the body's \`metadata.trigger_slug\` (\`GITHUB_ISSUE_ADDED_EVENT\`), else its top-level \`type\` (the subscription's account events, \`composio.connected_account.expired\`), and \`where\` pointers read the payload under \`/data\`.`,
|
|
81
|
+
describe: `\`composio\` takes a Composio project's delivery to a Composio trigger's route (/hooks/composio/{hook}): the Standard Webhooks headers and message, \`v1,<base64 HMAC-SHA256 of "{webhook-id}.{webhook-timestamp}.{body}">\`, keyed by the UTF-8 bytes of the whole secret string Composio made for the project's subscription (this server makes the subscription and keeps its secret sealed), with the same ${HOOK_TOLERANCE_S} s window and firing key (\`webhook-id\`). Its event is the body's \`metadata.trigger_slug\` (\`GITHUB_ISSUE_ADDED_EVENT\`), else its top-level \`type\` (the subscription's account events, \`composio.connected_account.expired\`), and \`where\` pointers read the payload under \`/data\`.`,
|
|
81
82
|
precheck: headersRefusal,
|
|
82
83
|
verify: (key, headers, body, nowMs) => verifyWithKey(Buffer.from(key, "utf8"), headers, body, nowMs),
|
|
83
84
|
firingKeyOf: (headers) => headers["webhook-id"],
|
|
@@ -98,13 +99,12 @@ export const SIGNATURE_SCHEMES = {
|
|
|
98
99
|
},
|
|
99
100
|
},
|
|
100
101
|
};
|
|
101
|
-
|
|
102
|
+
/** The schemes a webhook trigger's `signature` may name: every one but `composio`, a Composio trigger's. */
|
|
103
|
+
export const SCHEME_NAMES = ["standard", "github"];
|
|
102
104
|
export const DEFAULT_SCHEME = "standard";
|
|
103
|
-
/** The scheme a request asks for: the one whose signature header it carries.
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* read, where the headers' check is the same for both) the first of them stands in. `refusal` when it carries no
|
|
107
|
-
* signature header, or the headers of more than one. */
|
|
105
|
+
/** The webhook scheme a request asks for: the one of SCHEME_NAMES whose signature header it carries. Were two to share a
|
|
106
|
+
* header, the trigger's own (`wanted`, its `signature`) would pick, and with no `wanted` (before the trigger is read) the
|
|
107
|
+
* first of them. `refusal` when it carries no signature header, or the headers of more than one. */
|
|
108
108
|
export function schemeOf(headers, wanted) {
|
|
109
109
|
const carried = SCHEME_NAMES.filter((name) => headers[SIGNATURE_SCHEMES[name].signatureHeader] !== undefined);
|
|
110
110
|
const byHeader = new Set(carried.map((name) => SIGNATURE_SCHEMES[name].signatureHeader));
|
|
@@ -40,7 +40,7 @@ export type TriggerTargets = {
|
|
|
40
40
|
targetIssues(target: Target): Promise<InputIssue[]>;
|
|
41
41
|
start(target: Extract<Target, {
|
|
42
42
|
kind: "start_run";
|
|
43
|
-
}>, input: Json, origin: RunTrigger, from: MessageOrigin, title?: string): Promise<{
|
|
43
|
+
}>, input: Json, origin: RunTrigger, from: MessageOrigin, title?: string, previous?: boolean): Promise<{
|
|
44
44
|
run_id: string;
|
|
45
45
|
}>;
|
|
46
46
|
message(target: Extract<Target, {
|
package/dist/trigger-targets.js
CHANGED
|
@@ -61,13 +61,14 @@ export function triggerTargets(store, deps) {
|
|
|
61
61
|
const wrong = revision ? await deps.start.explainRun(await deps.start.inputIssuesOf(revision, target.input), { input: target.input }, revision) : [];
|
|
62
62
|
return [...uncapped, ...wrong.map((issue) => ({ ...issue, field: `target.${issue.field}` }))];
|
|
63
63
|
},
|
|
64
|
-
async start(target, given, trigger, from, title) {
|
|
64
|
+
async start(target, given, trigger, from, title, previous = true) {
|
|
65
65
|
const entry = await deps.needAgent(target.agent_id);
|
|
66
66
|
// An agentic run is handed its trigger's previous result after its message (previousResultOf), so a repeat run
|
|
67
67
|
// (a weekly digest) leaves out what the last one reported. A workflow's input is its own schema's: nothing is added.
|
|
68
|
+
// A source whose firings are different people's (an email's sender: its adapter's previousResult false) hands none.
|
|
68
69
|
const content = given.content;
|
|
69
|
-
const
|
|
70
|
-
const input =
|
|
70
|
+
const handed = previous && entry.revision?.kind === "agentic" && typeof content === "string" ? await previousResultOf(store, deps, trigger) : "";
|
|
71
|
+
const input = handed ? { ...given, content: `${content}${handed}` } : given;
|
|
71
72
|
// The target's cap, else the agent's default as it stands now: a run a trigger starts is never uncapped (capped).
|
|
72
73
|
const run = await startRun(store, deps.start, entry, { input, ...(target.max_cost_usd !== undefined ? { max_cost_usd: target.max_cost_usd } : {}), ...(target.effort ? { effort: target.effort } : {}) },
|
|
73
74
|
// Titled from the trigger (the engine's titleOf: "<Source> <name>"), never from its input, a sender's markup.
|
package/dist/trigger-webhook.js
CHANGED
|
@@ -12,12 +12,15 @@ import { isObject } from "./validate.js";
|
|
|
12
12
|
const ATTR_CHARS = 200;
|
|
13
13
|
/** The scheme a trigger's source takes. */
|
|
14
14
|
const schemeName = (source) => (typeof source.signature === "string" ? source.signature : DEFAULT_SCHEME);
|
|
15
|
-
/** Whether a source's secret is the sender's own (Composio's): given, not minted. */
|
|
16
|
-
const givesSecret = (source) => SIGNATURE_SCHEMES[schemeName(source)]?.givenSecret === true;
|
|
17
15
|
/** The source's own fields, checked: each issue through `bad`. Undefined when one does not read. */
|
|
18
16
|
function fieldsOf(value, bad) {
|
|
19
17
|
let failed = false;
|
|
20
|
-
if (value.signature
|
|
18
|
+
if (value.signature === "composio") {
|
|
19
|
+
// Composio's events start runs through a Composio trigger, whose project subscription this server makes and keeps.
|
|
20
|
+
failed = true;
|
|
21
|
+
bad("signature", "not_an_option", `A webhook trigger takes no composio signature: make a Composio trigger instead, in the console's Triggers → New app trigger (source kind "composio"). signature is one of ${SCHEME_NAMES.join(", ")} (default ${DEFAULT_SCHEME}).`);
|
|
22
|
+
}
|
|
23
|
+
else if (value.signature !== undefined && !SCHEME_NAMES.includes(value.signature)) {
|
|
21
24
|
failed = true;
|
|
22
25
|
bad("signature", "not_an_option", `signature is one of ${SCHEME_NAMES.join(", ")} (default ${DEFAULT_SCHEME})`);
|
|
23
26
|
}
|
|
@@ -40,7 +43,6 @@ export const webhook = {
|
|
|
40
43
|
delivery: "push",
|
|
41
44
|
owner: false,
|
|
42
45
|
settings: { scope: "trigger", fields: { secret: { mint: true, minBytes: MIN_KEY_BYTES } } },
|
|
43
|
-
givesSecret,
|
|
44
46
|
describe: `{kind: "webhook", signature?: ${SCHEME_NAMES.map((name) => `"${name}"`).join(" | ")}, accept?: [{event, actions?, where?}]}`,
|
|
45
47
|
fires: "a signed request to /hooks/{trigger_id} (`webhook`) that its `accept` takes",
|
|
46
48
|
firedBy: "`webhook`: a signed request to /hooks/{trigger_id}, its key from the trigger and what the request's signature covers: its `webhook-id` (`standard`), or the SHA-256 of its body (`github`).",
|
package/dist/triggers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type MessageOrigin } from "./timeline/index.js";
|
|
2
2
|
import { ApiError, type InputIssue } from "./errors.js";
|
|
3
3
|
import { type FiringRow, type Store } from "./store/index.js";
|
|
4
|
-
import { type Source, type TriggerAdapter } from "./trigger-adapter.js";
|
|
4
|
+
import { PAYLOAD_KEPT_BYTES, type Source, type TriggerAdapter } from "./trigger-adapter.js";
|
|
5
5
|
import { type Json } from "./validate.js";
|
|
6
6
|
export { MAX_EVERY_S, MIN_EVERY_S } from "./trigger-schedule.js";
|
|
7
7
|
/** The firings each trigger keeps in its history, newest first; a firing still due is never dropped, nor a failure whose
|
|
@@ -14,8 +14,8 @@ export declare const DUE_KEPT = 20;
|
|
|
14
14
|
export declare const SOURCE_KINDS: readonly string[];
|
|
15
15
|
export declare const TARGET_KINDS: readonly ["start_run", "message_run"];
|
|
16
16
|
export declare const FIRING_STATUSES: readonly ["due", "started", "sent", "skipped", "failed", "missed"];
|
|
17
|
-
/** The most of a webhook's payload a firing passes on: the rest is cut, at a character's start. */
|
|
18
|
-
export
|
|
17
|
+
/** The most of a webhook's payload a firing passes on: the rest is cut, at a character's start (trigger-adapter.ts). */
|
|
18
|
+
export { PAYLOAD_KEPT_BYTES };
|
|
19
19
|
/** How late a missed time may be and still fire once, by default: an hour. */
|
|
20
20
|
export declare const CATCHUP_WINDOW_S = 3600;
|
|
21
21
|
/** The failed tries in a row that turn a trigger off. */
|
|
@@ -30,6 +30,30 @@ export declare const WAIT_POLL_MS = 500;
|
|
|
30
30
|
export declare const SEEN_KEPT = 5000;
|
|
31
31
|
/** The highest max_active_runs a trigger may set (the store's CHECK holds the same). */
|
|
32
32
|
export declare const MAX_ACTIVE_RUNS = 100;
|
|
33
|
+
/** A polled source's trigger setting its last check is kept in (TriggerAdapter.poll), with the sign-ins refused in a row. */
|
|
34
|
+
export declare const LAST_CHECK = "last_check";
|
|
35
|
+
/** The sign-ins a polled source's server refuses in a row that turn its trigger off. */
|
|
36
|
+
export declare const REFUSALS_TO_STOP = 3;
|
|
37
|
+
/** How long a trigger's create, edit or turn-on waits for its source's start (trigger-adapter.ts `start`): one not taken
|
|
38
|
+
* by then is taken at its first check. */
|
|
39
|
+
export declare const START_WAIT_MS = 10000;
|
|
40
|
+
/** What a source's sender keeps of a trigger, set up from here (composio-triggers.ts: Composio's trigger instance): made
|
|
41
|
+
* before the trigger is kept and undone when it is not, kept in step as the owner turns the trigger on and off (and as
|
|
42
|
+
* the server turns it off itself: offThere), removed after it. What it could not do there is answered beside the change (`said`, by its source's name: `{composio: {done:
|
|
43
|
+
* false, note}}`), and the change here holds. */
|
|
44
|
+
export type TriggerUpstream = {
|
|
45
|
+
/** A trigger `id` of `source` being made (on or not): what it needs there made, then `keep` (the trigger's save here)
|
|
46
|
+
* given the source to keep, with what was made named in it; what `keep` answers is answered. When `keep` throws, what
|
|
47
|
+
* was made is undone and its refusal thrown. Throws the refusal when it can't be made. */
|
|
48
|
+
make<T>(source: Source, id: string, enabled: boolean, keep: (source: Source) => Promise<T>): Promise<T>;
|
|
49
|
+
/** A PATCH's source for the trigger that keeps `was`: the source to keep, or the refusal (thrown) of a change to what
|
|
50
|
+
* was made there. */
|
|
51
|
+
patched(was: Source, given: Source): Source;
|
|
52
|
+
/** The trigger `id` of `source`, turned on or off here: the same there. */
|
|
53
|
+
turned(source: Source, id: string, on: boolean): Promise<Json | undefined>;
|
|
54
|
+
/** The trigger `id` of `source`, deleted here: removed there. */
|
|
55
|
+
removed(source: Source, id: string): Promise<Json | undefined>;
|
|
56
|
+
};
|
|
33
57
|
/** `max_cost_usd`: each run's cap; absent, the agent's default as it stands when the firing starts (one of the two is
|
|
34
58
|
* required: server.ts targetIssues and start). */
|
|
35
59
|
export type Target = {
|
|
@@ -60,10 +84,13 @@ export type TriggerFailed = {
|
|
|
60
84
|
/** A run's provenance, kept with its launch row: the trigger that started it, and the firing. `name`: the trigger's name as
|
|
61
85
|
* it was at the firing, put on the run so its Timeline row names the trigger without a store read (runs.ts
|
|
62
86
|
* servedTriggerRow); a rename pushes the new name (server.ts triggerChanged). */
|
|
87
|
+
/** `attrs`: what its source said of the event that fired it (the firing's attrs, server-written), which the run's tools
|
|
88
|
+
* may read (an email's Message-ID: email/tools.ts reads the thread it started). */
|
|
63
89
|
export type RunTrigger = {
|
|
64
90
|
id: string;
|
|
65
91
|
firing_key: string;
|
|
66
92
|
name?: string;
|
|
93
|
+
attrs?: Record<string, string>;
|
|
67
94
|
};
|
|
68
95
|
/** The engine's clock and its one timer: Date.now and setTimeout, or a test's. */
|
|
69
96
|
export type TriggerClock = {
|
|
@@ -77,15 +104,18 @@ export type TriggerDeps = {
|
|
|
77
104
|
store: Pick<Store, "triggers" | "runs" | "agents">;
|
|
78
105
|
/** The refusal of a trigger of source `kind` made or turned on here, when it cannot be (the connection it needs is not
|
|
79
106
|
* there: GitHub not connected). Undefined, or no such dep, when it can. */
|
|
80
|
-
unavailable?(kind: string): ApiError | undefined
|
|
107
|
+
unavailable?(kind: string): ApiError | undefined | Promise<ApiError | undefined>;
|
|
108
|
+
/** A polled source's credentials, read as it polls (the email account, opened); undefined when there are none. */
|
|
109
|
+
credentials?(kind: string): Promise<unknown>;
|
|
81
110
|
/** What keeps a target from starting runs here, by field (its agent, its kind, its input). */
|
|
82
111
|
targetIssues(target: Target): Promise<InputIssue[]>;
|
|
83
112
|
/** Starts the target's run with `input`, as POST /agents/{id}/runs would, under `origin`, titled `title` (its
|
|
84
113
|
* trigger's, never its input's); its first message is the trigger's (`from`, never the person's); ApiError when
|
|
85
114
|
* refused. */
|
|
115
|
+
/** `previous` false: the run is handed no previous result (its adapter's previousResult). */
|
|
86
116
|
start(target: Extract<Target, {
|
|
87
117
|
kind: "start_run";
|
|
88
|
-
}>, input: Json, origin: RunTrigger, from: MessageOrigin, title: string): Promise<{
|
|
118
|
+
}>, input: Json, origin: RunTrigger, from: MessageOrigin, title: string, previous?: boolean): Promise<{
|
|
89
119
|
run_id: string;
|
|
90
120
|
}>;
|
|
91
121
|
/** Queues `input` for the target's run as a command row (answers false) under `key`, as the trigger's (`from`), within
|
|
@@ -105,6 +135,7 @@ export type TriggerDeps = {
|
|
|
105
135
|
mint(scope: string, field: string): Promise<string>;
|
|
106
136
|
set(scope: string, field: string, value: string, as?: "utf8"): Promise<void>;
|
|
107
137
|
remove(scope: string): Promise<void>;
|
|
138
|
+
get(scope: string, field: string): string | undefined;
|
|
108
139
|
} | undefined;
|
|
109
140
|
/** A run's status, or null when there is no such run. */
|
|
110
141
|
statusOf(runId: string): Promise<string | null>;
|
|
@@ -125,6 +156,8 @@ export type TriggerDeps = {
|
|
|
125
156
|
/** The address people and senders reach this server at (AGENTRUN_PUBLIC_URL), with no trailing slash: a pushed
|
|
126
157
|
* trigger's hook_url starts with it. None: the hook's path alone. */
|
|
127
158
|
publicUrl?: string;
|
|
159
|
+
/** What source `kind`'s sender keeps of its triggers, when it is set up from here (TriggerUpstream); none for the rest. */
|
|
160
|
+
upstream?(kind: string): TriggerUpstream | undefined;
|
|
128
161
|
};
|
|
129
162
|
export declare const firingKey: (by: string, triggerId: string, what: string) => string;
|
|
130
163
|
/** What is wrong with a POST /triggers body by itself, as create refuses it with the sources of `adapters`, all but the
|
|
@@ -148,6 +181,10 @@ export declare class Triggers {
|
|
|
148
181
|
private waiting;
|
|
149
182
|
/** The triggers whose day-kept keys are at their cap, said once until they are under it again. */
|
|
150
183
|
private readonly seenFull;
|
|
184
|
+
/** The polled triggers whose poll is running: one at a time each. */
|
|
185
|
+
private readonly polling;
|
|
186
|
+
/** Each polled trigger's count of starts taken (takeStart): a poll or a start that sees it changed keeps nothing. */
|
|
187
|
+
private readonly starts;
|
|
151
188
|
private closed;
|
|
152
189
|
constructor(deps: TriggerDeps);
|
|
153
190
|
/** At the server's start: every enabled trigger whose source no longer reads turned off, each failure's trigger.failed
|
|
@@ -187,6 +224,11 @@ export declare class Triggers {
|
|
|
187
224
|
message: string;
|
|
188
225
|
} | null;
|
|
189
226
|
} | null;
|
|
227
|
+
last_check?: {
|
|
228
|
+
at: string;
|
|
229
|
+
ok: boolean;
|
|
230
|
+
message: string;
|
|
231
|
+
} | null | undefined;
|
|
190
232
|
hook_url?: string | undefined;
|
|
191
233
|
}[];
|
|
192
234
|
}>;
|
|
@@ -221,6 +263,11 @@ export declare class Triggers {
|
|
|
221
263
|
message: string;
|
|
222
264
|
} | null;
|
|
223
265
|
} | null;
|
|
266
|
+
last_check?: {
|
|
267
|
+
at: string;
|
|
268
|
+
ok: boolean;
|
|
269
|
+
message: string;
|
|
270
|
+
} | null | undefined;
|
|
224
271
|
hook_url?: string | undefined;
|
|
225
272
|
}>;
|
|
226
273
|
firings(id: string): Promise<{
|
|
@@ -274,11 +321,15 @@ export declare class Triggers {
|
|
|
274
321
|
message: string;
|
|
275
322
|
} | null;
|
|
276
323
|
} | null;
|
|
324
|
+
last_check?: {
|
|
325
|
+
at: string;
|
|
326
|
+
ok: boolean;
|
|
327
|
+
message: string;
|
|
328
|
+
} | null | undefined;
|
|
277
329
|
hook_url?: string | undefined;
|
|
278
330
|
}>;
|
|
279
|
-
/** A trigger's new signing secret, shown this once; the old one signs nothing from now on.
|
|
280
|
-
|
|
281
|
-
rotate(id: string, given?: unknown): Promise<Record<string, string>>;
|
|
331
|
+
/** A trigger's new signing secret, shown this once; the old one signs nothing from now on. */
|
|
332
|
+
rotate(id: string): Promise<Record<string, string>>;
|
|
282
333
|
/** Whether `id` is a trigger of the pushed source `kind` that is on: the one a request delivered for `kind` may fire. */
|
|
283
334
|
hookable(id: string, kind: string): Promise<boolean>;
|
|
284
335
|
/** The source of trigger `id` when it is hookable: what its pushed source's check and parse read (its filter). With no
|
|
@@ -294,6 +345,14 @@ export declare class Triggers {
|
|
|
294
345
|
id: string;
|
|
295
346
|
source: Source;
|
|
296
347
|
}[]>;
|
|
348
|
+
/** Every trigger of source `kind`, on or off, with its name and source: what a source's sender keeps of them is shared
|
|
349
|
+
* between some (composio-triggers.ts: one Composio instance per server, event and config). */
|
|
350
|
+
ofKind(kind: string): Promise<{
|
|
351
|
+
id: string;
|
|
352
|
+
name: string;
|
|
353
|
+
enabled: boolean;
|
|
354
|
+
source: Source;
|
|
355
|
+
}[]>;
|
|
297
356
|
/** Every trigger of source `kind` that is on, turned off because the connection it needs is gone (`disabled: {reason:
|
|
298
357
|
* "connection_lost", detail}`), and said; how many. They are kept: on again once it is back. */
|
|
299
358
|
turnOff(kind: string, detail: string): Promise<number>;
|
|
@@ -367,9 +426,19 @@ export declare class Triggers {
|
|
|
367
426
|
message: string;
|
|
368
427
|
} | null;
|
|
369
428
|
} | null;
|
|
429
|
+
last_check?: {
|
|
430
|
+
at: string;
|
|
431
|
+
ok: boolean;
|
|
432
|
+
message: string;
|
|
433
|
+
} | null | undefined;
|
|
370
434
|
hook_url?: string | undefined;
|
|
371
435
|
}>;
|
|
372
|
-
|
|
436
|
+
/** Trigger `trigger`'s polled source started from now (its adapter's start, waited on at most START_WAIT_MS): its old
|
|
437
|
+
* cursor and last check forgotten, the start's cursor and check kept (no refusal counted), its note a skipped history
|
|
438
|
+
* line. A start not taken leaves no cursor, so its first poll takes it. Never throws: the create or edit stands. */
|
|
439
|
+
private takeStart;
|
|
440
|
+
/** The trigger deleted, and what its sender keeps of it removed after (said, when it could not be: the delete holds). */
|
|
441
|
+
remove(id: string): Promise<Json | undefined>;
|
|
373
442
|
/** Run now: one firing per Idempotency-Key, driven before the answer. `created` false: the key's firing, as it stands. */
|
|
374
443
|
fire(id: string, idempotencyKey: string): Promise<{
|
|
375
444
|
created: boolean;
|
|
@@ -388,6 +457,15 @@ export declare class Triggers {
|
|
|
388
457
|
* key), and every other is one `missed` row with their count. A one-time schedule, or one that never fires again, is
|
|
389
458
|
* turned off. */
|
|
390
459
|
private advance;
|
|
460
|
+
/** A polled source's time come: its next time moved on from the latest that has come (a time it was not there for is no
|
|
461
|
+
* `missed` row: what came meanwhile is still there to read), then its poll, after none still running for it, off the
|
|
462
|
+
* timer, so a slow server never holds the other triggers. */
|
|
463
|
+
private pollDue;
|
|
464
|
+
/** One poll of `trigger`'s source for its time `nominalAt`: each event it found recorded in order (its note a skipped
|
|
465
|
+
* history line; one it leaves, skipped and said; one its accept does not take, an ignored row kept for its day; any
|
|
466
|
+
* other due, and driven), its cursor kept once they are, then its last check, and at the REFUSALS_TO_STOPth refused
|
|
467
|
+
* sign-in in a row the trigger turned off. A poll that throws is a failed check. */
|
|
468
|
+
private polled;
|
|
391
469
|
/** A firing taken from due to its end: skipped when its trigger's last run is active, else its run started (or its
|
|
392
470
|
* message sent). A failed try keeps it due under the backoff table, or ends it failed. Each step reads the trigger and
|
|
393
471
|
* the firing again: either may be edited or deleted meanwhile. */
|
|
@@ -418,6 +496,13 @@ export declare class Triggers {
|
|
|
418
496
|
/** A failed firing: one more in its trigger's streak, the trigger turned off at FAILURES_TO_PAUSE, and trigger.failed
|
|
419
497
|
* queued (after the firing is written: a start finds one not yet queued and queues it, under the same webhook-id). */
|
|
420
498
|
private failed;
|
|
499
|
+
/** Trigger `triggerId`, turned off by its failure streak: off at its sender too (offThere). */
|
|
500
|
+
private pausedThere;
|
|
501
|
+
/** Triggers the server turned off itself (their agent archived, a failure streak, a connection or a run gone, a source
|
|
502
|
+
* that no longer reads): off at their sender too, as an owner's pause is, by its own rule (Composio's instance only
|
|
503
|
+
* once no trigger holding it is on). What could not be done there is said, with what to do by hand; the change here
|
|
504
|
+
* holds either way. */
|
|
505
|
+
private offThere;
|
|
421
506
|
private notifyFailed;
|
|
422
507
|
/** `firing` recorded for `trigger` (pruned first, so a key past its day is no longer known): `created` false and the
|
|
423
508
|
* key's firing as it stands when it is known. `room`: refused (429, retryable, nothing written) while the trigger holds
|