@lightdash-tools/client 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/agentops/apply-agent-change.d.ts +3 -0
- package/dist/agentops/apply-agent-change.js +63 -0
- package/dist/agentops/apply-bundle-diff.d.ts +13 -0
- package/dist/agentops/apply-bundle-diff.js +44 -0
- package/dist/agentops/apply-bundle-diff.test.d.ts +1 -0
- package/dist/agentops/apply-bundle-diff.test.js +397 -0
- package/dist/agentops/apply-context.d.ts +14 -0
- package/dist/agentops/apply-context.js +6 -0
- package/dist/agentops/apply-evaluation-change.d.ts +3 -0
- package/dist/agentops/apply-evaluation-change.js +78 -0
- package/dist/agentops/fetch-bundle-state.d.ts +6 -0
- package/dist/agentops/fetch-bundle-state.js +20 -0
- package/dist/agentops/fetch-bundle-state.test.d.ts +1 -0
- package/dist/agentops/fetch-bundle-state.test.js +44 -0
- package/dist/agentops/index.d.ts +3 -0
- package/dist/agentops/index.js +9 -0
- package/dist/agentops/resolve-evaluation-run.d.ts +15 -0
- package/dist/agentops/resolve-evaluation-run.js +48 -0
- package/dist/api/v1/ai-agents/admin.d.ts +16 -0
- package/dist/api/v1/ai-agents/admin.js +29 -0
- package/dist/api/v1/ai-agents/agents.d.ts +18 -0
- package/dist/api/v1/ai-agents/agents.js +31 -0
- package/dist/api/v1/ai-agents/artifacts.d.ts +26 -0
- package/dist/api/v1/ai-agents/artifacts.js +41 -0
- package/dist/api/v1/ai-agents/artifacts.test.d.ts +1 -0
- package/dist/api/v1/ai-agents/artifacts.test.js +69 -0
- package/dist/api/v1/ai-agents/discovery.d.ts +28 -0
- package/dist/api/v1/ai-agents/discovery.js +46 -0
- package/dist/api/v1/ai-agents/discovery.test.d.ts +1 -0
- package/dist/api/v1/ai-agents/discovery.test.js +90 -0
- package/dist/api/v1/ai-agents/evaluations.d.ts +39 -0
- package/dist/api/v1/ai-agents/evaluations.js +70 -0
- package/dist/api/v1/ai-agents/facade.d.ts +79 -0
- package/dist/api/v1/ai-agents/facade.js +193 -0
- package/dist/api/v1/ai-agents/feedback.d.ts +10 -0
- package/dist/api/v1/ai-agents/feedback.js +15 -0
- package/dist/api/v1/ai-agents/feedback.test.d.ts +1 -0
- package/dist/api/v1/ai-agents/feedback.test.js +23 -0
- package/dist/api/v1/ai-agents/index.d.ts +1 -0
- package/dist/api/v1/ai-agents/index.js +5 -0
- package/dist/api/v1/ai-agents/mcp-servers.d.ts +20 -0
- package/dist/api/v1/ai-agents/mcp-servers.js +35 -0
- package/dist/api/v1/ai-agents/mcp-servers.test.d.ts +1 -0
- package/dist/api/v1/ai-agents/mcp-servers.test.js +66 -0
- package/dist/api/v1/ai-agents/request-options.d.ts +12 -0
- package/dist/api/v1/ai-agents/request-options.js +20 -0
- package/dist/api/v1/ai-agents/sql-approval.d.ts +10 -0
- package/dist/api/v1/ai-agents/sql-approval.js +15 -0
- package/dist/api/v1/ai-agents/sql-approval.test.d.ts +1 -0
- package/dist/api/v1/ai-agents/sql-approval.test.js +25 -0
- package/dist/api/v1/ai-agents/threads.d.ts +56 -0
- package/dist/api/v1/ai-agents/threads.js +97 -0
- package/dist/api/v1/ai-agents/threads.test.d.ts +1 -0
- package/dist/api/v1/ai-agents/threads.test.js +39 -0
- package/dist/api/v1/ai-agents.test.js +172 -89
- package/dist/api/v1/analytics.d.ts +10 -0
- package/dist/api/v1/analytics.js +14 -0
- package/dist/api/v1/analytics.test.d.ts +4 -0
- package/dist/api/v1/analytics.test.js +27 -0
- package/dist/api/v1/charts.d.ts +13 -2
- package/dist/api/v1/charts.js +26 -30
- package/dist/api/v1/charts.test.js +35 -28
- package/dist/api/v1/dashboards.d.ts +42 -2
- package/dist/api/v1/dashboards.js +39 -14
- package/dist/api/v1/dashboards.test.js +126 -12
- package/dist/api/v1/explores.d.ts +4 -2
- package/dist/api/v1/explores.js +20 -29
- package/dist/api/v1/explores.test.js +31 -21
- package/dist/api/v1/groups.d.ts +1 -1
- package/dist/api/v1/groups.js +25 -51
- package/dist/api/v1/groups.test.js +15 -24
- package/dist/api/v1/metrics.d.ts +2 -2
- package/dist/api/v1/metrics.js +4 -17
- package/dist/api/v1/metrics.test.js +6 -15
- package/dist/api/v1/organizations.d.ts +1 -1
- package/dist/api/v1/organizations.js +2 -13
- package/dist/api/v1/organizations.test.js +3 -12
- package/dist/api/v1/project-access.d.ts +1 -1
- package/dist/api/v1/project-access.js +18 -45
- package/dist/api/v1/project-access.test.js +27 -36
- package/dist/api/v1/projects.d.ts +1 -1
- package/dist/api/v1/projects.js +6 -21
- package/dist/api/v1/projects.test.js +9 -18
- package/dist/api/v1/query.d.ts +5 -2
- package/dist/api/v1/query.js +8 -18
- package/dist/api/v1/query.test.js +6 -15
- package/dist/api/v1/schedulers.d.ts +2 -2
- package/dist/api/v1/schedulers.js +4 -17
- package/dist/api/v1/schedulers.test.js +6 -15
- package/dist/api/v1/spaces.d.ts +1 -1
- package/dist/api/v1/spaces.js +18 -45
- package/dist/api/v1/spaces.test.js +27 -36
- package/dist/api/v1/tags.d.ts +1 -1
- package/dist/api/v1/tags.js +4 -17
- package/dist/api/v1/tags.test.js +6 -15
- package/dist/api/v1/users.d.ts +3 -1
- package/dist/api/v1/users.js +22 -39
- package/dist/api/v1/users.test.js +44 -30
- package/dist/api/v1/validation.d.ts +9 -2
- package/dist/api/v1/validation.js +16 -18
- package/dist/api/v1/validation.test.js +22 -15
- package/dist/api/v2/charts.d.ts +12 -0
- package/dist/api/v2/charts.js +18 -0
- package/dist/api/v2/charts.test.d.ts +4 -0
- package/dist/api/v2/charts.test.js +45 -0
- package/dist/api/v2/content.d.ts +20 -3
- package/dist/api/v2/content.js +18 -14
- package/dist/api/v2/content.test.js +44 -12
- package/dist/api/v2/dashboards.d.ts +16 -0
- package/dist/api/v2/dashboards.js +22 -0
- package/dist/api/v2/dashboards.test.d.ts +4 -0
- package/dist/api/v2/dashboards.test.js +61 -0
- package/dist/api/v2/organization-roles.d.ts +1 -1
- package/dist/api/v2/organization-roles.js +21 -50
- package/dist/api/v2/organization-roles.test.js +33 -42
- package/dist/api/v2/parameters.d.ts +20 -0
- package/dist/api/v2/parameters.js +22 -0
- package/dist/api/v2/parameters.test.d.ts +4 -0
- package/dist/api/v2/parameters.test.js +39 -0
- package/dist/api/v2/project-role-assignments.d.ts +1 -1
- package/dist/api/v2/project-role-assignments.js +12 -33
- package/dist/api/v2/project-role-assignments.test.js +18 -27
- package/dist/api/v2/query.d.ts +16 -1
- package/dist/api/v2/query.js +26 -29
- package/dist/api/v2/query.test.js +31 -24
- package/dist/api/v2/validation.d.ts +28 -0
- package/dist/api/v2/validation.js +23 -0
- package/dist/client.d.ts +24 -14
- package/dist/client.js +26 -16
- package/dist/client.test.js +2 -0
- package/dist/config.d.ts +35 -10
- package/dist/http/axios-client.d.ts +4 -4
- package/dist/http/http-client.d.ts +3 -14
- package/dist/http/http-client.js +20 -43
- package/dist/http/interceptors.d.ts +3 -3
- package/dist/http/interceptors.js +16 -3
- package/dist/http/rate-limiter.js +2 -13
- package/dist/http/rate-limiter.test.js +15 -24
- package/dist/http/unwrap-api-success.d.ts +26 -0
- package/dist/http/unwrap-api-success.js +25 -0
- package/dist/http/unwrap-api-success.test.d.ts +1 -0
- package/dist/http/unwrap-api-success.test.js +19 -0
- package/dist/index.d.ts +13 -3
- package/dist/index.js +17 -1
- package/dist/index.test.js +13 -5
- package/dist/pagination/fetch-all-pages.js +18 -29
- package/dist/pagination/fetch-all-pages.test.js +15 -24
- package/dist/types/api.d.ts +1 -1
- package/dist/utils/env.d.ts +11 -2
- package/dist/utils/env.js +41 -8
- package/dist/utils/env.test.js +14 -4
- package/dist/utils/logger.js +5 -4
- package/dist/utils/retry.js +17 -28
- package/dist/utils/retry.test.js +9 -18
- package/dist/utils/secret-string.test.d.ts +1 -0
- package/dist/utils/secret-string.test.js +25 -0
- package/package.json +12 -4
- package/src/agentops/apply-agent-change.ts +82 -0
- package/src/agentops/apply-bundle-diff.test.ts +453 -0
- package/src/agentops/apply-bundle-diff.ts +63 -0
- package/src/agentops/apply-context.ts +23 -0
- package/src/agentops/apply-evaluation-change.ts +125 -0
- package/src/agentops/fetch-bundle-state.test.ts +51 -0
- package/src/agentops/fetch-bundle-state.ts +33 -0
- package/src/agentops/index.ts +11 -0
- package/src/agentops/resolve-evaluation-run.ts +94 -0
- package/src/api/v1/ai-agents/admin.ts +41 -0
- package/src/api/v1/ai-agents/agents.ts +40 -0
- package/src/api/v1/ai-agents/artifacts.test.ts +84 -0
- package/src/api/v1/ai-agents/artifacts.ts +92 -0
- package/src/api/v1/ai-agents/discovery.test.ts +102 -0
- package/src/api/v1/ai-agents/discovery.ts +79 -0
- package/src/api/v1/ai-agents/evaluations.ts +152 -0
- package/src/api/v1/ai-agents/facade.ts +489 -0
- package/src/api/v1/ai-agents/feedback.test.ts +30 -0
- package/src/api/v1/ai-agents/feedback.ts +24 -0
- package/src/api/v1/ai-agents/index.ts +1 -0
- package/src/api/v1/ai-agents/mcp-servers.test.ts +81 -0
- package/src/api/v1/ai-agents/mcp-servers.ts +67 -0
- package/src/api/v1/ai-agents/request-options.ts +32 -0
- package/src/api/v1/ai-agents/sql-approval.test.ts +32 -0
- package/src/api/v1/ai-agents/sql-approval.ts +24 -0
- package/src/api/v1/ai-agents/threads.test.ts +55 -0
- package/src/api/v1/ai-agents/threads.ts +216 -0
- package/src/api/v1/ai-agents.test.ts +189 -13
- package/src/api/v1/analytics.test.ts +32 -0
- package/src/api/v1/analytics.ts +16 -0
- package/src/api/v1/charts.test.ts +26 -6
- package/src/api/v1/charts.ts +25 -4
- package/src/api/v1/dashboards.test.ts +142 -0
- package/src/api/v1/dashboards.ts +127 -2
- package/src/api/v1/explores.test.ts +22 -0
- package/src/api/v1/explores.ts +13 -2
- package/src/api/v1/groups.test.ts +2 -0
- package/src/api/v1/groups.ts +9 -7
- package/src/api/v1/metrics.test.ts +2 -0
- package/src/api/v1/metrics.ts +3 -2
- package/src/api/v1/organizations.test.ts +2 -0
- package/src/api/v1/organizations.ts +2 -1
- package/src/api/v1/project-access.test.ts +3 -1
- package/src/api/v1/project-access.ts +2 -1
- package/src/api/v1/projects.test.ts +2 -0
- package/src/api/v1/projects.ts +2 -1
- package/src/api/v1/query.test.ts +2 -0
- package/src/api/v1/query.ts +6 -2
- package/src/api/v1/schedulers.test.ts +2 -0
- package/src/api/v1/schedulers.ts +3 -2
- package/src/api/v1/spaces.test.ts +2 -0
- package/src/api/v1/spaces.ts +2 -1
- package/src/api/v1/tags.test.ts +2 -0
- package/src/api/v1/tags.ts +2 -1
- package/src/api/v1/users.test.ts +26 -0
- package/src/api/v1/users.ts +8 -2
- package/src/api/v1/validation.test.ts +20 -0
- package/src/api/v1/validation.ts +26 -2
- package/src/api/v2/charts.test.ts +53 -0
- package/src/api/v2/charts.ts +23 -0
- package/src/api/v2/content.test.ts +47 -0
- package/src/api/v2/content.ts +37 -3
- package/src/api/v2/dashboards.test.ts +71 -0
- package/src/api/v2/dashboards.ts +40 -0
- package/src/api/v2/organization-roles.test.ts +2 -0
- package/src/api/v2/organization-roles.ts +2 -1
- package/src/api/v2/parameters.test.ts +45 -0
- package/src/api/v2/parameters.ts +38 -0
- package/src/api/v2/project-role-assignments.test.ts +2 -0
- package/src/api/v2/project-role-assignments.ts +2 -1
- package/src/api/v2/query.test.ts +20 -0
- package/src/api/v2/query.ts +55 -1
- package/src/api/v2/validation.ts +48 -0
- package/src/client.test.ts +3 -0
- package/src/client.ts +33 -17
- package/src/config.ts +38 -10
- package/src/errors.test.ts +1 -0
- package/src/http/axios-client.ts +8 -5
- package/src/http/http-client.ts +8 -21
- package/src/http/interceptors.ts +23 -10
- package/src/http/rate-limiter.test.ts +1 -0
- package/src/http/rate-limiter.ts +3 -1
- package/src/http/unwrap-api-success.test.ts +23 -0
- package/src/http/unwrap-api-success.ts +40 -0
- package/src/index.test.ts +16 -7
- package/src/index.ts +37 -2
- package/src/pagination/fetch-all-pages.test.ts +2 -0
- package/src/types/api.ts +1 -1
- package/src/utils/env.test.ts +16 -4
- package/src/utils/env.ts +61 -10
- package/src/utils/logger.ts +6 -4
- package/src/utils/retry.test.ts +1 -0
- package/src/utils/retry.ts +2 -1
- package/src/utils/secret-string.test.ts +27 -0
- package/tsconfig.json +4 -2
- package/dist/api/v1/ai-agents.d.ts +0 -63
- package/dist/api/v1/ai-agents.js +0 -173
- package/src/api/v1/ai-agents.ts +0 -252
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project-scoped AI agent thread client.
|
|
3
|
+
* Endpoints: /api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/...
|
|
4
|
+
*/
|
|
5
|
+
import { BaseApiClient } from '../../base-client';
|
|
6
|
+
import type { RequestOptions } from './request-options';
|
|
7
|
+
import type { AiAgentThread, AiAgentThreadSummary, CloneThreadBody, CreateAgentThreadBody, CreateAgentThreadMessageResult, GenerateAgentThreadBody, GenerateAgentThreadResult, GenerateThreadTitleResult } from '@lightdash-tools/common';
|
|
8
|
+
/** Thread metadata for {@link startConversation}; the user prompt is sent via the message body. */
|
|
9
|
+
export type StartConversationThreadBody = Omit<CreateAgentThreadBody, 'prompt'>;
|
|
10
|
+
export declare class AiAgentsThreadsClient extends BaseApiClient {
|
|
11
|
+
/** List all threads for an agent (GET /projects/{projectUuid}/aiAgents/{agentUuid}/threads). */
|
|
12
|
+
listAgentThreads(projectUuid: string, agentUuid: string): Promise<AiAgentThreadSummary[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new thread (POST /projects/{projectUuid}/aiAgents/{agentUuid}/threads).
|
|
15
|
+
* Does not send a prompt; use {@link createAgentThreadMessage} and
|
|
16
|
+
* {@link generateAgentThreadResponse} for the RFC conversation flow.
|
|
17
|
+
*/
|
|
18
|
+
createAgentThread(projectUuid: string, agentUuid: string, body?: CreateAgentThreadBody, options?: RequestOptions): Promise<AiAgentThreadSummary>;
|
|
19
|
+
/** Get a thread with its messages (GET …/threads/{threadUuid}). */
|
|
20
|
+
getAgentThread(projectUuid: string, agentUuid: string, threadUuid: string, options?: RequestOptions): Promise<AiAgentThread>;
|
|
21
|
+
/**
|
|
22
|
+
* Add a user message to a thread
|
|
23
|
+
* (POST …/threads/{threadUuid}/messages).
|
|
24
|
+
*/
|
|
25
|
+
createAgentThreadMessage(projectUuid: string, agentUuid: string, threadUuid: string, body: GenerateAgentThreadBody, options?: RequestOptions): Promise<CreateAgentThreadMessageResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Trigger agent generation for the latest pending user message
|
|
28
|
+
* (POST …/threads/{threadUuid}/generate). Sends no request body.
|
|
29
|
+
*/
|
|
30
|
+
generateAgentThreadResponse(projectUuid: string, agentUuid: string, threadUuid: string, options?: RequestOptions): Promise<GenerateAgentThreadResult>;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Pass the prompt via {@link createAgentThreadMessage} first. When `body` is
|
|
33
|
+
* provided, creates the message then calls generate for backward compatibility.
|
|
34
|
+
*/
|
|
35
|
+
generateAgentThreadResponse(projectUuid: string, agentUuid: string, threadUuid: string, body: GenerateAgentThreadBody, options?: RequestOptions): Promise<GenerateAgentThreadResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Start a new conversation: create thread → add user message → generate response.
|
|
38
|
+
*/
|
|
39
|
+
startConversation(projectUuid: string, agentUuid: string, body: GenerateAgentThreadBody, options?: RequestOptions & {
|
|
40
|
+
threadBody?: StartConversationThreadBody;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
thread: AiAgentThreadSummary;
|
|
43
|
+
result: GenerateAgentThreadResult;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Continue an existing conversation: add user message → generate response.
|
|
47
|
+
*/
|
|
48
|
+
continueConversation(projectUuid: string, agentUuid: string, threadUuid: string, body: GenerateAgentThreadBody, options?: RequestOptions): Promise<GenerateAgentThreadResult>;
|
|
49
|
+
/** Generate a title for a thread (POST …/threads/{threadUuid}/generate-title). */
|
|
50
|
+
generateThreadTitle(projectUuid: string, agentUuid: string, threadUuid: string, options?: RequestOptions): Promise<GenerateThreadTitleResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Clone a thread from an existing prompt
|
|
53
|
+
* (POST …/threads/{threadUuid}/clone/{promptUuid}).
|
|
54
|
+
*/
|
|
55
|
+
cloneThread(projectUuid: string, agentUuid: string, threadUuid: string, body?: CloneThreadBody): Promise<AiAgentThreadSummary>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Project-scoped AI agent thread client.
|
|
4
|
+
* Endpoints: /api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/...
|
|
5
|
+
*/
|
|
6
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
7
|
+
var t = {};
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
9
|
+
t[p] = s[p];
|
|
10
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
11
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
12
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
13
|
+
t[p[i]] = s[p[i]];
|
|
14
|
+
}
|
|
15
|
+
return t;
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AiAgentsThreadsClient = void 0;
|
|
19
|
+
const base_client_1 = require("../../base-client");
|
|
20
|
+
const request_options_1 = require("./request-options");
|
|
21
|
+
function toCreateThreadBody(threadBody) {
|
|
22
|
+
if (threadBody === undefined) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const body = Object.assign({}, threadBody);
|
|
26
|
+
delete body.prompt;
|
|
27
|
+
return body;
|
|
28
|
+
}
|
|
29
|
+
class AiAgentsThreadsClient extends base_client_1.BaseApiClient {
|
|
30
|
+
/** List all threads for an agent (GET /projects/{projectUuid}/aiAgents/{agentUuid}/threads). */
|
|
31
|
+
async listAgentThreads(projectUuid, agentUuid) {
|
|
32
|
+
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads`);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a new thread (POST /projects/{projectUuid}/aiAgents/{agentUuid}/threads).
|
|
36
|
+
* Does not send a prompt; use {@link createAgentThreadMessage} and
|
|
37
|
+
* {@link generateAgentThreadResponse} for the RFC conversation flow.
|
|
38
|
+
*/
|
|
39
|
+
async createAgentThread(projectUuid, agentUuid, body, options) {
|
|
40
|
+
return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads`, body !== null && body !== void 0 ? body : {}, (0, request_options_1.toAxiosConfig)(options));
|
|
41
|
+
}
|
|
42
|
+
/** Get a thread with its messages (GET …/threads/{threadUuid}). */
|
|
43
|
+
async getAgentThread(projectUuid, agentUuid, threadUuid, options) {
|
|
44
|
+
return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads/${threadUuid}`, (0, request_options_1.toAxiosConfig)(options));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Add a user message to a thread
|
|
48
|
+
* (POST …/threads/{threadUuid}/messages).
|
|
49
|
+
*/
|
|
50
|
+
async createAgentThreadMessage(projectUuid, agentUuid, threadUuid, body, options) {
|
|
51
|
+
return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads/${threadUuid}/messages`, body, (0, request_options_1.toAxiosConfig)(options));
|
|
52
|
+
}
|
|
53
|
+
async generateAgentThreadResponse(projectUuid, agentUuid, threadUuid, bodyOrOptions, maybeOptions) {
|
|
54
|
+
const hasPromptBody = bodyOrOptions !== undefined && typeof bodyOrOptions === 'object' && 'prompt' in bodyOrOptions;
|
|
55
|
+
if (hasPromptBody) {
|
|
56
|
+
const body = bodyOrOptions;
|
|
57
|
+
const options = maybeOptions;
|
|
58
|
+
await this.createAgentThreadMessage(projectUuid, agentUuid, threadUuid, body, options);
|
|
59
|
+
return this.generateAgentThreadResponse(projectUuid, agentUuid, threadUuid, options);
|
|
60
|
+
}
|
|
61
|
+
const options = (hasPromptBody ? maybeOptions : bodyOrOptions);
|
|
62
|
+
return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads/${threadUuid}/generate`, undefined, (0, request_options_1.toAxiosConfig)(options));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Start a new conversation: create thread → add user message → generate response.
|
|
66
|
+
*/
|
|
67
|
+
async startConversation(projectUuid, agentUuid, body, options) {
|
|
68
|
+
const _a = options !== null && options !== void 0 ? options : {}, { threadBody } = _a, requestOptions = __rest(_a, ["threadBody"]);
|
|
69
|
+
const thread = await this.createAgentThread(projectUuid, agentUuid, toCreateThreadBody(threadBody), requestOptions);
|
|
70
|
+
await this.createAgentThreadMessage(projectUuid, agentUuid, thread.uuid, body, requestOptions);
|
|
71
|
+
const result = await this.generateAgentThreadResponse(projectUuid, agentUuid, thread.uuid, requestOptions);
|
|
72
|
+
return { thread, result };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Continue an existing conversation: add user message → generate response.
|
|
76
|
+
*/
|
|
77
|
+
async continueConversation(projectUuid, agentUuid, threadUuid, body, options) {
|
|
78
|
+
await this.createAgentThreadMessage(projectUuid, agentUuid, threadUuid, body, options);
|
|
79
|
+
return this.generateAgentThreadResponse(projectUuid, agentUuid, threadUuid, options);
|
|
80
|
+
}
|
|
81
|
+
/** Generate a title for a thread (POST …/threads/{threadUuid}/generate-title). */
|
|
82
|
+
async generateThreadTitle(projectUuid, agentUuid, threadUuid, options) {
|
|
83
|
+
return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads/${threadUuid}/generate-title`, undefined, (0, request_options_1.toAxiosConfig)(options));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Clone a thread from an existing prompt
|
|
87
|
+
* (POST …/threads/{threadUuid}/clone/{promptUuid}).
|
|
88
|
+
*/
|
|
89
|
+
async cloneThread(projectUuid, agentUuid, threadUuid, body) {
|
|
90
|
+
const promptUuid = body === null || body === void 0 ? void 0 : body.promptUuid;
|
|
91
|
+
if (!promptUuid) {
|
|
92
|
+
throw new Error('cloneThread requires body.promptUuid');
|
|
93
|
+
}
|
|
94
|
+
return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/threads/${threadUuid}/clone/${promptUuid}`, undefined, body.createdFrom === undefined ? undefined : { params: { createdFrom: body.createdFrom } });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.AiAgentsThreadsClient = AiAgentsThreadsClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const threads_1 = require("./threads");
|
|
5
|
+
(0, vitest_1.describe)('AiAgentsThreadsClient extensions', () => {
|
|
6
|
+
let mockHttp;
|
|
7
|
+
(0, vitest_1.beforeEach)(() => {
|
|
8
|
+
mockHttp = {
|
|
9
|
+
get: vitest_1.vi.fn(),
|
|
10
|
+
post: vitest_1.vi.fn(),
|
|
11
|
+
put: vitest_1.vi.fn(),
|
|
12
|
+
patch: vitest_1.vi.fn(),
|
|
13
|
+
delete: vitest_1.vi.fn(),
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
(0, vitest_1.it)('generateThreadTitle should call POST …/generate-title', async () => {
|
|
17
|
+
const client = new threads_1.AiAgentsThreadsClient(mockHttp);
|
|
18
|
+
const title = { title: 'Revenue analysis' };
|
|
19
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(title);
|
|
20
|
+
const result = await client.generateThreadTitle('proj1', 'a1', 't1');
|
|
21
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads/t1/generate-title', undefined, undefined);
|
|
22
|
+
(0, vitest_1.expect)(result).toEqual(title);
|
|
23
|
+
});
|
|
24
|
+
(0, vitest_1.it)('cloneThread should call POST …/clone/{promptUuid}', async () => {
|
|
25
|
+
const client = new threads_1.AiAgentsThreadsClient(mockHttp);
|
|
26
|
+
const thread = { uuid: 't2', title: 'Clone' };
|
|
27
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(thread);
|
|
28
|
+
const result = await client.cloneThread('proj1', 'a1', 't1', {
|
|
29
|
+
promptUuid: 'p1',
|
|
30
|
+
createdFrom: 'web_app',
|
|
31
|
+
});
|
|
32
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads/t1/clone/p1', undefined, { params: { createdFrom: 'web_app' } });
|
|
33
|
+
(0, vitest_1.expect)(result).toEqual(thread);
|
|
34
|
+
});
|
|
35
|
+
(0, vitest_1.it)('cloneThread without body should throw', async () => {
|
|
36
|
+
const client = new threads_1.AiAgentsThreadsClient(mockHttp);
|
|
37
|
+
await (0, vitest_1.expect)(client.cloneThread('proj1', 'a1', 't1')).rejects.toThrow('cloneThread requires body.promptUuid');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const vitest_1 = require("vitest");
|
|
13
4
|
const ai_agents_1 = require("./ai-agents");
|
|
@@ -23,11 +14,11 @@ const ai_agents_1 = require("./ai-agents");
|
|
|
23
14
|
};
|
|
24
15
|
});
|
|
25
16
|
// ─── Admin ───────────────────────────────────────────────────────────────────
|
|
26
|
-
(0, vitest_1.it)('getAdminThreads should call GET /aiAgents/admin/threads with optional params', () =>
|
|
17
|
+
(0, vitest_1.it)('getAdminThreads should call GET /aiAgents/admin/threads with optional params', async () => {
|
|
27
18
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
28
19
|
const results = { data: [], pagination: { totalResults: 0, totalPageCount: 0 } };
|
|
29
20
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(results);
|
|
30
|
-
const result =
|
|
21
|
+
const result = await client.getAdminThreads({
|
|
31
22
|
page: 1,
|
|
32
23
|
pageSize: 20,
|
|
33
24
|
sortField: 'createdAt',
|
|
@@ -37,23 +28,23 @@ const ai_agents_1 = require("./ai-agents");
|
|
|
37
28
|
params: { page: 1, pageSize: 20, sortField: 'createdAt', sortDirection: 'desc' },
|
|
38
29
|
});
|
|
39
30
|
(0, vitest_1.expect)(result).toEqual(results);
|
|
40
|
-
})
|
|
41
|
-
(0, vitest_1.it)('getAdminThreads without params should call GET with no params', () =>
|
|
31
|
+
});
|
|
32
|
+
(0, vitest_1.it)('getAdminThreads without params should call GET with no params', async () => {
|
|
42
33
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
43
34
|
const results = { data: [], pagination: { totalResults: 0, totalPageCount: 0 } };
|
|
44
35
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(results);
|
|
45
|
-
|
|
36
|
+
await client.getAdminThreads();
|
|
46
37
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/aiAgents/admin/threads', { params: undefined });
|
|
47
|
-
})
|
|
48
|
-
(0, vitest_1.it)('listAdminAgents should call GET /aiAgents/admin/agents', () =>
|
|
38
|
+
});
|
|
39
|
+
(0, vitest_1.it)('listAdminAgents should call GET /aiAgents/admin/agents', async () => {
|
|
49
40
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
50
41
|
const list = [{ uuid: 'a1', name: 'Agent 1', description: null }];
|
|
51
42
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(list);
|
|
52
|
-
const result =
|
|
43
|
+
const result = await client.listAdminAgents();
|
|
53
44
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/aiAgents/admin/agents');
|
|
54
45
|
(0, vitest_1.expect)(result).toEqual(list);
|
|
55
|
-
})
|
|
56
|
-
(0, vitest_1.it)('getAiOrganizationSettings should call GET /aiAgents/admin/settings', () =>
|
|
46
|
+
});
|
|
47
|
+
(0, vitest_1.it)('getAiOrganizationSettings should call GET /aiAgents/admin/settings', async () => {
|
|
57
48
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
58
49
|
const settings = {
|
|
59
50
|
aiAgentsVisible: true,
|
|
@@ -62,177 +53,269 @@ const ai_agents_1 = require("./ai-agents");
|
|
|
62
53
|
isCopilotEnabled: false,
|
|
63
54
|
};
|
|
64
55
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(settings);
|
|
65
|
-
const result =
|
|
56
|
+
const result = await client.getAiOrganizationSettings();
|
|
66
57
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/aiAgents/admin/settings');
|
|
67
58
|
(0, vitest_1.expect)(result).toEqual(settings);
|
|
68
|
-
})
|
|
69
|
-
(0, vitest_1.it)('updateAiOrganizationSettings should call PATCH /aiAgents/admin/settings with body', () =>
|
|
59
|
+
});
|
|
60
|
+
(0, vitest_1.it)('updateAiOrganizationSettings should call PATCH /aiAgents/admin/settings with body', async () => {
|
|
70
61
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
71
62
|
const body = { aiAgentsVisible: false };
|
|
72
63
|
const updated = { aiAgentsVisible: false, organizationUuid: 'org1' };
|
|
73
64
|
vitest_1.vi.mocked(mockHttp.patch).mockResolvedValue(updated);
|
|
74
|
-
const result =
|
|
65
|
+
const result = await client.updateAiOrganizationSettings(body);
|
|
75
66
|
(0, vitest_1.expect)(mockHttp.patch).toHaveBeenCalledWith('/aiAgents/admin/settings', body);
|
|
76
67
|
(0, vitest_1.expect)(result).toEqual(updated);
|
|
77
|
-
})
|
|
68
|
+
});
|
|
78
69
|
// ─── Project-scoped: agent CRUD ──────────────────────────────────────────────
|
|
79
|
-
(0, vitest_1.it)('listAgents should call GET /projects/{projectUuid}/aiAgents', () =>
|
|
70
|
+
(0, vitest_1.it)('listAgents should call GET /projects/{projectUuid}/aiAgents', async () => {
|
|
80
71
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
81
72
|
const list = [{ uuid: 'a1', name: 'Agent 1' }];
|
|
82
73
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(list);
|
|
83
|
-
const result =
|
|
74
|
+
const result = await client.listAgents('proj1');
|
|
84
75
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents');
|
|
85
76
|
(0, vitest_1.expect)(result).toEqual(list);
|
|
86
|
-
})
|
|
87
|
-
(0, vitest_1.it)('getAgent should call GET /projects/{projectUuid}/aiAgents/{agentUuid}', () =>
|
|
77
|
+
});
|
|
78
|
+
(0, vitest_1.it)('getAgent should call GET /projects/{projectUuid}/aiAgents/{agentUuid}', async () => {
|
|
88
79
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
89
80
|
const agent = { uuid: 'a1', name: 'Agent 1', projectUuid: 'proj1' };
|
|
90
81
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(agent);
|
|
91
|
-
const result =
|
|
82
|
+
const result = await client.getAgent('proj1', 'a1');
|
|
92
83
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1');
|
|
93
84
|
(0, vitest_1.expect)(result).toEqual(agent);
|
|
94
|
-
})
|
|
95
|
-
(0, vitest_1.it)('createAgent should call POST /projects/{projectUuid}/aiAgents with body', () =>
|
|
85
|
+
});
|
|
86
|
+
(0, vitest_1.it)('createAgent should call POST /projects/{projectUuid}/aiAgents with body', async () => {
|
|
96
87
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
97
88
|
const body = { name: 'New Agent', projectUuid: 'proj1' };
|
|
98
89
|
const created = { uuid: 'a2', name: 'New Agent', projectUuid: 'proj1' };
|
|
99
90
|
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(created);
|
|
100
|
-
const result =
|
|
91
|
+
const result = await client.createAgent('proj1', body);
|
|
101
92
|
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents', body);
|
|
102
93
|
(0, vitest_1.expect)(result).toEqual(created);
|
|
103
|
-
})
|
|
104
|
-
(0, vitest_1.it)('updateAgent should call PATCH /projects/{projectUuid}/aiAgents/{agentUuid} with body', () =>
|
|
94
|
+
});
|
|
95
|
+
(0, vitest_1.it)('updateAgent should call PATCH /projects/{projectUuid}/aiAgents/{agentUuid} with body', async () => {
|
|
105
96
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
106
97
|
const body = { name: 'Updated Agent' };
|
|
107
98
|
const updated = { uuid: 'a1', name: 'Updated Agent', projectUuid: 'proj1' };
|
|
108
99
|
vitest_1.vi.mocked(mockHttp.patch).mockResolvedValue(updated);
|
|
109
|
-
const result =
|
|
100
|
+
const result = await client.updateAgent('proj1', 'a1', body);
|
|
110
101
|
(0, vitest_1.expect)(mockHttp.patch).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1', body);
|
|
111
102
|
(0, vitest_1.expect)(result).toEqual(updated);
|
|
112
|
-
})
|
|
113
|
-
(0, vitest_1.it)('deleteAgent should call DELETE /projects/{projectUuid}/aiAgents/{agentUuid}', () =>
|
|
103
|
+
});
|
|
104
|
+
(0, vitest_1.it)('deleteAgent should call DELETE /projects/{projectUuid}/aiAgents/{agentUuid}', async () => {
|
|
114
105
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
115
106
|
vitest_1.vi.mocked(mockHttp.delete).mockResolvedValue(undefined);
|
|
116
|
-
|
|
107
|
+
await client.deleteAgent('proj1', 'a1');
|
|
117
108
|
(0, vitest_1.expect)(mockHttp.delete).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1');
|
|
118
|
-
})
|
|
109
|
+
});
|
|
119
110
|
// ─── Project-scoped: threads ─────────────────────────────────────────────────
|
|
120
|
-
(0, vitest_1.it)('listAgentThreads should call GET /projects/{projectUuid}/aiAgents/{agentUuid}/threads', () =>
|
|
111
|
+
(0, vitest_1.it)('listAgentThreads should call GET /projects/{projectUuid}/aiAgents/{agentUuid}/threads', async () => {
|
|
121
112
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
122
113
|
const threads = [{ uuid: 't1', title: 'Thread 1' }];
|
|
123
114
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(threads);
|
|
124
|
-
const result =
|
|
115
|
+
const result = await client.listAgentThreads('proj1', 'a1');
|
|
125
116
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads');
|
|
126
117
|
(0, vitest_1.expect)(result).toEqual(threads);
|
|
127
|
-
})
|
|
128
|
-
(0, vitest_1.it)('createAgentThread should call POST /projects/{projectUuid}/aiAgents/{agentUuid}/threads', () =>
|
|
118
|
+
});
|
|
119
|
+
(0, vitest_1.it)('createAgentThread should call POST /projects/{projectUuid}/aiAgents/{agentUuid}/threads', async () => {
|
|
129
120
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
130
121
|
const thread = { uuid: 't1', title: null };
|
|
131
122
|
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(thread);
|
|
132
|
-
const result =
|
|
133
|
-
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads', {});
|
|
123
|
+
const result = await client.createAgentThread('proj1', 'a1');
|
|
124
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads', {}, undefined);
|
|
134
125
|
(0, vitest_1.expect)(result).toEqual(thread);
|
|
135
|
-
})
|
|
136
|
-
(0, vitest_1.it)('createAgentThread with body should pass body to POST', () =>
|
|
126
|
+
});
|
|
127
|
+
(0, vitest_1.it)('createAgentThread with body should pass body to POST', async () => {
|
|
137
128
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
138
129
|
const body = { prompt: 'Hello' };
|
|
139
130
|
const thread = { uuid: 't1', title: null };
|
|
140
131
|
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(thread);
|
|
141
|
-
|
|
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}', () =>
|
|
132
|
+
await client.createAgentThread('proj1', 'a1', body);
|
|
133
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads', body, undefined);
|
|
134
|
+
});
|
|
135
|
+
(0, vitest_1.it)('getAgentThread should call GET .../threads/{threadUuid}', async () => {
|
|
145
136
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
146
137
|
const thread = { uuid: 't1', messages: [] };
|
|
147
138
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(thread);
|
|
148
|
-
const result =
|
|
149
|
-
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads/t1');
|
|
139
|
+
const result = await client.getAgentThread('proj1', 'a1', 't1');
|
|
140
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads/t1', undefined);
|
|
150
141
|
(0, vitest_1.expect)(result).toEqual(thread);
|
|
151
|
-
})
|
|
152
|
-
(0, vitest_1.it)('
|
|
142
|
+
});
|
|
143
|
+
(0, vitest_1.it)('createAgentThreadMessage should call POST .../threads/{threadUuid}/messages', async () => {
|
|
144
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
145
|
+
const message = { uuid: 'm1', message: 'Hello', role: 'user' };
|
|
146
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(message);
|
|
147
|
+
const body = { prompt: 'What is the total revenue?' };
|
|
148
|
+
const result = await client.createAgentThreadMessage('proj1', 'a1', 't1', body);
|
|
149
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads/t1/messages', body, undefined);
|
|
150
|
+
(0, vitest_1.expect)(result).toEqual(message);
|
|
151
|
+
});
|
|
152
|
+
(0, vitest_1.it)('createAgentThreadMessage should pass RequestOptions to POST', async () => {
|
|
153
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
154
|
+
const controller = new AbortController();
|
|
155
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue({ uuid: 'm1' });
|
|
156
|
+
await client.createAgentThreadMessage('proj1', 'a1', 't1', { prompt: 'Hi' }, { signal: controller.signal, timeoutMs: 5000, requestId: 'req-1' });
|
|
157
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads/t1/messages', { prompt: 'Hi' }, {
|
|
158
|
+
signal: controller.signal,
|
|
159
|
+
timeout: 5000,
|
|
160
|
+
headers: { 'X-Request-Id': 'req-1' },
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
(0, vitest_1.it)('generateAgentThreadResponse without body should call POST .../generate with no body', async () => {
|
|
153
164
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
154
165
|
const response = { response: 'Here is your answer.' };
|
|
155
166
|
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(response);
|
|
156
|
-
const result =
|
|
167
|
+
const result = await client.generateAgentThreadResponse('proj1', 'a1', 't1');
|
|
168
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads/t1/generate', undefined, undefined);
|
|
169
|
+
(0, vitest_1.expect)(result).toEqual(response);
|
|
170
|
+
});
|
|
171
|
+
(0, vitest_1.it)('generateAgentThreadResponse with prompt body should create message then generate', async () => {
|
|
172
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
173
|
+
const message = { uuid: 'm1', message: 'What is the total revenue?', role: 'user' };
|
|
174
|
+
const response = { response: 'Here is your answer.' };
|
|
175
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValueOnce(message).mockResolvedValueOnce(response);
|
|
176
|
+
const result = await client.generateAgentThreadResponse('proj1', 'a1', 't1', {
|
|
157
177
|
prompt: 'What is the total revenue?',
|
|
158
178
|
});
|
|
159
|
-
(0, vitest_1.expect)(mockHttp.post).
|
|
160
|
-
|
|
179
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenNthCalledWith(1, '/projects/proj1/aiAgents/a1/threads/t1/messages', { prompt: 'What is the total revenue?' }, undefined);
|
|
180
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenNthCalledWith(2, '/projects/proj1/aiAgents/a1/threads/t1/generate', undefined, undefined);
|
|
181
|
+
(0, vitest_1.expect)(result).toEqual(response);
|
|
182
|
+
});
|
|
183
|
+
(0, vitest_1.it)('startConversation should create thread, message, and generate', async () => {
|
|
184
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
185
|
+
const thread = { uuid: 't1', title: null };
|
|
186
|
+
const message = { uuid: 'm1', message: 'Hello', role: 'user' };
|
|
187
|
+
const response = { response: 'Hi there.' };
|
|
188
|
+
vitest_1.vi.mocked(mockHttp.post)
|
|
189
|
+
.mockResolvedValueOnce(thread)
|
|
190
|
+
.mockResolvedValueOnce(message)
|
|
191
|
+
.mockResolvedValueOnce(response);
|
|
192
|
+
const result = await client.startConversation('proj1', 'a1', { prompt: 'Hello' });
|
|
193
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenNthCalledWith(1, '/projects/proj1/aiAgents/a1/threads', {}, undefined);
|
|
194
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenNthCalledWith(2, '/projects/proj1/aiAgents/a1/threads/t1/messages', { prompt: 'Hello' }, undefined);
|
|
195
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenNthCalledWith(3, '/projects/proj1/aiAgents/a1/threads/t1/generate', undefined, undefined);
|
|
196
|
+
(0, vitest_1.expect)(result).toEqual({ thread, result: response });
|
|
197
|
+
});
|
|
198
|
+
(0, vitest_1.it)('startConversation should strip prompt from threadBody when creating thread', async () => {
|
|
199
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
200
|
+
const thread = { uuid: 't1', title: null };
|
|
201
|
+
const message = { uuid: 'm1', message: 'Hello', role: 'user' };
|
|
202
|
+
const response = { response: 'Hi there.' };
|
|
203
|
+
vitest_1.vi.mocked(mockHttp.post)
|
|
204
|
+
.mockResolvedValueOnce(thread)
|
|
205
|
+
.mockResolvedValueOnce(message)
|
|
206
|
+
.mockResolvedValueOnce(response);
|
|
207
|
+
const threadBodyWithPrompt = {
|
|
208
|
+
prompt: 'duplicate',
|
|
209
|
+
modelConfig: { modelProvider: 'openai', modelName: 'gpt-4' },
|
|
210
|
+
};
|
|
211
|
+
await client.startConversation('proj1', 'a1', { prompt: 'Hello' }, {
|
|
212
|
+
threadBody: threadBodyWithPrompt,
|
|
161
213
|
});
|
|
214
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenNthCalledWith(1, '/projects/proj1/aiAgents/a1/threads', { modelConfig: { modelProvider: 'openai', modelName: 'gpt-4' } }, undefined);
|
|
215
|
+
});
|
|
216
|
+
(0, vitest_1.it)('continueConversation should create message then generate', async () => {
|
|
217
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
218
|
+
const message = { uuid: 'm2', message: 'Follow up', role: 'user' };
|
|
219
|
+
const response = { response: 'Sure.' };
|
|
220
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValueOnce(message).mockResolvedValueOnce(response);
|
|
221
|
+
const result = await client.continueConversation('proj1', 'a1', 't1', { prompt: 'Follow up' });
|
|
222
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenNthCalledWith(1, '/projects/proj1/aiAgents/a1/threads/t1/messages', { prompt: 'Follow up' }, undefined);
|
|
223
|
+
(0, vitest_1.expect)(mockHttp.post).toHaveBeenNthCalledWith(2, '/projects/proj1/aiAgents/a1/threads/t1/generate', undefined, undefined);
|
|
162
224
|
(0, vitest_1.expect)(result).toEqual(response);
|
|
163
|
-
})
|
|
225
|
+
});
|
|
164
226
|
// ─── Project-scoped: evaluations ─────────────────────────────────────────────
|
|
165
|
-
(0, vitest_1.it)('listEvaluations should call GET .../evaluations', () =>
|
|
227
|
+
(0, vitest_1.it)('listEvaluations should call GET .../evaluations', async () => {
|
|
166
228
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
167
229
|
const evals = [{ evalUuid: 'e1', title: 'Eval 1', agentUuid: 'a1' }];
|
|
168
230
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(evals);
|
|
169
|
-
const result =
|
|
231
|
+
const result = await client.listEvaluations('proj1', 'a1');
|
|
170
232
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations');
|
|
171
233
|
(0, vitest_1.expect)(result).toEqual(evals);
|
|
172
|
-
})
|
|
173
|
-
(0, vitest_1.it)('createEvaluation should call POST .../evaluations with body', () =>
|
|
234
|
+
});
|
|
235
|
+
(0, vitest_1.it)('createEvaluation should call POST .../evaluations with body', async () => {
|
|
174
236
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
175
237
|
const body = { title: 'My Eval', prompts: [] };
|
|
176
238
|
const created = { evalUuid: 'e1' };
|
|
177
239
|
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(created);
|
|
178
|
-
const result =
|
|
240
|
+
const result = await client.createEvaluation('proj1', 'a1', body);
|
|
179
241
|
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations', body);
|
|
180
242
|
(0, vitest_1.expect)(result).toEqual(created);
|
|
181
|
-
})
|
|
182
|
-
(0, vitest_1.it)('getEvaluation should call GET .../evaluations/{evalUuid}', () =>
|
|
243
|
+
});
|
|
244
|
+
(0, vitest_1.it)('getEvaluation should call GET .../evaluations/{evalUuid}', async () => {
|
|
183
245
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
184
246
|
const evaluation = { evalUuid: 'e1', title: 'My Eval', prompts: [] };
|
|
185
247
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(evaluation);
|
|
186
|
-
const result =
|
|
248
|
+
const result = await client.getEvaluation('proj1', 'a1', 'e1');
|
|
187
249
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1');
|
|
188
250
|
(0, vitest_1.expect)(result).toEqual(evaluation);
|
|
189
|
-
})
|
|
190
|
-
(0, vitest_1.it)('updateEvaluation should call PATCH .../evaluations/{evalUuid}', () =>
|
|
251
|
+
});
|
|
252
|
+
(0, vitest_1.it)('updateEvaluation should call PATCH .../evaluations/{evalUuid}', async () => {
|
|
191
253
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
192
254
|
const body = { title: 'Updated Eval' };
|
|
193
255
|
const updated = { evalUuid: 'e1', title: 'Updated Eval', prompts: [] };
|
|
194
256
|
vitest_1.vi.mocked(mockHttp.patch).mockResolvedValue(updated);
|
|
195
|
-
const result =
|
|
257
|
+
const result = await client.updateEvaluation('proj1', 'a1', 'e1', body);
|
|
196
258
|
(0, vitest_1.expect)(mockHttp.patch).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1', body);
|
|
197
259
|
(0, vitest_1.expect)(result).toEqual(updated);
|
|
198
|
-
})
|
|
199
|
-
(0, vitest_1.it)('appendToEvaluation should call POST .../evaluations/{evalUuid}/append
|
|
260
|
+
});
|
|
261
|
+
(0, vitest_1.it)('appendToEvaluation should call POST .../evaluations/{evalUuid}/append and return evaluation', async () => {
|
|
200
262
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
201
263
|
const body = { prompts: [{ prompt: 'Extra?', expectedResponse: null }] };
|
|
202
|
-
|
|
203
|
-
|
|
264
|
+
const updated = { evalUuid: 'e1', title: 'My Eval', prompts: body.prompts };
|
|
265
|
+
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(updated);
|
|
266
|
+
const result = await client.appendToEvaluation('proj1', 'a1', 'e1', body);
|
|
204
267
|
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1/append', body);
|
|
205
|
-
|
|
206
|
-
|
|
268
|
+
(0, vitest_1.expect)(result).toEqual(updated);
|
|
269
|
+
});
|
|
270
|
+
(0, vitest_1.it)('deleteEvaluation should call DELETE .../evaluations/{evalUuid}', async () => {
|
|
207
271
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
208
272
|
vitest_1.vi.mocked(mockHttp.delete).mockResolvedValue(undefined);
|
|
209
|
-
|
|
273
|
+
await client.deleteEvaluation('proj1', 'a1', 'e1');
|
|
210
274
|
(0, vitest_1.expect)(mockHttp.delete).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1');
|
|
211
|
-
})
|
|
275
|
+
});
|
|
212
276
|
// ─── Project-scoped: evaluation runs ─────────────────────────────────────────
|
|
213
|
-
(0, vitest_1.it)('runEvaluation should call POST .../evaluations/{evalUuid}/run', () =>
|
|
277
|
+
(0, vitest_1.it)('runEvaluation should call POST .../evaluations/{evalUuid}/run', async () => {
|
|
214
278
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
215
279
|
const runSummary = { runUuid: 'r1', evalUuid: 'e1', status: 'pending' };
|
|
216
280
|
vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(runSummary);
|
|
217
|
-
const result =
|
|
281
|
+
const result = await client.runEvaluation('proj1', 'a1', 'e1');
|
|
218
282
|
(0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1/run', {});
|
|
219
283
|
(0, vitest_1.expect)(result).toEqual(runSummary);
|
|
220
|
-
})
|
|
221
|
-
(0, vitest_1.it)('listEvaluationRuns should
|
|
284
|
+
});
|
|
285
|
+
(0, vitest_1.it)('listEvaluationRuns should return full paginated response', async () => {
|
|
222
286
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
223
287
|
const runs = [{ runUuid: 'r1', evalUuid: 'e1', status: 'completed' }];
|
|
224
|
-
const pagedResponse = {
|
|
288
|
+
const pagedResponse = {
|
|
289
|
+
data: { runs },
|
|
290
|
+
pagination: { totalResults: 1, totalPageCount: 1 },
|
|
291
|
+
};
|
|
225
292
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(pagedResponse);
|
|
226
|
-
const result =
|
|
227
|
-
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1/runs'
|
|
293
|
+
const result = await client.listEvaluationRuns('proj1', 'a1', 'e1');
|
|
294
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1/runs', {
|
|
295
|
+
params: undefined,
|
|
296
|
+
});
|
|
297
|
+
(0, vitest_1.expect)(result).toEqual(pagedResponse);
|
|
298
|
+
});
|
|
299
|
+
(0, vitest_1.it)('listAllEvaluationRuns should unwrap runs array from paginated response', async () => {
|
|
300
|
+
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
301
|
+
const runs = [{ runUuid: 'r1', evalUuid: 'e1', status: 'completed' }];
|
|
302
|
+
const pagedResponse = {
|
|
303
|
+
data: { runs },
|
|
304
|
+
pagination: { totalResults: 1, totalPageCount: 1 },
|
|
305
|
+
};
|
|
306
|
+
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(pagedResponse);
|
|
307
|
+
const result = await client.listAllEvaluationRuns('proj1', 'a1', 'e1');
|
|
308
|
+
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1/runs', {
|
|
309
|
+
params: { page: 1, pageSize: 100 },
|
|
310
|
+
});
|
|
228
311
|
(0, vitest_1.expect)(result).toEqual(runs);
|
|
229
|
-
})
|
|
230
|
-
(0, vitest_1.it)('getEvaluationRunResults should call GET .../evaluations/{evalUuid}/runs/{runUuid}', () =>
|
|
312
|
+
});
|
|
313
|
+
(0, vitest_1.it)('getEvaluationRunResults should call GET .../evaluations/{evalUuid}/runs/{runUuid}', async () => {
|
|
231
314
|
const client = new ai_agents_1.AiAgentsClient(mockHttp);
|
|
232
315
|
const run = { runUuid: 'r1', evalUuid: 'e1', results: [] };
|
|
233
316
|
vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(run);
|
|
234
|
-
const result =
|
|
317
|
+
const result = await client.getEvaluationRunResults('proj1', 'a1', 'e1', 'r1');
|
|
235
318
|
(0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/evaluations/e1/runs/r1');
|
|
236
319
|
(0, vitest_1.expect)(result).toEqual(run);
|
|
237
|
-
})
|
|
320
|
+
});
|
|
238
321
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analytics API client (v1). Project user-activity metadata (no CSV download).
|
|
3
|
+
*/
|
|
4
|
+
import { BaseApiClient } from '../base-client';
|
|
5
|
+
import type { components } from '@lightdash-tools/common';
|
|
6
|
+
export type UserActivity = components['schemas']['UserActivity'];
|
|
7
|
+
export declare class AnalyticsClient extends BaseApiClient {
|
|
8
|
+
/** Get user activity summary for a project (views, role counts, unused-ish tables). */
|
|
9
|
+
getUserActivity(projectUuid: string): Promise<UserActivity>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Analytics API client (v1). Project user-activity metadata (no CSV download).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AnalyticsClient = void 0;
|
|
7
|
+
const base_client_1 = require("../base-client");
|
|
8
|
+
class AnalyticsClient extends base_client_1.BaseApiClient {
|
|
9
|
+
/** Get user activity summary for a project (views, role counts, unused-ish tables). */
|
|
10
|
+
async getUserActivity(projectUuid) {
|
|
11
|
+
return this.http.get(`/analytics/user-activity/${projectUuid}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.AnalyticsClient = AnalyticsClient;
|