@mastra/client-js 1.51.3-alpha.0 → 1.52.0-alpha.2

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.
@@ -3,7 +3,7 @@ name: mastra-client-js
3
3
  description: Documentation for @mastra/client-js. Use when working with @mastra/client-js APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/client-js"
6
- version: "1.51.3-alpha.0"
6
+ version: "1.52.0-alpha.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.51.3-alpha.0",
2
+ "version": "1.52.0-alpha.2",
3
3
  "package": "@mastra/client-js",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -351,7 +351,7 @@ Use `createNotificationInboxTool()` to give agents one tool for inbox actions in
351
351
 
352
352
  ## Cross-agent connections in Mastra Code
353
353
 
354
- Cross-agent communication is experimental and off by default. Enable it in Mastra Code with the `/settings` toggle "Experimental cross-agent communication" and restart. Embedded clients can set `crossAgentSignals: true` when calling `createMastraCode()`. The setting enables thread ownership advertisements and peer discovery. It also makes the agent connection tools available. It doesn't affect the pub/sub transport itself.
354
+ Cross-agent communication is experimental and off by default. Enable it in Mastra Code with the `/settings` toggle "Experimental cross-agent communication" and restart. Embedded clients can set `crossAgentSignals: true` when calling `createMastraCode()`. The setting enables thread ownership advertisements and peer discovery. It also makes the agent connection tools available, and lets peer discovery reach instances in other projects on the same machine (see [Discover agents in other projects](#discover-agents-in-other-projects)).
355
355
 
356
356
  ```typescript
357
357
  import { createMastraCode } from 'mastracode'
@@ -388,6 +388,20 @@ Saved connections remain in the sender thread until explicitly disconnected. Eve
388
388
 
389
389
  After a send attempt reaches Core routing, the routing result is authoritative. The result can be `wake`, `deliver`, `persist`, `blocked`, or `discard`, depending on the target thread and notification policy. A send that isn't acknowledged by the advertised thread owner returns an error and doesn't consume its `messageId`, so the sender can retry it.
390
390
 
391
+ ### Discover agents in other projects
392
+
393
+ With cross-agent communication on, `agent_connections_list` lists Mastra Code instances in every project on the same machine, including the current one. An instance can connect to and message an instance in another project, and receive its replies. This needs Unix socket pub/sub. The Mastra Code CLI turns it on by default. Embedded clients pass `unixSocketPubSub: true` alongside `crossAgentSignals: true` to `createMastraCode()`. It doesn't apply in these cases:
394
+
395
+ - On Windows.
396
+ - When you pass your own `pubsub`.
397
+ - When the resource ID, set through `MASTRA_RESOURCE_ID` or `resourceId` in `.mastracode/database.json`, can't be used as a directory name. That covers IDs that are empty, are longer than 128 characters, contain `/`, `\` or control characters, or equal `.`, `..` or `_shared`. Mastra Code logs one warning at startup, and the instance only lists instances that share its resource ID.
398
+
399
+ Mastra Code routes a thread's messages and run leases to the socket directory of the thread's project. Thread-owner lookup and peer discovery, which lists the threads you can connect to, both run in a shared `/tmp/mc/_shared` directory. Instances running versions before this change can't see or be seen by updated instances, so restart every instance after updating.
400
+
401
+ Any local process running as your user can list the threads your instances advertise and message them, so only turn on cross-agent communication on machines and accounts you trust.
402
+
403
+ To isolate an instance or a test from the shared `/tmp/mc` directory, set `MASTRACODE_SIGNALS_SOCKET_ROOT` to another absolute path. Relative paths are ignored. Keep the path short, because macOS limits Unix socket paths to 104 bytes. The root also holds every thread's run and ownership leases. An instance with a different root doesn't coordinate threads with instances that use the default root.
404
+
391
405
  ## Distributed and serverless deployments
392
406
 
393
407
  Signals coordinate runs through a pub/sub backend. When a signal arrives on a backend that implements `LeaseProvider`, Mastra acquires a lease on the target thread so a single process owns the conversation at a time, then either wakes the agent or routes the input into the running loop. Backends without leasing fall back to a no-op that always grants ownership, which is fine in a single process but not across instances.
package/dist/index.cjs CHANGED
@@ -5592,6 +5592,7 @@ var WorkspaceSkillResource = class extends BaseResource {
5592
5592
  * - Filesystem operations (read, write, list, delete, mkdir, stat)
5593
5593
  * - Search operations (search, index)
5594
5594
  * - Skills operations (list, get, search, references)
5595
+ * - skills.sh registry operations (search, popular, preview, install, remove, update)
5595
5596
  */
5596
5597
  var Workspace = class extends BaseResource {
5597
5598
  workspaceId;
@@ -5746,6 +5747,72 @@ var Workspace = class extends BaseResource {
5746
5747
  getSkill(skillName, skillPath) {
5747
5748
  return new WorkspaceSkillResource(this.options, this.workspaceId, skillName, skillPath);
5748
5749
  }
5750
+ skillsShQuery(params) {
5751
+ const searchParams = new URLSearchParams();
5752
+ for (const [key, value] of Object.entries(params)) if (value !== void 0) searchParams.set(key, String(value));
5753
+ const query = searchParams.toString();
5754
+ return query ? `?${query}` : "";
5755
+ }
5756
+ /**
5757
+ * Searches the skills.sh registry
5758
+ * @param params - Search query and optional result limit
5759
+ * @returns Promise containing matching skills
5760
+ */
5761
+ searchSkillsSh(params) {
5762
+ return this.request(`${this.basePath}/skills-sh/search${this.skillsShQuery(params)}`);
5763
+ }
5764
+ /**
5765
+ * Lists popular skills from the skills.sh registry
5766
+ * @param params - Optional pagination
5767
+ * @returns Promise containing popular skills
5768
+ */
5769
+ listPopularSkillsSh(params = {}) {
5770
+ return this.request(`${this.basePath}/skills-sh/popular${this.skillsShQuery(params)}`);
5771
+ }
5772
+ /**
5773
+ * Fetches the SKILL.md of a skills.sh skill without installing it
5774
+ * @param params - GitHub owner, repo and skill path
5775
+ * @returns Promise containing the SKILL.md content
5776
+ */
5777
+ previewSkillsSh(params) {
5778
+ return this.request(`${this.basePath}/skills-sh/preview${this.skillsShQuery(params)}`);
5779
+ }
5780
+ /**
5781
+ * Installs a skills.sh skill into the workspace filesystem
5782
+ * @param params - GitHub owner, repo, skill name and optional mount
5783
+ * @returns Promise containing the installed path and files written
5784
+ */
5785
+ installSkillsSh(params) {
5786
+ return this.request(`${this.basePath}/skills-sh/install`, {
5787
+ method: "POST",
5788
+ body: params,
5789
+ retries: 0
5790
+ });
5791
+ }
5792
+ /**
5793
+ * Removes an installed skills.sh skill from the workspace
5794
+ * @param params - Name of the skill to remove
5795
+ * @returns Promise containing the removed path
5796
+ */
5797
+ removeSkillsSh(params) {
5798
+ return this.request(`${this.basePath}/skills-sh/remove`, {
5799
+ method: "POST",
5800
+ body: params,
5801
+ retries: 0
5802
+ });
5803
+ }
5804
+ /**
5805
+ * Re-fetches installed skills.sh skills from GitHub
5806
+ * @param params - Optional skill name; omit to update all
5807
+ * @returns Promise containing per-skill update results
5808
+ */
5809
+ updateSkillsSh(params = {}) {
5810
+ return this.request(`${this.basePath}/skills-sh/update`, {
5811
+ method: "POST",
5812
+ body: params,
5813
+ retries: 0
5814
+ });
5815
+ }
5749
5816
  };
5750
5817
  //#endregion
5751
5818
  //#region src/resources/stored-skill.ts