glchat-a2ui-react-renderer 0.3.6 → 0.4.1

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.
Files changed (128) hide show
  1. package/README.md +200 -267
  2. package/dist/index.d.ts +13 -6
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +14 -4
  5. package/dist/src/Provider.d.ts +33 -8
  6. package/dist/src/Provider.d.ts.map +1 -1
  7. package/dist/src/Provider.js +12 -10
  8. package/dist/src/SurfaceRenderer.d.ts +7 -1
  9. package/dist/src/SurfaceRenderer.d.ts.map +1 -1
  10. package/dist/src/SurfaceRenderer.js +2 -2
  11. package/dist/src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.d.ts +1 -5
  12. package/dist/src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.d.ts.map +1 -1
  13. package/dist/src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.js +2 -12
  14. package/dist/src/components/a2ui/v0_9/Button/Button.d.ts +73 -239
  15. package/dist/src/components/a2ui/v0_9/Button/Button.d.ts.map +1 -1
  16. package/dist/src/components/a2ui/v0_9/Button/Button.js +2 -13
  17. package/dist/src/components/a2ui/v0_9/ChoicePicker/ChoicePicker.d.ts +1 -8
  18. package/dist/src/components/a2ui/v0_9/ChoicePicker/ChoicePicker.d.ts.map +1 -1
  19. package/dist/src/components/a2ui/v0_9/ChoicePicker/ChoicePicker.js +2 -51
  20. package/dist/src/components/a2ui/v0_9/TagInput/TagInput.d.ts +40 -196
  21. package/dist/src/components/a2ui/v0_9/TagInput/TagInput.d.ts.map +1 -1
  22. package/dist/src/components/a2ui/v0_9/TagInput/TagInput.js +3 -10
  23. package/dist/src/components/a2ui/v0_9/Timeout/Timeout.d.ts +24 -100
  24. package/dist/src/components/a2ui/v0_9/Timeout/Timeout.d.ts.map +1 -1
  25. package/dist/src/components/a2ui/v0_9/Timeout/Timeout.js +3 -23
  26. package/dist/src/components/a2ui/v0_9/common.d.ts +11 -57
  27. package/dist/src/components/a2ui/v0_9/common.d.ts.map +1 -1
  28. package/dist/src/components/a2ui/v0_9/common.js +0 -9
  29. package/dist/src/components/a2ui/v1_0/AudioPlayer/AudioPlayer.d.ts +3 -0
  30. package/dist/src/components/a2ui/v1_0/AudioPlayer/AudioPlayer.d.ts.map +1 -0
  31. package/dist/src/components/a2ui/v1_0/AudioPlayer/AudioPlayer.js +6 -0
  32. package/dist/src/components/a2ui/v1_0/Button/Button.d.ts +223 -0
  33. package/dist/src/components/a2ui/v1_0/Button/Button.d.ts.map +1 -0
  34. package/dist/src/components/a2ui/v1_0/Button/Button.js +26 -0
  35. package/dist/src/components/a2ui/v1_0/ChoicePicker/ChoicePicker.d.ts +3 -0
  36. package/dist/src/components/a2ui/v1_0/ChoicePicker/ChoicePicker.d.ts.map +1 -0
  37. package/dist/src/components/a2ui/v1_0/ChoicePicker/ChoicePicker.js +6 -0
  38. package/dist/src/components/a2ui/v1_0/TagInput/TagInput.d.ts +214 -0
  39. package/dist/src/components/a2ui/v1_0/TagInput/TagInput.d.ts.map +1 -0
  40. package/dist/src/components/a2ui/v1_0/TagInput/TagInput.js +34 -0
  41. package/dist/src/components/a2ui/v1_0/Timeout/Timeout.d.ts +58 -0
  42. package/dist/src/components/a2ui/v1_0/Timeout/Timeout.d.ts.map +1 -0
  43. package/dist/src/components/a2ui/v1_0/Timeout/Timeout.js +25 -0
  44. package/dist/src/components/a2ui/v1_0/common.d.ts +15 -0
  45. package/dist/src/components/a2ui/v1_0/common.d.ts.map +1 -0
  46. package/dist/src/components/a2ui/v1_0/common.js +16 -0
  47. package/dist/src/components/a2ui/views/AudioPlayer/AudioPlayer.d.ts +14 -0
  48. package/dist/src/components/a2ui/views/AudioPlayer/AudioPlayer.d.ts.map +1 -0
  49. package/dist/src/components/a2ui/views/AudioPlayer/AudioPlayer.js +10 -0
  50. package/dist/src/components/a2ui/views/Button/Button.d.ts +18 -0
  51. package/dist/src/components/a2ui/views/Button/Button.d.ts.map +1 -0
  52. package/dist/src/components/a2ui/views/Button/Button.js +22 -0
  53. package/dist/src/components/a2ui/views/ChoicePicker/ChoicePicker.d.ts +25 -0
  54. package/dist/src/components/a2ui/views/ChoicePicker/ChoicePicker.d.ts.map +1 -0
  55. package/dist/src/components/a2ui/views/ChoicePicker/ChoicePicker.js +46 -0
  56. package/dist/src/components/a2ui/views/ChoicePicker/theme.d.ts.map +1 -0
  57. package/dist/src/components/a2ui/views/TagInput/TagInput.d.ts +16 -0
  58. package/dist/src/components/a2ui/views/TagInput/TagInput.d.ts.map +1 -0
  59. package/dist/src/components/a2ui/views/TagInput/TagInput.js +12 -0
  60. package/dist/src/components/a2ui/views/Timeout/Timeout.d.ts +9 -0
  61. package/dist/src/components/a2ui/views/Timeout/Timeout.d.ts.map +1 -0
  62. package/dist/src/components/a2ui/views/Timeout/Timeout.js +27 -0
  63. package/dist/src/components/a2ui/views/weight.d.ts +7 -0
  64. package/dist/src/components/a2ui/views/weight.d.ts.map +1 -0
  65. package/dist/src/components/a2ui/views/weight.js +9 -0
  66. package/dist/src/core/SurfaceErrorBoundary.d.ts +27 -0
  67. package/dist/src/core/SurfaceErrorBoundary.d.ts.map +1 -0
  68. package/dist/src/core/SurfaceErrorBoundary.js +24 -0
  69. package/dist/src/core/SurfaceGroupProvider.d.ts +40 -0
  70. package/dist/src/core/SurfaceGroupProvider.d.ts.map +1 -0
  71. package/dist/src/core/SurfaceGroupProvider.js +142 -0
  72. package/dist/src/core/SurfaceRenderer.d.ts +4 -0
  73. package/dist/src/core/SurfaceRenderer.d.ts.map +1 -0
  74. package/dist/src/core/SurfaceRenderer.js +64 -0
  75. package/dist/src/core/errors.d.ts +44 -0
  76. package/dist/src/core/errors.d.ts.map +1 -0
  77. package/dist/src/core/errors.js +42 -0
  78. package/dist/src/core/types.d.ts +11 -0
  79. package/dist/src/core/types.d.ts.map +1 -0
  80. package/dist/src/core/types.js +1 -0
  81. package/dist/src/core/unknownComponent.d.ts +28 -0
  82. package/dist/src/core/unknownComponent.d.ts.map +1 -0
  83. package/dist/src/core/unknownComponent.js +41 -0
  84. package/dist/src/{v0_9 → core}/useSurfaces.d.ts +3 -3
  85. package/dist/src/core/useSurfaces.d.ts.map +1 -0
  86. package/dist/src/utils/detectVersion.d.ts +4 -2
  87. package/dist/src/utils/detectVersion.d.ts.map +1 -1
  88. package/dist/src/utils/detectVersion.js +5 -1
  89. package/dist/src/v0_8/Provider.d.ts +2 -1
  90. package/dist/src/v0_8/Provider.d.ts.map +1 -1
  91. package/dist/src/v0_8/Provider.js +3 -8
  92. package/dist/src/v0_9/Provider.d.ts +13 -13
  93. package/dist/src/v0_9/Provider.d.ts.map +1 -1
  94. package/dist/src/v0_9/Provider.js +14 -61
  95. package/dist/src/v0_9/catalog.d.ts +2 -8
  96. package/dist/src/v0_9/catalog.d.ts.map +1 -1
  97. package/dist/src/v0_9/catalog.js +3 -17
  98. package/dist/src/v1_0/Provider.d.ts +27 -0
  99. package/dist/src/v1_0/Provider.d.ts.map +1 -0
  100. package/dist/src/v1_0/Provider.js +35 -0
  101. package/dist/src/v1_0/catalog.d.ts +52 -0
  102. package/dist/src/v1_0/catalog.d.ts.map +1 -0
  103. package/dist/src/v1_0/catalog.js +118 -0
  104. package/dist/src/v1_0/types.d.ts +13 -0
  105. package/dist/src/v1_0/types.d.ts.map +1 -0
  106. package/dist/src/v1_0/types.js +1 -0
  107. package/json/README.md +27 -30
  108. package/json/v0_9/glchat_standard_catalog_definition.json +5 -5
  109. package/json/v1_0/a2ui-sample-messages-extension.json +150 -0
  110. package/json/v1_0/a2ui-sample-messages.json +144 -0
  111. package/json/v1_0/glchat_extension_catalog_definition.json +794 -0
  112. package/json/v1_0/glchat_standard_catalog_definition.json +1487 -0
  113. package/package.json +4 -4
  114. package/styles/globals.css +136 -67
  115. package/dist/src/components/a2ui/v0_9/ChoicePicker/theme.d.ts.map +0 -1
  116. package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.d.ts +0 -231
  117. package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.d.ts.map +0 -1
  118. package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.js +0 -24
  119. package/dist/src/v0_9/SurfaceErrorBoundary.d.ts +0 -18
  120. package/dist/src/v0_9/SurfaceErrorBoundary.d.ts.map +0 -1
  121. package/dist/src/v0_9/SurfaceErrorBoundary.js +0 -24
  122. package/dist/src/v0_9/SurfaceRenderer.d.ts +0 -3
  123. package/dist/src/v0_9/SurfaceRenderer.d.ts.map +0 -1
  124. package/dist/src/v0_9/SurfaceRenderer.js +0 -47
  125. package/dist/src/v0_9/useSurfaces.d.ts.map +0 -1
  126. /package/dist/src/components/a2ui/{v0_9 → views}/ChoicePicker/theme.d.ts +0 -0
  127. /package/dist/src/components/a2ui/{v0_9 → views}/ChoicePicker/theme.js +0 -0
  128. /package/dist/src/{v0_9 → core}/useSurfaces.js +0 -0
