@foldrun/core 24.12.0 → 24.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/deploy.d.ts +4 -0
- package/dist/src/deploy.js +13 -1
- package/dist/src/model-credential.d.ts +3 -0
- package/dist/src/model-credential.js +3 -0
- package/dist/src/model-env.js +10 -3
- package/dist/src/platform.d.ts +7 -0
- package/dist/src/provider-health.js +5 -0
- package/dist/src/runner.js +16 -5
- package/dist/src/scan.d.ts +5 -0
- package/dist/src/scan.js +22 -0
- package/dist/src/starter.js +1 -1
- package/dist/src/workspace-check.js +5 -1
- package/package.json +1 -1
- package/src/deploy.ts +13 -1
- package/src/model-credential.ts +5 -0
- package/src/model-env.ts +9 -3
- package/src/platform.ts +7 -0
- package/src/provider-health.ts +4 -0
- package/src/runner.ts +16 -5
- package/src/scan.ts +26 -0
- package/src/starter.ts +1 -1
- package/src/workspace-check.ts +5 -1
package/dist/src/deploy.d.ts
CHANGED
|
@@ -111,6 +111,10 @@ export declare const DEPLOY_BLOCK_MODES: readonly ["none", "secrets", "security"
|
|
|
111
111
|
export type DeployBlockMode = (typeof DEPLOY_BLOCK_MODES)[number];
|
|
112
112
|
/** The workspace's own AGENTS.md, else the account's, else none. */
|
|
113
113
|
export declare function deployBlockMode(files: DeployFile[], accountKeys: Record<string, unknown>): DeployBlockMode;
|
|
114
|
+
/** Own keys off on this platform (models.byok, 22 Nov 2026): every
|
|
115
|
+
* `provider:` in the files is a refusal — nothing deploys that would run on
|
|
116
|
+
* an endpoint the platform does not meter. Nothing where they are allowed. */
|
|
117
|
+
export declare function ownKeyBlockers(tenant: string, files: DeployFile[]): DeployIssue[];
|
|
114
118
|
/** The findings `mode` turns into refusals, as deploy issues. */
|
|
115
119
|
export declare function deployBlockers(files: DeployFile[], mode: DeployBlockMode, options?: ScanOptions): DeployIssue[];
|
|
116
120
|
export declare function deployWarnings(files: DeployFile[]): DeployIssue[];
|
package/dist/src/deploy.js
CHANGED
|
@@ -43,6 +43,7 @@ import { languageProblem } from "./language.js";
|
|
|
43
43
|
import { localeProblems } from "./locale.js";
|
|
44
44
|
import { entriesNoFollow } from "./paths.js";
|
|
45
45
|
import { filterIgnored, findingFingerprint, ruleForWhere, scanFiles, scanRule, STRICT_FRONTMATTER_PATH } from "./scan.js";
|
|
46
|
+
import { platform } from "./platform.js";
|
|
46
47
|
/** Directories a deploy never reads out of a source tree. */
|
|
47
48
|
// `.cache` is what a run's tools leave in an agent's folder (HOME is that
|
|
48
49
|
// folder): logs and font caches, never authored.
|
|
@@ -311,6 +312,17 @@ function blockersFor(tenant, given) {
|
|
|
311
312
|
.map(([n]) => n);
|
|
312
313
|
return deployBlockers(files, mode, { accountNetwork: account.network, outwardTools });
|
|
313
314
|
}
|
|
315
|
+
/** Own keys off on this platform (models.byok, 22 Nov 2026): every
|
|
316
|
+
* `provider:` in the files is a refusal — nothing deploys that would run on
|
|
317
|
+
* an endpoint the platform does not meter. Nothing where they are allowed. */
|
|
318
|
+
export function ownKeyBlockers(tenant, files) {
|
|
319
|
+
if (platform.ownModelKeys?.(tenant) ?? true)
|
|
320
|
+
return [];
|
|
321
|
+
return scanFiles(files, { only: ["config/own-model-key"], ownModelKeys: false }).map((f) => ({
|
|
322
|
+
where: `${f.file}${f.line ? `:${f.line}` : ""}`,
|
|
323
|
+
message: `${f.message} [${f.rule}]`,
|
|
324
|
+
}));
|
|
325
|
+
}
|
|
314
326
|
/** The findings `mode` turns into refusals, as deploy issues. */
|
|
315
327
|
export function deployBlockers(files, mode, options = {}) {
|
|
316
328
|
if (mode === "none")
|
|
@@ -777,7 +789,7 @@ export function planDeploy(tenant, workspace, files, opts = {}) {
|
|
|
777
789
|
// deploy_block: (FOL-58) turns the scanner's findings into refusals —
|
|
778
790
|
// scanned with what the Checks page passes too: the account's network:
|
|
779
791
|
// and the library's outward tools (Codex review).
|
|
780
|
-
issues: [...deployIssues(files), ...blockersFor(tenant, files)],
|
|
792
|
+
issues: [...deployIssues(files), ...blockersFor(tenant, files), ...ownKeyBlockers(tenant, files)],
|
|
781
793
|
warnings: deployWarnings(files),
|
|
782
794
|
blockedBy: runsInFlight(tenant, workspace),
|
|
783
795
|
};
|
|
@@ -12,6 +12,9 @@ export declare function credentialLine(c: ModelCredential): {
|
|
|
12
12
|
type: "info" | "error";
|
|
13
13
|
text: string;
|
|
14
14
|
};
|
|
15
|
+
/** Why a step or a call that names its own model endpoint (`provider:`)
|
|
16
|
+
* is refused where a platform admin turned own keys off (models.byok). */
|
|
17
|
+
export declare const OWN_KEYS_OFF = "this platform runs every model call on foldrun's models, so an agent or project cannot name its own model endpoint \u2014 remove `provider:` from the agent or AGENTS.md (a platform admin can allow own keys: setting models.byok)";
|
|
15
18
|
/** The account vault names the account's own model key lives under. */
|
|
16
19
|
export declare const ACCOUNT_MODEL_SECRETS: {
|
|
17
20
|
readonly provider: "FOLDRUN_MODEL_PROVIDER";
|
|
@@ -63,6 +63,9 @@ export function credentialLine(c) {
|
|
|
63
63
|
// /api/account/model, or `foldrun account model set`). A provider: block at any
|
|
64
64
|
// level still wins; this is what a step falls to when none names one, before
|
|
65
65
|
// the platform's own credential.
|
|
66
|
+
/** Why a step or a call that names its own model endpoint (`provider:`)
|
|
67
|
+
* is refused where a platform admin turned own keys off (models.byok). */
|
|
68
|
+
export const OWN_KEYS_OFF = "this platform runs every model call on foldrun's models, so an agent or project cannot name its own model endpoint — remove `provider:` from the agent or AGENTS.md (a platform admin can allow own keys: setting models.byok)";
|
|
66
69
|
/** The account vault names the account's own model key lives under. */
|
|
67
70
|
export const ACCOUNT_MODEL_SECRETS = {
|
|
68
71
|
provider: "FOLDRUN_MODEL_PROVIDER",
|
package/dist/src/model-env.js
CHANGED
|
@@ -9,7 +9,7 @@ import { accountDir, workspaceDir, parseProvider, providerEnvFor } from "./store
|
|
|
9
9
|
import { readAgentsMd } from "./runner.js";
|
|
10
10
|
import { getSecret } from "./secrets.js";
|
|
11
11
|
import { platform, hostUrlProblem } from "./platform.js";
|
|
12
|
-
import { accountModelBlock, isClaudeLoginToken } from "./model-credential.js";
|
|
12
|
+
import { accountModelBlock, isClaudeLoginToken, OWN_KEYS_OFF } from "./model-credential.js";
|
|
13
13
|
import { providerPreset } from "./providers.js";
|
|
14
14
|
import { startTranslator, translatorSpecFor } from "./translator.js";
|
|
15
15
|
import { supplyProviderBlock } from "./model-supply.js";
|
|
@@ -32,8 +32,15 @@ export const NO_MODEL_KEY = "no model key: this account runs on its own API key,
|
|
|
32
32
|
* it, so a judge or a draft works on any key a run works on (FOL-16).
|
|
33
33
|
*/
|
|
34
34
|
export function accountModelEnv(tenant, workspace, platformEnv) {
|
|
35
|
-
const
|
|
35
|
+
const writtenBlock = readAgentsMd(workspaceDir(tenant, workspace))?.data?.provider ??
|
|
36
36
|
readAgentsMd(accountDir(tenant))?.data?.provider;
|
|
37
|
+
// Own keys as the platform admin allows them (models.byok), as a step
|
|
38
|
+
// takes them (runner.ts): off, a written block is refused and the stored
|
|
39
|
+
// key never read.
|
|
40
|
+
const ownKeys = platform.ownModelKeys?.(tenant) ?? true;
|
|
41
|
+
if (writtenBlock && !ownKeys)
|
|
42
|
+
throw new ModelKeyError(OWN_KEYS_OFF, 403);
|
|
43
|
+
const written = writtenBlock;
|
|
37
44
|
// foldrun's models, the same rung a step takes (runner.ts agentContext):
|
|
38
45
|
// after the written blocks, before the account's stored key; chosen but
|
|
39
46
|
// refused fails here, never onto the stored key or the operator's.
|
|
@@ -60,7 +67,7 @@ export function accountModelEnv(tenant, workspace, platformEnv) {
|
|
|
60
67
|
tenant,
|
|
61
68
|
};
|
|
62
69
|
}
|
|
63
|
-
const raw = written ?? accountModelBlock((name) => getSecret(tenant, name)?.value ?? null);
|
|
70
|
+
const raw = written ?? (ownKeys ? accountModelBlock((name) => getSecret(tenant, name)?.value ?? null) : undefined);
|
|
64
71
|
const spec = parseProvider(raw);
|
|
65
72
|
if (!spec?.baseUrl) {
|
|
66
73
|
if (!platform.platformKeyAllowed(tenant))
|
package/dist/src/platform.d.ts
CHANGED
|
@@ -159,6 +159,13 @@ export interface PlatformHooks {
|
|
|
159
159
|
* operator's accounts do so; every customer brings their own API key.
|
|
160
160
|
* Default: yes — a laptop or a self-hosted install is its own operator. */
|
|
161
161
|
platformKeyAllowed(tenant: string): boolean;
|
|
162
|
+
/** May this account's steps run on a model key or endpoint of its own —
|
|
163
|
+
* the account's stored key (Settings → Models) or a `provider:` block in
|
|
164
|
+
* its files (BYOK)? A platform admin decides, for the whole install
|
|
165
|
+
* (setting models.byok, 22 Nov 2026: off unless turned on). No: a stored
|
|
166
|
+
* key is never used, and a step whose files name a provider: is refused
|
|
167
|
+
* before it starts. Absent: yes — a laptop runs on what it is given. */
|
|
168
|
+
ownModelKeys?(tenant: string): boolean;
|
|
162
169
|
/** foldrun's models (3 Nov 2026): whether this account chose to run on
|
|
163
170
|
* the platform's own key for a provider, and whether it can now. Asked
|
|
164
171
|
* only where no provider: block of the account's own says otherwise.
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
// It reads the same provider block a run reads, resolved the same way, so a
|
|
19
19
|
// pass here means a run would reach the same place with the same key.
|
|
20
20
|
import { accountModelBlock } from "./model-credential.js";
|
|
21
|
+
import { platform } from "./platform.js";
|
|
21
22
|
import fs from "node:fs";
|
|
22
23
|
import path from "node:path";
|
|
23
24
|
import { configMatter } from "./matter.js";
|
|
@@ -187,6 +188,10 @@ function frontmatterOf(file) {
|
|
|
187
188
|
export function providersInUse(tenant) {
|
|
188
189
|
const out = [];
|
|
189
190
|
const seen = new Set();
|
|
191
|
+
// Own keys off on this platform (models.byok): nothing of the account's
|
|
192
|
+
// is used, so nothing is probed (or spent) on its behalf.
|
|
193
|
+
if (!(platform.ownModelKeys?.(tenant) ?? true))
|
|
194
|
+
return out;
|
|
190
195
|
const add = (raw, workspace, declaredIn) => {
|
|
191
196
|
const spec = parseProvider(raw);
|
|
192
197
|
if (!spec || !spec.baseUrl)
|
package/dist/src/runner.js
CHANGED
|
@@ -22,7 +22,7 @@ import { eventUrl } from "./webhook.js";
|
|
|
22
22
|
import { runStepInContainer, resolveResources, memoryGiB, heldCores, killRunSandboxes, classDisk } from "./run-container.js";
|
|
23
23
|
import { readResources, hasOverride, anyMemoryMi } from "./resources.js";
|
|
24
24
|
import { hostSafeEnv, platformApiUrl } from "./host-env.js";
|
|
25
|
-
import { resolveModelCredential, credentialLine, accountModelBlock, isClaudeLoginToken, isModelEnvName, DECLARED_ENV_PREFIX } from "./model-credential.js";
|
|
25
|
+
import { resolveModelCredential, credentialLine, accountModelBlock, isClaudeLoginToken, isModelEnvName, DECLARED_ENV_PREFIX, OWN_KEYS_OFF } from "./model-credential.js";
|
|
26
26
|
import { parseJudge } from "./judge-verdict.js";
|
|
27
27
|
import { validateSchema, describeSchemaErrors, looksLikeSchema } from "./json-schema.js";
|
|
28
28
|
import { EGRESS_ENV, MODEL_KEY_NAME, addGrant, grantModelKey, hostOf, placeholderNames, proxyModelEnv, unsubstitute } from "./egress.js";
|
|
@@ -1303,18 +1303,29 @@ grantsOnly = false) {
|
|
|
1303
1303
|
// agent's own block wins over the workspace's, like everything else here.
|
|
1304
1304
|
// Then the account's own model key (Settings → Models), when it set one:
|
|
1305
1305
|
// an account that brings its key need not write a block anywhere.
|
|
1306
|
-
const
|
|
1306
|
+
const writtenBlock = front.provider ?? workspaceFrontmatter(agentDir, tenant).provider;
|
|
1307
|
+
// Own keys (BYOK) as the platform admin allows them (models.byok): off,
|
|
1308
|
+
// a written provider: block refuses the step and a stored key is never
|
|
1309
|
+
// read — every call goes through foldrun's models.
|
|
1310
|
+
const ownKeys = platform.ownModelKeys?.(tenant) ?? true;
|
|
1311
|
+
const fileBlock = ownKeys ? writtenBlock : undefined;
|
|
1307
1312
|
// foldrun's models (3 Nov 2026): an account that chose the platform's key
|
|
1308
1313
|
// for a provider runs on it here, between its written blocks (which still
|
|
1309
1314
|
// win) and its stored key. Chosen but not to be had now — refused, and
|
|
1310
1315
|
// the step fails with why (runStep); it never falls to the stored key.
|
|
1311
|
-
const supply = fileBlock
|
|
1316
|
+
const supply = fileBlock
|
|
1317
|
+
? { kind: "none" }
|
|
1318
|
+
: writtenBlock
|
|
1319
|
+
? { kind: "refused", reason: OWN_KEYS_OFF }
|
|
1320
|
+
: platform.modelSupply?.(tenant) ?? { kind: "none" };
|
|
1312
1321
|
const providerBlock = fileBlock ??
|
|
1313
1322
|
(supply.kind === "foldrun"
|
|
1314
1323
|
? supplyProviderBlock(supply.provider, supply.tiers, supply.via)
|
|
1315
1324
|
: supply.kind === "refused"
|
|
1316
1325
|
? undefined
|
|
1317
|
-
:
|
|
1326
|
+
: ownKeys
|
|
1327
|
+
? accountModelBlock((name) => getSecret(tenant, name)?.value ?? null)
|
|
1328
|
+
: undefined);
|
|
1318
1329
|
let providerEnv = {};
|
|
1319
1330
|
let providerLabel = null;
|
|
1320
1331
|
// Secret values pulled into the provider block, name → value. Kept apart
|
|
@@ -2458,7 +2469,7 @@ conversation) {
|
|
|
2458
2469
|
// Chosen, but not to be had now: failed with why, before a sandbox —
|
|
2459
2470
|
// never onto the account's stored key or the operator's.
|
|
2460
2471
|
if (supply.kind === "refused") {
|
|
2461
|
-
push("error", `foldrun's models: ${supply.reason} — or switch this account back to its own key (Settings → Models, \`foldrun account model use own\`)`);
|
|
2472
|
+
push("error", platform.ownModelKeys?.(tenant) ?? true ? `foldrun's models: ${supply.reason} — or switch this account back to its own key (Settings → Models, \`foldrun account model use own\`)` : `foldrun's models: ${supply.reason}`);
|
|
2462
2473
|
step.status = "failed";
|
|
2463
2474
|
save();
|
|
2464
2475
|
return;
|
package/dist/src/scan.d.ts
CHANGED
|
@@ -59,6 +59,11 @@ export interface ScanOptions {
|
|
|
59
59
|
model: string;
|
|
60
60
|
on: string;
|
|
61
61
|
} | null;
|
|
62
|
+
/** May this account's files name their own model endpoint (`provider:`)?
|
|
63
|
+
* False where a platform admin turned own keys off (models.byok): each
|
|
64
|
+
* one is config/own-model-key, an error, so the deploy is refused.
|
|
65
|
+
* Absent (the CLI offline, a laptop): yes. */
|
|
66
|
+
ownModelKeys?: boolean;
|
|
62
67
|
}
|
|
63
68
|
export declare const OWASP_URL = "https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026";
|
|
64
69
|
export declare const SCAN_RULES: readonly ScanRule[];
|
package/dist/src/scan.js
CHANGED
|
@@ -260,6 +260,15 @@ export const SCAN_RULES = [
|
|
|
260
260
|
"The step still runs, at the nearest level the model has, and the step's log says so. Write the level it has, or choose " +
|
|
261
261
|
"a provider whose model has the one you want (Settings → Models).",
|
|
262
262
|
},
|
|
263
|
+
{
|
|
264
|
+
id: "config/own-model-key",
|
|
265
|
+
category: "config",
|
|
266
|
+
level: "error",
|
|
267
|
+
title: "A model endpoint of its own, where this platform runs every call on its own models",
|
|
268
|
+
help: "This platform's admin turned own model keys off (setting models.byok), so every model call goes through foldrun's models. " +
|
|
269
|
+
"An agent's or a project's `provider:` block names an endpoint and key of its own, which would run unmetered. Remove the " +
|
|
270
|
+
"block: the agent then runs on the account's choice in Settings → Models.",
|
|
271
|
+
},
|
|
263
272
|
{
|
|
264
273
|
id: "config/output-fitted",
|
|
265
274
|
category: "config",
|
|
@@ -1236,6 +1245,19 @@ export function scanFiles(files, options = {}) {
|
|
|
1236
1245
|
// A workspace that names its own provider: does not run on the account's
|
|
1237
1246
|
// choice, so the account's models say nothing about its efforts.
|
|
1238
1247
|
const ownWorkspaceProvider = Boolean(workspaceMd && frontOf(workspaceMd.content, "AGENTS.md")?.provider);
|
|
1248
|
+
// Own keys off on this platform (models.byok): every provider: is refused.
|
|
1249
|
+
if (options.ownModelKeys === false) {
|
|
1250
|
+
const lineOf = (content) => {
|
|
1251
|
+
const i = content.split("\n").findIndex((l) => /^provider\s*:/.test(l));
|
|
1252
|
+
return i >= 0 ? i + 1 : 1;
|
|
1253
|
+
};
|
|
1254
|
+
const say = (file, content) => push("config/own-model-key", file, lineOf(content), `config/own-model-key ${file}`, "provider: names a model endpoint of its own, and this platform runs every model call on its own models (own keys are off) — remove it; the agent runs on the account's choice in Settings → Models.");
|
|
1255
|
+
for (const a of agents)
|
|
1256
|
+
if (a.data.provider)
|
|
1257
|
+
say(a.file, files.find((f) => f.path === a.file)?.content ?? "");
|
|
1258
|
+
if (workspaceMd && ownWorkspaceProvider)
|
|
1259
|
+
say(workspaceMd.path, workspaceMd.content);
|
|
1260
|
+
}
|
|
1239
1261
|
if (options.effortRunsAs && !ownWorkspaceProvider)
|
|
1240
1262
|
scanEfforts(agents, flows, options.effortRunsAs, push);
|
|
1241
1263
|
if (options.outputCeiling && !ownWorkspaceProvider)
|
package/dist/src/starter.js
CHANGED
|
@@ -504,7 +504,7 @@ secrets: [CRM_TOKEN] # keys the agent uses itself; a tool's own come with
|
|
|
504
504
|
limits: {web.search: 40, crm: 20, calls: 300} # per step; a call past a limit is refused, never run
|
|
505
505
|
network: [api.example.com] # sites its sandbox may reach, added to the trusted list; open | trusted | none
|
|
506
506
|
timezone: Australia/Sydney # the calendar it works to — IANA name or UTC+10
|
|
507
|
-
provider: {} # BYOK for this agent; account-wide: \`foldrun account model set\`
|
|
507
|
+
provider: {} # BYOK for this agent, where the platform allows own keys (models.byok); account-wide: \`foldrun account model set\`
|
|
508
508
|
permissionMode: plan # plan first, act once approved
|
|
509
509
|
runtime: # only if scripts need packages
|
|
510
510
|
packages: [requests]
|
|
@@ -31,7 +31,11 @@ export function checkOptions(tenant, workspace) {
|
|
|
31
31
|
// AGENTS.md, or the older project.md, as the runner reads it (Codex review).
|
|
32
32
|
const accountKeys = readAgentsMdKeys(accountDir(tenant));
|
|
33
33
|
const accountNetwork = accountKeys.network;
|
|
34
|
-
|
|
34
|
+
// Own keys as the platform admin set them (models.byok): off, a provider:
|
|
35
|
+
// in these files is an error, so the deploy, a save and the Checks page
|
|
36
|
+
// all refuse it as the runner would.
|
|
37
|
+
const ownModelKeys = platform.ownModelKeys?.(tenant) ?? true;
|
|
38
|
+
return { outwardTools, accountNetwork, ...effortCheck(tenant, accountKeys.provider), ...(ownModelKeys ? {} : { ownModelKeys: false }) };
|
|
35
39
|
}
|
|
36
40
|
/**
|
|
37
41
|
* What an effort level runs at on the account's choice, for
|
package/package.json
CHANGED
package/src/deploy.ts
CHANGED
|
@@ -57,6 +57,7 @@ import { languageProblem } from "./language.ts";
|
|
|
57
57
|
import { localeProblems } from "./locale.ts";
|
|
58
58
|
import { entriesNoFollow } from "./paths.ts";
|
|
59
59
|
import { filterIgnored, findingFingerprint, ruleForWhere, scanFiles, scanRule, STRICT_FRONTMATTER_PATH, type ScanFinding, type ScanOptions } from "./scan.ts";
|
|
60
|
+
import { platform } from "./platform.ts";
|
|
60
61
|
|
|
61
62
|
/** Directories a deploy never reads out of a source tree. */
|
|
62
63
|
// `.cache` is what a run's tools leave in an agent's folder (HOME is that
|
|
@@ -372,6 +373,17 @@ function blockersFor(tenant: string, given: DeployFile[]): DeployIssue[] {
|
|
|
372
373
|
return deployBlockers(files, mode, { accountNetwork: account.network, outwardTools });
|
|
373
374
|
}
|
|
374
375
|
|
|
376
|
+
/** Own keys off on this platform (models.byok, 22 Nov 2026): every
|
|
377
|
+
* `provider:` in the files is a refusal — nothing deploys that would run on
|
|
378
|
+
* an endpoint the platform does not meter. Nothing where they are allowed. */
|
|
379
|
+
export function ownKeyBlockers(tenant: string, files: DeployFile[]): DeployIssue[] {
|
|
380
|
+
if (platform.ownModelKeys?.(tenant) ?? true) return [];
|
|
381
|
+
return scanFiles(files, { only: ["config/own-model-key"], ownModelKeys: false }).map((f) => ({
|
|
382
|
+
where: `${f.file}${f.line ? `:${f.line}` : ""}`,
|
|
383
|
+
message: `${f.message} [${f.rule}]`,
|
|
384
|
+
}));
|
|
385
|
+
}
|
|
386
|
+
|
|
375
387
|
/** The findings `mode` turns into refusals, as deploy issues. */
|
|
376
388
|
export function deployBlockers(files: DeployFile[], mode: DeployBlockMode, options: ScanOptions = {}): DeployIssue[] {
|
|
377
389
|
if (mode === "none") return [];
|
|
@@ -783,7 +795,7 @@ export function planDeploy(tenant: string, workspace: string, files: DeployFile[
|
|
|
783
795
|
// deploy_block: (FOL-58) turns the scanner's findings into refusals —
|
|
784
796
|
// scanned with what the Checks page passes too: the account's network:
|
|
785
797
|
// and the library's outward tools (Codex review).
|
|
786
|
-
issues: [...deployIssues(files), ...blockersFor(tenant, files)],
|
|
798
|
+
issues: [...deployIssues(files), ...blockersFor(tenant, files), ...ownKeyBlockers(tenant, files)],
|
|
787
799
|
warnings: deployWarnings(files),
|
|
788
800
|
blockedBy: runsInFlight(tenant, workspace),
|
|
789
801
|
};
|
package/src/model-credential.ts
CHANGED
|
@@ -79,6 +79,11 @@ export function credentialLine(c: ModelCredential): { type: "info" | "error"; te
|
|
|
79
79
|
// level still wins; this is what a step falls to when none names one, before
|
|
80
80
|
// the platform's own credential.
|
|
81
81
|
|
|
82
|
+
/** Why a step or a call that names its own model endpoint (`provider:`)
|
|
83
|
+
* is refused where a platform admin turned own keys off (models.byok). */
|
|
84
|
+
export const OWN_KEYS_OFF =
|
|
85
|
+
"this platform runs every model call on foldrun's models, so an agent or project cannot name its own model endpoint — remove `provider:` from the agent or AGENTS.md (a platform admin can allow own keys: setting models.byok)";
|
|
86
|
+
|
|
82
87
|
/** The account vault names the account's own model key lives under. */
|
|
83
88
|
export const ACCOUNT_MODEL_SECRETS = {
|
|
84
89
|
provider: "FOLDRUN_MODEL_PROVIDER",
|
package/src/model-env.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { accountDir, workspaceDir, parseProvider, providerEnvFor } from "./store
|
|
|
10
10
|
import { readAgentsMd } from "./runner.ts";
|
|
11
11
|
import { getSecret } from "./secrets.ts";
|
|
12
12
|
import { platform, hostUrlProblem } from "./platform.ts";
|
|
13
|
-
import { accountModelBlock, isClaudeLoginToken } from "./model-credential.ts";
|
|
13
|
+
import { accountModelBlock, isClaudeLoginToken, OWN_KEYS_OFF } from "./model-credential.ts";
|
|
14
14
|
import { providerPreset } from "./providers.ts";
|
|
15
15
|
import { startTranslator, translatorSpecFor, type TranslatorSpec } from "./translator.ts";
|
|
16
16
|
import { supplyProviderBlock, type SupplyAnswer } from "./model-supply.ts";
|
|
@@ -50,9 +50,15 @@ export function accountModelEnv(
|
|
|
50
50
|
translator: TranslatorSpec | null;
|
|
51
51
|
tenant?: string;
|
|
52
52
|
} {
|
|
53
|
-
const
|
|
53
|
+
const writtenBlock =
|
|
54
54
|
(readAgentsMd(workspaceDir(tenant, workspace))?.data?.provider as Record<string, unknown> | undefined) ??
|
|
55
55
|
(readAgentsMd(accountDir(tenant))?.data?.provider as Record<string, unknown> | undefined);
|
|
56
|
+
// Own keys as the platform admin allows them (models.byok), as a step
|
|
57
|
+
// takes them (runner.ts): off, a written block is refused and the stored
|
|
58
|
+
// key never read.
|
|
59
|
+
const ownKeys = platform.ownModelKeys?.(tenant) ?? true;
|
|
60
|
+
if (writtenBlock && !ownKeys) throw new ModelKeyError(OWN_KEYS_OFF, 403);
|
|
61
|
+
const written = writtenBlock;
|
|
56
62
|
// foldrun's models, the same rung a step takes (runner.ts agentContext):
|
|
57
63
|
// after the written blocks, before the account's stored key; chosen but
|
|
58
64
|
// refused fails here, never onto the stored key or the operator's.
|
|
@@ -78,7 +84,7 @@ export function accountModelEnv(
|
|
|
78
84
|
tenant,
|
|
79
85
|
};
|
|
80
86
|
}
|
|
81
|
-
const raw = written ?? accountModelBlock((name) => getSecret(tenant, name)?.value ?? null);
|
|
87
|
+
const raw = written ?? (ownKeys ? accountModelBlock((name) => getSecret(tenant, name)?.value ?? null) : undefined);
|
|
82
88
|
const spec = parseProvider(raw);
|
|
83
89
|
if (!spec?.baseUrl) {
|
|
84
90
|
if (!platform.platformKeyAllowed(tenant)) throw new ModelKeyError(NO_MODEL_KEY);
|
package/src/platform.ts
CHANGED
|
@@ -165,6 +165,13 @@ export interface PlatformHooks {
|
|
|
165
165
|
* operator's accounts do so; every customer brings their own API key.
|
|
166
166
|
* Default: yes — a laptop or a self-hosted install is its own operator. */
|
|
167
167
|
platformKeyAllowed(tenant: string): boolean;
|
|
168
|
+
/** May this account's steps run on a model key or endpoint of its own —
|
|
169
|
+
* the account's stored key (Settings → Models) or a `provider:` block in
|
|
170
|
+
* its files (BYOK)? A platform admin decides, for the whole install
|
|
171
|
+
* (setting models.byok, 22 Nov 2026: off unless turned on). No: a stored
|
|
172
|
+
* key is never used, and a step whose files name a provider: is refused
|
|
173
|
+
* before it starts. Absent: yes — a laptop runs on what it is given. */
|
|
174
|
+
ownModelKeys?(tenant: string): boolean;
|
|
168
175
|
/** foldrun's models (3 Nov 2026): whether this account chose to run on
|
|
169
176
|
* the platform's own key for a provider, and whether it can now. Asked
|
|
170
177
|
* only where no provider: block of the account's own says otherwise.
|
package/src/provider-health.ts
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
// pass here means a run would reach the same place with the same key.
|
|
20
20
|
|
|
21
21
|
import { accountModelBlock } from "./model-credential.ts";
|
|
22
|
+
import { platform } from "./platform.ts";
|
|
22
23
|
import fs from "node:fs";
|
|
23
24
|
import path from "node:path";
|
|
24
25
|
import { configMatter } from "./matter.ts";
|
|
@@ -224,6 +225,9 @@ function frontmatterOf(file: string): Record<string, unknown> {
|
|
|
224
225
|
export function providersInUse(tenant: string): ProviderInUse[] {
|
|
225
226
|
const out: ProviderInUse[] = [];
|
|
226
227
|
const seen = new Set<string>();
|
|
228
|
+
// Own keys off on this platform (models.byok): nothing of the account's
|
|
229
|
+
// is used, so nothing is probed (or spent) on its behalf.
|
|
230
|
+
if (!(platform.ownModelKeys?.(tenant) ?? true)) return out;
|
|
227
231
|
|
|
228
232
|
const add = (raw: unknown, workspace: string | null, declaredIn: string) => {
|
|
229
233
|
const spec = parseProvider(raw);
|
package/src/runner.ts
CHANGED
|
@@ -24,7 +24,7 @@ import { eventUrl } from "./webhook.ts";
|
|
|
24
24
|
import { runStepInContainer, resolveResources, memoryGiB, heldCores, killRunSandboxes, classDisk, type StepTiming } from "./run-container.ts";
|
|
25
25
|
import { readResources, hasOverride, anyMemoryMi } from "./resources.ts";
|
|
26
26
|
import { hostSafeEnv, platformApiUrl } from "./host-env.ts";
|
|
27
|
-
import { resolveModelCredential, credentialLine, accountModelBlock, isClaudeLoginToken, isModelEnvName, DECLARED_ENV_PREFIX } from "./model-credential.ts";
|
|
27
|
+
import { resolveModelCredential, credentialLine, accountModelBlock, isClaudeLoginToken, isModelEnvName, DECLARED_ENV_PREFIX, OWN_KEYS_OFF } from "./model-credential.ts";
|
|
28
28
|
import { parseJudge } from "./judge-verdict.ts";
|
|
29
29
|
import { validateSchema, describeSchemaErrors, looksLikeSchema } from "./json-schema.ts";
|
|
30
30
|
import { EGRESS_ENV, MODEL_KEY_NAME, addGrant, grantModelKey, hostOf, placeholderNames, proxyModelEnv, unsubstitute, type EgressGrant } from "./egress.ts";
|
|
@@ -1453,20 +1453,31 @@ export function agentContext(
|
|
|
1453
1453
|
// agent's own block wins over the workspace's, like everything else here.
|
|
1454
1454
|
// Then the account's own model key (Settings → Models), when it set one:
|
|
1455
1455
|
// an account that brings its key need not write a block anywhere.
|
|
1456
|
-
const
|
|
1456
|
+
const writtenBlock =
|
|
1457
1457
|
(front.provider as Record<string, unknown> | undefined) ?? workspaceFrontmatter(agentDir, tenant).provider;
|
|
1458
|
+
// Own keys (BYOK) as the platform admin allows them (models.byok): off,
|
|
1459
|
+
// a written provider: block refuses the step and a stored key is never
|
|
1460
|
+
// read — every call goes through foldrun's models.
|
|
1461
|
+
const ownKeys = platform.ownModelKeys?.(tenant) ?? true;
|
|
1462
|
+
const fileBlock = ownKeys ? writtenBlock : undefined;
|
|
1458
1463
|
// foldrun's models (3 Nov 2026): an account that chose the platform's key
|
|
1459
1464
|
// for a provider runs on it here, between its written blocks (which still
|
|
1460
1465
|
// win) and its stored key. Chosen but not to be had now — refused, and
|
|
1461
1466
|
// the step fails with why (runStep); it never falls to the stored key.
|
|
1462
|
-
const supply: SupplyAnswer = fileBlock
|
|
1467
|
+
const supply: SupplyAnswer = fileBlock
|
|
1468
|
+
? { kind: "none" }
|
|
1469
|
+
: writtenBlock
|
|
1470
|
+
? { kind: "refused", reason: OWN_KEYS_OFF }
|
|
1471
|
+
: platform.modelSupply?.(tenant) ?? { kind: "none" };
|
|
1463
1472
|
const providerBlock =
|
|
1464
1473
|
fileBlock ??
|
|
1465
1474
|
(supply.kind === "foldrun"
|
|
1466
1475
|
? supplyProviderBlock(supply.provider, supply.tiers, supply.via)
|
|
1467
1476
|
: supply.kind === "refused"
|
|
1468
1477
|
? undefined
|
|
1469
|
-
:
|
|
1478
|
+
: ownKeys
|
|
1479
|
+
? accountModelBlock((name) => getSecret(tenant, name)?.value ?? null)
|
|
1480
|
+
: undefined);
|
|
1470
1481
|
let providerEnv: Record<string, string> = {};
|
|
1471
1482
|
let providerLabel: string | null = null;
|
|
1472
1483
|
// Secret values pulled into the provider block, name → value. Kept apart
|
|
@@ -2658,7 +2669,7 @@ async function runStepBody(
|
|
|
2658
2669
|
// Chosen, but not to be had now: failed with why, before a sandbox —
|
|
2659
2670
|
// never onto the account's stored key or the operator's.
|
|
2660
2671
|
if (supply.kind === "refused") {
|
|
2661
|
-
push("error", `foldrun's models: ${supply.reason} — or switch this account back to its own key (Settings → Models, \`foldrun account model use own\`)`);
|
|
2672
|
+
push("error", platform.ownModelKeys?.(tenant) ?? true ? `foldrun's models: ${supply.reason} — or switch this account back to its own key (Settings → Models, \`foldrun account model use own\`)` : `foldrun's models: ${supply.reason}`);
|
|
2662
2673
|
step.status = "failed";
|
|
2663
2674
|
save();
|
|
2664
2675
|
return;
|
package/src/scan.ts
CHANGED
|
@@ -95,6 +95,11 @@ export interface ScanOptions {
|
|
|
95
95
|
* (a `model:` word or id) — the price list's ceiling on foldrun's
|
|
96
96
|
* models — or null when that is not known here. */
|
|
97
97
|
outputCeiling?: (model: string) => { ceiling: number; model: string; on: string } | null;
|
|
98
|
+
/** May this account's files name their own model endpoint (`provider:`)?
|
|
99
|
+
* False where a platform admin turned own keys off (models.byok): each
|
|
100
|
+
* one is config/own-model-key, an error, so the deploy is refused.
|
|
101
|
+
* Absent (the CLI offline, a laptop): yes. */
|
|
102
|
+
ownModelKeys?: boolean;
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
export const OWASP_URL = "https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026";
|
|
@@ -343,6 +348,16 @@ export const SCAN_RULES: readonly ScanRule[] = [
|
|
|
343
348
|
"The step still runs, at the nearest level the model has, and the step's log says so. Write the level it has, or choose " +
|
|
344
349
|
"a provider whose model has the one you want (Settings → Models).",
|
|
345
350
|
},
|
|
351
|
+
{
|
|
352
|
+
id: "config/own-model-key",
|
|
353
|
+
category: "config",
|
|
354
|
+
level: "error",
|
|
355
|
+
title: "A model endpoint of its own, where this platform runs every call on its own models",
|
|
356
|
+
help:
|
|
357
|
+
"This platform's admin turned own model keys off (setting models.byok), so every model call goes through foldrun's models. " +
|
|
358
|
+
"An agent's or a project's `provider:` block names an endpoint and key of its own, which would run unmetered. Remove the " +
|
|
359
|
+
"block: the agent then runs on the account's choice in Settings → Models.",
|
|
360
|
+
},
|
|
346
361
|
{
|
|
347
362
|
id: "config/output-fitted",
|
|
348
363
|
category: "config",
|
|
@@ -1368,6 +1383,17 @@ export function scanFiles(files: ScanFile[], options: ScanOptions = {}): ScanFin
|
|
|
1368
1383
|
// A workspace that names its own provider: does not run on the account's
|
|
1369
1384
|
// choice, so the account's models say nothing about its efforts.
|
|
1370
1385
|
const ownWorkspaceProvider = Boolean(workspaceMd && frontOf(workspaceMd.content, "AGENTS.md")?.provider);
|
|
1386
|
+
// Own keys off on this platform (models.byok): every provider: is refused.
|
|
1387
|
+
if (options.ownModelKeys === false) {
|
|
1388
|
+
const lineOf = (content: string) => {
|
|
1389
|
+
const i = content.split("\n").findIndex((l) => /^provider\s*:/.test(l));
|
|
1390
|
+
return i >= 0 ? i + 1 : 1;
|
|
1391
|
+
};
|
|
1392
|
+
const say = (file: string, content: string) =>
|
|
1393
|
+
push("config/own-model-key", file, lineOf(content), `config/own-model-key ${file}`, "provider: names a model endpoint of its own, and this platform runs every model call on its own models (own keys are off) — remove it; the agent runs on the account's choice in Settings → Models.");
|
|
1394
|
+
for (const a of agents) if (a.data.provider) say(a.file, files.find((f) => f.path === a.file)?.content ?? "");
|
|
1395
|
+
if (workspaceMd && ownWorkspaceProvider) say(workspaceMd.path, workspaceMd.content);
|
|
1396
|
+
}
|
|
1371
1397
|
if (options.effortRunsAs && !ownWorkspaceProvider) scanEfforts(agents, flows, options.effortRunsAs, push);
|
|
1372
1398
|
if (options.outputCeiling && !ownWorkspaceProvider) scanOutputs(agents, flows, options.outputCeiling, push);
|
|
1373
1399
|
for (const m of more.values()) {
|
package/src/starter.ts
CHANGED
|
@@ -520,7 +520,7 @@ secrets: [CRM_TOKEN] # keys the agent uses itself; a tool's own come with
|
|
|
520
520
|
limits: {web.search: 40, crm: 20, calls: 300} # per step; a call past a limit is refused, never run
|
|
521
521
|
network: [api.example.com] # sites its sandbox may reach, added to the trusted list; open | trusted | none
|
|
522
522
|
timezone: Australia/Sydney # the calendar it works to — IANA name or UTC+10
|
|
523
|
-
provider: {} # BYOK for this agent; account-wide: \`foldrun account model set\`
|
|
523
|
+
provider: {} # BYOK for this agent, where the platform allows own keys (models.byok); account-wide: \`foldrun account model set\`
|
|
524
524
|
permissionMode: plan # plan first, act once approved
|
|
525
525
|
runtime: # only if scripts need packages
|
|
526
526
|
packages: [requests]
|
package/src/workspace-check.ts
CHANGED
|
@@ -37,7 +37,11 @@ export function checkOptions(tenant: string, workspace: string): ScanOptions {
|
|
|
37
37
|
// AGENTS.md, or the older project.md, as the runner reads it (Codex review).
|
|
38
38
|
const accountKeys = readAgentsMdKeys(accountDir(tenant));
|
|
39
39
|
const accountNetwork = accountKeys.network;
|
|
40
|
-
|
|
40
|
+
// Own keys as the platform admin set them (models.byok): off, a provider:
|
|
41
|
+
// in these files is an error, so the deploy, a save and the Checks page
|
|
42
|
+
// all refuse it as the runner would.
|
|
43
|
+
const ownModelKeys = platform.ownModelKeys?.(tenant) ?? true;
|
|
44
|
+
return { outwardTools, accountNetwork, ...effortCheck(tenant, accountKeys.provider), ...(ownModelKeys ? {} : { ownModelKeys: false }) };
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
/**
|