@naturali/sdk 0.47.1 → 0.48.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.cjs +266 -144
- package/dist/index.d.cts +917 -314
- package/dist/index.d.mts +917 -314
- package/dist/index.mjs +266 -144
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -603,6 +603,272 @@ const createClient = (config = {}) => {
|
|
|
603
603
|
const client = createClient(createConfig());
|
|
604
604
|
//#endregion
|
|
605
605
|
//#region src/generated/sdk.gen.ts
|
|
606
|
+
var Channels = class {
|
|
607
|
+
/**
|
|
608
|
+
* List addresses
|
|
609
|
+
*/
|
|
610
|
+
static listAddresses(options) {
|
|
611
|
+
return (options.client ?? client).get({
|
|
612
|
+
url: "/v1/projects/{project_id}/addresses",
|
|
613
|
+
...options
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Erase an address
|
|
618
|
+
*
|
|
619
|
+
* Removes the address, its conversations, and its runtime actor and sessions.
|
|
620
|
+
*
|
|
621
|
+
*/
|
|
622
|
+
static deleteAddress(options) {
|
|
623
|
+
return (options.client ?? client).delete({
|
|
624
|
+
url: "/v1/projects/{project_id}/addresses/{identifier}",
|
|
625
|
+
...options
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Get an address
|
|
630
|
+
*/
|
|
631
|
+
static getAddress(options) {
|
|
632
|
+
return (options.client ?? client).get({
|
|
633
|
+
url: "/v1/projects/{project_id}/addresses/{identifier}",
|
|
634
|
+
...options
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Set or clear this address's own action
|
|
639
|
+
*
|
|
640
|
+
* Upserts the address and its `action` in one call. `action: null` forgets the exception and defers back to the route table; any other `action` requires the same fields a route or channel default would (`agent_id` for `agent`, `text` for `message`).
|
|
641
|
+
*
|
|
642
|
+
*/
|
|
643
|
+
static setAddressAction(options) {
|
|
644
|
+
return (options.client ?? client).put({
|
|
645
|
+
url: "/v1/projects/{project_id}/addresses/{identifier}",
|
|
646
|
+
...options,
|
|
647
|
+
headers: {
|
|
648
|
+
"Content-Type": "application/json",
|
|
649
|
+
...options.headers
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* List an address's conversations
|
|
655
|
+
*
|
|
656
|
+
* Every conversation this address has had, across every channel it has ever messaged — an address is project-scoped, not channel-scoped.
|
|
657
|
+
*
|
|
658
|
+
*/
|
|
659
|
+
static listAddressConversations(options) {
|
|
660
|
+
return (options.client ?? client).get({
|
|
661
|
+
url: "/v1/projects/{project_id}/addresses/{identifier}/conversations",
|
|
662
|
+
...options
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* List channel kinds
|
|
667
|
+
*
|
|
668
|
+
* Every connectable kind, its surfaces, and the predicates its routes can match on (engine-wide ones like `address_known` plus its own, like Discord's `guild_id`).
|
|
669
|
+
*
|
|
670
|
+
*/
|
|
671
|
+
static listChannelKinds(options) {
|
|
672
|
+
return (options?.client ?? client).get({
|
|
673
|
+
url: "/v1/channel-kinds",
|
|
674
|
+
...options
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* List a channel's routes
|
|
679
|
+
*/
|
|
680
|
+
static listChannelRoutes(options) {
|
|
681
|
+
return (options.client ?? client).get({
|
|
682
|
+
url: "/v1/projects/{project_id}/channels/{channel_id}/routes",
|
|
683
|
+
...options
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Create a route
|
|
688
|
+
*
|
|
689
|
+
* `action` is required; `agent_id` is required when it is `agent`, `text` when it is `message`; `repeat` is only valid alongside `action: message`. `surface`, when present, must be one this channel's kind serves (`GET /v1/channel-kinds`) — otherwise `400 unknown_surface`. `match` keys must be predicates that kind's registry declares — otherwise `400 unknown_predicate`. Writing a route for a surface whose transport mode is off (e.g. a Discord `guild_thread` route before `mention_threads` is enabled) still succeeds, with `unreachable_surface` in the response `warnings`.
|
|
690
|
+
*
|
|
691
|
+
*/
|
|
692
|
+
static createChannelRoute(options) {
|
|
693
|
+
return (options.client ?? client).post({
|
|
694
|
+
url: "/v1/projects/{project_id}/channels/{channel_id}/routes",
|
|
695
|
+
...options,
|
|
696
|
+
headers: {
|
|
697
|
+
"Content-Type": "application/json",
|
|
698
|
+
...options.headers
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Delete a route
|
|
704
|
+
*/
|
|
705
|
+
static deleteChannelRoute(options) {
|
|
706
|
+
return (options.client ?? client).delete({
|
|
707
|
+
url: "/v1/projects/{project_id}/channels/{channel_id}/routes/{route_id}",
|
|
708
|
+
...options
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Get a route
|
|
713
|
+
*/
|
|
714
|
+
static getChannelRoute(options) {
|
|
715
|
+
return (options.client ?? client).get({
|
|
716
|
+
url: "/v1/projects/{project_id}/channels/{channel_id}/routes/{route_id}",
|
|
717
|
+
...options
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Replace a route
|
|
722
|
+
*
|
|
723
|
+
* Full replace, the same validation as create.
|
|
724
|
+
*/
|
|
725
|
+
static updateChannelRoute(options) {
|
|
726
|
+
return (options.client ?? client).patch({
|
|
727
|
+
url: "/v1/projects/{project_id}/channels/{channel_id}/routes/{route_id}",
|
|
728
|
+
...options,
|
|
729
|
+
headers: {
|
|
730
|
+
"Content-Type": "application/json",
|
|
731
|
+
...options.headers
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Read the whole route table
|
|
737
|
+
*
|
|
738
|
+
* Every route across every channel in the project, one read — the table is small by construction (CHANNELS-ROUTING.md §3.6), so this is unpaginated.
|
|
739
|
+
*
|
|
740
|
+
*/
|
|
741
|
+
static listProjectChannelRoutes(options) {
|
|
742
|
+
return (options.client ?? client).get({
|
|
743
|
+
url: "/v1/projects/{project_id}/channel-routes",
|
|
744
|
+
...options
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Open a conversation
|
|
749
|
+
*
|
|
750
|
+
* The outbound-first path (CHANNELS-ROUTING.md §3.11): open a conversation for `{ channel_id, identifier }` ahead of any inbound message, which falls out of making the identifier the unit rather than the message. Resolves the same three-layer action an inbound would (§3.6); a `409` when that does not land on an agent — there is nothing to open for a `message`/`silence` outcome.
|
|
751
|
+
*
|
|
752
|
+
*/
|
|
753
|
+
static createConversation(options) {
|
|
754
|
+
return (options.client ?? client).post({
|
|
755
|
+
url: "/v1/projects/{project_id}/conversations",
|
|
756
|
+
...options,
|
|
757
|
+
headers: {
|
|
758
|
+
"Content-Type": "application/json",
|
|
759
|
+
...options.headers
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* List channels
|
|
765
|
+
*
|
|
766
|
+
* Lists the channels connected in the project.
|
|
767
|
+
*/
|
|
768
|
+
static listChannels(options) {
|
|
769
|
+
return (options.client ?? client).get({
|
|
770
|
+
url: "/v1/projects/{project_id}/channels",
|
|
771
|
+
...options
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Connect a channel
|
|
776
|
+
*
|
|
777
|
+
* Connect a channel. The required fields depend on `channel`; no credential is ever returned.
|
|
778
|
+
* **Discord** (`channel: discord`) — supply `application_id` and `bot_token`, plus the `modes` selecting which Gateway flows to serve (direct messages, and/or @mention-opens-a-thread). Returns `501` when the deployment has no `CHANNEL_TOKEN_KEY` configured.
|
|
779
|
+
* **WhatsApp** (default) — one of two credential paths, both filling the same write-only secret:
|
|
780
|
+
* * **BYOT** (`credential_source: byot`, default) — supply
|
|
781
|
+
* `phone_number_id` and `access_token` from your own Meta app.
|
|
782
|
+
*
|
|
783
|
+
* * **Embedded signup** (`credential_source: embedded_signup`) — supply
|
|
784
|
+
* `code` and `waba_id` (and optionally `pin`) from the Meta popup;
|
|
785
|
+
* naturali exchanges the `code` for the token and subscribes its app to
|
|
786
|
+
* the WABA, so the customer never hands over a token. Returns `501` on
|
|
787
|
+
* deployments where Meta App credentials are not configured.
|
|
788
|
+
*
|
|
789
|
+
*/
|
|
790
|
+
static createChannel(options) {
|
|
791
|
+
return (options.client ?? client).post({
|
|
792
|
+
url: "/v1/projects/{project_id}/channels",
|
|
793
|
+
...options,
|
|
794
|
+
headers: {
|
|
795
|
+
"Content-Type": "application/json",
|
|
796
|
+
...options.headers
|
|
797
|
+
}
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Delete a channel
|
|
802
|
+
*
|
|
803
|
+
* Deletes the channel and whatever it provisioned — the WhatsApp send tool and write-only credential secret, or the Discord channel's sealed bot token (dropped with the row, closing its gateway connection).
|
|
804
|
+
*
|
|
805
|
+
*/
|
|
806
|
+
static deleteChannel(options) {
|
|
807
|
+
return (options.client ?? client).delete({
|
|
808
|
+
url: "/v1/projects/{project_id}/channels/{channel_id}",
|
|
809
|
+
...options
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Get a channel
|
|
814
|
+
*/
|
|
815
|
+
static getChannel(options) {
|
|
816
|
+
return (options.client ?? client).get({
|
|
817
|
+
url: "/v1/projects/{project_id}/channels/{channel_id}",
|
|
818
|
+
...options
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Update a channel
|
|
823
|
+
*
|
|
824
|
+
* Rotate the credential, update the kind's config (`waba_id` / `credential_source` for WhatsApp, `modes` for Discord), or flip the naturali-side status. At least one field is required. Rotating a WhatsApp token stores a new write-only secret, repoints the send tool and deletes the old secret; rotating a Discord bot token reseals it and the gateway worker reconnects with it.
|
|
825
|
+
*
|
|
826
|
+
*/
|
|
827
|
+
static updateChannel(options) {
|
|
828
|
+
return (options.client ?? client).patch({
|
|
829
|
+
url: "/v1/projects/{project_id}/channels/{channel_id}",
|
|
830
|
+
...options,
|
|
831
|
+
headers: {
|
|
832
|
+
"Content-Type": "application/json",
|
|
833
|
+
...options.headers
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* List the channel's conversations
|
|
839
|
+
*
|
|
840
|
+
* A cursor page of the channel's conversations, newest first. A conversation is one address's dialogue on the channel — the continuity anchor that resumes the same runtime session instead of starting fresh per message — so this is the read path for who has talked to the channel and which actor/session their dialogue resolved to.
|
|
841
|
+
* Conversations are created by the inbound path (the WhatsApp webhook, the Discord gateway worker) when a real message arrives; there is no way to create one directly.
|
|
842
|
+
*
|
|
843
|
+
*/
|
|
844
|
+
static listChannelConversations(options) {
|
|
845
|
+
return (options.client ?? client).get({
|
|
846
|
+
url: "/v1/projects/{project_id}/channels/{channel_id}/conversations",
|
|
847
|
+
...options
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Get a conversation
|
|
852
|
+
*/
|
|
853
|
+
static getChannelConversation(options) {
|
|
854
|
+
return (options.client ?? client).get({
|
|
855
|
+
url: "/v1/projects/{project_id}/channels/{channel_id}/conversations/{conversation_id}",
|
|
856
|
+
...options
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Read a conversation's transcript
|
|
861
|
+
*
|
|
862
|
+
* The conversation's messages, oldest first. naturali stores no message bodies — the dialogue lives in the runtime session the conversation maps to, so this reads through to the runtime. Pagination is `limit`/`offset` rather than an opaque cursor because the upstream is offset-based over a stable `position` ordering.
|
|
863
|
+
*
|
|
864
|
+
*/
|
|
865
|
+
static listChannelConversationMessages(options) {
|
|
866
|
+
return (options.client ?? client).get({
|
|
867
|
+
url: "/v1/projects/{project_id}/channels/{channel_id}/conversations/{conversation_id}/messages",
|
|
868
|
+
...options
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
};
|
|
606
872
|
var Agents = class {
|
|
607
873
|
/**
|
|
608
874
|
* List agents
|
|
@@ -951,150 +1217,6 @@ var Boards = class {
|
|
|
951
1217
|
});
|
|
952
1218
|
}
|
|
953
1219
|
};
|
|
954
|
-
var Channels = class {
|
|
955
|
-
/**
|
|
956
|
-
* List channels
|
|
957
|
-
*
|
|
958
|
-
* Lists the channels connected in the project.
|
|
959
|
-
*/
|
|
960
|
-
static listChannels(options) {
|
|
961
|
-
return (options.client ?? client).get({
|
|
962
|
-
url: "/v1/projects/{project_id}/channels",
|
|
963
|
-
...options
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
/**
|
|
967
|
-
* Connect a channel
|
|
968
|
-
*
|
|
969
|
-
* Connect a channel. The required fields depend on `channel`; no credential is ever returned.
|
|
970
|
-
* **Discord** (`channel: discord`) — supply `application_id` and `bot_token`, plus the `modes` selecting which Gateway flows to serve (direct messages, and/or @mention-opens-a-thread). Returns `501` when the deployment has no `CHANNEL_TOKEN_KEY` configured.
|
|
971
|
-
* **WhatsApp** (default) — one of two credential paths, both filling the same write-only secret:
|
|
972
|
-
* * **BYOT** (`credential_source: byot`, default) — supply
|
|
973
|
-
* `phone_number_id` and `access_token` from your own Meta app.
|
|
974
|
-
*
|
|
975
|
-
* * **Embedded signup** (`credential_source: embedded_signup`) — supply
|
|
976
|
-
* `code` and `waba_id` (and optionally `pin`) from the Meta popup;
|
|
977
|
-
* naturali exchanges the `code` for the token and subscribes its app to
|
|
978
|
-
* the WABA, so the customer never hands over a token. Returns `501` on
|
|
979
|
-
* deployments where Meta App credentials are not configured.
|
|
980
|
-
*
|
|
981
|
-
*/
|
|
982
|
-
static createChannel(options) {
|
|
983
|
-
return (options.client ?? client).post({
|
|
984
|
-
url: "/v1/projects/{project_id}/channels",
|
|
985
|
-
...options,
|
|
986
|
-
headers: {
|
|
987
|
-
"Content-Type": "application/json",
|
|
988
|
-
...options.headers
|
|
989
|
-
}
|
|
990
|
-
});
|
|
991
|
-
}
|
|
992
|
-
/**
|
|
993
|
-
* Delete a channel
|
|
994
|
-
*
|
|
995
|
-
* Deletes the channel and whatever it provisioned — the WhatsApp send tool and write-only credential secret, or the Discord channel's sealed bot token (dropped with the row, closing its gateway connection).
|
|
996
|
-
*
|
|
997
|
-
*/
|
|
998
|
-
static deleteChannel(options) {
|
|
999
|
-
return (options.client ?? client).delete({
|
|
1000
|
-
url: "/v1/projects/{project_id}/channels/{channel_id}",
|
|
1001
|
-
...options
|
|
1002
|
-
});
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* Get a channel
|
|
1006
|
-
*/
|
|
1007
|
-
static getChannel(options) {
|
|
1008
|
-
return (options.client ?? client).get({
|
|
1009
|
-
url: "/v1/projects/{project_id}/channels/{channel_id}",
|
|
1010
|
-
...options
|
|
1011
|
-
});
|
|
1012
|
-
}
|
|
1013
|
-
/**
|
|
1014
|
-
* Update a channel
|
|
1015
|
-
*
|
|
1016
|
-
* Rotate the credential, update the kind's config (`waba_id` / `credential_source` for WhatsApp, `modes` for Discord), or flip the naturali-side status. At least one field is required. Rotating a WhatsApp token stores a new write-only secret, repoints the send tool and deletes the old secret; rotating a Discord bot token reseals it and the gateway worker reconnects with it.
|
|
1017
|
-
*
|
|
1018
|
-
*/
|
|
1019
|
-
static updateChannel(options) {
|
|
1020
|
-
return (options.client ?? client).patch({
|
|
1021
|
-
url: "/v1/projects/{project_id}/channels/{channel_id}",
|
|
1022
|
-
...options,
|
|
1023
|
-
headers: {
|
|
1024
|
-
"Content-Type": "application/json",
|
|
1025
|
-
...options.headers
|
|
1026
|
-
}
|
|
1027
|
-
});
|
|
1028
|
-
}
|
|
1029
|
-
/**
|
|
1030
|
-
* Unbind the channel
|
|
1031
|
-
*/
|
|
1032
|
-
static deleteChannelBinding(options) {
|
|
1033
|
-
return (options.client ?? client).delete({
|
|
1034
|
-
url: "/v1/projects/{project_id}/channels/{channel_id}/binding",
|
|
1035
|
-
...options
|
|
1036
|
-
});
|
|
1037
|
-
}
|
|
1038
|
-
/**
|
|
1039
|
-
* Get the channel's binding
|
|
1040
|
-
*/
|
|
1041
|
-
static getChannelBinding(options) {
|
|
1042
|
-
return (options.client ?? client).get({
|
|
1043
|
-
url: "/v1/projects/{project_id}/channels/{channel_id}/binding",
|
|
1044
|
-
...options
|
|
1045
|
-
});
|
|
1046
|
-
}
|
|
1047
|
-
/**
|
|
1048
|
-
* Set the channel's binding
|
|
1049
|
-
*
|
|
1050
|
-
* Create or replace the channel's agent binding (a channel has one binding in v1). `agent_id` is required and must be an agent owned in the project; `language` / `config` / `status` default to null / null / active when absent (full replace).
|
|
1051
|
-
*
|
|
1052
|
-
*/
|
|
1053
|
-
static setChannelBinding(options) {
|
|
1054
|
-
return (options.client ?? client).put({
|
|
1055
|
-
url: "/v1/projects/{project_id}/channels/{channel_id}/binding",
|
|
1056
|
-
...options,
|
|
1057
|
-
headers: {
|
|
1058
|
-
"Content-Type": "application/json",
|
|
1059
|
-
...options.headers
|
|
1060
|
-
}
|
|
1061
|
-
});
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* List the channel's conversations
|
|
1065
|
-
*
|
|
1066
|
-
* A cursor page of the channel's conversations, newest first. A conversation is one address's dialogue on the channel — the continuity anchor that resumes the same runtime session instead of starting fresh per message — so this is the read path for who has talked to the channel and which actor/session their dialogue resolved to.
|
|
1067
|
-
* Conversations are created by the inbound path (the WhatsApp webhook, the Discord gateway worker) when a real message arrives; there is no way to create one directly.
|
|
1068
|
-
*
|
|
1069
|
-
*/
|
|
1070
|
-
static listChannelConversations(options) {
|
|
1071
|
-
return (options.client ?? client).get({
|
|
1072
|
-
url: "/v1/projects/{project_id}/channels/{channel_id}/conversations",
|
|
1073
|
-
...options
|
|
1074
|
-
});
|
|
1075
|
-
}
|
|
1076
|
-
/**
|
|
1077
|
-
* Get a conversation
|
|
1078
|
-
*/
|
|
1079
|
-
static getChannelConversation(options) {
|
|
1080
|
-
return (options.client ?? client).get({
|
|
1081
|
-
url: "/v1/projects/{project_id}/channels/{channel_id}/conversations/{conversation_id}",
|
|
1082
|
-
...options
|
|
1083
|
-
});
|
|
1084
|
-
}
|
|
1085
|
-
/**
|
|
1086
|
-
* Read a conversation's transcript
|
|
1087
|
-
*
|
|
1088
|
-
* The conversation's messages, oldest first. naturali stores no message bodies — the dialogue lives in the runtime session the conversation maps to, so this reads through to the runtime. Pagination is `limit`/`offset` rather than an opaque cursor because the upstream is offset-based over a stable `position` ordering.
|
|
1089
|
-
*
|
|
1090
|
-
*/
|
|
1091
|
-
static listChannelConversationMessages(options) {
|
|
1092
|
-
return (options.client ?? client).get({
|
|
1093
|
-
url: "/v1/projects/{project_id}/channels/{channel_id}/conversations/{conversation_id}/messages",
|
|
1094
|
-
...options
|
|
1095
|
-
});
|
|
1096
|
-
}
|
|
1097
|
-
};
|
|
1098
1220
|
var Generations = class {
|
|
1099
1221
|
/**
|
|
1100
1222
|
* List an agent's generations
|