@relevanceai/sdk 3.0.0-alpha.4 → 3.0.0-alpha.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.
Files changed (76) hide show
  1. package/README.md +240 -98
  2. package/esm/agent.d.ts +47 -8
  3. package/esm/agent.js +161 -14
  4. package/esm/client.d.ts +6 -1
  5. package/esm/client.js +38 -4
  6. package/esm/event.d.ts +6 -25
  7. package/esm/event.js +4 -19
  8. package/esm/key.d.ts +1 -1
  9. package/esm/message/agent-error.d.ts +7 -2
  10. package/esm/message/agent-error.js +8 -2
  11. package/esm/message/agent.d.ts +2 -2
  12. package/esm/message/agent.js +2 -2
  13. package/esm/message/task.d.ts +25 -4
  14. package/esm/message/task.js +26 -2
  15. package/esm/message/tool.d.ts +30 -12
  16. package/esm/message/tool.js +46 -10
  17. package/esm/message/user.d.ts +19 -2
  18. package/esm/message/user.js +21 -2
  19. package/esm/message/workforce-agent-handover.d.ts +23 -0
  20. package/esm/message/workforce-agent-handover.js +3 -0
  21. package/esm/message/workforce-agent.d.ts +23 -0
  22. package/esm/message/workforce-agent.js +3 -0
  23. package/esm/mod.d.ts +3 -7
  24. package/esm/mod.js +1 -1
  25. package/esm/task/agent-strategy.d.ts +26 -0
  26. package/esm/task/agent-strategy.js +63 -0
  27. package/esm/task/task.d.ts +59 -0
  28. package/esm/task/task.js +166 -0
  29. package/esm/task/workforce-strategy.d.ts +17 -0
  30. package/esm/task/workforce-strategy.js +68 -0
  31. package/esm/tool.d.ts +22 -0
  32. package/esm/tool.js +27 -0
  33. package/esm/utils.d.ts +1 -0
  34. package/esm/utils.js +4 -0
  35. package/esm/workforce.d.ts +22 -0
  36. package/esm/workforce.js +50 -0
  37. package/package.json +7 -1
  38. package/script/agent.d.ts +47 -8
  39. package/script/agent.js +162 -14
  40. package/script/client.d.ts +6 -1
  41. package/script/client.js +37 -3
  42. package/script/event.d.ts +6 -25
  43. package/script/event.js +6 -23
  44. package/script/key.d.ts +1 -1
  45. package/script/message/agent-error.d.ts +7 -2
  46. package/script/message/agent-error.js +7 -1
  47. package/script/message/agent.d.ts +2 -2
  48. package/script/message/agent.js +1 -1
  49. package/script/message/task.d.ts +25 -4
  50. package/script/message/task.js +28 -4
  51. package/script/message/tool.d.ts +30 -12
  52. package/script/message/tool.js +45 -9
  53. package/script/message/user.d.ts +19 -2
  54. package/script/message/user.js +20 -1
  55. package/script/message/workforce-agent-handover.d.ts +23 -0
  56. package/script/message/workforce-agent-handover.js +7 -0
  57. package/script/message/workforce-agent.d.ts +23 -0
  58. package/script/message/workforce-agent.js +7 -0
  59. package/script/mod.d.ts +3 -7
  60. package/script/mod.js +3 -3
  61. package/script/task/agent-strategy.d.ts +26 -0
  62. package/script/task/agent-strategy.js +67 -0
  63. package/script/task/task.d.ts +59 -0
  64. package/script/task/task.js +170 -0
  65. package/script/task/workforce-strategy.d.ts +17 -0
  66. package/script/task/workforce-strategy.js +72 -0
  67. package/script/tool.d.ts +22 -0
  68. package/script/tool.js +31 -0
  69. package/script/utils.d.ts +1 -0
  70. package/script/utils.js +5 -0
  71. package/script/workforce.d.ts +22 -0
  72. package/script/workforce.js +54 -0
  73. package/esm/task.d.ts +0 -57
  74. package/esm/task.js +0 -259
  75. package/script/task.d.ts +0 -57
  76. package/script/task.js +0 -263
