@chanl-ai/sdk 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/adapters/openai.d.ts +106 -0
  2. package/dist/adapters/openai.d.ts.map +1 -0
  3. package/dist/adapters/openai.js +185 -0
  4. package/dist/adapters/openai.js.map +1 -0
  5. package/dist/client.d.ts +74 -0
  6. package/dist/client.d.ts.map +1 -0
  7. package/dist/client.js +293 -0
  8. package/dist/client.js.map +1 -0
  9. package/dist/errors/index.d.ts +179 -0
  10. package/dist/errors/index.d.ts.map +1 -0
  11. package/dist/errors/index.js +319 -0
  12. package/dist/errors/index.js.map +1 -0
  13. package/dist/index.d.ts +38 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +76 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/live/index.d.ts +9 -0
  18. package/dist/live/index.d.ts.map +1 -0
  19. package/dist/live/index.js +16 -0
  20. package/dist/live/index.js.map +1 -0
  21. package/dist/live/live-call.d.ts +48 -0
  22. package/dist/live/live-call.d.ts.map +1 -0
  23. package/dist/live/live-call.js +148 -0
  24. package/dist/live/live-call.js.map +1 -0
  25. package/dist/live/live-chat.d.ts +71 -0
  26. package/dist/live/live-chat.d.ts.map +1 -0
  27. package/dist/live/live-chat.js +95 -0
  28. package/dist/live/live-chat.js.map +1 -0
  29. package/dist/live/live-execution.d.ts +55 -0
  30. package/dist/live/live-execution.d.ts.map +1 -0
  31. package/dist/live/live-execution.js +170 -0
  32. package/dist/live/live-execution.js.map +1 -0
  33. package/dist/live/typed-emitter.d.ts +15 -0
  34. package/dist/live/typed-emitter.d.ts.map +1 -0
  35. package/dist/live/typed-emitter.js +40 -0
  36. package/dist/live/typed-emitter.js.map +1 -0
  37. package/dist/live/types.d.ts +24 -0
  38. package/dist/live/types.d.ts.map +1 -0
  39. package/dist/live/types.js +6 -0
  40. package/dist/live/types.js.map +1 -0
  41. package/dist/modules/agents.d.ts +378 -0
  42. package/dist/modules/agents.d.ts.map +1 -0
  43. package/dist/modules/agents.js +259 -0
  44. package/dist/modules/agents.js.map +1 -0
  45. package/dist/modules/alerts.d.ts +43 -0
  46. package/dist/modules/alerts.d.ts.map +1 -0
  47. package/dist/modules/alerts.js +56 -0
  48. package/dist/modules/alerts.js.map +1 -0
  49. package/dist/modules/audio.d.ts +47 -0
  50. package/dist/modules/audio.d.ts.map +1 -0
  51. package/dist/modules/audio.js +75 -0
  52. package/dist/modules/audio.js.map +1 -0
  53. package/dist/modules/auth.d.ts +76 -0
  54. package/dist/modules/auth.d.ts.map +1 -0
  55. package/dist/modules/auth.js +59 -0
  56. package/dist/modules/auth.js.map +1 -0
  57. package/dist/modules/calls.d.ts +825 -0
  58. package/dist/modules/calls.d.ts.map +1 -0
  59. package/dist/modules/calls.js +398 -0
  60. package/dist/modules/calls.js.map +1 -0
  61. package/dist/modules/chat.d.ts +165 -0
  62. package/dist/modules/chat.d.ts.map +1 -0
  63. package/dist/modules/chat.js +169 -0
  64. package/dist/modules/chat.js.map +1 -0
  65. package/dist/modules/health.d.ts +45 -0
  66. package/dist/modules/health.d.ts.map +1 -0
  67. package/dist/modules/health.js +22 -0
  68. package/dist/modules/health.js.map +1 -0
  69. package/dist/modules/knowledge.d.ts +202 -0
  70. package/dist/modules/knowledge.d.ts.map +1 -0
  71. package/dist/modules/knowledge.js +147 -0
  72. package/dist/modules/knowledge.js.map +1 -0
  73. package/dist/modules/mcp.d.ts +140 -0
  74. package/dist/modules/mcp.d.ts.map +1 -0
  75. package/dist/modules/mcp.js +110 -0
  76. package/dist/modules/mcp.js.map +1 -0
  77. package/dist/modules/memory.d.ts +163 -0
  78. package/dist/modules/memory.d.ts.map +1 -0
  79. package/dist/modules/memory.js +208 -0
  80. package/dist/modules/memory.js.map +1 -0
  81. package/dist/modules/personas.d.ts +168 -0
  82. package/dist/modules/personas.d.ts.map +1 -0
  83. package/dist/modules/personas.js +106 -0
  84. package/dist/modules/personas.js.map +1 -0
  85. package/dist/modules/prompts.d.ts +128 -0
  86. package/dist/modules/prompts.d.ts.map +1 -0
  87. package/dist/modules/prompts.js +93 -0
  88. package/dist/modules/prompts.js.map +1 -0
  89. package/dist/modules/scenarios.d.ts +294 -0
  90. package/dist/modules/scenarios.d.ts.map +1 -0
  91. package/dist/modules/scenarios.js +349 -0
  92. package/dist/modules/scenarios.js.map +1 -0
  93. package/dist/modules/scorecard.d.ts +642 -0
  94. package/dist/modules/scorecard.d.ts.map +1 -0
  95. package/dist/modules/scorecard.js +327 -0
  96. package/dist/modules/scorecard.js.map +1 -0
  97. package/dist/modules/tools.d.ts +222 -0
  98. package/dist/modules/tools.d.ts.map +1 -0
  99. package/dist/modules/tools.js +302 -0
  100. package/dist/modules/tools.js.map +1 -0
  101. package/dist/modules/toolsets.d.ts +173 -0
  102. package/dist/modules/toolsets.d.ts.map +1 -0
  103. package/dist/modules/toolsets.js +216 -0
  104. package/dist/modules/toolsets.js.map +1 -0
  105. package/dist/modules/transcript.d.ts +60 -0
  106. package/dist/modules/transcript.d.ts.map +1 -0
  107. package/dist/modules/transcript.js +69 -0
  108. package/dist/modules/transcript.js.map +1 -0
  109. package/dist/modules/workspace.d.ts +48 -0
  110. package/dist/modules/workspace.d.ts.map +1 -0
  111. package/dist/modules/workspace.js +49 -0
  112. package/dist/modules/workspace.js.map +1 -0
  113. package/dist/types/api.d.ts +8 -0
  114. package/dist/types/api.d.ts.map +1 -0
  115. package/dist/types/api.js +25 -0
  116. package/dist/types/api.js.map +1 -0
  117. package/dist/types/config.d.ts +70 -0
  118. package/dist/types/config.d.ts.map +1 -0
  119. package/dist/types/config.js +3 -0
  120. package/dist/types/config.js.map +1 -0
  121. package/dist/types/memory.d.ts +243 -0
  122. package/dist/types/memory.d.ts.map +1 -0
  123. package/dist/types/memory.js +9 -0
  124. package/dist/types/memory.js.map +1 -0
  125. package/dist/types/tool-calls.d.ts +61 -0
  126. package/dist/types/tool-calls.d.ts.map +1 -0
  127. package/dist/types/tool-calls.js +9 -0
  128. package/dist/types/tool-calls.js.map +1 -0
  129. package/dist/types/tools.d.ts +321 -0
  130. package/dist/types/tools.d.ts.map +1 -0
  131. package/dist/types/tools.js +9 -0
  132. package/dist/types/tools.js.map +1 -0
  133. package/dist/types/toolsets.d.ts +149 -0
  134. package/dist/types/toolsets.d.ts.map +1 -0
  135. package/dist/types/toolsets.js +8 -0
  136. package/dist/types/toolsets.js.map +1 -0
  137. package/package.json +60 -0
