@providerkit/core 0.23.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -7
- package/dist/auth/device.d.ts +3 -2
- package/dist/auth/device.d.ts.map +1 -1
- package/dist/auth/device.js +5 -2
- package/dist/auth/device.js.map +1 -1
- package/dist/auth/flows.d.ts +5 -1
- package/dist/auth/flows.d.ts.map +1 -1
- package/dist/auth/flows.js +237 -0
- package/dist/auth/flows.js.map +1 -1
- package/dist/auth/oauth.d.ts +4 -2
- package/dist/auth/oauth.d.ts.map +1 -1
- package/dist/auth/oauth.js +4 -3
- package/dist/auth/oauth.js.map +1 -1
- package/dist/auth/with-token.d.ts +4 -1
- package/dist/auth/with-token.d.ts.map +1 -1
- package/dist/auth/with-token.js +9 -4
- package/dist/auth/with-token.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +3 -0
- package/dist/errors.js.map +1 -1
- package/dist/gate.d.ts +29 -0
- package/dist/gate.d.ts.map +1 -0
- package/dist/gate.js +96 -0
- package/dist/gate.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/key-pool.d.ts +11 -0
- package/dist/key-pool.d.ts.map +1 -1
- package/dist/key-pool.js +14 -0
- package/dist/key-pool.js.map +1 -1
- package/dist/presets.d.ts +53 -0
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +100 -0
- package/dist/presets.js.map +1 -1
- package/dist/providers/anthropic.d.ts +7 -0
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +3 -1
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/factory.d.ts +36 -0
- package/dist/providers/factory.d.ts.map +1 -1
- package/dist/providers/factory.js +208 -22
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/gemini.d.ts +17 -5
- package/dist/providers/gemini.d.ts.map +1 -1
- package/dist/providers/gemini.js +241 -119
- package/dist/providers/gemini.js.map +1 -1
- package/dist/providers/openai.d.ts +7 -0
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +7 -4
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/responses.d.ts +11 -0
- package/dist/providers/responses.d.ts.map +1 -1
- package/dist/providers/responses.js +3 -1
- package/dist/providers/responses.js.map +1 -1
- package/dist/registry.d.ts +105 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +291 -0
- package/dist/registry.js.map +1 -0
- package/dist/schema.d.ts +27 -9
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +197 -62
- package/dist/schema.js.map +1 -1
- package/dist/tools.d.ts +8 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +2 -2
- package/dist/tools.js.map +1 -1
- package/dist/turn.d.ts +55 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +125 -0
- package/dist/turn.js.map +1 -0
- package/dist/types.d.ts +8 -22
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -45
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/auth/device.ts +8 -4
- package/src/auth/flows.ts +288 -1
- package/src/auth/oauth.ts +8 -3
- package/src/auth/with-token.ts +9 -4
- package/src/errors.ts +3 -0
- package/src/gate.ts +152 -0
- package/src/index.ts +3 -0
- package/src/key-pool.ts +15 -0
- package/src/presets.ts +100 -0
- package/src/providers/anthropic.ts +10 -1
- package/src/providers/factory.ts +288 -34
- package/src/providers/gemini.ts +273 -124
- package/src/providers/openai.ts +15 -4
- package/src/providers/responses.ts +14 -1
- package/src/registry.ts +420 -0
- package/src/schema.ts +200 -72
- package/src/tools.ts +10 -2
- package/src/turn.ts +166 -0
- package/src/types.ts +8 -62
package/dist/registry.js
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
// Providers and credentials, set up once per app.
|
|
2
|
+
//
|
|
3
|
+
// Every app on this package wrote the same block: build each provider from
|
|
4
|
+
// env, wrap it in a watchdog, chain a few into a fallback pool, keep that pool
|
|
5
|
+
// alive so its cooldowns survive, and cache it somewhere. The OpenCode Go
|
|
6
|
+
// chain alone was copied seven times. Where an app put the watchdog or the
|
|
7
|
+
// error envelope together by hand, it got it wrong (AGENTS.md, "A bump is an
|
|
8
|
+
// audit too"). A registry names each connection once, and `get` hands back
|
|
9
|
+
// the composition already assembled.
|
|
10
|
+
//
|
|
11
|
+
// The layers, outside in: the view (per-call effort and `maxTokens`), the
|
|
12
|
+
// fallback pool when there is more than one candidate, then per candidate the
|
|
13
|
+
// gate, the watchdog and the adapter.
|
|
14
|
+
//
|
|
15
|
+
// ponytail: one registry per process. Per-tenant keys would need one registry
|
|
16
|
+
// per tenant, and no app needs that yet.
|
|
17
|
+
import { ProviderError } from "./errors.js";
|
|
18
|
+
import { withFallbackProviders } from "./fallback.js";
|
|
19
|
+
import { createGate, withGate } from "./gate.js";
|
|
20
|
+
import { KeyPool, withKeyPool } from "./key-pool.js";
|
|
21
|
+
import { PROVIDER_PRESETS } from "./presets.js";
|
|
22
|
+
import { presetAdapter } from "./providers/factory.js";
|
|
23
|
+
import { withWatchdog } from "./watchdog.js";
|
|
24
|
+
// A value import from the `auth/` subpath, and a cheap one: with-token.ts
|
|
25
|
+
// imports only errors.ts at runtime and the sign-in flows as types, so the
|
|
26
|
+
// main entry gains these few lines and none of oauth, device or flows.
|
|
27
|
+
import { withToken } from "./auth/with-token.js";
|
|
28
|
+
export function createRegistry(options) {
|
|
29
|
+
const connections = new Map();
|
|
30
|
+
const chainRefs = new Map(Object.entries(options.chains ?? {}));
|
|
31
|
+
/** Built chains by ref, with the connections each one uses. */
|
|
32
|
+
const built = new Map();
|
|
33
|
+
// One store for every chain, so a candidate benched in one is benched in
|
|
34
|
+
// all. Weak, so a candidate dropped by `update` takes its bench with it.
|
|
35
|
+
const cooldowns = new WeakMap();
|
|
36
|
+
const refOf = new WeakMap();
|
|
37
|
+
const { onCooldown, ...fallback } = options.fallback ?? {};
|
|
38
|
+
const poolOptions = {
|
|
39
|
+
...fallback,
|
|
40
|
+
cooldowns,
|
|
41
|
+
...(onCooldown
|
|
42
|
+
? {
|
|
43
|
+
onCooldown: (info) => onCooldown({ ...info, ref: refOf.get(info.candidate) ?? info.candidate.id }),
|
|
44
|
+
}
|
|
45
|
+
: {}),
|
|
46
|
+
};
|
|
47
|
+
for (const [name, refs] of chainRefs) {
|
|
48
|
+
if (!name || name.includes("/")) {
|
|
49
|
+
throw new Error(`[providerkit] Chain name "${name}" can't be empty or contain "/".`);
|
|
50
|
+
}
|
|
51
|
+
if (refs.length === 0)
|
|
52
|
+
throw new Error(`[providerkit] Chain "${name}" lists no refs.`);
|
|
53
|
+
}
|
|
54
|
+
// `open` refuses a connection named like a chain.
|
|
55
|
+
for (const [name, config] of Object.entries(options.connections)) {
|
|
56
|
+
connections.set(name, open(name, config));
|
|
57
|
+
}
|
|
58
|
+
// Checked once every connection exists, so a chain may name any of them.
|
|
59
|
+
for (const name of chainRefs.keys())
|
|
60
|
+
members(name);
|
|
61
|
+
function open(name, config, current) {
|
|
62
|
+
if (!name || name.includes("/")) {
|
|
63
|
+
throw new Error(`[providerkit] Connection name "${name}" can't be empty or contain "/".`);
|
|
64
|
+
}
|
|
65
|
+
if (chainRefs.has(name)) {
|
|
66
|
+
throw new Error(`[providerkit] "${name}" names both a chain and a connection. Rename one of them.`);
|
|
67
|
+
}
|
|
68
|
+
if (!(config.preset in PROVIDER_PRESETS)) {
|
|
69
|
+
throw new Error(`[providerkit] Connection "${name}" names an unknown preset "${config.preset}".`);
|
|
70
|
+
}
|
|
71
|
+
const credentials = [config.apiKey, config.keys, config.token].filter((c) => c !== undefined);
|
|
72
|
+
if (credentials.length !== 1) {
|
|
73
|
+
throw new Error(`[providerkit] Connection "${name}" needs exactly one of apiKey, keys or token. ` +
|
|
74
|
+
`It has ${credentials.length}.`);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
config,
|
|
78
|
+
gate: gateFor(config, current),
|
|
79
|
+
keyPool: config.keys ? new KeyPool(name, config.keys) : undefined,
|
|
80
|
+
candidates: new Map(),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** The (connection, model) pairs a ref names, in order, duplicates dropped. */
|
|
84
|
+
function members(ref) {
|
|
85
|
+
const inChain = chainRefs.get(ref);
|
|
86
|
+
const out = new Map();
|
|
87
|
+
for (const member of inChain ?? [ref]) {
|
|
88
|
+
const slash = member.indexOf("/");
|
|
89
|
+
const name = slash < 0 ? member : member.slice(0, slash);
|
|
90
|
+
if (inChain && chainRefs.has(member)) {
|
|
91
|
+
throw new Error(`[providerkit] Chain "${ref}" names chain "${member}". List its refs instead.`);
|
|
92
|
+
}
|
|
93
|
+
const connection = connections.get(name);
|
|
94
|
+
if (!connection) {
|
|
95
|
+
throw new Error(inChain
|
|
96
|
+
? `[providerkit] Chain "${ref}" names connection "${name}", which doesn't exist.`
|
|
97
|
+
: `[providerkit] "${ref}" is not a chain or a connection. ` +
|
|
98
|
+
`Known: ${[...chainRefs.keys(), ...connections.keys()].join(", ")}.`);
|
|
99
|
+
}
|
|
100
|
+
const models = slash < 0 ? modelsOf(name, connection.config) : [member.slice(slash + 1)];
|
|
101
|
+
for (const model of models) {
|
|
102
|
+
if (!model)
|
|
103
|
+
throw new Error(`[providerkit] "${member}" has an empty model after "/".`);
|
|
104
|
+
const key = `${name}/${model}`;
|
|
105
|
+
if (!out.has(key))
|
|
106
|
+
out.set(key, { name, model });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return [...out.values()];
|
|
110
|
+
}
|
|
111
|
+
/** Get the provider for a ref, building it on first use. */
|
|
112
|
+
function resolve(ref) {
|
|
113
|
+
const cached = built.get(ref);
|
|
114
|
+
if (cached)
|
|
115
|
+
return cached.provider;
|
|
116
|
+
const list = members(ref);
|
|
117
|
+
const candidates = list.map(({ name, model }) => candidate(name, model));
|
|
118
|
+
// A single candidate gets no pool. A pool of one benches the only option:
|
|
119
|
+
// a 503 a retry would absorb in a second becomes 30 s of instant
|
|
120
|
+
// NoAvailableProviderError, and the real kind hides behind `rate`. KeyPool
|
|
121
|
+
// refuses to bench its last key for the same reason.
|
|
122
|
+
const provider = candidates.length === 1 ? candidates[0] : withFallbackProviders(candidates, poolOptions);
|
|
123
|
+
built.set(ref, { provider, uses: new Set(list.map(({ name }) => name)) });
|
|
124
|
+
return provider;
|
|
125
|
+
}
|
|
126
|
+
function candidate(name, model) {
|
|
127
|
+
const connection = connections.get(name);
|
|
128
|
+
const cached = connection.candidates.get(model);
|
|
129
|
+
if (cached)
|
|
130
|
+
return cached;
|
|
131
|
+
const { config, keyPool } = connection;
|
|
132
|
+
const { preset, apiKey: _apiKey, keys: _keys, token: _token, models: _models, maxConcurrent: _maxConcurrent, watchdog: _watchdog, headers, ...rest } = config;
|
|
133
|
+
// One session id per candidate, kept by every adapter a key pool or a
|
|
134
|
+
// token builds for it. A new id per attempt made a sticky gateway treat
|
|
135
|
+
// every call as a new session and miss its prompt cache.
|
|
136
|
+
const base = { ...rest, model, instanceSessionId: crypto.randomUUID() };
|
|
137
|
+
let provider;
|
|
138
|
+
if (config.token) {
|
|
139
|
+
// The credential's host and headers win: Copilot gives each plan its
|
|
140
|
+
// own host, and the Codex backend refuses a call without its account id.
|
|
141
|
+
provider = withToken(config.token, (auth) => presetAdapter(preset, { ...base, ...auth, headers: { ...headers, ...auth.headers } }));
|
|
142
|
+
}
|
|
143
|
+
else if (config.keys) {
|
|
144
|
+
// `open` builds the pool whenever `keys` is set.
|
|
145
|
+
provider = withKeyPool(keyPool, (key) => presetAdapter(preset, { ...base, headers, apiKey: key }));
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
provider = presetAdapter(preset, { ...base, headers, apiKey: config.apiKey });
|
|
149
|
+
}
|
|
150
|
+
// On unless turned off, where `createPresetProvider` adds one only when
|
|
151
|
+
// asked. Handing apps the whole composition is the point of a registry:
|
|
152
|
+
// two apps that wired the watchdog themselves left keep-alives uncounted,
|
|
153
|
+
// so the idle clock would cut a long tool call at 60 s (AGENTS.md, "A bump
|
|
154
|
+
// is an audit too").
|
|
155
|
+
const watchdog = config.watchdog === undefined ? options.watchdog : config.watchdog;
|
|
156
|
+
if (watchdog !== false)
|
|
157
|
+
provider = withWatchdog(provider, watchdog);
|
|
158
|
+
// Outside the watchdog, so a call waiting for a slot spends no deadline.
|
|
159
|
+
if (connection.gate)
|
|
160
|
+
provider = withGate(provider, connection.gate);
|
|
161
|
+
connection.candidates.set(model, provider);
|
|
162
|
+
refOf.set(provider, `${name}/${model}`);
|
|
163
|
+
return provider;
|
|
164
|
+
}
|
|
165
|
+
/** Drop every built chain that uses this connection. */
|
|
166
|
+
function forget(name) {
|
|
167
|
+
for (const [ref, entry] of built)
|
|
168
|
+
if (entry.uses.has(name))
|
|
169
|
+
built.delete(ref);
|
|
170
|
+
}
|
|
171
|
+
function view(ref, viewOpts) {
|
|
172
|
+
return {
|
|
173
|
+
get id() {
|
|
174
|
+
return resolve(ref).id;
|
|
175
|
+
},
|
|
176
|
+
get model() {
|
|
177
|
+
return resolve(ref).model;
|
|
178
|
+
},
|
|
179
|
+
createStream(messages, tools, opts = {}) {
|
|
180
|
+
async function* viewed() {
|
|
181
|
+
// A pool applies a per-call model to its primary only, and a single
|
|
182
|
+
// candidate would post it to a connection picked for another model.
|
|
183
|
+
if (opts.model) {
|
|
184
|
+
throw new ProviderError(ref, "invalid", `${ref}: a registry provider can't take a per-call model. ` +
|
|
185
|
+
`Ask the registry for it instead: get("conn/${opts.model}").`);
|
|
186
|
+
}
|
|
187
|
+
// Looked up per call, so `update` reaches a provider taken at boot.
|
|
188
|
+
const provider = resolve(ref);
|
|
189
|
+
for await (const chunk of provider.createStream(messages, tools, {
|
|
190
|
+
...opts,
|
|
191
|
+
effort: opts.effort ?? viewOpts.effort,
|
|
192
|
+
maxTokens: opts.maxTokens ?? viewOpts.maxTokens,
|
|
193
|
+
})) {
|
|
194
|
+
// A pool names the endpoint that answered; a single candidate is
|
|
195
|
+
// the endpoint, so its chunks get the same field.
|
|
196
|
+
yield chunk.source
|
|
197
|
+
? chunk
|
|
198
|
+
: { ...chunk, source: { provider: provider.id, model: provider.model } };
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return viewed();
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
get(ref, opts = {}) {
|
|
207
|
+
members(ref);
|
|
208
|
+
return view(ref, opts);
|
|
209
|
+
},
|
|
210
|
+
update(name, config) {
|
|
211
|
+
const current = connections.get(name);
|
|
212
|
+
if (current && sameValue(current.config, config))
|
|
213
|
+
return;
|
|
214
|
+
connections.set(name, open(name, config, current));
|
|
215
|
+
forget(name);
|
|
216
|
+
},
|
|
217
|
+
remove(name) {
|
|
218
|
+
connections.delete(name);
|
|
219
|
+
forget(name);
|
|
220
|
+
},
|
|
221
|
+
status() {
|
|
222
|
+
const out = {};
|
|
223
|
+
for (const [name, { gate, keyPool, candidates }] of connections) {
|
|
224
|
+
out[name] = {
|
|
225
|
+
...(gate ? { gate: { max: gate.max, held: gate.held, waiting: gate.waiting } } : {}),
|
|
226
|
+
...(keyPool ? { keys: keyPool.status() } : {}),
|
|
227
|
+
candidates: [...candidates].map(([model, provider]) => {
|
|
228
|
+
const { probe, ...bench } = cooldowns.get(provider) ?? { retryAtMs: 0 };
|
|
229
|
+
return { ref: `${name}/${model}`, ...bench, probing: probe !== undefined };
|
|
230
|
+
}),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
return out;
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function gateFor(config, current) {
|
|
238
|
+
if (config.maxConcurrent === undefined)
|
|
239
|
+
return undefined;
|
|
240
|
+
// Calls in flight hold slots on the current gate. A fresh one with the same
|
|
241
|
+
// limit would let `max` more through beside them.
|
|
242
|
+
if (current?.gate && current.config.maxConcurrent === config.maxConcurrent)
|
|
243
|
+
return current.gate;
|
|
244
|
+
return createGate(config.maxConcurrent);
|
|
245
|
+
}
|
|
246
|
+
/** A bare connection's models: `models`, then `model`, then the preset's
|
|
247
|
+
* rotation, then its default. The order `createPresetProvider` uses. */
|
|
248
|
+
function modelsOf(name, config) {
|
|
249
|
+
const preset = PROVIDER_PRESETS[config.preset];
|
|
250
|
+
if (config.models?.length)
|
|
251
|
+
return config.models;
|
|
252
|
+
if (config.model)
|
|
253
|
+
return [config.model];
|
|
254
|
+
if (preset.rotation?.length)
|
|
255
|
+
return preset.rotation;
|
|
256
|
+
if (preset.defaultModel)
|
|
257
|
+
return [preset.defaultModel];
|
|
258
|
+
throw new Error(`[providerkit] Connection "${name}" names no model, and preset "${config.preset}" has no ` +
|
|
259
|
+
"default. Set model or models.");
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Equality for configs: plain objects and arrays by their contents, functions
|
|
263
|
+
* and every other object by identity. A key set to `undefined` equals a key
|
|
264
|
+
* left out. So an app that re-reads its config on every request rebuilds
|
|
265
|
+
* nothing, as long as it hands back the same `TokenSource`, `fetchImpl` and
|
|
266
|
+
* `onEvict` each time: a new one is a change, even when it does the same.
|
|
267
|
+
*/
|
|
268
|
+
function sameValue(a, b) {
|
|
269
|
+
if (Object.is(a, b))
|
|
270
|
+
return true;
|
|
271
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
272
|
+
return (Array.isArray(a) &&
|
|
273
|
+
Array.isArray(b) &&
|
|
274
|
+
a.length === b.length &&
|
|
275
|
+
a.every((value, i) => sameValue(value, b[i])));
|
|
276
|
+
}
|
|
277
|
+
if (!isPlainObject(a) || !isPlainObject(b))
|
|
278
|
+
return false;
|
|
279
|
+
for (const key of new Set([...Object.keys(a), ...Object.keys(b)])) {
|
|
280
|
+
if (!sameValue(a[key], b[key]))
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
function isPlainObject(value) {
|
|
286
|
+
if (typeof value !== "object" || value === null)
|
|
287
|
+
return false;
|
|
288
|
+
const proto = Object.getPrototypeOf(value);
|
|
289
|
+
return proto === Object.prototype || proto === null;
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,EAAE;AACF,2EAA2E;AAC3E,+EAA+E;AAC/E,0EAA0E;AAC1E,2EAA2E;AAC3E,6EAA6E;AAC7E,2EAA2E;AAC3E,qCAAqC;AACrC,EAAE;AACF,0EAA0E;AAC1E,8EAA8E;AAC9E,sCAAsC;AACtC,EAAE;AACF,8EAA8E;AAC9E,yCAAyC;AACzC,OAAO,EAAE,aAAa,EAAkB,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAuC,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,WAAW,EAAqC,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAA8C,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,aAAa,EAA4B,MAAM,wBAAwB,CAAC;AAGjF,OAAO,EAAE,YAAY,EAAwB,MAAM,eAAe,CAAC;AACnE,0EAA0E;AAC1E,2EAA2E;AAC3E,uEAAuE;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAuGjD,MAAM,UAAU,cAAc,CAAC,OAAwB;IACrD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;IAClD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;IAChE,+DAA+D;IAC/D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAqD,CAAC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ChB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YAChB,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;YACrB,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC9C,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACzD,KAAK,MAAM,GAAG,IAAI,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IAC/C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,KAAK,GAAY,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC"}
|
package/dist/schema.d.ts
CHANGED
|
@@ -46,18 +46,36 @@ export declare function isStrictSchema(node: unknown): boolean;
|
|
|
46
46
|
*/
|
|
47
47
|
export declare function withoutPatterns(node: unknown): unknown;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* A JSON Schema for Gemini's `parametersJsonSchema` and `responseJsonSchema`, which take
|
|
50
|
+
* standard JSON Schema. It is sent as written except for the four shapes the API refuses.
|
|
51
|
+
* Measured on `gemini-3.8-flash` on 2026-10-21, in a tool and as a response schema alike;
|
|
52
|
+
* every other keyword tried (`$ref`, `$defs`, `oneOf`, `allOf`, `not`, `if`, `const`, numeric
|
|
53
|
+
* `enum`, `type: [..., "null"]`, `patternProperties`, `additionalProperties`, arrays without
|
|
54
|
+
* `items`) came back accepted:
|
|
50
55
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* -
|
|
54
|
-
*
|
|
55
|
-
* -
|
|
56
|
-
*
|
|
57
|
-
* -
|
|
58
|
-
*
|
|
56
|
+
* - `required` names a property that is not declared, at any depth: 400 "requires unspecified
|
|
57
|
+
* property". The names with no property are dropped.
|
|
58
|
+
* - Draft-04 `exclusiveMinimum: true` (or `false`): 400 "must be a number". It becomes the
|
|
59
|
+
* number form, `exclusiveMinimum: <minimum>`, and `minimum` goes.
|
|
60
|
+
* - A tuple, `items: [a, b]`: 400 "must be a boolean or an object". It becomes `prefixItems`,
|
|
61
|
+
* and `additionalItems` becomes `items`, as in 2020-12.
|
|
62
|
+
* - A recursive `$ref` that is not behind an optional property or an array that may be empty:
|
|
63
|
+
* 400 "ref loops are only supported if ...". The self-reference becomes `{}`.
|
|
64
|
+
*
|
|
65
|
+
* This replaced a sanitizer written for the older `parameters` field, which accepts a small
|
|
66
|
+
* OpenAPI subset. Kept on `parametersJsonSchema`, it turned a numeric enum into a string enum
|
|
67
|
+
* (the model then sent `"2"` for `2`), forced string items onto an array of anything, and
|
|
68
|
+
* dropped every `$ref`, while still sending the 400s above.
|
|
59
69
|
*/
|
|
60
70
|
export declare function toGeminiToolSchema(node: unknown): Record<string, unknown>;
|
|
71
|
+
/**
|
|
72
|
+
* Sanitize a JSON Schema to the OpenAPI 3.0 subset Google's Cloud Code Assist
|
|
73
|
+
* (`antigravity`) accepts in its `parameters` field (`type`, `nullable`,
|
|
74
|
+
* `description`, `format`, `enum`, `properties`, `items`, `required`, `anyOf`).
|
|
75
|
+
* Mirrors cc-proxy's `clean_json_schema`, including the `{ type: "string" }`
|
|
76
|
+
* fallback when an array omits `items`.
|
|
77
|
+
*/
|
|
78
|
+
export declare function toAntigravityToolSchema(node: unknown): Record<string, unknown>;
|
|
61
79
|
/**
|
|
62
80
|
* Sanitize a tool's JSON Schema for Anthropic's Messages API.
|
|
63
81
|
*
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAgBA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAkDpE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAWpD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAmBrD;AAoBD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAgBA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAkDpE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAWpD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAmBrD;AAoBD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAKtD;AAmCD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgBzE;AA+DD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiF9E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAwC5E"}
|