@foldrun/core 0.4.0 → 0.6.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/README.md +7 -4
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -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 +148 -0
- package/dist/src/browser-pod.js +333 -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/container.d.ts +9 -0
- package/dist/src/container.js +115 -5
- package/dist/src/context-tools.d.ts +1 -1
- 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 +9 -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/host-env.js +5 -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 +247 -0
- package/dist/src/model-credential.d.ts +14 -0
- package/dist/src/model-credential.js +58 -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 +424 -43
- package/dist/src/runner.d.ts +177 -9
- package/dist/src/runner.js +1146 -154
- package/dist/src/runtime.d.ts +52 -0
- package/dist/src/runtime.js +493 -58
- package/dist/src/script-tools.d.ts +17 -2
- package/dist/src/script-tools.js +82 -10
- 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 +72 -2
- package/dist/src/step-exec.js +431 -37
- 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 +222 -37
- package/dist/src/store.js +349 -62
- package/dist/src/subagents.d.ts +75 -0
- package/dist/src/subagents.js +149 -0
- package/dist/src/test-mode.d.ts +17 -2
- package/dist/src/test-mode.js +53 -13
- 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 +4 -0
- package/package.json +3 -3
- package/src/account.ts +149 -0
- package/src/api-tools.ts +32 -4
- package/src/browser-pod.ts +350 -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/container.ts +112 -5
- package/src/context-tools.ts +1 -1
- package/src/deploy.ts +137 -6
- package/src/egress.ts +13 -1
- package/src/eol.ts +7 -0
- package/src/evals.ts +14 -2
- package/src/flow-lint.ts +253 -1
- package/src/flow-patterns.ts +597 -0
- package/src/gitrepo.ts +48 -0
- package/src/host-env.ts +5 -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 +318 -0
- package/src/model-credential.ts +71 -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 +460 -44
- package/src/runner.ts +1168 -155
- package/src/runtime.ts +487 -55
- package/src/script-tools.ts +81 -10
- 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 +447 -38
- package/src/step-removal.ts +59 -0
- package/src/storage.ts +141 -22
- package/src/store.ts +506 -70
- package/src/subagents.ts +189 -0
- package/src/test-mode.ts +51 -11
- 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/blog-desk/agents/writer/agent.md +1 -1
- package/templates/hello/agents/curator/agent.md +4 -4
- package/templates/hello/agents/notetaker/agent.md +3 -3
package/dist/src/step-exec.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { McpServerConfig } from "@anthropic-ai/claude-agent-sdk";
|
|
2
2
|
import type { Effort } from "./store.ts";
|
|
3
3
|
import type { TestEffect } from "./test-mode.ts";
|
|
4
|
+
import type { OperatorEvent } from "./operator.ts";
|
|
5
|
+
import { type SubagentSpec } from "./subagents.ts";
|
|
6
|
+
import { type Limits } from "./limits.ts";
|
|
7
|
+
import { type BrowserPodOutcome, type ClassifyContext } from "./browser-pod.ts";
|
|
4
8
|
export interface ExecOutcome {
|
|
5
9
|
status: "completed" | "failed";
|
|
6
10
|
result: string | null;
|
|
@@ -20,6 +24,20 @@ export interface ExecOutcome {
|
|
|
20
24
|
inputTokens: number;
|
|
21
25
|
outputTokens: number;
|
|
22
26
|
} | null;
|
|
27
|
+
/** Set only when some turns ran on a different model from the step's — a
|
|
28
|
+
* sub-agent with its own `model:`. The sum of every turn, each priced at
|
|
29
|
+
* its own model. `usage` above is one lump and cannot be repriced at the
|
|
30
|
+
* step's model without charging the sub-agent's turns at the wrong rate;
|
|
31
|
+
* the runner reads this instead (repriced in runner.ts). */
|
|
32
|
+
turnsCostUsd?: number;
|
|
33
|
+
/** Why the model's last turn ended, as the SDK's result message says:
|
|
34
|
+
* end_turn, max_tokens, stop_sequence, tool_use, pause_turn, refusal or
|
|
35
|
+
* model_context_window_exceeded. Null when no result arrived. */
|
|
36
|
+
stopReason?: string | null;
|
|
37
|
+
/** Set when the step browsed through the account's browser pod from the
|
|
38
|
+
* slim image (ExecOptions.browserPod): its reconnects, and — when the pod
|
|
39
|
+
* was lost — why, and what the step had written by then. */
|
|
40
|
+
browserPod?: BrowserPodOutcome;
|
|
23
41
|
}
|
|
24
42
|
export interface ExecOptions {
|
|
25
43
|
agentDir: string;
|
|
@@ -77,10 +95,41 @@ export interface ExecOptions {
|
|
|
77
95
|
* runner answers from the run record (stopRun writes there from another
|
|
78
96
|
* process); a container has a sandbox that is destroyed instead. */
|
|
79
97
|
stopRequested?: () => boolean;
|
|
98
|
+
/** Reads the run's inbox (operator.ts inboxReader): what a person wrote
|
|
99
|
+
* in while the step runs, handed to the model after its next tool call.
|
|
100
|
+
* Absent where nobody can write in (no egress proxy). */
|
|
101
|
+
inbox?: () => Promise<string | null>;
|
|
102
|
+
/** `subagents:` — colleagues the model may delegate to, each with its own
|
|
103
|
+
* context and tools no wider than this step's (subagents.ts). Absent or
|
|
104
|
+
* empty: no Agent tool, as before. */
|
|
105
|
+
subagents?: SubagentSpec[];
|
|
106
|
+
/** `limits:` — the most calls this step may make, per tool and in all,
|
|
107
|
+
* resolved host-side (account, workspace, agent, step: nearest wins per
|
|
108
|
+
* key). Counted in the PreToolUse hook below; see limits.ts. */
|
|
109
|
+
limits?: Limits;
|
|
110
|
+
/** SDK tool name → the foldrun name it counts under, for the tools whose
|
|
111
|
+
* SDK name does not say (limits.ts toolOwners). */
|
|
112
|
+
toolOwners?: Record<string, string>;
|
|
113
|
+
/** The step runs on the slim image and browses through the account's
|
|
114
|
+
* browser pod (browser-pod.ts). `events` is the file the web tool writes
|
|
115
|
+
* its reconnects to; the classify context says which API operations and
|
|
116
|
+
* web actions are writes. A lost pod stops the step, and the outcome
|
|
117
|
+
* says what it had written, so the runner can re-run it or fail it. */
|
|
118
|
+
browserPod?: {
|
|
119
|
+
events: string;
|
|
120
|
+
} & ClassifyContext;
|
|
80
121
|
emit: (type: "text" | "tool" | "info" | "error", text: string, extra?: EventExtra) => void;
|
|
81
122
|
}
|
|
82
123
|
/** How often the stop flag is read while a step runs. */
|
|
83
124
|
export declare const STOP_POLL_MS = 2000;
|
|
125
|
+
/** The least a `verify:` gets when the step used up most of its `timeout:` —
|
|
126
|
+
* capped by the timeout itself, so the step and its check together never
|
|
127
|
+
* run past timeout + this. Under the isolated path's backstop (+60 s). */
|
|
128
|
+
export declare const VERIFY_FLOOR_MS = 30000;
|
|
129
|
+
/** How long a `verify:` may run: what is left of the step's `timeout:`,
|
|
130
|
+
* with a floor. Null when the flow set no timeout — `timeout:` is the only
|
|
131
|
+
* clock there is, and a stop still ends the check. */
|
|
132
|
+
export declare function verifyBudgetMs(timeoutSec: number | undefined, elapsedMs: number): number | null;
|
|
84
133
|
/** After an interrupt is asked for, how long the model loop gets to wind
|
|
85
134
|
* down on its own before the query is aborted outright. */
|
|
86
135
|
export declare const INTERRUPT_GRACE_MS = 10000;
|
|
@@ -99,6 +148,9 @@ export type EventExtra = {
|
|
|
99
148
|
ms?: number;
|
|
100
149
|
err?: boolean;
|
|
101
150
|
effect?: TestEffect;
|
|
151
|
+
operator?: OperatorEvent;
|
|
152
|
+
subagent?: string;
|
|
153
|
+
check?: boolean;
|
|
102
154
|
};
|
|
103
155
|
/** Conservative per-token rates for a model nothing else can price — an
|
|
104
156
|
* unknown id on a gateway with no catalogue. Opus-class, so a ceiling
|
|
@@ -136,11 +188,15 @@ export declare function stepCeiling(budgetUsd: number | null | undefined, spentU
|
|
|
136
188
|
*
|
|
137
189
|
* Two caps can apply to one step: the flow's `budget:` gives it an equal
|
|
138
190
|
* share of what the run has left; the agent's own `budget:` is the most that
|
|
139
|
-
* agent may spend in one run, less what its
|
|
191
|
+
* agent may spend in one run, less what its steps in this run have cost or
|
|
192
|
+
* may still cost, shared across `sharing` — this step and the agent's steps
|
|
193
|
+
* launched with it that have not started yet. Without the share, twenty
|
|
194
|
+
* fan-out copies of one agent each got the whole remainder, because none of
|
|
195
|
+
* them has recorded a cent when the next one starts.
|
|
140
196
|
* The tighter one wins, and the note says which, because "over budget" with
|
|
141
197
|
* no line to go and raise is a message that sends someone to the wrong file.
|
|
142
198
|
*/
|
|
143
|
-
export declare function stepCeilingFor(flowShareUsd: number | null, agentBudgetUsd: number | null | undefined, agentSpentUsd: number, agent: string): {
|
|
199
|
+
export declare function stepCeilingFor(flowShareUsd: number | null, agentBudgetUsd: number | null | undefined, agentSpentUsd: number, agent: string, sharing?: number): {
|
|
144
200
|
ceilingUsd: number | null;
|
|
145
201
|
note: string;
|
|
146
202
|
};
|
|
@@ -189,4 +245,18 @@ export declare function checkVerify(agentDir: string, verify: string, ctx: {
|
|
|
189
245
|
/** The step's own model environment, for `judge:` — it grades on the
|
|
190
246
|
* fast tier through the same credential the step rode. */
|
|
191
247
|
modelEnv?: Record<string, string | undefined>;
|
|
248
|
+
/** Ends a shell check or a judge mid-way: the step's clock ran out, or a
|
|
249
|
+
* person asked the run to stop. */
|
|
250
|
+
signal?: AbortSignal;
|
|
192
251
|
}): Promise<VerifyVerdict>;
|
|
252
|
+
/**
|
|
253
|
+
* The environment an Agent SDK session starts with: the step's, minus the
|
|
254
|
+
* connectors of whoever is signed in to claude.ai on this machine. Claude
|
|
255
|
+
* Code loads an account's claude.ai MCP servers (Docs, Drive, …) unless told
|
|
256
|
+
* not to, and `settingSources: []` does not reach them — they come with the
|
|
257
|
+
* login, not from a settings file. A local `foldrun run` handed every agent
|
|
258
|
+
* the person's own connectors: the hello template's agents reported that
|
|
259
|
+
* "the only tools I have are the Claude Docs ones". `strictMcpConfig` keeps
|
|
260
|
+
* the rest of the on-disk MCP configuration out; this keeps the account's.
|
|
261
|
+
*/
|
|
262
|
+
export declare function sdkEnv(base: Record<string, string | undefined> | undefined, extra?: Record<string, string>): Record<string, string | undefined>;
|