@foldrun/core 14.5.0 → 15.1.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.
@@ -47,6 +47,7 @@
47
47
  // FOLDRUN_S3_PATH_STYLE default true — R2 speaks path style; false on S3
48
48
  // FOLDRUN_STORAGE_MAX_MB per object, default 512
49
49
  // FOLDRUN_STORAGE_QUOTA_MB per workspace, default 5120
50
+ import { opsError } from "./ops-log.js";
50
51
  import fs from "node:fs";
51
52
  import path from "node:path";
52
53
  import crypto from "node:crypto";
@@ -563,7 +564,7 @@ async function announceFiles(tenant, workspace, paths, by) {
563
564
  await fireStorageTriggers(tenant, workspace, paths, by);
564
565
  }
565
566
  catch (err) {
566
- console.error(`[foldrun] storage trigger ${tenant}/${workspace}:`, err instanceof Error ? err.message : err);
567
+ opsError("trigger.storage_failed", err, { tenant, workspace });
567
568
  }
568
569
  }
569
570
  export async function putFile(tenant, workspace, rel, body, by) {
@@ -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 — not held to its list yet (FOL-110). */
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`): such a step gets no
1179
- // forward proxy yet, so its list does not hold (FOL-110).
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" | "failed";
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;
@@ -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
  }
@@ -11,8 +11,10 @@
11
11
  // None of them evaluates anything. A flow that chains on another does not
12
12
  // read that run's fields; it receives what the run concluded, as text, and
13
13
  // an agent reads it — the same rule as every other handoff in the format.
14
+ import { opsLog, opsError } from "./ops-log.js";
14
15
  import crypto from "node:crypto";
15
16
  import { platform } from "./platform.js";
17
+ import { refusalCode } from "./trigger-log.js";
16
18
  import { listFlows, readRun, runVerdict } from "./store.js";
17
19
  import { getSecret, signingSecretShown } from "./secrets.js";
18
20
  /** The last step's result — the same reading runner.ts makes, kept local so
@@ -86,7 +88,7 @@ export async function fireChainedFlows(tenant, workspace, finished) {
86
88
  try {
87
89
  const gate = await platform.admitTrigger(tenant, workspace, flow, { body, tag: "previous_run", fields: chainFields(finished) });
88
90
  if (!gate.admit) {
89
- console.log(`[foldrun] trigger: flow — ${tenant}/${workspace}/${flow.name} not started: ${gate.detail}`);
91
+ opsLog("info", "trigger.flow_not_started", { tenant, workspace, flow: flow.name, reason: gate.reason });
90
92
  continue;
91
93
  }
92
94
  try {
@@ -96,15 +98,15 @@ export async function fireChainedFlows(tenant, workspace, finished) {
96
98
  `after:${finished.flow}`,
97
99
  ], null, finished.test ? { test: true } : {});
98
100
  started.push(run.id);
99
- console.log(`[foldrun] trigger: flow — ${tenant}/${workspace}/${flow.name} started after ${finished.flow} ${finished.status}`);
101
+ opsLog("info", "trigger.flow_started", { tenant, workspace, flow: flow.name, runId: run.id, kind: "previous_run", outcome: finished.status });
100
102
  }
101
103
  catch (err) {
102
- await platform.rollbackTrigger(tenant, workspace, flow, { reason: err instanceof Error ? err.message : String(err) });
104
+ await platform.rollbackTrigger(tenant, workspace, flow, { reason: err instanceof Error ? err.message : String(err), code: refusalCode(err) });
103
105
  throw err;
104
106
  }
105
107
  }
106
108
  catch (err) {
107
- console.error(`[foldrun] trigger: flow — ${tenant}/${workspace}/${flow.name}:`, err instanceof Error ? err.message : err);
109
+ opsError("trigger.flow_failed", err, { tenant, workspace, flow: flow.name });
108
110
  }
109
111
  }
110
112
  return started;
@@ -151,7 +153,7 @@ export async function fireStorageTriggers(tenant, workspace, paths, by) {
151
153
  // forty runs — which is exactly what `debounce:` is for.
152
154
  const gate = await platform.admitTrigger(tenant, workspace, flow, { body, tag: "storage_event", fields: { by, paths: hits } });
153
155
  if (!gate.admit) {
154
- console.log(`[foldrun] trigger: storage — ${tenant}/${workspace}/${flow.name} not started: ${gate.detail}`);
156
+ opsLog("info", "trigger.storage_not_started", { tenant, workspace, flow: flow.name, reason: gate.reason });
155
157
  continue;
156
158
  }
157
159
  try {
@@ -161,12 +163,12 @@ export async function fireStorageTriggers(tenant, workspace, paths, by) {
161
163
  started.push(run.id);
162
164
  }
163
165
  catch (err) {
164
- await platform.rollbackTrigger(tenant, workspace, flow, { reason: err instanceof Error ? err.message : String(err) });
166
+ await platform.rollbackTrigger(tenant, workspace, flow, { reason: err instanceof Error ? err.message : String(err), code: refusalCode(err) });
165
167
  throw err;
166
168
  }
167
169
  }
168
170
  catch (err) {
169
- console.error(`[foldrun] trigger: storage — ${tenant}/${workspace}/${flow.name}:`, err instanceof Error ? err.message : err);
171
+ opsError("trigger.storage_failed", err, { tenant, workspace, flow: flow.name });
170
172
  }
171
173
  }
172
174
  return started;
@@ -1,6 +1,7 @@
1
1
  // Per-flow webhook tokens, derived rather than stored: HMAC of the flow's
2
2
  // identity under the install's secret key. Stable across restarts, unique
3
3
  // per flow, and rotating FOLDRUN_SECRET_KEY invalidates every hook at once.
4
+ import { opsLog } from "./ops-log.js";
4
5
  import fs from "node:fs";
5
6
  import path from "node:path";
6
7
  import { workspaceDir } from "./store.js";
@@ -171,8 +172,8 @@ function noteRefusal(tenant, workspace, delivery) {
171
172
  seen.since++;
172
173
  return;
173
174
  }
174
- const more = seen?.since ? ` (and ${seen.since} more since the last note)` : "";
175
- console.warn(`[hooks] refused a delivery to ${key}/${delivery.flow}: ${delivery.outcome}${more}`);
175
+ // count: this one and those refused since the last note.
176
+ opsLog("warn", "webhook.delivery_refused", { tenant, workspace, flow: delivery.flow, outcome: delivery.outcome, count: (seen?.since ?? 0) + 1 });
176
177
  refusalNotes.set(key, { at: now, since: 0 });
177
178
  if (refusalNotes.size > 10_000)
178
179
  refusalNotes.clear(); // bounded: a note lost beats memory
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldrun/core",
3
- "version": "14.5.0",
3
+ "version": "15.1.0",
4
4
  "description": "Agents are just folders. The format, the runner, the checks.",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "type": "module",
@@ -1,26 +1,48 @@
1
1
  // Browsing and `network:` (FOL-110, foldrun-docs/proposals/browse-egress.md).
2
2
  //
3
- // A step that may browse is not held to its `network:` list yet: the runner
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 will confine it.
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:` will refuse it.
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 the plain fact that it does not
35
- * hold yet — for the browser or anything else in the step. */
36
- export function browseNetworkLine(policy: NetworkPolicy, vendor: string | null | undefined): string {
37
- const { tier, title } = browseTier(vendor);
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
- const now = " — not enforced in this step: it may browse, and browsing does not go through the egress proxy yet, so the browser and every other program in this step reach sites directly";
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
- ? `. Its browser is ${title}: it comes under network: when hosted enforcement ships (FOL-110)`
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/capture.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  // is not in the vault, and is still a key. Masked first, cut second, so a
6
6
  // secret on the cap's edge is never kept half. Recording never fails the step.
7
7
 
8
+ import { opsError } from "./ops-log.ts";
8
9
  import { redactText } from "./scan.ts";
9
10
  import { writeCapturedCall, CAPTURE_CAP } from "./store.ts";
10
11
  import { isFileValue, fileContent, isApiValue, apiConfigOf, isClientCertValue, clientCertOf } from "./secrets.ts";
@@ -114,7 +115,7 @@ export function recordCallIo(
114
115
  });
115
116
  return true;
116
117
  } catch (err) {
117
- console.error(`[capture] ${tool} (${callId}) for ${runId}:`, err instanceof Error ? err.message : err);
118
+ opsError("capture.write_failed", err, { tool, runId });
118
119
  return false;
119
120
  }
