@mastra/client-js 1.41.0-alpha.9 → 1.41.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/dist/index.js CHANGED
@@ -5648,22 +5648,29 @@ const KNOWN_AGENT_CONTROLLER_EVENT_TYPES = new Set(Object.keys({
5648
5648
  message_start: true,
5649
5649
  message_update: true,
5650
5650
  message_end: true,
5651
+ state_changed: true,
5651
5652
  tool_input_start: true,
5652
5653
  tool_input_delta: true,
5653
5654
  tool_input_end: true,
5654
5655
  tool_start: true,
5655
5656
  tool_update: true,
5656
5657
  shell_output: true,
5658
+ command_exit: true,
5657
5659
  tool_end: true,
5658
5660
  tool_approval_required: true,
5659
5661
  tool_suspended: true,
5662
+ tool_suspension_cancelled: true,
5660
5663
  mode_changed: true,
5661
5664
  model_changed: true,
5662
5665
  thread_changed: true,
5663
5666
  thread_created: true,
5664
5667
  thread_deleted: true,
5665
5668
  subagent_start: true,
5669
+ subagent_text_delta: true,
5670
+ subagent_tool_start: true,
5671
+ subagent_tool_end: true,
5666
5672
  subagent_end: true,
5673
+ subagent_model_changed: true,
5667
5674
  task_updated: true,
5668
5675
  notification: true,
5669
5676
  notification_summary: true,
@@ -5694,19 +5701,42 @@ const KNOWN_AGENT_CONTROLLER_EVENT_TYPES = new Set(Object.keys({
5694
5701
  function isKnownAgentControllerEvent(event) {
5695
5702
  return KNOWN_AGENT_CONTROLLER_EVENT_TYPES.has(event.type);
5696
5703
  }
5704
+ const toDate = (value) => value instanceof Date ? value : new Date(value);
5697
5705
  function hydrateMessage(message) {
5698
5706
  return {
5699
5707
  ...message,
5700
- createdAt: message.createdAt instanceof Date ? message.createdAt : new Date(message.createdAt)
5708
+ createdAt: toDate(message.createdAt)
5701
5709
  };
5702
5710
  }
5703
- function hydrateEventMessage(event) {
5704
- if (event.type !== "message_start" && event.type !== "message_update" && event.type !== "message_end") return event;
5711
+ function hydrateThread(thread) {
5705
5712
  return {
5706
- ...event,
5707
- message: hydrateMessage(event.message)
5713
+ ...thread,
5714
+ createdAt: toDate(thread.createdAt),
5715
+ updatedAt: toDate(thread.updatedAt)
5708
5716
  };
5709
5717
  }
5718
+ function isKnownParsedEvent(event) {
5719
+ return KNOWN_AGENT_CONTROLLER_EVENT_TYPES.has(event.type);
5720
+ }
5721
+ /** The stream carries every timestamp as an ISO string; give consumers back the `Date`s {@link Hydrated} promises. */
5722
+ function hydrateKnownEvent(event) {
5723
+ switch (event.type) {
5724
+ case "message_start":
5725
+ case "message_update":
5726
+ case "message_end": return {
5727
+ ...event,
5728
+ message: hydrateMessage(event.message)
5729
+ };
5730
+ case "thread_created": return {
5731
+ ...event,
5732
+ thread: hydrateThread(event.thread)
5733
+ };
5734
+ default: return event;
5735
+ }
5736
+ }
5737
+ function hydrateEventTimestamps(event) {
5738
+ return isKnownParsedEvent(event) ? hydrateKnownEvent(event) : event;
5739
+ }
5710
5740
  /**
5711
5741
  * A session bound to a `resourceId` within one agent controller. Sessions are
5712
5742
  * get-or-create on the server, so re-creating the same resourceId (and scope)
@@ -5838,7 +5868,7 @@ var AgentControllerSession = class extends BaseResource {
5838
5868
  if (!data) continue;
5839
5869
  let event;
5840
5870
  try {
5841
- event = hydrateEventMessage(JSON.parse(data));
5871
+ event = hydrateEventTimestamps(JSON.parse(data));
5842
5872
  } catch {
5843
5873
  continue;
5844
5874
  }