@cadenya/cadenya 0.129.0 → 0.131.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/client.d.mts +17 -0
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +17 -0
  5. package/client.d.ts.map +1 -1
  6. package/client.js +17 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +17 -0
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/api-keys.d.mts +5 -4
  12. package/resources/api-keys.d.mts.map +1 -1
  13. package/resources/api-keys.d.ts +5 -4
  14. package/resources/api-keys.d.ts.map +1 -1
  15. package/resources/index.d.mts +2 -0
  16. package/resources/index.d.mts.map +1 -1
  17. package/resources/index.d.ts +2 -0
  18. package/resources/index.d.ts.map +1 -1
  19. package/resources/index.js +5 -1
  20. package/resources/index.js.map +1 -1
  21. package/resources/index.mjs +2 -0
  22. package/resources/index.mjs.map +1 -1
  23. package/resources/objectives/objectives.d.mts +71 -0
  24. package/resources/objectives/objectives.d.mts.map +1 -1
  25. package/resources/objectives/objectives.d.ts +71 -0
  26. package/resources/objectives/objectives.d.ts.map +1 -1
  27. package/resources/objectives/objectives.js.map +1 -1
  28. package/resources/objectives/objectives.mjs.map +1 -1
  29. package/resources/widget-sessions.d.mts +388 -0
  30. package/resources/widget-sessions.d.mts.map +1 -0
  31. package/resources/widget-sessions.d.ts +388 -0
  32. package/resources/widget-sessions.d.ts.map +1 -0
  33. package/resources/widget-sessions.js +79 -0
  34. package/resources/widget-sessions.js.map +1 -0
  35. package/resources/widget-sessions.mjs +75 -0
  36. package/resources/widget-sessions.mjs.map +1 -0
  37. package/resources/widgets.d.mts +225 -0
  38. package/resources/widgets.d.mts.map +1 -0
  39. package/resources/widgets.d.ts +225 -0
  40. package/resources/widgets.d.ts.map +1 -0
  41. package/resources/widgets.js +83 -0
  42. package/resources/widgets.js.map +1 -0
  43. package/resources/widgets.mjs +79 -0
  44. package/resources/widgets.mjs.map +1 -0
  45. package/src/client.ts +81 -0
  46. package/src/resources/api-keys.ts +5 -4
  47. package/src/resources/index.ts +32 -0
  48. package/src/resources/objectives/objectives.ts +78 -0
  49. package/src/resources/widget-sessions.ts +509 -0
  50. package/src/resources/widgets.ts +317 -0
  51. package/src/version.ts +1 -1
  52. package/version.d.mts +1 -1
  53. package/version.d.ts +1 -1
  54. package/version.js +1 -1
  55. package/version.mjs +1 -1
