@parcha/agentrun-serve 0.1.0-beta.56 → 0.1.0-beta.58
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 +281 -0
- package/README.md +246 -66
- package/dist/acp-package.d.ts +2 -0
- package/dist/adapters.d.ts +15 -3
- package/dist/adapters.js +17 -6
- package/dist/agent-package.d.ts +3 -3
- package/dist/agent-package.js +17 -8
- package/dist/api-keys.d.ts +76 -0
- package/dist/api-keys.js +217 -0
- package/dist/api-only.d.ts +15 -5
- package/dist/api-only.js +32 -8
- package/dist/box-paths.d.ts +4 -3
- package/dist/box-paths.js +7 -4
- package/dist/browser-hold.d.ts +23 -0
- package/dist/browser-hold.js +48 -0
- package/dist/browser-person.d.ts +3 -0
- package/dist/browser-person.js +4 -1
- package/dist/chatgpt-plan.d.ts +18 -8
- package/dist/chatgpt-plan.js +91 -34
- package/dist/claude-login-token.d.ts +117 -0
- package/dist/claude-login-token.js +737 -0
- package/dist/claude-login.d.ts +120 -22
- package/dist/claude-login.js +347 -63
- package/dist/claude-sign-in.d.ts +17 -6
- package/dist/claude-sign-in.js +42 -39
- package/dist/cli.js +33 -10
- package/dist/composio-made.d.ts +4 -0
- package/dist/composio-made.js +4 -0
- package/dist/composio-preset.d.ts +43 -2
- package/dist/composio-preset.js +92 -4
- package/dist/computer-attach.d.ts +35 -17
- package/dist/computer-attach.js +301 -49
- package/dist/computer-held-routes.d.ts +5 -4
- package/dist/computer-held-routes.js +29 -8
- package/dist/computer-held.d.ts +6 -1
- package/dist/computer-held.js +14 -0
- package/dist/computer-record.js +4 -2
- package/dist/computer-viewer.js +4 -1
- package/dist/computers.d.ts +10 -10
- package/dist/computers.js +5 -5
- package/dist/console/assets/{backend-Boh7tC4i.js → backend-CSAWUqtZ.js} +19 -19
- package/dist/console/assets/index-Bwn1oTem.css +1 -0
- package/dist/console/assets/index-DPh29cyz.js +747 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +1 -1
- package/dist/dial-relay.d.ts +25 -4
- package/dist/dial-relay.js +129 -1
- package/dist/docker-host-addresses.d.ts +22 -11
- package/dist/docker-host-addresses.js +38 -26
- package/dist/env-switch.d.ts +8 -0
- package/dist/env-switch.js +31 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +56 -20
- package/dist/fal-price.js +400 -90
- package/dist/handed-values.d.ts +43 -1
- package/dist/handed-values.js +119 -2
- package/dist/harness-archive.d.ts +13 -10
- package/dist/harness-archive.js +60 -34
- package/dist/harness-check.d.ts +3 -1
- package/dist/harness-check.js +25 -46
- package/dist/harness-keys.d.ts +73 -27
- package/dist/harness-keys.js +194 -61
- package/dist/harness-recipe-entry.d.ts +8 -7
- package/dist/harness-recipe-entry.js +21 -32
- package/dist/harness-recipe.d.ts +38 -25
- package/dist/harness-recipe.js +49 -36
- package/dist/harness-sign-in.js +12 -23
- package/dist/harness-table.d.ts +10 -3
- package/dist/harness-table.js +26 -21
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +17 -5
- package/dist/hosted-search.d.ts +1 -1
- package/dist/hosted-search.js +1 -2
- package/dist/import-worker.d.ts +4 -2
- package/dist/import-worker.js +9 -2
- package/dist/in-flight.d.ts +26 -0
- package/dist/in-flight.js +52 -0
- package/dist/key-refusal.d.ts +9 -4
- package/dist/key-refusal.js +107 -25
- package/dist/learn/ledger.d.ts +170 -0
- package/dist/learn/ledger.js +218 -0
- package/dist/learn/promote.d.ts +3 -3
- package/dist/learn/promote.js +1 -1
- package/dist/learn/secrets.d.ts +13 -3
- package/dist/learn/secrets.js +118 -17
- package/dist/learning-cost.d.ts +28 -23
- package/dist/learning-cost.js +19 -23
- package/dist/link-check.js +1 -1
- package/dist/live-reach.d.ts +2 -0
- package/dist/live-reach.js +2 -0
- package/dist/llms.txt +1 -1
- package/dist/marketplace.d.ts +77 -0
- package/dist/marketplace.js +224 -0
- package/dist/mcp-api-only-origins.d.ts +35 -0
- package/dist/mcp-api-only-origins.js +57 -0
- package/dist/mcp-gateway.d.ts +7 -5
- package/dist/mcp-gateway.js +9 -12
- package/dist/mcp-secret-writes.js +5 -3
- package/dist/mcp-servers-store.d.ts +28 -6
- package/dist/mcp-servers-store.js +53 -4
- package/dist/media-duration.d.ts +3 -0
- package/dist/media-duration.js +90 -9
- package/dist/micro.d.ts +2 -0
- package/dist/micro.js +2 -0
- package/dist/model-form.d.ts +5 -4
- package/dist/model-form.js +11 -7
- package/dist/model.d.ts +10 -6
- package/dist/model.js +16 -11
- package/dist/monid.d.ts +14 -1
- package/dist/monid.js +103 -26
- package/dist/ollama-provider.d.ts +7 -1
- package/dist/ollama-provider.js +14 -2
- package/dist/openapi.js +210 -37
- package/dist/otel/genai.d.ts +65 -0
- package/dist/otel/genai.js +116 -0
- package/dist/otel/tracer.d.ts +55 -0
- package/dist/otel/tracer.js +308 -0
- package/dist/page.d.ts +2 -0
- package/dist/page.js +3 -1
- package/dist/paid-calls.d.ts +1 -32
- package/dist/paid-calls.js +4 -39
- package/dist/place-offers.d.ts +4 -0
- package/dist/place-offers.js +7 -4
- package/dist/provider.d.ts +11 -2
- package/dist/provider.js +59 -8
- package/dist/redact/match.d.ts +30 -3
- package/dist/redact/match.js +422 -41
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +11 -0
- package/dist/run-census.d.ts +67 -0
- package/dist/run-census.js +240 -0
- package/dist/run-computer.d.ts +6 -3
- package/dist/run-computer.js +4 -1
- package/dist/run-cut.d.ts +15 -6
- package/dist/run-cut.js +30 -9
- package/dist/run-files.d.ts +3 -0
- package/dist/run-files.js +3 -0
- package/dist/run-launch.d.ts +12 -1
- package/dist/run-launch.js +9 -10
- package/dist/run-learning-served.d.ts +4 -2
- package/dist/run-model-key.d.ts +8 -0
- package/dist/run-model-key.js +31 -1
- package/dist/run-reads-over-store.d.ts +24 -6
- package/dist/run-reads-over-store.js +67 -23
- package/dist/run-recordings.d.ts +5 -1
- package/dist/run-recordings.js +39 -14
- package/dist/run-timeline-served.d.ts +2 -0
- package/dist/run-timeline-served.js +2 -2
- package/dist/run-usage.d.ts +1 -0
- package/dist/run-view.d.ts +1 -2
- package/dist/run-view.js +2 -1
- package/dist/runnable.d.ts +10 -1
- package/dist/runnable.js +20 -8
- package/dist/runner/adapter-loop.d.ts +11 -0
- package/dist/runner/adapter-loop.js +58 -26
- package/dist/runner/adapter-run-spec.d.ts +55 -11
- package/dist/runner/adapter-run-spec.js +183 -52
- package/dist/runner/adapters/pi.js +25 -3
- package/dist/runner/beside.d.ts +9 -2
- package/dist/runner/beside.js +27 -9
- package/dist/runner/big-writes.js +1 -10
- package/dist/runner/claim-secrets.d.ts +27 -10
- package/dist/runner/claim-secrets.js +49 -22
- package/dist/runner/cli-run-spec.d.ts +6 -0
- package/dist/runner/cli-run-spec.js +97 -38
- package/dist/runner/computer-journal.d.ts +9 -1
- package/dist/runner/computer-journal.js +26 -0
- package/dist/runner/conformance/harness.js +1 -1
- package/dist/runner/feedback-round.js +3 -0
- package/dist/runner/harness-loops.d.ts +6 -5
- package/dist/runner/harness-loops.js +7 -7
- package/dist/runner/held.d.ts +24 -6
- package/dist/runner/journal-kinds.d.ts +5 -0
- package/dist/runner/journal-kinds.js +5 -0
- package/dist/runner/main.d.ts +11 -6
- package/dist/runner/main.js +19 -9
- package/dist/runner/mcp-claim.js +31 -3
- package/dist/runner/mcp-run.d.ts +9 -0
- package/dist/runner/mcp-run.js +11 -5
- package/dist/runner/model-route.d.ts +17 -0
- package/dist/runner/model-route.js +120 -2
- package/dist/runner/presence.d.ts +11 -1
- package/dist/runner/presence.js +7 -0
- package/dist/runner/reflect-hook.js +1 -1
- package/dist/runner/run-child-host.d.ts +22 -8
- package/dist/runner/run-child-host.js +128 -41
- package/dist/runner/run-child.js +5 -2
- package/dist/runner/runner.d.ts +17 -3
- package/dist/runner/runner.js +130 -34
- package/dist/runner/save-slots.js +2 -1
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +6 -0
- package/dist/runner/store-secrets.js +49 -7
- package/dist/runner/subagent.d.ts +11 -0
- package/dist/runner/subagent.js +16 -38
- package/dist/runner/workflow-first.d.ts +35 -15
- package/dist/runner/workflow-first.js +38 -25
- package/dist/runner/workflow-spec.js +4 -3
- package/dist/runs-over-store.d.ts +15 -6
- package/dist/runs-over-store.js +33 -21
- package/dist/scrub-command.d.ts +73 -0
- package/dist/scrub-command.js +307 -0
- package/dist/secret-cut.d.ts +73 -0
- package/dist/secret-cut.js +291 -4
- package/dist/secret-rules.d.ts +143 -0
- package/dist/secret-rules.js +2564 -0
- package/dist/secrets.d.ts +7 -0
- package/dist/secrets.js +20 -0
- package/dist/server-keys.d.ts +20 -0
- package/dist/server-keys.js +25 -6
- package/dist/server.d.ts +65 -13
- package/dist/server.js +470 -157
- package/dist/skills/agentrun-serve/SKILL.md +4 -0
- package/dist/slots.d.ts +9 -0
- package/dist/slots.js +45 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +1 -1
- package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
- package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
- package/dist/store/schema.d.ts +23 -0
- package/dist/store/schema.js +58 -2
- package/dist/store/seal.d.ts +6 -1
- package/dist/store/seal.js +5 -3
- package/dist/store/sqlite/run-launch.d.ts +9 -1
- package/dist/store/sqlite/run-launch.js +24 -13
- package/dist/store/sqlite/run-patch.d.ts +12 -2
- package/dist/store/sqlite/run-patch.js +42 -5
- package/dist/store/sqlite/store.js +105 -12
- package/dist/store/store.d.ts +57 -2
- package/dist/store/store.js +20 -0
- package/dist/store-reads/learning.d.ts +84 -124
- package/dist/store-reads/learning.js +210 -274
- package/dist/store-view.d.ts +3 -0
- package/dist/store-view.js +3 -3
- package/dist/suggestions.js +3 -2
- package/dist/template-eval.d.ts +39 -9
- package/dist/template-eval.js +191 -60
- package/dist/template-import.js +6 -2
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +28 -8
- package/dist/timeline/labels.d.ts +6 -4
- package/dist/timeline/labels.js +18 -6
- package/dist/timeline/timeline.d.ts +5 -0
- package/dist/timeline/timeline.js +14 -8
- package/dist/timeline/util.js +1 -1
- package/dist/timeline/web-calls.d.ts +22 -7
- package/dist/timeline/web-calls.js +106 -35
- package/dist/tool-gate.d.ts +42 -3
- package/dist/tool-gate.js +66 -5
- package/dist/tool-keys-store.d.ts +2 -4
- package/dist/tool-keys-store.js +5 -21
- package/dist/tool-keys.d.ts +2 -2
- package/dist/tool-keys.js +2 -2
- package/dist/tool-list.js +1 -1
- package/dist/tool-plane.d.ts +2 -2
- package/dist/tool-plane.js +35 -33
- package/dist/tools.js +13 -7
- package/dist/trigger-targets.d.ts +4 -0
- package/dist/trigger-targets.js +9 -2
- package/dist/triggers.d.ts +67 -4
- package/dist/triggers.js +171 -22
- package/dist/until.d.ts +3 -0
- package/dist/until.js +11 -0
- package/dist/web-fake.d.ts +1 -3
- package/dist/web-fake.js +7 -18
- package/dist/web-fetch.d.ts +6 -72
- package/dist/web-fetch.js +11 -265
- package/dist/web-run.d.ts +31 -0
- package/dist/web-run.js +90 -0
- package/dist/web-save.d.ts +10 -13
- package/dist/web-save.js +13 -55
- package/dist/web-search.d.ts +9 -127
- package/dist/web-search.js +23 -259
- package/dist/wires.d.ts +13 -0
- package/dist/wires.js +11 -0
- package/dist/workflow-run.d.ts +5 -4
- package/dist/workflow-run.js +5 -4
- package/dist/workspace/attached-computers.d.ts +32 -9
- package/dist/workspace/attached-computers.js +77 -13
- package/dist/workspace/computer-deps.d.ts +8 -2
- package/dist/workspace/computer-deps.js +10 -3
- package/dist/workspace/computer-for-claim.d.ts +12 -1
- package/dist/workspace/computer-for-claim.js +83 -11
- package/dist/workspace/computer-kept.d.ts +3 -0
- package/dist/workspace/computer-kept.js +11 -2
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/kind-skills.d.ts +4 -0
- package/dist/workspace/kind-skills.js +9 -0
- package/dist/workspace/paired-route.d.ts +91 -0
- package/dist/workspace/paired-route.js +153 -0
- package/dist/workspace/synced-folder.js +3 -4
- package/dist/wrapped.d.ts +20 -6
- package/dist/wrapped.js +66 -25
- package/package.json +17 -11
- package/skills/agentrun-serve/SKILL.md +4 -0
- package/templates/README.md +32 -10
- package/dist/console/assets/index-CQ3cJRzI.js +0 -746
- package/dist/console/assets/index-DKkaS3a0.css +0 -1
- package/dist/exa-keyless.d.ts +0 -34
- package/dist/exa-keyless.js +0 -118
- package/dist/firecrawl-keyless.d.ts +0 -41
- package/dist/firecrawl-keyless.js +0 -152
- package/dist/keyless-mcp.d.ts +0 -36
- package/dist/keyless-mcp.js +0 -127
- package/dist/text-urls.d.ts +0 -38
- package/dist/text-urls.js +0 -170
- package/dist/web-fetch-direct.d.ts +0 -119
- package/dist/web-fetch-direct.js +0 -190
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// The marketplace's templates (GET /v2/marketplace/templates): marketplace.agentrun.ai lists every template package,
|
|
2
|
+
// Parcha's and the community's, and publishes that list as /search.json, the one its own pages are built beside. The
|
|
3
|
+
// console lists the packages this server ships and those imported here, then the marketplace's others, so the two show
|
|
4
|
+
// the same templates. This server reads the list only when asked (no read at its start, none in the background), keeps
|
|
5
|
+
// it 5 minutes (the site's own cache-control), and keeps the last good one when a read fails. Nothing on the list is
|
|
6
|
+
// imported or run: an entry is display data and, when it names one, the package source an install reads (POST
|
|
7
|
+
// /v2/templates/import, with its publisher trusted once). Off with AGENTRUN_MARKETPLACE=off, and under --faux unless
|
|
8
|
+
// AGENTRUN_MARKETPLACE names an address; an address there reads that site's list in place of marketplace.agentrun.ai's.
|
|
9
|
+
import { HARNESS_ID_PATTERN } from "./harness.js";
|
|
10
|
+
import { parseSource } from "./template-source.js";
|
|
11
|
+
import { CATEGORIES } from "./templates.js";
|
|
12
|
+
export const MARKETPLACE_URL = "https://marketplace.agentrun.ai";
|
|
13
|
+
export const MARKETPLACE_ENV = "AGENTRUN_MARKETPLACE";
|
|
14
|
+
/** How long a list read is answered before it is read again: the site's own cache-control (max-age=300). */
|
|
15
|
+
export const MARKETPLACE_TTL_MS = 5 * 60_000;
|
|
16
|
+
/** How long a failed read is answered before the next try, so a console open on an offline server asks the network
|
|
17
|
+
* once a minute, not on every page. */
|
|
18
|
+
export const MARKETPLACE_RETRY_MS = 60_000;
|
|
19
|
+
/** What one read may take: the list's bytes (today's is 68 KB), its entries, and the time the read may last. */
|
|
20
|
+
export const MARKETPLACE_LIMITS = { bytes: 4 << 20, entries: 1000, ms: 10_000 };
|
|
21
|
+
/** Where the packages this server ships live on GitHub, so a marketplace entry that names one is the bundled package. */
|
|
22
|
+
const BUNDLED_REPO = "parcha-ai/agentrun";
|
|
23
|
+
const BUNDLED_PATH = "packages/serve/templates/";
|
|
24
|
+
const NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
25
|
+
const TAG = /^[a-z0-9-]{1,32}$/;
|
|
26
|
+
const HARNESS = new RegExp(HARNESS_ID_PATTERN);
|
|
27
|
+
const MAX = { name: 64, title: 120, summary: 300, description: 2000, tags: 8, needs: 16, need: 200, harness: 8 };
|
|
28
|
+
const LOOPBACK = new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
29
|
+
/** The marketplace this server reads, from the environment: its address, or null for off. Unset, the public one, except
|
|
30
|
+
* under --faux (a test's or a demo's server, which reaches no network unasked). `off` (or 0, false) turns it off. An
|
|
31
|
+
* address is an https origin (with a path, when the site is served under one); http is taken for a loopback host
|
|
32
|
+
* alone, a local copy of the site. Anything else stops the start: the owner set it, and a typo should not read as off. */
|
|
33
|
+
export function marketplaceUrlOf(env, faux) {
|
|
34
|
+
const given = env[MARKETPLACE_ENV]?.trim();
|
|
35
|
+
if (!given)
|
|
36
|
+
return faux ? null : MARKETPLACE_URL;
|
|
37
|
+
if (/^(off|0|false|no)$/i.test(given))
|
|
38
|
+
return null;
|
|
39
|
+
let url;
|
|
40
|
+
try {
|
|
41
|
+
url = new URL(given);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
throw new Error(`${MARKETPLACE_ENV}=${given} is not an address: set it to the marketplace's https address (default ${MARKETPLACE_URL}), or to off.`);
|
|
45
|
+
}
|
|
46
|
+
const local = url.protocol === "http:" && LOOPBACK.has(url.hostname);
|
|
47
|
+
if ((url.protocol !== "https:" && !local) || url.username || url.password || url.search || url.hash) {
|
|
48
|
+
throw new Error(`${MARKETPLACE_ENV}=${given} is not one: the marketplace is read over https (http on a loopback host alone), with no user, query or fragment. Default ${MARKETPLACE_URL}; off turns it off.`);
|
|
49
|
+
}
|
|
50
|
+
return `${url.origin}${url.pathname.replace(/\/+$/, "")}`;
|
|
51
|
+
}
|
|
52
|
+
/** One line of text from the list: control characters made spaces, trimmed, and cut at `max`. Undefined for anything but
|
|
53
|
+
* a string with text in it. */
|
|
54
|
+
function line(value, max) {
|
|
55
|
+
if (typeof value !== "string")
|
|
56
|
+
return undefined;
|
|
57
|
+
const text = value.replace(/[\0-\x1f\x7f]+/g, " ").trim();
|
|
58
|
+
if (!text)
|
|
59
|
+
return undefined;
|
|
60
|
+
return text.length > max ? `${text.slice(0, max - 1).trimEnd()}…` : text;
|
|
61
|
+
}
|
|
62
|
+
/** One entry of the list read as a template, or undefined for one that is not (no name of a package's shape): an entry's
|
|
63
|
+
* other fields are kept where they are of their shape and dropped where not, so one odd field never hides a template. */
|
|
64
|
+
export function entryOf(raw, site) {
|
|
65
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
66
|
+
return undefined;
|
|
67
|
+
const e = raw;
|
|
68
|
+
if (typeof e.name !== "string" || e.name.length > MAX.name || !NAME.test(e.name))
|
|
69
|
+
return undefined;
|
|
70
|
+
const name = e.name;
|
|
71
|
+
const summary = line(e.summary, MAX.summary);
|
|
72
|
+
const description = line(e.description, MAX.description);
|
|
73
|
+
const category = typeof e.category === "string" && CATEGORIES.includes(e.category) ? e.category : undefined;
|
|
74
|
+
const tags = Array.isArray(e.tags) ? [...new Set(e.tags.filter((t) => typeof t === "string" && TAG.test(t)))].slice(0, MAX.tags) : [];
|
|
75
|
+
const needs = Array.isArray(e.needs) ? e.needs.map((n) => line(n, MAX.need)).filter((n) => !!n).slice(0, MAX.needs) : [];
|
|
76
|
+
// Its harnesses, in preference order: the ids of a harness's shape, each once. A list that says none leaves it out.
|
|
77
|
+
const harness = Array.isArray(e.harness) ? [...new Set(e.harness.filter((h) => typeof h === "string" && HARNESS.test(h)))].slice(0, MAX.harness) : undefined;
|
|
78
|
+
// Its page: the path the list gives, on the site itself; any other place, its page's usual one.
|
|
79
|
+
const usual = `${site}/templates/${name}/`;
|
|
80
|
+
let page_url = usual;
|
|
81
|
+
if (typeof e.url === "string" && e.url.startsWith("/") && !e.url.startsWith("//")) {
|
|
82
|
+
try {
|
|
83
|
+
const at = new URL(`${site}${e.url}`);
|
|
84
|
+
if (at.origin === new URL(site).origin)
|
|
85
|
+
page_url = at.href;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
page_url = usual;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Its source, kept as the list writes it (the commit it pins with it) when it reads as one: an install reads that.
|
|
92
|
+
let source;
|
|
93
|
+
if (typeof e.source === "string") {
|
|
94
|
+
try {
|
|
95
|
+
parseSource(e.source);
|
|
96
|
+
source = e.source.trim();
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
source = undefined;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
name, title: line(e.title, MAX.title) ?? name,
|
|
104
|
+
...(summary ? { summary } : {}), ...(description ? { description } : {}), ...(category ? { category } : {}),
|
|
105
|
+
tags, needs, ...(harness ? { harness } : {}), page_url, ...(source ? { source } : {}),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** The list's JSON read as templates, in its order, each name once (its first entry), at most MARKETPLACE_LIMITS.entries.
|
|
109
|
+
* Anything but a list is the read's failure. */
|
|
110
|
+
export function listOf(json, site) {
|
|
111
|
+
if (!Array.isArray(json))
|
|
112
|
+
throw new Error("The marketplace's list is not a list of templates.");
|
|
113
|
+
const seen = new Set();
|
|
114
|
+
const out = [];
|
|
115
|
+
for (const raw of json) {
|
|
116
|
+
const entry = entryOf(raw, site);
|
|
117
|
+
if (!entry || seen.has(entry.name))
|
|
118
|
+
continue;
|
|
119
|
+
seen.add(entry.name);
|
|
120
|
+
out.push(entry);
|
|
121
|
+
if (out.length >= MARKETPLACE_LIMITS.entries)
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
/** The package here that a marketplace entry is, by id: with a source, the package imported from it, else the bundled
|
|
127
|
+
* package of its name when the source is where this server's own packages live; with none (a list that names no
|
|
128
|
+
* sources), the package of its name, a bundled one first. */
|
|
129
|
+
export function hereOf(entry, packages) {
|
|
130
|
+
const bundled = packages.find((p) => p.origin === null && p.name === entry.name);
|
|
131
|
+
if (!entry.source)
|
|
132
|
+
return (bundled ?? packages.find((p) => p.name === entry.name))?.id;
|
|
133
|
+
const source = parseSource(entry.source);
|
|
134
|
+
const imported = packages.find((p) => p.origin !== null && p.id === source.id);
|
|
135
|
+
if (imported)
|
|
136
|
+
return imported.id;
|
|
137
|
+
return `${source.owner}/${source.repo}`.toLowerCase() === BUNDLED_REPO && source.path === `${BUNDLED_PATH}${entry.name}` ? bundled?.id : undefined;
|
|
138
|
+
}
|
|
139
|
+
/** The marketplace's list as this server reads it: on demand, kept MARKETPLACE_TTL_MS, one read at a time however many
|
|
140
|
+
* ask, and the last good list kept through a failed read. `fetchImpl`, `now` and `deadlineMs` (the read's time limit,
|
|
141
|
+
* MARKETPLACE_LIMITS.ms unless said) are a test's seams. */
|
|
142
|
+
export class Marketplace {
|
|
143
|
+
url;
|
|
144
|
+
#fetch;
|
|
145
|
+
#now;
|
|
146
|
+
#held;
|
|
147
|
+
#failed;
|
|
148
|
+
#reading;
|
|
149
|
+
#deadlineMs;
|
|
150
|
+
constructor(url, options = {}) {
|
|
151
|
+
this.url = url;
|
|
152
|
+
this.#fetch = options.fetchImpl ?? fetch;
|
|
153
|
+
this.#now = options.now ?? Date.now;
|
|
154
|
+
this.#deadlineMs = options.deadlineMs ?? MARKETPLACE_LIMITS.ms;
|
|
155
|
+
}
|
|
156
|
+
async list() {
|
|
157
|
+
if (!this.url)
|
|
158
|
+
return { url: null, state: "off", read_at: null, problem: `This server reads no marketplace (${MARKETPLACE_ENV}=off, or --faux with it unset).`, templates: [] };
|
|
159
|
+
const now = this.#now();
|
|
160
|
+
const held = this.#held;
|
|
161
|
+
const fresh = held && now - held.at < MARKETPLACE_TTL_MS;
|
|
162
|
+
const waiting = this.#failed && now - this.#failed.at < MARKETPLACE_RETRY_MS;
|
|
163
|
+
if (!fresh && !waiting) {
|
|
164
|
+
try {
|
|
165
|
+
this.#held = await (this.#reading ??= this.#read().finally(() => { this.#reading = undefined; }));
|
|
166
|
+
this.#failed = undefined;
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
this.#failed = { at: this.#now(), problem: error.message };
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const kept = this.#held;
|
|
173
|
+
const read_at = kept ? new Date(kept.at).toISOString() : null;
|
|
174
|
+
if (this.#failed)
|
|
175
|
+
return kept ? { url: this.url, state: "stale", read_at, problem: this.#failed.problem, templates: kept.templates } : { url: this.url, state: "unreachable", read_at: null, problem: this.#failed.problem, templates: [] };
|
|
176
|
+
return { url: this.url, state: "read", read_at, templates: kept?.templates ?? [] };
|
|
177
|
+
}
|
|
178
|
+
async #read() {
|
|
179
|
+
const at = `${this.url}/search.json`;
|
|
180
|
+
// One deadline for the whole read: the answer's headers and every byte of its body.
|
|
181
|
+
const signal = AbortSignal.timeout(this.#deadlineMs);
|
|
182
|
+
let res;
|
|
183
|
+
try {
|
|
184
|
+
res = await this.#fetch(at, { redirect: "manual", signal, headers: { accept: "application/json", "user-agent": "agentrun-serve" } });
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
throw new Error(signal.aborted ? `The marketplace (${this.url}) did not answer in ${this.#deadlineMs / 1000} s.` : `The marketplace (${this.url}) could not be reached: ${error.message}.`);
|
|
188
|
+
}
|
|
189
|
+
if (res.status >= 300 && res.status < 400) {
|
|
190
|
+
await res.body?.cancel();
|
|
191
|
+
throw new Error(`The marketplace (${this.url}) sent its list elsewhere (${res.status} to ${res.headers.get("location") ?? "nowhere"}): set ${MARKETPLACE_ENV} to the address it names.`);
|
|
192
|
+
}
|
|
193
|
+
if (res.status !== 200 || !res.body) {
|
|
194
|
+
await res.body?.cancel();
|
|
195
|
+
throw new Error(`The marketplace (${this.url}) answered ${res.status} for its list.`);
|
|
196
|
+
}
|
|
197
|
+
const declared = Number(res.headers.get("content-length"));
|
|
198
|
+
if (Number.isFinite(declared) && declared > MARKETPLACE_LIMITS.bytes) {
|
|
199
|
+
await res.body.cancel();
|
|
200
|
+
throw new Error(`The marketplace's list is ${declared} bytes, over the ${MARKETPLACE_LIMITS.bytes} this server reads.`);
|
|
201
|
+
}
|
|
202
|
+
const chunks = [];
|
|
203
|
+
let bytes = 0;
|
|
204
|
+
try {
|
|
205
|
+
for await (const chunk of res.body) {
|
|
206
|
+
bytes += chunk.byteLength;
|
|
207
|
+
if (bytes > MARKETPLACE_LIMITS.bytes)
|
|
208
|
+
throw new Error(`The marketplace's list is over the ${MARKETPLACE_LIMITS.bytes} bytes this server reads.`);
|
|
209
|
+
chunks.push(chunk);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
throw signal.aborted ? new Error(`The marketplace (${this.url}) did not finish its list in ${this.#deadlineMs / 1000} s.`) : error;
|
|
214
|
+
}
|
|
215
|
+
let json;
|
|
216
|
+
try {
|
|
217
|
+
json = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
throw new Error("The marketplace's list is not JSON.");
|
|
221
|
+
}
|
|
222
|
+
return { templates: listOf(json, this.url), at: this.#now() };
|
|
223
|
+
}
|
|
224
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { listMcpServers } from "./mcp-store.js";
|
|
2
|
+
/** The settings key the list is held under, as `{ origins: string[] }`. */
|
|
3
|
+
export declare const API_ONLY_MCP_ORIGINS_KEY = "mcp.api_only_origins";
|
|
4
|
+
type SettingsReader = {
|
|
5
|
+
settings: {
|
|
6
|
+
get(key: string): Promise<unknown>;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
type SettingsWriter = {
|
|
10
|
+
settings: {
|
|
11
|
+
put(key: string, value: unknown): Promise<void>;
|
|
12
|
+
remove(key: string): Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
/** Writes the list a server started with (`origins`, normalized) when it serves the API-only profile; removes it
|
|
16
|
+
* otherwise. */
|
|
17
|
+
export declare function holdApiOnlyMcpOrigins(store: SettingsWriter, apiOnly: boolean, origins: readonly string[]): Promise<void>;
|
|
18
|
+
/** The list the store holds, or undefined when it holds none (a full server's store). */
|
|
19
|
+
export declare function heldApiOnlyMcpOrigins(store: SettingsReader): Promise<readonly unknown[] | undefined>;
|
|
20
|
+
/** Why the saved server `name` (`row`) can't be used, or undefined when it can. It can't be used when it is a per_run
|
|
21
|
+
* server the API token saved, the store holds an API-only list, and its address's origin is not on that list. `held`:
|
|
22
|
+
* the list a caller already read (heldApiOnlyMcpOrigins); without it, the list is read here, for a per_run row alone.
|
|
23
|
+
* Undefined means "not read", never "none held": a caller passes the list only when the store holds one. */
|
|
24
|
+
export declare function offApiOnlyMcpOrigins(store: SettingsReader, name: string, row: {
|
|
25
|
+
auth: string;
|
|
26
|
+
url: string;
|
|
27
|
+
createdAt?: number;
|
|
28
|
+
}, held?: readonly unknown[]): Promise<string | undefined>;
|
|
29
|
+
/** The words a per_run server the token saved at an origin off the list is refused with (offApiOnlyMcpOrigins). */
|
|
30
|
+
export declare const offApiOnlyMcpOriginsWords: (name: string) => string;
|
|
31
|
+
/** The names of the saved servers offApiOnlyMcpOrigins refuses now, sorted: none when the store holds no list. What an
|
|
32
|
+
* API-only start says once in its log (server.ts), by name alone, never an address: on an upgrade with the setting
|
|
33
|
+
* unset, the only notice before a run that grants one fails. */
|
|
34
|
+
export declare function offApiOnlyMcpServers(store: SettingsReader & Parameters<typeof listMcpServers>[0]): Promise<string[]>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// The API-only MCP origin list (API_ONLY_MCP_ORIGINS_ENV), held in the store past the save: the serve README's API-only section.
|
|
2
|
+
import { mcpSourceKey, savedByToken } from "./mcp-sources.js";
|
|
3
|
+
import { listMcpServers } from "./mcp-store.js";
|
|
4
|
+
import { isObject } from "./validate.js";
|
|
5
|
+
/** The settings key the list is held under, as `{ origins: string[] }`. */
|
|
6
|
+
export const API_ONLY_MCP_ORIGINS_KEY = "mcp.api_only_origins";
|
|
7
|
+
/** Writes the list a server started with (`origins`, normalized) when it serves the API-only profile; removes it
|
|
8
|
+
* otherwise. */
|
|
9
|
+
export async function holdApiOnlyMcpOrigins(store, apiOnly, origins) {
|
|
10
|
+
if (apiOnly)
|
|
11
|
+
await store.settings.put(API_ONLY_MCP_ORIGINS_KEY, { origins: [...origins] });
|
|
12
|
+
else
|
|
13
|
+
await store.settings.remove(API_ONLY_MCP_ORIGINS_KEY);
|
|
14
|
+
}
|
|
15
|
+
/** The list the store holds, or undefined when it holds none (a full server's store). */
|
|
16
|
+
export async function heldApiOnlyMcpOrigins(store) {
|
|
17
|
+
const held = await store.settings.get(API_ONLY_MCP_ORIGINS_KEY);
|
|
18
|
+
return isObject(held) && Array.isArray(held.origins) ? held.origins : undefined;
|
|
19
|
+
}
|
|
20
|
+
/** Why the saved server `name` (`row`) can't be used, or undefined when it can. It can't be used when it is a per_run
|
|
21
|
+
* server the API token saved, the store holds an API-only list, and its address's origin is not on that list. `held`:
|
|
22
|
+
* the list a caller already read (heldApiOnlyMcpOrigins); without it, the list is read here, for a per_run row alone.
|
|
23
|
+
* Undefined means "not read", never "none held": a caller passes the list only when the store holds one. */
|
|
24
|
+
export async function offApiOnlyMcpOrigins(store, name, row, held) {
|
|
25
|
+
if (row.auth !== "per_run")
|
|
26
|
+
return undefined;
|
|
27
|
+
const origins = held ?? (await heldApiOnlyMcpOrigins(store));
|
|
28
|
+
if (!origins)
|
|
29
|
+
return undefined;
|
|
30
|
+
if (!savedByToken(await store.settings.get(mcpSourceKey(name)), row.createdAt))
|
|
31
|
+
return undefined;
|
|
32
|
+
let origin;
|
|
33
|
+
try {
|
|
34
|
+
origin = new URL(row.url).origin;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
origin = "";
|
|
38
|
+
}
|
|
39
|
+
if (origins.includes(origin))
|
|
40
|
+
return undefined;
|
|
41
|
+
return offApiOnlyMcpOriginsWords(name);
|
|
42
|
+
}
|
|
43
|
+
/** The words a per_run server the token saved at an origin off the list is refused with (offApiOnlyMcpOrigins). */
|
|
44
|
+
export const offApiOnlyMcpOriginsWords = (name) => `The MCP server ${name} can't be used: the API token saved it at an origin that is no longer on this server's AGENTRUN_API_ONLY_MCP_ORIGINS. Nothing was sent.`;
|
|
45
|
+
/** The names of the saved servers offApiOnlyMcpOrigins refuses now, sorted: none when the store holds no list. What an
|
|
46
|
+
* API-only start says once in its log (server.ts), by name alone, never an address: on an upgrade with the setting
|
|
47
|
+
* unset, the only notice before a run that grants one fails. */
|
|
48
|
+
export async function offApiOnlyMcpServers(store) {
|
|
49
|
+
const held = await heldApiOnlyMcpOrigins(store);
|
|
50
|
+
if (!held)
|
|
51
|
+
return [];
|
|
52
|
+
const off = [];
|
|
53
|
+
for (const row of await listMcpServers(store))
|
|
54
|
+
if (await offApiOnlyMcpOrigins(store, row.name, row, held))
|
|
55
|
+
off.push(row.name);
|
|
56
|
+
return off.sort();
|
|
57
|
+
}
|
package/dist/mcp-gateway.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { McpCallResult, McpTool } from "@parcha/agentrun-kernel";
|
|
2
|
-
import { type MediaReader } from "./fal-price.js";
|
|
2
|
+
import { type FalMeterName, type MediaReader } from "./fal-price.js";
|
|
3
3
|
import { type Workspace } from "./workspace/index.js";
|
|
4
4
|
/** The longest answer the model reads whole; past it, the rest is filed in the run's work/ as lines read pages through
|
|
5
5
|
* (filed-answer.ts). Within the host's result bound (HOST_RESULT_MAX_CHARS), so every harness passes it whole. */
|
|
@@ -13,7 +13,7 @@ export type McpPin = Record<string, {
|
|
|
13
13
|
url: string;
|
|
14
14
|
tools: McpTool[];
|
|
15
15
|
prices?: Record<string, number>;
|
|
16
|
-
meter?:
|
|
16
|
+
meter?: FalMeterName;
|
|
17
17
|
}>;
|
|
18
18
|
/** Each granted server's URL now, and its credential's headers when that URL is the pinned one (the claim step's). */
|
|
19
19
|
export type McpCredentials = Record<string, {
|
|
@@ -43,9 +43,11 @@ export type McpQuote = {
|
|
|
43
43
|
unpriceable?: string;
|
|
44
44
|
chargeOf(reply: Record<string, unknown> | undefined): number | null;
|
|
45
45
|
};
|
|
46
|
-
/** A server's keys scoped to the run (fal's submission keys, fal-price.ts falKeys): `
|
|
47
|
-
*
|
|
46
|
+
/** A server's keys scoped to the run (fal's submission keys, fal-price.ts falKeys): `refused`, why a call's keys can't
|
|
47
|
+
* be scoped (it is then refused unsent); `out`, a call's arguments as they leave; `back`, the text of its answer or error
|
|
48
|
+
* as the model reads it, each scoped key read as the agent's own. */
|
|
48
49
|
export type McpKeys = {
|
|
50
|
+
refused?(tool: string, args: Record<string, unknown>): string | undefined;
|
|
49
51
|
out(tool: string, args: Record<string, unknown>): Record<string, unknown>;
|
|
50
52
|
back(text: string): string;
|
|
51
53
|
};
|
|
@@ -105,7 +107,7 @@ export interface McpGatewayOptions {
|
|
|
105
107
|
* the runner's MCP claim step passes it: a github_app token whose App was disconnected or replaced. */
|
|
106
108
|
beforeCall?: (server: string, signal: AbortSignal) => Promise<void>;
|
|
107
109
|
/** Whether the run has a spend cap: under one, a metered call that cannot be priced is refused unsent. None: it has. */
|
|
108
|
-
capped?:
|
|
110
|
+
capped?: boolean;
|
|
109
111
|
/** Reads a metered job's input media, for one priced by its length. None: such a job cannot be priced. */
|
|
110
112
|
media?: MediaReader;
|
|
111
113
|
/** For tests: the clock a meter's prices are kept by. */
|
package/dist/mcp-gateway.js
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
import { randomUUID } from "node:crypto";
|
|
23
23
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
24
24
|
import { TOOL_UNMETERED } from "./timeline/index.js";
|
|
25
|
+
import { until } from "./until.js";
|
|
25
26
|
import { meterFor, meterNamed } from "./fal-price.js";
|
|
26
27
|
import { filedAnswer } from "./filed-answer.js";
|
|
27
28
|
import { paidLedger, paidStep } from "./paid-calls.js";
|
|
@@ -132,7 +133,7 @@ export function mcpPinOf(names, source) {
|
|
|
132
133
|
const declared = mcpHeaderProblem(tool.inputSchema);
|
|
133
134
|
if (declared)
|
|
134
135
|
throw new Error(`The MCP tool ${name} declares a header it cannot send: ${declared}.`);
|
|
135
|
-
const meter =
|
|
136
|
+
const meter = meterNamed(saved.url, saved.meter ?? saved.toolkit);
|
|
136
137
|
if (!Object.hasOwn(pin, parsed.server))
|
|
137
138
|
pin[parsed.server] = { url: saved.url, tools: [], ...(meter ? { meter } : {}) };
|
|
138
139
|
const pinned = pin[parsed.server];
|
|
@@ -185,14 +186,6 @@ function unreachable(error) {
|
|
|
185
186
|
return deepest;
|
|
186
187
|
}
|
|
187
188
|
const said = (text, isError = false) => ({ content: [{ type: "text", text }], ...(isError ? { isError: true } : {}) });
|
|
188
|
-
/** `work` until `signal` aborts: a connection shared by calls is never held by one that stopped. */
|
|
189
|
-
const until = (work, signal) => new Promise((resolve, reject) => {
|
|
190
|
-
if (signal.aborted)
|
|
191
|
-
return reject(signal.reason);
|
|
192
|
-
const stop = () => reject(signal.reason);
|
|
193
|
-
signal.addEventListener("abort", stop, { once: true });
|
|
194
|
-
work.then(resolve, reject).finally(() => signal.removeEventListener("abort", stop));
|
|
195
|
-
});
|
|
196
189
|
export function mcpGateway(options) {
|
|
197
190
|
/** Each server's client, with the account query it was connected with (`query`, JSON): a message that binds the run to
|
|
198
191
|
* another account connects again, so no session made as one account carries another's calls. */
|
|
@@ -426,6 +419,11 @@ export function mcpGateway(options) {
|
|
|
426
419
|
const why = unsendable(server, tool);
|
|
427
420
|
if (why)
|
|
428
421
|
return said(why, true);
|
|
422
|
+
// A key the server could not take once scoped to the run, refused before anything is priced or held.
|
|
423
|
+
const keys = meters.get(server)?.keys;
|
|
424
|
+
const keyless = keys?.refused?.(tool, args);
|
|
425
|
+
if (keyless)
|
|
426
|
+
return said(`${mcpToolName(server, tool)} was not sent: ${keyless}. Nothing was sent.`, true);
|
|
429
427
|
const { url, prices, tools: pinnedTools } = pins.get(server);
|
|
430
428
|
const listed = pinnedTools.find((t) => t.name === tool);
|
|
431
429
|
// Whether the call left for the server: only then is it booked, at its price or as not metered.
|
|
@@ -433,7 +431,6 @@ export function mcpGateway(options) {
|
|
|
433
431
|
let raw;
|
|
434
432
|
// The server's keys scoped to the run as the call leaves (fal's submission keys): its price is read from the call as
|
|
435
433
|
// the agent made it.
|
|
436
|
-
const keys = meters.get(server)?.keys;
|
|
437
434
|
const call = async (mark = async () => undefined) => {
|
|
438
435
|
const outcome = {};
|
|
439
436
|
const result = await forward(server, url, credentials.get(server)?.headers ?? {}, listed, keys ? keys.out(tool, args) : args, signal, async () => {
|
|
@@ -474,9 +471,9 @@ export function mcpGateway(options) {
|
|
|
474
471
|
return outcome.raw;
|
|
475
472
|
};
|
|
476
473
|
const quote = await meter.quote(tool, args, ask, signal);
|
|
477
|
-
if (quote.unpriceable && (options.capped
|
|
474
|
+
if (quote.unpriceable && (options.capped ?? true))
|
|
478
475
|
return said(`${name} was not sent: ${quote.unpriceable}, so a run with a spend cap can't send it. Nothing was sent.`, true);
|
|
479
|
-
// Settled by the server's reply; one that left and brought none back
|
|
476
|
+
// Settled by the server's reply; one that left and brought none back, at the meter's word for it (fal: its hold).
|
|
480
477
|
const stepped = await paidStep(onLedger, callId ?? name, { name, holdUsd: quote.holdUsd, basis: quote.basis, by: label.charged_by }, () => call(), () => (went ? quote.chargeOf(raw) : 0));
|
|
481
478
|
return "refused" in stepped ? said(stepped.refused, true) : stepped.result;
|
|
482
479
|
};
|
|
@@ -57,9 +57,11 @@ export const MCP_SECRET_OPERATIONS = ["saveMcpServer", "startMcpOAuth", "putMcpP
|
|
|
57
57
|
const STORED = { saveMcpServer: tokenWriteOverRefused, deleteMcpServer: tokenWriteOverRefused };
|
|
58
58
|
for (const operation of MCP_SECRET_OPERATIONS)
|
|
59
59
|
registerSecretWrite(operation, (body) => mcpWritesSecret(operation, body), STORED[operation]);
|
|
60
|
-
// The Composio preset takes the owner's API key and seals it as an MCP header:
|
|
61
|
-
// whatever the body (the
|
|
60
|
+
// The Composio preset takes the owner's API key and seals it as an MCP header: its routes are the owner's session alone,
|
|
61
|
+
// whatever the body (the listings, of a toolkit's actions and of the toolkits, send the key too, and only the session may
|
|
62
|
+
// type one).
|
|
62
63
|
registerSecretWrite("listComposioTools", () => true);
|
|
64
|
+
registerSecretWrite("listComposioToolkits", () => true);
|
|
63
65
|
registerSecretWrite("saveComposioServer", composioSaveSendsKey, composioSaveDropsSecret);
|
|
64
66
|
// A save's body that sends a key's value, or anything but api_key_env alone in its place: a secret written.
|
|
65
67
|
function composioSaveSendsKey(body) {
|
|
@@ -176,4 +178,4 @@ export const mcpSecretPage = (operation) => async (body, request) => {
|
|
|
176
178
|
};
|
|
177
179
|
for (const operation of ["saveMcpServer", "startMcpOAuth", "listComposioTools", "saveComposioServer"])
|
|
178
180
|
registerSecretPage(operation, mcpSecretPage(operation));
|
|
179
|
-
registerSecretPage(["putMcpPrivateHosts", "deleteMcpServer", "rotateComposioSecret", "deleteComposioSubscription"], MCP_PAGE);
|
|
181
|
+
registerSecretPage(["putMcpPrivateHosts", "deleteMcpServer", "rotateComposioSecret", "deleteComposioSubscription", "listComposioToolkits"], MCP_PAGE);
|
|
@@ -2,6 +2,7 @@ import { type Listed, type McpPrices, type McpTool } from "./mcp-probe.js";
|
|
|
2
2
|
import { type SecretMeta } from "./secret-writes.js";
|
|
3
3
|
import { type ClientKind, type OAuthNetwork } from "./mcp-oauth.js";
|
|
4
4
|
import { type Cleanup, COMPOSIO_KEY_ENV, type ComposioMade } from "./composio-made.js";
|
|
5
|
+
import { type ComposioAccount, type ComposioControl } from "./composio-preset.js";
|
|
5
6
|
import { type RecordedRow, type SourceRecord } from "./mcp-sources.js";
|
|
6
7
|
import { type ToolSettingsMap } from "./tool-plane.js";
|
|
7
8
|
import { type McpCredentialMark, type Mcp, type McpOauth, type McpServerRow, type Settings, type Store } from "./store/index.js";
|
|
@@ -137,6 +138,9 @@ export declare class McpServersOverStore {
|
|
|
137
138
|
}>;
|
|
138
139
|
list(): Promise<{
|
|
139
140
|
servers: {
|
|
141
|
+
composio_account?: (ComposioAccount & {
|
|
142
|
+
checked_at: string;
|
|
143
|
+
}) | undefined;
|
|
140
144
|
listed_at: string;
|
|
141
145
|
updated_at: string;
|
|
142
146
|
secret: SecretMeta;
|
|
@@ -151,7 +155,7 @@ export declare class McpServersOverStore {
|
|
|
151
155
|
headers?: string[] | undefined;
|
|
152
156
|
type: string;
|
|
153
157
|
};
|
|
154
|
-
credential: "
|
|
158
|
+
credential: "unreadable" | "sealed" | "expired" | null;
|
|
155
159
|
not_metered?: string[] | undefined;
|
|
156
160
|
tools: {
|
|
157
161
|
grant_problems?: Record<string, string>;
|
|
@@ -180,6 +184,9 @@ export declare class McpServersOverStore {
|
|
|
180
184
|
}[];
|
|
181
185
|
}>;
|
|
182
186
|
get(name: string): Promise<{
|
|
187
|
+
composio_account?: (ComposioAccount & {
|
|
188
|
+
checked_at: string;
|
|
189
|
+
}) | undefined;
|
|
183
190
|
listed_at: string;
|
|
184
191
|
updated_at: string;
|
|
185
192
|
secret: SecretMeta;
|
|
@@ -194,7 +201,7 @@ export declare class McpServersOverStore {
|
|
|
194
201
|
headers?: string[] | undefined;
|
|
195
202
|
type: string;
|
|
196
203
|
};
|
|
197
|
-
credential: "
|
|
204
|
+
credential: "unreadable" | "sealed" | "expired" | null;
|
|
198
205
|
not_metered?: string[] | undefined;
|
|
199
206
|
tools: {
|
|
200
207
|
grant_problems?: Record<string, string>;
|
|
@@ -256,6 +263,9 @@ export declare class McpServersOverStore {
|
|
|
256
263
|
* that row still carries the token's mark, compared in the row's own statement (412, nothing written, when an owner's
|
|
257
264
|
* save took it meanwhile). */
|
|
258
265
|
save(name: string, body: Record<string, unknown>, stop?: AbortSignal, checkedAgainst?: McpCredentialMark, made?: SourceRecord, stands?: ComposioMade, dropped?: (left: ComposioDropped) => void, guard?: SaveGuard, byToken?: boolean): Promise<{
|
|
266
|
+
composio_account?: (ComposioAccount & {
|
|
267
|
+
checked_at: string;
|
|
268
|
+
}) | undefined;
|
|
259
269
|
listed_at: string;
|
|
260
270
|
updated_at: string;
|
|
261
271
|
secret: SecretMeta;
|
|
@@ -270,7 +280,7 @@ export declare class McpServersOverStore {
|
|
|
270
280
|
headers?: string[] | undefined;
|
|
271
281
|
type: string;
|
|
272
282
|
};
|
|
273
|
-
credential: "
|
|
283
|
+
credential: "unreadable" | "sealed" | "expired" | null;
|
|
274
284
|
not_metered?: string[] | undefined;
|
|
275
285
|
tools: {
|
|
276
286
|
grant_problems?: Record<string, string>;
|
|
@@ -302,12 +312,16 @@ export declare class McpServersOverStore {
|
|
|
302
312
|
* save wrote between the two. One server holds a store (StoreOwned), so the turn is this process's. A delete takes
|
|
303
313
|
* none: its statement compares the mark itself (Mcp.removeIfCredential). */
|
|
304
314
|
private nameTurn;
|
|
305
|
-
/** POST refresh: list the saved server's tools again, keep them, and say what was added, removed and changed.
|
|
306
|
-
|
|
315
|
+
/** POST refresh: list the saved server's tools again, keep them, and say what was added, removed and changed. A
|
|
316
|
+
* Composio server's account is read again at Composio too (`composio`, where Composio is: checkAccount). */
|
|
317
|
+
refresh(name: string, stop?: AbortSignal, composio?: ComposioControl): Promise<{
|
|
307
318
|
added: string[];
|
|
308
319
|
removed: string[];
|
|
309
320
|
changed: string[];
|
|
310
321
|
server: {
|
|
322
|
+
composio_account?: (ComposioAccount & {
|
|
323
|
+
checked_at: string;
|
|
324
|
+
}) | undefined;
|
|
311
325
|
listed_at: string;
|
|
312
326
|
updated_at: string;
|
|
313
327
|
secret: SecretMeta;
|
|
@@ -322,7 +336,7 @@ export declare class McpServersOverStore {
|
|
|
322
336
|
headers?: string[] | undefined;
|
|
323
337
|
type: string;
|
|
324
338
|
};
|
|
325
|
-
credential: "
|
|
339
|
+
credential: "unreadable" | "sealed" | "expired" | null;
|
|
326
340
|
not_metered?: string[] | undefined;
|
|
327
341
|
tools: {
|
|
328
342
|
grant_problems?: Record<string, string>;
|
|
@@ -350,6 +364,14 @@ export declare class McpServersOverStore {
|
|
|
350
364
|
toolkit: string | null;
|
|
351
365
|
};
|
|
352
366
|
}>;
|
|
367
|
+
/** A Composio preset server's account read at Composio and kept (composioAccountKey) for every read of the server to
|
|
368
|
+
* say: connected or not, and each connected account's label. Only a server whose save recorded its user and auth config
|
|
369
|
+
* (composio-made.ts): one per-run (each run names its own account), of a toolkit with no sign-in (no auth config), or
|
|
370
|
+
* saved before that was recorded has none. A failure keeps `unknown`, and the refresh goes on: its tools are listed. */
|
|
371
|
+
private checkAccount;
|
|
372
|
+
/** The account a refresh last read for `row` (checkAccount), while it was read for what the server stands on now (its
|
|
373
|
+
* user, toolkit and auth config); none otherwise. */
|
|
374
|
+
private accountOf;
|
|
353
375
|
/** Writes the owner's change over the row it read (`was`), its credential left as it is, by a compare-and-set on that
|
|
354
376
|
* credential (store.mcp.rewrite). A lost one (a run kept a refreshed set meanwhile) reads the row again and re-applies the
|
|
355
377
|
* change onto it, while `still` holds of it, at most REWRITE_TRIES writes; then it is refused in words, nothing written. */
|