@umituz/web-ai 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +29 -3
  2. package/dist/{cancellation-error-_39nYWwz.d.cts → cancellation-error-BWb59Wkj.d.cts} +1 -1
  3. package/dist/{cancellation-error-hYcE9AS9.d.ts → cancellation-error-D9LETLCD.d.ts} +1 -1
  4. package/dist/chat/index.cjs +1 -0
  5. package/dist/chat/index.cjs.map +1 -1
  6. package/dist/chat/index.js +1 -0
  7. package/dist/chat/index.js.map +1 -1
  8. package/dist/content/index.cjs +622 -8
  9. package/dist/content/index.cjs.map +1 -1
  10. package/dist/content/index.d.cts +2 -2
  11. package/dist/content/index.d.ts +2 -2
  12. package/dist/content/index.js +622 -8
  13. package/dist/content/index.js.map +1 -1
  14. package/dist/context-manager-CuZz0vnC.d.cts +104 -0
  15. package/dist/context-manager-CuZz0vnC.d.ts +104 -0
  16. package/dist/core/index.cjs +147 -10
  17. package/dist/core/index.cjs.map +1 -1
  18. package/dist/core/index.d.cts +91 -73
  19. package/dist/core/index.d.ts +91 -73
  20. package/dist/core/index.js +141 -11
  21. package/dist/core/index.js.map +1 -1
  22. package/dist/{create-ai-D-oEWzf9.d.ts → create-ai-Cq3HkJxd.d.ts} +61 -1
  23. package/dist/{create-ai-DRysRImc.d.cts → create-ai-DDyTVzef.d.cts} +61 -1
  24. package/dist/hooks/index.cjs +747 -15
  25. package/dist/hooks/index.cjs.map +1 -1
  26. package/dist/hooks/index.d.cts +57 -4
  27. package/dist/hooks/index.d.ts +57 -4
  28. package/dist/hooks/index.js +746 -16
  29. package/dist/hooks/index.js.map +1 -1
  30. package/dist/index.cjs +1180 -242
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +7 -6
  33. package/dist/index.d.ts +7 -6
  34. package/dist/index.js +1140 -243
  35. package/dist/index.js.map +1 -1
  36. package/dist/providers/index.cjs +1212 -362
  37. package/dist/providers/index.cjs.map +1 -1
  38. package/dist/providers/index.d.cts +422 -10
  39. package/dist/providers/index.d.ts +422 -10
  40. package/dist/providers/index.js +1179 -363
  41. package/dist/providers/index.js.map +1 -1
  42. package/dist/remote-chat-client-LrNlew4n.d.cts +70 -0
  43. package/dist/remote-chat-client-LrNlew4n.d.ts +70 -0
  44. package/dist/{requestQueue-D89wx91Q.d.cts → requestQueue--h2uZ-Q3.d.cts} +1 -1
  45. package/dist/{requestQueue-AP6n_bRH.d.ts → requestQueue-BGeCy4Fd.d.ts} +1 -1
  46. package/package.json +1 -1
  47. package/dist/tool-call-accumulator-C7KhaXZA.d.cts +0 -69
  48. package/dist/tool-call-accumulator-C7KhaXZA.d.ts +0 -69
