@odin-ai/sdk 1.0.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/LICENSE +21 -0
- package/README.md +470 -0
- package/dist/BaseClient.d.ts +54 -0
- package/dist/BaseClient.d.ts.map +1 -0
- package/dist/ChatSDK.d.ts +93 -0
- package/dist/ChatSDK.d.ts.map +1 -0
- package/dist/SmartTablesSDK.d.ts +397 -0
- package/dist/SmartTablesSDK.d.ts.map +1 -0
- package/dist/VoiceSDK.d.ts +73 -0
- package/dist/VoiceSDK.d.ts.map +1 -0
- package/dist/WorkflowSDK.d.ts +188 -0
- package/dist/WorkflowSDK.d.ts.map +1 -0
- package/dist/examples/basic-chat.d.ts +2 -0
- package/dist/examples/basic-chat.d.ts.map +1 -0
- package/dist/examples/react-integration.d.ts +7 -0
- package/dist/examples/react-integration.d.ts.map +1 -0
- package/dist/examples/smart-tables-basic.d.ts +2 -0
- package/dist/examples/smart-tables-basic.d.ts.map +1 -0
- package/dist/examples/smart-tables-comprehensive.d.ts +2 -0
- package/dist/examples/smart-tables-comprehensive.d.ts.map +1 -0
- package/dist/examples/smart-tables-demo.d.ts +2 -0
- package/dist/examples/smart-tables-demo.d.ts.map +1 -0
- package/dist/examples/smart-tables-import.d.ts +2 -0
- package/dist/examples/smart-tables-import.d.ts.map +1 -0
- package/dist/examples/streaming-chat.d.ts +2 -0
- package/dist/examples/streaming-chat.d.ts.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +2281 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2295 -0
- package/dist/index.js.map +1 -0
- package/dist/src/BaseClient.d.ts +48 -0
- package/dist/src/BaseClient.d.ts.map +1 -0
- package/dist/src/ChatSDK.d.ts +91 -0
- package/dist/src/ChatSDK.d.ts.map +1 -0
- package/dist/src/SmartTablesSDK.d.ts +312 -0
- package/dist/src/SmartTablesSDK.d.ts.map +1 -0
- package/dist/src/components/MessageBubble.d.ts +24 -0
- package/dist/src/components/MessageBubble.d.ts.map +1 -0
- package/dist/src/components/MessageList.d.ts +28 -0
- package/dist/src/components/MessageList.d.ts.map +1 -0
- package/dist/src/components/index.d.ts +4 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/types.d.ts +348 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/types.d.ts +262 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/useVoiceConversation.d.ts +34 -0
- package/dist/useVoiceConversation.d.ts.map +1 -0
- package/dist/voice-types.d.ts +169 -0
- package/dist/voice-types.d.ts.map +1 -0
- package/dist/workflow-types.d.ts +431 -0
- package/dist/workflow-types.d.ts.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { BaseClient, BaseClientConfig } from './BaseClient';
|
|
2
|
+
export interface Filter {
|
|
3
|
+
column: string;
|
|
4
|
+
operator: string;
|
|
5
|
+
value: string | number | boolean | null;
|
|
6
|
+
}
|
|
7
|
+
export interface PaginationParams {
|
|
8
|
+
page?: number;
|
|
9
|
+
limit?: number;
|
|
10
|
+
search?: string;
|
|
11
|
+
sort_column?: string;
|
|
12
|
+
sort_direction?: "asc" | "desc";
|
|
13
|
+
}
|
|
14
|
+
export interface SmartTable {
|
|
15
|
+
id: string;
|
|
16
|
+
project_id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
description: string;
|
|
19
|
+
schema: SmartTableColumn[];
|
|
20
|
+
table_name: string;
|
|
21
|
+
created_at?: number;
|
|
22
|
+
updated_at?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface SmartTableColumn {
|
|
25
|
+
name: string;
|
|
26
|
+
type: 'text' | 'number' | 'boolean' | 'date' | 'email' | 'url' | 'json';
|
|
27
|
+
description?: string;
|
|
28
|
+
notNull?: boolean;
|
|
29
|
+
unique?: boolean;
|
|
30
|
+
defaultValue?: string | number | boolean | null;
|
|
31
|
+
options?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
export interface TableFilter {
|
|
34
|
+
column: string;
|
|
35
|
+
operator: 'eq' | 'ne' | 'gt' | 'lt' | 'gte' | 'lte' | 'contains' | 'startswith' | 'endswith';
|
|
36
|
+
value: string | number | boolean | null;
|
|
37
|
+
}
|
|
38
|
+
export interface TableSort {
|
|
39
|
+
column: string;
|
|
40
|
+
direction: 'asc' | 'desc';
|
|
41
|
+
}
|
|
42
|
+
export interface TablePagination {
|
|
43
|
+
page?: number;
|
|
44
|
+
limit?: number;
|
|
45
|
+
search?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface TableQueryOptions {
|
|
48
|
+
filters?: TableFilter[];
|
|
49
|
+
sort?: TableSort[];
|
|
50
|
+
pagination?: TablePagination;
|
|
51
|
+
}
|
|
52
|
+
export interface TableQueryResponse {
|
|
53
|
+
data: Record<string, unknown>[];
|
|
54
|
+
total: number;
|
|
55
|
+
page: number;
|
|
56
|
+
limit: number;
|
|
57
|
+
has_more: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface ColumnMapping {
|
|
60
|
+
sourceColumn: string;
|
|
61
|
+
targetColumn: string;
|
|
62
|
+
dataType: string;
|
|
63
|
+
}
|
|
64
|
+
export interface ImportResult {
|
|
65
|
+
data_type_id: string;
|
|
66
|
+
rows_imported: number;
|
|
67
|
+
table_name: string;
|
|
68
|
+
success: boolean;
|
|
69
|
+
message?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface TableView {
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
table_id: string;
|
|
75
|
+
column_meta?: Record<string, {
|
|
76
|
+
name: string;
|
|
77
|
+
order: number;
|
|
78
|
+
visible: boolean;
|
|
79
|
+
width: number;
|
|
80
|
+
type?: string;
|
|
81
|
+
}>;
|
|
82
|
+
filter?: {
|
|
83
|
+
filters?: TableFilter[];
|
|
84
|
+
};
|
|
85
|
+
sort?: {
|
|
86
|
+
configs?: TableSort[];
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export interface TableSchemaColumn {
|
|
90
|
+
name: string;
|
|
91
|
+
type: string;
|
|
92
|
+
options?: Record<string, unknown>;
|
|
93
|
+
order?: number;
|
|
94
|
+
visible?: boolean;
|
|
95
|
+
width?: number;
|
|
96
|
+
}
|
|
97
|
+
export interface TableFullInfo {
|
|
98
|
+
data_schema: TableSchemaColumn[];
|
|
99
|
+
views: TableView[];
|
|
100
|
+
data_view: Record<string, unknown>[];
|
|
101
|
+
total_count: number;
|
|
102
|
+
pagination?: Record<string, unknown>;
|
|
103
|
+
}
|
|
104
|
+
export interface SmartTablesSDKConfig extends BaseClientConfig {
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Integrated Smart Tables SDK that uses the BaseClient
|
|
108
|
+
*/
|
|
109
|
+
export declare class SmartTablesSDK extends BaseClient {
|
|
110
|
+
constructor(config: SmartTablesSDKConfig);
|
|
111
|
+
private getAllKbDataTypes;
|
|
112
|
+
private getKbDataType;
|
|
113
|
+
private createKbDataType;
|
|
114
|
+
private updateKbDataType;
|
|
115
|
+
private deleteKbDataType;
|
|
116
|
+
private getKbDataTypeForView;
|
|
117
|
+
private addDataTypeRow;
|
|
118
|
+
private deleteDataTypeRow;
|
|
119
|
+
private updateDataTypeColumnValue;
|
|
120
|
+
private addDataTypeColumn;
|
|
121
|
+
private deleteDataTypeColumn;
|
|
122
|
+
private renameDataType;
|
|
123
|
+
private updateColumnMetadata;
|
|
124
|
+
private getDataTypeExampleJson;
|
|
125
|
+
private importSmartTable;
|
|
126
|
+
/**
|
|
127
|
+
* Get all smart tables in the project
|
|
128
|
+
* @returns Promise resolving to array of tables
|
|
129
|
+
*/
|
|
130
|
+
getAllTables(): Promise<SmartTable[]>;
|
|
131
|
+
/**
|
|
132
|
+
* Get a specific smart table by ID
|
|
133
|
+
* @param tableId The ID of the table to retrieve
|
|
134
|
+
* @returns Promise resolving to the table details
|
|
135
|
+
*/
|
|
136
|
+
getTable(tableId: string): Promise<SmartTable>;
|
|
137
|
+
/**
|
|
138
|
+
* Create a new smart table
|
|
139
|
+
* @param title Title of the table
|
|
140
|
+
* @param description Description of the table
|
|
141
|
+
* @param metadata Optional metadata for the table
|
|
142
|
+
* @returns Promise resolving to the created table
|
|
143
|
+
*/
|
|
144
|
+
createTable(title: string, description: string, metadata?: Record<string, unknown>): Promise<SmartTable>;
|
|
145
|
+
/**
|
|
146
|
+
* Update an existing smart table
|
|
147
|
+
* @param tableId The ID of the table to update
|
|
148
|
+
* @param title New title for the table
|
|
149
|
+
* @param description New description for the table
|
|
150
|
+
* @param metadata New metadata for the table
|
|
151
|
+
* @returns Promise that resolves when the table is updated
|
|
152
|
+
*/
|
|
153
|
+
updateTable(tableId: string, title: string, description?: string, metadata?: any): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Delete a smart table
|
|
156
|
+
* @param tableId The ID of the table to delete
|
|
157
|
+
* @returns Promise that resolves when the table is deleted
|
|
158
|
+
*/
|
|
159
|
+
deleteTable(tableId: string): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Query table data with advanced filtering, sorting, and pagination
|
|
162
|
+
* @param tableId The ID of the table to query
|
|
163
|
+
* @param options Query options including filters, sorting, and pagination
|
|
164
|
+
* @returns Promise resolving to query results
|
|
165
|
+
*/
|
|
166
|
+
queryTable(tableId: string, options?: TableQueryOptions): Promise<TableQueryResponse>;
|
|
167
|
+
/**
|
|
168
|
+
* Add a new column to the table
|
|
169
|
+
* @param tableId The ID of the table
|
|
170
|
+
* @param column Column configuration
|
|
171
|
+
* @returns Promise that resolves when the column is added
|
|
172
|
+
*/
|
|
173
|
+
addColumn(tableId: string, column: SmartTableColumn): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Update column metadata
|
|
176
|
+
* @param tableId The ID of the table
|
|
177
|
+
* @param columnName Name of the column to update
|
|
178
|
+
* @param updates Column updates
|
|
179
|
+
* @returns Promise that resolves when the column is updated
|
|
180
|
+
*/
|
|
181
|
+
updateColumn(tableId: string, columnName: string, updates: Partial<SmartTableColumn>): Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* Delete a column from the table
|
|
184
|
+
* @param tableId The ID of the table
|
|
185
|
+
* @param columnName Name of the column to delete
|
|
186
|
+
* @returns Promise that resolves when the column is deleted
|
|
187
|
+
*/
|
|
188
|
+
deleteColumn(tableId: string, columnName: string): Promise<void>;
|
|
189
|
+
/**
|
|
190
|
+
* Add a new row to the table
|
|
191
|
+
* @param tableId The ID of the table
|
|
192
|
+
* @param data Row data
|
|
193
|
+
* @returns Promise that resolves when the row is added
|
|
194
|
+
*/
|
|
195
|
+
addRow(tableId: string, data: any): Promise<any>;
|
|
196
|
+
/**
|
|
197
|
+
* Update a specific row and column value
|
|
198
|
+
* @param tableId The ID of the table
|
|
199
|
+
* @param rowId The ID of the row to update
|
|
200
|
+
* @param columnName Name of the column to update
|
|
201
|
+
* @param newValue New value for the column
|
|
202
|
+
* @returns Promise that resolves when the row is updated
|
|
203
|
+
*/
|
|
204
|
+
updateRow(tableId: string, rowId: string, columnName: string, newValue: any): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* Delete a row from the table
|
|
207
|
+
* @param tableId The ID of the table
|
|
208
|
+
* @param rowId The ID of the row to delete
|
|
209
|
+
* @returns Promise that resolves when the row is deleted
|
|
210
|
+
*/
|
|
211
|
+
deleteRow(tableId: string, rowId: string): Promise<void>;
|
|
212
|
+
/**
|
|
213
|
+
* Get full table information including schema, views, and data
|
|
214
|
+
* @param tableId The ID of the table
|
|
215
|
+
* @param options Query options for data fetching
|
|
216
|
+
* @returns Promise resolving to complete table information
|
|
217
|
+
*/
|
|
218
|
+
getTableFullInfo(tableId: string, options?: TableQueryOptions): Promise<TableFullInfo>;
|
|
219
|
+
/**
|
|
220
|
+
* Get complete table data with query results and processed schema in a single call
|
|
221
|
+
* @param tableId The ID of the table
|
|
222
|
+
* @param options Query options for data fetching
|
|
223
|
+
* @returns Promise resolving to both query results and processed schema
|
|
224
|
+
*/
|
|
225
|
+
queryTableWithSchema(tableId: string, options?: TableQueryOptions): Promise<{
|
|
226
|
+
data: Record<string, unknown>[];
|
|
227
|
+
total: number;
|
|
228
|
+
page: number;
|
|
229
|
+
limit: number;
|
|
230
|
+
has_more: boolean;
|
|
231
|
+
columns: TableSchemaColumn[];
|
|
232
|
+
defaultView: TableView | null;
|
|
233
|
+
viewId: string;
|
|
234
|
+
}>;
|
|
235
|
+
/**
|
|
236
|
+
* Query table with grouped data and schema
|
|
237
|
+
* @param tableId The ID of the table
|
|
238
|
+
* @param options Query options including grouping parameters
|
|
239
|
+
* @returns Promise resolving to grouped data and schema
|
|
240
|
+
*/
|
|
241
|
+
queryGroupedTableWithSchema(tableId: string, options: {
|
|
242
|
+
groupColumn: string;
|
|
243
|
+
groupColumnType: string;
|
|
244
|
+
filters?: TableFilter[];
|
|
245
|
+
sort?: TableSort[];
|
|
246
|
+
pagination?: TablePagination;
|
|
247
|
+
}): Promise<{
|
|
248
|
+
grouped_data: Record<string, unknown>[];
|
|
249
|
+
total_count: number;
|
|
250
|
+
data_schema: TableSchemaColumn[];
|
|
251
|
+
defaultView: TableView | null;
|
|
252
|
+
viewId: string;
|
|
253
|
+
}>;
|
|
254
|
+
/**
|
|
255
|
+
* Get processed table schema with view metadata applied
|
|
256
|
+
* @param tableId The ID of the table
|
|
257
|
+
* @param options Query options
|
|
258
|
+
* @returns Promise resolving to processed schema columns
|
|
259
|
+
*/
|
|
260
|
+
getProcessedTableSchema(tableId: string, options?: TableQueryOptions): Promise<{
|
|
261
|
+
columns: TableSchemaColumn[];
|
|
262
|
+
defaultView: TableView | null;
|
|
263
|
+
viewId: string;
|
|
264
|
+
}>;
|
|
265
|
+
/**
|
|
266
|
+
* Get the table schema as JSON
|
|
267
|
+
* @param tableId The ID of the table
|
|
268
|
+
* @returns Promise resolving to the table schema
|
|
269
|
+
*/
|
|
270
|
+
getTableSchema(tableId: string): Promise<any>;
|
|
271
|
+
/**
|
|
272
|
+
* Import data from CSV/Excel file
|
|
273
|
+
* @param title Title for the new table
|
|
274
|
+
* @param description Description for the new table
|
|
275
|
+
* @param columnMappings Array of column mappings
|
|
276
|
+
* @param file File to import
|
|
277
|
+
* @returns Promise resolving to import result
|
|
278
|
+
*/
|
|
279
|
+
importTable(title: string, description: string, columnMappings: ColumnMapping[], file: File): Promise<ImportResult>;
|
|
280
|
+
/**
|
|
281
|
+
* Update a table view
|
|
282
|
+
* @param dataTypeId The ID of the data type
|
|
283
|
+
* @param viewId The ID of the view to update
|
|
284
|
+
* @param updates The view updates to apply
|
|
285
|
+
* @returns Promise resolving when update is complete
|
|
286
|
+
*/
|
|
287
|
+
updateView(dataTypeId: string, viewId: string, updates: {
|
|
288
|
+
name?: string;
|
|
289
|
+
description?: string;
|
|
290
|
+
type?: string;
|
|
291
|
+
sort?: any;
|
|
292
|
+
filter?: any;
|
|
293
|
+
group?: any;
|
|
294
|
+
options?: any;
|
|
295
|
+
settings?: any;
|
|
296
|
+
column_meta?: any;
|
|
297
|
+
enable_share?: boolean;
|
|
298
|
+
}): Promise<void>;
|
|
299
|
+
/**
|
|
300
|
+
* Compute values for specific columns in a row
|
|
301
|
+
* @param dataTypeId The ID of the data type
|
|
302
|
+
* @param rowId The ID of the row to compute
|
|
303
|
+
* @param columnNames Optional list of column names to compute. If not provided, all executable columns will be computed
|
|
304
|
+
* @returns Promise resolving when computation is complete
|
|
305
|
+
*/
|
|
306
|
+
computeRowColumns(dataTypeId: string, rowId: string, columnNames?: string[]): Promise<void>;
|
|
307
|
+
/**
|
|
308
|
+
* Start async column computation for all rows or specific row
|
|
309
|
+
* @param dataTypeId The ID of the data type
|
|
310
|
+
* @param columnName The name of the column to compute
|
|
311
|
+
* @param options Computation options
|
|
312
|
+
* @returns Promise resolving to execution ID
|
|
313
|
+
*/
|
|
314
|
+
startAsyncColumnComputation(dataTypeId: string, columnName: string, options?: {
|
|
315
|
+
rowId?: number;
|
|
316
|
+
recompute?: boolean;
|
|
317
|
+
}): Promise<{
|
|
318
|
+
execution_id: string;
|
|
319
|
+
status: string;
|
|
320
|
+
}>;
|
|
321
|
+
/**
|
|
322
|
+
* Get the status of an async column computation job
|
|
323
|
+
* @param dataTypeId The ID of the data type
|
|
324
|
+
* @param executionId The execution ID returned from startAsyncColumnComputation
|
|
325
|
+
* @returns Promise resolving to job status
|
|
326
|
+
*/
|
|
327
|
+
getJobStatus(dataTypeId: string, executionId: string): Promise<{
|
|
328
|
+
execution_id: string;
|
|
329
|
+
status: string;
|
|
330
|
+
progress_percentage: number;
|
|
331
|
+
processed_rows: number;
|
|
332
|
+
total_rows: number;
|
|
333
|
+
updated_rows: number;
|
|
334
|
+
failed_rows: number[];
|
|
335
|
+
started_at: string;
|
|
336
|
+
completed_at?: string;
|
|
337
|
+
error_message?: string;
|
|
338
|
+
metadata: any;
|
|
339
|
+
}>;
|
|
340
|
+
/**
|
|
341
|
+
* List all async column computation jobs
|
|
342
|
+
* @param dataTypeId The ID of the data type
|
|
343
|
+
* @param options Query options
|
|
344
|
+
* @returns Promise resolving to job list
|
|
345
|
+
*/
|
|
346
|
+
listJobs(dataTypeId: string, options?: {
|
|
347
|
+
limit?: number;
|
|
348
|
+
offset?: number;
|
|
349
|
+
}): Promise<{
|
|
350
|
+
jobs: Array<{
|
|
351
|
+
execution_id: string;
|
|
352
|
+
status: string;
|
|
353
|
+
progress_percentage: number;
|
|
354
|
+
processed_rows: number;
|
|
355
|
+
total_rows: number;
|
|
356
|
+
updated_rows: number;
|
|
357
|
+
started_at: string;
|
|
358
|
+
completed_at?: string;
|
|
359
|
+
task_metadata: any;
|
|
360
|
+
}>;
|
|
361
|
+
total_count: number;
|
|
362
|
+
}>;
|
|
363
|
+
/**
|
|
364
|
+
* Cancel an async column computation job
|
|
365
|
+
* @param dataTypeId The ID of the data type
|
|
366
|
+
* @param executionId The execution ID to cancel
|
|
367
|
+
* @returns Promise resolving when cancellation is complete
|
|
368
|
+
*/
|
|
369
|
+
cancelJob(dataTypeId: string, executionId: string): Promise<{
|
|
370
|
+
execution_id: string;
|
|
371
|
+
cancelled: boolean;
|
|
372
|
+
}>;
|
|
373
|
+
/**
|
|
374
|
+
* Compute values for all rows in a table using LLM
|
|
375
|
+
* @param dataTypeId The ID of the data type
|
|
376
|
+
* @returns Promise resolving to computation results
|
|
377
|
+
*/
|
|
378
|
+
computeAllRows(dataTypeId: string): Promise<{
|
|
379
|
+
message: string;
|
|
380
|
+
total_rows_processed: number;
|
|
381
|
+
total_columns_updated: number;
|
|
382
|
+
updated_columns: string[];
|
|
383
|
+
failed_rows: number[];
|
|
384
|
+
stopped_due_to_failures: boolean;
|
|
385
|
+
retry_attempts: Record<number, number>;
|
|
386
|
+
computation_id?: string;
|
|
387
|
+
history_table?: string;
|
|
388
|
+
}>;
|
|
389
|
+
/**
|
|
390
|
+
* Normalize table data from API response
|
|
391
|
+
* @private
|
|
392
|
+
*/
|
|
393
|
+
private normalizeTable;
|
|
394
|
+
}
|
|
395
|
+
export declare const createSmartTablesSDK: (projectId: string) => SmartTablesSDK;
|
|
396
|
+
export declare const useSmartTablesSDK: (projectId: string) => SmartTablesSDK;
|
|
397
|
+
//# sourceMappingURL=SmartTablesSDK.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmartTablesSDK.d.ts","sourceRoot":"","sources":["../src/SmartTablesSDK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG5D,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,M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MAAM,CAAC;QACxB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;IAOF;;;OAGG;IACH,OAAO,CAAC,cAAc;CAYvB;AAGD,eAAO,MAAM,oBAAoB,GAAI,WAAW,MAAM,mBAErD,CAAC;AAGF,eAAO,MAAM,iBAAiB,GAAI,WAAW,MAAM,mBAElD,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { BaseClient } from './BaseClient';
|
|
2
|
+
import type { VoiceSDKConfig, VoiceConversationState, StartVoiceConversationOptions, VoiceConversationSession, VoiceMessage, VoiceSettings } from './voice-types';
|
|
3
|
+
/**
|
|
4
|
+
* Voice SDK for ElevenLabs integration
|
|
5
|
+
* Provides voice conversation capabilities with automatic chat integration
|
|
6
|
+
*/
|
|
7
|
+
export declare class VoiceSDK extends BaseClient {
|
|
8
|
+
private defaultAgentId?;
|
|
9
|
+
private defaultVoiceSettings?;
|
|
10
|
+
private chatSDK?;
|
|
11
|
+
private activeSessions;
|
|
12
|
+
constructor(config: VoiceSDKConfig);
|
|
13
|
+
/**
|
|
14
|
+
* Start a voice conversation session
|
|
15
|
+
*/
|
|
16
|
+
startVoiceConversation(options?: StartVoiceConversationOptions): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* End a voice conversation session
|
|
19
|
+
*/
|
|
20
|
+
endVoiceSession(sessionId: string, reason?: string): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Get current voice conversation state
|
|
23
|
+
*/
|
|
24
|
+
getVoiceState(sessionId: string): VoiceConversationState | null;
|
|
25
|
+
/**
|
|
26
|
+
* Update voice settings for a session
|
|
27
|
+
*/
|
|
28
|
+
updateVoiceSettings(sessionId: string, settings: VoiceSettings): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Mute/unmute microphone for a session
|
|
31
|
+
*/
|
|
32
|
+
setMicrophoneMuted(sessionId: string, muted: boolean): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Set volume for a session
|
|
35
|
+
*/
|
|
36
|
+
setVolume(sessionId: string, volume: number): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Get audio frequency data for visualization
|
|
39
|
+
*/
|
|
40
|
+
getAudioFrequencyData(sessionId: string): {
|
|
41
|
+
input?: Uint8Array;
|
|
42
|
+
output?: Uint8Array;
|
|
43
|
+
} | null;
|
|
44
|
+
/**
|
|
45
|
+
* Send contextual information to enhance voice conversation
|
|
46
|
+
*/
|
|
47
|
+
sendContextualUpdate(sessionId: string, context: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Get conversation history for a session
|
|
50
|
+
*/
|
|
51
|
+
getConversationHistory(sessionId: string): VoiceMessage[];
|
|
52
|
+
/**
|
|
53
|
+
* Get all active voice sessions
|
|
54
|
+
*/
|
|
55
|
+
getActiveSessions(): VoiceConversationSession[];
|
|
56
|
+
/**
|
|
57
|
+
* Automatically save voice message to database via API
|
|
58
|
+
* This is called internally when voice messages are processed
|
|
59
|
+
*/
|
|
60
|
+
private saveVoiceMessageToAPI;
|
|
61
|
+
/**
|
|
62
|
+
* Private helper methods
|
|
63
|
+
*/
|
|
64
|
+
private generateSessionId;
|
|
65
|
+
private generateMessageId;
|
|
66
|
+
private handleVoiceMessage;
|
|
67
|
+
/**
|
|
68
|
+
* Auto-save voice messages when we have complete conversation pairs
|
|
69
|
+
*/
|
|
70
|
+
private autoSaveVoiceMessages;
|
|
71
|
+
private saveVoiceConversationToChat;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=VoiceSDK.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VoiceSDK.d.ts","sourceRoot":"","sources":["../src/VoiceSDK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EACV,cAAc,EAEd,sBAAsB,EAEtB,6BAA6B,EAC7B,wBAAwB,EACxB,YAAY,EACZ,aAAa,EACd,MAAM,eAAe,CAAC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AO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,kBAAkB;IA0B1B;;OAEG;YACW,qBAAqB;YAmCrB,2BAA2B;CA8B1C"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { BaseClient } from './BaseClient';
|
|
2
|
+
import { WorkflowSDKConfig, Workflow, ListWorkflowsResponse, ExecuteWorkflowOptions, WorkflowExecutionResult, WorkflowStreamCallbacks, WorkflowExecutionSession, WorkflowVersion, ListWorkflowVersionsResponse, ExecutionHistoryEntry, ListExecutionHistoryResponse } from './workflow-types';
|
|
3
|
+
/**
|
|
4
|
+
* SDK for interacting with the Odin AI Workflow system.
|
|
5
|
+
*
|
|
6
|
+
* Allows you to:
|
|
7
|
+
* - List and retrieve workflows
|
|
8
|
+
* - Execute workflows programmatically
|
|
9
|
+
* - Stream real-time execution updates
|
|
10
|
+
* - View execution history
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { WorkflowSDK } from '@odin-ai/sdk';
|
|
15
|
+
*
|
|
16
|
+
* const sdk = new WorkflowSDK({
|
|
17
|
+
* baseUrl: 'https://api.odin.ai/',
|
|
18
|
+
* projectId: 'your-project-id',
|
|
19
|
+
* apiKey: 'your-api-key',
|
|
20
|
+
* apiSecret: 'your-api-secret',
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // List workflows
|
|
24
|
+
* const { tools: workflows } = await sdk.listWorkflows();
|
|
25
|
+
*
|
|
26
|
+
* // Execute with streaming
|
|
27
|
+
* const session = await sdk.executeWorkflowStream(workflowId, {
|
|
28
|
+
* inputs: { name: 'John' },
|
|
29
|
+
* onNodeCompleted: (event) => console.log(`Node ${event.node_id} completed`),
|
|
30
|
+
* onExecutionCompleted: (event) => console.log('Done!', event.result),
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare class WorkflowSDK extends BaseClient {
|
|
35
|
+
/**
|
|
36
|
+
* Initialize the Workflow SDK
|
|
37
|
+
* @param config Configuration object with API credentials and settings
|
|
38
|
+
*/
|
|
39
|
+
constructor(config: WorkflowSDKConfig);
|
|
40
|
+
/**
|
|
41
|
+
* List all workflows in the project
|
|
42
|
+
* @param limit Maximum number of workflows to return (default: 50)
|
|
43
|
+
* @param offset Pagination offset (default: 0)
|
|
44
|
+
* @returns Promise resolving to list of workflows
|
|
45
|
+
*/
|
|
46
|
+
listWorkflows(limit?: number, offset?: number): Promise<ListWorkflowsResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* Get a specific workflow by ID
|
|
49
|
+
* @param workflowId The ID of the workflow to retrieve
|
|
50
|
+
* @returns Promise resolving to the workflow details
|
|
51
|
+
*/
|
|
52
|
+
getWorkflow(workflowId: string): Promise<Workflow>;
|
|
53
|
+
/**
|
|
54
|
+
* Get a specific published version of a workflow
|
|
55
|
+
* @param workflowId The ID of the workflow
|
|
56
|
+
* @param version The version string (e.g., "1.0.0")
|
|
57
|
+
* @returns Promise resolving to the workflow version details
|
|
58
|
+
*/
|
|
59
|
+
getWorkflowVersion(workflowId: string, version: string): Promise<WorkflowVersion>;
|
|
60
|
+
/**
|
|
61
|
+
* List all published versions of a workflow
|
|
62
|
+
* @param workflowId The ID of the workflow
|
|
63
|
+
* @param limit Maximum number of versions to return (default: 20)
|
|
64
|
+
* @param offset Pagination offset (default: 0)
|
|
65
|
+
* @returns Promise resolving to list of workflow versions
|
|
66
|
+
*/
|
|
67
|
+
listWorkflowVersions(workflowId: string, limit?: number, offset?: number): Promise<ListWorkflowVersionsResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Execute a workflow and wait for the result
|
|
70
|
+
*
|
|
71
|
+
* For real-time updates during execution, use `executeWorkflowStream` instead.
|
|
72
|
+
*
|
|
73
|
+
* @param workflowId The ID of the workflow to execute
|
|
74
|
+
* @param options Execution options including inputs
|
|
75
|
+
* @returns Promise resolving to the execution result
|
|
76
|
+
*/
|
|
77
|
+
executeWorkflow(workflowId: string, options?: ExecuteWorkflowOptions): Promise<WorkflowExecutionResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Execute a workflow with real-time streaming updates via SSE.
|
|
80
|
+
*
|
|
81
|
+
* This method provides callbacks for real-time execution events:
|
|
82
|
+
* - `onExecutionStarted`: Fired when execution begins
|
|
83
|
+
* - `onNodeStarted`: Fired when each node begins executing
|
|
84
|
+
* - `onNodeCompleted`: Fired when each node finishes
|
|
85
|
+
* - `onNodeError`: Fired if a node encounters an error
|
|
86
|
+
* - `onNodeSkipped`: Fired when a node is skipped (e.g., conditional branch)
|
|
87
|
+
* - `onExecutionCompleted`: Fired when the entire workflow completes
|
|
88
|
+
* - `onExecutionError`: Fired if the workflow fails
|
|
89
|
+
* - `onAgentChunk`: Fired when an AI agent streams text
|
|
90
|
+
* - `onAgentThinking`: Fired for AI agent reasoning/thinking updates
|
|
91
|
+
*
|
|
92
|
+
* @param workflowId The ID of the workflow to execute
|
|
93
|
+
* @param options Execution options
|
|
94
|
+
* @param callbacks Event callbacks for streaming updates
|
|
95
|
+
* @returns Promise resolving to an execution session for control
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const session = await sdk.executeWorkflowStream(
|
|
100
|
+
* 'workflow-123',
|
|
101
|
+
* { inputs: { name: 'John' } },
|
|
102
|
+
* {
|
|
103
|
+
* onNodeStarted: (e) => console.log(`Starting ${e.node_id}`),
|
|
104
|
+
* onNodeCompleted: (e) => console.log(`Completed ${e.node_id}`),
|
|
105
|
+
* onExecutionCompleted: (e) => {
|
|
106
|
+
* console.log('Workflow complete!', e.result);
|
|
107
|
+
* },
|
|
108
|
+
* onError: (err) => console.error('Error:', err),
|
|
109
|
+
* }
|
|
110
|
+
* );
|
|
111
|
+
*
|
|
112
|
+
* // Later, to cancel execution:
|
|
113
|
+
* session.close();
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
executeWorkflowStream(workflowId: string, options?: ExecuteWorkflowOptions & WorkflowStreamCallbacks): Promise<WorkflowExecutionSession>;
|
|
117
|
+
/**
|
|
118
|
+
* Get execution history for a workflow
|
|
119
|
+
* @param workflowId The ID of the workflow (optional - if not provided, returns all project executions)
|
|
120
|
+
* @param page Page number (1-based, default: 1)
|
|
121
|
+
* @param pageSize Number of results per page (default: 20, max: 100)
|
|
122
|
+
* @returns Promise resolving to execution history
|
|
123
|
+
*/
|
|
124
|
+
getExecutionHistory(workflowId?: string, page?: number, pageSize?: number): Promise<ListExecutionHistoryResponse>;
|
|
125
|
+
/**
|
|
126
|
+
* Get details of a specific execution
|
|
127
|
+
* @param executionId The ID of the execution
|
|
128
|
+
* @returns Promise resolving to execution details
|
|
129
|
+
*/
|
|
130
|
+
getExecution(executionId: string): Promise<ExecutionHistoryEntry>;
|
|
131
|
+
/**
|
|
132
|
+
* Prepare workflow execution by storing inputs in Redis.
|
|
133
|
+
* This is an internal method used by executeWorkflowStream.
|
|
134
|
+
* @private
|
|
135
|
+
*/
|
|
136
|
+
private prepareWorkflowExecution;
|
|
137
|
+
/**
|
|
138
|
+
* Get access token for SSE connection.
|
|
139
|
+
* Uses the configured access token or generates one from API keys.
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
142
|
+
private getAccessTokenForSSE;
|
|
143
|
+
/**
|
|
144
|
+
* Parse SSE event data into a typed event object.
|
|
145
|
+
* @private
|
|
146
|
+
*/
|
|
147
|
+
private parseSSEEvent;
|
|
148
|
+
/**
|
|
149
|
+
* Dispatch event to appropriate callback.
|
|
150
|
+
* @private
|
|
151
|
+
*/
|
|
152
|
+
private dispatchEvent;
|
|
153
|
+
/**
|
|
154
|
+
* Upload a file for use with file upload trigger workflows.
|
|
155
|
+
* Returns a temporary file reference to use with executeWorkflowStream.
|
|
156
|
+
*
|
|
157
|
+
* @param file The file to upload
|
|
158
|
+
* @returns Promise resolving to file reference info
|
|
159
|
+
*/
|
|
160
|
+
uploadWorkflowFile(file: File): Promise<{
|
|
161
|
+
temp_file_ref: string;
|
|
162
|
+
filenames: string[];
|
|
163
|
+
expires_in_seconds: number;
|
|
164
|
+
}>;
|
|
165
|
+
/**
|
|
166
|
+
* Upload multiple files for use with file upload trigger workflows.
|
|
167
|
+
* Returns a temporary file reference to use with executeWorkflowStream.
|
|
168
|
+
*
|
|
169
|
+
* @param files Array of files to upload
|
|
170
|
+
* @returns Promise resolving to file reference info
|
|
171
|
+
*/
|
|
172
|
+
uploadWorkflowFiles(files: File[]): Promise<{
|
|
173
|
+
temp_file_ref: string;
|
|
174
|
+
filenames: string[];
|
|
175
|
+
expires_in_seconds: number;
|
|
176
|
+
}>;
|
|
177
|
+
/**
|
|
178
|
+
* Execute a workflow with file upload trigger.
|
|
179
|
+
* This is a convenience method that handles file upload and execution in one call.
|
|
180
|
+
*
|
|
181
|
+
* @param workflowId The ID of the workflow to execute
|
|
182
|
+
* @param file File(s) to upload
|
|
183
|
+
* @param options Additional execution options
|
|
184
|
+
* @returns Promise resolving to the execution result
|
|
185
|
+
*/
|
|
186
|
+
executeWorkflowWithFile(workflowId: string, file: File | File[], options?: Omit<ExecuteWorkflowOptions, 'triggerMode'>): Promise<WorkflowExecutionResult>;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=WorkflowSDK.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkflowSDK.d.ts","sourceRoot":"","sources":["../src/WorkflowSDK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EAEvB,uBAAuB,EACvB,wBAAwB,EACxB,eAAe,EACf,4BAA4B,EAC5B,qBAAqB,EACrB,4BAA4B,EAG7B,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,WAAY,SAAQ,UAAU;IACzC;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