@kaiban/sdk 0.1.9 → 0.3.0

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 (93) hide show
  1. package/README.md +187 -21
  2. package/dist/cjs/index.js +21 -0
  3. package/dist/cjs/lib/client.js +56 -0
  4. package/dist/cjs/lib/http/HttpClient.js +243 -0
  5. package/dist/cjs/lib/http/errors.js +143 -0
  6. package/dist/cjs/lib/http/types.js +2 -0
  7. package/dist/cjs/lib/resources/ActivitiesClient.js +164 -0
  8. package/dist/cjs/lib/resources/AgentsClient.js +224 -0
  9. package/dist/cjs/lib/resources/BoardsClient.js +120 -0
  10. package/dist/cjs/lib/resources/CardsClient.js +352 -0
  11. package/dist/cjs/lib/resources/ExternalChannelsClient.js +78 -0
  12. package/dist/cjs/lib/resources/ModelCost.js +87 -0
  13. package/dist/cjs/lib/resources/ResourcesClient.js +78 -0
  14. package/dist/cjs/lib/resources/TeamMembersClient.js +102 -0
  15. package/dist/cjs/lib/resources/TeamsClient.js +96 -0
  16. package/dist/cjs/package.json +3 -0
  17. package/dist/cjs/test/helpers/mockFetch.js +27 -0
  18. package/dist/cjs/types/entities/a2a-dataparts.js +17 -0
  19. package/dist/cjs/types/entities/activities.js +72 -0
  20. package/dist/cjs/types/entities/agent.js +28 -0
  21. package/dist/cjs/types/entities/board.js +2 -0
  22. package/dist/cjs/types/entities/card.js +29 -0
  23. package/dist/cjs/types/entities/costs.js +2 -0
  24. package/dist/cjs/types/entities/external-channel.js +19 -0
  25. package/dist/cjs/types/entities/index.js +25 -0
  26. package/dist/cjs/types/entities/resource.js +10 -0
  27. package/dist/cjs/types/entities/shared.js +3 -0
  28. package/dist/cjs/types/entities/team.js +2 -0
  29. package/dist/cjs/types/entities.js +17 -0
  30. package/dist/cjs/types/responses.js +2 -0
  31. package/dist/esm/index.js +5 -0
  32. package/dist/{lib → esm/lib}/client.js +11 -9
  33. package/dist/{lib → esm/lib}/http/HttpClient.js +1 -1
  34. package/dist/{lib → esm/lib}/resources/AgentsClient.js +28 -0
  35. package/dist/{lib → esm/lib}/resources/BoardsClient.js +42 -0
  36. package/dist/{lib → esm/lib}/resources/CardsClient.js +1 -1
  37. package/dist/esm/lib/resources/TeamMembersClient.js +98 -0
  38. package/dist/{types → esm/types}/entities/activities.js +9 -13
  39. package/dist/esm/types/entities/index.js +9 -0
  40. package/dist/esm/types/entities.js +1 -0
  41. package/dist/esm/types/requests.js +19 -0
  42. package/dist/{lib → types/lib}/client.d.ts +3 -0
  43. package/dist/{lib → types/lib}/resources/AgentsClient.d.ts +26 -0
  44. package/dist/{lib → types/lib}/resources/BoardsClient.d.ts +34 -1
  45. package/dist/types/lib/resources/TeamMembersClient.d.ts +89 -0
  46. package/dist/types/{entities → types/entities}/activities.d.ts +14 -3
  47. package/dist/types/{entities → types/entities}/agent.d.ts +18 -10
  48. package/dist/types/{entities → types/entities}/board.d.ts +16 -5
  49. package/dist/types/{entities → types/entities}/card.d.ts +22 -13
  50. package/dist/types/{entities → types/entities}/external-channel.d.ts +1 -1
  51. package/dist/types/{entities → types/entities}/team.d.ts +4 -2
  52. package/package.json +18 -9
  53. package/dist/index.js +0 -5
  54. package/dist/types/entities/index.js +0 -9
  55. package/dist/types/entities.js +0 -1
  56. /package/dist/{types → cjs/types}/requests.js +0 -0
  57. /package/dist/{lib → esm/lib}/http/errors.js +0 -0
  58. /package/dist/{lib → esm/lib}/http/types.js +0 -0
  59. /package/dist/{lib → esm/lib}/resources/ActivitiesClient.js +0 -0
  60. /package/dist/{lib → esm/lib}/resources/ExternalChannelsClient.js +0 -0
  61. /package/dist/{lib → esm/lib}/resources/ModelCost.js +0 -0
  62. /package/dist/{lib → esm/lib}/resources/ResourcesClient.js +0 -0
  63. /package/dist/{lib → esm/lib}/resources/TeamsClient.js +0 -0
  64. /package/dist/{test → esm/test}/helpers/mockFetch.js +0 -0
  65. /package/dist/{types → esm/types}/entities/a2a-dataparts.js +0 -0
  66. /package/dist/{types → esm/types}/entities/agent.js +0 -0
  67. /package/dist/{types → esm/types}/entities/board.js +0 -0
  68. /package/dist/{types → esm/types}/entities/card.js +0 -0
  69. /package/dist/{types → esm/types}/entities/costs.js +0 -0
  70. /package/dist/{types → esm/types}/entities/external-channel.js +0 -0
  71. /package/dist/{types → esm/types}/entities/resource.js +0 -0
  72. /package/dist/{types → esm/types}/entities/shared.js +0 -0
  73. /package/dist/{types → esm/types}/entities/team.js +0 -0
  74. /package/dist/{types → esm/types}/responses.js +0 -0
  75. /package/dist/{index.d.ts → types/index.d.ts} +0 -0
  76. /package/dist/{lib → types/lib}/http/HttpClient.d.ts +0 -0
  77. /package/dist/{lib → types/lib}/http/errors.d.ts +0 -0
  78. /package/dist/{lib → types/lib}/http/types.d.ts +0 -0
  79. /package/dist/{lib → types/lib}/resources/ActivitiesClient.d.ts +0 -0
  80. /package/dist/{lib → types/lib}/resources/CardsClient.d.ts +0 -0
  81. /package/dist/{lib → types/lib}/resources/ExternalChannelsClient.d.ts +0 -0
  82. /package/dist/{lib → types/lib}/resources/ModelCost.d.ts +0 -0
  83. /package/dist/{lib → types/lib}/resources/ResourcesClient.d.ts +0 -0
  84. /package/dist/{lib → types/lib}/resources/TeamsClient.d.ts +0 -0
  85. /package/dist/{test → types/test}/helpers/mockFetch.d.ts +0 -0
  86. /package/dist/types/{entities → types/entities}/a2a-dataparts.d.ts +0 -0
  87. /package/dist/types/{entities → types/entities}/costs.d.ts +0 -0
  88. /package/dist/types/{entities → types/entities}/index.d.ts +0 -0
  89. /package/dist/types/{entities → types/entities}/resource.d.ts +0 -0
  90. /package/dist/types/{entities → types/entities}/shared.d.ts +0 -0
  91. /package/dist/types/{entities.d.ts → types/entities.d.ts} +0 -0
  92. /package/dist/types/{requests.d.ts → types/requests.d.ts} +0 -0
  93. /package/dist/types/{responses.d.ts → types/responses.d.ts} +0 -0
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServerError = exports.UnavailableError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.ValidationError = exports.BadRequestError = exports.ApiError = exports.AbortedError = exports.TimeoutError = exports.HttpError = void 0;
4
+ exports.mapHttpToSdkError = mapHttpToSdkError;
5
+ class HttpError extends Error {
6
+ constructor(message, status, url, body) {
7
+ super(message);
8
+ this.name = 'HttpError';
9
+ this.status = status;
10
+ this.url = url;
11
+ this.body = body;
12
+ }
13
+ }
14
+ exports.HttpError = HttpError;
15
+ class TimeoutError extends Error {
16
+ constructor(message = 'Request timed out') {
17
+ super(message);
18
+ this.name = 'TimeoutError';
19
+ }
20
+ }
21
+ exports.TimeoutError = TimeoutError;
22
+ class AbortedError extends Error {
23
+ constructor(message = 'Request was aborted') {
24
+ super(message);
25
+ this.name = 'AbortedError';
26
+ }
27
+ }
28
+ exports.AbortedError = AbortedError;
29
+ class ApiError extends Error {
30
+ constructor(shape) {
31
+ super(shape.message);
32
+ this.name = 'ApiError';
33
+ this.code = shape.code;
34
+ this.details = shape.details;
35
+ }
36
+ }
37
+ exports.ApiError = ApiError;
38
+ class BadRequestError extends ApiError {
39
+ constructor(shape) {
40
+ super(shape);
41
+ this.name = 'BadRequestError';
42
+ }
43
+ }
44
+ exports.BadRequestError = BadRequestError;
45
+ class ValidationError extends ApiError {
46
+ constructor(shape) {
47
+ super(shape);
48
+ this.name = 'ValidationError';
49
+ }
50
+ }
51
+ exports.ValidationError = ValidationError;
52
+ class UnauthorizedError extends ApiError {
53
+ constructor(shape) {
54
+ super(shape);
55
+ this.name = 'UnauthorizedError';
56
+ }
57
+ }
58
+ exports.UnauthorizedError = UnauthorizedError;
59
+ class ForbiddenError extends ApiError {
60
+ constructor(shape) {
61
+ super(shape);
62
+ this.name = 'ForbiddenError';
63
+ }
64
+ }
65
+ exports.ForbiddenError = ForbiddenError;
66
+ class NotFoundError extends ApiError {
67
+ constructor(shape) {
68
+ super(shape);
69
+ this.name = 'NotFoundError';
70
+ }
71
+ }
72
+ exports.NotFoundError = NotFoundError;
73
+ class ConflictError extends ApiError {
74
+ constructor(shape) {
75
+ super(shape);
76
+ this.name = 'ConflictError';
77
+ }
78
+ }
79
+ exports.ConflictError = ConflictError;
80
+ class RateLimitError extends ApiError {
81
+ constructor(shape) {
82
+ super(shape);
83
+ this.name = 'RateLimitError';
84
+ }
85
+ }
86
+ exports.RateLimitError = RateLimitError;
87
+ class UnavailableError extends ApiError {
88
+ constructor(shape) {
89
+ super(shape);
90
+ this.name = 'UnavailableError';
91
+ }
92
+ }
93
+ exports.UnavailableError = UnavailableError;
94
+ class ServerError extends ApiError {
95
+ constructor(shape) {
96
+ super(shape);
97
+ this.name = 'ServerError';
98
+ }
99
+ }
100
+ exports.ServerError = ServerError;
101
+ // Map HTTP response status and body to human-friendly SDK errors
102
+ function mapHttpToSdkError(status, body) {
103
+ const shape = normalizeBody(body);
104
+ switch (status) {
105
+ case 400:
106
+ return new BadRequestError(shape);
107
+ case 401:
108
+ return new UnauthorizedError(shape);
109
+ case 403:
110
+ return new ForbiddenError(shape);
111
+ case 404:
112
+ return new NotFoundError(shape);
113
+ case 409:
114
+ return new ConflictError(shape);
115
+ case 422:
116
+ return new ValidationError(shape);
117
+ case 429:
118
+ return new RateLimitError(shape);
119
+ case 502:
120
+ case 503:
121
+ case 504:
122
+ return new UnavailableError(shape);
123
+ case 500:
124
+ default:
125
+ return new ServerError(shape);
126
+ }
127
+ }
128
+ function normalizeBody(body) {
129
+ if (!body)
130
+ return { message: 'Unknown error' };
131
+ if (typeof body === 'string')
132
+ return { message: body };
133
+ if (typeof body === 'object') {
134
+ const anyBody = body;
135
+ const code = anyBody['code'] || anyBody['error'];
136
+ const message = anyBody['message'] ||
137
+ anyBody['error_description'] ||
138
+ 'Request failed';
139
+ const details = anyBody['details'];
140
+ return { code, message, details };
141
+ }
142
+ return { message: 'Request failed' };
143
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActivitiesClient = void 0;
4
+ // Reuse ActivityCreate from shared types
5
+ /**
6
+ * Client for managing card activities
7
+ * Activities track changes, comments, and events on cards
8
+ * @category Resources
9
+ */
10
+ class ActivitiesClient {
11
+ constructor(http) {
12
+ this.http = http;
13
+ }
14
+ /**
15
+ * List all activities with pagination, filters, and sorting
16
+ * Returns activities across all cards (use filters to narrow down)
17
+ *
18
+ * @param params - Optional query parameters for filtering and pagination
19
+ * @param params.limit - Number of items per page (default: 50, max: 100)
20
+ * @param params.after - Cursor to navigate forwards (get items after this cursor)
21
+ * @param params.before - Cursor to navigate backwards (get items before this cursor)
22
+ * @param params.order_by - Fields to sort by (prefix with - for descending order)
23
+ * @param params.filters - Filter parameters (e.g., { card_id: '123', type: 'comment' })
24
+ * @param options - Optional request configuration
25
+ *
26
+ * @returns A paginated list of activities
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * // Get activities with filters
31
+ * const result = await client.activities.list({
32
+ * limit: 20,
33
+ * order_by: '-created_at',
34
+ * filters: { card_id: 'card-123', type: 'comment' }
35
+ * });
36
+ * console.log(result.data); // Array of Activity objects
37
+ *
38
+ * // Get next page
39
+ * if (result.pagination.next_cursor) {
40
+ * const nextPage = await client.activities.list({
41
+ * limit: 20,
42
+ * after: result.pagination.next_cursor
43
+ * });
44
+ * }
45
+ * ```
46
+ */
47
+ list(params, options) {
48
+ return this.http.list(`/activities`, params, options);
49
+ }
50
+ /**
51
+ * Iterate through all activities using async generator
52
+ * Automatically handles pagination by following next_cursor
53
+ *
54
+ * @param params - Optional query parameters (excluding after/before cursors)
55
+ * @param params.limit - Number of items per page (used internally for pagination)
56
+ * @param params.order_by - Fields to sort by (prefix with - for descending)
57
+ * @param params.filters - Filter parameters to narrow results
58
+ * @param options - Optional request configuration
59
+ *
60
+ * @yields Individual Activity objects
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * // Process all activities
65
+ * for await (const activity of client.activities.listAll()) {
66
+ * console.log(activity.type, activity.description);
67
+ * }
68
+ *
69
+ * // With filters and custom page size
70
+ * for await (const activity of client.activities.listAll({
71
+ * limit: 100,
72
+ * order_by: '-created_at',
73
+ * filters: { card_id: 'card-123', type: 'comment' }
74
+ * })) {
75
+ * console.log(activity);
76
+ * }
77
+ * ```
78
+ */
79
+ async *listAll(params, options) {
80
+ let cursor = undefined;
81
+ do {
82
+ const page = await this.list({ ...(params || {}), after: cursor }, options);
83
+ for (const item of page.data)
84
+ yield item;
85
+ cursor = page.pagination.next_cursor;
86
+ } while (cursor);
87
+ }
88
+ /**
89
+ * Create a new activity
90
+ * Activities can track various events such as comments, status changes, or custom events
91
+ *
92
+ * @param data - Activity creation data
93
+ * @param data.card_id - The unique identifier of the card
94
+ * @param data.board_id - The board ID
95
+ * @param data.team_id - The team ID
96
+ * @param data.type - The type of activity (e.g., 'card_created', 'card_updated', 'comment')
97
+ * @param data.description - A description of the activity
98
+ * @param data.actor - The actor who performed the activity
99
+ * @param data.changes - Optional array of field changes
100
+ * @param data.metadata - Optional additional metadata
101
+ * @param options - Optional request configuration
102
+ *
103
+ * @returns The created activity object
104
+ *
105
+ * @throws {Error} If creation fails
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * const activity = await client.activities.create({
110
+ * card_id: 'card-123',
111
+ * board_id: 'board-456',
112
+ * team_id: 'team-789',
113
+ * type: 'comment',
114
+ * description: 'Added a comment',
115
+ * actor: {
116
+ * id: 'user-001',
117
+ * type: 'user',
118
+ * name: 'Jane Doe'
119
+ * }
120
+ * });
121
+ * ```
122
+ */
123
+ create(data, options) {
124
+ return this.http.post(`/activities:batch`, { items: [data] }, options);
125
+ }
126
+ /**
127
+ * Create multiple activities in a single batch request
128
+ * This is more efficient than creating activities one by one
129
+ *
130
+ * @param data - Array of activity creation data
131
+ * @param options - Optional request configuration
132
+ *
133
+ * @returns The batch creation result
134
+ *
135
+ * @throws {Error} If batch creation fails
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * const activities = await client.activities.createBatch([
140
+ * {
141
+ * card_id: 'card-123',
142
+ * board_id: 'board-456',
143
+ * team_id: 'team-789',
144
+ * type: 'comment',
145
+ * description: 'First comment',
146
+ * actor: { id: 'user-001', type: 'user', name: 'Jane Doe' }
147
+ * },
148
+ * {
149
+ * card_id: 'card-123',
150
+ * board_id: 'board-456',
151
+ * team_id: 'team-789',
152
+ * type: 'card_updated',
153
+ * description: 'Updated priority',
154
+ * actor: { id: 'user-001', type: 'user', name: 'Jane Doe' },
155
+ * changes: [{ field: 'priority', old_value: 'low', new_value: 'high' }]
156
+ * }
157
+ * ]);
158
+ * ```
159
+ */
160
+ createBatch(data, options) {
161
+ return this.http.post(`/activities:batch`, { items: data }, options);
162
+ }
163
+ }
164
+ exports.ActivitiesClient = ActivitiesClient;
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentsClient = void 0;
4
+ /**
5
+ * Client for managing agents in the Kaiban platform
6
+ * @category Resources
7
+ */
8
+ class AgentsClient {
9
+ constructor(http) {
10
+ this.http = http;
11
+ }
12
+ /**
13
+ * List agents with pagination, filters, and sorting
14
+ *
15
+ * @param params - Optional query parameters for filtering and pagination
16
+ * @param params.limit - Number of items per page (default: 50, max: 100)
17
+ * @param params.after - Cursor to navigate forwards (get items after this cursor)
18
+ * @param params.before - Cursor to navigate backwards (get items before this cursor)
19
+ * @param params.order_by - Fields to sort by (prefix with - for descending order)
20
+ * @param params.filters - Filter parameters to narrow results
21
+ * @param options - Optional request configuration
22
+ *
23
+ * @returns A paginated list of agents
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * // List first page of agents
28
+ * const result = await client.agents.list({ limit: 10 });
29
+ * console.log(result.data); // Array of Agent objects
30
+ * console.log(result.pagination.next_cursor); // Cursor for next page
31
+ *
32
+ * // Get next page using cursor
33
+ * if (result.pagination.next_cursor) {
34
+ * const nextPage = await client.agents.list({
35
+ * limit: 10,
36
+ * after: result.pagination.next_cursor
37
+ * });
38
+ * }
39
+ *
40
+ * // With filters and sorting
41
+ * const filtered = await client.agents.list({
42
+ * limit: 20,
43
+ * order_by: '-created_at',
44
+ * filters: { status: 'active' }
45
+ * });
46
+ * ```
47
+ */
48
+ list(params, options) {
49
+ return this.http.list('/agents', params, options);
50
+ }
51
+ /**
52
+ * Iterate through all agents using async generator
53
+ * Automatically handles pagination by following next_cursor
54
+ *
55
+ * @param params - Optional query parameters (excluding after/before cursors)
56
+ * @param params.limit - Number of items per page (used internally for pagination)
57
+ * @param params.order_by - Fields to sort by (prefix with - for descending order)
58
+ * @param params.filters - Filter parameters to narrow results
59
+ * @param options - Optional request configuration
60
+ *
61
+ * @yields Individual Agent objects
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * // Iterate through all agents
66
+ * for await (const agent of client.agents.listAll()) {
67
+ * console.log(agent.id, agent.name);
68
+ * }
69
+ *
70
+ * // With custom page size and sorting
71
+ * for await (const agent of client.agents.listAll({
72
+ * limit: 100,
73
+ * order_by: '-created_at',
74
+ * filters: { status: 'active' }
75
+ * })) {
76
+ * console.log(agent);
77
+ * }
78
+ * ```
79
+ */
80
+ async *listAll(params, options) {
81
+ let cursor = undefined;
82
+ do {
83
+ const page = await this.list({ ...(params || {}), after: cursor }, options);
84
+ for (const item of page.data)
85
+ yield item;
86
+ cursor = page.pagination.next_cursor;
87
+ } while (cursor);
88
+ }
89
+ /**
90
+ * Get a single agent by ID
91
+ *
92
+ * @param id - The unique identifier of the agent
93
+ * @param options - Optional request configuration
94
+ *
95
+ * @returns The agent object
96
+ *
97
+ * @throws {Error} If the agent is not found or request fails
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * const agent = await client.agents.get('agent-123');
102
+ * console.log(agent.name, agent.status);
103
+ * ```
104
+ */
105
+ get(id, options) {
106
+ return this.http.get(`/agent/${encodeURIComponent(id)}`, options);
107
+ }
108
+ /**
109
+ * Create a new agent
110
+ *
111
+ * @param data - Agent creation data
112
+ * @param options - Optional request configuration
113
+ *
114
+ * @returns The newly created agent object
115
+ *
116
+ * @throws {Error} If creation fails
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const agent = await client.agents.create({
121
+ * name: 'SupportAgent',
122
+ * description: 'Handles support tickets',
123
+ * team_id: 'team_123',
124
+ * owner_id: 'user_123',
125
+ * created_by: 'user_123',
126
+ * type: 'a2a',
127
+ * status: 'active',
128
+ * monthly_budget: 200,
129
+ * examples: []
130
+ * });
131
+ * ```
132
+ */
133
+ create(data, options) {
134
+ return this.http.post('/agents', data, options);
135
+ }
136
+ /**
137
+ * Update an agent's properties
138
+ *
139
+ * @param id - The unique identifier of the agent to update
140
+ * @param data - Partial agent data with fields to update
141
+ * @param options - Optional request configuration
142
+ *
143
+ * @returns The updated agent object
144
+ *
145
+ * @throws {Error} If the agent is not found or update fails
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const updatedAgent = await client.agents.update('agent-123', {
150
+ * name: 'New Name',
151
+ * status: 'active'
152
+ * });
153
+ * ```
154
+ */
155
+ update(id, data, options) {
156
+ return this.http.put(`/agent/${encodeURIComponent(id)}`, data, options);
157
+ }
158
+ /**
159
+ * Create feedback for an agent
160
+ *
161
+ * @param agentId - The unique identifier of the agent
162
+ * @param feedback - Feedback data to submit
163
+ * @param options - Optional request configuration
164
+ *
165
+ * @returns Promise that resolves when feedback is created
166
+ *
167
+ * @throws {Error} If the agent is not found or feedback creation fails
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * await client.agents.createFeedback('agent-123', {
172
+ * rating: 5,
173
+ * comment: 'Excellent performance',
174
+ * tags: ['helpful', 'accurate']
175
+ * });
176
+ * ```
177
+ */
178
+ createFeedback(agentId, feedback, options) {
179
+ return this.http.post(`/agent/${encodeURIComponent(agentId)}/feedback`, {
180
+ ...feedback,
181
+ agent_id: agentId,
182
+ }, options);
183
+ }
184
+ /**
185
+ * List supervisor feedback for a specific agent with pagination
186
+ *
187
+ * @param agentId - The unique identifier of the agent
188
+ * @param params - Optional query parameters for filtering and pagination
189
+ * @param params.limit - Number of items per page (default: 50, max: 100)
190
+ * @param params.after - Cursor to navigate forwards (get items after this cursor)
191
+ * @param params.before - Cursor to navigate backwards (get items before this cursor)
192
+ * @param params.order_by - Fields to sort by (prefix with - for descending order)
193
+ * @param options - Optional request configuration
194
+ *
195
+ * @returns A paginated list of supervisor feedback for the agent
196
+ *
197
+ * @throws {Error} If the agent is not found or request fails
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * // List supervisor feedback for an agent
202
+ * const result = await client.agents.listSupervisorFeedbacks('agent-123', {
203
+ * limit: 10,
204
+ * order_by: '-created_at'
205
+ * });
206
+ *
207
+ * for (const feedback of result.data) {
208
+ * console.log(feedback.rating, feedback.comment);
209
+ * }
210
+ *
211
+ * // Get next page if available
212
+ * if (result.pagination.next_cursor) {
213
+ * const nextPage = await client.agents.listSupervisorFeedbacks('agent-123', {
214
+ * limit: 10,
215
+ * after: result.pagination.next_cursor
216
+ * });
217
+ * }
218
+ * ```
219
+ */
220
+ listSupervisorFeedback(agentId, params, options) {
221
+ return this.http.list(`/supervisor-feedback/${encodeURIComponent(agentId)}`, params, options);
222
+ }
223
+ }
224
+ exports.AgentsClient = AgentsClient;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BoardsClient = void 0;
4
+ /**
5
+ * Client for managing boards in the Kaiban platform
6
+ * Boards organize cards into columns for workflow management
7
+ * @category Resources
8
+ */
9
+ class BoardsClient {
10
+ constructor(http) {
11
+ this.http = http;
12
+ }
13
+ /**
14
+ * List boards with pagination, filters, and sorting
15
+ *
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 boards
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const result = await client.boards.list({ limit: 10 });
27
+ * console.log(result.data);
28
+ * ```
29
+ */
30
+ list(params, options) {
31
+ return this.http.list('/boards', params, options);
32
+ }
33
+ /**
34
+ * Iterate through all boards using async generator
35
+ * Automatically handles pagination by following next_page_token
36
+ *
37
+ * @param params - Optional query parameters (excluding cursor)
38
+ * @param options - Optional request configuration
39
+ *
40
+ * @yields Individual Board objects
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * for await (const board of client.boards.listAll()) {
45
+ * console.log(board.id, board.name);
46
+ * }
47
+ * ```
48
+ */
49
+ async *listAll(params, options) {
50
+ let cursor = undefined;
51
+ do {
52
+ const page = await this.list({ ...(params || {}), after: cursor }, options);
53
+ for (const item of page.data)
54
+ yield item;
55
+ cursor = page.pagination.next_cursor;
56
+ } while (cursor);
57
+ }
58
+ /**
59
+ * Get a single board by ID
60
+ *
61
+ * @param id - The unique identifier of the board
62
+ * @param options - Optional request configuration
63
+ *
64
+ * @returns The board object
65
+ *
66
+ * @throws {Error} If the board is not found or request fails
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const board = await client.boards.get('board-123');
71
+ * console.log(board.name, board.columns);
72
+ * ```
73
+ */
74
+ get(id, options) {
75
+ return this.http.get(`/board/${encodeURIComponent(id)}`, options);
76
+ }
77
+ /**
78
+ * Create a new board
79
+ *
80
+ * @param data - Board creation data
81
+ * @param data.name - The board name
82
+ * @param data.team_id - The team this board belongs to
83
+ * @param data.owner_id - The owner of the board
84
+ * @param data.created_by - The user creating the board
85
+ * @param data.description - Board description
86
+ * @param data.agent_ids - Array of agent IDs
87
+ * @param data.member_ids - Array of member IDs
88
+ * @param data.allowed_roles - Array of allowed roles
89
+ * @param data.columns - Array of columns
90
+ * @param options - Optional request configuration
91
+ *
92
+ * @returns The newly created board
93
+ *
94
+ * @throws {Error} If creation fails
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const board = await client.boards.create({
99
+ * name: 'Sales',
100
+ * team_id: 'team_123',
101
+ * owner_id: 'user_123',
102
+ * created_by: 'user_123',
103
+ * description: 'Manage pipeline',
104
+ * columns: []
105
+ * // agent_ids, member_ids, and allowed_roles are optional (default to [])
106
+ * });
107
+ * ```
108
+ */
109
+ create(data, options) {
110
+ // Default empty arrays for optional fields
111
+ const payload = {
112
+ ...data,
113
+ agent_ids: data.agent_ids ?? [],
114
+ member_ids: data.member_ids ?? [],
115
+ allowed_roles: data.allowed_roles ?? [],
116
+ };
117
+ return this.http.post('/boards', payload, options);
118
+ }
119
+ }
120
+ exports.BoardsClient = BoardsClient;