@@ -1,21 +1,21 @@
1
1
  import type { PropsWithChildren } from 'react';
2
- import { type ReactComponentImplementation } from '@a2ui/react/v0_9';
3
- import { type Catalog, type A2uiClientAction, type SurfaceGroupModel } from '@a2ui/web_core/v0_9';
2
+ import type { ReactCatalogComponent } from '@a2ui/react/v0_9';
3
+ import { type A2uiClientAction, type Catalog } from '@a2ui/web_core/v0_9';
4
+ import type { A2UIErrorHandler } from '../core/errors.js';
5
+ import type { ActionOptions } from '../core/types.js';
4
6
  import type { V09Message } from '../utils/detectVersion.js';
5
7
  export type V09ActionPayload = A2uiClientAction;
6
- export type V09ActionHandler = (action: A2uiClientAction) => void | Promise<void>;
7
- export type V09MessageErrorHandler = (error: unknown) => void;
8
+ export type V09ActionHandler = (action: V09ActionPayload, options?: ActionOptions) => void | Promise<void>;
8
9
  export type V09ProviderProps = {
9
10
  messages?: V09Message[];
10
11
  onAction?: V09ActionHandler;
11
- onError?: V09MessageErrorHandler;
12
- catalog?: Catalog<ReactComponentImplementation>;
12
+ onError?: A2UIErrorHandler;
13
+ /** Catalog override (defaults to the GLChat v0.9 catalog). */
14
+ catalog?: Catalog<ReactCatalogComponent>;
13
15
  };