package/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # Relevance AI JavaScript SDK
2
2
 
3
3
  A comprehensive JavaScript/TypeScript SDK for building AI-powered applications
4
- with Relevance AI's workforce platform. Build, deploy, and scale AI agents
4
+ with Relevance AI's workforce platform. Build, deploy, and scale AI workforces
5
5
  across any JavaScript runtime.
6
6
 
7
7
  ## Description
8
8
 
9
9
  The Relevance AI JavaScript SDK provides a unified interface for integrating
10
- AI agents into your applications. Whether you're building server-side
11
- applications, browser-based interfaces, or edge computing solutions, this SDK
12
- delivers consistent, type-safe access to Relevance AI's powerful agent
10
+ AI workforces and agents into your applications. Whether you're building
11
+ server-side applications, browser-based interfaces, or edge computing solutions,
12
+ this SDK delivers consistent, type-safe access to Relevance AI's powerful agent
13
13
  ecosystem.
14
14
 
15
15
  ### Key Features
@@ -18,13 +18,11 @@ ecosystem.
18
18
  Cloudflare Workers, and browsers
19
19
  - **Event-Driven Architecture**: Real-time updates via native EventTarget API
20
20
  - **Type Safety**: Full TypeScript support with comprehensive type definitions
21
- - **Multi-Client Support**: Manage multiple projects and authentication scopes
22
- simultaneously
23
21
  - **Zero Dependencies**: Built on web standards for minimal footprint
24
22
 
25
23
  ## Quick Start
26
24
 
27
- Get up and running with AI agents in under 5 minutes:
25
+ Get up and running in seconds:
28
26
 
29
27
  ```typescript
30
28
  import { Agent, createClient, EU_REGION } from "@relevanceai/sdk";
@@ -36,16 +34,25 @@ const client = createClient({
36
34
  project: process.env.PROJECT_ID,
37
35
  });
38
36
 
39
- // Load an agent and start a conversation
37
+ // Load an agent
40
38
  const agent = await Agent.get("agent-id");
39
+ // Start a conversation
41
40
  const task = await agent.sendMessage("Hello, how can you help me today?");
42
-
43
41
  // Listen for agent responses
44
42
  task.addEventListener("message", ({ detail: { message } }) => {
45
43
  if (message.isAgent()) {
46
44
  console.log("Agent:", message.text);
47
45
  }
48
46
  });
47
+
48
+ // Or use a workforce of agents
49
+
50
+ import { Workforce } from "@relevanceai/sdk";
51
+
52
+ // Load the workforce
53
+ const workforce = await Workforce.get("workforce-id");
54
+ // Start delegating
55
+ const task = await workforce.sendMessage("Analyze this complex dataset");
49
56
  ```
50
57
 
51
58
  ## Installation
@@ -123,7 +130,7 @@ Configure your bundler to use the shim:
123
130
 
124
131
  The SDK supports two authentication methods for different use cases:
125
132
 
126
- #### API Keys (Server-side)
133
+ #### API Keys (server-side)
127
134
 
128
135
  API keys grant full access to your project. Use these for server applications
129
136
  and secure environments:
