@stack0/sdk 0.5.8 → 0.5.11

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.mjs CHANGED
@@ -416,6 +416,69 @@ var Events = class {
416
416
  }
417
417
  };
418
418
 
419
+ // src/mail/mailboxes.ts
420
+ var Mailboxes = class {
421
+ constructor(http) {
422
+ this.http = http;
423
+ }
424
+ /**
425
+ * Create a new mailbox
426
+ */
427
+ async create(request) {
428
+ return this.http.post("/mail/mailboxes", request);
429
+ }
430
+ /**
431
+ * Get a mailbox by ID
432
+ */
433
+ async get(id) {
434
+ return this.http.get(`/mail/mailboxes/${id}`);
435
+ }
436
+ /**
437
+ * List mailboxes with optional filters
438
+ */
439
+ async list(request) {
440
+ const params = new URLSearchParams();
441
+ if (request?.projectSlug) params.set("projectSlug", request.projectSlug);
442
+ if (request?.environment) params.set("environment", request.environment);
443
+ if (request?.domain) params.set("domain", request.domain);
444
+ if (request?.status) params.set("status", request.status);
445
+ if (request?.limit) params.set("limit", String(request.limit));
446
+ if (request?.cursor) params.set("cursor", request.cursor);
447
+ const qs = params.toString();
448
+ return this.http.get(`/mail/mailboxes${qs ? `?${qs}` : ""}`);
449
+ }
450
+ /**
451
+ * Update a mailbox
452
+ */
453
+ async update(request) {
454
+ const { id, ...data } = request;
455
+ return this.http.patch(`/mail/mailboxes/${id}`, data);
456
+ }
457
+ /**
458
+ * Delete a mailbox
459
+ */
460
+ async delete(id) {
461
+ return this.http.delete(`/mail/mailboxes/${id}`);
462
+ }
463
+ /**
464
+ * List inbound messages across mailboxes
465
+ */
466
+ async listMessages(request) {
467
+ const params = new URLSearchParams();
468
+ if (request?.mailboxId) params.set("mailboxId", request.mailboxId);
469
+ if (request?.limit) params.set("limit", String(request.limit));
470
+ if (request?.cursor) params.set("cursor", request.cursor);
471
+ const qs = params.toString();
472
+ return this.http.get(`/mail/mailboxes/messages${qs ? `?${qs}` : ""}`);
473
+ }
474
+ /**
475
+ * Get an inbound message by ID
476
+ */
477
+ async getMessage(id) {
478
+ return this.http.get(`/mail/mailboxes/messages/${id}`);
479
+ }
480
+ };
481
+
419
482
  // src/mail/sequences.ts
