@cadenya/widgets 1.0.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 (48) hide show
  1. package/README.md +133 -0
  2. package/api.md +66 -0
  3. package/dist/client.d.ts +33 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +49 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/core/error.d.ts +39 -0
  8. package/dist/core/error.d.ts.map +1 -0
  9. package/dist/core/error.js +56 -0
  10. package/dist/core/error.js.map +1 -0
  11. package/dist/core/http.d.ts +140 -0
  12. package/dist/core/http.d.ts.map +1 -0
  13. package/dist/core/http.js +525 -0
  14. package/dist/core/http.js.map +1 -0
  15. package/dist/core/pagination.d.ts +12 -0
  16. package/dist/core/pagination.d.ts.map +1 -0
  17. package/dist/core/pagination.js +29 -0
  18. package/dist/core/pagination.js.map +1 -0
  19. package/dist/core/sse.d.ts +44 -0
  20. package/dist/core/sse.d.ts.map +1 -0
  21. package/dist/core/sse.js +350 -0
  22. package/dist/core/sse.js.map +1 -0
  23. package/dist/index.d.ts +12 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +10 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/resources/config.d.ts +16 -0
  28. package/dist/resources/config.d.ts.map +1 -0
  29. package/dist/resources/config.js +21 -0
  30. package/dist/resources/config.js.map +1 -0
  31. package/dist/resources/conversations.d.ts +173 -0
  32. package/dist/resources/conversations.d.ts.map +1 -0
  33. package/dist/resources/conversations.js +150 -0
  34. package/dist/resources/conversations.js.map +1 -0
  35. package/dist/types.d.ts +461 -0
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/types.js +3 -0
  38. package/dist/types.js.map +1 -0
  39. package/package.json +29 -0
  40. package/src/client.ts +87 -0
  41. package/src/core/error.ts +69 -0
  42. package/src/core/http.ts +639 -0
  43. package/src/core/pagination.ts +27 -0
  44. package/src/core/sse.ts +338 -0
  45. package/src/index.ts +13 -0
  46. package/src/resources/config.ts +22 -0
  47. package/src/resources/conversations.ts +232 -0
  48. package/src/types.ts +512 -0