@@ -152,10 +159,12 @@ const key = new Key({
152
159
  const client = new Client(key);
153
160
  ```
154
161
 
155
- #### Embed Keys (Client-side)
162
+ #### Embed Keys (client-side)
156
163
 
157
164
  For public-facing applications, use embed keys which are scoped to a specific
158
- public agent:
165
+ public agent. Embed keys need to be generated and should be stored in your
166
+ applications local storage or database. Each embed key corresponds to a single
167
+ agent or workforce.
159
168
 
160
169
  ```typescript
161
170
  import { Key, createClient, US_REGION } from "@relevanceai/sdk";
@@ -169,105 +178,159 @@ const embedKey = await Key.generateEmbedKey({
169
178
  const client = createClient(embedKey);
170
179
  ```
171
180
 
172
- ### Fetching Agents
181
+ ### Agents
173
182
 
174
- Load agents before creating tasks:
183
+ #### Loading agents
175
184
 
176
185
  ```typescript
177
- // Using default client
186
+ // fetch all agents (with pagination)
187
+ const agents = await Agent.getAll({ pageSize: 20, page: 1 });
188
+
189
+ // fetch all agents with custom page size
190
+ const agents = await Agent.getAll({ pageSize: 50, page: 3 });
191
+
192
+ // fetch all agents using default options (pageSize: 20, page: 1)
193
+ const agents = await Agent.getAll();
194
+
195
+ // using the default client
178
196
  const agent = await Agent.get("agent-id");
179
197
 
180
- // Using specific client
181
- const customClient = createClient({
182
- /* config */
183
- });
184
- const agent = await Agent.get("agent-id", customClient);
198
+ // or using a specific client
199
+ const agent = await Agent.get("agent-id", client);
185
200
 
186
- // Access agent properties
201
+ // accessing agent properties
187
202
  console.log(agent.name);
188
203
  console.log(agent.avatar);
189
204
  console.log(agent.description);
190
205
  ```
191
206
 
192
- ### Sending Messages
193
-
194
- #### Create a New Task
207
+ #### Sending messages
195
208
 
196
- Start a new conversation with an agent:
209
+ Use `Agent#sendMessage()` to send messages to an agent.
197
210
 
198
211
  ```typescript
199
- const agent = await Agent.get("agent-id");
212
+ // create a new task
200
213
  const task = await agent.sendMessage("What's the weather like today?");
214
+
215
+ // reply to existing tasks
216
+ await agent.sendMessage("What about tomorrow?", task);
217
+
218
+ // sending attachments
219
+ const contents = await Deno.readFile("./contract.pdf");
220
+ const contract = new File([contents], "contract.pdf", {
221
+ type: "application/pdf",
222
+ });
223
+ await agent.sendMessage("Summarize this contract", [contract]);
224
+ ```
225
+
226
+ Note: `Agent#sendMessage()` returns once the message is sent and doesn't wait for
227
+ a response. See Tasks for handling message events.
228
+
229
+ #### Retrieving tasks
230
+
231
+ Fetch and filter tasks for an agent:
232
+
233
+ ```typescript
234
+ // specific task
235
+ const task = await agent.getTask("<task-id>");
236
+
237
+ // pagination
238
+ const tasks = await agent.getTasks({
239
+ pageSize: 10,
240
+ page: 1,
241
+ sort: { updatedAt: "desc" },
242
+ });
243
+
244
+ // filtering
245
+ const activeTasks = await agent.getTasks({
246
+ filter: { status: ["queued", "running", "idle"] },
247
+ });
248
+
249
+ // searching
250
+ const searchResults = await agent.getTasks({
251
+ search: "weather",
252
+ sort: { createdAt: "asc" },
253
+ });
254
+ ```
255
+
256
+ ### Workforces
257
+
258
+ #### Loading workforces
259
+
260
+ ```typescript
261
+ // using the default client
262
+ const workforce = await Workforce.get("<workforce-id>");
263
+
264
+ // or with a specific client
265
+ const workforce = await Workforce.get("<workforce-id>", client);
266
+
267
+ // accessing workforce properties
268
+ console.log(workforce.name);
201
269
  ```
202
270
 
203
- #### Send to Existing Task
271
+ #### Sending messages
204
272
 
205
- Continue an existing conversation:
273
+ Use `Workforce#sendMessage()` to send messages to a workforce.
206
274
 
207
275
  ```typescript
208
- // Get an existing task
209
- const task = await agent.getTask("task-id");
276
+ // create a new task
277
+ const task = await agent.sendMessage("What's the weather like today?");
210
278
 
211
- // Send a follow-up message
279
+ // reply to existing tasks
212
280
  await agent.sendMessage("What about tomorrow?", task);
213
281
  ```
214
282
 
215
- Note: `sendMessage` returns once the message is sent and doesn't wait for a
216
- response. Use event listeners to handle responses.
283
+ Note: `Workforce#sendMessage()` returns once the message is sent and doesn't
284
+ wait for a response. See Tasks for handling message events.
285
+
286
+ #### Retrieving tasks
287
+
288
+ Load existing workforce tasks.
289
+
290
+ ```typescript
291
+ const task = await workforce.getTask("<task-id>");
292
+ ```
217
293
 
218
- ### Event Handling
294
+ ### Tasks
219
295
 
220
- Tasks use an event-driven architecture for real-time updates:
296
+ Agents and workforces, subjects, all return an instance of a `Task` when sending
297
+ messages. Tasks dispatch events as they would occur on the the subjects timeline
298
+ in the Relevance AI workforce platform.
221
299
 
222
300
  #### Available Events
223
301
 
224
- - **`start`**: Task initialization
225
- - **`status`**: Status changes (queued, running, complete, error)
226
- - **`message`**: New messages from agent or user
227
- - **`update`**: Tool execution updates
302
+ - **`update`**: Whenever a subject has been update.
303
+ - **`message`**: Unified event for all message types
228
304
  - **`error`**: Error notifications
229
305
 
230
306
  #### Listening for Events
231
307
 
232
308
  ```typescript
233
- // Listen for messages
234
- task.addEventListener("message", ({ detail }) => {
235
- const { message } = detail;
236
-
309
+ // Listen for all messages (agent, user, and tool)
310
+ task.addEventListener("message", ({ detail: { message } }) => {
311
+ // use message helpers to determine the message
237
312
  if (message.isAgent()) {
238
313
  console.log("Agent:", message.text);
314
+ } else if (message.isUser()) {
315
+ console.log("User:", message.text);
316
+ } else if (message.isTool()) {
317
+ console.log("Tool:", message.status);
239
318
  }
240
319
  });
241
320
 
242
- // Listen for status changes
243
- task.addEventListener("status", ({ detail }) => {
244
- console.log("Status changed to:", detail.status);
245
- });
246
-
247
- // Listen for tool updates
248
- task.addEventListener("update", ({ detail }) => {
249
- console.log("Tool update:", detail.message);
321
+ // catching errors
322
+ task.addEventListener("error", ({ detail: { message } }) => {
323
+ console.error("Task error:", message.lastError);
250
324
  });
251
-
252
- // Listen for errors
253
- task.addEventListener("error", ({ detail }) => {
254
- console.error("Task error:", detail.message);
255
- });
256
-
257
- // Clean up when done
258
- task.unsubscribe();
259
325
  ```
260
326
 
261
- #### Managing Subscriptions
327
+ #### Unsubscribing
262
328
 
263
- The SDK automatically starts listening when you add event listeners. Remember
264
- to clean up:
329
+ It's important that you unsubscribe from tasks once they have moved out of
330
+ scope in your application. This will prevent memory leaks by removing dead
331
+ subscriptions.
265
332
 
266
333
  ```typescript
267
- // Start listening (called automatically with addEventListener)
268
- task.subscribe();
269
-
270
- // Stop listening and clean up
271
334
  task.unsubscribe();
272
335
  ```
273
336
 
@@ -283,6 +346,7 @@ createClient({ apiKey, region, project });
283
346
 
284
347
  // Access anywhere in your app
285
348
  import { Client } from "@relevanceai/sdk";
349
+
286
350
  const client = Client.default();
287
351
  ```
288
352
 
@@ -319,10 +383,12 @@ For complete working examples, check out the `internal/examples` directory:
319
383
 
320
384
  - **Deno Examples** (`internal/examples/deno/`):
321
385
 
322
- - Client setup and configuration
323
- - Creating and managing tasks
324
- - Fetching agent information
325
- - Retrieving existing tasks
386
+ - (Agent) Creating tasks
387
+ - (Agent) Getting a task
388
+ - (Agent) Getting all agents
389
+ - (Agent) Getting all tasks
390
+ - (Agent) Getting an agent
391
+ - (Workforce) Creating a task
326
392
 
327
393
  - **Browser Example** (`internal/examples/browser/`):
328
394
  - Full chat application with Preact
@@ -336,6 +402,7 @@ For complete working examples, check out the `internal/examples` directory:
336
402
  ```typescript
337
403
  class Client {
338
404
  constructor(key: Key);
405
+
339
406
  static default(): Client;
340
407
 
341
408
  readonly key: Key;
@@ -343,7 +410,9 @@ class Client {
343
410
  readonly project: string;
344
411
 
345
412
  isEmbedKey(): boolean;
413
+
346
414
  fetch<T>(endpoint: string, init?: RequestInit): Promise<T>;
415
+
347
416
  url(path: string): URL;
348
417
  }
349
418
 
@@ -370,7 +439,9 @@ class Key {
370
439
  readonly taskPrefix?: string;
371
440
 
372
441
  isEmbed(): boolean;
442
+
373
443
  fetchHeaders(): HeadersInit;
444
+
374
445
  toJSON(): CreateKeyOptions;
375
446
  }
376
447
 
@@ -395,6 +466,11 @@ interface GenerateEmbedKeyOptions {
395
466
  class Agent {
396
467
  static async get(id: string, client?: Client): Promise<Agent>;
397
468
 
469
+ static async getAll(
470
+ options?: GetAllOptions,
471
+ client?: Client
472
+ ): Promise<Agent[]>;
473
+
398
474
  readonly id: string;
399
475
  readonly name?: string;
400
476
  readonly description?: string;
@@ -405,31 +481,83 @@ class Agent {
405
481
  readonly project: string;
406
482
 
407
483
  getTask(taskId: string): Promise<Task>;
408
- sendMessage(message: string, task?: Task): Promise<Task>;
484
+
485
+ getTasks(): Promise<Task[]>;
486
+ getTasks(options: GetTaskOptions): Promise<Task[]>;
487
+
488
+ sendMessage(message: string): Promise<Task>;
489
+ sendMessage(message: string, task: Task): Promise<Task>;
490
+ sendMessage(
491
+ message: string,
492
+ attachments: (File | Attachment)[]
493
+ ): Promise<Task>;
494
+ sendMessage(
495
+ message: string,
496
+ attachments: (File | Attachment)[],
497
+ task: Task
498
+ ): Promise<Task>;
499
+ }
500
+
501
+ interface Attachment {
502
+ fileName: string;
503
+ fileUrl: string;
504
+ }
505
+
506
+ interface GetTaskOptions {
507
+ pageSize?: number; // default: 100
508
+ page?: number; // default: 1
509
+ // default: { createdAt: "asc" }
510
+ sort?: { createdAt: "asc" | "desc" } | { updatedAt: "asc" | "desc" };
511
+ search?: string;
512
+ filter?: {
513
+ status?: TaskStatus[];
514
+ };
515
+ }
516
+
517
+ interface GetAllOptions {
518
+ pageSize?: number; // default: 20
519
+ page?: number; // default: 1
409
520
  }
410
521
  ```
411
522
 
412
- ### Task
523
+ ### Workforce
413
524
 
414
525
  ```typescript
415
- class Task extends EventTarget {
416
- static async get(
417
- id: string,
418
- agentOrAgentId: Agent | string,
419
- client?: Client
420
- ): Promise<Task>;
526
+ class Workforce {
527
+ static async get(id: string, client?: Client): Promise<Workforce>;
421
528
 
529
+ readonly id: string;
530
+ readonly name: string;
531
+ readonly region: Region;
532
+ readonly project: string;
533
+
534
+ getTask(taskId: string): Promise<Task>;
535
+
536
+ sendMessage(message: string): Promise<Task>;
537
+ sendMessage(message: string, task: Task): Promise<Task>;
538
+ }
539
+ ```
540
+
541
+ ### Task
542
+
543
+ ```typescript
544
+ class Task<T extends Agent | Workforce = Agent> extends EventTarget {
422
545
  readonly id: string;
423
546
  readonly title: string;
424
547
  readonly status: TaskStatus;
425
- readonly agent: Agent;
548
+ readonly subject: Agent | Workforce;
426
549
 
427
550
  isRunning(): boolean;
428
- getMessages(options?: { from?: Date }): Promise<AnyTaskMessage[]>;
551
+
552
+ getMessages(): Promise<AnyTaskMessage[]>;
553
+ getMessages(options: { from: Date }): Promise<AnyTaskMessage[]>;
554
+
429
555
  subscribe(): void;
556
+
430
557
  unsubscribe(): void;
431
558
 
432
559
  addEventListener(type: string, listener: EventListener): void;
560
+
433
561
  removeEventListener(type: string, listener: EventListener): void;
434
562
  }
435
563
 
@@ -439,46 +567,60 @@ type TaskStatus =
439
567
  | "queued"
440
568
  | "running"
441
569
  | "action"
442
- | "complete"
570
+ | "completed"
443
571
  | "error";
444
572
  ```
445
573
 
446
574
  ### Messages
447
575
 
448
576
  ```typescript
449
- abstract class TaskMessage {
577
+ abstract class GenericMessage {
450
578
  readonly id: string;
451
579
  readonly type: MessageType;
452
580
  readonly createdAt: Date;
453
581
 
454
- isAgent(): boolean;
582
+ isAgent(): boolean; // Check if message is from agent
583
+ isUser(): boolean; // Check if message is from user
584
+ isTool(): boolean; // Check if message is a tool execution
585
+ isAgentError(): boolean; // Check if message is an agent error
455
586
  }
456
587
 
457
- class AgentMessage extends TaskMessage {
588
+ class AgentMessage extends GenericMessage {
458
589
  readonly text: string;
459
590
  }
460
591
 
461
- class UserMessage extends TaskMessage {
592
+ class UserMessage extends GenericMessage {
462
593
  readonly text: string;
463
594
  }
464
595
 
465
- class ToolMessage extends TaskMessage {
466
- readonly status: "pending" | "running" | "completed" | "failed";
467
- }
596
+ class ToolMessage extends GenericMessage {
597
+ readonly status: "cancelled" | "pending" | "running" | "completed" | "failed";
598
+ readonly tool?: Tool; // Available when message is from a tool (not subagent)
599
+ readonly toolOrAgentId: string; // ID of the tool or subagent
468
600
 
469
- class AgentErrorMessage extends TaskMessage {
470
- readonly error: string;
601
+ isSubAgent(): boolean; // Check if this is a subagent execution
602
+ subAgentTaskId: string | null; // Task ID if this is a subagent, null otherwise
471
603
  }
604
+
605
+ class AgentErrorMessage extends GenericMessage {}
606
+
607
+ class WorkforceAgentMessage extends GenericMessage {}
608
+
609
+ class WorkforceAgentHandoverMessage extends GenericMessage {}
472
610
  ```
473
611
 
474
- ### Types
612
+ ### Tool
475
613
 
476
614
  ```typescript
477
- type Region = "us" | "eu" | "au";
478
-
479
- const US_REGION: Region = "us";
480
- const EU_REGION: Region = "eu";
481
- const AU_REGION: Region = "au";
615
+ class Tool {
616
+ readonly id: string;
617
+ readonly name: string;
618
+ readonly avatar?: string;
619
+ readonly description?: string;
620
+ readonly region: Region;
621
+ readonly project: string;
622
+ readonly parametersSchema: JSONSchema4;
623
+ }
482
624
  ```
483
625
 
484
626
  ## Contributing
@@ -514,9 +656,10 @@ deno run dnt
514
656
  ### Current
515
657
 
516
658
  - [x] Core client functionality
517
- - [x] Agent and task creation
659
+ - [x] Task creation
518
660
  - [x] Event-driven messaging
519
661
  - [x] Multi-environment support
662
+ - [x] Workforce support
520
663
 
521
664
  ### Upcoming Features
522
665
 
@@ -524,7 +667,6 @@ deno run dnt
524
667
  - [ ] File upload support
525
668
  - [ ] Enhanced error recovery
526
669
  - [ ] Agent and task management
527
- - [ ] Workforce support
528
670
  - [ ] Tool support
529
671
 
530
672
  ### Future Considerations (2.0)
package/esm/agent.d.ts CHANGED
@@ -1,29 +1,68 @@
1
- import { Client } from "./client.js";
1
+ import { type Attachment, Client } from "./client.js";
2
2
  import type { Region } from "./region.js";
3
- import { Task } from "./task.js";
4
- interface AgentConfig {
3
+ import { Task, type TaskStatus } from "./task/task.js";
4
+ export interface AgentConfig {
5
5
  agent_id: string;
6
6
  public: boolean;
7
+ project: string;
7
8
  name?: string;
8
9
  description?: string;
9
10
  emoji?: string;
10
11
  insert_date_: string;
11
12
  update_date_: string;
13
+ model: string;
12
14
  }
15
+ export type AgentTaskState = "idle" | "starting-up" | "running" | "pending-approval" | "waiting-for-capacity" | "cancelled" | "timed-out" | "escalated" | "unrecoverable" | "paused" | "completed" | "errored-pending-approval" | "queued-for-approval" | "queued-for-rerun";
16
+ /**
17
+ * Converts an AgentTaskState to a simplified TaskStatus.
18
+ *
19
+ * @dev
20
+ * We want to simplify because our states are simplified in the UI and also
21
+ * some states have combined reasoning that the consumer does not need to care
22
+ * about. i.e. "queued-for-approval" "queued-for-rerun" should just be "queued".
23
+ *
24
+ * @param {AgentTaskState} state The agent task state to convert.
25
+ * @returns {TaskStatus} The simplified task status.
26
+ */
27
+ export declare function stateToStatus(state: AgentTaskState): TaskStatus;
28
+ type SortDirection = "asc" | "desc";
29
+ type GetTaskOptionSort = {
30
+ createdAt: SortDirection;
31
+ } | {
32
+ updatedAt: SortDirection;
33
+ };
34
+ type GetTaskOptions = {
35
+ pageSize?: number;
36
+ page?: number;
37
+ sort?: GetTaskOptionSort;
38
+ search?: string;
39
+ filter?: {
40
+ status?: TaskStatus[];
41
+ };
42
+ };
43
+ type GetAllOptions = {
44
+ pageSize?: number;
45
+ page?: number;
46
+ };
13
47
  export declare class Agent {
14
48
  #private;
15
- private readonly client;
16
49
  static get(id: string, client?: Client): Promise<Agent>;
50
+ static getAll({ page, pageSize, }?: GetAllOptions, client?: Client): Promise<Agent[]>;
51
+ private readonly client;
17
52
  constructor(config: AgentConfig, client: Client);
18
53
  get id(): string;
54
+ get region(): Region;
55
+ get project(): string;
19
56
  get name(): string | undefined;
20
57
  get description(): string | undefined;
21
58
  get avatar(): string | undefined;
22
59
  get createdAt(): Date;
23
60
  get updatedAt(): Date;
24
- get region(): Region;
25
- get project(): string;
26
- getTask(taskId: string): Promise<Task>;
27
- sendMessage(message: string, task?: Task): Promise<Task>;
61
+ getTask(taskId: string): Promise<Task<Agent>>;
62
+ getTasks({ sort, pageSize, page, search, filter, }?: GetTaskOptions): Promise<Task<Agent>[]>;
63
+ sendMessage(message: string): Promise<Task<Agent>>;
64
+ sendMessage(message: string, task: Task<Agent>): Promise<Task<Agent>>;
65
+ sendMessage(message: string, attachments: (Attachment | File)[]): Promise<Task<Agent>>;
66
+ sendMessage(message: string, attachments: (Attachment | File)[], task: Task<Agent>): Promise<Task<Agent>>;
28
67
  }
29
68
  export {};