@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,158 @@
1
+ /**
2
+ * Client for managing benchmarks in the Kaiban platform
3
+ * Benchmarks are used to evaluate and test agent performance
4
+ * @category Resources
5
+ */
6
+ export class BenchmarksClient {
7
+ constructor(http) {
8
+ this.http = http;
9
+ }
10
+ /**
11
+ * List benchmarks with pagination, filters, and sorting
12
+ *
13
+ * @param params - Optional query parameters for filtering and pagination
14
+ * @param params.cursor - Cursor for the next page of results
15
+ * @param params.limit - Number of items per page
16
+ * @param params.order_by - Fields to sort by
17
+ * @param options - Optional request configuration
18
+ *
19
+ * @returns A paginated list of benchmarks
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const result = await client.benchmarks.list({ limit: 10 });
24
+ * console.log(result.items);
25
+ * ```
26
+ */
27
+ list(params, options) {
28
+ return this.http.list('/benchmarks', params, options);
29
+ }
30
+ /**
31
+ * Iterate through all benchmarks using async generator
32
+ * Automatically handles pagination by following next_page_token
33
+ *
34
+ * @param params - Optional query parameters (excluding cursor)
35
+ * @param options - Optional request configuration
36
+ *
37
+ * @yields Individual Benchmark objects
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * for await (const benchmark of client.benchmarks.listAll()) {
42
+ * console.log(benchmark.id, benchmark.name);
43
+ * }
44
+ * ```
45
+ */
46
+ async *listAll(params, options) {
47
+ let pageToken = undefined;
48
+ do {
49
+ const page = await this.list({ ...(params || {}), cursor: pageToken }, options);
50
+ for (const item of page.items)
51
+ yield item;
52
+ pageToken = page.next_page_token;
53
+ } while (pageToken);
54
+ }
55
+ /**
56
+ * Get a single benchmark by ID
57
+ *
58
+ * @param id - The unique identifier of the benchmark
59
+ * @param options - Optional request configuration
60
+ *
61
+ * @returns The benchmark object
62
+ *
63
+ * @throws {Error} If the benchmark is not found or request fails
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const benchmark = await client.benchmarks.get('benchmark-123');
68
+ * console.log(benchmark.name, benchmark.description);
69
+ * ```
70
+ */
71
+ get(id, options) {
72
+ return this.http.get(`/benchmark/${encodeURIComponent(id)}`, options);
73
+ }
74
+ /**
75
+ * Create a new benchmark
76
+ *
77
+ * @param data - Benchmark creation data
78
+ * @param data.name - The benchmark name
79
+ * @param data.description - Optional description
80
+ * @param options - Optional request configuration
81
+ *
82
+ * @returns The newly created benchmark
83
+ *
84
+ * @throws {Error} If creation fails
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const benchmark = await client.benchmarks.create({
89
+ * name: 'Performance Test Suite',
90
+ * description: 'Test agent response times',
91
+ * test_cases: [...]
92
+ * });
93
+ * ```
94
+ */
95
+ create(data, options) {
96
+ return this.http.post('/benchmarks', data, options);
97
+ }
98
+ /**
99
+ * Update a benchmark's properties
100
+ *
101
+ * @param id - The unique identifier of the benchmark to update
102
+ * @param data - Benchmark data with fields to update
103
+ * @param options - Optional request configuration
104
+ *
105
+ * @returns The updated benchmark object
106
+ *
107
+ * @throws {Error} If the benchmark is not found or update fails
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * const updated = await client.benchmarks.update('benchmark-123', {
112
+ * name: 'Updated Benchmark Name'
113
+ * });
114
+ * ```
115
+ */
116
+ update(id, data, options) {
117
+ return this.http.put(`/benchmark/${encodeURIComponent(id)}`, data, options);
118
+ }
119
+ /**
120
+ * Execute a benchmark against an agent
121
+ * Runs the benchmark test suite with specified configuration
122
+ *
123
+ * @param params - Execution parameters
124
+ * @param params.benchmark_id - The unique identifier of the benchmark to execute
125
+ * @param params.body - Execution configuration
126
+ * @param params.body.agentConfig - Agent configuration including ID, name, and card URL
127
+ * @param params.body.thresholds - Optional performance thresholds
128
+ * @param params.body.maxTests - Optional maximum number of tests to run
129
+ * @param params.body.parallel - Optional flag to run tests in parallel
130
+ * @param params.body.batchSize - Optional batch size for parallel execution
131
+ * @param options - Optional request configuration
132
+ *
133
+ * @returns A response with execution status message
134
+ *
135
+ * @throws {Error} If the benchmark is not found or execution fails
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * const result = await client.benchmarks.execute({
140
+ * benchmark_id: 'benchmark-123',
141
+ * body: {
142
+ * agentConfig: {
143
+ * id: 'agent-456',
144
+ * name: 'Test Agent',
145
+ * cardUrl: 'https://example.com/agent-card'
146
+ * },
147
+ * maxTests: 100,
148
+ * parallel: true,
149
+ * batchSize: 10
150
+ * }
151
+ * });
152
+ * console.log(result.message);
153
+ * ```
154
+ */
155
+ execute(params, options) {
156
+ return this.http.post(`/benchmark/${encodeURIComponent(params.benchmark_id)}/execute`, params.body, options);
157
+ }
158
+ }
@@ -0,0 +1,65 @@
1
+ import { HttpClient } from '../http/HttpClient';
2
+ import { RequestOptions } from '../http/types';
3
+ import { Board } from '../../types/entities';
4
+ import { ListParams, Paginated } from '../../types/responses';
5
+ /**
6
+ * Client for managing boards in the Kaiban platform
7
+ * Boards organize cards into columns for workflow management
8
+ * @category Resources
9
+ */
10
+ export declare class BoardsClient {
11
+ private readonly http;
12
+ constructor(http: HttpClient);
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?: ListParams, options?: RequestOptions): Promise<Paginated<Board>>;
31
+ /**
32
+ * Iterate through all boards using async generator
33
+ * Automatically handles pagination by following next_page_token
34
+ *
35
+ * @param params - Optional query parameters (excluding cursor)
36
+ * @param options - Optional request configuration
37
+ *
38
+ * @yields Individual Board objects
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * for await (const board of client.boards.listAll()) {
43
+ * console.log(board.id, board.name);
44
+ * }
45
+ * ```
46
+ */
47
+ listAll(params?: Omit<ListParams, 'cursor'>, options?: RequestOptions): AsyncGenerator<Board, void, unknown>;
48
+ /**
49
+ * Get a single board by ID
50
+ *
51
+ * @param id - The unique identifier of the board
52
+ * @param options - Optional request configuration
53
+ *
54
+ * @returns The board object
55
+ *
56
+ * @throws {Error} If the board is not found or request fails
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const board = await client.boards.get('board-123');
61
+ * console.log(board.name, board.columns);
62
+ * ```
63
+ */
64
+ get(id: string, options?: RequestOptions): Promise<Board>;
65
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Client for managing boards in the Kaiban platform
3
+ * Boards organize cards into columns for workflow management
4
+ * @category Resources
5
+ */
6
+ export class BoardsClient {
7
+ constructor(http) {
8
+ this.http = http;
9
+ }
10
+ /**
11
+ * List boards with pagination, filters, and sorting
12
+ *
13
+ * @param params - Optional query parameters for filtering and pagination
14
+ * @param params.cursor - Cursor for the next page of results
15
+ * @param params.limit - Number of items per page
16
+ * @param params.order_by - Fields to sort by
17
+ * @param options - Optional request configuration
18
+ *
19
+ * @returns A paginated list of boards
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const result = await client.boards.list({ limit: 10 });
24
+ * console.log(result.data);
25
+ * ```
26
+ */
27
+ list(params, options) {
28
+ return this.http.list('/boards', params, options);
29
+ }
30
+ /**
31
+ * Iterate through all boards using async generator
32
+ * Automatically handles pagination by following next_page_token
33
+ *
34
+ * @param params - Optional query parameters (excluding cursor)
35
+ * @param options - Optional request configuration
36
+ *
37
+ * @yields Individual Board objects
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * for await (const board of client.boards.listAll()) {
42
+ * console.log(board.id, board.name);
43
+ * }
44
+ * ```
45
+ */
46
+ async *listAll(params, options) {
47
+ let cursor = undefined;
48
+ do {
49
+ const page = await this.list({ ...(params || {}), cursor: cursor }, options);
50
+ for (const item of page.data)
51
+ yield item;
52
+ cursor = page.meta.next_cursor;
53
+ } while (cursor);
54
+ }
55
+ /**
56
+ * Get a single board by ID
57
+ *
58
+ * @param id - The unique identifier of the board
59
+ * @param options - Optional request configuration
60
+ *
61
+ * @returns The board object
62
+ *
63
+ * @throws {Error} If the board is not found or request fails
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const board = await client.boards.get('board-123');
68
+ * console.log(board.name, board.columns);
69
+ * ```
70
+ */
71
+ get(id, options) {
72
+ return this.http.get(`/board/${encodeURIComponent(id)}`, options);
73
+ }
74
+ }
@@ -0,0 +1,161 @@
1
+ import { HttpClient } from '../http/HttpClient';
2
+ import { RequestOptions } from '../http/types';
3
+ import { Card, CreateCardInput, UpdateCardInput, ActivityActor } from '../../types/entities';
4
+ import { ListParams, Paginated } from '../../types/responses';
5
+ /**
6
+ * Client for managing cards in the Kaiban platform
7
+ * Cards represent work items, tasks, or tickets within boards
8
+ * @category Resources
9
+ */
10
+ export declare class CardsClient {
11
+ private readonly http;
12
+ constructor(http: HttpClient);
13
+ /**
14
+ * List cards 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 cards
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // List cards with filters
27
+ * const result = await client.cards.list({
28
+ * limit: 20,
29
+ * order_by: ['created_at']
30
+ * });
31
+ * ```
32
+ */
33
+ list(params?: ListParams, options?: RequestOptions): Promise<Paginated<Card>>;
34
+ /**
35
+ * Iterate through all cards using async generator
36
+ * Automatically handles pagination by following next_page_token
37
+ *
38
+ * @param params - Optional query parameters (excluding cursor)
39
+ * @param options - Optional request configuration
40
+ *
41
+ * @yields Individual Card objects
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * // Process all cards
46
+ * for await (const card of client.cards.listAll()) {
47
+ * console.log(card.title, card.status);
48
+ * }
49
+ * ```
50
+ */
51
+ listAll(params?: Omit<ListParams, 'cursor'>, options?: RequestOptions): AsyncGenerator<Card, void, unknown>;
52
+ /**
53
+ * Get a single card by ID
54
+ *
55
+ * @param id - The unique identifier of the card
56
+ * @param options - Optional request configuration
57
+ *
58
+ * @returns The card object
59
+ *
60
+ * @throws {Error} If the card is not found or request fails
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const card = await client.cards.get('card-123');
65
+ * console.log(card.title, card.description);
66
+ * ```
67
+ */
68
+ get(id: string, options?: RequestOptions): Promise<Card>;
69
+ /**
70
+ * Create a new card with optional activity tracking
71
+ *
72
+ * @param data - Card creation data
73
+ * @param data.title - The card title
74
+ * @param data.board_id - The board this card belongs to
75
+ * @param data.column_key - The column where the card should be placed
76
+ * @param options - Optional request configuration
77
+ * @param options.create_activity - If true, creates a 'card_created' activity
78
+ *
79
+ * @returns The newly created card
80
+ *
81
+ * @throws {Error} If creation fails
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const card = await client.cards.create({
86
+ * title: 'New Task',
87
+ * board_id: 'board-123',
88
+ * team_id: 'team-456',
89
+ * column_key: 'todo',
90
+ * description: 'Task description'
91
+ * }, { create_activity: true });
92
+ * ```
93
+ */
94
+ create(data: CreateCardInput, options?: RequestOptions & {
95
+ create_activity?: boolean;
96
+ }): Promise<Card>;
97
+ /**
98
+ * Update a card's properties
99
+ *
100
+ * @param id - The unique identifier of the card to update
101
+ * @param data - Card data with fields to update
102
+ * @param options - Optional request configuration
103
+ *
104
+ * @returns The updated card object
105
+ *
106
+ * @throws {Error} If the card is not found or update fails
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const updated = await client.cards.update('card-123', {
111
+ * title: 'Updated Title',
112
+ * status: 'in_progress'
113
+ * });
114
+ * ```
115
+ */
116
+ update(id: string, data: UpdateCardInput, options?: RequestOptions): Promise<Card>;
117
+ /**
118
+ * Delete a card by ID
119
+ *
120
+ * @param id - The unique identifier of the card to delete
121
+ * @param options - Optional request configuration
122
+ *
123
+ * @returns Promise that resolves when the card is deleted
124
+ *
125
+ * @throws {Error} If the card is not found or deletion fails
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * await client.cards.delete('card-123');
130
+ * ```
131
+ */
132
+ delete(id: string, options?: RequestOptions): Promise<void>;
133
+ /**
134
+ * Move a card to a new column and automatically record the activity
135
+ * This is a convenience method that combines update and activity creation
136
+ *
137
+ * @param id - The unique identifier of the card to move
138
+ * @param newColumnKey - The key of the destination column
139
+ * @param options - Optional request configuration
140
+ * @param options.actor - The actor performing the move (defaults to SDK system actor)
141
+ *
142
+ * @returns The updated card object
143
+ *
144
+ * @throws {Error} If the card is not found or move fails
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * // Move card to 'in_progress' column
149
+ * const card = await client.cards.moveToColumn('card-123', 'in_progress', {
150
+ * actor: {
151
+ * id: 'user-456',
152
+ * type: 'user',
153
+ * name: 'John Doe'
154
+ * }
155
+ * });
156
+ * ```
157
+ */
158
+ moveToColumn(id: string, newColumnKey: string, options?: RequestOptions & {
159
+ actor?: ActivityActor;
160
+ }): Promise<Card>;
161
+ }
@@ -0,0 +1,202 @@
1
+ // Minimal create-activity payload aligned to backend activity schema
2
+ // Activity types are shared in entities
3
+ /**
4
+ * Client for managing cards in the Kaiban platform
5
+ * Cards represent work items, tasks, or tickets within boards
6
+ * @category Resources
7
+ */
8
+ export class CardsClient {
9
+ constructor(http) {
10
+ this.http = http;
11
+ }
12
+ /**
13
+ * List cards 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 cards
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * // List cards with filters
26
+ * const result = await client.cards.list({
27
+ * limit: 20,
28
+ * order_by: ['created_at']
29
+ * });
30
+ * ```
31
+ */
32
+ list(params, options) {
33
+ return this.http.list('/cards', params, options);
34
+ }
35
+ /**
36
+ * Iterate through all cards using async generator
37
+ * Automatically handles pagination by following next_page_token
38
+ *
39
+ * @param params - Optional query parameters (excluding cursor)
40
+ * @param options - Optional request configuration
41
+ *
42
+ * @yields Individual Card objects
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * // Process all cards
47
+ * for await (const card of client.cards.listAll()) {
48
+ * console.log(card.title, card.status);
49
+ * }
50
+ * ```
51
+ */
52
+ async *listAll(params, options) {
53
+ let cursor = undefined;
54
+ do {
55
+ const page = await this.list({ ...(params || {}), cursor }, options);
56
+ for (const item of page.data)
57
+ yield item;
58
+ cursor = page.meta.next_cursor;
59
+ } while (cursor);
60
+ }
61
+ /**
62
+ * Get a single card by ID
63
+ *
64
+ * @param id - The unique identifier of the card
65
+ * @param options - Optional request configuration
66
+ *
67
+ * @returns The card object
68
+ *
69
+ * @throws {Error} If the card is not found or request fails
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const card = await client.cards.get('card-123');
74
+ * console.log(card.title, card.description);
75
+ * ```
76
+ */
77
+ get(id, options) {
78
+ return this.http.get(`/card/${encodeURIComponent(id)}`, options);
79
+ }
80
+ /**
81
+ * Create a new card with optional activity tracking
82
+ *
83
+ * @param data - Card creation data
84
+ * @param data.title - The card title
85
+ * @param data.board_id - The board this card belongs to
86
+ * @param data.column_key - The column where the card should be placed
87
+ * @param options - Optional request configuration
88
+ * @param options.create_activity - If true, creates a 'card_created' activity
89
+ *
90
+ * @returns The newly created card
91
+ *
92
+ * @throws {Error} If creation fails
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const card = await client.cards.create({
97
+ * title: 'New Task',
98
+ * board_id: 'board-123',
99
+ * team_id: 'team-456',
100
+ * column_key: 'todo',
101
+ * description: 'Task description'
102
+ * }, { create_activity: true });
103
+ * ```
104
+ */
105
+ async create(data, options) {
106
+ const card = await this.http.post('/cards', data, options);
107
+ if (options?.create_activity) {
108
+ const activity = {
109
+ board_id: card.board_id,
110
+ team_id: card.team_id,
111
+ card_id: card.id,
112
+ type: 'card_created',
113
+ description: 'Card created',
114
+ actor: { id: 'sdk', type: 'system', name: 'Kaiban SDK' },
115
+ };
116
+ await this.http.post(`/card/${encodeURIComponent(card.id)}/activities`, activity, options);
117
+ }
118
+ return card;
119
+ }
120
+ /**
121
+ * Update a card's properties
122
+ *
123
+ * @param id - The unique identifier of the card to update
124
+ * @param data - Card data with fields to update
125
+ * @param options - Optional request configuration
126
+ *
127
+ * @returns The updated card object
128
+ *
129
+ * @throws {Error} If the card is not found or update fails
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * const updated = await client.cards.update('card-123', {
134
+ * title: 'Updated Title',
135
+ * status: 'in_progress'
136
+ * });
137
+ * ```
138
+ */
139
+ update(id, data, options) {
140
+ return this.http.put(`/card/${encodeURIComponent(id)}`, data, options);
141
+ }
142
+ /**
143
+ * Delete a card by ID
144
+ *
145
+ * @param id - The unique identifier of the card to delete
146
+ * @param options - Optional request configuration
147
+ *
148
+ * @returns Promise that resolves when the card is deleted
149
+ *
150
+ * @throws {Error} If the card is not found or deletion fails
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * await client.cards.delete('card-123');
155
+ * ```
156
+ */
157
+ delete(id, options) {
158
+ return this.http.delete(`/card/${encodeURIComponent(id)}`, options);
159
+ }
160
+ // Activity operations moved to ActivitiesClient
161
+ /**
162
+ * Move a card to a new column and automatically record the activity
163
+ * This is a convenience method that combines update and activity creation
164
+ *
165
+ * @param id - The unique identifier of the card to move
166
+ * @param newColumnKey - The key of the destination column
167
+ * @param options - Optional request configuration
168
+ * @param options.actor - The actor performing the move (defaults to SDK system actor)
169
+ *
170
+ * @returns The updated card object
171
+ *
172
+ * @throws {Error} If the card is not found or move fails
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * // Move card to 'in_progress' column
177
+ * const card = await client.cards.moveToColumn('card-123', 'in_progress', {
178
+ * actor: {
179
+ * id: 'user-456',
180
+ * type: 'user',
181
+ * name: 'John Doe'
182
+ * }
183
+ * });
184
+ * ```
185
+ */
186
+ async moveToColumn(id, newColumnKey, options) {
187
+ const current = await this.get(id, options);
188
+ const oldColumn = current.column_key;
189
+ const updated = await this.update(id, { column_key: newColumnKey }, options);
190
+ const activity = {
191
+ board_id: updated.board_id,
192
+ team_id: updated.team_id,
193
+ card_id: updated.id,
194
+ type: 'card_column_changed',
195
+ description: `Moved card from ${oldColumn} to ${newColumnKey}`,
196
+ actor: options?.actor || { id: 'sdk', type: 'system', name: 'Kaiban SDK' },
197
+ changes: [{ field: 'column_key', old_value: oldColumn, new_value: newColumnKey }],
198
+ };
199
+ await this.http.post(`/card/${encodeURIComponent(updated.id)}/activities`, activity, options);
200
+ return updated;
201
+ }
202
+ }