@parcha/agentrun-serve 0.1.0-beta.60 → 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.
Files changed (93) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +42 -14
  3. package/dist/acp-package.d.ts +4 -0
  4. package/dist/api-only.d.ts +19 -1
  5. package/dist/api-only.js +38 -3
  6. package/dist/browser-person.d.ts +1 -1
  7. package/dist/browser-person.js +1 -1
  8. package/dist/calendar/tools.js +1 -1
  9. package/dist/cli.js +42 -10
  10. package/dist/console/assets/{backend-QnwGVBeU.js → backend-C9ffXUR5.js} +1 -1
  11. package/dist/console/assets/index-BnZV3lvW.js +639 -0
  12. package/dist/console/assets/{share-pz61zIn9.js → share-B1o5mJ56.js} +2 -2
  13. package/dist/console/assets/{styles-CcceGcu2.js → styles-D_znYrHR.js} +2 -2
  14. package/dist/console/index.html +2 -2
  15. package/dist/console/share.html +2 -2
  16. package/dist/errors.d.ts +1 -0
  17. package/dist/errors.js +2 -0
  18. package/dist/harness-check.js +2 -1
  19. package/dist/harness-recipe.d.ts +13 -2
  20. package/dist/harness-recipe.js +30 -7
  21. package/dist/harness-sign-in.js +2 -1
  22. package/dist/harness-table.d.ts +5 -3
  23. package/dist/harness-table.js +7 -5
  24. package/dist/key-refusal.js +6 -4
  25. package/dist/learn/secrets.d.ts +2 -1
  26. package/dist/learn/secrets.js +2 -2
  27. package/dist/learned-nodes.d.ts +36 -0
  28. package/dist/learned-nodes.js +23 -0
  29. package/dist/local-model.d.ts +144 -0
  30. package/dist/local-model.js +214 -0
  31. package/dist/mcp-probe.d.ts +7 -0
  32. package/dist/mcp-probe.js +7 -0
  33. package/dist/ollama-provider.d.ts +35 -0
  34. package/dist/ollama-provider.js +108 -2
  35. package/dist/openapi.js +59 -7
  36. package/dist/place.d.ts +7 -6
  37. package/dist/place.js +13 -10
  38. package/dist/print.js +1 -1
  39. package/dist/redact/match.d.ts +17 -4
  40. package/dist/redact/match.js +57 -15
  41. package/dist/run-export.js +4 -2
  42. package/dist/run-usage.js +3 -2
  43. package/dist/runner/adapter-loop.d.ts +8 -1
  44. package/dist/runner/adapter-loop.js +100 -20
  45. package/dist/runner/adapter-run-spec.d.ts +3 -5
  46. package/dist/runner/adapter-run-spec.js +26 -43
  47. package/dist/runner/adapters/pi.d.ts +3 -2
  48. package/dist/runner/adapters/pi.js +3 -1
  49. package/dist/runner/audit.d.ts +1 -1
  50. package/dist/runner/cli-run-spec.js +13 -10
  51. package/dist/runner/compare-end.d.ts +1 -1
  52. package/dist/runner/dispatch.js +2 -2
  53. package/dist/runner/harness-loops.d.ts +9 -0
  54. package/dist/runner/harness-loops.js +47 -4
  55. package/dist/runner/held.d.ts +4 -1
  56. package/dist/runner/live-ticker.js +3 -4
  57. package/dist/runner/mcp-claim.js +3 -2
  58. package/dist/runner/mcp-run.d.ts +19 -4
  59. package/dist/runner/mcp-run.js +29 -2
  60. package/dist/runner/metrics.d.ts +4 -0
  61. package/dist/runner/metrics.js +9 -3
  62. package/dist/runner/monid-run.js +3 -1
  63. package/dist/runner/native-loop.js +1 -1
  64. package/dist/runner/redact.d.ts +3 -0
  65. package/dist/runner/redact.js +7 -0
  66. package/dist/runner/run-child-host.js +1 -1
  67. package/dist/runner/sdk-loop.js +5 -3
  68. package/dist/runner/workflow-calls.d.ts +4 -1
  69. package/dist/runner/workflow-calls.js +35 -18
  70. package/dist/runner/workflow-loop.d.ts +1 -1
  71. package/dist/runner/workflow-loop.js +3 -1
  72. package/dist/runner/workflow-spec.d.ts +4 -0
  73. package/dist/runner/workflow-spec.js +18 -13
  74. package/dist/runs-over-store.d.ts +2 -2
  75. package/dist/runs-over-store.js +1 -1
  76. package/dist/secret-cut.js +7 -4
  77. package/dist/secret-rules.js +97 -83
  78. package/dist/server.d.ts +7 -0
  79. package/dist/server.js +97 -34
  80. package/dist/slack.js +2 -1
  81. package/dist/store/postgres/migrate.js +3 -1
  82. package/dist/store-reads/learning.d.ts +5 -4
  83. package/dist/store-reads/learning.js +7 -4
  84. package/dist/tool-plane.d.ts +23 -1
  85. package/dist/tool-plane.js +70 -2
  86. package/dist/tools.d.ts +12 -2
  87. package/dist/tools.js +42 -7
  88. package/dist/trigger-launch-hook.d.ts +2 -2
  89. package/dist/trigger-launch-hook.js +1 -1
  90. package/dist/triggers.d.ts +7 -4
  91. package/dist/triggers.js +4 -4
  92. package/package.json +12 -12
  93. package/dist/console/assets/index-DZi-muIj.js +0 -629
