@cubos/agent-sdk 0.0.1151293 → 0.0.1152796

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.
@@ -29,8 +29,8 @@ export declare function aiProvidersApi(t: Transport, tenantSlug: string): {
29
29
  plugin: string;
30
30
  shared: boolean;
31
31
  slug: string;
32
- token_sku_directions: {
33
- [key: string]: import("../generated/schema.js").components["schemas"]["SkuDirection"];
32
+ token_sku_classes: {
33
+ [key: string]: import("../generated/schema.js").components["schemas"]["SkuClass"];
34
34
  };
35
35
  type: string;
36
36
  }[]>;
@@ -49,8 +49,8 @@ export declare function aiProvidersApi(t: Transport, tenantSlug: string): {
49
49
  plugin: string;
50
50
  shared: boolean;
51
51
  slug: string;
52
- token_sku_directions: {
53
- [key: string]: import("../generated/schema.js").components["schemas"]["SkuDirection"];
52
+ token_sku_classes: {
53
+ [key: string]: import("../generated/schema.js").components["schemas"]["SkuClass"];
54
54
  };
55
55
  type: string;
56
56
  }>;
@@ -69,8 +69,8 @@ export declare function aiProvidersApi(t: Transport, tenantSlug: string): {
69
69
  plugin: string;
70
70
  shared: boolean;
71
71
  slug: string;
72
- token_sku_directions: {
73
- [key: string]: import("../generated/schema.js").components["schemas"]["SkuDirection"];
72
+ token_sku_classes: {
73
+ [key: string]: import("../generated/schema.js").components["schemas"]["SkuClass"];
74
74
  };
75
75
  type: string;
76
76
  }>;
@@ -89,8 +89,8 @@ export declare function aiProvidersApi(t: Transport, tenantSlug: string): {
89
89
  plugin: string;
90
90
  shared: boolean;
91
91
  slug: string;
92
- token_sku_directions: {
93
- [key: string]: import("../generated/schema.js").components["schemas"]["SkuDirection"];
92
+ token_sku_classes: {
93
+ [key: string]: import("../generated/schema.js").components["schemas"]["SkuClass"];
94
94
  };
95
95
  type: string;
96
96
  }>;
@@ -249,6 +249,30 @@ export declare function channelsApi(t: Transport, tenantSlug: string): {
249
249
  preview: string | null;
250
250
  source: string;
251
251
  }[]>;
252
+ /** One summary per channel of what it has not sent: pending messages,
253
+ * whether anything is trying to send them, and what it gave up on in the
254
+ * last `days` days (default 7). */
255
+ outboxReport: (query?: {
256
+ days?: number;
257
+ }, signal?: AbortSignal) => Promise<{
258
+ channels: import("../generated/schema.js").components["schemas"]["ChannelOutboxSummary"][];
259
+ failed_window_days: number;
260
+ retry_window_seconds: number;
261
+ }>;
262
+ /** The channel's outbox summary plus a page of its unsent messages, newest
263
+ * first. Pass the previous page's `next_before` as `before`. */
264
+ outbox: (slug: string, query?: {
265
+ status?: "pending" | "failed" | "all";
266
+ days?: number;
267
+ before?: string;
268
+ limit?: number;
269
+ }, signal?: AbortSignal) => Promise<{
270
+ failed_window_days: number;
271
+ items: import("../generated/schema.js").components["schemas"]["OutboxItem"][];
272
+ next_before: string | null;
273
+ retry_window_seconds: number;
274
+ summary: import("../generated/schema.js").components["schemas"]["ChannelOutboxSummary"];
275
+ }>;
252
276
  pairWhatsapp: (slug: string, input: Schemas["WhatsappPairInput"]) => Promise<{
253
277
  pair_code: string | null;
254
278
  pair_code_expires_at: string | null;
@@ -183,6 +183,7 @@ export declare function conversationsAdminApi(t: Transport, tenantSlug: string):
183
183
  provider: import("../generated/schema.js").components["schemas"]["ProviderRef"] | null;
184
184
  read_at: string | null;
185
185
  result?: unknown;
186
+ sent_at: string | null;
186
187
  seq: number;
187
188
  sub_conversation_id: string | null;
188
189
  tentative: boolean;
@@ -214,6 +215,7 @@ export declare function conversationsAdminApi(t: Transport, tenantSlug: string):
214
215
  provider: import("../generated/schema.js").components["schemas"]["ProviderRef"] | null;
215
216
  read_at: string | null;
216
217
  result?: unknown;
218
+ sent_at: string | null;
217
219
  seq: number;
218
220
  sub_conversation_id: string | null;
219
221
  tentative: boolean;
@@ -244,6 +246,7 @@ export declare function conversationsAdminApi(t: Transport, tenantSlug: string):
244
246
  provider: import("../generated/schema.js").components["schemas"]["ProviderRef"] | null;
245
247
  read_at: string | null;
246
248
  result?: unknown;
249
+ sent_at: string | null;
247
250
  seq: number;
248
251
  sub_conversation_id: string | null;
249
252
  tentative: boolean;
@@ -279,6 +282,7 @@ export declare function conversationsAdminApi(t: Transport, tenantSlug: string):
279
282
  provider: import("../generated/schema.js").components["schemas"]["ProviderRef"] | null;
280
283
  read_at: string | null;
281
284
  result?: unknown;
285
+ sent_at: string | null;
282
286
  seq: number;
283
287
  sub_conversation_id: string | null;
284
288
  tentative: boolean;
@@ -316,6 +320,7 @@ export declare function conversationsAdminApi(t: Transport, tenantSlug: string):
316
320
  provider: import("../generated/schema.js").components["schemas"]["ProviderRef"] | null;
317
321
  read_at: string | null;
318
322
  result?: unknown;
323
+ sent_at: string | null;
319
324
  seq: number;
320
325
  sub_conversation_id: string | null;
321
326
  tentative: boolean;
@@ -345,6 +350,7 @@ export declare function conversationsAdminApi(t: Transport, tenantSlug: string):
345
350
  provider: import("../generated/schema.js").components["schemas"]["ProviderRef"] | null;
346
351
  read_at: string | null;
347
352
  result?: unknown;
353
+ sent_at: string | null;
348
354
  seq: number;
349
355
  sub_conversation_id: string | null;
350
356
  tentative: boolean;
@@ -90,8 +90,8 @@ export declare function sharedProvidersApi(t: Transport): {
90
90
  plugin: string;
91
91
  shared: boolean;
92
92
  slug: string;
93
- token_sku_directions: {
94
- [key: string]: import("../generated/schema.js").components["schemas"]["SkuDirection"];
93
+ token_sku_classes: {
94
+ [key: string]: import("../generated/schema.js").components["schemas"]["SkuClass"];
95
95
  };
96
96
  type: string;
97
97
  }>;
@@ -110,8 +110,8 @@ export declare function sharedProvidersApi(t: Transport): {
110
110
  plugin: string;
111
111
  shared: boolean;
112
112
  slug: string;
113
- token_sku_directions: {
114
- [key: string]: import("../generated/schema.js").components["schemas"]["SkuDirection"];
113
+ token_sku_classes: {
114
+ [key: string]: import("../generated/schema.js").components["schemas"]["SkuClass"];
115
115
  };
116
116
  type: string;
117
117
  }>;
@@ -10,6 +10,7 @@ import { conversationsAdminApi } from "./conversations.js";
10
10
  import { apiKeysApi, pluginsApi, sharedProvidersApi, tenantsApi } from "./global.js";
11
11
  import { knowledgeBasesApi } from "./knowledge-bases.js";
12
12
  import { mcpsApi } from "./mcps.js";
13
+ import { instanceMetricsApi, metricsApi } from "./metrics.js";
13
14
  import { skillsApi } from "./skills.js";
14
15
  import { backgroundTasksApi, scheduledRunsApi, taskTemplatesApi } from "./task-templates.js";
15
16
  import { userRolesApi, usersApi, userTokensApi } from "./users.js";
@@ -45,6 +46,7 @@ export interface TenantScope {
45
46
  backgroundTasks: ReturnType<typeof backgroundTasksApi>;
46
47
  conversations: ReturnType<typeof conversationsAdminApi>;
47
48
  clientTools: ReturnType<typeof clientToolsApi>;
49
+ metrics: ReturnType<typeof metricsApi>;
48
50
  }
49
51
  export interface AdminClient {
50
52
  health(signal?: AbortSignal): Promise<Schemas["Health"]>;
@@ -53,6 +55,7 @@ export interface AdminClient {
53
55
  apiKeys: ReturnType<typeof apiKeysApi>;
54
56
  sharedProviders: ReturnType<typeof sharedProvidersApi>;
55
57
  plugins: ReturnType<typeof pluginsApi>;
58
+ metrics: ReturnType<typeof instanceMetricsApi>;
56
59
  tenant(slug: string): TenantScope;
57
60
  /** Escape hatch for a route the SDK hasn't wrapped yet. Paths are absolute
58
61
  * (`/api/v1/…`) and auth is applied for you. */
@@ -0,0 +1,172 @@
1
+ import type { Transport } from "../http.js";
2
+ import type { Schemas } from "../schemas.js";
3
+ export type MetricId = Schemas["Metric"];
4
+ export type Dimension = Schemas["Dimension"];
5
+ export type Granularity = Schemas["Granularity"];
6
+ export type MetricsInclude = Schemas["Include"];
7
+ export type MetricsCatalog = Schemas["MetricsCatalog"];
8
+ export type MetricInfo = Schemas["MetricInfo"];
9
+ export type MetricsCompleteness = Schemas["Completeness"];
10
+ /** A metric as asked for: its id, or `{ id }`. The object form is where a
11
+ * parameterised metric (a quantile, say) will take its parameters. */
12
+ export type MetricSpec = MetricId | {
13
+ readonly id: MetricId;
14
+ };
15
+ /** The id a spec names. */
16
+ export type MetricIdOf<S> = S extends MetricId ? S : S extends {
17
+ readonly id: infer I extends MetricId;
18
+ } ? I : never;
19
+ /** The values a dimension is restricted to. `none` also keeps the rows where
20
+ * the dimension has no value. A filter listing nothing is refused by the
21
+ * server — leave the dimension out to keep every value. */
22
+ export interface MetricsFilter {
23
+ readonly in?: readonly string[];
24
+ readonly none?: boolean;
25
+ }
26
+ export type MetricsFilters<Dim extends Dimension = Dimension> = {
27
+ readonly [D in Dim]?: MetricsFilter;
28
+ };
29
+ export type MetricsOrderBy<M extends MetricId, D extends Dimension> = {
30
+ readonly metric: M;
31
+ readonly direction?: "asc" | "desc";
32
+ } | {
33
+ readonly dimension: D;
34
+ readonly direction?: "asc" | "desc";
35
+ };
36
+ /**
37
+ * A metrics query. Every type parameter is inferred from the literal you
38
+ * pass, which is what types the result: the metrics you ask for are the keys
39
+ * of each row's `values`, the dimensions you group by are the keys of its
40
+ * `dimensions`, a granularity adds `bucket` (and `buckets`), and `include`
41
+ * adds `totals` and `labels`.
42
+ */
43
+ export interface MetricsQuery<S extends readonly MetricSpec[] = readonly MetricSpec[], D extends readonly Dimension[] = readonly Dimension[], G extends Granularity | null = Granularity | null, I extends readonly MetricsInclude[] = readonly MetricsInclude[], Dim extends Dimension = Dimension> {
44
+ readonly metrics: S;
45
+ /** Inclusive; rounded down to the hour. Default: 30 days before `to`. */
46
+ readonly from?: Date | string;
47
+ /** Exclusive; rounded up to the hour. Default: the end of the current hour. */
48
+ readonly to?: Date | string;
49
+ /** IANA zone buckets are cut in. Default `UTC`. */
50
+ readonly timezone?: string;
51
+ /** Omit (or `null`) for one row per group over the whole interval — and,
52
+ * with no `groupBy` either, exactly one row. */
53
+ readonly granularity?: G;
54
+ readonly groupBy?: D;
55
+ readonly filters?: MetricsFilters<Dim>;
56
+ /** Within a bucket; rows always go bucket by bucket. Default: the first
57
+ * metric, descending. */
58
+ readonly orderBy?: readonly MetricsOrderBy<MetricIdOf<S[number]>, D[number]>[];
59
+ /** 1 to 10 000. Default 1 000. */
60
+ readonly limit?: number;
61
+ readonly cursor?: string | null;
62
+ readonly include?: I;
63
+ }
64
+ type Values<M extends MetricId> = {
65
+ readonly [K in M]: number;
66
+ };
67
+ type Dims<D extends Dimension> = {
68
+ readonly [K in D]: string | null;
69
+ };
70
+ /** `yes` when the literal certainly holds `K`, `no` when it certainly does
71
+ * not, `maybe` when the type is too wide to tell (an `Include[]` variable). */
72
+ type Has<I extends readonly unknown[], K> = number extends I["length"] ? "maybe" : K extends I[number] ? "yes" : "no";
73
+ type BucketField<G> = [G] extends [null] ? unknown : [G] extends [Granularity] ? {
74
+ readonly bucket: string;
75
+ } : {
76
+ readonly bucket?: string;
77
+ };
78
+ export type MetricsRow<M extends MetricId = MetricId, D extends Dimension = Dimension, G extends Granularity | null = Granularity | null> = BucketField<G> & {
79
+ /** Every grouped dimension; `null` for the rows where it has no value. */
80
+ readonly dimensions: Dims<D>;
81
+ readonly values: Values<M>;
82
+ };
83
+ /** With neither `groupBy` nor `granularity`, the server answers exactly one
84
+ * row — so its type is a one-tuple and `rows[0]` needs no check. */
85
+ type Rows<M extends MetricId, D extends readonly Dimension[], G> = D extends readonly [] ? [G] extends [null] ? readonly [MetricsRow<M, never, null>] : readonly MetricsRow<M, never, G & (Granularity | null)>[] : readonly MetricsRow<M, D[number], G & (Granularity | null)>[];
86
+ /** A name for an id; which fields are set depends on the dimension. */
87
+ export interface EntityLabel {
88
+ readonly slug?: string;
89
+ readonly display_name?: string | null;
90
+ /** A user's first channel identity (a phone, a handle). */
91
+ readonly primary_identifier?: string | null;
92
+ /** A provider's type (`openai`, `anthropic`, …). */
93
+ readonly provider_type?: string;
94
+ }
95
+ type LabeledDimension = "tenant" | "user" | "agent" | "provider";
96
+ type Labels<D extends Dimension> = {
97
+ readonly [K in Extract<D, LabeledDimension>]?: Readonly<Record<string, EntityLabel>>;
98
+ };
99
+ type Optional<Present extends "yes" | "no" | "maybe", T> = Present extends "yes" ? T : Present extends "no" ? unknown : Partial<T>;
100
+ export type MetricsResult<S extends readonly MetricSpec[] = readonly MetricSpec[], D extends readonly Dimension[] = readonly Dimension[], G extends Granularity | null = Granularity | null, I extends readonly MetricsInclude[] = readonly MetricsInclude[]> = {
101
+ /** The query as answered: defaults filled in, the interval rounded to whole
102
+ * hours. */
103
+ readonly query: Schemas["ResolvedQuery"];
104
+ readonly columns: readonly Schemas["Column"][];
105
+ readonly rows: Rows<MetricIdOf<S[number]>, D, G>;
106
+ /** Pass back as `cursor`, with the same query, for the next page. */
107
+ readonly next_cursor: string | null;
108
+ readonly completeness: MetricsCompleteness;
109
+ } & ([G] extends [null] ? unknown : [G] extends [Granularity] ? {
110
+ readonly buckets: readonly string[];
111
+ } : {
112
+ readonly buckets?: readonly string[];
113
+ }) & Optional<Has<I, "totals">, {
114
+ readonly totals: {
115
+ readonly values: Values<MetricIdOf<S[number]>>;
116
+ };
117
+ }> & Optional<Has<I, "labels">, {
118
+ readonly labels: Labels<D[number]>;
119
+ }>;
120
+ export interface DimensionValuesQuery<Dim extends Dimension = Dimension> {
121
+ /** Ranks the values, and is what `metric_value` holds. */
122
+ readonly metric: MetricId;
123
+ readonly from?: Date | string;
124
+ readonly to?: Date | string;
125
+ readonly timezone?: string;
126
+ /** The page's other filters; this dimension's own is ignored. */
127
+ readonly filters?: MetricsFilters<Dim>;
128
+ /** Keep values whose id or name contains this, case-insensitively. */
129
+ readonly search?: string;
130
+ readonly limit?: number;
131
+ readonly cursor?: string | null;
132
+ }
133
+ export interface DimensionValues {
134
+ readonly values: readonly {
135
+ /** `null` is the rows with no value — filter on it with `none`. */
136
+ readonly value: string | null;
137
+ readonly label?: EntityLabel;
138
+ readonly metric_value: number;
139
+ }[];
140
+ readonly next_cursor: string | null;
141
+ }
142
+ /** The whole instance's metrics. Root only. */
143
+ export declare function instanceMetricsApi(t: Transport): {
144
+ /** The metrics this credential may read here: unit, aggregation,
145
+ * dimensions, finest granularity, completeness. */
146
+ catalog: (signal?: AbortSignal) => Promise<{
147
+ dimensions: import("../generated/schema.js").components["schemas"]["DimensionInfo"][];
148
+ metrics: import("../generated/schema.js").components["schemas"]["MetricInfo"][];
149
+ }>;
150
+ query: <const S extends readonly MetricSpec[], const D extends readonly ("agent" | "kind" | "model" | "provider" | "tenant" | "user")[] = [], G extends Granularity | null = null, const I extends readonly MetricsInclude[] = []>(q: MetricsQuery<S, D, G, I, "agent" | "kind" | "model" | "provider" | "tenant" | "user">, signal?: AbortSignal) => Promise<MetricsResult<S, D, G, I>>;
151
+ /** Every row of the query, following the cursor page by page. */
152
+ queryAll<const S extends readonly MetricSpec[], const D extends readonly ("agent" | "kind" | "model" | "provider" | "tenant" | "user")[] = [], G extends Granularity | null = null>(q: Omit<MetricsQuery<S, D, G, [], "agent" | "kind" | "model" | "provider" | "tenant" | "user">, "cursor" | "include">, signal?: AbortSignal): AsyncGenerator<Rows<MetricIdOf<S[number]>, D, G>[number], any, any>;
153
+ /** The values `dimension` takes in a slice, ranked by a metric — what a
154
+ * filter can offer given the page's other filters. */
155
+ dimensionValues: (dimension: "agent" | "kind" | "model" | "provider" | "tenant" | "user", q: DimensionValuesQuery<"agent" | "kind" | "model" | "provider" | "tenant" | "user">, signal?: AbortSignal) => Promise<DimensionValues>;
156
+ };
157
+ /** One tenant's metrics; there is no `tenant` dimension in this scope. */
158
+ export declare function metricsApi(t: Transport, tenantSlug: string): {
159
+ /** The metrics this credential may read here: unit, aggregation,
160
+ * dimensions, finest granularity, completeness. */
161
+ catalog: (signal?: AbortSignal) => Promise<{
162
+ dimensions: import("../generated/schema.js").components["schemas"]["DimensionInfo"][];
163
+ metrics: import("../generated/schema.js").components["schemas"]["MetricInfo"][];
164
+ }>;
165
+ query: <const S extends readonly MetricSpec[], const D extends readonly ("agent" | "kind" | "model" | "provider" | "user")[] = [], G extends Granularity | null = null, const I extends readonly MetricsInclude[] = []>(q: MetricsQuery<S, D, G, I, "agent" | "kind" | "model" | "provider" | "user">, signal?: AbortSignal) => Promise<MetricsResult<S, D, G, I>>;
166
+ /** Every row of the query, following the cursor page by page. */
167
+ queryAll<const S extends readonly MetricSpec[], const D extends readonly ("agent" | "kind" | "model" | "provider" | "user")[] = [], G extends Granularity | null = null>(q: Omit<MetricsQuery<S, D, G, [], "agent" | "kind" | "model" | "provider" | "user">, "cursor" | "include">, signal?: AbortSignal): AsyncGenerator<Rows<MetricIdOf<S[number]>, D, G>[number], any, any>;
168
+ /** The values `dimension` takes in a slice, ranked by a metric — what a
169
+ * filter can offer given the page's other filters. */
170
+ dimensionValues: (dimension: "agent" | "kind" | "model" | "provider" | "user", q: DimensionValuesQuery<"agent" | "kind" | "model" | "provider" | "user">, signal?: AbortSignal) => Promise<DimensionValues>;
171
+ };
172
+ export {};