@stack0/sdk 0.5.12 → 0.5.15

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
@@ -80,6 +80,7 @@ var Audiences = class {
80
80
  constructor(http) {
81
81
  this.http = http;
82
82
  }
83
+ http;
83
84
  /**
84
85
  * List all audiences
85
86
  */
@@ -154,6 +155,7 @@ var Campaigns = class {
154
155
  constructor(http) {
155
156
  this.http = http;
156
157
  }
158
+ http;
157
159
  /**
158
160
  * List all campaigns
159
161
  */
@@ -230,6 +232,7 @@ var Contacts = class {
230
232
  constructor(http) {
231
233
  this.http = http;
232
234
  }
235
+ http;
233
236
  /**
234
237
  * List all contacts
235
238
  */
@@ -281,6 +284,7 @@ var Domains = class {
281
284
  constructor(http) {
282
285
  this.http = http;
283
286
  }
287
+ http;
284
288
  /**
285
289
  * List all domains for the organization
286
290
  */
@@ -327,6 +331,7 @@ var Events = class {
327
331
  constructor(http) {
328
332
  this.http = http;
329
333
  }
334
+ http;
330
335
  // ============================================================================
331
336
  // EVENT DEFINITIONS
332
337
  // ============================================================================
@@ -421,6 +426,7 @@ var Mailboxes = class {
421
426
  constructor(http) {
422
427
  this.http = http;
423
428
  }
429
+ http;
424
430
  /**
425
431
  * Create a new mailbox
426
432
  */
@@ -484,6 +490,7 @@ var Sequences = class {
484
490
  constructor(http) {
485
491
  this.http = http;
486
492
  }
493
+ http;
487
494
  // ============================================================================
488
495
  // SEQUENCE CRUD
489
496
  // ============================================================================
@@ -655,6 +662,7 @@ var Sequences = class {
655
662
  if (params.limit) searchParams.set("limit", params.limit.toString());
656
663
  if (params.offset) searchParams.set("offset", params.offset.toString());
657
664
  if (params.status) searchParams.set("status", params.status);
665
+ if (params.search) searchParams.set("search", params.search);
658
666
  const query = searchParams.toString();
659
667
  return this.http.get(`/mail/sequences/${id}/entries${query ? `?${query}` : ""}`);
660
668
  }
@@ -691,6 +699,7 @@ var Templates = class {
691
699
  constructor(http) {
692
700
  this.http = http;
693
701
  }
702
+ http;
694
703
  /**
695
704
  * List all templates
696
705
  */
@@ -793,6 +802,43 @@ var Mail = class {
793
802
  async send(request) {
794
803
  return this.http.post("/mail/send", request);
795
804
  }
805
+ /**
806
+ * Reply to an inbound email with correct RFC 5322 threading headers.
807
+ * Automatically derives `from`, `to`, `subject`, `inReplyTo`, and `references`
808
+ * from the inbound webhook payload — pass through any overrides as the second
809
+ * argument.
810
+ *
811
+ * @example
812
+ * ```typescript
813
+ * // In your webhook handler:
814
+ * await mail.reply(inboundEmail, {
815
+ * text: 'Thanks for the note — talk soon.',
816
+ * });
817
+ * ```
818
+ */
819
+ async reply(inbound, body) {
820
+ const parentId = inbound.messageId;
821
+ const refs = [...inbound.references ?? [], parentId].filter(Boolean);
822
+ const subject = body.subject ?? (inbound.subject?.startsWith("Re:") ? inbound.subject : `Re: ${inbound.subject ?? ""}`);
823
+ const request = {
824
+ from: body.from ?? inbound.mailbox,
825
+ to: body.to ?? inbound.from.email,
826
+ subject,
827
+ text: body.text,
828
+ html: body.html,
829
+ replyTo: body.replyTo,
830
+ cc: body.cc,
831
+ bcc: body.bcc,
832
+ tags: body.tags,
833
+ metadata: body.metadata,
834
+ templateId: body.templateId,
835
+ templateVariables: body.templateVariables,
836
+ environment: body.environment,
837
+ inReplyTo: body.inReplyTo ?? parentId ?? void 0,
838
+ references: body.references ?? (refs.length ? refs.join(" ") : void 0)
839
+ };
840
+ return this.send(request);
841
+ }
796
842
  /**
797
843
  * Send multiple emails in a batch (up to 100)
798
844
  * Each email can have different content and recipients
@@ -1299,6 +1345,22 @@ var CDN = class {
1299
1345
  * });
1300
1346
  * console.log(`Job started: ${job.id}`);
1301
1347
  * ```
1348
+ *
1349
+ * @example Burn in a logo watermark (same config shape as image watermarks)
1350
+ * ```typescript
1351
+ * const job = await cdn.transcode({
1352
+ * projectSlug: 'my-project',
1353
+ * assetId: 'video-asset-id',
1354
+ * outputFormat: 'mp4',
1355
+ * variants: [{ quality: '1080p', codec: 'h264' }],
1356
+ * watermark: {
1357
+ * assetId: 'logo-asset-id',
1358
+ * position: 'bottom-right',
1359
+ * scale: 15, // 15% of the video width
1360
+ * opacity: 80,
1361
+ * },
1362
+ * });
1363
+ * ```
1302
1364
  */
1303
1365
  async transcode(request) {
1304
1366
  const response = await this.http.post("/cdn/video/transcode", request);
@@ -1311,6 +1373,7 @@ var CDN = class {
1311
1373
  * ```typescript
1312
1374
  * const job = await cdn.getJob('job-id');
1313
1375
  * console.log(`Status: ${job.status}, Progress: ${job.progress}%`);
1376
+ * if (job.status === 'failed') console.error(job.errorMessage);
1314
1377
  * ```
1315
1378
  */
1316
1379
  async getJob(jobId) {
@@ -1364,7 +1427,7 @@ var CDN = class {
1364
1427
  * ```
1365
1428
  */
1366
1429
  async getStreamingUrls(assetId) {
1367
- return this.http.get(`/cdn/video/stream/${assetId}`);
1430
+ return this.http.get(`/cdn/video/${assetId}/stream`);
1368
1431
  }
1369
1432
  /**
1370
1433
  * Generate a thumbnail from a video at a specific timestamp
@@ -2018,6 +2081,7 @@ var CDN = class {
2018
2081
  * output: {
2019
2082
  * format: 'mp4',
2020
2083
  * quality: '1080p',
2084
+ * aspectRatio: 'auto', // match first input's orientation ('9:16' forces vertical)
2021
2085
  * filename: 'final-video.mp4',
2022
2086
  * },
2023
2087
  * webhookUrl: 'https://your-app.com/webhook',
@@ -5495,271 +5559,6 @@ var Workflows = class {
5495
5559
  }
5496
5560
  };
5497
5561
 
5498
- // src/memory/agents.ts
5499
- var MemoryAgents = class {
5500
- constructor(http) {
5501
- this.http = http;
5502
- }
5503
- /**
5504
- * Create a new memory agent
5505
- */
5506
- async create(request) {
5507
- return this.http.post("/memory/agents", request);
5508
- }
5509
- /**
5510
- * List all memory agents
5511
- */
5512
- async list(params = {}) {
5513
- const qs = new URLSearchParams();
5514
- if (params.environment) qs.set("environment", params.environment);
5515
- const q = qs.toString();
5516
- return this.http.get(`/memory/agents${q ? `?${q}` : ""}`);
5517
- }
5518
- /**
5519
- * Get a memory agent by ID
5520
- */
5521
- async get(agentId) {
5522
- return this.http.get(`/memory/agents/${agentId}`);
5523
- }
5524
- /**
5525
- * Update a memory agent
5526
- */
5527
- async update(agentId, request) {
5528
- return this.http.patch(`/memory/agents/${agentId}`, request);
5529
- }
5530
- /**
5531
- * Delete a memory agent
5532
- */
5533
- async delete(agentId) {
5534
- return this.http.delete(`/memory/agents/${agentId}`);
5535
- }
5536
- };
5537
-
5538
- // src/memory/collections.ts
5539
- var MemoryCollections = class {
5540
- constructor(http) {
5541
- this.http = http;
5542
- }
5543
- /**
5544
- * Create a new collection for an agent
5545
- */
5546
- async create(request) {
5547
- return this.http.post(`/memory/agents/${request.agentId}/collections`, {
5548
- name: request.name,
5549
- slug: request.slug,
5550
- description: request.description,
5551
- compaction: request.compaction,
5552
- retention: request.retention
5553
- });
5554
- }
5555
- /**
5556
- * List all collections for an agent
5557
- */
5558
- async list(agentId) {
5559
- return this.http.get(`/memory/agents/${agentId}/collections`);
5560
- }
5561
- /**
5562
- * Get a collection by slug
5563
- */
5564
- async get(agentId, collectionSlug) {
5565
- return this.http.get(`/memory/agents/${agentId}/collections/${collectionSlug}`);
5566
- }
5567
- /**
5568
- * Update a collection
5569
- */
5570
- async update(agentId, collectionSlug, request) {
5571
- return this.http.patch(
5572
- `/memory/agents/${agentId}/collections/${collectionSlug}`,
5573
- request
5574
- );
5575
- }
5576
- /**
5577
- * Delete a collection
5578
- */
5579
- async delete(agentId, collectionSlug) {
5580
- return this.http.delete(`/memory/agents/${agentId}/collections/${collectionSlug}`);
5581
- }
5582
- /**
5583
- * Get collection statistics
5584
- */
5585
- async stats(agentId, collectionSlug) {
5586
- return this.http.get(
5587
- `/memory/agents/${agentId}/collections/${collectionSlug}/stats`
5588
- );
5589
- }
5590
- /**
5591
- * Trigger compaction for a collection
5592
- */
5593
- async compact(agentId, collectionSlug, request = {}) {
5594
- return this.http.post(
5595
- `/memory/agents/${agentId}/collections/${collectionSlug}/compact`,
5596
- request
5597
- );
5598
- }
5599
- /**
5600
- * Get a compaction job by ID
5601
- */
5602
- async getCompactionJob(agentId, collectionSlug, jobId) {
5603
- return this.http.get(
5604
- `/memory/agents/${agentId}/collections/${collectionSlug}/compact/${jobId}`
5605
- );
5606
- }
5607
- };
5608
-
5609
- // src/memory/entities.ts
5610
- var MemoryEntities = class {
5611
- constructor(http) {
5612
- this.http = http;
5613
- }
5614
- async list(params) {
5615
- const qs = new URLSearchParams();
5616
- qs.set("agentId", params.agentId);
5617
- if (params.type) qs.set("type", params.type);
5618
- if (params.limit) qs.set("limit", params.limit.toString());
5619
- if (params.offset) qs.set("offset", params.offset.toString());
5620
- const q = qs.toString();
5621
- return this.http.get(`/memory/entities${q ? `?${q}` : ""}`);
5622
- }
5623
- async get(entityId) {
5624
- return this.http.get(`/memory/entities/${entityId}`);
5625
- }
5626
- async getRelations(entityId) {
5627
- return this.http.get(`/memory/entities/${entityId}/relations`);
5628
- }
5629
- };
5630
-
5631
- // src/memory/client.ts
5632
- var Memory = class {
5633
- http;
5634
- /** Manage memory agents */
5635
- agents;
5636
- /** Manage memory collections */
5637
- collections;
5638
- /** Manage extracted entities */
5639
- entities;
5640
- constructor(config) {
5641
- this.http = new HttpClient(config);
5642
- this.agents = new MemoryAgents(this.http);
5643
- this.collections = new MemoryCollections(this.http);
5644
- this.entities = new MemoryEntities(this.http);
5645
- }
5646
- // ============================================================================
5647
- // MEMORY OPERATIONS
5648
- // ============================================================================
5649
- /**
5650
- * Store a memory
5651
- *
5652
- * @example
5653
- * ```typescript
5654
- * const memory = await stack0.memory.store({
5655
- * agentId: 'agent_123',
5656
- * content: 'User prefers dark mode',
5657
- * type: 'preference',
5658
- * tags: ['ui', 'settings'],
5659
- * });
5660
- * ```
5661
- */
5662
- async store(request) {
5663
- return this.http.post("/memory/memories", request);
5664
- }
5665
- /**
5666
- * Store multiple memories in a batch
5667
- *
5668
- * @example
5669
- * ```typescript
5670
- * const results = await stack0.memory.storeBatch({
5671
- * agentId: 'agent_123',
5672
- * memories: [
5673
- * { content: 'User prefers dark mode', type: 'preference' },
5674
- * { content: 'User is based in NYC', type: 'fact' },
5675
- * ],
5676
- * });
5677
- * ```
5678
- */
5679
- async storeBatch(request) {
5680
- return this.http.post("/memory/memories/batch", request);
5681
- }
5682
- /**
5683
- * Recall memories using semantic search (vector similarity)
5684
- *
5685
- * @example
5686
- * ```typescript
5687
- * const results = await stack0.memory.recall({
5688
- * agentId: 'agent_123',
5689
- * query: 'What are the user preferences?',
5690
- * limit: 10,
5691
- * });
5692
- * ```
5693
- */
5694
- async recall(request) {
5695
- return this.http.post("/memory/memories/recall", request);
5696
- }
5697
- /**
5698
- * Search memories using full-text search
5699
- *
5700
- * @example
5701
- * ```typescript
5702
- * const results = await stack0.memory.search({
5703
- * agentId: 'agent_123',
5704
- * query: 'dark mode',
5705
- * limit: 20,
5706
- * });
5707
- * ```
5708
- */
5709
- async search(request) {
5710
- return this.http.post("/memory/memories/search", request);
5711
- }
5712
- /**
5713
- * Get a memory by ID
5714
- */
5715
- async get(memoryId) {
5716
- return this.http.get(`/memory/memories/${memoryId}`);
5717
- }
5718
- /**
5719
- * List memories with optional filters
5720
- *
5721
- * @example
5722
- * ```typescript
5723
- * const memories = await stack0.memory.list({
5724
- * agentId: 'agent_123',
5725
- * type: 'preference',
5726
- * limit: 50,
5727
- * });
5728
- * ```
5729
- */
5730
- async list(params) {
5731
- const qs = new URLSearchParams();
5732
- qs.set("agentId", params.agentId);
5733
- if (params.collectionSlug) qs.set("collectionSlug", params.collectionSlug);
5734
- if (params.type) qs.set("type", params.type);
5735
- if (params.tier) qs.set("tier", params.tier);
5736
- if (params.limit) qs.set("limit", params.limit.toString());
5737
- if (params.offset) qs.set("offset", params.offset.toString());
5738
- if (params.sortBy) qs.set("sortBy", params.sortBy);
5739
- if (params.sortOrder) qs.set("sortOrder", params.sortOrder);
5740
- const q = qs.toString();
5741
- return this.http.get(`/memory/memories${q ? `?${q}` : ""}`);
5742
- }
5743
- /**
5744
- * Update a memory
5745
- */
5746
- async update(memoryId, request) {
5747
- return this.http.patch(`/memory/memories/${memoryId}`, request);
5748
- }
5749
- /**
5750
- * Delete a memory by ID
5751
- */
5752
- async delete(memoryId) {
5753
- return this.http.delete(`/memory/memories/${memoryId}`);
5754
- }
5755
- /**
5756
- * Delete multiple memories
5757
- */
5758
- async deleteMany(request) {
5759
- return this.http.deleteWithBody("/memory/memories", request);
5760
- }
5761
- };
5762
-
5763
5562
  // src/index.ts
5764
5563
  var Stack0 = class {
5765
5564
  http;
@@ -5773,7 +5572,6 @@ var Stack0 = class {
5773
5572
  integrations;
5774
5573
  marketing;
5775
5574
  workflows;
5776
- memory;
5777
5575
  /**
5778
5576
  * @deprecated Use `screenshots` and `extraction` instead. Will be removed in a future version.
5779
5577
  */
@@ -5794,7 +5592,6 @@ var Stack0 = class {
5794
5592
  this.integrations = new Integrations(clientConfig);
5795
5593
  this.marketing = new Marketing(clientConfig);
5796
5594
  this.workflows = new Workflows(clientConfig);
5797
- this.memory = new Memory(clientConfig);
5798
5595
  this.webdata = new Webdata(clientConfig);
5799
5596
  }
5800
5597
  // ============================================================================
@@ -5822,6 +5619,6 @@ var Stack0 = class {
5822
5619
  };
5823
5620
  var src_default = Stack0;
5824
5621
 
5825
- export { Audiences, CDN, Campaigns, Contacts, Crawl$ as Crawl, Crawl$, Documents, Domains, Events, Extraction, Integrations, Mail, Mailboxes, Map$ as Map, Map$, Marketing, Memory, MemoryAgents, MemoryCollections, MemoryEntities, Screenshots, Sequences, Stack0, Templates, Webdata, Workflows, src_default as default };
5622
+ export { Audiences, CDN, Campaigns, Contacts, Crawl$ as Crawl, Crawl$, Documents, Domains, Events, Extraction, Integrations, Mail, Mailboxes, Map$ as Map, Map$, Marketing, Screenshots, Sequences, Stack0, Templates, Webdata, Workflows, src_default as default };
5826
5623
  //# sourceMappingURL=index.mjs.map
5827
5624
  //# sourceMappingURL=index.mjs.map