120
121
  }
package/src/mail.ts CHANGED
@@ -24,6 +24,7 @@
24
24
  // — the platform keeps them as records. A laptop has no preferences store and
25
25
  // sends everything, which is what it always did.
26
26
 
27
+ import { opsError } from "./ops-log.ts";
27
28
  import crypto from "node:crypto";
28
29
  import { platform } from "./platform.ts";
29
30
  import { installKey, publicUrl } from "./webhook.ts";
@@ -247,7 +248,7 @@ export async function mailWanted(tenant: string, email: string, category: MailCa
247
248
  } catch (err) {
248
249
  // A preferences store that cannot be read sends: a missed alert is
249
250
  // worse than one unwanted mail, and the next send asks again.
250
- console.error(`[foldrun] mail: preference for ${category} unreadable, sending:`, err instanceof Error ? err.message : err);
251
+ opsError("mail.preference_unreadable", err, { tenant, kind: category, outcome: "sent" }, "warn");
251
252
  return true;
252
253
  }
253
254
  }
package/src/notify.ts CHANGED
@@ -31,6 +31,7 @@
31
31
  // that works is the quiet kind of good news, and a channel that pings on
32
32
  // every success gets muted, which un-pings the failures too.
33
33
 
34
+ import { opsLog, opsError } from "./ops-log.ts";
34
35
  import crypto from "node:crypto";
