@odin-ai/sdk 1.0.0 → 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.
Files changed (72) hide show
  1. package/README.md +106 -249
  2. package/dist/{src/BaseClient.d.ts → BaseClient.d.cts} +21 -2
  3. package/dist/BaseClient.d.ts +15 -1
  4. package/dist/BaseClient.d.ts.map +1 -1
  5. package/dist/{src/ChatSDK.d.ts → ChatSDK.d.cts} +52 -5
  6. package/dist/ChatSDK.d.ts +49 -3
  7. package/dist/ChatSDK.d.ts.map +1 -1
  8. package/dist/{src/SmartTablesSDK.d.ts → SmartTablesSDK.d.cts} +115 -9
  9. package/dist/SmartTablesSDK.d.ts +29 -7
  10. package/dist/SmartTablesSDK.d.ts.map +1 -1
  11. package/dist/VoiceSDK.d.cts +72 -0
  12. package/dist/VoiceSDK.d.ts +2 -2
  13. package/dist/VoiceSDK.d.ts.map +1 -1
  14. package/dist/{index.js → index.cjs} +651 -906
  15. package/dist/index.cjs.map +1 -0
  16. package/dist/index.d.cts +11 -0
  17. package/dist/index.d.ts +11 -13
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.esm.js +644 -900
  20. package/dist/index.esm.js.map +1 -1
  21. package/dist/react.cjs +1737 -0
  22. package/dist/react.cjs.map +1 -0
  23. package/dist/react.d.cts +3 -0
  24. package/dist/react.d.ts +4 -0
  25. package/dist/react.d.ts.map +1 -0
  26. package/dist/react.esm.js +1731 -0
  27. package/dist/react.esm.js.map +1 -0
  28. package/dist/resumableTurnStream.d.cts +57 -0
  29. package/dist/resumableTurnStream.d.ts +58 -0
  30. package/dist/resumableTurnStream.d.ts.map +1 -0
  31. package/dist/{src/types.d.ts → types.d.cts} +109 -111
  32. package/dist/types.d.ts +89 -4
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/useVoiceConversation.d.cts +33 -0
  35. package/dist/useVoiceConversation.d.ts +5 -5
  36. package/dist/useVoiceConversation.d.ts.map +1 -1
  37. package/dist/voice-types.d.cts +168 -0
  38. package/dist/voice-types.d.ts +7 -7
  39. package/dist/voice-types.d.ts.map +1 -1
  40. package/package.json +53 -26
  41. package/LICENSE +0 -21
  42. package/dist/WorkflowSDK.d.ts +0 -188
  43. package/dist/WorkflowSDK.d.ts.map +0 -1
  44. package/dist/examples/basic-chat.d.ts +0 -2
  45. package/dist/examples/basic-chat.d.ts.map +0 -1
  46. package/dist/examples/react-integration.d.ts +0 -7
  47. package/dist/examples/react-integration.d.ts.map +0 -1
  48. package/dist/examples/smart-tables-basic.d.ts +0 -2
  49. package/dist/examples/smart-tables-basic.d.ts.map +0 -1
  50. package/dist/examples/smart-tables-comprehensive.d.ts +0 -2
  51. package/dist/examples/smart-tables-comprehensive.d.ts.map +0 -1
  52. package/dist/examples/smart-tables-demo.d.ts +0 -2
  53. package/dist/examples/smart-tables-demo.d.ts.map +0 -1
  54. package/dist/examples/smart-tables-import.d.ts +0 -2
  55. package/dist/examples/smart-tables-import.d.ts.map +0 -1
  56. package/dist/examples/streaming-chat.d.ts +0 -2
  57. package/dist/examples/streaming-chat.d.ts.map +0 -1
  58. package/dist/index.js.map +0 -1
  59. package/dist/src/BaseClient.d.ts.map +0 -1
  60. package/dist/src/ChatSDK.d.ts.map +0 -1
  61. package/dist/src/SmartTablesSDK.d.ts.map +0 -1
  62. package/dist/src/components/MessageBubble.d.ts +0 -24
  63. package/dist/src/components/MessageBubble.d.ts.map +0 -1
  64. package/dist/src/components/MessageList.d.ts +0 -28
  65. package/dist/src/components/MessageList.d.ts.map +0 -1
  66. package/dist/src/components/index.d.ts +0 -4
  67. package/dist/src/components/index.d.ts.map +0 -1
  68. package/dist/src/index.d.ts +0 -10
  69. package/dist/src/index.d.ts.map +0 -1
  70. package/dist/src/types.d.ts.map +0 -1
  71. package/dist/workflow-types.d.ts +0 -431
  72. package/dist/workflow-types.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Odin AI SDK
