@informedai/react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -0
- package/dist/index.d.mts +234 -0
- package/dist/index.d.ts +234 -0
- package/dist/index.js +995 -0
- package/dist/index.mjs +963 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# @informedai/react
|
|
2
|
+
|
|
3
|
+
React SDK for [InformedAI Assistant](https://informedassistant.ai) - AI-powered content creation widget informed by your knowledge base.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @informedai/react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { InformedAssistant } from '@informedai/react';
|
|
15
|
+
|
|
16
|
+
function App() {
|
|
17
|
+
return (
|
|
18
|
+
<InformedAssistant
|
|
19
|
+
apiKey="wsk_..."
|
|
20
|
+
documentId="doc_123"
|
|
21
|
+
onFieldApply={(field, value) => {
|
|
22
|
+
console.log(`Applied ${value} to ${field}`);
|
|
23
|
+
}}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- **AI-Powered Widget** - Embeddable chat widget for content creation
|
|
32
|
+
- **Knowledge-Informed** - Responses powered by your domain knowledge
|
|
33
|
+
- **Real-time Streaming** - SSE streaming for instant AI responses
|
|
34
|
+
- **Pending Values** - Preview suggestions before applying
|
|
35
|
+
- **Customizable Theme** - Match your brand colors
|
|
36
|
+
- **TypeScript Support** - Full type definitions included
|
|
37
|
+
|
|
38
|
+
## Props
|
|
39
|
+
|
|
40
|
+
| Prop | Type | Required | Description |
|
|
41
|
+
|------|------|----------|-------------|
|
|
42
|
+
| `apiKey` | `string` | Yes | Your workspace API key |
|
|
43
|
+
| `documentId` | `string` | Yes | Document to work with |
|
|
44
|
+
| `apiUrl` | `string` | No | Custom API URL (default: production) |
|
|
45
|
+
| `sessionId` | `string` | No | Resume existing session |
|
|
46
|
+
| `onFieldApply` | `(field, value) => void` | No | Called when value is applied |
|
|
47
|
+
| `onSessionChange` | `(session) => void` | No | Called on session state change |
|
|
48
|
+
| `onError` | `(error) => void` | No | Called on errors |
|
|
49
|
+
| `theme` | `WidgetTheme` | No | Custom theme colors |
|
|
50
|
+
| `position` | `'inline' \| 'bottom-right' \| 'bottom-left'` | No | Widget position |
|
|
51
|
+
| `defaultCollapsed` | `boolean` | No | Start collapsed (floating only) |
|
|
52
|
+
|
|
53
|
+
## Theming
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
<InformedAssistant
|
|
57
|
+
apiKey="wsk_..."
|
|
58
|
+
documentId="doc_123"
|
|
59
|
+
theme={{
|
|
60
|
+
primaryColor: '#3b82f6',
|
|
61
|
+
backgroundColor: '#ffffff',
|
|
62
|
+
textColor: '#1f2937',
|
|
63
|
+
borderRadius: '16px',
|
|
64
|
+
fontFamily: 'Inter, sans-serif',
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Advanced Usage
|
|
70
|
+
|
|
71
|
+
### Using Hooks
|
|
72
|
+
|
|
73
|
+
For custom UI implementations:
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { useSession, useDocument } from '@informedai/react';
|
|
77
|
+
|
|
78
|
+
function CustomWidget() {
|
|
79
|
+
const { session, sendMessage, applyPendingValue, isStreaming } = useSession({
|
|
80
|
+
apiKey: 'wsk_...',
|
|
81
|
+
documentId: 'doc_123',
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const { document, documentType } = useDocument({
|
|
85
|
+
apiKey: 'wsk_...',
|
|
86
|
+
documentId: 'doc_123',
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Build your own UI
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Using Context Provider
|
|
94
|
+
|
|
95
|
+
For shared state across components:
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { InformedAIProvider, useInformedAI } from '@informedai/react';
|
|
99
|
+
|
|
100
|
+
function App() {
|
|
101
|
+
return (
|
|
102
|
+
<InformedAIProvider
|
|
103
|
+
config={{
|
|
104
|
+
apiKey: 'wsk_...',
|
|
105
|
+
documentId: 'doc_123',
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
<CustomWidget />
|
|
109
|
+
<FieldPreviews />
|
|
110
|
+
</InformedAIProvider>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function CustomWidget() {
|
|
115
|
+
const { session, sendMessage, isStreaming } = useInformedAI();
|
|
116
|
+
// ...
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Requirements
|
|
121
|
+
|
|
122
|
+
- React 18+
|
|
123
|
+
- An InformedAI workspace with API key
|
|
124
|
+
|
|
125
|
+
## Links
|
|
126
|
+
|
|
127
|
+
- [Documentation](https://informedassistant.ai/docs)
|
|
128
|
+
- [Dashboard](https://informedassistant.ai/dashboard)
|
|
129
|
+
- [GitHub](https://github.com/marolence/informedai-assistant-react-sdk)
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* InformedAI React SDK Types
|
|
6
|
+
*/
|
|
7
|
+
interface Session {
|
|
8
|
+
id: string;
|
|
9
|
+
documentId: string;
|
|
10
|
+
widgetMessages: WidgetMessage[];
|
|
11
|
+
taskStates: Record<string, TaskState>;
|
|
12
|
+
activeTask: string | null;
|
|
13
|
+
aiConversations: Record<string, ChatMessage[]>;
|
|
14
|
+
}
|
|
15
|
+
interface WidgetMessage {
|
|
16
|
+
id: string;
|
|
17
|
+
role: 'user' | 'assistant' | 'system';
|
|
18
|
+
content: string;
|
|
19
|
+
type: 'text' | 'quick_actions' | 'task_intro' | 'pending_preview';
|
|
20
|
+
quickActions?: QuickAction[];
|
|
21
|
+
timestamp: string;
|
|
22
|
+
}
|
|
23
|
+
interface QuickAction {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
action: string;
|
|
27
|
+
payload?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
interface TaskState {
|
|
30
|
+
status: 'pending' | 'active' | 'paused' | 'completed' | 'skipped';
|
|
31
|
+
pendingValue?: unknown;
|
|
32
|
+
}
|
|
33
|
+
interface ChatMessage {
|
|
34
|
+
role: 'system' | 'user' | 'assistant';
|
|
35
|
+
content: string;
|
|
36
|
+
}
|
|
37
|
+
interface FieldDefinition {
|
|
38
|
+
type: 'string' | 'number' | 'boolean' | 'richtext' | 'array' | 'image';
|
|
39
|
+
label: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
}
|
|
42
|
+
interface DocumentTypeSchema {
|
|
43
|
+
fields: Record<string, FieldDefinition>;
|
|
44
|
+
}
|
|
45
|
+
interface DocumentType {
|
|
46
|
+
id: string;
|
|
47
|
+
workspaceId: string;
|
|
48
|
+
name: string;
|
|
49
|
+
displayName: string;
|
|
50
|
+
schema: DocumentTypeSchema;
|
|
51
|
+
taskConfigs: Record<string, TaskConfig>;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
updatedAt: string;
|
|
54
|
+
}
|
|
55
|
+
interface TaskConfig {
|
|
56
|
+
templateId?: string;
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
}
|
|
59
|
+
interface Document {
|
|
60
|
+
id: string;
|
|
61
|
+
documentTypeId: string;
|
|
62
|
+
data: Record<string, unknown>;
|
|
63
|
+
version: number;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
documentType?: {
|
|
67
|
+
id?: string;
|
|
68
|
+
name: string;
|
|
69
|
+
displayName: string;
|
|
70
|
+
schema?: DocumentTypeSchema;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
interface InformedAssistantConfig {
|
|
74
|
+
/** API key for authentication (wsk_...) */
|
|
75
|
+
apiKey: string;
|
|
76
|
+
/** API base URL (defaults to https://api.informedassistant.ai/api/v1) */
|
|
77
|
+
apiUrl?: string;
|
|
78
|
+
/** Document ID to work with */
|
|
79
|
+
documentId: string;
|
|
80
|
+
/** Optional: Existing session ID to resume */
|
|
81
|
+
sessionId?: string;
|
|
82
|
+
/** Callback when a field value is applied */
|
|
83
|
+
onFieldApply?: (fieldName: string, value: unknown) => void;
|
|
84
|
+
/** Callback when session state changes */
|
|
85
|
+
onSessionChange?: (session: Session) => void;
|
|
86
|
+
/** Callback when an error occurs */
|
|
87
|
+
onError?: (error: Error) => void;
|
|
88
|
+
/** Custom theme overrides */
|
|
89
|
+
theme?: Partial<WidgetTheme>;
|
|
90
|
+
/** Position of the widget (for floating mode) */
|
|
91
|
+
position?: 'bottom-right' | 'bottom-left' | 'inline';
|
|
92
|
+
/** Initial collapsed state */
|
|
93
|
+
defaultCollapsed?: boolean;
|
|
94
|
+
}
|
|
95
|
+
interface WidgetTheme {
|
|
96
|
+
/** Primary accent color */
|
|
97
|
+
primaryColor: string;
|
|
98
|
+
/** Background color */
|
|
99
|
+
backgroundColor: string;
|
|
100
|
+
/** Text color */
|
|
101
|
+
textColor: string;
|
|
102
|
+
/** Border radius */
|
|
103
|
+
borderRadius: string;
|
|
104
|
+
/** Font family */
|
|
105
|
+
fontFamily: string;
|
|
106
|
+
}
|
|
107
|
+
interface SSEEvent {
|
|
108
|
+
type: 'content' | 'done' | 'error' | 'session_update';
|
|
109
|
+
content?: string;
|
|
110
|
+
session?: Session;
|
|
111
|
+
error?: string;
|
|
112
|
+
}
|
|
113
|
+
interface UseSessionReturn {
|
|
114
|
+
session: Session | null;
|
|
115
|
+
isLoading: boolean;
|
|
116
|
+
error: Error | null;
|
|
117
|
+
sendMessage: (message: string) => Promise<void>;
|
|
118
|
+
sendQuickAction: (action: string, payload?: Record<string, unknown>) => Promise<void>;
|
|
119
|
+
applyPendingValue: () => Promise<void>;
|
|
120
|
+
skipTask: () => Promise<void>;
|
|
121
|
+
}
|
|
122
|
+
interface UseDocumentReturn {
|
|
123
|
+
document: Document | null;
|
|
124
|
+
documentType: DocumentType | null;
|
|
125
|
+
isLoading: boolean;
|
|
126
|
+
error: Error | null;
|
|
127
|
+
updateField: (fieldName: string, value: unknown) => Promise<void>;
|
|
128
|
+
refetch: () => Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface InformedAssistantProps extends InformedAssistantConfig {
|
|
132
|
+
/** Additional CSS class name */
|
|
133
|
+
className?: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* InformedAssistant - AI-powered content assistant widget
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```tsx
|
|
140
|
+
* <InformedAssistant
|
|
141
|
+
* apiKey="wsk_..."
|
|
142
|
+
* documentId="doc_123"
|
|
143
|
+
* onFieldApply={(field, value) => updateForm(field, value)}
|
|
144
|
+
* />
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare function InformedAssistant({ className, ...config }: InformedAssistantProps): react_jsx_runtime.JSX.Element;
|
|
148
|
+
|
|
149
|
+
interface InformedAIContextValue {
|
|
150
|
+
session: Session | null;
|
|
151
|
+
document: Document | null;
|
|
152
|
+
documentType: DocumentType | null;
|
|
153
|
+
isLoading: boolean;
|
|
154
|
+
isStreaming: boolean;
|
|
155
|
+
error: Error | null;
|
|
156
|
+
streamingContent: string;
|
|
157
|
+
sendMessage: (message: string) => Promise<void>;
|
|
158
|
+
sendQuickAction: (action: string, payload?: Record<string, unknown>) => Promise<void>;
|
|
159
|
+
applyPendingValue: () => Promise<void>;
|
|
160
|
+
skipTask: () => Promise<void>;
|
|
161
|
+
clearError: () => void;
|
|
162
|
+
}
|
|
163
|
+
declare function useInformedAI(): InformedAIContextValue;
|
|
164
|
+
interface InformedAIProviderProps {
|
|
165
|
+
config: InformedAssistantConfig;
|
|
166
|
+
children: React.ReactNode;
|
|
167
|
+
}
|
|
168
|
+
declare function InformedAIProvider({ config, children }: InformedAIProviderProps): react_jsx_runtime.JSX.Element;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* useSession Hook
|
|
172
|
+
* For developers who want direct access to session management
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
interface UseSessionOptions {
|
|
176
|
+
apiKey: string;
|
|
177
|
+
apiUrl?: string;
|
|
178
|
+
documentId: string;
|
|
179
|
+
sessionId?: string;
|
|
180
|
+
onSessionChange?: (session: Session) => void;
|
|
181
|
+
onError?: (error: Error) => void;
|
|
182
|
+
}
|
|
183
|
+
declare function useSession(options: UseSessionOptions): UseSessionReturn;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* useDocument Hook
|
|
187
|
+
* For developers who want direct access to document management
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
interface UseDocumentOptions {
|
|
191
|
+
apiKey: string;
|
|
192
|
+
apiUrl?: string;
|
|
193
|
+
documentId: string;
|
|
194
|
+
onError?: (error: Error) => void;
|
|
195
|
+
}
|
|
196
|
+
declare function useDocument(options: UseDocumentOptions): UseDocumentReturn;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* InformedAI API Client
|
|
200
|
+
* Handles all communication with the InformedAI backend
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
declare class InformedAIClient {
|
|
204
|
+
private apiKey;
|
|
205
|
+
private apiUrl;
|
|
206
|
+
constructor(apiKey: string, apiUrl?: string);
|
|
207
|
+
private getHeaders;
|
|
208
|
+
private request;
|
|
209
|
+
getDocument(id: string): Promise<Document>;
|
|
210
|
+
getDocumentType(id: string): Promise<DocumentType>;
|
|
211
|
+
updateDocumentField(documentId: string, field: string, value: unknown): Promise<Document>;
|
|
212
|
+
createSession(documentId: string): Promise<Session>;
|
|
213
|
+
getSession(id: string): Promise<Session>;
|
|
214
|
+
deleteSession(id: string): Promise<void>;
|
|
215
|
+
/**
|
|
216
|
+
* Send a message to the session with SSE streaming
|
|
217
|
+
*/
|
|
218
|
+
sendMessage(sessionId: string, message: string, onEvent: (event: SSEEvent) => void): Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Send a quick action to the session with SSE streaming
|
|
221
|
+
*/
|
|
222
|
+
sendQuickAction(sessionId: string, action: string, payload?: Record<string, unknown>, onEvent?: (event: SSEEvent) => void): Promise<Session>;
|
|
223
|
+
/**
|
|
224
|
+
* Apply the pending value for the active task
|
|
225
|
+
*/
|
|
226
|
+
applyPendingValue(sessionId: string): Promise<Session>;
|
|
227
|
+
/**
|
|
228
|
+
* Skip the active task
|
|
229
|
+
*/
|
|
230
|
+
skipTask(sessionId: string): Promise<Session>;
|
|
231
|
+
private processSSEStream;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export { type ChatMessage, type Document, type DocumentType, type DocumentTypeSchema, type FieldDefinition, InformedAIClient, InformedAIProvider, InformedAssistant, type InformedAssistantConfig, type QuickAction, type SSEEvent, type Session, type TaskConfig, type TaskState, type UseDocumentReturn, type UseSessionReturn, type WidgetMessage, type WidgetTheme, useDocument, useInformedAI, useSession };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* InformedAI React SDK Types
|
|
6
|
+
*/
|
|
7
|
+
interface Session {
|
|
8
|
+
id: string;
|
|
9
|
+
documentId: string;
|
|
10
|
+
widgetMessages: WidgetMessage[];
|
|
11
|
+
taskStates: Record<string, TaskState>;
|
|
12
|
+
activeTask: string | null;
|
|
13
|
+
aiConversations: Record<string, ChatMessage[]>;
|
|
14
|
+
}
|
|
15
|
+
interface WidgetMessage {
|
|
16
|
+
id: string;
|
|
17
|
+
role: 'user' | 'assistant' | 'system';
|
|
18
|
+
content: string;
|
|
19
|
+
type: 'text' | 'quick_actions' | 'task_intro' | 'pending_preview';
|
|
20
|
+
quickActions?: QuickAction[];
|
|
21
|
+
timestamp: string;
|
|
22
|
+
}
|
|
23
|
+
interface QuickAction {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
action: string;
|
|
27
|
+
payload?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
interface TaskState {
|
|
30
|
+
status: 'pending' | 'active' | 'paused' | 'completed' | 'skipped';
|
|
31
|
+
pendingValue?: unknown;
|
|
32
|
+
}
|
|
33
|
+
interface ChatMessage {
|
|
34
|
+
role: 'system' | 'user' | 'assistant';
|
|
35
|
+
content: string;
|
|
36
|
+
}
|
|
37
|
+
interface FieldDefinition {
|
|
38
|
+
type: 'string' | 'number' | 'boolean' | 'richtext' | 'array' | 'image';
|
|
39
|
+
label: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
}
|
|
42
|
+
interface DocumentTypeSchema {
|
|
43
|
+
fields: Record<string, FieldDefinition>;
|
|
44
|
+
}
|
|
45
|
+
interface DocumentType {
|
|
46
|
+
id: string;
|
|
47
|
+
workspaceId: string;
|
|
48
|
+
name: string;
|
|
49
|
+
displayName: string;
|
|
50
|
+
schema: DocumentTypeSchema;
|
|
51
|
+
taskConfigs: Record<string, TaskConfig>;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
updatedAt: string;
|
|
54
|
+
}
|
|
55
|
+
interface TaskConfig {
|
|
56
|
+
templateId?: string;
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
}
|
|
59
|
+
interface Document {
|
|
60
|
+
id: string;
|
|
61
|
+
documentTypeId: string;
|
|
62
|
+
data: Record<string, unknown>;
|
|
63
|
+
version: number;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
documentType?: {
|
|
67
|
+
id?: string;
|
|
68
|
+
name: string;
|
|
69
|
+
displayName: string;
|
|
70
|
+
schema?: DocumentTypeSchema;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
interface InformedAssistantConfig {
|
|
74
|
+
/** API key for authentication (wsk_...) */
|
|
75
|
+
apiKey: string;
|
|
76
|
+
/** API base URL (defaults to https://api.informedassistant.ai/api/v1) */
|
|
77
|
+
apiUrl?: string;
|
|
78
|
+
/** Document ID to work with */
|
|
79
|
+
documentId: string;
|
|
80
|
+
/** Optional: Existing session ID to resume */
|
|
81
|
+
sessionId?: string;
|
|
82
|
+
/** Callback when a field value is applied */
|
|
83
|
+
onFieldApply?: (fieldName: string, value: unknown) => void;
|
|
84
|
+
/** Callback when session state changes */
|
|
85
|
+
onSessionChange?: (session: Session) => void;
|
|
86
|
+
/** Callback when an error occurs */
|
|
87
|
+
onError?: (error: Error) => void;
|
|
88
|
+
/** Custom theme overrides */
|
|
89
|
+
theme?: Partial<WidgetTheme>;
|
|
90
|
+
/** Position of the widget (for floating mode) */
|
|
91
|
+
position?: 'bottom-right' | 'bottom-left' | 'inline';
|
|
92
|
+
/** Initial collapsed state */
|
|
93
|
+
defaultCollapsed?: boolean;
|
|
94
|
+
}
|
|
95
|
+
interface WidgetTheme {
|
|
96
|
+
/** Primary accent color */
|
|
97
|
+
primaryColor: string;
|
|
98
|
+
/** Background color */
|
|
99
|
+
backgroundColor: string;
|
|
100
|
+
/** Text color */
|
|
101
|
+
textColor: string;
|
|
102
|
+
/** Border radius */
|
|
103
|
+
borderRadius: string;
|
|
104
|
+
/** Font family */
|
|
105
|
+
fontFamily: string;
|
|
106
|
+
}
|
|
107
|
+
interface SSEEvent {
|
|
108
|
+
type: 'content' | 'done' | 'error' | 'session_update';
|
|
109
|
+
content?: string;
|
|
110
|
+
session?: Session;
|
|
111
|
+
error?: string;
|
|
112
|
+
}
|
|
113
|
+
interface UseSessionReturn {
|
|
114
|
+
session: Session | null;
|
|
115
|
+
isLoading: boolean;
|
|
116
|
+
error: Error | null;
|
|
117
|
+
sendMessage: (message: string) => Promise<void>;
|
|
118
|
+
sendQuickAction: (action: string, payload?: Record<string, unknown>) => Promise<void>;
|
|
119
|
+
applyPendingValue: () => Promise<void>;
|
|
120
|
+
skipTask: () => Promise<void>;
|
|
121
|
+
}
|
|
122
|
+
interface UseDocumentReturn {
|
|
123
|
+
document: Document | null;
|
|
124
|
+
documentType: DocumentType | null;
|
|
125
|
+
isLoading: boolean;
|
|
126
|
+
error: Error | null;
|
|
127
|
+
updateField: (fieldName: string, value: unknown) => Promise<void>;
|
|
128
|
+
refetch: () => Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface InformedAssistantProps extends InformedAssistantConfig {
|
|
132
|
+
/** Additional CSS class name */
|
|
133
|
+
className?: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* InformedAssistant - AI-powered content assistant widget
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```tsx
|
|
140
|
+
* <InformedAssistant
|
|
141
|
+
* apiKey="wsk_..."
|
|
142
|
+
* documentId="doc_123"
|
|
143
|
+
* onFieldApply={(field, value) => updateForm(field, value)}
|
|
144
|
+
* />
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare function InformedAssistant({ className, ...config }: InformedAssistantProps): react_jsx_runtime.JSX.Element;
|
|
148
|
+
|
|
149
|
+
interface InformedAIContextValue {
|
|
150
|
+
session: Session | null;
|
|
151
|
+
document: Document | null;
|
|
152
|
+
documentType: DocumentType | null;
|
|
153
|
+
isLoading: boolean;
|
|
154
|
+
isStreaming: boolean;
|
|
155
|
+
error: Error | null;
|
|
156
|
+
streamingContent: string;
|
|
157
|
+
sendMessage: (message: string) => Promise<void>;
|
|
158
|
+
sendQuickAction: (action: string, payload?: Record<string, unknown>) => Promise<void>;
|
|
159
|
+
applyPendingValue: () => Promise<void>;
|
|
160
|
+
skipTask: () => Promise<void>;
|
|
161
|
+
clearError: () => void;
|
|
162
|
+
}
|
|
163
|
+
declare function useInformedAI(): InformedAIContextValue;
|
|
164
|
+
interface InformedAIProviderProps {
|
|
165
|
+
config: InformedAssistantConfig;
|
|
166
|
+
children: React.ReactNode;
|
|
167
|
+
}
|
|
168
|
+
declare function InformedAIProvider({ config, children }: InformedAIProviderProps): react_jsx_runtime.JSX.Element;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* useSession Hook
|
|
172
|
+
* For developers who want direct access to session management
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
interface UseSessionOptions {
|
|
176
|
+
apiKey: string;
|
|
177
|
+
apiUrl?: string;
|
|
178
|
+
documentId: string;
|
|
179
|
+
sessionId?: string;
|
|
180
|
+
onSessionChange?: (session: Session) => void;
|
|
181
|
+
onError?: (error: Error) => void;
|
|
182
|
+
}
|
|
183
|
+
declare function useSession(options: UseSessionOptions): UseSessionReturn;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* useDocument Hook
|
|
187
|
+
* For developers who want direct access to document management
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
interface UseDocumentOptions {
|
|
191
|
+
apiKey: string;
|
|
192
|
+
apiUrl?: string;
|
|
193
|
+
documentId: string;
|
|
194
|
+
onError?: (error: Error) => void;
|
|
195
|
+
}
|
|
196
|
+
declare function useDocument(options: UseDocumentOptions): UseDocumentReturn;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* InformedAI API Client
|
|
200
|
+
* Handles all communication with the InformedAI backend
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
declare class InformedAIClient {
|
|
204
|
+
private apiKey;
|
|
205
|
+
private apiUrl;
|
|
206
|
+
constructor(apiKey: string, apiUrl?: string);
|
|
207
|
+
private getHeaders;
|
|
208
|
+
private request;
|
|
209
|
+
getDocument(id: string): Promise<Document>;
|
|
210
|
+
getDocumentType(id: string): Promise<DocumentType>;
|
|
211
|
+
updateDocumentField(documentId: string, field: string, value: unknown): Promise<Document>;
|
|
212
|
+
createSession(documentId: string): Promise<Session>;
|
|
213
|
+
getSession(id: string): Promise<Session>;
|
|
214
|
+
deleteSession(id: string): Promise<void>;
|
|
215
|
+
/**
|
|
216
|
+
* Send a message to the session with SSE streaming
|
|
217
|
+
*/
|
|
218
|
+
sendMessage(sessionId: string, message: string, onEvent: (event: SSEEvent) => void): Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Send a quick action to the session with SSE streaming
|
|
221
|
+
*/
|
|
222
|
+
sendQuickAction(sessionId: string, action: string, payload?: Record<string, unknown>, onEvent?: (event: SSEEvent) => void): Promise<Session>;
|
|
223
|
+
/**
|
|
224
|
+
* Apply the pending value for the active task
|
|
225
|
+
*/
|
|
226
|
+
applyPendingValue(sessionId: string): Promise<Session>;
|
|
227
|
+
/**
|
|
228
|
+
* Skip the active task
|
|
229
|
+
*/
|
|
230
|
+
skipTask(sessionId: string): Promise<Session>;
|
|
231
|
+
private processSSEStream;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export { type ChatMessage, type Document, type DocumentType, type DocumentTypeSchema, type FieldDefinition, InformedAIClient, InformedAIProvider, InformedAssistant, type InformedAssistantConfig, type QuickAction, type SSEEvent, type Session, type TaskConfig, type TaskState, type UseDocumentReturn, type UseSessionReturn, type WidgetMessage, type WidgetTheme, useDocument, useInformedAI, useSession };
|