@seed-ship/mcp-ui-solid 6.25.1 → 7.0.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.
- package/CHANGELOG.md +22 -0
- package/README.md +14 -0
- package/dist/adapters/connector.cjs +3 -3
- package/dist/adapters/connector.cjs.map +1 -1
- package/dist/adapters/connector.d.cts +108 -0
- package/dist/adapters/connector.d.ts +1 -2
- package/dist/adapters/connector.js +3 -3
- package/dist/adapters/connector.js.map +1 -1
- package/dist/adapters/index.d.cts +21 -0
- package/dist/adapters/index.d.ts +6 -7
- package/dist/adapters/macro-run.d.cts +99 -0
- package/dist/adapters/macro-run.d.ts +1 -2
- package/dist/adapters/presentation.d.cts +1 -2
- package/dist/adapters/presentation.d.ts +1 -2
- package/dist/adapters.d.cts +1 -1
- package/dist/adapters.d.ts +1 -1
- package/dist/components/ActionGroupRenderer.d.cts +38 -0
- package/dist/components/ActionGroupRenderer.d.ts +1 -2
- package/dist/components/ActionRenderer.d.cts +9 -0
- package/dist/components/ActionRenderer.d.ts +0 -1
- package/dist/components/AgentCard.d.cts +19 -0
- package/dist/components/AgentCard.d.ts +1 -2
- package/dist/components/AgentHandoff.d.cts +11 -0
- package/dist/components/AgentHandoff.d.ts +1 -2
- package/dist/components/ArtifactRenderer.d.cts +11 -0
- package/dist/components/ArtifactRenderer.d.ts +0 -1
- package/dist/components/AutocompleteDropdown.d.cts +70 -0
- package/dist/components/AutocompleteDropdown.d.ts +1 -2
- package/dist/components/AutocompleteFormField.d.cts +51 -0
- package/dist/components/AutocompleteFormField.d.ts +1 -2
- package/dist/components/BriefingDiff.d.cts +11 -0
- package/dist/components/BriefingDiff.d.ts +1 -2
- package/dist/components/CarouselRenderer.d.cts +12 -0
- package/dist/components/CarouselRenderer.d.ts +1 -2
- package/dist/components/ChartJSRenderer.d.cts +62 -0
- package/dist/components/ChartJSRenderer.d.ts +1 -2
- package/dist/components/ChatPrompt.d.cts +69 -0
- package/dist/components/ChatPrompt.d.ts +1 -2
- package/dist/components/CodeBlockRenderer.d.cts +23 -0
- package/dist/components/CodeBlockRenderer.d.ts +1 -2
- package/dist/components/ComponentToolbar.d.cts +46 -0
- package/dist/components/ComponentToolbar.d.ts +0 -1
- package/dist/components/DataPreviewSection.d.cts +11 -0
- package/dist/components/DataPreviewSection.d.ts +1 -2
- package/dist/components/DegradedFallback.d.cts +43 -0
- package/dist/components/DegradedFallback.d.ts +0 -1
- package/dist/components/DraggableGridItem.d.cts +94 -0
- package/dist/components/DraggableGridItem.d.ts +1 -2
- package/dist/components/EditableLayoutContext.d.cts +4 -0
- package/dist/components/EditableLayoutContext.d.ts +0 -1
- package/dist/components/EditableUIResourceRenderer.d.cts +42 -0
- package/dist/components/EditableUIResourceRenderer.d.ts +1 -2
- package/dist/components/ElicitationForm.d.cts +67 -0
- package/dist/components/ElicitationForm.d.ts +1 -2
- package/dist/components/ExpandableWrapper.d.cts +49 -0
- package/dist/components/ExpandableWrapper.d.ts +0 -1
- package/dist/components/FeedbackInline.d.cts +70 -0
- package/dist/components/FeedbackInline.d.ts +0 -1
- package/dist/components/FooterRenderer.d.cts +15 -0
- package/dist/components/FooterRenderer.d.ts +0 -1
- package/dist/components/FormFieldRenderer.d.cts +19 -0
- package/dist/components/FormFieldRenderer.d.ts +1 -2
- package/dist/components/FormRenderer.d.cts +14 -0
- package/dist/components/FormRenderer.d.ts +1 -2
- package/dist/components/GenerativeUIErrorBoundary.d.cts +58 -0
- package/dist/components/GenerativeUIErrorBoundary.d.ts +1 -2
- package/dist/components/GenerativeUIErrorBoundary.default.d.cts +1 -0
- package/dist/components/GenerativeUIErrorBoundary.default.d.ts +1 -2
- package/dist/components/GhostText.d.cts +112 -0
- package/dist/components/GhostText.d.ts +0 -1
- package/dist/components/GraphRenderer.d.cts +66 -0
- package/dist/components/GraphRenderer.d.ts +1 -2
- package/dist/components/GridRenderer.d.cts +49 -0
- package/dist/components/GridRenderer.d.ts +1 -2
- package/dist/components/IframeFallbackLink.d.cts +22 -0
- package/dist/components/IframeFallbackLink.d.ts +0 -1
- package/dist/components/ImageGalleryRenderer.d.cts +22 -0
- package/dist/components/ImageGalleryRenderer.d.ts +1 -2
- package/dist/components/LightboxOverlay.d.cts +31 -0
- package/dist/components/LightboxOverlay.d.ts +1 -2
- package/dist/components/MapRenderer.d.cts +77 -0
- package/dist/components/MapRenderer.d.ts +1 -2
- package/dist/components/MissingValue.d.cts +26 -0
- package/dist/components/MissingValue.d.ts +0 -1
- package/dist/components/ModalRenderer.d.cts +66 -0
- package/dist/components/ModalRenderer.d.ts +1 -2
- package/dist/components/PortalDropdownMenu.d.cts +55 -0
- package/dist/components/PortalDropdownMenu.d.ts +0 -1
- package/dist/components/PresentationFeedback.d.cts +112 -0
- package/dist/components/PresentationFeedback.d.ts +0 -1
- package/dist/components/RenderContext.d.cts +41 -0
- package/dist/components/RenderContext.d.ts +1 -2
- package/dist/components/ResizeHandle.d.cts +49 -0
- package/dist/components/ResizeHandle.d.ts +0 -1
- package/dist/components/SafeHtml.d.cts +45 -0
- package/dist/components/SafeHtml.d.ts +0 -1
- package/dist/components/ScratchpadPanel.d.cts +34 -0
- package/dist/components/ScratchpadPanel.d.ts +1 -2
- package/dist/components/SplitStepper.d.cts +11 -0
- package/dist/components/SplitStepper.d.ts +1 -2
- package/dist/components/StreamingUIRenderer.d.cts +58 -0
- package/dist/components/StreamingUIRenderer.d.ts +3 -4
- package/dist/components/UIResourceRenderer.d.cts +181 -0
- package/dist/components/UIResourceRenderer.d.ts +3 -4
- package/dist/components/UIResourceRenderer.default.d.cts +1 -0
- package/dist/components/UIResourceRenderer.default.d.ts +1 -2
- package/dist/components/VerifiedText.d.cts +22 -0
- package/dist/components/VerifiedText.d.ts +1 -2
- package/dist/components/VideoRenderer.d.cts +41 -0
- package/dist/components/VideoRenderer.d.ts +1 -2
- package/dist/components/chart-data-table.d.cts +68 -0
- package/dist/components/chart-data-table.d.ts +0 -1
- package/dist/components/chart-missing-plugin.d.cts +128 -0
- package/dist/components/chart-missing-plugin.d.ts +1 -2
- package/dist/components/index.d.cts +62 -0
- package/dist/components/index.d.ts +57 -58
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/context/AutocompleteContext.d.cts +76 -0
- package/dist/context/AutocompleteContext.d.ts +1 -2
- package/dist/context/MCPActionContext.d.cts +169 -0
- package/dist/context/MCPActionContext.d.ts +0 -1
- package/dist/context/MCPUIConfigContext.d.cts +201 -0
- package/dist/context/MCPUIConfigContext.d.ts +1 -2
- package/dist/context/MCPUIMathContext.d.cts +17 -0
- package/dist/context/MCPUIMathContext.d.ts +0 -1
- package/dist/context/MCPUIStringsContext.d.cts +802 -0
- package/dist/context/MCPUIStringsContext.d.ts +1 -2
- package/dist/context/MCPUITelemetryContext.d.cts +35 -0
- package/dist/context/MCPUITelemetryContext.d.ts +1 -2
- package/dist/context/index.d.cts +7 -0
- package/dist/context/index.d.ts +2 -3
- package/dist/hooks/createResponsiveGrid.d.cts +5 -0
- package/dist/hooks/createResponsiveGrid.d.ts +0 -1
- package/dist/hooks/index.d.cts +25 -0
- package/dist/hooks/index.d.ts +20 -21
- package/dist/hooks/useAction.d.cts +164 -0
- package/dist/hooks/useAction.d.ts +2 -3
- package/dist/hooks/useAutocomplete.d.cts +118 -0
- package/dist/hooks/useAutocomplete.d.ts +1 -2
- package/dist/hooks/useChatBus.d.cts +55 -0
- package/dist/hooks/useChatBus.d.ts +1 -2
- package/dist/hooks/useConditionalField.d.cts +34 -0
- package/dist/hooks/useConditionalField.d.ts +1 -2
- package/dist/hooks/useDataValidator.d.cts +41 -0
- package/dist/hooks/useDataValidator.d.ts +1 -2
- package/dist/hooks/useDragDrop.d.cts +99 -0
- package/dist/hooks/useDragDrop.d.ts +1 -2
- package/dist/hooks/useFormPersistence.d.cts +80 -0
- package/dist/hooks/useFormPersistence.d.ts +0 -1
- package/dist/hooks/useModal.d.cts +106 -0
- package/dist/hooks/useModal.d.ts +0 -1
- package/dist/hooks/useResize.d.cts +86 -0
- package/dist/hooks/useResize.d.ts +1 -2
- package/dist/hooks/useStreamingUI.d.cts +117 -0
- package/dist/hooks/useStreamingUI.d.ts +1 -2
- package/dist/hooks.d.cts +1 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/index.d.cts +91 -92
- package/dist/index.d.ts +91 -92
- package/dist/plugins/duckdb.d.cts +1 -2
- package/dist/plugins/duckdb.d.ts +1 -2
- package/dist/plugins/groq.d.cts +12 -0
- package/dist/plugins/groq.d.ts +1 -2
- package/dist/plugins/index.d.cts +9 -0
- package/dist/plugins/index.d.ts +3 -4
- package/dist/plugins/katex.d.cts +1 -2
- package/dist/plugins/katex.d.ts +1 -2
- package/dist/plugins/rest.d.cts +12 -0
- package/dist/plugins/rest.d.ts +1 -2
- package/dist/plugins/supabase.d.cts +12 -0
- package/dist/plugins/supabase.d.ts +1 -2
- package/dist/services/chat-bus.d.cts +100 -0
- package/dist/services/chat-bus.d.ts +1 -2
- package/dist/services/chat-prompt-controller.d.cts +92 -0
- package/dist/services/chat-prompt-controller.d.ts +1 -2
- package/dist/services/component-registry.d.cts +119 -0
- package/dist/services/component-registry.d.ts +1 -2
- package/dist/services/data-validator.d.cts +27 -0
- package/dist/services/data-validator.d.ts +1 -2
- package/dist/services/index.d.cts +9 -0
- package/dist/services/index.d.ts +4 -5
- package/dist/services/telemetry.d.cts +86 -0
- package/dist/services/telemetry.d.ts +1 -2
- package/dist/services/validation.d.cts +169 -0
- package/dist/services/validation.d.ts +1 -2
- package/dist/stores/scratchpad-store.d.cts +109 -0
- package/dist/stores/scratchpad-store.d.ts +1 -2
- package/dist/stores/server-capabilities-store.d.cts +171 -0
- package/dist/stores/server-capabilities-store.d.ts +0 -1
- package/dist/test-setup.d.cts +5 -0
- package/dist/test-setup.d.ts +0 -1
- package/dist/testing/index.d.cts +34 -0
- package/dist/testing/index.d.ts +1 -2
- package/dist/types/chat-bus.d.cts +783 -0
- package/dist/types/chat-bus.d.ts +4 -5
- package/dist/types/index.d.cts +1616 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types-export.d.cts +1 -2
- package/dist/types-export.d.ts +1 -2
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/degraded-projections.d.cts +119 -0
- package/dist/utils/degraded-projections.d.ts +0 -1
- package/dist/utils/duplicate-mount-registry.d.cts +83 -0
- package/dist/utils/duplicate-mount-registry.d.ts +0 -1
- package/dist/utils/escape-html.d.cts +12 -0
- package/dist/utils/escape-html.d.ts +0 -1
- package/dist/utils/format-string.d.cts +25 -0
- package/dist/utils/format-string.d.ts +0 -1
- package/dist/utils/iframe-coep.d.cts +53 -0
- package/dist/utils/iframe-coep.d.ts +1 -2
- package/dist/utils/logger.d.cts +57 -0
- package/dist/utils/logger.d.ts +0 -1
- package/dist/utils/math-markdown.d.cts +15 -0
- package/dist/utils/math-markdown.d.ts +1 -2
- package/dist/utils/missing-value.d.cts +78 -0
- package/dist/utils/missing-value.d.ts +0 -1
- package/dist/utils/pan-zoom.d.cts +234 -0
- package/dist/utils/pan-zoom.d.ts +0 -1
- package/dist/utils/perf.d.cts +18 -0
- package/dist/utils/perf.d.ts +0 -1
- package/dist/utils/safe-url.d.cts +33 -0
- package/dist/utils/safe-url.d.ts +0 -1
- package/dist/utils/sanitize-html.d.cts +142 -0
- package/dist/utils/sanitize-html.d.ts +0 -1
- package/dist/utils/stable-key.d.cts +32 -0
- package/dist/utils/stable-key.d.ts +0 -1
- package/dist/utils/theme.d.cts +10 -0
- package/dist/utils/theme.d.ts +0 -1
- package/dist/validation.d.cts +3 -4
- package/dist/validation.d.ts +3 -4
- package/docs/SECURITY-DEPENDENCIES.md +129 -1
- package/docs/ZOD4-STABLE-MIGRATION-2026-10-26.md +181 -0
- package/package.json +8 -7
- package/src/adapters/connector.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [7.0.0] - Unreleased
|
|
9
|
+
|
|
10
|
+
### Breaking — Zod types, not the Solid engine
|
|
11
|
+
|
|
12
|
+
- Use Zod 4.6.6 and Spec ^6.0.0 while retaining Solid 1 and the existing renderer,
|
|
13
|
+
peer range, engine loading, sanitizer and MCP wire contracts. Adapt connector
|
|
14
|
+
records and preserve application validation codes/paths; native Zod messages
|
|
15
|
+
can change. The paused Solid 2 preview is not resumed.
|
|
16
|
+
- Qualify emitted ESM/CJS declarations with a real packed-consumer TypeScript
|
|
17
|
+
gate and retain the existing resource-size behavior explicitly as a limitation.
|
|
18
|
+
- See `docs/ZOD4-STABLE-MIGRATION-2026-10-26.md` for compatibility and release gates.
|
|
19
|
+
|
|
20
|
+
## Historical tooling follow-up before Zod 4
|
|
21
|
+
|
|
22
|
+
### Security — development tooling only
|
|
23
|
+
|
|
24
|
+
- Pin Vite 6.4.5, Vitest 4.1.12 and `@vitest/ui` 4.1.12; the lockfile also
|
|
25
|
+
resolves `@vitest/mocker` 4.1.12. Keep Solid 1 and the existing compiler plugin.
|
|
26
|
+
- Runtime Zod remains 3.25.76 and its advisory remains open. No public schema,
|
|
27
|
+
runtime dependency or package version change is implied by these tooling fixes.
|
|
28
|
+
See `docs/SECURITY-DEPENDENCIES.md` for current evidence and the migration gate.
|
|
29
|
+
|
|
8
30
|
## [6.25.1] - 2026-10-18
|
|
9
31
|
|
|
10
32
|
### Security
|
package/README.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @seed-ship/mcp-ui-solid
|
|
2
2
|
|
|
3
|
+
## Prepared v7.0.0 — Zod 4, still Solid 1
|
|
4
|
+
|
|
5
|
+
This stable-line candidate uses Zod `4.6.6` and requires Spec `^6.0.0`.
|
|
6
|
+
The Solid peer remains `^1.9.0`; no Solid 2 renderer or visual redesign is
|
|
7
|
+
included. This conservative major marks the Spec 6 dependency/public-type
|
|
8
|
+
compatibility boundary, not a new Solid engine or a direct Solid-local Zod
|
|
9
|
+
schema-class export. JSON acceptance, absent optional fields and application
|
|
10
|
+
validation codes/paths are preserved; native Zod error messages can change.
|
|
11
|
+
|
|
12
|
+
This is not the paused `7.0.0-solid2.0` experiment. Do not consume its branch or
|
|
13
|
+
old archives for this release. See the [migration record](./docs/ZOD4-STABLE-MIGRATION-2026-10-26.md)
|
|
14
|
+
for SemVer, exact gates, resource-limit caveats and the separate publication
|
|
15
|
+
approval. A PR or staged upload is not a public npm release.
|
|
16
|
+
|
|
3
17
|
SolidJS components + chat toolkit for MCP-generated UI. Part of the [MCP UI ecosystem](https://github.com/theseedship/mcp-ui).
|
|
4
18
|
|
|
5
19
|
[](https://www.npmjs.com/package/@seed-ship/mcp-ui-solid)
|
|
@@ -28,9 +28,9 @@ const LenientResultSchema = zod.z.object({
|
|
|
28
28
|
query: zod.z.string(),
|
|
29
29
|
queryHash: zod.z.string().optional(),
|
|
30
30
|
intent: zod.z.string().optional(),
|
|
31
|
-
primary: zod.z.record(zod.z.unknown()),
|
|
32
|
-
supplemental: zod.z.array(zod.z.record(zod.z.unknown())).optional(),
|
|
33
|
-
actions: zod.z.array(zod.z.record(zod.z.unknown())).optional()
|
|
31
|
+
primary: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
32
|
+
supplemental: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown())).optional(),
|
|
33
|
+
actions: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown())).optional()
|
|
34
34
|
});
|
|
35
35
|
const DEFAULT_GRID = { columns: 12, gap: "1rem" };
|
|
36
36
|
function withPosition(component) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.cjs","sources":["../../src/adapters/connector.ts"],"sourcesContent":["/**\n * Connector adapters — `ConnectorDynamicResultV1` → MCP-UI render structures.\n *\n * @since v6.6.0 (D5 / D6 of ROADMAP-opendata-macro-mcpui)\n *\n * ## Opt-in, pure\n *\n * These adapters are published under the dedicated subpath\n * `@seed-ship/mcp-ui-solid/adapters` — they are NEVER imported by the core\n * renderer path, so a consumer that does not emit connector results pays\n * nothing for them.\n *\n * Every adapter here is a **pure function** (D5) : same input → same\n * output, no `fetch`, no `localStorage`, no global state, no clock, no\n * randomness. This is what lets a host re-run an adapter deterministically\n * after presentation feedback (D1) and replay fixtures in tests.\n *\n * ## Unknown schema version — never throw (R2)\n *\n * `connectorResultToUILayout()` never throws on the runtime render path.\n * A payload it cannot read becomes an explicit degraded `UILayout` (a\n * visible notice), never a silent disappearance and never an exception.\n */\n\nimport type { UIComponent, UILayout, GridPosition } from '../types'\nimport {\n ConnectorDynamicResultV1Schema,\n CONNECTOR_DYNAMIC_RESULT_V1,\n type ConnectorAction,\n} from '@seed-ship/mcp-ui-spec'\nimport { z } from 'zod'\nimport { formatMCPUIString } from '../utils/format-string'\n\n// ─────────────────────────────────────────────────────────────\n// connectorActionsToActionGroup\n// ─────────────────────────────────────────────────────────────\n\nexport interface ConnectorActionsToActionGroupOptions {\n /** Component id. Default `'connector-actions'`. */\n id?: string\n /** Optional heading shown above the buttons. */\n title?: string\n /** Button row layout. Default `'horizontal'`. */\n layout?: 'horizontal' | 'vertical' | 'space-between' | 'end' | 'center'\n /** Gap between buttons. Default `'md'`. */\n gap?: 'none' | 'sm' | 'md' | 'lg'\n /** Grid position. Default full-width. */\n position?: GridPosition\n}\n\n/**\n * Wraps a connector's `actions` into an `action-group` `UIComponent`.\n *\n * `ConnectorAction` is the exact `action-group` action shape, so this is a\n * thin, pure envelope — no transformation of the actions themselves.\n */\nexport function connectorActionsToActionGroup(\n actions: ConnectorAction[],\n options: ConnectorActionsToActionGroupOptions = {}\n): UIComponent {\n return {\n id: options.id ?? 'connector-actions',\n type: 'action-group',\n position: options.position ?? { colStart: 1, colSpan: 12 },\n params: {\n actions,\n ...(options.title ? { title: options.title } : {}),\n layout: options.layout ?? 'horizontal',\n gap: options.gap ?? 'md',\n },\n } as UIComponent\n}\n\n// ─────────────────────────────────────────────────────────────\n// connectorResultToUILayout\n// ─────────────────────────────────────────────────────────────\n\n/**\n * The visible wording of the two degraded states (R2).\n *\n * These paragraphs are rendered as `text` components, so unlike the payload\n * they are the LIBRARY's own chrome. They cannot go through\n * `MCPUIStrings` — the adapters are runtime-free and never import\n * `solid-js` — so a host localizes them through\n * `ConnectorResultToUILayoutOptions.messages` instead.\n *\n * Every field is a template resolved with `formatMCPUIString`.\n *\n * @since v6.20.0 — the defaults used to be hardcoded French.\n */\nexport interface ConnectorAdapterMessages {\n /**\n * Unreadable payload (tier 3). Template — `{versionSuffix}` is\n * `degradedVersionSuffix` when the payload carried a string\n * `schemaVersion`, and `''` otherwise.\n */\n degradedNotice: string\n /** Inserted into `degradedNotice`. Template — `{version}`. */\n degradedVersionSuffix: string\n /**\n * Usable envelope, unknown version (tier 2). Template — `{version}` = the\n * version read, `{expected}` = `CONNECTOR_DYNAMIC_RESULT_V1`.\n */\n versionWarning: string\n}\n\n/** English defaults for {@link ConnectorAdapterMessages}. */\nexport const DEFAULT_CONNECTOR_MESSAGES: ConnectorAdapterMessages = {\n degradedNotice:\n '### Result not rendered\\n\\nThe connector result could not be interpreted{versionSuffix}. This explicit state replaces a silent disappearance of the rendering.',\n degradedVersionSuffix: ' (schema: `{version}`)',\n versionWarning:\n '> \\u26A0 Unrecognized connector schema (`{version}`, expected `{expected}`). The rendering below is in degraded mode.',\n}\n\nexport interface ConnectorResultToUILayoutOptions {\n /** Layout id. Default derived from `connectorId` + `queryHash` / `toolName`. */\n id?: string\n /** Heading for the actions `action-group`. */\n actionsTitle?: string\n /**\n * Partial override of the degraded-state wording, merged over\n * {@link DEFAULT_CONNECTOR_MESSAGES}. Hosts that render in another\n * language pass their own paragraphs here.\n *\n * @since v6.20.0\n */\n messages?: Partial<ConnectorAdapterMessages>\n}\n\n/**\n * Lenient mirror of `ConnectorDynamicResultV1Schema` — `schemaVersion`\n * relaxed to any string. Used to tell apart \"unknown version but otherwise\n * a usable envelope\" (→ render with a warning, R2) from \"truly unreadable\"\n * (→ explicit error state).\n */\nconst LenientResultSchema = z.object({\n schemaVersion: z.string(),\n connectorId: z.string().min(1),\n toolName: z.string().min(1),\n query: z.string(),\n queryHash: z.string().optional(),\n intent: z.string().optional(),\n primary: z.record(z.unknown()),\n supplemental: z.array(z.record(z.unknown())).optional(),\n actions: z.array(z.record(z.unknown())).optional(),\n})\n\nconst DEFAULT_GRID = { columns: 12, gap: '1rem' } as const\n\nfunction withPosition(component: UIComponent): UIComponent {\n if (component && component.position) return component\n return { ...component, position: { colStart: 1, colSpan: 12 } }\n}\n\n/** A component is a UILayout when it carries a `components` array. */\nfunction isLayoutShape(value: Record<string, unknown>): boolean {\n return Array.isArray((value as { components?: unknown }).components)\n}\n\nfunction degradedTextComponent(id: string, message: string): UIComponent {\n return {\n id,\n type: 'text',\n position: { colStart: 1, colSpan: 12 },\n params: { markdown: true, content: message },\n } as UIComponent\n}\n\n/**\n * Assembles a `ConnectorDynamicResultV1` into a single `UILayout` :\n * `primary` + `supplemental[]` + (`actions` → an `action-group`).\n *\n * - When `primary` is itself a layout, its components are spread in.\n * - Raw data is never sacrificed — every supplied component is kept.\n * - Pure : no side effects, deterministic.\n *\n * ### Degraded behavior (R2)\n *\n * - Valid v1 payload → normal assembled layout.\n * - Unknown `schemaVersion` but an otherwise-usable envelope → the\n * components are still rendered, prefixed with a visible warning notice.\n * - Unreadable payload → an explicit error `UILayout` (a single `text`\n * notice). Never throws, never returns an empty layout silently.\n *\n * A degraded layout always has an `id` starting with `connector-degraded`,\n * so a host can detect it (e.g. for telemetry) without inspecting content.\n */\nexport function connectorResultToUILayout(\n result: unknown,\n options: ConnectorResultToUILayoutOptions = {}\n): UILayout {\n const strict = ConnectorDynamicResultV1Schema.safeParse(result)\n const messages: ConnectorAdapterMessages = { ...DEFAULT_CONNECTOR_MESSAGES, ...options.messages }\n\n // ── Tier 3 : unreadable ───────────────────────────────────\n if (!strict.success) {\n const lenient = LenientResultSchema.safeParse(result)\n if (!lenient.success) {\n const version =\n result && typeof result === 'object'\n ? (result as { schemaVersion?: unknown }).schemaVersion\n : undefined\n return {\n id: 'connector-degraded',\n components: [\n degradedTextComponent(\n 'connector-degraded-notice',\n formatMCPUIString(messages.degradedNotice, {\n versionSuffix:\n typeof version === 'string'\n ? formatMCPUIString(messages.degradedVersionSuffix, { version })\n : '',\n })\n ),\n ],\n grid: { ...DEFAULT_GRID },\n }\n }\n // ── Tier 2 : usable envelope, unknown version ───────────\n const r = lenient.data\n const components: UIComponent[] = [\n degradedTextComponent(\n 'connector-version-warning',\n formatMCPUIString(messages.versionWarning, {\n version: r.schemaVersion,\n expected: CONNECTOR_DYNAMIC_RESULT_V1,\n })\n ),\n ...collectComponents(r),\n ]\n return {\n id: options.id ?? `connector-degraded-${r.connectorId}`,\n components: components.map(withPosition),\n grid: { ...DEFAULT_GRID },\n }\n }\n\n // ── Tier 1 : valid v1 ─────────────────────────────────────\n const r = strict.data\n const components = collectComponents(r, options.actionsTitle).map(withPosition)\n return {\n id: options.id ?? layoutId(r.connectorId, r.queryHash ?? r.toolName),\n components,\n grid: { ...DEFAULT_GRID },\n }\n}\n\n/**\n * Flattens `primary` + `supplemental` + `actions` into a component list.\n * Shared by the valid and degraded-but-usable paths.\n */\nfunction collectComponents(\n r: {\n primary: Record<string, unknown>\n supplemental?: Record<string, unknown>[]\n actions?: unknown[]\n },\n actionsTitle?: string\n): UIComponent[] {\n const components: UIComponent[] = []\n\n if (isLayoutShape(r.primary)) {\n const inner = (r.primary as { components?: UIComponent[] }).components ?? []\n components.push(...inner)\n } else {\n components.push(r.primary as unknown as UIComponent)\n }\n\n if (r.supplemental) {\n components.push(...(r.supplemental as unknown as UIComponent[]))\n }\n\n if (Array.isArray(r.actions) && r.actions.length > 0) {\n components.push(\n connectorActionsToActionGroup(r.actions as ConnectorAction[], {\n id: 'connector-actions',\n title: actionsTitle,\n })\n )\n }\n\n return components\n}\n\nfunction layoutId(connectorId: string, suffix: string): string {\n return `connector-${connectorId}-${suffix}`\n}\n"],"names":["z","ConnectorDynamicResultV1Schema","formatMCPUIString","r","components","CONNECTOR_DYNAMIC_RESULT_V1"],"mappings":";;;;;AAwDO,SAAS,8BACd,SACA,UAAgD,IACnC;AACb,SAAO;AAAA,IACL,IAAI,QAAQ,MAAM;AAAA,IAClB,MAAM;AAAA,IACN,UAAU,QAAQ,YAAY,EAAE,UAAU,GAAG,SAAS,GAAA;AAAA,IACtD,QAAQ;AAAA,MACN;AAAA,MACA,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAA,IAAU,CAAA;AAAA,MAC/C,QAAQ,QAAQ,UAAU;AAAA,MAC1B,KAAK,QAAQ,OAAO;AAAA,IAAA;AAAA,EACtB;AAEJ;AAoCO,MAAM,6BAAuD;AAAA,EAClE,gBACE;AAAA,EACF,uBAAuB;AAAA,EACvB,gBACE;AACJ;AAuBA,MAAM,sBAAsBA,IAAAA,EAAE,OAAO;AAAA,EACnC,eAAeA,IAAAA,EAAE,OAAA;AAAA,EACjB,aAAaA,IAAAA,EAAE,SAAS,IAAI,CAAC;AAAA,EAC7B,UAAUA,IAAAA,EAAE,SAAS,IAAI,CAAC;AAAA,EAC1B,OAAOA,IAAAA,EAAE,OAAA;AAAA,EACT,WAAWA,IAAAA,EAAE,OAAA,EAAS,SAAA;AAAA,EACtB,QAAQA,IAAAA,EAAE,OAAA,EAAS,SAAA;AAAA,EACnB,SAASA,IAAAA,EAAE,OAAOA,IAAAA,EAAE,SAAS;AAAA,EAC7B,cAAcA,IAAAA,EAAE,MAAMA,MAAE,OAAOA,IAAAA,EAAE,QAAA,CAAS,CAAC,EAAE,SAAA;AAAA,EAC7C,SAASA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,OAAOA,MAAE,SAAS,CAAC,EAAE,SAAA;AAC1C,CAAC;AAED,MAAM,eAAe,EAAE,SAAS,IAAI,KAAK,OAAA;AAEzC,SAAS,aAAa,WAAqC;AACzD,MA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Q,MAAM,sBAAsBA,GAAE,WAAW;AAAA,MACrD,YAAYC,YAAW,IAAI,YAAY;AAAA,MACvC,MAAM,EAAE,GAAG,aAAA;AAAA,IAAa;AAAA,EAE5B;AAGA,QAAM,IAAI,OAAO;AACjB,QAAM,aAAa,kBAAkB,GAAG,QAAQ,YAAY,EAAE,IAAI,YAAY;AAC9E,SAAO;AAAA,IACL,IAAI,QAAQ,MAAM,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ;AAAA,IACnE;AAAA,IACA,MAAM,EAAE,GAAG,aAAA;AAAA,EAAa;AAE5B;AAMA,SAAS,kBACP,GAKA,cACe;AACf,QAAM,aAA4B,CAAA;AAElC,MAAI,cAAc,EAAE,OAAO,GAAG;AAC5B,UAAM,QAAS,EAAE,QAA2C,cAAc,CAAA;AAC1E,eAAW,KAAK,GAAG,KAAK;AAAA,EAC1B,OAAO;AACL,eAAW,KAAK,EAAE,OAAiC;AAAA,EACrD;AAEA,MAAI,EAAE,cAAc;AAClB,eAAW,KAAK,GAAI,EAAE,YAAyC;AAAA,EACjE;AAEA,MAAI,MAAM,QAAQ,EAAE,OAAO,KAAK,EAAE,QAAQ,SAAS,GAAG;AACpD,eAAW;AAAA,MACT,8BAA8B,EAAE,SAA8B;AAAA,QAC5D,IAAI;AAAA,QACJ,OAAO;AAAA,MAAA,CACR;AAAA,IAAA;AAAA,EAEL;AAEA,SAAO;AACT;AAEA,SAAS,SAAS,aAAqB,QAAwB;AAC7D,SAAO,aAAa,WAAW,IAAI,MAAM;AAC3C;;;;"}
|
|
1
|
+
{"version":3,"file":"connector.cjs","sources":["../../src/adapters/connector.ts"],"sourcesContent":["/**\n * Connector adapters — `ConnectorDynamicResultV1` → MCP-UI render structures.\n *\n * @since v6.6.0 (D5 / D6 of ROADMAP-opendata-macro-mcpui)\n *\n * ## Opt-in, pure\n *\n * These adapters are published under the dedicated subpath\n * `@seed-ship/mcp-ui-solid/adapters` — they are NEVER imported by the core\n * renderer path, so a consumer that does not emit connector results pays\n * nothing for them.\n *\n * Every adapter here is a **pure function** (D5) : same input → same\n * output, no `fetch`, no `localStorage`, no global state, no clock, no\n * randomness. This is what lets a host re-run an adapter deterministically\n * after presentation feedback (D1) and replay fixtures in tests.\n *\n * ## Unknown schema version — never throw (R2)\n *\n * `connectorResultToUILayout()` never throws on the runtime render path.\n * A payload it cannot read becomes an explicit degraded `UILayout` (a\n * visible notice), never a silent disappearance and never an exception.\n */\n\nimport type { UIComponent, UILayout, GridPosition } from '../types'\nimport {\n ConnectorDynamicResultV1Schema,\n CONNECTOR_DYNAMIC_RESULT_V1,\n type ConnectorAction,\n} from '@seed-ship/mcp-ui-spec'\nimport { z } from 'zod'\nimport { formatMCPUIString } from '../utils/format-string'\n\n// ─────────────────────────────────────────────────────────────\n// connectorActionsToActionGroup\n// ─────────────────────────────────────────────────────────────\n\nexport interface ConnectorActionsToActionGroupOptions {\n /** Component id. Default `'connector-actions'`. */\n id?: string\n /** Optional heading shown above the buttons. */\n title?: string\n /** Button row layout. Default `'horizontal'`. */\n layout?: 'horizontal' | 'vertical' | 'space-between' | 'end' | 'center'\n /** Gap between buttons. Default `'md'`. */\n gap?: 'none' | 'sm' | 'md' | 'lg'\n /** Grid position. Default full-width. */\n position?: GridPosition\n}\n\n/**\n * Wraps a connector's `actions` into an `action-group` `UIComponent`.\n *\n * `ConnectorAction` is the exact `action-group` action shape, so this is a\n * thin, pure envelope — no transformation of the actions themselves.\n */\nexport function connectorActionsToActionGroup(\n actions: ConnectorAction[],\n options: ConnectorActionsToActionGroupOptions = {}\n): UIComponent {\n return {\n id: options.id ?? 'connector-actions',\n type: 'action-group',\n position: options.position ?? { colStart: 1, colSpan: 12 },\n params: {\n actions,\n ...(options.title ? { title: options.title } : {}),\n layout: options.layout ?? 'horizontal',\n gap: options.gap ?? 'md',\n },\n } as UIComponent\n}\n\n// ─────────────────────────────────────────────────────────────\n// connectorResultToUILayout\n// ─────────────────────────────────────────────────────────────\n\n/**\n * The visible wording of the two degraded states (R2).\n *\n * These paragraphs are rendered as `text` components, so unlike the payload\n * they are the LIBRARY's own chrome. They cannot go through\n * `MCPUIStrings` — the adapters are runtime-free and never import\n * `solid-js` — so a host localizes them through\n * `ConnectorResultToUILayoutOptions.messages` instead.\n *\n * Every field is a template resolved with `formatMCPUIString`.\n *\n * @since v6.20.0 — the defaults used to be hardcoded French.\n */\nexport interface ConnectorAdapterMessages {\n /**\n * Unreadable payload (tier 3). Template — `{versionSuffix}` is\n * `degradedVersionSuffix` when the payload carried a string\n * `schemaVersion`, and `''` otherwise.\n */\n degradedNotice: string\n /** Inserted into `degradedNotice`. Template — `{version}`. */\n degradedVersionSuffix: string\n /**\n * Usable envelope, unknown version (tier 2). Template — `{version}` = the\n * version read, `{expected}` = `CONNECTOR_DYNAMIC_RESULT_V1`.\n */\n versionWarning: string\n}\n\n/** English defaults for {@link ConnectorAdapterMessages}. */\nexport const DEFAULT_CONNECTOR_MESSAGES: ConnectorAdapterMessages = {\n degradedNotice:\n '### Result not rendered\\n\\nThe connector result could not be interpreted{versionSuffix}. This explicit state replaces a silent disappearance of the rendering.',\n degradedVersionSuffix: ' (schema: `{version}`)',\n versionWarning:\n '> \\u26A0 Unrecognized connector schema (`{version}`, expected `{expected}`). The rendering below is in degraded mode.',\n}\n\nexport interface ConnectorResultToUILayoutOptions {\n /** Layout id. Default derived from `connectorId` + `queryHash` / `toolName`. */\n id?: string\n /** Heading for the actions `action-group`. */\n actionsTitle?: string\n /**\n * Partial override of the degraded-state wording, merged over\n * {@link DEFAULT_CONNECTOR_MESSAGES}. Hosts that render in another\n * language pass their own paragraphs here.\n *\n * @since v6.20.0\n */\n messages?: Partial<ConnectorAdapterMessages>\n}\n\n/**\n * Lenient mirror of `ConnectorDynamicResultV1Schema` — `schemaVersion`\n * relaxed to any string. Used to tell apart \"unknown version but otherwise\n * a usable envelope\" (→ render with a warning, R2) from \"truly unreadable\"\n * (→ explicit error state).\n */\nconst LenientResultSchema = z.object({\n schemaVersion: z.string(),\n connectorId: z.string().min(1),\n toolName: z.string().min(1),\n query: z.string(),\n queryHash: z.string().optional(),\n intent: z.string().optional(),\n primary: z.record(z.string(), z.unknown()),\n supplemental: z.array(z.record(z.string(), z.unknown())).optional(),\n actions: z.array(z.record(z.string(), z.unknown())).optional(),\n})\n\nconst DEFAULT_GRID = { columns: 12, gap: '1rem' } as const\n\nfunction withPosition(component: UIComponent): UIComponent {\n if (component && component.position) return component\n return { ...component, position: { colStart: 1, colSpan: 12 } }\n}\n\n/** A component is a UILayout when it carries a `components` array. */\nfunction isLayoutShape(value: Record<string, unknown>): boolean {\n return Array.isArray((value as { components?: unknown }).components)\n}\n\nfunction degradedTextComponent(id: string, message: string): UIComponent {\n return {\n id,\n type: 'text',\n position: { colStart: 1, colSpan: 12 },\n params: { markdown: true, content: message },\n } as UIComponent\n}\n\n/**\n * Assembles a `ConnectorDynamicResultV1` into a single `UILayout` :\n * `primary` + `supplemental[]` + (`actions` → an `action-group`).\n *\n * - When `primary` is itself a layout, its components are spread in.\n * - Raw data is never sacrificed — every supplied component is kept.\n * - Pure : no side effects, deterministic.\n *\n * ### Degraded behavior (R2)\n *\n * - Valid v1 payload → normal assembled layout.\n * - Unknown `schemaVersion` but an otherwise-usable envelope → the\n * components are still rendered, prefixed with a visible warning notice.\n * - Unreadable payload → an explicit error `UILayout` (a single `text`\n * notice). Never throws, never returns an empty layout silently.\n *\n * A degraded layout always has an `id` starting with `connector-degraded`,\n * so a host can detect it (e.g. for telemetry) without inspecting content.\n */\nexport function connectorResultToUILayout(\n result: unknown,\n options: ConnectorResultToUILayoutOptions = {}\n): UILayout {\n const strict = ConnectorDynamicResultV1Schema.safeParse(result)\n const messages: ConnectorAdapterMessages = { ...DEFAULT_CONNECTOR_MESSAGES, ...options.messages }\n\n // ── Tier 3 : unreadable ───────────────────────────────────\n if (!strict.success) {\n const lenient = LenientResultSchema.safeParse(result)\n if (!lenient.success) {\n const version =\n result && typeof result === 'object'\n ? (result as { schemaVersion?: unknown }).schemaVersion\n : undefined\n return {\n id: 'connector-degraded',\n components: [\n degradedTextComponent(\n 'connector-degraded-notice',\n formatMCPUIString(messages.degradedNotice, {\n versionSuffix:\n typeof version === 'string'\n ? formatMCPUIString(messages.degradedVersionSuffix, { version })\n : '',\n })\n ),\n ],\n grid: { ...DEFAULT_GRID },\n }\n }\n // ── Tier 2 : usable envelope, unknown version ───────────\n const r = lenient.data\n const components: UIComponent[] = [\n degradedTextComponent(\n 'connector-version-warning',\n formatMCPUIString(messages.versionWarning, {\n version: r.schemaVersion,\n expected: CONNECTOR_DYNAMIC_RESULT_V1,\n })\n ),\n ...collectComponents(r),\n ]\n return {\n id: options.id ?? `connector-degraded-${r.connectorId}`,\n components: components.map(withPosition),\n grid: { ...DEFAULT_GRID },\n }\n }\n\n // ── Tier 1 : valid v1 ─────────────────────────────────────\n const r = strict.data\n const components = collectComponents(r, options.actionsTitle).map(withPosition)\n return {\n id: options.id ?? layoutId(r.connectorId, r.queryHash ?? r.toolName),\n components,\n grid: { ...DEFAULT_GRID },\n }\n}\n\n/**\n * Flattens `primary` + `supplemental` + `actions` into a component list.\n * Shared by the valid and degraded-but-usable paths.\n */\nfunction collectComponents(\n r: {\n primary: Record<string, unknown>\n supplemental?: Record<string, unknown>[]\n actions?: unknown[]\n },\n actionsTitle?: string\n): UIComponent[] {\n const components: UIComponent[] = []\n\n if (isLayoutShape(r.primary)) {\n const inner = (r.primary as { components?: UIComponent[] }).components ?? []\n components.push(...inner)\n } else {\n components.push(r.primary as unknown as UIComponent)\n }\n\n if (r.supplemental) {\n components.push(...(r.supplemental as unknown as UIComponent[]))\n }\n\n if (Array.isArray(r.actions) && r.actions.length > 0) {\n components.push(\n connectorActionsToActionGroup(r.actions as ConnectorAction[], {\n id: 'connector-actions',\n title: actionsTitle,\n })\n )\n }\n\n return components\n}\n\nfunction layoutId(connectorId: string, suffix: string): string {\n return `connector-${connectorId}-${suffix}`\n}\n"],"names":["z","ConnectorDynamicResultV1Schema","formatMCPUIString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,MAAM,sBAAsBA,GAAE,WAAW;AAAA,MACrD,YAAYC,YAAW,IAAI,YAAY;AAAA,MACvC,MAAM,EAAE,GAAG,aAAA;AAAA,IAAa;AAAA,EAE5B;AAGA,QAAM,IAAI,OAAO;AACjB,QAAM,aAAa,kBAAkB,GAAG,QAAQ,YAAY,EAAE,IAAI,YAAY;AAC9E,SAAO;AAAA,IACL,IAAI,QAAQ,MAAM,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ;AAAA,IACnE;AAAA,IACA,MAAM,EAAE,GAAG,aAAA;AAAA,EAAa;AAE5B;AAMA,SAAS,kBACP,GAKA,cACe;AACf,QAAM,aAA4B,CAAA;AAElC,MAAI,cAAc,EAAE,OAAO,GAAG;AAC5B,UAAM,QAAS,EAAE,QAA2C,cAAc,CAAA;AAC1E,eAAW,KAAK,GAAG,KAAK;AAAA,EAC1B,OAAO;AACL,eAAW,KAAK,EAAE,OAAiC;AAAA,EACrD;AAEA,MAAI,EAAE,cAAc;AAClB,eAAW,KAAK,GAAI,EAAE,YAAyC;AAAA,EACjE;AAEA,MAAI,MAAM,QAAQ,EAAE,OAAO,KAAK,EAAE,QAAQ,SAAS,GAAG;AACpD,eAAW;AAAA,MACT,8BAA8B,EAAE,SAA8B;AAAA,QAC5D,IAAI;AAAA,QACJ,OAAO;AAAA,MAAA,CACR;AAAA,IAAA;AAAA,EAEL;AAEA,SAAO;AACT;AAEA,SAAS,SAAS,aAAqB,QAAwB;AAC7D,SAAO,aAAa,WAAW,IAAI,MAAM;AAC3C;;;;"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector adapters — `ConnectorDynamicResultV1` → MCP-UI render structures.
|
|
3
|
+
*
|
|
4
|
+
* @since v6.6.0 (D5 / D6 of ROADMAP-opendata-macro-mcpui)
|
|
5
|
+
*
|
|
6
|
+
* ## Opt-in, pure
|
|
7
|
+
*
|
|
8
|
+
* These adapters are published under the dedicated subpath
|
|
9
|
+
* `@seed-ship/mcp-ui-solid/adapters` — they are NEVER imported by the core
|
|
10
|
+
* renderer path, so a consumer that does not emit connector results pays
|
|
11
|
+
* nothing for them.
|
|
12
|
+
*
|
|
13
|
+
* Every adapter here is a **pure function** (D5) : same input → same
|
|
14
|
+
* output, no `fetch`, no `localStorage`, no global state, no clock, no
|
|
15
|
+
* randomness. This is what lets a host re-run an adapter deterministically
|
|
16
|
+
* after presentation feedback (D1) and replay fixtures in tests.
|
|
17
|
+
*
|
|
18
|
+
* ## Unknown schema version — never throw (R2)
|
|
19
|
+
*
|
|
20
|
+
* `connectorResultToUILayout()` never throws on the runtime render path.
|
|
21
|
+
* A payload it cannot read becomes an explicit degraded `UILayout` (a
|
|
22
|
+
* visible notice), never a silent disappearance and never an exception.
|
|
23
|
+
*/
|
|
24
|
+
import type { UIComponent, UILayout, GridPosition } from "../types.cjs";
|
|
25
|
+
import { type ConnectorAction } from '@seed-ship/mcp-ui-spec';
|
|
26
|
+
export interface ConnectorActionsToActionGroupOptions {
|
|
27
|
+
/** Component id. Default `'connector-actions'`. */
|
|
28
|
+
id?: string;
|
|
29
|
+
/** Optional heading shown above the buttons. */
|
|
30
|
+
title?: string;
|
|
31
|
+
/** Button row layout. Default `'horizontal'`. */
|
|
32
|
+
layout?: 'horizontal' | 'vertical' | 'space-between' | 'end' | 'center';
|
|
33
|
+
/** Gap between buttons. Default `'md'`. */
|
|
34
|
+
gap?: 'none' | 'sm' | 'md' | 'lg';
|
|
35
|
+
/** Grid position. Default full-width. */
|
|
36
|
+
position?: GridPosition;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Wraps a connector's `actions` into an `action-group` `UIComponent`.
|
|
40
|
+
*
|
|
41
|
+
* `ConnectorAction` is the exact `action-group` action shape, so this is a
|
|
42
|
+
* thin, pure envelope — no transformation of the actions themselves.
|
|
43
|
+
*/
|
|
44
|
+
export declare function connectorActionsToActionGroup(actions: ConnectorAction[], options?: ConnectorActionsToActionGroupOptions): UIComponent;
|
|
45
|
+
/**
|
|
46
|
+
* The visible wording of the two degraded states (R2).
|
|
47
|
+
*
|
|
48
|
+
* These paragraphs are rendered as `text` components, so unlike the payload
|
|
49
|
+
* they are the LIBRARY's own chrome. They cannot go through
|
|
50
|
+
* `MCPUIStrings` — the adapters are runtime-free and never import
|
|
51
|
+
* `solid-js` — so a host localizes them through
|
|
52
|
+
* `ConnectorResultToUILayoutOptions.messages` instead.
|
|
53
|
+
*
|
|
54
|
+
* Every field is a template resolved with `formatMCPUIString`.
|
|
55
|
+
*
|
|
56
|
+
* @since v6.20.0 — the defaults used to be hardcoded French.
|
|
57
|
+
*/
|
|
58
|
+
export interface ConnectorAdapterMessages {
|
|
59
|
+
/**
|
|
60
|
+
* Unreadable payload (tier 3). Template — `{versionSuffix}` is
|
|
61
|
+
* `degradedVersionSuffix` when the payload carried a string
|
|
62
|
+
* `schemaVersion`, and `''` otherwise.
|
|
63
|
+
*/
|
|
64
|
+
degradedNotice: string;
|
|
65
|
+
/** Inserted into `degradedNotice`. Template — `{version}`. */
|
|
66
|
+
degradedVersionSuffix: string;
|
|
67
|
+
/**
|
|
68
|
+
* Usable envelope, unknown version (tier 2). Template — `{version}` = the
|
|
69
|
+
* version read, `{expected}` = `CONNECTOR_DYNAMIC_RESULT_V1`.
|
|
70
|
+
*/
|
|
71
|
+
versionWarning: string;
|
|
72
|
+
}
|
|
73
|
+
/** English defaults for {@link ConnectorAdapterMessages}. */
|
|
74
|
+
export declare const DEFAULT_CONNECTOR_MESSAGES: ConnectorAdapterMessages;
|
|
75
|
+
export interface ConnectorResultToUILayoutOptions {
|
|
76
|
+
/** Layout id. Default derived from `connectorId` + `queryHash` / `toolName`. */
|
|
77
|
+
id?: string;
|
|
78
|
+
/** Heading for the actions `action-group`. */
|
|
79
|
+
actionsTitle?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Partial override of the degraded-state wording, merged over
|
|
82
|
+
* {@link DEFAULT_CONNECTOR_MESSAGES}. Hosts that render in another
|
|
83
|
+
* language pass their own paragraphs here.
|
|
84
|
+
*
|
|
85
|
+
* @since v6.20.0
|
|
86
|
+
*/
|
|
87
|
+
messages?: Partial<ConnectorAdapterMessages>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Assembles a `ConnectorDynamicResultV1` into a single `UILayout` :
|
|
91
|
+
* `primary` + `supplemental[]` + (`actions` → an `action-group`).
|
|
92
|
+
*
|
|
93
|
+
* - When `primary` is itself a layout, its components are spread in.
|
|
94
|
+
* - Raw data is never sacrificed — every supplied component is kept.
|
|
95
|
+
* - Pure : no side effects, deterministic.
|
|
96
|
+
*
|
|
97
|
+
* ### Degraded behavior (R2)
|
|
98
|
+
*
|
|
99
|
+
* - Valid v1 payload → normal assembled layout.
|
|
100
|
+
* - Unknown `schemaVersion` but an otherwise-usable envelope → the
|
|
101
|
+
* components are still rendered, prefixed with a visible warning notice.
|
|
102
|
+
* - Unreadable payload → an explicit error `UILayout` (a single `text`
|
|
103
|
+
* notice). Never throws, never returns an empty layout silently.
|
|
104
|
+
*
|
|
105
|
+
* A degraded layout always has an `id` starting with `connector-degraded`,
|
|
106
|
+
* so a host can detect it (e.g. for telemetry) without inspecting content.
|
|
107
|
+
*/
|
|
108
|
+
export declare function connectorResultToUILayout(result: unknown, options?: ConnectorResultToUILayoutOptions): UILayout;
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* A payload it cannot read becomes an explicit degraded `UILayout` (a
|
|
22
22
|
* visible notice), never a silent disappearance and never an exception.
|
|
23
23
|
*/
|
|
24
|
-
import type { UIComponent, UILayout, GridPosition } from
|
|
24
|
+
import type { UIComponent, UILayout, GridPosition } from "../types.js";
|
|
25
25
|
import { type ConnectorAction } from '@seed-ship/mcp-ui-spec';
|
|
26
26
|
export interface ConnectorActionsToActionGroupOptions {
|
|
27
27
|
/** Component id. Default `'connector-actions'`. */
|
|
@@ -106,4 +106,3 @@ export interface ConnectorResultToUILayoutOptions {
|
|
|
106
106
|
* so a host can detect it (e.g. for telemetry) without inspecting content.
|
|
107
107
|
*/
|
|
108
108
|
export declare function connectorResultToUILayout(result: unknown, options?: ConnectorResultToUILayoutOptions): UILayout;
|
|
109
|
-
//# sourceMappingURL=connector.d.ts.map
|
|
@@ -26,9 +26,9 @@ const LenientResultSchema = z.object({
|
|
|
26
26
|
query: z.string(),
|
|
27
27
|
queryHash: z.string().optional(),
|
|
28
28
|
intent: z.string().optional(),
|
|
29
|
-
primary: z.record(z.unknown()),
|
|
30
|
-
supplemental: z.array(z.record(z.unknown())).optional(),
|
|
31
|
-
actions: z.array(z.record(z.unknown())).optional()
|
|
29
|
+
primary: z.record(z.string(), z.unknown()),
|
|
30
|
+
supplemental: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
31
|
+
actions: z.array(z.record(z.string(), z.unknown())).optional()
|
|
32
32
|
});
|
|
33
33
|
const DEFAULT_GRID = { columns: 12, gap: "1rem" };
|
|
34
34
|
function withPosition(component) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.js","sources":["../../src/adapters/connector.ts"],"sourcesContent":["/**\n * Connector adapters — `ConnectorDynamicResultV1` → MCP-UI render structures.\n *\n * @since v6.6.0 (D5 / D6 of ROADMAP-opendata-macro-mcpui)\n *\n * ## Opt-in, pure\n *\n * These adapters are published under the dedicated subpath\n * `@seed-ship/mcp-ui-solid/adapters` — they are NEVER imported by the core\n * renderer path, so a consumer that does not emit connector results pays\n * nothing for them.\n *\n * Every adapter here is a **pure function** (D5) : same input → same\n * output, no `fetch`, no `localStorage`, no global state, no clock, no\n * randomness. This is what lets a host re-run an adapter deterministically\n * after presentation feedback (D1) and replay fixtures in tests.\n *\n * ## Unknown schema version — never throw (R2)\n *\n * `connectorResultToUILayout()` never throws on the runtime render path.\n * A payload it cannot read becomes an explicit degraded `UILayout` (a\n * visible notice), never a silent disappearance and never an exception.\n */\n\nimport type { UIComponent, UILayout, GridPosition } from '../types'\nimport {\n ConnectorDynamicResultV1Schema,\n CONNECTOR_DYNAMIC_RESULT_V1,\n type ConnectorAction,\n} from '@seed-ship/mcp-ui-spec'\nimport { z } from 'zod'\nimport { formatMCPUIString } from '../utils/format-string'\n\n// ─────────────────────────────────────────────────────────────\n// connectorActionsToActionGroup\n// ─────────────────────────────────────────────────────────────\n\nexport interface ConnectorActionsToActionGroupOptions {\n /** Component id. Default `'connector-actions'`. */\n id?: string\n /** Optional heading shown above the buttons. */\n title?: string\n /** Button row layout. Default `'horizontal'`. */\n layout?: 'horizontal' | 'vertical' | 'space-between' | 'end' | 'center'\n /** Gap between buttons. Default `'md'`. */\n gap?: 'none' | 'sm' | 'md' | 'lg'\n /** Grid position. Default full-width. */\n position?: GridPosition\n}\n\n/**\n * Wraps a connector's `actions` into an `action-group` `UIComponent`.\n *\n * `ConnectorAction` is the exact `action-group` action shape, so this is a\n * thin, pure envelope — no transformation of the actions themselves.\n */\nexport function connectorActionsToActionGroup(\n actions: ConnectorAction[],\n options: ConnectorActionsToActionGroupOptions = {}\n): UIComponent {\n return {\n id: options.id ?? 'connector-actions',\n type: 'action-group',\n position: options.position ?? { colStart: 1, colSpan: 12 },\n params: {\n actions,\n ...(options.title ? { title: options.title } : {}),\n layout: options.layout ?? 'horizontal',\n gap: options.gap ?? 'md',\n },\n } as UIComponent\n}\n\n// ─────────────────────────────────────────────────────────────\n// connectorResultToUILayout\n// ─────────────────────────────────────────────────────────────\n\n/**\n * The visible wording of the two degraded states (R2).\n *\n * These paragraphs are rendered as `text` components, so unlike the payload\n * they are the LIBRARY's own chrome. They cannot go through\n * `MCPUIStrings` — the adapters are runtime-free and never import\n * `solid-js` — so a host localizes them through\n * `ConnectorResultToUILayoutOptions.messages` instead.\n *\n * Every field is a template resolved with `formatMCPUIString`.\n *\n * @since v6.20.0 — the defaults used to be hardcoded French.\n */\nexport interface ConnectorAdapterMessages {\n /**\n * Unreadable payload (tier 3). Template — `{versionSuffix}` is\n * `degradedVersionSuffix` when the payload carried a string\n * `schemaVersion`, and `''` otherwise.\n */\n degradedNotice: string\n /** Inserted into `degradedNotice`. Template — `{version}`. */\n degradedVersionSuffix: string\n /**\n * Usable envelope, unknown version (tier 2). Template — `{version}` = the\n * version read, `{expected}` = `CONNECTOR_DYNAMIC_RESULT_V1`.\n */\n versionWarning: string\n}\n\n/** English defaults for {@link ConnectorAdapterMessages}. */\nexport const DEFAULT_CONNECTOR_MESSAGES: ConnectorAdapterMessages = {\n degradedNotice:\n '### Result not rendered\\n\\nThe connector result could not be interpreted{versionSuffix}. This explicit state replaces a silent disappearance of the rendering.',\n degradedVersionSuffix: ' (schema: `{version}`)',\n versionWarning:\n '> \\u26A0 Unrecognized connector schema (`{version}`, expected `{expected}`). The rendering below is in degraded mode.',\n}\n\nexport interface ConnectorResultToUILayoutOptions {\n /** Layout id. Default derived from `connectorId` + `queryHash` / `toolName`. */\n id?: string\n /** Heading for the actions `action-group`. */\n actionsTitle?: string\n /**\n * Partial override of the degraded-state wording, merged over\n * {@link DEFAULT_CONNECTOR_MESSAGES}. Hosts that render in another\n * language pass their own paragraphs here.\n *\n * @since v6.20.0\n */\n messages?: Partial<ConnectorAdapterMessages>\n}\n\n/**\n * Lenient mirror of `ConnectorDynamicResultV1Schema` — `schemaVersion`\n * relaxed to any string. Used to tell apart \"unknown version but otherwise\n * a usable envelope\" (→ render with a warning, R2) from \"truly unreadable\"\n * (→ explicit error state).\n */\nconst LenientResultSchema = z.object({\n schemaVersion: z.string(),\n connectorId: z.string().min(1),\n toolName: z.string().min(1),\n query: z.string(),\n queryHash: z.string().optional(),\n intent: z.string().optional(),\n primary: z.record(z.unknown()),\n supplemental: z.array(z.record(z.unknown())).optional(),\n actions: z.array(z.record(z.unknown())).optional(),\n})\n\nconst DEFAULT_GRID = { columns: 12, gap: '1rem' } as const\n\nfunction withPosition(component: UIComponent): UIComponent {\n if (component && component.position) return component\n return { ...component, position: { colStart: 1, colSpan: 12 } }\n}\n\n/** A component is a UILayout when it carries a `components` array. */\nfunction isLayoutShape(value: Record<string, unknown>): boolean {\n return Array.isArray((value as { components?: unknown }).components)\n}\n\nfunction degradedTextComponent(id: string, message: string): UIComponent {\n return {\n id,\n type: 'text',\n position: { colStart: 1, colSpan: 12 },\n params: { markdown: true, content: message },\n } as UIComponent\n}\n\n/**\n * Assembles a `ConnectorDynamicResultV1` into a single `UILayout` :\n * `primary` + `supplemental[]` + (`actions` → an `action-group`).\n *\n * - When `primary` is itself a layout, its components are spread in.\n * - Raw data is never sacrificed — every supplied component is kept.\n * - Pure : no side effects, deterministic.\n *\n * ### Degraded behavior (R2)\n *\n * - Valid v1 payload → normal assembled layout.\n * - Unknown `schemaVersion` but an otherwise-usable envelope → the\n * components are still rendered, prefixed with a visible warning notice.\n * - Unreadable payload → an explicit error `UILayout` (a single `text`\n * notice). Never throws, never returns an empty layout silently.\n *\n * A degraded layout always has an `id` starting with `connector-degraded`,\n * so a host can detect it (e.g. for telemetry) without inspecting content.\n */\nexport function connectorResultToUILayout(\n result: unknown,\n options: ConnectorResultToUILayoutOptions = {}\n): UILayout {\n const strict = ConnectorDynamicResultV1Schema.safeParse(result)\n const messages: ConnectorAdapterMessages = { ...DEFAULT_CONNECTOR_MESSAGES, ...options.messages }\n\n // ── Tier 3 : unreadable ───────────────────────────────────\n if (!strict.success) {\n const lenient = LenientResultSchema.safeParse(result)\n if (!lenient.success) {\n const version =\n result && typeof result === 'object'\n ? (result as { schemaVersion?: unknown }).schemaVersion\n : undefined\n return {\n id: 'connector-degraded',\n components: [\n degradedTextComponent(\n 'connector-degraded-notice',\n formatMCPUIString(messages.degradedNotice, {\n versionSuffix:\n typeof version === 'string'\n ? formatMCPUIString(messages.degradedVersionSuffix, { version })\n : '',\n })\n ),\n ],\n grid: { ...DEFAULT_GRID },\n }\n }\n // ── Tier 2 : usable envelope, unknown version ───────────\n const r = lenient.data\n const components: UIComponent[] = [\n degradedTextComponent(\n 'connector-version-warning',\n formatMCPUIString(messages.versionWarning, {\n version: r.schemaVersion,\n expected: CONNECTOR_DYNAMIC_RESULT_V1,\n })\n ),\n ...collectComponents(r),\n ]\n return {\n id: options.id ?? `connector-degraded-${r.connectorId}`,\n components: components.map(withPosition),\n grid: { ...DEFAULT_GRID },\n }\n }\n\n // ── Tier 1 : valid v1 ─────────────────────────────────────\n const r = strict.data\n const components = collectComponents(r, options.actionsTitle).map(withPosition)\n return {\n id: options.id ?? layoutId(r.connectorId, r.queryHash ?? r.toolName),\n components,\n grid: { ...DEFAULT_GRID },\n }\n}\n\n/**\n * Flattens `primary` + `supplemental` + `actions` into a component list.\n * Shared by the valid and degraded-but-usable paths.\n */\nfunction collectComponents(\n r: {\n primary: Record<string, unknown>\n supplemental?: Record<string, unknown>[]\n actions?: unknown[]\n },\n actionsTitle?: string\n): UIComponent[] {\n const components: UIComponent[] = []\n\n if (isLayoutShape(r.primary)) {\n const inner = (r.primary as { components?: UIComponent[] }).components ?? []\n components.push(...inner)\n } else {\n components.push(r.primary as unknown as UIComponent)\n }\n\n if (r.supplemental) {\n components.push(...(r.supplemental as unknown as UIComponent[]))\n }\n\n if (Array.isArray(r.actions) && r.actions.length > 0) {\n components.push(\n connectorActionsToActionGroup(r.actions as ConnectorAction[], {\n id: 'connector-actions',\n title: actionsTitle,\n })\n )\n }\n\n return components\n}\n\nfunction layoutId(connectorId: string, suffix: string): string {\n return `connector-${connectorId}-${suffix}`\n}\n"],"names":["r","components"],"mappings":";;;AAwDO,SAAS,8BACd,SACA,UAAgD,IACnC;AACb,SAAO;AAAA,IACL,IAAI,QAAQ,MAAM;AAAA,IAClB,MAAM;AAAA,IACN,UAAU,QAAQ,YAAY,EAAE,UAAU,GAAG,SAAS,GAAA;AAAA,IACtD,QAAQ;AAAA,MACN;AAAA,MACA,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAA,IAAU,CAAA;AAAA,MAC/C,QAAQ,QAAQ,UAAU;AAAA,MAC1B,KAAK,QAAQ,OAAO;AAAA,IAAA;AAAA,EACtB;AAEJ;AAoCO,MAAM,6BAAuD;AAAA,EAClE,gBACE;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MAAI,MAAM,QAAQ,EAAE,OAAO,KAAK,EAAE,QAAQ,SAAS,GAAG;AACpD,eAAW;AAAA,MACT,8BAA8B,EAAE,SAA8B;AAAA,QAC5D,IAAI;AAAA,QACJ,OAAO;AAAA,MAAA,CACR;AAAA,IAAA;AAAA,EAEL;AAEA,SAAO;AACT;AAEA,SAAS,SAAS,aAAqB,QAAwB;AAC7D,SAAO,aAAa,WAAW,IAAI,MAAM;AAC3C;"}
|
|
1
|
+
{"version":3,"file":"connector.js","sources":["../../src/adapters/connector.ts"],"sourcesContent":["/**\n * Connector adapters — `ConnectorDynamicResultV1` → MCP-UI render structures.\n *\n * @since v6.6.0 (D5 / D6 of ROADMAP-opendata-macro-mcpui)\n *\n * ## Opt-in, pure\n *\n * These adapters are published under the dedicated subpath\n * `@seed-ship/mcp-ui-solid/adapters` — they are NEVER imported by the core\n * renderer path, so a consumer that does not emit connector results pays\n * nothing for them.\n *\n * Every adapter here is a **pure function** (D5) : same input → same\n * output, no `fetch`, no `localStorage`, no global state, no clock, no\n * randomness. This is what lets a host re-run an adapter deterministically\n * after presentation feedback (D1) and replay fixtures in tests.\n *\n * ## Unknown schema version — never throw (R2)\n *\n * `connectorResultToUILayout()` never throws on the runtime render path.\n * A payload it cannot read becomes an explicit degraded `UILayout` (a\n * visible notice), never a silent disappearance and never an exception.\n */\n\nimport type { UIComponent, UILayout, GridPosition } from '../types'\nimport {\n ConnectorDynamicResultV1Schema,\n CONNECTOR_DYNAMIC_RESULT_V1,\n type ConnectorAction,\n} from '@seed-ship/mcp-ui-spec'\nimport { z } from 'zod'\nimport { formatMCPUIString } from '../utils/format-string'\n\n// ─────────────────────────────────────────────────────────────\n// connectorActionsToActionGroup\n// ─────────────────────────────────────────────────────────────\n\nexport interface ConnectorActionsToActionGroupOptions {\n /** Component id. Default `'connector-actions'`. */\n id?: string\n /** Optional heading shown above the buttons. */\n title?: string\n /** Button row layout. Default `'horizontal'`. */\n layout?: 'horizontal' | 'vertical' | 'space-between' | 'end' | 'center'\n /** Gap between buttons. Default `'md'`. */\n gap?: 'none' | 'sm' | 'md' | 'lg'\n /** Grid position. Default full-width. */\n position?: GridPosition\n}\n\n/**\n * Wraps a connector's `actions` into an `action-group` `UIComponent`.\n *\n * `ConnectorAction` is the exact `action-group` action shape, so this is a\n * thin, pure envelope — no transformation of the actions themselves.\n */\nexport function connectorActionsToActionGroup(\n actions: ConnectorAction[],\n options: ConnectorActionsToActionGroupOptions = {}\n): UIComponent {\n return {\n id: options.id ?? 'connector-actions',\n type: 'action-group',\n position: options.position ?? { colStart: 1, colSpan: 12 },\n params: {\n actions,\n ...(options.title ? { title: options.title } : {}),\n layout: options.layout ?? 'horizontal',\n gap: options.gap ?? 'md',\n },\n } as UIComponent\n}\n\n// ─────────────────────────────────────────────────────────────\n// connectorResultToUILayout\n// ─────────────────────────────────────────────────────────────\n\n/**\n * The visible wording of the two degraded states (R2).\n *\n * These paragraphs are rendered as `text` components, so unlike the payload\n * they are the LIBRARY's own chrome. They cannot go through\n * `MCPUIStrings` — the adapters are runtime-free and never import\n * `solid-js` — so a host localizes them through\n * `ConnectorResultToUILayoutOptions.messages` instead.\n *\n * Every field is a template resolved with `formatMCPUIString`.\n *\n * @since v6.20.0 — the defaults used to be hardcoded French.\n */\nexport interface ConnectorAdapterMessages {\n /**\n * Unreadable payload (tier 3). Template — `{versionSuffix}` is\n * `degradedVersionSuffix` when the payload carried a string\n * `schemaVersion`, and `''` otherwise.\n */\n degradedNotice: string\n /** Inserted into `degradedNotice`. Template — `{version}`. */\n degradedVersionSuffix: string\n /**\n * Usable envelope, unknown version (tier 2). Template — `{version}` = the\n * version read, `{expected}` = `CONNECTOR_DYNAMIC_RESULT_V1`.\n */\n versionWarning: string\n}\n\n/** English defaults for {@link ConnectorAdapterMessages}. */\nexport const DEFAULT_CONNECTOR_MESSAGES: ConnectorAdapterMessages = {\n degradedNotice:\n '### Result not rendered\\n\\nThe connector result could not be interpreted{versionSuffix}. This explicit state replaces a silent disappearance of the rendering.',\n degradedVersionSuffix: ' (schema: `{version}`)',\n versionWarning:\n '> \\u26A0 Unrecognized connector schema (`{version}`, expected `{expected}`). The rendering below is in degraded mode.',\n}\n\nexport interface ConnectorResultToUILayoutOptions {\n /** Layout id. Default derived from `connectorId` + `queryHash` / `toolName`. */\n id?: string\n /** Heading for the actions `action-group`. */\n actionsTitle?: string\n /**\n * Partial override of the degraded-state wording, merged over\n * {@link DEFAULT_CONNECTOR_MESSAGES}. Hosts that render in another\n * language pass their own paragraphs here.\n *\n * @since v6.20.0\n */\n messages?: Partial<ConnectorAdapterMessages>\n}\n\n/**\n * Lenient mirror of `ConnectorDynamicResultV1Schema` — `schemaVersion`\n * relaxed to any string. Used to tell apart \"unknown version but otherwise\n * a usable envelope\" (→ render with a warning, R2) from \"truly unreadable\"\n * (→ explicit error state).\n */\nconst LenientResultSchema = z.object({\n schemaVersion: z.string(),\n connectorId: z.string().min(1),\n toolName: z.string().min(1),\n query: z.string(),\n queryHash: z.string().optional(),\n intent: z.string().optional(),\n primary: z.record(z.string(), z.unknown()),\n supplemental: z.array(z.record(z.string(), z.unknown())).optional(),\n actions: z.array(z.record(z.string(), z.unknown())).optional(),\n})\n\nconst DEFAULT_GRID = { columns: 12, gap: '1rem' } as const\n\nfunction withPosition(component: UIComponent): UIComponent {\n if (component && component.position) return component\n return { ...component, position: { colStart: 1, colSpan: 12 } }\n}\n\n/** A component is a UILayout when it carries a `components` array. */\nfunction isLayoutShape(value: Record<string, unknown>): boolean {\n return Array.isArray((value as { components?: unknown }).components)\n}\n\nfunction degradedTextComponent(id: string, message: string): UIComponent {\n return {\n id,\n type: 'text',\n position: { colStart: 1, colSpan: 12 },\n params: { markdown: true, content: message },\n } as UIComponent\n}\n\n/**\n * Assembles a `ConnectorDynamicResultV1` into a single `UILayout` :\n * `primary` + `supplemental[]` + (`actions` → an `action-group`).\n *\n * - When `primary` is itself a layout, its components are spread in.\n * - Raw data is never sacrificed — every supplied component is kept.\n * - Pure : no side effects, deterministic.\n *\n * ### Degraded behavior (R2)\n *\n * - Valid v1 payload → normal assembled layout.\n * - Unknown `schemaVersion` but an otherwise-usable envelope → the\n * components are still rendered, prefixed with a visible warning notice.\n * - Unreadable payload → an explicit error `UILayout` (a single `text`\n * notice). Never throws, never returns an empty layout silently.\n *\n * A degraded layout always has an `id` starting with `connector-degraded`,\n * so a host can detect it (e.g. for telemetry) without inspecting content.\n */\nexport function connectorResultToUILayout(\n result: unknown,\n options: ConnectorResultToUILayoutOptions = {}\n): UILayout {\n const strict = ConnectorDynamicResultV1Schema.safeParse(result)\n const messages: ConnectorAdapterMessages = { ...DEFAULT_CONNECTOR_MESSAGES, ...options.messages }\n\n // ── Tier 3 : unreadable ───────────────────────────────────\n if (!strict.success) {\n const lenient = LenientResultSchema.safeParse(result)\n if (!lenient.success) {\n const version =\n result && typeof result === 'object'\n ? (result as { schemaVersion?: unknown }).schemaVersion\n : undefined\n return {\n id: 'connector-degraded',\n components: [\n degradedTextComponent(\n 'connector-degraded-notice',\n formatMCPUIString(messages.degradedNotice, {\n versionSuffix:\n typeof version === 'string'\n ? formatMCPUIString(messages.degradedVersionSuffix, { version })\n : '',\n })\n ),\n ],\n grid: { ...DEFAULT_GRID },\n }\n }\n // ── Tier 2 : usable envelope, unknown version ───────────\n const r = lenient.data\n const components: UIComponent[] = [\n degradedTextComponent(\n 'connector-version-warning',\n formatMCPUIString(messages.versionWarning, {\n version: r.schemaVersion,\n expected: CONNECTOR_DYNAMIC_RESULT_V1,\n })\n ),\n ...collectComponents(r),\n ]\n return {\n id: options.id ?? `connector-degraded-${r.connectorId}`,\n components: components.map(withPosition),\n grid: { ...DEFAULT_GRID },\n }\n }\n\n // ── Tier 1 : valid v1 ─────────────────────────────────────\n const r = strict.data\n const components = collectComponents(r, options.actionsTitle).map(withPosition)\n return {\n id: options.id ?? layoutId(r.connectorId, r.queryHash ?? r.toolName),\n components,\n grid: { ...DEFAULT_GRID },\n }\n}\n\n/**\n * Flattens `primary` + `supplemental` + `actions` into a component list.\n * Shared by the valid and degraded-but-usable paths.\n */\nfunction collectComponents(\n r: {\n primary: Record<string, unknown>\n supplemental?: Record<string, unknown>[]\n actions?: unknown[]\n },\n actionsTitle?: string\n): UIComponent[] {\n const components: UIComponent[] = []\n\n if (isLayoutShape(r.primary)) {\n const inner = (r.primary as { components?: UIComponent[] }).components ?? []\n components.push(...inner)\n } else {\n components.push(r.primary as unknown as UIComponent)\n }\n\n if (r.supplemental) {\n components.push(...(r.supplemental as unknown as UIComponent[]))\n }\n\n if (Array.isArray(r.actions) && r.actions.length > 0) {\n components.push(\n connectorActionsToActionGroup(r.actions as ConnectorAction[], {\n id: 'connector-actions',\n title: actionsTitle,\n })\n )\n }\n\n return components\n}\n\nfunction layoutId(connectorId: string, suffix: string): string {\n return `connector-${connectorId}-${suffix}`\n}\n"],"names":["r","components"],"mappings":";;;AAwDO,SAAS,8BACd,SACA,UAAgD,IACnC;AACb,SAAO;AAAA,IACL,IAAI,QAAQ,MAAM;AAAA,IAClB,MAAM;AAAA,IACN,UAAU,QAAQ,YAAY,EAAE,UAAU,GAAG,SAAS,GAAA;AAAA,IACtD,QAAQ;AAAA,MACN;AAAA,MACA,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAA,IAAU,CAAA;AAAA,MAC/C,QAAQ,QAAQ,UAAU;AAAA,MAC1B,KAAK,QAAQ,OAAO;AAAA,IAAA;AAAA,EACtB;AAEJ;AAoCO,MAAM,6BAAuD;AAAA,EAClE,gBACE;AAAA,EACF,uBAAuB;AAAA,EACvB,gBACE;AACJ;AAuBA,MAAM,sBAAsB,EAAE,OAAO;AAAA,EACnC,eAAe,EAAE,OAAA;AAAA,EACjB,aAAa,EAAE,SAAS,IAAI,CAAC;AAAA,EAC7B,UAAU,EAAE,SAAS,IAAI,CAAC;AAAA,EAC1B,OAAO,EAAE,OAAA;AAAA,EACT,WAAW,EAAE,OAAA,EAAS,SAAA;AAAA,EACtB,QAAQ,EAAE,OAAA,EAAS,SAAA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AI,MAAM;AAC3C;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @seed-ship/mcp-ui-solid/adapters
|
|
3
|
+
*
|
|
4
|
+
* Opt-in, pure adapters that turn connector / macro contracts into MCP-UI
|
|
5
|
+
* render structures. Published as a dedicated subpath so the core renderer
|
|
6
|
+
* path never depends on them.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { connectorResultToUILayout } from '@seed-ship/mcp-ui-solid/adapters'
|
|
11
|
+
*
|
|
12
|
+
* const layout = connectorResultToUILayout(connectorResult)
|
|
13
|
+
* // → <UIResourceRenderer content={layout} />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export { connectorResultToUILayout, connectorActionsToActionGroup, DEFAULT_CONNECTOR_MESSAGES, } from "./connector.cjs";
|
|
17
|
+
export type { ConnectorResultToUILayoutOptions, ConnectorActionsToActionGroupOptions, ConnectorAdapterMessages, } from "./connector.cjs";
|
|
18
|
+
export { macroRunToScratchpadState, macroInterrogationToChatPromptConfig, DEFAULT_MACRO_RUN_MESSAGES, } from "./macro-run.cjs";
|
|
19
|
+
export type { MacroRunAdapterMessages, MacroRunAdapterOptions } from "./macro-run.cjs";
|
|
20
|
+
export { createComparisonLayout, createGeographyLayout, createEvidenceLayout, } from "./presentation.cjs";
|
|
21
|
+
export type { ComparisonLayoutInput, GeographyLayoutInput, EvidenceLayoutInput, PresentationComponent, ChartComponent, TableComponent, MapComponent, MetricComponent, TextComponent, LinkComponent, } from "./presentation.cjs";
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -13,10 +13,9 @@
|
|
|
13
13
|
* // → <UIResourceRenderer content={layout} />
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
export { connectorResultToUILayout, connectorActionsToActionGroup, DEFAULT_CONNECTOR_MESSAGES, } from
|
|
17
|
-
export type { ConnectorResultToUILayoutOptions, ConnectorActionsToActionGroupOptions, ConnectorAdapterMessages, } from
|
|
18
|
-
export { macroRunToScratchpadState, macroInterrogationToChatPromptConfig, DEFAULT_MACRO_RUN_MESSAGES, } from
|
|
19
|
-
export type { MacroRunAdapterMessages, MacroRunAdapterOptions } from
|
|
20
|
-
export { createComparisonLayout, createGeographyLayout, createEvidenceLayout, } from
|
|
21
|
-
export type { ComparisonLayoutInput, GeographyLayoutInput, EvidenceLayoutInput, PresentationComponent, ChartComponent, TableComponent, MapComponent, MetricComponent, TextComponent, LinkComponent, } from
|
|
22
|
-
//# sourceMappingURL=index.d.ts.map
|
|
16
|
+
export { connectorResultToUILayout, connectorActionsToActionGroup, DEFAULT_CONNECTOR_MESSAGES, } from "./connector.js";
|
|
17
|
+
export type { ConnectorResultToUILayoutOptions, ConnectorActionsToActionGroupOptions, ConnectorAdapterMessages, } from "./connector.js";
|
|
18
|
+
export { macroRunToScratchpadState, macroInterrogationToChatPromptConfig, DEFAULT_MACRO_RUN_MESSAGES, } from "./macro-run.js";
|
|
19
|
+
export type { MacroRunAdapterMessages, MacroRunAdapterOptions } from "./macro-run.js";
|
|
20
|
+
export { createComparisonLayout, createGeographyLayout, createEvidenceLayout, } from "./presentation.js";
|
|
21
|
+
export type { ComparisonLayoutInput, GeographyLayoutInput, EvidenceLayoutInput, PresentationComponent, ChartComponent, TableComponent, MapComponent, MetricComponent, TextComponent, LinkComponent, } from "./presentation.js";
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MacroRun adapters — `MacroRunV1` / `MacroInterrogationV1` → MCP-UI render
|
|
3
|
+
* primitives.
|
|
4
|
+
*
|
|
5
|
+
* @since v6.7.0 (MacroRun Phase 2 — contract consolidated in deposium_MCPs
|
|
6
|
+
* `docs/2026/briefs/2026-05-22-macro-run-runtime-contract-consolidation.md`)
|
|
7
|
+
*
|
|
8
|
+
* ## Opt-in, pure
|
|
9
|
+
*
|
|
10
|
+
* Published under the dedicated subpath `@seed-ship/mcp-ui-solid/adapters` —
|
|
11
|
+
* never imported by the core renderer path. Every function here is a **pure
|
|
12
|
+
* function**: same input → same output, no `fetch`, no SSE listener, no
|
|
13
|
+
* persistence, no global state, no clock, no randomness.
|
|
14
|
+
*
|
|
15
|
+
* ## Scope boundary
|
|
16
|
+
*
|
|
17
|
+
* These adapters only translate the agnostic `MacroRunV1` contract (defined
|
|
18
|
+
* in `@seed-ship/mcp-ui-spec`) into existing MCP-UI primitives — a
|
|
19
|
+
* `ScratchpadState` and a `ChatPromptConfig`. They do NOT:
|
|
20
|
+
*
|
|
21
|
+
* - emit or consume any SSE event (a `macro_run_snapshot` producer is a
|
|
22
|
+
* separate, later goal on the producing runtime repo);
|
|
23
|
+
* - perform any fetch, persistence or resume;
|
|
24
|
+
* - know anything about a specific runtime, host, corpus or domain;
|
|
25
|
+
* - touch the `action:'submit'` executors, nor mix MacroRun with the
|
|
26
|
+
* existing tool-call action path.
|
|
27
|
+
*
|
|
28
|
+
* The host owns all of the above — it feeds a `MacroRunV1` snapshot in and
|
|
29
|
+
* decides where to render the result.
|
|
30
|
+
*/
|
|
31
|
+
import type { MacroRunV1, MacroInterrogationV1 } from '@seed-ship/mcp-ui-spec';
|
|
32
|
+
import type { ScratchpadState, ChatPromptConfig } from "../types/chat-bus.cjs";
|
|
33
|
+
/**
|
|
34
|
+
* The English wording this adapter produces on its own — section titles and
|
|
35
|
+
* the fallbacks used when the run (or the interrogation) carries none.
|
|
36
|
+
*
|
|
37
|
+
* The adapter is runtime-free by contract: no `solid-js`, no
|
|
38
|
+
* `MCPUIStringsContext`. Hosts that render in another language pass a
|
|
39
|
+
* partial override through `MacroRunAdapterOptions.messages`, exactly like
|
|
40
|
+
* `ConnectorResultToUILayoutOptions.messages`.
|
|
41
|
+
*
|
|
42
|
+
* @since v6.20.0
|
|
43
|
+
*/
|
|
44
|
+
export interface MacroRunAdapterMessages {
|
|
45
|
+
/** Title of the always-present `agent_card` section. */
|
|
46
|
+
agentSectionTitle: string;
|
|
47
|
+
/** Title of the `stepper` / `split_stepper` section. */
|
|
48
|
+
progressSectionTitle: string;
|
|
49
|
+
/** Title of each result section. */
|
|
50
|
+
resultSectionTitle: string;
|
|
51
|
+
/** Error message of an aborted run that carries no `error`. */
|
|
52
|
+
runAborted: string;
|
|
53
|
+
/** Error message of a failed run that carries no `error`. */
|
|
54
|
+
runFailed: string;
|
|
55
|
+
/** Prompt body of an elicitation with no usable schema and no message. */
|
|
56
|
+
confirmDefault: string;
|
|
57
|
+
}
|
|
58
|
+
/** English defaults for {@link MacroRunAdapterMessages}. */
|
|
59
|
+
export declare const DEFAULT_MACRO_RUN_MESSAGES: MacroRunAdapterMessages;
|
|
60
|
+
/** Options shared by the MacroRun adapters. @since v6.20.0 */
|
|
61
|
+
export interface MacroRunAdapterOptions {
|
|
62
|
+
/**
|
|
63
|
+
* Partial override of the adapter's own wording, merged over
|
|
64
|
+
* {@link DEFAULT_MACRO_RUN_MESSAGES}.
|
|
65
|
+
*/
|
|
66
|
+
messages?: Partial<MacroRunAdapterMessages>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Convert a `MacroRunV1` snapshot into a `ScratchpadState`.
|
|
70
|
+
*
|
|
71
|
+
* Sections produced, in order:
|
|
72
|
+
* 1. `agent_card` — always (derived from `run.agent`, or from the macro
|
|
73
|
+
* identity when the run carries no agent, e.g. a non-interactive macro).
|
|
74
|
+
* 2. `stepper` — when the run has steps and none carry `parallel` branches.
|
|
75
|
+
* `split_stepper` instead when any step carries `parallel` (future model).
|
|
76
|
+
* 3. `prompt` — when `run.pendingInterrogation` is set; its content is the
|
|
77
|
+
* `ChatPromptConfig` produced by {@link macroInterrogationToChatPromptConfig}.
|
|
78
|
+
* 4. one section per `run.results` entry (`chart` / `map` / `data_preview` /
|
|
79
|
+
* `data`, by component type). Optional — the adapter works without results.
|
|
80
|
+
*
|
|
81
|
+
* Pure: no fetch, no SSE, no persistence. The host owns all wiring.
|
|
82
|
+
*/
|
|
83
|
+
export declare function macroRunToScratchpadState(run: MacroRunV1, options?: MacroRunAdapterOptions): ScratchpadState;
|
|
84
|
+
/**
|
|
85
|
+
* Convert a `MacroInterrogationV1` into a `ChatPromptConfig`.
|
|
86
|
+
*
|
|
87
|
+
* - `choice` → `{ type: 'choice' }` (vertical layout).
|
|
88
|
+
* - `confirm` → `{ type: 'confirm' }`.
|
|
89
|
+
* - `form` → `{ type: 'form' }` (the opaque `fields` are passed through).
|
|
90
|
+
* - `elicitation` → routed through the existing `elicitationToPromptConfig()`
|
|
91
|
+
* helper. If the interrogation carries no usable elicitation JSON Schema,
|
|
92
|
+
* it degrades to a `confirm` prompt rather than throwing.
|
|
93
|
+
*
|
|
94
|
+
* Always returns a `ChatPromptConfig` — never an `ElicitationEvent` — so the
|
|
95
|
+
* host has a single entry point. Usable standalone or via
|
|
96
|
+
* {@link macroRunToScratchpadState} (which calls it for an embedded
|
|
97
|
+
* `pendingInterrogation`).
|
|
98
|
+
*/
|
|
99
|
+
export declare function macroInterrogationToChatPromptConfig(q: MacroInterrogationV1, options?: MacroRunAdapterOptions): ChatPromptConfig;
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* decides where to render the result.
|
|
30
30
|
*/
|
|
31
31
|
import type { MacroRunV1, MacroInterrogationV1 } from '@seed-ship/mcp-ui-spec';
|
|
32
|
-
import type { ScratchpadState, ChatPromptConfig } from
|
|
32
|
+
import type { ScratchpadState, ChatPromptConfig } from "../types/chat-bus.js";
|
|
33
33
|
/**
|
|
34
34
|
* The English wording this adapter produces on its own — section titles and
|
|
35
35
|
* the fallbacks used when the run (or the interrogation) carries none.
|
|
@@ -97,4 +97,3 @@ export declare function macroRunToScratchpadState(run: MacroRunV1, options?: Mac
|
|
|
97
97
|
* `pendingInterrogation`).
|
|
98
98
|
*/
|
|
99
99
|
export declare function macroInterrogationToChatPromptConfig(q: MacroInterrogationV1, options?: MacroRunAdapterOptions): ChatPromptConfig;
|
|
100
|
-
//# sourceMappingURL=macro-run.d.ts.map
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* `src/adapters/presentation.subpath.test.ts` asserts the built ESM and CJS
|
|
16
16
|
* artifacts contain no import/require at all.
|
|
17
17
|
*/
|
|
18
|
-
import type { ChartComponentParams, GridPosition, MapComponentParams, MetricComponentParams, TableComponentParams, TextComponentParams, UIComponent, UILayout } from
|
|
18
|
+
import type { ChartComponentParams, GridPosition, MapComponentParams, MetricComponentParams, TableComponentParams, TextComponentParams, UIComponent, UILayout } from "../types.cjs";
|
|
19
19
|
import type { LinkComponentParams } from '@seed-ship/mcp-ui-spec';
|
|
20
20
|
type PresentationType = 'chart' | 'table' | 'map' | 'metric' | 'text' | 'link';
|
|
21
21
|
/** A recipe owns the eventual grid position, so caller positions are optional. */
|
|
@@ -75,4 +75,3 @@ export declare function createGeographyLayout(input: GeographyLayoutInput): UILa
|
|
|
75
75
|
*/
|
|
76
76
|
export declare function createEvidenceLayout(input: EvidenceLayoutInput): UILayout;
|
|
77
77
|
export {};
|
|
78
|
-
//# sourceMappingURL=presentation.d.ts.map
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* `src/adapters/presentation.subpath.test.ts` asserts the built ESM and CJS
|
|
16
16
|
* artifacts contain no import/require at all.
|
|
17
17
|
*/
|
|
18
|
-
import type { ChartComponentParams, GridPosition, MapComponentParams, MetricComponentParams, TableComponentParams, TextComponentParams, UIComponent, UILayout } from
|
|
18
|
+
import type { ChartComponentParams, GridPosition, MapComponentParams, MetricComponentParams, TableComponentParams, TextComponentParams, UIComponent, UILayout } from "../types.js";
|
|
19
19
|
import type { LinkComponentParams } from '@seed-ship/mcp-ui-spec';
|
|
20
20
|
type PresentationType = 'chart' | 'table' | 'map' | 'metric' | 'text' | 'link';
|
|
21
21
|
/** A recipe owns the eventual grid position, so caller positions are optional. */
|
|
@@ -75,4 +75,3 @@ export declare function createGeographyLayout(input: GeographyLayoutInput): UILa
|
|
|
75
75
|
*/
|
|
76
76
|
export declare function createEvidenceLayout(input: EvidenceLayoutInput): UILayout;
|
|
77
77
|
export {};
|
|
78
|
-
//# sourceMappingURL=presentation.d.ts.map
|
package/dist/adapters.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./adapters/index.cjs";
|
package/dist/adapters.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./adapters/index.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActionGroupRenderer - Group of actions with layout options
|
|
3
|
+
* Sprint 3: UX Improvements
|
|
4
|
+
*/
|
|
5
|
+
import { Component } from 'solid-js';
|
|
6
|
+
import type { UIComponent, ActionGroupParams } from "../types.cjs";
|
|
7
|
+
export interface ActionGroupRendererProps {
|
|
8
|
+
/**
|
|
9
|
+
* UIComponent with action-group params (for declarative use)
|
|
10
|
+
*/
|
|
11
|
+
component?: UIComponent;
|
|
12
|
+
/**
|
|
13
|
+
* Direct action group params (alternative to component)
|
|
14
|
+
*/
|
|
15
|
+
params?: ActionGroupParams;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Action group component for rendering multiple actions with consistent layout
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const actionGroup: UIComponent = {
|
|
23
|
+
* id: 'form-actions',
|
|
24
|
+
* type: 'action-group',
|
|
25
|
+
* position: { colStart: 1, colSpan: 12 },
|
|
26
|
+
* params: {
|
|
27
|
+
* layout: 'end',
|
|
28
|
+
* gap: 'md',
|
|
29
|
+
* actions: [
|
|
30
|
+
* { label: 'Cancel', variant: 'outline', action: 'link', url: '/back' },
|
|
31
|
+
* { label: 'Save', variant: 'primary', action: 'tool-call', toolName: 'save' },
|
|
32
|
+
* ],
|
|
33
|
+
* },
|
|
34
|
+
* }
|
|
35
|
+
* <ActionGroupRenderer component={actionGroup} />
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare const ActionGroupRenderer: Component<ActionGroupRendererProps>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Sprint 3: UX Improvements
|
|
4
4
|
*/
|
|
5
5
|
import { Component } from 'solid-js';
|
|
6
|
-
import type { UIComponent, ActionGroupParams } from
|
|
6
|
+
import type { UIComponent, ActionGroupParams } from "../types.js";
|
|
7
7
|
export interface ActionGroupRendererProps {
|
|
8
8
|
/**
|
|
9
9
|
* UIComponent with action-group params (for declarative use)
|
|
@@ -36,4 +36,3 @@ export interface ActionGroupRendererProps {
|
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export declare const ActionGroupRenderer: Component<ActionGroupRendererProps>;
|
|
39
|
-
//# sourceMappingURL=ActionGroupRenderer.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Component } from 'solid-js';
|
|
2
|
+
type ActionSpec = any;
|
|
3
|
+
export interface ActionRendererProps {
|
|
4
|
+
action: ActionSpec;
|
|
5
|
+
onExecute: (toolName: string, params: any) => Promise<any>;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const ActionRenderer: Component<ActionRendererProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentCard — Agent identity + status display
|
|
3
|
+
* v4.1.0: AITL sprint — shows avatar, name, status, capabilities, current step
|
|
4
|
+
*
|
|
5
|
+
* @experimental
|
|
6
|
+
*/
|
|
7
|
+
import type { AgentCardContent } from "../types/chat-bus.cjs";
|
|
8
|
+
export interface AgentCardProps {
|
|
9
|
+
content: AgentCardContent;
|
|
10
|
+
}
|
|
11
|
+
export declare function AgentCard(props: AgentCardProps): import("solid-js").JSX.Element;
|
|
12
|
+
/**
|
|
13
|
+
* AgentStatusBadge — compact pulse badge for scratchpad header
|
|
14
|
+
*/
|
|
15
|
+
export interface AgentStatusBadgeProps {
|
|
16
|
+
agentName: string;
|
|
17
|
+
status: 'idle' | 'running' | 'waiting' | 'done' | 'error';
|
|
18
|
+
}
|
|
19
|
+
export declare function AgentStatusBadge(props: AgentStatusBadgeProps): import("solid-js").JSX.Element;
|