package/src/types.ts ADDED
@@ -0,0 +1,512 @@
1
+ // Generated by redwood. Do not edit by hand.
2
+
3
+ /**
4
+ * Approve tool call request. Responds to a toolApprovalRequested event.
5
+ */
6
+ export interface ApproveToolCallRequest {
7
+ /**
8
+ * Conversation ID.
9
+ */
10
+ id?: string;
11
+ /**
12
+ * The tool call awaiting a decision, from the toolApprovalRequested event.
13
+ */
14
+ toolCallId?: string;
15
+ }
16
+
17
+ /**
18
+ * Continue conversation request.
19
+ */
20
+ export interface ContinueConversationRequest {
21
+ /**
22
+ * Conversation ID.
23
+ */
24
+ id?: string;
25
+ /**
26
+ * The visitor's next message.
27
+ */
28
+ message: string;
29
+ }
30
+
31
+ /**
32
+ * Create conversation request. The session, tenant, subject, secrets, labels,
33
+ * and pinned parameters all come from the presenting token's session — the
34
+ * browser asserts nothing.
35
+ */
36
+ export interface CreateConversationRequest {
37
+ /**
38
+ * The visitor's opening message.
39
+ */
40
+ message: string;
41
+ }
42
+
43
+ /**
44
+ * Deny tool call request. Responds to a toolApprovalRequested event.
45
+ */
46
+ export interface DenyToolCallRequest {
47
+ /**
48
+ * Conversation ID.
49
+ */
50
+ id?: string;
51
+ /**
52
+ * The tool call awaiting a decision, from the toolApprovalRequested event.
53
+ */
54
+ toolCallId?: string;
55
+ }
56
+
57
+ /**
58
+ * Contains an arbitrary serialized message along with a @type that describes the type of the serialized message.
59
+ */
60
+ export interface GoogleProtobufAny {
61
+ /**
62
+ * The type of the serialized message.
63
+ */
64
+ '@type'?: string;
65
+ }
66
+
67
+ /**
68
+ * Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a list of values.
69
+ */
70
+ export type GoogleProtobufValue = unknown;
71
+
72
+ /**
73
+ * List conversation events response. Ordered oldest first.
74
+ */
75
+ export interface ListConversationEventsResponse {
76
+ items?: Array<WidgetEvent>;
77
+ pagination?: Page;
78
+ }
79
+
80
+ /**
81
+ * List conversations response. Ordered by last activity, newest first.
82
+ */
83
+ export interface ListConversationsResponse {
84
+ items?: Array<WidgetConversation>;
85
+ pagination?: Page;
86
+ }
87
+
88
+ /**
89
+ * Page carries pagination data for list responses. A deliberate local
90
+ * duplicate of the api module's Page — this package imports nothing from
91
+ * cadenya.api.v1 (see the workspace README).
92
+ */
93
+ export interface Page {
94
+ /**
95
+ * Cursor for the next page. Empty when there are no further results.
96
+ */
97
+ nextCursor?: string;
98
+ /**
99
+ * Total number of items matching the request.
100
+ */
101
+ total?: number;
102
+ }
103
+
104
+ /**
105
+ * Set tool call content request. Lets the embedding page supply the result
106
+ * of a bare tool call (one whose tool set has no execution adapter) — the
107
+ * widget-session flavor of the reverse-harness pattern, where client-side
108
+ * logic executes the tool and reports the result back. The result then
109
+ * reaches the conversation as a toolResult event.
110
+ */
111
+ export interface SetToolCallContentRequest {
112
+ /**
113
+ * Conversation ID.
114
+ */
115
+ id?: string;
116
+ /**
117
+ * The bare tool call to supply content for.
118
+ */
119
+ toolCallId?: string;
120
+ /**
121
+ * The tool call's result content.
122
+ */
123
+ content: string;
124
+ }
125
+
126
+ /**
127
+ * The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
128
+ */
129
+ export interface Status {
130
+ /**
131
+ * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
132
+ */
133
+ code?: number;
134
+ /**
135
+ * A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
136
+ */
137
+ message?: string;
138
+ /**
139
+ * A list of messages that carry the error details. There is a common set of message types for APIs to use.
140
+ */
141
+ details?: Array<GoogleProtobufAny>;
142
+ }
143
+
144
+ /**
145
+ * Submit conversation feedback request — the visitor's rating of a
146
+ * conversation, mirroring internal objective feedback in slimmed form. Flows
147
+ * into the same feedback machinery that scores agent variations.
148
+ */
149
+ export interface SubmitConversationFeedbackRequest {
150
+ /**
151
+ * Conversation ID.
152
+ */
153
+ id?: string;
154
+ /**
155
+ * A score between -1.0 and 1.0. -1.0 is the worst, 0.0 neutral, 1.0 the
156
+ * best — a thumbs-down/up UI maps to -1.0/1.0.
157
+ */
158
+ score: number;
159
+ /**
160
+ * Optional comment explaining the feedback.
161
+ */
162
+ comment?: string;
163
+ }
164
+
165
+ /**
166
+ * WidgetAssistantMessageEvent is a message from the agent. Content may
167
+ * arrive incrementally: later events for the same turn replace earlier
168
+ * partial content.
169
+ */
170
+ export interface WidgetAssistantMessageEvent {
171
+ content: string;
172
+ }
173
+
174
+ /**
175
+ * WidgetCancelledEvent: the conversation was cancelled. Terminal.
176
+ */
177
+ export interface WidgetCancelledEvent {
178
+ }
179
+
180
+ /**
181
+ * WidgetConfig is the widget's presentation configuration, served to the
182
+ * browser before any session exists. Contains nothing sensitive: the widget
183
+ * is identified by the hostname, and the edge has already enforced the
184
+ * origin allowlist by the time this is served.
185
+ */
186
+ export interface WidgetConfig {
187
+ /**
188
+ * Display name shown in the widget header.
189
+ */
190
+ displayName: string;
191
+ }
192
+
193
+ export type WidgetConversationState = 'STATE_UNSPECIFIED' | 'STATE_RESPONDING' | 'STATE_OPEN' | 'STATE_CLOSED';
194
+
195
+ /**
196
+ * WidgetConversation is one conversation between the session's visitor and
197
+ * the widget's agent. Conversations are scoped by the presenting token to the
198
+ * VISITOR: a session with a subject sees that subject's conversations on this
199
+ * widget; a session without one sees only the conversations it created
200
+ * itself. A conversation id from outside that scope is indistinguishable from
201
+ * one that does not exist. Tenant is a management-side grouping only — it is
202
+ * never a read scope on this surface.
203
+ */
204
+ export interface WidgetConversation {
205
+ id: string;
206
+ state: WidgetConversationState;
207
+ /**
208
+ * Server-derived display title (e.g. from the opening message).
209
+ */
210
+ title?: string;
211
+ createdAt: string;
212
+ /**
213
+ * When the conversation last saw a message or event.
214
+ */
215
+ lastActiveAt?: string;
216
+ }
217
+
218
+ /**
219
+ * WidgetErrorEvent reports a visitor-safe conversation error. The message is
220
+ * sanitized; internal error detail never reaches the widget.
221
+ */
222
+ export interface WidgetErrorEvent {
223
+ message: string;
224
+ }
225
+
226
+ /**
227
+ * WidgetEvent is the visitor-facing event vocabulary. It MIRRORS the internal
228
+ * conversation event variants — same granularity, same discriminator names —
229
+ * with slimmed messages holding exactly what a widget UI needs. Internal
230
+ * events map to these through an explicit, exhaustive server-side projection;
231
+ * internal-only types (context compaction, memory reads, sub-agent
232
+ * bookkeeping) have no widget variant and are dropped. Nothing here carries
233
+ * tool configuration, tool arguments, server identities, operator details,
234
+ * or internal error strings.
235
+ */
236
+ export type WidgetEvent =
237
+ | WidgetEvent_UserMessage
238
+ | WidgetEvent_AssistantMessage
239
+ | WidgetEvent_ToolApprovalRequested
240
+ | WidgetEvent_ToolApproved
241
+ | WidgetEvent_ToolDenied
242
+ | WidgetEvent_ToolCalled
243
+ | WidgetEvent_ToolResult
244
+ | WidgetEvent_ToolError
245
+ | WidgetEvent_Error
246
+ | WidgetEvent_Cancelled
247
+ | WidgetEvent_TimedOut;
248
+
249
+ /**
250
+ * WidgetTimedOutEvent: the conversation timed out after inactivity. Terminal.
251
+ * (There is no finalized variant: agents with structured output — the only
252
+ * path to finalization — cannot be bound to widgets.)
253
+ */
254
+ export interface WidgetTimedOutEvent {
255
+ }
256
+
257
+ /**
258
+ * WidgetToolApprovalRequestedEvent asks the visitor to approve or deny a
259
+ * tool call before it runs. The tool reference lets the embedding UI render
260
+ * a custom approval experience per tool; the visitor responds via the
261
+ * approve/deny endpoints.
262
+ */
263
+ export interface WidgetToolApprovalRequestedEvent {
264
+ /**
265
+ * The tool call awaiting a decision; pass it to the approve/deny endpoint.
266
+ */
267
+ toolCallId: string;
268
+ tool: WidgetToolReference;
269
+ }
270
+
271
+ /**
272
+ * WidgetToolApprovedEvent records that the pending tool call was approved.
273
+ */
274
+ export interface WidgetToolApprovedEvent {
275
+ toolCallId: string;
276
+ }
277
+
278
+ /**
279
+ * WidgetToolCalledEvent reports that the agent invoked a tool. Arguments are
280
+ * never included.
281
+ */
282
+ export interface WidgetToolCalledEvent {
283
+ toolCallId: string;
284
+ tool: WidgetToolReference;
285
+ }
286
+
287
+ /**
288
+ * WidgetToolDeniedEvent records that the pending tool call was denied.
289
+ */
290
+ export interface WidgetToolDeniedEvent {
291
+ toolCallId: string;
292
+ }
293
+
294
+ /**
295
+ * WidgetToolErrorEvent reports that a tool call failed. Internal error
296
+ * detail never reaches the widget.
297
+ */
298
+ export interface WidgetToolErrorEvent {
299
+ toolCallId: string;
300
+ tool: WidgetToolReference;
301
+ }
302
+
303
+ /**
304
+ * WidgetToolReference identifies the tool involved in a tool event — enough
305
+ * for the embedding UI to label the activity and to register custom
306
+ * renderers keyed by the tool's id or the customer's own external id.
307
+ * Deliberately omitted: tool configuration, adapter details, and any server
308
+ * identity.
309
+ */
310
+ export interface WidgetToolReference {
311
+ /**
312
+ * Cadenya's canonical tool id.
313
+ */
314
+ id: string;
315
+ /**
316
+ * The tool's external id in the customer's namespace, when set.
317
+ */
318
+ externalId?: string;
319
+ /**
320
+ * The tool's name as the workspace configured it (e.g. "FetchOrderDetails").
321
+ */
322
+ name: string;
323
+ }
324
+
325
+ /**
326
+ * WidgetToolResultEvent reports that a tool call finished. Result content is
327
+ * omitted by default and included only for tools the workspace has opted in
328
+ * to sharing content with widget sessions.
329
+ */
330
+ export interface WidgetToolResultEvent {
331
+ toolCallId: string;
332
+ tool: WidgetToolReference;
333
+ /**
334
+ * The tool's result, present only for tools opted in to sharing content
335
+ * with widget sessions (a per-tool setting; default off). Arbitrary JSON
336
+ * the embedding UI may render — chart data, cards, structured results.
337
+ */
338
+ content?: GoogleProtobufValue;
339
+ }
340
+
341
+ /**
342
+ * WidgetUserMessageEvent is a message from the visitor.
343
+ */
344
+ export interface WidgetUserMessageEvent {
345
+ content: string;
346
+ }
347
+
348
+ export interface WidgetEvent_UserMessage {
349
+ type: 'userMessage';
350
+ userMessage: WidgetUserMessageEvent;
351
+ /**
352
+ * Unique event id (ULID). Doubles as the SSE `id:` — replay it as
353
+ * `Last-Event-ID` on reconnect to resume without duplication.
354
+ */
355
+ id: string;
356
+ /**
357
+ * The conversation this event belongs to.
358
+ */
359
+ conversationId: string;
360
+ createdAt: string;
361
+ }
362
+
363
+ export interface WidgetEvent_AssistantMessage {
364
+ type: 'assistantMessage';
365
+ assistantMessage: WidgetAssistantMessageEvent;
366
+ /**
367
+ * Unique event id (ULID). Doubles as the SSE `id:` — replay it as
368
+ * `Last-Event-ID` on reconnect to resume without duplication.
369
+ */
370
+ id: string;
371
+ /**
372
+ * The conversation this event belongs to.
373
+ */
374
+ conversationId: string;
375
+ createdAt: string;
376
+ }
377
+
378
+ export interface WidgetEvent_ToolApprovalRequested {
379
+ type: 'toolApprovalRequested';
380
+ toolApprovalRequested: WidgetToolApprovalRequestedEvent;
381
+ /**
382
+ * Unique event id (ULID). Doubles as the SSE `id:` — replay it as
383
+ * `Last-Event-ID` on reconnect to resume without duplication.
384
+ */
385
+ id: string;
386
+ /**
387
+ * The conversation this event belongs to.
388
+ */
389
+ conversationId: string;
390
+ createdAt: string;
391
+ }
392
+
393
+ export interface WidgetEvent_ToolApproved {
394
+ type: 'toolApproved';
395
+ toolApproved: WidgetToolApprovedEvent;
396
+ /**
397
+ * Unique event id (ULID). Doubles as the SSE `id:` — replay it as
398
+ * `Last-Event-ID` on reconnect to resume without duplication.
399
+ */
400
+ id: string;
401
+ /**
402
+ * The conversation this event belongs to.
403
+ */
404
+ conversationId: string;
405
+ createdAt: string;
406
+ }
407
+
408
+ export interface WidgetEvent_ToolDenied {
409
+ type: 'toolDenied';
410
+ toolDenied: WidgetToolDeniedEvent;
411
+ /**
412
+ * Unique event id (ULID). Doubles as the SSE `id:` — replay it as
413
+ * `Last-Event-ID` on reconnect to resume without duplication.
414
+ */
415
+ id: string;
416
+ /**
417
+ * The conversation this event belongs to.
418
+ */
419
+ conversationId: string;
420
+ createdAt: string;
421
+ }
422
+
423
+ export interface WidgetEvent_ToolCalled {
424
+ type: 'toolCalled';
425
+ toolCalled: WidgetToolCalledEvent;
426
+ /**
427
+ * Unique event id (ULID). Doubles as the SSE `id:` — replay it as
428
+ * `Last-Event-ID` on reconnect to resume without duplication.
429
+ */
430
+ id: string;
431
+ /**
432
+ * The conversation this event belongs to.
433
+ */
434
+ conversationId: string;
435
+ createdAt: string;
436
+ }
437
+
438
+ export interface WidgetEvent_ToolResult {
439
+ type: 'toolResult';
440
+ toolResult: WidgetToolResultEvent;
441
+ /**
442
+ * Unique event id (ULID). Doubles as the SSE `id:` — replay it as
443
+ * `Last-Event-ID` on reconnect to resume without duplication.
444
+ */
445
+ id: string;
446
+ /**
447
+ * The conversation this event belongs to.
448
+ */
449
+ conversationId: string;
450
+ createdAt: string;
451
+ }
452
+
453
+ export interface WidgetEvent_ToolError {
454
+ type: 'toolError';
455
+ toolError: WidgetToolErrorEvent;
456
+ /**
457
+ * Unique event id (ULID). Doubles as the SSE `id:` — replay it as
458
+ * `Last-Event-ID` on reconnect to resume without duplication.
459
+ */
460
+ id: string;
461
+ /**
462
+ * The conversation this event belongs to.
463
+ */
464
+ conversationId: string;
465
+ createdAt: string;
466
+ }
467
+
468
+ export interface WidgetEvent_Error {
469
+ type: 'error';
470
+ error: WidgetErrorEvent;
471
+ /**
472
+ * Unique event id (ULID). Doubles as the SSE `id:` — replay it as
473
+ * `Last-Event-ID` on reconnect to resume without duplication.
474
+ */
475
+ id: string;
476
+ /**
477
+ * The conversation this event belongs to.
478
+ */
479
+ conversationId: string;
480
+ createdAt: string;
481
+ }
482
+
483
+ export interface WidgetEvent_Cancelled {
484
+ type: 'cancelled';
485
+ cancelled: WidgetCancelledEvent;
486
+ /**
487
+ * Unique event id (ULID). Doubles as the SSE `id:` — replay it as
488
+ * `Last-Event-ID` on reconnect to resume without duplication.
489
+ */
490
+ id: string;
491
+ /**
492
+ * The conversation this event belongs to.
493
+ */
494
+ conversationId: string;
495
+ createdAt: string;
496
+ }
497
+
498
+ export interface WidgetEvent_TimedOut {
499
+ type: 'timedOut';
500
+ timedOut: WidgetTimedOutEvent;
501
+ /**
502
+ * Unique event id (ULID). Doubles as the SSE `id:` — replay it as
503
+ * `Last-Event-ID` on reconnect to resume without duplication.
504
+ */
505
+ id: string;
506
+ /**
507
+ * The conversation this event belongs to.
508
+ */
509
+ conversationId: string;
510
+ createdAt: string;
511
+ }
512
+