@dialgem/sdk 0.1.0-beta.1 → 0.1.0-beta.3
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/CHANGELOG.md +23 -1
- package/README.md +89 -10
- package/dist/index.cjs +505 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1713 -48
- package/dist/index.d.ts +1713 -48
- package/dist/index.js +505 -3
- package/dist/index.js.map +1 -1
- package/examples/webhook-express.ts +12 -4
- package/examples/webhook-fastify.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -106,10 +106,10 @@ function isErrorBody(body) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// src/version.ts
|
|
109
|
-
var VERSION = "0.1.0-beta.
|
|
109
|
+
var VERSION = "0.1.0-beta.3";
|
|
110
110
|
|
|
111
111
|
// src/core/http.ts
|
|
112
|
-
var RETRYABLE_METHODS = /* @__PURE__ */ new Set(["GET", "PATCH", "DELETE"]);
|
|
112
|
+
var RETRYABLE_METHODS = /* @__PURE__ */ new Set(["GET", "PUT", "PATCH", "DELETE"]);
|
|
113
113
|
var MAX_RETRY_DELAY_MS = 6e4;
|
|
114
114
|
var HttpClient = class {
|
|
115
115
|
baseURL;
|
|
@@ -142,6 +142,9 @@ var HttpClient = class {
|
|
|
142
142
|
postForm(path2, form, options) {
|
|
143
143
|
return this.request("POST", path2, { body: form, options });
|
|
144
144
|
}
|
|
145
|
+
put(path2, body, options) {
|
|
146
|
+
return this.request("PUT", path2, { body, options });
|
|
147
|
+
}
|
|
145
148
|
patch(path2, body, options) {
|
|
146
149
|
return this.request("PATCH", path2, { body, options });
|
|
147
150
|
}
|
|
@@ -444,6 +447,13 @@ var AgentMCPServers = class extends APIResource {
|
|
|
444
447
|
return this._client.delete(path`/v1/agents/${agentId}/mcp-servers/${serverId}`, options);
|
|
445
448
|
}
|
|
446
449
|
/** Connect to the server now, list its tools, and store the result as `last_status`. */
|
|
450
|
+
/**
|
|
451
|
+
* What the server offers right now, with each tool's description and argument schema. Connects live like
|
|
452
|
+
* `test`, but stores nothing. An unreachable server is not an error: `tools` is empty and `error` says why.
|
|
453
|
+
*/
|
|
454
|
+
listTools(agentId, serverId, options) {
|
|
455
|
+
return this._client.get(path`/v1/agents/${agentId}/mcp-servers/${serverId}/tools`, void 0, options);
|
|
456
|
+
}
|
|
447
457
|
test(agentId, serverId, options) {
|
|
448
458
|
return this._client.post(path`/v1/agents/${agentId}/mcp-servers/${serverId}/test`, void 0, options);
|
|
449
459
|
}
|
|
@@ -535,6 +545,20 @@ var Calls = class extends APIResource {
|
|
|
535
545
|
delete(callId, options) {
|
|
536
546
|
return this._client.delete(path`/v1/calls/${callId}`, options);
|
|
537
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* Run a finished call's post-call analysis again, with the agent's *current* analysis
|
|
550
|
+
* settings, and return the updated call. Use it after changing the fields or the model
|
|
551
|
+
* and wanting an older call read the new way.
|
|
552
|
+
*
|
|
553
|
+
* It replaces `analysis`; it does not bill the call again and does not send `call_analyzed`
|
|
554
|
+
* again, so read the result from this response or from `retrieve`. The model call can take
|
|
555
|
+
* a while. `ConflictError` with `errCode` `call_in_progress` until the call has ended,
|
|
556
|
+
* `no_transcript` when there is nothing to analyze, `agent_deleted` if the agent is gone.
|
|
557
|
+
* Not retried by default.
|
|
558
|
+
*/
|
|
559
|
+
rerunAnalysis(callId, options) {
|
|
560
|
+
return this._client.post(path`/v1/calls/${callId}/rerun-analysis`, void 0, options);
|
|
561
|
+
}
|
|
538
562
|
/**
|
|
539
563
|
* End an ongoing call now, as if the agent had hung up. The call becomes
|
|
540
564
|
* `completed` with `disconnection_reason: "manual_stopped"` a moment later, and
|
|
@@ -631,6 +655,12 @@ var Voices = class extends APIResource {
|
|
|
631
655
|
return this._client.delete(path`/v1/voices/${voiceId}`, options);
|
|
632
656
|
}
|
|
633
657
|
};
|
|
658
|
+
var ExtractionModels = class extends APIResource {
|
|
659
|
+
/** Models an agent may use for post-call analysis, with an estimated cost per session. */
|
|
660
|
+
list(options) {
|
|
661
|
+
return this._client.get("/v1/models/extraction", void 0, options);
|
|
662
|
+
}
|
|
663
|
+
};
|
|
634
664
|
var FlowTemplates = class extends APIResource {
|
|
635
665
|
/** Built-in conversation-flow templates (summaries, without `flow_config`). */
|
|
636
666
|
list(params = {}, options) {
|
|
@@ -650,12 +680,308 @@ var PromptTemplates = class extends APIResource {
|
|
|
650
680
|
}
|
|
651
681
|
};
|
|
652
682
|
|
|
683
|
+
// src/resources/account.ts
|
|
684
|
+
var ApiKey = class extends APIResource {
|
|
685
|
+
/**
|
|
686
|
+
* Who this key is: your organization and the key's name, prefix, scopes, allowed addresses
|
|
687
|
+
* and expiry. It answers for any valid key whatever its scopes, so an integration can check
|
|
688
|
+
* what it was given. Never returns the secret.
|
|
689
|
+
*
|
|
690
|
+
* ```ts
|
|
691
|
+
* const { key } = await dialgem.apiKey.retrieve()
|
|
692
|
+
* if (key && !key.full_access) console.log("scoped to", key.scopes)
|
|
693
|
+
* ```
|
|
694
|
+
*/
|
|
695
|
+
retrieve(options) {
|
|
696
|
+
return this._client.get("/v1/api-key-info", void 0, options);
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
var Sessions = class extends APIResource {
|
|
700
|
+
/**
|
|
701
|
+
* The calls your organization has in progress right now, with a `count`.
|
|
702
|
+
*
|
|
703
|
+
* Live state read from the service's own registry — use it for a
|
|
704
|
+
* concurrency check before placing a call. For finished calls use
|
|
705
|
+
* `calls.list`; a call whose teardown never arrived is not counted here.
|
|
706
|
+
*/
|
|
707
|
+
list(options) {
|
|
708
|
+
return this._client.get("/v1/agent/sessions", void 0, options);
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Change a live call's prompt and/or variables. It applies from the agent's **next turn**.
|
|
712
|
+
*
|
|
713
|
+
* `sessionId` is a session's `session_id` from `list`, or the call's own `call_id`. Only this call changes:
|
|
714
|
+
* the agent, its published versions and other calls are untouched, and the change is gone when the call ends.
|
|
715
|
+
* A turn already being spoken finishes as it was. `dynamic_variables` are merged over the call's variables;
|
|
716
|
+
* `system_prompt` replaces the prompt for the rest of the call.
|
|
717
|
+
*
|
|
718
|
+
* The call may be on any service instance. `NotFoundError` if it is not live (or is another organization's),
|
|
719
|
+
* `ConflictError` with `errCode` `session_ended` once it is over, `UnprocessableEntityError` with `errCode`
|
|
720
|
+
* `flow_agent_prompt` for a flow agent's prompt (its variables can still change). Not retried by default.
|
|
721
|
+
*
|
|
722
|
+
* ```ts
|
|
723
|
+
* await dialgem.sessions.update(callId, { dynamic_variables: { plan: "pro" } })
|
|
724
|
+
* ```
|
|
725
|
+
*/
|
|
726
|
+
update(sessionId, body, options) {
|
|
727
|
+
return this._client.patch(path`/v1/agent/sessions/${sessionId}`, body, options);
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Make the agent say `text` on a live call, in its own voice. Answers at once; the line plays behind what the
|
|
731
|
+
* agent is saying, or now with `interrupt: true`. The agent's conversation records it as something it said.
|
|
732
|
+
*
|
|
733
|
+
* Off unless the deployment enables live control: `ForbiddenError` with `errCode` `live_control_disabled`.
|
|
734
|
+
* `ConflictError` `human_has_call` while a human has taken the call. Owners, admins and API keys only.
|
|
735
|
+
* Not retried by default.
|
|
736
|
+
*
|
|
737
|
+
* ```ts
|
|
738
|
+
* await dialgem.sessions.say(callId, { text: "One moment while I check that." })
|
|
739
|
+
* ```
|
|
740
|
+
*/
|
|
741
|
+
say(sessionId, body, options) {
|
|
742
|
+
return this._client.post(path`/v1/agent/sessions/${sessionId}/say`, body, options);
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Hand a taken-over call back to the agent, for when the socket that took it is gone. The agent is told a
|
|
746
|
+
* human had the call and that it did not hear what was said. Same availability and limits as `say`.
|
|
747
|
+
* Listening in and taking over run over a WebSocket (`/v1/agent/sessions/{id}/live`), which this SDK does not wrap.
|
|
748
|
+
*/
|
|
749
|
+
release(sessionId, options) {
|
|
750
|
+
return this._client.post(path`/v1/agent/sessions/${sessionId}/release`, void 0, options);
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
// src/resources/simulations.ts
|
|
755
|
+
var Simulations = class extends APIResource {
|
|
756
|
+
/** Make a suite for one of your agents. */
|
|
757
|
+
createSuite(body, options) {
|
|
758
|
+
return this._client.post("/v1/simulations/suites", body, options);
|
|
759
|
+
}
|
|
760
|
+
/** Your suites, newest first, each with its latest run. Pass `agent_id` for one agent's. */
|
|
761
|
+
listSuites(params = {}, options) {
|
|
762
|
+
return this._client.get("/v1/simulations/suites", params, options);
|
|
763
|
+
}
|
|
764
|
+
/** One suite with its cases. */
|
|
765
|
+
retrieveSuite(suiteId, options) {
|
|
766
|
+
return this._client.get(path`/v1/simulations/suites/${suiteId}`, void 0, options);
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Rename a suite or set its publish gate: `off`, `warn` (publishing a version succeeds and lists the suites the draft
|
|
770
|
+
* has not passed) or `block` (publishing is refused with 409 `simulation_required` until it has).
|
|
771
|
+
*/
|
|
772
|
+
updateSuite(suiteId, body, options) {
|
|
773
|
+
return this._client.patch(path`/v1/simulations/suites/${suiteId}`, body, options);
|
|
774
|
+
}
|
|
775
|
+
/** Delete a suite and its cases. Past runs are deleted with it. */
|
|
776
|
+
deleteSuite(suiteId, options) {
|
|
777
|
+
return this._client.delete(path`/v1/simulations/suites/${suiteId}`, options);
|
|
778
|
+
}
|
|
779
|
+
/** Add a case (up to 50 per suite). 422 `invalid_case` says what to fix. */
|
|
780
|
+
createCase(suiteId, body, options) {
|
|
781
|
+
return this._client.post(path`/v1/simulations/suites/${suiteId}/cases`, body, options);
|
|
782
|
+
}
|
|
783
|
+
/** Change a case. Fields you leave out keep their value. */
|
|
784
|
+
updateCase(caseId, body, options) {
|
|
785
|
+
return this._client.patch(path`/v1/simulations/cases/${caseId}`, body, options);
|
|
786
|
+
}
|
|
787
|
+
deleteCase(caseId, options) {
|
|
788
|
+
return this._client.delete(path`/v1/simulations/cases/${caseId}`, options);
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Run every case of a suite against the draft, a published version or `"latest_published"`. Answers at once
|
|
792
|
+
* (`202`); the run happens in the background, so poll `retrieveRun` until `status` is `completed`.
|
|
793
|
+
*
|
|
794
|
+
* 409 `suite_empty`, 422 `agent_type_not_supported` (multi-prompt agents), 429 `too_many_runs` or
|
|
795
|
+
* `daily_run_limit`.
|
|
796
|
+
*/
|
|
797
|
+
run(suiteId, body = {}, options) {
|
|
798
|
+
return this._client.post(path`/v1/simulations/suites/${suiteId}/runs`, body, options);
|
|
799
|
+
}
|
|
800
|
+
/** Runs, newest first. Pass `suite_id` for one suite's. */
|
|
801
|
+
listRuns(params = {}, options) {
|
|
802
|
+
return this._client.get("/v1/simulations/runs", params, options);
|
|
803
|
+
}
|
|
804
|
+
/** A run with every case's transcript, tool calls and check results. */
|
|
805
|
+
retrieveRun(runId, options) {
|
|
806
|
+
return this._client.get(path`/v1/simulations/runs/${runId}`, void 0, options);
|
|
807
|
+
}
|
|
808
|
+
/** Stop a run that has not finished. Cases already under way finish; the rest are skipped. */
|
|
809
|
+
cancelRun(runId, options) {
|
|
810
|
+
return this._client.post(path`/v1/simulations/runs/${runId}/cancel`, void 0, options);
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
// src/resources/web-calls.ts
|
|
815
|
+
var WebCalls = class extends APIResource {
|
|
816
|
+
/**
|
|
817
|
+
* Create a call for one visitor and get its access token.
|
|
818
|
+
*
|
|
819
|
+
* const { access_token } = await dialgem.webCalls.create({ agent_id, metadata: { visitor: "v_123" } })
|
|
820
|
+
*
|
|
821
|
+
* `metadata` and `dialgem_llm_dynamic_variables` are fixed here, by you, and cannot be changed by the page.
|
|
822
|
+
* 409 `web_origins_not_configured` until an origin is allowed; 402 if the organization cannot pay for calls;
|
|
823
|
+
* 429 when more than `limits.tokens_per_minute` calls are created in a minute.
|
|
824
|
+
*/
|
|
825
|
+
create(body, options) {
|
|
826
|
+
return this._client.post("/v1/calls/web", body, options);
|
|
827
|
+
}
|
|
828
|
+
/** The origins browser calls may start from, and the limits that apply. */
|
|
829
|
+
retrieveSettings(options) {
|
|
830
|
+
return this._client.get("/v1/web-calls/settings", void 0, options);
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Replace the allowed origins. Each is `scheme://host[:port]`; `https://*.example.com` allows any subdomain
|
|
834
|
+
* (not the bare domain) and `*` allows any website. Tokens already issued keep the list they were issued with.
|
|
835
|
+
*/
|
|
836
|
+
updateSettings(body, options) {
|
|
837
|
+
return this._client.put("/v1/web-calls/settings", body, options);
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
// src/resources/contacts.ts
|
|
842
|
+
var Contacts = class extends APIResource {
|
|
843
|
+
/** Bulk import from CSV, with a dry-run preview. */
|
|
844
|
+
imports;
|
|
845
|
+
constructor(client) {
|
|
846
|
+
super(client);
|
|
847
|
+
this.imports = new ContactImports(client);
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Add a contact. `phone` is any way of writing a valid number; without a leading `+`
|
|
851
|
+
* also pass `default_country` (`"US"`). A number that is already a contact answers 409
|
|
852
|
+
* with its `contact_id`.
|
|
853
|
+
*/
|
|
854
|
+
create(body, options) {
|
|
855
|
+
return this._client.post("/v1/contacts", body, options);
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Contacts, newest first. Await for one page, or iterate for every contact:
|
|
859
|
+
*
|
|
860
|
+
*/
|
|
861
|
+
list(params = {}, options) {
|
|
862
|
+
const fetchPage = async (cursor) => {
|
|
863
|
+
const res = await this._client.get(
|
|
864
|
+
"/v1/contacts",
|
|
865
|
+
{ ...params, cursor: cursor ?? void 0 },
|
|
866
|
+
options
|
|
867
|
+
);
|
|
868
|
+
return { data: res.contacts, has_more: res.next_cursor !== null, pagination_key: res.next_cursor };
|
|
869
|
+
};
|
|
870
|
+
return new PagePromise(fetchPage);
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* The contact with this phone number. The number is matched as E.164, so
|
|
874
|
+
* `("(212) 220-0001", { default_country: "US" })` finds `+12122200001`. Throws
|
|
875
|
+
* `NotFoundError` if you have no such contact, and `UnprocessableEntityError` if the text is
|
|
876
|
+
* not a phone number.
|
|
877
|
+
*/
|
|
878
|
+
retrieveByPhone(phone, params = {}, options) {
|
|
879
|
+
return this._client.get(path`/v1/contacts/by-phone/${phone}`, params, options);
|
|
880
|
+
}
|
|
881
|
+
/** One contact, with its lists and how many calls it has had. */
|
|
882
|
+
retrieve(contactId, options) {
|
|
883
|
+
return this._client.get(path`/v1/contacts/${contactId}`, void 0, options);
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Partial update: only the fields you send change, and `null` clears a field.
|
|
887
|
+
* `attributes` replaces the whole set, so send every field you want kept.
|
|
888
|
+
*/
|
|
889
|
+
update(contactId, body, options) {
|
|
890
|
+
return this._client.patch(path`/v1/contacts/${contactId}`, body, options);
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Erase a contact and its list memberships. Calls already made stay in the call log, and
|
|
894
|
+
* a do-not-call entry for the number stays too, so forgetting a person never makes a number
|
|
895
|
+
* that asked not to be called dialable again.
|
|
896
|
+
*/
|
|
897
|
+
delete(contactId, options) {
|
|
898
|
+
return this._client.delete(path`/v1/contacts/${contactId}`, options);
|
|
899
|
+
}
|
|
900
|
+
/** Calls to or from the contact's number, newest first. Summaries, not transcripts. */
|
|
901
|
+
calls(contactId, params = {}, options) {
|
|
902
|
+
return this._client.get(path`/v1/contacts/${contactId}/calls`, params, options);
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
var ContactImports = class extends APIResource {
|
|
906
|
+
/** The file's headers, a guessed column mapping and a few rows. Imports nothing. */
|
|
907
|
+
inspect(csv, options) {
|
|
908
|
+
return this._client.post("/v1/contacts/imports/inspect", { csv }, options);
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Start an import. Without `mapping` the columns are guessed from the headers. With
|
|
912
|
+
* `dry_run: true` nothing is written: the import only validates and reports.
|
|
913
|
+
*/
|
|
914
|
+
create(body, options) {
|
|
915
|
+
return this._client.post("/v1/contacts/imports", body, options);
|
|
916
|
+
}
|
|
917
|
+
/** Recent imports, newest first. */
|
|
918
|
+
list(options) {
|
|
919
|
+
return this._client.get("/v1/contacts/imports", void 0, options);
|
|
920
|
+
}
|
|
921
|
+
/** Progress and counts. */
|
|
922
|
+
retrieve(importId, options) {
|
|
923
|
+
return this._client.get(path`/v1/contacts/imports/${importId}`, void 0, options);
|
|
924
|
+
}
|
|
925
|
+
/** The rows that were rejected, with the line, the reason and what each held. */
|
|
926
|
+
errors(importId, params = {}, options) {
|
|
927
|
+
return this._client.get(path`/v1/contacts/imports/${importId}/errors`, params, options);
|
|
928
|
+
}
|
|
929
|
+
/** Apply a previewed import: the file is read again, so what is applied is what was previewed. */
|
|
930
|
+
commit(importId, options) {
|
|
931
|
+
return this._client.post(path`/v1/contacts/imports/${importId}/commit`, void 0, options);
|
|
932
|
+
}
|
|
933
|
+
/** Stop an import that has not finished. Contacts a running import already wrote stay. */
|
|
934
|
+
cancel(importId, options) {
|
|
935
|
+
return this._client.delete(path`/v1/contacts/imports/${importId}`, options);
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
var ContactLists = class extends APIResource {
|
|
939
|
+
list(options) {
|
|
940
|
+
return this._client.get("/v1/contact-lists", void 0, options);
|
|
941
|
+
}
|
|
942
|
+
/** Names are unique within your organization, ignoring case. */
|
|
943
|
+
create(body, options) {
|
|
944
|
+
return this._client.post("/v1/contact-lists", body, options);
|
|
945
|
+
}
|
|
946
|
+
retrieve(listId, options) {
|
|
947
|
+
return this._client.get(path`/v1/contact-lists/${listId}`, void 0, options);
|
|
948
|
+
}
|
|
949
|
+
update(listId, body, options) {
|
|
950
|
+
return this._client.patch(path`/v1/contact-lists/${listId}`, body, options);
|
|
951
|
+
}
|
|
952
|
+
delete(listId, options) {
|
|
953
|
+
return this._client.delete(path`/v1/contact-lists/${listId}`, options);
|
|
954
|
+
}
|
|
955
|
+
/** Add up to 1000 of your contacts. Already-members are ignored; `added` says how many were new. */
|
|
956
|
+
addContacts(listId, contactIds, options) {
|
|
957
|
+
return this._client.post(path`/v1/contact-lists/${listId}/members`, { contact_ids: contactIds }, options);
|
|
958
|
+
}
|
|
959
|
+
removeContact(listId, contactId, options) {
|
|
960
|
+
return this._client.delete(path`/v1/contact-lists/${listId}/members/${contactId}`, options);
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
|
|
653
964
|
// src/resources/phone-numbers.ts
|
|
654
965
|
var PhoneNumbers = class extends APIResource {
|
|
655
966
|
/** Register a number you own (`phone_number` in E.164) with Dialgem. */
|
|
656
967
|
create(body, options) {
|
|
657
968
|
return this._client.post("/v1/phone-numbers", body, options);
|
|
658
969
|
}
|
|
970
|
+
/**
|
|
971
|
+
* Numbers that can be bought, with the monthly price. Throws `NotFoundError` (`number_purchase_disabled`) when the
|
|
972
|
+
* deployment has not switched buying on.
|
|
973
|
+
*/
|
|
974
|
+
search(params, options) {
|
|
975
|
+
return this._client.get("/v1/phone-numbers/available", { ...params }, options);
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Buy one of the numbers `search` returned. **Spends the organization's credit**: the first month is debited now and
|
|
979
|
+
* the rental renews monthly until the number is released. Throws on insufficient credit, or if the carrier no longer
|
|
980
|
+
* has the number; nothing is charged in either case.
|
|
981
|
+
*/
|
|
982
|
+
buy(body, options) {
|
|
983
|
+
return this._client.post("/v1/phone-numbers/buy", body, options);
|
|
984
|
+
}
|
|
659
985
|
/** Every active (not released) number in the organization, newest first. */
|
|
660
986
|
list(options) {
|
|
661
987
|
return this._client.get("/v1/phone-numbers", void 0, options);
|
|
@@ -689,15 +1015,159 @@ var PhoneNumbers = class extends APIResource {
|
|
|
689
1015
|
assign(phoneNumberId, body, options) {
|
|
690
1016
|
return this._client.patch(path`/v1/phone-numbers/${phoneNumberId}/assign`, body, options);
|
|
691
1017
|
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Send one signed test request to the number's inbound routing webhook and report what a real call would have done
|
|
1020
|
+
* with your answer: the status, how long you took against the time budget, and any field that would be ignored.
|
|
1021
|
+
* Throws a `ConflictError` (`inbound_webhook_not_set`) when the number has no `inbound_webhook_url`.
|
|
1022
|
+
*/
|
|
1023
|
+
testInboundWebhook(phoneNumberId, options) {
|
|
1024
|
+
return this._client.post(path`/v1/phone-numbers/${phoneNumberId}/inbound-webhook/test`, void 0, options);
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Replace the inbound webhook's signing secret. The new secret is returned **once**, as `inbound_webhook_secret`
|
|
1028
|
+
* on the number; the old one stops working at once.
|
|
1029
|
+
*/
|
|
1030
|
+
rotateInboundWebhookSecret(phoneNumberId, options) {
|
|
1031
|
+
return this._client.post(path`/v1/phone-numbers/${phoneNumberId}/inbound-webhook/rotate-secret`, void 0, options);
|
|
1032
|
+
}
|
|
692
1033
|
/** Release the number from Dialgem. It stops routing calls and disappears from `list()`; your carrier account is untouched. */
|
|
693
1034
|
delete(phoneNumberId, options) {
|
|
694
1035
|
return this._client.delete(path`/v1/phone-numbers/${phoneNumberId}`, options);
|
|
695
1036
|
}
|
|
696
1037
|
};
|
|
697
1038
|
|
|
1039
|
+
// src/resources/chats.ts
|
|
1040
|
+
var Chats = class extends APIResource {
|
|
1041
|
+
/**
|
|
1042
|
+
* Start a chat. If the agent has a first message it is already in `messages`.
|
|
1043
|
+
*
|
|
1044
|
+
* `UnprocessableEntityError` with `errCode` `agent_type_not_supported` (flow agents) or `chat_requires_storage`.
|
|
1045
|
+
* Not retried by default.
|
|
1046
|
+
*/
|
|
1047
|
+
create(body, options) {
|
|
1048
|
+
return this._client.post("/v1/chats", body, options);
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Chats, newest first. Await for one page, or iterate for every chat. Entries leave out `messages`;
|
|
1052
|
+
* `retrieve` a chat for them.
|
|
1053
|
+
*/
|
|
1054
|
+
list(params = {}, options) {
|
|
1055
|
+
const fetchPage = async (paginationKey) => {
|
|
1056
|
+
const res = await this._client.get(
|
|
1057
|
+
"/v1/chats",
|
|
1058
|
+
{ ...params, pagination_key: paginationKey ?? void 0 },
|
|
1059
|
+
options
|
|
1060
|
+
);
|
|
1061
|
+
return { data: res.chats, has_more: res.has_more, pagination_key: res.pagination_key };
|
|
1062
|
+
};
|
|
1063
|
+
return new PagePromise(fetchPage);
|
|
1064
|
+
}
|
|
1065
|
+
/** One chat with all its messages. */
|
|
1066
|
+
retrieve(chatId, options) {
|
|
1067
|
+
return this._client.get(path`/v1/chats/${chatId}`, void 0, options);
|
|
1068
|
+
}
|
|
1069
|
+
/** Replace the chat's `metadata` (the whole object). */
|
|
1070
|
+
update(chatId, body, options) {
|
|
1071
|
+
return this._client.patch(path`/v1/chats/${chatId}`, body, options);
|
|
1072
|
+
}
|
|
1073
|
+
/** Delete a chat and its messages. */
|
|
1074
|
+
delete(chatId, options) {
|
|
1075
|
+
return this._client.delete(path`/v1/chats/${chatId}`, options);
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Send the user's message and wait for the agent's reply. Returns only the new entries, in order: the user's
|
|
1079
|
+
* message, any tool use, the agent's reply.
|
|
1080
|
+
*
|
|
1081
|
+
* If the agent's model fails (`ServerError`, `errCode` `model_error`) nothing is stored and the same message
|
|
1082
|
+
* can be sent again. `ConflictError` with `errCode` `chat_busy` while another reply is in progress,
|
|
1083
|
+
* `chat_ended` after the end, `message_limit` at the cap. If the agent calls its end-call tool, the reply's
|
|
1084
|
+
* `chat_status` is `ended`.
|
|
1085
|
+
*
|
|
1086
|
+
* Not retried by default: a retry after an ambiguous failure could send the message twice.
|
|
1087
|
+
*/
|
|
1088
|
+
sendMessage(chatId, content, options) {
|
|
1089
|
+
return this._client.post(path`/v1/chats/${chatId}/messages`, { content }, options);
|
|
1090
|
+
}
|
|
1091
|
+
/** End the chat. Ending twice is fine. The analysis arrives a moment later; read it with `retrieve`. */
|
|
1092
|
+
end(chatId, options) {
|
|
1093
|
+
return this._client.post(path`/v1/chats/${chatId}/end`, void 0, options);
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Analyse an ended chat again with the agent's current analysis settings and return it. `ConflictError` with
|
|
1097
|
+
* `errCode` `chat_in_progress` until it has ended, `no_transcript` when it has no messages.
|
|
1098
|
+
*/
|
|
1099
|
+
rerunAnalysis(chatId, options) {
|
|
1100
|
+
return this._client.post(path`/v1/chats/${chatId}/rerun-analysis`, void 0, options);
|
|
1101
|
+
}
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
// src/resources/flows.ts
|
|
1105
|
+
var Flows = class extends APIResource {
|
|
1106
|
+
/** Validate and save a flow. `UnprocessableEntityError` (`errCode` `flow_invalid`) lists every problem. Not retried by default. */
|
|
1107
|
+
create(body, options) {
|
|
1108
|
+
return this._client.post("/v1/flows", body, options);
|
|
1109
|
+
}
|
|
1110
|
+
/** Flows, newest first. Await for one page, or iterate for every flow. Entries leave out `flow_config`. */
|
|
1111
|
+
list(params = {}, options) {
|
|
1112
|
+
const fetchPage = async (paginationKey) => {
|
|
1113
|
+
const res = await this._client.get(
|
|
1114
|
+
"/v1/flows",
|
|
1115
|
+
{ ...params, pagination_key: paginationKey ?? void 0 },
|
|
1116
|
+
options
|
|
1117
|
+
);
|
|
1118
|
+
return { data: res.flows, has_more: res.has_more, pagination_key: res.pagination_key };
|
|
1119
|
+
};
|
|
1120
|
+
return new PagePromise(fetchPage);
|
|
1121
|
+
}
|
|
1122
|
+
/** One flow with its `flow_config`. */
|
|
1123
|
+
retrieve(flowId, options) {
|
|
1124
|
+
return this._client.get(path`/v1/flows/${flowId}`, void 0, options);
|
|
1125
|
+
}
|
|
1126
|
+
/** Rename a flow and/or replace its `flow_config` (checked again). Agents it was attached to are not changed. */
|
|
1127
|
+
update(flowId, body, options) {
|
|
1128
|
+
return this._client.patch(path`/v1/flows/${flowId}`, body, options);
|
|
1129
|
+
}
|
|
1130
|
+
/** Delete a saved flow. Agents it was attached to keep their copy. */
|
|
1131
|
+
delete(flowId, options) {
|
|
1132
|
+
return this._client.delete(path`/v1/flows/${flowId}`, options);
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
|
|
1136
|
+
// src/resources/llms.ts
|
|
1137
|
+
var LLMs = class extends APIResource {
|
|
1138
|
+
/** Save LLM settings. Anything left out takes the default a new agent gets. Not retried by default. */
|
|
1139
|
+
create(body, options) {
|
|
1140
|
+
return this._client.post("/v1/llms", body, options);
|
|
1141
|
+
}
|
|
1142
|
+
/** Saved LLMs, newest first. Await for one page, or iterate for every one. */
|
|
1143
|
+
list(params = {}, options) {
|
|
1144
|
+
const fetchPage = async (paginationKey) => {
|
|
1145
|
+
const res = await this._client.get(
|
|
1146
|
+
"/v1/llms",
|
|
1147
|
+
{ ...params, pagination_key: paginationKey ?? void 0 },
|
|
1148
|
+
options
|
|
1149
|
+
);
|
|
1150
|
+
return { data: res.llms, has_more: res.has_more, pagination_key: res.pagination_key };
|
|
1151
|
+
};
|
|
1152
|
+
return new PagePromise(fetchPage);
|
|
1153
|
+
}
|
|
1154
|
+
retrieve(llmId, options) {
|
|
1155
|
+
return this._client.get(path`/v1/llms/${llmId}`, void 0, options);
|
|
1156
|
+
}
|
|
1157
|
+
/** Change the fields you send. Agents it was attached to are not changed. */
|
|
1158
|
+
update(llmId, body, options) {
|
|
1159
|
+
return this._client.patch(path`/v1/llms/${llmId}`, body, options);
|
|
1160
|
+
}
|
|
1161
|
+
/** Delete saved LLM settings. Agents they were attached to keep their copy. */
|
|
1162
|
+
delete(llmId, options) {
|
|
1163
|
+
return this._client.delete(path`/v1/llms/${llmId}`, options);
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
1166
|
+
|
|
698
1167
|
// src/webhooks.ts
|
|
699
1168
|
var WEBHOOK_SIGNATURE_HEADER = "x-dialgem-signature";
|
|
700
1169
|
var WEBHOOK_EVENT_HEADER = "x-dialgem-event";
|
|
1170
|
+
var WEBHOOK_PREVIOUS_SIGNATURE_HEADER = "x-dialgem-signature-previous";
|
|
701
1171
|
var WEBHOOK_DELIVERY_HEADER = "x-dialgem-delivery";
|
|
702
1172
|
var DEFAULT_SIGNATURE_TOLERANCE_MS = 5 * 60 * 1e3;
|
|
703
1173
|
var encoder = new TextEncoder();
|
|
@@ -816,9 +1286,31 @@ var Dialgem = class {
|
|
|
816
1286
|
calls;
|
|
817
1287
|
phoneNumbers;
|
|
818
1288
|
voices;
|
|
1289
|
+
/** Models available for post-call analysis. */
|
|
1290
|
+
extractionModels;
|
|
819
1291
|
flowTemplates;
|
|
820
1292
|
promptTemplates;
|
|
1293
|
+
/** Calls in progress right now. */
|
|
1294
|
+
sessions;
|
|
1295
|
+
/** Text conversations with an agent. */
|
|
1296
|
+
chats;
|
|
1297
|
+
flows;
|
|
1298
|
+
llms;
|
|
1299
|
+
/** What this API key is and may do. */
|
|
1300
|
+
apiKey;
|
|
1301
|
+
/**
|
|
1302
|
+
* Verify what Dialgem sends you: `dialgem.webhooks.constructEvent(rawBody, signatureHeader, secret)`.
|
|
1303
|
+
*/
|
|
821
1304
|
webhooks = webhooks;
|
|
1305
|
+
/** The organization's webhook destinations: create, update, rotate the signing secret, test. */
|
|
1306
|
+
/** The people you call, with CSV import under `contacts.imports`. */
|
|
1307
|
+
contacts;
|
|
1308
|
+
/** Named groups of contacts. */
|
|
1309
|
+
contactLists;
|
|
1310
|
+
/** Browser calls: tokens for `@dialgem/client`, and the origins allowed to start them. */
|
|
1311
|
+
webCalls;
|
|
1312
|
+
/** Saved test conversations for an agent, run in text, with an optional publish gate. */
|
|
1313
|
+
simulations;
|
|
822
1314
|
/** Always `https://api.dialgem.com`. */
|
|
823
1315
|
baseURL = BASE_URL;
|
|
824
1316
|
constructor(options = {}) {
|
|
@@ -855,8 +1347,18 @@ var Dialgem = class {
|
|
|
855
1347
|
this.calls = new Calls(http);
|
|
856
1348
|
this.phoneNumbers = new PhoneNumbers(http);
|
|
857
1349
|
this.voices = new Voices(http);
|
|
1350
|
+
this.extractionModels = new ExtractionModels(http);
|
|
858
1351
|
this.flowTemplates = new FlowTemplates(http);
|
|
859
1352
|
this.promptTemplates = new PromptTemplates(http);
|
|
1353
|
+
this.sessions = new Sessions(http);
|
|
1354
|
+
this.chats = new Chats(http);
|
|
1355
|
+
this.flows = new Flows(http);
|
|
1356
|
+
this.llms = new LLMs(http);
|
|
1357
|
+
this.apiKey = new ApiKey(http);
|
|
1358
|
+
this.contacts = new Contacts(http);
|
|
1359
|
+
this.contactLists = new ContactLists(http);
|
|
1360
|
+
this.webCalls = new WebCalls(http);
|
|
1361
|
+
this.simulations = new Simulations(http);
|
|
860
1362
|
}
|
|
861
1363
|
};
|
|
862
1364
|
function readEnv(name) {
|
|
@@ -897,6 +1399,7 @@ exports.UnprocessableEntityError = UnprocessableEntityError;
|
|
|
897
1399
|
exports.VERSION = VERSION;
|
|
898
1400
|
exports.WEBHOOK_DELIVERY_HEADER = WEBHOOK_DELIVERY_HEADER;
|
|
899
1401
|
exports.WEBHOOK_EVENT_HEADER = WEBHOOK_EVENT_HEADER;
|
|
1402
|
+
exports.WEBHOOK_PREVIOUS_SIGNATURE_HEADER = WEBHOOK_PREVIOUS_SIGNATURE_HEADER;
|
|
900
1403
|
exports.WEBHOOK_SIGNATURE_HEADER = WEBHOOK_SIGNATURE_HEADER;
|
|
901
1404
|
exports.WebhookVerificationError = WebhookVerificationError;
|
|
902
1405
|
exports.Webhooks = Webhooks;
|