@wonderwhy-er/desktop-commander 0.2.39 → 0.2.40
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/dist/server.js +1 -1
- package/dist/ui/file-preview/preview-runtime.js +204 -153
- package/dist/ui/file-preview/src/markdown/controller.d.ts +7 -1
- package/dist/ui/file-preview/src/markdown/controller.js +135 -16
- package/dist/ui/file-preview/src/markdown/editor.d.ts +97 -1
- package/dist/ui/file-preview/src/markdown/editor.js +814 -26
- package/dist/ui/file-preview/src/model.d.ts +2 -1
- package/dist/utils/capture.js +1 -1
- package/dist/utils/toolHistory.d.ts +13 -0
- package/dist/utils/toolHistory.js +65 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -1
- package/dist/ui/config-editor/app.js +0 -840
- package/dist/ui/config-editor/array-modal.d.ts +0 -19
- package/dist/ui/config-editor/array-modal.js +0 -185
- package/dist/ui/config-editor/main.d.ts +0 -1
- package/dist/ui/config-editor/main.js +0 -2
- package/dist/ui/config-editor/src/App.d.ts +0 -43
- package/dist/ui/config-editor/src/components/layout.d.ts +0 -4
- package/dist/ui/config-editor/src/components/layout.js +0 -83
- package/dist/ui/config-editor/src/components/toolbar.d.ts +0 -1
- package/dist/ui/config-editor/src/components/toolbar.js +0 -21
- package/dist/ui/config-editor/src/config-values.d.ts +0 -6
- package/dist/ui/config-editor/src/config-values.js +0 -61
- package/dist/ui/config-editor/src/contracts.d.ts +0 -14
- package/dist/ui/config-editor/src/contracts.js +0 -3
- package/dist/ui/config-editor/src/directory-browser.d.ts +0 -6
- package/dist/ui/config-editor/src/directory-browser.js +0 -71
- package/dist/ui/config-editor/src/layout.d.ts +0 -5
- package/dist/ui/config-editor/src/layout.js +0 -90
- package/dist/ui/config-editor/src/parsing.d.ts +0 -5
- package/dist/ui/config-editor/src/parsing.js +0 -50
- package/dist/ui/config-editor/src/toolbar.d.ts +0 -1
- package/dist/ui/config-editor/src/toolbar.js +0 -18
- package/dist/ui/config-editor/src/types.d.ts +0 -17
- package/dist/ui/config-editor/src/types.js +0 -3
- package/dist/ui/config-editor/src/utils/config-values.d.ts +0 -9
- package/dist/ui/config-editor/src/utils/config-values.js +0 -61
- package/dist/ui/config-editor/src/utils/directory-browser.d.ts +0 -31
- package/dist/ui/config-editor/src/utils/directory-browser.js +0 -201
- package/dist/ui/config-editor/src/utils/parsing.d.ts +0 -8
- package/dist/ui/config-editor/src/utils/parsing.js +0 -50
- package/dist/ui/file-preview/app.d.ts +0 -8
- package/dist/ui/file-preview/app.js +0 -2020
- package/dist/ui/file-preview/components/code-viewer.d.ts +0 -6
- package/dist/ui/file-preview/components/code-viewer.js +0 -73
- package/dist/ui/file-preview/components/highlighting.d.ts +0 -2
- package/dist/ui/file-preview/components/highlighting.js +0 -54
- package/dist/ui/file-preview/components/html-renderer.d.ts +0 -5
- package/dist/ui/file-preview/components/html-renderer.js +0 -47
- package/dist/ui/file-preview/components/markdown-renderer.d.ts +0 -1
- package/dist/ui/file-preview/components/markdown-renderer.js +0 -67
- package/dist/ui/file-preview/components/toolbar.d.ts +0 -6
- package/dist/ui/file-preview/components/toolbar.js +0 -75
- package/dist/ui/file-preview/image-preview.d.ts +0 -3
- package/dist/ui/file-preview/image-preview.js +0 -21
- package/dist/ui/file-preview/main.d.ts +0 -1
- package/dist/ui/file-preview/main.js +0 -5
- package/dist/ui/file-preview/markdown/editor.d.ts +0 -36
- package/dist/ui/file-preview/markdown/editor.js +0 -643
- package/dist/ui/file-preview/markdown/linking.d.ts +0 -9
- package/dist/ui/file-preview/markdown/linking.js +0 -210
- package/dist/ui/file-preview/markdown/outline.d.ts +0 -7
- package/dist/ui/file-preview/markdown/outline.js +0 -40
- package/dist/ui/file-preview/markdown/preview.d.ts +0 -8
- package/dist/ui/file-preview/markdown/preview.js +0 -33
- package/dist/ui/file-preview/markdown/slugify.d.ts +0 -3
- package/dist/ui/file-preview/markdown/slugify.js +0 -31
- package/dist/ui/file-preview/markdown/toc.d.ts +0 -11
- package/dist/ui/file-preview/markdown/toc.js +0 -75
- package/dist/ui/file-preview/markdown/utils.d.ts +0 -1
- package/dist/ui/file-preview/markdown/utils.js +0 -15
- package/dist/ui/file-preview/markdown/workspace-controller.d.ts +0 -25
- package/dist/ui/file-preview/markdown/workspace-controller.js +0 -40
- package/dist/ui/file-preview/src/components/CodeViewer.d.ts +0 -6
- package/dist/ui/file-preview/src/components/CodeViewer.js +0 -60
- package/dist/ui/file-preview/src/components/HtmlRenderer.d.ts +0 -8
- package/dist/ui/file-preview/src/components/HtmlRenderer.js +0 -45
- package/dist/ui/file-preview/src/components/MarkdownRenderer.d.ts +0 -1
- package/dist/ui/file-preview/src/components/MarkdownRenderer.js +0 -15
- package/dist/ui/file-preview/src/components/Toolbar.d.ts +0 -6
- package/dist/ui/file-preview/src/components/Toolbar.js +0 -75
- package/dist/ui/file-preview/src/components/editor-toolbar.d.ts +0 -15
- package/dist/ui/file-preview/src/components/editor-toolbar.js +0 -384
- package/dist/ui/file-preview/src/components/markdown-editor.d.ts +0 -29
- package/dist/ui/file-preview/src/components/markdown-editor.js +0 -535
- package/dist/ui/file-preview/src/markdown/block-merge.d.ts +0 -25
- package/dist/ui/file-preview/src/markdown/block-merge.js +0 -86
- package/dist/ui/file-preview/src/markdown/link-modal.d.ts +0 -13
- package/dist/ui/file-preview/src/markdown/link-modal.js +0 -213
- package/dist/ui/file-preview/src/markdown/raw-editor.d.ts +0 -8
- package/dist/ui/file-preview/src/markdown/raw-editor.js +0 -61
- package/dist/ui/file-preview/src/markdown/selection-toolbar.d.ts +0 -14
- package/dist/ui/file-preview/src/markdown/selection-toolbar.js +0 -128
- package/dist/ui/file-preview/src/markdown/toc.d.ts +0 -11
- package/dist/ui/file-preview/src/markdown/toc.js +0 -75
- package/dist/ui/file-preview/src/markdown-workspace/editor.d.ts +0 -36
- package/dist/ui/file-preview/src/markdown-workspace/editor.js +0 -643
- package/dist/ui/file-preview/src/markdown-workspace/linking.d.ts +0 -9
- package/dist/ui/file-preview/src/markdown-workspace/linking.js +0 -210
- package/dist/ui/file-preview/src/markdown-workspace/outline.d.ts +0 -7
- package/dist/ui/file-preview/src/markdown-workspace/outline.js +0 -40
- package/dist/ui/file-preview/src/markdown-workspace/preview.d.ts +0 -8
- package/dist/ui/file-preview/src/markdown-workspace/preview.js +0 -33
- package/dist/ui/file-preview/src/markdown-workspace/slugify.d.ts +0 -3
- package/dist/ui/file-preview/src/markdown-workspace/slugify.js +0 -31
- package/dist/ui/file-preview/src/markdown-workspace/toc.d.ts +0 -11
- package/dist/ui/file-preview/src/markdown-workspace/toc.js +0 -75
- package/dist/ui/file-preview/src/markdown-workspace/utils.d.ts +0 -1
- package/dist/ui/file-preview/src/markdown-workspace/utils.js +0 -15
- package/dist/ui/file-preview/src/markdown-workspace/workspace-controller.d.ts +0 -25
- package/dist/ui/file-preview/src/markdown-workspace/workspace-controller.js +0 -40
- package/dist/ui/file-preview/types.d.ts +0 -1
- package/dist/ui/file-preview/types.js +0 -1
- package/dist/ui/server-integration.d.ts +0 -13
- package/dist/ui/server-integration.js +0 -31
- package/dist/ui/shared/ToolHeader.d.ts +0 -9
- package/dist/ui/shared/ToolHeader.js +0 -29
- package/dist/ui/shared/app-bootstrap.d.ts +0 -9
- package/dist/ui/shared/app-bootstrap.js +0 -15
- package/dist/ui/shared/guards.d.ts +0 -1
- package/dist/ui/shared/guards.js +0 -3
- package/dist/ui/shared/host-lifecycle.d.ts +0 -17
- package/dist/ui/shared/host-lifecycle.js +0 -41
- package/dist/ui/shared/rpc-client.d.ts +0 -14
- package/dist/ui/shared/rpc-client.js +0 -72
- package/dist/ui/shared/theme-adaptation.d.ts +0 -10
- package/dist/ui/shared/theme-adaptation.js +0 -118
- package/dist/ui/shared/tool-header.d.ts +0 -9
- package/dist/ui/shared/tool-header.js +0 -25
- package/dist/utils/ui-call-context.d.ts +0 -8
- package/dist/utils/ui-call-context.js +0 -72
- /package/dist/ui/config-editor/{app.d.ts → src/app.d.ts} +0 -0
- /package/dist/ui/config-editor/src/{App.js → app.js} +0 -0
- /package/dist/ui/file-preview/src/{App.d.ts → app.d.ts} +0 -0
- /package/dist/ui/file-preview/src/{App.js → app.js} +0 -0
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export function createUiHostLifecycle(rpcClient, options) {
|
|
2
|
-
const { appName, appVersion = '1.0.0', getRootElement, onHostContext } = options;
|
|
3
|
-
const resolveRootElement = () => getRootElement?.() ?? (document.getElementById('app')?.firstElementChild ?? document.getElementById('app'));
|
|
4
|
-
const notifySizeChanged = () => {
|
|
5
|
-
const node = resolveRootElement();
|
|
6
|
-
const height = Math.max(28, Math.ceil(node?.getBoundingClientRect().height ?? 0));
|
|
7
|
-
rpcClient.notify('ui/notifications/size-changed', { height });
|
|
8
|
-
};
|
|
9
|
-
return {
|
|
10
|
-
notifyRender: () => {
|
|
11
|
-
notifySizeChanged();
|
|
12
|
-
setTimeout(notifySizeChanged, 80);
|
|
13
|
-
},
|
|
14
|
-
observeResize: () => {
|
|
15
|
-
if (!window.ResizeObserver) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const observer = new ResizeObserver(() => notifySizeChanged());
|
|
19
|
-
observer.observe(document.documentElement);
|
|
20
|
-
},
|
|
21
|
-
initialize: () => {
|
|
22
|
-
void rpcClient.request('ui/initialize', {
|
|
23
|
-
appInfo: { name: appName, version: appVersion },
|
|
24
|
-
appCapabilities: {},
|
|
25
|
-
protocolVersion: '2026-01-26',
|
|
26
|
-
}).then((response) => {
|
|
27
|
-
if (onHostContext && response !== null && typeof response === 'object') {
|
|
28
|
-
const hostContext = response.hostContext;
|
|
29
|
-
if (hostContext !== null && typeof hostContext === 'object') {
|
|
30
|
-
onHostContext(hostContext);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
rpcClient.notify('ui/notifications/initialized', {});
|
|
34
|
-
}).catch(() => {
|
|
35
|
-
// Initialization handshake failure should not break rendering.
|
|
36
|
-
// Still send initialized in case host is lenient.
|
|
37
|
-
rpcClient.notify('ui/notifications/initialized', {});
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface RpcClient {
|
|
2
|
-
notify: (method: string, params: Record<string, unknown>) => void;
|
|
3
|
-
request: (method: string, params: Record<string, unknown>) => Promise<unknown>;
|
|
4
|
-
handleMessageEvent: (event: MessageEvent) => boolean;
|
|
5
|
-
dispose: () => void;
|
|
6
|
-
}
|
|
7
|
-
export interface RpcClientOptions {
|
|
8
|
-
targetWindow: Window;
|
|
9
|
-
targetOrigin?: string;
|
|
10
|
-
timeoutMs?: number;
|
|
11
|
-
isTrustedSource?: (source: MessageEvent['source'] | null) => boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare function isTrustedParentMessageSource(source: MessageEvent['source'] | null, expectedSource: Window): boolean;
|
|
14
|
-
export declare function createWindowRpcClient(options: RpcClientOptions): RpcClient;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
function isObject(value) {
|
|
2
|
-
return typeof value === 'object' && value !== null;
|
|
3
|
-
}
|
|
4
|
-
export function isTrustedParentMessageSource(source, expectedSource) {
|
|
5
|
-
return source === expectedSource;
|
|
6
|
-
}
|
|
7
|
-
export function createWindowRpcClient(options) {
|
|
8
|
-
const { targetWindow, targetOrigin = '*', timeoutMs = 15000, isTrustedSource = () => true, } = options;
|
|
9
|
-
let requestId = 1;
|
|
10
|
-
const pendingRequests = new Map();
|
|
11
|
-
const postMessage = (payload) => {
|
|
12
|
-
targetWindow.postMessage(payload, targetOrigin);
|
|
13
|
-
};
|
|
14
|
-
const notify = (method, params) => {
|
|
15
|
-
postMessage({
|
|
16
|
-
jsonrpc: '2.0',
|
|
17
|
-
method,
|
|
18
|
-
params,
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
const request = (method, params) => {
|
|
22
|
-
const id = requestId++;
|
|
23
|
-
postMessage({
|
|
24
|
-
jsonrpc: '2.0',
|
|
25
|
-
id,
|
|
26
|
-
method,
|
|
27
|
-
params,
|
|
28
|
-
});
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
const timer = setTimeout(() => {
|
|
31
|
-
pendingRequests.delete(id);
|
|
32
|
-
reject(new Error(`Request timed out for method ${method}`));
|
|
33
|
-
}, timeoutMs);
|
|
34
|
-
pendingRequests.set(id, { resolve, reject, timer });
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
const handleMessageEvent = (event) => {
|
|
38
|
-
if (!isTrustedSource(event.source)) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
if (!isObject(event.data) || typeof event.data.id !== 'number') {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
const pending = pendingRequests.get(event.data.id);
|
|
45
|
-
if (!pending) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
clearTimeout(pending.timer);
|
|
49
|
-
pendingRequests.delete(event.data.id);
|
|
50
|
-
if (isObject(event.data.error)) {
|
|
51
|
-
const errorShape = event.data.error;
|
|
52
|
-
const message = typeof errorShape.message === 'string' ? errorShape.message : 'Unknown RPC error';
|
|
53
|
-
pending.reject(new Error(message));
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
pending.resolve(event.data.result);
|
|
57
|
-
return true;
|
|
58
|
-
};
|
|
59
|
-
const dispose = () => {
|
|
60
|
-
for (const [id, pending] of pendingRequests) {
|
|
61
|
-
clearTimeout(pending.timer);
|
|
62
|
-
pending.reject(new Error('RPC client disposed'));
|
|
63
|
-
pendingRequests.delete(id);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
return {
|
|
67
|
-
notify,
|
|
68
|
-
request,
|
|
69
|
-
handleMessageEvent,
|
|
70
|
-
dispose,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Theme synchronization utilities that adapt embedded UI styles to host light/dark context. It centralizes theme event handling and class/token updates.
|
|
3
|
-
*/
|
|
4
|
-
type ThemeMode = 'light' | 'dark';
|
|
5
|
-
export declare function resolveThemeMode(value: unknown): ThemeMode | undefined;
|
|
6
|
-
export interface UiThemeAdapter {
|
|
7
|
-
applyFromData: (data: unknown) => boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare function createUiThemeAdapter(root?: HTMLElement): UiThemeAdapter;
|
|
10
|
-
export {};
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
function isObject(value) {
|
|
2
|
-
return typeof value === 'object' && value !== null;
|
|
3
|
-
}
|
|
4
|
-
function normalizeThemeMode(value) {
|
|
5
|
-
if (typeof value !== 'string') {
|
|
6
|
-
return undefined;
|
|
7
|
-
}
|
|
8
|
-
const normalized = value.trim().toLowerCase();
|
|
9
|
-
if (normalized === 'dark' || normalized === 'night') {
|
|
10
|
-
return 'dark';
|
|
11
|
-
}
|
|
12
|
-
if (normalized === 'light' || normalized === 'day') {
|
|
13
|
-
return 'light';
|
|
14
|
-
}
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
function pickThemeCandidate(value) {
|
|
18
|
-
if (!isObject(value)) {
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
const candidates = [
|
|
22
|
-
value.theme,
|
|
23
|
-
value.colorScheme,
|
|
24
|
-
value.appearance,
|
|
25
|
-
value.mode,
|
|
26
|
-
];
|
|
27
|
-
if (isObject(value.context)) {
|
|
28
|
-
candidates.push(value.context, value.context.theme, value.context.colorScheme);
|
|
29
|
-
}
|
|
30
|
-
if (isObject(value.params)) {
|
|
31
|
-
candidates.push(value.params, value.params.theme, value.params.colorScheme, value.params.context);
|
|
32
|
-
}
|
|
33
|
-
return candidates;
|
|
34
|
-
}
|
|
35
|
-
export function resolveThemeMode(value) {
|
|
36
|
-
const direct = normalizeThemeMode(value);
|
|
37
|
-
if (direct) {
|
|
38
|
-
return direct;
|
|
39
|
-
}
|
|
40
|
-
if (!isObject(value)) {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
for (const candidate of pickThemeCandidate(value)) {
|
|
44
|
-
const resolved = resolveThemeMode(candidate);
|
|
45
|
-
if (resolved) {
|
|
46
|
-
return resolved;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
function isSafeCssVariableName(name) {
|
|
52
|
-
return /^--[a-zA-Z0-9_-]+$/.test(name);
|
|
53
|
-
}
|
|
54
|
-
function extractCssVariableMap(value) {
|
|
55
|
-
if (!isObject(value)) {
|
|
56
|
-
return {};
|
|
57
|
-
}
|
|
58
|
-
const params = isObject(value.params) ? value.params : undefined;
|
|
59
|
-
const paramsContext = params && isObject(params.context) ? params.context : undefined;
|
|
60
|
-
const rawMapCandidates = [
|
|
61
|
-
value.cssVariables,
|
|
62
|
-
value.variables,
|
|
63
|
-
value.tokens,
|
|
64
|
-
isObject(value.theme) ? value.theme.cssVariables : undefined,
|
|
65
|
-
isObject(value.theme) ? value.theme.variables : undefined,
|
|
66
|
-
isObject(value.theme) ? value.theme.tokens : undefined,
|
|
67
|
-
isObject(value.context) ? value.context.cssVariables : undefined,
|
|
68
|
-
isObject(value.context) ? value.context.variables : undefined,
|
|
69
|
-
isObject(value.context) ? value.context.tokens : undefined,
|
|
70
|
-
params ? params.cssVariables : undefined,
|
|
71
|
-
params ? params.variables : undefined,
|
|
72
|
-
params ? params.tokens : undefined,
|
|
73
|
-
paramsContext ? paramsContext.cssVariables : undefined,
|
|
74
|
-
paramsContext ? paramsContext.variables : undefined,
|
|
75
|
-
paramsContext ? paramsContext.tokens : undefined,
|
|
76
|
-
];
|
|
77
|
-
for (const candidate of rawMapCandidates) {
|
|
78
|
-
if (!isObject(candidate)) {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const next = {};
|
|
82
|
-
for (const [rawKey, rawValue] of Object.entries(candidate)) {
|
|
83
|
-
if (typeof rawValue !== 'string') {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
const key = rawKey.startsWith('--') ? rawKey : `--${rawKey}`;
|
|
87
|
-
if (!isSafeCssVariableName(key)) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
next[key] = rawValue.trim();
|
|
91
|
-
}
|
|
92
|
-
return next;
|
|
93
|
-
}
|
|
94
|
-
return {};
|
|
95
|
-
}
|
|
96
|
-
function applyCssVariables(root, variableMap) {
|
|
97
|
-
for (const [name, value] of Object.entries(variableMap)) {
|
|
98
|
-
root.style.setProperty(name, value);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
export function createUiThemeAdapter(root = document.documentElement) {
|
|
102
|
-
const applyFromData = (data) => {
|
|
103
|
-
const mode = resolveThemeMode(data);
|
|
104
|
-
const variableMap = extractCssVariableMap(data);
|
|
105
|
-
const hasChanges = Boolean(mode) || Object.keys(variableMap).length > 0;
|
|
106
|
-
if (mode) {
|
|
107
|
-
root.dataset.theme = mode;
|
|
108
|
-
root.style.colorScheme = mode;
|
|
109
|
-
}
|
|
110
|
-
if (Object.keys(variableMap).length > 0) {
|
|
111
|
-
applyCssVariables(root, variableMap);
|
|
112
|
-
}
|
|
113
|
-
return hasChanges;
|
|
114
|
-
};
|
|
115
|
-
return {
|
|
116
|
-
applyFromData,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reusable header renderer for MCP tool UIs. It provides a consistent title/description/status pattern so each app presents uniform top-of-page context.
|
|
3
|
-
*/
|
|
4
|
-
import { escapeHtml } from './escape-html.js';
|
|
5
|
-
export function renderToolHeader(config) {
|
|
6
|
-
return `
|
|
7
|
-
<header class="toolbar">
|
|
8
|
-
<div class="meta">
|
|
9
|
-
<div class="meta-main">
|
|
10
|
-
<span class="file-pill ${escapeHtml(config.pillClassName ?? '')}">${escapeHtml(config.pillLabel)}</span>
|
|
11
|
-
<div class="meta-text">
|
|
12
|
-
<span class="filename" title="${escapeHtml(config.title)}">${escapeHtml(config.title)}</span>
|
|
13
|
-
<span class="filepath" title="${escapeHtml(config.subtitle)}">${escapeHtml(config.subtitle)}</span>
|
|
14
|
-
</div>
|
|
15
|
-
</div>
|
|
16
|
-
<div class="meta-badges">
|
|
17
|
-
${config.badges.map((badge) => `<span class="badge">${escapeHtml(badge)}</span>`).join('')}
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
<div class="actions">
|
|
21
|
-
${config.actionsHtml}
|
|
22
|
-
</div>
|
|
23
|
-
</header>
|
|
24
|
-
`;
|
|
25
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const UI_CALL_CONTEXT_META_KEY = "dcUiContext";
|
|
2
|
-
export interface UiCallTelemetryFields {
|
|
3
|
-
call_origin: 'ui' | 'llm';
|
|
4
|
-
ui_component?: string;
|
|
5
|
-
ui_action?: string;
|
|
6
|
-
ui_invocation_id?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function extractUiCallTelemetryFields(metadata: unknown): UiCallTelemetryFields;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
// Shared key used by UI widgets to attach call-origin metadata inside tools/call _meta.
|
|
2
|
-
export const UI_CALL_CONTEXT_META_KEY = 'dcUiContext';
|
|
3
|
-
function normalizeLabel(value, maxLength) {
|
|
4
|
-
// Keep telemetry labels compact and query-friendly (snake-like + bounded length).
|
|
5
|
-
if (typeof value !== 'string') {
|
|
6
|
-
return undefined;
|
|
7
|
-
}
|
|
8
|
-
const trimmed = value.trim();
|
|
9
|
-
if (trimmed.length === 0) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
const normalized = trimmed
|
|
13
|
-
.toLowerCase()
|
|
14
|
-
.replace(/[^a-z0-9_.:-]+/g, '_')
|
|
15
|
-
.replace(/^_+|_+$/g, '')
|
|
16
|
-
.slice(0, maxLength);
|
|
17
|
-
if (normalized.length === 0) {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
return normalized;
|
|
21
|
-
}
|
|
22
|
-
function normalizeInvocationId(value, maxLength) {
|
|
23
|
-
// Invocation IDs are correlation-only; strip unusual characters and cap length.
|
|
24
|
-
if (typeof value !== 'string') {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
const trimmed = value.trim();
|
|
28
|
-
if (trimmed.length === 0) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
const clipped = trimmed.slice(0, maxLength);
|
|
32
|
-
const sanitized = clipped.replace(/[^A-Za-z0-9_.:-]+/g, '');
|
|
33
|
-
if (sanitized.length === 0) {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
return sanitized;
|
|
37
|
-
}
|
|
38
|
-
function isRecord(value) {
|
|
39
|
-
return typeof value === 'object' && value !== null;
|
|
40
|
-
}
|
|
41
|
-
export function extractUiCallTelemetryFields(metadata) {
|
|
42
|
-
// Default classification is LLM unless an explicit UI-origin envelope is present.
|
|
43
|
-
const base = { call_origin: 'llm' };
|
|
44
|
-
if (!isRecord(metadata)) {
|
|
45
|
-
return base;
|
|
46
|
-
}
|
|
47
|
-
const rawContext = metadata[UI_CALL_CONTEXT_META_KEY];
|
|
48
|
-
if (!isRecord(rawContext)) {
|
|
49
|
-
return base;
|
|
50
|
-
}
|
|
51
|
-
const rawOrigin = typeof rawContext.callOrigin === 'string'
|
|
52
|
-
? rawContext.callOrigin.trim().toLowerCase()
|
|
53
|
-
: '';
|
|
54
|
-
if (rawOrigin !== 'ui') {
|
|
55
|
-
// We only elevate to UI when the caller explicitly declares callOrigin="ui".
|
|
56
|
-
return base;
|
|
57
|
-
}
|
|
58
|
-
const result = { call_origin: 'ui' };
|
|
59
|
-
const component = normalizeLabel(rawContext.uiComponent, 64);
|
|
60
|
-
if (component) {
|
|
61
|
-
result.ui_component = component;
|
|
62
|
-
}
|
|
63
|
-
const action = normalizeLabel(rawContext.uiAction, 64);
|
|
64
|
-
if (action) {
|
|
65
|
-
result.ui_action = action;
|
|
66
|
-
}
|
|
67
|
-
const invocationId = normalizeInvocationId(rawContext.uiInvocationId, 120);
|
|
68
|
-
if (invocationId) {
|
|
69
|
-
result.ui_invocation_id = invocationId;
|
|
70
|
-
}
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|