@parcha/agentrun-serve 0.1.0-beta.60 → 0.1.0-beta.62
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 +124 -0
- package/README.md +139 -22
- package/dist/acp-package.d.ts +4 -0
- package/dist/api-only.d.ts +23 -1
- package/dist/api-only.js +43 -4
- package/dist/archil-settings.d.ts +9 -0
- package/dist/archil-settings.js +8 -1
- package/dist/bash-read-only.d.ts +3 -0
- package/dist/bash-read-only.js +6 -3
- package/dist/browser-person.d.ts +1 -1
- package/dist/browser-person.js +1 -1
- package/dist/calendar/tools.js +1 -1
- package/dist/chatgpt-plan.d.ts +26 -8
- package/dist/chatgpt-plan.js +89 -21
- package/dist/claude-login.d.ts +12 -5
- package/dist/claude-login.js +28 -3
- package/dist/cli.js +61 -18
- package/dist/composio-triggers.d.ts +9 -3
- package/dist/computers.d.ts +3 -0
- package/dist/computers.js +2 -1
- package/dist/console/assets/{backend-QnwGVBeU.js → backend-DEgVn5lC.js} +1 -1
- package/dist/console/assets/index-CG5tELph.js +639 -0
- package/dist/console/assets/share-CIeFK2Oe.js +6 -0
- package/dist/console/assets/{styles-CcceGcu2.js → styles-BGZxYkky.js} +2 -2
- package/dist/console/assets/{styles-fjQBFfMv.css → styles-D0SufbzK.css} +1 -1
- package/dist/console/index.html +3 -3
- package/dist/console/share.html +3 -3
- package/dist/cut-pool.d.ts +14 -0
- package/dist/cut-pool.js +98 -0
- package/dist/cut-worker.d.ts +14 -0
- package/dist/cut-worker.js +16 -0
- package/dist/decisions.d.ts +4 -0
- package/dist/decisions.js +9 -1
- package/dist/env-switch.d.ts +3 -0
- package/dist/env-switch.js +3 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/harness-check.js +2 -1
- package/dist/harness-recipe.d.ts +13 -2
- package/dist/harness-recipe.js +30 -7
- package/dist/harness-sign-in.js +2 -1
- package/dist/harness-table.d.ts +12 -3
- package/dist/harness-table.js +13 -8
- package/dist/import.d.ts +8 -1
- package/dist/import.js +36 -5
- package/dist/key-check.js +22 -8
- package/dist/key-refusal.js +6 -4
- package/dist/learn/secrets.d.ts +2 -1
- package/dist/learn/secrets.js +2 -2
- package/dist/learned-nodes.d.ts +37 -0
- package/dist/learned-nodes.js +24 -0
- package/dist/local-model.d.ts +144 -0
- package/dist/local-model.js +214 -0
- package/dist/mcp-gateway.d.ts +24 -0
- package/dist/mcp-gateway.js +97 -8
- package/dist/mcp-probe.d.ts +7 -0
- package/dist/mcp-probe.js +7 -0
- package/dist/mcp-servers-store.d.ts +7 -10
- package/dist/mcp-servers-store.js +15 -9
- package/dist/native/cli.js +5 -1
- package/dist/ollama-provider.d.ts +42 -0
- package/dist/ollama-provider.js +118 -2
- package/dist/openapi.js +85 -16
- package/dist/otel/tracer.d.ts +6 -3
- package/dist/otel/tracer.js +24 -6
- package/dist/page.d.ts +7 -0
- package/dist/page.js +17 -4
- package/dist/place.d.ts +28 -11
- package/dist/place.js +43 -14
- package/dist/print.d.ts +3 -2
- package/dist/print.js +8 -6
- package/dist/redact/match.d.ts +17 -4
- package/dist/redact/match.js +57 -15
- package/dist/run-export.js +4 -2
- package/dist/run-launch.js +16 -3
- package/dist/run-model-key.d.ts +2 -1
- package/dist/run-model-key.js +2 -1
- package/dist/run-reads-over-store.d.ts +7 -0
- package/dist/run-reads-over-store.js +32 -4
- package/dist/run-usage.js +3 -2
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +16 -6
- package/dist/runner/adapter-loop.d.ts +8 -1
- package/dist/runner/adapter-loop.js +148 -29
- package/dist/runner/adapter-run-spec.d.ts +9 -6
- package/dist/runner/adapter-run-spec.js +38 -52
- package/dist/runner/adapters/index.d.ts +4 -0
- package/dist/runner/adapters/index.js +2 -1
- package/dist/runner/adapters/pi.d.ts +3 -2
- package/dist/runner/adapters/pi.js +3 -1
- package/dist/runner/audit.d.ts +1 -1
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +18 -7
- package/dist/runner/cli-run-spec.js +24 -17
- package/dist/runner/compare-end.d.ts +1 -1
- package/dist/runner/dispatch.js +4 -2
- package/dist/runner/harness-loops.d.ts +14 -0
- package/dist/runner/harness-loops.js +51 -5
- package/dist/runner/held.d.ts +4 -1
- package/dist/runner/live-ticker.js +5 -4
- package/dist/runner/loop-contract.d.ts +4 -1
- package/dist/runner/mcp-claim.js +3 -2
- package/dist/runner/mcp-run.d.ts +24 -4
- package/dist/runner/mcp-run.js +47 -2
- package/dist/runner/meta-tools.js +4 -4
- package/dist/runner/metrics.d.ts +6 -0
- package/dist/runner/metrics.js +12 -4
- package/dist/runner/monid-run.js +3 -1
- package/dist/runner/native-loop.js +3 -3
- package/dist/runner/redact.d.ts +3 -0
- package/dist/runner/redact.js +7 -0
- package/dist/runner/run-child-host.d.ts +10 -6
- package/dist/runner/run-child-host.js +44 -29
- package/dist/runner/run-child.js +1 -0
- package/dist/runner/runner.js +2 -0
- package/dist/runner/sdk-loop.js +5 -3
- package/dist/runner/workflow-calls.d.ts +5 -1
- package/dist/runner/workflow-calls.js +65 -19
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +3 -1
- package/dist/runner/workflow-spec.d.ts +4 -0
- package/dist/runner/workflow-spec.js +18 -13
- package/dist/runs-over-store.d.ts +2 -2
- package/dist/runs-over-store.js +1 -1
- package/dist/secret-cut.js +7 -4
- package/dist/secret-rules.d.ts +0 -1
- package/dist/secret-rules.js +122 -88
- package/dist/server.d.ts +17 -1
- package/dist/server.js +208 -69
- package/dist/share-host.d.ts +111 -0
- package/dist/share-host.js +666 -0
- package/dist/slack.js +2 -1
- package/dist/store/postgres/migrate.js +3 -1
- package/dist/store-reads/analytics.d.ts +15 -0
- package/dist/store-reads/analytics.js +17 -0
- package/dist/store-reads/learning.d.ts +5 -4
- package/dist/store-reads/learning.js +7 -4
- package/dist/suggestions.js +32 -3
- package/dist/templates.d.ts +3 -1
- package/dist/templates.js +7 -3
- package/dist/tool-gate.d.ts +25 -9
- package/dist/tool-gate.js +58 -19
- package/dist/tool-plane.d.ts +24 -1
- package/dist/tool-plane.js +75 -3
- package/dist/tools.d.ts +12 -2
- package/dist/tools.js +42 -7
- package/dist/trigger-composio.js +1 -1
- package/dist/trigger-launch-hook.d.ts +2 -2
- package/dist/trigger-launch-hook.js +1 -1
- package/dist/triggers.d.ts +7 -4
- package/dist/triggers.js +4 -4
- package/dist/webhooks.d.ts +3 -0
- package/dist/webhooks.js +5 -0
- package/dist/workspace/archil-claim.d.ts +7 -3
- package/dist/workspace/archil-claim.js +13 -5
- package/dist/workspace/archil-mount-credential.d.ts +6 -0
- package/dist/workspace/archil-mount-credential.js +11 -0
- package/dist/workspace/computer-deps.d.ts +5 -3
- package/dist/workspace/computer-deps.js +11 -9
- package/dist/workspace/computer-for-claim.d.ts +6 -2
- package/dist/workspace/computer-for-claim.js +43 -12
- package/dist/workspace/computer-janitor.d.ts +7 -4
- package/dist/workspace/computer-janitor.js +7 -4
- package/dist/workspace/computer-kept.d.ts +7 -1
- package/dist/workspace/computer-kept.js +7 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +12 -3
- package/dist/workspace/mount-revoke-left.d.ts +16 -4
- package/dist/workspace/mount-revoke-left.js +42 -22
- package/dist/workspace/resolve-computer.d.ts +11 -5
- package/dist/workspace/resolve-computer.js +22 -13
- package/dist/workspace/run-end-computers.js +1 -1
- package/dist/workspace/run-tools.d.ts +10 -3
- package/dist/workspace/run-tools.js +5 -4
- package/dist/wrapped.d.ts +29 -2
- package/dist/wrapped.js +20 -3
- package/launcher/agentrun-serve +1 -1
- package/package.json +12 -12
- package/dist/console/assets/index-DZi-muIj.js +0 -629
- package/dist/console/assets/share-pz61zIn9.js +0 -6
package/dist/slack.js
CHANGED
|
@@ -277,7 +277,8 @@ export function slackMessage(type, data, { agent, base }) {
|
|
|
277
277
|
const lines = [
|
|
278
278
|
`Trigger ${link(triggerUrl, name)} could not start its run${agent ? ` of ${who}` : ""}.`,
|
|
279
279
|
`\`${esc(code || "error")}\`${message ? `: ${esc(message)}` : ""}`,
|
|
280
|
-
|
|
280
|
+
// The console's way, the CLI's and the API's: a server with no console (the API-only profile) takes the last two.
|
|
281
|
+
...(data.auto_paused === true ? [`It failed too many times in a row, so it is off now: turn it on again in the console, with \`agentrun triggers update ${esc(str(data.trigger_id))} --enabled\`, or with \`PATCH /v2/triggers/${esc(str(data.trigger_id))}\` and \`{"enabled": true}\`.`] : []),
|
|
281
282
|
];
|
|
282
283
|
return {
|
|
283
284
|
text: esc(`Trigger ${name} could not start its run${code ? `: ${code}` : ""}`),
|
|
@@ -174,8 +174,10 @@ export async function migrate(client, schema, at, migrations = migrationsIn()) {
|
|
|
174
174
|
throw new SchemaVersionUnknown(placeOf(schema), top, known);
|
|
175
175
|
for (const row of applied) {
|
|
176
176
|
const mine = migrations[Number(row.version) - 1];
|
|
177
|
+
// Both files named, the schema's and this build's, so a migration renamed or renumbered on one side is plain.
|
|
177
178
|
if (mine && mine.sha256 !== row.sha256) {
|
|
178
|
-
|
|
179
|
+
const file = (version, name, sha256) => `${String(version).padStart(4, "0")}_${name}.sql (sha256 ${sha256.slice(0, 12)})`;
|
|
180
|
+
throw new Error(`${placeOf(schema)} applied ${file(row.version, row.name, row.sha256)} where this build has ${file(mine.version, mine.name, mine.sha256)}: an applied migration is never edited, renumbered or renamed, a change is a new file`);
|
|
179
181
|
}
|
|
180
182
|
}
|
|
181
183
|
for (const migration of migrations.slice(top ?? 0)) {
|
|
@@ -52,6 +52,21 @@ export type StoreAnalytics = {
|
|
|
52
52
|
calls: number;
|
|
53
53
|
errors: number;
|
|
54
54
|
}>;
|
|
55
|
+
/** The imported runs' cache, summed (import.ts RunCache): how many runs were analyzed, their cache read and whole
|
|
56
|
+
* prompt (the hit rate's parts), breaks by cause, extra cost by cause (USD) and unpriced breaks. A run imported
|
|
57
|
+
* before the import analyzed it, or of a source with no chain, is in no figure here. */
|
|
58
|
+
cache: StoredCache & {
|
|
59
|
+
runs: number;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/** A run's cache as the import keeps it in the run's metrics (import.ts RunCache). */
|
|
63
|
+
type StoredCache = {
|
|
64
|
+
read: number;
|
|
65
|
+
prompt: number;
|
|
66
|
+
breaks: Record<string, number>;
|
|
67
|
+
extraCost: Record<string, number>;
|
|
68
|
+
unpriced: number;
|
|
55
69
|
};
|
|
56
70
|
/** The runs and their metrics summed (the old AgentStoreReader.analytics), from A's run rows. */
|
|
57
71
|
export declare function analytics(store: Store, filter?: AnalyticsFilter): Promise<StoreAnalytics>;
|
|
72
|
+
export {};
|
|
@@ -168,6 +168,22 @@ export async function analytics(store, filter = {}) {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
const tools = [...calls.entries()].map(([tool, c]) => ({ tool, calls: c.calls, errors: c.errors })).sort((a, b) => b.calls - a.calls || (a.tool < b.tool ? -1 : a.tool > b.tool ? 1 : 0)).slice(0, 20);
|
|
171
|
+
// The cache over the runs in scope that keep one, ended (an import writes its run ended).
|
|
172
|
+
const cache = { runs: 0, read: 0, prompt: 0, breaks: {}, extraCost: {}, unpriced: 0 };
|
|
173
|
+
for (const f of notPending) {
|
|
174
|
+
const kept = f.metered ? f.metrics?.cache : undefined;
|
|
175
|
+
if (!kept || typeof kept !== "object")
|
|
176
|
+
continue;
|
|
177
|
+
cache.runs += 1;
|
|
178
|
+
cache.read += num(kept.read);
|
|
179
|
+
cache.prompt += num(kept.prompt);
|
|
180
|
+
cache.unpriced += num(kept.unpriced);
|
|
181
|
+
for (const [cause, n] of Object.entries(kept.breaks ?? {}))
|
|
182
|
+
cache.breaks[cause] = (cache.breaks[cause] ?? 0) + num(n);
|
|
183
|
+
// Summed in micro-dollars: USD figures of six places added as floats drift.
|
|
184
|
+
for (const [cause, usd] of Object.entries(kept.extraCost ?? {}))
|
|
185
|
+
cache.extraCost[cause] = Math.round(((cache.extraCost[cause] ?? 0) + num(usd)) * 1e6) / 1e6;
|
|
186
|
+
}
|
|
171
187
|
const totalsGroup = counted(facts);
|
|
172
188
|
return {
|
|
173
189
|
totals: { ...totalsGroup, input: unknownTokens.has('input') ? null : input, cacheRead: unknownTokens.has('cacheRead') ? null : cacheRead, cacheWrite: unknownTokens.has('cacheWrite') ? null : cacheWrite, output: unknownTokens.has('output') ? null : output, requests: unknownRequests ? null : requests, unmetered: unknownRequests ? null : unmetered },
|
|
@@ -176,5 +192,6 @@ export async function analytics(store, filter = {}) {
|
|
|
176
192
|
byDay,
|
|
177
193
|
bySource,
|
|
178
194
|
tools,
|
|
195
|
+
cache,
|
|
179
196
|
};
|
|
180
197
|
}
|
|
@@ -159,10 +159,11 @@ export declare const costStopOverStore: (store: Store, agentId: string) => Promi
|
|
|
159
159
|
* new answer is the agent's, with its digest. Else, for a run its launch offered a learned workflow, its timeline
|
|
160
160
|
* (runner/learning-end.ts runPathOf, the agent calling the tool itself): `workflow` when its job did only that,
|
|
161
161
|
* `handed_back` when the agent went on, with the workflow it called last that ran (its call's record,
|
|
162
|
-
* runner/workflow-calls.ts workflowCallsOf). Any other run's path is `agent
|
|
162
|
+
* runner/workflow-calls.ts workflowCallsOf). Any other run's path is `agent`, one whose learned calls were all refused
|
|
163
|
+
* included. Both read the run's rows less its feedback rounds' (withoutFeedbackRounds): a grade's
|
|
163
164
|
* round never moves the path. `cut` on a hand-back a restart cut (servedOf: the workflow's call ended `interrupted`),
|
|
164
165
|
* never one the workflow made itself. `entries`: the run's (runEntries), when the caller read them already. */
|
|
165
|
-
export declare function runPathOverStore(store: Store, runId: string, started: RunLaunch["learning"], redact
|
|
166
|
+
export declare function runPathOverStore(store: Store, runId: string, started: RunLaunch["learning"], redact: (text: string) => string, entries?: readonly EntryLike[]): Promise<{
|
|
166
167
|
path: RunPath;
|
|
167
168
|
workflow: string | null;
|
|
168
169
|
digest?: string;
|
|
@@ -174,8 +175,8 @@ export declare function runPathOverStore(store: Store, runId: string, started: R
|
|
|
174
175
|
* classified (runPathOverStore, for a run that learns) and kept with its calls (`workflow_calls`) and why its ending
|
|
175
176
|
* claim's first choice did or did not serve (`choice`, firstChoice's reason). `redact`: the run's cut, as its
|
|
176
177
|
* follow-up showed a served answer. */
|
|
177
|
-
export declare function runPathMetricsOverStore(store: Store, runId: string, launch: RunLaunch, { redact, choice }
|
|
178
|
-
readonly redact
|
|
178
|
+
export declare function runPathMetricsOverStore(store: Store, runId: string, launch: RunLaunch, { redact, choice }: {
|
|
179
|
+
readonly redact: (text: string) => string;
|
|
179
180
|
readonly choice?: FirstReason;
|
|
180
181
|
}): Promise<ReturnType<typeof pathMetrics>>;
|
|
181
182
|
/** The path a run's views say it took (GET /runs/{id} and each runs list row: `path`, and `workflow`), read off its record
|
|
@@ -476,7 +476,8 @@ export const costStopOverStore = async (store, agentId) => pastRunsOverStore(sto
|
|
|
476
476
|
* new answer is the agent's, with its digest. Else, for a run its launch offered a learned workflow, its timeline
|
|
477
477
|
* (runner/learning-end.ts runPathOf, the agent calling the tool itself): `workflow` when its job did only that,
|
|
478
478
|
* `handed_back` when the agent went on, with the workflow it called last that ran (its call's record,
|
|
479
|
-
* runner/workflow-calls.ts workflowCallsOf). Any other run's path is `agent
|
|
479
|
+
* runner/workflow-calls.ts workflowCallsOf). Any other run's path is `agent`, one whose learned calls were all refused
|
|
480
|
+
* included. Both read the run's rows less its feedback rounds' (withoutFeedbackRounds): a grade's
|
|
480
481
|
* round never moves the path. `cut` on a hand-back a restart cut (servedOf: the workflow's call ended `interrupted`),
|
|
481
482
|
* never one the workflow made itself. `entries`: the run's (runEntries), when the caller read them already. */
|
|
482
483
|
export async function runPathOverStore(store, runId, started, redact, entries) {
|
|
@@ -485,7 +486,9 @@ export async function runPathOverStore(store, runId, started, redact, entries) {
|
|
|
485
486
|
// the run is classified as the agent's own calls say.
|
|
486
487
|
const calls = workflowCallsOf(entries);
|
|
487
488
|
const served = calls.some((call) => call.caller === "platform" && call.outcome === "refused") ? undefined : servedOf(entries);
|
|
488
|
-
|
|
489
|
+
// A run offered no workflow, or whose every learned call was refused (none ran a node), is the agent's, whatever its
|
|
490
|
+
// timeline shows of the refused calls (runPathOf reads a call and the agent going on after it as a hand-back).
|
|
491
|
+
if (!served && (!started?.workflows?.length || (calls.length > 0 && calls.every((call) => call.outcome === "refused"))))
|
|
489
492
|
return { path: "agent", workflow: null };
|
|
490
493
|
// The path is who wrote the run's final answer, read on the job's own rows: a grade's feedback round asks the agent no
|
|
491
494
|
// turn of the job's, so its words and its rows never change it (withoutFeedbackRounds).
|
|
@@ -496,7 +499,7 @@ export async function runPathOverStore(store, runId, started, redact, entries) {
|
|
|
496
499
|
// The workflow's answer as it produced it (its journal's), and as a follow-up showed it to the agent (cut by the
|
|
497
500
|
// runner's `redact`, adapter-loop.ts servedAnswerText): an agent that says it again leaves the path the workflow's.
|
|
498
501
|
const answer = servedAnswerOf(entries)?.answer ?? "";
|
|
499
|
-
const alone = served.outcome === "answered" && servedAnswerStands(answer, rows, redact
|
|
502
|
+
const alone = served.outcome === "answered" && servedAnswerStands(answer, rows, redact(answer));
|
|
500
503
|
return { path: alone ? "workflow" : "handed_back", workflow: served.workflow, ...(served.digest ? { digest: served.digest } : {}), ...(served.promotion !== undefined ? { promotion: served.promotion } : {}), ...(served.cut ? { cut: true } : {}) };
|
|
501
504
|
}
|
|
502
505
|
const path = runPathOf(rows);
|
|
@@ -514,7 +517,7 @@ export async function runPathOverStore(store, runId, started, redact, entries) {
|
|
|
514
517
|
* classified (runPathOverStore, for a run that learns) and kept with its calls (`workflow_calls`) and why its ending
|
|
515
518
|
* claim's first choice did or did not serve (`choice`, firstChoice's reason). `redact`: the run's cut, as its
|
|
516
519
|
* follow-up showed a served answer. */
|
|
517
|
-
export async function runPathMetricsOverStore(store, runId, launch, { redact, choice }
|
|
520
|
+
export async function runPathMetricsOverStore(store, runId, launch, { redact, choice }) {
|
|
518
521
|
if (!launch.learning && !launch.audit)
|
|
519
522
|
return {};
|
|
520
523
|
const entries = await runEntries(store, runId, BACKGROUND_CONTEXT);
|
package/dist/suggestions.js
CHANGED
|
@@ -313,16 +313,29 @@ ${cjs ? "async function" : "export async function"} ${fn}(input${t(`: ${input}`)
|
|
|
313
313
|
// The address with or without /v2, as AgentRun's own clients and CLI take AGENTRUN_BASE_URL.
|
|
314
314
|
const url = (() => { try { return new URL(address); } catch { return undefined; } })();
|
|
315
315
|
if (!url || !/^https?:$/.test(url.protocol)) throw new Error("AGENTRUN_BASE_URL must be an http or https URL, like https://agentrun.example.com/v2.");
|
|
316
|
+
// A user, a password or a query may be a key, and fetch's errors print the whole URL: AgentRun's SDK takes none of them,
|
|
317
|
+
// nor a fragment, and neither does this, naming the origin alone.
|
|
318
|
+
if (url.username || url.password || /[?#]/.test(address)) throw new Error(\`AGENTRUN_BASE_URL takes no user, password, query or fragment, like https://agentrun.example.com/v2: \${url.origin}\`);
|
|
316
319
|
const base = url.pathname.split("/").includes("v2") ? address : \`\${address}/v2\`;
|
|
317
320
|
const headers = { authorization: \`Bearer \${key}\`, "content-type": "application/json" };
|
|
318
|
-
|
|
321
|
+
// No redirect is followed, as AgentRun's SDK follows none that leaves the base: a fetch other than Node's may carry the
|
|
322
|
+
// key's header to wherever one points. Its body is let go of first, so an unread one never holds the connection open.
|
|
323
|
+
const started = await fetch(\`\${base}/agents/\${encodeURIComponent(agent)}/runs\`, { method: "POST", headers, body: JSON.stringify({ input }), signal: options.signal, redirect: "manual" });
|
|
324
|
+
if (started.status >= 300 && started.status < 400) {
|
|
325
|
+
await started.body?.cancel().catch(() => undefined);
|
|
326
|
+
throw new Error(\`AgentRun answered POST with a redirect (HTTP \${started.status}); not followed, so the API key stays with AGENTRUN_BASE_URL.\`);
|
|
327
|
+
}
|
|
319
328
|
if (!started.ok) throw new Error(\`AgentRun did not start the ${s.key} agent (HTTP \${started.status}): \${await started.text()}\`);
|
|
320
329
|
let run = (await started.json())${t(" as Run")};
|
|
321
330
|
const until = Date.now() + (options.timeoutMs ?? 300_000);
|
|
322
331
|
while (!ENDED.includes(run.status)) {
|
|
323
332
|
if (Date.now() > until) throw new Error(\`The ${s.key} agent's run \${run.run_id} did not end in time.\`);
|
|
324
333
|
await new Promise((resolve) => setTimeout(resolve, 1_500));
|
|
325
|
-
const read = await fetch(\`\${base}/runs/\${encodeURIComponent(run.run_id)}\`, { headers, signal: options.signal });
|
|
334
|
+
const read = await fetch(\`\${base}/runs/\${encodeURIComponent(run.run_id)}\`, { headers, signal: options.signal, redirect: "manual" });
|
|
335
|
+
if (read.status >= 300 && read.status < 400) {
|
|
336
|
+
await read.body?.cancel().catch(() => undefined);
|
|
337
|
+
throw new Error(\`AgentRun answered GET with a redirect (HTTP \${read.status}); not followed, so the API key stays with AGENTRUN_BASE_URL.\`);
|
|
338
|
+
}
|
|
326
339
|
if (!read.ok) throw new Error(\`AgentRun did not read the run \${run.run_id} (HTTP \${read.status}).\`);
|
|
327
340
|
run = (await read.json())${t(" as Run")};
|
|
328
341
|
}
|
|
@@ -353,6 +366,7 @@ ${s.agent.output.map((f) => `# ${f.name}: ${oneLine(f.description)}`).join("\n
|
|
|
353
366
|
import json
|
|
354
367
|
import os
|
|
355
368
|
import time
|
|
369
|
+
import urllib.error
|
|
356
370
|
import urllib.parse
|
|
357
371
|
import urllib.request
|
|
358
372
|
from typing import Any, Dict, Optional, TypedDict
|
|
@@ -363,10 +377,20 @@ _REQUIRED = (${required.join(", ")}${required.length === 1 ? "," : ""})
|
|
|
363
377
|
_ENDED = {"completed", "failed", "cancelled", "input_required", "paused"}
|
|
364
378
|
|
|
365
379
|
|
|
380
|
+
# urllib copies the authorization header onto a redirect to any host, http included: no redirect is followed, so the key
|
|
381
|
+
# goes to AGENTRUN_BASE_URL alone, as AgentRun's SDK sends it.
|
|
382
|
+
class _NoRedirect(urllib.request.HTTPRedirectHandler):
|
|
383
|
+
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
|
384
|
+
raise urllib.error.HTTPError(req.full_url, code, f"AgentRun answered {req.get_method()} with a redirect (HTTP {code}); not followed, so the API key stays with AGENTRUN_BASE_URL", headers, fp)
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
_OPENER = urllib.request.build_opener(_NoRedirect)
|
|
388
|
+
|
|
389
|
+
|
|
366
390
|
def _call(method: str, url: str, key: str, body: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
|
367
391
|
data = json.dumps(body).encode("utf-8") if body is not None else None
|
|
368
392
|
request = urllib.request.Request(url, data=data, method=method, headers={"authorization": f"Bearer {key}", "content-type": "application/json"})
|
|
369
|
-
with
|
|
393
|
+
with _OPENER.open(request, timeout=60) as response:
|
|
370
394
|
return json.loads(response.read().decode("utf-8"))
|
|
371
395
|
|
|
372
396
|
|
|
@@ -387,6 +411,11 @@ def run_${py}(inputs: ${input}, timeout_s: float = 300.0) -> Dict[str, Any]:
|
|
|
387
411
|
url = None
|
|
388
412
|
if url is None or url.scheme not in ("http", "https") or not url.netloc:
|
|
389
413
|
raise RuntimeError("AGENTRUN_BASE_URL must be an http or https URL, like https://agentrun.example.com/v2.")
|
|
414
|
+
# A user, a password or a query may be a key, and an error may print the whole URL: AgentRun's SDK takes none of them,
|
|
415
|
+
# nor a fragment, and neither does this, naming the origin alone.
|
|
416
|
+
if "@" in url.netloc or "?" in address or "#" in address:
|
|
417
|
+
host = url.netloc.rpartition("@")[2].lower()
|
|
418
|
+
raise RuntimeError(f"AGENTRUN_BASE_URL takes no user, password, query or fragment, like https://agentrun.example.com/v2: {url.scheme}://{host}")
|
|
390
419
|
base = address if "v2" in url.path.split("/") else f"{address}/v2"
|
|
391
420
|
run = _call("POST", f"{base}/agents/{agent}/runs", key, {"input": fields})
|
|
392
421
|
until = time.monotonic() + timeout_s
|
package/dist/templates.d.ts
CHANGED
|
@@ -474,13 +474,15 @@ export type PickedSetting = {
|
|
|
474
474
|
needs?: string[];
|
|
475
475
|
};
|
|
476
476
|
/** The shell this server can give an agent now (server.ts shellHere): the computer setting that gives it, the shell
|
|
477
|
-
* tools a run there has (tools.ts shellTools), and the shell in words; else, `none`, why it has none
|
|
477
|
+
* tools a run there has (tools.ts shellTools), and the shell in words; else, `none`, why it has none, and `fix`, what to
|
|
478
|
+
* do where COMPUTER_FIX is not it (a Mode 2 server whose Archil region has no serverless exec). */
|
|
478
479
|
export type ShellHere = {
|
|
479
480
|
computer: PickedSetting;
|
|
480
481
|
tools: readonly string[];
|
|
481
482
|
words: string;
|
|
482
483
|
} | {
|
|
483
484
|
none: string;
|
|
485
|
+
fix?: string;
|
|
484
486
|
};
|
|
485
487
|
/** What a package's computer list picks here: the entry, the setting the agent is saved with, the shell in words (null
|
|
486
488
|
* for none), the package's shell tools that shell does not run (`dropped`, never granted), the shell tools a package
|
package/dist/templates.js
CHANGED
|
@@ -749,7 +749,10 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
749
749
|
bad(MANIFEST, learningIssue);
|
|
750
750
|
if (f.approvals !== undefined && f.approvals !== "ask" && f.approvals !== "never")
|
|
751
751
|
bad(MANIFEST, "approvals is ask (the agent asks its person before a tool runs) or never (it runs unattended; deny and pins still hold)");
|
|
752
|
-
const
|
|
752
|
+
const written = f.triggers === undefined ? [] : Array.isArray(f.triggers) ? f.triggers : (bad(MANIFEST, "triggers is a list of POST /v2/triggers bodies"), []);
|
|
753
|
+
// A composio trigger written with no config is for an event whose config needs no field (Slack's new channel): its
|
|
754
|
+
// config is the empty one, as POST /v2/triggers takes it.
|
|
755
|
+
const triggers = written.map((trigger) => (isObject(trigger) && isObject(trigger.source) && trigger.source.kind === "composio" && trigger.source.config === undefined ? { ...trigger, source: { ...trigger.source, config: {} } } : trigger));
|
|
753
756
|
const triggerNames = new Set();
|
|
754
757
|
triggers.forEach((trigger, i) => {
|
|
755
758
|
const target = isObject(trigger) ? trigger.target : undefined;
|
|
@@ -1294,6 +1297,7 @@ export function pickComputer(p, here) {
|
|
|
1294
1297
|
const clash = found && found.computer.kind === "sandbox" && runnerOnly.length ? `${found.words} runs ${runnerOnly.join(", ")} nowhere` : undefined;
|
|
1295
1298
|
const shell = clash ? undefined : found;
|
|
1296
1299
|
const lack = "none" in here ? here.none : clash ?? "this server has none";
|
|
1300
|
+
const fix = ("none" in here ? here.fix : undefined) ?? COMPUTER_FIX;
|
|
1297
1301
|
// A package that needs programs (its list is [shell] alone) takes a sandbox, whose box each run checks for them: a
|
|
1298
1302
|
// shell that is no sandbox (Archil's serverless exec runs on the runner, whose programs no run checks) is refused.
|
|
1299
1303
|
if (p.needs && !(shell && shell.computer.kind === "sandbox")) {
|
|
@@ -1303,12 +1307,12 @@ export function pickComputer(p, here) {
|
|
|
1303
1307
|
}
|
|
1304
1308
|
const entry = p.computer.find((one) => one === "none" || shell);
|
|
1305
1309
|
if (!entry)
|
|
1306
|
-
return { refused: `The ${p.name} template needs a shell, and ${lack}. Nothing was created
|
|
1310
|
+
return { refused: `The ${p.name} template needs a shell, and ${lack}. Nothing was created.`, ...(fix === COMPUTER_FIX ? {} : { fix }) };
|
|
1307
1311
|
const runs = entry === "shell" && shell ? shell.tools : [];
|
|
1308
1312
|
const dropped = (p.tools ?? []).filter((tool) => toolOf(tool)?.sandboxOnly && !runs.includes(tool));
|
|
1309
1313
|
const without = new Intl.ListFormat("en", { type: "conjunction" }).format(dropped);
|
|
1310
1314
|
const note = entry === "none" && p.computer[0] === "shell" && !shell
|
|
1311
|
-
? `${lack.charAt(0).toUpperCase()}${lack.slice(1)}, so the agent was made with the template's next choice, no computer${dropped.length ? `, and without ${without}` : ""}. ${
|
|
1315
|
+
? `${lack.charAt(0).toUpperCase()}${lack.slice(1)}, so the agent was made with the template's next choice, no computer${dropped.length ? `, and without ${without}` : ""}. ${fix}`
|
|
1312
1316
|
: dropped.length && shell ? `The shell here is ${shell.words}, which runs ${runs.join(", ")} alone, so the agent was made without ${without}.` : null;
|
|
1313
1317
|
return entry === "shell" && shell
|
|
1314
1318
|
? { entry, computer: { ...shell.computer, ...(p.needs ? { needs: [...p.needs] } : {}) }, shell: shell.words, dropped, defaults: [...shell.tools], note }
|
package/dist/tool-gate.d.ts
CHANGED
|
@@ -31,12 +31,14 @@ export declare function heldAs(name: string, args: unknown): {
|
|
|
31
31
|
readonly tool: string;
|
|
32
32
|
readonly args: unknown;
|
|
33
33
|
} | undefined;
|
|
34
|
-
/** Why
|
|
35
|
-
* given",
|
|
36
|
-
*
|
|
37
|
-
* approve (`approvers` false)
|
|
38
|
-
|
|
39
|
-
export
|
|
34
|
+
/** Why the gate refuses every call held to a tool whatever its arguments, or undefined where it may let one through:
|
|
35
|
+
* "not given", the tool needs `grant` among the agent's `tools` and it is not there (none given, none: leaving it out is
|
|
36
|
+
* how its owner keeps it, whatever its setting says); "denied", the tool's `permission` is deny; "no approver", it asks
|
|
37
|
+
* and no one can approve (`approvers` false); "policy", bash's policy refuses every call of it (RunGate.opBar alone).
|
|
38
|
+
* The one answer the run's gate refuses by and its files note and bound tools offer by. */
|
|
39
|
+
export type Bar = "not given" | "denied" | "policy" | "no approver";
|
|
40
|
+
/** Why a run can't write a file (a screenshot's save_as), or undefined where it can: barOf, write needing write. */
|
|
41
|
+
export declare const writeBar: (tools: readonly string[] | undefined, permission: Permission, approvers: boolean) => Bar | undefined;
|
|
40
42
|
/** A session's `{name -> settings key}` map (nameMapOf). */
|
|
41
43
|
export type NameMap = ReadonlyMap<string, string>;
|
|
42
44
|
/** Every name a session on `harness` gives its tools, to the settings key each is held to: the shell family (bash's),
|
|
@@ -248,7 +250,7 @@ export declare class RunGate {
|
|
|
248
250
|
runId: string;
|
|
249
251
|
harness?: string;
|
|
250
252
|
computer?: boolean; /** The run's computer kind (its revision's setting): the key a computer tool's refusal and ask name on a tie (kindSetting). */
|
|
251
|
-
kind?: string; /** The tools the agent is given (its revision's `tools`): a screenshot's save_as and a script's op
|
|
253
|
+
kind?: string; /** The tools the agent is given (its revision's `tools`): a screenshot's save_as is refused unless write is among them, and a script's file op unless its tool is (OP_GRANTS); none given, none. */
|
|
252
254
|
tools?: readonly string[];
|
|
253
255
|
effectOf?: (name: string) => ToolEffect | undefined; /** The arguments each MCP tool's listing in the run's pin declares (ClaimMcp.argumentsOf), for a pinned tool's closure (pinRefusal). */
|
|
254
256
|
argumentsOf?: ArgumentsOf; /** The harness's adapter facts on the owner's table (its native tools' names, nameMapOf); undefined for one with none. */
|
|
@@ -261,7 +263,19 @@ export declare class RunGate {
|
|
|
261
263
|
/** Why this run can't write a file now (writeBar over its agent's tools, write's permission and whether anyone can
|
|
262
264
|
* approve), or undefined where it can: what decide refuses a save_as or a script's write by, and what the run's files
|
|
263
265
|
* note and computer_screenshot's save_as are offered by. */
|
|
264
|
-
readonly writeBar: () =>
|
|
266
|
+
readonly writeBar: () => Bar | undefined;
|
|
267
|
+
/** Why this run's gate refuses the computer op `op` whatever its arguments, or undefined where it may let one through:
|
|
268
|
+
* its grant not given (OP_GRANTS), or the tool it is held to (OP_HELD_AS) set to deny, refused by bash's policy
|
|
269
|
+
* whatever its arguments, or set to an ask no one can approve, in decide's order: the grant first, then the held
|
|
270
|
+
* tool's setting and policy as on a computer (onComputer), the gate decide asks. An op held to no tool (apps, raw
|
|
271
|
+
* input) is the kind's, never barred here. */
|
|
272
|
+
private opBar;
|
|
273
|
+
/** The computer ops this run's gate refuses whatever their arguments (opBar): what computer_op's op list and a
|
|
274
|
+
* script's `computer` declarations leave out. */
|
|
275
|
+
readonly opsRefused: () => readonly string[];
|
|
276
|
+
/** The refusal of a call (`what`, in words) that needs `tool` among the agent's tools, for an agent not given it (none
|
|
277
|
+
* given, none); undefined for one given it, or for a call that needs no tool (`tool` undefined). */
|
|
278
|
+
private notGiven;
|
|
265
279
|
/** The gate's answer for one call before its intent, for a loop that parks and answers asks itself (the runner's adapter
|
|
266
280
|
* loops, pi's and the CLI harnesses'): run it, ask a person, or refuse it with the words the model reads. The order:
|
|
267
281
|
* the deny (with where it was set, and that nothing was sent or charged), a pin, bash's policy (policyRefusal), then
|
|
@@ -321,7 +335,9 @@ export declare class RunGate {
|
|
|
321
335
|
private pinned;
|
|
322
336
|
/** Why bash's policy refuses the call `name` (held to `key`) with `args` now, or undefined: the revision's own setting
|
|
323
337
|
* (an agent's tool_settings.bash.policy), so every shell tool under every harness's name for it is held to it. A policy
|
|
324
|
-
* this server does not know refuses every shell call (fail closed), as a pin that does not read does.
|
|
338
|
+
* this server does not know refuses every shell call (fail closed), as a pin that does not read does. With no `call`,
|
|
339
|
+
* only what refuses every call of it whatever its arguments (opBar): an unknown policy, or a shell tool the read-only
|
|
340
|
+
* policy never runs (readOnlyToolReason). */
|
|
325
341
|
private policyRefusal;
|
|
326
342
|
private lastGood?;
|
|
327
343
|
private readonly told;
|
package/dist/tool-gate.js
CHANGED
|
@@ -36,7 +36,7 @@ import { asksByDefault, isToolRow, tableTools } from "./tool-list.js";
|
|
|
36
36
|
import { CANT_BE_CALLED, computerOffText, computerOffWords, DENIED_OPENING, deniedText, NOT_RUN, RAN_UNKNOWN } from "./refusal-words.js";
|
|
37
37
|
import { approvalsOf } from "./approvals.js";
|
|
38
38
|
import { settingOfDefinition } from "./computer-setting.js";
|
|
39
|
-
import { BASH_POLICIES, readOnlyReason, readOnlyText } from "./bash-read-only.js";
|
|
39
|
+
import { BASH_POLICIES, readOnlyReason, readOnlyText, readOnlyToolReason } from "./bash-read-only.js";
|
|
40
40
|
import { formatToolName, isCatalogName, mcpNameOf, mcpToolName, monidNameOf } from "./tool-names.js";
|
|
41
41
|
/** What the gate does with a tool's calls. */
|
|
42
42
|
export const PERMISSIONS = ["allow", "ask", "deny"];
|
|
@@ -77,10 +77,17 @@ const KIND_TOOLS = (() => {
|
|
|
77
77
|
})();
|
|
78
78
|
/** A script's computer op (computer_op's `op`) that runs on the computer what one of the run's own tools runs, held to
|
|
79
79
|
* that tool's setting: the shell is bash's, a program started to run on (processes.start) bash_background's (bash's
|
|
80
|
-
* setting, and a read-only bash policy refuses it), a file's write is write's
|
|
81
|
-
*
|
|
82
|
-
*
|
|
80
|
+
* setting, and a read-only bash policy refuses it), a file's write is write's, a file's read, listing or stat is read's
|
|
81
|
+
* (each needing its tool among the agent's tools first, OP_GRANTS). The other ops (apps, raw input) are the computer
|
|
82
|
+
* kind's, computer_op's own key (KIND_TOOLS). */
|
|
83
83
|
const OP_HELD_AS = Object.freeze({ "shell.run": "bash", "processes.start": "bash_background", "files.write": "write", "files.read": "read", "files.list": "read", "files.stat": "read" });
|
|
84
|
+
/** The tool a computer op needs among the agent's tools (none given, none) before any setting of it is read, as the
|
|
85
|
+
* run's own file tools do: a file's write needs write, its read, listing or stat read. An op not here needs no grant:
|
|
86
|
+
* the shell's (shell.run, processes.start) follow bash's setting alone, and the others the kind's. A test holds every
|
|
87
|
+
* op of the kernel's files group to one (computer-op-grants.test.mjs). */
|
|
88
|
+
const OP_GRANTS = Object.freeze({ "files.write": "write", "files.read": "read", "files.list": "read", "files.stat": "read" });
|
|
89
|
+
/** The tool `op` needs among the agent's tools (OP_GRANTS), or undefined for one that needs none. */
|
|
90
|
+
const grantOf = (op) => (typeof op === "string" && Object.hasOwn(OP_GRANTS, op) ? OP_GRANTS[op] : undefined);
|
|
84
91
|
/** The ops whose command runs in the computer's shell. */
|
|
85
92
|
const SHELL_OPS = new Set(["shell.run", "processes.start"]);
|
|
86
93
|
/** The tool a call of `name` with `args` is held to, with the arguments that tool's gate reads, where it is not its own:
|
|
@@ -106,12 +113,14 @@ function savedAs(name, args) {
|
|
|
106
113
|
}
|
|
107
114
|
/** What a screenshot's refusal for write's setting adds to write's own words: why write's setting holds it. */
|
|
108
115
|
const SAVED_AS_WORDS = "computer_screenshot with save_as writes a file into the run's files, so write's setting holds it; a screenshot without save_as is not held to it.";
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
|
|
112
|
-
|
|
116
|
+
const barOf = (grant, tools, permission, approvers) => grant !== undefined && !tools?.includes(grant) ? "not given" : permission === "deny" ? "denied" : permission === "ask" && !approvers ? "no approver" : undefined;
|
|
117
|
+
/** Why a run can't write a file (a screenshot's save_as), or undefined where it can: barOf, write needing write. */
|
|
118
|
+
export const writeBar = (tools, permission, approvers) => barOf("write", tools, permission, approvers);
|
|
119
|
+
/** The refusal of a call (`what`, in words) that needs `tool` among the agent's tools, for an agent not given it
|
|
120
|
+
* (`instead`: what to do, or ""). */
|
|
121
|
+
const notGivenText = (what, tool, instead, ran) => `${DENIED_OPENING}${what} needs ${tool} among this agent's tools, and this agent is not given ${tool}.${instead ? ` ${instead}` : ""} ${ran === "no" ? NOT_RUN : RAN_UNKNOWN}`;
|
|
113
122
|
/** What a screenshot's save_as does, and what to do instead, in a not-given refusal. */
|
|
114
|
-
const SAVED_AS_WRITES = ["computer_screenshot with save_as writes a file into the run's files", "Take the screenshot without save_as."];
|
|
123
|
+
const SAVED_AS_WRITES = ["computer_screenshot with save_as (it writes a file into the run's files)", "Take the screenshot without save_as."];
|
|
115
124
|
const STRICTNESS = { allow: 0, ask: 1, deny: 2 };
|
|
116
125
|
/** Every name a session on `harness` gives its tools, to the settings key each is held to: the shell family (bash's),
|
|
117
126
|
* table, own and decision tools, read_skill_file (`read`), the kinds' tools (a shared one by its first kind), nativeTools,
|
|
@@ -418,6 +427,29 @@ export class RunGate {
|
|
|
418
427
|
* approve), or undefined where it can: what decide refuses a save_as or a script's write by, and what the run's files
|
|
419
428
|
* note and computer_screenshot's save_as are offered by. */
|
|
420
429
|
writeBar = () => writeBar(this.where.tools, this.policy("write"), this.approvers);
|
|
430
|
+
/** Why this run's gate refuses the computer op `op` whatever its arguments, or undefined where it may let one through:
|
|
431
|
+
* its grant not given (OP_GRANTS), or the tool it is held to (OP_HELD_AS) set to deny, refused by bash's policy
|
|
432
|
+
* whatever its arguments, or set to an ask no one can approve, in decide's order: the grant first, then the held
|
|
433
|
+
* tool's setting and policy as on a computer (onComputer), the gate decide asks. An op held to no tool (apps, raw
|
|
434
|
+
* input) is the kind's, never barred here. */
|
|
435
|
+
opBar(op) {
|
|
436
|
+
const held = Object.hasOwn(OP_HELD_AS, op) ? OP_HELD_AS[op] : undefined;
|
|
437
|
+
if (held === undefined)
|
|
438
|
+
return undefined;
|
|
439
|
+
const gate = this.onComputer();
|
|
440
|
+
const bar = barOf(grantOf(op), this.where.tools, gate.policy(held), this.approvers);
|
|
441
|
+
if (bar === "not given" || bar === "denied")
|
|
442
|
+
return bar;
|
|
443
|
+
return gate.policyRefusal(gate.keyOf(held) ?? held, held) !== undefined ? "policy" : bar;
|
|
444
|
+
}
|
|
445
|
+
/** The computer ops this run's gate refuses whatever their arguments (opBar): what computer_op's op list and a
|
|
446
|
+
* script's `computer` declarations leave out. */
|
|
447
|
+
opsRefused = () => Object.keys(OP_HELD_AS).filter((op) => this.opBar(op) !== undefined);
|
|
448
|
+
/** The refusal of a call (`what`, in words) that needs `tool` among the agent's tools, for an agent not given it (none
|
|
449
|
+
* given, none); undefined for one given it, or for a call that needs no tool (`tool` undefined). */
|
|
450
|
+
notGiven(tool, what, instead, ran) {
|
|
451
|
+
return tool !== undefined && !this.where.tools?.includes(tool) ? { deny: notGivenText(what, tool, instead, ran) } : undefined;
|
|
452
|
+
}
|
|
421
453
|
/** The gate's answer for one call before its intent, for a loop that parks and answers asks itself (the runner's adapter
|
|
422
454
|
* loops, pi's and the CLI harnesses'): run it, ask a person, or refuse it with the words the model reads. The order:
|
|
423
455
|
* the deny (with where it was set, and that nothing was sent or charged), a pin, bash's policy (policyRefusal), then
|
|
@@ -448,10 +480,14 @@ export class RunGate {
|
|
|
448
480
|
const own = this.computerOwns(name);
|
|
449
481
|
const held = heldAs(name, args);
|
|
450
482
|
if (held && this.policy(name) !== "deny") {
|
|
451
|
-
// An op
|
|
452
|
-
//
|
|
453
|
-
|
|
454
|
-
|
|
483
|
+
// An op that needs a tool among the agent's tools (OP_GRANTS: a file's write, read, listing or stat) is refused to
|
|
484
|
+
// an agent not given it first, on every computer, whatever that tool's setting says: no setting offers a tool the
|
|
485
|
+
// agent was not given. Past that, the held tool's own setting and bash's policy decide, a deny, a policy refusal or
|
|
486
|
+
// an ask no one can approve refused in its words: what opBar reads, so the offer (opsRefused) leaves out what this
|
|
487
|
+
// refuses whatever the arguments.
|
|
488
|
+
const op = args.op;
|
|
489
|
+
if (this.opBar(op) === "not given")
|
|
490
|
+
return { deny: notGivenText(`computer_op ${op}`, grantOf(op), "", ran) };
|
|
455
491
|
return this.onComputer().decide(held.tool, held.args, options);
|
|
456
492
|
}
|
|
457
493
|
const key = this.keyOf(name) ?? name;
|
|
@@ -468,7 +504,7 @@ export class RunGate {
|
|
|
468
504
|
const pinned = this.pinned(key, args, ran);
|
|
469
505
|
if (pinned)
|
|
470
506
|
return { deny: pinned.text };
|
|
471
|
-
const policed = this.policyRefusal(key, name, args);
|
|
507
|
+
const policed = this.policyRefusal(key, name, { args });
|
|
472
508
|
if (policed)
|
|
473
509
|
return { deny: policed };
|
|
474
510
|
// A screenshot saved into the run's files (save_as) is a file written as write writes one: write's setting holds it
|
|
@@ -477,8 +513,9 @@ export class RunGate {
|
|
|
477
513
|
// offers a tool the agent was not given (write's default is allow).
|
|
478
514
|
const saved = savedAs(name, args);
|
|
479
515
|
if (saved) {
|
|
480
|
-
|
|
481
|
-
|
|
516
|
+
const refused = this.notGiven("write", ...SAVED_AS_WRITES, ran);
|
|
517
|
+
if (refused)
|
|
518
|
+
return refused;
|
|
482
519
|
const write = await this.decide("write", saved, options);
|
|
483
520
|
if (typeof write === "object")
|
|
484
521
|
return { deny: `${write.deny} ${SAVED_AS_WORDS}` };
|
|
@@ -590,8 +627,10 @@ export class RunGate {
|
|
|
590
627
|
}
|
|
591
628
|
/** Why bash's policy refuses the call `name` (held to `key`) with `args` now, or undefined: the revision's own setting
|
|
592
629
|
* (an agent's tool_settings.bash.policy), so every shell tool under every harness's name for it is held to it. A policy
|
|
593
|
-
* this server does not know refuses every shell call (fail closed), as a pin that does not read does.
|
|
594
|
-
|
|
630
|
+
* this server does not know refuses every shell call (fail closed), as a pin that does not read does. With no `call`,
|
|
631
|
+
* only what refuses every call of it whatever its arguments (opBar): an unknown policy, or a shell tool the read-only
|
|
632
|
+
* policy never runs (readOnlyToolReason). */
|
|
633
|
+
policyRefusal(key, name, call) {
|
|
595
634
|
if (key !== "bash")
|
|
596
635
|
return undefined;
|
|
597
636
|
const policy = this.overrides.bash?.policy;
|
|
@@ -602,7 +641,7 @@ export class RunGate {
|
|
|
602
641
|
const tool = shellToolOf(name) ?? "bash";
|
|
603
642
|
if (!BASH_POLICIES.includes(policy))
|
|
604
643
|
return `${tool}${CANT_BE_CALLED}this agent's bash policy ${JSON.stringify(policy).slice(0, 60)} is not one this server knows (${BASH_POLICIES.join(", ")}), so no command is let through until its tool_settings name one. ${NOT_RUN}`;
|
|
605
|
-
const reason = readOnlyReason(tool, args, [this.where.work, COMPUTER_ROOT]);
|
|
644
|
+
const reason = call === undefined ? readOnlyToolReason(tool) : readOnlyReason(tool, call.args, [this.where.work, COMPUTER_ROOT]);
|
|
606
645
|
return reason === undefined ? undefined : readOnlyText(tool, reason, NOT_RUN);
|
|
607
646
|
}
|
|
608
647
|
lastGood;
|
package/dist/tool-plane.d.ts
CHANGED
|
@@ -145,10 +145,16 @@ export type ResolveInput = {
|
|
|
145
145
|
* none (and for pi, whose hosted search is asked of the model's provider). */
|
|
146
146
|
export declare const ownSearchViaOpenRouter: (env: NodeJS.ProcessEnv, harness: string, model?: string) => boolean;
|
|
147
147
|
export declare const FIRECRAWL_FETCH = "Firecrawl's free keyless fetch, no key, the guarded direct fetch behind it. web_fetch sends each URL to Firecrawl's keyless service (never a private or local one); choose kernel to fetch directly";
|
|
148
|
+
/** A capability a claim held to UNREAD_CEILINGS: it runs nothing, and says why without the store's words. */
|
|
149
|
+
export declare const SETTINGS_NOT_READ: Resolution;
|
|
150
|
+
/** A capability a claim found past a ceiling where today's resolution (planeFor) gives none in its place, as where its
|
|
151
|
+
* tool is not granted in today's tooling: it runs nothing, never the value it was kept with (claimPlane). */
|
|
152
|
+
export declare const CEILING_LEAVES_NONE: Resolution;
|
|
148
153
|
/** What `capability` resolves to on a run of `input`, and why in a plain sentence (capabilities' `why`): one rule, so
|
|
149
154
|
* the two never disagree. A web_search the run's own tool runs, and a web_fetch its own Web serves (any resolution but
|
|
150
155
|
* a deny), say what Jev does with it and what it sends TypeSafe, where the server has a Jev key, or that Jev is off
|
|
151
|
-
* (`jevWhy`, `jevFetchWhy`).
|
|
156
|
+
* (`jevWhy`, `jevFetchWhy`). An agent's pick the server's setting is a ceiling over (CEILINGS) resolves as the server's
|
|
157
|
+
* setting does, and the why says so. */
|
|
152
158
|
export declare function explainCapability(capability: Pickable, input: ResolveInput): {
|
|
153
159
|
resolves: Resolution;
|
|
154
160
|
why: string;
|
|
@@ -256,6 +262,22 @@ export declare function relaunchPlane(kept: Plane | undefined, env: NodeJS.Proce
|
|
|
256
262
|
capped?: boolean;
|
|
257
263
|
first?: boolean;
|
|
258
264
|
}): Plane;
|
|
265
|
+
/** Whether a capability of `kept` goes past a ceiling of the server's `settings` now (claimCeiling). */
|
|
266
|
+
export declare const overCeilings: (kept: Plane, tooling: Tooling, settings: ToolSettingsMap, { unread }?: {
|
|
267
|
+
unread?: boolean;
|
|
268
|
+
}) => boolean;
|
|
269
|
+
/** The Plane a claim hands its run (runner/harness-loops.ts, before anything binds): `kept`, the launch's (resolved at
|
|
270
|
+
* the run's start), under the server's `settings` now. A capability kept past a ceiling the server's setting now sets
|
|
271
|
+
* (claimCeiling) takes today's resolution (planeFor in `env` for `tooling`) on `model`, the run's pinned one (its
|
|
272
|
+
* launch's), so a resume, a follow-up or a reclaim sends nothing the setting keeps from it, and its native search asks
|
|
273
|
+
* the model the run sends. Where the settings could not be read (`unread`), one past the strictest ceiling runs nothing
|
|
274
|
+
* (SETTINGS_NOT_READ), and so does one today's resolution leaves without one (CEILING_LEAVES_NONE). Every other value
|
|
275
|
+
* stays as kept; the same Plane where nothing is past a ceiling. */
|
|
276
|
+
export declare function claimPlane(kept: Plane, env: NodeJS.ProcessEnv, tooling: Tooling, settings: ToolSettingsMap, { capped, model, unread }?: {
|
|
277
|
+
capped?: boolean;
|
|
278
|
+
model?: string;
|
|
279
|
+
unread?: boolean;
|
|
280
|
+
}): Plane;
|
|
259
281
|
/** The Plane the server handed this run's process; empty when it handed none. */
|
|
260
282
|
export declare function planeOf(env: NodeJS.ProcessEnv): Plane;
|
|
261
283
|
/** Whether a run is handed Parallel's key: one of its capabilities resolves to Parallel. */
|
|
@@ -352,6 +374,7 @@ export declare function agentTools(env: NodeJS.ProcessEnv, settings: ToolSetting
|
|
|
352
374
|
blurb?: string | undefined;
|
|
353
375
|
name: string;
|
|
354
376
|
} | {
|
|
377
|
+
ceiling?: string | undefined;
|
|
355
378
|
provider: string;
|
|
356
379
|
provider_from: string;
|
|
357
380
|
default_provider: string;
|