@foldrun/core 14.0.0 → 14.0.1

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.
@@ -19,6 +19,22 @@ export interface SupplyProvider {
19
19
  method: "GET" | "POST";
20
20
  path: string;
21
21
  }[];
22
+ /** How a request is reshaped before it leaves (the gateway applies it,
23
+ * shapeRequest). The agent runtime sends Claude's whole surface —
24
+ * `thinking: {type: adaptive, display}`, `output_config.effort` in five
25
+ * words, `context_management` — and a compatible endpoint documents
26
+ * less: what it does with the rest is not stated, so it is not sent. */
27
+ send?: SendShape;
28
+ }
29
+ export interface SendShape {
30
+ /** Only these top-level fields are sent; any other is dropped. */
31
+ fields?: string[];
32
+ /** These top-level fields are dropped. */
33
+ drop?: string[];
34
+ /** The keys of `thinking` that are sent; null drops `thinking` whole. */
35
+ thinking?: string[] | null;
36
+ /** `output_config.effort`, as this provider spells it. */
37
+ effort?: Record<string, string>;
22
38
  }
23
39
  export declare const SUPPLY_PROVIDERS: Record<SupplyProviderName, SupplyProvider>;
24
40
  export declare const SUPPLY_PROVIDER_NAMES: SupplyProviderName[];
@@ -53,3 +69,10 @@ export declare function supplyProviderOfToken(value: string | null | undefined):
53
69
  * endpoint and format, the operator's tier map, and the key as a
54
70
  * placeholder only. */
55
71
  export declare function supplyProviderBlock(provider: SupplyProviderName, tiers: Partial<Record<"fast" | "default" | "max", string>>): Record<string, unknown>;
