@stack0/sdk 0.5.7 → 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/dist/index.js CHANGED
@@ -963,6 +963,27 @@ var CDN = class {
963
963
  }
964
964
  return this.confirmUpload(assetId);
965
965
  }
966
+ /**
967
+ * Upload a file from a remote URL (server-side fetch).
968
+ * The server streams the file directly from the source URL into storage,
969
+ * so the client never touches the bytes. Ideal for serverless environments
970
+ * with tight memory limits.
971
+ *
972
+ * @example
973
+ * ```typescript
974
+ * const asset = await cdn.uploadFromUrl({
975
+ * projectSlug: 'my-project',
976
+ * sourceUrl: 'https://replicate.delivery/output/video.mp4',
977
+ * filename: 'video.mp4',
978
+ * mimeType: 'video/mp4',
979
+ * });
980
+ * console.log(asset.cdnUrl);
981
+ * ```
982
+ */
983
+ async uploadFromUrl(request) {
984
+ const response = await this.http.post("/cdn/upload-from-url", request);
985
+ return this.convertAssetDates(response);
986
+ }
966
987
  /**
967
988
  * Get an asset by ID
968
989
  *
@@ -1339,6 +1360,80 @@ var CDN = class {
1339
1360
  async extractAudio(request) {
1340
1361
  return this.http.post("/cdn/video/extract-audio", request);
1341
1362
  }
1363
+ // ============================================================================
1364
+ // GIF Generation Methods
1365
+ // ============================================================================
1366
+ /**
1367
+ * Generate an animated GIF from a video segment
1368
+ *
1369
+ * Creates an optimized GIF from a portion of the video. Uses two-pass
1370
+ * palette generation by default for smaller file sizes with better quality.
1371
+ *
1372
+ * @example
1373
+ * ```typescript
1374
+ * const gif = await cdn.generateGif({
1375
+ * projectSlug: 'my-project',
1376
+ * assetId: 'video-asset-id',
1377
+ * startTime: 5, // Start at 5 seconds
1378
+ * duration: 3, // 3 second GIF
1379
+ * width: 480, // 480px wide
1380
+ * fps: 10, // 10 frames per second
1381
+ * });
1382
+ *
1383
+ * // Poll for completion
1384
+ * let result = await cdn.getGif(gif.id);
1385
+ * while (result?.status === 'pending' || result?.status === 'processing') {
1386
+ * await new Promise(r => setTimeout(r, 1000));
1387
+ * result = await cdn.getGif(gif.id);
1388
+ * }
1389
+ *
1390
+ * console.log(`GIF URL: ${result?.url}`);
1391
+ * ```
1392
+ */
1393
+ async generateGif(request) {
1394
+ const response = await this.http.post("/cdn/video/gif", request);
1395
+ return this.convertGifDates(response);
1396
+ }
1397
+ /**
1398
+ * Get a specific GIF by ID
1399
+ *
1400
+ * @example
1401
+ * ```typescript
1402
+ * const gif = await cdn.getGif('gif-id');
1403
+ * if (gif?.status === 'completed') {
1404
+ * console.log(`GIF URL: ${gif.url}`);
1405
+ * console.log(`Size: ${gif.sizeBytes} bytes`);
1406
+ * }
1407
+ * ```
1408
+ */
1409
+ async getGif(gifId) {
1410
+ const response = await this.http.get(`/cdn/video/gif/${gifId}`);
1411
+ return response ? this.convertGifDates(response) : null;
1412
+ }
1413
+ /**
1414
+ * List all GIFs generated for a video asset
1415
+ *
1416
+ * @example
1417
+ * ```typescript
1418
+ * const gifs = await cdn.listGifs({ assetId: 'video-asset-id' });
1419
+ * for (const gif of gifs) {
1420
+ * console.log(`GIF at ${gif.startTime}s: ${gif.url}`);
1421
+ * }
1422
+ * ```
1423
+ */
1424
+ async listGifs(request) {
1425
+ const response = await this.http.get(`/cdn/video/${request.assetId}/gifs`);
1426
+ return response.map((gif) => this.convertGifDates(gif));
1427
+ }
1428
+ convertGifDates(gif) {
1429
+ if (typeof gif.createdAt === "string") {
1430
+ gif.createdAt = new Date(gif.createdAt);
1431
+ }
1432
+ if (gif.completedAt && typeof gif.completedAt === "string") {
1433
+ gif.completedAt = new Date(gif.completedAt);
1434
+ }
1435
+ return gif;
1436
+ }
1342
1437
  convertJobDates(job) {
1343
1438
  if (typeof job.createdAt === "string") {
1344
1439
  job.createdAt = new Date(job.createdAt);
@@ -1941,6 +2036,204 @@ var CDN = class {
1941
2036
  convertMergeJobWithOutputDates(job) {
1942
2037
  return this.convertMergeJobDates(job);
1943
2038
  }
2039
+ // ============================================================================
2040
+ // S3 Import Methods
2041
+ // ============================================================================
2042
+ /**
2043
+ * Create an S3 import job to bulk import files from an external S3 bucket.
2044
+ * Requires Pro plan or higher.
2045
+ *
2046
+ * @example
2047
+ * ```typescript
2048
+ * // Using IAM credentials
2049
+ * const job = await cdn.createImport({
2050
+ * projectSlug: 'my-project',
2051
+ * sourceBucket: 'my-external-bucket',
2052
+ * sourceRegion: 'us-east-1',
2053
+ * sourcePrefix: 'images/',
2054
+ * authType: 'iam_credentials',
2055
+ * accessKeyId: 'AKIA...',
2056
+ * secretAccessKey: 'secret...',
2057
+ * pathMode: 'flatten',
2058
+ * notifyEmail: 'admin@example.com',
2059
+ * });
2060
+ *
2061
+ * // Using role assumption
2062
+ * const job = await cdn.createImport({
2063
+ * projectSlug: 'my-project',
2064
+ * sourceBucket: 'partner-bucket',
2065
+ * sourceRegion: 'eu-west-1',
2066
+ * authType: 'role_assumption',
2067
+ * roleArn: 'arn:aws:iam::123456789012:role/Stack0ImportRole',
2068
+ * externalId: 'optional-external-id',
2069
+ * pathMode: 'preserve',
2070
+ * targetFolder: '/imported',
2071
+ * });
2072
+ *
2073
+ * console.log(`Import job started: ${job.importId}`);
2074
+ * ```
2075
+ */
2076
+ async createImport(request) {
2077
+ const response = await this.http.post("/cdn/imports", request);
2078
+ return this.convertCreateImportDates(response);
2079
+ }
2080
+ /**
2081
+ * Get an import job by ID
2082
+ *
2083
+ * @example
2084
+ * ```typescript
2085
+ * const job = await cdn.getImport('import-id');
2086
+ * console.log(`Status: ${job.status}`);
2087
+ * console.log(`Progress: ${job.processedFiles}/${job.totalFiles} files`);
2088
+ * console.log(`Bytes: ${job.processedBytes}/${job.totalBytes}`);
2089
+ * ```
2090
+ */
2091
+ async getImport(importId) {
2092
+ const response = await this.http.get(`/cdn/imports/${importId}`);
2093
+ return response ? this.convertImportJobDates(response) : null;
2094
+ }
2095
+ /**
2096
+ * List import jobs with pagination and filters
2097
+ *
2098
+ * @example
2099
+ * ```typescript
2100
+ * const { imports, total, hasMore } = await cdn.listImports({
2101
+ * projectSlug: 'my-project',
2102
+ * status: 'importing',
2103
+ * limit: 20,
2104
+ * });
2105
+ *
2106
+ * for (const job of imports) {
2107
+ * console.log(`${job.sourceBucket}: ${job.processedFiles}/${job.totalFiles}`);
2108
+ * }
2109
+ * ```
2110
+ */
2111
+ async listImports(request) {
2112
+ const params = new URLSearchParams();
2113
+ params.set("projectSlug", request.projectSlug);
2114
+ if (request.environment) params.set("environment", request.environment);
2115
+ if (request.status) params.set("status", request.status);
2116
+ if (request.sortBy) params.set("sortBy", request.sortBy);
2117
+ if (request.sortOrder) params.set("sortOrder", request.sortOrder);
2118
+ if (request.limit) params.set("limit", request.limit.toString());
2119
+ if (request.offset) params.set("offset", request.offset.toString());
2120
+ const response = await this.http.get(`/cdn/imports?${params.toString()}`);
2121
+ return {
2122
+ ...response,
2123
+ imports: response.imports.map((job) => this.convertImportJobSummaryDates(job))
2124
+ };
2125
+ }
2126
+ /**
2127
+ * Cancel a running import job
2128
+ *
2129
+ * Files already imported will remain. Only pending/validating/importing jobs can be cancelled.
2130
+ *
2131
+ * @example
2132
+ * ```typescript
2133
+ * const result = await cdn.cancelImport('import-id');
2134
+ * console.log(`Cancelled: ${result.success}`);
2135
+ * ```
2136
+ */
2137
+ async cancelImport(importId) {
2138
+ return this.http.post(`/cdn/imports/${importId}/cancel`, {});
2139
+ }
2140
+ /**
2141
+ * Retry failed files in a completed or failed import job
2142
+ *
2143
+ * This resets failed files to pending and re-queues the import for processing.
2144
+ *
2145
+ * @example
2146
+ * ```typescript
2147
+ * const result = await cdn.retryImport('import-id');
2148
+ * console.log(`Retrying ${result.retriedCount} files`);
2149
+ * ```
2150
+ */
2151
+ async retryImport(importId) {
2152
+ return this.http.post(`/cdn/imports/${importId}/retry`, {});
2153
+ }
2154
+ /**
2155
+ * List files in an import job with optional status filter
2156
+ *
2157
+ * @example
2158
+ * ```typescript
2159
+ * // List all files
2160
+ * const { files, total } = await cdn.listImportFiles({
2161
+ * importId: 'import-id',
2162
+ * limit: 100,
2163
+ * });
2164
+ *
2165
+ * // List only failed files
2166
+ * const { files: failedFiles } = await cdn.listImportFiles({
2167
+ * importId: 'import-id',
2168
+ * status: 'failed',
2169
+ * });
2170
+ *
2171
+ * for (const file of failedFiles) {
2172
+ * console.log(`${file.sourceKey}: ${file.errorMessage}`);
2173
+ * }
2174
+ * ```
2175
+ */
2176
+ async listImportFiles(request) {
2177
+ const params = new URLSearchParams();
2178
+ if (request.status) params.set("status", request.status);
2179
+ if (request.sortBy) params.set("sortBy", request.sortBy);
2180
+ if (request.sortOrder) params.set("sortOrder", request.sortOrder);
2181
+ if (request.limit) params.set("limit", request.limit.toString());
2182
+ if (request.offset) params.set("offset", request.offset.toString());
2183
+ const query = params.toString();
2184
+ const response = await this.http.get(
2185
+ `/cdn/imports/${request.importId}/files${query ? `?${query}` : ""}`
2186
+ );
2187
+ return {
2188
+ ...response,
2189
+ files: response.files.map((file) => this.convertImportFileDates(file))
2190
+ };
2191
+ }
2192
+ convertCreateImportDates(response) {
2193
+ if (typeof response.createdAt === "string") {
2194
+ response.createdAt = new Date(response.createdAt);
2195
+ }
2196
+ return response;
2197
+ }
2198
+ convertImportJobDates(job) {
2199
+ if (typeof job.createdAt === "string") {
2200
+ job.createdAt = new Date(job.createdAt);
2201
+ }
2202
+ if (job.updatedAt && typeof job.updatedAt === "string") {
2203
+ job.updatedAt = new Date(job.updatedAt);
2204
+ }
2205
+ if (job.startedAt && typeof job.startedAt === "string") {
2206
+ job.startedAt = new Date(job.startedAt);
2207
+ }
2208
+ if (job.completedAt && typeof job.completedAt === "string") {
2209
+ job.completedAt = new Date(job.completedAt);
2210
+ }
2211
+ return job;
2212
+ }
2213
+ convertImportJobSummaryDates(job) {
2214
+ if (typeof job.createdAt === "string") {
2215
+ job.createdAt = new Date(job.createdAt);
2216
+ }
2217
+ if (job.startedAt && typeof job.startedAt === "string") {
2218
+ job.startedAt = new Date(job.startedAt);
2219
+ }
2220
+ if (job.completedAt && typeof job.completedAt === "string") {
2221
+ job.completedAt = new Date(job.completedAt);
2222
+ }
2223
+ return job;
2224
+ }
2225
+ convertImportFileDates(file) {
2226
+ if (typeof file.createdAt === "string") {
2227
+ file.createdAt = new Date(file.createdAt);
2228
+ }
2229
+ if (file.completedAt && typeof file.completedAt === "string") {
2230
+ file.completedAt = new Date(file.completedAt);
2231
+ }
2232
+ if (file.lastAttemptAt && typeof file.lastAttemptAt === "string") {
2233
+ file.lastAttemptAt = new Date(file.lastAttemptAt);
2234
+ }
2235
+ return file;
2236
+ }
1944
2237
  };
1945
2238
 
1946
2239
  // src/screenshots/client.ts
@@ -3515,9 +3808,7 @@ var Productivity = class {
3515
3808
  return this.http.get(`/integrations/productivity/tables/${tableId}/rows?${params}`);
3516
3809
  }
3517
3810
  async getTableRow(connectionId, tableId, rowId) {
3518
- return this.http.get(
3519
- `/integrations/productivity/tables/${tableId}/rows/${rowId}?connectionId=${connectionId}`
3520
- );
3811
+ return this.http.get(`/integrations/productivity/tables/${tableId}/rows/${rowId}?connectionId=${connectionId}`);
3521
3812
  }
3522
3813
  async createTableRow(connectionId, tableId, data) {
3523
3814
  return this.http.post(`/integrations/productivity/tables/${tableId}/rows`, {
@@ -3532,9 +3823,7 @@ var Productivity = class {
3532
3823
  });
3533
3824
  }
3534
3825
  async deleteTableRow(connectionId, tableId, rowId) {
3535
- return this.http.delete(
3536
- `/integrations/productivity/tables/${tableId}/rows/${rowId}?connectionId=${connectionId}`
3537
- );
3826
+ return this.http.delete(`/integrations/productivity/tables/${tableId}/rows/${rowId}?connectionId=${connectionId}`);
3538
3827
  }
3539
3828
  };
3540
3829
  var Integrations = class {
@@ -3661,10 +3950,9 @@ var Integrations = class {
3661
3950
  * ```
3662
3951
  */
3663
3952
  async reconnectConnection(request) {
3664
- return this.http.post(
3665
- `/integrations/connections/${request.connectionId}/reconnect`,
3666
- { redirectUrl: request.redirectUrl }
3667
- );
3953
+ return this.http.post(`/integrations/connections/${request.connectionId}/reconnect`, {
3954
+ redirectUrl: request.redirectUrl
3955
+ });
3668
3956
  }
3669
3957
  /**
3670
3958
  * Get integration statistics
@@ -3708,9 +3996,7 @@ var Integrations = class {
3708
3996
  if (request?.limit) params.set("limit", request.limit.toString());
3709
3997
  if (request?.cursor) params.set("cursor", request.cursor);
3710
3998
  const queryString = params.toString();
3711
- const response = await this.http.get(
3712
- `/integrations/logs${queryString ? `?${queryString}` : ""}`
3713
- );
3999
+ const response = await this.http.get(`/integrations/logs${queryString ? `?${queryString}` : ""}`);
3714
4000
  return {
3715
4001
  ...response,
3716
4002
  logs: response.logs.map((log) => this.convertLogDates(log))
@@ -4554,6 +4840,535 @@ var Marketing = class {
4554
4840
  }
4555
4841
  };
4556
4842
 
4843
+ // src/workflows/client.ts
4844
+ var Workflows = class {
4845
+ http;
4846
+ constructor(config) {
4847
+ this.http = new HttpClient(config);
4848
+ }
4849
+ // ==========================================================================
4850
+ // WORKFLOW CRUD
4851
+ // ==========================================================================
4852
+ /**
4853
+ * Create a new workflow
4854
+ *
4855
+ * @example
4856
+ * ```typescript
4857
+ * const workflow = await workflows.create({
4858
+ * slug: 'content-pipeline',
4859
+ * name: 'Content Generation Pipeline',
4860
+ * steps: [
4861
+ * {
4862
+ * id: 'generate',
4863
+ * name: 'Generate Content',
4864
+ * type: 'llm',
4865
+ * provider: 'anthropic',
4866
+ * model: 'claude-sonnet-4-20250514',
4867
+ * config: {
4868
+ * prompt: 'Write a blog post about {{topic}}',
4869
+ * maxTokens: 2000,
4870
+ * },
4871
+ * },
4872
+ * ],
4873
+ * variables: [
4874
+ * { name: 'topic', type: 'string', required: true },
4875
+ * ],
4876
+ * });
4877
+ * ```
4878
+ */
4879
+ async create(request) {
4880
+ return this.http.post("/workflows/workflows", request);
4881
+ }
4882
+ /**
4883
+ * Get a workflow by ID or slug
4884
+ *
4885
+ * @example
4886
+ * ```typescript
4887
+ * const workflow = await workflows.get({ slug: 'content-pipeline' });
4888
+ * console.log(workflow.steps);
4889
+ * ```
4890
+ */
4891
+ async get(request) {
4892
+ const params = new URLSearchParams();
4893
+ if (request.slug) params.set("slug", request.slug);
4894
+ if (request.environment) params.set("environment", request.environment);
4895
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
4896
+ const path = request.id ? `/workflows/workflows/${request.id}` : `/workflows/workflows?${params.toString()}`;
4897
+ const response = await this.http.get(path);
4898
+ return this.convertDates(response);
4899
+ }
4900
+ /**
4901
+ * List workflows with pagination
4902
+ *
4903
+ * @example
4904
+ * ```typescript
4905
+ * const { items, nextCursor } = await workflows.list({
4906
+ * environment: 'production',
4907
+ * isActive: true,
4908
+ * limit: 20,
4909
+ * });
4910
+ * ```
4911
+ */
4912
+ async list(request = {}) {
4913
+ const params = new URLSearchParams();
4914
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
4915
+ if (request.environment) params.set("environment", request.environment);
4916
+ if (request.isActive !== void 0) params.set("isActive", request.isActive.toString());
4917
+ if (request.limit) params.set("limit", request.limit.toString());
4918
+ if (request.cursor) params.set("cursor", request.cursor);
4919
+ const query = params.toString();
4920
+ const response = await this.http.get(
4921
+ `/workflows/workflows${query ? `?${query}` : ""}`
4922
+ );
4923
+ return {
4924
+ ...response,
4925
+ items: response.items.map((item) => this.convertDates(item))
4926
+ };
4927
+ }
4928
+ /**
4929
+ * Update a workflow
4930
+ *
4931
+ * @example
4932
+ * ```typescript
4933
+ * await workflows.update({
4934
+ * id: 'workflow-id',
4935
+ * name: 'Updated Pipeline',
4936
+ * isActive: false,
4937
+ * });
4938
+ * ```
4939
+ */
4940
+ async update(request) {
4941
+ const { id, ...data } = request;
4942
+ return this.http.post(
4943
+ `/workflows/workflows/${id}`,
4944
+ data
4945
+ );
4946
+ }
4947
+ /**
4948
+ * Delete a workflow
4949
+ *
4950
+ * @example
4951
+ * ```typescript
4952
+ * await workflows.delete({ id: 'workflow-id' });
4953
+ * ```
4954
+ */
4955
+ async delete(request) {
4956
+ return this.http.deleteWithBody(
4957
+ `/workflows/workflows/${request.id}`,
4958
+ request
4959
+ );
4960
+ }
4961
+ // ==========================================================================
4962
+ // WORKFLOW EXECUTION
4963
+ // ==========================================================================
4964
+ /**
4965
+ * Run a workflow
4966
+ *
4967
+ * @example
4968
+ * ```typescript
4969
+ * const run = await workflows.run({
4970
+ * workflowSlug: 'content-pipeline',
4971
+ * variables: {
4972
+ * topic: 'artificial intelligence',
4973
+ * },
4974
+ * webhook: {
4975
+ * url: 'https://example.com/webhook',
4976
+ * secret: 'webhook-secret',
4977
+ * },
4978
+ * });
4979
+ * console.log(run.id, run.status);
4980
+ * ```
4981
+ */
4982
+ async run(request) {
4983
+ return this.http.post("/workflows/workflows/run", request);
4984
+ }
4985
+ /**
4986
+ * Get a workflow run by ID
4987
+ *
4988
+ * @example
4989
+ * ```typescript
4990
+ * const run = await workflows.getRun({ id: 'run-id' });
4991
+ * if (run.status === 'completed') {
4992
+ * console.log(run.output);
4993
+ * }
4994
+ * ```
4995
+ */
4996
+ async getRun(request) {
4997
+ const params = new URLSearchParams();
4998
+ if (request.environment) params.set("environment", request.environment);
4999
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
5000
+ const query = params.toString();
5001
+ const response = await this.http.get(
5002
+ `/workflows/workflows/runs/${request.id}${query ? `?${query}` : ""}`
5003
+ );
5004
+ return this.convertRunDates(response);
5005
+ }
5006
+ /**
5007
+ * List workflow runs with pagination
5008
+ *
5009
+ * @example
5010
+ * ```typescript
5011
+ * const { items } = await workflows.listRuns({
5012
+ * workflowId: 'workflow-id',
5013
+ * status: 'completed',
5014
+ * });
5015
+ * ```
5016
+ */
5017
+ async listRuns(request = {}) {
5018
+ const params = new URLSearchParams();
5019
+ if (request.workflowId) params.set("workflowId", request.workflowId);
5020
+ if (request.workflowSlug) params.set("workflowSlug", request.workflowSlug);
5021
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
5022
+ if (request.environment) params.set("environment", request.environment);
5023
+ if (request.status) params.set("status", request.status);
5024
+ if (request.limit) params.set("limit", request.limit.toString());
5025
+ if (request.cursor) params.set("cursor", request.cursor);
5026
+ const query = params.toString();
5027
+ const response = await this.http.get(
5028
+ `/workflows/workflows/runs${query ? `?${query}` : ""}`
5029
+ );
5030
+ return {
5031
+ ...response,
5032
+ items: response.items.map((item) => this.convertRunDates(item))
5033
+ };
5034
+ }
5035
+ /**
5036
+ * Cancel a running workflow
5037
+ *
5038
+ * @example
5039
+ * ```typescript
5040
+ * await workflows.cancelRun({ id: 'run-id' });
5041
+ * ```
5042
+ */
5043
+ async cancelRun(request) {
5044
+ return this.http.post(
5045
+ `/workflows/workflows/runs/${request.id}/cancel`,
5046
+ {}
5047
+ );
5048
+ }
5049
+ /**
5050
+ * Run a workflow and wait for completion
5051
+ *
5052
+ * @example
5053
+ * ```typescript
5054
+ * const run = await workflows.runAndWait({
5055
+ * workflowSlug: 'content-pipeline',
5056
+ * variables: { topic: 'AI' },
5057
+ * });
5058
+ * console.log(run.output);
5059
+ * ```
5060
+ */
5061
+ async runAndWait(request, options = {}) {
5062
+ const { pollInterval = 2e3, timeout = 6e5 } = options;
5063
+ const startTime = Date.now();
5064
+ const { id } = await this.run(request);
5065
+ while (Date.now() - startTime < timeout) {
5066
+ const run = await this.getRun({
5067
+ id,
5068
+ environment: request.environment,
5069
+ projectSlug: request.projectSlug
5070
+ });
5071
+ if (run.status === "completed" || run.status === "failed" || run.status === "cancelled") {
5072
+ if (run.status === "failed") {
5073
+ throw new Error(run.error || "Workflow execution failed");
5074
+ }
5075
+ return run;
5076
+ }
5077
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
5078
+ }
5079
+ throw new Error("Workflow execution timed out");
5080
+ }
5081
+ // ==========================================================================
5082
+ // HELPERS
5083
+ // ==========================================================================
5084
+ convertDates(workflow) {
5085
+ if (typeof workflow.createdAt === "string") {
5086
+ workflow.createdAt = new Date(workflow.createdAt);
5087
+ }
5088
+ if (typeof workflow.updatedAt === "string") {
5089
+ workflow.updatedAt = new Date(workflow.updatedAt);
5090
+ }
5091
+ return workflow;
5092
+ }
5093
+ convertRunDates(run) {
5094
+ if (typeof run.createdAt === "string") {
5095
+ run.createdAt = new Date(run.createdAt);
5096
+ }
5097
+ if (run.startedAt && typeof run.startedAt === "string") {
5098
+ run.startedAt = new Date(run.startedAt);
5099
+ }
5100
+ if (run.completedAt && typeof run.completedAt === "string") {
5101
+ run.completedAt = new Date(run.completedAt);
5102
+ }
5103
+ return run;
5104
+ }
5105
+ };
5106
+
5107
+ // src/memory/agents.ts
5108
+ var MemoryAgents = class {
5109
+ constructor(http) {
5110
+ this.http = http;
5111
+ }
5112
+ /**
5113
+ * Create a new memory agent
5114
+ */
5115
+ async create(request) {
5116
+ return this.http.post("/memory/agents", request);
5117
+ }
5118
+ /**
5119
+ * List all memory agents
5120
+ */
5121
+ async list(params = {}) {
5122
+ const qs = new URLSearchParams();
5123
+ if (params.environment) qs.set("environment", params.environment);
5124
+ const q = qs.toString();
5125
+ return this.http.get(`/memory/agents${q ? `?${q}` : ""}`);
5126
+ }
5127
+ /**
5128
+ * Get a memory agent by ID
5129
+ */
5130
+ async get(agentId) {
5131
+ return this.http.get(`/memory/agents/${agentId}`);
5132
+ }
5133
+ /**
5134
+ * Update a memory agent
5135
+ */
5136
+ async update(agentId, request) {
5137
+ return this.http.patch(`/memory/agents/${agentId}`, request);
5138
+ }
5139
+ /**
5140
+ * Delete a memory agent
5141
+ */
5142
+ async delete(agentId) {
5143
+ return this.http.delete(`/memory/agents/${agentId}`);
5144
+ }
5145
+ };
5146
+
5147
+ // src/memory/collections.ts
5148
+ var MemoryCollections = class {
5149
+ constructor(http) {
5150
+ this.http = http;
5151
+ }
5152
+ /**
5153
+ * Create a new collection for an agent
5154
+ */
5155
+ async create(request) {
5156
+ return this.http.post(`/memory/agents/${request.agentId}/collections`, {
5157
+ name: request.name,
5158
+ slug: request.slug,
5159
+ description: request.description,
5160
+ compaction: request.compaction,
5161
+ retention: request.retention
5162
+ });
5163
+ }
5164
+ /**
5165
+ * List all collections for an agent
5166
+ */
5167
+ async list(agentId) {
5168
+ return this.http.get(`/memory/agents/${agentId}/collections`);
5169
+ }
5170
+ /**
5171
+ * Get a collection by slug
5172
+ */
5173
+ async get(agentId, collectionSlug) {
5174
+ return this.http.get(`/memory/agents/${agentId}/collections/${collectionSlug}`);
5175
+ }
5176
+ /**
5177
+ * Update a collection
5178
+ */
5179
+ async update(agentId, collectionSlug, request) {
5180
+ return this.http.patch(
5181
+ `/memory/agents/${agentId}/collections/${collectionSlug}`,
5182
+ request
5183
+ );
5184
+ }
5185
+ /**
5186
+ * Delete a collection
5187
+ */
5188
+ async delete(agentId, collectionSlug) {
5189
+ return this.http.delete(`/memory/agents/${agentId}/collections/${collectionSlug}`);
5190
+ }
5191
+ /**
5192
+ * Get collection statistics
5193
+ */
5194
+ async stats(agentId, collectionSlug) {
5195
+ return this.http.get(
5196
+ `/memory/agents/${agentId}/collections/${collectionSlug}/stats`
5197
+ );
5198
+ }
5199
+ /**
5200
+ * Trigger compaction for a collection
5201
+ */
5202
+ async compact(agentId, collectionSlug, request = {}) {
5203
+ return this.http.post(
5204
+ `/memory/agents/${agentId}/collections/${collectionSlug}/compact`,
5205
+ request
5206
+ );
5207
+ }
5208
+ /**
5209
+ * Get a compaction job by ID
5210
+ */
5211
+ async getCompactionJob(agentId, collectionSlug, jobId) {
5212
+ return this.http.get(
5213
+ `/memory/agents/${agentId}/collections/${collectionSlug}/compact/${jobId}`
5214
+ );
5215
+ }
5216
+ };
5217
+
5218
+ // src/memory/entities.ts
5219
+ var MemoryEntities = class {
5220
+ constructor(http) {
5221
+ this.http = http;
5222
+ }
5223
+ async list(params) {
5224
+ const qs = new URLSearchParams();
5225
+ qs.set("agentId", params.agentId);
5226
+ if (params.type) qs.set("type", params.type);
5227
+ if (params.limit) qs.set("limit", params.limit.toString());
5228
+ if (params.offset) qs.set("offset", params.offset.toString());
5229
+ const q = qs.toString();
5230
+ return this.http.get(`/memory/entities${q ? `?${q}` : ""}`);
5231
+ }
5232
+ async get(entityId) {
5233
+ return this.http.get(`/memory/entities/${entityId}`);
5234
+ }
5235
+ async getRelations(entityId) {
5236
+ return this.http.get(`/memory/entities/${entityId}/relations`);
5237
+ }
5238
+ };
5239
+
5240
+ // src/memory/client.ts
5241
+ var Memory = class {
5242
+ http;
5243
+ /** Manage memory agents */
5244
+ agents;
5245
+ /** Manage memory collections */
5246
+ collections;
5247
+ /** Manage extracted entities */
5248
+ entities;
5249
+ constructor(config) {
5250
+ this.http = new HttpClient(config);
5251
+ this.agents = new MemoryAgents(this.http);
5252
+ this.collections = new MemoryCollections(this.http);
5253
+ this.entities = new MemoryEntities(this.http);
5254
+ }
5255
+ // ============================================================================
5256
+ // MEMORY OPERATIONS
5257
+ // ============================================================================
5258
+ /**
5259
+ * Store a memory
5260
+ *
5261
+ * @example
5262
+ * ```typescript
5263
+ * const memory = await stack0.memory.store({
5264
+ * agentId: 'agent_123',
5265
+ * content: 'User prefers dark mode',
5266
+ * type: 'preference',
5267
+ * tags: ['ui', 'settings'],
5268
+ * });
5269
+ * ```
5270
+ */
5271
+ async store(request) {
5272
+ return this.http.post("/memory/memories", request);
5273
+ }
5274
+ /**
5275
+ * Store multiple memories in a batch
5276
+ *
5277
+ * @example
5278
+ * ```typescript
5279
+ * const results = await stack0.memory.storeBatch({
5280
+ * agentId: 'agent_123',
5281
+ * memories: [
5282
+ * { content: 'User prefers dark mode', type: 'preference' },
5283
+ * { content: 'User is based in NYC', type: 'fact' },
5284
+ * ],
5285
+ * });
5286
+ * ```
5287
+ */
5288
+ async storeBatch(request) {
5289
+ return this.http.post("/memory/memories/batch", request);
5290
+ }
5291
+ /**
5292
+ * Recall memories using semantic search (vector similarity)
5293
+ *
5294
+ * @example
5295
+ * ```typescript
5296
+ * const results = await stack0.memory.recall({
5297
+ * agentId: 'agent_123',
5298
+ * query: 'What are the user preferences?',
5299
+ * limit: 10,
5300
+ * });
5301
+ * ```
5302
+ */
5303
+ async recall(request) {
5304
+ return this.http.post("/memory/memories/recall", request);
5305
+ }
5306
+ /**
5307
+ * Search memories using full-text search
5308
+ *
5309
+ * @example
5310
+ * ```typescript
5311
+ * const results = await stack0.memory.search({
5312
+ * agentId: 'agent_123',
5313
+ * query: 'dark mode',
5314
+ * limit: 20,
5315
+ * });
5316
+ * ```
5317
+ */
5318
+ async search(request) {
5319
+ return this.http.post("/memory/memories/search", request);
5320
+ }
5321
+ /**
5322
+ * Get a memory by ID
5323
+ */
5324
+ async get(memoryId) {
5325
+ return this.http.get(`/memory/memories/${memoryId}`);
5326
+ }
5327
+ /**
5328
+ * List memories with optional filters
5329
+ *
5330
+ * @example
5331
+ * ```typescript
5332
+ * const memories = await stack0.memory.list({
5333
+ * agentId: 'agent_123',
5334
+ * type: 'preference',
5335
+ * limit: 50,
5336
+ * });
5337
+ * ```
5338
+ */
5339
+ async list(params) {
5340
+ const qs = new URLSearchParams();
5341
+ qs.set("agentId", params.agentId);
5342
+ if (params.collectionSlug) qs.set("collectionSlug", params.collectionSlug);
5343
+ if (params.type) qs.set("type", params.type);
5344
+ if (params.tier) qs.set("tier", params.tier);
5345
+ if (params.limit) qs.set("limit", params.limit.toString());
5346
+ if (params.offset) qs.set("offset", params.offset.toString());
5347
+ if (params.sortBy) qs.set("sortBy", params.sortBy);
5348
+ if (params.sortOrder) qs.set("sortOrder", params.sortOrder);
5349
+ const q = qs.toString();
5350
+ return this.http.get(`/memory/memories${q ? `?${q}` : ""}`);
5351
+ }
5352
+ /**
5353
+ * Update a memory
5354
+ */
5355
+ async update(memoryId, request) {
5356
+ return this.http.patch(`/memory/memories/${memoryId}`, request);
5357
+ }
5358
+ /**
5359
+ * Delete a memory by ID
5360
+ */
5361
+ async delete(memoryId) {
5362
+ return this.http.delete(`/memory/memories/${memoryId}`);
5363
+ }
5364
+ /**
5365
+ * Delete multiple memories
5366
+ */
5367
+ async deleteMany(request) {
5368
+ return this.http.deleteWithBody("/memory/memories", request);
5369
+ }
5370
+ };
5371
+
4557
5372
  // src/index.ts
4558
5373
  var Stack0 = class {
4559
5374
  mail;
@@ -4562,6 +5377,8 @@ var Stack0 = class {
4562
5377
  extraction;
4563
5378
  integrations;
4564
5379
  marketing;
5380
+ workflows;
5381
+ memory;
4565
5382
  /**
4566
5383
  * @deprecated Use `screenshots` and `extraction` instead. Will be removed in a future version.
4567
5384
  */
@@ -4577,6 +5394,8 @@ var Stack0 = class {
4577
5394
  this.extraction = new Extraction(clientConfig);
4578
5395
  this.integrations = new Integrations(clientConfig);
4579
5396
  this.marketing = new Marketing(clientConfig);
5397
+ this.workflows = new Workflows(clientConfig);
5398
+ this.memory = new Memory(clientConfig);
4580
5399
  this.webdata = new Webdata(clientConfig);
4581
5400
  }
4582
5401
  };
@@ -4592,11 +5411,16 @@ exports.Extraction = Extraction;
4592
5411
  exports.Integrations = Integrations;
4593
5412
  exports.Mail = Mail;
4594
5413
  exports.Marketing = Marketing;
5414
+ exports.Memory = Memory;
5415
+ exports.MemoryAgents = MemoryAgents;
5416
+ exports.MemoryCollections = MemoryCollections;
5417
+ exports.MemoryEntities = MemoryEntities;
4595
5418
  exports.Screenshots = Screenshots;
4596
5419
  exports.Sequences = Sequences;
4597
5420
  exports.Stack0 = Stack0;
4598
5421
  exports.Templates = Templates;
4599
5422
  exports.Webdata = Webdata;
5423
+ exports.Workflows = Workflows;
4600
5424
  exports.default = src_default;
4601
5425
  //# sourceMappingURL=index.js.map
4602
5426
  //# sourceMappingURL=index.js.map