@rymi/node 1.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -34,6 +34,9 @@ __export(index_exports, {
34
34
  AgentsResource: () => AgentsResource,
35
35
  BillingResource: () => BillingResource,
36
36
  CallsResource: () => CallsResource,
37
+ CampaignsResource: () => CampaignsResource,
38
+ ComplianceResource: () => ComplianceResource,
39
+ ContactsResource: () => ContactsResource,
37
40
  DncResource: () => DncResource,
38
41
  KeysResource: () => KeysResource,
39
42
  NumbersResource: () => NumbersResource,
@@ -42,6 +45,7 @@ __export(index_exports, {
42
45
  RymiError: () => RymiError,
43
46
  TelephonyResource: () => TelephonyResource,
44
47
  TemplatesResource: () => TemplatesResource,
48
+ ToolSecretsResource: () => ToolSecretsResource,
45
49
  WebhooksResource: () => WebhooksResource,
46
50
  default: () => index_default
47
51
  });
@@ -61,6 +65,7 @@ var RymiError = class extends Error {
61
65
  var RymiClient = class {
62
66
  apiKey;
63
67
  baseURL;
68
+ fetchImpl;
64
69
  constructor(options) {
65
70
  const key = options?.apiKey || (typeof process !== "undefined" ? process.env.RYMI_API_KEY : void 0);
66
71
  if (!key) {
@@ -68,6 +73,7 @@ var RymiClient = class {
68
73
  }
69
74
  this.apiKey = key;
70
75
  this.baseURL = options?.baseURL || "https://api.rymi.live/v1";
76
+ this.fetchImpl = options?.fetch ?? globalThis.fetch;
71
77
  if (this.baseURL.endsWith("/")) {
72
78
  this.baseURL = this.baseURL.slice(0, -1);
73
79
  }
@@ -88,7 +94,7 @@ var RymiClient = class {
88
94
  init.body = JSON.stringify(body);
89
95
  }
90
96
  try {
91
- const response = await fetch(url, init);
97
+ const response = await this.fetchImpl(url, init);
92
98
  const isJson = response.headers.get("content-type")?.includes("application/json");
93
99
  const data = isJson ? await response.json() : await response.text();
94
100
  if (!response.ok) {
@@ -196,6 +202,15 @@ var AgentsResource = class {
196
202
  async validatePublish(params) {
197
203
  return this.client.post("/agents/validate-publish", params);
198
204
  }
205
+ /**
206
+ * Publish an agent: validate its persisted config and freeze it into the
207
+ * published snapshot the harness/review pipeline reads as the baseline.
208
+ * Returns `{ published: false, blockers }` (HTTP 200) when blockers remain —
209
+ * inspect `blockers` rather than relying on a thrown error.
210
+ */
211
+ async publish(agentId) {
212
+ return this.client.post(`/agents/${agentId}/publish`, {});
213
+ }
199
214
  /**
200
215
  * Validate and apply a flat-diff change-set against the AgentConfig field registry.
201
216
  * Does NOT persist — callers must follow up with update().
@@ -211,9 +226,8 @@ var AgentsResource = class {
211
226
  }
212
227
  /**
213
228
  * Preview the resolved per-language model stack (STT/LLM/TTS), blockers,
214
- * warnings, model diffs, and any required role upgrades for a set of
215
- * supported languages — without persisting anything. Note: the concierge
216
- * (realtime) role is not supported by this endpoint.
229
+ * warnings, and model diffs for a set of supported languages — without
230
+ * persisting anything.
217
231
  */
218
232
  async previewStack(params) {
219
233
  return this.client.post("/agents/stack-preview", params);
@@ -236,6 +250,26 @@ var AgentsResource = class {
236
250
  async deleteKnowledgeSource(agentId, sourceId) {
237
251
  return this.client.delete(`/agents/${agentId}/knowledge-sources/${sourceId}`);
238
252
  }
253
+ /**
254
+ * Get the agent's public share link, or `link: null` if none exists.
255
+ * `link_feature: false` means share links are disabled on this deployment.
256
+ */
257
+ async getShareLink(agentId) {
258
+ const res = await this.client.get(`/agents/${agentId}/testers`);
259
+ return { link_feature: res.link_feature, link: res.link };
260
+ }
261
+ /**
262
+ * Create the agent's public share link, or update its settings if one exists.
263
+ */
264
+ async setShareLink(agentId, settings = {}) {
265
+ return this.client.put(`/agents/${agentId}/share-link`, settings);
266
+ }
267
+ /**
268
+ * Issue a new URL for the share link. The old URL stops working immediately.
269
+ */
270
+ async regenerateShareLink(agentId) {
271
+ return this.client.post(`/agents/${agentId}/share-link/regenerate`, {});
272
+ }
239
273
  /**
240
274
  * List the recorded configuration changes for an agent (most recent first).
241
275
  * Optionally pass an ISO timestamp to only return changes since then.
@@ -256,8 +290,20 @@ var AgentsResource = class {
256
290
  * the offline scorer; mode="live" runs the model-driven runner.
257
291
  */
258
292
  async runEvals(agentId, params = {}) {
259
- const query = params.mode ? `?mode=${params.mode}` : "";
260
- return this.client.post(`/agents/${agentId}/evals/run${query}`, {});
293
+ const query = new URLSearchParams();
294
+ if (params.mode) query.set("mode", params.mode);
295
+ if (params.judge) query.set("judge", "1");
296
+ const qs = query.toString();
297
+ return this.client.post(`/agents/${agentId}/evals/run${qs ? `?${qs}` : ""}`, {});
298
+ }
299
+ /**
300
+ * Run the eval SUITE across many agents at once (agents × seeded scenarios),
301
+ * bounded by the optional concurrency cap. One eval run is persisted per
302
+ * agent; the aggregate EvalSuiteReport is returned. Pass `judge: true` to
303
+ * supplement the heuristics with the opt-in LLM judge (needs a Gemini key).
304
+ */
305
+ async runEvalSuite(params) {
306
+ return this.client.post("/agents/evals/suite", params);
261
307
  }
262
308
  /**
263
309
  * List previous evaluation runs for an agent.
@@ -313,7 +359,16 @@ var CallsResource = class {
313
359
  return this.client.post("/calls", data);
314
360
  }
315
361
  /**
316
- * Queue up to 500 outbound PSTN recipients in one request.
362
+ * Group call fanout: dial up to 500 PSTN participants into a single call room.
363
+ * Every recipient joins the same call. For independent per-recipient attempts,
364
+ * retries, and reports, use `campaigns` instead.
365
+ */
366
+ async fanout(data) {
367
+ return this.client.post("/calls/fanout", data);
368
+ }
369
+ /**
370
+ * Compatibility alias for {@link fanout}. Creates one call room with multiple
371
+ * PSTN participants. Queue up to 500 outbound PSTN recipients in one request.
317
372
  */
318
373
  async batch(data) {
319
374
  return this.client.post("/calls/batch", data);
@@ -399,6 +454,14 @@ var NumbersResource = class {
399
454
  async attach(number, agentId) {
400
455
  return this.client.post(`/numbers/${encodeURIComponent(number)}/attach`, { agent_id: agentId });
401
456
  }
457
+ /** Clear the agent association without deregistering the number. */
458
+ async detach(number) {
459
+ return this.client.post(`/numbers/${encodeURIComponent(number)}/detach`);
460
+ }
461
+ /** Re-run carrier inbound-webhook auto-provisioning for a number. */
462
+ async provisionWebhook(number) {
463
+ return this.client.post(`/numbers/${encodeURIComponent(number)}/webhook`);
464
+ }
402
465
  async remove(number) {
403
466
  return this.client.delete(`/numbers/${encodeURIComponent(number)}`);
404
467
  }
@@ -522,7 +585,7 @@ var BillingResource = class {
522
585
  async usageSummary() {
523
586
  return this.client.get("/billing/usage-summary");
524
587
  }
525
- /** Estimate the cost of a call for a given tier and duration. */
588
+ /** Estimate the cost of a call for a custom model stack and duration. */
526
589
  async estimate(data = {}) {
527
590
  return this.client.post("/billing/estimate", data);
528
591
  }
@@ -550,6 +613,228 @@ var TemplatesResource = class {
550
613
  }
551
614
  };
552
615
 
616
+ // src/resources/campaigns.ts
617
+ function buildQuery4(params) {
618
+ const sp = new URLSearchParams();
619
+ for (const [k, v] of Object.entries(params)) {
620
+ if (v !== void 0 && v !== null) sp.set(k, String(v));
621
+ }
622
+ const q = sp.toString();
623
+ return q ? `?${q}` : "";
624
+ }
625
+ var CampaignMembersResource = class {
626
+ constructor(client) {
627
+ this.client = client;
628
+ }
629
+ /** List a campaign's members, paginated. */
630
+ async list(campaignId, params = {}) {
631
+ return this.client.get(`/campaigns/${campaignId}/members${buildQuery4(params)}`);
632
+ }
633
+ /** Attach existing contacts to a campaign as members. */
634
+ async add(campaignId, data) {
635
+ return this.client.post(`/campaigns/${campaignId}/members`, data);
636
+ }
637
+ /** Import inline contact rows (JSON or CSV): creates/merges contacts and attaches members in one call. */
638
+ async import(campaignId, data) {
639
+ return this.client.post(`/campaigns/${campaignId}/members/import`, data);
640
+ }
641
+ /** Update a campaign member (status, variables, next attempt time). */
642
+ async update(campaignId, memberId, data) {
643
+ return this.client.patch(`/campaigns/${campaignId}/members/${memberId}`, data);
644
+ }
645
+ /** Remove a member from a campaign. */
646
+ async remove(campaignId, memberId) {
647
+ return this.client.delete(`/campaigns/${campaignId}/members/${memberId}`);
648
+ }
649
+ };
650
+ var CampaignRoutesResource = class {
651
+ constructor(client) {
652
+ this.client = client;
653
+ }
654
+ /** List a campaign's inbound routing rules. */
655
+ async list(campaignId, params = {}) {
656
+ return this.client.get(`/campaigns/${campaignId}/routes${buildQuery4(params)}`);
657
+ }
658
+ /** Bind an owned phone number to this campaign for inbound routing. Only one active route per number is allowed. */
659
+ async create(campaignId, data) {
660
+ return this.client.post(`/campaigns/${campaignId}/routes`, data);
661
+ }
662
+ /** Update an inbound route's schedule or active flag. */
663
+ async update(campaignId, routeId, data) {
664
+ return this.client.patch(`/campaigns/${campaignId}/routes/${routeId}`, data);
665
+ }
666
+ /** Delete an inbound route. */
667
+ async delete(campaignId, routeId) {
668
+ return this.client.delete(`/campaigns/${campaignId}/routes/${routeId}`);
669
+ }
670
+ };
671
+ var CampaignsResource = class {
672
+ constructor(client) {
673
+ this.client = client;
674
+ this.members = new CampaignMembersResource(client);
675
+ this.routes = new CampaignRoutesResource(client);
676
+ }
677
+ members;
678
+ routes;
679
+ /** List campaigns for the authenticated tenant, paginated. */
680
+ async list(params = {}) {
681
+ return this.client.get(`/campaigns${buildQuery4(params)}`);
682
+ }
683
+ /** Create a new campaign in draft status against a published agent. */
684
+ async create(data) {
685
+ return this.client.post("/campaigns", data);
686
+ }
687
+ /** Retrieve a single campaign by id. */
688
+ async get(campaignId) {
689
+ return this.client.get(`/campaigns/${campaignId}`);
690
+ }
691
+ /** Update campaign policy/goal fields. Status and lifecycle fields are not writable here. */
692
+ async update(campaignId, data) {
693
+ return this.client.patch(`/campaigns/${campaignId}`, data);
694
+ }
695
+ /**
696
+ * Launch a campaign: validates launch blockers, then stamps
697
+ * `launched_at` + `agent_snapshot_id`, flips members to `ready`, and
698
+ * transitions status to `running`.
699
+ */
700
+ async launch(campaignId) {
701
+ return this.client.post(`/campaigns/${campaignId}/launch`);
702
+ }
703
+ /** Evaluate launch blockers without launching (dry run). Safe from any status. */
704
+ async launchBlockers(campaignId) {
705
+ return this.client.get(`/campaigns/${campaignId}/launch-blockers`);
706
+ }
707
+ /** Pause a running campaign. In-flight calls finish naturally. */
708
+ async pause(campaignId) {
709
+ return this.client.post(`/campaigns/${campaignId}/pause`);
710
+ }
711
+ /** Resume a paused campaign. */
712
+ async resume(campaignId) {
713
+ return this.client.post(`/campaigns/${campaignId}/resume`);
714
+ }
715
+ /** Archive a campaign. Terminal — the scheduler never selects work for it again. */
716
+ async archive(campaignId) {
717
+ return this.client.post(`/campaigns/${campaignId}/archive`);
718
+ }
719
+ /** Read the campaign report: `stat_*` summary counters + outcome/sentiment/hourly/snapshot distributions. */
720
+ async report(campaignId) {
721
+ return this.client.get(`/campaigns/${campaignId}/report`);
722
+ }
723
+ /** List a campaign's dial attempts, paginated. */
724
+ async attempts(campaignId, params = {}) {
725
+ return this.client.get(`/campaigns/${campaignId}/attempts${buildQuery4(params)}`);
726
+ }
727
+ /** List a campaign's sweep-claim batches, paginated. */
728
+ async batches(campaignId, params = {}) {
729
+ return this.client.get(`/campaigns/${campaignId}/batches${buildQuery4(params)}`);
730
+ }
731
+ /** List a campaign's follow-up jobs, paginated. */
732
+ async followups(campaignId, params = {}) {
733
+ return this.client.get(`/campaigns/${campaignId}/followups${buildQuery4(params)}`);
734
+ }
735
+ /** Run the improve engine: detectors gate an LLM proposal writer, persisting new `campaign_suggestions`. */
736
+ async improve(campaignId) {
737
+ return this.client.post(`/campaigns/${campaignId}/improve`);
738
+ }
739
+ /** List a campaign's improvement suggestions, paginated. */
740
+ async suggestions(campaignId, params = {}) {
741
+ return this.client.get(`/campaigns/${campaignId}/suggestions${buildQuery4(params)}`);
742
+ }
743
+ /** Accept a suggestion: agent-editing suggestions create an agent-changes draft; campaign-policy suggestions patch the campaign. */
744
+ async acceptSuggestion(campaignId, suggestionId) {
745
+ return this.client.post(`/campaigns/${campaignId}/suggestions/${suggestionId}/accept`);
746
+ }
747
+ /** Dismiss a suggestion without applying it. */
748
+ async dismissSuggestion(campaignId, suggestionId) {
749
+ return this.client.post(`/campaigns/${campaignId}/suggestions/${suggestionId}/dismiss`);
750
+ }
751
+ };
752
+
753
+ // src/resources/contacts.ts
754
+ function buildQuery5(params) {
755
+ const sp = new URLSearchParams();
756
+ for (const [k, v] of Object.entries(params)) {
757
+ if (v !== void 0 && v !== null) sp.set(k, String(v));
758
+ }
759
+ const q = sp.toString();
760
+ return q ? `?${q}` : "";
761
+ }
762
+ var ContactsResource = class {
763
+ constructor(client) {
764
+ this.client = client;
765
+ }
766
+ /** List tenant-level contacts, paginated. */
767
+ async list(params = {}) {
768
+ return this.client.get(`/contacts${buildQuery5(params)}`);
769
+ }
770
+ /**
771
+ * Create a tenant-level contact. If a contact with the same
772
+ * (tenant, phone) already exists, the existing row is returned instead
773
+ * of creating a duplicate — check `deduped` in the response.
774
+ */
775
+ async create(data) {
776
+ return this.client.post("/contacts", data);
777
+ }
778
+ /** Retrieve a single tenant-scoped contact by id. */
779
+ async get(contactId) {
780
+ return this.client.get(`/contacts/${contactId}`);
781
+ }
782
+ /** Update an existing tenant-scoped contact. Only provided fields change. */
783
+ async update(contactId, data) {
784
+ return this.client.patch(`/contacts/${contactId}`, data);
785
+ }
786
+ /** Delete a tenant-scoped contact. */
787
+ async delete(contactId) {
788
+ return this.client.delete(`/contacts/${contactId}`);
789
+ }
790
+ /**
791
+ * Bulk import contacts from JSON rows or CSV text. Each row's phone is
792
+ * normalized to E.164 and upserted on (tenant_id, phone); rows with
793
+ * unparseable phones are skipped and reported in `invalid`.
794
+ */
795
+ async import(data) {
796
+ return this.client.post("/contacts/import", data);
797
+ }
798
+ /** Record a consent grant or revoke for one channel, with evidence. Also
799
+ * appends an immutable row to the consent_events proof log. */
800
+ async setConsent(contactId, data) {
801
+ return this.client.patch(`/contacts/${contactId}/consent`, data);
802
+ }
803
+ };
804
+
805
+ // src/resources/compliance.ts
806
+ var ComplianceResource = class {
807
+ constructor(client) {
808
+ this.client = client;
809
+ }
810
+ /** Record a compliance attestation (append-only). Campaign launch blockers
811
+ * in `attested` mode read the most recent one of the matching `kind`. */
812
+ async attest(data) {
813
+ return this.client.post("/compliance/attestations", data);
814
+ }
815
+ /** List the tenant's 50 most recent compliance attestations, newest first. */
816
+ async listAttestations() {
817
+ return this.client.get("/compliance/attestations");
818
+ }
819
+ };
820
+
821
+ // src/resources/toolSecrets.ts
822
+ var ToolSecretsResource = class {
823
+ constructor(client) {
824
+ this.client = client;
825
+ }
826
+ async list() {
827
+ return this.client.get("/tool-secrets");
828
+ }
829
+ /** Create or replace. `name` is UPPER_SNAKE_CASE; `host` is a public hostname. */
830
+ async set(name, data) {
831
+ return this.client.put(`/tool-secrets/${encodeURIComponent(name)}`, data);
832
+ }
833
+ async delete(name) {
834
+ return this.client.delete(`/tool-secrets/${encodeURIComponent(name)}`);
835
+ }
836
+ };
837
+
553
838
  // src/index.ts
554
839
  __reExport(index_exports, require("@rymi/sdk-types"), module.exports);
555
840
  var Rymi = class {
@@ -563,6 +848,10 @@ var Rymi = class {
563
848
  telephony;
564
849
  billing;
565
850
  templates;
851
+ campaigns;
852
+ contacts;
853
+ compliance;
854
+ toolSecrets;
566
855
  constructor(options) {
567
856
  this.client = new RymiClient(options);
568
857
  this.agents = new AgentsResource(this.client);
@@ -574,6 +863,10 @@ var Rymi = class {
574
863
  this.telephony = new TelephonyResource(this.client);
575
864
  this.billing = new BillingResource(this.client);
576
865
  this.templates = new TemplatesResource(this.client);
866
+ this.campaigns = new CampaignsResource(this.client);
867
+ this.contacts = new ContactsResource(this.client);
868
+ this.compliance = new ComplianceResource(this.client);
869
+ this.toolSecrets = new ToolSecretsResource(this.client);
577
870
  }
578
871
  };
579
872
  var index_default = Rymi;
@@ -582,6 +875,9 @@ var index_default = Rymi;
582
875
  AgentsResource,
583
876
  BillingResource,
584
877
  CallsResource,
878
+ CampaignsResource,
879
+ ComplianceResource,
880
+ ContactsResource,
585
881
  DncResource,
586
882
  KeysResource,
587
883
  NumbersResource,
@@ -590,6 +886,7 @@ var index_default = Rymi;
590
886
  RymiError,
591
887
  TelephonyResource,
592
888
  TemplatesResource,
889
+ ToolSecretsResource,
593
890
  WebhooksResource,
594
891
  ...require("@rymi/sdk-types")
595
892
  });