@deepseek-harness-tui/dsh-tui 0.8.0 → 0.8.2
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 +32 -15
- package/cordis.patch.yml +21 -2
- package/cordis.yml +12 -1
- package/dsh-ecosystem-spec/protocols/profile-definitions.d.ts +13 -0
- package/dsh-ecosystem-spec/protocols/profile-definitions.js +59 -0
- package/dsh-ecosystem-spec/protocols/tui-channel-http.d.ts +15 -0
- package/dsh-ecosystem-spec/protocols/tui-channel-http.js +32 -0
- package/dsh-ecosystem-spec/protocols/tui-channel.d.ts +59 -0
- package/dsh-ecosystem-spec/protocols/tui-channel.js +166 -0
- package/dsh-ecosystem-spec/protocols/tui-contributions.d.ts +42 -0
- package/dsh-ecosystem-spec/protocols/tui-contributions.js +143 -0
- package/dsh-ecosystem-spec/registry/README.md +14 -0
- package/dsh-ecosystem-spec/registry/contracts/decision-events-v1alpha1.json +13 -0
- package/dsh-ecosystem-spec/registry/contracts/scene-v1alpha1.json +13 -0
- package/dsh-ecosystem-spec/registry/contracts/settings-section-v1alpha1.json +13 -0
- package/dsh-ecosystem-spec/registry/contracts/tui-channel-v1alpha1.json +30 -0
- package/dsh-ecosystem-spec/registry/contracts/workspace-provider-v1alpha1.json +6 -0
- package/dsh-ecosystem-spec/registry/host-descriptor.tui.example.json +56 -0
- package/dsh-ecosystem-spec/registry/permissions-0.1.json +13 -0
- package/dsh-ecosystem-spec/registry/registry-0.15.json +149 -0
- package/dsh-ecosystem-spec/schemas/conformance-claim.schema.json +15 -0
- package/dsh-ecosystem-spec/schemas/effect-ledger-record.schema.json +16 -0
- package/dsh-ecosystem-spec/schemas/host-descriptor.schema.json +26 -0
- package/lib/types/cc/figures.d.ts +4 -0
- package/lib/types/cc/figures.d.ts.map +1 -1
- package/lib/types/cc/figures.js +4 -0
- package/lib/types/command-trees.d.ts +2 -1
- package/lib/types/command-trees.d.ts.map +1 -1
- package/lib/types/command-trees.js +1 -1
- package/lib/types/commands.d.ts.map +1 -1
- package/lib/types/commands.js +2 -0
- package/lib/types/components/ExtensionDialog.d.ts +40 -0
- package/lib/types/components/ExtensionDialog.d.ts.map +1 -0
- package/lib/types/components/ExtensionDialog.js +210 -0
- package/lib/types/components/HelpMenu.js +1 -1
- package/lib/types/components/LoadedContextPanel.d.ts +5 -5
- package/lib/types/components/LoadedContextPanel.js +6 -6
- package/lib/types/components/LogoV2.d.ts.map +1 -1
- package/lib/types/components/LogoV2.js +16 -8
- package/lib/types/components/Markdown.d.ts +13 -1
- package/lib/types/components/Markdown.d.ts.map +1 -1
- package/lib/types/components/Markdown.js +15 -1
- package/lib/types/components/MessageList.d.ts +3 -1
- package/lib/types/components/MessageList.d.ts.map +1 -1
- package/lib/types/components/MessageList.js +111 -6
- package/lib/types/components/PromptInput.d.ts.map +1 -1
- package/lib/types/components/PromptInput.js +26 -12
- package/lib/types/components/RewindPicker.d.ts +13 -1
- package/lib/types/components/RewindPicker.d.ts.map +1 -1
- package/lib/types/components/RewindPicker.js +26 -2
- package/lib/types/components/StreamingMarkdown.d.ts +2 -8
- package/lib/types/components/StreamingMarkdown.d.ts.map +1 -1
- package/lib/types/components/StreamingMarkdown.js +51 -9
- package/lib/types/components/ToolUseLoader.d.ts +8 -3
- package/lib/types/components/ToolUseLoader.d.ts.map +1 -1
- package/lib/types/components/ToolUseLoader.js +43 -9
- package/lib/types/components/activityFrames.d.ts +1 -1
- package/lib/types/components/activityFrames.d.ts.map +1 -1
- package/lib/types/components/activityFrames.js +4 -1
- package/lib/types/components/messages/AssistantThinkingMessage.d.ts +5 -1
- package/lib/types/components/messages/AssistantThinkingMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantThinkingMessage.js +26 -3
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantToolUseMessage.js +13 -2
- package/lib/types/dsh-adapter/channel.d.ts +61 -11
- package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel.js +767 -120
- package/lib/types/dsh-adapter/childStderr.d.ts.map +1 -1
- package/lib/types/dsh-adapter/childStderr.js +10 -0
- package/lib/types/dsh-adapter/command-attribution.d.ts +51 -0
- package/lib/types/dsh-adapter/command-attribution.d.ts.map +1 -0
- package/lib/types/dsh-adapter/command-attribution.js +93 -0
- package/lib/types/dsh-adapter/command-errors.d.ts +42 -0
- package/lib/types/dsh-adapter/command-errors.d.ts.map +1 -0
- package/lib/types/dsh-adapter/command-errors.js +63 -0
- package/lib/types/dsh-adapter/command-trees.d.ts +7 -1
- package/lib/types/dsh-adapter/command-trees.d.ts.map +1 -1
- package/lib/types/dsh-adapter/command-trees.js +70 -20
- package/lib/types/dsh-adapter/component-identity.d.ts +33 -0
- package/lib/types/dsh-adapter/component-identity.d.ts.map +1 -0
- package/lib/types/dsh-adapter/component-identity.js +108 -0
- package/lib/types/dsh-adapter/contract.d.ts +1 -1
- package/lib/types/dsh-adapter/contract.js +2 -2
- package/lib/types/dsh-adapter/decision-guard.d.ts +84 -0
- package/lib/types/dsh-adapter/decision-guard.d.ts.map +1 -0
- package/lib/types/dsh-adapter/decision-guard.js +348 -0
- package/lib/types/dsh-adapter/dialogs.d.ts +145 -0
- package/lib/types/dsh-adapter/dialogs.d.ts.map +1 -0
- package/lib/types/dsh-adapter/dialogs.js +316 -0
- package/lib/types/dsh-adapter/effect-ledger.d.ts +91 -0
- package/lib/types/dsh-adapter/effect-ledger.d.ts.map +1 -0
- package/lib/types/dsh-adapter/effect-ledger.js +251 -0
- package/lib/types/dsh-adapter/extension-events.d.ts +193 -0
- package/lib/types/dsh-adapter/extension-events.d.ts.map +1 -0
- package/lib/types/dsh-adapter/extension-events.js +207 -0
- package/lib/types/dsh-adapter/extensions.d.ts +32 -0
- package/lib/types/dsh-adapter/extensions.d.ts.map +1 -0
- package/lib/types/dsh-adapter/extensions.js +42 -0
- package/lib/types/dsh-adapter/grants.d.ts +25 -0
- package/lib/types/dsh-adapter/grants.d.ts.map +1 -0
- package/lib/types/dsh-adapter/grants.js +213 -0
- package/lib/types/dsh-adapter/host-access.d.ts +37 -0
- package/lib/types/dsh-adapter/host-access.d.ts.map +1 -0
- package/lib/types/dsh-adapter/host-access.js +652 -0
- package/lib/types/dsh-adapter/host-descriptor.d.ts +24 -0
- package/lib/types/dsh-adapter/host-descriptor.d.ts.map +1 -0
- package/lib/types/dsh-adapter/host-descriptor.js +169 -0
- package/lib/types/dsh-adapter/index.d.ts +4 -0
- package/lib/types/dsh-adapter/index.d.ts.map +1 -1
- package/lib/types/dsh-adapter/index.js +1 -0
- package/lib/types/dsh-adapter/message-observer.d.ts +173 -0
- package/lib/types/dsh-adapter/message-observer.d.ts.map +1 -0
- package/lib/types/dsh-adapter/message-observer.js +553 -0
- package/lib/types/dsh-adapter/plugin-host.d.ts +136 -0
- package/lib/types/dsh-adapter/plugin-host.d.ts.map +1 -0
- package/lib/types/dsh-adapter/plugin-host.js +365 -0
- package/lib/types/dsh-adapter/plugin-storage.d.ts +108 -0
- package/lib/types/dsh-adapter/plugin-storage.d.ts.map +1 -0
- package/lib/types/dsh-adapter/plugin-storage.js +397 -0
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin.js +124 -14
- package/lib/types/dsh-adapter/plugins-info.d.ts +43 -0
- package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -0
- package/lib/types/dsh-adapter/plugins-info.js +276 -0
- package/lib/types/dsh-adapter/promptDebug.d.ts +0 -6
- package/lib/types/dsh-adapter/promptDebug.d.ts.map +1 -1
- package/lib/types/dsh-adapter/promptDebug.js +13 -4
- package/lib/types/dsh-adapter/renderers.d.ts +57 -0
- package/lib/types/dsh-adapter/renderers.d.ts.map +1 -0
- package/lib/types/dsh-adapter/renderers.js +173 -0
- package/lib/types/dsh-adapter/sanitize.d.ts +36 -0
- package/lib/types/dsh-adapter/sanitize.d.ts.map +1 -0
- package/lib/types/dsh-adapter/sanitize.js +65 -0
- package/lib/types/dsh-adapter/scenes.d.ts +15 -5
- package/lib/types/dsh-adapter/scenes.d.ts.map +1 -1
- package/lib/types/dsh-adapter/scenes.js +149 -35
- package/lib/types/dsh-adapter/settings-sections.d.ts +7 -3
- package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
- package/lib/types/dsh-adapter/settings-sections.js +106 -26
- package/lib/types/dsh-adapter/shortcuts.d.ts +107 -0
- package/lib/types/dsh-adapter/shortcuts.d.ts.map +1 -0
- package/lib/types/dsh-adapter/shortcuts.js +340 -0
- package/lib/types/dsh-adapter/status.d.ts +74 -0
- package/lib/types/dsh-adapter/status.d.ts.map +1 -0
- package/lib/types/dsh-adapter/status.js +234 -0
- package/lib/types/dsh-adapter/workspaces.d.ts +16 -5
- package/lib/types/dsh-adapter/workspaces.d.ts.map +1 -1
- package/lib/types/dsh-adapter/workspaces.js +287 -170
- package/lib/types/extensions.d.ts +13 -0
- package/lib/types/extensions.d.ts.map +1 -0
- package/lib/types/extensions.js +21 -0
- package/lib/types/force-production-react.d.ts +1 -0
- package/lib/types/force-production-react.d.ts.map +1 -0
- package/lib/types/force-production-react.js +12 -0
- package/lib/types/i18n.d.ts +174 -20
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +56 -6
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +1 -0
- package/lib/types/ink/components/App.d.ts +2 -0
- package/lib/types/ink/components/App.d.ts.map +1 -1
- package/lib/types/ink/components/App.js +4 -0
- package/lib/types/ink/ink.d.ts +31 -3
- package/lib/types/ink/ink.d.ts.map +1 -1
- package/lib/types/ink/ink.js +90 -5
- package/lib/types/ink/log-update.d.ts.map +1 -1
- package/lib/types/ink/log-update.js +225 -56
- package/lib/types/ink/output.d.ts +35 -2
- package/lib/types/ink/output.d.ts.map +1 -1
- package/lib/types/ink/output.js +281 -14
- package/lib/types/ink/render-node-to-output.d.ts.map +1 -1
- package/lib/types/ink/render-node-to-output.js +14 -6
- package/lib/types/ink/screen.d.ts +39 -0
- package/lib/types/ink/screen.d.ts.map +1 -1
- package/lib/types/ink/screen.js +117 -0
- package/lib/types/ink/terminal.d.ts.map +1 -1
- package/lib/types/ink/terminal.js +26 -6
- package/lib/types/ink/wrapAnsi.d.ts +1 -1
- package/lib/types/ink/wrapAnsi.d.ts.map +1 -1
- package/lib/types/ink/wrapAnsi.js +29 -2
- package/lib/types/plugin-host.d.ts +15 -0
- package/lib/types/plugin-host.d.ts.map +1 -0
- package/lib/types/plugin-host.js +17 -0
- package/lib/types/plugin-spec/negotiate.d.ts +11 -0
- package/lib/types/plugin-spec/negotiate.d.ts.map +1 -0
- package/lib/types/plugin-spec/negotiate.js +97 -0
- package/lib/types/plugin-spec/permission-scope.d.ts +32 -0
- package/lib/types/plugin-spec/permission-scope.d.ts.map +1 -0
- package/lib/types/plugin-spec/permission-scope.js +90 -0
- package/lib/types/plugin-spec/registry.d.ts +23 -0
- package/lib/types/plugin-spec/registry.d.ts.map +1 -0
- package/lib/types/plugin-spec/registry.js +252 -0
- package/lib/types/plugin-spec/schema-check.d.ts +17 -0
- package/lib/types/plugin-spec/schema-check.d.ts.map +1 -0
- package/lib/types/plugin-spec/schema-check.js +165 -0
- package/lib/types/plugin-spec/tui-extension.d.ts +16 -0
- package/lib/types/plugin-spec/tui-extension.d.ts.map +1 -0
- package/lib/types/plugin-spec/tui-extension.js +79 -0
- package/lib/types/plugin-spec/types.d.ts +114 -0
- package/lib/types/plugin-spec/types.d.ts.map +1 -0
- package/lib/types/plugin-spec/types.js +10 -0
- package/lib/types/plugin-spec/validate.d.ts +21 -0
- package/lib/types/plugin-spec/validate.d.ts.map +1 -0
- package/lib/types/plugin-spec/validate.js +138 -0
- package/lib/types/scenes.d.ts +2 -1
- package/lib/types/scenes.d.ts.map +1 -1
- package/lib/types/scenes.js +1 -1
- package/lib/types/screens/Chat.d.ts +14 -1
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +173 -49
- package/lib/types/screens/SessionBrowser.d.ts.map +1 -1
- package/lib/types/screens/SessionBrowser.js +10 -3
- package/lib/types/sessions/view.d.ts +3 -2
- package/lib/types/sessions/view.d.ts.map +1 -1
- package/lib/types/sessions/view.js +18 -0
- package/lib/types/settings-sections.d.ts +2 -1
- package/lib/types/settings-sections.d.ts.map +1 -1
- package/lib/types/settings-sections.js +1 -1
- package/lib/types/theme.d.ts +5 -0
- package/lib/types/theme.d.ts.map +1 -1
- package/lib/types/theme.js +15 -0
- package/lib/types/update.d.ts +20 -0
- package/lib/types/update.d.ts.map +1 -1
- package/lib/types/update.js +54 -7
- package/lib/types/utils/execFileNoThrow.d.ts.map +1 -1
- package/lib/types/utils/execFileNoThrow.js +3 -0
- package/lib/types/utils/loaded-context.d.ts +8 -3
- package/lib/types/utils/loaded-context.d.ts.map +1 -1
- package/lib/types/utils/loaded-context.js +39 -3
- package/lib/types/utils/modifiers.d.ts.map +1 -1
- package/lib/types/utils/modifiers.js +3 -2
- package/lib/types/working-activity.d.ts +12 -0
- package/lib/types/working-activity.d.ts.map +1 -1
- package/lib/types/working-activity.js +13 -0
- package/lib/types/workspaces.d.ts +2 -1
- package/lib/types/workspaces.d.ts.map +1 -1
- package/lib/types/workspaces.js +1 -1
- package/node_modules/@dsh-std/command/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/command/LICENSE +21 -0
- package/node_modules/@dsh-std/command/README.md +26 -0
- package/node_modules/@dsh-std/command/README.zh.md +28 -0
- package/node_modules/@dsh-std/command/lib/index.d.ts +144 -0
- package/node_modules/@dsh-std/command/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/command/lib/index.js +252 -0
- package/node_modules/@dsh-std/command/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/command/package.json +22 -0
- package/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/connection/LICENSE +21 -0
- package/node_modules/@dsh-std/connection/README.md +42 -0
- package/node_modules/@dsh-std/connection/README.zh.md +42 -0
- package/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
- package/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
- package/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
- package/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/connection/lib/index.js +158 -0
- package/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
- package/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
- package/node_modules/@dsh-std/connection/lib/memory.js +258 -0
- package/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
- package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
- package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
- package/node_modules/@dsh-std/connection/package.json +20 -0
- package/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/core/LICENSE +21 -0
- package/node_modules/@dsh-std/core/README.md +13 -0
- package/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/core/package.json +21 -0
- package/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -0
- package/node_modules/@dsh-std/manifest/LICENSE +21 -0
- package/node_modules/@dsh-std/manifest/README.md +5 -0
- package/node_modules/@dsh-std/manifest/README.zh.md +5 -0
- package/node_modules/@dsh-std/manifest/lib/index.d.ts +182 -0
- package/node_modules/@dsh-std/manifest/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/manifest/lib/index.js +625 -0
- package/node_modules/@dsh-std/manifest/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/manifest/package.json +20 -0
- package/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -0
- package/node_modules/@dsh-std/messages/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/messages/LICENSE +21 -0
- package/node_modules/@dsh-std/messages/README.md +5 -0
- package/node_modules/@dsh-std/messages/README.zh.md +7 -0
- package/node_modules/@dsh-std/messages/lib/index.d.ts +50 -0
- package/node_modules/@dsh-std/messages/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/messages/lib/index.js +151 -0
- package/node_modules/@dsh-std/messages/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/messages/package.json +20 -0
- package/node_modules/@dsh-std/messages/schema/message-observer-envelope-0.15.schema.json +54 -0
- package/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -0
- package/node_modules/@dsh-std/presentation/LICENSE +21 -0
- package/node_modules/@dsh-std/presentation/README.md +27 -0
- package/node_modules/@dsh-std/presentation/README.zh.md +29 -0
- package/node_modules/@dsh-std/presentation/lib/callback.d.ts +2 -0
- package/node_modules/@dsh-std/presentation/lib/callback.js +179 -0
- package/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -0
- package/node_modules/@dsh-std/presentation/lib/index.d.ts +262 -0
- package/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/presentation/lib/index.js +550 -0
- package/node_modules/@dsh-std/presentation/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/presentation/lib/interaction.d.ts +2 -0
- package/node_modules/@dsh-std/presentation/lib/interaction.js +2 -0
- package/node_modules/@dsh-std/presentation/lib/operations.d.ts +2 -0
- package/node_modules/@dsh-std/presentation/lib/operations.js +2 -0
- package/node_modules/@dsh-std/presentation/package.json +25 -0
- package/node_modules/@dsh-std/storage/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/storage/LICENSE +21 -0
- package/node_modules/@dsh-std/storage/README.md +5 -0
- package/node_modules/@dsh-std/storage/README.zh.md +7 -0
- package/node_modules/@dsh-std/storage/lib/index.d.ts +48 -0
- package/node_modules/@dsh-std/storage/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/storage/lib/index.js +104 -0
- package/node_modules/@dsh-std/storage/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/storage/package.json +20 -0
- package/node_modules/@dsh-std/storage/schema/local-storage-0.15.schema.json +56 -0
- package/package.json +110 -70
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/LICENSE +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.md +42 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.zh.md +42 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js +158 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js +258 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/package.json +20 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/LICENSE +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.md +5 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.zh.md +5 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.d.ts +182 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js +625 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/package.json +20 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/LICENSE +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.md +27 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.zh.md +29 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.d.ts +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js +179 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts +262 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js +550 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/interaction.d.ts +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/interaction.js +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/operations.d.ts +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/operations.js +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/package.json +25 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/LICENSE +21 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.md +42 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.zh.md +42 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js +158 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js +258 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/package.json +20 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/package.json +21 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /plugins diagnostics surface (C-070 trust disclosure + C-030 negotiation
|
|
3
|
+
* diagnostics): assembles the lines behind the `/plugins` command.
|
|
4
|
+
*
|
|
5
|
+
* Sections (overview):
|
|
6
|
+
*
|
|
7
|
+
* 1. TRUST BANNER — always the first line (C-070): plugins run in-process;
|
|
8
|
+
* grants are behavioral constraints, not a security boundary; passing
|
|
9
|
+
* validation is not proof of safety.
|
|
10
|
+
* 2. HOST DESCRIPTOR summary — what the running host actually advertises
|
|
11
|
+
* (coordinates + generation), including drift-dropped contracts.
|
|
12
|
+
* 3. GRANT MATRIX — plugins × the registered permissions. The plugin set is
|
|
13
|
+
* the union of FOOTPRINTS ONLY: keys of the grants file, pluginIds seen
|
|
14
|
+
* in the effect ledger, and storage namespaces on disk (the host cannot
|
|
15
|
+
* enumerate installed plugins — that knowledge lives in the dsh CLI
|
|
16
|
+
* Loader). The header says so honestly.
|
|
17
|
+
* 4. LEDGER TAIL — the last 5 effect-ledger records.
|
|
18
|
+
*
|
|
19
|
+
* `/plugins check <path>` uses the parser and projection from the pinned
|
|
20
|
+
* @dsh-std/manifest revision, then evaluates every public/private protocol
|
|
21
|
+
* through one ProtocolCatalog. Manifests and on-disk files are UNTRUSTED input:
|
|
22
|
+
* every derived line passes cleanScalarText before it reaches the
|
|
23
|
+
* transcript.
|
|
24
|
+
*/
|
|
25
|
+
import type { GrantStore } from './grants.js';
|
|
26
|
+
import type { HostDescriptorBuild } from './host-descriptor.js';
|
|
27
|
+
/** How many plugins the matrix shows before an overflow note. */
|
|
28
|
+
export declare const PLUGINS_MATRIX_MAX_ROWS = 20;
|
|
29
|
+
/** How many ledger records the tail section shows. */
|
|
30
|
+
export declare const PLUGINS_LEDGER_TAIL = 5;
|
|
31
|
+
export interface PluginsInfoDeps {
|
|
32
|
+
/** Effective grant answers (the plugin-host row's store when mounted). */
|
|
33
|
+
grants: GrantStore;
|
|
34
|
+
/** The plugin-host row's descriptor build; undefined → row not mounted. */
|
|
35
|
+
host?: HostDescriptorBuild;
|
|
36
|
+
/** Test overrides; default under DATA_DIR. */
|
|
37
|
+
dataDir?: string;
|
|
38
|
+
ledgerFile?: string;
|
|
39
|
+
storageDir?: string;
|
|
40
|
+
}
|
|
41
|
+
/** The `/plugins` overview lines (banner always first). */
|
|
42
|
+
export declare function pluginsInfoLines(args: string, deps: PluginsInfoDeps): string[];
|
|
43
|
+
//# sourceMappingURL=plugins-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins-info.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/plugins-info.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAYH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAK/D,iEAAiE;AACjE,eAAO,MAAM,uBAAuB,KAAK,CAAA;AACzC,sDAAsD;AACtD,eAAO,MAAM,mBAAmB,IAAI,CAAA;AAIpC,MAAM,WAAW,eAAe;IAC9B,0EAA0E;IAC1E,MAAM,EAAE,UAAU,CAAA;IAClB,2EAA2E;IAC3E,IAAI,CAAC,EAAE,mBAAmB,CAAA;IAC1B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AA2JD,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,MAAM,EAAE,CAmF9E"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /plugins diagnostics surface (C-070 trust disclosure + C-030 negotiation
|
|
3
|
+
* diagnostics): assembles the lines behind the `/plugins` command.
|
|
4
|
+
*
|
|
5
|
+
* Sections (overview):
|
|
6
|
+
*
|
|
7
|
+
* 1. TRUST BANNER — always the first line (C-070): plugins run in-process;
|
|
8
|
+
* grants are behavioral constraints, not a security boundary; passing
|
|
9
|
+
* validation is not proof of safety.
|
|
10
|
+
* 2. HOST DESCRIPTOR summary — what the running host actually advertises
|
|
11
|
+
* (coordinates + generation), including drift-dropped contracts.
|
|
12
|
+
* 3. GRANT MATRIX — plugins × the registered permissions. The plugin set is
|
|
13
|
+
* the union of FOOTPRINTS ONLY: keys of the grants file, pluginIds seen
|
|
14
|
+
* in the effect ledger, and storage namespaces on disk (the host cannot
|
|
15
|
+
* enumerate installed plugins — that knowledge lives in the dsh CLI
|
|
16
|
+
* Loader). The header says so honestly.
|
|
17
|
+
* 4. LEDGER TAIL — the last 5 effect-ledger records.
|
|
18
|
+
*
|
|
19
|
+
* `/plugins check <path>` uses the parser and projection from the pinned
|
|
20
|
+
* @dsh-std/manifest revision, then evaluates every public/private protocol
|
|
21
|
+
* through one ProtocolCatalog. Manifests and on-disk files are UNTRUSTED input:
|
|
22
|
+
* every derived line passes cleanScalarText before it reaches the
|
|
23
|
+
* transcript.
|
|
24
|
+
*/
|
|
25
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
26
|
+
import { join, resolve } from 'node:path';
|
|
27
|
+
import { parseManifest, projectManifest } from '@dsh-std/manifest';
|
|
28
|
+
import { DATA_DIR } from '../utils/paths.js';
|
|
29
|
+
import { t } from '../i18n.js';
|
|
30
|
+
import { loadSpecData } from '../plugin-spec/registry.js';
|
|
31
|
+
import { createContractIndex, validatePlugin } from '../plugin-spec/validate.js';
|
|
32
|
+
import { negotiate } from '../plugin-spec/negotiate.js';
|
|
33
|
+
import { cleanScalarText } from './sanitize.js';
|
|
34
|
+
import { buildHostDescriptor } from './host-descriptor.js';
|
|
35
|
+
import { PLUGIN_STORAGE_DIR } from './plugin-storage.js';
|
|
36
|
+
import { EFFECT_LEDGER_FILE } from './effect-ledger.js';
|
|
37
|
+
/** How many plugins the matrix shows before an overflow note. */
|
|
38
|
+
export const PLUGINS_MATRIX_MAX_ROWS = 20;
|
|
39
|
+
/** How many ledger records the tail section shows. */
|
|
40
|
+
export const PLUGINS_LEDGER_TAIL = 5;
|
|
41
|
+
/** Per-line cell cap for file-derived content. */
|
|
42
|
+
const LINE_CELLS = 200;
|
|
43
|
+
const cell = (value) => cleanScalarText(String(value ?? ''), LINE_CELLS);
|
|
44
|
+
/** Parse the ledger file tolerantly (skip corrupt lines, never throw). */
|
|
45
|
+
function readLedgerRecords(file) {
|
|
46
|
+
let text;
|
|
47
|
+
try {
|
|
48
|
+
text = readFileSync(file, 'utf8');
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
const records = [];
|
|
54
|
+
for (const line of text.split('\n')) {
|
|
55
|
+
if (line.trim() === '')
|
|
56
|
+
continue;
|
|
57
|
+
try {
|
|
58
|
+
const parsed = JSON.parse(line);
|
|
59
|
+
if (parsed !== null && typeof parsed === 'object')
|
|
60
|
+
records.push(parsed);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// Corrupt line: the diagnostics surface skips it (never rewrites).
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return records;
|
|
67
|
+
}
|
|
68
|
+
/** The plugin set for the matrix: grants-file keys ∪ ledger pluginIds ∪
|
|
69
|
+
* storage namespaces ('host'/'undeclared' ledger identities are not
|
|
70
|
+
* plugins and are excluded). */
|
|
71
|
+
function footprintPlugins(deps, dataDir, ledgerFile, storageDir) {
|
|
72
|
+
const found = new Set();
|
|
73
|
+
try {
|
|
74
|
+
const raw = JSON.parse(readFileSync(join(dataDir, 'extension-grants.json'), 'utf8'));
|
|
75
|
+
if (raw !== null && typeof raw === 'object') {
|
|
76
|
+
const table = raw;
|
|
77
|
+
for (const section of [table.grants, table.denies]) {
|
|
78
|
+
if (section !== null && typeof section === 'object') {
|
|
79
|
+
for (const plugin of Object.keys(section))
|
|
80
|
+
found.add(plugin);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// Missing/corrupt grants file: the GrantStore already answers deny;
|
|
87
|
+
// the matrix simply has no rows from this source.
|
|
88
|
+
}
|
|
89
|
+
for (const record of readLedgerRecords(ledgerFile)) {
|
|
90
|
+
if (typeof record.pluginId === 'string' && record.pluginId !== '' && record.pluginId !== 'host' && record.pluginId !== 'undeclared') {
|
|
91
|
+
found.add(record.pluginId);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
for (const entry of readdirSync(storageDir)) {
|
|
96
|
+
if (!entry.endsWith('.json'))
|
|
97
|
+
continue;
|
|
98
|
+
const namespace = decodeURIComponent(entry.slice(0, -'.json'.length));
|
|
99
|
+
if (namespace !== '')
|
|
100
|
+
found.add(namespace);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// No storage directory yet: no rows from this source.
|
|
105
|
+
}
|
|
106
|
+
void deps;
|
|
107
|
+
return [...found].sort();
|
|
108
|
+
}
|
|
109
|
+
/** `/plugins check <path>`: official parse/projection + profile validation + negotiation. */
|
|
110
|
+
function checkManifestLines(pathArg, deps) {
|
|
111
|
+
const lines = [];
|
|
112
|
+
const target = resolve(pathArg);
|
|
113
|
+
if (!existsSync(target)) {
|
|
114
|
+
lines.push(t('plugins-check-not-found', { path: cell(pathArg) }));
|
|
115
|
+
return lines;
|
|
116
|
+
}
|
|
117
|
+
let source;
|
|
118
|
+
try {
|
|
119
|
+
source = readFileSync(target, 'utf8');
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
lines.push(t('plugins-check-invalid-json', { err: cell(error instanceof Error ? error.message : String(error)) }));
|
|
123
|
+
return lines;
|
|
124
|
+
}
|
|
125
|
+
const data = loadSpecData();
|
|
126
|
+
if (data === undefined) {
|
|
127
|
+
lines.push(t('plugins-check-spec-unavailable'));
|
|
128
|
+
return lines;
|
|
129
|
+
}
|
|
130
|
+
let manifest;
|
|
131
|
+
try {
|
|
132
|
+
manifest = parseManifest(source, { source: target });
|
|
133
|
+
// Projection is an explicit admission stage. validatePlugin performs its
|
|
134
|
+
// own defensive projection too, but keeping this call here makes parser
|
|
135
|
+
// and projection failures distinguishable at the user-facing boundary.
|
|
136
|
+
projectManifest(manifest);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
const message = cell(error instanceof Error ? error.message : String(error));
|
|
140
|
+
lines.push(error instanceof SyntaxError
|
|
141
|
+
? t('plugins-check-invalid-json', { err: message })
|
|
142
|
+
: t('plugins-check-schema-failed', { err: message }));
|
|
143
|
+
return lines;
|
|
144
|
+
}
|
|
145
|
+
const index = createContractIndex(data.registry, data.permissions);
|
|
146
|
+
try {
|
|
147
|
+
validatePlugin(index, manifest);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
lines.push(t('plugins-check-invalid', { err: cell(error instanceof Error ? error.message : String(error)) }));
|
|
151
|
+
return lines;
|
|
152
|
+
}
|
|
153
|
+
const host = deps.host ?? buildHostDescriptor({ generationId: 'plugins-check' });
|
|
154
|
+
const granted = manifest.permissions
|
|
155
|
+
.map(request => ({
|
|
156
|
+
name: request.name,
|
|
157
|
+
scope: request.scope,
|
|
158
|
+
// `/plugins check` has no live activation instance. Passing an
|
|
159
|
+
// activation-less principal makes GrantStore fail closed when policy
|
|
160
|
+
// contains activation-scoped rules instead of treating them as global.
|
|
161
|
+
granted: deps.grants.allows({ componentId: manifest.id }, request.name, request.scope),
|
|
162
|
+
}));
|
|
163
|
+
const decision = negotiate(index, manifest, host.descriptor, granted);
|
|
164
|
+
lines.push(...decisionLines(decision));
|
|
165
|
+
if (host.dropped.length > 0) {
|
|
166
|
+
lines.push(t('plugins-check-dropped', { dropped: cell(host.dropped.join(', ')) }));
|
|
167
|
+
}
|
|
168
|
+
return lines;
|
|
169
|
+
}
|
|
170
|
+
function decisionLines(decision) {
|
|
171
|
+
switch (decision.decision) {
|
|
172
|
+
case 'compatible':
|
|
173
|
+
return [t('plugins-check-state', { state: 'compatible' })];
|
|
174
|
+
case 'compatible_degraded':
|
|
175
|
+
return [t('plugins-check-state', {
|
|
176
|
+
state: `compatible_degraded (missingOptional: ${cell(decision.missingOptional.join(', '))})`,
|
|
177
|
+
})];
|
|
178
|
+
case 'waiting_authorization':
|
|
179
|
+
return [t('plugins-check-state', {
|
|
180
|
+
state: `waiting_authorization (${cell(decision.reasonCode)}: ${cell(decision.deniedPermissions.join(', '))})`,
|
|
181
|
+
})];
|
|
182
|
+
case 'rejected': {
|
|
183
|
+
const detail = decision.missingRequired !== undefined
|
|
184
|
+
? `${cell(decision.reasonCode)}: ${cell(decision.missingRequired.join(', '))}`
|
|
185
|
+
: `${cell(decision.reasonCode)}: facet ${cell(decision.facetApiVersion)} vs host [${cell((decision.hostFacetApiVersions ?? []).join(', '))}]`;
|
|
186
|
+
return [t('plugins-check-state', { state: `rejected (${detail})` })];
|
|
187
|
+
}
|
|
188
|
+
case 'unknown':
|
|
189
|
+
return [t('plugins-check-state', {
|
|
190
|
+
state: `unknown (${cell(decision.reasonCode)}: ${cell(decision.unknownContracts.join(', '))})`,
|
|
191
|
+
})];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/** The `/plugins` overview lines (banner always first). */
|
|
195
|
+
export function pluginsInfoLines(args, deps) {
|
|
196
|
+
const lines = [t('plugins-trust-banner')];
|
|
197
|
+
const trimmed = args.trim();
|
|
198
|
+
if (trimmed !== '') {
|
|
199
|
+
const [sub, ...rest] = trimmed.split(/\s+/);
|
|
200
|
+
if (sub === 'check') {
|
|
201
|
+
const pathArg = rest.join(' ');
|
|
202
|
+
if (pathArg === '') {
|
|
203
|
+
lines.push(t('plugins-check-usage'));
|
|
204
|
+
return lines;
|
|
205
|
+
}
|
|
206
|
+
lines.push(...checkManifestLines(pathArg, deps));
|
|
207
|
+
return lines;
|
|
208
|
+
}
|
|
209
|
+
lines.push(t('plugins-unknown-subcommand', { sub: cell(sub) }));
|
|
210
|
+
return lines;
|
|
211
|
+
}
|
|
212
|
+
const dataDir = deps.dataDir ?? DATA_DIR;
|
|
213
|
+
const ledgerFile = deps.ledgerFile ?? EFFECT_LEDGER_FILE;
|
|
214
|
+
const storageDir = deps.storageDir ?? join(dataDir, PLUGIN_STORAGE_DIR);
|
|
215
|
+
// ── Host Descriptor ──
|
|
216
|
+
if (deps.host === undefined) {
|
|
217
|
+
lines.push(t('plugins-host-unavailable'));
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
const { descriptor, dropped } = deps.host;
|
|
221
|
+
lines.push(`Host Descriptor: ${cell(descriptor.hostId)} v${cell(descriptor.hostVersion)} · generation ${cell(descriptor.runtime.generationId)}`);
|
|
222
|
+
lines.push(` facets: ${cell(descriptor.facetApiVersions.join(', ') || '—')}`);
|
|
223
|
+
for (const contract of descriptor.contracts) {
|
|
224
|
+
const definition = contract.definition.source === 'dsh-std'
|
|
225
|
+
? contract.definition.package
|
|
226
|
+
: contract.definition.profileHash.slice(0, 19) + '…';
|
|
227
|
+
lines.push(` ${cell(contract.apiVersion)}#${cell(contract.kind)} · definition ${cell(definition)} · perms ${cell(contract.permissions.join(', ') || '—')}`);
|
|
228
|
+
}
|
|
229
|
+
for (const coordinate of dropped) {
|
|
230
|
+
lines.push(` ${cell(coordinate)} · ${t('plugins-contract-dropped')}`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// ── 授权矩阵 ──
|
|
234
|
+
const plugins = footprintPlugins(deps, dataDir, ledgerFile, storageDir);
|
|
235
|
+
lines.push(t('plugins-matrix-note'));
|
|
236
|
+
const permissions = deps.grants.knownPermissions();
|
|
237
|
+
if (permissions.length === 0) {
|
|
238
|
+
lines.push(` ${t('plugins-matrix-no-registry')}`);
|
|
239
|
+
}
|
|
240
|
+
else if (plugins.length === 0) {
|
|
241
|
+
lines.push(` ${t('plugins-matrix-empty')}`);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
lines.push(` ${permissions.map((permission, index) => `[${index + 1}] ${cell(permission)}`).join(' ')}`);
|
|
245
|
+
const shown = plugins.slice(0, PLUGINS_MATRIX_MAX_ROWS);
|
|
246
|
+
const width = Math.max(...shown.map(plugin => plugin.length), 8);
|
|
247
|
+
for (const plugin of shown) {
|
|
248
|
+
const diagnosticScope = (permission) => {
|
|
249
|
+
if (permission === 'storage.local.read' || permission === 'storage.local.write')
|
|
250
|
+
return plugin;
|
|
251
|
+
if (permission === 'commands.invoke')
|
|
252
|
+
return 'diagnostic.command';
|
|
253
|
+
return 'session:*';
|
|
254
|
+
};
|
|
255
|
+
const marks = permissions.map(permission => (deps.grants.allows({ componentId: plugin }, permission, diagnosticScope(permission)) ? '✓' : '·')).join(' ');
|
|
256
|
+
lines.push(` ${cell(plugin).padEnd(width)} ${marks}`);
|
|
257
|
+
}
|
|
258
|
+
if (plugins.length > shown.length) {
|
|
259
|
+
lines.push(` ${t('plugins-footprint-overflow', { count: plugins.length - shown.length })}`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
// ── 台账尾 ──
|
|
263
|
+
const records = readLedgerRecords(ledgerFile);
|
|
264
|
+
if (records.length === 0) {
|
|
265
|
+
lines.push(t('plugins-ledger-empty'));
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
lines.push(t('plugins-ledger-header', { file: cell(ledgerFile) }));
|
|
269
|
+
for (const record of records.slice(-PLUGINS_LEDGER_TAIL)) {
|
|
270
|
+
const resource = record.resource ?? {};
|
|
271
|
+
lines.push(` #${cell(record.sequence)} ${cell(record.operation)} ${cell(resource.kind)}/${cell(resource.id)} ` +
|
|
272
|
+
`${cell(record.pluginId)} ${cell(record.result)}${typeof record.errorCode === 'string' ? ` (${cell(record.errorCode)})` : ''}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return lines;
|
|
276
|
+
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
export declare const PROMPT_DEBUG_FILENAME = ".dsh-prompt-debug.json";
|
|
3
|
-
/**
|
|
4
|
-
* Register `/debug-prompt` and retain every final request observed for each
|
|
5
|
-
* live session. The command writes one private, atomic snapshot into the
|
|
6
|
-
* receiving session's workspace; it never records credentials, transport
|
|
7
|
-
* headers, or AbortSignals.
|
|
8
|
-
*/
|
|
9
3
|
export declare function registerPromptDebug(ctx: Context): void;
|
|
10
4
|
//# sourceMappingURL=promptDebug.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promptDebug.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/promptDebug.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAMlD,eAAO,MAAM,qBAAqB,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"promptDebug.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/promptDebug.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAMlD,eAAO,MAAM,qBAAqB,2BAA2B,CAAA;AAiG7D,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CA+FtD"}
|
|
@@ -52,11 +52,17 @@ function captureRequest(agent, options, requestIndex, position, attempt) {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
* Register `/debug-prompt` and retain
|
|
56
|
-
* live session
|
|
57
|
-
*
|
|
58
|
-
* headers, or
|
|
55
|
+
* Register `/debug-prompt` and retain the final requests observed for each
|
|
56
|
+
* live session (most recent {@link DEBUG_PROMPT_MAX_REQUESTS} kept). The
|
|
57
|
+
* command writes one private, atomic snapshot into the receiving session's
|
|
58
|
+
* workspace; it never records credentials, transport headers, or
|
|
59
|
+
* AbortSignals.
|
|
59
60
|
*/
|
|
61
|
+
/** Retention cap per session: every capture holds the fully assembled
|
|
62
|
+
* request context (messages + tools), so an unbounded list grows
|
|
63
|
+
* quadratically with an uncompacted conversation — the dominant long-session
|
|
64
|
+
* memory term. Retries of the current step stay well inside this window. */
|
|
65
|
+
const DEBUG_PROMPT_MAX_REQUESTS = 8;
|
|
60
66
|
export function registerPromptDebug(ctx) {
|
|
61
67
|
const commands = ctx.get('commands');
|
|
62
68
|
const agents = ctx.get('agents');
|
|
@@ -80,6 +86,9 @@ export function registerPromptDebug(ctx) {
|
|
|
80
86
|
const previous = capture.requests.findLast(request => request.turn === position.turn && request.step === position.step);
|
|
81
87
|
const attempt = (previous?.attempt ?? 0) + 1;
|
|
82
88
|
capture.requests.push(captureRequest(agent, options, capture.requests.length + 1, position, attempt));
|
|
89
|
+
if (capture.requests.length > DEBUG_PROMPT_MAX_REQUESTS) {
|
|
90
|
+
capture.requests.splice(0, capture.requests.length - DEBUG_PROMPT_MAX_REQUESTS);
|
|
91
|
+
}
|
|
83
92
|
return next();
|
|
84
93
|
});
|
|
85
94
|
// Replaced agents are no longer addressable by `/debug-prompt`; release
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom session-entry renderers — pi's `pi.registerMessageRenderer`. A
|
|
3
|
+
* plugin that appends its own log-only session events (`session.append(
|
|
4
|
+
* 'my-plugin/event', payload)`) registers a renderer mapping the payload to
|
|
5
|
+
* plain TEXT rows; the channel then projects those events into the
|
|
6
|
+
* transcript on the live stream and on replay (resume/rewind), exactly like
|
|
7
|
+
* its built-in projection of `activity/status` or `agent-preset/selected`.
|
|
8
|
+
*
|
|
9
|
+
* Renderers are text-only by design: the full-React surface is the scenes
|
|
10
|
+
* seam (`ctx.tuiScenes`, with the host-React contract); transcript rows are
|
|
11
|
+
* shared with replay paths where a crash mid-replay would corrupt the whole
|
|
12
|
+
* screen, so a renderer never receives React and its output is sanitized
|
|
13
|
+
* (control chars stripped, lines preview-clipped like `pushLocal` output).
|
|
14
|
+
*
|
|
15
|
+
* Registration rules (untrusted-input discipline):
|
|
16
|
+
*
|
|
17
|
+
* - The type must look like `plugin/event` (kebab, one slash) — this is the
|
|
18
|
+
* same shape the session-log strict registry expects plugins to register.
|
|
19
|
+
* - Core vocabulary is off-limits: a renderer can never shadow a built-in
|
|
20
|
+
* event type's projection (locals win, same as commands).
|
|
21
|
+
* - A renderer that throws is skipped for THAT event and logged once per
|
|
22
|
+
* type — replay must survive a buggy plugin.
|
|
23
|
+
*/
|
|
24
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
25
|
+
/** What a renderer returns: an optional title row plus body lines. */
|
|
26
|
+
export interface TuiEntryRenderResult {
|
|
27
|
+
/** Short heading (rendered as a notice row); omit for a body-only entry. */
|
|
28
|
+
title?: string;
|
|
29
|
+
/** Body rows, oldest-to-newest reading order. */
|
|
30
|
+
lines: readonly string[];
|
|
31
|
+
}
|
|
32
|
+
export type TuiEntryRenderer = (payload: unknown) => TuiEntryRenderResult | undefined;
|
|
33
|
+
/** Host-only transcript projection path. Plugins can register a renderer but
|
|
34
|
+
* cannot invoke an arbitrary registered renderer on demand. */
|
|
35
|
+
export interface TuiRendererHost {
|
|
36
|
+
render(type: string, payload: unknown): TuiEntryRenderResult | undefined;
|
|
37
|
+
}
|
|
38
|
+
declare module '@deepseek-ai/cordis' {
|
|
39
|
+
interface Context {
|
|
40
|
+
tuiRenderers: TuiRendererRuntime;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** `ctx.tuiRenderers` — custom session-entry text renderers. */
|
|
44
|
+
export declare class TuiRendererRuntime extends Service {
|
|
45
|
+
constructor(ctx: Context);
|
|
46
|
+
/**
|
|
47
|
+
* Map a log-only session event type to transcript rows. Returns the
|
|
48
|
+
* dispose function (caller scopes it with `ctx.effect`, same contract as
|
|
49
|
+
* `tuiScenes`). Refusals warn instead of throwing. The optional trailing
|
|
50
|
+
* `identity` (the plugin's own ctx) only feeds the effect ledger's
|
|
51
|
+
* pluginId — omitting it records `undeclared` (C-060).
|
|
52
|
+
*/
|
|
53
|
+
register(type: string, renderer: TuiEntryRenderer, identity?: Context): () => void;
|
|
54
|
+
}
|
|
55
|
+
export declare function getHostRenderers(runtime: TuiRendererRuntime | undefined): TuiRendererHost | undefined;
|
|
56
|
+
export default TuiRendererRuntime;
|
|
57
|
+
//# sourceMappingURL=renderers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderers.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/renderers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKtD,sEAAsE;AACtE,MAAM,WAAW,oBAAoB;IACnC,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iDAAiD;IACjD,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CACzB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,oBAAoB,GAAG,SAAS,CAAA;AAErF;+DAC+D;AAC/D,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CAAA;CACzE;AAsBD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf,YAAY,EAAE,kBAAkB,CAAA;KACjC;CACF;AAED,gEAAgE;AAChE,qBAAa,kBAAmB,SAAQ,OAAO;gBACjC,GAAG,EAAE,OAAO;IAexB;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,IAAI;CA8DnF;AA4CD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,GAAG,SAAS,GAAG,eAAe,GAAG,SAAS,CAOrG;AAED,eAAe,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom session-entry renderers — pi's `pi.registerMessageRenderer`. A
|
|
3
|
+
* plugin that appends its own log-only session events (`session.append(
|
|
4
|
+
* 'my-plugin/event', payload)`) registers a renderer mapping the payload to
|
|
5
|
+
* plain TEXT rows; the channel then projects those events into the
|
|
6
|
+
* transcript on the live stream and on replay (resume/rewind), exactly like
|
|
7
|
+
* its built-in projection of `activity/status` or `agent-preset/selected`.
|
|
8
|
+
*
|
|
9
|
+
* Renderers are text-only by design: the full-React surface is the scenes
|
|
10
|
+
* seam (`ctx.tuiScenes`, with the host-React contract); transcript rows are
|
|
11
|
+
* shared with replay paths where a crash mid-replay would corrupt the whole
|
|
12
|
+
* screen, so a renderer never receives React and its output is sanitized
|
|
13
|
+
* (control chars stripped, lines preview-clipped like `pushLocal` output).
|
|
14
|
+
*
|
|
15
|
+
* Registration rules (untrusted-input discipline):
|
|
16
|
+
*
|
|
17
|
+
* - The type must look like `plugin/event` (kebab, one slash) — this is the
|
|
18
|
+
* same shape the session-log strict registry expects plugins to register.
|
|
19
|
+
* - Core vocabulary is off-limits: a renderer can never shadow a built-in
|
|
20
|
+
* event type's projection (locals win, same as commands).
|
|
21
|
+
* - A renderer that throws is skipped for THAT event and logged once per
|
|
22
|
+
* type — replay must survive a buggy plugin.
|
|
23
|
+
*/
|
|
24
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
25
|
+
import { KNOWN_SESSION_EVENT_TYPES } from '@deepseek-ai/dsh-session';
|
|
26
|
+
import { cleanRenderText } from './sanitize.js';
|
|
27
|
+
import { bindCallerEffect, compositionRoot, concreteService, requirePluginCaller } from './host-access.js';
|
|
28
|
+
const TYPE_PATTERN = /^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/u;
|
|
29
|
+
/**
|
|
30
|
+
* The built-in session-event vocabulary, FROZEN at module load. The live
|
|
31
|
+
* KNOWN_SESSION_EVENT_TYPES set cannot serve as this denylist: a plugin
|
|
32
|
+
* persisting custom events MUST add its types to that set (seam 1's hard
|
|
33
|
+
* rule), so by the time it registers a renderer for `my-plugin/note`, the
|
|
34
|
+
* mutable set already contains `my-plugin/note` — checking against it would
|
|
35
|
+
* reject exactly the types this seam exists for. The module-load snapshot
|
|
36
|
+
* (this service's row mounts before any plugin row) is the built-in truth.
|
|
37
|
+
*/
|
|
38
|
+
const BUILTIN_SESSION_EVENT_TYPES = new Set(KNOWN_SESSION_EVENT_TYPES);
|
|
39
|
+
/** Output bounds (render-path hygiene): a renderer runs on the REPLAY path
|
|
40
|
+
* too, where an unbounded result would synchronously create thousands of
|
|
41
|
+
* transcript rows. Sanitization itself lives in ./sanitize.js. */
|
|
42
|
+
const MAX_RENDER_LINES = 100;
|
|
43
|
+
const TITLE_CELLS = 120;
|
|
44
|
+
const LINE_CELLS = 400;
|
|
45
|
+
/** `ctx.tuiRenderers` — custom session-entry text renderers. */
|
|
46
|
+
export class TuiRendererRuntime extends Service {
|
|
47
|
+
constructor(ctx) {
|
|
48
|
+
super(ctx, 'tuiRenderers');
|
|
49
|
+
compositionRoot(ctx);
|
|
50
|
+
const runtime = this;
|
|
51
|
+
const state = {
|
|
52
|
+
renderers: new Map(),
|
|
53
|
+
failedTypes: new Set(),
|
|
54
|
+
host: undefined,
|
|
55
|
+
logger: ctx.logger,
|
|
56
|
+
};
|
|
57
|
+
const host = Object.freeze({ render: (type, payload) => renderEntry(runtime, type, payload) });
|
|
58
|
+
state.host = host;
|
|
59
|
+
hostRenderers.set(runtime, state);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Map a log-only session event type to transcript rows. Returns the
|
|
63
|
+
* dispose function (caller scopes it with `ctx.effect`, same contract as
|
|
64
|
+
* `tuiScenes`). Refusals warn instead of throwing. The optional trailing
|
|
65
|
+
* `identity` (the plugin's own ctx) only feeds the effect ledger's
|
|
66
|
+
* pluginId — omitting it records `undeclared` (C-060).
|
|
67
|
+
*/
|
|
68
|
+
register(type, renderer, identity) {
|
|
69
|
+
let caller;
|
|
70
|
+
try {
|
|
71
|
+
caller = requirePluginCaller(this.ctx, 'tuiRenderers.register', this);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
this.ctx.logger.warn('dsh-tui: tuiRenderers.register requires a live non-root plugin activation');
|
|
75
|
+
return () => { };
|
|
76
|
+
}
|
|
77
|
+
const state = rendererStateFor(this);
|
|
78
|
+
let normalized;
|
|
79
|
+
try {
|
|
80
|
+
normalized = String(type ?? '').trim().toLowerCase();
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
this.ctx.logger.warn('dsh-tui: tuiRenderers.register rejected an uncoercible event type');
|
|
84
|
+
return () => { };
|
|
85
|
+
}
|
|
86
|
+
if (!TYPE_PATTERN.test(normalized)) {
|
|
87
|
+
this.ctx.logger.warn('dsh-tui: tuiRenderers.register rejected an invalid event type');
|
|
88
|
+
return () => { };
|
|
89
|
+
}
|
|
90
|
+
// The channel's own projection (its renderEvent switch plus special-
|
|
91
|
+
// cased plugin events like agent-preset/selected) always wins. The check
|
|
92
|
+
// uses the module-load snapshot of the built-in vocabulary — NOT the live
|
|
93
|
+
// KNOWN_SESSION_EVENT_TYPES, which plugins must extend with their own
|
|
94
|
+
// types (see BUILTIN_SESSION_EVENT_TYPES above).
|
|
95
|
+
if (BUILTIN_SESSION_EVENT_TYPES.has(normalized) || normalized === 'agent-preset/selected') {
|
|
96
|
+
this.ctx.logger.warn(`dsh-tui: tuiRenderers.register rejected "${normalized}" — built-in event types keep their own projection`);
|
|
97
|
+
return () => { };
|
|
98
|
+
}
|
|
99
|
+
if (state.renderers.has(normalized)) {
|
|
100
|
+
this.ctx.logger.warn(`dsh-tui: tuiRenderers.register rejected "${normalized}" — already registered`);
|
|
101
|
+
this.ctx.get('tuiEffectLedger')?.record({
|
|
102
|
+
operation: 'create',
|
|
103
|
+
resource: { kind: 'renderer', id: normalized },
|
|
104
|
+
result: 'failed',
|
|
105
|
+
errorCode: 'DUPLICATE_CONTRIBUTION_ID',
|
|
106
|
+
}, identity);
|
|
107
|
+
return () => { };
|
|
108
|
+
}
|
|
109
|
+
if (typeof renderer !== 'function') {
|
|
110
|
+
this.ctx.logger.warn(`dsh-tui: tuiRenderers.register rejected "${normalized}" — renderer must be a function`);
|
|
111
|
+
return () => { };
|
|
112
|
+
}
|
|
113
|
+
state.renderers.set(normalized, renderer);
|
|
114
|
+
this.ctx.get('tuiEffectLedger')?.record({ operation: 'create', resource: { kind: 'renderer', id: normalized }, result: 'applied' }, identity);
|
|
115
|
+
const dispose = () => {
|
|
116
|
+
if (state.renderers.get(normalized) !== renderer)
|
|
117
|
+
return;
|
|
118
|
+
state.renderers.delete(normalized);
|
|
119
|
+
this.ctx.get('tuiEffectLedger')?.record({ operation: 'release', resource: { kind: 'renderer', id: normalized }, result: 'applied' }, identity);
|
|
120
|
+
};
|
|
121
|
+
bindCallerEffect(caller, dispose);
|
|
122
|
+
return dispose;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const hostRenderers = new WeakMap();
|
|
126
|
+
function rendererStateFor(runtime) {
|
|
127
|
+
const state = hostRenderers.get(concreteService(runtime));
|
|
128
|
+
if (state === undefined)
|
|
129
|
+
throw new Error('tuiRenderers host state is unavailable');
|
|
130
|
+
return state;
|
|
131
|
+
}
|
|
132
|
+
function renderEntry(runtime, type, payload) {
|
|
133
|
+
const state = rendererStateFor(runtime);
|
|
134
|
+
const renderer = state.renderers.get(type);
|
|
135
|
+
if (renderer === undefined)
|
|
136
|
+
return undefined;
|
|
137
|
+
try {
|
|
138
|
+
const result = renderer(payload);
|
|
139
|
+
if (result === undefined)
|
|
140
|
+
return undefined;
|
|
141
|
+
const raw = result;
|
|
142
|
+
if (!Array.isArray(raw.lines))
|
|
143
|
+
return undefined;
|
|
144
|
+
const lines = [];
|
|
145
|
+
for (const line of raw.lines) {
|
|
146
|
+
if (lines.length >= MAX_RENDER_LINES)
|
|
147
|
+
break;
|
|
148
|
+
if (typeof line !== 'string' && typeof line !== 'number' && typeof line !== 'boolean')
|
|
149
|
+
continue;
|
|
150
|
+
lines.push(cleanRenderText(String(line), LINE_CELLS));
|
|
151
|
+
}
|
|
152
|
+
const title = typeof raw.title === 'string' ? cleanRenderText(raw.title, TITLE_CELLS) : undefined;
|
|
153
|
+
return { ...(title === undefined || title === '' ? {} : { title }), lines };
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
if (!state.failedTypes.has(type)) {
|
|
157
|
+
state.failedTypes.add(type);
|
|
158
|
+
state.logger.warn(`dsh-tui: renderer for "${type}" threw; its entries are skipped: %o`, error);
|
|
159
|
+
}
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export function getHostRenderers(runtime) {
|
|
164
|
+
if (runtime === undefined)
|
|
165
|
+
return undefined;
|
|
166
|
+
try {
|
|
167
|
+
return hostRenderers.get(concreteService(runtime))?.host;
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
export default TuiRendererRuntime;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The render-path sanitization contract for plugin-supplied text — the
|
|
3
|
+
* single implementation behind every managed-UI seam (dialogs, status line,
|
|
4
|
+
* entry renderers, rewind modes, decision notices). TUI-PROP-009 Track A
|
|
5
|
+
* makes these rules normative, so they live in exactly one place:
|
|
6
|
+
*
|
|
7
|
+
* - C0/C1 control chars are stripped (replaced by a space) — plugin text
|
|
8
|
+
* must never smuggle escape sequences onto the screen;
|
|
9
|
+
* - whitespace collapses to single spaces (render paths are single-line);
|
|
10
|
+
* - width is capped in terminal CELLS (never string.length) with an
|
|
11
|
+
* ellipsis.
|
|
12
|
+
*
|
|
13
|
+
* Non-scalar input is DROPPED, never `String()`-coerced — `String({})`
|
|
14
|
+
* would put "[object Object]" on the render path. Scalars
|
|
15
|
+
* (string/number/boolean) coerce through String() first.
|
|
16
|
+
*/
|
|
17
|
+
/** Sanitize an already-string value for the render path. */
|
|
18
|
+
export declare function cleanRenderText(value: string, maxCells: number): string;
|
|
19
|
+
/**
|
|
20
|
+
* Sanitize an untrusted (possibly non-string) value. Non-scalars — objects,
|
|
21
|
+
* arrays, functions, symbols, null/undefined — yield '' so the caller takes
|
|
22
|
+
* its drop/refuse path; scalars coerce then sanitize.
|
|
23
|
+
*/
|
|
24
|
+
export declare function cleanScalarText(value: unknown, maxCells: number): string;
|
|
25
|
+
/**
|
|
26
|
+
* Truncate to a cell budget WITHOUT ellipsis, whitespace folding, or any
|
|
27
|
+
* other mutation — the editing-path counterpart of {@link cleanRenderText}.
|
|
28
|
+
* An input panel caps what the user types/pastes; inserting '…' or
|
|
29
|
+
* collapsing their spaces would corrupt text they can still edit.
|
|
30
|
+
*/
|
|
31
|
+
export declare function capCells(value: string, maxCells: number): string;
|
|
32
|
+
/** C0/C1 control chars → space, nothing else touched. The single-line
|
|
33
|
+
* input panel flattens pasted chunks with this (newlines become spaces —
|
|
34
|
+
* the panel has no second row for them). */
|
|
35
|
+
export declare function flattenInline(value: string): string;
|
|
36
|
+
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAUvE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGxE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQhE;AAED;;6CAE6C;AAC7C,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGnD"}
|