@mastra/client-js 1.41.0-alpha.13 → 1.41.0-alpha.14

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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 1.41.0-alpha.14
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed the agent controller event types to match what the server actually sends. `KnownAgentControllerEvent` is now derived from the wire type `@mastra/core` exports instead of a hand-written copy: the `display_state_changed` fields are no longer all optional, and the `error` event no longer claims its `error` may be a bare string. Runtime behavior is unchanged; only fallbacks written for those two type gaps become unnecessary. ([#21761](https://github.com/mastra-ai/mastra/pull/21761))
8
+
9
+ ```ts
10
+ import type { KnownAgentControllerEvent } from '@mastra/client-js';
11
+
12
+ function onEvent(event: KnownAgentControllerEvent) {
13
+ if (event.type === 'display_state_changed') {
14
+ // before: event.displayState.isRunning ?? false
15
+ const running = event.displayState.isRunning;
16
+ }
17
+ if (event.type === 'error') {
18
+ // before: typeof event.error === 'string' ? event.error : event.error.message
19
+ const message = event.error.message;
20
+ }
21
+ }
22
+ ```
23
+
24
+ - Updated dependencies [[`58c43d3`](https://github.com/mastra-ai/mastra/commit/58c43d3f7cb2eeaeb8ac733ae71dde822348e588)]:
25
+ - @mastra/core@1.60.0-alpha.14
26
+
3
27
  ## 1.41.0-alpha.13
4
28
 
5
29
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-client-js
3
3
  description: Documentation for @mastra/client-js. Use when working with @mastra/client-js APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/client-js"
6
- version: "1.41.0-alpha.13"
6
+ version: "1.41.0-alpha.14"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.41.0-alpha.13",
2
+ "version": "1.41.0-alpha.14",
3
3
  "package": "@mastra/client-js",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -44,7 +44,7 @@ export default function Chat() {
44
44
 
45
45
  **messages** (`MessageListInput`): Messages to convert. Can be a string, array of strings, a single message object, or an array of message objects in any supported format.
46
46
 
47
- **options.version** (`'v5' | 'v6'`): Selects the AI SDK message type to return. Omit it or pass 'v5' for the existing default behavior. Pass 'v6' when your app is typed against AI SDK v6 useChat() message types.
47
+ **options.version** (`'v5' | 'v6' | 'v7'`): Selects the AI SDK message type to return. Omit it or pass 'v5' for the existing default behavior. Pass 'v6' when your app is typed against AI SDK v6 useChat() message types. Pass 'v7' when your app is typed against AI SDK v7.
48
48
 
49
49
  ## Returns
50
50
 
@@ -64,7 +64,7 @@ The first parameter is the Mastra stream to convert. It can be one of:
64
64
 
65
65
  The second parameter is an options object:
66
66
 
67
- **version** (`'v5' | 'v6'`): Selects the AI SDK stream contract to emit. Omit it or pass 'v5' for the existing default behavior. Pass 'v6' when your app is typed against AI SDK v6 response helpers. (Default: `'v5'`)
67
+ **version** (`'v5' | 'v6' | 'v7'`): Selects the AI SDK stream contract to emit. Omit it or pass 'v5' for the existing default behavior. Pass 'v6' when your app is typed against AI SDK v6 response helpers. Pass 'v7' when your app is typed against AI SDK v7. (Default: `'v5'`)
68
68
 
69
69
  **from** (`'agent' | 'network' | 'workflow'`): The type of Mastra stream being converted. (Default: `'agent'`)
70
70
 
package/dist/index.cjs CHANGED
@@ -5739,9 +5739,11 @@ function hydrateThread(thread) {
5739
5739
  updatedAt: toDate(thread.updatedAt)
5740
5740
  };
5741
5741
  }
5742
- /** The stream carries every timestamp as an ISO string; give consumers back the `Date`s the type promises. */
5743
- function hydrateEventTimestamps(event) {
5744
- if (!isKnownAgentControllerEvent(event)) return event;
5742
+ function isKnownParsedEvent(event) {
5743
+ return KNOWN_AGENT_CONTROLLER_EVENT_TYPES.has(event.type);
5744
+ }
5745
+ /** The stream carries every timestamp as an ISO string; give consumers back the `Date`s {@link Hydrated} promises. */
5746
+ function hydrateKnownEvent(event) {
5745
5747
  switch (event.type) {
5746
5748
  case "message_start":
5747
5749
  case "message_update":
@@ -5756,6 +5758,9 @@ function hydrateEventTimestamps(event) {
5756
5758
  default: return event;
5757
5759
  }
5758
5760
  }
5761
+ function hydrateEventTimestamps(event) {
5762
+ return isKnownParsedEvent(event) ? hydrateKnownEvent(event) : event;
5763
+ }
5759
5764
  /**
5760
5765
  * A session bound to a `resourceId` within one agent controller. Sessions are
5761
5766
  * get-or-create on the server, so re-creating the same resourceId (and scope)