@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 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
- ### Inline charts (no wire types here)
136
-
137
- Chart rendering does not have HTTP wire types. The producer
138
- tools (`render_data`, Genie) both emit `type: "chart"` events
139
- on Mastra's writer channel - first an event with the dataset
140
- (`{chartId, title, description?, data}`), then a follow-up
141
- event with the resolved `EChartsOption`
142
- (`{chartId, option}`) once the server-side chart-planner agent
143
- finishes. The chat client merges them by `chartId` and renders
144
- inline at the model's `[[chart:<chartId>]]` marker.
145
-
146
- The exact field shape lives on the writer-event consumer side
147
- (see `demo/client/src/components/chat-view.tsx`'s `ToolProgress`
148
- union for the canonical TypeScript). This package only ships
149
- URL helpers and HTTP wire types - chart events ride the agent
150
- stream and don't need any of that.
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