@foldrun/core 0.4.0 → 0.5.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/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/src/account.d.ts +45 -0
- package/dist/src/account.js +130 -0
- package/dist/src/api-tools.d.ts +8 -0
- package/dist/src/api-tools.js +22 -4
- package/dist/src/browser-pod.d.ts +129 -0
- package/dist/src/browser-pod.js +284 -0
- package/dist/src/catalog.js +2 -1
- package/dist/src/clock.d.ts +49 -0
- package/dist/src/clock.js +121 -0
- package/dist/src/completions.js +17 -8
- package/dist/src/confine.d.ts +22 -0
- package/dist/src/confine.js +218 -3
- package/dist/src/deploy.d.ts +33 -0
- package/dist/src/deploy.js +145 -6
- package/dist/src/egress.d.ts +7 -0
- package/dist/src/egress.js +6 -0
- package/dist/src/eol.d.ts +2 -0
- package/dist/src/eol.js +7 -0
- package/dist/src/evals.d.ts +5 -0
- package/dist/src/evals.js +6 -2
- package/dist/src/flow-lint.d.ts +8 -0
- package/dist/src/flow-lint.js +223 -1
- package/dist/src/flow-patterns.d.ts +141 -0
- package/dist/src/flow-patterns.js +568 -0
- package/dist/src/gitrepo.d.ts +18 -0
- package/dist/src/gitrepo.js +49 -0
- package/dist/src/kinds.js +1 -1
- package/dist/src/language.d.ts +17 -0
- package/dist/src/language.js +55 -0
- package/dist/src/layout.d.ts +69 -0
- package/dist/src/layout.js +200 -0
- package/dist/src/library.d.ts +9 -0
- package/dist/src/library.js +30 -3
- package/dist/src/limits.d.ts +84 -0
- package/dist/src/limits.js +287 -0
- package/dist/src/locale.d.ts +47 -0
- package/dist/src/locale.js +177 -0
- package/dist/src/mail.d.ts +88 -0
- package/dist/src/mail.js +245 -0
- package/dist/src/model-probe.d.ts +3 -0
- package/dist/src/model-probe.js +1 -0
- package/dist/src/notify.d.ts +53 -7
- package/dist/src/notify.js +194 -126
- package/dist/src/openapi.js +5 -3
- package/dist/src/operator.d.ts +201 -0
- package/dist/src/operator.js +251 -0
- package/dist/src/paths.d.ts +28 -0
- package/dist/src/paths.js +55 -0
- package/dist/src/platform.d.ts +43 -3
- package/dist/src/platform.js +9 -1
- package/dist/src/provider-health.js +3 -2
- package/dist/src/providers.d.ts +481 -0
- package/dist/src/providers.js +1105 -6
- package/dist/src/refusal.d.ts +83 -0
- package/dist/src/refusal.js +281 -0
- package/dist/src/run-container.d.ts +149 -13
- package/dist/src/run-container.js +403 -42
- package/dist/src/runner.d.ts +142 -9
- package/dist/src/runner.js +1027 -122
- package/dist/src/runtime.d.ts +52 -0
- package/dist/src/runtime.js +493 -58
- package/dist/src/script-tools.d.ts +3 -2
- package/dist/src/script-tools.js +35 -3
- package/dist/src/secret-files.d.ts +6 -5
- package/dist/src/secret-files.js +24 -11
- package/dist/src/secret-health.d.ts +30 -6
- package/dist/src/secret-health.js +42 -20
- package/dist/src/secrets.d.ts +19 -0
- package/dist/src/secrets.js +155 -86
- package/dist/src/starter.d.ts +9 -0
- package/dist/src/starter.js +92 -11
- package/dist/src/step-exec.d.ts +61 -2
- package/dist/src/step-exec.js +414 -36
- package/dist/src/step-removal.d.ts +15 -0
- package/dist/src/step-removal.js +49 -0
- package/dist/src/storage.d.ts +23 -4
- package/dist/src/storage.js +125 -23
- package/dist/src/store.d.ts +218 -37
- package/dist/src/store.js +347 -60
- package/dist/src/subagents.d.ts +75 -0
- package/dist/src/subagents.js +149 -0
- package/dist/src/tool-names.d.ts +13 -1
- package/dist/src/tool-names.js +38 -11
- package/dist/src/tool-programs.d.ts +26 -0
- package/dist/src/tool-programs.js +172 -0
- package/dist/src/tool-test.js +104 -12
- package/dist/src/translator.d.ts +8 -2
- package/dist/src/translator.js +69 -23
- package/dist/src/trigger-log.d.ts +1 -1
- package/dist/src/triggers.d.ts +3 -0
- package/dist/src/triggers.js +10 -2
- package/dist/src/untrusted-fetch.d.ts +11 -0
- package/dist/src/untrusted-fetch.js +77 -0
- package/dist/src/web-actions.d.ts +91 -0
- package/dist/src/web-actions.js +199 -0
- package/dist/src/webhook.d.ts +4 -0
- package/dist/src/webhook.js +39 -0
- package/index.ts +3 -0
- package/package.json +3 -3
- package/src/account.ts +149 -0
- package/src/api-tools.ts +32 -4
- package/src/browser-pod.ts +313 -0
- package/src/catalog.ts +2 -1
- package/src/clock.ts +149 -0
- package/src/completions.ts +17 -8
- package/src/confine.ts +218 -3
- package/src/deploy.ts +137 -6
- package/src/egress.ts +13 -1
- package/src/eol.ts +7 -0
- package/src/evals.ts +11 -2
- package/src/flow-lint.ts +253 -1
- package/src/flow-patterns.ts +597 -0
- package/src/gitrepo.ts +48 -0
- package/src/kinds.ts +1 -1
- package/src/language.ts +62 -0
- package/src/layout.ts +228 -0
- package/src/library.ts +37 -3
- package/src/limits.ts +290 -0
- package/src/locale.ts +217 -0
- package/src/mail.ts +316 -0
- package/src/model-probe.ts +4 -0
- package/src/notify.ts +189 -103
- package/src/openapi.ts +5 -3
- package/src/operator.ts +300 -0
- package/src/paths.ts +54 -0
- package/src/platform.ts +52 -3
- package/src/provider-health.ts +3 -2
- package/src/providers.ts +1368 -6
- package/src/refusal.ts +320 -0
- package/src/run-container.ts +439 -43
- package/src/runner.ts +1050 -122
- package/src/runtime.ts +487 -55
- package/src/script-tools.ts +38 -5
- package/src/secret-files.ts +22 -10
- package/src/secret-health.ts +64 -19
- package/src/secrets.ts +149 -87
- package/src/starter.ts +93 -11
- package/src/step-exec.ts +429 -37
- package/src/step-removal.ts +59 -0
- package/src/storage.ts +141 -22
- package/src/store.ts +500 -68
- package/src/subagents.ts +189 -0
- package/src/tool-names.ts +40 -11
- package/src/tool-programs.ts +179 -0
- package/src/tool-test.ts +110 -12
- package/src/translator.ts +72 -22
- package/src/trigger-log.ts +1 -0
- package/src/triggers.ts +10 -2
- package/src/untrusted-fetch.ts +88 -0
- package/src/web-actions.ts +237 -0
- package/src/webhook.ts +41 -0
- package/templates/hello/agents/curator/agent.md +1 -1
- package/templates/hello/agents/notetaker/agent.md +1 -1
package/dist/src/runner.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
import { type SubagentSpec } from "./subagents.ts";
|
|
1
2
|
import { type FlowStep, type RunRecord, type StepRecord } from "./store.ts";
|
|
3
|
+
import { type Catalog } from "./catalog.ts";
|
|
4
|
+
import { type RuntimeSpec } from "./runtime.ts";
|
|
5
|
+
import { type LanguageChoice } from "./language.ts";
|
|
6
|
+
import { type RegionChoice } from "./locale.ts";
|
|
7
|
+
import { type ClockChoice } from "./clock.ts";
|
|
8
|
+
export { localDate } from "./clock.ts";
|
|
2
9
|
/** How much of the earlier groups' output a step is handed, in characters.
|
|
3
10
|
* Newest groups are kept when the total is over it. */
|
|
4
11
|
export declare const CONTEXT_CHARS = 30000;
|
|
@@ -48,20 +55,73 @@ export declare function discoverSkills(agentDir: string, subdir?: string): Disco
|
|
|
48
55
|
* Returns null rather than throwing on unparseable YAML: a broken shared file
|
|
49
56
|
* must not take down every agent under it.
|
|
50
57
|
*/
|
|
58
|
+
/**
|
|
59
|
+
* AGENTS.md without the block a coding tool reads.
|
|
60
|
+
*
|
|
61
|
+
* AGENTS.md is two things in a foldrun folder: the account's (or
|
|
62
|
+
* workspace's) own context, which every running agent is given, and — the
|
|
63
|
+
* convention Next.js set — the file a coding agent (Claude Code, Cursor,
|
|
64
|
+
* Codex) reads before it edits the folder. The CLI writes a short managed
|
|
65
|
+
* block for the second reader between these markers; it is about editing
|
|
66
|
+
* the files, not about doing the work, so no running agent is shown it.
|
|
67
|
+
*/
|
|
68
|
+
export declare const AGENT_RULES_START = "<!-- BEGIN:foldrun-agent-rules -->";
|
|
69
|
+
export declare const AGENT_RULES_END = "<!-- END:foldrun-agent-rules -->";
|
|
70
|
+
export declare function withoutAgentRules(body: string): string;
|
|
51
71
|
export declare function readAgentsMd(dir: string): {
|
|
52
72
|
data: Record<string, unknown>;
|
|
53
73
|
body: string;
|
|
54
74
|
} | null;
|
|
55
75
|
/**
|
|
56
|
-
* The
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
76
|
+
* The runtime one agent's steps are built with: its own declaration (else its
|
|
77
|
+
* workspace's), merged with every script tool it grants. The runner builds
|
|
78
|
+
* exactly this for a step; the platform builds it ahead of time when the
|
|
79
|
+
* workspace is deployed, so a package that will not install is reported at
|
|
80
|
+
* deploy and a scheduled step finds its environment ready. One function, so
|
|
81
|
+
* the two can never disagree about what an agent needs.
|
|
82
|
+
*/
|
|
83
|
+
export declare function agentRuntimeSpec(tenant: string, workspace: string, agentDir: string): RuntimeSpec | null;
|
|
84
|
+
/** Every distinct runtime a workspace's agents need, with who needs it. */
|
|
85
|
+
export declare function workspaceRuntimePlan(tenant: string, workspace: string): {
|
|
86
|
+
fingerprint: string;
|
|
87
|
+
spec: RuntimeSpec;
|
|
88
|
+
agents: string[];
|
|
89
|
+
}[];
|
|
90
|
+
/**
|
|
91
|
+
* The calendar a set of frontmatter asks for, with no cascade around it —
|
|
92
|
+
* one merged record in, one zone out. The full cascade lives in
|
|
93
|
+
* `agentClock` below and in clock.ts; this is what the account-level parts
|
|
94
|
+
* of the platform (a wallet's month, a budget window) call.
|
|
61
95
|
*/
|
|
62
96
|
export declare function resolveTimezone(front: Record<string, unknown>): string;
|
|
63
|
-
/**
|
|
64
|
-
|
|
97
|
+
/**
|
|
98
|
+
* The clock this step works to: agent, then flow, then workspace, then
|
|
99
|
+
* account, then FOLDRUN_TIMEZONE, then UTC. Nearest wins, and a value that
|
|
100
|
+
* is not a zone falls through to the next level with a line to say so —
|
|
101
|
+
* see clock.ts for why this exists at all.
|
|
102
|
+
*/
|
|
103
|
+
export declare function agentClock(agentDir: string, tenant: string, agentFront: Record<string, unknown>, flowTimezone?: string | null): ClockChoice;
|
|
104
|
+
/**
|
|
105
|
+
* The language this step works in: agent, then workspace, then account, then
|
|
106
|
+
* FOLDRUN_LANGUAGE, then English. The flow level is not read yet — a flow's
|
|
107
|
+
* timezone: travels through three signatures to get here, and this will
|
|
108
|
+
* take the same road when a flow needs it.
|
|
109
|
+
*/
|
|
110
|
+
export declare function agentLanguage(agentDir: string, tenant: string, agentFront: Record<string, unknown>): LanguageChoice;
|
|
111
|
+
/**
|
|
112
|
+
* The country this step works for, on the same road as the language, then
|
|
113
|
+
* FOLDRUN_REGION, then whatever the language tag carried (`en-AU` says AU).
|
|
114
|
+
* Everything a country changes — currency, units, calendar, weekend, text
|
|
115
|
+
* direction — is derived from it in locale.ts; the three overrides
|
|
116
|
+
* (`currency:`, `calendar:`, `units:`) are read at the nearest level that
|
|
117
|
+
* wrote them.
|
|
118
|
+
*/
|
|
119
|
+
export declare function agentRegion(agentDir: string, tenant: string, agentFront: Record<string, unknown>, languageTag: string): RegionChoice;
|
|
120
|
+
export declare function agentLocaleOverrides(agentDir: string, tenant: string, agentFront: Record<string, unknown>): {
|
|
121
|
+
currency?: unknown;
|
|
122
|
+
calendar?: unknown;
|
|
123
|
+
units?: unknown;
|
|
124
|
+
};
|
|
65
125
|
/**
|
|
66
126
|
* The prose from AGENTS.md, outermost first.
|
|
67
127
|
*
|
|
@@ -69,6 +129,23 @@ export declare function localDate(timeZone: string, now?: Date): string;
|
|
|
69
129
|
* template as "context every agent here shares" — and never read. Only the
|
|
70
130
|
* frontmatter was, so the instructions people actually wrote reached no model.
|
|
71
131
|
*/
|
|
132
|
+
/**
|
|
133
|
+
* The sub-agents a step may delegate to (`subagents:`), as the SDK will get
|
|
134
|
+
* them: each resolved through agentContext exactly as its own step would be
|
|
135
|
+
* (grants only — no runtime; it runs inside its parent's), then cut to what
|
|
136
|
+
* the parent holds. Problems are lines on the step, never a failed step.
|
|
137
|
+
*/
|
|
138
|
+
export declare function buildSubagentSpecs(o: {
|
|
139
|
+
names: unknown;
|
|
140
|
+
self: string;
|
|
141
|
+
workspaceRoot: string;
|
|
142
|
+
tenant: string;
|
|
143
|
+
tags?: string[];
|
|
144
|
+
runId?: string;
|
|
145
|
+
flowTimezone?: string | null;
|
|
146
|
+
parentAllowed: string[];
|
|
147
|
+
push: (type: "info" | "error", text: string) => void;
|
|
148
|
+
}): SubagentSpec[];
|
|
72
149
|
export declare function sharedInstructions(agentDir: string, tenant: string): string | null;
|
|
73
150
|
/**
|
|
74
151
|
* Which of an agent's in-scope skills load for this run.
|
|
@@ -113,6 +190,14 @@ export declare function applicableSkills<T extends {
|
|
|
113
190
|
*/
|
|
114
191
|
export declare function saysUntilMarker(result: string | null, until: string): boolean;
|
|
115
192
|
export declare function resolveDocLinks(text: string, workspaceRoot: string): string;
|
|
193
|
+
export declare function repriced(catalog: Catalog | null, model: string, usage: {
|
|
194
|
+
inputTokens: number;
|
|
195
|
+
outputTokens: number;
|
|
196
|
+
} | null, sdkCost: number | null, push: (type: "info" | "error", text: string) => void,
|
|
197
|
+
/** The step's turns each priced at its own model — set when a sub-agent
|
|
198
|
+
* ran on a different model (ExecOutcome.turnsCostUsd). The lump `usage`
|
|
199
|
+
* priced at the step's model would bill those turns at the wrong rate. */
|
|
200
|
+
turnsCostUsd?: number | null): number | null;
|
|
116
201
|
/**
|
|
117
202
|
* Write one attempt onto the step's history and re-total the step.
|
|
118
203
|
*
|
|
@@ -123,10 +208,29 @@ export declare function resolveDocLinks(text: string, workspaceRoot: string): st
|
|
|
123
208
|
* step used to carry only its last attempt's cost, so a `retry: 2` step
|
|
124
209
|
* could spend three shares while reporting one.
|
|
125
210
|
*/
|
|
126
|
-
export declare function recordAttempt(step: StepRecord,
|
|
211
|
+
export declare function recordAttempt(step: StepRecord,
|
|
212
|
+
/** The step's attempt (`attempts`) these rows belong to. */
|
|
213
|
+
attempt: number, status: "completed" | "failed", startedAt: string, eventsBefore: number,
|
|
127
214
|
/** The attempt re-attached to a sandbox a previous driver left: same
|
|
128
215
|
* attempt, so its row is replaced rather than repeated. */
|
|
129
216
|
reattach?: boolean): void;
|
|
217
|
+
/**
|
|
218
|
+
* Did this attempt call its tools and then fail only on the check after —
|
|
219
|
+
* `verify:`, `output: json`, a schema? For a step whose tools act outward
|
|
220
|
+
* that is the one failure a retry must not answer: the email went, the post
|
|
221
|
+
* is up, and the check failing says nothing about whether they happened. A
|
|
222
|
+
* second attempt sends them again. Read off the attempt's own events, which
|
|
223
|
+
* both executors write the same way (step-exec.ts): every event a failed
|
|
224
|
+
* check writes carries `check: true`. It used to read only the LAST error's
|
|
225
|
+
* wording, and a failed shell verify or judge writes its detail after its
|
|
226
|
+
* headline — so the step was retried and the email went twice. The wording
|
|
227
|
+
* is still honoured, for a driver image older than the tag.
|
|
228
|
+
*/
|
|
229
|
+
export declare function actedThenFailedCheck(events: {
|
|
230
|
+
type: string;
|
|
231
|
+
text: string;
|
|
232
|
+
check?: boolean;
|
|
233
|
+
}[]): boolean;
|
|
130
234
|
/**
|
|
131
235
|
* Copy a directory tree by reading and writing the bytes.
|
|
132
236
|
*
|
|
@@ -140,6 +244,13 @@ reattach?: boolean): void;
|
|
|
140
244
|
* happened to create it.
|
|
141
245
|
*/
|
|
142
246
|
export declare function copyTreeBytes(from: string, to: string): void;
|
|
247
|
+
/**
|
|
248
|
+
* Wait, briefly, for the mounted credential to become one we have not
|
|
249
|
+
* already been refused on. Returns the new value, or null when the window
|
|
250
|
+
* passes without a change — which is the answer that means "this key is
|
|
251
|
+
* wrong", not "this key is stale".
|
|
252
|
+
*/
|
|
253
|
+
export declare function awaitRotatedCredential(before: string | undefined, now?: () => number, read?: () => string | undefined, waitMs?: number, pollMs?: number): Promise<string | null>;
|
|
143
254
|
/** How many times a busy provider is given another moment, and the longest
|
|
144
255
|
* any one wait may be. Three is the industry's habit and the point where
|
|
145
256
|
* waiting longer stops being kinder than failing. */
|
|
@@ -157,9 +268,31 @@ export declare const OVERLOAD_RETRIES = 3;
|
|
|
157
268
|
*/
|
|
158
269
|
export declare function isTransientOverload(text: string): boolean;
|
|
159
270
|
export declare function backoffMs(attempt: number, text?: string, random?: () => number): number;
|
|
271
|
+
/**
|
|
272
|
+
* The platform's model credential, read at the moment a step needs it.
|
|
273
|
+
*
|
|
274
|
+
* It used to come only from this process's environment, which meant the
|
|
275
|
+
* worker held whatever token it was started with. Refreshing an OAuth token
|
|
276
|
+
* REVOKES the old one, so a refresh without a restart left every run
|
|
277
|
+
* answering 401 — on 2026-09-18 that took every desk down for two hours, and
|
|
278
|
+
* nothing said so until a person read a failed run. The refresher's own
|
|
279
|
+
* comment had named the fix years of incidents earlier: stop shipping the
|
|
280
|
+
* token as an env var.
|
|
281
|
+
*
|
|
282
|
+
* So: when `FOLDRUN_MODEL_KEY_FILE` names a file (the Kubernetes secret,
|
|
283
|
+
* mounted rather than injected), it is read fresh every time. The kubelet
|
|
284
|
+
* updates a mounted secret in place within about a minute of it changing, so
|
|
285
|
+
* a refreshed token reaches the next step on its own, with no restart, no
|
|
286
|
+
* timing window, and nothing to skip while work is in flight.
|
|
287
|
+
*
|
|
288
|
+
* A missing or empty file falls back to the environment, which is what a
|
|
289
|
+
* local install, the CLI and every compose setup use.
|
|
290
|
+
*/
|
|
291
|
+
export declare function platformModelCredential(env?: NodeJS.ProcessEnv): string | undefined;
|
|
292
|
+
export declare function platformModelEnv(): Record<string, string | undefined>;
|
|
160
293
|
/**
|
|
161
294
|
* `schema: <path>` — the file, read and parsed, or null. Agent-relative like
|
|
162
|
-
* every other path in a flow (
|
|
295
|
+
* every other path in a flow (`workspace/schemas/lead.json`), confined to the
|
|
163
296
|
* workspace: a schema is the author's document, never something a step
|
|
164
297
|
* can point outside.
|
|
165
298
|
*/
|