@umituz/web-ai 0.0.0-stage → 1.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.
- package/LICENSE +21 -0
- package/README.md +98 -2
- package/dist/AIErrors-B2ogd1PB.d.ts +197 -0
- package/dist/AIErrors-C5EasV_c.d.cts +197 -0
- package/dist/ContentGeneration-B6iK2B33.d.cts +93 -0
- package/dist/ContentGeneration-B6iK2B33.d.ts +93 -0
- package/dist/ProviderConfig-DIFa9nmG.d.cts +108 -0
- package/dist/ProviderConfig-DIFa9nmG.d.ts +108 -0
- package/dist/cache-manager-Df9LLYGA.d.cts +31 -0
- package/dist/cache-manager-Df9LLYGA.d.ts +31 -0
- package/dist/chat/index.cjs +625 -0
- package/dist/chat/index.cjs.map +1 -0
- package/dist/chat/index.d.cts +25 -0
- package/dist/chat/index.d.ts +25 -0
- package/dist/chat/index.js +618 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat.service-CL1qtYxe.d.cts +124 -0
- package/dist/chat.service-q05GnhEm.d.ts +124 -0
- package/dist/content/index.cjs +3976 -0
- package/dist/content/index.cjs.map +1 -0
- package/dist/content/index.d.cts +224 -0
- package/dist/content/index.d.ts +224 -0
- package/dist/content/index.js +3945 -0
- package/dist/content/index.js.map +1 -0
- package/dist/core/index.cjs +1137 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +204 -0
- package/dist/core/index.d.ts +204 -0
- package/dist/core/index.js +1064 -0
- package/dist/core/index.js.map +1 -0
- package/dist/create-ai-DOI9jD3v.d.cts +251 -0
- package/dist/create-ai-DXEoke8-.d.ts +251 -0
- package/dist/hooks/index.cjs +5246 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.cts +210 -0
- package/dist/hooks/index.d.ts +210 -0
- package/dist/hooks/index.js +5235 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index-DIHz8_OJ.d.ts +48 -0
- package/dist/index-DKHNcMbl.d.cts +48 -0
- package/dist/index-fXjxTR5W.d.cts +66 -0
- package/dist/index-fXjxTR5W.d.ts +66 -0
- package/dist/index.cjs +3309 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +3197 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.factory-BxsfK4WW.d.cts +110 -0
- package/dist/provider.factory-DfDfk0dK.d.ts +110 -0
- package/dist/providers/index.cjs +2567 -0
- package/dist/providers/index.cjs.map +1 -0
- package/dist/providers/index.d.cts +332 -0
- package/dist/providers/index.d.ts +332 -0
- package/dist/providers/index.js +2533 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/request-deduplicator.util-NDo0_n1y.d.cts +50 -0
- package/dist/request-deduplicator.util-NDo0_n1y.d.ts +50 -0
- package/dist/wizard/index.cjs +230 -0
- package/dist/wizard/index.cjs.map +1 -0
- package/dist/wizard/index.d.cts +86 -0
- package/dist/wizard/index.d.ts +86 -0
- package/dist/wizard/index.js +223 -0
- package/dist/wizard/index.js.map +1 -0
- package/package.json +114 -4
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { P as ProviderHealth, T as TextRequest, G as GenerationResult, b as StructuredTextRequest, a as StructuredGeneration, S as StreamCallbacks, c as TextTier } from './index-fXjxTR5W.cjs';
|
|
2
|
+
import { T as TextGenerationRequest, I as ImageGenerationRequest, V as VideoGenerationRequest, G as GeneratedContent, a as ImageToVideoRequest, b as VideoToVideoRequest } from './ProviderConfig-DIFa9nmG.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What a provider can serve. Replaces the old single `'multimodal'` type flag:
|
|
6
|
+
* a provider declares exactly the capabilities it implements, and the factory
|
|
7
|
+
* walks providers by capability when routing or failing over.
|
|
8
|
+
*/
|
|
9
|
+
type ProviderCapability = "text" | "image" | "video";
|
|
10
|
+
/** Cost estimation input — any generation request shape the fleet knows. */
|
|
11
|
+
type CostEstimateRequest = TextGenerationRequest | ImageGenerationRequest | VideoGenerationRequest;
|
|
12
|
+
interface IProviderBase {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly capabilities: ReadonlyArray<ProviderCapability>;
|
|
16
|
+
healthCheck(): Promise<ProviderHealth>;
|
|
17
|
+
estimateCost(request: CostEstimateRequest): Promise<number>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A provider that can turn conversations into text. This is the surface the
|
|
21
|
+
* factory's `chat`/`chatStream` walk; model choice per quality tier is the
|
|
22
|
+
* provider's own business (each maps neutral tiers onto its catalogue).
|
|
23
|
+
*/
|
|
24
|
+
interface ITextProvider extends IProviderBase {
|
|
25
|
+
generate(request: TextRequest): Promise<GenerationResult>;
|
|
26
|
+
generateStructured<T>(request: StructuredTextRequest): Promise<StructuredGeneration<T>>;
|
|
27
|
+
stream(request: TextRequest, callbacks: StreamCallbacks): Promise<GenerationResult>;
|
|
28
|
+
resolveModel(tier: TextTier): string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A provider that generates media. Kept as B's media surface — image/video
|
|
32
|
+
* request and result shapes are already provider-neutral.
|
|
33
|
+
*/
|
|
34
|
+
interface IMediaProvider extends IProviderBase {
|
|
35
|
+
generateImage(request: ImageGenerationRequest): Promise<GeneratedContent>;
|
|
36
|
+
generateVideo(request: VideoGenerationRequest): Promise<GeneratedContent>;
|
|
37
|
+
imageToVideo(request: ImageToVideoRequest): Promise<GeneratedContent>;
|
|
38
|
+
videoToVideo(request: VideoToVideoRequest): Promise<GeneratedContent>;
|
|
39
|
+
}
|
|
40
|
+
type AnyProvider = ITextProvider | IMediaProvider;
|
|
41
|
+
declare function isTextProvider(provider: AnyProvider): provider is ITextProvider;
|
|
42
|
+
declare function isMediaProvider(provider: AnyProvider): provider is IMediaProvider;
|
|
43
|
+
|
|
44
|
+
interface TextGenerationOptions {
|
|
45
|
+
maxTokens?: number;
|
|
46
|
+
temperature?: number;
|
|
47
|
+
topP?: number;
|
|
48
|
+
stopSequences?: string[];
|
|
49
|
+
model?: string;
|
|
50
|
+
}
|
|
51
|
+
interface ITextGenerator {
|
|
52
|
+
generateText(prompt: string, options?: TextGenerationOptions): Promise<string>;
|
|
53
|
+
generateTextStream(prompt: string, options?: TextGenerationOptions): AsyncGenerator<string>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface ProviderFactoryConfig {
|
|
57
|
+
/** Provider ids in preference order; unlisted providers follow in registration order. */
|
|
58
|
+
priority?: ReadonlyArray<string>;
|
|
59
|
+
fallbackEnabled?: boolean;
|
|
60
|
+
/** Tier used when a request names neither a model nor a tier. */
|
|
61
|
+
defaultTier?: TextTier;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Composition-aware registry and router. Replaces both ancestors at once:
|
|
65
|
+
* B's ProviderFactory (health TTL cache, priority fallback walk, media
|
|
66
|
+
* dispatch) and A's singleton configureProvider (via createAI). Adds the
|
|
67
|
+
* provider-neutral `chat`/`chatStream` text surface with full usage
|
|
68
|
+
* propagation, and keeps B's ITextGenerator string facade so the ported
|
|
69
|
+
* content services compile unchanged.
|
|
70
|
+
*/
|
|
71
|
+
declare class ProviderFactory implements ITextGenerator {
|
|
72
|
+
private readonly providers;
|
|
73
|
+
private readonly healthCache;
|
|
74
|
+
private readonly priority;
|
|
75
|
+
private readonly fallbackEnabled;
|
|
76
|
+
readonly defaultTier: TextTier;
|
|
77
|
+
constructor(config?: ProviderFactoryConfig);
|
|
78
|
+
register(provider: AnyProvider): void;
|
|
79
|
+
getProvider(id: string): AnyProvider | undefined;
|
|
80
|
+
getAllProviders(): AnyProvider[];
|
|
81
|
+
getByCapability(capability: ProviderCapability): AnyProvider[];
|
|
82
|
+
getTextProviders(): ITextProvider[];
|
|
83
|
+
hasTextProvider(): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Single-chat entry point: resolves a healthy text provider by priority,
|
|
86
|
+
* injects the default tier when the request names neither model nor tier,
|
|
87
|
+
* and walks the fallback chain on failure. Providers map tiers onto their
|
|
88
|
+
* own models, so switching Groq→Anthropic is a config change.
|
|
89
|
+
*/
|
|
90
|
+
chat(request: TextRequest): Promise<GenerationResult>;
|
|
91
|
+
chatStream(request: TextRequest, callbacks: StreamCallbacks): Promise<GenerationResult>;
|
|
92
|
+
/** AsyncGenerator adapter over chatStream — A's familiar consumption shape. */
|
|
93
|
+
streamText(request: TextRequest): AsyncGenerator<string>;
|
|
94
|
+
generateJson<T>(request: StructuredTextRequest): Promise<StructuredGeneration<T>>;
|
|
95
|
+
generateText(prompt: string, options?: TextGenerationOptions): Promise<string>;
|
|
96
|
+
generateTextStream(prompt: string, options?: TextGenerationOptions): AsyncGenerator<string>;
|
|
97
|
+
generateImage(request: ImageGenerationRequest): Promise<GeneratedContent>;
|
|
98
|
+
generateVideo(request: VideoGenerationRequest): Promise<GeneratedContent>;
|
|
99
|
+
imageToVideo(request: ImageToVideoRequest): Promise<GeneratedContent>;
|
|
100
|
+
videoToVideo(request: VideoToVideoRequest): Promise<GeneratedContent>;
|
|
101
|
+
checkProviderHealth(providerId: string, forceRefresh?: boolean): Promise<ProviderHealth>;
|
|
102
|
+
isProviderHealthy(providerId: string): boolean;
|
|
103
|
+
refreshAllHealth(): Promise<void>;
|
|
104
|
+
private executeWithFallback;
|
|
105
|
+
private orderByPriority;
|
|
106
|
+
private markDegraded;
|
|
107
|
+
private noProviderError;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { type AnyProvider as A, type CostEstimateRequest as C, type IMediaProvider as I, type ProviderCapability as P, type TextGenerationOptions as T, type IProviderBase as a, type ITextProvider as b, ProviderFactory as c, type ProviderFactoryConfig as d, isTextProvider as e, type ITextGenerator as f, isMediaProvider as i };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { P as ProviderHealth, T as TextRequest, G as GenerationResult, b as StructuredTextRequest, a as StructuredGeneration, S as StreamCallbacks, c as TextTier } from './index-fXjxTR5W.js';
|
|
2
|
+
import { T as TextGenerationRequest, I as ImageGenerationRequest, V as VideoGenerationRequest, G as GeneratedContent, a as ImageToVideoRequest, b as VideoToVideoRequest } from './ProviderConfig-DIFa9nmG.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What a provider can serve. Replaces the old single `'multimodal'` type flag:
|
|
6
|
+
* a provider declares exactly the capabilities it implements, and the factory
|
|
7
|
+
* walks providers by capability when routing or failing over.
|
|
8
|
+
*/
|
|
9
|
+
type ProviderCapability = "text" | "image" | "video";
|
|
10
|
+
/** Cost estimation input — any generation request shape the fleet knows. */
|
|
11
|
+
type CostEstimateRequest = TextGenerationRequest | ImageGenerationRequest | VideoGenerationRequest;
|
|
12
|
+
interface IProviderBase {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly capabilities: ReadonlyArray<ProviderCapability>;
|
|
16
|
+
healthCheck(): Promise<ProviderHealth>;
|
|
17
|
+
estimateCost(request: CostEstimateRequest): Promise<number>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A provider that can turn conversations into text. This is the surface the
|
|
21
|
+
* factory's `chat`/`chatStream` walk; model choice per quality tier is the
|
|
22
|
+
* provider's own business (each maps neutral tiers onto its catalogue).
|
|
23
|
+
*/
|
|
24
|
+
interface ITextProvider extends IProviderBase {
|
|
25
|
+
generate(request: TextRequest): Promise<GenerationResult>;
|
|
26
|
+
generateStructured<T>(request: StructuredTextRequest): Promise<StructuredGeneration<T>>;
|
|
27
|
+
stream(request: TextRequest, callbacks: StreamCallbacks): Promise<GenerationResult>;
|
|
28
|
+
resolveModel(tier: TextTier): string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A provider that generates media. Kept as B's media surface — image/video
|
|
32
|
+
* request and result shapes are already provider-neutral.
|
|
33
|
+
*/
|
|
34
|
+
interface IMediaProvider extends IProviderBase {
|
|
35
|
+
generateImage(request: ImageGenerationRequest): Promise<GeneratedContent>;
|
|
36
|
+
generateVideo(request: VideoGenerationRequest): Promise<GeneratedContent>;
|
|
37
|
+
imageToVideo(request: ImageToVideoRequest): Promise<GeneratedContent>;
|
|
38
|
+
videoToVideo(request: VideoToVideoRequest): Promise<GeneratedContent>;
|
|
39
|
+
}
|
|
40
|
+
type AnyProvider = ITextProvider | IMediaProvider;
|
|
41
|
+
declare function isTextProvider(provider: AnyProvider): provider is ITextProvider;
|
|
42
|
+
declare function isMediaProvider(provider: AnyProvider): provider is IMediaProvider;
|
|
43
|
+
|
|
44
|
+
interface TextGenerationOptions {
|
|
45
|
+
maxTokens?: number;
|
|
46
|
+
temperature?: number;
|
|
47
|
+
topP?: number;
|
|
48
|
+
stopSequences?: string[];
|
|
49
|
+
model?: string;
|
|
50
|
+
}
|
|
51
|
+
interface ITextGenerator {
|
|
52
|
+
generateText(prompt: string, options?: TextGenerationOptions): Promise<string>;
|
|
53
|
+
generateTextStream(prompt: string, options?: TextGenerationOptions): AsyncGenerator<string>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface ProviderFactoryConfig {
|
|
57
|
+
/** Provider ids in preference order; unlisted providers follow in registration order. */
|
|
58
|
+
priority?: ReadonlyArray<string>;
|
|
59
|
+
fallbackEnabled?: boolean;
|
|
60
|
+
/** Tier used when a request names neither a model nor a tier. */
|
|
61
|
+
defaultTier?: TextTier;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Composition-aware registry and router. Replaces both ancestors at once:
|
|
65
|
+
* B's ProviderFactory (health TTL cache, priority fallback walk, media
|
|
66
|
+
* dispatch) and A's singleton configureProvider (via createAI). Adds the
|
|
67
|
+
* provider-neutral `chat`/`chatStream` text surface with full usage
|
|
68
|
+
* propagation, and keeps B's ITextGenerator string facade so the ported
|
|
69
|
+
* content services compile unchanged.
|
|
70
|
+
*/
|
|
71
|
+
declare class ProviderFactory implements ITextGenerator {
|
|
72
|
+
private readonly providers;
|
|
73
|
+
private readonly healthCache;
|
|
74
|
+
private readonly priority;
|
|
75
|
+
private readonly fallbackEnabled;
|
|
76
|
+
readonly defaultTier: TextTier;
|
|
77
|
+
constructor(config?: ProviderFactoryConfig);
|
|
78
|
+
register(provider: AnyProvider): void;
|
|
79
|
+
getProvider(id: string): AnyProvider | undefined;
|
|
80
|
+
getAllProviders(): AnyProvider[];
|
|
81
|
+
getByCapability(capability: ProviderCapability): AnyProvider[];
|
|
82
|
+
getTextProviders(): ITextProvider[];
|
|
83
|
+
hasTextProvider(): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Single-chat entry point: resolves a healthy text provider by priority,
|
|
86
|
+
* injects the default tier when the request names neither model nor tier,
|
|
87
|
+
* and walks the fallback chain on failure. Providers map tiers onto their
|
|
88
|
+
* own models, so switching Groq→Anthropic is a config change.
|
|
89
|
+
*/
|
|
90
|
+
chat(request: TextRequest): Promise<GenerationResult>;
|
|
91
|
+
chatStream(request: TextRequest, callbacks: StreamCallbacks): Promise<GenerationResult>;
|
|
92
|
+
/** AsyncGenerator adapter over chatStream — A's familiar consumption shape. */
|
|
93
|
+
streamText(request: TextRequest): AsyncGenerator<string>;
|
|
94
|
+
generateJson<T>(request: StructuredTextRequest): Promise<StructuredGeneration<T>>;
|
|
95
|
+
generateText(prompt: string, options?: TextGenerationOptions): Promise<string>;
|
|
96
|
+
generateTextStream(prompt: string, options?: TextGenerationOptions): AsyncGenerator<string>;
|
|
97
|
+
generateImage(request: ImageGenerationRequest): Promise<GeneratedContent>;
|
|
98
|
+
generateVideo(request: VideoGenerationRequest): Promise<GeneratedContent>;
|
|
99
|
+
imageToVideo(request: ImageToVideoRequest): Promise<GeneratedContent>;
|
|
100
|
+
videoToVideo(request: VideoToVideoRequest): Promise<GeneratedContent>;
|
|
101
|
+
checkProviderHealth(providerId: string, forceRefresh?: boolean): Promise<ProviderHealth>;
|
|
102
|
+
isProviderHealthy(providerId: string): boolean;
|
|
103
|
+
refreshAllHealth(): Promise<void>;
|
|
104
|
+
private executeWithFallback;
|
|
105
|
+
private orderByPriority;
|
|
106
|
+
private markDegraded;
|
|
107
|
+
private noProviderError;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { type AnyProvider as A, type CostEstimateRequest as C, type IMediaProvider as I, type ProviderCapability as P, type TextGenerationOptions as T, type IProviderBase as a, type ITextProvider as b, ProviderFactory as c, type ProviderFactoryConfig as d, isTextProvider as e, type ITextGenerator as f, isMediaProvider as i };
|