@agent-commons/sdk 0.2.0 → 0.2.2

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.d.mts CHANGED
@@ -7,6 +7,8 @@ interface ModelConfig {
7
7
  temperature?: number;
8
8
  maxTokens?: number;
9
9
  topP?: number;
10
+ reasoningEffort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
11
+ verbosity?: 'low' | 'medium' | 'high';
10
12
  }
11
13
  interface Agent {
12
14
  agentId: string;
@@ -14,6 +16,8 @@ interface Agent {
14
16
  owner?: string;
15
17
  instructions?: string;
16
18
  persona?: string;
19
+ greeting?: string;
20
+ conversationStarters?: string[];
17
21
  avatar?: string;
18
22
  modelProvider: ModelProvider;
19
23
  modelId: string;
@@ -28,11 +32,101 @@ interface Agent {
28
32
  externalUrl?: string;
29
33
  createdAt: string;
30
34
  }
35
+ type AgentComputerLifecycle = 'persistent' | 'ephemeral';
36
+ type AgentComputerStatus = 'provisioning' | 'starting' | 'running' | 'idle' | 'stopping' | 'stopped' | 'terminated' | 'failed' | 'error' | 'unavailable';
37
+ interface AgentComputerConfig {
38
+ configId: string;
39
+ agentId: string;
40
+ enabled: boolean;
41
+ defaultMode: AgentComputerLifecycle;
42
+ autoStart: boolean;
43
+ allowAgentStart: boolean;
44
+ allowUserSelect: boolean;
45
+ allowBrowser: boolean;
46
+ allowTerminal: boolean;
47
+ allowFilesystem: boolean;
48
+ networkAccess: 'standard' | 'restricted' | 'disabled' | string;
49
+ maxPersistentComputers: number;
50
+ maxEphemeralComputers: number;
51
+ maxConcurrentComputers: number;
52
+ idleTtlMinutes: number;
53
+ sessionTtlMinutes: number;
54
+ image?: string | null;
55
+ cpuLimit?: string | null;
56
+ memoryLimit?: string | null;
57
+ storageLimit?: string | null;
58
+ region?: string | null;
59
+ provider: string;
60
+ metadata?: Record<string, any> | null;
61
+ createdAt: string;
62
+ updatedAt: string;
63
+ }
64
+ interface AgentComputerInstance {
65
+ computerId: string;
66
+ agentId: string;
67
+ sessionId?: string | null;
68
+ ownerUserId?: string | null;
69
+ workspaceId?: string | null;
70
+ name: string;
71
+ lifecycle: AgentComputerLifecycle;
72
+ status: AgentComputerStatus;
73
+ provider: string;
74
+ cloudProvider?: string | null;
75
+ region?: string | null;
76
+ namespaceId?: string | null;
77
+ podName?: string | null;
78
+ image?: string | null;
79
+ cpuLimit?: string | null;
80
+ memoryLimit?: string | null;
81
+ storageLimit?: string | null;
82
+ workspaceRoot?: string | null;
83
+ workspaceSnapshot?: string | null;
84
+ browser?: {
85
+ status?: 'off' | 'starting' | 'on' | 'error';
86
+ url?: string | null;
87
+ title?: string | null;
88
+ screenshot?: string | null;
89
+ lastAction?: string | null;
90
+ error?: string | null;
91
+ updatedAt?: string | null;
92
+ } | null;
93
+ terminal?: {
94
+ lastCommand?: string | null;
95
+ lastExitCode?: number | null;
96
+ lastOutput?: string | null;
97
+ updatedAt?: string | null;
98
+ } | null;
99
+ metadata?: Record<string, any> | null;
100
+ lastActivityAt?: string | null;
101
+ expiresAt?: string | null;
102
+ startedAt?: string | null;
103
+ stoppedAt?: string | null;
104
+ errorMessage?: string | null;
105
+ createdAt: string;
106
+ updatedAt: string;
107
+ }
108
+ interface AgentComputerEvent {
109
+ eventId: string;
110
+ computerId: string;
111
+ agentId: string;
112
+ sessionId?: string | null;
113
+ eventType: string;
114
+ actorType: string;
115
+ actorId?: string | null;
116
+ summary?: string | null;
117
+ payload?: Record<string, any> | null;
118
+ createdAt: string;
119
+ }
31
120
  interface CreateAgentParams {
32
121
  name: string;
33
122
  instructions?: string;
34
123
  persona?: string;
124
+ greeting?: string;
125
+ conversationStarters?: string[];
35
126
  owner?: string;
127
+ ownerUserId?: string;
128
+ workspaceId?: string | null;
129
+ metadata?: Record<string, unknown>;
36
130
  modelProvider?: ModelProvider;
37
131
  modelId?: string;
38
132
  modelApiKey?: string;
@@ -62,6 +156,15 @@ interface RunParams {
62
156
  messages: ChatMessage[];
63
157
  sessionId?: string;
64
158
  initiatorId?: string;
159
+ computerRequest?: {
160
+ enabled: boolean;
161
+ computerIds?: string[];
162
+ lifecycle?: AgentComputerLifecycle;
163
+ };
164
+ /** Uploaded file references. Raw file bytes must be uploaded separately. */
165
+ attachments?: Array<{
166
+ fileId: string;
167
+ }>;
65
168
  /** Extra text injected into the agent's system prompt. Used by the CLI to deliver the local tools manifest. */
66
169
  cliContext?: string;
67
170
  /** Caller-owned function catalog executed through cli_tool_request events. */
@@ -73,21 +176,39 @@ interface RunParams {
73
176
  }
74
177
  interface ChatMessage {
75
178
  role: 'user' | 'assistant' | 'system' | 'tool';
76
- content: string;
179
+ content: string | Array<{
180
+ type: 'text';
181
+ text: string;
182
+ } | {
183
+ type: 'image_url';
184
+ image_url: {
185
+ url: string;
186
+ };
187
+ } | Record<string, any>>;
77
188
  tool_call_id?: string;
78
189
  name?: string;
79
190
  }
80
- type StreamEventType = 'token' | 'toolStart' | 'toolEnd' | 'agent_step' | 'final' | 'completed' | 'failed' | 'cancelled' | 'status' | 'keepalive' | 'cli_tool_request' | 'error';
191
+ type StreamEventType = 'token' | 'tool' | 'toolStart' | 'toolEnd' | 'agent_step' | 'final' | 'completed' | 'failed' | 'cancelled' | 'status' | 'keepalive' | 'cli_tool_request' | 'error';
81
192
  interface StreamEvent {
82
193
  type: StreamEventType;
194
+ phase?: 'commentary' | 'final_answer' | string;
83
195
  role?: string;
84
196
  content?: string;
197
+ stage?: string;
198
+ status?: 'queued' | 'running' | 'completed' | 'failed' | string;
199
+ name?: string;
85
200
  toolName?: string;
201
+ tool?: string;
86
202
  input?: string;
203
+ args?: any;
87
204
  output?: any;
205
+ result?: any;
206
+ requestId?: string;
88
207
  timestamp?: string;
208
+ sessionId?: string;
89
209
  payload?: any;
90
210
  message?: string;
211
+ detail?: string;
91
212
  }
92
213
  interface Workflow {
93
214
  workflowId: string;
@@ -102,11 +223,13 @@ interface Workflow {
102
223
  createdAt: string;
103
224
  }
104
225
  interface WorkflowDefinition {
226
+ startNodeId?: string;
227
+ endNodeId?: string;
105
228
  nodes: WorkflowNode[];
106
229
  edges: WorkflowEdge[];
107
230
  outputMapping?: Record<string, string>;
108
231
  }
109
- type WorkflowNodeType = 'tool' | 'input' | 'output' | 'condition' | 'transform' | 'loop' | 'agent_processor' | 'human_approval';
232
+ type WorkflowNodeType = 'tool' | 'input' | 'output' | 'condition' | 'transform' | 'loop' | 'agent_processor' | 'workflow' | 'human_approval';
110
233
  interface WorkflowNode {
111
234
  id: string;
112
235
  type: WorkflowNodeType | string;
@@ -198,10 +321,32 @@ interface CreateToolParams {
198
321
  displayName?: string;
199
322
  description?: string;
200
323
  schema: any;
324
+ apiSpec?: {
325
+ baseUrl: string;
326
+ path: string;
327
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | string;
328
+ headers?: Record<string, string>;
329
+ queryParams?: Record<string, string>;
330
+ bodyTemplate?: any;
331
+ authType?: 'none' | 'bearer' | 'api-key' | 'basic' | 'oauth2' | string;
332
+ authKeyName?: string;
333
+ oauthProviderKey?: string;
334
+ oauthScopes?: string[];
335
+ oauthTokenLocation?: 'header' | 'query' | 'body';
336
+ oauthTokenKey?: string;
337
+ oauthTokenPrefix?: string;
338
+ };
339
+ category?: string;
340
+ icon?: string;
341
+ inputSchema?: any;
342
+ outputSchema?: any;
201
343
  owner?: string;
202
344
  ownerType?: 'user' | 'agent';
203
345
  visibility?: 'private' | 'public' | 'platform';
204
346
  tags?: string[];
347
+ version?: string;
348
+ rateLimitPerMinute?: number;
349
+ rateLimitPerHour?: number;
205
350
  }
206
351
  interface ToolKey {
207
352
  keyId: string;
@@ -348,7 +493,8 @@ interface McpPrompt {
348
493
  }>;
349
494
  }
350
495
  interface CommonsClientConfig {
351
- baseUrl: string;
496
+ /** Defaults to the unified Commons API platform. */
497
+ baseUrl?: string;
352
498
  apiKey?: string;
353
499
  initiator?: string;
354
500
  /** Fetch implementation — defaults to global fetch */
@@ -469,6 +615,58 @@ interface UsageAggregation {
469
615
  callCount: number;
470
616
  events: UsageEvent[];
471
617
  }
618
+ type CreditDirection = 'grant' | 'debit' | 'adjustment' | 'refund' | 'expiration';
619
+ type CreditPlatform = 'agent_commons' | 'commonlab' | 'common_os' | 'system';
620
+ interface CreditLedgerEntry {
621
+ entryId: string;
622
+ principalId: string;
623
+ principalType: 'user' | 'agent' | 'service';
624
+ workspaceId?: string | null;
625
+ amount: number;
626
+ currency: 'credits';
627
+ direction: CreditDirection;
628
+ eventType: string;
629
+ sourcePlatform: CreditPlatform;
630
+ idempotencyKey: string;
631
+ description?: string | null;
632
+ relatedCourseId?: string | null;
633
+ relatedChallengeId?: string | null;
634
+ agentId?: string | null;
635
+ sessionId?: string | null;
636
+ taskId?: string | null;
637
+ workflowId?: string | null;
638
+ usageEventId?: string | null;
639
+ metadata?: Record<string, unknown>;
640
+ createdBy?: string | null;
641
+ createdByType?: string | null;
642
+ expiresAt?: string | null;
643
+ voidedAt?: string | null;
644
+ createdAt: string;
645
+ }
646
+ interface CreditBalance {
647
+ principalId: string;
648
+ workspaceId?: string | null;
649
+ balance: number;
650
+ currency: 'credits';
651
+ }
652
+ interface CreditWriteParams {
653
+ principalId: string;
654
+ principalType?: 'user' | 'agent' | 'service';
655
+ workspaceId?: string | null;
656
+ amount: number;
657
+ eventType: string;
658
+ sourcePlatform: CreditPlatform;
659
+ idempotencyKey: string;
660
+ description?: string;
661
+ relatedCourseId?: string;
662
+ relatedChallengeId?: string;
663
+ agentId?: string;
664
+ sessionId?: string;
665
+ taskId?: string;
666
+ workflowId?: string;
667
+ usageEventId?: string;
668
+ metadata?: Record<string, unknown>;
669
+ }
472
670
  type WalletType = 'eoa' | 'erc4337' | 'external';
473
671
  interface AgentWallet {
474
672
  id: string;
@@ -623,6 +821,56 @@ declare class CommonsClient {
623
821
  removePreferredConnection: (id: string) => Promise<{
624
822
  success: boolean;
625
823
  }>;
824
+ getComputerConfig: (agentId: string) => Promise<{
825
+ data: AgentComputerConfig;
826
+ }>;
827
+ updateComputerConfig: (agentId: string, params: Partial<AgentComputerConfig>) => Promise<{
828
+ data: AgentComputerConfig;
829
+ }>;
830
+ listComputers: (agentId: string, filter?: {
831
+ sessionId?: string;
832
+ includeTerminated?: boolean;
833
+ }) => Promise<{
834
+ data: AgentComputerInstance[];
835
+ }>;
836
+ startComputer: (agentId: string, params: {
837
+ sessionId?: string;
838
+ lifecycle?: "persistent" | "ephemeral";
839
+ name?: string;
840
+ reason?: string;
841
+ }) => Promise<{
842
+ data: AgentComputerInstance;
843
+ }>;
844
+ getComputer: (agentId: string, computerId: string) => Promise<{
845
+ data: AgentComputerInstance;
846
+ }>;
847
+ refreshComputer: (agentId: string, computerId: string) => Promise<{
848
+ data: AgentComputerInstance;
849
+ }>;
850
+ stopComputer: (agentId: string, computerId: string) => Promise<{
851
+ data: AgentComputerInstance;
852
+ }>;
853
+ readComputerFile: (agentId: string, computerId: string, path: string) => Promise<{
854
+ data: {
855
+ path: string;
856
+ content: string;
857
+ };
858
+ }>;
859
+ runComputerCommand: (agentId: string, computerId: string, params: {
860
+ command: string;
861
+ cwd?: string;
862
+ timeoutSeconds?: number;
863
+ }) => Promise<{
864
+ data: any;
865
+ }>;
866
+ openComputerBrowser: (agentId: string, computerId: string, params: {
867
+ url: string;
868
+ }) => Promise<{
869
+ data: any;
870
+ }>;
871
+ listComputerEvents: (agentId: string, computerId: string, limit?: number) => Promise<{
872
+ data: AgentComputerEvent[];
873
+ }>;
626
874
  /**
627
875
  * List available TTS voices for a provider.
628
876
  * @param provider - 'openai' (default) or 'elevenlabs'
@@ -1038,6 +1286,27 @@ declare class CommonsClient {
1038
1286
  data: UsageAggregation;
1039
1287
  }>;
1040
1288
  };
1289
+ get credits(): {
1290
+ balance: (filter?: {
1291
+ principalId?: string;
1292
+ workspaceId?: string;
1293
+ }) => Promise<{
1294
+ data: CreditBalance;
1295
+ }>;
1296
+ ledger: (filter?: {
1297
+ principalId?: string;
1298
+ workspaceId?: string;
1299
+ limit?: number;
1300
+ }) => Promise<{
1301
+ data: CreditLedgerEntry[];
1302
+ }>;
1303
+ grant: (params: CreditWriteParams) => Promise<{
1304
+ data: CreditLedgerEntry;
1305
+ }>;
1306
+ debit: (params: CreditWriteParams) => Promise<{
1307
+ data: CreditLedgerEntry;
1308
+ }>;
1309
+ };
1041
1310
  }
1042
1311
  declare class CommonsError extends Error {
1043
1312
  readonly status: number;
@@ -1045,4 +1314,40 @@ declare class CommonsError extends Error {
1045
1314
  constructor(message: string, status: number, data?: unknown | undefined);
1046
1315
  }
1047
1316
 
1048
- 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 ApiKey, type ApiKeyPrincipalType, type ChatMessage, CommonsClient, type CommonsClientConfig, CommonsError, type CreateAgentParams, type CreateApiKeyParams, type CreateMemoryParams, type CreateSkillParams, type CreateTaskParams, type CreateToolKeyParams, type CreateToolParams, type CreateWalletParams, type CreatedApiKey, 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 };
1317
+ type WorkflowTemplateName = 'country-weather-brief' | 'agent-research-summary' | 'multi-agent-field-report' | 'workflow-invocation-smoke';
1318
+ interface WorkflowTemplateContext {
1319
+ ownerId: string;
1320
+ prefix: string;
1321
+ agentId?: string;
1322
+ reviewerAgentId?: string;
1323
+ childWorkflowId?: string;
1324
+ }
1325
+ interface WorkflowTemplateTool {
1326
+ key: string;
1327
+ payload: CreateToolParams;
1328
+ }
1329
+ interface WorkflowTemplateBuild {
1330
+ name: string;
1331
+ description: string;
1332
+ tags: string[];
1333
+ category: string;
1334
+ tools: WorkflowTemplateTool[];
1335
+ buildDefinition: (toolIds: Record<string, string>, ctx: WorkflowTemplateContext) => WorkflowDefinition;
1336
+ sampleInput: Record<string, any>;
1337
+ }
1338
+ declare function listWorkflowTemplates(): readonly [{
1339
+ readonly name: "country-weather-brief";
1340
+ readonly description: "Tool-only workflow using countries.dev and Open-Meteo.";
1341
+ }, {
1342
+ readonly name: "agent-research-summary";
1343
+ readonly description: "Multi-tool workflow with an agent_processor summarization step.";
1344
+ }, {
1345
+ readonly name: "multi-agent-field-report";
1346
+ readonly description: "Multi-tool workflow with two agent_processor nodes.";
1347
+ }, {
1348
+ readonly name: "workflow-invocation-smoke";
1349
+ readonly description: "Parent workflow that invokes another workflow as a workflow node.";
1350
+ }];
1351
+ declare function buildWorkflowTemplate(templateName: WorkflowTemplateName, ctx: WorkflowTemplateContext): WorkflowTemplateBuild;
1352
+
1353
+ 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 ApiKey, type ApiKeyPrincipalType, type ChatMessage, CommonsClient, type CommonsClientConfig, CommonsError, type CreateAgentParams, type CreateApiKeyParams, type CreateMemoryParams, type CreateSkillParams, type CreateTaskParams, type CreateToolKeyParams, type CreateToolParams, type CreateWalletParams, type CreatedApiKey, 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, type WorkflowTemplateBuild, type WorkflowTemplateContext, type WorkflowTemplateName, type WorkflowTemplateTool, buildWorkflowTemplate, listWorkflowTemplates };