@mastra/client-js 1.27.1-alpha.1 → 1.28.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/CHANGELOG.md +94 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +22 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/resources/harness.d.ts +70 -3
- package/dist/resources/harness.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +44 -15
- package/dist/route-types.generated.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,99 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.28.0-alpha.3
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Enrich the harness HTTP session surface so a client can render a status line, ([#18446](https://github.com/mastra-ai/mastra/pull/18446))
|
|
8
|
+
read behavior settings, and scope threads per working directory.
|
|
9
|
+
|
|
10
|
+
`GET /harness/:harnessId/sessions/:resourceId` now also returns:
|
|
11
|
+
- `omProgress` — the status-line slice of observational-memory progress
|
|
12
|
+
(pending tokens vs. observation threshold, accumulated observations vs.
|
|
13
|
+
reflection threshold, plus projected message removal / reflection savings)
|
|
14
|
+
- `tokenUsage` — cumulative token usage for the current thread
|
|
15
|
+
- `settings` — agent behavior settings (`yolo`, `thinkingLevel`,
|
|
16
|
+
`notifications`, `smartEditing`)
|
|
17
|
+
|
|
18
|
+
`GET /harness/:harnessId/sessions/:resourceId/threads` accepts an optional
|
|
19
|
+
`tags` query param (a JSON-encoded object). A single resourceId can be shared
|
|
20
|
+
across git worktrees of the same repo (the id is derived from the git URL), so
|
|
21
|
+
passing `tags` scopes the list to threads matching every tag (e.g.
|
|
22
|
+
`{ projectPath }` for the working directory). Each returned thread now also
|
|
23
|
+
includes the scoping `tags` it was stamped with at creation.
|
|
24
|
+
|
|
25
|
+
The session event stream route (`.../stream`) now enqueues raw event objects
|
|
26
|
+
and lets the server adapter handle SSE framing, fixing a double-framing bug
|
|
27
|
+
where events were wrapped twice (`data: "data: {...}\n\n"\n\n`) and could not be
|
|
28
|
+
parsed by clients.
|
|
29
|
+
|
|
30
|
+
`@mastra/client-js` gains the matching types and reads:
|
|
31
|
+
- `HarnessOMProgress` and `HarnessSessionSettings`, surfaced on
|
|
32
|
+
`HarnessSessionState` (`omProgress`, `tokenUsage`, `settings`)
|
|
33
|
+
- a `display_state_changed` event in `KnownHarnessEvent` carrying the
|
|
34
|
+
status-line figures
|
|
35
|
+
- `HarnessSession.listThreads()` now accepts either a number (back-compat) or
|
|
36
|
+
`{ limit?, tags? }`
|
|
37
|
+
|
|
38
|
+
Example:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
const session = client.getHarness('code').session(resourceId);
|
|
42
|
+
|
|
43
|
+
// Scope a worktree's thread list (and resumed session) to its own threads.
|
|
44
|
+
await session.create({ tags: { projectPath: '/repo/worktree-a' } });
|
|
45
|
+
const threads = await session.listThreads({ tags: { projectPath: '/repo/worktree-a' } });
|
|
46
|
+
|
|
47
|
+
// Read the status-line figures and agent settings.
|
|
48
|
+
const state = await session.state();
|
|
49
|
+
state.omProgress; // observational-memory progress
|
|
50
|
+
state.tokenUsage; // cumulative token usage
|
|
51
|
+
state.settings; // { yolo, thinkingLevel, notifications, smartEditing }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- Scope harness session creation with tags so sessions sharing a resourceId can ([#18446](https://github.com/mastra-ai/mastra/pull/18446))
|
|
55
|
+
each resume their own thread.
|
|
56
|
+
|
|
57
|
+
`harness.createSession()` now accepts an optional `tags` record. The tags are
|
|
58
|
+
(a) seeded into the new session's state, (b) stamped onto every thread the
|
|
59
|
+
session creates (so thread listings can be filtered back to the session's
|
|
60
|
+
scope), and (c) used to filter initial thread selection: a thread is a resume
|
|
61
|
+
candidate only when its metadata matches every provided tag. Previously, initial
|
|
62
|
+
thread selection only consulted the
|
|
63
|
+
harness-global `initialState.projectPath`; on a multi-session server (where one
|
|
64
|
+
Harness serves many scopes) a session could resume the most recently updated
|
|
65
|
+
thread from a _different_ scope that shared the resourceId. Using a generic tag
|
|
66
|
+
record (e.g. `{ projectPath }`) keeps room for future scoping dimensions without
|
|
67
|
+
further API changes.
|
|
68
|
+
|
|
69
|
+
The `@mastra/client-js` `HarnessSession.create()` method accepts `{ tags }`, and
|
|
70
|
+
the `POST /harness/:id/sessions` route accepts a `tags` body field.
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
// before: initial thread chosen by resourceId only
|
|
74
|
+
const session = await harness.createSession({ resourceId, id, ownerId });
|
|
75
|
+
|
|
76
|
+
// after: initial thread scoped to this worktree via a tag
|
|
77
|
+
const session = await harness.createSession({
|
|
78
|
+
resourceId,
|
|
79
|
+
id,
|
|
80
|
+
ownerId,
|
|
81
|
+
tags: { projectPath: '/repo/worktree-a' },
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- 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)]:
|
|
88
|
+
- @mastra/core@1.47.0-alpha.3
|
|
89
|
+
|
|
90
|
+
## 1.27.1-alpha.2
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- Updated dependencies [[`86623c1`](https://github.com/mastra-ai/mastra/commit/86623c1adf7d22de32cc916dda17f4155184db36), [`7c9dd77`](https://github.com/mastra-ai/mastra/commit/7c9dd77bd18cb8dc72797e25f1a0fbdc71a11347), [`9990965`](https://github.com/mastra-ai/mastra/commit/999096571635a83b42ef40841fd7028cfa630779), [`c0ffa3c`](https://github.com/mastra-ai/mastra/commit/c0ffa3c897ccd326de880df734740a7f0681a18f), [`0504bf5`](https://github.com/mastra-ai/mastra/commit/0504bf5e8cffc571a4b343326178de371e6f859b), [`5afe423`](https://github.com/mastra-ai/mastra/commit/5afe423e4badf040f1b0d4525183a856fcb8146e), [`86623c1`](https://github.com/mastra-ai/mastra/commit/86623c1adf7d22de32cc916dda17f4155184db36), [`8c9f1c0`](https://github.com/mastra-ai/mastra/commit/8c9f1c0361d89066f9bcd14a2f69e761b01766c8)]:
|
|
95
|
+
- @mastra/core@1.47.0-alpha.2
|
|
96
|
+
|
|
3
97
|
## 1.27.1-alpha.1
|
|
4
98
|
|
|
5
99
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -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.
|
|
6
|
+
version: "1.28.0-alpha.3"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
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
|
-
/**
|
|
6103
|
-
|
|
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
|
-
|
|
6207
|
-
|
|
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
|
}
|