@creature-ai/sdk 0.1.17 → 0.1.19

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.
@@ -449,6 +449,120 @@ declare class ChatGptAppHostClient extends Subscribable implements HostClient {
449
449
  */
450
450
  declare function detectEnvironment(): Environment;
451
451
 
452
+ /**
453
+ * Environment-Aware Default Styles
454
+ *
455
+ * This module provides default CSS variable values for MCP Apps and ChatGPT Apps.
456
+ * Import `initStyles` early in your app entry point to prevent flash of unstyled content.
457
+ *
458
+ * The MCP Apps spec defines CSS variable names (e.g., --color-background-primary).
459
+ * This module provides environment-specific VALUES for those variables as sensible
460
+ * defaults until the host injects its own values.
461
+ *
462
+ * Flow:
463
+ * 1. Detect environment (ChatGPT, MCP Apps, or Standalone)
464
+ * 2. Detect theme (light or dark)
465
+ * 3. Inject defaults immediately on document.documentElement
466
+ * 4. When host connects, host variables override these defaults
467
+ *
468
+ * IMPORTANT: MCP Apps defaults match Creature's actual values exactly.
469
+ * The observer only runs for ChatGPT (MCP Apps hosts handle theme changes themselves).
470
+ */
471
+
472
+ /**
473
+ * Theme mode for styling.
474
+ */
475
+ type Theme = "light" | "dark";
476
+ /**
477
+ * Options for initializing styles.
478
+ */
479
+ interface InitStylesOptions {
480
+ /** Whether to set up a MutationObserver for dynamic theme changes. Default: true for ChatGPT only */
481
+ observeThemeChanges?: boolean;
482
+ }
483
+ /**
484
+ * MCP Apps / Creature default values - DARK mode.
485
+ * These values are extracted directly from Creature's globals.css.
486
+ * They MUST match exactly what Creature sends via hostContext.styles.variables.
487
+ */
488
+ declare const MCP_APPS_DARK_DEFAULTS: Record<string, string>;
489
+ /**
490
+ * MCP Apps / Creature default values - LIGHT mode.
491
+ * These values are extracted directly from Creature's globals.css.
492
+ */
493
+ declare const MCP_APPS_LIGHT_DEFAULTS: Record<string, string>;
494
+ /**
495
+ * Shared MCP Apps / Creature typography and layout tokens (same for light/dark).
496
+ * These values are extracted directly from Creature's globals.css.
497
+ */
498
+ declare const MCP_APPS_SHARED_DEFAULTS: Record<string, string>;
499
+ /**
500
+ * ChatGPT Apps default values - LIGHT mode.
501
+ * Ported from @openai/apps-sdk-ui design tokens.
502
+ */
503
+ declare const CHATGPT_LIGHT_DEFAULTS: Record<string, string>;
504
+ /**
505
+ * ChatGPT Apps default values - DARK mode.
506
+ */
507
+ declare const CHATGPT_DARK_DEFAULTS: Record<string, string>;
508
+ /**
509
+ * Shared ChatGPT typography and layout tokens (same for light/dark).
510
+ */
511
+ declare const CHATGPT_SHARED_DEFAULTS: Record<string, string>;
512
+ /**
513
+ * Get MCP Apps default styles for the specified theme.
514
+ * Returns CSS variable names with their default values.
515
+ * These values match exactly what Creature sends via hostContext.styles.variables.
516
+ *
517
+ * @param theme - The theme to get defaults for
518
+ * @returns Record of CSS variable names to their values
519
+ */
520
+ declare const getMcpAppDefaultStyles: ({ theme }: {
521
+ theme: Theme;
522
+ }) => Record<string, string>;
523
+ /**
524
+ * Get ChatGPT Apps default styles for the specified theme.
525
+ * Returns CSS variable names with their values matching the @openai/apps-sdk-ui design tokens.
526
+ *
527
+ * @param theme - The theme to get defaults for
528
+ * @returns Record of CSS variable names to their values
529
+ */
530
+ declare const getChatGptDefaultStyles: ({ theme }: {
531
+ theme: Theme;
532
+ }) => Record<string, string>;
533
+ /**
534
+ * Detect the current theme from the document.
535
+ * Checks data-theme attribute, dark class (Tailwind), and prefers-color-scheme.
536
+ *
537
+ * @returns The detected theme
538
+ */
539
+ declare const detectTheme: () => Theme;
540
+ /**
541
+ * Apply CSS variables to the document root.
542
+ *
543
+ * @param styles - Record of CSS variable names to their values
544
+ */
545
+ declare const applyStyles: ({ styles }: {
546
+ styles: Record<string, string>;
547
+ }) => void;
548
+ /**
549
+ * Initialize default styles based on detected environment and theme.
550
+ * This should be called early in your app entry point to prevent FOUC.
551
+ *
552
+ * For MCP Apps (Creature): Applies defaults once. The host handles theme changes
553
+ * and sends new styles via hostContext, which override these defaults.
554
+ *
555
+ * For ChatGPT: Applies defaults and sets up an observer to handle theme changes,
556
+ * since ChatGPT may change theme before sending new hostContext.
557
+ *
558
+ * @param environment - The detected environment (from detectEnvironment)
559
+ * @param options - Configuration options
560
+ */
561
+ declare const initStyles: ({ environment, options, }: {
562
+ environment: Environment;
563
+ options?: InitStylesOptions;
564
+ }) => void;
565
+
452
566
  /**
453
567
  * Create a WebSocket client with automatic reconnection.
454
568
  *
@@ -458,6 +572,13 @@ declare function detectEnvironment(): Environment;
458
572
  */
459
573
  declare function createWebSocket<TSend = unknown, TReceive = unknown>(url: string, config?: WebSocketClientConfig<TReceive>): WebSocketClient<TSend, TReceive>;
460
574
 
575
+ /**
576
+ * Create a host client for the detected environment.
577
+ * Automatically selects McpAppHostClient or ChatGptAppHostClient based on runtime detection.
578
+ *
579
+ * @param config - Configuration for the host client
580
+ * @returns The appropriate host client for the environment
581
+ */
461
582
  declare function createHost(config: HostClientConfig): HostClient;
462
583
 
463
- export { ChatGptAppHostClient, type DisplayMode, type Environment, type HostClient, type HostClientConfig, type HostClientEvents, type HostClientState, type HostContext, type LogLevel, McpAppHostClient, type StateListener, type StructuredWidgetState, type ToolResult, type WebSocketClient, type WebSocketClientConfig, type WebSocketStatus, type WidgetState, createHost, createWebSocket, detectEnvironment };
584
+ export { CHATGPT_DARK_DEFAULTS, CHATGPT_LIGHT_DEFAULTS, CHATGPT_SHARED_DEFAULTS, ChatGptAppHostClient, type DisplayMode, type Environment, type HostClient, type HostClientConfig, type HostClientEvents, type HostClientState, type HostContext, type InitStylesOptions, type LogLevel, MCP_APPS_DARK_DEFAULTS, MCP_APPS_LIGHT_DEFAULTS, MCP_APPS_SHARED_DEFAULTS, McpAppHostClient, type StateListener, type StructuredWidgetState, type Theme, type ToolResult, type WebSocketClient, type WebSocketClientConfig, type WebSocketStatus, type WidgetState, applyStyles, createHost, createWebSocket, detectEnvironment, detectTheme, getChatGptDefaultStyles, getMcpAppDefaultStyles, initStyles };
@@ -9795,6 +9795,345 @@ function detectEnvironment() {
9795
9795
  return "standalone";
9796
9796
  }
9797
9797
 
9798
+ // src/core/styles.ts
9799
+ var MCP_APPS_DARK_DEFAULTS = {
9800
+ // Background colors
9801
+ "--color-background-primary": "#0D0D0B",
9802
+ "--color-background-secondary": "#1A1917",
9803
+ "--color-background-tertiary": "#141311",
9804
+ "--color-background-inverse": "#efefef",
9805
+ "--color-background-ghost": "transparent",
9806
+ "--color-background-info": "#1e3a5f",
9807
+ "--color-background-danger": "#5f1e1e",
9808
+ "--color-background-success": "#1e5f2e",
9809
+ "--color-background-warning": "#5f4a1e",
9810
+ "--color-background-disabled": "#1A1917",
9811
+ // Text colors
9812
+ "--color-text-primary": "#efefef",
9813
+ "--color-text-secondary": "#888888",
9814
+ "--color-text-tertiary": "#4A4846",
9815
+ "--color-text-inverse": "#0D0D0B",
9816
+ "--color-text-ghost": "#3A3836",
9817
+ "--color-text-info": "#58a6ff",
9818
+ "--color-text-danger": "#F85149",
9819
+ "--color-text-success": "#3fb950",
9820
+ "--color-text-warning": "#d29922",
9821
+ "--color-text-disabled": "#4A4846",
9822
+ // Border colors
9823
+ "--color-border-primary": "#4A4846",
9824
+ "--color-border-secondary": "#242222",
9825
+ "--color-border-tertiary": "#1A1917",
9826
+ "--color-border-inverse": "#ABABAB",
9827
+ "--color-border-ghost": "transparent",
9828
+ "--color-border-info": "#58a6ff",
9829
+ "--color-border-danger": "#F85149",
9830
+ "--color-border-success": "#3fb950",
9831
+ "--color-border-warning": "#d29922",
9832
+ "--color-border-disabled": "#242222",
9833
+ // Ring/focus colors
9834
+ "--color-ring-primary": "#cdcdcd",
9835
+ "--color-ring-secondary": "#666666",
9836
+ "--color-ring-inverse": "#0D0D0B",
9837
+ "--color-ring-info": "#58a6ff",
9838
+ "--color-ring-danger": "#F85149",
9839
+ "--color-ring-success": "#3fb950",
9840
+ "--color-ring-warning": "#d29922",
9841
+ // Shadows (dark mode)
9842
+ "--shadow-hairline": "0 0 0 1px rgba(0, 0, 0, 0.1)",
9843
+ "--shadow-sm": "0 1px 2px 0 rgba(0, 0, 0, 0.3)",
9844
+ "--shadow-md": "0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3)",
9845
+ "--shadow-lg": "0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3)"
9846
+ };
9847
+ var MCP_APPS_LIGHT_DEFAULTS = {
9848
+ // Background colors
9849
+ "--color-background-primary": "#f2f2f2",
9850
+ "--color-background-secondary": "#e8e8e8",
9851
+ "--color-background-tertiary": "#eaeaea",
9852
+ "--color-background-inverse": "#1F1E1D",
9853
+ "--color-background-ghost": "transparent",
9854
+ "--color-background-info": "#dbeafe",
9855
+ "--color-background-danger": "#fee2e2",
9856
+ "--color-background-success": "#dcfce7",
9857
+ "--color-background-warning": "#fef3c7",
9858
+ "--color-background-disabled": "#e8e8e8",
9859
+ // Text colors
9860
+ "--color-text-primary": "#1F1E1D",
9861
+ "--color-text-secondary": "#6B6A68",
9862
+ "--color-text-tertiary": "#9A9998",
9863
+ "--color-text-inverse": "#F8F7F6",
9864
+ "--color-text-ghost": "#B8B7B5",
9865
+ "--color-text-info": "#0366d6",
9866
+ "--color-text-danger": "#DC2626",
9867
+ "--color-text-success": "#22863a",
9868
+ "--color-text-warning": "#b08800",
9869
+ "--color-text-disabled": "#9A9998",
9870
+ // Border colors
9871
+ "--color-border-primary": "#b8b8b8",
9872
+ "--color-border-secondary": "#d8d8d8",
9873
+ "--color-border-tertiary": "#e8e8e8",
9874
+ "--color-border-inverse": "#1F1E1D",
9875
+ "--color-border-ghost": "transparent",
9876
+ "--color-border-info": "#0366d6",
9877
+ "--color-border-danger": "#DC2626",
9878
+ "--color-border-success": "#22863a",
9879
+ "--color-border-warning": "#b08800",
9880
+ "--color-border-disabled": "#d8d8d8",
9881
+ // Ring/focus colors
9882
+ "--color-ring-primary": "#666666",
9883
+ "--color-ring-secondary": "#AAAAAA",
9884
+ "--color-ring-inverse": "#F8F7F6",
9885
+ "--color-ring-info": "#0366d6",
9886
+ "--color-ring-danger": "#DC2626",
9887
+ "--color-ring-success": "#22863a",
9888
+ "--color-ring-warning": "#b08800",
9889
+ // Shadows (light mode)
9890
+ "--shadow-hairline": "0 0 0 1px rgba(0, 0, 0, 0.05)",
9891
+ "--shadow-sm": "0 1px 2px 0 rgba(0, 0, 0, 0.1)",
9892
+ "--shadow-md": "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",
9893
+ "--shadow-lg": "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)"
9894
+ };
9895
+ var MCP_APPS_SHARED_DEFAULTS = {
9896
+ // Typography - font families
9897
+ "--font-sans": '"Sora", system-ui, sans-serif',
9898
+ "--font-mono": '"SF Mono", Monaco, Consolas, "Liberation Mono", monospace',
9899
+ // Typography - font weights
9900
+ "--font-weight-normal": "400",
9901
+ "--font-weight-medium": "500",
9902
+ "--font-weight-semibold": "600",
9903
+ "--font-weight-bold": "700",
9904
+ // Typography - text sizes
9905
+ "--font-text-xs-size": "0.6875rem",
9906
+ "--font-text-sm-size": "0.75rem",
9907
+ "--font-text-md-size": "0.875rem",
9908
+ "--font-text-lg-size": "1rem",
9909
+ // Typography - text line heights
9910
+ "--font-text-xs-line-height": "1rem",
9911
+ "--font-text-sm-line-height": "1.25rem",
9912
+ "--font-text-md-line-height": "1.5rem",
9913
+ "--font-text-lg-line-height": "1.75rem",
9914
+ // Typography - heading sizes
9915
+ "--font-heading-xs-size": "0.875rem",
9916
+ "--font-heading-sm-size": "1rem",
9917
+ "--font-heading-md-size": "1.125rem",
9918
+ "--font-heading-lg-size": "1.25rem",
9919
+ "--font-heading-xl-size": "1.5rem",
9920
+ "--font-heading-2xl-size": "1.875rem",
9921
+ "--font-heading-3xl-size": "2.25rem",
9922
+ // Typography - heading line heights
9923
+ "--font-heading-xs-line-height": "1.25rem",
9924
+ "--font-heading-sm-line-height": "1.5rem",
9925
+ "--font-heading-md-line-height": "1.75rem",
9926
+ "--font-heading-lg-line-height": "2rem",
9927
+ "--font-heading-xl-line-height": "2.25rem",
9928
+ "--font-heading-2xl-line-height": "2.5rem",
9929
+ "--font-heading-3xl-line-height": "2.75rem",
9930
+ // Border radius
9931
+ "--border-radius-xs": "0.125rem",
9932
+ "--border-radius-sm": "0.25rem",
9933
+ "--border-radius-md": "0.375rem",
9934
+ "--border-radius-lg": "0.5rem",
9935
+ "--border-radius-xl": "0.75rem",
9936
+ "--border-radius-full": "9999px",
9937
+ // Border width
9938
+ "--border-width-regular": "1px"
9939
+ };
9940
+ var CHATGPT_LIGHT_DEFAULTS = {
9941
+ "--color-background-primary": "#ffffff",
9942
+ "--color-background-secondary": "#f7f7f8",
9943
+ "--color-background-tertiary": "#ececec",
9944
+ "--color-background-inverse": "#0d0d0d",
9945
+ "--color-background-ghost": "rgba(0, 0, 0, 0.04)",
9946
+ "--color-background-info": "#eef6fc",
9947
+ "--color-background-danger": "#fdecec",
9948
+ "--color-background-success": "#edf8ee",
9949
+ "--color-background-warning": "#fdf5e6",
9950
+ "--color-background-disabled": "#f4f4f4",
9951
+ "--color-text-primary": "#0d0d0d",
9952
+ "--color-text-secondary": "#6e6e80",
9953
+ "--color-text-tertiary": "#8e8ea0",
9954
+ "--color-text-inverse": "#ffffff",
9955
+ "--color-text-ghost": "rgba(0, 0, 0, 0.4)",
9956
+ "--color-text-info": "#0066da",
9957
+ "--color-text-danger": "#d93025",
9958
+ "--color-text-success": "#188038",
9959
+ "--color-text-warning": "#b36200",
9960
+ "--color-text-disabled": "#b4b4b4",
9961
+ "--color-border-primary": "#e5e5e5",
9962
+ "--color-border-secondary": "#ececec",
9963
+ "--color-border-tertiary": "#f4f4f4",
9964
+ "--color-border-inverse": "#3c3c3c",
9965
+ "--color-border-ghost": "rgba(0, 0, 0, 0.08)",
9966
+ "--color-border-info": "#a8d4fb",
9967
+ "--color-border-danger": "#f9b4ab",
9968
+ "--color-border-success": "#a8dab5",
9969
+ "--color-border-warning": "#f9dca8",
9970
+ "--color-border-disabled": "#d9d9d9",
9971
+ "--color-ring-primary": "#10a37f",
9972
+ "--color-ring-secondary": "#6e6e80",
9973
+ "--color-ring-inverse": "#ffffff",
9974
+ "--color-ring-info": "#0066da",
9975
+ "--color-ring-danger": "#d93025",
9976
+ "--color-ring-success": "#188038",
9977
+ "--color-ring-warning": "#b36200"
9978
+ };
9979
+ var CHATGPT_DARK_DEFAULTS = {
9980
+ "--color-background-primary": "#212121",
9981
+ "--color-background-secondary": "#2f2f2f",
9982
+ "--color-background-tertiary": "#424242",
9983
+ "--color-background-inverse": "#ffffff",
9984
+ "--color-background-ghost": "rgba(255, 255, 255, 0.04)",
9985
+ "--color-background-info": "#1a3a4a",
9986
+ "--color-background-danger": "#4a1a1a",
9987
+ "--color-background-success": "#1a3a1a",
9988
+ "--color-background-warning": "#4a3a1a",
9989
+ "--color-background-disabled": "#3a3a3a",
9990
+ "--color-text-primary": "#ececec",
9991
+ "--color-text-secondary": "#b4b4b4",
9992
+ "--color-text-tertiary": "#8e8e8e",
9993
+ "--color-text-inverse": "#0d0d0d",
9994
+ "--color-text-ghost": "rgba(255, 255, 255, 0.4)",
9995
+ "--color-text-info": "#6eb5ff",
9996
+ "--color-text-danger": "#ff6b6b",
9997
+ "--color-text-success": "#6bff6b",
9998
+ "--color-text-warning": "#ffb86b",
9999
+ "--color-text-disabled": "#666666",
10000
+ "--color-border-primary": "#424242",
10001
+ "--color-border-secondary": "#3a3a3a",
10002
+ "--color-border-tertiary": "#2f2f2f",
10003
+ "--color-border-inverse": "#e5e5e5",
10004
+ "--color-border-ghost": "rgba(255, 255, 255, 0.08)",
10005
+ "--color-border-info": "#3a5a7a",
10006
+ "--color-border-danger": "#7a3a3a",
10007
+ "--color-border-success": "#3a7a3a",
10008
+ "--color-border-warning": "#7a5a3a",
10009
+ "--color-border-disabled": "#4a4a4a",
10010
+ "--color-ring-primary": "#10a37f",
10011
+ "--color-ring-secondary": "#8e8e8e",
10012
+ "--color-ring-inverse": "#0d0d0d",
10013
+ "--color-ring-info": "#6eb5ff",
10014
+ "--color-ring-danger": "#ff6b6b",
10015
+ "--color-ring-success": "#6bff6b",
10016
+ "--color-ring-warning": "#ffb86b"
10017
+ };
10018
+ var CHATGPT_SHARED_DEFAULTS = {
10019
+ "--font-sans": '"S\xF6hne", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
10020
+ "--font-mono": '"S\xF6hne Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',
10021
+ "--font-weight-normal": "400",
10022
+ "--font-weight-medium": "500",
10023
+ "--font-weight-semibold": "600",
10024
+ "--font-weight-bold": "700",
10025
+ "--font-text-xs-size": "0.75rem",
10026
+ "--font-text-xs-line-height": "1rem",
10027
+ "--font-text-sm-size": "0.875rem",
10028
+ "--font-text-sm-line-height": "1.25rem",
10029
+ "--font-text-md-size": "1rem",
10030
+ "--font-text-md-line-height": "1.5rem",
10031
+ "--font-text-lg-size": "1.125rem",
10032
+ "--font-text-lg-line-height": "1.75rem",
10033
+ "--font-heading-xs-size": "0.875rem",
10034
+ "--font-heading-xs-line-height": "1.25rem",
10035
+ "--font-heading-sm-size": "1rem",
10036
+ "--font-heading-sm-line-height": "1.5rem",
10037
+ "--font-heading-md-size": "1.125rem",
10038
+ "--font-heading-md-line-height": "1.75rem",
10039
+ "--font-heading-lg-size": "1.25rem",
10040
+ "--font-heading-lg-line-height": "1.75rem",
10041
+ "--font-heading-xl-size": "1.5rem",
10042
+ "--font-heading-xl-line-height": "2rem",
10043
+ "--font-heading-2xl-size": "1.875rem",
10044
+ "--font-heading-2xl-line-height": "2.25rem",
10045
+ "--font-heading-3xl-size": "2.25rem",
10046
+ "--font-heading-3xl-line-height": "2.5rem",
10047
+ "--border-radius-xs": "4px",
10048
+ "--border-radius-sm": "6px",
10049
+ "--border-radius-md": "8px",
10050
+ "--border-radius-lg": "12px",
10051
+ "--border-radius-xl": "16px",
10052
+ "--border-radius-full": "9999px",
10053
+ "--border-width-regular": "1px",
10054
+ "--shadow-hairline": "0 0 0 1px rgba(0, 0, 0, 0.05)",
10055
+ "--shadow-sm": "0 1px 2px rgba(0, 0, 0, 0.04)",
10056
+ "--shadow-md": "0 2px 8px rgba(0, 0, 0, 0.08)",
10057
+ "--shadow-lg": "0 8px 24px rgba(0, 0, 0, 0.12)"
10058
+ };
10059
+ var getMcpAppDefaultStyles = ({ theme }) => {
10060
+ const colorDefaults = theme === "dark" ? MCP_APPS_DARK_DEFAULTS : MCP_APPS_LIGHT_DEFAULTS;
10061
+ return { ...colorDefaults, ...MCP_APPS_SHARED_DEFAULTS };
10062
+ };
10063
+ var getChatGptDefaultStyles = ({ theme }) => {
10064
+ const colorDefaults = theme === "dark" ? CHATGPT_DARK_DEFAULTS : CHATGPT_LIGHT_DEFAULTS;
10065
+ return { ...colorDefaults, ...CHATGPT_SHARED_DEFAULTS };
10066
+ };
10067
+ var detectTheme = () => {
10068
+ if (typeof document === "undefined") {
10069
+ return "dark";
10070
+ }
10071
+ const root = document.documentElement;
10072
+ const dataTheme = root.getAttribute("data-theme");
10073
+ if (dataTheme === "dark" || dataTheme === "light") {
10074
+ return dataTheme;
10075
+ }
10076
+ if (root.classList.contains("light")) {
10077
+ return "light";
10078
+ }
10079
+ if (root.classList.contains("dark")) {
10080
+ return "dark";
10081
+ }
10082
+ if (typeof window !== "undefined" && window.matchMedia?.("(prefers-color-scheme: dark)").matches) {
10083
+ return "dark";
10084
+ }
10085
+ return "dark";
10086
+ };
10087
+ var applyStyles = ({ styles }) => {
10088
+ if (typeof document === "undefined") {
10089
+ return;
10090
+ }
10091
+ const root = document.documentElement;
10092
+ for (const [key, value] of Object.entries(styles)) {
10093
+ root.style.setProperty(key, value);
10094
+ }
10095
+ };
10096
+ var initStyles = ({
10097
+ environment,
10098
+ options = {}
10099
+ }) => {
10100
+ if (typeof document === "undefined") {
10101
+ return;
10102
+ }
10103
+ const theme = detectTheme();
10104
+ const defaults = environment === "chatgpt" ? getChatGptDefaultStyles({ theme }) : getMcpAppDefaultStyles({ theme });
10105
+ applyStyles({ styles: defaults });
10106
+ document.documentElement.setAttribute("data-env", environment);
10107
+ const shouldObserve = options.observeThemeChanges ?? environment === "chatgpt";
10108
+ if (shouldObserve && environment === "chatgpt") {
10109
+ setupThemeObserver({ environment });
10110
+ }
10111
+ };
10112
+ var setupThemeObserver = ({ environment }) => {
10113
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") {
10114
+ return;
10115
+ }
10116
+ if (environment !== "chatgpt") {
10117
+ return;
10118
+ }
10119
+ const root = document.documentElement;
10120
+ const observer = new MutationObserver((mutations) => {
10121
+ for (const mutation of mutations) {
10122
+ if (mutation.type === "attributes" && (mutation.attributeName === "data-theme" || mutation.attributeName === "class")) {
10123
+ const newTheme = detectTheme();
10124
+ const defaults = getChatGptDefaultStyles({ theme: newTheme });
10125
+ applyStyles({ styles: defaults });
10126
+ }
10127
+ }
10128
+ });
10129
+ setTimeout(() => {
10130
+ observer.observe(root, {
10131
+ attributes: true,
10132
+ attributeFilter: ["data-theme", "class"]
10133
+ });
10134
+ }, 100);
10135
+ };
10136
+
9798
10137
  // src/core/websocket.ts