14
- type SurfaceGroupContextValue = {
15
- model: SurfaceGroupModel<ReactComponentImplementation>;
16
- hasMessages: boolean;
17
- };
18
- export declare function V09Provider({ messages, onAction, onError, catalog, children, }: Readonly<PropsWithChildren<V09ProviderProps>>): import("react").JSX.Element;
19
- export declare function useSurfaceGroup(): SurfaceGroupContextValue;
20
- export {};
16
+ /**
17
+ * A2UI v0.9: one catalog (GLChat, or the `catalog` override). Unknown
18
+ * `createSurface.catalogId` values are rewritten to that catalog.
19
+ */
20
+ export declare function V09Provider({ catalog, children, ...rest }: Readonly<PropsWithChildren<V09ProviderProps>>): import("react").JSX.Element;
21
21
  //# sourceMappingURL=Provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/v0_9/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,EAAmB,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAK7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAQ5D,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAChD,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAClF,MAAM,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC;CACjD,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,KAAK,EAAE,iBAAiB,CAAC,4BAA4B,CAAC,CAAC;IACvD,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAMF,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,QAAQ,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,+BAoF/C;AAED,wBAAgB,eAAe,IAAI,wBAAwB,CAI1D"}
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/v0_9/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAoB,KAAK,gBAAgB,EAAE,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAI5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAChD,MAAM,MAAM,gBAAgB,GAAG,CAC7B,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,aAAa,KACpB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,8DAA8D;IAC9D,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC1C,CAAC;AAEF;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,QAAQ,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,+BA6B/C"}
@@ -1,74 +1,27 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { createContext, useContext, useEffect, useMemo, useRef, useState } from 'react';
4
- import { MarkdownContext } from '@a2ui/react/v0_9';
5
- import { MessageProcessor, } from '@a2ui/web_core/v0_9';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useCallback, useEffect, useState } from 'react';
4
+ import { MessageProcessor } from '@a2ui/web_core/v0_9';
6
5
  import { injectBasicCatalogStyles } from '@a2ui/web_core/v0_9/basic_catalog';