72
+ /**
73
+ * Reshape a request body for a provider (its `send`), in place. True when
74
+ * anything changed. What a provider's schema does not list is not sent,
75
+ * rather than trusted to be ignored; an effort word it does not spell is
76
+ * sent as the nearest one it does.
77
+ */
78
+ export declare function shapeRequest(p: SupplyProvider, json: Record<string, unknown>): boolean;
@@ -29,10 +29,13 @@ export const SUPPLY_PROVIDERS = {
29
29
  openai: {
30
30
  name: "openai",
31
31
  preset: "openai",
32
- format: "openai",
32
+ // The Responses API, not Chat Completions: GPT-6 Astra and GPT-6.1 Sol
33
+ // call tools on Responses alone, GPT-6 Luna on Chat Completions only
34
+ // with reasoning off (OpenAI's model pages, 3 Nov 2026).
35
+ format: "responses",
33
36
  host: "api.openai.com",
34
37
  auth: "bearer",
35
- metered: ["/v1/chat/completions"],
38
+ metered: ["/v1/responses"],
36
39
  free: [{ method: "GET", path: "/v1/models" }],
37
40
  },
38
41
  gemini: {
@@ -57,6 +60,11 @@ export const SUPPLY_PROVIDERS = {
57
60
  auth: "x-api-key",
58
61
  metered: ["/anthropic/v1/messages"],
59
62
  free: [],
63
+ // api-docs.deepseek.com/api/create-message (3 Nov 2026): thinking.type
64
+ // enabled|disabled|adaptive (adaptive = enabled), budget_tokens ignored;
65
+ // effort takes every word ours does (medium and xhigh = high). Context
66
+ // editing and thinking.display are not in its schema.
67
+ send: { drop: ["context_management"], thinking: ["type", "budget_tokens"] },
60
68
  },
61
69
  moonshot: {
62
70
  name: "moonshot",
@@ -66,6 +74,15 @@ export const SUPPLY_PROVIDERS = {
66
74
  auth: "bearer",
67
75
  metered: ["/anthropic/v1/messages"],
68
76
  free: [],
77
+ // platform.kimi.ai/docs/api/messages (3 Nov 2026): the request schema is
78
+ // these fields alone; `thinking` is K2-only (K3.1 Pro always thinks);
79
+ // effort is low | high | max; temperature and top_p are fixed (any
80
+ // other value is an error).
81
+ send: {
82
+ fields: ["model", "messages", "max_tokens", "system", "stream", "stop_sequences", "tools", "tool_choice", "metadata", "cache_control", "output_config"],
83
+ thinking: null,
84
+ effort: { minimal: "low", low: "low", medium: "high", high: "high", xhigh: "high", max: "max" },
85
+ },
69
86
  },
70
87
  };
71
88
  export const SUPPLY_PROVIDER_NAMES = Object.keys(SUPPLY_PROVIDERS);
@@ -110,3 +127,49 @@ export function supplyProviderBlock(provider, tiers) {
110
127
  ...(Object.keys(tiers).length ? { models: tiers } : {}),
111
128
  };
112
129
  }
130
+ /**
131
+ * Reshape a request body for a provider (its `send`), in place. True when
132
+ * anything changed. What a provider's schema does not list is not sent,
133
+ * rather than trusted to be ignored; an effort word it does not spell is
134
+ * sent as the nearest one it does.
135
+ */
136
+ export function shapeRequest(p, json) {
137
+ const shape = p.send;
138
+ if (!shape)
139
+ return false;
140
+ let changed = false;
141
+ if (shape.fields) {
142
+ for (const k of Object.keys(json))
143
+ if (!shape.fields.includes(k))
144
+ (delete json[k], (changed = true));
145
+ }
146
+ for (const k of shape.drop ?? [])
147
+ if (k in json)
148
+ (delete json[k], (changed = true));
149
+ if (shape.thinking !== undefined && "thinking" in json) {
150
+ if (shape.thinking === null) {
151
+ delete json.thinking;
152
+ changed = true;
153
+ }
154
+ else if (json.thinking && typeof json.thinking === "object") {
155
+ const t = json.thinking;
156
+ for (const k of Object.keys(t))
157
+ if (!shape.thinking.includes(k))
158
+ (delete t[k], (changed = true));
159
+ }
160
+ }
161
+ const oc = json.output_config;
162
+ if (shape.effort && oc && typeof oc === "object" && typeof oc.effort === "string") {
163
+ const word = oc.effort;
164
+ const to = shape.effort[word];
165
+ if (to === undefined) {
166
+ delete oc.effort;
167
+ changed = true;
168
+ }
169
+ else if (to !== word) {
170
+ oc.effort = to;
171
+ changed = true;
172
+ }
173
+ }
174
+ return changed;
175
+ }
@@ -221,9 +221,9 @@ export const PROVIDERS = [
221
221
  { name: "vllm", title: "vLLM (yours)", format: "anthropic", auth: "bearer",
222
222
  note: "base_url is your server (default :8000). Start it with --enable-auto-tool-choice and a --tool-call-parser or no tool loop closes." },
223
223
  // ------------------------------------------- Chat-Completions, translated
224
- { name: "openai", title: "OpenAI", format: "openai", baseUrl: "https://api.openai.com/v1", auth: "bearer", verified: true,
224
+ { name: "openai", title: "OpenAI", format: "responses", baseUrl: "https://api.openai.com/v1", auth: "bearer", verified: true,
225
225
  maxTokensParam: "max_completion_tokens", reasoningEffort: true, promptCacheKey: true,
226
- note: "Reached over Chat Completions, which OpenAI keeps supporting; the Responses API is not spoken here, so a reasoning model's reasoning does not carry across tool calls.", search: "openai" },
226
+ note: "Reached over the Responses API (3 Nov 2026): GPT-6 Astra and GPT-6.1 Sol call tools there alone, GPT-6 Luna on Chat Completions only with reasoning off. `format: openai` still says Chat Completions, for an older model or a proxy that speaks only that.", search: "openai" },
227
227
  { name: "gemini", title: "Google Gemini", format: "openai", baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai", auth: "bearer",
228
228
  note: "Google's OpenAI-compatible route. Unknown parameters are ignored silently; reasoning cannot be switched off on the newest models." },
229
229
  { name: "xai", title: "xAI Grok", format: "openai", baseUrl: "https://api.x.ai/v1", auth: "bearer",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldrun/core",
3
- "version": "14.0.0",
3
+ "version": "14.0.1",
4
4
  "description": "Agents are just folders. The format, the runner, the checks.",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "type": "module",
@@ -33,6 +33,23 @@ export interface SupplyProvider {
33
33
  /** Paths that cost nothing and may pass unmetered (GET model lists, a
34
34
  * free token count). Anything not listed in either is refused. */
35
35
  free: { method: "GET" | "POST"; path: string }[];
36
+ /** How a request is reshaped before it leaves (the gateway applies it,
37
+ * shapeRequest). The agent runtime sends Claude's whole surface —
38
+ * `thinking: {type: adaptive, display}`, `output_config.effort` in five
39
+ * words, `context_management` — and a compatible endpoint documents
40
+ * less: what it does with the rest is not stated, so it is not sent. */
41
+ send?: SendShape;
42
+ }
43
+
44
+ export interface SendShape {
45
+ /** Only these top-level fields are sent; any other is dropped. */
46
+ fields?: string[];
47
+ /** These top-level fields are dropped. */
48
+ drop?: string[];
49
+ /** The keys of `thinking` that are sent; null drops `thinking` whole. */
50
+ thinking?: string[] | null;
51
+ /** `output_config.effort`, as this provider spells it. */
52
+ effort?: Record<string, string>;
36
53
  }
37
54
 
38
55
  export const SUPPLY_PROVIDERS: Record<SupplyProviderName, SupplyProvider> = {
@@ -51,10 +68,13 @@ export const SUPPLY_PROVIDERS: Record<SupplyProviderName, SupplyProvider> = {
51
68
  openai: {
52
69
  name: "openai",
53
70
  preset: "openai",
54
- format: "openai",
71
+ // The Responses API, not Chat Completions: GPT-6 Astra and GPT-6.1 Sol
72
+ // call tools on Responses alone, GPT-6 Luna on Chat Completions only
73
+ // with reasoning off (OpenAI's model pages, 3 Nov 2026).
74
+ format: "responses",
55
75
  host: "api.openai.com",
56
76
  auth: "bearer",
57
- metered: ["/v1/chat/completions"],
77
+ metered: ["/v1/responses"],
58
78
  free: [{ method: "GET", path: "/v1/models" }],
59
79
  },
60
80
  gemini: {
@@ -79,6 +99,11 @@ export const SUPPLY_PROVIDERS: Record<SupplyProviderName, SupplyProvider> = {
79
99
  auth: "x-api-key",
80
100
  metered: ["/anthropic/v1/messages"],
81
101
  free: [],
102
+ // api-docs.deepseek.com/api/create-message (3 Nov 2026): thinking.type
103
+ // enabled|disabled|adaptive (adaptive = enabled), budget_tokens ignored;
104
+ // effort takes every word ours does (medium and xhigh = high). Context
105
+ // editing and thinking.display are not in its schema.
106
+ send: { drop: ["context_management"], thinking: ["type", "budget_tokens"] },
82
107
  },
83
108
  moonshot: {
84
109
  name: "moonshot",
@@ -88,6 +113,15 @@ export const SUPPLY_PROVIDERS: Record<SupplyProviderName, SupplyProvider> = {
88
113
  auth: "bearer",
89
114
  metered: ["/anthropic/v1/messages"],
90
115
  free: [],
116
+ // platform.kimi.ai/docs/api/messages (3 Nov 2026): the request schema is
117
+ // these fields alone; `thinking` is K2-only (K3.1 Pro always thinks);
118
+ // effort is low | high | max; temperature and top_p are fixed (any
119
+ // other value is an error).
120
+ send: {
121
+ fields: ["model", "messages", "max_tokens", "system", "stream", "stop_sequences", "tools", "tool_choice", "metadata", "cache_control", "output_config"],
122
+ thinking: null,
123
+ effort: { minimal: "low", low: "low", medium: "high", high: "high", xhigh: "high", max: "max" },
124
+ },
91
125
  },
92
126
  };
93
127
 
@@ -151,3 +185,41 @@ export function supplyProviderBlock(provider: SupplyProviderName, tiers: Partial
151
185
  ...(Object.keys(tiers).length ? { models: tiers } : {}),
152
186
  };
153
187
  }
188
+
189
+ /**
190
+ * Reshape a request body for a provider (its `send`), in place. True when
191
+ * anything changed. What a provider's schema does not list is not sent,
192
+ * rather than trusted to be ignored; an effort word it does not spell is
193
+ * sent as the nearest one it does.
194
+ */
195
+ export function shapeRequest(p: SupplyProvider, json: Record<string, unknown>): boolean {
196
+ const shape = p.send;
197
+ if (!shape) return false;
198
+ let changed = false;
199
+ if (shape.fields) {
200
+ for (const k of Object.keys(json)) if (!shape.fields.includes(k)) (delete json[k], (changed = true));
201
+ }
202
+ for (const k of shape.drop ?? []) if (k in json) (delete json[k], (changed = true));
203
+ if (shape.thinking !== undefined && "thinking" in json) {
204
+ if (shape.thinking === null) {
205
+ delete json.thinking;
206
+ changed = true;
207
+ } else if (json.thinking && typeof json.thinking === "object") {
208
+ const t = json.thinking as Record<string, unknown>;
209
+ for (const k of Object.keys(t)) if (!shape.thinking.includes(k)) (delete t[k], (changed = true));
210
+ }
211
+ }
212
+ const oc = json.output_config;
213
+ if (shape.effort && oc && typeof oc === "object" && typeof (oc as Record<string, unknown>).effort === "string") {
214
+ const word = (oc as Record<string, unknown>).effort as string;
215
+ const to = shape.effort[word];
216
+ if (to === undefined) {
217
+ delete (oc as Record<string, unknown>).effort;
218
+ changed = true;
219
+ } else if (to !== word) {
220
+ (oc as Record<string, unknown>).effort = to;
221
+ changed = true;
222
+ }
223
+ }
224
+ return changed;
225
+ }
package/src/providers.ts CHANGED
@@ -436,9 +436,9 @@ export const PROVIDERS: readonly ProviderPreset[] = [
436
436
  note: "base_url is your server (default :8000). Start it with --enable-auto-tool-choice and a --tool-call-parser or no tool loop closes." },
437
437
 
438
438
  // ------------------------------------------- Chat-Completions, translated
439
- { name: "openai", title: "OpenAI", format: "openai", baseUrl: "https://api.openai.com/v1", auth: "bearer", verified: true,
439
+ { name: "openai", title: "OpenAI", format: "responses", baseUrl: "https://api.openai.com/v1", auth: "bearer", verified: true,
440
440
  maxTokensParam: "max_completion_tokens", reasoningEffort: true, promptCacheKey: true,
441
- note: "Reached over Chat Completions, which OpenAI keeps supporting; the Responses API is not spoken here, so a reasoning model's reasoning does not carry across tool calls." , search: "openai" },
441
+ note: "Reached over the Responses API (3 Nov 2026): GPT-6 Astra and GPT-6.1 Sol call tools there alone, GPT-6 Luna on Chat Completions only with reasoning off. `format: openai` still says Chat Completions, for an older model or a proxy that speaks only that." , search: "openai" },
442
442
  { name: "gemini", title: "Google Gemini", format: "openai", baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai", auth: "bearer",
443
443
  note: "Google's OpenAI-compatible route. Unknown parameters are ignored silently; reasoning cannot be switched off on the newest models." },
444
444
  { name: "xai", title: "xAI Grok", format: "openai", baseUrl: "https://api.x.ai/v1", auth: "bearer",