9799
10138
  function createWebSocket(url, config = {}) {
9800
10139
  const {
@@ -9908,14 +10247,25 @@ function createHost(config) {
9908
10247
  return new McpAppHostClient(config);
9909
10248
  }
9910
10249
  export {
10250
+ CHATGPT_DARK_DEFAULTS,
10251
+ CHATGPT_LIGHT_DEFAULTS,
10252
+ CHATGPT_SHARED_DEFAULTS,
9911
10253
  ChatGptAppHostClient,
10254
+ MCP_APPS_DARK_DEFAULTS,
10255
+ MCP_APPS_LIGHT_DEFAULTS,
10256
+ MCP_APPS_SHARED_DEFAULTS,
9912
10257
  McpAppHostClient,
9913
10258
  YU as applyDocumentTheme,
9914
10259
  qU as applyHostFonts,
9915
10260
  QU as applyHostStyleVariables,
10261
+ applyStyles,
9916
10262
  createHost,
9917
10263
  createWebSocket,
9918
10264
  detectEnvironment,
9919
- VU as getDocumentTheme
10265
+ detectTheme,
10266
+ getChatGptDefaultStyles,
10267
+ VU as getDocumentTheme,
10268
+ getMcpAppDefaultStyles,
10269
+ initStyles
9920
10270
  };
9921
10271
  //# sourceMappingURL=index.js.map