@miragon/mcp-toolkit-ui 2.6.0 → 2.8.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/README.md +14 -5
- package/dist/app/adapt-data-widget.d.ts +1 -22
- package/dist/app/adapt-data-widget.d.ts.map +1 -1
- package/dist/app/adapt-data-widget.js +1 -35
- package/dist/app/adapt-data-widget.js.map +1 -1
- package/dist/app/builder/BuilderBanners.d.ts +7 -2
- package/dist/app/builder/BuilderBanners.d.ts.map +1 -1
- package/dist/app/builder/BuilderBanners.js +8 -3
- package/dist/app/builder/BuilderBanners.js.map +1 -1
- package/dist/app/builder/CanvasRow.d.ts +4 -2
- package/dist/app/builder/CanvasRow.d.ts.map +1 -1
- package/dist/app/builder/CanvasRow.js +29 -17
- package/dist/app/builder/CanvasRow.js.map +1 -1
- package/dist/app/builder/CatalogueSheet.d.ts.map +1 -1
- package/dist/app/builder/CatalogueSheet.js +14 -6
- package/dist/app/builder/CatalogueSheet.js.map +1 -1
- package/dist/app/builder/CellPropsSheet.d.ts +7 -3
- package/dist/app/builder/CellPropsSheet.d.ts.map +1 -1
- package/dist/app/builder/CellPropsSheet.js +10 -3
- package/dist/app/builder/CellPropsSheet.js.map +1 -1
- package/dist/app/builder/DiscardDialog.d.ts +18 -0
- package/dist/app/builder/DiscardDialog.d.ts.map +1 -0
- package/dist/app/builder/DiscardDialog.js +18 -0
- package/dist/app/builder/DiscardDialog.js.map +1 -0
- package/dist/app/builder/EmptyHint.d.ts +4 -0
- package/dist/app/builder/EmptyHint.d.ts.map +1 -1
- package/dist/app/builder/EmptyHint.js +6 -1
- package/dist/app/builder/EmptyHint.js.map +1 -1
- package/dist/app/builder/LayoutSurface.d.ts +33 -9
- package/dist/app/builder/LayoutSurface.d.ts.map +1 -1
- package/dist/app/builder/LayoutSurface.js +74 -23
- package/dist/app/builder/LayoutSurface.js.map +1 -1
- package/dist/app/builder/PipelineStrip.d.ts +5 -2
- package/dist/app/builder/PipelineStrip.d.ts.map +1 -1
- package/dist/app/builder/PipelineStrip.js +33 -15
- package/dist/app/builder/PipelineStrip.js.map +1 -1
- package/dist/app/builder/SaveDialog.d.ts +9 -1
- package/dist/app/builder/SaveDialog.d.ts.map +1 -1
- package/dist/app/builder/SaveDialog.js +9 -3
- package/dist/app/builder/SaveDialog.js.map +1 -1
- package/dist/app/builder/Toolbar.d.ts +14 -4
- package/dist/app/builder/Toolbar.d.ts.map +1 -1
- package/dist/app/builder/Toolbar.js +24 -7
- package/dist/app/builder/Toolbar.js.map +1 -1
- package/dist/app/builder/Workspace.d.ts +23 -3
- package/dist/app/builder/Workspace.d.ts.map +1 -1
- package/dist/app/builder/Workspace.js +58 -8
- package/dist/app/builder/Workspace.js.map +1 -1
- package/dist/app/builder/builder-model.d.ts +146 -3
- package/dist/app/builder/builder-model.d.ts.map +1 -1
- package/dist/app/builder/builder-model.js +196 -5
- package/dist/app/builder/builder-model.js.map +1 -1
- package/dist/app/builder/labels.d.ts +13 -62
- package/dist/app/builder/labels.d.ts.map +1 -1
- package/dist/app/builder/labels.js +9 -58
- package/dist/app/builder/labels.js.map +1 -1
- package/dist/app/builder/reveal.d.ts +10 -0
- package/dist/app/builder/reveal.d.ts.map +1 -0
- package/dist/app/builder/reveal.js +10 -0
- package/dist/app/builder/reveal.js.map +1 -0
- package/dist/app/builder/status-chip.d.ts.map +1 -1
- package/dist/app/builder/status-chip.js +3 -2
- package/dist/app/builder/status-chip.js.map +1 -1
- package/dist/app/builder/use-builder-catalogue.d.ts +5 -1
- package/dist/app/builder/use-builder-catalogue.d.ts.map +1 -1
- package/dist/app/builder/use-builder-catalogue.js +50 -17
- package/dist/app/builder/use-builder-catalogue.js.map +1 -1
- package/dist/app/builder/use-builder-session.d.ts +30 -0
- package/dist/app/builder/use-builder-session.d.ts.map +1 -0
- package/dist/app/builder/use-builder-session.js +58 -0
- package/dist/app/builder/use-builder-session.js.map +1 -0
- package/dist/app/builder/use-display-resolver.d.ts +17 -0
- package/dist/app/builder/use-display-resolver.d.ts.map +1 -0
- package/dist/app/builder/use-display-resolver.js +16 -0
- package/dist/app/builder/use-display-resolver.js.map +1 -0
- package/dist/app/builder/use-save-dashboard.d.ts +3 -1
- package/dist/app/builder/use-save-dashboard.d.ts.map +1 -1
- package/dist/app/builder/use-save-dashboard.js +3 -1
- package/dist/app/builder/use-save-dashboard.js.map +1 -1
- package/dist/app/index.d.ts +8 -3
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +8 -2
- package/dist/app/index.js.map +1 -1
- package/dist/app/layout-builder.d.ts +18 -25
- package/dist/app/layout-builder.d.ts.map +1 -1
- package/dist/app/layout-builder.js +84 -78
- package/dist/app/layout-builder.js.map +1 -1
- package/dist/app/mcp-app-view-chrome.d.ts +103 -20
- package/dist/app/mcp-app-view-chrome.d.ts.map +1 -1
- package/dist/app/mcp-app-view-chrome.js +125 -40
- package/dist/app/mcp-app-view-chrome.js.map +1 -1
- package/dist/app/mcp-app-view-states.d.ts +23 -0
- package/dist/app/mcp-app-view-states.d.ts.map +1 -0
- package/dist/app/mcp-app-view-states.js +55 -0
- package/dist/app/mcp-app-view-states.js.map +1 -0
- package/dist/app/mcp-app-view.d.ts +72 -5
- package/dist/app/mcp-app-view.d.ts.map +1 -1
- package/dist/app/mcp-app-view.js +241 -141
- package/dist/app/mcp-app-view.js.map +1 -1
- package/dist/app/mcp-toolkit-app.d.ts +8 -2
- package/dist/app/mcp-toolkit-app.d.ts.map +1 -1
- package/dist/app/mcp-toolkit-app.js +33 -4
- package/dist/app/mcp-toolkit-app.js.map +1 -1
- package/dist/app/mcp-use-host-bridge.d.ts +15 -6
- package/dist/app/mcp-use-host-bridge.d.ts.map +1 -1
- package/dist/app/mcp-use-host-bridge.js +51 -22
- package/dist/app/mcp-use-host-bridge.js.map +1 -1
- package/dist/app/model-context.d.ts +71 -0
- package/dist/app/model-context.d.ts.map +1 -0
- package/dist/app/model-context.js +101 -0
- package/dist/app/model-context.js.map +1 -0
- package/dist/app/use-build-mode-focus.d.ts +33 -0
- package/dist/app/use-build-mode-focus.d.ts.map +1 -0
- package/dist/app/use-build-mode-focus.js +59 -0
- package/dist/app/use-build-mode-focus.js.map +1 -0
- package/dist/app/use-view-actions.d.ts +31 -0
- package/dist/app/use-view-actions.d.ts.map +1 -0
- package/dist/app/use-view-actions.js +81 -0
- package/dist/app/use-view-actions.js.map +1 -0
- package/dist/app/use-view-lifecycle.d.ts +42 -0
- package/dist/app/use-view-lifecycle.d.ts.map +1 -0
- package/dist/app/use-view-lifecycle.js +81 -0
- package/dist/app/use-view-lifecycle.js.map +1 -0
- package/dist/app/view-lifecycle.d.ts +185 -0
- package/dist/app/view-lifecycle.d.ts.map +1 -0
- package/dist/app/view-lifecycle.js +207 -0
- package/dist/app/view-lifecycle.js.map +1 -0
- package/dist/app/widget-fixture.d.ts +10 -3
- package/dist/app/widget-fixture.d.ts.map +1 -1
- package/dist/app/widget-fixture.js +21 -8
- package/dist/app/widget-fixture.js.map +1 -1
- package/dist/app/widget-props-sheet.d.ts +6 -10
- package/dist/app/widget-props-sheet.d.ts.map +1 -1
- package/dist/app/widget-props-sheet.js +25 -20
- package/dist/app/widget-props-sheet.js.map +1 -1
- package/dist/app/widget-renderer.d.ts +41 -1
- package/dist/app/widget-renderer.d.ts.map +1 -1
- package/dist/app/widget-renderer.js +82 -31
- package/dist/app/widget-renderer.js.map +1 -1
- package/dist/components/DrillButton.d.ts +9 -6
- package/dist/components/DrillButton.d.ts.map +1 -1
- package/dist/components/DrillButton.js +9 -6
- package/dist/components/DrillButton.js.map +1 -1
- package/dist/components/EmptyState.d.ts +33 -0
- package/dist/components/EmptyState.d.ts.map +1 -0
- package/dist/components/EmptyState.js +19 -0
- package/dist/components/EmptyState.js.map +1 -0
- package/dist/components/ErrorState.d.ts +53 -0
- package/dist/components/ErrorState.d.ts.map +1 -0
- package/dist/components/ErrorState.js +77 -0
- package/dist/components/ErrorState.js.map +1 -0
- package/dist/components/FilterBar.d.ts +16 -5
- package/dist/components/FilterBar.d.ts.map +1 -1
- package/dist/components/FilterBar.js +13 -5
- package/dist/components/FilterBar.js.map +1 -1
- package/dist/components/GroupCard.d.ts.map +1 -1
- package/dist/components/GroupCard.js +2 -1
- package/dist/components/GroupCard.js.map +1 -1
- package/dist/components/KpiGrid.d.ts +70 -18
- package/dist/components/KpiGrid.d.ts.map +1 -1
- package/dist/components/KpiGrid.js +112 -23
- package/dist/components/KpiGrid.js.map +1 -1
- package/dist/components/ListFooter.d.ts +32 -4
- package/dist/components/ListFooter.d.ts.map +1 -1
- package/dist/components/ListFooter.js +35 -6
- package/dist/components/ListFooter.js.map +1 -1
- package/dist/components/PagedListFooter.d.ts +57 -0
- package/dist/components/PagedListFooter.d.ts.map +1 -0
- package/dist/components/PagedListFooter.js +27 -0
- package/dist/components/PagedListFooter.js.map +1 -0
- package/dist/components/Pills.d.ts +36 -12
- package/dist/components/Pills.d.ts.map +1 -1
- package/dist/components/Pills.js +29 -8
- package/dist/components/Pills.js.map +1 -1
- package/dist/components/SectionHeading.d.ts +3 -1
- package/dist/components/SectionHeading.d.ts.map +1 -1
- package/dist/components/SectionHeading.js +6 -2
- package/dist/components/SectionHeading.js.map +1 -1
- package/dist/components/Toast.d.ts +43 -0
- package/dist/components/Toast.d.ts.map +1 -0
- package/dist/components/Toast.js +106 -0
- package/dist/components/Toast.js.map +1 -0
- package/dist/components/WidgetHeader.d.ts +34 -10
- package/dist/components/WidgetHeader.d.ts.map +1 -1
- package/dist/components/WidgetHeader.js +11 -6
- package/dist/components/WidgetHeader.js.map +1 -1
- package/dist/hooks/index.d.ts +4 -4
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/tool-result-recovery-model.d.ts +155 -0
- package/dist/hooks/tool-result-recovery-model.d.ts.map +1 -0
- package/dist/hooks/tool-result-recovery-model.js +273 -0
- package/dist/hooks/tool-result-recovery-model.js.map +1 -0
- package/dist/hooks/use-tool-query.d.ts +56 -14
- package/dist/hooks/use-tool-query.d.ts.map +1 -1
- package/dist/hooks/use-tool-query.js +102 -25
- package/dist/hooks/use-tool-query.js.map +1 -1
- package/dist/hooks/use-tool-result-recovery.d.ts +61 -44
- package/dist/hooks/use-tool-result-recovery.d.ts.map +1 -1
- package/dist/hooks/use-tool-result-recovery.js +62 -110
- package/dist/hooks/use-tool-result-recovery.js.map +1 -1
- package/dist/hooks/use-view-data.d.ts +55 -7
- package/dist/hooks/use-view-data.d.ts.map +1 -1
- package/dist/hooks/use-view-data.js +81 -11
- package/dist/hooks/use-view-data.js.map +1 -1
- package/dist/hooks/use-view-tool-query.d.ts +12 -7
- package/dist/hooks/use-view-tool-query.d.ts.map +1 -1
- package/dist/hooks/use-view-tool-query.js +15 -14
- package/dist/hooks/use-view-tool-query.js.map +1 -1
- package/dist/index.d.ts +27 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -7
- package/dist/index.js.map +1 -1
- package/dist/lib/focus-return.d.ts +61 -0
- package/dist/lib/focus-return.d.ts.map +1 -0
- package/dist/lib/focus-return.js +46 -0
- package/dist/lib/focus-return.js.map +1 -0
- package/dist/lib/focus-ring.d.ts +18 -0
- package/dist/lib/focus-ring.d.ts.map +1 -0
- package/dist/lib/focus-ring.js +18 -0
- package/dist/lib/focus-ring.js.map +1 -0
- package/dist/lib/icon-stroke.d.ts +12 -0
- package/dist/lib/icon-stroke.d.ts.map +1 -0
- package/dist/lib/icon-stroke.js +12 -0
- package/dist/lib/icon-stroke.js.map +1 -0
- package/dist/lib/parse-tool-result.d.ts +23 -1
- package/dist/lib/parse-tool-result.d.ts.map +1 -1
- package/dist/lib/parse-tool-result.js +38 -2
- package/dist/lib/parse-tool-result.js.map +1 -1
- package/dist/lib/toast-model.d.ts +86 -0
- package/dist/lib/toast-model.d.ts.map +1 -0
- package/dist/lib/toast-model.js +102 -0
- package/dist/lib/toast-model.js.map +1 -0
- package/dist/lib/tone-utils.d.ts +95 -9
- package/dist/lib/tone-utils.d.ts.map +1 -1
- package/dist/lib/tone-utils.js +100 -9
- package/dist/lib/tone-utils.js.map +1 -1
- package/dist/lib/tool-query.d.ts +107 -0
- package/dist/lib/tool-query.d.ts.map +1 -0
- package/dist/lib/tool-query.js +182 -0
- package/dist/lib/tool-query.js.map +1 -0
- package/dist/lib/tool-result-observer.d.ts +108 -0
- package/dist/lib/tool-result-observer.d.ts.map +1 -0
- package/dist/lib/tool-result-observer.js +158 -0
- package/dist/lib/tool-result-observer.js.map +1 -0
- package/dist/lib/typography.d.ts +37 -0
- package/dist/lib/typography.d.ts.map +1 -0
- package/dist/lib/typography.js +41 -0
- package/dist/lib/typography.js.map +1 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +11 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/locale/index.d.ts +3 -1
- package/dist/locale/index.d.ts.map +1 -1
- package/dist/locale/index.js +2 -1
- package/dist/locale/index.js.map +1 -1
- package/dist/locale/locale-provider.d.ts +42 -1
- package/dist/locale/locale-provider.d.ts.map +1 -1
- package/dist/locale/locale-provider.js +44 -3
- package/dist/locale/locale-provider.js.map +1 -1
- package/dist/locale/message-types.d.ts +336 -0
- package/dist/locale/message-types.d.ts.map +1 -0
- package/dist/locale/message-types.js +7 -0
- package/dist/locale/message-types.js.map +1 -0
- package/dist/locale/messages-de.d.ts +9 -0
- package/dist/locale/messages-de.d.ts.map +1 -0
- package/dist/locale/messages-de.js +185 -0
- package/dist/locale/messages-de.js.map +1 -0
- package/dist/locale/messages-en.d.ts +8 -0
- package/dist/locale/messages-en.d.ts.map +1 -0
- package/dist/locale/messages-en.js +184 -0
- package/dist/locale/messages-en.js.map +1 -0
- package/dist/locale/toolkit-messages.d.ts +57 -0
- package/dist/locale/toolkit-messages.d.ts.map +1 -0
- package/dist/locale/toolkit-messages.js +103 -0
- package/dist/locale/toolkit-messages.js.map +1 -0
- package/dist/primitives/alert.d.ts +1 -1
- package/dist/primitives/alert.d.ts.map +1 -1
- package/dist/primitives/alert.js +6 -2
- package/dist/primitives/alert.js.map +1 -1
- package/dist/primitives/badge.d.ts +1 -1
- package/dist/primitives/badge.d.ts.map +1 -1
- package/dist/primitives/badge.js +19 -6
- package/dist/primitives/badge.js.map +1 -1
- package/dist/primitives/button.d.ts +1 -1
- package/dist/primitives/button.d.ts.map +1 -1
- package/dist/primitives/button.js +12 -8
- package/dist/primitives/button.js.map +1 -1
- package/dist/primitives/card.js +4 -4
- package/dist/primitives/card.js.map +1 -1
- package/dist/primitives/dialog.d.ts +7 -3
- package/dist/primitives/dialog.d.ts.map +1 -1
- package/dist/primitives/dialog.js +22 -8
- package/dist/primitives/dialog.js.map +1 -1
- package/dist/primitives/input.d.ts.map +1 -1
- package/dist/primitives/input.js +4 -1
- package/dist/primitives/input.js.map +1 -1
- package/dist/primitives/scroll-area.js +1 -1
- package/dist/primitives/scroll-area.js.map +1 -1
- package/dist/primitives/select.d.ts.map +1 -1
- package/dist/primitives/select.js +6 -3
- package/dist/primitives/select.js.map +1 -1
- package/dist/primitives/sheet.d.ts +3 -1
- package/dist/primitives/sheet.d.ts.map +1 -1
- package/dist/primitives/sheet.js +17 -7
- package/dist/primitives/sheet.js.map +1 -1
- package/dist/primitives/skeleton.js +1 -1
- package/dist/primitives/skeleton.js.map +1 -1
- package/dist/primitives/switch.d.ts.map +1 -1
- package/dist/primitives/switch.js +2 -1
- package/dist/primitives/switch.js.map +1 -1
- package/dist/primitives/tabs.d.ts.map +1 -1
- package/dist/primitives/tabs.js +5 -3
- package/dist/primitives/tabs.js.map +1 -1
- package/dist/providers/query-provider.d.ts +32 -1
- package/dist/providers/query-provider.d.ts.map +1 -1
- package/dist/providers/query-provider.js +53 -4
- package/dist/providers/query-provider.js.map +1 -1
- package/dist/render-cases-primitives.js +1 -1
- package/dist/render-cases-primitives.js.map +1 -1
- package/dist/render-cases.d.ts.map +1 -1
- package/dist/render-cases.js +48 -6
- package/dist/render-cases.js.map +1 -1
- package/dist/render-effects.d.ts +42 -0
- package/dist/render-effects.d.ts.map +1 -0
- package/dist/render-effects.js +81 -0
- package/dist/render-effects.js.map +1 -0
- package/dist/render-scan.d.ts +25 -0
- package/dist/render-scan.d.ts.map +1 -0
- package/dist/render-scan.js +66 -0
- package/dist/render-scan.js.map +1 -0
- package/dist/theme/cd-tokens.d.ts +66 -0
- package/dist/theme/cd-tokens.d.ts.map +1 -0
- package/dist/theme/cd-tokens.js +64 -0
- package/dist/theme/cd-tokens.js.map +1 -0
- package/dist/theme/create-theme.d.ts +214 -39
- package/dist/theme/create-theme.d.ts.map +1 -1
- package/dist/theme/create-theme.js +204 -13
- package/dist/theme/create-theme.js.map +1 -1
- package/dist/theme/fonts.d.ts +38 -0
- package/dist/theme/fonts.d.ts.map +1 -0
- package/dist/theme/fonts.js +56 -0
- package/dist/theme/fonts.js.map +1 -0
- package/dist/theme/host-fonts.d.ts +39 -0
- package/dist/theme/host-fonts.d.ts.map +1 -0
- package/dist/theme/host-fonts.js +44 -0
- package/dist/theme/host-fonts.js.map +1 -0
- package/dist/theme/index.d.ts +8 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +5 -1
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/portal-container.d.ts +16 -0
- package/dist/theme/portal-container.d.ts.map +1 -0
- package/dist/theme/portal-container.js +19 -0
- package/dist/theme/portal-container.js.map +1 -0
- package/dist/theme/presets.d.ts +24 -9
- package/dist/theme/presets.d.ts.map +1 -1
- package/dist/theme/presets.js +44 -11
- package/dist/theme/presets.js.map +1 -1
- package/dist/theme/theme-provider.d.ts +27 -9
- package/dist/theme/theme-provider.d.ts.map +1 -1
- package/dist/theme/theme-provider.js +42 -20
- package/dist/theme/theme-provider.js.map +1 -1
- package/package.json +11 -5
- package/src/app/adapt-data-widget.tsx +2 -42
- package/src/app/builder/BuilderBanners.tsx +26 -13
- package/src/app/builder/CanvasRow.tsx +79 -32
- package/src/app/builder/CatalogueSheet.tsx +58 -35
- package/src/app/builder/CellPropsSheet.tsx +17 -2
- package/src/app/builder/DiscardDialog.tsx +59 -0
- package/src/app/builder/EmptyHint.tsx +16 -11
- package/src/app/builder/LayoutSurface.tsx +207 -67
- package/src/app/builder/PipelineStrip.tsx +265 -156
- package/src/app/builder/SaveDialog.tsx +25 -14
- package/src/app/builder/Toolbar.tsx +154 -57
- package/src/app/builder/Workspace.tsx +226 -56
- package/src/app/builder/builder-feedback.test.tsx +75 -0
- package/src/app/builder/builder-model.test.ts +5 -0
- package/src/app/builder/builder-model.ts +346 -6
- package/src/app/builder/builder-model.ux.test.ts +456 -0
- package/src/app/builder/builder-ux.test.tsx +844 -0
- package/src/app/builder/labels.ts +15 -121
- package/src/app/builder/reveal.ts +10 -0
- package/src/app/builder/status-chip.tsx +8 -4
- package/src/app/builder/use-builder-catalogue.ts +62 -19
- package/src/app/builder/use-builder-session.ts +68 -0
- package/src/app/builder/use-display-resolver.ts +24 -0
- package/src/app/builder/use-save-dashboard.ts +5 -0
- package/src/app/index.ts +20 -3
- package/src/app/layout-builder.tsx +193 -186
- package/src/app/mcp-app-view-chrome.test.tsx +487 -14
- package/src/app/mcp-app-view-chrome.tsx +328 -100
- package/src/app/mcp-app-view-states.tsx +140 -0
- package/src/app/mcp-app-view.effects.test.tsx +292 -0
- package/src/app/mcp-app-view.test.tsx +478 -0
- package/src/app/mcp-app-view.tsx +447 -190
- package/src/app/mcp-toolkit-app.test.tsx +40 -0
- package/src/app/mcp-toolkit-app.tsx +39 -8
- package/src/app/mcp-use-host-bridge.test.tsx +180 -0
- package/src/app/mcp-use-host-bridge.tsx +67 -24
- package/src/app/model-context.test.tsx +116 -0
- package/src/app/model-context.tsx +125 -0
- package/src/app/use-build-mode-focus.ts +62 -0
- package/src/app/use-view-actions.ts +89 -0
- package/src/app/use-view-lifecycle.ts +122 -0
- package/src/app/view-lifecycle.test.ts +443 -0
- package/src/app/view-lifecycle.ts +334 -0
- package/src/app/widget-fixture.effects.test.tsx +51 -0
- package/src/app/widget-fixture.render.test.tsx +81 -0
- package/src/app/widget-fixture.tsx +34 -11
- package/src/app/widget-props-sheet.tsx +67 -39
- package/src/app/widget-renderer.render.test.tsx +131 -0
- package/src/app/widget-renderer.tsx +136 -38
- package/src/components/DrillButton.tsx +24 -10
- package/src/components/EmptyState.tsx +83 -0
- package/src/components/ErrorState.tsx +204 -0
- package/src/components/FilterBar.test.tsx +82 -0
- package/src/components/FilterBar.tsx +56 -27
- package/src/components/GroupCard.tsx +3 -2
- package/src/components/KpiGrid.test.tsx +279 -0
- package/src/components/KpiGrid.tsx +329 -91
- package/src/components/ListFooter.test.tsx +116 -0
- package/src/components/ListFooter.tsx +110 -12
- package/src/components/PagedListFooter.test.tsx +140 -0
- package/src/components/PagedListFooter.tsx +107 -0
- package/src/components/Pills.test.tsx +77 -0
- package/src/components/Pills.tsx +78 -16
- package/src/components/SectionHeading.tsx +9 -3
- package/src/components/Toast.tsx +206 -0
- package/src/components/WidgetHeader.test.tsx +78 -0
- package/src/components/WidgetHeader.tsx +63 -16
- package/src/components/feedback-states.test.tsx +314 -0
- package/src/components/tone-figures.test.tsx +58 -0
- package/src/fonts.css +19 -0
- package/src/globals.css +9 -165
- package/src/hooks/index.ts +6 -3
- package/src/hooks/tool-result-recovery-model.test.ts +744 -0
- package/src/hooks/tool-result-recovery-model.ts +418 -0
- package/src/hooks/use-tool-query.effects.test.tsx +205 -0
- package/src/hooks/use-tool-query.ts +156 -33
- package/src/hooks/use-tool-result-recovery.effects.test.tsx +141 -0
- package/src/hooks/use-tool-result-recovery.test.ts +28 -5
- package/src/hooks/use-tool-result-recovery.ts +101 -131
- package/src/hooks/use-view-data.test.tsx +169 -0
- package/src/hooks/use-view-data.ts +131 -10
- package/src/hooks/use-view-tool-query.ts +25 -19
- package/src/i18n-coverage.test.tsx +425 -0
- package/src/index.ts +102 -13
- package/src/lib/focus-return.test.ts +288 -0
- package/src/lib/focus-return.ts +96 -0
- package/src/lib/focus-ring.ts +20 -0
- package/src/lib/icon-stroke.test.ts +59 -0
- package/src/lib/icon-stroke.ts +13 -0
- package/src/lib/parse-tool-result.test.ts +46 -1
- package/src/lib/parse-tool-result.ts +40 -2
- package/src/lib/toast-model.test.ts +233 -0
- package/src/lib/toast-model.ts +165 -0
- package/src/lib/tone-utils.test.ts +125 -16
- package/src/lib/tone-utils.ts +144 -15
- package/src/lib/tool-query.test.ts +569 -0
- package/src/lib/tool-query.ts +253 -0
- package/src/lib/tool-result-observer.test.ts +296 -0
- package/src/lib/tool-result-observer.ts +211 -0
- package/src/lib/typography.test.ts +45 -0
- package/src/lib/typography.ts +47 -0
- package/src/lib/utils.ts +12 -1
- package/src/locale/index.ts +14 -1
- package/src/locale/locale-provider.test.tsx +87 -0
- package/src/locale/locale-provider.tsx +90 -3
- package/src/locale/message-types.ts +337 -0
- package/src/locale/messages-de.ts +198 -0
- package/src/locale/messages-en.ts +196 -0
- package/src/locale/toolkit-messages.test.ts +349 -0
- package/src/locale/toolkit-messages.ts +143 -0
- package/src/no-hardcoded-copy.test.ts +432 -0
- package/src/primitives/alert.tsx +7 -2
- package/src/primitives/badge.tsx +19 -7
- package/src/primitives/button.tsx +13 -8
- package/src/primitives/card.tsx +4 -4
- package/src/primitives/dialog.tsx +42 -8
- package/src/primitives/input.tsx +5 -3
- package/src/primitives/scroll-area.tsx +1 -1
- package/src/primitives/select.tsx +7 -4
- package/src/primitives/sheet.tsx +33 -6
- package/src/primitives/skeleton.tsx +1 -1
- package/src/primitives/switch.tsx +4 -2
- package/src/primitives/tabs.tsx +9 -6
- package/src/providers/query-provider.test.tsx +154 -0
- package/src/providers/query-provider.tsx +66 -5
- package/src/render-cases-primitives.tsx +1 -1
- package/src/render-cases.tsx +82 -6
- package/src/render-effects.tsx +96 -0
- package/src/render-scan.ts +75 -0
- package/src/theme/cd-tokens.generated.css +48 -0
- package/src/theme/cd-tokens.test.ts +109 -0
- package/src/theme/cd-tokens.ts +67 -0
- package/src/theme/create-theme.test.ts +253 -5
- package/src/theme/create-theme.ts +341 -41
- package/src/theme/fonts.test.ts +85 -0
- package/src/theme/fonts.ts +72 -0
- package/src/theme/host-fonts.test.ts +135 -0
- package/src/theme/host-fonts.ts +52 -0
- package/src/theme/index.ts +15 -1
- package/src/theme/portal-container.ts +20 -0
- package/src/theme/presets.ts +44 -11
- package/src/theme/theme-css.test.ts +619 -0
- package/src/theme/theme-provider.test.tsx +82 -0
- package/src/theme/theme-provider.tsx +60 -24
- package/src/theme.css +344 -0
- package/ui-catalog.json +783 -49
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetHeader.d.ts","sourceRoot":"","sources":["../../src/components/WidgetHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,
|
|
1
|
+
{"version":3,"file":"WidgetHeader.d.ts","sourceRoot":"","sources":["../../src/components/WidgetHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAA0B,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAG5E,uDAAuD;AACvD,MAAM,MAAM,kBAAkB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAExE,MAAM,WAAW,iBAAiB;IAChC,wBAAwB;IACxB,KAAK,EAAE,SAAS,CAAA;IAChB;;;;;;OAMG;IACH,EAAE,CAAC,EAAE,kBAAkB,CAAA;IACvB;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC3B,uEAAuE;IACvE,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,sEAAsE;IACtE,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,0FAA0F;IAC1F,GAAG,CAAC,EAAE,SAAS,CAAA;IACf,4DAA4D;IAC5D,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAOD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,EAAE,EAAE,OAAc,EAClB,IAAgB,EAChB,WAAW,EACX,KAAK,EACL,GAAG,EACH,OAAO,EACP,IAAI,EACJ,QAAoB,EACpB,SAAS,GACV,EAAE,iBAAiB,+BAkCnB"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { TONE_SOFT } from "../lib/tone-utils.js";
|
|
2
|
+
import { resolveTone, TONE_SOFT } from "../lib/tone-utils.js";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
const TITLE_SIZE = {
|
|
5
|
+
default: "text-title",
|
|
6
|
+
detail: "text-section",
|
|
7
|
+
};
|
|
3
8
|
/**
|
|
4
|
-
* Page-level header
|
|
5
|
-
*
|
|
6
|
-
* Use once per widget surface to anchor it.
|
|
9
|
+
* Page-level header at the top of a widget: an optional state badge, the
|
|
10
|
+
* title (heading level per `as`, size per `size`), a subtitle/meta row and a
|
|
11
|
+
* right-aligned actions slot. Use once per widget surface to anchor it.
|
|
7
12
|
*/
|
|
8
|
-
export function WidgetHeader({
|
|
9
|
-
return (_jsxs("header", { className: "flex flex-wrap items-start justify-between gap-4", children: [_jsxs("div", { className: "min-w-0", children: [icon && (_jsx("div", { className:
|
|
13
|
+
export function WidgetHeader({ title, as: Heading = "h1", size = "default", titleSuffix, badge, sub, actions, icon, iconTone = "neutral", className, }) {
|
|
14
|
+
return (_jsxs("header", { "data-slot": "widget-header", className: cn("flex flex-wrap items-start justify-between gap-4", className), children: [_jsxs("div", { className: "min-w-0", children: [icon && (_jsx("div", { "aria-hidden": "true", className: cn("text-section mb-3.5 grid size-11 place-items-center rounded-md", TONE_SOFT[resolveTone(iconTone)]), children: icon })), badge && _jsx("div", { className: "mb-3", children: badge }), _jsxs(Heading, { className: cn("text-foreground mb-1.5 tracking-tight break-words", TITLE_SIZE[size]), children: [title, titleSuffix] }), sub && (_jsx("div", { className: "text-muted-foreground text-small flex flex-wrap items-center gap-2", children: sub }))] }), actions && _jsx("div", { className: "flex flex-wrap items-center gap-2", children: actions })] }));
|
|
10
15
|
}
|
|
11
16
|
//# sourceMappingURL=WidgetHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetHeader.js","sourceRoot":"","sources":["../../src/components/WidgetHeader.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"WidgetHeader.js","sourceRoot":"","sources":["../../src/components/WidgetHeader.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAiB,MAAM,sBAAsB,CAAA;AAC5E,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AAwCpC,MAAM,UAAU,GAA2D;IACzE,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,cAAc;CACvB,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,KAAK,EACL,EAAE,EAAE,OAAO,GAAG,IAAI,EAClB,IAAI,GAAG,SAAS,EAChB,WAAW,EACX,KAAK,EACL,GAAG,EACH,OAAO,EACP,IAAI,EACJ,QAAQ,GAAG,SAAS,EACpB,SAAS,GACS;IAClB,OAAO,CACL,+BACY,eAAe,EACzB,SAAS,EAAE,EAAE,CAAC,kDAAkD,EAAE,SAAS,CAAC,aAE5E,eAAK,SAAS,EAAC,SAAS,aACrB,IAAI,IAAI,CACP,6BACc,MAAM,EAClB,SAAS,EAAE,EAAE,CACX,gEAAgE,EAChE,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CACjC,YAEA,IAAI,GACD,CACP,EACA,KAAK,IAAI,cAAK,SAAS,EAAC,MAAM,YAAE,KAAK,GAAO,EAC7C,MAAC,OAAO,IACN,SAAS,EAAE,EAAE,CAAC,mDAAmD,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,aAEnF,KAAK,EACL,WAAW,IACJ,EACT,GAAG,IAAI,CACN,cAAK,SAAS,EAAC,oEAAoE,YAChF,GAAG,GACA,CACP,IACG,EACL,OAAO,IAAI,cAAK,SAAS,EAAC,mCAAmC,YAAE,OAAO,GAAO,IACvE,CACV,CAAA;AACH,CAAC"}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { useIsMobile } from "./use-mobile.js";
|
|
2
2
|
export { useDebouncedValue } from "./use-debounced-value.js";
|
|
3
|
-
export { useToolQuery, useToolMutation } from "./use-tool-query.js";
|
|
4
|
-
export type { UseToolQueryOptions } from "./use-tool-query.js";
|
|
3
|
+
export { useToolQuery, useToolQueryKey, useToolMutation } from "./use-tool-query.js";
|
|
4
|
+
export type { UseToolQueryOptions, UseToolMutationOptions } from "./use-tool-query.js";
|
|
5
5
|
export { useViewToolQuery } from "./use-view-tool-query.js";
|
|
6
6
|
export type { UseViewToolQueryOptions } from "./use-view-tool-query.js";
|
|
7
7
|
export { useViewData } from "./use-view-data.js";
|
|
8
|
-
export type { ViewDataResult } from "./use-view-data.js";
|
|
8
|
+
export type { ViewDataResult, UseViewDataOptions, ViewDataMode } from "./use-view-data.js";
|
|
9
9
|
export { useToolResultRecovery, resolveRecoveryToolName, decodeRecoveredResult, } from "./use-tool-result-recovery.js";
|
|
10
|
-
export type { ToolResultRecoveryOptions, ToolResultRecoveryState, } from "./use-tool-result-recovery.js";
|
|
10
|
+
export type { RecoveryBlockReason, RecoveryPolicy, ToolResultRecoveryOptions, ToolResultRecoveryState, ToolSafety, } from "./use-tool-result-recovery.js";
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACpF,YAAY,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC1F,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,+BAA+B,CAAA;AACtC,YAAY,EACV,mBAAmB,EACnB,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,UAAU,GACX,MAAM,+BAA+B,CAAA"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { useIsMobile } from "./use-mobile.js";
|
|
2
2
|
export { useDebouncedValue } from "./use-debounced-value.js";
|
|
3
|
-
export { useToolQuery, useToolMutation } from "./use-tool-query.js";
|
|
3
|
+
export { useToolQuery, useToolQueryKey, useToolMutation } from "./use-tool-query.js";
|
|
4
4
|
export { useViewToolQuery } from "./use-view-tool-query.js";
|
|
5
5
|
export { useViewData } from "./use-view-data.js";
|
|
6
6
|
export { useToolResultRecovery, resolveRecoveryToolName, decodeRecoveredResult, } from "./use-tool-result-recovery.js";
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAEpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,+BAA+B,CAAA"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { ToolObservation, ToolResultObserver } from "../lib/tool-result-observer.js";
|
|
2
|
+
/**
|
|
3
|
+
* What the host's tool annotations say about re-running the originating
|
|
4
|
+
* tool: `readOnlyHint: true` is `"read-only"`, `readOnlyHint: false` or
|
|
5
|
+
* `destructiveHint: true` is `"writes"`, anything else (no tool definition,
|
|
6
|
+
* no annotations, no read-only hint) is `"unknown"`.
|
|
7
|
+
*/
|
|
8
|
+
export type ToolSafety = "read-only" | "writes" | "unknown";
|
|
9
|
+
/**
|
|
10
|
+
* Which tools the view may re-execute on its own to recover a stripped result.
|
|
11
|
+
*
|
|
12
|
+
* - `"auto"` (default): any tool the host does not report as writing — a
|
|
13
|
+
* view tool is a read by the toolkit's render contract, so a missing hint
|
|
14
|
+
* counts as one.
|
|
15
|
+
* - `"read-only"`: only a tool the host reports with `readOnlyHint: true`.
|
|
16
|
+
* - `"never"`: never; a stripped result shows the error state, whose retry
|
|
17
|
+
* runs the tool on the user's click.
|
|
18
|
+
*/
|
|
19
|
+
export type RecoveryPolicy = "auto" | "read-only" | "never";
|
|
20
|
+
/** Why a needed recovery did not run: the policy forbids it, or the host names no tool. */
|
|
21
|
+
export type RecoveryBlockReason = "policy" | "no-tool";
|
|
22
|
+
/** Read {@link ToolSafety} from `hostContext.toolInfo.tool.annotations` (SEP-1865). */
|
|
23
|
+
export declare function resolveToolSafety(hostContext: unknown): ToolSafety;
|
|
24
|
+
/** Whether `policy` lets the view re-execute a tool of this `safety` on its own. */
|
|
25
|
+
export declare function policyAllows(policy: RecoveryPolicy, safety: ToolSafety): boolean;
|
|
26
|
+
export interface RecoveryDecisionInput {
|
|
27
|
+
/** The latch fired (`useToolContext().status !== "pending"`). */
|
|
28
|
+
resultReady: boolean;
|
|
29
|
+
/** The latched payload is renderable (a conforming host delivered it). */
|
|
30
|
+
payloadValid: boolean;
|
|
31
|
+
/** The host cancelled the call. */
|
|
32
|
+
cancelled: boolean;
|
|
33
|
+
/** The call latched a tool error (an `isError` result or a failed call). */
|
|
34
|
+
errored: boolean;
|
|
35
|
+
/** What the transport observer saw; `null` when none listens. */
|
|
36
|
+
observation: ToolObservation | null;
|
|
37
|
+
/** The call's arguments arrived (any tool-input, partial or complete). */
|
|
38
|
+
hasInput: boolean;
|
|
39
|
+
/** The originating tool (`hostContext.toolInfo`), when the host names it. */
|
|
40
|
+
toolName: string | undefined;
|
|
41
|
+
safety: ToolSafety;
|
|
42
|
+
policy: RecoveryPolicy;
|
|
43
|
+
/** The fallback grace period passed for the current arguments. */
|
|
44
|
+
graceElapsed: boolean;
|
|
45
|
+
}
|
|
46
|
+
export type RecoveryDecision =
|
|
47
|
+
/** Delivered, failed or cancelled: nothing to recover. */
|
|
48
|
+
{
|
|
49
|
+
action: "none";
|
|
50
|
+
}
|
|
51
|
+
/** The result is not in yet; `armGrace` starts the fallback timer (observer cannot vouch). */
|
|
52
|
+
| {
|
|
53
|
+
action: "wait";
|
|
54
|
+
armGrace: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** Re-execute the originating tool now. */
|
|
57
|
+
| {
|
|
58
|
+
action: "recover";
|
|
59
|
+
}
|
|
60
|
+
/** A recovery is needed but must not run. */
|
|
61
|
+
| {
|
|
62
|
+
action: "blocked";
|
|
63
|
+
reason: RecoveryBlockReason;
|
|
64
|
+
};
|
|
65
|
+
/** The recovery rule (see the module comment). Pure: every input is explicit. */
|
|
66
|
+
export declare function decideRecovery(input: RecoveryDecisionInput): RecoveryDecision;
|
|
67
|
+
/**
|
|
68
|
+
* The arguments a re-execution runs with: the complete tool-input the
|
|
69
|
+
* observer saw, else the view runtime's latest input, else none.
|
|
70
|
+
*/
|
|
71
|
+
export declare function recoveryArgs(observation: ToolObservation | null, toolInput: Record<string, unknown> | null | undefined): Record<string, unknown>;
|
|
72
|
+
/**
|
|
73
|
+
* Content identity of a JSON value, independent of key order and object
|
|
74
|
+
* identity: a re-delivered equal input is the same input (N21).
|
|
75
|
+
*/
|
|
76
|
+
export declare function stableKey(value: unknown): string;
|
|
77
|
+
/**
|
|
78
|
+
* Decodes a re-executed tool result and validates it: the payload, or `null`
|
|
79
|
+
* for an error result, an empty one or one the validator refuses.
|
|
80
|
+
*/
|
|
81
|
+
export declare function decodeRecoveredResult<T>(result: unknown, isValid: (value: unknown) => boolean): T | null;
|
|
82
|
+
export interface ToolResultRecoveryState<T> {
|
|
83
|
+
/** The recovered payload, `null` until the re-execution resolved (or when it failed). */
|
|
84
|
+
data: T | null;
|
|
85
|
+
/** The single recovery attempt failed — the view shows its error state, no retry loop. */
|
|
86
|
+
failed: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* A recovery was needed but did not run: the policy forbids re-executing
|
|
89
|
+
* this tool, or the host names no tool. `null` otherwise.
|
|
90
|
+
*/
|
|
91
|
+
blocked: RecoveryBlockReason | null;
|
|
92
|
+
/** When the recovered payload arrived (epoch ms) — its data is live as of then (N23). */
|
|
93
|
+
recoveredAt: number | null;
|
|
94
|
+
/** The arguments the recovered payload was computed for. */
|
|
95
|
+
args: Record<string, unknown> | null;
|
|
96
|
+
}
|
|
97
|
+
export declare const RECOVERY_IDLE: ToolResultRecoveryState<never>;
|
|
98
|
+
/** What the view knows about the rendering call on each render. */
|
|
99
|
+
export interface RecoveryInputs {
|
|
100
|
+
resultReady: boolean;
|
|
101
|
+
cancelled: boolean;
|
|
102
|
+
errored: boolean;
|
|
103
|
+
/** The payload the host delivered (`useToolContext().toolOutput`). */
|
|
104
|
+
props: unknown;
|
|
105
|
+
isValid: (value: unknown) => boolean;
|
|
106
|
+
toolInput: Record<string, unknown> | null | undefined;
|
|
107
|
+
/** Raw host context; `toolInfo` names the originating tool and its annotations. */
|
|
108
|
+
hostContext: Record<string, unknown> | null | undefined;
|
|
109
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
110
|
+
policy: RecoveryPolicy;
|
|
111
|
+
/** The fallback grace period (observer cannot vouch). */
|
|
112
|
+
graceMs: number;
|
|
113
|
+
/** Resolves the originating tool name from the host context. */
|
|
114
|
+
resolveToolName: (hostContext: unknown) => string | undefined;
|
|
115
|
+
}
|
|
116
|
+
export interface RecoveryController<T> {
|
|
117
|
+
subscribe: (listener: () => void) => () => void;
|
|
118
|
+
getState: () => ToolResultRecoveryState<T>;
|
|
119
|
+
/** Feed the latest inputs (every commit) and act on the decision. */
|
|
120
|
+
update: (inputs: RecoveryInputs) => void;
|
|
121
|
+
/** Listen to the observer (mount). */
|
|
122
|
+
start: () => void;
|
|
123
|
+
/** Stop listening and drop the grace timer; an in-flight call still lands (StrictMode re-runs). */
|
|
124
|
+
stop: () => void;
|
|
125
|
+
}
|
|
126
|
+
export interface RecoveryControllerOptions {
|
|
127
|
+
/** The transport observer; `null` when none listens (the grace timer decides alone). */
|
|
128
|
+
observer: ToolResultObserver | null;
|
|
129
|
+
/** Clock for {@link ToolResultRecoveryState.recoveredAt}. Default `Date.now`. */
|
|
130
|
+
now?: () => number;
|
|
131
|
+
}
|
|
132
|
+
/** One evaluation of the inputs: the decision plus the run it concerns. */
|
|
133
|
+
interface Evaluation {
|
|
134
|
+
decision: RecoveryDecision;
|
|
135
|
+
toolName: string | undefined;
|
|
136
|
+
args: Record<string, unknown>;
|
|
137
|
+
/** Content identity of `args` (the grace timer's key). */
|
|
138
|
+
argsKey: string;
|
|
139
|
+
/** Identity of the run: the tool and its arguments (the single flight's key). */
|
|
140
|
+
runKey: string;
|
|
141
|
+
}
|
|
142
|
+
/** Run {@link decideRecovery} on the controller's current knowledge. */
|
|
143
|
+
export declare function evaluateRecovery(inputs: RecoveryInputs, observation: ToolObservation | null, grace: {
|
|
144
|
+
key: string | null;
|
|
145
|
+
elapsed: boolean;
|
|
146
|
+
}): Evaluation;
|
|
147
|
+
/**
|
|
148
|
+
* Runs {@link decideRecovery} for the view: re-evaluates on every input
|
|
149
|
+
* update and observer change, arms the fallback grace timer per argument set,
|
|
150
|
+
* and makes at most one call per run (single flight, keyed by the tool and
|
|
151
|
+
* its arguments; a newer run drops an older call's outcome).
|
|
152
|
+
*/
|
|
153
|
+
export declare function createRecoveryController<T>(options: RecoveryControllerOptions): RecoveryController<T>;
|
|
154
|
+
export {};
|
|
155
|
+
//# sourceMappingURL=tool-result-recovery-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-result-recovery-model.d.ts","sourceRoot":"","sources":["../../src/hooks/tool-result-recovery-model.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAEzF;;;;;GAKG;AACH,MAAM,MAAM,U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,IAAI,EACnC,KAAK,EAAE;IAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC9C,UAAU,CAiBZ;AAuBD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,OAAO,EAAE,yBAAyB,GACjC,kBAAkB,CAAC,CAAC,CAAC,CA4GvB"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stripped-result recovery of `McpAppView` as plain logic (toolkit#176):
|
|
3
|
+
* WHEN the originating tool may be re-executed ({@link decideRecovery}) and a
|
|
4
|
+
* framework-free controller that runs that decision against the transport
|
|
5
|
+
* observer, a fallback grace timer and a single-flight call
|
|
6
|
+
* ({@link createRecoveryController}). `useToolResultRecovery` only binds the
|
|
7
|
+
* controller to React, so the scenarios here (keep / strip / slow / late
|
|
8
|
+
* observer) are the hook's behaviour.
|
|
9
|
+
*
|
|
10
|
+
* The rule, in order:
|
|
11
|
+
*
|
|
12
|
+
* 1. Never recover a call that was cancelled or failed: the view renders that
|
|
13
|
+
* state (an `isError` is an error, K14).
|
|
14
|
+
* 2. Recover when the host delivered a result the view cannot render: the
|
|
15
|
+
* latch fired with an invalid payload, or the observer saw the stripped,
|
|
16
|
+
* content-only result claude.ai sends. The re-run uses the COMPLETE
|
|
17
|
+
* arguments of the call (N21), never a partial stream.
|
|
18
|
+
* 3. Otherwise wait. A slow tool on a compliant host is simply still running
|
|
19
|
+
* (K13): the observer, listening since the handshake, would have seen its
|
|
20
|
+
* result. Only when it cannot vouch for that (no observer, or installed
|
|
21
|
+
* after the handshake) does the 2.x grace timer still infer a stripped
|
|
22
|
+
* result, and only once the call's arguments arrived.
|
|
23
|
+
* 4. A needed recovery runs only for a tool the policy allows
|
|
24
|
+
* ({@link RecoveryPolicy}: by default never one the host reports as
|
|
25
|
+
* writing) and only when the host names the tool; else it is `blocked`,
|
|
26
|
+
* which the view renders as an error whose retry is the user's own call.
|
|
27
|
+
*/
|
|
28
|
+
import { parseToolResult } from "../lib/parse-tool-result.js";
|
|
29
|
+
function isRecord(value) {
|
|
30
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31
|
+
}
|
|
32
|
+
/** Read {@link ToolSafety} from `hostContext.toolInfo.tool.annotations` (SEP-1865). */
|
|
33
|
+
export function resolveToolSafety(hostContext) {
|
|
34
|
+
if (!isRecord(hostContext) || !isRecord(hostContext.toolInfo))
|
|
35
|
+
return "unknown";
|
|
36
|
+
const tool = hostContext.toolInfo.tool;
|
|
37
|
+
const annotations = isRecord(tool) ? tool.annotations : undefined;
|
|
38
|
+
if (!isRecord(annotations))
|
|
39
|
+
return "unknown";
|
|
40
|
+
if (annotations.destructiveHint === true || annotations.readOnlyHint === false)
|
|
41
|
+
return "writes";
|
|
42
|
+
return annotations.readOnlyHint === true ? "read-only" : "unknown";
|
|
43
|
+
}
|
|
44
|
+
/** Whether `policy` lets the view re-execute a tool of this `safety` on its own. */
|
|
45
|
+
export function policyAllows(policy, safety) {
|
|
46
|
+
if (policy === "never")
|
|
47
|
+
return false;
|
|
48
|
+
if (policy === "read-only")
|
|
49
|
+
return safety === "read-only";
|
|
50
|
+
return safety !== "writes";
|
|
51
|
+
}
|
|
52
|
+
const NONE = { action: "none" };
|
|
53
|
+
const WAIT = { action: "wait", armGrace: false };
|
|
54
|
+
const WAIT_ARMED = { action: "wait", armGrace: true };
|
|
55
|
+
const RECOVER = { action: "recover" };
|
|
56
|
+
/** Rules 1–3: does the result need recovering, or is it delivered / still on its way? */
|
|
57
|
+
function recoveryNeed(input) {
|
|
58
|
+
if (input.resultReady)
|
|
59
|
+
return input.payloadValid ? NONE : "needed";
|
|
60
|
+
const observed = input.observation?.result ?? "none";
|
|
61
|
+
if (observed === "stripped")
|
|
62
|
+
return "needed";
|
|
63
|
+
// A structured result or an error: the latch is about to follow.
|
|
64
|
+
if (observed !== "none")
|
|
65
|
+
return NONE;
|
|
66
|
+
// Listening since the handshake: nothing arrived because nothing was sent.
|
|
67
|
+
if (input.observation?.sawHandshake)
|
|
68
|
+
return WAIT;
|
|
69
|
+
if (input.toolName === undefined || !input.hasInput)
|
|
70
|
+
return WAIT;
|
|
71
|
+
return input.graceElapsed ? "needed" : WAIT_ARMED;
|
|
72
|
+
}
|
|
73
|
+
/** The recovery rule (see the module comment). Pure: every input is explicit. */
|
|
74
|
+
export function decideRecovery(input) {
|
|
75
|
+
if (input.cancelled || input.errored || input.observation?.cancelled)
|
|
76
|
+
return NONE;
|
|
77
|
+
const need = recoveryNeed(input);
|
|
78
|
+
if (need !== "needed")
|
|
79
|
+
return need;
|
|
80
|
+
if (input.toolName === undefined)
|
|
81
|
+
return { action: "blocked", reason: "no-tool" };
|
|
82
|
+
if (!policyAllows(input.policy, input.safety))
|
|
83
|
+
return { action: "blocked", reason: "policy" };
|
|
84
|
+
return RECOVER;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The arguments a re-execution runs with: the complete tool-input the
|
|
88
|
+
* observer saw, else the view runtime's latest input, else none.
|
|
89
|
+
*/
|
|
90
|
+
export function recoveryArgs(observation, toolInput) {
|
|
91
|
+
return observation?.completeInput ?? toolInput ?? {};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Content identity of a JSON value, independent of key order and object
|
|
95
|
+
* identity: a re-delivered equal input is the same input (N21).
|
|
96
|
+
*/
|
|
97
|
+
export function stableKey(value) {
|
|
98
|
+
return (JSON.stringify(value, (_key, v) => isRecord(v)
|
|
99
|
+
? Object.fromEntries(Object.keys(v)
|
|
100
|
+
.sort()
|
|
101
|
+
.map((k) => [k, v[k]]))
|
|
102
|
+
: v) ?? "undefined");
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Decodes a re-executed tool result and validates it: the payload, or `null`
|
|
106
|
+
* for an error result, an empty one or one the validator refuses.
|
|
107
|
+
*/
|
|
108
|
+
export function decodeRecoveredResult(result, isValid) {
|
|
109
|
+
let decoded;
|
|
110
|
+
try {
|
|
111
|
+
decoded = parseToolResult(result);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
return decoded !== null && isValid(decoded) ? decoded : null;
|
|
117
|
+
}
|
|
118
|
+
export const RECOVERY_IDLE = Object.freeze({
|
|
119
|
+
data: null,
|
|
120
|
+
failed: false,
|
|
121
|
+
blocked: null,
|
|
122
|
+
recoveredAt: null,
|
|
123
|
+
args: null,
|
|
124
|
+
});
|
|
125
|
+
/** Run {@link decideRecovery} on the controller's current knowledge. */
|
|
126
|
+
export function evaluateRecovery(inputs, observation, grace) {
|
|
127
|
+
const toolName = inputs.resolveToolName(inputs.hostContext);
|
|
128
|
+
const args = recoveryArgs(observation, inputs.toolInput);
|
|
129
|
+
const argsKey = stableKey(args);
|
|
130
|
+
const decision = decideRecovery({
|
|
131
|
+
resultReady: inputs.resultReady,
|
|
132
|
+
payloadValid: inputs.isValid(inputs.props),
|
|
133
|
+
cancelled: inputs.cancelled,
|
|
134
|
+
errored: inputs.errored,
|
|
135
|
+
observation,
|
|
136
|
+
hasInput: inputs.toolInput != null || observation?.completeInput !== undefined,
|
|
137
|
+
toolName,
|
|
138
|
+
safety: resolveToolSafety(inputs.hostContext),
|
|
139
|
+
policy: inputs.policy,
|
|
140
|
+
graceElapsed: grace.elapsed && grace.key === argsKey,
|
|
141
|
+
});
|
|
142
|
+
return { decision, toolName, args, argsKey, runKey: `${toolName ?? ""}\u0000${argsKey}` };
|
|
143
|
+
}
|
|
144
|
+
/** Re-execute the tool and decode its answer; `null` for anything unusable. */
|
|
145
|
+
async function rerun(callTool, isValid, toolName, args) {
|
|
146
|
+
try {
|
|
147
|
+
const data = decodeRecoveredResult(await callTool(toolName, args), isValid);
|
|
148
|
+
if (data === null) {
|
|
149
|
+
console.warn(`[mcp-toolkit] tool-result recovery: re-executing "${toolName}" returned no usable payload`);
|
|
150
|
+
}
|
|
151
|
+
return data;
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
console.warn(`[mcp-toolkit] tool-result recovery for "${toolName}" failed:`, err);
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Runs {@link decideRecovery} for the view: re-evaluates on every input
|
|
160
|
+
* update and observer change, arms the fallback grace timer per argument set,
|
|
161
|
+
* and makes at most one call per run (single flight, keyed by the tool and
|
|
162
|
+
* its arguments; a newer run drops an older call's outcome).
|
|
163
|
+
*/
|
|
164
|
+
export function createRecoveryController(options) {
|
|
165
|
+
const { observer } = options;
|
|
166
|
+
const now = options.now ?? Date.now;
|
|
167
|
+
const listeners = new Set();
|
|
168
|
+
let state = RECOVERY_IDLE;
|
|
169
|
+
let inputs = null;
|
|
170
|
+
let unsubscribe = null;
|
|
171
|
+
let flight = null;
|
|
172
|
+
// The fallback grace timer: armed per argument set, elapsed once it fired.
|
|
173
|
+
const grace = { key: null, elapsed: false };
|
|
174
|
+
let graceTimer = null;
|
|
175
|
+
const setState = (next) => {
|
|
176
|
+
if (next === state)
|
|
177
|
+
return;
|
|
178
|
+
state = next;
|
|
179
|
+
for (const listener of [...listeners])
|
|
180
|
+
listener();
|
|
181
|
+
};
|
|
182
|
+
const clearGraceTimer = () => {
|
|
183
|
+
if (graceTimer !== null)
|
|
184
|
+
clearTimeout(graceTimer);
|
|
185
|
+
graceTimer = null;
|
|
186
|
+
};
|
|
187
|
+
const armGrace = (key, ms) => {
|
|
188
|
+
if (grace.key === key && (grace.elapsed || graceTimer !== null))
|
|
189
|
+
return;
|
|
190
|
+
clearGraceTimer();
|
|
191
|
+
grace.key = key;
|
|
192
|
+
grace.elapsed = false;
|
|
193
|
+
graceTimer = setTimeout(() => {
|
|
194
|
+
graceTimer = null;
|
|
195
|
+
grace.elapsed = true;
|
|
196
|
+
evaluate();
|
|
197
|
+
}, ms);
|
|
198
|
+
};
|
|
199
|
+
const launch = (current, run, toolName) => {
|
|
200
|
+
const own = {
|
|
201
|
+
key: run.runKey,
|
|
202
|
+
promise: rerun(current.callTool, current.isValid, toolName, run.args),
|
|
203
|
+
};
|
|
204
|
+
flight = own;
|
|
205
|
+
void own.promise.then((data) => {
|
|
206
|
+
// A newer run superseded this call: its outcome is stale.
|
|
207
|
+
if (flight !== own)
|
|
208
|
+
return;
|
|
209
|
+
setState(data === null
|
|
210
|
+
? { ...RECOVERY_IDLE, failed: true, args: run.args }
|
|
211
|
+
: { data: data, failed: false, blocked: null, recoveredAt: now(), args: run.args });
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
/** Act on one evaluation: drop a superseded attempt, launch, block or settle. */
|
|
215
|
+
const apply = (current, run) => {
|
|
216
|
+
const { decision } = run;
|
|
217
|
+
// A new run (the need went away, or new arguments) drops the previous
|
|
218
|
+
// attempt and its outcome.
|
|
219
|
+
if (flight && (decision.action !== "recover" || flight.key !== run.runKey)) {
|
|
220
|
+
flight = null;
|
|
221
|
+
setState(RECOVERY_IDLE);
|
|
222
|
+
}
|
|
223
|
+
if (decision.action === "blocked") {
|
|
224
|
+
if (state.blocked !== decision.reason) {
|
|
225
|
+
setState({ ...RECOVERY_IDLE, blocked: decision.reason });
|
|
226
|
+
}
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
// A lifted block (the tool got named, the policy changed) is gone at once,
|
|
230
|
+
// also while the re-run it allows is still in flight.
|
|
231
|
+
if (state.blocked !== null)
|
|
232
|
+
setState(RECOVERY_IDLE);
|
|
233
|
+
if (decision.action === "recover" && !flight && run.toolName !== undefined) {
|
|
234
|
+
launch(current, run, run.toolName);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
function evaluate() {
|
|
238
|
+
if (!inputs)
|
|
239
|
+
return;
|
|
240
|
+
const run = evaluateRecovery(inputs, observer?.getSnapshot() ?? null, grace);
|
|
241
|
+
if (run.decision.action === "wait" && run.decision.armGrace)
|
|
242
|
+
armGrace(run.argsKey, inputs.graceMs);
|
|
243
|
+
else
|
|
244
|
+
clearGraceTimer();
|
|
245
|
+
apply(inputs, run);
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
subscribe: (listener) => {
|
|
249
|
+
listeners.add(listener);
|
|
250
|
+
return () => {
|
|
251
|
+
listeners.delete(listener);
|
|
252
|
+
};
|
|
253
|
+
},
|
|
254
|
+
getState: () => state,
|
|
255
|
+
update: (next) => {
|
|
256
|
+
inputs = next;
|
|
257
|
+
evaluate();
|
|
258
|
+
},
|
|
259
|
+
start: () => {
|
|
260
|
+
if (!unsubscribe && observer)
|
|
261
|
+
unsubscribe = observer.subscribe(evaluate);
|
|
262
|
+
evaluate();
|
|
263
|
+
},
|
|
264
|
+
stop: () => {
|
|
265
|
+
unsubscribe?.();
|
|
266
|
+
unsubscribe = null;
|
|
267
|
+
// A stopped timer restarts in full on the next start (armGrace re-arms
|
|
268
|
+
// a key whose timer is gone); an elapsed grace stays elapsed.
|
|
269
|
+
clearGraceTimer();
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=tool-result-recovery-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-result-recovery-model.js","sourceRoot":"","sources":["../../src/hooks/tool-result-recovery-model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AA0B7D,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,iBAAiB,CAAC,WAAoB;IACpD,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC;QAAE,OAAO,SAAS,CAAA;IAC/E,MAAM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;QACZ,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACV,IAAI,CAAC,WAAW,IAAI,QAAQ;gBAAE,WAAW,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;YACxE,QAAQ,EAAE,CAAA;QACZ,CAAC;QACD,IAAI,EAAE,GAAG,EAAE;YACT,WAAW,EAAE,EAAE,CAAA;YACf,WAAW,GAAG,IAAI,CAAA;YAClB,uEAAuE;YACvE,8DAA8D;YAC9D,eAAe,EAAE,CAAA;QACnB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,21 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { type UseMutationOptions, type UseMutationResult, type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import { type UseToolQueryOptions } from "../lib/tool-query.js";
|
|
3
|
+
export type { UseToolQueryOptions } from "../lib/tool-query.js";
|
|
4
|
+
/**
|
|
5
|
+
* The exact cache key `useToolQuery`, `useViewToolQuery` and `useViewData`
|
|
6
|
+
* use for this tool and args under the nearest `AppQueryProvider`:
|
|
7
|
+
* `toolQueryKey` with the provider's `toolNameInQueryKey` setting. For
|
|
8
|
+
* `getQueryData`, `setQueryData` or `cancelQueries({ exact: true })`; prefix
|
|
9
|
+
* invalidation needs only the caller's `queryKey`. A new array per render.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useToolQueryKey(queryKey: readonly unknown[], toolName: string, args: object): unknown[];
|
|
12
|
+
/**
|
|
13
|
+
* Warns when two tools use one cache key (toolkit#176 K18): their answers
|
|
14
|
+
* would overwrite each other. Only the 2.x key can collide: with the tool
|
|
15
|
+
* name in the key (`toolNameInQueryKey`), two tools never share one.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useToolKeyGuard(queryKey: readonly unknown[], toolName: string, args: object): void;
|
|
18
|
+
/**
|
|
19
|
+
* Fetches a query again once a tool transport arrives, when it failed for
|
|
20
|
+
* want of one ({@link NoToolTransportError}): a `callTool` that resolves
|
|
21
|
+
* after the first render. TanStack refetches on a new key or `enabled`,
|
|
22
|
+
* never on a new fetcher, so the query would keep the error until a remount.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useRefetchOnTransport(callTool: unknown, query: Pick<UseQueryResult<unknown, Error>, "error" | "refetch">): void;
|
|
5
25
|
/**
|
|
6
26
|
* Loads data from a widget tool via TanStack Query.
|
|
7
27
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* entries
|
|
11
|
-
*
|
|
12
|
-
*
|
|
28
|
+
* The effective cache key is `[...queryKey, args]` (`toolQueryKey`): two
|
|
29
|
+
* callers that share `queryKey` but pass different `args` get separate
|
|
30
|
+
* entries. Two tools must not share a key and args; the hook warns when they
|
|
31
|
+
* do. Under an `AppQueryProvider` with `toolNameInQueryKey` (opt-in in 2.x,
|
|
32
|
+
* the default from the next major) the key is `[...queryKey, toolName,
|
|
33
|
+
* args]` and two tools never collide; `useToolQueryKey` returns the key in
|
|
34
|
+
* force. `opts` passes TanStack's query options through (`retry`,
|
|
35
|
+
* `retryDelay`, `staleTime`, `placeholderData` / `keepPreviousData`,
|
|
36
|
+
* `initialData` + `initialDataUpdatedAt`, `enabled`, `select`, …), and the
|
|
37
|
+
* result exposes `refetch`, `failureCount` and `failureReason`. `retry`
|
|
38
|
+
* defaults to the client's; `retry: shouldRetryToolCall` stops retrying a
|
|
39
|
+
* tool's own `isError` answer.
|
|
40
|
+
*
|
|
41
|
+
* The tool goes through `AppQueryProvider`'s `callTool`, else the nearest
|
|
42
|
+
* `HostBridgeProvider`'s bridge; with neither, the query fails with a
|
|
43
|
+
* "no tool transport" error instead of idling, and fetches once one arrives.
|
|
13
44
|
*/
|
|
14
|
-
export declare function useToolQuery<TData = unknown, TSelected = TData>(queryKey: unknown[], toolName: string, args: object, opts?: UseToolQueryOptions<TData, TSelected>):
|
|
45
|
+
export declare function useToolQuery<TData = unknown, TSelected = TData>(queryKey: readonly unknown[], toolName: string, args: object, opts?: UseToolQueryOptions<TData, TSelected>): UseQueryResult<TSelected, Error>;
|
|
46
|
+
/** Options of {@link useToolMutation}: TanStack's mutation options plus `invalidateKeys`. */
|
|
47
|
+
export type UseToolMutationOptions<TData = unknown> = Omit<UseMutationOptions<TData, Error, Record<string, unknown>, unknown>, "mutationFn" | "onMutate"> & {
|
|
48
|
+
/** Query keys (prefixes) to invalidate after a successful call. */
|
|
49
|
+
invalidateKeys?: unknown[][];
|
|
50
|
+
};
|
|
15
51
|
/**
|
|
16
|
-
* Executes a mutation via a widget tool and invalidates
|
|
52
|
+
* Executes a mutation via a widget tool and invalidates `invalidateKeys`
|
|
53
|
+
* after each successful call (`invalidateQueries`: active queries refetch,
|
|
54
|
+
* inactive ones are marked stale and refetch when they are next used).
|
|
55
|
+
*
|
|
56
|
+
* `mutate(args, { onSuccess, onError, onSettled })` fires its per-call
|
|
57
|
+
* callbacks for EVERY call while the component is mounted, not only for the
|
|
58
|
+
* latest one (TanStack's own rule), so two quick calls each get their
|
|
59
|
+
* confirmation. The hook-level callbacks in `opts` run first; the
|
|
60
|
+
* invalidation runs before the hook-level `onSuccess`.
|
|
17
61
|
*/
|
|
18
|
-
export declare function useToolMutation<TData = unknown>(toolName: string, opts?:
|
|
19
|
-
invalidateKeys?: unknown[][];
|
|
20
|
-
}): import("@tanstack/react-query").UseMutationResult<TData, Error, Record<string, unknown>, unknown>;
|
|
62
|
+
export declare function useToolMutation<TData = unknown>(toolName: string, opts?: UseToolMutationOptions<TData>): UseMutationResult<TData, Error, Record<string, unknown>>;
|
|
21
63
|
//# sourceMappingURL=use-tool-query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tool-query.d.ts","sourceRoot":"","sources":["../../src/hooks/use-tool-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-tool-query.d.ts","sourceRoot":"","sources":["../../src/hooks/use-tool-query.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,k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