@cubos/agent-sdk 0.0.1136563

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.
@@ -0,0 +1,122 @@
1
+ import type { Transport } from "../http.js";
2
+ import type { Schemas } from "../schemas.js";
3
+ export declare function aiProvidersApi(t: Transport, tenantSlug: string): {
4
+ /** Includes providers shared by the `_root` tenant, flagged `shared: true`. */
5
+ list: (signal?: AbortSignal) => Promise<{
6
+ account_id: string | null;
7
+ base_url: string | null;
8
+ created_at: string;
9
+ has_api_key: boolean;
10
+ id: string;
11
+ last_reconcile_error: string | null;
12
+ last_reconciled_at: string | null;
13
+ model_count: number;
14
+ shared: boolean;
15
+ slug: string;
16
+ token_sku_directions: {
17
+ [key: string]: import("../generated/schema.js").components["schemas"]["SkuDirection"];
18
+ };
19
+ type: import("../generated/schema.js").components["schemas"]["ProviderType"];
20
+ }[]>;
21
+ get: (slug: string, signal?: AbortSignal) => Promise<{
22
+ account_id: string | null;
23
+ base_url: string | null;
24
+ created_at: string;
25
+ has_api_key: boolean;
26
+ id: string;
27
+ last_reconcile_error: string | null;
28
+ last_reconciled_at: string | null;
29
+ model_count: number;
30
+ shared: boolean;
31
+ slug: string;
32
+ token_sku_directions: {
33
+ [key: string]: import("../generated/schema.js").components["schemas"]["SkuDirection"];
34
+ };
35
+ type: import("../generated/schema.js").components["schemas"]["ProviderType"];
36
+ }>;
37
+ create: (input: Schemas["CreateAiProviderInput"]) => Promise<{
38
+ account_id: string | null;
39
+ base_url: string | null;
40
+ created_at: string;
41
+ has_api_key: boolean;
42
+ id: string;
43
+ last_reconcile_error: string | null;
44
+ last_reconciled_at: string | null;
45
+ model_count: number;
46
+ shared: boolean;
47
+ slug: string;
48
+ token_sku_directions: {
49
+ [key: string]: import("../generated/schema.js").components["schemas"]["SkuDirection"];
50
+ };
51
+ type: import("../generated/schema.js").components["schemas"]["ProviderType"];
52
+ }>;
53
+ update: (currentSlug: string, input: Schemas["UpdateAiProviderInput"]) => Promise<{
54
+ account_id: string | null;
55
+ base_url: string | null;
56
+ created_at: string;
57
+ has_api_key: boolean;
58
+ id: string;
59
+ last_reconcile_error: string | null;
60
+ last_reconciled_at: string | null;
61
+ model_count: number;
62
+ shared: boolean;
63
+ slug: string;
64
+ token_sku_directions: {
65
+ [key: string]: import("../generated/schema.js").components["schemas"]["SkuDirection"];
66
+ };
67
+ type: import("../generated/schema.js").components["schemas"]["ProviderType"];
68
+ }>;
69
+ delete: (slug: string) => Promise<void>;
70
+ listModels: (slug: string, signal?: AbortSignal) => Promise<{
71
+ capabilities: import("../generated/schema.js").components["schemas"]["ModelCapabilities"];
72
+ context_window_tokens: number | null;
73
+ context_window_tokens_override: number | null;
74
+ disappeared_at: string | null;
75
+ display_name: string | null;
76
+ embedding_native_dimensions: number | null;
77
+ id: string;
78
+ last_reconciled_at: string;
79
+ max_input_tokens: number | null;
80
+ max_output_tokens: number | null;
81
+ model_id: string;
82
+ model_version: string | null;
83
+ pricing: {
84
+ [key: string]: number;
85
+ };
86
+ pricing_effective: {
87
+ [key: string]: number;
88
+ };
89
+ pricing_override: {
90
+ [key: string]: number;
91
+ };
92
+ pricing_skus: import("../generated/schema.js").components["schemas"]["SkuDisplayDto"][];
93
+ reasoning_options: null | import("../generated/schema.js").components["schemas"]["ReasoningOptions"];
94
+ }[]>;
95
+ /** Re-probes the upstream catalog. 409 while another reconcile is running. */
96
+ refreshModels: (slug: string) => Promise<{
97
+ capabilities: import("../generated/schema.js").components["schemas"]["ModelCapabilities"];
98
+ context_window_tokens: number | null;
99
+ context_window_tokens_override: number | null;
100
+ disappeared_at: string | null;
101
+ display_name: string | null;
102
+ embedding_native_dimensions: number | null;
103
+ id: string;
104
+ last_reconciled_at: string;
105
+ max_input_tokens: number | null;
106
+ max_output_tokens: number | null;
107
+ model_id: string;
108
+ model_version: string | null;
109
+ pricing: {
110
+ [key: string]: number;
111
+ };
112
+ pricing_effective: {
113
+ [key: string]: number;
114
+ };
115
+ pricing_override: {
116
+ [key: string]: number;
117
+ };
118
+ pricing_skus: import("../generated/schema.js").components["schemas"]["SkuDisplayDto"][];
119
+ reasoning_options: null | import("../generated/schema.js").components["schemas"]["ReasoningOptions"];
120
+ }[]>;
121
+ updateModel: (slug: string, modelId: string, input: Schemas["UpdateProviderModelInput"]) => Promise<void>;
122
+ };
@@ -0,0 +1,261 @@
1
+ import type { Transport } from "../http.js";
2
+ import type { Schemas } from "../schemas.js";
3
+ /** `Channel` and its Create/Update inputs are discriminated unions over `type`
4
+ * (telegram, whapi, whatsapp, external), so no per-type methods are needed. */
5
+ export declare function channelsApi(t: Transport, tenantSlug: string): {
6
+ list: (signal?: AbortSignal) => Promise<(({
7
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
8
+ connection_secret_hint: string;
9
+ created_at: string;
10
+ default_user_role_slugs: string[];
11
+ disabled_at: string | null;
12
+ id: string;
13
+ last_connected_at: string | null;
14
+ slug: string;
15
+ user_onboarding_mode: string;
16
+ } & {
17
+ type: "external";
18
+ }) | ({
19
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
20
+ bot_display_name: string;
21
+ bot_id: number;
22
+ bot_username: string | null;
23
+ created_at: string;
24
+ default_user_role_slugs: string[];
25
+ disabled_at: string | null;
26
+ id: string;
27
+ slug: string;
28
+ user_onboarding_mode: string;
29
+ } & {
30
+ type: "telegram";
31
+ }) | ({
32
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
33
+ created_at: string;
34
+ default_user_role_slugs: string[];
35
+ disabled_at: string | null;
36
+ health_status: string | null;
37
+ id: string;
38
+ phone_number: string | null;
39
+ profile_name: string | null;
40
+ slug: string;
41
+ user_onboarding_mode: string;
42
+ whapi_channel_id: string | null;
43
+ } & {
44
+ type: "whapi";
45
+ }) | ({
46
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
47
+ created_at: string;
48
+ default_user_role_slugs: string[];
49
+ disabled_at: string | null;
50
+ id: string;
51
+ pairing_status: string;
52
+ phone_number: string | null;
53
+ push_name: string | null;
54
+ slug: string;
55
+ user_onboarding_mode: string;
56
+ } & {
57
+ type: "whatsapp";
58
+ }))[]>;
59
+ get: (slug: string, signal?: AbortSignal) => Promise<({
60
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
61
+ connection_secret_hint: string;
62
+ created_at: string;
63
+ default_user_role_slugs: string[];
64
+ disabled_at: string | null;
65
+ id: string;
66
+ last_connected_at: string | null;
67
+ slug: string;
68
+ user_onboarding_mode: string;
69
+ } & {
70
+ type: "external";
71
+ }) | ({
72
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
73
+ bot_display_name: string;
74
+ bot_id: number;
75
+ bot_username: string | null;
76
+ created_at: string;
77
+ default_user_role_slugs: string[];
78
+ disabled_at: string | null;
79
+ id: string;
80
+ slug: string;
81
+ user_onboarding_mode: string;
82
+ } & {
83
+ type: "telegram";
84
+ }) | ({
85
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
86
+ created_at: string;
87
+ default_user_role_slugs: string[];
88
+ disabled_at: string | null;
89
+ health_status: string | null;
90
+ id: string;
91
+ phone_number: string | null;
92
+ profile_name: string | null;
93
+ slug: string;
94
+ user_onboarding_mode: string;
95
+ whapi_channel_id: string | null;
96
+ } & {
97
+ type: "whapi";
98
+ }) | ({
99
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
100
+ created_at: string;
101
+ default_user_role_slugs: string[];
102
+ disabled_at: string | null;
103
+ id: string;
104
+ pairing_status: string;
105
+ phone_number: string | null;
106
+ push_name: string | null;
107
+ slug: string;
108
+ user_onboarding_mode: string;
109
+ } & {
110
+ type: "whatsapp";
111
+ })>;
112
+ create: (input: Schemas["CreateChannelInput"]) => Promise<({
113
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
114
+ bot_display_name: string;
115
+ bot_id: number;
116
+ bot_username: string | null;
117
+ created_at: string;
118
+ default_user_role_slugs: string[];
119
+ disabled_at: string | null;
120
+ id: string;
121
+ slug: string;
122
+ user_onboarding_mode: string;
123
+ } & {
124
+ type: "telegram";
125
+ }) | ({
126
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
127
+ created_at: string;
128
+ default_user_role_slugs: string[];
129
+ disabled_at: string | null;
130
+ health_status: string | null;
131
+ id: string;
132
+ phone_number: string | null;
133
+ profile_name: string | null;
134
+ slug: string;
135
+ user_onboarding_mode: string;
136
+ whapi_channel_id: string | null;
137
+ } & {
138
+ type: "whapi";
139
+ }) | ({
140
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
141
+ created_at: string;
142
+ default_user_role_slugs: string[];
143
+ disabled_at: string | null;
144
+ id: string;
145
+ pairing_status: string;
146
+ phone_number: string | null;
147
+ push_name: string | null;
148
+ slug: string;
149
+ user_onboarding_mode: string;
150
+ } & {
151
+ type: "whatsapp";
152
+ }) | ({
153
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
154
+ connection_secret_hint: string;
155
+ created_at: string;
156
+ default_user_role_slugs: string[];
157
+ disabled_at: string | null;
158
+ id: string;
159
+ last_connected_at: string | null;
160
+ slug: string;
161
+ user_onboarding_mode: string;
162
+ } & {
163
+ connection_secret: string;
164
+ } & {
165
+ type: "external";
166
+ })>;
167
+ update: (slug: string, input: Schemas["UpdateChannelInput"]) => Promise<({
168
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
169
+ connection_secret_hint: string;
170
+ created_at: string;
171
+ default_user_role_slugs: string[];
172
+ disabled_at: string | null;
173
+ id: string;
174
+ last_connected_at: string | null;
175
+ slug: string;
176
+ user_onboarding_mode: string;
177
+ } & {
178
+ type: "external";
179
+ }) | ({
180
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
181
+ bot_display_name: string;
182
+ bot_id: number;
183
+ bot_username: string | null;
184
+ created_at: string;
185
+ default_user_role_slugs: string[];
186
+ disabled_at: string | null;
187
+ id: string;
188
+ slug: string;
189
+ user_onboarding_mode: string;
190
+ } & {
191
+ type: "telegram";
192
+ }) | ({
193
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
194
+ created_at: string;
195
+ default_user_role_slugs: string[];
196
+ disabled_at: string | null;
197
+ health_status: string | null;
198
+ id: string;
199
+ phone_number: string | null;
200
+ profile_name: string | null;
201
+ slug: string;
202
+ user_onboarding_mode: string;
203
+ whapi_channel_id: string | null;
204
+ } & {
205
+ type: "whapi";
206
+ }) | ({
207
+ agent: import("../generated/schema.js").components["schemas"]["AgentRef"];
208
+ created_at: string;
209
+ default_user_role_slugs: string[];
210
+ disabled_at: string | null;
211
+ id: string;
212
+ pairing_status: string;
213
+ phone_number: string | null;
214
+ push_name: string | null;
215
+ slug: string;
216
+ user_onboarding_mode: string;
217
+ } & {
218
+ type: "whatsapp";
219
+ })>;
220
+ delete: (slug: string) => Promise<void>;
221
+ /** Invalidates the current connection secret and returns a new one. */
222
+ rotateSecret: (slug: string) => Promise<{
223
+ connection_secret: string;
224
+ }>;
225
+ /** The response components registered on the channel (external channels
226
+ * only carry them) — the catalog every conversation on the channel
227
+ * resolves at turn load. */
228
+ listComponentLibraries: (slug: string, signal?: AbortSignal) => Promise<{
229
+ libraries: string[];
230
+ tags: string[];
231
+ }>;
232
+ /** Replaces the channel's enabled libraries (send the complete list every
233
+ * time; empty clears it). External channels only — 409 on any other type.
234
+ * Running conversations pick the new catalog up on their next turn.
235
+ *
236
+ * Returns the slugs together with every tag they resolve to, so a runner can
237
+ * check the catalog against what its frontend actually renders. */
238
+ setComponentLibraries: (slug: string, libraries: string[]) => Promise<{
239
+ libraries: string[];
240
+ tags: string[];
241
+ }>;
242
+ listDeadLetters: (slug: string, signal?: AbortSignal) => Promise<{
243
+ attempts: number;
244
+ conversation_id: string | null;
245
+ error: string | null;
246
+ failed_at: string | null;
247
+ id: string;
248
+ identifier: string | null;
249
+ preview: string | null;
250
+ source: string;
251
+ }[]>;
252
+ pairWhatsapp: (slug: string, input: Schemas["WhatsappPairInput"]) => Promise<{
253
+ pair_code: string | null;
254
+ pair_code_expires_at: string | null;
255
+ pairing_status: string;
256
+ phone_number: string | null;
257
+ push_name: string | null;
258
+ qr_expires_at: string | null;
259
+ qr_payload: string | null;
260
+ }>;
261
+ };
@@ -0,0 +1,74 @@
1
+ import { type ClientToolsSession, type ServeClientToolsOptions } from "../client-tools.js";
2
+ import type { Transport } from "../http.js";
3
+ import type { Schemas } from "../schemas.js";
4
+ /**
5
+ * Client tools: tools defined on a conversation with no server-side
6
+ * implementation. The agent calls one, its turn suspends, and whoever drives
7
+ * the API answers.
8
+ *
9
+ * This is the wire layer. For the usual case — "here are my functions, run
10
+ * them" — use `serveClientTools`, which drives this on your behalf.
11
+ */
12
+ export declare function clientToolsApi(t: Transport, tenantSlug: string): {
13
+ /** Declares your functions on the conversation and runs them as the agent
14
+ * calls them, until you stop the session. This is the whole feature in one
15
+ * call; everything below is the wire it drives. */
16
+ serve: (convId: string, options: ServeClientToolsOptions) => ClientToolsSession;
17
+ list: (convId: string, signal?: AbortSignal) => Promise<{
18
+ created_at: string;
19
+ description: string;
20
+ destructive_hint: boolean | null;
21
+ id: string;
22
+ idempotent_hint: boolean | null;
23
+ input_schema: import("../generated/schema.js").components["schemas"]["Value"];
24
+ name: string;
25
+ output_schema: null | import("../generated/schema.js").components["schemas"]["Value"];
26
+ read_only_hint: boolean | null;
27
+ timeout_seconds: number;
28
+ updated_at: string;
29
+ }[]>;
30
+ /** Declares the whole set: entries are upserted, anything not listed is
31
+ * removed. The shape a reconnecting client wants — it converges instead of
32
+ * accumulating definitions from a previous session. */
33
+ replace: (convId: string, input: Schemas["ReplaceClientToolsInput"]) => Promise<{
34
+ created_at: string;
35
+ description: string;
36
+ destructive_hint: boolean | null;
37
+ id: string;
38
+ idempotent_hint: boolean | null;
39
+ input_schema: import("../generated/schema.js").components["schemas"]["Value"];
40
+ name: string;
41
+ output_schema: null | import("../generated/schema.js").components["schemas"]["Value"];
42
+ read_only_hint: boolean | null;
43
+ timeout_seconds: number;
44
+ updated_at: string;
45
+ }[]>;
46
+ /** Calls the agent is blocked on. Normally you learn about a call from the
47
+ * `client_tool_call` event on the conversation's SSE stream; this is the
48
+ * catch-up read for calls issued before you connected. */
49
+ listCalls: (convId: string, signal?: AbortSignal) => Promise<{
50
+ arguments: import("../generated/schema.js").components["schemas"]["Value"];
51
+ claim_expires_at: string | null;
52
+ claimed_by: string | null;
53
+ conversation_id: string;
54
+ created_at: string;
55
+ deadline_at: string;
56
+ tool_call_id: string;
57
+ tool_name: string;
58
+ }[]>;
59
+ /** Takes the exclusive lease, or renews it when `claimant` matches the
60
+ * holder. Rejects with 409 while someone else holds a live one. */
61
+ claim: (convId: string, toolCallId: string, input: Schemas["ClaimInput"]) => Promise<{
62
+ arguments: import("../generated/schema.js").components["schemas"]["Value"];
63
+ claim_expires_at: string | null;
64
+ claimed_by: string | null;
65
+ conversation_id: string;
66
+ created_at: string;
67
+ deadline_at: string;
68
+ tool_call_id: string;
69
+ tool_name: string;
70
+ }>;
71
+ releaseClaim: (convId: string, toolCallId: string, claimant: string) => Promise<void>;
72
+ /** Answers a call. Supply exactly one of `result`, `content` or `error`. */
73
+ submitResult: (convId: string, toolCallId: string, input: Schemas["SubmitResultInput"]) => Promise<void>;
74
+ };
@@ -0,0 +1,63 @@
1
+ import type { Transport } from "../http.js";
2
+ import type { Schemas } from "../schemas.js";
3
+ /** Component libraries: the catalogs of interactive blocks an agent may put in a
4
+ * reply, authored here and enabled by slug on a conversation or an external
5
+ * channel.
6
+ *
7
+ * Authoring is deliberately an operator capability. A component's `summary`,
8
+ * `description` and `exampleMdx` are shown to the model verbatim, so writing one
9
+ * is writing prompt content — hence `component_libraries:write` on an api_key,
10
+ * never a browser. A client app holding an end-user token can only *enable* a
11
+ * library, which is the half that depends on which of its screens is open.
12
+ *
13
+ * Edits replace in place — no version snapshots, and every conversation with the
14
+ * library enabled sees the latest on its next turn, the same rule skills follow. */
15
+ export declare function componentLibrariesApi(t: Transport, tenantSlug: string): {
16
+ /** Every library in the tenant with its tag names — enough to wire one up
17
+ * without fetching the full entries. */
18
+ list: (signal?: AbortSignal) => Promise<{
19
+ created_at: string;
20
+ description: string;
21
+ display_name: string;
22
+ id: string;
23
+ slug: string;
24
+ tags: string[];
25
+ updated_at: string;
26
+ }[]>;
27
+ /** One library with every component's full entry — the same text the agent
28
+ * receives from `component_read`. */
29
+ get: (slug: string, signal?: AbortSignal) => Promise<{
30
+ components: import("../generated/schema.js").components["schemas"]["LibraryComponent"][];
31
+ created_at: string;
32
+ description: string;
33
+ display_name: string;
34
+ id: string;
35
+ slug: string;
36
+ updated_at: string;
37
+ }>;
38
+ create: (input: Schemas["CreateComponentLibraryInput"]) => Promise<{
39
+ components: import("../generated/schema.js").components["schemas"]["LibraryComponent"][];
40
+ created_at: string;
41
+ description: string;
42
+ display_name: string;
43
+ id: string;
44
+ slug: string;
45
+ updated_at: string;
46
+ }>;
47
+ /** Patches in place; omitted fields stay. Supplying `components` replaces
48
+ * the whole set, so send it complete — half a library must never reach a
49
+ * prompt because two calls were in flight. */
50
+ update: (currentSlug: string, input: Schemas["UpdateComponentLibraryInput"]) => Promise<{
51
+ components: import("../generated/schema.js").components["schemas"]["LibraryComponent"][];
52
+ created_at: string;
53
+ description: string;
54
+ display_name: string;
55
+ id: string;
56
+ slug: string;
57
+ updated_at: string;
58
+ }>;
59
+ /** Deletes the library and every enablement of it. Messages already written
60
+ * keep their text: blocks are re-derived from content on read, and the read
61
+ * path consults no catalog. */
62
+ delete: (slug: string) => Promise<void>;
63
+ };