@genesislcap/foundation-ai 14.495.0 → 14.496.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/dts/ai-provider-di.d.ts +136 -0
- package/dist/dts/ai-provider-di.d.ts.map +1 -0
- package/dist/dts/ai-provider.d.ts +1 -112
- package/dist/dts/ai-provider.d.ts.map +1 -1
- package/dist/dts/index.d.ts +5 -3
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/transports/anthropic-transport.d.ts.map +1 -1
- package/dist/dts/transports/gemini-transport.d.ts.map +1 -1
- package/dist/dts/types/chat.types.d.ts +34 -0
- package/dist/dts/types/chat.types.d.ts.map +1 -1
- package/dist/dts/types/config.types.d.ts +1 -1
- package/dist/dts/types/config.types.d.ts.map +1 -1
- package/dist/esm/ai-provider-di.js +84 -0
- package/dist/esm/ai-provider.js +0 -83
- package/dist/esm/index.js +6 -1
- package/dist/esm/transports/anthropic-transport.js +99 -31
- package/dist/esm/transports/gemini-transport.js +12 -1
- package/dist/esm/types/config.types.js +2 -0
- package/dist/foundation-ai.api.json +137 -6
- package/dist/foundation-ai.d.ts +36 -1
- package/package.json +11 -11
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { type Container } from '@microsoft/fast-foundation';
|
|
2
|
+
import { MutableAIProviderRegistry } from './ai-provider';
|
|
3
|
+
import type { AIProvider, AIProviderRegistryStatusEntry } from './ai-provider';
|
|
4
|
+
import type { AIStatus } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* AI provider registry contract + FAST dependency-injection wiring.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* This module is deliberately the **only** one that imports `@microsoft/fast-foundation`
|
|
10
|
+
* (`DI` / `Registration` / `Container`). `@microsoft/fast-foundation` transitively pulls
|
|
11
|
+
* `@microsoft/fast-element`, which touches `document` at module-eval — fatal in a non-browser
|
|
12
|
+
* (Node / headless) context. Keeping the DI token + registration helpers here — and out of
|
|
13
|
+
* `ai-provider.ts` (the registry classes, guards, and `createAIProvider`/`resolveAIConfig` that
|
|
14
|
+
* `ChatDriver` depends on) — means a headless consumer that never registers providers via the
|
|
15
|
+
* container can load the driver stack in bare Node; the FAST import is tree-shaken out. Hosts that
|
|
16
|
+
* *do* use FAST DI import these helpers explicitly.
|
|
17
|
+
*
|
|
18
|
+
* The {@link AIProviderRegistry} **interface** lives here too (rather than in `ai-provider.ts`) so
|
|
19
|
+
* it can share its name with the DI **token** below via TypeScript's interface/const declaration
|
|
20
|
+
* merge — that merge only works within a single module. `ai-provider.ts` imports it as a
|
|
21
|
+
* type-only symbol (erased at runtime, so it never pulls this module's FAST import).
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Registry of named AI providers. Replaces the single-provider DI token —
|
|
27
|
+
* hosts register one or more named providers and consumers can either ask
|
|
28
|
+
* for the default or resolve a specific provider by name.
|
|
29
|
+
*
|
|
30
|
+
* If no host registration happens, the DI container resolves a built-in
|
|
31
|
+
* empty registry — every lookup returns a no-op provider.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Register from app bootstrap with the {@link registerAIProviders} helper:
|
|
35
|
+
* ```ts
|
|
36
|
+
* registerAIProviders(container, { openai: provider });
|
|
37
|
+
* // or, for multi-provider:
|
|
38
|
+
* registerAIProviders(container, { openai, anthropic }, { default: 'openai' });
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @beta
|
|
42
|
+
*/
|
|
43
|
+
export interface AIProviderRegistry {
|
|
44
|
+
/** Look up a registered provider by name. Returns `undefined` if no such name is registered. */
|
|
45
|
+
get(name: string): AIProvider | undefined;
|
|
46
|
+
/** The default provider — used when an agent doesn't specify one. */
|
|
47
|
+
default(): AIProvider;
|
|
48
|
+
/** Name of the default provider. Useful for status display. */
|
|
49
|
+
defaultName(): string;
|
|
50
|
+
/** All registered provider names, in registration order. */
|
|
51
|
+
names(): string[];
|
|
52
|
+
/**
|
|
53
|
+
* Returns the status payload for a single named provider, or for the
|
|
54
|
+
* default when `name` is omitted. Returns `null` when the provider doesn't
|
|
55
|
+
* implement {@link AIProvider.getStatus} or returns null.
|
|
56
|
+
*/
|
|
57
|
+
getStatus(name?: string): Promise<AIStatus | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Returns statuses for all registered providers in registration order.
|
|
60
|
+
* Each entry carries the registered name and an `isDefault` flag.
|
|
61
|
+
*/
|
|
62
|
+
listStatuses(): Promise<AIProviderRegistryStatusEntry[]>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The DI token for the {@link (AIProviderRegistry:interface)}. When no host
|
|
66
|
+
* registers a concrete registry, the container resolves the built-in empty
|
|
67
|
+
* registry (a single no-op provider) so consumers degrade to inert rather
|
|
68
|
+
* than throwing.
|
|
69
|
+
*
|
|
70
|
+
* Prefer the {@link registerAIProviders} helper over registering this token
|
|
71
|
+
* directly.
|
|
72
|
+
*
|
|
73
|
+
* @beta
|
|
74
|
+
*/
|
|
75
|
+
export declare const AIProviderRegistry: import("@microsoft/fast-foundation").InterfaceSymbol<AIProviderRegistry>;
|
|
76
|
+
/**
|
|
77
|
+
* Options for {@link registerAIProviders}.
|
|
78
|
+
*
|
|
79
|
+
* @beta
|
|
80
|
+
*/
|
|
81
|
+
export interface RegisterAIProvidersOptions {
|
|
82
|
+
/**
|
|
83
|
+
* Name of the provider to use as the default — must be a key in the
|
|
84
|
+
* `providers` map. Required when more than one provider is registered;
|
|
85
|
+
* inferred when exactly one is registered.
|
|
86
|
+
*/
|
|
87
|
+
default?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Registers one or more named AI providers as an {@link (AIProviderRegistry:interface)}
|
|
91
|
+
* on the given DI container.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* - With a single provider, the default is inferred — `options.default` may be omitted.
|
|
95
|
+
* - With multiple providers, `options.default` is required to avoid implicit ordering.
|
|
96
|
+
* - Throws when `providers` is empty, when the named default isn't present, or
|
|
97
|
+
* when multiple providers are passed without an explicit default.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* // Single provider — default inferred
|
|
102
|
+
* registerAIProviders(container, { openai: createAIProvider(openAiConfig) });
|
|
103
|
+
*
|
|
104
|
+
* // Multiple providers — explicit default
|
|
105
|
+
* registerAIProviders(
|
|
106
|
+
* container,
|
|
107
|
+
* { fast: chromeProvider, deep: anthropicProvider },
|
|
108
|
+
* { default: 'deep' },
|
|
109
|
+
* );
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @returns the constructed {@link MutableAIProviderRegistry}, so a host that
|
|
113
|
+
* wants to switch providers at runtime can keep the handle and call
|
|
114
|
+
* {@link MutableAIProviderRegistry.set | set} /
|
|
115
|
+
* {@link MutableAIProviderRegistry.setDefault | setDefault} /
|
|
116
|
+
* {@link MutableAIProviderRegistry.update | update} on it later. Callers that
|
|
117
|
+
* register once and never switch can ignore the return value.
|
|
118
|
+
*
|
|
119
|
+
* @beta
|
|
120
|
+
*/
|
|
121
|
+
export declare function registerAIProviders(container: Container, providers: Record<string, AIProvider>, options?: RegisterAIProvidersOptions): MutableAIProviderRegistry;
|
|
122
|
+
/**
|
|
123
|
+
* Registers a host-supplied {@link (AIProviderRegistry:interface)} instance on
|
|
124
|
+
* the DI container under the {@link (AIProviderRegistry:variable)} token.
|
|
125
|
+
*
|
|
126
|
+
* @remarks
|
|
127
|
+
* A thin wrapper over FAST's `Registration.instance` so a host can register its
|
|
128
|
+
* own pre-built registry — typically a {@link MutableAIProviderRegistry} it
|
|
129
|
+
* owns and mutates for runtime provider switching — **without importing FAST
|
|
130
|
+
* primitives** itself. {@link registerAIProviders} delegates to this; reach for
|
|
131
|
+
* it directly when you construct the registry yourself.
|
|
132
|
+
*
|
|
133
|
+
* @beta
|
|
134
|
+
*/
|
|
135
|
+
export declare function registerAIProviderRegistry(container: Container, registry: AIProviderRegistry): void;
|
|
136
|
+
//# sourceMappingURL=ai-provider-di.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-provider-di.d.ts","sourceRoot":"","sources":["../../src/ai-provider-di.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAA2B,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,KAAK,EAAE,UAAU,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,kBAAkB;IACjC,gGAAgG;IAChG,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAC1C,qEAAqE;IACrE,OAAO,IAAI,UAAU,CAAC;IACtB,+DAA+D;IAC/D,WAAW,IAAI,MAAM,CAAC;IACtB,4DAA4D;IAC5D,KAAK,IAAI,MAAM,EAAE,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IACnD;;;OAGG;IACH,YAAY,IAAI,OAAO,CAAC,6BAA6B,EAAE,CAAC,CAAC;CAC1D;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,0EAE9B,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACrC,OAAO,GAAE,0BAA+B,GACvC,yBAAyB,CAyB3B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,kBAAkB,GAC3B,IAAI,CAEN"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AIProviderRegistry } from './ai-provider-di';
|
|
2
2
|
import type { CriteriaInterpretContext } from './interactions';
|
|
3
3
|
import { type AIConfig, type AIStatus, type CriteriaInterpretationResult } from './types';
|
|
4
4
|
import type { ChatMessage, ChatRequestOptions, ChatStreamChunk } from './types/chat.types';
|
|
@@ -93,45 +93,6 @@ export interface AIProviderRegistryStatusEntry {
|
|
|
93
93
|
/** The provider's `getStatus()` result, or `null` if unavailable. */
|
|
94
94
|
status: AIStatus | null;
|
|
95
95
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Registry of named AI providers. Replaces the single-provider DI token —
|
|
98
|
-
* hosts register one or more named providers and consumers can either ask
|
|
99
|
-
* for the default or resolve a specific provider by name.
|
|
100
|
-
*
|
|
101
|
-
* If no host registration happens, the DI container resolves a built-in
|
|
102
|
-
* empty registry — every lookup returns a no-op provider.
|
|
103
|
-
*
|
|
104
|
-
* @remarks
|
|
105
|
-
* Register from app bootstrap with the {@link registerAIProviders} helper:
|
|
106
|
-
* ```ts
|
|
107
|
-
* registerAIProviders(container, { openai: provider });
|
|
108
|
-
* // or, for multi-provider:
|
|
109
|
-
* registerAIProviders(container, { openai, anthropic }, { default: 'openai' });
|
|
110
|
-
* ```
|
|
111
|
-
*
|
|
112
|
-
* @beta
|
|
113
|
-
*/
|
|
114
|
-
export interface AIProviderRegistry {
|
|
115
|
-
/** Look up a registered provider by name. Returns `undefined` if no such name is registered. */
|
|
116
|
-
get(name: string): AIProvider | undefined;
|
|
117
|
-
/** The default provider — used when an agent doesn't specify one. */
|
|
118
|
-
default(): AIProvider;
|
|
119
|
-
/** Name of the default provider. Useful for status display. */
|
|
120
|
-
defaultName(): string;
|
|
121
|
-
/** All registered provider names, in registration order. */
|
|
122
|
-
names(): string[];
|
|
123
|
-
/**
|
|
124
|
-
* Returns the status payload for a single named provider, or for the
|
|
125
|
-
* default when `name` is omitted. Returns `null` when the provider doesn't
|
|
126
|
-
* implement {@link AIProvider.getStatus} or returns null.
|
|
127
|
-
*/
|
|
128
|
-
getStatus(name?: string): Promise<AIStatus | null>;
|
|
129
|
-
/**
|
|
130
|
-
* Returns statuses for all registered providers in registration order.
|
|
131
|
-
* Each entry carries the registered name and an `isDefault` flag.
|
|
132
|
-
*/
|
|
133
|
-
listStatuses(): Promise<AIProviderRegistryStatusEntry[]>;
|
|
134
|
-
}
|
|
135
96
|
/**
|
|
136
97
|
* Optional capability layered onto {@link (AIProviderRegistry:interface)}: a
|
|
137
98
|
* registry whose provider mapping and default can change at runtime, and that
|
|
@@ -243,76 +204,4 @@ export declare class MutableAIProviderRegistry implements ObservableAIProviderRe
|
|
|
243
204
|
*/
|
|
244
205
|
private notify;
|
|
245
206
|
}
|
|
246
|
-
/**
|
|
247
|
-
* The DI token for the {@link (AIProviderRegistry:interface)}. When no host
|
|
248
|
-
* registers a concrete registry, the container resolves the built-in empty
|
|
249
|
-
* registry (a single no-op provider) so consumers degrade to inert rather
|
|
250
|
-
* than throwing.
|
|
251
|
-
*
|
|
252
|
-
* Prefer the {@link registerAIProviders} helper over registering this token
|
|
253
|
-
* directly.
|
|
254
|
-
*
|
|
255
|
-
* @beta
|
|
256
|
-
*/
|
|
257
|
-
export declare const AIProviderRegistry: import("@microsoft/fast-foundation").InterfaceSymbol<AIProviderRegistry>;
|
|
258
|
-
/**
|
|
259
|
-
* Options for {@link registerAIProviders}.
|
|
260
|
-
*
|
|
261
|
-
* @beta
|
|
262
|
-
*/
|
|
263
|
-
export interface RegisterAIProvidersOptions {
|
|
264
|
-
/**
|
|
265
|
-
* Name of the provider to use as the default — must be a key in the
|
|
266
|
-
* `providers` map. Required when more than one provider is registered;
|
|
267
|
-
* inferred when exactly one is registered.
|
|
268
|
-
*/
|
|
269
|
-
default?: string;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Registers one or more named AI providers as an {@link (AIProviderRegistry:interface)}
|
|
273
|
-
* on the given DI container.
|
|
274
|
-
*
|
|
275
|
-
* @remarks
|
|
276
|
-
* - With a single provider, the default is inferred — `options.default` may be omitted.
|
|
277
|
-
* - With multiple providers, `options.default` is required to avoid implicit ordering.
|
|
278
|
-
* - Throws when `providers` is empty, when the named default isn't present, or
|
|
279
|
-
* when multiple providers are passed without an explicit default.
|
|
280
|
-
*
|
|
281
|
-
* @example
|
|
282
|
-
* ```ts
|
|
283
|
-
* // Single provider — default inferred
|
|
284
|
-
* registerAIProviders(container, { openai: createAIProvider(openAiConfig) });
|
|
285
|
-
*
|
|
286
|
-
* // Multiple providers — explicit default
|
|
287
|
-
* registerAIProviders(
|
|
288
|
-
* container,
|
|
289
|
-
* { fast: chromeProvider, deep: anthropicProvider },
|
|
290
|
-
* { default: 'deep' },
|
|
291
|
-
* );
|
|
292
|
-
* ```
|
|
293
|
-
*
|
|
294
|
-
* @returns the constructed {@link MutableAIProviderRegistry}, so a host that
|
|
295
|
-
* wants to switch providers at runtime can keep the handle and call
|
|
296
|
-
* {@link MutableAIProviderRegistry.set | set} /
|
|
297
|
-
* {@link MutableAIProviderRegistry.setDefault | setDefault} /
|
|
298
|
-
* {@link MutableAIProviderRegistry.update | update} on it later. Callers that
|
|
299
|
-
* register once and never switch can ignore the return value.
|
|
300
|
-
*
|
|
301
|
-
* @beta
|
|
302
|
-
*/
|
|
303
|
-
export declare function registerAIProviders(container: Container, providers: Record<string, AIProvider>, options?: RegisterAIProvidersOptions): MutableAIProviderRegistry;
|
|
304
|
-
/**
|
|
305
|
-
* Registers a host-supplied {@link (AIProviderRegistry:interface)} instance on
|
|
306
|
-
* the DI container under the {@link (AIProviderRegistry:variable)} token.
|
|
307
|
-
*
|
|
308
|
-
* @remarks
|
|
309
|
-
* A thin wrapper over FAST's `Registration.instance` so a host can register its
|
|
310
|
-
* own pre-built registry — typically a {@link MutableAIProviderRegistry} it
|
|
311
|
-
* owns and mutates for runtime provider switching — **without importing FAST
|
|
312
|
-
* primitives** itself. {@link registerAIProviders} delegates to this; reach for
|
|
313
|
-
* it directly when you construct the registry yourself.
|
|
314
|
-
*
|
|
315
|
-
* @beta
|
|
316
|
-
*/
|
|
317
|
-
export declare function registerAIProviderRegistry(container: Container, registry: AIProviderRegistry): void;
|
|
318
207
|
//# sourceMappingURL=ai-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-provider.d.ts","sourceRoot":"","sources":["../../src/ai-provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ai-provider.d.ts","sourceRoot":"","sources":["../../src/ai-provider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAU/D,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,QAAQ,EAIb,KAAK,4BAA4B,EAIlC,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAI3F;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,iBAAiB,CAAC,CAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CAAC;IAEhD;;OAEG;IACH,SAAS,CAAC,IAAI,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAEvC;;;OAGG;IACH,eAAe,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC;;;;;;OAMG;IACH,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,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,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAC/D,OAAO,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAO,GACjC,IAAI;IASP,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAO3C;;;;OAIG;IACH,OAAO,CAAC,MAAM;CAGf"}
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type { AIProvider, AIProviderRegistryStatusEntry, ObservableAIProviderRegistry,
|
|
1
|
+
export { createAIProvider, isObservableAIProviderRegistry, MutableAIProviderRegistry, resolveAIConfig, } from './ai-provider';
|
|
2
|
+
export type { AIProvider, AIProviderRegistryStatusEntry, ObservableAIProviderRegistry, } from './ai-provider';
|
|
3
|
+
export { AIProviderRegistry, registerAIProviderRegistry, registerAIProviders, } from './ai-provider-di';
|
|
4
|
+
export type { RegisterAIProvidersOptions } from './ai-provider-di';
|
|
3
5
|
export { AnthropicProvider } from './providers/anthropic-provider';
|
|
4
6
|
export { GeminiProvider } from './providers/gemini-provider';
|
|
5
7
|
export { AnthropicTransport, ResponseTruncatedError } from './transports/anthropic-transport';
|
|
@@ -8,7 +10,7 @@ export { AI_FEATURE_FLAG, isAIFeatureEnabled } from './utils/feature-flags';
|
|
|
8
10
|
export { ChatTemperature } from './utils/temperature';
|
|
9
11
|
export { SUPPORTED_ANTHROPIC_MODEL_IDS, SUPPORTED_GEMINI_MODEL_IDS } from './types';
|
|
10
12
|
export type { AIConfig, AIStatus, AIProviderType, AnthropicAIConfig, AnthropicModelId, ChromeAIConfig, ChromeAvailability, GeminiAIConfig, GeminiModelId, ServerAIConfig, } from './types';
|
|
11
|
-
export type { AgentPickerMode, ChatAgentConfig, ChatAgentPickerConfig, ChatAnimationsConfig, ChatAttachment, ChatConfig, ChatCostHistoryConfig, ChatDriverResult, ChatInputDuringExecutionMode, CachePolicy, ChatMessage, ChatInteraction, ChatRequestOptions, ChatResponseMeta, ChatRole, ChatStreamChunk, ChatToolCall, ChatToolCallUnknown, ChatToolChoice, ChatToolDefinition, ChatToolHandlers, ChatToolResult, ChatUiConfig, CondensePolicy, CondenseResult, CondenseTrigger, ChatSuggestionsConfig, InteractionPresentation, InteractionRequestOptions, InteractionResult, MessageCompaction, ModelTagAppearance, SubAgentFailureReason, SubAgentRequestOptions, TurnFailureReason, } from './types/chat.types';
|
|
13
|
+
export type { AgentPickerMode, ChatAgentConfig, ChatAgentPickerConfig, ChatAnimationsConfig, ChatAttachment, ChatConfig, ChatCostHistoryConfig, ChatDriverResult, ChatFallback, ChatInputDuringExecutionMode, CachePolicy, ChatMessage, ChatInteraction, ChatRequestOptions, ChatResponseMeta, ChatRole, ChatStreamChunk, ChatToolCall, ChatToolCallUnknown, ChatToolChoice, ChatToolDefinition, ChatToolHandlers, ChatToolResult, ChatUiConfig, CondensePolicy, CondenseResult, CondenseTrigger, ChatSuggestionsConfig, InteractionPresentation, InteractionRequestOptions, InteractionResult, MessageCompaction, ModelTagAppearance, SubAgentFailureReason, SubAgentRequestOptions, TurnFailureReason, } from './types/chat.types';
|
|
12
14
|
export { isChatToolCallUnknown } from './types/chat.types';
|
|
13
15
|
export type { ChatTransport } from './types/chat-transport.types';
|
|
14
16
|
export type { CostReportingTransport } from './types/transports.types';
|
package/dist/dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,8BAA8B,EAC9B,yBAAyB,EACzB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,UAAU,EACV,6BAA6B,EAC7B,4BAA4B,GAC7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AAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,YAAY,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC1E,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-transport.d.ts","sourceRoot":"","sources":["../../../src/transports/anthropic-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC7B,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAGV,WAAW,EACX,kBAAkB,EAGnB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"anthropic-transport.d.ts","sourceRoot":"","sources":["../../../src/transports/anthropic-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC7B,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAGV,WAAW,EACX,kBAAkB,EAGnB,MAAM,qBAAqB,CAAC;AAmJ7B,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,OAAO,CAAC,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CAIxC;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAQ;YAEjC,IAAI;IAgBlB,OAAO,CAAC,eAAe;CAexB"}
|
|
@@ -769,6 +769,40 @@ export interface ChatRequestOptions {
|
|
|
769
769
|
* @beta
|
|
770
770
|
*/
|
|
771
771
|
tailContext?: string;
|
|
772
|
+
/**
|
|
773
|
+
* Provider-neutral refusal-fallback chain: if the model declines the request
|
|
774
|
+
* (`stop_reason: 'refusal'`, e.g. Fable 5 safety classifiers), the provider re-runs the
|
|
775
|
+
* same request on the next listed model and returns its answer. Ordered most- to
|
|
776
|
+
* least-preferred; each entry may cap its own `maxTokens`. Providers that support it
|
|
777
|
+
* apply it server-side (Anthropic: `fallbacks` + the `server-side-fallback` beta); others
|
|
778
|
+
* ignore it. Typical use: Fable 5 with an Opus 4.8 fallback.
|
|
779
|
+
*
|
|
780
|
+
* @beta
|
|
781
|
+
*/
|
|
782
|
+
fallbacks?: ChatFallback[];
|
|
783
|
+
/**
|
|
784
|
+
* Structured-output schema (JSON Schema) for this turn. When set, the model's final (non-tool)
|
|
785
|
+
* answer is constrained to it instead of free text. Composes with `tools` — the model may still
|
|
786
|
+
* call tools this turn, then conform its closing answer to the schema. Providers apply it
|
|
787
|
+
* natively where the model supports it (Anthropic `output_config.format`, Gemini JSON mode) and
|
|
788
|
+
* drop it otherwise (caller keeps a prompt-instruction + validator fallback). Keep to the
|
|
789
|
+
* portable JSON-Schema subset providers share (`additionalProperties: false`, explicit
|
|
790
|
+
* `required`, enums, `anyOf` for nullables — no numeric/string constraints or recursion).
|
|
791
|
+
*
|
|
792
|
+
* @beta
|
|
793
|
+
*/
|
|
794
|
+
responseSchema?: object;
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* One entry in a {@link ChatRequestOptions.fallbacks} chain.
|
|
798
|
+
*
|
|
799
|
+
* @beta
|
|
800
|
+
*/
|
|
801
|
+
export interface ChatFallback {
|
|
802
|
+
/** Model id to fall back to (e.g. `'claude-opus-4-8'`). */
|
|
803
|
+
model: string;
|
|
804
|
+
/** Optional per-hop `max_tokens` cap for this fallback attempt. */
|
|
805
|
+
maxTokens?: number;
|
|
772
806
|
}
|
|
773
807
|
/**
|
|
774
808
|
* Why a driver turn ended in failure — the typed taxonomy the tool loop already
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.types.d.ts","sourceRoot":"","sources":["../../../src/types/chat.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,MAAM,GACN,cAAc,GACd,gBAAgB,GAChB,mBAAmB,CAAC;AAExB;;;;GAIG;AACH,KAAK,gBAAgB,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;CAC/B,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,GAAG;IACnD,OAAO,EAAE,IAAI,CAAC;IACd,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAElE;;;;GAIG;AACH,wBAA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,CAAC;CAChB,GACD;IACE;;;OAGG;IACH,QAAQ,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -17,7 +17,7 @@ export declare const SUPPORTED_GEMINI_MODEL_IDS: readonly GeminiModelId[];
|
|
|
17
17
|
*
|
|
18
18
|
* @beta
|
|
19
19
|
*/
|
|
20
|
-
export type AnthropicModelId = 'claude-opus-4-7' | 'claude-sonnet-5' | 'claude-sonnet-4-6' | 'claude-haiku-4-5-20251001';
|
|
20
|
+
export type AnthropicModelId = 'claude-fable-5' | 'claude-opus-4-8' | 'claude-opus-4-7' | 'claude-sonnet-5' | 'claude-sonnet-4-6' | 'claude-haiku-4-5-20251001';
|
|
21
21
|
/** @beta */
|
|
22
22
|
export declare const SUPPORTED_ANTHROPIC_MODEL_IDS: readonly AnthropicModelId[];
|
|
23
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.types.d.ts","sourceRoot":"","sources":["../../../src/types/config.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAC;AAEnF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,gBAAgB,GAChB,kBAAkB,GAClB,uBAAuB,GACvB,kBAAkB,GAClB,uBAAuB,GAEvB,wBAAwB,CAAC;AAE7B,YAAY;AACZ,eAAO,MAAM,0BAA0B,EAAE,SAAS,aAAa,EAOrD,CAAC;AAEX;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,2BAA2B,CAAC;AAEhC,YAAY;AACZ,eAAO,MAAM,6BAA6B,EAAE,SAAS,gBAAgB,
|
|
1
|
+
{"version":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ACtD,YAAY,EAAE,QAAQ,CAAC;IACvB,4GAA4G;IAC5G,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,YAAY,EAAE,WAAW,CAAC;IAC1B,mHAAmH;IACnH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,cAAc,GAAG,cAAc,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { DI, Registration } from '@microsoft/fast-foundation';
|
|
2
|
+
import { EmptyAIProviderRegistry, MutableAIProviderRegistry } from './ai-provider';
|
|
3
|
+
/**
|
|
4
|
+
* The DI token for the {@link (AIProviderRegistry:interface)}. When no host
|
|
5
|
+
* registers a concrete registry, the container resolves the built-in empty
|
|
6
|
+
* registry (a single no-op provider) so consumers degrade to inert rather
|
|
7
|
+
* than throwing.
|
|
8
|
+
*
|
|
9
|
+
* Prefer the {@link registerAIProviders} helper over registering this token
|
|
10
|
+
* directly.
|
|
11
|
+
*
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
export const AIProviderRegistry = DI.createInterface((x) => x.singleton(EmptyAIProviderRegistry));
|
|
15
|
+
/**
|
|
16
|
+
* Registers one or more named AI providers as an {@link (AIProviderRegistry:interface)}
|
|
17
|
+
* on the given DI container.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* - With a single provider, the default is inferred — `options.default` may be omitted.
|
|
21
|
+
* - With multiple providers, `options.default` is required to avoid implicit ordering.
|
|
22
|
+
* - Throws when `providers` is empty, when the named default isn't present, or
|
|
23
|
+
* when multiple providers are passed without an explicit default.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* // Single provider — default inferred
|
|
28
|
+
* registerAIProviders(container, { openai: createAIProvider(openAiConfig) });
|
|
29
|
+
*
|
|
30
|
+
* // Multiple providers — explicit default
|
|
31
|
+
* registerAIProviders(
|
|
32
|
+
* container,
|
|
33
|
+
* { fast: chromeProvider, deep: anthropicProvider },
|
|
34
|
+
* { default: 'deep' },
|
|
35
|
+
* );
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @returns the constructed {@link MutableAIProviderRegistry}, so a host that
|
|
39
|
+
* wants to switch providers at runtime can keep the handle and call
|
|
40
|
+
* {@link MutableAIProviderRegistry.set | set} /
|
|
41
|
+
* {@link MutableAIProviderRegistry.setDefault | setDefault} /
|
|
42
|
+
* {@link MutableAIProviderRegistry.update | update} on it later. Callers that
|
|
43
|
+
* register once and never switch can ignore the return value.
|
|
44
|
+
*
|
|
45
|
+
* @beta
|
|
46
|
+
*/
|
|
47
|
+
export function registerAIProviders(container, providers, options = {}) {
|
|
48
|
+
const entries = Object.entries(providers);
|
|
49
|
+
if (entries.length === 0) {
|
|
50
|
+
throw new Error('registerAIProviders: at least one provider is required.');
|
|
51
|
+
}
|
|
52
|
+
let defaultName;
|
|
53
|
+
if (options.default !== undefined) {
|
|
54
|
+
if (!Object.prototype.hasOwnProperty.call(providers, options.default)) {
|
|
55
|
+
throw new Error(`registerAIProviders: default "${options.default}" is not one of the registered providers (${entries.map(([k]) => k).join(', ')}).`);
|
|
56
|
+
}
|
|
57
|
+
defaultName = options.default;
|
|
58
|
+
}
|
|
59
|
+
else if (entries.length === 1) {
|
|
60
|
+
defaultName = entries[0][0];
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new Error(`registerAIProviders: multiple providers registered (${entries.map(([k]) => k).join(', ')}) — must specify { default } to disambiguate.`);
|
|
64
|
+
}
|
|
65
|
+
const registry = new MutableAIProviderRegistry(new Map(entries), defaultName);
|
|
66
|
+
registerAIProviderRegistry(container, registry);
|
|
67
|
+
return registry;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Registers a host-supplied {@link (AIProviderRegistry:interface)} instance on
|
|
71
|
+
* the DI container under the {@link (AIProviderRegistry:variable)} token.
|
|
72
|
+
*
|
|
73
|
+
* @remarks
|
|
74
|
+
* A thin wrapper over FAST's `Registration.instance` so a host can register its
|
|
75
|
+
* own pre-built registry — typically a {@link MutableAIProviderRegistry} it
|
|
76
|
+
* owns and mutates for runtime provider switching — **without importing FAST
|
|
77
|
+
* primitives** itself. {@link registerAIProviders} delegates to this; reach for
|
|
78
|
+
* it directly when you construct the registry yourself.
|
|
79
|
+
*
|
|
80
|
+
* @beta
|
|
81
|
+
*/
|
|
82
|
+
export function registerAIProviderRegistry(container, registry) {
|
|
83
|
+
container.register(Registration.instance(AIProviderRegistry, registry));
|
|
84
|
+
}
|
package/dist/esm/ai-provider.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { DI, Registration } from '@microsoft/fast-foundation';
|
|
3
2
|
import { AnthropicProvider } from './providers/anthropic-provider';
|
|
4
3
|
import { ChromeProvider } from './providers/chrome-provider';
|
|
5
4
|
import { DefaultAIProvider } from './providers/default-provider';
|
|
@@ -300,85 +299,3 @@ export class MutableAIProviderRegistry {
|
|
|
300
299
|
listener();
|
|
301
300
|
}
|
|
302
301
|
}
|
|
303
|
-
/**
|
|
304
|
-
* The DI token for the {@link (AIProviderRegistry:interface)}. When no host
|
|
305
|
-
* registers a concrete registry, the container resolves the built-in empty
|
|
306
|
-
* registry (a single no-op provider) so consumers degrade to inert rather
|
|
307
|
-
* than throwing.
|
|
308
|
-
*
|
|
309
|
-
* Prefer the {@link registerAIProviders} helper over registering this token
|
|
310
|
-
* directly.
|
|
311
|
-
*
|
|
312
|
-
* @beta
|
|
313
|
-
*/
|
|
314
|
-
export const AIProviderRegistry = DI.createInterface((x) => x.singleton(EmptyAIProviderRegistry));
|
|
315
|
-
/**
|
|
316
|
-
* Registers one or more named AI providers as an {@link (AIProviderRegistry:interface)}
|
|
317
|
-
* on the given DI container.
|
|
318
|
-
*
|
|
319
|
-
* @remarks
|
|
320
|
-
* - With a single provider, the default is inferred — `options.default` may be omitted.
|
|
321
|
-
* - With multiple providers, `options.default` is required to avoid implicit ordering.
|
|
322
|
-
* - Throws when `providers` is empty, when the named default isn't present, or
|
|
323
|
-
* when multiple providers are passed without an explicit default.
|
|
324
|
-
*
|
|
325
|
-
* @example
|
|
326
|
-
* ```ts
|
|
327
|
-
* // Single provider — default inferred
|
|
328
|
-
* registerAIProviders(container, { openai: createAIProvider(openAiConfig) });
|
|
329
|
-
*
|
|
330
|
-
* // Multiple providers — explicit default
|
|
331
|
-
* registerAIProviders(
|
|
332
|
-
* container,
|
|
333
|
-
* { fast: chromeProvider, deep: anthropicProvider },
|
|
334
|
-
* { default: 'deep' },
|
|
335
|
-
* );
|
|
336
|
-
* ```
|
|
337
|
-
*
|
|
338
|
-
* @returns the constructed {@link MutableAIProviderRegistry}, so a host that
|
|
339
|
-
* wants to switch providers at runtime can keep the handle and call
|
|
340
|
-
* {@link MutableAIProviderRegistry.set | set} /
|
|
341
|
-
* {@link MutableAIProviderRegistry.setDefault | setDefault} /
|
|
342
|
-
* {@link MutableAIProviderRegistry.update | update} on it later. Callers that
|
|
343
|
-
* register once and never switch can ignore the return value.
|
|
344
|
-
*
|
|
345
|
-
* @beta
|
|
346
|
-
*/
|
|
347
|
-
export function registerAIProviders(container, providers, options = {}) {
|
|
348
|
-
const entries = Object.entries(providers);
|
|
349
|
-
if (entries.length === 0) {
|
|
350
|
-
throw new Error('registerAIProviders: at least one provider is required.');
|
|
351
|
-
}
|
|
352
|
-
let defaultName;
|
|
353
|
-
if (options.default !== undefined) {
|
|
354
|
-
if (!Object.prototype.hasOwnProperty.call(providers, options.default)) {
|
|
355
|
-
throw new Error(`registerAIProviders: default "${options.default}" is not one of the registered providers (${entries.map(([k]) => k).join(', ')}).`);
|
|
356
|
-
}
|
|
357
|
-
defaultName = options.default;
|
|
358
|
-
}
|
|
359
|
-
else if (entries.length === 1) {
|
|
360
|
-
defaultName = entries[0][0];
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
throw new Error(`registerAIProviders: multiple providers registered (${entries.map(([k]) => k).join(', ')}) — must specify { default } to disambiguate.`);
|
|
364
|
-
}
|
|
365
|
-
const registry = new MutableAIProviderRegistry(new Map(entries), defaultName);
|
|
366
|
-
registerAIProviderRegistry(container, registry);
|
|
367
|
-
return registry;
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Registers a host-supplied {@link (AIProviderRegistry:interface)} instance on
|
|
371
|
-
* the DI container under the {@link (AIProviderRegistry:variable)} token.
|
|
372
|
-
*
|
|
373
|
-
* @remarks
|
|
374
|
-
* A thin wrapper over FAST's `Registration.instance` so a host can register its
|
|
375
|
-
* own pre-built registry — typically a {@link MutableAIProviderRegistry} it
|
|
376
|
-
* owns and mutates for runtime provider switching — **without importing FAST
|
|
377
|
-
* primitives** itself. {@link registerAIProviders} delegates to this; reach for
|
|
378
|
-
* it directly when you construct the registry yourself.
|
|
379
|
-
*
|
|
380
|
-
* @beta
|
|
381
|
-
*/
|
|
382
|
-
export function registerAIProviderRegistry(container, registry) {
|
|
383
|
-
container.register(Registration.instance(AIProviderRegistry, registry));
|
|
384
|
-
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createAIProvider, isObservableAIProviderRegistry, MutableAIProviderRegistry, resolveAIConfig, } from './ai-provider';
|
|
2
|
+
// FAST DI wiring lives in its own module so `@microsoft/fast-foundation` (→ `fast-element`, which
|
|
3
|
+
// touches `document` at eval) is only pulled when a host actually uses the container. Keeps the
|
|
4
|
+
// registry/driver path loadable in bare Node. `AIProviderRegistry` carries both the interface
|
|
5
|
+
// (type) and the DI token (value) — both merged in `ai-provider-di.ts`. See `ai-provider-di.ts`.
|
|
6
|
+
export { AIProviderRegistry, registerAIProviderRegistry, registerAIProviders, } from './ai-provider-di';
|
|
2
7
|
export { AnthropicProvider } from './providers/anthropic-provider';
|
|
3
8
|
export { GeminiProvider } from './providers/gemini-provider';
|
|
4
9
|
export { AnthropicTransport, ResponseTruncatedError } from './transports/anthropic-transport';
|
|
@@ -30,6 +30,8 @@ function toAnthropicToolChoice(choice) {
|
|
|
30
30
|
* Source: https://docs.claude.com/en/docs/about-claude/models/overview
|
|
31
31
|
*/
|
|
32
32
|
const ANTHROPIC_CONTEXT_LIMITS = {
|
|
33
|
+
'claude-fable-5': 1000000,
|
|
34
|
+
'claude-opus-4-8': 1000000,
|
|
33
35
|
'claude-opus-4-7': 1000000,
|
|
34
36
|
'claude-sonnet-5': 1000000,
|
|
35
37
|
'claude-sonnet-4-6': 1000000,
|
|
@@ -41,6 +43,8 @@ const ANTHROPIC_CONTEXT_LIMITS = {
|
|
|
41
43
|
* and surfaces the `input` field as the structured response.
|
|
42
44
|
*/
|
|
43
45
|
const STRUCTURED_OUTPUT_TOOL_NAME = 'emit_structured_response';
|
|
46
|
+
/** Beta flag enabling the server-side `fallbacks` request parameter (refusal rescue). */
|
|
47
|
+
const SERVER_SIDE_FALLBACK_BETA = 'server-side-fallback-2026-06-01';
|
|
44
48
|
function assertSupportedAnthropicModel(model) {
|
|
45
49
|
if (!SUPPORTED_ANTHROPIC_MODEL_IDS.includes(model)) {
|
|
46
50
|
throw new Error(`AnthropicTransport: unsupported model "${model}". Use one of: ${SUPPORTED_ANTHROPIC_MODEL_IDS.join(', ')}.`);
|
|
@@ -53,36 +57,60 @@ function estimatedAnthropicRatesUsdPerMillion(model) {
|
|
|
53
57
|
if (model === 'claude-haiku-4-5-20251001') {
|
|
54
58
|
return { promptPerMillion: 1, candidatePerMillion: 5 };
|
|
55
59
|
}
|
|
60
|
+
// Fable 5 — Anthropic's most capable widely-released model; priced above Opus tier.
|
|
61
|
+
if (model === 'claude-fable-5') {
|
|
62
|
+
return { promptPerMillion: 10, candidatePerMillion: 50 };
|
|
63
|
+
}
|
|
56
64
|
// Sonnet 5 and Sonnet 4.6 share the standard Sonnet tier ($3 / $15 per MTok). Sonnet 5's
|
|
57
65
|
// introductory rate ($2 / $10 through 2026-08-31) is deliberately NOT used here — standard rates.
|
|
58
66
|
if (model === 'claude-sonnet-5' || model === 'claude-sonnet-4-6') {
|
|
59
67
|
return { promptPerMillion: 3, candidatePerMillion: 15 };
|
|
60
68
|
}
|
|
61
|
-
// Opus 4.7
|
|
69
|
+
// Opus 4.7 / 4.8 — same $5 / $25 per MTok.
|
|
62
70
|
return { promptPerMillion: 5, candidatePerMillion: 25 };
|
|
63
71
|
}
|
|
64
72
|
/**
|
|
65
73
|
* Models that reject non-default sampling parameters (`temperature`/`top_p`/`top_k`) with a 400 —
|
|
66
|
-
* the Opus 4.7+ generation. Sonnet 4.6 and Haiku 4.5 still accept them.
|
|
74
|
+
* the Opus 4.7+ / Sonnet 5 / Fable 5 generation. Sonnet 4.6 and Haiku 4.5 still accept them.
|
|
67
75
|
*/
|
|
68
76
|
function rejectsSamplingParams(model) {
|
|
69
|
-
return model === 'claude-
|
|
77
|
+
return (model === 'claude-fable-5' ||
|
|
78
|
+
model === 'claude-opus-4-8' ||
|
|
79
|
+
model === 'claude-opus-4-7' ||
|
|
80
|
+
model === 'claude-sonnet-5');
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Whether the model enforces structured output natively via decode-time `output_config.format`
|
|
84
|
+
* (json_schema). True for Fable 5, Opus 4.8, Sonnet 5, and Haiku 4.5; false for Opus 4.7 and
|
|
85
|
+
* Sonnet 4.6, which fall back to the forced-tool approach on the one-shot path. `output_config`
|
|
86
|
+
* composes with a live `tools` array, so no tool-vs-schema gating is needed on this provider.
|
|
87
|
+
*/
|
|
88
|
+
function supportsNativeStructuredOutput(model) {
|
|
89
|
+
return (model === 'claude-fable-5' ||
|
|
90
|
+
model === 'claude-opus-4-8' ||
|
|
91
|
+
model === 'claude-sonnet-5' ||
|
|
92
|
+
model === 'claude-haiku-4-5-20251001');
|
|
70
93
|
}
|
|
71
94
|
/**
|
|
72
|
-
* Extended-thinking posture for a request. Sonnet 5
|
|
95
|
+
* Extended-thinking posture for a request. Sonnet 5 and Fable 5 run adaptive thinking with
|
|
73
96
|
* `display:'summarized'` — regardless of `tool_choice`. First-party has no forced-tool-vs-thinking
|
|
74
97
|
* restriction (that's Bedrock-only), and "adaptive" self-regulates (the model thinks little on
|
|
75
98
|
* trivial/mechanical turns on its own), so there is no reason to special-case forced tool calls.
|
|
76
99
|
* `display:'summarized'` means the reasoning summary is always returned (billed regardless; the
|
|
77
100
|
* host's toggle decides visibility).
|
|
78
101
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
102
|
+
* Fable 5 runs thinking *unconditionally* (it cannot be disabled — an explicit
|
|
103
|
+
* `{type:'disabled'}` is a 400), so it must never be sent `disabled`; `{type:'adaptive'}`
|
|
104
|
+
* is the accepted posture and is what we return.
|
|
105
|
+
*
|
|
106
|
+
* Every other model (Opus 4.8/4.7, Sonnet 4.6, Haiku) returns undefined → `thinking` is omitted
|
|
107
|
+
* → it runs WITHOUT thinking on the chat path (Opus 4.8 adaptive thinking is opt-in). So the older
|
|
108
|
+
* "forced tool + thinking is incompatible" restriction never applies to them (you can't hit it when
|
|
109
|
+
* thinking is off). If thinking is ever enabled for one of those, revisit the forced-tool
|
|
110
|
+
* interaction for that model then.
|
|
83
111
|
*/
|
|
84
112
|
function anthropicThinking(model) {
|
|
85
|
-
if (model !== 'claude-sonnet-5')
|
|
113
|
+
if (model !== 'claude-sonnet-5' && model !== 'claude-fable-5')
|
|
86
114
|
return undefined;
|
|
87
115
|
return { type: 'adaptive', display: 'summarized' };
|
|
88
116
|
}
|
|
@@ -178,8 +206,11 @@ export class AnthropicTransport {
|
|
|
178
206
|
else if (model === 'claude-sonnet-4-6') {
|
|
179
207
|
logger.warn('AnthropicTransport: using claude-sonnet-4-6 — higher cost than Haiku; use for stronger reasoning or agent tasks.');
|
|
180
208
|
}
|
|
181
|
-
else if (model === 'claude-opus-4-7') {
|
|
182
|
-
logger.warn(
|
|
209
|
+
else if (model === 'claude-opus-4-7' || model === 'claude-opus-4-8') {
|
|
210
|
+
logger.warn(`AnthropicTransport: using ${model} — significantly higher cost; reserve for tasks where Sonnet reliability is insufficient.`);
|
|
211
|
+
}
|
|
212
|
+
else if (model === 'claude-fable-5') {
|
|
213
|
+
logger.warn('AnthropicTransport: using claude-fable-5 — Anthropic\'s most capable model, priced above Opus tier ($10 / $50 per MTok) with thinking always on. Reserve for the hardest reasoning/long-horizon work. Requires ≥30-day data retention (unavailable under ZDR) and may return stop_reason "refusal"; pair with an Opus 4.8 fallback.');
|
|
183
214
|
}
|
|
184
215
|
this.timeout = (_b = config.timeout) !== null && _b !== void 0 ? _b : DEFAULT_TIMEOUT;
|
|
185
216
|
this.stallTimeout = (_c = config.stallTimeout) !== null && _c !== void 0 ? _c : DEFAULT_STALL_TIMEOUT;
|
|
@@ -213,19 +244,6 @@ export class AnthropicTransport {
|
|
|
213
244
|
var _a, _b, _c;
|
|
214
245
|
const { systemPrompt, userPrompt, responseSchema } = options;
|
|
215
246
|
const messages = [{ role: 'user', content: userPrompt }];
|
|
216
|
-
// Anthropic has no native JSON-schema response format. The supported pattern
|
|
217
|
-
// is to define a tool whose input_schema is the desired schema, then force
|
|
218
|
-
// the model to call it via tool_choice. The tool's `input` is the structured
|
|
219
|
-
// payload we surface back to the caller as a JSON string.
|
|
220
|
-
const tools = responseSchema
|
|
221
|
-
? [
|
|
222
|
-
{
|
|
223
|
-
name: STRUCTURED_OUTPUT_TOOL_NAME,
|
|
224
|
-
description: 'Emit the structured response that matches the required schema.',
|
|
225
|
-
input_schema: responseSchema,
|
|
226
|
-
},
|
|
227
|
-
]
|
|
228
|
-
: undefined;
|
|
229
247
|
const body = {
|
|
230
248
|
model: this.model,
|
|
231
249
|
max_tokens: this.maxTokens,
|
|
@@ -233,19 +251,38 @@ export class AnthropicTransport {
|
|
|
233
251
|
};
|
|
234
252
|
if (systemPrompt)
|
|
235
253
|
body.system = systemPrompt;
|
|
236
|
-
|
|
237
|
-
|
|
254
|
+
// Prefer native decode-time enforcement (`output_config.format`) where the model supports it —
|
|
255
|
+
// the answer comes back as ordinary text conforming to the schema. On models without native
|
|
256
|
+
// support (Opus 4.7, Sonnet 4.6), fall back to the legacy pattern: a tool whose `input_schema`
|
|
257
|
+
// is the schema, forced via `tool_choice`, with the structured payload read from its `tool_use`.
|
|
258
|
+
const useNative = responseSchema != null && supportsNativeStructuredOutput(this.model);
|
|
259
|
+
const useForcedTool = responseSchema != null && !useNative;
|
|
260
|
+
if (useNative) {
|
|
261
|
+
body.output_config = {
|
|
262
|
+
format: { type: 'json_schema', schema: responseSchema },
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
else if (useForcedTool) {
|
|
266
|
+
body.tools = [
|
|
267
|
+
{
|
|
268
|
+
name: STRUCTURED_OUTPUT_TOOL_NAME,
|
|
269
|
+
description: 'Emit the structured response that matches the required schema.',
|
|
270
|
+
input_schema: responseSchema,
|
|
271
|
+
},
|
|
272
|
+
];
|
|
238
273
|
body.tool_choice = { type: 'tool', name: STRUCTURED_OUTPUT_TOOL_NAME };
|
|
239
274
|
}
|
|
240
|
-
// Sonnet 5 runs adaptive thinking by default; disable it for
|
|
241
|
-
//
|
|
275
|
+
// Sonnet 5 runs adaptive thinking by default; disable it for one-shot prompts — the reasoning
|
|
276
|
+
// would be billed but discarded. Fable 5 runs thinking unconditionally (cannot be disabled — a
|
|
277
|
+
// 400), so it is left on; its summary is simply unused here.
|
|
242
278
|
if (this.model === 'claude-sonnet-5')
|
|
243
279
|
body.thinking = { type: 'disabled' };
|
|
244
280
|
const response = yield this.post(body);
|
|
245
|
-
if (
|
|
281
|
+
if (useForcedTool) {
|
|
246
282
|
const toolUse = ((_a = response.content) !== null && _a !== void 0 ? _a : []).find((b) => b.type === 'tool_use' && b.name === STRUCTURED_OUTPUT_TOOL_NAME);
|
|
247
283
|
return toolUse ? JSON.stringify((_b = toolUse.input) !== null && _b !== void 0 ? _b : {}) : '';
|
|
248
284
|
}
|
|
285
|
+
// Native structured output and plain prompts both return the answer as text.
|
|
249
286
|
return ((_c = response.content) !== null && _c !== void 0 ? _c : [])
|
|
250
287
|
.filter((b) => b.type === 'text')
|
|
251
288
|
.map((b) => b.text)
|
|
@@ -255,7 +292,7 @@ export class AnthropicTransport {
|
|
|
255
292
|
// ── ChatTransport (multi-turn chat) ────────────────────────────────────
|
|
256
293
|
sendChatMessage(history, userMessage, options) {
|
|
257
294
|
return __awaiter(this, void 0, void 0, function* () {
|
|
258
|
-
var _a, _b;
|
|
295
|
+
var _a, _b, _c;
|
|
259
296
|
const messages = this.toAnthropicMessages(history, userMessage, options === null || options === void 0 ? void 0 : options.attachments);
|
|
260
297
|
const body = {
|
|
261
298
|
model: this.model,
|
|
@@ -294,6 +331,22 @@ export class AnthropicTransport {
|
|
|
294
331
|
maxTemp: ANTHROPIC_MAX_TEMPERATURE,
|
|
295
332
|
});
|
|
296
333
|
}
|
|
334
|
+
// Structured output: constrain the final text answer to the caller's JSON schema via
|
|
335
|
+
// decode-time `output_config.format`. Composes with a live `tools` array — the model still
|
|
336
|
+
// calls tools through the turn and conforms its closing answer to the schema. Applied only on
|
|
337
|
+
// models that support it natively; elsewhere the schema is dropped here (the caller keeps a
|
|
338
|
+
// prompt-instruction + validator fallback). No beta header needed.
|
|
339
|
+
if ((options === null || options === void 0 ? void 0 : options.responseSchema) && supportsNativeStructuredOutput(this.model)) {
|
|
340
|
+
body.output_config = {
|
|
341
|
+
format: { type: 'json_schema', schema: options.responseSchema },
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
// Refusal fallback chain (e.g. Fable 5 → Opus 4.8). Sent as the server-side `fallbacks`
|
|
345
|
+
// param; `post` adds the required beta header when this is present. A refused turn is
|
|
346
|
+
// re-run on the next model in one round trip.
|
|
347
|
+
if ((_c = options === null || options === void 0 ? void 0 : options.fallbacks) === null || _c === void 0 ? void 0 : _c.length) {
|
|
348
|
+
body.fallbacks = options.fallbacks.map((f) => f.maxTokens != null ? { model: f.model, max_tokens: f.maxTokens } : { model: f.model });
|
|
349
|
+
}
|
|
297
350
|
// Place prompt-cache breakpoints per the resolved policy (no-op for `'default'`/absent).
|
|
298
351
|
if (options === null || options === void 0 ? void 0 : options.cachePolicy) {
|
|
299
352
|
this.applyCacheControl(body, options.cachePolicy);
|
|
@@ -553,6 +606,14 @@ export class AnthropicTransport {
|
|
|
553
606
|
if (response.stop_reason === 'max_tokens') {
|
|
554
607
|
base.responseMeta = { finishReason: 'max_tokens' };
|
|
555
608
|
}
|
|
609
|
+
// A `refusal` stop means safety classifiers declined the request (Fable 5 and other
|
|
610
|
+
// recent models). Content is empty (pre-output) or partial (mid-stream) — return it
|
|
611
|
+
// rather than crash on an assumed non-empty block, and flag the reason so the driver
|
|
612
|
+
// (or a server-side `fallbacks` chain) can respond deterministically instead of
|
|
613
|
+
// retrying into the same wall. Usage/cost is already logged above.
|
|
614
|
+
if (response.stop_reason === 'refusal') {
|
|
615
|
+
base.responseMeta = { finishReason: 'refusal' };
|
|
616
|
+
}
|
|
556
617
|
return base;
|
|
557
618
|
}
|
|
558
619
|
buildEndpoint() {
|
|
@@ -584,10 +645,17 @@ export class AnthropicTransport {
|
|
|
584
645
|
}
|
|
585
646
|
post(body, signal) {
|
|
586
647
|
return __awaiter(this, void 0, void 0, function* () {
|
|
648
|
+
var _a;
|
|
587
649
|
const { url, headers, credentials } = this.buildEndpoint();
|
|
650
|
+
// The server-side `fallbacks` param is gated behind a beta flag; add it per-request only
|
|
651
|
+
// when a fallback chain is set (the param without the header is a 400, and vice-versa is fine).
|
|
652
|
+
const requestHeaders = ((_a = body.fallbacks) === null || _a === void 0 ? void 0 : _a.length)
|
|
653
|
+
? Object.assign(Object.assign({}, headers), { 'anthropic-beta': [headers['anthropic-beta'], SERVER_SIDE_FALLBACK_BETA]
|
|
654
|
+
.filter(Boolean)
|
|
655
|
+
.join(',') }) : headers;
|
|
588
656
|
return (yield postWithRetry({
|
|
589
657
|
url,
|
|
590
|
-
headers,
|
|
658
|
+
headers: requestHeaders,
|
|
591
659
|
body,
|
|
592
660
|
credentials,
|
|
593
661
|
vendorLabel: 'Anthropic',
|
|
@@ -258,7 +258,18 @@ export class GeminiTransport {
|
|
|
258
258
|
// Names of the tools offered this turn — used to validate a repaired
|
|
259
259
|
// malformed call against the real tool surface before accepting it.
|
|
260
260
|
const offeredToolNames = new Set(((_b = options === null || options === void 0 ? void 0 : options.tools) !== null && _b !== void 0 ? _b : []).map((t) => t.name));
|
|
261
|
-
|
|
261
|
+
// Structured output (native JSON mode). Gemini 3 can combine it with function calling;
|
|
262
|
+
// Gemini 2.x cannot, so on 2.x apply the schema only on a pure structured turn (no tools) and
|
|
263
|
+
// otherwise drop it (the caller keeps a prompt-instruction + validator fallback). Passed as a
|
|
264
|
+
// top-level `responseSchema` that `toDirectPayload` maps to `generationConfig.responseMimeType`
|
|
265
|
+
// + `responseSchema` on the direct path (the proxy forwards it).
|
|
266
|
+
const schemaCoexistsWithTools = this.model.startsWith('gemini-3');
|
|
267
|
+
const applyResponseSchema = (options === null || options === void 0 ? void 0 : options.responseSchema) != null && (!tools || schemaCoexistsWithTools);
|
|
268
|
+
const response = yield this.post(Object.assign({ model: this.model, contents,
|
|
269
|
+
tools,
|
|
270
|
+
systemInstruction,
|
|
271
|
+
toolConfig,
|
|
272
|
+
generationConfig }, (applyResponseSchema ? { responseSchema: options.responseSchema } : {})), options === null || options === void 0 ? void 0 : options.signal);
|
|
262
273
|
return this.fromGeminiResponse(response, offeredToolNames);
|
|
263
274
|
});
|
|
264
275
|
}
|
|
@@ -719,7 +719,7 @@
|
|
|
719
719
|
"text": "export interface AIProviderRegistry "
|
|
720
720
|
}
|
|
721
721
|
],
|
|
722
|
-
"fileUrlPath": "src/ai-provider.ts",
|
|
722
|
+
"fileUrlPath": "src/ai-provider-di.ts",
|
|
723
723
|
"releaseTag": "Beta",
|
|
724
724
|
"name": "AIProviderRegistry",
|
|
725
725
|
"preserveMemberOrder": false,
|
|
@@ -995,7 +995,7 @@
|
|
|
995
995
|
"text": ">"
|
|
996
996
|
}
|
|
997
997
|
],
|
|
998
|
-
"fileUrlPath": "src/ai-provider.ts",
|
|
998
|
+
"fileUrlPath": "src/ai-provider-di.ts",
|
|
999
999
|
"isReadonly": true,
|
|
1000
1000
|
"releaseTag": "Beta",
|
|
1001
1001
|
"name": "AIProviderRegistry",
|
|
@@ -1441,7 +1441,7 @@
|
|
|
1441
1441
|
},
|
|
1442
1442
|
{
|
|
1443
1443
|
"kind": "Content",
|
|
1444
|
-
"text": "'claude-opus-4-7' | 'claude-sonnet-5' | 'claude-sonnet-4-6' | 'claude-haiku-4-5-20251001'"
|
|
1444
|
+
"text": "'claude-fable-5' | 'claude-opus-4-8' | 'claude-opus-4-7' | 'claude-sonnet-5' | 'claude-sonnet-4-6' | 'claude-haiku-4-5-20251001'"
|
|
1445
1445
|
},
|
|
1446
1446
|
{
|
|
1447
1447
|
"kind": "Content",
|
|
@@ -3162,6 +3162,78 @@
|
|
|
3162
3162
|
"endIndex": 4
|
|
3163
3163
|
}
|
|
3164
3164
|
},
|
|
3165
|
+
{
|
|
3166
|
+
"kind": "Interface",
|
|
3167
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatFallback:interface",
|
|
3168
|
+
"docComment": "/**\n * One entry in a {@link ChatRequestOptions.fallbacks} chain.\n *\n * @beta\n */\n",
|
|
3169
|
+
"excerptTokens": [
|
|
3170
|
+
{
|
|
3171
|
+
"kind": "Content",
|
|
3172
|
+
"text": "export interface ChatFallback "
|
|
3173
|
+
}
|
|
3174
|
+
],
|
|
3175
|
+
"fileUrlPath": "src/types/chat.types.ts",
|
|
3176
|
+
"releaseTag": "Beta",
|
|
3177
|
+
"name": "ChatFallback",
|
|
3178
|
+
"preserveMemberOrder": false,
|
|
3179
|
+
"members": [
|
|
3180
|
+
{
|
|
3181
|
+
"kind": "PropertySignature",
|
|
3182
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatFallback#maxTokens:member",
|
|
3183
|
+
"docComment": "/**\n * Optional per-hop `max_tokens` cap for this fallback attempt.\n */\n",
|
|
3184
|
+
"excerptTokens": [
|
|
3185
|
+
{
|
|
3186
|
+
"kind": "Content",
|
|
3187
|
+
"text": "maxTokens?: "
|
|
3188
|
+
},
|
|
3189
|
+
{
|
|
3190
|
+
"kind": "Content",
|
|
3191
|
+
"text": "number"
|
|
3192
|
+
},
|
|
3193
|
+
{
|
|
3194
|
+
"kind": "Content",
|
|
3195
|
+
"text": ";"
|
|
3196
|
+
}
|
|
3197
|
+
],
|
|
3198
|
+
"isReadonly": false,
|
|
3199
|
+
"isOptional": true,
|
|
3200
|
+
"releaseTag": "Beta",
|
|
3201
|
+
"name": "maxTokens",
|
|
3202
|
+
"propertyTypeTokenRange": {
|
|
3203
|
+
"startIndex": 1,
|
|
3204
|
+
"endIndex": 2
|
|
3205
|
+
}
|
|
3206
|
+
},
|
|
3207
|
+
{
|
|
3208
|
+
"kind": "PropertySignature",
|
|
3209
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatFallback#model:member",
|
|
3210
|
+
"docComment": "/**\n * Model id to fall back to (e.g. `'claude-opus-4-8'`).\n */\n",
|
|
3211
|
+
"excerptTokens": [
|
|
3212
|
+
{
|
|
3213
|
+
"kind": "Content",
|
|
3214
|
+
"text": "model: "
|
|
3215
|
+
},
|
|
3216
|
+
{
|
|
3217
|
+
"kind": "Content",
|
|
3218
|
+
"text": "string"
|
|
3219
|
+
},
|
|
3220
|
+
{
|
|
3221
|
+
"kind": "Content",
|
|
3222
|
+
"text": ";"
|
|
3223
|
+
}
|
|
3224
|
+
],
|
|
3225
|
+
"isReadonly": false,
|
|
3226
|
+
"isOptional": false,
|
|
3227
|
+
"releaseTag": "Beta",
|
|
3228
|
+
"name": "model",
|
|
3229
|
+
"propertyTypeTokenRange": {
|
|
3230
|
+
"startIndex": 1,
|
|
3231
|
+
"endIndex": 2
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
],
|
|
3235
|
+
"extendsTokenRanges": []
|
|
3236
|
+
},
|
|
3165
3237
|
{
|
|
3166
3238
|
"kind": "TypeAlias",
|
|
3167
3239
|
"canonicalReference": "@genesislcap/foundation-ai!ChatInputDuringExecutionMode:type",
|
|
@@ -4023,6 +4095,65 @@
|
|
|
4023
4095
|
"endIndex": 2
|
|
4024
4096
|
}
|
|
4025
4097
|
},
|
|
4098
|
+
{
|
|
4099
|
+
"kind": "PropertySignature",
|
|
4100
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatRequestOptions#fallbacks:member",
|
|
4101
|
+
"docComment": "/**\n * Provider-neutral refusal-fallback chain: if the model declines the request (`stop_reason: 'refusal'`, e.g. Fable 5 safety classifiers), the provider re-runs the same request on the next listed model and returns its answer. Ordered most- to least-preferred; each entry may cap its own `maxTokens`. Providers that support it apply it server-side (Anthropic: `fallbacks` + the `server-side-fallback` beta); others ignore it. Typical use: Fable 5 with an Opus 4.8 fallback.\n *\n * @beta\n */\n",
|
|
4102
|
+
"excerptTokens": [
|
|
4103
|
+
{
|
|
4104
|
+
"kind": "Content",
|
|
4105
|
+
"text": "fallbacks?: "
|
|
4106
|
+
},
|
|
4107
|
+
{
|
|
4108
|
+
"kind": "Reference",
|
|
4109
|
+
"text": "ChatFallback",
|
|
4110
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatFallback:interface"
|
|
4111
|
+
},
|
|
4112
|
+
{
|
|
4113
|
+
"kind": "Content",
|
|
4114
|
+
"text": "[]"
|
|
4115
|
+
},
|
|
4116
|
+
{
|
|
4117
|
+
"kind": "Content",
|
|
4118
|
+
"text": ";"
|
|
4119
|
+
}
|
|
4120
|
+
],
|
|
4121
|
+
"isReadonly": false,
|
|
4122
|
+
"isOptional": true,
|
|
4123
|
+
"releaseTag": "Beta",
|
|
4124
|
+
"name": "fallbacks",
|
|
4125
|
+
"propertyTypeTokenRange": {
|
|
4126
|
+
"startIndex": 1,
|
|
4127
|
+
"endIndex": 3
|
|
4128
|
+
}
|
|
4129
|
+
},
|
|
4130
|
+
{
|
|
4131
|
+
"kind": "PropertySignature",
|
|
4132
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatRequestOptions#responseSchema:member",
|
|
4133
|
+
"docComment": "/**\n * Structured-output schema (JSON Schema) for this turn. When set, the model's final (non-tool) answer is constrained to it instead of free text. Composes with `tools` — the model may still call tools this turn, then conform its closing answer to the schema. Providers apply it natively where the model supports it (Anthropic `output_config.format`, Gemini JSON mode) and drop it otherwise (caller keeps a prompt-instruction + validator fallback). Keep to the portable JSON-Schema subset providers share (`additionalProperties: false`, explicit `required`, enums, `anyOf` for nullables — no numeric/string constraints or recursion).\n *\n * @beta\n */\n",
|
|
4134
|
+
"excerptTokens": [
|
|
4135
|
+
{
|
|
4136
|
+
"kind": "Content",
|
|
4137
|
+
"text": "responseSchema?: "
|
|
4138
|
+
},
|
|
4139
|
+
{
|
|
4140
|
+
"kind": "Content",
|
|
4141
|
+
"text": "object"
|
|
4142
|
+
},
|
|
4143
|
+
{
|
|
4144
|
+
"kind": "Content",
|
|
4145
|
+
"text": ";"
|
|
4146
|
+
}
|
|
4147
|
+
],
|
|
4148
|
+
"isReadonly": false,
|
|
4149
|
+
"isOptional": true,
|
|
4150
|
+
"releaseTag": "Beta",
|
|
4151
|
+
"name": "responseSchema",
|
|
4152
|
+
"propertyTypeTokenRange": {
|
|
4153
|
+
"startIndex": 1,
|
|
4154
|
+
"endIndex": 2
|
|
4155
|
+
}
|
|
4156
|
+
},
|
|
4026
4157
|
{
|
|
4027
4158
|
"kind": "PropertySignature",
|
|
4028
4159
|
"canonicalReference": "@genesislcap/foundation-ai!ChatRequestOptions#signal:member",
|
|
@@ -8678,7 +8809,7 @@
|
|
|
8678
8809
|
"text": ";"
|
|
8679
8810
|
}
|
|
8680
8811
|
],
|
|
8681
|
-
"fileUrlPath": "src/ai-provider.ts",
|
|
8812
|
+
"fileUrlPath": "src/ai-provider-di.ts",
|
|
8682
8813
|
"returnTypeTokenRange": {
|
|
8683
8814
|
"startIndex": 5,
|
|
8684
8815
|
"endIndex": 6
|
|
@@ -8764,7 +8895,7 @@
|
|
|
8764
8895
|
"text": ";"
|
|
8765
8896
|
}
|
|
8766
8897
|
],
|
|
8767
|
-
"fileUrlPath": "src/ai-provider.ts",
|
|
8898
|
+
"fileUrlPath": "src/ai-provider-di.ts",
|
|
8768
8899
|
"returnTypeTokenRange": {
|
|
8769
8900
|
"startIndex": 10,
|
|
8770
8901
|
"endIndex": 11
|
|
@@ -8809,7 +8940,7 @@
|
|
|
8809
8940
|
"text": "export interface RegisterAIProvidersOptions "
|
|
8810
8941
|
}
|
|
8811
8942
|
],
|
|
8812
|
-
"fileUrlPath": "src/ai-provider.ts",
|
|
8943
|
+
"fileUrlPath": "src/ai-provider-di.ts",
|
|
8813
8944
|
"releaseTag": "Beta",
|
|
8814
8945
|
"name": "RegisterAIProvidersOptions",
|
|
8815
8946
|
"preserveMemberOrder": false,
|
package/dist/foundation-ai.d.ts
CHANGED
|
@@ -227,7 +227,7 @@ export declare interface AnthropicAIConfig extends AIProviderConfig {
|
|
|
227
227
|
*
|
|
228
228
|
* @beta
|
|
229
229
|
*/
|
|
230
|
-
export declare type AnthropicModelId = 'claude-opus-4-7' | 'claude-sonnet-5' | 'claude-sonnet-4-6' | 'claude-haiku-4-5-20251001';
|
|
230
|
+
export declare type AnthropicModelId = 'claude-fable-5' | 'claude-opus-4-8' | 'claude-opus-4-7' | 'claude-sonnet-5' | 'claude-sonnet-4-6' | 'claude-haiku-4-5-20251001';
|
|
231
231
|
|
|
232
232
|
/**
|
|
233
233
|
* Anthropic Claude AI provider. Uses {@link AnthropicTransport} to handle requests.
|
|
@@ -579,6 +579,18 @@ export declare type ChatDriverResult = {
|
|
|
579
579
|
remainingTask: string;
|
|
580
580
|
};
|
|
581
581
|
|
|
582
|
+
/**
|
|
583
|
+
* One entry in a {@link ChatRequestOptions.fallbacks} chain.
|
|
584
|
+
*
|
|
585
|
+
* @beta
|
|
586
|
+
*/
|
|
587
|
+
export declare interface ChatFallback {
|
|
588
|
+
/** Model id to fall back to (e.g. `'claude-opus-4-8'`). */
|
|
589
|
+
model: string;
|
|
590
|
+
/** Optional per-hop `max_tokens` cap for this fallback attempt. */
|
|
591
|
+
maxTokens?: number;
|
|
592
|
+
}
|
|
593
|
+
|
|
582
594
|
/**
|
|
583
595
|
* Controls how the main chat input area behaves while an agent (or sub-agent)
|
|
584
596
|
* is executing.
|
|
@@ -783,6 +795,29 @@ export declare interface ChatRequestOptions {
|
|
|
783
795
|
* @beta
|
|
784
796
|
*/
|
|
785
797
|
tailContext?: string;
|
|
798
|
+
/**
|
|
799
|
+
* Provider-neutral refusal-fallback chain: if the model declines the request
|
|
800
|
+
* (`stop_reason: 'refusal'`, e.g. Fable 5 safety classifiers), the provider re-runs the
|
|
801
|
+
* same request on the next listed model and returns its answer. Ordered most- to
|
|
802
|
+
* least-preferred; each entry may cap its own `maxTokens`. Providers that support it
|
|
803
|
+
* apply it server-side (Anthropic: `fallbacks` + the `server-side-fallback` beta); others
|
|
804
|
+
* ignore it. Typical use: Fable 5 with an Opus 4.8 fallback.
|
|
805
|
+
*
|
|
806
|
+
* @beta
|
|
807
|
+
*/
|
|
808
|
+
fallbacks?: ChatFallback[];
|
|
809
|
+
/**
|
|
810
|
+
* Structured-output schema (JSON Schema) for this turn. When set, the model's final (non-tool)
|
|
811
|
+
* answer is constrained to it instead of free text. Composes with `tools` — the model may still
|
|
812
|
+
* call tools this turn, then conform its closing answer to the schema. Providers apply it
|
|
813
|
+
* natively where the model supports it (Anthropic `output_config.format`, Gemini JSON mode) and
|
|
814
|
+
* drop it otherwise (caller keeps a prompt-instruction + validator fallback). Keep to the
|
|
815
|
+
* portable JSON-Schema subset providers share (`additionalProperties: false`, explicit
|
|
816
|
+
* `required`, enums, `anyOf` for nullables — no numeric/string constraints or recursion).
|
|
817
|
+
*
|
|
818
|
+
* @beta
|
|
819
|
+
*/
|
|
820
|
+
responseSchema?: object;
|
|
786
821
|
}
|
|
787
822
|
|
|
788
823
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/foundation-ai",
|
|
3
3
|
"description": "Genesis Foundation AI - Provider-agnostic AI configuration and shared utilities",
|
|
4
|
-
"version": "14.
|
|
4
|
+
"version": "14.496.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "SEE LICENSE IN license.txt",
|
|
7
7
|
"main": "dist/esm/index.js",
|
|
@@ -52,17 +52,17 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@genesislcap/foundation-testing": "14.
|
|
56
|
-
"@genesislcap/genx": "14.
|
|
57
|
-
"@genesislcap/rollup-builder": "14.
|
|
58
|
-
"@genesislcap/ts-builder": "14.
|
|
59
|
-
"@genesislcap/uvu-playwright-builder": "14.
|
|
60
|
-
"@genesislcap/vite-builder": "14.
|
|
61
|
-
"@genesislcap/webpack-builder": "14.
|
|
55
|
+
"@genesislcap/foundation-testing": "14.496.0",
|
|
56
|
+
"@genesislcap/genx": "14.496.0",
|
|
57
|
+
"@genesislcap/rollup-builder": "14.496.0",
|
|
58
|
+
"@genesislcap/ts-builder": "14.496.0",
|
|
59
|
+
"@genesislcap/uvu-playwright-builder": "14.496.0",
|
|
60
|
+
"@genesislcap/vite-builder": "14.496.0",
|
|
61
|
+
"@genesislcap/webpack-builder": "14.496.0"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@genesislcap/foundation-logger": "14.
|
|
65
|
-
"@genesislcap/foundation-utils": "14.
|
|
64
|
+
"@genesislcap/foundation-logger": "14.496.0",
|
|
65
|
+
"@genesislcap/foundation-utils": "14.496.0",
|
|
66
66
|
"@microsoft/fast-foundation": "2.50.0"
|
|
67
67
|
},
|
|
68
68
|
"repository": {
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"access": "public"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "2ae3ec60cab8440c6beb1da84e2d47239b11e9b5"
|
|
77
77
|
}
|