@runtypelabs/persona 3.29.0 → 3.30.0
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/README.md +55 -0
- package/dist/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-CxvHw0X6.d.cts → types-B_Qazlm4.d.cts} +6 -0
- package/dist/animations/{types-CxvHw0X6.d.ts → types-B_Qazlm4.d.ts} +6 -0
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/codegen.cjs +6 -6
- package/dist/codegen.js +4 -4
- package/dist/index.cjs +47 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +127 -7
- package/dist/index.d.ts +127 -7
- package/dist/index.global.js +60 -60
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +47 -47
- package/dist/index.js.map +1 -1
- package/dist/launcher.global.js +2 -2
- package/dist/launcher.global.js.map +1 -1
- package/dist/plugin-kit.cjs +1 -0
- package/dist/plugin-kit.d.cts +98 -0
- package/dist/plugin-kit.d.ts +98 -0
- package/dist/plugin-kit.js +1 -0
- package/dist/smart-dom-reader.d.cts +113 -4
- package/dist/smart-dom-reader.d.ts +113 -4
- package/dist/theme-editor.cjs +38 -38
- package/dist/theme-editor.d.cts +117 -6
- package/dist/theme-editor.d.ts +117 -6
- package/dist/theme-editor.js +38 -38
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +2 -0
- package/dist/theme-reference.d.ts +2 -0
- package/dist/theme-reference.js +1 -1
- package/package.json +8 -2
- package/src/client.test.ts +40 -0
- package/src/client.ts +18 -4
- package/src/components/approval-bubble.test.ts +268 -0
- package/src/components/approval-bubble.ts +170 -20
- package/src/components/launcher.ts +6 -3
- package/src/components/tool-bubble.test.ts +39 -0
- package/src/components/tool-bubble.ts +4 -0
- package/src/generated/runtype-openapi-contract.ts +12 -0
- package/src/index-core.ts +1 -0
- package/src/plugin-kit.test.ts +230 -0
- package/src/plugin-kit.ts +294 -0
- package/src/plugins/types.ts +49 -2
- package/src/session.test.ts +99 -0
- package/src/session.ts +204 -32
- package/src/session.webmcp.test.ts +326 -6
- package/src/theme-editor/preview-utils.test.ts +10 -0
- package/src/theme-editor/preview-utils.ts +29 -1
- package/src/theme-editor/sections.test.ts +17 -0
- package/src/theme-editor/sections.ts +31 -0
- package/src/theme-reference.ts +1 -1
- package/src/types/theme.ts +2 -0
- package/src/types.ts +59 -2
- package/src/ui.approval-plugin.test.ts +204 -0
- package/src/ui.ts +149 -16
- package/src/utils/theme.test.ts +6 -2
- package/src/utils/theme.ts +0 -8
- package/src/utils/tokens.ts +6 -1
- package/src/webmcp-bridge.test.ts +66 -0
- package/src/webmcp-bridge.ts +49 -0
package/src/webmcp-bridge.ts
CHANGED
|
@@ -66,6 +66,14 @@ interface ModelContextToolInfo {
|
|
|
66
66
|
description: string;
|
|
67
67
|
/** JSON-encoded JSON Schema for the tool's input. */
|
|
68
68
|
inputSchema?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Display title declared on the tool (`ToolDescriptor.title` in the WebMCP
|
|
71
|
+
* spec). The polyfill returns `""` when the tool didn't declare one. Note:
|
|
72
|
+
* `annotations` (incl. the legacy `annotations.title`) are NOT exposed on
|
|
73
|
+
* this strict consumer surface — top-level `title` is the only display-name
|
|
74
|
+
* channel available to us.
|
|
75
|
+
*/
|
|
76
|
+
title?: string;
|
|
69
77
|
}
|
|
70
78
|
|
|
71
79
|
interface ModelContextCoreLike {
|
|
@@ -77,6 +85,43 @@ interface ModelContextCoreLike {
|
|
|
77
85
|
): Promise<string | null>;
|
|
78
86
|
}
|
|
79
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Page-global map of bare tool name → declared display title
|
|
90
|
+
* (`ToolDescriptor.title`). `document.modelContext` is page-global, so a
|
|
91
|
+
* single map shared across widget/bridge instances is semantically correct.
|
|
92
|
+
* Refreshed on every registry read (`snapshotForDispatch` / `executeToolCall`)
|
|
93
|
+
* and consumed by the approval bubble's summary line via
|
|
94
|
+
* `getWebMcpToolDisplayTitle`.
|
|
95
|
+
*/
|
|
96
|
+
const webMcpToolDisplayTitles = new Map<string, string>();
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Record declared display titles from a fresh `getTools()` read. The map is
|
|
100
|
+
* rebuilt from scratch — callers always pass the FULL registry snapshot — so
|
|
101
|
+
* a tool that unregistered or dropped its title can't leave a stale label
|
|
102
|
+
* behind. Exported for tests; production callers are the bridge's registry
|
|
103
|
+
* reads.
|
|
104
|
+
*/
|
|
105
|
+
export const recordWebMcpToolDisplayTitles = (
|
|
106
|
+
infos: ModelContextToolInfo[],
|
|
107
|
+
): void => {
|
|
108
|
+
webMcpToolDisplayTitles.clear();
|
|
109
|
+
for (const info of infos) {
|
|
110
|
+
const title = info.title?.trim();
|
|
111
|
+
if (title) webMcpToolDisplayTitles.set(info.name, title);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Look up the display title a page tool declared via the WebMCP spec's
|
|
117
|
+
* `ToolDescriptor.title`. Accepts wire (`webmcp:add_to_cart`) or bare
|
|
118
|
+
* (`add_to_cart`) names. Returns `undefined` when the tool didn't declare
|
|
119
|
+
* one (callers fall back to humanizing the tool name).
|
|
120
|
+
*/
|
|
121
|
+
export const getWebMcpToolDisplayTitle = (
|
|
122
|
+
toolName: string,
|
|
123
|
+
): string | undefined => webMcpToolDisplayTitles.get(stripWebMcpPrefix(toolName));
|
|
124
|
+
|
|
80
125
|
const log = {
|
|
81
126
|
warn(message: string, ...rest: unknown[]): void {
|
|
82
127
|
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
@@ -220,6 +265,7 @@ export class WebMcpBridge {
|
|
|
220
265
|
log.warn("getTools() threw — shipping an empty WebMCP snapshot.", err);
|
|
221
266
|
return [];
|
|
222
267
|
}
|
|
268
|
+
recordWebMcpToolDisplayTitles(infos);
|
|
223
269
|
|
|
224
270
|
const pageOrigin = typeof location !== "undefined" ? location.origin : "";
|
|
225
271
|
|
|
@@ -295,6 +341,7 @@ export class WebMcpBridge {
|
|
|
295
341
|
const message = err instanceof Error ? err.message : String(err);
|
|
296
342
|
return errorResult(`Failed to read WebMCP registry: ${message}`);
|
|
297
343
|
}
|
|
344
|
+
recordWebMcpToolDisplayTitles(infos);
|
|
298
345
|
const info = infos.find((candidate) => candidate.name === bareName);
|
|
299
346
|
|
|
300
347
|
if (!info) {
|
|
@@ -323,10 +370,12 @@ export class WebMcpBridge {
|
|
|
323
370
|
|
|
324
371
|
// Confirm-by-default gate. Every `webmcp:*` call routes through here,
|
|
325
372
|
// regardless of `annotations.readOnlyHint`.
|
|
373
|
+
const displayTitle = getWebMcpToolDisplayTitle(bareName);
|
|
326
374
|
const gateInfo: WebMcpConfirmInfo = {
|
|
327
375
|
toolName: bareName,
|
|
328
376
|
args,
|
|
329
377
|
description: info.description,
|
|
378
|
+
...(displayTitle ? { title: displayTitle } : {}),
|
|
330
379
|
reason: "gate",
|
|
331
380
|
};
|
|
332
381
|
if (!(await this.requestConfirm(gateInfo))) {
|