@mastra/client-js 1.45.1-alpha.0 → 1.46.0-alpha.3

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
@@ -2760,6 +2760,24 @@ var MemoryThread = class extends BaseResource {
2760
2760
  body
2761
2761
  });
2762
2762
  }
2763
+ /**
2764
+ * Transfers ownership of the thread (and all of its messages) to a different resource.
2765
+ *
2766
+ * This is a privileged operation: the server rejects it when the caller is resource-scoped
2767
+ * (i.e. a per-user/tenant context). Unlike `update`, it does not reset the thread's `createdAt`.
2768
+ * @param params - Transfer parameters including the target `resourceId`, optional `agentId`, and request context.
2769
+ * @returns Promise containing the transferred thread with its new `resourceId`
2770
+ */
2771
+ transfer(params) {
2772
+ const { agentId, requestContext, ...body } = params;
2773
+ const resolvedAgentId = agentId ?? this.agentId;
2774
+ const agentIdParam = resolvedAgentId ? `?agentId=${resolvedAgentId}` : "";
2775
+ const contextParam = requestContextQueryString(requestContext, agentIdParam ? "&" : "?");
2776
+ return this.request(`/memory/threads/${this.threadId}/transfer${agentIdParam}${contextParam}`, {
2777
+ method: "POST",
2778
+ body
2779
+ });
2780
+ }
2763
2781
  };
2764
2782
  /**
2765
2783
  * Backwards-compat helper: `deleteMessages` historically accepted a `RequestContext` (or plain
@@ -5914,6 +5932,7 @@ var AgentControllerSession = class extends BaseResource {
5914
5932
  while (!cancelled) {
5915
5933
  const { done, value } = await reader.read();
5916
5934
  if (done) return cancelled ? { kind: "cancelled" } : { kind: "done" };
5935
+ if (cancelled) return { kind: "cancelled" };
5917
5936
  buffer += decoder.decode(value, { stream: true });
5918
5937
  let separator;
5919
5938
  while ((separator = findFrameSeparator(buffer)) !== null) {
@@ -5929,6 +5948,7 @@ var AgentControllerSession = class extends BaseResource {
5929
5948
  } catch {
5930
5949
  continue;
5931
5950
  }
5951
+ if (cancelled) return { kind: "cancelled" };
5932
5952
  try {
5933
5953
  options.onEvent(event);
5934
5954
  } catch (cause) {
@@ -5981,6 +6001,7 @@ var AgentControllerSession = class extends BaseResource {
5981
6001
  let attempts = 0;
5982
6002
  let reconnectedResponse;
5983
6003
  while (!reconnectedResponse) {
6004
+ if (cancelled) return;
5984
6005
  if (attempts >= reconnectOptions.maxRetries) {
5985
6006
  reportTerminalError(result);
5986
6007
  return;
@@ -6005,6 +6026,10 @@ var AgentControllerSession = class extends BaseResource {
6005
6026
  try {
6006
6027
  options.onReconnect?.();
6007
6028
  } catch {}
6029
+ if (cancelled) {
6030
+ response.body?.cancel().catch(() => {});
6031
+ return;
6032
+ }
6008
6033
  }
6009
6034
  };
6010
6035
  run(firstResponse);
@@ -6310,6 +6335,25 @@ function agentControllerMessageText(message) {
6310
6335
  }
6311
6336
  //#endregion
6312
6337
  //#region src/client.ts
6338
+ /**
6339
+ * Provides typed access to agents, workflows, and other APIs on a running Mastra server.
6340
+ * Point `baseUrl` at your server and configure authentication when required.
6341
+ *
6342
+ * @example
6343
+ * ```typescript
6344
+ * import { MastraClient } from '@mastra/client-js';
6345
+ *
6346
+ * const client = new MastraClient({ baseUrl: 'http://localhost:4111' });
6347
+ * ```
6348
+ *
6349
+ * @see For documentation bundled with your installed package, locate
6350
+ * `@mastra/client-js/package.json` with your project's resolver or package-manager
6351
+ * tooling, then read `dist/docs/SKILL.md` from that package root and follow its
6352
+ * reference links. Use package-manager tools for virtual or archived packages.
6353
+ *
6354
+ * @see [Client documentation](https://mastra.ai/reference/client-js/mastra-client)
6355
+ * if packaged docs are unavailable.
6356
+ */
6313
6357
  var MastraClient = class extends BaseResource {
6314
6358
  observability;
6315
6359
  conversations;