mastracode 0.23.1-alpha.1 → 0.23.1-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.
Files changed (38) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/dist/agents/memory.d.ts.map +1 -1
  3. package/dist/{chunk-EWXZ5A65.js → chunk-GJYXDL6Q.js} +197 -191
  4. package/dist/chunk-GJYXDL6Q.js.map +1 -0
  5. package/dist/{chunk-RDG7DHFG.cjs → chunk-VETNGNCX.cjs} +197 -191
  6. package/dist/chunk-VETNGNCX.cjs.map +1 -0
  7. package/dist/{chunk-7QUEBL6Z.js → chunk-VN4EYS2P.js} +44 -35
  8. package/dist/chunk-VN4EYS2P.js.map +1 -0
  9. package/dist/{chunk-3PNUO4FX.cjs → chunk-YJPPQYEY.cjs} +45 -36
  10. package/dist/chunk-YJPPQYEY.cjs.map +1 -0
  11. package/dist/cli.cjs +16 -16
  12. package/dist/cli.cjs.map +1 -1
  13. package/dist/cli.js +10 -10
  14. package/dist/cli.js.map +1 -1
  15. package/dist/index.cjs +3 -3
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +1 -1
  18. package/dist/tools/utils.d.ts.map +1 -1
  19. package/dist/tui/commands/github.d.ts.map +1 -1
  20. package/dist/tui/commands/om.d.ts.map +1 -1
  21. package/dist/tui/commands/sandbox.d.ts.map +1 -1
  22. package/dist/tui/commands/types.d.ts +2 -1
  23. package/dist/tui/commands/types.d.ts.map +1 -1
  24. package/dist/tui/mastra-tui.d.ts.map +1 -1
  25. package/dist/tui/render-messages.d.ts.map +1 -1
  26. package/dist/tui/state.d.ts +2 -1
  27. package/dist/tui/state.d.ts.map +1 -1
  28. package/dist/tui.cjs +11 -11
  29. package/dist/tui.js +1 -1
  30. package/package.json +7 -8
  31. package/dist/HarnessCompat.d.ts +0 -60
  32. package/dist/HarnessCompat.d.ts.map +0 -1
  33. package/dist/chunk-3PNUO4FX.cjs.map +0 -1
  34. package/dist/chunk-7QUEBL6Z.js.map +0 -1
  35. package/dist/chunk-EWXZ5A65.js.map +0 -1
  36. package/dist/chunk-RDG7DHFG.cjs.map +0 -1
  37. package/dist/harness-tui-v1.d.ts +0 -2
  38. package/dist/harness-tui-v1.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,87 @@
1
1
  # mastracode
2
2
 
