@kaiban/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.
Files changed (86) hide show
  1. package/README.md +225 -0
  2. package/dist/index.d.ts +15 -0
  3. package/dist/index.js +15 -0
  4. package/dist/lib/client.d.ts +65 -0
  5. package/dist/lib/client.js +51 -0
  6. package/dist/lib/http/HttpClient.d.ts +16 -0
  7. package/dist/lib/http/HttpClient.js +237 -0
  8. package/dist/lib/http/errors.d.ts +50 -0
  9. package/dist/lib/http/errors.js +126 -0
  10. package/dist/lib/http/types.d.ts +40 -0
  11. package/dist/lib/http/types.js +1 -0
  12. package/dist/lib/resources/ActivitiesClient.d.ts +89 -0
  13. package/dist/lib/resources/ActivitiesClient.js +99 -0
  14. package/dist/lib/resources/AgentsClient.d.ts +121 -0
  15. package/dist/lib/resources/AgentsClient.js +134 -0
  16. package/dist/lib/resources/BenchmarkExecutionsClient.d.ts +250 -0
  17. package/dist/lib/resources/BenchmarkExecutionsClient.js +261 -0
  18. package/dist/lib/resources/BenchmarksClient.d.ts +159 -0
  19. package/dist/lib/resources/BenchmarksClient.js +158 -0
  20. package/dist/lib/resources/BoardsClient.d.ts +65 -0
  21. package/dist/lib/resources/BoardsClient.js +74 -0
  22. package/dist/lib/resources/CardsClient.d.ts +161 -0
  23. package/dist/lib/resources/CardsClient.js +202 -0
  24. package/dist/lib/resources/ExternalChannelsClient.d.ts +65 -0
  25. package/dist/lib/resources/ExternalChannelsClient.js +74 -0
  26. package/dist/lib/resources/ResourcesClient.d.ts +92 -0
  27. package/dist/lib/resources/ResourcesClient.js +98 -0
  28. package/dist/lib/resources/SupervisorFeedbackClient.d.ts +75 -0
  29. package/dist/lib/resources/SupervisorFeedbackClient.js +67 -0
  30. package/dist/lib/resources/TeamMembersClient.d.ts +66 -0
  31. package/dist/lib/resources/TeamMembersClient.js +75 -0
  32. package/dist/lib/resources/TeamsClient.d.ts +83 -0
  33. package/dist/lib/resources/TeamsClient.js +92 -0
  34. package/dist/lib/resources/__tests__/ActivitiesClient.test.d.ts +1 -0
  35. package/dist/lib/resources/__tests__/ActivitiesClient.test.js +33 -0
  36. package/dist/lib/resources/__tests__/AgentsClient.test.d.ts +1 -0
  37. package/dist/lib/resources/__tests__/AgentsClient.test.js +37 -0
  38. package/dist/lib/resources/__tests__/BenchmarkExecutionsClient.test.d.ts +1 -0
  39. package/dist/lib/resources/__tests__/BenchmarkExecutionsClient.test.js +59 -0
  40. package/dist/lib/resources/__tests__/BenchmarksClient.test.d.ts +1 -0
  41. package/dist/lib/resources/__tests__/BenchmarksClient.test.js +42 -0
  42. package/dist/lib/resources/__tests__/BoardsClient.test.d.ts +1 -0
  43. package/dist/lib/resources/__tests__/BoardsClient.test.js +26 -0
  44. package/dist/lib/resources/__tests__/CardsClient.test.d.ts +1 -0
  45. package/dist/lib/resources/__tests__/CardsClient.test.js +62 -0
  46. package/dist/lib/resources/__tests__/ExternalChannelsClient.test.d.ts +1 -0
  47. package/dist/lib/resources/__tests__/ExternalChannelsClient.test.js +26 -0
  48. package/dist/lib/resources/__tests__/ResourcesClient.test.d.ts +1 -0
  49. package/dist/lib/resources/__tests__/ResourcesClient.test.js +28 -0
  50. package/dist/lib/resources/__tests__/SupervisorFeedbackClient.test.d.ts +1 -0
  51. package/dist/lib/resources/__tests__/SupervisorFeedbackClient.test.js +24 -0
  52. package/dist/lib/resources/__tests__/TeamMembersClient.test.d.ts +1 -0
  53. package/dist/lib/resources/__tests__/TeamMembersClient.test.js +26 -0
  54. package/dist/lib/resources/__tests__/TeamsClient.test.d.ts +1 -0
  55. package/dist/lib/resources/__tests__/TeamsClient.test.js +26 -0
  56. package/dist/test/helpers/mockFetch.d.ts +8 -0
  57. package/dist/test/helpers/mockFetch.js +22 -0
  58. package/dist/types/a2a-data-parts.d.ts +64 -0
  59. package/dist/types/a2a-data-parts.js +13 -0
  60. package/dist/types/entities/activities.d.ts +32 -0
  61. package/dist/types/entities/activities.js +1 -0
  62. package/dist/types/entities/agent.d.ts +16 -0
  63. package/dist/types/entities/agent.js +1 -0
  64. package/dist/types/entities/benchmark.d.ts +82 -0
  65. package/dist/types/entities/benchmark.js +1 -0
  66. package/dist/types/entities/board.d.ts +20 -0
  67. package/dist/types/entities/board.js +1 -0
  68. package/dist/types/entities/card.d.ts +50 -0
  69. package/dist/types/entities/card.js +1 -0
  70. package/dist/types/entities/external-channel.d.ts +12 -0
  71. package/dist/types/entities/external-channel.js +1 -0
  72. package/dist/types/entities/index.d.ts +9 -0
  73. package/dist/types/entities/index.js +9 -0
  74. package/dist/types/entities/resource.d.ts +16 -0
  75. package/dist/types/entities/resource.js +1 -0
  76. package/dist/types/entities/shared.d.ts +1 -0
  77. package/dist/types/entities/shared.js +2 -0
  78. package/dist/types/entities/team.d.ts +14 -0
  79. package/dist/types/entities/team.js +1 -0
  80. package/dist/types/entities.d.ts +1 -0
  81. package/dist/types/entities.js +1 -0
  82. package/dist/types/requests.d.ts +22 -0
  83. package/dist/types/requests.js +1 -0
  84. package/dist/types/responses.d.ts +77 -0
  85. package/dist/types/responses.js +1 -0
  86. package/package.json +54 -0
