@parcha/agentrun-serve 0.1.0-beta.43 → 0.1.0-beta.45
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 +231 -0
- package/README.md +580 -320
- package/dist/acp-package.d.ts +28 -0
- package/dist/acp-package.js +23 -0
- package/dist/adapter-facts.d.ts +8 -1
- package/dist/adapter-facts.js +9 -1
- package/dist/adapters.d.ts +5 -0
- package/dist/adapters.js +36 -3
- package/dist/agent-delete.d.ts +50 -0
- package/dist/agent-delete.js +125 -0
- package/dist/agents-store.d.ts +9 -3
- package/dist/agents-store.js +22 -8
- package/dist/agents.d.ts +5 -1
- package/dist/agents.js +8 -4
- package/dist/api-only.d.ts +8 -3
- package/dist/api-only.js +10 -4
- package/dist/archil-routes.d.ts +5 -1
- package/dist/archil-routes.js +57 -2
- package/dist/browser-wait-ended.d.ts +2 -0
- package/dist/browser-wait-ended.js +2 -0
- package/dist/calendar/ics-faux.d.ts +3 -1
- package/dist/calendar/ics-faux.js +12 -2
- package/dist/calendar/tools.js +5 -2
- package/dist/chatgpt-plan.js +3 -1
- package/dist/claude-login.d.ts +135 -0
- package/dist/claude-login.js +244 -0
- package/dist/cli.js +92 -22
- package/dist/composio-preset.d.ts +4 -3
- package/dist/composio-preset.js +81 -11
- package/dist/composio-triggers.d.ts +34 -2
- package/dist/composio-triggers.js +261 -31
- package/dist/computer-attach.d.ts +40 -5
- package/dist/computer-attach.js +130 -15
- package/dist/computer-keys.d.ts +3 -0
- package/dist/computer-keys.js +7 -1
- package/dist/computer-live.js +3 -2
- package/dist/computer-lost.d.ts +11 -0
- package/dist/computer-lost.js +19 -0
- package/dist/computer-record.d.ts +10 -2
- package/dist/computer-record.js +50 -18
- package/dist/computer-setting.d.ts +1 -0
- package/dist/computer-setting.js +2 -2
- package/dist/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
- package/dist/console/assets/index-DaFsZuzQ.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/dial-relay.d.ts +29 -0
- package/dist/dial-relay.js +94 -0
- package/dist/email/tools.js +10 -5
- package/dist/env-proxy.d.ts +2 -0
- package/dist/env-proxy.js +35 -0
- package/dist/errors.d.ts +4 -1
- package/dist/errors.js +10 -4
- package/dist/faux-computers.d.ts +8 -2
- package/dist/faux-computers.js +83 -6
- package/dist/harness-archive.d.ts +67 -0
- package/dist/harness-archive.js +177 -0
- package/dist/harness-goose.d.ts +34 -0
- package/dist/harness-goose.js +87 -0
- package/dist/harness-install.d.ts +21 -0
- package/dist/harness-install.js +24 -11
- package/dist/harness-opencode/adapter.js +1 -1
- package/dist/harness-table.d.ts +59 -3
- package/dist/harness-table.js +119 -14
- package/dist/harness.d.ts +17 -1
- package/dist/harness.js +22 -11
- package/dist/host.d.ts +12 -10
- package/dist/host.js +19 -16
- package/dist/import-worker.d.ts +3 -0
- package/dist/import-worker.js +7 -5
- package/dist/import.d.ts +22 -1
- package/dist/import.js +141 -28
- package/dist/key-check.js +3 -0
- package/dist/learn/audit.d.ts +6 -6
- package/dist/learn/audit.js +3 -7
- package/dist/learn/check.d.ts +26 -89
- package/dist/learn/check.js +58 -336
- package/dist/learn/commit.d.ts +63 -90
- package/dist/learn/commit.js +124 -316
- package/dist/learn/compile.d.ts +53 -50
- package/dist/learn/compile.js +88 -103
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +17 -0
- package/dist/learn/delete.js +42 -0
- package/dist/learn/folder.d.ts +35 -47
- package/dist/learn/folder.js +118 -134
- package/dist/learn/index.d.ts +3 -5
- package/dist/learn/index.js +6 -9
- package/dist/learn/learning.sh +45 -15
- package/dist/learn/promote.d.ts +20 -2
- package/dist/learn/promote.js +17 -4
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +34 -38
- package/dist/learn/{skills.js → workflow-draft.js} +65 -59
- package/dist/learn/workflow-nodes.d.ts +22 -1
- package/dist/learn/workflow-nodes.js +29 -10
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +127 -13
- package/dist/learning-cost.js +142 -10
- package/dist/learning-routes.d.ts +99 -170
- package/dist/learning-routes.js +199 -420
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +4 -4
- package/dist/learning-setting.js +6 -6
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +62 -393
- package/dist/learning.js +101 -651
- package/dist/listen-first.d.ts +30 -0
- package/dist/listen-first.js +115 -0
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +2 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +16 -16
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +12 -4
- package/dist/model.js +41 -16
- package/dist/native/binding.js +1 -1
- package/dist/native/connection.js +1 -1
- package/dist/native/discovery.js +1 -1
- package/dist/native/instructions.d.ts +3 -0
- package/dist/native/instructions.js +5 -3
- package/dist/native/remote-worker-bridge.js +9 -43
- package/dist/native/remote.d.ts +8 -15
- package/dist/native/remote.js +3 -3
- package/dist/native/schema.js +1 -1
- package/dist/native/types.d.ts +2 -2
- package/dist/openapi.js +375 -347
- package/dist/owner.d.ts +8 -0
- package/dist/owner.js +11 -0
- package/dist/paid-calls.d.ts +14 -0
- package/dist/paid-calls.js +31 -1
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/place.d.ts +8 -3
- package/dist/place.js +13 -9
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +28 -11
- package/dist/print.d.ts +27 -0
- package/dist/print.js +21 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +30 -2
- package/dist/reflect-range.js +2 -3
- package/dist/run-launch.d.ts +14 -28
- package/dist/run-launch.js +9 -12
- package/dist/run-learning-served.d.ts +16 -90
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.d.ts +64 -0
- package/dist/run-model-key.js +147 -0
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-trace.d.ts +97 -0
- package/dist/run-trace.js +253 -0
- package/dist/run-view.d.ts +15 -0
- package/dist/run-view.js +9 -0
- package/dist/runnable.js +2 -1
- package/dist/runner/adapter-loop.d.ts +14 -6
- package/dist/runner/adapter-loop.js +25 -14
- package/dist/runner/adapter-run-spec.d.ts +22 -7
- package/dist/runner/adapter-run-spec.js +130 -77
- package/dist/runner/adapters/index.d.ts +4 -2
- package/dist/runner/adapters/index.js +35 -4
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +5 -1
- package/dist/runner/audit.js +31 -12
- package/dist/runner/beside.d.ts +7 -2
- package/dist/runner/beside.js +41 -9
- package/dist/runner/claim-secrets.d.ts +66 -1
- package/dist/runner/claim-secrets.js +136 -3
- package/dist/runner/cli-run-spec.d.ts +2 -1
- package/dist/runner/cli-run-spec.js +82 -59
- package/dist/runner/commands.d.ts +3 -6
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +16 -5
- package/dist/runner/dispatch.d.ts +2 -2
- package/dist/runner/end-of-run.d.ts +6 -14
- package/dist/runner/end-of-run.js +8 -33
- package/dist/runner/feedback-round.d.ts +5 -4
- package/dist/runner/feedback-round.js +14 -10
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +30 -56
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +7 -3
- package/dist/runner/journal-kinds.js +2 -3
- package/dist/runner/learned-first.d.ts +40 -0
- package/dist/runner/learned-first.js +32 -0
- package/dist/runner/learning-end.d.ts +77 -66
- package/dist/runner/learning-end.js +250 -299
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +8 -3
- package/dist/runner/loop-contract.js +4 -0
- package/dist/runner/loop.js +6 -2
- package/dist/runner/main.d.ts +18 -9
- package/dist/runner/main.js +82 -22
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +14 -6
- package/dist/runner/memory-claim.js +18 -9
- package/dist/runner/model-route.d.ts +7 -4
- package/dist/runner/model-route.js +22 -10
- package/dist/runner/native-loop.d.ts +0 -7
- package/dist/runner/native-loop.js +9 -101
- package/dist/runner/promotion.d.ts +13 -6
- package/dist/runner/promotion.js +63 -17
- package/dist/runner/reflect-hook.d.ts +64 -91
- package/dist/runner/reflect-hook.js +112 -206
- package/dist/runner/run-channel.d.ts +43 -0
- package/dist/runner/run-channel.js +467 -0
- package/dist/runner/run-child-host.d.ts +169 -0
- package/dist/runner/run-child-host.js +1222 -0
- package/dist/runner/run-child.d.ts +1 -0
- package/dist/runner/run-child.js +254 -0
- package/dist/runner/run-errors.d.ts +2 -0
- package/dist/runner/run-errors.js +20 -0
- package/dist/runner/runner.js +58 -9
- package/dist/runner/sdk-ask.d.ts +78 -0
- package/dist/runner/sdk-ask.js +158 -0
- package/dist/runner/sdk-loop.d.ts +2 -4
- package/dist/runner/sdk-loop.js +29 -49
- package/dist/runner/store-secrets.d.ts +5 -3
- package/dist/runner/store-secrets.js +14 -6
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +17 -4
- package/dist/runs-over-store.d.ts +21 -32
- package/dist/runs-over-store.js +44 -41
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/sdk/workflows.d.ts +1 -1
- package/dist/seal-key.d.ts +5 -0
- package/dist/seal-key.js +7 -0
- package/dist/secrets.d.ts +3 -0
- package/dist/secrets.js +16 -3
- package/dist/server.d.ts +119 -83
- package/dist/server.js +1121 -419
- package/dist/sign-ins-store.d.ts +8 -0
- package/dist/sign-ins-store.js +36 -1
- package/dist/skills.js +1 -1
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.js +3 -0
- package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
- package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
- package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
- package/dist/store/schema.d.ts +53 -4
- package/dist/store/schema.js +137 -6
- package/dist/store/seal.d.ts +20 -2
- package/dist/store/seal.js +24 -8
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-launch.d.ts +4 -1
- package/dist/store/sqlite/run-launch.js +12 -0
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.d.ts +3 -2
- package/dist/store/sqlite/store.js +360 -75
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +231 -39
- package/dist/store/store.js +25 -3
- package/dist/store-reads/analytics.js +11 -1
- package/dist/store-reads/learning.d.ts +131 -194
- package/dist/store-reads/learning.js +292 -301
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-reads/stats.js +13 -3
- package/dist/store-view.d.ts +34 -2
- package/dist/store-view.js +108 -41
- package/dist/telemetry.d.ts +59 -0
- package/dist/telemetry.js +153 -0
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +2 -1
- package/dist/templates.js +6 -3
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -1
- package/dist/timeline/timeline.js +16 -0
- package/dist/tool-gate.d.ts +0 -7
- package/dist/tool-gate.js +1 -15
- package/dist/tool-keys-store.d.ts +1 -1
- package/dist/tool-keys.d.ts +6 -4
- package/dist/tool-keys.js +12 -6
- package/dist/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +13 -13
- package/dist/tools.js +29 -9
- package/dist/trigger-adapter.d.ts +3 -0
- package/dist/trigger-adapters.d.ts +4 -0
- package/dist/trigger-adapters.js +13 -0
- package/dist/trigger-composio.d.ts +58 -1
- package/dist/trigger-composio.js +160 -6
- package/dist/triggers.d.ts +64 -5
- package/dist/triggers.js +141 -17
- package/dist/validate.d.ts +11 -7
- package/dist/validate.js +9 -8
- package/dist/webhooks.d.ts +4 -1
- package/dist/webhooks.js +11 -4
- package/dist/workspace/agent-computer.d.ts +2 -0
- package/dist/workspace/agent-computer.js +2 -0
- package/dist/workspace/archil-claim.d.ts +7 -0
- package/dist/workspace/archil-claim.js +29 -0
- package/dist/workspace/archil.d.ts +9 -1
- package/dist/workspace/archil.js +165 -3
- package/dist/workspace/attach.d.ts +3 -1
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/attached-computers.d.ts +16 -5
- package/dist/workspace/attached-computers.js +25 -9
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +22 -8
- package/dist/workspace/computer-for-claim.js +339 -46
- package/dist/workspace/computer-hold.js +2 -1
- package/dist/workspace/computer-kept.d.ts +11 -1
- package/dist/workspace/computer-kept.js +24 -3
- package/dist/workspace/resolve-computer.d.ts +41 -21
- package/dist/workspace/resolve-computer.js +172 -64
- package/dist/workspace/revision-skills.d.ts +1 -2
- package/dist/workspace/revision-skills.js +3 -4
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +5 -0
- package/dist/workspace/synced-folder.d.ts +85 -0
- package/dist/workspace/synced-folder.js +230 -0
- package/dist/workspace/workspace.d.ts +4 -0
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -9
- package/templates/README.md +7 -7
- package/templates/inbound-lead/agent.md +3 -3
- package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
- package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
- package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
- package/templates/inbound-lead/lead.schema.json +6 -5
- package/templates/inbound-lead/rules/RUBRIC.md +4 -4
- package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
- package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
- package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
- package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
- package/templates/release-notes/evals/learned-style/case.yaml +4 -4
- package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
- package/templates/release-notes/evals/learned-style/prompt.md +1 -1
- package/dist/console/assets/index-BrcDSBD8.css +0 -1
- package/dist/console/assets/index-Bz6IWncl.js +0 -711
- package/dist/learn/grade.d.ts +0 -138
- package/dist/learn/grade.js +0 -682
- package/dist/learn/notes.d.ts +0 -81
- package/dist/learn/notes.js +0 -178
- package/dist/learn/reflect.d.ts +0 -77
- package/dist/learn/reflect.js +0 -228
- package/dist/learn/relevance.d.ts +0 -24
- package/dist/learn/relevance.js +0 -91
- package/dist/learn/seed-check.d.ts +0 -74
- package/dist/learn/seed-check.js +0 -103
- package/dist/learning-batch.d.ts +0 -291
- package/dist/learning-batch.js +0 -600
- package/dist/learning-evals.d.ts +0 -33
- package/dist/learning-evals.js +0 -98
- package/dist/native/context.d.ts +0 -6
- package/dist/native/context.js +0 -22
- package/dist/propose.d.ts +0 -52
- package/dist/propose.js +0 -224
- package/dist/runner/learning-ask.d.ts +0 -47
- package/dist/runner/learning-ask.js +0 -128
- package/dist/runner/learning-dispatch.d.ts +0 -45
- package/dist/runner/learning-dispatch.js +0 -99
- package/dist/runner/learning-factory.d.ts +0 -16
- package/dist/runner/learning-factory.js +0 -50
- package/dist/runner/learning-loop.d.ts +0 -273
- package/dist/runner/learning-loop.js +0 -521
- package/dist/usage.d.ts +0 -11
- package/dist/usage.js +0 -11
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
package/dist/cli.js
CHANGED
|
@@ -10,22 +10,28 @@ import { spawn } from "node:child_process";
|
|
|
10
10
|
import { accessSync, chmodSync, constants as fsConstants, statSync, writeFileSync } from "node:fs";
|
|
11
11
|
import { dirname, join, resolve } from "node:path";
|
|
12
12
|
import { defaultData, removeOwnRecord, SERVER_FILE, writeDurableSync } from "./server-fs.js";
|
|
13
|
-
import { startedWith } from "./adapters.js";
|
|
14
13
|
import { REPEAT_MS, stopOnSignals } from "./stop-signals.js";
|
|
15
|
-
import { canOpen } from "./host.js";
|
|
16
14
|
import { resetPassword } from "./owner.js";
|
|
17
15
|
import { banner } from "./print.js";
|
|
18
16
|
import { parseTokens } from "./api-token.js";
|
|
19
|
-
import { DEFAULT_PORT, fauxEnvOf, startServe } from "./server.js";
|
|
20
|
-
import { besideRunnerOptions, besideStopping, runnerBeside } from "./runner/beside.js";
|
|
21
17
|
import { apiOnlyFrom } from "./api-only.js";
|
|
18
|
+
import { harnessModulesOf } from "./harness-table.js";
|
|
22
19
|
import { surviveClosedPipes } from "./closed-pipes.js";
|
|
20
|
+
import { installEnvProxy } from "./env-proxy.js";
|
|
21
|
+
import { startTelemetry } from "./telemetry.js";
|
|
22
|
+
// The rest of the server (server.js, the runner, the harness adapters) loads after the port is bound (listen-first.ts):
|
|
23
|
+
// on a slow disk that load is most of a start. Nothing above loads more than a few files.
|
|
24
|
+
import { DEFAULT_HOST, DEFAULT_PORT, listenFirst, urlOf } from "./listen-first.js";
|
|
23
25
|
// A stdout or stderr its reader closed loses the lines written after, never the process (closed-pipes.ts): for every
|
|
24
26
|
// command, the server and the runner alike.
|
|
25
27
|
surviveClosedPipes();
|
|
26
|
-
|
|
28
|
+
// Every outbound call through the proxy HTTPS_PROXY or HTTP_PROXY names, NO_PROXY's hosts and loopback direct
|
|
29
|
+
// (env-proxy.ts): for every command, before anything calls out. Neither set, nothing changes.
|
|
30
|
+
installEnvProxy();
|
|
31
|
+
const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--open] [--faux MODULE] [--faux-browser MODULE] [--faux-github] [--allow-host NAME ...] [--max-runs N] [--drain-timeout D] [--documents DIR] [--allow-code-nodes] [--learning on|off] [--no-runner] [--harness-module MODULE ...]
|
|
27
32
|
agentrun-serve reset-password [--data DIR]
|
|
28
33
|
agentrun-serve validate-template DIR
|
|
34
|
+
agentrun-serve install-harness goose [--data DIR]
|
|
29
35
|
agentrun-serve eval-template DIR [--case NAME ...] [--runs N] [--server URL | --on-data DIR] [--grader-model PROVIDER/MODEL] [--report FILE] [--faux MODULE]
|
|
30
36
|
agentrun-serve import [--data DIR] [--from claude-code,codex,pi] [--dry-run] [--include-deleted] [--all] [--verbose] [--port N]
|
|
31
37
|
agentrun-serve runner --data DIR [--loops N] [--drain-timeout D] [--name NAME]
|
|
@@ -57,11 +63,11 @@ const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--
|
|
|
57
63
|
resumes at the next start
|
|
58
64
|
--learning on|off whether runs learn (default on, or AGENTRUN_SERVE_LEARNING): on, a run of an agent whose definition
|
|
59
65
|
says learning: true starts from what that agent learned and adds to it; off, no run does
|
|
60
|
-
--
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
--harness-module MODULE
|
|
67
|
+
a harness module to add harnesses from (repeatable; default AGENTRUN_SERVE_HARNESS_MODULES, comma-
|
|
68
|
+
separated): a path, or a package installed with npm install --prefix DIR/harnesses PACKAGE, whose
|
|
69
|
+
entries(builtins) export adds harnesses of its own to this server and its runner. It never replaces
|
|
70
|
+
a built-in harness (pi, claude-agent, codex, opencode); one that does, or is missing, refuses the start
|
|
65
71
|
--no-runner run the server alone, with no runner beside it (default: one runner beside the server); start one or
|
|
66
72
|
more \`agentrun-serve runner --data DIR\` processes on the same data directory to claim and run runs;
|
|
67
73
|
each holds at most --loops N runs (default AGENTRUN_MAX_RUNS, else as many pi runs as its host's
|
|
@@ -83,6 +89,10 @@ AGENTRUN_FREE_MODEL_REQUESTS (default 60) is the most requests on free models ($
|
|
|
83
89
|
or not (ChatGPT-plan requests don't count): the next is not sent and the run fails, spend_cap_reached. stdout gets one line per request, per run start and
|
|
84
90
|
end, and per refused credential; AGENTRUN_LOG=quiet leaves out the request lines.
|
|
85
91
|
|
|
92
|
+
AGENTRUN_TELEMETRY=0 (or DO_NOT_TRACK=1) turns off the anonymous usage counts (docs/telemetry.md): a random id, the
|
|
93
|
+
version, the platform and how many runs as a range, never prompts, files or keys. Off in CI and under --faux too;
|
|
94
|
+
AGENTRUN_TELEMETRY=debug prints each event on stderr and sends none.
|
|
95
|
+
|
|
86
96
|
AGENTRUN_API_ONLY=1 serves the run routes alone, for a server behind its caller's backend: a run's launch, read, list,
|
|
87
97
|
timeline, messages, stop, cancel, kill and cap raise, its files and uploads, an agent's Archil disk, capabilities, health
|
|
88
98
|
and usage. Every other address (the page, sign-in, setup, settings, MCP, triggers and their hooks, the rest of agents)
|
|
@@ -145,6 +155,46 @@ if (process.argv[2] === "reset-password") {
|
|
|
145
155
|
console.log(`The password is cleared and every browser is signed out (${target}). The next visit to the page sets a new one.`);
|
|
146
156
|
process.exit(0);
|
|
147
157
|
}
|
|
158
|
+
// A harness its owner installs (harness-goose.ts: Goose, the one there is), never a run: its pinned archive downloaded,
|
|
159
|
+
// checked and unpacked into DIR/harnesses/<name> (harness-archive.ts). 0 once it is there (now or already), 1 when the
|
|
160
|
+
// install failed (its code and the command to try again), 2 for a name it does not install. No provider key is read.
|
|
161
|
+
if (process.argv[2] === "install-harness") {
|
|
162
|
+
const usage = (message) => (console.error(`agentrun-serve install-harness: ${message}\n\n${USAGE}`), process.exit(2));
|
|
163
|
+
const read = () => {
|
|
164
|
+
try {
|
|
165
|
+
return parseArgs({ args: process.argv.slice(3), options: { data: { type: "string" } }, allowPositionals: true });
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
return usage(error.message);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
const { values, positionals } = read();
|
|
172
|
+
const { GOOSE_ID, installGoose } = await import("./harness-goose.js");
|
|
173
|
+
if (positionals.length !== 1)
|
|
174
|
+
usage(`it takes one harness: ${GOOSE_ID}.`);
|
|
175
|
+
if (positionals[0] !== GOOSE_ID)
|
|
176
|
+
usage(`it installs ${GOOSE_ID}, not ${positionals[0]}: claude-agent and codex install on first use, and pi and opencode come with AgentRun.`);
|
|
177
|
+
const [{ ArchiveInstallFailed }, { acpPackage, ACP_PACKAGE }] = await Promise.all([import("./harness-archive.js"), import("./acp-package.js")]);
|
|
178
|
+
if (!acpPackage()) {
|
|
179
|
+
console.error(`Goose's adapter (${ACP_PACKAGE}) is not installed beside this server, so it has no pinned release to install.`);
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
const data = resolve(values.data ?? defaultData());
|
|
183
|
+
try {
|
|
184
|
+
const said = { downloaded: "the archive is downloaded and its sha256 matches the pin", unpacked: "unpacked", verified: "the binary's sha256 matches the pin" };
|
|
185
|
+
const { version, installed, binary } = await installGoose(data, { onStep: (step) => console.error(`Goose: ${said[step]}`) });
|
|
186
|
+
console.log(installed === "already"
|
|
187
|
+
? `Goose ${version} is installed in ${dirname(binary)} (already: the pinned binary is there, so nothing was downloaded).`
|
|
188
|
+
: `Goose ${version} is installed in ${dirname(binary)} (now). Restart AgentRun to pick it up.`);
|
|
189
|
+
process.exit(0);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
if (!(error instanceof ArchiveInstallFailed))
|
|
193
|
+
throw error;
|
|
194
|
+
console.error(error.message);
|
|
195
|
+
process.exit(1);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
148
198
|
// A template package folder checked by the one validator the server runs on the packages it ships (templates.ts): what
|
|
149
199
|
// it holds as one JSON line and 0, or each problem and 1. Nothing in the package runs.
|
|
150
200
|
if (process.argv[2] === "validate-template") {
|
|
@@ -290,9 +340,8 @@ try {
|
|
|
290
340
|
documents: { type: "string" },
|
|
291
341
|
"allow-code-nodes": { type: "boolean", default: false },
|
|
292
342
|
learning: { type: "string" },
|
|
293
|
-
"grade-model": { type: "string" },
|
|
294
|
-
"learning-budget": { type: "string" },
|
|
295
343
|
"no-runner": { type: "boolean", default: false },
|
|
344
|
+
"harness-module": { type: "string", multiple: true, default: [] },
|
|
296
345
|
help: { type: "boolean", short: "h", default: false },
|
|
297
346
|
},
|
|
298
347
|
}));
|
|
@@ -330,11 +379,6 @@ if (values["faux-github"] && !values.faux) {
|
|
|
330
379
|
console.error(`--faux-github goes with --faux\n\n${USAGE}`);
|
|
331
380
|
process.exit(2);
|
|
332
381
|
}
|
|
333
|
-
const budget = values["learning-budget"];
|
|
334
|
-
if (budget !== undefined && !/^\d+$/.test(budget)) {
|
|
335
|
-
console.error(`--learning-budget takes a whole number of bytes\n\n${USAGE}`);
|
|
336
|
-
process.exit(2);
|
|
337
|
-
}
|
|
338
382
|
const data = values.data ?? defaultData();
|
|
339
383
|
const given = secret("AGENTRUN_TOKEN") || undefined;
|
|
340
384
|
// More tokens, each with an id (api-token.ts), for a rotation with no caller refused; never printed. A list that cannot
|
|
@@ -373,6 +417,20 @@ catch (error) {
|
|
|
373
417
|
process.exit(2);
|
|
374
418
|
}
|
|
375
419
|
const accounts = !apiOnly && process.env.AGENTRUN_ACCOUNTS !== "0";
|
|
420
|
+
// The address first (listen-first.ts): the port bound and named before the rest of the server loads, then answering that
|
|
421
|
+
// the server is warming until it takes the socket over. A port already taken is left to the start's own listen below,
|
|
422
|
+
// which waits for a server it replaces, as it always has: no early line then. The banner's "Open " line still means ready.
|
|
423
|
+
let early;
|
|
424
|
+
try {
|
|
425
|
+
early = await listenFirst({ host: values.listen ?? DEFAULT_HOST, port, data, env: process.env });
|
|
426
|
+
}
|
|
427
|
+
catch (error) {
|
|
428
|
+
console.error(`agentrun-serve: ${error.message}`);
|
|
429
|
+
process.exit(1);
|
|
430
|
+
}
|
|
431
|
+
if (early)
|
|
432
|
+
console.log(`Starting ${publicUrl ?? urlOf(early, values.listen ?? DEFAULT_HOST)}/ (warming: health says so and the API answers 503 until the server is ready)`);
|
|
433
|
+
const [{ fauxEnvOf, startServe }, { besideRunnerOptions, besideStopping, runnerBeside }, { startedWith }, { canOpen }] = await Promise.all([import("./server.js"), import("./runner/beside.js"), import("./adapters.js"), import("./host.js")]);
|
|
376
434
|
// How it was started, for the hints that start it again (adapters.ts npxLine): itself and its runs read it.
|
|
377
435
|
Object.assign(process.env, startedWith({ ...(values.port !== undefined ? { port: values.port } : {}), open: values.open === true }));
|
|
378
436
|
let serve;
|
|
@@ -386,9 +444,11 @@ try {
|
|
|
386
444
|
console.error(`agentrun-serve: ${error.message}`);
|
|
387
445
|
process.exit(1);
|
|
388
446
|
},
|
|
389
|
-
data, port, ...(values.port === undefined ? { nextFreePort: true } : {}), ...(values.listen ? { host: values.listen } : {}), ...(given ? { token: given } : {}), ...(givenList ? { tokens: givenList } : {}), ...(values.faux ? { faux: values.faux } : {}), ...(values["faux-browser"] ? { fauxBrowser: values["faux-browser"] } : {}), ...(values["faux-github"] ? { fauxGitHub: true } : {}), allowHosts: values["allow-host"],
|
|
447
|
+
data, port, ...(values.port === undefined ? { nextFreePort: true } : {}), ...(early ? { listener: early } : {}), ...(values.listen ? { host: values.listen } : {}), ...(given ? { token: given } : {}), ...(givenList ? { tokens: givenList } : {}), ...(values.faux ? { faux: values.faux } : {}), ...(values["faux-browser"] ? { fauxBrowser: values["faux-browser"] } : {}), ...(values["faux-github"] ? { fauxGitHub: true } : {}), allowHosts: values["allow-host"],
|
|
390
448
|
...(values["max-runs"] !== undefined ? { maxRuns: Number(values["max-runs"]) } : {}),
|
|
391
|
-
|
|
449
|
+
// The owner's harness modules: --harness-module, else AGENTRUN_SERVE_HARNESS_MODULES (harness-table.ts).
|
|
450
|
+
...(harnessModulesOf(values["harness-module"], process.env).length ? { harnessModules: harnessModulesOf(values["harness-module"], process.env) } : {}),
|
|
451
|
+
...(values["drain-timeout"] ? { drainTimeout: values["drain-timeout"] } : {}), ...(values.documents ? { documents: values.documents } : {}), ...(values["allow-code-nodes"] ? { allowCodeNodes: true } : {}), ...(values.learning !== undefined ? { learning: values.learning } : {}), log: (line) => void process.stdout.write(`${line}\n`),
|
|
392
452
|
// The public address is the server's with accounts on or off: the Host names it serves, the webhook URLs it gives.
|
|
393
453
|
...(publicUrl ? { publicUrl } : {}),
|
|
394
454
|
...(accounts ? { accounts, openSetup: !publicUrl, countSessions: true } : {}), ...(apiOnly ? { apiOnly } : {}),
|
|
@@ -396,6 +456,8 @@ try {
|
|
|
396
456
|
...(trustedProxies.length ? { trustedProxies } : {}),
|
|
397
457
|
// A local install only as its operator says, never inferred: an MCP server on loopback is refused without it.
|
|
398
458
|
...(process.env.AGENTRUN_MCP_ALLOW_LOOPBACK === "1" ? { mcpLoopback: true } : {}),
|
|
459
|
+
// No runner beside this server: a paired computer's socket stays here, where no run reaches it, which the pairing says.
|
|
460
|
+
...(values["no-runner"] ? { runnerApart: true } : {}),
|
|
399
461
|
});
|
|
400
462
|
}
|
|
401
463
|
catch (error) {
|
|
@@ -408,7 +470,10 @@ catch (error) {
|
|
|
408
470
|
// (besideRunnerOptions): at most --max-runs runs at once, the rest waiting queued, and on the stop each busy run finishes
|
|
409
471
|
// its turn for up to --drain-timeout.
|
|
410
472
|
let runnerProc;
|
|
411
|
-
|
|
473
|
+
// Anonymous usage counts (telemetry.ts, docs/telemetry.md): off with AGENTRUN_TELEMETRY=0 or DO_NOT_TRACK=1, in CI and
|
|
474
|
+
// under --faux. It hears each run's end from the runner beside the server; with --no-runner it counts no runs.
|
|
475
|
+
const telemetry = startTelemetry({ data: resolve(data), ...(values.faux ? { faux: true } : {}) });
|
|
476
|
+
const { loops, loopsTold, drainMs } = besideRunnerOptions(serveOptions, process.env);
|
|
412
477
|
// A stop asked during the server's start starts no runner: nothing is claimed for the stop to cut.
|
|
413
478
|
if (!values["no-runner"] && askedAt === undefined) {
|
|
414
479
|
try {
|
|
@@ -421,7 +486,8 @@ if (!values["no-runner"] && askedAt === undefined) {
|
|
|
421
486
|
// server's AttachHub: a paired computer's socket is in this process, so only this runner takes one (--no-runner's
|
|
422
487
|
// separate runners refuse it in words). Its runs reach an MCP server on loopback only when this server is a local
|
|
423
488
|
// install (Serve.localInstall).
|
|
424
|
-
|
|
489
|
+
// Each run a process of its own, as a user of its own where the image's helper can switch (run-child-host.ts).
|
|
490
|
+
runnerProc = await runnerBeside(data, { loops, loopsTold, drainMs, env: besideRunEnv(process.env, fauxEnvOf(serveOptions)), janitor: true, ownProcesses: true, hub: serve.attachHub, dial: serve.dial, mcpLoopback: serve.localInstall, mcpOwn: serve.own, onRunEnded: telemetry.runEnded });
|
|
425
491
|
}
|
|
426
492
|
catch (error) {
|
|
427
493
|
console.error(`agentrun-serve: the runner could not start: ${error.message}`);
|
|
@@ -437,6 +503,9 @@ for (const line of banner({ url: serve.url, baseUrl: serve.baseUrl, data, token:
|
|
|
437
503
|
// setup link with its code as the code was made (owner.ts).
|
|
438
504
|
if (serve.setupUrl && serve.setupOpen)
|
|
439
505
|
console.log(`Set your password: ${serve.setupUrl} (the first visit sets it)`);
|
|
506
|
+
// The notice of the anonymous counts, once, on stderr: the npx command passes stderr through and keeps stdout to itself.
|
|
507
|
+
if (telemetry.notice)
|
|
508
|
+
console.error(telemetry.notice);
|
|
440
509
|
// The console's page, once the server listens: never its sign-in link, whose token would sit in the opener's arguments
|
|
441
510
|
// and the browser's history.
|
|
442
511
|
// API-only: there is no console, so nothing to open.
|
|
@@ -454,7 +523,8 @@ const stop = stopOnSignals({
|
|
|
454
523
|
const busy = runnerProc?.runner.held().length ?? 0;
|
|
455
524
|
if (busy > 0 && drainMs > 0)
|
|
456
525
|
console.error(`agentrun-serve: stopping: waiting up to ${Math.ceil(drainMs / 1000)} s for ${busy} ${busy === 1 ? "run" : "runs"} to finish ${busy === 1 ? "its turn" : "their turns"}`);
|
|
457
|
-
|
|
526
|
+
// The counts' last write (telemetry.ts) is waited for once the runner has said its last run's end.
|
|
527
|
+
return Promise.all([(runnerProc?.close() ?? Promise.resolve()).then(() => telemetry.close()), serve.close()]).then(() => undefined);
|
|
458
528
|
},
|
|
459
529
|
// The stop's deadline waits out the runner's whole close: its drain, then the stop of the loops left, so a run's end
|
|
460
530
|
// and release are never cut short (besideStopping).
|
|
@@ -14,9 +14,10 @@ export type ComposioTool = {
|
|
|
14
14
|
};
|
|
15
15
|
/** A Composio call (asking): its JSON answer, or the refusal in words that name its step. */
|
|
16
16
|
export type Ask = (step: string, method: "GET" | "POST" | "PATCH" | "DELETE", path: string, body?: unknown, missing?: string) => Promise<Json>;
|
|
17
|
-
/** A Composio call as `key`: its JSON answer, or an error in words that name `step` and never the key
|
|
18
|
-
* `outcome`, what the failure left (a save's: nothing was saved).
|
|
19
|
-
|
|
17
|
+
/** A Composio call as `key`: its JSON answer, or an error in words that name `step` and never the key nor a `sealed`
|
|
18
|
+
* value (a trigger's sealed config), and end with `outcome`, what the failure left (a save's: nothing was saved). A call
|
|
19
|
+
* with sealed values in play passes on none of Composio's words. */
|
|
20
|
+
export declare function asking(control: ComposioControl, key: string, signal: AbortSignal | undefined, outcome?: string, sealed?: readonly string[]): Ask;
|
|
20
21
|
/** POST /settings/mcp-servers/composio/tools: a toolkit's actions, for the console's picker, and whether it needs no sign-in. */
|
|
21
22
|
export declare function composioTools(body: unknown, control: ComposioControl, signal?: AbortSignal): Promise<{
|
|
22
23
|
toolkit: string;
|
package/dist/composio-preset.js
CHANGED
|
@@ -20,12 +20,18 @@ const MAX_TOOLS = 500;
|
|
|
20
20
|
const WAIT_MS = 20_000;
|
|
21
21
|
const text = (value) => (typeof value === "string" ? value : "");
|
|
22
22
|
const issue = (field, reason, message) => ({ field, reason, message });
|
|
23
|
-
/** A Composio call as `key`: its JSON answer, or an error in words that name `step` and never the key
|
|
24
|
-
* `outcome`, what the failure left (a save's: nothing was saved).
|
|
25
|
-
|
|
23
|
+
/** A Composio call as `key`: its JSON answer, or an error in words that name `step` and never the key nor a `sealed`
|
|
24
|
+
* value (a trigger's sealed config), and end with `outcome`, what the failure left (a save's: nothing was saved). A call
|
|
25
|
+
* with sealed values in play passes on none of Composio's words. */
|
|
26
|
+
export function asking(control, key, signal, outcome = "nothing was saved", sealed = []) {
|
|
26
27
|
const base = (control.baseUrl ?? BASE).replace(/\/+$/, "");
|
|
27
28
|
const send = control.fetch ?? fetch;
|
|
28
|
-
|
|
29
|
+
// Composio's words may quote what it was sent, as sent, JSON-escaped or percent-encoded. With a sealed value in play
|
|
30
|
+
// (`sealed`) none of its words go on, as no match is sure to find every form of it; otherwise they go on with the key
|
|
31
|
+
// out in each of those forms.
|
|
32
|
+
const withheld = sealed.some(Boolean);
|
|
33
|
+
const forms = [...new Set([key, JSON.stringify(key).slice(1, -1), encodeURIComponent(key)])].filter(Boolean).sort((a, b) => b.length - a.length);
|
|
34
|
+
const scrub = (said) => forms.reduce((text, form) => text.split(form).join("[the key]"), said).slice(0, 300);
|
|
29
35
|
return async (step, method, path, body, missing) => {
|
|
30
36
|
let res;
|
|
31
37
|
let raw;
|
|
@@ -59,6 +65,8 @@ export function asking(control, key, signal, outcome = "nothing was saved") {
|
|
|
59
65
|
throw invalid([issue("api_key", "refused", `Composio refused the API key while ${step}: check it in Composio's dashboard.`)]);
|
|
60
66
|
if (res.status === 404 && missing)
|
|
61
67
|
throw invalid([issue("toolkit", "not_found", missing)]);
|
|
68
|
+
if (res.status >= 400 && res.status < 500 && withheld)
|
|
69
|
+
throw invalid([issue("body", "refused", `Composio refused the request while ${step} (HTTP ${res.status}): ${outcome}. Its answer is withheld because the request carried a sealed value.`)]);
|
|
62
70
|
if (res.status >= 400 && res.status < 500)
|
|
63
71
|
throw invalid([issue("body", "refused", `Composio refused the request while ${step} (${res.status})${said ? `: ${scrub(said)}` : ""}.`)]);
|
|
64
72
|
throw new ApiError("upstream_failed", `Composio failed while ${step} (${res.status}): ${outcome}.`);
|
|
@@ -88,24 +96,71 @@ function needsNoAuth(kit) {
|
|
|
88
96
|
return modes.length > 0 && modes.every((mode) => mode === "NO_AUTH");
|
|
89
97
|
}
|
|
90
98
|
const notFound = (toolkit) => `Composio has no toolkit ${toolkit}: use its slug (github, slack, gmail...).`;
|
|
91
|
-
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const kit = await ask("reading the toolkit", "GET", `/api/v3/toolkits/${encodeURIComponent(toolkit)}`, undefined, notFound(toolkit));
|
|
99
|
+
/** A toolkit's actions, every page (at most MAX_PAGES), at its latest version: without toolkit_versions Composio lists its
|
|
100
|
+
* base version (00000000_00), which leaves out the actions added since (linear 21 of 48, stripe 33 of 435, live 11-18),
|
|
101
|
+
* though its MCP servers serve them. `complete`: the list ended within MAX_PAGES. */
|
|
102
|
+
async function toolkitTools(ask, toolkit) {
|
|
96
103
|
const tools = [];
|
|
97
104
|
let cursor;
|
|
98
105
|
for (let page = 0; page < MAX_PAGES; page++) {
|
|
99
|
-
const listed = await ask("listing the toolkit's actions", "GET", `/api/v3/tools?toolkit_slug=${encodeURIComponent(toolkit)}&limit=${PAGE}${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ""}`, undefined, notFound(toolkit));
|
|
106
|
+
const listed = await ask("listing the toolkit's actions", "GET", `/api/v3/tools?toolkit_slug=${encodeURIComponent(toolkit)}&toolkit_versions=latest&limit=${PAGE}${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ""}`, undefined, notFound(toolkit));
|
|
100
107
|
for (const item of Array.isArray(listed.items) ? listed.items : [])
|
|
101
108
|
if (isObject(item) && text(item.slug))
|
|
102
109
|
tools.push({ slug: text(item.slug), name: text(item.name) || text(item.slug), description: text(item.description) });
|
|
103
110
|
cursor = text(listed.next_cursor) || undefined;
|
|
104
111
|
if (!cursor)
|
|
105
|
-
|
|
112
|
+
return { tools, complete: true };
|
|
106
113
|
}
|
|
114
|
+
return { tools, complete: false };
|
|
115
|
+
}
|
|
116
|
+
/** POST /settings/mcp-servers/composio/tools: a toolkit's actions, for the console's picker, and whether it needs no sign-in. */
|
|
117
|
+
export async function composioTools(body, control, signal) {
|
|
118
|
+
const { key, toolkit } = head(body);
|
|
119
|
+
const ask = asking(control, key, signal);
|
|
120
|
+
const kit = await ask("reading the toolkit", "GET", `/api/v3/toolkits/${encodeURIComponent(toolkit)}`, undefined, notFound(toolkit));
|
|
121
|
+
const { tools } = await toolkitTools(ask, toolkit);
|
|
107
122
|
return { toolkit, no_auth: needsNoAuth(kit), tools };
|
|
108
123
|
}
|
|
124
|
+
/** Edit distance (Levenshtein). */
|
|
125
|
+
function distance(a, b) {
|
|
126
|
+
let prev = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
127
|
+
for (let i = 1; i <= a.length; i++) {
|
|
128
|
+
const row = [i];
|
|
129
|
+
for (let j = 1; j <= b.length; j++)
|
|
130
|
+
row[j] = Math.min(prev[j] + 1, row[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
131
|
+
prev = row;
|
|
132
|
+
}
|
|
133
|
+
return prev[b.length];
|
|
134
|
+
}
|
|
135
|
+
/** The listed slug a missing one most likely means, when one is obvious: the same slug in another case, the one listed
|
|
136
|
+
* slug that only adds or drops a trailing _WORD, else the one within a typo's reach (an edit distance of at most
|
|
137
|
+
* max(2, length/10)). */
|
|
138
|
+
function likelySlug(slug, listed) {
|
|
139
|
+
const want = slug.toUpperCase();
|
|
140
|
+
const same = listed.find((s) => s.toUpperCase() === want);
|
|
141
|
+
if (same)
|
|
142
|
+
return same;
|
|
143
|
+
const extended = listed.filter((s) => s.toUpperCase().startsWith(`${want}_`) || want.startsWith(`${s.toUpperCase()}_`)).sort((a, b) => a.length - b.length);
|
|
144
|
+
if (extended.length === 1 || (extended.length > 1 && extended[0].length < extended[1].length))
|
|
145
|
+
return extended[0];
|
|
146
|
+
const reach = Math.max(2, Math.floor(want.length / 10));
|
|
147
|
+
let best;
|
|
148
|
+
let tie = false;
|
|
149
|
+
for (const s of listed) {
|
|
150
|
+
// An edit distance is at least the length difference: a slug that far off is skipped before the O(n·m) distance, so a
|
|
151
|
+
// huge pasted value against a big toolkit costs one length compare per action.
|
|
152
|
+
if (Math.abs(s.length - want.length) > reach)
|
|
153
|
+
continue;
|
|
154
|
+
const d = distance(want, s.toUpperCase());
|
|
155
|
+
if (d > reach)
|
|
156
|
+
continue;
|
|
157
|
+
if (!best || d < best.d)
|
|
158
|
+
[best, tie] = [{ slug: s, d }, false];
|
|
159
|
+
else if (d === best.d)
|
|
160
|
+
tie = true;
|
|
161
|
+
}
|
|
162
|
+
return best && !tie ? best.slug : undefined;
|
|
163
|
+
}
|
|
109
164
|
/** The address Composio's generate answers, made one this server's client can use: the helper actions that connect an
|
|
110
165
|
* account left off, and the path ended in /mcp (Composio redirects the bare one, which the client refuses on purpose). */
|
|
111
166
|
export function composioAddress(generated) {
|
|
@@ -140,6 +195,21 @@ export async function composioSave(body, control, save, name, signal, savedUrl)
|
|
|
140
195
|
let url;
|
|
141
196
|
try {
|
|
142
197
|
const kit = await ask("reading the toolkit", "GET", `/api/v3/toolkits/${encodeURIComponent(toolkit)}`, undefined, notFound(toolkit));
|
|
198
|
+
// Every slug is one the toolkit lists (at its latest version), before anything is made: Composio makes a server
|
|
199
|
+
// allowing a slug it doesn't have, which then serves nothing under that name. A list longer than MAX_PAGES refuses
|
|
200
|
+
// nothing on what it didn't read; the check after the save (not_served) still names an action left out.
|
|
201
|
+
const offered = await toolkitTools(ask, toolkit);
|
|
202
|
+
const known = new Set(offered.tools.map((tool) => tool.slug));
|
|
203
|
+
const unknown = offered.complete ? [...new Set(tools)].filter((slug) => !known.has(slug)) : [];
|
|
204
|
+
if (unknown.length) {
|
|
205
|
+
// A slug past 128 characters is named by its first 64 and its length, so the refusal never carries a pasted megabyte back.
|
|
206
|
+
const names = unknown.map((slug) => {
|
|
207
|
+
const likely = likelySlug(slug, [...known]);
|
|
208
|
+
const shown = slug.length > 128 ? `${slug.slice(0, 64)}… (${slug.length} characters)` : slug;
|
|
209
|
+
return likely ? `${shown} (did you mean ${likely}?)` : shown;
|
|
210
|
+
});
|
|
211
|
+
throw invalid([issue("tools", "not_found", `Composio's ${toolkit} toolkit has no action ${names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} or ${names.at(-1)}`}: pick from its list (POST /settings/mcp-servers/composio/tools). Nothing was saved.`)]);
|
|
212
|
+
}
|
|
143
213
|
const noAuth = needsNoAuth(kit);
|
|
144
214
|
let authConfig;
|
|
145
215
|
let madeConfig = false;
|
|
@@ -14,6 +14,7 @@ type Holder = {
|
|
|
14
14
|
name: string;
|
|
15
15
|
enabled: boolean;
|
|
16
16
|
source: Source;
|
|
17
|
+
updatedAt?: number;
|
|
17
18
|
};
|
|
18
19
|
type Sealed = {
|
|
19
20
|
get(scope: string, field: string): string | undefined;
|
|
@@ -34,7 +35,7 @@ export type ComposioTriggerDeps = {
|
|
|
34
35
|
signal?: AbortSignal;
|
|
35
36
|
say(fields: Record<string, string>): void;
|
|
36
37
|
};
|
|
37
|
-
/** An event of a toolkit as the console's form reads it. */
|
|
38
|
+
/** An event of a toolkit as the console's form reads it: `sealed`, the fields of its config a save seals. */
|
|
38
39
|
export type ComposioEvent = {
|
|
39
40
|
slug: string;
|
|
40
41
|
name: string;
|
|
@@ -42,6 +43,7 @@ export type ComposioEvent = {
|
|
|
42
43
|
instructions?: string;
|
|
43
44
|
config: Json;
|
|
44
45
|
polled: boolean;
|
|
46
|
+
sealed: string[];
|
|
45
47
|
};
|
|
46
48
|
export declare class ComposioTriggers implements TriggerUpstream {
|
|
47
49
|
private readonly deps;
|
|
@@ -49,9 +51,23 @@ export declare class ComposioTriggers implements TriggerUpstream {
|
|
|
49
51
|
private readonly queues;
|
|
50
52
|
constructor(deps: ComposioTriggerDeps);
|
|
51
53
|
make<T>(source: Source, id: string, enabled: boolean, keep: (source: Source) => Promise<T>): Promise<T>;
|
|
54
|
+
/** A source sent whole again for trigger `id` (`was`), as an apply with agent_id sends its package's, its credentials in
|
|
55
|
+
* the clear: each sealed field whose value it sends is the value sealed (compared in constant time) is left out, so the
|
|
56
|
+
* PATCH keeps it (patched); then patched's own check, so another value, or any other change to the config, is refused
|
|
57
|
+
* here, before the caller writes anything, in patched's words (none holds a value). The answer is the source to PATCH
|
|
58
|
+
* the trigger with: no sealed value is in it. */
|
|
59
|
+
resent(was: Source, id: string, given: Source): Source;
|
|
52
60
|
patched(was: Source, given: Source): Source;
|
|
53
61
|
turned(source: Source, id: string, on: boolean): Promise<Json | undefined>;
|
|
54
62
|
removed(source: Source, id: string): Promise<Json | undefined>;
|
|
63
|
+
removedThere(source: Source, id: string, here: () => Promise<void>): Promise<Json | undefined>;
|
|
64
|
+
forgotten(source: Source, id: string): Promise<void>;
|
|
65
|
+
/** The trigger `id`'s instance on Composio deleted, or turned off while other triggers hold it (none of them on), or
|
|
66
|
+
* kept (one of them on): undefined when that is done, else what is left there, said. `values`: its sealed config's,
|
|
67
|
+
* withheld from Composio's words. `here`, once that is done, in the same step of the project's: the trigger's delete
|
|
68
|
+
* here, so the next removal of a trigger sharing the instance reads the holders without it (two removals at once
|
|
69
|
+
* never each keep the instance for the other); its refusal is thrown, never said as Composio's. */
|
|
70
|
+
private leftThere;
|
|
55
71
|
/** GET /settings/mcp-servers/{name}/composio/events: its toolkit's events, every page. */
|
|
56
72
|
events(name: string): Promise<{
|
|
57
73
|
server: string;
|
|
@@ -85,6 +101,19 @@ export declare class ComposioTriggers implements TriggerUpstream {
|
|
|
85
101
|
/** The triggers that use saved server `name`: a server that has any is not deleted, nor saved off what they stand on
|
|
86
102
|
* (`then`: what to do once they are gone), refused, naming them. */
|
|
87
103
|
inUse(name: string, then?: string): Promise<void>;
|
|
104
|
+
/** At the server's start: each composio trigger kept with a credential of its config in the clear (made before the
|
|
105
|
+
* config was sealed) sealed now, its source rewritten (`rewrite`) as an answer shows it (shownSource: the mask in its
|
|
106
|
+
* place), and said with the trigger's id and the fields' names alone. Composio's instance is left as it is: it already
|
|
107
|
+
* holds the value. One that can't be sealed is said, still answered masked, and left for the next start. A trigger
|
|
108
|
+
* with nothing in the clear is passed over, so a second start does nothing. */
|
|
109
|
+
sealKept(rewrite: (id: string, source: Source) => Promise<void>): Promise<number>;
|
|
110
|
+
/** After the server's start, never holding it up: each composio trigger an earlier server kept with a value in the clear
|
|
111
|
+
* in a field only its event's schema marks (format: password, writeOnly: sealedSchemaFields; the name rule is
|
|
112
|
+
* sealKept's) sealed, as sealKept seals one. Each event's schema is read once from Composio with its server's key, its
|
|
113
|
+
* words withheld when the server's triggers hold sealed values. When a read fails (Composio down), that is said once,
|
|
114
|
+
* by a code, and those triggers are left for the next start. The rewrites run inside `around` (the store's
|
|
115
|
+
* secureRewrite), once, and only when there is one to make. */
|
|
116
|
+
sealMarked(rewrite: (id: string, source: Source, updatedAt: number | undefined, read: Source) => Promise<boolean>, around: (work: () => Promise<number>) => Promise<unknown>): Promise<void>;
|
|
88
117
|
/** `step` run once the steps queued before it for the project of key `key` are done (failed or not), and before any
|
|
89
118
|
* queued after it. The key is digested, never kept as it is. */
|
|
90
119
|
private serial;
|
|
@@ -95,7 +124,10 @@ export declare class ComposioTriggers implements TriggerUpstream {
|
|
|
95
124
|
private leftWith;
|
|
96
125
|
/** Instance `instance` deleted on Composio or turned off, as `left` says; Composio's 404 to the delete: already gone. */
|
|
97
126
|
private leave;
|
|
98
|
-
/**
|
|
127
|
+
/** The sealed config values `holders` keep here: what Composio may quote back about their instance. */
|
|
128
|
+
private sealedValues;
|
|
129
|
+
/** Composio asked with the server's key; a failure's words end with what it left (`outcome`), and pass on none of
|
|
130
|
+
* Composio's own with a value of `sealed` (a trigger's sealed config) in play. */
|
|
99
131
|
private ask;
|
|
100
132
|
private addressOf;
|
|
101
133
|
/** The hook an address's path names (/v2/hooks/composio/{hook}), whatever its origin. */
|