@mcp-b/embedded-agent 1.2.6 → 1.2.7
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/web-component.js
CHANGED
|
@@ -3582,6 +3582,71 @@ const UnifiedToolFallback = ({ toolCallId: _toolCallId, toolName, argsText, args
|
|
|
3582
3582
|
};
|
|
3583
3583
|
var UnifiedToolFallback_default = UnifiedToolFallback;
|
|
3584
3584
|
|
|
3585
|
+
//#endregion
|
|
3586
|
+
//#region src/hooks/usePrompts.ts
|
|
3587
|
+
/**
|
|
3588
|
+
* Hook to access MCP prompts.
|
|
3589
|
+
*
|
|
3590
|
+
* @example Basic usage
|
|
3591
|
+
* ```tsx
|
|
3592
|
+
* function MyComponent() {
|
|
3593
|
+
* const { prompts, hasPrompts, getPrompt } = usePrompts()
|
|
3594
|
+
*
|
|
3595
|
+
* const handleClick = async (prompt: Prompt) => {
|
|
3596
|
+
* const result = await getPrompt(prompt.name)
|
|
3597
|
+
* console.log(result.messages)
|
|
3598
|
+
* }
|
|
3599
|
+
*
|
|
3600
|
+
* if (!hasPrompts) return null
|
|
3601
|
+
*
|
|
3602
|
+
* return (
|
|
3603
|
+
* <div>
|
|
3604
|
+
* {prompts.map(p => (
|
|
3605
|
+
* <button key={p.name} onClick={() => handleClick(p)}>
|
|
3606
|
+
* {p.name}
|
|
3607
|
+
* </button>
|
|
3608
|
+
* ))}
|
|
3609
|
+
* </div>
|
|
3610
|
+
* )
|
|
3611
|
+
* }
|
|
3612
|
+
* ```
|
|
3613
|
+
*/
|
|
3614
|
+
function usePrompts() {
|
|
3615
|
+
const $ = c(8);
|
|
3616
|
+
const mcpTools = useOptionalMCPTools();
|
|
3617
|
+
let t0;
|
|
3618
|
+
if ($[0] !== mcpTools?.prompts) {
|
|
3619
|
+
t0 = mcpTools?.prompts ?? [];
|
|
3620
|
+
$[0] = mcpTools?.prompts;
|
|
3621
|
+
$[1] = t0;
|
|
3622
|
+
} else t0 = $[1];
|
|
3623
|
+
const prompts = t0;
|
|
3624
|
+
const hasPrompts = prompts.length > 0;
|
|
3625
|
+
let t1;
|
|
3626
|
+
if ($[2] !== mcpTools) {
|
|
3627
|
+
t1 = async (name, args) => {
|
|
3628
|
+
if (!mcpTools?.getPrompt) throw new Error("MCPToolsProvider not found or getPrompt not available");
|
|
3629
|
+
return mcpTools.getPrompt(name, args);
|
|
3630
|
+
};
|
|
3631
|
+
$[2] = mcpTools;
|
|
3632
|
+
$[3] = t1;
|
|
3633
|
+
} else t1 = $[3];
|
|
3634
|
+
const getPrompt = t1;
|
|
3635
|
+
let t2;
|
|
3636
|
+
if ($[4] !== getPrompt || $[5] !== hasPrompts || $[6] !== prompts) {
|
|
3637
|
+
t2 = {
|
|
3638
|
+
prompts,
|
|
3639
|
+
hasPrompts,
|
|
3640
|
+
getPrompt
|
|
3641
|
+
};
|
|
3642
|
+
$[4] = getPrompt;
|
|
3643
|
+
$[5] = hasPrompts;
|
|
3644
|
+
$[6] = prompts;
|
|
3645
|
+
$[7] = t2;
|
|
3646
|
+
} else t2 = $[7];
|
|
3647
|
+
return t2;
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3585
3650
|
//#endregion
|
|
3586
3651
|
//#region src/providers/ToolSelectionProvider.tsx
|
|
3587
3652
|
const ToolSelectionContext = createContext(null);
|
|
@@ -5947,26 +6012,26 @@ const ThreadWelcome = () => {
|
|
|
5947
6012
|
} else t0 = $[0];
|
|
5948
6013
|
return t0;
|
|
5949
6014
|
};
|
|
5950
|
-
const SUGGESTIONS = [{
|
|
5951
|
-
title: "What's the weather",
|
|
5952
|
-
label: "in San Francisco?",
|
|
5953
|
-
prompt: "What's the weather in San Francisco?"
|
|
5954
|
-
}, {
|
|
5955
|
-
title: "Explain React hooks",
|
|
5956
|
-
label: "like useState and useEffect",
|
|
5957
|
-
prompt: "Explain React hooks like useState and useEffect"
|
|
5958
|
-
}];
|
|
5959
6015
|
const ThreadSuggestions = () => {
|
|
5960
|
-
const $ = c(
|
|
6016
|
+
const $ = c(4);
|
|
6017
|
+
const { prompts, hasPrompts } = usePrompts();
|
|
6018
|
+
if (!hasPrompts) return null;
|
|
5961
6019
|
let t0;
|
|
5962
|
-
if ($[0]
|
|
5963
|
-
t0 =
|
|
6020
|
+
if ($[0] !== prompts) {
|
|
6021
|
+
t0 = prompts.slice(0, 4).map(_temp$10);
|
|
6022
|
+
$[0] = prompts;
|
|
6023
|
+
$[1] = t0;
|
|
6024
|
+
} else t0 = $[1];
|
|
6025
|
+
let t1;
|
|
6026
|
+
if ($[2] !== t0) {
|
|
6027
|
+
t1 = /* @__PURE__ */ jsx("div", {
|
|
5964
6028
|
className: "aui-thread-welcome-suggestions wm:grid wm:w-full @md:wm:grid-cols-2 wm:gap-2 wm:pb-4",
|
|
5965
|
-
children:
|
|
6029
|
+
children: t0
|
|
5966
6030
|
});
|
|
5967
|
-
$[
|
|
5968
|
-
|
|
5969
|
-
|
|
6031
|
+
$[2] = t0;
|
|
6032
|
+
$[3] = t1;
|
|
6033
|
+
} else t1 = $[3];
|
|
6034
|
+
return t1;
|
|
5970
6035
|
};
|
|
5971
6036
|
const Composer = () => {
|
|
5972
6037
|
const $ = c(12);
|
|
@@ -6589,28 +6654,28 @@ const BranchPicker = (t0) => {
|
|
|
6589
6654
|
} else t6 = $[11];
|
|
6590
6655
|
return t6;
|
|
6591
6656
|
};
|
|
6592
|
-
function _temp$10(
|
|
6657
|
+
function _temp$10(prompt, index) {
|
|
6593
6658
|
return /* @__PURE__ */ jsx("div", {
|
|
6594
6659
|
className: "aui-thread-welcome-suggestion-display wm:fade-in wm:slide-in-from-bottom-2 @md:wm:nth-[n+3]:block wm:nth-[n+3]:hidden wm:animate-in wm:fill-mode-both wm:duration-200",
|
|
6595
6660
|
style: { animationDelay: `${100 + index * 50}ms` },
|
|
6596
6661
|
children: /* @__PURE__ */ jsx(ThreadPrimitive.Suggestion, {
|
|
6597
|
-
prompt:
|
|
6662
|
+
prompt: prompt.description || prompt.name,
|
|
6598
6663
|
send: true,
|
|
6599
6664
|
asChild: true,
|
|
6600
6665
|
children: /* @__PURE__ */ jsxs(Button, {
|
|
6601
6666
|
variant: "ghost",
|
|
6602
6667
|
className: "aui-thread-welcome-suggestion wm:h-auto wm:w-full @md:wm:flex-col wm:flex-wrap wm:items-start wm:justify-start wm:gap-1 wm:rounded-2xl wm:border wm:px-4 wm:py-3 wm:text-left wm:text-sm wm:transition-colors hover:wm:bg-muted",
|
|
6603
|
-
"aria-label":
|
|
6668
|
+
"aria-label": prompt.description || prompt.name,
|
|
6604
6669
|
children: [/* @__PURE__ */ jsx("span", {
|
|
6605
6670
|
className: "aui-thread-welcome-suggestion-text-1 wm:font-medium",
|
|
6606
|
-
children:
|
|
6607
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
6671
|
+
children: prompt.name
|
|
6672
|
+
}), prompt.description && /* @__PURE__ */ jsx("span", {
|
|
6608
6673
|
className: "aui-thread-welcome-suggestion-text-2 wm:text-muted-foreground",
|
|
6609
|
-
children:
|
|
6674
|
+
children: prompt.description
|
|
6610
6675
|
})]
|
|
6611
6676
|
})
|
|
6612
6677
|
})
|
|
6613
|
-
},
|
|
6678
|
+
}, prompt.name);
|
|
6614
6679
|
}
|
|
6615
6680
|
function _temp2$4(t0) {
|
|
6616
6681
|
const { thread } = t0;
|
|
@@ -8355,7 +8420,7 @@ function decodeJWT(token) {
|
|
|
8355
8420
|
* Used for DO routing - actual token validation happens on the backend.
|
|
8356
8421
|
*
|
|
8357
8422
|
* @param token - The JWT token
|
|
8358
|
-
* @returns The sub claim value, or null if extraction fails
|
|
8423
|
+
* @returns The sub claim value, or null if extraction fails (malformed token)
|
|
8359
8424
|
*/
|
|
8360
8425
|
function extractUserIdFromToken(token) {
|
|
8361
8426
|
return decodeJWT(token)?.sub ?? null;
|
|
@@ -10818,6 +10883,68 @@ function _temp(error) {
|
|
|
10818
10883
|
//#endregion
|
|
10819
10884
|
//#region src/components/agent/ShadowRoot.tsx
|
|
10820
10885
|
/**
|
|
10886
|
+
* CSS variable names supported for external theming.
|
|
10887
|
+
* These can be set on the <webmcp-agent> host element.
|
|
10888
|
+
*/
|
|
10889
|
+
const CSS_VARIABLE_NAMES = [
|
|
10890
|
+
"--wm-color-primary",
|
|
10891
|
+
"--wm-color-primary-foreground",
|
|
10892
|
+
"--wm-color-secondary",
|
|
10893
|
+
"--wm-color-secondary-foreground",
|
|
10894
|
+
"--wm-color-accent",
|
|
10895
|
+
"--wm-color-accent-foreground",
|
|
10896
|
+
"--wm-color-background",
|
|
10897
|
+
"--wm-color-foreground",
|
|
10898
|
+
"--wm-color-muted",
|
|
10899
|
+
"--wm-color-muted-foreground",
|
|
10900
|
+
"--wm-color-border",
|
|
10901
|
+
"--wm-color-input",
|
|
10902
|
+
"--wm-color-ring",
|
|
10903
|
+
"--wm-radius",
|
|
10904
|
+
"--wm-font-sans",
|
|
10905
|
+
"--wm-user-bubble-bg",
|
|
10906
|
+
"--wm-user-bubble-text",
|
|
10907
|
+
"--wm-assistant-bubble-bg",
|
|
10908
|
+
"--wm-assistant-bubble-text",
|
|
10909
|
+
"--wm-composer-bg",
|
|
10910
|
+
"--wm-composer-border",
|
|
10911
|
+
"--wm-composer-button-bg",
|
|
10912
|
+
"--wm-composer-button-text",
|
|
10913
|
+
"--wm-composer-text",
|
|
10914
|
+
"--wm-tool-bg",
|
|
10915
|
+
"--wm-tool-border",
|
|
10916
|
+
"--wm-tool-approve-bg",
|
|
10917
|
+
"--wm-tool-deny-bg",
|
|
10918
|
+
"--wm-code-bg",
|
|
10919
|
+
"--wm-code-text",
|
|
10920
|
+
"--wm-input-bg",
|
|
10921
|
+
"--wm-input-border",
|
|
10922
|
+
"--wm-input-text",
|
|
10923
|
+
"--wm-font-size-xs",
|
|
10924
|
+
"--wm-font-size-sm",
|
|
10925
|
+
"--wm-font-size-base",
|
|
10926
|
+
"--wm-font-size-lg"
|
|
10927
|
+
];
|
|
10928
|
+
/**
|
|
10929
|
+
* Extracts CSS variables from a host element's computed styles.
|
|
10930
|
+
* Returns a CSS block with !important declarations to override defaults.
|
|
10931
|
+
*/
|
|
10932
|
+
function extractCssVariables(hostElement) {
|
|
10933
|
+
const hostStyles = getComputedStyle(hostElement);
|
|
10934
|
+
const varsWithImportant = CSS_VARIABLE_NAMES.map((name) => {
|
|
10935
|
+
const value = hostStyles.getPropertyValue(name).trim();
|
|
10936
|
+
return value ? `${name}: ${value} !important;` : "";
|
|
10937
|
+
}).filter(Boolean).join("\n ");
|
|
10938
|
+
if (!varsWithImportant) return "";
|
|
10939
|
+
return `
|
|
10940
|
+
/* CSS variables passed through from host element */
|
|
10941
|
+
/* Using !important to ensure custom variables override built-in defaults */
|
|
10942
|
+
:host, :host(.dark) {
|
|
10943
|
+
${varsWithImportant}
|
|
10944
|
+
}
|
|
10945
|
+
`;
|
|
10946
|
+
}
|
|
10947
|
+
/**
|
|
10821
10948
|
* ShadowRoot - Renders children inside an isolated shadow DOM
|
|
10822
10949
|
*
|
|
10823
10950
|
* This component creates a shadow DOM boundary that:
|
|
@@ -10886,60 +11013,8 @@ const ShadowRoot = (t0) => {
|
|
|
10886
11013
|
if (!host_0) return;
|
|
10887
11014
|
let shadow = host_0.shadowRoot;
|
|
10888
11015
|
if (!shadow) shadow = host_0.attachShadow({ mode });
|
|
10889
|
-
let cssVariables = "";
|
|
10890
11016
|
const webComponentHost = host_0.parentElement;
|
|
10891
|
-
|
|
10892
|
-
const hostStyles = getComputedStyle(webComponentHost);
|
|
10893
|
-
const varsWithImportant = [
|
|
10894
|
-
"--wm-color-primary",
|
|
10895
|
-
"--wm-color-primary-foreground",
|
|
10896
|
-
"--wm-color-secondary",
|
|
10897
|
-
"--wm-color-secondary-foreground",
|
|
10898
|
-
"--wm-color-accent",
|
|
10899
|
-
"--wm-color-accent-foreground",
|
|
10900
|
-
"--wm-color-background",
|
|
10901
|
-
"--wm-color-foreground",
|
|
10902
|
-
"--wm-color-muted",
|
|
10903
|
-
"--wm-color-muted-foreground",
|
|
10904
|
-
"--wm-color-border",
|
|
10905
|
-
"--wm-color-input",
|
|
10906
|
-
"--wm-color-ring",
|
|
10907
|
-
"--wm-radius",
|
|
10908
|
-
"--wm-font-sans",
|
|
10909
|
-
"--wm-user-bubble-bg",
|
|
10910
|
-
"--wm-user-bubble-text",
|
|
10911
|
-
"--wm-assistant-bubble-bg",
|
|
10912
|
-
"--wm-assistant-bubble-text",
|
|
10913
|
-
"--wm-composer-bg",
|
|
10914
|
-
"--wm-composer-border",
|
|
10915
|
-
"--wm-composer-button-bg",
|
|
10916
|
-
"--wm-composer-button-text",
|
|
10917
|
-
"--wm-composer-text",
|
|
10918
|
-
"--wm-tool-bg",
|
|
10919
|
-
"--wm-tool-border",
|
|
10920
|
-
"--wm-tool-approve-bg",
|
|
10921
|
-
"--wm-tool-deny-bg",
|
|
10922
|
-
"--wm-code-bg",
|
|
10923
|
-
"--wm-code-text",
|
|
10924
|
-
"--wm-input-bg",
|
|
10925
|
-
"--wm-input-border",
|
|
10926
|
-
"--wm-input-text",
|
|
10927
|
-
"--wm-font-size-xs",
|
|
10928
|
-
"--wm-font-size-sm",
|
|
10929
|
-
"--wm-font-size-base",
|
|
10930
|
-
"--wm-font-size-lg"
|
|
10931
|
-
].map((name) => {
|
|
10932
|
-
const value = hostStyles.getPropertyValue(name).trim();
|
|
10933
|
-
return value ? `${name}: ${value} !important;` : "";
|
|
10934
|
-
}).filter(Boolean).join("\n ");
|
|
10935
|
-
if (varsWithImportant) cssVariables = `
|
|
10936
|
-
/* CSS variables passed through from host element */
|
|
10937
|
-
/* Using !important to ensure custom variables override built-in defaults */
|
|
10938
|
-
:host, :host(.dark) {
|
|
10939
|
-
${varsWithImportant}
|
|
10940
|
-
}
|
|
10941
|
-
`;
|
|
10942
|
-
}
|
|
11017
|
+
const cssVariables = webComponentHost ? extractCssVariables(webComponentHost) : "";
|
|
10943
11018
|
let styleElement = shadow.querySelector("style[data-webmcp-styles]");
|
|
10944
11019
|
if (!styleElement) {
|
|
10945
11020
|
styleElement = document.createElement("style");
|