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