@mastra/client-js 1.0.0-beta.3 → 1.0.0-beta.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.js CHANGED
@@ -1452,7 +1452,7 @@ var MemoryThread = class extends BaseResource {
1452
1452
  if (include) queryParams.include = JSON.stringify(include);
1453
1453
  const query = new URLSearchParams(queryParams);
1454
1454
  const queryString = query.toString();
1455
- const url = `/api/memory/threads/${this.threadId}/messages${queryString ? `?${queryString}` : ""}${requestContextQueryString(requestContext, queryString ? "&" : "?")}`;
1455
+ const url = `/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}${queryString ? `&${queryString}` : ""}${requestContextQueryString(requestContext, "&")}`;
1456
1456
  return this.request(url);
1457
1457
  }
1458
1458
  /**
@@ -2075,6 +2075,142 @@ var Workflow = class extends BaseResource {
2075
2075
  }
2076
2076
  });
2077
2077
  }
2078
+ /**
2079
+ * Restarts an active workflow run synchronously without waiting for the workflow to complete
2080
+ * @param params - Object containing the runId and requestContext
2081
+ * @returns Promise containing success message
2082
+ */
2083
+ restart(params) {
2084
+ const requestContext = parseClientRequestContext(params.requestContext);
2085
+ return this.request(`/api/workflows/${this.workflowId}/restart?runId=${params.runId}`, {
2086
+ method: "POST",
2087
+ body: {
2088
+ requestContext,
2089
+ tracingOptions: params.tracingOptions
2090
+ }
2091
+ });
2092
+ }
2093
+ /**
2094
+ * Restarts an active workflow run asynchronously
2095
+ * @param params - Object containing the runId and requestContext
2096
+ * @returns Promise containing the workflow restart results
2097
+ */
2098
+ restartAsync(params) {
2099
+ const requestContext = parseClientRequestContext(params.requestContext);
2100
+ return this.request(`/api/workflows/${this.workflowId}/restart-async?runId=${params.runId}`, {
2101
+ method: "POST",
2102
+ body: {
2103
+ requestContext,
2104
+ tracingOptions: params.tracingOptions
2105
+ }
2106
+ });
2107
+ }
2108
+ /**
2109
+ * Restart all active workflow runs synchronously without waiting for the workflow to complete
2110
+ * @returns Promise containing success message
2111
+ */
2112
+ restartAllActiveWorkflowRuns() {
2113
+ return this.request(`/api/workflows/${this.workflowId}/restart-all-active-workflow-runs`, {
2114
+ method: "POST"
2115
+ });
2116
+ }
2117
+ /**
2118
+ * Restart all active workflow runs asynchronously
2119
+ * @returns Promise containing success message
2120
+ */
2121
+ restartAllActiveWorkflowRunsAsync() {
2122
+ return this.request(`/api/workflows/${this.workflowId}/restart-all-active-workflow-runs-async`, {
2123
+ method: "POST"
2124
+ });
2125
+ }
2126
+ /**
2127
+ * Time travels a workflow run synchronously without waiting for the workflow to complete
2128
+ * @param params - Object containing the runId, step, inputData, resumeData, initialState, context, nestedStepsContext, requestContext and tracingOptions
2129
+ * @returns Promise containing success message
2130
+ */
2131
+ timeTravel({
2132
+ runId,
2133
+ requestContext: paramsRequestContext,
2134
+ ...params
2135
+ }) {
2136
+ const requestContext = parseClientRequestContext(paramsRequestContext);
2137
+ return this.request(`/api/workflows/${this.workflowId}/time-travel?runId=${runId}`, {
2138
+ method: "POST",
2139
+ body: {
2140
+ ...params,
2141
+ requestContext
2142
+ }
2143
+ });
2144
+ }
2145
+ /**
2146
+ * Time travels a workflow run asynchronously
2147
+ * @param params - Object containing the runId, step, inputData, resumeData, initialState, context, nestedStepsContext, requestContext and tracingOptions
2148
+ * @returns Promise containing the workflow time travel results
2149
+ */
2150
+ timeTravelAsync({
2151
+ runId,
2152
+ requestContext: paramsRequestContext,
2153
+ ...params
2154
+ }) {
2155
+ const requestContext = parseClientRequestContext(paramsRequestContext);
2156
+ return this.request(`/api/workflows/${this.workflowId}/time-travel-async?runId=${runId}`, {
2157
+ method: "POST",
2158
+ body: {
2159
+ ...params,
2160
+ requestContext
2161
+ }
2162
+ });
2163
+ }
2164
+ /**
2165
+ * Time travels a workflow run and returns a stream
2166
+ * @param params - Object containing the runId, step, inputData, resumeData, initialState, context, nestedStepsContext, requestContext and tracingOptions
2167
+ * @returns Promise containing the workflow execution results
2168
+ */
2169
+ async timeTravelStream({ runId, requestContext: paramsRequestContext, ...params }) {
2170
+ const requestContext = parseClientRequestContext(paramsRequestContext);
2171
+ const response = await this.request(
2172
+ `/api/workflows/${this.workflowId}/time-travel-stream?runId=${runId}`,
2173
+ {
2174
+ method: "POST",
2175
+ body: {
2176
+ ...params,
2177
+ requestContext
2178
+ },
2179
+ stream: true
2180
+ }
2181
+ );
2182
+ if (!response.ok) {
2183
+ throw new Error(`Failed to time travel workflow: ${response.statusText}`);
2184
+ }
2185
+ if (!response.body) {
2186
+ throw new Error("Response body is null");
2187
+ }
2188
+ let failedChunk = void 0;
2189
+ const transformStream = new TransformStream({
2190
+ start() {
2191
+ },
2192
+ async transform(chunk, controller) {
2193
+ try {
2194
+ const decoded = new TextDecoder().decode(chunk);
2195
+ const chunks = decoded.split(RECORD_SEPARATOR);
2196
+ for (const chunk2 of chunks) {
2197
+ if (chunk2) {
2198
+ const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
2199
+ try {
2200
+ const parsedChunk = JSON.parse(newChunk);
2201
+ controller.enqueue(parsedChunk);
2202
+ failedChunk = void 0;
2203
+ } catch {
2204
+ failedChunk = newChunk;
2205
+ }
2206
+ }
2207
+ }
2208
+ } catch {
2209
+ }
2210
+ }
2211
+ });
2212
+ return response.body.pipeThrough(transformStream);
2213
+ }
2078
2214
  };
2079
2215
 
2080
2216
  // src/resources/a2a.ts