@rebasepro/cms 0.28.2 → 0.29.0-canary.g0e3a0e7
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 +3 -3
- package/dist/collection_editor/_cms_internals.d.ts +0 -1
- package/dist/collection_editor/ui/EditorCollectionAction.d.ts +2 -2
- package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +2 -2
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -1
- package/dist/components/AdditionalFieldValue.d.ts +9 -3
- package/dist/components/AdditionalFieldValue.js +7 -4
- package/dist/components/AdditionalFieldValue.js.map +1 -1
- package/dist/components/CollectionPanel.d.ts +117 -18
- package/dist/components/CollectionPanel.js +115 -37
- package/dist/components/CollectionPanel.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +5 -5
- package/dist/components/CollectionTableBinding/CollectionRowActions.js +16 -12
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js +33 -8
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +8 -3
- package/dist/components/CollectionTableBinding/PropertyTableCell.js +2 -2
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
- package/dist/components/CollectionTableBinding/column_utils.d.ts +9 -1
- package/dist/components/CollectionTableBinding/column_utils.js +6 -3
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +3 -2
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +9 -7
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/common.d.ts +26 -2
- package/dist/components/CollectionTableBinding/internal/common.js +88 -4
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +4 -3
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.js +19 -14
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionAddButton.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js +50 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +11 -3
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -4
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +29 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js +112 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +58 -16
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.d.ts +57 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js +146 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +22 -26
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +58 -22
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js +81 -1089
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewContent.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js +152 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js +38 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.d.ts +13 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js +32 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.d.ts +14 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js +22 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +39 -67
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js +54 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.d.ts +24 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js +69 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/EntityCardBinding.js +34 -23
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.d.ts +17 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +107 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -0
- package/dist/components/CollectionViewBinding/FiltersButton.d.ts +15 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js +49 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +35 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js +45 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -0
- package/dist/components/CollectionViewBinding/RowActions.d.ts +40 -0
- package/dist/components/CollectionViewBinding/RowActions.js +60 -0
- package/dist/components/CollectionViewBinding/RowActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListView.d.ts +7 -4
- package/dist/components/CollectionViewBinding/SplitListView.js +20 -21
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
- package/dist/components/CollectionViewBinding/builtin_action_props.d.ts +13 -0
- package/dist/components/CollectionViewBinding/fields.d.ts +22 -0
- package/dist/components/CollectionViewBinding/fields.js +47 -0
- package/dist/components/CollectionViewBinding/fields.js.map +1 -0
- package/dist/components/CollectionViewBinding/useBoardDataController.js +6 -7
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.d.ts +19 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js +28 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js.map +1 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +125 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js +844 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +20 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.js +23 -2
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/useSelectionController.d.ts +21 -3
- package/dist/components/CollectionViewBinding/useSelectionController.js +37 -6
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
- package/dist/components/CollectionsProvider.d.ts +3 -3
- package/dist/components/CollectionsProvider.js +4 -4
- package/dist/components/CollectionsProvider.js.map +1 -1
- package/dist/components/CollectionsScopeContext.d.ts +1 -1
- package/dist/components/CollectionsScopeContext.js +1 -1
- package/dist/components/CollectionsScopeContext.js.map +1 -1
- package/dist/components/DeleteEntityDialog.d.ts +1 -1
- package/dist/components/DeleteEntityDialog.js +2 -2
- package/dist/components/DeleteEntityDialog.js.map +1 -1
- package/dist/components/DetailViewBinding.js +32 -68
- package/dist/components/DetailViewBinding.js.map +1 -1
- package/dist/components/EditFormActions.js +5 -4
- package/dist/components/EditFormActions.js.map +1 -1
- package/dist/components/EditViewBinding.d.ts +2 -2
- package/dist/components/EditViewBinding.js +25 -15
- package/dist/components/EditViewBinding.js.map +1 -1
- package/dist/components/EntityDisplayHeader.js +8 -5
- package/dist/components/EntityDisplayHeader.js.map +1 -1
- package/dist/components/EntityPreviewBinding.js +1 -1
- package/dist/components/EntityPreviewBinding.js.map +1 -1
- package/dist/components/EntityViewBinding.d.ts +8 -1
- package/dist/components/EntityViewBinding.js +43 -14
- package/dist/components/EntityViewBinding.js.map +1 -1
- package/dist/components/EntityViewBody.d.ts +40 -0
- package/dist/components/EntityViewBody.js +90 -0
- package/dist/components/EntityViewBody.js.map +1 -0
- package/dist/components/FieldValue.d.ts +50 -0
- package/dist/components/FieldValue.js +81 -0
- package/dist/components/FieldValue.js.map +1 -0
- package/dist/components/InlineEntityPreview.js +1 -1
- package/dist/components/InlineEntityPreview.js.map +1 -1
- package/dist/components/PanelNotFound.d.ts +5 -0
- package/dist/components/PanelNotFound.js +21 -0
- package/dist/components/PanelNotFound.js.map +1 -0
- package/dist/components/RebaseCMS.d.ts +1 -1
- package/dist/components/RebaseCMS.js +11 -3
- package/dist/components/RebaseCMS.js.map +1 -1
- package/dist/components/RebaseNavigation.js +9 -3
- package/dist/components/RebaseNavigation.js.map +1 -1
- package/dist/components/RebaseShell.js +10 -5
- package/dist/components/RebaseShell.js.map +1 -1
- package/dist/components/RecordDetail.d.ts +61 -0
- package/dist/components/RecordDetail.js +123 -0
- package/dist/components/RecordDetail.js.map +1 -0
- package/dist/components/RecordForm.d.ts +126 -0
- package/dist/components/{EntityFormPanel.js → RecordForm.js} +64 -36
- package/dist/components/RecordForm.js.map +1 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +47 -17
- package/dist/components/ReferenceTable/SelectionTableBinding.js +89 -53
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
- package/dist/components/ReferenceWidget.d.ts +5 -3
- package/dist/components/ReferenceWidget.js +10 -7
- package/dist/components/ReferenceWidget.js.map +1 -1
- package/dist/components/RelationSelector.js +4 -4
- package/dist/components/RelationSelector.js.map +1 -1
- package/dist/components/SelectableTable/SelectableTable.js +2 -3
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
- package/dist/components/SelectableTable/SelectionStore.d.ts +1 -1
- package/dist/components/SelectableTable/SelectionStore.js +1 -1
- package/dist/components/SelectableTable/SelectionStore.js.map +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
- package/dist/components/SidePanelBinding.js +13 -12
- package/dist/components/SidePanelBinding.js.map +1 -1
- package/dist/components/collection_prop.d.ts +18 -0
- package/dist/components/collection_prop.js +23 -0
- package/dist/components/collection_prop.js.map +1 -0
- package/dist/components/common/default_entity_actions.js +54 -54
- package/dist/components/common/default_entity_actions.js.map +1 -1
- package/dist/components/history/EntityHistoryView.d.ts +4 -1
- package/dist/components/history/EntityHistoryView.js +1 -1
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/components/history/LastEditedByFormAction.d.ts +1 -1
- package/dist/components/index.d.ts +4 -2
- package/dist/data_export/export/ExportCollectionAction.d.ts +3 -2
- package/dist/data_export/export/ExportCollectionAction.js +4 -3
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
- package/dist/data_export/export/additional_fields.d.ts +6 -3
- package/dist/data_export/export/additional_fields.js +8 -4
- package/dist/data_export/export/additional_fields.js.map +1 -1
- package/dist/data_import/import/ImportCollectionAction.js +2 -2
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/EntityForm.js +252 -150
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormActions.js +3 -2
- package/dist/form/EntityFormActions.js.map +1 -1
- package/dist/form/EntityFormBinding.d.ts +1 -1
- package/dist/form/EntityFormBinding.js +22 -11
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/FormField.d.ts +36 -0
- package/dist/form/FormField.js +41 -0
- package/dist/form/FormField.js.map +1 -0
- package/dist/form/FormFieldsContext.d.ts +69 -0
- package/dist/form/FormFieldsContext.js +143 -0
- package/dist/form/FormFieldsContext.js.map +1 -0
- package/dist/form/PropertyFieldBinding.js +4 -4
- package/dist/form/PropertyFieldBinding.js.map +1 -1
- package/dist/form/collection_showing.d.ts +8 -0
- package/dist/form/collection_showing.js +29 -0
- package/dist/form/collection_showing.js.map +1 -0
- package/dist/form/components/ErrorFocus.js +2 -1
- package/dist/form/components/ErrorFocus.js.map +1 -1
- package/dist/form/components/FieldBlock.js +3 -1
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FormRail.d.ts +5 -1
- package/dist/form/components/FormRail.js +5 -1
- package/dist/form/components/FormRail.js.map +1 -1
- package/dist/form/components/FormSections.d.ts +5 -1
- package/dist/form/components/FormSections.js +11 -4
- package/dist/form/components/FormSections.js.map +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
- package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
- package/dist/form/form_dom_ids.d.ts +25 -0
- package/dist/form/form_dom_ids.js +42 -0
- package/dist/form/form_dom_ids.js.map +1 -0
- package/dist/form/index.d.ts +3 -1
- package/dist/form/resolve_cell_property.d.ts +5 -0
- package/dist/form/resolve_cell_property.js +22 -1
- package/dist/form/resolve_cell_property.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +2 -2
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
- package/dist/hooks/navigation/useNavigationResolution.d.ts +3 -3
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
- package/dist/hooks/navigation/useResolvedCollections.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
- package/dist/hooks/navigation/useResolvedViews.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
- package/dist/hooks/useBuildSidePanel.js +9 -9
- package/dist/hooks/useBuildSidePanel.js.map +1 -1
- package/dist/hooks/useEntityDisplay.js +6 -4
- package/dist/hooks/useEntityDisplay.js.map +1 -1
- package/dist/hooks/useRecordActions.js +2 -2
- package/dist/hooks/useRecordActions.js.map +1 -1
- package/dist/hooks/useSelectionDialog.d.ts +20 -7
- package/dist/hooks/useSelectionDialog.js +29 -8
- package/dist/hooks/useSelectionDialog.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +15 -9
- package/dist/mcp-view.d.ts +9 -0
- package/dist/mcp-view.js +2 -0
- package/dist/mcp_view/app_modules.d.ts +29 -0
- package/dist/mcp_view/app_modules.js +163 -0
- package/dist/mcp_view/app_modules.js.map +1 -0
- package/dist/mcp_view/bridge.d.ts +90 -0
- package/dist/mcp_view/bridge.js +205 -0
- package/dist/mcp_view/bridge.js.map +1 -0
- package/dist/mcp_view/code_app.d.ts +65 -0
- package/dist/mcp_view/code_app.js +139 -0
- package/dist/mcp_view/code_app.js.map +1 -0
- package/dist/mcp_view/index.d.ts +48 -0
- package/dist/mcp_view/index.js +235 -0
- package/dist/mcp_view/index.js.map +1 -0
- package/dist/mcp_view/payload.d.ts +78 -0
- package/dist/mcp_view/payload.js +155 -0
- package/dist/mcp_view/payload.js.map +1 -0
- package/dist/mcp_view/screen.d.ts +28 -0
- package/dist/mcp_view/screen.js +223 -0
- package/dist/mcp_view/screen.js.map +1 -0
- package/dist/mcp_view/storage_source.d.ts +14 -0
- package/dist/mcp_view/storage_source.js +29 -0
- package/dist/mcp_view/storage_source.js.map +1 -0
- package/dist/mcp_view/store.d.ts +9 -0
- package/dist/mcp_view/store.js +27 -0
- package/dist/mcp_view/store.js.map +1 -0
- package/dist/mcp_view/tool_driver.d.ts +135 -0
- package/dist/mcp_view/tool_driver.js +527 -0
- package/dist/mcp_view/tool_driver.js.map +1 -0
- package/dist/preview/components/DatePreview.d.ts +34 -1
- package/dist/preview/components/DatePreview.js +72 -37
- package/dist/preview/components/DatePreview.js.map +1 -1
- package/dist/routes/RebaseRoute.js +1 -1
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/selection/SelectionMenu.d.ts +5 -3
- package/dist/selection/SelectionMenu.js +16 -9
- package/dist/selection/SelectionMenu.js.map +1 -1
- package/dist/selection/index.d.ts +2 -1
- package/dist/selection/resolve_selection.d.ts +61 -7
- package/dist/selection/resolve_selection.js +93 -11
- package/dist/selection/resolve_selection.js.map +1 -1
- package/dist/types/components/EntityFormProps.d.ts +60 -10
- package/dist/types/fields.d.ts +2 -65
- package/dist/util/dataControllerAdapter.d.ts +8 -0
- package/dist/util/dataControllerAdapter.js +11 -0
- package/dist/util/dataControllerAdapter.js.map +1 -1
- package/dist/util/navigation_utils.d.ts +5 -4
- package/dist/util/navigation_utils.js +6 -6
- package/dist/util/navigation_utils.js.map +1 -1
- package/dist/util/propertyConfigMapper.d.ts +8 -0
- package/dist/util/propertyConfigMapper.js +16 -2
- package/dist/util/propertyConfigMapper.js.map +1 -1
- package/package.json +15 -9
- package/recipes/README.md +79 -26
- package/recipes/approval-queue.tsx +79 -0
- package/recipes/bulk-set-status.tsx +23 -17
- package/recipes/calendar-view.tsx +28 -23
- package/recipes/master-detail.tsx +75 -0
- package/recipes/my-preferences.tsx +3 -3
- package/recipes/orders-dashboard.tsx +58 -84
- package/recipes/site-settings.tsx +4 -4
- package/dist/components/EntityFormPanel.d.ts +0 -63
- package/dist/components/EntityFormPanel.js.map +0 -1
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
//#region src/mcp_view/bridge.ts
|
|
2
|
+
/**
|
|
3
|
+
* The view's side of the MCP Apps protocol (`io.modelcontextprotocol/ui`,
|
|
4
|
+
* revision 2026-01-26): JSON-RPC 2.0 over `postMessage` with the host window.
|
|
5
|
+
*
|
|
6
|
+
* Hand-written rather than taken from `@modelcontextprotocol/ext-apps`, whose
|
|
7
|
+
* `App` carries the MCP SDK and zod — half a megabyte, in a document a host
|
|
8
|
+
* downloads for every table it shows. A view needs a handful of messages:
|
|
9
|
+
*
|
|
10
|
+
* - `ui/initialize` → the host's context (theme, display mode), then
|
|
11
|
+
* `ui/notifications/initialized`;
|
|
12
|
+
* - the host's `ui/notifications/tool-input` and `…/tool-result`: the call
|
|
13
|
+
* that opened this view, and its answer;
|
|
14
|
+
* - `tools/call`, which the host relays to the MCP server with its own
|
|
15
|
+
* credential — the view holds none;
|
|
16
|
+
* - `ui/update-model-context`, to tell the model what the person did here;
|
|
17
|
+
* - `ui/notifications/size-changed`, so the host sizes the iframe to fit;
|
|
18
|
+
* - `ui/request-display-mode`, to open the view fullscreen where the host
|
|
19
|
+
* offers it.
|
|
20
|
+
*/
|
|
21
|
+
var APPS_PROTOCOL_VERSION = "2026-01-26";
|
|
22
|
+
/** The modes this view can be shown in. Declared at the handshake. */
|
|
23
|
+
var VIEW_DISPLAY_MODES = ["inline", "fullscreen"];
|
|
24
|
+
var McpAppBridge = class {
|
|
25
|
+
onhostcontext;
|
|
26
|
+
/** Everything the host has said about its context so far, each update merged in. */
|
|
27
|
+
hostContext = {};
|
|
28
|
+
contextWatchers = /* @__PURE__ */ new Set();
|
|
29
|
+
/** Called with the whole context now and on every change; returns the unsubscribe. */
|
|
30
|
+
watchHostContext(watcher) {
|
|
31
|
+
this.contextWatchers.add(watcher);
|
|
32
|
+
watcher(this.hostContext);
|
|
33
|
+
return () => {
|
|
34
|
+
this.contextWatchers.delete(watcher);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The call that opened this view, and its answer. Kept, because the host
|
|
39
|
+
* may send them before a handler is set — a React effect runs after the
|
|
40
|
+
* first paint — and it sends each once.
|
|
41
|
+
*/
|
|
42
|
+
toolInput;
|
|
43
|
+
toolResult;
|
|
44
|
+
inputHandler;
|
|
45
|
+
resultHandler;
|
|
46
|
+
set ontoolinput(handler) {
|
|
47
|
+
this.inputHandler = handler;
|
|
48
|
+
if (handler && this.toolInput) handler(this.toolInput);
|
|
49
|
+
}
|
|
50
|
+
set ontoolresult(handler) {
|
|
51
|
+
this.resultHandler = handler;
|
|
52
|
+
if (handler && this.toolResult) handler(this.toolResult);
|
|
53
|
+
}
|
|
54
|
+
nextId = 1;
|
|
55
|
+
connected = false;
|
|
56
|
+
height;
|
|
57
|
+
pending = /* @__PURE__ */ new Map();
|
|
58
|
+
host;
|
|
59
|
+
/** `events` is where the host's messages arrive: this view's window. */
|
|
60
|
+
constructor(host = window.parent, events = window) {
|
|
61
|
+
this.host = host;
|
|
62
|
+
events.addEventListener("message", this.receive);
|
|
63
|
+
}
|
|
64
|
+
async connect(appInfo) {
|
|
65
|
+
const result = await this.request("ui/initialize", {
|
|
66
|
+
appInfo,
|
|
67
|
+
appCapabilities: { availableDisplayModes: VIEW_DISPLAY_MODES },
|
|
68
|
+
protocolVersion: APPS_PROTOCOL_VERSION
|
|
69
|
+
});
|
|
70
|
+
if (isRecord(result) && isRecord(result.hostContext)) this.contextChanged(hostContextOf(result.hostContext));
|
|
71
|
+
this.notify("ui/notifications/initialized", {});
|
|
72
|
+
this.connected = true;
|
|
73
|
+
if (this.height !== void 0) this.notify("ui/notifications/size-changed", { height: this.height });
|
|
74
|
+
}
|
|
75
|
+
/** A tool on this view's MCP server, called through the host. */
|
|
76
|
+
async callTool(name, args) {
|
|
77
|
+
const result = await this.request("tools/call", {
|
|
78
|
+
name,
|
|
79
|
+
arguments: args
|
|
80
|
+
});
|
|
81
|
+
return isRecord(result) ? toolResultOf(result) : {};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* What the model should know about this view, sent with the person's next
|
|
85
|
+
* message. Each call replaces the last.
|
|
86
|
+
*/
|
|
87
|
+
async updateModelContext(text) {
|
|
88
|
+
await this.request("ui/update-model-context", { content: [{
|
|
89
|
+
type: "text",
|
|
90
|
+
text
|
|
91
|
+
}] });
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Ask the host to show this view in `mode`. The answer is the mode it is
|
|
95
|
+
* in now, which may not be the one asked for.
|
|
96
|
+
*/
|
|
97
|
+
async requestDisplayMode(mode) {
|
|
98
|
+
const result = await this.request("ui/request-display-mode", { mode });
|
|
99
|
+
return isRecord(result) && isDisplayMode(result.mode) ? result.mode : void 0;
|
|
100
|
+
}
|
|
101
|
+
/** The document's height, for the host to size the iframe to. Sent when it changes. */
|
|
102
|
+
sizeChanged(height) {
|
|
103
|
+
if (height === this.height) return;
|
|
104
|
+
this.height = height;
|
|
105
|
+
if (this.connected) this.notify("ui/notifications/size-changed", { height });
|
|
106
|
+
}
|
|
107
|
+
contextChanged(update) {
|
|
108
|
+
this.hostContext = {
|
|
109
|
+
...this.hostContext,
|
|
110
|
+
...update
|
|
111
|
+
};
|
|
112
|
+
this.onhostcontext?.(update);
|
|
113
|
+
for (const watcher of this.contextWatchers) watcher(this.hostContext);
|
|
114
|
+
}
|
|
115
|
+
request(method, params) {
|
|
116
|
+
const id = this.nextId++;
|
|
117
|
+
return new Promise((resolve, reject) => {
|
|
118
|
+
this.pending.set(id, {
|
|
119
|
+
resolve,
|
|
120
|
+
reject
|
|
121
|
+
});
|
|
122
|
+
this.host.postMessage({
|
|
123
|
+
jsonrpc: "2.0",
|
|
124
|
+
id,
|
|
125
|
+
method,
|
|
126
|
+
params
|
|
127
|
+
}, "*");
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
notify(method, params) {
|
|
131
|
+
this.host.postMessage({
|
|
132
|
+
jsonrpc: "2.0",
|
|
133
|
+
method,
|
|
134
|
+
params
|
|
135
|
+
}, "*");
|
|
136
|
+
}
|
|
137
|
+
respond(id, result) {
|
|
138
|
+
this.host.postMessage({
|
|
139
|
+
jsonrpc: "2.0",
|
|
140
|
+
id,
|
|
141
|
+
result
|
|
142
|
+
}, "*");
|
|
143
|
+
}
|
|
144
|
+
receive = (event) => {
|
|
145
|
+
if (!(event instanceof MessageEvent) || event.source !== this.host) return;
|
|
146
|
+
const message = event.data;
|
|
147
|
+
if (!isRecord(message) || message.jsonrpc !== "2.0") return;
|
|
148
|
+
const id = typeof message.id === "string" || typeof message.id === "number" ? message.id : void 0;
|
|
149
|
+
if (id !== void 0 && ("result" in message || "error" in message)) {
|
|
150
|
+
const pending = this.pending.get(id);
|
|
151
|
+
if (!pending) return;
|
|
152
|
+
this.pending.delete(id);
|
|
153
|
+
if (isRecord(message.error)) pending.reject(new Error(String(message.error.message ?? "The host refused the request.")));
|
|
154
|
+
else pending.resolve(message.result);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const params = isRecord(message.params) ? message.params : {};
|
|
158
|
+
switch (message.method) {
|
|
159
|
+
case "ui/notifications/tool-input":
|
|
160
|
+
this.toolInput = isRecord(params.arguments) ? params.arguments : {};
|
|
161
|
+
this.inputHandler?.(this.toolInput);
|
|
162
|
+
return;
|
|
163
|
+
case "ui/notifications/tool-result":
|
|
164
|
+
this.toolResult = toolResultOf(params);
|
|
165
|
+
this.resultHandler?.(this.toolResult);
|
|
166
|
+
return;
|
|
167
|
+
case "ui/notifications/host-context-changed":
|
|
168
|
+
this.contextChanged(hostContextOf(params));
|
|
169
|
+
return;
|
|
170
|
+
case "ui/resource-teardown":
|
|
171
|
+
case "ping":
|
|
172
|
+
if (id !== void 0) this.respond(id, {});
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
function toolResultOf(value) {
|
|
178
|
+
return {
|
|
179
|
+
content: Array.isArray(value.content) ? value.content.filter(isRecord).map((block) => ({
|
|
180
|
+
type: String(block.type),
|
|
181
|
+
...typeof block.text === "string" && { text: block.text }
|
|
182
|
+
})) : void 0,
|
|
183
|
+
structuredContent: value.structuredContent,
|
|
184
|
+
isError: value.isError === true
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/** The fields of the host's context this view reads. A partial update leaves the rest out. */
|
|
188
|
+
function hostContextOf(value) {
|
|
189
|
+
return {
|
|
190
|
+
...(value.theme === "light" || value.theme === "dark") && { theme: value.theme },
|
|
191
|
+
...isDisplayMode(value.displayMode) && { displayMode: value.displayMode },
|
|
192
|
+
...Array.isArray(value.availableDisplayModes) && { availableDisplayModes: value.availableDisplayModes.filter(isDisplayMode) },
|
|
193
|
+
...typeof value.locale === "string" && { locale: value.locale }
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function isDisplayMode(value) {
|
|
197
|
+
return value === "inline" || value === "fullscreen" || value === "pip";
|
|
198
|
+
}
|
|
199
|
+
function isRecord(value) {
|
|
200
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
201
|
+
}
|
|
202
|
+
//#endregion
|
|
203
|
+
export { APPS_PROTOCOL_VERSION, McpAppBridge, isRecord };
|
|
204
|
+
|
|
205
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","names":[],"sources":["../../src/mcp_view/bridge.ts"],"sourcesContent":["/**\n * The view's side of the MCP Apps protocol (`io.modelcontextprotocol/ui`,\n * revision 2026-01-26): JSON-RPC 2.0 over `postMessage` with the host window.\n *\n * Hand-written rather than taken from `@modelcontextprotocol/ext-apps`, whose\n * `App` carries the MCP SDK and zod — half a megabyte, in a document a host\n * downloads for every table it shows. A view needs a handful of messages:\n *\n * - `ui/initialize` → the host's context (theme, display mode), then\n * `ui/notifications/initialized`;\n * - the host's `ui/notifications/tool-input` and `…/tool-result`: the call\n * that opened this view, and its answer;\n * - `tools/call`, which the host relays to the MCP server with its own\n * credential — the view holds none;\n * - `ui/update-model-context`, to tell the model what the person did here;\n * - `ui/notifications/size-changed`, so the host sizes the iframe to fit;\n * - `ui/request-display-mode`, to open the view fullscreen where the host\n * offers it.\n */\n\nexport const APPS_PROTOCOL_VERSION = \"2026-01-26\";\n\nexport interface ToolResult {\n content?: Array<{ type: string; text?: string }>;\n structuredContent?: unknown;\n isError?: boolean;\n}\n\nexport type DisplayMode = \"inline\" | \"fullscreen\" | \"pip\";\n\n/** The modes this view can be shown in. Declared at the handshake. */\nconst VIEW_DISPLAY_MODES: DisplayMode[] = [\"inline\", \"fullscreen\"];\n\nexport interface HostContext {\n theme?: \"light\" | \"dark\";\n displayMode?: DisplayMode;\n /** The modes the host will show this view in; absent, only the one it is in. */\n availableDisplayModes?: DisplayMode[];\n locale?: string;\n}\n\ninterface Pending {\n resolve: (result: unknown) => void;\n reject: (error: Error) => void;\n}\n\ntype JsonRpcId = string | number;\n\n/** The host end of the channel: the parent window, in a host. */\nexport interface HostWindow {\n postMessage(message: unknown, targetOrigin: string): void;\n}\n\nexport class McpAppBridge {\n onhostcontext?: (context: HostContext) => void;\n\n /** Everything the host has said about its context so far, each update merged in. */\n hostContext: HostContext = {};\n private readonly contextWatchers = new Set<(context: HostContext) => void>();\n\n /** Called with the whole context now and on every change; returns the unsubscribe. */\n watchHostContext(watcher: (context: HostContext) => void): () => void {\n this.contextWatchers.add(watcher);\n watcher(this.hostContext);\n return () => {\n this.contextWatchers.delete(watcher);\n };\n }\n\n /**\n * The call that opened this view, and its answer. Kept, because the host\n * may send them before a handler is set — a React effect runs after the\n * first paint — and it sends each once.\n */\n toolInput?: Record<string, unknown>;\n toolResult?: ToolResult;\n private inputHandler?: (args: Record<string, unknown>) => void;\n private resultHandler?: (result: ToolResult) => void;\n\n set ontoolinput(handler: ((args: Record<string, unknown>) => void) | undefined) {\n this.inputHandler = handler;\n if (handler && this.toolInput) handler(this.toolInput);\n }\n\n set ontoolresult(handler: ((result: ToolResult) => void) | undefined) {\n this.resultHandler = handler;\n if (handler && this.toolResult) handler(this.toolResult);\n }\n\n private nextId = 1;\n private connected = false;\n private height?: number;\n private readonly pending = new Map<JsonRpcId, Pending>();\n private readonly host: HostWindow;\n\n /** `events` is where the host's messages arrive: this view's window. */\n constructor(host: HostWindow = window.parent, events: EventTarget = window) {\n this.host = host;\n events.addEventListener(\"message\", this.receive);\n }\n\n async connect(appInfo: { name: string; version: string }): Promise<void> {\n const result = await this.request(\"ui/initialize\", {\n appInfo,\n appCapabilities: { availableDisplayModes: VIEW_DISPLAY_MODES },\n protocolVersion: APPS_PROTOCOL_VERSION\n });\n if (isRecord(result) && isRecord(result.hostContext)) this.contextChanged(hostContextOf(result.hostContext));\n this.notify(\"ui/notifications/initialized\", {});\n this.connected = true;\n // A size measured before the handshake is held until now: nothing\n // but `ui/initialize` may reach the host before it.\n if (this.height !== undefined) this.notify(\"ui/notifications/size-changed\", { height: this.height });\n }\n\n /** A tool on this view's MCP server, called through the host. */\n async callTool(name: string, args: Record<string, unknown>): Promise<ToolResult> {\n const result = await this.request(\"tools/call\", { name, arguments: args });\n return isRecord(result) ? toolResultOf(result) : {};\n }\n\n /**\n * What the model should know about this view, sent with the person's next\n * message. Each call replaces the last.\n */\n async updateModelContext(text: string): Promise<void> {\n await this.request(\"ui/update-model-context\", { content: [{ type: \"text\", text }] });\n }\n\n /**\n * Ask the host to show this view in `mode`. The answer is the mode it is\n * in now, which may not be the one asked for.\n */\n async requestDisplayMode(mode: DisplayMode): Promise<DisplayMode | undefined> {\n const result = await this.request(\"ui/request-display-mode\", { mode });\n return isRecord(result) && isDisplayMode(result.mode) ? result.mode : undefined;\n }\n\n /** The document's height, for the host to size the iframe to. Sent when it changes. */\n sizeChanged(height: number): void {\n if (height === this.height) return;\n this.height = height;\n if (this.connected) this.notify(\"ui/notifications/size-changed\", { height });\n }\n\n private contextChanged(update: HostContext): void {\n this.hostContext = { ...this.hostContext, ...update };\n this.onhostcontext?.(update);\n for (const watcher of this.contextWatchers) watcher(this.hostContext);\n }\n\n private request(method: string, params: Record<string, unknown>): Promise<unknown> {\n const id = this.nextId++;\n return new Promise((resolve, reject) => {\n this.pending.set(id, { resolve, reject });\n this.host.postMessage({ jsonrpc: \"2.0\", id, method, params }, \"*\");\n });\n }\n\n private notify(method: string, params: Record<string, unknown>): void {\n this.host.postMessage({ jsonrpc: \"2.0\", method, params }, \"*\");\n }\n\n private respond(id: JsonRpcId, result: Record<string, unknown>): void {\n this.host.postMessage({ jsonrpc: \"2.0\", id, result }, \"*\");\n }\n\n private readonly receive = (event: Event): void => {\n // Only the host speaks to this view. The sandbox gives the iframe an\n // opaque origin, so the window is the check, not the origin.\n if (!(event instanceof MessageEvent) || event.source !== this.host) return;\n const message: unknown = event.data;\n if (!isRecord(message) || message.jsonrpc !== \"2.0\") return;\n const id = typeof message.id === \"string\" || typeof message.id === \"number\" ? message.id : undefined;\n\n if (id !== undefined && (\"result\" in message || \"error\" in message)) {\n const pending = this.pending.get(id);\n if (!pending) return;\n this.pending.delete(id);\n if (isRecord(message.error)) pending.reject(new Error(String(message.error.message ?? \"The host refused the request.\")));\n else pending.resolve(message.result);\n return;\n }\n\n const params = isRecord(message.params) ? message.params : {};\n switch (message.method) {\n case \"ui/notifications/tool-input\":\n this.toolInput = isRecord(params.arguments) ? params.arguments : {};\n this.inputHandler?.(this.toolInput);\n return;\n case \"ui/notifications/tool-result\":\n this.toolResult = toolResultOf(params);\n this.resultHandler?.(this.toolResult);\n return;\n case \"ui/notifications/host-context-changed\":\n this.contextChanged(hostContextOf(params));\n return;\n // Requests the host may send. Nothing to clean up, nothing to report.\n case \"ui/resource-teardown\":\n case \"ping\":\n if (id !== undefined) this.respond(id, {});\n return;\n }\n };\n}\n\nfunction toolResultOf(value: Record<string, unknown>): ToolResult {\n return {\n content: Array.isArray(value.content)\n ? value.content.filter(isRecord).map(block => ({\n type: String(block.type),\n ...(typeof block.text === \"string\" && { text: block.text })\n }))\n : undefined,\n structuredContent: value.structuredContent,\n isError: value.isError === true\n };\n}\n\n/** The fields of the host's context this view reads. A partial update leaves the rest out. */\nfunction hostContextOf(value: Record<string, unknown>): HostContext {\n return {\n ...((value.theme === \"light\" || value.theme === \"dark\") && { theme: value.theme }),\n ...(isDisplayMode(value.displayMode) && { displayMode: value.displayMode }),\n ...(Array.isArray(value.availableDisplayModes) && {\n availableDisplayModes: value.availableDisplayModes.filter(isDisplayMode)\n }),\n ...(typeof value.locale === \"string\" && { locale: value.locale })\n };\n}\n\nfunction isDisplayMode(value: unknown): value is DisplayMode {\n return value === \"inline\" || value === \"fullscreen\" || value === \"pip\";\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Running an app the model wrote (show_app): its compiled module, the
|
|
3
|
+
* modules it may import, and what happens when it fails.
|
|
4
|
+
*
|
|
5
|
+
* The server compiled it to CommonJS with the source's line numbers,
|
|
6
|
+
* refusing any import `MCP_APP_MODULES` does not list. Here it is evaluated
|
|
7
|
+
* with a `require` that hands out those modules (`app_modules.tsx`) — the
|
|
8
|
+
* view's own copies, so the app's components live in the same React tree as
|
|
9
|
+
* the admin panel's — each one refusing, by name, an export it does not serve.
|
|
10
|
+
*
|
|
11
|
+
* The code runs in this frame, as the view does: it reaches the project
|
|
12
|
+
* through the same tools, as the same person, so it can do nothing the model
|
|
13
|
+
* could not do with those tools — that person's RLS and their connection's
|
|
14
|
+
* scopes are the boundary. `useRowWrites` asks them before it writes, so an
|
|
15
|
+
* app does not write without their click; it is a courtesy, not that
|
|
16
|
+
* boundary, since code in this frame can also post `tools/call` itself. A
|
|
17
|
+
* failure — at load or while drawing — is shown in place of the app and told
|
|
18
|
+
* to the model, with the line it wrote.
|
|
19
|
+
*/
|
|
20
|
+
import React from "react";
|
|
21
|
+
type AppFactory = (require: (name: string) => object, module: {
|
|
22
|
+
exports: Record<string, unknown>;
|
|
23
|
+
}, exports: Record<string, unknown>) => void;
|
|
24
|
+
declare global {
|
|
25
|
+
interface Window {
|
|
26
|
+
/** Where an app's module lands when it is evaluated as a script. */
|
|
27
|
+
__rebaseApps?: Record<string, AppFactory>;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export interface LoadedApp {
|
|
31
|
+
Component?: React.ComponentType;
|
|
32
|
+
error?: AppError;
|
|
33
|
+
lineOffset: number;
|
|
34
|
+
}
|
|
35
|
+
export interface AppError {
|
|
36
|
+
message: string;
|
|
37
|
+
/** The line of the model's source, where the trace names one. */
|
|
38
|
+
line?: number;
|
|
39
|
+
}
|
|
40
|
+
/** Evaluate the app's module and take its default export. */
|
|
41
|
+
export declare function loadApp(code: string): LoadedApp;
|
|
42
|
+
/** An error's message, and the line of the app's code its trace points at. */
|
|
43
|
+
export declare function appErrorOf(error: unknown, lineOffset: number): AppError;
|
|
44
|
+
/** What the model is told when the app fails, so the person's next message reaches it with the fix to make. */
|
|
45
|
+
export declare function describeAppError(error: AppError): string;
|
|
46
|
+
interface BoundaryProps {
|
|
47
|
+
lineOffset: number;
|
|
48
|
+
onError: (error: AppError) => void;
|
|
49
|
+
fallback: (error: AppError) => React.ReactNode;
|
|
50
|
+
children: React.ReactNode;
|
|
51
|
+
}
|
|
52
|
+
/** Catches what the app throws while it draws. */
|
|
53
|
+
export declare class AppErrorBoundary extends React.Component<BoundaryProps, {
|
|
54
|
+
error?: AppError;
|
|
55
|
+
}> {
|
|
56
|
+
state: {
|
|
57
|
+
error?: AppError;
|
|
58
|
+
};
|
|
59
|
+
static getDerivedStateFromError(): {
|
|
60
|
+
error: AppError;
|
|
61
|
+
};
|
|
62
|
+
componentDidCatch(error: unknown): void;
|
|
63
|
+
render(): React.ReactNode;
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { APP_MODULE_EXPORTS } from "./app_modules.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { MCP_APP_MODULES } from "@rebasepro/types";
|
|
4
|
+
//#region src/mcp_view/code_app.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Running an app the model wrote (show_app): its compiled module, the
|
|
7
|
+
* modules it may import, and what happens when it fails.
|
|
8
|
+
*
|
|
9
|
+
* The server compiled it to CommonJS with the source's line numbers,
|
|
10
|
+
* refusing any import `MCP_APP_MODULES` does not list. Here it is evaluated
|
|
11
|
+
* with a `require` that hands out those modules (`app_modules.tsx`) — the
|
|
12
|
+
* view's own copies, so the app's components live in the same React tree as
|
|
13
|
+
* the admin panel's — each one refusing, by name, an export it does not serve.
|
|
14
|
+
*
|
|
15
|
+
* The code runs in this frame, as the view does: it reaches the project
|
|
16
|
+
* through the same tools, as the same person, so it can do nothing the model
|
|
17
|
+
* could not do with those tools — that person's RLS and their connection's
|
|
18
|
+
* scopes are the boundary. `useRowWrites` asks them before it writes, so an
|
|
19
|
+
* app does not write without their click; it is a courtesy, not that
|
|
20
|
+
* boundary, since code in this frame can also post `tools/call` itself. A
|
|
21
|
+
* failure — at load or while drawing — is shown in place of the app and told
|
|
22
|
+
* to the model, with the line it wrote.
|
|
23
|
+
*/
|
|
24
|
+
/** A module as the app sees it: a missing export is an error that names it, not `undefined` three calls later. */
|
|
25
|
+
function strict(name, exports) {
|
|
26
|
+
const served = MCP_APP_MODULES[name];
|
|
27
|
+
return new Proxy(exports, { get(target, property, receiver) {
|
|
28
|
+
if (typeof property === "symbol" || property === "then") return Reflect.get(target, property, receiver);
|
|
29
|
+
if (property === "__esModule") return true;
|
|
30
|
+
if (property in target) return Reflect.get(target, property, receiver);
|
|
31
|
+
if (property === "default") return target;
|
|
32
|
+
throw new Error(served === "*" ? `"${property}" is not exported by "${name}".` : `"${property}" is not one of the "${name}" exports this view serves (${served.join(", ")}).`);
|
|
33
|
+
} });
|
|
34
|
+
}
|
|
35
|
+
function isAppModule(name) {
|
|
36
|
+
return Object.hasOwn(MCP_APP_MODULES, name);
|
|
37
|
+
}
|
|
38
|
+
function requireModule(name) {
|
|
39
|
+
if (!isAppModule(name)) throw new Error(`The app imports "${name}", which this view does not provide.`);
|
|
40
|
+
return strict(name, APP_MODULE_EXPORTS[name]);
|
|
41
|
+
}
|
|
42
|
+
/** The name a stack trace gives the app's code. */
|
|
43
|
+
var APP_SOURCE_URL = "rebase-app.js";
|
|
44
|
+
var loads = 0;
|
|
45
|
+
/**
|
|
46
|
+
* The app's module as a function, and how many lines its code sits below
|
|
47
|
+
* the line the model wrote.
|
|
48
|
+
*
|
|
49
|
+
* As a script element first: a sandbox that runs the view's own inline
|
|
50
|
+
* scripts runs this one, and it keeps the source's line numbers. A host
|
|
51
|
+
* whose policy refuses an inserted script may still allow `Function`, which
|
|
52
|
+
* puts the code two lines down.
|
|
53
|
+
*/
|
|
54
|
+
function evaluate(code) {
|
|
55
|
+
const id = `app${++loads}`;
|
|
56
|
+
const registry = window.__rebaseApps ??= {};
|
|
57
|
+
const script = document.createElement("script");
|
|
58
|
+
script.textContent = `(window.__rebaseApps = window.__rebaseApps || {})[${JSON.stringify(id)}] = function (require, module, exports) {${code}\n};\n//# sourceURL=${APP_SOURCE_URL}`;
|
|
59
|
+
document.head.appendChild(script);
|
|
60
|
+
script.remove();
|
|
61
|
+
const loaded = registry[id];
|
|
62
|
+
delete registry[id];
|
|
63
|
+
if (loaded) return {
|
|
64
|
+
factory: loaded,
|
|
65
|
+
lineOffset: 0
|
|
66
|
+
};
|
|
67
|
+
try {
|
|
68
|
+
const compiled = new Function("require", "module", "exports", `${code}\n//# sourceURL=${APP_SOURCE_URL}`);
|
|
69
|
+
const factory = (require, module, exports) => compiled(require, module, exports);
|
|
70
|
+
return {
|
|
71
|
+
factory,
|
|
72
|
+
lineOffset: 2
|
|
73
|
+
};
|
|
74
|
+
} catch {
|
|
75
|
+
throw new Error("This client's sandbox does not let the view run an app's code.");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** Evaluate the app's module and take its default export. */
|
|
79
|
+
function loadApp(code) {
|
|
80
|
+
let lineOffset = 0;
|
|
81
|
+
try {
|
|
82
|
+
const evaluated = evaluate(code);
|
|
83
|
+
lineOffset = evaluated.lineOffset;
|
|
84
|
+
const module = { exports: {} };
|
|
85
|
+
evaluated.factory(requireModule, module, module.exports);
|
|
86
|
+
const Component = module.exports.default;
|
|
87
|
+
if (!isComponent(Component)) return {
|
|
88
|
+
error: { message: "The app's default export is not a component." },
|
|
89
|
+
lineOffset
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
Component,
|
|
93
|
+
lineOffset
|
|
94
|
+
};
|
|
95
|
+
} catch (error) {
|
|
96
|
+
return {
|
|
97
|
+
error: appErrorOf(error, lineOffset),
|
|
98
|
+
lineOffset
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/** A function component, or what `memo` and `forwardRef` make of one. */
|
|
103
|
+
function isComponent(value) {
|
|
104
|
+
return typeof value === "function" || typeof value === "object" && value !== null && "$$typeof" in value;
|
|
105
|
+
}
|
|
106
|
+
/** An error's message, and the line of the app's code its trace points at. */
|
|
107
|
+
function appErrorOf(error, lineOffset) {
|
|
108
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
109
|
+
const stack = error instanceof Error ? error.stack ?? "" : "";
|
|
110
|
+
const match = new RegExp(`${APP_SOURCE_URL.replace(".", "\\.")}:(\\d+)`).exec(stack);
|
|
111
|
+
const line = match ? Number(match[1]) - lineOffset : void 0;
|
|
112
|
+
return {
|
|
113
|
+
message,
|
|
114
|
+
...line !== void 0 && line > 0 && { line }
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** What the model is told when the app fails, so the person's next message reaches it with the fix to make. */
|
|
118
|
+
function describeAppError(error) {
|
|
119
|
+
return `The app opened with show_app failed: ${error.message}${error.line ? ` (line ${error.line} of its code)` : ""}. Fix the code and call show_app again.`;
|
|
120
|
+
}
|
|
121
|
+
/** Catches what the app throws while it draws. */
|
|
122
|
+
var AppErrorBoundary = class extends React.Component {
|
|
123
|
+
state = {};
|
|
124
|
+
static getDerivedStateFromError() {
|
|
125
|
+
return { error: { message: "" } };
|
|
126
|
+
}
|
|
127
|
+
componentDidCatch(error) {
|
|
128
|
+
const described = appErrorOf(error, this.props.lineOffset);
|
|
129
|
+
this.setState({ error: described });
|
|
130
|
+
this.props.onError(described);
|
|
131
|
+
}
|
|
132
|
+
render() {
|
|
133
|
+
return this.state.error ? this.props.fallback(this.state.error) : this.props.children;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
//#endregion
|
|
137
|
+
export { AppErrorBoundary, appErrorOf, describeAppError, loadApp };
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=code_app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code_app.js","names":[],"sources":["../../src/mcp_view/code_app.tsx"],"sourcesContent":["/**\n * Running an app the model wrote (show_app): its compiled module, the\n * modules it may import, and what happens when it fails.\n *\n * The server compiled it to CommonJS with the source's line numbers,\n * refusing any import `MCP_APP_MODULES` does not list. Here it is evaluated\n * with a `require` that hands out those modules (`app_modules.tsx`) — the\n * view's own copies, so the app's components live in the same React tree as\n * the admin panel's — each one refusing, by name, an export it does not serve.\n *\n * The code runs in this frame, as the view does: it reaches the project\n * through the same tools, as the same person, so it can do nothing the model\n * could not do with those tools — that person's RLS and their connection's\n * scopes are the boundary. `useRowWrites` asks them before it writes, so an\n * app does not write without their click; it is a courtesy, not that\n * boundary, since code in this frame can also post `tools/call` itself. A\n * failure — at load or while drawing — is shown in place of the app and told\n * to the model, with the line it wrote.\n */\nimport React from \"react\";\nimport { MCP_APP_MODULES, type McpAppModule } from \"@rebasepro/types\";\nimport { APP_MODULE_EXPORTS } from \"./app_modules\";\n\n/** A module as the app sees it: a missing export is an error that names it, not `undefined` three calls later. */\nfunction strict(name: McpAppModule, exports: object): object {\n const served = MCP_APP_MODULES[name];\n return new Proxy(exports, {\n get(target, property, receiver) {\n if (typeof property === \"symbol\" || property === \"then\") return Reflect.get(target, property, receiver);\n if (property === \"__esModule\") return true;\n if (property in target) return Reflect.get(target, property, receiver);\n // `import React from \"react\"`: the module is its own default.\n if (property === \"default\") return target;\n throw new Error(served === \"*\"\n ? `\"${property}\" is not exported by \"${name}\".`\n : `\"${property}\" is not one of the \"${name}\" exports this view serves (${served.join(\", \")}).`);\n }\n });\n}\n\nfunction isAppModule(name: string): name is McpAppModule {\n return Object.hasOwn(MCP_APP_MODULES, name);\n}\n\nfunction requireModule(name: string): object {\n if (!isAppModule(name)) throw new Error(`The app imports \"${name}\", which this view does not provide.`);\n return strict(name, APP_MODULE_EXPORTS[name]);\n}\n\ntype AppFactory = (require: (name: string) => object, module: { exports: Record<string, unknown> }, exports: Record<string, unknown>) => void;\n\ndeclare global {\n interface Window {\n /** Where an app's module lands when it is evaluated as a script. */\n __rebaseApps?: Record<string, AppFactory>;\n }\n}\n\n/** The name a stack trace gives the app's code. */\nconst APP_SOURCE_URL = \"rebase-app.js\";\n\nlet loads = 0;\n\n/**\n * The app's module as a function, and how many lines its code sits below\n * the line the model wrote.\n *\n * As a script element first: a sandbox that runs the view's own inline\n * scripts runs this one, and it keeps the source's line numbers. A host\n * whose policy refuses an inserted script may still allow `Function`, which\n * puts the code two lines down.\n */\nfunction evaluate(code: string): { factory: AppFactory; lineOffset: number } {\n const id = `app${++loads}`;\n const registry = window.__rebaseApps ??= {};\n const script = document.createElement(\"script\");\n script.textContent = `(window.__rebaseApps = window.__rebaseApps || {})[${JSON.stringify(id)}] = function (require, module, exports) {${code}\\n};\\n//# sourceURL=${APP_SOURCE_URL}`;\n document.head.appendChild(script);\n script.remove();\n const loaded = registry[id];\n delete registry[id];\n if (loaded) return { factory: loaded, lineOffset: 0 };\n try {\n // A script the policy refused leaves nothing behind; this is the other way in.\n const compiled = new Function(\"require\", \"module\", \"exports\", `${code}\\n//# sourceURL=${APP_SOURCE_URL}`);\n const factory: AppFactory = (require, module, exports) => compiled(require, module, exports);\n return { factory, lineOffset: 2 };\n } catch {\n throw new Error(\"This client's sandbox does not let the view run an app's code.\");\n }\n}\n\nexport interface LoadedApp {\n Component?: React.ComponentType;\n error?: AppError;\n lineOffset: number;\n}\n\nexport interface AppError {\n message: string;\n /** The line of the model's source, where the trace names one. */\n line?: number;\n}\n\n/** Evaluate the app's module and take its default export. */\nexport function loadApp(code: string): LoadedApp {\n let lineOffset = 0;\n try {\n const evaluated = evaluate(code);\n lineOffset = evaluated.lineOffset;\n const module: { exports: Record<string, unknown> } = { exports: {} };\n evaluated.factory(requireModule, module, module.exports);\n const Component = module.exports.default;\n if (!isComponent(Component)) {\n return { error: { message: \"The app's default export is not a component.\" }, lineOffset };\n }\n return { Component, lineOffset };\n } catch (error) {\n return { error: appErrorOf(error, lineOffset), lineOffset };\n }\n}\n\n/** A function component, or what `memo` and `forwardRef` make of one. */\nfunction isComponent(value: unknown): value is React.ComponentType {\n return typeof value === \"function\" || (typeof value === \"object\" && value !== null && \"$$typeof\" in value);\n}\n\n/** An error's message, and the line of the app's code its trace points at. */\nexport function appErrorOf(error: unknown, lineOffset: number): AppError {\n const message = error instanceof Error ? error.message : String(error);\n const stack = error instanceof Error ? error.stack ?? \"\" : \"\";\n const match = new RegExp(`${APP_SOURCE_URL.replace(\".\", \"\\\\.\")}:(\\\\d+)`).exec(stack);\n const line = match ? Number(match[1]) - lineOffset : undefined;\n return { message, ...(line !== undefined && line > 0 && { line }) };\n}\n\n/** What the model is told when the app fails, so the person's next message reaches it with the fix to make. */\nexport function describeAppError(error: AppError): string {\n return `The app opened with show_app failed: ${error.message}${error.line ? ` (line ${error.line} of its code)` : \"\"}. `\n + \"Fix the code and call show_app again.\";\n}\n\ninterface BoundaryProps {\n lineOffset: number;\n onError: (error: AppError) => void;\n fallback: (error: AppError) => React.ReactNode;\n children: React.ReactNode;\n}\n\n/** Catches what the app throws while it draws. */\nexport class AppErrorBoundary extends React.Component<BoundaryProps, { error?: AppError }> {\n state: { error?: AppError } = {};\n\n static getDerivedStateFromError(): { error: AppError } {\n return { error: { message: \"\" } };\n }\n\n componentDidCatch(error: unknown): void {\n const described = appErrorOf(error, this.props.lineOffset);\n this.setState({ error: described });\n this.props.onError(described);\n }\n\n render(): React.ReactNode {\n return this.state.error ? this.props.fallback(this.state.error) : this.props.children;\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
2
|
+
import { McpAppBridge } from "./bridge.js";
|
|
3
|
+
import { type Screen } from "./payload.js";
|
|
4
|
+
export { APPS_PROTOCOL_VERSION, McpAppBridge, isRecord } from "./bridge.js";
|
|
5
|
+
export type { HostContext, ToolResult, DisplayMode } from "./bridge.js";
|
|
6
|
+
export { createToolDriver, DEFAULT_ACTIONS, SaveCancelledError, describeChanges } from "./tool_driver.js";
|
|
7
|
+
export type { CallTool, SeedPage, ToolDriver, ViewActions, WritePlan, ViewChange } from "./tool_driver.js";
|
|
8
|
+
export { parseResult, actionsOf, filterOf } from "./payload.js";
|
|
9
|
+
export type { Screen, Block } from "./payload.js";
|
|
10
|
+
export interface McpViewOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Mount the app, once the host is set: import the project's entry (which
|
|
13
|
+
* renders its app as it would on its page), or render a default one into
|
|
14
|
+
* `#root`. Given the screen the tool opened, for an app with no
|
|
15
|
+
* collections of its own.
|
|
16
|
+
*/
|
|
17
|
+
mountApp: (screen: Screen) => void | Promise<unknown>;
|
|
18
|
+
/**
|
|
19
|
+
* Draw a result from a server that predates the admin panel's views
|
|
20
|
+
* (show_collection's columns only): the old table, where the view has it.
|
|
21
|
+
*/
|
|
22
|
+
mountTable?: (bridge: McpAppBridge, container: HTMLElement) => void;
|
|
23
|
+
/** Name and version the view gives the host. */
|
|
24
|
+
appInfo?: {
|
|
25
|
+
name: string;
|
|
26
|
+
version: string;
|
|
27
|
+
};
|
|
28
|
+
/** The channel to the host; a new one on this window's parent by default. */
|
|
29
|
+
bridge?: McpAppBridge;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Connect to the host, wait for the tool's result, set the embed host from
|
|
33
|
+
* it, and mount the app.
|
|
34
|
+
*/
|
|
35
|
+
export declare function startMcpView(options: McpViewOptions): McpAppBridge;
|
|
36
|
+
/**
|
|
37
|
+
* The app's collections as this person may see them here: the project's own
|
|
38
|
+
* configs — with their components — narrowed as the server narrowed the ones
|
|
39
|
+
* it sent (`McpViewPayload` in the server's `mcp/mcp-view.ts`). A field the
|
|
40
|
+
* server left out is left out; one it made read-only is read-only; its
|
|
41
|
+
* security rules (the project's, and the one closing what the connection was
|
|
42
|
+
* not granted) are the ones checked. A collection the server sent nothing
|
|
43
|
+
* for is shown with every change closed: this screen did not ask for it.
|
|
44
|
+
*
|
|
45
|
+
* Where the app has no collections of its own (the view without a project),
|
|
46
|
+
* the server's configs are the collections.
|
|
47
|
+
*/
|
|
48
|
+
export declare function narrowCollections(own: AdminCollection[], sent: readonly AdminCollection[]): AdminCollection[];
|