@smooai/smooth-operator 0.1.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.
- package/LICENSE +21 -0
- package/README.md +157 -0
- package/dist/client.d.ts +148 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +359 -0
- package/dist/client.js.map +1 -0
- package/dist/generated/types.d.ts +1273 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +9 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/transport.d.ts +70 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +167 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +74 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +49 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.d.ts +52 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +133 -0
- package/dist/validate.js.map +1 -0
- package/package.json +65 -0
- package/src/client.ts +435 -0
- package/src/generated/types.ts +1358 -0
- package/src/index.ts +31 -0
- package/src/transport.ts +194 -0
- package/src/types.ts +184 -0
- package/src/validate.ts +158 -0
|
@@ -0,0 +1,1273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUTO-GENERATED — do not edit by hand.
|
|
3
|
+
*
|
|
4
|
+
* Generated from the JSON Schemas in ../spec by scripts/generate.ts
|
|
5
|
+
* Run `pnpm generate` to regenerate after a schema change.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Fields sent by the client to approve or reject a pending tool write.
|
|
9
|
+
*/
|
|
10
|
+
export interface ConfirmToolActionRequest {
|
|
11
|
+
/**
|
|
12
|
+
* Action discriminator.
|
|
13
|
+
*/
|
|
14
|
+
action: 'confirm_tool_action';
|
|
15
|
+
/**
|
|
16
|
+
* Must match the `requestId` from the `write_confirmation_required` event being responded to. This is how the server correlates the confirmation back to the paused workflow.
|
|
17
|
+
*/
|
|
18
|
+
requestId: string;
|
|
19
|
+
/**
|
|
20
|
+
* Session ID of the paused session.
|
|
21
|
+
*/
|
|
22
|
+
sessionId: string;
|
|
23
|
+
/**
|
|
24
|
+
* True to allow the tool call to proceed; false to reject it. On rejection the agent workflow resumes with an informational context message.
|
|
25
|
+
*/
|
|
26
|
+
approved: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* No dedicated response — the workflow continuation is signalled by resumed streaming events.
|
|
30
|
+
*/
|
|
31
|
+
export interface ConfirmToolActionResponse {
|
|
32
|
+
[k: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Fields sent by the client to open a new session.
|
|
36
|
+
*/
|
|
37
|
+
export interface CreateConversationSessionRequest {
|
|
38
|
+
/**
|
|
39
|
+
* Action discriminator.
|
|
40
|
+
*/
|
|
41
|
+
action: 'create_conversation_session';
|
|
42
|
+
/**
|
|
43
|
+
* Client-generated correlation ID echoed back on all related events.
|
|
44
|
+
*/
|
|
45
|
+
requestId?: string;
|
|
46
|
+
/**
|
|
47
|
+
* UUID of the agent to start a session with.
|
|
48
|
+
*/
|
|
49
|
+
agentId: string;
|
|
50
|
+
/**
|
|
51
|
+
* Optional display name for the user participant.
|
|
52
|
+
*/
|
|
53
|
+
userName?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Optional email address for the user participant.
|
|
56
|
+
*/
|
|
57
|
+
userEmail?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Browser fingerprint string (e.g. from ThumbmarkJS) used for anonymous user correlation across sessions.
|
|
60
|
+
*/
|
|
61
|
+
browserFingerprint?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Arbitrary key/value metadata to attach to the session.
|
|
64
|
+
*/
|
|
65
|
+
metadata?: {
|
|
66
|
+
[k: string]: unknown;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Pre-auth context for HMAC-based identity verification. When provided, the server can skip OTP flows by verifying the HMAC signature instead.
|
|
70
|
+
*/
|
|
71
|
+
authContext?: {
|
|
72
|
+
/**
|
|
73
|
+
* The user's identity claim.
|
|
74
|
+
*/
|
|
75
|
+
userId: string;
|
|
76
|
+
/**
|
|
77
|
+
* HMAC-SHA256 signature over `userId + timestamp` using a shared secret.
|
|
78
|
+
*/
|
|
79
|
+
signature: string;
|
|
80
|
+
/**
|
|
81
|
+
* Unix epoch seconds when the HMAC was signed. Used for replay protection (typical max age: 60s).
|
|
82
|
+
*/
|
|
83
|
+
timestamp: number;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Data payload carried in the `immediate_response` event that acknowledges session creation.
|
|
88
|
+
*/
|
|
89
|
+
export interface CreateConversationSessionResponse {
|
|
90
|
+
/**
|
|
91
|
+
* Newly created session ID. Use this in all subsequent actions.
|
|
92
|
+
*/
|
|
93
|
+
sessionId: string;
|
|
94
|
+
/**
|
|
95
|
+
* ID of the conversation created for this session.
|
|
96
|
+
*/
|
|
97
|
+
conversationId: string;
|
|
98
|
+
/**
|
|
99
|
+
* ID of the agent handling this session.
|
|
100
|
+
*/
|
|
101
|
+
agentId: string;
|
|
102
|
+
/**
|
|
103
|
+
* Display name of the agent.
|
|
104
|
+
*/
|
|
105
|
+
agentName: string;
|
|
106
|
+
/**
|
|
107
|
+
* Participant ID representing the user in this conversation.
|
|
108
|
+
*/
|
|
109
|
+
userParticipantId: string;
|
|
110
|
+
/**
|
|
111
|
+
* Participant ID representing the AI agent in this conversation.
|
|
112
|
+
*/
|
|
113
|
+
agentParticipantId: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Fields sent by the client to page through conversation history.
|
|
117
|
+
*/
|
|
118
|
+
export interface GetMessagesRequest {
|
|
119
|
+
/**
|
|
120
|
+
* Action discriminator.
|
|
121
|
+
*/
|
|
122
|
+
action: 'get_conversation_messages';
|
|
123
|
+
/**
|
|
124
|
+
* Client-generated correlation ID echoed back on all related events.
|
|
125
|
+
*/
|
|
126
|
+
requestId?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Session ID whose conversation messages to fetch.
|
|
129
|
+
*/
|
|
130
|
+
sessionId: string;
|
|
131
|
+
/**
|
|
132
|
+
* Maximum number of messages to return per page. Must be 1–100; defaults to 50.
|
|
133
|
+
*/
|
|
134
|
+
limit?: number;
|
|
135
|
+
/**
|
|
136
|
+
* ISO 8601 cursor: return only messages created strictly before this timestamp. Omit to start from the most recent message.
|
|
137
|
+
*/
|
|
138
|
+
before?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Data payload carried in the `immediate_response` event.
|
|
142
|
+
*/
|
|
143
|
+
export interface GetMessagesResponse {
|
|
144
|
+
/**
|
|
145
|
+
* Ordered list of messages (newest-first up to `limit`).
|
|
146
|
+
*/
|
|
147
|
+
messages: ConversationMessage[];
|
|
148
|
+
/**
|
|
149
|
+
* True if more messages exist before the oldest message in this page. Use the oldest `createdAt` as the next `before` cursor.
|
|
150
|
+
*/
|
|
151
|
+
hasMore: boolean;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* A single message as returned on the wire. This is a subset of the full `Message` domain object — it omits server-only fields (metadataJson, analyticsJson) and includes abbreviated participant descriptors.
|
|
155
|
+
*/
|
|
156
|
+
export interface ConversationMessage {
|
|
157
|
+
/**
|
|
158
|
+
* Unique message ID.
|
|
159
|
+
*/
|
|
160
|
+
id: string;
|
|
161
|
+
/**
|
|
162
|
+
* Message direction: `inbound` = from user, `outbound` = from agent.
|
|
163
|
+
*/
|
|
164
|
+
direction: 'inbound' | 'outbound';
|
|
165
|
+
/**
|
|
166
|
+
* Message payload. `text` contains the plain-text form; `structuredResponse` contains parsed agent output when present.
|
|
167
|
+
*/
|
|
168
|
+
content: {
|
|
169
|
+
/**
|
|
170
|
+
* Plain-text content.
|
|
171
|
+
*/
|
|
172
|
+
text?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Structured agent response (shape depends on agent template).
|
|
175
|
+
*/
|
|
176
|
+
structuredResponse?: {
|
|
177
|
+
[k: string]: unknown;
|
|
178
|
+
} | null;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Abbreviated sender descriptor.
|
|
182
|
+
*/
|
|
183
|
+
from?: {
|
|
184
|
+
id: string;
|
|
185
|
+
type: string;
|
|
186
|
+
name?: string;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Abbreviated recipient descriptor.
|
|
190
|
+
*/
|
|
191
|
+
to?: {
|
|
192
|
+
id: string;
|
|
193
|
+
type: string;
|
|
194
|
+
name?: string;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* ISO 8601 timestamp when the message was created.
|
|
198
|
+
*/
|
|
199
|
+
createdAt: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Fields sent by the client to retrieve a session.
|
|
203
|
+
*/
|
|
204
|
+
export interface GetSessionRequest {
|
|
205
|
+
/**
|
|
206
|
+
* Action discriminator.
|
|
207
|
+
*/
|
|
208
|
+
action: 'get_session';
|
|
209
|
+
/**
|
|
210
|
+
* Client-generated correlation ID echoed back on all related events.
|
|
211
|
+
*/
|
|
212
|
+
requestId?: string;
|
|
213
|
+
/**
|
|
214
|
+
* ID of the session to retrieve.
|
|
215
|
+
*/
|
|
216
|
+
sessionId: string;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Data payload carried in the `immediate_response` event. Field set matches `Session` in `domain/session.schema.json` (wire-subset; full domain object may include additional server-only fields).
|
|
220
|
+
*/
|
|
221
|
+
export interface GetSessionResponse {
|
|
222
|
+
/**
|
|
223
|
+
* Session ID.
|
|
224
|
+
*/
|
|
225
|
+
sessionId: string;
|
|
226
|
+
/**
|
|
227
|
+
* Conversation ID.
|
|
228
|
+
*/
|
|
229
|
+
conversationId: string;
|
|
230
|
+
/**
|
|
231
|
+
* Agent ID.
|
|
232
|
+
*/
|
|
233
|
+
agentId: string;
|
|
234
|
+
/**
|
|
235
|
+
* Display name of the agent.
|
|
236
|
+
*/
|
|
237
|
+
agentName: string;
|
|
238
|
+
/**
|
|
239
|
+
* Participant ID for the user in this session.
|
|
240
|
+
*/
|
|
241
|
+
userParticipantId: string;
|
|
242
|
+
/**
|
|
243
|
+
* Participant ID for the agent in this session.
|
|
244
|
+
*/
|
|
245
|
+
agentParticipantId: string;
|
|
246
|
+
/**
|
|
247
|
+
* smooth-operator thread identifier. Present when the session has an associated workflow thread.
|
|
248
|
+
*/
|
|
249
|
+
threadId?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Current lifecycle status of the session.
|
|
252
|
+
*/
|
|
253
|
+
status?: 'active' | 'idle' | 'ended';
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* A ping frame. Only `action` and the optional `requestId` are required.
|
|
257
|
+
*/
|
|
258
|
+
export interface PingRequest {
|
|
259
|
+
/**
|
|
260
|
+
* Action discriminator.
|
|
261
|
+
*/
|
|
262
|
+
action: 'ping';
|
|
263
|
+
/**
|
|
264
|
+
* Client-generated correlation ID echoed back in the `pong` event.
|
|
265
|
+
*/
|
|
266
|
+
requestId?: string;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Data payload carried in the `pong` event.
|
|
270
|
+
*/
|
|
271
|
+
export interface PongResponse {
|
|
272
|
+
/**
|
|
273
|
+
* Server-side Unix epoch milliseconds when the pong was sent.
|
|
274
|
+
*/
|
|
275
|
+
timestamp: number;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Fields sent by the client to submit a message.
|
|
279
|
+
*/
|
|
280
|
+
export interface SendMessageRequest {
|
|
281
|
+
/**
|
|
282
|
+
* Action discriminator.
|
|
283
|
+
*/
|
|
284
|
+
action: 'send_message';
|
|
285
|
+
/**
|
|
286
|
+
* Client-generated correlation ID echoed back on all related events.
|
|
287
|
+
*/
|
|
288
|
+
requestId?: string;
|
|
289
|
+
/**
|
|
290
|
+
* Session ID returned by `create_conversation_session`.
|
|
291
|
+
*/
|
|
292
|
+
sessionId: string;
|
|
293
|
+
/**
|
|
294
|
+
* The user's message text. Between 1 and 10 000 characters.
|
|
295
|
+
*/
|
|
296
|
+
message: string;
|
|
297
|
+
/**
|
|
298
|
+
* Whether to receive incremental `stream_chunk` and `stream_token` events. Defaults to `true`. Set to `false` to receive only the final `eventual_response`.
|
|
299
|
+
*/
|
|
300
|
+
stream?: boolean;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Data payload carried in the terminal `eventual_response` event for this action. Also see `GeneralAgentResponse` for the structured response shape.
|
|
304
|
+
*/
|
|
305
|
+
export interface SendMessageResponse {
|
|
306
|
+
/**
|
|
307
|
+
* ID of the agent's response message as persisted to the database.
|
|
308
|
+
*/
|
|
309
|
+
messageId: string;
|
|
310
|
+
response: GeneralAgentResponse;
|
|
311
|
+
/**
|
|
312
|
+
* True if the agent flagged this turn for human escalation.
|
|
313
|
+
*/
|
|
314
|
+
needsEscalation: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Human-readable reason when `needsEscalation` is true.
|
|
317
|
+
*/
|
|
318
|
+
escalationReason?: string;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Structured agent response.
|
|
322
|
+
*/
|
|
323
|
+
export interface GeneralAgentResponse {
|
|
324
|
+
/**
|
|
325
|
+
* Ordered text segments that together form the agent's reply. Clients may join them or render each separately.
|
|
326
|
+
*/
|
|
327
|
+
responseParts: string[];
|
|
328
|
+
/**
|
|
329
|
+
* Estimated customer happiness for this turn (0 = very unhappy, 1 = very happy).
|
|
330
|
+
*/
|
|
331
|
+
customerHappinessScore: number;
|
|
332
|
+
/**
|
|
333
|
+
* Estimated degree to which the customer's needs were met (0 = not met, 1 = fully met).
|
|
334
|
+
*/
|
|
335
|
+
needsSatisfactionScore: number;
|
|
336
|
+
/**
|
|
337
|
+
* One-sentence summary of what the user requested.
|
|
338
|
+
*/
|
|
339
|
+
requestSummary: string;
|
|
340
|
+
/**
|
|
341
|
+
* The agent's assessment of where the conversation stands after this turn.
|
|
342
|
+
*/
|
|
343
|
+
resolutionStatus: 'resolved' | 'in_progress' | 'requires_escalation' | 'needs_more_info' | 'blocked';
|
|
344
|
+
/**
|
|
345
|
+
* Ordered list of suggested follow-up actions the client UI may surface to the user.
|
|
346
|
+
*/
|
|
347
|
+
suggestedNextActions: string[];
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Fields sent by the client to submit an OTP code.
|
|
351
|
+
*/
|
|
352
|
+
export interface VerifyOtpRequest {
|
|
353
|
+
/**
|
|
354
|
+
* Action discriminator.
|
|
355
|
+
*/
|
|
356
|
+
action: 'verify_otp';
|
|
357
|
+
/**
|
|
358
|
+
* Must match the `requestId` from the `otp_verification_required` event being responded to.
|
|
359
|
+
*/
|
|
360
|
+
requestId: string;
|
|
361
|
+
/**
|
|
362
|
+
* Session ID of the paused session.
|
|
363
|
+
*/
|
|
364
|
+
sessionId: string;
|
|
365
|
+
/**
|
|
366
|
+
* The one-time password code entered by the user.
|
|
367
|
+
*/
|
|
368
|
+
code: string;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* No dedicated response — outcome signalled by `otp_verified` or `otp_invalid` events.
|
|
372
|
+
*/
|
|
373
|
+
export interface VerifyOtpResponse {
|
|
374
|
+
[k: string]: unknown;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* A point-in-time snapshot of a smooth-operator agent's state. Checkpoints are written by the agent runtime and are used to resume execution after interruptions (Lambda cold starts, HITL pauses, network errors). Corresponds to the `Checkpoint` struct in the smooth-operator Rust crate.
|
|
378
|
+
*/
|
|
379
|
+
export interface Checkpoint {
|
|
380
|
+
/**
|
|
381
|
+
* Unique checkpoint identifier (UUID v4).
|
|
382
|
+
*/
|
|
383
|
+
id: string;
|
|
384
|
+
/**
|
|
385
|
+
* smooth-operator workflow thread identifier this checkpoint belongs to. Matches `Session.threadId` for the associated session.
|
|
386
|
+
*/
|
|
387
|
+
threadId: string;
|
|
388
|
+
/**
|
|
389
|
+
* The agent whose state is captured in this checkpoint.
|
|
390
|
+
*/
|
|
391
|
+
agentId: string;
|
|
392
|
+
/**
|
|
393
|
+
* Agent loop iteration counter at the time the checkpoint was taken.
|
|
394
|
+
*/
|
|
395
|
+
iteration: number;
|
|
396
|
+
/**
|
|
397
|
+
* Arbitrary string key/value metadata attached to this checkpoint (e.g. phase name, bead ID).
|
|
398
|
+
*/
|
|
399
|
+
metadata?: {
|
|
400
|
+
[k: string]: string;
|
|
401
|
+
};
|
|
402
|
+
/**
|
|
403
|
+
* ISO 8601 timestamp when the checkpoint was created.
|
|
404
|
+
*/
|
|
405
|
+
createdAt: string;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* A source the agent used to ground its answer. Each citation points back at one retrieved knowledge-base document — the chunk the model read, plus enough metadata to render an attribution link. Citations are collected by the runtime from the documents that actually grounded a turn (the auto-injected `[Relevant knowledge]` context and any `knowledge_search` tool results) and attached to the terminal `eventual_response`. For GitHub-sourced documents `url` is the blob/issue URL; documents without a web source omit it.
|
|
409
|
+
*/
|
|
410
|
+
export interface Citation {
|
|
411
|
+
/**
|
|
412
|
+
* Stable identifier of the cited source document (the knowledge-base `document_id`). Used to deduplicate citations within a turn.
|
|
413
|
+
*/
|
|
414
|
+
id: string;
|
|
415
|
+
/**
|
|
416
|
+
* Human-readable label for the source — typically the document's source path or, for web-sourced docs, the URL/title.
|
|
417
|
+
*/
|
|
418
|
+
title: string;
|
|
419
|
+
/**
|
|
420
|
+
* Canonical link to the source, when one exists. For GitHub-sourced documents this is the blob/issue URL stamped onto the document's `source` at ingest (see CONNECTORS.md). Absent for sources with no web location (e.g. uploaded files).
|
|
421
|
+
*/
|
|
422
|
+
url?: string;
|
|
423
|
+
/**
|
|
424
|
+
* The retrieved chunk text that grounded the answer, truncated to a bounded length for display.
|
|
425
|
+
*/
|
|
426
|
+
snippet: string;
|
|
427
|
+
/**
|
|
428
|
+
* Relevance score of this source for the turn's query (the knowledge-base similarity score). Higher is more relevant.
|
|
429
|
+
*/
|
|
430
|
+
score: number;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* A conversation thread between participants (users, AI agents, or human agents). Corresponds to a row in the `conversations` table. Platform indicates the channel on which the conversation takes place.
|
|
434
|
+
*/
|
|
435
|
+
export interface Conversation {
|
|
436
|
+
/**
|
|
437
|
+
* Unique conversation identifier.
|
|
438
|
+
*/
|
|
439
|
+
id: string;
|
|
440
|
+
/**
|
|
441
|
+
* The channel on which this conversation takes place.
|
|
442
|
+
*/
|
|
443
|
+
platform: 'web' | 'messenger' | 'instagram' | 'email' | 'discord' | 'phone' | 'sms' | 'slack' | 'whatsapp' | 'tiktok';
|
|
444
|
+
/**
|
|
445
|
+
* Human-readable display name for the conversation.
|
|
446
|
+
*/
|
|
447
|
+
name: string;
|
|
448
|
+
/**
|
|
449
|
+
* The organization that owns this conversation.
|
|
450
|
+
*/
|
|
451
|
+
organizationId: string;
|
|
452
|
+
/**
|
|
453
|
+
* Client-provided key that prevents duplicate conversations from being created for the same logical thread.
|
|
454
|
+
*/
|
|
455
|
+
idempotencyKey: string;
|
|
456
|
+
/**
|
|
457
|
+
* Arbitrary key/value metadata attached to the conversation (e.g. campaign source, CRM fields).
|
|
458
|
+
*/
|
|
459
|
+
metadataJson?: {
|
|
460
|
+
[k: string]: unknown;
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* Analytics and scoring data aggregated from messages in this conversation.
|
|
464
|
+
*/
|
|
465
|
+
analyticsJson?: {
|
|
466
|
+
[k: string]: unknown;
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* ISO 8601 timestamp when the conversation was created.
|
|
470
|
+
*/
|
|
471
|
+
createdAt: string;
|
|
472
|
+
/**
|
|
473
|
+
* ISO 8601 timestamp when the conversation was last updated.
|
|
474
|
+
*/
|
|
475
|
+
updatedAt: string;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* A single message within a conversation. Direction is from the conversation's perspective: `inbound` = arriving from the user/external party; `outbound` = sent by the agent or platform. Corresponds to a row in the `conversation_messages` table.
|
|
479
|
+
*/
|
|
480
|
+
export interface Message {
|
|
481
|
+
/**
|
|
482
|
+
* Unique message identifier.
|
|
483
|
+
*/
|
|
484
|
+
id: string;
|
|
485
|
+
/**
|
|
486
|
+
* ID assigned by an external platform (e.g. a Twilio SID or Messenger message id).
|
|
487
|
+
*/
|
|
488
|
+
externalId?: string | null;
|
|
489
|
+
/**
|
|
490
|
+
* The organization that owns this message.
|
|
491
|
+
*/
|
|
492
|
+
organizationId?: string | null;
|
|
493
|
+
/**
|
|
494
|
+
* The conversation this message belongs to.
|
|
495
|
+
*/
|
|
496
|
+
conversationId?: string | null;
|
|
497
|
+
/**
|
|
498
|
+
* Message direction relative to the platform: `inbound` = from user/external, `outbound` = from agent/platform.
|
|
499
|
+
*/
|
|
500
|
+
direction: 'inbound' | 'outbound';
|
|
501
|
+
content: MessageContent;
|
|
502
|
+
/**
|
|
503
|
+
* Abbreviated sender descriptor (wire shape used in API responses; full participant data lives in domain/participant.schema.json).
|
|
504
|
+
*/
|
|
505
|
+
from?: {
|
|
506
|
+
/**
|
|
507
|
+
* Participant ID of the sender.
|
|
508
|
+
*/
|
|
509
|
+
id: string;
|
|
510
|
+
/**
|
|
511
|
+
* Participant type of the sender.
|
|
512
|
+
*/
|
|
513
|
+
type: string;
|
|
514
|
+
/**
|
|
515
|
+
* Display name of the sender.
|
|
516
|
+
*/
|
|
517
|
+
name?: string | null;
|
|
518
|
+
} | null;
|
|
519
|
+
/**
|
|
520
|
+
* Abbreviated recipient descriptor.
|
|
521
|
+
*/
|
|
522
|
+
to?: {
|
|
523
|
+
/**
|
|
524
|
+
* Participant ID of the recipient.
|
|
525
|
+
*/
|
|
526
|
+
id: string;
|
|
527
|
+
/**
|
|
528
|
+
* Participant type of the recipient.
|
|
529
|
+
*/
|
|
530
|
+
type: string;
|
|
531
|
+
/**
|
|
532
|
+
* Display name of the recipient.
|
|
533
|
+
*/
|
|
534
|
+
name?: string | null;
|
|
535
|
+
} | null;
|
|
536
|
+
/**
|
|
537
|
+
* Arbitrary key/value metadata attached to this message.
|
|
538
|
+
*/
|
|
539
|
+
metadataJson?: {
|
|
540
|
+
[k: string]: unknown;
|
|
541
|
+
} | null;
|
|
542
|
+
/**
|
|
543
|
+
* Analytics data associated with this message (e.g. sentiment scores, token counts).
|
|
544
|
+
*/
|
|
545
|
+
analyticsJson?: {
|
|
546
|
+
[k: string]: unknown;
|
|
547
|
+
} | null;
|
|
548
|
+
/**
|
|
549
|
+
* ISO 8601 timestamp when the message was created.
|
|
550
|
+
*/
|
|
551
|
+
createdAt: string;
|
|
552
|
+
/**
|
|
553
|
+
* ISO 8601 timestamp when the message was last updated.
|
|
554
|
+
*/
|
|
555
|
+
updatedAt?: string | null;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* The message payload.
|
|
559
|
+
*/
|
|
560
|
+
export interface MessageContent {
|
|
561
|
+
/**
|
|
562
|
+
* Ordered list of content items that make up this message.
|
|
563
|
+
*/
|
|
564
|
+
items?: ContentItem[];
|
|
565
|
+
/**
|
|
566
|
+
* Convenience flat-text representation of the message (populated for simple text-only messages).
|
|
567
|
+
*/
|
|
568
|
+
text?: string | null;
|
|
569
|
+
/**
|
|
570
|
+
* Structured agent response payload. Shape varies by agent template.
|
|
571
|
+
*/
|
|
572
|
+
structuredResponse?: {
|
|
573
|
+
[k: string]: unknown;
|
|
574
|
+
} | null;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* A single content element within a message. Currently only `text` items are defined; additional types (image, file, tool_result) may be added in future protocol versions.
|
|
578
|
+
*/
|
|
579
|
+
export interface ContentItem {
|
|
580
|
+
/**
|
|
581
|
+
* Content item type discriminator.
|
|
582
|
+
*/
|
|
583
|
+
type: 'text';
|
|
584
|
+
/**
|
|
585
|
+
* The text content (required when type = `text`).
|
|
586
|
+
*/
|
|
587
|
+
text?: string;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* A participant in a conversation. Participants may be end users, AI agents, or human support agents. Corresponds to a row in the `conversation_participants` table.
|
|
591
|
+
*/
|
|
592
|
+
export interface Participant {
|
|
593
|
+
/**
|
|
594
|
+
* Unique participant identifier.
|
|
595
|
+
*/
|
|
596
|
+
id: string;
|
|
597
|
+
/**
|
|
598
|
+
* The conversation this participant belongs to.
|
|
599
|
+
*/
|
|
600
|
+
conversationId: string;
|
|
601
|
+
/**
|
|
602
|
+
* The organization that owns this participant record.
|
|
603
|
+
*/
|
|
604
|
+
organizationId: string;
|
|
605
|
+
/**
|
|
606
|
+
* Participant role: `user` = end-user, `ai-agent` = smooth-operator agent, `human-agent` = live support agent.
|
|
607
|
+
*/
|
|
608
|
+
type: 'user' | 'ai-agent' | 'human-agent';
|
|
609
|
+
/**
|
|
610
|
+
* External identity (e.g. Supabase auth user UUID) for authenticated participants.
|
|
611
|
+
*/
|
|
612
|
+
externalId?: string | null;
|
|
613
|
+
/**
|
|
614
|
+
* Internal system identifier (e.g. agent UUID from the agents table).
|
|
615
|
+
*/
|
|
616
|
+
internalId?: string | null;
|
|
617
|
+
/**
|
|
618
|
+
* Browser fingerprint (ThumbmarkJS) for anonymous user identification.
|
|
619
|
+
*/
|
|
620
|
+
browserFingerprint?: string | null;
|
|
621
|
+
/**
|
|
622
|
+
* Parsed browser / device metadata collected at session start.
|
|
623
|
+
*/
|
|
624
|
+
browserInfo?: {
|
|
625
|
+
[k: string]: unknown;
|
|
626
|
+
} | null;
|
|
627
|
+
/**
|
|
628
|
+
* Display name for this participant.
|
|
629
|
+
*/
|
|
630
|
+
name: string;
|
|
631
|
+
/**
|
|
632
|
+
* Email address if known.
|
|
633
|
+
*/
|
|
634
|
+
email?: string | null;
|
|
635
|
+
/**
|
|
636
|
+
* Phone number in E.164 format if known.
|
|
637
|
+
*/
|
|
638
|
+
phone?: string | null;
|
|
639
|
+
/**
|
|
640
|
+
* Foreign key into the CRM contacts table if this participant has been matched.
|
|
641
|
+
*/
|
|
642
|
+
crmContactId?: string | null;
|
|
643
|
+
/**
|
|
644
|
+
* Arbitrary key/value metadata attached to this participant.
|
|
645
|
+
*/
|
|
646
|
+
metadataJson?: {
|
|
647
|
+
[k: string]: unknown;
|
|
648
|
+
};
|
|
649
|
+
/**
|
|
650
|
+
* ISO 8601 timestamp when the participant record was created.
|
|
651
|
+
*/
|
|
652
|
+
createdAt: string;
|
|
653
|
+
/**
|
|
654
|
+
* ISO 8601 timestamp when the participant record was last updated.
|
|
655
|
+
*/
|
|
656
|
+
updatedAt: string;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* An AI conversation session. Ties together a conversation, an agent, the user and agent participants, and the smooth-operator workflow thread. Corresponds to a row in the `conversation_sessions` table. The `threadId` field is the smooth-operator thread identifier (stored as `langgraph_thread_id` in the DB for historical reasons; renamed to `threadId` in the protocol).
|
|
660
|
+
*/
|
|
661
|
+
export interface Session {
|
|
662
|
+
/**
|
|
663
|
+
* Unique session identifier.
|
|
664
|
+
*/
|
|
665
|
+
sessionId: string;
|
|
666
|
+
/**
|
|
667
|
+
* The conversation this session is attached to.
|
|
668
|
+
*/
|
|
669
|
+
conversationId: string;
|
|
670
|
+
/**
|
|
671
|
+
* The agent handling this session.
|
|
672
|
+
*/
|
|
673
|
+
agentId: string;
|
|
674
|
+
/**
|
|
675
|
+
* Human-readable display name of the agent.
|
|
676
|
+
*/
|
|
677
|
+
agentName: string;
|
|
678
|
+
/**
|
|
679
|
+
* The participant record representing the end user in this session.
|
|
680
|
+
*/
|
|
681
|
+
userParticipantId: string;
|
|
682
|
+
/**
|
|
683
|
+
* The participant record representing the AI agent in this session.
|
|
684
|
+
*/
|
|
685
|
+
agentParticipantId: string;
|
|
686
|
+
/**
|
|
687
|
+
* smooth-operator workflow thread identifier. Used to resume agent state across turns and process restarts. Stored as `langgraph_thread_id` in the database for historical reasons.
|
|
688
|
+
*/
|
|
689
|
+
threadId: string;
|
|
690
|
+
/**
|
|
691
|
+
* Lifecycle status of the session.
|
|
692
|
+
*/
|
|
693
|
+
status?: 'active' | 'idle' | 'ended';
|
|
694
|
+
/**
|
|
695
|
+
* Cumulative token count consumed in this session.
|
|
696
|
+
*/
|
|
697
|
+
tokenCount?: number;
|
|
698
|
+
/**
|
|
699
|
+
* Number of messages exchanged in this session.
|
|
700
|
+
*/
|
|
701
|
+
messageCount?: number;
|
|
702
|
+
/**
|
|
703
|
+
* Arbitrary key/value metadata attached to this session (e.g. browser info, campaign source).
|
|
704
|
+
*/
|
|
705
|
+
metadata?: {
|
|
706
|
+
[k: string]: unknown;
|
|
707
|
+
};
|
|
708
|
+
/**
|
|
709
|
+
* ISO 8601 timestamp when the session was created.
|
|
710
|
+
*/
|
|
711
|
+
createdAt?: string;
|
|
712
|
+
/**
|
|
713
|
+
* ISO 8601 timestamp when the session was last updated.
|
|
714
|
+
*/
|
|
715
|
+
updatedAt?: string;
|
|
716
|
+
/**
|
|
717
|
+
* ISO 8601 timestamp when the session ended, or null if still active.
|
|
718
|
+
*/
|
|
719
|
+
endedAt?: string | null;
|
|
720
|
+
/**
|
|
721
|
+
* ISO 8601 timestamp of the most recent activity (message, keepalive, etc.).
|
|
722
|
+
*/
|
|
723
|
+
lastActivityAt?: string;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* A structured error descriptor. Used in error events and nested inside event data payloads.
|
|
727
|
+
*/
|
|
728
|
+
export interface ErrorObject {
|
|
729
|
+
/**
|
|
730
|
+
* Machine-readable error code (e.g. `SESSION_NOT_FOUND`, `RATE_LIMITED`, `VALIDATION_ERROR`).
|
|
731
|
+
*/
|
|
732
|
+
code: string;
|
|
733
|
+
/**
|
|
734
|
+
* Human-readable error description.
|
|
735
|
+
*/
|
|
736
|
+
message: string;
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Base shape for every client-to-server WebSocket frame. The `action` field is a snake_case verb that selects the handler. `requestId` is chosen by the client and echoed back on all related server events so the client can correlate responses to pending requests.
|
|
740
|
+
*/
|
|
741
|
+
export interface ActionEnvelope {
|
|
742
|
+
/**
|
|
743
|
+
* The action to perform.
|
|
744
|
+
*/
|
|
745
|
+
action: 'create_conversation_session' | 'send_message' | 'get_session' | 'get_conversation_messages' | 'confirm_tool_action' | 'verify_otp' | 'ping';
|
|
746
|
+
/**
|
|
747
|
+
* Client-generated correlation ID. Will be echoed back on all related server events. Should be unique per in-flight request. If omitted the server may generate one, but correlating responses becomes the client's problem.
|
|
748
|
+
*/
|
|
749
|
+
requestId?: string;
|
|
750
|
+
[k: string]: unknown;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Event: `error`. Emitted when an unrecoverable error occurs during request processing. The nested `error` object shape (`{ code, message }`) is preserved for wire compatibility with clients that destructure `message.error.code`. `details` carries additional structured context when available.
|
|
754
|
+
*/
|
|
755
|
+
export interface Error {
|
|
756
|
+
/**
|
|
757
|
+
* Event type discriminator.
|
|
758
|
+
*/
|
|
759
|
+
type: 'error';
|
|
760
|
+
/**
|
|
761
|
+
* Echoes the `requestId` from the originating action, if applicable. Absent for server-initiated errors with no associated request.
|
|
762
|
+
*/
|
|
763
|
+
requestId?: string;
|
|
764
|
+
/**
|
|
765
|
+
* Top-level error object (duplicate of `data.error`; kept for clients that pattern-match on the envelope-level `error` field).
|
|
766
|
+
*/
|
|
767
|
+
error?: {
|
|
768
|
+
/**
|
|
769
|
+
* Machine-readable error code.
|
|
770
|
+
*/
|
|
771
|
+
code: string;
|
|
772
|
+
/**
|
|
773
|
+
* Human-readable error description.
|
|
774
|
+
*/
|
|
775
|
+
message: string;
|
|
776
|
+
};
|
|
777
|
+
/**
|
|
778
|
+
* Full error payload.
|
|
779
|
+
*/
|
|
780
|
+
data: {
|
|
781
|
+
/**
|
|
782
|
+
* The request ID this error belongs to, if any.
|
|
783
|
+
*/
|
|
784
|
+
requestId?: string;
|
|
785
|
+
/**
|
|
786
|
+
* The error descriptor (nested for wire backward-compatibility).
|
|
787
|
+
*/
|
|
788
|
+
error: {
|
|
789
|
+
/**
|
|
790
|
+
* Machine-readable error code (e.g. `SESSION_NOT_FOUND`, `RATE_LIMITED`, `VALIDATION_ERROR`, `INTERNAL_ERROR`).
|
|
791
|
+
*/
|
|
792
|
+
code: string;
|
|
793
|
+
/**
|
|
794
|
+
* Human-readable error description.
|
|
795
|
+
*/
|
|
796
|
+
message: string;
|
|
797
|
+
};
|
|
798
|
+
/**
|
|
799
|
+
* Optional additional structured error context (e.g. validation issues, partial results).
|
|
800
|
+
*/
|
|
801
|
+
details?: {} | unknown[] | string | number | boolean | null;
|
|
802
|
+
};
|
|
803
|
+
/**
|
|
804
|
+
* Unix epoch milliseconds when the event was emitted.
|
|
805
|
+
*/
|
|
806
|
+
timestamp?: number;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Event: `eventual_response`. The terminal event of a streaming turn. Emitted after the agent workflow completes and its output has been persisted. Clients should treat this as the authoritative final state for the turn and may discard intermediate `stream_chunk` / `stream_token` data. Status is always 200 on success.
|
|
810
|
+
*/
|
|
811
|
+
export interface EventualResponse {
|
|
812
|
+
/**
|
|
813
|
+
* Event type discriminator.
|
|
814
|
+
*/
|
|
815
|
+
type: 'eventual_response';
|
|
816
|
+
/**
|
|
817
|
+
* Echoes the `requestId` from the originating `send_message` action.
|
|
818
|
+
*/
|
|
819
|
+
requestId?: string;
|
|
820
|
+
/**
|
|
821
|
+
* HTTP-like status. Always 200 for a successful eventual response.
|
|
822
|
+
*/
|
|
823
|
+
status?: number;
|
|
824
|
+
/**
|
|
825
|
+
* The terminal response payload.
|
|
826
|
+
*/
|
|
827
|
+
data: {
|
|
828
|
+
/**
|
|
829
|
+
* The request ID this response belongs to.
|
|
830
|
+
*/
|
|
831
|
+
requestId: string;
|
|
832
|
+
/**
|
|
833
|
+
* HTTP-like status. Typically 200.
|
|
834
|
+
*/
|
|
835
|
+
status: number;
|
|
836
|
+
/**
|
|
837
|
+
* The final agent output.
|
|
838
|
+
*/
|
|
839
|
+
data: {
|
|
840
|
+
/**
|
|
841
|
+
* ID of the agent message as persisted to the `conversation_messages` table.
|
|
842
|
+
*/
|
|
843
|
+
messageId: string;
|
|
844
|
+
/**
|
|
845
|
+
* The structured agent response payload. Shape depends on the agent template. Clients should validate against a template-specific schema before rendering.
|
|
846
|
+
*/
|
|
847
|
+
response: {} | unknown[] | string | number | boolean | null;
|
|
848
|
+
/**
|
|
849
|
+
* True if the agent flagged this conversation for human escalation.
|
|
850
|
+
*/
|
|
851
|
+
needsEscalation?: boolean;
|
|
852
|
+
/**
|
|
853
|
+
* Human-readable escalation reason when `needsEscalation` is true.
|
|
854
|
+
*/
|
|
855
|
+
escalationReason?: string;
|
|
856
|
+
/**
|
|
857
|
+
* The sources that grounded this answer, when any were retrieved. Collected by the runtime from the documents that actually grounded the turn — the auto-injected `[Relevant knowledge]` context and any `knowledge_search` tool results — deduplicated by source id and capped. Optional and back-compatible: absent when the turn used no knowledge sources. Each item is a `Citation` (see `domain/citation.schema.json`).
|
|
858
|
+
*/
|
|
859
|
+
citations?: {
|
|
860
|
+
/**
|
|
861
|
+
* Stable identifier of the cited source document (the knowledge-base `document_id`). Used to deduplicate citations within a turn.
|
|
862
|
+
*/
|
|
863
|
+
id: string;
|
|
864
|
+
/**
|
|
865
|
+
* Human-readable label for the source — typically the document's source path or, for web-sourced docs, the URL/title.
|
|
866
|
+
*/
|
|
867
|
+
title: string;
|
|
868
|
+
/**
|
|
869
|
+
* Canonical link to the source, when one exists. For GitHub-sourced documents this is the blob/issue URL stamped onto the document's `source` at ingest. Absent for sources with no web location.
|
|
870
|
+
*/
|
|
871
|
+
url?: string;
|
|
872
|
+
/**
|
|
873
|
+
* The retrieved chunk text that grounded the answer, truncated to a bounded length for display.
|
|
874
|
+
*/
|
|
875
|
+
snippet: string;
|
|
876
|
+
/**
|
|
877
|
+
* Relevance score of this source for the turn's query (the knowledge-base similarity score). Higher is more relevant.
|
|
878
|
+
*/
|
|
879
|
+
score: number;
|
|
880
|
+
}[];
|
|
881
|
+
};
|
|
882
|
+
};
|
|
883
|
+
/**
|
|
884
|
+
* Unix epoch milliseconds when the event was emitted.
|
|
885
|
+
*/
|
|
886
|
+
timestamp?: number;
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Event: `immediate_response`. Sent by the server synchronously upon receiving any action, to acknowledge that the request was accepted and processing has begun. For streaming actions (`send_message`) this always precedes `stream_chunk` / `stream_token` events and the final `eventual_response`. For non-streaming actions (e.g. `get_session`, `create_conversation_session`) this also carries the complete response payload in `data`.
|
|
890
|
+
*/
|
|
891
|
+
export interface ImmediateResponse {
|
|
892
|
+
/**
|
|
893
|
+
* Event type discriminator.
|
|
894
|
+
*/
|
|
895
|
+
type: 'immediate_response';
|
|
896
|
+
/**
|
|
897
|
+
* Echoes the `requestId` from the originating action.
|
|
898
|
+
*/
|
|
899
|
+
requestId?: string;
|
|
900
|
+
/**
|
|
901
|
+
* HTTP-like status. 202 = accepted and processing; 200 = synchronous success (non-streaming responses).
|
|
902
|
+
*/
|
|
903
|
+
status?: number;
|
|
904
|
+
/**
|
|
905
|
+
* Human-readable status description (e.g. `Processing your request...`).
|
|
906
|
+
*/
|
|
907
|
+
message?: string;
|
|
908
|
+
/**
|
|
909
|
+
* Action-specific response payload. For `create_conversation_session` and `get_session`, this is the session descriptor. For `get_conversation_messages`, this is the message page. For streaming `send_message`, this is typically empty or contains only a minimal ack.
|
|
910
|
+
*/
|
|
911
|
+
data: {
|
|
912
|
+
[k: string]: unknown;
|
|
913
|
+
};
|
|
914
|
+
/**
|
|
915
|
+
* Unix epoch milliseconds when the event was emitted.
|
|
916
|
+
*/
|
|
917
|
+
timestamp?: number;
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Event: `keepalive`. Sent periodically by the server during long-running agent turns (typically every 30 seconds) to prevent AWS API Gateway's 10-minute idle connection timeout from closing the WebSocket while the backend is still computing. Clients should acknowledge receipt by updating their last-seen timestamp, but no reply action is needed. Distinct from `ping`/`pong` which are client-initiated.
|
|
921
|
+
*/
|
|
922
|
+
export interface Keepalive {
|
|
923
|
+
/**
|
|
924
|
+
* Event type discriminator.
|
|
925
|
+
*/
|
|
926
|
+
type: 'keepalive';
|
|
927
|
+
/**
|
|
928
|
+
* The `requestId` of the in-flight request this keepalive is associated with.
|
|
929
|
+
*/
|
|
930
|
+
requestId?: string;
|
|
931
|
+
/**
|
|
932
|
+
* Keepalive payload.
|
|
933
|
+
*/
|
|
934
|
+
data: {
|
|
935
|
+
/**
|
|
936
|
+
* The request ID of the in-flight request this keepalive belongs to.
|
|
937
|
+
*/
|
|
938
|
+
requestId: string;
|
|
939
|
+
};
|
|
940
|
+
/**
|
|
941
|
+
* Unix epoch milliseconds when the keepalive was sent.
|
|
942
|
+
*/
|
|
943
|
+
timestamp?: number;
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Event: `otp_invalid`. Emitted when the caller's OTP attempt is rejected — wrong code, expired, max attempts reached, or record not found. When `attemptsRemaining` is 0 the session is locked; the client must restart the OTP flow. When greater than 0 the client may prompt the user to try again.
|
|
947
|
+
*/
|
|
948
|
+
export interface OtpInvalid {
|
|
949
|
+
/**
|
|
950
|
+
* Event type discriminator.
|
|
951
|
+
*/
|
|
952
|
+
type: 'otp_invalid';
|
|
953
|
+
/**
|
|
954
|
+
* Echoes the `requestId` from the originating `verify_otp` action.
|
|
955
|
+
*/
|
|
956
|
+
requestId?: string;
|
|
957
|
+
/**
|
|
958
|
+
* Failure details.
|
|
959
|
+
*/
|
|
960
|
+
data: {
|
|
961
|
+
/**
|
|
962
|
+
* The request ID this verification belongs to.
|
|
963
|
+
*/
|
|
964
|
+
requestId: string;
|
|
965
|
+
/**
|
|
966
|
+
* OTP invalid payload.
|
|
967
|
+
*/
|
|
968
|
+
data: {
|
|
969
|
+
/**
|
|
970
|
+
* Machine-readable failure reason. Absent if the server cannot determine a specific cause.
|
|
971
|
+
*/
|
|
972
|
+
error?: 'INVALID_CODE' | 'MAX_ATTEMPTS' | 'NOT_FOUND' | 'EXPIRED';
|
|
973
|
+
/**
|
|
974
|
+
* How many more attempts the caller has before the OTP is locked. Zero means the session is locked and a new OTP must be requested.
|
|
975
|
+
*/
|
|
976
|
+
attemptsRemaining: number;
|
|
977
|
+
/**
|
|
978
|
+
* Human-readable failure message suitable for display in the verification UI.
|
|
979
|
+
*/
|
|
980
|
+
message: string;
|
|
981
|
+
};
|
|
982
|
+
};
|
|
983
|
+
/**
|
|
984
|
+
* Unix epoch milliseconds when the event was emitted.
|
|
985
|
+
*/
|
|
986
|
+
timestamp?: number;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Event: `otp_sent`. Acknowledgement that an OTP code has been dispatched to the user via the chosen delivery channel. The client should update the UI to prompt the user to enter the code they received.
|
|
990
|
+
*/
|
|
991
|
+
export interface OtpSent {
|
|
992
|
+
/**
|
|
993
|
+
* Event type discriminator.
|
|
994
|
+
*/
|
|
995
|
+
type: 'otp_sent';
|
|
996
|
+
/**
|
|
997
|
+
* Echoes the `requestId` from the originating action.
|
|
998
|
+
*/
|
|
999
|
+
requestId?: string;
|
|
1000
|
+
/**
|
|
1001
|
+
* OTP send acknowledgement details.
|
|
1002
|
+
*/
|
|
1003
|
+
data: {
|
|
1004
|
+
/**
|
|
1005
|
+
* The request ID this OTP delivery belongs to.
|
|
1006
|
+
*/
|
|
1007
|
+
requestId: string;
|
|
1008
|
+
/**
|
|
1009
|
+
* Delivery details.
|
|
1010
|
+
*/
|
|
1011
|
+
data: {
|
|
1012
|
+
/**
|
|
1013
|
+
* The channel through which the OTP was delivered.
|
|
1014
|
+
*/
|
|
1015
|
+
channel: 'email' | 'sms';
|
|
1016
|
+
/**
|
|
1017
|
+
* Partially masked destination address for display in the UI (e.g. `j***@example.com` or `+1 ***-***-4567`). Sufficient for the user to recognize their own address without exposing it fully.
|
|
1018
|
+
*/
|
|
1019
|
+
maskedDestination: string;
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
1022
|
+
/**
|
|
1023
|
+
* Unix epoch milliseconds when the event was emitted.
|
|
1024
|
+
*/
|
|
1025
|
+
timestamp?: number;
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Event: `otp_verification_required`. Emitted when the agent workflow pauses because it needs the caller to complete OTP verification before proceeding with an authenticated action. Corresponds to smooth-operator's `AgentEvent::HumanInputRequired { Input }` for auth gates. The client should surface a channel-selection and OTP input UI. After the user selects a channel, the client may trigger OTP delivery via a separate flow; the `verify_otp` action submits the received code.
|
|
1029
|
+
*/
|
|
1030
|
+
export interface OtpVerificationRequired {
|
|
1031
|
+
/**
|
|
1032
|
+
* Event type discriminator.
|
|
1033
|
+
*/
|
|
1034
|
+
type: 'otp_verification_required';
|
|
1035
|
+
/**
|
|
1036
|
+
* Echoes the `requestId` from the originating `send_message` action. Must be included in the `verify_otp` reply.
|
|
1037
|
+
*/
|
|
1038
|
+
requestId?: string;
|
|
1039
|
+
/**
|
|
1040
|
+
* Verification prompt details.
|
|
1041
|
+
*/
|
|
1042
|
+
data: {
|
|
1043
|
+
/**
|
|
1044
|
+
* The request ID this verification belongs to.
|
|
1045
|
+
*/
|
|
1046
|
+
requestId: string;
|
|
1047
|
+
/**
|
|
1048
|
+
* Details about the authentication requirement.
|
|
1049
|
+
*/
|
|
1050
|
+
data: {
|
|
1051
|
+
/**
|
|
1052
|
+
* Opaque identifier of the tool invocation awaiting verification.
|
|
1053
|
+
*/
|
|
1054
|
+
toolId: string;
|
|
1055
|
+
/**
|
|
1056
|
+
* Human-readable description of the action requiring verification, suitable for the consent UI.
|
|
1057
|
+
*/
|
|
1058
|
+
actionDescription: string;
|
|
1059
|
+
/**
|
|
1060
|
+
* Delivery channels available to send the OTP. The client should let the user choose.
|
|
1061
|
+
*
|
|
1062
|
+
* @minItems 1
|
|
1063
|
+
*/
|
|
1064
|
+
availableChannels: ['email' | 'sms', ...('email' | 'sms')[]];
|
|
1065
|
+
/**
|
|
1066
|
+
* Required authentication level. Common values: `email`, `sms`, `mfa`, `end_user`, `admin`.
|
|
1067
|
+
*/
|
|
1068
|
+
authLevel: string;
|
|
1069
|
+
};
|
|
1070
|
+
};
|
|
1071
|
+
/**
|
|
1072
|
+
* Unix epoch milliseconds when the event was emitted.
|
|
1073
|
+
*/
|
|
1074
|
+
timestamp?: number;
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Event: `otp_verified`. Emitted when the caller's OTP attempt succeeds, or when a pre-auth HMAC makes OTP unnecessary. The session is now authenticated at the required level and the paused agent workflow resumes. A streaming sequence (`stream_chunk` / `stream_token` → `eventual_response`) follows.
|
|
1078
|
+
*/
|
|
1079
|
+
export interface OtpVerified {
|
|
1080
|
+
/**
|
|
1081
|
+
* Event type discriminator.
|
|
1082
|
+
*/
|
|
1083
|
+
type: 'otp_verified';
|
|
1084
|
+
/**
|
|
1085
|
+
* Echoes the `requestId` from the originating `verify_otp` action.
|
|
1086
|
+
*/
|
|
1087
|
+
requestId?: string;
|
|
1088
|
+
/**
|
|
1089
|
+
* Verification success details.
|
|
1090
|
+
*/
|
|
1091
|
+
data: {
|
|
1092
|
+
/**
|
|
1093
|
+
* The request ID this verification belongs to.
|
|
1094
|
+
*/
|
|
1095
|
+
requestId: string;
|
|
1096
|
+
/**
|
|
1097
|
+
* Success payload.
|
|
1098
|
+
*/
|
|
1099
|
+
data: {
|
|
1100
|
+
/**
|
|
1101
|
+
* Short human-readable confirmation message (e.g. `Identity verified successfully.`).
|
|
1102
|
+
*/
|
|
1103
|
+
message: string;
|
|
1104
|
+
};
|
|
1105
|
+
};
|
|
1106
|
+
/**
|
|
1107
|
+
* Unix epoch milliseconds when the event was emitted.
|
|
1108
|
+
*/
|
|
1109
|
+
timestamp?: number;
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* Event: `pong`. The server's reply to a `ping` action. Carries the server's current Unix epoch timestamp in milliseconds. Clients use the round-trip time to detect zombie connections.
|
|
1113
|
+
*/
|
|
1114
|
+
export interface Pong {
|
|
1115
|
+
/**
|
|
1116
|
+
* Event type discriminator.
|
|
1117
|
+
*/
|
|
1118
|
+
type: 'pong';
|
|
1119
|
+
/**
|
|
1120
|
+
* Echoes the `requestId` from the originating `ping` action.
|
|
1121
|
+
*/
|
|
1122
|
+
requestId?: string;
|
|
1123
|
+
/**
|
|
1124
|
+
* Server-side Unix epoch milliseconds when the pong was emitted.
|
|
1125
|
+
*/
|
|
1126
|
+
timestamp?: number;
|
|
1127
|
+
/**
|
|
1128
|
+
* Pong payload (mirrors top-level `timestamp` for clients that only inspect `data`).
|
|
1129
|
+
*/
|
|
1130
|
+
data?: {
|
|
1131
|
+
/**
|
|
1132
|
+
* Server-side Unix epoch milliseconds.
|
|
1133
|
+
*/
|
|
1134
|
+
timestamp: number;
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Event: `stream_chunk`. Emitted each time a node in the smooth-operator workflow completes. Carries the node name and a filtered state snapshot. Clients use this to show per-node progress (e.g. `knowledge_search completed`, tool activity) in an agent team view. Distinct from `stream_token` which carries raw token deltas; a `stream_chunk` typically fires once per node while multiple `stream_token` events may fire within a single node's LLM call.
|
|
1139
|
+
*/
|
|
1140
|
+
export interface StreamChunk {
|
|
1141
|
+
/**
|
|
1142
|
+
* Event type discriminator.
|
|
1143
|
+
*/
|
|
1144
|
+
type: 'stream_chunk';
|
|
1145
|
+
/**
|
|
1146
|
+
* Echoes the `requestId` from the originating `send_message` action.
|
|
1147
|
+
*/
|
|
1148
|
+
requestId?: string;
|
|
1149
|
+
/**
|
|
1150
|
+
* Name of the workflow node that just completed and produced this chunk.
|
|
1151
|
+
*/
|
|
1152
|
+
node?: string;
|
|
1153
|
+
/**
|
|
1154
|
+
* The per-node state snapshot.
|
|
1155
|
+
*/
|
|
1156
|
+
data: {
|
|
1157
|
+
/**
|
|
1158
|
+
* The request ID this chunk belongs to.
|
|
1159
|
+
*/
|
|
1160
|
+
requestId: string;
|
|
1161
|
+
/**
|
|
1162
|
+
* Name of the workflow node that produced this state snapshot.
|
|
1163
|
+
*/
|
|
1164
|
+
node: string;
|
|
1165
|
+
/**
|
|
1166
|
+
* Filtered subset of the node's output state exposed to the client. Only safe-to-expose fields are included; server-internal state is stripped.
|
|
1167
|
+
*/
|
|
1168
|
+
state: {
|
|
1169
|
+
/**
|
|
1170
|
+
* Unstructured LLM output from this node, if any.
|
|
1171
|
+
*/
|
|
1172
|
+
rawResponse?: {} | unknown[] | string | number | boolean | null;
|
|
1173
|
+
/**
|
|
1174
|
+
* Parsed structured response from this node, if any.
|
|
1175
|
+
*/
|
|
1176
|
+
structuredResponse?: {} | unknown[] | string | number | boolean | null;
|
|
1177
|
+
/**
|
|
1178
|
+
* Non-null when the workflow has paused awaiting user confirmation of a write operation. Clients should surface a confirmation UI.
|
|
1179
|
+
*/
|
|
1180
|
+
pendingWriteConfirmation?: {
|
|
1181
|
+
[k: string]: unknown;
|
|
1182
|
+
} | null;
|
|
1183
|
+
/**
|
|
1184
|
+
* Non-null when the workflow has paused awaiting OTP verification. Clients should surface an OTP input UI.
|
|
1185
|
+
*/
|
|
1186
|
+
pendingOtpVerification?: {
|
|
1187
|
+
[k: string]: unknown;
|
|
1188
|
+
} | null;
|
|
1189
|
+
};
|
|
1190
|
+
/**
|
|
1191
|
+
* Reserved for future use. When true, this is the last `stream_chunk` for the request. Currently clients should use `eventual_response` to detect stream completion.
|
|
1192
|
+
*/
|
|
1193
|
+
done?: boolean;
|
|
1194
|
+
};
|
|
1195
|
+
/**
|
|
1196
|
+
* Unix epoch milliseconds when the event was emitted.
|
|
1197
|
+
*/
|
|
1198
|
+
timestamp?: number;
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Event: `stream_token`. A single LLM output token forwarded to the client in real time. Corresponds to smooth-operator's `AgentEvent::TokenDelta`. Clients accumulate tokens to display a live typing animation. After the node finishes, a `stream_chunk` event carries the complete state snapshot for that node.
|
|
1202
|
+
*/
|
|
1203
|
+
export interface StreamToken {
|
|
1204
|
+
/**
|
|
1205
|
+
* Event type discriminator.
|
|
1206
|
+
*/
|
|
1207
|
+
type: 'stream_token';
|
|
1208
|
+
/**
|
|
1209
|
+
* Echoes the `requestId` from the originating `send_message` action.
|
|
1210
|
+
*/
|
|
1211
|
+
requestId?: string;
|
|
1212
|
+
/**
|
|
1213
|
+
* The raw token text. Also present inside `data.token` for consumers that only inspect `data`.
|
|
1214
|
+
*/
|
|
1215
|
+
token?: string;
|
|
1216
|
+
/**
|
|
1217
|
+
* Token event payload.
|
|
1218
|
+
*/
|
|
1219
|
+
data: {
|
|
1220
|
+
/**
|
|
1221
|
+
* The request ID this token belongs to.
|
|
1222
|
+
*/
|
|
1223
|
+
requestId: string;
|
|
1224
|
+
/**
|
|
1225
|
+
* The raw token text.
|
|
1226
|
+
*/
|
|
1227
|
+
token: string;
|
|
1228
|
+
};
|
|
1229
|
+
/**
|
|
1230
|
+
* Unix epoch milliseconds when the event was emitted.
|
|
1231
|
+
*/
|
|
1232
|
+
timestamp?: number;
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Event: `write_confirmation_required`. Emitted when the agent workflow pauses before running a state-mutating tool call that requires explicit user approval. Corresponds to smooth-operator's `AgentEvent::HumanInputRequired { Confirm }`. The client must surface a confirmation dialog and reply with a `confirm_tool_action` action using the same `requestId`. Until the client responds, the workflow remains paused.
|
|
1236
|
+
*/
|
|
1237
|
+
export interface WriteConfirmationRequired {
|
|
1238
|
+
/**
|
|
1239
|
+
* Event type discriminator.
|
|
1240
|
+
*/
|
|
1241
|
+
type: 'write_confirmation_required';
|
|
1242
|
+
/**
|
|
1243
|
+
* Echoes the `requestId` from the originating `send_message` action. Must be included in the `confirm_tool_action` reply.
|
|
1244
|
+
*/
|
|
1245
|
+
requestId?: string;
|
|
1246
|
+
/**
|
|
1247
|
+
* Confirmation prompt details.
|
|
1248
|
+
*/
|
|
1249
|
+
data: {
|
|
1250
|
+
/**
|
|
1251
|
+
* The request ID this confirmation belongs to.
|
|
1252
|
+
*/
|
|
1253
|
+
requestId: string;
|
|
1254
|
+
/**
|
|
1255
|
+
* Details about the pending write that the user must approve or reject.
|
|
1256
|
+
*/
|
|
1257
|
+
data: {
|
|
1258
|
+
/**
|
|
1259
|
+
* Opaque identifier of the tool invocation awaiting confirmation. Provided for correlation; clients do not need to parse or display this.
|
|
1260
|
+
*/
|
|
1261
|
+
toolId: string;
|
|
1262
|
+
/**
|
|
1263
|
+
* Human-readable description of the action the agent wants to perform, suitable for displaying in a confirmation dialog (e.g. `Delete contact John Doe (john@example.com)`).
|
|
1264
|
+
*/
|
|
1265
|
+
actionDescription: string;
|
|
1266
|
+
};
|
|
1267
|
+
};
|
|
1268
|
+
/**
|
|
1269
|
+
* Unix epoch milliseconds when the event was emitted.
|
|
1270
|
+
*/
|
|
1271
|
+
timestamp?: number;
|
|
1272
|
+
}
|
|
1273
|
+
//# sourceMappingURL=types.d.ts.map
|