@lightdash-tools/client 0.2.6 → 0.3.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 +6 -8
- package/dist/api/v1/ai-agents.d.ts +52 -6
- package/dist/api/v1/ai-agents.js +131 -5
- package/dist/api/v1/ai-agents.test.js +161 -0
- package/dist/client.d.ts +0 -65
- package/dist/client.js +0 -23
- package/dist/client.test.js +0 -34
- package/dist/index.test.js +1 -1
- package/package.json +2 -2
- package/src/api/v1/ai-agents.test.ts +191 -0
- package/src/api/v1/ai-agents.ts +216 -5
- package/src/client.test.ts +0 -38
- package/src/client.ts +0 -86
- package/src/index.test.ts +1 -1
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ Pass `signal` when calling the low-level HTTP client:
|
|
|
65
65
|
|
|
66
66
|
```typescript
|
|
67
67
|
const controller = new AbortController();
|
|
68
|
-
const http = client.
|
|
68
|
+
const http = client.getHttpClientV1();
|
|
69
69
|
const result = await http.get('/projects/p1', { signal: controller.signal });
|
|
70
70
|
controller.abort(); // cancels the request
|
|
71
71
|
```
|
|
@@ -101,8 +101,8 @@ const client = new LightdashClient({
|
|
|
101
101
|
- `client.v1.query` – run/compile metric queries
|
|
102
102
|
- `client.v1.users` – list/get/update/delete organization members
|
|
103
103
|
- `client.v1.groups` – list/create/update groups
|
|
104
|
-
- `client.v1.aiAgents` – list AI agents (admin), list threads (admin), get/update AI organization settings
|
|
105
|
-
- `client.v1.metrics` – list metrics in data catalog
|
|
104
|
+
- `client.v1.aiAgents` – list AI agents (admin), list threads (admin), get/update AI organization settings; project-scoped agent CRUD, conversations (threads), and evaluations (suites, runs, results)
|
|
105
|
+
- `client.v1.metrics` – list metrics in data catalog; get metric details by table and name
|
|
106
106
|
- `client.v1.schedulers` – list/get/create/update/delete scheduled deliveries
|
|
107
107
|
- `client.v1.tags` – list/create/update/delete tags
|
|
108
108
|
- `client.v1.validation` – list/get/delete validation errors
|
|
@@ -110,11 +110,9 @@ const client = new LightdashClient({
|
|
|
110
110
|
### V2 API (Experimental)
|
|
111
111
|
|
|
112
112
|
- `client.v2.content` – search for charts, dashboards, and spaces across projects
|
|
113
|
-
- `client.v2.query` – execute async metric
|
|
114
|
-
- `client.v2.organizationRoles` – list organization roles and
|
|
115
|
-
- `client.v2.projectRoleAssignments` – list
|
|
116
|
-
|
|
117
|
-
Deprecated top-level aliases (`client.projects`, `client.organizations`, etc.) are still available but will be removed in a future major version.
|
|
113
|
+
- `client.v2.query` – execute async metric, SQL, saved chart, and dashboard chart queries
|
|
114
|
+
- `client.v2.organizationRoles` – list organization roles, get role details, and manage assignments to users
|
|
115
|
+
- `client.v2.projectRoleAssignments` – list, grant, and revoke project role assignments for users and groups
|
|
118
116
|
|
|
119
117
|
For custom endpoints use `client.getHttpClientV1()` and call `get`, `post`, `put`, `patch`, `delete` with the path (relative to `/api/v1`).
|
|
120
118
|
|
|
@@ -1,17 +1,63 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AI agents API client.
|
|
2
|
+
* AI agents API client.
|
|
3
|
+
*
|
|
4
|
+
* Admin endpoints → /api/v1/aiAgents/admin/...
|
|
5
|
+
* Project-scoped → /api/v1/projects/{projectUuid}/aiAgents/...
|
|
3
6
|
*/
|
|
4
|
-
import type { AiAgentSummary, AiAgentsAdminThreadsResult, GetAdminThreadsParams, GetAiOrganizationSettingsResult, UpdateAiOrganizationSettings, UpdateAiOrganizationSettingsResult } from '@lightdash-tools/common';
|
|
7
|
+
import type { AiAgentSummary, AiAgentsAdminThreadsResult, GetAdminThreadsParams, GetAiOrganizationSettingsResult, UpdateAiOrganizationSettings, UpdateAiOrganizationSettingsResult, AiAgent, CreateAiAgent, UpdateAiAgent, AiAgentThreadSummary, AiAgentThread, CreateAgentThreadBody, GenerateAgentThreadBody, GenerateAgentThreadResult, CreateEvaluationBody, CreateEvaluationResult, UpdateEvaluationBody, AppendEvaluationBody, AiAgentEvaluationSummary, AiAgentEvaluation, AiAgentEvaluationRunSummary, AiAgentEvaluationRun } from '@lightdash-tools/common';
|
|
5
8
|
import { BaseApiClient } from '../base-client';
|
|
6
9
|
export declare class AiAgentsClient extends BaseApiClient {
|
|
7
|
-
/**
|
|
8
|
-
* List all AI agent threads (admin). Supports pagination and filters.
|
|
9
|
-
*/
|
|
10
|
+
/** List all AI agent threads across the org (admin). Supports pagination and filters. */
|
|
10
11
|
getAdminThreads(params?: GetAdminThreadsParams): Promise<AiAgentsAdminThreadsResult>;
|
|
11
|
-
/** List all AI agents (admin). */
|
|
12
|
+
/** List all AI agents across the org (admin). */
|
|
12
13
|
listAdminAgents(): Promise<AiAgentSummary[]>;
|
|
13
14
|
/** Get AI organization settings. */
|
|
14
15
|
getAiOrganizationSettings(): Promise<GetAiOrganizationSettingsResult>;
|
|
15
16
|
/** Update AI organization settings. */
|
|
16
17
|
updateAiOrganizationSettings(body: UpdateAiOrganizationSettings): Promise<UpdateAiOrganizationSettingsResult>;
|
|
18
|
+
/** List all agents in a project (GET /projects/{projectUuid}/aiAgents). */
|
|
19
|
+
listAgents(projectUuid: string): Promise<AiAgentSummary[]>;
|
|
20
|
+
/** Get a single agent by UUID (GET /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
21
|
+
getAgent(projectUuid: string, agentUuid: string): Promise<AiAgent>;
|
|
22
|
+
/** Create a new agent in a project (POST /projects/{projectUuid}/aiAgents). */
|
|
23
|
+
createAgent(projectUuid: string, body: CreateAiAgent): Promise<AiAgent>;
|
|
24
|
+
/** Update an existing agent (PATCH /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
25
|
+
updateAgent(projectUuid: string, agentUuid: string, body: UpdateAiAgent): Promise<AiAgent>;
|
|
26
|
+
/** Delete an agent (DELETE /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
27
|
+
deleteAgent(projectUuid: string, agentUuid: string): Promise<void>;
|
|
28
|
+
/** List all threads for an agent (GET /projects/{projectUuid}/aiAgents/{agentUuid}/threads). */
|
|
29
|
+
listAgentThreads(projectUuid: string, agentUuid: string): Promise<AiAgentThreadSummary[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Create a new thread (POST /projects/{projectUuid}/aiAgents/{agentUuid}/threads).
|
|
32
|
+
* Pass `prompt` in the body to trigger an immediate generation.
|
|
33
|
+
*/
|
|
34
|
+
createAgentThread(projectUuid: string, agentUuid: string, body?: CreateAgentThreadBody): Promise<AiAgentThreadSummary>;
|
|
35
|
+
/** Get a thread with its messages (GET …/threads/{threadUuid}). */
|
|
36
|
+
getAgentThread(projectUuid: string, agentUuid: string, threadUuid: string): Promise<AiAgentThread>;
|
|
37
|
+
/**
|
|
38
|
+
* Generate a response in a thread (POST …/threads/{threadUuid}/generate).
|
|
39
|
+
* Use this to send a prompt and receive the agent's reply.
|
|
40
|
+
*/
|
|
41
|
+
generateAgentThreadResponse(projectUuid: string, agentUuid: string, threadUuid: string, body: GenerateAgentThreadBody): Promise<GenerateAgentThreadResult>;
|
|
42
|
+
/** List all evaluations for an agent (GET …/{agentUuid}/evaluations). */
|
|
43
|
+
listEvaluations(projectUuid: string, agentUuid: string): Promise<AiAgentEvaluationSummary[]>;
|
|
44
|
+
/** Create a new evaluation (POST …/{agentUuid}/evaluations). */
|
|
45
|
+
createEvaluation(projectUuid: string, agentUuid: string, body: CreateEvaluationBody): Promise<CreateEvaluationResult>;
|
|
46
|
+
/** Get a full evaluation with prompts (GET …/evaluations/{evalUuid}). */
|
|
47
|
+
getEvaluation(projectUuid: string, agentUuid: string, evalUuid: string): Promise<AiAgentEvaluation>;
|
|
48
|
+
/** Update an evaluation's title, description, or prompts (PATCH …/evaluations/{evalUuid}). */
|
|
49
|
+
updateEvaluation(projectUuid: string, agentUuid: string, evalUuid: string, body: UpdateEvaluationBody): Promise<AiAgentEvaluation>;
|
|
50
|
+
/** Append additional prompts to an existing evaluation (POST …/evaluations/{evalUuid}/append). */
|
|
51
|
+
appendToEvaluation(projectUuid: string, agentUuid: string, evalUuid: string, body: AppendEvaluationBody): Promise<void>;
|
|
52
|
+
/** Delete an evaluation (DELETE …/evaluations/{evalUuid}). */
|
|
53
|
+
deleteEvaluation(projectUuid: string, agentUuid: string, evalUuid: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Trigger a new evaluation run (POST …/evaluations/{evalUuid}/run).
|
|
56
|
+
* Returns a run summary with the new runUuid and initial status.
|
|
57
|
+
*/
|
|
58
|
+
runEvaluation(projectUuid: string, agentUuid: string, evalUuid: string): Promise<AiAgentEvaluationRunSummary>;
|
|
59
|
+
/** List all runs for an evaluation (GET …/evaluations/{evalUuid}/runs). */
|
|
60
|
+
listEvaluationRuns(projectUuid: string, agentUuid: string, evalUuid: string): Promise<AiAgentEvaluationRunSummary[]>;
|
|
61
|
+
/** Get detailed results of a specific run (GET …/evaluations/{evalUuid}/runs/{runUuid}). */
|
|
62
|
+
getEvaluationRunResults(projectUuid: string, agentUuid: string, evalUuid: string, runUuid: string): Promise<AiAgentEvaluationRun>;
|
|
17
63
|
}
|
package/dist/api/v1/ai-agents.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* AI agents API client.
|
|
3
|
+
* AI agents API client.
|
|
4
|
+
*
|
|
5
|
+
* Admin endpoints → /api/v1/aiAgents/admin/...
|
|
6
|
+
* Project-scoped → /api/v1/projects/{projectUuid}/aiAgents/...
|
|
4
7
|
*/
|
|
5
8
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
9
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -15,9 +18,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
18
|
exports.AiAgentsClient = void 0;
|
|
16
19
|
const base_client_1 = require("../base-client");
|
|
17
20
|
class AiAgentsClient extends base_client_1.BaseApiClient {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
+
// ─── Admin: threads ──────────────────────────────────────────────────────────
|
|
22
|
+
/** List all AI agent threads across the org (admin). Supports pagination and filters. */
|
|
21
23
|
getAdminThreads(params) {
|
|
22
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
25
|
return this.http.get('/aiAgents/admin/threads', {
|
|
@@ -25,12 +27,14 @@ class AiAgentsClient extends base_client_1.BaseApiClient {
|
|
|
25
27
|
});
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
// ─── Admin: agents ───────────────────────────────────────────────────────────
|
|
31
|
+
/** List all AI agents across the org (admin). */
|
|
29
32
|
listAdminAgents() {
|
|
30
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
34
|
return this.http.get('/aiAgents/admin/agents');
|
|
32
35
|
});
|
|
33
36
|
}
|
|
37
|
+
// ─── Admin: settings ─────────────────────────────────────────────────────────
|
|
34
38
|
/** Get AI organization settings. */
|
|
35
39
|
getAiOrganizationSettings() {
|
|
36
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43,5 +47,127 @@ class AiAgentsClient extends base_client_1.BaseApiClient {
|
|
|
43
47
|
return this.http.patch('/aiAgents/admin/settings', body);
|
|
44
48
|
});
|
|
45
49
|
}
|
|
50
|
+
// ─── Project-scoped: agent CRUD ──────────────────────────────────────────────
|
|
51
|
+
/** List all agents in a project (GET /projects/{projectUuid}/aiAgents). */
|
|
52
|
+
listAgents(projectUuid) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
return this.http.get(`/projects/${projectUuid}/aiAgents`);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Get a single agent by UUID (GET /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
58
|
+
getAgent(projectUuid, agentUuid) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}`);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Create a new agent in a project (POST /projects/{projectUuid}/aiAgents). */
|
|
64
|
+
createAgent(projectUuid, body) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
return this.http.post(`/projects/${projectUuid}/aiAgents`, body);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** Update an existing agent (PATCH /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
70
|
+
updateAgent(projectUuid, agentUuid, body) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
return this.http.patch(`/projects/${projectUuid}/aiAgents/${agentUuid}`, body);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/** Delete an agent (DELETE /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
76
|
+
deleteAgent(projectUuid, agentUuid) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
yield this.http.delete(`/projects/${projectUuid}/aiAgents/${agentUuid}`);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
// ─── Project-scoped: threads ─────────────────────────────────────────────────
|
|
82
|
+
/** List all threads for an agent (GET /projects/{projectUuid}/aiAgents/{agentUuid}/threads). */
|
|
83
|
+
listAgentThreads(projectUuid, agentUuid) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads`);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create a new thread (POST /projects/{projectUuid}/aiAgents/{agentUuid}/threads).
|
|
90
|
+
* Pass `prompt` in the body to trigger an immediate generation.
|
|
91
|
+
*/
|
|
92
|
+
createAgentThread(projectUuid, agentUuid, body) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads`, body !== null && body !== void 0 ? body : {});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/** Get a thread with its messages (GET …/threads/{threadUuid}). */
|
|
98
|
+
getAgentThread(projectUuid, agentUuid, threadUuid) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads/${threadUuid}`);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Generate a response in a thread (POST …/threads/{threadUuid}/generate).
|
|
105
|
+
* Use this to send a prompt and receive the agent's reply.
|
|
106
|
+
*/
|
|
107
|
+
generateAgentThreadResponse(projectUuid, agentUuid, threadUuid, body) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads/${threadUuid}/generate`, body);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
// ─── Project-scoped: evaluations ─────────────────────────────────────────────
|
|
113
|
+
/** List all evaluations for an agent (GET …/{agentUuid}/evaluations). */
|
|
114
|
+
listEvaluations(projectUuid, agentUuid) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations`);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/** Create a new evaluation (POST …/{agentUuid}/evaluations). */
|
|
120
|
+
createEvaluation(projectUuid, agentUuid, body) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations`, body);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/** Get a full evaluation with prompts (GET …/evaluations/{evalUuid}). */
|
|
126
|
+
getEvaluation(projectUuid, agentUuid, evalUuid) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}`);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/** Update an evaluation's title, description, or prompts (PATCH …/evaluations/{evalUuid}). */
|
|
132
|
+
updateEvaluation(projectUuid, agentUuid, evalUuid, body) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
return this.http.patch(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}`, body);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/** Append additional prompts to an existing evaluation (POST …/evaluations/{evalUuid}/append). */
|
|
138
|
+
appendToEvaluation(projectUuid, agentUuid, evalUuid, body) {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
yield this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}/append`, body);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/** Delete an evaluation (DELETE …/evaluations/{evalUuid}). */
|
|
144
|
+
deleteEvaluation(projectUuid, agentUuid, evalUuid) {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
yield this.http.delete(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}`);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// ─── Project-scoped: evaluation runs ─────────────────────────────────────────
|
|
150
|
+
/**
|
|
151
|
+
* Trigger a new evaluation run (POST …/evaluations/{evalUuid}/run).
|
|
152
|
+
* Returns a run summary with the new runUuid and initial status.
|
|
153
|
+
*/
|
|
154
|
+
runEvaluation(projectUuid, agentUuid, evalUuid) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}/run`, {});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/** List all runs for an evaluation (GET …/evaluations/{evalUuid}/runs). */
|
|
160
|
+
listEvaluationRuns(projectUuid, agentUuid, evalUuid) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
const response = yield this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}/runs`);
|
|
163
|
+
return response.data.runs;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/** Get detailed results of a specific run (GET …/evaluations/{evalUuid}/runs/{runUuid}). */
|
|
167
|
+
getEvaluationRunResults(projectUuid, agentUuid, evalUuid, runUuid) {
|
|
168
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}/runs/${runUuid}`);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
46
172
|
}
|
|
47
173
|
exports.AiAgentsClient = AiAgentsClient;
|
|
@@ -22,6 +22,7 @@ const ai_agents_1 = require("./ai-agents");
|
|
|
22
22
|
delete: vitest_1.vi.fn(),
|
|
23
23
|
};
|
|
24
24
|
});
|
|
25
|
+
// ─── Admin ───────────────────────────────────────────────────────────────────
|
|
25
26
|
(0, vitest_1.it)('getAdminThreads should call GET /aiAgents/admin/threads with optional params', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
27
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
27
28
|
const results = { data: [], pagination: { totalResults: 0, totalPageCount: 0 } };
|
|
@@ -74,4 +75,164 @@ const ai_agents_1 = require("./ai-agents");
|
|
|
74
75
|
(0, vitest_1.expect)(mockHttp.patch).toHaveBeenCalledWith('/aiAgents/admin/settings', body);
|
|
75
76
|
(0, vitest_1.expect)(result).toEqual(updated);
|
|
76
77
|
}));
|
|
78
|
+
// ─── Project-scoped: agent CRUD ──────────────────────────────────────────────
|
|
79
|
+
(0, vitest_1.it)('listAgents should call GET /projects/{projectUuid}/aiAgents', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
81
|
+
const list = [{ uuid: 'a1', name: 'Agent 1' }];
|
|
82
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(list);
|
|
83
|
+
const result = yield client.listAgents('proj1');
|
|
84
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents');
|
|
85
|
+
(0, vitest_1.expect)(result).toEqual(list);
|
|
86
|
+
}));
|
|
87
|
+
(0, vitest_1.it)('getAgent should call GET /projects/{projectUuid}/aiAgents/{agentUuid}', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
89
|
+
const agent = { uuid: 'a1', name: 'Agent 1', projectUuid: 'proj1' };
|
|
90
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(agent);
|
|
91
|
+
const result = yield client.getAgent('proj1', 'a1');
|
|
92
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1');
|
|
93
|
+
(0, vitest_1.expect)(result).toEqual(agent);
|
|
94
|
+
}));
|
|
95
|
+
(0, vitest_1.it)('createAgent should call POST /projects/{projectUuid}/aiAgents with body', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
97
|
+
const body = { name: 'New Agent', projectUuid: 'proj1' };
|
|
98
|
+
const created = { uuid: 'a2', name: 'New Agent', projectUuid: 'proj1' };
|
|
99
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(created);
|
|
100
|
+
const result = yield client.createAgent('proj1', body);
|
|
101
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents', body);
|
|
102
|
+
(0, vitest_1.expect)(result).toEqual(created);
|
|
103
|
+
}));
|
|
104
|
+
(0, vitest_1.it)('updateAgent should call PATCH /projects/{projectUuid}/aiAgents/{agentUuid} with body', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
106
|
+
const body = { name: 'Updated Agent' };
|
|
107
|
+
const updated = { uuid: 'a1', name: 'Updated Agent', projectUuid: 'proj1' };
|
|
108
|
+
vitest_1.vi.mocked(mockHttp.patch).mockResolvedValue(updated);
|
|
109
|
+
const result = yield client.updateAgent('proj1', 'a1', body);
|
|
110
|
+
(0, vitest_1.expect)(mockHttp.patch).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1', body);
|
|
111
|
+
(0, vitest_1.expect)(result).toEqual(updated);
|
|
112
|
+
}));
|
|
113
|
+
(0, vitest_1.it)('deleteAgent should call DELETE /projects/{projectUuid}/aiAgents/{agentUuid}', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
114
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
115
|
+
vitest_1.vi.mocked(mockHttp.delete).mockResolvedValue(undefined);
|
|
116
|
+
yield client.deleteAgent('proj1', 'a1');
|
|
117
|
+
(0, vitest_1.expect)(mockHttp.delete).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1');
|
|
118
|
+
}));
|
|
119
|
+
// ─── Project-scoped: threads ─────────────────────────────────────────────────
|
|
120
|
+
(0, vitest_1.it)('listAgentThreads should call GET /projects/{projectUuid}/aiAgents/{agentUuid}/threads', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
122
|
+
const threads = [{ uuid: 't1', title: 'Thread 1' }];
|
|
123
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(threads);
|
|
124
|
+
const result = yield client.listAgentThreads('proj1', 'a1');
|
|
125
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads');
|
|
126
|
+
(0, vitest_1.expect)(result).toEqual(threads);
|
|
127
|
+
}));
|
|
128
|
+
(0, vitest_1.it)('createAgentThread should call POST /projects/{projectUuid}/aiAgents/{agentUuid}/threads', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
129
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
130
|
+
const thread = { uuid: 't1', title: null };
|
|
131
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(thread);
|
|
132
|
+
const result = yield client.createAgentThread('proj1', 'a1');
|
|
133
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads', {});
|
|
134
|
+
(0, vitest_1.expect)(result).toEqual(thread);
|
|
135
|
+
}));
|
|
136
|
+
(0, vitest_1.it)('createAgentThread with body should pass body to POST', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
138
|
+
const body = { prompt: 'Hello' };
|
|
139
|
+
const thread = { uuid: 't1', title: null };
|
|
140
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(thread);
|
|
141
|
+
yield client.createAgentThread('proj1', 'a1', body);
|
|
142
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads', body);
|
|
143
|
+
}));
|
|
144
|
+
(0, vitest_1.it)('getAgentThread should call GET .../threads/{threadUuid}', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
145
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
146
|
+
const thread = { uuid: 't1', messages: [] };
|
|
147
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(thread);
|
|
148
|
+
const result = yield client.getAgentThread('proj1', 'a1', 't1');
|
|
149
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads/t1');
|
|
150
|
+
(0, vitest_1.expect)(result).toEqual(thread);
|
|
151
|
+
}));
|
|
152
|
+
(0, vitest_1.it)('generateAgentThreadResponse should call POST .../threads/{threadUuid}/generate', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
153
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
154
|
+
const response = { response: 'Here is your answer.' };
|
|
155
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(response);
|
|
156
|
+
const result = yield client.generateAgentThreadResponse('proj1', 'a1', 't1', {
|
|
157
|
+
prompt: 'What is the total revenue?',
|
|
158
|
+
});
|
|
159
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads/t1/generate', {
|
|
160
|
+
prompt: 'What is the total revenue?',
|
|
161
|
+
});
|
|
162
|
+
(0, vitest_1.expect)(result).toEqual(response);
|
|
163
|
+
}));
|
|
164
|
+
// ─── Project-scoped: evaluations ─────────────────────────────────────────────
|
|
165
|
+
(0, vitest_1.it)('listEvaluations should call GET .../evaluations', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
166
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
167
|
+
const evals = [{ evalUuid: 'e1', title: 'Eval 1', agentUuid: 'a1' }];
|
|
168
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(evals);
|
|
169
|
+
const result = yield client.listEvaluations('proj1', 'a1');
|
|
170
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations');
|
|
171
|
+
(0, vitest_1.expect)(result).toEqual(evals);
|
|
172
|
+
}));
|
|
173
|
+
(0, vitest_1.it)('createEvaluation should call POST .../evaluations with body', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
174
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
175
|
+
const body = { title: 'My Eval', prompts: [] };
|
|
176
|
+
const created = { evalUuid: 'e1' };
|
|
177
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(created);
|
|
178
|
+
const result = yield client.createEvaluation('proj1', 'a1', body);
|
|
179
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations', body);
|
|
180
|
+
(0, vitest_1.expect)(result).toEqual(created);
|
|
181
|
+
}));
|
|
182
|
+
(0, vitest_1.it)('getEvaluation should call GET .../evaluations/{evalUuid}', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
183
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
184
|
+
const evaluation = { evalUuid: 'e1', title: 'My Eval', prompts: [] };
|
|
185
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(evaluation);
|
|
186
|
+
const result = yield client.getEvaluation('proj1', 'a1', 'e1');
|
|
187
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1');
|
|
188
|
+
(0, vitest_1.expect)(result).toEqual(evaluation);
|
|
189
|
+
}));
|
|
190
|
+
(0, vitest_1.it)('updateEvaluation should call PATCH .../evaluations/{evalUuid}', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
191
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
192
|
+
const body = { title: 'Updated Eval' };
|
|
193
|
+
const updated = { evalUuid: 'e1', title: 'Updated Eval', prompts: [] };
|
|
194
|
+
vitest_1.vi.mocked(mockHttp.patch).mockResolvedValue(updated);
|
|
195
|
+
const result = yield client.updateEvaluation('proj1', 'a1', 'e1', body);
|
|
196
|
+
(0, vitest_1.expect)(mockHttp.patch).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1', body);
|
|
197
|
+
(0, vitest_1.expect)(result).toEqual(updated);
|
|
198
|
+
}));
|
|
199
|
+
(0, vitest_1.it)('appendToEvaluation should call POST .../evaluations/{evalUuid}/append', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
200
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
201
|
+
const body = { prompts: [{ prompt: 'Extra?', expectedResponse: null }] };
|
|
202
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(undefined);
|
|
203
|
+
yield client.appendToEvaluation('proj1', 'a1', 'e1', body);
|
|
204
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1/append', body);
|
|
205
|
+
}));
|
|
206
|
+
(0, vitest_1.it)('deleteEvaluation should call DELETE .../evaluations/{evalUuid}', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
207
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
208
|
+
vitest_1.vi.mocked(mockHttp.delete).mockResolvedValue(undefined);
|
|
209
|
+
yield client.deleteEvaluation('proj1', 'a1', 'e1');
|
|
210
|
+
(0, vitest_1.expect)(mockHttp.delete).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1');
|
|
211
|
+
}));
|
|
212
|
+
// ─── Project-scoped: evaluation runs ─────────────────────────────────────────
|
|
213
|
+
(0, vitest_1.it)('runEvaluation should call POST .../evaluations/{evalUuid}/run', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
214
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
215
|
+
const runSummary = { runUuid: 'r1', evalUuid: 'e1', status: 'pending' };
|
|
216
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(runSummary);
|
|
217
|
+
const result = yield client.runEvaluation('proj1', 'a1', 'e1');
|
|
218
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1/run', {});
|
|
219
|
+
(0, vitest_1.expect)(result).toEqual(runSummary);
|
|
220
|
+
}));
|
|
221
|
+
(0, vitest_1.it)('listEvaluationRuns should call GET .../evaluations/{evalUuid}/runs and unwrap runs array', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
222
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
223
|
+
const runs = [{ runUuid: 'r1', evalUuid: 'e1', status: 'completed' }];
|
|
224
|
+
const pagedResponse = { data: { runs }, pagination: undefined };
|
|
225
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(pagedResponse);
|
|
226
|
+
const result = yield client.listEvaluationRuns('proj1', 'a1', 'e1');
|
|
227
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1/runs');
|
|
228
|
+
(0, vitest_1.expect)(result).toEqual(runs);
|
|
229
|
+
}));
|
|
230
|
+
(0, vitest_1.it)('getEvaluationRunResults should call GET .../evaluations/{evalUuid}/runs/{runUuid}', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
231
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
232
|
+
const run = { runUuid: 'r1', evalUuid: 'e1', results: [] };
|
|
233
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(run);
|
|
234
|
+
const result = yield client.getEvaluationRunResults('proj1', 'a1', 'e1', 'r1');
|
|
235
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1/runs/r1');
|
|
236
|
+
(0, vitest_1.expect)(result).toEqual(run);
|
|
237
|
+
}));
|
|
77
238
|
});
|
package/dist/client.d.ts
CHANGED
|
@@ -71,72 +71,7 @@ export declare class LightdashClient {
|
|
|
71
71
|
private readonly httpV2;
|
|
72
72
|
readonly v1: V1ApiClients;
|
|
73
73
|
readonly v2: V2ApiClients;
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated Use `client.v1.projects` instead. This alias will be removed in a future major version.
|
|
76
|
-
*/
|
|
77
|
-
readonly projects: ProjectsClient;
|
|
78
|
-
/**
|
|
79
|
-
* @deprecated Use `client.v1.organizations` instead. This alias will be removed in a future major version.
|
|
80
|
-
*/
|
|
81
|
-
readonly organizations: OrganizationsClient;
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated Use `client.v1.charts` instead. This alias will be removed in a future major version.
|
|
84
|
-
*/
|
|
85
|
-
readonly charts: ChartsClient;
|
|
86
|
-
/**
|
|
87
|
-
* @deprecated Use `client.v1.dashboards` instead. This alias will be removed in a future major version.
|
|
88
|
-
*/
|
|
89
|
-
readonly dashboards: DashboardsClient;
|
|
90
|
-
/**
|
|
91
|
-
* @deprecated Use `client.v1.spaces` instead. This alias will be removed in a future major version.
|
|
92
|
-
*/
|
|
93
|
-
readonly spaces: SpacesClient;
|
|
94
|
-
/**
|
|
95
|
-
* @deprecated Use `client.v1.query` instead. This alias will be removed in a future major version.
|
|
96
|
-
*/
|
|
97
|
-
readonly query: QueryClient;
|
|
98
|
-
/**
|
|
99
|
-
* @deprecated Use `client.v1.users` instead. This alias will be removed in a future major version.
|
|
100
|
-
*/
|
|
101
|
-
readonly users: UsersClient;
|
|
102
|
-
/**
|
|
103
|
-
* @deprecated Use `client.v1.groups` instead. This alias will be removed in a future major version.
|
|
104
|
-
*/
|
|
105
|
-
readonly groups: GroupsClient;
|
|
106
|
-
/**
|
|
107
|
-
* @deprecated Use `client.v1.aiAgents` instead. This alias will be removed in a future major version.
|
|
108
|
-
*/
|
|
109
|
-
readonly aiAgents: AiAgentsClient;
|
|
110
|
-
/**
|
|
111
|
-
* @deprecated Use `client.v1.explores` instead. This alias will be removed in a future major version.
|
|
112
|
-
*/
|
|
113
|
-
readonly explores: ExploresClient;
|
|
114
|
-
/**
|
|
115
|
-
* @deprecated Use `client.v1.validation` instead. This alias will be removed in a future major version.
|
|
116
|
-
*/
|
|
117
|
-
readonly validation: ValidationClient;
|
|
118
|
-
/**
|
|
119
|
-
* @deprecated Use `client.v1.metrics` instead. This alias will be removed in a future major version.
|
|
120
|
-
*/
|
|
121
|
-
readonly metrics: MetricsClient;
|
|
122
|
-
/**
|
|
123
|
-
* @deprecated Use `client.v1.schedulers` instead. This alias will be removed in a future major version.
|
|
124
|
-
*/
|
|
125
|
-
readonly schedulers: SchedulersClient;
|
|
126
|
-
/**
|
|
127
|
-
* @deprecated Use `client.v1.tags` instead. This alias will be removed in a future major version.
|
|
128
|
-
*/
|
|
129
|
-
readonly tags: TagsClient;
|
|
130
|
-
/**
|
|
131
|
-
* @deprecated Use `client.v2.content` instead. This alias will be removed in a future major version.
|
|
132
|
-
*/
|
|
133
|
-
readonly content: ContentClient;
|
|
134
74
|
constructor(config?: PartialLightdashClientConfig);
|
|
135
|
-
/**
|
|
136
|
-
* Low-level HTTP client for custom v1 requests. Prefer domain methods (e.g. v1.projects, v1.charts) when available.
|
|
137
|
-
* @deprecated Use `getHttpClientV1()` instead. This method will be removed in a future major version.
|
|
138
|
-
*/
|
|
139
|
-
getHttpClient(): HttpClient;
|
|
140
75
|
/**
|
|
141
76
|
* Low-level HTTP client for custom v1 requests. Prefer domain methods (e.g. v1.projects, v1.charts) when available.
|
|
142
77
|
*/
|
package/dist/client.js
CHANGED
|
@@ -88,29 +88,6 @@ class LightdashClient {
|
|
|
88
88
|
// Create versioned namespaces
|
|
89
89
|
this.v1 = new V1ApiClients(this.httpV1);
|
|
90
90
|
this.v2 = new V2ApiClients(this.httpV2);
|
|
91
|
-
// Backward compatibility: deprecated aliases delegate to v1
|
|
92
|
-
this.projects = this.v1.projects;
|
|
93
|
-
this.organizations = this.v1.organizations;
|
|
94
|
-
this.charts = this.v1.charts;
|
|
95
|
-
this.dashboards = this.v1.dashboards;
|
|
96
|
-
this.spaces = this.v1.spaces;
|
|
97
|
-
this.query = this.v1.query;
|
|
98
|
-
this.users = this.v1.users;
|
|
99
|
-
this.groups = this.v1.groups;
|
|
100
|
-
this.aiAgents = this.v1.aiAgents;
|
|
101
|
-
this.explores = this.v1.explores;
|
|
102
|
-
this.validation = this.v1.validation;
|
|
103
|
-
this.metrics = this.v1.metrics;
|
|
104
|
-
this.schedulers = this.v1.schedulers;
|
|
105
|
-
this.tags = this.v1.tags;
|
|
106
|
-
this.content = this.v2.content;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Low-level HTTP client for custom v1 requests. Prefer domain methods (e.g. v1.projects, v1.charts) when available.
|
|
110
|
-
* @deprecated Use `getHttpClientV1()` instead. This method will be removed in a future major version.
|
|
111
|
-
*/
|
|
112
|
-
getHttpClient() {
|
|
113
|
-
return this.httpV1;
|
|
114
91
|
}
|
|
115
92
|
/**
|
|
116
93
|
* Low-level HTTP client for custom v1 requests. Prefer domain methods (e.g. v1.projects, v1.charts) when available.
|
package/dist/client.test.js
CHANGED
|
@@ -47,34 +47,6 @@ const client_1 = require("./client");
|
|
|
47
47
|
(0, vitest_1.expect)(typeof client.v2.query.runSqlQuery).toBe('function');
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
|
-
(0, vitest_1.describe)('Backward compatibility (deprecated aliases)', () => {
|
|
51
|
-
(0, vitest_1.it)('should expose deprecated top-level aliases that delegate to v1', () => {
|
|
52
|
-
const client = new client_1.LightdashClient(config);
|
|
53
|
-
(0, vitest_1.expect)(client.projects).toBeDefined();
|
|
54
|
-
(0, vitest_1.expect)(client.organizations).toBeDefined();
|
|
55
|
-
(0, vitest_1.expect)(client.charts).toBeDefined();
|
|
56
|
-
(0, vitest_1.expect)(client.dashboards).toBeDefined();
|
|
57
|
-
(0, vitest_1.expect)(client.spaces).toBeDefined();
|
|
58
|
-
(0, vitest_1.expect)(client.query).toBeDefined();
|
|
59
|
-
(0, vitest_1.expect)(client.users).toBeDefined();
|
|
60
|
-
(0, vitest_1.expect)(client.groups).toBeDefined();
|
|
61
|
-
});
|
|
62
|
-
(0, vitest_1.it)('deprecated aliases should reference v1 clients', () => {
|
|
63
|
-
const client = new client_1.LightdashClient(config);
|
|
64
|
-
(0, vitest_1.expect)(client.projects).toBe(client.v1.projects);
|
|
65
|
-
(0, vitest_1.expect)(client.organizations).toBe(client.v1.organizations);
|
|
66
|
-
(0, vitest_1.expect)(client.charts).toBe(client.v1.charts);
|
|
67
|
-
(0, vitest_1.expect)(client.dashboards).toBe(client.v1.dashboards);
|
|
68
|
-
(0, vitest_1.expect)(client.spaces).toBe(client.v1.spaces);
|
|
69
|
-
(0, vitest_1.expect)(client.query).toBe(client.v1.query);
|
|
70
|
-
(0, vitest_1.expect)(client.users).toBe(client.v1.users);
|
|
71
|
-
(0, vitest_1.expect)(client.groups).toBe(client.v1.groups);
|
|
72
|
-
});
|
|
73
|
-
(0, vitest_1.it)('deprecated projects.getProject should work', () => {
|
|
74
|
-
const client = new client_1.LightdashClient(config);
|
|
75
|
-
(0, vitest_1.expect)(typeof client.projects.getProject).toBe('function');
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
50
|
(0, vitest_1.describe)('HTTP clients', () => {
|
|
79
51
|
(0, vitest_1.it)('should provide separate HTTP clients for v1 and v2', () => {
|
|
80
52
|
const client = new client_1.LightdashClient(config);
|
|
@@ -84,11 +56,5 @@ const client_1 = require("./client");
|
|
|
84
56
|
(0, vitest_1.expect)(httpV2).toBeDefined();
|
|
85
57
|
(0, vitest_1.expect)(httpV1).not.toBe(httpV2);
|
|
86
58
|
});
|
|
87
|
-
(0, vitest_1.it)('getHttpClient should return v1 client (deprecated)', () => {
|
|
88
|
-
const client = new client_1.LightdashClient(config);
|
|
89
|
-
const http = client.getHttpClient();
|
|
90
|
-
const httpV1 = client.getHttpClientV1();
|
|
91
|
-
(0, vitest_1.expect)(http).toBe(httpV1);
|
|
92
|
-
});
|
|
93
59
|
});
|
|
94
60
|
});
|
package/dist/index.test.js
CHANGED
|
@@ -16,7 +16,7 @@ const index_1 = require("./index");
|
|
|
16
16
|
baseUrl: 'https://app.lightdash.cloud',
|
|
17
17
|
personalAccessToken: 'test-token',
|
|
18
18
|
});
|
|
19
|
-
(0, vitest_1.expect)(client.
|
|
19
|
+
(0, vitest_1.expect)(client.getHttpClientV1()).toBeDefined();
|
|
20
20
|
});
|
|
21
21
|
(0, vitest_1.it)('should throw when baseUrl and personalAccessToken are missing and not in env', () => {
|
|
22
22
|
(0, vitest_1.expect)(() => new index_1.LightdashClient({})).toThrow(/baseUrl and personalAccessToken|LIGHTDASH_URL and LIGHTDASH_API_KEY/);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash-tools/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Client library for Lightdash AI.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"axios": "^1.13.5",
|
|
12
12
|
"bottleneck": "^2.19.5",
|
|
13
|
-
"@lightdash-tools/common": "0.
|
|
13
|
+
"@lightdash-tools/common": "0.3.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/node": "^25.2.3"
|
|
@@ -15,6 +15,8 @@ describe('AiAgentsClient', () => {
|
|
|
15
15
|
} as unknown as HttpClient;
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
// ─── Admin ───────────────────────────────────────────────────────────────────
|
|
19
|
+
|
|
18
20
|
it('getAdminThreads should call GET /aiAgents/admin/threads with optional params', async () => {
|
|
19
21
|
const client = new AiAgentsClient(mockHttp);
|
|
20
22
|
const results = { data: [], pagination: { totalResults: 0, totalPageCount: 0 } };
|
|
@@ -71,4 +73,193 @@ describe('AiAgentsClient', () => {
|
|
|
71
73
|
expect(mockHttp.patch).toHaveBeenCalledWith('/aiAgents/admin/settings', body);
|
|
72
74
|
expect(result).toEqual(updated);
|
|
73
75
|
});
|
|
76
|
+
|
|
77
|
+
// ─── Project-scoped: agent CRUD ──────────────────────────────────────────────
|
|
78
|
+
|
|
79
|
+
it('listAgents should call GET /projects/{projectUuid}/aiAgents', async () => {
|
|
80
|
+
const client = new AiAgentsClient(mockHttp);
|
|
81
|
+
const list = [{ uuid: 'a1', name: 'Agent 1' }];
|
|
82
|
+
vi.mocked(mockHttp.get).mockResolvedValue(list);
|
|
83
|
+
const result = await client.listAgents('proj1');
|
|
84
|
+
expect(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents');
|
|
85
|
+
expect(result).toEqual(list);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('getAgent should call GET /projects/{projectUuid}/aiAgents/{agentUuid}', async () => {
|
|
89
|
+
const client = new AiAgentsClient(mockHttp);
|
|
90
|
+
const agent = { uuid: 'a1', name: 'Agent 1', projectUuid: 'proj1' };
|
|
91
|
+
vi.mocked(mockHttp.get).mockResolvedValue(agent);
|
|
92
|
+
const result = await client.getAgent('proj1', 'a1');
|
|
93
|
+
expect(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1');
|
|
94
|
+
expect(result).toEqual(agent);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('createAgent should call POST /projects/{projectUuid}/aiAgents with body', async () => {
|
|
98
|
+
const client = new AiAgentsClient(mockHttp);
|
|
99
|
+
const body = { name: 'New Agent', projectUuid: 'proj1' } as never;
|
|
100
|
+
const created = { uuid: 'a2', name: 'New Agent', projectUuid: 'proj1' };
|
|
101
|
+
vi.mocked(mockHttp.post).mockResolvedValue(created);
|
|
102
|
+
const result = await client.createAgent('proj1', body);
|
|
103
|
+
expect(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents', body);
|
|
104
|
+
expect(result).toEqual(created);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('updateAgent should call PATCH /projects/{projectUuid}/aiAgents/{agentUuid} with body', async () => {
|
|
108
|
+
const client = new AiAgentsClient(mockHttp);
|
|
109
|
+
const body = { name: 'Updated Agent' } as never;
|
|
110
|
+
const updated = { uuid: 'a1', name: 'Updated Agent', projectUuid: 'proj1' };
|
|
111
|
+
vi.mocked(mockHttp.patch).mockResolvedValue(updated);
|
|
112
|
+
const result = await client.updateAgent('proj1', 'a1', body);
|
|
113
|
+
expect(mockHttp.patch).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1', body);
|
|
114
|
+
expect(result).toEqual(updated);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('deleteAgent should call DELETE /projects/{projectUuid}/aiAgents/{agentUuid}', async () => {
|
|
118
|
+
const client = new AiAgentsClient(mockHttp);
|
|
119
|
+
vi.mocked(mockHttp.delete).mockResolvedValue(undefined);
|
|
120
|
+
await client.deleteAgent('proj1', 'a1');
|
|
121
|
+
expect(mockHttp.delete).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// ─── Project-scoped: threads ─────────────────────────────────────────────────
|
|
125
|
+
|
|
126
|
+
it('listAgentThreads should call GET /projects/{projectUuid}/aiAgents/{agentUuid}/threads', async () => {
|
|
127
|
+
const client = new AiAgentsClient(mockHttp);
|
|
128
|
+
const threads = [{ uuid: 't1', title: 'Thread 1' }];
|
|
129
|
+
vi.mocked(mockHttp.get).mockResolvedValue(threads);
|
|
130
|
+
const result = await client.listAgentThreads('proj1', 'a1');
|
|
131
|
+
expect(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads');
|
|
132
|
+
expect(result).toEqual(threads);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('createAgentThread should call POST /projects/{projectUuid}/aiAgents/{agentUuid}/threads', async () => {
|
|
136
|
+
const client = new AiAgentsClient(mockHttp);
|
|
137
|
+
const thread = { uuid: 't1', title: null };
|
|
138
|
+
vi.mocked(mockHttp.post).mockResolvedValue(thread);
|
|
139
|
+
const result = await client.createAgentThread('proj1', 'a1');
|
|
140
|
+
expect(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads', {});
|
|
141
|
+
expect(result).toEqual(thread);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('createAgentThread with body should pass body to POST', async () => {
|
|
145
|
+
const client = new AiAgentsClient(mockHttp);
|
|
146
|
+
const body = { prompt: 'Hello' };
|
|
147
|
+
const thread = { uuid: 't1', title: null };
|
|
148
|
+
vi.mocked(mockHttp.post).mockResolvedValue(thread);
|
|
149
|
+
await client.createAgentThread('proj1', 'a1', body);
|
|
150
|
+
expect(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads', body);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('getAgentThread should call GET .../threads/{threadUuid}', async () => {
|
|
154
|
+
const client = new AiAgentsClient(mockHttp);
|
|
155
|
+
const thread = { uuid: 't1', messages: [] };
|
|
156
|
+
vi.mocked(mockHttp.get).mockResolvedValue(thread);
|
|
157
|
+
const result = await client.getAgentThread('proj1', 'a1', 't1');
|
|
158
|
+
expect(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads/t1');
|
|
159
|
+
expect(result).toEqual(thread);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('generateAgentThreadResponse should call POST .../threads/{threadUuid}/generate', async () => {
|
|
163
|
+
const client = new AiAgentsClient(mockHttp);
|
|
164
|
+
const response = { response: 'Here is your answer.' };
|
|
165
|
+
vi.mocked(mockHttp.post).mockResolvedValue(response);
|
|
166
|
+
const result = await client.generateAgentThreadResponse('proj1', 'a1', 't1', {
|
|
167
|
+
prompt: 'What is the total revenue?',
|
|
168
|
+
});
|
|
169
|
+
expect(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads/t1/generate', {
|
|
170
|
+
prompt: 'What is the total revenue?',
|
|
171
|
+
});
|
|
172
|
+
expect(result).toEqual(response);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// ─── Project-scoped: evaluations ─────────────────────────────────────────────
|
|
176
|
+
|
|
177
|
+
it('listEvaluations should call GET .../evaluations', async () => {
|
|
178
|
+
const client = new AiAgentsClient(mockHttp);
|
|
179
|
+
const evals = [{ evalUuid: 'e1', title: 'Eval 1', agentUuid: 'a1' }];
|
|
180
|
+
vi.mocked(mockHttp.get).mockResolvedValue(evals);
|
|
181
|
+
const result = await client.listEvaluations('proj1', 'a1');
|
|
182
|
+
expect(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations');
|
|
183
|
+
expect(result).toEqual(evals);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('createEvaluation should call POST .../evaluations with body', async () => {
|
|
187
|
+
const client = new AiAgentsClient(mockHttp);
|
|
188
|
+
const body = { title: 'My Eval', prompts: [] };
|
|
189
|
+
const created = { evalUuid: 'e1' };
|
|
190
|
+
vi.mocked(mockHttp.post).mockResolvedValue(created);
|
|
191
|
+
const result = await client.createEvaluation('proj1', 'a1', body);
|
|
192
|
+
expect(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations', body);
|
|
193
|
+
expect(result).toEqual(created);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it('getEvaluation should call GET .../evaluations/{evalUuid}', async () => {
|
|
197
|
+
const client = new AiAgentsClient(mockHttp);
|
|
198
|
+
const evaluation = { evalUuid: 'e1', title: 'My Eval', prompts: [] };
|
|
199
|
+
vi.mocked(mockHttp.get).mockResolvedValue(evaluation);
|
|
200
|
+
const result = await client.getEvaluation('proj1', 'a1', 'e1');
|
|
201
|
+
expect(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1');
|
|
202
|
+
expect(result).toEqual(evaluation);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('updateEvaluation should call PATCH .../evaluations/{evalUuid}', async () => {
|
|
206
|
+
const client = new AiAgentsClient(mockHttp);
|
|
207
|
+
const body = { title: 'Updated Eval' };
|
|
208
|
+
const updated = { evalUuid: 'e1', title: 'Updated Eval', prompts: [] };
|
|
209
|
+
vi.mocked(mockHttp.patch).mockResolvedValue(updated);
|
|
210
|
+
const result = await client.updateEvaluation('proj1', 'a1', 'e1', body);
|
|
211
|
+
expect(mockHttp.patch).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1', body);
|
|
212
|
+
expect(result).toEqual(updated);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('appendToEvaluation should call POST .../evaluations/{evalUuid}/append', async () => {
|
|
216
|
+
const client = new AiAgentsClient(mockHttp);
|
|
217
|
+
const body = { prompts: [{ prompt: 'Extra?', expectedResponse: null }] };
|
|
218
|
+
vi.mocked(mockHttp.post).mockResolvedValue(undefined);
|
|
219
|
+
await client.appendToEvaluation('proj1', 'a1', 'e1', body);
|
|
220
|
+
expect(mockHttp.post).toHaveBeenCalledWith(
|
|
221
|
+
'/projects/proj1/aiAgents/a1/evaluations/e1/append',
|
|
222
|
+
body,
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('deleteEvaluation should call DELETE .../evaluations/{evalUuid}', async () => {
|
|
227
|
+
const client = new AiAgentsClient(mockHttp);
|
|
228
|
+
vi.mocked(mockHttp.delete).mockResolvedValue(undefined);
|
|
229
|
+
await client.deleteEvaluation('proj1', 'a1', 'e1');
|
|
230
|
+
expect(mockHttp.delete).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1');
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// ─── Project-scoped: evaluation runs ─────────────────────────────────────────
|
|
234
|
+
|
|
235
|
+
it('runEvaluation should call POST .../evaluations/{evalUuid}/run', async () => {
|
|
236
|
+
const client = new AiAgentsClient(mockHttp);
|
|
237
|
+
const runSummary = { runUuid: 'r1', evalUuid: 'e1', status: 'pending' };
|
|
238
|
+
vi.mocked(mockHttp.post).mockResolvedValue(runSummary);
|
|
239
|
+
const result = await client.runEvaluation('proj1', 'a1', 'e1');
|
|
240
|
+
expect(mockHttp.post).toHaveBeenCalledWith(
|
|
241
|
+
'/projects/proj1/aiAgents/a1/evaluations/e1/run',
|
|
242
|
+
{},
|
|
243
|
+
);
|
|
244
|
+
expect(result).toEqual(runSummary);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('listEvaluationRuns should call GET .../evaluations/{evalUuid}/runs and unwrap runs array', async () => {
|
|
248
|
+
const client = new AiAgentsClient(mockHttp);
|
|
249
|
+
const runs = [{ runUuid: 'r1', evalUuid: 'e1', status: 'completed' }];
|
|
250
|
+
const pagedResponse = { data: { runs }, pagination: undefined };
|
|
251
|
+
vi.mocked(mockHttp.get).mockResolvedValue(pagedResponse);
|
|
252
|
+
const result = await client.listEvaluationRuns('proj1', 'a1', 'e1');
|
|
253
|
+
expect(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1/runs');
|
|
254
|
+
expect(result).toEqual(runs);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('getEvaluationRunResults should call GET .../evaluations/{evalUuid}/runs/{runUuid}', async () => {
|
|
258
|
+
const client = new AiAgentsClient(mockHttp);
|
|
259
|
+
const run = { runUuid: 'r1', evalUuid: 'e1', results: [] };
|
|
260
|
+
vi.mocked(mockHttp.get).mockResolvedValue(run);
|
|
261
|
+
const result = await client.getEvaluationRunResults('proj1', 'a1', 'e1', 'r1');
|
|
262
|
+
expect(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1/runs/r1');
|
|
263
|
+
expect(result).toEqual(run);
|
|
264
|
+
});
|
|
74
265
|
});
|
package/src/api/v1/ai-agents.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AI agents API client.
|
|
2
|
+
* AI agents API client.
|
|
3
|
+
*
|
|
4
|
+
* Admin endpoints → /api/v1/aiAgents/admin/...
|
|
5
|
+
* Project-scoped → /api/v1/projects/{projectUuid}/aiAgents/...
|
|
3
6
|
*/
|
|
4
7
|
|
|
5
8
|
import type {
|
|
@@ -9,24 +12,45 @@ import type {
|
|
|
9
12
|
GetAiOrganizationSettingsResult,
|
|
10
13
|
UpdateAiOrganizationSettings,
|
|
11
14
|
UpdateAiOrganizationSettingsResult,
|
|
15
|
+
AiAgent,
|
|
16
|
+
CreateAiAgent,
|
|
17
|
+
UpdateAiAgent,
|
|
18
|
+
AiAgentThreadSummary,
|
|
19
|
+
AiAgentThread,
|
|
20
|
+
CreateAgentThreadBody,
|
|
21
|
+
GenerateAgentThreadBody,
|
|
22
|
+
GenerateAgentThreadResult,
|
|
23
|
+
CreateEvaluationBody,
|
|
24
|
+
CreateEvaluationResult,
|
|
25
|
+
UpdateEvaluationBody,
|
|
26
|
+
AppendEvaluationBody,
|
|
27
|
+
AiAgentEvaluationSummary,
|
|
28
|
+
AiAgentEvaluation,
|
|
29
|
+
AiAgentEvaluationRunSummary,
|
|
30
|
+
AiAgentEvaluationRunsListResponse,
|
|
31
|
+
AiAgentEvaluationRun,
|
|
12
32
|
} from '@lightdash-tools/common';
|
|
13
33
|
import { BaseApiClient } from '../base-client';
|
|
14
34
|
|
|
15
35
|
export class AiAgentsClient extends BaseApiClient {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
36
|
+
// ─── Admin: threads ──────────────────────────────────────────────────────────
|
|
37
|
+
|
|
38
|
+
/** List all AI agent threads across the org (admin). Supports pagination and filters. */
|
|
19
39
|
async getAdminThreads(params?: GetAdminThreadsParams): Promise<AiAgentsAdminThreadsResult> {
|
|
20
40
|
return this.http.get<AiAgentsAdminThreadsResult>('/aiAgents/admin/threads', {
|
|
21
41
|
params,
|
|
22
42
|
});
|
|
23
43
|
}
|
|
24
44
|
|
|
25
|
-
|
|
45
|
+
// ─── Admin: agents ───────────────────────────────────────────────────────────
|
|
46
|
+
|
|
47
|
+
/** List all AI agents across the org (admin). */
|
|
26
48
|
async listAdminAgents(): Promise<AiAgentSummary[]> {
|
|
27
49
|
return this.http.get<AiAgentSummary[]>('/aiAgents/admin/agents');
|
|
28
50
|
}
|
|
29
51
|
|
|
52
|
+
// ─── Admin: settings ─────────────────────────────────────────────────────────
|
|
53
|
+
|
|
30
54
|
/** Get AI organization settings. */
|
|
31
55
|
async getAiOrganizationSettings(): Promise<GetAiOrganizationSettingsResult> {
|
|
32
56
|
return this.http.get<GetAiOrganizationSettingsResult>('/aiAgents/admin/settings');
|
|
@@ -38,4 +62,191 @@ export class AiAgentsClient extends BaseApiClient {
|
|
|
38
62
|
): Promise<UpdateAiOrganizationSettingsResult> {
|
|
39
63
|
return this.http.patch<UpdateAiOrganizationSettingsResult>('/aiAgents/admin/settings', body);
|
|
40
64
|
}
|
|
65
|
+
|
|
66
|
+
// ─── Project-scoped: agent CRUD ──────────────────────────────────────────────
|
|
67
|
+
|
|
68
|
+
/** List all agents in a project (GET /projects/{projectUuid}/aiAgents). */
|
|
69
|
+
async listAgents(projectUuid: string): Promise<AiAgentSummary[]> {
|
|
70
|
+
return this.http.get<AiAgentSummary[]>(`/projects/${projectUuid}/aiAgents`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Get a single agent by UUID (GET /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
74
|
+
async getAgent(projectUuid: string, agentUuid: string): Promise<AiAgent> {
|
|
75
|
+
return this.http.get<AiAgent>(`/projects/${projectUuid}/aiAgents/${agentUuid}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Create a new agent in a project (POST /projects/{projectUuid}/aiAgents). */
|
|
79
|
+
async createAgent(projectUuid: string, body: CreateAiAgent): Promise<AiAgent> {
|
|
80
|
+
return this.http.post<AiAgent>(`/projects/${projectUuid}/aiAgents`, body);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Update an existing agent (PATCH /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
84
|
+
async updateAgent(projectUuid: string, agentUuid: string, body: UpdateAiAgent): Promise<AiAgent> {
|
|
85
|
+
return this.http.patch<AiAgent>(`/projects/${projectUuid}/aiAgents/${agentUuid}`, body);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Delete an agent (DELETE /projects/{projectUuid}/aiAgents/{agentUuid}). */
|
|
89
|
+
async deleteAgent(projectUuid: string, agentUuid: string): Promise<void> {
|
|
90
|
+
await this.http.delete(`/projects/${projectUuid}/aiAgents/${agentUuid}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ─── Project-scoped: threads ─────────────────────────────────────────────────
|
|
94
|
+
|
|
95
|
+
/** List all threads for an agent (GET /projects/{projectUuid}/aiAgents/{agentUuid}/threads). */
|
|
96
|
+
async listAgentThreads(projectUuid: string, agentUuid: string): Promise<AiAgentThreadSummary[]> {
|
|
97
|
+
return this.http.get<AiAgentThreadSummary[]>(
|
|
98
|
+
`/projects/${projectUuid}/aiAgents/${agentUuid}/threads`,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Create a new thread (POST /projects/{projectUuid}/aiAgents/{agentUuid}/threads).
|
|
104
|
+
* Pass `prompt` in the body to trigger an immediate generation.
|
|
105
|
+
*/
|
|
106
|
+
async createAgentThread(
|
|
107
|
+
projectUuid: string,
|
|
108
|
+
agentUuid: string,
|
|
109
|
+
body?: CreateAgentThreadBody,
|
|
110
|
+
): Promise<AiAgentThreadSummary> {
|
|
111
|
+
return this.http.post<AiAgentThreadSummary>(
|
|
112
|
+
`/projects/${projectUuid}/aiAgents/${agentUuid}/threads`,
|
|
113
|
+
body ?? {},
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Get a thread with its messages (GET …/threads/{threadUuid}). */
|
|
118
|
+
async getAgentThread(
|
|
119
|
+
projectUuid: string,
|
|
120
|
+
agentUuid: string,
|
|
121
|
+
threadUuid: string,
|
|
122
|
+
): Promise<AiAgentThread> {
|
|
123
|
+
return this.http.get<AiAgentThread>(
|
|
124
|
+
`/projects/${projectUuid}/aiAgents/${agentUuid}/threads/${threadUuid}`,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Generate a response in a thread (POST …/threads/{threadUuid}/generate).
|
|
130
|
+
* Use this to send a prompt and receive the agent's reply.
|
|
131
|
+
*/
|
|
132
|
+
async generateAgentThreadResponse(
|
|
133
|
+
projectUuid: string,
|
|
134
|
+
agentUuid: string,
|
|
135
|
+
threadUuid: string,
|
|
136
|
+
body: GenerateAgentThreadBody,
|
|
137
|
+
): Promise<GenerateAgentThreadResult> {
|
|
138
|
+
return this.http.post<GenerateAgentThreadResult>(
|
|
139
|
+
`/projects/${projectUuid}/aiAgents/${agentUuid}/threads/${threadUuid}/generate`,
|
|
140
|
+
body,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ─── Project-scoped: evaluations ─────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
/** List all evaluations for an agent (GET …/{agentUuid}/evaluations). */
|
|
147
|
+
async listEvaluations(
|
|
148
|
+
projectUuid: string,
|
|
149
|
+
agentUuid: string,
|
|
150
|
+
): Promise<AiAgentEvaluationSummary[]> {
|
|
151
|
+
return this.http.get<AiAgentEvaluationSummary[]>(
|
|
152
|
+
`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations`,
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Create a new evaluation (POST …/{agentUuid}/evaluations). */
|
|
157
|
+
async createEvaluation(
|
|
158
|
+
projectUuid: string,
|
|
159
|
+
agentUuid: string,
|
|
160
|
+
body: CreateEvaluationBody,
|
|
161
|
+
): Promise<CreateEvaluationResult> {
|
|
162
|
+
return this.http.post<CreateEvaluationResult>(
|
|
163
|
+
`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations`,
|
|
164
|
+
body,
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Get a full evaluation with prompts (GET …/evaluations/{evalUuid}). */
|
|
169
|
+
async getEvaluation(
|
|
170
|
+
projectUuid: string,
|
|
171
|
+
agentUuid: string,
|
|
172
|
+
evalUuid: string,
|
|
173
|
+
): Promise<AiAgentEvaluation> {
|
|
174
|
+
return this.http.get<AiAgentEvaluation>(
|
|
175
|
+
`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}`,
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Update an evaluation's title, description, or prompts (PATCH …/evaluations/{evalUuid}). */
|
|
180
|
+
async updateEvaluation(
|
|
181
|
+
projectUuid: string,
|
|
182
|
+
agentUuid: string,
|
|
183
|
+
evalUuid: string,
|
|
184
|
+
body: UpdateEvaluationBody,
|
|
185
|
+
): Promise<AiAgentEvaluation> {
|
|
186
|
+
return this.http.patch<AiAgentEvaluation>(
|
|
187
|
+
`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}`,
|
|
188
|
+
body,
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Append additional prompts to an existing evaluation (POST …/evaluations/{evalUuid}/append). */
|
|
193
|
+
async appendToEvaluation(
|
|
194
|
+
projectUuid: string,
|
|
195
|
+
agentUuid: string,
|
|
196
|
+
evalUuid: string,
|
|
197
|
+
body: AppendEvaluationBody,
|
|
198
|
+
): Promise<void> {
|
|
199
|
+
await this.http.post(
|
|
200
|
+
`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}/append`,
|
|
201
|
+
body,
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Delete an evaluation (DELETE …/evaluations/{evalUuid}). */
|
|
206
|
+
async deleteEvaluation(projectUuid: string, agentUuid: string, evalUuid: string): Promise<void> {
|
|
207
|
+
await this.http.delete(
|
|
208
|
+
`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}`,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ─── Project-scoped: evaluation runs ─────────────────────────────────────────
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Trigger a new evaluation run (POST …/evaluations/{evalUuid}/run).
|
|
216
|
+
* Returns a run summary with the new runUuid and initial status.
|
|
217
|
+
*/
|
|
218
|
+
async runEvaluation(
|
|
219
|
+
projectUuid: string,
|
|
220
|
+
agentUuid: string,
|
|
221
|
+
evalUuid: string,
|
|
222
|
+
): Promise<AiAgentEvaluationRunSummary> {
|
|
223
|
+
return this.http.post<AiAgentEvaluationRunSummary>(
|
|
224
|
+
`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}/run`,
|
|
225
|
+
{},
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** List all runs for an evaluation (GET …/evaluations/{evalUuid}/runs). */
|
|
230
|
+
async listEvaluationRuns(
|
|
231
|
+
projectUuid: string,
|
|
232
|
+
agentUuid: string,
|
|
233
|
+
evalUuid: string,
|
|
234
|
+
): Promise<AiAgentEvaluationRunSummary[]> {
|
|
235
|
+
const response = await this.http.get<AiAgentEvaluationRunsListResponse>(
|
|
236
|
+
`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}/runs`,
|
|
237
|
+
);
|
|
238
|
+
return response.data.runs;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Get detailed results of a specific run (GET …/evaluations/{evalUuid}/runs/{runUuid}). */
|
|
242
|
+
async getEvaluationRunResults(
|
|
243
|
+
projectUuid: string,
|
|
244
|
+
agentUuid: string,
|
|
245
|
+
evalUuid: string,
|
|
246
|
+
runUuid: string,
|
|
247
|
+
): Promise<AiAgentEvaluationRun> {
|
|
248
|
+
return this.http.get<AiAgentEvaluationRun>(
|
|
249
|
+
`/projects/${projectUuid}/aiAgents/${agentUuid}/evaluations/${evalUuid}/runs/${runUuid}`,
|
|
250
|
+
);
|
|
251
|
+
}
|
|
41
252
|
}
|
package/src/client.test.ts
CHANGED
|
@@ -54,37 +54,6 @@ describe('LightdashClient', () => {
|
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
describe('Backward compatibility (deprecated aliases)', () => {
|
|
58
|
-
it('should expose deprecated top-level aliases that delegate to v1', () => {
|
|
59
|
-
const client = new LightdashClient(config);
|
|
60
|
-
expect(client.projects).toBeDefined();
|
|
61
|
-
expect(client.organizations).toBeDefined();
|
|
62
|
-
expect(client.charts).toBeDefined();
|
|
63
|
-
expect(client.dashboards).toBeDefined();
|
|
64
|
-
expect(client.spaces).toBeDefined();
|
|
65
|
-
expect(client.query).toBeDefined();
|
|
66
|
-
expect(client.users).toBeDefined();
|
|
67
|
-
expect(client.groups).toBeDefined();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('deprecated aliases should reference v1 clients', () => {
|
|
71
|
-
const client = new LightdashClient(config);
|
|
72
|
-
expect(client.projects).toBe(client.v1.projects);
|
|
73
|
-
expect(client.organizations).toBe(client.v1.organizations);
|
|
74
|
-
expect(client.charts).toBe(client.v1.charts);
|
|
75
|
-
expect(client.dashboards).toBe(client.v1.dashboards);
|
|
76
|
-
expect(client.spaces).toBe(client.v1.spaces);
|
|
77
|
-
expect(client.query).toBe(client.v1.query);
|
|
78
|
-
expect(client.users).toBe(client.v1.users);
|
|
79
|
-
expect(client.groups).toBe(client.v1.groups);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('deprecated projects.getProject should work', () => {
|
|
83
|
-
const client = new LightdashClient(config);
|
|
84
|
-
expect(typeof client.projects.getProject).toBe('function');
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
57
|
describe('HTTP clients', () => {
|
|
89
58
|
it('should provide separate HTTP clients for v1 and v2', () => {
|
|
90
59
|
const client = new LightdashClient(config);
|
|
@@ -94,12 +63,5 @@ describe('LightdashClient', () => {
|
|
|
94
63
|
expect(httpV2).toBeDefined();
|
|
95
64
|
expect(httpV1).not.toBe(httpV2);
|
|
96
65
|
});
|
|
97
|
-
|
|
98
|
-
it('getHttpClient should return v1 client (deprecated)', () => {
|
|
99
|
-
const client = new LightdashClient(config);
|
|
100
|
-
const http = client.getHttpClient();
|
|
101
|
-
const httpV1 = client.getHttpClientV1();
|
|
102
|
-
expect(http).toBe(httpV1);
|
|
103
|
-
});
|
|
104
66
|
});
|
|
105
67
|
});
|
package/src/client.ts
CHANGED
|
@@ -103,67 +103,6 @@ export class LightdashClient {
|
|
|
103
103
|
readonly v1: V1ApiClients;
|
|
104
104
|
readonly v2: V2ApiClients;
|
|
105
105
|
|
|
106
|
-
/**
|
|
107
|
-
* @deprecated Use `client.v1.projects` instead. This alias will be removed in a future major version.
|
|
108
|
-
*/
|
|
109
|
-
readonly projects: ProjectsClient;
|
|
110
|
-
/**
|
|
111
|
-
* @deprecated Use `client.v1.organizations` instead. This alias will be removed in a future major version.
|
|
112
|
-
*/
|
|
113
|
-
readonly organizations: OrganizationsClient;
|
|
114
|
-
/**
|
|
115
|
-
* @deprecated Use `client.v1.charts` instead. This alias will be removed in a future major version.
|
|
116
|
-
*/
|
|
117
|
-
readonly charts: ChartsClient;
|
|
118
|
-
/**
|
|
119
|
-
* @deprecated Use `client.v1.dashboards` instead. This alias will be removed in a future major version.
|
|
120
|
-
*/
|
|
121
|
-
readonly dashboards: DashboardsClient;
|
|
122
|
-
/**
|
|
123
|
-
* @deprecated Use `client.v1.spaces` instead. This alias will be removed in a future major version.
|
|
124
|
-
*/
|
|
125
|
-
readonly spaces: SpacesClient;
|
|
126
|
-
/**
|
|
127
|
-
* @deprecated Use `client.v1.query` instead. This alias will be removed in a future major version.
|
|
128
|
-
*/
|
|
129
|
-
readonly query: QueryClient;
|
|
130
|
-
/**
|
|
131
|
-
* @deprecated Use `client.v1.users` instead. This alias will be removed in a future major version.
|
|
132
|
-
*/
|
|
133
|
-
readonly users: UsersClient;
|
|
134
|
-
/**
|
|
135
|
-
* @deprecated Use `client.v1.groups` instead. This alias will be removed in a future major version.
|
|
136
|
-
*/
|
|
137
|
-
readonly groups: GroupsClient;
|
|
138
|
-
/**
|
|
139
|
-
* @deprecated Use `client.v1.aiAgents` instead. This alias will be removed in a future major version.
|
|
140
|
-
*/
|
|
141
|
-
readonly aiAgents: AiAgentsClient;
|
|
142
|
-
/**
|
|
143
|
-
* @deprecated Use `client.v1.explores` instead. This alias will be removed in a future major version.
|
|
144
|
-
*/
|
|
145
|
-
readonly explores: ExploresClient;
|
|
146
|
-
/**
|
|
147
|
-
* @deprecated Use `client.v1.validation` instead. This alias will be removed in a future major version.
|
|
148
|
-
*/
|
|
149
|
-
readonly validation: ValidationClient;
|
|
150
|
-
/**
|
|
151
|
-
* @deprecated Use `client.v1.metrics` instead. This alias will be removed in a future major version.
|
|
152
|
-
*/
|
|
153
|
-
readonly metrics: MetricsClient;
|
|
154
|
-
/**
|
|
155
|
-
* @deprecated Use `client.v1.schedulers` instead. This alias will be removed in a future major version.
|
|
156
|
-
*/
|
|
157
|
-
readonly schedulers: SchedulersClient;
|
|
158
|
-
/**
|
|
159
|
-
* @deprecated Use `client.v1.tags` instead. This alias will be removed in a future major version.
|
|
160
|
-
*/
|
|
161
|
-
readonly tags: TagsClient;
|
|
162
|
-
/**
|
|
163
|
-
* @deprecated Use `client.v2.content` instead. This alias will be removed in a future major version.
|
|
164
|
-
*/
|
|
165
|
-
readonly content: ContentClient;
|
|
166
|
-
|
|
167
106
|
constructor(config?: PartialLightdashClientConfig) {
|
|
168
107
|
const merged = mergeConfig(config);
|
|
169
108
|
const rateLimiter = new RateLimiter(merged.rateLimit);
|
|
@@ -179,31 +118,6 @@ export class LightdashClient {
|
|
|
179
118
|
// Create versioned namespaces
|
|
180
119
|
this.v1 = new V1ApiClients(this.httpV1);
|
|
181
120
|
this.v2 = new V2ApiClients(this.httpV2);
|
|
182
|
-
|
|
183
|
-
// Backward compatibility: deprecated aliases delegate to v1
|
|
184
|
-
this.projects = this.v1.projects;
|
|
185
|
-
this.organizations = this.v1.organizations;
|
|
186
|
-
this.charts = this.v1.charts;
|
|
187
|
-
this.dashboards = this.v1.dashboards;
|
|
188
|
-
this.spaces = this.v1.spaces;
|
|
189
|
-
this.query = this.v1.query;
|
|
190
|
-
this.users = this.v1.users;
|
|
191
|
-
this.groups = this.v1.groups;
|
|
192
|
-
this.aiAgents = this.v1.aiAgents;
|
|
193
|
-
this.explores = this.v1.explores;
|
|
194
|
-
this.validation = this.v1.validation;
|
|
195
|
-
this.metrics = this.v1.metrics;
|
|
196
|
-
this.schedulers = this.v1.schedulers;
|
|
197
|
-
this.tags = this.v1.tags;
|
|
198
|
-
this.content = this.v2.content;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Low-level HTTP client for custom v1 requests. Prefer domain methods (e.g. v1.projects, v1.charts) when available.
|
|
203
|
-
* @deprecated Use `getHttpClientV1()` instead. This method will be removed in a future major version.
|
|
204
|
-
*/
|
|
205
|
-
getHttpClient(): HttpClient {
|
|
206
|
-
return this.httpV1;
|
|
207
121
|
}
|
|
208
122
|
|
|
209
123
|
/**
|
package/src/index.test.ts
CHANGED
|
@@ -28,7 +28,7 @@ describe('LightdashClient', () => {
|
|
|
28
28
|
baseUrl: 'https://app.lightdash.cloud',
|
|
29
29
|
personalAccessToken: 'test-token',
|
|
30
30
|
});
|
|
31
|
-
expect(client.
|
|
31
|
+
expect(client.getHttpClientV1()).toBeDefined();
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
it('should throw when baseUrl and personalAccessToken are missing and not in env', () => {
|