@@ -0,0 +1,126 @@
1
+ export class HttpError extends Error {
2
+ constructor(message, status, url, body) {
3
+ super(message);
4
+ this.name = 'HttpError';
5
+ this.status = status;
6
+ this.url = url;
7
+ this.body = body;
8
+ }
9
+ }
10
+ export class TimeoutError extends Error {
11
+ constructor(message = 'Request timed out') {
12
+ super(message);
13
+ this.name = 'TimeoutError';
14
+ }
15
+ }
16
+ export class AbortedError extends Error {
17
+ constructor(message = 'Request was aborted') {
18
+ super(message);
19
+ this.name = 'AbortedError';
20
+ }
21
+ }
22
+ export class ApiError extends Error {
23
+ constructor(shape) {
24
+ super(shape.message);
25
+ this.name = 'ApiError';
26
+ this.code = shape.code;
27
+ this.details = shape.details;
28
+ }
29
+ }
30
+ export class BadRequestError extends ApiError {
31
+ constructor(shape) {
32
+ super(shape);
33
+ this.name = 'BadRequestError';
34
+ }
35
+ }
36
+ export class ValidationError extends ApiError {
37
+ constructor(shape) {
38
+ super(shape);
39
+ this.name = 'ValidationError';
40
+ }
41
+ }
42
+ export class UnauthorizedError extends ApiError {
43
+ constructor(shape) {
44
+ super(shape);
45
+ this.name = 'UnauthorizedError';
46
+ }
47
+ }
48
+ export class ForbiddenError extends ApiError {
49
+ constructor(shape) {
50
+ super(shape);
51
+ this.name = 'ForbiddenError';
52
+ }
53
+ }
54
+ export class NotFoundError extends ApiError {
55
+ constructor(shape) {
56
+ super(shape);
57
+ this.name = 'NotFoundError';
58
+ }
59
+ }
60
+ export class ConflictError extends ApiError {
61
+ constructor(shape) {
62
+ super(shape);
63
+ this.name = 'ConflictError';
64
+ }
65
+ }
66
+ export class RateLimitError extends ApiError {
67
+ constructor(shape) {
68
+ super(shape);
69
+ this.name = 'RateLimitError';
70
+ }
71
+ }
72
+ export class UnavailableError extends ApiError {
73
+ constructor(shape) {
74
+ super(shape);
75
+ this.name = 'UnavailableError';
76
+ }
77
+ }
78
+ export class ServerError extends ApiError {
79
+ constructor(shape) {
80
+ super(shape);
81
+ this.name = 'ServerError';
82
+ }
83
+ }
84
+ // Map HTTP response status and body to human-friendly SDK errors
85
+ export function mapHttpToSdkError(status, body) {
86
+ const shape = normalizeBody(body);
87
+ switch (status) {
88
+ case 400:
89
+ return new BadRequestError(shape);
90
+ case 401:
91
+ return new UnauthorizedError(shape);
92
+ case 403:
93
+ return new ForbiddenError(shape);
94
+ case 404:
95
+ return new NotFoundError(shape);
96
+ case 409:
97
+ return new ConflictError(shape);
98
+ case 422:
99
+ return new ValidationError(shape);
100
+ case 429:
101
+ return new RateLimitError(shape);
102
+ case 502:
103
+ case 503:
104
+ case 504:
105
+ return new UnavailableError(shape);
106
+ case 500:
107
+ default:
108
+ return new ServerError(shape);
109
+ }
110
+ }
111
+ function normalizeBody(body) {
112
+ if (!body)
113
+ return { message: 'Unknown error' };
114
+ if (typeof body === 'string')
115
+ return { message: body };
116
+ if (typeof body === 'object') {
117
+ const anyBody = body;
118
+ const code = anyBody['code'] || anyBody['error'];
119
+ const message = anyBody['message'] ||
120
+ anyBody['error_description'] ||
121
+ 'Request failed';
122
+ const details = anyBody['details'];
123
+ return { code, message, details };
124
+ }
125
+ return { message: 'Request failed' };
126
+ }
@@ -0,0 +1,40 @@
1
+ export interface KaibanClientConfig {
2
+ tenant: string;
3
+ token: string;
4
+ baseUrl?: string;
5
+ timeoutMs?: number;
6
+ retry?: {
7
+ maxAttempts?: number;
8
+ backoffMs?: number;
9
+ maxBackoffMs?: number;
10
+ jitter?: boolean;
11
+ retryOn?: number[];
12
+ retryMethods?: string[];
13
+ };
14
+ fetch?: typeof fetch;
15
+ onRequest?: (info: {
16
+ method: string;
17
+ url: string;
18
+ init: RequestInit;
19
+ }) => void;
20
+ onResponse?: (info: {
21
+ status: number;
22
+ url: string;
23
+ response: Response;
24
+ }) => void;
25
+ }
26
+ export interface RequestOptions {
27
+ signal?: AbortSignal;
28
+ headers?: Record<string, string>;
29
+ query?: Record<string, unknown>;
30
+ timeoutMs?: number;
31
+ /** Optional per-request retry overrides; merged with client-level defaults. */
32
+ retry?: {
33
+ maxAttempts?: number;
34
+ backoffMs?: number;
35
+ maxBackoffMs?: number;
36
+ jitter?: boolean;
37
+ retryOn?: number[];
38
+ retryMethods?: string[];
39
+ };
40
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,89 @@
1
+ import { HttpClient } from '../http/HttpClient';
2
+ import { RequestOptions } from '../http/types';
3
+ import { CardActivity, ActivityCreate } from '../../types/entities';
4
+ import { ListParams, Paginated } from '../../types/responses';
5
+ /**
6
+ * Client for managing card activities
7
+ * Activities track changes, comments, and events on cards
8
+ * @category Resources
9
+ */
10
+ export declare class ActivitiesClient {
11
+ private readonly http;
12
+ constructor(http: HttpClient);
13
+ /**
14
+ * List activities for a specific card
15
+ * Supports pagination, filtering, and sorting through query parameters
16
+ *
17
+ * @param cardId - The unique identifier of the card
18
+ * @param params - Optional query parameters for filtering and pagination
19
+ * @param params.cursor - Cursor for the next page of results
20
+ * @param params.limit - Number of items per page
21
+ * @param params.order_by - Fields to sort by
22
+ * @param options - Optional request configuration
23
+ *
24
+ * @returns A paginated list of activities
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * // Get activities for a card
29
+ * const result = await client.activities.list('card-123', {
30
+ * limit: 20,
31
+ * order_by: ['created_at']
32
+ * });
33
+ *
34
+ * console.log(result.items); // Array of CardActivity objects
35
+ * ```
36
+ */
37
+ list(cardId: string, params?: ListParams, options?: RequestOptions): Promise<Paginated<CardActivity>>;
38
+ /**
39
+ * Iterate through all activities for a card using async generator
40
+ * Automatically handles pagination by following next_page_token
41
+ *
42
+ * @param cardId - The unique identifier of the card
43
+ * @param params - Optional query parameters (excluding cursor)
44
+ * @param options - Optional request configuration
45
+ *
46
+ * @yields Individual CardActivity objects
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * // Process all activities for a card
51
+ * for await (const activity of client.activities.listAll('card-123')) {
52
+ * console.log(activity.type, activity.description);
53
+ * }
54
+ * ```
55
+ */
56
+ listAll(cardId: string, params?: Omit<ListParams, 'cursor'>, options?: RequestOptions): AsyncGenerator<CardActivity, void, unknown>;
57
+ /**
58
+ * Create a new activity for a card
59
+ * Activities can track various events such as comments, status changes, or custom events
60
+ *
61
+ * @param cardId - The unique identifier of the card
62
+ * @param data - Activity creation data
63
+ * @param data.type - The type of activity (e.g., 'card_created', 'card_updated', 'comment')
64
+ * @param data.description - A description of the activity
65
+ * @param data.actor - The actor who performed the activity
66
+ * @param options - Optional request configuration
67
+ *
68
+ * @returns The created activity object
69
+ *
70
+ * @throws {Error} If the card is not found or creation fails
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const activity = await client.activities.create('card-123', {
75
+ * board_id: 'board-456',
76
+ * team_id: 'team-789',
77
+ * card_id: 'card-123',
78
+ * type: 'comment',
79
+ * description: 'Added a comment',
80
+ * actor: {
81
+ * id: 'user-001',
82
+ * type: 'user',
83
+ * name: 'Jane Doe'
84
+ * }
85
+ * });
86
+ * ```
87
+ */
88
+ create(cardId: string, data: ActivityCreate, options?: RequestOptions): Promise<CardActivity>;
89
+ }
@@ -0,0 +1,99 @@
1
+ // Reuse ActivityCreate from shared types
2
+ /**
3
+ * Client for managing card activities
4
+ * Activities track changes, comments, and events on cards
5
+ * @category Resources
6
+ */
7
+ export class ActivitiesClient {
8
+ constructor(http) {
9
+ this.http = http;
10
+ }
11
+ /**
12
+ * List activities for a specific card
13
+ * Supports pagination, filtering, and sorting through query parameters
14
+ *
15
+ * @param cardId - The unique identifier of the card
16
+ * @param params - Optional query parameters for filtering and pagination
17
+ * @param params.cursor - Cursor for the next page of results
18
+ * @param params.limit - Number of items per page
19
+ * @param params.order_by - Fields to sort by
20
+ * @param options - Optional request configuration
21
+ *
22
+ * @returns A paginated list of activities
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // Get activities for a card
27
+ * const result = await client.activities.list('card-123', {
28
+ * limit: 20,
29
+ * order_by: ['created_at']
30
+ * });
31
+ *
32
+ * console.log(result.items); // Array of CardActivity objects
33
+ * ```
34
+ */
35
+ list(cardId, params, options) {
36
+ return this.http.list(`/card/${encodeURIComponent(cardId)}/activities`, params, options);
37
+ }
38
+ /**
39
+ * Iterate through all activities for a card using async generator
40
+ * Automatically handles pagination by following next_page_token
41
+ *
42
+ * @param cardId - The unique identifier of the card
43
+ * @param params - Optional query parameters (excluding cursor)
44
+ * @param options - Optional request configuration
45
+ *
46
+ * @yields Individual CardActivity objects
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * // Process all activities for a card
51
+ * for await (const activity of client.activities.listAll('card-123')) {
52
+ * console.log(activity.type, activity.description);
53
+ * }
54
+ * ```
55
+ */
56
+ async *listAll(cardId, params, options) {
57
+ let cursor = undefined;
58
+ do {
59
+ const page = await this.list(cardId, { ...(params || {}), cursor }, options);
60
+ for (const item of page.data)
61
+ yield item;
62
+ cursor = page.meta.next_cursor;
63
+ } while (cursor);
64
+ }
65
+ /**
66
+ * Create a new activity for a card
67
+ * Activities can track various events such as comments, status changes, or custom events
68
+ *
69
+ * @param cardId - The unique identifier of the card
70
+ * @param data - Activity creation data
71
+ * @param data.type - The type of activity (e.g., 'card_created', 'card_updated', 'comment')
72
+ * @param data.description - A description of the activity
73
+ * @param data.actor - The actor who performed the activity
74
+ * @param options - Optional request configuration
75
+ *
76
+ * @returns The created activity object
77
+ *
78
+ * @throws {Error} If the card is not found or creation fails
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const activity = await client.activities.create('card-123', {
83
+ * board_id: 'board-456',
84
+ * team_id: 'team-789',
85
+ * card_id: 'card-123',
86
+ * type: 'comment',
87
+ * description: 'Added a comment',
88
+ * actor: {
89
+ * id: 'user-001',
90
+ * type: 'user',
91
+ * name: 'Jane Doe'
92
+ * }
93
+ * });
94
+ * ```
95
+ */
96
+ create(cardId, data, options) {
97
+ return this.http.post(`/card/${encodeURIComponent(cardId)}/activities`, data, options);
98
+ }
99
+ }
@@ -0,0 +1,121 @@
1
+ import { HttpClient } from '../http/HttpClient';
2
+ import { RequestOptions } from '../http/types';
3
+ import { Agent, AgentFeedback } from '../../types/entities';
4
+ import { ListParams, Paginated } from '../../types/responses';
5
+ /**
6
+ * Client for managing agents in the Kaiban platform
7
+ * @category Resources
8
+ */
9
+ export declare class AgentsClient {
10
+ private readonly http;
11
+ constructor(http: HttpClient);
12
+ /**
13
+ * List agents with pagination, filters, and sorting
14
+ *
15
+ * @param params - Optional query parameters for filtering and pagination
16
+ * @param params.cursor - Cursor for the next page of results
17
+ * @param params.limit - Number of items per page
18
+ * @param params.order_by - Fields to sort by
19
+ * @param options - Optional request configuration
20
+ *
21
+ * @returns A paginated list of agents
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * // List first page of agents
26
+ * const result = await client.agents.list({ limit: 10 });
27
+ * console.log(result.items); // Array of Agent objects
28
+ *
29
+ * // Get next page using cursor
30
+ * if (result.next_page_token) {
31
+ * const nextPage = await client.agents.list({
32
+ * cursor: result.next_page_token
33
+ * });
34
+ * }
35
+ * ```
36
+ */
37
+ list(params?: ListParams, options?: RequestOptions): Promise<Paginated<Agent>>;
38
+ /**
39
+ * Iterate through all agents using async generator
40
+ * Automatically handles pagination by following next_page_token
41
+ *
42
+ * @param params - Optional query parameters (excluding cursor)
43
+ * @param options - Optional request configuration
44
+ *
45
+ * @yields Individual Agent objects
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * // Iterate through all agents
50
+ * for await (const agent of client.agents.listAll()) {
51
+ * console.log(agent.id, agent.name);
52
+ * }
53
+ *
54
+ * // With filtering
55
+ * for await (const agent of client.agents.listAll({
56
+ * order_by: ['created_at']
57
+ * })) {
58
+ * console.log(agent);
59
+ * }
60
+ * ```
61
+ */
62
+ listAll(params?: Omit<ListParams, 'cursor'>, options?: RequestOptions): AsyncGenerator<Agent, void, unknown>;
63
+ /**
64
+ * Get a single agent by ID
65
+ *
66
+ * @param id - The unique identifier of the agent
67
+ * @param options - Optional request configuration
68
+ *
69
+ * @returns The agent object
70
+ *
71
+ * @throws {Error} If the agent is not found or request fails
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const agent = await client.agents.get('agent-123');
76
+ * console.log(agent.name, agent.status);
77
+ * ```
78
+ */
79
+ get(id: string, options?: RequestOptions): Promise<Agent>;
80
+ /**
81
+ * Update an agent's properties
82
+ *
83
+ * @param id - The unique identifier of the agent to update
84
+ * @param data - Partial agent data with fields to update
85
+ * @param options - Optional request configuration
86
+ *
87
+ * @returns The updated agent object
88
+ *
89
+ * @throws {Error} If the agent is not found or update fails
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * const updatedAgent = await client.agents.update('agent-123', {
94
+ * name: 'New Name',
95
+ * status: 'active'
96
+ * });
97
+ * ```
98
+ */
99
+ update(id: string, data: Partial<Agent>, options?: RequestOptions): Promise<Agent>;
100
+ /**
101
+ * Create feedback for an agent
102
+ *
103
+ * @param id - The unique identifier of the agent
104
+ * @param feedback - Feedback data to submit
105
+ * @param options - Optional request configuration
106
+ *
107
+ * @returns Promise that resolves when feedback is created
108
+ *
109
+ * @throws {Error} If the agent is not found or feedback creation fails
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * await client.agents.createFeedback('agent-123', {
114
+ * rating: 5,
115
+ * comment: 'Excellent performance',
116
+ * tags: ['helpful', 'accurate']
117
+ * });
118
+ * ```
119
+ */
120
+ createFeedback(id: string, feedback: AgentFeedback, options?: RequestOptions): Promise<void>;
121
+ }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Client for managing agents in the Kaiban platform
3
+ * @category Resources
4
+ */
5
+ export class AgentsClient {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ /**
10
+ * List agents with pagination, filters, and sorting
11
+ *
12
+ * @param params - Optional query parameters for filtering and pagination
13
+ * @param params.cursor - Cursor for the next page of results
14
+ * @param params.limit - Number of items per page
15
+ * @param params.order_by - Fields to sort by
16
+ * @param options - Optional request configuration
17
+ *
18
+ * @returns A paginated list of agents
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // List first page of agents
23
+ * const result = await client.agents.list({ limit: 10 });
24
+ * console.log(result.items); // Array of Agent objects
25
+ *
26
+ * // Get next page using cursor
27
+ * if (result.next_page_token) {
28
+ * const nextPage = await client.agents.list({
29
+ * cursor: result.next_page_token
30
+ * });
31
+ * }
32
+ * ```
33
+ */
34
+ list(params, options) {
35
+ return this.http.list('/agents', params, options);
36
+ }
37
+ /**
38
+ * Iterate through all agents using async generator
39
+ * Automatically handles pagination by following next_page_token
40
+ *
41
+ * @param params - Optional query parameters (excluding cursor)
42
+ * @param options - Optional request configuration
43
+ *
44
+ * @yields Individual Agent objects
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * // Iterate through all agents
49
+ * for await (const agent of client.agents.listAll()) {
50
+ * console.log(agent.id, agent.name);
51
+ * }
52
+ *
53
+ * // With filtering
54
+ * for await (const agent of client.agents.listAll({
55
+ * order_by: ['created_at']
56
+ * })) {
57
+ * console.log(agent);
58
+ * }
59
+ * ```
60
+ */
61
+ async *listAll(params, options) {
62
+ let pageToken = undefined;
63
+ do {
64
+ const page = await this.list({ ...(params || {}), cursor: pageToken }, options);
65
+ for (const item of page.data)
66
+ yield item;
67
+ pageToken = page.meta.next_cursor;
68
+ } while (pageToken);
69
+ }
70
+ /**
71
+ * Get a single agent by ID
72
+ *
73
+ * @param id - The unique identifier of the agent
74
+ * @param options - Optional request configuration
75
+ *
76
+ * @returns The agent object
77
+ *
78
+ * @throws {Error} If the agent is not found or request fails
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const agent = await client.agents.get('agent-123');
83
+ * console.log(agent.name, agent.status);
84
+ * ```
85
+ */
86
+ get(id, options) {
87
+ return this.http.get(`/agent/${encodeURIComponent(id)}`, options);
88
+ }
89
+ /**
90
+ * Update an agent's properties
91
+ *
92
+ * @param id - The unique identifier of the agent to update
93
+ * @param data - Partial agent data with fields to update
94
+ * @param options - Optional request configuration
95
+ *
96
+ * @returns The updated agent object
97
+ *
98
+ * @throws {Error} If the agent is not found or update fails
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * const updatedAgent = await client.agents.update('agent-123', {
103
+ * name: 'New Name',
104
+ * status: 'active'
105
+ * });
106
+ * ```
107
+ */
108
+ update(id, data, options) {
109
+ return this.http.put(`/agent/${encodeURIComponent(id)}`, data, options);
110
+ }
111
+ /**
112
+ * Create feedback for an agent
113
+ *
114
+ * @param id - The unique identifier of the agent
115
+ * @param feedback - Feedback data to submit
116
+ * @param options - Optional request configuration
117
+ *
118
+ * @returns Promise that resolves when feedback is created
119
+ *
120
+ * @throws {Error} If the agent is not found or feedback creation fails
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * await client.agents.createFeedback('agent-123', {
125
+ * rating: 5,
126
+ * comment: 'Excellent performance',
127
+ * tags: ['helpful', 'accurate']
128
+ * });
129
+ * ```
130
+ */
131
+ createFeedback(id, feedback, options) {
132
+ return this.http.post(`/agent/${encodeURIComponent(id)}/feedback`, feedback, options);
133
+ }
134
+ }