7
- import { renderMarkdown } from '@a2ui/markdown-it';
8
- import { InlineAlert } from '../components/ui/InlineAlert/InlineAlert.js';
9
- import { createGlchatCatalog, GLCHAT_CATALOG_ID, installUnknownComponentFallback, withFallbackCatalogId, } from './catalog.js';
10
- const SurfaceGroupContext = createContext(null);
11
- const PROCESS_ERROR_MESSAGE = 'Failed to process A2UI messages (v0.9)';
12
- export function V09Provider({ messages, onAction, onError, catalog, children, }) {
13
- const onActionRef = useRef(onAction);
14
- const onErrorRef = useRef(onError);
15
- const [processError, setProcessError] = useState(null);
16
- const hasMessages = !!messages?.length;
17
- useEffect(() => {
18
- onActionRef.current = onAction;
19
- }, [onAction]);
20
- useEffect(() => {
21
- onErrorRef.current = onError;
22
- }, [onError]);
6
+ import { SurfaceGroupProvider } from '../core/SurfaceGroupProvider.js';
7
+ import { installUnknownComponentFallback } from '../core/unknownComponent.js';
8
+ import { createGlchatCatalog, GLCHAT_CATALOG_ID, withFallbackCatalogId } from './catalog.js';
9
+ /**
10
+ * A2UI v0.9: one catalog (GLChat, or the `catalog` override). Unknown
11
+ * `createSurface.catalogId` values are rewritten to that catalog.
12
+ */
13
+ export function V09Provider({ catalog, children, ...rest }) {
23
14
  const [processor] = useState(() => {
24
15
  const resolvedCatalog = catalog ?? createGlchatCatalog();
25
16
  installUnknownComponentFallback(resolvedCatalog);
26
17
  return new MessageProcessor([resolvedCatalog]);
27
18
  });
28
- const processedCountRef = useRef(0);
29
- useEffect(() => {
30
- const subscription = processor.model.onAction.subscribe((action) => {
31
- onActionRef.current?.(action);
32
- });
33
- return () => subscription.unsubscribe();
34
- }, [processor]);
19
+ const catalogId = catalog?.id ?? GLCHAT_CATALOG_ID;
20
+ const prepareMessages = useCallback((messages) => withFallbackCatalogId(messages, catalogId), [catalogId]);
35
21
  useEffect(() => {
36
22
  if (typeof document !== 'undefined' && document.adoptedStyleSheets) {
37
23
  injectBasicCatalogStyles();
38
24
  }
39
25
  }, []);
40
- useEffect(() => {
41
- if (!messages?.length)
42
- return;
43
- if (messages.length < processedCountRef.current) {
44
- processedCountRef.current = 0;
45
- }
46
- if (processedCountRef.current >= messages.length)
47
- return;
48
- const pending = withFallbackCatalogId(messages.slice(processedCountRef.current), catalog?.id ?? GLCHAT_CATALOG_ID);
49
- processedCountRef.current = messages.length;
50
- try {
51
- processor.processMessages(pending);
52
- // eslint-disable-next-line react-hooks/set-state-in-effect -- sync process result into alert UI
53
- setProcessError(null);
54
- }
55
- catch (error) {
56
- setProcessError(PROCESS_ERROR_MESSAGE);
57
- if (onErrorRef.current) {
58
- onErrorRef.current(error);
59
- }
60
- else {
61
- // eslint-disable-next-line no-console
62
- console.error('[glchat-a2ui] Failed to process v0.9 messages:', error);
63
- }
64
- }
65
- }, [messages, processor, catalog?.id]);
66
- const contextValue = useMemo(() => ({ model: processor.model, hasMessages }), [processor.model, hasMessages]);
67
- return (_jsx(SurfaceGroupContext.Provider, { value: contextValue, children: _jsxs(MarkdownContext.Provider, { value: renderMarkdown, children: [processError ? (_jsx("div", { className: "a2ui-surface", children: _jsx(InlineAlert, { role: "alert", variant: "warning", children: processError }) })) : null, children] }) }));
68
- }
69
- export function useSurfaceGroup() {
70
- const ctx = useContext(SurfaceGroupContext);
71
- if (!ctx)
72
- throw new Error('useSurfaceGroup must be used inside Provider (v0.9)');
73
- return ctx;
26
+ return (_jsx(SurfaceGroupProvider, { version: "v0.9", processor: processor, prepareMessages: prepareMessages, ...rest, children: children }));
74
27
  }
@@ -1,4 +1,4 @@
1
- import { type ReactComponentImplementation } from '@a2ui/react/v0_9';
1
+ import type { ReactCatalogComponent } from '@a2ui/react/v0_9';
2
2
  import { Catalog, type A2uiMessage } from '@a2ui/web_core/v0_9';
3
3
  /**
4
4
  * Catalog identifier for the GLChat extended A2UI v0.9 catalog.
@@ -8,19 +8,13 @@ export declare const GLCHAT_CATALOG_ID = "https://github.com/GDP-ADMIN/glchat-sd
8
8
  export declare const GLCHAT_CATALOG_OVERRIDES: readonly ["Button"];
9
9
  /** GLChat-only components not present in the basic catalog. */
10
10
  export declare const GLCHAT_CATALOG_EXTENSIONS: readonly ["TagInput", "Timeout"];
11
- /**
12
- * Makes `catalog.components.get(type)` return the warning fallback when the
13
- * type is not registered, so unknown components render an alert instead of
14
- * `@a2ui/react`'s red placeholder.
15
- */
16
- export declare function installUnknownComponentFallback(catalog: Catalog<ReactComponentImplementation>): void;
17
11
  /**
18
12
  * Builds the GLChat A2UI v0.9 catalog:
19
13
  * - Includes basic catalog components except those GLChat overrides (`AudioPlayer`, `Button`, `ChoicePicker`).
20
14
  * - Adds GLChat overrides and extensions (`AudioPlayer`, `Button`, `ChoicePicker`, `TagInput`, `Timeout`).
21
15
  * - Reuses basic catalog functions unchanged.
22
16
  */
23
- export declare function createGlchatCatalog(): Catalog<ReactComponentImplementation>;
17
+ export declare function createGlchatCatalog(): Catalog<ReactCatalogComponent>;
24
18
  /**
25
19
  * Rewrites `createSurface.catalogId` to the given `registeredId` when the
26
20
  * message uses an unrecognized catalog. This prevents "Catalog not found"
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/v0_9/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAShE;;GAEG;AACH,eAAO,MAAM,iBAAiB,iIACkG,CAAC;AAKjI,0EAA0E;AAC1E,eAAO,MAAM,wBAAwB,qBAAsB,CAAC;AAE5D,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,kCAAmC,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,OAAO,CAAC,4BAA4B,CAAC,GAC7C,IAAI,CASN;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAiB3E;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,WAAW,EAAE,EACvB,YAAY,EAAE,MAAM,GACnB,WAAW,EAAE,CAqBf"}
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/v0_9/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAQhE;;GAEG;AACH,eAAO,MAAM,iBAAiB,iIACkG,CAAC;AAKjI,0EAA0E;AAC1E,eAAO,MAAM,wBAAwB,qBAAsB,CAAC;AAE5D,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,kCAAmC,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAkBpE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,WAAW,EAAE,EACvB,YAAY,EAAE,MAAM,GACnB,WAAW,EAAE,CAqBf"}
@@ -1,11 +1,10 @@
1
- import { basicCatalog } from '@a2ui/react/v0_9';
1
+ import { basicCatalog } from '@a2ui/web_core/v0_9/basic_catalog';
2
2
  import { Catalog } from '@a2ui/web_core/v0_9';
3
3
  import { GlchatAudioPlayerComponent } from '../components/a2ui/v0_9/AudioPlayer/AudioPlayer.js';
4
4
  import { GlchatButtonComponent } from '../components/a2ui/v0_9/Button/Button.js';
5
5
  import { GlchatChoicePickerComponent } from '../components/a2ui/v0_9/ChoicePicker/ChoicePicker.js';
6
6
  import { GlchatTagInputComponent } from '../components/a2ui/v0_9/TagInput/TagInput.js';
7
7
  import { GlchatTimeoutComponent } from '../components/a2ui/v0_9/Timeout/Timeout.js';
8
- import { UnknownComponentFallback } from '../components/a2ui/v0_9/UnknownComponent/UnknownComponent.js';
9
8
  /**
10
9
  * Catalog identifier for the GLChat extended A2UI v0.9 catalog.
11
10
  */
@@ -16,20 +15,6 @@ const OVERRIDDEN_COMPONENTS = new Set(['AudioPlayer', 'Button', 'ChoicePicker'])
16
15
  export const GLCHAT_CATALOG_OVERRIDES = ['Button'];
17
16
  /** GLChat-only components not present in the basic catalog. */
18
17
  export const GLCHAT_CATALOG_EXTENSIONS = ['TagInput', 'Timeout'];
19
- /**
20
- * Makes `catalog.components.get(type)` return the warning fallback when the
21
- * type is not registered, so unknown components render an alert instead of
22
- * `@a2ui/react`'s red placeholder.
23
- */
24
- export function installUnknownComponentFallback(catalog) {
25
- const map = catalog.components;
26
- if (map.__glchatUnknownFallback) {
27
- return;
28
- }
29
- const originalGet = map.get.bind(map);
30
- map.get = ((name) => originalGet(name) ?? UnknownComponentFallback);
31
- map.__glchatUnknownFallback = true;
32
- }
33
18
  /**
34
19
  * Builds the GLChat A2UI v0.9 catalog:
35
20
  * - Includes basic catalog components except those GLChat overrides (`AudioPlayer`, `Button`, `ChoicePicker`).
@@ -47,7 +32,8 @@ export function createGlchatCatalog() {
47
32
  GlchatTimeoutComponent,
48
33
  ];
49
34
  const functions = Array.from(basicCatalog.functions.values());
50
- return new Catalog(GLCHAT_CATALOG_ID, components, functions);
35
+ // Spec version this catalog targets (v0.9 schemas/bindings).
36
+ return new Catalog(GLCHAT_CATALOG_ID, 'v0.9', components, functions);
51
37
  }
52
38
  /**
53
39
  * Rewrites `createSurface.catalogId` to the given `registeredId` when the
@@ -0,0 +1,27 @@
1
+ import type { PropsWithChildren } from 'react';
2
+ import type { ReactCatalogComponent } from '@a2ui/react';
3
+ import { type Catalog } from '@a2ui/web_core/v1_0';
4
+ import type { A2UIErrorHandler } from '../core/errors.js';
5
+ import type { ActionOptions } from '../core/types.js';
6
+ import type { V1Message } from '../utils/detectVersion.js';
7
+ import type { AgentMessageHandler, V1ActionPayload } from './types.js';
8
+ export type V1ActionHandler = (action: V1ActionPayload, options?: ActionOptions) => void | Promise<void>;
9
+ export type V1ProviderProps = {
10
+ messages?: V1Message[];
11
+ onAction?: V1ActionHandler;
12
+ onError?: A2UIErrorHandler;
13
+ /** Handler for the messages the renderer emits for the agent. */
14
+ onAgentMessage?: AgentMessageHandler;
15
+ /**
16
+ * Custom catalogs, added next to the built-in ones. A catalog with a
17
+ * built-in ID replaces it. Read once on mount.
18
+ */
19
+ catalogsV1?: Catalog<ReactCatalogComponent>[];
20
+ };
21
+ /**
22
+ * A2UI v1.0: registers the A2UI basic, GLChat full and GLChat-only catalogs
23
+ * (plus `catalogsV1`), which surfaces may mix per component, and forwards the
24
+ * renderer's agent-bound messages to `onAgentMessage`.
25
+ */
26
+ export declare function V1Provider({ catalogsV1, onAgentMessage, children, ...rest }: Readonly<PropsWithChildren<V1ProviderProps>>): import("react").JSX.Element;
27
+ //# sourceMappingURL=Provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/v1_0/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,MAAM,eAAe,GAAG,CAC5B,MAAM,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE,aAAa,KACpB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,iEAAiE;IACjE,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACrC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC;CAC/C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EACzB,UAAU,EACV,cAAc,EACd,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,QAAQ,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC,+BAkC9C"}
@@ -0,0 +1,35 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import { injectBasicCatalogStyles } from '@a2ui/web_core/catalogs/basic/v1';
5
+ import { MessageProcessor } from '@a2ui/web_core/v1_0';
6
+ import { SurfaceGroupProvider } from '../core/SurfaceGroupProvider.js';
7
+ import { createGlchatRuntimeCatalogsV1 } from './catalog.js';
8
+ /**
9
+ * A2UI v1.0: registers the A2UI basic, GLChat full and GLChat-only catalogs
10
+ * (plus `catalogsV1`), which surfaces may mix per component, and forwards the
11
+ * renderer's agent-bound messages to `onAgentMessage`.
12
+ */
13
+ export function V1Provider({ catalogsV1, onAgentMessage, children, ...rest }) {
14
+ const onAgentMessageRef = useRef(onAgentMessage);
15
+ useEffect(() => {
16
+ onAgentMessageRef.current = onAgentMessage;
17
+ }, [onAgentMessage]);
18
+ // The callbacks below read `onAgentMessageRef` only when upstream invokes
19
+ // them (while processing messages in an effect, or on an async RPC reply),
20
+ // never during render.
21
+ // eslint-disable-next-line react-hooks/refs
22
+ const [processor] = useState(() => {
23
+ return new MessageProcessor(createGlchatRuntimeCatalogsV1(catalogsV1), undefined, {
24
+ version: '1.0',
25
+ outboundListener: (message) => onAgentMessageRef.current?.(message),
26
+ errorHandler: (error) => onAgentMessageRef.current?.(error),
27
+ });
28
+ });
29
+ useEffect(() => {
30
+ if (typeof document !== 'undefined' && document.adoptedStyleSheets) {
31
+ injectBasicCatalogStyles();
32
+ }
33
+ }, []);
34
+ return (_jsx(SurfaceGroupProvider, { version: "v1.0", processor: processor, ...rest, children: children }));
35
+ }
@@ -0,0 +1,52 @@
1
+ import type { ReactCatalogComponent } from '@a2ui/react';
2
+ import type { Catalog } from '@a2ui/web_core/v1_0';
3
+ /**
4
+ * Full GLChat A2UI v1.0 catalog: the A2UI basic catalog with GLChat overrides
5
+ * and extensions. Use it as the surface default (`createSurface.catalogId`);
6
+ * components need no per-component catalog.
7
+ */
8
+ export declare const GLCHAT_CATALOG_ID_V1 = "https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/v1_0/glchat_standard_catalog_definition.json";
9
+ /**
10
+ * GLChat-only A2UI v1.0 catalog: GLChat overrides and extensions plus the basic
11
+ * functions. Use it alongside the A2UI basic catalog and tag GLChat components
12
+ * with their catalog (see `COMPONENT_CATALOG_ID_KEY`).
13
+ */
14
+ export declare const GLCHAT_EXTENSION_CATALOG_ID_V1 = "https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/v1_0/glchat_extension_catalog_definition.json";
15
+ /** A2UI v1.0 basic catalog ID (`@a2ui/web_core/catalogs/basic/v1`). */
16
+ export declare const A2UI_BASIC_CATALOG_ID_V1: string;
17
+ /**
18
+ * Component key that selects a component's catalog. @a2ui/web_core 0.15 implements
19
+ * the v1.0 draft with bare envelope keys (`catalogId`, `checks`); the later v1.0
20
+ * evolution guide renames them to `@catalogId` / `@checks`. Switch this when the
21
+ * runtime adopts the `@` form.
22
+ */
23
+ export declare const COMPONENT_CATALOG_ID_KEY = "catalogId";
24
+ /** Basic catalog components replaced by GLChat implementations. */
25
+ export declare const GLCHAT_V1_OVERRIDES: readonly ["AudioPlayer", "Button", "ChoicePicker"];
26
+ /** GLChat-only components not present in the basic catalog. */
27
+ export declare const GLCHAT_V1_EXTENSIONS: readonly ["TagInput", "Timeout"];
28
+ /**
29
+ * Builds the full GLChat A2UI v1.0 catalog: every basic component except the
30
+ * overridden ones, GLChat overrides and extensions, and all basic functions.
31
+ */
32
+ export declare function createGlchatCatalogV1(): Catalog<ReactCatalogComponent>;
33
+ /**
34
+ * Builds the GLChat-only A2UI v1.0 catalog: GLChat overrides and extensions plus
35
+ * all basic functions (so it also works as a surface default for checks and
36
+ * `openUrl`). Meant to be used together with the A2UI basic catalog.
37
+ */
38
+ export declare function createGlchatExtensionCatalogV1(): Catalog<ReactCatalogComponent>;
39
+ /**
40
+ * Catalogs the renderer registers to process A2UI v1.0 messages: the A2UI v1.0
41
+ * basic catalog, the full GLChat catalog and the GLChat-only catalog. A v1.0
42
+ * surface may use any of them as its default and mix them per component.
43
+ *
44
+ * `extra` adds custom v1.0 catalogs. A catalog whose ID matches a built-in one
45
+ * replaces it (e.g. the GLChat full catalog extended with custom components).
46
+ *
47
+ * Each catalog gets the unknown-component warning fallback. The basic catalog
48
+ * is a private copy (same ID), so the shared upstream `basicCatalog` instance
49
+ * is never mutated.
50
+ */
51
+ export declare function createGlchatRuntimeCatalogsV1(extra?: Catalog<ReactCatalogComponent>[]): Catalog<ReactCatalogComponent>[];
52
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/v1_0/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAYnD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,sIAA6D,CAAC;AAE/F;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,uIAA8D,CAAC;AAE1G,uEAAuE;AACvE,eAAO,MAAM,wBAAwB,QAAkB,CAAC;AAExD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,cAAc,CAAC;AAEpD,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,oDAAqD,CAAC;AAEtF,+DAA+D;AAC/D,eAAO,MAAM,oBAAoB,kCAAmC,CAAC;AAqBrE;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAetE;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAgB/E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,GAAE,OAAO,CAAC,qBAAqB,CAAC,EAAO,GAC3C,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAelC"}
@@ -0,0 +1,118 @@
1
+ import { basicCatalog } from '@a2ui/web_core/catalogs/basic/v1';
2
+ import { GlchatAudioPlayerComponentV1 } from '../components/a2ui/v1_0/AudioPlayer/AudioPlayer.js';
3
+ import { GlchatButtonComponentV1 } from '../components/a2ui/v1_0/Button/Button.js';
4
+ import { GlchatChoicePickerComponentV1 } from '../components/a2ui/v1_0/ChoicePicker/ChoicePicker.js';
5
+ import { GlchatTagInputComponentV1 } from '../components/a2ui/v1_0/TagInput/TagInput.js';
6
+ import { GlchatTimeoutComponentV1 } from '../components/a2ui/v1_0/Timeout/Timeout.js';
7
+ import { installUnknownComponentFallback } from '../core/unknownComponent.js';
8
+ const JSON_BASE_URL = 'https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/v1_0';
9
+ /**
10
+ * Full GLChat A2UI v1.0 catalog: the A2UI basic catalog with GLChat overrides
11
+ * and extensions. Use it as the surface default (`createSurface.catalogId`);
12
+ * components need no per-component catalog.
13
+ */
14
+ export const GLCHAT_CATALOG_ID_V1 = `${JSON_BASE_URL}/glchat_standard_catalog_definition.json`;
15
+ /**
16
+ * GLChat-only A2UI v1.0 catalog: GLChat overrides and extensions plus the basic
17
+ * functions. Use it alongside the A2UI basic catalog and tag GLChat components
18
+ * with their catalog (see `COMPONENT_CATALOG_ID_KEY`).
19
+ */
20
+ export const GLCHAT_EXTENSION_CATALOG_ID_V1 = `${JSON_BASE_URL}/glchat_extension_catalog_definition.json`;
21
+ /** A2UI v1.0 basic catalog ID (`@a2ui/web_core/catalogs/basic/v1`). */
22
+ export const A2UI_BASIC_CATALOG_ID_V1 = basicCatalog.id;
23
+ /**
24
+ * Component key that selects a component's catalog. @a2ui/web_core 0.15 implements
25
+ * the v1.0 draft with bare envelope keys (`catalogId`, `checks`); the later v1.0
26
+ * evolution guide renames them to `@catalogId` / `@checks`. Switch this when the
27
+ * runtime adopts the `@` form.
28
+ */
29
+ export const COMPONENT_CATALOG_ID_KEY = 'catalogId';
30
+ /** Basic catalog components replaced by GLChat implementations. */
31
+ export const GLCHAT_V1_OVERRIDES = ['AudioPlayer', 'Button', 'ChoicePicker'];
32
+ /** GLChat-only components not present in the basic catalog. */
33
+ export const GLCHAT_V1_EXTENSIONS = ['TagInput', 'Timeout'];
34
+ const GLCHAT_COMPONENTS = [
35
+ GlchatAudioPlayerComponentV1,
36
+ GlchatButtonComponentV1,
37
+ GlchatChoicePickerComponentV1,
38
+ GlchatTagInputComponentV1,
39
+ GlchatTimeoutComponentV1,
40
+ ];
41
+ const GLCHAT_COMPONENT_GUIDELINES = `- Button supports an extra \`destructive\` variant for dangerous or irreversible actions.
42
+ - TagInput adds and removes string tags; bind \`value\` to a string array. \`validationRegexp\` validates each tag before it is added.
43
+ - Timeout counts down to \`targetTimeUtc\` (ISO 8601 UTC string).
44
+ - Modal opens locally when its trigger is clicked. Do NOT use a Button as the Modal trigger; it would also dispatch an action.`;
45
+ /**
46
+ * The basic catalog, typed for React catalogs: its Lit (custom element)
47
+ * components and GLChat's React components share one catalog.
48
+ */
49
+ const basic = basicCatalog;
50
+ /**
51
+ * Builds the full GLChat A2UI v1.0 catalog: every basic component except the
52
+ * overridden ones, GLChat overrides and extensions, and all basic functions.
53
+ */
54
+ export function createGlchatCatalogV1() {
55
+ const overridden = new Set(GLCHAT_V1_OVERRIDES);
56
+ const basicComponents = [...basic.components.keys()].filter((name) => !overridden.has(name));
57
+ return basic.derive({
58
+ catalogId: GLCHAT_CATALOG_ID_V1,
59
+ components: [...basicComponents, ...GLCHAT_COMPONENTS],
60
+ instructions: `${basic.instructions ?? ''}
61
+
62
+ ## GLChat catalog
63
+
64
+ This catalog is the A2UI basic catalog with GLChat overrides (${GLCHAT_V1_OVERRIDES.join(', ')}) and extensions (${GLCHAT_V1_EXTENSIONS.join(', ')}). Use \`${GLCHAT_CATALOG_ID_V1}\` as \`createSurface.catalogId\`; components then need no \`${COMPONENT_CATALOG_ID_KEY}\`.
65
+
66
+ ${GLCHAT_COMPONENT_GUIDELINES}`,
67
+ });
68
+ }
69
+ /**
70
+ * Builds the GLChat-only A2UI v1.0 catalog: GLChat overrides and extensions plus
71
+ * all basic functions (so it also works as a surface default for checks and
72
+ * `openUrl`). Meant to be used together with the A2UI basic catalog.
73
+ */
74
+ export function createGlchatExtensionCatalogV1() {
75
+ return basic.derive({
76
+ catalogId: GLCHAT_EXTENSION_CATALOG_ID_V1,
77
+ components: GLCHAT_COMPONENTS,
78
+ instructions: `GLChat components for A2UI v1.0, used together with the A2UI basic catalog (\`${A2UI_BASIC_CATALOG_ID_V1}\`).
79
+
80
+ ## Choosing the catalog per component
81
+
82
+ - ${GLCHAT_V1_OVERRIDES.join(', ')} also exist in the basic catalog. ALWAYS use this catalog's versions: set \`"${COMPONENT_CATALOG_ID_KEY}": "${GLCHAT_EXTENSION_CATALOG_ID_V1}"\` on every ${GLCHAT_V1_OVERRIDES.join(', ')} component.
83
+ - ${GLCHAT_V1_EXTENSIONS.join(', ')} exist only in this catalog; set the same \`"${COMPONENT_CATALOG_ID_KEY}"\` on them.
84
+ - All other components (Text, Row, Column, TextField, ...) come from the basic catalog. A component without \`${COMPONENT_CATALOG_ID_KEY}\` resolves to \`createSurface.catalogId\`, so use the basic catalog ID there.
85
+
86
+ ## Components
87
+
88
+ ${GLCHAT_COMPONENT_GUIDELINES}`,
89
+ });
90
+ }
91
+ /**
92
+ * Catalogs the renderer registers to process A2UI v1.0 messages: the A2UI v1.0
93
+ * basic catalog, the full GLChat catalog and the GLChat-only catalog. A v1.0
94
+ * surface may use any of them as its default and mix them per component.
95
+ *
96
+ * `extra` adds custom v1.0 catalogs. A catalog whose ID matches a built-in one
97
+ * replaces it (e.g. the GLChat full catalog extended with custom components).
98
+ *
99
+ * Each catalog gets the unknown-component warning fallback. The basic catalog
100
+ * is a private copy (same ID), so the shared upstream `basicCatalog` instance
101
+ * is never mutated.
102
+ */
103
+ export function createGlchatRuntimeCatalogsV1(extra = []) {
104
+ const byId = new Map();
105
+ for (const catalog of [
106
+ basic.derive({ catalogId: basic.id }),
107
+ createGlchatCatalogV1(),
108
+ createGlchatExtensionCatalogV1(),
109
+ ...extra,
110
+ ]) {
111
+ byId.set(catalog.id, catalog);
112
+ }
113
+ const catalogs = [...byId.values()];
114
+ for (const catalog of catalogs) {
115
+ installUnknownComponentFallback(catalog);
116
+ }
117
+ return catalogs;
118
+ }
@@ -0,0 +1,13 @@
1
+ import type { ActionMessage, CallAgentFunctionMessage, RendererErrorMessage, RendererFunctionResponseMessage } from '@a2ui/web_core/v1_0';
2
+ /** v1.0 action (adds optional `userMessage` and `metadata` from v0.9). */
3
+ export type V1ActionPayload = ActionMessage['action'];
4
+ /**
5
+ * A2UI v1.0 messages the renderer emits for the agent (actions go to `onAction`):
6
+ * - function results (`rendererFunctionResponse`)
7
+ * - renderer→agent calls (`callAgentFunction`)
8
+ * - structured processing errors (`error`).
9
+ * Agent replies (`agentFunctionResponse`, `callRendererFunction`) go into `messages`.
10
+ */
11
+ export type A2UIAgentMessage = RendererFunctionResponseMessage | CallAgentFunctionMessage | RendererErrorMessage;
12
+ export type AgentMessageHandler = (message: A2UIAgentMessage) => void;
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/v1_0/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,EAChC,MAAM,qBAAqB,CAAC;AAE7B,0EAA0E;AAC1E,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GACxB,+BAA+B,GAC/B,wBAAwB,GACxB,oBAAoB,CAAC;AACzB,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
package/json/README.md CHANGED
@@ -1,43 +1,40 @@
1
1
  # JSON reference files
