@mastra/client-js 1.28.1-alpha.3 → 1.29.0-alpha.10
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 +155 -0
- package/dist/client.d.ts +50 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-agents-heartbeats.md +211 -0
- package/dist/docs/references/reference-client-js-agents.md +21 -0
- package/dist/index.cjs +111 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +111 -5
- package/dist/index.js.map +1 -1
- package/dist/resources/agent.d.ts +11 -1
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +844 -6
- package/dist/route-types.generated.d.ts.map +1 -1
- package/dist/types.d.ts +115 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2333,6 +2333,26 @@ var Agent = class extends BaseResource {
|
|
|
2333
2333
|
};
|
|
2334
2334
|
return streamResponse;
|
|
2335
2335
|
}
|
|
2336
|
+
/**
|
|
2337
|
+
* Lists suspended runs for this agent from storage — runs waiting on a
|
|
2338
|
+
* tool-call approval or on a tool that suspended. Backed by storage, so it
|
|
2339
|
+
* works after a server restart and across server instances. Pass the
|
|
2340
|
+
* returned runId to approveToolCall(), declineToolCall(), or resumeStream().
|
|
2341
|
+
* @param params - Optional filters (threadId, resourceId, fromDate, toDate) and pagination (perPage, page)
|
|
2342
|
+
* @param requestContext - Optional request context
|
|
2343
|
+
* @returns Promise containing the matching runs and the total count before pagination
|
|
2344
|
+
*/
|
|
2345
|
+
async listSuspendedRuns(params, requestContext) {
|
|
2346
|
+
const searchParams = new URLSearchParams(requestContextQueryString(requestContext).slice(1));
|
|
2347
|
+
if (params?.threadId) searchParams.set("threadId", params.threadId);
|
|
2348
|
+
if (params?.resourceId) searchParams.set("resourceId", params.resourceId);
|
|
2349
|
+
if (params?.fromDate) searchParams.set("fromDate", params.fromDate.toISOString());
|
|
2350
|
+
if (params?.toDate) searchParams.set("toDate", params.toDate.toISOString());
|
|
2351
|
+
if (params?.perPage !== void 0) searchParams.set("perPage", String(params.perPage));
|
|
2352
|
+
if (params?.page !== void 0) searchParams.set("page", String(params.page));
|
|
2353
|
+
const query = searchParams.size ? `?${searchParams}` : "";
|
|
2354
|
+
return this.request(`/agents/${this.agentId}/suspended-runs${query}`);
|
|
2355
|
+
}
|
|
2336
2356
|
async approveToolCall(params) {
|
|
2337
2357
|
const { requestContext, ...rest } = params;
|
|
2338
2358
|
const processedParams = { ...rest, requestContext: parseClientRequestContext(requestContext) };
|
|
@@ -6704,10 +6724,10 @@ var MastraClient = class extends BaseResource {
|
|
|
6704
6724
|
if (logLevel) {
|
|
6705
6725
|
searchParams.set("logLevel", logLevel);
|
|
6706
6726
|
}
|
|
6707
|
-
if (page) {
|
|
6727
|
+
if (page !== void 0) {
|
|
6708
6728
|
searchParams.set("page", String(page));
|
|
6709
6729
|
}
|
|
6710
|
-
if (perPage) {
|
|
6730
|
+
if (perPage !== void 0) {
|
|
6711
6731
|
searchParams.set("perPage", String(perPage));
|
|
6712
6732
|
}
|
|
6713
6733
|
if (_filters) {
|
|
@@ -6749,10 +6769,10 @@ var MastraClient = class extends BaseResource {
|
|
|
6749
6769
|
if (logLevel) {
|
|
6750
6770
|
searchParams.set("logLevel", logLevel);
|
|
6751
6771
|
}
|
|
6752
|
-
if (page) {
|
|
6772
|
+
if (page !== void 0) {
|
|
6753
6773
|
searchParams.set("page", String(page));
|
|
6754
6774
|
}
|
|
6755
|
-
if (perPage) {
|
|
6775
|
+
if (perPage !== void 0) {
|
|
6756
6776
|
searchParams.set("perPage", String(perPage));
|
|
6757
6777
|
}
|
|
6758
6778
|
if (_filters) {
|
|
@@ -7994,12 +8014,14 @@ var MastraClient = class extends BaseResource {
|
|
|
7994
8014
|
);
|
|
7995
8015
|
}
|
|
7996
8016
|
/**
|
|
7997
|
-
* Lists
|
|
8017
|
+
* Lists schedules with optional filtering by workflowId, status, ownerType, or ownerId.
|
|
7998
8018
|
*/
|
|
7999
8019
|
listSchedules(params = {}) {
|
|
8000
8020
|
const searchParams = new URLSearchParams();
|
|
8001
8021
|
if (params.workflowId) searchParams.set("workflowId", params.workflowId);
|
|
8002
8022
|
if (params.status) searchParams.set("status", params.status);
|
|
8023
|
+
if (params.ownerType) searchParams.set("ownerType", params.ownerType);
|
|
8024
|
+
if (params.ownerId) searchParams.set("ownerId", params.ownerId);
|
|
8003
8025
|
const qs = searchParams.toString();
|
|
8004
8026
|
return this.request(`/schedules${qs ? `?${qs}` : ""}`);
|
|
8005
8027
|
}
|
|
@@ -8036,6 +8058,90 @@ var MastraClient = class extends BaseResource {
|
|
|
8036
8058
|
resumeSchedule(scheduleId) {
|
|
8037
8059
|
return this.request(`/schedules/${encodeURIComponent(scheduleId)}/resume`, { method: "POST" });
|
|
8038
8060
|
}
|
|
8061
|
+
/**
|
|
8062
|
+
* Lists heartbeats across all agents. Pass `agentId` to scope the list to
|
|
8063
|
+
* a single agent. Filter further by `threadId`, `resourceId`, or `name`.
|
|
8064
|
+
*/
|
|
8065
|
+
listHeartbeats(params = {}) {
|
|
8066
|
+
const searchParams = new URLSearchParams();
|
|
8067
|
+
if (params.agentId) searchParams.set("agentId", params.agentId);
|
|
8068
|
+
if (params.threadId) searchParams.set("threadId", params.threadId);
|
|
8069
|
+
if (params.resourceId) searchParams.set("resourceId", params.resourceId);
|
|
8070
|
+
if (params.name) searchParams.set("name", params.name);
|
|
8071
|
+
const qs = searchParams.toString();
|
|
8072
|
+
return this.request(`/heartbeats${qs ? `?${qs}` : ""}`).then(
|
|
8073
|
+
(response) => response.heartbeats
|
|
8074
|
+
);
|
|
8075
|
+
}
|
|
8076
|
+
/**
|
|
8077
|
+
* Gets a single heartbeat by id.
|
|
8078
|
+
*/
|
|
8079
|
+
getHeartbeat(heartbeatId) {
|
|
8080
|
+
return this.request(`/heartbeats/${encodeURIComponent(heartbeatId)}`);
|
|
8081
|
+
}
|
|
8082
|
+
/**
|
|
8083
|
+
* Creates a heartbeat for the agent named by `agentId`. By default each call
|
|
8084
|
+
* creates a new heartbeat with a random `hb_<uuid>` id — multiple heartbeats
|
|
8085
|
+
* per agent/thread are supported. Use `name` to label distinct heartbeats.
|
|
8086
|
+
* Pass `id` to choose a stable id (normalized to `hb_<slug>`); creating one
|
|
8087
|
+
* with an id that already exists throws.
|
|
8088
|
+
*
|
|
8089
|
+
* Trigger (fire) history is read through the generic schedules surface:
|
|
8090
|
+
* `listScheduleTriggers(heartbeat.id)`.
|
|
8091
|
+
*/
|
|
8092
|
+
createHeartbeat(options) {
|
|
8093
|
+
return this.request(`/heartbeats`, {
|
|
8094
|
+
method: "POST",
|
|
8095
|
+
body: options
|
|
8096
|
+
});
|
|
8097
|
+
}
|
|
8098
|
+
/**
|
|
8099
|
+
* Patches an existing heartbeat. `threadId` / `resourceId` are immutable —
|
|
8100
|
+
* to retarget, delete and recreate.
|
|
8101
|
+
*/
|
|
8102
|
+
updateHeartbeat(heartbeatId, patch) {
|
|
8103
|
+
return this.request(`/heartbeats/${encodeURIComponent(heartbeatId)}`, {
|
|
8104
|
+
method: "PATCH",
|
|
8105
|
+
body: patch
|
|
8106
|
+
});
|
|
8107
|
+
}
|
|
8108
|
+
/**
|
|
8109
|
+
* Deletes a heartbeat.
|
|
8110
|
+
*/
|
|
8111
|
+
deleteHeartbeat(heartbeatId) {
|
|
8112
|
+
return this.request(`/heartbeats/${encodeURIComponent(heartbeatId)}`, {
|
|
8113
|
+
method: "DELETE"
|
|
8114
|
+
});
|
|
8115
|
+
}
|
|
8116
|
+
/**
|
|
8117
|
+
* Pauses a heartbeat. Idempotent — pausing an already-paused heartbeat
|
|
8118
|
+
* returns the current state unchanged.
|
|
8119
|
+
*/
|
|
8120
|
+
pauseHeartbeat(heartbeatId) {
|
|
8121
|
+
return this.request(`/heartbeats/${encodeURIComponent(heartbeatId)}/pause`, {
|
|
8122
|
+
method: "POST"
|
|
8123
|
+
});
|
|
8124
|
+
}
|
|
8125
|
+
/**
|
|
8126
|
+
* Resumes a paused heartbeat. Recomputes nextFireAt from "now" so a
|
|
8127
|
+
* long-paused heartbeat does not fire a backlog. Idempotent.
|
|
8128
|
+
*/
|
|
8129
|
+
resumeHeartbeat(heartbeatId) {
|
|
8130
|
+
return this.request(`/heartbeats/${encodeURIComponent(heartbeatId)}/resume`, {
|
|
8131
|
+
method: "POST"
|
|
8132
|
+
});
|
|
8133
|
+
}
|
|
8134
|
+
/**
|
|
8135
|
+
* Fires a heartbeat manually, out-of-band from the cron schedule. Behaves
|
|
8136
|
+
* like a scheduled fire (honoring `ifActive` / `ifIdle`) but
|
|
8137
|
+
* does not advance `nextFireAt`. The returned `claimId` is the trigger row's
|
|
8138
|
+
* runId — look it up via `listScheduleTriggers(heartbeatId)`.
|
|
8139
|
+
*/
|
|
8140
|
+
runHeartbeat(heartbeatId) {
|
|
8141
|
+
return this.request(`/heartbeats/${encodeURIComponent(heartbeatId)}/run`, {
|
|
8142
|
+
method: "POST"
|
|
8143
|
+
});
|
|
8144
|
+
}
|
|
8039
8145
|
};
|
|
8040
8146
|
|
|
8041
8147
|
// src/tools.ts
|