@parcha/agentrun-serve 0.1.0-beta.45 → 0.1.0-beta.47
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 +180 -0
- package/NOTICE +4 -0
- package/README.md +283 -47
- package/dist/acp-package.d.ts +35 -6
- package/dist/acp-package.js +3 -3
- package/dist/adapter-facts.d.ts +5 -2
- package/dist/adapter-facts.js +6 -3
- package/dist/adapters.d.ts +7 -0
- package/dist/adapters.js +39 -0
- package/dist/agents-store.d.ts +5 -3
- package/dist/agents-store.js +13 -8
- package/dist/api-only.d.ts +7 -10
- package/dist/api-only.js +7 -10
- package/dist/archil-routes.js +2 -1
- package/dist/cap.js +12 -2
- package/dist/chatgpt-plan.js +2 -1
- package/dist/cli.js +119 -44
- package/dist/composio-made.d.ts +19 -2
- package/dist/composio-made.js +17 -5
- package/dist/composio-preset.d.ts +42 -7
- package/dist/composio-preset.js +106 -70
- package/dist/composio-triggers.d.ts +9 -4
- package/dist/composio-triggers.js +20 -13
- package/dist/computer-attach.d.ts +11 -10
- package/dist/computer-attach.js +13 -14
- package/dist/computer-commands.d.ts +3 -0
- package/dist/computer-commands.js +3 -2
- package/dist/computer-lost.d.ts +4 -0
- package/dist/computer-lost.js +8 -3
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +2 -0
- package/dist/computers.d.ts +9 -75
- package/dist/computers.js +20 -66
- package/dist/console/assets/index-BBFzAxLB.js +715 -0
- package/dist/console/assets/index-BRi-Rgq6.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/cost-heal.d.ts +13 -0
- package/dist/cost-heal.js +27 -0
- package/dist/dial-relay.d.ts +6 -2
- package/dist/dial-relay.js +9 -12
- package/dist/email/routes.js +2 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +5 -0
- package/dist/exa-keyless.d.ts +1 -1
- package/dist/exa-keyless.js +1 -1
- package/dist/faux-computers.d.ts +2 -3
- package/dist/faux-computers.js +9 -31
- package/dist/github-connection.js +2 -1
- package/dist/harness-archive.d.ts +19 -2
- package/dist/harness-archive.js +49 -15
- package/dist/harness-check.d.ts +73 -0
- package/dist/harness-check.js +489 -0
- package/dist/harness-cursor.d.ts +45 -0
- package/dist/harness-cursor.js +121 -0
- package/dist/harness-recipe.d.ts +127 -0
- package/dist/harness-recipe.js +357 -0
- package/dist/harness-table.d.ts +12 -0
- package/dist/harness-table.js +62 -2
- package/dist/harness.d.ts +2 -0
- package/dist/harness.js +3 -2
- package/dist/host-check.d.ts +6 -0
- package/dist/host-check.js +14 -0
- package/dist/host.d.ts +10 -3
- package/dist/host.js +17 -3
- package/dist/import-sources.d.ts +2 -0
- package/dist/import-sources.js +2 -0
- package/dist/import-summary.d.ts +15 -5
- package/dist/import-summary.js +24 -8
- package/dist/import.d.ts +34 -4
- package/dist/import.js +134 -32
- package/dist/key-refusal.d.ts +1 -0
- package/dist/key-refusal.js +8 -3
- package/dist/key-words.d.ts +1 -1
- package/dist/key-words.js +4 -4
- package/dist/learn/check.d.ts +3 -0
- package/dist/learn/check.js +31 -20
- package/dist/learn/compile.js +11 -4
- package/dist/learn/promote.d.ts +77 -4
- package/dist/learn/promote.js +123 -2
- package/dist/learned-nodes.d.ts +4 -3
- package/dist/learned-workflow.js +4 -1
- package/dist/learning-cost.d.ts +6 -16
- package/dist/learning-cost.js +6 -12
- package/dist/learning-setting.d.ts +17 -6
- package/dist/learning-setting.js +41 -5
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +1 -1
- package/dist/listen-first.d.ts +10 -0
- package/dist/listen-first.js +25 -1
- package/dist/llms.txt +1 -1
- package/dist/mcp-gateway.d.ts +2 -1
- package/dist/mcp-gateway.js +31 -15
- package/dist/mcp-probe.d.ts +18 -6
- package/dist/mcp-probe.js +41 -8
- package/dist/mcp-secret-writes.d.ts +8 -0
- package/dist/mcp-secret-writes.js +104 -4
- package/dist/mcp-servers-store.d.ts +11 -5
- package/dist/mcp-servers-store.js +46 -20
- package/dist/model-form.d.ts +2 -1
- package/dist/model-form.js +22 -8
- package/dist/model-gateway.d.ts +113 -0
- package/dist/model-gateway.js +433 -0
- package/dist/model.d.ts +2 -1
- package/dist/model.js +9 -7
- package/dist/monid.js +1 -1
- package/dist/native/binding.d.ts +4 -0
- package/dist/native/binding.js +9 -0
- package/dist/native/cli.d.ts +3 -2
- package/dist/native/cli.js +6 -5
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +326 -41
- package/dist/owner.d.ts +4 -2
- package/dist/owner.js +10 -4
- package/dist/page.d.ts +8 -0
- package/dist/page.js +9 -1
- package/dist/port-models.js +17 -10
- package/dist/provider.d.ts +3 -3
- package/dist/provider.js +12 -3
- package/dist/public-address.d.ts +28 -0
- package/dist/public-address.js +62 -0
- package/dist/run-launch.d.ts +1 -1
- package/dist/run-launch.js +1 -1
- package/dist/run-secrets.d.ts +3 -2
- package/dist/run-secrets.js +6 -4
- package/dist/runner/adapter-loop.d.ts +10 -7
- package/dist/runner/adapter-loop.js +57 -22
- package/dist/runner/adapter-run-spec.d.ts +12 -0
- package/dist/runner/adapter-run-spec.js +40 -6
- package/dist/runner/adapters/index.js +16 -0
- package/dist/runner/adapters/pi.d.ts +5 -2
- package/dist/runner/adapters/pi.js +7 -4
- package/dist/runner/audit.d.ts +7 -0
- package/dist/runner/audit.js +24 -6
- package/dist/runner/claim-secrets.js +5 -1
- package/dist/runner/cli-run-spec.js +15 -7
- package/dist/runner/compare-end.d.ts +43 -0
- package/dist/runner/compare-end.js +95 -0
- package/dist/runner/computer-journal.d.ts +3 -0
- package/dist/runner/computer-journal.js +22 -2
- package/dist/runner/conformance/harness.js +19 -8
- package/dist/runner/conformance/subject.d.ts +6 -0
- package/dist/runner/harness-loops.d.ts +6 -1
- package/dist/runner/harness-loops.js +94 -54
- package/dist/runner/held.d.ts +5 -4
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +3 -0
- package/dist/runner/loop-contract.d.ts +10 -0
- package/dist/runner/main.d.ts +5 -5
- package/dist/runner/main.js +81 -11
- package/dist/runner/mcp-claim.js +40 -12
- package/dist/runner/metrics.d.ts +26 -0
- package/dist/runner/metrics.js +44 -1
- package/dist/runner/presence.d.ts +41 -0
- package/dist/runner/presence.js +89 -0
- package/dist/runner/promotion.d.ts +10 -3
- package/dist/runner/promotion.js +42 -21
- package/dist/runner/run-child-host.js +52 -14
- package/dist/runner/runner.d.ts +5 -0
- package/dist/runner/runner.js +8 -0
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/store-secrets.js +19 -7
- package/dist/runner/workflow-first.d.ts +5 -2
- package/dist/runner/workflow-first.js +6 -3
- package/dist/runs-over-store.d.ts +6 -2
- package/dist/runs-over-store.js +14 -4
- package/dist/sdk/runs.d.ts +1 -1
- package/dist/sdk/runs.js +6 -1
- package/dist/sdk/schema.js +1 -1
- package/dist/secret-writes.d.ts +16 -3
- package/dist/secret-writes.js +28 -3
- package/dist/server-secrets-store.js +5 -0
- package/dist/server.d.ts +31 -2
- package/dist/server.js +326 -53
- package/dist/sign-ins-secrets.js +4 -1
- package/dist/skills/agentrun-serve/SKILL.md +11 -0
- package/dist/slack-url.d.ts +5 -0
- package/dist/slack-url.js +11 -0
- package/dist/slack.d.ts +107 -0
- package/dist/slack.js +292 -0
- package/dist/start-switches.d.ts +28 -0
- package/dist/start-switches.js +37 -0
- package/dist/stats.d.ts +1 -1
- package/dist/stats.js +2 -1
- package/dist/stop-signals.d.ts +11 -0
- package/dist/stop-signals.js +22 -0
- package/dist/store/agent-body.d.ts +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/migrations/0020_runners.sql +18 -0
- package/dist/store/postgres/store.d.ts +1 -1
- package/dist/store/postgres/store.js +4 -2
- package/dist/store/schema.d.ts +13 -5
- package/dist/store/schema.js +20 -11
- package/dist/store/seal.d.ts +16 -4
- package/dist/store/sqlite/store.d.ts +1 -1
- package/dist/store/sqlite/store.js +106 -27
- package/dist/store/store.d.ts +75 -23
- package/dist/store/store.js +11 -0
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +7 -0
- package/dist/store-reads/cap.js +11 -1
- package/dist/store-reads/journal.js +27 -1
- package/dist/store-reads/learning.d.ts +23 -2
- package/dist/store-reads/learning.js +29 -8
- package/dist/store-reads/runs.d.ts +9 -0
- package/dist/store-reads/runs.js +19 -6
- package/dist/store-reads/stats.d.ts +4 -1
- package/dist/store-reads/stats.js +15 -6
- package/dist/store-view.d.ts +123 -14
- package/dist/store-view.js +154 -21
- package/dist/telemetry.d.ts +7 -7
- package/dist/telemetry.js +38 -15
- package/dist/templates.d.ts +6 -3
- package/dist/templates.js +38 -3
- package/dist/timeline/timeline.js +18 -0
- package/dist/tool-keys-store.js +2 -2
- package/dist/tool-keys.js +2 -1
- package/dist/tool-plane.js +2 -2
- package/dist/trigger-adapter.d.ts +3 -4
- package/dist/trigger-adapter.js +2 -2
- package/dist/trigger-composio.js +3 -3
- package/dist/trigger-email.js +0 -2
- package/dist/trigger-feed.js +0 -2
- package/dist/trigger-schedule.js +3 -0
- package/dist/trigger-secrets-shown.d.ts +6 -3
- package/dist/trigger-secrets-shown.js +22 -13
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +19 -8
- package/dist/triggers.d.ts +7 -3
- package/dist/triggers.js +2 -1
- package/dist/webhooks.d.ts +85 -9
- package/dist/webhooks.js +129 -46
- package/dist/wires.d.ts +6 -1
- package/dist/wires.js +5 -0
- package/dist/workspace/attach.d.ts +3 -2
- package/dist/workspace/attach.js +2 -1
- package/dist/workspace/attached-computers.d.ts +6 -8
- package/dist/workspace/attached-computers.js +27 -24
- package/dist/workspace/computer-deps.d.ts +2 -3
- package/dist/workspace/computer-deps.js +3 -6
- package/dist/workspace/computer-for-claim.js +72 -96
- package/dist/workspace/computer-kept.d.ts +0 -7
- package/dist/workspace/computer-kept.js +0 -17
- package/dist/workspace/resolve-computer.d.ts +18 -14
- package/dist/workspace/resolve-computer.js +47 -60
- package/dist/workspace/synced-folder.d.ts +20 -15
- package/dist/workspace/synced-folder.js +33 -43
- package/launcher/agentrun-serve +4 -1
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +11 -0
- package/templates/README.md +1 -1
- package/templates/inbound-lead/agent.md +2 -1
- package/templates/kyb/agent.md +2 -1
- package/dist/console/assets/index-3O2Yl6hZ.js +0 -701
- package/dist/console/assets/index-DaFsZuzQ.css +0 -1
|
@@ -15,8 +15,8 @@ import { checkPrivateHosts, privateOAuthHosts, savePrivateOAuthHosts } from "./m
|
|
|
15
15
|
import { credentialMark } from "./mcp-secret-writes.js";
|
|
16
16
|
import { secretMeta, secretName } from "./secret-writes.js";
|
|
17
17
|
import { dialAt, issuerOf, LOOPBACK, MAX_PENDING, MCP_SETTINGS_PAGE, mcpServerAt, McpSignIns, reasonOf, SIGN_IN_AGAIN, systemNetwork } from "./mcp-oauth.js";
|
|
18
|
-
import { cleanupOf, composioMadeKey, droppedOf, madeToWrite, recordedMade, storedMade } from "./composio-made.js";
|
|
19
|
-
import { COMPOSIO_USER, composioServerId } from "./composio-preset.js";
|
|
18
|
+
import { cleanupOf, composioMadeKey, composioPerRun, droppedOf, madeToWrite, recordedMade, releasedOf, storedMade } from "./composio-made.js";
|
|
19
|
+
import { COMPOSIO_PER_RUN, COMPOSIO_USER, composioListingAddress, composioServerId } from "./composio-preset.js";
|
|
20
20
|
import { mcpSourceKey, recordedForAnother, sourceOf, sourceToWrite, standInGiven, storedSource, toolkitGiven } from "./mcp-sources.js";
|
|
21
21
|
import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
|
|
22
22
|
import { GITHUB_MCP_ONLY, GITHUB_MCP_ORIGIN, githubMcpUrl } from "./github.js";
|
|
@@ -26,6 +26,7 @@ import { HARNESSES } from "./harness.js";
|
|
|
26
26
|
import { harnessOf } from "./harness-table.js";
|
|
27
27
|
import { droppedWords, mcpGrantNameProblem, mcpToolName } from "./tool-names.js";
|
|
28
28
|
import { isObject, unknownFields } from "./validate.js";
|
|
29
|
+
import { MCP_ALLOW_LOOPBACK_ENV, restartToAllow } from "./start-switches.js";
|
|
29
30
|
/** How many writes an owner's save or tools refresh makes over a row whose credential a run's refresh keeps changing,
|
|
30
31
|
* each re-applied onto the row read again, before it is refused in words. */
|
|
31
32
|
const REWRITE_TRIES = 3;
|
|
@@ -191,7 +192,7 @@ export class McpServersOverStore {
|
|
|
191
192
|
const kept = await this.need(name);
|
|
192
193
|
const url = new URL(kept.url);
|
|
193
194
|
const send = await this.reached(kept.auth, url, stop);
|
|
194
|
-
return marked(kept.url, await this.signInNoted(url, this.listServer(url, await this.withAppToken(kept.auth, url, (await this.opened(name, kept, "name")).headers, stop), send, stop), stop));
|
|
195
|
+
return marked(kept.url, await this.signInNoted(url, this.listServer(url, await this.withAppToken(kept.auth, url, (await this.opened(name, kept, "name")).headers, stop), send, stop, await this.perRunComposio(name, kept)), stop));
|
|
195
196
|
}
|
|
196
197
|
// `name` with a url: the saved server the form is editing. Its address as every read shows it (shownUrl), sent back
|
|
197
198
|
// unchanged, is the saved one here too (as save and sign-in map it): the browser never gets the real address back.
|
|
@@ -203,7 +204,9 @@ export class McpServersOverStore {
|
|
|
203
204
|
if (auth.type !== "none" && auth.type !== "github_app" && auth.type !== "per_run" && !auth.headers)
|
|
204
205
|
throw invalid([credentialMissing(auth.type, "A preview needs the credential it is to connect with.")]);
|
|
205
206
|
const send = await this.reached(auth.type, url, stop);
|
|
206
|
-
|
|
207
|
+
// The edit form of a per-run Composio server at its saved address lists it as a preview by name does.
|
|
208
|
+
const perRun = !!saved && auth.type === "headers" && saved.url === url.href && (await this.perRunComposio(String(editing), saved));
|
|
209
|
+
return marked(url.href, await this.signInNoted(url, this.listServer(url, await this.withAppToken(auth.type, url, auth.headers ?? {}, stop), send, stop, perRun), stop));
|
|
207
210
|
}
|
|
208
211
|
/** What an agent's save pins of the saved server `name` (mcp-gateway.ts mcpPinOf): its URL, its tools as it lists them
|
|
209
212
|
* now (listed once, with its saved credential, as a preview by name lists them; nothing stored), each marked grantable
|
|
@@ -222,7 +225,7 @@ export class McpServersOverStore {
|
|
|
222
225
|
};
|
|
223
226
|
const send = await this.reached(row.auth, url, stop);
|
|
224
227
|
try {
|
|
225
|
-
return pinned((await this.listServer(url, await this.withAppToken(row.auth, url, (await this.opened(name, row, "name")).headers, stop), send, stop)).tools);
|
|
228
|
+
return pinned((await this.listServer(url, await this.withAppToken(row.auth, url, (await this.opened(name, row, "name")).headers, stop), send, stop, await this.perRunComposio(name, row))).tools);
|
|
226
229
|
}
|
|
227
230
|
catch (error) {
|
|
228
231
|
if ((row.auth === "per_run" || row.auth === "oauth") && error instanceof ApiError && error.code === "auth_required")
|
|
@@ -314,14 +317,20 @@ export class McpServersOverStore {
|
|
|
314
317
|
else if (auth.type !== "none") {
|
|
315
318
|
credential = { type: "headers", headers: headers };
|
|
316
319
|
}
|
|
317
|
-
|
|
318
|
-
const
|
|
320
|
+
// A per-run Composio server, made so now (`stands`) or saved so and kept at its address by an ordinary save.
|
|
321
|
+
const perRun = Boolean(stands?.per_run) || (!made && was !== undefined && auth.type === "headers" && was.url === url.href && (await this.perRunComposio(name, was)));
|
|
322
|
+
const listed = await this.listServer(url, await this.withAppToken(auth.type, url, headers ?? {}, stop), send, stop, perRun);
|
|
323
|
+
// The Composio preset prices each action it granted (its price_usd): one its server doesn't list goes unpriced, as the
|
|
324
|
+
// preset's answer names it (not_served), never a refusal. An owner's prices name only tools the server lists.
|
|
325
|
+
const asked = made && prices ? pricesListed(prices, listed.tools) : prices;
|
|
326
|
+
const unlisted = Object.keys(asked ?? {}).filter((tool) => !listed.tools.some((listedTool) => listedTool.name === tool));
|
|
319
327
|
if (unlisted.length)
|
|
320
328
|
throw invalid(unlisted.map((tool) => ({ field: `prices.${tool}`, reason: "not_an_option", message: `The server ${name} lists no tool ${tool}; its tools are ${listed.tools.map((t) => t.name).join(", ") || "none"}.` })));
|
|
321
329
|
// The row as saved over `row` (the one read, or read again): a body with no `prices` keeps the saved ones, for the tools
|
|
322
|
-
// still listed at the same address
|
|
330
|
+
// still listed at the same address; a preset save over a preset row keeps them at the new address its Composio server
|
|
331
|
+
// has (each preset save makes one), so a re-save never leaves a priced action unmetered.
|
|
323
332
|
const fields = (row) => {
|
|
324
|
-
const priced =
|
|
333
|
+
const priced = asked ?? (row && (row.url === url.href || (made && wasPreset)) ? pricesListed((row.prices ?? undefined), listed.tools) : undefined);
|
|
325
334
|
return {
|
|
326
335
|
name, url: url.href, auth: auth.type, protocol: listed.protocol, tools: listed.tools, serverInfo: listed.server_info, instructions: listed.instructions ?? null,
|
|
327
336
|
...(priced && Object.keys(priced).length ? { prices: priced } : {}),
|
|
@@ -332,7 +341,7 @@ export class McpServersOverStore {
|
|
|
332
341
|
const write = async () => {
|
|
333
342
|
if (guard && wasPreset) {
|
|
334
343
|
const stood = recordedMade(await this.store.settings.get(composioMadeKey(name)), was.createdAt);
|
|
335
|
-
if (moved || (made && stands && (!stood || stood.user !== stands.user || (stood.auth_config?.id ?? null) !== (stands.auth_config?.id ?? null))))
|
|
344
|
+
if (moved || (made && stands && (!stood || stood.user !== stands.user || Boolean(stood.per_run) !== Boolean(stands.per_run) || (stood.auth_config?.id ?? null) !== (stands.auth_config?.id ?? null))))
|
|
336
345
|
await guard.inUse();
|
|
337
346
|
}
|
|
338
347
|
const saved = keeping
|
|
@@ -353,7 +362,12 @@ export class McpServersOverStore {
|
|
|
353
362
|
// What it stands on at Composio: what the preset found and made, over what the server saved before over this row had
|
|
354
363
|
// made. A row moved off Composio stands on nothing there: its delete removes nothing at Composio.
|
|
355
364
|
if (made && stands) {
|
|
356
|
-
|
|
365
|
+
// An auth config the owner named (auth_config_id) is theirs from this save on: every other saved server's claim to
|
|
366
|
+
// have made it is let go first, so neither this record nor theirs, nor what they hand on, ever removes it.
|
|
367
|
+
const listed = (await this.composioRecords()).filter(([other]) => other !== name);
|
|
368
|
+
const released = stands.auth_config?.named ? releasedOf(stands.auth_config.id, listed) : [];
|
|
369
|
+
await this.handOver(listed, released);
|
|
370
|
+
const others = listed.map(([other, record, at]) => [other, released.find(([one]) => one === other)?.[1] ?? record, at]);
|
|
357
371
|
const before = was ? recordedMade(await this.store.settings.get(composioMadeKey(name)), was.createdAt) : undefined;
|
|
358
372
|
const record = madeToWrite(stands, before, others.map(([, other]) => other));
|
|
359
373
|
await this.store.settings.put(composioMadeKey(name), storedMade(record, saved));
|
|
@@ -399,7 +413,7 @@ export class McpServersOverStore {
|
|
|
399
413
|
const was = await this.need(name);
|
|
400
414
|
const send = await this.reached(was.auth, new URL(was.url), stop);
|
|
401
415
|
const open = await this.opened(name, was, "name");
|
|
402
|
-
const listed = await this.listServer(new URL(was.url), await this.withAppToken(was.auth, new URL(was.url), open.headers, stop), send, stop);
|
|
416
|
+
const listed = await this.listServer(new URL(was.url), await this.withAppToken(was.auth, new URL(was.url), open.headers, stop), send, stop, await this.perRunComposio(name, was));
|
|
403
417
|
const before = new Map(was.tools.map((tool) => [tool.name, canonical(tool)]));
|
|
404
418
|
const after = new Map(listed.tools.map((tool) => [tool.name, canonical(tool)]));
|
|
405
419
|
// A refresh re-lists the tools and leaves the credential as it is (rewriteKeeping: a run's refreshed set kept meanwhile
|
|
@@ -578,9 +592,15 @@ export class McpServersOverStore {
|
|
|
578
592
|
return back(await reasonOf(error));
|
|
579
593
|
}
|
|
580
594
|
}
|
|
581
|
-
|
|
595
|
+
/** `perRun`: the server is a per-run Composio server, whose saved address names no user, which Composio refuses even
|
|
596
|
+
* for a listing: listed as composio-preset.ts COMPOSIO_LISTING_USER, at that address alone. */
|
|
597
|
+
listServer(url, headers, send, stop, perRun = false) {
|
|
582
598
|
// The shared probe (mcp-probe.listServer), bound also to this server's own stop, each request sent as `send` (reached).
|
|
583
|
-
return listServer(url, headers, this.version, AbortSignal.any([this.stopped.signal, ...(stop ? [stop] : [])]), send);
|
|
599
|
+
return listServer(perRun ? composioListingAddress(url) : url, headers, this.version, AbortSignal.any([this.stopped.signal, ...(stop ? [stop] : [])]), send);
|
|
600
|
+
}
|
|
601
|
+
/** Whether the saved server `row` (named `name`) is a per-run Composio server (composio-made.ts composioPerRun). */
|
|
602
|
+
async perRunComposio(name, row) {
|
|
603
|
+
return composioPerRun(row, await this.store.settings.get(composioMadeKey(name)));
|
|
584
604
|
}
|
|
585
605
|
/** How a request to the MCP server at `url` goes, or a 422 on url before anything is sent to it (or a token minted for
|
|
586
606
|
* it): a github_app server anywhere but GitHub's hosted MCP (GITHUB_MCP_ONLY, as withAppToken says), and at it, as it
|
|
@@ -653,7 +673,8 @@ export class McpServersOverStore {
|
|
|
653
673
|
return "credential" in open && open.credential.type === "oauth" ? open.credential.set : undefined;
|
|
654
674
|
}
|
|
655
675
|
/** A saved Composio preset server's key (its sealed x-api-key), the Composio user its address names (`user_id`, the
|
|
656
|
-
* preset's default when none)
|
|
676
|
+
* preset's default when none), its toolkit and the auth config its save recorded (composio-made.ts; none for a server
|
|
677
|
+
* saved before that was recorded): what its Composio triggers are made with (composio-triggers.ts). Refused
|
|
657
678
|
* when `name` is no such server: on the trigger's `source.server` at its create (`field`), as a 404 on the server's own
|
|
658
679
|
* routes (`route`). The key goes only to Composio. */
|
|
659
680
|
async composioOf(name, refusal) {
|
|
@@ -666,11 +687,16 @@ export class McpServersOverStore {
|
|
|
666
687
|
throw refuse(`${name} is not a Composio server: only one saved with Settings → MCP servers → Composio makes Composio triggers.`);
|
|
667
688
|
if (!toolkit)
|
|
668
689
|
throw refuse(`${name} is a Composio server of no toolkit this server can name: save it again with its toolkit's slug.`);
|
|
690
|
+
const recorded = await this.store.settings.get(composioMadeKey(name));
|
|
691
|
+
// A trigger runs as one Composio account, and a per-run server has none: each run names its own.
|
|
692
|
+
if (refusal === "field" && composioPerRun(row, recorded))
|
|
693
|
+
throw refuse(`${name} takes its Composio account from each run (saved with user_id "${COMPOSIO_PER_RUN}"), and a trigger runs as one account: save a Composio server for that account to make its triggers.`);
|
|
669
694
|
const { headers } = await this.opened(name, row, refusal === "field" ? "source.server" : "api_key");
|
|
670
695
|
const key = Object.entries(headers).find(([header]) => header.toLowerCase() === "x-api-key")?.[1];
|
|
671
696
|
if (!key)
|
|
672
697
|
throw refuse(`${name}'s saved credential holds no Composio key: save it again with its key.`);
|
|
673
|
-
|
|
698
|
+
const config = recordedMade(recorded, row.createdAt)?.auth_config?.id;
|
|
699
|
+
return { key, user: new URL(row.url).searchParams.get("user_id") || COMPOSIO_USER, toolkit, ...(config ? { auth_config: config } : {}) };
|
|
674
700
|
}
|
|
675
701
|
/** What the saved server `row` is, for a template's apply to match (mcp-sources.ts sourceOf): github on the GitHub App's
|
|
676
702
|
* tokens, else its record, else url with none. */
|
|
@@ -769,10 +795,10 @@ function grantProblemsOf(env, server, tool) {
|
|
|
769
795
|
/** Which save of a server this is: a PUT or a sign-in makes a new one (its updated time moves), a refresh of its tools or
|
|
770
796
|
* token does not change the url. The staleness key an OAuth sign-in carries from start to callback. */
|
|
771
797
|
const saving = (row) => `${row.url} ${row.updatedAt}`;
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
export const loopbackWords = (host) => `${host} is this machine;
|
|
798
|
+
export { MCP_ALLOW_LOOPBACK_ENV };
|
|
799
|
+
/** What a URL on loopback says on a server that is not one, with how to make it one: the switch, its value and the restart
|
|
800
|
+
* it takes (start-switches.ts). */
|
|
801
|
+
export const loopbackWords = (host) => `${host} is this machine; ${restartToAllow(MCP_ALLOW_LOOPBACK_ENV)}.`;
|
|
776
802
|
/** The owner's MCP registry over the one store. No load() is needed: every read goes to the store (the runner also writes
|
|
777
803
|
* the OAuth state), so a read is always current. */
|
|
778
804
|
export function mcpServersOverStore(store, env, version, network) {
|
package/dist/model-form.d.ts
CHANGED
|
@@ -33,5 +33,6 @@ export declare function likelyModel(env: NodeJS.ProcessEnv, harness: string, giv
|
|
|
33
33
|
export declare function modelFormWhy(env: NodeJS.ProcessEnv, harness: string, named: string, host: boolean): string;
|
|
34
34
|
/** "On pi, a model is <provider>/<model id>, like A or B": the forms this server can run, each of the harness's first
|
|
35
35
|
* vendor's everyday model, the vendor's own and OpenRouter's. Only the forms a key here runs; with neither key both, since
|
|
36
|
-
* either key makes one run.
|
|
36
|
+
* either key makes one run. A harness billed to its own plan (Cursor: its wire `plan`, so no vendor of ours) takes its
|
|
37
|
+
* own form, `<harness>/<model id>`, a model its vendor lists for its owner's key, like its own default. */
|
|
37
38
|
export declare function modelShape(env: NodeJS.ProcessEnv, harness: string): string;
|
package/dist/model-form.js
CHANGED
|
@@ -5,9 +5,12 @@
|
|
|
5
5
|
import { adapterFactsOf } from "./adapter-facts.js";
|
|
6
6
|
import { FAUX_ENV, MODEL_KEYS } from "./model.js";
|
|
7
7
|
import { openRouterName } from "./provider.js";
|
|
8
|
-
import {
|
|
8
|
+
import { wireOf } from "./wires.js";
|
|
9
9
|
import { PLAN_PROVIDER, planOf, signedIn } from "./chatgpt-plan.js";
|
|
10
10
|
import { PLAN_HARNESSES } from "./harness.js";
|
|
11
|
+
// The default a harness billed to its own plan is named by (Cursor's, the one such harness: `cursor/default`). Already in
|
|
12
|
+
// any process that loads model.ts (whose harness table imports it), so no module is added to its graph.
|
|
13
|
+
import { CURSOR_DEFAULT_MODEL } from "./harness-cursor.js";
|
|
11
14
|
/** The current models a person may pick, by vendor, in the vendor's own ids (Anthropic's dashes; OpenRouter's dotted name
|
|
12
15
|
* for the same model is derived, provider.ts openRouterName). The everyday model first: it is the example a refusal gives.
|
|
13
16
|
* A candidate a harness cannot run on this server (one pi-ai's catalog does not list) is dropped before it is served
|
|
@@ -17,10 +20,14 @@ export const PICKABLE = Object.freeze([
|
|
|
17
20
|
{ vendor: "openai", ids: Object.freeze(["gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-luna"]) },
|
|
18
21
|
{ vendor: "particle", ids: Object.freeze(["particle-1"]) },
|
|
19
22
|
]);
|
|
20
|
-
/** The vendors whose models `harness` runs: pi any; an adapter harness, its wire's vendor
|
|
23
|
+
/** The vendors whose models `harness` runs: pi any; an adapter harness, its wire's vendor; one billed to its own plan, none
|
|
24
|
+
* of ours. */
|
|
21
25
|
const vendorsOf = (harness) => {
|
|
22
26
|
const facts = adapterFactsOf(harness);
|
|
23
|
-
|
|
27
|
+
if (!facts)
|
|
28
|
+
return PICKABLE.map((p) => p.vendor);
|
|
29
|
+
const settings = wireOf(facts.wire);
|
|
30
|
+
return settings ? [settings.vendor] : [];
|
|
24
31
|
};
|
|
25
32
|
/** `vendor`'s model `id` in the form this server runs it: `vendor/id` on the vendor's own key, or through OpenRouter
|
|
26
33
|
* (`openrouter/vendor/id`, Anthropic's id in OpenRouter's dotted name) when OpenRouter's key is the only one here. */
|
|
@@ -34,11 +41,13 @@ export function formOf(env, vendor, id) {
|
|
|
34
41
|
* (harness.ts harnessOffers drops those it does not run). Behind serve's gateway every id is the gateway's own string, so
|
|
35
42
|
* the host's tier models stand for what it runs; with the faux model none is offered. */
|
|
36
43
|
export function pickerCandidates(env, harness) {
|
|
37
|
-
|
|
44
|
+
// A harness billed to its own plan (Cursor) runs its vendor's models, listed by its vendor for its owner's key alone: its
|
|
45
|
+
// entry's default is offered (harness.ts harnessOffers' default_model), and none of ours.
|
|
46
|
+
const facts = adapterFactsOf(harness);
|
|
47
|
+
if (env[FAUX_ENV] || (facts && !wireOf(facts.wire)))
|
|
38
48
|
return [];
|
|
39
49
|
// The gateway serves the harnesses whose wire goes through it (pi, and the OpenAI Responses wire: providerFor); the
|
|
40
50
|
// Anthropic Messages wire never does, so Claude is offered Anthropic's models on its own key.
|
|
41
|
-
const facts = adapterFactsOf(harness);
|
|
42
51
|
if (env.AGENT_MODEL_BASE_URL && facts?.wire !== "anthropic-messages")
|
|
43
52
|
return [...new Set([env.AGENT_MODEL, env.AGENT_MODEL_FAST, env.AGENT_MODEL_STRONG].filter((id) => Boolean(id)))];
|
|
44
53
|
const vendors = vendorsOf(harness);
|
|
@@ -86,11 +95,16 @@ export function modelFormWhy(env, harness, named, host) {
|
|
|
86
95
|
}
|
|
87
96
|
/** "On pi, a model is <provider>/<model id>, like A or B": the forms this server can run, each of the harness's first
|
|
88
97
|
* vendor's everyday model, the vendor's own and OpenRouter's. Only the forms a key here runs; with neither key both, since
|
|
89
|
-
* either key makes one run.
|
|
98
|
+
* either key makes one run. A harness billed to its own plan (Cursor: its wire `plan`, so no vendor of ours) takes its
|
|
99
|
+
* own form, `<harness>/<model id>`, a model its vendor lists for its owner's key, like its own default. */
|
|
90
100
|
export function modelShape(env, harness) {
|
|
101
|
+
const facts = adapterFactsOf(harness);
|
|
91
102
|
const first = PICKABLE.find((p) => vendorsOf(harness).includes(p.vendor));
|
|
92
|
-
const id = first
|
|
93
|
-
|
|
103
|
+
const id = first?.ids[0];
|
|
104
|
+
if (!first || !id)
|
|
105
|
+
return `On ${harness}, a model is ${harness}/<model id> (one ${facts?.label ?? harness} lists for your key), like ${harness}/${CURSOR_DEFAULT_MODEL}`;
|
|
106
|
+
const key = MODEL_KEYS.find((r) => r.id === first.vendor)?.field;
|
|
107
|
+
const own = Boolean(key && env[key]);
|
|
94
108
|
const router = Boolean(env.OPENROUTER_API_KEY);
|
|
95
109
|
const shown = [...(own || !router ? [`${first.vendor}/${id}`] : []), ...(router || !own ? [`openrouter/${first.vendor}/${first.vendor === "anthropic" ? openRouterName(id) : id}`] : [])];
|
|
96
110
|
return `On ${harness}, a model is <provider>/<model id>, like ${shown.join(" or ")}`;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type KeyEnv } from "./key-meta.js";
|
|
2
|
+
import { type Tier } from "./model.js";
|
|
3
|
+
import { type SecretMeta } from "./secret-writes.js";
|
|
4
|
+
import type { SealedKeys, Settings } from "./store/index.js";
|
|
5
|
+
/** The routes, by their operation names. */
|
|
6
|
+
export declare const MODEL_GATEWAY_ROUTES: ReadonlySet<string>;
|
|
7
|
+
/** The settings row: the address, the id style and the models. */
|
|
8
|
+
export declare const GATEWAY_SETTING = "model_gateway";
|
|
9
|
+
/** The sealed-key row of the gateway's key: never AGENT_MODEL_API_KEY's name, so nothing that reads a key by that name
|
|
10
|
+
* (a run's claim, the environment's gateway) opens it. Only withSavedGateway hands it on, with its own address. */
|
|
11
|
+
export declare const GATEWAY_KEY_ROW = "model_gateway.api_key";
|
|
12
|
+
/** How the gateway takes the ids a revision or a provider key's default names: whole (`as_named`, `openai/gpt-x`), or
|
|
13
|
+
* `bare`, the part after the provider (AGENT_MODEL_GATEWAY_IDS=bare). The tiers' own models go as saved either way. */
|
|
14
|
+
export declare const GATEWAY_IDS: readonly ["as_named", "bare"];
|
|
15
|
+
export type GatewayIds = (typeof GATEWAY_IDS)[number];
|
|
16
|
+
/** How long the test waits for the gateway, and how many ids it lists. */
|
|
17
|
+
export declare const TEST_TIMEOUT_MS = 10000;
|
|
18
|
+
/** The most of the gateway's answer to the test that is read: a list of MAX_LISTED models is far smaller. */
|
|
19
|
+
export declare const MAX_TEST_BYTES: number;
|
|
20
|
+
/** The saved row. */
|
|
21
|
+
export type GatewaySetting = {
|
|
22
|
+
v: 1;
|
|
23
|
+
base_url: string;
|
|
24
|
+
ids: GatewayIds;
|
|
25
|
+
models: Partial<Record<Tier, string>>;
|
|
26
|
+
};
|
|
27
|
+
/** The saved gateway with its key opened (none saved, or one that does not open: none). */
|
|
28
|
+
export type SavedGateway = GatewaySetting & {
|
|
29
|
+
key?: string;
|
|
30
|
+
};
|
|
31
|
+
/** The key's name in every secret's view (secret-writes.ts SecretMeta). */
|
|
32
|
+
export declare const GATEWAY_SECRET: string;
|
|
33
|
+
/** The row as saved, or undefined when there is none (or it is not one this reads). */
|
|
34
|
+
export declare function gatewaySettingOf(settings: Pick<Settings, "get">): Promise<GatewaySetting | undefined>;
|
|
35
|
+
/** The secrets of the key's row as opened, for the scan of every stored secret (runner/store-secrets.ts): the key itself,
|
|
36
|
+
* which is what a gateway's reply or a tool's output could quote, never the JSON it is sealed in alone. A row not of
|
|
37
|
+
* this shape is one secret whole. */
|
|
38
|
+
export declare const gatewayKeyRowSecrets: (opened: string) => string[];
|
|
39
|
+
/** The saved gateway with its key opened under `sealKey`, or undefined when none is saved. The key is there only when it
|
|
40
|
+
* was saved for the address's origin: none without a seal key, one that does not open, or one saved for another origin
|
|
41
|
+
* (an address changed while this read, or a save that failed between its two writes). */
|
|
42
|
+
export declare function readSavedGateway(store: {
|
|
43
|
+
readonly settings: Pick<Settings, "get">;
|
|
44
|
+
readonly sealedKeys: Pick<SealedKeys, "get">;
|
|
45
|
+
}, sealKey: Buffer | undefined): Promise<SavedGateway | undefined>;
|
|
46
|
+
/** Whether the environment AgentRun started with names its own gateway: then it is the one in force, whole. */
|
|
47
|
+
export declare const envGatewayInForce: (env: KeyEnv) => boolean;
|
|
48
|
+
/** Whether `env`'s gateway is the one saved in the console. */
|
|
49
|
+
export declare const savedGatewayIn: (env: NodeJS.ProcessEnv) => boolean;
|
|
50
|
+
/** The plain variable a runner sets on a run's own process (run-child-host.ts) whose gateway is the one saved in the
|
|
51
|
+
* console: that process holds no seal key and reads no store row of the gateway, so its runner lays the gateway over the
|
|
52
|
+
* claim and hands its key over the secrets' pipe, and this says the gateway is the saved one (savedGatewayIn), so its
|
|
53
|
+
* key stays off the run's tools there too. Not a secret. */
|
|
54
|
+
export declare const SAVED_GATEWAY_ENV = "AGENTRUN_MODEL_GATEWAY_SAVED";
|
|
55
|
+
/** `env` (a run's own process's, its runner having laid the saved gateway over it) marked as the saved gateway's, without
|
|
56
|
+
* SAVED_GATEWAY_ENV; `env` itself where that variable is not set. A copy, every property of `env` as it is. */
|
|
57
|
+
export declare function savedGatewayMarked<E extends NodeJS.ProcessEnv>(env: E): E;
|
|
58
|
+
/**
|
|
59
|
+
* `env` with the saved gateway laid over it, as the variables would set it: AGENT_MODEL_BASE_URL, its key as
|
|
60
|
+
* AGENT_MODEL_API_KEY (non-enumerable; empty where none is saved, so a key the environment holds for no address never goes
|
|
61
|
+
* to this one), and AGENT_MODEL_GATEWAY_IDS and each tier's model where the environment sets none. `env` itself where
|
|
62
|
+
* nothing is saved or the environment names its own gateway (envGatewayInForce). A copy, every property of `env` as it is
|
|
63
|
+
* (non-enumerable secrets and symbols too), never `env` changed.
|
|
64
|
+
*/
|
|
65
|
+
export declare function withSavedGateway<E extends NodeJS.ProcessEnv>(env: E, saved: SavedGateway | undefined): E;
|
|
66
|
+
/** GET /v2/settings/model-gateway. `source`: the gateway in force, the environment's (`env`), the console's (`console`),
|
|
67
|
+
* or none (`null`: the provider keys are). `set_at_start`: the variables of these fields set where AgentRun starts, which
|
|
68
|
+
* win, read-only here. `problem`: why the gateway in force runs no model (an address the one rule refuses), else null. */
|
|
69
|
+
export type GatewayView = {
|
|
70
|
+
source: "env" | "console" | null;
|
|
71
|
+
base_url: string | null;
|
|
72
|
+
ids: GatewayIds;
|
|
73
|
+
models: Record<Tier, string | null>;
|
|
74
|
+
set_at_start: string[];
|
|
75
|
+
secret: SecretMeta;
|
|
76
|
+
problem: string | null;
|
|
77
|
+
};
|
|
78
|
+
/** What the test answers: the model ids the gateway lists, or why it could not be asked, in words. */
|
|
79
|
+
export type GatewayTest = {
|
|
80
|
+
ok: true;
|
|
81
|
+
models: string[];
|
|
82
|
+
} | {
|
|
83
|
+
ok: false;
|
|
84
|
+
why: string;
|
|
85
|
+
};
|
|
86
|
+
/** What the routes need of the server: its store, its seal key, the environment it started with (never a saved key), and
|
|
87
|
+
* `changed`, its reading made again after a save or a removal. `fetch` is the test's (a test's fake, else the global). */
|
|
88
|
+
export type ModelGatewayDeps = {
|
|
89
|
+
readonly store: {
|
|
90
|
+
readonly settings: Pick<Settings, "get" | "put" | "remove">;
|
|
91
|
+
readonly sealedKeys: Pick<SealedKeys, "get" | "put" | "remove" | "all">;
|
|
92
|
+
flush(): Promise<void>;
|
|
93
|
+
};
|
|
94
|
+
readonly sealKey: Buffer;
|
|
95
|
+
readonly env: KeyEnv;
|
|
96
|
+
readonly changed: () => Promise<void>;
|
|
97
|
+
readonly fetch?: typeof fetch;
|
|
98
|
+
};
|
|
99
|
+
export declare function gatewayView({ store, env }: Pick<ModelGatewayDeps, "store" | "env">): Promise<GatewayView>;
|
|
100
|
+
/** PUT: the gateway saved, once every field is right; nothing is saved when one is not. No message holds the key. */
|
|
101
|
+
export declare function saveGateway(deps: ModelGatewayDeps, body: unknown): Promise<GatewayView>;
|
|
102
|
+
/** DELETE: the gateway and its key gone; the provider keys are in force again. */
|
|
103
|
+
export declare function removeGateway(deps: ModelGatewayDeps): Promise<GatewayView>;
|
|
104
|
+
/** POST /test: the model ids the gateway lists at GET <base>/v1/models, asked with its key. The body may name an address
|
|
105
|
+
* and a key not saved yet (the form's), else the gateway in force is asked with its own. A saved key goes only to the
|
|
106
|
+
* origin it was saved for; the environment's key only to the environment's gateway. No redirect is followed, and the
|
|
107
|
+
* answer never holds the key. */
|
|
108
|
+
export declare function testGateway(deps: ModelGatewayDeps, body: unknown, signal?: AbortSignal): Promise<GatewayTest>;
|
|
109
|
+
/** One of the routes at its handler: its answer (sent 200), or an ApiError. */
|
|
110
|
+
export declare function modelGatewayRoute(deps: ModelGatewayDeps, name: string, request: {
|
|
111
|
+
readonly body?: unknown;
|
|
112
|
+
readonly signal?: AbortSignal;
|
|
113
|
+
}): Promise<unknown>;
|