@lightdash-tools/client 0.19.0 → 0.21.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.
@@ -1,30 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applyAgentChange = applyAgentChange;
4
+ const common_1 = require("@lightdash-tools/common");
4
5
  const apply_context_1 = require("./apply-context");
5
6
  function findDesiredAgent(ctx, key) {
6
7
  return ctx.bundle.spec.agents.find((a) => a.key === key);
7
8
  }
8
- function buildCreateAgentBody(desired, projectUuid) {
9
- var _a, _b, _c, _d, _e;
10
- return {
11
- name: desired.name,
12
- projectUuid,
13
- description: (_a = desired.description) !== null && _a !== void 0 ? _a : null,
14
- instruction: (_b = desired.instruction) !== null && _b !== void 0 ? _b : null,
15
- tags: (_c = desired.tags) !== null && _c !== void 0 ? _c : null,
16
- integrations: [],
17
- imageUrl: null,
18
- groupAccess: [],
19
- userAccess: [],
20
- spaceAccess: [],
21
- enableDataAccess: (_d = desired.enableDataAccess) !== null && _d !== void 0 ? _d : false,
22
- enableSelfImprovement: (_e = desired.enableSelfImprovement) !== null && _e !== void 0 ? _e : false,
23
- version: 1,
24
- };
9
+ function buildAgentUpdatePatch(desired, agentUuid) {
10
+ var _a, _b, _c;
11
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ uuid: agentUuid, name: desired.name, description: (_a = desired.description) !== null && _a !== void 0 ? _a : null, instruction: (_b = desired.instruction) !== null && _b !== void 0 ? _b : null, tags: (_c = desired.tags) !== null && _c !== void 0 ? _c : null }, (desired.enableDataAccess !== undefined
12
+ ? { enableDataAccess: desired.enableDataAccess }
13
+ : {})), (desired.enableContentTools !== undefined
14
+ ? { enableContentTools: desired.enableContentTools }
15
+ : {})), (desired.enableSqlMode !== undefined ? { enableSqlMode: desired.enableSqlMode } : {})), (desired.enableUserContext !== undefined
16
+ ? { enableUserContext: desired.enableUserContext }
17
+ : {})), (desired.adminOnly !== undefined ? { adminOnly: desired.adminOnly } : {})), (desired.enableSelfImprovement !== undefined
18
+ ? { enableSelfImprovement: desired.enableSelfImprovement }
19
+ : {})), (desired.spaceAccess !== undefined ? { spaceAccess: desired.spaceAccess } : {}));
25
20
  }
