@parcha/agentrun-serve 0.1.0-beta.49 → 0.1.0-beta.50
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 +26 -9
- package/README.md +104 -22
- package/dist/agent-delete.d.ts +3 -2
- package/dist/agent-delete.js +29 -4
- package/dist/api-only.d.ts +7 -10
- package/dist/api-only.js +9 -11
- package/dist/compute-cost.d.ts +101 -0
- package/dist/compute-cost.js +250 -0
- package/dist/console/assets/{index-CR2ZGei1.css → index-D0mr9wfZ.css} +1 -1
- package/dist/console/assets/index-D7G6o-1E.js +720 -0
- package/dist/console/index.html +2 -2
- package/dist/eval-previous.d.ts +52 -0
- package/dist/eval-previous.js +164 -0
- package/dist/file-types.d.ts +2 -0
- package/dist/file-types.js +3 -1
- package/dist/harness.js +2 -1
- package/dist/learn/check.d.ts +8 -5
- package/dist/learn/check.js +25 -24
- package/dist/learn/repick.d.ts +22 -13
- package/dist/learn/repick.js +57 -56
- package/dist/learn/workflow-draft.d.ts +4 -0
- package/dist/learn/workflow-draft.js +10 -7
- package/dist/learned-workflow.js +8 -8
- package/dist/learning-setting.js +2 -2
- package/dist/openapi.js +25 -17
- package/dist/paid-calls.d.ts +13 -6
- package/dist/paid-calls.js +14 -8
- package/dist/run-launch.d.ts +2 -2
- package/dist/run-launch.js +2 -1
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-usage.d.ts +23 -8
- package/dist/run-usage.js +100 -18
- package/dist/runner/adapter-loop.d.ts +4 -0
- package/dist/runner/adapter-loop.js +15 -1
- package/dist/runner/adapter-run-spec.d.ts +8 -3
- package/dist/runner/adapter-run-spec.js +13 -6
- package/dist/runner/big-writes.d.ts +33 -0
- package/dist/runner/big-writes.js +105 -0
- package/dist/runner/cli-run-spec.js +14 -6
- package/dist/runner/held.d.ts +4 -1
- package/dist/runner/learning-end.js +9 -4
- package/dist/runner/metrics.d.ts +4 -0
- package/dist/runner/metrics.js +9 -0
- package/dist/runner/run-child-host.d.ts +15 -2
- package/dist/runner/run-child-host.js +24 -8
- package/dist/runner/run-child.js +3 -0
- package/dist/runner/save-slots.d.ts +9 -0
- package/dist/runner/save-slots.js +91 -0
- package/dist/sdk/runs.d.ts +3 -4
- package/dist/sdk/runs.js +10 -7
- package/dist/sdk/runtimes.d.ts +19 -0
- package/dist/sdk/runtimes.js +23 -0
- package/dist/sdk/schema.d.ts +14 -8
- package/dist/sdk/schema.js +18 -6
- package/dist/server.d.ts +4 -0
- package/dist/server.js +3 -3
- package/dist/store/agent-body.d.ts +2 -3
- package/dist/store/agent-body.js +3 -2
- package/dist/store/postgres/migrations/0023_computer_interval_resources.sql +14 -0
- package/dist/store/schema.d.ts +8 -3
- package/dist/store/schema.js +12 -2
- package/dist/store/sqlite/connection.d.ts +3 -3
- package/dist/store/sqlite/connection.js +3 -3
- package/dist/store/sqlite/store.d.ts +2 -4
- package/dist/store/sqlite/store.js +95 -85
- package/dist/store/store.d.ts +8 -1
- package/dist/store-reads/cap.d.ts +9 -5
- package/dist/store-reads/cap.js +28 -2
- package/dist/store-reads/decisions.d.ts +21 -0
- package/dist/store-reads/decisions.js +22 -0
- package/dist/store-reads/journal.d.ts +8 -2
- package/dist/store-reads/journal.js +27 -8
- package/dist/store-view.d.ts +5 -1
- package/dist/store-view.js +37 -18
- package/dist/template-eval.d.ts +15 -1
- package/dist/template-eval.js +92 -13
- package/dist/templates.d.ts +1 -1
- package/dist/templates.js +4 -3
- package/dist/timeline/labels.js +17 -0
- package/dist/tool-list.js +1 -0
- package/dist/tools.d.ts +6 -2
- package/dist/tools.js +13 -1
- package/dist/trigger-targets.d.ts +21 -5
- package/dist/trigger-targets.js +13 -10
- package/dist/web-fake.d.ts +25 -0
- package/dist/web-fake.js +38 -1
- package/dist/web-save.d.ts +75 -0
- package/dist/web-save.js +235 -0
- package/dist/workspace/archil-claim.d.ts +5 -2
- package/dist/workspace/archil-claim.js +5 -2
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +19 -1
- package/dist/workspace/archil.d.ts +3 -0
- package/dist/workspace/archil.js +101 -16
- package/dist/workspace/computer-for-claim.d.ts +14 -0
- package/dist/workspace/computer-for-claim.js +46 -7
- package/dist/workspace/computer-intervals.d.ts +9 -3
- package/dist/workspace/computer-intervals.js +17 -8
- package/dist/workspace/pieced.d.ts +14 -0
- package/dist/workspace/pieced.js +23 -0
- package/dist/workspace/run-disk.js +32 -12
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +11 -6
- package/package.json +10 -10
- package/templates/README.md +36 -7
- package/dist/console/assets/index-Bzn4eUYF.js +0 -715
package/dist/learn/repick.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// learning.repick (learning-setting.ts), the owner's, off by default: the answer's quote re-pick (check.ts quoteRule, a
|
|
2
|
-
// loop of REPICK_PASSES until its quote_missing check passes) reads the run's fetched pages on its second pass
|
|
3
|
-
// re-pick
|
|
4
|
-
// which reads its compact facts and its draft alone (check.ts compactStateProblems), found them on 2 of 8 in S6.
|
|
2
|
+
// loop of REPICK_PASSES until its quote_missing check passes) reads the run's fetched pages on its second pass, where the
|
|
3
|
+
// compiled re-pick reads its compact facts and its draft alone (check.ts compactStateProblems).
|
|
5
4
|
//
|
|
6
5
|
// The host does it, at compile time, in today's DSL: runner/learning-end.ts checkDraftOf rewrites the loop of a draft
|
|
7
6
|
// the checks passed, and commits the rewrite, so the digest that serves is the doc the promotion check replayed. The
|
|
8
|
-
// loop
|
|
7
|
+
// loop is the one quoteRule finds (its RepickSite): a top-level step of the draft, or of the composed child writing its
|
|
8
|
+
// answer, at any depth. Its body becomes a pass marker, two routes by value (no model asked):
|
|
9
9
|
// repick_pass reads repick_next.taken: missing on pass 1, so it takes "first", whose route repick_mark records
|
|
10
10
|
// {taken: "pages"} under repick_next before running the answer step as compiled;
|
|
11
11
|
// on pass 2 it reads "pages", and runs the step's clone: the same step, labelled <label>_pages, that also reads each
|
|
@@ -16,11 +16,18 @@
|
|
|
16
16
|
// (check.ts repickLabels, learned-nodes.ts LoopRow). The compile prompt never names any of it.
|
|
17
17
|
import { isDeepStrictEqual } from "node:util";
|
|
18
18
|
import { isRepickMaxChars } from "../learning-setting.js";
|
|
19
|
-
import { childNodes } from "./workflow-draft.js";
|
|
19
|
+
import { childNodes, isNode, isObject } from "./workflow-draft.js";
|
|
20
20
|
/** The passes of a checked answer's re-pick loop: the draft, then one re-pick. */
|
|
21
21
|
export const REPICK_PASSES = 2;
|
|
22
|
-
|
|
23
|
-
const
|
|
22
|
+
/** `label`, a step's in the workflow holding `site`'s loop, as a run labels it: the DSL prefixes a composed child's `<step>/`. */
|
|
23
|
+
const scoped = (site, label) => (site.inner ? `${String(site.step.label)}/${scoped(site.inner, label)}` : label);
|
|
24
|
+
/** The site of the loop itself, the innermost. */
|
|
25
|
+
const loopSite = (site) => (site.inner ? loopSite(site.inner) : site);
|
|
26
|
+
/** Whether a composed workflow node on the way to `site`'s loop hands its child the marker's key: the child's state
|
|
27
|
+
* starts from its node's `input`, so that child would start on whichever pass the key names. */
|
|
28
|
+
const handsMark = (site) => !!site.inner && ((isObject(site.step.input) && Object.hasOwn(site.step.input, REPICK_MARK)) || handsMark(site.inner));
|
|
29
|
+
/** The label a run's loop events give the re-pick loop at `site`. */
|
|
30
|
+
export const repickLabelOf = (site) => scoped(site, String(loopSite(site).step.label));
|
|
24
31
|
/** The quote_missing a re-pick loop waits on: `step`'s, when it is a loop of REPICK_PASSES until `not` of a quote_missing. */
|
|
25
32
|
export const repickCheckOf = (step) => isNode(step) && step.node === "loop" && step.maxIters === REPICK_PASSES && isObject(step.until) && step.until.predicate === "not" && isObject(step.until.of) && step.until.of.predicate === "quote_missing" ? step.until.of : undefined;
|
|
26
33
|
/** The state key the pass marker writes. */
|
|
@@ -91,69 +98,63 @@ export function repickPassOne(loop) {
|
|
|
91
98
|
return undefined;
|
|
92
99
|
return isDeepStrictEqual(body, markerOf(step, pages, cap)) ? step : undefined;
|
|
93
100
|
}
|
|
94
|
-
/**
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
if (!pages)
|
|
101
|
+
/** `doc` with its answer's re-pick loop, at `site` (check.ts repickSiteOf of `doc`), its body the pass marker, its clone
|
|
102
|
+
* capped at `maxChars`; a loop already marked is marked again from its pass 1. Undefined when the rewrite does not reach
|
|
103
|
+
* it: its pass 1 is not one model step writing its workflow's answer (isPassOne), or the marker's key or a label it adds
|
|
104
|
+
* is one that workflow or its input already has. Given a draft the checks passed (check.ts checkDraft). `doc` is
|
|
105
|
+
* unchanged. */
|
|
106
|
+
export function repickRewrite(doc, site, maxChars) {
|
|
107
|
+
return isObject(doc) && site && !handsMark(site) && isRepickMaxChars(maxChars) ? rewriteAt(doc, site, maxChars) : undefined;
|
|
108
|
+
}
|
|
109
|
+
function rewriteAt(workflow, { at, step: node, inner }, maxChars) {
|
|
110
|
+
const replace = (step) => (isNode(workflow.root) && workflow.root.node === "chain" && Array.isArray(workflow.root.steps)
|
|
111
|
+
? { ...workflow, root: { ...workflow.root, steps: workflow.root.steps.with(at, step) } }
|
|
112
|
+
: { ...workflow, root: step });
|
|
113
|
+
// A composed child's: rewritten in the child (its node hands it no marker key: handsMark).
|
|
114
|
+
if (inner) {
|
|
115
|
+
const child = isObject(node.workflow) ? rewriteAt(node.workflow, inner, maxChars) : undefined;
|
|
116
|
+
return child && replace({ ...node, workflow: child });
|
|
117
|
+
}
|
|
118
|
+
const head = isObject(workflow.output) && typeof workflow.output.path === "string" ? workflow.output.path.split(".")[0] : "";
|
|
119
|
+
const step = repickPassOne(node) ?? node.body;
|
|
120
|
+
const pages = pagesOf(repickCheckOf(node) ?? {});
|
|
121
|
+
if (!isPassOne(step) || keyOf(step) !== head || !pages)
|
|
116
122
|
return undefined;
|
|
117
123
|
// The run's input is the state the run starts from: a key its schema names there is the input's.
|
|
118
|
-
const schemas = isObject(
|
|
119
|
-
const input = isObject(
|
|
124
|
+
const schemas = isObject(workflow.schemas) ? workflow.schemas : {};
|
|
125
|
+
const input = isObject(workflow.input) && typeof workflow.input.schemaId === "string" ? schemas[workflow.input.schemaId] : undefined;
|
|
120
126
|
if (isObject(input) && isObject(input.properties) && Object.hasOwn(input.properties, REPICK_MARK))
|
|
121
127
|
return undefined;
|
|
122
|
-
// Every other node's labels and the keys it writes: none may be the marker's.
|
|
128
|
+
// Every other node's labels and the keys it writes, in this workflow: none may be the marker's.
|
|
123
129
|
const taken = new Set();
|
|
124
|
-
const walk = (
|
|
125
|
-
if (!isNode(
|
|
130
|
+
const walk = (one, depth) => {
|
|
131
|
+
if (!isNode(one) || one === node || depth > 32)
|
|
126
132
|
return;
|
|
127
|
-
for (const name of [
|
|
133
|
+
for (const name of [one.label, one.as])
|
|
128
134
|
if (typeof name === "string")
|
|
129
135
|
taken.add(name);
|
|
130
|
-
if (
|
|
131
|
-
for (const child of childNodes(
|
|
136
|
+
if (one.node !== "workflow")
|
|
137
|
+
for (const child of childNodes(one))
|
|
132
138
|
walk(child, depth + 1);
|
|
133
139
|
};
|
|
134
|
-
|
|
140
|
+
walk(workflow.root, 0);
|
|
135
141
|
if ([REPICK_MARK, PASS_ROUTE, MARK_ROUTE, UNREACHED, `${String(step.label)}${PAGES_LABEL}`].some((name) => taken.has(name)))
|
|
136
142
|
return undefined;
|
|
137
|
-
|
|
138
|
-
return { ...doc, root: isNode(doc.root) && doc.root.node === "chain" ? { ...doc.root, steps: marked } : marked[0] };
|
|
143
|
+
return replace({ ...node, body: markerOf(step, pages, maxChars) });
|
|
139
144
|
}
|
|
140
|
-
/** The marked re-pick
|
|
141
|
-
*
|
|
142
|
-
* compact state rule (check.ts) reads only
|
|
143
|
-
*
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return [{ loop: loop, step, label: `${String(step.label)}${PAGES_LABEL}`, cap: clone.metadata.repick.max_chars }];
|
|
153
|
-
});
|
|
145
|
+
/** The marked re-pick loop at `site` (check.ts repickSiteOf), when its body is the marker (repickPassOne): its pass-1
|
|
146
|
+
* step, and its clone's label as a run gives it and its cap. The one place a marker counts, the one the rewrite puts it:
|
|
147
|
+
* the compact state rule (check.ts) reads only this loop as its pass 1, and the runner (learned-workflow.ts runNode)
|
|
148
|
+
* cuts only this clone. A marker anywhere else, which a revised draft could carry, is a page read like any other, as
|
|
149
|
+
* is one in a child its node hands the marker's key (handsMark), which would start on the pass that key names. */
|
|
150
|
+
export function repickMarked(site) {
|
|
151
|
+
const loop = site && !handsMark(site) ? loopSite(site).step : undefined;
|
|
152
|
+
const step = loop && repickPassOne(loop);
|
|
153
|
+
if (!site || !loop || !step)
|
|
154
|
+
return undefined;
|
|
155
|
+
const clone = loop.body.branches.pages.body;
|
|
156
|
+
return { loop, step, label: scoped(site, `${String(step.label)}${PAGES_LABEL}`), cap: clone.metadata.repick.max_chars };
|
|
154
157
|
}
|
|
155
|
-
/** Each marked re-pick's pass-2 label in `doc`, with its cap (repickMarked): what learned-workflow.ts runNode cuts. */
|
|
156
|
-
export const repickPageCaps = (doc) => new Map(repickMarked(doc).map(({ label, cap }) => [label, cap]));
|
|
157
158
|
/** `text` cut to its first `at` UTF-16 units, never through a surrogate pair. */
|
|
158
159
|
const headOf = (text, at) => {
|
|
159
160
|
const head = text.slice(0, at);
|
|
@@ -138,6 +138,10 @@ type Synthesized = {
|
|
|
138
138
|
};
|
|
139
139
|
/** What the DSL's synthesizeInstance would build of `schema` over `definitions`, counted without building it. */
|
|
140
140
|
export declare const synthesizedSize: (schema: unknown, definitions?: Readonly<Record<string, unknown>>) => Synthesized;
|
|
141
|
+
/** A JSON object (no array, no null). */
|
|
142
|
+
export declare const isObject: (value: unknown) => value is Record<string, unknown>;
|
|
143
|
+
/** A workflow node: an object naming its `node` kind. */
|
|
144
|
+
export declare const isNode: (value: unknown) => value is Record<string, unknown>;
|
|
141
145
|
/** The nodes directly inside `node`, as the DSL reads them (recovery/execution-path.ts childrenOf): a chain's steps, a
|
|
142
146
|
* parallel's branches, a map's or a loop's body, a route's branch bodies. A composed workflow node's child is a
|
|
143
147
|
* workflow, walked as one (eachWorkflow). Only these are node positions: an object anywhere else (a schema, a const, a
|
|
@@ -481,7 +481,10 @@ function synthesized(schema, definitions, depth, seen) {
|
|
|
481
481
|
}
|
|
482
482
|
/** What the DSL's synthesizeInstance would build of `schema` over `definitions`, counted without building it. */
|
|
483
483
|
export const synthesizedSize = (schema, definitions = {}) => synthesized(schema, definitions, 0, new Map());
|
|
484
|
-
|
|
484
|
+
/** A JSON object (no array, no null). */
|
|
485
|
+
export const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
486
|
+
/** A workflow node: an object naming its `node` kind. */
|
|
487
|
+
export const isNode = (value) => isObject(value) && typeof value.node === "string";
|
|
485
488
|
/** The nodes directly inside `node`, as the DSL reads them (recovery/execution-path.ts childrenOf): a chain's steps, a
|
|
486
489
|
* parallel's branches, a map's or a loop's body, a route's branch bodies. A composed workflow node's child is a
|
|
487
490
|
* workflow, walked as one (eachWorkflow). Only these are node positions: an object anywhere else (a schema, a const, a
|
|
@@ -492,7 +495,7 @@ export function childNodes(node) {
|
|
|
492
495
|
case "parallel": return Array.isArray(node.branches) ? node.branches : [];
|
|
493
496
|
case "map":
|
|
494
497
|
case "loop": return [node.body];
|
|
495
|
-
case "route": return
|
|
498
|
+
case "route": return isObject(node.branches) ? Object.values(node.branches).map((branch) => (isObject(branch) ? branch.body : undefined)) : [];
|
|
496
499
|
default: return [];
|
|
497
500
|
}
|
|
498
501
|
}
|
|
@@ -500,7 +503,7 @@ export function childNodes(node) {
|
|
|
500
503
|
* around it (their maxIters multiplied), and each node of it at a node position with the loops around that node. */
|
|
501
504
|
function eachWorkflow(doc, visit) {
|
|
502
505
|
const walkNode = (value, around) => {
|
|
503
|
-
if (!
|
|
506
|
+
if (!isObject(value))
|
|
504
507
|
return;
|
|
505
508
|
const within = visit.node ? visit.node(value, around) : around;
|
|
506
509
|
if (value.node === "workflow")
|
|
@@ -509,7 +512,7 @@ function eachWorkflow(doc, visit) {
|
|
|
509
512
|
walkNode(child, within);
|
|
510
513
|
};
|
|
511
514
|
const walkWorkflow = (value, around) => {
|
|
512
|
-
if (!
|
|
515
|
+
if (!isObject(value))
|
|
513
516
|
return;
|
|
514
517
|
visit.workflow?.(value);
|
|
515
518
|
walkNode(value.root, around);
|
|
@@ -529,12 +532,12 @@ const SCHEMA_LISTS = ["anyOf", "oneOf", "allOf", "prefixItems"];
|
|
|
529
532
|
const SCHEMA_ONES = ["items", "additionalItems", "additionalProperties", "contains", "not", "if", "then", "else", "propertyNames", "unevaluatedItems", "unevaluatedProperties"];
|
|
530
533
|
/** Each schema in `schema`, itself first, at schema positions only (each once). */
|
|
531
534
|
function eachSchema(schema, visit, seen = new Set()) {
|
|
532
|
-
if (!
|
|
535
|
+
if (!isObject(schema) || seen.has(schema))
|
|
533
536
|
return;
|
|
534
537
|
seen.add(schema);
|
|
535
538
|
visit(schema);
|
|
536
539
|
for (const key of SCHEMA_MAPS)
|
|
537
|
-
if (
|
|
540
|
+
if (isObject(schema[key]))
|
|
538
541
|
for (const sub of Object.values(schema[key]))
|
|
539
542
|
eachSchema(sub, visit, seen);
|
|
540
543
|
for (const key of SCHEMA_LISTS)
|
|
@@ -643,7 +646,7 @@ function shapeOf(schema, depth = 0) {
|
|
|
643
646
|
oneOf = shapeOf(value, depth + 1);
|
|
644
647
|
else if (key === "type")
|
|
645
648
|
out.type = Array.isArray(value) ? [...new Set(value.map((one) => (one === "integer" ? "number" : one)))] : value === "integer" ? "number" : value;
|
|
646
|
-
else if (MAP_KEYWORDS.has(key) &&
|
|
649
|
+
else if (MAP_KEYWORDS.has(key) && isObject(value))
|
|
647
650
|
out[key] = Object.fromEntries(Object.entries(value).map(([name, sub]) => [name, shapeOf(sub, depth + 1)]));
|
|
648
651
|
else if (SUB_KEYWORDS.has(key))
|
|
649
652
|
out[key] = shapeOf(value, depth + 1);
|
package/dist/learned-workflow.js
CHANGED
|
@@ -33,8 +33,8 @@ import { defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
|
33
33
|
import { registerLabel, registerOutcome } from "./timeline/index.js";
|
|
34
34
|
import { LEARNED_NODES, LEARNED_NODES_MAX } from "./learned-nodes.js";
|
|
35
35
|
import { draftProblems, LEARNED_MAX_TURNS } from "./learn/index.js";
|
|
36
|
-
import { repickLabels } from "./learn/check.js";
|
|
37
|
-
import { capState, REPICK_MARK,
|
|
36
|
+
import { repickLabels, repickSiteOf } from "./learn/check.js";
|
|
37
|
+
import { capState, REPICK_MARK, repickMarked } from "./learn/repick.js";
|
|
38
38
|
import { decisionsAsked, deniedDecisionWords } from "./learn/workflow-draft.js";
|
|
39
39
|
import { DEFAULT_DECISION_PROVIDER } from "./decisions.js";
|
|
40
40
|
import { workflowLine } from "./learning.js";
|
|
@@ -332,13 +332,13 @@ export async function runLearned(run, flow, input, signal, ledger, nodes = [], n
|
|
|
332
332
|
const doc = JSON.parse(flow.workflow);
|
|
333
333
|
// Its quote re-pick loops (check.ts repickLabels): their exits are the run's re-picks (LoopRow `repick`).
|
|
334
334
|
const repickAt = repickLabels(doc);
|
|
335
|
-
//
|
|
336
|
-
// of state it sends: its prompt state is cut to that (capState), its longest strings first; the
|
|
337
|
-
// the quote check after it reads, stays whole.
|
|
338
|
-
const
|
|
335
|
+
// The re-pick's pass over the run's pages (learning.repick, learn/repick.ts), by its label as the run gives it, with the
|
|
336
|
+
// most characters of state it sends: its prompt state is cut to that (capState), its longest strings first; the
|
|
337
|
+
// workflow's state, which the quote check after it reads, stays whole.
|
|
338
|
+
const pages = repickMarked(repickSiteOf(doc));
|
|
339
339
|
// The marker's key is the host's: an input holding it would pick the re-pick's pass (or fail its route), whatever the
|
|
340
340
|
// input's schema says of it, so such an input is refused before anything runs.
|
|
341
|
-
if (
|
|
341
|
+
if (pages && Object.hasOwn(input, REPICK_MARK))
|
|
342
342
|
return refuse(`its input holds "${REPICK_MARK}", the key its quote re-pick keeps its pass under`);
|
|
343
343
|
// What a node answered the first time this call ran it, in every rerun of the call (`nested.memo`, by `key`): a rerun
|
|
344
344
|
// after a park or a crash goes on from the same answers, so its MCP calls are asked with the arguments a person saw,
|
|
@@ -397,7 +397,7 @@ export async function runLearned(run, flow, input, signal, ledger, nodes = [], n
|
|
|
397
397
|
const model = !ref ? undefined : ref.provider === PORT_PROVIDER ? (run.modelName?.(tier) ?? undefined) : ref.modelId;
|
|
398
398
|
if (model && typeof request.executionPath === "string")
|
|
399
399
|
ranOn.set(request.executionPath, { model, ...(tier ? { tier } : {}) });
|
|
400
|
-
const cap =
|
|
400
|
+
const cap = request.label === pages?.label ? pages.cap : undefined;
|
|
401
401
|
const user = cap === undefined ? request.user : capState(request.user, cap);
|
|
402
402
|
// A state past the cap with every string cut to nothing is never sent: the node fails and the re-pick hands back.
|
|
403
403
|
if (user === undefined)
|
package/dist/learning-setting.js
CHANGED
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
// schema: its enum can be an echo of the owner's setting, not the decision, and a wrong field that promotes is worse than
|
|
17
17
|
// none.
|
|
18
18
|
// A compile reads two more (runner/learning-end.ts checkDraftOf, learn/repick.ts), off by default:
|
|
19
|
-
// repick: the answer's quote re-pick (learn/check.ts quoteRule) reads the run's fetched pages on its second pass,
|
|
20
|
-
//
|
|
19
|
+
// repick: the answer's quote re-pick (learn/check.ts quoteRule) reads the run's fetched pages on its second pass,
|
|
20
|
+
// where the compiled one reads its compact facts and its draft alone;
|
|
21
21
|
// repick_max_chars: the most characters of state that second pass sends, its longest strings cut first.
|
|
22
22
|
// Each is read when a draft is committed, so a change reaches the workflows compiled after it, never one already kept.
|
|
23
23
|
export const COMPILE_AFTER_DEFAULT = 20;
|
package/dist/openapi.js
CHANGED
|
@@ -235,19 +235,24 @@ const COST_WORDS = {
|
|
|
235
235
|
const RUN_USAGE_LINE = {
|
|
236
236
|
type: "object", additionalProperties: false, required: ["meter", "model", "provider", "charged_by", "quantity", "unit", "basis", "usd"],
|
|
237
237
|
properties: {
|
|
238
|
-
meter: { enum: ["tokens", "tools", "browser_time"], description: "`tokens`: model requests, by model. `tools`: paid tool calls, by who charged for them
|
|
239
|
-
model: { type: ["string", "null"], description: "On `tokens`: the model the requests were sent on, as the run's booking names it (a workflow decision's model too). One line per model and route: the same model reached two ways is two lines. Null on the other meters, and when the record names none." },
|
|
240
|
-
provider: { type: ["string", "null"], description: "On `tokens`: the provider the requests went to, named only when this server sent them there itself (the run's own model on a provider's key). Null behind a model gateway, whose upstream this server does not know, and for a model it did not route (a workflow decision's). On `tools`: the vendor that charged for the calls, the same name as `charged_by` (the vendor that charges for a call is its provider). On `browser_time`: the browser provider. Null where the record names none." },
|
|
241
|
-
charged_by: { type: ["string", "null"], description: "On `tools`: who charged for the calls, whose invoice they land on (`monid`, an MCP server's name, `parallel`). Null on the other meters, and when the record names none." },
|
|
242
|
-
quantity: { type: ["number", "null"], minimum: 0, description: "In `unit`, as measured: never rounded to a billing increment, never topped up to a minimum. On `tokens`, the requests' input, cache read, cache write and output tokens as each reported them (a workflow decision's as its receipt does; a request that reported none is in `unmetered_requests`, in no token); on `tools`, the charges booked, one per paid call; on `browser_time`, the seconds this server's clock charged the provider's sessions for, its minimum per session included as the browser charged it
|
|
243
|
-
unit: { enum: ["token", "call", "second"] },
|
|
244
|
-
basis: { enum: ["reported", "estimate", "unpriced"], description: "How `usd` was reached. On `tokens`, as the run's `cost.basis` is, over the line's requests alone: `reported` when every request priced had its gateway's or provider's own figure, `estimate` when any was priced from a price table, `unpriced` when none was priced. On `tools`, `reported` when every charge with a figure is the provider's own (monid's answer says what it charged), `estimate` when any is a price this server holds (an MCP tool's saved price, Parallel's), `unpriced` when none has a figure. On `browser_time`, `estimate` when any charge has a figure (the provider's price per hour on this server's clock, never its invoice), else `unpriced`." },
|
|
238
|
+
meter: { enum: ["tokens", "tools", "browser_time", "compute_time"], description: "`tokens`: model requests, by model. `tools`: paid tool calls, by who charged for them; a workflow decision Parallel answered on its own API (this server's PARALLEL_API_KEY) is one, on the `parallel` line, never on `tokens`. `browser_time`: browser session time, by browser provider. `compute_time`: the time of the computers the run made, by provider and resource (`resource`, a GPU's `gpu_type`), priced by the operator's per-resource settings; sum a provider's lines for its compute figure.", "x-agentrun-serve": "runusage/5" },
|
|
239
|
+
model: { type: ["string", "null"], description: "On `tokens`: the model the requests were sent on, as the run's booking names it (a workflow decision's model too, but for a decision Parallel charged, which is on the `parallel` `tools` line). One line per model and route: the same model reached two ways is two lines. Null on the other meters, and when the record names none." },
|
|
240
|
+
provider: { type: ["string", "null"], description: "On `tokens`: the provider the requests went to, named only when this server sent them there itself (the run's own model on a provider's key). Null behind a model gateway, whose upstream this server does not know, and for a model it did not route (a workflow decision's). On `tools`: the vendor that charged for the calls, the same name as `charged_by` (the vendor that charges for a call is its provider). On `browser_time`: the browser provider. On `compute_time`: the computer provider, as this server's registry names it. Null where the record names none." },
|
|
241
|
+
charged_by: { type: ["string", "null"], description: "On `tools`: who charged for the calls, whose invoice they land on (`monid`, an MCP server's name, `parallel`). On `compute_time`: the computer provider, the same name as `provider`. Null on the other meters, and when the record names none." },
|
|
242
|
+
quantity: { type: ["number", "null"], minimum: 0, description: "In `unit`, as measured: never rounded to a billing increment, never topped up to a minimum. On `tokens`, the requests' input, cache read, cache write and output tokens as each reported them (a workflow decision's as its receipt does; a request that reported none is in `unmetered_requests`, in no token); on `tools`, the charges booked, one per paid call (a decision Parallel charged is one); on `browser_time`, the seconds this server's clock charged the provider's sessions for, its minimum per session included as the browser charged it; on `compute_time`, every second of every such computer of the run's times its figure (vCPUs, GiB of memory, GPUs, or GB of disk over a 730-hour month), a computer still open counted up to `measured_to`. Null when nothing measured it, or when a computer's figure is unknown (its provider said none and its create asked none)." },
|
|
243
|
+
unit: { enum: ["token", "call", "second", "vcpu_second", "gib_second", "gpu_second", "gb_month"] },
|
|
244
|
+
basis: { enum: ["reported", "estimate", "unpriced"], description: "How `usd` was reached. On `tokens`, as the run's `cost.basis` is, over the line's requests alone: `reported` when every request priced had its gateway's or provider's own figure, `estimate` when any was priced from a price table, `unpriced` when none was priced. On `tools`, `reported` when every charge with a figure is the provider's own (monid's answer says what it charged), `estimate` when any is a price this server holds (an MCP tool's saved price, Parallel's, a Parallel decision's list price), `unpriced` when none has a figure. On `browser_time`, `estimate` when any charge has a figure (the provider's price per hour on this server's clock, never its invoice), else `unpriced`. On `compute_time`, `estimate` when the run's ledger booked any of it at the operator's price (or its provider bills nothing, at $0), else `unpriced` (no price set for the resource, or its figure unknown): its time ran outside the run's cap, and `usd` is null." },
|
|
245
245
|
usd: { type: ["number", "null"], minimum: 0, description: "The line's cost on this server, as booked, joined by the rule `cost.usd` is (float noise rounded off at 1e-12). Null when a charge of it is unknown: never $0 for unknown." },
|
|
246
246
|
...COST_WORDS,
|
|
247
247
|
requests: { type: "integer", minimum: 0, description: "On `tokens`: the model requests booked." },
|
|
248
248
|
tokens: closed({ input: { type: "integer", minimum: 0, description: "Input not read from cache." }, output: { type: "integer", minimum: 0 }, cache_read: { type: "integer", minimum: 0 }, cache_write: { type: "integer", minimum: 0 } }, "On `tokens`: `quantity` by kind."),
|
|
249
249
|
unmetered_requests: { type: "integer", minimum: 0, description: "On `tokens`: requests that reported no tokens (booked with no usage, or sent and never answered), in no token count." },
|
|
250
250
|
not_metered_calls: { type: "integer", minimum: 1, description: "On `tools`: calls with no price set (an MCP tool its owner set none for), as GET /usage counts them. They ran outside the run's cost and its cap, so they are in neither `quantity` nor `usd`: a line of such calls alone has `quantity` 0 and `usd` 0." },
|
|
251
|
+
resource: { enum: ["vcpu", "memory", "gpu", "disk"], description: "On `compute_time`: the resource the line counts." },
|
|
252
|
+
gpu_type: { type: ["string", "null"], description: "On `compute_time` for `gpu`: the provider's own name for the GPU type. Null on the other resources." },
|
|
253
|
+
unheld_quantity: { type: ["number", "null"], minimum: 0, description: "On `compute_time`: the part of `quantity` no claim of the run held, so no cap held and nothing booked: a computer kept past its claim for a follow-up, one deleted after its run ended, one whose delete failed, one still open. Its cost is in neither `usd` nor `total`. Null when `quantity` is." },
|
|
254
|
+
open_computers: { type: "integer", minimum: 0, description: "On `compute_time`: how many of the line's computers no delete has ended yet (still running, or their delete failed), counted up to `measured_to`." },
|
|
255
|
+
measured_to: { type: "string", format: "date-time", description: "On `compute_time` with an open computer: the moment its time is counted to, this read's." },
|
|
251
256
|
},
|
|
252
257
|
};
|
|
253
258
|
/** One browser session on GET /runs/{run_id}/usage (browser-sessions.ts). */
|
|
@@ -277,21 +282,23 @@ const BROWSER_SESSION = {
|
|
|
277
282
|
/** One computer a run made on GET /runs/{run_id}/usage (run-usage.ts computerIntervalsOf, store computer_intervals). */
|
|
278
283
|
const COMPUTER_INTERVAL = {
|
|
279
284
|
type: "object", additionalProperties: false,
|
|
280
|
-
required: ["provider", "provider_id", "kind", "gpu", "cpus", "memory_mb", "started_at", "ended_at", "kept"],
|
|
285
|
+
required: ["provider", "provider_id", "kind", "gpu", "cpus", "memory_mb", "disk_gb", "started_at", "ended_at", "kept", "booked_seconds"],
|
|
281
286
|
properties: {
|
|
282
287
|
provider: { type: "string", description: "The computer provider, as this server's registry names it (the agent's computer setting's `provider`: `docker`, `e2b`, `daytona`, ...)." },
|
|
283
288
|
provider_id: { type: "string", description: "The provider's own id for the computer, by which its console, its API and its invoice find it." },
|
|
284
289
|
kind: { type: ["string", "null"], description: "`sandbox`, `desktop` or `phone`. Null when not known." },
|
|
285
290
|
gpu: {
|
|
286
291
|
type: ["object", "null"], additionalProperties: false, required: ["type", "count"],
|
|
287
|
-
description: "The
|
|
292
|
+
description: "The computer's GPUs: its provider's own figure where its answer gave one, else what its create asked for. Null when neither says it has any.",
|
|
288
293
|
properties: { type: { type: ["string", "null"] }, count: { type: ["integer", "null"], minimum: 0 } },
|
|
289
294
|
},
|
|
290
|
-
cpus: { type: ["number", "null"], minimum: 0, description: "The
|
|
291
|
-
memory_mb: { type: ["integer", "null"], minimum: 0, description: "The memory, in MB
|
|
295
|
+
cpus: { type: ["number", "null"], minimum: 0, description: "The computer's vCPUs: its provider's own figure where its answer gave one (Daytona, E2B, Fly), else what its create asked for. Null when neither says: none is guessed." },
|
|
296
|
+
memory_mb: { type: ["integer", "null"], minimum: 0, description: "The computer's memory, in MB: its provider's own figure where its answer gave one, else what its create asked for. Null when neither says." },
|
|
297
|
+
disk_gb: { type: ["number", "null"], minimum: 0, description: "The computer's disk, in GB, where its provider's answer said it (Daytona). Null else.", "x-agentrun-serve": "runusage/4" },
|
|
292
298
|
started_at: { type: "string", format: "date-time", description: "When the provider's create answered with the computer, on this server's clock." },
|
|
293
299
|
ended_at: { type: ["string", "null"], format: "date-time", description: "When the provider's delete of the computer answered ok, on this server's clock. Null while none did: the computer may still be running (a run that ended with one open left it behind), or its delete failed or its answer is unknown. Never a guessed end." },
|
|
294
300
|
kept: { type: "boolean", description: "The run's park kept the computer past its claim, for the person's answer (it is deleted once its keep's time passes, or at the run's end)." },
|
|
301
|
+
booked_seconds: { type: "number", minimum: 0, description: "How much of the computer's time a claim of the run held and booked on the run's ledger. The rest of its life is time no claim held (`unheld_quantity` on its `compute_time` lines). 0 for one whose provider has no price set, or that bills nothing.", "x-agentrun-serve": "runusage/4" },
|
|
295
302
|
},
|
|
296
303
|
};
|
|
297
304
|
const RUN_USAGE = {
|
|
@@ -302,11 +309,11 @@ const RUN_USAGE = {
|
|
|
302
309
|
currency: { const: "USD" },
|
|
303
310
|
total: {
|
|
304
311
|
type: ["object", "null"], additionalProperties: false, required: ["usd"], description: "The run's cost, joined from its lines. Null with no lines.",
|
|
305
|
-
properties: { usd: { type: ["number", "null"], minimum: 0, description: "The
|
|
312
|
+
properties: { usd: { type: ["number", "null"], minimum: 0, description: "The run's booking joined by the rule `cost.usd` is: the run's `cost.usd` on GET /runs/{run_id}, always. Null when a charge of it is unknown. A `compute_time` line that is `unpriced`, and any line's `unheld_quantity`, ran outside the run's booking and are not in it." }, ...COST_WORDS },
|
|
306
313
|
},
|
|
307
|
-
lines: { type: ["array", "null"], items: RUN_USAGE_LINE, description: "`tokens` lines first, then `tools`, then `browser_time`, each by its model, charger or provider. A meter the run used nothing of has no line. Null when the server can't split the run (`reason`)." },
|
|
314
|
+
lines: { type: ["array", "null"], items: RUN_USAGE_LINE, description: "`tokens` lines first, then `tools`, then `browser_time`, then `compute_time`, each by its model, charger or provider (`compute_time` then by resource). A meter the run used nothing of has no line. Null when the server can't split the run (`reason`)." },
|
|
308
315
|
browser_sessions: { type: ["array", "null"], items: BROWSER_SESSION, description: "One record per browser session the run opened, in the order it opened them, for matching `browser_time` to the provider's own records and invoice by its session id. Empty for a run that opened none. Null exactly when `lines` is. Its words are cut of this server's secrets and the run's sign-ins, as the lines' names are.", "x-agentrun-serve": "runusage/2" },
|
|
309
|
-
computer_intervals: { type: ["array", "null"], items: COMPUTER_INTERVAL, description: "One record per computer the run made through its provider (a sandbox, a desktop, a phone), by when each was made: how long each lived for the run, one left running after it (`ended_at` null), and the provider's own id to match its invoice by. Not the agent's own persistent computer, a paired computer, or a browser's sessions (those are `browser_sessions`).
|
|
316
|
+
computer_intervals: { type: ["array", "null"], items: COMPUTER_INTERVAL, description: "One record per computer the run made through its provider (a sandbox, a desktop, a phone), by when each was made: how long each lived for the run, one left running after it (`ended_at` null), and the provider's own id to match its invoice by. Not the agent's own persistent computer, a paired computer, or a browser's sessions (those are `browser_sessions`). Their time is on the `compute_time` lines. Empty for a run that made none (or one made before this server kept them). Null exactly when `lines` is. Its words are cut of this server's secrets and the run's sign-ins, as the lines' names are.", "x-agentrun-serve": "runusage/3" },
|
|
310
317
|
reason: { enum: ["running", "not_booked", "reopened", null], description: "Why `lines` is null: `running`, the run is at work and its booking still moves; `not_booked`, its figure is not its booking's (an imported run's, a native or SDK run's harness figure, a CLI run whose model requests went past its model proxy); `reopened`, a learning run a follow-up opened again, whose `cost.usd` is its first round's and whose booking can't be split by round. Null with lines." },
|
|
311
318
|
},
|
|
312
319
|
};
|
|
@@ -1339,6 +1346,7 @@ const TEMPLATE_APPLIED = closedWith({
|
|
|
1339
1346
|
template: { type: "string" },
|
|
1340
1347
|
version: { type: "string" },
|
|
1341
1348
|
agent_id: { type: "string", description: "The agent made, or the one updated (GET /agents/{agent_id})." },
|
|
1349
|
+
revision_version: { type: "integer", minimum: 1, description: "The number of the agent's revision this apply wrote, its current one now (its `definition.version`): 1 for an agent it made; on an update with agent_id, the new revision's." },
|
|
1342
1350
|
servers: { type: "object", additionalProperties: { type: ["string", "null"] }, description: "The saved MCP server each of the package's toolkits runs on, by toolkit; null: none here matches it (said under `mcp.<toolkit>`)." },
|
|
1343
1351
|
trigger_ids: { type: "array", items: { type: "string" }, description: "Its triggers, in the package's order (GET /triggers/{trigger_id})." },
|
|
1344
1352
|
warnings: { type: "array", items: ref("schemas/InputIssue"), description: "What this host still lacks for the agent to run, as POST /agents answers it; a webhook trigger the apply made adds a warning pointing to the console for its signing secret, never the secret itself (the first answer to the owner's signed-in session shows it once, under `webhook_secrets`)." },
|
|
@@ -1680,7 +1688,7 @@ const LEARNING_EXTENSIONS = {
|
|
|
1680
1688
|
{ name: "limit", in: "query", required: false, description: `The latest runs to answer, each keeping its number. At most ${COST_RUNS_MAX}.`, schema: { type: "integer", minimum: 1, maximum: COST_RUNS_MAX, default: COST_RUNS_DEFAULT } },
|
|
1681
1689
|
{ name: "format", in: "query", required: false, description: "`csv`: the runs as CSV, columns " + COST_CSV_COLUMNS.join(", ") + ".", schema: { enum: ["json", "csv"], default: "json" } },
|
|
1682
1690
|
],
|
|
1683
|
-
responses: { "200": { description: "The agent's cost per run.", content: { "application/json": { schema: LEARNING_COST }, "text/csv": { schema: { type: "string" } } } }, ...errors(400, 401, 404, 429, 500) },
|
|
1691
|
+
responses: { "200": { description: "The agent's cost per run.", content: { "application/json": { schema: LEARNING_COST }, "text/csv": { schema: { type: "string" } } } }, ...errors(400, 401, 403, 404, 429, 500) },
|
|
1684
1692
|
"x-agentrun-serve": "learningcost/1",
|
|
1685
1693
|
},
|
|
1686
1694
|
},
|
|
@@ -3299,7 +3307,7 @@ const FIELD_EXTENSIONS = {
|
|
|
3299
3307
|
"x-agentrun-serve": "costbasis/1",
|
|
3300
3308
|
},
|
|
3301
3309
|
learning_usd: { type: ["number", "null"], minimum: 0, description: "On the run read (GET /v2/runs/{run_id}) alone, where `usd` is the run's own spend, the job's: what learning spent for it, on the agent's own model route. Its audit shadow's cost (the agent on its input with learning off) and its share of its workflow revision's learning spend: the compile turn that drafted that revision and its check's replay runs, spread over the first `compile_after` runs the revision serves (GET /agents/{agent_id}/learning/cost `bill.revisions`). A compile turn is never in the `usd` or `learning_usd` of the run whose session asked it: it is its revision's (a recompile's, its recompiled revision's), or, when it kept no draft (every draft failed its checks, or the cap stopped it), on no run (`bill.unattributed_usd`). 0 for a replay or shadow run, whose spend is on the runs it serves. As booked (float noise rounded off at 1e-12, as `usd` is); null while the run or its shadow is at work, or a part is unknown: never $0 for unknown.", "x-agentrun-serve": "allin/1" },
|
|
3302
|
-
tools_usd: { type: ["number", "null"], minimum: 0, description: "On the run read (GET /v2/runs/{run_id}) alone: the part of `usd` that went to the run's paid tool calls (a monid endpoint's charge, an MCP tool's saved price, Parallel's behind `web_search` and `web_fetch`, the browser's session time), as the run's ledger booked them, joined and rounded as `usd` is, so `usd` less this is its model requests and decisions. Inside `usd`, never added to it. A paid call in the run's end-of-run turn is learning's, in `learning_usd` and never here. 0 when the run made no paid call. An MCP tool with no price is in neither (`not_metered` on its trace span). Null while a paid call's charge is unknown (one charged an unknown amount, cut, or still running), or counted at its hold; while the run is at work (until it ended, stopped or failed); for a run a follow-up opened again (a round past its first), whose job is what it had cost when its first round answered; and for an imported, native or SDK run, whose `usd` is its import's or its harness's own figure and whose tool calls the server never books: never $0 for unknown.", "x-agentrun-serve": "toolsusd/
|
|
3310
|
+
tools_usd: { type: ["number", "null"], minimum: 0, description: "On the run read (GET /v2/runs/{run_id}) alone: the part of `usd` that went to the run's paid tool calls (a monid endpoint's charge, an MCP tool's saved price, Parallel's behind `web_search` and `web_fetch`, the browser's session time, and a workflow decision Parallel answered on its own API on this server's PARALLEL_API_KEY, at Parallel's list price), as the run's ledger booked them, joined and rounded as `usd` is, so `usd` less this is its model requests and its other decisions (Jev's, an OpenRouter model's, Parallel's model reached through OpenRouter). Inside `usd`, never added to it. A paid call in the run's end-of-run turn is learning's, in `learning_usd` and never here. 0 when the run made no paid call. An MCP tool with no price is in neither (`not_metered` on its trace span). Null while a paid call's charge is unknown (one charged an unknown amount, cut, or still running), or counted at its hold; while the run is at work (until it ended, stopped or failed); for a run a follow-up opened again (a round past its first), whose job is what it had cost when its first round answered; and for an imported, native or SDK run, whose `usd` is its import's or its harness's own figure and whose tool calls the server never books: never $0 for unknown.", "x-agentrun-serve": "toolsusd/2" },
|
|
3303
3311
|
all_in_usd: { type: ["number", "null"], minimum: 0, description: "On the run read alone: `usd` and `learning_usd` together, what the run cost its owner all in. 0 for a replay or shadow run. Over every run of an agent, these and the cost route's `bill.unattributed_usd` add up to its `bill.booked_usd`. Null when either is, or `usd` is only a bound (`upper_bound`).", "x-agentrun-serve": "allin/1" },
|
|
3304
3312
|
plan: {
|
|
3305
3313
|
type: "object", additionalProperties: false, required: ["requests", "tokens", "on"],
|
|
@@ -3567,7 +3575,7 @@ const FIELD_EXTENSIONS = {
|
|
|
3567
3575
|
hold_window: { type: "integer", minimum: 1, maximum: AUDIT_MAX, default: AUDIT_DEFAULTS.hold_window, description: "The audit rows of the serving revision the hold rule reads: its newest this many (an owner's grade on a served run is one too)." },
|
|
3568
3576
|
hold_disagree: { type: "integer", minimum: 1, maximum: AUDIT_MAX, default: AUDIT_DEFAULTS.hold_disagree, description: "When at least this many of those rows disagree, the workflow stops serving (a hold, source `audit`) and is recompiled once with them as data, then checked again: promoted serves again, otherwise it stops. At most `hold_window`." },
|
|
3569
3577
|
stop_window: { type: "integer", minimum: 1, maximum: AUDIT_MAX, default: AUDIT_DEFAULTS.stop_window, description: "A second hold within this many served runs of the first stops the workflow for good, asking no compile." },
|
|
3570
|
-
repick: { type: "boolean", default: false, description: "`true`: a learned workflow compiled from now on re-picks its answer's quotes from the pages its run fetched. When a quote in its first answer is in none of those pages, its one re-pick writes the answer again from the pages themselves (each sent as data, told it is untrusted text from the web and never instructions, with no tools), not from its compact notes alone. It is read when a draft is committed, so a workflow already kept is unchanged until its next compile. An agent whose workflows run through an SDK bridge ignores it. `false` or absent: the re-pick reads its compact notes and its draft." },
|
|
3578
|
+
repick: { type: "boolean", default: false, description: "`true`: a learned workflow compiled from now on re-picks its answer's quotes from the pages its run fetched. When a quote in its first answer is in none of those pages, its one re-pick writes the answer again from the pages themselves (each sent as data, told it is untrusted text from the web and never instructions, with no tools), not from its compact notes alone. It is read when a draft is committed, so a workflow already kept is unchanged until its next compile. It reaches a re-pick of one model step, in the workflow or in the composed workflow that writes its answer; any other re-pick is kept as compiled, and the server's log says so. An agent whose workflows run through an SDK bridge ignores it. `false` or absent: the re-pick reads its compact notes and its draft." },
|
|
3571
3579
|
repick_max_chars: { type: "integer", minimum: 1, maximum: REPICK_MAX_CHARS_MAX, default: REPICK_MAX_CHARS_DEFAULT, description: "The most characters of state a re-pick over the pages sends its model: past it, the longest strings (the pages) are cut first, each to one length and marked where it was cut. Its cost is the served run's, under the run's cost cap like every model request of the run. Read with `repick`, at each compile." },
|
|
3572
3580
|
} }], default: false, description: "Whether an agentic revision's runs learn: `true`, its owner's corrections and learned workflows; an object, the same with the loop's numbers set on it (`compile_after`, `agree_min`, `alone_min`, `agree_on`, `audit_every`, `audit_every_later`, `audit_later_after`, `hold_window`, `hold_disagree`, `stop_window`, `repick`, `repick_max_chars`, each optional: one left out is its default; `true` is every default); `false`, nothing. A run that learns starts from what its agent has learned, its corrections.md whole in its instructions under `# Learned` and its learned workflows behind its learned_workflow tool; once its job is due, it is asked one compile turn that writes the job as a learned workflow, checked and committed. Kept when a definition says so, true, false or an object (its numbers in one order); a number out of range or an unknown key is a 422 `wrong_type`; absent, off, and an answer shows none. An edit that leaves it out keeps the agent's. A workflow revision keeps none. On a server whose learning is off (`capabilities.features.learning`), no run learns, whatever this says.", "x-agentrun-serve": "learning/1" },
|
|
3573
3581
|
checkout: { enum: ["pull_request", "none"], description: "What the server checks out in each run's folder before its first turn, an agentic definition's alone. `pull_request`: the pull request the run's GitHub event names (a GitHub trigger's firing: its repository, number, head and base), at its head, detached, in `repo/`, with its base and their merge base fetched beside it (refs `pr/head`, `pr/base`, `pr/merge-base`). The fetch is the server's own, one command on the run's folder, with an installation token of the server's GitHub App narrowed to that repository and `contents: read`, which the agent never holds: it is never in the folder, the checkout's git config, its remote's URL, the agent's environment or the log. With no App, or one not installed there, the fetch is anonymous, which a public repository answers. The run's system prompt says what was checked out, or why nothing was (no pull request named, the fetch failed), so it can read the change another way, such as the GitHub MCP. The checkout is removed when the run's claim ends. An edit that leaves it out keeps the agent's; `none` clears it. A template sets it from its manifest's `checkout`.", "x-agentrun-serve": "checkout/1" },
|
package/dist/paid-calls.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { Refusal } from "@parcha/agentrun-kernel";
|
|
2
2
|
import type { ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
|
-
/** Parallel's
|
|
4
|
-
|
|
3
|
+
/** The modes Parallel's Search API is priced in here; a request in any other mode (or naming none) has no price. */
|
|
4
|
+
export type ParallelSearchMode = "turbo" | "fast" | "basic" | "advanced";
|
|
5
|
+
/** Parallel's published prices (https://docs.parallel.ai/resources/pricing, read 2026-11-20). Search, by the request's
|
|
6
|
+
* `mode`: `turbo` or `fast` $1 per 1,000 requests, `basic` or `advanced` $5 per 1,000, each with 10 results included,
|
|
7
|
+
* and each result past those 10 $1 per 1,000. Extract: $1 per 1,000 URLs. */
|
|
8
|
+
export declare const PARALLEL_SEARCH_MODE_USD: Readonly<Record<ParallelSearchMode, number>>;
|
|
9
|
+
/** A `fast` search's price: the mode the web tools search in (web-search.ts). */
|
|
5
10
|
export declare const PARALLEL_SEARCH_USD = 0.001;
|
|
6
11
|
export declare const PARALLEL_SEARCH_RESULT_USD = 0.001;
|
|
7
12
|
export declare const PARALLEL_SEARCH_INCLUDED = 10;
|
|
@@ -13,12 +18,14 @@ export type Fee = {
|
|
|
13
18
|
usd: number;
|
|
14
19
|
basis: string;
|
|
15
20
|
};
|
|
16
|
-
/** A
|
|
17
|
-
|
|
21
|
+
/** A search in `mode` for `n` results: the mode's price (PARALLEL_SEARCH_MODE_USD), and $0.001 for each past the 10 it
|
|
22
|
+
* includes. The web tools search `fast`: $0.001. */
|
|
23
|
+
export declare const parallelSearchFee: (n: number, mode?: ParallelSearchMode) => Fee;
|
|
18
24
|
/** An extract of `urls` URLs (the web tools ask one at a time). */
|
|
19
25
|
export declare const parallelExtractFee: (urls?: number) => Fee;
|
|
20
|
-
/** The fee of a request to Parallel's `url` with `body`: its search's, by the results it asks for (10 by
|
|
21
|
-
* extract's, by the URLs; undefined for an endpoint the web tools do not ask
|
|
26
|
+
/** 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
|
|
27
|
+
* default), or its extract's, by the URLs; undefined for an endpoint the web tools do not ask, and for a search whose
|
|
28
|
+
* mode has no price here (one naming none, or one Parallel added since): never $0, never another mode's price. */
|
|
22
29
|
export declare function parallelFeeOf(url: string, body: unknown): Fee | undefined;
|
|
23
30
|
/** 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:
|
|
24
31
|
* nothing was sent. Its message is the refusal, in the cap's words. */
|
package/dist/paid-calls.js
CHANGED
|
@@ -15,28 +15,34 @@
|
|
|
15
15
|
// tool books without the ledger passed down to it.
|
|
16
16
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
17
17
|
import { SPEND_CAP_REACHED } from "./cap.js";
|
|
18
|
-
/** Parallel's published prices (https://docs.parallel.ai/
|
|
19
|
-
* $1 per 1,000 requests
|
|
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). */
|
|
20
23
|
export const PARALLEL_SEARCH_USD = 0.001;
|
|
21
24
|
export const PARALLEL_SEARCH_RESULT_USD = 0.001;
|
|
22
25
|
export const PARALLEL_SEARCH_INCLUDED = 10;
|
|
23
26
|
export const PARALLEL_EXTRACT_USD = 0.001;
|
|
24
27
|
/** In whole millionths of a dollar, so a sum of prices is the price. */
|
|
25
28
|
const usd = (dollars) => Math.round(dollars * 1e6) / 1e6;
|
|
26
|
-
|
|
27
|
-
|
|
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") => {
|
|
28
33
|
const more = Math.max(0, n - PARALLEL_SEARCH_INCLUDED);
|
|
29
|
-
return { name: "Parallel's search", by: "parallel", usd: usd(
|
|
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` };
|
|
30
35
|
};
|
|
31
36
|
/** An extract of `urls` URLs (the web tools ask one at a time). */
|
|
32
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` });
|
|
33
|
-
/** The fee of a request to Parallel's `url` with `body`: its search's, by the results it asks for (10 by
|
|
34
|
-
* extract's, by the URLs; undefined for an endpoint the web tools do not ask
|
|
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. */
|
|
35
41
|
export function parallelFeeOf(url, body) {
|
|
36
42
|
const path = URL.parse(url)?.pathname;
|
|
37
43
|
const asked = (body ?? {});
|
|
38
44
|
if (path === "/v1/search")
|
|
39
|
-
return parallelSearchFee(typeof asked.advanced_settings?.max_results === "number" ? asked.advanced_settings.max_results : PARALLEL_SEARCH_INCLUDED);
|
|
45
|
+
return isSearchMode(asked.mode) ? parallelSearchFee(typeof asked.advanced_settings?.max_results === "number" ? asked.advanced_settings.max_results : PARALLEL_SEARCH_INCLUDED, asked.mode) : undefined;
|
|
40
46
|
if (path === "/v1/extract")
|
|
41
47
|
return parallelExtractFee(Array.isArray(asked.urls) ? Math.max(1, asked.urls.length) : 1);
|
|
42
48
|
return undefined;
|
package/dist/run-launch.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SdkBinding } from "./sdk/runtimes.js";
|
|
1
2
|
import type { SdkWorkflowTool, SdkWorkflowAdapter } from "./sdk/workflows.js";
|
|
2
3
|
import type { NativeBinding } from "./native/types.js";
|
|
3
4
|
import { type MessageOrigin } from "./timeline/index.js";
|
|
@@ -12,8 +13,7 @@ import type { Place } from "./workspace/place.js";
|
|
|
12
13
|
* `documents` and `boxAllow` are the per-run choices
|
|
13
14
|
* the old path recomputed; here they are pinned at start, and optional (a built-in run may name none). */
|
|
14
15
|
export interface RunLaunch {
|
|
15
|
-
readonly sdk?: {
|
|
16
|
-
runtime: "claude-agent-sdk" | "codex-sdk" | "eve";
|
|
16
|
+
readonly sdk?: SdkBinding & {
|
|
17
17
|
instructions: string;
|
|
18
18
|
model?: string;
|
|
19
19
|
workflow_tools?: SdkWorkflowTool[];
|
package/dist/run-launch.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sdkBindingOf } from "./sdk/runtimes.js";
|
|
1
2
|
import { nativeOf } from "./native/binding.js";
|
|
2
3
|
// A run's launch record: the one JSON body the server writes when it starts a run (start = INSERT run, design 2.1), and
|
|
3
4
|
// the runner reads at its claim to build the run's spec. It replaces the per-run `serve.json` the old per-run process read
|
|
@@ -104,7 +105,7 @@ export function readLaunchBody(stored) {
|
|
|
104
105
|
const archilDisk = readDisk(stored.archil_disk);
|
|
105
106
|
return {
|
|
106
107
|
input: stored.input,
|
|
107
|
-
...(isObject(stored.sdk) && (stored.sdk
|
|
108
|
+
...(isObject(stored.sdk) && sdkBindingOf(stored.sdk) && typeof stored.sdk.instructions === "string" ? { sdk: stored.sdk } : {}),
|
|
108
109
|
...(nativeOf(stored) ? { native: nativeOf(stored) } : {}),
|
|
109
110
|
title: typeof stored.title === "string" ? stored.title : "",
|
|
110
111
|
...(typeof stored.repo === "string" ? { repo: stored.repo } : {}),
|
|
@@ -11,7 +11,7 @@ import { capNowOf } from "./runner/journal-kinds.js";
|
|
|
11
11
|
import { journalRecords } from "./runner/journal-reader.js";
|
|
12
12
|
import { decisionsOverStore } from "./store-reads/decisions.js";
|
|
13
13
|
import { readRun } from "./store-reads/runs.js";
|
|
14
|
-
import { runTimeline, wholeAnswerFor, wholeAnswers } from "./store-reads/journal.js";
|
|
14
|
+
import { runTimeline, servedSince, wholeAnswerFor, wholeAnswers } from "./store-reads/journal.js";
|
|
15
15
|
import { FINAL_STATES } from "./store/store.js";
|
|
16
16
|
/** Run `runId`'s Timeline rows as served: cut by its one cut set, its decision rows among them, its error rows in the
|
|
17
17
|
* run's error's words; none for a run withheld. `calls`: each call's arguments whole and its output's head to
|
|
@@ -20,7 +20,9 @@ export async function servedTimelineRows(deps, store, runId, context, calls = fa
|
|
|
20
20
|
// The run's rows, its decisions, its learning end and the triggers' names, all read in one snapshot of the store (one
|
|
21
21
|
// moment, whatever the run's runner writes meanwhile): a row from before an answer never sits beside one from after it.
|
|
22
22
|
// They are rendered under the run's cut, which is read before the snapshot and again after it (underCut): the cut only
|
|
23
|
-
// grows, so a cut that is the same after holds every value saved before the rows were read.
|
|
23
|
+
// grows, so a cut that is the same after holds every value saved before the rows were read. Its whole answers are kept
|
|
24
|
+
// only while no run's text was forgotten since it began (servedSince: a purge it overtook).
|
|
25
|
+
const since = servedSince(store);
|
|
24
26
|
const read = await underCut(() => runCutValues(deps, store, runId), async (cut) => {
|
|
25
27
|
if (cut === "unreadable")
|
|
26
28
|
return undefined;
|
|
@@ -47,7 +49,7 @@ export async function servedTimelineRows(deps, store, runId, context, calls = fa
|
|
|
47
49
|
const final = run?.state === "stopped" || run?.state === "failed" ? run.state
|
|
48
50
|
: stopAsked(view, run, await snapshot.commands(runId, 0)) ? "stopped" : undefined;
|
|
49
51
|
const options = { redact, settled: ended, ended: view ? view.state !== "running" : false, ...(calls ? { calls: { result: CALL_RESULT_CHARS, redact: (text) => redacted(text, values, CALL_RESULT_CHARS), held: (value) => heldNumber(value, values) } } : {}) };
|
|
50
|
-
const timeline = await wholeAnswers(snapshot, runId, context, await runTimeline(snapshot, runId, context, options), options, wholeAnswerFor(values));
|
|
52
|
+
const timeline = await wholeAnswers(snapshot, runId, context, await runTimeline(snapshot, runId, context, options), options, wholeAnswerFor(values), since);
|
|
51
53
|
// A run whose booked spend passed its cap says so, by how much, after its usage row (run-view.ts withOverCap, as main's
|
|
52
54
|
// served Timeline did): at the cap as it stands (a raise taken counts, capNowOf).
|
|
53
55
|
const capNow = capNowOf((await launchOf(snapshot, runId))?.maxCostUsd, records.entries);
|