@@ -0,0 +1,317 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as AccountAPI from './account';
5
+ import * as Shared from './shared';
6
+ import { APIPromise } from '../core/api-promise';
7
+ import { CursorPagination, type CursorPaginationParams, PagePromise } from '../core/pagination';
8
+ import { buildHeaders } from '../internal/headers';
9
+ import { RequestOptions } from '../internal/request-options';
10
+ import { path } from '../internal/utils/path';
11
+
12
+ /**
13
+ * Manage embeddable chat widgets. A widget binds an agent to a globally
14
+ * unique hostname with a per-widget origin allowlist; browsers reach it with
15
+ * session tokens minted via WidgetSessionService.
16
+ */
17
+ export class Widgets extends APIResource {
18
+ /**
19
+ * Creates a widget bound to an agent. The widget's DNS label and hostname are
20
+ * generated by the server and returned in `info`. The hostname may take up to a
21
+ * minute to become reachable while the edge propagates.
22
+ */
23
+ create(params: WidgetCreateParams, options?: RequestOptions): APIPromise<Widget> {
24
+ const { workspaceId = this._client.workspaceID, ...body } = params;
25
+ return this._client.post(path`/v1/workspaces/${workspaceId}/widgets`, { body, ...options });
26
+ }
27
+
28
+ /**
29
+ * Retrieves a widget by ID
30
+ */
31
+ retrieve(
32
+ id: string,
33
+ params: WidgetRetrieveParams | null | undefined = {},
34
+ options?: RequestOptions,
35
+ ): APIPromise<Widget> {
36
+ const { workspaceId = this._client.workspaceID } = params ?? {};
37
+ return this._client.get(path`/v1/workspaces/${workspaceId}/widgets/${id}`, options);
38
+ }
39
+
40
+ /**
41
+ * Updates a widget's metadata or spec. The DNS label is immutable and cannot be
42
+ * updated. Re-pointing the agent affects new sessions only; in-flight
43
+ * conversations finish against the agent they started with.
44
+ */
45
+ update(id: string, params: WidgetUpdateParams, options?: RequestOptions): APIPromise<Widget> {
46
+ const { workspaceId = this._client.workspaceID, ...body } = params;
47
+ return this._client.patch(path`/v1/workspaces/${workspaceId}/widgets/${id}`, { body, ...options });
48
+ }
49
+
50
+ /**
51
+ * Lists all widgets in a workspace
52
+ */
53
+ list(
54
+ params: WidgetListParams | null | undefined = {},
55
+ options?: RequestOptions,
56
+ ): PagePromise<WidgetsCursorPagination, Widget> {
57
+ const { workspaceId = this._client.workspaceID, ...query } = params ?? {};
58
+ return this._client.getAPIList(path`/v1/workspaces/${workspaceId}/widgets`, CursorPagination<Widget>, {
59
+ query,
60
+ ...options,
61
+ });
62
+ }
63
+
64
+ /**
65
+ * Deletes a widget. Its hostname stops serving and all of its sessions are
66
+ * revoked.
67
+ */
68
+ delete(
69
+ id: string,
70
+ params: WidgetDeleteParams | null | undefined = {},
71
+ options?: RequestOptions,
72
+ ): APIPromise<void> {
73
+ const { workspaceId = this._client.workspaceID } = params ?? {};
74
+ return this._client.delete(path`/v1/workspaces/${workspaceId}/widgets/${id}`, {
75
+ ...options,
76
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
77
+ });
78
+ }
79
+
80
+ /**
81
+ * Transitions a widget to STATE_ARCHIVED. The hostname stops serving at the edge,
82
+ * existing sessions are revoked, and no new sessions can be minted. Reversible via
83
+ * :unarchive.
84
+ */
85
+ archive(id: string, params: WidgetArchiveParams, options?: RequestOptions): APIPromise<Widget> {
86
+ const { workspaceId = this._client.workspaceID, ...body } = params;
87
+ return this._client.post(path`/v1/workspaces/${workspaceId}/widgets/${id}:archive`, { body, ...options });
88
+ }
89
+
90
+ /**
91
+ * Transitions an archived widget back to STATE_ACTIVE so its hostname serves
92
+ * traffic again. Sessions revoked by archival stay revoked; mint new ones.
93
+ */
94
+ unarchive(id: string, params: WidgetUnarchiveParams, options?: RequestOptions): APIPromise<Widget> {
95
+ const { workspaceId = this._client.workspaceID, ...body } = params;
96
+ return this._client.post(path`/v1/workspaces/${workspaceId}/widgets/${id}:unarchive`, {
97
+ body,
98
+ ...options,
99
+ });
100
+ }
101
+ }
102
+
103
+ export type WidgetsCursorPagination = CursorPagination<Widget>;
104
+
105
+ /**
106
+ * Widget is an embeddable chat surface bound to a single agent. Each widget owns a
107
+ * globally unique, immutable DNS label under the widgets domain (e.g.
108
+ * "k7m2xq9fp4wn.widgets.cadenya.com"): one widget = one hostname = one origin
109
+ * allowlist = one agent binding. Browsers talk to the widget host with session
110
+ * bearer tokens minted server-side via WidgetSessionService.
111
+ */
112
+ export interface Widget {
113
+ /**
114
+ * Standard metadata for persistent, named resources (e.g., agents, tools, prompts)
115
+ */
116
+ metadata: Shared.ResourceMetadata;
117
+
118
+ /**
119
+ * WidgetSpec is the user-provided configuration for a widget.
120
+ */
121
+ spec: WidgetSpec;
122
+
123
+ /**
124
+ * The current lifecycle state of the widget. Output only. Widgets are created
125
+ * STATE_ACTIVE; use the :archive and :unarchive actions to transition between
126
+ * states.
127
+ */
128
+ state: 'STATE_UNSPECIFIED' | 'STATE_ACTIVE' | 'STATE_ARCHIVED';
129
+
130
+ /**
131
+ * WidgetInfo provides read-only server-derived data about a widget.
132
+ */
133
+ info?: WidgetInfo;
134
+ }
135
+
136
+ /**
137
+ * WidgetInfo provides read-only server-derived data about a widget.
138
+ */
139
+ export interface WidgetInfo {
140
+ /**
141
+ * BareMetadata contains the minimal metadata for a resource: the ID and an
142
+ * optional human-readable name. These are used for reference fields where the full
143
+ * metadata (account scoping, timestamps, labels, external IDs) is not needed —
144
+ * e.g., the tool references inside an agent variation spec or the tools assigned
145
+ * to an objective. Both fields are server-populated; clients provide IDs through
146
+ * sibling fields rather than by constructing a BareMetadata themselves.
147
+ */
148
+ agent?: Shared.BareMetadata;
149
+
150
+ /**
151
+ * A profile identifies a user or non-human principal (such as an API key) at the
152
+ * account level. Profiles are account-scoped and can be granted access to multiple
153
+ * workspaces.
154
+ */
155
+ createdBy?: AccountAPI.Profile;
156
+
157
+ /**
158
+ * The widget's DNS label — the single hostname label under the widgets domain.
159
+ * Server-generated at creation, globally unique, immutable, and deliberately
160
+ * unrelated to the widget's id.
161
+ */
162
+ dnsLabel?: string;
163
+
164
+ /**
165
+ * The full hostname browsers talk to. Authoritative — clients must use this value
166
+ * rather than constructing the hostname themselves.
167
+ */
168
+ host?: string;
169
+ }
170
+
171
+ /**
172
+ * WidgetSpec is the user-provided configuration for a widget.
173
+ */
174
+ export interface WidgetSpec {
175
+ /**
176
+ * Agent this widget is bound to. Accepts the canonical `agent_…` form or the
177
+ * `external_id:<value>` form. Sessions copy the agent at mint: re-pointing a
178
+ * widget's agent affects new sessions only.
179
+ */
180
+ agentId: string;
181
+
182
+ /**
183
+ * Web origins allowed to embed and use this widget, enforced at the edge on every
184
+ * browser request. Exact origins only (scheme + host + optional port), no paths,
185
+ * no wildcard subdomains.
186
+ */
187
+ originAllowlist?: Array<string>;
188
+
189
+ /**
190
+ * Optional explicit variation pin. Must belong to the widget's agent. When set,
191
+ * every objective created through the widget runs this variation — bypassing the
192
+ * agent's variation_selection_mode (staged rollout: pin in production, follow in
193
+ * staging, promote by clearing). When unset, the agent's selection mode chooses
194
+ * per conversation.
195
+ */
196
+ variationId?: string;
197
+ }
198
+
199
+ export interface WidgetCreateParams {
200
+ /**
201
+ * Path param: Workspace ID.
202
+ */
203
+ workspaceId?: string;
204
+
205
+ /**
206
+ * Body param: CreateResourceMetadata contains the user-provided fields for
207
+ * creating a workspace-scoped resource. Read-only fields (id, account_id,
208
+ * workspace_id, profile_id, created_at) are excluded since they are set by the
209
+ * server.
210
+ */
211
+ metadata: Shared.CreateResourceMetadata;
212
+
213
+ /**
214
+ * Body param: WidgetSpec is the user-provided configuration for a widget.
215
+ */
216
+ spec: WidgetSpec;
217
+ }
218
+
219
+ export interface WidgetRetrieveParams {
220
+ /**
221
+ * Workspace ID.
222
+ */
223
+ workspaceId?: string;
224
+ }
225
+
226
+ export interface WidgetUpdateParams {
227
+ /**
228
+ * Path param: Workspace ID.
229
+ */
230
+ workspaceId?: string;
231
+
232
+ /**
233
+ * Body param: UpdateResourceMetadata contains the user-provided fields for
234
+ * updating a workspace-scoped resource. Read-only fields (id, account_id,
235
+ * workspace_id, profile_id, created_at) are excluded since they are set by the
236
+ * server.
237
+ */
238
+ metadata?: Shared.UpdateResourceMetadata;
239
+
240
+ /**
241
+ * Body param: WidgetSpec is the user-provided configuration for a widget.
242
+ */
243
+ spec?: WidgetSpec;
244
+
245
+ /**
246
+ * Body param: Fields to update.
247
+ */
248
+ updateMask?: string;
249
+ }
250
+
251
+ export interface WidgetListParams extends CursorPaginationParams {
252
+ /**
253
+ * Path param: Workspace ID.
254
+ */
255
+ workspaceId?: string;
256
+
257
+ /**
258
+ * Query param: Filter to widgets bound to a specific agent. Accepts the canonical
259
+ * `agent_…` form or the `external_id:<value>` form.
260
+ */
261
+ agentId?: string;
262
+
263
+ /**
264
+ * Query param: When true, the `info` field on each returned widget is populated.
265
+ * Requests with this flag count more against your rate limit.
266
+ */
267
+ includeInfo?: boolean;
268
+
269
+ /**
270
+ * Query param: Filters by metadata labels. Comma-separated key=value pairs, e.g.
271
+ * "env=prod,team=ai". A resource matches only if every pair matches exactly (AND
272
+ * semantics).
273
+ */
274
+ labels?: string;
275
+
276
+ /**
277
+ * Query param: Sort order for results (asc or desc by creation time).
278
+ */
279
+ sortOrder?: string;
280
+ }
281
+
282
+ export interface WidgetDeleteParams {
283
+ /**
284
+ * Workspace ID.
285
+ */
286
+ workspaceId?: string;
287
+ }
288
+
289
+ export interface WidgetArchiveParams {
290
+ /**
291
+ * Workspace ID.
292
+ */
293
+ workspaceId?: string;
294
+ }
295
+
296
+ export interface WidgetUnarchiveParams {
297
+ /**
298
+ * Workspace ID.
299
+ */
300
+ workspaceId?: string;
301
+ }
302
+
303
+ export declare namespace Widgets {
304
+ export {
305
+ type Widget as Widget,
306
+ type WidgetInfo as WidgetInfo,
307
+ type WidgetSpec as WidgetSpec,
308
+ type WidgetsCursorPagination as WidgetsCursorPagination,
309
+ type WidgetCreateParams as WidgetCreateParams,
310
+ type WidgetRetrieveParams as WidgetRetrieveParams,
311
+ type WidgetUpdateParams as WidgetUpdateParams,
312
+ type WidgetListParams as WidgetListParams,
313
+ type WidgetDeleteParams as WidgetDeleteParams,
314
+ type WidgetArchiveParams as WidgetArchiveParams,
315
+ type WidgetUnarchiveParams as WidgetUnarchiveParams,
316
+ };
317
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.129.0'; // x-release-please-version
1
+ export const VERSION = '0.131.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.129.0";
1
+ export declare const VERSION = "0.131.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.129.0";
1
+ export declare const VERSION = "0.131.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.129.0'; // x-release-please-version
4
+ exports.VERSION = '0.131.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.129.0'; // x-release-please-version
1
+ export const VERSION = '0.131.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map