@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/learn/secrets.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
-
import { cutSpans, holds, MONEY_SHAPES, planCut, SECRET_SHAPES, shapeKinds } from "../redact/match.js";
|
|
2
|
+
import { CREDENTIAL_NAMES, cutSpans, holds, MONEY_SHAPES, planCut, SECRET_SHAPES, shapeKinds, squeeze } from "../redact/match.js";
|
|
3
3
|
/** Whether `text` ends in a `Bearer` scheme and the blanks after it: the one place a shape is read across whitespace
|
|
4
4
|
* (the scheme, then its token), so a reader that cuts a text at whitespace must not cut there (key-refusal.ts
|
|
5
5
|
* redactedAnswer). */
|
|
@@ -25,9 +25,19 @@ export const PRINT_MAX = 4096;
|
|
|
25
25
|
* form not found as it stands (percent encoded, split by whitespace, an NFKC variant), read in `text` as given, is
|
|
26
26
|
* redacted whole, never in part, unless every character of it is inside what the finds cut: a cut can hide part of a
|
|
27
27
|
* value, so the rest is looked for before the cut (redact/match.ts planCut). So is a text over `max` bytes (PRINT_MAX
|
|
28
|
-
* unless the caller names more), and one whose cut leaves a value or a shape.
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
* unless the caller names more), and one whose cut leaves a value or a shape. `held`: spans of `text` cut in place
|
|
29
|
+
* beside the finds (heldSpans, of values no longer at hand). */
|
|
30
|
+
export function redactSecrets(text, values, max = PRINT_MAX, held = []) {
|
|
31
|
+
return redactWith(text, values, max, SECRET_SHAPES, held);
|
|
32
|
+
}
|
|
33
|
+
/** Where redactSecrets cuts `values` in `text`, shapes left out: each span it cuts in place (UTF-16 offsets, overlapping
|
|
34
|
+
* ones merged, in order), or "whole" when its checks over them cut the text whole (a value split by a line break,
|
|
35
|
+
* percent encoded, an NFKC variant, read in the text as it came: redact/match.ts planCut). What a run's census keeps of
|
|
36
|
+
* a file, never the values (run-census.ts): redactSecrets given these spans as `held` cuts the text as it would have
|
|
37
|
+
* with the values among its own. */
|
|
38
|
+
export function heldSpans(text, values) {
|
|
39
|
+
const cut = planCut(text, derivedOf(values), []);
|
|
40
|
+
return cut === "whole" ? "whole" : cut.spans;
|
|
31
41
|
}
|
|
32
42
|
/** `text` as redactSecrets cuts it, and of a bank's numbers beside their words too (MONEY_SHAPES): what learning prints
|
|
33
43
|
* and serves of what it learned or refused (a problem's path and detail, a note read), never a run's own view, which
|
|
@@ -51,11 +61,11 @@ export function valueLeft(text, values, cuts) {
|
|
|
51
61
|
const needles = derivedOf(values);
|
|
52
62
|
return holds(text, needles, { cuts: cuts ?? cutSpans(text, needles, SECRET_SHAPES) });
|
|
53
63
|
}
|
|
54
|
-
/** redactSecrets over `shapes`, each found in place (redact/match.ts planCut). */
|
|
55
|
-
function redactWith(text, values, max, shapes) {
|
|
64
|
+
/** redactSecrets over `shapes`, each found in place, and `held` spans cut beside them (redact/match.ts planCut). */
|
|
65
|
+
function redactWith(text, values, max, shapes, held = []) {
|
|
56
66
|
if (Buffer.byteLength(text) > max)
|
|
57
67
|
return "[redacted]";
|
|
58
|
-
const cut = planCut(text, derivedOf(values), shapes);
|
|
68
|
+
const cut = planCut(text, derivedOf(values), shapes, held);
|
|
59
69
|
return cut === "whole" ? "[redacted]" : cut.out;
|
|
60
70
|
}
|
|
61
71
|
/** Each value set's Needles, by the array a caller passes, with a copy of the values it was derived of. A run's view
|
|
@@ -63,27 +73,39 @@ function redactWith(text, values, max, shapes) {
|
|
|
63
73
|
* alignments, percent forms, folded needles, for every value, a private key's PEM among them) took seconds per view.
|
|
64
74
|
* An array whose values changed since is derived again, never served a stale set: what a caller adds is always cut. */
|
|
65
75
|
const DERIVED = new WeakMap();
|
|
66
|
-
/** What the matcher looks for of a set of values, whatever the text: each value
|
|
67
|
-
*
|
|
68
|
-
* the needles the whole-text
|
|
76
|
+
/** What the matcher looks for of a set of values, whatever the text: each value, each string of a held JSON value
|
|
77
|
+
* that may be printed alone (heldFields) and their path spellings, their forms found as they stand (as written, as
|
|
78
|
+
* JSON writes it, their plain needles and percent forms), their hex and folded needles, the needles the whole-text
|
|
79
|
+
* check reads (redact/match.ts Needles), and the parts of each of many lines (partsOf), as written and squeezed: of
|
|
80
|
+
* each value but a JSON object or array, and of each string heldFields holds. */
|
|
69
81
|
function derivedOf(values) {
|
|
70
82
|
const kept = DERIVED.get(values);
|
|
71
83
|
if (kept && kept.values.length === values.length && kept.values.every((value, at) => value === values[at]))
|
|
72
84
|
return kept.derived;
|
|
73
|
-
const
|
|
85
|
+
const held = values.filter((v) => v.length > 0);
|
|
86
|
+
const fields = held.map(heldFields);
|
|
87
|
+
const strings = fields.flatMap((of) => of ?? []);
|
|
88
|
+
const whole = [...held, ...strings];
|
|
89
|
+
const given = withPathSpellings(whole);
|
|
74
90
|
const needles = new Map(given.filter(longEnough).map((v) => [v, needlesOf(v)]));
|
|
91
|
+
// A held JSON value's own lines are no parts of it (a pretty-printed one has its public strings on lines of their
|
|
92
|
+
// own); the strings heldFields holds of it have theirs.
|
|
93
|
+
const parts = [...new Set([...held.filter((_, at) => fields[at] === undefined), ...strings].flatMap(partsOf))];
|
|
75
94
|
const derived = {
|
|
76
|
-
forms: [...new Set(given.flatMap((v) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
95
|
+
forms: [...new Set([...given.flatMap((v) => {
|
|
96
|
+
const of = needles.get(v);
|
|
97
|
+
return [v, asJson(v), ...(of ? [...of.plain, ...percentForms(v)] : [])];
|
|
98
|
+
}), ...parts].filter((form) => form.length > 0))],
|
|
80
99
|
hexes: [...needles.values()].map((of) => of.hex),
|
|
81
100
|
folds: [...needles.values()].flatMap((of) => of.folded),
|
|
82
|
-
plain: [...new Set([...needles.values()].flatMap((of) => of.plain))],
|
|
101
|
+
plain: [...new Set([...[...needles.values()].flatMap((of) => of.plain), ...parts.map(squeeze)])],
|
|
83
102
|
};
|
|
84
103
|
DERIVED.set(values, { values: [...values], derived });
|
|
85
104
|
return derived;
|
|
86
105
|
}
|
|
106
|
+
/** What the matcher looks for of `values` (derivedOf, cached by array): the scrubber's held rule (secret-rules.ts) cuts
|
|
107
|
+
* each form, hex and folded identifier in place with redact/match.ts cutSpans. */
|
|
108
|
+
export const heldNeedles = (values) => derivedOf(values);
|
|
87
109
|
/** A value shorter than this matches too much text by chance to be refused. */
|
|
88
110
|
export const MIN_SECRET = 8;
|
|
89
111
|
/** An excerpt of a run's input or answer as learning keeps it: `text` cut of the secrets `shown` knows, whole, then
|
|
@@ -98,7 +120,6 @@ export function excerptShown(text, shown, max) {
|
|
|
98
120
|
const end = /[\uD800-\uDBFF]/.test(clean.charAt(max - 1)) ? max - 1 : max;
|
|
99
121
|
return `${clean.slice(0, end)}…`;
|
|
100
122
|
}
|
|
101
|
-
const squeeze = (text) => text.normalize("NFKC").replace(/\s+/gu, "");
|
|
102
123
|
/** The base64 of `secret` as it can sit inside a longer blob: the characters that depend on the secret's bytes alone,
|
|
103
124
|
* at each of the three alignments, in both alphabets. */
|
|
104
125
|
function base64Needles(secret) {
|
|
@@ -189,6 +210,86 @@ function needlesOf(value) {
|
|
|
189
210
|
return { plain: [...new Set([squeeze(value), squeeze(asJson(value)), ...base64Needles(raw)])], hex: raw.toString("hex"), folded: foldedOf(value) };
|
|
190
211
|
}
|
|
191
212
|
const longEnough = (value) => [...value].length >= MIN_SECRET;
|
|
213
|
+
/** The fewest characters a line of a held value must have to be held as a part of it: a key's base64 line (64) is, a
|
|
214
|
+
* short line any text may hold ("-----END …-----", "}", a JSON field's name and a word) is not. */
|
|
215
|
+
const LINE_MIN = 40;
|
|
216
|
+
const ARMOR_BEGIN = /^-----BEGIN [^-]*-----$/;
|
|
217
|
+
const ARMOR_END = /^-----END [^-]*-----$/;
|
|
218
|
+
/** The parts of a held value of many lines that a reader may print without the rest (`head -n 11 key.pem`, a body
|
|
219
|
+
* with its armor stripped), each held as itself, found as it stands and cut in place, and found in each view: each
|
|
220
|
+
* line of its body of LINE_MIN characters or more, and its body with its line breaks gone. Its body is its lines but
|
|
221
|
+
* a first "-----BEGIN …-----" and a last "-----END …-----", its armor. A key's last body line is mostly shorter than
|
|
222
|
+
* LINE_MIN: one of MIN_SECRET characters or more is held with the END line after it, as written (`tail -n 2 key.pem`).
|
|
223
|
+
* A value of one line has none: it is matched whole. */
|
|
224
|
+
function partsOf(value) {
|
|
225
|
+
const lines = value.split(/\r\n|\r|\n/).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
226
|
+
if (lines.length < 2)
|
|
227
|
+
return [];
|
|
228
|
+
const armored = ARMOR_END.test(lines.at(-1));
|
|
229
|
+
const body = lines.slice(ARMOR_BEGIN.test(lines[0]) ? 1 : 0, armored ? -1 : lines.length);
|
|
230
|
+
const parts = [...body.filter((line) => line.length >= LINE_MIN), body.join("")];
|
|
231
|
+
const last = body.at(-1);
|
|
232
|
+
if (armored && last !== undefined && last.length >= MIN_SECRET && last.length < LINE_MIN) {
|
|
233
|
+
const end = lines.at(-1);
|
|
234
|
+
const endAt = value.lastIndexOf(end);
|
|
235
|
+
parts.push(value.slice(value.lastIndexOf(last, endAt), endAt + end.length));
|
|
236
|
+
}
|
|
237
|
+
return parts.filter(longEnough);
|
|
238
|
+
}
|
|
239
|
+
/** Whether a held JSON value's string under the key `name` is a secret by its name (heldFields): its name with its
|
|
240
|
+
* separators dropped and lowered names a secret, a password, a token, a private value, a credential or an API key, or
|
|
241
|
+
* ends in "key" ("aws_secret_access_key", "SessionToken", "signing_secret", "private_key", "secret_key"); or, lowered,
|
|
242
|
+
* it is a credential parameter's whole name (redact/match.ts CREDENTIAL_NAMES: "signature"). Never one that names a
|
|
243
|
+
* public thing by its end (an id, a URI or URL, a type, an email, an endpoint, an expiry: "client_id", "token_uri",
|
|
244
|
+
* "access_key_id", "token_type"), a public key, or a token that is none (a page's, the next page's). */
|
|
245
|
+
function secretName(name) {
|
|
246
|
+
const flat = name.toLowerCase().replace(/[-_.\s]/g, "");
|
|
247
|
+
if (/(?:uri|url|id|type|email|endpoint|expiry|expires|pagetoken|nexttoken)$/.test(flat) || flat.includes("public"))
|
|
248
|
+
return false;
|
|
249
|
+
return /secret|password|passwd|token|private|credential|apikey/.test(flat) || flat.endsWith("key") || CREDENTIAL_NAMES.has(name.toLowerCase());
|
|
250
|
+
}
|
|
251
|
+
/** A JWK's private members (RFC 7518: an EC or OKP key's "d", an RSA key's "d", "p", "q", "dp", "dq" and "qi", a
|
|
252
|
+
* symmetric key's "k"), held in an object with a "kty" only: elsewhere a one-letter name says nothing. */
|
|
253
|
+
const JWK_PRIVATE = new Set(["d", "p", "q", "dp", "dq", "qi", "k"]);
|
|
254
|
+
/** The strings of a held JSON value (an object or an array, as it parses, at any depth) that may be printed alone, each
|
|
255
|
+
* held as itself (trimmed), as any held value: one that holds a line break (a service account's private key, `jq -r
|
|
256
|
+
* .private_key`), one whose key names a secret (secretName: an OAuth client's "client_secret", an AWS secret access
|
|
257
|
+
* key; never "page_token"), and a JWK's private member beside its "kty" (JWK_PRIVATE). An array's items have no key,
|
|
258
|
+
* so only the line-break rule holds them. Its other strings are not held: an id, a project, an email and public URLs
|
|
259
|
+
* ("client_id", "token_uri") are no secret, and would be cut wherever a text names them. Undefined where `value` is no
|
|
260
|
+
* JSON object or array. */
|
|
261
|
+
function heldFields(value) {
|
|
262
|
+
const head = value.trimStart()[0];
|
|
263
|
+
if (head !== "{" && head !== "[")
|
|
264
|
+
return undefined;
|
|
265
|
+
let parsed;
|
|
266
|
+
try {
|
|
267
|
+
parsed = JSON.parse(value);
|
|
268
|
+
}
|
|
269
|
+
catch {
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
const out = [];
|
|
273
|
+
// Walked with a stack of its own, not a call per level: a value nested thousands deep is read as any other.
|
|
274
|
+
// Each node with its key and whether its object is a JWK (holds a "kty").
|
|
275
|
+
const stack = [[parsed, undefined, false]];
|
|
276
|
+
for (let next = stack.pop(); next !== undefined; next = stack.pop()) {
|
|
277
|
+
const [node, key, jwk] = next;
|
|
278
|
+
if (typeof node === "string") {
|
|
279
|
+
if (/[\r\n]/.test(node) || (key !== undefined && (secretName(key) || (jwk && JWK_PRIVATE.has(key)))))
|
|
280
|
+
out.push(node.trim());
|
|
281
|
+
}
|
|
282
|
+
else if (Array.isArray(node))
|
|
283
|
+
for (const item of node)
|
|
284
|
+
stack.push([item, undefined, false]);
|
|
285
|
+
else if (node !== null && typeof node === "object") {
|
|
286
|
+
const kty = typeof node.kty === "string";
|
|
287
|
+
for (const [name, item] of Object.entries(node))
|
|
288
|
+
stack.push([item, name, kty]);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return out.filter(longEnough);
|
|
292
|
+
}
|
|
192
293
|
/** A matcher for `values` in a text: plain, split by whitespace, as JSON writes it, percent or form encoded, base64 or
|
|
193
294
|
* hex, and each hex identifier in a value folded: in any case, its separators dropped or moved (foldedOf). Values
|
|
194
295
|
* shorter than MIN_SECRET are left out. `fold: false`, the matcher without the folded needles. */
|
package/dist/learning-cost.d.ts
CHANGED
|
@@ -9,30 +9,10 @@
|
|
|
9
9
|
* record at its end (metrics.path). */
|
|
10
10
|
export declare const RUN_PATHS: readonly ["agent", "handed_back", "workflow", "replay", "audit"];
|
|
11
11
|
export type RunPath = (typeof RUN_PATHS)[number];
|
|
12
|
-
/** What a run that looked back kept of its costs as it answered (runner/reflect-hook.ts: store-reads/learning.ts
|
|
13
|
-
* answeredOf): when the job answered, what it had cost by then and what looking back cost after it. */
|
|
14
|
-
export type CostLooked = {
|
|
15
|
-
answered_at?: string;
|
|
16
|
-
job_cost_usd?: number | null;
|
|
17
|
-
look_back_usd?: number | null;
|
|
18
|
-
};
|
|
19
12
|
/** A booked figure with its float noise rounded off, nothing more (runner/metrics.ts floatNoiseOff, the precision a run's
|
|
20
13
|
* own cost is kept at): a decision costs millionths of a dollar, so a figure rounded to the millionth would lose it, and
|
|
21
14
|
* the run's cost here would read other than its usage row (A8). `+ 0` makes a noise-sized negative a plain 0, never -0. */
|
|
22
15
|
export declare const noiseOff: (value: number) => number;
|
|
23
|
-
/** A run's own cost and what learning added for it, from its row's cost (`rowUsd`: the job, its look-back and any turn a
|
|
24
|
-
* person asked of it after) and what it kept as it answered (`looked`, none for a run that did not look back):
|
|
25
|
-
* - `cost_usd`: the job's own $: its row's cost less its look-back, never under what it had cost when it answered (a
|
|
26
|
-
* later turn's spend is the job's too); its row's cost for a run that did not look back;
|
|
27
|
-
* - `learning_usd`: what learning cost for it: its look-back (its compile turn) and what was spent beside it
|
|
28
|
-
* (`besideUsd`: its audit's shadow run), 0 for a run that does not learn; null when unknown (a turn stopped mid-ask
|
|
29
|
-
* spent what no one knows, or a shadow still running);
|
|
30
|
-
* - `total_usd`: their sum, the run's all-in $; null when either is. */
|
|
31
|
-
export declare function runCostOf(rowUsd: number | null, looked: CostLooked | null, besideUsd?: number | null): {
|
|
32
|
-
cost_usd: number | null;
|
|
33
|
-
learning_usd: number | null;
|
|
34
|
-
total_usd: number | null;
|
|
35
|
-
};
|
|
36
16
|
/** One run of the series, in the order the agent's runs started: `n` its number among the runs that do a job (JOB_PATHS,
|
|
37
17
|
* 1 the first: the bill's numbering), null for a replay, which checks a revision and does no job. */
|
|
38
18
|
export type CostRun = {
|
|
@@ -56,7 +36,29 @@ export type CostRun = {
|
|
|
56
36
|
cost_upper_bound: boolean;
|
|
57
37
|
learning_usd: number | null;
|
|
58
38
|
total_usd: number | null;
|
|
39
|
+
/** `learning_usd`'s parts, each null when unknown: its own compile turns (`compile_usd`, which GET /runs/{id} charges
|
|
40
|
+
* to the revision they drafted instead), its follow-up rounds' turns (`followup_usd`) and its audit's shadow run
|
|
41
|
+
* (`shadow_usd`). `share_usd`: its share of its revision's compile and check (amortize), which GET /runs/{id}'s
|
|
42
|
+
* `learning_usd` carries in place of `compile_usd`. */
|
|
43
|
+
compile_usd: number | null;
|
|
44
|
+
followup_usd: number | null;
|
|
45
|
+
shadow_usd: number | null;
|
|
46
|
+
share_usd: number | null;
|
|
47
|
+
/** Why a learned workflow did not serve it alone (NOT_SERVED), null when nothing says. */
|
|
48
|
+
not_served: NotServed | null;
|
|
59
49
|
};
|
|
50
|
+
/** Why a run's learned workflow did not serve it alone: `cost_stop`, the money rule stopped it from running first
|
|
51
|
+
* (runner/workflow-first.ts costLineOf: its WORKFLOW_FIRST entry's `needs_revision`, metrics.not_served); `cut`, a
|
|
52
|
+
* restart cut its call and the run was handed back (metrics.workflow_cut, servedOf `cut`), never the workflow's own
|
|
53
|
+
* hand-back: costSummary counts it in `hand_backs.cut`, not `back`. */
|
|
54
|
+
export declare const NOT_SERVED: readonly ["cost_stop", "cut"];
|
|
55
|
+
export type NotServed = (typeof NOT_SERVED)[number];
|
|
56
|
+
/** The by-hand side, the one baseline both the cost page's `before` and the money rule read (costSummary,
|
|
57
|
+
* runner/workflow-first.ts costLineOf): of `runs` (oldest first), the `agent` runs before the first run a learned
|
|
58
|
+
* workflow served (SERVED_PATHS), every one when none has been served. */
|
|
59
|
+
export declare function byHandSide<T extends {
|
|
60
|
+
readonly path: unknown;
|
|
61
|
+
}>(runs: readonly T[]): T[];
|
|
60
62
|
/** The fewest runs after the takeover a "times cheaper" figure needs: fewer say too little. */
|
|
61
63
|
export declare const CHEAPER_AFTER_RUNS = 20;
|
|
62
64
|
/** How many of a learned workflow's newest runs served first at one version the money rule reads
|
|
@@ -100,8 +102,10 @@ export type AfterState = (typeof AFTER_STATES)[number];
|
|
|
100
102
|
* leaves learning out and the after side keeps it in, so the figure never flatters learning. `withheld`: after a
|
|
101
103
|
* takeover, how many runs either side reads have an unknown cost and how many one known only as at most
|
|
102
104
|
* (`cost_upper_bound`); while any does there is no ratio, null when none does. `hand_backs`: of the served runs from
|
|
103
|
-
* the takeover on, how many handed back
|
|
104
|
-
*
|
|
105
|
+
* the takeover on (`ran`), how many the workflow handed back itself (`back`: an escalate, a failed step, an answer cut
|
|
106
|
+
* by size or schema) and how many a restart cut (`cut`: the run ids `cut` names, its call ended `interrupted`,
|
|
107
|
+
* metrics.workflow_cut); null before a takeover. A cut run stays `handed_back` at agent cost: only the count moves.
|
|
108
|
+
* `replay`: the serving promotion's, as given. Every one is over every run, never only the latest a read lists. */
|
|
105
109
|
export type CostSummary = {
|
|
106
110
|
takeover: {
|
|
107
111
|
n: number;
|
|
@@ -120,6 +124,7 @@ export type CostSummary = {
|
|
|
120
124
|
hand_backs: {
|
|
121
125
|
ran: number;
|
|
122
126
|
back: number;
|
|
127
|
+
cut: number;
|
|
123
128
|
} | null;
|
|
124
129
|
withheld: {
|
|
125
130
|
unknown: number;
|
|
@@ -127,7 +132,7 @@ export type CostSummary = {
|
|
|
127
132
|
} | null;
|
|
128
133
|
replay: CostReplay | null;
|
|
129
134
|
};
|
|
130
|
-
export declare function costSummary(runs: readonly CostRun[], replay?: CostReplay | null): CostSummary;
|
|
135
|
+
export declare function costSummary(runs: readonly CostRun[], replay?: CostReplay | null, cut?: ReadonlySet<string>): CostSummary;
|
|
131
136
|
/** The paths of the runs that do a job: the bill's run index counts these. A replay checks a revision and an audit's
|
|
132
137
|
* shadow audits a run: their spend is learning, booked where it falls (billOf) and carried by the runs they serve. */
|
|
133
138
|
export declare const JOB_PATHS: readonly RunPath[];
|
package/dist/learning-cost.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// An agent's cost per run, run after run (GET /agents/{id}/learning/cost): what each run of its cost, what learning added
|
|
2
2
|
// for it, and the path it took, so a person sees the cost fall once a learned workflow does the job, and by how much.
|
|
3
|
-
// Aggregates only: no run's input, answer or tool text.
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// Aggregates only: no run's input, answer or tool text. Each run's figures come from the ledger (learn/ledger.ts: one row
|
|
4
|
+
// a run written at its end, one spend row a learning cost, read by summarize); this module says what the series shows
|
|
5
|
+
// (costSummary, billOf), the rule the console, the CLI and the CSV all read. It imports only the errors, so the API
|
|
6
6
|
// document reads its words.
|
|
7
7
|
import { ApiError } from "./errors.js";
|
|
8
8
|
/** The path a run took: `workflow`, a learned workflow finished it alone (served first and answered, or its job's only
|
|
@@ -21,23 +21,17 @@ const usd = (value) => Math.round(value * 1e6) / 1e6;
|
|
|
21
21
|
* own cost is kept at): a decision costs millionths of a dollar, so a figure rounded to the millionth would lose it, and
|
|
22
22
|
* the run's cost here would read other than its usage row (A8). `+ 0` makes a noise-sized negative a plain 0, never -0. */
|
|
23
23
|
export const noiseOff = (value) => Math.round(value * 1e12) / 1e12 + 0;
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
export function
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const back = answered ? (looked.look_back_usd ?? null) : 0;
|
|
36
|
-
// What the row holds past the answer and its look-back is a later turn's spend, unknown once the row's cost is; with the
|
|
37
|
-
// look-back's cost unknown the two can't be told apart, and the job is what it had cost when it answered.
|
|
38
|
-
const job = !answered || asAnswered === null || back === null ? asAnswered : rowUsd === null ? null : Math.max(asAnswered, rowUsd - back);
|
|
39
|
-
const spent = back === null || besideUsd === null ? null : back + besideUsd;
|
|
40
|
-
return { cost_usd: job === null ? null : noiseOff(job), learning_usd: spent === null ? null : noiseOff(spent), total_usd: job === null || spent === null ? null : noiseOff(job + spent) };
|
|
24
|
+
/** Why a run's learned workflow did not serve it alone: `cost_stop`, the money rule stopped it from running first
|
|
25
|
+
* (runner/workflow-first.ts costLineOf: its WORKFLOW_FIRST entry's `needs_revision`, metrics.not_served); `cut`, a
|
|
26
|
+
* restart cut its call and the run was handed back (metrics.workflow_cut, servedOf `cut`), never the workflow's own
|
|
27
|
+
* hand-back: costSummary counts it in `hand_backs.cut`, not `back`. */
|
|
28
|
+
export const NOT_SERVED = ["cost_stop", "cut"];
|
|
29
|
+
/** The by-hand side, the one baseline both the cost page's `before` and the money rule read (costSummary,
|
|
30
|
+
* runner/workflow-first.ts costLineOf): of `runs` (oldest first), the `agent` runs before the first run a learned
|
|
31
|
+
* workflow served (SERVED_PATHS), every one when none has been served. */
|
|
32
|
+
export function byHandSide(runs) {
|
|
33
|
+
const first = runs.findIndex((run) => SERVED_PATHS.includes(run.path));
|
|
34
|
+
return (first < 0 ? runs : runs.slice(0, first)).filter((run) => run.path === "agent");
|
|
41
35
|
}
|
|
42
36
|
/** The fewest runs after the takeover a "times cheaper" figure needs: fewer say too little. */
|
|
43
37
|
export const CHEAPER_AFTER_RUNS = 20;
|
|
@@ -67,9 +61,9 @@ export function tookOverOf(runs) {
|
|
|
67
61
|
/** Why the after side has a figure or not: `priced`, it has; `no_served_runs`, no learned workflow has taken over (a
|
|
68
62
|
* replay is no served run); `cost_unknown`, runs were served but none's all-in cost is known exactly. */
|
|
69
63
|
export const AFTER_STATES = ["priced", "no_served_runs", "cost_unknown"];
|
|
70
|
-
export function costSummary(runs, replay = null) {
|
|
64
|
+
export function costSummary(runs, replay = null, cut = new Set()) {
|
|
71
65
|
const first = runs.findIndex((run) => SERVED_PATHS.includes(run.path));
|
|
72
|
-
const beforeSide = (
|
|
66
|
+
const beforeSide = byHandSide(runs).map((run) => ({ value: run.cost_usd, bound: run.cost_upper_bound }));
|
|
73
67
|
// Served runs alone: a replay (a check of a new revision, at workflow cost) and a run by hand are never the after side.
|
|
74
68
|
const served = first < 0 ? [] : runs.slice(first).filter((run) => SERVED_PATHS.includes(run.path));
|
|
75
69
|
const afterSide = served.map((run) => ({ value: run.total_usd, bound: run.cost_upper_bound }));
|
|
@@ -85,7 +79,9 @@ export function costSummary(runs, replay = null) {
|
|
|
85
79
|
const atMost = read.filter(({ bound }) => bound).length;
|
|
86
80
|
const withheld = first >= 0 && unknown + atMost > 0 ? { unknown, at_most: atMost } : null;
|
|
87
81
|
const times = !withheld && before && after && after.runs >= CHEAPER_AFTER_RUNS && after.mean_usd > 0 ? Math.round((before.mean_usd / after.mean_usd) * 10) / 10 : null;
|
|
88
|
-
const
|
|
82
|
+
const handedBack = served.filter((run) => run.path === "handed_back");
|
|
83
|
+
const cutBack = handedBack.filter((run) => cut.has(run.run_id)).length;
|
|
84
|
+
const handBacks = first < 0 ? null : { ran: served.length, back: handedBack.length - cutBack, cut: cutBack };
|
|
89
85
|
const afterState = after ? "priced" : first < 0 ? "no_served_runs" : "cost_unknown";
|
|
90
86
|
return { takeover: first < 0 ? null : { n: runs[first].n, run_id: runs[first].run_id }, before, after, after_state: afterState, times_cheaper: times, hand_backs: handBacks, withheld, replay };
|
|
91
87
|
}
|
package/dist/link-check.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// sets equal, and each value equal, except that a call's value read as "…" (a timeline read elides query values,
|
|
7
7
|
// scrubUrls) matches any value for its key. Structural only: whether a cited item is in scope stays the rubric's call.
|
|
8
8
|
import { lastJsonBlock } from "./answer-json.js";
|
|
9
|
-
import { linksOf, linksWritten, TRAILING, trimmed, wholeUrl } from "
|
|
9
|
+
import { linksOf, linksWritten, TRAILING, trimmed, wholeUrl } from "@parcha/agentrun-web";
|
|
10
10
|
import { scrubUrl } from "./timeline/index.js";
|
|
11
11
|
import { WEB_FETCH_TOOL } from "./web-fetch.js";
|
|
12
12
|
import { WEB_SEARCH_TOOL } from "./web-search.js";
|
package/dist/live-reach.d.ts
CHANGED
|
@@ -69,6 +69,8 @@ export declare const liveForRun: (live: RunnerLive, runId: string) => RunnerLive
|
|
|
69
69
|
export declare function provenFor(req: Pick<IncomingMessage, "headers">, live: Pick<RunnerLive, "key">, viewerId: string, now?: number, windowMs?: number): boolean;
|
|
70
70
|
/** How far a relay's proof's time may be from the runner's clock: the one hop's time, and no more. */
|
|
71
71
|
export declare const RELAY_PROOF_MS = 10000;
|
|
72
|
+
/** How long the server waits for a runner's attach listener to take a relayed dial. */
|
|
73
|
+
export declare const RELAY_CONNECT_MS = 10000;
|
|
72
74
|
/** What a relay's proof binds: the machine's token (its SHA-256), the runner its row names, and that runner's
|
|
73
75
|
* incarnation. A viewer's id has no newline, so no relay subject is ever a viewer's. */
|
|
74
76
|
export type RelayTo = {
|
package/dist/live-reach.js
CHANGED
|
@@ -143,6 +143,8 @@ export function provenFor(req, live, viewerId, now = Date.now(), windowMs = LIVE
|
|
|
143
143
|
// runner and nowhere else. Its window is RELAY_PROOF_MS, and the runner takes each proof once (relayProofs).
|
|
144
144
|
/** How far a relay's proof's time may be from the runner's clock: the one hop's time, and no more. */
|
|
145
145
|
export const RELAY_PROOF_MS = 10_000;
|
|
146
|
+
/** How long the server waits for a runner's attach listener to take a relayed dial. */
|
|
147
|
+
export const RELAY_CONNECT_MS = 10_000;
|
|
146
148
|
const relaySubject = (to) => `attach relay\n${to.tokenSha256}\n${to.runner}\n${to.incarnation}`;
|
|
147
149
|
/** The server's proof for relaying the dial of token `to.tokenSha256` to runner `to.runner`, at `at` (ms). */
|
|
148
150
|
export const relayProof = (reach, to, at = Date.now()) => liveProof(reach, relaySubject(to), at);
|
package/dist/llms.txt
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> The open platform's server for agents: make an agent (a prompt with tools, or a typed workflow), run it, and read what it did, over one HTTP API at `/v2`, an MCP endpoint at `/v2/mcp`, and a CLI. Every run is kept, with its timeline, its files and its cost.
|
|
4
4
|
|
|
5
|
-
Auth: the API's routes take `Authorization: Bearer <token>`, all but `GET /v2/health`, `GET /v2/capabilities` and `GET /v2/openapi.json`; this file needs none. The MCP endpoint takes the Bearer token only. The token is the server's data directory's `.token` (`--data DIR`; without it, `$XDG_DATA_HOME/agentrun/agents`, else `~/.local/share/agentrun/agents`), or `AGENTRUN_TOKEN` when the server was started with it. Never print it. Links below are relative to this server.
|
|
5
|
+
Auth: the API's routes take `Authorization: Bearer <token>`, all but `GET /v2/health`, `GET /v2/capabilities` and `GET /v2/openapi.json`; this file needs none. The MCP endpoint takes the Bearer token only. The token is the server's data directory's `.token` (`--data DIR`; without it, `$XDG_DATA_HOME/agentrun/agents`, else `~/.local/share/agentrun/agents`), or `AGENTRUN_TOKEN` when the server was started with it. An API key the owner made in the console (Settings, AgentRun API keys; it starts `ar_key_`) is taken wherever the token is, except as the setup code; only the owner's signed-in session makes or revokes one. Never print it. Links below are relative to this server.
|
|
6
6
|
|
|
7
7
|
## Start
|
|
8
8
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export declare const MARKETPLACE_URL = "https://marketplace.agentrun.ai";
|
|
2
|
+
export declare const MARKETPLACE_ENV = "AGENTRUN_MARKETPLACE";
|
|
3
|
+
/** How long a list read is answered before it is read again: the site's own cache-control (max-age=300). */
|
|
4
|
+
export declare const MARKETPLACE_TTL_MS: number;
|
|
5
|
+
/** How long a failed read is answered before the next try, so a console open on an offline server asks the network
|
|
6
|
+
* once a minute, not on every page. */
|
|
7
|
+
export declare const MARKETPLACE_RETRY_MS = 60000;
|
|
8
|
+
/** What one read may take: the list's bytes (today's is 68 KB), its entries, and the time the read may last. */
|
|
9
|
+
export declare const MARKETPLACE_LIMITS: {
|
|
10
|
+
readonly bytes: number;
|
|
11
|
+
readonly entries: 1000;
|
|
12
|
+
readonly ms: 10000;
|
|
13
|
+
};
|
|
14
|
+
/** One template on the marketplace. `title`, its display name; `summary`, its card's one line; `description`, the rest;
|
|
15
|
+
* `needs`, what it requires, in the marketplace's words; `harness`, its package's harness preference list (empty: any
|
|
16
|
+
* harness; left out when the list does not say), display only; `page_url`, its page there; `source`, the package an install
|
|
17
|
+
* reads (`github:<owner>/<repo>[/<path>]@<sha>`), when the list names one; `here`, the id of this server's package that
|
|
18
|
+
* is this one, when there is one (a bundled package by its name, or one imported from its source). */
|
|
19
|
+
export type MarketplaceTemplate = {
|
|
20
|
+
name: string;
|
|
21
|
+
title: string;
|
|
22
|
+
summary?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
category?: string;
|
|
25
|
+
tags: string[];
|
|
26
|
+
needs: string[];
|
|
27
|
+
harness?: string[];
|
|
28
|
+
page_url: string;
|
|
29
|
+
source?: string;
|
|
30
|
+
};
|
|
31
|
+
export type MarketplaceAnswer = {
|
|
32
|
+
/** The site read, or null when the marketplace is off here. */
|
|
33
|
+
url: string | null;
|
|
34
|
+
/** `read`: the list as read within the last 5 minutes; `stale`: the last read failed, and this is the list as read at
|
|
35
|
+
* `read_at`; `unreachable`: no read has worked yet, so the list is empty; `off`: this server reads no marketplace. */
|
|
36
|
+
state: "read" | "stale" | "unreachable" | "off";
|
|
37
|
+
read_at: string | null;
|
|
38
|
+
/** Why the last read failed (`stale`, `unreachable`), or why the marketplace is off. */
|
|
39
|
+
problem?: string;
|
|
40
|
+
templates: (MarketplaceTemplate & {
|
|
41
|
+
here?: string;
|
|
42
|
+
})[];
|
|
43
|
+
};
|
|
44
|
+
/** The marketplace this server reads, from the environment: its address, or null for off. Unset, the public one, except
|
|
45
|
+
* under --faux (a test's or a demo's server, which reaches no network unasked). `off` (or 0, false) turns it off. An
|
|
46
|
+
* address is an https origin (with a path, when the site is served under one); http is taken for a loopback host
|
|
47
|
+
* alone, a local copy of the site. Anything else stops the start: the owner set it, and a typo should not read as off. */
|
|
48
|
+
export declare function marketplaceUrlOf(env: NodeJS.ProcessEnv, faux: boolean): string | null;
|
|
49
|
+
/** One entry of the list read as a template, or undefined for one that is not (no name of a package's shape): an entry's
|
|
50
|
+
* other fields are kept where they are of their shape and dropped where not, so one odd field never hides a template. */
|
|
51
|
+
export declare function entryOf(raw: unknown, site: string): MarketplaceTemplate | undefined;
|
|
52
|
+
/** The list's JSON read as templates, in its order, each name once (its first entry), at most MARKETPLACE_LIMITS.entries.
|
|
53
|
+
* Anything but a list is the read's failure. */
|
|
54
|
+
export declare function listOf(json: unknown, site: string): MarketplaceTemplate[];
|
|
55
|
+
/** The package here that a marketplace entry is, by id: with a source, the package imported from it, else the bundled
|
|
56
|
+
* package of its name when the source is where this server's own packages live; with none (a list that names no
|
|
57
|
+
* sources), the package of its name, a bundled one first. */
|
|
58
|
+
export declare function hereOf(entry: Pick<MarketplaceTemplate, "name" | "source">, packages: readonly {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
origin: unknown;
|
|
62
|
+
}[]): string | undefined;
|
|
63
|
+
/** The marketplace's list as this server reads it: on demand, kept MARKETPLACE_TTL_MS, one read at a time however many
|
|
64
|
+
* ask, and the last good list kept through a failed read. `fetchImpl`, `now` and `deadlineMs` (the read's time limit,
|
|
65
|
+
* MARKETPLACE_LIMITS.ms unless said) are a test's seams. */
|
|
66
|
+
export declare class Marketplace {
|
|
67
|
+
#private;
|
|
68
|
+
readonly url: string | null;
|
|
69
|
+
constructor(url: string | null, options?: {
|
|
70
|
+
fetchImpl?: typeof fetch;
|
|
71
|
+
now?: () => number;
|
|
72
|
+
deadlineMs?: number;
|
|
73
|
+
});
|
|
74
|
+
list(): Promise<Omit<MarketplaceAnswer, "templates"> & {
|
|
75
|
+
templates: MarketplaceTemplate[];
|
|
76
|
+
}>;
|
|
77
|
+
}
|