@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/paid-calls.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
// A web tool's request to Parallel (its search
|
|
1
|
+
// A web tool's request to Parallel (its search and its extract, @parcha/agentrun-web), booked as a monid endpoint's
|
|
2
2
|
// call is (monid.ts): on the run's one ledger (the kernel cap's paid tool calls, RunTools), admitted at the request's price
|
|
3
3
|
// before it is sent (refused unsent in the cap's words when the cap does not hold it) and settled after at what it
|
|
4
4
|
// charged. A charge is the run's cost, a line of its own on its timeline and /usage's `tools` meter. Every request goes
|
|
5
|
-
// through the run's one Parallel client's `post` (web-
|
|
5
|
+
// through the run's one Parallel client's `post` (the run's Web, web-run.ts webOf), which books it here at the fee web's
|
|
6
|
+
// fees.ts prices it at. PaidRefused is web's, so web's client reads a refusal as its own.
|
|
6
7
|
// Parallel's answers report what they used as SKU counts, never an amount, so each request is booked at Parallel's
|
|
7
8
|
// published price, an estimate: its price on a 2xx; nothing on a 4xx other than a 408 (Parallel refused it before any
|
|
8
9
|
// work); and its price on a 408, a 5xx or a request that failed or was stopped after it was sent, which Parallel may
|
|
@@ -14,44 +15,8 @@
|
|
|
14
15
|
// and narrowed to the tool's own call by `booking`, where the web tools are bound (tools.ts). The client deep inside a
|
|
15
16
|
// tool books without the ledger passed down to it.
|
|
16
17
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
18
|
+
import { PaidRefused } from "@parcha/agentrun-web";
|
|
17
19
|
import { SPEND_CAP_REACHED } from "./cap.js";
|
|
18
|
-
/** Parallel's published prices (https://docs.parallel.ai/resources/pricing, read 2026-11-20). Search, by the request's
|
|
19
|
-
* `mode`: `turbo` or `fast` $1 per 1,000 requests, `basic` or `advanced` $5 per 1,000, each with 10 results included,
|
|
20
|
-
* and each result past those 10 $1 per 1,000. Extract: $1 per 1,000 URLs. */
|
|
21
|
-
export const PARALLEL_SEARCH_MODE_USD = Object.freeze({ turbo: 0.001, fast: 0.001, basic: 0.005, advanced: 0.005 });
|
|
22
|
-
/** A `fast` search's price: the mode the web tools search in (web-search.ts). */
|
|
23
|
-
export const PARALLEL_SEARCH_USD = 0.001;
|
|
24
|
-
export const PARALLEL_SEARCH_RESULT_USD = 0.001;
|
|
25
|
-
export const PARALLEL_SEARCH_INCLUDED = 10;
|
|
26
|
-
export const PARALLEL_EXTRACT_USD = 0.001;
|
|
27
|
-
/** In whole millionths of a dollar, so a sum of prices is the price. */
|
|
28
|
-
const usd = (dollars) => Math.round(dollars * 1e6) / 1e6;
|
|
29
|
-
const isSearchMode = (mode) => typeof mode === "string" && Object.hasOwn(PARALLEL_SEARCH_MODE_USD, mode);
|
|
30
|
-
/** A search in `mode` for `n` results: the mode's price (PARALLEL_SEARCH_MODE_USD), and $0.001 for each past the 10 it
|
|
31
|
-
* includes. The web tools search `fast`: $0.001. */
|
|
32
|
-
export const parallelSearchFee = (n, mode = "fast") => {
|
|
33
|
-
const more = Math.max(0, n - PARALLEL_SEARCH_INCLUDED);
|
|
34
|
-
return { name: "Parallel's search", by: "parallel", usd: usd(PARALLEL_SEARCH_MODE_USD[mode] + PARALLEL_SEARCH_RESULT_USD * more), basis: more ? `Parallel's list price for a ${mode} search of ${n} results` : `Parallel's list price for a ${mode} search` };
|
|
35
|
-
};
|
|
36
|
-
/** An extract of `urls` URLs (the web tools ask one at a time). */
|
|
37
|
-
export const parallelExtractFee = (urls = 1) => ({ name: "Parallel's extract", by: "parallel", usd: usd(PARALLEL_EXTRACT_USD * urls), basis: urls === 1 ? "Parallel's list price for one URL" : `Parallel's list price for ${urls} URLs` });
|
|
38
|
-
/** The fee of a request to Parallel's `url` with `body`: its search's, by its `mode` and the results it asks for (10 by
|
|
39
|
-
* default), or its extract's, by the URLs; undefined for an endpoint the web tools do not ask, and for a search whose
|
|
40
|
-
* mode has no price here (one naming none, or one Parallel added since): never $0, never another mode's price. */
|
|
41
|
-
export function parallelFeeOf(url, body) {
|
|
42
|
-
const path = URL.parse(url)?.pathname;
|
|
43
|
-
const asked = (body ?? {});
|
|
44
|
-
if (path === "/v1/search")
|
|
45
|
-
return isSearchMode(asked.mode) ? parallelSearchFee(typeof asked.advanced_settings?.max_results === "number" ? asked.advanced_settings.max_results : PARALLEL_SEARCH_INCLUDED, asked.mode) : undefined;
|
|
46
|
-
if (path === "/v1/extract")
|
|
47
|
-
return parallelExtractFee(Array.isArray(asked.urls) ? Math.max(1, asked.urls.length) : 1);
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
/** A paid request the run's cap refused, whose hold could not be kept, or that has no run's ledger to book it on:
|
|
51
|
-
* nothing was sent. Its message is the refusal, in the cap's words. */
|
|
52
|
-
export class PaidRefused extends Error {
|
|
53
|
-
name = "PaidRefused";
|
|
54
|
-
}
|
|
55
20
|
/** `error`, a refusal of the run's one ledger, as its pause takes it: the cap's refusal for room (a raise would send
|
|
56
21
|
* the step) with its figures; undefined for anything else (a refusal for good, a hold that could not be kept). */
|
|
57
22
|
const roomOf = (error) => {
|
package/dist/place-offers.d.ts
CHANGED
|
@@ -99,6 +99,10 @@ export type PlaceOffersOptions = {
|
|
|
99
99
|
container?: ContainerFacts;
|
|
100
100
|
/** Under --faux only: Docker answers, whatever AGENTRUN_BOXES lists, and nothing asks it. */
|
|
101
101
|
fauxDocker?: boolean;
|
|
102
|
+
/** Told the architecture of the Docker daemon the probe found (amd64, arm64), when Docker answers and names it: the
|
|
103
|
+
* server's check that a Docker computer's daemon is built for it (box-paths.ts dockerComputerRefusal) asks Docker
|
|
104
|
+
* nothing more. */
|
|
105
|
+
dockerArch?: (arch: string) => void;
|
|
102
106
|
};
|
|
103
107
|
/** Every box, in BOX_IDS order, as this server has it at its start (`env`: its environment, its secrets readable): a box AGENTRUN_BOXES does not list is not enabled; docker by its probe (or `fauxDocker`); daytona
|
|
104
108
|
* and modal by their keys. Rejects only for a name in AGENTRUN_BOXES that is no box. No reason holds a key or an answer's body. */
|
package/dist/place-offers.js
CHANGED
|
@@ -169,13 +169,13 @@ export async function askDockerDaemon(env, signal, groups = ownGroups(), contain
|
|
|
169
169
|
return { up: true };
|
|
170
170
|
}
|
|
171
171
|
/** Docker's offer: `docker version` names the daemon's version, so the CLI is on PATH and its daemon answers this user.
|
|
172
|
-
* Bounded by `timeoutMs`; never rejects. */
|
|
173
|
-
async function probeDocker(env, timeoutMs, groups, container) {
|
|
172
|
+
* The same call names the daemon's architecture, told to `arch` when it does. Bounded by `timeoutMs`; never rejects. */
|
|
173
|
+
async function probeDocker(env, timeoutMs, groups, container, arch) {
|
|
174
174
|
const no = (reason) => ({ id: "docker", available: false, reason: inOtherContainer(container, reason) });
|
|
175
175
|
// Its environment is the server's through the cut a run's takes (withoutSecrets): no box key, no other secret, no
|
|
176
176
|
// name shaped like a key.
|
|
177
177
|
const dockerEnv = withoutSecrets(env);
|
|
178
|
-
const answer = await new Promise((resolve) => execFile("docker", ["version", "--format", "{{.Server.Version}}"], { env: dockerEnv, timeout: timeoutMs, killSignal: "SIGKILL", maxBuffer: 64 * 1024 }, (error, stdout, stderr) => {
|
|
178
|
+
const answer = await new Promise((resolve) => execFile("docker", ["version", "--format", "{{.Server.Version}} {{.Server.Arch}}"], { env: dockerEnv, timeout: timeoutMs, killSignal: "SIGKILL", maxBuffer: 64 * 1024 }, (error, stdout, stderr) => {
|
|
179
179
|
const failed = error;
|
|
180
180
|
const code = failed?.code;
|
|
181
181
|
resolve({ ...(failed ? { failed: typeof code === "number" ? `exit ${code}` : errorName(failed), ...(failed.killed ? { late: true } : {}), ...(SOCKET_DENIED.test(String(stderr)) ? { denied: true } : {}), ...endpointIn(stderr) } : {}), out: String(stdout) });
|
|
@@ -197,6 +197,9 @@ async function probeDocker(env, timeoutMs, groups, container) {
|
|
|
197
197
|
return no(`Docker isn't running on this machine, or this user may not use it (docker version failed: ${answer.failed}): start Docker, or add this user to the docker group, then restart AgentRun`);
|
|
198
198
|
if (!answer.out.trim())
|
|
199
199
|
return no("Docker isn't running on this machine (docker version named no daemon): start Docker, then restart AgentRun");
|
|
200
|
+
const named = /^\S+\s+(\S+)$/.exec(answer.out.trim())?.[1];
|
|
201
|
+
if (named !== undefined)
|
|
202
|
+
arch?.(named);
|
|
200
203
|
return { id: "docker", available: true };
|
|
201
204
|
}
|
|
202
205
|
/** A remote box's offer: available when every key its computer provider requires is set, read as a run's claim reads
|
|
@@ -223,7 +226,7 @@ export async function placeOffers(env, options = {}) {
|
|
|
223
226
|
if (!enabled.has(id))
|
|
224
227
|
return { id, available: false, reason: notEnabled(id, enabled) };
|
|
225
228
|
if (id === "docker")
|
|
226
|
-
return probeDocker(env, options.timeoutMs ?? PROBE_TIMEOUT_MS, options.groups ?? ownGroups(), options.container ?? containerOf(env));
|
|
229
|
+
return probeDocker(env, options.timeoutMs ?? PROBE_TIMEOUT_MS, options.groups ?? ownGroups(), options.container ?? containerOf(env), options.dockerArch);
|
|
227
230
|
return remoteOffer(id, keyOf);
|
|
228
231
|
}));
|
|
229
232
|
}
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HarnessWire as Wire } from "@parcha/agentrun-kernel";
|
|
2
|
-
import type
|
|
2
|
+
import { type RunLogin } from "./claude-login.js";
|
|
3
3
|
import { type ModelNeeds, type ModelRef } from "./model.js";
|
|
4
4
|
import { modelWire, WIRES, wireOf } from "./wires.js";
|
|
5
5
|
export { modelWire, WIRES, wireOf };
|
|
@@ -66,6 +66,8 @@ export declare function anthropicModelId(model: ModelRef): string;
|
|
|
66
66
|
* calling Anthropic itself; `origin` and `credential` are never read (no proxy, no key). */
|
|
67
67
|
/** `headers`: what each request on serve's own gateway carries beside its key (request-metadata.ts: the run, turn and
|
|
68
68
|
* attempt it was made for, as LiteLLM's spend-logs metadata); none on any other endpoint. */
|
|
69
|
+
/** `fetch`: the route's own, for a model it translates onto the wire (routedProvider): the harness's proxy forwards
|
|
70
|
+
* with it, to `origin` (ROUTE_ORIGIN), and nothing goes to the network but what the route sends. */
|
|
69
71
|
export type Provider = {
|
|
70
72
|
origin: string;
|
|
71
73
|
credential: () => string | Promise<string>;
|
|
@@ -74,9 +76,16 @@ export type Provider = {
|
|
|
74
76
|
priceModel: ModelRef;
|
|
75
77
|
billing?: "plan";
|
|
76
78
|
refused?: (credential: string) => Promise<void>;
|
|
77
|
-
login?:
|
|
79
|
+
login?: RunLogin;
|
|
78
80
|
headers?: Readonly<Record<string, string>>;
|
|
81
|
+
fetch?: typeof fetch;
|
|
79
82
|
};
|
|
83
|
+
/** The provider of a held run its model kept from running at its create (run-launch.ts hold.refused), on pi and on every
|
|
84
|
+
* CLI harness's proxy: its model's route chooses no model and reads no key, so a host with no key for its model still
|
|
85
|
+
* opens its claim and holds its computer. Its credential refuses in `words`, the create's own: the session's proxy reads it first
|
|
86
|
+
* and refuses each request in them (CredentialUnavailable), before the request is admitted, booked or sent. Its origin
|
|
87
|
+
* names no host. */
|
|
88
|
+
export declare const heldRefusedProvider: (model: ModelRef, words: string) => Provider;
|
|
80
89
|
export declare function providerFor(wire: Wire, env: NodeJS.ProcessEnv, model: ModelRef, who: string): Provider;
|
|
81
90
|
/** The catalog entry a run on `wire` of `model` is capped and priced by: providerFor's, or the model's own (normalized)
|
|
82
91
|
* where the wire refuses the run (its run is refused before any request). */
|
package/dist/provider.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { CredentialUnavailable, ROUTE_ORIGIN } from "@parcha/agentrun-kernel/host";
|
|
2
|
+
import { CLAUDE_LOGIN_PROVIDER, onClaudeLogin, claudeLoginOf, loginServes } from "./claude-login.js";
|
|
3
|
+
import { chooseModel, FAUX_ENV, hostModel, MODEL_PROVIDER, ollamaWouldRun, START_OLLAMA } from "./model.js";
|
|
4
|
+
import { modelWire, routed, routedId, translatesOnto, WIRES, wireOf } from "./wires.js";
|
|
4
5
|
import { modelFormWhy } from "./model-form.js";
|
|
5
6
|
import { gatewayHeadersOf } from "./request-metadata.js";
|
|
6
7
|
import { EXPIRED, PLAN_ORIGIN, PLAN_PROVIDER, planOf, SIGNED_OUT } from "./chatgpt-plan.js";
|
|
@@ -117,6 +118,41 @@ export const openRouterName = (id) => id.replace(/-(\d+)-(\d+)$/, "-$1.$2");
|
|
|
117
118
|
export function anthropicModelId(model) {
|
|
118
119
|
return model.provider === WIRES["anthropic-messages"].vendor ? model.modelId.replaceAll(".", "-") : model.modelId;
|
|
119
120
|
}
|
|
121
|
+
/** The provider of a held run its model kept from running at its create (run-launch.ts hold.refused), on pi and on every
|
|
122
|
+
* CLI harness's proxy: its model's route chooses no model and reads no key, so a host with no key for its model still
|
|
123
|
+
* opens its claim and holds its computer. Its credential refuses in `words`, the create's own: the session's proxy reads it first
|
|
124
|
+
* and refuses each request in them (CredentialUnavailable), before the request is admitted, booked or sent. Its origin
|
|
125
|
+
* names no host. */
|
|
126
|
+
export const heldRefusedProvider = (model, words) => ({
|
|
127
|
+
origin: "https://held-run.invalid",
|
|
128
|
+
credential: () => {
|
|
129
|
+
throw new CredentialUnavailable(words);
|
|
130
|
+
},
|
|
131
|
+
auth: "bearer",
|
|
132
|
+
modelId: model.modelId,
|
|
133
|
+
priceModel: model,
|
|
134
|
+
});
|
|
135
|
+
/** A model the runner's route translates onto a harness's wire (wires.ts routed): its proxy forwards to the route's own
|
|
136
|
+
* origin (ROUTE_ORIGIN), where the route's fetch answers (runner/model-route.ts routeOf on `env`: the model's own
|
|
137
|
+
* provider, an Ollama model's num_ctx and its tools as text where it takes them so), translated onto `wire` by its entry
|
|
138
|
+
* in TRANSLATORS, priced by its catalog entry ($0 for an Ollama model, whose requests the cap counts as local). No key. The route is made at the first
|
|
139
|
+
* request (routeOf is asynchronous) and kept; one that failed is made again at the next. */
|
|
140
|
+
function routedProvider(env, wire, model) {
|
|
141
|
+
let route;
|
|
142
|
+
const sent = (async (input, init) => {
|
|
143
|
+
route ??= import("./runner/model-route.js").then(({ TRANSLATORS }) => {
|
|
144
|
+
const translate = TRANSLATORS[wire];
|
|
145
|
+
if (!translate)
|
|
146
|
+
throw new Error(`The model route has no translation onto ${wire}.`);
|
|
147
|
+
return translate(`${model.provider}/${model.modelId}`, env);
|
|
148
|
+
}).catch((error) => {
|
|
149
|
+
route = undefined;
|
|
150
|
+
throw error;
|
|
151
|
+
});
|
|
152
|
+
return (await route)(input, init);
|
|
153
|
+
});
|
|
154
|
+
return { origin: ROUTE_ORIGIN, credential: () => "model-route", auth: "x-api-key", modelId: model.modelId, priceModel: model, fetch: sent };
|
|
155
|
+
}
|
|
120
156
|
/** `env`'s gateway headers (gatewayHeadersOf), as a Provider's optional field. */
|
|
121
157
|
const onGateway = (env) => {
|
|
122
158
|
const headers = gatewayHeadersOf(env);
|
|
@@ -136,11 +172,22 @@ export function providerFor(wire, env, model, who) {
|
|
|
136
172
|
// A harness on its own plan (Cursor's) calls its vendor itself, on its owner's key: no route of ours is its.
|
|
137
173
|
if (!modelWire(wire))
|
|
138
174
|
throw new HarnessUnavailable(`${who} runs its model on its own plan, never through a model route of AgentRun's; ${named} is not one to proxy.`);
|
|
175
|
+
// A model the route translates onto this wire, for any harness on it; never behind serve's gateway, whose models are its.
|
|
176
|
+
if (routed(wire, model) && !env.AGENT_MODEL_BASE_URL)
|
|
177
|
+
return routedProvider(env, wire, model);
|
|
139
178
|
if (wire === "anthropic-messages") {
|
|
140
179
|
// A model of serve's gateway that the gateway takes on Messages (a Claude model, model.ts gatewayWire): the gateway's
|
|
141
180
|
// own route, as on Responses. No harness of this wire chooses one (claude-agent's model is never the gateway's).
|
|
142
181
|
if (model.provider === MODEL_PROVIDER && env.AGENT_MODEL_BASE_URL)
|
|
143
182
|
return gatewayProvider(env, model);
|
|
183
|
+
// Claude Code's login on this machine, turned on here: a model it runs (loginServes: Anthropic's own) goes on it,
|
|
184
|
+
// whatever key is set. Any other, Anthropic's through OpenRouter included, goes on its provider's key below. The
|
|
185
|
+
// refusal's offer to move a box agent to the runner (loginOnRunnerOnly) asks the same rule.
|
|
186
|
+
const login = loginServes(named) && onClaudeLogin(env, who) ? claudeLoginOf(env) : undefined;
|
|
187
|
+
if (login) {
|
|
188
|
+
const own = anthropicModelId(model);
|
|
189
|
+
return { origin: ANTHROPIC_ORIGIN, credential: () => "", auth: "x-api-key", modelId: own, priceModel: { provider: CLAUDE_LOGIN_PROVIDER, modelId: own }, billing: "plan", login };
|
|
190
|
+
}
|
|
144
191
|
if (model.provider === "openrouter" && model.modelId.startsWith("anthropic/")) {
|
|
145
192
|
const own = anthropicModelId({ provider: "anthropic", modelId: model.modelId.slice("anthropic/".length) });
|
|
146
193
|
return { origin: OPENROUTER_BASE, credential: openRouterKey(env, who, named), auth: "bearer", modelId: own, priceModel: { provider: "openrouter", modelId: `anthropic/${openRouterName(own)}` } };
|
|
@@ -148,10 +195,6 @@ export function providerFor(wire, env, model, who) {
|
|
|
148
195
|
if (model.provider !== "anthropic")
|
|
149
196
|
throw new HarnessUnavailable(`${who} runs Anthropic models; the run's model is ${named}.`);
|
|
150
197
|
const own = anthropicModelId(model);
|
|
151
|
-
// Claude Code's login on this machine, turned on here: claude-agent's Anthropic model goes on it, whatever key is set.
|
|
152
|
-
const login = onClaudeLogin(env, who) ? claudeLoginOf(env) : undefined;
|
|
153
|
-
if (login)
|
|
154
|
-
return { origin: ANTHROPIC_ORIGIN, credential: () => "", auth: "x-api-key", modelId: own, priceModel: { provider: CLAUDE_LOGIN_PROVIDER, modelId: own }, billing: "plan", login };
|
|
155
198
|
if (openRouterOnly(wire, env))
|
|
156
199
|
return { origin: OPENROUTER_BASE, credential: openRouterKey(env, who, named), auth: "bearer", modelId: own, priceModel: { provider: "openrouter", modelId: `anthropic/${openRouterName(own)}` } };
|
|
157
200
|
// The endpoint first: one it refuses is the reason, and no key would fix it (no `keys`). An endpoint the host names
|
|
@@ -210,6 +253,14 @@ export async function modelOn(wire, env, ref, harness) {
|
|
|
210
253
|
return { why: `${harness} runs a model of its own plan, which its own entry chooses.`, host: false };
|
|
211
254
|
const { vendor, label } = WIRES[wire];
|
|
212
255
|
const named = ref ?? hostModel(env, "default", harness);
|
|
256
|
+
// A model the route translates onto this wire (an Ollama model; the host's default with no key held, read from the
|
|
257
|
+
// Ollama here): chosen as pi's is (model.ts chooseModel: that Ollama listed, its tag asked of it, an expired default
|
|
258
|
+
// chosen again), with the no-model words below where none is.
|
|
259
|
+
if (!env[FAUX_ENV] && !env.AGENT_MODEL_BASE_URL && (named === undefined ? translatesOnto(wire) : routedId(wire, named))) {
|
|
260
|
+
const chosen = await chooseModel(env, ref, "default", harness);
|
|
261
|
+
if ("model" in chosen || named !== undefined)
|
|
262
|
+
return chosen;
|
|
263
|
+
}
|
|
213
264
|
if (wire === "openai-responses") {
|
|
214
265
|
if (env[FAUX_ENV] || !openRouterOnly(wire, env) || !named?.startsWith(`${vendor}/`))
|
|
215
266
|
return chooseModel(env, ref, "default", harness);
|
|
@@ -220,7 +271,7 @@ export async function modelOn(wire, env, ref, harness) {
|
|
|
220
271
|
return { model: { provider: vendor, modelId } };
|
|
221
272
|
}
|
|
222
273
|
if (!named)
|
|
223
|
-
return { why: `No model yet for ${harness}: add an OpenRouter or ${label} key in Settings → Model keys, or set OPENROUTER_API_KEY or ${WIRES[wire].key} where AgentRun starts.`, host: true };
|
|
274
|
+
return { why: `No model yet for ${harness}: ${ollamaWouldRun(env, harness) ? START_OLLAMA : ""}add an OpenRouter or ${label} key in Settings → Model keys, or set OPENROUTER_API_KEY or ${WIRES[wire].key} where AgentRun starts.`, host: true };
|
|
224
275
|
const slash = named.indexOf("/");
|
|
225
276
|
if (slash < 1)
|
|
226
277
|
return { why: modelFormWhy(env, harness, named, ref === undefined), host: ref === undefined };
|
package/dist/redact/match.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export type Span = [start: number, end: number];
|
|
2
|
-
/** The characters the
|
|
3
|
-
* read, each guard read back
|
|
4
|
-
*
|
|
2
|
+
/** The characters the redaction pipeline has visited in this process: the text each prefix search passes over, each
|
|
3
|
+
* run read, each guard read back (the shape scanners); each form, hex, folded and plain needle's search, and the text
|
|
4
|
+
* it passes over (find); each view built (its special characters found, its blanks, its decoders' reads, its non-ASCII
|
|
5
|
+
* stretches squeezed, each cut its cover passes), lowered and flattened; each covered stretch a find in a view is
|
|
6
|
+
* checked against (inside); the finds merged and the text cut; and
|
|
7
|
+
* key-refusal.ts's reads of a text in pieces. A test sets it to 0, redacts, and reads it: a stage that read again from
|
|
8
|
+
* the start at each find would count the text once per find. */
|
|
5
9
|
export declare const scanned: {
|
|
6
10
|
chars: number;
|
|
7
11
|
};
|
|
@@ -25,12 +29,24 @@ export type Shape = {
|
|
|
25
29
|
readonly ci?: boolean;
|
|
26
30
|
readonly scan: (text: string, at: number, prefix: string) => Found;
|
|
27
31
|
};
|
|
32
|
+
/** Where the private key block whose "-----BEGIN" stands at `at` ends, past its END line, or -1: no key's header there,
|
|
33
|
+
* or no END line in reach, as PRIVATE_KEY reads it whole. key-refusal.ts reads it so that no piece of an answer ends
|
|
34
|
+
* inside a block. Whether any "-----" stands within KEY_BODY_MAX of the header is read back from there first (the
|
|
35
|
+
* header's own closing dashes stop that read), so a header with none after it reads no further. */
|
|
36
|
+
export declare function privateKeyEnd(text: string, at: number): number;
|
|
37
|
+
/** Each name a credential parameter goes by, as written after "?" or "&" and lowered; and each key, lowered, of a held
|
|
38
|
+
* JSON value whose string is held as itself (learn/secrets.ts heldFields). */
|
|
39
|
+
export declare const CREDENTIAL_NAMES: ReadonlySet<string>;
|
|
28
40
|
/** Text shaped like a secret, by kind. The same shapes the Pi learning loop's guard refuses. */
|
|
29
41
|
export declare const SECRET_SHAPES: readonly Shape[];
|
|
30
42
|
/** A bank's numbers beside their words, which learning never keeps: an account, IBAN, routing or sort-code number. Not
|
|
31
43
|
* one of SECRET_SHAPES: a run may show its user an account number (a finance job's answer), and those shapes cut every
|
|
32
44
|
* run's view; only what learning keeps refuses them. */
|
|
33
45
|
export declare const MONEY_SHAPES: readonly Shape[];
|
|
46
|
+
/** Every span `shape` matches in `text`, each on its own (not merged), in order: the scrubber's known-format rules
|
|
47
|
+
* (secret-rules.ts) read each match, a URL's password inside its `://user:password@`, a PEM header stretched to its
|
|
48
|
+
* block's end. */
|
|
49
|
+
export declare function shapeSpans(text: string, shape: Shape): Span[];
|
|
34
50
|
/** The kinds of `shapes` in `text`, each once, in their order. */
|
|
35
51
|
export declare function shapeKinds(text: string, shapes: readonly Shape[]): string[];
|
|
36
52
|
/** What the matcher looks for of a set of held values (learn/secrets.ts derives it of each value and its spellings):
|
|
@@ -50,6 +66,17 @@ export type Needles = {
|
|
|
50
66
|
export declare function merged(found: readonly (readonly [number, number])[]): Span[];
|
|
51
67
|
/** `text` with each of `spans` (merged, in order) replaced by "[redacted]". */
|
|
52
68
|
export declare function cutAt(text: string, spans: readonly Span[]): string;
|
|
69
|
+
/** `text` as a view reads it, and as a held value's needles are read: NFKC, with its whitespace and its characters that
|
|
70
|
+
* render as nothing gone, before NFKC (so one between a letter and its accent hides neither) and after. A held value
|
|
71
|
+
* with a zero-width space or a soft hyphen between its characters reads as itself. */
|
|
72
|
+
export declare const squeeze: (text: string) => string;
|
|
73
|
+
/** What JSON_ESCAPE reads at `at`: the character the escape there decodes to, through both levels, and where it ends;
|
|
74
|
+
* undefined where no escape starts (the "\" is then itself). key-refusal.ts's peek counts an escape by it, so the
|
|
75
|
+
* read past a call's stop and the JSON view see the same characters. */
|
|
76
|
+
export declare function jsonEscapeAt(text: string, at: number): {
|
|
77
|
+
char: string;
|
|
78
|
+
end: number;
|
|
79
|
+
} | undefined;
|
|
53
80
|
/** Whether `text` holds a held value in a form the cut does not find as it stands: split by whitespace, percent or
|
|
54
81
|
* form encoded, an NFKC variant, its hex in any case, a hex identifier folded (`fold`). With `cuts`, a value whose
|
|
55
82
|
* every character the view read comes from inside the cuts is not held: it is cut in place. */
|