@dbx-tools/appkit-mastra-shared 0.1.18 → 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.
- package/README.md +51 -16
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,13 +10,24 @@ TypeScript types and three small URL helpers.
|
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
import {
|
|
13
|
+
// URL helpers
|
|
13
14
|
chatUrl,
|
|
14
15
|
historyUrl,
|
|
16
|
+
// Protocol types + schemas
|
|
15
17
|
type MastraClientConfig,
|
|
16
18
|
type ServingEndpointSummary,
|
|
17
19
|
type ServingEndpointsResponse,
|
|
18
20
|
type MastraHistoryUIMessage,
|
|
19
21
|
type MastraHistoryResponse,
|
|
22
|
+
type MastraClearHistoryResponse,
|
|
23
|
+
// Genie writer-event vocabulary + workflow output shapes
|
|
24
|
+
type GenieAgentResult,
|
|
25
|
+
type GenieSummaryItem,
|
|
26
|
+
type GenieDataset,
|
|
27
|
+
type GenieWriterEvent,
|
|
28
|
+
type MinimalWriter,
|
|
29
|
+
isGenieAgentResult,
|
|
30
|
+
genieResultToWriterEvents,
|
|
20
31
|
} from "@dbx-tools/appkit-mastra-shared";
|
|
21
32
|
```
|
|
22
33
|
|
|
@@ -132,22 +143,46 @@ interface ServingEndpointsResponse {
|
|
|
132
143
|
}
|
|
133
144
|
```
|
|
134
145
|
|
|
135
|
-
###
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
### Genie writer-event vocabulary
|
|
147
|
+
|
|
148
|
+
The Mastra Genie agent publishes a unified
|
|
149
|
+
[`GenieWriterEvent`](src/genie.ts) union through Mastra's
|
|
150
|
+
`ctx.writer`. Subscribers narrow on `event.type` and read the
|
|
151
|
+
event's flat fields directly - no payload wrapper, no
|
|
152
|
+
translation layer:
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import type { GenieWriterEvent } from "@dbx-tools/appkit-mastra-shared";
|
|
156
|
+
|
|
157
|
+
function handleEvent(event: GenieWriterEvent) {
|
|
158
|
+
switch (event.type) {
|
|
159
|
+
case "started": // Mastra-only: tool invocation began
|
|
160
|
+
case "ask_genie_done": // Mastra-only: one ask_genie turn finished
|
|
161
|
+
case "summary": // Mastra-only: structured-output coercion landed
|
|
162
|
+
case "chart": // Mastra-only: chart rendered for the active turn
|
|
163
|
+
case "error": // Mastra-only: terminal error
|
|
164
|
+
case "status": // wire: status transition
|
|
165
|
+
case "thinking": // wire: Genie thought
|
|
166
|
+
case "text": // wire: text delta
|
|
167
|
+
case "query": // wire: SQL emitted
|
|
168
|
+
case "statement": // wire: warehouse statement submitted
|
|
169
|
+
case "rows": // wire: row-count progress
|
|
170
|
+
case "suggested_questions": // wire: follow-up suggestions
|
|
171
|
+
// ...
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`isGenieAgentResult(value)` is an O(1) structural guard that
|
|
177
|
+
detects the agent's tool-result payload off Mastra's
|
|
178
|
+
`tool-result` chunks without coupling to a specific tool name.
|
|
179
|
+
|
|
180
|
+
`genieResultToWriterEvents(result)` replays the terminal
|
|
181
|
+
`error` event from a completed `GenieAgentResult`, useful for
|
|
182
|
+
reconstructing lifecycle pills on history reload. Live-only
|
|
183
|
+
chart specs are intentionally not replayed (the resolved
|
|
184
|
+
Echarts spec is held off-band on the per-request
|
|
185
|
+
`RequestContext`, not on the persisted summary).
|
|
151
186
|
|
|
152
187
|
## License
|
|
153
188
|
|