@dbx-tools/appkit-mastra-shared 0.1.13 → 0.1.19

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.
@@ -0,0 +1,635 @@
1
+ /**
2
+ * Mastra-only surface for the Genie agent that
3
+ * `@dbx-tools/appkit-mastra` runs server-side.
4
+ *
5
+ * The pure Genie wire vocabulary (chat events, terminal-status
6
+ * helpers, attachment shapes) lives in `@dbx-tools/genie-shared`
7
+ * so anything that doesn't speak Mastra (browser bundles,
8
+ * headless renderers, non-Mastra clients) can import the protocol
9
+ * without dragging Mastra in. We re-export that surface from this
10
+ * module so downstream callers keep a single
11
+ * `@dbx-tools/appkit-mastra-shared` import.
12
+ *
13
+ * What lives here:
14
+ *
15
+ * - {@link MinimalWriter}: structural shape of `ctx.writer`,
16
+ * used by every Mastra tool that publishes Genie events.
17
+ * - {@link GenieAgentEvent}: lifecycle and chart events the
18
+ * Mastra Genie agent emits that are NOT on the Genie wire
19
+ * (`started`, `ask_genie_done`, `error`, `chart`). Same flat
20
+ * `{type, ...fields}` shape as the wire's
21
+ * {@link GenieChatEvent} so subscribers union both with one
22
+ * `switch (event.type)`.
23
+ * - {@link GenieWriterEvent}: the unified vocabulary the Genie
24
+ * agent writes through `ctx.writer`. Subscribers narrow on
25
+ * `type` and read the event's fields directly - no
26
+ * translation layer.
27
+ * - Workflow output shapes ({@link GenieDataset},
28
+ * {@link GenieDatasetChart}, {@link GenieSummaryItem},
29
+ * {@link GenieAgentResult}): structurally Mastra-only because
30
+ * the agent's two-step workflow (agent step + finalize step)
31
+ * embeds a chart-planner output (`dataset.chart`) and a mixed
32
+ * `(string | visualize)[]` summary that the Genie wire knows
33
+ * nothing about.
34
+ * - {@link genieResultToWriterEvents}: helper that replays the
35
+ * terminal `error` event from a completed
36
+ * {@link GenieAgentResult} (e.g. on history reload). Chart
37
+ * replay is intentionally not supported - the resolved
38
+ * Echarts spec is held off-band on the per-request
39
+ * `RequestContext`, not on the persisted summary.
40
+ *
41
+ * Pure types and small helpers; no Node-only imports, safe for
42
+ * browser bundles.
43
+ */
44
+ import { z } from "zod";
45
+ /**
46
+ * Minimal `ToolStream`-shaped writer the Genie agent and chart
47
+ * helpers publish events through. Defined here (vs imported from
48
+ * `@mastra/core`) so helpers in `@dbx-tools/appkit-mastra` can
49
+ * accept any object with a `.write` method without dragging
50
+ * Mastra's full `ToolStream` (and its agent / tool typings) into
51
+ * call sites. The actual Mastra `ctx.writer` is assignable to
52
+ * this shape so callers pass it straight through.
53
+ *
54
+ * Kept as a plain TypeScript interface (vs a zod schema) because
55
+ * the contract is a method - zod can only validate the shape via
56
+ * `z.custom`, which adds noise without buying any runtime check.
57
+ */
58
+ export interface MinimalWriter {
59
+ write: (chunk: unknown) => unknown;
60
+ }
61
+ /**
62
+ * Mastra-only lifecycle event: the Genie tool invocation started.
63
+ * Emitted immediately when the calling agent invokes the Genie
64
+ * tool, before any inner agent / wire activity, so the UI can
65
+ * pop a "Thinking..." pill the instant the model decides to
66
+ * delegate. `conversationId` / `messageId` are absent on this
67
+ * first emit (no Genie round-trip yet). Field names are
68
+ * camelCase (vs the snake_case wire events) to mirror the
69
+ * Genie agent's own internal data plumbing.
70
+ */
71
+ export declare const StartedEventSchema: z.ZodObject<{
72
+ type: z.ZodLiteral<"started">;
73
+ spaceId: z.ZodString;
74
+ conversationId: z.ZodOptional<z.ZodString>;
75
+ messageId: z.ZodOptional<z.ZodString>;
76
+ content: z.ZodString;
77
+ }, z.core.$strip>;
78
+ export type StartedEvent = z.infer<typeof StartedEventSchema>;
79
+ /**
80
+ * Mastra-only lifecycle event: one `ask_genie` invocation
81
+ * finished. Carries the hydrated `statementIds` (rows are fetched
82
+ * via `getStatement` separately) and Genie's final prose answer
83
+ * so the UI can move from "thinking" to "answered" without
84
+ * waiting for the Genie agent's whole reasoning loop to end.
85
+ */
86
+ export declare const AskGenieDoneEventSchema: z.ZodObject<{
87
+ type: z.ZodLiteral<"ask_genie_done">;
88
+ spaceId: z.ZodString;
89
+ conversationId: z.ZodOptional<z.ZodString>;
90
+ messageId: z.ZodOptional<z.ZodString>;
91
+ answer: z.ZodOptional<z.ZodString>;
92
+ statementIds: z.ZodArray<z.ZodString>;
93
+ status: z.ZodCustom<"ASKING_AI" | "CANCELLED" | "COMPLETED" | "EXECUTING_QUERY" | "FAILED" | "FETCHING_METADATA" | "FILTERING_CONTEXT" | "PENDING_WAREHOUSE" | "QUERY_RESULT_EXPIRED" | "SUBMITTED", "ASKING_AI" | "CANCELLED" | "COMPLETED" | "EXECUTING_QUERY" | "FAILED" | "FETCHING_METADATA" | "FILTERING_CONTEXT" | "PENDING_WAREHOUSE" | "QUERY_RESULT_EXPIRED" | "SUBMITTED">;
94
+ }, z.core.$strip>;
95
+ export type AskGenieDoneEvent = z.infer<typeof AskGenieDoneEventSchema>;
96
+ /**
97
+ * Mastra-only error event: terminal Genie agent / transport
98
+ * error. Genie's own `FAILED` / `CANCELLED` come through the
99
+ * wire's `result` event - this variant is for failures the wire
100
+ * can't represent (network, Genie agent crash, planner error,
101
+ * etc.) plus a UI-friendly mirror of `result` when the status is
102
+ * non-`COMPLETED`.
103
+ */
104
+ export declare const MastraGenieErrorEventSchema: z.ZodObject<{
105
+ type: z.ZodLiteral<"error">;
106
+ spaceId: z.ZodOptional<z.ZodString>;
107
+ conversationId: z.ZodOptional<z.ZodString>;
108
+ messageId: z.ZodOptional<z.ZodString>;
109
+ error: z.ZodString;
110
+ }, z.core.$strip>;
111
+ export type MastraGenieErrorEvent = z.infer<typeof MastraGenieErrorEventSchema>;
112
+ /**
113
+ * Mastra-only lifecycle event: the inner Genie agent's
114
+ * structured-output coercion has landed. Fires once per Genie
115
+ * tool invocation, AFTER `agent.generate(...)` completes (i.e.
116
+ * the inner loop + Mastra's structuring pass have both
117
+ * finished) and BEFORE the wrapper hydrates each `data` item
118
+ * with a chart. Signals to the host UI that the agent has
119
+ * stopped reasoning and is moving into chart generation.
120
+ *
121
+ * The structuring pass itself is opaque (it runs inside
122
+ * Mastra's `agent.generate(...)` together with the tool loop)
123
+ * so this is the earliest hook we can offer; we can't fire a
124
+ * "summary started" event the way we fire `started`.
125
+ */
126
+ export declare const SummaryEventSchema: z.ZodObject<{
127
+ type: z.ZodLiteral<"summary">;
128
+ spaceId: z.ZodString;
129
+ items: z.ZodNumber;
130
+ textItems: z.ZodNumber;
131
+ dataItems: z.ZodNumber;
132
+ }, z.core.$strip>;
133
+ export type SummaryEvent = z.infer<typeof SummaryEventSchema>;
134
+ /**
135
+ * Mastra-only render event: a chart was rendered for the active
136
+ * turn. Emitted by the chart-rendering tool (and replayed from
137
+ * `genieResultToWriterEvents` on history reload) so the host UI
138
+ * can drop an `[[chart:<chartId>]]`-keyed slot inline. Carries
139
+ * the dataset (for the table fallback / hover) and the resolved
140
+ * Echarts `option` in a single event keyed by `chartId`.
141
+ */
142
+ export declare const ChartEventSchema: z.ZodObject<{
143
+ type: z.ZodLiteral<"chart">;
144
+ chartId: z.ZodString;
145
+ title: z.ZodOptional<z.ZodString>;
146
+ description: z.ZodOptional<z.ZodString>;
147
+ data: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
148
+ option: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
149
+ statementId: z.ZodOptional<z.ZodString>;
150
+ messageId: z.ZodOptional<z.ZodString>;
151
+ }, z.core.$strip>;
152
+ export type ChartEvent = z.infer<typeof ChartEventSchema>;
153
+ /**
154
+ * Mastra-only event union. Each variant uses the same flat
155
+ * `{type, ...fields}` shape as {@link GenieChatEvent} so
156
+ * subscribers union both with a single `switch (event.type)`.
157
+ */
158
+ export declare const GenieAgentEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
159
+ type: z.ZodLiteral<"started">;
160
+ spaceId: z.ZodString;
161
+ conversationId: z.ZodOptional<z.ZodString>;
162
+ messageId: z.ZodOptional<z.ZodString>;
163
+ content: z.ZodString;
164
+ }, z.core.$strip>, z.ZodObject<{
165
+ type: z.ZodLiteral<"ask_genie_done">;
166
+ spaceId: z.ZodString;
167
+ conversationId: z.ZodOptional<z.ZodString>;
168
+ messageId: z.ZodOptional<z.ZodString>;
169
+ answer: z.ZodOptional<z.ZodString>;
170
+ statementIds: z.ZodArray<z.ZodString>;
171
+ status: z.ZodCustom<"ASKING_AI" | "CANCELLED" | "COMPLETED" | "EXECUTING_QUERY" | "FAILED" | "FETCHING_METADATA" | "FILTERING_CONTEXT" | "PENDING_WAREHOUSE" | "QUERY_RESULT_EXPIRED" | "SUBMITTED", "ASKING_AI" | "CANCELLED" | "COMPLETED" | "EXECUTING_QUERY" | "FAILED" | "FETCHING_METADATA" | "FILTERING_CONTEXT" | "PENDING_WAREHOUSE" | "QUERY_RESULT_EXPIRED" | "SUBMITTED">;
172
+ }, z.core.$strip>, z.ZodObject<{
173
+ type: z.ZodLiteral<"error">;
174
+ spaceId: z.ZodOptional<z.ZodString>;
175
+ conversationId: z.ZodOptional<z.ZodString>;
176
+ messageId: z.ZodOptional<z.ZodString>;
177
+ error: z.ZodString;
178
+ }, z.core.$strip>, z.ZodObject<{
179
+ type: z.ZodLiteral<"summary">;
180
+ spaceId: z.ZodString;
181
+ items: z.ZodNumber;
182
+ textItems: z.ZodNumber;
183
+ dataItems: z.ZodNumber;
184
+ }, z.core.$strip>, z.ZodObject<{
185
+ type: z.ZodLiteral<"chart">;
186
+ chartId: z.ZodString;
187
+ title: z.ZodOptional<z.ZodString>;
188
+ description: z.ZodOptional<z.ZodString>;
189
+ data: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
190
+ option: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
191
+ statementId: z.ZodOptional<z.ZodString>;
192
+ messageId: z.ZodOptional<z.ZodString>;
193
+ }, z.core.$strip>], "type">;
194
+ export type GenieAgentEvent = z.infer<typeof GenieAgentEventSchema>;
195
+ /**
196
+ * The unified writer-event vocabulary subscribers see on
197
+ * `ctx.writer`: the wire-derived {@link GenieChatEvent} union
198
+ * **plus** Mastra-only events from {@link GenieAgentEvent}. Each
199
+ * variant is a flat `{type, ...fields}` object; consumers narrow
200
+ * on `type` and read fields inline - there is no payload wrapper
201
+ * and no writer-boundary translator.
202
+ *
203
+ * Composed via `z.union` (not `z.discriminatedUnion`) because
204
+ * both halves are themselves discriminated unions on the same
205
+ * `type` key.
206
+ */
207
+ export declare const GenieWriterEventSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
208
+ conversation_id: z.ZodOptional<z.ZodString>;
209
+ space_id: z.ZodString;
210
+ message_id: z.ZodOptional<z.ZodString>;
211
+ type: z.ZodLiteral<"question">;
212
+ content: z.ZodString;
213
+ }, z.core.$strip>, z.ZodObject<{
214
+ type: z.ZodLiteral<"message">;
215
+ message: z.ZodObject<{
216
+ content: z.ZodString;
217
+ conversation_id: z.ZodString;
218
+ created_timestamp: z.ZodOptional<z.ZodNumber>;
219
+ error: z.ZodOptional<z.ZodObject<{
220
+ error: z.ZodOptional<z.ZodString>;
221
+ type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"BLOCK_MULTIPLE_EXECUTIONS_EXCEPTION">, z.ZodLiteral<"CHAT_COMPLETION_CLIENT_EXCEPTION">, z.ZodLiteral<"CHAT_COMPLETION_CLIENT_TIMEOUT_EXCEPTION">, z.ZodLiteral<"CHAT_COMPLETION_NETWORK_EXCEPTION">, z.ZodLiteral<"CONTENT_FILTER_EXCEPTION">, z.ZodLiteral<"CONTEXT_EXCEEDED_EXCEPTION">, z.ZodLiteral<"COULD_NOT_GET_MODEL_DEPLOYMENTS_EXCEPTION">, z.ZodLiteral<"COULD_NOT_GET_UC_SCHEMA_EXCEPTION">, z.ZodLiteral<"DEPLOYMENT_NOT_FOUND_EXCEPTION">, z.ZodLiteral<"DESCRIBE_QUERY_INVALID_SQL_ERROR">, z.ZodLiteral<"DESCRIBE_QUERY_TIMEOUT">, z.ZodLiteral<"DESCRIBE_QUERY_UNEXPECTED_FAILURE">, z.ZodLiteral<"EXCEEDED_MAX_TOKEN_LENGTH_EXCEPTION">, z.ZodLiteral<"FUNCTIONS_NOT_AVAILABLE_EXCEPTION">, z.ZodLiteral<"FUNCTION_ARGUMENTS_INVALID_EXCEPTION">, z.ZodLiteral<"FUNCTION_ARGUMENTS_INVALID_JSON_EXCEPTION">, z.ZodLiteral<"FUNCTION_ARGUMENTS_INVALID_TYPE_EXCEPTION">, z.ZodLiteral<"FUNCTION_CALL_MISSING_PARAMETER_EXCEPTION">, z.ZodLiteral<"GENERATED_SQL_QUERY_TOO_LONG_EXCEPTION">, z.ZodLiteral<"GENERIC_CHAT_COMPLETION_EXCEPTION">, z.ZodLiteral<"GENERIC_CHAT_COMPLETION_SERVICE_EXCEPTION">, z.ZodLiteral<"GENERIC_SQL_EXEC_API_CALL_EXCEPTION">, z.ZodLiteral<"ILLEGAL_PARAMETER_DEFINITION_EXCEPTION">, z.ZodLiteral<"INTERNAL_CATALOG_ASSET_CREATION_FAILED_EXCEPTION">, z.ZodLiteral<"INTERNAL_CATALOG_ASSET_CREATION_ONGOING_EXCEPTION">, z.ZodLiteral<"INTERNAL_CATALOG_ASSET_CREATION_UNSUPPORTED_EXCEPTION">, z.ZodLiteral<"INTERNAL_CATALOG_MISSING_UC_PATH_EXCEPTION">, z.ZodLiteral<"INTERNAL_CATALOG_PATH_OVERLAP_EXCEPTION">, z.ZodLiteral<"INVALID_CERTIFIED_ANSWER_FUNCTION_EXCEPTION">, z.ZodLiteral<"INVALID_CERTIFIED_ANSWER_IDENTIFIER_EXCEPTION">, z.ZodLiteral<"INVALID_CHAT_COMPLETION_ARGUMENTS_JSON_EXCEPTION">, z.ZodLiteral<"INVALID_CHAT_COMPLETION_JSON_EXCEPTION">, z.ZodLiteral<"INVALID_COMPLETION_REQUEST_EXCEPTION">, z.ZodLiteral<"INVALID_FUNCTION_CALL_EXCEPTION">, z.ZodLiteral<"INVALID_SQL_MULTIPLE_DATASET_REFERENCES_EXCEPTION">, z.ZodLiteral<"INVALID_SQL_MULTIPLE_STATEMENTS_EXCEPTION">, z.ZodLiteral<"INVALID_SQL_UNKNOWN_TABLE_EXCEPTION">, z.ZodLiteral<"INVALID_TABLE_IDENTIFIER_EXCEPTION">, z.ZodLiteral<"LOCAL_CONTEXT_EXCEEDED_EXCEPTION">, z.ZodLiteral<"MESSAGE_ATTACHMENT_TOO_LONG_ERROR">, z.ZodLiteral<"MESSAGE_CANCELLED_WHILE_EXECUTING_EXCEPTION">, z.ZodLiteral<"MESSAGE_DELETED_WHILE_EXECUTING_EXCEPTION">, z.ZodLiteral<"MESSAGE_UPDATED_WHILE_EXECUTING_EXCEPTION">, z.ZodLiteral<"MISSING_SQL_QUERY_EXCEPTION">, z.ZodLiteral<"NO_DEPLOYMENTS_AVAILABLE_TO_WORKSPACE">, z.ZodLiteral<"NO_QUERY_TO_VISUALIZE_EXCEPTION">, z.ZodLiteral<"NO_TABLES_TO_QUERY_EXCEPTION">, z.ZodLiteral<"RATE_LIMIT_EXCEEDED_GENERIC_EXCEPTION">, z.ZodLiteral<"RATE_LIMIT_EXCEEDED_SPECIFIED_WAIT_EXCEPTION">, z.ZodLiteral<"REPLY_PROCESS_TIMEOUT_EXCEPTION">, z.ZodLiteral<"RETRYABLE_PROCESSING_EXCEPTION">, z.ZodLiteral<"SQL_EXECUTION_EXCEPTION">, z.ZodLiteral<"STOP_PROCESS_DUE_TO_AUTO_REGENERATE">, z.ZodLiteral<"TABLES_MISSING_EXCEPTION">, z.ZodLiteral<"TOO_MANY_CERTIFIED_ANSWERS_EXCEPTION">, z.ZodLiteral<"TOO_MANY_TABLES_EXCEPTION">, z.ZodLiteral<"UNEXPECTED_REPLY_PROCESS_EXCEPTION">, z.ZodLiteral<"UNKNOWN_AI_MODEL">, z.ZodLiteral<"UNSUPPORTED_CONVERSATION_TYPE_EXCEPTION">, z.ZodLiteral<"WAREHOUSE_ACCESS_MISSING_EXCEPTION">, z.ZodLiteral<"WAREHOUSE_NOT_FOUND_EXCEPTION">]>>;
222
+ }, z.core.$strip>>;
223
+ feedback: z.ZodOptional<z.ZodObject<{
224
+ rating: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"NEGATIVE">, z.ZodLiteral<"NONE">, z.ZodLiteral<"POSITIVE">]>>;
225
+ }, z.core.$strip>>;
226
+ id: z.ZodString;
227
+ last_updated_timestamp: z.ZodOptional<z.ZodNumber>;
228
+ message_id: z.ZodString;
229
+ query_result: z.ZodOptional<z.ZodObject<{
230
+ is_truncated: z.ZodOptional<z.ZodBoolean>;
231
+ row_count: z.ZodOptional<z.ZodNumber>;
232
+ statement_id: z.ZodOptional<z.ZodString>;
233
+ statement_id_signature: z.ZodOptional<z.ZodString>;
234
+ }, z.core.$strip>>;
235
+ space_id: z.ZodString;
236
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ASKING_AI">, z.ZodLiteral<"CANCELLED">, z.ZodLiteral<"COMPLETED">, z.ZodLiteral<"EXECUTING_QUERY">, z.ZodLiteral<"FAILED">, z.ZodLiteral<"FETCHING_METADATA">, z.ZodLiteral<"FILTERING_CONTEXT">, z.ZodLiteral<"PENDING_WAREHOUSE">, z.ZodLiteral<"QUERY_RESULT_EXPIRED">, z.ZodLiteral<"SUBMITTED">]>>;
237
+ user_id: z.ZodOptional<z.ZodNumber>;
238
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
239
+ attachment_id: z.ZodOptional<z.ZodString>;
240
+ suggested_questions: z.ZodOptional<z.ZodObject<{
241
+ questions: z.ZodOptional<z.ZodArray<z.ZodString>>;
242
+ }, z.core.$strip>>;
243
+ text: z.ZodOptional<z.ZodObject<{
244
+ content: z.ZodOptional<z.ZodString>;
245
+ id: z.ZodOptional<z.ZodString>;
246
+ purpose: z.ZodOptional<z.ZodLiteral<"FOLLOW_UP_QUESTION">>;
247
+ }, z.core.$strip>>;
248
+ query: z.ZodOptional<z.ZodObject<{
249
+ description: z.ZodOptional<z.ZodString>;
250
+ id: z.ZodOptional<z.ZodString>;
251
+ last_updated_timestamp: z.ZodOptional<z.ZodNumber>;
252
+ parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
253
+ keyword: z.ZodOptional<z.ZodString>;
254
+ sql_type: z.ZodOptional<z.ZodString>;
255
+ value: z.ZodOptional<z.ZodString>;
256
+ }, z.core.$strip>>>;
257
+ query: z.ZodOptional<z.ZodString>;
258
+ query_result_metadata: z.ZodOptional<z.ZodObject<{
259
+ is_truncated: z.ZodOptional<z.ZodBoolean>;
260
+ row_count: z.ZodOptional<z.ZodNumber>;
261
+ }, z.core.$strip>>;
262
+ statement_id: z.ZodOptional<z.ZodString>;
263
+ title: z.ZodOptional<z.ZodString>;
264
+ thoughts: z.ZodOptional<z.ZodArray<z.ZodObject<{
265
+ thought_type: z.ZodCustom<import("@dbx-tools/genie-shared").GenieThoughtType, import("@dbx-tools/genie-shared").GenieThoughtType>;
266
+ content: z.ZodString;
267
+ }, z.core.$strip>>>;
268
+ }, z.core.$strip>>;
269
+ attachment_type: z.ZodOptional<z.ZodCustom<import("@dbx-tools/genie-shared").AttachmentType, import("@dbx-tools/genie-shared").AttachmentType>>;
270
+ }, z.core.$strip>>>;
271
+ auto_regenerate_count: z.ZodOptional<z.ZodNumber>;
272
+ }, z.core.$strip>;
273
+ }, z.core.$strip>, z.ZodObject<{
274
+ conversation_id: z.ZodOptional<z.ZodString>;
275
+ space_id: z.ZodString;
276
+ message_id: z.ZodOptional<z.ZodString>;
277
+ type: z.ZodLiteral<"status">;
278
+ status: z.ZodUnion<readonly [z.ZodLiteral<"ASKING_AI">, z.ZodLiteral<"CANCELLED">, z.ZodLiteral<"COMPLETED">, z.ZodLiteral<"EXECUTING_QUERY">, z.ZodLiteral<"FAILED">, z.ZodLiteral<"FETCHING_METADATA">, z.ZodLiteral<"FILTERING_CONTEXT">, z.ZodLiteral<"PENDING_WAREHOUSE">, z.ZodLiteral<"QUERY_RESULT_EXPIRED">, z.ZodLiteral<"SUBMITTED">]>;
279
+ previous_status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ASKING_AI">, z.ZodLiteral<"CANCELLED">, z.ZodLiteral<"COMPLETED">, z.ZodLiteral<"EXECUTING_QUERY">, z.ZodLiteral<"FAILED">, z.ZodLiteral<"FETCHING_METADATA">, z.ZodLiteral<"FILTERING_CONTEXT">, z.ZodLiteral<"PENDING_WAREHOUSE">, z.ZodLiteral<"QUERY_RESULT_EXPIRED">, z.ZodLiteral<"SUBMITTED">]>>;
280
+ }, z.core.$strip>, z.ZodObject<{
281
+ space_id: z.ZodString;
282
+ conversation_id: z.ZodOptional<z.ZodString>;
283
+ message_id: z.ZodOptional<z.ZodString>;
284
+ attachment_id: z.ZodOptional<z.ZodString>;
285
+ type: z.ZodLiteral<"attachment">;
286
+ index: z.ZodNumber;
287
+ attachment_type: z.ZodCustom<import("@dbx-tools/genie-shared").AttachmentType, import("@dbx-tools/genie-shared").AttachmentType>;
288
+ }, z.core.$strip>, z.ZodObject<{
289
+ space_id: z.ZodString;
290
+ conversation_id: z.ZodOptional<z.ZodString>;
291
+ message_id: z.ZodOptional<z.ZodString>;
292
+ attachment_id: z.ZodOptional<z.ZodString>;
293
+ type: z.ZodLiteral<"thinking">;
294
+ text: z.ZodString;
295
+ thought_type: z.ZodCustom<import("@dbx-tools/genie-shared").GenieThoughtType, import("@dbx-tools/genie-shared").GenieThoughtType>;
296
+ }, z.core.$strip>, z.ZodObject<{
297
+ space_id: z.ZodString;
298
+ conversation_id: z.ZodOptional<z.ZodString>;
299
+ message_id: z.ZodOptional<z.ZodString>;
300
+ attachment_id: z.ZodOptional<z.ZodString>;
301
+ type: z.ZodLiteral<"text">;
302
+ text: z.ZodString;
303
+ }, z.core.$strip>, z.ZodObject<{
304
+ space_id: z.ZodString;
305
+ conversation_id: z.ZodOptional<z.ZodString>;
306
+ message_id: z.ZodOptional<z.ZodString>;
307
+ attachment_id: z.ZodOptional<z.ZodString>;
308
+ type: z.ZodLiteral<"query">;
309
+ sql: z.ZodString;
310
+ title: z.ZodOptional<z.ZodString>;
311
+ description: z.ZodOptional<z.ZodString>;
312
+ }, z.core.$strip>, z.ZodObject<{
313
+ space_id: z.ZodString;
314
+ conversation_id: z.ZodOptional<z.ZodString>;
315
+ message_id: z.ZodOptional<z.ZodString>;
316
+ attachment_id: z.ZodOptional<z.ZodString>;
317
+ type: z.ZodLiteral<"statement">;
318
+ statement_id: z.ZodString;
319
+ }, z.core.$strip>, z.ZodObject<{
320
+ space_id: z.ZodString;
321
+ conversation_id: z.ZodOptional<z.ZodString>;
322
+ message_id: z.ZodOptional<z.ZodString>;
323
+ attachment_id: z.ZodOptional<z.ZodString>;
324
+ type: z.ZodLiteral<"rows">;
325
+ row_count: z.ZodNumber;
326
+ previous_row_count: z.ZodOptional<z.ZodNumber>;
327
+ statement_id: z.ZodOptional<z.ZodString>;
328
+ }, z.core.$strip>, z.ZodObject<{
329
+ space_id: z.ZodString;
330
+ conversation_id: z.ZodOptional<z.ZodString>;
331
+ message_id: z.ZodOptional<z.ZodString>;
332
+ attachment_id: z.ZodOptional<z.ZodString>;
333
+ type: z.ZodLiteral<"suggested_questions">;
334
+ questions: z.ZodArray<z.ZodString>;
335
+ }, z.core.$strip>, z.ZodObject<{
336
+ conversation_id: z.ZodOptional<z.ZodString>;
337
+ space_id: z.ZodString;
338
+ message_id: z.ZodOptional<z.ZodString>;
339
+ type: z.ZodLiteral<"result">;
340
+ status: z.ZodEnum<{
341
+ CANCELLED: "CANCELLED";
342
+ COMPLETED: "COMPLETED";
343
+ FAILED: "FAILED";
344
+ }>;
345
+ message: z.ZodObject<{
346
+ content: z.ZodString;
347
+ conversation_id: z.ZodString;
348
+ created_timestamp: z.ZodOptional<z.ZodNumber>;
349
+ error: z.ZodOptional<z.ZodObject<{
350
+ error: z.ZodOptional<z.ZodString>;
351
+ type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"BLOCK_MULTIPLE_EXECUTIONS_EXCEPTION">, z.ZodLiteral<"CHAT_COMPLETION_CLIENT_EXCEPTION">, z.ZodLiteral<"CHAT_COMPLETION_CLIENT_TIMEOUT_EXCEPTION">, z.ZodLiteral<"CHAT_COMPLETION_NETWORK_EXCEPTION">, z.ZodLiteral<"CONTENT_FILTER_EXCEPTION">, z.ZodLiteral<"CONTEXT_EXCEEDED_EXCEPTION">, z.ZodLiteral<"COULD_NOT_GET_MODEL_DEPLOYMENTS_EXCEPTION">, z.ZodLiteral<"COULD_NOT_GET_UC_SCHEMA_EXCEPTION">, z.ZodLiteral<"DEPLOYMENT_NOT_FOUND_EXCEPTION">, z.ZodLiteral<"DESCRIBE_QUERY_INVALID_SQL_ERROR">, z.ZodLiteral<"DESCRIBE_QUERY_TIMEOUT">, z.ZodLiteral<"DESCRIBE_QUERY_UNEXPECTED_FAILURE">, z.ZodLiteral<"EXCEEDED_MAX_TOKEN_LENGTH_EXCEPTION">, z.ZodLiteral<"FUNCTIONS_NOT_AVAILABLE_EXCEPTION">, z.ZodLiteral<"FUNCTION_ARGUMENTS_INVALID_EXCEPTION">, z.ZodLiteral<"FUNCTION_ARGUMENTS_INVALID_JSON_EXCEPTION">, z.ZodLiteral<"FUNCTION_ARGUMENTS_INVALID_TYPE_EXCEPTION">, z.ZodLiteral<"FUNCTION_CALL_MISSING_PARAMETER_EXCEPTION">, z.ZodLiteral<"GENERATED_SQL_QUERY_TOO_LONG_EXCEPTION">, z.ZodLiteral<"GENERIC_CHAT_COMPLETION_EXCEPTION">, z.ZodLiteral<"GENERIC_CHAT_COMPLETION_SERVICE_EXCEPTION">, z.ZodLiteral<"GENERIC_SQL_EXEC_API_CALL_EXCEPTION">, z.ZodLiteral<"ILLEGAL_PARAMETER_DEFINITION_EXCEPTION">, z.ZodLiteral<"INTERNAL_CATALOG_ASSET_CREATION_FAILED_EXCEPTION">, z.ZodLiteral<"INTERNAL_CATALOG_ASSET_CREATION_ONGOING_EXCEPTION">, z.ZodLiteral<"INTERNAL_CATALOG_ASSET_CREATION_UNSUPPORTED_EXCEPTION">, z.ZodLiteral<"INTERNAL_CATALOG_MISSING_UC_PATH_EXCEPTION">, z.ZodLiteral<"INTERNAL_CATALOG_PATH_OVERLAP_EXCEPTION">, z.ZodLiteral<"INVALID_CERTIFIED_ANSWER_FUNCTION_EXCEPTION">, z.ZodLiteral<"INVALID_CERTIFIED_ANSWER_IDENTIFIER_EXCEPTION">, z.ZodLiteral<"INVALID_CHAT_COMPLETION_ARGUMENTS_JSON_EXCEPTION">, z.ZodLiteral<"INVALID_CHAT_COMPLETION_JSON_EXCEPTION">, z.ZodLiteral<"INVALID_COMPLETION_REQUEST_EXCEPTION">, z.ZodLiteral<"INVALID_FUNCTION_CALL_EXCEPTION">, z.ZodLiteral<"INVALID_SQL_MULTIPLE_DATASET_REFERENCES_EXCEPTION">, z.ZodLiteral<"INVALID_SQL_MULTIPLE_STATEMENTS_EXCEPTION">, z.ZodLiteral<"INVALID_SQL_UNKNOWN_TABLE_EXCEPTION">, z.ZodLiteral<"INVALID_TABLE_IDENTIFIER_EXCEPTION">, z.ZodLiteral<"LOCAL_CONTEXT_EXCEEDED_EXCEPTION">, z.ZodLiteral<"MESSAGE_ATTACHMENT_TOO_LONG_ERROR">, z.ZodLiteral<"MESSAGE_CANCELLED_WHILE_EXECUTING_EXCEPTION">, z.ZodLiteral<"MESSAGE_DELETED_WHILE_EXECUTING_EXCEPTION">, z.ZodLiteral<"MESSAGE_UPDATED_WHILE_EXECUTING_EXCEPTION">, z.ZodLiteral<"MISSING_SQL_QUERY_EXCEPTION">, z.ZodLiteral<"NO_DEPLOYMENTS_AVAILABLE_TO_WORKSPACE">, z.ZodLiteral<"NO_QUERY_TO_VISUALIZE_EXCEPTION">, z.ZodLiteral<"NO_TABLES_TO_QUERY_EXCEPTION">, z.ZodLiteral<"RATE_LIMIT_EXCEEDED_GENERIC_EXCEPTION">, z.ZodLiteral<"RATE_LIMIT_EXCEEDED_SPECIFIED_WAIT_EXCEPTION">, z.ZodLiteral<"REPLY_PROCESS_TIMEOUT_EXCEPTION">, z.ZodLiteral<"RETRYABLE_PROCESSING_EXCEPTION">, z.ZodLiteral<"SQL_EXECUTION_EXCEPTION">, z.ZodLiteral<"STOP_PROCESS_DUE_TO_AUTO_REGENERATE">, z.ZodLiteral<"TABLES_MISSING_EXCEPTION">, z.ZodLiteral<"TOO_MANY_CERTIFIED_ANSWERS_EXCEPTION">, z.ZodLiteral<"TOO_MANY_TABLES_EXCEPTION">, z.ZodLiteral<"UNEXPECTED_REPLY_PROCESS_EXCEPTION">, z.ZodLiteral<"UNKNOWN_AI_MODEL">, z.ZodLiteral<"UNSUPPORTED_CONVERSATION_TYPE_EXCEPTION">, z.ZodLiteral<"WAREHOUSE_ACCESS_MISSING_EXCEPTION">, z.ZodLiteral<"WAREHOUSE_NOT_FOUND_EXCEPTION">]>>;
352
+ }, z.core.$strip>>;
353
+ feedback: z.ZodOptional<z.ZodObject<{
354
+ rating: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"NEGATIVE">, z.ZodLiteral<"NONE">, z.ZodLiteral<"POSITIVE">]>>;
355
+ }, z.core.$strip>>;
356
+ id: z.ZodString;
357
+ last_updated_timestamp: z.ZodOptional<z.ZodNumber>;
358
+ message_id: z.ZodString;
359
+ query_result: z.ZodOptional<z.ZodObject<{
360
+ is_truncated: z.ZodOptional<z.ZodBoolean>;
361
+ row_count: z.ZodOptional<z.ZodNumber>;
362
+ statement_id: z.ZodOptional<z.ZodString>;
363
+ statement_id_signature: z.ZodOptional<z.ZodString>;
364
+ }, z.core.$strip>>;
365
+ space_id: z.ZodString;
366
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ASKING_AI">, z.ZodLiteral<"CANCELLED">, z.ZodLiteral<"COMPLETED">, z.ZodLiteral<"EXECUTING_QUERY">, z.ZodLiteral<"FAILED">, z.ZodLiteral<"FETCHING_METADATA">, z.ZodLiteral<"FILTERING_CONTEXT">, z.ZodLiteral<"PENDING_WAREHOUSE">, z.ZodLiteral<"QUERY_RESULT_EXPIRED">, z.ZodLiteral<"SUBMITTED">]>>;
367
+ user_id: z.ZodOptional<z.ZodNumber>;
368
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
369
+ attachment_id: z.ZodOptional<z.ZodString>;
370
+ suggested_questions: z.ZodOptional<z.ZodObject<{
371
+ questions: z.ZodOptional<z.ZodArray<z.ZodString>>;
372
+ }, z.core.$strip>>;
373
+ text: z.ZodOptional<z.ZodObject<{
374
+ content: z.ZodOptional<z.ZodString>;
375
+ id: z.ZodOptional<z.ZodString>;
376
+ purpose: z.ZodOptional<z.ZodLiteral<"FOLLOW_UP_QUESTION">>;
377
+ }, z.core.$strip>>;
378
+ query: z.ZodOptional<z.ZodObject<{
379
+ description: z.ZodOptional<z.ZodString>;
380
+ id: z.ZodOptional<z.ZodString>;
381
+ last_updated_timestamp: z.ZodOptional<z.ZodNumber>;
382
+ parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
383
+ keyword: z.ZodOptional<z.ZodString>;
384
+ sql_type: z.ZodOptional<z.ZodString>;
385
+ value: z.ZodOptional<z.ZodString>;
386
+ }, z.core.$strip>>>;
387
+ query: z.ZodOptional<z.ZodString>;
388
+ query_result_metadata: z.ZodOptional<z.ZodObject<{
389
+ is_truncated: z.ZodOptional<z.ZodBoolean>;
390
+ row_count: z.ZodOptional<z.ZodNumber>;
391
+ }, z.core.$strip>>;
392
+ statement_id: z.ZodOptional<z.ZodString>;
393
+ title: z.ZodOptional<z.ZodString>;
394
+ thoughts: z.ZodOptional<z.ZodArray<z.ZodObject<{
395
+ thought_type: z.ZodCustom<import("@dbx-tools/genie-shared").GenieThoughtType, import("@dbx-tools/genie-shared").GenieThoughtType>;
396
+ content: z.ZodString;
397
+ }, z.core.$strip>>>;
398
+ }, z.core.$strip>>;
399
+ attachment_type: z.ZodOptional<z.ZodCustom<import("@dbx-tools/genie-shared").AttachmentType, import("@dbx-tools/genie-shared").AttachmentType>>;
400
+ }, z.core.$strip>>>;
401
+ auto_regenerate_count: z.ZodOptional<z.ZodNumber>;
402
+ }, z.core.$strip>;
403
+ }, z.core.$strip>], "type">, z.ZodDiscriminatedUnion<[z.ZodObject<{
404
+ type: z.ZodLiteral<"started">;
405
+ spaceId: z.ZodString;
406
+ conversationId: z.ZodOptional<z.ZodString>;
407
+ messageId: z.ZodOptional<z.ZodString>;
408
+ content: z.ZodString;
409
+ }, z.core.$strip>, z.ZodObject<{
410
+ type: z.ZodLiteral<"ask_genie_done">;
411
+ spaceId: z.ZodString;
412
+ conversationId: z.ZodOptional<z.ZodString>;
413
+ messageId: z.ZodOptional<z.ZodString>;
414
+ answer: z.ZodOptional<z.ZodString>;
415
+ statementIds: z.ZodArray<z.ZodString>;
416
+ status: z.ZodCustom<"ASKING_AI" | "CANCELLED" | "COMPLETED" | "EXECUTING_QUERY" | "FAILED" | "FETCHING_METADATA" | "FILTERING_CONTEXT" | "PENDING_WAREHOUSE" | "QUERY_RESULT_EXPIRED" | "SUBMITTED", "ASKING_AI" | "CANCELLED" | "COMPLETED" | "EXECUTING_QUERY" | "FAILED" | "FETCHING_METADATA" | "FILTERING_CONTEXT" | "PENDING_WAREHOUSE" | "QUERY_RESULT_EXPIRED" | "SUBMITTED">;
417
+ }, z.core.$strip>, z.ZodObject<{
418
+ type: z.ZodLiteral<"error">;
419
+ spaceId: z.ZodOptional<z.ZodString>;
420
+ conversationId: z.ZodOptional<z.ZodString>;
421
+ messageId: z.ZodOptional<z.ZodString>;
422
+ error: z.ZodString;
423
+ }, z.core.$strip>, z.ZodObject<{
424
+ type: z.ZodLiteral<"summary">;
425
+ spaceId: z.ZodString;
426
+ items: z.ZodNumber;
427
+ textItems: z.ZodNumber;
428
+ dataItems: z.ZodNumber;
429
+ }, z.core.$strip>, z.ZodObject<{
430
+ type: z.ZodLiteral<"chart">;
431
+ chartId: z.ZodString;
432
+ title: z.ZodOptional<z.ZodString>;
433
+ description: z.ZodOptional<z.ZodString>;
434
+ data: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
435
+ option: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
436
+ statementId: z.ZodOptional<z.ZodString>;
437
+ messageId: z.ZodOptional<z.ZodString>;
438
+ }, z.core.$strip>], "type">]>;
439
+ export type GenieWriterEvent = z.infer<typeof GenieWriterEventSchema>;
440
+ /** Discriminator type for {@link GenieWriterEvent}. */
441
+ export type GenieWriterEventType = GenieWriterEvent["type"];
442
+ /**
443
+ * Tabular payload embedded in every {@link GenieSummaryItem}
444
+ * `visualize` dataset. Always present: hydrated by the workflow's
445
+ * agent step before the finalize step runs, so consumers can render
446
+ * a table fallback regardless of chart-planner outcome.
447
+ *
448
+ * Fields:
449
+ * - `columns`: column names in display order.
450
+ * - `rows`: tabular rows keyed by column name.
451
+ * - `rowCount`: total row count Genie reported (may exceed
452
+ * `rows.length` when the statement was truncated).
453
+ */
454
+ export declare const GenieDatasetDataSchema: z.ZodObject<{
455
+ columns: z.ZodArray<z.ZodString>;
456
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
457
+ rowCount: z.ZodNumber;
458
+ }, z.core.$strip>;
459
+ export type GenieDatasetData = z.infer<typeof GenieDatasetDataSchema>;
460
+ /**
461
+ * Slim chart reference attached to a visualize dataset once the
462
+ * workflow's finalize step runs the chart-planner. Only present
463
+ * when planning succeeded.
464
+ *
465
+ * `option` is intentionally NOT included. The resolved Echarts
466
+ * spec lives off-band:
467
+ *
468
+ * - On the wire to the UI: in the matching {@link ChartEvent}
469
+ * writer event (the host UI receives both this dataset and
470
+ * the writer event and joins them on `chartId`).
471
+ * - On the server: in the per-request {@link RequestContext}
472
+ * under the chart inventory key (see appkit-mastra's
473
+ * `chartInventoryFromContext`), so output processors and
474
+ * downstream tools can look up the full payload by `chartId`
475
+ * without round-tripping through the LLM.
476
+ *
477
+ * Why slim: full Echarts options nest deeply and are several
478
+ * KB per chart. Embedding them in the tool result means every
479
+ * subsequent turn of the agent loop reads them back into context
480
+ * for zero LLM benefit (the model only needs the `chartId` to
481
+ * place a `[[chart:<chartId>]]` marker).
482
+ */
483
+ export declare const GenieDatasetChartSchema: z.ZodObject<{
484
+ chartId: z.ZodString;
485
+ chartType: z.ZodEnum<{
486
+ bar: "bar";
487
+ line: "line";
488
+ area: "area";
489
+ scatter: "scatter";
490
+ pie: "pie";
491
+ }>;
492
+ }, z.core.$strip>;
493
+ export type GenieDatasetChart = z.infer<typeof GenieDatasetChartSchema>;
494
+ /**
495
+ * Dataset bundle attached to a {@link GenieSummaryItem} `visualize`
496
+ * item. `data` is always populated; `chart` is best-effort and
497
+ * absent when the workflow's chart-planner failed (timeout,
498
+ * malformed plan, abort) so the host UI can still render the
499
+ * underlying table.
500
+ */
501
+ export declare const GenieDatasetSchema: z.ZodObject<{
502
+ data: z.ZodObject<{
503
+ columns: z.ZodArray<z.ZodString>;
504
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
505
+ rowCount: z.ZodNumber;
506
+ }, z.core.$strip>;
507
+ chart: z.ZodOptional<z.ZodObject<{
508
+ chartId: z.ZodString;
509
+ chartType: z.ZodEnum<{
510
+ bar: "bar";
511
+ line: "line";
512
+ area: "area";
513
+ scatter: "scatter";
514
+ pie: "pie";
515
+ }>;
516
+ }, z.core.$strip>>;
517
+ }, z.core.$strip>;
518
+ export type GenieDataset = z.infer<typeof GenieDatasetSchema>;
519
+ /**
520
+ * One item inside the Genie workflow's final summary. The
521
+ * workflow produces a mixed sequence of:
522
+ *
523
+ * - `string`: a markdown paragraph (interpretation, callouts,
524
+ * transitions between data blocks).
525
+ * - `visualize`: a request from the agent step to visualize a
526
+ * specific Genie statement at this position in the prose.
527
+ * The finalize step hydrates `dataset.data` (rows from the
528
+ * matching `statementId`) and attaches `dataset.chart` after
529
+ * running the chart-planner. The agent NEVER picks the chart
530
+ * type - it only marks where a visualization belongs.
531
+ *
532
+ * The host UI walks the array in display order to compose the
533
+ * final assistant message.
534
+ */
535
+ export declare const GenieSummaryItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
536
+ type: z.ZodLiteral<"string">;
537
+ text: z.ZodString;
538
+ }, z.core.$strip>, z.ZodObject<{
539
+ type: z.ZodLiteral<"visualize">;
540
+ statementId: z.ZodString;
541
+ title: z.ZodOptional<z.ZodString>;
542
+ description: z.ZodOptional<z.ZodString>;
543
+ dataset: z.ZodObject<{
544
+ data: z.ZodObject<{
545
+ columns: z.ZodArray<z.ZodString>;
546
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
547
+ rowCount: z.ZodNumber;
548
+ }, z.core.$strip>;
549
+ chart: z.ZodOptional<z.ZodObject<{
550
+ chartId: z.ZodString;
551
+ chartType: z.ZodEnum<{
552
+ bar: "bar";
553
+ line: "line";
554
+ area: "area";
555
+ scatter: "scatter";
556
+ pie: "pie";
557
+ }>;
558
+ }, z.core.$strip>>;
559
+ }, z.core.$strip>;
560
+ }, z.core.$strip>], "type">;
561
+ export type GenieSummaryItem = z.infer<typeof GenieSummaryItemSchema>;
562
+ /** Discriminator type for {@link GenieSummaryItem}. */
563
+ export type GenieSummaryItemType = GenieSummaryItem["type"];
564
+ /**
565
+ * The Genie agent's final output shape - what the calling agent's
566
+ * Genie tool returns to the calling LLM. The `summary` array is
567
+ * the user-facing renderable; `conversationId` lets the calling
568
+ * agent (or the UI) follow up in the same Genie thread on the
569
+ * next turn.
570
+ */
571
+ export declare const GenieAgentResultSchema: z.ZodObject<{
572
+ spaceId: z.ZodString;
573
+ conversationId: z.ZodOptional<z.ZodString>;
574
+ summary: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
575
+ type: z.ZodLiteral<"string">;
576
+ text: z.ZodString;
577
+ }, z.core.$strip>, z.ZodObject<{
578
+ type: z.ZodLiteral<"visualize">;
579
+ statementId: z.ZodString;
580
+ title: z.ZodOptional<z.ZodString>;
581
+ description: z.ZodOptional<z.ZodString>;
582
+ dataset: z.ZodObject<{
583
+ data: z.ZodObject<{
584
+ columns: z.ZodArray<z.ZodString>;
585
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
586
+ rowCount: z.ZodNumber;
587
+ }, z.core.$strip>;
588
+ chart: z.ZodOptional<z.ZodObject<{
589
+ chartId: z.ZodString;
590
+ chartType: z.ZodEnum<{
591
+ bar: "bar";
592
+ line: "line";
593
+ area: "area";
594
+ scatter: "scatter";
595
+ pie: "pie";
596
+ }>;
597
+ }, z.core.$strip>>;
598
+ }, z.core.$strip>;
599
+ }, z.core.$strip>], "type">>;
600
+ error: z.ZodOptional<z.ZodString>;
601
+ }, z.core.$strip>;
602
+ export type GenieAgentResult = z.infer<typeof GenieAgentResultSchema>;
603
+ /**
604
+ * Structural type guard for {@link GenieAgentResult}. Used by
605
+ * host UIs to detect the Genie agent's payload off Mastra's
606
+ * `tool-result` chunks without coupling to a specific Mastra tool
607
+ * name (per-space variants like `tool-genie-<alias>` all return
608
+ * the same shape).
609
+ *
610
+ * Cheap structural check (vs full `safeParse`) so the guard stays
611
+ * O(1) on the hot path; consumers that want full validation can
612
+ * call {@link GenieAgentResultSchema}`.safeParse(value)` directly.
613
+ */
614
+ export declare function isGenieAgentResult(value: unknown): value is GenieAgentResult;
615
+ /**
616
+ * Walk a {@link GenieAgentResult} and produce the lifecycle
617
+ * writer events a host UI needs to replay terminal state inline.
618
+ *
619
+ * Chart replay is intentionally NOT supported: the resolved
620
+ * Echarts `option` is held off-band in the per-request
621
+ * `RequestContext` (and on the live writer event when the run is
622
+ * in flight), not on the persisted summary, so a completed run
623
+ * read back from storage has no chart spec to replay. Host UIs
624
+ * that want post-reload chart rendering need to plumb the spec
625
+ * through a separate persisted side-channel.
626
+ *
627
+ * Currently extracted:
628
+ *
629
+ * - `type: "error"` when `output.error` is set (Genie returned
630
+ * `FAILED` / `CANCELLED`, `getStatement` errored, etc.).
631
+ *
632
+ * `string` summary items are not surfaced here - the calling
633
+ * LLM's text reply renders them inline.
634
+ */
635
+ export declare function genieResultToWriterEvents(output: GenieAgentResult): GenieAgentEvent[];