@@ -0,0 +1,327 @@
1
+ "use strict";
2
+ /**
3
+ * ScorecardModule - SDK module for scorecard management and evaluation
4
+ *
5
+ * Provides operations for:
6
+ * - Scorecard CRUD operations
7
+ * - Category and criteria management
8
+ * - Evaluation and results retrieval
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.ScorecardModule = void 0;
12
+ // ==================== Module Implementation ====================
13
+ class ScorecardModule {
14
+ constructor(sdk) {
15
+ this.sdk = sdk;
16
+ }
17
+ // ==================== Scorecard CRUD ====================
18
+ /**
19
+ * List all scorecards with optional filters
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const { data } = await sdk.scorecards.list();
24
+ * console.log(data.scorecards);
25
+ *
26
+ * // Filter by status
27
+ * const { data } = await sdk.scorecards.list({ status: 'active' });
28
+ * ```
29
+ */
30
+ async list(filters) {
31
+ const queryParams = new URLSearchParams();
32
+ if (filters?.status)
33
+ queryParams.append('status', filters.status);
34
+ if (filters?.industry)
35
+ queryParams.append('industry', filters.industry);
36
+ if (filters?.useCase)
37
+ queryParams.append('useCase', filters.useCase);
38
+ if (filters?.tags)
39
+ queryParams.append('tags', filters.tags.join(','));
40
+ if (filters?.page)
41
+ queryParams.append('page', filters.page.toString());
42
+ if (filters?.limit)
43
+ queryParams.append('limit', filters.limit.toString());
44
+ if (filters?.sortBy)
45
+ queryParams.append('sortBy', filters.sortBy);
46
+ if (filters?.sortOrder)
47
+ queryParams.append('sortOrder', filters.sortOrder);
48
+ const url = `/api/v1/scorecards${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
49
+ return this.sdk.request('GET', url);
50
+ }
51
+ /**
52
+ * Get a scorecard by ID
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const { data } = await sdk.scorecards.get('scorecard_abc');
57
+ * console.log(data.name, data.status);
58
+ * ```
59
+ */
60
+ async get(id) {
61
+ return this.sdk.request('GET', `/api/v1/scorecards/${id}`);
62
+ }
63
+ /**
64
+ * Create a new scorecard
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const { data } = await sdk.scorecards.create({
69
+ * name: 'Customer Service Quality',
70
+ * description: 'Evaluate customer service call quality',
71
+ * status: 'active',
72
+ * passingThreshold: 70,
73
+ * scoringAlgorithm: 'weighted_average'
74
+ * });
75
+ * ```
76
+ */
77
+ async create(data) {
78
+ return this.sdk.request('POST', '/api/v1/scorecards', data);
79
+ }
80
+ /**
81
+ * Update a scorecard
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const { data } = await sdk.scorecards.update('scorecard_abc', {
86
+ * name: 'Updated Name',
87
+ * status: 'inactive'
88
+ * });
89
+ * ```
90
+ */
91
+ async update(id, data) {
92
+ return this.sdk.request('PUT', `/api/v1/scorecards/${id}`, data);
93
+ }
94
+ /**
95
+ * Delete a scorecard
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * await sdk.scorecards.delete('scorecard_abc');
100
+ * ```
101
+ */
102
+ async delete(id) {
103
+ return this.sdk.request('DELETE', `/api/v1/scorecards/${id}`);
104
+ }
105
+ // ==================== Category Operations ====================
106
+ /**
107
+ * List categories for a scorecard
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * const { data } = await sdk.scorecards.listCategories('ws_123', 'scorecard_abc');
112
+ * console.log(data.categories);
113
+ * ```
114
+ */
115
+ async listCategories(scorecardId) {
116
+ return this.sdk.request('GET', `/api/v1/scorecards/${scorecardId}/categories`);
117
+ }
118
+ /**
119
+ * Get a category by ID
120
+ */
121
+ async getCategory(scorecardId, categoryId) {
122
+ return this.sdk.request('GET', `/api/v1/scorecards/${scorecardId}/categories/${categoryId}`);
123
+ }
124
+ /**
125
+ * Create a category for a scorecard
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * const { data } = await sdk.scorecards.createCategory('ws_123', 'scorecard_abc', {
130
+ * name: 'Greeting',
131
+ * description: 'Opening greeting quality',
132
+ * weight: 20
133
+ * });
134
+ * ```
135
+ */
136
+ async createCategory(scorecardId, data) {
137
+ return this.sdk.request('POST', `/api/v1/scorecards/${scorecardId}/categories`, data);
138
+ }
139
+ /**
140
+ * Update a category
141
+ */
142
+ async updateCategory(scorecardId, categoryId, data) {
143
+ return this.sdk.request('PUT', `/api/v1/scorecards/${scorecardId}/categories/${categoryId}`, data);
144
+ }
145
+ /**
146
+ * Delete a category
147
+ */
148
+ async deleteCategory(scorecardId, categoryId) {
149
+ return this.sdk.request('DELETE', `/api/v1/scorecards/${scorecardId}/categories/${categoryId}`);
150
+ }
151
+ // ==================== Criteria Operations ====================
152
+ /**
153
+ * List criteria for a scorecard
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const { data } = await sdk.scorecards.listCriteria('ws_123', 'scorecard_abc');
158
+ * console.log(data.criteria);
159
+ * ```
160
+ */
161
+ async listCriteria(scorecardId) {
162
+ return this.sdk.request('GET', `/api/v1/scorecards/${scorecardId}/criteria`);
163
+ }
164
+ /**
165
+ * Get a criterion by ID
166
+ */
167
+ async getCriterion(scorecardId, criterionId) {
168
+ return this.sdk.request('GET', `/api/v1/scorecards/${scorecardId}/criteria/${criterionId}`);
169
+ }
170
+ /**
171
+ * Create a criterion for a scorecard
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * // Prompt-based criterion
176
+ * const { data } = await sdk.scorecards.createCriterion('ws_123', 'scorecard_abc', {
177
+ * key: 'proper_greeting',
178
+ * name: 'Proper Greeting',
179
+ * type: 'prompt',
180
+ * settings: {
181
+ * description: 'Agent greeted customer properly with name and company',
182
+ * evaluationType: 'boolean'
183
+ * },
184
+ * threshold: { expectedValue: true }
185
+ * });
186
+ *
187
+ * // Keyword-based criterion
188
+ * const { data } = await sdk.scorecards.createCriterion('ws_123', 'scorecard_abc', {
189
+ * key: 'thank_you',
190
+ * name: 'Said Thank You',
191
+ * type: 'keyword',
192
+ * settings: {
193
+ * matchType: 'must_contain',
194
+ * keyword: ['thank you', 'thanks']
195
+ * }
196
+ * });
197
+ * ```
198
+ */
199
+ async createCriterion(scorecardId, data) {
200
+ return this.sdk.request('POST', `/api/v1/scorecards/${scorecardId}/criteria`, data);
201
+ }
202
+ /**
203
+ * Update a criterion
204
+ */
205
+ async updateCriterion(scorecardId, criterionId, data) {
206
+ return this.sdk.request('PATCH', `/api/v1/scorecards/${scorecardId}/criteria/${criterionId}`, data);
207
+ }
208
+ /**
209
+ * Delete a criterion
210
+ */
211
+ async deleteCriterion(scorecardId, criterionId) {
212
+ return this.sdk.request('DELETE', `/api/v1/scorecards/${scorecardId}/criteria/${criterionId}`);
213
+ }
214
+ // ==================== Evaluation & Results ====================
215
+ /**
216
+ * Evaluate a call with a scorecard
217
+ *
218
+ * @example
219
+ * ```typescript
220
+ * // Evaluate with auto-selected scorecard
221
+ * const { data } = await sdk.scorecards.evaluate('call_abc');
222
+ *
223
+ * // Evaluate with specific scorecard
224
+ * const { data } = await sdk.scorecards.evaluate('call_abc', {
225
+ * scorecardId: 'scorecard_xyz',
226
+ * force: true // Re-evaluate even if already evaluated
227
+ * });
228
+ * ```
229
+ */
230
+ async evaluate(callId, options) {
231
+ return this.sdk.request('POST', `/api/v1/scorecard-results/evaluate/${callId}`, options || {});
232
+ }
233
+ /**
234
+ * List evaluation results
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * const { data } = await sdk.scorecards.listResults('ws_123', {
239
+ * scorecardId: 'scorecard_abc',
240
+ * status: 'completed'
241
+ * });
242
+ * ```
243
+ */
244
+ async listResults(filters) {
245
+ const queryParams = new URLSearchParams();
246
+ if (filters?.scorecardId)
247
+ queryParams.append('scorecardId', filters.scorecardId);
248
+ if (filters?.callId)
249
+ queryParams.append('callId', filters.callId);
250
+ if (filters?.status)
251
+ queryParams.append('status', filters.status);
252
+ if (filters?.page)
253
+ queryParams.append('page', filters.page.toString());
254
+ if (filters?.limit)
255
+ queryParams.append('limit', filters.limit.toString());
256
+ if (filters?.sortBy)
257
+ queryParams.append('sortBy', filters.sortBy);
258
+ if (filters?.sortOrder)
259
+ queryParams.append('sortOrder', filters.sortOrder);
260
+ const url = `/api/v1/scorecard-results${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
261
+ return this.sdk.request('GET', url);
262
+ }
263
+ /**
264
+ * Get a result by ID
265
+ */
266
+ async getResult(resultId) {
267
+ return this.sdk.request('GET', `/api/v1/scorecard-results/${resultId}`);
268
+ }
269
+ /**
270
+ * Get results for a call
271
+ *
272
+ * @example
273
+ * ```typescript
274
+ * const { data } = await sdk.scorecards.getResultsByCall('ws_123', 'call_abc');
275
+ * for (const result of data.results) {
276
+ * console.log('Score:', result.overallScore);
277
+ * }
278
+ * ```
279
+ */
280
+ async getResultsByCall(callId) {
281
+ return this.sdk.request('GET', `/api/v1/scorecard-results/by-call/${callId}`);
282
+ }
283
+ /**
284
+ * Get populated result (with scorecard details) for a call
285
+ */
286
+ async getPopulatedResultsByCall(callId) {
287
+ return this.sdk.request('GET', `/api/v1/scorecard-results/by-call/${callId}/populated`);
288
+ }
289
+ /**
290
+ * Delete a result
291
+ */
292
+ async deleteResult(resultId) {
293
+ return this.sdk.request('DELETE', `/api/v1/scorecard-results/${resultId}`);
294
+ }
295
+ // ==================== Legacy Methods (deprecated) ====================
296
+ /**
297
+ * @deprecated Use list() instead
298
+ */
299
+ async getAll(params) {
300
+ const response = await this.list(params);
301
+ // Transform to match old response format
302
+ return {
303
+ ...response,
304
+ data: response.data?.scorecards || [],
305
+ };
306
+ }
307
+ /**
308
+ * @deprecated Use get() instead
309
+ */
310
+ async getById(id) {
311
+ return this.get(id);
312
+ }
313
+ /**
314
+ * @deprecated Use getResultsByCall() instead
315
+ */
316
+ async getEvaluationById(id) {
317
+ return this.getResult(id);
318
+ }
319
+ /**
320
+ * @deprecated Extraction is now part of CallsModule
321
+ */
322
+ async extractData(_data) {
323
+ throw new Error('extractData is deprecated. Use CallsModule.import() with customExtractions instead.');
324
+ }
325
+ }
326
+ exports.ScorecardModule = ScorecardModule;
327
+ //# sourceMappingURL=scorecard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scorecard.js","sourceRoot":"","sources":["../../src/modules/scorecard.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAmeH,kEAAkE;AAElE,MAAa,eAAe;IAC1B,YAAoB,GAAa;QAAb,QAAG,GAAH,GAAG,CAAU;IAAG,CAAC;IAErC,2DAA2D;IAE3D;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,IAAI,CACR,OAA0B;QAE1B,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;QAE1C,IAAI,OAAO,EAAE,MAAM;YAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAClE,IAAI,OAAO,EAAE,QAAQ;YAAE,WAAW,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxE,IAAI,OAAO,EAAE,OAAO;YAAE,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACrE,IAAI,OAAO,EAAE,IAAI;YAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACtE,IAAI,OAAO,EAAE,IAAI;YAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvE,IAAI,OAAO,EAAE,KAAK;YAAE,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC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E,6BAA6B,QAAQ,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,wEAAwE;IAExE;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,MAA0C;QAE1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,yCAAyC;QACzC,OAAO;YACL,GAAG,QAAQ;YACX,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,IAAI,EAAE;SACV,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CACX,EAAU;QAEV,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB,CACrB,EAAU;QAEV,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,KAAmD;QAEnD,MAAM,IAAI,KAAK,CACb,qFAAqF,CACtF,CAAC;IACJ,CAAC;CACF;AAjbD,0CAibC"}
@@ -0,0 +1,222 @@
1
+ /**
2
+ * ToolsModule - SDK module for MCP tool management and execution
3
+ *
4
+ * TDD Phase: GREEN - Implementation to make tests pass
5
+ *
6
+ * Provides CRUD operations for tools and execution capabilities.
7
+ * Supports both JWT auth (admin UI) and MCP API key auth.
8
+ */
9
+ import { ChanlSDK } from '../client';
10
+ import { ApiResponse } from '../types/config';
11
+ import type { ExecuteResult, CreateToolInput, UpdateToolInput, ToolFilters, ExecutionFilters, ToolListResponse, ToolResponse, ToolDeleteResponse, ExecutionListResponse, ToolCategoriesResponse } from '../types/tools';
12
+ export declare class ToolsModule {
13
+ private sdk;
14
+ constructor(sdk: ChanlSDK);
15
+ /**
16
+ * List all tools with optional filters
17
+ *
18
+ * @param filters - Optional filters for the query
19
+ * @returns Paginated list of tools
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // List all tools
24
+ * const { data } = await sdk.tools.list();
25
+ *
26
+ * // Filter by type and status
27
+ * const { data } = await sdk.tools.list({
28
+ * type: 'http',
29
+ * isEnabled: true,
30
+ * page: 1,
31
+ * limit: 10
32
+ * });
33
+ *
34
+ * // Exclude system tools (kb_search, chanl_reason, etc.)
35
+ * const { data } = await sdk.tools.list({
36
+ * includeSystem: false
37
+ * });
38
+ * ```
39
+ */
40
+ list(filters?: ToolFilters): Promise<ApiResponse<ToolListResponse>>;
41
+ /**
42
+ * Get a single tool by ID
43
+ *
44
+ * @param id - Tool ID
45
+ * @returns Tool details
46
+ * @throws NotFoundError if tool doesn't exist
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const { data } = await sdk.tools.get('tool_abc123');
51
+ * console.log(data.tool.name);
52
+ * ```
53
+ */
54
+ get(id: string): Promise<ApiResponse<ToolResponse>>;
55
+ /**
56
+ * Create a new tool
57
+ *
58
+ * @param workspaceId - Workspace ID
59
+ * @param input - Tool creation data
60
+ * @returns Created tool
61
+ * @throws ValidationError if input is invalid
62
+ * @throws ConflictError if tool name already exists
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const { data } = await sdk.tools.create({
67
+ * name: 'get_weather',
68
+ * description: 'Get weather for a city',
69
+ * type: 'http',
70
+ * inputSchema: {
71
+ * type: 'object',
72
+ * properties: { city: { type: 'string' } },
73
+ * required: ['city']
74
+ * },
75
+ * configuration: {
76
+ * http: { method: 'GET', url: 'https://wttr.in/{{city}}' }
77
+ * }
78
+ * });
79
+ * ```
80
+ */
81
+ create(input: CreateToolInput): Promise<ApiResponse<ToolResponse>>;
82
+ /**
83
+ * Update an existing tool
84
+ *
85
+ * @param workspaceId - Workspace ID
86
+ * @param id - Tool ID
87
+ * @param input - Update data
88
+ * @returns Updated tool
89
+ * @throws NotFoundError if tool doesn't exist
90
+ * @throws ValidationError if input is invalid
91
+ * @throws ConflictError if new name already exists
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const { data } = await sdk.tools.update('tool_abc123', {
96
+ * description: 'Updated description',
97
+ * isEnabled: false
98
+ * });
99
+ * ```
100
+ */
101
+ update(id: string, input: UpdateToolInput): Promise<ApiResponse<ToolResponse>>;
102
+ /**
103
+ * Delete a tool
104
+ *
105
+ * @param workspaceId - Workspace ID
106
+ * @param id - Tool ID
107
+ * @returns Deletion confirmation
108
+ * @throws NotFoundError if tool doesn't exist
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * const { data } = await sdk.tools.delete('tool_abc123');
113
+ * console.log(data.deleted); // true
114
+ * ```
115
+ */
116
+ delete(id: string): Promise<ApiResponse<ToolDeleteResponse>>;
117
+ /**
118
+ * Execute a tool with given arguments
119
+ *
120
+ * @param workspaceId - Workspace ID
121
+ * @param id - Tool ID
122
+ * @param args - Arguments to pass to the tool
123
+ * @returns Execution result
124
+ * @throws NotFoundError if tool doesn't exist
125
+ * @throws ValidationError if args don't match input schema
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * const { data } = await sdk.tools.execute('tool_abc123', {
130
+ * city: 'London',
131
+ * units: 'celsius'
132
+ * });
133
+ * console.log(data.output); // { temperature: 12, ... }
134
+ * ```
135
+ */
136
+ execute(id: string, args: Record<string, unknown>): Promise<ApiResponse<ExecuteResult>>;
137
+ /**
138
+ * Test a tool execution (same as execute but for testing in admin UI)
139
+ *
140
+ * @param workspaceId - Workspace ID
141
+ * @param id - Tool ID
142
+ * @param args - Arguments to pass to the tool
143
+ * @returns Execution result
144
+ * @throws NotFoundError if tool doesn't exist
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const { data } = await sdk.tools.test('tool_abc123', {
149
+ * city: 'London'
150
+ * });
151
+ * ```
152
+ */
153
+ test(id: string, args: Record<string, unknown>): Promise<ApiResponse<ExecuteResult>>;
154
+ /**
155
+ * Get execution history for a tool
156
+ *
157
+ * @param workspaceId - Workspace ID
158
+ * @param id - Tool ID
159
+ * @param filters - Optional filters for the query
160
+ * @returns Paginated list of executions
161
+ * @throws NotFoundError if tool doesn't exist
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * // Get all executions
166
+ * const { data } = await sdk.tools.getExecutions('ws_123', 'tool_abc123');
167
+ *
168
+ * // Filter by status and date range
169
+ * const { data } = await sdk.tools.getExecutions('ws_123', 'tool_abc123', {
170
+ * status: 'completed',
171
+ * fromDate: '2025-01-01',
172
+ * toDate: '2025-01-31'
173
+ * });
174
+ * ```
175
+ */
176
+ getExecutions(id: string, filters?: ExecutionFilters): Promise<ApiResponse<ExecutionListResponse>>;
177
+ /**
178
+ * Enable a tool (shortcut for setting isEnabled=true)
179
+ *
180
+ * @param workspaceId - Workspace ID
181
+ * @param id - Tool ID
182
+ * @returns Updated tool
183
+ * @throws NotFoundError if tool doesn't exist
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const { data } = await sdk.tools.enable('tool_abc123');
188
+ * console.log(data.tool.isEnabled); // true
189
+ * ```
190
+ */
191
+ enable(id: string): Promise<ApiResponse<ToolResponse>>;
192
+ /**
193
+ * Disable a tool (shortcut for setting isEnabled=false)
194
+ *
195
+ * @param workspaceId - Workspace ID
196
+ * @param id - Tool ID
197
+ * @returns Updated tool
198
+ * @throws NotFoundError if tool doesn't exist
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const { data } = await sdk.tools.disable('tool_abc123');
203
+ * console.log(data.tool.isEnabled); // false
204
+ * ```
205
+ */
206
+ disable(id: string): Promise<ApiResponse<ToolResponse>>;
207
+ /**
208
+ * Get tool categories (aggregated tags with counts)
209
+ *
210
+ * @param workspaceId - Workspace ID
211
+ * @returns List of categories with counts
212
+ *
213
+ * @example
214
+ * ```typescript
215
+ * const { data } = await sdk.tools.getCategories('ws_123');
216
+ * console.log(data.categories);
217
+ * // [{ name: 'weather', count: 5, enabledCount: 3 }, ...]
218
+ * ```
219
+ */
220
+ getCategories(): Promise<ApiResponse<ToolCategoriesResponse>>;
221
+ }
222
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../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