@foldrun/core 24.2.1 → 24.2.3
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/account.js +2 -2
- package/dist/src/agent-import.js +2 -2
- package/dist/src/budget.js +1 -1
- package/dist/src/copy-back.js +2 -2
- package/dist/src/data-import.js +9 -9
- package/dist/src/deploy.js +2 -2
- package/dist/src/failure.js +1 -1
- package/dist/src/flow-lint.js +8 -8
- package/dist/src/frontmatter-fields.js +8 -8
- package/dist/src/mail.js +1 -1
- package/dist/src/manifest.js +1 -1
- package/dist/src/notify.js +2 -2
- package/dist/src/oauth-capabilities.js +1 -1
- package/dist/src/openapi.js +3 -3
- package/dist/src/package.js +2 -2
- package/dist/src/providers.js +2 -2
- package/dist/src/publish.js +2 -2
- package/dist/src/run-container.js +3 -3
- package/dist/src/scan.js +7 -7
- package/dist/src/secrets.js +7 -7
- package/dist/src/starter.js +18 -18
- package/dist/src/storage.js +6 -6
- package/dist/src/store.js +16 -16
- package/dist/src/tool-test.js +1 -1
- package/dist/src/webhook.js +1 -1
- package/dist/src/workspace-revisions.js +2 -2
- package/package.json +1 -1
- package/src/account.ts +2 -2
- package/src/agent-import.ts +2 -2
- package/src/budget.ts +1 -1
- package/src/copy-back.ts +2 -2
- package/src/data-import.ts +9 -9
- package/src/deploy.ts +2 -2
- package/src/failure.ts +1 -1
- package/src/flow-lint.ts +8 -8
- package/src/frontmatter-fields.ts +8 -8
- package/src/mail.ts +1 -1
- package/src/manifest.ts +1 -1
- package/src/notify.ts +2 -2
- package/src/oauth-capabilities.ts +1 -1
- package/src/openapi.ts +3 -3
- package/src/package.ts +2 -2
- package/src/providers.ts +2 -2
- package/src/publish.ts +2 -2
- package/src/run-container.ts +3 -3
- package/src/scan.ts +7 -7
- package/src/secrets.ts +7 -7
- package/src/starter.ts +19 -19
- package/src/storage.ts +6 -6
- package/src/store.ts +16 -16
- package/src/tool-test.ts +1 -1
- package/src/webhook.ts +1 -1
- package/src/workspace-revisions.ts +2 -2
|
@@ -75,7 +75,7 @@ const LOCALE = { validated: true } as const;
|
|
|
75
75
|
const AGENT: FieldSpec[] = [
|
|
76
76
|
{ key: "name", type: "string", help: "kebab-case; the folder is the identity" },
|
|
77
77
|
{ key: "description", type: "string", help: "what it does and when — other agents and people read it" },
|
|
78
|
-
{ key: "owner", type: "string", help: "the person accountable for it — an email or a name; else the
|
|
78
|
+
{ key: "owner", type: "string", help: "the person accountable for it — an email or a name; else the project's, else the account's" },
|
|
79
79
|
{ key: "model", type: "string", help: "fast | default | max, an alias, or a full model id" },
|
|
80
80
|
{ key: "effort", type: "string", values: EFFORT_LEVELS, help: "how long it thinks" },
|
|
81
81
|
{ key: "max_output_tokens", type: ["number", "string"], help: "the most tokens one model reply may have, 1 to 1048576; on foldrun's models the price list's ceiling applies too" },
|
|
@@ -114,8 +114,8 @@ const AGENT: FieldSpec[] = [
|
|
|
114
114
|
const AGENTS_MD: FieldSpec[] = [
|
|
115
115
|
{ key: "foldrun_version", type: ["string", "number"], help: "the format version this account targets" },
|
|
116
116
|
{ key: "mdagent_version", type: ["string", "number"], legacy: true, help: "older spelling of foldrun_version" },
|
|
117
|
-
{ key: "name", type: "string", help: "the
|
|
118
|
-
{ key: "description", type: "string", help: "shown in the
|
|
117
|
+
{ key: "name", type: "string", help: "the project's name" },
|
|
118
|
+
{ key: "description", type: "string", help: "shown in the project list" },
|
|
119
119
|
{ key: "owner", type: "string", help: "the person accountable for every agent and flow here that names none" },
|
|
120
120
|
{ key: "provider", type: "object", help: "the model endpoint every agent here uses unless it names its own" },
|
|
121
121
|
{ key: "runtime", type: "object", help: "packages for agents that declare none" },
|
|
@@ -133,10 +133,10 @@ const AGENTS_MD: FieldSpec[] = [
|
|
|
133
133
|
{ key: "budget", type: ["number", "string"], help: "USD per month, or N/day | N/week | N/month" },
|
|
134
134
|
{ key: "priority", type: "string", values: ["high", "normal", "low"], help: "account: where its runs stand in the queue" },
|
|
135
135
|
{ key: "concurrency", type: ["number", "string"], help: "account: runs at once" },
|
|
136
|
-
{ key: "compute", type: "object", help: "{vcpu, memory, disk} the running steps here may hold together — the account's pool, or this
|
|
136
|
+
{ key: "compute", type: "object", help: "{vcpu, memory, disk} the running steps here may hold together — the account's pool, or this project's; only narrows the level above" },
|
|
137
137
|
{ key: "alerts", type: "object", validated: true, help: "thresholds that tell notify: — failure_rate (30%), min_runs, credits_day, run_minutes, stale_days, cost_spike, runs_per_hour, new_host" },
|
|
138
138
|
{ key: "capture", type: "string", values: ["full", "metadata"], help: "what runs record of each tool call: full (its input and output, secrets masked) or metadata (name, size and time only)" },
|
|
139
|
-
{ key: "network_enforce", type: "boolean", help: "true: a site off a step's network: list is refused, not only named in the trace. The account's or the
|
|
139
|
+
{ key: "network_enforce", type: "boolean", help: "true: a site off a step's network: list is refused, not only named in the trace. The account's or the project's true is enough" },
|
|
140
140
|
{ key: "telemetry", type: "object", validated: true, help: "send each run as an OpenTelemetry trace — otlp: <https …/v1/traces>, headers: { authorization: ${SECRET} }" },
|
|
141
141
|
{ key: "deploy_block", type: "string", values: ["none", "secrets", "security"], help: "refuse a deploy on scanner findings: secrets (a key written in) or security (any security warning)" },
|
|
142
142
|
{ key: "judge", type: "object", validated: true, help: "the model every judge: here grades with — {model: fast | default | max, effort}; an eval's own model: wins" },
|
|
@@ -146,7 +146,7 @@ const AGENTS_MD: FieldSpec[] = [
|
|
|
146
146
|
const FLOW: FieldSpec[] = [
|
|
147
147
|
{ key: "name", type: "string", help: "the flow's name" },
|
|
148
148
|
{ key: "description", type: "string", help: "what it is for" },
|
|
149
|
-
{ key: "owner", type: "string", help: "the person accountable for it — an email or a name; else the
|
|
149
|
+
{ key: "owner", type: "string", help: "the person accountable for it — an email or a name; else the project's, else the account's" },
|
|
150
150
|
{ key: "trigger", type: "string", values: FLOW_TRIGGERS, help: "what starts it; any other value never fires" },
|
|
151
151
|
{ key: "schedule", type: "string", help: "cron, when trigger: schedule" },
|
|
152
152
|
{ key: "timezone", type: "string", validated: true, help: "the zone its schedule reads in" },
|
|
@@ -175,7 +175,7 @@ const FLOW: FieldSpec[] = [
|
|
|
175
175
|
{ key: "pause_when", type: "string", help: "a marker that pauses the flow when a run's result says it" },
|
|
176
176
|
{ key: "approvers", type: ["list", "string"], help: "who may approve its gates" },
|
|
177
177
|
{ key: "budget", type: ["number", "string"], help: "USD per run" },
|
|
178
|
-
{ key: "compute", type: "object", help: "{vcpu, memory, disk} one run's steps may hold together at once — only narrows the
|
|
178
|
+
{ key: "compute", type: "object", help: "{vcpu, memory, disk} one run's steps may hold together at once — only narrows the project's and account's" },
|
|
179
179
|
{ key: "live", type: "boolean", help: "true: steps may act for real in a test run" },
|
|
180
180
|
{ key: "a2a", type: "object", help: "serve this flow to outside agents over A2A 1.0 — {publish: true, name?, description?, examples?, public_card?, input?, accept_risk?: [agent]}; changing it needs workspace:manage" },
|
|
181
181
|
];
|
|
@@ -185,7 +185,7 @@ const TOOL: FieldSpec[] = [
|
|
|
185
185
|
{ key: "description", type: "string", help: "what it does — the model chooses by it" },
|
|
186
186
|
{ key: "transport", type: "string", values: ["http", "script", "mcp"], help: "http | script | mcp" },
|
|
187
187
|
{ key: "type", type: "string", legacy: true, help: "older spelling of transport" },
|
|
188
|
-
{ key: "outward", type: "boolean", help: "true: it changes something outside the
|
|
188
|
+
{ key: "outward", type: "boolean", help: "true: it changes something outside the project" },
|
|
189
189
|
{ key: "base", type: "string", help: "http: the API's base URL" },
|
|
190
190
|
{ key: "headers", type: "object", help: "http or mcp: request headers; ${SECRET} is filled server-side" },
|
|
191
191
|
{ key: "query", type: "object", help: "http: query parameters on every call" },
|
package/src/mail.ts
CHANGED
|
@@ -90,7 +90,7 @@ export const MAIL_CATEGORIES: readonly MailCategoryInfo[] = [
|
|
|
90
90
|
label: "Run alerts",
|
|
91
91
|
required: false,
|
|
92
92
|
perWorkspace: true,
|
|
93
|
-
description: "A run failed, finished, or was blocked; a flow was quarantined, a run passed its SLA, a budget is nearly spent — mail from a
|
|
93
|
+
description: "A run failed, finished, or was blocked; a flow was quarantined, a run passed its SLA, a budget is nearly spent — mail from a project's notify: email.",
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
id: "approvals",
|
package/src/manifest.ts
CHANGED
|
@@ -137,7 +137,7 @@ export function assertManifestPath(rel: string, kind?: Manifest["kind"]): string
|
|
|
137
137
|
// name on a Mac and two on Linux. A manifest holds the composed form, so it
|
|
138
138
|
// extracts the same everywhere. (Case is handled per manifest, below.)
|
|
139
139
|
if (rel !== rel.normalize("NFC")) throw new Error(`illegal manifest path (not NFC-normalised): ${rel}`);
|
|
140
|
-
if (kind !== "run-output" && sideOf(rel) === null) throw new Error(`${rel} is not
|
|
140
|
+
if (kind !== "run-output" && sideOf(rel) === null) throw new Error(`${rel} is not project content (authored: ${[...AUTHORED_DIRS, ...AUTHORED_ROOT_FILES].join(", ")}; state: state/)`);
|
|
141
141
|
return rel;
|
|
142
142
|
}
|
|
143
143
|
|
package/src/notify.ts
CHANGED
|
@@ -326,7 +326,7 @@ export async function attemptWebhook(
|
|
|
326
326
|
const config = notifyConfig(tenant, workspace);
|
|
327
327
|
const base = { n: d.attempt, at, ...(d.manual ? { manual: true } : {}) };
|
|
328
328
|
if (!config?.url) {
|
|
329
|
-
return { ...base, ok: false, statusCode: null, durationMs: 0, response: null, error: "this
|
|
329
|
+
return { ...base, ok: false, statusCode: null, durationMs: 0, response: null, error: "this project's notify: has no url any more" };
|
|
330
330
|
}
|
|
331
331
|
const { url, refused, filled } = webhookTarget(tenant, workspace, config);
|
|
332
332
|
if (!url) {
|
|
@@ -540,7 +540,7 @@ export async function sendTestNotification(
|
|
|
540
540
|
ok: false,
|
|
541
541
|
destination: "none",
|
|
542
542
|
detail:
|
|
543
|
-
"no notify: in this
|
|
543
|
+
"no notify: in this project's AGENTS.md or the account's — nothing would be sent for a failure or a gate either",
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
546
|
const sent = new Date().toISOString();
|
|
@@ -179,7 +179,7 @@ export const OAUTH_CAPABILITIES: OAuthCapability[] = [
|
|
|
179
179
|
},
|
|
180
180
|
{
|
|
181
181
|
id: "server.client-credentials", role: "server", title: "Client credentials for machine clients", spec: "RFC 6749 §4.4",
|
|
182
|
-
status: "supported", note: "An admin registers a machine client (Settings, or `foldrun mcp clients add`) with a role,
|
|
182
|
+
status: "supported", note: "An admin registers a machine client (Settings, or `foldrun mcp clients add`) with a role, projects and access; no refresh token; disconnecting it makes it `invalid_client`.",
|
|
183
183
|
proof: [web("tests/mcp-oauth.test.ts", "machine clients (client credentials, part G)"), web("tests/mcp-oauth.test.ts", "a machine client can sign in with private_key_jwt"), cli("tests/cli-mcp.test.ts", "mcp clients add")],
|
|
184
184
|
},
|
|
185
185
|
{
|
package/src/openapi.ts
CHANGED
|
@@ -292,18 +292,18 @@ export function loadOpenApiDocument(
|
|
|
292
292
|
const root = path.resolve(workspaceRoot);
|
|
293
293
|
const abs = path.resolve(root, source);
|
|
294
294
|
const inside = (p: string, r: string) => p === r || p.startsWith(r + path.sep);
|
|
295
|
-
if (!inside(abs, root)) return { doc: null, error: `${source} escapes the
|
|
295
|
+
if (!inside(abs, root)) return { doc: null, error: `${source} escapes the project` };
|
|
296
296
|
let text: string;
|
|
297
297
|
try {
|
|
298
298
|
// The real path too: a symlink out of the workspace is still out. Both
|
|
299
299
|
// sides resolved, because the root itself may sit behind one (/var on
|
|
300
300
|
// macOS is /private/var).
|
|
301
301
|
const real = fs.realpathSync(abs);
|
|
302
|
-
if (!inside(real, fs.realpathSync(root))) return { doc: null, error: `${source} escapes the
|
|
302
|
+
if (!inside(real, fs.realpathSync(root))) return { doc: null, error: `${source} escapes the project` };
|
|
303
303
|
text = fs.readFileSync(real, "utf8");
|
|
304
304
|
} catch (err) {
|
|
305
305
|
const code = (err as NodeJS.ErrnoException).code;
|
|
306
|
-
return { doc: null, error: code === "ENOENT" ? `${source}: no such file in the
|
|
306
|
+
return { doc: null, error: code === "ENOENT" ? `${source}: no such file in the project` : `${source}: ${(err as Error).message}` };
|
|
307
307
|
}
|
|
308
308
|
try {
|
|
309
309
|
return { doc: parseDocumentText(text), error: null };
|
package/src/package.ts
CHANGED
|
@@ -112,7 +112,7 @@ const MAX_PACKAGE_FILE = 10 * 1024 * 1024;
|
|
|
112
112
|
export function packageOf(tenant: string, workspace: string, kind: PackageKind, name?: string): Package {
|
|
113
113
|
assertSafeName(workspace, "workspace");
|
|
114
114
|
if (!listWorkspaces(tenant).some((w) => w.name === workspace)) {
|
|
115
|
-
throw new PackageError(`no
|
|
115
|
+
throw new PackageError(`no project called "${workspace}" in this account`, 404);
|
|
116
116
|
}
|
|
117
117
|
const all = listWorkspaceFiles(tenant, workspace).filter(isPackagedPath);
|
|
118
118
|
const read = (p: string) => readWorkspaceFile(tenant, workspace, p);
|
|
@@ -342,7 +342,7 @@ export function planImport(tenant: string, workspace: string, pkg: Package): Imp
|
|
|
342
342
|
assertSafeName(workspace, "workspace");
|
|
343
343
|
const exists = listWorkspaces(tenant).some((w) => w.name === workspace);
|
|
344
344
|
if (!exists && pkg.manifest.kind !== "workspace") {
|
|
345
|
-
throw new PackageError(`no
|
|
345
|
+
throw new PackageError(`no project called "${workspace}" — a ${pkg.manifest.kind} imports into one that exists`, 404);
|
|
346
346
|
}
|
|
347
347
|
const dir = workspaceDir(tenant, workspace);
|
|
348
348
|
const added: string[] = [];
|
package/src/providers.ts
CHANGED
|
@@ -979,9 +979,9 @@ export function readBrowseSettings(raw: unknown): { settings: BrowseSettings; re
|
|
|
979
979
|
}
|
|
980
980
|
if (k === "init" || k === "extensions") {
|
|
981
981
|
const list = browseList(v);
|
|
982
|
-
if (!list) return { settings, rest: left(rest), error: `web.browse.${k} is a list of
|
|
982
|
+
if (!list) return { settings, rest: left(rest), error: `web.browse.${k} is a list of project paths, like [${k === "init" ? "scripts/stub.js" : "library/extensions/my-ext"}].` };
|
|
983
983
|
const bad = list.find((p) => p.startsWith("/") || p.split(/[\\/]/).includes("..") || p.includes(","));
|
|
984
|
-
if (bad) return { settings, rest: left(rest), error: `web.browse.${k}: ${bad} must be a path inside the
|
|
984
|
+
if (bad) return { settings, rest: left(rest), error: `web.browse.${k}: ${bad} must be a path inside the project (no leading /, no .., no comma).` };
|
|
985
985
|
if (list.length) settings[k] = list;
|
|
986
986
|
continue;
|
|
987
987
|
}
|
package/src/publish.ts
CHANGED
|
@@ -406,7 +406,7 @@ async function publishScope(deps: Deps, input: PublishInput, scope: Scope, chang
|
|
|
406
406
|
if (res.status === "duplicate") return { status: "duplicate", revision: res.revision, conflicts: [] };
|
|
407
407
|
// stale: the head moved. Fold again onto it.
|
|
408
408
|
}
|
|
409
|
-
throw new PublishError("the
|
|
409
|
+
throw new PublishError("the project changed too often while publishing; try again", "too_many_replays");
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
/** Combine the two heads' answers: the workspace revision is `revision`, the
|
|
@@ -499,7 +499,7 @@ async function restoreScope(deps: Deps, input: RestoreInput, scope: Scope, toId:
|
|
|
499
499
|
if (res.status === "committed") return { status: "committed", revision: res.revision, conflicts: [] };
|
|
500
500
|
if (res.status === "duplicate") return { status: "duplicate", revision: res.revision, conflicts: [] };
|
|
501
501
|
}
|
|
502
|
-
throw new PublishError("the
|
|
502
|
+
throw new PublishError("the project changed too often while restoring; try again", "too_many_replays");
|
|
503
503
|
}
|
|
504
504
|
|
|
505
505
|
/** A new revision with an old one's content. History is untouched. Refuses,
|
package/src/run-container.ts
CHANGED
|
@@ -661,8 +661,8 @@ export function applyContainerChanges(
|
|
|
661
661
|
applied.push(conflictRel);
|
|
662
662
|
written.push({ path: conflictRel.replaceAll("\\", "/"), base: null, after: next });
|
|
663
663
|
note?.(
|
|
664
|
-
`write-back conflict on ${rel.replaceAll("\\", "/")}: it changed on the
|
|
665
|
-
`and not only by appending — kept the
|
|
664
|
+
`write-back conflict on ${rel.replaceAll("\\", "/")}: it changed on the project while this step ran, ` +
|
|
665
|
+
`and not only by appending — kept the project's version; this step's version is ${conflictRel.replaceAll("\\", "/")}`,
|
|
666
666
|
);
|
|
667
667
|
continue;
|
|
668
668
|
}
|
|
@@ -694,7 +694,7 @@ export function applyContainerChanges(
|
|
|
694
694
|
try {
|
|
695
695
|
recordStepOutputs(opts.revision.tenant, path.basename(hostWs), written, { runId: opts.revision.runId, step: opts.revision.step, base: opts.revision.base });
|
|
696
696
|
} catch (err) {
|
|
697
|
-
note?.(`the step's files were written to the
|
|
697
|
+
note?.(`the step's files were written to the project but not recorded as a revision yet: ${err instanceof Error ? err.message : String(err)}`);
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
700
|
return applied;
|
package/src/scan.ts
CHANGED
|
@@ -191,7 +191,7 @@ export const SCAN_RULES: readonly ScanRule[] = [
|
|
|
191
191
|
id: "security/published-flow-ungated",
|
|
192
192
|
category: "security",
|
|
193
193
|
level: "warn",
|
|
194
|
-
title: "A flow published over A2A acts outside the
|
|
194
|
+
title: "A flow published over A2A acts outside the project with no person in the way",
|
|
195
195
|
help:
|
|
196
196
|
"An outside caller can start a published flow as often as its key allows. A step that posts, sends, writes to an API or calls " +
|
|
197
197
|
"another outside agent, with no approval (`!`) or `ask:` before it or on it, does what any caller asked. Put a gate before the " +
|
|
@@ -225,7 +225,7 @@ export const SCAN_RULES: readonly ScanRule[] = [
|
|
|
225
225
|
level: "warn",
|
|
226
226
|
title: "A download piped straight into a shell",
|
|
227
227
|
help:
|
|
228
|
-
"`curl … | sh` runs whatever the server returns today, unreviewed, in the sandbox that holds this
|
|
228
|
+
"`curl … | sh` runs whatever the server returns today, unreviewed, in the sandbox that holds this project. " +
|
|
229
229
|
"Declare the package under `runtime: system:` or `packages:`, or download, verify a checksum, then run.",
|
|
230
230
|
owasp: ["ASI04", "ASI05"],
|
|
231
231
|
},
|
|
@@ -410,15 +410,15 @@ const OWN_RULES = "checks-own-rules";
|
|
|
410
410
|
export const CHECK_RULES: readonly (Omit<ScanRule, "level"> & { level?: ScanLevel })[] = [
|
|
411
411
|
{ id: "agent/config", anchor: OWN_RULES, category: "config", title: "An agent's frontmatter or references are wrong", help: "A field foldrun cannot read, or a tool, skill, colleague or hook it names that does not exist. The message says which and what to write." },
|
|
412
412
|
{ id: "flow/config", anchor: OWN_RULES, category: "config", title: "A flow's steps or options are wrong", help: "A step naming no agent, an option value the parser cannot read, a verify: written as prose, or an arrangement that cannot have what its instruction asks for." },
|
|
413
|
-
{ id: "flow/outward-ungated", category: "security", title: "A step that acts outside the
|
|
413
|
+
{ id: "flow/outward-ungated", category: "security", title: "A step that acts outside the project with no check and no approval", help: "Give the step a verify: that reads what it did, or an approval (`!`), so a wrong post or send is caught before it repeats.", owasp: ["ASI02", "ASI09"] },
|
|
414
414
|
{ id: "tool/config", anchor: OWN_RULES, category: "config", title: "A tool's definition or program is wrong", help: "A run: program that does not exist, a package it imports that nothing declares, or a leftover type: field." },
|
|
415
415
|
{ id: "skill/config", anchor: OWN_RULES, category: "config", title: "A skill does not follow the skill format", help: "SKILL.md needs a name and a description the model can choose it by." },
|
|
416
416
|
{ id: "eval/config", anchor: OWN_RULES, category: "config", title: "An eval names nothing, or has no cases", help: "An eval names one agent or flow that exists and holds at least one case." },
|
|
417
417
|
{ id: "hook/config", anchor: OWN_RULES, category: "config", title: "A hook is not a valid hook, or a hooks: name resolves to nothing", help: "hooks/<name>/hook.md with on:, and run.mjs beside it; a run refuses a step whose hook is missing rather than run it unguarded." },
|
|
418
418
|
{ id: "knowledge/okf", anchor: OWN_RULES, category: "config", title: "A knowledge or memory document is not a conformant OKF bundle entry", help: "Each document needs a type:; dates are YYYY-MM-DD; stale documents are flagged so an agent does not treat them as current." },
|
|
419
|
-
{ id: "workspace/config", anchor: OWN_RULES, category: "config", title: "A
|
|
420
|
-
{ id: "library/config", anchor: OWN_RULES, category: "config", title: "A library entry is wrong", help: "The same rules as in a
|
|
421
|
-
{ id: "paths/workspace-spelling", anchor: OWN_RULES, category: "config", title: "An older spelling of a
|
|
419
|
+
{ id: "workspace/config", anchor: OWN_RULES, category: "config", title: "A project or account setting cannot be read", help: "AGENTS.md defaults — limits:, network:, foldrun_version: — that would leave every agent on the level above, and paths a deploy refuses." },
|
|
420
|
+
{ id: "library/config", anchor: OWN_RULES, category: "config", title: "A library entry is wrong", help: "The same rules as in a project, for the account's shared library." },
|
|
421
|
+
{ id: "paths/workspace-spelling", anchor: OWN_RULES, category: "config", title: "An older spelling of a project path", help: "`../../storage/x` still works; `workspace/storage/x` reads the same in every tool, script and check." },
|
|
422
422
|
];
|
|
423
423
|
|
|
424
424
|
/** The rule id of a check or deploy problem, from where it was found and
|
|
@@ -1030,7 +1030,7 @@ function scanPublishedFlows(flows: FlowFacts[], legs: Map<string, AgentLegs>, tr
|
|
|
1030
1030
|
if (!writes.length) continue;
|
|
1031
1031
|
push(
|
|
1032
1032
|
"security/published-flow-ungated", fl.file, s.line ?? at, `published ungated ${g} ${s.agent}`,
|
|
1033
|
-
`step ${g} ([[${s.agent}]]) can act outside the
|
|
1033
|
+
`step ${g} ([[${s.agent}]]) can act outside the project (${writes.slice(0, 2).join(", ")}${writes.length > 2 ? ", …" : ""}) and ${info.name} is published over A2A, ` +
|
|
1034
1034
|
`with no approval or ask: before it — any caller with a key starts it. Put a gate (\`${g}!.\`) on it or before it`,
|
|
1035
1035
|
);
|
|
1036
1036
|
}
|
package/src/secrets.ts
CHANGED
|
@@ -174,7 +174,7 @@ function vaultAad(tenant: string, workspace: string | undefined, name: string, r
|
|
|
174
174
|
throw new Error("malformed sites");
|
|
175
175
|
}
|
|
176
176
|
if (rec.workspaces !== undefined && (!Array.isArray(rec.workspaces) || rec.workspaces.some((x) => typeof x !== "string"))) {
|
|
177
|
-
throw new Error("malformed
|
|
177
|
+
throw new Error("malformed projects");
|
|
178
178
|
}
|
|
179
179
|
return Buffer.from(
|
|
180
180
|
JSON.stringify([
|
|
@@ -434,7 +434,7 @@ export interface SecretLimit {
|
|
|
434
434
|
function cleanWorkspaceList(workspaces: unknown): string[] | null {
|
|
435
435
|
if (workspaces === null) return null;
|
|
436
436
|
if (!Array.isArray(workspaces) || workspaces.some((w) => typeof w !== "string")) {
|
|
437
|
-
throw new Error("
|
|
437
|
+
throw new Error("projects is a list of project names, or null for every project");
|
|
438
438
|
}
|
|
439
439
|
const clean = [...new Set((workspaces as string[]).map((w) => w.trim()).filter(Boolean))].sort();
|
|
440
440
|
for (const w of clean) assertSafeName(w, "workspace");
|
|
@@ -443,7 +443,7 @@ function cleanWorkspaceList(workspaces: unknown): string[] | null {
|
|
|
443
443
|
function assertWorkspacesExist(list: string[] | null, exists?: (w: string) => boolean) {
|
|
444
444
|
if (!list || !exists) return;
|
|
445
445
|
const missing = list.filter((w) => !exists(w));
|
|
446
|
-
if (missing.length) throw Object.assign(new Error(`no
|
|
446
|
+
if (missing.length) throw Object.assign(new Error(`no project ${missing.join(", ")} in this account`), { status: 400 });
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
export function setSecret(
|
|
@@ -485,7 +485,7 @@ export function setSecret(
|
|
|
485
485
|
* asked to change it. Only the account's store has lists. */
|
|
486
486
|
function limitFor(workspace: string | undefined, limit: SecretLimit): string[] | null | undefined {
|
|
487
487
|
if (limit.workspaces === undefined) return undefined;
|
|
488
|
-
if (workspace) throw new Error("a
|
|
488
|
+
if (workspace) throw new Error("a project's own secret is that project's already — only an account secret is limited to projects");
|
|
489
489
|
return cleanWorkspaceList(limit.workspaces);
|
|
490
490
|
}
|
|
491
491
|
|
|
@@ -531,7 +531,7 @@ export function setSecretSites(tenant: string, name: string, sites: string[], wo
|
|
|
531
531
|
else delete rec.sites;
|
|
532
532
|
return all;
|
|
533
533
|
});
|
|
534
|
-
if (!found) throw new Error(`no secret ${name}${workspace ? ` in
|
|
534
|
+
if (!found) throw new Error(`no secret ${name}${workspace ? ` in project ${workspace}` : " in the account"}`);
|
|
535
535
|
return clean;
|
|
536
536
|
}
|
|
537
537
|
|
|
@@ -700,7 +700,7 @@ export function setSecretWorkspaces(
|
|
|
700
700
|
if (expected !== undefined) {
|
|
701
701
|
const now = Array.isArray(rec.workspaces) ? [...rec.workspaces].sort() : null;
|
|
702
702
|
if (JSON.stringify(now) !== JSON.stringify(expected)) {
|
|
703
|
-
throw Object.assign(new Error(`${name}'s
|
|
703
|
+
throw Object.assign(new Error(`${name}'s projects changed since you loaded them (now ${now === null ? "every project" : now.length ? now.join(", ") : "none"}) — reload and try again`), { status: 409 });
|
|
704
704
|
}
|
|
705
705
|
}
|
|
706
706
|
assertWorkspacesExist(clean, opts.exists);
|
|
@@ -716,7 +716,7 @@ export function setSecretWorkspaces(
|
|
|
716
716
|
* One that will not open is refused, never relabelled (setSecretSites). */
|
|
717
717
|
function withWorkspaces(tenant: string, name: string, rec: StoredSecret, workspaces: string[] | null): StoredSecret {
|
|
718
718
|
const value = openRecord(tenant, undefined, name, rec);
|
|
719
|
-
if (value === null) throw new Error(`${name} cannot be read with this install's keys — set its value again before changing its
|
|
719
|
+
if (value === null) throw new Error(`${name} cannot be read with this install's keys — set its value again before changing its projects`);
|
|
720
720
|
return sealRecord(tenant, undefined, name, value, { kind: rec.kind, sites: rec.sites, workspaces: workspaces ?? undefined, updatedAt: rec.updatedAt }, true);
|
|
721
721
|
}
|
|
722
722
|
|
package/src/starter.ts
CHANGED
|
@@ -43,7 +43,7 @@ export function accountFiles(account: string): StarterFile[] {
|
|
|
43
43
|
path: "AGENTS.md",
|
|
44
44
|
content: `---
|
|
45
45
|
foldrun_version: "0.1"
|
|
46
|
-
# Config here applies to every
|
|
46
|
+
# Config here applies to every project under this account, and a project
|
|
47
47
|
# that declares the same key replaces it *whole* — base_url and token never
|
|
48
48
|
# merge across scopes, so a provider block belongs entirely at one level.
|
|
49
49
|
#
|
|
@@ -84,9 +84,9 @@ foldrun_version: "0.1"
|
|
|
84
84
|
|
|
85
85
|
# ${account}
|
|
86
86
|
|
|
87
|
-
Context every agent in every
|
|
87
|
+
Context every agent in every project here shares.
|
|
88
88
|
|
|
89
|
-
Unlike the frontmatter above, this prose **accumulates**: a
|
|
89
|
+
Unlike the frontmatter above, this prose **accumulates**: a project's
|
|
90
90
|
AGENTS.md is added to it, not swapped for it, so a rule written here cannot be
|
|
91
91
|
dropped further down.
|
|
92
92
|
`,
|
|
@@ -135,7 +135,7 @@ export function starterFiles(workspace: string): StarterFile[] {
|
|
|
135
135
|
path: "AGENTS.md",
|
|
136
136
|
content: `---
|
|
137
137
|
name: ${workspace}
|
|
138
|
-
description: A starter
|
|
138
|
+
description: A starter project — edit the agents, then run the flow.
|
|
139
139
|
foldrun_version: "0.1"
|
|
140
140
|
---
|
|
141
141
|
|
|
@@ -153,7 +153,7 @@ Context every agent here shares. Prices, rules, anything they should all know.
|
|
|
153
153
|
// every secret *inside the workspace*, and without this file the first
|
|
154
154
|
// `git add -A` after setting a secret commits it.
|
|
155
155
|
path: ".gitignore",
|
|
156
|
-
content: `# The key that decrypts every secret in this
|
|
156
|
+
content: `# The key that decrypts every secret in this project, plus the
|
|
157
157
|
# local run store. Never commit these.
|
|
158
158
|
.foldrun/
|
|
159
159
|
|
|
@@ -298,7 +298,7 @@ only when they asked for exactly that deletion.
|
|
|
298
298
|
|
|
299
299
|
| Path | What |
|
|
300
300
|
|---|---|
|
|
301
|
-
| \`AGENTS.md\` | shared context every agent in this
|
|
301
|
+
| \`AGENTS.md\` | shared context every agent in this project sees |
|
|
302
302
|
| \`agents/<name>/agent.md\` | one role: its persona, model, tools |
|
|
303
303
|
| \`flows/<name>.md\` | steps, in order, naming the agents that run them |
|
|
304
304
|
| \`knowledge/\` | reference material agents read |
|
|
@@ -317,10 +317,10 @@ Regenerated every run means a file; accumulated across runs means \`state/\`.
|
|
|
317
317
|
That last row is worth knowing: a subagent you write in Claude Code is imported
|
|
318
318
|
as \`agents/<name>/agent.md\` at deploy, no conversion. Write it either way.
|
|
319
319
|
|
|
320
|
-
## Paths inside a
|
|
320
|
+
## Paths inside a project
|
|
321
321
|
|
|
322
322
|
An agent's working directory is \`agents/<name>/\`. Write every path to the
|
|
323
|
-
|
|
323
|
+
project's own folders as \`workspace/…\` — \`workspace/storage/report.csv\`,
|
|
324
324
|
\`workspace/state/cursor.json\` — in an agent's prose, in flow options
|
|
325
325
|
(\`each: rows of\`, \`when: rows of\`, \`verify:\`, \`preview:\`, \`schema:\`) and in
|
|
326
326
|
script arguments. It resolves the same in the file tools, the shell, scripts
|
|
@@ -346,9 +346,9 @@ A step held to its list still searches the web through the proxy's search door;
|
|
|
346
346
|
at \`none\` or \`defaults: false\` write it out — \`web: {actions: [search, fetch]}\` —
|
|
347
347
|
because a query's words leave (\`foldrun docs network\`).
|
|
348
348
|
|
|
349
|
-
## Talking to a deployed
|
|
349
|
+
## Talking to a deployed project
|
|
350
350
|
|
|
351
|
-
The CLI is local except for \`deploy\`. To inspect or drive a
|
|
351
|
+
The CLI is local except for \`deploy\`. To inspect or drive a project running
|
|
352
352
|
on a server, use the HTTP API — every route takes the same API key
|
|
353
353
|
(\`Authorization: Bearer $FOLDRUN_TOKEN\`, from Settings → API keys) or a browser
|
|
354
354
|
session, and refuses without one.
|
|
@@ -367,7 +367,7 @@ All of it, \`/api/workspaces/<workspace>\` unless noted:
|
|
|
367
367
|
|
|
368
368
|
| Route | Methods | For |
|
|
369
369
|
|---|---|---|
|
|
370
|
-
| \`/\` | GET DELETE PATCH | the
|
|
370
|
+
| \`/\` | GET DELETE PATCH | the project itself |
|
|
371
371
|
| \`/deploy\` | POST | what \`foldrun deploy\` calls |
|
|
372
372
|
| \`/source\` | GET PUT PATCH DELETE | read and write single files |
|
|
373
373
|
| \`/runs\` | GET | list runs |
|
|
@@ -381,19 +381,19 @@ All of it, \`/api/workspaces/<workspace>\` unless noted:
|
|
|
381
381
|
| \`/flows\` · \`/flows/<f>\` | GET POST · POST DELETE PATCH | list, create, edit |
|
|
382
382
|
| \`/flows/<f>/run\` | POST | start a flow |
|
|
383
383
|
| \`/flows/<f>/filter\` | POST | would this delivery start it? its \`filter:\` against a payload — nothing starts |
|
|
384
|
-
| \`/agents\` · \`/agents/<a>/run\` · \`/agents/import\` | GET POST · POST · GET POST | list agents, run one, copy one in from another
|
|
384
|
+
| \`/agents\` · \`/agents/<a>/run\` · \`/agents/import\` | GET POST · POST · GET POST | list agents, run one, copy one in from another project |
|
|
385
385
|
| \`/evals\` · \`/evals/<e>/run\` | GET POST · POST | list evals, run one |
|
|
386
386
|
| \`/evals/<e>/compare\` | GET POST | its cases under two to four models, side by side — test runs, a spend limit |
|
|
387
387
|
| \`/evals/<e>/grades\` · \`/evals/<e>/grade\` | GET · POST | a grader's grades (\`trigger: runs\`); grade one finished run now |
|
|
388
388
|
| \`/evals/<e>/improve\` · \`/proposals\` · \`/proposals/<id>\` | POST · GET · GET POST | ask for a proposed fix; list them; apply or dismiss one |
|
|
389
389
|
| \`/tools/<t>/test\` | POST | exercise one tool alone |
|
|
390
|
-
| \`/storage\` · \`/storage/download\` · \`/storage/upload-url\` · \`/storage/preview\` | GET POST PUT DELETE · GET · POST · GET |
|
|
390
|
+
| \`/storage\` · \`/storage/download\` · \`/storage/upload-url\` · \`/storage/preview\` | GET POST PUT DELETE · GET · POST · GET | project files, any type; \`preview\` returns one parsed for reading |
|
|
391
391
|
| \`/assets\` | POST | upload an asset |
|
|
392
392
|
| \`/hooks/<f>/rotate\` | POST | new webhook token for a flow |
|
|
393
393
|
| \`/notify/deliveries\` · \`/notify/deliveries/<id>/redeliver\` | GET · POST | every notify: webhook sent and each attempt; send one again |
|
|
394
|
-
| \`/export\` · \`/import\` | GET · POST | the
|
|
395
|
-
| \`/restore\` | POST | the
|
|
396
|
-
| \`/vocabulary\` | GET | what this
|
|
394
|
+
| \`/export\` · \`/import\` | GET · POST | the project, a flow (\`?kind=flow&name=\`) or an agent as a .zip; take one in (\`?dryRun=1\` first, \`?overwrite=1\` to replace) |
|
|
395
|
+
| \`/restore\` | POST | the project's source back to a point in its history — \`dryRun\` first, then \`confirm\` |
|
|
396
|
+
| \`/vocabulary\` | GET | what this project's documents may say |
|
|
397
397
|
| \`/a2a\` | GET | what it serves to outside agents over A2A: flows that say \`a2a:\`, card URLs, recent tasks |
|
|
398
398
|
| \`/check\` | GET | what \`foldrun check\` says about the deployed copy, as findings with rule ids (\`?security=1\`) |
|
|
399
399
|
| \`/assistant\` | POST | ask the assistant, or have it write agents, flows, tools and skills — from the docs only; proposals come back, nothing is written |
|
|
@@ -538,7 +538,7 @@ Only \`name\` and the prose are required. Every other field widens or narrows
|
|
|
538
538
|
what the agent can reach, and the default is narrow.
|
|
539
539
|
|
|
540
540
|
\`timezone:\` is nearest-wins all the way down: the agent's own, else its
|
|
541
|
-
flow's, else the
|
|
541
|
+
flow's, else the project's AGENTS.md, else the account's, else UTC. It sets
|
|
542
542
|
\`TZ\` and the date the agent is told, so a Sydney desk stamps the Sydney date.
|
|
543
543
|
|
|
544
544
|
\`runtime:\` installs pip/npm packages in the sandbox each agent runs in. Pin
|
|
@@ -591,8 +591,8 @@ export function blankWorkspaceFiles(workspace: string): StarterFile[] {
|
|
|
591
591
|
? {
|
|
592
592
|
...f,
|
|
593
593
|
content: f.content.replace(
|
|
594
|
-
"description: A starter
|
|
595
|
-
"description: A new
|
|
594
|
+
"description: A starter project — edit the agents, then run the flow.",
|
|
595
|
+
"description: A new project — add an agent or import one from another project, then write a flow.",
|
|
596
596
|
),
|
|
597
597
|
}
|
|
598
598
|
: f,
|
package/src/storage.ts
CHANGED
|
@@ -118,7 +118,7 @@ function bytesOf(files: Pick<FileRecord, "sha" | "size">[]): number {
|
|
|
118
118
|
*/
|
|
119
119
|
export function requireWorkspace(tenant: string, workspace: string): void {
|
|
120
120
|
if (!fs.existsSync(workspaceDir(tenant, workspace))) {
|
|
121
|
-
throw Object.assign(new Error(`
|
|
121
|
+
throw Object.assign(new Error(`project ${workspace} not found`), { status: 404 });
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -1121,7 +1121,7 @@ async function putFileQuietly(
|
|
|
1121
1121
|
assertNoNameClash(seen.files, norm);
|
|
1122
1122
|
const before = seen.files.find((f) => f.path === norm);
|
|
1123
1123
|
if (before?.sha !== sha && usedBytes(tenant, workspace) - (before?.size ?? 0) + body.length > quotaBytes()) {
|
|
1124
|
-
throw new Error(`
|
|
1124
|
+
throw new Error(`project file quota exceeded (${quotaBytes() / 1e6}MB)`);
|
|
1125
1125
|
}
|
|
1126
1126
|
}
|
|
1127
1127
|
// The upload happens outside the lock: it can be long, and a blob is
|
|
@@ -1140,7 +1140,7 @@ async function putFileQuietly(
|
|
|
1140
1140
|
if (projected > quotaBytes()) {
|
|
1141
1141
|
// Nothing names the blob we just put unless another record already does.
|
|
1142
1142
|
if (!index.files.some((f) => f.sha === sha)) await driver.remove(key).catch(() => {});
|
|
1143
|
-
throw new Error(`
|
|
1143
|
+
throw new Error(`project file quota exceeded (${quotaBytes() / 1e6}MB)`);
|
|
1144
1144
|
}
|
|
1145
1145
|
// A delete or replace that ran between our upload and now may have
|
|
1146
1146
|
// collected this very blob (it was unreferenced then). We hold the bytes,
|
|
@@ -1214,7 +1214,7 @@ export async function registerUpload(
|
|
|
1214
1214
|
await refuse(`${norm} is ${Math.round(size / 1e6)}MB — the limit is ${maxBytes() / 1e6}MB`);
|
|
1215
1215
|
}
|
|
1216
1216
|
if (bytesOf(files) > quotaBytes() && bytesOf(files) > bytesOf(index.files)) {
|
|
1217
|
-
await refuse(`
|
|
1217
|
+
await refuse(`project file quota exceeded (${quotaBytes() / 1e6}MB)`);
|
|
1218
1218
|
}
|
|
1219
1219
|
indexPut(tenant, workspace, index, record);
|
|
1220
1220
|
if (previous && previous.sha !== sha) await collectLocked(tenant, workspace, previous.sha);
|
|
@@ -1355,7 +1355,7 @@ export async function uploadUrl(
|
|
|
1355
1355
|
const files = readIndex(tenant, workspace).files;
|
|
1356
1356
|
const next = [...files.filter((f) => f.path !== norm), { sha, size }];
|
|
1357
1357
|
if (bytesOf(next) > quotaBytes() && bytesOf(next) > bytesOf(files)) {
|
|
1358
|
-
throw new Error(`
|
|
1358
|
+
throw new Error(`project file quota exceeded (${quotaBytes() / 1e6}MB)`);
|
|
1359
1359
|
}
|
|
1360
1360
|
}
|
|
1361
1361
|
return driverFor(tenant, workspace).presignPut(blobKey(tenant, workspace, sha), mimeFor(norm), undefined, size);
|
|
@@ -1434,7 +1434,7 @@ async function moveUnlocked(tenant: string, from: string, to: string): Promise<v
|
|
|
1434
1434
|
if (!fs.existsSync(src) && !(port && port.fileList(tenant, from).length)) return;
|
|
1435
1435
|
const driver = driverFor(tenant, from);
|
|
1436
1436
|
const shas = driver.kind === "fs" ? [] : [...new Set(readIndex(tenant, from).files.map((f) => f.sha))];
|
|
1437
|
-
if (shas.length && !driver.copy) throw new Error(`the ${driver.kind} store cannot move files to a new
|
|
1437
|
+
if (shas.length && !driver.copy) throw new Error(`the ${driver.kind} store cannot move files to a new project name`);
|
|
1438
1438
|
for (const sha of shas) await driver.copy!(blobKey(tenant, from, sha), blobKey(tenant, to, sha));
|
|
1439
1439
|
if (fs.existsSync(src)) {
|
|
1440
1440
|
fs.mkdirSync(path.dirname(dest), { recursive: true });
|