@mastra/client-js 1.20.0-alpha.0 → 1.20.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/dist/index.js CHANGED
@@ -444,6 +444,34 @@ var Agent = class extends BaseResource {
444
444
  details(requestContext) {
445
445
  return this.request(`/agents/${this.agentId}${this.getQueryString(requestContext)}`);
446
446
  }
447
+ /**
448
+ * Probe the agent's browser session state before opening a screencast WebSocket.
449
+ *
450
+ * Returns `{ hasSession, screencastAvailable }`. Use this to avoid opening a WS
451
+ * that would either fail (screencast packages not installed) or sit idle (no
452
+ * active browser session yet). See {@link GetAgentBrowserSessionResponse}.
453
+ *
454
+ * @param threadId - Optional thread ID for thread-scoped browser sessions
455
+ */
456
+ browserSession(threadId) {
457
+ const query = threadId ? `?threadId=${encodeURIComponent(threadId)}` : "";
458
+ return this.request(`/agents/${this.agentId}/browser/session${query}`);
459
+ }
460
+ /**
461
+ * Close the agent's browser session.
462
+ *
463
+ * For thread-scoped browsers, pass `threadId` to close only that thread's
464
+ * session. Omit it to close the shared session (or all sessions for the agent
465
+ * depending on the toolset's scope).
466
+ *
467
+ * @param threadId - Optional thread ID for thread-scoped browser sessions
468
+ */
469
+ closeBrowser(threadId) {
470
+ return this.request(`/agents/${this.agentId}/browser/close`, {
471
+ method: "POST",
472
+ body: { threadId }
473
+ });
474
+ }
447
475
  enhanceInstructions(instructions, comment) {
448
476
  return this.request(`/agents/${this.agentId}/instructions/enhance`, {
449
477
  method: "POST",
@@ -1356,6 +1384,7 @@ var Agent = class extends BaseResource {
1356
1384
  }
1357
1385
  const newMessages = lastMessage != null ? [...messages.filter((m) => m.id !== lastMessage.id), lastMessage] : [...messages];
1358
1386
  const updatedMessages = threadId ? newMessages : [...Array.isArray(processedParams.messages) ? processedParams.messages : [], ...newMessages];
1387
+ const recursionRoute = route === "resume-stream" ? "stream" : route === "resume-stream-until-idle" ? "stream-until-idle" : route;
1359
1388
  try {
1360
1389
  await this.processStreamResponse(
1361
1390
  {
@@ -1363,7 +1392,7 @@ var Agent = class extends BaseResource {
1363
1392
  messages: updatedMessages
1364
1393
  },
1365
1394
  controller,
1366
- route
1395
+ recursionRoute
1367
1396
  );
1368
1397
  } catch (error) {
1369
1398
  console.error("Error processing recursive stream response:", error);
@@ -4040,6 +4069,37 @@ var StoredAgent = class extends BaseResource {
4040
4069
  );
4041
4070
  }
4042
4071
  // ==========================================================================
4072
+ // Favorite Methods (EE feature)
4073
+ // ==========================================================================
4074
+ /**
4075
+ * Favorites this agent for the calling user. Idempotent.
4076
+ * Requires the `agent.favorites` builder feature flag to be enabled on the server.
4077
+ * @param requestContext - Optional request context to pass as query parameter
4078
+ * @returns Promise containing the new favorited state and updated favorite count
4079
+ */
4080
+ favorite(requestContext) {
4081
+ return this.request(
4082
+ `/stored/agents/${encodeURIComponent(this.storedAgentId)}/favorite${requestContextQueryString(requestContext)}`,
4083
+ {
4084
+ method: "PUT"
4085
+ }
4086
+ );
4087
+ }
4088
+ /**
4089
+ * Unfavorites this agent for the calling user. Idempotent.
4090
+ * Requires the `agent.favorites` builder feature flag to be enabled on the server.
4091
+ * @param requestContext - Optional request context to pass as query parameter
4092
+ * @returns Promise containing the new favorited state and updated favorite count
4093
+ */
4094
+ unfavorite(requestContext) {
4095
+ return this.request(
4096
+ `/stored/agents/${encodeURIComponent(this.storedAgentId)}/favorite${requestContextQueryString(requestContext)}`,
4097
+ {
4098
+ method: "DELETE"
4099
+ }
4100
+ );
4101
+ }
4102
+ // ==========================================================================
4043
4103
  // Version Methods
4044
4104
  // ==========================================================================
4045
4105
  /**
@@ -4857,6 +4917,30 @@ var StoredSkill = class extends BaseResource {
4857
4917
  }
4858
4918
  );
4859
4919
  }
4920
+ /**
4921
+ * Favorites this skill for the calling user. Idempotent.
4922
+ * Requires the `skill.favorites` builder feature flag to be enabled on the server.
4923
+ */
4924
+ favorite(requestContext) {
4925
+ return this.request(
4926
+ `/stored/skills/${encodeURIComponent(this.storedSkillId)}/favorite${requestContextQueryString(requestContext)}`,
4927
+ {
4928
+ method: "PUT"
4929
+ }
4930
+ );
4931
+ }
4932
+ /**
4933
+ * Unfavorites this skill for the calling user. Idempotent.
4934
+ * Requires the `skill.favorites` builder feature flag to be enabled on the server.
4935
+ */
4936
+ unfavorite(requestContext) {
4937
+ return this.request(
4938
+ `/stored/skills/${encodeURIComponent(this.storedSkillId)}/favorite${requestContextQueryString(requestContext)}`,
4939
+ {
4940
+ method: "DELETE"
4941
+ }
4942
+ );
4943
+ }
4860
4944
  };
4861
4945
 
4862
4946
  // src/resources/responses.ts
@@ -5862,12 +5946,24 @@ var MastraClient = class extends BaseResource {
5862
5946
  searchParams.set("orderBy[direction]", params.orderBy.direction);
5863
5947
  }
5864
5948
  }
5949
+ if (params?.status) {
5950
+ searchParams.set("status", params.status);
5951
+ }
5865
5952
  if (params?.authorId) {
5866
5953
  searchParams.set("authorId", params.authorId);
5867
5954
  }
5955
+ if (params?.visibility) {
5956
+ searchParams.set("visibility", params.visibility);
5957
+ }
5868
5958
  if (params?.metadata) {
5869
5959
  searchParams.set("metadata", JSON.stringify(params.metadata));
5870
5960
  }
5961
+ if (params?.favoritedOnly) {
5962
+ searchParams.set("favoritedOnly", "true");
5963
+ }
5964
+ if (params?.pinFavoritedFor) {
5965
+ searchParams.set("pinFavoritedFor", params.pinFavoritedFor);
5966
+ }
5871
5967
  const queryString = searchParams.toString();
5872
5968
  return this.request(`/stored/agents${queryString ? `?${queryString}` : ""}`);
5873
5969
  }
@@ -6076,9 +6172,18 @@ var MastraClient = class extends BaseResource {
6076
6172
  if (params?.authorId) {
6077
6173
  searchParams.set("authorId", params.authorId);
6078
6174
  }
6175
+ if (params?.visibility) {
6176
+ searchParams.set("visibility", params.visibility);
6177
+ }
6079
6178
  if (params?.metadata) {
6080
6179
  searchParams.set("metadata", JSON.stringify(params.metadata));
6081
6180
  }
6181
+ if (params?.favoritedOnly) {
6182
+ searchParams.set("favoritedOnly", "true");
6183
+ }
6184
+ if (params?.pinFavoritedFor) {
6185
+ searchParams.set("pinFavoritedFor", params.pinFavoritedFor);
6186
+ }
6082
6187
  const queryString = searchParams.toString();
6083
6188
  return this.request(`/stored/skills${queryString ? `?${queryString}` : ""}`);
6084
6189
  }
@@ -6148,6 +6253,80 @@ var MastraClient = class extends BaseResource {
6148
6253
  return this.request("/system/packages");
6149
6254
  }
6150
6255
  // ============================================================================
6256
+ // Editor / Builder
6257
+ // ============================================================================
6258
+ /**
6259
+ * Retrieves agent builder settings for UI gating.
6260
+ * Returns feature flags and configuration set by admin.
6261
+ * @returns Promise containing builder settings
6262
+ */
6263
+ getBuilderSettings() {
6264
+ return this.request("/editor/builder/settings");
6265
+ }
6266
+ /**
6267
+ * Retrieves Agent Builder infrastructure configuration and resolution status.
6268
+ * Requires `infrastructure:read` permission.
6269
+ * @returns Promise containing infrastructure status
6270
+ */
6271
+ getInfrastructureStatus() {
6272
+ return this.request("/editor/builder/infrastructure");
6273
+ }
6274
+ /**
6275
+ * Lists known skill registries surfaced by the Agent Builder config.
6276
+ * Each entry reports whether the registry is enabled. Disabled or unknown
6277
+ * registries return 404 from registry-scoped routes.
6278
+ * Requires `stored-skills:read` permission.
6279
+ */
6280
+ listBuilderRegistries() {
6281
+ return this.request("/editor/builder/registries");
6282
+ }
6283
+ /**
6284
+ * Search a builder skill registry. The registry must be enabled or the
6285
+ * server returns 404.
6286
+ * Requires `stored-skills:read` permission.
6287
+ */
6288
+ searchBuilderRegistry(registryId, params) {
6289
+ const search = new URLSearchParams({ q: params.q });
6290
+ if (params.limit !== void 0) search.set("limit", String(params.limit));
6291
+ return this.request(`/editor/builder/registries/${encodeURIComponent(registryId)}/search?${search.toString()}`);
6292
+ }
6293
+ /**
6294
+ * Fetch the popular skills feed from a builder skill registry.
6295
+ * Requires `stored-skills:read` permission.
6296
+ */
6297
+ getBuilderRegistryPopular(registryId, params) {
6298
+ const search = new URLSearchParams();
6299
+ if (params?.limit !== void 0) search.set("limit", String(params.limit));
6300
+ if (params?.offset !== void 0) search.set("offset", String(params.offset));
6301
+ const query = search.toString();
6302
+ return this.request(
6303
+ `/editor/builder/registries/${encodeURIComponent(registryId)}/popular${query ? `?${query}` : ""}`
6304
+ );
6305
+ }
6306
+ /**
6307
+ * Fetch the rendered preview content for a single registry skill.
6308
+ * Requires `stored-skills:read` permission.
6309
+ */
6310
+ getBuilderRegistryPreview(registryId, params) {
6311
+ const search = new URLSearchParams({
6312
+ owner: params.owner,
6313
+ repo: params.repo,
6314
+ path: params.path
6315
+ });
6316
+ return this.request(`/editor/builder/registries/${encodeURIComponent(registryId)}/preview?${search.toString()}`);
6317
+ }
6318
+ /**
6319
+ * Install a registry skill into the builder's stored-skills DB.
6320
+ * Returns 409 when a stored skill with the derived id already exists.
6321
+ * Requires `stored-skills:write` permission.
6322
+ */
6323
+ installBuilderRegistrySkill(registryId, body) {
6324
+ return this.request(`/editor/builder/registries/${encodeURIComponent(registryId)}/install`, {
6325
+ method: "POST",
6326
+ body
6327
+ });
6328
+ }
6329
+ // ============================================================================
6151
6330
  // Workspace
6152
6331
  // ============================================================================
6153
6332
  /**
@@ -6166,6 +6345,32 @@ var MastraClient = class extends BaseResource {
6166
6345
  return new Workspace(this.options, workspaceId);
6167
6346
  }
6168
6347
  // ============================================================================
6348
+ // Stored Workspaces
6349
+ // ============================================================================
6350
+ /**
6351
+ * Lists stored workspace configurations from the database
6352
+ * @param params - Optional filter and pagination parameters
6353
+ * @returns Promise containing paginated list of stored workspaces
6354
+ */
6355
+ listStoredWorkspaces(params) {
6356
+ const searchParams = new URLSearchParams();
6357
+ if (params?.page !== void 0) searchParams.set("page", String(params.page));
6358
+ if (params?.perPage !== void 0) searchParams.set("perPage", String(params.perPage));
6359
+ if (params?.authorId) searchParams.set("authorId", params.authorId);
6360
+ if (params?.orderBy?.field) searchParams.set("orderBy[field]", params.orderBy.field);
6361
+ if (params?.orderBy?.direction) searchParams.set("orderBy[direction]", params.orderBy.direction);
6362
+ const qs = searchParams.toString();
6363
+ return this.request(`/stored/workspaces${qs ? `?${qs}` : ""}`);
6364
+ }
6365
+ /**
6366
+ * Gets a specific stored workspace by ID
6367
+ * @param id - The workspace ID
6368
+ * @returns Promise containing the stored workspace
6369
+ */
6370
+ getStoredWorkspace(id) {
6371
+ return this.request(`/stored/workspaces/${encodeURIComponent(id)}`);
6372
+ }
6373
+ // ============================================================================
6169
6374
  // Vectors & Embedders
6170
6375
  // ============================================================================
6171
6376
  /**