@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.
- package/README.md +225 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +15 -0
- package/dist/lib/client.d.ts +65 -0
- package/dist/lib/client.js +51 -0
- package/dist/lib/http/HttpClient.d.ts +16 -0
- package/dist/lib/http/HttpClient.js +237 -0
- package/dist/lib/http/errors.d.ts +50 -0
- package/dist/lib/http/errors.js +126 -0
- package/dist/lib/http/types.d.ts +40 -0
- package/dist/lib/http/types.js +1 -0
- package/dist/lib/resources/ActivitiesClient.d.ts +89 -0
- package/dist/lib/resources/ActivitiesClient.js +99 -0
- package/dist/lib/resources/AgentsClient.d.ts +121 -0
- package/dist/lib/resources/AgentsClient.js +134 -0
- package/dist/lib/resources/BenchmarkExecutionsClient.d.ts +250 -0
- package/dist/lib/resources/BenchmarkExecutionsClient.js +261 -0
- package/dist/lib/resources/BenchmarksClient.d.ts +159 -0
- package/dist/lib/resources/BenchmarksClient.js +158 -0
- package/dist/lib/resources/BoardsClient.d.ts +65 -0
- package/dist/lib/resources/BoardsClient.js +74 -0
- package/dist/lib/resources/CardsClient.d.ts +161 -0
- package/dist/lib/resources/CardsClient.js +202 -0
- package/dist/lib/resources/ExternalChannelsClient.d.ts +65 -0
- package/dist/lib/resources/ExternalChannelsClient.js +74 -0
- package/dist/lib/resources/ResourcesClient.d.ts +92 -0
- package/dist/lib/resources/ResourcesClient.js +98 -0
- package/dist/lib/resources/SupervisorFeedbackClient.d.ts +75 -0
- package/dist/lib/resources/SupervisorFeedbackClient.js +67 -0
- package/dist/lib/resources/TeamMembersClient.d.ts +66 -0
- package/dist/lib/resources/TeamMembersClient.js +75 -0
- package/dist/lib/resources/TeamsClient.d.ts +83 -0
- package/dist/lib/resources/TeamsClient.js +92 -0
- package/dist/lib/resources/__tests__/ActivitiesClient.test.d.ts +1 -0
- package/dist/lib/resources/__tests__/ActivitiesClient.test.js +33 -0
- package/dist/lib/resources/__tests__/AgentsClient.test.d.ts +1 -0
- package/dist/lib/resources/__tests__/AgentsClient.test.js +37 -0
- package/dist/lib/resources/__tests__/BenchmarkExecutionsClient.test.d.ts +1 -0
- package/dist/lib/resources/__tests__/BenchmarkExecutionsClient.test.js +59 -0
- package/dist/lib/resources/__tests__/BenchmarksClient.test.d.ts +1 -0
- package/dist/lib/resources/__tests__/BenchmarksClient.test.js +42 -0
- package/dist/lib/resources/__tests__/BoardsClient.test.d.ts +1 -0
- package/dist/lib/resources/__tests__/BoardsClient.test.js +26 -0
- package/dist/lib/resources/__tests__/CardsClient.test.d.ts +1 -0
- package/dist/lib/resources/__tests__/CardsClient.test.js +62 -0
- package/dist/lib/resources/__tests__/ExternalChannelsClient.test.d.ts +1 -0
- package/dist/lib/resources/__tests__/ExternalChannelsClient.test.js +26 -0
- package/dist/lib/resources/__tests__/ResourcesClient.test.d.ts +1 -0
- package/dist/lib/resources/__tests__/ResourcesClient.test.js +28 -0
- package/dist/lib/resources/__tests__/SupervisorFeedbackClient.test.d.ts +1 -0
- package/dist/lib/resources/__tests__/SupervisorFeedbackClient.test.js +24 -0
- package/dist/lib/resources/__tests__/TeamMembersClient.test.d.ts +1 -0
- package/dist/lib/resources/__tests__/TeamMembersClient.test.js +26 -0
- package/dist/lib/resources/__tests__/TeamsClient.test.d.ts +1 -0
- package/dist/lib/resources/__tests__/TeamsClient.test.js +26 -0
- package/dist/test/helpers/mockFetch.d.ts +8 -0
- package/dist/test/helpers/mockFetch.js +22 -0
- package/dist/types/a2a-data-parts.d.ts +64 -0
- package/dist/types/a2a-data-parts.js +13 -0
- package/dist/types/entities/activities.d.ts +32 -0
- package/dist/types/entities/activities.js +1 -0
- package/dist/types/entities/agent.d.ts +16 -0
- package/dist/types/entities/agent.js +1 -0
- package/dist/types/entities/benchmark.d.ts +82 -0
- package/dist/types/entities/benchmark.js +1 -0
- package/dist/types/entities/board.d.ts +20 -0
- package/dist/types/entities/board.js +1 -0
- package/dist/types/entities/card.d.ts +50 -0
- package/dist/types/entities/card.js +1 -0
- package/dist/types/entities/external-channel.d.ts +12 -0
- package/dist/types/entities/external-channel.js +1 -0
- package/dist/types/entities/index.d.ts +9 -0
- package/dist/types/entities/index.js +9 -0
- package/dist/types/entities/resource.d.ts +16 -0
- package/dist/types/entities/resource.js +1 -0
- package/dist/types/entities/shared.d.ts +1 -0
- package/dist/types/entities/shared.js +2 -0
- package/dist/types/entities/team.d.ts +14 -0
- package/dist/types/entities/team.js +1 -0
- package/dist/types/entities.d.ts +1 -0
- package/dist/types/entities.js +1 -0
- package/dist/types/requests.d.ts +22 -0
- package/dist/types/requests.js +1 -0
- package/dist/types/responses.d.ts +77 -0
- package/dist/types/responses.js +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client for managing teams in the Kaiban platform
|
|
3
|
+
* @category Resources
|
|
4
|
+
*/
|
|
5
|
+
export class TeamsClient {
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* List teams with pagination, filters, and sorting
|
|
11
|
+
*
|
|
12
|
+
* @param params - Optional query parameters for filtering and pagination
|
|
13
|
+
* @param params.cursor - Cursor for pagination (from previous/next response)
|
|
14
|
+
* @param params.limit - Number of items per page (default: 50, max: 100)
|
|
15
|
+
* @param params.order_by - Fields to sort by. Use - prefix for descending order
|
|
16
|
+
* @param params.filters - Filter parameters (e.g., { status: 'active' })
|
|
17
|
+
* @param options - Optional request configuration
|
|
18
|
+
*
|
|
19
|
+
* @returns A paginated list of teams
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // Basic pagination
|
|
24
|
+
* const result = await client.teams.list({ limit: 20 });
|
|
25
|
+
* console.log(result.data); // Current page items
|
|
26
|
+
* console.log(result.pagination.next_cursor); // Use for next page
|
|
27
|
+
*
|
|
28
|
+
* // With sorting
|
|
29
|
+
* const sorted = await client.teams.list({
|
|
30
|
+
* order_by: '-created_at',
|
|
31
|
+
* limit: 50
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* // With filters
|
|
35
|
+
* const filtered = await client.teams.list({
|
|
36
|
+
* filters: { status: 'active' }
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // Next page
|
|
40
|
+
* const nextPage = await client.teams.list({
|
|
41
|
+
* cursor: result.pagination.next_cursor
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
list(params, options) {
|
|
46
|
+
return this.http.list('/teams', params, options);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Iterate through all teams using async generator
|
|
50
|
+
* Automatically handles pagination by following next_page_token
|
|
51
|
+
*
|
|
52
|
+
* @param params - Optional query parameters (excluding cursor)
|
|
53
|
+
* @param options - Optional request configuration
|
|
54
|
+
*
|
|
55
|
+
* @yields Individual Team objects
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* for await (const team of client.teams.listAll()) {
|
|
60
|
+
* console.log(team.id, team.name);
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
async *listAll(params, options) {
|
|
65
|
+
let cursor = undefined;
|
|
66
|
+
do {
|
|
67
|
+
const page = await this.list({ ...(params || {}), cursor }, options);
|
|
68
|
+
for (const item of page.data)
|
|
69
|
+
yield item;
|
|
70
|
+
cursor = page.meta.next_cursor;
|
|
71
|
+
} while (cursor);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get a single team by ID
|
|
75
|
+
*
|
|
76
|
+
* @param id - The unique identifier of the team
|
|
77
|
+
* @param options - Optional request configuration
|
|
78
|
+
*
|
|
79
|
+
* @returns The team object
|
|
80
|
+
*
|
|
81
|
+
* @throws {Error} If the team is not found or request fails
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const team = await client.teams.get('team-123');
|
|
86
|
+
* console.log(team.name);
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
get(id, options) {
|
|
90
|
+
return this.http.get(`/team/${encodeURIComponent(id)}`, options);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { createKaibanClient } from '../../client';
|
|
3
|
+
import { createMockFetch, jsonOk } from '../../../test/helpers/mockFetch';
|
|
4
|
+
function makeClient(responses) {
|
|
5
|
+
const fetch = createMockFetch(responses);
|
|
6
|
+
return createKaibanClient({ tenant: 't', token: 'x', fetch });
|
|
7
|
+
}
|
|
8
|
+
describe('ActivitiesClient', () => {
|
|
9
|
+
it('lists activities and iterates', async () => {
|
|
10
|
+
const client = makeClient([
|
|
11
|
+
jsonOk({ items: [{ id: 'act1' }], next_page_token: 'n1' }),
|
|
12
|
+
jsonOk({ items: [{ id: 'act2' }] }),
|
|
13
|
+
]);
|
|
14
|
+
const page = await client.activities.list('c1', { page_size: 1 });
|
|
15
|
+
expect(page.items[0].id).toBe('act1');
|
|
16
|
+
const all = [];
|
|
17
|
+
for await (const a of client.activities.listAll('c1', { page_size: 1 }))
|
|
18
|
+
all.push(a);
|
|
19
|
+
expect(all.map((x) => x.id)).toEqual(['act1', 'act2']);
|
|
20
|
+
});
|
|
21
|
+
it('creates an activity', async () => {
|
|
22
|
+
const client = makeClient([jsonOk({ id: 'act1' })]);
|
|
23
|
+
const res = await client.activities.create('c1', {
|
|
24
|
+
board_id: 'b',
|
|
25
|
+
card_id: 'c1',
|
|
26
|
+
team_id: 't',
|
|
27
|
+
type: 'card_created',
|
|
28
|
+
description: 'd',
|
|
29
|
+
actor: { id: 'x', type: 'system', name: 'n' },
|
|
30
|
+
});
|
|
31
|
+
expect(res.id).toBe('act1');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { createKaibanClient } from '../../client';
|
|
3
|
+
import { createMockFetch, jsonOk } from '../../../test/helpers/mockFetch';
|
|
4
|
+
function makeClient(responses) {
|
|
5
|
+
const fetch = createMockFetch(responses);
|
|
6
|
+
return createKaibanClient({ tenant: 't', token: 'x', fetch });
|
|
7
|
+
}
|
|
8
|
+
describe('AgentsClient', () => {
|
|
9
|
+
it('lists agents with pagination', async () => {
|
|
10
|
+
const client = makeClient([
|
|
11
|
+
jsonOk({ items: [{ id: 'a1' }], next_page_token: 'n1' }),
|
|
12
|
+
jsonOk({ items: [{ id: 'a2' }], next_page_token: undefined }),
|
|
13
|
+
]);
|
|
14
|
+
const page1 = await client.agents.list({ page_size: 1 });
|
|
15
|
+
expect(page1.items[0].id).toBe('a1');
|
|
16
|
+
expect(page1.next_page_token).toBe('n1');
|
|
17
|
+
const items = [];
|
|
18
|
+
for await (const a of client.agents.listAll({ page_size: 1 }))
|
|
19
|
+
items.push(a);
|
|
20
|
+
expect(items.map((x) => x.id)).toEqual(['a1', 'a2']);
|
|
21
|
+
});
|
|
22
|
+
it('gets an agent', async () => {
|
|
23
|
+
const client = makeClient([jsonOk({ id: 'a1', name: 'Agent' })]);
|
|
24
|
+
const agent = await client.agents.get('a1');
|
|
25
|
+
expect(agent.id).toBe('a1');
|
|
26
|
+
});
|
|
27
|
+
it('updates an agent', async () => {
|
|
28
|
+
const client = makeClient([jsonOk({ id: 'a1', name: 'New' })]);
|
|
29
|
+
const updated = await client.agents.update('a1', { name: 'New' });
|
|
30
|
+
expect(updated.name).toBe('New');
|
|
31
|
+
});
|
|
32
|
+
it('creates feedback', async () => {
|
|
33
|
+
const client = makeClient([jsonOk({})]);
|
|
34
|
+
await client.agents.createFeedback('a1', { rating: 5 });
|
|
35
|
+
expect(true).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { createKaibanClient } from '../../client';
|
|
3
|
+
import { createMockFetch, jsonOk } from '../../../test/helpers/mockFetch';
|
|
4
|
+
function makeClient(responses) {
|
|
5
|
+
const fetch = createMockFetch(responses);
|
|
6
|
+
return createKaibanClient({ tenant: 't', token: 'x', fetch });
|
|
7
|
+
}
|
|
8
|
+
describe('BenchmarkExecutionsClient', () => {
|
|
9
|
+
it('lists executions and iterates', async () => {
|
|
10
|
+
const client = makeClient([
|
|
11
|
+
jsonOk({ items: [{ id: 'e1' }], next_page_token: 'n1' }),
|
|
12
|
+
jsonOk({ items: [{ id: 'e2' }] }),
|
|
13
|
+
]);
|
|
14
|
+
const page = await client.benchmarkExecutions.list({ page_size: 1 });
|
|
15
|
+
expect(page.items[0].id).toBe('e1');
|
|
16
|
+
const all = [];
|
|
17
|
+
for await (const e of client.benchmarkExecutions.listAll({ page_size: 1 }))
|
|
18
|
+
all.push(e);
|
|
19
|
+
expect(all.map((x) => x.id)).toEqual(['e1', 'e2']);
|
|
20
|
+
});
|
|
21
|
+
it('CRUD execution', async () => {
|
|
22
|
+
const client = makeClient([jsonOk({ id: 'e1' }), jsonOk({ id: 'e1' }), jsonOk({})]);
|
|
23
|
+
const c = await client.benchmarkExecutions.create({ benchmark_id: 'b', agent_id: 'a' });
|
|
24
|
+
expect(c.id).toBe('e1');
|
|
25
|
+
const g = await client.benchmarkExecutions.get('e1');
|
|
26
|
+
expect(g.id).toBe('e1');
|
|
27
|
+
await client.benchmarkExecutions.delete('e1');
|
|
28
|
+
expect(true).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
it('test cases: create, list, get, update, delete', async () => {
|
|
31
|
+
const client = makeClient([
|
|
32
|
+
jsonOk({ id: 't1' }),
|
|
33
|
+
jsonOk({ items: [{ id: 't1' }] }),
|
|
34
|
+
jsonOk({ id: 't1' }),
|
|
35
|
+
jsonOk({ id: 't1', test_index: 1 }),
|
|
36
|
+
jsonOk({}),
|
|
37
|
+
]);
|
|
38
|
+
const tc = await client.benchmarkExecutions.createTestCase({
|
|
39
|
+
execution_id: 'e1',
|
|
40
|
+
body: { input: 'i', agent_output: 'o', execution_time: 1 },
|
|
41
|
+
});
|
|
42
|
+
expect(tc.id).toBe('t1');
|
|
43
|
+
const list = await client.benchmarkExecutions.listTestCases({ execution_id: 'e1' });
|
|
44
|
+
expect(list.items[0].id).toBe('t1');
|
|
45
|
+
const g = await client.benchmarkExecutions.getTestCase({
|
|
46
|
+
execution_id: 'e1',
|
|
47
|
+
test_case_id: 't1',
|
|
48
|
+
});
|
|
49
|
+
expect(g.id).toBe('t1');
|
|
50
|
+
const u = await client.benchmarkExecutions.updateTestCase({
|
|
51
|
+
execution_id: 'e1',
|
|
52
|
+
test_case_id: 't1',
|
|
53
|
+
body: { test_index: 1 },
|
|
54
|
+
});
|
|
55
|
+
expect(u.test_index).toBe(1);
|
|
56
|
+
await client.benchmarkExecutions.deleteTestCase({ execution_id: 'e1', test_case_id: 't1' });
|
|
57
|
+
expect(true).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { createKaibanClient } from '../../client';
|
|
3
|
+
import { createMockFetch, jsonOk } from '../../../test/helpers/mockFetch';
|
|
4
|
+
function makeClient(responses) {
|
|
5
|
+
const fetch = createMockFetch(responses);
|
|
6
|
+
return createKaibanClient({ tenant: 't', token: 'x', fetch });
|
|
7
|
+
}
|
|
8
|
+
describe('BenchmarksClient', () => {
|
|
9
|
+
it('lists and iterates benchmarks', async () => {
|
|
10
|
+
const client = makeClient([
|
|
11
|
+
jsonOk({ items: [{ id: 'bm1' }], next_page_token: 'n1' }),
|
|
12
|
+
jsonOk({ items: [{ id: 'bm2' }] }),
|
|
13
|
+
]);
|
|
14
|
+
const page = await client.benchmarks.list({ page_size: 1 });
|
|
15
|
+
expect(page.items[0].id).toBe('bm1');
|
|
16
|
+
const all = [];
|
|
17
|
+
for await (const b of client.benchmarks.listAll({ page_size: 1 }))
|
|
18
|
+
all.push(b);
|
|
19
|
+
expect(all.map((x) => x.id)).toEqual(['bm1', 'bm2']);
|
|
20
|
+
});
|
|
21
|
+
it('gets, creates and updates benchmark', async () => {
|
|
22
|
+
const client = makeClient([
|
|
23
|
+
jsonOk({ id: 'bm1' }),
|
|
24
|
+
jsonOk({ id: 'bm2' }),
|
|
25
|
+
jsonOk({ id: 'bm2', name: 'n' }),
|
|
26
|
+
]);
|
|
27
|
+
const g = await client.benchmarks.get('bm1');
|
|
28
|
+
expect(g.id).toBe('bm1');
|
|
29
|
+
const c = await client.benchmarks.create({ name: 'x' });
|
|
30
|
+
expect(c.id).toBe('bm2');
|
|
31
|
+
const u = await client.benchmarks.update('bm2', { name: 'n' });
|
|
32
|
+
expect(u.name).toBe('n');
|
|
33
|
+
});
|
|
34
|
+
it('executes a benchmark', async () => {
|
|
35
|
+
const client = makeClient([jsonOk({ message: 'ok' })]);
|
|
36
|
+
const res = await client.benchmarks.execute({
|
|
37
|
+
benchmark_id: 'bm1',
|
|
38
|
+
body: { agentConfig: { id: 'a' } },
|
|
39
|
+
});
|
|
40
|
+
expect(res.message).toBe('ok');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { createKaibanClient } from '../../client';
|
|
3
|
+
import { createMockFetch, jsonOk } from '../../../test/helpers/mockFetch';
|
|
4
|
+
function makeClient(responses) {
|
|
5
|
+
const fetch = createMockFetch(responses);
|
|
6
|
+
return createKaibanClient({ tenant: 't', token: 'x', fetch });
|
|
7
|
+
}
|
|
8
|
+
describe('BoardsClient', () => {
|
|
9
|
+
it('lists boards and iterates', async () => {
|
|
10
|
+
const client = makeClient([
|
|
11
|
+
jsonOk({ items: [{ id: 'b1' }], next_page_token: 'n1' }),
|
|
12
|
+
jsonOk({ items: [{ id: 'b2' }] }),
|
|
13
|
+
]);
|
|
14
|
+
const page = await client.boards.list({ page_size: 1 });
|
|
15
|
+
expect(page.items[0].id).toBe('b1');
|
|
16
|
+
const all = [];
|
|
17
|
+
for await (const b of client.boards.listAll({ page_size: 1 }))
|
|
18
|
+
all.push(b);
|
|
19
|
+
expect(all.map((x) => x.id)).toEqual(['b1', 'b2']);
|
|
20
|
+
});
|
|
21
|
+
it('gets a board', async () => {
|
|
22
|
+
const client = makeClient([jsonOk({ id: 'b1' })]);
|
|
23
|
+
const board = await client.boards.get('b1');
|
|
24
|
+
expect(board.id).toBe('b1');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { createKaibanClient } from '../../client';
|
|
3
|
+
import { createMockFetch, jsonOk } from '../../../test/helpers/mockFetch';
|
|
4
|
+
function makeClient(responses) {
|
|
5
|
+
const fetch = createMockFetch(responses);
|
|
6
|
+
return createKaibanClient({ tenant: 't', token: 'x', fetch });
|
|
7
|
+
}
|
|
8
|
+
describe('CardsClient', () => {
|
|
9
|
+
it('lists and iterates cards', async () => {
|
|
10
|
+
const client = makeClient([
|
|
11
|
+
jsonOk({ items: [{ id: 'c1' }], next_page_token: 'n1' }),
|
|
12
|
+
jsonOk({ items: [{ id: 'c2' }] }),
|
|
13
|
+
]);
|
|
14
|
+
const page = await client.cards.list({ page_size: 1 });
|
|
15
|
+
expect(page.items[0].id).toBe('c1');
|
|
16
|
+
const all = [];
|
|
17
|
+
for await (const c of client.cards.listAll({ page_size: 1 }))
|
|
18
|
+
all.push(c);
|
|
19
|
+
expect(all.map((x) => x.id)).toEqual(['c1', 'c2']);
|
|
20
|
+
});
|
|
21
|
+
it('gets a card', async () => {
|
|
22
|
+
const client = makeClient([
|
|
23
|
+
jsonOk({ id: 'c1', column_key: 'todo', board_id: 'b', team_id: 't' }),
|
|
24
|
+
]);
|
|
25
|
+
const card = await client.cards.get('c1');
|
|
26
|
+
expect(card.id).toBe('c1');
|
|
27
|
+
});
|
|
28
|
+
it('creates a card', async () => {
|
|
29
|
+
const client = makeClient([jsonOk({ id: 'c1' })]);
|
|
30
|
+
const card = await client.cards.create({
|
|
31
|
+
team_id: 't',
|
|
32
|
+
board_id: 'b',
|
|
33
|
+
owner_id: 'u',
|
|
34
|
+
agent_id: 'a',
|
|
35
|
+
title: 'x',
|
|
36
|
+
status: 'todo',
|
|
37
|
+
column_key: 'col',
|
|
38
|
+
priority: 'p',
|
|
39
|
+
member_ids: [],
|
|
40
|
+
});
|
|
41
|
+
expect(card.id).toBe('c1');
|
|
42
|
+
});
|
|
43
|
+
it('updates a card', async () => {
|
|
44
|
+
const client = makeClient([jsonOk({ id: 'c1', title: 'y' })]);
|
|
45
|
+
const res = await client.cards.update('c1', { title: 'y' });
|
|
46
|
+
expect(res.title).toBe('y');
|
|
47
|
+
});
|
|
48
|
+
it('deletes a card', async () => {
|
|
49
|
+
const client = makeClient([jsonOk({})]);
|
|
50
|
+
await client.cards.delete('c1');
|
|
51
|
+
expect(true).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
it('moves to column and creates activity', async () => {
|
|
54
|
+
const client = makeClient([
|
|
55
|
+
jsonOk({ id: 'c1', column_key: 'todo', board_id: 'b', team_id: 't' }), // get current
|
|
56
|
+
jsonOk({ id: 'c1', column_key: 'done', board_id: 'b', team_id: 't' }), // update
|
|
57
|
+
jsonOk({}), // post activity
|
|
58
|
+
]);
|
|
59
|
+
const res = await client.cards.moveToColumn('c1', 'done');
|
|
60
|
+
expect(res.column_key).toBe('done');
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { createKaibanClient } from '../../client';
|
|
3
|
+
import { createMockFetch, jsonOk } from '../../../test/helpers/mockFetch';
|
|
4
|
+
function makeClient(responses) {
|
|
5
|
+
const fetch = createMockFetch(responses);
|
|
6
|
+
return createKaibanClient({ tenant: 't', token: 'x', fetch });
|
|
7
|
+
}
|
|
8
|
+
describe('ExternalChannelsClient', () => {
|
|
9
|
+
it('lists and iterates external channels', async () => {
|
|
10
|
+
const client = makeClient([
|
|
11
|
+
jsonOk({ items: [{ id: 'ec1' }], next_page_token: 'n1' }),
|
|
12
|
+
jsonOk({ items: [{ id: 'ec2' }] }),
|
|
13
|
+
]);
|
|
14
|
+
const page = await client.externalChannels.list({ page_size: 1 });
|
|
15
|
+
expect(page.items[0].id).toBe('ec1');
|
|
16
|
+
const all = [];
|
|
17
|
+
for await (const e of client.externalChannels.listAll({ page_size: 1 }))
|
|
18
|
+
all.push(e);
|
|
19
|
+
expect(all.map((x) => x.id)).toEqual(['ec1', 'ec2']);
|
|
20
|
+
});
|
|
21
|
+
it('gets an external channel', async () => {
|
|
22
|
+
const client = makeClient([jsonOk({ id: 'ec1' })]);
|
|
23
|
+
const ch = await client.externalChannels.get('ec1');
|
|
24
|
+
expect(ch.id).toBe('ec1');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { createKaibanClient } from '../../client';
|
|
3
|
+
import { createMockFetch, jsonOk } from '../../../test/helpers/mockFetch';
|
|
4
|
+
function makeClient(responses) {
|
|
5
|
+
const fetch = createMockFetch(responses);
|
|
6
|
+
return createKaibanClient({ tenant: 't', token: 'x', fetch });
|
|
7
|
+
}
|
|
8
|
+
describe('ResourcesClient', () => {
|
|
9
|
+
it('lists and iterates resources', async () => {
|
|
10
|
+
const client = makeClient([
|
|
11
|
+
jsonOk({ items: [{ id: 'r1' }], next_page_token: 'n1' }),
|
|
12
|
+
jsonOk({ items: [{ id: 'r2' }] }),
|
|
13
|
+
]);
|
|
14
|
+
const page = await client.resources.list({ page_size: 1 });
|
|
15
|
+
expect(page.items[0].id).toBe('r1');
|
|
16
|
+
const all = [];
|
|
17
|
+
for await (const r of client.resources.listAll({ page_size: 1 }))
|
|
18
|
+
all.push(r);
|
|
19
|
+
expect(all.map((x) => x.id)).toEqual(['r1', 'r2']);
|
|
20
|
+
});
|
|
21
|
+
it('gets and publishes a resource', async () => {
|
|
22
|
+
const client = makeClient([jsonOk({ id: 'r1' }), jsonOk({ message: 'ok' })]);
|
|
23
|
+
const g = await client.resources.get('r1');
|
|
24
|
+
expect(g.id).toBe('r1');
|
|
25
|
+
const p = await client.resources.publish({ resource_id: 'r1', userId: 'u1' });
|
|
26
|
+
expect(p.message).toBe('ok');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { createKaibanClient } from '../../client';
|
|
3
|
+
import { createMockFetch, jsonOk } from '../../../test/helpers/mockFetch';
|
|
4
|
+
function makeClient(responses) {
|
|
5
|
+
const fetch = createMockFetch(responses);
|
|
6
|
+
return createKaibanClient({ tenant: 't', token: 'x', fetch });
|
|
7
|
+
}
|
|
8
|
+
describe('SupervisorFeedbackClient', () => {
|
|
9
|
+
it('lists feedback by agent and iterates', async () => {
|
|
10
|
+
const client = makeClient([
|
|
11
|
+
jsonOk({ items: [{ id: 'sf1' }], next_page_token: 'n1' }),
|
|
12
|
+
jsonOk({ items: [{ id: 'sf2' }] }),
|
|
13
|
+
]);
|
|
14
|
+
const page = await client.supervisorFeedback.listByAgent({ agent_id: 'a1', page_size: 1 });
|
|
15
|
+
expect(page.items[0].id).toBe('sf1');
|
|
16
|
+
const all = [];
|
|
17
|
+
for await (const s of client.supervisorFeedback.listAllByAgent({
|
|
18
|
+
agent_id: 'a1',
|
|
19
|
+
page_size: 1,
|
|
20
|
+
}))
|
|
21
|
+
all.push(s);
|
|
22
|
+
expect(all.map((x) => x.id)).toEqual(['sf1', 'sf2']);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { createKaibanClient } from '../../client';
|
|
3
|
+
import { createMockFetch, jsonOk } from '../../../test/helpers/mockFetch';
|
|
4
|
+
function makeClient(responses) {
|
|
5
|
+
const fetch = createMockFetch(responses);
|
|
6
|
+
return createKaibanClient({ tenant: 't', token: 'x', fetch });
|
|
7
|
+
}
|
|
8
|
+
describe('TeamMembersClient', () => {
|
|
9
|
+
it('lists and iterates team members', async () => {
|
|
10
|
+
const client = makeClient([
|
|
11
|
+
jsonOk({ items: [{ id: 'tm1' }], next_page_token: 'n1' }),
|
|
12
|
+
jsonOk({ items: [{ id: 'tm2' }] }),
|
|
13
|
+
]);
|
|
14
|
+
const page = await client.teamMembers.list({ page_size: 1 });
|
|
15
|
+
expect(page.items[0].id).toBe('tm1');
|
|
16
|
+
const all = [];
|
|
17
|
+
for await (const t of client.teamMembers.listAll({ page_size: 1 }))
|
|
18
|
+
all.push(t);
|
|
19
|
+
expect(all.map((x) => x.id)).toEqual(['tm1', 'tm2']);
|
|
20
|
+
});
|
|
21
|
+
it('gets a team member', async () => {
|
|
22
|
+
const client = makeClient([jsonOk({ id: 'tm1' })]);
|
|
23
|
+
const tm = await client.teamMembers.get('tm1');
|
|
24
|
+
expect(tm.id).toBe('tm1');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { createKaibanClient } from '../../client';
|
|
3
|
+
import { createMockFetch, jsonOk } from '../../../test/helpers/mockFetch';
|
|
4
|
+
function makeClient(responses) {
|
|
5
|
+
const fetch = createMockFetch(responses);
|
|
6
|
+
return createKaibanClient({ tenant: 't', token: 'x', fetch });
|
|
7
|
+
}
|
|
8
|
+
describe('TeamsClient', () => {
|
|
9
|
+
it('lists and iterates teams', async () => {
|
|
10
|
+
const client = makeClient([
|
|
11
|
+
jsonOk({ items: [{ id: 't1' }], next_page_token: 'n1' }),
|
|
12
|
+
jsonOk({ items: [{ id: 't2' }] }),
|
|
13
|
+
]);
|
|
14
|
+
const page = await client.teams.list({ page_size: 1 });
|
|
15
|
+
expect(page.items[0].id).toBe('t1');
|
|
16
|
+
const all = [];
|
|
17
|
+
for await (const t of client.teams.listAll({ page_size: 1 }))
|
|
18
|
+
all.push(t);
|
|
19
|
+
expect(all.map((x) => x.id)).toEqual(['t1', 't2']);
|
|
20
|
+
});
|
|
21
|
+
it('gets a team', async () => {
|
|
22
|
+
const client = makeClient([jsonOk({ id: 't1' })]);
|
|
23
|
+
const team = await client.teams.get('t1');
|
|
24
|
+
expect(team.id).toBe('t1');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type MockResponse = {
|
|
2
|
+
status: number;
|
|
3
|
+
headers?: Record<string, string>;
|
|
4
|
+
body?: unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare function createMockFetch(sequence: Array<MockResponse | ((input: RequestInfo | URL, init?: RequestInit) => MockResponse | Promise<MockResponse>)>): typeof fetch;
|
|
7
|
+
export declare function jsonOk(body: unknown, headers?: Record<string, string>): MockResponse;
|
|
8
|
+
export declare function jsonError(status: number, body: unknown): MockResponse;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function createMockFetch(sequence) {
|
|
2
|
+
let callIndex = 0;
|
|
3
|
+
const fetchImpl = async (input, init) => {
|
|
4
|
+
const item = sequence[Math.min(callIndex, sequence.length - 1)];
|
|
5
|
+
callIndex++;
|
|
6
|
+
const resolved = typeof item === 'function' ? await item(input, init) : item;
|
|
7
|
+
const headers = new Headers(resolved.headers || { 'content-type': 'application/json' });
|
|
8
|
+
const body = resolved.body === undefined || resolved.body === null
|
|
9
|
+
? null
|
|
10
|
+
: headers.get('content-type')?.includes('application/json')
|
|
11
|
+
? JSON.stringify(resolved.body)
|
|
12
|
+
: String(resolved.body);
|
|
13
|
+
return new Response(body, { status: resolved.status, headers });
|
|
14
|
+
};
|
|
15
|
+
return fetchImpl;
|
|
16
|
+
}
|
|
17
|
+
export function jsonOk(body, headers) {
|
|
18
|
+
return { status: 200, headers: { 'content-type': 'application/json', ...(headers || {}) }, body };
|
|
19
|
+
}
|
|
20
|
+
export function jsonError(status, body) {
|
|
21
|
+
return { status, headers: { 'content-type': 'application/json' }, body };
|
|
22
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ActivityCreate } from './entities';
|
|
2
|
+
export declare const A2ADataPartType: {
|
|
3
|
+
readonly TOOL_CALL_START: "tool_call_start";
|
|
4
|
+
readonly TOOL_CALL_ARGS: "tool_call_args";
|
|
5
|
+
readonly TOOL_CALL_END: "tool_call_end";
|
|
6
|
+
readonly TOOL_CALL_RESULT: "tool_call_result";
|
|
7
|
+
readonly TASK_INFO_MESSAGE: "task_info_message";
|
|
8
|
+
readonly TASK_STEP_OUTPUT: "task_step_output";
|
|
9
|
+
readonly USER_EVALUATION: "user_evaluation";
|
|
10
|
+
readonly USER_THREAD_FEEDBACK: "user_thread_feedback";
|
|
11
|
+
readonly KAIBAN_ACTIVITY: "kaiban_activity";
|
|
12
|
+
readonly AGENT_STATUS: "agent_status";
|
|
13
|
+
};
|
|
14
|
+
export type A2ADataPartType = (typeof A2ADataPartType)[keyof typeof A2ADataPartType];
|
|
15
|
+
export interface A2ADataPartBase<T extends A2ADataPartType, P extends object> {
|
|
16
|
+
data: {
|
|
17
|
+
type: T;
|
|
18
|
+
} & P;
|
|
19
|
+
}
|
|
20
|
+
export type ToolCallStartPart = A2ADataPartBase<'tool_call_start', {
|
|
21
|
+
toolName: string;
|
|
22
|
+
}>;
|
|
23
|
+
export type ToolCallArgsPart = A2ADataPartBase<'tool_call_args', {
|
|
24
|
+
toolName: string;
|
|
25
|
+
args: Record<string, unknown>;
|
|
26
|
+
}>;
|
|
27
|
+
export type ToolCallEndPart = A2ADataPartBase<'tool_call_end', {
|
|
28
|
+
toolName: string;
|
|
29
|
+
}>;
|
|
30
|
+
export type ToolCallResultPart = A2ADataPartBase<'tool_call_result', {
|
|
31
|
+
toolName: string;
|
|
32
|
+
result: Record<string, unknown>;
|
|
33
|
+
}>;
|
|
34
|
+
export type TaskInfoMessagePart = A2ADataPartBase<'task_info_message', {
|
|
35
|
+
message: string;
|
|
36
|
+
}>;
|
|
37
|
+
export type TaskStepOutputPart = A2ADataPartBase<'task_step_output', {
|
|
38
|
+
stepName: string;
|
|
39
|
+
output?: Record<string, unknown>;
|
|
40
|
+
costs?: Array<{
|
|
41
|
+
model: string;
|
|
42
|
+
inputTokens: number;
|
|
43
|
+
outputTokens: number;
|
|
44
|
+
totalTokens: number;
|
|
45
|
+
reasoningTokens: number;
|
|
46
|
+
cachedInputTokens: number;
|
|
47
|
+
}>;
|
|
48
|
+
duration: number;
|
|
49
|
+
}>;
|
|
50
|
+
export type UserEvaluationPart = A2ADataPartBase<'user_evaluation', {
|
|
51
|
+
messageId: string;
|
|
52
|
+
evaluation: 'good' | 'bad';
|
|
53
|
+
}>;
|
|
54
|
+
export type UserThreadFeedbackPart = A2ADataPartBase<'user_thread_feedback', {
|
|
55
|
+
wasHelpful: boolean;
|
|
56
|
+
feedback: string;
|
|
57
|
+
}>;
|
|
58
|
+
export type KaibanActivityPart = A2ADataPartBase<'kaiban_activity', {
|
|
59
|
+
activity: ActivityCreate;
|
|
60
|
+
}>;
|
|
61
|
+
export type AgentStatusPart = A2ADataPartBase<'agent_status', {
|
|
62
|
+
status: string;
|
|
63
|
+
}>;
|
|
64
|
+
export type AnyA2ADataPart = ToolCallStartPart | ToolCallArgsPart | ToolCallEndPart | ToolCallResultPart | TaskInfoMessagePart | TaskStepOutputPart | UserEvaluationPart | UserThreadFeedbackPart | KaibanActivityPart | AgentStatusPart;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// A2A Data Part type identifiers
|
|
2
|
+
export const A2ADataPartType = {
|
|
3
|
+
TOOL_CALL_START: 'tool_call_start',
|
|
4
|
+
TOOL_CALL_ARGS: 'tool_call_args',
|
|
5
|
+
TOOL_CALL_END: 'tool_call_end',
|
|
6
|
+
TOOL_CALL_RESULT: 'tool_call_result',
|
|
7
|
+
TASK_INFO_MESSAGE: 'task_info_message',
|
|
8
|
+
TASK_STEP_OUTPUT: 'task_step_output',
|
|
9
|
+
USER_EVALUATION: 'user_evaluation',
|
|
10
|
+
USER_THREAD_FEEDBACK: 'user_thread_feedback',
|
|
11
|
+
KAIBAN_ACTIVITY: 'kaiban_activity',
|
|
12
|
+
AGENT_STATUS: 'agent_status',
|
|
13
|
+
};
|