@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
@@ -0,0 +1,173 @@
1
+ import { HttpClient, RequestOptions, APIPromise } from '../core/http.js';
2
+ import { Page } from '../core/pagination.js';
3
+ import { Stream } from '../core/sse.js';
4
+ import type { WidgetConversation, WidgetEvent } from '../types.js';
5
+ export interface ConversationListParams {
6
+ /**
7
+ * Maximum number of results to return.
8
+ */
9
+ limit?: number;
10
+ /**
11
+ * Pagination cursor from previous response.
12
+ */
13
+ cursor?: string;
14
+ }
15
+ export interface ConversationCreateParams {
16
+ /**
17
+ * The visitor's opening message.
18
+ */
19
+ message: string;
20
+ }
21
+ export interface ConversationListEventsParams {
22
+ /**
23
+ * Maximum number of results to return.
24
+ */
25
+ limit?: number;
26
+ /**
27
+ * Pagination cursor from previous response.
28
+ */
29
+ cursor?: string;
30
+ }
31
+ export interface ConversationSubmitFeedbackParams {
32
+ /**
33
+ * A score between -1.0 and 1.0. -1.0 is the worst, 0.0 neutral, 1.0 the
34
+ * best — a thumbs-down/up UI maps to -1.0/1.0.
35
+ */
36
+ score: number;
37
+ /**
38
+ * Optional comment explaining the feedback.
39
+ */
40
+ comment?: string;
41
+ }
42
+ export interface ConversationApproveToolCallParams {
43
+ /**
44
+ * The tool call awaiting a decision, from the toolApprovalRequested event.
45
+ */
46
+ toolCallId: string;
47
+ }
48
+ export interface ConversationDenyToolCallParams {
49
+ /**
50
+ * The tool call awaiting a decision, from the toolApprovalRequested event.
51
+ */
52
+ toolCallId: string;
53
+ }
54
+ export interface ConversationSetToolCallContentParams {
55
+ /**
56
+ * The bare tool call to supply content for.
57
+ */
58
+ toolCallId: string;
59
+ /**
60
+ * The tool call's result content.
61
+ */
62
+ content: string;
63
+ }
64
+ export interface ConversationContinueParams {
65
+ /**
66
+ * The visitor's next message.
67
+ */
68
+ message: string;
69
+ }
70
+ export declare class Conversations {
71
+ private readonly _client;
72
+ constructor(_client: HttpClient);
73
+ /**
74
+ * List conversations
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const page = await client.conversations.list();
79
+ * for await (const item of page) {
80
+ * // auto-fetches every page
81
+ * }
82
+ * ```
83
+ */
84
+ list(params?: ConversationListParams, options?: RequestOptions): Promise<Page<WidgetConversation>>;
85
+ /**
86
+ * Start a conversation
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * const widgetConversation = await client.conversations.create({ message: 'sample' });
91
+ * ```
92
+ */
93
+ create(params: ConversationCreateParams, options?: RequestOptions): APIPromise<WidgetConversation>;
94
+ /**
95
+ * Get a conversation
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * const widgetConversation = await client.conversations.retrieve('_123');
100
+ * ```
101
+ */
102
+ retrieve(id: string, options?: RequestOptions): APIPromise<WidgetConversation>;
103
+ /**
104
+ * List conversation events
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * const page = await client.conversations.listEvents('_123');
109
+ * for await (const item of page) {
110
+ * // auto-fetches every page
111
+ * }
112
+ * ```
113
+ */
114
+ listEvents(id: string, params?: ConversationListEventsParams, options?: RequestOptions): Promise<Page<WidgetEvent>>;
115
+ /**
116
+ * Stream conversation events
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * const stream = await client.conversations.streamEvents('_123');
121
+ * for await (const event of stream) {
122
+ * // typed event payloads; housekeeping frames are skipped
123
+ * }
124
+ * ```
125
+ */
126
+ streamEvents(id: string, options?: RequestOptions): Promise<Stream<WidgetEvent>>;
127
+ /**
128
+ * Submit conversation feedback
129
+ *
130
+ * @example
131
+ * ```ts
132
+ * await client.conversations.submitFeedback('_123', { score: 1.5 });
133
+ * ```
134
+ */
135
+ submitFeedback(id: string, params: ConversationSubmitFeedbackParams, options?: RequestOptions): APIPromise<void>;
136
+ /**
137
+ * Approve a pending tool call
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * await client.conversations.approveToolCall('_123', { toolCallId: 'tool_call_123' });
142
+ * ```
143
+ */
144
+ approveToolCall(id: string, params: ConversationApproveToolCallParams, options?: RequestOptions): APIPromise<void>;
145
+ /**
146
+ * Deny a pending tool call
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * await client.conversations.denyToolCall('_123', { toolCallId: 'tool_call_123' });
151
+ * ```
152
+ */
153
+ denyToolCall(id: string, params: ConversationDenyToolCallParams, options?: RequestOptions): APIPromise<void>;
154
+ /**
155
+ * Supply a bare tool call's result
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * await client.conversations.setToolCallContent('_123', { toolCallId: 'tool_call_123', content: 'sample' });
160
+ * ```
161
+ */
162
+ setToolCallContent(id: string, params: ConversationSetToolCallContentParams, options?: RequestOptions): APIPromise<void>;
163
+ /**
164
+ * Send the next message
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * const widgetConversation = await client.conversations.continue('_123', { message: 'sample' });
169
+ * ```
170
+ */
171
+ continue(id: string, params: ConversationContinueParams, options?: RequestOptions): APIPromise<WidgetConversation>;
172
+ }
173
+ //# sourceMappingURL=conversations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../src/resources/conversations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAe,UAAU,EAA+B,MAAM,iBAAiB,CAAC;AACnH,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,EAA6D,kBAAkB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE9H,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;I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cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAMtF;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,gCAAgC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;IAMhH;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,iCAAiC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;IAMlH;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;IAM5G;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,oCAAoC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;IAMxH;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,0BAA0B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,kBAAkB,CAAC;CAKnH"}
@@ -0,0 +1,150 @@
1
+ // Generated by redwood. Do not edit by hand.
2
+ import { pathSegment, snapshotParams } from '../core/http.js';
3
+ import { Page } from '../core/pagination.js';
4
+ import { Stream } from '../core/sse.js';
5
+ export class Conversations {
6
+ _client;
7
+ constructor(_client) {
8
+ this._client = _client;
9
+ }
10
+ /**
11
+ * List conversations
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const page = await client.conversations.list();
16
+ * for await (const item of page) {
17
+ * // auto-fetches every page
18
+ * }
19
+ * ```
20
+ */
21
+ async list(params, options) {
22
+ const _base = snapshotParams(params);
23
+ const response = await this._client.request({ method: 'GET', path: `/v1/conversations`, query: { limit: params?.limit, cursor: params?.cursor } }, options);
24
+ return new Page(response.items ?? [], response.pagination?.nextCursor, (cursor) => this.list({ ..._base, cursor: cursor }, options));
25
+ }
26
+ /**
27
+ * Start a conversation
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const widgetConversation = await client.conversations.create({ message: 'sample' });
32
+ * ```
33
+ */
34
+ create(params, options) {
35
+ return this._client.requestAPI(() => {
36
+ return { method: 'POST', path: `/v1/conversations`, body: { message: params.message } };
37
+ }, options);
38
+ }
39
+ /**
40
+ * Get a conversation
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const widgetConversation = await client.conversations.retrieve('_123');
45
+ * ```
46
+ */
47
+ retrieve(id, options) {
48
+ return this._client.requestAPI(() => {
49
+ return { method: 'GET', path: `/v1/conversations/${pathSegment('id', id)}` };
50
+ }, options);
51
+ }
52
+ /**
53
+ * List conversation events
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const page = await client.conversations.listEvents('_123');
58
+ * for await (const item of page) {
59
+ * // auto-fetches every page
60
+ * }
61
+ * ```
62
+ */
63
+ async listEvents(id, params, options) {
64
+ const _base = snapshotParams(params);
65
+ const response = await this._client.request({ method: 'GET', path: `/v1/conversations/${pathSegment('id', id)}/events`, query: { limit: params?.limit, cursor: params?.cursor } }, options);
66
+ return new Page(response.items ?? [], response.pagination?.nextCursor, (cursor) => this.listEvents(id, { ..._base, cursor: cursor }, options));
67
+ }
68
+ /**
69
+ * Stream conversation events
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * const stream = await client.conversations.streamEvents('_123');
74
+ * for await (const event of stream) {
75
+ * // typed event payloads; housekeeping frames are skipped
76
+ * }
77
+ * ```
78
+ */
79
+ async streamEvents(id, options) {
80
+ const _spec = { method: 'GET', path: `/v1/conversations/${pathSegment('id', id)}/events:stream`, stream: true };
81
+ const response = await this._client.rawRequest(_spec, options);
82
+ return new Stream(response, options?.signal, options?.lastEventId, ['ping', 'open'], options?.reconnect === false ? undefined : (lastEventId, signal) => this._client.rawRequest(_spec, { ...options, lastEventId, signal }));
83
+ }
84
+ /**
85
+ * Submit conversation feedback
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * await client.conversations.submitFeedback('_123', { score: 1.5 });
90
+ * ```
91
+ */
92
+ submitFeedback(id, params, options) {
93
+ return this._client.requestAPI(() => {
94
+ return { method: 'POST', path: `/v1/conversations/${pathSegment('id', id)}/feedback`, body: { score: params.score, comment: params.comment }, void: true };
95
+ }, options);
96
+ }
97
+ /**
98
+ * Approve a pending tool call
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * await client.conversations.approveToolCall('_123', { toolCallId: 'tool_call_123' });
103
+ * ```
104
+ */
105
+ approveToolCall(id, params, options) {
106
+ return this._client.requestAPI(() => {
107
+ return { method: 'POST', path: `/v1/conversations/${pathSegment('id', id)}/tool_calls/${pathSegment('toolCallId', params.toolCallId)}:approve`, void: true };
108
+ }, options);
109
+ }
110
+ /**
111
+ * Deny a pending tool call
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * await client.conversations.denyToolCall('_123', { toolCallId: 'tool_call_123' });
116
+ * ```
117
+ */
118
+ denyToolCall(id, params, options) {
119
+ return this._client.requestAPI(() => {
120
+ return { method: 'POST', path: `/v1/conversations/${pathSegment('id', id)}/tool_calls/${pathSegment('toolCallId', params.toolCallId)}:deny`, void: true };
121
+ }, options);
122
+ }
123
+ /**
124
+ * Supply a bare tool call's result
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * await client.conversations.setToolCallContent('_123', { toolCallId: 'tool_call_123', content: 'sample' });
129
+ * ```
130
+ */
131
+ setToolCallContent(id, params, options) {
132
+ return this._client.requestAPI(() => {
133
+ return { method: 'POST', path: `/v1/conversations/${pathSegment('id', id)}/tool_calls/${pathSegment('toolCallId', params.toolCallId)}:setContent`, body: { content: params.content }, void: true };
134
+ }, options);
135
+ }
136
+ /**
137
+ * Send the next message
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * const widgetConversation = await client.conversations.continue('_123', { message: 'sample' });
142
+ * ```
143
+ */
144
+ continue(id, params, options) {
145
+ return this._client.requestAPI(() => {
146
+ return { method: 'POST', path: `/v1/conversations/${pathSegment('id', id)}:continue`, body: { message: params.message } };
147
+ }, options);
148
+ }
149
+ }
150
+ //# sourceMappingURL=conversations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversations.js","sourceRoot":"","sources":["../../src/resources/conversations.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAE7C,OAAO,EAAuD,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACnH,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AA4ExC,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;IAAG,CAAC;IAEpD;;;;;;;;;;OAUG;IACH,KAAK,CAAC,IAAI,CAAC,MAA+B,EAAE,OAAwB;QAClE,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAA4B,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QACvL,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,EAAE,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;IACvI,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,MAAgC,EAAE,OAAwB;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAqB,GAA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AAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5H,CAAC,EAAE,OAAO,CAAC,CAAC;IACd,CAAC;CACF","sourcesContent":["// Generated by redwood. Do not edit by hand.\n\nimport { HttpClient, RequestOptions, RequestSpec, APIPromise, pathSegment, snapshotParams } from '../core/http.js';\nimport { Page } from '../core/pagination.js';\nimport { Stream } from '../core/sse.js';\nimport type { ListConversationEventsResponse, ListConversationsResponse, WidgetConversation, WidgetEvent } from '../types.js';\n\nexport interface ConversationListParams {\n /**\n * Maximum number of results to return.\n */\n limit?: number;\n /**\n * Pagination cursor from previous response.\n */\n cursor?: string;\n}\n\nexport interface ConversationCreateParams {\n /**\n * The visitor's opening message.\n */\n message: string;\n}\n\nexport interface ConversationListEventsParams {\n /**\n * Maximum number of results to return.\n */\n limit?: number;\n /**\n * Pagination cursor from previous response.\n */\n cursor?: string;\n}\n\nexport interface ConversationSubmitFeedbackParams {\n /**\n * A score between -1.0 and 1.0. -1.0 is the worst, 0.0 neutral, 1.0 the\n * best — a thumbs-down/up UI maps to -1.0/1.0.\n */\n score: number;\n /**\n * Optional comment explaining the feedback.\n */\n comment?: string;\n}\n\nexport interface ConversationApproveToolCallParams {\n /**\n * The tool call awaiting a decision, from the toolApprovalRequested event.\n */\n toolCallId: string;\n}\n\nexport interface ConversationDenyToolCallParams {\n /**\n * The tool call awaiting a decision, from the toolApprovalRequested event.\n */\n toolCallId: string;\n}\n\nexport interface ConversationSetToolCallContentParams {\n /**\n * The bare tool call to supply content for.\n */\n toolCallId: string;\n /**\n * The tool call's result content.\n */\n content: string;\n}\n\nexport interface ConversationContinueParams {\n /**\n * The visitor's next message.\n */\n message: string;\n}\n\nexport class Conversations {\n constructor(private readonly _client: HttpClient) {}\n\n /**\n * List conversations\n * \n * @example\n * ```ts\n * const page = await client.conversations.list();\n * for await (const item of page) {\n * // auto-fetches every page\n * }\n * ```\n */\n async list(params?: ConversationListParams, options?: RequestOptions): Promise<Page<WidgetConversation>> {\n const _base = snapshotParams(params);\n const response = await this._client.request<ListConversationsResponse>({ method: 'GET', path: `/v1/conversations`, query: { limit: params?.limit, cursor: params?.cursor } }, options);\n return new Page(response.items ?? [], response.pagination?.nextCursor, (cursor) => this.list({ ..._base, cursor: cursor }, options));\n }\n\n /**\n * Start a conversation\n * \n * @example\n * ```ts\n * const widgetConversation = await client.conversations.create({ message: 'sample' });\n * ```\n */\n create(params: ConversationCreateParams, options?: RequestOptions): APIPromise<WidgetConversation> {\n return this._client.requestAPI<WidgetConversation>(() => {\n return { method: 'POST', path: `/v1/conversations`, body: { message: params.message } };\n }, options);\n }\n\n /**\n * Get a conversation\n * \n * @example\n * ```ts\n * const widgetConversation = await client.conversations.retrieve('_123');\n * ```\n */\n retrieve(id: string, options?: RequestOptions): APIPromise<WidgetConversation> {\n return this._client.requestAPI<WidgetConversation>(() => {\n return { method: 'GET', path: `/v1/conversations/${pathSegment('id', id)}` };\n }, options);\n }\n\n /**\n * List conversation events\n * \n * @example\n * ```ts\n * const page = await client.conversations.listEvents('_123');\n * for await (const item of page) {\n * // auto-fetches every page\n * }\n * ```\n */\n async listEvents(id: string, params?: ConversationListEventsParams, options?: RequestOptions): Promise<Page<WidgetEvent>> {\n const _base = snapshotParams(params);\n const response = await this._client.request<ListConversationEventsResponse>({ method: 'GET', path: `/v1/conversations/${pathSegment('id', id)}/events`, query: { limit: params?.limit, cursor: params?.cursor } }, options);\n return new Page(response.items ?? [], response.pagination?.nextCursor, (cursor) => this.listEvents(id, { ..._base, cursor: cursor }, options));\n }\n\n /**\n * Stream conversation events\n * \n * @example\n * ```ts\n * const stream = await client.conversations.streamEvents('_123');\n * for await (const event of stream) {\n * // typed event payloads; housekeeping frames are skipped\n * }\n * ```\n */\n async streamEvents(id: string, options?: RequestOptions): Promise<Stream<WidgetEvent>> {\n const _spec: RequestSpec = { method: 'GET', path: `/v1/conversations/${pathSegment('id', id)}/events:stream`, stream: true };\n const response = await this._client.rawRequest(_spec, options);\n return new Stream<WidgetEvent>(response, options?.signal, options?.lastEventId, ['ping', 'open'], options?.reconnect === false ? undefined : (lastEventId, signal) => this._client.rawRequest(_spec, { ...options, lastEventId, signal }));\n }\n\n /**\n * Submit conversation feedback\n * \n * @example\n * ```ts\n * await client.conversations.submitFeedback('_123', { score: 1.5 });\n * ```\n */\n submitFeedback(id: string, params: ConversationSubmitFeedbackParams, options?: RequestOptions): APIPromise<void> {\n return this._client.requestAPI<void>(() => {\n return { method: 'POST', path: `/v1/conversations/${pathSegment('id', id)}/feedback`, body: { score: params.score, comment: params.comment }, void: true };\n }, options);\n }\n\n /**\n * Approve a pending tool call\n * \n * @example\n * ```ts\n * await client.conversations.approveToolCall('_123', { toolCallId: 'tool_call_123' });\n * ```\n */\n approveToolCall(id: string, params: ConversationApproveToolCallParams, options?: RequestOptions): APIPromise<void> {\n return this._client.requestAPI<void>(() => {\n return { method: 'POST', path: `/v1/conversations/${pathSegment('id', id)}/tool_calls/${pathSegment('toolCallId', params.toolCallId)}:approve`, void: true };\n }, options);\n }\n\n /**\n * Deny a pending tool call\n * \n * @example\n * ```ts\n * await client.conversations.denyToolCall('_123', { toolCallId: 'tool_call_123' });\n * ```\n */\n denyToolCall(id: string, params: ConversationDenyToolCallParams, options?: RequestOptions): APIPromise<void> {\n return this._client.requestAPI<void>(() => {\n return { method: 'POST', path: `/v1/conversations/${pathSegment('id', id)}/tool_calls/${pathSegment('toolCallId', params.toolCallId)}:deny`, void: true };\n }, options);\n }\n\n /**\n * Supply a bare tool call's result\n * \n * @example\n * ```ts\n * await client.conversations.setToolCallContent('_123', { toolCallId: 'tool_call_123', content: 'sample' });\n * ```\n */\n setToolCallContent(id: string, params: ConversationSetToolCallContentParams, options?: RequestOptions): APIPromise<void> {\n return this._client.requestAPI<void>(() => {\n return { method: 'POST', path: `/v1/conversations/${pathSegment('id', id)}/tool_calls/${pathSegment('toolCallId', params.toolCallId)}:setContent`, body: { content: params.content }, void: true };\n }, options);\n }\n\n /**\n * Send the next message\n * \n * @example\n * ```ts\n * const widgetConversation = await client.conversations.continue('_123', { message: 'sample' });\n * ```\n */\n continue(id: string, params: ConversationContinueParams, options?: RequestOptions): APIPromise<WidgetConversation> {\n return this._client.requestAPI<WidgetConversation>(() => {\n return { method: 'POST', path: `/v1/conversations/${pathSegment('id', id)}:continue`, body: { message: params.message } };\n }, options);\n }\n}\n"]}