@rymi/node 1.0.1 → 2.0.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/README.md +53 -8
- package/dist/index.d.mts +562 -15
- package/dist/index.d.ts +562 -15
- package/dist/index.js +264 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +261 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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,
|
|
@@ -61,6 +64,7 @@ var RymiError = class extends Error {
|
|
|
61
64
|
var RymiClient = class {
|
|
62
65
|
apiKey;
|
|
63
66
|
baseURL;
|
|
67
|
+
fetchImpl;
|
|
64
68
|
constructor(options) {
|
|
65
69
|
const key = options?.apiKey || (typeof process !== "undefined" ? process.env.RYMI_API_KEY : void 0);
|
|
66
70
|
if (!key) {
|
|
@@ -68,6 +72,7 @@ var RymiClient = class {
|
|
|
68
72
|
}
|
|
69
73
|
this.apiKey = key;
|
|
70
74
|
this.baseURL = options?.baseURL || "https://api.rymi.live/v1";
|
|
75
|
+
this.fetchImpl = options?.fetch ?? globalThis.fetch;
|
|
71
76
|
if (this.baseURL.endsWith("/")) {
|
|
72
77
|
this.baseURL = this.baseURL.slice(0, -1);
|
|
73
78
|
}
|
|
@@ -88,7 +93,7 @@ var RymiClient = class {
|
|
|
88
93
|
init.body = JSON.stringify(body);
|
|
89
94
|
}
|
|
90
95
|
try {
|
|
91
|
-
const response = await
|
|
96
|
+
const response = await this.fetchImpl(url, init);
|
|
92
97
|
const isJson = response.headers.get("content-type")?.includes("application/json");
|
|
93
98
|
const data = isJson ? await response.json() : await response.text();
|
|
94
99
|
if (!response.ok) {
|
|
@@ -196,6 +201,15 @@ var AgentsResource = class {
|
|
|
196
201
|
async validatePublish(params) {
|
|
197
202
|
return this.client.post("/agents/validate-publish", params);
|
|
198
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Publish an agent: validate its persisted config and freeze it into the
|
|
206
|
+
* published snapshot the harness/review pipeline reads as the baseline.
|
|
207
|
+
* Returns `{ published: false, blockers }` (HTTP 200) when blockers remain —
|
|
208
|
+
* inspect `blockers` rather than relying on a thrown error.
|
|
209
|
+
*/
|
|
210
|
+
async publish(agentId) {
|
|
211
|
+
return this.client.post(`/agents/${agentId}/publish`, {});
|
|
212
|
+
}
|
|
199
213
|
/**
|
|
200
214
|
* Validate and apply a flat-diff change-set against the AgentConfig field registry.
|
|
201
215
|
* Does NOT persist — callers must follow up with update().
|
|
@@ -211,9 +225,8 @@ var AgentsResource = class {
|
|
|
211
225
|
}
|
|
212
226
|
/**
|
|
213
227
|
* Preview the resolved per-language model stack (STT/LLM/TTS), blockers,
|
|
214
|
-
* warnings, model diffs
|
|
215
|
-
*
|
|
216
|
-
* (realtime) role is not supported by this endpoint.
|
|
228
|
+
* warnings, and model diffs for a set of supported languages — without
|
|
229
|
+
* persisting anything.
|
|
217
230
|
*/
|
|
218
231
|
async previewStack(params) {
|
|
219
232
|
return this.client.post("/agents/stack-preview", params);
|
|
@@ -256,8 +269,20 @@ var AgentsResource = class {
|
|
|
256
269
|
* the offline scorer; mode="live" runs the model-driven runner.
|
|
257
270
|
*/
|
|
258
271
|
async runEvals(agentId, params = {}) {
|
|
259
|
-
const query =
|
|
260
|
-
|
|
272
|
+
const query = new URLSearchParams();
|
|
273
|
+
if (params.mode) query.set("mode", params.mode);
|
|
274
|
+
if (params.judge) query.set("judge", "1");
|
|
275
|
+
const qs = query.toString();
|
|
276
|
+
return this.client.post(`/agents/${agentId}/evals/run${qs ? `?${qs}` : ""}`, {});
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Run the eval SUITE across many agents at once (agents × seeded scenarios),
|
|
280
|
+
* bounded by the optional concurrency cap. One eval run is persisted per
|
|
281
|
+
* agent; the aggregate EvalSuiteReport is returned. Pass `judge: true` to
|
|
282
|
+
* supplement the heuristics with the opt-in LLM judge (needs a Gemini key).
|
|
283
|
+
*/
|
|
284
|
+
async runEvalSuite(params) {
|
|
285
|
+
return this.client.post("/agents/evals/suite", params);
|
|
261
286
|
}
|
|
262
287
|
/**
|
|
263
288
|
* List previous evaluation runs for an agent.
|
|
@@ -313,7 +338,16 @@ var CallsResource = class {
|
|
|
313
338
|
return this.client.post("/calls", data);
|
|
314
339
|
}
|
|
315
340
|
/**
|
|
316
|
-
*
|
|
341
|
+
* Group call fanout: dial up to 500 PSTN participants into a single call room.
|
|
342
|
+
* Every recipient joins the same call. For independent per-recipient attempts,
|
|
343
|
+
* retries, and reports, use `campaigns` instead.
|
|
344
|
+
*/
|
|
345
|
+
async fanout(data) {
|
|
346
|
+
return this.client.post("/calls/fanout", data);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Compatibility alias for {@link fanout}. Creates one call room with multiple
|
|
350
|
+
* PSTN participants. Queue up to 500 outbound PSTN recipients in one request.
|
|
317
351
|
*/
|
|
318
352
|
async batch(data) {
|
|
319
353
|
return this.client.post("/calls/batch", data);
|
|
@@ -399,6 +433,14 @@ var NumbersResource = class {
|
|
|
399
433
|
async attach(number, agentId) {
|
|
400
434
|
return this.client.post(`/numbers/${encodeURIComponent(number)}/attach`, { agent_id: agentId });
|
|
401
435
|
}
|
|
436
|
+
/** Clear the agent association without deregistering the number. */
|
|
437
|
+
async detach(number) {
|
|
438
|
+
return this.client.post(`/numbers/${encodeURIComponent(number)}/detach`);
|
|
439
|
+
}
|
|
440
|
+
/** Re-run carrier inbound-webhook auto-provisioning for a number. */
|
|
441
|
+
async provisionWebhook(number) {
|
|
442
|
+
return this.client.post(`/numbers/${encodeURIComponent(number)}/webhook`);
|
|
443
|
+
}
|
|
402
444
|
async remove(number) {
|
|
403
445
|
return this.client.delete(`/numbers/${encodeURIComponent(number)}`);
|
|
404
446
|
}
|
|
@@ -522,7 +564,7 @@ var BillingResource = class {
|
|
|
522
564
|
async usageSummary() {
|
|
523
565
|
return this.client.get("/billing/usage-summary");
|
|
524
566
|
}
|
|
525
|
-
/** Estimate the cost of a call for a
|
|
567
|
+
/** Estimate the cost of a call for a custom model stack and duration. */
|
|
526
568
|
async estimate(data = {}) {
|
|
527
569
|
return this.client.post("/billing/estimate", data);
|
|
528
570
|
}
|
|
@@ -550,6 +592,211 @@ var TemplatesResource = class {
|
|
|
550
592
|
}
|
|
551
593
|
};
|
|
552
594
|
|
|
595
|
+
// src/resources/campaigns.ts
|
|
596
|
+
function buildQuery4(params) {
|
|
597
|
+
const sp = new URLSearchParams();
|
|
598
|
+
for (const [k, v] of Object.entries(params)) {
|
|
599
|
+
if (v !== void 0 && v !== null) sp.set(k, String(v));
|
|
600
|
+
}
|
|
601
|
+
const q = sp.toString();
|
|
602
|
+
return q ? `?${q}` : "";
|
|
603
|
+
}
|
|
604
|
+
var CampaignMembersResource = class {
|
|
605
|
+
constructor(client) {
|
|
606
|
+
this.client = client;
|
|
607
|
+
}
|
|
608
|
+
/** List a campaign's members, paginated. */
|
|
609
|
+
async list(campaignId, params = {}) {
|
|
610
|
+
return this.client.get(`/campaigns/${campaignId}/members${buildQuery4(params)}`);
|
|
611
|
+
}
|
|
612
|
+
/** Attach existing contacts to a campaign as members. */
|
|
613
|
+
async add(campaignId, data) {
|
|
614
|
+
return this.client.post(`/campaigns/${campaignId}/members`, data);
|
|
615
|
+
}
|
|
616
|
+
/** Import inline contact rows (JSON or CSV): creates/merges contacts and attaches members in one call. */
|
|
617
|
+
async import(campaignId, data) {
|
|
618
|
+
return this.client.post(`/campaigns/${campaignId}/members/import`, data);
|
|
619
|
+
}
|
|
620
|
+
/** Update a campaign member (status, variables, next attempt time). */
|
|
621
|
+
async update(campaignId, memberId, data) {
|
|
622
|
+
return this.client.patch(`/campaigns/${campaignId}/members/${memberId}`, data);
|
|
623
|
+
}
|
|
624
|
+
/** Remove a member from a campaign. */
|
|
625
|
+
async remove(campaignId, memberId) {
|
|
626
|
+
return this.client.delete(`/campaigns/${campaignId}/members/${memberId}`);
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
var CampaignRoutesResource = class {
|
|
630
|
+
constructor(client) {
|
|
631
|
+
this.client = client;
|
|
632
|
+
}
|
|
633
|
+
/** List a campaign's inbound routing rules. */
|
|
634
|
+
async list(campaignId, params = {}) {
|
|
635
|
+
return this.client.get(`/campaigns/${campaignId}/routes${buildQuery4(params)}`);
|
|
636
|
+
}
|
|
637
|
+
/** Bind an owned phone number to this campaign for inbound routing. Only one active route per number is allowed. */
|
|
638
|
+
async create(campaignId, data) {
|
|
639
|
+
return this.client.post(`/campaigns/${campaignId}/routes`, data);
|
|
640
|
+
}
|
|
641
|
+
/** Update an inbound route's schedule or active flag. */
|
|
642
|
+
async update(campaignId, routeId, data) {
|
|
643
|
+
return this.client.patch(`/campaigns/${campaignId}/routes/${routeId}`, data);
|
|
644
|
+
}
|
|
645
|
+
/** Delete an inbound route. */
|
|
646
|
+
async delete(campaignId, routeId) {
|
|
647
|
+
return this.client.delete(`/campaigns/${campaignId}/routes/${routeId}`);
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
var CampaignsResource = class {
|
|
651
|
+
constructor(client) {
|
|
652
|
+
this.client = client;
|
|
653
|
+
this.members = new CampaignMembersResource(client);
|
|
654
|
+
this.routes = new CampaignRoutesResource(client);
|
|
655
|
+
}
|
|
656
|
+
members;
|
|
657
|
+
routes;
|
|
658
|
+
/** List campaigns for the authenticated tenant, paginated. */
|
|
659
|
+
async list(params = {}) {
|
|
660
|
+
return this.client.get(`/campaigns${buildQuery4(params)}`);
|
|
661
|
+
}
|
|
662
|
+
/** Create a new campaign in draft status against a published agent. */
|
|
663
|
+
async create(data) {
|
|
664
|
+
return this.client.post("/campaigns", data);
|
|
665
|
+
}
|
|
666
|
+
/** Retrieve a single campaign by id. */
|
|
667
|
+
async get(campaignId) {
|
|
668
|
+
return this.client.get(`/campaigns/${campaignId}`);
|
|
669
|
+
}
|
|
670
|
+
/** Update campaign policy/goal fields. Status and lifecycle fields are not writable here. */
|
|
671
|
+
async update(campaignId, data) {
|
|
672
|
+
return this.client.patch(`/campaigns/${campaignId}`, data);
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Launch a campaign: validates launch blockers, then stamps
|
|
676
|
+
* `launched_at` + `agent_snapshot_id`, flips members to `ready`, and
|
|
677
|
+
* transitions status to `running`.
|
|
678
|
+
*/
|
|
679
|
+
async launch(campaignId) {
|
|
680
|
+
return this.client.post(`/campaigns/${campaignId}/launch`);
|
|
681
|
+
}
|
|
682
|
+
/** Evaluate launch blockers without launching (dry run). Safe from any status. */
|
|
683
|
+
async launchBlockers(campaignId) {
|
|
684
|
+
return this.client.get(`/campaigns/${campaignId}/launch-blockers`);
|
|
685
|
+
}
|
|
686
|
+
/** Pause a running campaign. In-flight calls finish naturally. */
|
|
687
|
+
async pause(campaignId) {
|
|
688
|
+
return this.client.post(`/campaigns/${campaignId}/pause`);
|
|
689
|
+
}
|
|
690
|
+
/** Resume a paused campaign. */
|
|
691
|
+
async resume(campaignId) {
|
|
692
|
+
return this.client.post(`/campaigns/${campaignId}/resume`);
|
|
693
|
+
}
|
|
694
|
+
/** Archive a campaign. Terminal — the scheduler never selects work for it again. */
|
|
695
|
+
async archive(campaignId) {
|
|
696
|
+
return this.client.post(`/campaigns/${campaignId}/archive`);
|
|
697
|
+
}
|
|
698
|
+
/** Read the campaign report: `stat_*` summary counters + outcome/sentiment/hourly/snapshot distributions. */
|
|
699
|
+
async report(campaignId) {
|
|
700
|
+
return this.client.get(`/campaigns/${campaignId}/report`);
|
|
701
|
+
}
|
|
702
|
+
/** List a campaign's dial attempts, paginated. */
|
|
703
|
+
async attempts(campaignId, params = {}) {
|
|
704
|
+
return this.client.get(`/campaigns/${campaignId}/attempts${buildQuery4(params)}`);
|
|
705
|
+
}
|
|
706
|
+
/** List a campaign's sweep-claim batches, paginated. */
|
|
707
|
+
async batches(campaignId, params = {}) {
|
|
708
|
+
return this.client.get(`/campaigns/${campaignId}/batches${buildQuery4(params)}`);
|
|
709
|
+
}
|
|
710
|
+
/** List a campaign's follow-up jobs, paginated. */
|
|
711
|
+
async followups(campaignId, params = {}) {
|
|
712
|
+
return this.client.get(`/campaigns/${campaignId}/followups${buildQuery4(params)}`);
|
|
713
|
+
}
|
|
714
|
+
/** Run the improve engine: detectors gate an LLM proposal writer, persisting new `campaign_suggestions`. */
|
|
715
|
+
async improve(campaignId) {
|
|
716
|
+
return this.client.post(`/campaigns/${campaignId}/improve`);
|
|
717
|
+
}
|
|
718
|
+
/** List a campaign's improvement suggestions, paginated. */
|
|
719
|
+
async suggestions(campaignId, params = {}) {
|
|
720
|
+
return this.client.get(`/campaigns/${campaignId}/suggestions${buildQuery4(params)}`);
|
|
721
|
+
}
|
|
722
|
+
/** Accept a suggestion: agent-editing suggestions create an agent-changes draft; campaign-policy suggestions patch the campaign. */
|
|
723
|
+
async acceptSuggestion(campaignId, suggestionId) {
|
|
724
|
+
return this.client.post(`/campaigns/${campaignId}/suggestions/${suggestionId}/accept`);
|
|
725
|
+
}
|
|
726
|
+
/** Dismiss a suggestion without applying it. */
|
|
727
|
+
async dismissSuggestion(campaignId, suggestionId) {
|
|
728
|
+
return this.client.post(`/campaigns/${campaignId}/suggestions/${suggestionId}/dismiss`);
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
// src/resources/contacts.ts
|
|
733
|
+
function buildQuery5(params) {
|
|
734
|
+
const sp = new URLSearchParams();
|
|
735
|
+
for (const [k, v] of Object.entries(params)) {
|
|
736
|
+
if (v !== void 0 && v !== null) sp.set(k, String(v));
|
|
737
|
+
}
|
|
738
|
+
const q = sp.toString();
|
|
739
|
+
return q ? `?${q}` : "";
|
|
740
|
+
}
|
|
741
|
+
var ContactsResource = class {
|
|
742
|
+
constructor(client) {
|
|
743
|
+
this.client = client;
|
|
744
|
+
}
|
|
745
|
+
/** List tenant-level contacts, paginated. */
|
|
746
|
+
async list(params = {}) {
|
|
747
|
+
return this.client.get(`/contacts${buildQuery5(params)}`);
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Create a tenant-level contact. If a contact with the same
|
|
751
|
+
* (tenant, phone) already exists, the existing row is returned instead
|
|
752
|
+
* of creating a duplicate — check `deduped` in the response.
|
|
753
|
+
*/
|
|
754
|
+
async create(data) {
|
|
755
|
+
return this.client.post("/contacts", data);
|
|
756
|
+
}
|
|
757
|
+
/** Retrieve a single tenant-scoped contact by id. */
|
|
758
|
+
async get(contactId) {
|
|
759
|
+
return this.client.get(`/contacts/${contactId}`);
|
|
760
|
+
}
|
|
761
|
+
/** Update an existing tenant-scoped contact. Only provided fields change. */
|
|
762
|
+
async update(contactId, data) {
|
|
763
|
+
return this.client.patch(`/contacts/${contactId}`, data);
|
|
764
|
+
}
|
|
765
|
+
/** Delete a tenant-scoped contact. */
|
|
766
|
+
async delete(contactId) {
|
|
767
|
+
return this.client.delete(`/contacts/${contactId}`);
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Bulk import contacts from JSON rows or CSV text. Each row's phone is
|
|
771
|
+
* normalized to E.164 and upserted on (tenant_id, phone); rows with
|
|
772
|
+
* unparseable phones are skipped and reported in `invalid`.
|
|
773
|
+
*/
|
|
774
|
+
async import(data) {
|
|
775
|
+
return this.client.post("/contacts/import", data);
|
|
776
|
+
}
|
|
777
|
+
/** Record a consent grant or revoke for one channel, with evidence. Also
|
|
778
|
+
* appends an immutable row to the consent_events proof log. */
|
|
779
|
+
async setConsent(contactId, data) {
|
|
780
|
+
return this.client.patch(`/contacts/${contactId}/consent`, data);
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
// src/resources/compliance.ts
|
|
785
|
+
var ComplianceResource = class {
|
|
786
|
+
constructor(client) {
|
|
787
|
+
this.client = client;
|
|
788
|
+
}
|
|
789
|
+
/** Record a compliance attestation (append-only). Campaign launch blockers
|
|
790
|
+
* in `attested` mode read the most recent one of the matching `kind`. */
|
|
791
|
+
async attest(data) {
|
|
792
|
+
return this.client.post("/compliance/attestations", data);
|
|
793
|
+
}
|
|
794
|
+
/** List the tenant's 50 most recent compliance attestations, newest first. */
|
|
795
|
+
async listAttestations() {
|
|
796
|
+
return this.client.get("/compliance/attestations");
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
|
|
553
800
|
// src/index.ts
|
|
554
801
|
__reExport(index_exports, require("@rymi/sdk-types"), module.exports);
|
|
555
802
|
var Rymi = class {
|
|
@@ -563,6 +810,9 @@ var Rymi = class {
|
|
|
563
810
|
telephony;
|
|
564
811
|
billing;
|
|
565
812
|
templates;
|
|
813
|
+
campaigns;
|
|
814
|
+
contacts;
|
|
815
|
+
compliance;
|
|
566
816
|
constructor(options) {
|
|
567
817
|
this.client = new RymiClient(options);
|
|
568
818
|
this.agents = new AgentsResource(this.client);
|
|
@@ -574,6 +824,9 @@ var Rymi = class {
|
|
|
574
824
|
this.telephony = new TelephonyResource(this.client);
|
|
575
825
|
this.billing = new BillingResource(this.client);
|
|
576
826
|
this.templates = new TemplatesResource(this.client);
|
|
827
|
+
this.campaigns = new CampaignsResource(this.client);
|
|
828
|
+
this.contacts = new ContactsResource(this.client);
|
|
829
|
+
this.compliance = new ComplianceResource(this.client);
|
|
577
830
|
}
|
|
578
831
|
};
|
|
579
832
|
var index_default = Rymi;
|
|
@@ -582,6 +835,9 @@ var index_default = Rymi;
|
|
|
582
835
|
AgentsResource,
|
|
583
836
|
BillingResource,
|
|
584
837
|
CallsResource,
|
|
838
|
+
CampaignsResource,
|
|
839
|
+
ComplianceResource,
|
|
840
|
+
ContactsResource,
|
|
585
841
|
DncResource,
|
|
586
842
|
KeysResource,
|
|
587
843
|
NumbersResource,
|