package/dist/place.d.ts CHANGED
@@ -29,8 +29,9 @@ export declare function newAgentPlace(registry: readonly BoxOffer[]): {
29
29
  * (newAgentPlace) for an agentic revision with a tool that runs only in a box (`flags`, tools.ts: bash and the
30
30
  * background tools); the runner for a workflow, which is never given a box, for one whose tools need no shell (none, or
31
31
  * only read and write: a container would only hold up its start), and for one that names a tool the box refuses (the
32
- * browser, runner-only for now). */
33
- export declare function defaultPlaceOf(kind: "agentic" | "workflow", tools: readonly unknown[], registry: readonly BoxOffer[], flags: ToolFlags): Place;
32
+ * browser, runner-only for now). Where the runner has a shell (`runnerShell`: Mode 2's Archil exec), the runner for
33
+ * every revision: Docker's box can't mount the folder Mode 2 keeps on Archil. */
34
+ export declare function defaultPlaceOf(kind: "agentic" | "workflow", tools: readonly unknown[], registry: readonly BoxOffer[], flags: ToolFlags, runnerShell: boolean): Place;
34
35
  type ToolFlags = (tool: string) => {
35
36
  readonly sandboxOnly?: true;
36
37
  readonly runnerOnly?: true;
@@ -60,10 +61,10 @@ export declare function noBoxReason(registry: readonly BoxOffer[], listed: Reado
60
61
  export declare function boxesLine(registry: readonly BoxOffer[], listed: ReadonlySet<string>, allow?: readonly string[] | "none", byDefault?: boolean, runnerShell?: boolean): string;
61
62
  /** `places` in capabilities: the modes a revision may name, the place a new agent is saved with and a revision that
62
63
  * names none runs in (`default_place`), each box, and the hosts a box whose `network` is `allowlist` reaches (`allow`,
63
- * box-settings.ts boxAllowOf; empty for `none`). `default_place` is Docker's box where this server has it; else, where
64
- * the runner has a shell (`runnerShell`: Mode 2's Archil exec), the runner; else null, no default: a new agent names its
65
- * place, and `default_reason` is the words a no-place create is refused in (noBoxRefusal). `default_reason` is there
66
- * exactly when `default_place` is null. */
64
+ * box-settings.ts boxAllowOf; empty for `none`). `default_place` is the runner where it has a shell (`runnerShell`:
65
+ * Mode 2's Archil exec), Docker answering or not (defaultPlaceOf); else Docker's box where this server has it; else
66
+ * null, no default: a new agent names its place, and `default_reason` is the words a no-place create is refused in
67
+ * (noBoxRefusal). `default_reason` is there exactly when `default_place` is null. */
67
68
  export declare const placesOf: (registry: readonly BoxOffer[], allow?: readonly string[] | "none", runnerShell?: boolean) => {
68
69
  boxes: BoxOffer[];
69
70
  allow: string[];
package/dist/place.js CHANGED
@@ -15,7 +15,9 @@
15
15
  // it names a box or the runner, and no other box that answers is picked for it. A revision that names no place resolves
16
16
  // the same way at each run (defaultPlaceOf): with a shell tool, this server's default_place, so where docker is there
17
17
  // now it runs in the Docker box, and where it is not its run is refused in the same words. A workflow, a revision whose
18
- // tools need no shell, and one with a tool the box refuses run on the runner.
18
+ // tools need no shell, and one with a tool the box refuses run on the runner. In Mode 2 (the runner's shell is Archil's
19
+ // serverless exec) the default is the runner, Docker answering or not: Mode 2 keeps the run's folder on Archil, which
20
+ // Docker's box can't mount, so a run given that box would only be refused.
19
21
  import { BOX_IDS, BOXES_ENV, DEFAULT_BOX } from "./place-offers.js";
20
22
  import { sentence } from "./errors.js";
21
23
  export const PLACE_MODES = ["runner", "sandbox"];
@@ -56,9 +58,10 @@ export function newAgentPlace(registry) {
56
58
  * (newAgentPlace) for an agentic revision with a tool that runs only in a box (`flags`, tools.ts: bash and the
57
59
  * background tools); the runner for a workflow, which is never given a box, for one whose tools need no shell (none, or
58
60
  * only read and write: a container would only hold up its start), and for one that names a tool the box refuses (the
59
- * browser, runner-only for now). */
60
- export function defaultPlaceOf(kind, tools, registry, flags) {
61
- if (kind === "workflow" || !wantsBox(tools, flags))
61
+ * browser, runner-only for now). Where the runner has a shell (`runnerShell`: Mode 2's Archil exec), the runner for
62
+ * every revision: Docker's box can't mount the folder Mode 2 keeps on Archil. */
63
+ export function defaultPlaceOf(kind, tools, registry, flags, runnerShell) {
64
+ if (kind === "workflow" || runnerShell || !wantsBox(tools, flags))
62
65
  return { mode: "runner" };
63
66
  const fresh = newAgentPlace(registry);
64
67
  return "place" in fresh ? fresh.place : { mode: "runner" };
@@ -126,19 +129,19 @@ export function boxesLine(registry, listed, allow = "none", byDefault = false, r
126
129
  const box = defaultBox(registry);
127
130
  if (!box?.available)
128
131
  return `Boxes: none, so ${runnerShell ? "new agents run on the runner" : "a new agent must name its place: a box, or the runner"}. ${sentence(box?.reason ?? NO_REASON)}`;
129
- return [`Boxes: ${box.id} (on by default; set ${BOXES_ENV} to change).`, ...reach].join(" ");
132
+ return [`Boxes: ${box.id} (on by default; set ${BOXES_ENV} to change).`, ...(runnerShell ? [`New agents run on the runner: Mode 2 keeps workspaces on Archil, which the ${box.id} box can't mount.`] : []), ...reach].join(" ");
130
133
  }
131
134
  return ["Boxes:", ...(none ? ["none is ready, so sandbox agents do not run here."] : said), ...reach, ...why.map((box) => sentence(`${box.id}: ${box.reason ?? "not available"}`)), ...(rest ? [sentence(rest)] : [])].join(" ");
132
135
  }
133
136
  /** `places` in capabilities: the modes a revision may name, the place a new agent is saved with and a revision that
134
137
  * names none runs in (`default_place`), each box, and the hosts a box whose `network` is `allowlist` reaches (`allow`,
135
- * box-settings.ts boxAllowOf; empty for `none`). `default_place` is Docker's box where this server has it; else, where
136
- * the runner has a shell (`runnerShell`: Mode 2's Archil exec), the runner; else null, no default: a new agent names its
137
- * place, and `default_reason` is the words a no-place create is refused in (noBoxRefusal). `default_reason` is there
138
- * exactly when `default_place` is null. */
138
+ * box-settings.ts boxAllowOf; empty for `none`). `default_place` is the runner where it has a shell (`runnerShell`:
139
+ * Mode 2's Archil exec), Docker answering or not (defaultPlaceOf); else Docker's box where this server has it; else
140
+ * null, no default: a new agent names its place, and `default_reason` is the words a no-place create is refused in
141
+ * (noBoxRefusal). `default_reason` is there exactly when `default_place` is null. */
139
142
  export const placesOf = (registry, allow = "none", runnerShell = false) => {
140
143
  const fresh = newAgentPlace(registry);
141
- const byDefault = "place" in fresh ? { default_place: fresh.place } : runnerShell ? { default_place: { mode: "runner" } } : { default_place: null, default_reason: fresh.reason };
144
+ const byDefault = runnerShell ? { default_place: { mode: "runner" } } : "place" in fresh ? { default_place: fresh.place } : { default_place: null, default_reason: fresh.reason };
142
145
  return { modes: [...PLACE_MODES], ...byDefault, boxes: boxAvailability(registry).map(stated), allow: allow === "none" ? [] : [...allow] };
143
146
  };
144
147
  /** A box with its state, `ready` when it is available and `unavailable` when not; and, on an available box, its network as the server set it, with
package/dist/print.js CHANGED
@@ -16,7 +16,7 @@ export function banner(o) {
16
16
  `AGENTRUN_API_KEY=${key}`,
17
17
  ...(o.tokenIds && (o.tokenIds.length > 1 || o.source === "list") ? [`API tokens taken (ids): ${o.tokenIds.join(", ")}`] : []),
18
18
  o.apiOnly
19
- ? "API only (AGENTRUN_API_ONLY=1): the run and deploy routes, the MCP server names, a Composio server's save, a per_run server's save at an origin AGENTRUN_API_ONLY_MCP_ORIGINS lists and a server's delete are served; the console, sign-in, setup, other settings, the MCP endpoint, triggers and hooks are refused."
19
+ ? "API only (AGENTRUN_API_ONLY=1): the run and deploy routes, a trigger's reads and its turn on or off, the MCP server names, a Composio server's save, a per_run server's save at an origin AGENTRUN_API_ONLY_MCP_ORIGINS lists and a server's delete are served; the console, sign-in, setup, other settings, the MCP endpoint, the other trigger routes and hooks are refused."
20
20
  : o.accounts || o.launchCode === undefined ? `Open ${o.publicUrl ?? o.url}/` : `Open ${o.publicUrl ?? o.url}/?launch=${o.launchCode}`,
21
21
  ...(o.boxes ? [o.boxes] : []),
22
22
  ];
@@ -70,12 +70,23 @@ export type Needles = {
70
70
  export declare function merged(found: readonly (readonly [number, number])[]): Span[];
71
71
  /** `text` with each of `spans` (merged, in order) replaced by "[redacted]". */
72
72
  export declare function cutAt(text: string, spans: readonly Span[]): string;
73
+ /** What ends each pass of a join (joinOf). Every view keeps it, and no needle holds it, so no held value reads across
74
+ * it. It cannot be a NUL, as the views drop control characters wherever they come from (the text, or an escape or an
75
+ * encoding that decodes to one), and a separator they dropped would join the passes. It is U+FFFF, a noncharacter:
76
+ * squeeze, which every plain and joined needle is made with, drops it, and a hex, folded or base64 needle is ASCII.
77
+ * Only the one joinOf puts there separates. One the text brought shows as a box at most, and a reader reads a held
78
+ * value through it, so the views drop it as they drop a control character, as it stands or as a decoder made it, and
79
+ * joinOf reads one in a part's text as a NUL (one character for one, so every offset stays, and dropped too). A
80
+ * caller that marks places in a text with its own (secret-cut.ts) asks holds for `separated`. */
81
+ export declare const SEPARATOR = "\uFFFF";
73
82
  /** `text` as a view reads it, and as a held value's needles are read: decomposed (NFKD), its combining marks dropped,
74
83
  * then NFKC, with its whitespace and its characters that render as nothing gone, before (so one between a letter and
75
84
  * its accent hides neither) and after. A held value with a zero-width space or a soft hyphen between its characters
76
- * reads as itself; so does one with a combining mark after a letter, which NFKC alone composes into another letter
85
+ * reads as itself, and so does one with a control character between them (a NUL, an escape); so does one with a
86
+ * combining mark after a letter, which NFKC alone composes into another letter
77
87
  * ("Z" and U+0301 into "Ź"), and one written with a precomposed letter in place of its own ("Ź" for "Z"). A held
78
- * value's accents are dropped the same way, so it reads as itself with them or without: more cutting, never less. */
88
+ * value's accents are dropped the same way, so it reads as itself with them or without: more cutting, never less.
89
+ * SEPARATOR goes too, so no needle holds it (a join's view keeps it, never squeezing it). */
79
90
  export declare const squeeze: (text: string) => string;
80
91
  /** One of Python's own escapes at `at`, as its repr writes a str: an escaped apostrophe ("\'", in a string that holds
81
92
  * both quotes) is an apostrophe, "\x" and two hex digits the character they number; with `levels` 2, either written
@@ -112,10 +123,12 @@ export declare function entityAt(text: string, at: number): {
112
123
  * form encoded, an NFKC variant, its hex in any case, a hex identifier folded (`fold`), split across two strings of a
113
124
  * JSON text (joinOf; a "+" after its head or a quote of its own in it too), or split there at its own "," or ":"
114
125
  * (`joined`). With `cuts`, a value whose every character the view read comes from inside the cuts is not held: it is
115
- * cut in place. */
116
- export declare function holds(text: string, needles: Needles, { fold, cuts }?: {
126
+ * cut in place. A U+FFFF in `text` is nothing to the views (SEPARATOR); with `separated`, each one is the caller's
127
+ * mark and separates there in every view. */
128
+ export declare function holds(text: string, needles: Needles, { fold, cuts, separated }?: {
117
129
  fold?: boolean;
118
130
  cuts?: readonly Span[];
131
+ separated?: boolean;
119
132
  }): boolean;
120
133
  /** planCut's first step: every form, hex, folded identifier and shape of `text` as it came, and `held`, merged. */
121
134
  export declare function cutSpans(text: string, needles: Needles, shapes: readonly Shape[], held?: readonly (readonly [number, number])[]): Span[];
@@ -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
- /** A character that renders as nothing (a zero-width space, a soft hyphen, a byte order mark, a variation selector). */
728
- const IGNORABLE = /\p{Default_Ignorable_Code_Point}+/gu;
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; so does one with a combining mark after a letter, which NFKC alone composes into another letter
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 = {
@@ -941,7 +957,7 @@ function familiesOf(text) {
941
957
  const viewSpec = (when, decoders, join) => ({
942
958
  when,
943
959
  decoders,
944
- special: new RegExp(`[\\s${decoders.map((decoder) => `\\${decoder.trigger}`).join("")}\\u0080-\\uffff]`, "g"),
960
+ special: new RegExp(`[\\s${decoders.map((decoder) => `\\${decoder.trigger}`).join("")}\\u0000-\\u0008\\u000e-\\u001f\\u007f-\\uffff]`, "g"),
945
961
  ...(join ? { join } : {}),
946
962
  });
947
963
  /** The views of a text read for each held value, in order:
@@ -1080,8 +1096,8 @@ function partsOf(text, from, to, level, out, kind = "nested", written) {
1080
1096
  }
1081
1097
  /** `text`'s join of `kind` (JoinKind): its parts (partsOf) read three times over, each time joined, each part followed by a space (gone
1082
1098
  * from the view, and no escape reads past it): the values and the runs outside strings; the property names; then all
1083
- * of them. Each pass is closed by a NUL, which the view keeps and no held value holds, so no value reads across two
1084
- * 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"}),
1085
1101
  * across two names, across a name and its value, across a quote of JSON written in a string, or across a string and
1086
1102
  * the line after the JSON reads whole in one of them. A view decodes and squeezes the join as any text (viewOf), each
1087
1103
  * part's characters keeping their source: with `cuts` (merged spans of `text`), the spans of each part a cut covers
@@ -1125,7 +1141,7 @@ function joinOf(text, kind, cuts) {
1125
1141
  pieces.push(text.slice(part.from, part.to), " ");
1126
1142
  length += part.to - part.from + 1;
1127
1143
  }
1128
- pieces.push("\u0000");
1144
+ pieces.push(SEPARATOR);
1129
1145
  length++;
1130
1146
  }
1131
1147
  // The join written once.
@@ -1144,9 +1160,12 @@ function bothOf(first, second) {
1144
1160
  /** `text` as the whole-text check reads it: decoded by `spec`'s decoders, then squeezed (squeeze: NFKC, its whitespace
1145
1161
  * and its characters that render as nothing gone), as a held value's needles are. The squeeze is applied to each
1146
1162
  * stretch of non-ASCII characters with the ASCII character before it, which gives what it gives over the whole text (an
1147
- * ASCII character is a starter nothing composes onto), and each character it makes comes from that whole stretch. With `cuts` (merged spans of `text`), the view's
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
1148
1167
  * covered stretches: where every character comes from inside one cut. */
1149
- function viewOf(text, spec, cuts) {
1168
+ function viewOf(text, spec, cuts, separates = false) {
1150
1169
  const out = [];
1151
1170
  const covered = [];
1152
1171
  let length = 0;
@@ -1222,7 +1241,12 @@ function viewOf(text, spec, cuts) {
1222
1241
  group = undefined;
1223
1242
  };
1224
1243
  const unit = (char, from, to) => {
1225
- if (char.charCodeAt(0) >= 128) {
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) {
1226
1250
  if (group) {
1227
1251
  group.chars += char;
1228
1252
  group.to = to;
@@ -1271,6 +1295,13 @@ function viewOf(text, spec, cuts) {
1271
1295
  held = { char: text[BLANKS.lastIndex - 1], from: BLANKS.lastIndex - 1, to: BLANKS.lastIndex };
1272
1296
  at = BLANKS.lastIndex;
1273
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
+ }
1274
1305
  else {
1275
1306
  unit(char, stop, stop + 1);
1276
1307
  at = stop + 1;
@@ -1382,24 +1413,35 @@ function holdsIn(view, covered, needles) {
1382
1413
  * form encoded, an NFKC variant, its hex in any case, a hex identifier folded (`fold`), split across two strings of a
1383
1414
  * JSON text (joinOf; a "+" after its head or a quote of its own in it too), or split there at its own "," or ":"
1384
1415
  * (`joined`). With `cuts`, a value whose every character the view read comes from inside the cuts is not held: it is
1385
- * cut in place. */
1386
- export function holds(text, needles, { fold = true, cuts } = {}) {
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 } = {}) {
1387
1419
  const folds = fold ? needles.folds : [];
1388
1420
  if (!needles.plain.length && !needles.hexes.length && !folds.length)
1389
1421
  return false;
1390
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
+ };
1391
1433
  const joins = new Map();
1392
1434
  const joinFor = (kind) => {
1393
1435
  let join = joins.get(kind);
1394
1436
  if (!join)
1395
- joins.set(kind, (join = kind === "both" ? bothOf(joinFor("quoted"), joinFor("again")) : joinOf(text, kind, cuts)));
1437
+ joins.set(kind, (join = kind === "both" ? bothOf(joinFor("quoted"), joinFor("again")) : joinOf(joinText(), kind, cuts)));
1396
1438
  return join;
1397
1439
  };
1398
1440
  for (const spec of VIEWS) {
1399
1441
  if (!spec.when(has))
1400
1442
  continue;
1401
1443
  const join = spec.join ? joinFor(spec.join) : undefined;
1402
- 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);
1403
1445
  const covered = cuts ? view.covered : undefined;
1404
1446
  if (holdsIn(view.text, covered, needles.plain))
1405
1447
  return true;
@@ -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
- const carried = listed.carried.map((file) => ({ path: cutFileText(file.path, input.held), content: cutFileText(file.content, input.held) }));
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.path }, restoring);
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-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`. Its money is what the run's ledger booked for it (`booked`, by computeKey): `estimate` when any was;
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
  });
@@ -8,7 +8,7 @@ import { type GenAiTracing } from "../otel/tracer.js";
8
8
  import { type AgentOfRun, type RouteTrace } from "../otel/genai.js";
9
9
  type EndCost = Required<Pick<EndData, "costUsd" | "costUpperBound">>;
10
10
  import { type Claim, type EndOfRunTurn, type LoopFactory } from "./loop-contract.js";
11
- import type { HeldRedact } from "./redact.js";
11
+ import { type HeldRedact } from "./redact.js";
12
12
  import { type BoundTimer, Parked } from "./loop.js";
13
13
  import type { PiRun } from "./adapters/pi.js";
14
14
  import { type HeldSpec } from "./held-run.js";
@@ -84,6 +84,13 @@ export type SpecGate = ((call: ToolCall, options?: {
84
84
  /** A tool's setting now, by any name a call reaches the gate by (a harness's own, Codex's `web_search`), read again at
85
85
  * each ask: what the session reads (SessionIO.permission) for a tool no call of which reaches the gate before it runs. */
86
86
  readonly permission?: (tool: string) => Promise<"allow" | "ask" | "deny">;
87
+ /** The run's learned workflow a learned_workflow call's arguments name (its name and its digest, workflow-first.ts
88
+ * workflowDigest), or undefined for a name the run has none of: what the record of such a call the gate refuses
89
+ * names (learnedEntry). */
90
+ readonly learnedOf?: (args: unknown) => {
91
+ readonly workflow: string;
92
+ readonly digest: string;
93
+ } | undefined;
87
94
  };
88
95
  /** What one claimed run's adapter loop runs. */
89
96
  export interface AdapterRunSpec {