420
483
  var Sequences = class {
421
484
  constructor(http) {
@@ -698,6 +761,8 @@ var Mail = class {
698
761
  sequences;
699
762
  /** Track and manage custom events */
700
763
  events;
764
+ /** Manage agent mailboxes */
765
+ mailboxes;
701
766
  constructor(config) {
702
767
  this.http = new HttpClient(config);
703
768
  this.domains = new Domains(this.http);
@@ -707,6 +772,7 @@ var Mail = class {
707
772
  this.campaigns = new Campaigns(this.http);
708
773
  this.sequences = new Sequences(this.http);
709
774
  this.events = new Events(this.http);
775
+ this.mailboxes = new Mailboxes(this.http);
710
776
  }
711
777
  // ============================================================================
712
778
  // TRANSACTIONAL EMAILS
@@ -959,6 +1025,27 @@ var CDN = class {
959
1025
  }
960
1026
  return this.confirmUpload(assetId);
961
1027
  }
1028
+ /**
1029
+ * Upload a file from a remote URL (server-side fetch).
1030
+ * The server streams the file directly from the source URL into storage,
1031
+ * so the client never touches the bytes. Ideal for serverless environments
1032
+ * with tight memory limits.
1033
+ *
1034
+ * @example
1035
+ * ```typescript
1036
+ * const asset = await cdn.uploadFromUrl({
1037
+ * projectSlug: 'my-project',
1038
+ * sourceUrl: 'https://replicate.delivery/output/video.mp4',
1039
+ * filename: 'video.mp4',
1040
+ * mimeType: 'video/mp4',
1041
+ * });
1042
+ * console.log(asset.cdnUrl);
1043
+ * ```
1044
+ */
1045
+ async uploadFromUrl(request) {
1046
+ const response = await this.http.post("/cdn/upload-from-url", request);
1047
+ return this.convertAssetDates(response);
1048
+ }
962
1049
  /**
963
1050
  * Get an asset by ID
964
1051
  *
@@ -2011,6 +2098,204 @@ var CDN = class {
2011
2098
  convertMergeJobWithOutputDates(job) {
2012
2099
  return this.convertMergeJobDates(job);
2013
2100
  }
2101
+ // ============================================================================
2102
+ // S3 Import Methods
2103
+ // ============================================================================
2104
+ /**
2105
+ * Create an S3 import job to bulk import files from an external S3 bucket.
2106
+ * Requires Pro plan or higher.
2107
+ *
2108
+ * @example
2109
+ * ```typescript
2110
+ * // Using IAM credentials
2111
+ * const job = await cdn.createImport({
2112
+ * projectSlug: 'my-project',
2113
+ * sourceBucket: 'my-external-bucket',
2114
+ * sourceRegion: 'us-east-1',
2115
+ * sourcePrefix: 'images/',
2116
+ * authType: 'iam_credentials',
2117
+ * accessKeyId: 'AKIA...',
2118
+ * secretAccessKey: 'secret...',
2119
+ * pathMode: 'flatten',
2120
+ * notifyEmail: 'admin@example.com',
2121
+ * });
2122
+ *
2123
+ * // Using role assumption
2124
+ * const job = await cdn.createImport({
2125
+ * projectSlug: 'my-project',
2126
+ * sourceBucket: 'partner-bucket',
2127
+ * sourceRegion: 'eu-west-1',
2128
+ * authType: 'role_assumption',
2129
+ * roleArn: 'arn:aws:iam::123456789012:role/Stack0ImportRole',
2130
+ * externalId: 'optional-external-id',
2131
+ * pathMode: 'preserve',
2132
+ * targetFolder: '/imported',
2133
+ * });
2134
+ *
2135
+ * console.log(`Import job started: ${job.importId}`);
2136
+ * ```
2137
+ */
2138
+ async createImport(request) {
2139
+ const response = await this.http.post("/cdn/imports", request);
2140
+ return this.convertCreateImportDates(response);
2141
+ }
2142
+ /**
2143
+ * Get an import job by ID
2144
+ *
2145
+ * @example
2146
+ * ```typescript
2147
+ * const job = await cdn.getImport('import-id');
2148
+ * console.log(`Status: ${job.status}`);
2149
+ * console.log(`Progress: ${job.processedFiles}/${job.totalFiles} files`);
2150
+ * console.log(`Bytes: ${job.processedBytes}/${job.totalBytes}`);
2151
+ * ```
2152
+ */
2153
+ async getImport(importId) {
2154
+ const response = await this.http.get(`/cdn/imports/${importId}`);
2155
+ return response ? this.convertImportJobDates(response) : null;
2156
+ }
2157
+ /**
2158
+ * List import jobs with pagination and filters
2159
+ *
2160
+ * @example
2161
+ * ```typescript
2162
+ * const { imports, total, hasMore } = await cdn.listImports({
2163
+ * projectSlug: 'my-project',
2164
+ * status: 'importing',
2165
+ * limit: 20,
2166
+ * });
2167
+ *
2168
+ * for (const job of imports) {
2169
+ * console.log(`${job.sourceBucket}: ${job.processedFiles}/${job.totalFiles}`);
2170
+ * }
2171
+ * ```
2172
+ */
2173
+ async listImports(request) {
2174
+ const params = new URLSearchParams();
2175
+ params.set("projectSlug", request.projectSlug);
2176
+ if (request.environment) params.set("environment", request.environment);
2177
+ if (request.status) params.set("status", request.status);
2178
+ if (request.sortBy) params.set("sortBy", request.sortBy);
2179
+ if (request.sortOrder) params.set("sortOrder", request.sortOrder);
2180
+ if (request.limit) params.set("limit", request.limit.toString());
2181
+ if (request.offset) params.set("offset", request.offset.toString());
2182
+ const response = await this.http.get(`/cdn/imports?${params.toString()}`);
2183
+ return {
2184
+ ...response,
2185
+ imports: response.imports.map((job) => this.convertImportJobSummaryDates(job))
2186
+ };
2187
+ }
2188
+ /**
2189
+ * Cancel a running import job
2190
+ *
2191
+ * Files already imported will remain. Only pending/validating/importing jobs can be cancelled.
2192
+ *
2193
+ * @example
2194
+ * ```typescript
2195
+ * const result = await cdn.cancelImport('import-id');
2196
+ * console.log(`Cancelled: ${result.success}`);
2197
+ * ```
2198
+ */
2199
+ async cancelImport(importId) {
2200
+ return this.http.post(`/cdn/imports/${importId}/cancel`, {});
2201
+ }
2202
+ /**
2203
+ * Retry failed files in a completed or failed import job
2204
+ *
2205
+ * This resets failed files to pending and re-queues the import for processing.
2206
+ *
2207
+ * @example
2208
+ * ```typescript
2209
+ * const result = await cdn.retryImport('import-id');
2210
+ * console.log(`Retrying ${result.retriedCount} files`);
2211
+ * ```
2212
+ */
2213
+ async retryImport(importId) {
2214
+ return this.http.post(`/cdn/imports/${importId}/retry`, {});
2215
+ }
2216
+ /**
2217
+ * List files in an import job with optional status filter
2218
+ *
2219
+ * @example
2220
+ * ```typescript
2221
+ * // List all files
2222
+ * const { files, total } = await cdn.listImportFiles({
2223
+ * importId: 'import-id',
2224
+ * limit: 100,
2225
+ * });
2226
+ *
2227
+ * // List only failed files
2228
+ * const { files: failedFiles } = await cdn.listImportFiles({
2229
+ * importId: 'import-id',
2230
+ * status: 'failed',
2231
+ * });
2232
+ *
2233
+ * for (const file of failedFiles) {
2234
+ * console.log(`${file.sourceKey}: ${file.errorMessage}`);
2235
+ * }
2236
+ * ```
2237
+ */
2238
+ async listImportFiles(request) {
2239
+ const params = new URLSearchParams();
2240
+ if (request.status) params.set("status", request.status);
2241
+ if (request.sortBy) params.set("sortBy", request.sortBy);
2242
+ if (request.sortOrder) params.set("sortOrder", request.sortOrder);
2243
+ if (request.limit) params.set("limit", request.limit.toString());
2244
+ if (request.offset) params.set("offset", request.offset.toString());
2245
+ const query = params.toString();
2246
+ const response = await this.http.get(
2247
+ `/cdn/imports/${request.importId}/files${query ? `?${query}` : ""}`
2248
+ );
2249
+ return {
2250
+ ...response,
2251
+ files: response.files.map((file) => this.convertImportFileDates(file))
2252
+ };
2253
+ }
2254
+ convertCreateImportDates(response) {
2255
+ if (typeof response.createdAt === "string") {
2256
+ response.createdAt = new Date(response.createdAt);
2257
+ }
2258
+ return response;
2259
+ }
2260
+ convertImportJobDates(job) {
2261
+ if (typeof job.createdAt === "string") {
2262
+ job.createdAt = new Date(job.createdAt);
2263
+ }
2264
+ if (job.updatedAt && typeof job.updatedAt === "string") {
2265
+ job.updatedAt = new Date(job.updatedAt);
2266
+ }
2267
+ if (job.startedAt && typeof job.startedAt === "string") {
2268
+ job.startedAt = new Date(job.startedAt);
2269
+ }
2270
+ if (job.completedAt && typeof job.completedAt === "string") {
2271
+ job.completedAt = new Date(job.completedAt);
2272
+ }
2273
+ return job;
2274
+ }
2275
+ convertImportJobSummaryDates(job) {
2276
+ if (typeof job.createdAt === "string") {
2277
+ job.createdAt = new Date(job.createdAt);
2278
+ }
2279
+ if (job.startedAt && typeof job.startedAt === "string") {
2280
+ job.startedAt = new Date(job.startedAt);
2281
+ }
2282
+ if (job.completedAt && typeof job.completedAt === "string") {
2283
+ job.completedAt = new Date(job.completedAt);
2284
+ }
2285
+ return job;
2286
+ }
2287
+ convertImportFileDates(file) {
2288
+ if (typeof file.createdAt === "string") {
2289
+ file.createdAt = new Date(file.createdAt);
2290
+ }
2291
+ if (file.completedAt && typeof file.completedAt === "string") {
2292
+ file.completedAt = new Date(file.completedAt);
2293
+ }
2294
+ if (file.lastAttemptAt && typeof file.lastAttemptAt === "string") {
2295
+ file.lastAttemptAt = new Date(file.lastAttemptAt);
2296
+ }
2297
+ return file;
2298
+ }
2014
2299
  };
2015
2300
 
2016
2301
  // src/screenshots/client.ts
@@ -3603,18 +3888,104 @@ var Productivity = class {
3603
3888
  return this.http.delete(`/integrations/productivity/tables/${tableId}/rows/${rowId}?connectionId=${connectionId}`);
3604
3889
  }
3605
3890
  };
3891
+ var CalendarClient = class {
3892
+ http;
3893
+ constructor(http) {
3894
+ this.http = http;
3895
+ }
3896
+ async listCalendars(connectionId, options) {
3897
+ const params = new URLSearchParams({ connectionId });
3898
+ if (options?.cursor) params.set("cursor", options.cursor);
3899
+ if (options?.limit) params.set("limit", String(options.limit));
3900
+ return this.http.get(`/integrations/calendar/calendars?${params}`);
3901
+ }
3902
+ async listEvents(connectionId, calendarId, options) {
3903
+ const params = new URLSearchParams({ connectionId, calendarId });
3904
+ if (options?.cursor) params.set("cursor", options.cursor);
3905
+ if (options?.limit) params.set("limit", String(options.limit));
3906
+ if (options?.timeMin) params.set("timeMin", options.timeMin.toISOString());
3907
+ if (options?.timeMax) params.set("timeMax", options.timeMax.toISOString());
3908
+ if (options?.query) params.set("query", options.query);
3909
+ return this.http.get(`/integrations/calendar/events?${params}`);
3910
+ }
3911
+ async getEvent(connectionId, calendarId, eventId) {
3912
+ return this.http.get(
3913
+ `/integrations/calendar/events/${eventId}?connectionId=${connectionId}&calendarId=${calendarId}`
3914
+ );
3915
+ }
3916
+ async createEvent(connectionId, calendarId, data) {
3917
+ return this.http.post("/integrations/calendar/events", { connectionId, calendarId, data });
3918
+ }
3919
+ async updateEvent(connectionId, calendarId, eventId, data) {
3920
+ return this.http.patch(`/integrations/calendar/events/${eventId}`, { connectionId, calendarId, data });
3921
+ }
3922
+ async deleteEvent(connectionId, calendarId, eventId) {
3923
+ return this.http.delete(
3924
+ `/integrations/calendar/events/${eventId}?connectionId=${connectionId}&calendarId=${calendarId}`
3925
+ );
3926
+ }
3927
+ };
3928
+ var Mail2 = class {
3929
+ http;
3930
+ constructor(http) {
3931
+ this.http = http;
3932
+ }
3933
+ async listMessages(connectionId, options) {
3934
+ const params = new URLSearchParams({ connectionId });
3935
+ if (options?.cursor) params.set("cursor", options.cursor);
3936
+ if (options?.limit) params.set("limit", String(options.limit));
3937
+ if (options?.query) params.set("query", options.query);
3938
+ if (options?.labelIds) {
3939
+ for (const labelId of options.labelIds) {
3940
+ params.append("labelIds", labelId);
3941
+ }
3942
+ }
3943
+ return this.http.get(`/integrations/email/messages?${params}`);
3944
+ }
3945
+ async getMessage(connectionId, messageId) {
3946
+ return this.http.get(`/integrations/email/messages/${messageId}?connectionId=${connectionId}`);
3947
+ }
3948
+ async sendMessage(connectionId, data) {
3949
+ return this.http.post("/integrations/email/messages/send", { connectionId, data });
3950
+ }
3951
+ async listThreads(connectionId, options) {
3952
+ const params = new URLSearchParams({ connectionId });
3953
+ if (options?.cursor) params.set("cursor", options.cursor);
3954
+ if (options?.limit) params.set("limit", String(options.limit));
3955
+ if (options?.query) params.set("query", options.query);
3956
+ if (options?.labelIds) {
3957
+ for (const labelId of options.labelIds) {
3958
+ params.append("labelIds", labelId);
3959
+ }
3960
+ }
3961
+ return this.http.get(`/integrations/email/threads?${params}`);
3962
+ }
3963
+ async getThread(connectionId, threadId) {
3964
+ return this.http.get(`/integrations/email/threads/${threadId}?connectionId=${connectionId}`);
3965
+ }
3966
+ async listLabels(connectionId) {
3967
+ const result = await this.http.get(
3968
+ `/integrations/email/labels?connectionId=${connectionId}`
3969
+ );
3970
+ return result.labels;
3971
+ }
3972
+ };
3606
3973
  var Integrations = class {
3607
3974
  http;
3608
3975
  crm;
3609
3976
  storage;
3610
3977
  communication;
3611
3978
  productivity;
3979
+ calendar;
3980
+ mail;
3612
3981
  constructor(config) {
3613
3982
  this.http = new HttpClient(config);
3614
3983
  this.crm = new CRM(this.http);
3615
3984
  this.storage = new Storage(this.http);
3616
3985
  this.communication = new Communication(this.http);
3617
3986
  this.productivity = new Productivity(this.http);
3987
+ this.calendar = new CalendarClient(this.http);
3988
+ this.mail = new Mail2(this.http);
3618
3989
  }
3619
3990
  // ============================================================================
3620
3991
  // CONNECTORS
@@ -3652,6 +4023,7 @@ var Integrations = class {
3652
4023
  if (request?.environment) params.set("environment", request.environment);
3653
4024
  if (request?.connectorSlug) params.set("connectorSlug", request.connectorSlug);
3654
4025
  if (request?.status) params.set("status", request.status);
4026
+ if (request?.endUserId) params.set("endUserId", request.endUserId);
3655
4027
  if (request?.limit) params.set("limit", request.limit.toString());
3656
4028
  const queryString = params.toString();
3657
4029
  const response = await this.http.get(
@@ -3685,6 +4057,22 @@ var Integrations = class {
3685
4057
  async initiateOAuth(request) {
3686
4058
  return this.http.post("/integrations/connections/oauth/initiate", request);
3687
4059
  }
4060
+ /**
4061
+ * Create a connection session for an end user
4062
+ *
4063
+ * @example
4064
+ * ```typescript
4065
+ * const { authUrl, sessionId } = await integrations.createConnectionSession({
4066
+ * endUserId: 'user_123',
4067
+ * connectorSlug: 'google-calendar',
4068
+ * redirectUrl: 'https://yourapp.com/oauth/callback',
4069
+ * });
4070
+ * // Redirect user to authUrl
4071
+ * ```
4072
+ */
4073
+ async createConnectionSession(request) {
4074
+ return this.http.post("/integrations/connections/session", request);
4075
+ }
3688
4076
  /**
3689
4077
  * Complete OAuth flow with callback data
3690
4078
  *
@@ -4617,6 +5005,535 @@ var Marketing = class {
4617
5005
  }
4618
5006
  };
4619
5007
 
5008
+ // src/workflows/client.ts
5009
+ var Workflows = class {
5010
+ http;
5011
+ constructor(config) {
5012
+ this.http = new HttpClient(config);
5013
+ }
5014
+ // ==========================================================================
5015
+ // WORKFLOW CRUD
5016
+ // ==========================================================================
5017
+ /**
5018
+ * Create a new workflow
5019
+ *
5020
+ * @example
5021
+ * ```typescript
5022
+ * const workflow = await workflows.create({
5023
+ * slug: 'content-pipeline',
5024
+ * name: 'Content Generation Pipeline',
5025
+ * steps: [
5026
+ * {
5027
+ * id: 'generate',
5028
+ * name: 'Generate Content',
5029
+ * type: 'llm',
5030
+ * provider: 'anthropic',
5031
+ * model: 'claude-sonnet-4-20250514',
5032
+ * config: {
5033
+ * prompt: 'Write a blog post about {{topic}}',
5034
+ * maxTokens: 2000,
5035
+ * },
5036
+ * },
5037
+ * ],
5038
+ * variables: [
5039
+ * { name: 'topic', type: 'string', required: true },
5040
+ * ],
5041
+ * });
5042
+ * ```
5043
+ */
5044
+ async create(request) {
5045
+ return this.http.post("/workflows/workflows", request);
5046
+ }
5047
+ /**
5048
+ * Get a workflow by ID or slug
5049
+ *
5050
+ * @example
5051
+ * ```typescript
5052
+ * const workflow = await workflows.get({ slug: 'content-pipeline' });
5053
+ * console.log(workflow.steps);
5054
+ * ```
5055
+ */
5056
+ async get(request) {
5057
+ const params = new URLSearchParams();
5058
+ if (request.slug) params.set("slug", request.slug);
5059
+ if (request.environment) params.set("environment", request.environment);
5060
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
5061
+ const path = request.id ? `/workflows/workflows/${request.id}` : `/workflows/workflows?${params.toString()}`;
5062
+ const response = await this.http.get(path);
5063
+ return this.convertDates(response);
5064
+ }
5065
+ /**
5066
+ * List workflows with pagination
5067
+ *
5068
+ * @example
5069
+ * ```typescript
5070
+ * const { items, nextCursor } = await workflows.list({
5071
+ * environment: 'production',
5072
+ * isActive: true,
5073
+ * limit: 20,
5074
+ * });
5075
+ * ```
5076
+ */
5077
+ async list(request = {}) {
5078
+ const params = new URLSearchParams();
5079
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
5080
+ if (request.environment) params.set("environment", request.environment);
5081
+ if (request.isActive !== void 0) params.set("isActive", request.isActive.toString());
5082
+ if (request.limit) params.set("limit", request.limit.toString());
5083
+ if (request.cursor) params.set("cursor", request.cursor);
5084
+ const query = params.toString();
5085
+ const response = await this.http.get(
5086
+ `/workflows/workflows${query ? `?${query}` : ""}`
5087
+ );
5088
+ return {
5089
+ ...response,
5090
+ items: response.items.map((item) => this.convertDates(item))
5091
+ };
5092
+ }
5093
+ /**
5094
+ * Update a workflow
5095
+ *
5096
+ * @example
5097
+ * ```typescript
5098
+ * await workflows.update({
5099
+ * id: 'workflow-id',
5100
+ * name: 'Updated Pipeline',
5101
+ * isActive: false,
5102
+ * });
5103
+ * ```
5104
+ */
5105
+ async update(request) {
5106
+ const { id, ...data } = request;
5107
+ return this.http.post(
5108
+ `/workflows/workflows/${id}`,
5109
+ data
5110
+ );
5111
+ }
5112
+ /**
5113
+ * Delete a workflow
5114
+ *
5115
+ * @example
5116
+ * ```typescript
5117
+ * await workflows.delete({ id: 'workflow-id' });
5118
+ * ```
5119
+ */
5120
+ async delete(request) {
5121
+ return this.http.deleteWithBody(
5122
+ `/workflows/workflows/${request.id}`,
5123
+ request
5124
+ );
5125
+ }
5126
+ // ==========================================================================
5127
+ // WORKFLOW EXECUTION
5128
+ // ==========================================================================
5129
+ /**
5130
+ * Run a workflow
5131
+ *
5132
+ * @example
5133
+ * ```typescript
5134
+ * const run = await workflows.run({
5135
+ * workflowSlug: 'content-pipeline',
5136
+ * variables: {
5137
+ * topic: 'artificial intelligence',
5138
+ * },
5139
+ * webhook: {
5140
+ * url: 'https://example.com/webhook',
5141
+ * secret: 'webhook-secret',
5142
+ * },
5143
+ * });
5144
+ * console.log(run.id, run.status);
5145
+ * ```
5146
+ */
5147
+ async run(request) {
5148
+ return this.http.post("/workflows/workflows/run", request);
5149
+ }
5150
+ /**
5151
+ * Get a workflow run by ID
5152
+ *
5153
+ * @example
5154
+ * ```typescript
5155
+ * const run = await workflows.getRun({ id: 'run-id' });
5156
+ * if (run.status === 'completed') {
5157
+ * console.log(run.output);
5158
+ * }
5159
+ * ```
5160
+ */
5161
+ async getRun(request) {
5162
+ const params = new URLSearchParams();
5163
+ if (request.environment) params.set("environment", request.environment);
5164
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
5165
+ const query = params.toString();
5166
+ const response = await this.http.get(
5167
+ `/workflows/workflows/runs/${request.id}${query ? `?${query}` : ""}`
5168
+ );
5169
+ return this.convertRunDates(response);
5170
+ }
5171
+ /**
5172
+ * List workflow runs with pagination
5173
+ *
5174
+ * @example
5175
+ * ```typescript
5176
+ * const { items } = await workflows.listRuns({
5177
+ * workflowId: 'workflow-id',
5178
+ * status: 'completed',
5179
+ * });
5180
+ * ```
5181
+ */
5182
+ async listRuns(request = {}) {
5183
+ const params = new URLSearchParams();
5184
+ if (request.workflowId) params.set("workflowId", request.workflowId);
5185
+ if (request.workflowSlug) params.set("workflowSlug", request.workflowSlug);
5186
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
5187
+ if (request.environment) params.set("environment", request.environment);
5188
+ if (request.status) params.set("status", request.status);
5189
+ if (request.limit) params.set("limit", request.limit.toString());
5190
+ if (request.cursor) params.set("cursor", request.cursor);
5191
+ const query = params.toString();
5192
+ const response = await this.http.get(
5193
+ `/workflows/workflows/runs${query ? `?${query}` : ""}`
5194
+ );
5195
+ return {
5196
+ ...response,
5197
+ items: response.items.map((item) => this.convertRunDates(item))
5198
+ };
5199
+ }
5200
+ /**
5201
+ * Cancel a running workflow
5202
+ *
5203
+ * @example
5204
+ * ```typescript
5205
+ * await workflows.cancelRun({ id: 'run-id' });
5206
+ * ```
5207
+ */
5208
+ async cancelRun(request) {
5209
+ return this.http.post(
5210
+ `/workflows/workflows/runs/${request.id}/cancel`,
5211
+ {}
5212
+ );
5213
+ }
5214
+ /**
5215
+ * Run a workflow and wait for completion
5216
+ *
5217
+ * @example
5218
+ * ```typescript
5219
+ * const run = await workflows.runAndWait({
5220
+ * workflowSlug: 'content-pipeline',
5221
+ * variables: { topic: 'AI' },
5222
+ * });
5223
+ * console.log(run.output);
5224
+ * ```
5225
+ */
5226
+ async runAndWait(request, options = {}) {
5227
+ const { pollInterval = 2e3, timeout = 6e5 } = options;
5228
+ const startTime = Date.now();
5229
+ const { id } = await this.run(request);
5230
+ while (Date.now() - startTime < timeout) {
5231
+ const run = await this.getRun({
5232
+ id,
5233
+ environment: request.environment,
5234
+ projectSlug: request.projectSlug
5235
+ });
5236
+ if (run.status === "completed" || run.status === "failed" || run.status === "cancelled") {
5237
+ if (run.status === "failed") {
5238
+ throw new Error(run.error || "Workflow execution failed");
5239
+ }
5240
+ return run;
5241
+ }
5242
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
5243
+ }
5244
+ throw new Error("Workflow execution timed out");
5245
+ }
5246
+ // ==========================================================================
5247
+ // HELPERS
5248
+ // ==========================================================================
5249
+ convertDates(workflow) {
5250
+ if (typeof workflow.createdAt === "string") {
5251
+ workflow.createdAt = new Date(workflow.createdAt);
5252
+ }
5253
+ if (typeof workflow.updatedAt === "string") {
5254
+ workflow.updatedAt = new Date(workflow.updatedAt);
5255
+ }
5256
+ return workflow;
5257
+ }
5258
+ convertRunDates(run) {
5259
+ if (typeof run.createdAt === "string") {
5260
+ run.createdAt = new Date(run.createdAt);
5261
+ }
5262
+ if (run.startedAt && typeof run.startedAt === "string") {
5263
+ run.startedAt = new Date(run.startedAt);
5264
+ }
5265
+ if (run.completedAt && typeof run.completedAt === "string") {
5266
+ run.completedAt = new Date(run.completedAt);
5267
+ }
5268
+ return run;
5269
+ }
5270
+ };
5271
+
5272
+ // src/memory/agents.ts
5273
+ var MemoryAgents = class {
5274
+ constructor(http) {
5275
+ this.http = http;
5276
+ }
5277
+ /**
5278
+ * Create a new memory agent
5279
+ */
5280
+ async create(request) {
5281
+ return this.http.post("/memory/agents", request);
5282
+ }
5283
+ /**
5284
+ * List all memory agents
5285
+ */
5286
+ async list(params = {}) {
5287
+ const qs = new URLSearchParams();
5288
+ if (params.environment) qs.set("environment", params.environment);
5289
+ const q = qs.toString();
5290
+ return this.http.get(`/memory/agents${q ? `?${q}` : ""}`);
5291
+ }
5292
+ /**
5293
+ * Get a memory agent by ID
5294
+ */
5295
+ async get(agentId) {
5296
+ return this.http.get(`/memory/agents/${agentId}`);
5297
+ }
5298
+ /**
5299
+ * Update a memory agent
5300
+ */
5301
+ async update(agentId, request) {
5302
+ return this.http.patch(`/memory/agents/${agentId}`, request);
5303
+ }
5304
+ /**
5305
+ * Delete a memory agent
5306
+ */
5307
+ async delete(agentId) {
5308
+ return this.http.delete(`/memory/agents/${agentId}`);
5309
+ }
5310
+ };
5311
+
5312
+ // src/memory/collections.ts
5313
+ var MemoryCollections = class {
5314
+ constructor(http) {
5315
+ this.http = http;
5316
+ }
5317
+ /**
5318
+ * Create a new collection for an agent
5319
+ */
5320
+ async create(request) {
5321
+ return this.http.post(`/memory/agents/${request.agentId}/collections`, {
5322
+ name: request.name,
5323
+ slug: request.slug,
5324
+ description: request.description,
5325
+ compaction: request.compaction,
5326
+ retention: request.retention
5327
+ });
5328
+ }
5329
+ /**
5330
+ * List all collections for an agent
5331
+ */
5332
+ async list(agentId) {
5333
+ return this.http.get(`/memory/agents/${agentId}/collections`);
5334
+ }
5335
+ /**
5336
+ * Get a collection by slug
5337
+ */
5338
+ async get(agentId, collectionSlug) {
5339
+ return this.http.get(`/memory/agents/${agentId}/collections/${collectionSlug}`);
5340
+ }
5341
+ /**
5342
+ * Update a collection
5343
+ */
5344
+ async update(agentId, collectionSlug, request) {
5345
+ return this.http.patch(
5346
+ `/memory/agents/${agentId}/collections/${collectionSlug}`,
5347
+ request
5348
+ );
5349
+ }
5350
+ /**
5351
+ * Delete a collection
5352
+ */
5353
+ async delete(agentId, collectionSlug) {
5354
+ return this.http.delete(`/memory/agents/${agentId}/collections/${collectionSlug}`);
5355
+ }
5356
+ /**
5357
+ * Get collection statistics
5358
+ */
5359
+ async stats(agentId, collectionSlug) {
5360
+ return this.http.get(
5361
+ `/memory/agents/${agentId}/collections/${collectionSlug}/stats`
5362
+ );
5363
+ }
5364
+ /**
5365
+ * Trigger compaction for a collection
5366
+ */
5367
+ async compact(agentId, collectionSlug, request = {}) {
5368
+ return this.http.post(
5369
+ `/memory/agents/${agentId}/collections/${collectionSlug}/compact`,
5370
+ request
5371
+ );
5372
+ }
5373
+ /**
5374
+ * Get a compaction job by ID
5375
+ */
5376
+ async getCompactionJob(agentId, collectionSlug, jobId) {
5377
+ return this.http.get(
5378
+ `/memory/agents/${agentId}/collections/${collectionSlug}/compact/${jobId}`
5379
+ );
5380
+ }
5381
+ };
5382
+
5383
+ // src/memory/entities.ts
5384
+ var MemoryEntities = class {
5385
+ constructor(http) {
5386
+ this.http = http;
5387
+ }
5388
+ async list(params) {
5389
+ const qs = new URLSearchParams();
5390
+ qs.set("agentId", params.agentId);
5391
+ if (params.type) qs.set("type", params.type);
5392
+ if (params.limit) qs.set("limit", params.limit.toString());
5393
+ if (params.offset) qs.set("offset", params.offset.toString());
5394
+ const q = qs.toString();
5395
+ return this.http.get(`/memory/entities${q ? `?${q}` : ""}`);
5396
+ }
5397
+ async get(entityId) {
5398
+ return this.http.get(`/memory/entities/${entityId}`);
5399
+ }
5400
+ async getRelations(entityId) {
5401
+ return this.http.get(`/memory/entities/${entityId}/relations`);
5402
+ }
5403
+ };
5404
+
5405
+ // src/memory/client.ts
5406
+ var Memory = class {
5407
+ http;
5408
+ /** Manage memory agents */
5409
+ agents;
5410
+ /** Manage memory collections */
5411
+ collections;
5412
+ /** Manage extracted entities */
5413
+ entities;
5414
+ constructor(config) {
5415
+ this.http = new HttpClient(config);
5416
+ this.agents = new MemoryAgents(this.http);
5417
+ this.collections = new MemoryCollections(this.http);
5418
+ this.entities = new MemoryEntities(this.http);
5419
+ }
5420
+ // ============================================================================
5421
+ // MEMORY OPERATIONS
5422
+ // ============================================================================
5423
+ /**
5424
+ * Store a memory
5425
+ *
5426
+ * @example
5427
+ * ```typescript
5428
+ * const memory = await stack0.memory.store({
5429
+ * agentId: 'agent_123',
5430
+ * content: 'User prefers dark mode',
5431
+ * type: 'preference',
5432
+ * tags: ['ui', 'settings'],
5433
+ * });
5434
+ * ```
5435
+ */
5436
+ async store(request) {
5437
+ return this.http.post("/memory/memories", request);
5438
+ }
5439
+ /**
5440
+ * Store multiple memories in a batch
5441
+ *
5442
+ * @example
5443
+ * ```typescript
5444
+ * const results = await stack0.memory.storeBatch({
5445
+ * agentId: 'agent_123',
5446
+ * memories: [
5447
+ * { content: 'User prefers dark mode', type: 'preference' },
5448
+ * { content: 'User is based in NYC', type: 'fact' },
5449
+ * ],
5450
+ * });
5451
+ * ```
5452
+ */
5453
+ async storeBatch(request) {
5454
+ return this.http.post("/memory/memories/batch", request);
5455
+ }
5456
+ /**
5457
+ * Recall memories using semantic search (vector similarity)
5458
+ *
5459
+ * @example
5460
+ * ```typescript
5461
+ * const results = await stack0.memory.recall({
5462
+ * agentId: 'agent_123',
5463
+ * query: 'What are the user preferences?',
5464
+ * limit: 10,
5465
+ * });
5466
+ * ```
5467
+ */
5468
+ async recall(request) {
5469
+ return this.http.post("/memory/memories/recall", request);
5470
+ }
5471
+ /**
5472
+ * Search memories using full-text search
5473
+ *
5474
+ * @example
5475
+ * ```typescript
5476
+ * const results = await stack0.memory.search({
5477
+ * agentId: 'agent_123',
5478
+ * query: 'dark mode',
5479
+ * limit: 20,
5480
+ * });
5481
+ * ```
5482
+ */
5483
+ async search(request) {
5484
+ return this.http.post("/memory/memories/search", request);
5485
+ }
5486
+ /**
5487
+ * Get a memory by ID
5488
+ */
5489
+ async get(memoryId) {
5490
+ return this.http.get(`/memory/memories/${memoryId}`);
5491
+ }
5492
+ /**
5493
+ * List memories with optional filters
5494
+ *
5495
+ * @example
5496
+ * ```typescript
5497
+ * const memories = await stack0.memory.list({
5498
+ * agentId: 'agent_123',
5499
+ * type: 'preference',
5500
+ * limit: 50,
5501
+ * });
5502
+ * ```
5503
+ */
5504
+ async list(params) {
5505
+ const qs = new URLSearchParams();
5506
+ qs.set("agentId", params.agentId);
5507
+ if (params.collectionSlug) qs.set("collectionSlug", params.collectionSlug);
5508
+ if (params.type) qs.set("type", params.type);
5509
+ if (params.tier) qs.set("tier", params.tier);
5510
+ if (params.limit) qs.set("limit", params.limit.toString());
5511
+ if (params.offset) qs.set("offset", params.offset.toString());
5512
+ if (params.sortBy) qs.set("sortBy", params.sortBy);
5513
+ if (params.sortOrder) qs.set("sortOrder", params.sortOrder);
5514
+ const q = qs.toString();
5515
+ return this.http.get(`/memory/memories${q ? `?${q}` : ""}`);
5516
+ }
5517
+ /**
5518
+ * Update a memory
5519
+ */
5520
+ async update(memoryId, request) {
5521
+ return this.http.patch(`/memory/memories/${memoryId}`, request);
5522
+ }
5523
+ /**
5524
+ * Delete a memory by ID
5525
+ */
5526
+ async delete(memoryId) {
5527
+ return this.http.delete(`/memory/memories/${memoryId}`);
5528
+ }
5529
+ /**
5530
+ * Delete multiple memories
5531
+ */
5532
+ async deleteMany(request) {
5533
+ return this.http.deleteWithBody("/memory/memories", request);
5534
+ }
5535
+ };
5536
+
4620
5537
  // src/index.ts
4621
5538
  var Stack0 = class {
4622
5539
  mail;
@@ -4625,6 +5542,8 @@ var Stack0 = class {
4625
5542
  extraction;
4626
5543
  integrations;
4627
5544
  marketing;
5545
+ workflows;
5546
+ memory;
4628
5547
  /**
4629
5548
  * @deprecated Use `screenshots` and `extraction` instead. Will be removed in a future version.
4630
5549
  */
@@ -4640,11 +5559,13 @@ var Stack0 = class {
4640
5559
  this.extraction = new Extraction(clientConfig);
4641
5560
  this.integrations = new Integrations(clientConfig);
4642
5561
  this.marketing = new Marketing(clientConfig);
5562
+ this.workflows = new Workflows(clientConfig);
5563
+ this.memory = new Memory(clientConfig);
4643
5564
  this.webdata = new Webdata(clientConfig);
4644
5565
  }
4645
5566
  };
4646
5567
  var src_default = Stack0;
4647
5568
 
4648
- export { Audiences, CDN, Campaigns, Contacts, Domains, Events, Extraction, Integrations, Mail, Marketing, Screenshots, Sequences, Stack0, Templates, Webdata, src_default as default };
5569
+ export { Audiences, CDN, Campaigns, Contacts, Domains, Events, Extraction, Integrations, Mail, Mailboxes, Marketing, Memory, MemoryAgents, MemoryCollections, MemoryEntities, Screenshots, Sequences, Stack0, Templates, Webdata, Workflows, src_default as default };
4649
5570
  //# sourceMappingURL=index.mjs.map
4650
5571
  //# sourceMappingURL=index.mjs.map