@parcha/agentrun-serve 0.1.0-beta.29 → 0.1.0-beta.31
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 +238 -0
- package/README.md +739 -116
- package/dist/adapters.d.ts +35 -6
- package/dist/adapters.js +152 -26
- package/dist/agents.d.ts +18 -7
- package/dist/agents.js +19 -10
- package/dist/app.js +101 -26
- package/dist/background.d.ts +29 -0
- package/dist/background.js +397 -0
- package/dist/box-egress-vm.d.ts +125 -0
- package/dist/box-egress-vm.js +350 -0
- package/dist/box-egress.d.ts +99 -0
- package/dist/box-egress.js +259 -0
- package/dist/box-image.d.ts +1 -1
- package/dist/box-image.js +9 -7
- package/dist/box-relay-vm.d.ts +84 -0
- package/dist/box-relay-vm.js +410 -0
- package/dist/box-relay.d.ts +8 -5
- package/dist/box-relay.js +14 -9
- package/dist/boxes.d.ts +28 -5
- package/dist/boxes.js +44 -18
- package/dist/browser-cost.d.ts +41 -0
- package/dist/browser-cost.js +158 -0
- package/dist/cap.d.ts +130 -21
- package/dist/cap.js +339 -67
- package/dist/cli.js +30 -4
- package/dist/coding-tools.d.ts +7 -3
- package/dist/coding-tools.js +16 -10
- package/dist/console/THIRD-PARTY-NOTICES.txt +580 -0
- package/dist/console/assets/index-CnJBf7Lc.js +486 -0
- package/dist/console/assets/index-DUHbWcIP.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-rows.d.ts +11 -3
- package/dist/decision-rows.js +18 -11
- package/dist/decisions.d.ts +3 -3
- package/dist/decisions.js +4 -3
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +5 -2
- package/dist/files.d.ts +9 -1
- package/dist/files.js +10 -2
- package/dist/grade.d.ts +11 -11
- package/dist/grade.js +43 -55
- package/dist/graph-served.d.ts +23 -0
- package/dist/graph-served.js +75 -0
- package/dist/graph-view.d.ts +7 -5
- package/dist/graph-view.js +10 -3
- package/dist/harness-app.d.ts +4 -2
- package/dist/harness-app.js +110 -19
- package/dist/harness-opencode/adapter.d.ts +45 -0
- package/dist/harness-opencode/adapter.js +272 -0
- package/dist/harness-opencode/binary.d.ts +18 -0
- package/dist/harness-opencode/binary.js +87 -0
- package/dist/harness-opencode/config.d.ts +24 -0
- package/dist/harness-opencode/config.js +61 -0
- package/dist/harness-opencode/harness.d.ts +77 -0
- package/dist/harness-opencode/harness.js +620 -0
- package/dist/harness-opencode/host/mcp.d.ts +40 -0
- package/dist/harness-opencode/host/mcp.js +208 -0
- package/dist/harness-opencode/host/policy.d.ts +71 -0
- package/dist/harness-opencode/host/policy.js +419 -0
- package/dist/harness-opencode/host/server.d.ts +55 -0
- package/dist/harness-opencode/host/server.js +165 -0
- package/dist/harness-opencode/index.d.ts +9 -0
- package/dist/harness-opencode/index.js +6 -0
- package/dist/harness-opencode/verify.d.ts +32 -0
- package/dist/harness-opencode/verify.js +75 -0
- package/dist/harness-opencode/versions.d.ts +33 -0
- package/dist/harness-opencode/versions.js +64 -0
- package/dist/harness.d.ts +4 -1
- package/dist/harness.js +5 -2
- package/dist/host-check.d.ts +12 -0
- package/dist/host-check.js +34 -0
- package/dist/host-tools.d.ts +12 -2
- package/dist/host-tools.js +26 -12
- package/dist/host.js +6 -2
- package/dist/hosted-search.js +5 -1
- package/dist/import.d.ts +2 -2
- package/dist/import.js +4 -3
- package/dist/key-check.d.ts +3 -2
- package/dist/key-check.js +7 -3
- package/dist/key-refusal.js +8 -4
- package/dist/key-words.d.ts +37 -0
- package/dist/key-words.js +40 -0
- package/dist/learn/check.d.ts +10 -1
- package/dist/learn/check.js +19 -1
- package/dist/learn/grade.d.ts +6 -2
- package/dist/learn/grade.js +28 -14
- package/dist/learn/index.d.ts +3 -3
- package/dist/learn/index.js +3 -3
- package/dist/learn/notes.js +2 -1
- package/dist/learn/reflect.d.ts +2 -2
- package/dist/learn/reflect.js +53 -5
- package/dist/learn/secrets.js +28 -8
- package/dist/learn/skills.d.ts +19 -4
- package/dist/learn/skills.js +95 -6
- package/dist/learned-workflow.d.ts +59 -0
- package/dist/learned-workflow.js +191 -0
- package/dist/learning-routes.d.ts +30 -1
- package/dist/learning-routes.js +173 -19
- package/dist/learning-run.d.ts +8 -6
- package/dist/learning-run.js +70 -27
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +34 -13
- package/dist/learning.d.ts +52 -3
- package/dist/learning.js +204 -4
- package/dist/mcp-gateway.d.ts +96 -0
- package/dist/mcp-gateway.js +408 -0
- package/dist/mcp-meta.d.ts +17 -0
- package/dist/mcp-meta.js +38 -0
- package/dist/mcp-servers.d.ts +33 -9
- package/dist/mcp-servers.js +58 -10
- package/dist/mcp.js +5 -5
- package/dist/model.d.ts +13 -11
- package/dist/model.js +11 -10
- package/dist/openapi/agentrun-v2.openapi.json +1 -0
- package/dist/openapi.js +407 -54
- package/dist/page.d.ts +2 -0
- package/dist/page.js +3 -0
- package/dist/paid-calls.d.ts +5 -1
- package/dist/paid-calls.js +1 -1
- package/dist/pause.d.ts +2 -0
- package/dist/place.d.ts +29 -5
- package/dist/place.js +51 -11
- package/dist/print.d.ts +7 -0
- package/dist/print.js +13 -0
- package/dist/propose.d.ts +2 -0
- package/dist/propose.js +38 -8
- package/dist/request-start.d.ts +12 -4
- package/dist/request-start.js +139 -15
- package/dist/run-box.d.ts +56 -4
- package/dist/run-box.js +183 -23
- package/dist/runnable.d.ts +13 -3
- package/dist/runnable.js +63 -6
- package/dist/runs.d.ts +266 -37
- package/dist/runs.js +884 -90
- package/dist/secrets.d.ts +27 -0
- package/dist/secrets.js +38 -2
- package/dist/server.d.ts +141 -36
- package/dist/server.js +562 -118
- package/dist/sign-ins.d.ts +99 -0
- package/dist/sign-ins.js +288 -0
- package/dist/skills.d.ts +16 -4
- package/dist/skills.js +35 -7
- package/dist/stats.d.ts +7 -2
- package/dist/stats.js +28 -7
- package/dist/tool-gate.d.ts +281 -0
- package/dist/tool-gate.js +585 -0
- package/dist/tool-keys.d.ts +48 -11
- package/dist/tool-keys.js +46 -8
- package/dist/tool-plane.d.ts +116 -27
- package/dist/tool-plane.js +232 -50
- package/dist/tools.d.ts +69 -14
- package/dist/tools.js +148 -26
- package/dist/trigger-secrets.d.ts +32 -0
- package/dist/trigger-secrets.js +143 -0
- package/dist/triggers.d.ts +439 -0
- package/dist/triggers.js +863 -0
- package/dist/turn-end.d.ts +3 -2
- package/dist/turn-end.js +3 -2
- package/dist/usage-lines.d.ts +26 -0
- package/dist/usage-lines.js +28 -0
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +11 -2
- package/dist/web-fetch.js +3 -3
- package/dist/webhooks.d.ts +11 -4
- package/dist/webhooks.js +17 -1
- package/launcher/agentrun-serve +1 -1
- package/package.json +16 -14
- package/dist/console/assets/index-BN7oVcO4.js +0 -445
- package/dist/console/assets/index-By-jkqki.css +0 -1
package/dist/tool-keys.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export declare const SEAL_KEY_ENV = "AGENTRUN_SEAL_KEY";
|
|
|
5
5
|
* and is kept the same way), and what it may unlock: tools by name, and `decisions.<id>`, a workflow's decision
|
|
6
6
|
* provider. GET lists only those this server binds (unlockedBy), so a name here the server does not bind is never
|
|
7
7
|
* promised, and one shows by itself once the server binds it. A `tool` key's fields reach only the runs that name a
|
|
8
|
-
* tool it unlocks (runs.ts' secretsFor); a key of any other kind (a model's) reaches every run.
|
|
8
|
+
* tool it unlocks (runs.ts' secretsFor); a key of any other kind (a model's) reaches every run. The tool rows live in
|
|
9
|
+
* key-words.ts (TOOL_KEY_ROWS), whose words name this page where a key is not set. */
|
|
9
10
|
export declare const TOOL_KEYS: readonly [{
|
|
10
11
|
readonly id: "parallel";
|
|
11
12
|
readonly kind: "tool";
|
|
@@ -24,6 +25,12 @@ export declare const TOOL_KEYS: readonly [{
|
|
|
24
25
|
readonly label: "Browserbase";
|
|
25
26
|
readonly fields: readonly ["BROWSERBASE_API_KEY", "BROWSERBASE_PROJECT_ID"];
|
|
26
27
|
readonly unlocks: readonly ["browser"];
|
|
28
|
+
}, {
|
|
29
|
+
readonly id: "kernel";
|
|
30
|
+
readonly kind: "tool";
|
|
31
|
+
readonly label: "Kernel";
|
|
32
|
+
readonly fields: readonly ["KERNEL_API_KEY"];
|
|
33
|
+
readonly unlocks: readonly ["browser"];
|
|
27
34
|
}, {
|
|
28
35
|
readonly id: "typesafe";
|
|
29
36
|
readonly kind: "tool";
|
|
@@ -36,7 +43,7 @@ export declare const TOOL_KEYS: readonly [{
|
|
|
36
43
|
label: "Anthropic" | "OpenAI" | "OpenRouter";
|
|
37
44
|
fields: readonly ["ANTHROPIC_API_KEY" | "OPENAI_API_KEY" | "OPENROUTER_API_KEY"];
|
|
38
45
|
unlocks: readonly [];
|
|
39
|
-
harnesses: readonly ["pi" | "claude-agent" | "codex", "claude-agent"] | readonly ["pi" | "claude-agent" | "codex", "codex"] | readonly ["pi" | "claude-agent" | "codex", "claude-agent", "codex"];
|
|
46
|
+
harnesses: readonly ["pi" | "claude-agent" | "codex" | "opencode", "claude-agent"] | readonly ["pi" | "claude-agent" | "codex" | "opencode", "codex", "opencode"] | readonly ["pi" | "claude-agent" | "codex" | "opencode", "claude-agent", "codex", "opencode"];
|
|
40
47
|
}[]];
|
|
41
48
|
/** The fields of the `tool` rows: keys a tool or a decision provider reads, and no harness (the harnesses read their
|
|
42
49
|
* packages, their pins and their models' keys). A row of another kind (a model's) is outside them. */
|
|
@@ -51,7 +58,7 @@ export declare function unlockedBy(candidates: readonly string[], tools: readonl
|
|
|
51
58
|
id: string;
|
|
52
59
|
}[]): {
|
|
53
60
|
unlocks: string[];
|
|
54
|
-
harnesses: ("pi" | "claude-agent" | "codex")[];
|
|
61
|
+
harnesses: ("pi" | "claude-agent" | "codex" | "opencode")[];
|
|
55
62
|
};
|
|
56
63
|
/** What a row unlocks here: a `tool` row's, its tools and providers as capabilities bind them (unlockedBy); any other
|
|
57
64
|
* kind's (a model's), no tool, on those that run on it (its `harnesses`, when it names them) that this server runs
|
|
@@ -69,13 +76,20 @@ export declare function rowUnlocks(row: {
|
|
|
69
76
|
keys?: readonly string[];
|
|
70
77
|
}[]): {
|
|
71
78
|
unlocks: string[];
|
|
72
|
-
harnesses: ("pi" | "claude-agent" | "codex")[];
|
|
79
|
+
harnesses: ("pi" | "claude-agent" | "codex" | "opencode")[];
|
|
73
80
|
};
|
|
74
81
|
/** The key that unlocks the tool `name` (capabilities' `tools[].key`, so a page links "needs the X key" to it), if any. */
|
|
75
82
|
export declare const keyOf: (name: string) => string | undefined;
|
|
76
83
|
/** Why a stored value does not open, in the order a re-entry names one: no seal key now, another than it was sealed
|
|
77
84
|
* under, or the file (or its entry) damaged. */
|
|
78
85
|
export declare const UNREADABLE: readonly ["seal_key_missing", "seal_key_changed", "file_unreadable"];
|
|
86
|
+
/** The check of a key the server was started with (ToolKeys.checkServer): a KeyCheck, or refused by its provider, why in
|
|
87
|
+
* plain words. Held in memory only, for this start. */
|
|
88
|
+
export type StartCheck = KeyCheck | {
|
|
89
|
+
state: "refused";
|
|
90
|
+
reason: string;
|
|
91
|
+
at: string;
|
|
92
|
+
};
|
|
79
93
|
/** The seal key `text` gives: 32 bytes in base64 (or base64url), else none. */
|
|
80
94
|
export declare function sealKeyOf(text: string | undefined): Buffer | undefined;
|
|
81
95
|
export declare class ToolKeys {
|
|
@@ -85,6 +99,8 @@ export declare class ToolKeys {
|
|
|
85
99
|
private readonly key;
|
|
86
100
|
private readonly sealCheck;
|
|
87
101
|
private said;
|
|
102
|
+
/** The checks of the keys the server was started with, by key id, each once it answered (checkServer). */
|
|
103
|
+
private readonly started;
|
|
88
104
|
/** `env` is what the server is started with (withSecrets' `"own"`, never a saved key, or each would read as the
|
|
89
105
|
* server's and could not be deleted): a field it sets is the server's, and wins. `say` takes a log line's fields. */
|
|
90
106
|
constructor(data: string, env: NodeJS.ProcessEnv, say: (fields: Record<string, string>) => void);
|
|
@@ -103,31 +119,52 @@ export declare class ToolKeys {
|
|
|
103
119
|
view(offers?: Parameters<typeof rowUnlocks>[3]): {
|
|
104
120
|
keys: {
|
|
105
121
|
fields: ({
|
|
106
|
-
name: "
|
|
122
|
+
name: "KERNEL_API_KEY" | "BROWSERBASE_API_KEY" | "BROWSERBASE_PROJECT_ID" | "TYPESAFE_API_KEY" | "PARALLEL_API_KEY" | "ANTHROPIC_API_KEY" | "OPENAI_API_KEY" | "OPENROUTER_API_KEY" | "MONID_API_KEY";
|
|
107
123
|
set: boolean;
|
|
108
124
|
source: "server";
|
|
109
125
|
} | {
|
|
110
|
-
name: "
|
|
126
|
+
name: "KERNEL_API_KEY" | "BROWSERBASE_API_KEY" | "BROWSERBASE_PROJECT_ID" | "TYPESAFE_API_KEY" | "PARALLEL_API_KEY" | "ANTHROPIC_API_KEY" | "OPENAI_API_KEY" | "OPENROUTER_API_KEY" | "MONID_API_KEY";
|
|
111
127
|
set: boolean;
|
|
112
128
|
source: "stored";
|
|
113
129
|
} | {
|
|
114
130
|
stored_unreadable?: true | undefined;
|
|
115
|
-
name: "
|
|
131
|
+
name: "KERNEL_API_KEY" | "BROWSERBASE_API_KEY" | "BROWSERBASE_PROJECT_ID" | "TYPESAFE_API_KEY" | "PARALLEL_API_KEY" | "ANTHROPIC_API_KEY" | "OPENAI_API_KEY" | "OPENROUTER_API_KEY" | "MONID_API_KEY";
|
|
116
132
|
set: boolean;
|
|
117
133
|
source: null;
|
|
118
134
|
})[];
|
|
119
|
-
check:
|
|
135
|
+
check: {
|
|
136
|
+
state: "accepted";
|
|
137
|
+
at: string;
|
|
138
|
+
} | {
|
|
139
|
+
state: "not_checked";
|
|
140
|
+
reason: string;
|
|
141
|
+
at?: string;
|
|
142
|
+
} | {
|
|
143
|
+
state: "refused";
|
|
144
|
+
reason: string;
|
|
145
|
+
at: string;
|
|
146
|
+
} | null;
|
|
120
147
|
unlocks: string[];
|
|
121
|
-
harnesses: ("pi" | "claude-agent" | "codex")[];
|
|
122
|
-
id: "anthropic" | "openai" | "typesafe" | "openrouter" | "parallel" | "
|
|
148
|
+
harnesses: ("pi" | "claude-agent" | "codex" | "opencode")[];
|
|
149
|
+
id: "browserbase" | "kernel" | "anthropic" | "openai" | "typesafe" | "openrouter" | "parallel" | "monid";
|
|
123
150
|
kind: "model" | "tool";
|
|
124
|
-
label: "Anthropic" | "OpenAI" | "OpenRouter" | "Parallel" | "Monid" | "Browserbase" | "TypeSafe (Jev)";
|
|
151
|
+
label: "Anthropic" | "OpenAI" | "OpenRouter" | "Parallel" | "Monid" | "Browserbase" | "Kernel" | "TypeSafe (Jev)";
|
|
125
152
|
}[];
|
|
126
153
|
reenter: {
|
|
127
154
|
reason: "seal_key_missing" | "seal_key_changed" | "file_unreadable";
|
|
128
155
|
fields: string[];
|
|
129
156
|
} | null;
|
|
130
157
|
};
|
|
158
|
+
/** Each tool key the server is started with (a `tool` row whose key, its first field, the server sets), checked against
|
|
159
|
+
* its provider once, as a saved one is (key-check.ts), through the fetch `fetchFor` gives for the row (null: not
|
|
160
|
+
* checked, its check stays null); all at once, none holding up another or the start. `answered` is called as each
|
|
161
|
+
* answers, unless `stop` (the server closing) came first. A fetch that cannot be made (a fake that does not load)
|
|
162
|
+
* reads as not checked, saying so; this never rejects. A model key is not checked here: a run on a refused one fails
|
|
163
|
+
* at its first request, saying so. */
|
|
164
|
+
checkServer(fetchFor: (id: string) => Promise<typeof fetch | null>, stop: AbortSignal, answered: () => void): Promise<void>;
|
|
165
|
+
/** The variables of the keys the server was started with that their provider refused at the start, each with why
|
|
166
|
+
* (capabilities' tools that need one read unavailable: tools.ts toolsView). */
|
|
167
|
+
refused(): Record<string, string>;
|
|
131
168
|
/** A PUT's check, before save(): the key it sends (its row's first field; Browserbase's project id is no key) checked
|
|
132
169
|
* against its provider (key-check.ts), the fetch `fetchFor` gives for the row (undefined: none, so not checked), its
|
|
133
170
|
* wait cut by `stop`. The body is held to what save() takes first, so a save that would be refused sends nothing. A
|
package/dist/tool-keys.js
CHANGED
|
@@ -21,6 +21,7 @@ import { HARNESSES } from "./harness.js";
|
|
|
21
21
|
import { checkKey } from "./key-check.js";
|
|
22
22
|
import { toolsView } from "./tools.js";
|
|
23
23
|
import { MODEL_KEYS } from "./model.js";
|
|
24
|
+
import { TOOL_KEY_ROWS } from "./key-words.js";
|
|
24
25
|
import { isObject, unknownFields } from "./validate.js";
|
|
25
26
|
export const TOOL_KEYS_FILE = "tool-keys.json";
|
|
26
27
|
export const SEAL_KEY_ENV = "AGENTRUN_SEAL_KEY";
|
|
@@ -31,15 +32,12 @@ const CONTROL = /[\u0000-\u001f\u007f-\u009f]/;
|
|
|
31
32
|
* and is kept the same way), and what it may unlock: tools by name, and `decisions.<id>`, a workflow's decision
|
|
32
33
|
* provider. GET lists only those this server binds (unlockedBy), so a name here the server does not bind is never
|
|
33
34
|
* promised, and one shows by itself once the server binds it. A `tool` key's fields reach only the runs that name a
|
|
34
|
-
* tool it unlocks (runs.ts' secretsFor); a key of any other kind (a model's) reaches every run.
|
|
35
|
+
* tool it unlocks (runs.ts' secretsFor); a key of any other kind (a model's) reaches every run. The tool rows live in
|
|
36
|
+
* key-words.ts (TOOL_KEY_ROWS), whose words name this page where a key is not set. */
|
|
35
37
|
export const TOOL_KEYS = [
|
|
36
|
-
|
|
37
|
-
{ id: "monid", kind: "tool", label: "Monid", fields: ["MONID_API_KEY"], unlocks: ["monid.discover", "monid.inspect", "monid.run"] },
|
|
38
|
-
{ id: "browserbase", kind: "tool", label: "Browserbase", fields: ["BROWSERBASE_API_KEY", "BROWSERBASE_PROJECT_ID"], unlocks: ["browser"] },
|
|
39
|
-
// Jev's decision provider (decisions.ts' `jev`), on TypeSafe's key: a workflow's judges, as Parallel's key unlocks its.
|
|
40
|
-
{ id: "typesafe", kind: "tool", label: "TypeSafe (Jev)", fields: ["TYPESAFE_API_KEY"], unlocks: ["decisions.jev"] },
|
|
38
|
+
...TOOL_KEY_ROWS,
|
|
41
39
|
// A model provider's key (model.ts' MODEL_KEYS, which give each its default model): every run gets it, as the
|
|
42
|
-
// launcher's model keys reach every run. Its harnesses are pi and
|
|
40
|
+
// launcher's model keys reach every run. Its harnesses are pi and those that talk to the provider's API (MODEL_KEYS).
|
|
43
41
|
...MODEL_KEYS.map(({ id, label, field, harnesses }) => ({ id, kind: "model", label, fields: [field], unlocks: [], harnesses })),
|
|
44
42
|
];
|
|
45
43
|
const FIELDS = TOOL_KEYS.flatMap((row) => row.fields);
|
|
@@ -92,6 +90,8 @@ export class ToolKeys {
|
|
|
92
90
|
key;
|
|
93
91
|
sealCheck;
|
|
94
92
|
said = "";
|
|
93
|
+
/** The checks of the keys the server was started with, by key id, each once it answered (checkServer). */
|
|
94
|
+
started = {};
|
|
95
95
|
/** `env` is what the server is started with (withSecrets' `"own"`, never a saved key, or each would read as the
|
|
96
96
|
* server's and could not be deleted): a field it sets is the server's, and wins. `say` takes a log line's fields. */
|
|
97
97
|
constructor(data, env, say) {
|
|
@@ -169,7 +169,7 @@ export class ToolKeys {
|
|
|
169
169
|
again.push({ name, why: opened.unreadable });
|
|
170
170
|
return { name, set: false, source: null, ...(opened ? { stored_unreadable: true } : {}) };
|
|
171
171
|
});
|
|
172
|
-
const check = fields[0].source === "stored" && kept !== "unreadable" ? (kept.checks[row.id] ?? UNCHECKED) : null;
|
|
172
|
+
const check = fields[0].source === "stored" && kept !== "unreadable" ? (kept.checks[row.id] ?? UNCHECKED) : fields[0].source === "server" ? (this.started[row.id] ?? null) : null;
|
|
173
173
|
return { id: row.id, kind: row.kind, label: row.label, ...rowUnlocks(row, tools, providers, offers), fields, check };
|
|
174
174
|
});
|
|
175
175
|
// A file that does not read as a whole names no field: which it held is unknown.
|
|
@@ -181,6 +181,44 @@ export class ToolKeys {
|
|
|
181
181
|
this.said = said;
|
|
182
182
|
return { keys, reenter };
|
|
183
183
|
}
|
|
184
|
+
/** Each tool key the server is started with (a `tool` row whose key, its first field, the server sets), checked against
|
|
185
|
+
* its provider once, as a saved one is (key-check.ts), through the fetch `fetchFor` gives for the row (null: not
|
|
186
|
+
* checked, its check stays null); all at once, none holding up another or the start. `answered` is called as each
|
|
187
|
+
* answers, unless `stop` (the server closing) came first. A fetch that cannot be made (a fake that does not load)
|
|
188
|
+
* reads as not checked, saying so; this never rejects. A model key is not checked here: a run on a refused one fails
|
|
189
|
+
* at its first request, saying so. */
|
|
190
|
+
async checkServer(fetchFor, stop, answered) {
|
|
191
|
+
await Promise.all(TOOL_KEYS.filter((row) => row.kind === "tool" && this.env[row.fields[0]]).map(async (row) => {
|
|
192
|
+
const name = row.fields[0];
|
|
193
|
+
let fetcher;
|
|
194
|
+
try {
|
|
195
|
+
fetcher = await fetchFor(row.id);
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
if (stop.aborted)
|
|
199
|
+
return;
|
|
200
|
+
const why = error?.code ?? error?.name ?? "an error";
|
|
201
|
+
this.started[row.id] = { state: "not_checked", reason: `${row.label}'s key could not be checked: its check did not start (${why})`, at: new Date().toISOString() };
|
|
202
|
+
answered();
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (!fetcher)
|
|
206
|
+
return;
|
|
207
|
+
const outcome = await checkKey(row, this.env[name], this.env, fetcher, undefined, stop, name).catch(() => undefined);
|
|
208
|
+
if (!outcome || stop.aborted)
|
|
209
|
+
return;
|
|
210
|
+
this.started[row.id] = outcome.state === "refused" ? { state: "refused", reason: `${outcome.message} when this server started: set the right one where AgentRun starts, then restart it`, at: new Date().toISOString() } : outcome;
|
|
211
|
+
answered();
|
|
212
|
+
}));
|
|
213
|
+
}
|
|
214
|
+
/** The variables of the keys the server was started with that their provider refused at the start, each with why
|
|
215
|
+
* (capabilities' tools that need one read unavailable: tools.ts toolsView). */
|
|
216
|
+
refused() {
|
|
217
|
+
return Object.fromEntries(TOOL_KEYS.flatMap((row) => {
|
|
218
|
+
const check = this.started[row.id];
|
|
219
|
+
return check?.state === "refused" ? [[row.fields[0], check.reason]] : [];
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
184
222
|
/** A PUT's check, before save(): the key it sends (its row's first field; Browserbase's project id is no key) checked
|
|
185
223
|
* against its provider (key-check.ts), the fetch `fetchFor` gives for the row (undefined: none, so not checked), its
|
|
186
224
|
* wait cut by `stop`. The body is held to what save() takes first, so a save that would be refused sends nothing. A
|
package/dist/tool-plane.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { InputIssue } from "./errors.js";
|
|
2
2
|
import { type HarnessId } from "./harness.js";
|
|
3
|
+
import { type Permission } from "./tool-gate.js";
|
|
3
4
|
/**
|
|
4
5
|
* The capabilities a pack or a revision may grant, by name: the tools the kernel gives a run, bound from serve's closed
|
|
5
6
|
* table (tools.ts) and named the same on every harness that runs them. `web_search` and `web_fetch` resolve to a
|
|
@@ -14,10 +15,13 @@ export type Capability = (typeof CAPABILITIES)[number];
|
|
|
14
15
|
* server holds its key, else keyless Exa; `native`, the harness's own tool or its model provider's hosted one, and
|
|
15
16
|
* nothing else; `exa-keyless`, Exa's public MCP endpoint, no key; `kernel`, the guarded direct fetch; `parallel`,
|
|
16
17
|
* Parallel's Search and Extract APIs on PARALLEL_API_KEY; `off`, web_search turned off: nothing is searched, and an
|
|
17
|
-
* agent naming it is refused until it is turned on again.
|
|
18
|
+
* agent naming it is refused until it is turned on again. The browser's: `auto`, Browserbase where the server holds its
|
|
19
|
+
* keys, else Kernel where it holds Kernel's; `browserbase` or `kernel`, that one alone; `chrome`, a Chrome on the
|
|
20
|
+
* server's own host, which no server sets up yet (browserBy). */
|
|
18
21
|
export declare const PROVIDERS: Readonly<{
|
|
19
22
|
readonly web_search: readonly ["auto", "native", "exa-keyless", "parallel", "off"];
|
|
20
23
|
readonly web_fetch: readonly ["kernel", "parallel"];
|
|
24
|
+
readonly browser: readonly ["auto", "browserbase", "kernel", "chrome"];
|
|
21
25
|
}>;
|
|
22
26
|
export type Pickable = keyof typeof PROVIDERS;
|
|
23
27
|
export declare const PICKABLE: Pickable[];
|
|
@@ -26,18 +30,37 @@ export declare const PICKABLE: Pickable[];
|
|
|
26
30
|
export declare const LEGACY_NAMES: Readonly<Record<string, Pickable>>;
|
|
27
31
|
/** The capability a granted name runs: its legacy target, else itself. */
|
|
28
32
|
export declare const capabilityOf: (name: string) => string;
|
|
29
|
-
/**
|
|
33
|
+
/** Every tool of serve's table (tools.ts) and its legacy names, by name, so this module needs no import of it: a test
|
|
34
|
+
* holds the two as one. */
|
|
35
|
+
export declare const TABLE_TOOLS: readonly string[];
|
|
36
|
+
/** The tools whose approved call the kernel runs itself, outside the model's turn (host-tools.ts's REPLAY): ask is
|
|
37
|
+
* offered for these and for catalog tools. Any other (browser, ask_person, the call-only ones) is allow or deny. The
|
|
38
|
+
* run's learned_workflow is one (tool-gate.ts runs an approved call of it on the run's own tools). */
|
|
39
|
+
export declare const ASKABLE: readonly string[];
|
|
40
|
+
/** The permissions `name` may be set to. */
|
|
41
|
+
export declare const permissionsOf: (name: string) => readonly Permission[];
|
|
42
|
+
/** The run's own tools beyond the table, each its own settings key, allowed by default like a table tool: the learned
|
|
43
|
+
* workflow a run's pin names runs as `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL). */
|
|
44
|
+
export declare const SERVE_OWN_TOOLS: readonly string[];
|
|
45
|
+
/** One tool's settings: its provider (a capability that has a choice) and its permission. */
|
|
30
46
|
export type ToolSetting = {
|
|
31
47
|
provider?: string;
|
|
48
|
+
permission?: Permission; /** Read as a stand-in for a value not offered (readToolSettings); never shown or written. */
|
|
49
|
+
fallback?: true; /** The stand-in's value as written in the file, which a save that keeps the stand-in writes back (ToolSettings.put). Never shown. */
|
|
50
|
+
raw?: unknown;
|
|
32
51
|
};
|
|
33
|
-
/** The settings
|
|
34
|
-
*
|
|
35
|
-
export type ToolSettingsMap = Partial<Record<
|
|
52
|
+
/** The tools' settings, the server's (`/v2/settings/tools`) and an agent's own (`definition.tool_settings`), one shape:
|
|
53
|
+
* by settings key. */
|
|
54
|
+
export type ToolSettingsMap = Partial<Record<string, ToolSetting>>;
|
|
36
55
|
/** What a capability resolves to on a run: the native tool, the kernel's own, keyless Exa, Parallel, or why not. */
|
|
37
|
-
export type Resolution = "native" | "kernel" | "exa-keyless" | "parallel" | `unavailable: ${string}`;
|
|
56
|
+
export type Resolution = "native" | "kernel" | "exa-keyless" | "parallel" | "browserbase" | `unavailable: ${string}`;
|
|
38
57
|
export declare const NO_PARALLEL_KEY: Resolution;
|
|
39
58
|
/** web_search with `off` picked: no search leaves the server. */
|
|
40
59
|
export declare const SEARCH_OFF: Resolution;
|
|
60
|
+
/** A capability set to deny: no provider is asked, and the gate refuses each call, so its run still starts. */
|
|
61
|
+
export declare const DENIED: Resolution;
|
|
62
|
+
/** `native` picked for a capability set to ask on a harness whose own search runs inside its CLI. */
|
|
63
|
+
export declare const NATIVE_ASKS: Resolution;
|
|
41
64
|
/** The model providers whose hosted web search pi's web_search asks (hosted-search.ts), by pi-ai's provider id. */
|
|
42
65
|
export declare const HOSTED_SEARCH_PROVIDERS: readonly string[];
|
|
43
66
|
/** A run's facts its capabilities resolve from. */
|
|
@@ -54,10 +77,14 @@ export type ResolveInput = {
|
|
|
54
77
|
/** The server holds PARALLEL_API_KEY; `parallelKeyFrom`, where from: its own environment, or saved on Tool keys. */
|
|
55
78
|
parallelKey: boolean;
|
|
56
79
|
parallelKeyFrom?: "server" | "saved";
|
|
80
|
+
/** Which of the browser's providers the server holds the keys of (BROWSER_KEYS); none given, neither. */
|
|
81
|
+
browserKeys?: Record<BrowserVendor, boolean>;
|
|
57
82
|
/** The run has a spend cap: Codex's own search sends a request with no input bound, which a cap cannot admit. */
|
|
58
83
|
capped?: boolean;
|
|
59
84
|
/** The harness's model requests go through OpenRouter (model.ts' viaOpenRouter), where its own search does not run. */
|
|
60
85
|
openRouter?: boolean;
|
|
86
|
+
/** Its permission in force (tool-gate.ts); absent, allow. */
|
|
87
|
+
permission?: Permission;
|
|
61
88
|
};
|
|
62
89
|
/** What `capability` resolves to on a run of `input`, and why in a plain sentence (capabilities' `why`): one rule, so
|
|
63
90
|
* the two never disagree. */
|
|
@@ -69,7 +96,22 @@ export declare function explainCapability(capability: Pickable, input: ResolveIn
|
|
|
69
96
|
export declare const resolveCapability: (capability: Pickable, input: ResolveInput) => Resolution;
|
|
70
97
|
export declare const isUnavailable: (resolution: Resolution | undefined) => resolution is `unavailable: ${string}`;
|
|
71
98
|
/** Why a resolution is unavailable: its words after "unavailable: " (any other resolution as it is). */
|
|
99
|
+
/** Why `resolution` is unavailable, in words. A vendor picked whose key this server does not hold (its value, kept in a
|
|
100
|
+
* run's meta and read back, names the variables) names where to save the key first, then the variable to set. */
|
|
72
101
|
export declare const whyUnavailable: (resolution: string) => string;
|
|
102
|
+
/** The keys each of the browser's vendors needs, by name: a tool key's fields (tool-keys.ts), set or saved. Its plane
|
|
103
|
+
* value is the vendor's id: `kernel` on browser is Kernel's hosted browser, never the guarded fetch web_fetch calls so. */
|
|
104
|
+
export declare const BROWSER_KEYS: Readonly<{
|
|
105
|
+
readonly browserbase: readonly ["BROWSERBASE_API_KEY", "BROWSERBASE_PROJECT_ID"];
|
|
106
|
+
readonly kernel: readonly ["KERNEL_API_KEY"];
|
|
107
|
+
}>;
|
|
108
|
+
type BrowserVendor = keyof typeof BROWSER_KEYS;
|
|
109
|
+
/** The keys a browser that resolves to `resolution` runs on: its vendor's (BROWSER_KEYS), none for no vendor. */
|
|
110
|
+
export declare const browserNeeds: (resolution: string | undefined) => readonly string[];
|
|
111
|
+
/** `auto` where the server holds neither vendor's keys. */
|
|
112
|
+
export declare const NO_BROWSER_KEY: Resolution;
|
|
113
|
+
/** `chrome` picked: a Chrome on the server's own host, refused by name until a server can set one up. */
|
|
114
|
+
export declare const NO_CHROME: Resolution;
|
|
73
115
|
/** Each pickable capability on each harness under the server's `settings` and an agent's `overrides`, on `model`
|
|
74
116
|
* (default each harness's host model, the one a run that names none runs on: hostModel): what it resolves to and why, as
|
|
75
117
|
* capabilities and the tool catalog show them. */
|
|
@@ -92,52 +134,99 @@ export type Tooling = {
|
|
|
92
134
|
};
|
|
93
135
|
/** The run's process's description of its tools' providers: JSON of its Plane. */
|
|
94
136
|
export declare const TOOL_PLANE_ENV = "AGENTRUN_SERVE_TOOL_PLANE";
|
|
95
|
-
/** The Plane of a run of `tooling`, in the server's `env` (with its secrets) under its `settings`.
|
|
96
|
-
|
|
137
|
+
/** The Plane of a run of `tooling`, in the server's `env` (with its secrets) under its `settings`. `run`: the Plane a
|
|
138
|
+
* run's process is handed, where a capability set to deny resolves as under ask (the provider a held call would use),
|
|
139
|
+
* since the gate refuses its calls while it is denied; else the one shown and checked, where it resolves denied. */
|
|
140
|
+
export declare function planeFor(env: NodeJS.ProcessEnv, tooling: Tooling, settings: ToolSettingsMap, { capped, run }?: {
|
|
141
|
+
capped?: boolean;
|
|
142
|
+
run?: boolean;
|
|
143
|
+
}): Plane;
|
|
144
|
+
/** A run's kept Plane at a later launch: as it was, but Parallel, or the browser's vendor, where the server no longer
|
|
145
|
+
* holds its key, which is unavailable, never another provider; and, given `now` (the Plane it would get today and each
|
|
146
|
+
* capability's permission today), a capability set to ask or deny, or kept denied, as it resolves today: a harness's
|
|
147
|
+
* own search cannot wait for a person, and a deny that was lifted is lifted. The browser keeps its vendor, whose
|
|
148
|
+
* sessions it has: only a deny it was kept with is lifted. */
|
|
149
|
+
export declare function recheckPlane(plane: Plane, env: NodeJS.ProcessEnv, now?: {
|
|
150
|
+
fresh: Plane;
|
|
151
|
+
permission: (name: Pickable) => Permission;
|
|
152
|
+
}): Plane;
|
|
153
|
+
/** The Plane kept for a run made before its plane was kept, resolved at a later launch (runs.ts): its browser stays
|
|
154
|
+
* Browserbase, the one vendor there was then, never today's pick, which could check its sessions at another vendor. It
|
|
155
|
+
* keeps the vendor, never a refusal: the plane each launch hands over is checked again (recheckPlane), so Browserbase's
|
|
156
|
+
* keys missing make it unavailable for that launch alone, and restored keys make the next one run. */
|
|
157
|
+
export declare const keptFromBefore: (plane: Plane) => Plane;
|
|
158
|
+
/** A run's saved Plane as a launch reads it: a vendor's missing-key refusal an earlier server saved (noBrowserKey's exact
|
|
159
|
+
* words, Browserbase's or Kernel's) is that vendor again, which the launch checks again as usual (recheckPlane), so
|
|
160
|
+
* restored keys make it run. Every other saved value stays as it is: `auto` with no key at a run's first launch
|
|
161
|
+
* (NO_BROWSER_KEY) and `chrome` stay frozen. The same Plane where nothing changes. */
|
|
162
|
+
export declare function keptVendor(plane: Plane): Plane;
|
|
163
|
+
/** The key row (tool-keys.ts) of the browser's vendor on `resolution` with `picked` the provider in force: Kernel's where
|
|
164
|
+
* Kernel is picked or resolved, else Browserbase's, so a page links a missing key to the row it is saved on. */
|
|
165
|
+
export declare const browserKeyRow: (picked: string | undefined, resolution: string | undefined) => "kernel" | "browserbase";
|
|
166
|
+
/** The Plane a run's process is handed at a launch, under the server's `settings` now: its kept Plane (as keptVendor
|
|
167
|
+
* reads it) checked again (recheckPlane) against the one it would get today; with none kept, today's, its browser kept
|
|
168
|
+
* (keptFromBefore). At a launch after its first (a relaunch, a follow-up's, one after a restart) a capability set
|
|
169
|
+
* to deny is handed denied (planeFor without `run`), the tool's own refusal backing the gate's; at its `first`, as
|
|
170
|
+
* under ask, so a deny lifted while that process lives is lifted at the next call. */
|
|
171
|
+
export declare function relaunchPlane(kept: Plane | undefined, env: NodeJS.ProcessEnv, tooling: Tooling | undefined, settings: ToolSettingsMap, { capped, first }?: {
|
|
97
172
|
capped?: boolean;
|
|
173
|
+
first?: boolean;
|
|
98
174
|
}): Plane;
|
|
99
|
-
/** A run's kept Plane at a later launch: as it was, but Parallel where the server no longer holds its key, which is
|
|
100
|
-
* unavailable, never another provider. */
|
|
101
|
-
export declare function recheckPlane(plane: Plane, env: NodeJS.ProcessEnv): Plane;
|
|
102
175
|
/** The Plane the server handed this run's process; empty when it handed none. */
|
|
103
176
|
export declare function planeOf(env: NodeJS.ProcessEnv): Plane;
|
|
104
177
|
/** Whether a run is handed Parallel's key: one of its capabilities resolves to Parallel. */
|
|
105
178
|
export declare const handsParallel: (plane: Plane) => boolean;
|
|
106
|
-
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
* choice to `{provider?}`, the provider one offered for it. */
|
|
179
|
+
/** The issues of `value` as a settings map, its fields under `at` (none: a body's own): each settings key (a tool of the
|
|
180
|
+
* table, a catalog tool, an MCP server's wildcard) to `{provider?, permission?}`, a provider only for a capability that
|
|
181
|
+
* has a choice and one offered for it, a permission one offered for the tool. */
|
|
110
182
|
export declare function settingsIssues(value: unknown, at?: string): InputIssue[];
|
|
111
|
-
/** `map` with each capability's provider, its default where none is picked. */
|
|
112
|
-
export declare const withDefaults: (map: ToolSettingsMap) => Record<Pickable, {
|
|
183
|
+
/** `map` with each capability's provider, its default where none is picked; a permission where one is set. */
|
|
184
|
+
export declare const withDefaults: (map: ToolSettingsMap) => ToolSettingsMap & Record<Pickable, {
|
|
113
185
|
provider: string;
|
|
186
|
+
permission?: Permission;
|
|
114
187
|
}>;
|
|
115
188
|
/** The server's tool settings, beside the agent store in its data directory: not a secret, and not in store.sqlite,
|
|
116
189
|
* which runs hold open. Read once at the start, written whole and durably (0600) at each PUT; a missing file is every
|
|
117
190
|
* default, and so is one it cannot read, which it says in one line. */
|
|
191
|
+
/** The tool settings in `dir` as the server and the tool gate read them, failing closed: each entry that reads is kept;
|
|
192
|
+
* one that does not is dropped, but a known tool keeps what of it reads, and its permission, when not one offered,
|
|
193
|
+
* reads ask (deny where ask is not offered), never its allow default. `problems`: one line for each entry dropped or
|
|
194
|
+
* changed, naming the file and the field, never a value. `unreadable`: the file as a whole does not read (none, a
|
|
195
|
+
* missing file is every default). */
|
|
196
|
+
export declare function readToolSettings(dir: string): {
|
|
197
|
+
settings: ToolSettingsMap;
|
|
198
|
+
problems: string[];
|
|
199
|
+
unreadable?: true;
|
|
200
|
+
};
|
|
118
201
|
export declare class ToolSettings {
|
|
119
202
|
private readonly dir;
|
|
120
203
|
static readonly FILE = "tool-settings.json";
|
|
121
204
|
private current;
|
|
122
205
|
constructor(dir: string, warn?: (line: string) => void);
|
|
123
206
|
get(): ToolSettingsMap;
|
|
124
|
-
/** Replaces the settings: a
|
|
207
|
+
/** Replaces the settings: a tool `map` leaves out takes its defaults. Durable before it returns. */
|
|
125
208
|
put(map: ToolSettingsMap): ToolSettingsMap;
|
|
126
209
|
}
|
|
127
|
-
/** GET /v2/agents/{id}'s `tools`: each tool its current revision grants, in `order` (capabilities.tools'),
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
210
|
+
/** GET /v2/agents/{id}'s `tools`: each tool its current revision grants, in `order` (capabilities.tools'), with its
|
|
211
|
+
* permission in force and where it came from (the agent's own settings, the server's, or the default), the one that
|
|
212
|
+
* applies when the agent sets none (the server's, else the default) and those it may be set to; and for one with a
|
|
213
|
+
* provider choice the provider in force and where it came from, the one that applies when the agent sets none, and what
|
|
214
|
+
* it resolves to on the agent's harness and model. */
|
|
131
215
|
export declare function agentTools(env: NodeJS.ProcessEnv, settings: ToolSettingsMap, agent: Tooling, order: readonly string[]): ({
|
|
216
|
+
permission: "ask" | "deny" | "allow";
|
|
217
|
+
permission_from: "default" | "agent" | "server";
|
|
218
|
+
default_permission: "ask" | "deny" | "allow";
|
|
219
|
+
permissions: ("ask" | "deny" | "allow")[];
|
|
132
220
|
name: string;
|
|
133
|
-
provider?: undefined;
|
|
134
|
-
provider_from?: undefined;
|
|
135
|
-
default_provider?: undefined;
|
|
136
|
-
resolved?: undefined;
|
|
137
221
|
} | {
|
|
138
|
-
name: string;
|
|
139
222
|
provider: string;
|
|
140
223
|
provider_from: string;
|
|
141
224
|
default_provider: string;
|
|
142
225
|
resolved: Resolution;
|
|
226
|
+
permission: "ask" | "deny" | "allow";
|
|
227
|
+
permission_from: "default" | "agent" | "server";
|
|
228
|
+
default_permission: "ask" | "deny" | "allow";
|
|
229
|
+
permissions: ("ask" | "deny" | "allow")[];
|
|
230
|
+
name: string;
|
|
143
231
|
})[];
|
|
232
|
+
export {};
|