26
21
  async function applyAgentChange(ctx, change) {
27
- var _a, _b, _c, _d, _e;
22
+ var _a, _b;
28
23
  const { client, projectUuid, agentUuidByKey } = ctx;
29
24
  if (change.operation === 'create') {
30
25
  const desired = findDesiredAgent(ctx, change.key);
@@ -32,7 +27,7 @@ async function applyAgentChange(ctx, change) {
32
27
  (0, apply_context_1.recordApplyFailure)(ctx, change, `Agent spec not found for key '${change.key}'`);
33
28
  return false;
34
29
  }
35
- const created = await client.v1.aiAgents.createAgent(projectUuid, buildCreateAgentBody(desired, projectUuid));
30
+ const created = await client.v1.aiAgents.createAgent(projectUuid, (0, common_1.buildSecureCreateAiAgentBody)(Object.assign(Object.assign({}, desired), { projectUuid })));
36
31
  agentUuidByKey.set(desired.key, created.uuid);
37
32
  return true;
38
33
  }
@@ -47,11 +42,7 @@ async function applyAgentChange(ctx, change) {
47
42
  (0, apply_context_1.recordApplyFailure)(ctx, change, `Could not resolve agent UUID for key '${change.key}'`);
48
43
  return false;
49
44
  }
50
- await client.v1.aiAgents.updateAgent(projectUuid, agentUuid, Object.assign(Object.assign({ uuid: agentUuid, name: desired.name, description: (_c = desired.description) !== null && _c !== void 0 ? _c : null, instruction: (_d = desired.instruction) !== null && _d !== void 0 ? _d : null, tags: (_e = desired.tags) !== null && _e !== void 0 ? _e : null }, (desired.enableDataAccess !== undefined
51
- ? { enableDataAccess: desired.enableDataAccess }
52
- : {})), (desired.enableSelfImprovement !== undefined
53
- ? { enableSelfImprovement: desired.enableSelfImprovement }
54
- : {})));
45
+ await client.v1.aiAgents.updateAgent(projectUuid, agentUuid, buildAgentUpdatePatch(desired, agentUuid));
55
46
  agentUuidByKey.set(desired.key, agentUuid);
56
47
  return true;
57
48
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const common_1 = require("@lightdash-tools/common");
4
+ const vitest_1 = require("vitest");
5
+ const apply_agent_change_js_1 = require("./apply-agent-change.js");
6
+ const PROJECT_UUID = '550e8400-e29b-41d4-a716-446655440000';
7
+ const bundle = {
8
+ apiVersion: 'lightdash.ai/v1alpha1',
9
+ kind: 'LightdashAiAgentBundle',
10
+ metadata: { name: 'test-bundle' },
11
+ spec: {
12
+ projectUuid: PROJECT_UUID,
13
+ agents: [
14
+ {
15
+ key: 'a1',
16
+ name: 'Governed Agent',
17
+ evaluations: [],
18
+ },
19
+ ],
20
+ },
21
+ };
22
+ function makeCreateContext(createAgent) {
23
+ return {
24
+ bundle,
25
+ projectUuid: PROJECT_UUID,
26
+ client: {
27
+ v1: {
28
+ aiAgents: {
29
+ createAgent,
30
+ updateAgent: vitest_1.vi.fn(),
31
+ deleteAgent: vitest_1.vi.fn(),
32
+ },
33
+ },
34
+ },
35
+ agentUuidByKey: new Map(),
36
+ failed: [],
37
+ };
38
+ }
39
+ (0, vitest_1.describe)('applyAgentChange create', () => {
40
+ (0, vitest_1.it)('applies secure defaults when bundle omits permission flags', async () => {
41
+ var _a;
42
+ const createAgent = vitest_1.vi.fn().mockResolvedValue({ uuid: 'agent-1', name: 'Governed Agent' });
43
+ const ctx = makeCreateContext(createAgent);
44
+ const ok = await (0, apply_agent_change_js_1.applyAgentChange)(ctx, {
45
+ resourceType: 'agent',
46
+ operation: 'create',
47
+ key: 'a1',
48
+ path: 'agents[a1]',
49
+ });
50
+ (0, vitest_1.expect)(ok).toBe(true);
51
+ (0, vitest_1.expect)(createAgent).toHaveBeenCalledWith(PROJECT_UUID, vitest_1.expect.objectContaining((0, common_1.resolveSecureAgentCreateFlags)({})));
52
+ (0, vitest_1.expect)((_a = createAgent.mock.calls[0]) === null || _a === void 0 ? void 0 : _a[1]).toMatchObject(common_1.SECURE_AGENT_CREATE_DEFAULTS);
53
+ });
54
+ (0, vitest_1.it)('forwards spaceAccess from bundle spec on create', async () => {
55
+ var _a;
56
+ const spaceUuid = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa';
57
+ const createAgent = vitest_1.vi.fn().mockResolvedValue({ uuid: 'agent-1', name: 'Scoped Agent' });
58
+ const bundleWithSpaces = Object.assign(Object.assign({}, bundle), { spec: Object.assign(Object.assign({}, bundle.spec), { agents: [
59
+ {
60
+ key: 'a1',
61
+ name: 'Scoped Agent',
62
+ spaceAccess: [spaceUuid],
63
+ evaluations: [],
64
+ },
65
+ ] }) });
66
+ const ctx = Object.assign(Object.assign({}, makeCreateContext(createAgent)), { bundle: bundleWithSpaces });
67
+ const ok = await (0, apply_agent_change_js_1.applyAgentChange)(ctx, {
68
+ resourceType: 'agent',
69
+ operation: 'create',
70
+ key: 'a1',
71
+ path: 'agents[a1]',
72
+ });
73
+ (0, vitest_1.expect)(ok).toBe(true);
74
+ (0, vitest_1.expect)((_a = createAgent.mock.calls[0]) === null || _a === void 0 ? void 0 : _a[1]).toMatchObject({ spaceAccess: [spaceUuid] });
75
+ });
76
+ });
77
+ (0, vitest_1.describe)('applyAgentChange update', () => {
78
+ (0, vitest_1.it)('forwards optional permission fields from bundle spec', async () => {
79
+ const updateAgent = vitest_1.vi.fn().mockResolvedValue({});
80
+ const bundleWithPerms = Object.assign(Object.assign({}, bundle), { spec: Object.assign(Object.assign({}, bundle.spec), { agents: [
81
+ {
82
+ key: 'a1',
83
+ uuid: 'agent-1',
84
+ name: 'Governed Agent',
85
+ enableContentTools: true,
86
+ adminOnly: false,
87
+ evaluations: [],
88
+ },
89
+ ] }) });
90
+ const ctx = {
91
+ bundle: bundleWithPerms,
92
+ projectUuid: PROJECT_UUID,
93
+ client: {
94
+ v1: {
95
+ aiAgents: {
96
+ createAgent: vitest_1.vi.fn(),
97
+ updateAgent,
98
+ deleteAgent: vitest_1.vi.fn(),
99
+ },
100
+ },
101
+ },
102
+ agentUuidByKey: new Map(),
103
+ failed: [],
104
+ };
105
+ const ok = await (0, apply_agent_change_js_1.applyAgentChange)(ctx, {
106
+ resourceType: 'agent',
107
+ operation: 'update',
108
+ key: 'a1',
109
+ agentUuid: 'agent-1',
110
+ path: 'agents[a1]',
111
+ });
112
+ (0, vitest_1.expect)(ok).toBe(true);
113
+ (0, vitest_1.expect)(updateAgent).toHaveBeenCalledWith(PROJECT_UUID, 'agent-1', {
114
+ uuid: 'agent-1',
115
+ name: 'Governed Agent',
116
+ description: null,
117
+ instruction: null,
118
+ tags: null,
119
+ enableContentTools: true,
120
+ adminOnly: false,
121
+ });
122
+ });
123
+ (0, vitest_1.it)('forwards spaceAccess from bundle spec on update', async () => {
124
+ const spaceUuid = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa';
125
+ const updateAgent = vitest_1.vi.fn().mockResolvedValue({});
126
+ const bundleWithSpaces = Object.assign(Object.assign({}, bundle), { spec: Object.assign(Object.assign({}, bundle.spec), { agents: [
127
+ {
128
+ key: 'a1',
129
+ uuid: 'agent-1',
130
+ name: 'Governed Agent',
131
+ spaceAccess: [spaceUuid],
132
+ evaluations: [],
133
+ },
134
+ ] }) });
135
+ const ctx = {
136
+ bundle: bundleWithSpaces,
137
+ projectUuid: PROJECT_UUID,
138
+ client: {
139
+ v1: {
140
+ aiAgents: {
141
+ createAgent: vitest_1.vi.fn(),
142
+ updateAgent,
143
+ deleteAgent: vitest_1.vi.fn(),
144
+ },
145
+ },
146
+ },
147
+ agentUuidByKey: new Map(),
148
+ failed: [],
149
+ };
150
+ const ok = await (0, apply_agent_change_js_1.applyAgentChange)(ctx, {
151
+ resourceType: 'agent',
152
+ operation: 'update',
153
+ key: 'a1',
154
+ agentUuid: 'agent-1',
155
+ path: 'agents[a1]',
156
+ });
157
+ (0, vitest_1.expect)(ok).toBe(true);
158
+ (0, vitest_1.expect)(updateAgent).toHaveBeenCalledWith(PROJECT_UUID, 'agent-1', vitest_1.expect.objectContaining({ spaceAccess: [spaceUuid] }));
159
+ });
160
+ });
@@ -17,7 +17,9 @@ class AiAgentsProjectClient extends base_client_1.BaseApiClient {
17
17
  }
18
18
  /** Create a new agent in a project (POST /projects/{projectUuid}/aiAgents). */
19
19
  async createAgent(projectUuid, body) {
20
- return this.http.post(`/projects/${projectUuid}/aiAgents`, body);
20
+ return this.http.post(`/projects/${projectUuid}/aiAgents`, body, undefined, {
21
+ maxRetries: 0,
22
+ });
21
23
  }
22
24
  /** Update an existing agent (PATCH /projects/{projectUuid}/aiAgents/{agentUuid}). */
23
25
  async updateAgent(projectUuid, agentUuid, body) {
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Project-scoped AI agent knowledge document client.
3
+ * Endpoints: /api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/documents/...
4
+ */
5
+ import { BaseApiClient } from '../../base-client';
6
+ import type { AiAgentDocument, AiAgentDocumentContent, AiAgentDocumentSummary, CreateAgentDocumentBody, UpdateAgentDocumentContentBody, UpdateAgentDocumentSettingsBody } from '@lightdash-tools/common';
7
+ export declare class AiAgentsDocumentsClient extends BaseApiClient {
8
+ /** List knowledge documents for an agent (GET …/documents). */
9
+ listDocuments(projectUuid: string, agentUuid: string): Promise<AiAgentDocumentSummary[]>;
10
+ /** Read full document content (GET …/documents/{documentUuid}/content). */
11
+ getDocumentContent(projectUuid: string, agentUuid: string, documentUuid: string): Promise<AiAgentDocumentContent>;
12
+ /** Create a knowledge document scoped to this agent (POST …/documents). */
13
+ createDocument(projectUuid: string, agentUuid: string, body: CreateAgentDocumentBody): Promise<AiAgentDocument>;
14
+ /** Replace document name and content (PATCH …/documents/{documentUuid}/content). */
15
+ updateDocumentContent(projectUuid: string, agentUuid: string, documentUuid: string, body: UpdateAgentDocumentContentBody): Promise<AiAgentDocument>;
16
+ /** Update document settings such as alwaysIncludeInContext (PATCH …/documents/{documentUuid}). */
17
+ updateDocumentSettings(projectUuid: string, agentUuid: string, documentUuid: string, body: UpdateAgentDocumentSettingsBody): Promise<void>;
18
+ /** Delete a knowledge document (DELETE …/documents/{documentUuid}). */
19
+ deleteDocument(projectUuid: string, agentUuid: string, documentUuid: string): Promise<void>;
20
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /**
3
+ * Project-scoped AI agent knowledge document client.
4
+ * Endpoints: /api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/documents/...
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.AiAgentsDocumentsClient = void 0;
8
+ const base_client_1 = require("../../base-client");
9
+ class AiAgentsDocumentsClient extends base_client_1.BaseApiClient {
10
+ /** List knowledge documents for an agent (GET …/documents). */
11
+ async listDocuments(projectUuid, agentUuid) {
12
+ return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/documents`);
13
+ }
14
+ /** Read full document content (GET …/documents/{documentUuid}/content). */
15
+ async getDocumentContent(projectUuid, agentUuid, documentUuid) {
16
+ return this.http.get(`/projects/${projectUuid}/aiAgents/${agentUuid}/documents/${documentUuid}/content`);
17
+ }
18
+ /** Create a knowledge document scoped to this agent (POST …/documents). */
19
+ async createDocument(projectUuid, agentUuid, body) {
20
+ return this.http.post(`/projects/${projectUuid}/aiAgents/${agentUuid}/documents`, body, undefined, { maxRetries: 0 });
21
+ }
22
+ /** Replace document name and content (PATCH …/documents/{documentUuid}/content). */
23
+ async updateDocumentContent(projectUuid, agentUuid, documentUuid, body) {
24
+ return this.http.patch(`/projects/${projectUuid}/aiAgents/${agentUuid}/documents/${documentUuid}/content`, body);
25
+ }
26
+ /** Update document settings such as alwaysIncludeInContext (PATCH …/documents/{documentUuid}). */
27
+ async updateDocumentSettings(projectUuid, agentUuid, documentUuid, body) {
28
+ await this.http.patch(`/projects/${projectUuid}/aiAgents/${agentUuid}/documents/${documentUuid}`, body);
29
+ }
30
+ /** Delete a knowledge document (DELETE …/documents/{documentUuid}). */
31
+ async deleteDocument(projectUuid, agentUuid, documentUuid) {
32
+ await this.http.delete(`/projects/${projectUuid}/aiAgents/${agentUuid}/documents/${documentUuid}`);
33
+ }
34
+ }
35
+ exports.AiAgentsDocumentsClient = AiAgentsDocumentsClient;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const documents_1 = require("./documents");
5
+ (0, vitest_1.describe)('AiAgentsDocumentsClient', () => {
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)('listDocuments should call GET …/documents', async () => {
17
+ const client = new documents_1.AiAgentsDocumentsClient(mockHttp);
18
+ const summaries = [{ uuid: 'd1', name: 'Glossary' }];
19
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(summaries);
20
+ const result = await client.listDocuments('proj1', 'a1');
21
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/documents');
22
+ (0, vitest_1.expect)(result).toEqual(summaries);
23
+ });
24
+ (0, vitest_1.it)('getDocumentContent should call GET …/documents/{uuid}/content', async () => {
25
+ const client = new documents_1.AiAgentsDocumentsClient(mockHttp);
26
+ const content = { uuid: 'd1', name: 'Glossary', mimeType: 'text/markdown', content: '# Hi' };
27
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(content);
28
+ const result = await client.getDocumentContent('proj1', 'a1', 'd1');
29
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/documents/d1/content');
30
+ (0, vitest_1.expect)(result).toEqual(content);
31
+ });
32
+ (0, vitest_1.it)('createDocument should call POST …/documents', async () => {
33
+ const client = new documents_1.AiAgentsDocumentsClient(mockHttp);
34
+ const body = {
35
+ name: 'Glossary',
36
+ content: '# Terms',
37
+ mimeType: 'text/markdown',
38
+ originalFilename: 'Glossary.md',
39
+ };
40
+ const created = Object.assign({ uuid: 'd1' }, body);
41
+ vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(created);
42
+ const result = await client.createDocument('proj1', 'a1', body);
43
+ (0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/documents', body, undefined, { maxRetries: 0 });
44
+ (0, vitest_1.expect)(result).toEqual(created);
45
+ });
46
+ (0, vitest_1.it)('updateDocumentContent should call PATCH …/content', async () => {
47
+ const client = new documents_1.AiAgentsDocumentsClient(mockHttp);
48
+ const body = { name: 'Glossary v2', content: '# Updated' };
49
+ const updated = Object.assign({ uuid: 'd1' }, body);
50
+ vitest_1.vi.mocked(mockHttp.patch).mockResolvedValue(updated);
51
+ const result = await client.updateDocumentContent('proj1', 'a1', 'd1', body);
52
+ (0, vitest_1.expect)(mockHttp.patch).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/documents/d1/content', body);
53
+ (0, vitest_1.expect)(result).toEqual(updated);
54
+ });
55
+ (0, vitest_1.it)('updateDocumentSettings should call PATCH …/documents/{uuid}', async () => {
56
+ const client = new documents_1.AiAgentsDocumentsClient(mockHttp);
57
+ vitest_1.vi.mocked(mockHttp.patch).mockResolvedValue(undefined);
58
+ await client.updateDocumentSettings('proj1', 'a1', 'd1', { alwaysIncludeInContext: true });
59
+ (0, vitest_1.expect)(mockHttp.patch).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/documents/d1', {
60
+ alwaysIncludeInContext: true,
61
+ });
62
+ });
63
+ (0, vitest_1.it)('deleteDocument should call DELETE …/documents/{uuid}', async () => {
64
+ const client = new documents_1.AiAgentsDocumentsClient(mockHttp);
65
+ vitest_1.vi.mocked(mockHttp.delete).mockResolvedValue(undefined);
66
+ await client.deleteDocument('proj1', 'a1', 'd1');
67
+ (0, vitest_1.expect)(mockHttp.delete).toHaveBeenCalledWith('/projects/proj1/aiAgents/a1/documents/d1');
68
+ });
69
+ });
@@ -6,12 +6,13 @@ import { BaseApiClient } from '../../base-client';
6
6
  import { type StartConversationThreadBody } from './threads';
7
7
  import type { RequestOptions } from './request-options';
8
8
  import type { HttpClient } from '../../../http/http-client';
9
- import type { AgentSuggestions, AiAgent, AiAgentEvaluation, AiAgentEvaluationRun, AiAgentEvaluationRunSummary, AiAgentEvaluationRunsListResponse, AiAgentEvaluationSummary, AiAgentExploreAccessSummary, AiAgentMcpServerTool, AiAgentsAdminThreadsResult, AiAgentSummary, AiAgentThread, AiAgentThreadMessageVizQuery, AiAgentThreadSummary, AiAgentUserPreferences, AiAgentVerifiedArtifactsListResult, AiAgentVerifiedQuestion, AiArtifact, AiMcpServer, AiMcpServerTool, AiModelOption, AiRouterRouteRequest, AiRouterRouteResponseResult, AppendEvaluationBody, CloneThreadBody, CreateAgentThreadBody, CreateAgentThreadMessageResult, CreateAiAgent, CreateEvaluationBody, CreateEvaluationResult, CreateProjectMcpServerBody, ExploreAccessSummaryBody, GenerateAgentThreadBody, GenerateAgentThreadResult, GenerateThreadTitleResult, GetAdminThreadsParams, GetAgentSuggestionsParams, GetAiOrganizationSettingsResult, ListVerifiedArtifactsParams, ReadinessScore, SubmitSqlApprovalBody, SubmitSqlApprovalResult, UpdateAiAgent, UpdateAiOrganizationSettings, UpdateAiOrganizationSettingsResult, UpdateAgentMcpServerToolsBody, UpdateEvaluationBody, UpdateMessageFeedbackBody } from '@lightdash-tools/common';
9
+ import type { AgentSuggestions, AiAgent, AiAgentDocument, AiAgentDocumentContent, AiAgentDocumentSummary, AiAgentEvaluation, AiAgentEvaluationRun, AiAgentEvaluationRunSummary, AiAgentEvaluationRunsListResponse, AiAgentEvaluationSummary, AiAgentExploreAccessSummary, AiAgentMcpServerTool, AiAgentsAdminThreadsResult, AiAgentSummary, AiAgentThread, AiAgentThreadMessageVizQuery, AiAgentThreadSummary, AiAgentUserPreferences, AiAgentVerifiedArtifactsListResult, AiAgentVerifiedQuestion, AiArtifact, AiMcpServer, AiMcpServerTool, AiModelOption, AiRouterRouteRequest, AiRouterRouteResponseResult, AppendEvaluationBody, CloneThreadBody, CreateAgentThreadBody, CreateAgentThreadMessageResult, CreateAgentDocumentBody, CreateAiAgent, CreateEvaluationBody, CreateEvaluationResult, CreateProjectMcpServerBody, ExploreAccessSummaryBody, GenerateAgentThreadBody, GenerateAgentThreadResult, GenerateThreadTitleResult, GetAdminThreadsParams, GetAgentSuggestionsParams, GetAiOrganizationSettingsResult, ListVerifiedArtifactsParams, ReadinessScore, SubmitSqlApprovalBody, SubmitSqlApprovalResult, UpdateAiAgent, UpdateAiOrganizationSettings, UpdateAgentDocumentContentBody, UpdateAgentDocumentSettingsBody, UpdateAiOrganizationSettingsResult, UpdateAgentMcpServerToolsBody, UpdateEvaluationBody, UpdateMessageFeedbackBody } from '@lightdash-tools/common';
10
10
  export declare class AiAgentsClient extends BaseApiClient {
11
11
  private readonly admin;
12
12
  private readonly agents;
13
13
  private readonly artifacts;
14
14
  private readonly discovery;
15
+ private readonly documents;
15
16
  private readonly threads;
16
17
  private readonly evaluations;
17
18
  private readonly feedback;
@@ -83,4 +84,10 @@ export declare class AiAgentsClient extends BaseApiClient {
83
84
  }): Promise<AiAgentEvaluationRunsListResponse>;
84
85
  listAllEvaluationRuns(projectUuid: string, agentUuid: string, evalUuid: string): Promise<AiAgentEvaluationRunSummary[]>;
85
86
  getEvaluationRunResults(projectUuid: string, agentUuid: string, evalUuid: string, runUuid: string): Promise<AiAgentEvaluationRun>;
87
+ listDocuments(projectUuid: string, agentUuid: string): Promise<AiAgentDocumentSummary[]>;
88
+ getDocumentContent(projectUuid: string, agentUuid: string, documentUuid: string): Promise<AiAgentDocumentContent>;
89
+ createDocument(projectUuid: string, agentUuid: string, body: CreateAgentDocumentBody): Promise<AiAgentDocument>;
90
+ updateDocumentContent(projectUuid: string, agentUuid: string, documentUuid: string, body: UpdateAgentDocumentContentBody): Promise<AiAgentDocument>;
91
+ updateDocumentSettings(projectUuid: string, agentUuid: string, documentUuid: string, body: UpdateAgentDocumentSettingsBody): Promise<void>;
92
+ deleteDocument(projectUuid: string, agentUuid: string, documentUuid: string): Promise<void>;
86
93
  }
@@ -10,6 +10,7 @@ const admin_1 = require("./admin");
10
10
  const agents_1 = require("./agents");
11
11
  const artifacts_1 = require("./artifacts");
12
12
  const discovery_1 = require("./discovery");
13
+ const documents_1 = require("./documents");
13
14
  const evaluations_1 = require("./evaluations");
14
15
  const feedback_1 = require("./feedback");
15
16
  const mcp_servers_1 = require("./mcp-servers");
@@ -23,6 +24,7 @@ class AiAgentsClient extends base_client_1.BaseApiClient {
23
24
  this.agents = new agents_1.AiAgentsProjectClient(http);
24
25
  this.artifacts = new artifacts_1.AiAgentsArtifactsClient(http);
25
26
  this.discovery = new discovery_1.AiAgentsDiscoveryClient(http);
27
+ this.documents = new documents_1.AiAgentsDocumentsClient(http);
26
28
  this.threads = new threads_1.AiAgentsThreadsClient(http);
27
29
  this.evaluations = new evaluations_1.AiAgentsEvaluationsClient(http);
28
30
  this.feedback = new feedback_1.AiAgentsFeedbackClient(http);
@@ -198,5 +200,24 @@ class AiAgentsClient extends base_client_1.BaseApiClient {
198
200
  getEvaluationRunResults(projectUuid, agentUuid, evalUuid, runUuid) {
199
201
  return this.evaluations.getEvaluationRunResults(projectUuid, agentUuid, evalUuid, runUuid);
200
202
  }
203
+ // ─── Project-scoped: knowledge documents ─────────────────────────────────────
204
+ listDocuments(projectUuid, agentUuid) {
205
+ return this.documents.listDocuments(projectUuid, agentUuid);
206
+ }
207
+ getDocumentContent(projectUuid, agentUuid, documentUuid) {
208
+ return this.documents.getDocumentContent(projectUuid, agentUuid, documentUuid);
209
+ }
210
+ createDocument(projectUuid, agentUuid, body) {
211
+ return this.documents.createDocument(projectUuid, agentUuid, body);
212
+ }
213
+ updateDocumentContent(projectUuid, agentUuid, documentUuid, body) {
214
+ return this.documents.updateDocumentContent(projectUuid, agentUuid, documentUuid, body);
215
+ }
216
+ updateDocumentSettings(projectUuid, agentUuid, documentUuid, body) {
217
+ return this.documents.updateDocumentSettings(projectUuid, agentUuid, documentUuid, body);
218
+ }
219
+ deleteDocument(projectUuid, agentUuid, documentUuid) {
220
+ return this.documents.deleteDocument(projectUuid, agentUuid, documentUuid);
221
+ }
201
222
  }
202
223
  exports.AiAgentsClient = AiAgentsClient;
@@ -89,7 +89,9 @@ const ai_agents_1 = require("./ai-agents");
89
89
  const created = { uuid: 'a2', name: 'New Agent', projectUuid: 'proj1' };
90
90
  vitest_1.vi.mocked(mockHttp.post).mockResolvedValue(created);
91
91
  const result = await client.createAgent('proj1', body);
92
- (0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents', body);
92
+ (0, vitest_1.expect)(mockHttp.post).toHaveBeenCalledWith('/projects/proj1/aiAgents', body, undefined, {
93
+ maxRetries: 0,
94
+ });
93
95
  (0, vitest_1.expect)(result).toEqual(created);
94
96
  });
95
97
  (0, vitest_1.it)('updateAgent should call PATCH /projects/{projectUuid}/aiAgents/{agentUuid} with body', async () => {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * SQL Runner API client. Endpoints for saved SQL charts (metadata + authored SQL body).
3
+ */
4
+ import { BaseApiClient } from '../base-client';
5
+ import type { components } from '@lightdash-tools/common';
6
+ /** Saved SQL chart including authored `sql` body. */
7
+ export type SqlChart = components['schemas']['SqlChart'];
8
+ export declare class SqlRunnerClient extends BaseApiClient {
9
+ /** Get a saved SQL chart by UUID within a project (includes authored SQL). */
10
+ getSavedSqlChart(projectUuid: string, uuid: string): Promise<SqlChart>;
11
+ /** Get a saved SQL chart by slug within a project (includes authored SQL). */
12
+ getSavedSqlChartBySlug(projectUuid: string, slug: string): Promise<SqlChart>;
13
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ * SQL Runner API client. Endpoints for saved SQL charts (metadata + authored SQL body).
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SqlRunnerClient = void 0;
7
+ const base_client_1 = require("../base-client");
8
+ class SqlRunnerClient extends base_client_1.BaseApiClient {
9
+ /** Get a saved SQL chart by UUID within a project (includes authored SQL). */
10
+ async getSavedSqlChart(projectUuid, uuid) {
11
+ return this.http.get(`/projects/${projectUuid}/sqlRunner/saved/${encodeURIComponent(uuid)}`);
12
+ }
13
+ /** Get a saved SQL chart by slug within a project (includes authored SQL). */
14
+ async getSavedSqlChartBySlug(projectUuid, slug) {
15
+ return this.http.get(`/projects/${projectUuid}/sqlRunner/saved/slug/${encodeURIComponent(slug)}`);
16
+ }
17
+ }
18
+ exports.SqlRunnerClient = SqlRunnerClient;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const sql_runner_js_1 = require("./sql-runner.js");
5
+ (0, vitest_1.describe)('SqlRunnerClient', () => {
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
+ getBytes: vitest_1.vi.fn(),
15
+ };
16
+ });
17
+ (0, vitest_1.it)('getSavedSqlChart should call GET /projects/{projectUuid}/sqlRunner/saved/{uuid}', async () => {
18
+ const client = new sql_runner_js_1.SqlRunnerClient(mockHttp);
19
+ const chart = {
20
+ savedSqlUuid: 'sql-1',
21
+ name: 'Orders SQL',
22
+ slug: 'orders-sql',
23
+ sql: 'SELECT 1',
24
+ limit: 500,
25
+ };
26
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(chart);
27
+ const result = await client.getSavedSqlChart('p1', 'sql-1');
28
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/sqlRunner/saved/sql-1');
29
+ (0, vitest_1.expect)(result).toEqual(chart);
30
+ });
31
+ (0, vitest_1.it)('getSavedSqlChartBySlug should call GET …/sqlRunner/saved/slug/{slug}', async () => {
32
+ const client = new sql_runner_js_1.SqlRunnerClient(mockHttp);
33
+ const chart = {
34
+ savedSqlUuid: 'sql-1',
35
+ name: 'Orders SQL',
36
+ slug: 'orders-sql',
37
+ sql: 'SELECT 1',
38
+ limit: 500,
39
+ };
40
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue(chart);
41
+ const result = await client.getSavedSqlChartBySlug('p1', 'orders-sql');
42
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/sqlRunner/saved/slug/orders-sql');
43
+ (0, vitest_1.expect)(result).toEqual(chart);
44
+ });
45
+ (0, vitest_1.it)('encodes uuid and slug path segments', async () => {
46
+ const client = new sql_runner_js_1.SqlRunnerClient(mockHttp);
47
+ vitest_1.vi.mocked(mockHttp.get).mockResolvedValue({});
48
+ await client.getSavedSqlChart('p1', 'a/b');
49
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/sqlRunner/saved/a%2Fb');
50
+ await client.getSavedSqlChartBySlug('p1', 'slug/with spaces');
51
+ (0, vitest_1.expect)(mockHttp.get).toHaveBeenCalledWith('/projects/p1/sqlRunner/saved/slug/slug%2Fwith%20spaces');
52
+ });
53
+ });
package/dist/client.d.ts CHANGED
@@ -14,6 +14,7 @@ import { ProjectsClient } from './api/v1/projects';
14
14
  import { QueryClient } from './api/v1/query';
15
15
  import { SchedulersClient } from './api/v1/schedulers';
16
16
  import { SpacesClient } from './api/v1/spaces';
17
+ import { SqlRunnerClient } from './api/v1/sql-runner';
17
18
  import { TagsClient } from './api/v1/tags';
18
19
  import { UsersClient } from './api/v1/users';
19
20
  import { ValidationClient } from './api/v1/validation';
@@ -47,6 +48,7 @@ export declare class V1ApiClients {
47
48
  readonly schedulers: SchedulersClient;
48
49
  readonly tags: TagsClient;
49
50
  readonly analytics: AnalyticsClient;
51
+ readonly sqlRunner: SqlRunnerClient;
50
52
  constructor(http: HttpClient);
51
53
  }
52
54
  /**
package/dist/client.js CHANGED
@@ -17,6 +17,7 @@ const projects_1 = require("./api/v1/projects");
17
17
  const query_1 = require("./api/v1/query");
18
18
  const schedulers_1 = require("./api/v1/schedulers");
19
19
  const spaces_1 = require("./api/v1/spaces");
20
+ const sql_runner_1 = require("./api/v1/sql-runner");
20
21
  const tags_1 = require("./api/v1/tags");
21
22
  const users_1 = require("./api/v1/users");
22
23
  const validation_1 = require("./api/v1/validation");
@@ -53,6 +54,7 @@ class V1ApiClients {
53
54
  this.schedulers = new schedulers_1.SchedulersClient(http);
54
55
  this.tags = new tags_1.TagsClient(http);
55
56
  this.analytics = new analytics_1.AnalyticsClient(http);
57
+ this.sqlRunner = new sql_runner_1.SqlRunnerClient(http);
56
58
  }
57
59
  }
58
60
  exports.V1ApiClients = V1ApiClients;
package/dist/index.d.ts CHANGED
@@ -12,6 +12,8 @@ export { MetricsClient } from './api/v1/metrics';
12
12
  export { SchedulersClient } from './api/v1/schedulers';
13
13
  export { TagsClient } from './api/v1/tags';
14
14
  export { AnalyticsClient } from './api/v1/analytics';
15
+ export { SqlRunnerClient } from './api/v1/sql-runner';
16
+ export type { SqlChart } from './api/v1/sql-runner';
15
17
  export { ContentClient } from './api/v2/content';
16
18
  export { ChartsClientV2 } from './api/v2/charts';
17
19
  export { DashboardsClientV2 } from './api/v2/dashboards';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SecretString = exports.RateLimiter = exports.isApiSuccessEnvelope = exports.HttpClient = exports.ENV_LIGHTDASH_PROXY_AUTHORIZATION = exports.ENV_LIGHTDASH_URL = exports.ENV_LIGHTDASH_API_KEY = exports.createBearerConfig = exports.mergeConfig = exports.loadConfigFromEnv = exports.isBlockedBinaryHostname = exports.DEFAULT_BINARY_MAX_BYTES = exports.CHART_IMAGE_MAX_BYTES = exports.CHART_IMAGE_EXPORT_TIMEOUT_MS = exports.CONTRACT_ERROR_MESSAGE = exports.CONTRACT_ERROR_NAME = exports.ChartImageSizeError = exports.NetworkError = exports.RateLimitError = exports.LightdashApiError = exports.DEFAULT_RETRY = exports.DEFAULT_TIMEOUT = exports.DEFAULT_RATE_LIMIT = exports.consoleLogger = exports.noopLogger = exports.DashboardsClientV2 = exports.ChartsClientV2 = exports.ContentClient = exports.AnalyticsClient = exports.TagsClient = exports.SchedulersClient = exports.MetricsClient = exports.ValidationClientV2 = exports.ValidationClient = exports.ProjectAccessClient = exports.AiAgentsClient = exports.ProjectRoleAssignmentsClient = exports.OrganizationRolesClient = exports.GroupsClient = exports.UsersClient = exports.resolveEvaluationRun = exports.applyBundleDiff = exports.fetchBundleCurrentState = exports.V2ApiClients = exports.V1ApiClients = exports.LightdashClient = void 0;
3
+ exports.SecretString = exports.RateLimiter = exports.isApiSuccessEnvelope = exports.HttpClient = exports.ENV_LIGHTDASH_PROXY_AUTHORIZATION = exports.ENV_LIGHTDASH_URL = exports.ENV_LIGHTDASH_API_KEY = exports.createBearerConfig = exports.mergeConfig = exports.loadConfigFromEnv = exports.isBlockedBinaryHostname = exports.DEFAULT_BINARY_MAX_BYTES = exports.CHART_IMAGE_MAX_BYTES = exports.CHART_IMAGE_EXPORT_TIMEOUT_MS = exports.CONTRACT_ERROR_MESSAGE = exports.CONTRACT_ERROR_NAME = exports.ChartImageSizeError = exports.NetworkError = exports.RateLimitError = exports.LightdashApiError = exports.DEFAULT_RETRY = exports.DEFAULT_TIMEOUT = exports.DEFAULT_RATE_LIMIT = exports.consoleLogger = exports.noopLogger = exports.DashboardsClientV2 = exports.ChartsClientV2 = exports.ContentClient = exports.SqlRunnerClient = exports.AnalyticsClient = exports.TagsClient = exports.SchedulersClient = exports.MetricsClient = exports.ValidationClientV2 = exports.ValidationClient = exports.ProjectAccessClient = exports.AiAgentsClient = exports.ProjectRoleAssignmentsClient = exports.OrganizationRolesClient = exports.GroupsClient = exports.UsersClient = exports.resolveEvaluationRun = exports.applyBundleDiff = exports.fetchBundleCurrentState = exports.V2ApiClients = exports.V1ApiClients = exports.LightdashClient = void 0;
4
4
  var client_1 = require("./client");
5
5
  Object.defineProperty(exports, "LightdashClient", { enumerable: true, get: function () { return client_1.LightdashClient; } });
6
6
  Object.defineProperty(exports, "V1ApiClients", { enumerable: true, get: function () { return client_1.V1ApiClients; } });
@@ -33,6 +33,8 @@ var tags_1 = require("./api/v1/tags");
33
33
  Object.defineProperty(exports, "TagsClient", { enumerable: true, get: function () { return tags_1.TagsClient; } });
34
34
  var analytics_1 = require("./api/v1/analytics");
35
35
  Object.defineProperty(exports, "AnalyticsClient", { enumerable: true, get: function () { return analytics_1.AnalyticsClient; } });
36
+ var sql_runner_1 = require("./api/v1/sql-runner");
37
+ Object.defineProperty(exports, "SqlRunnerClient", { enumerable: true, get: function () { return sql_runner_1.SqlRunnerClient; } });
36
38
  var content_1 = require("./api/v2/content");
37
39
  Object.defineProperty(exports, "ContentClient", { enumerable: true, get: function () { return content_1.ContentClient; } });
38
40
  var charts_1 = require("./api/v2/charts");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash-tools/client",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "Client library for Lightdash AI.",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -15,7 +15,7 @@
15
15
  "dependencies": {
16
16
  "axios": "^1.19.0",
17
17
  "bottleneck": "^2.19.5",
18
- "@lightdash-tools/common": "0.19.0"
18
+ "@lightdash-tools/common": "0.21.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/node": "^25.9.3"