@foldrun/core 14.4.0 → 15.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/browse-egress.d.ts +45 -4
- package/dist/src/browse-egress.js +58 -16
- package/dist/src/platform.d.ts +15 -1
- package/dist/src/run-container.d.ts +4 -19
- package/dist/src/run-container.js +4 -20
- package/dist/src/runner.js +44 -12
- package/dist/src/startup.d.ts +61 -0
- package/dist/src/startup.js +86 -0
- package/dist/src/store.d.ts +4 -1
- package/dist/src/store.js +9 -3
- package/dist/src/trigger-log.d.ts +11 -1
- package/dist/src/trigger-log.js +12 -0
- package/dist/src/triggers.js +3 -2
- package/package.json +1 -1
- package/src/browse-egress.ts +88 -17
- package/src/platform.ts +13 -1
- package/src/run-container.ts +4 -22
- package/src/runner.ts +44 -12
- package/src/startup.ts +106 -0
- package/src/store.ts +12 -5
- package/src/trigger-log.ts +17 -0
- package/src/triggers.ts +3 -2
|
@@ -1,11 +1,52 @@
|
|
|
1
|
-
import { type NetworkPolicy } from "./network.ts";
|
|
1
|
+
import { type NetworkLevel, type NetworkPolicy } from "./network.ts";
|
|
2
2
|
export type BrowseTier = "hosted" | "vendor" | "none";
|
|
3
|
+
/** Set to "1" in a browsing step held to its list (browseVerdict "hosted"):
|
|
4
|
+
* the web tool gives its browser the forward door as launch options and
|
|
5
|
+
* refuses what cannot go through it; the platform starts no account browser
|
|
6
|
+
* pod for the step (its pod could not reach one, and that pod is not walled). */
|
|
7
|
+
export declare const BROWSER_CONFINED_ENV = "FOLDRUN_BROWSER_CONFINED";
|
|
8
|
+
/** The vendor a `web.browse` value names (the runner's FOLDRUN_BROWSER_VENDOR),
|
|
9
|
+
* or null for foldrun's own browser — read the way runner.ts reads it. */
|
|
10
|
+
export declare function browseVendorOf(browse: unknown): string | null;
|
|
3
11
|
/** Which tier a step's browser falls in: no vendor (or foldrun) is ours. */
|
|
4
12
|
export declare function browseTier(vendor: string | null | undefined): {
|
|
5
13
|
tier: BrowseTier;
|
|
6
14
|
title: string;
|
|
7
15
|
};
|
|
16
|
+
/** How one browsing step is held to its `network:` list:
|
|
17
|
+
*
|
|
18
|
+
* legacy — as before phase 3: no forward proxy, the pod keeps the world,
|
|
19
|
+
* and the trace says the list does not hold. An open list, a
|
|
20
|
+
* report-only install, or an executor that cannot wall the
|
|
21
|
+
* step's network.
|
|
22
|
+
* hosted — enforced: the step gets the forward proxy, its pod is walled
|
|
23
|
+
* to the egress proxy and DNS, and foldrun's browser runs in it.
|
|
24
|
+
* refuse — a vendor's browser under a restricted, enforced list on an
|
|
25
|
+
* install that holds browsing: it browses from the vendor's
|
|
26
|
+
* network, which nothing here can hold to the list, so the step
|
|
27
|
+
* is refused before anything connects (decision 4). */
|
|
28
|
+
export type BrowseVerdict = {
|
|
29
|
+
kind: "legacy";
|
|
30
|
+
} | {
|
|
31
|
+
kind: "hosted";
|
|
32
|
+
} | {
|
|
33
|
+
kind: "refuse";
|
|
34
|
+
message: string;
|
|
35
|
+
};
|
|
36
|
+
export declare function browseVerdict(o: {
|
|
37
|
+
/** The step's resolved level (network.ts). */
|
|
38
|
+
level: NetworkLevel;
|
|
39
|
+
/** Will the proxy refuse a site off the list (lease.enforce)? */
|
|
40
|
+
enforce: boolean;
|
|
41
|
+
/** FOLDRUN_BROWSER_VENDOR: the vendor the agent named, if any. */
|
|
42
|
+
vendor: string | null | undefined;
|
|
43
|
+
/** Can this executor wall the step's network (Platform.confinesBrowsing)? */
|
|
44
|
+
confines: boolean;
|
|
45
|
+
}): BrowseVerdict;
|
|
8
46
|
/** The trace's network line for a step that may browse, on an install with
|
|
9
|
-
* an egress proxy: the step's list, and
|
|
10
|
-
*
|
|
11
|
-
|
|
47
|
+
* an egress proxy: the step's list, and whether it holds — `hosted` when
|
|
48
|
+
* browseVerdict put the step under the wall, else the plain fact that it
|
|
49
|
+
* does not hold yet, for the browser or anything else in the step. */
|
|
50
|
+
export declare function browseNetworkLine(policy: NetworkPolicy, vendor: string | null | undefined, opts?: {
|
|
51
|
+
hosted?: boolean;
|
|
52
|
+
}): string;
|
|
@@ -1,22 +1,42 @@
|
|
|
1
1
|
// Browsing and `network:` (FOL-110, foldrun-docs/proposals/browse-egress.md).
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
// gives it no forward proxy (a browser in the sandbox cannot send credentials
|
|
5
|
-
// written into a proxy URL), so the browser — and every other program in that
|
|
6
|
-
// step — reaches sites directly. Until the browse service and hosted
|
|
7
|
-
// enforcement ship, the trace says so plainly, and says which of the three
|
|
8
|
-
// tiers this step's browser will fall in:
|
|
3
|
+
// Three tiers, said in the trace:
|
|
9
4
|
//
|
|
10
5
|
// hosted — foldrun's own browser (the account's browser pod, Lightpanda,
|
|
11
|
-
// Obscura, a live session): our network boundary
|
|
6
|
+
// Obscura, a live session): our network boundary confines it.
|
|
12
7
|
// vendor — a vendor that takes a customer proxy (Browserbase, Steel,
|
|
13
8
|
// Hyperbrowser, Browserless): through the egress proxy, enforced
|
|
14
|
-
// once that vendor is qualified by our own tests.
|
|
9
|
+
// once that vendor is qualified by our own tests (phase 4).
|
|
15
10
|
// none — a vendor that always browses through its own network (Bright
|
|
16
11
|
// Data, ZenRows) or any DevTools address: never enforced; a
|
|
17
|
-
// restricted, enforced `network:`
|
|
18
|
-
|
|
12
|
+
// restricted, enforced `network:` refuses it.
|
|
13
|
+
//
|
|
14
|
+
// Phase 3 (hosted enforcement) holds a browsing step to its list where the
|
|
15
|
+
// executor can wall the step's network (the k8s tier, with the install's
|
|
16
|
+
// FOLDRUN_BROWSE_ENFORCE=1 — Platform.confinesBrowsing). Such a step gets the
|
|
17
|
+
// forward proxy like any other, so its run pod is `filtered`: it reaches the
|
|
18
|
+
// egress proxy and DNS and nothing else, and the browser runs inside it, in
|
|
19
|
+
// the step's own pod. A client that sets another proxy, a CDP context with
|
|
20
|
+
// its own proxyServer, a curl that ignores HTTPS_PROXY — each finds no route,
|
|
21
|
+
// never a way round the list. Not covered: DNS lookups through the cluster's
|
|
22
|
+
// resolver, which the wall admits and nothing here restricts. browseVerdict
|
|
23
|
+
// says, for one step, which of the three ways it goes; everywhere else (no
|
|
24
|
+
// wall, an open or report-only list) the step browses as it did before
|
|
25
|
+
// phase 3, and the trace says so.
|
|
26
|
+
import { findBrowserApi, readBrowseSettings, resolveSearch } from "./providers.js";
|
|
19
27
|
import { networkLine } from "./network.js";
|
|
28
|
+
/** Set to "1" in a browsing step held to its list (browseVerdict "hosted"):
|
|
29
|
+
* the web tool gives its browser the forward door as launch options and
|
|
30
|
+
* refuses what cannot go through it; the platform starts no account browser
|
|
31
|
+
* pod for the step (its pod could not reach one, and that pod is not walled). */
|
|
32
|
+
export const BROWSER_CONFINED_ENV = "FOLDRUN_BROWSER_CONFINED";
|
|
33
|
+
/** The vendor a `web.browse` value names (the runner's FOLDRUN_BROWSER_VENDOR),
|
|
34
|
+
* or null for foldrun's own browser — read the way runner.ts reads it. */
|
|
35
|
+
export function browseVendorOf(browse) {
|
|
36
|
+
const read = readBrowseSettings(browse);
|
|
37
|
+
const choice = resolveSearch(read.rest, "browse");
|
|
38
|
+
return choice.shape === "direct" && choice.provider ? choice.provider : null;
|
|
39
|
+
}
|
|
20
40
|
/** Which tier a step's browser falls in: no vendor (or foldrun) is ours. */
|
|
21
41
|
export function browseTier(vendor) {
|
|
22
42
|
const name = (vendor ?? "").trim().toLowerCase();
|
|
@@ -27,15 +47,37 @@ export function browseTier(vendor) {
|
|
|
27
47
|
return { tier: "none", title: name };
|
|
28
48
|
return { tier: api.egress === "proxy" ? "vendor" : "none", title: api.title };
|
|
29
49
|
}
|
|
50
|
+
export function browseVerdict(o) {
|
|
51
|
+
if (o.level === "open" || !o.enforce || !o.confines)
|
|
52
|
+
return { kind: "legacy" };
|
|
53
|
+
const { tier, title } = browseTier(o.vendor);
|
|
54
|
+
if (tier === "hosted")
|
|
55
|
+
return { kind: "hosted" };
|
|
56
|
+
const why = tier === "vendor"
|
|
57
|
+
? `${title} browses from its own network, and foldrun cannot hold it to network: until that vendor is qualified (FOL-110 phase 4)`
|
|
58
|
+
: `${title} always browses through its own network, and nothing can hold it to network:`;
|
|
59
|
+
return {
|
|
60
|
+
kind: "refuse",
|
|
61
|
+
message: `browse: refused before it connected — this step's network: ${o.level} is enforced, and ${why}. ` +
|
|
62
|
+
`Drop browse: ${(o.vendor ?? "").trim()} from the agent's web: block to browse with foldrun's own browser, which is held to the list; ` +
|
|
63
|
+
`or, to accept browsing that no list holds for this one agent, give that agent network: open.`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
30
66
|
/** The trace's network line for a step that may browse, on an install with
|
|
31
|
-
* an egress proxy: the step's list, and
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
|
|
67
|
+
* an egress proxy: the step's list, and whether it holds — `hosted` when
|
|
68
|
+
* browseVerdict put the step under the wall, else the plain fact that it
|
|
69
|
+
* does not hold yet, for the browser or anything else in the step. */
|
|
70
|
+
export function browseNetworkLine(policy, vendor, opts = {}) {
|
|
35
71
|
const what = networkLine(policy, true);
|
|
36
|
-
|
|
72
|
+
if (opts.hosted) {
|
|
73
|
+
return `${what} — enforced — hosted: the browser runs inside this step's sandbox, whose network reaches only the egress proxy (which holds the list) and DNS, so a page, a script or a changed proxy setting reaches no site off the list; DNS lookups themselves are not restricted.`;
|
|
74
|
+
}
|
|
75
|
+
const { tier, title } = browseTier(vendor);
|
|
76
|
+
const now = " — not enforced in this step: it may browse, and browsing does not go through the egress proxy here, so the browser and every other program in this step reach sites directly";
|
|
37
77
|
const later = tier === "hosted"
|
|
38
|
-
?
|
|
78
|
+
? policy.level === "open"
|
|
79
|
+
? `. Its browser is ${title}; with an open list there is nothing to hold it to`
|
|
80
|
+
: `. Its browser is ${title}: it is held to network: on an install that confines browsing, with the list enforced (FOL-110)`
|
|
39
81
|
: tier === "vendor"
|
|
40
82
|
? `. Its browser (${title}) browses from the vendor's network: it comes under network: through the egress proxy once that vendor is qualified (FOL-110)`
|
|
41
83
|
: `. Its browser (${title}) always browses through its own network and cannot be held to network: — a restricted, enforced network: will refuse it (FOL-110)`;
|
package/dist/src/platform.d.ts
CHANGED
|
@@ -83,9 +83,13 @@ export interface PlatformHooks {
|
|
|
83
83
|
* recorded — the delivery as seen, the throttle window — so the sender's
|
|
84
84
|
* retry is a fresh event rather than a "duplicate" of a run that never
|
|
85
85
|
* existed. Default: nothing, because the default gate records nothing. */
|
|
86
|
-
rollbackTrigger(tenant: string, workspace: string, flow: FlowInfo,
|
|
86
|
+
rollbackTrigger(tenant: string, workspace: string, flow: FlowInfo,
|
|
87
|
+
/** `code`: the refusal's own code, when it had one — `waiting_cap`
|
|
88
|
+
* is logged as `queue-full` rather than `failed`. */
|
|
89
|
+
opts?: {
|
|
87
90
|
deliveryKey?: string | null;
|
|
88
91
|
reason?: string;
|
|
92
|
+
code?: string;
|
|
89
93
|
}): Promise<void>;
|
|
90
94
|
/** Step executors by FOLDRUN_RUN_ISOLATION value, beyond the `container`
|
|
91
95
|
* one core ships. The platform adds `k8s`. */
|
|
@@ -148,6 +152,16 @@ export interface PlatformHooks {
|
|
|
148
152
|
* only where no provider: block of the account's own says otherwise.
|
|
149
153
|
* Absent: nobody can (a laptop, a self-hosted install). */
|
|
150
154
|
modelSupply?(tenant: string): SupplyAnswer;
|
|
155
|
+
/**
|
|
156
|
+
* Does this isolation mode wall a step's network to the egress proxy and
|
|
157
|
+
* DNS when its `network:` is restricted and enforced — and is browsing
|
|
158
|
+
* put under that wall (FOL-110 phase 3, browse-egress.ts browseVerdict)?
|
|
159
|
+
* True: a browsing step gets the forward proxy like any other and its
|
|
160
|
+
* browser runs inside the walled sandbox, so the list holds for it.
|
|
161
|
+
* Absent or false: a browsing step browses as before phase 3, said in the
|
|
162
|
+
* trace as not enforced.
|
|
163
|
+
*/
|
|
164
|
+
confinesBrowsing?(isolation: string): boolean;
|
|
151
165
|
/**
|
|
152
166
|
* An operator setting, by the environment variable that used to hold it
|
|
153
167
|
* (30 Oct 2026): the platform answers with the operator's value where one
|
|
@@ -10,6 +10,7 @@ import { type RuntimeSpec } from "./runtime.ts";
|
|
|
10
10
|
import { type NetworkLevel } from "./network.ts";
|
|
11
11
|
import { type ResourceOverride } from "./resources.ts";
|
|
12
12
|
import type { ScriptSpec } from "./script-tools.ts";
|
|
13
|
+
import { STARTUP_PHASES, type StartupPhase, type StartupPhases } from "./startup.ts";
|
|
13
14
|
import type { ConsultSpec } from "./agent-tools.ts";
|
|
14
15
|
import type { DelegateSpec, SubagentSpec } from "./subagents.ts";
|
|
15
16
|
import { type OperatorEvent } from "./operator.ts";
|
|
@@ -131,25 +132,9 @@ export interface StepTiming {
|
|
|
131
132
|
* first driver's phases are on the record already). */
|
|
132
133
|
phases?: StartupPhases;
|
|
133
134
|
}
|
|
134
|
-
/**
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
* two neighbours is what the later one cost (FOL-29: "pod ready" was the
|
|
138
|
-
* only number, and the six seconds after it had no names).
|
|
139
|
-
*
|
|
140
|
-
* The executor marks its own: `services` (the account's search/browser pods
|
|
141
|
-
* up), `room` (room on the cluster to start — platform pod-room.ts),
|
|
142
|
-
* `applied` (pod created), `ready`, `files` (the workspace copied in),
|
|
143
|
-
* `go` (the step released). The sandbox marks the rest as `{"e":"mark"}`
|
|
144
|
-
* lines: `shim` (the shim saw go), `system` (system packages restored),
|
|
145
|
-
* `driver` (node up), `imports` (core loaded), `tools` (runtime and tools
|
|
146
|
-
* built, the SDK about to start) and `model` (the model's first text or tool
|
|
147
|
-
* call). A worker that predates a mark ignores the line — parseDriverLine
|
|
148
|
-
* answers null for an `e` it does not know.
|
|
149
|
-
*/
|
|
150
|
-
export declare const STARTUP_PHASES: readonly ["services", "room", "applied", "ready", "files", "go", "shim", "system", "driver", "imports", "tools", "model"];
|
|
151
|
-
export type StartupPhase = (typeof STARTUP_PHASES)[number];
|
|
152
|
-
export type StartupPhases = Partial<Record<StartupPhase, number>>;
|
|
135
|
+
/** The start-up phases and what each marks — startup.ts, where every
|
|
136
|
+
* surface that shows them reads them from (FOL-74). */
|
|
137
|
+
export { STARTUP_PHASES, type StartupPhase, type StartupPhases };
|
|
153
138
|
/** A sandbox-side mark: which phase ended, and when (epoch ms, the
|
|
154
139
|
* sandbox's clock — the same machine's as the worker's on one node). */
|
|
155
140
|
export declare function parseDriverMark(line: string): {
|
|
@@ -31,28 +31,12 @@ import { isFileValue, fileContent } from "./secrets.js";
|
|
|
31
31
|
import { safeTenantSegment, systemInstallSh, SYSTEM_FROM_INPUT_SH, INSTALL_SOCKET } from "./runtime.js";
|
|
32
32
|
import { egressCaSh } from "./network.js";
|
|
33
33
|
import { anyMemoryMi, quantityMi } from "./resources.js";
|
|
34
|
+
import { STARTUP_PHASES } from "./startup.js";
|
|
34
35
|
import { isOperatorEvent } from "./operator.js";
|
|
35
36
|
import { parseBrowserPod } from "./browser-pod.js";
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
* two neighbours is what the later one cost (FOL-29: "pod ready" was the
|
|
40
|
-
* only number, and the six seconds after it had no names).
|
|
41
|
-
*
|
|
42
|
-
* The executor marks its own: `services` (the account's search/browser pods
|
|
43
|
-
* up), `room` (room on the cluster to start — platform pod-room.ts),
|
|
44
|
-
* `applied` (pod created), `ready`, `files` (the workspace copied in),
|
|
45
|
-
* `go` (the step released). The sandbox marks the rest as `{"e":"mark"}`
|
|
46
|
-
* lines: `shim` (the shim saw go), `system` (system packages restored),
|
|
47
|
-
* `driver` (node up), `imports` (core loaded), `tools` (runtime and tools
|
|
48
|
-
* built, the SDK about to start) and `model` (the model's first text or tool
|
|
49
|
-
* call). A worker that predates a mark ignores the line — parseDriverLine
|
|
50
|
-
* answers null for an `e` it does not know.
|
|
51
|
-
*/
|
|
52
|
-
export const STARTUP_PHASES = [
|
|
53
|
-
"services", "room", "applied", "ready", "files", "go",
|
|
54
|
-
"shim", "system", "driver", "imports", "tools", "model",
|
|
55
|
-
];
|
|
37
|
+
/** The start-up phases and what each marks — startup.ts, where every
|
|
38
|
+
* surface that shows them reads them from (FOL-74). */
|
|
39
|
+
export { STARTUP_PHASES };
|
|
56
40
|
/** A sandbox-side mark: which phase ended, and when (epoch ms, the
|
|
57
41
|
* sandbox's clock — the same machine's as the worker's on one node). */
|
|
58
42
|
export function parseDriverMark(line) {
|
package/dist/src/runner.js
CHANGED
|
@@ -48,7 +48,7 @@ import { PromptLayers, promptCacheKey } from "./prompt-layers.js";
|
|
|
48
48
|
import { loadCatalog, checkModel, clampEffort, catalogCost, findModel, tokenPriceOf } from "./catalog.js";
|
|
49
49
|
import { resolveSecrets, getSecret, materializeSecrets, secretSites, isClientCertValue, clientCertOf, withoutHeldCerts, isIdentityValue, identityOf } from "./secrets.js";
|
|
50
50
|
import { resolveNetwork, networkLine, networkEnforceWanted, proxyEnv, siteCovers, EGRESS_CA_ENV } from "./network.js";
|
|
51
|
-
import { browseNetworkLine } from "./browse-egress.js";
|
|
51
|
+
import { BROWSER_CONFINED_ENV, browseNetworkLine, browseVerdict } from "./browse-egress.js";
|
|
52
52
|
import { materializeFileSecrets, cleanupFileSecrets } from "./secret-files.js";
|
|
53
53
|
import { buildApiTools, secretsUsedByApi } from "./api-tools.js";
|
|
54
54
|
import { buildA2ATools } from "./a2a-tools.js";
|
|
@@ -2827,6 +2827,27 @@ mayDefer) {
|
|
|
2827
2827
|
save();
|
|
2828
2828
|
return;
|
|
2829
2829
|
}
|
|
2830
|
+
// A step that may browse, on an install with the forward door: held to
|
|
2831
|
+
// its list where the executor walls the step's network, refused when
|
|
2832
|
+
// it names a vendor that list cannot hold, else as before phase 3
|
|
2833
|
+
// (browse-egress.ts browseVerdict, FOL-110).
|
|
2834
|
+
const browses = scriptSpecs.some((sc) => sc.name === "web") && (!web.actions || web.actions.includes("browse"));
|
|
2835
|
+
const browse = browses && lease?.proxy
|
|
2836
|
+
? browseVerdict({
|
|
2837
|
+
level: network.level,
|
|
2838
|
+
enforce: lease.enforce === true,
|
|
2839
|
+
vendor: clockEnv.FOLDRUN_BROWSER_VENDOR,
|
|
2840
|
+
confines: !!isolation && platform.confinesBrowsing?.(isolation) === true,
|
|
2841
|
+
})
|
|
2842
|
+
: null;
|
|
2843
|
+
if (lease && browse?.kind === "refuse") {
|
|
2844
|
+
push("info", networkLine(network, true));
|
|
2845
|
+
push("error", browse.message);
|
|
2846
|
+
await lease.release();
|
|
2847
|
+
step.status = "failed";
|
|
2848
|
+
save();
|
|
2849
|
+
return;
|
|
2850
|
+
}
|
|
2830
2851
|
// Serve those jobs while this step runs: each one becomes a step of
|
|
2831
2852
|
// its own (delegateJob), and the door answers the long-poll with its
|
|
2832
2853
|
// reply. No proxy, or a platform without the door: not offered — the
|
|
@@ -2851,16 +2872,18 @@ mayDefer) {
|
|
|
2851
2872
|
// The forward door: every program in the sandbox sends through the
|
|
2852
2873
|
// proxy, which holds the site list and fills bound secrets. A proxy
|
|
2853
2874
|
// without the door (an older platform) leaves programs going direct.
|
|
2854
|
-
// A step that may browse gets no proxy variables
|
|
2855
|
-
// reads HTTPS_PROXY too, and
|
|
2856
|
-
// into a proxy URL — every
|
|
2857
|
-
// (14 Oct 2026, the reel
|
|
2858
|
-
//
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
//
|
|
2862
|
-
|
|
2863
|
-
|
|
2875
|
+
// A step that may browse gets no proxy variables unless it is held
|
|
2876
|
+
// (browse.kind "hosted"): the browser in it reads HTTPS_PROXY too, and
|
|
2877
|
+
// Chromium cannot send credentials written into a proxy URL — every
|
|
2878
|
+
// page failed ERR_INVALID_AUTH_CREDENTIALS (14 Oct 2026, the reel
|
|
2879
|
+
// posters). A held step's web tool hands the browser the proxy and its
|
|
2880
|
+
// credential as launch options instead (FOLDRUN_BROWSER_CONFINED).
|
|
2881
|
+
// Every other browsing step is open by default, and its bound secrets
|
|
2882
|
+
// materialise as they did before the door.
|
|
2883
|
+
const forward = lease?.proxy && (!browses || browse?.kind === "hosted") ? lease : null;
|
|
2884
|
+
// A browsing step on an install with the door says whether it is held
|
|
2885
|
+
// to its list, and which tier its browser falls in (browse-egress.ts).
|
|
2886
|
+
push("info", browse ? browseNetworkLine(network, clockEnv.FOLDRUN_BROWSER_VENDOR, { hosted: browse.kind === "hosted" }) : networkLine(network, forward ? forward.enforce === true : null));
|
|
2864
2887
|
const bound = forward ? Object.keys(boundSites).filter((name) => name in liveSecrets) : [];
|
|
2865
2888
|
for (const name of bound) {
|
|
2866
2889
|
for (const site of boundSites[name])
|
|
@@ -3084,11 +3107,20 @@ mayDefer) {
|
|
|
3084
3107
|
// Every program's HTTP(S) through the proxy's forward door, and
|
|
3085
3108
|
// the CA it signs bound sites with, for the sandbox to trust.
|
|
3086
3109
|
...(forward ? proxyEnv(forward.proxy) : {}),
|
|
3110
|
+
// A browsing step held to its list: the web tool gives its
|
|
3111
|
+
// browser the forward door as launch options, refuses what
|
|
3112
|
+
// cannot go through it, and the platform starts no account
|
|
3113
|
+
// browser pod for it (browse-egress.ts, FOL-110 phase 3).
|
|
3114
|
+
...(browse?.kind === "hosted" ? { [BROWSER_CONFINED_ENV]: "1" } : {}),
|
|
3087
3115
|
// Only a step with a bound secret has a site the proxy
|
|
3088
3116
|
// intercepts, so only that step's TLS clients are pointed at a
|
|
3089
3117
|
// bundle with the egress CA in it; every other step's are as
|
|
3090
3118
|
// they always were.
|
|
3091
|
-
|
|
3119
|
+
// A browser held to its list (browse "hosted") meets the proxy's
|
|
3120
|
+
// leaf on any host a secret is granted to — an api tool's, a web
|
|
3121
|
+
// provider's — not only a bound site, so it is handed the CA
|
|
3122
|
+
// whenever the step has one: the web tool trusts it for Chromium.
|
|
3123
|
+
...(forward?.ca && (bound.length || (browse?.kind === "hosted" && Object.keys(grant.secrets).length)) ? { [EGRESS_CA_ENV]: Buffer.from(forward.ca).toString("base64") } : {}),
|
|
3092
3124
|
...clockEnv,
|
|
3093
3125
|
// Who is running: the in-process path stamps scripts with these
|
|
3094
3126
|
// host-side, but a container rebuilds its tools from its own
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The start-up of one step, in the order it happens. Each is the moment the
|
|
3
|
+
* phase ENDED, in ms since the executor began the step (seconds on the step
|
|
4
|
+
* record), so the gap between two neighbours is what the later one cost
|
|
5
|
+
* (FOL-29: "pod ready" was the only number, and the six seconds after it had
|
|
6
|
+
* no names).
|
|
7
|
+
*
|
|
8
|
+
* The executor marks its own: `services` (the account's search/browser pods
|
|
9
|
+
* up), `room` (room on the cluster to start — platform pod-room.ts),
|
|
10
|
+
* `applied` (pod created), `ready`, `files` (the workspace copied in),
|
|
11
|
+
* `go` (the step released). The sandbox marks the rest as `{"e":"mark"}`
|
|
12
|
+
* lines: `shim` (the shim saw go), `system` (system packages restored),
|
|
13
|
+
* `driver` (node up), `imports` (core loaded), `tools` (runtime and tools
|
|
14
|
+
* built, the SDK about to start) and `model` (the model's first text or tool
|
|
15
|
+
* call). A worker that predates a mark ignores the line — parseDriverLine
|
|
16
|
+
* answers null for an `e` it does not know.
|
|
17
|
+
*
|
|
18
|
+
* `services` is the one phase that may not be in line: since FOL-46 the
|
|
19
|
+
* account's search and browser pods boot ALONGSIDE the step pod, and `go`
|
|
20
|
+
* waits for both. See startupBreakdown.
|
|
21
|
+
*/
|
|
22
|
+
export declare const STARTUP_PHASES: readonly ["services", "room", "applied", "ready", "files", "go", "shim", "system", "driver", "imports", "tools", "model"];
|
|
23
|
+
export type StartupPhase = (typeof STARTUP_PHASES)[number];
|
|
24
|
+
export type StartupPhases = Partial<Record<StartupPhase, number>>;
|
|
25
|
+
/** One phase of one step's start-up, placed on its lane. */
|
|
26
|
+
export interface StartupSpan {
|
|
27
|
+
phase: StartupPhase;
|
|
28
|
+
/** When the phase could begin, counted from the step's start. */
|
|
29
|
+
from: number;
|
|
30
|
+
/** When it ended — the mark itself. */
|
|
31
|
+
at: number;
|
|
32
|
+
/** Its own share: `at − from`, never negative. */
|
|
33
|
+
took: number;
|
|
34
|
+
/** It ran alongside the step pod's own phases rather than before them —
|
|
35
|
+
* `services` on a run whose search or browser pod was still booting
|
|
36
|
+
* when the step pod was up (FOL-46). */
|
|
37
|
+
parallel: boolean;
|
|
38
|
+
/** How long this phase sat ready to start but held back by a parallel
|
|
39
|
+
* lane — `go` behind a `services` that was still booting. 0 otherwise. */
|
|
40
|
+
waited: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A step's start-up marks as spans, overlap-aware (FOL-74).
|
|
44
|
+
*
|
|
45
|
+
* Every phase but `services` runs in line: each starts when the one marked
|
|
46
|
+
* before it ended. `services` either comes first — no services, or ones
|
|
47
|
+
* awaited before the step pod was asked for, and its mark lands before the
|
|
48
|
+
* pod's first — or, when it was marked after the pod's first phase, it ran in
|
|
49
|
+
* parallel from the step's start: its span is 0 → its mark, the pod's lane
|
|
50
|
+
* starts at 0 as well, and `go` (which the gate holds until every service is
|
|
51
|
+
* up) starts at the later of the two lanes, the difference being `waited`.
|
|
52
|
+
* (The executor re-marks `services` at the gate and keeps no earlier mark,
|
|
53
|
+
* so on such a run the staging before the pod is asked for falls in the
|
|
54
|
+
* pod lane's first phase, usually `room`, rather than in `services`.)
|
|
55
|
+
*
|
|
56
|
+
* Subtracting neighbours in STARTUP_PHASES order instead gave the overlapped
|
|
57
|
+
* run's `services` the pod's boot as well, and every phase it overlapped
|
|
58
|
+
* +0.00s. Missing and non-finite marks are skipped; a later mark that reads
|
|
59
|
+
* earlier than the one before it (two clocks) takes 0, never a negative.
|
|
60
|
+
*/
|
|
61
|
+
export declare function startupBreakdown(marks: Record<string, unknown> | null | undefined): StartupSpan[];
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Where a step's start-up went, phase by phase (FOL-29), read the same way
|
|
2
|
+
// by every surface that shows it: the platform's Observe report (and through
|
|
3
|
+
// its API the CLI's `foldrun observe`) and the run page's start-up chip.
|
|
4
|
+
//
|
|
5
|
+
// Pure and import-free, so the dashboard can load it in the browser.
|
|
6
|
+
/**
|
|
7
|
+
* The start-up of one step, in the order it happens. Each is the moment the
|
|
8
|
+
* phase ENDED, in ms since the executor began the step (seconds on the step
|
|
9
|
+
* record), so the gap between two neighbours is what the later one cost
|
|
10
|
+
* (FOL-29: "pod ready" was the only number, and the six seconds after it had
|
|
11
|
+
* no names).
|
|
12
|
+
*
|
|
13
|
+
* The executor marks its own: `services` (the account's search/browser pods
|
|
14
|
+
* up), `room` (room on the cluster to start — platform pod-room.ts),
|
|
15
|
+
* `applied` (pod created), `ready`, `files` (the workspace copied in),
|
|
16
|
+
* `go` (the step released). The sandbox marks the rest as `{"e":"mark"}`
|
|
17
|
+
* lines: `shim` (the shim saw go), `system` (system packages restored),
|
|
18
|
+
* `driver` (node up), `imports` (core loaded), `tools` (runtime and tools
|
|
19
|
+
* built, the SDK about to start) and `model` (the model's first text or tool
|
|
20
|
+
* call). A worker that predates a mark ignores the line — parseDriverLine
|
|
21
|
+
* answers null for an `e` it does not know.
|
|
22
|
+
*
|
|
23
|
+
* `services` is the one phase that may not be in line: since FOL-46 the
|
|
24
|
+
* account's search and browser pods boot ALONGSIDE the step pod, and `go`
|
|
25
|
+
* waits for both. See startupBreakdown.
|
|
26
|
+
*/
|
|
27
|
+
export const STARTUP_PHASES = [
|
|
28
|
+
"services", "room", "applied", "ready", "files", "go",
|
|
29
|
+
"shim", "system", "driver", "imports", "tools", "model",
|
|
30
|
+
];
|
|
31
|
+
/**
|
|
32
|
+
* A step's start-up marks as spans, overlap-aware (FOL-74).
|
|
33
|
+
*
|
|
34
|
+
* Every phase but `services` runs in line: each starts when the one marked
|
|
35
|
+
* before it ended. `services` either comes first — no services, or ones
|
|
36
|
+
* awaited before the step pod was asked for, and its mark lands before the
|
|
37
|
+
* pod's first — or, when it was marked after the pod's first phase, it ran in
|
|
38
|
+
* parallel from the step's start: its span is 0 → its mark, the pod's lane
|
|
39
|
+
* starts at 0 as well, and `go` (which the gate holds until every service is
|
|
40
|
+
* up) starts at the later of the two lanes, the difference being `waited`.
|
|
41
|
+
* (The executor re-marks `services` at the gate and keeps no earlier mark,
|
|
42
|
+
* so on such a run the staging before the pod is asked for falls in the
|
|
43
|
+
* pod lane's first phase, usually `room`, rather than in `services`.)
|
|
44
|
+
*
|
|
45
|
+
* Subtracting neighbours in STARTUP_PHASES order instead gave the overlapped
|
|
46
|
+
* run's `services` the pod's boot as well, and every phase it overlapped
|
|
47
|
+
* +0.00s. Missing and non-finite marks are skipped; a later mark that reads
|
|
48
|
+
* earlier than the one before it (two clocks) takes 0, never a negative.
|
|
49
|
+
*/
|
|
50
|
+
export function startupBreakdown(marks) {
|
|
51
|
+
if (!marks || typeof marks !== "object")
|
|
52
|
+
return [];
|
|
53
|
+
const at = (p) => {
|
|
54
|
+
const v = marks[p];
|
|
55
|
+
return typeof v === "number" && Number.isFinite(v) ? v : null;
|
|
56
|
+
};
|
|
57
|
+
const services = at("services");
|
|
58
|
+
const firstInLine = STARTUP_PHASES.find((p) => p !== "services" && at(p) !== null);
|
|
59
|
+
const parallel = services !== null && firstInLine !== undefined && services > at(firstInLine);
|
|
60
|
+
const spans = [];
|
|
61
|
+
// Where the step pod's lane has got to. A services phase in line is the
|
|
62
|
+
// first thing on it; one in parallel leaves it at the step's start.
|
|
63
|
+
let lane = 0;
|
|
64
|
+
for (const phase of STARTUP_PHASES) {
|
|
65
|
+
const end = at(phase);
|
|
66
|
+
if (end === null)
|
|
67
|
+
continue;
|
|
68
|
+
if (phase === "services") {
|
|
69
|
+
spans.push({ phase, from: 0, at: end, took: Math.max(0, end), parallel, waited: 0 });
|
|
70
|
+
if (!parallel)
|
|
71
|
+
lane = Math.max(lane, end);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
let from = lane;
|
|
75
|
+
let waited = 0;
|
|
76
|
+
// `go` is released only once every service is up: on an overlapped run
|
|
77
|
+
// it starts when the later of the two lanes did.
|
|
78
|
+
if (phase === "go" && parallel && services > lane) {
|
|
79
|
+
waited = services - lane;
|
|
80
|
+
from = services;
|
|
81
|
+
}
|
|
82
|
+
spans.push({ phase, from, at: end, took: Math.max(0, end - from), parallel: false, waited });
|
|
83
|
+
lane = Math.max(from, end);
|
|
84
|
+
}
|
|
85
|
+
return spans;
|
|
86
|
+
}
|
package/dist/src/store.d.ts
CHANGED
|
@@ -372,10 +372,13 @@ export interface AgentInfo {
|
|
|
372
372
|
* the default (open when it may fetch or browse the web, else trusted).
|
|
373
373
|
* `implied` here is its `apis:` hosts; a run also adds its MCP servers',
|
|
374
374
|
* its web providers' and its bound secrets' sites. */
|
|
375
|
-
/** browses: the step may browse
|
|
375
|
+
/** browses: the step may browse; enforceWanted and browseVendor are what
|
|
376
|
+
* this folder says toward browseVerdict (FOL-110) — the install says the rest. */
|
|
376
377
|
network: NetworkPolicy & {
|
|
377
378
|
readsWeb: boolean;
|
|
378
379
|
browses: boolean;
|
|
380
|
+
enforceWanted: boolean;
|
|
381
|
+
browseVendor: string | null;
|
|
379
382
|
};
|
|
380
383
|
/** Tools this agent declares inline rather than in `tools:` — `apis:`,
|
|
381
384
|
* `scripts:` and `mcpServers:` names — which a limit may also name. */
|
package/dist/src/store.js
CHANGED
|
@@ -50,7 +50,8 @@ import { parseRemotes, remoteNetworkHosts, A2A_LIMIT_KEY } from "./a2a-remotes.j
|
|
|
50
50
|
import { parseBudget, budgetProblem } from "./budget.js";
|
|
51
51
|
import { timezoneProblem } from "./clock.js";
|
|
52
52
|
import { parseStepLimits, readLimits } from "./limits.js";
|
|
53
|
-
import { networkProblems, resolveNetwork } from "./network.js";
|
|
53
|
+
import { networkEnforceWanted, networkProblems, resolveNetwork } from "./network.js";
|
|
54
|
+
import { browseVendorOf } from "./browse-egress.js";
|
|
54
55
|
import { webProblems, webWarnings, runnerEngines, webConfig } from "./providers.js";
|
|
55
56
|
import { actionProblems } from "./web-actions.js";
|
|
56
57
|
import { languageProblem } from "./language.js";
|
|
@@ -1175,9 +1176,14 @@ export function listAgents(tenant, workspace) {
|
|
|
1175
1176
|
],
|
|
1176
1177
|
}),
|
|
1177
1178
|
readsWeb,
|
|
1178
|
-
// The runner's own test (runner.ts `browses`)
|
|
1179
|
-
//
|
|
1179
|
+
// The runner's own test (runner.ts `browses`). Whether its list holds
|
|
1180
|
+
// for such a step depends on the install too (browse-egress.ts
|
|
1181
|
+
// browseVerdict): the two fields below are this folder's half of it.
|
|
1180
1182
|
browses: tools.includes("web") && (!actions || actions.includes("browse")),
|
|
1183
|
+
// network_enforce: true in the account's or workspace's AGENTS.md.
|
|
1184
|
+
enforceWanted: networkEnforceWanted(accountFront.network_enforce, workspaceFront.network_enforce),
|
|
1185
|
+
// The vendor its web.browse names, null for foldrun's own browser.
|
|
1186
|
+
browseVendor: browseVendorOf(webConfig(data, { ...accountFront, ...workspaceFront }).raw.browse),
|
|
1181
1187
|
};
|
|
1182
1188
|
return {
|
|
1183
1189
|
network,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/** What became of one trigger firing. `started` is here too: without it the
|
|
2
2
|
* log answers "why did nothing run" and not "how often does anything",
|
|
3
3
|
* and the ratio is the whole point of the page. */
|
|
4
|
-
export type TriggerOutcome = "started" | "duplicate" | "throttled" | "debounced" | "quarantined" | "paused" | "halted" | "overlap-skipped" | "missed" | "filtered"
|
|
4
|
+
export type TriggerOutcome = "started" | "duplicate" | "throttled" | "debounced" | "quarantined" | "paused" | "halted" | "overlap-skipped" | "missed" | "filtered"
|
|
5
|
+
/** The account already had its most runs waiting for their turn
|
|
6
|
+
* (FOL-100, 5 Nov 2026): this one was refused, not lined up. */
|
|
7
|
+
| "queue-full" | "failed";
|
|
5
8
|
export interface TriggerEvent {
|
|
6
9
|
t: string;
|
|
7
10
|
flow: string;
|
|
@@ -13,6 +16,13 @@ export interface TriggerEvent {
|
|
|
13
16
|
detail?: string;
|
|
14
17
|
runId?: string;
|
|
15
18
|
}
|
|
19
|
+
/** A refused start's own code, for rollbackTrigger: a lowercase word an
|
|
20
|
+
* error that carries an HTTP status also carries (`waiting_cap`), never a
|
|
21
|
+
* system errno (`ENOENT`). Undefined for anything else. */
|
|
22
|
+
export declare function refusalCode(err: unknown): string | undefined;
|
|
23
|
+
/** The outcome a start that threw is logged as: `queue-full` for the
|
|
24
|
+
* account's waiting cap, else `failed`. */
|
|
25
|
+
export declare function failedOutcome(code: string | undefined): TriggerOutcome;
|
|
16
26
|
/** Never throws. A diagnostic that can break a trigger is worse than no
|
|
17
27
|
* diagnostic: the whole point is to be reading it on the bad morning. */
|
|
18
28
|
export declare function recordTriggerEvent(tenant: string, workspace: string, event: TriggerEvent): void;
|
package/dist/src/trigger-log.js
CHANGED
|
@@ -27,6 +27,18 @@
|
|
|
27
27
|
import fs from "node:fs";
|
|
28
28
|
import path from "node:path";
|
|
29
29
|
import { workspaceDir } from "./store.js";
|
|
30
|
+
/** A refused start's own code, for rollbackTrigger: a lowercase word an
|
|
31
|
+
* error that carries an HTTP status also carries (`waiting_cap`), never a
|
|
32
|
+
* system errno (`ENOENT`). Undefined for anything else. */
|
|
33
|
+
export function refusalCode(err) {
|
|
34
|
+
const o = err;
|
|
35
|
+
return o && typeof o.status === "number" && typeof o.code === "string" && /^[a-z][a-z0-9_]*$/.test(o.code) ? o.code : undefined;
|
|
36
|
+
}
|
|
37
|
+
/** The outcome a start that threw is logged as: `queue-full` for the
|
|
38
|
+
* account's waiting cap, else `failed`. */
|
|
39
|
+
export function failedOutcome(code) {
|
|
40
|
+
return code === "waiting_cap" ? "queue-full" : "failed";
|
|
41
|
+
}
|
|
30
42
|
function logFile(tenant, workspace) {
|
|
31
43
|
return path.join(workspaceDir(tenant, workspace), "trigger-log.jsonl");
|
|
32
44
|
}
|
package/dist/src/triggers.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
// an agent reads it — the same rule as every other handoff in the format.
|
|
14
14
|
import crypto from "node:crypto";
|
|
15
15
|
import { platform } from "./platform.js";
|
|
16
|
+
import { refusalCode } from "./trigger-log.js";
|
|
16
17
|
import { listFlows, readRun, runVerdict } from "./store.js";
|
|
17
18
|
import { getSecret, signingSecretShown } from "./secrets.js";
|
|
18
19
|
/** The last step's result — the same reading runner.ts makes, kept local so
|
|
@@ -99,7 +100,7 @@ export async function fireChainedFlows(tenant, workspace, finished) {
|
|
|
99
100
|
console.log(`[foldrun] trigger: flow — ${tenant}/${workspace}/${flow.name} started after ${finished.flow} ${finished.status}`);
|
|
100
101
|
}
|
|
101
102
|
catch (err) {
|
|
102
|
-
await platform.rollbackTrigger(tenant, workspace, flow, { reason: err instanceof Error ? err.message : String(err) });
|
|
103
|
+
await platform.rollbackTrigger(tenant, workspace, flow, { reason: err instanceof Error ? err.message : String(err), code: refusalCode(err) });
|
|
103
104
|
throw err;
|
|
104
105
|
}
|
|
105
106
|
}
|
|
@@ -161,7 +162,7 @@ export async function fireStorageTriggers(tenant, workspace, paths, by) {
|
|
|
161
162
|
started.push(run.id);
|
|
162
163
|
}
|
|
163
164
|
catch (err) {
|
|
164
|
-
await platform.rollbackTrigger(tenant, workspace, flow, { reason: err instanceof Error ? err.message : String(err) });
|
|
165
|
+
await platform.rollbackTrigger(tenant, workspace, flow, { reason: err instanceof Error ? err.message : String(err), code: refusalCode(err) });
|
|
165
166
|
throw err;
|
|
166
167
|
}
|
|
167
168
|
}
|
package/package.json
CHANGED
package/src/browse-egress.ts
CHANGED
|
@@ -1,26 +1,48 @@
|
|
|
1
1
|
// Browsing and `network:` (FOL-110, foldrun-docs/proposals/browse-egress.md).
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
// gives it no forward proxy (a browser in the sandbox cannot send credentials
|
|
5
|
-
// written into a proxy URL), so the browser — and every other program in that
|
|
6
|
-
// step — reaches sites directly. Until the browse service and hosted
|
|
7
|
-
// enforcement ship, the trace says so plainly, and says which of the three
|
|
8
|
-
// tiers this step's browser will fall in:
|
|
3
|
+
// Three tiers, said in the trace:
|
|
9
4
|
//
|
|
10
5
|
// hosted — foldrun's own browser (the account's browser pod, Lightpanda,
|
|
11
|
-
// Obscura, a live session): our network boundary
|
|
6
|
+
// Obscura, a live session): our network boundary confines it.
|
|
12
7
|
// vendor — a vendor that takes a customer proxy (Browserbase, Steel,
|
|
13
8
|
// Hyperbrowser, Browserless): through the egress proxy, enforced
|
|
14
|
-
// once that vendor is qualified by our own tests.
|
|
9
|
+
// once that vendor is qualified by our own tests (phase 4).
|
|
15
10
|
// none — a vendor that always browses through its own network (Bright
|
|
16
11
|
// Data, ZenRows) or any DevTools address: never enforced; a
|
|
17
|
-
// restricted, enforced `network:`
|
|
12
|
+
// restricted, enforced `network:` refuses it.
|
|
13
|
+
//
|
|
14
|
+
// Phase 3 (hosted enforcement) holds a browsing step to its list where the
|
|
15
|
+
// executor can wall the step's network (the k8s tier, with the install's
|
|
16
|
+
// FOLDRUN_BROWSE_ENFORCE=1 — Platform.confinesBrowsing). Such a step gets the
|
|
17
|
+
// forward proxy like any other, so its run pod is `filtered`: it reaches the
|
|
18
|
+
// egress proxy and DNS and nothing else, and the browser runs inside it, in
|
|
19
|
+
// the step's own pod. A client that sets another proxy, a CDP context with
|
|
20
|
+
// its own proxyServer, a curl that ignores HTTPS_PROXY — each finds no route,
|
|
21
|
+
// never a way round the list. Not covered: DNS lookups through the cluster's
|
|
22
|
+
// resolver, which the wall admits and nothing here restricts. browseVerdict
|
|
23
|
+
// says, for one step, which of the three ways it goes; everywhere else (no
|
|
24
|
+
// wall, an open or report-only list) the step browses as it did before
|
|
25
|
+
// phase 3, and the trace says so.
|
|
18
26
|
|
|
19
|
-
import { findBrowserApi } from "./providers.ts";
|
|
20
|
-
import { networkLine, type NetworkPolicy } from "./network.ts";
|
|
27
|
+
import { findBrowserApi, readBrowseSettings, resolveSearch } from "./providers.ts";
|
|
28
|
+
import { networkLine, type NetworkLevel, type NetworkPolicy } from "./network.ts";
|
|
21
29
|
|
|
22
30
|
export type BrowseTier = "hosted" | "vendor" | "none";
|
|
23
31
|
|
|
32
|
+
/** Set to "1" in a browsing step held to its list (browseVerdict "hosted"):
|
|
33
|
+
* the web tool gives its browser the forward door as launch options and
|
|
34
|
+
* refuses what cannot go through it; the platform starts no account browser
|
|
35
|
+
* pod for the step (its pod could not reach one, and that pod is not walled). */
|
|
36
|
+
export const BROWSER_CONFINED_ENV = "FOLDRUN_BROWSER_CONFINED";
|
|
37
|
+
|
|
38
|
+
/** The vendor a `web.browse` value names (the runner's FOLDRUN_BROWSER_VENDOR),
|
|
39
|
+
* or null for foldrun's own browser — read the way runner.ts reads it. */
|
|
40
|
+
export function browseVendorOf(browse: unknown): string | null {
|
|
41
|
+
const read = readBrowseSettings(browse);
|
|
42
|
+
const choice = resolveSearch(read.rest, "browse");
|
|
43
|
+
return choice.shape === "direct" && choice.provider ? choice.provider : null;
|
|
44
|
+
}
|
|
45
|
+
|
|
24
46
|
/** Which tier a step's browser falls in: no vendor (or foldrun) is ours. */
|
|
25
47
|
export function browseTier(vendor: string | null | undefined): { tier: BrowseTier; title: string } {
|
|
26
48
|
const name = (vendor ?? "").trim().toLowerCase();
|
|
@@ -30,16 +52,65 @@ export function browseTier(vendor: string | null | undefined): { tier: BrowseTie
|
|
|
30
52
|
return { tier: api.egress === "proxy" ? "vendor" : "none", title: api.title };
|
|
31
53
|
}
|
|
32
54
|
|
|
55
|
+
/** How one browsing step is held to its `network:` list:
|
|
56
|
+
*
|
|
57
|
+
* legacy — as before phase 3: no forward proxy, the pod keeps the world,
|
|
58
|
+
* and the trace says the list does not hold. An open list, a
|
|
59
|
+
* report-only install, or an executor that cannot wall the
|
|
60
|
+
* step's network.
|
|
61
|
+
* hosted — enforced: the step gets the forward proxy, its pod is walled
|
|
62
|
+
* to the egress proxy and DNS, and foldrun's browser runs in it.
|
|
63
|
+
* refuse — a vendor's browser under a restricted, enforced list on an
|
|
64
|
+
* install that holds browsing: it browses from the vendor's
|
|
65
|
+
* network, which nothing here can hold to the list, so the step
|
|
66
|
+
* is refused before anything connects (decision 4). */
|
|
67
|
+
export type BrowseVerdict =
|
|
68
|
+
| { kind: "legacy" }
|
|
69
|
+
| { kind: "hosted" }
|
|
70
|
+
| { kind: "refuse"; message: string };
|
|
71
|
+
|
|
72
|
+
export function browseVerdict(o: {
|
|
73
|
+
/** The step's resolved level (network.ts). */
|
|
74
|
+
level: NetworkLevel;
|
|
75
|
+
/** Will the proxy refuse a site off the list (lease.enforce)? */
|
|
76
|
+
enforce: boolean;
|
|
77
|
+
/** FOLDRUN_BROWSER_VENDOR: the vendor the agent named, if any. */
|
|
78
|
+
vendor: string | null | undefined;
|
|
79
|
+
/** Can this executor wall the step's network (Platform.confinesBrowsing)? */
|
|
80
|
+
confines: boolean;
|
|
81
|
+
}): BrowseVerdict {
|
|
82
|
+
if (o.level === "open" || !o.enforce || !o.confines) return { kind: "legacy" };
|
|
83
|
+
const { tier, title } = browseTier(o.vendor);
|
|
84
|
+
if (tier === "hosted") return { kind: "hosted" };
|
|
85
|
+
const why =
|
|
86
|
+
tier === "vendor"
|
|
87
|
+
? `${title} browses from its own network, and foldrun cannot hold it to network: until that vendor is qualified (FOL-110 phase 4)`
|
|
88
|
+
: `${title} always browses through its own network, and nothing can hold it to network:`;
|
|
89
|
+
return {
|
|
90
|
+
kind: "refuse",
|
|
91
|
+
message:
|
|
92
|
+
`browse: refused before it connected — this step's network: ${o.level} is enforced, and ${why}. ` +
|
|
93
|
+
`Drop browse: ${(o.vendor ?? "").trim()} from the agent's web: block to browse with foldrun's own browser, which is held to the list; ` +
|
|
94
|
+
`or, to accept browsing that no list holds for this one agent, give that agent network: open.`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
33
98
|
/** The trace's network line for a step that may browse, on an install with
|
|
34
|
-
* an egress proxy: the step's list, and
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
99
|
+
* an egress proxy: the step's list, and whether it holds — `hosted` when
|
|
100
|
+
* browseVerdict put the step under the wall, else the plain fact that it
|
|
101
|
+
* does not hold yet, for the browser or anything else in the step. */
|
|
102
|
+
export function browseNetworkLine(policy: NetworkPolicy, vendor: string | null | undefined, opts: { hosted?: boolean } = {}): string {
|
|
38
103
|
const what = networkLine(policy, true);
|
|
39
|
-
|
|
104
|
+
if (opts.hosted) {
|
|
105
|
+
return `${what} — enforced — hosted: the browser runs inside this step's sandbox, whose network reaches only the egress proxy (which holds the list) and DNS, so a page, a script or a changed proxy setting reaches no site off the list; DNS lookups themselves are not restricted.`;
|
|
106
|
+
}
|
|
107
|
+
const { tier, title } = browseTier(vendor);
|
|
108
|
+
const now = " — not enforced in this step: it may browse, and browsing does not go through the egress proxy here, so the browser and every other program in this step reach sites directly";
|
|
40
109
|
const later =
|
|
41
110
|
tier === "hosted"
|
|
42
|
-
?
|
|
111
|
+
? policy.level === "open"
|
|
112
|
+
? `. Its browser is ${title}; with an open list there is nothing to hold it to`
|
|
113
|
+
: `. Its browser is ${title}: it is held to network: on an install that confines browsing, with the list enforced (FOL-110)`
|
|
43
114
|
: tier === "vendor"
|
|
44
115
|
? `. Its browser (${title}) browses from the vendor's network: it comes under network: through the egress proxy once that vendor is qualified (FOL-110)`
|
|
45
116
|
: `. Its browser (${title}) always browses through its own network and cannot be held to network: — a restricted, enforced network: will refuse it (FOL-110)`;
|
package/src/platform.ts
CHANGED
|
@@ -105,7 +105,9 @@ export interface PlatformHooks {
|
|
|
105
105
|
tenant: string,
|
|
106
106
|
workspace: string,
|
|
107
107
|
flow: FlowInfo,
|
|
108
|
-
|
|
108
|
+
/** `code`: the refusal's own code, when it had one — `waiting_cap`
|
|
109
|
+
* is logged as `queue-full` rather than `failed`. */
|
|
110
|
+
opts?: { deliveryKey?: string | null; reason?: string; code?: string },
|
|
109
111
|
): Promise<void>;
|
|
110
112
|
/** Step executors by FOLDRUN_RUN_ISOLATION value, beyond the `container`
|
|
111
113
|
* one core ships. The platform adds `k8s`. */
|
|
@@ -155,6 +157,16 @@ export interface PlatformHooks {
|
|
|
155
157
|
* only where no provider: block of the account's own says otherwise.
|
|
156
158
|
* Absent: nobody can (a laptop, a self-hosted install). */
|
|
157
159
|
modelSupply?(tenant: string): SupplyAnswer;
|
|
160
|
+
/**
|
|
161
|
+
* Does this isolation mode wall a step's network to the egress proxy and
|
|
162
|
+
* DNS when its `network:` is restricted and enforced — and is browsing
|
|
163
|
+
* put under that wall (FOL-110 phase 3, browse-egress.ts browseVerdict)?
|
|
164
|
+
* True: a browsing step gets the forward proxy like any other and its
|
|
165
|
+
* browser runs inside the walled sandbox, so the list holds for it.
|
|
166
|
+
* Absent or false: a browsing step browses as before phase 3, said in the
|
|
167
|
+
* trace as not enforced.
|
|
168
|
+
*/
|
|
169
|
+
confinesBrowsing?(isolation: string): boolean;
|
|
158
170
|
/**
|
|
159
171
|
* An operator setting, by the environment variable that used to hold it
|
|
160
172
|
* (30 Oct 2026): the platform answers with the operator's value where one
|
package/src/run-container.ts
CHANGED
|
@@ -38,6 +38,7 @@ import { safeTenantSegment, systemInstallSh, SYSTEM_FROM_INPUT_SH, INSTALL_SOCKE
|
|
|
38
38
|
import { egressCaSh, type NetworkLevel } from "./network.ts";
|
|
39
39
|
import { anyMemoryMi, quantityMi, type ResourceOverride } from "./resources.ts";
|
|
40
40
|
import type { ScriptSpec } from "./script-tools.ts";
|
|
41
|
+
import { STARTUP_PHASES, type StartupPhase, type StartupPhases } from "./startup.ts";
|
|
41
42
|
import type { ConsultSpec } from "./agent-tools.ts";
|
|
42
43
|
import type { DelegateSpec, SubagentSpec } from "./subagents.ts";
|
|
43
44
|
import { isOperatorEvent, type OperatorEvent } from "./operator.ts";
|
|
@@ -153,28 +154,9 @@ export interface StepTiming {
|
|
|
153
154
|
phases?: StartupPhases;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
/**
|
|
157
|
-
*
|
|
158
|
-
|
|
159
|
-
* two neighbours is what the later one cost (FOL-29: "pod ready" was the
|
|
160
|
-
* only number, and the six seconds after it had no names).
|
|
161
|
-
*
|
|
162
|
-
* The executor marks its own: `services` (the account's search/browser pods
|
|
163
|
-
* up), `room` (room on the cluster to start — platform pod-room.ts),
|
|
164
|
-
* `applied` (pod created), `ready`, `files` (the workspace copied in),
|
|
165
|
-
* `go` (the step released). The sandbox marks the rest as `{"e":"mark"}`
|
|
166
|
-
* lines: `shim` (the shim saw go), `system` (system packages restored),
|
|
167
|
-
* `driver` (node up), `imports` (core loaded), `tools` (runtime and tools
|
|
168
|
-
* built, the SDK about to start) and `model` (the model's first text or tool
|
|
169
|
-
* call). A worker that predates a mark ignores the line — parseDriverLine
|
|
170
|
-
* answers null for an `e` it does not know.
|
|
171
|
-
*/
|
|
172
|
-
export const STARTUP_PHASES = [
|
|
173
|
-
"services", "room", "applied", "ready", "files", "go",
|
|
174
|
-
"shim", "system", "driver", "imports", "tools", "model",
|
|
175
|
-
] as const;
|
|
176
|
-
export type StartupPhase = (typeof STARTUP_PHASES)[number];
|
|
177
|
-
export type StartupPhases = Partial<Record<StartupPhase, number>>;
|
|
157
|
+
/** The start-up phases and what each marks — startup.ts, where every
|
|
158
|
+
* surface that shows them reads them from (FOL-74). */
|
|
159
|
+
export { STARTUP_PHASES, type StartupPhase, type StartupPhases };
|
|
178
160
|
|
|
179
161
|
/** A sandbox-side mark: which phase ended, and when (epoch ms, the
|
|
180
162
|
* sandbox's clock — the same machine's as the worker's on one node). */
|
package/src/runner.ts
CHANGED
|
@@ -101,7 +101,7 @@ import { PromptLayers, promptCacheKey } from "./prompt-layers.ts";
|
|
|
101
101
|
import { loadCatalog, checkModel, clampEffort, catalogCost, findModel, tokenPriceOf, type Catalog, type TokenPrice } from "./catalog.ts";
|
|
102
102
|
import { resolveSecrets, getSecret, materializeSecrets, secretSites, isClientCertValue, clientCertOf, withoutHeldCerts, isIdentityValue, identityOf } from "./secrets.ts";
|
|
103
103
|
import { resolveNetwork, networkLine, networkEnforceWanted, proxyEnv, siteCovers, EGRESS_CA_ENV } from "./network.ts";
|
|
104
|
-
import { browseNetworkLine } from "./browse-egress.ts";
|
|
104
|
+
import { BROWSER_CONFINED_ENV, browseNetworkLine, browseVerdict } from "./browse-egress.ts";
|
|
105
105
|
import { materializeFileSecrets, cleanupFileSecrets } from "./secret-files.ts";
|
|
106
106
|
import { buildApiTools, secretsUsedByApi } from "./api-tools.ts";
|
|
107
107
|
import { buildA2ATools } from "./a2a-tools.ts";
|
|
@@ -3035,6 +3035,27 @@ async function runStep(
|
|
|
3035
3035
|
save();
|
|
3036
3036
|
return;
|
|
3037
3037
|
}
|
|
3038
|
+
// A step that may browse, on an install with the forward door: held to
|
|
3039
|
+
// its list where the executor walls the step's network, refused when
|
|
3040
|
+
// it names a vendor that list cannot hold, else as before phase 3
|
|
3041
|
+
// (browse-egress.ts browseVerdict, FOL-110).
|
|
3042
|
+
const browses = scriptSpecs.some((sc) => sc.name === "web") && (!web.actions || web.actions.includes("browse"));
|
|
3043
|
+
const browse = browses && lease?.proxy
|
|
3044
|
+
? browseVerdict({
|
|
3045
|
+
level: network.level,
|
|
3046
|
+
enforce: lease.enforce === true,
|
|
3047
|
+
vendor: clockEnv.FOLDRUN_BROWSER_VENDOR,
|
|
3048
|
+
confines: !!isolation && platform.confinesBrowsing?.(isolation) === true,
|
|
3049
|
+
})
|
|
3050
|
+
: null;
|
|
3051
|
+
if (lease && browse?.kind === "refuse") {
|
|
3052
|
+
push("info", networkLine(network, true));
|
|
3053
|
+
push("error", browse.message);
|
|
3054
|
+
await lease.release();
|
|
3055
|
+
step.status = "failed";
|
|
3056
|
+
save();
|
|
3057
|
+
return;
|
|
3058
|
+
}
|
|
3038
3059
|
// Serve those jobs while this step runs: each one becomes a step of
|
|
3039
3060
|
// its own (delegateJob), and the door answers the long-poll with its
|
|
3040
3061
|
// reply. No proxy, or a platform without the door: not offered — the
|
|
@@ -3060,16 +3081,18 @@ async function runStep(
|
|
|
3060
3081
|
// The forward door: every program in the sandbox sends through the
|
|
3061
3082
|
// proxy, which holds the site list and fills bound secrets. A proxy
|
|
3062
3083
|
// without the door (an older platform) leaves programs going direct.
|
|
3063
|
-
// A step that may browse gets no proxy variables
|
|
3064
|
-
// reads HTTPS_PROXY too, and
|
|
3065
|
-
// into a proxy URL — every
|
|
3066
|
-
// (14 Oct 2026, the reel
|
|
3067
|
-
//
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
//
|
|
3071
|
-
|
|
3072
|
-
|
|
3084
|
+
// A step that may browse gets no proxy variables unless it is held
|
|
3085
|
+
// (browse.kind "hosted"): the browser in it reads HTTPS_PROXY too, and
|
|
3086
|
+
// Chromium cannot send credentials written into a proxy URL — every
|
|
3087
|
+
// page failed ERR_INVALID_AUTH_CREDENTIALS (14 Oct 2026, the reel
|
|
3088
|
+
// posters). A held step's web tool hands the browser the proxy and its
|
|
3089
|
+
// credential as launch options instead (FOLDRUN_BROWSER_CONFINED).
|
|
3090
|
+
// Every other browsing step is open by default, and its bound secrets
|
|
3091
|
+
// materialise as they did before the door.
|
|
3092
|
+
const forward = lease?.proxy && (!browses || browse?.kind === "hosted") ? lease : null;
|
|
3093
|
+
// A browsing step on an install with the door says whether it is held
|
|
3094
|
+
// to its list, and which tier its browser falls in (browse-egress.ts).
|
|
3095
|
+
push("info", browse ? browseNetworkLine(network, clockEnv.FOLDRUN_BROWSER_VENDOR, { hosted: browse.kind === "hosted" }) : networkLine(network, forward ? forward.enforce === true : null));
|
|
3073
3096
|
const bound = forward ? Object.keys(boundSites).filter((name) => name in liveSecrets) : [];
|
|
3074
3097
|
for (const name of bound) {
|
|
3075
3098
|
for (const site of boundSites[name]) addGrant(grant, name, liveSecrets[name], site);
|
|
@@ -3297,11 +3320,20 @@ async function runStep(
|
|
|
3297
3320
|
// Every program's HTTP(S) through the proxy's forward door, and
|
|
3298
3321
|
// the CA it signs bound sites with, for the sandbox to trust.
|
|
3299
3322
|
...(forward ? proxyEnv(forward.proxy!) : {}),
|
|
3323
|
+
// A browsing step held to its list: the web tool gives its
|
|
3324
|
+
// browser the forward door as launch options, refuses what
|
|
3325
|
+
// cannot go through it, and the platform starts no account
|
|
3326
|
+
// browser pod for it (browse-egress.ts, FOL-110 phase 3).
|
|
3327
|
+
...(browse?.kind === "hosted" ? { [BROWSER_CONFINED_ENV]: "1" } : {}),
|
|
3300
3328
|
// Only a step with a bound secret has a site the proxy
|
|
3301
3329
|
// intercepts, so only that step's TLS clients are pointed at a
|
|
3302
3330
|
// bundle with the egress CA in it; every other step's are as
|
|
3303
3331
|
// they always were.
|
|
3304
|
-
|
|
3332
|
+
// A browser held to its list (browse "hosted") meets the proxy's
|
|
3333
|
+
// leaf on any host a secret is granted to — an api tool's, a web
|
|
3334
|
+
// provider's — not only a bound site, so it is handed the CA
|
|
3335
|
+
// whenever the step has one: the web tool trusts it for Chromium.
|
|
3336
|
+
...(forward?.ca && (bound.length || (browse?.kind === "hosted" && Object.keys(grant.secrets).length)) ? { [EGRESS_CA_ENV]: Buffer.from(forward.ca).toString("base64") } : {}),
|
|
3305
3337
|
...clockEnv,
|
|
3306
3338
|
// Who is running: the in-process path stamps scripts with these
|
|
3307
3339
|
// host-side, but a container rebuilds its tools from its own
|
package/src/startup.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Where a step's start-up went, phase by phase (FOL-29), read the same way
|
|
2
|
+
// by every surface that shows it: the platform's Observe report (and through
|
|
3
|
+
// its API the CLI's `foldrun observe`) and the run page's start-up chip.
|
|
4
|
+
//
|
|
5
|
+
// Pure and import-free, so the dashboard can load it in the browser.
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The start-up of one step, in the order it happens. Each is the moment the
|
|
9
|
+
* phase ENDED, in ms since the executor began the step (seconds on the step
|
|
10
|
+
* record), so the gap between two neighbours is what the later one cost
|
|
11
|
+
* (FOL-29: "pod ready" was the only number, and the six seconds after it had
|
|
12
|
+
* no names).
|
|
13
|
+
*
|
|
14
|
+
* The executor marks its own: `services` (the account's search/browser pods
|
|
15
|
+
* up), `room` (room on the cluster to start — platform pod-room.ts),
|
|
16
|
+
* `applied` (pod created), `ready`, `files` (the workspace copied in),
|
|
17
|
+
* `go` (the step released). The sandbox marks the rest as `{"e":"mark"}`
|
|
18
|
+
* lines: `shim` (the shim saw go), `system` (system packages restored),
|
|
19
|
+
* `driver` (node up), `imports` (core loaded), `tools` (runtime and tools
|
|
20
|
+
* built, the SDK about to start) and `model` (the model's first text or tool
|
|
21
|
+
* call). A worker that predates a mark ignores the line — parseDriverLine
|
|
22
|
+
* answers null for an `e` it does not know.
|
|
23
|
+
*
|
|
24
|
+
* `services` is the one phase that may not be in line: since FOL-46 the
|
|
25
|
+
* account's search and browser pods boot ALONGSIDE the step pod, and `go`
|
|
26
|
+
* waits for both. See startupBreakdown.
|
|
27
|
+
*/
|
|
28
|
+
export const STARTUP_PHASES = [
|
|
29
|
+
"services", "room", "applied", "ready", "files", "go",
|
|
30
|
+
"shim", "system", "driver", "imports", "tools", "model",
|
|
31
|
+
] as const;
|
|
32
|
+
export type StartupPhase = (typeof STARTUP_PHASES)[number];
|
|
33
|
+
export type StartupPhases = Partial<Record<StartupPhase, number>>;
|
|
34
|
+
|
|
35
|
+
/** One phase of one step's start-up, placed on its lane. */
|
|
36
|
+
export interface StartupSpan {
|
|
37
|
+
phase: StartupPhase;
|
|
38
|
+
/** When the phase could begin, counted from the step's start. */
|
|
39
|
+
from: number;
|
|
40
|
+
/** When it ended — the mark itself. */
|
|
41
|
+
at: number;
|
|
42
|
+
/** Its own share: `at − from`, never negative. */
|
|
43
|
+
took: number;
|
|
44
|
+
/** It ran alongside the step pod's own phases rather than before them —
|
|
45
|
+
* `services` on a run whose search or browser pod was still booting
|
|
46
|
+
* when the step pod was up (FOL-46). */
|
|
47
|
+
parallel: boolean;
|
|
48
|
+
/** How long this phase sat ready to start but held back by a parallel
|
|
49
|
+
* lane — `go` behind a `services` that was still booting. 0 otherwise. */
|
|
50
|
+
waited: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A step's start-up marks as spans, overlap-aware (FOL-74).
|
|
55
|
+
*
|
|
56
|
+
* Every phase but `services` runs in line: each starts when the one marked
|
|
57
|
+
* before it ended. `services` either comes first — no services, or ones
|
|
58
|
+
* awaited before the step pod was asked for, and its mark lands before the
|
|
59
|
+
* pod's first — or, when it was marked after the pod's first phase, it ran in
|
|
60
|
+
* parallel from the step's start: its span is 0 → its mark, the pod's lane
|
|
61
|
+
* starts at 0 as well, and `go` (which the gate holds until every service is
|
|
62
|
+
* up) starts at the later of the two lanes, the difference being `waited`.
|
|
63
|
+
* (The executor re-marks `services` at the gate and keeps no earlier mark,
|
|
64
|
+
* so on such a run the staging before the pod is asked for falls in the
|
|
65
|
+
* pod lane's first phase, usually `room`, rather than in `services`.)
|
|
66
|
+
*
|
|
67
|
+
* Subtracting neighbours in STARTUP_PHASES order instead gave the overlapped
|
|
68
|
+
* run's `services` the pod's boot as well, and every phase it overlapped
|
|
69
|
+
* +0.00s. Missing and non-finite marks are skipped; a later mark that reads
|
|
70
|
+
* earlier than the one before it (two clocks) takes 0, never a negative.
|
|
71
|
+
*/
|
|
72
|
+
export function startupBreakdown(marks: Record<string, unknown> | null | undefined): StartupSpan[] {
|
|
73
|
+
if (!marks || typeof marks !== "object") return [];
|
|
74
|
+
const at = (p: StartupPhase): number | null => {
|
|
75
|
+
const v = marks[p];
|
|
76
|
+
return typeof v === "number" && Number.isFinite(v) ? v : null;
|
|
77
|
+
};
|
|
78
|
+
const services = at("services");
|
|
79
|
+
const firstInLine = STARTUP_PHASES.find((p) => p !== "services" && at(p) !== null);
|
|
80
|
+
const parallel = services !== null && firstInLine !== undefined && services > at(firstInLine)!;
|
|
81
|
+
|
|
82
|
+
const spans: StartupSpan[] = [];
|
|
83
|
+
// Where the step pod's lane has got to. A services phase in line is the
|
|
84
|
+
// first thing on it; one in parallel leaves it at the step's start.
|
|
85
|
+
let lane = 0;
|
|
86
|
+
for (const phase of STARTUP_PHASES) {
|
|
87
|
+
const end = at(phase);
|
|
88
|
+
if (end === null) continue;
|
|
89
|
+
if (phase === "services") {
|
|
90
|
+
spans.push({ phase, from: 0, at: end, took: Math.max(0, end), parallel, waited: 0 });
|
|
91
|
+
if (!parallel) lane = Math.max(lane, end);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
let from = lane;
|
|
95
|
+
let waited = 0;
|
|
96
|
+
// `go` is released only once every service is up: on an overlapped run
|
|
97
|
+
// it starts when the later of the two lanes did.
|
|
98
|
+
if (phase === "go" && parallel && services! > lane) {
|
|
99
|
+
waited = services! - lane;
|
|
100
|
+
from = services!;
|
|
101
|
+
}
|
|
102
|
+
spans.push({ phase, from, at: end, took: Math.max(0, end - from), parallel: false, waited });
|
|
103
|
+
lane = Math.max(from, end);
|
|
104
|
+
}
|
|
105
|
+
return spans;
|
|
106
|
+
}
|
package/src/store.ts
CHANGED
|
@@ -55,7 +55,8 @@ import { parseRemotes, remoteNetworkHosts, A2A_LIMIT_KEY, type RemoteSpec } from
|
|
|
55
55
|
import { parseBudget, budgetProblem } from "./budget.ts";
|
|
56
56
|
import { timezoneProblem } from "./clock.ts";
|
|
57
57
|
import { parseStepLimits, readLimits } from "./limits.ts";
|
|
58
|
-
import { networkProblems, resolveNetwork, type NetworkPolicy } from "./network.ts";
|
|
58
|
+
import { networkEnforceWanted, networkProblems, resolveNetwork, type NetworkPolicy } from "./network.ts";
|
|
59
|
+
import { browseVendorOf } from "./browse-egress.ts";
|
|
59
60
|
import { webProblems, webWarnings, runnerEngines, webConfig } from "./providers.ts";
|
|
60
61
|
import { actionProblems } from "./web-actions.ts";
|
|
61
62
|
import { languageProblem } from "./language.ts";
|
|
@@ -1050,8 +1051,9 @@ export interface AgentInfo {
|
|
|
1050
1051
|
* the default (open when it may fetch or browse the web, else trusted).
|
|
1051
1052
|
* `implied` here is its `apis:` hosts; a run also adds its MCP servers',
|
|
1052
1053
|
* its web providers' and its bound secrets' sites. */
|
|
1053
|
-
/** browses: the step may browse
|
|
1054
|
-
|
|
1054
|
+
/** browses: the step may browse; enforceWanted and browseVendor are what
|
|
1055
|
+
* this folder says toward browseVerdict (FOL-110) — the install says the rest. */
|
|
1056
|
+
network: NetworkPolicy & { readsWeb: boolean; browses: boolean; enforceWanted: boolean; browseVendor: string | null };
|
|
1055
1057
|
/** Tools this agent declares inline rather than in `tools:` — `apis:`,
|
|
1056
1058
|
* `scripts:` and `mcpServers:` names — which a limit may also name. */
|
|
1057
1059
|
inlineTools: string[];
|
|
@@ -1677,9 +1679,14 @@ export function listAgents(tenant: string, workspace: string): AgentInfo[] {
|
|
|
1677
1679
|
],
|
|
1678
1680
|
}),
|
|
1679
1681
|
readsWeb,
|
|
1680
|
-
// The runner's own test (runner.ts `browses`)
|
|
1681
|
-
//
|
|
1682
|
+
// The runner's own test (runner.ts `browses`). Whether its list holds
|
|
1683
|
+
// for such a step depends on the install too (browse-egress.ts
|
|
1684
|
+
// browseVerdict): the two fields below are this folder's half of it.
|
|
1682
1685
|
browses: tools.includes("web") && (!actions || actions.includes("browse")),
|
|
1686
|
+
// network_enforce: true in the account's or workspace's AGENTS.md.
|
|
1687
|
+
enforceWanted: networkEnforceWanted(accountFront.network_enforce, workspaceFront.network_enforce),
|
|
1688
|
+
// The vendor its web.browse names, null for foldrun's own browser.
|
|
1689
|
+
browseVendor: browseVendorOf(webConfig(data, { ...accountFront, ...workspaceFront }).raw.browse),
|
|
1683
1690
|
};
|
|
1684
1691
|
return {
|
|
1685
1692
|
network,
|
package/src/trigger-log.ts
CHANGED
|
@@ -43,6 +43,9 @@ export type TriggerOutcome =
|
|
|
43
43
|
| "overlap-skipped"
|
|
44
44
|
| "missed"
|
|
45
45
|
| "filtered"
|
|
46
|
+
/** The account already had its most runs waiting for their turn
|
|
47
|
+
* (FOL-100, 5 Nov 2026): this one was refused, not lined up. */
|
|
48
|
+
| "queue-full"
|
|
46
49
|
| "failed";
|
|
47
50
|
|
|
48
51
|
export interface TriggerEvent {
|
|
@@ -57,6 +60,20 @@ export interface TriggerEvent {
|
|
|
57
60
|
runId?: string;
|
|
58
61
|
}
|
|
59
62
|
|
|
63
|
+
/** A refused start's own code, for rollbackTrigger: a lowercase word an
|
|
64
|
+
* error that carries an HTTP status also carries (`waiting_cap`), never a
|
|
65
|
+
* system errno (`ENOENT`). Undefined for anything else. */
|
|
66
|
+
export function refusalCode(err: unknown): string | undefined {
|
|
67
|
+
const o = err as { code?: unknown; status?: unknown } | null;
|
|
68
|
+
return o && typeof o.status === "number" && typeof o.code === "string" && /^[a-z][a-z0-9_]*$/.test(o.code) ? o.code : undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The outcome a start that threw is logged as: `queue-full` for the
|
|
72
|
+
* account's waiting cap, else `failed`. */
|
|
73
|
+
export function failedOutcome(code: string | undefined): TriggerOutcome {
|
|
74
|
+
return code === "waiting_cap" ? "queue-full" : "failed";
|
|
75
|
+
}
|
|
76
|
+
|
|
60
77
|
function logFile(tenant: string, workspace: string) {
|
|
61
78
|
return path.join(workspaceDir(tenant, workspace), "trigger-log.jsonl");
|
|
62
79
|
}
|
package/src/triggers.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import crypto from "node:crypto";
|
|
16
16
|
import { platform } from "./platform.ts";
|
|
17
|
+
import { refusalCode } from "./trigger-log.ts";
|
|
17
18
|
import { listFlows, readRun, runVerdict, type FlowInfo, type FlowStep, type RunRecord } from "./store.ts";
|
|
18
19
|
import { getSecret, signingSecretShown } from "./secrets.ts";
|
|
19
20
|
|
|
@@ -104,7 +105,7 @@ export async function fireChainedFlows(tenant: string, workspace: string, finish
|
|
|
104
105
|
started.push(run.id);
|
|
105
106
|
console.log(`[foldrun] trigger: flow — ${tenant}/${workspace}/${flow.name} started after ${finished.flow} ${finished.status}`);
|
|
106
107
|
} catch (err) {
|
|
107
|
-
await platform.rollbackTrigger(tenant, workspace, flow, { reason: err instanceof Error ? err.message : String(err) });
|
|
108
|
+
await platform.rollbackTrigger(tenant, workspace, flow, { reason: err instanceof Error ? err.message : String(err), code: refusalCode(err) });
|
|
108
109
|
throw err;
|
|
109
110
|
}
|
|
110
111
|
} catch (err) {
|
|
@@ -166,7 +167,7 @@ export async function fireStorageTriggers(
|
|
|
166
167
|
]);
|
|
167
168
|
started.push(run.id);
|
|
168
169
|
} catch (err) {
|
|
169
|
-
await platform.rollbackTrigger(tenant, workspace, flow, { reason: err instanceof Error ? err.message : String(err) });
|
|
170
|
+
await platform.rollbackTrigger(tenant, workspace, flow, { reason: err instanceof Error ? err.message : String(err), code: refusalCode(err) });
|
|
170
171
|
throw err;
|
|
171
172
|
}
|
|
172
173
|
} catch (err) {
|