@dbx-tools/ui-mastra 0.9.74 → 0.9.93
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/index.ts +1 -1
- package/package.json +6 -6
- package/src/react/tool-pill.tsx +18 -2
- package/src/support/shiki-plugin.ts +11 -9
package/index.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Hand edits are overwritten on the next watch; this file is read-only.
|
|
4
4
|
|
|
5
5
|
export const PACKAGE_IDENTIFIER = "@dbx-tools/ui-mastra";
|
|
6
|
-
export const PACKAGE_VERSION = "0.9.
|
|
6
|
+
export const PACKAGE_VERSION = "0.9.93";
|
|
7
7
|
export * as reactBubbles from "./src/react/bubbles.tsx";
|
|
8
8
|
export * as reactChatApprovals from "./src/react/chat-approvals.ts";
|
|
9
9
|
export * as reactChatComposer from "./src/react/chat-composer.tsx";
|
package/package.json
CHANGED
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"react-dom": "~19.2.4"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@dbx-tools/shared-core": "^0.9.
|
|
33
|
-
"@dbx-tools/shared-genie": "^0.9.
|
|
34
|
-
"@dbx-tools/shared-mastra": "^0.9.
|
|
35
|
-
"@dbx-tools/shared-model": "^0.9.
|
|
36
|
-
"@dbx-tools/ui": "^0.9.
|
|
32
|
+
"@dbx-tools/shared-core": "^0.9.93",
|
|
33
|
+
"@dbx-tools/shared-genie": "^0.9.93",
|
|
34
|
+
"@dbx-tools/shared-mastra": "^0.9.93",
|
|
35
|
+
"@dbx-tools/shared-model": "^0.9.93",
|
|
36
|
+
"@dbx-tools/ui": "^0.9.93",
|
|
37
37
|
"@mastra/client-js": "1.50.0",
|
|
38
38
|
"@mastra/core": "1.71.0",
|
|
39
39
|
"@tanstack/react-table": "^8.21.3",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"version": "0.9.
|
|
53
|
+
"version": "0.9.93",
|
|
54
54
|
"dbxToolsConfig": {
|
|
55
55
|
"tags": [
|
|
56
56
|
"ui"
|
package/src/react/tool-pill.tsx
CHANGED
|
@@ -15,18 +15,34 @@ import type { ToolEvent, ToolProgress } from "./types.ts";
|
|
|
15
15
|
// groups the wire events one assistant turn produced into per-sub-call
|
|
16
16
|
// cards (question + numbered queries + prose answers + errors).
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Mastra registers built-in workspace tools under
|
|
20
|
+
* `WORKSPACE_TOOLS_PREFIX` (`mastra_workspace_*`). The wire id stays
|
|
21
|
+
* that branded name; session pills drop the prefix so labels read as
|
|
22
|
+
* `Execute Command` rather than `Mastra Workspace Execute Command`.
|
|
23
|
+
*/
|
|
24
|
+
const MASTRA_WORKSPACE_TOOL_PREFIX = "mastra_workspace_";
|
|
25
|
+
|
|
18
26
|
/**
|
|
19
27
|
* Turn a snake/camel tool id into a Title Cased label the user can
|
|
20
28
|
* read. Genie tools land on this surface as flat ids
|
|
21
29
|
* (`ask_genie`, `get_statement`, `prepare_chart`) plus per-space
|
|
22
|
-
* suffixes for non-default aliases (`ask_genie_sales`).
|
|
30
|
+
* suffixes for non-default aliases (`ask_genie_sales`). Mastra
|
|
31
|
+
* workspace tools keep their `mastra_workspace_` wire prefix, which
|
|
32
|
+
* this strips before labeling.
|
|
23
33
|
*
|
|
24
34
|
* Examples:
|
|
25
35
|
* `ask_genie` -> `Ask Genie`
|
|
26
36
|
* `ask_genie_sales` -> `Ask Genie Sales`
|
|
37
|
+
* `mastra_workspace_execute_command` -> `Execute Command`
|
|
27
38
|
* `myCoolTool` -> `My Cool Tool`
|
|
28
39
|
*/
|
|
29
|
-
export const humanizeToolName = (toolName: string): string =>
|
|
40
|
+
export const humanizeToolName = (toolName: string): string => {
|
|
41
|
+
const label = toolName.startsWith(MASTRA_WORKSPACE_TOOL_PREFIX)
|
|
42
|
+
? toolName.slice(MASTRA_WORKSPACE_TOOL_PREFIX.length)
|
|
43
|
+
: toolName;
|
|
44
|
+
return stringUtils.toLabel(label);
|
|
45
|
+
};
|
|
30
46
|
|
|
31
47
|
/**
|
|
32
48
|
* Track the freshest status label a running tool has published so the
|
|
@@ -13,7 +13,10 @@ import type { CodeHighlighterPlugin } from "streamdown";
|
|
|
13
13
|
* query previews); the rest cover code the assistant might emit. Kept
|
|
14
14
|
* to a curated set so shiki only bundles these grammars.
|
|
15
15
|
*/
|
|
16
|
-
const LANGUAGES
|
|
16
|
+
const LANGUAGES = [
|
|
17
|
+
"text",
|
|
18
|
+
"plaintext",
|
|
19
|
+
"txt",
|
|
17
20
|
"sql",
|
|
18
21
|
"python",
|
|
19
22
|
"typescript",
|
|
@@ -22,7 +25,7 @@ const LANGUAGES: BundledLanguage[] = [
|
|
|
22
25
|
"bash",
|
|
23
26
|
"yaml",
|
|
24
27
|
"markdown",
|
|
25
|
-
];
|
|
28
|
+
] as const;
|
|
26
29
|
|
|
27
30
|
/**
|
|
28
31
|
* Single light theme. The demo has no dark-mode toggle, and a single
|
|
@@ -33,7 +36,7 @@ const LANGUAGES: BundledLanguage[] = [
|
|
|
33
36
|
const THEME: BundledTheme = "github-light";
|
|
34
37
|
|
|
35
38
|
/** Languages we can tokenize, as a set for O(1) support checks. */
|
|
36
|
-
const SUPPORTED = new Set<
|
|
39
|
+
const SUPPORTED = new Set<string>(LANGUAGES);
|
|
37
40
|
|
|
38
41
|
let _highlighter: HighlighterCore | null = null;
|
|
39
42
|
let _loading: Promise<HighlighterCore> | null = null;
|
|
@@ -50,9 +53,9 @@ function loadHighlighter(): Promise<HighlighterCore> {
|
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
/** Tokenize `code` with the active theme into Streamdown's result shape. */
|
|
53
|
-
function highlightTokens(h: HighlighterCore, code: string, language:
|
|
56
|
+
function highlightTokens(h: HighlighterCore, code: string, language: string) {
|
|
54
57
|
const { tokens, fg, bg, rootStyle } = h.codeToTokens(code, {
|
|
55
|
-
lang: language,
|
|
58
|
+
lang: language as BundledLanguage,
|
|
56
59
|
theme: THEME,
|
|
57
60
|
});
|
|
58
61
|
return { tokens, fg, bg, rootStyle };
|
|
@@ -70,7 +73,7 @@ const escapeHtml = stringUtils.escapeHtml;
|
|
|
70
73
|
* supported or shiki fails to parse the snippet.
|
|
71
74
|
*/
|
|
72
75
|
export async function highlightToHtml(code: string, language: string): Promise<string> {
|
|
73
|
-
if (!SUPPORTED.has(language
|
|
76
|
+
if (!SUPPORTED.has(language)) return escapeHtml(code);
|
|
74
77
|
const h = await loadHighlighter();
|
|
75
78
|
try {
|
|
76
79
|
const { tokens } = h.codeToTokens(code, {
|
|
@@ -100,13 +103,12 @@ export async function highlightToHtml(code: string, language: string): Promise<s
|
|
|
100
103
|
* block stays plaintext rather than throwing.
|
|
101
104
|
*/
|
|
102
105
|
export function createShikiPlugin(): CodeHighlighterPlugin {
|
|
103
|
-
const isSupported = (language: string):
|
|
104
|
-
SUPPORTED.has(language as BundledLanguage);
|
|
106
|
+
const isSupported = (language: string): boolean => SUPPORTED.has(language);
|
|
105
107
|
|
|
106
108
|
return {
|
|
107
109
|
name: "shiki",
|
|
108
110
|
type: "code-highlighter",
|
|
109
|
-
getSupportedLanguages: () => LANGUAGES,
|
|
111
|
+
getSupportedLanguages: () => [...LANGUAGES],
|
|
110
112
|
getThemes: () => [THEME, THEME],
|
|
111
113
|
supportsLanguage: (language) => isSupported(language),
|
|
112
114
|
highlight: (options, callback) => {
|