3
+ ## 0.23.1-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Removed the unused harness v1 TUI development script. ([#18131](https://github.com/mastra-ai/mastra/pull/18131))
8
+
9
+ - Move the Harness display state onto `session.displayState` ([#18136](https://github.com/mastra-ai/mastra/pull/18136))
10
+
11
+ The canonical display state a UI renders — `isRunning`, active tools, tool-input
12
+ buffers, pending approval/suspensions, active subagents, current message,
13
+ queued follow-ups, modified files, tasks, OM progress, and token usage — now
14
+ lives on the Session as `session.displayState`, alongside the reducer that keeps
15
+ it in sync with every Harness event.
16
+
17
+ `SessionDisplayState` owns:
18
+ - `get()` — a read-only snapshot to render from (replaces `harness.getDisplayState()`)
19
+ - `apply(event)` — the centralized state machine that folds each event into the snapshot
20
+ - `resetThread()` — reset thread-scoped fields on thread switch/create
21
+ - `restoreTasks(tasks)` — restore replayed task history without emitting an event
22
+ - `clearPendingSuspensions()` / `deletePendingSuspension(toolCallId)` — display mirror upkeep on abort/resume
23
+
24
+ Display state is inherently per-conversation, so in a shared (multi-user) host
25
+ it can't hang off the Harness — `harness.getDisplayState()` has no single answer
26
+ when one host serves many sessions. It reads from `harness.session.displayState`
27
+ instead.
28
+
29
+ The Harness stays the **event-bus owner**: `emit()` folds the event into
30
+ `session.displayState` and then dispatches to listeners (including the
31
+ `display_state_changed` fan-out). The reducer needs a few read-only host facts it
32
+ doesn't own — the live token-usage tally, the subagent display-name lookup
33
+ (Harness config), and the active thread id — which are injected into the Session
34
+ at construction.
35
+
36
+ Removed from the Harness public API (read through `harness.session.displayState.*`):
37
+ - `getDisplayState()` → `session.displayState.get()`
38
+ - `restoreDisplayTasks(tasks)` → `session.displayState.restoreTasks(tasks)`
39
+
40
+ `restoreTasks` is now a pure session-state mutation (it no longer emits
41
+ `display_state_changed`); the UI re-renders explicitly after a replay.
42
+
43
+ - Introduce the Harness `Session`: the Harness now exposes `harness.session`, a class that owns the per-conversation runtime state that previously lived flattened on the Harness instance. The Harness remains the shared host (storage, the thread lock, the agent registry, the event bus); the Session owns the state scoped to a single user's conversation. ([#18107](https://github.com/mastra-ai/mastra/pull/18107))
44
+
45
+ `harness.session` owns:
46
+ - **`session.identity`** — the session's `resourceId` / `defaultResourceId` (the stable "who").
47
+ - **`session.thread`** — the active thread binding (`getId` / `set` / `clear` / `isSet` / `requireId`) plus the thread data domain scoped to the session: `list`, `getById`, `listMessages`, `listActiveMessages`, `firstUserMessage(s)`, and thread settings (`getSetting` / `setSetting` / `deleteSetting`). It reaches shared-host storage through an injected gateway rather than calling back into Harness orchestration.
48
+ - **`session.mode`** / **`session.model`** — the currently-selected mode and model (source of truth), the mode-switch sequence, and per-mode model memory. The Harness still owns the mode _definitions_ (`config.modes`).
49
+ - **`session.run`** — transient per-run identity (run id, trace id, operation counter) and abort control (controller, `isRunning`, `requestAbort`, …). Never persisted.
50
+ - **`session.stream`** — the live agent-thread subscription handle and its dedup key. Adds `session.getCurrentRunId()` and `session.abortRun()`, which compose the subscription.
51
+ - **`session.suspensions`** — the parked-tool resume map (`toolCallId → { runId, toolName }`) for tools paused via the native suspension primitive (`ask_user` / `request_access` / `submit_plan`).
52
+ - **`session.followUps`** — the queue of messages to send after the active run finishes.
53
+ - **`session.approval`** — the interactive tool-approval gate; `session.respondToToolApproval({ decision, requestContext })` applies the user's approve / decline / always-allow choice and releases the run.
54
+ - session-scoped permission grants and the live token-usage counter (the Harness still persists usage to thread metadata, since usage is thread-scoped).
55
+
56
+ **Removed from the Harness public API** — read these through `harness.session.*` instead:
57
+ - `getSessionGrants()`, `getTokenUsage()` → `session.getGrants()` / `session.getTokenUsage()`
58
+ - `getCurrentModelId()`, `hasModelSelected()` → `session.model.get()` / `session.model.hasSelection()`
59
+ - `getCurrentRunId()`, `getCurrentTraceId()`, `isRunning()` → `session.getCurrentRunId()` / `session.run.getTraceId()` / `session.run.isRunning()`
60
+ - `getCurrentThreadId()`, `getThreads()`, `listThreads()`, `listMessages()`, `listMessagesForThread()`, `getFirstUserMessage(s)ForThread(s)()`, `getThreadSetting()`, `setThreadSetting()` → `session.thread.*`
61
+ - `getResourceId()`, `getDefaultResourceId()` → `session.identity.*`
62
+ - `getFollowUpCount()` → `session.followUps.count()`
63
+ - `respondToToolApproval()` → `session.respondToToolApproval()`
64
+ - `getCurrentModeId()` → `session.mode.get()`
65
+ - `getCurrentMode()` → `session.mode.resolve()` (resolves the selected mode id against the host's `config.modes` catalog, injected into the Session)
66
+ - `hasPendingSuspensions()` → `session.suspensions.hasPending()`
67
+ - `isCurrentThreadStreamActive()` → `session.stream.isActive()`
68
+
69
+ `Harness.abort()` and `setResourceId()` remain on the Harness with unchanged behavior — they orchestrate Harness-host state (the display-state mirror, the agent-stream subscription, thread teardown) before delegating the relevant reads/writes to the session.
70
+
71
+ `session.mode` exposes two complementary accessors: `get()` returns the selected mode **id** (a `string`, mirroring `session.model.get()`), while `resolve()` returns the full `HarnessMode` definition by looking the id up in the injected mode catalog.
72
+
73
+ The legacy `HarnessCompat` shim (v1-session/legacy-thread merge) has been removed; its thread-list merge now lives in the Session's thread-data store, so `session.thread.list()` returns the merged result directly.
74
+
75
+ `session.abortRun()` now also releases a parked tool-approval gate: a run awaiting `session.approval.arm()` is not actively streaming, so aborting resolves the gate as a decline (rejecting the gated tool) instead of leaving the await hung. Mirrors how abort already drops parked tool suspensions.
76
+
77
+ - Improved MastraCode Harness state access. ([#18133](https://github.com/mastra-ai/mastra/pull/18133))
78
+
79
+ MastraCode now reads and writes Harness state through `harness.session.state` while keeping fallback support for older request-context mocks during the transition.
80
+
81
+ - Updated dependencies [[`339c57c`](https://github.com/mastra-ai/mastra/commit/339c57c5b2c6dbe75a125e138228e0556528976f), [`1dd4117`](https://github.com/mastra-ai/mastra/commit/1dd4117dcbd8e031ede9f0489436bfbc6f0315b8), [`2b11d1f`](https://github.com/mastra-ai/mastra/commit/2b11d1f6ac7024c5dd2b2dd12a48a956ac9d63bd), [`7d6ff70`](https://github.com/mastra-ai/mastra/commit/7d6ff708727297a0526ca0e26e93eeb5bbaaa187), [`49af8df`](https://github.com/mastra-ai/mastra/commit/49af8df589c4ff71a5015a4553b377b32704b691), [`30ce559`](https://github.com/mastra-ai/mastra/commit/30ce55902ecf819b8ab8697398dd68b108228063), [`c241b92`](https://github.com/mastra-ai/mastra/commit/c241b929dc8c8d6a7b7219c99ed13ac1f3124a77), [`7d6ff70`](https://github.com/mastra-ai/mastra/commit/7d6ff708727297a0526ca0e26e93eeb5bbaaa187)]:
82
+ - @mastra/core@1.44.0-alpha.2
83
+ - @mastra/observability@1.14.4-alpha.1
84
+
3
85
  ## 0.23.1-alpha.1
4
86
 
5
87
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/agents/memory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAoExC;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,EAAE,MAAM,CAAC,EAAE,YAAY,IAC3E,oBAAoB;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,YA4D/D"}
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/agents/memory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAqExC;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,EAAE,MAAM,CAAC,EAAE,YAAY,IAC3E,oBAAoB;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,YA4D/D"}