@erdoai/types 0.1.4 → 0.1.6
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 +20 -0
- package/dist/index.cjs +18 -0
- package/dist/index.d.cts +235 -0
- package/dist/index.d.ts +49 -4
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -19,6 +19,14 @@ import type {
|
|
|
19
19
|
InvokeResult,
|
|
20
20
|
InvokeParams,
|
|
21
21
|
UIContentType,
|
|
22
|
+
// Token types
|
|
23
|
+
CreateTokenParams,
|
|
24
|
+
TokenResponse,
|
|
25
|
+
// Thread types
|
|
26
|
+
Thread,
|
|
27
|
+
CreateThreadParams,
|
|
28
|
+
ListThreadsResponse,
|
|
29
|
+
SendMessageParams,
|
|
22
30
|
} from '@erdoai/types';
|
|
23
31
|
```
|
|
24
32
|
|
|
@@ -31,6 +39,18 @@ import type {
|
|
|
31
39
|
- **`InvokeResult`** - Processed result with `messages`, `steps`, `events`, `result`
|
|
32
40
|
- **`InvokeParams`** - Parameters for invoking an Erdo agent
|
|
33
41
|
|
|
42
|
+
### Token Types
|
|
43
|
+
|
|
44
|
+
- **`CreateTokenParams`** - Parameters for creating a scoped token (botKeys, datasetIds, externalUserId)
|
|
45
|
+
- **`TokenResponse`** - Token creation response (token, expiresAt)
|
|
46
|
+
|
|
47
|
+
### Thread Types
|
|
48
|
+
|
|
49
|
+
- **`Thread`** - Thread object (id, name, createdAt, updatedAt)
|
|
50
|
+
- **`CreateThreadParams`** - Parameters for creating a thread (name, datasetIds)
|
|
51
|
+
- **`ListThreadsResponse`** - Response from listThreads (threads array)
|
|
52
|
+
- **`SendMessageParams`** - Parameters for sending a message (content, botKey)
|
|
53
|
+
|
|
34
54
|
### UI Types
|
|
35
55
|
|
|
36
56
|
- **`UIContentType`** - Content type hints for UI rendering (charts, tables, etc.)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var index_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(index_exports);
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Erdo TypeScript SDK Types
|
|
3
|
+
*
|
|
4
|
+
* TODO: Auto-generate from Go types via `erdo gen-ts-client`
|
|
5
|
+
* These types mirror erdo-python-sdk/erdo/_generated/types.py
|
|
6
|
+
*/
|
|
7
|
+
interface Message {
|
|
8
|
+
role: 'user' | 'assistant' | 'system';
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
interface InvokeParams {
|
|
12
|
+
/** Messages to send to the agent */
|
|
13
|
+
messages?: Message[];
|
|
14
|
+
/** Parameters to pass to the agent */
|
|
15
|
+
parameters?: Record<string, unknown>;
|
|
16
|
+
/** Dataset slugs to include (e.g. ["my-dataset"] or ["org.my-dataset"]) */
|
|
17
|
+
datasets?: string[];
|
|
18
|
+
/** Invocation mode */
|
|
19
|
+
mode?: InvocationMode;
|
|
20
|
+
/** Manual mock responses for mode="manual" */
|
|
21
|
+
manualMocks?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
type InvocationMode = 'live' | 'replay' | 'manual' | {
|
|
24
|
+
mode: 'replay';
|
|
25
|
+
refresh?: boolean;
|
|
26
|
+
};
|
|
27
|
+
interface Result {
|
|
28
|
+
status?: string;
|
|
29
|
+
parameters?: Record<string, unknown>;
|
|
30
|
+
output?: ResultOutput;
|
|
31
|
+
message?: string;
|
|
32
|
+
error?: string;
|
|
33
|
+
}
|
|
34
|
+
interface ResultOutput {
|
|
35
|
+
content?: ContentItem[];
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
interface ContentItem {
|
|
39
|
+
id?: string;
|
|
40
|
+
content_type: ContentType | string;
|
|
41
|
+
ui_content_type?: UIContentType | {
|
|
42
|
+
Valid: boolean;
|
|
43
|
+
String: string;
|
|
44
|
+
};
|
|
45
|
+
content: unknown;
|
|
46
|
+
data?: unknown;
|
|
47
|
+
chartConfig?: unknown;
|
|
48
|
+
chartData?: unknown[];
|
|
49
|
+
tableColumns?: Array<{
|
|
50
|
+
column_name: string;
|
|
51
|
+
key: string;
|
|
52
|
+
format?: string;
|
|
53
|
+
value_type?: 'number' | 'category' | 'date';
|
|
54
|
+
}>;
|
|
55
|
+
tableData?: unknown[];
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
type ContentType = 'text' | 'json' | 'code' | 'table' | 'image' | 'error';
|
|
59
|
+
type UIContentType = 'chart' | 'bar_chart' | 'line_chart' | 'pie_chart' | 'scatter_chart' | 'heatmap' | 'table' | 'markdown' | string;
|
|
60
|
+
interface InvokeResult {
|
|
61
|
+
/** Whether the invocation succeeded */
|
|
62
|
+
success: boolean;
|
|
63
|
+
/** Bot key used for invocation */
|
|
64
|
+
botKey?: string;
|
|
65
|
+
/** Unique invocation ID */
|
|
66
|
+
invocationId?: string;
|
|
67
|
+
/** The actual bot result */
|
|
68
|
+
result?: Result;
|
|
69
|
+
/** Messages from the invocation */
|
|
70
|
+
messages: MessageContent[];
|
|
71
|
+
/** All raw SSE events (for debugging/analysis) */
|
|
72
|
+
events: SSEEvent[];
|
|
73
|
+
/** Step execution info */
|
|
74
|
+
steps: StepInfo[];
|
|
75
|
+
/** Error message if failed */
|
|
76
|
+
error?: string;
|
|
77
|
+
}
|
|
78
|
+
interface MessageContent {
|
|
79
|
+
role: 'user' | 'assistant' | 'system';
|
|
80
|
+
content: string;
|
|
81
|
+
}
|
|
82
|
+
interface StepInfo {
|
|
83
|
+
key: string;
|
|
84
|
+
action: string;
|
|
85
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
86
|
+
}
|
|
87
|
+
interface SSEEvent {
|
|
88
|
+
type?: string;
|
|
89
|
+
payload?: unknown;
|
|
90
|
+
metadata?: SSEEventMetadata;
|
|
91
|
+
[key: string]: unknown;
|
|
92
|
+
}
|
|
93
|
+
interface SSEEventMetadata {
|
|
94
|
+
user_visibility?: 'visible' | 'hidden';
|
|
95
|
+
bot_visibility?: 'visible' | 'hidden';
|
|
96
|
+
content_type?: ContentType;
|
|
97
|
+
ui_content_type?: UIContentType;
|
|
98
|
+
message_content_id?: string;
|
|
99
|
+
[key: string]: unknown;
|
|
100
|
+
}
|
|
101
|
+
interface ChartConfig {
|
|
102
|
+
type: ChartType;
|
|
103
|
+
title?: string;
|
|
104
|
+
xAxis?: AxisConfig;
|
|
105
|
+
yAxis?: AxisConfig;
|
|
106
|
+
series?: SeriesConfig[];
|
|
107
|
+
chartConfig?: Record<string, ChartSeriesConfig>;
|
|
108
|
+
}
|
|
109
|
+
type ChartType = 'bar' | 'line' | 'pie' | 'scatter' | 'area' | 'heatmap';
|
|
110
|
+
interface AxisConfig {
|
|
111
|
+
label?: string;
|
|
112
|
+
dataKey?: string;
|
|
113
|
+
type?: 'category' | 'number' | 'time';
|
|
114
|
+
}
|
|
115
|
+
interface SeriesConfig {
|
|
116
|
+
dataKey: string;
|
|
117
|
+
name?: string;
|
|
118
|
+
color?: string;
|
|
119
|
+
}
|
|
120
|
+
interface ChartSeriesConfig {
|
|
121
|
+
label: string;
|
|
122
|
+
color?: string;
|
|
123
|
+
}
|
|
124
|
+
interface ChartContent extends ContentItem {
|
|
125
|
+
ui_content_type: 'chart' | 'bar_chart' | 'line_chart' | 'pie_chart' | 'scatter_chart';
|
|
126
|
+
data: unknown[];
|
|
127
|
+
config?: ChartConfig;
|
|
128
|
+
}
|
|
129
|
+
interface ErdoClientConfig {
|
|
130
|
+
/** API endpoint URL */
|
|
131
|
+
endpoint?: string;
|
|
132
|
+
/** Authentication token (API key) - use for server-side requests */
|
|
133
|
+
authToken?: string;
|
|
134
|
+
/** Scoped token - use for client-side requests (created via createToken) */
|
|
135
|
+
token?: string;
|
|
136
|
+
}
|
|
137
|
+
/** Interface for ErdoClient - implemented by @erdoai/server */
|
|
138
|
+
interface ErdoClient {
|
|
139
|
+
invoke(botKey: string, params?: InvokeParams): Promise<InvokeResult>;
|
|
140
|
+
invokeStream(botKey: string, params?: InvokeParams): AsyncGenerator<SSEEvent, void, unknown>;
|
|
141
|
+
createToken?(params: CreateTokenParams): Promise<TokenResponse>;
|
|
142
|
+
createThread?(params?: CreateThreadParams): Promise<Thread>;
|
|
143
|
+
listThreads?(): Promise<ListThreadsResponse>;
|
|
144
|
+
getThread?(threadId: string): Promise<Thread>;
|
|
145
|
+
sendMessage?(threadId: string, params: SendMessageParams): AsyncGenerator<SSEEvent, void, unknown>;
|
|
146
|
+
sendMessageAndWait?(threadId: string, params: SendMessageParams): Promise<SSEEvent[]>;
|
|
147
|
+
}
|
|
148
|
+
interface CreateTokenParams {
|
|
149
|
+
/** Bot keys to grant access to */
|
|
150
|
+
botKeys?: string[];
|
|
151
|
+
/** Dataset IDs to grant access to */
|
|
152
|
+
datasetIds?: string[];
|
|
153
|
+
/** Optional identifier for the external user */
|
|
154
|
+
externalUserId?: string;
|
|
155
|
+
/** Token expiry in seconds (default: 3600 = 1 hour, max: 86400 = 24 hours) */
|
|
156
|
+
expiresInSeconds?: number;
|
|
157
|
+
}
|
|
158
|
+
interface TokenResponse {
|
|
159
|
+
/** The scoped token (only returned once) */
|
|
160
|
+
token: string;
|
|
161
|
+
/** When the token expires */
|
|
162
|
+
expiresAt: string;
|
|
163
|
+
}
|
|
164
|
+
interface ToolInvocation {
|
|
165
|
+
invocation_id: string;
|
|
166
|
+
action: string;
|
|
167
|
+
params: Record<string, unknown>;
|
|
168
|
+
}
|
|
169
|
+
interface ToolResult {
|
|
170
|
+
invocation_id: string;
|
|
171
|
+
result: unknown;
|
|
172
|
+
}
|
|
173
|
+
interface ToolGroup {
|
|
174
|
+
invocation: ToolInvocation;
|
|
175
|
+
result?: ToolResult;
|
|
176
|
+
}
|
|
177
|
+
type LogLevel = 'info' | 'error' | 'requires_info';
|
|
178
|
+
interface LogEntry {
|
|
179
|
+
level: LogLevel;
|
|
180
|
+
message: string;
|
|
181
|
+
timestamp?: string;
|
|
182
|
+
}
|
|
183
|
+
interface WebSearchResult {
|
|
184
|
+
title: string;
|
|
185
|
+
description: string;
|
|
186
|
+
url: string;
|
|
187
|
+
}
|
|
188
|
+
interface WebSearchOutput {
|
|
189
|
+
results: WebSearchResult[];
|
|
190
|
+
}
|
|
191
|
+
interface WebParseOutput {
|
|
192
|
+
title: string;
|
|
193
|
+
description: string;
|
|
194
|
+
content: string;
|
|
195
|
+
url: string;
|
|
196
|
+
}
|
|
197
|
+
interface CodeExecOutputItem {
|
|
198
|
+
index: number;
|
|
199
|
+
level: 'output' | 'error' | 'warning';
|
|
200
|
+
message: string;
|
|
201
|
+
timestamp?: string;
|
|
202
|
+
}
|
|
203
|
+
type InvocationStatus = 'pending' | 'running' | 'success' | 'error' | 'requires info' | 'go to step' | 'skipped' | 'break' | 'cancelled';
|
|
204
|
+
interface BotInvocationInfo {
|
|
205
|
+
id: string;
|
|
206
|
+
bot_id: string;
|
|
207
|
+
bot_key: string;
|
|
208
|
+
bot_name?: string;
|
|
209
|
+
status: InvocationStatus;
|
|
210
|
+
started_at?: string;
|
|
211
|
+
completed_at?: string;
|
|
212
|
+
}
|
|
213
|
+
interface CreateThreadParams {
|
|
214
|
+
/** Optional thread name */
|
|
215
|
+
name?: string;
|
|
216
|
+
/** Dataset IDs to attach to the thread */
|
|
217
|
+
datasetIds?: string[];
|
|
218
|
+
}
|
|
219
|
+
interface Thread {
|
|
220
|
+
id: string;
|
|
221
|
+
name: string;
|
|
222
|
+
createdAt: string;
|
|
223
|
+
updatedAt: string;
|
|
224
|
+
}
|
|
225
|
+
interface ListThreadsResponse {
|
|
226
|
+
threads: Thread[];
|
|
227
|
+
}
|
|
228
|
+
interface SendMessageParams {
|
|
229
|
+
/** Message content */
|
|
230
|
+
content: string;
|
|
231
|
+
/** Optional bot key to use (must be in token scope) */
|
|
232
|
+
botKey?: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export type { AxisConfig, BotInvocationInfo, ChartConfig, ChartContent, ChartSeriesConfig, ChartType, CodeExecOutputItem, ContentItem, ContentType, CreateThreadParams, CreateTokenParams, ErdoClient, ErdoClientConfig, InvocationMode, InvocationStatus, InvokeParams, InvokeResult, ListThreadsResponse, LogEntry, LogLevel, Message, MessageContent, Result, ResultOutput, SSEEvent, SSEEventMetadata, SendMessageParams, SeriesConfig, StepInfo, Thread, TokenResponse, ToolGroup, ToolInvocation, ToolResult, UIContentType, WebParseOutput, WebSearchOutput, WebSearchResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -60,8 +60,8 @@ type UIContentType = 'chart' | 'bar_chart' | 'line_chart' | 'pie_chart' | 'scatt
|
|
|
60
60
|
interface InvokeResult {
|
|
61
61
|
/** Whether the invocation succeeded */
|
|
62
62
|
success: boolean;
|
|
63
|
-
/** Bot
|
|
64
|
-
|
|
63
|
+
/** Bot key used for invocation */
|
|
64
|
+
botKey?: string;
|
|
65
65
|
/** Unique invocation ID */
|
|
66
66
|
invocationId?: string;
|
|
67
67
|
/** The actual bot result */
|
|
@@ -129,13 +129,37 @@ interface ChartContent extends ContentItem {
|
|
|
129
129
|
interface ErdoClientConfig {
|
|
130
130
|
/** API endpoint URL */
|
|
131
131
|
endpoint?: string;
|
|
132
|
-
/** Authentication token (API key) */
|
|
132
|
+
/** Authentication token (API key) - use for server-side requests */
|
|
133
133
|
authToken?: string;
|
|
134
|
+
/** Scoped token - use for client-side requests (created via createToken) */
|
|
135
|
+
token?: string;
|
|
134
136
|
}
|
|
135
137
|
/** Interface for ErdoClient - implemented by @erdoai/server */
|
|
136
138
|
interface ErdoClient {
|
|
137
139
|
invoke(botKey: string, params?: InvokeParams): Promise<InvokeResult>;
|
|
138
140
|
invokeStream(botKey: string, params?: InvokeParams): AsyncGenerator<SSEEvent, void, unknown>;
|
|
141
|
+
createToken?(params: CreateTokenParams): Promise<TokenResponse>;
|
|
142
|
+
createThread?(params?: CreateThreadParams): Promise<Thread>;
|
|
143
|
+
listThreads?(): Promise<ListThreadsResponse>;
|
|
144
|
+
getThread?(threadId: string): Promise<Thread>;
|
|
145
|
+
sendMessage?(threadId: string, params: SendMessageParams): AsyncGenerator<SSEEvent, void, unknown>;
|
|
146
|
+
sendMessageAndWait?(threadId: string, params: SendMessageParams): Promise<SSEEvent[]>;
|
|
147
|
+
}
|
|
148
|
+
interface CreateTokenParams {
|
|
149
|
+
/** Bot keys to grant access to */
|
|
150
|
+
botKeys?: string[];
|
|
151
|
+
/** Dataset IDs to grant access to */
|
|
152
|
+
datasetIds?: string[];
|
|
153
|
+
/** Optional identifier for the external user */
|
|
154
|
+
externalUserId?: string;
|
|
155
|
+
/** Token expiry in seconds (default: 3600 = 1 hour, max: 86400 = 24 hours) */
|
|
156
|
+
expiresInSeconds?: number;
|
|
157
|
+
}
|
|
158
|
+
interface TokenResponse {
|
|
159
|
+
/** The scoped token (only returned once) */
|
|
160
|
+
token: string;
|
|
161
|
+
/** When the token expires */
|
|
162
|
+
expiresAt: string;
|
|
139
163
|
}
|
|
140
164
|
interface ToolInvocation {
|
|
141
165
|
invocation_id: string;
|
|
@@ -186,5 +210,26 @@ interface BotInvocationInfo {
|
|
|
186
210
|
started_at?: string;
|
|
187
211
|
completed_at?: string;
|
|
188
212
|
}
|
|
213
|
+
interface CreateThreadParams {
|
|
214
|
+
/** Optional thread name */
|
|
215
|
+
name?: string;
|
|
216
|
+
/** Dataset IDs to attach to the thread */
|
|
217
|
+
datasetIds?: string[];
|
|
218
|
+
}
|
|
219
|
+
interface Thread {
|
|
220
|
+
id: string;
|
|
221
|
+
name: string;
|
|
222
|
+
createdAt: string;
|
|
223
|
+
updatedAt: string;
|
|
224
|
+
}
|
|
225
|
+
interface ListThreadsResponse {
|
|
226
|
+
threads: Thread[];
|
|
227
|
+
}
|
|
228
|
+
interface SendMessageParams {
|
|
229
|
+
/** Message content */
|
|
230
|
+
content: string;
|
|
231
|
+
/** Optional bot key to use (must be in token scope) */
|
|
232
|
+
botKey?: string;
|
|
233
|
+
}
|
|
189
234
|
|
|
190
|
-
export type { AxisConfig, BotInvocationInfo, ChartConfig, ChartContent, ChartSeriesConfig, ChartType, CodeExecOutputItem, ContentItem, ContentType, ErdoClient, ErdoClientConfig, InvocationMode, InvocationStatus, InvokeParams, InvokeResult, LogEntry, LogLevel, Message, MessageContent, Result, ResultOutput, SSEEvent, SSEEventMetadata, SeriesConfig, StepInfo, ToolGroup, ToolInvocation, ToolResult, UIContentType, WebParseOutput, WebSearchOutput, WebSearchResult };
|
|
235
|
+
export type { AxisConfig, BotInvocationInfo, ChartConfig, ChartContent, ChartSeriesConfig, ChartType, CodeExecOutputItem, ContentItem, ContentType, CreateThreadParams, CreateTokenParams, ErdoClient, ErdoClientConfig, InvocationMode, InvocationStatus, InvokeParams, InvokeResult, ListThreadsResponse, LogEntry, LogLevel, Message, MessageContent, Result, ResultOutput, SSEEvent, SSEEventMetadata, SendMessageParams, SeriesConfig, StepInfo, Thread, TokenResponse, ToolGroup, ToolInvocation, ToolResult, UIContentType, WebParseOutput, WebSearchOutput, WebSearchResult };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@erdoai/types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Erdo SDK shared types",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js"
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
13
14
|
}
|
|
14
15
|
},
|
|
15
16
|
"files": [
|
|
@@ -34,4 +35,4 @@
|
|
|
34
35
|
"tsup": "^8.5.1",
|
|
35
36
|
"typescript": "^5.9.3"
|
|
36
37
|
}
|
|
37
|
-
}
|
|
38
|
+
}
|