@parcha/agentrun-serve 0.1.0-beta.54 → 0.1.0-beta.56
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 +142 -2
- package/README.md +310 -98
- package/dist/adapters.d.ts +11 -0
- package/dist/adapters.js +49 -0
- package/dist/agent-package.d.ts +3 -3
- package/dist/agent-package.js +6 -13
- package/dist/agents-store.js +6 -5
- package/dist/answer-json.d.ts +6 -2
- package/dist/answer-json.js +22 -4
- package/dist/api-only.d.ts +16 -4
- package/dist/api-only.js +23 -7
- package/dist/calendar/tools.js +3 -2
- package/dist/chatgpt-plan.d.ts +16 -1
- package/dist/chatgpt-plan.js +116 -12
- package/dist/claude-login.d.ts +34 -5
- package/dist/claude-login.js +31 -7
- package/dist/claude-sign-in.d.ts +35 -0
- package/dist/claude-sign-in.js +90 -0
- package/dist/cli.js +5 -3
- package/dist/composio-made.d.ts +26 -1
- package/dist/composio-made.js +39 -2
- package/dist/composio-preset.d.ts +3 -2
- package/dist/composio-preset.js +46 -14
- package/dist/computer-held-routes.js +2 -3
- package/dist/computer-setting.d.ts +4 -2
- package/dist/computer-setting.js +0 -2
- package/dist/computers-running.d.ts +8 -0
- package/dist/computers-running.js +27 -0
- package/dist/console/assets/backend-Boh7tC4i.js +166 -0
- package/dist/console/assets/index-CQ3cJRzI.js +746 -0
- package/dist/console/assets/index-DKkaS3a0.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/docker-host-addresses.d.ts +23 -3
- package/dist/docker-host-addresses.js +90 -18
- package/dist/exa-keyless.d.ts +2 -3
- package/dist/exa-keyless.js +43 -127
- package/dist/firecrawl-keyless.d.ts +41 -0
- package/dist/firecrawl-keyless.js +152 -0
- package/dist/handed-secret.d.ts +3 -1
- package/dist/handed-secret.js +4 -2
- package/dist/harness-keys.d.ts +98 -0
- package/dist/harness-keys.js +247 -0
- package/dist/harness-recipe-entry.d.ts +14 -9
- package/dist/harness-recipe-entry.js +25 -14
- package/dist/harness-table.d.ts +16 -1
- package/dist/harness-table.js +19 -7
- package/dist/harness.d.ts +4 -0
- package/dist/harness.js +12 -1
- package/dist/host-check.d.ts +6 -0
- package/dist/host-check.js +10 -0
- package/dist/import-summary.d.ts +1 -1
- package/dist/import-summary.js +1 -1
- package/dist/import.d.ts +5 -5
- package/dist/import.js +54 -67
- package/dist/key-refusal.d.ts +21 -5
- package/dist/key-refusal.js +231 -37
- package/dist/keyless-mcp.d.ts +36 -0
- package/dist/keyless-mcp.js +127 -0
- package/dist/learn/audit.d.ts +3 -3
- package/dist/learn/audit.js +3 -3
- package/dist/learn/commit.d.ts +8 -7
- package/dist/learn/commit.js +60 -20
- package/dist/learn/compile.d.ts +4 -3
- package/dist/learn/compile.js +7 -5
- package/dist/learn/folder.d.ts +16 -3
- package/dist/learn/folder.js +46 -13
- package/dist/learn/promote.d.ts +37 -13
- package/dist/learn/promote.js +112 -40
- package/dist/learn/secrets.d.ts +20 -10
- package/dist/learn/secrets.js +44 -176
- package/dist/learning-routes.d.ts +22 -17
- package/dist/learning-routes.js +40 -39
- package/dist/learning.js +2 -2
- package/dist/llms.txt +1 -1
- package/dist/manifest.d.ts +10 -0
- package/dist/manifest.js +30 -0
- package/dist/mcp-pin-first.d.ts +4 -2
- package/dist/mcp-pin-first.js +5 -2
- package/dist/mcp-secret-writes.d.ts +16 -7
- package/dist/mcp-secret-writes.js +35 -27
- package/dist/mcp-servers-store.d.ts +30 -6
- package/dist/mcp-servers-store.js +112 -28
- package/dist/mcp-sources.d.ts +10 -2
- package/dist/mcp-sources.js +9 -2
- package/dist/mcp-store.d.ts +13 -7
- package/dist/mcp-store.js +12 -9
- package/dist/model-form.d.ts +3 -2
- package/dist/model-form.js +11 -7
- package/dist/model.d.ts +20 -4
- package/dist/model.js +68 -9
- package/dist/native/history.d.ts +1 -1
- package/dist/native/history.js +2 -2
- package/dist/ollama-provider.d.ts +92 -0
- package/dist/ollama-provider.js +495 -0
- package/dist/openapi/agentrun-v2.openapi.json +2 -2
- package/dist/openapi.d.ts +3 -3
- package/dist/openapi.js +197 -55
- package/dist/page.d.ts +11 -3
- package/dist/page.js +22 -7
- package/dist/place-offers.d.ts +25 -1
- package/dist/place-offers.js +62 -8
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +35 -7
- package/dist/purged-workflow.js +73 -26
- package/dist/redact/match.d.ts +74 -0
- package/dist/redact/match.js +771 -0
- package/dist/run-computer.d.ts +2 -0
- package/dist/run-computer.js +2 -0
- package/dist/run-files.d.ts +4 -0
- package/dist/run-files.js +4 -0
- package/dist/run-keys.d.ts +2 -4
- package/dist/run-keys.js +6 -7
- package/dist/run-launch.d.ts +4 -0
- package/dist/run-launch.js +4 -0
- package/dist/run-reads-over-store.d.ts +3 -2
- package/dist/run-reads-over-store.js +66 -2
- package/dist/run-secrets.js +5 -2
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +4 -4
- package/dist/runner/adapter-loop.d.ts +9 -3
- package/dist/runner/adapter-loop.js +34 -15
- package/dist/runner/adapter-run-spec.d.ts +3 -0
- package/dist/runner/adapter-run-spec.js +9 -4
- package/dist/runner/audit.js +8 -4
- package/dist/runner/beside.d.ts +2 -1
- package/dist/runner/beside.js +13 -5
- package/dist/runner/claim-secrets.d.ts +5 -8
- package/dist/runner/claim-secrets.js +6 -0
- package/dist/runner/cli-run-spec.d.ts +1 -1
- package/dist/runner/cli-run-spec.js +41 -7
- package/dist/runner/harness-loops.d.ts +22 -9
- package/dist/runner/harness-loops.js +21 -11
- package/dist/runner/held.d.ts +3 -0
- package/dist/runner/learning-end.d.ts +1 -1
- package/dist/runner/learning-end.js +8 -3
- package/dist/runner/loop-contract.d.ts +9 -4
- package/dist/runner/main.js +12 -6
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +26 -2
- package/dist/runner/mcp-run.d.ts +3 -0
- package/dist/runner/mcp-run.js +2 -1
- package/dist/runner/metrics.d.ts +10 -10
- package/dist/runner/metrics.js +19 -38
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +6 -2
- package/dist/runner/presence.d.ts +4 -3
- package/dist/runner/presence.js +4 -2
- package/dist/runner/promotion.d.ts +15 -9
- package/dist/runner/promotion.js +25 -15
- package/dist/runner/run-child-host.d.ts +2 -0
- package/dist/runner/run-child-host.js +19 -9
- package/dist/runner/run-child.js +3 -1
- package/dist/runner/runner.d.ts +4 -0
- package/dist/runner/runner.js +33 -3
- package/dist/runner/sdk-loop.js +2 -0
- package/dist/runner/workflow-loop.d.ts +2 -2
- package/dist/runner/workflow-loop.js +1 -2
- package/dist/runner/workflow-spec.d.ts +1 -1
- package/dist/runner/workflow-spec.js +6 -6
- package/dist/sdk/check.d.ts +4 -1
- package/dist/sdk/check.js +2 -1
- package/dist/sdk/runs.d.ts +2 -2
- package/dist/sdk/runs.js +8 -6
- package/dist/secret-cut.js +2 -1
- package/dist/secret-writes.d.ts +3 -2
- package/dist/secret-writes.js +1 -1
- package/dist/server.d.ts +49 -10
- package/dist/server.js +324 -118
- package/dist/standard-webhooks.d.ts +11 -0
- package/dist/standard-webhooks.js +20 -2
- package/dist/store/dialect.d.ts +3 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/dialect.js +3 -0
- package/dist/store/schema.js +5 -2
- package/dist/store/sqlite/store.js +133 -47
- package/dist/store/store.d.ts +64 -15
- package/dist/store/store.js +7 -0
- package/dist/store-reads/journal.d.ts +7 -2
- package/dist/store-reads/journal.js +9 -6
- package/dist/store-reads/learning.d.ts +12 -9
- package/dist/store-reads/learning.js +18 -24
- package/dist/store-view.d.ts +0 -5
- package/dist/store-view.js +10 -9
- package/dist/template-eval.d.ts +51 -6
- package/dist/template-eval.js +177 -53
- package/dist/template-import.js +4 -2
- package/dist/templates.d.ts +5 -3
- package/dist/templates.js +19 -40
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/labels.d.ts +2 -2
- package/dist/timeline/labels.js +2 -2
- package/dist/timeline/timeline.d.ts +14 -9
- package/dist/timeline/timeline.js +15 -7
- package/dist/tool-gate.js +3 -1
- package/dist/tool-plane.d.ts +17 -9
- package/dist/tool-plane.js +38 -17
- package/dist/tools.js +2 -2
- package/dist/trigger-launch-hook.d.ts +16 -8
- package/dist/trigger-launch-hook.js +32 -23
- package/dist/trigger-targets.d.ts +18 -8
- package/dist/trigger-targets.js +42 -19
- package/dist/triggers.d.ts +85 -23
- package/dist/triggers.js +303 -96
- package/dist/validate.js +1 -1
- package/dist/web-fake.js +3 -3
- package/dist/web-fetch-direct.d.ts +4 -0
- package/dist/web-fetch-direct.js +8 -1
- package/dist/web-fetch.d.ts +12 -3
- package/dist/web-fetch.js +47 -14
- package/dist/web-search.d.ts +33 -4
- package/dist/web-search.js +100 -41
- package/dist/webhooks.js +4 -5
- package/dist/workspace/computer-deps.d.ts +2 -1
- package/dist/workspace/computer-deps.js +5 -4
- package/dist/workspace/computer-for-claim.d.ts +8 -2
- package/dist/workspace/computer-for-claim.js +28 -9
- package/dist/workspace/computer-janitor.d.ts +15 -7
- package/dist/workspace/computer-janitor.js +33 -8
- package/dist/workspace/computer-kept.d.ts +52 -4
- package/dist/workspace/computer-kept.js +118 -6
- package/dist/workspace/run-end-computers.d.ts +5 -1
- package/dist/workspace/run-end-computers.js +27 -1
- package/dist/wrapped.d.ts +57 -0
- package/dist/wrapped.js +51 -0
- package/launcher/agentrun-serve +5 -1
- package/package.json +17 -13
- package/templates/README.md +10 -9
- package/dist/console/assets/index-B_85An2t.js +0 -745
- package/dist/console/assets/index-n1YsbnYh.css +0 -1
- package/dist/import-sources.d.ts +0 -116
- package/dist/import-sources.js +0 -693
package/dist/key-refusal.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// count, a file name, a duration, another service's status) is no refused key, and the error is left as it is.
|
|
5
5
|
import { DEFAULT_HARNESS } from "./harness.js";
|
|
6
6
|
import { harnessOf } from "./harness-table.js";
|
|
7
|
-
import { endsInScheme, redactSecrets, valueMatcher } from "./learn/secrets.js";
|
|
7
|
+
import { cutSecrets, endsInScheme, redactSecrets, secretShapes, valueLeft, valueMatcher } from "./learn/secrets.js";
|
|
8
8
|
import { hostModel, MODEL_KEYS } from "./model.js";
|
|
9
9
|
import { modelWire, openRouterOnly, WIRES } from "./provider.js";
|
|
10
10
|
import { savedGatewayIn } from "./model-gateway.js";
|
|
@@ -59,7 +59,7 @@ const SHOWN = 2000;
|
|
|
59
59
|
* form (6 times it, for JSON's \uXXXX; percent is 3, hex 2, base64 4/3) and 16 more. A key whose start the cut can show
|
|
60
60
|
* starts before SHOWN, so it ends inside that head and is found whole; one that starts later is never shown. So a long
|
|
61
61
|
* error costs no more to redact than a short one, whatever it holds. `shown`: a head of another length, for a reader
|
|
62
|
-
* that is shown more
|
|
62
|
+
* that is shown more. */
|
|
63
63
|
export function redacted(text, secrets, shown = SHOWN) {
|
|
64
64
|
const longest = secrets.reduce((most, value) => Math.max(most, value.length), 0);
|
|
65
65
|
const window = shown + 6 * longest + 16;
|
|
@@ -83,50 +83,244 @@ export const answerPasses = { count: 0 };
|
|
|
83
83
|
* in it, and NEVER cut: an answer is shown whole. The same rule as redacted() (redactSecrets over `secrets`), over the
|
|
84
84
|
* whole text, read in pieces of about ANSWER_PIECE characters cut at whitespace. No form of a held value redactSecrets
|
|
85
85
|
* finds as it stands (as written, JSON-escaped, base64, hex) holds whitespace, so a cut there splits none; the one shape
|
|
86
|
-
* read across whitespace, a Bearer scheme and its token, is never cut between the two (endsInScheme). A run
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
86
|
+
* read across whitespace, a Bearer scheme and its token, is never cut between the two (endsInScheme). A run with no
|
|
87
|
+
* whitespace past a piece is cut at the end of a JSON string in it (never in a URL's user and password), or, a run of
|
|
88
|
+
* a JSON array's numbers only, after a comma (runCut), so compact JSON reads in pieces too. A run of more than ANSWER_PIECE characters with neither is no
|
|
89
|
+
* person's text and is shown as "[redacted]", unread, from where its run starts. A value or a secret shape split across
|
|
90
|
+
* a cut, or a form only found across pieces, still shows to one pass over the joined pieces (heldIn: valueLeft over
|
|
91
|
+
* them as they came, and secretShapes over them redacted; with the head of each run left unread, where the rest of a
|
|
92
|
+
* value split before it would be), and then the whole answer is "[redacted]", as redactSecrets does with a text that
|
|
93
|
+
* still holds a value. So is an answer whose pieces, as shown, read as a held value together (heldIn reads the text it
|
|
94
|
+
* returns too). A value split inside one piece withholds only that piece, by the piece's own redaction. */
|
|
90
95
|
export function redactedAnswer(text, secrets) {
|
|
91
96
|
if (!text)
|
|
92
97
|
return text;
|
|
93
98
|
answerPasses.count++;
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
const { out, seen } = inPieces(text, secrets);
|
|
100
|
+
return heldIn(seen, secrets, out) ? "[redacted]" : out;
|
|
101
|
+
}
|
|
102
|
+
/** `text`, a call's result as a grader's read shows it (timeline calls, tool_result_text), with no held secret in it:
|
|
103
|
+
* read in pieces as redactedAnswer reads an answer, each piece redacted, then shown as `show` makes it (the timeline's
|
|
104
|
+
* scrubUrls), then one pass over the pieces (heldIn). Every check reads the text as it came, redacted, and not only as
|
|
105
|
+
* shown: shown, a URL's query, fragment and userinfo are cut apart, and a held value in one no longer reads as itself;
|
|
106
|
+
* what it returns is read too, for a held value its pieces show only together. A piece
|
|
107
|
+
* never splits a URL (it is cut at whitespace, after a quote, or in a run of numbers), so a piece shows as the whole
|
|
108
|
+
* text would. Only the head the reader is shown is read: pieces stop once they show more than `shown` characters, and
|
|
109
|
+
* the pass also reads the text where they stopped (peek), so a value or a shape the stop split is seen whole. Every
|
|
110
|
+
* character returned was read; the caller cuts it to `shown`. So no redaction pass reads more than a piece, however long
|
|
111
|
+
* the result or its head. */
|
|
112
|
+
export function redactedCall(text, secrets, shown, show = (piece) => piece) {
|
|
113
|
+
if (!text)
|
|
114
|
+
return text;
|
|
115
|
+
const { out, seen, short } = inPieces(text, secrets, shown, show);
|
|
116
|
+
// A read that stopped on what it read, before what it shows reached `shown`, ends as a cut does ("...", timeline/util.ts
|
|
117
|
+
// cut), so a reader (the link check) knows it is not whole.
|
|
118
|
+
const result = short ? `${out}...` : out;
|
|
119
|
+
return heldIn(seen, secrets, result) ? "[redacted]" : result;
|
|
120
|
+
}
|
|
121
|
+
/** Whether the text a reader is about to be shown (`shown`, what the caller returns) holds a held value, or the joined
|
|
122
|
+
* pieces still hold one or a secret shape: one a cut split. `shown` is read whole for a held value (valueMatcher, one
|
|
123
|
+
* linear pass): however the pieces were put together, as each was cut or shown, or an unread run's "[redacted]" between
|
|
124
|
+
* them, no text that reads as a held value is returned (a held value holding "[redacted]", its parts on either side of
|
|
125
|
+
* a cut in another piece). A value is also looked for in the pieces as they came, joined by line breaks, each piece's
|
|
126
|
+
* own cuts covering it (valueLeft): a piece's cut can take part of a value split across pieces (a credential
|
|
127
|
+
* parameter's value cut in place at the end of a piece, the rest of the held value in the next), and the rest then no
|
|
128
|
+
* longer reads as the value. A piece withheld whole covers all of itself, so a value split inside one piece is that
|
|
129
|
+
* piece's own redaction's, and only a value no cut covers across pieces (or in the text read past where they stopped)
|
|
130
|
+
* withholds the text. Each unread run's head is covered (it shows as "[redacted]") and read for the rest of a value
|
|
131
|
+
* split before it. A shape is looked for in the pieces each redacted (a shape whole in one is no shape a cut split). A
|
|
132
|
+
* peek too long to read (`unread`) withholds the text too. */
|
|
133
|
+
function heldIn(seen, secrets, shown) {
|
|
134
|
+
return seen.unread || valueMatcher(secrets)(shown) || valueLeft(seen.raw, secrets, seen.cuts) || secretShapes(seen.shapes).length > 0;
|
|
135
|
+
}
|
|
136
|
+
/** `text` read in pieces as redactedAnswer says (pieceEnd), each redacted by itself: what the pieces show, joined, and
|
|
137
|
+
* what the pass after them reads (heldIn): each piece as it came and the spans its redaction cut, and each piece
|
|
138
|
+
* redacted, with the head of each unread run put back (covered, as it came; redacted by itself before its "[redacted]"
|
|
139
|
+
* for the shapes). A run runCut cut that then goes on past a piece with
|
|
140
|
+
* no place to cut is unread from its start, the pieces of it already read taken back, so no piece shows the head of a
|
|
141
|
+
* value or a shape the cut split. With `enough`, no piece is read once the pieces show more than `enough` characters,
|
|
142
|
+
* and the text where they stopped, `hold` characters the matcher sees of it (peek), goes to the pass the same way.
|
|
143
|
+
* Each piece is redacted, then shown as `show` makes it: `out` is what the pieces show, the pass reads them unshown. */
|
|
144
|
+
function inPieces(text, secrets, enough = Number.POSITIVE_INFINITY, show = (piece) => piece) {
|
|
145
|
+
const hold = 6 * secrets.reduce((most, value) => Math.max(most, value.length), 0) + 16;
|
|
146
|
+
const out = [];
|
|
147
|
+
const shapes = [];
|
|
148
|
+
const reads = [];
|
|
149
|
+
let shown = 0;
|
|
150
|
+
let unread = false;
|
|
151
|
+
// The run runCut is cutting: where it starts in `text`, and its first piece's index in `out`.
|
|
152
|
+
let run;
|
|
153
|
+
let from = 0;
|
|
154
|
+
// Also stops past 4 × `enough` characters read: text that shows as almost nothing (URLs whose queries are elided) is
|
|
155
|
+
// not read to its end. Where it stops, the peek reads on as at any stop.
|
|
156
|
+
while (from < text.length && shown <= enough && from <= 4 * enough) {
|
|
157
|
+
const to = pieceEnd(text, from);
|
|
158
|
+
const raw = text.slice(from, to);
|
|
159
|
+
if (raw.length > ANSWER_PIECE) {
|
|
160
|
+
const start = run?.from ?? from;
|
|
161
|
+
if (run) {
|
|
162
|
+
for (const part of out.splice(run.at))
|
|
163
|
+
shown -= part.length;
|
|
164
|
+
shapes.splice(run.at);
|
|
165
|
+
reads.splice(run.at);
|
|
106
166
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
to = from + before + 1;
|
|
115
|
-
else {
|
|
116
|
-
const next = text.slice(to).search(/\s/);
|
|
117
|
-
to = next < 0 ? text.length : to + next;
|
|
118
|
-
parts.push(to - from > ANSWER_PIECE ? "[redacted]" : redactSecrets(text.slice(from, to), secrets, Buffer.byteLength(text.slice(from, to))));
|
|
119
|
-
from = to;
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
167
|
+
const head = peek(text, start, hold);
|
|
168
|
+
if (head === undefined)
|
|
169
|
+
unread = true;
|
|
170
|
+
else {
|
|
171
|
+
shapes.push(`${redactSecrets(head, secrets, Buffer.byteLength(head))}[redacted]`);
|
|
172
|
+
// The run is shown as "[redacted]": all of its head is covered.
|
|
173
|
+
reads.push({ text: head, cuts: head ? [[0, head.length]] : [] });
|
|
122
174
|
}
|
|
175
|
+
out.push("[redacted]");
|
|
176
|
+
shown += "[redacted]".length;
|
|
177
|
+
run = undefined;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
const cut = cutSecrets(raw, secrets, Buffer.byteLength(raw));
|
|
181
|
+
const part = cut === "whole" ? "[redacted]" : cut.out;
|
|
182
|
+
reads.push({ text: raw, cuts: cut === "whole" ? [[0, raw.length]] : cut.spans });
|
|
183
|
+
// A piece that ends inside a run (runCut's): its run goes on in the next piece.
|
|
184
|
+
if (to < text.length && /\S/.test(text[to - 1] ?? "") && /\S/.test(text[to] ?? ""))
|
|
185
|
+
run ??= { from, at: out.length };
|
|
186
|
+
else
|
|
187
|
+
run = undefined;
|
|
188
|
+
const showsAs = show(part);
|
|
189
|
+
out.push(showsAs);
|
|
190
|
+
shapes.push(part);
|
|
191
|
+
shown += showsAs.length;
|
|
123
192
|
}
|
|
124
|
-
const piece = text.slice(from, to);
|
|
125
|
-
parts.push(redactSecrets(piece, secrets, Buffer.byteLength(piece)));
|
|
126
193
|
from = to;
|
|
127
194
|
}
|
|
128
|
-
|
|
129
|
-
|
|
195
|
+
if (from < text.length) {
|
|
196
|
+
// Stopped inside a run runCut cut: the rest of it, to its next whitespace (at most a piece), goes to the pass too.
|
|
197
|
+
const space = run ? text.slice(from, from + ANSWER_PIECE).search(/\s/) : 0;
|
|
198
|
+
const runTo = from + (space < 0 ? ANSWER_PIECE : space);
|
|
199
|
+
const ahead = peek(text, from, hold);
|
|
200
|
+
if (ahead === undefined)
|
|
201
|
+
unread = true;
|
|
202
|
+
else {
|
|
203
|
+
const rest = runTo > from + ahead.length ? text.slice(from, runTo) : ahead;
|
|
204
|
+
shapes.push(redactSecrets(rest, secrets, Buffer.byteLength(rest)));
|
|
205
|
+
reads.push({ text: rest, cuts: [] });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// The reads joined by line breaks, each one's cuts moved to where it stands in the join. The matcher's views read a
|
|
209
|
+
// line break as nothing, so a value whole across two pieces is no form found as it stands there, and is left.
|
|
210
|
+
let raw = "";
|
|
211
|
+
const cuts = [];
|
|
212
|
+
reads.forEach((read, at) => {
|
|
213
|
+
if (at > 0)
|
|
214
|
+
raw += "\n";
|
|
215
|
+
for (const [start, end] of read.cuts)
|
|
216
|
+
cuts.push([raw.length + start, raw.length + end]);
|
|
217
|
+
raw += read.text;
|
|
218
|
+
});
|
|
219
|
+
return { out: out.join(""), seen: { raw, cuts, shapes: shapes.join(""), unread }, short: from < text.length && shown <= enough };
|
|
220
|
+
}
|
|
221
|
+
/** text from `from` on, as far as `count` characters the matcher sees (all of it, if it holds fewer), each run of
|
|
222
|
+
* whitespace in it one space. The matcher reads "+" as a space and decodes percent-encoded bytes, so a "+" and an
|
|
223
|
+
* encoded byte that decodes to whitespace count no more than whitespace does: padding of either never hides the rest
|
|
224
|
+
* of a value split before it. Undefined, so the caller withholds the text, when that takes more than a piece of text
|
|
225
|
+
* (a run of whitespace counted as one): no redaction pass reads more than a piece. */
|
|
226
|
+
function peek(text, from, count) {
|
|
227
|
+
const parts = [];
|
|
228
|
+
let span = 0;
|
|
229
|
+
let found = 0;
|
|
230
|
+
for (let at = from; at < text.length && found < count;) {
|
|
231
|
+
SPACES.lastIndex = at;
|
|
232
|
+
let end = SPACES.test(text) ? SPACES.lastIndex : at;
|
|
233
|
+
if (end > at) {
|
|
234
|
+
parts.push(" ");
|
|
235
|
+
span++;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
while (end - at <= ANSWER_PIECE && text[end] === "%" && HEX_PAIR.test(text.slice(end + 1, end + 3)))
|
|
239
|
+
end += 3;
|
|
240
|
+
if (end > at)
|
|
241
|
+
found += Buffer.from(text.slice(at, end).replaceAll("%", ""), "hex").toString("utf8").replace(/\s+/g, "").length;
|
|
242
|
+
else {
|
|
243
|
+
end = at + 1;
|
|
244
|
+
if (text[at] !== "+")
|
|
245
|
+
found++;
|
|
246
|
+
}
|
|
247
|
+
parts.push(text.slice(at, end));
|
|
248
|
+
span += end - at;
|
|
249
|
+
}
|
|
250
|
+
if (span > ANSWER_PIECE)
|
|
251
|
+
return undefined;
|
|
252
|
+
at = end;
|
|
253
|
+
}
|
|
254
|
+
return parts.join("");
|
|
255
|
+
}
|
|
256
|
+
const SPACES = /\s+/y;
|
|
257
|
+
const HEX_PAIR = /^[0-9A-Fa-f]{2}$/;
|
|
258
|
+
/** Where the piece of `text` read from `from` ends: at its last whitespace before ANSWER_PIECE characters; with none, at
|
|
259
|
+
* runCut's place, else at the next whitespace (a run read as one, or unread past ANSWER_PIECE). */
|
|
260
|
+
function pieceEnd(text, from) {
|
|
261
|
+
const to = Math.min(text.length, from + ANSWER_PIECE);
|
|
262
|
+
if (to === text.length)
|
|
263
|
+
return to;
|
|
264
|
+
const head = text.slice(from, to);
|
|
265
|
+
const space = head.search(/\s[^\s]*$/);
|
|
266
|
+
if (space <= 0) {
|
|
267
|
+
const cut = runCut(text, from, to);
|
|
268
|
+
return cut > from ? cut : runEnd(text, to);
|
|
269
|
+
}
|
|
270
|
+
const end = from + space + 1;
|
|
271
|
+
// A cut after a Bearer scheme would leave its token at the head of the next piece, where no shape reads it (the shape
|
|
272
|
+
// is the scheme, then the token). The cut moves back to the whitespace before the scheme; with none in this piece, the
|
|
273
|
+
// scheme and its token are read as one run, to the next whitespace, as a run with no whitespace is.
|
|
274
|
+
if (!endsInScheme(text.slice(from, end)))
|
|
275
|
+
return end;
|
|
276
|
+
const before = text.slice(from, end).trimEnd().search(/\s[^\s]*$/);
|
|
277
|
+
return before > 0 ? from + before + 1 : runEnd(text, end);
|
|
278
|
+
}
|
|
279
|
+
/** The next whitespace in `text` at or after `at`, or its end. */
|
|
280
|
+
function runEnd(text, at) {
|
|
281
|
+
const next = text.slice(at).search(/\s/);
|
|
282
|
+
return next < 0 ? text.length : at + next;
|
|
283
|
+
}
|
|
284
|
+
/** Where a run with no whitespace in text[from, to) may be cut, or -1: after the last quote in it that ends a JSON
|
|
285
|
+
* string (no backslash before it; a comma, colon or closing bracket after it) and is in no URL's authority
|
|
286
|
+
* (authorities); or, a run of a JSON array's numbers only, after its last comma. The one secret shape that may hold a
|
|
287
|
+
* quote is a URL's user and password, so no cut splits a shape, whatever its length: a run with no other place to cut
|
|
288
|
+
* is read to its end, or unread from its start. A held value cut there still shows to the pass over the joined pieces
|
|
289
|
+
* (heldIn), and withholds the text whole. Each search keeps to text[from, to), but for where a URL's authority ends,
|
|
290
|
+
* which is read once per URL, to the end of its run at most. */
|
|
291
|
+
function runCut(text, from, to) {
|
|
292
|
+
const head = text.slice(from, to);
|
|
293
|
+
const urls = authorities(text, from, head);
|
|
294
|
+
let url = urls.length - 1;
|
|
295
|
+
for (let at = head.lastIndexOf('"'); at >= 0; at = at > 0 ? head.lastIndexOf('"', at - 1) : -1) {
|
|
296
|
+
// The authority starting last before this quote, the one it could be in: they do not overlap.
|
|
297
|
+
while (url >= 0 && urls[url][0] >= at)
|
|
298
|
+
url--;
|
|
299
|
+
const inUrl = url >= 0 && at < urls[url][1];
|
|
300
|
+
if (!inUrl && (at > 0 ? head[at - 1] : text[from - 1]) !== "\\" && /[,:\]}]/.test(text[from + at + 1] ?? ""))
|
|
301
|
+
return from + at + 1;
|
|
302
|
+
}
|
|
303
|
+
const comma = head.lastIndexOf(",");
|
|
304
|
+
return comma > 0 && /^\s?[-+.\deE,[\]{}:]+$/.test(head) ? from + comma + 1 : -1;
|
|
305
|
+
}
|
|
306
|
+
/** Each URL authority in `head` (text from `from`) that holds a user and password, as [start, end) in `head`: from its
|
|
307
|
+
* "://" to the "@" that ends it, past the head's end if need be. One whose first whitespace, "/", "?" or "#" comes
|
|
308
|
+
* before any "@" (a URL with no password, then the rest of the JSON it is in) holds none, so none of it is kept whole. */
|
|
309
|
+
function authorities(text, from, head) {
|
|
310
|
+
const found = [];
|
|
311
|
+
const stop = /[\s/?#@]/g;
|
|
312
|
+
for (let at = head.indexOf("://"); at >= 0; at = head.indexOf("://", at)) {
|
|
313
|
+
stop.lastIndex = from + at + 3;
|
|
314
|
+
const hit = stop.exec(text);
|
|
315
|
+
const end = (hit?.index ?? text.length) - from;
|
|
316
|
+
if (hit?.[0] === "@")
|
|
317
|
+
found.push([at, end]);
|
|
318
|
+
if (end >= head.length)
|
|
319
|
+
break;
|
|
320
|
+
// Past an "@", on; past any other stop, from the character before it: a "/" may be the first of the next "://".
|
|
321
|
+
at = hit?.[0] === "@" ? end : end - 1;
|
|
322
|
+
}
|
|
323
|
+
return found;
|
|
130
324
|
}
|
|
131
325
|
/** Whether a number shows a held value. A held value can be all digits (a gateway's key), and a record or a call's
|
|
132
326
|
* arguments can quote it as a number: one whose digits hold a held value, by the same rule as a string's, is held. A
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** The MCP revision this client speaks; the server answers the one it takes. */
|
|
2
|
+
export declare const PROTOCOL = "2025-06-18";
|
|
3
|
+
/** The most of an answer read: a search's text is a few kilobytes, a page's markdown more; past this the rest is never
|
|
4
|
+
* read. */
|
|
5
|
+
export declare const MAX_BYTES: number;
|
|
6
|
+
/** What a free web search answers when its free limit holds, in our words: a backend's own (a link to sign up, a key in
|
|
7
|
+
* its MCP URL) mean nothing to a person here, so they are never passed on. */
|
|
8
|
+
export declare const RATE_LIMITED = "Free web search is rate-limited right now. Try again in a minute; add the free Parallel Search server in Settings \u2192 MCP servers and grant the agent its web_search; or add a Parallel key in Settings \u2192 API Keys to search with a key.";
|
|
9
|
+
/** One tool call's outcome: `status`, a non-2xx answer to `step` (with the seconds its Retry-After named); `error`, a
|
|
10
|
+
* JSON-RPC error's message, or that the server answered no initialize; else the call's `result` (undefined: no answer
|
|
11
|
+
* to the call came). */
|
|
12
|
+
export type Called = {
|
|
13
|
+
status: number;
|
|
14
|
+
retryAfterS?: number;
|
|
15
|
+
step: "initialize" | "the call";
|
|
16
|
+
} | {
|
|
17
|
+
error: string;
|
|
18
|
+
rpc: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
result: Record<string, unknown> | undefined;
|
|
21
|
+
};
|
|
22
|
+
/** A call given its own bound: as Called, or `over`, its answer ran past that bound (in bytes), unread. */
|
|
23
|
+
export type Bounded = Called | {
|
|
24
|
+
over: number;
|
|
25
|
+
};
|
|
26
|
+
/** The seconds a Retry-After names, as seconds or a date; undefined when it names none. */
|
|
27
|
+
export declare function retryAfterOf(response: Response): number | undefined;
|
|
28
|
+
/** `ms` of waiting that `signal` ends, rejecting with its reason. */
|
|
29
|
+
export declare const sleep: (ms: number, signal: AbortSignal) => Promise<void>;
|
|
30
|
+
/** A tool result's text blocks, joined by lines; empty when it has none. */
|
|
31
|
+
export declare const textBlocks: (result: Record<string, unknown> | undefined) => string;
|
|
32
|
+
/** The tool `name` called with `args` on the MCP server at `endpoint` through `dial`, each request ended by `deadline`:
|
|
33
|
+
* one exchange (initialize, notifications/initialized, tools/call). `maxBytes`: the call's answer's own bound, past
|
|
34
|
+
* which it is `over` (none: its first MAX_BYTES read). A failure to reach the server throws. */
|
|
35
|
+
export declare function callTool(endpoint: string, dial: typeof fetch, deadline: AbortSignal, name: string, args: Record<string, unknown>): Promise<Called>;
|
|
36
|
+
export declare function callTool(endpoint: string, dial: typeof fetch, deadline: AbortSignal, name: string, args: Record<string, unknown>, maxBytes: number): Promise<Bounded>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// The MCP client the keyless web backends share (firecrawl-keyless.ts, exa-keyless.ts): one tool call is one exchange
|
|
2
|
+
// over MCP's streamable HTTP transport. `initialize` (its session id, when the server names one), then
|
|
3
|
+
// `notifications/initialized`, then `tools/call`, each request carrying the session id only where one came back. An
|
|
4
|
+
// answer is JSON or an event stream's `data:` lines, and no more than 1 MiB of one is read, but for a call's answer given
|
|
5
|
+
// its own bound: one past that bound is `over`, never parsed cut. No key and no header beyond
|
|
6
|
+
// the transport's own is sent. What a refusal means (a free limit, a connection refused) is each backend's to read.
|
|
7
|
+
/** The MCP revision this client speaks; the server answers the one it takes. */
|
|
8
|
+
export const PROTOCOL = "2025-06-18";
|
|
9
|
+
const ACCEPT = "application/json, text/event-stream";
|
|
10
|
+
/** The most of an answer read: a search's text is a few kilobytes, a page's markdown more; past this the rest is never
|
|
11
|
+
* read. */
|
|
12
|
+
export const MAX_BYTES = 1 << 20;
|
|
13
|
+
/** What a free web search answers when its free limit holds, in our words: a backend's own (a link to sign up, a key in
|
|
14
|
+
* its MCP URL) mean nothing to a person here, so they are never passed on. */
|
|
15
|
+
export const RATE_LIMITED = "Free web search is rate-limited right now. Try again in a minute; add the free Parallel Search server in Settings → MCP servers and grant the agent its web_search; or add a Parallel key in Settings → API Keys to search with a key.";
|
|
16
|
+
/** The seconds a Retry-After names, as seconds or a date; undefined when it names none. */
|
|
17
|
+
export function retryAfterOf(response) {
|
|
18
|
+
const said = response.headers.get("retry-after")?.trim();
|
|
19
|
+
if (!said)
|
|
20
|
+
return undefined;
|
|
21
|
+
if (/^\d+$/.test(said))
|
|
22
|
+
return Number(said);
|
|
23
|
+
const at = Date.parse(said);
|
|
24
|
+
return Number.isNaN(at) ? undefined : Math.max(0, Math.ceil((at - Date.now()) / 1000));
|
|
25
|
+
}
|
|
26
|
+
/** `ms` of waiting that `signal` ends, rejecting with its reason. */
|
|
27
|
+
export const sleep = (ms, signal) => new Promise((resolve, reject) => {
|
|
28
|
+
if (signal.aborted)
|
|
29
|
+
return reject(signal.reason);
|
|
30
|
+
const stop = () => {
|
|
31
|
+
clearTimeout(timer);
|
|
32
|
+
reject(signal.reason);
|
|
33
|
+
};
|
|
34
|
+
const timer = setTimeout(() => {
|
|
35
|
+
signal.removeEventListener("abort", stop);
|
|
36
|
+
resolve();
|
|
37
|
+
}, ms);
|
|
38
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
39
|
+
});
|
|
40
|
+
/** At most MAX_BYTES of a body, as text; the rest is not read. */
|
|
41
|
+
async function boundedText(response) {
|
|
42
|
+
const reader = response.body?.getReader();
|
|
43
|
+
const chunks = [];
|
|
44
|
+
for (let size = 0; reader && size < MAX_BYTES;) {
|
|
45
|
+
const { done, value } = await reader.read();
|
|
46
|
+
if (done)
|
|
47
|
+
break;
|
|
48
|
+
chunks.push(value);
|
|
49
|
+
size += value.byteLength;
|
|
50
|
+
}
|
|
51
|
+
await reader?.cancel().catch(() => undefined);
|
|
52
|
+
return Buffer.concat(chunks).subarray(0, MAX_BYTES).toString("utf8");
|
|
53
|
+
}
|
|
54
|
+
/** A body of at most `max` bytes, as text; undefined where it runs past them (the rest is not read). */
|
|
55
|
+
async function cappedText(response, max) {
|
|
56
|
+
const reader = response.body?.getReader();
|
|
57
|
+
const chunks = [];
|
|
58
|
+
for (let size = 0; reader;) {
|
|
59
|
+
const { done, value } = await reader.read();
|
|
60
|
+
if (done)
|
|
61
|
+
break;
|
|
62
|
+
chunks.push(value);
|
|
63
|
+
size += value.byteLength;
|
|
64
|
+
if (size > max) {
|
|
65
|
+
await reader.cancel().catch(() => undefined);
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
70
|
+
}
|
|
71
|
+
/** A JSON-RPC answer's body: JSON, or the `data:` lines of an event stream, the one answering `id`. With `max`, a body
|
|
72
|
+
* past it is "over"; without, its first MAX_BYTES are read. */
|
|
73
|
+
async function answerOf(response, id, max) {
|
|
74
|
+
const text = max === undefined ? await boundedText(response) : await cappedText(response, max);
|
|
75
|
+
if (text === undefined)
|
|
76
|
+
return "over";
|
|
77
|
+
const messages = /event-stream/i.test(response.headers.get("content-type") ?? "")
|
|
78
|
+
? text.split("\n").filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trim())
|
|
79
|
+
: [text];
|
|
80
|
+
for (const message of messages) {
|
|
81
|
+
try {
|
|
82
|
+
const parsed = JSON.parse(message);
|
|
83
|
+
if (parsed.id === id)
|
|
84
|
+
return parsed;
|
|
85
|
+
}
|
|
86
|
+
catch { }
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
/** A tool result's text blocks, joined by lines; empty when it has none. */
|
|
91
|
+
export const textBlocks = (result) => (Array.isArray(result?.content) ? result.content : []).flatMap((part) => (part.type === "text" && typeof part.text === "string" ? [part.text] : [])).join("\n");
|
|
92
|
+
export async function callTool(endpoint, dial, deadline, name, args, maxBytes) {
|
|
93
|
+
let session;
|
|
94
|
+
const post = (body) => dial(endpoint, {
|
|
95
|
+
method: "POST",
|
|
96
|
+
headers: { "content-type": "application/json", accept: ACCEPT, "mcp-protocol-version": PROTOCOL, ...(session ? { "mcp-session-id": session } : {}) },
|
|
97
|
+
body: JSON.stringify({ jsonrpc: "2.0", ...body }),
|
|
98
|
+
signal: deadline,
|
|
99
|
+
});
|
|
100
|
+
const refused = async (response, step) => {
|
|
101
|
+
if (response.ok)
|
|
102
|
+
return undefined;
|
|
103
|
+
await response.body?.cancel().catch(() => undefined);
|
|
104
|
+
const retryAfterS = retryAfterOf(response);
|
|
105
|
+
return { status: response.status, step, ...(retryAfterS === undefined ? {} : { retryAfterS }) };
|
|
106
|
+
};
|
|
107
|
+
const opened = await post({ id: 1, method: "initialize", params: { protocolVersion: PROTOCOL, capabilities: {}, clientInfo: { name: "agentrun-serve", version: "1" } } });
|
|
108
|
+
const failed = await refused(opened, "initialize");
|
|
109
|
+
if (failed)
|
|
110
|
+
return failed;
|
|
111
|
+
session = opened.headers.get("mcp-session-id") ?? undefined;
|
|
112
|
+
const hello = await answerOf(opened, 1);
|
|
113
|
+
if (hello === "over" || !hello?.result)
|
|
114
|
+
return { error: "", rpc: false };
|
|
115
|
+
const ready = await post({ method: "notifications/initialized" });
|
|
116
|
+
await ready.body?.cancel().catch(() => undefined);
|
|
117
|
+
const called = await post({ id: 2, method: "tools/call", params: { name, arguments: args } });
|
|
118
|
+
const late = await refused(called, "the call");
|
|
119
|
+
if (late)
|
|
120
|
+
return late;
|
|
121
|
+
const answer = await answerOf(called, 2, maxBytes);
|
|
122
|
+
if (answer === "over")
|
|
123
|
+
return { over: maxBytes };
|
|
124
|
+
if (answer?.error)
|
|
125
|
+
return { error: typeof answer.error.message === "string" ? answer.error.message : "", rpc: true };
|
|
126
|
+
return { result: answer?.result };
|
|
127
|
+
}
|
package/dist/learn/audit.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Workspace } from "../workspace/index.js";
|
|
|
2
2
|
import type { AuditLoop } from "../learning-setting.js";
|
|
3
3
|
import type { RunLaunch } from "../run-launch.js";
|
|
4
4
|
import { AUDITS_FILE, type FolderChange, type FolderRead } from "./folder.js";
|
|
5
|
-
import { type CostStop, type PromotionRecord, type ServingState } from "./promote.js";
|
|
5
|
+
import { type CostStop, type PromotionRecord, type Refused, type ServingState } from "./promote.js";
|
|
6
6
|
export { AUDITS_FILE };
|
|
7
7
|
/** The newest rows the ledger keeps: twice the widest window a definition may set (AUDIT_MAX), and a file well under the
|
|
8
8
|
* folder's file cap (a line is a few hundred bytes); with them, the started lines of theirs, and every open one. */
|
|
@@ -109,7 +109,7 @@ export declare function auditLineOf(rows: readonly AuditRow[], workflow: string,
|
|
|
109
109
|
/** What the promotions read says of each learned workflow beside what serves (learn/promote.ts servingOf, in its order):
|
|
110
110
|
* `state` (learn/promote.ts servingStateOf with the money rule's decision, `costStop`: the word the learning view's
|
|
111
111
|
* `status` says too), its newest decided check's numbers, and its audit line over the rows of the serving (else the
|
|
112
|
-
* newest) revision's newest promotion (the ones the hold rule counts). */
|
|
112
|
+
* newest) revision's newest promotion (the ones the hold rule counts). Its champions skip `refused` (championOf). */
|
|
113
113
|
export type ServingLine = {
|
|
114
114
|
readonly state: ServingState;
|
|
115
115
|
readonly check: {
|
|
@@ -120,4 +120,4 @@ export type ServingLine = {
|
|
|
120
120
|
} | null;
|
|
121
121
|
readonly audit: AuditLine | null;
|
|
122
122
|
};
|
|
123
|
-
export declare function servingLinesOf(records: readonly PromotionRecord[], rows: readonly AuditRow[], loop: Pick<AuditLoop, "hold_window" | "hold_disagree">, costStop: CostStop): ServingLine[];
|
|
123
|
+
export declare function servingLinesOf(records: readonly PromotionRecord[], rows: readonly AuditRow[], loop: Pick<AuditLoop, "hold_window" | "hold_disagree">, costStop: CostStop, refused?: Refused): ServingLine[];
|
package/dist/learn/audit.js
CHANGED
|
@@ -140,14 +140,14 @@ export function auditLineOf(rows, workflow, digest, promotedAt, loop) {
|
|
|
140
140
|
const counted = windowOf(rows, workflow, digest, promotedAt, loop);
|
|
141
141
|
return { window: loop.hold_window, disagree: loop.hold_disagree, rows: counted.length, disagreed: counted.filter((row) => row.agreed === false).length };
|
|
142
142
|
}
|
|
143
|
-
export function servingLinesOf(records, rows, loop, costStop) {
|
|
144
|
-
return servingOf(records).map(({ workflow, digest }) => {
|
|
143
|
+
export function servingLinesOf(records, rows, loop, costStop, refused) {
|
|
144
|
+
return servingOf(records, refused).map(({ workflow, digest }) => {
|
|
145
145
|
const own = records.filter((one) => one.workflow === workflow);
|
|
146
146
|
const newest = own.at(-1);
|
|
147
147
|
const checked = own.findLast((one) => one.check?.n !== undefined)?.check;
|
|
148
148
|
const at = digest ?? newest?.digest;
|
|
149
149
|
return {
|
|
150
|
-
state: servingStateOf(records, workflow, costStop),
|
|
150
|
+
state: servingStateOf(records, workflow, costStop, refused),
|
|
151
151
|
check: checked ? { n: checked.n, agreed: checked.agreed ?? 0, alone: checked.alone ?? 0, attempt: checked.attempt } : null,
|
|
152
152
|
audit: at === undefined ? null : auditLineOf(rows, workflow, at, promotionStartOf(records, workflow, at)?.at ?? null, loop),
|
|
153
153
|
};
|
package/dist/learn/commit.d.ts
CHANGED
|
@@ -110,14 +110,15 @@ export declare function putCorrections(ws: Workspace, input: {
|
|
|
110
110
|
}>;
|
|
111
111
|
/**
|
|
112
112
|
* Run `runId`'s text taken off the folder's current files, at its purge (agent-delete.ts purgeRun): first its learned
|
|
113
|
-
* workflows (forgetRunWorkflows), whether or not it left a diff file; then the
|
|
114
|
-
* corrections.md, as its diff file keeps them, dropped from main in one host commit
|
|
115
|
-
* since is theirs and stays); each other merge's diff that shows such a line as
|
|
116
|
-
* run's diff files deleted, last, so a call stopped part way finds what it has
|
|
117
|
-
* folder's git history until a learning reset or its agent's purge deletes the
|
|
118
|
-
* lands once, nothing left to drop makes no commit, and a run with no diff file
|
|
113
|
+
* workflows (forgetRunWorkflows; `purged`: whether another run is purged), whether or not it left a diff file; then the
|
|
114
|
+
* lines each of its merges added to corrections.md, as its diff file keeps them, dropped from main in one host commit
|
|
115
|
+
* per merge (a line a person edited since is theirs and stays); each other merge's diff that shows such a line as
|
|
116
|
+
* context written without it; then the run's diff files deleted, last, so a call stopped part way finds what it has
|
|
117
|
+
* left to do. Its merges stay in the folder's git history until a learning reset or its agent's purge deletes the
|
|
118
|
+
* folder. Idempotent: each merge's scrub lands once, nothing left to drop makes no commit, and a run with no diff file
|
|
119
|
+
* and no workflow here is no work.
|
|
119
120
|
* `commit`: the host's last commit, when one was made.
|
|
120
121
|
*/
|
|
121
|
-
export declare function forgetRunText(ws: Workspace, runId: string): Promise<{
|
|
122
|
+
export declare function forgetRunText(ws: Workspace, runId: string, purged: (run: string) => Promise<boolean>): Promise<{
|
|
122
123
|
commit?: string;
|
|
123
124
|
}>;
|