@agent-commons/sdk 0.1.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.
- package/dist/index.cjs +382 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +867 -0
- package/dist/index.d.ts +867 -0
- package/dist/index.mjs +354 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +35 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,867 @@
|
|
|
1
|
+
type ModelProvider = 'openai' | 'anthropic' | 'google' | 'mistral' | 'groq' | 'ollama';
|
|
2
|
+
interface ModelConfig {
|
|
3
|
+
provider: ModelProvider;
|
|
4
|
+
modelId: string;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
temperature?: number;
|
|
8
|
+
maxTokens?: number;
|
|
9
|
+
topP?: number;
|
|
10
|
+
}
|
|
11
|
+
interface Agent {
|
|
12
|
+
agentId: string;
|
|
13
|
+
name: string;
|
|
14
|
+
owner?: string;
|
|
15
|
+
instructions?: string;
|
|
16
|
+
persona?: string;
|
|
17
|
+
avatar?: string;
|
|
18
|
+
modelProvider: ModelProvider;
|
|
19
|
+
modelId: string;
|
|
20
|
+
temperature?: number;
|
|
21
|
+
maxTokens?: number;
|
|
22
|
+
topP?: number;
|
|
23
|
+
presencePenalty?: number;
|
|
24
|
+
frequencyPenalty?: number;
|
|
25
|
+
commonTools?: string[];
|
|
26
|
+
externalTools?: string[];
|
|
27
|
+
isLiaison?: boolean;
|
|
28
|
+
externalUrl?: string;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
}
|
|
31
|
+
interface CreateAgentParams {
|
|
32
|
+
name: string;
|
|
33
|
+
instructions?: string;
|
|
34
|
+
persona?: string;
|
|
35
|
+
owner?: string;
|
|
36
|
+
modelProvider?: ModelProvider;
|
|
37
|
+
modelId?: string;
|
|
38
|
+
modelApiKey?: string;
|
|
39
|
+
modelBaseUrl?: string;
|
|
40
|
+
temperature?: number;
|
|
41
|
+
maxTokens?: number;
|
|
42
|
+
topP?: number;
|
|
43
|
+
commonTools?: string[];
|
|
44
|
+
avatar?: string;
|
|
45
|
+
}
|
|
46
|
+
interface Session {
|
|
47
|
+
sessionId: string;
|
|
48
|
+
agentId: string;
|
|
49
|
+
initiator: string;
|
|
50
|
+
title?: string;
|
|
51
|
+
model: ModelConfig & {
|
|
52
|
+
name?: string;
|
|
53
|
+
};
|
|
54
|
+
createdAt: string;
|
|
55
|
+
}
|
|
56
|
+
interface RunParams {
|
|
57
|
+
agentId: string;
|
|
58
|
+
messages: ChatMessage[];
|
|
59
|
+
sessionId?: string;
|
|
60
|
+
}
|
|
61
|
+
interface ChatMessage {
|
|
62
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
63
|
+
content: string;
|
|
64
|
+
tool_call_id?: string;
|
|
65
|
+
name?: string;
|
|
66
|
+
}
|
|
67
|
+
type StreamEventType = 'token' | 'toolStart' | 'toolEnd' | 'agent_step' | 'final' | 'completed' | 'failed' | 'cancelled' | 'status' | 'heartbeat' | 'error';
|
|
68
|
+
interface StreamEvent {
|
|
69
|
+
type: StreamEventType;
|
|
70
|
+
role?: string;
|
|
71
|
+
content?: string;
|
|
72
|
+
toolName?: string;
|
|
73
|
+
input?: string;
|
|
74
|
+
output?: any;
|
|
75
|
+
timestamp?: string;
|
|
76
|
+
payload?: any;
|
|
77
|
+
message?: string;
|
|
78
|
+
}
|
|
79
|
+
interface Workflow {
|
|
80
|
+
workflowId: string;
|
|
81
|
+
name: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
definition: WorkflowDefinition;
|
|
84
|
+
ownerId: string;
|
|
85
|
+
ownerType: 'user' | 'agent';
|
|
86
|
+
isPublic?: boolean;
|
|
87
|
+
category?: string;
|
|
88
|
+
tags?: string[];
|
|
89
|
+
createdAt: string;
|
|
90
|
+
}
|
|
91
|
+
interface WorkflowDefinition {
|
|
92
|
+
nodes: WorkflowNode[];
|
|
93
|
+
edges: WorkflowEdge[];
|
|
94
|
+
outputMapping?: Record<string, string>;
|
|
95
|
+
}
|
|
96
|
+
type WorkflowNodeType = 'tool' | 'input' | 'output' | 'condition' | 'transform' | 'loop' | 'agent_processor' | 'human_approval';
|
|
97
|
+
interface WorkflowNode {
|
|
98
|
+
id: string;
|
|
99
|
+
type: WorkflowNodeType | string;
|
|
100
|
+
toolId?: string;
|
|
101
|
+
position?: {
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
};
|
|
105
|
+
config?: Record<string, any>;
|
|
106
|
+
}
|
|
107
|
+
interface WorkflowEdge {
|
|
108
|
+
id: string;
|
|
109
|
+
source: string;
|
|
110
|
+
target: string;
|
|
111
|
+
/** For condition nodes: 'true' routes the true branch, 'false' the false branch */
|
|
112
|
+
sourceHandle?: string;
|
|
113
|
+
targetHandle?: string;
|
|
114
|
+
mapping?: Record<string, string>;
|
|
115
|
+
}
|
|
116
|
+
interface WorkflowExecution {
|
|
117
|
+
executionId: string;
|
|
118
|
+
workflowId: string;
|
|
119
|
+
status: 'running' | 'completed' | 'failed' | 'cancelled' | 'awaiting_approval';
|
|
120
|
+
startedAt?: string;
|
|
121
|
+
completedAt?: string;
|
|
122
|
+
outputData?: any;
|
|
123
|
+
nodeResults?: Record<string, any>;
|
|
124
|
+
errorMessage?: string;
|
|
125
|
+
currentNode?: string;
|
|
126
|
+
/** Set when status is 'awaiting_approval' */
|
|
127
|
+
pausedAtNode?: string;
|
|
128
|
+
approvalToken?: string;
|
|
129
|
+
}
|
|
130
|
+
interface Task {
|
|
131
|
+
taskId: string;
|
|
132
|
+
agentId: string;
|
|
133
|
+
sessionId: string;
|
|
134
|
+
title: string;
|
|
135
|
+
description?: string;
|
|
136
|
+
status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
137
|
+
executionMode: 'single' | 'workflow' | 'sequential';
|
|
138
|
+
workflowId?: string;
|
|
139
|
+
cronExpression?: string;
|
|
140
|
+
isRecurring?: boolean;
|
|
141
|
+
priority?: number;
|
|
142
|
+
timeoutMs?: number;
|
|
143
|
+
progress?: number;
|
|
144
|
+
resultContent?: any;
|
|
145
|
+
summary?: string;
|
|
146
|
+
errorMessage?: string;
|
|
147
|
+
createdBy: string;
|
|
148
|
+
createdByType: 'user' | 'agent';
|
|
149
|
+
createdAt: string;
|
|
150
|
+
}
|
|
151
|
+
interface CreateTaskParams {
|
|
152
|
+
agentId: string;
|
|
153
|
+
sessionId: string;
|
|
154
|
+
title: string;
|
|
155
|
+
description?: string;
|
|
156
|
+
executionMode?: 'single' | 'workflow' | 'sequential';
|
|
157
|
+
workflowId?: string;
|
|
158
|
+
workflowInputs?: Record<string, any>;
|
|
159
|
+
cronExpression?: string;
|
|
160
|
+
scheduledFor?: Date;
|
|
161
|
+
isRecurring?: boolean;
|
|
162
|
+
dependsOn?: string[];
|
|
163
|
+
tools?: string[];
|
|
164
|
+
toolConstraintType?: 'hard' | 'soft' | 'none';
|
|
165
|
+
toolInstructions?: string;
|
|
166
|
+
priority?: number;
|
|
167
|
+
/** Max execution time in milliseconds for workflow tasks */
|
|
168
|
+
timeoutMs?: number;
|
|
169
|
+
createdBy: string;
|
|
170
|
+
createdByType: 'user' | 'agent';
|
|
171
|
+
}
|
|
172
|
+
interface Tool {
|
|
173
|
+
toolId: string;
|
|
174
|
+
name: string;
|
|
175
|
+
displayName?: string;
|
|
176
|
+
description?: string;
|
|
177
|
+
schema: any;
|
|
178
|
+
owner?: string;
|
|
179
|
+
isPublic?: boolean;
|
|
180
|
+
tags?: string[];
|
|
181
|
+
createdAt: string;
|
|
182
|
+
}
|
|
183
|
+
interface CreateToolParams {
|
|
184
|
+
name: string;
|
|
185
|
+
displayName?: string;
|
|
186
|
+
description?: string;
|
|
187
|
+
schema: any;
|
|
188
|
+
owner?: string;
|
|
189
|
+
ownerType?: 'user' | 'agent';
|
|
190
|
+
visibility?: 'private' | 'public' | 'platform';
|
|
191
|
+
tags?: string[];
|
|
192
|
+
}
|
|
193
|
+
interface ToolKey {
|
|
194
|
+
keyId: string;
|
|
195
|
+
toolId?: string;
|
|
196
|
+
ownerId: string;
|
|
197
|
+
ownerType: 'user' | 'agent';
|
|
198
|
+
keyName: string;
|
|
199
|
+
displayName?: string;
|
|
200
|
+
description?: string;
|
|
201
|
+
maskedValue?: string;
|
|
202
|
+
isActive?: boolean;
|
|
203
|
+
usageCount?: number;
|
|
204
|
+
createdAt: string;
|
|
205
|
+
}
|
|
206
|
+
interface CreateToolKeyParams {
|
|
207
|
+
toolId?: string;
|
|
208
|
+
ownerId: string;
|
|
209
|
+
ownerType: 'user' | 'agent';
|
|
210
|
+
keyName: string;
|
|
211
|
+
value: string;
|
|
212
|
+
displayName?: string;
|
|
213
|
+
description?: string;
|
|
214
|
+
keyType?: string;
|
|
215
|
+
}
|
|
216
|
+
interface ToolPermission {
|
|
217
|
+
id: string;
|
|
218
|
+
toolId: string;
|
|
219
|
+
subjectId: string;
|
|
220
|
+
subjectType: 'user' | 'agent';
|
|
221
|
+
permission: 'read' | 'execute' | 'admin';
|
|
222
|
+
grantedBy?: string;
|
|
223
|
+
createdAt: string;
|
|
224
|
+
expiresAt?: string;
|
|
225
|
+
}
|
|
226
|
+
type A2ATaskState = 'submitted' | 'working' | 'input-required' | 'completed' | 'failed' | 'canceled';
|
|
227
|
+
interface A2ATextPart {
|
|
228
|
+
type: 'text';
|
|
229
|
+
text: string;
|
|
230
|
+
metadata?: Record<string, any>;
|
|
231
|
+
}
|
|
232
|
+
interface A2ADataPart {
|
|
233
|
+
type: 'data';
|
|
234
|
+
data: Record<string, any>;
|
|
235
|
+
metadata?: Record<string, any>;
|
|
236
|
+
}
|
|
237
|
+
interface A2AFilePart {
|
|
238
|
+
type: 'file';
|
|
239
|
+
file: {
|
|
240
|
+
name?: string;
|
|
241
|
+
mimeType?: string;
|
|
242
|
+
bytes?: string;
|
|
243
|
+
uri?: string;
|
|
244
|
+
};
|
|
245
|
+
metadata?: Record<string, any>;
|
|
246
|
+
}
|
|
247
|
+
type A2AMessagePart = A2ATextPart | A2ADataPart | A2AFilePart;
|
|
248
|
+
interface A2AMessage {
|
|
249
|
+
role: 'user' | 'agent';
|
|
250
|
+
parts: A2AMessagePart[];
|
|
251
|
+
contextId?: string;
|
|
252
|
+
messageId?: string;
|
|
253
|
+
taskId?: string;
|
|
254
|
+
metadata?: Record<string, any>;
|
|
255
|
+
}
|
|
256
|
+
interface A2AArtifact {
|
|
257
|
+
artifactId?: string;
|
|
258
|
+
name?: string;
|
|
259
|
+
description?: string;
|
|
260
|
+
parts: A2AMessagePart[];
|
|
261
|
+
index?: number;
|
|
262
|
+
metadata?: Record<string, any>;
|
|
263
|
+
}
|
|
264
|
+
interface A2ATask {
|
|
265
|
+
id: string;
|
|
266
|
+
contextId?: string;
|
|
267
|
+
status: {
|
|
268
|
+
state: A2ATaskState;
|
|
269
|
+
message?: A2AMessage;
|
|
270
|
+
timestamp?: string;
|
|
271
|
+
};
|
|
272
|
+
artifacts?: A2AArtifact[];
|
|
273
|
+
history?: A2AMessage[];
|
|
274
|
+
metadata?: Record<string, any>;
|
|
275
|
+
}
|
|
276
|
+
interface A2ASkill {
|
|
277
|
+
id: string;
|
|
278
|
+
name: string;
|
|
279
|
+
description?: string;
|
|
280
|
+
tags?: string[];
|
|
281
|
+
examples?: string[];
|
|
282
|
+
inputModes?: string[];
|
|
283
|
+
outputModes?: string[];
|
|
284
|
+
}
|
|
285
|
+
interface AgentCard {
|
|
286
|
+
name: string;
|
|
287
|
+
description?: string;
|
|
288
|
+
url: string;
|
|
289
|
+
version: string;
|
|
290
|
+
capabilities: {
|
|
291
|
+
streaming?: boolean;
|
|
292
|
+
pushNotifications?: boolean;
|
|
293
|
+
stateTransitionHistory?: boolean;
|
|
294
|
+
};
|
|
295
|
+
defaultInputModes: string[];
|
|
296
|
+
defaultOutputModes: string[];
|
|
297
|
+
skills: A2ASkill[];
|
|
298
|
+
}
|
|
299
|
+
interface A2ASendTaskParams {
|
|
300
|
+
id?: string;
|
|
301
|
+
message: A2AMessage;
|
|
302
|
+
pushNotification?: {
|
|
303
|
+
url: string;
|
|
304
|
+
token?: string;
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
type McpConnectionType = 'stdio' | 'sse' | 'http' | 'streamable-http';
|
|
308
|
+
interface McpServer {
|
|
309
|
+
serverId: string;
|
|
310
|
+
name: string;
|
|
311
|
+
description?: string;
|
|
312
|
+
connectionType: McpConnectionType;
|
|
313
|
+
connectionConfig: Record<string, any>;
|
|
314
|
+
status: 'connected' | 'disconnected' | 'error';
|
|
315
|
+
toolsCount: number;
|
|
316
|
+
capabilities?: Record<string, any>;
|
|
317
|
+
isPublic: boolean;
|
|
318
|
+
ownerId: string;
|
|
319
|
+
ownerType: 'user' | 'agent';
|
|
320
|
+
createdAt: string;
|
|
321
|
+
}
|
|
322
|
+
interface McpResource {
|
|
323
|
+
uri: string;
|
|
324
|
+
name: string;
|
|
325
|
+
description?: string;
|
|
326
|
+
mimeType?: string;
|
|
327
|
+
}
|
|
328
|
+
interface McpPrompt {
|
|
329
|
+
name: string;
|
|
330
|
+
description?: string;
|
|
331
|
+
arguments?: Array<{
|
|
332
|
+
name: string;
|
|
333
|
+
description?: string;
|
|
334
|
+
required?: boolean;
|
|
335
|
+
}>;
|
|
336
|
+
}
|
|
337
|
+
interface CommonsClientConfig {
|
|
338
|
+
baseUrl: string;
|
|
339
|
+
apiKey?: string;
|
|
340
|
+
initiator?: string;
|
|
341
|
+
/** Fetch implementation — defaults to global fetch */
|
|
342
|
+
fetch?: typeof fetch;
|
|
343
|
+
}
|
|
344
|
+
interface Skill {
|
|
345
|
+
skillId: string;
|
|
346
|
+
slug: string;
|
|
347
|
+
name: string;
|
|
348
|
+
description: string;
|
|
349
|
+
instructions: string;
|
|
350
|
+
tools: string[];
|
|
351
|
+
triggers: string[];
|
|
352
|
+
ownerId?: string | null;
|
|
353
|
+
ownerType: string;
|
|
354
|
+
isPublic: boolean;
|
|
355
|
+
isActive: boolean;
|
|
356
|
+
version: string;
|
|
357
|
+
tags: string[];
|
|
358
|
+
icon?: string | null;
|
|
359
|
+
usageCount: number;
|
|
360
|
+
source: string;
|
|
361
|
+
sourceUrl?: string | null;
|
|
362
|
+
createdAt: string;
|
|
363
|
+
updatedAt: string;
|
|
364
|
+
}
|
|
365
|
+
interface SkillIndex {
|
|
366
|
+
skillId: string;
|
|
367
|
+
slug: string;
|
|
368
|
+
name: string;
|
|
369
|
+
description: string;
|
|
370
|
+
tags: string[];
|
|
371
|
+
icon?: string | null;
|
|
372
|
+
triggers: string[];
|
|
373
|
+
}
|
|
374
|
+
interface CreateSkillParams {
|
|
375
|
+
slug: string;
|
|
376
|
+
name: string;
|
|
377
|
+
description: string;
|
|
378
|
+
instructions: string;
|
|
379
|
+
tools?: string[];
|
|
380
|
+
triggers?: string[];
|
|
381
|
+
ownerId?: string;
|
|
382
|
+
ownerType?: 'platform' | 'user' | 'agent';
|
|
383
|
+
isPublic?: boolean;
|
|
384
|
+
tags?: string[];
|
|
385
|
+
icon?: string;
|
|
386
|
+
source?: string;
|
|
387
|
+
sourceUrl?: string;
|
|
388
|
+
}
|
|
389
|
+
type MemoryType = 'episodic' | 'semantic' | 'procedural';
|
|
390
|
+
type MemorySourceType = 'auto' | 'manual';
|
|
391
|
+
interface AgentMemory {
|
|
392
|
+
memoryId: string;
|
|
393
|
+
agentId: string;
|
|
394
|
+
sessionId?: string;
|
|
395
|
+
memoryType: MemoryType;
|
|
396
|
+
content: string;
|
|
397
|
+
summary: string;
|
|
398
|
+
importanceScore: number;
|
|
399
|
+
accessCount: number;
|
|
400
|
+
lastAccessedAt?: string;
|
|
401
|
+
tags: string[];
|
|
402
|
+
sourceType: MemorySourceType;
|
|
403
|
+
isActive: boolean;
|
|
404
|
+
expiresAt?: string;
|
|
405
|
+
createdAt: string;
|
|
406
|
+
updatedAt: string;
|
|
407
|
+
}
|
|
408
|
+
interface MemoryStats {
|
|
409
|
+
total: number;
|
|
410
|
+
episodic: number;
|
|
411
|
+
semantic: number;
|
|
412
|
+
procedural: number;
|
|
413
|
+
avgImportance: number;
|
|
414
|
+
}
|
|
415
|
+
interface CreateMemoryParams {
|
|
416
|
+
agentId: string;
|
|
417
|
+
sessionId?: string;
|
|
418
|
+
memoryType?: MemoryType;
|
|
419
|
+
content: string;
|
|
420
|
+
summary: string;
|
|
421
|
+
importanceScore?: number;
|
|
422
|
+
tags?: string[];
|
|
423
|
+
}
|
|
424
|
+
interface UpdateMemoryParams {
|
|
425
|
+
content?: string;
|
|
426
|
+
summary?: string;
|
|
427
|
+
importanceScore?: number;
|
|
428
|
+
tags?: string[];
|
|
429
|
+
isActive?: boolean;
|
|
430
|
+
memoryType?: MemoryType;
|
|
431
|
+
}
|
|
432
|
+
interface UsageEvent {
|
|
433
|
+
eventId: string;
|
|
434
|
+
agentId: string;
|
|
435
|
+
sessionId?: string;
|
|
436
|
+
taskId?: string;
|
|
437
|
+
workflowExecutionId?: string;
|
|
438
|
+
provider: string;
|
|
439
|
+
modelId: string;
|
|
440
|
+
inputTokens: number;
|
|
441
|
+
outputTokens: number;
|
|
442
|
+
cachedTokens: number;
|
|
443
|
+
totalTokens: number;
|
|
444
|
+
costUsd: number;
|
|
445
|
+
isByok: boolean;
|
|
446
|
+
durationMs?: number;
|
|
447
|
+
/** Trace ID — links all LLM calls in a single runAgent() invocation. */
|
|
448
|
+
traceId?: string;
|
|
449
|
+
createdAt: string;
|
|
450
|
+
}
|
|
451
|
+
interface UsageAggregation {
|
|
452
|
+
totalInputTokens: number;
|
|
453
|
+
totalOutputTokens: number;
|
|
454
|
+
totalTokens: number;
|
|
455
|
+
totalCostUsd: number;
|
|
456
|
+
callCount: number;
|
|
457
|
+
events: UsageEvent[];
|
|
458
|
+
}
|
|
459
|
+
type WalletType = 'eoa' | 'erc4337' | 'external';
|
|
460
|
+
interface AgentWallet {
|
|
461
|
+
id: string;
|
|
462
|
+
agentId: string;
|
|
463
|
+
walletType: WalletType;
|
|
464
|
+
address: string;
|
|
465
|
+
smartAccountAddress?: string | null;
|
|
466
|
+
chainId: string;
|
|
467
|
+
label?: string | null;
|
|
468
|
+
isActive: boolean;
|
|
469
|
+
createdAt: string;
|
|
470
|
+
}
|
|
471
|
+
interface WalletBalance {
|
|
472
|
+
address: string;
|
|
473
|
+
chainId: string;
|
|
474
|
+
native: string;
|
|
475
|
+
usdc: string;
|
|
476
|
+
}
|
|
477
|
+
interface CreateWalletParams {
|
|
478
|
+
agentId: string;
|
|
479
|
+
walletType?: WalletType;
|
|
480
|
+
label?: string;
|
|
481
|
+
/** For 'external' wallets: the owner-provided address */
|
|
482
|
+
externalAddress?: string;
|
|
483
|
+
chainId?: string;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
declare class CommonsClient {
|
|
487
|
+
private readonly baseUrl;
|
|
488
|
+
private readonly apiKey?;
|
|
489
|
+
private readonly initiator?;
|
|
490
|
+
private readonly _fetch;
|
|
491
|
+
constructor(config: CommonsClientConfig);
|
|
492
|
+
private headers;
|
|
493
|
+
private request;
|
|
494
|
+
get agents(): {
|
|
495
|
+
create: (params: CreateAgentParams) => Promise<{
|
|
496
|
+
data: Agent;
|
|
497
|
+
}>;
|
|
498
|
+
list: (owner?: string) => Promise<{
|
|
499
|
+
data: Agent[];
|
|
500
|
+
}>;
|
|
501
|
+
get: (agentId: string) => Promise<{
|
|
502
|
+
data: Agent;
|
|
503
|
+
}>;
|
|
504
|
+
update: (agentId: string, params: Partial<CreateAgentParams>) => Promise<{
|
|
505
|
+
data: Agent;
|
|
506
|
+
}>;
|
|
507
|
+
/** List tools assigned to an agent. */
|
|
508
|
+
listTools: (agentId: string) => Promise<{
|
|
509
|
+
data: any[];
|
|
510
|
+
}>;
|
|
511
|
+
/** Assign a tool to an agent. */
|
|
512
|
+
addTool: (agentId: string, params: {
|
|
513
|
+
toolId: string;
|
|
514
|
+
usageComments?: string;
|
|
515
|
+
}) => Promise<{
|
|
516
|
+
data: any;
|
|
517
|
+
}>;
|
|
518
|
+
/** Remove a tool assignment from an agent. */
|
|
519
|
+
removeTool: (assignmentId: string) => Promise<void>;
|
|
520
|
+
/** Create a liaison agent for an external agent. */
|
|
521
|
+
createLiaison: (params: Record<string, any>) => Promise<any>;
|
|
522
|
+
/**
|
|
523
|
+
* Stream an agent run. Returns an async generator of StreamEvents.
|
|
524
|
+
* Works in Node.js, browsers, and Edge runtimes.
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
* for await (const event of client.agents.stream({ agentId, messages })) {
|
|
528
|
+
* if (event.type === 'token') process.stdout.write(event.content ?? '');
|
|
529
|
+
* }
|
|
530
|
+
*/
|
|
531
|
+
stream: (params: RunParams) => AsyncGenerator<StreamEvent>;
|
|
532
|
+
};
|
|
533
|
+
get run(): {
|
|
534
|
+
once: (params: RunParams) => Promise<any>;
|
|
535
|
+
};
|
|
536
|
+
get workflows(): {
|
|
537
|
+
create: (params: {
|
|
538
|
+
name: string;
|
|
539
|
+
description?: string;
|
|
540
|
+
definition: any;
|
|
541
|
+
ownerId: string;
|
|
542
|
+
ownerType: "user" | "agent";
|
|
543
|
+
isPublic?: boolean;
|
|
544
|
+
category?: string;
|
|
545
|
+
tags?: string[];
|
|
546
|
+
}) => Promise<Workflow>;
|
|
547
|
+
list: (ownerId: string, ownerType: "user" | "agent") => Promise<Workflow[]>;
|
|
548
|
+
get: (workflowId: string) => Promise<Workflow>;
|
|
549
|
+
update: (workflowId: string, updates: Partial<Workflow>) => Promise<Workflow>;
|
|
550
|
+
delete: (workflowId: string) => Promise<{
|
|
551
|
+
success: boolean;
|
|
552
|
+
}>;
|
|
553
|
+
execute: (workflowId: string, params: {
|
|
554
|
+
agentId?: string;
|
|
555
|
+
sessionId?: string;
|
|
556
|
+
inputData?: Record<string, any>;
|
|
557
|
+
userId?: string;
|
|
558
|
+
}) => Promise<WorkflowExecution>;
|
|
559
|
+
getExecution: (workflowId: string, executionId: string) => Promise<WorkflowExecution>;
|
|
560
|
+
listExecutions: (workflowId: string, limit?: number) => Promise<WorkflowExecution[]>;
|
|
561
|
+
cancelExecution: (workflowId: string, executionId: string) => Promise<{
|
|
562
|
+
success: boolean;
|
|
563
|
+
}>;
|
|
564
|
+
/** Approve a paused human_approval node and resume execution. */
|
|
565
|
+
approveExecution: (workflowId: string, executionId: string, params: {
|
|
566
|
+
approvalToken: string;
|
|
567
|
+
approvalData?: Record<string, any>;
|
|
568
|
+
}) => Promise<{
|
|
569
|
+
success: boolean;
|
|
570
|
+
executionId: string;
|
|
571
|
+
action: string;
|
|
572
|
+
}>;
|
|
573
|
+
/** Reject a paused human_approval node and terminate execution. */
|
|
574
|
+
rejectExecution: (workflowId: string, executionId: string, params: {
|
|
575
|
+
approvalToken: string;
|
|
576
|
+
reason?: string;
|
|
577
|
+
}) => Promise<{
|
|
578
|
+
success: boolean;
|
|
579
|
+
executionId: string;
|
|
580
|
+
action: string;
|
|
581
|
+
}>;
|
|
582
|
+
/** Stream execution progress via SSE. Returns an async generator. */
|
|
583
|
+
stream: (workflowId: string, executionId: string) => AsyncGenerator<StreamEvent>;
|
|
584
|
+
};
|
|
585
|
+
get tasks(): {
|
|
586
|
+
create: (params: CreateTaskParams) => Promise<{
|
|
587
|
+
data: Task;
|
|
588
|
+
}>;
|
|
589
|
+
list: (filter: {
|
|
590
|
+
sessionId?: string;
|
|
591
|
+
agentId?: string;
|
|
592
|
+
ownerId?: string;
|
|
593
|
+
ownerType?: "user" | "agent";
|
|
594
|
+
}) => Promise<{
|
|
595
|
+
data: Task[];
|
|
596
|
+
}>;
|
|
597
|
+
get: (taskId: string) => Promise<{
|
|
598
|
+
data: Task;
|
|
599
|
+
}>;
|
|
600
|
+
execute: (taskId: string) => Promise<{
|
|
601
|
+
success: boolean;
|
|
602
|
+
data: any;
|
|
603
|
+
}>;
|
|
604
|
+
cancel: (taskId: string) => Promise<{
|
|
605
|
+
success: boolean;
|
|
606
|
+
}>;
|
|
607
|
+
delete: (taskId: string) => Promise<{
|
|
608
|
+
success: boolean;
|
|
609
|
+
}>;
|
|
610
|
+
/** Stream task status updates via SSE. Returns an async generator. */
|
|
611
|
+
stream: (taskId: string) => AsyncGenerator<StreamEvent>;
|
|
612
|
+
};
|
|
613
|
+
get sessions(): {
|
|
614
|
+
list: (agentId: string, initiatorId: string) => Promise<{
|
|
615
|
+
data: Session[];
|
|
616
|
+
}>;
|
|
617
|
+
create: (params: {
|
|
618
|
+
agentId: string;
|
|
619
|
+
initiator: string;
|
|
620
|
+
title?: string;
|
|
621
|
+
model?: Record<string, any>;
|
|
622
|
+
}) => Promise<{
|
|
623
|
+
data: Session;
|
|
624
|
+
}>;
|
|
625
|
+
get: (sessionId: string) => Promise<{
|
|
626
|
+
data: Session;
|
|
627
|
+
}>;
|
|
628
|
+
/** Get full session with history, tasks, childSessions, and spaces. */
|
|
629
|
+
getFull: (sessionId: string) => Promise<{
|
|
630
|
+
data: any;
|
|
631
|
+
}>;
|
|
632
|
+
};
|
|
633
|
+
get tools(): {
|
|
634
|
+
list: (filter?: {
|
|
635
|
+
agentId?: string;
|
|
636
|
+
owner?: string;
|
|
637
|
+
ownerType?: string;
|
|
638
|
+
visibility?: string;
|
|
639
|
+
}) => Promise<{
|
|
640
|
+
data: Tool[];
|
|
641
|
+
}>;
|
|
642
|
+
get: (toolId: string) => Promise<{
|
|
643
|
+
data: Tool;
|
|
644
|
+
}>;
|
|
645
|
+
create: (params: CreateToolParams) => Promise<{
|
|
646
|
+
data: Tool;
|
|
647
|
+
}>;
|
|
648
|
+
update: (toolId: string, params: Partial<CreateToolParams>) => Promise<{
|
|
649
|
+
data: Tool;
|
|
650
|
+
}>;
|
|
651
|
+
delete: (toolId: string) => Promise<{
|
|
652
|
+
success: boolean;
|
|
653
|
+
}>;
|
|
654
|
+
/** List built-in static tools available to all agents. */
|
|
655
|
+
listStatic: () => Promise<{
|
|
656
|
+
data: Tool[];
|
|
657
|
+
}>;
|
|
658
|
+
};
|
|
659
|
+
get toolKeys(): {
|
|
660
|
+
list: (filter: {
|
|
661
|
+
ownerId?: string;
|
|
662
|
+
ownerType?: string;
|
|
663
|
+
toolId?: string;
|
|
664
|
+
}) => Promise<{
|
|
665
|
+
success: boolean;
|
|
666
|
+
data: ToolKey[];
|
|
667
|
+
}>;
|
|
668
|
+
create: (params: CreateToolKeyParams) => Promise<{
|
|
669
|
+
success: boolean;
|
|
670
|
+
data: ToolKey;
|
|
671
|
+
}>;
|
|
672
|
+
delete: (keyId: string) => Promise<{
|
|
673
|
+
success: boolean;
|
|
674
|
+
}>;
|
|
675
|
+
};
|
|
676
|
+
get toolPermissions(): {
|
|
677
|
+
list: (toolId?: string) => Promise<{
|
|
678
|
+
success: boolean;
|
|
679
|
+
data: ToolPermission[];
|
|
680
|
+
}>;
|
|
681
|
+
grant: (params: {
|
|
682
|
+
toolId: string;
|
|
683
|
+
subjectId: string;
|
|
684
|
+
subjectType: "user" | "agent";
|
|
685
|
+
permission: "read" | "execute" | "admin";
|
|
686
|
+
grantedBy?: string;
|
|
687
|
+
}) => Promise<{
|
|
688
|
+
success: boolean;
|
|
689
|
+
data: ToolPermission;
|
|
690
|
+
}>;
|
|
691
|
+
revoke: (permissionId: string) => Promise<{
|
|
692
|
+
success: boolean;
|
|
693
|
+
}>;
|
|
694
|
+
};
|
|
695
|
+
get skills(): {
|
|
696
|
+
list: (filter?: {
|
|
697
|
+
ownerId?: string;
|
|
698
|
+
ownerType?: string;
|
|
699
|
+
isPublic?: boolean;
|
|
700
|
+
}) => Promise<{
|
|
701
|
+
data: Skill[];
|
|
702
|
+
}>;
|
|
703
|
+
get: (skillIdOrSlug: string) => Promise<{
|
|
704
|
+
data: Skill;
|
|
705
|
+
}>;
|
|
706
|
+
getIndex: (ownerId?: string) => Promise<{
|
|
707
|
+
data: SkillIndex[];
|
|
708
|
+
}>;
|
|
709
|
+
create: (params: CreateSkillParams) => Promise<{
|
|
710
|
+
data: Skill;
|
|
711
|
+
}>;
|
|
712
|
+
update: (skillIdOrSlug: string, updates: Partial<CreateSkillParams>) => Promise<{
|
|
713
|
+
data: Skill;
|
|
714
|
+
}>;
|
|
715
|
+
delete: (skillIdOrSlug: string) => Promise<{
|
|
716
|
+
deleted: boolean;
|
|
717
|
+
}>;
|
|
718
|
+
};
|
|
719
|
+
get wallets(): {
|
|
720
|
+
/** List all wallets for an agent. */
|
|
721
|
+
list: (agentId: string) => Promise<AgentWallet[]>;
|
|
722
|
+
/** Get the primary active wallet for an agent. */
|
|
723
|
+
primary: (agentId: string) => Promise<AgentWallet | null>;
|
|
724
|
+
/** Get a specific wallet by ID. */
|
|
725
|
+
get: (walletId: string) => Promise<AgentWallet>;
|
|
726
|
+
/** Create a new wallet for an agent. */
|
|
727
|
+
create: (params: CreateWalletParams) => Promise<AgentWallet>;
|
|
728
|
+
/** Get USDC and native token balance for a wallet. */
|
|
729
|
+
balance: (walletId: string) => Promise<WalletBalance>;
|
|
730
|
+
/** Deactivate a wallet. */
|
|
731
|
+
deactivate: (walletId: string) => Promise<void>;
|
|
732
|
+
};
|
|
733
|
+
private _streamAgentRun;
|
|
734
|
+
private _streamSse;
|
|
735
|
+
private _parseEventStream;
|
|
736
|
+
get a2a(): {
|
|
737
|
+
/** Fetch the A2A Agent Card for an agent. */
|
|
738
|
+
getAgentCard: (agentId: string) => Promise<AgentCard>;
|
|
739
|
+
/** Send a task to an agent (synchronous, waits for completion). */
|
|
740
|
+
sendTask: (agentId: string, params: A2ASendTaskParams) => Promise<A2ATask>;
|
|
741
|
+
/** Get A2A task status. */
|
|
742
|
+
getTask: (agentId: string, taskId: string) => Promise<A2ATask>;
|
|
743
|
+
/** Cancel a running A2A task. */
|
|
744
|
+
cancelTask: (agentId: string, taskId: string) => Promise<A2ATask>;
|
|
745
|
+
/** List recent A2A tasks for an agent. */
|
|
746
|
+
listTasks: (agentId: string, limit?: number) => Promise<{
|
|
747
|
+
tasks: A2ATask[];
|
|
748
|
+
total: number;
|
|
749
|
+
}>;
|
|
750
|
+
/** Stream A2A task updates (SSE). */
|
|
751
|
+
stream: (agentId: string, taskId: string) => AsyncGenerator<StreamEvent>;
|
|
752
|
+
};
|
|
753
|
+
get mcp(): {
|
|
754
|
+
/** List MCP servers for an owner. */
|
|
755
|
+
listServers: (ownerId: string, ownerType: "user" | "agent") => Promise<{
|
|
756
|
+
servers: McpServer[];
|
|
757
|
+
total: number;
|
|
758
|
+
}>;
|
|
759
|
+
/** Create a new MCP server. */
|
|
760
|
+
createServer: (params: {
|
|
761
|
+
name: string;
|
|
762
|
+
description?: string;
|
|
763
|
+
connectionType: McpConnectionType;
|
|
764
|
+
connectionConfig: Record<string, any>;
|
|
765
|
+
isPublic?: boolean;
|
|
766
|
+
tags?: string[];
|
|
767
|
+
ownerId: string;
|
|
768
|
+
ownerType: "user" | "agent";
|
|
769
|
+
}) => Promise<McpServer>;
|
|
770
|
+
/** Get MCP server by ID. */
|
|
771
|
+
getServer: (serverId: string) => Promise<McpServer>;
|
|
772
|
+
/** Delete an MCP server. */
|
|
773
|
+
deleteServer: (serverId: string) => Promise<void>;
|
|
774
|
+
/** Connect to an MCP server. */
|
|
775
|
+
connect: (serverId: string) => Promise<{
|
|
776
|
+
connected: boolean;
|
|
777
|
+
}>;
|
|
778
|
+
/** Disconnect from an MCP server. */
|
|
779
|
+
disconnect: (serverId: string) => Promise<void>;
|
|
780
|
+
/** Sync tools + resources + prompts from the MCP server. */
|
|
781
|
+
sync: (serverId: string) => Promise<{
|
|
782
|
+
toolsDiscovered: number;
|
|
783
|
+
resourcesDiscovered: number;
|
|
784
|
+
promptsDiscovered: number;
|
|
785
|
+
}>;
|
|
786
|
+
/** List tools discovered from an MCP server. */
|
|
787
|
+
listTools: (serverId: string) => Promise<{
|
|
788
|
+
tools: any[];
|
|
789
|
+
total: number;
|
|
790
|
+
}>;
|
|
791
|
+
/** List all MCP tools across all servers for a given owner. */
|
|
792
|
+
listToolsByOwner: (ownerId: string, ownerType: "user" | "agent") => Promise<{
|
|
793
|
+
tools: any[];
|
|
794
|
+
}>;
|
|
795
|
+
/** List resources from an MCP server. */
|
|
796
|
+
listResources: (serverId: string) => Promise<{
|
|
797
|
+
resources: McpResource[];
|
|
798
|
+
total: number;
|
|
799
|
+
}>;
|
|
800
|
+
/** Read a resource by URI. */
|
|
801
|
+
readResource: (serverId: string, uri: string) => Promise<{
|
|
802
|
+
uri: string;
|
|
803
|
+
contents: any;
|
|
804
|
+
}>;
|
|
805
|
+
/** List prompts from an MCP server. */
|
|
806
|
+
listPrompts: (serverId: string) => Promise<{
|
|
807
|
+
prompts: McpPrompt[];
|
|
808
|
+
total: number;
|
|
809
|
+
}>;
|
|
810
|
+
/** Render a prompt with arguments. */
|
|
811
|
+
getPrompt: (serverId: string, promptName: string, args?: Record<string, string>) => Promise<{
|
|
812
|
+
description?: string;
|
|
813
|
+
messages: any[];
|
|
814
|
+
}>;
|
|
815
|
+
};
|
|
816
|
+
get memory(): {
|
|
817
|
+
/** List all memories for an agent. */
|
|
818
|
+
list: (agentId: string, opts?: {
|
|
819
|
+
type?: MemoryType;
|
|
820
|
+
limit?: number;
|
|
821
|
+
}) => Promise<{
|
|
822
|
+
data: AgentMemory[];
|
|
823
|
+
}>;
|
|
824
|
+
/** Get memory stats for an agent. */
|
|
825
|
+
stats: (agentId: string) => Promise<{
|
|
826
|
+
data: MemoryStats;
|
|
827
|
+
}>;
|
|
828
|
+
/** Retrieve memories most relevant to a query. */
|
|
829
|
+
retrieve: (agentId: string, query: string, limit?: number) => Promise<{
|
|
830
|
+
data: AgentMemory[];
|
|
831
|
+
}>;
|
|
832
|
+
/** Get a single memory by ID. */
|
|
833
|
+
get: (memoryId: string) => Promise<{
|
|
834
|
+
data: AgentMemory;
|
|
835
|
+
}>;
|
|
836
|
+
/** Manually create a memory. */
|
|
837
|
+
create: (params: CreateMemoryParams) => Promise<{
|
|
838
|
+
data: AgentMemory;
|
|
839
|
+
}>;
|
|
840
|
+
/** Update a memory. */
|
|
841
|
+
update: (memoryId: string, params: UpdateMemoryParams) => Promise<{
|
|
842
|
+
data: AgentMemory;
|
|
843
|
+
}>;
|
|
844
|
+
/** Soft-delete (deactivate) a memory. */
|
|
845
|
+
delete: (memoryId: string) => Promise<void>;
|
|
846
|
+
};
|
|
847
|
+
get usage(): {
|
|
848
|
+
/** Get aggregated token + cost usage for an agent. */
|
|
849
|
+
getAgentUsage: (agentId: string, opts?: {
|
|
850
|
+
from?: string;
|
|
851
|
+
to?: string;
|
|
852
|
+
}) => Promise<{
|
|
853
|
+
data: UsageAggregation;
|
|
854
|
+
}>;
|
|
855
|
+
/** Get aggregated token + cost usage for a session. */
|
|
856
|
+
getSessionUsage: (sessionId: string) => Promise<{
|
|
857
|
+
data: UsageAggregation;
|
|
858
|
+
}>;
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
declare class CommonsError extends Error {
|
|
862
|
+
readonly status: number;
|
|
863
|
+
readonly data?: unknown | undefined;
|
|
864
|
+
constructor(message: string, status: number, data?: unknown | undefined);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
export { type A2AArtifact, type A2ADataPart, type A2AFilePart, type A2AMessage, type A2AMessagePart, type A2ASendTaskParams, type A2ASkill, type A2ATask, type A2ATaskState, type A2ATextPart, type Agent, type AgentCard, type AgentMemory, type AgentWallet, type ChatMessage, CommonsClient, type CommonsClientConfig, CommonsError, type CreateAgentParams, type CreateMemoryParams, type CreateSkillParams, type CreateTaskParams, type CreateToolKeyParams, type CreateToolParams, type CreateWalletParams, type McpConnectionType, type McpPrompt, type McpResource, type McpServer, type MemorySourceType, type MemoryStats, type MemoryType, type ModelConfig, type ModelProvider, type RunParams, type Session, type Skill, type SkillIndex, type StreamEvent, type StreamEventType, type Task, type Tool, type ToolKey, type ToolPermission, type UpdateMemoryParams, type UsageAggregation, type UsageEvent, type WalletBalance, type WalletType, type Workflow, type WorkflowDefinition, type WorkflowEdge, type WorkflowExecution, type WorkflowNode, type WorkflowNodeType };
|