@stack0/sdk 0.5.8 → 0.5.9
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 +1026 -369
- package/dist/cdn/index.d.mts +316 -1
- package/dist/cdn/index.d.ts +316 -1
- package/dist/cdn/index.js +219 -0
- package/dist/cdn/index.js.map +1 -1
- package/dist/cdn/index.mjs +219 -0
- package/dist/cdn/index.mjs.map +1 -1
- package/dist/index.d.mts +760 -3
- package/dist/index.d.ts +760 -3
- package/dist/index.js +757 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +753 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -6
package/dist/index.mjs
CHANGED
|
@@ -959,6 +959,27 @@ var CDN = class {
|
|
|
959
959
|
}
|
|
960
960
|
return this.confirmUpload(assetId);
|
|
961
961
|
}
|
|
962
|
+
/**
|
|
963
|
+
* Upload a file from a remote URL (server-side fetch).
|
|
964
|
+
* The server streams the file directly from the source URL into storage,
|
|
965
|
+
* so the client never touches the bytes. Ideal for serverless environments
|
|
966
|
+
* with tight memory limits.
|
|
967
|
+
*
|
|
968
|
+
* @example
|
|
969
|
+
* ```typescript
|
|
970
|
+
* const asset = await cdn.uploadFromUrl({
|
|
971
|
+
* projectSlug: 'my-project',
|
|
972
|
+
* sourceUrl: 'https://replicate.delivery/output/video.mp4',
|
|
973
|
+
* filename: 'video.mp4',
|
|
974
|
+
* mimeType: 'video/mp4',
|
|
975
|
+
* });
|
|
976
|
+
* console.log(asset.cdnUrl);
|
|
977
|
+
* ```
|
|
978
|
+
*/
|
|
979
|
+
async uploadFromUrl(request) {
|
|
980
|
+
const response = await this.http.post("/cdn/upload-from-url", request);
|
|
981
|
+
return this.convertAssetDates(response);
|
|
982
|
+
}
|
|
962
983
|
/**
|
|
963
984
|
* Get an asset by ID
|
|
964
985
|
*
|
|
@@ -2011,6 +2032,204 @@ var CDN = class {
|
|
|
2011
2032
|
convertMergeJobWithOutputDates(job) {
|
|
2012
2033
|
return this.convertMergeJobDates(job);
|
|
2013
2034
|
}
|
|
2035
|
+
// ============================================================================
|
|
2036
|
+
// S3 Import Methods
|
|
2037
|
+
// ============================================================================
|
|
2038
|
+
/**
|
|
2039
|
+
* Create an S3 import job to bulk import files from an external S3 bucket.
|
|
2040
|
+
* Requires Pro plan or higher.
|
|
2041
|
+
*
|
|
2042
|
+
* @example
|
|
2043
|
+
* ```typescript
|
|
2044
|
+
* // Using IAM credentials
|
|
2045
|
+
* const job = await cdn.createImport({
|
|
2046
|
+
* projectSlug: 'my-project',
|
|
2047
|
+
* sourceBucket: 'my-external-bucket',
|
|
2048
|
+
* sourceRegion: 'us-east-1',
|
|
2049
|
+
* sourcePrefix: 'images/',
|
|
2050
|
+
* authType: 'iam_credentials',
|
|
2051
|
+
* accessKeyId: 'AKIA...',
|
|
2052
|
+
* secretAccessKey: 'secret...',
|
|
2053
|
+
* pathMode: 'flatten',
|
|
2054
|
+
* notifyEmail: 'admin@example.com',
|
|
2055
|
+
* });
|
|
2056
|
+
*
|
|
2057
|
+
* // Using role assumption
|
|
2058
|
+
* const job = await cdn.createImport({
|
|
2059
|
+
* projectSlug: 'my-project',
|
|
2060
|
+
* sourceBucket: 'partner-bucket',
|
|
2061
|
+
* sourceRegion: 'eu-west-1',
|
|
2062
|
+
* authType: 'role_assumption',
|
|
2063
|
+
* roleArn: 'arn:aws:iam::123456789012:role/Stack0ImportRole',
|
|
2064
|
+
* externalId: 'optional-external-id',
|
|
2065
|
+
* pathMode: 'preserve',
|
|
2066
|
+
* targetFolder: '/imported',
|
|
2067
|
+
* });
|
|
2068
|
+
*
|
|
2069
|
+
* console.log(`Import job started: ${job.importId}`);
|
|
2070
|
+
* ```
|
|
2071
|
+
*/
|
|
2072
|
+
async createImport(request) {
|
|
2073
|
+
const response = await this.http.post("/cdn/imports", request);
|
|
2074
|
+
return this.convertCreateImportDates(response);
|
|
2075
|
+
}
|
|
2076
|
+
/**
|
|
2077
|
+
* Get an import job by ID
|
|
2078
|
+
*
|
|
2079
|
+
* @example
|
|
2080
|
+
* ```typescript
|
|
2081
|
+
* const job = await cdn.getImport('import-id');
|
|
2082
|
+
* console.log(`Status: ${job.status}`);
|
|
2083
|
+
* console.log(`Progress: ${job.processedFiles}/${job.totalFiles} files`);
|
|
2084
|
+
* console.log(`Bytes: ${job.processedBytes}/${job.totalBytes}`);
|
|
2085
|
+
* ```
|
|
2086
|
+
*/
|
|
2087
|
+
async getImport(importId) {
|
|
2088
|
+
const response = await this.http.get(`/cdn/imports/${importId}`);
|
|
2089
|
+
return response ? this.convertImportJobDates(response) : null;
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* List import jobs with pagination and filters
|
|
2093
|
+
*
|
|
2094
|
+
* @example
|
|
2095
|
+
* ```typescript
|
|
2096
|
+
* const { imports, total, hasMore } = await cdn.listImports({
|
|
2097
|
+
* projectSlug: 'my-project',
|
|
2098
|
+
* status: 'importing',
|
|
2099
|
+
* limit: 20,
|
|
2100
|
+
* });
|
|
2101
|
+
*
|
|
2102
|
+
* for (const job of imports) {
|
|
2103
|
+
* console.log(`${job.sourceBucket}: ${job.processedFiles}/${job.totalFiles}`);
|
|
2104
|
+
* }
|
|
2105
|
+
* ```
|
|
2106
|
+
*/
|
|
2107
|
+
async listImports(request) {
|
|
2108
|
+
const params = new URLSearchParams();
|
|
2109
|
+
params.set("projectSlug", request.projectSlug);
|
|
2110
|
+
if (request.environment) params.set("environment", request.environment);
|
|
2111
|
+
if (request.status) params.set("status", request.status);
|
|
2112
|
+
if (request.sortBy) params.set("sortBy", request.sortBy);
|
|
2113
|
+
if (request.sortOrder) params.set("sortOrder", request.sortOrder);
|
|
2114
|
+
if (request.limit) params.set("limit", request.limit.toString());
|
|
2115
|
+
if (request.offset) params.set("offset", request.offset.toString());
|
|
2116
|
+
const response = await this.http.get(`/cdn/imports?${params.toString()}`);
|
|
2117
|
+
return {
|
|
2118
|
+
...response,
|
|
2119
|
+
imports: response.imports.map((job) => this.convertImportJobSummaryDates(job))
|
|
2120
|
+
};
|
|
2121
|
+
}
|
|
2122
|
+
/**
|
|
2123
|
+
* Cancel a running import job
|
|
2124
|
+
*
|
|
2125
|
+
* Files already imported will remain. Only pending/validating/importing jobs can be cancelled.
|
|
2126
|
+
*
|
|
2127
|
+
* @example
|
|
2128
|
+
* ```typescript
|
|
2129
|
+
* const result = await cdn.cancelImport('import-id');
|
|
2130
|
+
* console.log(`Cancelled: ${result.success}`);
|
|
2131
|
+
* ```
|
|
2132
|
+
*/
|
|
2133
|
+
async cancelImport(importId) {
|
|
2134
|
+
return this.http.post(`/cdn/imports/${importId}/cancel`, {});
|
|
2135
|
+
}
|
|
2136
|
+
/**
|
|
2137
|
+
* Retry failed files in a completed or failed import job
|
|
2138
|
+
*
|
|
2139
|
+
* This resets failed files to pending and re-queues the import for processing.
|
|
2140
|
+
*
|
|
2141
|
+
* @example
|
|
2142
|
+
* ```typescript
|
|
2143
|
+
* const result = await cdn.retryImport('import-id');
|
|
2144
|
+
* console.log(`Retrying ${result.retriedCount} files`);
|
|
2145
|
+
* ```
|
|
2146
|
+
*/
|
|
2147
|
+
async retryImport(importId) {
|
|
2148
|
+
return this.http.post(`/cdn/imports/${importId}/retry`, {});
|
|
2149
|
+
}
|
|
2150
|
+
/**
|
|
2151
|
+
* List files in an import job with optional status filter
|
|
2152
|
+
*
|
|
2153
|
+
* @example
|
|
2154
|
+
* ```typescript
|
|
2155
|
+
* // List all files
|
|
2156
|
+
* const { files, total } = await cdn.listImportFiles({
|
|
2157
|
+
* importId: 'import-id',
|
|
2158
|
+
* limit: 100,
|
|
2159
|
+
* });
|
|
2160
|
+
*
|
|
2161
|
+
* // List only failed files
|
|
2162
|
+
* const { files: failedFiles } = await cdn.listImportFiles({
|
|
2163
|
+
* importId: 'import-id',
|
|
2164
|
+
* status: 'failed',
|
|
2165
|
+
* });
|
|
2166
|
+
*
|
|
2167
|
+
* for (const file of failedFiles) {
|
|
2168
|
+
* console.log(`${file.sourceKey}: ${file.errorMessage}`);
|
|
2169
|
+
* }
|
|
2170
|
+
* ```
|
|
2171
|
+
*/
|
|
2172
|
+
async listImportFiles(request) {
|
|
2173
|
+
const params = new URLSearchParams();
|
|
2174
|
+
if (request.status) params.set("status", request.status);
|
|
2175
|
+
if (request.sortBy) params.set("sortBy", request.sortBy);
|
|
2176
|
+
if (request.sortOrder) params.set("sortOrder", request.sortOrder);
|
|
2177
|
+
if (request.limit) params.set("limit", request.limit.toString());
|
|
2178
|
+
if (request.offset) params.set("offset", request.offset.toString());
|
|
2179
|
+
const query = params.toString();
|
|
2180
|
+
const response = await this.http.get(
|
|
2181
|
+
`/cdn/imports/${request.importId}/files${query ? `?${query}` : ""}`
|
|
2182
|
+
);
|
|
2183
|
+
return {
|
|
2184
|
+
...response,
|
|
2185
|
+
files: response.files.map((file) => this.convertImportFileDates(file))
|
|
2186
|
+
};
|
|
2187
|
+
}
|
|
2188
|
+
convertCreateImportDates(response) {
|
|
2189
|
+
if (typeof response.createdAt === "string") {
|
|
2190
|
+
response.createdAt = new Date(response.createdAt);
|
|
2191
|
+
}
|
|
2192
|
+
return response;
|
|
2193
|
+
}
|
|
2194
|
+
convertImportJobDates(job) {
|
|
2195
|
+
if (typeof job.createdAt === "string") {
|
|
2196
|
+
job.createdAt = new Date(job.createdAt);
|
|
2197
|
+
}
|
|
2198
|
+
if (job.updatedAt && typeof job.updatedAt === "string") {
|
|
2199
|
+
job.updatedAt = new Date(job.updatedAt);
|
|
2200
|
+
}
|
|
2201
|
+
if (job.startedAt && typeof job.startedAt === "string") {
|
|
2202
|
+
job.startedAt = new Date(job.startedAt);
|
|
2203
|
+
}
|
|
2204
|
+
if (job.completedAt && typeof job.completedAt === "string") {
|
|
2205
|
+
job.completedAt = new Date(job.completedAt);
|
|
2206
|
+
}
|
|
2207
|
+
return job;
|
|
2208
|
+
}
|
|
2209
|
+
convertImportJobSummaryDates(job) {
|
|
2210
|
+
if (typeof job.createdAt === "string") {
|
|
2211
|
+
job.createdAt = new Date(job.createdAt);
|
|
2212
|
+
}
|
|
2213
|
+
if (job.startedAt && typeof job.startedAt === "string") {
|
|
2214
|
+
job.startedAt = new Date(job.startedAt);
|
|
2215
|
+
}
|
|
2216
|
+
if (job.completedAt && typeof job.completedAt === "string") {
|
|
2217
|
+
job.completedAt = new Date(job.completedAt);
|
|
2218
|
+
}
|
|
2219
|
+
return job;
|
|
2220
|
+
}
|
|
2221
|
+
convertImportFileDates(file) {
|
|
2222
|
+
if (typeof file.createdAt === "string") {
|
|
2223
|
+
file.createdAt = new Date(file.createdAt);
|
|
2224
|
+
}
|
|
2225
|
+
if (file.completedAt && typeof file.completedAt === "string") {
|
|
2226
|
+
file.completedAt = new Date(file.completedAt);
|
|
2227
|
+
}
|
|
2228
|
+
if (file.lastAttemptAt && typeof file.lastAttemptAt === "string") {
|
|
2229
|
+
file.lastAttemptAt = new Date(file.lastAttemptAt);
|
|
2230
|
+
}
|
|
2231
|
+
return file;
|
|
2232
|
+
}
|
|
2014
2233
|
};
|
|
2015
2234
|
|
|
2016
2235
|
// src/screenshots/client.ts
|
|
@@ -4617,6 +4836,535 @@ var Marketing = class {
|
|
|
4617
4836
|
}
|
|
4618
4837
|
};
|
|
4619
4838
|
|
|
4839
|
+
// src/workflows/client.ts
|
|
4840
|
+
var Workflows = class {
|
|
4841
|
+
http;
|
|
4842
|
+
constructor(config) {
|
|
4843
|
+
this.http = new HttpClient(config);
|
|
4844
|
+
}
|
|
4845
|
+
// ==========================================================================
|
|
4846
|
+
// WORKFLOW CRUD
|
|
4847
|
+
// ==========================================================================
|
|
4848
|
+
/**
|
|
4849
|
+
* Create a new workflow
|
|
4850
|
+
*
|
|
4851
|
+
* @example
|
|
4852
|
+
* ```typescript
|
|
4853
|
+
* const workflow = await workflows.create({
|
|
4854
|
+
* slug: 'content-pipeline',
|
|
4855
|
+
* name: 'Content Generation Pipeline',
|
|
4856
|
+
* steps: [
|
|
4857
|
+
* {
|
|
4858
|
+
* id: 'generate',
|
|
4859
|
+
* name: 'Generate Content',
|
|
4860
|
+
* type: 'llm',
|
|
4861
|
+
* provider: 'anthropic',
|
|
4862
|
+
* model: 'claude-sonnet-4-20250514',
|
|
4863
|
+
* config: {
|
|
4864
|
+
* prompt: 'Write a blog post about {{topic}}',
|
|
4865
|
+
* maxTokens: 2000,
|
|
4866
|
+
* },
|
|
4867
|
+
* },
|
|
4868
|
+
* ],
|
|
4869
|
+
* variables: [
|
|
4870
|
+
* { name: 'topic', type: 'string', required: true },
|
|
4871
|
+
* ],
|
|
4872
|
+
* });
|
|
4873
|
+
* ```
|
|
4874
|
+
*/
|
|
4875
|
+
async create(request) {
|
|
4876
|
+
return this.http.post("/workflows/workflows", request);
|
|
4877
|
+
}
|
|
4878
|
+
/**
|
|
4879
|
+
* Get a workflow by ID or slug
|
|
4880
|
+
*
|
|
4881
|
+
* @example
|
|
4882
|
+
* ```typescript
|
|
4883
|
+
* const workflow = await workflows.get({ slug: 'content-pipeline' });
|
|
4884
|
+
* console.log(workflow.steps);
|
|
4885
|
+
* ```
|
|
4886
|
+
*/
|
|
4887
|
+
async get(request) {
|
|
4888
|
+
const params = new URLSearchParams();
|
|
4889
|
+
if (request.slug) params.set("slug", request.slug);
|
|
4890
|
+
if (request.environment) params.set("environment", request.environment);
|
|
4891
|
+
if (request.projectSlug) params.set("projectSlug", request.projectSlug);
|
|
4892
|
+
const path = request.id ? `/workflows/workflows/${request.id}` : `/workflows/workflows?${params.toString()}`;
|
|
4893
|
+
const response = await this.http.get(path);
|
|
4894
|
+
return this.convertDates(response);
|
|
4895
|
+
}
|
|
4896
|
+
/**
|
|
4897
|
+
* List workflows with pagination
|
|
4898
|
+
*
|
|
4899
|
+
* @example
|
|
4900
|
+
* ```typescript
|
|
4901
|
+
* const { items, nextCursor } = await workflows.list({
|
|
4902
|
+
* environment: 'production',
|
|
4903
|
+
* isActive: true,
|
|
4904
|
+
* limit: 20,
|
|
4905
|
+
* });
|
|
4906
|
+
* ```
|
|
4907
|
+
*/
|
|
4908
|
+
async list(request = {}) {
|
|
4909
|
+
const params = new URLSearchParams();
|
|
4910
|
+
if (request.projectSlug) params.set("projectSlug", request.projectSlug);
|
|
4911
|
+
if (request.environment) params.set("environment", request.environment);
|
|
4912
|
+
if (request.isActive !== void 0) params.set("isActive", request.isActive.toString());
|
|
4913
|
+
if (request.limit) params.set("limit", request.limit.toString());
|
|
4914
|
+
if (request.cursor) params.set("cursor", request.cursor);
|
|
4915
|
+
const query = params.toString();
|
|
4916
|
+
const response = await this.http.get(
|
|
4917
|
+
`/workflows/workflows${query ? `?${query}` : ""}`
|
|
4918
|
+
);
|
|
4919
|
+
return {
|
|
4920
|
+
...response,
|
|
4921
|
+
items: response.items.map((item) => this.convertDates(item))
|
|
4922
|
+
};
|
|
4923
|
+
}
|
|
4924
|
+
/**
|
|
4925
|
+
* Update a workflow
|
|
4926
|
+
*
|
|
4927
|
+
* @example
|
|
4928
|
+
* ```typescript
|
|
4929
|
+
* await workflows.update({
|
|
4930
|
+
* id: 'workflow-id',
|
|
4931
|
+
* name: 'Updated Pipeline',
|
|
4932
|
+
* isActive: false,
|
|
4933
|
+
* });
|
|
4934
|
+
* ```
|
|
4935
|
+
*/
|
|
4936
|
+
async update(request) {
|
|
4937
|
+
const { id, ...data } = request;
|
|
4938
|
+
return this.http.post(
|
|
4939
|
+
`/workflows/workflows/${id}`,
|
|
4940
|
+
data
|
|
4941
|
+
);
|
|
4942
|
+
}
|
|
4943
|
+
/**
|
|
4944
|
+
* Delete a workflow
|
|
4945
|
+
*
|
|
4946
|
+
* @example
|
|
4947
|
+
* ```typescript
|
|
4948
|
+
* await workflows.delete({ id: 'workflow-id' });
|
|
4949
|
+
* ```
|
|
4950
|
+
*/
|
|
4951
|
+
async delete(request) {
|
|
4952
|
+
return this.http.deleteWithBody(
|
|
4953
|
+
`/workflows/workflows/${request.id}`,
|
|
4954
|
+
request
|
|
4955
|
+
);
|
|
4956
|
+
}
|
|
4957
|
+
// ==========================================================================
|
|
4958
|
+
// WORKFLOW EXECUTION
|
|
4959
|
+
// ==========================================================================
|
|
4960
|
+
/**
|
|
4961
|
+
* Run a workflow
|
|
4962
|
+
*
|
|
4963
|
+
* @example
|
|
4964
|
+
* ```typescript
|
|
4965
|
+
* const run = await workflows.run({
|
|
4966
|
+
* workflowSlug: 'content-pipeline',
|
|
4967
|
+
* variables: {
|
|
4968
|
+
* topic: 'artificial intelligence',
|
|
4969
|
+
* },
|
|
4970
|
+
* webhook: {
|
|
4971
|
+
* url: 'https://example.com/webhook',
|
|
4972
|
+
* secret: 'webhook-secret',
|
|
4973
|
+
* },
|
|
4974
|
+
* });
|
|
4975
|
+
* console.log(run.id, run.status);
|
|
4976
|
+
* ```
|
|
4977
|
+
*/
|
|
4978
|
+
async run(request) {
|
|
4979
|
+
return this.http.post("/workflows/workflows/run", request);
|
|
4980
|
+
}
|
|
4981
|
+
/**
|
|
4982
|
+
* Get a workflow run by ID
|
|
4983
|
+
*
|
|
4984
|
+
* @example
|
|
4985
|
+
* ```typescript
|
|
4986
|
+
* const run = await workflows.getRun({ id: 'run-id' });
|
|
4987
|
+
* if (run.status === 'completed') {
|
|
4988
|
+
* console.log(run.output);
|
|
4989
|
+
* }
|
|
4990
|
+
* ```
|
|
4991
|
+
*/
|
|
4992
|
+
async getRun(request) {
|
|
4993
|
+
const params = new URLSearchParams();
|
|
4994
|
+
if (request.environment) params.set("environment", request.environment);
|
|
4995
|
+
if (request.projectSlug) params.set("projectSlug", request.projectSlug);
|
|
4996
|
+
const query = params.toString();
|
|
4997
|
+
const response = await this.http.get(
|
|
4998
|
+
`/workflows/workflows/runs/${request.id}${query ? `?${query}` : ""}`
|
|
4999
|
+
);
|
|
5000
|
+
return this.convertRunDates(response);
|
|
5001
|
+
}
|
|
5002
|
+
/**
|
|
5003
|
+
* List workflow runs with pagination
|
|
5004
|
+
*
|
|
5005
|
+
* @example
|
|
5006
|
+
* ```typescript
|
|
5007
|
+
* const { items } = await workflows.listRuns({
|
|
5008
|
+
* workflowId: 'workflow-id',
|
|
5009
|
+
* status: 'completed',
|
|
5010
|
+
* });
|
|
5011
|
+
* ```
|
|
5012
|
+
*/
|
|
5013
|
+
async listRuns(request = {}) {
|
|
5014
|
+
const params = new URLSearchParams();
|
|
5015
|
+
if (request.workflowId) params.set("workflowId", request.workflowId);
|
|
5016
|
+
if (request.workflowSlug) params.set("workflowSlug", request.workflowSlug);
|
|
5017
|
+
if (request.projectSlug) params.set("projectSlug", request.projectSlug);
|
|
5018
|
+
if (request.environment) params.set("environment", request.environment);
|
|
5019
|
+
if (request.status) params.set("status", request.status);
|
|
5020
|
+
if (request.limit) params.set("limit", request.limit.toString());
|
|
5021
|
+
if (request.cursor) params.set("cursor", request.cursor);
|
|
5022
|
+
const query = params.toString();
|
|
5023
|
+
const response = await this.http.get(
|
|
5024
|
+
`/workflows/workflows/runs${query ? `?${query}` : ""}`
|
|
5025
|
+
);
|
|
5026
|
+
return {
|
|
5027
|
+
...response,
|
|
5028
|
+
items: response.items.map((item) => this.convertRunDates(item))
|
|
5029
|
+
};
|
|
5030
|
+
}
|
|
5031
|
+
/**
|
|
5032
|
+
* Cancel a running workflow
|
|
5033
|
+
*
|
|
5034
|
+
* @example
|
|
5035
|
+
* ```typescript
|
|
5036
|
+
* await workflows.cancelRun({ id: 'run-id' });
|
|
5037
|
+
* ```
|
|
5038
|
+
*/
|
|
5039
|
+
async cancelRun(request) {
|
|
5040
|
+
return this.http.post(
|
|
5041
|
+
`/workflows/workflows/runs/${request.id}/cancel`,
|
|
5042
|
+
{}
|
|
5043
|
+
);
|
|
5044
|
+
}
|
|
5045
|
+
/**
|
|
5046
|
+
* Run a workflow and wait for completion
|
|
5047
|
+
*
|
|
5048
|
+
* @example
|
|
5049
|
+
* ```typescript
|
|
5050
|
+
* const run = await workflows.runAndWait({
|
|
5051
|
+
* workflowSlug: 'content-pipeline',
|
|
5052
|
+
* variables: { topic: 'AI' },
|
|
5053
|
+
* });
|
|
5054
|
+
* console.log(run.output);
|
|
5055
|
+
* ```
|
|
5056
|
+
*/
|
|
5057
|
+
async runAndWait(request, options = {}) {
|
|
5058
|
+
const { pollInterval = 2e3, timeout = 6e5 } = options;
|
|
5059
|
+
const startTime = Date.now();
|
|
5060
|
+
const { id } = await this.run(request);
|
|
5061
|
+
while (Date.now() - startTime < timeout) {
|
|
5062
|
+
const run = await this.getRun({
|
|
5063
|
+
id,
|
|
5064
|
+
environment: request.environment,
|
|
5065
|
+
projectSlug: request.projectSlug
|
|
5066
|
+
});
|
|
5067
|
+
if (run.status === "completed" || run.status === "failed" || run.status === "cancelled") {
|
|
5068
|
+
if (run.status === "failed") {
|
|
5069
|
+
throw new Error(run.error || "Workflow execution failed");
|
|
5070
|
+
}
|
|
5071
|
+
return run;
|
|
5072
|
+
}
|
|
5073
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
5074
|
+
}
|
|
5075
|
+
throw new Error("Workflow execution timed out");
|
|
5076
|
+
}
|
|
5077
|
+
// ==========================================================================
|
|
5078
|
+
// HELPERS
|
|
5079
|
+
// ==========================================================================
|
|
5080
|
+
convertDates(workflow) {
|
|
5081
|
+
if (typeof workflow.createdAt === "string") {
|
|
5082
|
+
workflow.createdAt = new Date(workflow.createdAt);
|
|
5083
|
+
}
|
|
5084
|
+
if (typeof workflow.updatedAt === "string") {
|
|
5085
|
+
workflow.updatedAt = new Date(workflow.updatedAt);
|
|
5086
|
+
}
|
|
5087
|
+
return workflow;
|
|
5088
|
+
}
|
|
5089
|
+
convertRunDates(run) {
|
|
5090
|
+
if (typeof run.createdAt === "string") {
|
|
5091
|
+
run.createdAt = new Date(run.createdAt);
|
|
5092
|
+
}
|
|
5093
|
+
if (run.startedAt && typeof run.startedAt === "string") {
|
|
5094
|
+
run.startedAt = new Date(run.startedAt);
|
|
5095
|
+
}
|
|
5096
|
+
if (run.completedAt && typeof run.completedAt === "string") {
|
|
5097
|
+
run.completedAt = new Date(run.completedAt);
|
|
5098
|
+
}
|
|
5099
|
+
return run;
|
|
5100
|
+
}
|
|
5101
|
+
};
|
|
5102
|
+
|
|
5103
|
+
// src/memory/agents.ts
|
|
5104
|
+
var MemoryAgents = class {
|
|
5105
|
+
constructor(http) {
|
|
5106
|
+
this.http = http;
|
|
5107
|
+
}
|
|
5108
|
+
/**
|
|
5109
|
+
* Create a new memory agent
|
|
5110
|
+
*/
|
|
5111
|
+
async create(request) {
|
|
5112
|
+
return this.http.post("/memory/agents", request);
|
|
5113
|
+
}
|
|
5114
|
+
/**
|
|
5115
|
+
* List all memory agents
|
|
5116
|
+
*/
|
|
5117
|
+
async list(params = {}) {
|
|
5118
|
+
const qs = new URLSearchParams();
|
|
5119
|
+
if (params.environment) qs.set("environment", params.environment);
|
|
5120
|
+
const q = qs.toString();
|
|
5121
|
+
return this.http.get(`/memory/agents${q ? `?${q}` : ""}`);
|
|
5122
|
+
}
|
|
5123
|
+
/**
|
|
5124
|
+
* Get a memory agent by ID
|
|
5125
|
+
*/
|
|
5126
|
+
async get(agentId) {
|
|
5127
|
+
return this.http.get(`/memory/agents/${agentId}`);
|
|
5128
|
+
}
|
|
5129
|
+
/**
|
|
5130
|
+
* Update a memory agent
|
|
5131
|
+
*/
|
|
5132
|
+
async update(agentId, request) {
|
|
5133
|
+
return this.http.patch(`/memory/agents/${agentId}`, request);
|
|
5134
|
+
}
|
|
5135
|
+
/**
|
|
5136
|
+
* Delete a memory agent
|
|
5137
|
+
*/
|
|
5138
|
+
async delete(agentId) {
|
|
5139
|
+
return this.http.delete(`/memory/agents/${agentId}`);
|
|
5140
|
+
}
|
|
5141
|
+
};
|
|
5142
|
+
|
|
5143
|
+
// src/memory/collections.ts
|
|
5144
|
+
var MemoryCollections = class {
|
|
5145
|
+
constructor(http) {
|
|
5146
|
+
this.http = http;
|
|
5147
|
+
}
|
|
5148
|
+
/**
|
|
5149
|
+
* Create a new collection for an agent
|
|
5150
|
+
*/
|
|
5151
|
+
async create(request) {
|
|
5152
|
+
return this.http.post(`/memory/agents/${request.agentId}/collections`, {
|
|
5153
|
+
name: request.name,
|
|
5154
|
+
slug: request.slug,
|
|
5155
|
+
description: request.description,
|
|
5156
|
+
compaction: request.compaction,
|
|
5157
|
+
retention: request.retention
|
|
5158
|
+
});
|
|
5159
|
+
}
|
|
5160
|
+
/**
|
|
5161
|
+
* List all collections for an agent
|
|
5162
|
+
*/
|
|
5163
|
+
async list(agentId) {
|
|
5164
|
+
return this.http.get(`/memory/agents/${agentId}/collections`);
|
|
5165
|
+
}
|
|
5166
|
+
/**
|
|
5167
|
+
* Get a collection by slug
|
|
5168
|
+
*/
|
|
5169
|
+
async get(agentId, collectionSlug) {
|
|
5170
|
+
return this.http.get(`/memory/agents/${agentId}/collections/${collectionSlug}`);
|
|
5171
|
+
}
|
|
5172
|
+
/**
|
|
5173
|
+
* Update a collection
|
|
5174
|
+
*/
|
|
5175
|
+
async update(agentId, collectionSlug, request) {
|
|
5176
|
+
return this.http.patch(
|
|
5177
|
+
`/memory/agents/${agentId}/collections/${collectionSlug}`,
|
|
5178
|
+
request
|
|
5179
|
+
);
|
|
5180
|
+
}
|
|
5181
|
+
/**
|
|
5182
|
+
* Delete a collection
|
|
5183
|
+
*/
|
|
5184
|
+
async delete(agentId, collectionSlug) {
|
|
5185
|
+
return this.http.delete(`/memory/agents/${agentId}/collections/${collectionSlug}`);
|
|
5186
|
+
}
|
|
5187
|
+
/**
|
|
5188
|
+
* Get collection statistics
|
|
5189
|
+
*/
|
|
5190
|
+
async stats(agentId, collectionSlug) {
|
|
5191
|
+
return this.http.get(
|
|
5192
|
+
`/memory/agents/${agentId}/collections/${collectionSlug}/stats`
|
|
5193
|
+
);
|
|
5194
|
+
}
|
|
5195
|
+
/**
|
|
5196
|
+
* Trigger compaction for a collection
|
|
5197
|
+
*/
|
|
5198
|
+
async compact(agentId, collectionSlug, request = {}) {
|
|
5199
|
+
return this.http.post(
|
|
5200
|
+
`/memory/agents/${agentId}/collections/${collectionSlug}/compact`,
|
|
5201
|
+
request
|
|
5202
|
+
);
|
|
5203
|
+
}
|
|
5204
|
+
/**
|
|
5205
|
+
* Get a compaction job by ID
|
|
5206
|
+
*/
|
|
5207
|
+
async getCompactionJob(agentId, collectionSlug, jobId) {
|
|
5208
|
+
return this.http.get(
|
|
5209
|
+
`/memory/agents/${agentId}/collections/${collectionSlug}/compact/${jobId}`
|
|
5210
|
+
);
|
|
5211
|
+
}
|
|
5212
|
+
};
|
|
5213
|
+
|
|
5214
|
+
// src/memory/entities.ts
|
|
5215
|
+
var MemoryEntities = class {
|
|
5216
|
+
constructor(http) {
|
|
5217
|
+
this.http = http;
|
|
5218
|
+
}
|
|
5219
|
+
async list(params) {
|
|
5220
|
+
const qs = new URLSearchParams();
|
|
5221
|
+
qs.set("agentId", params.agentId);
|
|
5222
|
+
if (params.type) qs.set("type", params.type);
|
|
5223
|
+
if (params.limit) qs.set("limit", params.limit.toString());
|
|
5224
|
+
if (params.offset) qs.set("offset", params.offset.toString());
|
|
5225
|
+
const q = qs.toString();
|
|
5226
|
+
return this.http.get(`/memory/entities${q ? `?${q}` : ""}`);
|
|
5227
|
+
}
|
|
5228
|
+
async get(entityId) {
|
|
5229
|
+
return this.http.get(`/memory/entities/${entityId}`);
|
|
5230
|
+
}
|
|
5231
|
+
async getRelations(entityId) {
|
|
5232
|
+
return this.http.get(`/memory/entities/${entityId}/relations`);
|
|
5233
|
+
}
|
|
5234
|
+
};
|
|
5235
|
+
|
|
5236
|
+
// src/memory/client.ts
|
|
5237
|
+
var Memory = class {
|
|
5238
|
+
http;
|
|
5239
|
+
/** Manage memory agents */
|
|
5240
|
+
agents;
|
|
5241
|
+
/** Manage memory collections */
|
|
5242
|
+
collections;
|
|
5243
|
+
/** Manage extracted entities */
|
|
5244
|
+
entities;
|
|
5245
|
+
constructor(config) {
|
|
5246
|
+
this.http = new HttpClient(config);
|
|
5247
|
+
this.agents = new MemoryAgents(this.http);
|
|
5248
|
+
this.collections = new MemoryCollections(this.http);
|
|
5249
|
+
this.entities = new MemoryEntities(this.http);
|
|
5250
|
+
}
|
|
5251
|
+
// ============================================================================
|
|
5252
|
+
// MEMORY OPERATIONS
|
|
5253
|
+
// ============================================================================
|
|
5254
|
+
/**
|
|
5255
|
+
* Store a memory
|
|
5256
|
+
*
|
|
5257
|
+
* @example
|
|
5258
|
+
* ```typescript
|
|
5259
|
+
* const memory = await stack0.memory.store({
|
|
5260
|
+
* agentId: 'agent_123',
|
|
5261
|
+
* content: 'User prefers dark mode',
|
|
5262
|
+
* type: 'preference',
|
|
5263
|
+
* tags: ['ui', 'settings'],
|
|
5264
|
+
* });
|
|
5265
|
+
* ```
|
|
5266
|
+
*/
|
|
5267
|
+
async store(request) {
|
|
5268
|
+
return this.http.post("/memory/memories", request);
|
|
5269
|
+
}
|
|
5270
|
+
/**
|
|
5271
|
+
* Store multiple memories in a batch
|
|
5272
|
+
*
|
|
5273
|
+
* @example
|
|
5274
|
+
* ```typescript
|
|
5275
|
+
* const results = await stack0.memory.storeBatch({
|
|
5276
|
+
* agentId: 'agent_123',
|
|
5277
|
+
* memories: [
|
|
5278
|
+
* { content: 'User prefers dark mode', type: 'preference' },
|
|
5279
|
+
* { content: 'User is based in NYC', type: 'fact' },
|
|
5280
|
+
* ],
|
|
5281
|
+
* });
|
|
5282
|
+
* ```
|
|
5283
|
+
*/
|
|
5284
|
+
async storeBatch(request) {
|
|
5285
|
+
return this.http.post("/memory/memories/batch", request);
|
|
5286
|
+
}
|
|
5287
|
+
/**
|
|
5288
|
+
* Recall memories using semantic search (vector similarity)
|
|
5289
|
+
*
|
|
5290
|
+
* @example
|
|
5291
|
+
* ```typescript
|
|
5292
|
+
* const results = await stack0.memory.recall({
|
|
5293
|
+
* agentId: 'agent_123',
|
|
5294
|
+
* query: 'What are the user preferences?',
|
|
5295
|
+
* limit: 10,
|
|
5296
|
+
* });
|
|
5297
|
+
* ```
|
|
5298
|
+
*/
|
|
5299
|
+
async recall(request) {
|
|
5300
|
+
return this.http.post("/memory/memories/recall", request);
|
|
5301
|
+
}
|
|
5302
|
+
/**
|
|
5303
|
+
* Search memories using full-text search
|
|
5304
|
+
*
|
|
5305
|
+
* @example
|
|
5306
|
+
* ```typescript
|
|
5307
|
+
* const results = await stack0.memory.search({
|
|
5308
|
+
* agentId: 'agent_123',
|
|
5309
|
+
* query: 'dark mode',
|
|
5310
|
+
* limit: 20,
|
|
5311
|
+
* });
|
|
5312
|
+
* ```
|
|
5313
|
+
*/
|
|
5314
|
+
async search(request) {
|
|
5315
|
+
return this.http.post("/memory/memories/search", request);
|
|
5316
|
+
}
|
|
5317
|
+
/**
|
|
5318
|
+
* Get a memory by ID
|
|
5319
|
+
*/
|
|
5320
|
+
async get(memoryId) {
|
|
5321
|
+
return this.http.get(`/memory/memories/${memoryId}`);
|
|
5322
|
+
}
|
|
5323
|
+
/**
|
|
5324
|
+
* List memories with optional filters
|
|
5325
|
+
*
|
|
5326
|
+
* @example
|
|
5327
|
+
* ```typescript
|
|
5328
|
+
* const memories = await stack0.memory.list({
|
|
5329
|
+
* agentId: 'agent_123',
|
|
5330
|
+
* type: 'preference',
|
|
5331
|
+
* limit: 50,
|
|
5332
|
+
* });
|
|
5333
|
+
* ```
|
|
5334
|
+
*/
|
|
5335
|
+
async list(params) {
|
|
5336
|
+
const qs = new URLSearchParams();
|
|
5337
|
+
qs.set("agentId", params.agentId);
|
|
5338
|
+
if (params.collectionSlug) qs.set("collectionSlug", params.collectionSlug);
|
|
5339
|
+
if (params.type) qs.set("type", params.type);
|
|
5340
|
+
if (params.tier) qs.set("tier", params.tier);
|
|
5341
|
+
if (params.limit) qs.set("limit", params.limit.toString());
|
|
5342
|
+
if (params.offset) qs.set("offset", params.offset.toString());
|
|
5343
|
+
if (params.sortBy) qs.set("sortBy", params.sortBy);
|
|
5344
|
+
if (params.sortOrder) qs.set("sortOrder", params.sortOrder);
|
|
5345
|
+
const q = qs.toString();
|
|
5346
|
+
return this.http.get(`/memory/memories${q ? `?${q}` : ""}`);
|
|
5347
|
+
}
|
|
5348
|
+
/**
|
|
5349
|
+
* Update a memory
|
|
5350
|
+
*/
|
|
5351
|
+
async update(memoryId, request) {
|
|
5352
|
+
return this.http.patch(`/memory/memories/${memoryId}`, request);
|
|
5353
|
+
}
|
|
5354
|
+
/**
|
|
5355
|
+
* Delete a memory by ID
|
|
5356
|
+
*/
|
|
5357
|
+
async delete(memoryId) {
|
|
5358
|
+
return this.http.delete(`/memory/memories/${memoryId}`);
|
|
5359
|
+
}
|
|
5360
|
+
/**
|
|
5361
|
+
* Delete multiple memories
|
|
5362
|
+
*/
|
|
5363
|
+
async deleteMany(request) {
|
|
5364
|
+
return this.http.deleteWithBody("/memory/memories", request);
|
|
5365
|
+
}
|
|
5366
|
+
};
|
|
5367
|
+
|
|
4620
5368
|
// src/index.ts
|
|
4621
5369
|
var Stack0 = class {
|
|
4622
5370
|
mail;
|
|
@@ -4625,6 +5373,8 @@ var Stack0 = class {
|
|
|
4625
5373
|
extraction;
|
|
4626
5374
|
integrations;
|
|
4627
5375
|
marketing;
|
|
5376
|
+
workflows;
|
|
5377
|
+
memory;
|
|
4628
5378
|
/**
|
|
4629
5379
|
* @deprecated Use `screenshots` and `extraction` instead. Will be removed in a future version.
|
|
4630
5380
|
*/
|
|
@@ -4640,11 +5390,13 @@ var Stack0 = class {
|
|
|
4640
5390
|
this.extraction = new Extraction(clientConfig);
|
|
4641
5391
|
this.integrations = new Integrations(clientConfig);
|
|
4642
5392
|
this.marketing = new Marketing(clientConfig);
|
|
5393
|
+
this.workflows = new Workflows(clientConfig);
|
|
5394
|
+
this.memory = new Memory(clientConfig);
|
|
4643
5395
|
this.webdata = new Webdata(clientConfig);
|
|
4644
5396
|
}
|
|
4645
5397
|
};
|
|
4646
5398
|
var src_default = Stack0;
|
|
4647
5399
|
|
|
4648
|
-
export { Audiences, CDN, Campaigns, Contacts, Domains, Events, Extraction, Integrations, Mail, Marketing, Screenshots, Sequences, Stack0, Templates, Webdata, src_default as default };
|
|
5400
|
+
export { Audiences, CDN, Campaigns, Contacts, Domains, Events, Extraction, Integrations, Mail, Marketing, Memory, MemoryAgents, MemoryCollections, MemoryEntities, Screenshots, Sequences, Stack0, Templates, Webdata, Workflows, src_default as default };
|
|
4649
5401
|
//# sourceMappingURL=index.mjs.map
|
|
4650
5402
|
//# sourceMappingURL=index.mjs.map
|