@aginies/webuikit 0.2.0 → 0.3.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/index.d.cts CHANGED
@@ -9,8 +9,13 @@ import { ButtonHTMLAttributes, HTMLAttributes, InputHTMLAttributes, TextareaHTML
9
9
  interface AginiesConfig {
10
10
  /** Platform origin, e.g. `https://app.example.com`. No trailing slash. */
11
11
  baseUrl: string;
12
- /** Activation token issued for the deployment. Without it nothing renders. */
13
- token: string;
12
+ /** Activation token issued for the deployment. Without it nothing renders, unless `hosted`. */
13
+ token?: string;
14
+ /**
15
+ * The platform's own pages: the widget runs on the platform origin and activates
16
+ * without a token. Refused from any other origin.
17
+ */
18
+ hosted?: boolean;
14
19
  /** UI language. Defaults to the document language, then English. */
15
20
  locale?: 'tr' | 'en';
16
21
  /** Fetch implementation override (tests, SSR). */
@@ -67,6 +72,16 @@ interface ChatConfig {
67
72
  blockId: string;
68
73
  path?: string;
69
74
  }>;
75
+ /** What the platform can do with speech for this chat. */
76
+ voice?: {
77
+ stt: boolean;
78
+ tts: boolean;
79
+ };
80
+ }
81
+ interface Transcription {
82
+ transcript: string;
83
+ language?: string;
84
+ duration?: number;
70
85
  }
71
86
  interface ChatAuthRequired {
72
87
  authRequired: ChatConfig['authType'];
@@ -108,7 +123,8 @@ declare class AginiesError extends Error {
108
123
  }
109
124
  declare class AginiesClient {
110
125
  readonly baseUrl: string;
111
- readonly token: string;
126
+ readonly token: string | null;
127
+ private readonly hosted;
112
128
  readonly locale: 'tr' | 'en';
113
129
  private readonly fetchImpl;
114
130
  private state;
@@ -143,6 +159,10 @@ declare class AginiesClient {
143
159
  private request;
144
160
  /** A raw request against the platform for endpoints the client does not wrap. */
145
161
  fetchRaw(path: string, init?: RequestInit): Promise<Response>;
162
+ /** Sends a recording to the platform's transcription model. */
163
+ transcribe(identifier: string, audio: Blob, filename?: string, language?: string): Promise<Transcription>;
164
+ /** Audio for a reply from the platform's synthesis endpoint. */
165
+ speak(identifier: string, text: string): Promise<Blob>;
146
166
  /** Hosted-chat configuration. Resolves to an auth requirement instead of throwing on 401. */
147
167
  getChat(identifier: string): Promise<ChatConfig | ChatAuthRequired>;
148
168
  /**
@@ -396,9 +416,14 @@ interface ChatWidgetProps {
396
416
  defaultOpen?: boolean;
397
417
  /** Theme for the widget subtree; `auto` follows the host page. */
398
418
  theme?: 'dark' | 'light' | 'auto';
419
+ /**
420
+ * Offer dictation and a hands-free voice conversation when the platform provides speech
421
+ * for this chat and the browser can record. Default true.
422
+ */
423
+ voice?: boolean;
399
424
  className?: string;
400
425
  }
401
- declare function ChatWidget({ identifier, mode, position, launcherLabel, defaultOpen, theme, className, }: ChatWidgetProps): react.JSX.Element | null;
426
+ declare function ChatWidget({ identifier, mode, position, launcherLabel, defaultOpen, theme, voice, className, }: ChatWidgetProps): react.JSX.Element | null;
402
427
 
403
428
  /**
404
429
  * Small Markdown renderer for agent replies. It builds React elements directly, so nothing
@@ -410,6 +435,44 @@ declare function Markdown({ text, className }: {
410
435
  className?: string;
411
436
  }): react.JSX.Element;
412
437
 
438
+ /**
439
+ * Voice for the chat widget: records the visitor with the browser's recorder, sends the
440
+ * clip to the platform (which runs its own transcription model) and plays replies back
441
+ * from the platform's synthesis endpoint. No third-party browser speech API is involved,
442
+ * so it behaves the same in every browser and the audio never leaves the platform.
443
+ */
444
+ type VoiceState = 'idle' | 'listening' | 'transcribing' | 'speaking' | 'denied' | 'unsupported';
445
+ interface UseVoiceOptions {
446
+ identifier: string;
447
+ /** Receives the transcript of a finished recording; empty recordings are dropped. */
448
+ onTranscript: (text: string) => void;
449
+ /** Language hint for transcription; omit for auto-detection. */
450
+ language?: string;
451
+ /** Stop recording after this much silence once speech was heard. */
452
+ silenceMs?: number;
453
+ /** Longest single recording. */
454
+ maxMs?: number;
455
+ }
456
+ interface VoiceControls {
457
+ state: VoiceState;
458
+ /** Last failure, cleared on the next successful action. */
459
+ error: string | null;
460
+ /** Whether this browser can record at all. */
461
+ supported: boolean;
462
+ /** Input level 0..1 while listening, for a meter. */
463
+ level: number;
464
+ startListening: () => Promise<void>;
465
+ /** Ends the recording and transcribes it. */
466
+ stopListening: () => void;
467
+ /** Ends the recording and discards it. */
468
+ cancelListening: () => void;
469
+ /** Plays a reply; resolves when playback ends or is stopped. */
470
+ speak: (text: string) => Promise<void>;
471
+ stopSpeaking: () => void;
472
+ }
473
+ declare function isVoiceSupported(): boolean;
474
+ declare function useVoice({ identifier, onTranscript, language, silenceMs, maxMs, }: UseVoiceOptions): VoiceControls;
475
+
413
476
  /** Joins class names, dropping falsy entries. */
414
477
  declare function cx(...parts: Array<string | false | null | undefined>): string;
415
478
  interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
@@ -615,6 +678,68 @@ declare const STRINGS: {
615
678
  readonly en: "Sign in";
616
679
  };
617
680
  };
681
+ readonly voice: {
682
+ readonly talk: {
683
+ readonly tr: "Konuşmak için dokunun";
684
+ readonly en: "Tap to talk";
685
+ };
686
+ readonly stopTalking: {
687
+ readonly tr: "Bitirmek için dokunun";
688
+ readonly en: "Tap when done";
689
+ };
690
+ readonly dictate: {
691
+ readonly tr: "Sesle yaz";
692
+ readonly en: "Dictate";
693
+ };
694
+ readonly handsFree: {
695
+ readonly tr: "Sesli sohbet";
696
+ readonly en: "Voice conversation";
697
+ };
698
+ readonly exit: {
699
+ readonly tr: "Sesli sohbetten çık";
700
+ readonly en: "Leave voice conversation";
701
+ };
702
+ readonly listening: {
703
+ readonly tr: "Dinliyor";
704
+ readonly en: "Listening";
705
+ };
706
+ readonly transcribing: {
707
+ readonly tr: "Yazıya dökülüyor";
708
+ readonly en: "Transcribing";
709
+ };
710
+ readonly thinking: {
711
+ readonly tr: "Yanıt hazırlanıyor";
712
+ readonly en: "Working on it";
713
+ };
714
+ readonly speaking: {
715
+ readonly tr: "Konuşuyor";
716
+ readonly en: "Speaking";
717
+ };
718
+ readonly idle: {
719
+ readonly tr: "Hazır";
720
+ readonly en: "Ready";
721
+ };
722
+ readonly interrupt: {
723
+ readonly tr: "Sözünü kesmek için dokunun";
724
+ readonly en: "Tap to interrupt";
725
+ };
726
+ readonly micDenied: {
727
+ readonly tr: "Mikrofon izni verilmedi. Tarayıcı ayarlarından izin verin.";
728
+ readonly en: "Microphone access was denied. Allow it in your browser settings.";
729
+ };
730
+ readonly unsupported: {
731
+ readonly tr: "Bu tarayıcı ses kaydını desteklemiyor.";
732
+ readonly en: "This browser cannot record audio.";
733
+ };
734
+ readonly unavailable: {
735
+ readonly tr: "Ses özelliği bu sohbet için açık değil.";
736
+ readonly en: "Voice is not enabled for this chat.";
737
+ };
738
+ readonly error: {
739
+ readonly tr: "Ses işlenemedi. Lütfen tekrar deneyin.";
740
+ readonly en: "Voice could not be processed. Please try again.";
741
+ };
742
+ };
618
743
  readonly run: {
619
744
  readonly submit: {
620
745
  readonly tr: "Çalıştır";
@@ -962,4 +1087,4 @@ declare function runAgent(client: AginiesClient, workflowId: string, options: Ru
962
1087
  /** Decodes an execute SSE body into run events. Exported for tests. */
963
1088
  declare function parseRunSSE(stream: ReadableStream<Uint8Array>): AsyncGenerator<RunEvent>;
964
1089
 
965
- export { ATTACHMENT_LIMITS, type ActivationConfig, type ActivationSession, type ActivationState, AgentRunner, type AgentRunnerProps, AginiesClient, type AginiesConfig, AginiesError, AginiesProvider, type AginiesProviderProps, ApprovalPanel, type ApprovalPanelProps, type ApprovalStatus, Button, type ButtonProps, type ChatAttachment, type ChatAuthRequired, type ChatConfig, type ChatFilePayload, type ChatMessage, type ChatStreamEvent, ChatWidget, type ChatWidgetProps, Chip, type CodeRequestResult, type CostBarItem, CostBars, type CostBarsProps, Eyebrow, Field, type HeatmapRow, Input, type Locale, Markdown, Panel, type PauseContext, type PausePoint, type PausedExecution, type ResumeField, type ResumeOutcome, type ResumeQueueEntry, type ResumeStatus, type RunEvent, type RunField, type RunOptions, type RunStatus, type RunStep, RunTimeline, type RunTimelineProps, type SendMessageInput, Spinner, Stat, type StatItem, StatTiles, type StructuredItem, type StructuredResponse, StructuredUI, SuccessHeatmap, type SuccessHeatmapProps, Tag, Textarea, type TimelineStep, buildSubmission, cx, fieldsOf, formatFieldValue, getClient, getPauseContext, getPausedExecution, init, initialValues, listPausedExecutions, outputOf, parseFieldValue, parseRunSSE, parseSSE, parseStructured, resumeExecution, runAgent, translator, useAgentRun, useAginies, useApproval, useChat, useModule };
1090
+ export { ATTACHMENT_LIMITS, type ActivationConfig, type ActivationSession, type ActivationState, AgentRunner, type AgentRunnerProps, AginiesClient, type AginiesConfig, AginiesError, AginiesProvider, type AginiesProviderProps, ApprovalPanel, type ApprovalPanelProps, type ApprovalStatus, Button, type ButtonProps, type ChatAttachment, type ChatAuthRequired, type ChatConfig, type ChatFilePayload, type ChatMessage, type ChatStreamEvent, ChatWidget, type ChatWidgetProps, Chip, type CodeRequestResult, type CostBarItem, CostBars, type CostBarsProps, Eyebrow, Field, type HeatmapRow, Input, type Locale, Markdown, Panel, type PauseContext, type PausePoint, type PausedExecution, type ResumeField, type ResumeOutcome, type ResumeQueueEntry, type ResumeStatus, type RunEvent, type RunField, type RunOptions, type RunStatus, type RunStep, RunTimeline, type RunTimelineProps, type SendMessageInput, Spinner, Stat, type StatItem, StatTiles, type StructuredItem, type StructuredResponse, StructuredUI, SuccessHeatmap, type SuccessHeatmapProps, Tag, Textarea, type TimelineStep, type Transcription, type UseVoiceOptions, type VoiceControls, type VoiceState, buildSubmission, cx, fieldsOf, formatFieldValue, getClient, getPauseContext, getPausedExecution, init, initialValues, isVoiceSupported, listPausedExecutions, outputOf, parseFieldValue, parseRunSSE, parseSSE, parseStructured, resumeExecution, runAgent, translator, useAgentRun, useAginies, useApproval, useChat, useModule, useVoice };
package/dist/index.d.ts CHANGED
@@ -9,8 +9,13 @@ import { ButtonHTMLAttributes, HTMLAttributes, InputHTMLAttributes, TextareaHTML
9
9
  interface AginiesConfig {
10
10
  /** Platform origin, e.g. `https://app.example.com`. No trailing slash. */
11
11
  baseUrl: string;
12
- /** Activation token issued for the deployment. Without it nothing renders. */
13
- token: string;
12
+ /** Activation token issued for the deployment. Without it nothing renders, unless `hosted`. */
13
+ token?: string;
14
+ /**
15
+ * The platform's own pages: the widget runs on the platform origin and activates
16
+ * without a token. Refused from any other origin.
17
+ */
18
+ hosted?: boolean;
14
19
  /** UI language. Defaults to the document language, then English. */
15
20
  locale?: 'tr' | 'en';
16
21
  /** Fetch implementation override (tests, SSR). */
@@ -67,6 +72,16 @@ interface ChatConfig {
67
72
  blockId: string;
68
73
  path?: string;
69
74
  }>;
75
+ /** What the platform can do with speech for this chat. */
76
+ voice?: {
77
+ stt: boolean;
78
+ tts: boolean;
79
+ };
80
+ }
81
+ interface Transcription {
82
+ transcript: string;
83
+ language?: string;
84
+ duration?: number;
70
85
  }
71
86
  interface ChatAuthRequired {
72
87
  authRequired: ChatConfig['authType'];
@@ -108,7 +123,8 @@ declare class AginiesError extends Error {
108
123
  }
109
124
  declare class AginiesClient {
110
125
  readonly baseUrl: string;
111
- readonly token: string;
126
+ readonly token: string | null;
127
+ private readonly hosted;
112
128
  readonly locale: 'tr' | 'en';
113
129
  private readonly fetchImpl;
114
130
  private state;
@@ -143,6 +159,10 @@ declare class AginiesClient {
143
159
  private request;
144
160
  /** A raw request against the platform for endpoints the client does not wrap. */
145
161
  fetchRaw(path: string, init?: RequestInit): Promise<Response>;
162
+ /** Sends a recording to the platform's transcription model. */
163
+ transcribe(identifier: string, audio: Blob, filename?: string, language?: string): Promise<Transcription>;
164
+ /** Audio for a reply from the platform's synthesis endpoint. */
165
+ speak(identifier: string, text: string): Promise<Blob>;
146
166
  /** Hosted-chat configuration. Resolves to an auth requirement instead of throwing on 401. */
147
167
  getChat(identifier: string): Promise<ChatConfig | ChatAuthRequired>;
148
168
  /**
@@ -396,9 +416,14 @@ interface ChatWidgetProps {
396
416
  defaultOpen?: boolean;
397
417
  /** Theme for the widget subtree; `auto` follows the host page. */
398
418
  theme?: 'dark' | 'light' | 'auto';
419
+ /**
420
+ * Offer dictation and a hands-free voice conversation when the platform provides speech
421
+ * for this chat and the browser can record. Default true.
422
+ */
423
+ voice?: boolean;
399
424
  className?: string;
400
425
  }
401
- declare function ChatWidget({ identifier, mode, position, launcherLabel, defaultOpen, theme, className, }: ChatWidgetProps): react.JSX.Element | null;
426
+ declare function ChatWidget({ identifier, mode, position, launcherLabel, defaultOpen, theme, voice, className, }: ChatWidgetProps): react.JSX.Element | null;
402
427
 
403
428
  /**
404
429
  * Small Markdown renderer for agent replies. It builds React elements directly, so nothing
@@ -410,6 +435,44 @@ declare function Markdown({ text, className }: {
410
435
  className?: string;
411
436
  }): react.JSX.Element;
412
437
 
438
+ /**
439
+ * Voice for the chat widget: records the visitor with the browser's recorder, sends the
440
+ * clip to the platform (which runs its own transcription model) and plays replies back
441
+ * from the platform's synthesis endpoint. No third-party browser speech API is involved,
442
+ * so it behaves the same in every browser and the audio never leaves the platform.
443
+ */
444
+ type VoiceState = 'idle' | 'listening' | 'transcribing' | 'speaking' | 'denied' | 'unsupported';
445
+ interface UseVoiceOptions {
446
+ identifier: string;
447
+ /** Receives the transcript of a finished recording; empty recordings are dropped. */
448
+ onTranscript: (text: string) => void;
449
+ /** Language hint for transcription; omit for auto-detection. */
450
+ language?: string;
451
+ /** Stop recording after this much silence once speech was heard. */
452
+ silenceMs?: number;
453
+ /** Longest single recording. */
454
+ maxMs?: number;
455
+ }
456
+ interface VoiceControls {
457
+ state: VoiceState;
458
+ /** Last failure, cleared on the next successful action. */
459
+ error: string | null;
460
+ /** Whether this browser can record at all. */
461
+ supported: boolean;
462
+ /** Input level 0..1 while listening, for a meter. */
463
+ level: number;
464
+ startListening: () => Promise<void>;
465
+ /** Ends the recording and transcribes it. */
466
+ stopListening: () => void;
467
+ /** Ends the recording and discards it. */
468
+ cancelListening: () => void;
469
+ /** Plays a reply; resolves when playback ends or is stopped. */
470
+ speak: (text: string) => Promise<void>;
471
+ stopSpeaking: () => void;
472
+ }
473
+ declare function isVoiceSupported(): boolean;
474
+ declare function useVoice({ identifier, onTranscript, language, silenceMs, maxMs, }: UseVoiceOptions): VoiceControls;
475
+
413
476
  /** Joins class names, dropping falsy entries. */
414
477
  declare function cx(...parts: Array<string | false | null | undefined>): string;
415
478
  interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
@@ -615,6 +678,68 @@ declare const STRINGS: {
615
678
  readonly en: "Sign in";
616
679
  };
617
680
  };
681
+ readonly voice: {
682
+ readonly talk: {
683
+ readonly tr: "Konuşmak için dokunun";
684
+ readonly en: "Tap to talk";
685
+ };
686
+ readonly stopTalking: {
687
+ readonly tr: "Bitirmek için dokunun";
688
+ readonly en: "Tap when done";
689
+ };
690
+ readonly dictate: {
691
+ readonly tr: "Sesle yaz";
692
+ readonly en: "Dictate";
693
+ };
694
+ readonly handsFree: {
695
+ readonly tr: "Sesli sohbet";
696
+ readonly en: "Voice conversation";
697
+ };
698
+ readonly exit: {
699
+ readonly tr: "Sesli sohbetten çık";
700
+ readonly en: "Leave voice conversation";
701
+ };
702
+ readonly listening: {
703
+ readonly tr: "Dinliyor";
704
+ readonly en: "Listening";
705
+ };
706
+ readonly transcribing: {
707
+ readonly tr: "Yazıya dökülüyor";
708
+ readonly en: "Transcribing";
709
+ };
710
+ readonly thinking: {
711
+ readonly tr: "Yanıt hazırlanıyor";
712
+ readonly en: "Working on it";
713
+ };
714
+ readonly speaking: {
715
+ readonly tr: "Konuşuyor";
716
+ readonly en: "Speaking";
717
+ };
718
+ readonly idle: {
719
+ readonly tr: "Hazır";
720
+ readonly en: "Ready";
721
+ };
722
+ readonly interrupt: {
723
+ readonly tr: "Sözünü kesmek için dokunun";
724
+ readonly en: "Tap to interrupt";
725
+ };
726
+ readonly micDenied: {
727
+ readonly tr: "Mikrofon izni verilmedi. Tarayıcı ayarlarından izin verin.";
728
+ readonly en: "Microphone access was denied. Allow it in your browser settings.";
729
+ };
730
+ readonly unsupported: {
731
+ readonly tr: "Bu tarayıcı ses kaydını desteklemiyor.";
732
+ readonly en: "This browser cannot record audio.";
733
+ };
734
+ readonly unavailable: {
735
+ readonly tr: "Ses özelliği bu sohbet için açık değil.";
736
+ readonly en: "Voice is not enabled for this chat.";
737
+ };
738
+ readonly error: {
739
+ readonly tr: "Ses işlenemedi. Lütfen tekrar deneyin.";
740
+ readonly en: "Voice could not be processed. Please try again.";
741
+ };
742
+ };
618
743
  readonly run: {
619
744
  readonly submit: {
620
745
  readonly tr: "Çalıştır";
@@ -962,4 +1087,4 @@ declare function runAgent(client: AginiesClient, workflowId: string, options: Ru
962
1087
  /** Decodes an execute SSE body into run events. Exported for tests. */
963
1088
  declare function parseRunSSE(stream: ReadableStream<Uint8Array>): AsyncGenerator<RunEvent>;
964
1089
 
965
- export { ATTACHMENT_LIMITS, type ActivationConfig, type ActivationSession, type ActivationState, AgentRunner, type AgentRunnerProps, AginiesClient, type AginiesConfig, AginiesError, AginiesProvider, type AginiesProviderProps, ApprovalPanel, type ApprovalPanelProps, type ApprovalStatus, Button, type ButtonProps, type ChatAttachment, type ChatAuthRequired, type ChatConfig, type ChatFilePayload, type ChatMessage, type ChatStreamEvent, ChatWidget, type ChatWidgetProps, Chip, type CodeRequestResult, type CostBarItem, CostBars, type CostBarsProps, Eyebrow, Field, type HeatmapRow, Input, type Locale, Markdown, Panel, type PauseContext, type PausePoint, type PausedExecution, type ResumeField, type ResumeOutcome, type ResumeQueueEntry, type ResumeStatus, type RunEvent, type RunField, type RunOptions, type RunStatus, type RunStep, RunTimeline, type RunTimelineProps, type SendMessageInput, Spinner, Stat, type StatItem, StatTiles, type StructuredItem, type StructuredResponse, StructuredUI, SuccessHeatmap, type SuccessHeatmapProps, Tag, Textarea, type TimelineStep, buildSubmission, cx, fieldsOf, formatFieldValue, getClient, getPauseContext, getPausedExecution, init, initialValues, listPausedExecutions, outputOf, parseFieldValue, parseRunSSE, parseSSE, parseStructured, resumeExecution, runAgent, translator, useAgentRun, useAginies, useApproval, useChat, useModule };
1090
+ export { ATTACHMENT_LIMITS, type ActivationConfig, type ActivationSession, type ActivationState, AgentRunner, type AgentRunnerProps, AginiesClient, type AginiesConfig, AginiesError, AginiesProvider, type AginiesProviderProps, ApprovalPanel, type ApprovalPanelProps, type ApprovalStatus, Button, type ButtonProps, type ChatAttachment, type ChatAuthRequired, type ChatConfig, type ChatFilePayload, type ChatMessage, type ChatStreamEvent, ChatWidget, type ChatWidgetProps, Chip, type CodeRequestResult, type CostBarItem, CostBars, type CostBarsProps, Eyebrow, Field, type HeatmapRow, Input, type Locale, Markdown, Panel, type PauseContext, type PausePoint, type PausedExecution, type ResumeField, type ResumeOutcome, type ResumeQueueEntry, type ResumeStatus, type RunEvent, type RunField, type RunOptions, type RunStatus, type RunStep, RunTimeline, type RunTimelineProps, type SendMessageInput, Spinner, Stat, type StatItem, StatTiles, type StructuredItem, type StructuredResponse, StructuredUI, SuccessHeatmap, type SuccessHeatmapProps, Tag, Textarea, type TimelineStep, type Transcription, type UseVoiceOptions, type VoiceControls, type VoiceState, buildSubmission, cx, fieldsOf, formatFieldValue, getClient, getPauseContext, getPausedExecution, init, initialValues, isVoiceSupported, listPausedExecutions, outputOf, parseFieldValue, parseRunSSE, parseSSE, parseStructured, resumeExecution, runAgent, translator, useAgentRun, useAginies, useApproval, useChat, useModule, useVoice };