@foldrun/core 14.1.0 → 14.2.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.
@@ -0,0 +1,24 @@
1
+ /** foldrun's effort words, low to high (frontmatter-fields EFFORT_LEVELS). */
2
+ export declare const EFFORT_ORDER: readonly ["low", "medium", "high", "xhigh", "max"];
3
+ /**
4
+ * The reasoning-effort words each model takes on an OpenAI-shaped endpoint
5
+ * (Chat Completions' reasoning_effort, Responses' reasoning.effort), from
6
+ * the providers' own pages; the first match wins. A model not listed gets
7
+ * low | medium | high, which every reasoning model there has taken — a
8
+ * word it might not know is never sent on a guess. Add a row when a model
9
+ * documents more (or fewer).
10
+ */
11
+ export declare const MODEL_EFFORTS: readonly {
12
+ match: RegExp;
13
+ levels: readonly string[];
14
+ source: string;
15
+ }[];
16
+ /** The levels a model takes, by its id (a provider prefix ignored). */
17
+ export declare function effortsOf(model: string): readonly string[];
18
+ /**
19
+ * A foldrun effort word as this model takes it: the word itself when the
20
+ * model has it, else the nearest level below that it has (xhigh on a model
21
+ * that stops at high runs as high), else its lowest. Null for a word that
22
+ * is not one of ours.
23
+ */
24
+ export declare function fitEffort(model: string, word: string): string | null;
@@ -0,0 +1,52 @@
1
+ // Which reasoning-effort levels each model takes, and how a foldrun level
2
+ // runs on it. One table for the translator (what is sent), the gateway's
3
+ // reshaping and the checks (what a developer is told), so the warning and
4
+ // the wire never disagree. Pure: no network, no platform.
5
+ /** foldrun's effort words, low to high (frontmatter-fields EFFORT_LEVELS). */
6
+ export const EFFORT_ORDER = ["low", "medium", "high", "xhigh", "max"];
7
+ /**
8
+ * The reasoning-effort words each model takes on an OpenAI-shaped endpoint
9
+ * (Chat Completions' reasoning_effort, Responses' reasoning.effort), from
10
+ * the providers' own pages; the first match wins. A model not listed gets
11
+ * low | medium | high, which every reasoning model there has taken — a
12
+ * word it might not know is never sent on a guess. Add a row when a model
13
+ * documents more (or fewer).
14
+ */
15
+ export const MODEL_EFFORTS = [
16
+ {
17
+ // "reasoning.effort supports low, medium (default), high, xhigh, and max"
18
+ // (Luna also none, which no foldrun word asks for).
19
+ match: /^gpt-6(?:\.\d+)?-(?:astra|sol|luna)(?:$|-)/,
20
+ levels: ["low", "medium", "high", "xhigh", "max"],
21
+ source: "developers.openai.com/api/docs/models, 3 Nov 2026",
22
+ },
23
+ {
24
+ // reasoning_effort minimal | low | medium | high; thinking cannot be
25
+ // turned off on Gemini 3 and later.
26
+ match: /^gemini-/,
27
+ levels: ["low", "medium", "high"],
28
+ source: "ai.google.dev/gemini-api/docs/openai, 3 Nov 2026",
29
+ },
30
+ ];
31
+ const DEFAULT_EFFORTS = ["low", "medium", "high"];
32
+ /** The levels a model takes, by its id (a provider prefix ignored). */
33
+ export function effortsOf(model) {
34
+ const id = String(model).split("/").pop()?.toLowerCase() ?? "";
35
+ return MODEL_EFFORTS.find((m) => m.match.test(id))?.levels ?? DEFAULT_EFFORTS;
36
+ }
37
+ /**
38
+ * A foldrun effort word as this model takes it: the word itself when the
39
+ * model has it, else the nearest level below that it has (xhigh on a model
40
+ * that stops at high runs as high), else its lowest. Null for a word that
41
+ * is not one of ours.
42
+ */
43
+ export function fitEffort(model, word) {
44
+ const want = EFFORT_ORDER.indexOf(word);
45
+ if (want < 0)
46
+ return null;
47
+ const levels = effortsOf(model);
48
+ for (let i = want; i >= 0; i--)
49
+ if (levels.includes(EFFORT_ORDER[i]))
50
+ return EFFORT_ORDER[i];
51
+ return EFFORT_ORDER.find((l) => levels.includes(l)) ?? null;
52
+ }
@@ -76,3 +76,11 @@ export declare function supplyProviderBlock(provider: SupplyProviderName, tiers:
76
76
  * sent as the nearest one it does.
77
77
  */
78
78
  export declare function shapeRequest(p: SupplyProvider, json: Record<string, unknown>): boolean;
79
+ /**
80
+ * The effort a foldrun level actually runs at on one of foldrun's models:
81
+ * the provider's own aliases (DeepSeek), its reshaping (Kimi), the model's
82
+ * levels on an OpenAI-shaped endpoint (OpenAI, Gemini), or the level itself
83
+ * (Claude takes all five). Null for a word that is not one of ours. What a
84
+ * check tells a developer, from the same tables the wire uses.
85
+ */
86
+ export declare function effortRunsAs(provider: SupplyProviderName, model: string, word: string): string | null;
@@ -13,6 +13,7 @@
13
13
  // an operator in the console, sealed in the platform's store — never in the
14
14
  // environment), the operator lists it, and the price list names the model.
15
15
  import { providerPreset } from "./providers.js";
16
+ import { fitEffort, EFFORT_ORDER } from "./effort-fit.js";
16
17
  export const SUPPLY_PROVIDERS = {
17
18
  anthropic: {
18
19
  name: "anthropic",
@@ -173,3 +174,25 @@ export function shapeRequest(p, json) {
173
174
  }
174
175
  return changed;
175
176
  }
177
+ /** DeepSeek takes every foldrun word but runs three levels (its docs:
178
+ * "medium and xhigh both map to high"). Said, not rewritten. */
179
+ const DEEPSEEK_RUNS = { low: "low", medium: "high", high: "high", xhigh: "high", max: "max" };
180
+ /**
181
+ * The effort a foldrun level actually runs at on one of foldrun's models:
182
+ * the provider's own aliases (DeepSeek), its reshaping (Kimi), the model's
183
+ * levels on an OpenAI-shaped endpoint (OpenAI, Gemini), or the level itself
184
+ * (Claude takes all five). Null for a word that is not one of ours. What a
185
+ * check tells a developer, from the same tables the wire uses.
186
+ */
187
+ export function effortRunsAs(provider, model, word) {
188
+ if (!EFFORT_ORDER.includes(word))
189
+ return null;
190
+ const p = SUPPLY_PROVIDERS[provider];
191
+ if (p.send?.effort)
192
+ return p.send.effort[word] ?? null;
193
+ if (provider === "deepseek")
194
+ return DEEPSEEK_RUNS[word] ?? null;
195
+ if (p.format === "anthropic")
196
+ return word;
197
+ return fitEffort(model, word);
198
+ }
@@ -40,6 +40,14 @@ export interface ScanOptions {
40
40
  /** The account AGENTS.md's `network:` — the level above the workspace's,
41
41
  * which the files of one workspace do not carry. */
42
42
  accountNetwork?: unknown;
43
+ /** What an effort level runs at on the model this account's steps run on
44
+ * (a `model:` word or id, an effort word), and where — or null when that
45
+ * is not known here (the CLI, offline: it knows no account's choice). */
46
+ effortRunsAs?: (model: string, effort: string) => {
47
+ effort: string;
48
+ model: string;
49
+ on: string;
50
+ } | null;
43
51
  }
44
52
  export declare const OWASP_URL = "https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026";
45
53
  export declare const SCAN_RULES: readonly ScanRule[];
@@ -96,11 +104,6 @@ export declare function nearestField(key: string, known: readonly string[]): str
96
104
  export declare const STRICT_FRONTMATTER_PATH: RegExp;
97
105
  /** How many times one rule is listed for one file before the rest are counted. */
98
106
  export declare const PER_FILE_RULE = 100;
99
- /**
100
- * Every finding in these files, ignores applied. Findings are sorted by file
101
- * then line, and one rule says one thing once per line, and at most
102
- * PER_FILE_RULE times in one file.
103
- */
104
107
  export declare function scanFiles(files: ScanFile[], options?: ScanOptions): ScanFinding[];
105
108
  /**
106
109
  * Drop the findings a `foldrun-ignore` comment (with a reason) covers — for
package/dist/src/scan.js CHANGED
@@ -32,7 +32,7 @@ import { resolveNetwork } from "./network.js";
32
32
  import { frontmatterProblems, schemaKindOf } from "./frontmatter-schema.js";
33
33
  import { parseRemotes } from "./a2a-remotes.js";
34
34
  import { isA2aPublished } from "./a2a-publish.js";
35
- import { parseFlow } from "./store.js";
35
+ import { parseFlow, resolveEffort } from "./store.js";
36
36
  export const OWASP_URL = "https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026";
37
37
  export const SCAN_RULES = [
38
38
  {
@@ -231,6 +231,15 @@ export const SCAN_RULES = [
231
231
  {
232
232
  // 30 Oct 2026: check and the scheduler read a schedule with the same
233
233
  // cronCanFire (core cron.ts), so check says what the scheduler does.
234
+ id: "config/effort-fitted",
235
+ category: "config",
236
+ level: "warn",
237
+ title: "An effort level the model this account runs on does not have",
238
+ help: "Each model takes its own effort levels: GPT-6 and Claude take all five, Gemini stops at high, Kimi has low, high and max. " +
239
+ "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 " +
240
+ "a provider whose model has the one you want (Settings → Model provider).",
241
+ },
242
+ {
234
243
  id: "config/cron-never-fires",
235
244
  category: "config",
236
245
  level: "warn",
@@ -875,6 +884,78 @@ export const PER_FILE_RULE = 100;
875
884
  * then line, and one rule says one thing once per line, and at most
876
885
  * PER_FILE_RULE times in one file.
877
886
  */
887
+ /**
888
+ * An `effort:` the model a step will run on does not have: warned, not
889
+ * refused — the step runs at the nearest level, and a file stays valid when
890
+ * the account changes provider. Agents' own effort, a flow's default and a
891
+ * step's override, each on the model it would run with.
892
+ */
893
+ function scanEfforts(agents, flows, runsAs, push) {
894
+ const say = (file, line, effort, model, whence) => {
895
+ const r = runsAs(model, effort);
896
+ if (!r || r.effort === effort)
897
+ return;
898
+ push("config/effort-fitted", file, line, `config/effort-fitted ${file} ${whence} ${effort} ${r.model}`, `effort: ${effort}${whence} runs as ${r.effort} on ${r.on} (${r.model}) — the nearest level that model has.`);
899
+ };
900
+ // Each agent: its own effort on its own model, as the runner reads them
901
+ // (resolveEffort: MAX, maximum, extra-high … are levels too).
902
+ const byName = new Map();
903
+ const ownProvider = new Set();
904
+ for (const a of agents) {
905
+ const model = typeof a.data.model === "string" && a.data.model.trim() ? a.data.model.trim() : "default";
906
+ const effort = resolveEffort(a.data.effort);
907
+ byName.set(a.name, { model, raw: a.data.effort });
908
+ // An agent with its own provider: runs there, not on the account's choice.
909
+ if (a.data.provider) {
910
+ ownProvider.add(a.name);
911
+ continue;
912
+ }
913
+ if (effort)
914
+ say(a.file, keyLine(a.lines, "effort"), effort, model, "");
915
+ }
916
+ // Each flow step: effort and model resolved step → flow → agent, the way
917
+ // runStep does, and said where the effort was written (Codex review).
918
+ for (const fl of flows) {
919
+ let info;
920
+ try {
921
+ info = parseFlow(fl.file, fl.content);
922
+ }
923
+ catch {
924
+ continue;
925
+ }
926
+ const steps = [...(info.steps ?? [])].sort((x, y) => (x.line ?? 0) - (y.line ?? 0));
927
+ const flowEffortLine = keyLine(fl.lines, "effort");
928
+ steps.forEach((st, i) => {
929
+ if (st.subflow || ownProvider.has(st.agent))
930
+ return;
931
+ const agent = byName.get(st.agent);
932
+ // The written value that wins, then read — runStep's order: a step's
933
+ // effort (even one that names no level) is the step's (Codex review).
934
+ const from = st.effort != null ? "step" : info.effort != null ? "flow" : "agent";
935
+ const effort = resolveEffort(from === "step" ? st.effort : from === "flow" ? info.effort : agent?.raw);
936
+ if (!effort)
937
+ return;
938
+ const model = st.model ?? info.model ?? agent?.model ?? "default";
939
+ if (from === "step") {
940
+ // The step's own `effort:` line, within this step's lines.
941
+ const from = st.line ?? 1;
942
+ const to = steps[i + 1]?.line ?? fl.lines.length + 1;
943
+ let at;
944
+ for (let n = from; n < to; n++)
945
+ if (/^\s+effort\s*:/.test(fl.lines[n - 1] ?? ""))
946
+ at = n;
947
+ say(fl.file, at ?? st.line, effort, model, ` (step ${st.agent})`);
948
+ }
949
+ else if (from === "flow") {
950
+ say(fl.file, flowEffortLine, effort, model, ` (the flow's, on step ${st.agent})`);
951
+ }
952
+ else if (st.model || info.model) {
953
+ // The agent's own effort, on a model this flow chose for it.
954
+ say(fl.file, st.line, effort, model, ` (${st.agent}'s own, on this step's model)`);
955
+ }
956
+ });
957
+ }
958
+ }
878
959
  export function scanFiles(files, options = {}) {
879
960
  const want = options.only?.length ? new Set(options.only) : null;
880
961
  const enabled = (rule) => !want || want.has(rule) || want.has(scanRule(rule)?.category ?? "") || rule === "check/ignore-needs-reason";
@@ -983,6 +1064,10 @@ export function scanFiles(files, options = {}) {
983
1064
  const workspaceMd = files.find((f) => f.path === "AGENTS.md") ?? files.find((f) => f.path === "project.md");
984
1065
  const legs = scanAgents(agents, outward, toolDefs, push, { account: options.accountNetwork, workspace: workspaceMd ? frontOf(workspaceMd.content, "AGENTS.md")?.network : undefined });
985
1066
  scanPublishedFlows(flows, legs, push);
1067
+ // A workspace that names its own provider: does not run on the account's
1068
+ // choice, so the account's models say nothing about its efforts.
1069
+ if (options.effortRunsAs && !(workspaceMd && frontOf(workspaceMd.content, "AGENTS.md")?.provider))
1070
+ scanEfforts(agents, flows, options.effortRunsAs, push);
986
1071
  for (const m of more.values()) {
987
1072
  findings.push({ rule: m.rule, level: m.level ?? scanRule(m.rule)?.level ?? "warn", file: m.file, message: `and ${m.n} more like this in this file, not listed`, fingerprint: m.hash.digest("hex").slice(0, 16), truncated: true });
988
1073
  }
@@ -69,27 +69,15 @@ interface Dropped {
69
69
  lines(): string[];
70
70
  }
71
71
  /**
72
- * The reasoning-effort words each model takes on an OpenAI-shaped endpoint
73
- * (Chat Completions' reasoning_effort, Responses' reasoning.effort), from
74
- * the providers' own pages; the first match wins. A model not listed gets
75
- * low | medium | high, which every reasoning model there has taken — a
76
- * word it might not know is never sent on a guess. Add a row when a model
77
- * documents more (or fewer).
72
+ * Whether a model is one OpenAI's own endpoint refuses a reasoning-effort
73
+ * parameter for ("Unsupported parameter: 'reasoning.effort'" on gpt-4o-mini).
74
+ * A gateway in front of it ignored the field, which is how the preset's
75
+ * reasoningEffort shipped untested against the origin. The families that do
76
+ * not reason are the ones named — anything else (o-series, gpt-5, grok,
77
+ * gemini, deepseek-r, qwen thinking) keeps getting the knob, because on a
78
+ * gateway the id alone cannot say and an ignored field costs nothing.
78
79
  */
79
- export declare const MODEL_EFFORTS: readonly {
80
- match: RegExp;
81
- levels: readonly string[];
82
- source: string;
83
- }[];
84
- /** The levels a model takes, by its id (a provider prefix ignored). */
85
- export declare function effortsOf(model: string): readonly string[];
86
- /**
87
- * A foldrun effort word as this model takes it: the word itself when the
88
- * model has it, else the nearest level below that it has (xhigh on a model
89
- * that stops at high runs as high), else its lowest. Null for a word that
90
- * is not one of ours.
91
- */
92
- export declare function fitEffort(model: string, word: string): string | null;
80
+ export { MODEL_EFFORTS, effortsOf, fitEffort } from "./effort-fit.ts";
93
81
  export declare function modelRejectsReasoning(model: string): boolean;
94
82
  /**
95
83
  * An Anthropic Messages request as a Chat Completions request. Pure.
@@ -227,4 +215,3 @@ export declare function translatorSpecFor(spec: {
227
215
  reasoningEffort?: boolean;
228
216
  cacheKey?: string;
229
217
  }): TranslatorSpec | null;
230
- export {};
@@ -91,54 +91,10 @@ function stableId(id) {
91
91
  * gemini, deepseek-r, qwen thinking) keeps getting the knob, because on a
92
92
  * gateway the id alone cannot say and an ignored field costs nothing.
93
93
  */
94
- /** foldrun's effort words, low to high (frontmatter-fields EFFORT_LEVELS). */
95
- const EFFORT_ORDER = ["low", "medium", "high", "xhigh", "max"];
96
- /**
97
- * The reasoning-effort words each model takes on an OpenAI-shaped endpoint
98
- * (Chat Completions' reasoning_effort, Responses' reasoning.effort), from
99
- * the providers' own pages; the first match wins. A model not listed gets
100
- * low | medium | high, which every reasoning model there has taken — a
101
- * word it might not know is never sent on a guess. Add a row when a model
102
- * documents more (or fewer).
103
- */
104
- export const MODEL_EFFORTS = [
105
- {
106
- // "reasoning.effort supports low, medium (default), high, xhigh, and max"
107
- // (Luna also none, which no foldrun word asks for).
108
- match: /^gpt-6(?:\.\d+)?-(?:astra|sol|luna)(?:$|-)/,
109
- levels: ["low", "medium", "high", "xhigh", "max"],
110
- source: "developers.openai.com/api/docs/models, 3 Nov 2026",
111
- },
112
- {
113
- // reasoning_effort minimal | low | medium | high; thinking cannot be
114
- // turned off on Gemini 3 and later.
115
- match: /^gemini-/,
116
- levels: ["low", "medium", "high"],
117
- source: "ai.google.dev/gemini-api/docs/openai, 3 Nov 2026",
118
- },
119
- ];
120
- const DEFAULT_EFFORTS = ["low", "medium", "high"];
121
- /** The levels a model takes, by its id (a provider prefix ignored). */
122
- export function effortsOf(model) {
123
- const id = String(model).split("/").pop()?.toLowerCase() ?? "";
124
- return MODEL_EFFORTS.find((m) => m.match.test(id))?.levels ?? DEFAULT_EFFORTS;
125
- }
126
- /**
127
- * A foldrun effort word as this model takes it: the word itself when the
128
- * model has it, else the nearest level below that it has (xhigh on a model
129
- * that stops at high runs as high), else its lowest. Null for a word that
130
- * is not one of ours.
131
- */
132
- export function fitEffort(model, word) {
133
- const want = EFFORT_ORDER.indexOf(word);
134
- if (want < 0)
135
- return null;
136
- const levels = effortsOf(model);
137
- for (let i = want; i >= 0; i--)
138
- if (levels.includes(EFFORT_ORDER[i]))
139
- return EFFORT_ORDER[i];
140
- return EFFORT_ORDER.find((l) => levels.includes(l)) ?? null;
141
- }
94
+ // The effort levels each model takes live in effort-fit.ts (the scanner
95
+ // reads them too); re-exported for callers that found them here.
96
+ export { MODEL_EFFORTS, effortsOf, fitEffort } from "./effort-fit.js";
97
+ import { fitEffort } from "./effort-fit.js";
142
98
  export function modelRejectsReasoning(model) {
143
99
  const id = String(model).split("/").pop()?.toLowerCase() ?? "";
144
100
  return /^(gpt-3|gpt-4|chatgpt|gpt-5-chat|davinci|babbage)/.test(id);
@@ -6,6 +6,9 @@ import { accountDir, workspaceDir, workspaceTools } from "./store.js";
6
6
  import { readAgentsMdKeys } from "./agents-md.js";
7
7
  import { libraryTools } from "./library.js";
8
8
  import { checkFiles, readTree } from "./deploy.js";
9
+ import { platform } from "./platform.js";
10
+ import { SUPPLY_TITLES, effortRunsAs } from "./model-supply.js";
11
+ import { resolveTier, parseProvider } from "./store.js";
9
12
  /** What the checks read of a workspace, at most. Data (state/ and memory/,
10
13
  * what agents write) past these is left out and named; the rest past its
11
14
  * budget is not read at all (TreeTooLarge). On 20 Oct 2026 the daily
@@ -26,8 +29,40 @@ export function checkOptions(tenant, workspace) {
26
29
  const tools = { ...libraryTools(tenant), ...workspaceTools(tenant, workspace) };
27
30
  const outwardTools = Object.entries(tools).filter(([, d]) => d.outward === true).map(([n]) => n);
28
31
  // AGENTS.md, or the older project.md, as the runner reads it (Codex review).
29
- const accountNetwork = readAgentsMdKeys(accountDir(tenant)).network;
30
- return { outwardTools, accountNetwork };
32
+ const accountKeys = readAgentsMdKeys(accountDir(tenant));
33
+ const accountNetwork = accountKeys.network;
34
+ return { outwardTools, accountNetwork, ...effortCheck(tenant, accountKeys.provider) };
35
+ }
36
+ /**
37
+ * What an effort level runs at on the account's choice, for
38
+ * config/effort-fitted — when that choice is foldrun's models (a provider
39
+ * and its tiers the platform knows). An account AGENTS.md provider: block
40
+ * runs instead, and its own key's models are not the platform's to say.
41
+ */
42
+ function effortCheck(tenant, accountProvider) {
43
+ if (parseProvider(accountProvider)?.baseUrl)
44
+ return {};
45
+ let answer;
46
+ try {
47
+ answer = platform.modelSupply?.(tenant);
48
+ }
49
+ catch {
50
+ return {};
51
+ }
52
+ if (!answer || answer.kind !== "foldrun")
53
+ return {};
54
+ const { provider, tiers } = answer;
55
+ const on = `foldrun's models (${SUPPLY_TITLES[provider]})`;
56
+ return {
57
+ effortRunsAs: (model, effort) => {
58
+ const tier = resolveTier(model);
59
+ const id = tier ? tiers[tier] : model;
60
+ if (!id)
61
+ return null; // a Claude tier word: Claude takes every level
62
+ const runs = effortRunsAs(provider, id, effort);
63
+ return runs ? { effort: runs, model: id, on } : null;
64
+ },
65
+ };
31
66
  }
32
67
  export function checkWorkspace(tenant, workspace, tree = checkTree(workspaceDir(tenant, workspace))) {
33
68
  return checkFiles(tree, checkOptions(tenant, workspace));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldrun/core",
3
- "version": "14.1.0",
3
+ "version": "14.2.0",
4
4
  "description": "Agents are just folders. The format, the runner, the checks.",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "type": "module",
@@ -0,0 +1,54 @@
1
+ // Which reasoning-effort levels each model takes, and how a foldrun level
2
+ // runs on it. One table for the translator (what is sent), the gateway's
3
+ // reshaping and the checks (what a developer is told), so the warning and
4
+ // the wire never disagree. Pure: no network, no platform.
5
+
6
+ /** foldrun's effort words, low to high (frontmatter-fields EFFORT_LEVELS). */
7
+ export const EFFORT_ORDER = ["low", "medium", "high", "xhigh", "max"] as const;
8
+
9
+ /**
10
+ * The reasoning-effort words each model takes on an OpenAI-shaped endpoint
11
+ * (Chat Completions' reasoning_effort, Responses' reasoning.effort), from
12
+ * the providers' own pages; the first match wins. A model not listed gets
13
+ * low | medium | high, which every reasoning model there has taken — a
14
+ * word it might not know is never sent on a guess. Add a row when a model
15
+ * documents more (or fewer).
16
+ */
17
+ export const MODEL_EFFORTS: readonly { match: RegExp; levels: readonly string[]; source: string }[] = [
18
+ {
19
+ // "reasoning.effort supports low, medium (default), high, xhigh, and max"
20
+ // (Luna also none, which no foldrun word asks for).
21
+ match: /^gpt-6(?:\.\d+)?-(?:astra|sol|luna)(?:$|-)/,
22
+ levels: ["low", "medium", "high", "xhigh", "max"],
23
+ source: "developers.openai.com/api/docs/models, 3 Nov 2026",
24
+ },
25
+ {
26
+ // reasoning_effort minimal | low | medium | high; thinking cannot be
27
+ // turned off on Gemini 3 and later.
28
+ match: /^gemini-/,
29
+ levels: ["low", "medium", "high"],
30
+ source: "ai.google.dev/gemini-api/docs/openai, 3 Nov 2026",
31
+ },
32
+ ];
33
+ const DEFAULT_EFFORTS = ["low", "medium", "high"] as const;
34
+
35
+ /** The levels a model takes, by its id (a provider prefix ignored). */
36
+ export function effortsOf(model: string): readonly string[] {
37
+ const id = String(model).split("/").pop()?.toLowerCase() ?? "";
38
+ return MODEL_EFFORTS.find((m) => m.match.test(id))?.levels ?? DEFAULT_EFFORTS;
39
+ }
40
+
41
+ /**
42
+ * A foldrun effort word as this model takes it: the word itself when the
43
+ * model has it, else the nearest level below that it has (xhigh on a model
44
+ * that stops at high runs as high), else its lowest. Null for a word that
45
+ * is not one of ours.
46
+ */
47
+ export function fitEffort(model: string, word: string): string | null {
48
+ const want = (EFFORT_ORDER as readonly string[]).indexOf(word);
49
+ if (want < 0) return null;
50
+ const levels = effortsOf(model);
51
+ for (let i = want; i >= 0; i--) if (levels.includes(EFFORT_ORDER[i]!)) return EFFORT_ORDER[i]!;
52
+ return EFFORT_ORDER.find((l) => levels.includes(l)) ?? null;
53
+ }
54
+
@@ -14,6 +14,7 @@
14
14
  // environment), the operator lists it, and the price list names the model.
15
15
 
16
16
  import { providerPreset, type WireFormat } from "./providers.ts";
17
+ import { fitEffort, EFFORT_ORDER } from "./effort-fit.ts";
17
18
 
18
19
  export type SupplyProviderName = "anthropic" | "openai" | "gemini" | "deepseek" | "moonshot";
19
20
 
@@ -223,3 +224,23 @@ export function shapeRequest(p: SupplyProvider, json: Record<string, unknown>):
223
224
  }
224
225
  return changed;
225
226
  }
227
+
228
+ /** DeepSeek takes every foldrun word but runs three levels (its docs:
229
+ * "medium and xhigh both map to high"). Said, not rewritten. */
230
+ const DEEPSEEK_RUNS: Record<string, string> = { low: "low", medium: "high", high: "high", xhigh: "high", max: "max" };
231
+
232
+ /**
233
+ * The effort a foldrun level actually runs at on one of foldrun's models:
234
+ * the provider's own aliases (DeepSeek), its reshaping (Kimi), the model's
235
+ * levels on an OpenAI-shaped endpoint (OpenAI, Gemini), or the level itself
236
+ * (Claude takes all five). Null for a word that is not one of ours. What a
237
+ * check tells a developer, from the same tables the wire uses.
238
+ */
239
+ export function effortRunsAs(provider: SupplyProviderName, model: string, word: string): string | null {
240
+ if (!(EFFORT_ORDER as readonly string[]).includes(word)) return null;
241
+ const p = SUPPLY_PROVIDERS[provider];
242
+ if (p.send?.effort) return p.send.effort[word] ?? null;
243
+ if (provider === "deepseek") return DEEPSEEK_RUNS[word] ?? null;
244
+ if (p.format === "anthropic") return word;
245
+ return fitEffort(model, word);
246
+ }
package/src/scan.ts CHANGED
@@ -33,7 +33,7 @@ import { resolveNetwork } from "./network.ts";
33
33
  import { frontmatterProblems, schemaKindOf } from "./frontmatter-schema.ts";
34
34
  import { parseRemotes } from "./a2a-remotes.ts";
35
35
  import { isA2aPublished } from "./a2a-publish.ts";
36
- import { parseFlow, type FlowStep } from "./store.ts";
36
+ import { parseFlow, resolveEffort, type FlowStep } from "./store.ts";
37
37
 
38
38
  export type ScanLevel = "error" | "warn" | "info";
39
39
  export type ScanCategory = "secret" | "security" | "content" | "supply-chain" | "config";
@@ -81,6 +81,10 @@ export interface ScanOptions {
81
81
  /** The account AGENTS.md's `network:` — the level above the workspace's,
82
82
  * which the files of one workspace do not carry. */
83
83
  accountNetwork?: unknown;
84
+ /** What an effort level runs at on the model this account's steps run on
85
+ * (a `model:` word or id, an effort word), and where — or null when that
86
+ * is not known here (the CLI, offline: it knows no account's choice). */
87
+ effortRunsAs?: (model: string, effort: string) => { effort: string; model: string; on: string } | null;
84
88
  }
85
89
 
86
90
  export const OWASP_URL = "https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026";
@@ -301,6 +305,16 @@ export const SCAN_RULES: readonly ScanRule[] = [
301
305
  {
302
306
  // 30 Oct 2026: check and the scheduler read a schedule with the same
303
307
  // cronCanFire (core cron.ts), so check says what the scheduler does.
308
+ id: "config/effort-fitted",
309
+ category: "config",
310
+ level: "warn",
311
+ title: "An effort level the model this account runs on does not have",
312
+ help:
313
+ "Each model takes its own effort levels: GPT-6 and Claude take all five, Gemini stops at high, Kimi has low, high and max. " +
314
+ "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 " +
315
+ "a provider whose model has the one you want (Settings → Model provider).",
316
+ },
317
+ {
304
318
  id: "config/cron-never-fires",
305
319
  category: "config",
306
320
  level: "warn",
@@ -995,6 +1009,76 @@ export const PER_FILE_RULE = 100;
995
1009
  * then line, and one rule says one thing once per line, and at most
996
1010
  * PER_FILE_RULE times in one file.
997
1011
  */
1012
+ /**
1013
+ * An `effort:` the model a step will run on does not have: warned, not
1014
+ * refused — the step runs at the nearest level, and a file stays valid when
1015
+ * the account changes provider. Agents' own effort, a flow's default and a
1016
+ * step's override, each on the model it would run with.
1017
+ */
1018
+ function scanEfforts(agents: AgentFacts[], flows: FlowFacts[], runsAs: NonNullable<ScanOptions["effortRunsAs"]>, push: Push): void {
1019
+ const say = (file: string, line: number | undefined, effort: string, model: string, whence: string) => {
1020
+ const r = runsAs(model, effort);
1021
+ if (!r || r.effort === effort) return;
1022
+ push(
1023
+ "config/effort-fitted",
1024
+ file,
1025
+ line,
1026
+ `config/effort-fitted ${file} ${whence} ${effort} ${r.model}`,
1027
+ `effort: ${effort}${whence} runs as ${r.effort} on ${r.on} (${r.model}) — the nearest level that model has.`,
1028
+ );
1029
+ };
1030
+ // Each agent: its own effort on its own model, as the runner reads them
1031
+ // (resolveEffort: MAX, maximum, extra-high … are levels too).
1032
+ const byName = new Map<string, { model: string; raw: unknown }>();
1033
+ const ownProvider = new Set<string>();
1034
+ for (const a of agents) {
1035
+ const model = typeof a.data.model === "string" && a.data.model.trim() ? a.data.model.trim() : "default";
1036
+ const effort = resolveEffort(a.data.effort);
1037
+ byName.set(a.name, { model, raw: a.data.effort });
1038
+ // An agent with its own provider: runs there, not on the account's choice.
1039
+ if (a.data.provider) {
1040
+ ownProvider.add(a.name);
1041
+ continue;
1042
+ }
1043
+ if (effort) say(a.file, keyLine(a.lines, "effort"), effort, model, "");
1044
+ }
1045
+ // Each flow step: effort and model resolved step → flow → agent, the way
1046
+ // runStep does, and said where the effort was written (Codex review).
1047
+ for (const fl of flows) {
1048
+ let info: ReturnType<typeof parseFlow>;
1049
+ try {
1050
+ info = parseFlow(fl.file, fl.content);
1051
+ } catch {
1052
+ continue;
1053
+ }
1054
+ const steps = [...(info.steps ?? [])].sort((x, y) => (x.line ?? 0) - (y.line ?? 0));
1055
+ const flowEffortLine = keyLine(fl.lines, "effort");
1056
+ steps.forEach((st, i) => {
1057
+ if (st.subflow || ownProvider.has(st.agent)) return;
1058
+ const agent = byName.get(st.agent);
1059
+ // The written value that wins, then read — runStep's order: a step's
1060
+ // effort (even one that names no level) is the step's (Codex review).
1061
+ const from = st.effort != null ? "step" : info.effort != null ? "flow" : "agent";
1062
+ const effort = resolveEffort(from === "step" ? st.effort : from === "flow" ? info.effort : agent?.raw);
1063
+ if (!effort) return;
1064
+ const model = st.model ?? info.model ?? agent?.model ?? "default";
1065
+ if (from === "step") {
1066
+ // The step's own `effort:` line, within this step's lines.
1067
+ const from = st.line ?? 1;
1068
+ const to = steps[i + 1]?.line ?? fl.lines.length + 1;
1069
+ let at: number | undefined;
1070
+ for (let n = from; n < to; n++) if (/^\s+effort\s*:/.test(fl.lines[n - 1] ?? "")) at = n;
1071
+ say(fl.file, at ?? st.line, effort, model, ` (step ${st.agent})`);
1072
+ } else if (from === "flow") {
1073
+ say(fl.file, flowEffortLine, effort, model, ` (the flow's, on step ${st.agent})`);
1074
+ } else if (st.model || info.model) {
1075
+ // The agent's own effort, on a model this flow chose for it.
1076
+ say(fl.file, st.line, effort, model, ` (${st.agent}'s own, on this step's model)`);
1077
+ }
1078
+ });
1079
+ }
1080
+ }
1081
+
998
1082
  export function scanFiles(files: ScanFile[], options: ScanOptions = {}): ScanFinding[] {
999
1083
  const want = options.only?.length ? new Set(options.only) : null;
1000
1084
  const enabled = (rule: string) => !want || want.has(rule) || want.has(scanRule(rule)?.category ?? "") || rule === "check/ignore-needs-reason";
@@ -1096,6 +1180,9 @@ export function scanFiles(files: ScanFile[], options: ScanOptions = {}): ScanFin
1096
1180
  const workspaceMd = files.find((f) => f.path === "AGENTS.md") ?? files.find((f) => f.path === "project.md");
1097
1181
  const legs = scanAgents(agents, outward, toolDefs, push, { account: options.accountNetwork, workspace: workspaceMd ? frontOf(workspaceMd.content, "AGENTS.md")?.network : undefined });
1098
1182
  scanPublishedFlows(flows, legs, push);
1183
+ // A workspace that names its own provider: does not run on the account's
1184
+ // choice, so the account's models say nothing about its efforts.
1185
+ if (options.effortRunsAs && !(workspaceMd && frontOf(workspaceMd.content, "AGENTS.md")?.provider)) scanEfforts(agents, flows, options.effortRunsAs, push);
1099
1186
  for (const m of more.values()) {
1100
1187
  findings.push({ rule: m.rule, level: m.level ?? scanRule(m.rule)?.level ?? "warn", file: m.file, message: `and ${m.n} more like this in this file, not listed`, fingerprint: m.hash.digest("hex").slice(0, 16), truncated: true });
1101
1188
  }
package/src/translator.ts CHANGED
@@ -163,54 +163,10 @@ function stableId(id: string): string {
163
163
  * gemini, deepseek-r, qwen thinking) keeps getting the knob, because on a
164
164
  * gateway the id alone cannot say and an ignored field costs nothing.
165
165
  */
166
- /** foldrun's effort words, low to high (frontmatter-fields EFFORT_LEVELS). */
167
- const EFFORT_ORDER = ["low", "medium", "high", "xhigh", "max"] as const;
168
-
169
- /**
170
- * The reasoning-effort words each model takes on an OpenAI-shaped endpoint
171
- * (Chat Completions' reasoning_effort, Responses' reasoning.effort), from
172
- * the providers' own pages; the first match wins. A model not listed gets
173
- * low | medium | high, which every reasoning model there has taken — a
174
- * word it might not know is never sent on a guess. Add a row when a model
175
- * documents more (or fewer).
176
- */
177
- export const MODEL_EFFORTS: readonly { match: RegExp; levels: readonly string[]; source: string }[] = [
178
- {
179
- // "reasoning.effort supports low, medium (default), high, xhigh, and max"
180
- // (Luna also none, which no foldrun word asks for).
181
- match: /^gpt-6(?:\.\d+)?-(?:astra|sol|luna)(?:$|-)/,
182
- levels: ["low", "medium", "high", "xhigh", "max"],
183
- source: "developers.openai.com/api/docs/models, 3 Nov 2026",
184
- },
185
- {
186
- // reasoning_effort minimal | low | medium | high; thinking cannot be
187
- // turned off on Gemini 3 and later.
188
- match: /^gemini-/,
189
- levels: ["low", "medium", "high"],
190
- source: "ai.google.dev/gemini-api/docs/openai, 3 Nov 2026",
191
- },
192
- ];
193
- const DEFAULT_EFFORTS = ["low", "medium", "high"] as const;
194
-
195
- /** The levels a model takes, by its id (a provider prefix ignored). */
196
- export function effortsOf(model: string): readonly string[] {
197
- const id = String(model).split("/").pop()?.toLowerCase() ?? "";
198
- return MODEL_EFFORTS.find((m) => m.match.test(id))?.levels ?? DEFAULT_EFFORTS;
199
- }
200
-
201
- /**
202
- * A foldrun effort word as this model takes it: the word itself when the
203
- * model has it, else the nearest level below that it has (xhigh on a model
204
- * that stops at high runs as high), else its lowest. Null for a word that
205
- * is not one of ours.
206
- */
207
- export function fitEffort(model: string, word: string): string | null {
208
- const want = (EFFORT_ORDER as readonly string[]).indexOf(word);
209
- if (want < 0) return null;
210
- const levels = effortsOf(model);
211
- for (let i = want; i >= 0; i--) if (levels.includes(EFFORT_ORDER[i]!)) return EFFORT_ORDER[i]!;
212
- return EFFORT_ORDER.find((l) => levels.includes(l)) ?? null;
213
- }
166
+ // The effort levels each model takes live in effort-fit.ts (the scanner
167
+ // reads them too); re-exported for callers that found them here.
168
+ export { MODEL_EFFORTS, effortsOf, fitEffort } from "./effort-fit.ts";
169
+ import { fitEffort } from "./effort-fit.ts";
214
170
 
215
171
  export function modelRejectsReasoning(model: string): boolean {
216
172
  const id = String(model).split("/").pop()?.toLowerCase() ?? "";
@@ -9,6 +9,9 @@ import { libraryTools } from "./library.ts";
9
9
  import { checkFiles, readTree } from "./deploy.ts";
10
10
  import type { DeployFile } from "./store.ts";
11
11
  import type { ScanFinding, ScanOptions } from "./scan.ts";
12
+ import { platform } from "./platform.ts";
13
+ import { SUPPLY_TITLES, effortRunsAs } from "./model-supply.ts";
14
+ import { resolveTier, parseProvider } from "./store.ts";
12
15
 
13
16
  /** What the checks read of a workspace, at most. Data (state/ and memory/,
14
17
  * what agents write) past these is left out and named; the rest past its
@@ -32,8 +35,37 @@ export function checkOptions(tenant: string, workspace: string): ScanOptions {
32
35
  const tools = { ...libraryTools(tenant), ...workspaceTools(tenant, workspace) };
33
36
  const outwardTools = Object.entries(tools).filter(([, d]) => (d as OutwardMark).outward === true).map(([n]) => n);
34
37
  // AGENTS.md, or the older project.md, as the runner reads it (Codex review).
35
- const accountNetwork = readAgentsMdKeys(accountDir(tenant)).network;
36
- return { outwardTools, accountNetwork };
38
+ const accountKeys = readAgentsMdKeys(accountDir(tenant));
39
+ const accountNetwork = accountKeys.network;
40
+ return { outwardTools, accountNetwork, ...effortCheck(tenant, accountKeys.provider) };
41
+ }
42
+
43
+ /**
44
+ * What an effort level runs at on the account's choice, for
45
+ * config/effort-fitted — when that choice is foldrun's models (a provider
46
+ * and its tiers the platform knows). An account AGENTS.md provider: block
47
+ * runs instead, and its own key's models are not the platform's to say.
48
+ */
49
+ function effortCheck(tenant: string, accountProvider: unknown): Pick<ScanOptions, "effortRunsAs"> {
50
+ if (parseProvider(accountProvider)?.baseUrl) return {};
51
+ let answer: ReturnType<NonNullable<typeof platform.modelSupply>> | undefined;
52
+ try {
53
+ answer = platform.modelSupply?.(tenant);
54
+ } catch {
55
+ return {};
56
+ }
57
+ if (!answer || answer.kind !== "foldrun") return {};
58
+ const { provider, tiers } = answer;
59
+ const on = `foldrun's models (${SUPPLY_TITLES[provider]})`;
60
+ return {
61
+ effortRunsAs: (model, effort) => {
62
+ const tier = resolveTier(model);
63
+ const id = tier ? tiers[tier as "fast" | "default" | "max"] : model;
64
+ if (!id) return null; // a Claude tier word: Claude takes every level
65
+ const runs = effortRunsAs(provider, id, effort);
66
+ return runs ? { effort: runs, model: id, on } : null;
67
+ },
68
+ };
37
69
  }
38
70
 
39
71
  export function checkWorkspace(tenant: string, workspace: string, tree: DeployFile[] = checkTree(workspaceDir(tenant, workspace))): ScanFinding[] {