1
+ # Chat SDK
2
2
 
3
- A TypeScript SDK for interacting with the Odin AI platform, including Chat, Smart Tables, Voice, and **Workflows**.
3
+ A TypeScript SDK for interacting with the AI Content Creator chat system.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,30 +8,56 @@ A TypeScript SDK for interacting with the Odin AI platform, including Chat, Smar
8
8
  npm install @odin-ai/sdk
9
9
  ```
10
10
 
11
- ## Available SDKs
11
+ ## Entry points
12
12
 
13
- | SDK | Description |
14
- |-----|-------------|
15
- | `ChatSDK` | Chat conversations with AI agents |
16
- | `SmartTablesSDK` | Structured data tables with AI enrichment |
17
- | `VoiceSDK` | Voice conversations with AI |
18
- | **`WorkflowSDK`** | Execute and monitor workflows with real-time updates |
13
+ | Import | Contents | Runtime |
14
+ | ---------------------------- | ----------------------------------------------------- | ---------------------------- |
15
+ | `@odin-ai/sdk` | `ChatSDK`, `SmartTablesSDK`, `VoiceSDK`, `BaseClient` | Node, server, browser |
16
+ | `@odin-ai/sdk/react` | `useVoiceConversation`, `postOverallFeedback` | browser only (needs `react`) |
17
+
18
+ The root entry is runtime-agnostic: it does not import `react` or the ElevenLabs
19
+ browser client, so it can be used from a Node/server process as-is. The React
20
+ hook and the ElevenLabs helpers live in the `./react` subpath:
21
+
22
+ ```typescript
23
+ import { ChatSDK } from "@odin-ai/sdk"; // server-safe
24
+ import { useVoiceConversation } from "@odin-ai/sdk/react"; // browser
25
+ ```
26
+
27
+ **Install footprint.** `@elevenlabs/client` and `@elevenlabs/react` are regular
28
+ dependencies, so a server install still pulls them (and `react`, as
29
+ `@elevenlabs/react`'s peer) even if you only use `ChatSDK`. They are not loaded
30
+ at runtime by the root entry — the cost is install size, not a browser
31
+ dependency in your process. The voice types are derived from `@elevenlabs/react`
32
+ types, so they cannot be made optional peers without first decoupling
33
+ `src/voice-types.ts` from those types.
34
+
35
+ **TypeScript resolution.** The package ships a declaration file per module
36
+ format (`dist/*.d.ts` for `import`, `dist/*.d.cts` for `require`) with explicit
37
+ `.js`/`.cjs` specifiers, so the root entry type-checks under `node16`,
38
+ `nodenext`, `bundler` and `node10` — including with `skipLibCheck: false`. One
39
+ combination is not supported: `require()`-ing `./react` from a CommonJS
40
+ TypeScript file with `skipLibCheck: false` reports TS1479, because `./react`
41
+ re-exports `postOverallFeedback` from `@elevenlabs/client`, which is ESM-only.
42
+ The runtime is fine (the dependency is bundled into `dist/react.cjs`); only the
43
+ declaration cannot express a CommonJS re-export of an ESM value. Use `./react`
44
+ from ESM or bundler resolution, which is what React toolchains use.
19
45
 
20
46
  ## Authentication
21
47
 
22
- All SDKs support two authentication methods:
48
+ The ChatSDK supports two authentication methods:
23
49
 
24
50
  ### 1. Access Token Authentication (Web App)
25
51
 
26
52
  For web applications that already have user sessions:
27
53
 
28
54
  ```typescript
29
- import { ChatSDK } from '@odin-ai/sdk';
55
+ import { ChatSDK } from "@odin-ai/sdk";
30
56
 
31
57
  const chatSDK = new ChatSDK({
32
- baseUrl: 'https://api.example.com/',
33
- projectId: 'your-project-id',
34
- accessToken: 'your-access-token', // From user session
58
+ baseUrl: "https://api.example.com/",
59
+ projectId: "your-project-id",
60
+ accessToken: "your-access-token", // From user session
35
61
  });
36
62
  ```
37
63
 
@@ -40,13 +66,13 @@ const chatSDK = new ChatSDK({
40
66
  For external applications and server-to-server communication:
41
67
 
42
68
  ```typescript
43
- import { ChatSDK } from '@odin-ai/sdk';
69
+ import { ChatSDK } from "@odin-ai/sdk";
44
70
 
45
71
  const chatSDK = new ChatSDK({
46
- baseUrl: 'https://api.example.com/',
47
- projectId: 'your-project-id',
48
- apiKey: 'your-api-key',
49
- apiSecret: 'your-api-secret',
72
+ baseUrl: "https://api.example.com/",
73
+ projectId: "your-project-id",
74
+ apiKey: "your-api-key",
75
+ apiSecret: "your-api-secret",
50
76
  });
51
77
  ```
52
78
 
@@ -55,28 +81,28 @@ const chatSDK = new ChatSDK({
55
81
  ### Creating a Chat
56
82
 
57
83
  ```typescript
58
- const chat = await chatSDK.createChat('My Chat', ['document-key-1']);
59
- console.log('Created chat:', chat.chat_id);
84
+ const chat = await chatSDK.createChat("My Chat", ["document-key-1"]);
85
+ console.log("Created chat:", chat.chat_id);
60
86
  ```
61
87
 
62
88
  ### Sending a Message
63
89
 
64
90
  ```typescript
65
- const response = await chatSDK.sendMessage('Hello!', {
66
- chatId: 'chat-id',
67
- agentType: 'chat_agent',
91
+ const response = await chatSDK.sendMessage("Hello!", {
92
+ chatId: "chat-id",
93
+ agentType: "chat_agent",
68
94
  });
69
- console.log('Response:', response);
95
+ console.log("Response:", response);
70
96
  ```
71
97
 
72
98
  ### Streaming Messages
73
99
 
74
100
  ```typescript
75
- await chatSDK.sendMessageStream('Tell me about...', {
76
- chatId: 'chat-id',
77
- onChunk: (chunk) => console.log('Chunk:', chunk),
78
- onComplete: (message) => console.log('Complete:', message),
79
- onError: (error) => console.error('Error:', error),
101
+ await chatSDK.sendMessageStream("Tell me about...", {
102
+ chatId: "chat-id",
103
+ onChunk: (chunk) => console.log("Chunk:", chunk),
104
+ onComplete: (message) => console.log("Complete:", message),
105
+ onError: (error) => console.error("Error:", error),
80
106
  });
81
107
  ```
82
108
 
@@ -84,14 +110,14 @@ await chatSDK.sendMessageStream('Tell me about...', {
84
110
 
85
111
  ```typescript
86
112
  const chats = await chatSDK.listChats();
87
- console.log('Chats:', chats.chats);
113
+ console.log("Chats:", chats.chats);
88
114
  ```
89
115
 
90
116
  ### Deleting a Chat
91
117
 
92
118
  ```typescript
93
- await chatSDK.deleteChat('chat-id');
94
- console.log('Chat deleted');
119
+ await chatSDK.deleteChat("chat-id");
120
+ console.log("Chat deleted");
95
121
  ```
96
122
 
97
123
  ## Error Handling
@@ -100,10 +126,10 @@ The SDK throws errors for failed requests. Always wrap SDK calls in try-catch bl
100
126
 
101
127
  ```typescript
102
128
  try {
103
- const chat = await chatSDK.createChat('My Chat');
129
+ const chat = await chatSDK.createChat("My Chat");
104
130
  // Handle success
105
131
  } catch (error) {
106
- console.error('Failed to create chat:', error.message);
132
+ console.error("Failed to create chat:", error.message);
107
133
  // Handle error
108
134
  }
109
135
  ```
@@ -130,23 +156,25 @@ The SDK is written in TypeScript and includes full type definitions for all meth
130
156
 
131
157
  ```typescript
132
158
  interface ChatSDKConfig {
133
- apiKey: string; // X-API-KEY header
134
- apiSecret: string; // X-API-SECRET header
135
- baseUrl: string; // API base URL
136
- projectId: string; // Project ID for all operations
159
+ apiKey: string; // X-API-KEY header
160
+ apiSecret: string; // X-API-SECRET header
161
+ baseUrl: string; // API base URL
162
+ projectId: string; // Project ID for all operations
137
163
  }
138
164
  ```
139
165
 
140
166
  ### Chat Management
141
167
 
142
168
  #### `createChat(name?, documentKeys?)`
169
+
143
170
  Creates a new chat in the project.
144
171
 
145
172
  ```typescript
146
- const chat = await chatSDK.createChat('My Chat', ['doc1', 'doc2']);
173
+ const chat = await chatSDK.createChat("My Chat", ["doc1", "doc2"]);
147
174
  ```
148
175
 
149
176
  #### `listChats(cursor?, limit?)`
177
+
150
178
  Lists chats with pagination support.
151
179
 
152
180
  ```typescript
@@ -154,60 +182,65 @@ const { chats, has_more, next_cursor } = await chatSDK.listChats();
154
182
  ```
155
183
 
156
184
  #### `getChatHistory(chatId)`
185
+
157
186
  Gets a specific chat with its message history.
158
187
 
159
188
  ```typescript
160
- const chatHistory = await chatSDK.getChatHistory('chat-id');
189
+ const chatHistory = await chatSDK.getChatHistory("chat-id");
161
190
  ```
162
191
 
163
192
  #### `deleteChat(chatId)`
193
+
164
194
  Deletes a chat and all its messages.
165
195
 
166
196
  ```typescript
167
- await chatSDK.deleteChat('chat-id');
197
+ await chatSDK.deleteChat("chat-id");
168
198
  ```
169
199
 
170
200
  #### `updateChatName(chatId, newName)`
201
+
171
202
  Updates the name of an existing chat.
172
203
 
173
204
  ```typescript
174
- await chatSDK.updateChatName('chat-id', 'New Chat Name');
205
+ await chatSDK.updateChatName("chat-id", "New Chat Name");
175
206
  ```
176
207
 
177
208
  ### Message Operations
178
209
 
179
210
  #### `sendMessage(message, options?)`
211
+
180
212
  Sends a message and returns the response.
181
213
 
182
214
  ```typescript
183
- const response = await chatSDK.sendMessage('Hello!', {
184
- chatId: 'chat-id',
185
- agentType: 'chat_agent',
186
- documentKeys: ['doc1'],
215
+ const response = await chatSDK.sendMessage("Hello!", {
216
+ chatId: "chat-id",
217
+ agentType: "chat_agent",
218
+ documentKeys: ["doc1"],
187
219
  });
188
220
  ```
189
221
 
190
222
  #### `sendMessageStream(message, options?)`
223
+
191
224
  Sends a message with streaming response support.
192
225
 
193
226
  ```typescript
194
- await chatSDK.sendMessageStream('Tell me about AI', {
195
- chatId: 'chat-id',
227
+ await chatSDK.sendMessageStream("Tell me about AI", {
228
+ chatId: "chat-id",
196
229
  onChunk: (chunk) => {
197
230
  // Handle streaming text chunks
198
- console.log('Chunk:', chunk);
231
+ console.log("Chunk:", chunk);
199
232
  },
200
233
  onMessageObject: (obj) => {
201
234
  // Handle structured message objects
202
- console.log('Message object:', obj);
235
+ console.log("Message object:", obj);
203
236
  },
204
237
  onComplete: (message) => {
205
238
  // Handle completion
206
- console.log('Complete:', message);
239
+ console.log("Complete:", message);
207
240
  },
208
241
  onError: (error) => {
209
242
  // Handle errors
210
- console.error('Error:', error);
243
+ console.error("Error:", error);
211
244
  },
212
245
  });
213
246
  ```
@@ -215,11 +248,12 @@ await chatSDK.sendMessageStream('Tell me about AI', {
215
248
  ### Feedback
216
249
 
217
250
  #### `sendFeedback(messageId, chatId, feedback)`
251
+
218
252
  Sends user feedback (thumbs up/down) for a message.
219
253
 
220
254
  ```typescript
221
- await chatSDK.sendFeedback('message-id', 'chat-id', true); // thumbs up
222
- await chatSDK.sendFeedback('message-id', 'chat-id', false); // thumbs down
255
+ await chatSDK.sendFeedback("message-id", "chat-id", true); // thumbs up
256
+ await chatSDK.sendFeedback("message-id", "chat-id", false); // thumbs down
223
257
  ```
224
258
 
225
259
  ## Advanced Usage
@@ -227,11 +261,11 @@ await chatSDK.sendFeedback('message-id', 'chat-id', false); // thumbs down
227
261
  ### File Uploads
228
262
 
229
263
  ```typescript
230
- const fileInput = document.getElementById('file') as HTMLInputElement;
264
+ const fileInput = document.getElementById("file") as HTMLInputElement;
231
265
  const files = Array.from(fileInput.files || []);
232
266
 
233
- await chatSDK.sendMessageStream('Analyze this image', {
234
- chatId: 'chat-id',
267
+ await chatSDK.sendMessageStream("Analyze this image", {
268
+ chatId: "chat-id",
235
269
  images: files,
236
270
  onChunk: (chunk) => console.log(chunk),
237
271
  });
@@ -240,20 +274,20 @@ await chatSDK.sendMessageStream('Analyze this image', {
240
274
  ### Custom Agents
241
275
 
242
276
  ```typescript
243
- await chatSDK.sendMessage('Help me write code', {
244
- chatId: 'chat-id',
245
- agentType: 'chat_agent',
246
- agentId: 'custom-agent-id',
247
- modelName: 'gpt-4o',
277
+ await chatSDK.sendMessage("Help me write code", {
278
+ chatId: "chat-id",
279
+ agentType: "chat_agent",
280
+ agentId: "custom-agent-id",
281
+ modelName: "gpt-4o",
248
282
  });
249
283
  ```
250
284
 
251
285
  ### Knowledge Base Integration
252
286
 
253
287
  ```typescript
254
- await chatSDK.sendMessage('What does our documentation say about X?', {
255
- chatId: 'chat-id',
256
- documentKeys: ['doc1', 'doc2', 'doc3'],
288
+ await chatSDK.sendMessage("What does our documentation say about X?", {
289
+ chatId: "chat-id",
290
+ documentKeys: ["doc1", "doc2", "doc3"],
257
291
  useKnowledgebase: true,
258
292
  });
259
293
  ```
@@ -261,12 +295,12 @@ await chatSDK.sendMessage('What does our documentation say about X?', {
261
295
  ### Metadata
262
296
 
263
297
  ```typescript
264
- await chatSDK.sendMessage('Hello', {
265
- chatId: 'chat-id',
298
+ await chatSDK.sendMessage("Hello", {
299
+ chatId: "chat-id",
266
300
  metadata: {
267
- userId: 'user-123',
268
- sessionId: 'session-456',
269
- customField: 'value',
301
+ userId: "user-123",
302
+ sessionId: "session-456",
303
+ customField: "value",
270
304
  },
271
305
  });
272
306
  ```
@@ -279,183 +313,6 @@ See the `/examples` directory for complete working examples:
279
313
  - `streaming-chat.ts` - Real-time streaming chat
280
314
  - `file-upload.ts` - Chat with file uploads
281
315
  - `react-integration.tsx` - React component integration
282
- - `workflow-basic.ts` - Basic workflow listing and execution
283
- - `workflow-streaming.ts` - Real-time streaming workflow execution
284
- - `workflow-react-embed.tsx` - React component for embedding workflows
285
-
286
- ---
287
-
288
- ## WorkflowSDK
289
-
290
- Execute and monitor workflows from external applications with real-time streaming updates.
291
-
292
- ### Quick Start
293
-
294
- ```typescript
295
- import { WorkflowSDK } from '@odin-ai/sdk';
296
-
297
- const sdk = new WorkflowSDK({
298
- baseUrl: 'https://ecs-api.getodin.ai/',
299
- projectId: 'your-project-id',
300
- accessToken: 'your-access-token', // From Firebase, Supabase, or your auth
301
- });
302
-
303
- // List workflows
304
- const { tools: workflows } = await sdk.listWorkflows();
305
-
306
- // Execute with streaming updates
307
- const session = await sdk.executeWorkflowStream('workflow-id', {
308
- inputs: { name: 'John' },
309
- onNodeStarted: (event) => console.log(`Starting ${event.node_id}`),
310
- onNodeCompleted: (event) => console.log(`Completed ${event.node_id}`),
311
- onExecutionCompleted: (event) => console.log('Done!', event.result),
312
- });
313
- ```
314
-
315
- ### Key Features
316
-
317
- - **List & retrieve workflows** - Get available workflows in your project
318
- - **Execute workflows** - Run workflows with custom input values
319
- - **Real-time streaming** - SSE-based updates for node-by-node progress
320
- - **Execution history** - Track past executions and results
321
- - **File upload support** - Execute workflows with file inputs
322
- - **Full TypeScript support** - Complete type definitions
323
-
324
- See [WorkflowSDK Documentation](./docs/WorkflowSDK.md) for full API reference.
325
-
326
- ---
327
-
328
- ## Workflow Embed
329
-
330
- Embed workflow visualization directly in your web application with a lightweight bundle (335 KB / 106 KB gzipped).
331
-
332
- ### Installation
333
-
334
- Include the embed script and CSS:
335
-
336
- ```html
337
- <link rel="stylesheet" href="https://cdn.getodin.ai/embed/odin-workflow.css">
338
- <script src="https://cdn.getodin.ai/embed/odin-workflow.js"></script>
339
- ```
340
-
341
- Or build from source:
342
-
343
- ```bash
344
- cd ai-content-creator
345
- npx vite build --config vite.embed.config.ts
346
- # Output: dist/embed/odin-workflow.js, dist/embed/odin-workflow.css
347
- ```
348
-
349
- ### Usage
350
-
351
- #### Method 1: JavaScript API
352
-
353
- ```javascript
354
- OdinWorkflow.mount(document.getElementById('workflow-container'), {
355
- apiUrl: 'https://ecs-api.getodin.ai/',
356
- projectId: 'your-project-id',
357
- workflowId: 'your-workflow-id',
358
- accessToken: 'your-access-token',
359
- theme: 'odin', // 'odin' | 'aai' | 'leah' | 'emerald' | 'sunset'
360
- onExecutionStart: (executionId) => console.log('Started:', executionId),
361
- onExecutionComplete: (result) => console.log('Complete:', result),
362
- onError: (error) => console.error('Error:', error),
363
- });
364
- ```
365
-
366
- #### Method 2: Web Component
367
-
368
- ```html
369
- <odin-workflow
370
- api-url="https://ecs-api.getodin.ai/"
371
- project-id="your-project-id"
372
- workflow-id="your-workflow-id"
373
- access-token="your-access-token"
374
- theme="odin"
375
- ></odin-workflow>
376
-
377
- <script>
378
- document.querySelector('odin-workflow').addEventListener('execution-complete', (e) => {
379
- console.log('Workflow completed:', e.detail.result);
380
- });
381
- </script>
382
- ```
383
-
384
- ### Authentication Examples
385
-
386
- #### With Firebase Auth
387
-
388
- ```javascript
389
- import { initializeApp } from 'firebase/app';
390
- import { getAuth, signInWithEmailAndPassword } from 'firebase/auth';
391
-
392
- const app = initializeApp({ apiKey: '...', authDomain: '...' });
393
- const auth = getAuth(app);
394
-
395
- const userCredential = await signInWithEmailAndPassword(auth, email, password);
396
- const accessToken = await userCredential.user.getIdToken();
397
-
398
- OdinWorkflow.mount(container, {
399
- apiUrl: 'https://ecs-api.getodin.ai/',
400
- projectId: 'your-project-id',
401
- workflowId: 'your-workflow-id',
402
- accessToken: accessToken,
403
- });
404
- ```
405
-
406
- #### With Supabase Auth
407
-
408
- ```javascript
409
- import { createClient } from '@supabase/supabase-js';
410
-
411
- const supabase = createClient('https://your-project.supabase.co', 'your-anon-key');
412
-
413
- const { data: { session } } = await supabase.auth.signInWithPassword({
414
- email: 'user@example.com',
415
- password: 'password',
416
- });
417
-
418
- OdinWorkflow.mount(container, {
419
- apiUrl: 'https://ecs-api.getodin.ai/',
420
- projectId: 'your-project-id',
421
- workflowId: 'your-workflow-id',
422
- accessToken: session.access_token,
423
- });
424
- ```
425
-
426
- ### Available Themes
427
-
428
- | Theme | Primary Color |
429
- |-------|---------------|
430
- | `odin` | Blue (#4485FF) |
431
- | `aai` | Orange (#FF5A10) |
432
- | `leah` | Purple (#A855F7) |
433
- | `emerald` | Green (#10B981) |
434
- | `sunset` | Amber (#F59E0B) |
435
-
436
- ### Props Reference
437
-
438
- | Prop | Type | Required | Description |
439
- |------|------|----------|-------------|
440
- | `apiUrl` | string | ✅ | API base URL |
441
- | `projectId` | string | ✅ | Your project ID |
442
- | `workflowId` | string | ✅ | Workflow to display |
443
- | `accessToken` | string | ✅ | Auth token |
444
- | `theme` | string | ❌ | Theme name (default: 'odin') |
445
- | `height` | string/number | ❌ | Container height |
446
- | `width` | string/number | ❌ | Container width |
447
- | `darkMode` | boolean | ❌ | Enable dark mode |
448
- | `hideHeader` | boolean | ❌ | Hide workflow header |
449
- | `hideInputs` | boolean | ❌ | Hide input fields |
450
- | `showControls` | boolean | ❌ | Show zoom controls |
451
- | `initialInputs` | object | ❌ | Pre-fill input values |
452
- | `onExecutionStart` | function | ❌ | Callback when execution starts |
453
- | `onExecutionComplete` | function | ❌ | Callback when execution completes |
454
- | `onError` | function | ❌ | Callback on error |
455
-
456
- See [examples/workflow-embed-supabase.html](./examples/workflow-embed-supabase.html) for a complete Supabase example.
457
-
458
- ---
459
316
 
460
317
  ## Contributing
461
318
 
@@ -467,4 +324,4 @@ See [examples/workflow-embed-supabase.html](./examples/workflow-embed-supabase.h
467
324
 
468
325
  ## License
469
326
 
470
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
327
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -1,13 +1,28 @@
1
+ /**
2
+ * Picks a human-readable string out of a parsed error response body.
3
+ *
4
+ * FastAPI wraps every raised `HTTPException` as `{"detail": ...}`. `detail`
5
+ * is a plain string for most errors, but structured blocks -- notably the
6
+ * credit gate's 402 (`{code, limit_type, message, limit, used, ...}`) -- send
7
+ * an object instead. Interpolating that object into the error message with a
8
+ * template literal used to stringify it via `String(detail)`, producing
9
+ * "HTTP 402: [object Object]" instead of the actual message. Preferring
10
+ * `detail.message` when `detail` is an object keeps that readable; the raw
11
+ * object is still preserved on `APIError.detail` for callers that want to
12
+ * branch on `code`/`limit_type` (see `parseCreditLimitError`).
13
+ */
14
+ export declare function extractErrorMessage(errorData: unknown, fallback: string): string;
1
15
  export interface BaseClientConfig {
2
16
  baseUrl: string;
3
17
  projectId: string;
4
18
  accessToken?: string;
5
19
  apiKey?: string;
6
20
  apiSecret?: string;
21
+ customFetch?: typeof fetch;
7
22
  }
