@kaiban/sdk 0.1.1 → 0.1.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/README.md +376 -80
- package/dist/index.d.ts +6 -7
- package/dist/index.js +6 -7
- package/dist/lib/client.d.ts +5 -8
- package/dist/lib/client.js +5 -7
- package/dist/lib/http/HttpClient.js +5 -3
- package/dist/lib/resources/ActivitiesClient.d.ts +86 -27
- package/dist/lib/resources/ActivitiesClient.js +90 -29
- package/dist/lib/resources/AgentsClient.d.ts +68 -15
- package/dist/lib/resources/AgentsClient.js +75 -17
- package/dist/lib/resources/BoardsClient.d.ts +3 -3
- package/dist/lib/resources/BoardsClient.js +2 -2
- package/dist/lib/resources/CardsClient.d.ts +139 -12
- package/dist/lib/resources/CardsClient.js +171 -25
- package/dist/lib/resources/ExternalChannelsClient.d.ts +3 -3
- package/dist/lib/resources/ExternalChannelsClient.js +2 -2
- package/dist/lib/resources/ResourcesClient.d.ts +3 -30
- package/dist/lib/resources/ResourcesClient.js +2 -26
- package/dist/lib/resources/TeamsClient.d.ts +3 -3
- package/dist/lib/resources/TeamsClient.js +2 -2
- package/dist/types/a2a-data-parts.d.ts +2 -2
- package/dist/types/entities/activities.d.ts +56 -14
- package/dist/types/entities/activities.js +73 -1
- package/dist/types/entities/agent.d.ts +47 -5
- package/dist/types/entities/agent.js +25 -1
- package/dist/types/entities/card.d.ts +16 -26
- package/dist/types/entities/card.js +26 -1
- package/dist/types/entities/external-channel.d.ts +25 -5
- package/dist/types/entities/external-channel.js +16 -1
- package/dist/types/entities/index.d.ts +4 -5
- package/dist/types/entities/index.js +4 -5
- package/dist/types/entities/resource.d.ts +21 -12
- package/dist/types/entities/resource.js +7 -1
- package/dist/types/responses.d.ts +10 -10
- package/package.json +33 -6
- package/dist/lib/resources/BenchmarkExecutionsClient.d.ts +0 -250
- package/dist/lib/resources/BenchmarkExecutionsClient.js +0 -261
- package/dist/lib/resources/BenchmarksClient.d.ts +0 -159
- package/dist/lib/resources/BenchmarksClient.js +0 -158
- package/dist/lib/resources/SupervisorFeedbackClient.d.ts +0 -75
- package/dist/lib/resources/SupervisorFeedbackClient.js +0 -67
- package/dist/lib/resources/TeamMembersClient.d.ts +0 -66
- package/dist/lib/resources/TeamMembersClient.js +0 -75
- package/dist/lib/resources/__tests__/ActivitiesClient.test.d.ts +0 -1
- package/dist/lib/resources/__tests__/ActivitiesClient.test.js +0 -33
- package/dist/lib/resources/__tests__/AgentsClient.test.d.ts +0 -1
- package/dist/lib/resources/__tests__/AgentsClient.test.js +0 -37
- package/dist/lib/resources/__tests__/BenchmarkExecutionsClient.test.d.ts +0 -1
- package/dist/lib/resources/__tests__/BenchmarkExecutionsClient.test.js +0 -59
- package/dist/lib/resources/__tests__/BenchmarksClient.test.d.ts +0 -1
- package/dist/lib/resources/__tests__/BenchmarksClient.test.js +0 -42
- package/dist/lib/resources/__tests__/BoardsClient.test.d.ts +0 -1
- package/dist/lib/resources/__tests__/BoardsClient.test.js +0 -26
- package/dist/lib/resources/__tests__/CardsClient.test.d.ts +0 -1
- package/dist/lib/resources/__tests__/CardsClient.test.js +0 -62
- package/dist/lib/resources/__tests__/ExternalChannelsClient.test.d.ts +0 -1
- package/dist/lib/resources/__tests__/ExternalChannelsClient.test.js +0 -26
- package/dist/lib/resources/__tests__/ResourcesClient.test.d.ts +0 -1
- package/dist/lib/resources/__tests__/ResourcesClient.test.js +0 -28
- package/dist/lib/resources/__tests__/SupervisorFeedbackClient.test.d.ts +0 -1
- package/dist/lib/resources/__tests__/SupervisorFeedbackClient.test.js +0 -24
- package/dist/lib/resources/__tests__/TeamMembersClient.test.d.ts +0 -1
- package/dist/lib/resources/__tests__/TeamMembersClient.test.js +0 -26
- package/dist/lib/resources/__tests__/TeamsClient.test.d.ts +0 -1
- package/dist/lib/resources/__tests__/TeamsClient.test.js +0 -26
- package/dist/types/entities/benchmark.d.ts +0 -82
- package/dist/types/entities/benchmark.js +0 -1
package/README.md
CHANGED
|
@@ -5,20 +5,21 @@ Official TypeScript SDK for the Kaiban API.
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @kaiban
|
|
8
|
+
npm install @kaiban/sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Quickstart
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { createKaibanClient } from '@kaiban
|
|
14
|
+
import { createKaibanClient } from '@kaiban/sdk';
|
|
15
15
|
|
|
16
16
|
const client = createKaibanClient({
|
|
17
17
|
tenant: 'agi',
|
|
18
18
|
token: process.env.KAIBAN_TOKEN,
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const result = await client.agents.list({ limit: 10 });
|
|
22
|
+
console.log(result.data); // Array of agents
|
|
22
23
|
```
|
|
23
24
|
|
|
24
25
|
## Auth and tenancy
|
|
@@ -29,18 +30,132 @@ const agents = await client.agents.list();
|
|
|
29
30
|
|
|
30
31
|
## Resources
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
- teams
|
|
33
|
+
The SDK provides clients for the following API resources:
|
|
34
|
+
|
|
35
|
+
### Available Resource Clients
|
|
36
|
+
|
|
37
|
+
- **agents**: `list`, `listAll`, `get`, `update`, `createFeedback`, `listSupervisorFeedback`
|
|
38
|
+
- **cards**: `list`, `listAll`, `get`, `create`, `update`, `delete`, `moveToColumn`, `createActivity`, `createBatchActivities`, `listActivities`, `listAllActivities`
|
|
39
|
+
- **activities**: `list`, `listAll`, `create`, `createBatch`
|
|
40
|
+
- **teams**: `list`, `listAll`, `get`
|
|
41
|
+
- **boards**: `list`, `listAll`, `get`
|
|
42
|
+
- **resources**: `list`, `listAll`, `get`
|
|
43
|
+
- **external_channels**: `list`, `listAll`, `get`
|
|
44
|
+
|
|
45
|
+
### Pagination
|
|
46
|
+
|
|
47
|
+
All `list` methods return paginated results with cursor-based navigation:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { type Paginated, type Agent, type ListParams } from '@kaiban/sdk';
|
|
51
|
+
|
|
52
|
+
// Basic pagination
|
|
53
|
+
const params: ListParams = {
|
|
54
|
+
limit: 10,
|
|
55
|
+
order_by: '-created_at',
|
|
56
|
+
filters: { status: 'active' },
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const result: Paginated<Agent> = await client.agents.list(params);
|
|
60
|
+
console.log(result.data); // Array of Agent objects
|
|
61
|
+
console.log(result.pagination.next_cursor); // Cursor for next page
|
|
62
|
+
console.log(result.pagination.prev_cursor); // Cursor for previous page
|
|
63
|
+
|
|
64
|
+
// Navigate to next page
|
|
65
|
+
if (result.pagination.next_cursor) {
|
|
66
|
+
const nextPage = await client.agents.list({
|
|
67
|
+
limit: 10,
|
|
68
|
+
after: result.pagination.next_cursor,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Navigate backwards
|
|
73
|
+
if (result.pagination.prev_cursor) {
|
|
74
|
+
const prevPage = await client.agents.list({
|
|
75
|
+
limit: 10,
|
|
76
|
+
before: result.pagination.prev_cursor,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
All `listAll` methods return async generators that automatically handle pagination:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
// Iterate through all items automatically
|
|
85
|
+
for await (const agent of client.agents.listAll({ limit: 100 })) {
|
|
86
|
+
console.log(agent.id, agent.name);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
40
89
|
|
|
41
90
|
## Types
|
|
42
91
|
|
|
43
|
-
|
|
92
|
+
All types are published and re-exported from `@kaiban/sdk`. Available types include:
|
|
93
|
+
|
|
94
|
+
- **Entities**: `Agent`, `Card`, `Activity`, `Team`, `Board`, `Resource`, `ExternalChannel`
|
|
95
|
+
- **Request/Response**: `ActivityCreate`, `ListParams`, `Paginated`, `PaginationMeta`
|
|
96
|
+
- **Configuration**: `KaibanClientConfig`, `RequestOptions`
|
|
97
|
+
- **Actors & Changes**: `ActivityActor`, `ActivityChange`
|
|
98
|
+
- **Card Types**: `CardStatus`, `CardPart`
|
|
99
|
+
- **Enums/Constants**: `AgentType`, `AgentStatus`, `ActivityType`, `ResourceStatus`, `ExternalChannelType`, `ExternalChannelStatus`, `AgentFeedbackType`, `AgentFeedbackEvaluation`
|
|
100
|
+
- **Error classes**: `ApiError`, `NotFoundError`, `BadRequestError`, `UnauthorizedError`, `ForbiddenError`, `ConflictError`, `TooManyRequestsError`, `InternalServerError`, `TimeoutError`, `AbortedError`
|
|
101
|
+
|
|
102
|
+
### Example: Using Types
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import {
|
|
106
|
+
createKaibanClient,
|
|
107
|
+
type Agent,
|
|
108
|
+
type Card,
|
|
109
|
+
type Activity,
|
|
110
|
+
type ActivityCreate,
|
|
111
|
+
type Paginated,
|
|
112
|
+
type ListParams,
|
|
113
|
+
CardStatus,
|
|
114
|
+
ActivityType,
|
|
115
|
+
} from '@kaiban/sdk';
|
|
116
|
+
|
|
117
|
+
const client = createKaibanClient({
|
|
118
|
+
tenant: 'my-tenant',
|
|
119
|
+
token: process.env.KAIBAN_TOKEN!,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Type-safe card creation
|
|
123
|
+
// Use Omit<Card, 'id' | 'created_at'> for the input type
|
|
124
|
+
const cardData: Omit<Card, 'id' | 'created_at'> = {
|
|
125
|
+
team_id: 'team-123',
|
|
126
|
+
board_id: 'board-123',
|
|
127
|
+
owner_id: 'user-123',
|
|
128
|
+
agent_id: 'agent-123',
|
|
129
|
+
title: 'New task',
|
|
130
|
+
status: CardStatus.BACKLOG,
|
|
131
|
+
column_key: 'inbox',
|
|
132
|
+
priority: 'high',
|
|
133
|
+
member_ids: [],
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const card: Card = await client.cards.create(cardData);
|
|
137
|
+
|
|
138
|
+
// Type-safe card update
|
|
139
|
+
// Use Partial<Omit<Card, 'id' | 'created_at' | 'updated_at'>>
|
|
140
|
+
const updateData: Partial<Omit<Card, 'id' | 'created_at' | 'updated_at'>> = {
|
|
141
|
+
status: CardStatus.DOING,
|
|
142
|
+
priority: 'urgent',
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const updatedCard: Card = await client.cards.update(card.id, updateData);
|
|
146
|
+
|
|
147
|
+
// Type-safe activity creation
|
|
148
|
+
const activityData: ActivityCreate = {
|
|
149
|
+
board_id: card.board_id,
|
|
150
|
+
team_id: card.team_id,
|
|
151
|
+
card_id: card.id,
|
|
152
|
+
type: ActivityType.CARD_COMMENT_ADDED,
|
|
153
|
+
description: 'Initial comment',
|
|
154
|
+
actor: { id: 'user-1', type: 'user', name: 'John' },
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const activity: Activity = await client.activities.create(activityData);
|
|
158
|
+
```
|
|
44
159
|
|
|
45
160
|
## Documentation
|
|
46
161
|
|
|
@@ -84,142 +199,323 @@ npm run docs:clean
|
|
|
84
199
|
|
|
85
200
|
## Configuration
|
|
86
201
|
|
|
202
|
+
The client accepts the following configuration options:
|
|
203
|
+
|
|
87
204
|
```ts
|
|
88
|
-
createKaibanClient
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
205
|
+
import { createKaibanClient, type KaibanClientConfig } from '@kaiban/sdk';
|
|
206
|
+
|
|
207
|
+
const config: KaibanClientConfig = {
|
|
208
|
+
tenant: 'your-tenant', // Required: Your tenant identifier
|
|
209
|
+
token: 'your-api-token', // Required: Your API authentication token
|
|
210
|
+
baseUrl: 'https://custom-host', // Optional: Custom API base URL
|
|
211
|
+
timeoutMs: 30000, // Optional: Request timeout in milliseconds (default: 30000)
|
|
212
|
+
retry: {
|
|
213
|
+
// Optional: Retry configuration
|
|
214
|
+
maxAttempts: 3, // Maximum number of retry attempts (default: 3)
|
|
215
|
+
backoffMs: 1000, // Initial backoff delay (default: 1000)
|
|
216
|
+
maxBackoffMs: 30000, // Maximum backoff delay (default: 30000)
|
|
217
|
+
jitter: true, // Add randomness to backoff (default: true)
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const client = createKaibanClient(config);
|
|
94
222
|
```
|
|
95
223
|
|
|
96
224
|
## Per-call options
|
|
97
225
|
|
|
98
|
-
All resource methods accept optional per-call overrides:
|
|
226
|
+
All resource methods accept an optional `RequestOptions` parameter for per-call overrides:
|
|
99
227
|
|
|
100
228
|
```ts
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
timeoutMs: 10_000,
|
|
106
|
-
signal: new AbortController().signal,
|
|
107
|
-
|
|
229
|
+
import { type RequestOptions } from '@kaiban/sdk';
|
|
230
|
+
|
|
231
|
+
const options: RequestOptions = {
|
|
232
|
+
headers: { 'x-request-id': 'abc-123' }, // Custom headers
|
|
233
|
+
timeoutMs: 10_000, // Override timeout for this request
|
|
234
|
+
signal: new AbortController().signal, // AbortSignal for cancellation
|
|
235
|
+
retry: {
|
|
236
|
+
// Override retry behavior
|
|
237
|
+
maxAttempts: 5,
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
await client.cards.list({ limit: 20 }, options);
|
|
242
|
+
await client.agents.get('agent-123', options);
|
|
108
243
|
```
|
|
109
244
|
|
|
110
245
|
## Error handling
|
|
111
246
|
|
|
247
|
+
The SDK provides typed error classes for different HTTP status codes:
|
|
248
|
+
|
|
112
249
|
```ts
|
|
113
|
-
import { createKaibanClient,
|
|
250
|
+
import { createKaibanClient, ApiError, NotFoundError, BadRequestError } from '@kaiban/sdk';
|
|
114
251
|
|
|
115
252
|
try {
|
|
116
|
-
await client.cards.get(
|
|
253
|
+
await client.cards.get('non-existent-id');
|
|
117
254
|
} catch (err) {
|
|
118
|
-
if (err instanceof
|
|
119
|
-
console.error('
|
|
255
|
+
if (err instanceof NotFoundError) {
|
|
256
|
+
console.error('Card not found:', err.message);
|
|
257
|
+
} else if (err instanceof BadRequestError) {
|
|
258
|
+
console.error('Invalid request:', err.message);
|
|
259
|
+
} else if (err instanceof ApiError) {
|
|
260
|
+
console.error('API error:', err.status, err.message);
|
|
120
261
|
} else {
|
|
121
|
-
console.error('Unexpected error', err);
|
|
262
|
+
console.error('Unexpected error:', err);
|
|
122
263
|
}
|
|
123
264
|
}
|
|
124
265
|
```
|
|
125
266
|
|
|
267
|
+
Available error classes: `ApiError`, `BadRequestError`, `UnauthorizedError`, `ForbiddenError`, `NotFoundError`, `ConflictError`, `TooManyRequestsError`, `InternalServerError`, `TimeoutError`, `AbortedError`.
|
|
268
|
+
|
|
126
269
|
## Examples by resource
|
|
127
270
|
|
|
128
271
|
### Agents
|
|
129
272
|
|
|
130
273
|
```ts
|
|
131
|
-
// List agents
|
|
132
|
-
const
|
|
274
|
+
// List agents with pagination
|
|
275
|
+
const result = await client.agents.list({
|
|
276
|
+
limit: 20,
|
|
277
|
+
order_by: '-created_at',
|
|
278
|
+
});
|
|
279
|
+
console.log(result.data); // Array of agents
|
|
280
|
+
console.log(result.pagination.next_cursor);
|
|
281
|
+
|
|
282
|
+
// Iterate through all agents
|
|
283
|
+
for await (const agent of client.agents.listAll({ limit: 100 })) {
|
|
284
|
+
console.log(agent.id, agent.name);
|
|
285
|
+
}
|
|
133
286
|
|
|
134
287
|
// Get agent by id
|
|
135
|
-
const agent = await client.agents.get(
|
|
288
|
+
const agent = await client.agents.get('agent-123');
|
|
136
289
|
|
|
137
290
|
// Update agent
|
|
138
|
-
const updated = await client.agents.update(
|
|
291
|
+
const updated = await client.agents.update('agent-123', {
|
|
292
|
+
name: 'Updated Name',
|
|
293
|
+
description: 'New description',
|
|
294
|
+
});
|
|
139
295
|
|
|
140
296
|
// Create agent feedback
|
|
141
|
-
await client.agents.createFeedback(
|
|
297
|
+
await client.agents.createFeedback('agent-123', {
|
|
298
|
+
team_id: 'team-123',
|
|
299
|
+
activity_id: 'activity-456',
|
|
300
|
+
status: 'unprocessed',
|
|
301
|
+
type: 'user_conversation_feedback',
|
|
302
|
+
evaluation: 'positive',
|
|
303
|
+
comment: 'Excellent performance',
|
|
304
|
+
created_by: 'user-001',
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
// List supervisor feedback for an agent
|
|
308
|
+
const feedback = await client.agents.listSupervisorFeedback('agent-123', {
|
|
309
|
+
limit: 10,
|
|
310
|
+
order_by: '-created_at',
|
|
311
|
+
});
|
|
142
312
|
```
|
|
143
313
|
|
|
144
314
|
### Teams
|
|
145
315
|
|
|
146
316
|
```ts
|
|
147
|
-
|
|
148
|
-
const
|
|
317
|
+
// List teams with pagination
|
|
318
|
+
const result = await client.teams.list({
|
|
319
|
+
limit: 20,
|
|
320
|
+
filters: { status: 'active' },
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
// Iterate through all teams
|
|
324
|
+
for await (const team of client.teams.listAll()) {
|
|
325
|
+
console.log(team.id, team.name);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// Get a specific team
|
|
329
|
+
const team = await client.teams.get('team-123');
|
|
149
330
|
```
|
|
150
331
|
|
|
151
332
|
### Boards
|
|
152
333
|
|
|
153
334
|
```ts
|
|
154
|
-
|
|
155
|
-
const
|
|
335
|
+
// List boards
|
|
336
|
+
const result = await client.boards.list({ limit: 10 });
|
|
337
|
+
|
|
338
|
+
// Iterate through all boards
|
|
339
|
+
for await (const board of client.boards.listAll()) {
|
|
340
|
+
console.log(board.id, board.name, board.columns);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Get a specific board
|
|
344
|
+
const board = await client.boards.get('board-123');
|
|
156
345
|
```
|
|
157
346
|
|
|
158
347
|
### Cards
|
|
159
348
|
|
|
160
349
|
```ts
|
|
161
|
-
import
|
|
162
|
-
|
|
163
|
-
//
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
board_id: '
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
350
|
+
import { CardStatus, ActivityType } from '@kaiban/sdk';
|
|
351
|
+
|
|
352
|
+
// List cards with pagination and filters
|
|
353
|
+
const result = await client.cards.list({
|
|
354
|
+
limit: 20,
|
|
355
|
+
filters: { status: 'doing', board_id: 'board-123' },
|
|
356
|
+
order_by: '-created_at',
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
// Iterate through all cards
|
|
360
|
+
for await (const card of client.cards.listAll({ limit: 100 })) {
|
|
361
|
+
console.log(card.id, card.title);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Create a card with optional activity tracking
|
|
365
|
+
const newCard = await client.cards.create(
|
|
366
|
+
{
|
|
367
|
+
team_id: 'team-123',
|
|
368
|
+
board_id: 'board-123',
|
|
369
|
+
owner_id: 'user-123',
|
|
370
|
+
agent_id: 'agent-123',
|
|
371
|
+
title: 'Investigate issue',
|
|
372
|
+
status: CardStatus.BACKLOG,
|
|
373
|
+
column_key: 'inbox',
|
|
374
|
+
priority: 'medium',
|
|
375
|
+
member_ids: [],
|
|
376
|
+
},
|
|
377
|
+
{ create_activity: true } // Automatically creates a 'card_created' activity
|
|
378
|
+
);
|
|
176
379
|
|
|
177
380
|
// Get a card
|
|
178
|
-
const card = await client.cards.get(
|
|
381
|
+
const card = await client.cards.get(newCard.id);
|
|
179
382
|
|
|
180
383
|
// Update a card
|
|
181
|
-
const
|
|
182
|
-
|
|
384
|
+
const updatedCard = await client.cards.update(card.id, {
|
|
385
|
+
status: CardStatus.DOING,
|
|
386
|
+
priority: 'high',
|
|
387
|
+
});
|
|
183
388
|
|
|
184
|
-
//
|
|
185
|
-
const
|
|
389
|
+
// Move card to a different column (with automatic activity tracking)
|
|
390
|
+
const movedCard = await client.cards.moveToColumn(card.id, 'in_progress', {
|
|
391
|
+
actor: {
|
|
392
|
+
id: 'user-123',
|
|
393
|
+
type: 'user',
|
|
394
|
+
name: 'John Doe',
|
|
395
|
+
},
|
|
396
|
+
});
|
|
186
397
|
|
|
187
398
|
// Delete a card
|
|
188
|
-
await client.cards.delete(
|
|
399
|
+
await client.cards.delete(card.id);
|
|
400
|
+
|
|
401
|
+
// Create an activity for a card
|
|
402
|
+
await client.cards.createActivity(card.id, {
|
|
403
|
+
board_id: card.board_id,
|
|
404
|
+
team_id: card.team_id,
|
|
405
|
+
type: ActivityType.CARD_COMMENT_ADDED,
|
|
406
|
+
description: 'Added a comment',
|
|
407
|
+
actor: { id: 'user-1', type: 'user', name: 'Alice' },
|
|
408
|
+
});
|
|
189
409
|
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
card_id: card.id,
|
|
194
|
-
body: {
|
|
410
|
+
// Create multiple activities in batch
|
|
411
|
+
await client.cards.createBatchActivities(card.id, [
|
|
412
|
+
{
|
|
195
413
|
board_id: card.board_id,
|
|
196
414
|
team_id: card.team_id,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
actor: { id: 'user_1', type: 'user', name: 'Alice' },
|
|
415
|
+
type: ActivityType.CARD_COMMENT_ADDED,
|
|
416
|
+
description: 'First comment',
|
|
417
|
+
actor: { id: 'user-1', type: 'user', name: 'Alice' },
|
|
201
418
|
},
|
|
419
|
+
{
|
|
420
|
+
board_id: card.board_id,
|
|
421
|
+
team_id: card.team_id,
|
|
422
|
+
type: ActivityType.CARD_PRIORITY_CHANGED,
|
|
423
|
+
description: 'Changed priority',
|
|
424
|
+
actor: { id: 'user-1', type: 'user', name: 'Alice' },
|
|
425
|
+
changes: [{ field: 'priority', old_value: 'medium', new_value: 'high' }],
|
|
426
|
+
},
|
|
427
|
+
]);
|
|
428
|
+
|
|
429
|
+
// List activities for a card
|
|
430
|
+
const activities = await client.cards.listActivities(card.id, {
|
|
431
|
+
limit: 50,
|
|
432
|
+
order_by: '-created_at',
|
|
202
433
|
});
|
|
203
|
-
|
|
434
|
+
|
|
435
|
+
// Iterate through all activities for a card
|
|
436
|
+
for await (const activity of client.cards.listAllActivities(card.id, { limit: 100 })) {
|
|
437
|
+
console.log(activity.type, activity.description);
|
|
438
|
+
}
|
|
204
439
|
```
|
|
205
440
|
|
|
206
|
-
###
|
|
441
|
+
### Activities
|
|
207
442
|
|
|
208
443
|
```ts
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
444
|
+
import { ActivityType, type ActivityCreate } from '@kaiban/sdk';
|
|
445
|
+
|
|
446
|
+
// List all activities with filters
|
|
447
|
+
const result = await client.activities.list({
|
|
448
|
+
limit: 50,
|
|
449
|
+
filters: { card_id: 'card-123' },
|
|
450
|
+
order_by: '-created_at',
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
// Iterate through all activities
|
|
454
|
+
for await (const activity of client.activities.listAll({ limit: 100 })) {
|
|
455
|
+
console.log(activity.id, activity.type);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// Create a single activity
|
|
459
|
+
await client.activities.create({
|
|
460
|
+
board_id: 'board-123',
|
|
461
|
+
team_id: 'team-123',
|
|
462
|
+
card_id: 'card-123',
|
|
463
|
+
type: ActivityType.CARD_PRIORITY_CHANGED,
|
|
464
|
+
description: 'Updated priority',
|
|
465
|
+
actor: { id: 'user-1', type: 'user', name: 'Alice' },
|
|
466
|
+
changes: [{ field: 'priority', old_value: 'low', new_value: 'high' }],
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
// Create multiple activities in batch
|
|
470
|
+
await client.activities.createBatch([
|
|
471
|
+
{
|
|
472
|
+
board_id: 'board-123',
|
|
473
|
+
team_id: 'team-123',
|
|
474
|
+
card_id: 'card-123',
|
|
475
|
+
type: ActivityType.CARD_COMMENT_ADDED,
|
|
476
|
+
description: 'First comment',
|
|
477
|
+
actor: { id: 'user-1', type: 'user', name: 'Alice' },
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
board_id: 'board-123',
|
|
481
|
+
team_id: 'team-123',
|
|
482
|
+
card_id: 'card-123',
|
|
483
|
+
type: ActivityType.CARD_COMMENT_ADDED,
|
|
484
|
+
description: 'Second comment',
|
|
485
|
+
actor: { id: 'user-2', type: 'user', name: 'Bob' },
|
|
486
|
+
},
|
|
487
|
+
]);
|
|
212
488
|
```
|
|
213
489
|
|
|
214
|
-
###
|
|
490
|
+
### Resources
|
|
215
491
|
|
|
216
492
|
```ts
|
|
217
|
-
|
|
218
|
-
const
|
|
493
|
+
// List resources
|
|
494
|
+
const result = await client.resources.list({
|
|
495
|
+
limit: 25,
|
|
496
|
+
order_by: '-created_at',
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
// Iterate through all resources
|
|
500
|
+
for await (const resource of client.resources.listAll()) {
|
|
501
|
+
console.log(resource.id, resource.title, resource.status);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// Get a specific resource
|
|
505
|
+
const resource = await client.resources.get('resource-123');
|
|
219
506
|
```
|
|
220
507
|
|
|
221
|
-
###
|
|
508
|
+
### External Channels
|
|
222
509
|
|
|
223
510
|
```ts
|
|
224
|
-
|
|
511
|
+
// List external channels
|
|
512
|
+
const result = await client.external_channels.list({ limit: 15 });
|
|
513
|
+
|
|
514
|
+
// Iterate through all channels
|
|
515
|
+
for await (const channel of client.external_channels.listAll()) {
|
|
516
|
+
console.log(channel.id, channel.type, channel.name);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Get a specific channel
|
|
520
|
+
const channel = await client.external_channels.get('channel-123');
|
|
225
521
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
export * from './lib/client';
|
|
2
2
|
export * from './lib/http/errors';
|
|
3
|
-
export * from './lib/
|
|
4
|
-
export * from './lib/resources/CardsClient';
|
|
3
|
+
export * from './lib/http/types';
|
|
5
4
|
export * from './lib/resources/ActivitiesClient';
|
|
6
|
-
export * from './lib/resources/
|
|
5
|
+
export * from './lib/resources/AgentsClient';
|
|
7
6
|
export * from './lib/resources/BoardsClient';
|
|
8
|
-
export * from './lib/resources/
|
|
7
|
+
export * from './lib/resources/CardsClient';
|
|
9
8
|
export * from './lib/resources/ExternalChannelsClient';
|
|
10
|
-
export * from './lib/resources/
|
|
11
|
-
export * from './lib/
|
|
9
|
+
export * from './lib/resources/ResourcesClient';
|
|
10
|
+
export * from './lib/resources/TeamsClient';
|
|
11
|
+
export * from './types/a2a-data-parts';
|
|
12
12
|
export * from './types/entities';
|
|
13
13
|
export * from './types/requests';
|
|
14
14
|
export * from './types/responses';
|
|
15
|
-
export * from './types/a2a-data-parts';
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
export * from './lib/client';
|
|
2
2
|
export * from './lib/http/errors';
|
|
3
|
-
export * from './lib/
|
|
4
|
-
export * from './lib/resources/CardsClient';
|
|
3
|
+
export * from './lib/http/types';
|
|
5
4
|
export * from './lib/resources/ActivitiesClient';
|
|
6
|
-
export * from './lib/resources/
|
|
5
|
+
export * from './lib/resources/AgentsClient';
|
|
7
6
|
export * from './lib/resources/BoardsClient';
|
|
8
|
-
export * from './lib/resources/
|
|
7
|
+
export * from './lib/resources/CardsClient';
|
|
9
8
|
export * from './lib/resources/ExternalChannelsClient';
|
|
10
|
-
export * from './lib/resources/
|
|
11
|
-
export * from './lib/
|
|
9
|
+
export * from './lib/resources/ResourcesClient';
|
|
10
|
+
export * from './lib/resources/TeamsClient';
|
|
11
|
+
export * from './types/a2a-data-parts';
|
|
12
12
|
export * from './types/entities';
|
|
13
13
|
export * from './types/requests';
|
|
14
14
|
export * from './types/responses';
|
|
15
|
-
export * from './types/a2a-data-parts';
|
package/dist/lib/client.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { KaibanClientConfig } from './http/types';
|
|
2
|
+
import { ActivitiesClient } from './resources/ActivitiesClient';
|
|
2
3
|
import { AgentsClient } from './resources/AgentsClient';
|
|
3
|
-
import { CardsClient } from './resources/CardsClient';
|
|
4
|
-
import { TeamsClient } from './resources/TeamsClient';
|
|
5
4
|
import { BoardsClient } from './resources/BoardsClient';
|
|
6
|
-
import {
|
|
5
|
+
import { CardsClient } from './resources/CardsClient';
|
|
7
6
|
import { ExternalChannelsClient } from './resources/ExternalChannelsClient';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { ResourcesClient } from './resources/ResourcesClient';
|
|
8
|
+
import { TeamsClient } from './resources/TeamsClient';
|
|
10
9
|
/**
|
|
11
10
|
* Main Kaiban SDK client interface providing access to all API resources
|
|
12
11
|
* @category Client
|
|
@@ -30,9 +29,7 @@ export interface KaibanClient {
|
|
|
30
29
|
/** Client for managing resources */
|
|
31
30
|
resources: ResourcesClient;
|
|
32
31
|
/** Client for managing external channels */
|
|
33
|
-
|
|
34
|
-
/** Client for managing supervisor feedback */
|
|
35
|
-
supervisorFeedback: SupervisorFeedbackClient;
|
|
32
|
+
external_channels: ExternalChannelsClient;
|
|
36
33
|
}
|
|
37
34
|
/**
|
|
38
35
|
* Create a Kaiban SDK client instance
|
package/dist/lib/client.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { HttpClient } from './http/HttpClient';
|
|
2
|
+
import { ActivitiesClient } from './resources/ActivitiesClient';
|
|
2
3
|
import { AgentsClient } from './resources/AgentsClient';
|
|
3
|
-
import { CardsClient } from './resources/CardsClient';
|
|
4
|
-
import { TeamsClient } from './resources/TeamsClient';
|
|
5
4
|
import { BoardsClient } from './resources/BoardsClient';
|
|
6
|
-
import {
|
|
5
|
+
import { CardsClient } from './resources/CardsClient';
|
|
7
6
|
import { ExternalChannelsClient } from './resources/ExternalChannelsClient';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { ResourcesClient } from './resources/ResourcesClient';
|
|
8
|
+
import { TeamsClient } from './resources/TeamsClient';
|
|
10
9
|
/**
|
|
11
10
|
* Create a Kaiban SDK client instance
|
|
12
11
|
*
|
|
@@ -45,7 +44,6 @@ export function createKaibanClient(config) {
|
|
|
45
44
|
teams: new TeamsClient(http),
|
|
46
45
|
boards: new BoardsClient(http),
|
|
47
46
|
resources: new ResourcesClient(http),
|
|
48
|
-
|
|
49
|
-
supervisorFeedback: new SupervisorFeedbackClient(http),
|
|
47
|
+
external_channels: new ExternalChannelsClient(http),
|
|
50
48
|
};
|
|
51
49
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbortedError, RateLimitError, ServerError, TimeoutError, UnavailableError, mapHttpToSdkError, } from './errors';
|
|
2
2
|
function buildQuery(query) {
|
|
3
3
|
if (!query)
|
|
4
4
|
return '';
|
|
@@ -194,10 +194,12 @@ export class HttpClient {
|
|
|
194
194
|
const queryParams = {};
|
|
195
195
|
if (listParams) {
|
|
196
196
|
// Handle pagination
|
|
197
|
-
if (listParams.cursor)
|
|
198
|
-
queryParams.cursor = listParams.cursor;
|
|
199
197
|
if (listParams.limit)
|
|
200
198
|
queryParams.limit = listParams.limit;
|
|
199
|
+
if (listParams.before)
|
|
200
|
+
queryParams.before = listParams.before;
|
|
201
|
+
if (listParams.after)
|
|
202
|
+
queryParams.after = listParams.after;
|
|
201
203
|
// Handle sorting (already a string)
|
|
202
204
|
if (listParams.order_by)
|
|
203
205
|
queryParams.order_by = listParams.order_by;
|