@parcha/agentrun-serve 0.1.0-beta.53 → 0.1.0-beta.55
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 +138 -3
- package/README.md +346 -99
- package/dist/adapters.d.ts +10 -0
- package/dist/adapters.js +46 -0
- package/dist/agent-package.d.ts +3 -3
- package/dist/agent-package.js +7 -14
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.js +7 -6
- package/dist/api-only.d.ts +17 -6
- package/dist/api-only.js +22 -9
- package/dist/cli.js +11 -4
- package/dist/composio-made.d.ts +26 -1
- package/dist/composio-made.js +39 -2
- package/dist/composio-preset.d.ts +6 -4
- package/dist/composio-preset.js +50 -17
- package/dist/computer-held-routes.js +2 -3
- package/dist/computer-needs.d.ts +1 -1
- package/dist/computer-needs.js +1 -1
- package/dist/computer-setting.d.ts +8 -4
- package/dist/computer-setting.js +0 -2
- package/dist/computers-running.d.ts +8 -0
- package/dist/computers-running.js +27 -0
- package/dist/computers.d.ts +0 -2
- package/dist/computers.js +1 -1
- package/dist/console/assets/backend-D5EmB4N3.js +166 -0
- package/dist/console/assets/index-DUYLaqiR.js +746 -0
- package/dist/console/assets/index-DYhU4adm.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/docker-host-addresses.d.ts +23 -3
- package/dist/docker-host-addresses.js +90 -18
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +7 -0
- package/dist/exa-keyless.d.ts +2 -3
- package/dist/exa-keyless.js +43 -127
- package/dist/firecrawl-keyless.d.ts +41 -0
- package/dist/firecrawl-keyless.js +152 -0
- package/dist/github-connection.d.ts +50 -1
- package/dist/github-connection.js +96 -3
- package/dist/github-faux.d.ts +11 -2
- package/dist/github-faux.js +138 -7
- package/dist/github-pull-request.d.ts +37 -0
- package/dist/github-pull-request.js +110 -0
- package/dist/handed-secret.d.ts +3 -1
- package/dist/handed-secret.js +4 -2
- package/dist/harness-keys.d.ts +98 -0
- package/dist/harness-keys.js +247 -0
- package/dist/harness-recipe-entry.d.ts +14 -9
- package/dist/harness-recipe-entry.js +25 -14
- package/dist/harness-table.d.ts +16 -1
- package/dist/harness-table.js +19 -7
- package/dist/harness.d.ts +4 -0
- package/dist/harness.js +12 -1
- package/dist/host-check.d.ts +2 -0
- package/dist/host-check.js +6 -0
- package/dist/import-summary.d.ts +1 -1
- package/dist/import-summary.js +1 -1
- package/dist/import.d.ts +5 -5
- package/dist/import.js +54 -67
- package/dist/keyless-mcp.d.ts +36 -0
- package/dist/keyless-mcp.js +127 -0
- package/dist/learn/audit.d.ts +3 -3
- package/dist/learn/audit.js +3 -3
- package/dist/learn/commit.d.ts +8 -7
- package/dist/learn/commit.js +60 -20
- package/dist/learn/compile.d.ts +4 -3
- package/dist/learn/compile.js +7 -5
- package/dist/learn/folder.d.ts +16 -3
- package/dist/learn/folder.js +46 -13
- package/dist/learn/promote.d.ts +37 -13
- package/dist/learn/promote.js +112 -40
- package/dist/learn/secrets.js +10 -2
- package/dist/learning-routes.d.ts +22 -17
- package/dist/learning-routes.js +40 -39
- package/dist/learning.js +2 -2
- package/dist/live-reach.d.ts +34 -7
- package/dist/live-reach.js +76 -11
- package/dist/manifest.d.ts +10 -0
- package/dist/manifest.js +30 -0
- package/dist/mcp-pin-first.d.ts +4 -2
- package/dist/mcp-pin-first.js +5 -2
- package/dist/mcp-probe.js +2 -2
- package/dist/mcp-secret-writes.d.ts +16 -7
- package/dist/mcp-secret-writes.js +35 -27
- package/dist/mcp-servers-store.d.ts +30 -6
- package/dist/mcp-servers-store.js +112 -28
- package/dist/mcp-sources.d.ts +10 -2
- package/dist/mcp-sources.js +9 -2
- package/dist/mcp-store.d.ts +13 -7
- package/dist/mcp-store.js +12 -9
- package/dist/model-form.d.ts +3 -2
- package/dist/model-form.js +11 -7
- package/dist/model.d.ts +20 -4
- package/dist/model.js +68 -9
- package/dist/native/history.d.ts +1 -1
- package/dist/native/history.js +2 -2
- package/dist/ollama-provider.d.ts +92 -0
- package/dist/ollama-provider.js +495 -0
- package/dist/openapi/agentrun-v2.openapi.json +2 -2
- package/dist/openapi.js +235 -41
- package/dist/page.d.ts +11 -3
- package/dist/page.js +22 -7
- package/dist/place-offers.d.ts +17 -1
- package/dist/place-offers.js +46 -5
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +35 -7
- package/dist/purged-workflow.js +73 -26
- package/dist/run-computer.d.ts +2 -0
- package/dist/run-computer.js +2 -0
- package/dist/run-files.d.ts +4 -0
- package/dist/run-files.js +4 -0
- package/dist/run-keys.d.ts +2 -4
- package/dist/run-keys.js +6 -7
- package/dist/run-launch.d.ts +4 -0
- package/dist/run-launch.js +4 -0
- package/dist/run-reads-over-store.d.ts +3 -2
- package/dist/run-reads-over-store.js +66 -2
- package/dist/run-secrets.js +5 -2
- package/dist/runner/adapter-loop.d.ts +6 -3
- package/dist/runner/adapter-loop.js +34 -15
- package/dist/runner/adapter-run-spec.d.ts +3 -0
- package/dist/runner/adapter-run-spec.js +6 -4
- package/dist/runner/audit.js +8 -4
- package/dist/runner/beside.d.ts +2 -1
- package/dist/runner/beside.js +6 -2
- package/dist/runner/claim-secrets.d.ts +5 -8
- package/dist/runner/claim-secrets.js +6 -0
- package/dist/runner/cli-run-spec.d.ts +1 -1
- package/dist/runner/cli-run-spec.js +39 -7
- package/dist/runner/harness-loops.d.ts +22 -9
- package/dist/runner/harness-loops.js +21 -11
- package/dist/runner/held.d.ts +3 -0
- package/dist/runner/learning-end.d.ts +1 -1
- package/dist/runner/learning-end.js +8 -3
- package/dist/runner/loop-contract.d.ts +5 -4
- package/dist/runner/main.js +4 -2
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +26 -2
- package/dist/runner/mcp-run.d.ts +3 -0
- package/dist/runner/mcp-run.js +2 -1
- package/dist/runner/metrics.d.ts +10 -8
- package/dist/runner/metrics.js +20 -27
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +6 -2
- package/dist/runner/pr-checkout.d.ts +21 -4
- package/dist/runner/pr-checkout.js +103 -4
- package/dist/runner/promotion.d.ts +15 -9
- package/dist/runner/promotion.js +25 -15
- package/dist/runner/run-child-host.js +24 -11
- package/dist/runner/run-child.js +3 -1
- package/dist/runner/runner-check.d.ts +3 -0
- package/dist/runner/runner-check.js +23 -0
- package/dist/runner/sdk-loop.js +2 -0
- package/dist/runner/workflow-loop.d.ts +2 -2
- package/dist/runner/workflow-loop.js +1 -2
- package/dist/runner/workflow-spec.d.ts +1 -1
- package/dist/runner/workflow-spec.js +6 -6
- package/dist/sdk/check.d.ts +4 -1
- package/dist/sdk/check.js +2 -1
- package/dist/sdk/runs.d.ts +2 -2
- package/dist/sdk/runs.js +8 -6
- package/dist/secret-cut.js +2 -1
- package/dist/secret-writes.d.ts +3 -2
- package/dist/secret-writes.js +1 -1
- package/dist/server.d.ts +55 -8
- package/dist/server.js +363 -118
- package/dist/standard-webhooks.d.ts +11 -0
- package/dist/standard-webhooks.js +20 -2
- package/dist/store/agent-body.d.ts +2 -2
- package/dist/store/agent-body.js +2 -2
- package/dist/store/index.d.ts +1 -1
- package/dist/store/schema.js +5 -2
- package/dist/store/sqlite/store.js +90 -34
- package/dist/store/store.d.ts +54 -14
- package/dist/store-reads/journal.d.ts +7 -2
- package/dist/store-reads/journal.js +9 -6
- package/dist/store-reads/learning.d.ts +12 -9
- package/dist/store-reads/learning.js +18 -24
- package/dist/store-view.d.ts +0 -5
- package/dist/store-view.js +9 -8
- package/dist/suggestions.d.ts +282 -0
- package/dist/suggestions.js +919 -0
- package/dist/telemetry.d.ts +8 -1
- package/dist/telemetry.js +12 -4
- package/dist/template-eval.d.ts +49 -4
- package/dist/template-eval.js +168 -45
- package/dist/template-import.d.ts +17 -0
- package/dist/template-import.js +36 -2
- package/dist/templates.d.ts +83 -76
- package/dist/templates.js +29 -48
- package/dist/timeline/labels.d.ts +2 -2
- package/dist/timeline/labels.js +2 -2
- package/dist/timeline/timeline.d.ts +2 -2
- package/dist/timeline/timeline.js +1 -1
- package/dist/tool-plane.d.ts +17 -9
- package/dist/tool-plane.js +38 -17
- package/dist/tools.js +2 -2
- package/dist/trigger-launch-hook.d.ts +19 -9
- package/dist/trigger-launch-hook.js +35 -25
- package/dist/trigger-targets.d.ts +18 -8
- package/dist/trigger-targets.js +42 -19
- package/dist/triggers.d.ts +85 -23
- package/dist/triggers.js +303 -96
- package/dist/validate.d.ts +1 -1
- package/dist/validate.js +2 -2
- package/dist/web-fake.js +3 -3
- package/dist/web-fetch-direct.d.ts +4 -0
- package/dist/web-fetch-direct.js +8 -1
- package/dist/web-fetch.d.ts +12 -3
- package/dist/web-fetch.js +47 -14
- package/dist/web-search.d.ts +33 -4
- package/dist/web-search.js +100 -41
- package/dist/webhooks.js +4 -5
- package/dist/workspace/synced-folder.d.ts +1 -1
- package/dist/workspace/synced-folder.js +11 -14
- package/launcher/agentrun-serve +5 -1
- package/package.json +17 -13
- package/templates/README.md +5 -4
- package/templates/agent-scout/agent.md +46 -0
- package/templates/agent-scout/skills/scout/SKILL.md +88 -0
- package/templates/agent-scout/skills/scout/suggestions.schema.json +112 -0
- package/dist/console/assets/index-BFgyZzF_.js +0 -734
- package/dist/console/assets/index-DbilxljH.css +0 -1
- package/dist/import-sources.d.ts +0 -116
- package/dist/import-sources.js +0 -693
package/dist/adapters.d.ts
CHANGED
|
@@ -22,6 +22,16 @@ export declare function installedHere(name: string, from?: string): string | und
|
|
|
22
22
|
* (~/.agentrun) is not the server's default, and after the server's own command when the store is not its default.
|
|
23
23
|
*/
|
|
24
24
|
export declare function npxLine(spec: string, env?: NodeJS.ProcessEnv, installed?: (name: string) => string | undefined): string;
|
|
25
|
+
/**
|
|
26
|
+
* A start `npx @parcha/agentrun` made (NPX_PACKAGE_ENV) that a data directory refused because an earlier version wrote it
|
|
27
|
+
* (store.ts StoreFromEarlierVersion, or SchemaVersionUnknown on an earlier release's store): the refusal's own first line,
|
|
28
|
+
* then the two ways on as commands to paste. That command keeps its data in ~/.agentrun wherever it is run, so a new
|
|
29
|
+
* folder alone is not a new AgentRun. First, the old folder moved aside whole, so the same command starts this version
|
|
30
|
+
* where it was, and the earlier version still opens what it holds; then this version on a new, empty folder: the same
|
|
31
|
+
* command with --data. Nothing is deleted either way. Any other error, or a start the launcher did not
|
|
32
|
+
* make, is undefined: the refusal's own words stand.
|
|
33
|
+
*/
|
|
34
|
+
export declare function earlierDataRefusal(error: unknown, data: string, env?: NodeJS.ProcessEnv, exists?: (path: string) => boolean): string | undefined;
|
|
25
35
|
/** The port the server was started on when `--port` named one, and whether `--open` was given (1 or 0): set by its CLI
|
|
26
36
|
* for itself and its runs (startedWith), read by npxLine, so a hint keeps them. */
|
|
27
37
|
export declare const STARTED_PORT_ENV = "AGENTRUN_SERVE_PORT";
|
package/dist/adapters.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// alone (harness-install.ts); opencode's pinned CLI that is missing says so with the one line that installs it: an npm
|
|
6
6
|
// install beside serve, or, when serve runs from npx, the npx line that runs it with the missing package.
|
|
7
7
|
import { accessSync, constants, existsSync, readFileSync, statSync } from "node:fs";
|
|
8
|
+
import { homedir } from "node:os";
|
|
8
9
|
import { dirname, join, resolve, sep } from "node:path";
|
|
9
10
|
import { fileURLToPath } from "node:url";
|
|
10
11
|
import { facts as claudeFacts } from "@parcha/agentrun-harness-claude/facts";
|
|
@@ -74,6 +75,51 @@ export function npxLine(spec, env = {}, installed = installedHere) {
|
|
|
74
75
|
const flags = [...(port && /^\d{1,5}$/.test(port) ? [`--port ${port}`] : []), ...(command && env[STARTED_OPEN_ENV] === "0" ? ["--no-open"] : []), ...(!command && env[STARTED_OPEN_ENV] === "1" ? ["--open"] : [])];
|
|
75
76
|
return `npx ${yes}${packages.map((name) => `-p ${name}`).join(" ")} ${command ? "agentrun" : "agentrun-serve"}${named}${flags.map((flag) => ` ${flag}`).join("")}`;
|
|
76
77
|
}
|
|
78
|
+
/** The first of `base`, `base-2`, `base-3`… that is not there. */
|
|
79
|
+
const freeName = (base, exists) => {
|
|
80
|
+
let name = base;
|
|
81
|
+
for (let n = 2; exists(name); n++)
|
|
82
|
+
name = `${base}-${n}`;
|
|
83
|
+
return name;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* A start `npx @parcha/agentrun` made (NPX_PACKAGE_ENV) that a data directory refused because an earlier version wrote it
|
|
87
|
+
* (store.ts StoreFromEarlierVersion, or SchemaVersionUnknown on an earlier release's store): the refusal's own first line,
|
|
88
|
+
* then the two ways on as commands to paste. That command keeps its data in ~/.agentrun wherever it is run, so a new
|
|
89
|
+
* folder alone is not a new AgentRun. First, the old folder moved aside whole, so the same command starts this version
|
|
90
|
+
* where it was, and the earlier version still opens what it holds; then this version on a new, empty folder: the same
|
|
91
|
+
* command with --data. Nothing is deleted either way. Any other error, or a start the launcher did not
|
|
92
|
+
* make, is undefined: the refusal's own words stand.
|
|
93
|
+
*/
|
|
94
|
+
export function earlierDataRefusal(error, data, env = {}, exists = existsSync) {
|
|
95
|
+
const refused = error;
|
|
96
|
+
const earlier = refused?.name === "StoreFromEarlierVersion" || (refused?.name === "SchemaVersionUnknown" && typeof refused.found === "number" && typeof refused.known === "number" && refused.found < refused.known);
|
|
97
|
+
const door = env[NPX_PACKAGE_ENV];
|
|
98
|
+
if (!earlier || typeof refused?.message !== "string" || door === undefined || !/^@parcha\/agentrun@\d[\w.+-]*$/.test(door))
|
|
99
|
+
return undefined;
|
|
100
|
+
const dir = resolve(data);
|
|
101
|
+
const yes = env.npm_config_yes === "true" ? "-y " : "";
|
|
102
|
+
const port = env[STARTED_PORT_ENV];
|
|
103
|
+
const flags = `${port && /^\d{1,5}$/.test(port) ? ` --port ${port}` : ""}${env[STARTED_OPEN_ENV] === "0" ? " --no-open" : ""}`;
|
|
104
|
+
const command = `npx ${yes}${door}`;
|
|
105
|
+
// The launcher's own folder when --data names none (agentrun start.mjs): this same command opens `dir` again with no
|
|
106
|
+
// --data only when `dir` is it.
|
|
107
|
+
const launcherData = resolve(env.HOME || homedir(), ".agentrun");
|
|
108
|
+
const again = `${command}${dir === launcherData ? "" : ` --data ${shellWord(dir)}`}${flags}`;
|
|
109
|
+
const fresh = freeName(`${dir}-new`, exists);
|
|
110
|
+
const aside = freeName(`${dir}-earlier`, exists);
|
|
111
|
+
const installed = exists(join(dir, "bin", "agentrun")) ? " Its bin/agentrun (the earlier installer's command) moves with it: run the installer again for this version's." : "";
|
|
112
|
+
return [
|
|
113
|
+
refused.message.split("\n")[0],
|
|
114
|
+
// Moved aside first: every later command (doctor, the harness commands, the service) then finds this version where it
|
|
115
|
+
// looks with nothing more to remember; a new folder means the same --data on each of them.
|
|
116
|
+
`To keep all of it where the earlier version still opens it and start this version in ${dir}: mv ${shellWord(dir)} ${shellWord(aside)}, then ${again}. The earlier version opens the old data with --data ${shellWord(aside)}.${installed}`,
|
|
117
|
+
`Or start this version on a new, empty folder: ${command} --data ${shellWord(fresh)}${flags}`,
|
|
118
|
+
` (every later agentrun command then takes the same --data: without it, they open ${launcherData})`,
|
|
119
|
+
// The store's own refusal already says to add them again; an earlier release's schema says it only in the lines cut here.
|
|
120
|
+
`Either way, nothing is deleted.${refused.name === "SchemaVersionUnknown" ? " Add your agents, MCP servers, keys and sign-ins again in this version." : ""}`,
|
|
121
|
+
].join("\n");
|
|
122
|
+
}
|
|
77
123
|
/** The port the server was started on when `--port` named one, and whether `--open` was given (1 or 0): set by its CLI
|
|
78
124
|
* for itself and its runs (startedWith), read by npxLine, so a hint keeps them. */
|
|
79
125
|
export const STARTED_PORT_ENV = "AGENTRUN_SERVE_PORT";
|
package/dist/agent-package.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type PackageFile = {
|
|
|
8
8
|
};
|
|
9
9
|
/** What an export's note can be about: the document's enum of them (openapi.ts), so a note of a kind not here fails the
|
|
10
10
|
* build, and an answer the document does not list fails its schema check. */
|
|
11
|
-
export declare const EXPORT_NOTE_KINDS: readonly ["mcp_server", "trigger", "pin", "tool_setting", "tool_policy", "computer", "paired_computer", "sign_in", "learning", "
|
|
11
|
+
export declare const EXPORT_NOTE_KINDS: readonly ["mcp_server", "trigger", "pin", "tool_setting", "tool_policy", "computer", "paired_computer", "sign_in", "learning", "input_schema", "budget", "package"];
|
|
12
12
|
/** One thing an export could not carry as it is here: what it is, which one, and why, in words. */
|
|
13
13
|
export type ExportNote = {
|
|
14
14
|
kind: (typeof EXPORT_NOTE_KINDS)[number];
|
|
@@ -46,8 +46,8 @@ export type ExportInput = {
|
|
|
46
46
|
definition: Json;
|
|
47
47
|
/** The revision's skill files, by path under the agent's skills folder. */
|
|
48
48
|
skills: Readonly<Record<string, string>>;
|
|
49
|
-
/** The package the agent was applied from (agentView's `template`) with the key names its apply kept
|
|
50
|
-
*
|
|
49
|
+
/** The package the agent was applied from (agentView's `template`) with the key names its apply kept, and that package
|
|
50
|
+
* as this server holds it now. */
|
|
51
51
|
template: {
|
|
52
52
|
id: string;
|
|
53
53
|
version: string;
|
package/dist/agent-package.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { createHash } from "node:crypto";
|
|
9
9
|
import { stringify } from "yaml";
|
|
10
10
|
import { LOOPBACK } from "./mcp-oauth.js";
|
|
11
|
-
import { MANIFEST, memoryFiles, onServerNames, PackageError, readPackage } from "./templates.js";
|
|
11
|
+
import { INPUT_KEYS, ITEM_KEYS, MANIFEST, memoryFiles, onServerNames, PackageError, readPackage } from "./templates.js";
|
|
12
12
|
import { isMcpName, isMonidName, mcpToolName, parseToolName } from "./tool-names.js";
|
|
13
13
|
import { isPinKeys, permissionKeys, SHELL_FAMILY } from "./tool-gate.js";
|
|
14
14
|
import { toolOf } from "./tools.js";
|
|
@@ -18,7 +18,7 @@ import { isObject, MODEL_TIER_NAMES, stable } from "./validate.js";
|
|
|
18
18
|
import { PAIRED_ID_PREFIX } from "./workspace/attached-computers.js";
|
|
19
19
|
/** What an export's note can be about: the document's enum of them (openapi.ts), so a note of a kind not here fails the
|
|
20
20
|
* build, and an answer the document does not list fails its schema check. */
|
|
21
|
-
export const EXPORT_NOTE_KINDS = ["mcp_server", "trigger", "pin", "tool_setting", "tool_policy", "computer", "paired_computer", "sign_in", "learning", "
|
|
21
|
+
export const EXPORT_NOTE_KINDS = ["mcp_server", "trigger", "pin", "tool_setting", "tool_policy", "computer", "paired_computer", "sign_in", "learning", "input_schema", "budget", "package"];
|
|
22
22
|
/** The package's digest: sha256, in hex, over its files sorted by path, each written as `path NUL bytes NUL`. */
|
|
23
23
|
export function packageSha256(files) {
|
|
24
24
|
const hash = createHash("sha256");
|
|
@@ -37,9 +37,8 @@ const REMADE_TRIGGERS = {
|
|
|
37
37
|
composio: "A composio trigger is made again on the target's Composio project.",
|
|
38
38
|
email: "An email trigger receives at an address the target gives it: point the sender at the new one.",
|
|
39
39
|
};
|
|
40
|
-
/**
|
|
41
|
-
const FIELD_KEYS =
|
|
42
|
-
const ITEM_KEYS = ["type", "pattern", "format", "minLength", "maxLength", "minimum", "maximum", "enum"];
|
|
40
|
+
/** An input field's own keys, in the order a package writes them: `required` and `items` are written after them. */
|
|
41
|
+
const FIELD_KEYS = INPUT_KEYS.filter((key) => key !== "required" && key !== "items");
|
|
43
42
|
const pick = (from, keys) => Object.fromEntries(keys.flatMap((key) => (from[key] !== undefined ? [[key, from[key]]] : [])));
|
|
44
43
|
/** Each field of `value`, a part of the agent an export copies as it is, that holds a credential in the clear, as its
|
|
45
44
|
* path from `at` (source.urls.0, target.input.api_key): by the walk a composio trigger's config is sealed by
|
|
@@ -71,7 +70,6 @@ export function agentPackage(input) {
|
|
|
71
70
|
const remade = [];
|
|
72
71
|
// Its name: the template's it was applied from, else the agent's own as a package name.
|
|
73
72
|
const pkgName = origin?.name || (template ? slug(template.id.split(/[/:]/).at(-1) ?? "") : "") || slug(agent.name) || slug(agent.id) || "agent";
|
|
74
|
-
const sameVersion = !!origin && !!template && origin.version === template.version;
|
|
75
73
|
const settings = (isObject(definition.tool_settings) ? definition.tool_settings : {});
|
|
76
74
|
// Denied as the gate reads the agent's own settings: a shell tool by bash's, then the most specific key set (the tool's
|
|
77
75
|
// own, else its MCP server's or monid provider's wildcard).
|
|
@@ -287,13 +285,8 @@ export function agentPackage(input) {
|
|
|
287
285
|
const inputs = inputSchema && inputsOf(inputSchema);
|
|
288
286
|
if (inputSchema && !inputs)
|
|
289
287
|
blocked.push({ kind: "input_schema", name: "inputs", reason: "Its input schema is not a closed object of fields, which is what a package's inputs are." });
|
|
290
|
-
// The keys its package declared, as its apply kept them
|
|
291
|
-
|
|
292
|
-
const declared = template?.secrets ?? (sameVersion ? origin.secrets : []);
|
|
293
|
-
const secrets = [...new Set([...declared, ...((plain ?? []).some(isMonidName) ? ["MONID_API_KEY"] : [])])].sort();
|
|
294
|
-
// Such a revision of a package updated or removed since its apply: the keys it was applied with are unknown here.
|
|
295
|
-
if (template && !template.secrets && !sameVersion)
|
|
296
|
-
remade.push({ kind: "secrets", name: template.id, reason: `The keys version ${template.version} of ${template.id} names are not known here: ${origin ? `this server holds version ${origin.version}` : "this server no longer holds it"}. Save the keys the agent uses on the target, and name them under secrets in ${MANIFEST}.` });
|
|
288
|
+
// The keys its package declared, as its apply kept them.
|
|
289
|
+
const secrets = [...new Set([...(template?.secrets ?? []), ...((plain ?? []).some(isMonidName) ? ["MONID_API_KEY"] : [])])].sort();
|
|
297
290
|
const bash = settings.bash?.policy;
|
|
298
291
|
// Bash's policy holds every shell tool, and a package writes it only beside bash: a shell tool kept without bash would
|
|
299
292
|
// run there what the policy refuses here.
|
|
@@ -319,7 +312,7 @@ export function agentPackage(input) {
|
|
|
319
312
|
...(plain ? { tools: plain } : {}), ...(mcp.length ? { mcp } : {}),
|
|
320
313
|
...(typeof bash === "string" && plain?.includes("bash") ? { tool_policy: { bash } } : {}),
|
|
321
314
|
...(computers ? { computer: computers } : {}), ...(needs ? { needs } : {}),
|
|
322
|
-
...(definition.checkout === "pull_request" ? { checkout:
|
|
315
|
+
...(definition.checkout === "pull_request" || definition.checkout === "repository" ? { checkout: definition.checkout } : {}),
|
|
323
316
|
...(inputs ? { inputs } : {}), ...(secrets.length ? { secrets } : {}),
|
|
324
317
|
...(cost !== undefined ? { budget: { per_run_usd: cost, ...(requests !== undefined ? { max_requests: requests } : {}) } } : {}),
|
|
325
318
|
...(learning !== undefined ? { learning } : {}),
|
package/dist/agent-rows.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export type AgenticBody = {
|
|
|
42
42
|
maxCostUsd?: number;
|
|
43
43
|
inputSchema?: Record<string, unknown>;
|
|
44
44
|
outputSchema?: Record<string, unknown>;
|
|
45
|
-
checkout?: "pull_request";
|
|
45
|
+
checkout?: "pull_request" | "repository";
|
|
46
46
|
};
|
|
47
47
|
export type WorkflowBody = {
|
|
48
48
|
workflow: Workflow;
|
package/dist/agents-store.js
CHANGED
|
@@ -17,7 +17,7 @@ import { learningSettingForBody } from "./store/agent-body.js";
|
|
|
17
17
|
import { storedHarness } from "./harness-table.js";
|
|
18
18
|
import { AgentBodyInvalid, RevisionMoved, bodyOf, canonical, isObject, StoreConstraint, } from "./store/index.js";
|
|
19
19
|
import { canonicalToolSettings, settingsIssues } from "./tool-plane.js";
|
|
20
|
-
import {
|
|
20
|
+
import { settingOfDefinition } from "./computer-setting.js";
|
|
21
21
|
import { skillIssues, skillNames } from "./validate.js";
|
|
22
22
|
const ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
23
23
|
/** A store refusal as the request's answer: a duplicate name (agent exists) and a constraint map the right way. */
|
|
@@ -99,7 +99,7 @@ function revisionInputOf(definition, files) {
|
|
|
99
99
|
...(definition.approvals === "ask" || definition.approvals === "never" ? { approvals: definition.approvals } : {}),
|
|
100
100
|
...(isObject(definition.input_schema) ? { inputSchema: definition.input_schema } : {}),
|
|
101
101
|
...(isObject(definition.output_schema) ? { outputSchema: definition.output_schema } : {}),
|
|
102
|
-
...(definition.checkout === "pull_request" ? { checkout:
|
|
102
|
+
...(definition.checkout === "pull_request" || definition.checkout === "repository" ? { checkout: definition.checkout } : {}),
|
|
103
103
|
...common,
|
|
104
104
|
...learning,
|
|
105
105
|
...capped,
|
|
@@ -400,6 +400,9 @@ export const etagOf = (entry) => `"${entry.revision?.id ?? "none"}"`;
|
|
|
400
400
|
export function definitionOf(agent, revision, version) {
|
|
401
401
|
const body = revision.body;
|
|
402
402
|
const common = { ...(body.maxCostUsd !== undefined ? { max_cost_usd: body.maxCostUsd } : {}), ...(body.maxRequests !== undefined ? { max_requests: body.maxRequests } : {}) };
|
|
403
|
+
// A revision saved before the computer setting keeps its place alone; one that names neither has no computer here
|
|
404
|
+
// (the host's default applies).
|
|
405
|
+
const computer = settingOfDefinition(body)?.computer;
|
|
403
406
|
const kindBody = revision.kind === "agentic"
|
|
404
407
|
? { instructions: body.instructions, ...(body.model ? { model: body.model } : {}), ...(body.modelTiers ? { model_tiers: body.modelTiers } : {}), ...(body.thinking ? { thinking: body.thinking } : {}), ...(learningSettingForBody(body) !== undefined ? { learning: learningSettingForBody(body) } : {}), ...(body.inputSchema !== undefined ? { input_schema: body.inputSchema } : {}), ...(body.outputSchema !== undefined ? { output_schema: body.outputSchema } : {}), ...(body.checkout !== undefined ? { checkout: body.checkout } : {}), ...common }
|
|
405
408
|
: { workflow: body.workflow, ...common };
|
|
@@ -416,9 +419,7 @@ export function definitionOf(agent, revision, version) {
|
|
|
416
419
|
approvals: approvalsOf(body.approvals),
|
|
417
420
|
harness: harnessOfBody(body),
|
|
418
421
|
...(body.place ? { place: body.place } : {}),
|
|
419
|
-
|
|
420
|
-
// setting keeps its place alone); none when it names neither (the host's default applies).
|
|
421
|
-
...(body.computer ? { computer: body.computer } : body.place ? { computer: computerOfPlace(body.place) } : {}),
|
|
422
|
+
...(computer ? { computer } : {}),
|
|
422
423
|
skills: skillNames(Object.keys(body.skills ?? {})),
|
|
423
424
|
tools: body.tools,
|
|
424
425
|
...(body.toolSettings ? { tool_settings: body.toolSettings } : {}),
|
|
@@ -442,7 +443,7 @@ export function agentView(entry, origin, extra = {}) {
|
|
|
442
443
|
revisions: entry.revisions,
|
|
443
444
|
source: null,
|
|
444
445
|
...(sourceSyncOf(body) ? { source_sync: { moved: true } } : {}),
|
|
445
|
-
// The
|
|
446
|
+
// The package its current revision came from (packageOf): the package's id, version and the commit an
|
|
446
447
|
// imported one was read at (null for a bundled one). Null for an agent made otherwise.
|
|
447
448
|
template: entry.template ? { id: entry.template.id, version: entry.template.version, sha: entry.template.sha ?? null } : null,
|
|
448
449
|
skills: Object.entries(body.skills ?? {}).map(([path, sha]) => ({ path, sha256: sha, size_bytes: entry.sizes.get(sha) ?? null })),
|
package/dist/api-only.d.ts
CHANGED
|
@@ -3,21 +3,32 @@ import type { Route } from "./server.js";
|
|
|
3
3
|
/** The routes (server.ts ROUTES, by name) an API-only server serves. Past a run's own, why each group is here:
|
|
4
4
|
* - a run's hosted machine fetches computerd with the token its create minted, not the server's;
|
|
5
5
|
* - the computers list and the Archil settings are read before a launch, naming keys, never a value;
|
|
6
|
-
* - an agent its inline runs made has its disk, its delete and its runs' purges sent by the backend that made it
|
|
7
|
-
* of an agent made here is
|
|
6
|
+
* - an agent its inline runs made has its disk, its delete and its runs' purges sent by the backend that made it. A run
|
|
7
|
+
* of an agent made here is purged too (deleteRun): the token may archive and delete that whole agent below, every
|
|
8
|
+
* run of it purged, so one run of it is no more;
|
|
8
9
|
* - a run's computer, take-over, hand-back and viewer link go to the backend, which has no owner's session here;
|
|
9
10
|
* - a backend reads what its agents learned (loop, promotions, cost per run, a run's learning), cut as the console's,
|
|
10
11
|
* and resets it (deleteAgentLearning: the agent and its runs kept) when it erases what an agent learned;
|
|
11
12
|
* - a run's usage lines (what its cost.usd joins, by meter) are a read of that run alone, cut as the run's read is;
|
|
12
13
|
* - an operator or a scaler reads the runners' capacity (getCapacity, capacity.ts) from the server whose runners run apart;
|
|
13
|
-
* - a backend
|
|
14
|
-
* credential, to hold back a job whose server isn't saved before its launch is refused for it;
|
|
14
|
+
* - a backend reads the saved MCP servers' names (listMcpServerNames), never a URL or a credential;
|
|
15
15
|
* - a backend uploads an agent's package (importTemplate, as {files} alone: a GitHub source is refused in this profile's
|
|
16
16
|
* words, template-import.ts), which an apply then makes into its agent;
|
|
17
17
|
* - a backend that deploys agents here applies their template, reads the agent and its revisions, moves its current
|
|
18
18
|
* revision back, and archives it before its delete (or unarchives it, the schedule and feed triggers its archive
|
|
19
|
-
* turned off on again when the server has the launch hook)
|
|
20
|
-
*
|
|
19
|
+
* turned off on again when the server has the launch hook). That is more than inline runs give its token: it makes
|
|
20
|
+
* agents and revisions that stay, archives and deletes any agent made here and purges any run of one, as the whole
|
|
21
|
+
* server's token does, and with the launch hook its apply makes schedule and feed triggers. A trigger the apply can't
|
|
22
|
+
* make here is skipped, and said (apiOnlyTriggerSkipped). One the agent had before the profile stays as it was:
|
|
23
|
+
* without the hook, an enabled one still fires here on this server's keys until the agent is archived;
|
|
24
|
+
* - an API-only server has no owner, so the token is the backend's own, as with take-over: it saves the Composio servers
|
|
25
|
+
* its agents need through the preset (saveComposioServer), saves over or deletes only a server it saved
|
|
26
|
+
* (mcp-secret-writes.ts tokenWriteOverRefused), and never writes a secret (secret-writes.ts). A Composio server names
|
|
27
|
+
* its key by api_key_env (COMPOSIO_API_KEY, on the launcher's list of secrets, read at each use through secrets.ts
|
|
28
|
+
* secret, sent to Composio's origin alone: composio-made.ts composioEnvKey), and its body names no address or headers.
|
|
29
|
+
* There is no list or read of the servers here (listMcpServerNames above is the listing), and no generic save (saveMcpServer), so the
|
|
30
|
+
* token saves no server at an address or with headers of its own. Previews, refreshes, sign-ins and Composio's
|
|
31
|
+
* triggers stay refused. */
|
|
21
32
|
export declare const API_ONLY_ROUTES: ReadonlySet<string>;
|
|
22
33
|
/** The trigger sources an apply on an API-only server makes once the server has the launch hook: the ones that fire on
|
|
23
34
|
* its own clock and need nothing a refused route sets up. Each firing goes to the backend in front of it
|
package/dist/api-only.js
CHANGED
|
@@ -1,32 +1,44 @@
|
|
|
1
1
|
// The API-only profile (AGENTRUN_API_ONLY=1): a server that runs behind its caller's backend serves the run routes and a
|
|
2
2
|
// deploy's routes alone, and refuses every other address before anything else reads the request: the console at "/" and
|
|
3
|
-
// its assets, sign-in and setup, settings
|
|
4
|
-
//
|
|
3
|
+
// its assets, sign-in and setup, settings but the MCP servers' names, a Composio server's save and the delete of a server
|
|
4
|
+
// (the secret-write gate lets the token save over or delete only a server it saved, mcp-secret-writes.ts), the MCP
|
|
5
|
+
// endpoint, triggers and their webhook hooks, the rest of agents and templates. Off by default.
|
|
5
6
|
import { API_ONLY_ENV } from "./env-switch.js";
|
|
6
7
|
import { NOT_SET_UP } from "./runnable.js";
|
|
7
8
|
import { LAUNCH_HOOK_SECRET_ENV, LAUNCH_HOOK_URL_ENV } from "./trigger-launch-hook.js";
|
|
8
9
|
/** The routes (server.ts ROUTES, by name) an API-only server serves. Past a run's own, why each group is here:
|
|
9
10
|
* - a run's hosted machine fetches computerd with the token its create minted, not the server's;
|
|
10
11
|
* - the computers list and the Archil settings are read before a launch, naming keys, never a value;
|
|
11
|
-
* - an agent its inline runs made has its disk, its delete and its runs' purges sent by the backend that made it
|
|
12
|
-
* of an agent made here is
|
|
12
|
+
* - an agent its inline runs made has its disk, its delete and its runs' purges sent by the backend that made it. A run
|
|
13
|
+
* of an agent made here is purged too (deleteRun): the token may archive and delete that whole agent below, every
|
|
14
|
+
* run of it purged, so one run of it is no more;
|
|
13
15
|
* - a run's computer, take-over, hand-back and viewer link go to the backend, which has no owner's session here;
|
|
14
16
|
* - a backend reads what its agents learned (loop, promotions, cost per run, a run's learning), cut as the console's,
|
|
15
17
|
* and resets it (deleteAgentLearning: the agent and its runs kept) when it erases what an agent learned;
|
|
16
18
|
* - a run's usage lines (what its cost.usd joins, by meter) are a read of that run alone, cut as the run's read is;
|
|
17
19
|
* - an operator or a scaler reads the runners' capacity (getCapacity, capacity.ts) from the server whose runners run apart;
|
|
18
|
-
* - a backend
|
|
19
|
-
* credential, to hold back a job whose server isn't saved before its launch is refused for it;
|
|
20
|
+
* - a backend reads the saved MCP servers' names (listMcpServerNames), never a URL or a credential;
|
|
20
21
|
* - a backend uploads an agent's package (importTemplate, as {files} alone: a GitHub source is refused in this profile's
|
|
21
22
|
* words, template-import.ts), which an apply then makes into its agent;
|
|
22
23
|
* - a backend that deploys agents here applies their template, reads the agent and its revisions, moves its current
|
|
23
24
|
* revision back, and archives it before its delete (or unarchives it, the schedule and feed triggers its archive
|
|
24
|
-
* turned off on again when the server has the launch hook)
|
|
25
|
-
*
|
|
25
|
+
* turned off on again when the server has the launch hook). That is more than inline runs give its token: it makes
|
|
26
|
+
* agents and revisions that stay, archives and deletes any agent made here and purges any run of one, as the whole
|
|
27
|
+
* server's token does, and with the launch hook its apply makes schedule and feed triggers. A trigger the apply can't
|
|
28
|
+
* make here is skipped, and said (apiOnlyTriggerSkipped). One the agent had before the profile stays as it was:
|
|
29
|
+
* without the hook, an enabled one still fires here on this server's keys until the agent is archived;
|
|
30
|
+
* - an API-only server has no owner, so the token is the backend's own, as with take-over: it saves the Composio servers
|
|
31
|
+
* its agents need through the preset (saveComposioServer), saves over or deletes only a server it saved
|
|
32
|
+
* (mcp-secret-writes.ts tokenWriteOverRefused), and never writes a secret (secret-writes.ts). A Composio server names
|
|
33
|
+
* its key by api_key_env (COMPOSIO_API_KEY, on the launcher's list of secrets, read at each use through secrets.ts
|
|
34
|
+
* secret, sent to Composio's origin alone: composio-made.ts composioEnvKey), and its body names no address or headers.
|
|
35
|
+
* There is no list or read of the servers here (listMcpServerNames above is the listing), and no generic save (saveMcpServer), so the
|
|
36
|
+
* token saves no server at an address or with headers of its own. Previews, refreshes, sign-ins and Composio's
|
|
37
|
+
* triggers stay refused. */
|
|
26
38
|
export const API_ONLY_ROUTES = new Set([
|
|
27
39
|
"createRun", "createInlineRun", "getComputerDaemon",
|
|
28
40
|
"getRunComputer", "takeOverRunComputer", "handBackRunComputer", "createRunComputerViewer",
|
|
29
|
-
"listComputers", "getWorkspaceArchil",
|
|
41
|
+
"listComputers", "listRunningComputers", "getWorkspaceArchil",
|
|
30
42
|
"getAgentArchil", "deleteAgentArchil", "deleteAgent", "deleteAgentLearning", "deleteRun",
|
|
31
43
|
"getLearningLoop", "listLearningPromotions", "getLearningCost", "getRunLearning",
|
|
32
44
|
"getRun", "getRunUsage", "listRuns", "listAllRuns", "getTimeline",
|
|
@@ -35,6 +47,7 @@ export const API_ONLY_ROUTES = new Set([
|
|
|
35
47
|
"createFile", "listFiles", "getFile", "uploadFile", "deleteFile",
|
|
36
48
|
"getCapabilities", "getHealth", "getUsage", "getCapacity", "listMcpServerNames",
|
|
37
49
|
"importTemplate", "applyTemplate", "getAgent", "listRevisions", "setCurrent", "archiveAgent", "unarchiveAgent",
|
|
50
|
+
"saveComposioServer", "deleteMcpServer",
|
|
38
51
|
]);
|
|
39
52
|
/** The trigger sources an apply on an API-only server makes once the server has the launch hook: the ones that fire on
|
|
40
53
|
* its own clock and need nothing a refused route sets up. Each firing goes to the backend in front of it
|
package/dist/cli.js
CHANGED
|
@@ -573,11 +573,13 @@ catch (error) {
|
|
|
573
573
|
}
|
|
574
574
|
if (early)
|
|
575
575
|
console.log(`Starting ${publicUrl ?? urlOf(early, values.listen ?? DEFAULT_HOST)}/ (warming: health says so and the API answers 503 until the server is ready)`);
|
|
576
|
-
const [{ fauxEnvOf, startServe }, { besideRunnerOptions, besideStopping, runnerBeside }, { startedWith }, { canOpen }] = await Promise.all([import("./server.js"), import("./runner/beside.js"), import("./adapters.js"), import("./host.js")]);
|
|
576
|
+
const [{ fauxEnvOf, startServe }, { besideRunnerOptions, besideStopping, runnerBeside }, { earlierDataRefusal, startedWith }, { canOpen }] = await Promise.all([import("./server.js"), import("./runner/beside.js"), import("./adapters.js"), import("./host.js")]);
|
|
577
577
|
// How it was started, for the hints that start it again (adapters.ts npxLine): itself and its runs read it.
|
|
578
578
|
Object.assign(process.env, startedWith({ ...(values.port !== undefined ? { port: values.port } : {}), open: values.open === true }));
|
|
579
579
|
let serve;
|
|
580
580
|
let serveOptions;
|
|
581
|
+
// The anonymous counts start once the server has (below); a feature used before then, in the start's first moment, is not counted.
|
|
582
|
+
let used;
|
|
581
583
|
const trustedProxies = (process.env.AGENTRUN_TRUSTED_PROXIES ?? "").split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
582
584
|
try {
|
|
583
585
|
serve = await startServe(serveOptions = {
|
|
@@ -587,6 +589,7 @@ try {
|
|
|
587
589
|
console.error(`agentrun-serve: ${error.message}`);
|
|
588
590
|
process.exit(1);
|
|
589
591
|
},
|
|
592
|
+
onUsage: (event) => used?.(event),
|
|
590
593
|
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"],
|
|
591
594
|
...(values["max-runs"] !== undefined ? { maxRuns: Number(values["max-runs"]) } : {}),
|
|
592
595
|
// The owner's harness modules: --harness-module, else AGENTRUN_SERVE_HARNESS_MODULES (harness-table.ts).
|
|
@@ -608,7 +611,9 @@ try {
|
|
|
608
611
|
});
|
|
609
612
|
}
|
|
610
613
|
catch (error) {
|
|
611
|
-
|
|
614
|
+
// A data directory an earlier version wrote, refused on a start `npx @parcha/agentrun` made: the ways on as that command
|
|
615
|
+
// (adapters.ts earlierDataRefusal). Any other start keeps the refusal's own words.
|
|
616
|
+
console.error(`agentrun-serve: ${earlierDataRefusal(error, data, process.env) ?? error.message}`);
|
|
612
617
|
process.exit(1);
|
|
613
618
|
}
|
|
614
619
|
// The start launches one runner beside the server on the same data dir (design: "server and runner"): it claims and runs
|
|
@@ -617,8 +622,10 @@ catch (error) {
|
|
|
617
622
|
// (besideRunnerOptions): at most --max-runs runs at once, the rest waiting queued, and on the stop each busy run finishes
|
|
618
623
|
// its turn for up to --drain-timeout.
|
|
619
624
|
let runnerProc;
|
|
620
|
-
// Anonymous usage counts (docs/telemetry.md). It hears each run's end from the runner beside the server
|
|
625
|
+
// Anonymous usage counts (docs/telemetry.md). It hears each run's end from the runner beside the server (with --no-runner it
|
|
626
|
+
// counts no runs), and each use of suggested agents from the server (onUsage).
|
|
621
627
|
const telemetry = startTelemetry({ data: resolve(data), ...(values.faux ? { faux: true } : {}) });
|
|
628
|
+
used = telemetry.used;
|
|
622
629
|
const { loops, loopsTold, drainMs } = besideRunnerOptions(serveOptions, process.env);
|
|
623
630
|
// A stop asked during the server's start starts no runner: nothing is claimed for the stop to cut.
|
|
624
631
|
if (!values["no-runner"] && askedAt === undefined) {
|
|
@@ -633,7 +640,7 @@ if (!values["no-runner"] && askedAt === undefined) {
|
|
|
633
640
|
// separate runners refuse it in words). Its runs reach an MCP server on loopback only when this server is a local
|
|
634
641
|
// install (Serve.localInstall).
|
|
635
642
|
// Each run a process of its own, as a user of its own where the image's helper can switch (run-child-host.ts).
|
|
636
|
-
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 });
|
|
643
|
+
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, ollamaHost: serve.ollamaHost, onRunEnded: telemetry.runEnded });
|
|
637
644
|
}
|
|
638
645
|
catch (error) {
|
|
639
646
|
// A run isolation the runner cannot give (run-child-host.ts runIsolationOf) is said, and the server serves on with no
|
package/dist/composio-made.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ export type Made = {
|
|
|
8
8
|
* under it. `per_run`: saved with `user_id: "per_run"` (COMPOSIO_PER_RUN), its address names no user and no account,
|
|
9
9
|
* and each run names its own (mcp_auth, composioPerRun); `user` is then that word and `accounts` empty. Only a save made
|
|
10
10
|
* since the mode exists writes it, so a server saved before for a Composio user literally named "per_run" keeps that
|
|
11
|
-
* user until it is saved again.
|
|
11
|
+
* user until it is saved again. `key_env`: saved with `api_key_env`, its key is the value of this variable the server and
|
|
12
|
+
* each runner were started with, read at each use, and its row seals no credential (composioKeyFromEnv). */
|
|
12
13
|
export type ComposioMade = {
|
|
13
14
|
user: string;
|
|
14
15
|
auth_config: (Made & {
|
|
@@ -16,7 +17,14 @@ export type ComposioMade = {
|
|
|
16
17
|
}) | null;
|
|
17
18
|
accounts: Made[];
|
|
18
19
|
per_run?: true;
|
|
20
|
+
key_env?: typeof COMPOSIO_KEY_ENV;
|
|
19
21
|
};
|
|
22
|
+
/** The one variable a Composio save may name for its key (`api_key_env`). Composio's host is fixed in code, so no other
|
|
23
|
+
* secret of the server's environment is ever sent there. */
|
|
24
|
+
export declare const COMPOSIO_KEY_ENV = "COMPOSIO_API_KEY";
|
|
25
|
+
/** Composio's origin: its API's base (composio-preset.ts) and where its MCP servers are (a preset save's address). The one
|
|
26
|
+
* place a key read from the environment is ever sent. */
|
|
27
|
+
export declare const COMPOSIO_ORIGIN = "https://backend.composio.dev";
|
|
20
28
|
/** What a delete does at Composio beyond the MCP server: what it removes, in order (the accounts before the auth config
|
|
21
29
|
* they are under), and what it keeps, each with whose it stays (`by`: the saved server that uses it too; none: this
|
|
22
30
|
* server didn't make it). */
|
|
@@ -52,6 +60,23 @@ export declare const composioPerRun: (row: {
|
|
|
52
60
|
* saved before over this row (`was`) or of another saved server (`others`) says was made here stays made here; and the
|
|
53
61
|
* accounts the server saved before had made, under the same auth config and user, stay its own. */
|
|
54
62
|
export declare function madeToWrite(found: ComposioMade, was: ComposioMade | undefined, others: readonly ComposioMade[]): ComposioMade;
|
|
63
|
+
/** The value of `name`, a server's key variable (ComposioMade.key_env), as this process (the server, or a runner) was
|
|
64
|
+
* handed it at its start: over the launcher's pipe, so its environment never holds it (secrets.ts secret; the launcher
|
|
65
|
+
* names it among its secrets). Trimmed; none when unset, blank or longer than any key. Read at each use, never kept. */
|
|
66
|
+
export declare function composioKeyFromEnv(name?: typeof COMPOSIO_KEY_ENV): string | undefined;
|
|
67
|
+
/** Why the server `server`, which reads its key from `name`, can't be used now: the variable is unset. */
|
|
68
|
+
export declare const composioKeyUnset: (server: string, name?: string) => string;
|
|
69
|
+
/** The key the server `server` (its address `url`) reads from `name`, its record's key_env, for a request to that address:
|
|
70
|
+
* the variable's value as this process was started with it (composioKeyFromEnv), only while the address is on Composio's origin (`origin`, COMPOSIO_ORIGIN; a test's fake
|
|
71
|
+
* through the server's and runner's seam). Otherwise why not, in words, and the caller sends nothing: `not_allowed`, an
|
|
72
|
+
* address no preset save writes (a row written by hand); `missing`, the variable unset. Every read of such a key for a
|
|
73
|
+
* request to the server's address goes through here: a save's and a refresh's listing, a run's start, a claim. */
|
|
74
|
+
export declare function composioEnvKey(server: string, url: string, name: typeof COMPOSIO_KEY_ENV, origin?: string): {
|
|
75
|
+
key: string;
|
|
76
|
+
} | {
|
|
77
|
+
refused: string;
|
|
78
|
+
reason: "not_allowed" | "missing";
|
|
79
|
+
};
|
|
55
80
|
/** The records of the other saved servers (`others`, by name) that say they made the auth config `id`, each as it is to
|
|
56
81
|
* be written once the owner named that config in a save: made by none of them, so none of their deletes removes it. */
|
|
57
82
|
export declare function releasedOf(id: string, others: readonly (readonly [string, ComposioMade, ...unknown[]])[]): [string, ComposioMade][];
|
package/dist/composio-made.js
CHANGED
|
@@ -9,7 +9,14 @@
|
|
|
9
9
|
// same with what the record it replaces made that the new one no longer stands on (droppedOf). An auth config the owner
|
|
10
10
|
// names in a save (auth_config_id) is the owner's from that save on, whoever made it: the record written says it was not
|
|
11
11
|
// made here, and every other record's claim to have made it is let go (releasedOf), so no delete or save removes it.
|
|
12
|
+
import { secret } from "./secrets.js";
|
|
12
13
|
import { isObject } from "./validate.js";
|
|
14
|
+
/** The one variable a Composio save may name for its key (`api_key_env`). Composio's host is fixed in code, so no other
|
|
15
|
+
* secret of the server's environment is ever sent there. */
|
|
16
|
+
export const COMPOSIO_KEY_ENV = "COMPOSIO_API_KEY";
|
|
17
|
+
/** Composio's origin: its API's base (composio-preset.ts) and where its MCP servers are (a preset save's address). The one
|
|
18
|
+
* place a key read from the environment is ever sent. */
|
|
19
|
+
export const COMPOSIO_ORIGIN = "https://backend.composio.dev";
|
|
13
20
|
/** The store.settings key a server's record lives under. */
|
|
14
21
|
export const composioMadeKey = (name) => `mcp.composio/${name}`;
|
|
15
22
|
/** The settings value a record is stored as, bound to the server row it was written for. */
|
|
@@ -25,7 +32,7 @@ export function recordedMade(value, createdAt) {
|
|
|
25
32
|
const accounts = value.accounts.map(thingOf);
|
|
26
33
|
if (config === undefined || accounts.some((account) => !account))
|
|
27
34
|
return undefined;
|
|
28
|
-
return { user: value.user, auth_config: config, accounts: accounts, ...(value.per_run === true ? { per_run: true } : {}) };
|
|
35
|
+
return { user: value.user, auth_config: config, accounts: accounts, ...(value.per_run === true ? { per_run: true } : {}), ...(value.key_env === COMPOSIO_KEY_ENV ? { key_env: COMPOSIO_KEY_ENV } : {}) };
|
|
29
36
|
}
|
|
30
37
|
/** Whether the saved server `row` is a per-run Composio server: auth headers (the install's sealed key) and its own
|
|
31
38
|
* record (`recorded`, read at composioMadeKey) saying per_run. Its runs call it as the Composio user and account each
|
|
@@ -44,7 +51,37 @@ export function madeToWrite(found, was, others) {
|
|
|
44
51
|
const config = found.auth_config && { id: found.auth_config.id, made: !found.auth_config.named && (found.auth_config.made || madeHere(found.auth_config.id)) };
|
|
45
52
|
const accounts = found.accounts.map((a) => ({ id: a.id, made: a.made || madeHere(a.id) }));
|
|
46
53
|
const kept = was && sharesAccounts(found, was) ? was.accounts.filter((a) => a.made && !accounts.some((b) => b.id === a.id)) : [];
|
|
47
|
-
return { user: found.user, auth_config: config, accounts: [...accounts, ...kept], ...(found.per_run ? { per_run: true } : {}) };
|
|
54
|
+
return { user: found.user, auth_config: config, accounts: [...accounts, ...kept], ...(found.per_run ? { per_run: true } : {}), ...(found.key_env ? { key_env: found.key_env } : {}) };
|
|
55
|
+
}
|
|
56
|
+
/** The value of `name`, a server's key variable (ComposioMade.key_env), as this process (the server, or a runner) was
|
|
57
|
+
* handed it at its start: over the launcher's pipe, so its environment never holds it (secrets.ts secret; the launcher
|
|
58
|
+
* names it among its secrets). Trimmed; none when unset, blank or longer than any key. Read at each use, never kept. */
|
|
59
|
+
export function composioKeyFromEnv(name = COMPOSIO_KEY_ENV) {
|
|
60
|
+
const value = secret(name)?.trim();
|
|
61
|
+
return value && value.length <= 8192 ? value : undefined;
|
|
62
|
+
}
|
|
63
|
+
/** Why the server `server`, which reads its key from `name`, can't be used now: the variable is unset. */
|
|
64
|
+
export const composioKeyUnset = (server, name = COMPOSIO_KEY_ENV) => `The MCP server ${server} reads its Composio key from the environment variable ${name}, which is not set: set it where AgentRun runs, then try again.`;
|
|
65
|
+
/** Why the server `server`, which reads its key from `name`, is never sent it: its address is not on Composio's origin. */
|
|
66
|
+
const composioKeyOffOrigin = (server, url, name, origin) => `The MCP server ${server} reads its Composio key from the environment variable ${name}, and its address (${originOf(url)}) is not Composio's (${origin}): that key is only ever sent to Composio. Save it again with the Composio preset.`;
|
|
67
|
+
const originOf = (url) => {
|
|
68
|
+
try {
|
|
69
|
+
return new URL(url).origin;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return "not a URL";
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
/** The key the server `server` (its address `url`) reads from `name`, its record's key_env, for a request to that address:
|
|
76
|
+
* the variable's value as this process was started with it (composioKeyFromEnv), only while the address is on Composio's origin (`origin`, COMPOSIO_ORIGIN; a test's fake
|
|
77
|
+
* through the server's and runner's seam). Otherwise why not, in words, and the caller sends nothing: `not_allowed`, an
|
|
78
|
+
* address no preset save writes (a row written by hand); `missing`, the variable unset. Every read of such a key for a
|
|
79
|
+
* request to the server's address goes through here: a save's and a refresh's listing, a run's start, a claim. */
|
|
80
|
+
export function composioEnvKey(server, url, name, origin = COMPOSIO_ORIGIN) {
|
|
81
|
+
if (originOf(url) !== new URL(origin).origin)
|
|
82
|
+
return { refused: composioKeyOffOrigin(server, url, name, origin), reason: "not_allowed" };
|
|
83
|
+
const key = composioKeyFromEnv(name);
|
|
84
|
+
return key ? { key } : { refused: composioKeyUnset(server, name), reason: "missing" };
|
|
48
85
|
}
|
|
49
86
|
/** The records of the other saved servers (`others`, by name) that say they made the auth config `id`, each as it is to
|
|
50
87
|
* be written once the owner named that config in a save: made by none of them, so none of their deletes removes it. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Cleanup, type ComposioMade } from "./composio-made.js";
|
|
2
2
|
import { type InputIssue } from "./errors.js";
|
|
3
3
|
import { type Json } from "./validate.js";
|
|
4
4
|
/** Another Composio than the real one, and its fetch: a test's fake (the same seam as `archilControl`). */
|
|
@@ -10,9 +10,10 @@ export type ComposioControl = {
|
|
|
10
10
|
export declare const COMPOSIO_USER = "agentrun";
|
|
11
11
|
/** A Composio toolkit's slug, as a save takes it once trimmed and lower-cased. */
|
|
12
12
|
export declare const COMPOSIO_TOOLKIT: RegExp;
|
|
13
|
-
/** A Composio user id, as a save's `user_id` and a run's binding
|
|
14
|
-
* a host names a team's connected accounts by a user such as `team:<tenant>`. */
|
|
13
|
+
/** A Composio user id, as a save's `user_id` and a run's binding take it. */
|
|
15
14
|
export declare const COMPOSIO_USER_ID: RegExp;
|
|
15
|
+
/** COMPOSIO_USER_ID in words, for the messages that refuse a user id. */
|
|
16
|
+
export declare const COMPOSIO_USER_ID_WORDS = "letters, digits and . _ @ : - (1 to 128)";
|
|
16
17
|
/** The `user_id` a save names for a per-run server, reserved for that and never a Composio user: the server keeps no user
|
|
17
18
|
* and no connected account, and each run names its own (mcp_auth.<server> = {composio_user_id, connected_account_id?}). */
|
|
18
19
|
export declare const COMPOSIO_PER_RUN = "per_run";
|
|
@@ -65,7 +66,8 @@ export declare const composioRunQuery: (binding: {
|
|
|
65
66
|
* the owner has, a custom OAuth app's say: read first, and refused unless it is this toolkit's and enabled), else the
|
|
66
67
|
* toolkit's Composio-managed one, found or made. `save` gets what the server stands on there too (`stands`,
|
|
67
68
|
* composio-made.ts): the auth config found or made and the account found or started, each marked whether this save made
|
|
68
|
-
* it, for its delete to remove what was made.
|
|
69
|
+
* it, for its delete to remove what was made. The key is the body's `api_key`, or COMPOSIO_API_KEY's value when the body
|
|
70
|
+
* sends `api_key_env` (head): then `stands.key_env` names it, and the store seals no credential. */
|
|
69
71
|
export declare function composioSave<T extends {
|
|
70
72
|
tools?: readonly {
|
|
71
73
|
name: string;
|