8
23
  export interface APIError extends Error {
9
24
  status?: number;
10
- detail?: string;
25
+ detail?: unknown;
11
26
  }
12
27
  /**
13
28
  * Generic HTTP client for AI Content Creator SDKs
@@ -15,6 +30,7 @@ export interface APIError extends Error {
15
30
  export declare class BaseClient {
16
31
  protected config: BaseClientConfig;
17
32
  protected headers: Record<string, string>;
33
+ protected customFetch: typeof fetch;
18
34
  constructor(config: BaseClientConfig);
19
35
  /**
20
36
  * Make an HTTP request with proper error handling
@@ -44,5 +60,8 @@ export declare class BaseClient {
44
60
  * Create an error object from an HTTP response
45
61
  */
46
62
  protected createErrorFromResponse(response: Response): Promise<APIError>;
63
+ /**
64
+ * Update the access token at runtime. Useful when the application's session token is refreshed.
65
+ */
66
+ setAccessToken(newAccessToken: string): void;
47
67
  }
48
- //# sourceMappingURL=BaseClient.d.ts.map
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Picks a human-readable string out of a parsed error response body.
3
+ *
4
+ * FastAPI wraps every raised `HTTPException` as `{"detail": ...}`. `detail`
5
+ * is a plain string for most errors, but structured blocks -- notably the
6
+ * credit gate's 402 (`{code, limit_type, message, limit, used, ...}`) -- send
7
+ * an object instead. Interpolating that object into the error message with a
8
+ * template literal used to stringify it via `String(detail)`, producing
9
+ * "HTTP 402: [object Object]" instead of the actual message. Preferring
10
+ * `detail.message` when `detail` is an object keeps that readable; the raw
11
+ * object is still preserved on `APIError.detail` for callers that want to
12
+ * branch on `code`/`limit_type` (see `parseCreditLimitError`).
13
+ */
14
+ export declare function extractErrorMessage(errorData: unknown, fallback: string): string;
1
15
  export interface BaseClientConfig {
2
16
  baseUrl: string;
3
17
  projectId: string;
@@ -8,7 +22,7 @@ export interface BaseClientConfig {
8
22
  }
9
23
  export interface APIError extends Error {
10
24
  status?: number;
11
- detail?: string;
25
+ detail?: unknown;
12
26
  }
13
27
  /**
14
28
  * Generic HTTP client for AI Content Creator SDKs
@@ -1 +1 @@
1
- {"version":3,"file":"BaseClient.d.ts","sourceRoot":"","sources":["../src/BaseClient.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,KAAK,CAAC;CAC5B;AAED,MAAM,WAAW,QAAS,SAAQ,KAAK;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB,SAAS,CAAC,MAAM,EAAE,gBAAgB,CAAC;IACnC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,SAAS,CAAC,WAAW,EAAE,OAAO,KAAK,CAAC;gBAExB,MAAM,EAAE,gBAAgB;IAsCpC;;OAEG;cACa,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,MAAc,EACtB,IAAI,CAAC,EAAE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