@lightdash-tools/client 0.5.0 → 0.7.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.
Files changed (237) hide show
  1. package/README.md +2 -2
  2. package/dist/agentops/apply-agent-change.d.ts +3 -0
  3. package/dist/agentops/apply-agent-change.js +63 -0
  4. package/dist/agentops/apply-bundle-diff.d.ts +13 -0
  5. package/dist/agentops/apply-bundle-diff.js +44 -0
  6. package/dist/agentops/apply-bundle-diff.test.d.ts +1 -0
  7. package/dist/agentops/apply-bundle-diff.test.js +397 -0
  8. package/dist/agentops/apply-context.d.ts +14 -0
  9. package/dist/agentops/apply-context.js +6 -0
  10. package/dist/agentops/apply-evaluation-change.d.ts +3 -0
  11. package/dist/agentops/apply-evaluation-change.js +78 -0
  12. package/dist/agentops/fetch-bundle-state.d.ts +6 -0
  13. package/dist/agentops/fetch-bundle-state.js +20 -0
  14. package/dist/agentops/fetch-bundle-state.test.d.ts +1 -0
  15. package/dist/agentops/fetch-bundle-state.test.js +44 -0
  16. package/dist/agentops/index.d.ts +3 -0
  17. package/dist/agentops/index.js +9 -0
  18. package/dist/agentops/resolve-evaluation-run.d.ts +15 -0
  19. package/dist/agentops/resolve-evaluation-run.js +48 -0
  20. package/dist/api/v1/ai-agents/admin.d.ts +16 -0
  21. package/dist/api/v1/ai-agents/admin.js +29 -0
  22. package/dist/api/v1/ai-agents/agents.d.ts +18 -0
  23. package/dist/api/v1/ai-agents/agents.js +31 -0
  24. package/dist/api/v1/ai-agents/artifacts.d.ts +26 -0
  25. package/dist/api/v1/ai-agents/artifacts.js +41 -0
  26. package/dist/api/v1/ai-agents/artifacts.test.d.ts +1 -0
  27. package/dist/api/v1/ai-agents/artifacts.test.js +69 -0
  28. package/dist/api/v1/ai-agents/discovery.d.ts +28 -0
  29. package/dist/api/v1/ai-agents/discovery.js +46 -0
  30. package/dist/api/v1/ai-agents/discovery.test.d.ts +1 -0
  31. package/dist/api/v1/ai-agents/discovery.test.js +90 -0
  32. package/dist/api/v1/ai-agents/evaluations.d.ts +39 -0
  33. package/dist/api/v1/ai-agents/evaluations.js +70 -0
  34. package/dist/api/v1/ai-agents/facade.d.ts +79 -0
  35. package/dist/api/v1/ai-agents/facade.js +193 -0
  36. package/dist/api/v1/ai-agents/feedback.d.ts +10 -0
  37. package/dist/api/v1/ai-agents/feedback.js +15 -0
  38. package/dist/api/v1/ai-agents/feedback.test.d.ts +1 -0
  39. package/dist/api/v1/ai-agents/feedback.test.js +23 -0
  40. package/dist/api/v1/ai-agents/index.d.ts +1 -0
  41. package/dist/api/v1/ai-agents/index.js +5 -0
  42. package/dist/api/v1/ai-agents/mcp-servers.d.ts +20 -0
  43. package/dist/api/v1/ai-agents/mcp-servers.js +35 -0
  44. package/dist/api/v1/ai-agents/mcp-servers.test.d.ts +1 -0
  45. package/dist/api/v1/ai-agents/mcp-servers.test.js +66 -0
  46. package/dist/api/v1/ai-agents/request-options.d.ts +12 -0
  47. package/dist/api/v1/ai-agents/request-options.js +20 -0
  48. package/dist/api/v1/ai-agents/sql-approval.d.ts +10 -0
  49. package/dist/api/v1/ai-agents/sql-approval.js +15 -0
  50. package/dist/api/v1/ai-agents/sql-approval.test.d.ts +1 -0
  51. package/dist/api/v1/ai-agents/sql-approval.test.js +25 -0
  52. package/dist/api/v1/ai-agents/threads.d.ts +56 -0
  53. package/dist/api/v1/ai-agents/threads.js +97 -0
  54. package/dist/api/v1/ai-agents/threads.test.d.ts +1 -0
  55. package/dist/api/v1/ai-agents/threads.test.js +39 -0
  56. package/dist/api/v1/ai-agents.test.js +172 -89
  57. package/dist/api/v1/analytics.d.ts +10 -0
  58. package/dist/api/v1/analytics.js +14 -0
  59. package/dist/api/v1/analytics.test.d.ts +4 -0
  60. package/dist/api/v1/analytics.test.js +27 -0
  61. package/dist/api/v1/charts.d.ts +5 -2
  62. package/dist/api/v1/charts.js +18 -30
  63. package/dist/api/v1/charts.test.js +19 -28
  64. package/dist/api/v1/dashboards.d.ts +11 -2
  65. package/dist/api/v1/dashboards.js +19 -14
  66. package/dist/api/v1/dashboards.test.js +54 -12
  67. package/dist/api/v1/explores.d.ts +4 -2
  68. package/dist/api/v1/explores.js +20 -29
  69. package/dist/api/v1/explores.test.js +31 -21
  70. package/dist/api/v1/groups.d.ts +1 -1
  71. package/dist/api/v1/groups.js +25 -51
  72. package/dist/api/v1/groups.test.js +15 -24
  73. package/dist/api/v1/metrics.d.ts +2 -2
  74. package/dist/api/v1/metrics.js +4 -17
  75. package/dist/api/v1/metrics.test.js +6 -15
  76. package/dist/api/v1/organizations.d.ts +1 -1
  77. package/dist/api/v1/organizations.js +2 -13
  78. package/dist/api/v1/organizations.test.js +3 -12
  79. package/dist/api/v1/project-access.d.ts +1 -1
  80. package/dist/api/v1/project-access.js +18 -45
  81. package/dist/api/v1/project-access.test.js +27 -36
  82. package/dist/api/v1/projects.d.ts +1 -1
  83. package/dist/api/v1/projects.js +6 -21
  84. package/dist/api/v1/projects.test.js +9 -18
  85. package/dist/api/v1/query.d.ts +5 -2
  86. package/dist/api/v1/query.js +8 -18
  87. package/dist/api/v1/query.test.js +6 -15
  88. package/dist/api/v1/schedulers.d.ts +2 -2
  89. package/dist/api/v1/schedulers.js +4 -17
  90. package/dist/api/v1/schedulers.test.js +6 -15
  91. package/dist/api/v1/spaces.d.ts +1 -1
  92. package/dist/api/v1/spaces.js +18 -45
  93. package/dist/api/v1/spaces.test.js +27 -36
  94. package/dist/api/v1/tags.d.ts +1 -1
  95. package/dist/api/v1/tags.js +4 -17
  96. package/dist/api/v1/tags.test.js +6 -15
  97. package/dist/api/v1/users.d.ts +3 -1
  98. package/dist/api/v1/users.js +22 -39
  99. package/dist/api/v1/users.test.js +44 -30
  100. package/dist/api/v1/validation.d.ts +5 -2
  101. package/dist/api/v1/validation.js +8 -18
  102. package/dist/api/v1/validation.test.js +6 -15
  103. package/dist/api/v2/content.d.ts +2 -2
  104. package/dist/api/v2/content.js +3 -14
  105. package/dist/api/v2/content.test.js +3 -12
  106. package/dist/api/v2/dashboards.d.ts +10 -0
  107. package/dist/api/v2/dashboards.js +14 -0
  108. package/dist/api/v2/dashboards.test.d.ts +4 -0
  109. package/dist/api/v2/dashboards.test.js +27 -0
  110. package/dist/api/v2/organization-roles.d.ts +1 -1
  111. package/dist/api/v2/organization-roles.js +21 -50
  112. package/dist/api/v2/organization-roles.test.js +33 -42
  113. package/dist/api/v2/project-role-assignments.d.ts +1 -1
  114. package/dist/api/v2/project-role-assignments.js +12 -33
  115. package/dist/api/v2/project-role-assignments.test.js +18 -27
  116. package/dist/api/v2/query.d.ts +1 -1
  117. package/dist/api/v2/query.js +10 -29
  118. package/dist/api/v2/query.test.js +15 -24
  119. package/dist/api/v2/validation.d.ts +28 -0
  120. package/dist/api/v2/validation.js +23 -0
  121. package/dist/client.d.ts +20 -14
  122. package/dist/client.js +22 -16
  123. package/dist/config.d.ts +35 -10
  124. package/dist/http/axios-client.d.ts +4 -4
  125. package/dist/http/http-client.d.ts +3 -3
  126. package/dist/http/http-client.js +19 -40
  127. package/dist/http/interceptors.d.ts +3 -3
  128. package/dist/http/interceptors.js +16 -3
  129. package/dist/http/rate-limiter.js +2 -13
  130. package/dist/http/rate-limiter.test.js +15 -24
  131. package/dist/index.d.ts +7 -2
  132. package/dist/index.js +12 -1
  133. package/dist/index.test.js +13 -5
  134. package/dist/pagination/fetch-all-pages.js +18 -29
  135. package/dist/pagination/fetch-all-pages.test.js +15 -24
  136. package/dist/types/api.d.ts +1 -1
  137. package/dist/utils/env.d.ts +11 -2
  138. package/dist/utils/env.js +41 -8
  139. package/dist/utils/env.test.js +14 -4
  140. package/dist/utils/logger.js +5 -4
  141. package/dist/utils/retry.js +17 -28
  142. package/dist/utils/retry.test.js +9 -18
  143. package/dist/utils/secret-string.test.d.ts +1 -0
  144. package/dist/utils/secret-string.test.js +25 -0
  145. package/package.json +12 -4
  146. package/src/agentops/apply-agent-change.ts +82 -0
  147. package/src/agentops/apply-bundle-diff.test.ts +453 -0
  148. package/src/agentops/apply-bundle-diff.ts +63 -0
  149. package/src/agentops/apply-context.ts +23 -0
  150. package/src/agentops/apply-evaluation-change.ts +125 -0
  151. package/src/agentops/fetch-bundle-state.test.ts +51 -0
  152. package/src/agentops/fetch-bundle-state.ts +33 -0
  153. package/src/agentops/index.ts +11 -0
  154. package/src/agentops/resolve-evaluation-run.ts +94 -0
  155. package/src/api/v1/ai-agents/admin.ts +41 -0
  156. package/src/api/v1/ai-agents/agents.ts +40 -0
  157. package/src/api/v1/ai-agents/artifacts.test.ts +84 -0
  158. package/src/api/v1/ai-agents/artifacts.ts +92 -0
  159. package/src/api/v1/ai-agents/discovery.test.ts +102 -0
  160. package/src/api/v1/ai-agents/discovery.ts +79 -0
  161. package/src/api/v1/ai-agents/evaluations.ts +152 -0
  162. package/src/api/v1/ai-agents/facade.ts +489 -0
  163. package/src/api/v1/ai-agents/feedback.test.ts +30 -0
  164. package/src/api/v1/ai-agents/feedback.ts +24 -0
  165. package/src/api/v1/ai-agents/index.ts +1 -0
  166. package/src/api/v1/ai-agents/mcp-servers.test.ts +81 -0
  167. package/src/api/v1/ai-agents/mcp-servers.ts +67 -0
  168. package/src/api/v1/ai-agents/request-options.ts +32 -0
  169. package/src/api/v1/ai-agents/sql-approval.test.ts +32 -0
  170. package/src/api/v1/ai-agents/sql-approval.ts +24 -0
  171. package/src/api/v1/ai-agents/threads.test.ts +55 -0
  172. package/src/api/v1/ai-agents/threads.ts +216 -0
  173. package/src/api/v1/ai-agents.test.ts +189 -13
  174. package/src/api/v1/analytics.test.ts +32 -0
  175. package/src/api/v1/analytics.ts +16 -0
  176. package/src/api/v1/charts.test.ts +8 -6
  177. package/src/api/v1/charts.ts +8 -4
  178. package/src/api/v1/dashboards.test.ts +57 -0
  179. package/src/api/v1/dashboards.ts +41 -2
  180. package/src/api/v1/explores.test.ts +22 -0
  181. package/src/api/v1/explores.ts +13 -2
  182. package/src/api/v1/groups.test.ts +2 -0
  183. package/src/api/v1/groups.ts +9 -7
  184. package/src/api/v1/metrics.test.ts +2 -0
  185. package/src/api/v1/metrics.ts +3 -2
  186. package/src/api/v1/organizations.test.ts +2 -0
  187. package/src/api/v1/organizations.ts +2 -1
  188. package/src/api/v1/project-access.test.ts +3 -1
  189. package/src/api/v1/project-access.ts +2 -1
  190. package/src/api/v1/projects.test.ts +2 -0
  191. package/src/api/v1/projects.ts +2 -1
  192. package/src/api/v1/query.test.ts +2 -0
  193. package/src/api/v1/query.ts +6 -2
  194. package/src/api/v1/schedulers.test.ts +2 -0
  195. package/src/api/v1/schedulers.ts +3 -2
  196. package/src/api/v1/spaces.test.ts +2 -0
  197. package/src/api/v1/spaces.ts +2 -1
  198. package/src/api/v1/tags.test.ts +2 -0
  199. package/src/api/v1/tags.ts +2 -1
  200. package/src/api/v1/users.test.ts +26 -0
  201. package/src/api/v1/users.ts +8 -2
  202. package/src/api/v1/validation.test.ts +2 -0
  203. package/src/api/v1/validation.ts +6 -2
  204. package/src/api/v2/content.test.ts +2 -0
  205. package/src/api/v2/content.ts +3 -2
  206. package/src/api/v2/dashboards.test.ts +32 -0
  207. package/src/api/v2/dashboards.ts +18 -0
  208. package/src/api/v2/organization-roles.test.ts +2 -0
  209. package/src/api/v2/organization-roles.ts +2 -1
  210. package/src/api/v2/project-role-assignments.test.ts +2 -0
  211. package/src/api/v2/project-role-assignments.ts +2 -1
  212. package/src/api/v2/query.test.ts +2 -0
  213. package/src/api/v2/query.ts +2 -1
  214. package/src/api/v2/validation.ts +48 -0
  215. package/src/client.test.ts +1 -0
  216. package/src/client.ts +27 -17
  217. package/src/config.ts +38 -10
  218. package/src/errors.test.ts +1 -0
  219. package/src/http/axios-client.ts +8 -5
  220. package/src/http/http-client.ts +8 -6
  221. package/src/http/interceptors.ts +23 -10
  222. package/src/http/rate-limiter.test.ts +1 -0
  223. package/src/http/rate-limiter.ts +3 -1
  224. package/src/index.test.ts +16 -7
  225. package/src/index.ts +16 -1
  226. package/src/pagination/fetch-all-pages.test.ts +2 -0
  227. package/src/types/api.ts +1 -1
  228. package/src/utils/env.test.ts +16 -4
  229. package/src/utils/env.ts +61 -10
  230. package/src/utils/logger.ts +6 -4
  231. package/src/utils/retry.test.ts +1 -0
  232. package/src/utils/retry.ts +2 -1
  233. package/src/utils/secret-string.test.ts +27 -0
  234. package/tsconfig.json +4 -2
  235. package/dist/api/v1/ai-agents.d.ts +0 -63
  236. package/dist/api/v1/ai-agents.js +0 -173
  237. 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', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.getAdminThreads({
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', () => __awaiter(void 0, void 0, void 0, function* () {
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
- yield client.getAdminThreads();
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', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.listAdminAgents();
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', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.getAiOrganizationSettings();
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', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.updateAiOrganizationSettings(body);
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', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.listAgents('proj1');
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}', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.getAgent('proj1', 'a1');
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', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.createAgent('proj1', body);
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', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.updateAgent('proj1', 'a1', body);
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}', () => __awaiter(void 0, void 0, void 0, function* () {
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
- yield client.deleteAgent('proj1', 'a1');
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', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.listAgentThreads('proj1', 'a1');
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', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.createAgentThread('proj1', 'a1');
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', () => __awaiter(void 0, void 0, void 0, function* () {
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
- 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* () {
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 = yield client.getAgentThread('proj1', 'a1', 't1');
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)('generateAgentThreadResponse should call POST .../threads/{threadUuid}/generate', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.generateAgentThreadResponse('proj1', 'a1', 't1', {
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).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/threads/t1/generate', {
160
- prompt: 'What is the total revenue?',
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', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.listEvaluations('proj1', 'a1');
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', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.createEvaluation('proj1', 'a1', body);
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}', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.getEvaluation('proj1', 'a1', 'e1');
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}', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.updateEvaluation('proj1', 'a1', 'e1', body);
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', () => __awaiter(void 0, void 0, void 0, function* () {
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
- vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(undefined);
203
- yield client.appendToEvaluation('proj1', 'a1', 'e1', body);
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
- (0, vitest_1.it)('deleteEvaluation should call DELETE .../evaluations/{evalUuid}', () => __awaiter(void 0, void 0, void 0, function* () {
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
- yield client.deleteEvaluation('proj1', 'a1', 'e1');
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', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.runEvaluation('proj1', 'a1', 'e1');
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 call GET .../evaluations/{evalUuid}/runs and unwrap runs array', () => __awaiter(void 0, void 0, void 0, function* () {
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 = { data: { runs }, pagination: undefined };
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 = yield client.listEvaluationRuns('proj1', 'a1', 'e1');
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}', () => __awaiter(void 0, void 0, void 0, function* () {
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 = yield client.getEvaluationRunResults('proj1', 'a1', 'e1', 'r1');
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;