@seed-ship/mcp-ui-solid 5.1.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +64 -13
  3. package/dist/components/ElicitationForm.cjs +51 -0
  4. package/dist/components/ElicitationForm.cjs.map +1 -0
  5. package/dist/components/ElicitationForm.d.ts +68 -0
  6. package/dist/components/ElicitationForm.d.ts.map +1 -0
  7. package/dist/components/ElicitationForm.js +51 -0
  8. package/dist/components/ElicitationForm.js.map +1 -0
  9. package/dist/components/FeedbackInline.cjs +57 -0
  10. package/dist/components/FeedbackInline.cjs.map +1 -0
  11. package/dist/components/FeedbackInline.d.ts +71 -0
  12. package/dist/components/FeedbackInline.d.ts.map +1 -0
  13. package/dist/components/FeedbackInline.js +57 -0
  14. package/dist/components/FeedbackInline.js.map +1 -0
  15. package/dist/components/index.d.ts +2 -0
  16. package/dist/components/index.d.ts.map +1 -1
  17. package/dist/components.cjs +2 -0
  18. package/dist/components.cjs.map +1 -1
  19. package/dist/components.d.cts +2 -0
  20. package/dist/components.d.ts +2 -0
  21. package/dist/components.js +2 -0
  22. package/dist/components.js.map +1 -1
  23. package/dist/index.cjs +17 -0
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +12 -2
  26. package/dist/index.d.ts +12 -2
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +19 -2
  29. package/dist/index.js.map +1 -1
  30. package/dist/services/chat-bus.cjs +71 -0
  31. package/dist/services/chat-bus.cjs.map +1 -1
  32. package/dist/services/chat-bus.d.ts +31 -1
  33. package/dist/services/chat-bus.d.ts.map +1 -1
  34. package/dist/services/chat-bus.js +71 -0
  35. package/dist/services/chat-bus.js.map +1 -1
  36. package/dist/services/chat-prompt-controller.cjs +83 -0
  37. package/dist/services/chat-prompt-controller.cjs.map +1 -0
  38. package/dist/services/chat-prompt-controller.d.ts +93 -0
  39. package/dist/services/chat-prompt-controller.d.ts.map +1 -0
  40. package/dist/services/chat-prompt-controller.js +83 -0
  41. package/dist/services/chat-prompt-controller.js.map +1 -0
  42. package/dist/stores/scratchpad-store.cjs +105 -77
  43. package/dist/stores/scratchpad-store.cjs.map +1 -1
  44. package/dist/stores/scratchpad-store.d.ts +88 -19
  45. package/dist/stores/scratchpad-store.d.ts.map +1 -1
  46. package/dist/stores/scratchpad-store.js +105 -77
  47. package/dist/stores/scratchpad-store.js.map +1 -1
  48. package/dist/stores/server-capabilities-store.cjs +61 -0
  49. package/dist/stores/server-capabilities-store.cjs.map +1 -0
  50. package/dist/stores/server-capabilities-store.d.ts +172 -0
  51. package/dist/stores/server-capabilities-store.d.ts.map +1 -0
  52. package/dist/stores/server-capabilities-store.js +61 -0
  53. package/dist/stores/server-capabilities-store.js.map +1 -0
  54. package/dist/types/chat-bus.d.ts +39 -0
  55. package/dist/types/chat-bus.d.ts.map +1 -1
  56. package/docs/recipes/elicitation-pseudo-spec-adapter.md +171 -0
  57. package/docs/recipes/feedback-inline-wiring.md +142 -0
  58. package/package.json +1 -1
  59. package/src/components/ElicitationForm.test.tsx +197 -0
  60. package/src/components/ElicitationForm.tsx +126 -0
  61. package/src/components/FeedbackInline.test.tsx +117 -0
  62. package/src/components/FeedbackInline.tsx +143 -0
  63. package/src/components/index.ts +4 -0
  64. package/src/index.ts +39 -1
  65. package/src/services/chat-bus.test.ts +154 -2
  66. package/src/services/chat-bus.ts +115 -0
  67. package/src/services/chat-prompt-controller.test.ts +144 -0
  68. package/src/services/chat-prompt-controller.ts +214 -0
  69. package/src/stores/scratchpad-store.test.tsx +140 -0
  70. package/src/stores/scratchpad-store.tsx +244 -0
  71. package/src/stores/server-capabilities-store.test.tsx +206 -0
  72. package/src/stores/server-capabilities-store.tsx +215 -0
  73. package/src/types/chat-bus.ts +40 -0
  74. package/tsconfig.tsbuildinfo +1 -1
  75. package/src/stores/scratchpad-store.ts +0 -126
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedbackInline.js","sources":["../../src/components/FeedbackInline.tsx"],"sourcesContent":["/**\n * FeedbackInline — per-message inline feedback (thumbs up/down)\n *\n * @experimental\n * @since v5.2.0\n *\n * A small, non-blocking per-message feedback primitive. Sits next to an\n * assistant message, captures a rating, calls back to the consumer for\n * persistence. Best-effort by design — no retry UX, no revision UX.\n *\n * ## When to use vs other feedback primitives\n *\n * - **`FeedbackInline`** (this) → per-message thumb-up/down, non-blocking,\n * many can coexist.\n * - **`ChatPrompt` (type=choice)** → modal, one-at-a-time above the input,\n * used when the agent needs a blocking answer.\n * - **`ScratchpadPanel` feedback section** → structured feedback bound to a\n * scratchpad turn, panel-side.\n *\n * ## Persistence is the consumer's job\n *\n * The component flips to \"submitted\" state *optimistically* on click and\n * calls `onSubmit(rating, context)`. Network failures do not revert the UI —\n * feedback is best-effort. If you need stricter semantics (offline retry,\n * revision, ...) wrap this in your own component.\n *\n * @example\n * ```tsx\n * <FeedbackInline\n * messageHash={msg.hash}\n * context={{ intent: msg.intent, confidenceBand: msg.band }}\n * onSubmit={(rating, ctx) =>\n * fetch('/api/feedback', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ message_hash: msg.hash, rating, ...ctx }),\n * })\n * }\n * />\n * ```\n */\n\nimport { Component, Show, createSignal } from 'solid-js'\n\nexport interface FeedbackInlineContext {\n intent?: string\n confidenceBand?: string\n tags?: string[]\n [key: string]: unknown\n}\n\nexport interface FeedbackInlineProps {\n /** Stable identifier for the message being rated. */\n messageHash?: string\n /**\n * Called on click. Consumer is responsible for persistence (HTTP, store,\n * localStorage). Return value ignored.\n */\n onSubmit: (rating: 'positive' | 'negative', context?: FeedbackInlineContext) => void | Promise<void>\n /** Extra context forwarded to `onSubmit`. */\n context?: FeedbackInlineContext\n /** Ack text shown after positive rating. Default: 'Merci !' */\n positiveAck?: string\n /** Ack text shown after negative rating. Default: \"Noté, on s'améliore\" */\n negativeAck?: string\n /** Extra Tailwind classes on the container. */\n class?: string\n}\n\n/**\n * @experimental\n * Per-message inline feedback (thumbs up/down). Non-blocking.\n */\nexport const FeedbackInline: Component<FeedbackInlineProps> = (props) => {\n const [rating, setRating] = createSignal<'positive' | 'negative' | null>(null)\n\n const handle = (value: 'positive' | 'negative') => {\n if (rating() !== null) return // already submitted, final state\n setRating(value)\n try {\n // Fire-and-forget. If the consumer returns a Promise that rejects,\n // swallow it — feedback is best-effort by design.\n const result = props.onSubmit(value, props.context)\n if (result && typeof (result as Promise<void>).catch === 'function') {\n ;(result as Promise<void>).catch(() => {\n /* non-blocking */\n })\n }\n } catch {\n /* non-blocking */\n }\n }\n\n return (\n <div class={`flex items-center gap-1 ${props.class ?? ''}`.trim()}>\n <Show\n when={rating() === null}\n fallback={\n <span class=\"text-[11px] text-deposium-slate-500\">\n {rating() === 'positive'\n ? (props.positiveAck ?? 'Merci !')\n : (props.negativeAck ?? \"Noté, on s'améliore\")}\n </span>\n }\n >\n <button\n type=\"button\"\n onClick={() => handle('positive')}\n class=\"p-1 rounded hover:bg-green-500/10 text-deposium-slate-500 hover:text-green-500 transition-colors\"\n title=\"Utile\"\n aria-label=\"Mark response as useful\"\n data-feedback-inline-rating=\"positive\"\n >\n <svg class=\"w-3.5 h-3.5\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n d=\"M14 9V5a3 3 0 00-3-3l-4 9v11h11.28a2 2 0 002-1.7l1.38-9a2 2 0 00-2-2.3H14z M3 15v7\"\n />\n </svg>\n </button>\n <button\n type=\"button\"\n onClick={() => handle('negative')}\n class=\"p-1 rounded hover:bg-red-500/10 text-deposium-slate-500 hover:text-red-500 transition-colors\"\n title=\"Pas utile\"\n aria-label=\"Mark response as not useful\"\n data-feedback-inline-rating=\"negative\"\n >\n <svg class=\"w-3.5 h-3.5\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n d=\"M10 15v4a3 3 0 003 3l4-9V2H5.72a2 2 0 00-2 1.7l-1.38 9a2 2 0 002 2.3H10z M21 4v7\"\n />\n </svg>\n </button>\n </Show>\n </div>\n )\n}\n"],"names":["FeedbackInline","props","rating","setRating","createSignal","handle","value","result","onSubmit","context","catch","_el$","_$getNextElement","_tmpl$3","_$insert","_$createComponent","Show","when","fallback","_el$4","_tmpl$4","_c$","_$memo","positiveAck","negativeAck","children","_el$2","_tmpl$","$$click","_$runHydrationEvents","_el$3","_tmpl$2","_$effect","_$className","class","trim","_$delegateEvents"],"mappings":";;;AAyEO,MAAMA,iBAAkDC,CAAAA,UAAU;AACvE,QAAM,CAACC,QAAQC,SAAS,IAAIC,aAA6C,IAAI;AAE7E,QAAMC,SAASA,CAACC,UAAmC;AACjD,QAAIJ,OAAAA,MAAa,KAAM;AACvBC,cAAUG,KAAK;AACf,QAAI;AAGF,YAAMC,SAASN,MAAMO,SAASF,OAAOL,MAAMQ,OAAO;AAClD,UAAIF,UAAU,OAAQA,OAAyBG,UAAU,YAAY;AACnE;AAAEH,eAAyBG,MAAM,MAAM;AAAA,QACrC,CACD;AAAA,MACH;AAAA,IACF,QAAQ;AAAA,IACN;AAAA,EAEJ;AAEA,UAAA,MAAA;AAAA,QAAAC,OAAAC,eAAAC,OAAA;AAAAC,WAAAH,MAAAI,gBAEKC,MAAI;AAAA,MAAA,IACHC,OAAI;AAAA,eAAEf,aAAa;AAAA,MAAI;AAAA,MAAA,IACvBgB,WAAQ;AAAA,gBAAA,MAAA;AAAA,cAAAC,QAAAP,eAAAQ,OAAA;AAAAN,iBAAAK,QAAA,MAAA;AAAA,gBAAAE,MAAAC,KAAA,MAEHpB,OAAAA,MAAa,UAAU;AAAA,mBAAA,MAAvBmB,IAAAA,IACIpB,MAAMsB,eAAe,YACrBtB,MAAMuB,eAAe;AAAA,UAAsB,IAAA;AAAA,iBAAAL;AAAAA,QAAA,GAAA;AAAA,MAAA;AAAA,MAAA,IAAAM,WAAA;AAAA,eAAA,EAAA,MAAA;AAAA,cAAAC,QAAAd,eAAAe,MAAA;AAAAD,gBAAAE,UAMzC,MAAMvB,OAAO,UAAU;AAACwB,6BAAAA;AAAA,iBAAAH;AAAAA,QAAA,GAAA,IAAA,MAAA;AAAA,cAAAI,QAAAlB,eAAAmB,OAAA;AAAAD,gBAAAF,UAiBxB,MAAMvB,OAAO,UAAU;AAACwB,6BAAAA;AAAA,iBAAAC;AAAAA,QAAA,IAAA;AAAA,MAAA;AAAA,IAAA,CAAA,CAAA;AAAAE,WAAA,MAAAC,UAAAtB,MA9B3B,2BAA2BV,MAAMiC,SAAS,EAAE,GAAGC,KAAAA,CAAM,CAAA;AAAA,WAAAxB;AAAAA,EAAA,GAAA;AAgDrE;AAACyB,eAAA,CAAA,OAAA,CAAA;"}
@@ -53,5 +53,7 @@ export { DataPreviewSection } from './DataPreviewSection';
53
53
  export type { DataPreviewSectionProps } from './DataPreviewSection';
54
54
  export { RenderContext, RenderProvider, useRenderContext } from './RenderContext';
55
55
  export type { RenderContextValue, RenderComponentFn } from './RenderContext';
56
+ export { ElicitationForm } from './ElicitationForm';
57
+ export type { ElicitationFormProps } from './ElicitationForm';
56
58
  export { UIResourceRenderer as default } from './UIResourceRenderer';
57
59
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,YAAY,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAErE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AACvE,YAAY,EAAE,8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CAAA;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAGnE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACjF,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAG5E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAG7D,OAAO,EAAE,kBAAkB,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAA"}
@@ -25,6 +25,7 @@ const BriefingDiff = require("./components/BriefingDiff.cjs");
25
25
  const VerifiedText = require("./components/VerifiedText.cjs");
26
26
  const DataPreviewSection = require("./components/DataPreviewSection.cjs");
27
27
  const RenderContext = require("./components/RenderContext.cjs");
28
+ const ElicitationForm = require("./components/ElicitationForm.cjs");
28
29
  exports.UIResourceRenderer = UIResourceRenderer.UIResourceRenderer;
29
30
  exports.default = UIResourceRenderer.UIResourceRenderer;
30
31
  exports.StreamingUIRenderer = StreamingUIRenderer.StreamingUIRenderer;
@@ -57,4 +58,5 @@ exports.DataPreviewSection = DataPreviewSection.DataPreviewSection;
57
58
  exports.RenderContext = RenderContext.RenderContext;
58
59
  exports.RenderProvider = RenderContext.RenderProvider;
59
60
  exports.useRenderContext = RenderContext.useRenderContext;
61
+ exports.ElicitationForm = ElicitationForm.ElicitationForm;
60
62
  //# sourceMappingURL=components.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"components.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -53,5 +53,7 @@ export { DataPreviewSection } from './DataPreviewSection';
53
53
  export type { DataPreviewSectionProps } from './DataPreviewSection';
54
54
  export { RenderContext, RenderProvider, useRenderContext } from './RenderContext';
55
55
  export type { RenderContextValue, RenderComponentFn } from './RenderContext';
56
+ export { ElicitationForm } from './ElicitationForm';
57
+ export type { ElicitationFormProps } from './ElicitationForm';
56
58
  export { UIResourceRenderer as default } from './UIResourceRenderer';
57
59
  //# sourceMappingURL=index.d.ts.map
@@ -53,5 +53,7 @@ export { DataPreviewSection } from './DataPreviewSection';
53
53
  export type { DataPreviewSectionProps } from './DataPreviewSection';
54
54
  export { RenderContext, RenderProvider, useRenderContext } from './RenderContext';
55
55
  export type { RenderContextValue, RenderComponentFn } from './RenderContext';
56
+ export { ElicitationForm } from './ElicitationForm';
57
+ export type { ElicitationFormProps } from './ElicitationForm';
56
58
  export { UIResourceRenderer as default } from './UIResourceRenderer';
57
59
  //# sourceMappingURL=index.d.ts.map
@@ -23,6 +23,7 @@ import { BriefingDiff } from "./components/BriefingDiff.js";
23
23
  import { VerifiedText } from "./components/VerifiedText.js";
24
24
  import { DataPreviewSection } from "./components/DataPreviewSection.js";
25
25
  import { RenderContext, RenderProvider, useRenderContext } from "./components/RenderContext.js";
26
+ import { ElicitationForm } from "./components/ElicitationForm.js";
26
27
  export {
27
28
  ActionGroupRenderer,
28
29
  ActionRenderer,
@@ -35,6 +36,7 @@ export {
35
36
  ChartJSRenderer,
36
37
  CodeBlockRenderer,
37
38
  DataPreviewSection,
39
+ ElicitationForm,
38
40
  FooterRenderer,
39
41
  FormFieldRenderer,
40
42
  FormRenderer,
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"components.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.cjs CHANGED
@@ -22,15 +22,18 @@ const AgentHandoff = require("./components/AgentHandoff.cjs");
22
22
  const BriefingDiff = require("./components/BriefingDiff.cjs");
23
23
  const VerifiedText = require("./components/VerifiedText.cjs");
24
24
  const DataPreviewSection = require("./components/DataPreviewSection.cjs");
25
+ const ElicitationForm = require("./components/ElicitationForm.cjs");
25
26
  const DraggableGridItem = require("./components/DraggableGridItem.cjs");
26
27
  const ResizeHandle = require("./components/ResizeHandle.cjs");
27
28
  const EditableUIResourceRenderer = require("./components/EditableUIResourceRenderer.cjs");
28
29
  const ExpandableWrapper = require("./components/ExpandableWrapper.cjs");
29
30
  const ComponentToolbar = require("./components/ComponentToolbar.cjs");
31
+ const FeedbackInline = require("./components/FeedbackInline.cjs");
30
32
  const useChatBus = require("./hooks/useChatBus.cjs");
31
33
  const ChatPrompt = require("./components/ChatPrompt.cjs");
32
34
  const ScratchpadPanel = require("./components/ScratchpadPanel.cjs");
33
35
  const scratchpadStore = require("./stores/scratchpad-store.cjs");
36
+ const serverCapabilitiesStore = require("./stores/server-capabilities-store.cjs");
34
37
  const GhostText = require("./components/GhostText.cjs");
35
38
  const AutocompleteDropdown = require("./components/AutocompleteDropdown.cjs");
36
39
  const AutocompleteFormField = require("./components/AutocompleteFormField.cjs");
@@ -52,6 +55,7 @@ const validation = require("./services/validation.cjs");
52
55
  const componentRegistry = require("./services/component-registry.cjs");
53
56
  const chatBus = require("./services/chat-bus.cjs");
54
57
  const dataValidator = require("./services/data-validator.cjs");
58
+ const chatPromptController = require("./services/chat-prompt-controller.cjs");
55
59
  const index = require("./testing/index.cjs");
56
60
  exports.UIResourceRenderer = UIResourceRenderer.UIResourceRenderer;
57
61
  exports.StreamingUIRenderer = StreamingUIRenderer.StreamingUIRenderer;
@@ -63,18 +67,28 @@ exports.AgentHandoff = AgentHandoff.AgentHandoff;
63
67
  exports.BriefingDiff = BriefingDiff.BriefingDiff;
64
68
  exports.VerifiedText = VerifiedText.VerifiedText;
65
69
  exports.DataPreviewSection = DataPreviewSection.DataPreviewSection;
70
+ exports.ElicitationForm = ElicitationForm.ElicitationForm;
66
71
  exports.DraggableGridItem = DraggableGridItem.DraggableGridItem;
67
72
  exports.ResizeHandle = ResizeHandle.ResizeHandle;
68
73
  exports.EditableUIResourceRenderer = EditableUIResourceRenderer.EditableUIResourceRenderer;
69
74
  exports.ExpandableWrapper = ExpandableWrapper.ExpandableWrapper;
70
75
  exports.useExpanded = ExpandableWrapper.useExpanded;
71
76
  exports.ComponentToolbar = ComponentToolbar.ComponentToolbar;
77
+ exports.FeedbackInline = FeedbackInline.FeedbackInline;
72
78
  exports.ChatBusProvider = useChatBus.ChatBusProvider;
73
79
  exports.useChatBus = useChatBus.useChatBus;
74
80
  exports.ChatPrompt = ChatPrompt.ChatPrompt;
75
81
  exports.ScratchpadPanel = ScratchpadPanel.ScratchpadPanel;
82
+ exports.ScratchpadStoreContext = scratchpadStore.ScratchpadStoreContext;
83
+ exports.ScratchpadStoreProvider = scratchpadStore.ScratchpadStoreProvider;
84
+ exports.createScratchpadStore = scratchpadStore.createScratchpadStore;
76
85
  exports.dispatchScratchpad = scratchpadStore.dispatchScratchpad;
77
86
  exports.useScratchpadState = scratchpadStore.useScratchpadState;
87
+ exports.ServerCapabilitiesContext = serverCapabilitiesStore.ServerCapabilitiesContext;
88
+ exports.ServerCapabilitiesProvider = serverCapabilitiesStore.ServerCapabilitiesProvider;
89
+ exports.createServerCapabilitiesStore = serverCapabilitiesStore.createServerCapabilitiesStore;
90
+ exports.setServerCapabilities = serverCapabilitiesStore.setServerCapabilities;
91
+ exports.useServerCapabilities = serverCapabilitiesStore.useServerCapabilities;
78
92
  exports.GhostText = GhostText.GhostText;
79
93
  exports.GhostTextInput = GhostText.GhostTextInput;
80
94
  exports.AutocompleteDropdown = AutocompleteDropdown.AutocompleteDropdown;
@@ -113,7 +127,10 @@ exports.clarificationToPromptConfig = chatBus.clarificationToPromptConfig;
113
127
  exports.createChatBus = chatBus.createChatBus;
114
128
  exports.createCommandHandler = chatBus.createCommandHandler;
115
129
  exports.createEventEmitter = chatBus.createEventEmitter;
130
+ exports.elicitationToPromptConfig = chatBus.elicitationToPromptConfig;
116
131
  exports.mergeScratchpadSections = chatBus.mergeScratchpadSections;
117
132
  exports.validateAgainstSource = dataValidator.validateAgainstSource;
133
+ exports.PromptReplacedError = chatPromptController.PromptReplacedError;
134
+ exports.createChatPromptController = chatPromptController.createChatPromptController;
118
135
  exports.createMockChatBus = index.createMockChatBus;
119
136
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.cts CHANGED
@@ -33,10 +33,16 @@ export { ResizeHandle } from './components/ResizeHandle';
33
33
  export { EditableUIResourceRenderer } from './components/EditableUIResourceRenderer';
34
34
  export { ExpandableWrapper, useExpanded } from './components/ExpandableWrapper';
35
35
  export { ComponentToolbar } from './components/ComponentToolbar';
36
+ export { FeedbackInline } from './components/FeedbackInline';
37
+ export type { FeedbackInlineProps, FeedbackInlineContext } from './components/FeedbackInline';
36
38
  export { ChatBusProvider, useChatBus } from './hooks/useChatBus';
37
39
  export { ChatPrompt } from './components/ChatPrompt';
40
+ export { ElicitationForm } from './components/ElicitationForm';
38
41
  export { ScratchpadPanel } from './components/ScratchpadPanel';
39
- export { dispatchScratchpad, useScratchpadState } from './stores/scratchpad-store';
42
+ export { dispatchScratchpad, useScratchpadState, createScratchpadStore, ScratchpadStoreContext, ScratchpadStoreProvider, } from './stores/scratchpad-store';
43
+ export type { ScratchpadStoreHandle } from './stores/scratchpad-store';
44
+ export { setServerCapabilities, useServerCapabilities, createServerCapabilitiesStore, ServerCapabilitiesContext, ServerCapabilitiesProvider, } from './stores/server-capabilities-store';
45
+ export type { ServerCapabilities, ServerInitializeInfo, ServerCapabilitiesStoreHandle, } from './stores/server-capabilities-store';
40
46
  export { VerifiedText } from './components/VerifiedText';
41
47
  export { DataPreviewSection } from './components/DataPreviewSection';
42
48
  export { AgentCard, AgentStatusBadge } from './components/AgentCard';
@@ -53,6 +59,7 @@ export type { EditableUIResourceRendererProps } from './components/EditableUIRes
53
59
  export type { ExpandableWrapperProps } from './components/ExpandableWrapper';
54
60
  export type { ComponentToolbarProps, ToolbarAction, ToolbarIcon } from './components/ComponentToolbar';
55
61
  export type { ChatPromptProps } from './components/ChatPrompt';
62
+ export type { ElicitationFormProps } from './components/ElicitationForm';
56
63
  export type { ScratchpadPanelProps } from './components/ScratchpadPanel';
57
64
  export type { VerifiedTextProps } from './components/VerifiedText';
58
65
  export type { DataPreviewSectionProps } from './components/DataPreviewSection';
@@ -73,7 +80,10 @@ export { createGroqPlugin, createSupabasePlugin, createRestPlugin, } from './plu
73
80
  export type { UIComponent, UILayout, GridPosition, ComponentType, RendererError, ChartComponentParams, TableComponentParams, MetricComponentParams, TextComponentParams, ActionComponentParams, GridComponentParams, FormFieldOption, FormFieldType, FormFieldParams, FormComponentParams, ShowWhenOperator, ShowWhenCondition, ActionRequestBase, ActionResultBase, ActionLifecycleCallbacks, ModalSize, ModalComponentParams, ActionGroupLayout, ActionGroupGap, ActionGroupParams, GalleryImage, ImageGalleryParams, VideoComponentParams, CodeComponentParams, MapMarker, MapComponentParams, MapPopupConfig, MapGeoJSONStyle, MapLayer, MapPMTilesConfig, IframePolicy, ValidationOptions, ResizeConstraints, DragDropConfig, DragEventData, DraggableGridItemProps as DraggableGridItemPropsType, AutocompleteResultType, AutocompleteOption, AutocompleteResult, AutocompleteContext, AutocompletePlugin, GroqPluginConfig, SupabasePluginConfig, DuckDBPluginConfig, RestPluginConfig, FieldAutocompleteConfig, AutocompleteProviderConfig, } from './types';
74
81
  export { validateComponent, validateLayout, validateIframeDomain, getIframeSandbox, DEFAULT_RESOURCE_LIMITS, DEFAULT_IFRAME_DOMAINS, TRUSTED_IFRAME_DOMAINS, ComponentRegistry, createEventEmitter, createCommandHandler, createChatBus, mergeScratchpadSections, validateAgainstSource, } from './services';
75
82
  export { clarificationToPromptConfig } from './services/chat-bus';
83
+ export { elicitationToPromptConfig } from './services/chat-bus';
84
+ export { createChatPromptController, PromptReplacedError, } from './services/chat-prompt-controller';
85
+ export type { ChatPromptController } from './services/chat-prompt-controller';
76
86
  export { createMockChatBus } from './testing';
77
87
  export type { MockChatBusOptions } from './testing';
78
- export type { ChatEventBase, ChatEvents, ChatCommands, ChatBus, ChatEventEmitter, ChatCommandHandler, EventSubscribeOptions, ChatPromptConfig, ChatPromptResponse, ChoicePromptConfig, ChoiceOption, ConfirmPromptConfig, FormPromptConfig, SuggestionItem, AgentContext, BriefingEvent, BriefingSection, ScratchpadState, ScratchpadSection, ScratchpadEvent, StreamDoneMetadata, ChatError, Citation, ToolCallEvent, ClarificationEvent, DataValidation, LLMNumber, HallucinatedNumber, DataValidationOptions, VerifiedTextContent, DataPreviewColumn, DataPreviewContent, MapSectionContent, AgentCardContent, SplitStepperContent, AgentHandoffContent, BriefingDiffContent, } from './types/chat-bus';
88
+ export type { ChatEventBase, ChatEvents, ChatCommands, ChatBus, ChatEventEmitter, ChatCommandHandler, EventSubscribeOptions, ChatPromptConfig, ChatPromptResponse, ChoicePromptConfig, ChoiceOption, ConfirmPromptConfig, FormPromptConfig, SuggestionItem, AgentContext, BriefingEvent, BriefingSection, ScratchpadState, ScratchpadSection, ScratchpadEvent, StreamDoneMetadata, ChatError, Citation, ToolCallEvent, ClarificationEvent, ElicitationEvent, ElicitationRequestedSchema, ElicitationPropertySchema, DataValidation, LLMNumber, HallucinatedNumber, DataValidationOptions, VerifiedTextContent, DataPreviewColumn, DataPreviewContent, MapSectionContent, AgentCardContent, SplitStepperContent, AgentHandoffContent, BriefingDiffContent, } from './types/chat-bus';
79
89
  //# sourceMappingURL=index.d.ts.map
package/dist/index.d.ts CHANGED
@@ -33,10 +33,16 @@ export { ResizeHandle } from './components/ResizeHandle';
33
33
  export { EditableUIResourceRenderer } from './components/EditableUIResourceRenderer';
34
34
  export { ExpandableWrapper, useExpanded } from './components/ExpandableWrapper';
35
35
  export { ComponentToolbar } from './components/ComponentToolbar';
36
+ export { FeedbackInline } from './components/FeedbackInline';
37
+ export type { FeedbackInlineProps, FeedbackInlineContext } from './components/FeedbackInline';
36
38
  export { ChatBusProvider, useChatBus } from './hooks/useChatBus';
37
39
  export { ChatPrompt } from './components/ChatPrompt';
40
+ export { ElicitationForm } from './components/ElicitationForm';
38
41
  export { ScratchpadPanel } from './components/ScratchpadPanel';
39
- export { dispatchScratchpad, useScratchpadState } from './stores/scratchpad-store';
42
+ export { dispatchScratchpad, useScratchpadState, createScratchpadStore, ScratchpadStoreContext, ScratchpadStoreProvider, } from './stores/scratchpad-store';
43
+ export type { ScratchpadStoreHandle } from './stores/scratchpad-store';
44
+ export { setServerCapabilities, useServerCapabilities, createServerCapabilitiesStore, ServerCapabilitiesContext, ServerCapabilitiesProvider, } from './stores/server-capabilities-store';
45
+ export type { ServerCapabilities, ServerInitializeInfo, ServerCapabilitiesStoreHandle, } from './stores/server-capabilities-store';
40
46
  export { VerifiedText } from './components/VerifiedText';
41
47
  export { DataPreviewSection } from './components/DataPreviewSection';
42
48
  export { AgentCard, AgentStatusBadge } from './components/AgentCard';
@@ -53,6 +59,7 @@ export type { EditableUIResourceRendererProps } from './components/EditableUIRes
53
59
  export type { ExpandableWrapperProps } from './components/ExpandableWrapper';
54
60
  export type { ComponentToolbarProps, ToolbarAction, ToolbarIcon } from './components/ComponentToolbar';
55
61
  export type { ChatPromptProps } from './components/ChatPrompt';
62
+ export type { ElicitationFormProps } from './components/ElicitationForm';
56
63
  export type { ScratchpadPanelProps } from './components/ScratchpadPanel';
57
64
  export type { VerifiedTextProps } from './components/VerifiedText';
58
65
  export type { DataPreviewSectionProps } from './components/DataPreviewSection';
@@ -73,7 +80,10 @@ export { createGroqPlugin, createSupabasePlugin, createRestPlugin, } from './plu
73
80
  export type { UIComponent, UILayout, GridPosition, ComponentType, RendererError, ChartComponentParams, TableComponentParams, MetricComponentParams, TextComponentParams, ActionComponentParams, GridComponentParams, FormFieldOption, FormFieldType, FormFieldParams, FormComponentParams, ShowWhenOperator, ShowWhenCondition, ActionRequestBase, ActionResultBase, ActionLifecycleCallbacks, ModalSize, ModalComponentParams, ActionGroupLayout, ActionGroupGap, ActionGroupParams, GalleryImage, ImageGalleryParams, VideoComponentParams, CodeComponentParams, MapMarker, MapComponentParams, MapPopupConfig, MapGeoJSONStyle, MapLayer, MapPMTilesConfig, IframePolicy, ValidationOptions, ResizeConstraints, DragDropConfig, DragEventData, DraggableGridItemProps as DraggableGridItemPropsType, AutocompleteResultType, AutocompleteOption, AutocompleteResult, AutocompleteContext, AutocompletePlugin, GroqPluginConfig, SupabasePluginConfig, DuckDBPluginConfig, RestPluginConfig, FieldAutocompleteConfig, AutocompleteProviderConfig, } from './types';
74
81
  export { validateComponent, validateLayout, validateIframeDomain, getIframeSandbox, DEFAULT_RESOURCE_LIMITS, DEFAULT_IFRAME_DOMAINS, TRUSTED_IFRAME_DOMAINS, ComponentRegistry, createEventEmitter, createCommandHandler, createChatBus, mergeScratchpadSections, validateAgainstSource, } from './services';
75
82
  export { clarificationToPromptConfig } from './services/chat-bus';
83
+ export { elicitationToPromptConfig } from './services/chat-bus';
84
+ export { createChatPromptController, PromptReplacedError, } from './services/chat-prompt-controller';
85
+ export type { ChatPromptController } from './services/chat-prompt-controller';
76
86
  export { createMockChatBus } from './testing';
77
87
  export type { MockChatBusOptions } from './testing';
78
- export type { ChatEventBase, ChatEvents, ChatCommands, ChatBus, ChatEventEmitter, ChatCommandHandler, EventSubscribeOptions, ChatPromptConfig, ChatPromptResponse, ChoicePromptConfig, ChoiceOption, ConfirmPromptConfig, FormPromptConfig, SuggestionItem, AgentContext, BriefingEvent, BriefingSection, ScratchpadState, ScratchpadSection, ScratchpadEvent, StreamDoneMetadata, ChatError, Citation, ToolCallEvent, ClarificationEvent, DataValidation, LLMNumber, HallucinatedNumber, DataValidationOptions, VerifiedTextContent, DataPreviewColumn, DataPreviewContent, MapSectionContent, AgentCardContent, SplitStepperContent, AgentHandoffContent, BriefingDiffContent, } from './types/chat-bus';
88
+ export type { ChatEventBase, ChatEvents, ChatCommands, ChatBus, ChatEventEmitter, ChatCommandHandler, EventSubscribeOptions, ChatPromptConfig, ChatPromptResponse, ChoicePromptConfig, ChoiceOption, ConfirmPromptConfig, FormPromptConfig, SuggestionItem, AgentContext, BriefingEvent, BriefingSection, ScratchpadState, ScratchpadSection, ScratchpadEvent, StreamDoneMetadata, ChatError, Citation, ToolCallEvent, ClarificationEvent, ElicitationEvent, ElicitationRequestedSchema, ElicitationPropertySchema, DataValidation, LLMNumber, HallucinatedNumber, DataValidationOptions, VerifiedTextContent, DataPreviewColumn, DataPreviewContent, MapSectionContent, AgentCardContent, SplitStepperContent, AgentHandoffContent, BriefingDiffContent, } from './types/chat-bus';
79
89
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAA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AAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAA;AAGjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAGnD,YAAY,EACV,aAAa,EACb,UAAU,EACV,YAAY,EACZ,OAAO,EACP,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,aAAa,EACb,kBAAkB,EAElB,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAEjB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAGjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAA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ACf,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,0BAA0B,EAC1B,yBAAyB,EAEzB,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAEjB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAkB,CAAA"}
package/dist/index.js CHANGED
@@ -20,15 +20,18 @@ import { AgentHandoff } from "./components/AgentHandoff.js";
20
20
  import { BriefingDiff } from "./components/BriefingDiff.js";
21
21
  import { VerifiedText } from "./components/VerifiedText.js";
22
22
  import { DataPreviewSection } from "./components/DataPreviewSection.js";
23
+ import { ElicitationForm } from "./components/ElicitationForm.js";
23
24
  import { DraggableGridItem } from "./components/DraggableGridItem.js";
24
25
  import { ResizeHandle } from "./components/ResizeHandle.js";
25
26
  import { EditableUIResourceRenderer } from "./components/EditableUIResourceRenderer.js";
26
27
  import { ExpandableWrapper, useExpanded } from "./components/ExpandableWrapper.js";
27
28
  import { ComponentToolbar } from "./components/ComponentToolbar.js";
29
+ import { FeedbackInline } from "./components/FeedbackInline.js";
28
30
  import { ChatBusProvider, useChatBus } from "./hooks/useChatBus.js";
29
31
  import { ChatPrompt } from "./components/ChatPrompt.js";
30
32
  import { ScratchpadPanel } from "./components/ScratchpadPanel.js";
31
- import { dispatchScratchpad, useScratchpadState } from "./stores/scratchpad-store.js";
33
+ import { ScratchpadStoreContext, ScratchpadStoreProvider, createScratchpadStore, dispatchScratchpad, useScratchpadState } from "./stores/scratchpad-store.js";
34
+ import { ServerCapabilitiesContext, ServerCapabilitiesProvider, createServerCapabilitiesStore, setServerCapabilities, useServerCapabilities } from "./stores/server-capabilities-store.js";
32
35
  import { GhostText, GhostTextInput } from "./components/GhostText.js";
33
36
  import { AutocompleteDropdown } from "./components/AutocompleteDropdown.js";
34
37
  import { AutocompleteFormField } from "./components/AutocompleteFormField.js";
@@ -48,8 +51,9 @@ import { createSupabasePlugin } from "./plugins/supabase.js";
48
51
  import { createRestPlugin } from "./plugins/rest.js";
49
52
  import { DEFAULT_IFRAME_DOMAINS, DEFAULT_RESOURCE_LIMITS, TRUSTED_IFRAME_DOMAINS, getIframeSandbox, validateComponent, validateIframeDomain, validateLayout } from "./services/validation.js";
50
53
  import { ComponentRegistry } from "./services/component-registry.js";
51
- import { clarificationToPromptConfig, createChatBus, createCommandHandler, createEventEmitter, mergeScratchpadSections } from "./services/chat-bus.js";
54
+ import { clarificationToPromptConfig, createChatBus, createCommandHandler, createEventEmitter, elicitationToPromptConfig, mergeScratchpadSections } from "./services/chat-bus.js";
52
55
  import { validateAgainstSource } from "./services/data-validator.js";
56
+ import { PromptReplacedError, createChatPromptController } from "./services/chat-prompt-controller.js";
53
57
  import { createMockChatBus } from "./testing/index.js";
54
58
  export {
55
59
  AgentCard,
@@ -68,14 +72,21 @@ export {
68
72
  DataPreviewSection,
69
73
  DraggableGridItem,
70
74
  EditableUIResourceRenderer,
75
+ ElicitationForm,
71
76
  ExpandableWrapper,
77
+ FeedbackInline,
72
78
  GenerativeUIErrorBoundary,
73
79
  GhostText,
74
80
  GhostTextInput,
75
81
  MCPActionContext,
76
82
  MCPActionProvider,
83
+ PromptReplacedError,
77
84
  ResizeHandle,
78
85
  ScratchpadPanel,
86
+ ScratchpadStoreContext,
87
+ ScratchpadStoreProvider,
88
+ ServerCapabilitiesContext,
89
+ ServerCapabilitiesProvider,
79
90
  SplitStepper,
80
91
  StreamingUIRenderer,
81
92
  TRUSTED_IFRAME_DOMAINS,
@@ -83,16 +94,21 @@ export {
83
94
  VerifiedText,
84
95
  clarificationToPromptConfig,
85
96
  createChatBus,
97
+ createChatPromptController,
86
98
  createCommandHandler,
87
99
  createEventEmitter,
88
100
  createGroqPlugin,
89
101
  createMockChatBus,
90
102
  createRestPlugin,
103
+ createScratchpadStore,
104
+ createServerCapabilitiesStore,
91
105
  createSupabasePlugin,
92
106
  dispatchScratchpad,
107
+ elicitationToPromptConfig,
93
108
  evaluateCondition,
94
109
  getIframeSandbox,
95
110
  mergeScratchpadSections,
111
+ setServerCapabilities,
96
112
  useAction,
97
113
  useAutocomplete,
98
114
  useAutocompleteContext,
@@ -109,6 +125,7 @@ export {
109
125
  useModal,
110
126
  useResize,
111
127
  useScratchpadState,
128
+ useServerCapabilities,
112
129
  useStreamingUI,
113
130
  useToolAction,
114
131
  validateAgainstSource,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -134,6 +134,76 @@ function mergeScratchpadSections(existing, incoming, mode = "replace") {
134
134
  return incoming;
135
135
  }
136
136
  }
137
+ function elicitationToPromptConfig(event) {
138
+ const propEntries = Object.entries(event.requestedSchema.properties);
139
+ if (propEntries.length === 1 && propEntries[0][1].type === "boolean") {
140
+ return {
141
+ type: "confirm",
142
+ title: event.message,
143
+ config: {
144
+ message: propEntries[0][1].description
145
+ }
146
+ };
147
+ }
148
+ if (propEntries.length === 1) {
149
+ const [, schema] = propEntries[0];
150
+ if (schema.enum && schema.enum.length > 0 && schema.enum.length <= 4) {
151
+ return {
152
+ type: "choice",
153
+ title: event.message,
154
+ config: {
155
+ options: schema.enum.map((val, idx) => {
156
+ var _a;
157
+ return {
158
+ value: String(val),
159
+ label: ((_a = schema.enumNames) == null ? void 0 : _a[idx]) ?? String(val)
160
+ };
161
+ }),
162
+ layout: "vertical"
163
+ }
164
+ };
165
+ }
166
+ }
167
+ const required = new Set(event.requestedSchema.required ?? []);
168
+ const fields = propEntries.map(([name, schema]) => ({
169
+ name,
170
+ label: schema.title ?? name,
171
+ ...schemaToFieldType(schema),
172
+ required: required.has(name),
173
+ helpText: schema.description,
174
+ ...schema.default !== void 0 ? { placeholder: String(schema.default) } : {}
175
+ }));
176
+ return {
177
+ type: "form",
178
+ title: event.message,
179
+ config: { fields }
180
+ };
181
+ }
182
+ function schemaToFieldType(schema) {
183
+ if (schema.enum && schema.enum.length > 0) {
184
+ return {
185
+ type: "select",
186
+ options: schema.enum.map((val, idx) => {
187
+ var _a;
188
+ return {
189
+ label: ((_a = schema.enumNames) == null ? void 0 : _a[idx]) ?? String(val),
190
+ value: String(val)
191
+ };
192
+ })
193
+ };
194
+ }
195
+ if (schema.type === "boolean") return { type: "checkbox" };
196
+ if (schema.type === "number" || schema.type === "integer") return { type: "number" };
197
+ if (schema.type === "string") {
198
+ if (schema.format === "email") return { type: "email" };
199
+ if (schema.format === "date" || schema.format === "date-time") return { type: "date" };
200
+ return { type: "text" };
201
+ }
202
+ console.warn(
203
+ `[MCP-UI] elicitationToPromptConfig: unsupported schema type "${schema.type}", falling back to text.`
204
+ );
205
+ return { type: "text" };
206
+ }
137
207
  function clarificationToPromptConfig(event) {
138
208
  return {
139
209
  type: "choice",
@@ -160,5 +230,6 @@ exports.clarificationToPromptConfig = clarificationToPromptConfig;
160
230
  exports.createChatBus = createChatBus;
161
231
  exports.createCommandHandler = createCommandHandler;
162
232
  exports.createEventEmitter = createEventEmitter;
233
+ exports.elicitationToPromptConfig = elicitationToPromptConfig;
163
234
  exports.mergeScratchpadSections = mergeScratchpadSections;
164
235
  //# sourceMappingURL=chat-bus.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"chat-bus.cjs","sources":["../../src/services/chat-bus.ts"],"sourcesContent":["/**\n * Chat Bus — Event Emitter + Command Handler\n * v2.4.0: Core primitives for the chat event/command bus\n *\n * @experimental — This API may change without major bump until v2.5.0.\n */\n\nimport type {\n ChatEvents,\n ChatCommands,\n ChatEventEmitter,\n ChatCommandHandler,\n ChatBus,\n EventSubscribeOptions,\n ScratchpadSection,\n ClarificationEvent,\n ChatPromptConfig,\n} from '../types/chat-bus'\n\n// ─── Event Emitter ───────────────────────────────────────────\n\ninterface Listener<F extends (...args: any[]) => any> {\n handler: F\n options?: EventSubscribeOptions\n throttledHandler?: F\n}\n\n/**\n * Create a typed event emitter with throttle and streamKey filtering support.\n *\n * @experimental\n *\n * @example\n * const emitter = createEventEmitter<ChatEvents>()\n * const unsub = emitter.on('onToken', (event) => console.log(event.token), { throttle: 100 })\n * emitter.emit('onToken', { streamKey: 'abc', token: 'hello' })\n * unsub()\n */\nexport function createEventEmitter(): ChatEventEmitter {\n const listeners = new Map<string, Set<Listener<any>>>()\n\n interface ThrottledFn<F> {\n fn: F\n cancel: () => void\n }\n\n function createThrottled<F extends (...args: any[]) => void>(fn: F, ms: number): ThrottledFn<F> {\n let lastCall = 0\n let timer: ReturnType<typeof setTimeout> | null = null\n let lastArgs: any[] | null = null\n let cancelled = false\n\n const throttled = ((...args: any[]) => {\n if (cancelled) return\n lastArgs = args\n const now = Date.now()\n const remaining = ms - (now - lastCall)\n\n if (remaining <= 0) {\n if (timer) { clearTimeout(timer); timer = null }\n lastCall = now\n fn(...args)\n } else if (!timer) {\n timer = setTimeout(() => {\n lastCall = Date.now()\n timer = null\n if (lastArgs && !cancelled) {\n try { fn(...lastArgs) } catch (err) { console.error('[ChatBus] Error in throttled handler:', err) }\n }\n }, remaining)\n }\n }) as F\n\n return {\n fn: throttled,\n cancel: () => { cancelled = true; if (timer) { clearTimeout(timer); timer = null } },\n }\n }\n\n return {\n on(event, handler, options) {\n if (!listeners.has(event as string)) {\n listeners.set(event as string, new Set())\n }\n\n const listener: Listener<typeof handler> = { handler, options }\n\n // Apply throttle if requested\n let throttleHandle: ThrottledFn<typeof handler> | null = null\n if (options?.throttle && options.throttle > 0) {\n throttleHandle = createThrottled(handler, options.throttle)\n listener.throttledHandler = throttleHandle.fn\n }\n\n listeners.get(event as string)!.add(listener)\n\n // Return unsubscribe function — cancels pending throttle timers\n return () => {\n throttleHandle?.cancel()\n listeners.get(event as string)?.delete(listener)\n }\n },\n\n emit(event, ...args) {\n const set = listeners.get(event as string)\n if (!set) return\n\n for (const listener of set) {\n // StreamKey filtering: skip if listener wants a specific streamKey\n // For most events args[0] has streamKey; for onCustomEvent args[1] has it\n if (listener.options?.streamKey) {\n let streamKeyArg: unknown\n for (const arg of args) {\n if (arg && typeof arg === 'object' && 'streamKey' in (arg as any)) {\n streamKeyArg = (arg as any).streamKey\n break\n }\n }\n if (streamKeyArg !== undefined && streamKeyArg !== listener.options.streamKey) continue\n }\n\n const fn = listener.throttledHandler || listener.handler\n try {\n fn(...args)\n } catch (err) {\n console.error(`[ChatBus] Error in ${event as string} handler:`, err)\n }\n }\n },\n\n clear() {\n listeners.clear()\n },\n } as ChatEventEmitter\n}\n\n// ─── Command Handler ─────────────────────────────────────────\n\n/**\n * Create a typed command handler. The host app registers handlers,\n * agents execute commands.\n *\n * @experimental\n *\n * @example\n * const commands = createCommandHandler<ChatCommands>()\n * commands.handle('injectPrompt', (text) => setInputValue(text))\n * commands.exec('injectPrompt', 'Hello world')\n */\nexport function createCommandHandler(): ChatCommandHandler {\n const handlers = new Map<string, (...args: any[]) => any>()\n\n return {\n handle(command, handler) {\n handlers.set(command as string, handler)\n },\n\n exec(command, ...args) {\n const handler = handlers.get(command as string)\n if (!handler) {\n console.warn(`[ChatBus] No handler registered for command: ${command as string}`)\n return undefined as any\n }\n return handler(...args)\n },\n } as ChatCommandHandler\n}\n\n// ─── Chat Bus Factory ────────────────────────────────────────\n\n/**\n * Create a complete ChatBus with events + commands.\n *\n * @experimental\n *\n * @example\n * const bus = createChatBus()\n * bus.events.on('onStreamEnd', (event) => { ... })\n * bus.commands.handle('sendPrompt', (text) => { ... })\n */\nexport function createChatBus(): ChatBus {\n return {\n events: createEventEmitter(),\n commands: createCommandHandler(),\n }\n}\n\n// ─── Scratchpad Section Merge Helper ─────────────────────────\n\n/**\n * Merge sections from a ScratchpadEvent into existing state sections.\n * Handles replace/append/upsert modes.\n *\n * @example\n * const newSections = mergeScratchpadSections(\n * currentState.sections,\n * event.sections,\n * event.sectionMode\n * )\n */\nexport function mergeScratchpadSections(\n existing: ScratchpadSection[],\n incoming: ScratchpadSection[] | undefined,\n mode: 'replace' | 'append' | 'upsert' = 'replace'\n): ScratchpadSection[] {\n if (!incoming) return existing\n\n switch (mode) {\n case 'append':\n return [...existing, ...incoming]\n\n case 'upsert': {\n const result = [...existing]\n for (const section of incoming) {\n const idx = result.findIndex((s) => s.id === section.id)\n if (idx >= 0) {\n result[idx] = section\n } else {\n result.push(section)\n }\n }\n return result\n }\n\n case 'replace':\n default:\n return incoming\n }\n}\n\n// ─── Clarification → Prompt Helper (v4.3.9) ──────────────────\n\n/**\n * Convert a ClarificationEvent into a ChatPromptConfig.\n * Universal bridge for apps receiving clarification events via SSE.\n *\n * Legacy runtime `file_id` (removed from the type in v5.0.0) is still\n * transparently migrated into `metadata.file_id` when present, so payloads\n * from older servers continue to work without upgrade pressure.\n *\n * @experimental\n * @since v4.3.9\n * @example\n * bus.events.on('onClarificationNeeded', ({ clarification }) => {\n * bus.commands.exec('showChatPrompt', clarificationToPromptConfig(clarification))\n * })\n */\nexport function clarificationToPromptConfig(\n event: ClarificationEvent\n): ChatPromptConfig {\n return {\n type: 'choice',\n title: event.question,\n config: {\n options: event.options.map((opt) => {\n const merged: Record<string, unknown> = { ...(opt.metadata ?? {}) }\n // Runtime fallback for legacy payloads that still carry file_id at the top level.\n const legacyFileId = (opt as { file_id?: number }).file_id\n if (legacyFileId !== undefined && merged.file_id === undefined) {\n merged.file_id = legacyFileId\n }\n return {\n value: opt.value,\n label: opt.label,\n // Only include metadata if non-empty (keeps payloads clean)\n ...(Object.keys(merged).length > 0 ? { metadata: merged } : {}),\n }\n }),\n layout: 'vertical',\n },\n }\n}\n"],"names":[],"mappings":";;AAsCO,SAAS,qBAAuC;AACrD,QAAM,gCAAgB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;AAAA,IACN,KAAK;AACH,aAAO,CAAC,GAAG,UAAU,GAAG,QAAQ;AAAA,IAElC,KAAK,UAAU;AACb,YAAM,SAAS,CAAC,GAAG,QAAQ;AAC3B,iBAAW,WAAW,UAAU;AAC9B,cAAM,MAAM,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,QAAQ,EAAE;AACvD,YAAI,OAAO,GAAG;AACZ,iBAAO,GAAG,IAAI;AAAA,QAChB,OAAO;AACL,iBAAO,KAAK,OAAO;AAAA,QACrB;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IAEA,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EAAA;AAEb;AAmBO,SAAS,4BACd,OACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO,MAAM;AAAA,IACb,QAAQ;AAAA,MACN,SAAS,MAAM,QAAQ,IAAI,CAAC,QAAQ;AAClC,cAAM,SAAkC,EAAE,GAAI,IAAI,YAAY,CAAA,EAAC;AAE/D,cAAM,eAAgB,IAA6B;AACnD,YAAI,iBAAiB,UAAa,OAAO,YAAY,QAAW;AAC9D,iBAAO,UAAU;AAAA,QACnB;AACA,eAAO;AAAA,UACL,OAAO,IAAI;AAAA,UACX,OAAO,IAAI;AAAA;AAAA,UAEX,GAAI,OAAO,KAAK,MAAM,EAAE,SAAS,IAAI,EAAE,UAAU,WAAW,CAAA;AAAA,QAAC;AAAA,MAEjE,CAAC;AAAA,MACD,QAAQ;AAAA,IAAA;AAAA,EACV;AAEJ;;;;;;"}
1
+ {"version":3,"file":"chat-bus.cjs","sources":["../../src/services/chat-bus.ts"],"sourcesContent":["/**\n * Chat Bus — Event Emitter + Command Handler\n * v2.4.0: Core primitives for the chat event/command bus\n *\n * @experimental — This API may change without major bump until v2.5.0.\n */\n\nimport type {\n ChatEvents,\n ChatCommands,\n ChatEventEmitter,\n ChatCommandHandler,\n ChatBus,\n EventSubscribeOptions,\n ScratchpadSection,\n ClarificationEvent,\n ElicitationEvent,\n ElicitationPropertySchema,\n ChatPromptConfig,\n FormPromptConfig,\n} from '../types/chat-bus'\n\n// ─── Event Emitter ───────────────────────────────────────────\n\ninterface Listener<F extends (...args: any[]) => any> {\n handler: F\n options?: EventSubscribeOptions\n throttledHandler?: F\n}\n\n/**\n * Create a typed event emitter with throttle and streamKey filtering support.\n *\n * @experimental\n *\n * @example\n * const emitter = createEventEmitter<ChatEvents>()\n * const unsub = emitter.on('onToken', (event) => console.log(event.token), { throttle: 100 })\n * emitter.emit('onToken', { streamKey: 'abc', token: 'hello' })\n * unsub()\n */\nexport function createEventEmitter(): ChatEventEmitter {\n const listeners = new Map<string, Set<Listener<any>>>()\n\n interface ThrottledFn<F> {\n fn: F\n cancel: () => void\n }\n\n function createThrottled<F extends (...args: any[]) => void>(fn: F, ms: number): ThrottledFn<F> {\n let lastCall = 0\n let timer: ReturnType<typeof setTimeout> | null = null\n let lastArgs: any[] | null = null\n let cancelled = false\n\n const throttled = ((...args: any[]) => {\n if (cancelled) return\n lastArgs = args\n const now = Date.now()\n const remaining = ms - (now - lastCall)\n\n if (remaining <= 0) {\n if (timer) { clearTimeout(timer); timer = null }\n lastCall = now\n fn(...args)\n } else if (!timer) {\n timer = setTimeout(() => {\n lastCall = Date.now()\n timer = null\n if (lastArgs && !cancelled) {\n try { fn(...lastArgs) } catch (err) { console.error('[ChatBus] Error in throttled handler:', err) }\n }\n }, remaining)\n }\n }) as F\n\n return {\n fn: throttled,\n cancel: () => { cancelled = true; if (timer) { clearTimeout(timer); timer = null } },\n }\n }\n\n return {\n on(event, handler, options) {\n if (!listeners.has(event as string)) {\n listeners.set(event as string, new Set())\n }\n\n const listener: Listener<typeof handler> = { handler, options }\n\n // Apply throttle if requested\n let throttleHandle: ThrottledFn<typeof handler> | null = null\n if (options?.throttle && options.throttle > 0) {\n throttleHandle = createThrottled(handler, options.throttle)\n listener.throttledHandler = throttleHandle.fn\n }\n\n listeners.get(event as string)!.add(listener)\n\n // Return unsubscribe function — cancels pending throttle timers\n return () => {\n throttleHandle?.cancel()\n listeners.get(event as string)?.delete(listener)\n }\n },\n\n emit(event, ...args) {\n const set = listeners.get(event as string)\n if (!set) return\n\n for (const listener of set) {\n // StreamKey filtering: skip if listener wants a specific streamKey\n // For most events args[0] has streamKey; for onCustomEvent args[1] has it\n if (listener.options?.streamKey) {\n let streamKeyArg: unknown\n for (const arg of args) {\n if (arg && typeof arg === 'object' && 'streamKey' in (arg as any)) {\n streamKeyArg = (arg as any).streamKey\n break\n }\n }\n if (streamKeyArg !== undefined && streamKeyArg !== listener.options.streamKey) continue\n }\n\n const fn = listener.throttledHandler || listener.handler\n try {\n fn(...args)\n } catch (err) {\n console.error(`[ChatBus] Error in ${event as string} handler:`, err)\n }\n }\n },\n\n clear() {\n listeners.clear()\n },\n } as ChatEventEmitter\n}\n\n// ─── Command Handler ─────────────────────────────────────────\n\n/**\n * Create a typed command handler. The host app registers handlers,\n * agents execute commands.\n *\n * @experimental\n *\n * @example\n * const commands = createCommandHandler<ChatCommands>()\n * commands.handle('injectPrompt', (text) => setInputValue(text))\n * commands.exec('injectPrompt', 'Hello world')\n */\nexport function createCommandHandler(): ChatCommandHandler {\n const handlers = new Map<string, (...args: any[]) => any>()\n\n return {\n handle(command, handler) {\n handlers.set(command as string, handler)\n },\n\n exec(command, ...args) {\n const handler = handlers.get(command as string)\n if (!handler) {\n console.warn(`[ChatBus] No handler registered for command: ${command as string}`)\n return undefined as any\n }\n return handler(...args)\n },\n } as ChatCommandHandler\n}\n\n// ─── Chat Bus Factory ────────────────────────────────────────\n\n/**\n * Create a complete ChatBus with events + commands.\n *\n * @experimental\n *\n * @example\n * const bus = createChatBus()\n * bus.events.on('onStreamEnd', (event) => { ... })\n * bus.commands.handle('sendPrompt', (text) => { ... })\n */\nexport function createChatBus(): ChatBus {\n return {\n events: createEventEmitter(),\n commands: createCommandHandler(),\n }\n}\n\n// ─── Scratchpad Section Merge Helper ─────────────────────────\n\n/**\n * Merge sections from a ScratchpadEvent into existing state sections.\n * Handles replace/append/upsert modes.\n *\n * @example\n * const newSections = mergeScratchpadSections(\n * currentState.sections,\n * event.sections,\n * event.sectionMode\n * )\n */\nexport function mergeScratchpadSections(\n existing: ScratchpadSection[],\n incoming: ScratchpadSection[] | undefined,\n mode: 'replace' | 'append' | 'upsert' = 'replace'\n): ScratchpadSection[] {\n if (!incoming) return existing\n\n switch (mode) {\n case 'append':\n return [...existing, ...incoming]\n\n case 'upsert': {\n const result = [...existing]\n for (const section of incoming) {\n const idx = result.findIndex((s) => s.id === section.id)\n if (idx >= 0) {\n result[idx] = section\n } else {\n result.push(section)\n }\n }\n return result\n }\n\n case 'replace':\n default:\n return incoming\n }\n}\n\n// ─── Clarification → Prompt Helper (v4.3.9) ──────────────────\n\n/**\n * Convert a ClarificationEvent into a ChatPromptConfig.\n * Universal bridge for apps receiving clarification events via SSE.\n *\n * Legacy runtime `file_id` (removed from the type in v5.0.0) is still\n * transparently migrated into `metadata.file_id` when present, so payloads\n * from older servers continue to work without upgrade pressure.\n *\n * @experimental\n * @since v4.3.9\n * @example\n * bus.events.on('onClarificationNeeded', ({ clarification }) => {\n * bus.commands.exec('showChatPrompt', clarificationToPromptConfig(clarification))\n * })\n */\n// ─── Elicitation → Prompt Helper (v5.2.0) ───────────────────\n\n/**\n * Convert an MCP `elicitation/create` payload into a `ChatPromptConfig`.\n *\n * Mapping rules :\n * - Single `boolean` property → `type: 'confirm'`\n * - Single property with `enum` of ≤4 values → `type: 'choice'` (one option per enum value)\n * - Anything else → `type: 'form'` with one field per schema property\n *\n * JSON Schema primitive types map to mcp-ui form field types :\n *\n * | JSON Schema | mcp-ui FormFieldType |\n * |---|---|\n * | `type: 'string'` | `'text'` |\n * | `type: 'string', format: 'email'` | `'email'` |\n * | `type: 'string', format: 'date'` or `'date-time'` | `'date'` |\n * | `type: 'string', enum: [...]` | `'select'` |\n * | `type: 'number' \\| 'integer'` | `'number'` |\n * | `type: 'boolean'` | `'checkbox'` |\n *\n * Unknown shapes fall through to plain text with a `helpText` warning.\n *\n * @experimental\n * @since v5.2.0\n *\n * @example\n * bus.events.on('onElicitation', ({ elicitation }) => {\n * bus.commands.exec('showChatPrompt', elicitationToPromptConfig(elicitation))\n * })\n */\nexport function elicitationToPromptConfig(event: ElicitationEvent): ChatPromptConfig {\n const propEntries = Object.entries(event.requestedSchema.properties)\n\n // Shortcut 1 : single boolean → confirm\n if (propEntries.length === 1 && propEntries[0][1].type === 'boolean') {\n return {\n type: 'confirm',\n title: event.message,\n config: {\n message: propEntries[0][1].description,\n },\n }\n }\n\n // Shortcut 2 : single enum property with ≤4 values → choice\n if (propEntries.length === 1) {\n const [, schema] = propEntries[0]\n if (schema.enum && schema.enum.length > 0 && schema.enum.length <= 4) {\n return {\n type: 'choice',\n title: event.message,\n config: {\n options: schema.enum.map((val, idx) => ({\n value: String(val),\n label: schema.enumNames?.[idx] ?? String(val),\n })),\n layout: 'vertical',\n },\n }\n }\n }\n\n // Default : full form\n const required = new Set(event.requestedSchema.required ?? [])\n const fields: FormPromptConfig['fields'] = propEntries.map(([name, schema]) => ({\n name,\n label: schema.title ?? name,\n ...schemaToFieldType(schema),\n required: required.has(name),\n helpText: schema.description,\n ...(schema.default !== undefined ? { placeholder: String(schema.default) } : {}),\n }))\n\n return {\n type: 'form',\n title: event.message,\n config: { fields },\n }\n}\n\nfunction schemaToFieldType(\n schema: ElicitationPropertySchema\n):\n | { type: FormPromptConfig['fields'][number]['type']; options?: Array<{ label: string; value: string }> }\n | { type: FormPromptConfig['fields'][number]['type']; helpText?: string } {\n // Enum → select\n if (schema.enum && schema.enum.length > 0) {\n return {\n type: 'select',\n options: schema.enum.map((val, idx) => ({\n label: schema.enumNames?.[idx] ?? String(val),\n value: String(val),\n })),\n }\n }\n\n if (schema.type === 'boolean') return { type: 'checkbox' }\n if (schema.type === 'number' || schema.type === 'integer') return { type: 'number' }\n if (schema.type === 'string') {\n if (schema.format === 'email') return { type: 'email' }\n if (schema.format === 'date' || schema.format === 'date-time') return { type: 'date' }\n return { type: 'text' }\n }\n\n // Unknown primitive — fall back to text with a warning\n console.warn(\n `[MCP-UI] elicitationToPromptConfig: unsupported schema type \"${(schema as { type?: string }).type}\", falling back to text.`\n )\n return { type: 'text' }\n}\n\nexport function clarificationToPromptConfig(\n event: ClarificationEvent\n): ChatPromptConfig {\n return {\n type: 'choice',\n title: event.question,\n config: {\n options: event.options.map((opt) => {\n const merged: Record<string, unknown> = { ...(opt.metadata ?? {}) }\n // Runtime fallback for legacy payloads that still carry file_id at the top level.\n const legacyFileId = (opt as { file_id?: number }).file_id\n if (legacyFileId !== undefined && merged.file_id === undefined) {\n merged.file_id = legacyFileId\n }\n return {\n value: opt.value,\n label: opt.label,\n // Only include metadata if non-empty (keeps payloads clean)\n ...(Object.keys(merged).length > 0 ? { metadata: merged } : {}),\n }\n }),\n layout: 'vertical',\n },\n }\n}\n"],"names":[],"mappings":";;AAyCO,SAAS,qBAAuC;AACrD,QAAM,gCAAgB,IAAA;AAOtB,WAAS,gBAAoD,IAAO,IAA4B;AAC9F,QAAI,WAAW;AACf,QAAI,QAA8C;AAClD,QAAI,WAAyB;AAC7B,QAAI,YAAY;AAEhB,UAAM,aAAa,IAAI,SAAgB;AACrC,UAAI,UAAW;AACf,iBAAW;AACX,YAAM,MAAM,KAAK,IAAA;AACjB,YAAM,YAAY,MAAM,MAAM;AAE9B,UAAI,aAAa,GAAG;AAClB,YAAI,OAAO;AAAE,uBAAa,KAAK;AAAG,kBAAQ;AAAA,QAAK;AAC/C,mBAAW;AACX,WAAG,GAAG,IAAI;AAAA,MACZ,WAAW,CAAC,OAAO;AACjB,gBAAQ,WAAW,MAAM;AACvB,qBAAW,KAAK,IAAA;AAChB,kBAAQ;AACR,cAAI,YAAY,CAAC,WAAW;AAC1B,gBAAI;AAAE,iBAAG,GAAG,QAAQ;AAAA,YAAE,SAAS,KAAK;AAAE,sBAAQ,MAAM,yCAAyC,GAAG;AAAA,YAAE;AAAA,UACpG;AAAA,QACF,GAAG,SAAS;AAAA,MAC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G;AAAA,QAAA;AAAA,OACjB;AAAA,IAAA;AAAA,EAEN;AAEA,MAAI,OAAO,SAAS,UAAW,QAAO,EAAE,MAAM,WAAA;AAC9C,MAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAW,QAAO,EAAE,MAAM,SAAA;AAC1E,MAAI,OAAO,SAAS,UAAU;AAC5B,QAAI,OAAO,WAAW,QAAS,QAAO,EAAE,MAAM,QAAA;AAC9C,QAAI,OAAO,WAAW,UAAU,OAAO,WAAW,YAAa,QAAO,EAAE,MAAM,OAAA;AAC9E,WAAO,EAAE,MAAM,OAAA;AAAA,EACjB;AAGA,UAAQ;AAAA,IACN,gEAAiE,OAA6B,IAAI;AAAA,EAAA;AAEpG,SAAO,EAAE,MAAM,OAAA;AACjB;AAEO,SAAS,4BACd,OACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO,MAAM;AAAA,IACb,QAAQ;AAAA,MACN,SAAS,MAAM,QAAQ,IAAI,CAAC,QAAQ;AAClC,cAAM,SAAkC,EAAE,GAAI,IAAI,YAAY,CAAA,EAAC;AAE/D,cAAM,eAAgB,IAA6B;AACnD,YAAI,iBAAiB,UAAa,OAAO,YAAY,QAAW;AAC9D,iBAAO,UAAU;AAAA,QACnB;AACA,eAAO;AAAA,UACL,OAAO,IAAI;AAAA,UACX,OAAO,IAAI;AAAA;AAAA,UAEX,GAAI,OAAO,KAAK,MAAM,EAAE,SAAS,IAAI,EAAE,UAAU,WAAW,CAAA;AAAA,QAAC;AAAA,MAEjE,CAAC;AAAA,MACD,QAAQ;AAAA,IAAA;AAAA,EACV;AAEJ;;;;;;;"}
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @experimental — This API may change without major bump until v2.5.0.
6
6
  */
7
- import type { ChatEventEmitter, ChatCommandHandler, ChatBus, ScratchpadSection, ClarificationEvent, ChatPromptConfig } from '../types/chat-bus';
7
+ import type { ChatEventEmitter, ChatCommandHandler, ChatBus, ScratchpadSection, ClarificationEvent, ElicitationEvent, ChatPromptConfig } from '../types/chat-bus';
8
8
  /**
9
9
  * Create a typed event emitter with throttle and streamKey filtering support.
10
10
  *
@@ -67,5 +67,35 @@ export declare function mergeScratchpadSections(existing: ScratchpadSection[], i
67
67
  * bus.commands.exec('showChatPrompt', clarificationToPromptConfig(clarification))
68
68
  * })
69
69
  */
70
+ /**
71
+ * Convert an MCP `elicitation/create` payload into a `ChatPromptConfig`.
72
+ *
73
+ * Mapping rules :
74
+ * - Single `boolean` property → `type: 'confirm'`
75
+ * - Single property with `enum` of ≤4 values → `type: 'choice'` (one option per enum value)
76
+ * - Anything else → `type: 'form'` with one field per schema property
77
+ *
78
+ * JSON Schema primitive types map to mcp-ui form field types :
79
+ *
80
+ * | JSON Schema | mcp-ui FormFieldType |
81
+ * |---|---|
82
+ * | `type: 'string'` | `'text'` |
83
+ * | `type: 'string', format: 'email'` | `'email'` |
84
+ * | `type: 'string', format: 'date'` or `'date-time'` | `'date'` |
85
+ * | `type: 'string', enum: [...]` | `'select'` |
86
+ * | `type: 'number' \| 'integer'` | `'number'` |
87
+ * | `type: 'boolean'` | `'checkbox'` |
88
+ *
89
+ * Unknown shapes fall through to plain text with a `helpText` warning.
90
+ *
91
+ * @experimental
92
+ * @since v5.2.0
93
+ *
94
+ * @example
95
+ * bus.events.on('onElicitation', ({ elicitation }) => {
96
+ * bus.commands.exec('showChatPrompt', elicitationToPromptConfig(elicitation))
97
+ * })
98
+ */
99
+ export declare function elicitationToPromptConfig(event: ElicitationEvent): ChatPromptConfig;
70
100
  export declare function clarificationToPromptConfig(event: ClarificationEvent): ChatPromptConfig;
71
101
  //# sourceMappingURL=chat-bus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chat-bus.d.ts","sourceRoot":"","sources":["../../src/services/chat-bus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAGV,gBAAgB,EAChB,kBAAkB,EAClB,OAAO,EAEP,iBAAiB,EACjB,kBAAkB,EAClB,g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