@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.mjs
CHANGED
|
@@ -12,6 +12,7 @@ var RymiError = class extends Error {
|
|
|
12
12
|
var RymiClient = class {
|
|
13
13
|
apiKey;
|
|
14
14
|
baseURL;
|
|
15
|
+
fetchImpl;
|
|
15
16
|
constructor(options) {
|
|
16
17
|
const key = options?.apiKey || (typeof process !== "undefined" ? process.env.RYMI_API_KEY : void 0);
|
|
17
18
|
if (!key) {
|
|
@@ -19,6 +20,7 @@ var RymiClient = class {
|
|
|
19
20
|
}
|
|
20
21
|
this.apiKey = key;
|
|
21
22
|
this.baseURL = options?.baseURL || "https://api.rymi.live/v1";
|
|
23
|
+
this.fetchImpl = options?.fetch ?? globalThis.fetch;
|
|
22
24
|
if (this.baseURL.endsWith("/")) {
|
|
23
25
|
this.baseURL = this.baseURL.slice(0, -1);
|
|
24
26
|
}
|
|
@@ -39,7 +41,7 @@ var RymiClient = class {
|
|
|
39
41
|
init.body = JSON.stringify(body);
|
|
40
42
|
}
|
|
41
43
|
try {
|
|
42
|
-
const response = await
|
|
44
|
+
const response = await this.fetchImpl(url, init);
|
|
43
45
|
const isJson = response.headers.get("content-type")?.includes("application/json");
|
|
44
46
|
const data = isJson ? await response.json() : await response.text();
|
|
45
47
|
if (!response.ok) {
|
|
@@ -147,6 +149,15 @@ var AgentsResource = class {
|
|
|
147
149
|
async validatePublish(params) {
|
|
148
150
|
return this.client.post("/agents/validate-publish", params);
|
|
149
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Publish an agent: validate its persisted config and freeze it into the
|
|
154
|
+
* published snapshot the harness/review pipeline reads as the baseline.
|
|
155
|
+
* Returns `{ published: false, blockers }` (HTTP 200) when blockers remain —
|
|
156
|
+
* inspect `blockers` rather than relying on a thrown error.
|
|
157
|
+
*/
|
|
158
|
+
async publish(agentId) {
|
|
159
|
+
return this.client.post(`/agents/${agentId}/publish`, {});
|
|
160
|
+
}
|
|
150
161
|
/**
|
|
151
162
|
* Validate and apply a flat-diff change-set against the AgentConfig field registry.
|
|
152
163
|
* Does NOT persist — callers must follow up with update().
|
|
@@ -162,9 +173,8 @@ var AgentsResource = class {
|
|
|
162
173
|
}
|
|
163
174
|
/**
|
|
164
175
|
* Preview the resolved per-language model stack (STT/LLM/TTS), blockers,
|
|
165
|
-
* warnings, model diffs
|
|
166
|
-
*
|
|
167
|
-
* (realtime) role is not supported by this endpoint.
|
|
176
|
+
* warnings, and model diffs for a set of supported languages — without
|
|
177
|
+
* persisting anything.
|
|
168
178
|
*/
|
|
169
179
|
async previewStack(params) {
|
|
170
180
|
return this.client.post("/agents/stack-preview", params);
|
|
@@ -207,8 +217,20 @@ var AgentsResource = class {
|
|
|
207
217
|
* the offline scorer; mode="live" runs the model-driven runner.
|
|
208
218
|
*/
|
|
209
219
|
async runEvals(agentId, params = {}) {
|
|
210
|
-
const query =
|
|
211
|
-
|
|
220
|
+
const query = new URLSearchParams();
|
|
221
|
+
if (params.mode) query.set("mode", params.mode);
|
|
222
|
+
if (params.judge) query.set("judge", "1");
|
|
223
|
+
const qs = query.toString();
|
|
224
|
+
return this.client.post(`/agents/${agentId}/evals/run${qs ? `?${qs}` : ""}`, {});
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Run the eval SUITE across many agents at once (agents × seeded scenarios),
|
|
228
|
+
* bounded by the optional concurrency cap. One eval run is persisted per
|
|
229
|
+
* agent; the aggregate EvalSuiteReport is returned. Pass `judge: true` to
|
|
230
|
+
* supplement the heuristics with the opt-in LLM judge (needs a Gemini key).
|
|
231
|
+
*/
|
|
232
|
+
async runEvalSuite(params) {
|
|
233
|
+
return this.client.post("/agents/evals/suite", params);
|
|
212
234
|
}
|
|
213
235
|
/**
|
|
214
236
|
* List previous evaluation runs for an agent.
|
|
@@ -264,7 +286,16 @@ var CallsResource = class {
|
|
|
264
286
|
return this.client.post("/calls", data);
|
|
265
287
|
}
|
|
266
288
|
/**
|
|
267
|
-
*
|
|
289
|
+
* Group call fanout: dial up to 500 PSTN participants into a single call room.
|
|
290
|
+
* Every recipient joins the same call. For independent per-recipient attempts,
|
|
291
|
+
* retries, and reports, use `campaigns` instead.
|
|
292
|
+
*/
|
|
293
|
+
async fanout(data) {
|
|
294
|
+
return this.client.post("/calls/fanout", data);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Compatibility alias for {@link fanout}. Creates one call room with multiple
|
|
298
|
+
* PSTN participants. Queue up to 500 outbound PSTN recipients in one request.
|
|
268
299
|
*/
|
|
269
300
|
async batch(data) {
|
|
270
301
|
return this.client.post("/calls/batch", data);
|
|
@@ -350,6 +381,14 @@ var NumbersResource = class {
|
|
|
350
381
|
async attach(number, agentId) {
|
|
351
382
|
return this.client.post(`/numbers/${encodeURIComponent(number)}/attach`, { agent_id: agentId });
|
|
352
383
|
}
|
|
384
|
+
/** Clear the agent association without deregistering the number. */
|
|
385
|
+
async detach(number) {
|
|
386
|
+
return this.client.post(`/numbers/${encodeURIComponent(number)}/detach`);
|
|
387
|
+
}
|
|
388
|
+
/** Re-run carrier inbound-webhook auto-provisioning for a number. */
|
|
389
|
+
async provisionWebhook(number) {
|
|
390
|
+
return this.client.post(`/numbers/${encodeURIComponent(number)}/webhook`);
|
|
391
|
+
}
|
|
353
392
|
async remove(number) {
|
|
354
393
|
return this.client.delete(`/numbers/${encodeURIComponent(number)}`);
|
|
355
394
|
}
|
|
@@ -473,7 +512,7 @@ var BillingResource = class {
|
|
|
473
512
|
async usageSummary() {
|
|
474
513
|
return this.client.get("/billing/usage-summary");
|
|
475
514
|
}
|
|
476
|
-
/** Estimate the cost of a call for a
|
|
515
|
+
/** Estimate the cost of a call for a custom model stack and duration. */
|
|
477
516
|
async estimate(data = {}) {
|
|
478
517
|
return this.client.post("/billing/estimate", data);
|
|
479
518
|
}
|
|
@@ -501,6 +540,211 @@ var TemplatesResource = class {
|
|
|
501
540
|
}
|
|
502
541
|
};
|
|
503
542
|
|
|
543
|
+
// src/resources/campaigns.ts
|
|
544
|
+
function buildQuery4(params) {
|
|
545
|
+
const sp = new URLSearchParams();
|
|
546
|
+
for (const [k, v] of Object.entries(params)) {
|
|
547
|
+
if (v !== void 0 && v !== null) sp.set(k, String(v));
|
|
548
|
+
}
|
|
549
|
+
const q = sp.toString();
|
|
550
|
+
return q ? `?${q}` : "";
|
|
551
|
+
}
|
|
552
|
+
var CampaignMembersResource = class {
|
|
553
|
+
constructor(client) {
|
|
554
|
+
this.client = client;
|
|
555
|
+
}
|
|
556
|
+
/** List a campaign's members, paginated. */
|
|
557
|
+
async list(campaignId, params = {}) {
|
|
558
|
+
return this.client.get(`/campaigns/${campaignId}/members${buildQuery4(params)}`);
|
|
559
|
+
}
|
|
560
|
+
/** Attach existing contacts to a campaign as members. */
|
|
561
|
+
async add(campaignId, data) {
|
|
562
|
+
return this.client.post(`/campaigns/${campaignId}/members`, data);
|
|
563
|
+
}
|
|
564
|
+
/** Import inline contact rows (JSON or CSV): creates/merges contacts and attaches members in one call. */
|
|
565
|
+
async import(campaignId, data) {
|
|
566
|
+
return this.client.post(`/campaigns/${campaignId}/members/import`, data);
|
|
567
|
+
}
|
|
568
|
+
/** Update a campaign member (status, variables, next attempt time). */
|
|
569
|
+
async update(campaignId, memberId, data) {
|
|
570
|
+
return this.client.patch(`/campaigns/${campaignId}/members/${memberId}`, data);
|
|
571
|
+
}
|
|
572
|
+
/** Remove a member from a campaign. */
|
|
573
|
+
async remove(campaignId, memberId) {
|
|
574
|
+
return this.client.delete(`/campaigns/${campaignId}/members/${memberId}`);
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
var CampaignRoutesResource = class {
|
|
578
|
+
constructor(client) {
|
|
579
|
+
this.client = client;
|
|
580
|
+
}
|
|
581
|
+
/** List a campaign's inbound routing rules. */
|
|
582
|
+
async list(campaignId, params = {}) {
|
|
583
|
+
return this.client.get(`/campaigns/${campaignId}/routes${buildQuery4(params)}`);
|
|
584
|
+
}
|
|
585
|
+
/** Bind an owned phone number to this campaign for inbound routing. Only one active route per number is allowed. */
|
|
586
|
+
async create(campaignId, data) {
|
|
587
|
+
return this.client.post(`/campaigns/${campaignId}/routes`, data);
|
|
588
|
+
}
|
|
589
|
+
/** Update an inbound route's schedule or active flag. */
|
|
590
|
+
async update(campaignId, routeId, data) {
|
|
591
|
+
return this.client.patch(`/campaigns/${campaignId}/routes/${routeId}`, data);
|
|
592
|
+
}
|
|
593
|
+
/** Delete an inbound route. */
|
|
594
|
+
async delete(campaignId, routeId) {
|
|
595
|
+
return this.client.delete(`/campaigns/${campaignId}/routes/${routeId}`);
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
var CampaignsResource = class {
|
|
599
|
+
constructor(client) {
|
|
600
|
+
this.client = client;
|
|
601
|
+
this.members = new CampaignMembersResource(client);
|
|
602
|
+
this.routes = new CampaignRoutesResource(client);
|
|
603
|
+
}
|
|
604
|
+
members;
|
|
605
|
+
routes;
|
|
606
|
+
/** List campaigns for the authenticated tenant, paginated. */
|
|
607
|
+
async list(params = {}) {
|
|
608
|
+
return this.client.get(`/campaigns${buildQuery4(params)}`);
|
|
609
|
+
}
|
|
610
|
+
/** Create a new campaign in draft status against a published agent. */
|
|
611
|
+
async create(data) {
|
|
612
|
+
return this.client.post("/campaigns", data);
|
|
613
|
+
}
|
|
614
|
+
/** Retrieve a single campaign by id. */
|
|
615
|
+
async get(campaignId) {
|
|
616
|
+
return this.client.get(`/campaigns/${campaignId}`);
|
|
617
|
+
}
|
|
618
|
+
/** Update campaign policy/goal fields. Status and lifecycle fields are not writable here. */
|
|
619
|
+
async update(campaignId, data) {
|
|
620
|
+
return this.client.patch(`/campaigns/${campaignId}`, data);
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Launch a campaign: validates launch blockers, then stamps
|
|
624
|
+
* `launched_at` + `agent_snapshot_id`, flips members to `ready`, and
|
|
625
|
+
* transitions status to `running`.
|
|
626
|
+
*/
|
|
627
|
+
async launch(campaignId) {
|
|
628
|
+
return this.client.post(`/campaigns/${campaignId}/launch`);
|
|
629
|
+
}
|
|
630
|
+
/** Evaluate launch blockers without launching (dry run). Safe from any status. */
|
|
631
|
+
async launchBlockers(campaignId) {
|
|
632
|
+
return this.client.get(`/campaigns/${campaignId}/launch-blockers`);
|
|
633
|
+
}
|
|
634
|
+
/** Pause a running campaign. In-flight calls finish naturally. */
|
|
635
|
+
async pause(campaignId) {
|
|
636
|
+
return this.client.post(`/campaigns/${campaignId}/pause`);
|
|
637
|
+
}
|
|
638
|
+
/** Resume a paused campaign. */
|
|
639
|
+
async resume(campaignId) {
|
|
640
|
+
return this.client.post(`/campaigns/${campaignId}/resume`);
|
|
641
|
+
}
|
|
642
|
+
/** Archive a campaign. Terminal — the scheduler never selects work for it again. */
|
|
643
|
+
async archive(campaignId) {
|
|
644
|
+
return this.client.post(`/campaigns/${campaignId}/archive`);
|
|
645
|
+
}
|
|
646
|
+
/** Read the campaign report: `stat_*` summary counters + outcome/sentiment/hourly/snapshot distributions. */
|
|
647
|
+
async report(campaignId) {
|
|
648
|
+
return this.client.get(`/campaigns/${campaignId}/report`);
|
|
649
|
+
}
|
|
650
|
+
/** List a campaign's dial attempts, paginated. */
|
|
651
|
+
async attempts(campaignId, params = {}) {
|
|
652
|
+
return this.client.get(`/campaigns/${campaignId}/attempts${buildQuery4(params)}`);
|
|
653
|
+
}
|
|
654
|
+
/** List a campaign's sweep-claim batches, paginated. */
|
|
655
|
+
async batches(campaignId, params = {}) {
|
|
656
|
+
return this.client.get(`/campaigns/${campaignId}/batches${buildQuery4(params)}`);
|
|
657
|
+
}
|
|
658
|
+
/** List a campaign's follow-up jobs, paginated. */
|
|
659
|
+
async followups(campaignId, params = {}) {
|
|
660
|
+
return this.client.get(`/campaigns/${campaignId}/followups${buildQuery4(params)}`);
|
|
661
|
+
}
|
|
662
|
+
/** Run the improve engine: detectors gate an LLM proposal writer, persisting new `campaign_suggestions`. */
|
|
663
|
+
async improve(campaignId) {
|
|
664
|
+
return this.client.post(`/campaigns/${campaignId}/improve`);
|
|
665
|
+
}
|
|
666
|
+
/** List a campaign's improvement suggestions, paginated. */
|
|
667
|
+
async suggestions(campaignId, params = {}) {
|
|
668
|
+
return this.client.get(`/campaigns/${campaignId}/suggestions${buildQuery4(params)}`);
|
|
669
|
+
}
|
|
670
|
+
/** Accept a suggestion: agent-editing suggestions create an agent-changes draft; campaign-policy suggestions patch the campaign. */
|
|
671
|
+
async acceptSuggestion(campaignId, suggestionId) {
|
|
672
|
+
return this.client.post(`/campaigns/${campaignId}/suggestions/${suggestionId}/accept`);
|
|
673
|
+
}
|
|
674
|
+
/** Dismiss a suggestion without applying it. */
|
|
675
|
+
async dismissSuggestion(campaignId, suggestionId) {
|
|
676
|
+
return this.client.post(`/campaigns/${campaignId}/suggestions/${suggestionId}/dismiss`);
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
// src/resources/contacts.ts
|
|
681
|
+
function buildQuery5(params) {
|
|
682
|
+
const sp = new URLSearchParams();
|
|
683
|
+
for (const [k, v] of Object.entries(params)) {
|
|
684
|
+
if (v !== void 0 && v !== null) sp.set(k, String(v));
|
|
685
|
+
}
|
|
686
|
+
const q = sp.toString();
|
|
687
|
+
return q ? `?${q}` : "";
|
|
688
|
+
}
|
|
689
|
+
var ContactsResource = class {
|
|
690
|
+
constructor(client) {
|
|
691
|
+
this.client = client;
|
|
692
|
+
}
|
|
693
|
+
/** List tenant-level contacts, paginated. */
|
|
694
|
+
async list(params = {}) {
|
|
695
|
+
return this.client.get(`/contacts${buildQuery5(params)}`);
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Create a tenant-level contact. If a contact with the same
|
|
699
|
+
* (tenant, phone) already exists, the existing row is returned instead
|
|
700
|
+
* of creating a duplicate — check `deduped` in the response.
|
|
701
|
+
*/
|
|
702
|
+
async create(data) {
|
|
703
|
+
return this.client.post("/contacts", data);
|
|
704
|
+
}
|
|
705
|
+
/** Retrieve a single tenant-scoped contact by id. */
|
|
706
|
+
async get(contactId) {
|
|
707
|
+
return this.client.get(`/contacts/${contactId}`);
|
|
708
|
+
}
|
|
709
|
+
/** Update an existing tenant-scoped contact. Only provided fields change. */
|
|
710
|
+
async update(contactId, data) {
|
|
711
|
+
return this.client.patch(`/contacts/${contactId}`, data);
|
|
712
|
+
}
|
|
713
|
+
/** Delete a tenant-scoped contact. */
|
|
714
|
+
async delete(contactId) {
|
|
715
|
+
return this.client.delete(`/contacts/${contactId}`);
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Bulk import contacts from JSON rows or CSV text. Each row's phone is
|
|
719
|
+
* normalized to E.164 and upserted on (tenant_id, phone); rows with
|
|
720
|
+
* unparseable phones are skipped and reported in `invalid`.
|
|
721
|
+
*/
|
|
722
|
+
async import(data) {
|
|
723
|
+
return this.client.post("/contacts/import", data);
|
|
724
|
+
}
|
|
725
|
+
/** Record a consent grant or revoke for one channel, with evidence. Also
|
|
726
|
+
* appends an immutable row to the consent_events proof log. */
|
|
727
|
+
async setConsent(contactId, data) {
|
|
728
|
+
return this.client.patch(`/contacts/${contactId}/consent`, data);
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
// src/resources/compliance.ts
|
|
733
|
+
var ComplianceResource = class {
|
|
734
|
+
constructor(client) {
|
|
735
|
+
this.client = client;
|
|
736
|
+
}
|
|
737
|
+
/** Record a compliance attestation (append-only). Campaign launch blockers
|
|
738
|
+
* in `attested` mode read the most recent one of the matching `kind`. */
|
|
739
|
+
async attest(data) {
|
|
740
|
+
return this.client.post("/compliance/attestations", data);
|
|
741
|
+
}
|
|
742
|
+
/** List the tenant's 50 most recent compliance attestations, newest first. */
|
|
743
|
+
async listAttestations() {
|
|
744
|
+
return this.client.get("/compliance/attestations");
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
|
|
504
748
|
// src/index.ts
|
|
505
749
|
export * from "@rymi/sdk-types";
|
|
506
750
|
var Rymi = class {
|
|
@@ -514,6 +758,9 @@ var Rymi = class {
|
|
|
514
758
|
telephony;
|
|
515
759
|
billing;
|
|
516
760
|
templates;
|
|
761
|
+
campaigns;
|
|
762
|
+
contacts;
|
|
763
|
+
compliance;
|
|
517
764
|
constructor(options) {
|
|
518
765
|
this.client = new RymiClient(options);
|
|
519
766
|
this.agents = new AgentsResource(this.client);
|
|
@@ -525,6 +772,9 @@ var Rymi = class {
|
|
|
525
772
|
this.telephony = new TelephonyResource(this.client);
|
|
526
773
|
this.billing = new BillingResource(this.client);
|
|
527
774
|
this.templates = new TemplatesResource(this.client);
|
|
775
|
+
this.campaigns = new CampaignsResource(this.client);
|
|
776
|
+
this.contacts = new ContactsResource(this.client);
|
|
777
|
+
this.compliance = new ComplianceResource(this.client);
|
|
528
778
|
}
|
|
529
779
|
};
|
|
530
780
|
var index_default = Rymi;
|
|
@@ -532,6 +782,9 @@ export {
|
|
|
532
782
|
AgentsResource,
|
|
533
783
|
BillingResource,
|
|
534
784
|
CallsResource,
|
|
785
|
+
CampaignsResource,
|
|
786
|
+
ComplianceResource,
|
|
787
|
+
ContactsResource,
|
|
535
788
|
DncResource,
|
|
536
789
|
KeysResource,
|
|
537
790
|
NumbersResource,
|