2
2
 
3
- This folder contains JSON schema and sample payload files for the GLChat A2UI React renderer, split by schema version under `v0_8/` and `v0_9/`.
3
+ GLChat catalog definitions for agents, and sample messages, split by A2UI version. **v1.0** is the current version; `v0_9/` and `v0_8/` are [legacy](#legacy-versions).
4
4
 
5
- ---
5
+ All files are generated by `npm run generate:json`, which also validates the samples against `@a2ui/web_core`.
6
6
 
7
- ## v0.9 files (`v0_9/`)
7
+ ## v1.0 (`v1_0/`)
8
8
 
9
- ### `v0_9/glchat_standard_catalog_definition.json`
9
+ A2UI v1.0 lets one surface mix catalogs: a component uses its own `catalogId` when set, otherwise the surface default (`createSurface.catalogId`). GLChat publishes two v1.0 catalogs, so agents can choose how to integrate:
10
10
 
11
- The GLChat extended A2UI **v0.9** unified catalog.
11
+ | File | Contents | How an agent uses it |
12
+ |---|---|---|
13
+ | `glchat_standard_catalog_definition.json` (**full**) | A2UI v1.0 basic catalog with the GLChat components | Set it as `createSurface.catalogId`. No per-component catalog needed. |
14
+ | `glchat_extension_catalog_definition.json` (**GLChat-only**) | The GLChat components only | Use the [A2UI v1.0 basic catalog](https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json) as `createSurface.catalogId`, and set `"catalogId"` to this catalog on each GLChat component. |
12
15
 
13
- **Catalog ID:** `https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json`
16
+ GLChat components: `Button` (adds a `destructive` variant), `ChoicePicker` and `AudioPlayer` override the basic ones; `TagInput` and `Timeout` are extensions. Both catalogs include all basic functions and their `instructions` for agents.
14
17
 
15
- **Base specification:** [A2UI v0.9 basic catalog](https://github.com/a2ui-project/a2ui/blob/main/specification/v0_9/catalogs/basic/catalog.json)
18
+ **Catalog IDs** (matched exactly, never fetched):
19
+ - Full: `https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/v1_0/glchat_standard_catalog_definition.json`
20
+ - GLChat-only: `https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/v1_0/glchat_extension_catalog_definition.json`
16
21
 
17
- GLChat overrides/extensions: `Button`, `ChoicePicker`, `TagInput`, `Timeout`.
22
+ Notes for agents:
23
+ - With the GLChat-only catalog, a `Button`, `ChoicePicker` or `AudioPlayer` **without** a component `catalogId` silently renders the basic version. Always tag them.
24
+ - Per-component catalog and checks use the keys `catalogId` and `checks`, as implemented by `@a2ui/web_core` 0.15.
25
+ - `Text` only has `variant: body | caption`. Write headings in Markdown (`### Title`).
18
26
 
19
- To regenerate the v0.9 catalog JSON after changing a component schema, run:
27
+ Samples, both building the same surface (`"main"`):
28
+ - `a2ui-sample-messages.json`: full catalog as the surface default.
29
+ - `a2ui-sample-messages-extension.json`: basic catalog plus tagged GLChat components.
20
30
 
21
- ```bash
22
- npm run generate:json
23
- ```
31
+ ## Legacy versions
24
32
 
25
- ### `v0_9/a2ui-sample-messages.json`
33
+ v0.9 and v0.8 are still rendered, but new agents should use v1.0.
26
34
 
27
- A2UI **v0.9** sample messages (`createSurface`, `updateDataModel`, `updateComponents`) for surface `"main"`.
28
-
29
- ---
30
-
31
- ## v0.8 files (`v0_8/`)
32
-
33
- ### `v0_8/glchat_standard_catalog_definition.json`
34
-
35
- The GLChat extended A2UI **v0.8** catalog. Extends the [v0.8 standard catalog](https://a2ui.org/specification/v0_8/standard_catalog_definition.json) with `ButtonAsLink`, `DestructiveButton`, `TagInput`, and `Timeout`.
36
-
37
- **Catalog ID:** `https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/v0_8/glchat_standard_catalog_definition.json`
38
-
39
- When `beginRendering` omits `catalogId`, `Provider` injects this catalog ID automatically.
40
-
41
- ### `v0_8/a2ui-sample-messages.json`
42
-
43
- A2UI **v0.8** sample messages (`beginRendering`, `surfaceUpdate`) for surface `"all-components-demo"`. Demonstrates standard catalog components plus GLChat-styled `Button` and `MultipleChoice` variants.
35
+ | | `v0_9/` | `v0_8/` |
36
+ |---|---|---|
37
+ | Catalog | `glchat_standard_catalog_definition.json`, based on the [v0.9 basic catalog](https://github.com/a2ui-project/a2ui/blob/main/specification/v0_9/catalogs/basic/catalog.json) | `glchat_standard_catalog_definition.json`, based on the [v0.8 standard catalog](https://a2ui.org/specification/v0_8/standard_catalog_definition.json) |
38
+ | GLChat components | `Button`, `ChoicePicker`, `AudioPlayer`, `TagInput`, `Timeout` | `Button`, `ButtonAsLink`, `DestructiveButton`, `MultipleChoice`, `TagInput`, `Timeout` |
39
+ | Catalog ID | `https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json` | `https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/v0_8/glchat_standard_catalog_definition.json` (optional; the renderer ignores it) |
40
+ | Sample | `a2ui-sample-messages.json` (surface `"main"`) | `a2ui-sample-messages.json` (surface `"all-components-demo"`) |
@@ -445,7 +445,7 @@
445
445
  },
446
446
  "child": {
447
447
  "$ref": "common_types.json#/$defs/ComponentId",
448
- "description": "The ID of the single child component to be rendered inside the card. To display multiple elements, you MUST wrap them in a layout component (like Column or Row) and pass that container's ID here. Do NOT pass multiple IDs or a non-existent ID. Do NOT define the child component inline."
448
+ "description": "The ID of the single child component to be rendered inside the card. To display multiple elements, you MUST wrap them in a layout component (like Column or Row) and pass that container's ID here. Do NOT pass multiple IDs or a non-existent ID."
449
449
  }
450
450
  },
451
451
  "required": [
@@ -484,7 +484,7 @@
484
484
  },
485
485
  "child": {
486
486
  "$ref": "common_types.json#/$defs/ComponentId",
487
- "description": "The ID of the child component. Do NOT define the component inline."
487
+ "description": "The ID of the child component."
488
488
  }
489
489
  },
490
490
  "required": [
@@ -520,11 +520,11 @@
520
520
  },
521
521
  "trigger": {
522
522
  "$ref": "common_types.json#/$defs/ComponentId",
523
- "description": "The ID of the component that opens the modal when interacted with (e.g. Text). Do NOT use Button as the trigger — Modal opens locally on click, and Button would also dispatch an action. Do NOT define the component inline."
523
+ "description": "The ID of the component that opens the modal when interacted with (e.g. Text). Do NOT use Button as the trigger — Modal opens locally on click, and Button would also dispatch an action."
524
524
  },
525
525
  "content": {
526
526
  "$ref": "common_types.json#/$defs/ComponentId",
527
- "description": "The ID of the component to be displayed inside the modal. Do NOT define the component inline."
527
+ "description": "The ID of the component to be displayed inside the modal."
528
528
  }
529
529
  },
530
530
  "required": [
@@ -588,7 +588,7 @@
588
588
  },
589
589
  "child": {
590
590
  "$ref": "common_types.json#/$defs/ComponentId",
591
- "description": "The ID of the child component. Use a 'Text' component for a labeled button. Only use an 'Icon' if the requirements explicitly ask for an icon-only button. Do NOT define the child component inline."
591
+ "description": "The ID of the child component. Use a 'Text' component for a labeled button. Only use an 'Icon' if the requirements explicitly ask for an icon-only button."
592
592
  },
593
593
  "variant": {
594
594
  "type": "string",