@mastra/client-js 1.27.1-alpha.2 → 1.28.0-alpha.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,99 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 1.28.0-alpha.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`462a769`](https://github.com/mastra-ai/mastra/commit/462a769da61850862ca1be3d74134d33078ee6a7), [`f328049`](https://github.com/mastra-ai/mastra/commit/f3280498c324afd2a8d36cd828f5b9f94a2dddc1), [`e545228`](https://github.com/mastra-ai/mastra/commit/e54522856934a5dc030b7b6385771e3548020d59)]:
8
+ - @mastra/core@1.47.0-alpha.4
9
+
10
+ ## 1.28.0-alpha.3
11
+
12
+ ### Minor Changes
13
+
14
+ - Enrich the harness HTTP session surface so a client can render a status line, ([#18446](https://github.com/mastra-ai/mastra/pull/18446))
15
+ read behavior settings, and scope threads per working directory.
16
+
17
+ `GET /harness/:harnessId/sessions/:resourceId` now also returns:
18
+ - `omProgress` — the status-line slice of observational-memory progress
19
+ (pending tokens vs. observation threshold, accumulated observations vs.
20
+ reflection threshold, plus projected message removal / reflection savings)
21
+ - `tokenUsage` — cumulative token usage for the current thread
22
+ - `settings` — agent behavior settings (`yolo`, `thinkingLevel`,
23
+ `notifications`, `smartEditing`)
24
+
25
+ `GET /harness/:harnessId/sessions/:resourceId/threads` accepts an optional
26
+ `tags` query param (a JSON-encoded object). A single resourceId can be shared
27
+ across git worktrees of the same repo (the id is derived from the git URL), so
28
+ passing `tags` scopes the list to threads matching every tag (e.g.
29
+ `{ projectPath }` for the working directory). Each returned thread now also
30
+ includes the scoping `tags` it was stamped with at creation.
31
+
32
+ The session event stream route (`.../stream`) now enqueues raw event objects
33
+ and lets the server adapter handle SSE framing, fixing a double-framing bug
34
+ where events were wrapped twice (`data: "data: {...}\n\n"\n\n`) and could not be
35
+ parsed by clients.
36
+
37
+ `@mastra/client-js` gains the matching types and reads:
38
+ - `HarnessOMProgress` and `HarnessSessionSettings`, surfaced on
39
+ `HarnessSessionState` (`omProgress`, `tokenUsage`, `settings`)
40
+ - a `display_state_changed` event in `KnownHarnessEvent` carrying the
41
+ status-line figures
42
+ - `HarnessSession.listThreads()` now accepts either a number (back-compat) or
43
+ `{ limit?, tags? }`
44
+
45
+ Example:
46
+
47
+ ```ts
48
+ const session = client.getHarness('code').session(resourceId);
49
+
50
+ // Scope a worktree's thread list (and resumed session) to its own threads.
51
+ await session.create({ tags: { projectPath: '/repo/worktree-a' } });
52
+ const threads = await session.listThreads({ tags: { projectPath: '/repo/worktree-a' } });
53
+
54
+ // Read the status-line figures and agent settings.
55
+ const state = await session.state();
56
+ state.omProgress; // observational-memory progress
57
+ state.tokenUsage; // cumulative token usage
58
+ state.settings; // { yolo, thinkingLevel, notifications, smartEditing }
59
+ ```
60
+
61
+ - Scope harness session creation with tags so sessions sharing a resourceId can ([#18446](https://github.com/mastra-ai/mastra/pull/18446))
62
+ each resume their own thread.
63
+
64
+ `harness.createSession()` now accepts an optional `tags` record. The tags are
65
+ (a) seeded into the new session's state, (b) stamped onto every thread the
66
+ session creates (so thread listings can be filtered back to the session's
67
+ scope), and (c) used to filter initial thread selection: a thread is a resume
68
+ candidate only when its metadata matches every provided tag. Previously, initial
69
+ thread selection only consulted the
70
+ harness-global `initialState.projectPath`; on a multi-session server (where one
71
+ Harness serves many scopes) a session could resume the most recently updated
72
+ thread from a _different_ scope that shared the resourceId. Using a generic tag
73
+ record (e.g. `{ projectPath }`) keeps room for future scoping dimensions without
74
+ further API changes.
75
+
76
+ The `@mastra/client-js` `HarnessSession.create()` method accepts `{ tags }`, and
77
+ the `POST /harness/:id/sessions` route accepts a `tags` body field.
78
+
79
+ ```ts
80
+ // before: initial thread chosen by resourceId only
81
+ const session = await harness.createSession({ resourceId, id, ownerId });
82
+
83
+ // after: initial thread scoped to this worktree via a tag
84
+ const session = await harness.createSession({
85
+ resourceId,
86
+ id,
87
+ ownerId,
88
+ tags: { projectPath: '/repo/worktree-a' },
89
+ });
90
+ ```
91
+
92
+ ### Patch Changes
93
+
94
+ - Updated dependencies [[`bf3fe49`](https://github.com/mastra-ai/mastra/commit/bf3fe49f9467dbbdb8f9eaf74e0f7971ffb19559), [`24ceaea`](https://github.com/mastra-ai/mastra/commit/24ceaea0bdd8609cabbab764380608ca6621a194), [`6ccf67b`](https://github.com/mastra-ai/mastra/commit/6ccf67bf075753754927a57bc2e1734ba2c820c5), [`825d8de`](https://github.com/mastra-ai/mastra/commit/825d8def9fa64c2bcc3d8dd6b49e09342c3ac5c7), [`ffa09e7`](https://github.com/mastra-ai/mastra/commit/ffa09e772a5c92270eabe2090fc42d45bd8ec4b7), [`461a7c5`](https://github.com/mastra-ai/mastra/commit/461a7c501449295287f4f0ee4b0b42344f39fcf8), [`4211472`](https://github.com/mastra-ai/mastra/commit/4211472a5a2bd319c60cd2e42d9109c3eef7ac1c), [`9e45902`](https://github.com/mastra-ai/mastra/commit/9e4590208e745055cecca202e2db0e5c65e17d3c), [`5c0df77`](https://github.com/mastra-ai/mastra/commit/5c0df776c40efa420f8c07a2f3ee66010296618e)]:
95
+ - @mastra/core@1.47.0-alpha.3
96
+
3
97
  ## 1.27.1-alpha.2
4
98
 
5
99
  ### Patch Changes
@@ -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.27.1-alpha.2"
6
+ version: "1.28.0-alpha.4"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.27.1-alpha.2",
2
+ "version": "1.28.0-alpha.4",
3
3
  "package": "@mastra/client-js",
4
4
  "exports": {
5
5
  "RequestContext": {
package/dist/index.cjs CHANGED
@@ -6099,11 +6099,17 @@ var HarnessSession = class extends BaseResource {
6099
6099
  base() {
6100
6100
  return `/harness/${encodeURIComponent(this.harnessId)}/sessions/${encodeURIComponent(this.resourceId)}`;
6101
6101
  }
6102
- /** Create or resume this session. */
6103
- create() {
6102
+ /**
6103
+ * Create or resume this session. Pass `tags` to scope initial thread
6104
+ * selection — a thread is a resume candidate only when its metadata matches
6105
+ * every tag. Required when sessions share a resourceId (e.g. git worktrees
6106
+ * using a `{ projectPath }` tag) so each resumes its own thread instead of the
6107
+ * most recent thread across the whole resource.
6108
+ */
6109
+ create(options) {
6104
6110
  return this.request(`/harness/${encodeURIComponent(this.harnessId)}/sessions`, {
6105
6111
  method: "POST",
6106
- body: { resourceId: this.resourceId }
6112
+ body: { resourceId: this.resourceId, tags: options?.tags }
6107
6113
  });
6108
6114
  }
6109
6115
  /**
@@ -6203,8 +6209,19 @@ var HarnessSession = class extends BaseResource {
6203
6209
  });
6204
6210
  }
6205
6211
  /** List the threads for this session's resource, most-recently-updated first. Pass `limit` for just the newest N. */
6206
- async listThreads(limit) {
6207
- const query = limit != null ? `?limit=${limit}` : "";
6212
+ /**
6213
+ * List the session's threads, newest first. Pass `limit` to cap the count
6214
+ * (e.g. for a sidebar) and `tags` to scope to threads matching every tag —
6215
+ * necessary when one resourceId is shared across git worktrees of the same
6216
+ * repo (e.g. `{ tags: { projectPath } }` so each worktree sees only its own
6217
+ * threads). Passing a bare number is shorthand for `{ limit }`.
6218
+ */
6219
+ async listThreads(options) {
6220
+ const opts = typeof options === "number" ? { limit: options } : options ?? {};
6221
+ const params = new URLSearchParams();
6222
+ if (opts.limit != null) params.set("limit", String(opts.limit));
6223
+ if (opts.tags && Object.keys(opts.tags).length > 0) params.set("tags", JSON.stringify(opts.tags));
6224
+ const query = params.toString() ? `?${params.toString()}` : "";
6208
6225
  const body = await this.request(`${this.base()}/threads${query}`);
6209
6226
  return body.threads;
6210
6227
  }