@parcha/agentrun-serve 0.1.0-beta.56 → 0.1.0-beta.58
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 +281 -0
- package/README.md +246 -66
- package/dist/acp-package.d.ts +2 -0
- package/dist/adapters.d.ts +15 -3
- package/dist/adapters.js +17 -6
- package/dist/agent-package.d.ts +3 -3
- package/dist/agent-package.js +17 -8
- package/dist/api-keys.d.ts +76 -0
- package/dist/api-keys.js +217 -0
- package/dist/api-only.d.ts +15 -5
- package/dist/api-only.js +32 -8
- package/dist/box-paths.d.ts +4 -3
- package/dist/box-paths.js +7 -4
- package/dist/browser-hold.d.ts +23 -0
- package/dist/browser-hold.js +48 -0
- package/dist/browser-person.d.ts +3 -0
- package/dist/browser-person.js +4 -1
- package/dist/chatgpt-plan.d.ts +18 -8
- package/dist/chatgpt-plan.js +91 -34
- package/dist/claude-login-token.d.ts +117 -0
- package/dist/claude-login-token.js +737 -0
- package/dist/claude-login.d.ts +120 -22
- package/dist/claude-login.js +347 -63
- package/dist/claude-sign-in.d.ts +17 -6
- package/dist/claude-sign-in.js +42 -39
- package/dist/cli.js +33 -10
- package/dist/composio-made.d.ts +4 -0
- package/dist/composio-made.js +4 -0
- package/dist/composio-preset.d.ts +43 -2
- package/dist/composio-preset.js +92 -4
- package/dist/computer-attach.d.ts +35 -17
- package/dist/computer-attach.js +301 -49
- package/dist/computer-held-routes.d.ts +5 -4
- package/dist/computer-held-routes.js +29 -8
- package/dist/computer-held.d.ts +6 -1
- package/dist/computer-held.js +14 -0
- package/dist/computer-record.js +4 -2
- package/dist/computer-viewer.js +4 -1
- package/dist/computers.d.ts +10 -10
- package/dist/computers.js +5 -5
- package/dist/console/assets/{backend-Boh7tC4i.js → backend-CSAWUqtZ.js} +19 -19
- package/dist/console/assets/index-Bwn1oTem.css +1 -0
- package/dist/console/assets/index-DPh29cyz.js +747 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +1 -1
- package/dist/dial-relay.d.ts +25 -4
- package/dist/dial-relay.js +129 -1
- package/dist/docker-host-addresses.d.ts +22 -11
- package/dist/docker-host-addresses.js +38 -26
- package/dist/env-switch.d.ts +8 -0
- package/dist/env-switch.js +31 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +56 -20
- package/dist/fal-price.js +400 -90
- package/dist/handed-values.d.ts +43 -1
- package/dist/handed-values.js +119 -2
- package/dist/harness-archive.d.ts +13 -10
- package/dist/harness-archive.js +60 -34
- package/dist/harness-check.d.ts +3 -1
- package/dist/harness-check.js +25 -46
- package/dist/harness-keys.d.ts +73 -27
- package/dist/harness-keys.js +194 -61
- package/dist/harness-recipe-entry.d.ts +8 -7
- package/dist/harness-recipe-entry.js +21 -32
- package/dist/harness-recipe.d.ts +38 -25
- package/dist/harness-recipe.js +49 -36
- package/dist/harness-sign-in.js +12 -23
- package/dist/harness-table.d.ts +10 -3
- package/dist/harness-table.js +26 -21
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +17 -5
- package/dist/hosted-search.d.ts +1 -1
- package/dist/hosted-search.js +1 -2
- package/dist/import-worker.d.ts +4 -2
- package/dist/import-worker.js +9 -2
- package/dist/in-flight.d.ts +26 -0
- package/dist/in-flight.js +52 -0
- package/dist/key-refusal.d.ts +9 -4
- package/dist/key-refusal.js +107 -25
- package/dist/learn/ledger.d.ts +170 -0
- package/dist/learn/ledger.js +218 -0
- package/dist/learn/promote.d.ts +3 -3
- package/dist/learn/promote.js +1 -1
- package/dist/learn/secrets.d.ts +13 -3
- package/dist/learn/secrets.js +118 -17
- package/dist/learning-cost.d.ts +28 -23
- package/dist/learning-cost.js +19 -23
- package/dist/link-check.js +1 -1
- package/dist/live-reach.d.ts +2 -0
- package/dist/live-reach.js +2 -0
- package/dist/llms.txt +1 -1
- package/dist/marketplace.d.ts +77 -0
- package/dist/marketplace.js +224 -0
- package/dist/mcp-api-only-origins.d.ts +35 -0
- package/dist/mcp-api-only-origins.js +57 -0
- package/dist/mcp-gateway.d.ts +7 -5
- package/dist/mcp-gateway.js +9 -12
- package/dist/mcp-secret-writes.js +5 -3
- package/dist/mcp-servers-store.d.ts +28 -6
- package/dist/mcp-servers-store.js +53 -4
- package/dist/media-duration.d.ts +3 -0
- package/dist/media-duration.js +90 -9
- package/dist/micro.d.ts +2 -0
- package/dist/micro.js +2 -0
- package/dist/model-form.d.ts +5 -4
- package/dist/model-form.js +11 -7
- package/dist/model.d.ts +10 -6
- package/dist/model.js +16 -11
- package/dist/monid.d.ts +14 -1
- package/dist/monid.js +103 -26
- package/dist/ollama-provider.d.ts +7 -1
- package/dist/ollama-provider.js +14 -2
- package/dist/openapi.js +210 -37
- package/dist/otel/genai.d.ts +65 -0
- package/dist/otel/genai.js +116 -0
- package/dist/otel/tracer.d.ts +55 -0
- package/dist/otel/tracer.js +308 -0
- package/dist/page.d.ts +2 -0
- package/dist/page.js +3 -1
- package/dist/paid-calls.d.ts +1 -32
- package/dist/paid-calls.js +4 -39
- package/dist/place-offers.d.ts +4 -0
- package/dist/place-offers.js +7 -4
- package/dist/provider.d.ts +11 -2
- package/dist/provider.js +59 -8
- package/dist/redact/match.d.ts +30 -3
- package/dist/redact/match.js +422 -41
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +11 -0
- package/dist/run-census.d.ts +67 -0
- package/dist/run-census.js +240 -0
- package/dist/run-computer.d.ts +6 -3
- package/dist/run-computer.js +4 -1
- package/dist/run-cut.d.ts +15 -6
- package/dist/run-cut.js +30 -9
- package/dist/run-files.d.ts +3 -0
- package/dist/run-files.js +3 -0
- package/dist/run-launch.d.ts +12 -1
- package/dist/run-launch.js +9 -10
- package/dist/run-learning-served.d.ts +4 -2
- package/dist/run-model-key.d.ts +8 -0
- package/dist/run-model-key.js +31 -1
- package/dist/run-reads-over-store.d.ts +24 -6
- package/dist/run-reads-over-store.js +67 -23
- package/dist/run-recordings.d.ts +5 -1
- package/dist/run-recordings.js +39 -14
- package/dist/run-timeline-served.d.ts +2 -0
- package/dist/run-timeline-served.js +2 -2
- package/dist/run-usage.d.ts +1 -0
- package/dist/run-view.d.ts +1 -2
- package/dist/run-view.js +2 -1
- package/dist/runnable.d.ts +10 -1
- package/dist/runnable.js +20 -8
- package/dist/runner/adapter-loop.d.ts +11 -0
- package/dist/runner/adapter-loop.js +58 -26
- package/dist/runner/adapter-run-spec.d.ts +55 -11
- package/dist/runner/adapter-run-spec.js +183 -52
- package/dist/runner/adapters/pi.js +25 -3
- package/dist/runner/beside.d.ts +9 -2
- package/dist/runner/beside.js +27 -9
- package/dist/runner/big-writes.js +1 -10
- package/dist/runner/claim-secrets.d.ts +27 -10
- package/dist/runner/claim-secrets.js +49 -22
- package/dist/runner/cli-run-spec.d.ts +6 -0
- package/dist/runner/cli-run-spec.js +97 -38
- package/dist/runner/computer-journal.d.ts +9 -1
- package/dist/runner/computer-journal.js +26 -0
- package/dist/runner/conformance/harness.js +1 -1
- package/dist/runner/feedback-round.js +3 -0
- package/dist/runner/harness-loops.d.ts +6 -5
- package/dist/runner/harness-loops.js +7 -7
- package/dist/runner/held.d.ts +24 -6
- package/dist/runner/journal-kinds.d.ts +5 -0
- package/dist/runner/journal-kinds.js +5 -0
- package/dist/runner/main.d.ts +11 -6
- package/dist/runner/main.js +19 -9
- package/dist/runner/mcp-claim.js +31 -3
- package/dist/runner/mcp-run.d.ts +9 -0
- package/dist/runner/mcp-run.js +11 -5
- package/dist/runner/model-route.d.ts +17 -0
- package/dist/runner/model-route.js +120 -2
- package/dist/runner/presence.d.ts +11 -1
- package/dist/runner/presence.js +7 -0
- package/dist/runner/reflect-hook.js +1 -1
- package/dist/runner/run-child-host.d.ts +22 -8
- package/dist/runner/run-child-host.js +128 -41
- package/dist/runner/run-child.js +5 -2
- package/dist/runner/runner.d.ts +17 -3
- package/dist/runner/runner.js +130 -34
- package/dist/runner/save-slots.js +2 -1
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +6 -0
- package/dist/runner/store-secrets.js +49 -7
- package/dist/runner/subagent.d.ts +11 -0
- package/dist/runner/subagent.js +16 -38
- package/dist/runner/workflow-first.d.ts +35 -15
- package/dist/runner/workflow-first.js +38 -25
- package/dist/runner/workflow-spec.js +4 -3
- package/dist/runs-over-store.d.ts +15 -6
- package/dist/runs-over-store.js +33 -21
- package/dist/scrub-command.d.ts +73 -0
- package/dist/scrub-command.js +307 -0
- package/dist/secret-cut.d.ts +73 -0
- package/dist/secret-cut.js +291 -4
- package/dist/secret-rules.d.ts +143 -0
- package/dist/secret-rules.js +2564 -0
- package/dist/secrets.d.ts +7 -0
- package/dist/secrets.js +20 -0
- package/dist/server-keys.d.ts +20 -0
- package/dist/server-keys.js +25 -6
- package/dist/server.d.ts +65 -13
- package/dist/server.js +470 -157
- package/dist/skills/agentrun-serve/SKILL.md +4 -0
- package/dist/slots.d.ts +9 -0
- package/dist/slots.js +45 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +1 -1
- package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
- package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
- package/dist/store/schema.d.ts +23 -0
- package/dist/store/schema.js +58 -2
- package/dist/store/seal.d.ts +6 -1
- package/dist/store/seal.js +5 -3
- package/dist/store/sqlite/run-launch.d.ts +9 -1
- package/dist/store/sqlite/run-launch.js +24 -13
- package/dist/store/sqlite/run-patch.d.ts +12 -2
- package/dist/store/sqlite/run-patch.js +42 -5
- package/dist/store/sqlite/store.js +105 -12
- package/dist/store/store.d.ts +57 -2
- package/dist/store/store.js +20 -0
- package/dist/store-reads/learning.d.ts +84 -124
- package/dist/store-reads/learning.js +210 -274
- package/dist/store-view.d.ts +3 -0
- package/dist/store-view.js +3 -3
- package/dist/suggestions.js +3 -2
- package/dist/template-eval.d.ts +39 -9
- package/dist/template-eval.js +191 -60
- package/dist/template-import.js +6 -2
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +28 -8
- package/dist/timeline/labels.d.ts +6 -4
- package/dist/timeline/labels.js +18 -6
- package/dist/timeline/timeline.d.ts +5 -0
- package/dist/timeline/timeline.js +14 -8
- package/dist/timeline/util.js +1 -1
- package/dist/timeline/web-calls.d.ts +22 -7
- package/dist/timeline/web-calls.js +106 -35
- package/dist/tool-gate.d.ts +42 -3
- package/dist/tool-gate.js +66 -5
- package/dist/tool-keys-store.d.ts +2 -4
- package/dist/tool-keys-store.js +5 -21
- package/dist/tool-keys.d.ts +2 -2
- package/dist/tool-keys.js +2 -2
- package/dist/tool-list.js +1 -1
- package/dist/tool-plane.d.ts +2 -2
- package/dist/tool-plane.js +35 -33
- package/dist/tools.js +13 -7
- package/dist/trigger-targets.d.ts +4 -0
- package/dist/trigger-targets.js +9 -2
- package/dist/triggers.d.ts +67 -4
- package/dist/triggers.js +171 -22
- package/dist/until.d.ts +3 -0
- package/dist/until.js +11 -0
- package/dist/web-fake.d.ts +1 -3
- package/dist/web-fake.js +7 -18
- package/dist/web-fetch.d.ts +6 -72
- package/dist/web-fetch.js +11 -265
- package/dist/web-run.d.ts +31 -0
- package/dist/web-run.js +90 -0
- package/dist/web-save.d.ts +10 -13
- package/dist/web-save.js +13 -55
- package/dist/web-search.d.ts +9 -127
- package/dist/web-search.js +23 -259
- package/dist/wires.d.ts +13 -0
- package/dist/wires.js +11 -0
- package/dist/workflow-run.d.ts +5 -4
- package/dist/workflow-run.js +5 -4
- package/dist/workspace/attached-computers.d.ts +32 -9
- package/dist/workspace/attached-computers.js +77 -13
- package/dist/workspace/computer-deps.d.ts +8 -2
- package/dist/workspace/computer-deps.js +10 -3
- package/dist/workspace/computer-for-claim.d.ts +12 -1
- package/dist/workspace/computer-for-claim.js +83 -11
- package/dist/workspace/computer-kept.d.ts +3 -0
- package/dist/workspace/computer-kept.js +11 -2
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/kind-skills.d.ts +4 -0
- package/dist/workspace/kind-skills.js +9 -0
- package/dist/workspace/paired-route.d.ts +91 -0
- package/dist/workspace/paired-route.js +153 -0
- package/dist/workspace/synced-folder.js +3 -4
- package/dist/wrapped.d.ts +20 -6
- package/dist/wrapped.js +66 -25
- package/package.json +17 -11
- package/skills/agentrun-serve/SKILL.md +4 -0
- package/templates/README.md +32 -10
- package/dist/console/assets/index-CQ3cJRzI.js +0 -746
- package/dist/console/assets/index-DKkaS3a0.css +0 -1
- package/dist/exa-keyless.d.ts +0 -34
- package/dist/exa-keyless.js +0 -118
- package/dist/firecrawl-keyless.d.ts +0 -41
- package/dist/firecrawl-keyless.js +0 -152
- package/dist/keyless-mcp.d.ts +0 -36
- package/dist/keyless-mcp.js +0 -127
- package/dist/text-urls.d.ts +0 -38
- package/dist/text-urls.js +0 -170
- package/dist/web-fetch-direct.d.ts +0 -119
- package/dist/web-fetch-direct.js +0 -190
package/dist/templates.d.ts
CHANGED
|
@@ -233,6 +233,14 @@ export declare function folderFiles(dir: string): PackageFiles;
|
|
|
233
233
|
/** A package held in memory, by path (template-source.ts keeps regular files alone): its folders are those its files'
|
|
234
234
|
* paths name. */
|
|
235
235
|
export declare function memoryFiles(name: string, where: string, files: ReadonlyMap<string, Buffer>): PackageFiles;
|
|
236
|
+
/** Each of a package's triggers (POST /v2/triggers bodies, as its manifest or an export writes them) with no spend cap of
|
|
237
|
+
* its own (target.max_cost_usd, read by isCap here, not left to the trigger's schema), by its index and name. A package
|
|
238
|
+
* with triggers and no budget.per_run_usd is taken only when this is empty, so every run a trigger starts is capped by
|
|
239
|
+
* the budget or by its trigger. readPackage refuses by it, and an export blocks by it (agent-package.ts). */
|
|
240
|
+
export declare function uncappedTriggers(triggers: readonly unknown[]): {
|
|
241
|
+
index: number;
|
|
242
|
+
name: string;
|
|
243
|
+
}[];
|
|
236
244
|
/** Reads the package at `from` (its folder, or its files: PackageFiles) checked whole: a valid package, or PackageError
|
|
237
245
|
* with every problem found. */
|
|
238
246
|
export declare function readPackage(from: string | PackageFiles, { evalFixtures }?: {
|
|
@@ -260,7 +268,7 @@ export declare function packageView(p: Package): {
|
|
|
260
268
|
license: string | null;
|
|
261
269
|
author: Json | null;
|
|
262
270
|
repository: string | null;
|
|
263
|
-
category: "engineering" | "security" | "sales" | "marketing" | "research" | "finance" | "operations" | "compliance" |
|
|
271
|
+
category: "personal" | "engineering" | "security" | "sales" | "marketing" | "research" | "finance" | "operations" | "compliance" | null;
|
|
264
272
|
tags: string[];
|
|
265
273
|
output: {
|
|
266
274
|
schema: string;
|
|
@@ -334,7 +342,7 @@ export declare function packageDetail<Pick>(p: Package, computerHere: (p: Packag
|
|
|
334
342
|
license: string | null;
|
|
335
343
|
author: Json | null;
|
|
336
344
|
repository: string | null;
|
|
337
|
-
category: "engineering" | "security" | "sales" | "marketing" | "research" | "finance" | "operations" | "compliance" |
|
|
345
|
+
category: "personal" | "engineering" | "security" | "sales" | "marketing" | "research" | "finance" | "operations" | "compliance" | null;
|
|
338
346
|
tags: string[];
|
|
339
347
|
output: {
|
|
340
348
|
schema: string;
|
package/dist/templates.js
CHANGED
|
@@ -508,6 +508,20 @@ function fieldsSchema(value, of, bad) {
|
|
|
508
508
|
}
|
|
509
509
|
return { type: "object", additionalProperties: false, ...(required.length ? { required } : {}), properties };
|
|
510
510
|
}
|
|
511
|
+
/** A spend cap a run can hold: a number above 0 and finite (0, a negative, NaN and Infinity are none). */
|
|
512
|
+
const isCap = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
513
|
+
/** Each of a package's triggers (POST /v2/triggers bodies, as its manifest or an export writes them) with no spend cap of
|
|
514
|
+
* its own (target.max_cost_usd, read by isCap here, not left to the trigger's schema), by its index and name. A package
|
|
515
|
+
* with triggers and no budget.per_run_usd is taken only when this is empty, so every run a trigger starts is capped by
|
|
516
|
+
* the budget or by its trigger. readPackage refuses by it, and an export blocks by it (agent-package.ts). */
|
|
517
|
+
export function uncappedTriggers(triggers) {
|
|
518
|
+
return triggers.flatMap((trigger, index) => {
|
|
519
|
+
const target = isObject(trigger) ? trigger.target : undefined;
|
|
520
|
+
if (isObject(target) && isCap(target.max_cost_usd))
|
|
521
|
+
return [];
|
|
522
|
+
return [{ index, name: isObject(trigger) && typeof trigger.name === "string" ? trigger.name.trim() : "" }];
|
|
523
|
+
});
|
|
524
|
+
}
|
|
511
525
|
/** Reads the package at `from` (its folder, or its files: PackageFiles) checked whole: a valid package, or PackageError
|
|
512
526
|
* with every problem found. */
|
|
513
527
|
export function readPackage(from, { evalFixtures = true } = {}) {
|
|
@@ -554,8 +568,10 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
554
568
|
bad(MANIFEST, `${field} names one item twice`);
|
|
555
569
|
return value;
|
|
556
570
|
};
|
|
557
|
-
/** `path
|
|
558
|
-
const
|
|
571
|
+
/** `path`, named in agent.md, passes through a hidden file or folder: one the package leaves out (entries), so never read. */
|
|
572
|
+
const hidden = (path) => typeof path === "string" && path.split("/").some((part) => part.startsWith("."));
|
|
573
|
+
/** `path` is a regular file inside the package, none of its parts hidden (".", ".." and ".env" alike) or empty. */
|
|
574
|
+
const inside = (path) => typeof path === "string" && !path.startsWith("/") && !hidden(path) && !path.split("/").includes("") && kind(path) === "file";
|
|
559
575
|
const name = src.name;
|
|
560
576
|
if (src.kind("") !== "dir")
|
|
561
577
|
throw new PackageError(dir, ["it is not a folder: a package is one"]);
|
|
@@ -604,7 +620,7 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
604
620
|
bad(MANIFEST, "repository is an http(s) URL");
|
|
605
621
|
// Display only: what a marketplace page and the console's list file it under, and its tags.
|
|
606
622
|
if (f.category !== undefined && !CATEGORIES.includes(f.category))
|
|
607
|
-
bad(MANIFEST, `category is one of ${CATEGORIES.join(", ")}`);
|
|
623
|
+
bad(MANIFEST, `category is one of ${CATEGORIES.join(", ")}, not ${JSON.stringify(f.category)}`);
|
|
608
624
|
const tags = f.tags === undefined ? [] : Array.isArray(f.tags) && f.tags.length <= MAX_TAGS && f.tags.every((tag) => typeof tag === "string" && TAG.test(tag)) && new Set(f.tags).size === f.tags.length ? f.tags : (bad(MANIFEST, `tags is a list of at most ${MAX_TAGS} tags, each once, each lowercase letters, digits and dashes (${TAG.source})`), []);
|
|
609
625
|
const harness = f.harness === undefined ? undefined : list(f.harness, "harness", (id) => HARNESSES.includes(id));
|
|
610
626
|
if (harness && !harness.length)
|
|
@@ -703,9 +719,8 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
703
719
|
bad(MANIFEST, `secrets names ${secret}, a key this server cannot hold: a package needs the keys Settings saves and a run is handed (${PACKAGE_SECRETS.join(", ")})`);
|
|
704
720
|
// Each run's limits: its spend cap (per_run_usd, the agent's max_cost_usd), required once a budget is given, and the most
|
|
705
721
|
// requests on free models it makes (max_requests, the agent's max_requests), which a dollar cap cannot bound.
|
|
706
|
-
const perRun = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
707
722
|
const requests = (value) => value === undefined || (typeof value === "number" && Number.isSafeInteger(value) && value >= 1);
|
|
708
|
-
if (f.budget !== undefined && !(isObject(f.budget) && !unknownFields(f.budget, ["per_run_usd", "max_requests"]).length &&
|
|
723
|
+
if (f.budget !== undefined && !(isObject(f.budget) && !unknownFields(f.budget, ["per_run_usd", "max_requests"]).length && isCap(f.budget.per_run_usd) && requests(f.budget.max_requests)))
|
|
709
724
|
bad(MANIFEST, "budget is {per_run_usd: a number above 0, max_requests: a whole number of free-model requests above 0, when given}");
|
|
710
725
|
const learningIssue = f.learning === undefined ? undefined : learningSettingIssue(f.learning, "learning");
|
|
711
726
|
if (learningIssue)
|
|
@@ -743,13 +758,18 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
743
758
|
bad(MANIFEST, `triggers[${i}].source.server ${need.toolkit}: the trigger's server is the mcp need of the toolkit ${need.toolkit}, so that need is required: true. An optional one may have no saved server here, and the trigger would have none`);
|
|
744
759
|
}
|
|
745
760
|
});
|
|
746
|
-
|
|
747
|
-
|
|
761
|
+
// Every run a trigger starts is capped: by the package's budget, else by each trigger's own max_cost_usd.
|
|
762
|
+
if (triggers.length && !(isObject(f.budget) && f.budget.per_run_usd !== undefined)) {
|
|
763
|
+
for (const { index, name } of uncappedTriggers(triggers))
|
|
764
|
+
bad(MANIFEST, `triggers[${index}]${name ? ` (${name})` : ""} has no max_cost_usd of its own, and the package has no budget: every run a trigger starts is capped, so give the trigger's target a max_cost_usd above 0, or the package a budget: {per_run_usd}, each run's cap`);
|
|
765
|
+
}
|
|
748
766
|
let outputSchema;
|
|
749
767
|
if (f.output !== undefined) {
|
|
750
768
|
const at = isObject(f.output) ? f.output.schema : undefined;
|
|
751
769
|
const evalSize = typeof at === "string" && at.startsWith("evals/") && inside(at) ? src.size(at) : 0;
|
|
752
|
-
if (
|
|
770
|
+
if (isObject(f.output) && typeof at === "string" && hidden(at) && !at.split("/").some((part) => part === "." || part === ".."))
|
|
771
|
+
bad(MANIFEST, `output.schema ${at} is a hidden file: a hidden file or folder is no part of a package, so it is never read. Name a file with no part of its path starting with "."`);
|
|
772
|
+
else if (!isObject(f.output) || unknownFields(f.output, ["schema"]).length || !inside(at))
|
|
753
773
|
bad(MANIFEST, "output is {schema: a JSON Schema file in the package}");
|
|
754
774
|
else if (evalSize > MAX_FILE_BYTES || agentBytes + evalSize > MAX_PACKAGE_BYTES) {
|
|
755
775
|
bad(at, evalSize > MAX_FILE_BYTES ? `is over ${MAX_FILE_BYTES} bytes, a package file's limit: the answer's schema is given to the agent, so it keeps an agent file's limits, under evals/ too` : `takes the agent's files over ${MAX_PACKAGE_BYTES} bytes together, POST /v2/agents' own limit: the answer's schema is given to the agent, so it counts as an agent file, under evals/ too`);
|
|
@@ -15,13 +15,15 @@ export type FoldSpec = {
|
|
|
15
15
|
};
|
|
16
16
|
/** Registers the label of one tool, in the past tense, and with `name` what the tool is called where calls are counted
|
|
17
17
|
* (a run's analytics). `saysFailure`: the label of a call that errored says so itself ("Could not take a screenshot"),
|
|
18
|
-
* so its row adds only why
|
|
18
|
+
* so its row adds only why; `true` for every error, or a test of the errored result for the errors whose label says so.
|
|
19
|
+
* A host adds its own tools here. */
|
|
19
20
|
export declare function registerLabel(tool: string, label: LabelFn, fold?: FoldSpec, { name, saysFailure }?: {
|
|
20
21
|
name?: string;
|
|
21
|
-
saysFailure?: true;
|
|
22
|
+
saysFailure?: true | ((result: ToolResultView) => boolean);
|
|
22
23
|
}): void;
|
|
23
|
-
/** Whether `tool`'s label says
|
|
24
|
-
|
|
24
|
+
/** Whether `tool`'s label says that its errored call `result` failed (registerLabel's saysFailure). `result` is the one
|
|
25
|
+
* the label was given, so the two read the same text. */
|
|
26
|
+
export declare const saysFailure: (tool: string, result: ToolResultView) => boolean;
|
|
25
27
|
/** What a tool is called where its calls are counted, in plain words: its registered name, else the name it was called by. */
|
|
26
28
|
export declare const nameOf: (tool: string) => string;
|
|
27
29
|
/** A finished call's outcome, when its own result says more than that the call returned: a tool that answers a refusal
|
package/dist/timeline/labels.js
CHANGED
|
@@ -3,10 +3,11 @@ import { cut, firstLine, json, list, obj, scrubUrls, str, where } from "./util.j
|
|
|
3
3
|
const labels = new Map();
|
|
4
4
|
const folds = new Map();
|
|
5
5
|
const names = new Map();
|
|
6
|
-
const saying = new
|
|
6
|
+
const saying = new Map();
|
|
7
7
|
/** Registers the label of one tool, in the past tense, and with `name` what the tool is called where calls are counted
|
|
8
8
|
* (a run's analytics). `saysFailure`: the label of a call that errored says so itself ("Could not take a screenshot"),
|
|
9
|
-
* so its row adds only why
|
|
9
|
+
* so its row adds only why; `true` for every error, or a test of the errored result for the errors whose label says so.
|
|
10
|
+
* A host adds its own tools here. */
|
|
10
11
|
export function registerLabel(tool, label, fold, { name, saysFailure } = {}) {
|
|
11
12
|
labels.set(tool, label);
|
|
12
13
|
if (fold)
|
|
@@ -14,10 +15,11 @@ export function registerLabel(tool, label, fold, { name, saysFailure } = {}) {
|
|
|
14
15
|
if (name)
|
|
15
16
|
names.set(tool, name);
|
|
16
17
|
if (saysFailure)
|
|
17
|
-
saying.
|
|
18
|
+
saying.set(tool, saysFailure === true ? () => true : saysFailure);
|
|
18
19
|
}
|
|
19
|
-
/** Whether `tool`'s label says
|
|
20
|
-
|
|
20
|
+
/** Whether `tool`'s label says that its errored call `result` failed (registerLabel's saysFailure). `result` is the one
|
|
21
|
+
* the label was given, so the two read the same text. */
|
|
22
|
+
export const saysFailure = (tool, result) => saying.get(tool)?.(result) === true;
|
|
21
23
|
/** A remote MCP server's tool, read `<server> · <tool>`: by its catalog name, `mcp:<server>/<tool>`, or by the name the
|
|
22
24
|
* harnesses call it, `mcp__<server>__<tool>` (a server's name has no `_`; `hands` is a harness's own tools'). A tool whose
|
|
23
25
|
* `mcp__<server>__<tool>` is too long is called by a hashed name (the server's catalog.ts wireName), which reads as no
|
|
@@ -162,8 +164,18 @@ registerLabel("browser_read", (_a, result) => {
|
|
|
162
164
|
}, { many: (n) => `Read ${n} pages`, subject: (_input, output) => { const url = output && /^url: (\S+)/m.exec(output)?.[1]; return url ? where(url) : undefined; } }, { name: "Read the browser's page" });
|
|
163
165
|
registerLabel("snapshot", () => "Looked at the page structure", { many: (n) => `Looked at the page structure ${n} times` }, { name: "Look at the page structure" });
|
|
164
166
|
registerLabel("screenshot", () => "Took a screenshot", { many: (n) => `Took ${n} screenshots` }, { name: "Take screenshots" });
|
|
167
|
+
/** Whether a browser call errored as the browser's refusal before it ran: pi-browser's typed failure, `code: "refused"`
|
|
168
|
+
* with `effect: "none"` (code sent to a browser that takes only actions, an op it does not take), read by those fields,
|
|
169
|
+
* never by its words. A refusal after some of its actions ran (`effect: "partial"`, a take-over mid-batch) is not one. */
|
|
170
|
+
const browserRefused = (result) => {
|
|
171
|
+
const failure = result?.isError === true ? obj(json(result.text)) : undefined;
|
|
172
|
+
return str(failure?.code) === "refused" && str(failure?.effect) === "none";
|
|
173
|
+
};
|
|
165
174
|
registerLabel("run", (a, result) => {
|
|
166
175
|
const goto = GOTO.exec(str(a.code) ?? "")?.[1];
|
|
176
|
+
// Refused before it ran: the row says what the browser refused, never that a page failed to open.
|
|
177
|
+
if (browserRefused(result))
|
|
178
|
+
return str(a.code) === undefined ? "The browser refused the action" : goto ? `The browser refused the code to open ${where(goto)}` : "The browser refused the agent's code";
|
|
167
179
|
if (goto)
|
|
168
180
|
return `Opened ${where(goto)}`;
|
|
169
181
|
const sent = obj(result?.details)?.sent;
|
|
@@ -171,7 +183,7 @@ registerLabel("run", (a, result) => {
|
|
|
171
183
|
? sent.flatMap((request) => { const r = obj(request); const [method, url] = [str(r?.method), str(r?.url)]; return method && url ? `${method} ${where(url)}` : []; })
|
|
172
184
|
: [];
|
|
173
185
|
return requests.length ? `Acted on the page (${requests.length} request${requests.length === 1 ? "" : "s"} sent: ${list(requests)})` : "Acted on the page";
|
|
174
|
-
}, { many: (n) => `Acted on the page ${n} times` }, { name: "Open or act on a page in the browser" });
|
|
186
|
+
}, { many: (n) => `Acted on the page ${n} times` }, { name: "Open or act on a page in the browser", saysFailure: browserRefused });
|
|
175
187
|
registerLabel("browser_downloads", (_a, result) => {
|
|
176
188
|
const fetched = result && json(result.text)?.fetched;
|
|
177
189
|
const names = Array.isArray(fetched) ? fetched.flatMap((file) => str(obj(file)?.name) ?? []) : [];
|
|
@@ -293,6 +293,11 @@ export type TimelineOptions = {
|
|
|
293
293
|
redact?: (text: string) => string;
|
|
294
294
|
held?: (value: number | bigint) => boolean;
|
|
295
295
|
};
|
|
296
|
+
/** Whether a text holds a held value no cut in place takes (key-refusal.ts withheldWhole). A web call's output is read
|
|
297
|
+
* through it joined, its JSON's strings as they came (web-calls.ts webHeld), before any of its rows shows any of it: a
|
|
298
|
+
* value split across two of its strings, which `redact` and `calls.redact` never read side by side, withholds the
|
|
299
|
+
* output, so its preview, its summary and a `calls` read's text read "[redacted]". Default: none withheld. */
|
|
300
|
+
holds?: (text: string) => boolean;
|
|
296
301
|
};
|
|
297
302
|
/** A tool's calls in a run, and how many failed. */
|
|
298
303
|
export type ToolMetrics = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BROWSER_OPENERS, BROWSER_STEPS, callFailed, endsTurn, failedWith, inputPreview, labelOf, outcomeOf, refusedLabel, savedPaths, saysFailure } from "./labels.js";
|
|
2
2
|
import { cut, firstLine, firstSentence, json, obj, saidSummary, scrubUrls, str, utf8Bytes } from "./util.js";
|
|
3
3
|
import { BESIDE_SUFFIX, NOTE_SUFFIX, originMatcher, TRIGGER_LABELS } from "./origin.js";
|
|
4
|
-
import { webShownOf, webWithin } from "./web-calls.js";
|
|
4
|
+
import { webHeld, webShownOf, webWithin } from "./web-calls.js";
|
|
5
5
|
/** The call a nested call (the kernel's NestedCalls: a script's, tools_call's) was made in, read off its id
|
|
6
6
|
* (`<callId>/<key>`); undefined for a call the model made itself. */
|
|
7
7
|
export const nestingCallOf = (callId) => {
|
|
@@ -683,9 +683,13 @@ function createProjector(options) {
|
|
|
683
683
|
const verdict = /^(\w+): /.exec(text);
|
|
684
684
|
return verdict ? `${verdict[1]}: ${scrubUrls(firstLine(redactText(text.slice(verdict[0].length))))}` : scrubUrls(firstLine(redactText(text)));
|
|
685
685
|
};
|
|
686
|
-
/** A result as its rows show it: its whole output redacted once,
|
|
687
|
-
* from (resultRow); its details and error flag as they came. */
|
|
688
|
-
const shownOf = (view) =>
|
|
686
|
+
/** A result as its rows show it: its whole output redacted once, or "[redacted]" when it is withheld whole (`withheld`),
|
|
687
|
+
* which its label, summary and preview are all taken from (resultRow); its details and error flag as they came. */
|
|
688
|
+
const shownOf = (tool, view) => withheld(tool, view.text) ? { ...view, text: "[redacted]", details: redactValue(view.details) }
|
|
689
|
+
: options.redact ? { ...view, text: view.text ? options.redact(view.text) : view.text, details: redactValue(view.details) } : view;
|
|
690
|
+
/** Whether a call of `tool`'s output is withheld whole before any row shows it: a web call's strings, read joined
|
|
691
|
+
* (TimelineOptions.holds). */
|
|
692
|
+
const withheld = (tool, text) => (options.holds && text ? webHeld(tool, text, options.holds) : false);
|
|
689
693
|
const failure = (text) => scrubUrls(firstLine(str(json(text)?.message) ?? diagnosticOf(text) ?? text)) || "no detail";
|
|
690
694
|
/** Whether a result is a call's refusal before it ran: an error its host marked so in its details (CALL_REFUSED),
|
|
691
695
|
* read by that field, never by its words. */
|
|
@@ -711,6 +715,8 @@ function createProjector(options) {
|
|
|
711
715
|
const resultText = (tool, text) => {
|
|
712
716
|
if (!text)
|
|
713
717
|
return null;
|
|
718
|
+
if (withheld(tool, text))
|
|
719
|
+
return "[redacted]";
|
|
714
720
|
const web = webShownOf(tool, text, callShown);
|
|
715
721
|
return web ? webWithin(web, options.calls.result) : cut(callShown(text), options.calls.result);
|
|
716
722
|
};
|
|
@@ -730,8 +736,8 @@ function createProjector(options) {
|
|
|
730
736
|
// ok, and never the detail as it came.
|
|
731
737
|
const worded = shown.text === view.text ? outcome : outcomeOf(tool.name, { ...view, text: shown.text });
|
|
732
738
|
// A call refused before it ran is named refused already (refusedLabel), and a computer step's label says it could not
|
|
733
|
-
// (saysFailure): its row says why, never that it failed.
|
|
734
|
-
const failedSummary = refused(view) || saysFailure(tool.name) ? `${named}: ${failure(shown.text)}` : `${named} failed: ${failure(shown.text)}`;
|
|
739
|
+
// (saysFailure, asked of an error alone, with the text its label read): its row says why, never that it failed.
|
|
740
|
+
const failedSummary = refused(view) || (view.isError && saysFailure(tool.name, { text: shown.text, details: view.details, isError: true })) ? `${named}: ${failure(shown.text)}` : `${named} failed: ${failure(shown.text)}`;
|
|
735
741
|
// One the run's end closed has no outcome: interrupted, as a call cut off reads (interrupt), with no status.
|
|
736
742
|
const unended = endedWithRun(view);
|
|
737
743
|
return make("tool_result", conv, rowId, {
|
|
@@ -930,7 +936,7 @@ function createProjector(options) {
|
|
|
930
936
|
const call = calls.get(`${conv}:${id}`);
|
|
931
937
|
const name = call?.name ?? str(message.toolName) ?? "tool";
|
|
932
938
|
const view = viewOf(message);
|
|
933
|
-
const shown = shownOf(view);
|
|
939
|
+
const shown = shownOf(name, view);
|
|
934
940
|
// A call that failed ended nothing: the agent goes on after it, so a message then is still a steer.
|
|
935
941
|
ended.set(conv, (previous.get(conv) !== "pi.tool-result" || ended.get(conv) === true) && endsTurn(name) && !view.isError);
|
|
936
942
|
// One an abort cut did end the turn. A round's results come in as its calls end, so one that ended before the abort
|
|
@@ -1078,7 +1084,7 @@ function createProjector(options) {
|
|
|
1078
1084
|
const text = typeof output === "string" ? output : output !== undefined ? JSON.stringify(output) : (diagnostic ?? "");
|
|
1079
1085
|
const failed = result.isError === true;
|
|
1080
1086
|
const view = { text, details: result.details, isError: failed };
|
|
1081
|
-
const shown = shownOf(view);
|
|
1087
|
+
const shown = shownOf(call.name, view);
|
|
1082
1088
|
const named = nameFor(call.name, call.args, view, shown);
|
|
1083
1089
|
call.done = true;
|
|
1084
1090
|
call.use.summary = clean(named, caps.summary);
|
package/dist/timeline/util.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SCRUBBED_URL, trimmed } from "
|
|
1
|
+
import { SCRUBBED_URL, trimmed } from "@parcha/agentrun-web/text-urls";
|
|
2
2
|
export const obj = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
|
|
3
3
|
export const str = (value) => (typeof value === "string" ? value : undefined);
|
|
4
4
|
export const cut = (text, max) => (text.length > max ? `${text.slice(0, max - 3)}...` : text);
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
+
/** The names eachString has tried for a property, counted so a test can bound the work, not time it. */
|
|
2
|
+
export declare const namesTried: {
|
|
3
|
+
count: number;
|
|
4
|
+
};
|
|
1
5
|
/** A web call's output with each text that gives way cut to `keep` characters (a cut one ending "…"), the rest whole. */
|
|
2
6
|
export type WebShown = (keep: number) => string;
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
7
|
+
/** Whether a text holds a held value no cut in place takes (key-refusal.ts withheldWhole): `joined` is `parts` joined
|
|
8
|
+
* by line breaks, for a reader that reads each part by itself too (adapter-run-spec.ts answersCut). */
|
|
9
|
+
export type WebHolds = (joined: string, parts: readonly string[]) => boolean;
|
|
10
|
+
/** Whether `text`, a web call's output, is withheld whole: `holds` (key-refusal.ts withheldWhole) finds a held value in
|
|
11
|
+
* its JSON's strings joined by line breaks (false for an output that is not a web call's JSON). They are read in the
|
|
12
|
+
* order the output is written back in (stringsOf) and, where that differs, in the order it was written (writtenStrings).
|
|
13
|
+
* Every reader asks this first: the runner before it stores the answer (answersCut), a timeline before its row shows.
|
|
14
|
+
* Each string is cut on its own wherever the output is shown, and no view joins across the JSON's punctuation between
|
|
15
|
+
* two strings, so a held value split across two of them is found only here. */
|
|
16
|
+
export declare function webHeld(tool: string, text: string, holds: WebHolds): boolean;
|
|
17
|
+
/** `text`, a call of `tool`'s output, with `cut` (the run's redactor) applied to each string of its JSON by itself, its
|
|
18
|
+
* property names too, and to the lines after it, never to its JSON line whole: the redactor reads a run of more than
|
|
19
|
+
* 8,192 characters with no whitespace as "[redacted]" (key-refusal.ts redactedAnswer), and a JSON line, whose newlines
|
|
20
|
+
* are escapes, is one such run from its text's last space through its links, so cut whole it loses its links and no
|
|
21
|
+
* longer parses. "[redacted]" when `holds` finds a held value split across its strings (webHeld). Undefined for a tool
|
|
22
|
+
* other than web_search and web_fetch, or an output whose first line is not a JSON object: that one is cut as any other
|
|
23
|
+
* tool's. */
|
|
24
|
+
export declare function webCut(tool: string, text: string, cut: (text: string) => string, holds?: WebHolds): string | undefined;
|
|
10
25
|
/** `text`, a call of `tool`'s output, as a grader reads it (WebShown), each of its strings through `each` first (the
|
|
11
26
|
* run's redaction, its URLs' query values elided), so a cut never falls inside what that takes out. Undefined for a
|
|
12
27
|
* tool other than web_search and web_fetch, or an output that is not its JSON. A page's links past a cut are counted
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const WEB_SEARCH = "web_search";
|
|
2
2
|
const WEB_FETCH = "web_fetch";
|
|
3
|
+
/** The names eachString has tried for a property, counted so a test can bound the work, not time it. */
|
|
4
|
+
export const namesTried = { count: 0 };
|
|
3
5
|
const isObj = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
6
|
/** `text` cut to `keep` characters and marked, never splitting a surrogate pair. */
|
|
5
7
|
function clip(text, keep) {
|
|
@@ -8,33 +10,62 @@ function clip(text, keep) {
|
|
|
8
10
|
const code = keep > 0 ? text.charCodeAt(keep - 1) : 0;
|
|
9
11
|
return `${text.slice(0, code >= 0xd800 && code <= 0xdbff ? keep - 1 : keep)}…`;
|
|
10
12
|
}
|
|
11
|
-
/** Every string in `value`, property names
|
|
13
|
+
/** Every string in `value` through `each`, property names too (a tool may write a value as one): two names `each` makes
|
|
14
|
+
* one are both kept, the later ones numbered, as the runner's cutDeep keeps them (runner/redact.ts). */
|
|
12
15
|
function eachString(value, each) {
|
|
13
16
|
if (typeof value === "string")
|
|
14
17
|
return each(value);
|
|
15
18
|
if (Array.isArray(value))
|
|
16
19
|
return value.map((item) => eachString(item, each));
|
|
17
|
-
if (isObj(value))
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
if (!isObj(value))
|
|
21
|
+
return value;
|
|
22
|
+
const out = {};
|
|
23
|
+
let next;
|
|
24
|
+
for (const [key, item] of Object.entries(value)) {
|
|
25
|
+
const once = each(key);
|
|
26
|
+
let name = once;
|
|
27
|
+
// Each name's count goes on from its last free number: no name is taken back, so every number below it is still taken.
|
|
28
|
+
for (let n = next?.get(once) ?? 2; (namesTried.count++, Object.hasOwn(out, name)); n++) {
|
|
29
|
+
name = `${once} (${n})`;
|
|
30
|
+
(next ??= new Map()).set(once, n + 1);
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(out, name, { value: eachString(item, each), enumerable: true, writable: true, configurable: true });
|
|
28
33
|
}
|
|
29
|
-
return
|
|
34
|
+
return out;
|
|
30
35
|
}
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
/** Every string in `value` in the order its object reads (Object.entries: integer-like names first, a name written twice
|
|
37
|
+
* once, with its last value): the order JSON.stringify writes it back in (webCut, webShownOf). With `names`, each
|
|
38
|
+
* property name before its value. */
|
|
39
|
+
function stringsOf(value, names, out = []) {
|
|
40
|
+
if (typeof value === "string")
|
|
41
|
+
out.push(value);
|
|
42
|
+
else if (Array.isArray(value))
|
|
43
|
+
for (const item of value)
|
|
44
|
+
stringsOf(item, names, out);
|
|
45
|
+
else if (isObj(value))
|
|
46
|
+
for (const [key, item] of Object.entries(value)) {
|
|
47
|
+
if (names)
|
|
48
|
+
out.push(key);
|
|
49
|
+
stringsOf(item, names, out);
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
/** A JSON string as written, and the colon after it when it is a property name. */
|
|
54
|
+
const JSON_STRING = /("(?:[^"\\]|\\.)*")(\s*:)?/g;
|
|
55
|
+
/** Every string in `line`, a JSON text that parses, in the order it is written, each value of a name written twice too;
|
|
56
|
+
* with `names`, each property name as well, before its value. In JSON that parses, a quote outside a string only
|
|
57
|
+
* ever opens one, so the strings are read by JSON_STRING alone. */
|
|
58
|
+
function writtenStrings(line, names) {
|
|
59
|
+
const out = [];
|
|
60
|
+
for (const [, quoted, colon] of line.matchAll(JSON_STRING))
|
|
61
|
+
if (names || !colon)
|
|
62
|
+
out.push(JSON.parse(quoted));
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
/** `text`, a call of `tool`'s output, read as its tool writes it: the JSON object on its first line, and where that line
|
|
66
|
+
* ends (-1 when it is the whole text). Undefined for a tool other than web_search and web_fetch, or an output whose
|
|
67
|
+
* first line is not a JSON object. */
|
|
68
|
+
function webRead(tool, text) {
|
|
38
69
|
if (tool !== WEB_SEARCH && tool !== WEB_FETCH)
|
|
39
70
|
return undefined;
|
|
40
71
|
const end = text.indexOf("\n");
|
|
@@ -45,29 +76,69 @@ export function webCut(tool, text, cut) {
|
|
|
45
76
|
catch {
|
|
46
77
|
return undefined;
|
|
47
78
|
}
|
|
48
|
-
|
|
79
|
+
return isObj(read) ? { read, end } : undefined;
|
|
80
|
+
}
|
|
81
|
+
/** Whether `text`, a web call's output, is withheld whole: `holds` (key-refusal.ts withheldWhole) finds a held value in
|
|
82
|
+
* its JSON's strings joined by line breaks (false for an output that is not a web call's JSON). They are read in the
|
|
83
|
+
* order the output is written back in (stringsOf) and, where that differs, in the order it was written (writtenStrings).
|
|
84
|
+
* Every reader asks this first: the runner before it stores the answer (answersCut), a timeline before its row shows.
|
|
85
|
+
* Each string is cut on its own wherever the output is shown, and no view joins across the JSON's punctuation between
|
|
86
|
+
* two strings, so a held value split across two of them is found only here. */
|
|
87
|
+
export function webHeld(tool, text, holds) {
|
|
88
|
+
const web = webRead(tool, text);
|
|
89
|
+
return web ? heldIn(web, text, holds) : false;
|
|
90
|
+
}
|
|
91
|
+
/** webHeld of an output already read (webRead). */
|
|
92
|
+
function heldIn(web, text, holds) {
|
|
93
|
+
const after = web.end < 0 ? [] : [text.slice(web.end + 1)];
|
|
94
|
+
const line = web.end < 0 ? text : text.slice(0, web.end);
|
|
95
|
+
const asked = (strings) => {
|
|
96
|
+
const parts = [...strings, ...after];
|
|
97
|
+
return holds(parts.join("\n"), parts);
|
|
98
|
+
};
|
|
99
|
+
return [false, true].some((names) => {
|
|
100
|
+
const back = stringsOf(web.read, names);
|
|
101
|
+
const written = writtenStrings(line, names);
|
|
102
|
+
return asked(back) || (!sameStrings(back, written) && asked(written));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/** Whether two lists hold the same strings in the same order. */
|
|
106
|
+
const sameStrings = (a, b) => a.length === b.length && a.every((one, i) => one === b[i]);
|
|
107
|
+
/** How many of `links`, in order, fit in `keep` characters of JSON. */
|
|
108
|
+
function linksWithin(links, keep) {
|
|
109
|
+
let used = 0;
|
|
110
|
+
for (const [i, link] of links.entries()) {
|
|
111
|
+
used += JSON.stringify(link).length + 1;
|
|
112
|
+
if (used > keep)
|
|
113
|
+
return i;
|
|
114
|
+
}
|
|
115
|
+
return links.length;
|
|
116
|
+
}
|
|
117
|
+
/** `text`, a call of `tool`'s output, with `cut` (the run's redactor) applied to each string of its JSON by itself, its
|
|
118
|
+
* property names too, and to the lines after it, never to its JSON line whole: the redactor reads a run of more than
|
|
119
|
+
* 8,192 characters with no whitespace as "[redacted]" (key-refusal.ts redactedAnswer), and a JSON line, whose newlines
|
|
120
|
+
* are escapes, is one such run from its text's last space through its links, so cut whole it loses its links and no
|
|
121
|
+
* longer parses. "[redacted]" when `holds` finds a held value split across its strings (webHeld). Undefined for a tool
|
|
122
|
+
* other than web_search and web_fetch, or an output whose first line is not a JSON object: that one is cut as any other
|
|
123
|
+
* tool's. */
|
|
124
|
+
export function webCut(tool, text, cut, holds) {
|
|
125
|
+
const web = webRead(tool, text);
|
|
126
|
+
if (!web)
|
|
49
127
|
return undefined;
|
|
50
|
-
|
|
128
|
+
if (holds && heldIn(web, text, holds))
|
|
129
|
+
return "[redacted]";
|
|
130
|
+
return `${JSON.stringify(eachString(web.read, cut))}${web.end < 0 ? "" : cut(text.slice(web.end))}`;
|
|
51
131
|
}
|
|
52
132
|
/** `text`, a call of `tool`'s output, as a grader reads it (WebShown), each of its strings through `each` first (the
|
|
53
133
|
* run's redaction, its URLs' query values elided), so a cut never falls inside what that takes out. Undefined for a
|
|
54
134
|
* tool other than web_search and web_fetch, or an output that is not its JSON. A page's links past a cut are counted
|
|
55
135
|
* in `links_cut`. */
|
|
56
136
|
export function webShownOf(tool, text, each = (part) => part) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const end = text.indexOf("\n");
|
|
60
|
-
let read;
|
|
61
|
-
try {
|
|
62
|
-
read = JSON.parse(end < 0 ? text : text.slice(0, end));
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
const shown = eachString(read, each);
|
|
68
|
-
if (!isObj(shown))
|
|
137
|
+
const web = webRead(tool, text);
|
|
138
|
+
if (!web)
|
|
69
139
|
return undefined;
|
|
70
|
-
const
|
|
140
|
+
const shown = eachString(web.read, each);
|
|
141
|
+
const after = web.end < 0 ? "" : each(text.slice(web.end));
|
|
71
142
|
if (tool === WEB_SEARCH) {
|
|
72
143
|
const results = shown.results;
|
|
73
144
|
if (!Array.isArray(results) || !results.every(isObj))
|
package/dist/tool-gate.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SHELL_FAMILY, SHELL_WATCHERS, shellToolOf } from "@parcha/agentrun-kernel/kernel";
|
|
1
|
+
import { SHELL_FAMILY, SHELL_WATCHERS, type ShellPlace, shellToolOf } from "@parcha/agentrun-kernel/kernel";
|
|
2
2
|
import { type AdapterFacts } from "@parcha/agentrun-kernel";
|
|
3
3
|
import type { Workspace } from "./workspace/workspace.js";
|
|
4
4
|
import { type ToolSettingsRead } from "./tool-plane.js";
|
|
@@ -130,8 +130,8 @@ export declare const SETTINGS_UNREAD: unique symbol;
|
|
|
130
130
|
export declare const permissionOf: (name: string, server: PermissionSettings, agent?: PermissionSettings, approvals?: Approvals, effect?: ToolEffect) => Permission;
|
|
131
131
|
/** An approval's price for the person who answers it: USD where the tool declares one (booked through the spend cap's
|
|
132
132
|
* paidCall), else "not metered" (an unpriced MCP call, the owner's ruling of 11-04), or "priced by usage" for a monid
|
|
133
|
-
* endpoint priced by usage:
|
|
134
|
-
* can pass that estimate (runner/monid-run.ts). */
|
|
133
|
+
* endpoint priced by usage or a fal job: each is priced only when the call runs, after the person's allow, and its
|
|
134
|
+
* charge can pass that estimate (runner/monid-run.ts, fal-price.ts). */
|
|
135
135
|
export type ApprovalPrice = number | "not metered" | "priced by usage";
|
|
136
136
|
/** One pending approval, as the run's view shows it (`pending`) and the console's approval card reads it. */
|
|
137
137
|
export type PendingApproval = {
|
|
@@ -197,6 +197,25 @@ export declare function runGate(where: {
|
|
|
197
197
|
place?: unknown;
|
|
198
198
|
};
|
|
199
199
|
}, serverSettings: () => ToolSettingsRead, approvers: boolean): RunGate;
|
|
200
|
+
/** The tools a run's computer of `kind` serves, by the names its gate decides them by: a desktop's or a phone's own
|
|
201
|
+
* (COMPUTER_TOOLS, held to its kind's key), a browser's (its key), and, where the run's shell is on the computer
|
|
202
|
+
* (`shell` "computer": a sandbox, a desktop that mounts the run's folder), each host tool the agent grants. */
|
|
203
|
+
export declare function computerToolsOf(kind: string, granted: readonly string[], shell: ShellPlace): readonly string[];
|
|
204
|
+
/** The kind of the agent's computer when every tool it serves (computerToolsOf) is set to deny for `revision` under the
|
|
205
|
+
* server's `server` settings, as its run's gate reads them: a run of it never starts that computer. Undefined for an agent
|
|
206
|
+
* with no computer, one whose computer serves none of its tools, or one any of them is allowed or asked of. `shell`: where
|
|
207
|
+
* a run of it has its shell (resolve-computer.ts runShellOf). Settings that do not read deny nothing (the gate asks). */
|
|
208
|
+
export declare function computerDenied(revision: {
|
|
209
|
+
kind: string;
|
|
210
|
+
body: {
|
|
211
|
+
tools?: readonly string[];
|
|
212
|
+
toolSettings?: unknown;
|
|
213
|
+
harness?: string;
|
|
214
|
+
approvals?: Approvals;
|
|
215
|
+
computer?: unknown;
|
|
216
|
+
place?: unknown;
|
|
217
|
+
};
|
|
218
|
+
}, shell: ShellPlace, server: ToolSettingsRead): string | undefined;
|
|
200
219
|
/** The top-level arguments the listing of the MCP tool `name` (`mcp:<server>/<tool>`) in the run's pin declares under
|
|
201
220
|
* its inputSchema's `properties`, the snapshot the run offers the model, never a live listing; undefined for a listing
|
|
202
221
|
* with no `properties` object (nothing to close a pinned call to) and for any other tool. */
|
|
@@ -244,6 +263,26 @@ export declare class RunGate {
|
|
|
244
263
|
}): Promise<"allow" | "ask" | {
|
|
245
264
|
deny: string;
|
|
246
265
|
}>;
|
|
266
|
+
/** The refusal of a call of the run's computer's own tools (computerOwns) once that computer is off for the rest of the
|
|
267
|
+
* run (computerOff): short, decided with no setting read and nothing sent to it, a setting changed since included.
|
|
268
|
+
* Undefined for any other call, or while the computer is on. */
|
|
269
|
+
offRefusal(name: string, options?: {
|
|
270
|
+
readonly replayed?: boolean;
|
|
271
|
+
}): {
|
|
272
|
+
deny: string;
|
|
273
|
+
} | undefined;
|
|
274
|
+
/** The run's computer's kind once it is off for the rest of the run: by the first deny of a call of its own tools
|
|
275
|
+
* (decide, whose refusal says so once), or from a claim's start (turnOff). Undefined while it is on. */
|
|
276
|
+
get computerOff(): string | undefined;
|
|
277
|
+
/** The run's computer off from this claim's start: an earlier claim's deny turned it off for the run
|
|
278
|
+
* (computer-journal.ts computerTurnedOff), so each call of its tools is refused short, never said off again. */
|
|
279
|
+
turnOff(): void;
|
|
280
|
+
/** Set by the first deny of a call of the run's computer's own tools (computerOwns), or by turnOff. */
|
|
281
|
+
private off;
|
|
282
|
+
/** The run's computer kind (where.kind) when `name` is one of that computer's own tools: a desktop's or a phone's
|
|
283
|
+
* (KIND_TOOLS), a browser's (held to the browser key). Undefined for any other call, a shell or file tool the computer
|
|
284
|
+
* runs included: a deny of one of those leaves the computer's own tools as they are. */
|
|
285
|
+
private computerOwns;
|
|
247
286
|
/** The settings key a call of `name` is held to, the one its refusal and its ask name: a computer tool's is the kind
|
|
248
287
|
* whose setting decides it (kindSetting), any other's its session's name map. */
|
|
249
288
|
private keyOf;
|