@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/tool-gate.js
CHANGED
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
// wins; the same answer again is 204, a conflicting one 409. Only the owner's password session answers (server.ts), never
|
|
27
27
|
// a token. A cancel marks pending approvals canceled. Where no one can approve (accounts off), an ask is refused at once
|
|
28
28
|
// in words, never parked.
|
|
29
|
-
import { COMPUTER_OP_TOOL, computerToolDefs, defaultPermissionOf, SHELL_FAMILY, SHELL_WATCHERS, shellPermission, shellToolOf } from "@parcha/agentrun-kernel/kernel";
|
|
29
|
+
import { COMPUTER_OP_TOOL, COMPUTER_TOOLS, computerToolDefs, defaultPermissionOf, hostToolDefs, SHELL_FAMILY, SHELL_WATCHERS, shellPermission, shellToolOf } from "@parcha/agentrun-kernel/kernel";
|
|
30
30
|
import { READ_SKILL_FILE } from "@parcha/agentrun-kernel";
|
|
31
31
|
import { COMPUTER_ROOT } from "./workspace/paths.js";
|
|
32
32
|
import { META_TOOLS } from "./meta-tool-names.js";
|
|
33
33
|
import { DEFAULT_HARNESS } from "./harness.js";
|
|
34
34
|
import { DECISION_PROVIDER_KEYS, KIND_KEYS, SERVE_OWN_TOOLS } from "./tool-plane.js";
|
|
35
35
|
import { asksByDefault, isToolRow, tableTools } from "./tool-list.js";
|
|
36
|
-
import { CANT_BE_CALLED, DENIED_OPENING, deniedText, NOT_RUN, RAN_UNKNOWN } from "./refusal-words.js";
|
|
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
39
|
import { BASH_POLICIES, readOnlyReason, readOnlyText } from "./bash-read-only.js";
|
|
@@ -353,6 +353,27 @@ export function runGate(where, runId, revision, serverSettings, approvers) {
|
|
|
353
353
|
const kind = settingOfDefinition(revision.body)?.computer.kind;
|
|
354
354
|
return new RunGate({ root: where.root, work: where.work, runId, harness: revision.body.harness ?? DEFAULT_HARNESS, ...(where.computer === undefined ? {} : { computer: where.computer }), ...(kind !== undefined ? { kind } : {}), ...(where.effectOf ? { effectOf: where.effectOf } : {}), ...(where.argumentsOf ? { argumentsOf: where.argumentsOf } : {}), facts: where.facts }, serverSettings, (revision.body.toolSettings ?? {}), approvers, approvalsOf(revision.body.approvals));
|
|
355
355
|
}
|
|
356
|
+
/** The host tools that run on a computer that holds the run's shell (the kernel registry's, for shell "computer"). */
|
|
357
|
+
const ON_COMPUTER = new Set(hostToolDefs({ maxExecS: 600, shell: "computer" }).map((def) => def.name));
|
|
358
|
+
/** 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
|
|
359
|
+
* (COMPUTER_TOOLS, held to its kind's key), a browser's (its key), and, where the run's shell is on the computer
|
|
360
|
+
* (`shell` "computer": a sandbox, a desktop that mounts the run's folder), each host tool the agent grants. */
|
|
361
|
+
export function computerToolsOf(kind, granted, shell) {
|
|
362
|
+
const own = kind === "desktop" || kind === "phone" ? [...COMPUTER_TOOLS] : kind === "browser" ? ["browser"] : [];
|
|
363
|
+
return [...own, ...(shell === "computer" ? granted.filter((name) => ON_COMPUTER.has(name)) : [])];
|
|
364
|
+
}
|
|
365
|
+
/** The kind of the agent's computer when every tool it serves (computerToolsOf) is set to deny for `revision` under the
|
|
366
|
+
* server's `server` settings, as its run's gate reads them: a run of it never starts that computer. Undefined for an agent
|
|
367
|
+
* with no computer, one whose computer serves none of its tools, or one any of them is allowed or asked of. `shell`: where
|
|
368
|
+
* a run of it has its shell (resolve-computer.ts runShellOf). Settings that do not read deny nothing (the gate asks). */
|
|
369
|
+
export function computerDenied(revision, shell, server) {
|
|
370
|
+
const kind = settingOfDefinition(revision.body)?.computer.kind;
|
|
371
|
+
if (kind === undefined || kind === "none")
|
|
372
|
+
return undefined;
|
|
373
|
+
const tools = computerToolsOf(kind, revision.body.tools ?? [], shell);
|
|
374
|
+
const gate = runGate({ root: COMPUTER_ROOT, work: COMPUTER_ROOT, computer: shell === "computer", facts: undefined }, "", revision, () => server, true);
|
|
375
|
+
return tools.length > 0 && tools.every((tool) => gate.policy(tool) === "deny") ? kind : undefined;
|
|
376
|
+
}
|
|
356
377
|
/** A run's tool gate on the runner: its policy, asked before each call's intent (decide). */
|
|
357
378
|
export class RunGate {
|
|
358
379
|
where;
|
|
@@ -397,15 +418,27 @@ export class RunGate {
|
|
|
397
418
|
// call, decided as on a computer, where it runs: a desktop that mounts no folder has a computer to run a command on,
|
|
398
419
|
// so shell.run and processes.start follow bash's one setting alike, as the run's own tools on a computer do. It is a
|
|
399
420
|
// computer tool too: the kind's deny (desktop or phone set to deny) refuses it first, in the kind's words, below.
|
|
421
|
+
const ran = options.replayed ? "unknown" : "no";
|
|
422
|
+
// The run's computer once a call of its own tools was refused for a deny is off for the rest of the run: a later call
|
|
423
|
+
// of them is refused here, short, with no setting read and nothing sent to it (a setting changed since included).
|
|
424
|
+
const off = this.offRefusal(name, options);
|
|
425
|
+
if (off)
|
|
426
|
+
return off;
|
|
427
|
+
const own = this.computerOwns(name);
|
|
400
428
|
const held = heldAs(name, args);
|
|
401
429
|
if (held && this.policy(name) !== "deny")
|
|
402
430
|
return this.onComputer().decide(held.tool, held.args, options);
|
|
403
431
|
const key = this.keyOf(name) ?? name;
|
|
404
432
|
const tool = this.askedAs(name);
|
|
405
|
-
const ran = options.replayed ? "unknown" : "no";
|
|
406
433
|
const verdict = this.policy(name);
|
|
407
|
-
if (verdict === "deny")
|
|
408
|
-
|
|
434
|
+
if (verdict === "deny") {
|
|
435
|
+
const text = deniedText(tool, key, this.denyFrom(name), ran);
|
|
436
|
+
if (!own)
|
|
437
|
+
return { deny: text };
|
|
438
|
+
// The first such deny says so, once, in its refusal.
|
|
439
|
+
this.off = true;
|
|
440
|
+
return { deny: `${text} ${computerOffWords(own)}` };
|
|
441
|
+
}
|
|
409
442
|
const pinned = this.pinned(key, args, ran);
|
|
410
443
|
if (pinned)
|
|
411
444
|
return { deny: pinned.text };
|
|
@@ -416,6 +449,34 @@ export class RunGate {
|
|
|
416
449
|
return "allow";
|
|
417
450
|
return this.approvers ? "ask" : { deny: noApproverText(tool, ran) };
|
|
418
451
|
}
|
|
452
|
+
/** The refusal of a call of the run's computer's own tools (computerOwns) once that computer is off for the rest of the
|
|
453
|
+
* run (computerOff): short, decided with no setting read and nothing sent to it, a setting changed since included.
|
|
454
|
+
* Undefined for any other call, or while the computer is on. */
|
|
455
|
+
offRefusal(name, options = {}) {
|
|
456
|
+
const own = this.off ? this.computerOwns(name) : undefined;
|
|
457
|
+
return own ? { deny: computerOffText(own, options.replayed ? "unknown" : "no") } : undefined;
|
|
458
|
+
}
|
|
459
|
+
/** 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
|
|
460
|
+
* (decide, whose refusal says so once), or from a claim's start (turnOff). Undefined while it is on. */
|
|
461
|
+
get computerOff() {
|
|
462
|
+
return this.off ? this.where.kind : undefined;
|
|
463
|
+
}
|
|
464
|
+
/** The run's computer off from this claim's start: an earlier claim's deny turned it off for the run
|
|
465
|
+
* (computer-journal.ts computerTurnedOff), so each call of its tools is refused short, never said off again. */
|
|
466
|
+
turnOff() {
|
|
467
|
+
this.off = true;
|
|
468
|
+
}
|
|
469
|
+
/** Set by the first deny of a call of the run's computer's own tools (computerOwns), or by turnOff. */
|
|
470
|
+
off = false;
|
|
471
|
+
/** The run's computer kind (where.kind) when `name` is one of that computer's own tools: a desktop's or a phone's
|
|
472
|
+
* (KIND_TOOLS), a browser's (held to the browser key). Undefined for any other call, a shell or file tool the computer
|
|
473
|
+
* runs included: a deny of one of those leaves the computer's own tools as they are. */
|
|
474
|
+
computerOwns(name) {
|
|
475
|
+
const kind = this.where.kind;
|
|
476
|
+
if (kind === "desktop" || kind === "phone")
|
|
477
|
+
return KIND_TOOLS.has(name) ? kind : undefined;
|
|
478
|
+
return kind === "browser" && !KIND_TOOLS.has(name) && this.keyOf(name) === "browser" ? kind : undefined;
|
|
479
|
+
}
|
|
419
480
|
/** 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
|
|
420
481
|
* whose setting decides it (kindSetting), any other's its session's name map. */
|
|
421
482
|
keyOf(name) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type KeyCheck } from "./key-check.js";
|
|
2
|
-
import {
|
|
2
|
+
import { UNREADABLE } from "./server-keys.js";
|
|
3
|
+
import { rowUnlocks } from "./tool-keys.js";
|
|
3
4
|
import { type SealedKeys, type Settings } from "./store/index.js";
|
|
4
5
|
/** Where the per-key checks and seal-key fingerprints live in store.settings: one row, outside the sealed values. */
|
|
5
6
|
export declare const TOOL_KEY_CHECKS_KEY = "tool-key-checks";
|
|
@@ -30,9 +31,6 @@ declare class ToolKeysOverStore {
|
|
|
30
31
|
/** The checks and fingerprints the settings row holds, failing closed (an unreadable row reads as none, so no value is
|
|
31
32
|
* lost and each field is just asked to be checked again). */
|
|
32
33
|
private readChecks;
|
|
33
|
-
/** Opens a field's sealed bytes now, or why not: a fingerprint that no longer matches (seal_key_changed); else unseal,
|
|
34
|
-
* which fails as file_unreadable. */
|
|
35
|
-
private openAt;
|
|
36
34
|
/** The stored value of the field `name`, opened; undefined with none, or one that does not open: never a clear fallback. */
|
|
37
35
|
value(name: string): string | undefined;
|
|
38
36
|
/** Every stored value that opens, by field name. */
|
package/dist/tool-keys-store.js
CHANGED
|
@@ -7,14 +7,13 @@
|
|
|
7
7
|
// save/remove return a promise the handler awaits (durable before the 204). The reads are served from an in-memory
|
|
8
8
|
// snapshot the server (the one writer of these rows) loads once at start (load()) and keeps in step with every write, so a
|
|
9
9
|
// read answers without a round trip.
|
|
10
|
-
import { createHmac } from "node:crypto";
|
|
11
10
|
import { decisionsOf } from "./decisions.js";
|
|
12
11
|
import { ApiError, invalid } from "./errors.js";
|
|
13
12
|
import { checkKey } from "./key-check.js";
|
|
14
|
-
import { putSealedKey, removeSealedKey } from "./server-keys.js";
|
|
15
|
-
import { rowSecrets, rowUnlocks, SEAL_KEY_ENV, sealKeyOf, TOOL_KEYS
|
|
13
|
+
import { openSealed, putSealedKey, removeSealedKey, sealFingerprint, UNREADABLE } from "./server-keys.js";
|
|
14
|
+
import { rowSecrets, rowUnlocks, SEAL_KEY_ENV, sealKeyOf, TOOL_KEYS } from "./tool-keys.js";
|
|
16
15
|
import { toolsView } from "./tools.js";
|
|
17
|
-
import { sealColumn, sealedAt
|
|
16
|
+
import { sealColumn, sealedAt } from "./store/index.js";
|
|
18
17
|
import { isObject, unknownFields } from "./validate.js";
|
|
19
18
|
/** Where the per-key checks and seal-key fingerprints live in store.settings: one row, outside the sealed values. */
|
|
20
19
|
export const TOOL_KEY_CHECKS_KEY = "tool-key-checks";
|
|
@@ -29,9 +28,6 @@ const keptCheck = (entry) => !isObject(entry) ? undefined
|
|
|
29
28
|
: entry.state === "accepted" && typeof entry.at === "string" ? { state: "accepted", at: entry.at }
|
|
30
29
|
: entry.state === "not_checked" && typeof entry.reason === "string" ? { state: "not_checked", reason: entry.reason, ...(typeof entry.at === "string" ? { at: entry.at } : {}) }
|
|
31
30
|
: undefined;
|
|
32
|
-
/** The fingerprint of a seal key: an HMAC of a fixed label under it, stable across restarts, so a value whose fingerprint
|
|
33
|
-
* no longer matches was sealed under another key (seal_key_changed), told apart from one that is simply damaged. */
|
|
34
|
-
const fingerprint = (key) => createHmac("sha256", key).update("agentrun-serve sealed_keys key check").digest("base64url");
|
|
35
31
|
/** What the start's log line says to a person when saved keys do not open, by why: where they are kept is the server's
|
|
36
32
|
* store (`kept=store`), and what to do is to save them again in the console's Settings. */
|
|
37
33
|
export const REENTER_SAID = {
|
|
@@ -58,7 +54,7 @@ class ToolKeysOverStore {
|
|
|
58
54
|
if (!key)
|
|
59
55
|
throw new Error(`tool keys are kept under the server's seal key (${SEAL_KEY_ENV}), and none was handed over: the server does not start without one`);
|
|
60
56
|
this.key = key;
|
|
61
|
-
this.sealCheck =
|
|
57
|
+
this.sealCheck = sealFingerprint(key);
|
|
62
58
|
}
|
|
63
59
|
/** Reads the store once into the snapshot: each sealed field opened now, the checks and the fingerprints beside them.
|
|
64
60
|
* Awaited once at start, before the first read. */
|
|
@@ -69,7 +65,7 @@ class ToolKeysOverStore {
|
|
|
69
65
|
for (const row of await this.store.sealedKeys.all()) {
|
|
70
66
|
if (!FIELDS.includes(row.name))
|
|
71
67
|
continue; // the sealed_keys table also holds Archil's keys, which are not tool keys
|
|
72
|
-
fields.set(row.name, this.
|
|
68
|
+
fields.set(row.name, openSealed(this.key, row.name, row.sealed, seals.get(row.name)));
|
|
73
69
|
changed.set(row.name, row.updatedAt);
|
|
74
70
|
}
|
|
75
71
|
this.snapshot = { fields, checks, seals, changed };
|
|
@@ -93,18 +89,6 @@ class ToolKeysOverStore {
|
|
|
93
89
|
}
|
|
94
90
|
return { checks, seals };
|
|
95
91
|
}
|
|
96
|
-
/** Opens a field's sealed bytes now, or why not: a fingerprint that no longer matches (seal_key_changed); else unseal,
|
|
97
|
-
* which fails as file_unreadable. */
|
|
98
|
-
openAt(name, sealed, fp) {
|
|
99
|
-
if (fp !== undefined && fp !== this.sealCheck)
|
|
100
|
-
return { unreadable: "seal_key_changed" };
|
|
101
|
-
try {
|
|
102
|
-
return { value: unsealColumn(this.key, sealedAt.sealedKey(name), sealed).toString("utf8") };
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
return { unreadable: "file_unreadable" };
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
92
|
/** The stored value of the field `name`, opened; undefined with none, or one that does not open: never a clear fallback. */
|
|
109
93
|
value(name) {
|
|
110
94
|
if (!FIELDS.includes(name))
|
package/dist/tool-keys.d.ts
CHANGED
|
@@ -87,8 +87,8 @@ export declare const unlocksTool: (unlock: string, name: string) => boolean;
|
|
|
87
87
|
/** The key that unlocks the tool `name` (capabilities' `tools[].key`, so a page links "needs the X key" to it), if any. */
|
|
88
88
|
export declare const keyOf: (name: string) => string | undefined;
|
|
89
89
|
/** Why a stored value does not open, in the order a re-entry names one: sealed under another key than the server's, or
|
|
90
|
-
* its row damaged. */
|
|
91
|
-
export
|
|
90
|
+
* its row damaged (server-keys.ts: the one list every sealed key's view reads). */
|
|
91
|
+
export { UNREADABLE } from "./server-keys.js";
|
|
92
92
|
/** The check of a key the server was started with (tool-keys-store.ts checkServer): a KeyCheck, or refused by its provider, why in
|
|
93
93
|
* plain words. Held in memory only, for this start. */
|
|
94
94
|
export type StartCheck = KeyCheck | {
|
package/dist/tool-keys.js
CHANGED
|
@@ -66,8 +66,8 @@ export const unlocksTool = (unlock, name) => unlock === name || (unlock.endsWith
|
|
|
66
66
|
/** The key that unlocks the tool `name` (capabilities' `tools[].key`, so a page links "needs the X key" to it), if any. */
|
|
67
67
|
export const keyOf = (name) => TOOL_KEYS.find((row) => row.unlocks.some((unlock) => unlocksTool(unlock, name)))?.id;
|
|
68
68
|
/** Why a stored value does not open, in the order a re-entry names one: sealed under another key than the server's, or
|
|
69
|
-
* its row damaged. */
|
|
70
|
-
export
|
|
69
|
+
* its row damaged (server-keys.ts: the one list every sealed key's view reads). */
|
|
70
|
+
export { UNREADABLE } from "./server-keys.js";
|
|
71
71
|
/** A key row's secrets as every secret's view says them (secret-writes.ts SecretMeta): one per field, named
|
|
72
72
|
* "<kind>:<FIELD>" (tool:MONID_API_KEY, model:OPENROUTER_API_KEY); source env when the server is started with it, console
|
|
73
73
|
* when the owner saved it; `changedAt` the time that field's own value was saved (its own row in the store, its own entry
|
package/dist/tool-list.js
CHANGED
|
@@ -3,7 +3,7 @@ export const TOOL_LIST = Object.freeze({
|
|
|
3
3
|
write: { table: true, askable: true, replay: "never", blurb: "Write files in the run's folder" },
|
|
4
4
|
edit: { table: true, askable: true, replay: "never", blurb: "Edit files in the run's folder" },
|
|
5
5
|
bash: { table: true, askable: true, replay: "never", blurb: "Run shell commands in the sandbox" },
|
|
6
|
-
ask_person: { table: true, replay: "safe", blurb: "
|
|
6
|
+
ask_person: { table: true, replay: "safe", blurb: "Lets the agent stop and ask you a question" },
|
|
7
7
|
web_fetch: { table: true, askable: true, replay: "safe", host: true, blurb: "Read a public web page" },
|
|
8
8
|
web_search: { table: true, askable: true, replay: "safe", host: true, blurb: "Search the web" },
|
|
9
9
|
web_save: { table: true, askable: true, replay: "never", host: true, blurb: "Save a public file into the run's folder" },
|
package/dist/tool-plane.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ export declare const CAPABILITIES: readonly ["read", "write", "edit", "web_searc
|
|
|
20
20
|
* Named once here, so the scan of vendor ids (scripts/check-vendor-ids.mjs) counts it once. */
|
|
21
21
|
declare const DIRECT_FETCH: "kernel";
|
|
22
22
|
/** The providers a user may pick for each capability that has a choice, its default first: `auto`, for web_search the
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* Parallel where the server holds its key, else keyless Firecrawl, on every harness (a native search is never `auto`,
|
|
24
|
+
* only `native`); for web_fetch the guarded direct fetch where the
|
|
25
25
|
* server holds a Parallel key, else keyless Firecrawl; `native`, the harness's own tool or its model provider's hosted
|
|
26
26
|
* one, and nothing else; `firecrawl-keyless`, Firecrawl's public MCP endpoint, no key, with keyless Exa behind it for
|
|
27
27
|
* web_search and the guarded direct fetch behind it for web_fetch; `exa-keyless`, Exa's public MCP endpoint alone, no
|
package/dist/tool-plane.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
// The tool plane: the capabilities a pack or a revision may grant, the providers a user may pick for the two that reach
|
|
2
2
|
// the web, and what each resolves to on a run. A capability resolves in one order: (1) the provider the user picked, the
|
|
3
|
-
// agent's own (`definition.tool_settings`) over the server's (`PUT /v2/settings/tools`), optional; (2)
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// (exa-keyless.ts) behind it. web_fetch has no (2): its `auto` is the guarded direct fetch where the server holds a
|
|
3
|
+
// agent's own (`definition.tool_settings`) over the server's (`PUT /v2/settings/tools`), optional; (2) for web_search,
|
|
4
|
+
// Parallel where the server holds its key (env or saved, which then bills it); (3) the keyless fallback: Firecrawl's
|
|
5
|
+
// public keyless MCP endpoint (@parcha/agentrun-web providers/firecrawl-keyless.ts), with Exa's
|
|
6
|
+
// (providers/exa-keyless.ts) behind it. web_fetch's `auto` is the guarded direct fetch where the server holds a
|
|
8
7
|
// Parallel key (as before keyless Firecrawl), else keyless Firecrawl with the guarded direct fetch behind it, and
|
|
9
8
|
// Parallel's extract is a pick. Through Firecrawl web_fetch sends each URL to a third party, and its `why` says so; a URL
|
|
10
|
-
// the public-host guard refuses never goes (web-fetch.ts).
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
9
|
+
// the public-host guard refuses never goes (web-fetch.ts). The native search, a harness's own (Claude's WebSearch,
|
|
10
|
+
// Codex's live search) or on pi one request to the run's own model provider with its hosted search (hosted-search.ts),
|
|
11
|
+
// runs only where it is picked, `native`: `auto` never resolves to it, on any harness. `off` turns web_search off.
|
|
12
|
+
// web_search's default, `auto`, is that order; a pick of `native` is native only,
|
|
14
13
|
// unavailable where there is none, never a keyless search. A grant names a capability, never a provider. A pick of parallel without
|
|
15
14
|
// PARALLEL_API_KEY resolves unavailable, never to something else. The server resolves a run's tools at its first
|
|
16
15
|
// launch, from its pinned revision and the settings then, keeps them for the run's life (runs.ts), and hands the run's
|
|
@@ -31,6 +30,7 @@ import { keyNeeded } from "./key-words.js";
|
|
|
31
30
|
import { DEFAULT_HARNESS, HARNESSES } from "./harness.js";
|
|
32
31
|
import { factsOf as tableFactsOf, harnessOf } from "./harness-table.js";
|
|
33
32
|
import { viaOpenRouter, wireOf } from "./provider.js";
|
|
33
|
+
import { routedId } from "./wires.js";
|
|
34
34
|
import { savedIn } from "./secrets.js";
|
|
35
35
|
import { hostModel } from "./model.js";
|
|
36
36
|
import { NEEDS_A_COMPUTER, NO_SHELL } from "@parcha/agentrun-kernel/kernel";
|
|
@@ -50,8 +50,8 @@ export const CAPABILITIES = ["read", "write", "edit", "web_search", "web_fetch",
|
|
|
50
50
|
* Named once here, so the scan of vendor ids (scripts/check-vendor-ids.mjs) counts it once. */
|
|
51
51
|
const DIRECT_FETCH = "kernel";
|
|
52
52
|
/** The providers a user may pick for each capability that has a choice, its default first: `auto`, for web_search the
|
|
53
|
-
*
|
|
54
|
-
*
|
|
53
|
+
* Parallel where the server holds its key, else keyless Firecrawl, on every harness (a native search is never `auto`,
|
|
54
|
+
* only `native`); for web_fetch the guarded direct fetch where the
|
|
55
55
|
* server holds a Parallel key, else keyless Firecrawl; `native`, the harness's own tool or its model provider's hosted
|
|
56
56
|
* one, and nothing else; `firecrawl-keyless`, Firecrawl's public MCP endpoint, no key, with keyless Exa behind it for
|
|
57
57
|
* web_search and the guarded direct fetch behind it for web_fetch; `exa-keyless`, Exa's public MCP endpoint alone, no
|
|
@@ -168,16 +168,20 @@ export const ownSearchViaOpenRouter = (env, harness, model) => {
|
|
|
168
168
|
function noNative(input) {
|
|
169
169
|
// Native, where there is one: a harness's own (its facts' webSearch), else pi's, which asks Anthropic's or OpenAI's. A
|
|
170
170
|
// harness's own search goes with its request on its wire, except on OpenRouter (which runs no harness's own search, nor
|
|
171
|
-
// counts its searches),
|
|
171
|
+
// counts its searches), on a model the route translates onto its wire (wires.ts routed: the route asks that model, which
|
|
172
|
+
// has no provider-hosted tool, so the harness's own search is never sent), behind serve's gateway on the wire it serves (no known hosted search), or under a spend cap
|
|
172
173
|
// (cappedOwn: per-use fees the cap cannot reserve yet, its request's bound holding the pages' input tokens, not the
|
|
173
174
|
// fees; or a request with no input bound). A harness with none (OpenCode, whose proxy policy refuses a
|
|
174
|
-
// provider-hosted tool) has none at all. Where there is none, `native` is unavailable
|
|
175
|
-
//
|
|
175
|
+
// provider-hosted tool) has none at all. Where there is none, `native` is unavailable. `auto` goes to Parallel on the
|
|
176
|
+
// server's key (its fee booked and held by a cap, paid-calls.ts), else to keyless Firecrawl, with a native search or
|
|
177
|
+
// without.
|
|
176
178
|
const vendor = input.model?.slice(0, Math.max(0, input.model.indexOf("/")));
|
|
177
179
|
const { facts } = input;
|
|
178
180
|
if (facts) {
|
|
179
181
|
if (!facts.webSearch)
|
|
180
182
|
return { id: `${input.harness}, whose model requests carry no provider-hosted tool`, why: `${facts.label}'s model requests carry no provider-hosted tool` };
|
|
183
|
+
if (input.model && routedId(facts.wire, input.model))
|
|
184
|
+
return { id: `${input.harness} on a model the route translates`, why: `${facts.label}'s own search does not run on a model the route translates` };
|
|
181
185
|
if (input.openRouter)
|
|
182
186
|
return { id: `${input.harness} on OpenRouter`, why: `through OpenRouter ${facts.label}'s own search is not run, and its searches are not counted to price` };
|
|
183
187
|
if (input.gateway && wireOf(facts.wire)?.gateway)
|
|
@@ -190,11 +194,13 @@ function noNative(input) {
|
|
|
190
194
|
return undefined;
|
|
191
195
|
return input.model ? { id: input.model, why: `${input.model} has no hosted search here` } : { id: "a model with none named", why: "no model is named, so there is no hosted search" };
|
|
192
196
|
}
|
|
193
|
-
/** The native search of a run that has one,
|
|
194
|
-
const
|
|
197
|
+
/** The native search of a run that has one, by name: the harness's own, else its model provider's hosted one. */
|
|
198
|
+
const ownSearch = (input) => {
|
|
195
199
|
const { facts } = input;
|
|
196
|
-
return facts?.webSearch ? `${facts.label}'s own search` : `${input.model?.startsWith("openai/") ? "OpenAI" : "Anthropic"}'s hosted search
|
|
200
|
+
return facts?.webSearch ? `${facts.label}'s own search` : `${input.model?.startsWith("openai/") ? "OpenAI" : "Anthropic"}'s hosted search`;
|
|
197
201
|
};
|
|
202
|
+
/** The native search of a run that has one, in a sentence. */
|
|
203
|
+
const nativeWhy = (input) => (input.facts?.webSearch ? ownSearch(input) : `${ownSearch(input)}, for ${input.model}`);
|
|
198
204
|
/** Keyless Firecrawl in a sentence, as web_search and web_fetch use it. web_fetch's says plainly that each URL leaves
|
|
199
205
|
* the server, and how to keep it here. */
|
|
200
206
|
const FIRECRAWL_SEARCH = "Firecrawl's free keyless search, no key, keyless Exa behind it";
|
|
@@ -224,23 +230,19 @@ export function explainCapability(capability, input) {
|
|
|
224
230
|
return { resolves: "exa-keyless", why: `keyless Exa, ${picked}: Exa's free search, no key` };
|
|
225
231
|
if (chosen === "firecrawl-keyless")
|
|
226
232
|
return { resolves: "firecrawl-keyless", why: `keyless Firecrawl, ${picked}: ${FIRECRAWL_SEARCH}` };
|
|
227
|
-
// Under ask, a harness's own search runs inside its CLI, where no call can
|
|
228
|
-
//
|
|
229
|
-
const asks = input.permission === "ask" && input.facts !== undefined;
|
|
233
|
+
// `native` picked: the native search only. Under ask, a harness's own search runs inside its CLI, where no call can
|
|
234
|
+
// wait for a person, so it is unavailable; pi's is a tool of the run's, which the gate holds.
|
|
230
235
|
const without = noNative(input);
|
|
231
|
-
if (chosen === "native"
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
// `auto`
|
|
237
|
-
//
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if (none === undefined)
|
|
242
|
-
return { resolves: "native", why: nativeWhy(input) };
|
|
243
|
-
return input.parallelKey ? { resolves: "parallel", why: `${none.why}; ${key}` } : { resolves: "firecrawl-keyless", why: `${none.why}; ${FIRECRAWL_SEARCH}` };
|
|
236
|
+
if (chosen === "native") {
|
|
237
|
+
if (without !== undefined)
|
|
238
|
+
return { resolves: `unavailable: no native search for ${without.id}`, why: `no native search for ${without.id}` };
|
|
239
|
+
return input.permission === "ask" && input.facts !== undefined ? { resolves: NATIVE_ASKS, why: "native search cannot wait for an approval: it runs inside the harness's CLI" } : { resolves: "native", why: nativeWhy(input) };
|
|
240
|
+
}
|
|
241
|
+
// `auto` never resolves native, on any harness: Parallel on the server's key, else keyless Firecrawl. Where a native
|
|
242
|
+
// search would run, auto's why names it as the pick it is; where none runs (noNative), it says why not.
|
|
243
|
+
if (without === undefined)
|
|
244
|
+
return input.parallelKey ? { resolves: "parallel", why: key } : { resolves: "firecrawl-keyless", why: `${FIRECRAWL_SEARCH}; ${ownSearch(input)} is an explicit pick` };
|
|
245
|
+
return input.parallelKey ? { resolves: "parallel", why: `${without.why}; ${key}` } : { resolves: "firecrawl-keyless", why: `${without.why}; ${FIRECRAWL_SEARCH}` };
|
|
244
246
|
}
|
|
245
247
|
/** What `capability` resolves to on a run of `input`. */
|
|
246
248
|
export const resolveCapability = (capability, input) => explainCapability(capability, input).resolves;
|
package/dist/tools.js
CHANGED
|
@@ -18,7 +18,8 @@ import { defineExtension, defineTool, ROOT_CONVERSATION_ID } from "@earendil-wor
|
|
|
18
18
|
import { registerTurnEnding } from "./timeline/index.js";
|
|
19
19
|
import { BACKGROUND_LOG_BYTES, BACKGROUND_MAX, BACKGROUND_PAGE_BYTES } from "./background.js";
|
|
20
20
|
import { isWorkspaceError, localWorkspace } from "./workspace/index.js";
|
|
21
|
-
import {
|
|
21
|
+
import { HTML_READ_CHARS, TEXT_CAP } from "@parcha/agentrun-web";
|
|
22
|
+
import { fetchOptions } from "./web-run.js";
|
|
22
23
|
import { harnessIds, onAdapter } from "./harness-table.js";
|
|
23
24
|
import { META_TOOLS } from "./meta-tool-names.js";
|
|
24
25
|
import { localFolderOf } from "./workspace/local.js";
|
|
@@ -31,10 +32,10 @@ import { browserPrice, browserSpend } from "./browser-cost.js";
|
|
|
31
32
|
import { sessionEnds } from "./browser-sessions.js";
|
|
32
33
|
import { sessionRecordings } from "./computer-record.js";
|
|
33
34
|
import { forModel } from "./result.js";
|
|
34
|
-
import { fetchFor,
|
|
35
|
+
import { fetchFor, WEB_FETCH_TOOL, webFetchTool } from "./web-fetch.js";
|
|
35
36
|
import { searchFor, WEB_SEARCH_TOOL, webSearchTool } from "./web-search.js";
|
|
36
37
|
import { fakeFetch, fakeSaveOptions, fakeSearch } from "./web-fake.js";
|
|
37
|
-
import { SAVE_MAX_BYTES, WEB_SAVE_TOOL, webSaveTool } from "./web-save.js";
|
|
38
|
+
import { LENGTH_TYPES, SAVE_MAX_BYTES, WEB_SAVE_TOOL, webSaveTool } from "./web-save.js";
|
|
38
39
|
import { browserNeeds, explainsView, isUnavailable, NO_PARALLEL_KEY, PICKABLE, planeOf, PROVIDERS, serverGate, whyUnavailable, withDefaults } from "./tool-plane.js";
|
|
39
40
|
import { fauxFetch, PARALLEL_KEY_ENV } from "./decisions.js";
|
|
40
41
|
import { keyNeeded } from "./key-words.js";
|
|
@@ -48,6 +49,7 @@ import { runnerSecrets } from "./runner/redact.js";
|
|
|
48
49
|
import { HANDOVER_WAITING } from "./runner/journal-kinds.js";
|
|
49
50
|
import { provenFor } from "./live-reach.js";
|
|
50
51
|
import { clearWaitEnded, markWaitEnded } from "./browser-wait-ended.js";
|
|
52
|
+
import { browserHoldWriter } from "./browser-hold.js";
|
|
51
53
|
import { runSignIn, verifyRunSignIn } from "./sign-ins-store.js";
|
|
52
54
|
import { held } from "./runner/held.js";
|
|
53
55
|
export const ASK_TOOL = "ask_person";
|
|
@@ -114,9 +116,9 @@ const webFetchEntry = (name) => ({
|
|
|
114
116
|
return { tools: [tool], extensions: [extension] };
|
|
115
117
|
},
|
|
116
118
|
// A call node's Page is the workflow's, not a model's context: it reads the most of a part by default, from the page
|
|
117
|
-
// the run read (
|
|
119
|
+
// the run read (its Web's pages) where it holds the URL. Its request to Parallel, when it makes one, is booked under the call
|
|
118
120
|
// (paid-calls.ts); a part from what the run read makes none and books nothing.
|
|
119
|
-
effect: async (args, run) => bookedIn(run.ledger, async () => fetchFor(run.env, args.url, { ...(await fetchOptions(run.env, FAUX_ENV)), offset: args.offset, maxChars: args.max_chars ?? TEXT_CAP,
|
|
121
|
+
effect: async (args, run) => bookedIn(run.ledger, async () => fetchFor(run.env, args.url, { ...(await fetchOptions(run.env, FAUX_ENV)), offset: args.offset, maxChars: args.max_chars ?? TEXT_CAP, signal: run.signal })),
|
|
120
122
|
});
|
|
121
123
|
/** A file or shell tool: listed here for its words and its rules, bound by the run's workspace registry
|
|
122
124
|
* (workspace/run-tools.ts), never by this table. */
|
|
@@ -372,6 +374,8 @@ const browserTool = {
|
|
|
372
374
|
cursor = page.next;
|
|
373
375
|
}
|
|
374
376
|
}, context)) ?? [];
|
|
377
|
+
// The browser's take as the server reads it: written in order, and none from an earlier process of the run kept.
|
|
378
|
+
const holdWriter = host.store && host.claim ? browserHoldWriter(host.store.settings, host.claim.runId, host.claim.epoch) : undefined;
|
|
375
379
|
const hands = person.personHands({
|
|
376
380
|
gates,
|
|
377
381
|
personTime: (what, seconds, options) => spend.personTime(what, seconds, options),
|
|
@@ -386,6 +390,8 @@ const browserTool = {
|
|
|
386
390
|
if (host.store && host.claim)
|
|
387
391
|
void markWaitEnded(host.store.settings, host.claim.runId, { at: new Date(at).toISOString(), why }, host.claim.epoch).catch(() => undefined);
|
|
388
392
|
},
|
|
393
|
+
// Who drives the browser, for the run read's computer state (browser-hold.ts): one settings row while a take is live.
|
|
394
|
+
held: (tag, on, at) => void holdWriter?.held(tag, on, at),
|
|
389
395
|
note: async (kind, data) => {
|
|
390
396
|
// A hand-over's waiting entry, on the runner: the row says the run waits on the person in its browser from that
|
|
391
397
|
// commit (the server tells run.needs_input by it), and no more from its answer's, whoever writes it.
|
|
@@ -617,7 +623,7 @@ export const TOOLS = Object.freeze({
|
|
|
617
623
|
},
|
|
618
624
|
[WEB_FETCH_TOOL]: webFetchEntry(WEB_FETCH_TOOL),
|
|
619
625
|
[WEB_SEARCH_TOOL]: {
|
|
620
|
-
summary: "Search the web:
|
|
626
|
+
summary: "Search the web: Parallel's Search API where the server holds its key, else Firecrawl's keyless search with Exa's behind it; or the provider picked, the harness's own search (claude-agent's, codex's) or on pi the model provider's hosted search (Anthropic, OpenAI) only where native is picked: { query, n? } -> { provider, query, results: [{ url, title, snippet, published? }], text? }, provider naming the one that served it, 1 to 25 results, each snippet at most 3,000 characters; { error } when the search gives no answer.",
|
|
621
627
|
needs: [],
|
|
622
628
|
nodes: true,
|
|
623
629
|
// On the runner its hosted search goes through the run's own route (host.search, run.search), labelled web_search.
|
|
@@ -628,7 +634,7 @@ export const TOOLS = Object.freeze({
|
|
|
628
634
|
// web_save (web-save.ts). It makes no paid request, so nothing books it. No node or call node names it: a workflow's
|
|
629
635
|
// effect has only a local work path, not the run's Workspace.
|
|
630
636
|
[WEB_SAVE_TOOL]: {
|
|
631
|
-
summary: `Download one public file into the run's work/ (a bare name under media/), never overwriting: { url, path } -> { ok: true, path, bytes, content_type, duration_s?, url } (duration_s
|
|
637
|
+
summary: `Download one public file into the run's work/ (a bare name under media/), never overwriting: { url, path } -> { ok: true, path, bytes, content_type, duration_s?, url } (duration_s the length in seconds of an ${LENGTH_TYPES}) or { ok: false, url, refused | error }; at most ${SAVE_MAX_BYTES / (1024 * 1024)} MiB, a media type only when its bytes agree.`,
|
|
632
638
|
needs: [],
|
|
633
639
|
nodes: false,
|
|
634
640
|
bind: async (host) => {
|
|
@@ -30,6 +30,10 @@ export interface TriggerTargetDeps {
|
|
|
30
30
|
/** `work`, a write that may open run `runId` of agent `agentId` again, done in the agent's delete turn (server.ts
|
|
31
31
|
* runWrite): never under a purge of the run, and 410 purged after one. */
|
|
32
32
|
runWrite<T>(agentId: string, runId: string, work: () => Promise<T>): Promise<T>;
|
|
33
|
+
/** `text` as a message to run `runId` is written: cut of what the run holds now (server.ts cutHeld), read inside the
|
|
34
|
+
* turn that writes it (runWrite), as a person's message is. A run whose seal doesn't open here refuses it (ApiError
|
|
35
|
+
* WITHHELD_MESSAGE): the firing skips with those words, never writes it uncut. */
|
|
36
|
+
cutHeld(runId: string, text: string): Promise<string>;
|
|
33
37
|
/** A run's v2 status, or null for an unknown run (the run view): the trigger engine's overlap and active-run checks. */
|
|
34
38
|
runStatus(runId: string): Promise<string | null>;
|
|
35
39
|
/** A completed run's result.output as GET /runs/{id} serves it (cut of the secrets it holds; null when it has none), and
|
package/dist/trigger-targets.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { ApiError, unsupported } from "./errors.js";
|
|
8
8
|
import { message, startRun, WAITS_ON_A_PERSON } from "./runs-over-store.js";
|
|
9
9
|
import { runOfOrigin } from "./store-reads/runs.js";
|
|
10
|
+
import { WITHHELD_MESSAGE } from "./handed-values.js";
|
|
10
11
|
import { NATIVE_CAP_UNSUPPORTED, NATIVE_RUN_OVERRIDES_UNSUPPORTED, nativeOf, nativeRunOverrides } from "./native/binding.js";
|
|
11
12
|
import { firingsOwe, keysOwedRefusal } from "./run-keys.js";
|
|
12
13
|
import { isObject } from "./validate.js";
|
|
@@ -191,7 +192,9 @@ export function triggerTargets(store, deps) {
|
|
|
191
192
|
const cap = handedCap(target.max_cost_usd ?? agentCap, hostCap);
|
|
192
193
|
const run = await startRun(store, deps.start, entry, { ...body, ...(cap !== undefined ? { max_cost_usd: cap } : {}), ...(target.effort ? { effort: target.effort } : {}) },
|
|
193
194
|
// Titled from the trigger (the engine's titleOf: "<Source> <name>"), never from its input, a sender's markup.
|
|
194
|
-
|
|
195
|
+
// A host's start (`host`) starts the firing it was handed in the run's own write: refused, with nothing written,
|
|
196
|
+
// once that firing has moved (its host released it meanwhile).
|
|
197
|
+
{ trigger, origin: { key: trigger.firing_key }, capped: !native, from, ...(title ? { title } : {}), ...(host?.sealed ? { sealed: host.sealed } : {}), ...(host?.keys ? { keys: host.keys } : {}), ...(host ? { firing: { triggerId: trigger.id, key: trigger.firing_key } } : {}) });
|
|
195
198
|
return { run_id: run.id };
|
|
196
199
|
},
|
|
197
200
|
async message(target, input, key, from, bound) {
|
|
@@ -219,7 +222,9 @@ export function triggerTargets(store, deps) {
|
|
|
219
222
|
// (store.triggers.message): a server that goes down after it never sends it again, and past the bound the firing
|
|
220
223
|
// is skipped in words. A firing no longer due there (already sent) writes nothing.
|
|
221
224
|
const triggerId = from.trigger_id;
|
|
222
|
-
|
|
225
|
+
// Its text is cut of what the run holds, read in the turn that writes it: a firing hands no key, but its text (its
|
|
226
|
+
// content, the payload it carries) may say one the run was handed, which the run's end erases.
|
|
227
|
+
const queued = await deps.runWrite(run.agentId, run.id, async () => message(store, run, await deps.cutHeld(run.id, String(input.content)), {
|
|
223
228
|
answers: false,
|
|
224
229
|
origin: from,
|
|
225
230
|
requestId: key,
|
|
@@ -235,6 +240,8 @@ export function triggerTargets(store, deps) {
|
|
|
235
240
|
catch (error) {
|
|
236
241
|
if (error instanceof ApiError && error.message === WAITS_ON_A_PERSON)
|
|
237
242
|
return { skipped: WAITS_ON_A_PERSON };
|
|
243
|
+
if (error instanceof ApiError && error.message === WITHHELD_MESSAGE)
|
|
244
|
+
return { skipped: WITHHELD_MESSAGE };
|
|
238
245
|
throw error;
|
|
239
246
|
}
|
|
240
247
|
},
|
package/dist/triggers.d.ts
CHANGED
|
@@ -18,6 +18,17 @@ export declare const FIRING_STATUSES: readonly ["due", "started", "sent", "skipp
|
|
|
18
18
|
/** The reason of a firing the launch hook's host took (a 2xx) without starting its run here under the firing (RunCreate
|
|
19
19
|
* trigger_firing). */
|
|
20
20
|
export declare const HANDED_NO_RUN = "Handed to the host by the launch hook, which started no run here for it.";
|
|
21
|
+
/** The error code of a firing its launch hook's host released (Triggers.release): it took the firing (a 2xx) and said it
|
|
22
|
+
* will start no run for it. */
|
|
23
|
+
export declare const HOST_RELEASED = "host_released";
|
|
24
|
+
/** The reason of such a firing; its error's message is the host's own words. */
|
|
25
|
+
export declare const HOST_RELEASED_REASON = "Released by the launch hook's host, which took it and will start no run for it.";
|
|
26
|
+
/** The `details.reason` of a release refused because the firing's run started (Triggers.release), beside `details.run_id`:
|
|
27
|
+
* for a host to match without reading the words. A start refused because its host released the firing carries
|
|
28
|
+
* HOST_RELEASED there. */
|
|
29
|
+
export declare const RUN_STARTED = "run_started";
|
|
30
|
+
/** The most characters of the host's words a release keeps. */
|
|
31
|
+
export declare const RELEASE_WORDS_MAX = 500;
|
|
21
32
|
/** The most of a webhook's payload a firing passes on: the rest is cut, at a character's start (trigger-adapter.ts). */
|
|
22
33
|
/** How late a missed time may be and still fire once, by default: an hour. */
|
|
23
34
|
export declare const CATCHUP_WINDOW_S = 3600;
|
|
@@ -109,7 +120,9 @@ export type RunTrigger = {
|
|
|
109
120
|
/** A host's start of a firing the launch hook handed it (Triggers.handedStart): the firing's key, the trigger, input
|
|
110
121
|
* origin and title a start here would give the run, and the target and previous-result flag it starts on
|
|
111
122
|
* (TriggerDeps.start's, so a handed run gets its target's cap, effort and previous result as one started here does; the
|
|
112
|
-
* host may lower the cap, and its effort holds when the target sets none).
|
|
123
|
+
* host may lower the cap, and its effort holds when the target sets none). The start writes its run with the firing's
|
|
124
|
+
* start in the same write (store.runs.create `firing`), so a release of the firing meanwhile, on any server, refuses
|
|
125
|
+
* it (FiringMoved) and leaves no run. */
|
|
113
126
|
export type HandedStart = {
|
|
114
127
|
key: string;
|
|
115
128
|
trigger: RunTrigger;
|
|
@@ -664,16 +677,66 @@ export declare class Triggers {
|
|
|
664
677
|
/** Run `runId`, which the host started for firing `key` (handedStart), started: a firing with no run yet, still due
|
|
665
678
|
* (being handed, or waiting on its retry after the hook failed) or one its host took first, is made started here, as
|
|
666
679
|
* handed() makes it when the run came first, so the overlap check, max_active_runs and last_run_id count it. A failed
|
|
667
|
-
* or settled firing is left as it is
|
|
668
|
-
|
|
680
|
+
* or settled firing is left as it is, and so is one that moved between this read and the write (the write is only
|
|
681
|
+
* while it is still in the status read, with no run: a release that failed it meanwhile stands). Whether it started
|
|
682
|
+
* it here. */
|
|
683
|
+
handedRan(triggerId: string, key: string, runId: string): Promise<boolean>;
|
|
684
|
+
/** The refusal of a host start of firing `key` whose run's write found the firing moved (FiringMoved): released by
|
|
685
|
+
* its host, or another not_due naming what it is now. */
|
|
686
|
+
private movedRefusal;
|
|
687
|
+
/** Firing `key` of trigger `triggerId` released by the host the launch hook handed it to: the host answered it 2xx and
|
|
688
|
+
* says it will start no run for it (its job failed before any run started). `body` is `{ error }`, the host's words
|
|
689
|
+
* (1 to RELEASE_WORDS_MAX characters), which `cut` takes the server's secrets out of before they are kept. A firing
|
|
690
|
+
* sent with no run, before or after its start_by, fails at once: host_released with those words, one failure in its
|
|
691
|
+
* trigger's streak and a trigger.failed, as any failed firing. Its trigger's room is free from that write, so a firing
|
|
692
|
+
* waiting on it is driven on the next tick. The same call on a firing it released already answers that firing as it
|
|
693
|
+
* is. Refused in words: 422 not_allowed on a server with no launch hook, not_due for a firing whose run started, one
|
|
694
|
+
* still due once the engine's turn on it ends (not handed yet) or any other, with `details` { reason: RUN_STARTED,
|
|
695
|
+
* run_id } when its run started; 404 for a trigger or firing this server does not have. A release during the engine's
|
|
696
|
+
* own turn on the firing (its hook's answer read but not yet written) waits for that turn and reads the firing again,
|
|
697
|
+
* so a 2xx it writes is released. A host start of the firing already writing its run on this server is waited for
|
|
698
|
+
* first: a run it writes makes the firing started, and refused. Any other start, on this server (its room check
|
|
699
|
+
* landing after that wait) or another, is decided by the store: its run's write and this release's are each
|
|
700
|
+
* conditional on the firing being sent with no run, so the one that lands second finds it moved (a start, FiringMoved;
|
|
701
|
+
* this release, the firing read again and refused). */
|
|
702
|
+
release(triggerId: string, key: string, body: Json, cut: (text: string) => string): Promise<{
|
|
703
|
+
start_by?: string | undefined;
|
|
704
|
+
attempts?: number | undefined;
|
|
705
|
+
retry_at?: string | undefined;
|
|
706
|
+
catch_up?: boolean | undefined;
|
|
707
|
+
count?: number | undefined;
|
|
708
|
+
key: string;
|
|
709
|
+
by: string;
|
|
710
|
+
nominal_at: string;
|
|
711
|
+
status: import("./store/store.js").FiringStatus;
|
|
712
|
+
at: string;
|
|
713
|
+
run_id: string | null;
|
|
714
|
+
reason: string | null;
|
|
715
|
+
error: {
|
|
716
|
+
code: string;
|
|
717
|
+
message: string;
|
|
718
|
+
} | null;
|
|
719
|
+
}>;
|
|
720
|
+
/** What a release of firing `key` finds, read within its trigger's room checks (release): the firing, released already;
|
|
721
|
+
* the run already under its key (`ran`, linked or not: a stop between its write and handedRan); or the start_by of a
|
|
722
|
+
* firing its host took with no run, which the release then fails. Any other is refused in words. */
|
|
723
|
+
private releasable;
|
|
724
|
+
/** A release refused for firing `key`, `why` saying what it is. */
|
|
725
|
+
private notDue;
|
|
726
|
+
/** A release refused for firing `key` because its run `runId` started: in words, and in `details` (RUN_STARTED and the
|
|
727
|
+
* run) for a host to match. Never retryable: the run stays started. */
|
|
728
|
+
private ranRefusal;
|
|
669
729
|
/** Each sent firing whose host's run is in the store under its key, though the server stopped before the firing was
|
|
670
730
|
* started with it (a late start writes the run, then handedRan): started with that run, so the overlap check and
|
|
671
731
|
* max_active_runs count it. */
|
|
672
732
|
private relink;
|
|
733
|
+
/** Firing `key` started with run `runId`, as `only` allows (FiringChange's guards); said when written. Whether it was. */
|
|
673
734
|
private started;
|
|
674
735
|
/** A failed firing: one more in its trigger's streak, the trigger turned off at FAILURES_TO_PAUSE, and trigger.failed
|
|
675
736
|
* queued (after the firing is written: a start finds one not yet queued and queues it, under the same webhook-id).
|
|
676
|
-
* Failed only while it is due:
|
|
737
|
+
* Failed only while it is due (or as `only` says: a release's, while it is sent with no run and its start_by unmoved):
|
|
738
|
+
* one its host's run started meanwhile is left started, with no failure and no message. The firing as written, or
|
|
739
|
+
* undefined when nothing was. */
|
|
677
740
|
private failed;
|
|
678
741
|
/** Trigger `triggerId`, turned off by its failure streak: off at its sender too (offThere). */
|
|
679
742
|
private pausedThere;
|