@parcha/agentrun-serve 0.1.0-beta.59 → 0.1.0-beta.61
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 +135 -0
- package/README.md +230 -120
- package/dist/acp-package.d.ts +4 -0
- package/dist/agent-delete.d.ts +6 -9
- package/dist/agent-delete.js +5 -3
- package/dist/agent-package.js +11 -1
- package/dist/api-only.d.ts +21 -3
- package/dist/api-only.js +41 -6
- package/dist/archil-routes.d.ts +4 -1
- package/dist/archil-routes.js +15 -12
- package/dist/archil-settings.d.ts +18 -8
- package/dist/archil-settings.js +35 -17
- package/dist/browser-person.d.ts +1 -1
- package/dist/browser-person.js +1 -1
- package/dist/calendar/tools.js +1 -1
- package/dist/chatgpt-plan.d.ts +4 -2
- package/dist/chatgpt-plan.js +13 -3
- package/dist/claude-login-token.d.ts +5 -0
- package/dist/claude-login-token.js +8 -0
- package/dist/claude-login.d.ts +49 -3
- package/dist/claude-login.js +140 -10
- package/dist/cli-learning/connections.js +1 -1
- package/dist/cli.js +42 -10
- package/dist/console/assets/{backend-BztxEAvb.js → backend-C9ffXUR5.js} +1 -1
- package/dist/console/assets/index-BnZV3lvW.js +639 -0
- package/dist/console/assets/{share-L84tlUDW.js → share-B1o5mJ56.js} +2 -2
- package/dist/console/assets/{styles-CaRKlHke.js → styles-D_znYrHR.js} +31 -31
- package/dist/console/assets/styles-fjQBFfMv.css +1 -0
- package/dist/console/index.html +3 -3
- package/dist/console/share.html +3 -3
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +2 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/factory-activity.d.ts +68 -0
- package/dist/factory-activity.js +153 -0
- package/dist/factory-runs.d.ts +11 -0
- package/dist/factory-runs.js +52 -0
- package/dist/filed-tool.d.ts +32 -0
- package/dist/filed-tool.js +122 -0
- package/dist/harness-check.js +2 -1
- package/dist/harness-keys.d.ts +1 -2
- package/dist/harness-keys.js +1 -2
- package/dist/harness-recipe.d.ts +13 -2
- package/dist/harness-recipe.js +30 -7
- package/dist/harness-sign-in.js +2 -1
- package/dist/harness-table.d.ts +9 -3
- package/dist/harness-table.js +11 -5
- package/dist/harness.js +6 -2
- package/dist/import-worker.js +2 -2
- package/dist/import.d.ts +9 -0
- package/dist/import.js +11 -1
- package/dist/key-refusal.d.ts +5 -0
- package/dist/key-refusal.js +30 -18
- package/dist/learn/audit.d.ts +20 -22
- package/dist/learn/audit.js +72 -55
- package/dist/learn/check.js +1 -1
- package/dist/learn/commit.d.ts +35 -43
- package/dist/learn/commit.js +62 -270
- package/dist/learn/compile.d.ts +4 -4
- package/dist/learn/compile.js +6 -7
- package/dist/learn/corrections.js +1 -1
- package/dist/learn/delete.d.ts +5 -12
- package/dist/learn/delete.js +17 -30
- package/dist/learn/forget-run.d.ts +16 -0
- package/dist/learn/forget-run.js +53 -0
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning-of.d.ts +0 -4
- package/dist/learn/learning-of.js +0 -5
- package/dist/learn/{folder.d.ts → legacy/folder.d.ts} +2 -1
- package/dist/learn/{folder.js → legacy/folder.js} +4 -7
- package/dist/learn/legacy/place.d.ts +16 -0
- package/dist/{workspace/learning-workspace.js → learn/legacy/place.js} +12 -42
- package/dist/learn/legacy/scrub.d.ts +28 -0
- package/dist/learn/legacy/scrub.js +258 -0
- package/dist/learn/promote.d.ts +40 -66
- package/dist/learn/promote.js +69 -207
- package/dist/learn/reset-ledger.d.ts +18 -0
- package/dist/learn/reset-ledger.js +14 -0
- package/dist/learn/rows.d.ts +186 -0
- package/dist/learn/rows.js +376 -0
- package/dist/learn/secrets.d.ts +2 -1
- package/dist/learn/secrets.js +2 -2
- package/dist/learn/workflow-draft.d.ts +4 -1
- package/dist/learn/workflow-draft.js +12 -2
- package/dist/learned-nodes.d.ts +36 -0
- package/dist/learned-nodes.js +23 -0
- package/dist/learning-reset.d.ts +1 -1
- package/dist/learning-reset.js +9 -11
- package/dist/learning-routes.d.ts +60 -81
- package/dist/learning-routes.js +187 -360
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +2 -0
- package/dist/learning.d.ts +18 -24
- package/dist/learning.js +35 -66
- package/dist/local-model.d.ts +144 -0
- package/dist/local-model.js +214 -0
- package/dist/mcp-gateway.d.ts +6 -0
- package/dist/mcp-gateway.js +44 -8
- package/dist/mcp-probe.d.ts +7 -0
- package/dist/mcp-probe.js +7 -0
- package/dist/mcp-resources.d.ts +1 -1
- package/dist/native/discovery.d.ts +6 -0
- package/dist/native/discovery.js +14 -1
- package/dist/native/remote.d.ts +5 -0
- package/dist/native/remote.js +16 -0
- package/dist/native/runtime.js +3 -2
- package/dist/observation/observer.d.ts +6 -6
- package/dist/ollama-provider.d.ts +35 -0
- package/dist/ollama-provider.js +108 -2
- package/dist/openapi.js +147 -35
- package/dist/place-offers.d.ts +3 -0
- package/dist/place-offers.js +3 -0
- package/dist/place.d.ts +35 -12
- package/dist/place.js +67 -29
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +0 -33
- package/dist/purged-workflow.js +3 -71
- package/dist/redact/match.d.ts +36 -8
- package/dist/redact/match.js +179 -44
- package/dist/run-export.js +4 -2
- package/dist/run-launch.d.ts +3 -3
- package/dist/run-learning-served.d.ts +3 -3
- package/dist/run-learning-served.js +1 -1
- package/dist/run-listing.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +6 -5
- package/dist/run-usage.js +3 -2
- package/dist/runnable.js +25 -8
- package/dist/runner/adapter-loop.d.ts +8 -1
- package/dist/runner/adapter-loop.js +100 -20
- package/dist/runner/adapter-run-spec.d.ts +3 -5
- package/dist/runner/adapter-run-spec.js +35 -61
- package/dist/runner/adapters/pi.d.ts +3 -2
- package/dist/runner/adapters/pi.js +3 -1
- package/dist/runner/audit.d.ts +3 -5
- package/dist/runner/audit.js +28 -51
- package/dist/runner/cli-run-spec.js +19 -22
- package/dist/runner/compare-end.d.ts +1 -3
- package/dist/runner/compare-end.js +6 -2
- package/dist/runner/disk-free.d.ts +15 -4
- package/dist/runner/disk-free.js +25 -7
- package/dist/runner/dispatch.js +2 -2
- package/dist/runner/feedback-round.d.ts +1 -1
- package/dist/runner/feedback-round.js +2 -2
- package/dist/runner/harness-loops.d.ts +9 -0
- package/dist/runner/harness-loops.js +49 -7
- package/dist/runner/held.d.ts +4 -11
- package/dist/runner/held.js +0 -25
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +1 -1
- package/dist/runner/learned-first.d.ts +0 -2
- package/dist/runner/learned-first.js +3 -3
- package/dist/runner/learning-end.d.ts +12 -16
- package/dist/runner/learning-end.js +41 -75
- package/dist/runner/learning-seed.d.ts +13 -16
- package/dist/runner/learning-seed.js +13 -23
- package/dist/runner/live-ticker.js +3 -4
- package/dist/runner/main.js +1 -1
- package/dist/runner/mcp-claim.js +3 -2
- package/dist/runner/mcp-run.d.ts +23 -4
- package/dist/runner/mcp-run.js +31 -2
- package/dist/runner/metrics.d.ts +4 -0
- package/dist/runner/metrics.js +9 -3
- package/dist/runner/monid-run.js +3 -1
- package/dist/runner/native-loop.js +3 -4
- package/dist/runner/promotion.d.ts +19 -28
- package/dist/runner/promotion.js +50 -69
- package/dist/runner/redact.d.ts +3 -0
- package/dist/runner/redact.js +7 -0
- package/dist/runner/reflect-hook.d.ts +2 -2
- package/dist/runner/reflect-hook.js +4 -1
- package/dist/runner/run-child-host.d.ts +1 -9
- package/dist/runner/run-child-host.js +12 -68
- package/dist/runner/runner.d.ts +1 -1
- package/dist/runner/sdk-loop.js +7 -7
- package/dist/runner/workflow-calls.d.ts +4 -1
- package/dist/runner/workflow-calls.js +35 -18
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +3 -1
- package/dist/runner/workflow-spec.d.ts +4 -0
- package/dist/runner/workflow-spec.js +18 -13
- package/dist/runs-over-store.d.ts +2 -2
- package/dist/runs-over-store.js +1 -1
- package/dist/sdk/check.d.ts +1 -4
- package/dist/sdk/check.js +2 -3
- package/dist/sdk/runs.d.ts +20 -7
- package/dist/sdk/runs.js +105 -68
- package/dist/secret-cut.js +7 -4
- package/dist/secret-rules.js +97 -83
- package/dist/secrets.d.ts +4 -0
- package/dist/secrets.js +44 -10
- package/dist/server-fs.d.ts +1 -1
- package/dist/server-fs.js +1 -1
- package/dist/server-keys.d.ts +6 -0
- package/dist/server-keys.js +12 -0
- package/dist/server.d.ts +22 -15
- package/dist/server.js +311 -198
- package/dist/slack.js +2 -1
- package/dist/source-sync/auxiliary.js +2 -2
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/migrate.js +3 -1
- package/dist/store/postgres/migrations/0032_learning_rows.sql +65 -0
- package/dist/store/schema.d.ts +28 -2
- package/dist/store/schema.js +81 -5
- package/dist/store/sqlite/learning-rows.d.ts +23 -0
- package/dist/store/sqlite/learning-rows.js +559 -0
- package/dist/store/sqlite/store.d.ts +7 -1
- package/dist/store/sqlite/store.js +84 -18
- package/dist/store/store.d.ts +219 -6
- package/dist/store/store.js +13 -0
- package/dist/store-reads/journal.d.ts +33 -3
- package/dist/store-reads/journal.js +99 -4
- package/dist/store-reads/learning.d.ts +23 -26
- package/dist/store-reads/learning.js +42 -30
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +24 -2
- package/dist/store-view.js +40 -11
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +31 -4
- package/dist/tool-plane.d.ts +27 -3
- package/dist/tool-plane.js +79 -4
- package/dist/tools.d.ts +12 -2
- package/dist/tools.js +42 -7
- package/dist/trigger-launch-hook.d.ts +2 -2
- package/dist/trigger-launch-hook.js +1 -1
- package/dist/triggers.d.ts +7 -4
- package/dist/triggers.js +4 -4
- package/dist/web-holds.d.ts +2 -0
- package/dist/web-holds.js +5 -2
- package/dist/web-run.js +2 -1
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.d.ts +1 -1
- package/dist/workspace/archil.js +1 -1
- package/dist/workspace/computer-deps.js +5 -3
- package/dist/workspace/computer-providers.d.ts +11 -1
- package/dist/workspace/computer-providers.js +29 -2
- package/dist/workspace/index.d.ts +1 -2
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/paths.d.ts +0 -4
- package/dist/workspace/paths.js +0 -6
- package/dist/workspace/workspace.d.ts +1 -1
- package/dist/workspace/workspace.js +1 -1
- package/package.json +13 -13
- package/templates/TOOLS.md +46 -0
- package/dist/console/assets/index-LwNL4L9q.js +0 -619
- package/dist/console/assets/styles-DQo8rzY-.css +0 -1
- package/dist/workspace/learning-workspace.d.ts +0 -24
- /package/dist/learn/{learning.sh → legacy/learning.sh} +0 -0
package/dist/redact/match.js
CHANGED
|
@@ -724,17 +724,33 @@ export function cutAt(text, spans) {
|
|
|
724
724
|
}
|
|
725
725
|
const HEX = only("0123456789abcdefABCDEF");
|
|
726
726
|
const BLANKS = /[\t-\r ]+/y;
|
|
727
|
-
/**
|
|
728
|
-
|
|
727
|
+
/** Whether a UTF-16 unit is a control character that is no whitespace: U+0000-0008, U+000E-001F, U+007F-009F (a NUL,
|
|
728
|
+
* an escape, a delete, a C1 control). It renders as nothing, so the views drop it as they drop whitespace. Tab, line
|
|
729
|
+
* feed, vertical tab, form feed and carriage return (U+0009-000D) are whitespace (isSpace) and read as such. */
|
|
730
|
+
const isControl = (code) => code <= 0x08 || (code >= 0x0e && code <= 0x1f) || (code >= 0x7f && code <= 0x9f);
|
|
731
|
+
/** What ends each pass of a join (joinOf). Every view keeps it, and no needle holds it, so no held value reads across
|
|
732
|
+
* it. It cannot be a NUL, as the views drop control characters wherever they come from (the text, or an escape or an
|
|
733
|
+
* encoding that decodes to one), and a separator they dropped would join the passes. It is U+FFFF, a noncharacter:
|
|
734
|
+
* squeeze, which every plain and joined needle is made with, drops it, and a hex, folded or base64 needle is ASCII.
|
|
735
|
+
* Only the one joinOf puts there separates. One the text brought shows as a box at most, and a reader reads a held
|
|
736
|
+
* value through it, so the views drop it as they drop a control character, as it stands or as a decoder made it, and
|
|
737
|
+
* joinOf reads one in a part's text as a NUL (one character for one, so every offset stays, and dropped too). A
|
|
738
|
+
* caller that marks places in a text with its own (secret-cut.ts) asks holds for `separated`. */
|
|
739
|
+
export const SEPARATOR = "\uffff";
|
|
740
|
+
/** A character that renders as nothing (a zero-width space, a soft hyphen, a byte order mark, a variation selector, a
|
|
741
|
+
* control character that is no whitespace: isControl), and SEPARATOR. */
|
|
742
|
+
const IGNORABLE = /[\p{Default_Ignorable_Code_Point}\u0000-\u0008\u000e-\u001f\u007f-\u009f\uffff]+/gu;
|
|
729
743
|
const GONE = /[\s\p{Default_Ignorable_Code_Point}]+/gu;
|
|
730
744
|
/** Combining marks: an accent, a cedilla, an enclosing circle. */
|
|
731
745
|
const MARKS = /\p{M}+/gu;
|
|
732
746
|
/** `text` as a view reads it, and as a held value's needles are read: decomposed (NFKD), its combining marks dropped,
|
|
733
747
|
* then NFKC, with its whitespace and its characters that render as nothing gone, before (so one between a letter and
|
|
734
748
|
* its accent hides neither) and after. A held value with a zero-width space or a soft hyphen between its characters
|
|
735
|
-
* reads as itself
|
|
749
|
+
* reads as itself, and so does one with a control character between them (a NUL, an escape); so does one with a
|
|
750
|
+
* combining mark after a letter, which NFKC alone composes into another letter
|
|
736
751
|
* ("Z" and U+0301 into "Ź"), and one written with a precomposed letter in place of its own ("Ź" for "Z"). A held
|
|
737
|
-
* value's accents are dropped the same way, so it reads as itself with them or without: more cutting, never less.
|
|
752
|
+
* value's accents are dropped the same way, so it reads as itself with them or without: more cutting, never less.
|
|
753
|
+
* SEPARATOR goes too, so no needle holds it (a join's view keeps it, never squeezing it). */
|
|
738
754
|
export const squeeze = (text) => text.replace(IGNORABLE, "").normalize("NFKD").replace(MARKS, "").normalize("NFKC").replace(GONE, "");
|
|
739
755
|
/** A run of percent-encoded bytes, decoded as UTF-8 (decoded). */
|
|
740
756
|
const PERCENT = {
|
|
@@ -827,6 +843,38 @@ const JSON_ESCAPE_QUOTED = jsonEscape(false);
|
|
|
827
843
|
* two levels JSON_ESCAPE reads make the escaped backslash and what follows it one escape; so does one with a quote of
|
|
828
844
|
* its own, written once. */
|
|
829
845
|
const JSON_ESCAPE_ONCE = jsonEscape(false, 1);
|
|
846
|
+
/** One of Python's own escapes at `at`, as its repr writes a str: an escaped apostrophe ("\'", in a string that holds
|
|
847
|
+
* both quotes) is an apostrophe, "\x" and two hex digits the character they number; with `levels` 2, either written
|
|
848
|
+
* once more as a JSON string's text too ("\\'", "\\x41": a dict a model wrote in a call's arguments, read one level
|
|
849
|
+
* down). The character and where it ends; undefined where none starts. It reads at most five characters. key-refusal.ts's
|
|
850
|
+
* peek counts an escape by it (both levels), so the read past a call's stop counts "\x20" as the views that read
|
|
851
|
+
* Python's escapes do: a space. */
|
|
852
|
+
export function pythonEscapeAt(text, at, levels = 2) {
|
|
853
|
+
if (text[at] !== "\\")
|
|
854
|
+
return undefined;
|
|
855
|
+
scanned.chars += Math.min(5, text.length - at);
|
|
856
|
+
const from = levels === 2 && text[at + 1] === "\\" ? at + 2 : at + 1;
|
|
857
|
+
if (text[from] === "'")
|
|
858
|
+
return { char: "'", end: from + 1 };
|
|
859
|
+
if (text[from] !== "x" || !HEX(text.charCodeAt(from + 1)) || !HEX(text.charCodeAt(from + 2)))
|
|
860
|
+
return undefined;
|
|
861
|
+
return { char: String.fromCharCode(Number.parseInt(text.slice(from + 1, from + 3), 16)), end: from + 3 };
|
|
862
|
+
}
|
|
863
|
+
/** Python's escapes (pythonEscapeAt) at `levels`, and the rest as `json` reads them: a single-quoted dict's strings as
|
|
864
|
+
* its repr wrote them, with one level of JSON's escapes ("\\", "\n", "\u" and four hex digits); and, written in a
|
|
865
|
+
* JSON string, both levels of each ("\\'" and "\\x41", "\\\\" and "\\n"). */
|
|
866
|
+
const pythonEscape = (levels, json) => ({
|
|
867
|
+
trigger: "\\",
|
|
868
|
+
decode(text, at, unit) {
|
|
869
|
+
const found = pythonEscapeAt(text, at, levels);
|
|
870
|
+
if (!found)
|
|
871
|
+
return json.decode(text, at, unit);
|
|
872
|
+
unit(found.char, at, found.end);
|
|
873
|
+
return found.end;
|
|
874
|
+
},
|
|
875
|
+
});
|
|
876
|
+
const PYTHON_ESCAPE = pythonEscape(1, JSON_ESCAPE_ONCE);
|
|
877
|
+
const PYTHON_ESCAPE_TWICE = pythonEscape(2, JSON_ESCAPE_QUOTED);
|
|
830
878
|
/** What JSON_ESCAPE reads at `at`: the character the escape there decodes to, through both levels ("" for an escaped
|
|
831
879
|
* quote, which decodes to nothing), and where it ends; undefined where no escape starts (the "\" is then itself).
|
|
832
880
|
* key-refusal.ts's peek counts an escape by it, so the read past a call's stop and the JSON view see the same
|
|
@@ -839,29 +887,51 @@ export function jsonEscapeAt(text, at) {
|
|
|
839
887
|
return end < 0 ? undefined : { char, end };
|
|
840
888
|
}
|
|
841
889
|
const DECIMAL = only(DIGIT);
|
|
842
|
-
/** The
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
*
|
|
890
|
+
/** The named references a writer's HTML escape emits (and a no-break space), each with its ";". */
|
|
891
|
+
const NAMED = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: "\u00a0", AMP: "&", LT: "<", GT: ">", QUOT: '"' };
|
|
892
|
+
/** The character an HTML character reference at `at` stands for, as a browser reads one in text, and where it ends:
|
|
893
|
+
* - a named one of NAMED, with its ";" ("&" is "&"); it reads at most 6 characters;
|
|
894
|
+
* - a numeric one: "&#" and decimal digits, or "&#x" or "&#X" and hex digits, any zeros first (read as nothing:
|
|
895
|
+
* "A" is "A"), then at most 7 decimal or 6 hex digits, then ";" or not (a browser reads "A" before a letter
|
|
896
|
+
* as "A" too). It reads its zeros and one digit past the most, each once and counted: a run of zeros is read again
|
|
897
|
+
* only by the view that copies it where no reference stands.
|
|
898
|
+
* Undefined where none starts, or it stands for no character (zero, a surrogate, past U+10FFFF, or more digits than
|
|
899
|
+
* that). key-refusal.ts's peek counts a reference by it, so the read past a call's stop and the views see the same
|
|
900
|
+
* characters. */
|
|
846
901
|
export function entityAt(text, at) {
|
|
847
|
-
|
|
848
|
-
|
|
902
|
+
if (text[at] !== "&") {
|
|
903
|
+
scanned.chars++;
|
|
904
|
+
return undefined;
|
|
905
|
+
}
|
|
906
|
+
if (text[at + 1] !== "#") {
|
|
907
|
+
scanned.chars += Math.min(6, text.length - at);
|
|
908
|
+
for (let length = 2; length <= 4; length++) {
|
|
909
|
+
const name = text.slice(at + 1, at + 1 + length);
|
|
910
|
+
if (text[at + 1 + length] === ";" && Object.hasOwn(NAMED, name))
|
|
911
|
+
return { char: NAMED[name], end: at + 2 + length };
|
|
912
|
+
}
|
|
849
913
|
return undefined;
|
|
914
|
+
}
|
|
850
915
|
const hex = text[at + 2] === "x" || text[at + 2] === "X";
|
|
851
916
|
const from = at + (hex ? 3 : 2);
|
|
852
917
|
const digit = hex ? HEX : DECIMAL;
|
|
853
|
-
|
|
854
|
-
|
|
918
|
+
const most = hex ? 6 : 7;
|
|
919
|
+
let start = from;
|
|
920
|
+
while (start < text.length && text.charCodeAt(start) === 48)
|
|
921
|
+
start++;
|
|
922
|
+
let end = start;
|
|
923
|
+
while (end < text.length && end - start <= most && digit(text.charCodeAt(end)))
|
|
855
924
|
end++;
|
|
856
|
-
|
|
925
|
+
scanned.chars += end - at + 1;
|
|
926
|
+
if (end === from || end - start > most)
|
|
857
927
|
return undefined;
|
|
858
|
-
const code = Number.parseInt(text.slice(
|
|
928
|
+
const code = end === start ? 0 : Number.parseInt(text.slice(start, end), hex ? 16 : 10);
|
|
859
929
|
if (code === 0 || (code >= 0xd800 && code <= 0xdfff) || code > 0x10ffff)
|
|
860
930
|
return undefined;
|
|
861
|
-
return { char: String.fromCodePoint(code), end: end + 1 };
|
|
931
|
+
return { char: String.fromCodePoint(code), end: text[end] === ";" ? end + 1 : end };
|
|
862
932
|
}
|
|
863
|
-
/** An HTML
|
|
864
|
-
*
|
|
933
|
+
/** An HTML character reference (entityAt), as the character it stands for (a character past U+FFFF as its two UTF-16
|
|
934
|
+
* units, each from the whole reference). */
|
|
865
935
|
const ENTITY = {
|
|
866
936
|
trigger: "&",
|
|
867
937
|
decode(text, at, unit) {
|
|
@@ -877,15 +947,17 @@ const PERCENT_BYTE = /%[0-9a-fA-F]{2}/;
|
|
|
877
947
|
const JSON_ESCAPED = /\\(?:u[0-9a-fA-F]{4}|["\\/bfnrt])/;
|
|
878
948
|
const QUOTE_ESCAPED = /\\"|\\u00[2]2/;
|
|
879
949
|
const BACKSLASH_ESCAPED = /\\\\|\\u005[cC]/;
|
|
950
|
+
const PYTHON_ESCAPED = /\\(?:'|x[0-9a-fA-F]{2})/;
|
|
951
|
+
const ENTITY_START = /&(?:#|(?:amp|lt|gt|quot|apos|nbsp|AMP|LT|GT|QUOT);)/;
|
|
880
952
|
function familiesOf(text) {
|
|
881
|
-
//
|
|
882
|
-
scanned.chars +=
|
|
883
|
-
return { percent: PERCENT_BYTE.test(text), escape: JSON_ESCAPED.test(text), quoteEscape: QUOTE_ESCAPED.test(text), entity:
|
|
953
|
+
// Nine reads of the text, each to its first find at most.
|
|
954
|
+
scanned.chars += 9 * text.length;
|
|
955
|
+
return { percent: PERCENT_BYTE.test(text), escape: JSON_ESCAPED.test(text), quoteEscape: QUOTE_ESCAPED.test(text), entity: ENTITY_START.test(text), plus: text.includes("+"), quote: text.includes('"'), apostrophe: text.includes("'"), deep: BACKSLASH_ESCAPED.test(text), python: PYTHON_ESCAPED.test(text) };
|
|
884
956
|
}
|
|
885
957
|
const viewSpec = (when, decoders, join) => ({
|
|
886
958
|
when,
|
|
887
959
|
decoders,
|
|
888
|
-
special: new RegExp(`[\\s${decoders.map((decoder) => `\\${decoder.trigger}`).join("")}\\
|
|
960
|
+
special: new RegExp(`[\\s${decoders.map((decoder) => `\\${decoder.trigger}`).join("")}\\u0000-\\u0008\\u000e-\\u001f\\u007f-\\uffff]`, "g"),
|
|
889
961
|
...(join ? { join } : {}),
|
|
890
962
|
});
|
|
891
963
|
/** The views of a text read for each held value, in order:
|
|
@@ -895,19 +967,30 @@ const viewSpec = (when, decoders, join) => ({
|
|
|
895
967
|
* decodes to a backslash (elsewhere the two levels read as one does). Each reads a held value that holds another
|
|
896
968
|
* family's text of its own (a literal "\n", a literal "%41", "A") as itself, which a stacked view decodes, so
|
|
897
969
|
* keeping them keeps every find they made;
|
|
898
|
-
* - stacked: its percent-encoded bytes, JSON's escapes (twice, an escaped quote as nothing) and HTML's
|
|
899
|
-
* references each decoded where it stands, so a value split by an encoded space of one family and an escaped one of
|
|
970
|
+
* - stacked: its percent-encoded bytes, JSON's escapes (twice, an escaped quote as nothing) and HTML's character
|
|
971
|
+
* references (entityAt) each decoded where it stands, so a value split by an encoded space of one family and an escaped one of
|
|
900
972
|
* another, or written half in each, or split by an escaped quote, reads whole; and the same with "+" as a space. Each
|
|
901
973
|
* is read only where it can read otherwise than the one-family views: the text has a character reference, an escaped
|
|
902
974
|
* quote, or both percent-encoding and JSON's escapes (and, with "+", any of JSON's escapes);
|
|
903
975
|
* - for a text with a quote in it, its JSON strings joined (joinOf), each string's contents read again for the strings
|
|
904
|
-
* written in it, decoded as the stacked view;
|
|
976
|
+
* written in it, decoded as the stacked view; and the same with "+" as a space, where the text has a "+" (a "+" after
|
|
977
|
+
* a held value's head with a character reference in it, or in JSON written in a string);
|
|
905
978
|
* - for a text with a quote in it, its JSON strings joined whole, read as the base's check of a web call's strings read
|
|
906
979
|
* them (decoded as JSON.parse decodes them, then through the one-family views): one level of JSON's escapes, an
|
|
907
980
|
* escaped quote a quote, so a held value with a quote of its own reads whole across two strings; the same
|
|
908
981
|
* percent-decoded, and with "+" as a space (a "+" after a held value's head in one string and its rest in the next);
|
|
909
982
|
* and JSON's escapes decoded twice, an escaped quote a quote (only where the text has an escaped backslash: otherwise
|
|
910
|
-
* it reads as the first). Each is read only where the text holds what it decodes
|
|
983
|
+
* it reads as the first). Each is read only where the text holds what it decodes;
|
|
984
|
+
* - for a text with an apostrophe in it, its strings joined whole with an apostrophe opening one too (a Python repr's
|
|
985
|
+
* single-quoted dict), one level of JSON's escapes decoded, followed by the again join (the text of each value
|
|
986
|
+
* written in quotes, read as the quoted join one level down: a dict written in a JSON string, a call's arguments)
|
|
987
|
+
* read the same way (a backslash of the dict's own, written once). A view of its own, so the views before it read an
|
|
988
|
+
* apostrophe outside a "..." string as they did; and the quoted join alone decoded through Python's escapes, where
|
|
989
|
+
* the text holds one ("\'" in a string with both quotes, "\x41"), beside it, so a backslash read as itself there
|
|
990
|
+
* still is; and, where the text holds a quote too, the again join alone through both levels of Python's escapes and
|
|
991
|
+
* of JSON's ("\\'", "\\x41", "\\t", "\"", or none). Neither level's parts are read beside the other's, so no held
|
|
992
|
+
* value reads across the two. The quoted join is never read through two levels: in a dict escaped once with no JSON
|
|
993
|
+
* string around it, "\\t" is a backslash and a "t", and a tab there would be a second decode, not a find.
|
|
911
994
|
* The decoders of a view decode in one pass: each reads at its own trigger character, so a view costs one read of the
|
|
912
995
|
* text whatever it decodes. Each view is lowered for hexes and flattened for folded identifiers in holds. */
|
|
913
996
|
const VIEWS = [
|
|
@@ -919,10 +1002,14 @@ const VIEWS = [
|
|
|
919
1002
|
viewSpec((has) => has.entity || has.quoteEscape || (has.percent && has.escape), [PERCENT, JSON_ESCAPE, ENTITY]),
|
|
920
1003
|
viewSpec((has) => has.plus && (has.entity || has.escape), [PERCENT, PLUS, JSON_ESCAPE, ENTITY]),
|
|
921
1004
|
viewSpec((has) => has.quote, [PERCENT, JSON_ESCAPE, ENTITY], "nested"),
|
|
1005
|
+
viewSpec((has) => has.quote && has.plus, [PERCENT, PLUS, JSON_ESCAPE, ENTITY], "nested"),
|
|
922
1006
|
viewSpec((has) => has.quote, [JSON_ESCAPE_ONCE], "strings"),
|
|
923
1007
|
viewSpec((has) => has.quote && has.percent, [PERCENT, JSON_ESCAPE_ONCE], "strings"),
|
|
924
1008
|
viewSpec((has) => has.quote && has.plus, [PERCENT, PLUS, JSON_ESCAPE_ONCE], "strings"),
|
|
925
1009
|
viewSpec((has) => has.quote && has.deep, [JSON_ESCAPE_QUOTED], "strings"),
|
|
1010
|
+
viewSpec((has) => has.apostrophe, [JSON_ESCAPE_ONCE], "both"),
|
|
1011
|
+
viewSpec((has) => has.apostrophe && has.python, [PYTHON_ESCAPE], "quoted"),
|
|
1012
|
+
viewSpec((has) => has.apostrophe && has.quote, [PYTHON_ESCAPE_TWICE], "again"),
|
|
926
1013
|
];
|
|
927
1014
|
/** JSON's punctuation between its values. */
|
|
928
1015
|
const STRUCTURE = only("{}[],:");
|
|
@@ -950,10 +1037,12 @@ function unitAt(text, at, to, level) {
|
|
|
950
1037
|
* (a string the next character after whitespace of which is ":") whole; a value's, at level 0 with `nested`, read again
|
|
951
1038
|
* at level 1 for the strings written in it (JSON in a string), each of its parts added in its place, and else whole; and
|
|
952
1039
|
* each run of characters outside a string that are neither whitespace nor JSON's punctuation. A string with no closing
|
|
953
|
-
* quote runs to `to`. Any text is read so, JSON or not: a quote in prose opens a string as one in JSON does.
|
|
954
|
-
*
|
|
955
|
-
* "
|
|
956
|
-
|
|
1040
|
+
* quote runs to `to`. Any text is read so, JSON or not: a quote in prose opens a string as one in JSON does. With
|
|
1041
|
+
* `quoted`, an apostrophe opens a string too, closed by the next apostrophe (a quote inside it is text, as an
|
|
1042
|
+
* apostrophe inside a "..." string is), and at level 0, with `written`, the span of each value written in quotes is added
|
|
1043
|
+
* to it (the again join reads it one level down). Each character is read at most three times (at level 0, at level 1,
|
|
1044
|
+
* and in the whitespace after a string looking for a ":"). */
|
|
1045
|
+
function partsOf(text, from, to, level, out, kind = "nested", written) {
|
|
957
1046
|
let bare = -1;
|
|
958
1047
|
const endBare = (end) => {
|
|
959
1048
|
if (bare >= 0)
|
|
@@ -963,7 +1052,7 @@ function partsOf(text, from, to, level, out, nested = true) {
|
|
|
963
1052
|
for (let at = from; at < to;) {
|
|
964
1053
|
const { char, end } = unitAt(text, at, to, level);
|
|
965
1054
|
const code = char.charCodeAt(0);
|
|
966
|
-
if (char !== '"') {
|
|
1055
|
+
if (char !== '"' && !(kind === "quoted" && char === "'")) {
|
|
967
1056
|
if (isSpace(code) || STRUCTURE(code))
|
|
968
1057
|
endBare(at);
|
|
969
1058
|
else if (bare < 0)
|
|
@@ -976,7 +1065,7 @@ function partsOf(text, from, to, level, out, nested = true) {
|
|
|
976
1065
|
let close = end;
|
|
977
1066
|
while (close < to) {
|
|
978
1067
|
const inner = unitAt(text, close, to, level);
|
|
979
|
-
if (inner.char ===
|
|
1068
|
+
if (inner.char === char)
|
|
980
1069
|
break;
|
|
981
1070
|
close = inner.char === "\\" && inner.end < to ? unitAt(text, inner.end, to, level).end : inner.end;
|
|
982
1071
|
}
|
|
@@ -994,18 +1083,21 @@ function partsOf(text, from, to, level, out, nested = true) {
|
|
|
994
1083
|
}
|
|
995
1084
|
if (next === ":")
|
|
996
1085
|
out.push({ from: end, to: close, name: true });
|
|
997
|
-
else if (level === 0 && nested)
|
|
1086
|
+
else if (level === 0 && kind === "nested")
|
|
998
1087
|
partsOf(text, end, close, 1, out);
|
|
999
|
-
else
|
|
1088
|
+
else {
|
|
1000
1089
|
out.push({ from: end, to: close, name: false });
|
|
1090
|
+
if (level === 0 && char === '"')
|
|
1091
|
+
written?.push([end, close]);
|
|
1092
|
+
}
|
|
1001
1093
|
at = after;
|
|
1002
1094
|
}
|
|
1003
1095
|
endBare(to);
|
|
1004
1096
|
}
|
|
1005
1097
|
/** `text`'s join of `kind` (JoinKind): its parts (partsOf) read three times over, each time joined, each part followed by a space (gone
|
|
1006
1098
|
* from the view, and no escape reads past it): the values and the runs outside strings; the property names; then all
|
|
1007
|
-
* of them. Each pass is closed by
|
|
1008
|
-
* passes. A held value split across two values with a name between them ({"title":"see <H>","snippet":"<R> more"}),
|
|
1099
|
+
* of them. Each pass is closed by SEPARATOR, which a view of a join keeps and no needle holds, so no value reads across
|
|
1100
|
+
* two passes (holds reads a U+FFFF the text brought as a NUL first, so it is the only one). A held value split across two values with a name between them ({"title":"see <H>","snippet":"<R> more"}),
|
|
1009
1101
|
* across two names, across a name and its value, across a quote of JSON written in a string, or across a string and
|
|
1010
1102
|
* the line after the JSON reads whole in one of them. A view decodes and squeezes the join as any text (viewOf), each
|
|
1011
1103
|
* part's characters keeping their source: with `cuts` (merged spans of `text`), the spans of each part a cut covers
|
|
@@ -1014,7 +1106,15 @@ function partsOf(text, from, to, level, out, nested = true) {
|
|
|
1014
1106
|
* join is the same for every view that reads it: holds builds each kind once per text. */
|
|
1015
1107
|
function joinOf(text, kind, cuts) {
|
|
1016
1108
|
const parts = [];
|
|
1017
|
-
|
|
1109
|
+
if (kind === "again") {
|
|
1110
|
+
// The quoted join's values written in quotes, each read one level down, in the text's order.
|
|
1111
|
+
const written = [];
|
|
1112
|
+
partsOf(text, 0, text.length, 0, [], "quoted", written);
|
|
1113
|
+
for (const [start, end] of written)
|
|
1114
|
+
partsOf(text, start, end, 1, parts, "quoted");
|
|
1115
|
+
}
|
|
1116
|
+
else
|
|
1117
|
+
partsOf(text, 0, text.length, 0, parts, kind);
|
|
1018
1118
|
const pieces = [];
|
|
1019
1119
|
const moved = [];
|
|
1020
1120
|
let length = 0;
|
|
@@ -1041,19 +1141,31 @@ function joinOf(text, kind, cuts) {
|
|
|
1041
1141
|
pieces.push(text.slice(part.from, part.to), " ");
|
|
1042
1142
|
length += part.to - part.from + 1;
|
|
1043
1143
|
}
|
|
1044
|
-
pieces.push(
|
|
1144
|
+
pieces.push(SEPARATOR);
|
|
1045
1145
|
length++;
|
|
1046
1146
|
}
|
|
1047
1147
|
// The join written once.
|
|
1048
1148
|
scanned.chars += length;
|
|
1049
1149
|
return { text: pieces.join(""), ...(cuts ? { cuts: moved } : {}) };
|
|
1050
1150
|
}
|
|
1151
|
+
/** Two joins one after the other (JoinKind `both`), the second's cuts moved past the first; written once. */
|
|
1152
|
+
function bothOf(first, second) {
|
|
1153
|
+
const text = first.text + second.text;
|
|
1154
|
+
scanned.chars += text.length;
|
|
1155
|
+
if (!first.cuts || !second.cuts)
|
|
1156
|
+
return { text };
|
|
1157
|
+
const at = first.text.length;
|
|
1158
|
+
return { text, cuts: [...first.cuts, ...second.cuts.map(([start, end]) => [at + start, at + end])] };
|
|
1159
|
+
}
|
|
1051
1160
|
/** `text` as the whole-text check reads it: decoded by `spec`'s decoders, then squeezed (squeeze: NFKC, its whitespace
|
|
1052
1161
|
* and its characters that render as nothing gone), as a held value's needles are. The squeeze is applied to each
|
|
1053
1162
|
* stretch of non-ASCII characters with the ASCII character before it, which gives what it gives over the whole text (an
|
|
1054
|
-
* ASCII character is a starter nothing composes onto), and each character it makes comes from that whole stretch.
|
|
1163
|
+
* ASCII character is a starter nothing composes onto), and each character it makes comes from that whole stretch. A
|
|
1164
|
+
* control character (isControl) is dropped, as it stands or as a decoder made it, and so is SEPARATOR, unless
|
|
1165
|
+
* `separates` and it stands in the text as it is (a join's own, or a caller's: holds), where it is copied, never
|
|
1166
|
+
* squeezed. With `cuts` (merged spans of `text`), the view's
|
|
1055
1167
|
* covered stretches: where every character comes from inside one cut. */
|
|
1056
|
-
function viewOf(text, spec, cuts) {
|
|
1168
|
+
function viewOf(text, spec, cuts, separates = false) {
|
|
1057
1169
|
const out = [];
|
|
1058
1170
|
const covered = [];
|
|
1059
1171
|
let length = 0;
|
|
@@ -1129,7 +1241,12 @@ function viewOf(text, spec, cuts) {
|
|
|
1129
1241
|
group = undefined;
|
|
1130
1242
|
};
|
|
1131
1243
|
const unit = (char, from, to) => {
|
|
1132
|
-
|
|
1244
|
+
const code = char.charCodeAt(0);
|
|
1245
|
+
// A control character, or SEPARATOR, as it stands or decoded, is nothing: dropped before anything is flushed, so
|
|
1246
|
+
// the characters either side of it compose as they would with it gone (as squeeze drops it before NFKD).
|
|
1247
|
+
if (isControl(code) || char === SEPARATOR)
|
|
1248
|
+
return;
|
|
1249
|
+
if (code >= 128) {
|
|
1133
1250
|
if (group) {
|
|
1134
1251
|
group.chars += char;
|
|
1135
1252
|
group.to = to;
|
|
@@ -1178,6 +1295,13 @@ function viewOf(text, spec, cuts) {
|
|
|
1178
1295
|
held = { char: text[BLANKS.lastIndex - 1], from: BLANKS.lastIndex - 1, to: BLANKS.lastIndex };
|
|
1179
1296
|
at = BLANKS.lastIndex;
|
|
1180
1297
|
}
|
|
1298
|
+
else if (separates && char === SEPARATOR) {
|
|
1299
|
+
// A separator as it stands is copied, never squeezed, and nothing composes across it.
|
|
1300
|
+
flushGroup();
|
|
1301
|
+
flushHeld();
|
|
1302
|
+
emit(char, stop, stop + 1);
|
|
1303
|
+
at = stop + 1;
|
|
1304
|
+
}
|
|
1181
1305
|
else {
|
|
1182
1306
|
unit(char, stop, stop + 1);
|
|
1183
1307
|
at = stop + 1;
|
|
@@ -1289,24 +1413,35 @@ function holdsIn(view, covered, needles) {
|
|
|
1289
1413
|
* form encoded, an NFKC variant, its hex in any case, a hex identifier folded (`fold`), split across two strings of a
|
|
1290
1414
|
* JSON text (joinOf; a "+" after its head or a quote of its own in it too), or split there at its own "," or ":"
|
|
1291
1415
|
* (`joined`). With `cuts`, a value whose every character the view read comes from inside the cuts is not held: it is
|
|
1292
|
-
* cut in place.
|
|
1293
|
-
|
|
1416
|
+
* cut in place. A U+FFFF in `text` is nothing to the views (SEPARATOR); with `separated`, each one is the caller's
|
|
1417
|
+
* mark and separates there in every view. */
|
|
1418
|
+
export function holds(text, needles, { fold = true, cuts, separated = false } = {}) {
|
|
1294
1419
|
const folds = fold ? needles.folds : [];
|
|
1295
1420
|
if (!needles.plain.length && !needles.hexes.length && !folds.length)
|
|
1296
1421
|
return false;
|
|
1297
1422
|
const has = familiesOf(text);
|
|
1423
|
+
// What the joins read: the text with each U+FFFF it brought read as a NUL (SEPARATOR), so the only one in a join is
|
|
1424
|
+
// the one joinOf puts after each pass; with `separated`, the text as it is. Read once, on the first join.
|
|
1425
|
+
let source;
|
|
1426
|
+
const joinText = () => {
|
|
1427
|
+
if (source === undefined) {
|
|
1428
|
+
scanned.chars += text.length;
|
|
1429
|
+
source = !separated && text.includes(SEPARATOR) ? text.replaceAll(SEPARATOR, "\u0000") : text;
|
|
1430
|
+
}
|
|
1431
|
+
return source;
|
|
1432
|
+
};
|
|
1298
1433
|
const joins = new Map();
|
|
1299
1434
|
const joinFor = (kind) => {
|
|
1300
1435
|
let join = joins.get(kind);
|
|
1301
1436
|
if (!join)
|
|
1302
|
-
joins.set(kind, (join = joinOf(
|
|
1437
|
+
joins.set(kind, (join = kind === "both" ? bothOf(joinFor("quoted"), joinFor("again")) : joinOf(joinText(), kind, cuts)));
|
|
1303
1438
|
return join;
|
|
1304
1439
|
};
|
|
1305
1440
|
for (const spec of VIEWS) {
|
|
1306
1441
|
if (!spec.when(has))
|
|
1307
1442
|
continue;
|
|
1308
1443
|
const join = spec.join ? joinFor(spec.join) : undefined;
|
|
1309
|
-
const view = join ? viewOf(join.text, spec, join.cuts) : viewOf(text, spec, cuts);
|
|
1444
|
+
const view = join ? viewOf(join.text, spec, join.cuts, true) : viewOf(text, spec, cuts, separated);
|
|
1310
1445
|
const covered = cuts ? view.covered : undefined;
|
|
1311
1446
|
if (holdsIn(view.text, covered, needles.plain))
|
|
1312
1447
|
return true;
|
package/dist/run-export.js
CHANGED
|
@@ -147,7 +147,9 @@ export async function exportBundle(input) {
|
|
|
147
147
|
// before the scrubber reads them: a held value the scrubber's own reading misses (wrapped over line breaks, re-encoded)
|
|
148
148
|
// is withheld there. A census-cut run carries no file at all (filesOf), so no census applies here.
|
|
149
149
|
const listed = await filesOf(input.files, input.filesTruncated, input.filesUncounted === true, caps);
|
|
150
|
-
|
|
150
|
+
// `source` is the path as the run wrote it, never written into the bundle: the scrubber reads a file's content knowing
|
|
151
|
+
// it (a `.env.<held value>` file is still an env file, cut whole), and the bundle carries the cut path alone.
|
|
152
|
+
const carried = listed.carried.map((file) => ({ path: cutFileText(file.path, input.held), source: file.path, content: cutFileText(file.content, input.held) }));
|
|
151
153
|
const omitted = listed.omitted.map((one) => (one.what === "file" ? { ...one, path: cutFileText(one.path, input.held) } : one));
|
|
152
154
|
const kind = String(input.view.kind);
|
|
153
155
|
// What is cut: everything that came from the run. The format and source are this server's own words.
|
|
@@ -244,7 +246,7 @@ export async function exportBundle(input) {
|
|
|
244
246
|
const cutFile = async (file, index, restoring) => {
|
|
245
247
|
const before = { cuts: cuts.length, restored: restored.length, seen: new Set(seen.keys()) };
|
|
246
248
|
const path = await cutString(file.path, `/files/${index}/path`, undefined, restoring);
|
|
247
|
-
const content = await cutString(file.content, `/files/${index}/content`, { path: file.
|
|
249
|
+
const content = await cutString(file.content, `/files/${index}/content`, { path: file.source }, restoring);
|
|
248
250
|
const undo = () => {
|
|
249
251
|
cuts.splice(before.cuts);
|
|
250
252
|
restored.splice(before.restored);
|
package/dist/run-launch.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export interface RunLaunch {
|
|
|
69
69
|
* The control marker is outside the run's tool workspace. No source path or credential is kept in this record. */
|
|
70
70
|
readonly sourceProject?: SourceProjectLaunch;
|
|
71
71
|
/** The run's learning start, when its agent learns and the server's learning is on, decided once here so the runner reads
|
|
72
|
-
* no learning
|
|
72
|
+
* no learning rows: `seed`, the learning save's id (or null when the seed could not be read); `section`,
|
|
73
73
|
* the exact # Learned text to lay into the prompt (its owner's corrections, learning.ts learnedSection); `workflows`,
|
|
74
74
|
* the names of the learned workflows the seed offers the run (chooseWorkflows), absent when none; `noWorkflows`, a run
|
|
75
75
|
* never answered by a learned workflow and asked for no workflow draft at its end (a native run, an SDK run with no
|
|
@@ -172,9 +172,9 @@ export declare function readLaunchBody(stored: unknown): RunLaunch | undefined;
|
|
|
172
172
|
export declare const learningStartOf: (launch: RunLaunch) => RunLaunch["learning"];
|
|
173
173
|
/** The same start read from a launch body's `learning` member alone (Store.runs.learningStarts), as readLaunchBody reads it. */
|
|
174
174
|
export declare const learningStartOfStored: (stored: unknown) => RunLaunch["learning"];
|
|
175
|
-
/** Why a learning run starts with nothing learned, as main says it: its agent's learning
|
|
175
|
+
/** Why a learning run starts with nothing learned, as main says it: its agent's learning could not be read
|
|
176
176
|
* (`unreadable`, STOPPED.unreadable), what was read could not be made into its start (`not_copied`,
|
|
177
|
-
* STOPPED.notCopied), or its launch names a disk of its own, whose learning
|
|
177
|
+
* STOPPED.notCopied), or its launch names a disk of its own, whose learning the server does not read
|
|
178
178
|
* (`other_disk`, STOPPED.otherDisk): a run on a named disk learns nothing (learn/learning-of.ts). */
|
|
179
179
|
export type SeedFailed = "unreadable" | "not_copied" | "other_disk";
|
|
180
180
|
/** A learning start with no seed (no commit of main, runs-over-store.ts learningStartFor): the run learns nothing, is
|
|
@@ -10,7 +10,7 @@ export declare function servedRunLearning(deps: {
|
|
|
10
10
|
}, store: Store, runId: string): Promise<{
|
|
11
11
|
run: string;
|
|
12
12
|
state: "dropped" | "merged" | "seeded" | "reflecting";
|
|
13
|
-
reason: "cancelled" | "reset" | "
|
|
13
|
+
reason: "cancelled" | "reset" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_failed" | "empty" | "checker" | "use" | "purged_since_seed" | null;
|
|
14
14
|
detail: string | null;
|
|
15
15
|
at: string;
|
|
16
16
|
workflows: import("./learning.js").LearnedFile[];
|
|
@@ -53,7 +53,7 @@ export declare function servedRunLearning(deps: {
|
|
|
53
53
|
};
|
|
54
54
|
run: string;
|
|
55
55
|
state: "dropped" | "merged" | "seeded" | "reflecting";
|
|
56
|
-
reason: "cancelled" | "reset" | "
|
|
56
|
+
reason: "cancelled" | "reset" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_failed" | "empty" | "checker" | "use" | "purged_since_seed" | null;
|
|
57
57
|
detail: string | null;
|
|
58
58
|
at: string;
|
|
59
59
|
workflows: import("./learning.js").LearnedFile[];
|
|
@@ -90,7 +90,7 @@ export declare function servedRunDiff(deps: {
|
|
|
90
90
|
signIns?: SignInReader;
|
|
91
91
|
sealKey: Buffer | undefined;
|
|
92
92
|
}, store: Store, data: string, runId: string): Promise<{
|
|
93
|
-
base: string;
|
|
93
|
+
base: string | null;
|
|
94
94
|
head: string;
|
|
95
95
|
files: ({
|
|
96
96
|
path: string;
|
|
@@ -31,5 +31,5 @@ export async function servedRunLearning(deps, store, runId) {
|
|
|
31
31
|
/** Run `runId`'s learning diff as GET /runs/{id}/learning/diff serves it (learning-routes.ts runDiffOverStore), cut as its
|
|
32
32
|
* learning is, or ApiError forbidden for a withheld run. */
|
|
33
33
|
export async function servedRunDiff(deps, store, data, runId) {
|
|
34
|
-
return runDiffOverStore(
|
|
34
|
+
return runDiffOverStore(store, runId, secretsShown(await learningCutOf(deps, store, runId)));
|
|
35
35
|
}
|
package/dist/run-listing.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface Lister {
|
|
|
19
19
|
/** The server's keys or settings changed: every failed run's listing (its error words) is marked behind before this
|
|
20
20
|
* resolves, so the next list builds it again. */
|
|
21
21
|
keysChanged(): Promise<void>;
|
|
22
|
-
/** A person changed agent `agentId`'s learning
|
|
22
|
+
/** A person changed agent `agentId`'s learning (a workflow approved, retired or restored): each of its runs
|
|
23
23
|
* whose listing read a workflow held for the owner's OK is marked behind before this resolves, so the next list says what
|
|
24
24
|
* the folder says now. A change made outside the server is read by the next pass. */
|
|
25
25
|
learningChanged(agentId: string): Promise<void>;
|
|
@@ -10,7 +10,7 @@ export type ServedTimelineDeps = {
|
|
|
10
10
|
readonly sealKey: Buffer | undefined;
|
|
11
11
|
/** The environment a run's model key is read from, with the keys a person saved (withSecrets, as main's plainKey). */
|
|
12
12
|
readonly keyEnv: () => NodeJS.ProcessEnv;
|
|
13
|
-
/** Each learned item's status on an agent's learning
|
|
13
|
+
/** Each learned item's status on an agent's newest learning save (learning-routes.ts statusesOf): what a run held for
|
|
14
14
|
* its owner's OK reads as it stands there. None: as the merge wrote it. */
|
|
15
15
|
readonly statuses?: (agentId: string) => Promise<ReadonlyMap<string, ItemStatus> | undefined>;
|
|
16
16
|
};
|
|
@@ -3,7 +3,7 @@ import { withDecisions } from "./decision-rows.js";
|
|
|
3
3
|
import { currentLearning, holdsForOk, secretsShown } from "./learning.js";
|
|
4
4
|
import { withLearning } from "./learning-run.js";
|
|
5
5
|
import { runLearningEnd } from "./store-reads/learning.js";
|
|
6
|
-
import { heldNumber,
|
|
6
|
+
import { heldNumber, redactedCall } from "./key-refusal.js";
|
|
7
7
|
import { runCutValues, runErrorWordsOf, underCut } from "./run-cut.js";
|
|
8
8
|
import { answersOf, asksOf, shownOf, stopAsked, withApprovalRows, withAsks, withBudgetRows, withOverCap } from "./run-view.js";
|
|
9
9
|
import { launchOf } from "./handed-values.js";
|
|
@@ -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, servedSince, wholeAnswerFor, wholeAnswers } from "./store-reads/journal.js";
|
|
14
|
+
import { rowCutsOnce, 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 whole to
|
|
@@ -27,7 +27,8 @@ export async function servedTimelineRows(deps, store, runId, context, calls = fa
|
|
|
27
27
|
if (cut === "unreadable")
|
|
28
28
|
return undefined;
|
|
29
29
|
const { values } = cut;
|
|
30
|
-
|
|
30
|
+
// Each text cut once per held value set (rowCutsOnce): a reader that follows the run cuts only what an earlier read had not.
|
|
31
|
+
const { redact, holds } = rowCutsOnce(store, runId, cut, since);
|
|
31
32
|
return { values, redact, ...(await store.snapshot(async (snapshot) => {
|
|
32
33
|
// The rows a person reads: each call that waited for approval in order (held, your approval, what came of it), its
|
|
33
34
|
// arguments and the person's notes through the cut (run-view.ts withApprovalRows), as main's served Timeline read them.
|
|
@@ -50,7 +51,7 @@ export async function servedTimelineRows(deps, store, runId, context, calls = fa
|
|
|
50
51
|
: stopAsked(view, run, await snapshot.commands(runId, 0)) ? "stopped" : undefined;
|
|
51
52
|
// A call's arguments, or a web call's output, split across two strings are withheld whole in every read, with calls
|
|
52
53
|
// or without (TimelineOptions.holds).
|
|
53
|
-
const options = { redact, holds
|
|
54
|
+
const options = { redact, holds, settled: ended, ended: view ? view.state !== "running" : false, ...(calls ? { calls: { result: CALL_RESULT_CHARS, redact: (text) => redactedCall(text, values, CALL_RESULT_CHARS, scrubUrls), input: (text, shown) => redactedCall(text, values, shown), held: (value) => heldNumber(value, values) } } : {}) };
|
|
54
55
|
const timeline = await wholeAnswers(snapshot, runId, context, await runTimeline(snapshot, runId, context, options), options, wholeAnswerFor(values), since);
|
|
55
56
|
// A run whose booked spend passed its cap says so, by how much, after its usage row (run-view.ts withOverCap, as main's
|
|
56
57
|
// served Timeline did): at the cap as it stands (a raise taken counts, capNowOf).
|
|
@@ -62,7 +63,7 @@ export async function servedTimelineRows(deps, store, runId, context, calls = fa
|
|
|
62
63
|
// A workflow's decisions: their rows among the model nodes' by time, each text shown through the cut set, with as many
|
|
63
64
|
// characters held back from a text stored cut as a held value takes in its widest form (main's decisionShown).
|
|
64
65
|
const receipts = await decisionsOverStore(snapshot, runId, context).catch(() => null);
|
|
65
|
-
const decisionShown = { redact
|
|
66
|
+
const decisionShown = { redact, hold: 6 * values.reduce((most, value) => Math.max(most, value.length), 0) + 16 };
|
|
66
67
|
const own = receipts === null || receipts.length ? withDecisions(rows, receipts, decisionShown, { ended }) : rows;
|
|
67
68
|
// The run's learning end, once its learning merged or dropped (runLearningEnd).
|
|
68
69
|
const end = await runLearningEnd(snapshot, runId);
|
package/dist/run-usage.js
CHANGED
|
@@ -350,7 +350,8 @@ const RESOURCE_ORDER = { vcpu: 0, memory: 1, gpu: 2, disk: 3 };
|
|
|
350
350
|
const micro = (value) => Math.round(value * 1e6) / 1e6;
|
|
351
351
|
/** The run's `compute_time` lines: one per provider and resource of the computers it made (`rows`), each second of each at
|
|
352
352
|
* its figure, an open one's up to `at` (the read), and the part no claim held (its life less its booked time) apart in
|
|
353
|
-
* `unheld_quantity
|
|
353
|
+
* `unheld_quantity` (0 for a provider that bills nothing: none of its time costs anything, booked or not, so none is
|
|
354
|
+
* outside the run's cost). Its money is what the run's ledger booked for it (`booked`, by computeKey): `estimate` when any was;
|
|
354
355
|
* $0 for a provider that bills nothing; else `unpriced`, its usd null. A figure no one said makes its quantity null. */
|
|
355
356
|
function computeLinesOf(rows, at, booked, spans) {
|
|
356
357
|
const sums = new Map();
|
|
@@ -395,7 +396,7 @@ function computeLinesOf(rows, at, booked, spans) {
|
|
|
395
396
|
return {
|
|
396
397
|
meter: "compute_time", model: null, provider: sum.provider, charged_by: sum.provider,
|
|
397
398
|
quantity: sum.quantity === null ? null : micro(sum.quantity), unit: COMPUTE_UNITS[sum.resource], basis: charged || free ? "estimate" : "unpriced", ...sum.at, ...words,
|
|
398
|
-
resource: sum.resource, gpu_type: sum.gpuType, unheld_quantity: sum.unheld === null ? null : micro(sum.unheld), open_computers: sum.open,
|
|
399
|
+
resource: sum.resource, gpu_type: sum.gpuType, unheld_quantity: unmetered(sum.provider) ? 0 : sum.unheld === null ? null : micro(sum.unheld), open_computers: sum.open,
|
|
399
400
|
...(sum.open > 0 ? { measured_to: new Date(at).toISOString() } : {}),
|
|
400
401
|
};
|
|
401
402
|
});
|