@mastra/client-js 1.41.0-alpha.10 → 1.41.0-alpha.12
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 +48 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-client-js-agents.md +20 -0
- package/dist/index.cjs +31 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -6
- package/dist/index.js.map +1 -1
- package/dist/resources/agent-controller.d.ts +54 -194
- package/dist/resources/agent-controller.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +54 -21
- package/dist/route-types.generated.d.ts.map +1 -1
- package/dist/types.d.ts +21 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
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,37 @@ 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:
|
|
5708
|
+
createdAt: toDate(message.createdAt)
|
|
5701
5709
|
};
|
|
5702
5710
|
}
|
|
5703
|
-
function
|
|
5704
|
-
if (event.type !== "message_start" && event.type !== "message_update" && event.type !== "message_end") return event;
|
|
5711
|
+
function hydrateThread(thread) {
|
|
5705
5712
|
return {
|
|
5706
|
-
...
|
|
5707
|
-
|
|
5713
|
+
...thread,
|
|
5714
|
+
createdAt: toDate(thread.createdAt),
|
|
5715
|
+
updatedAt: toDate(thread.updatedAt)
|
|
5708
5716
|
};
|
|
5709
5717
|
}
|
|
5718
|
+
/** The stream carries every timestamp as an ISO string; give consumers back the `Date`s the type promises. */
|
|
5719
|
+
function hydrateEventTimestamps(event) {
|
|
5720
|
+
if (!isKnownAgentControllerEvent(event)) return event;
|
|
5721
|
+
switch (event.type) {
|
|
5722
|
+
case "message_start":
|
|
5723
|
+
case "message_update":
|
|
5724
|
+
case "message_end": return {
|
|
5725
|
+
...event,
|
|
5726
|
+
message: hydrateMessage(event.message)
|
|
5727
|
+
};
|
|
5728
|
+
case "thread_created": return {
|
|
5729
|
+
...event,
|
|
5730
|
+
thread: hydrateThread(event.thread)
|
|
5731
|
+
};
|
|
5732
|
+
default: return event;
|
|
5733
|
+
}
|
|
5734
|
+
}
|
|
5710
5735
|
/**
|
|
5711
5736
|
* A session bound to a `resourceId` within one agent controller. Sessions are
|
|
5712
5737
|
* get-or-create on the server, so re-creating the same resourceId (and scope)
|
|
@@ -5838,7 +5863,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
5838
5863
|
if (!data) continue;
|
|
5839
5864
|
let event;
|
|
5840
5865
|
try {
|
|
5841
|
-
event =
|
|
5866
|
+
event = hydrateEventTimestamps(JSON.parse(data));
|
|
5842
5867
|
} catch {
|
|
5843
5868
|
continue;
|
|
5844
5869
|
}
|