35
36
  import { readAgentsMd } from "./runner.ts";
36
37
  import { accountDir, workspaceDir, runCost, readFlow, runVerdict, type RunRecord } from "./store.ts";
@@ -179,9 +180,7 @@ export function signatureHeaders(
179
180
  if (!config.signingSecret) return {};
180
181
  const secret = getSecret(tenant, config.signingSecret, workspace);
181
182
  if (!secret) {
182
- console.error(
183
- `[foldrun] notify: signing_secret names ${signingSecretShown(config.signingSecret)}, which is not in the vault for ${tenant}/${workspace} — sending unsigned`,
184
- );
183
+ opsLog("warn", "notify.signing_secret_missing", { tenant, workspace, outcome: "sent_unsigned" });
185
184
  return {};
186
185
  }
187
186
  const timestamp = Math.floor(Date.now() / 1000).toString();
@@ -503,7 +502,7 @@ export async function sendPlainNotificationOutcome(
503
502
  const r = await platform.deliverWebhook(tenant, workspace, { event: msg.event, body: JSON.stringify(body), retry: true });
504
503
  return { ok: r.ok, retrying: r.retrying === true };
505
504
  } catch (err) {
506
- console.error(`[foldrun] notify (${msg.event}): ${tenant}/${workspace} →`, err instanceof Error ? err.message : err);
505
+ opsError("notify.event_failed", err, { tenant, workspace, kind: msg.event });
507
506
  return no;
508
507
  }
509
508
  }
@@ -672,7 +671,9 @@ export async function sendRunNotification(
672
671
  if (config.email) {
673
672
  const mail = notifyMail(tenant, workspace);
674
673
  if (!mail) {
675
- console.error(`[foldrun] notify: email configured but no mail credential — set RESEND_API_KEY (and EMAIL_FROM) on the account ${tenant}, or FOLDRUN_RESEND_API_KEY on the platform`);
674
+ // RESEND_API_KEY (and EMAIL_FROM) on the account, or
675
+ // FOLDRUN_RESEND_API_KEY on the platform.
676
+ opsLog("error", "notify.no_mail_credential", { tenant, workspace });
676
677
  return false;
677
678
  }
678
679
  // A gate is its own category: a person may want failures and not
@@ -707,7 +708,9 @@ export async function sendRunNotification(
707
708
  // Resend's body says WHY — "domain not verified", "can only send to
708
709
  // your own address" — and a status alone sent someone to the wrong
709
710
  // dashboard for twenty minutes on 2026-09-06.
710
- console.error(`[foldrun] notify email: ${tenant}/${workspace} → ${r.status ? `HTTP ${r.status} ` : ""}${r.error ?? ""}`);
711
+ // The provider's words stay out of our log (they quote what was
712
+ // sent); the status is what an operator can act on.
713
+ opsLog("error", "notify.email_failed", { tenant, workspace, status: r.status });
711
714
  return false;
712
715
  }
713
716
  return true;
@@ -717,18 +720,18 @@ export async function sendRunNotification(
717
720
  // vault instead of in a file that gets committed.
718
721
  const target = webhookTarget(tenant, workspace, config);
719
722
  if (!target.url) {
720
- console.error(`[foldrun] notify: ${target.refused ?? "secret in URL not set"} for ${tenant}/${workspace}`);
723
+ opsLog("error", "notify.no_webhook_url", { tenant, workspace, reason: target.refused ? "refused" : "secret_not_set" });
721
724
  return false;
722
725
  }
723
726
  const event = blocked ? "blocked" : run.status;
724
727
  const r = await platform.deliverWebhook(tenant, workspace, { event, body: JSON.stringify(body), retry: true });
725
728
  if (!r.ok) {
726
- console.error(`[foldrun] notify: ${tenant}/${workspace} → ${r.statusCode ? `HTTP ${r.statusCode}` : r.detail}${r.retrying ? " (will retry)" : ""}`);
729
+ opsLog("error", "notify.webhook_failed", { tenant, workspace, status: r.statusCode, retrying: r.retrying === true });
727
730
  return false;
728
731
  }
729
732
  return true;
730
733
  } catch (err) {
731
- console.error(`[foldrun] notify: ${tenant}/${workspace} →`, err instanceof Error ? err.message : err);
734
+ opsError("notify.failed", err, { tenant, workspace });
732
735
  return false;
733
736
  }
734
737
  }