@@ -3,12 +3,14 @@ import { d as AIErrorCode, t as SentimentAnalysisResult, C as ContentAnalysisReq
3
3
  export { f as AspectRatio, h as CreditCost, i as GENERATION_COSTS, j as GenerationMetadata, x as calculateCreditCost } from '../AIErrors-_IyXRWj1.cjs';
4
4
  import { d as ProviderConfig, I as ImageGenerationRequest, G as GeneratedContent, V as VideoGenerationRequest, a as ImageToVideoRequest, b as VideoToVideoRequest } from '../ProviderConfig-DIFa9nmG.cjs';
5
5
  import { c as ITextGenerator, d as ITextProvider, e as ProviderFactory } from '../provider.factory-Ce6Een1G.cjs';
6
- import { A as AIProviderConfig, q as GroqGenerationConfig } from '../create-ai-DRysRImc.cjs';
6
+ import { A as AIProviderConfig, q as GroqGenerationConfig } from '../create-ai-DDyTVzef.cjs';
7
7
  import { b as TextTier } from '../index-OhvYUTXf.cjs';
8
8
  import { C as CacheManager, b as CacheStats } from '../cache-manager-Df9LLYGA.cjs';
9
9
  import { d as ChatService, U as UseChatOptions, k as UseChatReturn } from '../chat.service-8MaW9pum.cjs';
10
- import { T as TextGenerationService, j as PrunaResult, G as GenerateOptions, e as PrunaInput, a as GenerationStage } from '../cancellation-error-_39nYWwz.cjs';
11
- export { C as CancellationError } from '../cancellation-error-_39nYWwz.cjs';
10
+ import { T as TextGenerationService, j as PrunaResult, G as GenerateOptions, e as PrunaInput, a as GenerationStage } from '../cancellation-error-BWb59Wkj.cjs';
11
+ export { C as CancellationError } from '../cancellation-error-BWb59Wkj.cjs';
12
+ import { Dispatch, SetStateAction } from 'react';
13
+ import { R as RemoteChatClient, b as RemoteChatStreamBody } from '../remote-chat-client-LrNlew4n.cjs';
12
14
  import '../index-Dv8gRzAu.cjs';
13
15
 
14
16
  /** Provider config for the underlying AIContentService — new AIProviderConfig,
@@ -244,6 +246,57 @@ interface UseGroqDeps {
244
246
  }
245
247
  declare function useGroq(options?: UseGroqOptions, deps?: UseGroqDeps): UseGroqReturn;
246
248
 
249
+ type RemoteChatMessageStatus = "pending" | "streaming" | "complete" | "stopped" | "error";
250
+ interface RemoteChatUsage {
251
+ readonly inputTokens: number;
252
+ readonly outputTokens: number;
253
+ readonly reasoningTokens?: number;
254
+ }
255
+ interface RemoteChatMessage {
256
+ readonly id: string;
257
+ readonly role: "user" | "assistant";
258
+ readonly content: string;
259
+ readonly reasoning: string;
260
+ readonly status: RemoteChatMessageStatus;
261
+ readonly error: {
262
+ readonly code: string;
263
+ readonly message: string;
264
+ } | null;
265
+ readonly usage: RemoteChatUsage | null;
266
+ }
267
+ /** Placeholder id for the assistant message while it streams; replaced by
268
+ * the persisted id on `done`. */
269
+ declare const REMOTE_CHAT_STREAMING_ID = "streaming";
270
+ interface UseRemoteChatOptions<TToolCall = unknown> {
271
+ readonly client: RemoteChatClient;
272
+ /** Called for every `tool_call` event (pending approval, etc.). */
273
+ readonly onToolCall?: (toolCall: TToolCall) => void;
274
+ /** Called once per finished stream (success, error, or abort). */
275
+ readonly onStreamEnd?: (info: {
276
+ readonly conversationId: string;
277
+ readonly stopped: boolean;
278
+ }) => void | Promise<void>;
279
+ /** Id factory for the optimistic user echo. */
280
+ readonly localUserId?: () => string;
281
+ }
282
+ interface UseRemoteChatReturn {
283
+ readonly messages: ReadonlyArray<RemoteChatMessage>;
284
+ setMessages: Dispatch<SetStateAction<RemoteChatMessage[]>>;
285
+ readonly isStreaming: boolean;
286
+ readonly isResolving: boolean;
287
+ /** Start a stream; `localUserContent` echoes the user message optimistically. */
288
+ stream(conversationId: string, body: RemoteChatStreamBody, opts?: {
289
+ readonly localUserContent?: string;
290
+ }): Promise<void>;
291
+ /** Approve/reject a tool call and consume the continuation stream. */
292
+ resolveToolCall(conversationId: string, toolCallId: string, approved: boolean): Promise<boolean>;
293
+ /** Abort the active stream; the next `onStreamEnd` reports `stopped: true`. */
294
+ abort(): void;
295
+ /** Patch the last message (status/id/usage updates). */
296
+ patchLast(patch: Partial<RemoteChatMessage>): void;
297
+ }
298
+ declare function useRemoteChat<TToolCall = unknown>(options: UseRemoteChatOptions<TToolCall>): UseRemoteChatReturn;
299
+
247
300
  interface AsyncActionState<TResult> {
248
301
  result: TResult | null;
249
302
  isLoading: boolean;
@@ -279,4 +332,4 @@ interface UsePrunaProxyOptions {
279
332
  type UsePrunaProxyReturn = AsyncActionApi<PrunaResult, PrunaInput>;
280
333
  declare function usePrunaProxy(options: UsePrunaProxyOptions): UsePrunaProxyReturn;
281
334
 
282
- export { type AsyncActionApi, type AsyncActionExecutor, type AsyncActionState, type ContentWizardRequest, type CreditCheckFunction, GenerationProgress, GenerationResult, GenerationStatus, GenerationType, ImageGenerationInput, ImageQuality, type SaveFunction, type UploadFunction, type UseAIContentOptions, type UseAIContentReturn, type UseAIGenerationOptions, type UseAIGenerationReturn, type UseAsyncActionOptions, type UseBlogGeneratorOptions, type UseBlogGeneratorReturn, type UseCacheStatsOptions, type UseChatDeps, type UseContentWizardOptions, type UseContentWizardReturn, type UseGroqDeps, type UseGroqOptions, type UseGroqReturn, type UseImageWizardOptions, type UseImageWizardReturn, type UsePrunaGenerationOptions, type UsePrunaGenerationReturn, type UsePrunaProxyOptions, type UsePrunaProxyReturn, type UseSocialContentGeneratorOptions, type UseSocialContentGeneratorReturn, type UseTextConfig, type UseTextDeps, type UseTextOptions, type UseTextReturn, type UseVideoWizardOptions, type UseVideoWizardReturn, VideoGenerationInput, VideoQuality, type VideoWizardRequest, useAIContent, useAIGeneration, useAsyncAction, useBlogGenerator, useCacheStats, useChat, useContentWizard, useGroq, useImageWizard, usePrunaGeneration, usePrunaProxy, useSocialContentGenerator, useText, useVideoWizard };
335
+ export { type AsyncActionApi, type AsyncActionExecutor, type AsyncActionState, type ContentWizardRequest, type CreditCheckFunction, GenerationProgress, GenerationResult, GenerationStatus, GenerationType, ImageGenerationInput, ImageQuality, REMOTE_CHAT_STREAMING_ID, type RemoteChatMessage, type RemoteChatMessageStatus, type RemoteChatUsage, type SaveFunction, type UploadFunction, type UseAIContentOptions, type UseAIContentReturn, type UseAIGenerationOptions, type UseAIGenerationReturn, type UseAsyncActionOptions, type UseBlogGeneratorOptions, type UseBlogGeneratorReturn, type UseCacheStatsOptions, type UseChatDeps, type UseContentWizardOptions, type UseContentWizardReturn, type UseGroqDeps, type UseGroqOptions, type UseGroqReturn, type UseImageWizardOptions, type UseImageWizardReturn, type UsePrunaGenerationOptions, type UsePrunaGenerationReturn, type UsePrunaProxyOptions, type UsePrunaProxyReturn, type UseRemoteChatOptions, type UseRemoteChatReturn, type UseSocialContentGeneratorOptions, type UseSocialContentGeneratorReturn, type UseTextConfig, type UseTextDeps, type UseTextOptions, type UseTextReturn, type UseVideoWizardOptions, type UseVideoWizardReturn, VideoGenerationInput, VideoQuality, type VideoWizardRequest, useAIContent, useAIGeneration, useAsyncAction, useBlogGenerator, useCacheStats, useChat, useContentWizard, useGroq, useImageWizard, usePrunaGeneration, usePrunaProxy, useRemoteChat, useSocialContentGenerator, useText, useVideoWizard };
@@ -3,12 +3,14 @@ import { d as AIErrorCode, t as SentimentAnalysisResult, C as ContentAnalysisReq
3
3
  export { f as AspectRatio, h as CreditCost, i as GENERATION_COSTS, j as GenerationMetadata, x as calculateCreditCost } from '../AIErrors-TuSFl--T.js';
4
4
  import { d as ProviderConfig, I as ImageGenerationRequest, G as GeneratedContent, V as VideoGenerationRequest, a as ImageToVideoRequest, b as VideoToVideoRequest } from '../ProviderConfig-DIFa9nmG.js';
5
5
  import { c as ITextGenerator, d as ITextProvider, e as ProviderFactory } from '../provider.factory-B9RNUTYj.js';
6
- import { A as AIProviderConfig, q as GroqGenerationConfig } from '../create-ai-D-oEWzf9.js';
6
+ import { A as AIProviderConfig, q as GroqGenerationConfig } from '../create-ai-Cq3HkJxd.js';
7
7
  import { b as TextTier } from '../index-OhvYUTXf.js';
8
8
  import { C as CacheManager, b as CacheStats } from '../cache-manager-Df9LLYGA.js';
9
9
  import { d as ChatService, U as UseChatOptions, k as UseChatReturn } from '../chat.service-B4Isrckn.js';
10
- import { T as TextGenerationService, j as PrunaResult, G as GenerateOptions, e as PrunaInput, a as GenerationStage } from '../cancellation-error-hYcE9AS9.js';
11
- export { C as CancellationError } from '../cancellation-error-hYcE9AS9.js';
10
+ import { T as TextGenerationService, j as PrunaResult, G as GenerateOptions, e as PrunaInput, a as GenerationStage } from '../cancellation-error-D9LETLCD.js';
11
+ export { C as CancellationError } from '../cancellation-error-D9LETLCD.js';
12
+ import { Dispatch, SetStateAction } from 'react';
13
+ import { R as RemoteChatClient, b as RemoteChatStreamBody } from '../remote-chat-client-LrNlew4n.js';
12
14
  import '../index-1e91KRYU.js';
13
15
 
14
16
  /** Provider config for the underlying AIContentService — new AIProviderConfig,
@@ -244,6 +246,57 @@ interface UseGroqDeps {
244
246
  }
245
247
  declare function useGroq(options?: UseGroqOptions, deps?: UseGroqDeps): UseGroqReturn;
246
248
 
249
+ type RemoteChatMessageStatus = "pending" | "streaming" | "complete" | "stopped" | "error";
250
+ interface RemoteChatUsage {
251
+ readonly inputTokens: number;
252
+ readonly outputTokens: number;
253
+ readonly reasoningTokens?: number;
254
+ }
255
+ interface RemoteChatMessage {
256
+ readonly id: string;
257
+ readonly role: "user" | "assistant";
258
+ readonly content: string;
259
+ readonly reasoning: string;
260
+ readonly status: RemoteChatMessageStatus;
261
+ readonly error: {
262
+ readonly code: string;
263
+ readonly message: string;
264
+ } | null;
265
+ readonly usage: RemoteChatUsage | null;
266
+ }
267
+ /** Placeholder id for the assistant message while it streams; replaced by
268
+ * the persisted id on `done`. */
269
+ declare const REMOTE_CHAT_STREAMING_ID = "streaming";
270
+ interface UseRemoteChatOptions<TToolCall = unknown> {
271
+ readonly client: RemoteChatClient;
272
+ /** Called for every `tool_call` event (pending approval, etc.). */
273
+ readonly onToolCall?: (toolCall: TToolCall) => void;
274
+ /** Called once per finished stream (success, error, or abort). */
275
+ readonly onStreamEnd?: (info: {
276
+ readonly conversationId: string;
277
+ readonly stopped: boolean;
278
+ }) => void | Promise<void>;
279
+ /** Id factory for the optimistic user echo. */
280
+ readonly localUserId?: () => string;
281
+ }
282
+ interface UseRemoteChatReturn {
283
+ readonly messages: ReadonlyArray<RemoteChatMessage>;
284
+ setMessages: Dispatch<SetStateAction<RemoteChatMessage[]>>;
285
+ readonly isStreaming: boolean;
286
+ readonly isResolving: boolean;
287
+ /** Start a stream; `localUserContent` echoes the user message optimistically. */
288
+ stream(conversationId: string, body: RemoteChatStreamBody, opts?: {
289
+ readonly localUserContent?: string;
290
+ }): Promise<void>;
291
+ /** Approve/reject a tool call and consume the continuation stream. */
292
+ resolveToolCall(conversationId: string, toolCallId: string, approved: boolean): Promise<boolean>;
293
+ /** Abort the active stream; the next `onStreamEnd` reports `stopped: true`. */
294
+ abort(): void;
295
+ /** Patch the last message (status/id/usage updates). */
296
+ patchLast(patch: Partial<RemoteChatMessage>): void;
297
+ }
298
+ declare function useRemoteChat<TToolCall = unknown>(options: UseRemoteChatOptions<TToolCall>): UseRemoteChatReturn;
299
+
247
300
  interface AsyncActionState<TResult> {
248
301
  result: TResult | null;
249
302
  isLoading: boolean;
@@ -279,4 +332,4 @@ interface UsePrunaProxyOptions {
279
332
  type UsePrunaProxyReturn = AsyncActionApi<PrunaResult, PrunaInput>;
280
333
  declare function usePrunaProxy(options: UsePrunaProxyOptions): UsePrunaProxyReturn;
281
334
 
282
- export { type AsyncActionApi, type AsyncActionExecutor, type AsyncActionState, type ContentWizardRequest, type CreditCheckFunction, GenerationProgress, GenerationResult, GenerationStatus, GenerationType, ImageGenerationInput, ImageQuality, type SaveFunction, type UploadFunction, type UseAIContentOptions, type UseAIContentReturn, type UseAIGenerationOptions, type UseAIGenerationReturn, type UseAsyncActionOptions, type UseBlogGeneratorOptions, type UseBlogGeneratorReturn, type UseCacheStatsOptions, type UseChatDeps, type UseContentWizardOptions, type UseContentWizardReturn, type UseGroqDeps, type UseGroqOptions, type UseGroqReturn, type UseImageWizardOptions, type UseImageWizardReturn, type UsePrunaGenerationOptions, type UsePrunaGenerationReturn, type UsePrunaProxyOptions, type UsePrunaProxyReturn, type UseSocialContentGeneratorOptions, type UseSocialContentGeneratorReturn, type UseTextConfig, type UseTextDeps, type UseTextOptions, type UseTextReturn, type UseVideoWizardOptions, type UseVideoWizardReturn, VideoGenerationInput, VideoQuality, type VideoWizardRequest, useAIContent, useAIGeneration, useAsyncAction, useBlogGenerator, useCacheStats, useChat, useContentWizard, useGroq, useImageWizard, usePrunaGeneration, usePrunaProxy, useSocialContentGenerator, useText, useVideoWizard };
335
+ export { type AsyncActionApi, type AsyncActionExecutor, type AsyncActionState, type ContentWizardRequest, type CreditCheckFunction, GenerationProgress, GenerationResult, GenerationStatus, GenerationType, ImageGenerationInput, ImageQuality, REMOTE_CHAT_STREAMING_ID, type RemoteChatMessage, type RemoteChatMessageStatus, type RemoteChatUsage, type SaveFunction, type UploadFunction, type UseAIContentOptions, type UseAIContentReturn, type UseAIGenerationOptions, type UseAIGenerationReturn, type UseAsyncActionOptions, type UseBlogGeneratorOptions, type UseBlogGeneratorReturn, type UseCacheStatsOptions, type UseChatDeps, type UseContentWizardOptions, type UseContentWizardReturn, type UseGroqDeps, type UseGroqOptions, type UseGroqReturn, type UseImageWizardOptions, type UseImageWizardReturn, type UsePrunaGenerationOptions, type UsePrunaGenerationReturn, type UsePrunaProxyOptions, type UsePrunaProxyReturn, type UseRemoteChatOptions, type UseRemoteChatReturn, type UseSocialContentGeneratorOptions, type UseSocialContentGeneratorReturn, type UseTextConfig, type UseTextDeps, type UseTextOptions, type UseTextReturn, type UseVideoWizardOptions, type UseVideoWizardReturn, VideoGenerationInput, VideoQuality, type VideoWizardRequest, useAIContent, useAIGeneration, useAsyncAction, useBlogGenerator, useCacheStats, useChat, useContentWizard, useGroq, useImageWizard, usePrunaGeneration, usePrunaProxy, useRemoteChat, useSocialContentGenerator, useText, useVideoWizard };