@foldrun/core 15.1.0 → 17.0.0
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/dist/src/a2a-publish.d.ts +7 -0
- package/dist/src/a2a-publish.js +15 -1
- package/dist/src/a2a-reach.d.ts +156 -0
- package/dist/src/a2a-reach.js +446 -0
- package/dist/src/browse-egress.d.ts +1 -1
- package/dist/src/browse-egress.js +7 -6
- package/dist/src/egress.d.ts +9 -0
- package/dist/src/env-names.d.ts +12 -0
- package/dist/src/env-names.js +49 -0
- package/dist/src/failure.d.ts +92 -0
- package/dist/src/failure.js +294 -0
- package/dist/src/frontmatter-fields.js +1 -1
- package/dist/src/install-helper.js +10 -5
- package/dist/src/network.js +1 -1
- package/dist/src/ops-log.js +4 -0
- package/dist/src/otel.d.ts +16 -1
- package/dist/src/otel.js +121 -5
- package/dist/src/platform.d.ts +8 -0
- package/dist/src/run-container.d.ts +88 -4
- package/dist/src/run-container.js +215 -26
- package/dist/src/run-event.d.ts +179 -0
- package/dist/src/run-event.js +473 -0
- package/dist/src/runner.js +35 -1
- package/dist/src/runtime.d.ts +116 -16
- package/dist/src/runtime.js +531 -44
- package/dist/src/scan.js +80 -18
- package/dist/src/search-egress.d.ts +58 -0
- package/dist/src/search-egress.js +88 -0
- package/dist/src/starter.js +4 -1
- package/dist/src/store.d.ts +34 -3
- package/dist/src/store.js +46 -10
- package/package.json +2 -1
- package/src/a2a-publish.ts +19 -1
- package/src/a2a-reach.ts +503 -0
- package/src/browse-egress.ts +8 -7
- package/src/egress.ts +7 -0
- package/src/env-names.ts +53 -0
- package/src/failure.ts +368 -0
- package/src/frontmatter-fields.ts +1 -1
- package/src/install-helper.ts +10 -5
- package/src/network.ts +1 -1
- package/src/ops-log.ts +4 -0
- package/src/otel.ts +122 -7
- package/src/platform.ts +8 -0
- package/src/run-container.ts +228 -29
- package/src/run-event.ts +563 -0
- package/src/runner.ts +32 -1
- package/src/runtime.ts +546 -45
- package/src/scan.ts +91 -20
- package/src/search-egress.ts +116 -0
- package/src/starter.ts +4 -1
- package/src/store.ts +75 -12
package/dist/src/otel.js
CHANGED
|
@@ -13,9 +13,35 @@
|
|
|
13
13
|
// whole, like notify:). Ids are derived from the run and span ids, so a run
|
|
14
14
|
// sent twice is the same trace, not two. No OpenTelemetry SDK: the wire
|
|
15
15
|
// format is small, and a dependency in every runner image is not.
|
|
16
|
+
//
|
|
17
|
+
// Names follow the OpenTelemetry GenAI semantic conventions — since 2026 in
|
|
18
|
+
// their own repository, github.com/open-telemetry/semantic-conventions-genai
|
|
19
|
+
// (docs/gen-ai/gen-ai-agent-spans.md, gen-ai-spans.md, client-inference.md;
|
|
20
|
+
// read at 58daeb9, 5 Nov 2026, status Development):
|
|
21
|
+
//
|
|
22
|
+
// run invoke_workflow {flow} INTERNAL gen_ai.workflow.name
|
|
23
|
+
// step invoke_agent {agent} INTERNAL gen_ai.agent.name
|
|
24
|
+
// model call chat {model} CLIENT gen_ai.provider.name, usage
|
|
25
|
+
// tool call execute_tool {tool} INTERNAL gen_ai.tool.name, call.id
|
|
26
|
+
//
|
|
27
|
+
// each with gen_ai.operation.name, and error.type on a failed span. A direct
|
|
28
|
+
// agent run (flow "adhoc:<agent>") is not a workflow — the spec says not to
|
|
29
|
+
// report one for a standalone agent — so its root stays `run adhoc:<agent>`
|
|
30
|
+
// with no operation, and the step under it is the invoke_agent.
|
|
31
|
+
//
|
|
32
|
+
// Content stays out: no gen_ai.input/output.messages, no tool call
|
|
33
|
+
// arguments or results — the spec makes every one of them Opt-In, and a
|
|
34
|
+
// trace is built from the run record alone, which holds none of them (a
|
|
35
|
+
// captured call's content is under runs/<run>/calls/, never read here).
|
|
36
|
+
// What a span says of a failure is its class (error.type) and the step's
|
|
37
|
+
// own error line as the status message, capped.
|
|
16
38
|
import crypto from "node:crypto";
|
|
39
|
+
import { isSplicedRecord } from "./store.js";
|
|
17
40
|
import { buildTraceTree } from "./trace-tree.js";
|
|
41
|
+
import { errorClass } from "./ops-log.js";
|
|
42
|
+
import { platformCause } from "./issues.js";
|
|
18
43
|
export { parseTelemetry, telemetrySecretNames, telemetryHeaders } from "./otel-config.js";
|
|
44
|
+
const strings = (key, v) => (v.length ? [{ key, value: { arrayValue: { values: v.map((x) => ({ stringValue: x })) } } }] : []);
|
|
19
45
|
const attr = (key, v) => {
|
|
20
46
|
if (v === null || v === undefined || v === "")
|
|
21
47
|
return [];
|
|
@@ -29,37 +55,127 @@ const hex = (s, len) => crypto.createHash("sha256").update(s).digest("hex").slic
|
|
|
29
55
|
const nanos = (msEpoch) => (BigInt(Math.round(msEpoch)) * BigInt(1_000_000)).toString();
|
|
30
56
|
/** OTLP span kinds: INTERNAL, and CLIENT for a call that leaves the platform. */
|
|
31
57
|
const SPAN_KIND = { internal: 1, client: 3 };
|
|
58
|
+
/** What `error.type` may say: one of the platform's error classes
|
|
59
|
+
* (ops-log.ts, FOL-121), or the spec's `_OTHER` when the words of the
|
|
60
|
+
* failure match none. The spec asks an instrumentation to document the
|
|
61
|
+
* list it reports; this is it. */
|
|
62
|
+
export const SPAN_ERROR_TYPES = ["timeout", "cancelled", "model_error", "oom", "disk_full", "network_error", "not_found", "policy_denied", "platform_error", "_OTHER"];
|
|
63
|
+
/** A failure's class from its words, the way an operator counts them.
|
|
64
|
+
* Only the class leaves: the words stay where they were. */
|
|
65
|
+
export function spanErrorType(text, stopped = false) {
|
|
66
|
+
if (stopped)
|
|
67
|
+
return "cancelled";
|
|
68
|
+
if (!text)
|
|
69
|
+
return "_OTHER";
|
|
70
|
+
// What stopRun writes on the step it interrupted, and on the run.
|
|
71
|
+
if (/\b(stopped by a person|cancelled by .+) — sandbox destroyed|^run (stopped|cancelled)\b/.test(text))
|
|
72
|
+
return "cancelled";
|
|
73
|
+
const cause = platformCause(text)?.key;
|
|
74
|
+
if (cause === "model-auth" || cause === "model-cap" || cause === "model-busy")
|
|
75
|
+
return "model_error";
|
|
76
|
+
if (cause === "sandbox" || cause === "worker")
|
|
77
|
+
return "platform_error";
|
|
78
|
+
if (/\btimed out\b/i.test(text))
|
|
79
|
+
return "timeout";
|
|
80
|
+
const cls = errorClass({ message: text });
|
|
81
|
+
return cls !== "platform_error" && SPAN_ERROR_TYPES.includes(cls) ? cls : "_OTHER";
|
|
82
|
+
}
|
|
83
|
+
/** The step that failed the run, by the runner's own rule (runner.ts: a
|
|
84
|
+
* failed step that is not optional, carried from an earlier run or a
|
|
85
|
+
* spliced record); else any failed one. */
|
|
86
|
+
const failingStep = (run) => run.steps.find((s) => s.status === "failed" && !s.optional && !s.carriedFrom && !isSplicedRecord(s)) ?? run.steps.find((s) => s.status === "failed");
|
|
87
|
+
const lastError = (s) => {
|
|
88
|
+
const errors = (s?.events ?? []).filter((e) => e.type === "error");
|
|
89
|
+
return errors[errors.length - 1]?.text ?? null;
|
|
90
|
+
};
|
|
91
|
+
/** gen_ai.provider.name — the spec's well-known value, only where the record
|
|
92
|
+
* says whose model it was: the platform's own Claude credential, or one of
|
|
93
|
+
* foldrun's models. An account's own provider: block could be anyone's, so
|
|
94
|
+
* it says nothing rather than guess. */
|
|
95
|
+
const PROVIDER = { anthropic: "anthropic", openai: "openai", gemini: "gcp.gemini", deepseek: "deepseek", moonshot: "moonshot_ai" };
|
|
96
|
+
function providerOf(step) {
|
|
97
|
+
if (!step)
|
|
98
|
+
return null;
|
|
99
|
+
// A refusal retried on the fallback supply (runner.ts) runs calls the
|
|
100
|
+
// step's `supply` does not describe; the record does not say which call
|
|
101
|
+
// went where, so none of them claims a provider.
|
|
102
|
+
if (step.events.some((e) => e.type === "info" && /retrying this step on the fallback provider/.test(e.text)))
|
|
103
|
+
return null;
|
|
104
|
+
if (step.supply === "operator")
|
|
105
|
+
return "anthropic";
|
|
106
|
+
if (step.supply === "foldrun" && step.supplyProvider)
|
|
107
|
+
return PROVIDER[step.supplyProvider] ?? step.supplyProvider;
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
32
110
|
/** The ExportTraceServiceRequest for one run. */
|
|
33
111
|
export function runToOtlp(run, ctx, now = Date.now()) {
|
|
34
112
|
const tree = buildTraceTree(run, now);
|
|
35
113
|
const traceId = hex(`foldrun-trace\0${ctx.tenant}\0${ctx.workspace}\0${run.id}`, 32);
|
|
36
114
|
const spans = [];
|
|
115
|
+
const adhoc = run.flow.startsWith("adhoc:");
|
|
37
116
|
const visit = (s, parent, inherited) => {
|
|
38
117
|
const spanId = hex(`${traceId}\0${s.id}`, 16);
|
|
39
118
|
const start = s.start ?? inherited.start;
|
|
40
119
|
const end = Math.max(start, s.end ?? s.start ?? now);
|
|
41
120
|
const step = s.step !== undefined ? run.steps[s.step] : undefined;
|
|
42
121
|
const agent = s.kind === "step" ? step?.agent : inherited.agent;
|
|
122
|
+
const operation = s.kind === "run" ? (adhoc ? null : "invoke_workflow") : s.kind === "step" ? "invoke_agent" : s.kind === "model" ? "chat" : s.kind === "tool" ? "execute_tool" : null;
|
|
123
|
+
const name = s.kind === "run" ? (adhoc ? `run ${s.label}` : `invoke_workflow ${s.label}`)
|
|
124
|
+
: s.kind === "step" ? `invoke_agent ${s.label}`
|
|
125
|
+
: s.kind === "model" ? `chat ${s.model ?? s.label}`
|
|
126
|
+
: s.kind === "tool" ? `execute_tool ${s.label}`
|
|
127
|
+
: s.label;
|
|
128
|
+
// Why it failed, as a class: the run by its failing step, a step by its
|
|
129
|
+
// last error line, an error leaf by its own words. A failed tool call's
|
|
130
|
+
// record holds no words, only that it erred.
|
|
131
|
+
const failed = s.status === "error";
|
|
132
|
+
// A person (or a caller) stopping the run is why the run failed; a step
|
|
133
|
+
// that failed before the stop failed for its own reason — the step the
|
|
134
|
+
// stop interrupted is marked skipped, and its error line says cancelled.
|
|
135
|
+
const stopped = run.stopRequested === true && s.kind === "run";
|
|
136
|
+
const errorText = !failed ? null
|
|
137
|
+
: s.kind === "run" ? lastError(failingStep(run))
|
|
138
|
+
: s.kind === "step" ? lastError(step)
|
|
139
|
+
: s.text ?? null;
|
|
43
140
|
spans.push({
|
|
44
141
|
traceId,
|
|
45
142
|
spanId,
|
|
46
143
|
...(parent ? { parentSpanId: parent } : {}),
|
|
47
|
-
name
|
|
144
|
+
name,
|
|
48
145
|
kind: s.kind === "model" ? SPAN_KIND.client : SPAN_KIND.internal,
|
|
49
146
|
startTimeUnixNano: nanos(start),
|
|
50
147
|
endTimeUnixNano: nanos(end),
|
|
51
148
|
attributes: [
|
|
149
|
+
...attr("gen_ai.operation.name", operation),
|
|
52
150
|
...attr("foldrun.span.kind", s.kind),
|
|
53
151
|
...attr("foldrun.status", s.status),
|
|
54
|
-
...(s.kind === "
|
|
152
|
+
...(s.kind === "run" && !adhoc ? attr("gen_ai.workflow.name", s.label) : []),
|
|
153
|
+
...(s.kind === "step" ? [...attr("gen_ai.agent.name", agent), ...attr("foldrun.agent", agent), ...attr("foldrun.owner", agent ? ctx.owners?.[agent] ?? null : null), ...attr("foldrun.step", s.step)] : []),
|
|
154
|
+
...(s.kind === "model" ? attr("gen_ai.provider.name", providerOf(step)) : []),
|
|
55
155
|
...attr("gen_ai.request.model", s.model),
|
|
56
|
-
...(s.tokens
|
|
156
|
+
...(s.tokens
|
|
157
|
+
? [
|
|
158
|
+
...attr("gen_ai.usage.input_tokens", s.tokens.input),
|
|
159
|
+
...attr("gen_ai.usage.output_tokens", s.tokens.output),
|
|
160
|
+
// The spec's names: "when available and non-zero".
|
|
161
|
+
...(s.tokens.cacheRead ? attr("gen_ai.usage.cache_read.input_tokens", s.tokens.cacheRead) : []),
|
|
162
|
+
...(s.tokens.cacheWrite ? attr("gen_ai.usage.cache_write.input_tokens", s.tokens.cacheWrite) : []),
|
|
163
|
+
// Deprecated (5 Nov 2026): the names this export sent before the
|
|
164
|
+
// spec named them. Kept for one release; read the ones above.
|
|
165
|
+
...attr("gen_ai.usage.cache_read_tokens", s.tokens.cacheRead),
|
|
166
|
+
...attr("gen_ai.usage.cache_write_tokens", s.tokens.cacheWrite),
|
|
167
|
+
]
|
|
168
|
+
: []),
|
|
169
|
+
...(s.stop ? strings("gen_ai.response.finish_reasons", [s.stop]) : []),
|
|
170
|
+
// Deprecated (5 Nov 2026): the singular this export sent before; the
|
|
171
|
+
// spec's is the array above. Kept for one release.
|
|
57
172
|
...attr("gen_ai.response.finish_reason", s.stop),
|
|
58
173
|
...(typeof s.costUsd === "number" ? attr("foldrun.cost_usd", s.costUsd) : []),
|
|
59
|
-
...(s.kind === "tool" ? [...attr("gen_ai.tool.name", s.label), ...attr("gen_ai.tool.call.id", s.call)] : []),
|
|
174
|
+
...(s.kind === "tool" ? [...attr("gen_ai.tool.name", s.label), ...attr("gen_ai.tool.call.id", s.call), ...attr("gen_ai.agent.name", s.subagent ?? agent)] : []),
|
|
60
175
|
...attr("foldrun.subagent", s.subagent),
|
|
176
|
+
...(failed ? attr("error.type", spanErrorType(errorText, stopped)) : []),
|
|
61
177
|
],
|
|
62
|
-
status:
|
|
178
|
+
status: failed ? { code: 2, ...(errorText ? { message: errorText.slice(0, 500) } : {}) } : { code: 0 },
|
|
63
179
|
});
|
|
64
180
|
for (const c of s.children)
|
|
65
181
|
visit(c, spanId, { start, agent });
|
package/dist/src/platform.d.ts
CHANGED
|
@@ -162,6 +162,14 @@ export interface PlatformHooks {
|
|
|
162
162
|
* trace as not enforced.
|
|
163
163
|
*/
|
|
164
164
|
confinesBrowsing?(isolation: string): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Does this isolation mode wall a step whose `network:` is restricted and
|
|
167
|
+
* enforced to the egress proxy alone (a `filtered` pod)? True: such a
|
|
168
|
+
* step's web search goes through the proxy's search door (FOL-128,
|
|
169
|
+
* search-egress.ts), since the account's search engine is out of its
|
|
170
|
+
* reach. Absent or false: it reaches the engine as it always did.
|
|
171
|
+
*/
|
|
172
|
+
wallsRestricted?(isolation: string): boolean;
|
|
165
173
|
/**
|
|
166
174
|
* An operator setting, by the environment variable that used to hold it
|
|
167
175
|
* (30 Oct 2026): the platform answers with the operator's value where one
|
|
@@ -131,6 +131,10 @@ export interface StepTiming {
|
|
|
131
131
|
* from an executor that marks none, and from a resumed driver (the
|
|
132
132
|
* first driver's phases are on the record already). */
|
|
133
133
|
phases?: StartupPhases;
|
|
134
|
+
/** When the phases count from: the epoch ms the executor began the step
|
|
135
|
+
* (FOL-122) — what places them on the clock (StepRecord.startupAt). Set
|
|
136
|
+
* beside `phases` only. */
|
|
137
|
+
origin?: number;
|
|
134
138
|
}
|
|
135
139
|
/** The start-up phases and what each marks — startup.ts, where every
|
|
136
140
|
* surface that shows them reads them from (FOL-74). */
|
|
@@ -293,8 +297,52 @@ export declare const RUNTIME_CACHE = "/home/agent/.foldrun/runner/.runtimes";
|
|
|
293
297
|
/** Starts the install helper as root, in the background, before the drop to
|
|
294
298
|
* the agent user: the root half of the `install` tool (install-helper.ts).
|
|
295
299
|
* The agent reaches it only through the socket; it installs only validated
|
|
296
|
-
* Debian package names, and dies with the container.
|
|
300
|
+
* Debian package names, and dies with the container.
|
|
301
|
+
* @deprecated the start-ups use rootStartSh, which starts the helper in a
|
|
302
|
+
* clean environment with the snapshot key's path (FOL-129). */
|
|
297
303
|
export declare const INSTALL_HELPER_SH = "FOLDRUN_INSTALL_SOCKET=/opt/runner/job/install.sock; export FOLDRUN_INSTALL_SOCKET\nnode /opt/runner/node_modules/@foldrun/core/dist/src/install-helper.js \"$FOLDRUN_INSTALL_SOCKET\" /home/agent/.foldrun/runner/.runtimes >/dev/null 2>&1 &";
|
|
304
|
+
/**
|
|
305
|
+
* The account's key for sealing its `runtime: system:` snapshots (FOL-129):
|
|
306
|
+
* derived from the install key, so it needs no store and no rotation of its
|
|
307
|
+
* own, and per account, so one account's key seals nothing for another. The
|
|
308
|
+
* worker stages it as the step's SNAPSHOT_KEY_FILE; null (no tenant, or a
|
|
309
|
+
* process without the install key) means the step gets no snapshots.
|
|
310
|
+
*/
|
|
311
|
+
export declare function aptSnapshotKey(tenant: string | undefined | null): string | null;
|
|
312
|
+
/**
|
|
313
|
+
* Root's part of a run container's start-up, before the chown and the drop
|
|
314
|
+
* to the agent user (k8s SHIM, docker ENTRY): the snapshot key moved where
|
|
315
|
+
* only root can read it, then — in a subshell whose environment is the root
|
|
316
|
+
* shell's own plus the proxy's variables (ROOT_ENV_FILE), reset to those
|
|
317
|
+
* alone (ROOT_ENV_RESET_SH) — the declared system packages and the install
|
|
318
|
+
* helper. The key never enters an environment: root's commands and the
|
|
319
|
+
* helper get only its path, and the copy in the job folder (which is chowned
|
|
320
|
+
* to the agent next) is gone before the subshell ends, or the start-up stops.
|
|
321
|
+
*
|
|
322
|
+
* The step's own environment (STEP_ENV_FILE) is never read here (FOL-130):
|
|
323
|
+
* its names are the account's to choose, and an LD_PRELOAD or PATH there
|
|
324
|
+
* pointing into the agent-writable cache would run the agent's code as root.
|
|
325
|
+
* ROOT_ENV_FILE is the worker's cut of it to ROOT_ENV_NAMES, sourced before
|
|
326
|
+
* the reset so even a name that should not be there is unset again; the
|
|
327
|
+
* socket and the locale are set after it, so nothing read can move them.
|
|
328
|
+
*/
|
|
329
|
+
export declare function rootStartSh(cacheDir?: string): string;
|
|
330
|
+
/**
|
|
331
|
+
* The drop to the agent user, and the only place the step's environment is
|
|
332
|
+
* read (FOL-130): runuser starts with the root shell's own environment — the
|
|
333
|
+
* image's and the pod spec's, which ROOT_SHELL_GUARD_SH has already cleaned —
|
|
334
|
+
* and the agent's shell then sources STEP_ENV_FILE, sets up the egress
|
|
335
|
+
* proxy's CA (which root never needs: apt goes through the proxy unopened),
|
|
336
|
+
* and execs `command`, so its exit status is the step's.
|
|
337
|
+
*
|
|
338
|
+
* What the agent ends with is what it had when root sourced the file before
|
|
339
|
+
* the drop: the step's names over the root shell's, the CA's variables over
|
|
340
|
+
* those, runuser's HOME/USER/LOGNAME over all (kept in positional
|
|
341
|
+
* parameters, which no sourced name can reach), and the install socket at
|
|
342
|
+
* its fixed path. No `set -e`: an egress CA that cannot be written leaves
|
|
343
|
+
* the step without it, as before, rather than stopping it.
|
|
344
|
+
*/
|
|
345
|
+
export declare function agentStartSh(command?: string): string;
|
|
298
346
|
/**
|
|
299
347
|
* Where the platform's shared runtime layer is mounted, read-only, in a run
|
|
300
348
|
* pod — and read-write, one entry at a time, in the pod that builds an entry
|
|
@@ -370,7 +418,41 @@ export declare const RETRY_SH = "retry() { what=$1; shift; n=1; until \"$@\"; do
|
|
|
370
418
|
* 23 Oct 2026: Node 22.23.4 (the 21 Oct security release: Brotli decoder
|
|
371
419
|
* RCE, TLS hostname bypasses); the pin before carried 22.23.3. */
|
|
372
420
|
export declare const NODE_BASE = "node:22-trixie-slim@sha256:8eb619e402eaede1748a3c8173bffab391592812e85136452f781741c7242ddf";
|
|
373
|
-
export declare const DOCKERFILE = "FROM node:22-trixie-slim@sha256:8eb619e402eaede1748a3c8173bffab391592812e85136452f781741c7242ddf AS base\nRUN apt-get update \\\n && apt-get install -y --no-install-recommends python3 python3-venv ca-certificates bash util-linux tar openssh-client sshpass git curl \\\n && rm -rf /var/lib/apt/lists/* \\\n && useradd -m -u 10001 agent\n# uv builds the declared python environments (runtime.ts): a fraction of\n# pip's time, and it can fetch a pinned python the image does not carry.\nCOPY --from=ghcr.io/astral-sh/uv:0.11.25 /uv /uvx /usr/local/bin/\nENV PLAYWRIGHT_BROWSERS_PATH=/opt/browser NODE_PATH=/usr/local/lib/node_modules\n\nFROM base AS core\nWORKDIR /opt/runner\nCOPY foldrun-core.tgz ./\nRUN npm init -y >/dev/null && npm install ./foldrun-core.tgz --omit=dev \\\n && npm cache clean --force >/dev/null 2>&1 \\\n && rm -f foldrun-core.tgz node_modules/@foldrun/core/README.md\n\nFROM base AS slim\n# Fonts, because a step that draws text without a browser still needs them:\n# the full image gets 51 from Playwright's --with-deps, slim had none, so from\n# 2026-09-29 (when non-browsing steps moved to slim) every resvg/sharp diagram\n# rendered its labels as empty boxes \u2014 expert-witness-desk's validator failed\n# four passes on a post image that was \"three empty boxes\". DejaVu covers\n# Latin, Greek and Cyrillic in a few MB; fontconfig is how renderers find it.\n# DejaVu alone still drew emoji, Chinese, Japanese, Korean, Devanagari and\n# Thai as empty boxes (reproduced 2026-10-01 with resvg-js 2.6 and sharp\n# 0.34), so four more, the smallest set that drew all of them \u2014 8 MB:\n# Symbola emoji and symbols, as outlines. NOT Noto Color Emoji (10 MB):\n# resvg draws nothing from its bitmap glyphs, so a resvg\n# diagram kept its empty boxes.\n# WenQuanYi Micro Hei Chinese, Japanese kana and Korean Hangul, one file.\n# Lohit Devanagari, Loma Hindi and Thai.\n# Here, not in base, so the full image's browser layers stay cached.\nRUN apt-get update \\\n && apt-get install -y --no-install-recommends fonts-dejavu-core fontconfig fonts-symbola fonts-wqy-microhei fonts-lohit-deva fonts-tlwg-loma-otf \\\n && rm -rf /var/lib/apt/lists/* \\\n && fc-cache -f >/dev/null\n# The Playwright client only, the same pinned version as the browser pod's\n# server (the wire protocol is version-locked), so a tool that imports it\n# still loads; there is nothing here for it to launch.\n# npm's download cache is dropped in the same layer: it was 190 MB of every\n# image, read by nothing after the build.\nRUN npm install -g playwright@1.63.0 axe-core@4.13.0 >/dev/null && npm cache clean --force >/dev/null 2>&1\nWORKDIR /opt/runner\nCOPY --from=core --chown=agent:agent /opt/runner/ ./\nCOPY --chown=agent:agent driver.mjs entry.sh ./\nRUN mkdir -p /workspace /library /opt/runner/job /home/agent/.foldrun/runner/.runtimes /opt/foldrun-runtimes/shared/.runtimes \\\n && chown agent:agent /opt/runner \\\n && chown -R agent:agent /workspace /library /opt/runner/job /home/agent/.foldrun /opt/foldrun-runtimes \\\n && chmod +x /opt/runner/entry.sh\nENTRYPOINT [\"/opt/runner/entry.sh\"]\n\nFROM base AS browsers\n# Real browsers, because directories and portals increasingly render with\n# JavaScript and a plain fetch sees only the empty shell. Chromium is the one the\n# browser tool drives by default; Firefox and WebKit (Safari's engine) are\n# there for an agent asked to see a page the way those render it. Installed\n# to a fixed path the agent user can read (the default cache would be\n# root's HOME). The browsers' own sandboxes are disabled at launch time \u2014 in\n# this platform the container/gVisor IS the sandbox, and the two fight.\n# Pinned exactly, not @1: web browse's numbered elements use ariaSnapshot's\n# \"ai\" mode (1.59+), and the per-account browser pod runs this same image, so\n# a floating version would move both under a working tool on any rebuild.\n# Raise it on purpose, with the gallery tests and one real call.\n# axe-core beside it is web browse's mode=a11y: one file the tool injects\n# into the page; without it the mode falls back to its own shorter checks.\n# Xvfb by name: the browser pod starts it at boot and web browse starts one\n# per call for headless: false. It used to arrive only as one of Playwright's\n# --with-deps packages, so a Playwright bump that dropped it would have\n# broken every windowed browser without a word. No xauth: nothing here runs\n# xvfb-run, and Xvfb started without -auth takes the local client as it is.\nRUN apt-get update \\\n && apt-get install -y --no-install-recommends xvfb \\\n && rm -rf /var/lib/apt/lists/*\n# Google Chrome and Chrome beta come from Google's apt repository, which\n# Playwright adds; each is tried ENGINE_DOWNLOAD_ATTEMPTS times. Only on\n# x86_64: Google ships no Linux Chrome for arm64, so there it is not tried.\nRUN npm install -g playwright@1.63.0 axe-core@4.13.0 >/dev/null \\\n && playwright install --with-deps chromium firefox webkit >/dev/null \\\n && retry() { what=$1; shift; n=1; until \"$@\"; do if [ \"$n\" -ge 3 ]; then echo \"runner image: $what - download failed $n times, giving up\" >&2; return 1; fi; echo \"runner image: $what - download failed (attempt $n of 3), retrying in $((n * 15))s\" >&2; sleep $((n * 15)); n=$((n + 1)); done; } \\\n && if [ \"$(uname -m)\" = x86_64 ]; then \\\n retry chrome playwright install --with-deps chrome >/dev/null || echo \"runner image: chrome not installed - engine: chrome would fall back to chromium\" >&2; \\\n retry chrome-beta playwright install --with-deps chrome-beta >/dev/null || echo \"runner image: chrome-beta not installed\" >&2; \\\n else echo \"runner image: no Google Chrome for $(uname -m) - engine: chrome falls back to chromium\"; fi \\\n && chmod -R a+rX /opt/browser \\\n && npm cache clean --force >/dev/null 2>&1\n# Lightpanda (engine: lightpanda): a browser that runs the JavaScript and\n# never draws \u2014 a fraction of Chromium's memory for reading and filling\n# pages. Its own program, which web browse starts beside a call and drives\n# over the DevTools protocol; shipped unmodified (AGPL-3.0). Pinned by\n# checksum (GitHub's own asset digests, checked again here). 0.4.1 since the\n# move to Debian 13: 0.3.7 on wants glibc 2.38, and Debian 12's 2.36 held it\n# at 0.3.6. An arch without a build leaves the engine out, and the tool says\n# so when asked for it. Each download (with its checksum) is tried\n# ENGINE_DOWNLOAD_ATTEMPTS times before the engine is left out.\n# Raise it on purpose: the new release's two sha256s, then one\n# engine=lightpanda call on each arch.\nRUN arch=$(uname -m) \\\n && case \"$arch\" in \\\n x86_64) sum=1d40801e72c0bc61b2cbd3f3562bcfc46de7b79e0568f33f686b64f2e587610a ;; \\\n aarch64) sum=664775c7f5ab69cc3189954c7f9345e25c167cb4dace016173e629f9a5e82c42 ;; \\\n *) sum= ;; \\\n esac \\\n && mkdir -p /opt/browser/lightpanda \\\n && retry() { what=$1; shift; n=1; until \"$@\"; do if [ \"$n\" -ge 3 ]; then echo \"runner image: $what - download failed $n times, giving up\" >&2; return 1; fi; echo \"runner image: $what - download failed (attempt $n of 3), retrying in $((n * 15))s\" >&2; sleep $((n * 15)); n=$((n + 1)); done; } \\\n && fetch() { curl -fsSL -o /opt/browser/lightpanda/lightpanda \"https://github.com/lightpanda-io/browser/releases/download/0.4.1/lightpanda-$arch-linux\" \\\n && echo \"$sum /opt/browser/lightpanda/lightpanda\" | sha256sum -c - >/dev/null; } \\\n && if [ -n \"$sum\" ] && retry lightpanda fetch; then \\\n chmod a+rx /opt/browser/lightpanda/lightpanda && /opt/browser/lightpanda/lightpanda version; \\\n else rm -f /opt/browser/lightpanda/lightpanda; echo \"runner image: lightpanda not installed for $arch - engine: lightpanda says so when asked\" >&2; fi\n# Obscura (engine: obscura): a headless browser in Rust around V8 that does\n# draw \u2014 screenshots, a raster PDF, a screencast \u2014 light like Lightpanda.\n# Apache-2.0. The plain build, not -stealth: this platform does not help a\n# page not see automation. Two binaries, obscura and obscura-worker, which\n# must sit side by side. Pinned by checksum; glibc 2.35 is its floor, so\n# Debian 13 (2.41) runs it. As above, a download is tried\n# ENGINE_DOWNLOAD_ATTEMPTS times, then a failed one leaves the engine out.\nRUN arch=$(uname -m) \\\n && case \"$arch\" in \\\n x86_64) sum=1534d1e6ddaf3d080ec4091eb41d0a4d8cc042a48b607d3c410fc13b482a9eec ;; \\\n aarch64) sum=5ecf980bca3060236a7a86ec7ed83d943e6598ee87caa46d20325d90bc75f979 ;; \\\n *) sum= ;; \\\n esac \\\n && mkdir -p /opt/browser/obscura \\\n && retry() { what=$1; shift; n=1; until \"$@\"; do if [ \"$n\" -ge 3 ]; then echo \"runner image: $what - download failed $n times, giving up\" >&2; return 1; fi; echo \"runner image: $what - download failed (attempt $n of 3), retrying in $((n * 15))s\" >&2; sleep $((n * 15)); n=$((n + 1)); done; } \\\n && fetch() { curl -fsSL -o /tmp/obscura.tgz \"https://github.com/h4ckf0r0day/obscura/releases/download/v0.2.3/obscura-$arch-linux.tar.gz\" \\\n && echo \"$sum /tmp/obscura.tgz\" | sha256sum -c - >/dev/null; } \\\n && if [ -n \"$sum\" ] && retry obscura fetch \\\n && tar -xzf /tmp/obscura.tgz -C /opt/browser/obscura obscura obscura-worker; then \\\n chmod a+rx /opt/browser/obscura/obscura /opt/browser/obscura/obscura-worker && /opt/browser/obscura/obscura --version; \\\n else rm -rf /opt/browser/obscura/*; echo \"runner image: obscura not installed for $arch - engine: obscura says so when asked\" >&2; fi \\\n && rm -f /tmp/obscura.tgz\n# What this image actually has, written down: /opt/browser/engines.json, one\n# entry per engine (its path and version, or null when the install above\n# left it out) plus Xvfb. Chromium's version is its own --version (dotted,\n# so FOLDRUN_RUNNER_ENGINES carries it: a pinned user_agent on engine\n# chromium is compared with it, not with Google Chrome's) then the build.\n# web browse reads it for its \"built without\" answer, and the deploy reads\n# it to report the engines beside the version.\n# On x86_64 a missing engine FAILS the build: every engine ships for that\n# arch, so a gap there is a failed download, and an image that quietly lacks\n# the Chrome or Lightpanda a desk names would fail those runs instead. A\n# failed build leaves the previous image running and says why. Elsewhere\n# (arm64 has no Google Chrome) the gap is recorded and the image ships.\nRUN node -e ' \\\n const fs = require(\"fs\"), cp = require(\"child_process\"), pw = require(\"playwright\"); \\\n const at = (p) => (p && fs.existsSync(p) ? p : null); \\\n const ver = (bin, args) => { try { return cp.execFileSync(bin, args, { timeout: 30000, stdio: [\"ignore\", \"pipe\", \"ignore\"] }).toString().trim().split(\"\\n\")[0] || null; } catch { return null; } }; \\\n const one = (p, v) => (p ? { path: p, version: v } : null); \\\n const pwBuild = (p) => (p ? (p.match(/(chromium|firefox|webkit)-(\\d+)/) || [])[0] || null : null); \\\n const lp = at(\"/opt/browser/lightpanda/lightpanda\"); \\\n const cr = at(pw.chromium.executablePath()); \\\n const ob = at(\"/opt/browser/obscura/obscura-worker\") && at(\"/opt/browser/obscura/obscura\"); \\\n const engines = { \\\n chromium: one(cr, cr && [ver(cr, [\"--version\"]), pwBuild(cr)].filter(Boolean).join(\" \")), \\\n chrome: one(at(\"/opt/google/chrome/chrome\"), ver(\"/opt/google/chrome/chrome\", [\"--version\"])), \\\n \"chrome-beta\": one(at(\"/opt/google/chrome-beta/chrome\"), ver(\"/opt/google/chrome-beta/chrome\", [\"--version\"])), \\\n firefox: one(at(pw.firefox.executablePath()), pwBuild(pw.firefox.executablePath())), \\\n webkit: one(at(pw.webkit.executablePath()), pwBuild(pw.webkit.executablePath())), \\\n lightpanda: one(lp, lp && ver(lp, [\"version\"])), \\\n obscura: one(ob, ob && ver(ob, [\"--version\"])), \\\n }; \\\n const xvfb = ver(\"sh\", [\"-c\", \"command -v Xvfb\"]); \\\n const arch = cp.execFileSync(\"uname\", [\"-m\"]).toString().trim(); \\\n const manifest = { arch, playwright: require(\"playwright/package.json\").version, engines, xvfb }; \\\n fs.writeFileSync(\"/opt/browser/engines.json\", JSON.stringify(manifest, null, 2) + \"\\n\"); \\\n console.log(JSON.stringify(manifest)); \\\n const missing = [\"chromium\", \"chrome\", \"firefox\", \"webkit\", \"lightpanda\", \"obscura\"].filter((e) => !engines[e]).concat(xvfb ? [] : [\"Xvfb\"]); \\\n if (missing.length && arch === \"x86_64\") { \\\n console.error(\"runner image: MISSING ENGINES on x86_64: \" + missing.join(\", \")); \\\n console.error(\"runner image: every engine ships for x86_64, so a missing one is a failed download (the retry lines above say which) - failing the build\"); \\\n process.exit(1); \\\n } \\\n if (missing.length) console.error(\"runner image: built without \" + missing.join(\", \") + \" on \" + arch); \\\n ' \\\n && chmod a+r /opt/browser/engines.json\n\nFROM browsers AS full\nWORKDIR /opt/runner\nCOPY --from=core --chown=agent:agent /opt/runner/ ./\nCOPY --chown=agent:agent driver.mjs entry.sh ./\nRUN mkdir -p /workspace /library /opt/runner/job /home/agent/.foldrun/runner/.runtimes /opt/foldrun-runtimes/shared/.runtimes \\\n && chown agent:agent /opt/runner \\\n && chown -R agent:agent /workspace /library /opt/runner/job /home/agent/.foldrun /opt/foldrun-runtimes \\\n && chmod +x /opt/runner/entry.sh\nENTRYPOINT [\"/opt/runner/entry.sh\"]\n";
|
|
421
|
+
/** Which definition of the OS part this core holds: 16 hex of the sha256 of
|
|
422
|
+
* its text. A base image carries it (label io.foldrun.runner-os and
|
|
423
|
+
* /etc/foldrun-runner-os); a base from another definition is refused. */
|
|
424
|
+
export declare const RUNNER_OS_ID: string;
|
|
425
|
+
/** The runner's OS part on its own — what the base image is built from
|
|
426
|
+
* (targets RUNNER_OS_TARGETS). No build context: it copies nothing local. */
|
|
427
|
+
export declare const RUNNER_OS_DOCKERFILE: string;
|
|
428
|
+
/** The OS part's build target for each runner variant. */
|
|
429
|
+
export declare const RUNNER_OS_TARGETS: {
|
|
430
|
+
readonly slim: "slim-os";
|
|
431
|
+
readonly full: "browsers";
|
|
432
|
+
};
|
|
433
|
+
/** The base images a runner is built FROM, by digest, one per variant. */
|
|
434
|
+
export type RunnerBase = {
|
|
435
|
+
slim: string;
|
|
436
|
+
full: string;
|
|
437
|
+
};
|
|
438
|
+
/**
|
|
439
|
+
* The runner base from FOLDRUN_RUNNER_BASE_SLIM and FOLDRUN_RUNNER_BASE_FULL:
|
|
440
|
+
* both or neither (empty counts as unset, as FOLDRUN_RUNNER_IMAGE does), each
|
|
441
|
+
* an image by digest — a tag would let the same runner tag hold another
|
|
442
|
+
* base's bytes. Anything else throws: a half-set base is a broken deploy,
|
|
443
|
+
* not a reason to quietly build the OS again.
|
|
444
|
+
*/
|
|
445
|
+
export declare function runnerBase(env?: NodeJS.ProcessEnv): RunnerBase | null;
|
|
446
|
+
/**
|
|
447
|
+
* The runner's Dockerfile: with no base, the OS part and the app part in one
|
|
448
|
+
* file (a self-contained build); with one, the app part FROM the base's two
|
|
449
|
+
* images. The app part's text is the same either way.
|
|
450
|
+
*/
|
|
451
|
+
export declare function runnerDockerfile(base?: RunnerBase | null): string;
|
|
452
|
+
/** The self-contained runner Dockerfile (no base): runnerDockerfile(). */
|
|
453
|
+
export declare const DOCKERFILE: string;
|
|
454
|
+
/** The docker run container's entrypoint (entry.sh), exported for its tests. */
|
|
455
|
+
export declare const ENTRY: string;
|
|
374
456
|
/** Which build target of the runner image (see DOCKERFILE). */
|
|
375
457
|
export type RunnerVariant = "full" | "slim";
|
|
376
458
|
export declare function runnerImageTag(variant?: RunnerVariant): string;
|
|
@@ -547,8 +629,10 @@ export interface WriteDivert {
|
|
|
547
629
|
/**
|
|
548
630
|
* What crosses into the container as its environment, and how.
|
|
549
631
|
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
632
|
+
* It crosses as a file the agent's shell sources after the drop (env.sh,
|
|
633
|
+
* FOL-130); until then it was a docker --env-file, one `KEY=value` per
|
|
634
|
+
* line, which cannot carry a newline — and what a step sees stays the shape
|
|
635
|
+
* that file set. @file secrets are multi-line by nature (a PEM key, a cert), so
|
|
552
636
|
* they are staged as files NOW, into the copied-in workspace, and the env
|
|
553
637
|
* carries the container path — the one place a path is stable across the
|
|
554
638
|
* boundary. A plain secret whose value happens to hold a newline gets the
|