@backflow.sdk/client 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +210 -0
- package/dist/index.d.mts +1845 -0
- package/dist/index.d.ts +1845 -0
- package/dist/index.js +2945 -0
- package/dist/index.mjs +2862 -0
- package/package.json +47 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2945 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AgentAnalysisResource: () => AgentAnalysisResource,
|
|
24
|
+
AnalyticsResource: () => AnalyticsResource,
|
|
25
|
+
AssetsResource: () => AssetsResource,
|
|
26
|
+
Backflow: () => BackflowSDK,
|
|
27
|
+
BackflowClient: () => BackflowClient,
|
|
28
|
+
BackflowSDK: () => BackflowSDK,
|
|
29
|
+
BatchResource: () => BatchResource,
|
|
30
|
+
CACHE_OPERATIONS: () => CACHE_OPERATIONS,
|
|
31
|
+
CHUNKING_STRATEGIES: () => CHUNKING_STRATEGIES,
|
|
32
|
+
CLI_PROVIDERS: () => CLI_PROVIDERS,
|
|
33
|
+
CONDITION_OPERATORS: () => CONDITION_OPERATORS,
|
|
34
|
+
CacheResource: () => CacheResource,
|
|
35
|
+
DB_OPERATIONS: () => DB_OPERATIONS,
|
|
36
|
+
DB_PROVIDERS: () => DB_PROVIDERS,
|
|
37
|
+
DefaultResource: () => DefaultResource,
|
|
38
|
+
DeploymentResource: () => DeploymentResource,
|
|
39
|
+
EmbeddingsResource: () => EmbeddingsResource,
|
|
40
|
+
FeedbackResource: () => FeedbackResource,
|
|
41
|
+
FilesResource: () => FilesResource,
|
|
42
|
+
GithubResource: () => GithubResource,
|
|
43
|
+
GoalsResource: () => GoalsResource,
|
|
44
|
+
GoogleDriveResource: () => GoogleDriveResource,
|
|
45
|
+
HTTP_METHODS: () => HTTP_METHODS,
|
|
46
|
+
IMAGE_DETAILS: () => IMAGE_DETAILS,
|
|
47
|
+
JiraResource: () => JiraResource,
|
|
48
|
+
LLM_PROVIDERS: () => LLM_PROVIDERS,
|
|
49
|
+
LlmResource: () => LlmResource,
|
|
50
|
+
McpToolsResource: () => McpToolsResource,
|
|
51
|
+
NOTIFY_CHANNELS: () => NOTIFY_CHANNELS,
|
|
52
|
+
NOTIFY_PRIORITIES: () => NOTIFY_PRIORITIES,
|
|
53
|
+
PolarResource: () => PolarResource,
|
|
54
|
+
ProjectsResource: () => ProjectsResource,
|
|
55
|
+
PublishResource: () => PublishResource,
|
|
56
|
+
QueuesResource: () => QueuesResource,
|
|
57
|
+
RAG_MODES: () => RAG_MODES,
|
|
58
|
+
STORAGE_OPERATIONS: () => STORAGE_OPERATIONS,
|
|
59
|
+
SearchResource: () => SearchResource,
|
|
60
|
+
StripeResource: () => StripeResource,
|
|
61
|
+
TOOL_PARAM_CONTEXT: () => TOOL_PARAM_CONTEXT,
|
|
62
|
+
TOOL_TYPES: () => TOOL_TYPES,
|
|
63
|
+
TRIGGER_TYPES: () => TRIGGER_TYPES,
|
|
64
|
+
TeamsResource: () => TeamsResource,
|
|
65
|
+
TenantWebhookReceiversResource: () => TenantWebhookReceiversResource,
|
|
66
|
+
TenantWebhooksResource: () => TenantWebhooksResource,
|
|
67
|
+
ToolDiscoveryResource: () => ToolDiscoveryResource,
|
|
68
|
+
TrackingResource: () => TrackingResource,
|
|
69
|
+
TwitterResource: () => TwitterResource,
|
|
70
|
+
UsageResource: () => UsageResource,
|
|
71
|
+
WORKFLOW_VALIDATION_SCHEMA: () => WORKFLOW_VALIDATION_SCHEMA,
|
|
72
|
+
WebsocketResource: () => WebsocketResource,
|
|
73
|
+
WorkflowsResource: () => WorkflowsResource,
|
|
74
|
+
WorkspacesResource: () => WorkspacesResource,
|
|
75
|
+
createBackflow: () => createBackflow,
|
|
76
|
+
getSDKDocs: () => getSDKDocs,
|
|
77
|
+
getSDKDocsCompact: () => getSDKDocsCompact,
|
|
78
|
+
toCompactContext: () => toCompactContext,
|
|
79
|
+
toPromptContext: () => toPromptContext
|
|
80
|
+
});
|
|
81
|
+
module.exports = __toCommonJS(index_exports);
|
|
82
|
+
|
|
83
|
+
// src/client.ts
|
|
84
|
+
var DEFAULT_ENDPOINT = "https://api.backflow.dev";
|
|
85
|
+
var BackflowClient = class {
|
|
86
|
+
constructor(config) {
|
|
87
|
+
this.tokenCache = null;
|
|
88
|
+
this.tokenPromise = null;
|
|
89
|
+
const clientKey = config.clientKey;
|
|
90
|
+
if (!clientKey && !config.getAuthToken) {
|
|
91
|
+
throw new Error("Either clientKey or getAuthToken is required");
|
|
92
|
+
}
|
|
93
|
+
this.config = {
|
|
94
|
+
...config,
|
|
95
|
+
clientKey,
|
|
96
|
+
endpoint: config.endpoint?.replace(/\/$/, "") || DEFAULT_ENDPOINT
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
async exchangeApiKeyForToken() {
|
|
100
|
+
const response = await fetch(`${this.config.endpoint}/auth/token`, {
|
|
101
|
+
method: "POST",
|
|
102
|
+
headers: {
|
|
103
|
+
"Content-Type": "application/json",
|
|
104
|
+
"x-api-key": this.config.clientKey
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
if (!response.ok) {
|
|
108
|
+
const error = await response.json().catch(() => ({ error: "Token exchange failed" }));
|
|
109
|
+
throw new Error(error.error || "Failed to exchange API key for token");
|
|
110
|
+
}
|
|
111
|
+
const data = await response.json();
|
|
112
|
+
const expiresAt = Date.now() + data.expiresIn * 1e3 * 0.8;
|
|
113
|
+
return { token: data.token, expiresAt };
|
|
114
|
+
}
|
|
115
|
+
async getToken() {
|
|
116
|
+
if (this.config.getAuthToken) {
|
|
117
|
+
return this.config.getAuthToken();
|
|
118
|
+
}
|
|
119
|
+
if (this.tokenCache && Date.now() < this.tokenCache.expiresAt) {
|
|
120
|
+
return this.tokenCache.token;
|
|
121
|
+
}
|
|
122
|
+
if (this.tokenPromise) {
|
|
123
|
+
const cache = await this.tokenPromise.then(() => this.tokenCache);
|
|
124
|
+
return cache.token;
|
|
125
|
+
}
|
|
126
|
+
this.tokenPromise = this.exchangeApiKeyForToken().then((cache) => {
|
|
127
|
+
this.tokenCache = cache;
|
|
128
|
+
this.tokenPromise = null;
|
|
129
|
+
return cache.token;
|
|
130
|
+
}).catch((err) => {
|
|
131
|
+
this.tokenPromise = null;
|
|
132
|
+
throw err;
|
|
133
|
+
});
|
|
134
|
+
return this.tokenPromise;
|
|
135
|
+
}
|
|
136
|
+
get endpoint() {
|
|
137
|
+
return this.config.endpoint;
|
|
138
|
+
}
|
|
139
|
+
async request(path, options = {}) {
|
|
140
|
+
const { params, body, ...fetchOptions } = options;
|
|
141
|
+
const startTime = Date.now();
|
|
142
|
+
const debug = this.config.debug ?? false;
|
|
143
|
+
let ctx = {
|
|
144
|
+
method: fetchOptions.method || "GET",
|
|
145
|
+
path,
|
|
146
|
+
params,
|
|
147
|
+
body,
|
|
148
|
+
startTime
|
|
149
|
+
};
|
|
150
|
+
if (this.config.middleware?.onRequest) {
|
|
151
|
+
const result = await this.config.middleware.onRequest(ctx);
|
|
152
|
+
if (result) ctx = result;
|
|
153
|
+
}
|
|
154
|
+
let url = `${this.config.endpoint}${ctx.path}`;
|
|
155
|
+
if (ctx.params) {
|
|
156
|
+
const searchParams = new URLSearchParams();
|
|
157
|
+
Object.entries(ctx.params).forEach(([key, value]) => {
|
|
158
|
+
if (value !== void 0) {
|
|
159
|
+
searchParams.append(key, String(value));
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
const queryString = searchParams.toString();
|
|
163
|
+
if (queryString) {
|
|
164
|
+
url += `?${queryString}`;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const headers = {
|
|
168
|
+
"Content-Type": "application/json",
|
|
169
|
+
...fetchOptions.headers || {}
|
|
170
|
+
};
|
|
171
|
+
const token = await this.getToken();
|
|
172
|
+
if (token) {
|
|
173
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
174
|
+
}
|
|
175
|
+
if (debug) {
|
|
176
|
+
console.log(`[Backflow] \u2192 ${ctx.method} ${url}`);
|
|
177
|
+
console.log(
|
|
178
|
+
`[Backflow] clientKey: ${this.config.clientKey ? "***" : "(not set)"}`
|
|
179
|
+
);
|
|
180
|
+
if (ctx.body) console.log("[Backflow] Request body:", ctx.body);
|
|
181
|
+
}
|
|
182
|
+
let response;
|
|
183
|
+
let responseData;
|
|
184
|
+
let error;
|
|
185
|
+
try {
|
|
186
|
+
response = await fetch(url, {
|
|
187
|
+
...fetchOptions,
|
|
188
|
+
headers,
|
|
189
|
+
body: ctx.body ? JSON.stringify(ctx.body) : void 0
|
|
190
|
+
});
|
|
191
|
+
if (!response.ok) {
|
|
192
|
+
error = new Error(
|
|
193
|
+
`Request failed: ${response.status}`
|
|
194
|
+
);
|
|
195
|
+
error.status = response.status;
|
|
196
|
+
try {
|
|
197
|
+
const errorBody = await response.json();
|
|
198
|
+
error.code = errorBody.code;
|
|
199
|
+
error.details = errorBody;
|
|
200
|
+
error.message = errorBody.message || errorBody.error || error.message;
|
|
201
|
+
} catch {
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
const contentType = response.headers.get("content-type");
|
|
205
|
+
if (contentType?.includes("application/json")) {
|
|
206
|
+
responseData = await response.json();
|
|
207
|
+
} else {
|
|
208
|
+
responseData = await response.text();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
} catch (e) {
|
|
212
|
+
error = e;
|
|
213
|
+
error.status = 0;
|
|
214
|
+
}
|
|
215
|
+
const duration = Date.now() - startTime;
|
|
216
|
+
if (debug) {
|
|
217
|
+
const status = error?.status ?? response.status;
|
|
218
|
+
if (error) console.log("[Backflow] Error:", error.message);
|
|
219
|
+
else console.log("[Backflow] Response:", responseData);
|
|
220
|
+
}
|
|
221
|
+
if (this.config.middleware?.onResponse) {
|
|
222
|
+
const resCtx = {
|
|
223
|
+
...ctx,
|
|
224
|
+
status: error?.status ?? response.status,
|
|
225
|
+
duration,
|
|
226
|
+
response: responseData,
|
|
227
|
+
error
|
|
228
|
+
};
|
|
229
|
+
await this.config.middleware.onResponse(resCtx);
|
|
230
|
+
}
|
|
231
|
+
if (error) throw error;
|
|
232
|
+
return responseData;
|
|
233
|
+
}
|
|
234
|
+
async get(path, params) {
|
|
235
|
+
return this.request(path, { method: "GET", params });
|
|
236
|
+
}
|
|
237
|
+
async post(path, body, params) {
|
|
238
|
+
return this.request(path, { method: "POST", body, params });
|
|
239
|
+
}
|
|
240
|
+
async put(path, body, params) {
|
|
241
|
+
return this.request(path, { method: "PUT", body, params });
|
|
242
|
+
}
|
|
243
|
+
async patch(path, body, params) {
|
|
244
|
+
return this.request(path, { method: "PATCH", body, params });
|
|
245
|
+
}
|
|
246
|
+
async delete(path, params) {
|
|
247
|
+
return this.request(path, { method: "DELETE", params });
|
|
248
|
+
}
|
|
249
|
+
async upload(path, files, metadata) {
|
|
250
|
+
const formData = new FormData();
|
|
251
|
+
const fileArray = Array.isArray(files) ? files : [files];
|
|
252
|
+
const fieldName = fileArray.length === 1 ? "file" : "files";
|
|
253
|
+
fileArray.forEach((file) => formData.append(fieldName, file));
|
|
254
|
+
if (metadata) {
|
|
255
|
+
Object.entries(metadata).forEach(([key, value]) => {
|
|
256
|
+
formData.append(key, value);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
const url = `${this.config.endpoint}${path}`;
|
|
260
|
+
const uploadHeaders = {};
|
|
261
|
+
const token = await this.getToken();
|
|
262
|
+
if (token) {
|
|
263
|
+
uploadHeaders["Authorization"] = `Bearer ${token}`;
|
|
264
|
+
}
|
|
265
|
+
const response = await fetch(url, {
|
|
266
|
+
method: "POST",
|
|
267
|
+
headers: uploadHeaders,
|
|
268
|
+
body: formData
|
|
269
|
+
});
|
|
270
|
+
if (!response.ok) {
|
|
271
|
+
const error = new Error(
|
|
272
|
+
`Upload failed: ${response.status}`
|
|
273
|
+
);
|
|
274
|
+
error.status = response.status;
|
|
275
|
+
try {
|
|
276
|
+
const errorBody = await response.json();
|
|
277
|
+
error.code = errorBody.code;
|
|
278
|
+
error.details = errorBody;
|
|
279
|
+
error.message = errorBody.message || errorBody.error || error.message;
|
|
280
|
+
} catch {
|
|
281
|
+
}
|
|
282
|
+
throw error;
|
|
283
|
+
}
|
|
284
|
+
return response.json();
|
|
285
|
+
}
|
|
286
|
+
async getRaw(path, params) {
|
|
287
|
+
const url = `${this.config.endpoint}${path}`;
|
|
288
|
+
const queryString = params ? Object.entries(params).filter(([, value]) => value !== void 0).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`).join("&") : "";
|
|
289
|
+
const finalUrl = queryString ? `${url}?${queryString}` : url;
|
|
290
|
+
const headers = {};
|
|
291
|
+
const token = await this.getToken();
|
|
292
|
+
if (token) {
|
|
293
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
294
|
+
}
|
|
295
|
+
return fetch(finalUrl, { headers });
|
|
296
|
+
}
|
|
297
|
+
createWebSocket(room) {
|
|
298
|
+
const wsEndpoint = this.config.endpoint.replace("http", "ws");
|
|
299
|
+
const ws = new WebSocket(`${wsEndpoint}/ws`);
|
|
300
|
+
ws.onopen = async () => {
|
|
301
|
+
const token = await this.getToken();
|
|
302
|
+
ws.send(JSON.stringify({ type: "auth", token }));
|
|
303
|
+
ws.send(JSON.stringify({ type: "join_room", room }));
|
|
304
|
+
};
|
|
305
|
+
return ws;
|
|
306
|
+
}
|
|
307
|
+
subscribeSSE(path, handlers) {
|
|
308
|
+
const es = new EventSource(`${this.config.endpoint}${path}`);
|
|
309
|
+
es.addEventListener("connected", () => handlers.onConnected?.());
|
|
310
|
+
es.addEventListener("completed", (e) => {
|
|
311
|
+
const data = JSON.parse(e.data);
|
|
312
|
+
handlers.onComplete?.(data);
|
|
313
|
+
es.close();
|
|
314
|
+
});
|
|
315
|
+
es.addEventListener("failed", (e) => {
|
|
316
|
+
const data = JSON.parse(e.data);
|
|
317
|
+
handlers.onFailed?.(data.error || data.message);
|
|
318
|
+
es.close();
|
|
319
|
+
});
|
|
320
|
+
es.addEventListener("progress", (e) => {
|
|
321
|
+
const data = JSON.parse(e.data);
|
|
322
|
+
handlers.onProgress?.(data.progress, data.message);
|
|
323
|
+
});
|
|
324
|
+
es.addEventListener("warning", (e) => {
|
|
325
|
+
handlers.onWarning?.(e.data);
|
|
326
|
+
});
|
|
327
|
+
es.onerror = (e) => {
|
|
328
|
+
handlers.onError?.(e);
|
|
329
|
+
es.close();
|
|
330
|
+
};
|
|
331
|
+
return () => es.close();
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// src/generated/agent-analysis.ts
|
|
336
|
+
var AgentAnalysisResource = class {
|
|
337
|
+
constructor(client) {
|
|
338
|
+
this.client = client;
|
|
339
|
+
}
|
|
340
|
+
/** Retrieve cached analysis results from a previous scan */
|
|
341
|
+
async get(executionId) {
|
|
342
|
+
return this.client.get(`/agent/analysis/${executionId}`);
|
|
343
|
+
}
|
|
344
|
+
/** Apply fixes from cached analysis. In hybrid mode, returns fix instructions for local MCP execution. */
|
|
345
|
+
async createApply(executionId, data) {
|
|
346
|
+
return this.client.post(`/agent/analysis/${executionId}/apply`, data);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
// src/generated/analytics.ts
|
|
351
|
+
var AnalyticsResource = class {
|
|
352
|
+
constructor(client) {
|
|
353
|
+
this.client = client;
|
|
354
|
+
}
|
|
355
|
+
/** Get high-level analytics overview (tenant-isolated) */
|
|
356
|
+
async list() {
|
|
357
|
+
return this.client.get("/analytics/overview");
|
|
358
|
+
}
|
|
359
|
+
/** Get endpoint statistics (tenant-isolated) */
|
|
360
|
+
async listEndpoints() {
|
|
361
|
+
return this.client.get("/analytics/endpoints");
|
|
362
|
+
}
|
|
363
|
+
/** Get recent errors (tenant-isolated) */
|
|
364
|
+
async listErrors() {
|
|
365
|
+
return this.client.get("/analytics/errors");
|
|
366
|
+
}
|
|
367
|
+
/** Get device type breakdown (tenant-isolated) */
|
|
368
|
+
async listDevices() {
|
|
369
|
+
return this.client.get("/analytics/devices");
|
|
370
|
+
}
|
|
371
|
+
/** Get geographic distribution of requests (tenant-isolated) */
|
|
372
|
+
async listGeography() {
|
|
373
|
+
return this.client.get("/analytics/geography");
|
|
374
|
+
}
|
|
375
|
+
/** Get time series data (tenant-isolated) */
|
|
376
|
+
async listTimeseries() {
|
|
377
|
+
return this.client.get("/analytics/timeseries");
|
|
378
|
+
}
|
|
379
|
+
/** Get endpoints that haven't been called recently (tenant-isolated) */
|
|
380
|
+
async listUnusedEndpoints() {
|
|
381
|
+
return this.client.get("/analytics/unused-endpoints");
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
// src/generated/batch.ts
|
|
386
|
+
var BatchResource = class {
|
|
387
|
+
constructor(client) {
|
|
388
|
+
this.client = client;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Import records in batch to a specified entity
|
|
392
|
+
*
|
|
393
|
+
* @param options - Import options including entity name, records, and mode
|
|
394
|
+
* @returns Import result with success/failure counts
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* // Insert new records
|
|
398
|
+
* const result = await bf.batch.import({
|
|
399
|
+
* entity: 'products',
|
|
400
|
+
* records: [
|
|
401
|
+
* { name: 'Product 1', price: 100 },
|
|
402
|
+
* { name: 'Product 2', price: 200 },
|
|
403
|
+
* ],
|
|
404
|
+
* });
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* // Upsert records (update existing, insert new)
|
|
408
|
+
* const result = await bf.batch.import({
|
|
409
|
+
* entity: 'products',
|
|
410
|
+
* records: products,
|
|
411
|
+
* mode: 'upsert',
|
|
412
|
+
* upsertKey: 'sku',
|
|
413
|
+
* });
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* // Large async import (>1000 records or explicit async)
|
|
417
|
+
* const result = await bf.batch.import({
|
|
418
|
+
* entity: 'orders',
|
|
419
|
+
* records: largeDataset,
|
|
420
|
+
* async: true,
|
|
421
|
+
* });
|
|
422
|
+
* // Check status
|
|
423
|
+
* const status = await bf.batch.getJob(result.jobId!);
|
|
424
|
+
*/
|
|
425
|
+
async import(options) {
|
|
426
|
+
return this.client.post("/batch/import", options);
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Get status of a batch import job
|
|
430
|
+
*
|
|
431
|
+
* @param jobId - The job ID returned from async import
|
|
432
|
+
* @returns Job status including progress and error details
|
|
433
|
+
*/
|
|
434
|
+
async getJob(jobId) {
|
|
435
|
+
return this.client.get(`/batch/jobs/${jobId}`);
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* List batch jobs for the current tenant
|
|
439
|
+
*
|
|
440
|
+
* @returns List of recent batch jobs
|
|
441
|
+
*/
|
|
442
|
+
async listJobs() {
|
|
443
|
+
return this.client.get("/batch/jobs");
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Export records from an entity
|
|
447
|
+
*
|
|
448
|
+
* @param options - Export options including entity name and optional filters
|
|
449
|
+
* @returns Exported records
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* // Export all records
|
|
453
|
+
* const result = await bf.batch.export({ entity: 'products' });
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* // Export with filters
|
|
457
|
+
* const result = await bf.batch.export({
|
|
458
|
+
* entity: 'orders',
|
|
459
|
+
* filters: [
|
|
460
|
+
* { field: 'status', operator: 'eq', value: 'completed' },
|
|
461
|
+
* ],
|
|
462
|
+
* select: ['id', 'total', 'created_at'],
|
|
463
|
+
* limit: 5000,
|
|
464
|
+
* });
|
|
465
|
+
*/
|
|
466
|
+
async export(options) {
|
|
467
|
+
return this.client.post("/batch/export", options);
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Poll job until completion
|
|
471
|
+
*
|
|
472
|
+
* @param jobId - The job ID to poll
|
|
473
|
+
* @param intervalMs - Polling interval in milliseconds (default: 1000)
|
|
474
|
+
* @param timeoutMs - Timeout in milliseconds (default: 300000 = 5 minutes)
|
|
475
|
+
* @returns Final job status
|
|
476
|
+
*/
|
|
477
|
+
async waitForJob(jobId, intervalMs = 1e3, timeoutMs = 3e5) {
|
|
478
|
+
const startTime = Date.now();
|
|
479
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
480
|
+
const job = await this.getJob(jobId);
|
|
481
|
+
if (job.status === "completed" || job.status === "failed") {
|
|
482
|
+
return job;
|
|
483
|
+
}
|
|
484
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
485
|
+
}
|
|
486
|
+
throw new Error(`Job ${jobId} timed out after ${timeoutMs}ms`);
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
// src/generated/assets.ts
|
|
491
|
+
var AssetsResource = class {
|
|
492
|
+
constructor(client) {
|
|
493
|
+
this.client = client;
|
|
494
|
+
}
|
|
495
|
+
/** List tenant assets with optional filtering */
|
|
496
|
+
async list(params) {
|
|
497
|
+
return this.client.get("/admin/assets", params);
|
|
498
|
+
}
|
|
499
|
+
/** Get asset by ID */
|
|
500
|
+
async get(id) {
|
|
501
|
+
return this.client.get(`/admin/assets/${id}`);
|
|
502
|
+
}
|
|
503
|
+
/** Delete asset by ID */
|
|
504
|
+
async delete(id) {
|
|
505
|
+
return this.client.delete(`/admin/assets/${id}`);
|
|
506
|
+
}
|
|
507
|
+
/** Get asset storage statistics */
|
|
508
|
+
async stats(tenant) {
|
|
509
|
+
return this.client.get("/admin/assets/stats", tenant ? { tenant } : void 0);
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
// src/generated/cache.ts
|
|
514
|
+
var CacheResource = class {
|
|
515
|
+
constructor(client) {
|
|
516
|
+
this.client = client;
|
|
517
|
+
}
|
|
518
|
+
/** Get cache statistics including hit rate, memory usage, and item count */
|
|
519
|
+
async list() {
|
|
520
|
+
return this.client.get("/cache/stats");
|
|
521
|
+
}
|
|
522
|
+
/** Clear all items from the cache and reset statistics */
|
|
523
|
+
async delete() {
|
|
524
|
+
return this.client.delete("/cache/flush");
|
|
525
|
+
}
|
|
526
|
+
/** Invalidate all cache entries that match a given pattern */
|
|
527
|
+
async create(data) {
|
|
528
|
+
return this.client.post("/cache/invalidate", data);
|
|
529
|
+
}
|
|
530
|
+
/** Reset cache hit/miss statistics while preserving cached data */
|
|
531
|
+
async createResetStats(data) {
|
|
532
|
+
return this.client.post("/cache/reset-stats", data);
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
// src/generated/default.ts
|
|
537
|
+
var DefaultResource = class {
|
|
538
|
+
constructor(client) {
|
|
539
|
+
this.client = client;
|
|
540
|
+
}
|
|
541
|
+
/** GET /tenant/debug/raw-query */
|
|
542
|
+
async list() {
|
|
543
|
+
return this.client.get("/tenant/debug/raw-query");
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
// src/generated/deployment.ts
|
|
548
|
+
var DeploymentResource = class {
|
|
549
|
+
constructor(client) {
|
|
550
|
+
this.client = client;
|
|
551
|
+
}
|
|
552
|
+
/** Get deployment information */
|
|
553
|
+
async list() {
|
|
554
|
+
return this.client.get("/deployment");
|
|
555
|
+
}
|
|
556
|
+
/** Get server information */
|
|
557
|
+
async listServer() {
|
|
558
|
+
return this.client.get("/deployment/server");
|
|
559
|
+
}
|
|
560
|
+
/** Get full deployment status */
|
|
561
|
+
async listStatus() {
|
|
562
|
+
return this.client.get("/deployment/status");
|
|
563
|
+
}
|
|
564
|
+
/** Get Cloud Run service URL */
|
|
565
|
+
async listUrl() {
|
|
566
|
+
return this.client.get("/deployment/url");
|
|
567
|
+
}
|
|
568
|
+
/** Server-Sent Events (SSE) stream for real-time deployment status updates. Sends periodic status updates and heartbeats. */
|
|
569
|
+
async listStream() {
|
|
570
|
+
return this.client.get("/deployment/stream");
|
|
571
|
+
}
|
|
572
|
+
/** Filtered Server-Sent Events (SSE) stream for specific deployment event types. Filter by status, server, or url events. */
|
|
573
|
+
async listEvents() {
|
|
574
|
+
return this.client.get("/deployment/events");
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
// src/generated/embeddings.ts
|
|
579
|
+
var EmbeddingsResource = class {
|
|
580
|
+
constructor(client) {
|
|
581
|
+
this.client = client;
|
|
582
|
+
}
|
|
583
|
+
/** List all embedded documents with chunk counts and metadata */
|
|
584
|
+
async list() {
|
|
585
|
+
return this.client.get("/agent/embeddings/documents");
|
|
586
|
+
}
|
|
587
|
+
/** Upload and process a document for vector embeddings with automatic chunking. Supports various content types (code, documentation, articles) with optimized chunking strategies for RAG. */
|
|
588
|
+
async create(data) {
|
|
589
|
+
return this.client.post("/agent/embeddings/document", data);
|
|
590
|
+
}
|
|
591
|
+
/** Search within a specific document using semantic similarity. Performs vector search within document chunks. */
|
|
592
|
+
async search(documentId) {
|
|
593
|
+
return this.client.get(`/agent/embeddings/document/${documentId}/search`);
|
|
594
|
+
}
|
|
595
|
+
/** Search across all embedded documents using semantic similarity */
|
|
596
|
+
async listSearch() {
|
|
597
|
+
return this.client.get("/agent/embeddings/search");
|
|
598
|
+
}
|
|
599
|
+
/** Delete all chunks and embeddings for a document. Removes the document from the vector store. */
|
|
600
|
+
async delete(documentId) {
|
|
601
|
+
return this.client.delete(`/agent/embeddings/document/${documentId}`);
|
|
602
|
+
}
|
|
603
|
+
/** Process multiple documents (up to 50) for vector embeddings in a single batch. Supports both raw text and file references (PDF, DOCX, TXT, MD). Uses 3 concurrent processing threads. */
|
|
604
|
+
async createBatch(data) {
|
|
605
|
+
return this.client.post("/agent/embeddings/batch", data);
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
// src/generated/feedback.ts
|
|
610
|
+
var FeedbackResource = class {
|
|
611
|
+
constructor(client) {
|
|
612
|
+
this.client = client;
|
|
613
|
+
}
|
|
614
|
+
/** Submit feedback for a workflow execution. Used to optimize and improve workflow performance based on user ratings and suggestions. */
|
|
615
|
+
async create(data) {
|
|
616
|
+
return this.client.post("/agent/feedback", data);
|
|
617
|
+
}
|
|
618
|
+
/** Get feedback trends and analytics. Analyzes workflow feedback to identify patterns and areas for improvement. */
|
|
619
|
+
async list() {
|
|
620
|
+
return this.client.get("/agent/feedback/trends");
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
// src/generated/files.ts
|
|
625
|
+
var FilesResource = class {
|
|
626
|
+
constructor(client) {
|
|
627
|
+
this.client = client;
|
|
628
|
+
}
|
|
629
|
+
/** Upload a single file with entity association and tenant isolation */
|
|
630
|
+
async create(data) {
|
|
631
|
+
return this.client.post("/files/upload", data);
|
|
632
|
+
}
|
|
633
|
+
/** Upload multiple files with entity association and tenant isolation */
|
|
634
|
+
async createUploadMultiple(data) {
|
|
635
|
+
return this.client.post("/files/upload-multiple", data);
|
|
636
|
+
}
|
|
637
|
+
/** List files for an entity with pagination */
|
|
638
|
+
async get(entityType, entityId) {
|
|
639
|
+
return this.client.get(`/files/entity/${entityType}/${entityId}`);
|
|
640
|
+
}
|
|
641
|
+
/** Delete all files for an entity */
|
|
642
|
+
async delete(entityType, entityId) {
|
|
643
|
+
return this.client.delete(`/files/entity/${entityType}/${entityId}`);
|
|
644
|
+
}
|
|
645
|
+
/** Download file via secure signed URL redirect (5 minute expiry) */
|
|
646
|
+
async getDownload(bucket, path) {
|
|
647
|
+
return this.client.get(`/files/download/${bucket}/${path}`);
|
|
648
|
+
}
|
|
649
|
+
/** Get a signed URL for file access (max 30 seconds expiry) */
|
|
650
|
+
async getSignedUrl(bucket, path) {
|
|
651
|
+
return this.client.get(`/files/signed-url/${bucket}/${path}`);
|
|
652
|
+
}
|
|
653
|
+
/** Delete a file from storage */
|
|
654
|
+
async deleteDELETE(bucket, path) {
|
|
655
|
+
return this.client.delete(`/files/${bucket}/${path}`);
|
|
656
|
+
}
|
|
657
|
+
/** Upload JSON content to storage */
|
|
658
|
+
async createUploadJson(data) {
|
|
659
|
+
return this.client.post("/files/upload-json", data);
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
// src/generated/github.ts
|
|
664
|
+
var GithubResource = class {
|
|
665
|
+
constructor(client) {
|
|
666
|
+
this.client = client;
|
|
667
|
+
}
|
|
668
|
+
/** Get GitHub repositories for a user */
|
|
669
|
+
async get(username) {
|
|
670
|
+
return this.client.get(`/api/github/repos/${username}`);
|
|
671
|
+
}
|
|
672
|
+
/** Get file or directory contents from a GitHub repository */
|
|
673
|
+
async getContent(owner, repo, path) {
|
|
674
|
+
return this.client.get(`/api/github/repos/${owner}/${repo}/contents/${path}`);
|
|
675
|
+
}
|
|
676
|
+
/** Create or update a file in a GitHub repository */
|
|
677
|
+
async updateContent(owner, repo, path, data) {
|
|
678
|
+
return this.client.put(`/api/github/repos/${owner}/${repo}/contents/${path}`, data);
|
|
679
|
+
}
|
|
680
|
+
/** Delete a file from a GitHub repository */
|
|
681
|
+
async deleteContent(owner, repo, path) {
|
|
682
|
+
return this.client.delete(`/api/github/repos/${owner}/${repo}/contents/${path}`);
|
|
683
|
+
}
|
|
684
|
+
/** Compare two commits and view the diff */
|
|
685
|
+
async getCompare(owner, repo, basehead) {
|
|
686
|
+
return this.client.get(`/api/github/repos/${owner}/${repo}/compare/${basehead}`);
|
|
687
|
+
}
|
|
688
|
+
/** Get a single commit with its changes */
|
|
689
|
+
async getCommit(owner, repo, ref) {
|
|
690
|
+
return this.client.get(`/api/github/repos/${owner}/${repo}/commits/${ref}`);
|
|
691
|
+
}
|
|
692
|
+
/** List commits in a repository */
|
|
693
|
+
async commits(owner, repo) {
|
|
694
|
+
return this.client.get(`/api/github/repos/${owner}/${repo}/commits`);
|
|
695
|
+
}
|
|
696
|
+
/** Get pull request details */
|
|
697
|
+
async getPull(owner, repo, pull_number) {
|
|
698
|
+
return this.client.get(`/api/github/repos/${owner}/${repo}/pulls/${pull_number}`);
|
|
699
|
+
}
|
|
700
|
+
/** List files changed in a pull request with diffs */
|
|
701
|
+
async files(owner, repo, pull_number) {
|
|
702
|
+
return this.client.get(`/api/github/repos/${owner}/${repo}/pulls/${pull_number}/files`);
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
// src/generated/goals.ts
|
|
707
|
+
var GoalsResource = class {
|
|
708
|
+
constructor(client) {
|
|
709
|
+
this.client = client;
|
|
710
|
+
}
|
|
711
|
+
/** Configure goal evaluation rules for a workflow. Sets KPIs, success criteria, and evaluation parameters. */
|
|
712
|
+
async create(data) {
|
|
713
|
+
return this.client.post("/agent/goal/configure", data);
|
|
714
|
+
}
|
|
715
|
+
/** Manually trigger goal evaluation for a workflow. Evaluates workflow performance against configured KPIs and success criteria. */
|
|
716
|
+
async createEvaluate(workflowId, data) {
|
|
717
|
+
return this.client.post(`/agent/goal/evaluate/${workflowId}`, data);
|
|
718
|
+
}
|
|
719
|
+
/** Get evaluation history for a workflow. Returns all historical goal evaluation records. */
|
|
720
|
+
async get(workflowId) {
|
|
721
|
+
return this.client.get(`/agent/goal/history/${workflowId}`);
|
|
722
|
+
}
|
|
723
|
+
/** Start scheduled goal evaluation. Automatically evaluates all active workflows at specified intervals. */
|
|
724
|
+
async createStart(data) {
|
|
725
|
+
return this.client.post("/agent/goal/schedule/start", data);
|
|
726
|
+
}
|
|
727
|
+
/** Stop scheduled goal evaluation. Cancels automatic workflow evaluations. */
|
|
728
|
+
async createStop(data) {
|
|
729
|
+
return this.client.post("/agent/goal/schedule/stop", data);
|
|
730
|
+
}
|
|
731
|
+
/** Evaluate all active workflows. Generates evaluation reports for all workflows with configured goals. */
|
|
732
|
+
async createEvaluateAll(data) {
|
|
733
|
+
return this.client.post("/agent/goal/evaluate-all", data);
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
|
|
737
|
+
// src/generated/google-drive.ts
|
|
738
|
+
var GoogleDriveResource = class {
|
|
739
|
+
constructor(client) {
|
|
740
|
+
this.client = client;
|
|
741
|
+
}
|
|
742
|
+
/** List files in Google Drive */
|
|
743
|
+
async list() {
|
|
744
|
+
return this.client.get("/api/google-drive/files");
|
|
745
|
+
}
|
|
746
|
+
/** Get file metadata from Google Drive */
|
|
747
|
+
async get(fileId) {
|
|
748
|
+
return this.client.get(`/api/google-drive/files/${fileId}`);
|
|
749
|
+
}
|
|
750
|
+
/** Update file metadata (rename, move) */
|
|
751
|
+
async patch(fileId, data) {
|
|
752
|
+
return this.client.patch(`/api/google-drive/files/${fileId}`, data);
|
|
753
|
+
}
|
|
754
|
+
/** Delete a file from Google Drive */
|
|
755
|
+
async delete(fileId) {
|
|
756
|
+
return this.client.delete(`/api/google-drive/files/${fileId}`);
|
|
757
|
+
}
|
|
758
|
+
/** Download file content from Google Drive */
|
|
759
|
+
async download(fileId) {
|
|
760
|
+
return this.client.get(`/api/google-drive/files/${fileId}/download`);
|
|
761
|
+
}
|
|
762
|
+
/** Search for PDF files in Google Drive */
|
|
763
|
+
async listPdfs() {
|
|
764
|
+
return this.client.get("/api/google-drive/pdfs");
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
// src/generated/jira.ts
|
|
769
|
+
var JiraResource = class {
|
|
770
|
+
constructor(client) {
|
|
771
|
+
this.client = client;
|
|
772
|
+
}
|
|
773
|
+
/** Search JIRA issues using JQL */
|
|
774
|
+
async list() {
|
|
775
|
+
return this.client.get("/api/jira/issues/search");
|
|
776
|
+
}
|
|
777
|
+
/** Get JIRA issue details */
|
|
778
|
+
async get(issueKey) {
|
|
779
|
+
return this.client.get(`/api/jira/issues/${issueKey}`);
|
|
780
|
+
}
|
|
781
|
+
/** Update a JIRA issue */
|
|
782
|
+
async update(issueKey, data) {
|
|
783
|
+
return this.client.put(`/api/jira/issues/${issueKey}`, data);
|
|
784
|
+
}
|
|
785
|
+
/** Delete a JIRA issue */
|
|
786
|
+
async delete(issueKey) {
|
|
787
|
+
return this.client.delete(`/api/jira/issues/${issueKey}`);
|
|
788
|
+
}
|
|
789
|
+
/** Create a new JIRA issue */
|
|
790
|
+
async create(data) {
|
|
791
|
+
return this.client.post("/api/jira/issues", data);
|
|
792
|
+
}
|
|
793
|
+
/** Get available transitions for a JIRA issue */
|
|
794
|
+
async transitions(issueKey) {
|
|
795
|
+
return this.client.get(`/api/jira/issues/${issueKey}/transitions`);
|
|
796
|
+
}
|
|
797
|
+
/** Transition a JIRA issue to new status */
|
|
798
|
+
async createTransition(issueKey, data) {
|
|
799
|
+
return this.client.post(`/api/jira/issues/${issueKey}/transition`, data);
|
|
800
|
+
}
|
|
801
|
+
/** Get comments for a JIRA issue */
|
|
802
|
+
async comments(issueKey) {
|
|
803
|
+
return this.client.get(`/api/jira/issues/${issueKey}/comments`);
|
|
804
|
+
}
|
|
805
|
+
/** Add comment to a JIRA issue */
|
|
806
|
+
async createComment(issueKey, data) {
|
|
807
|
+
return this.client.post(`/api/jira/issues/${issueKey}/comments`, data);
|
|
808
|
+
}
|
|
809
|
+
/** Assign a JIRA issue to a user */
|
|
810
|
+
async updateAssign(issueKey, data) {
|
|
811
|
+
return this.client.put(`/api/jira/issues/${issueKey}/assign`, data);
|
|
812
|
+
}
|
|
813
|
+
/** Get all JIRA projects */
|
|
814
|
+
async listProjects() {
|
|
815
|
+
return this.client.get("/api/jira/projects");
|
|
816
|
+
}
|
|
817
|
+
/** Get JIRA project details */
|
|
818
|
+
async getProjects(projectKey) {
|
|
819
|
+
return this.client.get(`/api/jira/projects/${projectKey}`);
|
|
820
|
+
}
|
|
821
|
+
/** Get current authenticated JIRA user */
|
|
822
|
+
async listMe() {
|
|
823
|
+
return this.client.get("/api/jira/user/me");
|
|
824
|
+
}
|
|
825
|
+
/** Search JIRA users */
|
|
826
|
+
async listSearch() {
|
|
827
|
+
return this.client.get("/api/jira/users/search");
|
|
828
|
+
}
|
|
829
|
+
/** Get all JIRA issue types */
|
|
830
|
+
async listIssueTypes() {
|
|
831
|
+
return this.client.get("/api/jira/metadata/issue-types");
|
|
832
|
+
}
|
|
833
|
+
/** Get all JIRA priority levels */
|
|
834
|
+
async listPriorities() {
|
|
835
|
+
return this.client.get("/api/jira/metadata/priorities");
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
// src/generated/llm.ts
|
|
840
|
+
var LlmResource = class {
|
|
841
|
+
constructor(client) {
|
|
842
|
+
this.client = client;
|
|
843
|
+
}
|
|
844
|
+
/** POST /llm/stream */
|
|
845
|
+
async create(data) {
|
|
846
|
+
return this.client.post("/llm/stream", data);
|
|
847
|
+
}
|
|
848
|
+
/** GET /llm/models */
|
|
849
|
+
async list() {
|
|
850
|
+
return this.client.get("/llm/models");
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
// src/generated/mcptools.ts
|
|
855
|
+
var McpToolsResource = class {
|
|
856
|
+
constructor(client) {
|
|
857
|
+
this.client = client;
|
|
858
|
+
}
|
|
859
|
+
/** List all available MCP tools from connected servers. Returns tools, connection status, and server information. */
|
|
860
|
+
async list() {
|
|
861
|
+
return this.client.get("/agent/mcp/tools");
|
|
862
|
+
}
|
|
863
|
+
/** Execute a Model Context Protocol (MCP) tool. MCP tools provide external capabilities like file system access, database queries, and API calls to LLM workflows. */
|
|
864
|
+
async create(data) {
|
|
865
|
+
return this.client.post("/agent/mcp/execute", data);
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
// src/generated/polar.ts
|
|
870
|
+
var PolarResource = class {
|
|
871
|
+
constructor(client) {
|
|
872
|
+
this.client = client;
|
|
873
|
+
}
|
|
874
|
+
/** Create a Polar checkout session */
|
|
875
|
+
async create(data) {
|
|
876
|
+
return this.client.post("/integrations/polar/checkouts", data);
|
|
877
|
+
}
|
|
878
|
+
/** Retrieve a Polar checkout session */
|
|
879
|
+
async get(checkoutId) {
|
|
880
|
+
return this.client.get(`/integrations/polar/checkouts/${checkoutId}`);
|
|
881
|
+
}
|
|
882
|
+
/** Create a Polar subscription */
|
|
883
|
+
async createSubscriptions(data) {
|
|
884
|
+
return this.client.post("/integrations/polar/subscriptions", data);
|
|
885
|
+
}
|
|
886
|
+
/** Cancel a Polar subscription */
|
|
887
|
+
async delete(subscriptionId) {
|
|
888
|
+
return this.client.delete(`/integrations/polar/subscriptions/${subscriptionId}`);
|
|
889
|
+
}
|
|
890
|
+
/** List Polar products */
|
|
891
|
+
async list() {
|
|
892
|
+
return this.client.get("/integrations/polar/products");
|
|
893
|
+
}
|
|
894
|
+
/** Create a Polar product */
|
|
895
|
+
async createProducts(data) {
|
|
896
|
+
return this.client.post("/integrations/polar/products", data);
|
|
897
|
+
}
|
|
898
|
+
/** Retrieve a Polar order */
|
|
899
|
+
async getOrders(orderId) {
|
|
900
|
+
return this.client.get(`/integrations/polar/orders/${orderId}`);
|
|
901
|
+
}
|
|
902
|
+
/** Create a Polar benefit */
|
|
903
|
+
async createBenefits(data) {
|
|
904
|
+
return this.client.post("/integrations/polar/benefits", data);
|
|
905
|
+
}
|
|
906
|
+
/** Grant a Polar benefit to a customer */
|
|
907
|
+
async createGrants(data) {
|
|
908
|
+
return this.client.post("/integrations/polar/benefits/grants", data);
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
// src/generated/projects.ts
|
|
913
|
+
var ProjectsResource = class {
|
|
914
|
+
constructor(client) {
|
|
915
|
+
this.client = client;
|
|
916
|
+
}
|
|
917
|
+
/** List version history for a project with pagination and date range filter */
|
|
918
|
+
async versions(id) {
|
|
919
|
+
return this.client.get(`/projects/${id}/versions`);
|
|
920
|
+
}
|
|
921
|
+
/** Create a new project version record (Pro tier) */
|
|
922
|
+
async createVersion(id, data) {
|
|
923
|
+
return this.client.post(`/projects/${id}/versions`, data);
|
|
924
|
+
}
|
|
925
|
+
/** Delete all versions for a project and their R2 files (parallel) */
|
|
926
|
+
async deleteAllVersions(id) {
|
|
927
|
+
return this.client.delete(`/projects/${id}/versions`);
|
|
928
|
+
}
|
|
929
|
+
/** Get a specific version record */
|
|
930
|
+
async getVersion(id, versionId) {
|
|
931
|
+
return this.client.get(`/projects/${id}/versions/${versionId}`);
|
|
932
|
+
}
|
|
933
|
+
/** Delete a specific project version and its R2 files */
|
|
934
|
+
async deleteVersion(id, versionId) {
|
|
935
|
+
return this.client.delete(`/projects/${id}/versions/${versionId}`);
|
|
936
|
+
}
|
|
937
|
+
/** Rollback project to a previous version (Pro tier) */
|
|
938
|
+
async rollback(id, version, data) {
|
|
939
|
+
return this.client.post(`/projects/${id}/rollback/${version}`, data);
|
|
940
|
+
}
|
|
941
|
+
/** Save project with parallel R2 uploads and Firestore updates */
|
|
942
|
+
async updateSave(projectId, data) {
|
|
943
|
+
return this.client.put(`/projects/${projectId}/save`, data);
|
|
944
|
+
}
|
|
945
|
+
/** Save project and execute content as workflow */
|
|
946
|
+
async saveAndRun(projectId, data) {
|
|
947
|
+
return this.client.post(`/projects/${projectId}/save-and-run`, data);
|
|
948
|
+
}
|
|
949
|
+
/** Get project by ID */
|
|
950
|
+
async get(id) {
|
|
951
|
+
return this.client.get(`/projects/${id}`);
|
|
952
|
+
}
|
|
953
|
+
/** Update project metadata (title, description, etc.) */
|
|
954
|
+
async patch(id, data) {
|
|
955
|
+
return this.client.patch(`/projects/${id}`, data);
|
|
956
|
+
}
|
|
957
|
+
/** Delete project and all related files/versions (parallel) */
|
|
958
|
+
async delete(id) {
|
|
959
|
+
return this.client.delete(`/projects/${id}`);
|
|
960
|
+
}
|
|
961
|
+
/** List all shares for a project */
|
|
962
|
+
async shares(id) {
|
|
963
|
+
return this.client.get(`/projects/${id}/shares`);
|
|
964
|
+
}
|
|
965
|
+
/** Share a project with another user */
|
|
966
|
+
async share(id, data) {
|
|
967
|
+
return this.client.post(`/projects/${id}/share`, data);
|
|
968
|
+
}
|
|
969
|
+
/** Remove share access from a user */
|
|
970
|
+
async deleteShare(id, userId) {
|
|
971
|
+
return this.client.delete(`/projects/${id}/share/${userId}`);
|
|
972
|
+
}
|
|
973
|
+
/** Get public project by ID (no auth required) */
|
|
974
|
+
async public(projectId) {
|
|
975
|
+
return this.client.get(`/projects/${projectId}/public`);
|
|
976
|
+
}
|
|
977
|
+
/** Toggle project public/private status with optional email notification */
|
|
978
|
+
async patchPublic(id, data) {
|
|
979
|
+
return this.client.patch(`/projects/${id}/public`, data);
|
|
980
|
+
}
|
|
981
|
+
/** List all projects shared with the current user */
|
|
982
|
+
async list() {
|
|
983
|
+
return this.client.get("/projects/shared-with-me");
|
|
984
|
+
}
|
|
985
|
+
/** Update project files (add/remove attached assets) */
|
|
986
|
+
async patchFile(id, data) {
|
|
987
|
+
return this.client.patch(`/projects/${id}/files`, data);
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
// src/generated/publish.ts
|
|
992
|
+
var PublishResource = class {
|
|
993
|
+
constructor(client) {
|
|
994
|
+
this.client = client;
|
|
995
|
+
}
|
|
996
|
+
/** Initialize publishing system - checks database setup */
|
|
997
|
+
async create(data) {
|
|
998
|
+
return this.client.post("/publish/init", data);
|
|
999
|
+
}
|
|
1000
|
+
/** Verify database migration was applied */
|
|
1001
|
+
async createVerify(data) {
|
|
1002
|
+
return this.client.post("/publish/verify", data);
|
|
1003
|
+
}
|
|
1004
|
+
/** Publish an entity (checks database readiness automatically) */
|
|
1005
|
+
async createEntity(data) {
|
|
1006
|
+
return this.client.post("/publish/entity", data);
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
// src/generated/queues.ts
|
|
1011
|
+
var QueuesResource = class {
|
|
1012
|
+
constructor(client) {
|
|
1013
|
+
this.client = client;
|
|
1014
|
+
}
|
|
1015
|
+
/** Get all queues and their statistics (tenant-isolated) */
|
|
1016
|
+
async list() {
|
|
1017
|
+
return this.client.get("/queues");
|
|
1018
|
+
}
|
|
1019
|
+
/** Get statistics for a specific queue (tenant-isolated) */
|
|
1020
|
+
async stats(name) {
|
|
1021
|
+
return this.client.get(`/queues/${name}/stats`);
|
|
1022
|
+
}
|
|
1023
|
+
/** Get jobs from a queue (tenant-isolated) */
|
|
1024
|
+
async jobs(name) {
|
|
1025
|
+
return this.client.get(`/queues/${name}/jobs`);
|
|
1026
|
+
}
|
|
1027
|
+
/** Add a job to the queue (with tenant isolation) */
|
|
1028
|
+
async createJob(name, data) {
|
|
1029
|
+
return this.client.post(`/queues/${name}/jobs`, data);
|
|
1030
|
+
}
|
|
1031
|
+
/** Get a specific job (tenant-isolated) */
|
|
1032
|
+
async getJob(name, jobId) {
|
|
1033
|
+
return this.client.get(`/queues/${name}/jobs/${jobId}`);
|
|
1034
|
+
}
|
|
1035
|
+
/** Retry a failed job (tenant-isolated) */
|
|
1036
|
+
async retry(name, jobId, data) {
|
|
1037
|
+
return this.client.post(`/queues/${name}/jobs/${jobId}/retry`, data);
|
|
1038
|
+
}
|
|
1039
|
+
/** Pause a queue (admin only - affects all tenants) */
|
|
1040
|
+
async pause(name, data) {
|
|
1041
|
+
return this.client.post(`/queues/${name}/pause`, data);
|
|
1042
|
+
}
|
|
1043
|
+
/** Resume a paused queue (admin only - affects all tenants) */
|
|
1044
|
+
async resume(name, data) {
|
|
1045
|
+
return this.client.post(`/queues/${name}/resume`, data);
|
|
1046
|
+
}
|
|
1047
|
+
/** Clean old jobs from queue (tenant-isolated) */
|
|
1048
|
+
async createClean(name, data) {
|
|
1049
|
+
return this.client.post(`/queues/${name}/clean`, data);
|
|
1050
|
+
}
|
|
1051
|
+
/** Get detailed performance metrics for a queue */
|
|
1052
|
+
async metrics(name) {
|
|
1053
|
+
return this.client.get(`/queues/${name}/metrics`);
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
// src/generated/search.ts
|
|
1058
|
+
var SearchResource = class {
|
|
1059
|
+
constructor(client) {
|
|
1060
|
+
this.client = client;
|
|
1061
|
+
}
|
|
1062
|
+
/** Fast search across an entity with configurable modes (exact, fuzzy, hybrid) */
|
|
1063
|
+
async get(entity) {
|
|
1064
|
+
return this.client.get(`/search/${entity}`);
|
|
1065
|
+
}
|
|
1066
|
+
/** Index entity records for vector search */
|
|
1067
|
+
async create(data) {
|
|
1068
|
+
return this.client.post("/search/index", data);
|
|
1069
|
+
}
|
|
1070
|
+
/** Delete and reindex all records for an entity */
|
|
1071
|
+
async createReindex(data) {
|
|
1072
|
+
return this.client.post("/search/reindex", data);
|
|
1073
|
+
}
|
|
1074
|
+
/** Delete all indexed records for an entity */
|
|
1075
|
+
async delete(entity) {
|
|
1076
|
+
return this.client.delete(`/search/index/${entity}`);
|
|
1077
|
+
}
|
|
1078
|
+
/** Get search index statistics */
|
|
1079
|
+
async list() {
|
|
1080
|
+
return this.client.get("/search/stats");
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
// src/generated/stripe.ts
|
|
1085
|
+
var StripeResource = class {
|
|
1086
|
+
constructor(client) {
|
|
1087
|
+
this.client = client;
|
|
1088
|
+
}
|
|
1089
|
+
/** Create a Stripe customer */
|
|
1090
|
+
async create(data) {
|
|
1091
|
+
return this.client.post("/integrations/stripe/customers", data);
|
|
1092
|
+
}
|
|
1093
|
+
/** Create a Stripe payment intent */
|
|
1094
|
+
async createPaymentIntents(data) {
|
|
1095
|
+
return this.client.post("/integrations/stripe/payment-intents", data);
|
|
1096
|
+
}
|
|
1097
|
+
/** Create a Stripe subscription */
|
|
1098
|
+
async createSubscriptions(data) {
|
|
1099
|
+
return this.client.post("/integrations/stripe/subscriptions", data);
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
|
|
1103
|
+
// src/generated/teams.ts
|
|
1104
|
+
var TeamsResource = class {
|
|
1105
|
+
constructor(client) {
|
|
1106
|
+
this.client = client;
|
|
1107
|
+
}
|
|
1108
|
+
/** Get all teams */
|
|
1109
|
+
async list() {
|
|
1110
|
+
return this.client.get("/teams");
|
|
1111
|
+
}
|
|
1112
|
+
/** Create a new team */
|
|
1113
|
+
async create(data) {
|
|
1114
|
+
return this.client.post("/teams", data);
|
|
1115
|
+
}
|
|
1116
|
+
/** Get team by ID */
|
|
1117
|
+
async get(id) {
|
|
1118
|
+
return this.client.get(`/teams/${id}`);
|
|
1119
|
+
}
|
|
1120
|
+
/** Update team metadata (name, description, members) */
|
|
1121
|
+
async update(id, data) {
|
|
1122
|
+
return this.client.put(`/teams/${id}`, data);
|
|
1123
|
+
}
|
|
1124
|
+
/** Delete team */
|
|
1125
|
+
async delete(id) {
|
|
1126
|
+
return this.client.delete(`/teams/${id}`);
|
|
1127
|
+
}
|
|
1128
|
+
/** Get all projects for a team */
|
|
1129
|
+
async projects(id) {
|
|
1130
|
+
return this.client.get(`/teams/${id}/projects`);
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
|
|
1134
|
+
// src/generated/tenant-webhook-receivers.ts
|
|
1135
|
+
var TenantWebhookReceiversResource = class {
|
|
1136
|
+
constructor(client) {
|
|
1137
|
+
this.client = client;
|
|
1138
|
+
}
|
|
1139
|
+
/** List webhook receivers */
|
|
1140
|
+
async list() {
|
|
1141
|
+
return this.client.get("/tenant/webhook-receivers");
|
|
1142
|
+
}
|
|
1143
|
+
/** Create webhook receiver */
|
|
1144
|
+
async create(data) {
|
|
1145
|
+
return this.client.post("/tenant/webhook-receivers", data);
|
|
1146
|
+
}
|
|
1147
|
+
/** Get webhook receiver */
|
|
1148
|
+
async get(id) {
|
|
1149
|
+
return this.client.get(`/tenant/webhook-receivers/${id}`);
|
|
1150
|
+
}
|
|
1151
|
+
/** Update webhook receiver */
|
|
1152
|
+
async update(id, data) {
|
|
1153
|
+
return this.client.put(`/tenant/webhook-receivers/${id}`, data);
|
|
1154
|
+
}
|
|
1155
|
+
/** Delete webhook receiver */
|
|
1156
|
+
async delete(id) {
|
|
1157
|
+
return this.client.delete(`/tenant/webhook-receivers/${id}`);
|
|
1158
|
+
}
|
|
1159
|
+
};
|
|
1160
|
+
|
|
1161
|
+
// src/generated/tenant-webhooks.ts
|
|
1162
|
+
var TenantWebhooksResource = class {
|
|
1163
|
+
constructor(client) {
|
|
1164
|
+
this.client = client;
|
|
1165
|
+
}
|
|
1166
|
+
/** List webhooks */
|
|
1167
|
+
async list() {
|
|
1168
|
+
return this.client.get("/tenant/webhooks");
|
|
1169
|
+
}
|
|
1170
|
+
/** Create webhook */
|
|
1171
|
+
async create(data) {
|
|
1172
|
+
return this.client.post("/tenant/webhooks", data);
|
|
1173
|
+
}
|
|
1174
|
+
/** Get webhook */
|
|
1175
|
+
async get(id) {
|
|
1176
|
+
return this.client.get(`/tenant/webhooks/${id}`);
|
|
1177
|
+
}
|
|
1178
|
+
/** Update webhook */
|
|
1179
|
+
async update(id, data) {
|
|
1180
|
+
return this.client.put(`/tenant/webhooks/${id}`, data);
|
|
1181
|
+
}
|
|
1182
|
+
/** Delete webhook */
|
|
1183
|
+
async delete(id) {
|
|
1184
|
+
return this.client.delete(`/tenant/webhooks/${id}`);
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
|
|
1188
|
+
// src/generated/tooldiscovery.ts
|
|
1189
|
+
var ToolDiscoveryResource = class {
|
|
1190
|
+
constructor(client) {
|
|
1191
|
+
this.client = client;
|
|
1192
|
+
}
|
|
1193
|
+
/** Get all registered tools including MCP, user-configured, and built-in tools */
|
|
1194
|
+
async list() {
|
|
1195
|
+
return this.client.get("/agent/tools");
|
|
1196
|
+
}
|
|
1197
|
+
/** Search for tools using text query, category, tags, capabilities, and performance filters */
|
|
1198
|
+
async create(data) {
|
|
1199
|
+
return this.client.post("/agent/tools/search", data);
|
|
1200
|
+
}
|
|
1201
|
+
/** Search for tools using natural language semantic similarity */
|
|
1202
|
+
async createSemanticSearch(data) {
|
|
1203
|
+
return this.client.post("/agent/tools/semantic-search", data);
|
|
1204
|
+
}
|
|
1205
|
+
/** Use AI to automatically select appropriate tools based on a natural language goal */
|
|
1206
|
+
async createSelect(data) {
|
|
1207
|
+
return this.client.post("/agent/tools/select", data);
|
|
1208
|
+
}
|
|
1209
|
+
/** Get tool recommendations based on goal and historical performance data */
|
|
1210
|
+
async createRecommend(data) {
|
|
1211
|
+
return this.client.post("/agent/tools/recommend", data);
|
|
1212
|
+
}
|
|
1213
|
+
/** Get performance metrics (success rate, latency, usage) for a specific tool */
|
|
1214
|
+
async metrics(toolName) {
|
|
1215
|
+
return this.client.get(`/agent/tools/${toolName}/metrics`);
|
|
1216
|
+
}
|
|
1217
|
+
/** Index all registered tools for semantic search using embeddings */
|
|
1218
|
+
async createIndex(data) {
|
|
1219
|
+
return this.client.post("/agent/tools/index", data);
|
|
1220
|
+
}
|
|
1221
|
+
};
|
|
1222
|
+
|
|
1223
|
+
// src/generated/tracking.ts
|
|
1224
|
+
var TrackingResource = class {
|
|
1225
|
+
constructor(client) {
|
|
1226
|
+
this.client = client;
|
|
1227
|
+
}
|
|
1228
|
+
/** Get MCP call statistics for the tenant */
|
|
1229
|
+
async list() {
|
|
1230
|
+
return this.client.get("/tracking/mcp/stats");
|
|
1231
|
+
}
|
|
1232
|
+
/** Get field-level change history for an entity */
|
|
1233
|
+
async history(entityType, entityId) {
|
|
1234
|
+
return this.client.get(`/tracking/entity/${entityType}/${entityId}/history`);
|
|
1235
|
+
}
|
|
1236
|
+
/** Get change history for a specific field */
|
|
1237
|
+
async getField(entityType, entityId, fieldName) {
|
|
1238
|
+
return this.client.get(`/tracking/entity/${entityType}/${entityId}/field/${fieldName}`);
|
|
1239
|
+
}
|
|
1240
|
+
/** Get tracking buffer status (AI usage buffer size) */
|
|
1241
|
+
async listStatus() {
|
|
1242
|
+
return this.client.get("/tracking/buffer/status");
|
|
1243
|
+
}
|
|
1244
|
+
/** Manually flush tracking buffers to database */
|
|
1245
|
+
async create(data) {
|
|
1246
|
+
return this.client.post("/tracking/buffer/flush", data);
|
|
1247
|
+
}
|
|
1248
|
+
};
|
|
1249
|
+
|
|
1250
|
+
// src/generated/twitter.ts
|
|
1251
|
+
var TwitterResource = class {
|
|
1252
|
+
constructor(client) {
|
|
1253
|
+
this.client = client;
|
|
1254
|
+
}
|
|
1255
|
+
/** Search X (Twitter) tweets by query */
|
|
1256
|
+
async list() {
|
|
1257
|
+
return this.client.get("/api/twitter/search");
|
|
1258
|
+
}
|
|
1259
|
+
/** Get details of a specific tweet */
|
|
1260
|
+
async get(tweetId) {
|
|
1261
|
+
return this.client.get(`/api/twitter/tweets/${tweetId}`);
|
|
1262
|
+
}
|
|
1263
|
+
/** Delete a tweet */
|
|
1264
|
+
async delete(tweetId) {
|
|
1265
|
+
return this.client.delete(`/api/twitter/tweets/${tweetId}`);
|
|
1266
|
+
}
|
|
1267
|
+
/** Post a new tweet */
|
|
1268
|
+
async create(data) {
|
|
1269
|
+
return this.client.post("/api/twitter/tweets", data);
|
|
1270
|
+
}
|
|
1271
|
+
/** Like a tweet */
|
|
1272
|
+
async createLike(userId, data) {
|
|
1273
|
+
return this.client.post(`/api/twitter/users/${userId}/likes`, data);
|
|
1274
|
+
}
|
|
1275
|
+
/** Unlike a tweet */
|
|
1276
|
+
async deleteLike(userId, tweetId) {
|
|
1277
|
+
return this.client.delete(`/api/twitter/users/${userId}/likes/${tweetId}`);
|
|
1278
|
+
}
|
|
1279
|
+
/** Retweet a tweet */
|
|
1280
|
+
async createRetweet(userId, data) {
|
|
1281
|
+
return this.client.post(`/api/twitter/users/${userId}/retweets`, data);
|
|
1282
|
+
}
|
|
1283
|
+
/** Remove a retweet */
|
|
1284
|
+
async deleteRetweet(userId, tweetId) {
|
|
1285
|
+
return this.client.delete(`/api/twitter/users/${userId}/retweets/${tweetId}`);
|
|
1286
|
+
}
|
|
1287
|
+
/** Get user information by username */
|
|
1288
|
+
async getUsername(username) {
|
|
1289
|
+
return this.client.get(`/api/twitter/users/by/username/${username}`);
|
|
1290
|
+
}
|
|
1291
|
+
/** Get user information by user ID */
|
|
1292
|
+
async getUsers(userId) {
|
|
1293
|
+
return this.client.get(`/api/twitter/users/${userId}`);
|
|
1294
|
+
}
|
|
1295
|
+
/** Get authenticated user information */
|
|
1296
|
+
async listMe() {
|
|
1297
|
+
return this.client.get("/api/twitter/user/me");
|
|
1298
|
+
}
|
|
1299
|
+
/** Get recent tweets from a user */
|
|
1300
|
+
async tweets(userId) {
|
|
1301
|
+
return this.client.get(`/api/twitter/users/${userId}/tweets`);
|
|
1302
|
+
}
|
|
1303
|
+
/** Follow a user */
|
|
1304
|
+
async createFollowing(userId, data) {
|
|
1305
|
+
return this.client.post(`/api/twitter/users/${userId}/following`, data);
|
|
1306
|
+
}
|
|
1307
|
+
/** Unfollow a user */
|
|
1308
|
+
async deleteFollowing(userId, targetUserId) {
|
|
1309
|
+
return this.client.delete(`/api/twitter/users/${userId}/following/${targetUserId}`);
|
|
1310
|
+
}
|
|
1311
|
+
/** Get followers of a user */
|
|
1312
|
+
async followers(userId) {
|
|
1313
|
+
return this.client.get(`/api/twitter/users/${userId}/followers`);
|
|
1314
|
+
}
|
|
1315
|
+
/** Get users that a user is following */
|
|
1316
|
+
async followingList(userId) {
|
|
1317
|
+
return this.client.get(`/api/twitter/users/${userId}/following_list`);
|
|
1318
|
+
}
|
|
1319
|
+
/** Get users who liked a tweet */
|
|
1320
|
+
async likedBy(tweetId) {
|
|
1321
|
+
return this.client.get(`/api/twitter/tweets/${tweetId}/liked_by`);
|
|
1322
|
+
}
|
|
1323
|
+
/** Get users who retweeted a tweet */
|
|
1324
|
+
async retweetedBy(tweetId) {
|
|
1325
|
+
return this.client.get(`/api/twitter/tweets/${tweetId}/retweeted_by`);
|
|
1326
|
+
}
|
|
1327
|
+
/** Get tweets in a conversation thread */
|
|
1328
|
+
async getConversations(conversationId) {
|
|
1329
|
+
return this.client.get(`/api/twitter/conversations/${conversationId}`);
|
|
1330
|
+
}
|
|
1331
|
+
/** Get tweets liked by a user */
|
|
1332
|
+
async likedTweets(userId) {
|
|
1333
|
+
return this.client.get(`/api/twitter/users/${userId}/liked_tweets`);
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
|
|
1337
|
+
// src/generated/usage.ts
|
|
1338
|
+
var UsageResource = class {
|
|
1339
|
+
constructor(client) {
|
|
1340
|
+
this.client = client;
|
|
1341
|
+
}
|
|
1342
|
+
/** Get unified usage metrics for a user across AI, API, and integrations */
|
|
1343
|
+
async get(userId) {
|
|
1344
|
+
return this.client.get(`/usage/user/${userId}`);
|
|
1345
|
+
}
|
|
1346
|
+
/** Get a brief summary of user usage */
|
|
1347
|
+
async summary(userId) {
|
|
1348
|
+
return this.client.get(`/usage/user/${userId}/summary`);
|
|
1349
|
+
}
|
|
1350
|
+
/** Get usage metrics for the authenticated user */
|
|
1351
|
+
async list() {
|
|
1352
|
+
return this.client.get("/usage/me");
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1355
|
+
|
|
1356
|
+
// src/generated/websocket.ts
|
|
1357
|
+
var WebsocketResource = class {
|
|
1358
|
+
constructor(client) {
|
|
1359
|
+
this.client = client;
|
|
1360
|
+
}
|
|
1361
|
+
/** WebSocket API Documentation */
|
|
1362
|
+
async list() {
|
|
1363
|
+
return this.client.get("/websocket/info");
|
|
1364
|
+
}
|
|
1365
|
+
};
|
|
1366
|
+
|
|
1367
|
+
// src/generated/workflows.ts
|
|
1368
|
+
var WorkflowsResource = class {
|
|
1369
|
+
constructor(client) {
|
|
1370
|
+
this.client = client;
|
|
1371
|
+
}
|
|
1372
|
+
/** Orchestrate a task by ID. Executes predefined task orchestration logic. */
|
|
1373
|
+
async create(data) {
|
|
1374
|
+
return this.client.post("/agent/orchestrate", data);
|
|
1375
|
+
}
|
|
1376
|
+
/** Execute an agentic workflow with tools and steps. Workflows define a series of actions that can call LLMs, APIs, shell commands, and MCP tools. */
|
|
1377
|
+
async createWorkflow(data) {
|
|
1378
|
+
return this.client.post("/agent/workflow", data);
|
|
1379
|
+
}
|
|
1380
|
+
/** List all workflow executions with date range filter and pagination. */
|
|
1381
|
+
async list() {
|
|
1382
|
+
return this.client.get("/agent/workflows/executions");
|
|
1383
|
+
}
|
|
1384
|
+
/** Delete all workflow executions and their activity records */
|
|
1385
|
+
async delete() {
|
|
1386
|
+
return this.client.delete("/agent/workflows/executions");
|
|
1387
|
+
}
|
|
1388
|
+
/** Delete a specific workflow execution and all its activity records */
|
|
1389
|
+
async deleteExecutions(workflowId) {
|
|
1390
|
+
return this.client.delete(`/agent/workflows/executions/${workflowId}`);
|
|
1391
|
+
}
|
|
1392
|
+
/** Get execution history for a workflow by ID. Returns all historical execution records. */
|
|
1393
|
+
async history(workflowId) {
|
|
1394
|
+
return this.client.get(`/agent/workflow/${workflowId}/history`);
|
|
1395
|
+
}
|
|
1396
|
+
/** Resume a paused workflow execution. Allows continuing or cancelling execution with optional user input. */
|
|
1397
|
+
async createResume(data) {
|
|
1398
|
+
return this.client.post("/agent/workflow/resume", data);
|
|
1399
|
+
}
|
|
1400
|
+
/** Request pause for a running workflow. The workflow will pause after the current step completes. */
|
|
1401
|
+
async pause(executionId, data) {
|
|
1402
|
+
return this.client.post(`/agent/workflow/${executionId}/pause`, data);
|
|
1403
|
+
}
|
|
1404
|
+
/** Cancel a running workflow. The workflow will stop after the current step completes. */
|
|
1405
|
+
async cancel(executionId, data) {
|
|
1406
|
+
return this.client.post(`/agent/workflow/${executionId}/cancel`, data);
|
|
1407
|
+
}
|
|
1408
|
+
/** Get background execution status for workflows that returned early */
|
|
1409
|
+
async status(executionId) {
|
|
1410
|
+
return this.client.get(`/agent/workflow/${executionId}/status`);
|
|
1411
|
+
}
|
|
1412
|
+
/** Retry a workflow execution. Can restart from beginning or resume from last checkpoint. */
|
|
1413
|
+
async retry(executionId, data) {
|
|
1414
|
+
return this.client.post(`/agent/workflow/${executionId}/retry`, data);
|
|
1415
|
+
}
|
|
1416
|
+
/** Health check endpoint with detailed component status. Returns status of embeddings, vector store, MCP servers, and database. */
|
|
1417
|
+
async listHealth() {
|
|
1418
|
+
return this.client.get("/agent/health");
|
|
1419
|
+
}
|
|
1420
|
+
/** Automatically generate and execute a workflow from a natural language goal using AI */
|
|
1421
|
+
async createDynamic(data) {
|
|
1422
|
+
return this.client.post("/agent/workflow/dynamic", data);
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
|
|
1426
|
+
// src/generated/workspaces.ts
|
|
1427
|
+
var WorkspacesResource = class {
|
|
1428
|
+
constructor(client) {
|
|
1429
|
+
this.client = client;
|
|
1430
|
+
}
|
|
1431
|
+
/** Get all workspaces */
|
|
1432
|
+
async list() {
|
|
1433
|
+
return this.client.get("/workspaces");
|
|
1434
|
+
}
|
|
1435
|
+
/** Create a new workspace */
|
|
1436
|
+
async create(data) {
|
|
1437
|
+
return this.client.post("/workspaces", data);
|
|
1438
|
+
}
|
|
1439
|
+
/** Get workspace by ID */
|
|
1440
|
+
async get(id) {
|
|
1441
|
+
return this.client.get(`/workspaces/${id}`);
|
|
1442
|
+
}
|
|
1443
|
+
/** Update workspace */
|
|
1444
|
+
async update(id, data) {
|
|
1445
|
+
return this.client.put(`/workspaces/${id}`, data);
|
|
1446
|
+
}
|
|
1447
|
+
/** Delete workspace */
|
|
1448
|
+
async delete(id) {
|
|
1449
|
+
return this.client.delete(`/workspaces/${id}`);
|
|
1450
|
+
}
|
|
1451
|
+
};
|
|
1452
|
+
|
|
1453
|
+
// src/resources/ai.ts
|
|
1454
|
+
var AIResource = class {
|
|
1455
|
+
constructor(client) {
|
|
1456
|
+
this.client = client;
|
|
1457
|
+
}
|
|
1458
|
+
async chat(options) {
|
|
1459
|
+
return this.client.post("/ai/chat", options);
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
|
|
1463
|
+
// src/resources/collaboration.ts
|
|
1464
|
+
var CollaborationResource = class {
|
|
1465
|
+
constructor(client) {
|
|
1466
|
+
this.client = client;
|
|
1467
|
+
}
|
|
1468
|
+
async presence(data) {
|
|
1469
|
+
return this.client.post("/collaboration/presence", data);
|
|
1470
|
+
}
|
|
1471
|
+
};
|
|
1472
|
+
|
|
1473
|
+
// src/resources/webhooks.ts
|
|
1474
|
+
var WebhooksResource = class {
|
|
1475
|
+
constructor(client, projectId) {
|
|
1476
|
+
this.client = client;
|
|
1477
|
+
this.projectId = projectId;
|
|
1478
|
+
}
|
|
1479
|
+
async trigger(data) {
|
|
1480
|
+
return this.client.post(`/webhooks/${this.projectId}/trigger`, data);
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
var WebhooksFactory = class {
|
|
1484
|
+
constructor(client) {
|
|
1485
|
+
this.client = client;
|
|
1486
|
+
}
|
|
1487
|
+
for(projectId) {
|
|
1488
|
+
return new WebhooksResource(this.client, projectId);
|
|
1489
|
+
}
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1492
|
+
// src/resources/exports.ts
|
|
1493
|
+
var ExportsResource = class {
|
|
1494
|
+
constructor(client) {
|
|
1495
|
+
this.client = client;
|
|
1496
|
+
}
|
|
1497
|
+
async highRes(options) {
|
|
1498
|
+
const contentType = options.contentType || (options.format === "svg" ? "image/svg+xml" : options.format === "pdf" ? "application/pdf" : "image/png");
|
|
1499
|
+
return this.client.post("/exports/high-res", {
|
|
1500
|
+
...options,
|
|
1501
|
+
contentType
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
|
|
1506
|
+
// src/resources/user.ts
|
|
1507
|
+
var UserResource = class {
|
|
1508
|
+
constructor(client) {
|
|
1509
|
+
this.client = client;
|
|
1510
|
+
}
|
|
1511
|
+
async createMetrics(metrics) {
|
|
1512
|
+
return this.client.post("/user/metrics", metrics);
|
|
1513
|
+
}
|
|
1514
|
+
async getMetrics() {
|
|
1515
|
+
return this.client.get("/user/metrics");
|
|
1516
|
+
}
|
|
1517
|
+
async updateMetrics(metrics) {
|
|
1518
|
+
return this.client.put("/user/metrics", metrics);
|
|
1519
|
+
}
|
|
1520
|
+
async getProfile() {
|
|
1521
|
+
return this.client.get("/admin/users/me");
|
|
1522
|
+
}
|
|
1523
|
+
async updateProfile(options) {
|
|
1524
|
+
return this.client.put("/admin/users/me/profile", options);
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
|
|
1528
|
+
// src/resources/entities.ts
|
|
1529
|
+
var EntitiesResource = class {
|
|
1530
|
+
constructor(client) {
|
|
1531
|
+
this.client = client;
|
|
1532
|
+
}
|
|
1533
|
+
async listCollections() {
|
|
1534
|
+
const response = await this.client.get("/admin/entities");
|
|
1535
|
+
return response.data || [];
|
|
1536
|
+
}
|
|
1537
|
+
async list(collection, options) {
|
|
1538
|
+
const params = new URLSearchParams();
|
|
1539
|
+
if (options?.limit) params.set("limit", String(options.limit));
|
|
1540
|
+
if (options?.offset) params.set("offset", String(options.offset));
|
|
1541
|
+
if (options?.includeDeleted) params.set("includeDeleted", "true");
|
|
1542
|
+
const query = params.toString();
|
|
1543
|
+
const url = `/admin/entities/${encodeURIComponent(collection)}${query ? `?${query}` : ""}`;
|
|
1544
|
+
return this.client.get(url);
|
|
1545
|
+
}
|
|
1546
|
+
async get(collection, id, options) {
|
|
1547
|
+
const params = new URLSearchParams();
|
|
1548
|
+
if (options?.includeDeleted) params.set("includeDeleted", "true");
|
|
1549
|
+
const query = params.toString();
|
|
1550
|
+
const response = await this.client.get(
|
|
1551
|
+
`/admin/entities/${encodeURIComponent(collection)}/${encodeURIComponent(id)}${query ? `?${query}` : ""}`
|
|
1552
|
+
);
|
|
1553
|
+
return response.data;
|
|
1554
|
+
}
|
|
1555
|
+
async create(collection, data) {
|
|
1556
|
+
const response = await this.client.post(
|
|
1557
|
+
`/admin/entities/${encodeURIComponent(collection)}`,
|
|
1558
|
+
data
|
|
1559
|
+
);
|
|
1560
|
+
return response.data;
|
|
1561
|
+
}
|
|
1562
|
+
async update(collection, id, data) {
|
|
1563
|
+
const response = await this.client.put(
|
|
1564
|
+
`/admin/entities/${encodeURIComponent(collection)}/${encodeURIComponent(id)}`,
|
|
1565
|
+
data
|
|
1566
|
+
);
|
|
1567
|
+
return response.data;
|
|
1568
|
+
}
|
|
1569
|
+
async delete(collection, id, options) {
|
|
1570
|
+
const params = new URLSearchParams();
|
|
1571
|
+
if (options?.hard) params.set("hard", "true");
|
|
1572
|
+
if (options?.softDelete === false) params.set("softDelete", "false");
|
|
1573
|
+
const query = params.toString();
|
|
1574
|
+
const url = `/admin/entities/${encodeURIComponent(collection)}/${encodeURIComponent(id)}${query ? `?${query}` : ""}`;
|
|
1575
|
+
return this.client.delete(url);
|
|
1576
|
+
}
|
|
1577
|
+
async restore(collection, id) {
|
|
1578
|
+
return this.client.post(
|
|
1579
|
+
`/admin/entities/${encodeURIComponent(collection)}/${encodeURIComponent(id)}/restore`,
|
|
1580
|
+
{}
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1583
|
+
async getSchema() {
|
|
1584
|
+
const response = await this.client.get("/admin/schema");
|
|
1585
|
+
return response.data || [];
|
|
1586
|
+
}
|
|
1587
|
+
/**
|
|
1588
|
+
* Get schema for a specific collection
|
|
1589
|
+
*/
|
|
1590
|
+
async getCollectionSchema(collection) {
|
|
1591
|
+
const schemas = await this.getSchema();
|
|
1592
|
+
return schemas.find((s) => s.collection === collection) || null;
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* Validate data against a collection's schema (client-side)
|
|
1596
|
+
*/
|
|
1597
|
+
async validate(collection, data) {
|
|
1598
|
+
const schema = await this.getCollectionSchema(collection);
|
|
1599
|
+
if (!schema) {
|
|
1600
|
+
return { valid: true };
|
|
1601
|
+
}
|
|
1602
|
+
const errors = [];
|
|
1603
|
+
for (const field of schema.fields) {
|
|
1604
|
+
if (field.source === "builtin") continue;
|
|
1605
|
+
const value = data[field.name];
|
|
1606
|
+
const hasValue = value !== void 0 && value !== null && value !== "";
|
|
1607
|
+
if (field.required && !hasValue) {
|
|
1608
|
+
errors.push({ field: field.name, message: `${field.name} is required` });
|
|
1609
|
+
continue;
|
|
1610
|
+
}
|
|
1611
|
+
if (!hasValue) continue;
|
|
1612
|
+
if (field.type === "integer" || field.type === "bigint") {
|
|
1613
|
+
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
1614
|
+
errors.push({ field: field.name, message: `${field.name} must be an integer` });
|
|
1615
|
+
continue;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
if (field.type === "decimal") {
|
|
1619
|
+
if (typeof value !== "number") {
|
|
1620
|
+
errors.push({ field: field.name, message: `${field.name} must be a number` });
|
|
1621
|
+
continue;
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
if (field.type === "boolean") {
|
|
1625
|
+
if (typeof value !== "boolean") {
|
|
1626
|
+
errors.push({ field: field.name, message: `${field.name} must be a boolean` });
|
|
1627
|
+
continue;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
if (typeof value === "number") {
|
|
1631
|
+
if (field.min !== void 0 && value < field.min) {
|
|
1632
|
+
errors.push({ field: field.name, message: `${field.name} must be at least ${field.min}` });
|
|
1633
|
+
}
|
|
1634
|
+
if (field.max !== void 0 && value > field.max) {
|
|
1635
|
+
errors.push({ field: field.name, message: `${field.name} must be at most ${field.max}` });
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
if (typeof value === "string") {
|
|
1639
|
+
if (field.min !== void 0 && value.length < field.min) {
|
|
1640
|
+
errors.push({ field: field.name, message: `${field.name} must be at least ${field.min} characters` });
|
|
1641
|
+
}
|
|
1642
|
+
if (field.max !== void 0 && value.length > field.max) {
|
|
1643
|
+
errors.push({ field: field.name, message: `${field.name} must be at most ${field.max} characters` });
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
if (field.enum && field.enum.length > 0) {
|
|
1647
|
+
if (!field.enum.includes(String(value))) {
|
|
1648
|
+
errors.push({ field: field.name, message: `${field.name} must be one of: ${field.enum.join(", ")}` });
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
if (field.pattern && typeof value === "string") {
|
|
1652
|
+
const regex = new RegExp(field.pattern);
|
|
1653
|
+
if (!regex.test(value)) {
|
|
1654
|
+
errors.push({ field: field.name, message: `${field.name} has invalid format` });
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
if (field.preset && typeof value === "string") {
|
|
1658
|
+
const presetError = this.validatePreset(field.preset, value, field.name);
|
|
1659
|
+
if (presetError) {
|
|
1660
|
+
errors.push(presetError);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
return errors.length > 0 ? { valid: false, errors } : { valid: true };
|
|
1665
|
+
}
|
|
1666
|
+
validatePreset(preset, value, fieldName) {
|
|
1667
|
+
const patterns = {
|
|
1668
|
+
email: { regex: /^[^\s@]+@[^\s@]+\.[^\s@]+$/, message: "must be a valid email" },
|
|
1669
|
+
url: { regex: /^https?:\/\/[^\s/$.?#].[^\s]*$/i, message: "must be a valid URL" },
|
|
1670
|
+
"phone-us": { regex: /^\+?1?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/, message: "must be a valid US phone" },
|
|
1671
|
+
"phone-intl": { regex: /^\+?[\d\s\-().]{7,20}$/, message: "must be a valid phone number" },
|
|
1672
|
+
uuid: { regex: /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, message: "must be a valid UUID" },
|
|
1673
|
+
slug: { regex: /^[a-z0-9]+(?:-[a-z0-9]+)*$/, message: "must be a valid slug" },
|
|
1674
|
+
username: { regex: /^[a-zA-Z0-9_]{3,30}$/, message: "must be 3-30 chars, letters/numbers/underscores" },
|
|
1675
|
+
password: { regex: /^.{8,}$/, message: "must be at least 8 characters" },
|
|
1676
|
+
name: { regex: /^[\p{L}\s\-'.]{1,100}$/u, message: "must be a valid name" },
|
|
1677
|
+
currency: { regex: /^\d+(\.\d{1,2})?$/, message: "must be a valid currency amount" },
|
|
1678
|
+
percentage: { regex: /^(100(\.0{1,2})?|\d{1,2}(\.\d{1,2})?)$/, message: "must be 0-100" },
|
|
1679
|
+
date: { regex: /^\d{4}-\d{2}-\d{2}$/, message: "must be YYYY-MM-DD format" },
|
|
1680
|
+
datetime: { regex: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/, message: "must be ISO datetime" },
|
|
1681
|
+
time: { regex: /^\d{2}:\d{2}(:\d{2})?$/, message: "must be HH:MM or HH:MM:SS" },
|
|
1682
|
+
ip: { regex: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/, message: "must be a valid IP" },
|
|
1683
|
+
ipv4: { regex: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/, message: "must be a valid IPv4" },
|
|
1684
|
+
ipv6: { regex: /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/, message: "must be a valid IPv6" },
|
|
1685
|
+
"mac-address": { regex: /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/, message: "must be a valid MAC address" },
|
|
1686
|
+
"credit-card": { regex: /^\d{13,19}$/, message: "must be a valid card number" },
|
|
1687
|
+
"postal-code-us": { regex: /^\d{5}(-\d{4})?$/, message: "must be a valid US postal code" },
|
|
1688
|
+
ssn: { regex: /^\d{3}-\d{2}-\d{4}$/, message: "must be XXX-XX-XXXX format" },
|
|
1689
|
+
"hex-color": { regex: /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, message: "must be #RGB or #RRGGBB" },
|
|
1690
|
+
json: { regex: /^[\s\S]*$/, message: "must be valid JSON" }
|
|
1691
|
+
};
|
|
1692
|
+
const config = patterns[preset];
|
|
1693
|
+
if (!config) return null;
|
|
1694
|
+
if (preset === "json") {
|
|
1695
|
+
try {
|
|
1696
|
+
JSON.parse(value);
|
|
1697
|
+
return null;
|
|
1698
|
+
} catch {
|
|
1699
|
+
return { field: fieldName, message: `${fieldName} ${config.message}` };
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
if (!config.regex.test(value)) {
|
|
1703
|
+
return { field: fieldName, message: `${fieldName} ${config.message}` };
|
|
1704
|
+
}
|
|
1705
|
+
return null;
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* Create with validation (validates before sending to server)
|
|
1709
|
+
*/
|
|
1710
|
+
async createValidated(collection, data) {
|
|
1711
|
+
const validation = await this.validate(collection, data);
|
|
1712
|
+
if (!validation.valid) {
|
|
1713
|
+
return { errors: validation.errors };
|
|
1714
|
+
}
|
|
1715
|
+
const result = await this.create(collection, data);
|
|
1716
|
+
return { data: result };
|
|
1717
|
+
}
|
|
1718
|
+
/**
|
|
1719
|
+
* Update with validation (validates before sending to server)
|
|
1720
|
+
*/
|
|
1721
|
+
async updateValidated(collection, id, data) {
|
|
1722
|
+
const validation = await this.validate(collection, data);
|
|
1723
|
+
if (!validation.valid) {
|
|
1724
|
+
return { errors: validation.errors };
|
|
1725
|
+
}
|
|
1726
|
+
const result = await this.update(collection, id, data);
|
|
1727
|
+
return { data: result };
|
|
1728
|
+
}
|
|
1729
|
+
};
|
|
1730
|
+
|
|
1731
|
+
// src/resources/files.ts
|
|
1732
|
+
var FilesResource2 = class {
|
|
1733
|
+
constructor(client) {
|
|
1734
|
+
this.client = client;
|
|
1735
|
+
}
|
|
1736
|
+
async upload(file, options = {}) {
|
|
1737
|
+
return this.client.upload("/files/upload", file, {
|
|
1738
|
+
bucket: options.bucket || "squeed-storage",
|
|
1739
|
+
entityType: options.entityType || "project",
|
|
1740
|
+
entityId: options.entityId || "default"
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
async uploadMultiple(files, options = {}) {
|
|
1744
|
+
return this.client.upload("/files/upload-multiple", files, {
|
|
1745
|
+
bucket: options.bucket || "squeed-storage",
|
|
1746
|
+
entityType: options.entityType || "project",
|
|
1747
|
+
entityId: options.entityId || "default"
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1750
|
+
async list(entityType, entityId, options) {
|
|
1751
|
+
const params = {};
|
|
1752
|
+
if (options?.limit) params.limit = options.limit;
|
|
1753
|
+
if (options?.offset) params.offset = options.offset;
|
|
1754
|
+
const response = await this.client.get(`/files/entity/${entityType}/${entityId}`, params);
|
|
1755
|
+
return response.files || [];
|
|
1756
|
+
}
|
|
1757
|
+
async getSignedUrl(bucket, key, expiresIn = 600) {
|
|
1758
|
+
return this.client.get(`/files/signed-url/${bucket}/${encodeURIComponent(key)}`, { expiresIn });
|
|
1759
|
+
}
|
|
1760
|
+
async download(bucket, key) {
|
|
1761
|
+
const { signedUrl } = await this.getSignedUrl(bucket, key);
|
|
1762
|
+
const response = await fetch(signedUrl);
|
|
1763
|
+
return response.blob();
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Stream file download with optional progress tracking
|
|
1767
|
+
* More efficient for large files than standard download()
|
|
1768
|
+
* Streaming must be enabled in backend config (r2.streaming.enabled: true)
|
|
1769
|
+
*/
|
|
1770
|
+
async downloadStream(bucket, key, options) {
|
|
1771
|
+
const response = await this.client.getRaw(
|
|
1772
|
+
`/files/stream/${bucket}/${encodeURIComponent(key)}`
|
|
1773
|
+
);
|
|
1774
|
+
if (!response.body) {
|
|
1775
|
+
throw new Error("No response body");
|
|
1776
|
+
}
|
|
1777
|
+
const total = parseInt(response.headers.get("content-length") || "0", 10);
|
|
1778
|
+
const reader = response.body.getReader();
|
|
1779
|
+
const chunks = [];
|
|
1780
|
+
let loaded = 0;
|
|
1781
|
+
try {
|
|
1782
|
+
while (true) {
|
|
1783
|
+
const { done, value } = await reader.read();
|
|
1784
|
+
if (done) break;
|
|
1785
|
+
chunks.push(new Uint8Array(value));
|
|
1786
|
+
loaded += value.length;
|
|
1787
|
+
if (options?.onProgress) {
|
|
1788
|
+
options.onProgress({
|
|
1789
|
+
loaded,
|
|
1790
|
+
total,
|
|
1791
|
+
percentage: total > 0 ? Math.round(loaded / total * 100) : 0
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
} finally {
|
|
1796
|
+
reader.releaseLock();
|
|
1797
|
+
}
|
|
1798
|
+
const contentType = response.headers.get("content-type") || "application/octet-stream";
|
|
1799
|
+
return new Blob(chunks, { type: contentType });
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Get a raw stream for the file
|
|
1803
|
+
* Useful for custom processing or piping to other streams
|
|
1804
|
+
* Streaming must be enabled in backend config (r2.streaming.enabled: true)
|
|
1805
|
+
*/
|
|
1806
|
+
async getDownloadStream(bucket, key) {
|
|
1807
|
+
const response = await this.client.getRaw(
|
|
1808
|
+
`/files/stream/${bucket}/${encodeURIComponent(key)}`
|
|
1809
|
+
);
|
|
1810
|
+
if (!response.body) {
|
|
1811
|
+
throw new Error("No response body");
|
|
1812
|
+
}
|
|
1813
|
+
return response.body;
|
|
1814
|
+
}
|
|
1815
|
+
async delete(bucket, key) {
|
|
1816
|
+
return this.client.delete(`/files/${bucket}/${encodeURIComponent(key)}`);
|
|
1817
|
+
}
|
|
1818
|
+
async deleteByEntity(entityType, entityId) {
|
|
1819
|
+
return this.client.delete(`/files/entity/${entityType}/${entityId}`);
|
|
1820
|
+
}
|
|
1821
|
+
async uploadJson(options) {
|
|
1822
|
+
return this.client.post("/files/upload-json", options);
|
|
1823
|
+
}
|
|
1824
|
+
};
|
|
1825
|
+
|
|
1826
|
+
// src/resources/workflows.ts
|
|
1827
|
+
var TOOL_TYPES = [
|
|
1828
|
+
"llm_call",
|
|
1829
|
+
"api_call",
|
|
1830
|
+
"shell_command",
|
|
1831
|
+
"web_search",
|
|
1832
|
+
"file_edit",
|
|
1833
|
+
"git_command",
|
|
1834
|
+
"mcp_tool",
|
|
1835
|
+
"storage",
|
|
1836
|
+
"database",
|
|
1837
|
+
"notification",
|
|
1838
|
+
"workflow",
|
|
1839
|
+
"rag",
|
|
1840
|
+
"cache",
|
|
1841
|
+
"emit_event",
|
|
1842
|
+
"transform"
|
|
1843
|
+
];
|
|
1844
|
+
var TRIGGER_TYPES = ["manual", "cron", "webhook", "event"];
|
|
1845
|
+
var NOTIFY_CHANNELS = ["email", "sms", "whatsapp", "push", "slack"];
|
|
1846
|
+
var NOTIFY_PRIORITIES = ["low", "normal", "high", "urgent"];
|
|
1847
|
+
var DB_OPERATIONS = ["get", "query", "insert", "update", "upsert", "delete", "deletewhere", "arrayRemove", "updateArrayElement", "count"];
|
|
1848
|
+
var STORAGE_OPERATIONS = ["get", "download", "put", "upload", "list", "signedUrl", "delete", "deleteByPrefix", "url", "publicUrl"];
|
|
1849
|
+
var CACHE_OPERATIONS = ["get", "set", "delete", "invalidate"];
|
|
1850
|
+
var LLM_PROVIDERS = ["openai", "anthropic", "google", "openrouter", "lmstudio", "custom", "claude", "ollama"];
|
|
1851
|
+
var CLI_PROVIDERS = ["claude", "openai", "aider", "anthropic", "claude-cli", "openai-cli", "ollama-cli"];
|
|
1852
|
+
var DB_PROVIDERS = ["firebase", "supabase", "sqlite", "custom"];
|
|
1853
|
+
var HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
1854
|
+
var RAG_MODES = ["single", "accumulate", "iterative"];
|
|
1855
|
+
var CHUNKING_STRATEGIES = ["fixed_size", "recursive", "token_based", "semantic"];
|
|
1856
|
+
var IMAGE_DETAILS = ["auto", "low", "high"];
|
|
1857
|
+
var CONDITION_OPERATORS = ["$eq", "$ne", "$gt", "$gte", "$lt", "$lte", "$in", "$exists"];
|
|
1858
|
+
var WORKFLOW_VALIDATION_SCHEMA = {
|
|
1859
|
+
root: {
|
|
1860
|
+
id: { type: "string", required: true, description: "Unique workflow identifier" },
|
|
1861
|
+
name: { type: "string", required: true, description: "Human-readable workflow name" },
|
|
1862
|
+
description: { type: "string", required: false, description: "Workflow purpose and details" },
|
|
1863
|
+
tools: { type: "array", required: true, multiselect: true, description: "Tool definitions available to the workflow" },
|
|
1864
|
+
workflows: { type: "array", required: true, multiselect: true, description: "Array of executable workflows" },
|
|
1865
|
+
agent: {
|
|
1866
|
+
type: "object",
|
|
1867
|
+
required: false,
|
|
1868
|
+
description: "Agent configuration with LLM instructions",
|
|
1869
|
+
properties: {
|
|
1870
|
+
id: { type: "string", required: false, description: "Unique agent identifier" },
|
|
1871
|
+
name: { type: "string", required: false, description: "Agent display name" },
|
|
1872
|
+
role: { type: "string", required: false, description: "Agent role/responsibility" },
|
|
1873
|
+
llm_prompt: { type: "string", required: false, description: "System prompt for LLM" }
|
|
1874
|
+
}
|
|
1875
|
+
},
|
|
1876
|
+
monitoring: {
|
|
1877
|
+
type: "object",
|
|
1878
|
+
required: false,
|
|
1879
|
+
description: "KPI and performance tracking",
|
|
1880
|
+
properties: {
|
|
1881
|
+
kpis: {
|
|
1882
|
+
type: "array",
|
|
1883
|
+
required: false,
|
|
1884
|
+
multiselect: true,
|
|
1885
|
+
description: "Key performance indicators",
|
|
1886
|
+
itemType: {
|
|
1887
|
+
type: "object",
|
|
1888
|
+
required: false,
|
|
1889
|
+
properties: {
|
|
1890
|
+
metric: { type: "string", required: true, description: "Metric name" },
|
|
1891
|
+
target: { type: "string", required: false, description: "Target value" },
|
|
1892
|
+
measurement: { type: "string", required: false, description: "Measurement source" }
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
},
|
|
1898
|
+
working_directory: { type: "string", required: false, description: "Base directory for execution" },
|
|
1899
|
+
context: { type: "object", required: false, description: "Initial context variables for template substitution" },
|
|
1900
|
+
planOnly: { type: "boolean", required: false, default: false, description: "If true, only generate execution plan" },
|
|
1901
|
+
allowPause: { type: "boolean", required: false, default: false, description: "Enable pause/resume capabilities" },
|
|
1902
|
+
subscribable: { type: "boolean", required: false, default: false, description: "Enable real-time WebSocket progress updates" }
|
|
1903
|
+
},
|
|
1904
|
+
tool: {
|
|
1905
|
+
name: { type: "string", required: true, description: "Unique tool identifier" },
|
|
1906
|
+
type: { type: "enum", required: true, options: TOOL_TYPES, description: "Tool type" },
|
|
1907
|
+
description: { type: "string", required: false, description: "What the tool does" },
|
|
1908
|
+
endpoint: { type: "string", required: false, description: "API endpoint URL (for api_call type)" },
|
|
1909
|
+
params: {
|
|
1910
|
+
type: "object",
|
|
1911
|
+
required: false,
|
|
1912
|
+
description: "Configuration parameters",
|
|
1913
|
+
properties: {
|
|
1914
|
+
timeout: { type: "number", required: false, default: 3e4, description: "Timeout in milliseconds" },
|
|
1915
|
+
method: { type: "enum", required: false, options: HTTP_METHODS, description: "HTTP method" },
|
|
1916
|
+
headers: { type: "object", required: false, description: "HTTP headers" },
|
|
1917
|
+
maxBuffer: { type: "number", required: false, description: "Max buffer size for shell commands" },
|
|
1918
|
+
cwd: { type: "string", required: false, description: "Working directory" },
|
|
1919
|
+
env: { type: "object", required: false, description: "Environment variables for shell commands" },
|
|
1920
|
+
provider: { type: "enum", required: false, options: LLM_PROVIDERS, description: "LLM provider" },
|
|
1921
|
+
model: { type: "string", required: false, description: "Model identifier" },
|
|
1922
|
+
baseURL: { type: "string", required: false, description: "Custom API endpoint for LLM" },
|
|
1923
|
+
temperature: { type: "number", required: false, default: 0.7, description: "LLM temperature (0-2)" },
|
|
1924
|
+
max_tokens: { type: "number", required: false, default: 4e3, description: "Max tokens for LLM response" },
|
|
1925
|
+
maxTokens: { type: "number", required: false, default: 4e3, description: "Max tokens (alias)" },
|
|
1926
|
+
stop: { type: "array", required: false, multiselect: true, description: "Stop sequences for LLM" },
|
|
1927
|
+
saveMedia: { type: "boolean", required: false, default: false, description: "Save generated images to storage" },
|
|
1928
|
+
mediaBucket: { type: "string", required: false, description: "Storage bucket for media" },
|
|
1929
|
+
mediaPrefix: { type: "string", required: false, description: "Path prefix for media files" },
|
|
1930
|
+
cliProvider: { type: "enum", required: false, options: CLI_PROVIDERS, description: "CLI provider for shell commands" },
|
|
1931
|
+
requireAuth: { type: "boolean", required: false, description: "Check CLI authentication" },
|
|
1932
|
+
parseJSON: { type: "boolean", required: false, description: "Attempt to parse stdout as JSON" },
|
|
1933
|
+
mcpServer: { type: "string", required: false, description: "MCP server name" },
|
|
1934
|
+
toolName: { type: "string", required: false, description: "MCP tool name" },
|
|
1935
|
+
operation: { type: "enum", required: false, options: [...DB_OPERATIONS, ...STORAGE_OPERATIONS, ...CACHE_OPERATIONS], description: "Database/storage/cache operation" },
|
|
1936
|
+
bucket: { type: "string", required: false, description: "Storage bucket name" },
|
|
1937
|
+
contentKey: { type: "string", required: false, description: "Storage content key/path" },
|
|
1938
|
+
path: { type: "string", required: false, description: "File path (alias for contentKey)" },
|
|
1939
|
+
entityType: { type: "string", required: false, description: "Entity type for storage linking" },
|
|
1940
|
+
entityId: { type: "string", required: false, description: "Entity ID for storage linking" },
|
|
1941
|
+
contentType: { type: "string", required: false, description: "MIME type" },
|
|
1942
|
+
expiresIn: { type: "number", required: false, description: "Expiry in seconds for signed URLs" },
|
|
1943
|
+
prefix: { type: "string", required: false, description: "Prefix for deleteByPrefix operation" },
|
|
1944
|
+
dbProvider: { type: "enum", required: false, options: DB_PROVIDERS, default: "supabase", description: "Database provider" },
|
|
1945
|
+
collection: { type: "string", required: false, description: "Database collection/table name" },
|
|
1946
|
+
table: { type: "string", required: false, description: "Table name (alias for collection)" },
|
|
1947
|
+
id: { type: "string", required: false, description: "Document/record ID" },
|
|
1948
|
+
docId: { type: "string", required: false, description: "Document ID (alias)" },
|
|
1949
|
+
data: { type: "object", required: false, description: "Data for insert/update" },
|
|
1950
|
+
where: { type: "array", required: false, multiselect: true, description: "Query filters" },
|
|
1951
|
+
filters: { type: "array", required: false, multiselect: true, description: "Query filters (alias)" },
|
|
1952
|
+
orderBy: { type: "string", required: false, description: "Sort order" },
|
|
1953
|
+
limit: { type: "number", required: false, description: "Result limit" },
|
|
1954
|
+
offset: { type: "number", required: false, description: "Result offset" },
|
|
1955
|
+
field: { type: "string", required: false, description: "Field name for array operations" },
|
|
1956
|
+
value: { type: "string", required: false, description: "Value for array operations" },
|
|
1957
|
+
arrayField: { type: "string", required: false, description: "Array field name" },
|
|
1958
|
+
matchKey: { type: "string", required: false, description: "Key to match in array" },
|
|
1959
|
+
matchValue: { type: "string", required: false, description: "Value to match in array" },
|
|
1960
|
+
updates: { type: "object", required: false, description: "Partial update data" },
|
|
1961
|
+
channels: { type: "array", required: false, multiselect: true, options: NOTIFY_CHANNELS, description: "Notification channels" },
|
|
1962
|
+
title: { type: "string", required: false, description: "Notification title" },
|
|
1963
|
+
body: { type: "string", required: false, description: "Notification message" },
|
|
1964
|
+
userId: { type: "string", required: false, description: "Recipient user ID" },
|
|
1965
|
+
email: { type: "string", required: false, description: "Recipient email" },
|
|
1966
|
+
phone: { type: "string", required: false, description: "Recipient phone" },
|
|
1967
|
+
priority: { type: "enum", required: false, options: NOTIFY_PRIORITIES, description: "Notification priority" },
|
|
1968
|
+
category: { type: "string", required: false, description: "Notification category" },
|
|
1969
|
+
actionUrl: { type: "string", required: false, description: "Action URL" },
|
|
1970
|
+
actionText: { type: "string", required: false, description: "Action button text" },
|
|
1971
|
+
imageUrl: { type: "string", required: false, description: "Image URL" },
|
|
1972
|
+
respectUserPreferences: { type: "boolean", required: false, default: true, description: "Respect user notification preferences" },
|
|
1973
|
+
silent: { type: "boolean", required: false, default: false, description: "Silent notification" },
|
|
1974
|
+
saveToHistory: { type: "boolean", required: false, default: true, description: "Save to notification history" },
|
|
1975
|
+
pattern: { type: "string", required: false, description: "Cache invalidation pattern" },
|
|
1976
|
+
key: { type: "string", required: false, description: "Cache key" },
|
|
1977
|
+
ttl: { type: "number", required: false, description: "Cache TTL in seconds" },
|
|
1978
|
+
command: { type: "string", required: false, description: "Shell command to execute" }
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
},
|
|
1982
|
+
step: {
|
|
1983
|
+
id: { type: "string", required: true, description: "Unique step identifier within workflow" },
|
|
1984
|
+
action: { type: "string", required: true, description: "Name of tool to execute" },
|
|
1985
|
+
type: { type: "enum", required: false, options: TOOL_TYPES, description: "Step type override (e.g., for rag)" },
|
|
1986
|
+
description: { type: "string", required: false, description: "Step purpose" },
|
|
1987
|
+
input: {
|
|
1988
|
+
type: "object",
|
|
1989
|
+
required: false,
|
|
1990
|
+
description: "Data passed to the step",
|
|
1991
|
+
properties: {
|
|
1992
|
+
query: { type: "string", required: false, description: "Search query for RAG" },
|
|
1993
|
+
mode: { type: "enum", required: false, options: RAG_MODES, description: "RAG search mode" },
|
|
1994
|
+
limit: { type: "number", required: false, default: 5, description: "Result limit" },
|
|
1995
|
+
filter: { type: "object", required: false, description: "RAG filter criteria" },
|
|
1996
|
+
contextKey: { type: "string", required: false, description: "Context key for RAG results" },
|
|
1997
|
+
timeout: { type: "number", required: false, default: 3e4, description: "Step timeout" }
|
|
1998
|
+
}
|
|
1999
|
+
},
|
|
2000
|
+
output: { type: "string", required: false, description: "Variable name to store output" },
|
|
2001
|
+
params: { type: "object", required: false, description: "Step-specific parameter overrides (same as tool params)" },
|
|
2002
|
+
conditions: {
|
|
2003
|
+
type: "object",
|
|
2004
|
+
required: false,
|
|
2005
|
+
description: "Conditional execution logic",
|
|
2006
|
+
properties: {
|
|
2007
|
+
if: { type: "string", required: false, description: "Expression-based condition" }
|
|
2008
|
+
}
|
|
2009
|
+
},
|
|
2010
|
+
files: {
|
|
2011
|
+
type: "array",
|
|
2012
|
+
required: false,
|
|
2013
|
+
multiselect: true,
|
|
2014
|
+
description: "File attachments for LLM steps",
|
|
2015
|
+
itemType: {
|
|
2016
|
+
type: "object",
|
|
2017
|
+
required: false,
|
|
2018
|
+
properties: {
|
|
2019
|
+
id: { type: "string", required: false, description: "File ID" },
|
|
2020
|
+
url: { type: "string", required: false, description: "File URL" },
|
|
2021
|
+
data: { type: "string", required: false, description: "Base64 encoded data" },
|
|
2022
|
+
mimeType: { type: "string", required: true, description: "MIME type" },
|
|
2023
|
+
filename: { type: "string", required: false, description: "Original filename" }
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
},
|
|
2027
|
+
images: {
|
|
2028
|
+
type: "array",
|
|
2029
|
+
required: false,
|
|
2030
|
+
multiselect: true,
|
|
2031
|
+
description: "Image attachments for vision tasks",
|
|
2032
|
+
itemType: {
|
|
2033
|
+
type: "object",
|
|
2034
|
+
required: false,
|
|
2035
|
+
properties: {
|
|
2036
|
+
url: { type: "string", required: true, description: "Image URL" },
|
|
2037
|
+
detail: { type: "enum", required: false, options: IMAGE_DETAILS, default: "auto", description: "Image detail level" }
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
},
|
|
2041
|
+
dependsOn: { type: "array", required: false, multiselect: true, description: "Step IDs this step depends on" },
|
|
2042
|
+
parallel: { type: "boolean", required: false, default: false, description: "Execute in parallel with other steps" },
|
|
2043
|
+
earlyReturn: { type: "boolean", required: false, default: false, description: "Return immediately, continue in background" },
|
|
2044
|
+
queueAsJob: { type: "boolean", required: false, default: false, description: "Queue background execution as a job (requires earlyReturn)" },
|
|
2045
|
+
pausePoint: { type: "object", required: false, description: "Pause/approval control" },
|
|
2046
|
+
retryCount: { type: "number", required: false, default: 0, description: "Current retry count" },
|
|
2047
|
+
maxRetries: { type: "number", required: false, default: 0, description: "Maximum retry attempts" },
|
|
2048
|
+
optional: { type: "boolean", required: false, default: false, description: "If true, step failure won't stop the workflow" },
|
|
2049
|
+
continueOnError: { type: "boolean", required: false, default: false, description: "Alias for optional" },
|
|
2050
|
+
defaultValue: { type: "object", required: false, description: "Value to use if step fails when optional=true" }
|
|
2051
|
+
},
|
|
2052
|
+
trigger: {
|
|
2053
|
+
type: { type: "enum", required: true, options: TRIGGER_TYPES, description: "Trigger type" },
|
|
2054
|
+
cron: { type: "string", required: false, description: "Cron expression for scheduled triggers" },
|
|
2055
|
+
webhook: { type: "object", required: false, description: "Webhook configuration" },
|
|
2056
|
+
event: { type: "string", required: false, description: "Event name or pattern for event triggers (e.g., posts.created, posts.*)" },
|
|
2057
|
+
eventFilter: { type: "object", required: false, description: "Filter criteria for event data" }
|
|
2058
|
+
},
|
|
2059
|
+
pausePoint: {
|
|
2060
|
+
requireApproval: { type: "boolean", required: false, default: false, description: "Manual approval required" },
|
|
2061
|
+
message: { type: "string", required: false, description: "Message shown to user" },
|
|
2062
|
+
metadata: { type: "object", required: false, description: "Custom metadata for pause state" },
|
|
2063
|
+
notify: { type: "object", required: false, description: "Notification settings when paused" }
|
|
2064
|
+
},
|
|
2065
|
+
notify: {
|
|
2066
|
+
enabled: { type: "boolean", required: false, default: false, description: "Enable notifications" },
|
|
2067
|
+
channels: { type: "array", required: false, multiselect: true, options: NOTIFY_CHANNELS, description: "Notification channels" },
|
|
2068
|
+
priority: { type: "enum", required: false, options: NOTIFY_PRIORITIES, default: "normal", description: "Notification priority" },
|
|
2069
|
+
userId: { type: "string", required: false, description: "User ID to notify" }
|
|
2070
|
+
},
|
|
2071
|
+
workflow: {
|
|
2072
|
+
name: { type: "string", required: true, description: "Workflow name" },
|
|
2073
|
+
trigger: { type: "object", required: true, description: "Trigger configuration" },
|
|
2074
|
+
steps: { type: "array", required: true, multiselect: true, description: "Array of workflow steps" },
|
|
2075
|
+
config: {
|
|
2076
|
+
type: "object",
|
|
2077
|
+
required: false,
|
|
2078
|
+
description: "Workflow-specific configuration",
|
|
2079
|
+
properties: {
|
|
2080
|
+
allowPause: { type: "boolean", required: false, description: "Override parent allowPause" },
|
|
2081
|
+
maxAttempts: { type: "number", required: false, description: "Maximum retry attempts" }
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
},
|
|
2085
|
+
fileAttachment: {
|
|
2086
|
+
id: { type: "string", required: false, description: "File ID" },
|
|
2087
|
+
url: { type: "string", required: false, description: "File URL" },
|
|
2088
|
+
data: { type: "string", required: false, description: "Base64 encoded file data" },
|
|
2089
|
+
mimeType: { type: "string", required: true, description: "MIME type of the file" },
|
|
2090
|
+
filename: { type: "string", required: false, description: "Original filename" }
|
|
2091
|
+
},
|
|
2092
|
+
imageAttachment: {
|
|
2093
|
+
url: { type: "string", required: true, description: "Image URL" },
|
|
2094
|
+
detail: { type: "enum", required: false, options: IMAGE_DETAILS, default: "auto", description: "Image detail level for vision" }
|
|
2095
|
+
},
|
|
2096
|
+
conditionOperators: {
|
|
2097
|
+
$eq: { type: "string", required: false, description: "Equal to value" },
|
|
2098
|
+
$ne: { type: "string", required: false, description: "Not equal to value" },
|
|
2099
|
+
$gt: { type: "number", required: false, description: "Greater than value" },
|
|
2100
|
+
$gte: { type: "number", required: false, description: "Greater than or equal to value" },
|
|
2101
|
+
$lt: { type: "number", required: false, description: "Less than value" },
|
|
2102
|
+
$lte: { type: "number", required: false, description: "Less than or equal to value" },
|
|
2103
|
+
$in: { type: "array", required: false, multiselect: true, description: "Value is in array" },
|
|
2104
|
+
$exists: { type: "boolean", required: false, description: "Property exists" }
|
|
2105
|
+
}
|
|
2106
|
+
};
|
|
2107
|
+
var WorkflowsResource2 = class {
|
|
2108
|
+
constructor(client) {
|
|
2109
|
+
this.client = client;
|
|
2110
|
+
}
|
|
2111
|
+
async execute(config) {
|
|
2112
|
+
return this.client.post("/agent/workflow", config);
|
|
2113
|
+
}
|
|
2114
|
+
async get(executionId) {
|
|
2115
|
+
return this.client.get(`/agent/workflow/${executionId}`);
|
|
2116
|
+
}
|
|
2117
|
+
async list(params) {
|
|
2118
|
+
const response = await this.client.get("/agent/workflows/executions", params);
|
|
2119
|
+
return { executions: response.executions || [], pagination: response.pagination };
|
|
2120
|
+
}
|
|
2121
|
+
async getHistory(workflowId) {
|
|
2122
|
+
return this.client.get(`/agent/workflow/${workflowId}/history`);
|
|
2123
|
+
}
|
|
2124
|
+
async pause(executionId) {
|
|
2125
|
+
return this.client.post(`/agent/workflow/${executionId}/pause`);
|
|
2126
|
+
}
|
|
2127
|
+
async resume(executionId, options) {
|
|
2128
|
+
return this.client.post("/agent/workflow/resume", {
|
|
2129
|
+
executionId,
|
|
2130
|
+
continue: options?.continue ?? true,
|
|
2131
|
+
userInput: options?.userInput
|
|
2132
|
+
});
|
|
2133
|
+
}
|
|
2134
|
+
async cancel(executionId) {
|
|
2135
|
+
return this.client.post(`/agent/workflow/${executionId}/cancel`);
|
|
2136
|
+
}
|
|
2137
|
+
async getStatus(executionId) {
|
|
2138
|
+
const response = await this.client.get(`/agent/workflow/${executionId}/status`);
|
|
2139
|
+
return response.execution;
|
|
2140
|
+
}
|
|
2141
|
+
async retry(executionId) {
|
|
2142
|
+
return this.client.post(`/agent/workflow/${executionId}/retry`);
|
|
2143
|
+
}
|
|
2144
|
+
async rerun(workflowId) {
|
|
2145
|
+
return this.client.post(`/agent/workflow/${workflowId}/rerun`);
|
|
2146
|
+
}
|
|
2147
|
+
async delete(workflowId) {
|
|
2148
|
+
return this.client.delete(`/agent/workflows/executions/${workflowId}`);
|
|
2149
|
+
}
|
|
2150
|
+
async deleteAll() {
|
|
2151
|
+
return this.client.delete("/agent/workflows/executions");
|
|
2152
|
+
}
|
|
2153
|
+
subscribe(executionId, handlers) {
|
|
2154
|
+
const ws = this.client.createWebSocket(`workflow:${executionId}`);
|
|
2155
|
+
ws.onmessage = (event) => {
|
|
2156
|
+
try {
|
|
2157
|
+
const data = JSON.parse(event.data);
|
|
2158
|
+
switch (data.type) {
|
|
2159
|
+
case "step_started":
|
|
2160
|
+
handlers.onStepStarted?.(data.step);
|
|
2161
|
+
break;
|
|
2162
|
+
case "step_completed":
|
|
2163
|
+
handlers.onStepCompleted?.(data.step, data.duration);
|
|
2164
|
+
handlers.onProgress?.({ stepId: data.step, status: "success" });
|
|
2165
|
+
break;
|
|
2166
|
+
case "step_failed":
|
|
2167
|
+
handlers.onStepFailed?.(data.step, data.error);
|
|
2168
|
+
handlers.onProgress?.({ stepId: data.step, status: "failed", error: data.error });
|
|
2169
|
+
break;
|
|
2170
|
+
case "step_skipped":
|
|
2171
|
+
handlers.onStepSkipped?.(data.step, data.error);
|
|
2172
|
+
handlers.onProgress?.({ stepId: data.step, status: "skipped", error: data.error });
|
|
2173
|
+
break;
|
|
2174
|
+
case "workflow_completed":
|
|
2175
|
+
handlers.onComplete?.({ id: data.executionId, workflowId: "", status: "completed", startedAt: "" });
|
|
2176
|
+
break;
|
|
2177
|
+
case "workflow_failed":
|
|
2178
|
+
handlers.onError?.(new Error(data.error || "Workflow failed"));
|
|
2179
|
+
break;
|
|
2180
|
+
case "workflow_cancelled":
|
|
2181
|
+
handlers.onComplete?.({ id: data.executionId, workflowId: "", status: "cancelled", startedAt: "" });
|
|
2182
|
+
break;
|
|
2183
|
+
}
|
|
2184
|
+
} catch (error) {
|
|
2185
|
+
handlers.onError?.(error);
|
|
2186
|
+
}
|
|
2187
|
+
};
|
|
2188
|
+
ws.onerror = (error) => handlers.onError?.(error);
|
|
2189
|
+
return () => ws.close();
|
|
2190
|
+
}
|
|
2191
|
+
getValidationSchema() {
|
|
2192
|
+
return WORKFLOW_VALIDATION_SCHEMA;
|
|
2193
|
+
}
|
|
2194
|
+
getSchemaFor(section) {
|
|
2195
|
+
return WORKFLOW_VALIDATION_SCHEMA[section];
|
|
2196
|
+
}
|
|
2197
|
+
getToolTypes() {
|
|
2198
|
+
return TOOL_TYPES;
|
|
2199
|
+
}
|
|
2200
|
+
getTriggerTypes() {
|
|
2201
|
+
return TRIGGER_TYPES;
|
|
2202
|
+
}
|
|
2203
|
+
getNotifyChannels() {
|
|
2204
|
+
return NOTIFY_CHANNELS;
|
|
2205
|
+
}
|
|
2206
|
+
getNotifyPriorities() {
|
|
2207
|
+
return NOTIFY_PRIORITIES;
|
|
2208
|
+
}
|
|
2209
|
+
getDbOperations() {
|
|
2210
|
+
return DB_OPERATIONS;
|
|
2211
|
+
}
|
|
2212
|
+
getStorageOperations() {
|
|
2213
|
+
return STORAGE_OPERATIONS;
|
|
2214
|
+
}
|
|
2215
|
+
validateProperty(section, property, value) {
|
|
2216
|
+
const schema = WORKFLOW_VALIDATION_SCHEMA[section];
|
|
2217
|
+
const propSchema = schema[property];
|
|
2218
|
+
if (!propSchema) {
|
|
2219
|
+
return { valid: false, error: `Unknown property: ${property}` };
|
|
2220
|
+
}
|
|
2221
|
+
if (propSchema.required && (value === void 0 || value === null)) {
|
|
2222
|
+
return { valid: false, error: `${property} is required` };
|
|
2223
|
+
}
|
|
2224
|
+
if (value === void 0 || value === null) {
|
|
2225
|
+
return { valid: true };
|
|
2226
|
+
}
|
|
2227
|
+
if (propSchema.type === "enum" && propSchema.options) {
|
|
2228
|
+
if (!propSchema.options.includes(value)) {
|
|
2229
|
+
return { valid: false, error: `${property} must be one of: ${propSchema.options.join(", ")}` };
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
if (propSchema.type === "array" && !Array.isArray(value)) {
|
|
2233
|
+
return { valid: false, error: `${property} must be an array` };
|
|
2234
|
+
}
|
|
2235
|
+
if (propSchema.type === "boolean" && typeof value !== "boolean") {
|
|
2236
|
+
return { valid: false, error: `${property} must be a boolean` };
|
|
2237
|
+
}
|
|
2238
|
+
if (propSchema.type === "number" && typeof value !== "number") {
|
|
2239
|
+
return { valid: false, error: `${property} must be a number` };
|
|
2240
|
+
}
|
|
2241
|
+
if (propSchema.type === "string" && typeof value !== "string") {
|
|
2242
|
+
return { valid: false, error: `${property} must be a string` };
|
|
2243
|
+
}
|
|
2244
|
+
return { valid: true };
|
|
2245
|
+
}
|
|
2246
|
+
};
|
|
2247
|
+
var TOOL_PARAM_CONTEXT = {
|
|
2248
|
+
llm_call: ["provider", "model", "temperature", "max_tokens", "baseURL", "stop", "saveMedia", "mediaBucket"],
|
|
2249
|
+
api_call: ["method", "headers", "timeout", "endpoint"],
|
|
2250
|
+
shell_command: ["command", "cwd", "timeout", "env", "maxBuffer", "cliProvider", "parseJSON", "requireAuth"],
|
|
2251
|
+
database: ["dbProvider", "operation", "collection", "id", "data", "where", "orderBy", "limit", "offset"],
|
|
2252
|
+
storage: ["operation", "bucket", "contentKey", "path", "data", "contentType", "expiresIn", "prefix"],
|
|
2253
|
+
notification: ["channels", "title", "body", "userId", "email", "phone", "priority", "silent"],
|
|
2254
|
+
cache: ["operation", "key", "pattern", "ttl", "value"],
|
|
2255
|
+
mcp_tool: ["mcpServer", "toolName", "timeout"],
|
|
2256
|
+
rag: ["query", "mode", "limit", "filter", "contextKey"],
|
|
2257
|
+
workflow: ["timeout"],
|
|
2258
|
+
web_search: ["query", "limit"],
|
|
2259
|
+
file_edit: ["path", "content"],
|
|
2260
|
+
git_command: ["command", "cwd"]
|
|
2261
|
+
};
|
|
2262
|
+
function formatProp(key, val, indent = "") {
|
|
2263
|
+
const req = val.required ? "*" : "";
|
|
2264
|
+
const opts = val.options ? ` [${val.options.slice(0, 6).join("|")}${val.options.length > 6 ? "..." : ""}]` : "";
|
|
2265
|
+
const multi = val.multiselect ? "[]" : "";
|
|
2266
|
+
return `${indent}${key}${req}: ${val.type}${multi}${opts}`;
|
|
2267
|
+
}
|
|
2268
|
+
function toPromptContext(options = {}) {
|
|
2269
|
+
const { sections, toolType, compact = false } = options;
|
|
2270
|
+
const sectionsToInclude = sections || ["root", "tool", "step", "trigger", "pausePoint", "notify"];
|
|
2271
|
+
let out = "# Workflow Schema\n\n";
|
|
2272
|
+
if (!compact) {
|
|
2273
|
+
out += `Tool types: ${TOOL_TYPES.join(", ")}
|
|
2274
|
+
`;
|
|
2275
|
+
out += `Triggers: ${TRIGGER_TYPES.join(", ")}
|
|
2276
|
+
`;
|
|
2277
|
+
out += `Notify channels: ${NOTIFY_CHANNELS.join(", ")}
|
|
2278
|
+
|
|
2279
|
+
`;
|
|
2280
|
+
}
|
|
2281
|
+
for (const section of sectionsToInclude) {
|
|
2282
|
+
const schema = WORKFLOW_VALIDATION_SCHEMA[section];
|
|
2283
|
+
if (!schema) continue;
|
|
2284
|
+
out += `## ${section}
|
|
2285
|
+
`;
|
|
2286
|
+
for (const [key, val] of Object.entries(schema)) {
|
|
2287
|
+
if (key === "params" && toolType && TOOL_PARAM_CONTEXT[toolType]) {
|
|
2288
|
+
out += formatProp(key, val) + "\n";
|
|
2289
|
+
const relevantParams = TOOL_PARAM_CONTEXT[toolType];
|
|
2290
|
+
if (val.properties) {
|
|
2291
|
+
for (const pk of relevantParams) {
|
|
2292
|
+
const pv = val.properties[pk];
|
|
2293
|
+
if (pv) out += formatProp(pk, pv, " ") + "\n";
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
} else {
|
|
2297
|
+
out += formatProp(key, val) + "\n";
|
|
2298
|
+
if (!compact && val.properties) {
|
|
2299
|
+
for (const [pk, pv] of Object.entries(val.properties)) {
|
|
2300
|
+
out += formatProp(pk, pv, " ") + "\n";
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
out += "\n";
|
|
2306
|
+
}
|
|
2307
|
+
return out;
|
|
2308
|
+
}
|
|
2309
|
+
function toCompactContext(toolType) {
|
|
2310
|
+
return toPromptContext({ compact: true, toolType, sections: ["step", "tool"] });
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
// src/resources/embeddings.ts
|
|
2314
|
+
var EmbeddingsResource2 = class {
|
|
2315
|
+
constructor(client) {
|
|
2316
|
+
this.client = client;
|
|
2317
|
+
}
|
|
2318
|
+
async listDocuments(limit = 100) {
|
|
2319
|
+
return this.client.get("/agent/embeddings/documents", { limit });
|
|
2320
|
+
}
|
|
2321
|
+
async embedDocument(options) {
|
|
2322
|
+
return this.client.post("/agent/embeddings/document", options);
|
|
2323
|
+
}
|
|
2324
|
+
async embedBatch(documents, contentType) {
|
|
2325
|
+
return this.client.post("/agent/embeddings/batch", {
|
|
2326
|
+
documents,
|
|
2327
|
+
contentType
|
|
2328
|
+
});
|
|
2329
|
+
}
|
|
2330
|
+
async search(documentId, query, limit = 5) {
|
|
2331
|
+
return this.client.get(`/agent/embeddings/document/${encodeURIComponent(documentId)}/search`, {
|
|
2332
|
+
q: query,
|
|
2333
|
+
limit
|
|
2334
|
+
});
|
|
2335
|
+
}
|
|
2336
|
+
async delete(documentId) {
|
|
2337
|
+
return this.client.delete(`/agent/embeddings/document/${encodeURIComponent(documentId)}`);
|
|
2338
|
+
}
|
|
2339
|
+
async semanticSearch(query, limit = 10) {
|
|
2340
|
+
return this.client.post("/agent/tools/semantic-search", {
|
|
2341
|
+
query,
|
|
2342
|
+
limit
|
|
2343
|
+
});
|
|
2344
|
+
}
|
|
2345
|
+
};
|
|
2346
|
+
|
|
2347
|
+
// src/resources/usage.ts
|
|
2348
|
+
var UsageResource2 = class {
|
|
2349
|
+
constructor(client) {
|
|
2350
|
+
this.client = client;
|
|
2351
|
+
}
|
|
2352
|
+
async getMyUsage() {
|
|
2353
|
+
return this.client.get("/usage/me");
|
|
2354
|
+
}
|
|
2355
|
+
async getUserUsage(userId, options) {
|
|
2356
|
+
return this.client.get(`/usage/user/${userId}`, options);
|
|
2357
|
+
}
|
|
2358
|
+
async getSummary(userId) {
|
|
2359
|
+
return this.client.get(`/usage/user/${userId}/summary`);
|
|
2360
|
+
}
|
|
2361
|
+
};
|
|
2362
|
+
|
|
2363
|
+
// src/resources/analytics.ts
|
|
2364
|
+
var AnalyticsResource2 = class {
|
|
2365
|
+
constructor(client) {
|
|
2366
|
+
this.client = client;
|
|
2367
|
+
}
|
|
2368
|
+
async project(projectId) {
|
|
2369
|
+
return this.client.get(`/analytics/project/${projectId}`);
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
|
|
2373
|
+
// src/resources/github.ts
|
|
2374
|
+
var GithubResource2 = class {
|
|
2375
|
+
constructor(client) {
|
|
2376
|
+
this.client = client;
|
|
2377
|
+
}
|
|
2378
|
+
async import(owner, repo, options) {
|
|
2379
|
+
return this.client.post(`/api/github/repos/${owner}/${repo}/import`, options);
|
|
2380
|
+
}
|
|
2381
|
+
async repos() {
|
|
2382
|
+
return this.client.get("/api/github/repos");
|
|
2383
|
+
}
|
|
2384
|
+
async contents(owner, repo, path) {
|
|
2385
|
+
const url = path ? `/api/github/repos/${owner}/${repo}/contents/${path}` : `/api/github/repos/${owner}/${repo}/contents`;
|
|
2386
|
+
return this.client.get(url);
|
|
2387
|
+
}
|
|
2388
|
+
async branches(owner, repo) {
|
|
2389
|
+
return this.client.get(`/api/github/repos/${owner}/${repo}/branches`);
|
|
2390
|
+
}
|
|
2391
|
+
async pulls(owner, repo) {
|
|
2392
|
+
return this.client.get(`/api/github/repos/${owner}/${repo}/pulls`);
|
|
2393
|
+
}
|
|
2394
|
+
async getPull(owner, repo, pullNumber) {
|
|
2395
|
+
return this.client.get(`/api/github/repos/${owner}/${repo}/pulls/${pullNumber}`);
|
|
2396
|
+
}
|
|
2397
|
+
async files(owner, repo, pullNumber) {
|
|
2398
|
+
return this.client.get(`/api/github/repos/${owner}/${repo}/pulls/${pullNumber}/files`);
|
|
2399
|
+
}
|
|
2400
|
+
};
|
|
2401
|
+
|
|
2402
|
+
// src/resources/queues.ts
|
|
2403
|
+
var QueuesResource2 = class {
|
|
2404
|
+
constructor(client) {
|
|
2405
|
+
this.client = client;
|
|
2406
|
+
}
|
|
2407
|
+
/** Get all queues and their statistics (tenant-isolated) */
|
|
2408
|
+
async list() {
|
|
2409
|
+
return this.client.get("/queues");
|
|
2410
|
+
}
|
|
2411
|
+
/** Get statistics for a specific queue (tenant-isolated) */
|
|
2412
|
+
async stats(name) {
|
|
2413
|
+
return this.client.get(`/queues/${name}/stats`);
|
|
2414
|
+
}
|
|
2415
|
+
/** Get jobs from a queue (tenant-isolated) */
|
|
2416
|
+
async jobs(name) {
|
|
2417
|
+
return this.client.get(`/queues/${name}/jobs`);
|
|
2418
|
+
}
|
|
2419
|
+
/** Add a job to the queue (with tenant isolation) */
|
|
2420
|
+
async createJob(name, data) {
|
|
2421
|
+
return this.client.post(`/queues/${name}/jobs`, data);
|
|
2422
|
+
}
|
|
2423
|
+
/** Get a specific job (tenant-isolated) */
|
|
2424
|
+
async getJob(name, jobId) {
|
|
2425
|
+
return this.client.get(`/queues/${name}/jobs/${jobId}`);
|
|
2426
|
+
}
|
|
2427
|
+
/** Retry a failed job (tenant-isolated) */
|
|
2428
|
+
async retry(name, jobId, data) {
|
|
2429
|
+
return this.client.post(`/queues/${name}/jobs/${jobId}/retry`, data);
|
|
2430
|
+
}
|
|
2431
|
+
/** Pause a queue (admin only - affects all tenants) */
|
|
2432
|
+
async pause(name, data) {
|
|
2433
|
+
return this.client.post(`/queues/${name}/pause`, data);
|
|
2434
|
+
}
|
|
2435
|
+
/** Resume a paused queue (admin only - affects all tenants) */
|
|
2436
|
+
async resume(name, data) {
|
|
2437
|
+
return this.client.post(`/queues/${name}/resume`, data);
|
|
2438
|
+
}
|
|
2439
|
+
/** Clean old jobs from queue (tenant-isolated) */
|
|
2440
|
+
async createClean(name, data) {
|
|
2441
|
+
return this.client.post(`/queues/${name}/clean`, data);
|
|
2442
|
+
}
|
|
2443
|
+
/** Get detailed performance metrics for a queue */
|
|
2444
|
+
async metrics(name) {
|
|
2445
|
+
return this.client.get(`/queues/${name}/metrics`);
|
|
2446
|
+
}
|
|
2447
|
+
/** Subscribe to job updates via SSE. Returns unsubscribe function. */
|
|
2448
|
+
subscribe(sseUrl, handlers) {
|
|
2449
|
+
return this.client.subscribeSSE(sseUrl, handlers);
|
|
2450
|
+
}
|
|
2451
|
+
};
|
|
2452
|
+
|
|
2453
|
+
// src/resources/search.ts
|
|
2454
|
+
var SearchConfigValidator = class {
|
|
2455
|
+
constructor() {
|
|
2456
|
+
this.validOperators = ["eq", "neq", "gt", "gte", "lt", "lte", "like", "ilike", "in", "not_in", "is_null", "not_null"];
|
|
2457
|
+
this.validModes = ["exact", "fuzzy", "hybrid"];
|
|
2458
|
+
}
|
|
2459
|
+
/**
|
|
2460
|
+
* Validate search options for a query
|
|
2461
|
+
*/
|
|
2462
|
+
validateSearchOptions(options) {
|
|
2463
|
+
const errors = [];
|
|
2464
|
+
if (!options.q || options.q.trim().length === 0) {
|
|
2465
|
+
errors.push({ field: "q", message: "Search query is required and cannot be empty" });
|
|
2466
|
+
}
|
|
2467
|
+
if (options.mode && !this.validModes.includes(options.mode)) {
|
|
2468
|
+
errors.push({ field: "mode", message: `Invalid mode. Must be one of: ${this.validModes.join(", ")}` });
|
|
2469
|
+
}
|
|
2470
|
+
if (options.limit !== void 0) {
|
|
2471
|
+
if (options.limit < 1 || options.limit > 100) {
|
|
2472
|
+
errors.push({ field: "limit", message: "Limit must be between 1 and 100" });
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
if (options.threshold !== void 0) {
|
|
2476
|
+
if (options.threshold < 0 || options.threshold > 1) {
|
|
2477
|
+
errors.push({ field: "threshold", message: "Threshold must be between 0 and 1" });
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
return { valid: errors.length === 0, errors };
|
|
2481
|
+
}
|
|
2482
|
+
/**
|
|
2483
|
+
* Validate entity configuration
|
|
2484
|
+
*/
|
|
2485
|
+
validateEntityConfig(entity, config) {
|
|
2486
|
+
const errors = [];
|
|
2487
|
+
if (!entity || entity.trim().length === 0) {
|
|
2488
|
+
errors.push({ field: "entity", message: "Entity name is required" });
|
|
2489
|
+
}
|
|
2490
|
+
if (!config.searchFields || config.searchFields.length === 0) {
|
|
2491
|
+
errors.push({ field: "searchFields", message: "At least one search field is required" });
|
|
2492
|
+
} else {
|
|
2493
|
+
config.searchFields.forEach((field, idx) => {
|
|
2494
|
+
if (!field || field.trim().length === 0) {
|
|
2495
|
+
errors.push({ field: `searchFields[${idx}]`, message: "Search field cannot be empty" });
|
|
2496
|
+
}
|
|
2497
|
+
});
|
|
2498
|
+
}
|
|
2499
|
+
if (config.filters) {
|
|
2500
|
+
config.filters.forEach((filter, idx) => {
|
|
2501
|
+
if (!filter.column) {
|
|
2502
|
+
errors.push({ field: `filters[${idx}].column`, message: "Filter column is required" });
|
|
2503
|
+
}
|
|
2504
|
+
if (!filter.operator) {
|
|
2505
|
+
errors.push({ field: `filters[${idx}].operator`, message: "Filter operator is required" });
|
|
2506
|
+
} else if (!this.validOperators.includes(filter.operator)) {
|
|
2507
|
+
errors.push({
|
|
2508
|
+
field: `filters[${idx}].operator`,
|
|
2509
|
+
message: `Invalid operator. Must be one of: ${this.validOperators.join(", ")}`
|
|
2510
|
+
});
|
|
2511
|
+
}
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
return { valid: errors.length === 0, errors };
|
|
2515
|
+
}
|
|
2516
|
+
/**
|
|
2517
|
+
* Validate full search configuration
|
|
2518
|
+
*/
|
|
2519
|
+
validateConfig(config) {
|
|
2520
|
+
const errors = [];
|
|
2521
|
+
if (config.defaultMode && !this.validModes.includes(config.defaultMode)) {
|
|
2522
|
+
errors.push({ field: "defaultMode", message: `Invalid mode. Must be one of: ${this.validModes.join(", ")}` });
|
|
2523
|
+
}
|
|
2524
|
+
if (config.defaultLimit !== void 0) {
|
|
2525
|
+
if (config.defaultLimit < 1 || config.defaultLimit > 100) {
|
|
2526
|
+
errors.push({ field: "defaultLimit", message: "Default limit must be between 1 and 100" });
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
if (config.cacheTTL !== void 0 && config.cacheTTL < 0) {
|
|
2530
|
+
errors.push({ field: "cacheTTL", message: "Cache TTL cannot be negative" });
|
|
2531
|
+
}
|
|
2532
|
+
if (config.threshold !== void 0) {
|
|
2533
|
+
if (config.threshold < 0 || config.threshold > 1) {
|
|
2534
|
+
errors.push({ field: "threshold", message: "Threshold must be between 0 and 1" });
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
if (config.entities) {
|
|
2538
|
+
Object.entries(config.entities).forEach(([entity, entityConfig]) => {
|
|
2539
|
+
const entityResult = this.validateEntityConfig(entity, entityConfig);
|
|
2540
|
+
entityResult.errors.forEach((err) => {
|
|
2541
|
+
errors.push({ field: `entities.${entity}.${err.field}`, message: err.message });
|
|
2542
|
+
});
|
|
2543
|
+
});
|
|
2544
|
+
}
|
|
2545
|
+
return { valid: errors.length === 0, errors };
|
|
2546
|
+
}
|
|
2547
|
+
};
|
|
2548
|
+
var SearchResource2 = class {
|
|
2549
|
+
constructor(client) {
|
|
2550
|
+
this.client = client;
|
|
2551
|
+
this.validator = new SearchConfigValidator();
|
|
2552
|
+
}
|
|
2553
|
+
/**
|
|
2554
|
+
* Search an entity
|
|
2555
|
+
*
|
|
2556
|
+
* @param entity - Entity/table name to search
|
|
2557
|
+
* @param options - Search options
|
|
2558
|
+
* @returns Search results with metadata
|
|
2559
|
+
*
|
|
2560
|
+
* @example
|
|
2561
|
+
* ```typescript
|
|
2562
|
+
* // Basic search
|
|
2563
|
+
* const results = await backflow.search.query('products', { q: 'laptop' });
|
|
2564
|
+
*
|
|
2565
|
+
* // Advanced search with all options
|
|
2566
|
+
* const results = await backflow.search.query('products', {
|
|
2567
|
+
* q: 'gaming laptop',
|
|
2568
|
+
* mode: 'hybrid', // 'exact' | 'fuzzy' | 'hybrid'
|
|
2569
|
+
* limit: 20, // max results
|
|
2570
|
+
* threshold: 0.7 // similarity threshold for fuzzy/hybrid
|
|
2571
|
+
* });
|
|
2572
|
+
*
|
|
2573
|
+
* // Access results
|
|
2574
|
+
* results.results.forEach(product => {
|
|
2575
|
+
* console.log(product.name, product._score); // _score for fuzzy results
|
|
2576
|
+
* });
|
|
2577
|
+
* ```
|
|
2578
|
+
*/
|
|
2579
|
+
async query(entity, options) {
|
|
2580
|
+
const validation = this.validator.validateSearchOptions(options);
|
|
2581
|
+
if (!validation.valid) {
|
|
2582
|
+
throw new Error(`Invalid search options: ${validation.errors.map((e) => e.message).join(", ")}`);
|
|
2583
|
+
}
|
|
2584
|
+
const params = { q: options.q };
|
|
2585
|
+
if (options.mode) params.mode = options.mode;
|
|
2586
|
+
if (options.limit) params.limit = options.limit;
|
|
2587
|
+
if (options.threshold) params.threshold = options.threshold;
|
|
2588
|
+
return this.client.get(`/search/${entity}`, params);
|
|
2589
|
+
}
|
|
2590
|
+
/**
|
|
2591
|
+
* Index entity records for vector search
|
|
2592
|
+
*
|
|
2593
|
+
* @param options - Index options
|
|
2594
|
+
* @returns Index result
|
|
2595
|
+
*
|
|
2596
|
+
* @example
|
|
2597
|
+
* ```typescript
|
|
2598
|
+
* // Index all products
|
|
2599
|
+
* const result = await backflow.search.index({ entity: 'products' });
|
|
2600
|
+
* console.log(`Indexed ${result.indexed} records in ${result.latency}ms`);
|
|
2601
|
+
*
|
|
2602
|
+
* // Index specific records
|
|
2603
|
+
* await backflow.search.index({
|
|
2604
|
+
* entity: 'products',
|
|
2605
|
+
* ids: ['prod_123', 'prod_456'],
|
|
2606
|
+
* batchSize: 50
|
|
2607
|
+
* });
|
|
2608
|
+
* ```
|
|
2609
|
+
*/
|
|
2610
|
+
async index(options) {
|
|
2611
|
+
return this.client.post("/search/index", options);
|
|
2612
|
+
}
|
|
2613
|
+
/**
|
|
2614
|
+
* Delete and reindex all records for an entity
|
|
2615
|
+
*
|
|
2616
|
+
* @param options - Reindex options
|
|
2617
|
+
* @returns Reindex result
|
|
2618
|
+
*
|
|
2619
|
+
* @example
|
|
2620
|
+
* ```typescript
|
|
2621
|
+
* // Reindex all products
|
|
2622
|
+
* const result = await backflow.search.reindex({ entity: 'products' });
|
|
2623
|
+
* console.log(`Deleted ${result.deleted}, indexed ${result.indexed}`);
|
|
2624
|
+
* ```
|
|
2625
|
+
*/
|
|
2626
|
+
async reindex(options) {
|
|
2627
|
+
return this.client.post("/search/reindex", options);
|
|
2628
|
+
}
|
|
2629
|
+
/**
|
|
2630
|
+
* Delete all indexed records for an entity
|
|
2631
|
+
*
|
|
2632
|
+
* @param entity - Entity name
|
|
2633
|
+
* @returns Delete result
|
|
2634
|
+
*
|
|
2635
|
+
* @example
|
|
2636
|
+
* ```typescript
|
|
2637
|
+
* await backflow.search.delete('products');
|
|
2638
|
+
* ```
|
|
2639
|
+
*/
|
|
2640
|
+
async delete(entity) {
|
|
2641
|
+
return this.client.delete(`/search/index/${entity}`);
|
|
2642
|
+
}
|
|
2643
|
+
/**
|
|
2644
|
+
* Get search statistics
|
|
2645
|
+
*
|
|
2646
|
+
* @returns Search configuration stats
|
|
2647
|
+
*
|
|
2648
|
+
* @example
|
|
2649
|
+
* ```typescript
|
|
2650
|
+
* const stats = await backflow.search.stats();
|
|
2651
|
+
* console.log('Configured entities:', stats.configuredEntities);
|
|
2652
|
+
* console.log('Default mode:', stats.defaultMode);
|
|
2653
|
+
* ```
|
|
2654
|
+
*/
|
|
2655
|
+
async stats() {
|
|
2656
|
+
return this.client.get("/search/stats");
|
|
2657
|
+
}
|
|
2658
|
+
};
|
|
2659
|
+
|
|
2660
|
+
// src/resources/tenant.ts
|
|
2661
|
+
var TenantResource = class {
|
|
2662
|
+
constructor(client) {
|
|
2663
|
+
this.client = client;
|
|
2664
|
+
}
|
|
2665
|
+
async getInfo() {
|
|
2666
|
+
return this.client.get("/tenant/info");
|
|
2667
|
+
}
|
|
2668
|
+
async getConfig() {
|
|
2669
|
+
return this.client.get(
|
|
2670
|
+
"/tenant/config"
|
|
2671
|
+
);
|
|
2672
|
+
}
|
|
2673
|
+
async updateConfig(config) {
|
|
2674
|
+
return this.client.put(
|
|
2675
|
+
"/tenant/config",
|
|
2676
|
+
config
|
|
2677
|
+
);
|
|
2678
|
+
}
|
|
2679
|
+
async getUsage() {
|
|
2680
|
+
return this.client.get("/tenant/usage");
|
|
2681
|
+
}
|
|
2682
|
+
async getId() {
|
|
2683
|
+
const info = await this.getInfo();
|
|
2684
|
+
return info.id;
|
|
2685
|
+
}
|
|
2686
|
+
};
|
|
2687
|
+
|
|
2688
|
+
// src/sdk.ts
|
|
2689
|
+
var IntegrationsResource = class {
|
|
2690
|
+
constructor(client) {
|
|
2691
|
+
this.client = client;
|
|
2692
|
+
this.stripe = new StripeResource(client);
|
|
2693
|
+
this.polar = new PolarResource(client);
|
|
2694
|
+
}
|
|
2695
|
+
};
|
|
2696
|
+
var BackflowSDK = class {
|
|
2697
|
+
constructor(config) {
|
|
2698
|
+
this.client = new BackflowClient(config);
|
|
2699
|
+
this.agentAnalysis = new AgentAnalysisResource(this.client);
|
|
2700
|
+
this.assets = new AssetsResource(this.client);
|
|
2701
|
+
this.batch = new BatchResource(this.client);
|
|
2702
|
+
this.cache = new CacheResource(this.client);
|
|
2703
|
+
this.default = new DefaultResource(this.client);
|
|
2704
|
+
this.deployment = new DeploymentResource(this.client);
|
|
2705
|
+
this.feedback = new FeedbackResource(this.client);
|
|
2706
|
+
this.goals = new GoalsResource(this.client);
|
|
2707
|
+
this.googleDrive = new GoogleDriveResource(this.client);
|
|
2708
|
+
this.jira = new JiraResource(this.client);
|
|
2709
|
+
this.llm = new LlmResource(this.client);
|
|
2710
|
+
this.mcptools = new McpToolsResource(this.client);
|
|
2711
|
+
this.projects = new ProjectsResource(this.client);
|
|
2712
|
+
this.publish = new PublishResource(this.client);
|
|
2713
|
+
this.teams = new TeamsResource(this.client);
|
|
2714
|
+
this.tenantWebhookReceivers = new TenantWebhookReceiversResource(this.client);
|
|
2715
|
+
this.tenantWebhooks = new TenantWebhooksResource(this.client);
|
|
2716
|
+
this.tooldiscovery = new ToolDiscoveryResource(this.client);
|
|
2717
|
+
this.tracking = new TrackingResource(this.client);
|
|
2718
|
+
this.twitter = new TwitterResource(this.client);
|
|
2719
|
+
this.websocket = new WebsocketResource(this.client);
|
|
2720
|
+
this.workspaces = new WorkspacesResource(this.client);
|
|
2721
|
+
this.integrations = new IntegrationsResource(this.client);
|
|
2722
|
+
this.files = new FilesResource2(this.client);
|
|
2723
|
+
this.workflows = new WorkflowsResource2(this.client);
|
|
2724
|
+
this.embeddings = new EmbeddingsResource2(this.client);
|
|
2725
|
+
this.usage = new UsageResource2(this.client);
|
|
2726
|
+
this.analytics = new AnalyticsResource2(this.client);
|
|
2727
|
+
this.github = new GithubResource2(this.client);
|
|
2728
|
+
this.queues = new QueuesResource2(this.client);
|
|
2729
|
+
this.search = new SearchResource2(this.client);
|
|
2730
|
+
this.ai = new AIResource(this.client);
|
|
2731
|
+
this.collaboration = new CollaborationResource(this.client);
|
|
2732
|
+
this.webhooks = (projectId) => new WebhooksFactory(this.client).for(projectId);
|
|
2733
|
+
this.exports = new ExportsResource(this.client);
|
|
2734
|
+
this.user = new UserResource(this.client);
|
|
2735
|
+
this.tenant = new TenantResource(this.client);
|
|
2736
|
+
this.entities = new EntitiesResource(this.client);
|
|
2737
|
+
}
|
|
2738
|
+
get endpoint() {
|
|
2739
|
+
return this.client.endpoint;
|
|
2740
|
+
}
|
|
2741
|
+
get(path, params) {
|
|
2742
|
+
return this.client.get(path, params);
|
|
2743
|
+
}
|
|
2744
|
+
post(path, data, params) {
|
|
2745
|
+
return this.client.post(path, data, params);
|
|
2746
|
+
}
|
|
2747
|
+
put(path, data, params) {
|
|
2748
|
+
return this.client.put(path, data, params);
|
|
2749
|
+
}
|
|
2750
|
+
patch(path, data, params) {
|
|
2751
|
+
return this.client.patch(path, data, params);
|
|
2752
|
+
}
|
|
2753
|
+
delete(path, params) {
|
|
2754
|
+
return this.client.delete(path, params);
|
|
2755
|
+
}
|
|
2756
|
+
};
|
|
2757
|
+
function createBackflow(config) {
|
|
2758
|
+
return new BackflowSDK(config);
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
// src/docs.ts
|
|
2762
|
+
function getSDKDocs() {
|
|
2763
|
+
return `
|
|
2764
|
+
## @backflow/sdk Methods
|
|
2765
|
+
|
|
2766
|
+
Use the sdk: prefix in component actions to call SDK methods.
|
|
2767
|
+
Example: dataSource: "sdk:entities.list('products')"
|
|
2768
|
+
|
|
2769
|
+
### Entities (bf.entities)
|
|
2770
|
+
CRUD operations on database collections.
|
|
2771
|
+
|
|
2772
|
+
- list(collection, options?) \u2192 Promise<{data: Entity[], count?: number}>
|
|
2773
|
+
Options: { limit?: number, offset?: number, includeDeleted?: boolean }
|
|
2774
|
+
Example: sdk:entities.list('users', {limit: 10})
|
|
2775
|
+
|
|
2776
|
+
- get(collection, id) \u2192 Promise<Entity>
|
|
2777
|
+
Example: sdk:entities.get('users', '{{userId}}')
|
|
2778
|
+
|
|
2779
|
+
- create(collection, data) \u2192 Promise<Entity>
|
|
2780
|
+
Example: sdk:entities.create('orders', formData)
|
|
2781
|
+
|
|
2782
|
+
- update(collection, id, data) \u2192 Promise<Entity>
|
|
2783
|
+
Example: sdk:entities.update('users', '{{userId}}', formData)
|
|
2784
|
+
|
|
2785
|
+
- delete(collection, id, options?) \u2192 Promise<{success: boolean}>
|
|
2786
|
+
Options: { hard?: boolean }
|
|
2787
|
+
Example: sdk:entities.delete('orders', '{{orderId}}')
|
|
2788
|
+
|
|
2789
|
+
- getSchema() \u2192 Promise<CollectionSchema[]>
|
|
2790
|
+
Get schema for all collections
|
|
2791
|
+
|
|
2792
|
+
### WebSocket (bf.websocket)
|
|
2793
|
+
Real-time subscriptions and messaging.
|
|
2794
|
+
|
|
2795
|
+
- connect(options?) \u2192 Promise<void>
|
|
2796
|
+
Establish WebSocket connection
|
|
2797
|
+
|
|
2798
|
+
- subscribe(channel, callback) \u2192 UnsubscribeFn
|
|
2799
|
+
Example: sdk:websocket.subscribe('orders:{{userId}}', onOrderUpdate)
|
|
2800
|
+
|
|
2801
|
+
- publish(channel, data) \u2192 void
|
|
2802
|
+
Example: sdk:websocket.publish('notifications', {type: 'alert', message: '...'})
|
|
2803
|
+
|
|
2804
|
+
### Workflows (bf.workflows)
|
|
2805
|
+
Trigger backend automation.
|
|
2806
|
+
|
|
2807
|
+
- trigger(workflowId, input?) \u2192 Promise<{success: boolean, data?: any}>
|
|
2808
|
+
Example: sdk:workflows.trigger('send-welcome-email', {userId: '{{userId}}'})
|
|
2809
|
+
|
|
2810
|
+
- list() \u2192 Promise<Workflow[]>
|
|
2811
|
+
Get available workflows
|
|
2812
|
+
|
|
2813
|
+
### Files (bf.files)
|
|
2814
|
+
File upload and storage.
|
|
2815
|
+
|
|
2816
|
+
- upload(file, options?) \u2192 Promise<{url: string, key: string}>
|
|
2817
|
+
Options: { path?: string, public?: boolean }
|
|
2818
|
+
|
|
2819
|
+
- list(prefix?) \u2192 Promise<FileInfo[]>
|
|
2820
|
+
List files in storage
|
|
2821
|
+
|
|
2822
|
+
- getUrl(key) \u2192 Promise<string>
|
|
2823
|
+
Get download URL for a file
|
|
2824
|
+
|
|
2825
|
+
### Cache (bf.cache)
|
|
2826
|
+
Key-value caching.
|
|
2827
|
+
|
|
2828
|
+
- get(key) \u2192 Promise<any>
|
|
2829
|
+
- set(key, value, ttl?) \u2192 Promise<void>
|
|
2830
|
+
- delete(key) \u2192 Promise<void>
|
|
2831
|
+
|
|
2832
|
+
### Search (bf.search)
|
|
2833
|
+
Full-text search across entities.
|
|
2834
|
+
|
|
2835
|
+
- query(collection, query, options?) \u2192 Promise<SearchResult[]>
|
|
2836
|
+
Options: { limit?: number, fields?: string[] }
|
|
2837
|
+
|
|
2838
|
+
### Queues (bf.queues)
|
|
2839
|
+
Background job processing.
|
|
2840
|
+
|
|
2841
|
+
- push(queueName, data) \u2192 Promise<{jobId: string}>
|
|
2842
|
+
Example: sdk:queues.push('email-queue', {to: '{{email}}', template: 'welcome'})
|
|
2843
|
+
|
|
2844
|
+
### Pagination
|
|
2845
|
+
List operations support automatic pagination via limit/offset.
|
|
2846
|
+
Response includes count for total items.
|
|
2847
|
+
|
|
2848
|
+
Component props:
|
|
2849
|
+
- pagination: boolean (default: true) - show Previous/Next controls
|
|
2850
|
+
- pageSize: number (default: 10) - items per page
|
|
2851
|
+
|
|
2852
|
+
Example:
|
|
2853
|
+
{"type": "list", "dataSource": "sdk:entities.list('orders')", "pageSize": 20}
|
|
2854
|
+
{"type": "table", "dataSource": "sdk:entities.list('users')", "pagination": true}
|
|
2855
|
+
`;
|
|
2856
|
+
}
|
|
2857
|
+
function getSDKDocsCompact() {
|
|
2858
|
+
return `
|
|
2859
|
+
SDK METHODS (use sdk: prefix):
|
|
2860
|
+
|
|
2861
|
+
ENTITIES:
|
|
2862
|
+
sdk:entities.list('collection', {limit?, offset?})
|
|
2863
|
+
sdk:entities.get('collection', 'id')
|
|
2864
|
+
sdk:entities.create('collection', data)
|
|
2865
|
+
sdk:entities.update('collection', 'id', data)
|
|
2866
|
+
sdk:entities.delete('collection', 'id')
|
|
2867
|
+
|
|
2868
|
+
WEBSOCKET:
|
|
2869
|
+
sdk:websocket.subscribe('channel', callback)
|
|
2870
|
+
sdk:websocket.publish('channel', data)
|
|
2871
|
+
|
|
2872
|
+
WORKFLOWS:
|
|
2873
|
+
sdk:workflows.trigger('workflowId', input)
|
|
2874
|
+
|
|
2875
|
+
FILES:
|
|
2876
|
+
sdk:files.upload(file, {path?, public?})
|
|
2877
|
+
|
|
2878
|
+
QUEUES:
|
|
2879
|
+
sdk:queues.push('queueName', data)
|
|
2880
|
+
|
|
2881
|
+
PAGINATION (auto-handled by renderer):
|
|
2882
|
+
list/table props: pagination (true), pageSize (10)
|
|
2883
|
+
Response includes count for total items
|
|
2884
|
+
`;
|
|
2885
|
+
}
|
|
2886
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2887
|
+
0 && (module.exports = {
|
|
2888
|
+
AgentAnalysisResource,
|
|
2889
|
+
AnalyticsResource,
|
|
2890
|
+
AssetsResource,
|
|
2891
|
+
Backflow,
|
|
2892
|
+
BackflowClient,
|
|
2893
|
+
BackflowSDK,
|
|
2894
|
+
BatchResource,
|
|
2895
|
+
CACHE_OPERATIONS,
|
|
2896
|
+
CHUNKING_STRATEGIES,
|
|
2897
|
+
CLI_PROVIDERS,
|
|
2898
|
+
CONDITION_OPERATORS,
|
|
2899
|
+
CacheResource,
|
|
2900
|
+
DB_OPERATIONS,
|
|
2901
|
+
DB_PROVIDERS,
|
|
2902
|
+
DefaultResource,
|
|
2903
|
+
DeploymentResource,
|
|
2904
|
+
EmbeddingsResource,
|
|
2905
|
+
FeedbackResource,
|
|
2906
|
+
FilesResource,
|
|
2907
|
+
GithubResource,
|
|
2908
|
+
GoalsResource,
|
|
2909
|
+
GoogleDriveResource,
|
|
2910
|
+
HTTP_METHODS,
|
|
2911
|
+
IMAGE_DETAILS,
|
|
2912
|
+
JiraResource,
|
|
2913
|
+
LLM_PROVIDERS,
|
|
2914
|
+
LlmResource,
|
|
2915
|
+
McpToolsResource,
|
|
2916
|
+
NOTIFY_CHANNELS,
|
|
2917
|
+
NOTIFY_PRIORITIES,
|
|
2918
|
+
PolarResource,
|
|
2919
|
+
ProjectsResource,
|
|
2920
|
+
PublishResource,
|
|
2921
|
+
QueuesResource,
|
|
2922
|
+
RAG_MODES,
|
|
2923
|
+
STORAGE_OPERATIONS,
|
|
2924
|
+
SearchResource,
|
|
2925
|
+
StripeResource,
|
|
2926
|
+
TOOL_PARAM_CONTEXT,
|
|
2927
|
+
TOOL_TYPES,
|
|
2928
|
+
TRIGGER_TYPES,
|
|
2929
|
+
TeamsResource,
|
|
2930
|
+
TenantWebhookReceiversResource,
|
|
2931
|
+
TenantWebhooksResource,
|
|
2932
|
+
ToolDiscoveryResource,
|
|
2933
|
+
TrackingResource,
|
|
2934
|
+
TwitterResource,
|
|
2935
|
+
UsageResource,
|
|
2936
|
+
WORKFLOW_VALIDATION_SCHEMA,
|
|
2937
|
+
WebsocketResource,
|
|
2938
|
+
WorkflowsResource,
|
|
2939
|
+
WorkspacesResource,
|
|
2940
|
+
createBackflow,
|
|
2941
|
+
getSDKDocs,
|
|
2942
|
+
getSDKDocsCompact,
|
|
2943
|
+
toCompactContext,
|
|
2944
|
+
toPromptContext
|
|
2945
|
+
});
|