@mastra/playground-ui 9.1.0-alpha.0 → 10.0.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.
- package/CHANGELOG.md +130 -0
- package/dist/{compatibility-DPfpqfml.cjs → compatibility-BSJHu6pD.cjs} +16 -19
- package/dist/compatibility-BSJHu6pD.cjs.map +1 -0
- package/dist/{compatibility-D6cOTcfi.js → compatibility-f2FIOihW.js} +16 -19
- package/dist/compatibility-f2FIOihW.js.map +1 -0
- package/dist/index.cjs.js +1261 -501
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1262 -502
- package/dist/index.es.js.map +1 -1
- package/dist/src/domains/agents/components/agent-chat.d.ts +1 -1
- package/dist/src/domains/agents/components/agent-cms-blocks/agent-cms-block.d.ts +5 -1
- package/dist/src/domains/agents/components/agent-cms-blocks/agent-cms-blocks.d.ts +3 -2
- package/dist/src/domains/agents/components/agent-edit-page/agent-edit-layout.d.ts +1 -2
- package/dist/src/domains/agents/components/agent-edit-page/index.d.ts +1 -2
- package/dist/src/domains/agents/components/agent-edit-page/instructions-preview-dialog.d.ts +3 -2
- package/dist/src/domains/agents/components/agent-edit-page/use-agent-edit-form.d.ts +18 -0
- package/dist/src/domains/agents/components/agent-edit-page/utils/form-validation.d.ts +39 -0
- package/dist/src/domains/agents/components/agent-version-combobox.d.ts +9 -0
- package/dist/src/domains/agents/context/agent-observational-memory-context.d.ts +32 -8
- package/dist/src/domains/agents/hooks/use-clone-agent.d.ts +4 -0
- package/dist/src/domains/request-context/hooks/use-request-context-presets.d.ts +4 -0
- package/dist/src/domains/request-context/index.d.ts +1 -0
- package/dist/src/domains/workflows/workflow/workflow-default-node.d.ts +1 -0
- package/dist/src/domains/workflows/workflow/workflow-nested-node.d.ts +1 -0
- package/dist/src/domains/workspace/compatibility.d.ts +2 -2
- package/dist/src/domains/workspace/types.d.ts +11 -0
- package/dist/src/ds/components/CodeEditor/code-editor.d.ts +17 -1
- package/dist/src/ds/components/ContentBlocks/content-block.d.ts +2 -1
- package/dist/src/ds/components/ContentBlocks/content-blocks.d.ts +4 -4
- package/dist/src/ds/components/ContentBlocks/index.d.ts +0 -1
- package/dist/src/lib/ai-ui/messages/observation-marker.d.ts +38 -1
- package/dist/src/lib/ai-ui/tools/badges/observation-marker-badge.d.ts +7 -1
- package/dist/src/lib/rule-engine/components/rule-value-input.d.ts +4 -2
- package/dist/src/lib/rule-engine/components/types.d.ts +4 -0
- package/dist/src/types.d.ts +1 -1
- package/dist/utils.cjs.js +1 -1
- package/dist/utils.es.js +1 -1
- package/package.json +19 -19
- package/dist/compatibility-D6cOTcfi.js.map +0 -1
- package/dist/compatibility-DPfpqfml.cjs.map +0 -1
- package/dist/src/domains/agents/components/agent-cms-blocks/agent-cms-block-rules.d.ts +0 -8
- package/dist/src/domains/agents/components/agent-edit-page/agent-versions-panel.d.ts +0 -7
- package/dist/src/domains/agents/components/agent-edit-page/version-list.d.ts +0 -7
- package/dist/src/ds/components/ContentBlocks/content-blocks.context.d.ts +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,135 @@
|
|
|
1
1
|
# @mastra/playground-ui
|
|
2
2
|
|
|
3
|
+
## 10.0.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed observational memory progress bars resetting to zero after agent responses finish. The messages and observations sidebar bars now retain their values on stream completion, cancellation, and page reload. Also added a buffer-status endpoint so buffering badges resolve with accurate token counts instead of spinning forever when buffering outlives the stream. ([#12934](https://github.com/mastra-ai/mastra/pull/12934))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`b31c922`](https://github.com/mastra-ai/mastra/commit/b31c922215b513791d98feaea1b98784aa00803a)]:
|
|
10
|
+
- @mastra/client-js@1.3.0-alpha.2
|
|
11
|
+
- @mastra/core@1.3.0-alpha.2
|
|
12
|
+
- @mastra/react@0.2.2-alpha.2
|
|
13
|
+
- @mastra/ai-sdk@1.0.4-alpha.0
|
|
14
|
+
|
|
15
|
+
## 10.0.0-alpha.1
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- Supporting work to allow for cloning agents via the client SDK ([#12796](https://github.com/mastra-ai/mastra/pull/12796))
|
|
20
|
+
|
|
21
|
+
- Added support for request context presets in Mastra Studio. You can now define a JSON file with named requestContext presets and pass it via the `--request-context-presets` CLI flag to both `mastra dev` and `mastra studio` commands. A dropdown selector appears in the Studio Playground, allowing you to quickly switch between preset configurations. ([#12501](https://github.com/mastra-ai/mastra/pull/12501))
|
|
22
|
+
|
|
23
|
+
**Usage:**
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
mastra dev --request-context-presets ./presets.json
|
|
27
|
+
mastra studio --request-context-presets ./presets.json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Presets file format:**
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"development": { "userId": "dev-user", "env": "development" },
|
|
35
|
+
"production": { "userId": "prod-user", "env": "production" }
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
When presets are loaded, a dropdown appears above the JSON editor on the Request Context page. Selecting a preset populates the editor, and manually editing the JSON automatically switches back to "Custom".
|
|
40
|
+
|
|
41
|
+
- Added multi-block instruction editing for agents. Instructions can now be split into separate blocks that are reorderable via drag-and-drop, each with optional conditional display rules based on agent variables. Includes a preview dialog to test how blocks compile with different variable values. ([#12759](https://github.com/mastra-ai/mastra/pull/12759))
|
|
42
|
+
|
|
43
|
+
- Update peer dependencies to match core package version bump (1.1.0) ([#12508](https://github.com/mastra-ai/mastra/pull/12508))
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- dependencies updates: ([#11750](https://github.com/mastra-ai/mastra/pull/11750))
|
|
48
|
+
- Updated dependency [`@assistant-ui/react@^0.12.3` ↗︎](https://www.npmjs.com/package/@assistant-ui/react/v/0.12.3) (from `^0.11.47`, in `dependencies`)
|
|
49
|
+
- Updated dependency [`@assistant-ui/react-markdown@^0.12.1` ↗︎](https://www.npmjs.com/package/@assistant-ui/react-markdown/v/0.12.1) (from `^0.11.6`, in `dependencies`)
|
|
50
|
+
- Updated dependency [`@assistant-ui/react-syntax-highlighter@^0.12.1` ↗︎](https://www.npmjs.com/package/@assistant-ui/react-syntax-highlighter/v/0.12.1) (from `^0.11.6`, in `dependencies`)
|
|
51
|
+
|
|
52
|
+
- dependencies updates: ([#11829](https://github.com/mastra-ai/mastra/pull/11829))
|
|
53
|
+
- Updated dependency [`@codemirror/autocomplete@^6.20.0` ↗︎](https://www.npmjs.com/package/@codemirror/autocomplete/v/6.20.0) (from `^6.18.0`, in `dependencies`)
|
|
54
|
+
- Updated dependency [`@codemirror/lang-javascript@^6.2.4` ↗︎](https://www.npmjs.com/package/@codemirror/lang-javascript/v/6.2.4) (from `^6.2.2`, in `dependencies`)
|
|
55
|
+
- Updated dependency [`@codemirror/state@^6.5.4` ↗︎](https://www.npmjs.com/package/@codemirror/state/v/6.5.4) (from `^6.5.2`, in `dependencies`)
|
|
56
|
+
- Updated dependency [`@codemirror/view@^6.39.12` ↗︎](https://www.npmjs.com/package/@codemirror/view/v/6.39.12) (from `^6.38.6`, in `dependencies`)
|
|
57
|
+
|
|
58
|
+
- dependencies updates: ([#11830](https://github.com/mastra-ai/mastra/pull/11830))
|
|
59
|
+
- Updated dependency [`@uiw/codemirror-theme-dracula@^4.25.4` ↗︎](https://www.npmjs.com/package/@uiw/codemirror-theme-dracula/v/4.25.4) (from `^4.23.14`, in `dependencies`)
|
|
60
|
+
|
|
61
|
+
- dependencies updates: ([#11843](https://github.com/mastra-ai/mastra/pull/11843))
|
|
62
|
+
- Updated dependency [`@uiw/react-codemirror@^4.25.4` ↗︎](https://www.npmjs.com/package/@uiw/react-codemirror/v/4.25.4) (from `^4.23.14`, in `dependencies`)
|
|
63
|
+
|
|
64
|
+
- dependencies updates: ([#12782](https://github.com/mastra-ai/mastra/pull/12782))
|
|
65
|
+
- Updated dependency [`@uiw/codemirror-theme-github@^4.25.4` ↗︎](https://www.npmjs.com/package/@uiw/codemirror-theme-github/v/4.25.4) (from `^4.25.3`, in `dependencies`)
|
|
66
|
+
|
|
67
|
+
- Improved workspace file browser with mount point support. Mounted directories now display provider-specific icons (S3, GCS, Azure, Cloudflare, MinIO) and optional description tooltips. File entries include mount metadata for distinguishing storage providers at a glance. ([#12851](https://github.com/mastra-ai/mastra/pull/12851))
|
|
68
|
+
|
|
69
|
+
- Update docs links to request context ([#12144](https://github.com/mastra-ai/mastra/pull/12144))
|
|
70
|
+
|
|
71
|
+
- **Async buffering for observational memory is now enabled by default.** Observations are pre-computed in the background as conversations grow — when the context window fills up, buffered observations activate instantly with no blocking LLM call. This keeps agents responsive during long conversations. ([#12891](https://github.com/mastra-ai/mastra/pull/12891))
|
|
72
|
+
|
|
73
|
+
**Default settings:**
|
|
74
|
+
- `observation.bufferTokens: 0.2` — buffer every 20% of `messageTokens` (~6k tokens with the default 30k threshold)
|
|
75
|
+
- `observation.bufferActivation: 0.8` — on activation, retain 20% of the message window
|
|
76
|
+
- `reflection.bufferActivation: 0.5` — start background reflection at 50% of the observation threshold
|
|
77
|
+
|
|
78
|
+
**Disabling async buffering:**
|
|
79
|
+
|
|
80
|
+
Set `observation.bufferTokens: false` to disable async buffering for both observations and reflections:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const memory = new Memory({
|
|
84
|
+
options: {
|
|
85
|
+
observationalMemory: {
|
|
86
|
+
model: 'google/gemini-2.5-flash',
|
|
87
|
+
observation: {
|
|
88
|
+
bufferTokens: false,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Model is now required** when passing an observational memory config object. Use `observationalMemory: true` for the default (google/gemini-2.5-flash), or set a model explicitly:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
// Uses default model (google/gemini-2.5-flash)
|
|
99
|
+
observationalMemory: true
|
|
100
|
+
|
|
101
|
+
// Explicit model
|
|
102
|
+
observationalMemory: {
|
|
103
|
+
model: "google/gemini-2.5-flash",
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**`shareTokenBudget` requires `bufferTokens: false`** (temporary limitation). If you use `shareTokenBudget: true`, you must explicitly disable async buffering:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
observationalMemory: {
|
|
111
|
+
model: "google/gemini-2.5-flash",
|
|
112
|
+
shareTokenBudget: true,
|
|
113
|
+
observation: { bufferTokens: false },
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**New streaming event:** `data-om-status` replaces `data-om-progress` with a structured status object containing active window usage, buffered observation/reflection state, and projected activation impact.
|
|
118
|
+
|
|
119
|
+
**Buffering markers:** New `data-om-buffering-start`, `data-om-buffering-end`, and `data-om-buffering-failed` streaming events for UI feedback during background operations.
|
|
120
|
+
|
|
121
|
+
- Fixed skill install/update/remove error toasts showing generic "Internal Server Error" instead of the actual error message. Added mount status indicators to the file browser. ([#12605](https://github.com/mastra-ai/mastra/pull/12605))
|
|
122
|
+
|
|
123
|
+
- Supporting work to enable workflow step metadata ([#12508](https://github.com/mastra-ai/mastra/pull/12508))
|
|
124
|
+
|
|
125
|
+
- Fixed chat messages flashing when loading a thread. Messages now update reactively via useEffect instead of lazy state initialization, preventing the brief flash of empty state. ([#12863](https://github.com/mastra-ai/mastra/pull/12863))
|
|
126
|
+
|
|
127
|
+
- Updated dependencies [[`717ffab`](https://github.com/mastra-ai/mastra/commit/717ffab42cfd58ff723b5c19ada4939997773004), [`e4b6dab`](https://github.com/mastra-ai/mastra/commit/e4b6dab171c5960e340b3ea3ea6da8d64d2b8672), [`6c40593`](https://github.com/mastra-ai/mastra/commit/6c40593d6d2b1b68b0c45d1a3a4c6ac5ecac3937), [`5719fa8`](https://github.com/mastra-ai/mastra/commit/5719fa8880e86e8affe698ec4b3807c7e0e0a06f), [`83cda45`](https://github.com/mastra-ai/mastra/commit/83cda4523e588558466892bff8f80f631a36945a), [`11804ad`](https://github.com/mastra-ai/mastra/commit/11804adf1d6be46ebe216be40a43b39bb8b397d7), [`11804ad`](https://github.com/mastra-ai/mastra/commit/11804adf1d6be46ebe216be40a43b39bb8b397d7), [`aa95f95`](https://github.com/mastra-ai/mastra/commit/aa95f958b186ae5c9f4219c88e268f5565c277a2), [`f8772f5`](https://github.com/mastra-ai/mastra/commit/f8772f595d34926ae2135ed4ec2e9441704d239c), [`047635c`](https://github.com/mastra-ai/mastra/commit/047635ccd7861d726c62d135560c0022a5490aec), [`f5501ae`](https://github.com/mastra-ai/mastra/commit/f5501aedb0a11106c7db7e480d6eaf3971b7bda8), [`44573af`](https://github.com/mastra-ai/mastra/commit/44573afad0a4bc86f627d6cbc0207961cdcb3bc3), [`00e3861`](https://github.com/mastra-ai/mastra/commit/00e3861863fbfee78faeb1ebbdc7c0223aae13ff), [`7bfbc52`](https://github.com/mastra-ai/mastra/commit/7bfbc52a8604feb0fff2c0a082c13c0c2a3df1a2), [`42a2e13`](https://github.com/mastra-ai/mastra/commit/42a2e1388869c87d81f09fcdc58b1e9e3c99abe6), [`1445994`](https://github.com/mastra-ai/mastra/commit/1445994aee19c9334a6a101cf7bd80ca7ed4d186), [`73b0925`](https://github.com/mastra-ai/mastra/commit/73b0925b63edaeacd32b0613f83fcd1daec40846), [`61f44a2`](https://github.com/mastra-ai/mastra/commit/61f44a26861c89e364f367ff40825bdb7f19df55), [`37145d2`](https://github.com/mastra-ai/mastra/commit/37145d25f99dc31f1a9105576e5452609843ce32), [`fdad759`](https://github.com/mastra-ai/mastra/commit/fdad75939ff008b27625f5ec0ce9c6915d99d9ec), [`e4569c5`](https://github.com/mastra-ai/mastra/commit/e4569c589e00c4061a686c9eb85afe1b7050b0a8), [`be42958`](https://github.com/mastra-ai/mastra/commit/be42958d62c9f3d6b3a037580a6ef362afa47240), [`7309a85`](https://github.com/mastra-ai/mastra/commit/7309a85427281a8be23f4fb80ca52e18eaffd596), [`5bee8ea`](https://github.com/mastra-ai/mastra/commit/5bee8eaa5e25566994a10f1c76fd9e72e05f925a), [`99424f6`](https://github.com/mastra-ai/mastra/commit/99424f6862ffb679c4ec6765501486034754a4c2), [`1445994`](https://github.com/mastra-ai/mastra/commit/1445994aee19c9334a6a101cf7bd80ca7ed4d186), [`44eb452`](https://github.com/mastra-ai/mastra/commit/44eb4529b10603c279688318bebf3048543a1d61), [`a211248`](https://github.com/mastra-ai/mastra/commit/a21124845b1b1321b6075a8377c341c7f5cda1b6), [`6c40593`](https://github.com/mastra-ai/mastra/commit/6c40593d6d2b1b68b0c45d1a3a4c6ac5ecac3937), [`4493fb9`](https://github.com/mastra-ai/mastra/commit/4493fb93f68e504c8531b90fd5b2e1866bee6381), [`8c1135d`](https://github.com/mastra-ai/mastra/commit/8c1135dfb91b057283eae7ee11f9ec28753cc64f), [`dd39e54`](https://github.com/mastra-ai/mastra/commit/dd39e54ea34532c995b33bee6e0e808bf41a7341), [`b6fad9a`](https://github.com/mastra-ai/mastra/commit/b6fad9a602182b1cc0df47cd8c55004fa829ad61), [`e8f3910`](https://github.com/mastra-ai/mastra/commit/e8f3910d5323d91a69ec35ad78d14a524f54ca8a), [`4129c07`](https://github.com/mastra-ai/mastra/commit/4129c073349b5a66643fd8136ebfe9d7097cf793), [`5b930ab`](https://github.com/mastra-ai/mastra/commit/5b930aba1834d9898e8460a49d15106f31ac7c8d), [`4be93d0`](https://github.com/mastra-ai/mastra/commit/4be93d09d68e20aaf0ea3f210749422719618b5f), [`047635c`](https://github.com/mastra-ai/mastra/commit/047635ccd7861d726c62d135560c0022a5490aec), [`047635c`](https://github.com/mastra-ai/mastra/commit/047635ccd7861d726c62d135560c0022a5490aec), [`8c90ff4`](https://github.com/mastra-ai/mastra/commit/8c90ff4d3414e7f2a2d216ea91274644f7b29133), [`ed232d1`](https://github.com/mastra-ai/mastra/commit/ed232d1583f403925dc5ae45f7bee948cf2a182b), [`3891795`](https://github.com/mastra-ai/mastra/commit/38917953518eb4154a984ee36e6ededdcfe80f72), [`4f955b2`](https://github.com/mastra-ai/mastra/commit/4f955b20c7f66ed282ee1fd8709696fa64c4f19d), [`55a4c90`](https://github.com/mastra-ai/mastra/commit/55a4c9044ac7454349b9f6aeba0bbab5ee65d10f)]:
|
|
128
|
+
- @mastra/core@1.3.0-alpha.1
|
|
129
|
+
- @mastra/client-js@1.3.0-alpha.1
|
|
130
|
+
- @mastra/ai-sdk@1.0.4-alpha.0
|
|
131
|
+
- @mastra/react@0.2.2-alpha.1
|
|
132
|
+
|
|
3
133
|
## 9.1.0-alpha.0
|
|
4
134
|
|
|
5
135
|
### Minor Changes
|
|
@@ -12,15 +12,22 @@ const isWorkspaceV1Supported = (client) => {
|
|
|
12
12
|
const clientSupported = workspaceClientMethods.every((method) => hasMethod(client, method));
|
|
13
13
|
return coreSupported && clientSupported;
|
|
14
14
|
};
|
|
15
|
-
const
|
|
16
|
-
if (!error || typeof error !== "object") return
|
|
17
|
-
if ("status" in error && error.status ===
|
|
18
|
-
return
|
|
15
|
+
const getStatusCode = (error) => {
|
|
16
|
+
if (!error || typeof error !== "object") return void 0;
|
|
17
|
+
if ("status" in error && typeof error.status === "number") {
|
|
18
|
+
return error.status;
|
|
19
19
|
}
|
|
20
|
-
if ("statusCode" in error && error.statusCode ===
|
|
21
|
-
return
|
|
20
|
+
if ("statusCode" in error && typeof error.statusCode === "number") {
|
|
21
|
+
return error.statusCode;
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return void 0;
|
|
24
|
+
};
|
|
25
|
+
const hasStatusCode = (error, statusCode) => {
|
|
26
|
+
return getStatusCode(error) === statusCode;
|
|
27
|
+
};
|
|
28
|
+
const isClientError = (error) => {
|
|
29
|
+
const status = getStatusCode(error);
|
|
30
|
+
return status !== void 0 && status >= 400 && status < 500;
|
|
24
31
|
};
|
|
25
32
|
const isWorkspaceNotSupportedError = (error) => {
|
|
26
33
|
if (hasStatusCode(error, 501)) {
|
|
@@ -32,18 +39,8 @@ const isWorkspaceNotSupportedError = (error) => {
|
|
|
32
39
|
}
|
|
33
40
|
return false;
|
|
34
41
|
};
|
|
35
|
-
const isNotFoundError = (error) => {
|
|
36
|
-
if (hasStatusCode(error, 404)) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
if (error && typeof error === "object" && "message" in error) {
|
|
40
|
-
const message = error.message;
|
|
41
|
-
return message.includes("status: 404");
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
};
|
|
45
42
|
const shouldRetryWorkspaceQuery = (failureCount, error) => {
|
|
46
|
-
if (
|
|
43
|
+
if (isClientError(error)) {
|
|
47
44
|
return false;
|
|
48
45
|
}
|
|
49
46
|
if (isWorkspaceNotSupportedError(error)) {
|
|
@@ -55,4 +52,4 @@ const shouldRetryWorkspaceQuery = (failureCount, error) => {
|
|
|
55
52
|
exports.isWorkspaceNotSupportedError = isWorkspaceNotSupportedError;
|
|
56
53
|
exports.isWorkspaceV1Supported = isWorkspaceV1Supported;
|
|
57
54
|
exports.shouldRetryWorkspaceQuery = shouldRetryWorkspaceQuery;
|
|
58
|
-
//# sourceMappingURL=compatibility-
|
|
55
|
+
//# sourceMappingURL=compatibility-BSJHu6pD.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility-BSJHu6pD.cjs","sources":["../src/domains/workspace/client-utils.ts","../src/domains/workspace/compatibility.ts"],"sourcesContent":["/**\n * Checks if a method exists on an object and is callable.\n */\nexport function hasMethod<T>(obj: T, method: string): boolean {\n return method in (obj as object) && typeof (obj as Record<string, unknown>)[method] === 'function';\n}\n","import { coreFeatures } from '@mastra/core/features';\nimport { MastraClient } from '@mastra/client-js';\nimport { hasMethod } from './client-utils';\n\n/**\n * Checks if workspace v1 features are supported by both core and client.\n * This guards against version mismatches between playground-ui, core, and client-js.\n */\nexport const isWorkspaceV1Supported = (client: MastraClient) => {\n const workspaceClientMethods = ['listWorkspaces', 'getWorkspace'];\n\n const coreSupported = coreFeatures.has('workspaces-v1');\n const clientSupported = workspaceClientMethods.every(method => hasMethod(client, method));\n\n return coreSupported && clientSupported;\n};\n\n/**\n * Gets the HTTP status code from an error if present.\n * Supports MastraClientError, fetch Response, and other HTTP client error formats.\n */\nconst getStatusCode = (error: unknown): number | undefined => {\n if (!error || typeof error !== 'object') return undefined;\n\n // Check for status property (MastraClientError, fetch Response, etc.)\n if ('status' in error && typeof (error as { status: unknown }).status === 'number') {\n return (error as { status: number }).status;\n }\n\n // Check for statusCode property (from some HTTP clients)\n if ('statusCode' in error && typeof (error as { statusCode: unknown }).statusCode === 'number') {\n return (error as { statusCode: number }).statusCode;\n }\n\n return undefined;\n};\n\n/**\n * Checks if an error has a specific HTTP status code.\n * Supports MastraClientError, fetch Response, and other HTTP client error formats.\n */\nconst hasStatusCode = (error: unknown, statusCode: number): boolean => {\n return getStatusCode(error) === statusCode;\n};\n\n/**\n * Checks if an error is a 4xx client error (e.g., 400, 401, 403, 404).\n * Client errors won't resolve with retries.\n */\nconst isClientError = (error: unknown): boolean => {\n const status = getStatusCode(error);\n return status !== undefined && status >= 400 && status < 500;\n};\n\n/**\n * Checks if an error is a \"Not Implemented\" (501) error from the server.\n * This indicates the server's @mastra/core version doesn't support workspaces.\n */\nexport const isWorkspaceNotSupportedError = (error: unknown): boolean => {\n if (hasStatusCode(error, 501)) {\n return true;\n }\n\n // Check error message for our specific error\n if (error && typeof error === 'object' && 'message' in error) {\n const message = (error as { message: string }).message;\n return message.includes('Workspace v1 not supported') || message.includes('501');\n }\n\n return false;\n};\n\n/**\n * Checks if an error is a \"Not Found\" (404) error from the server.\n * This indicates the requested resource doesn't exist (e.g., file not found).\n */\nexport const isNotFoundError = (error: unknown): boolean => {\n if (hasStatusCode(error, 404)) {\n return true;\n }\n\n // Check error message for status code (client-js throws Error with message like \"HTTP error! status: 404 - ...\")\n if (error && typeof error === 'object' && 'message' in error) {\n const message = (error as { message: string }).message;\n return message.includes('status: 404');\n }\n\n return false;\n};\n\n/**\n * React Query retry function that doesn't retry on client errors (4xx) or 501 errors.\n * Use this to prevent infinite retries when resources don't exist, access is denied, or workspaces aren't supported.\n */\nexport const shouldRetryWorkspaceQuery = (failureCount: number, error: unknown): boolean => {\n // Don't retry 4xx client errors (400, 401, 403, 404, etc.) - these won't resolve with retries\n if (isClientError(error)) {\n return false;\n }\n // Don't retry 501 \"Not Implemented\" errors - they won't resolve with retries\n if (isWorkspaceNotSupportedError(error)) {\n return false;\n }\n // Default retry behavior: retry up to 3 times\n return failureCount < 3;\n};\n"],"names":["coreFeatures"],"mappings":";;;;AAGO,SAAS,SAAA,CAAa,KAAQ,MAAA,EAAyB;AAC5D,EAAA,OAAO,MAAA,IAAW,GAAA,IAAkB,OAAQ,GAAA,CAAgC,MAAM,CAAA,KAAM,UAAA;AAC1F;;ACGO,MAAM,sBAAA,GAAyB,CAAC,MAAA,KAAyB;AAC9D,EAAA,MAAM,sBAAA,GAAyB,CAAC,gBAAA,EAAkB,cAAc,CAAA;AAEhE,EAAA,MAAM,aAAA,GAAgBA,qBAAA,CAAa,GAAA,CAAI,eAAe,CAAA;AACtD,EAAA,MAAM,kBAAkB,sBAAA,CAAuB,KAAA,CAAM,YAAU,SAAA,CAAU,MAAA,EAAQ,MAAM,CAAC,CAAA;AAExF,EAAA,OAAO,aAAA,IAAiB,eAAA;AAC1B;AAMA,MAAM,aAAA,GAAgB,CAAC,KAAA,KAAuC;AAC5D,EAAA,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,UAAU,OAAO,MAAA;AAGhD,EAAA,IAAI,QAAA,IAAY,KAAA,IAAS,OAAQ,KAAA,CAA8B,WAAW,QAAA,EAAU;AAClF,IAAA,OAAQ,KAAA,CAA6B,MAAA;AAAA,EACvC;AAGA,EAAA,IAAI,YAAA,IAAgB,KAAA,IAAS,OAAQ,KAAA,CAAkC,eAAe,QAAA,EAAU;AAC9F,IAAA,OAAQ,KAAA,CAAiC,UAAA;AAAA,EAC3C;AAEA,EAAA,OAAO,MAAA;AACT,CAAA;AAMA,MAAM,aAAA,GAAgB,CAAC,KAAA,EAAgB,UAAA,KAAgC;AACrE,EAAA,OAAO,aAAA,CAAc,KAAK,CAAA,KAAM,UAAA;AAClC,CAAA;AAMA,MAAM,aAAA,GAAgB,CAAC,KAAA,KAA4B;AACjD,EAAA,MAAM,MAAA,GAAS,cAAc,KAAK,CAAA;AAClC,EAAA,OAAO,MAAA,KAAW,MAAA,IAAa,MAAA,IAAU,GAAA,IAAO,MAAA,GAAS,GAAA;AAC3D,CAAA;AAMO,MAAM,4BAAA,GAA+B,CAAC,KAAA,KAA4B;AACvE,EAAA,IAAI,aAAA,CAAc,KAAA,EAAO,GAAG,CAAA,EAAG;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,IAAI,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAY,aAAa,KAAA,EAAO;AAC5D,IAAA,MAAM,UAAW,KAAA,CAA8B,OAAA;AAC/C,IAAA,OAAO,QAAQ,QAAA,CAAS,4BAA4B,CAAA,IAAK,OAAA,CAAQ,SAAS,KAAK,CAAA;AAAA,EACjF;AAEA,EAAA,OAAO,KAAA;AACT;AAwBO,MAAM,yBAAA,GAA4B,CAAC,YAAA,EAAsB,KAAA,KAA4B;AAE1F,EAAA,IAAI,aAAA,CAAc,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI,4BAAA,CAA6B,KAAK,CAAA,EAAG;AACvC,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO,YAAA,GAAe,CAAA;AACxB;;;;;;"}
|
|
@@ -10,15 +10,22 @@ const isWorkspaceV1Supported = (client) => {
|
|
|
10
10
|
const clientSupported = workspaceClientMethods.every((method) => hasMethod(client, method));
|
|
11
11
|
return coreSupported && clientSupported;
|
|
12
12
|
};
|
|
13
|
-
const
|
|
14
|
-
if (!error || typeof error !== "object") return
|
|
15
|
-
if ("status" in error && error.status ===
|
|
16
|
-
return
|
|
13
|
+
const getStatusCode = (error) => {
|
|
14
|
+
if (!error || typeof error !== "object") return void 0;
|
|
15
|
+
if ("status" in error && typeof error.status === "number") {
|
|
16
|
+
return error.status;
|
|
17
17
|
}
|
|
18
|
-
if ("statusCode" in error && error.statusCode ===
|
|
19
|
-
return
|
|
18
|
+
if ("statusCode" in error && typeof error.statusCode === "number") {
|
|
19
|
+
return error.statusCode;
|
|
20
20
|
}
|
|
21
|
-
return
|
|
21
|
+
return void 0;
|
|
22
|
+
};
|
|
23
|
+
const hasStatusCode = (error, statusCode) => {
|
|
24
|
+
return getStatusCode(error) === statusCode;
|
|
25
|
+
};
|
|
26
|
+
const isClientError = (error) => {
|
|
27
|
+
const status = getStatusCode(error);
|
|
28
|
+
return status !== void 0 && status >= 400 && status < 500;
|
|
22
29
|
};
|
|
23
30
|
const isWorkspaceNotSupportedError = (error) => {
|
|
24
31
|
if (hasStatusCode(error, 501)) {
|
|
@@ -30,18 +37,8 @@ const isWorkspaceNotSupportedError = (error) => {
|
|
|
30
37
|
}
|
|
31
38
|
return false;
|
|
32
39
|
};
|
|
33
|
-
const isNotFoundError = (error) => {
|
|
34
|
-
if (hasStatusCode(error, 404)) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
if (error && typeof error === "object" && "message" in error) {
|
|
38
|
-
const message = error.message;
|
|
39
|
-
return message.includes("status: 404");
|
|
40
|
-
}
|
|
41
|
-
return false;
|
|
42
|
-
};
|
|
43
40
|
const shouldRetryWorkspaceQuery = (failureCount, error) => {
|
|
44
|
-
if (
|
|
41
|
+
if (isClientError(error)) {
|
|
45
42
|
return false;
|
|
46
43
|
}
|
|
47
44
|
if (isWorkspaceNotSupportedError(error)) {
|
|
@@ -51,4 +48,4 @@ const shouldRetryWorkspaceQuery = (failureCount, error) => {
|
|
|
51
48
|
};
|
|
52
49
|
|
|
53
50
|
export { isWorkspaceNotSupportedError as a, isWorkspaceV1Supported as i, shouldRetryWorkspaceQuery as s };
|
|
54
|
-
//# sourceMappingURL=compatibility-
|
|
51
|
+
//# sourceMappingURL=compatibility-f2FIOihW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility-f2FIOihW.js","sources":["../src/domains/workspace/client-utils.ts","../src/domains/workspace/compatibility.ts"],"sourcesContent":["/**\n * Checks if a method exists on an object and is callable.\n */\nexport function hasMethod<T>(obj: T, method: string): boolean {\n return method in (obj as object) && typeof (obj as Record<string, unknown>)[method] === 'function';\n}\n","import { coreFeatures } from '@mastra/core/features';\nimport { MastraClient } from '@mastra/client-js';\nimport { hasMethod } from './client-utils';\n\n/**\n * Checks if workspace v1 features are supported by both core and client.\n * This guards against version mismatches between playground-ui, core, and client-js.\n */\nexport const isWorkspaceV1Supported = (client: MastraClient) => {\n const workspaceClientMethods = ['listWorkspaces', 'getWorkspace'];\n\n const coreSupported = coreFeatures.has('workspaces-v1');\n const clientSupported = workspaceClientMethods.every(method => hasMethod(client, method));\n\n return coreSupported && clientSupported;\n};\n\n/**\n * Gets the HTTP status code from an error if present.\n * Supports MastraClientError, fetch Response, and other HTTP client error formats.\n */\nconst getStatusCode = (error: unknown): number | undefined => {\n if (!error || typeof error !== 'object') return undefined;\n\n // Check for status property (MastraClientError, fetch Response, etc.)\n if ('status' in error && typeof (error as { status: unknown }).status === 'number') {\n return (error as { status: number }).status;\n }\n\n // Check for statusCode property (from some HTTP clients)\n if ('statusCode' in error && typeof (error as { statusCode: unknown }).statusCode === 'number') {\n return (error as { statusCode: number }).statusCode;\n }\n\n return undefined;\n};\n\n/**\n * Checks if an error has a specific HTTP status code.\n * Supports MastraClientError, fetch Response, and other HTTP client error formats.\n */\nconst hasStatusCode = (error: unknown, statusCode: number): boolean => {\n return getStatusCode(error) === statusCode;\n};\n\n/**\n * Checks if an error is a 4xx client error (e.g., 400, 401, 403, 404).\n * Client errors won't resolve with retries.\n */\nconst isClientError = (error: unknown): boolean => {\n const status = getStatusCode(error);\n return status !== undefined && status >= 400 && status < 500;\n};\n\n/**\n * Checks if an error is a \"Not Implemented\" (501) error from the server.\n * This indicates the server's @mastra/core version doesn't support workspaces.\n */\nexport const isWorkspaceNotSupportedError = (error: unknown): boolean => {\n if (hasStatusCode(error, 501)) {\n return true;\n }\n\n // Check error message for our specific error\n if (error && typeof error === 'object' && 'message' in error) {\n const message = (error as { message: string }).message;\n return message.includes('Workspace v1 not supported') || message.includes('501');\n }\n\n return false;\n};\n\n/**\n * Checks if an error is a \"Not Found\" (404) error from the server.\n * This indicates the requested resource doesn't exist (e.g., file not found).\n */\nexport const isNotFoundError = (error: unknown): boolean => {\n if (hasStatusCode(error, 404)) {\n return true;\n }\n\n // Check error message for status code (client-js throws Error with message like \"HTTP error! status: 404 - ...\")\n if (error && typeof error === 'object' && 'message' in error) {\n const message = (error as { message: string }).message;\n return message.includes('status: 404');\n }\n\n return false;\n};\n\n/**\n * React Query retry function that doesn't retry on client errors (4xx) or 501 errors.\n * Use this to prevent infinite retries when resources don't exist, access is denied, or workspaces aren't supported.\n */\nexport const shouldRetryWorkspaceQuery = (failureCount: number, error: unknown): boolean => {\n // Don't retry 4xx client errors (400, 401, 403, 404, etc.) - these won't resolve with retries\n if (isClientError(error)) {\n return false;\n }\n // Don't retry 501 \"Not Implemented\" errors - they won't resolve with retries\n if (isWorkspaceNotSupportedError(error)) {\n return false;\n }\n // Default retry behavior: retry up to 3 times\n return failureCount < 3;\n};\n"],"names":[],"mappings":";;AAGO,SAAS,SAAA,CAAa,KAAQ,MAAA,EAAyB;AAC5D,EAAA,OAAO,MAAA,IAAW,GAAA,IAAkB,OAAQ,GAAA,CAAgC,MAAM,CAAA,KAAM,UAAA;AAC1F;;ACGO,MAAM,sBAAA,GAAyB,CAAC,MAAA,KAAyB;AAC9D,EAAA,MAAM,sBAAA,GAAyB,CAAC,gBAAA,EAAkB,cAAc,CAAA;AAEhE,EAAA,MAAM,aAAA,GAAgB,YAAA,CAAa,GAAA,CAAI,eAAe,CAAA;AACtD,EAAA,MAAM,kBAAkB,sBAAA,CAAuB,KAAA,CAAM,YAAU,SAAA,CAAU,MAAA,EAAQ,MAAM,CAAC,CAAA;AAExF,EAAA,OAAO,aAAA,IAAiB,eAAA;AAC1B;AAMA,MAAM,aAAA,GAAgB,CAAC,KAAA,KAAuC;AAC5D,EAAA,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,UAAU,OAAO,MAAA;AAGhD,EAAA,IAAI,QAAA,IAAY,KAAA,IAAS,OAAQ,KAAA,CAA8B,WAAW,QAAA,EAAU;AAClF,IAAA,OAAQ,KAAA,CAA6B,MAAA;AAAA,EACvC;AAGA,EAAA,IAAI,YAAA,IAAgB,KAAA,IAAS,OAAQ,KAAA,CAAkC,eAAe,QAAA,EAAU;AAC9F,IAAA,OAAQ,KAAA,CAAiC,UAAA;AAAA,EAC3C;AAEA,EAAA,OAAO,MAAA;AACT,CAAA;AAMA,MAAM,aAAA,GAAgB,CAAC,KAAA,EAAgB,UAAA,KAAgC;AACrE,EAAA,OAAO,aAAA,CAAc,KAAK,CAAA,KAAM,UAAA;AAClC,CAAA;AAMA,MAAM,aAAA,GAAgB,CAAC,KAAA,KAA4B;AACjD,EAAA,MAAM,MAAA,GAAS,cAAc,KAAK,CAAA;AAClC,EAAA,OAAO,MAAA,KAAW,MAAA,IAAa,MAAA,IAAU,GAAA,IAAO,MAAA,GAAS,GAAA;AAC3D,CAAA;AAMO,MAAM,4BAAA,GAA+B,CAAC,KAAA,KAA4B;AACvE,EAAA,IAAI,aAAA,CAAc,KAAA,EAAO,GAAG,CAAA,EAAG;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,IAAI,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAY,aAAa,KAAA,EAAO;AAC5D,IAAA,MAAM,UAAW,KAAA,CAA8B,OAAA;AAC/C,IAAA,OAAO,QAAQ,QAAA,CAAS,4BAA4B,CAAA,IAAK,OAAA,CAAQ,SAAS,KAAK,CAAA;AAAA,EACjF;AAEA,EAAA,OAAO,KAAA;AACT;AAwBO,MAAM,yBAAA,GAA4B,CAAC,YAAA,EAAsB,KAAA,KAA4B;AAE1F,EAAA,IAAI,aAAA,CAAc,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI,4BAAA,CAA6B,KAAK,CAAA,EAAG;AACvC,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO,YAAA,GAAe,CAAA;AACxB;;;;"}
|