@mastra/client-js 1.28.1-alpha.4 → 1.29.0-alpha.5

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.cjs CHANGED
@@ -2338,6 +2338,26 @@ var Agent = class extends BaseResource {
2338
2338
  };
2339
2339
  return streamResponse;
2340
2340
  }
2341
+ /**
2342
+ * Lists suspended runs for this agent from storage — runs waiting on a
2343
+ * tool-call approval or on a tool that suspended. Backed by storage, so it
2344
+ * works after a server restart and across server instances. Pass the
2345
+ * returned runId to approveToolCall(), declineToolCall(), or resumeStream().
2346
+ * @param params - Optional filters (threadId, resourceId, fromDate, toDate) and pagination (perPage, page)
2347
+ * @param requestContext - Optional request context
2348
+ * @returns Promise containing the matching runs and the total count before pagination
2349
+ */
2350
+ async listSuspendedRuns(params, requestContext) {
2351
+ const searchParams = new URLSearchParams(requestContextQueryString(requestContext).slice(1));
2352
+ if (params?.threadId) searchParams.set("threadId", params.threadId);
2353
+ if (params?.resourceId) searchParams.set("resourceId", params.resourceId);
2354
+ if (params?.fromDate) searchParams.set("fromDate", params.fromDate.toISOString());
2355
+ if (params?.toDate) searchParams.set("toDate", params.toDate.toISOString());
2356
+ if (params?.perPage !== void 0) searchParams.set("perPage", String(params.perPage));
2357
+ if (params?.page !== void 0) searchParams.set("page", String(params.page));
2358
+ const query = searchParams.size ? `?${searchParams}` : "";
2359
+ return this.request(`/agents/${this.agentId}/suspended-runs${query}`);
2360
+ }
2341
2361
  async approveToolCall(params) {
2342
2362
  const { requestContext, ...rest } = params;
2343
2363
  const processedParams = { ...rest, requestContext: parseClientRequestContext(requestContext) };
@@ -7999,12 +8019,14 @@ var MastraClient = class extends BaseResource {
7999
8019
  );
8000
8020
  }
8001
8021
  /**
8002
- * Lists workflow schedules with optional filtering by workflowId or status.
8022
+ * Lists schedules with optional filtering by workflowId, status, ownerType, or ownerId.
8003
8023
  */
8004
8024
  listSchedules(params = {}) {
8005
8025
  const searchParams = new URLSearchParams();
8006
8026
  if (params.workflowId) searchParams.set("workflowId", params.workflowId);
8007
8027
  if (params.status) searchParams.set("status", params.status);
8028
+ if (params.ownerType) searchParams.set("ownerType", params.ownerType);
8029
+ if (params.ownerId) searchParams.set("ownerId", params.ownerId);
8008
8030
  const qs = searchParams.toString();
8009
8031
  return this.request(`/schedules${qs ? `?${qs}` : ""}`);
8010
8032
  }
@@ -8041,6 +8063,90 @@ var MastraClient = class extends BaseResource {
8041
8063
  resumeSchedule(scheduleId) {
8042
8064
  return this.request(`/schedules/${encodeURIComponent(scheduleId)}/resume`, { method: "POST" });
8043
8065
  }
8066
+ /**
8067
+ * Lists heartbeats across all agents. Pass `agentId` to scope the list to
8068
+ * a single agent. Filter further by `threadId`, `resourceId`, or `name`.
8069
+ */
8070
+ listHeartbeats(params = {}) {
8071
+ const searchParams = new URLSearchParams();
8072
+ if (params.agentId) searchParams.set("agentId", params.agentId);
8073
+ if (params.threadId) searchParams.set("threadId", params.threadId);
8074
+ if (params.resourceId) searchParams.set("resourceId", params.resourceId);
8075
+ if (params.name) searchParams.set("name", params.name);
8076
+ const qs = searchParams.toString();
8077
+ return this.request(`/heartbeats${qs ? `?${qs}` : ""}`).then(
8078
+ (response) => response.heartbeats
8079
+ );
8080
+ }
8081
+ /**
8082
+ * Gets a single heartbeat by id.
8083
+ */
8084
+ getHeartbeat(heartbeatId) {
8085
+ return this.request(`/heartbeats/${encodeURIComponent(heartbeatId)}`);
8086
+ }
8087
+ /**
8088
+ * Creates a heartbeat for the agent named by `agentId`. By default each call
8089
+ * creates a new heartbeat with a random `hb_<uuid>` id — multiple heartbeats
8090
+ * per agent/thread are supported. Use `name` to label distinct heartbeats.
8091
+ * Pass `id` to choose a stable id (normalized to `hb_<slug>`); creating one
8092
+ * with an id that already exists throws.
8093
+ *
8094
+ * Trigger (fire) history is read through the generic schedules surface:
8095
+ * `listScheduleTriggers(heartbeat.id)`.
8096
+ */
8097
+ createHeartbeat(options) {
8098
+ return this.request(`/heartbeats`, {
8099
+ method: "POST",
8100
+ body: options
8101
+ });
8102
+ }
8103
+ /**
8104
+ * Patches an existing heartbeat. `threadId` / `resourceId` are immutable —
8105
+ * to retarget, delete and recreate.
8106
+ */
8107
+ updateHeartbeat(heartbeatId, patch) {
8108
+ return this.request(`/heartbeats/${encodeURIComponent(heartbeatId)}`, {
8109
+ method: "PATCH",
8110
+ body: patch
8111
+ });
8112
+ }
8113
+ /**
8114
+ * Deletes a heartbeat.
8115
+ */
8116
+ deleteHeartbeat(heartbeatId) {
8117
+ return this.request(`/heartbeats/${encodeURIComponent(heartbeatId)}`, {
8118
+ method: "DELETE"
8119
+ });
8120
+ }
8121
+ /**
8122
+ * Pauses a heartbeat. Idempotent — pausing an already-paused heartbeat
8123
+ * returns the current state unchanged.
8124
+ */
8125
+ pauseHeartbeat(heartbeatId) {
8126
+ return this.request(`/heartbeats/${encodeURIComponent(heartbeatId)}/pause`, {
8127
+ method: "POST"
8128
+ });
8129
+ }
8130
+ /**
8131
+ * Resumes a paused heartbeat. Recomputes nextFireAt from "now" so a
8132
+ * long-paused heartbeat does not fire a backlog. Idempotent.
8133
+ */
8134
+ resumeHeartbeat(heartbeatId) {
8135
+ return this.request(`/heartbeats/${encodeURIComponent(heartbeatId)}/resume`, {
8136
+ method: "POST"
8137
+ });
8138
+ }
8139
+ /**
8140
+ * Fires a heartbeat manually, out-of-band from the cron schedule. Behaves
8141
+ * like a scheduled fire (honoring `ifActive` / `ifIdle`) but
8142
+ * does not advance `nextFireAt`. The returned `claimId` is the trigger row's
8143
+ * runId — look it up via `listScheduleTriggers(heartbeatId)`.
8144
+ */
8145
+ runHeartbeat(heartbeatId) {
8146
+ return this.request(`/heartbeats/${encodeURIComponent(heartbeatId)}/run`, {
8147
+ method: "POST"
8148
+ });
8149
+ }
8044
8150
  };
8045
8151
 
8046
8152
  // src/tools.ts