@tbox.cn/app-template-agent 0.10.37 → 1.0.0-alpha.10
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/._.gitignore +0 -0
- package/._.nvmrc +0 -0
- package/._AGENTS.md +0 -0
- package/._ENV.md +0 -0
- package/._LEGAL.md +0 -0
- package/._LICENSE +0 -0
- package/._README.md +0 -0
- package/._eslint.config.mjs +0 -0
- package/._package.json +0 -0
- package/._pnpm-lock.template.yaml +0 -0
- package/._pnpm-workspace.template.yaml +0 -0
- package/._tsconfig.base.json +0 -0
- package/.gitignore +14 -2
- package/.tbox/._app.json +0 -0
- package/.tbox/._default-modules.json +0 -0
- package/.tbox/._miniapp-containers.json +0 -0
- package/.tbox/app.json +3 -19
- package/.tbox/default-modules.json +4 -1
- package/.tbox/factory/._chat.json +0 -0
- package/.tbox/factory/chat.json +9 -0
- package/.tbox/miniapp-containers.json +1 -1
- package/AGENTS.md +96 -148
- package/ENV.md +4 -4
- package/README.md +31 -27
- package/apps/._AGENTS.md +0 -0
- package/apps/AGENTS.md +9 -0
- package/apps/client/._index.html +0 -0
- package/apps/client/._package.json +0 -0
- package/apps/client/._tsconfig.json +0 -0
- package/apps/client/._vite.config.ts +0 -0
- package/apps/client/index.html +1 -20
- package/apps/client/package.json +7 -5
- package/apps/client/scripts/._acceptance-changes.test.mjs +0 -0
- package/apps/client/scripts/._check-evidence.mjs +0 -0
- package/apps/client/scripts/._color-scan.mjs +0 -0
- package/apps/client/scripts/._color-scan.test.mjs +0 -0
- package/apps/client/scripts/._evidence-gate.mjs +0 -0
- package/apps/client/scripts/._evidence-gate.test.mjs +0 -0
- package/apps/client/scripts/._experience-checks.mjs +0 -0
- package/apps/client/scripts/._geometry-kernel.test.mjs +0 -0
- package/apps/client/scripts/._in-process-checks.mjs +0 -0
- package/apps/client/scripts/._probe-checks.mjs +0 -0
- package/apps/client/scripts/._render-card.mjs +0 -0
- package/apps/client/scripts/._sample-entries.test.mjs +0 -0
- package/apps/client/scripts/._storyboard.test.mjs +0 -0
- package/apps/client/scripts/._surface-css.mjs +0 -0
- package/apps/client/scripts/._theme-kernel.mjs +0 -0
- package/apps/client/scripts/._theme-kernel.test.mjs +0 -0
- package/apps/client/scripts/acceptance-changes.test.mjs +97 -0
- package/apps/client/scripts/check-evidence.mjs +1402 -0
- package/apps/client/scripts/color-scan.mjs +66 -0
- package/apps/client/scripts/color-scan.test.mjs +25 -0
- package/apps/client/scripts/evidence-gate.mjs +337 -0
- package/apps/client/scripts/evidence-gate.test.mjs +135 -0
- package/apps/client/scripts/experience-checks.mjs +163 -0
- package/apps/client/scripts/geometry-kernel.test.mjs +92 -0
- package/apps/client/scripts/in-process-checks.mjs +51 -0
- package/apps/client/scripts/lib/._card-registry.mjs +0 -0
- package/apps/client/scripts/lib/._card-registry.test.mjs +0 -0
- package/apps/client/scripts/lib/._evidence-inputs.mjs +0 -0
- package/apps/client/scripts/lib/._evidence-inputs.test.mjs +0 -0
- package/apps/client/scripts/lib/._static-render.mjs +0 -0
- package/apps/client/scripts/lib/._static-render.test.mjs +0 -0
- package/apps/client/scripts/lib/card-registry.mjs +81 -0
- package/apps/client/scripts/lib/card-registry.test.mjs +59 -0
- package/apps/client/scripts/lib/evidence-inputs.mjs +91 -0
- package/apps/client/scripts/lib/evidence-inputs.test.mjs +27 -0
- package/apps/client/scripts/lib/static-render.mjs +35 -0
- package/apps/client/scripts/lib/static-render.test.mjs +21 -0
- package/apps/client/scripts/probe-checks.mjs +85 -0
- package/apps/client/scripts/render-card.mjs +710 -0
- package/apps/client/scripts/sample-entries.test.mjs +31 -0
- package/apps/client/scripts/storyboard.test.mjs +149 -0
- package/apps/client/scripts/surface-css.mjs +55 -0
- package/apps/client/scripts/theme-kernel.mjs +236 -0
- package/apps/client/scripts/theme-kernel.test.mjs +136 -0
- package/apps/client/src/._app.config.ts +0 -0
- package/apps/client/src/._vite-env.d.ts +0 -0
- package/apps/client/src/app.config.ts +43 -0
- package/apps/client/src/cards/._AGENTS.md +0 -0
- package/apps/client/src/cards/._registry.ts +0 -0
- package/apps/client/src/cards/AGENTS.md +11 -0
- package/apps/client/src/cards/registry.ts +6 -19
- package/apps/client/src/pages/._page.tsx +0 -0
- package/apps/client/src/pages/index/._index.tsx +0 -0
- package/apps/client/src/pages/index/index.tsx +1 -1
- package/apps/client/src/pages/page.tsx +11 -0
- package/apps/client/src/store/._chat.ts +0 -0
- package/apps/client/src/store/chat.ts +7 -3
- package/apps/client/src/styles/._brand.css +0 -0
- package/apps/client/src/styles/._tailwind.css +0 -0
- package/apps/client/src/styles/brand.css +50 -0
- package/apps/client/src/styles/tailwind.css +326 -0
- package/apps/client/src/test/._setup.ts +0 -0
- package/apps/client/src/vite-env.d.ts +0 -2
- package/apps/client/vite.config.ts +7 -53
- package/apps/server/._package.json +0 -0
- package/apps/server/._tsconfig.json +0 -0
- package/apps/server/._tsup.config.ts +0 -0
- package/apps/server/._vitest.config.ts +0 -0
- package/apps/server/package.json +1 -1
- package/apps/server/scripts/._probe.mjs +0 -0
- package/apps/server/scripts/._scenario-lib.mjs +0 -0
- package/apps/server/scripts/._scenario.mjs +0 -0
- package/apps/server/scripts/probe.mjs +387 -0
- package/apps/server/scripts/scenario-lib.mjs +295 -0
- package/apps/server/scripts/scenario.mjs +67 -0
- package/apps/server/src/._app.ts +0 -0
- package/apps/server/src/._dev.ts +0 -0
- package/apps/server/src/._index.ts +0 -0
- package/apps/server/src/._intent-routes.ts +0 -0
- package/apps/server/src/._pre-tools.ts +0 -0
- package/apps/server/src/app.ts +17 -17
- package/apps/server/src/cards/._AGENTS.md +0 -0
- package/apps/server/src/cards/AGENTS.md +19 -0
- package/apps/server/src/cli/._collect-registry.ts +0 -0
- package/apps/server/src/cli/._plugin-doctor.ts +0 -0
- package/apps/server/src/cli/._plugin-inspect.ts +0 -0
- package/apps/server/src/cli/collect-registry.ts +7 -11
- package/apps/server/src/config/._integration.ts +0 -0
- package/apps/server/src/dev.ts +38 -64
- package/apps/server/src/index.ts +27 -45
- package/apps/server/src/pre-tools.ts +7 -16
- package/apps/server/src/tools/._AGENTS.md +0 -0
- package/apps/server/src/tools/AGENTS.md +23 -0
- package/apps/server/tests/._agent-prompt.test.ts +0 -0
- package/apps/server/tests/._cards-registry.test.ts +0 -0
- package/apps/server/tests/._deployment-loader.test.ts +0 -0
- package/apps/server/tests/._intent-dispatcher.test.ts +0 -0
- package/apps/server/tests/._tool-runtime.test.ts +0 -0
- package/apps/server/tests/cards-registry.test.ts +1 -1
- package/apps/server/tests/helpers/._register.ts +0 -0
- package/apps/server/tests/helpers/register.ts +10 -0
- package/apps/server/tests/tool-runtime.test.ts +1 -28
- package/apps/server/tsconfig.json +1 -1
- package/apps/server/tsup.config.ts +6 -3
- package/config/._AGENTS.md +0 -0
- package/config/._README.md +0 -0
- package/config/._chat.json +0 -0
- package/config/._integrations.json +0 -0
- package/config/._llm_provider.json +0 -0
- package/config/._plugins.json +0 -0
- package/config/AGENTS.md +14 -0
- package/config/README.md +4 -4
- package/config/chat.json +25 -7
- package/config/integrations.json +1 -1
- package/docs/agent/._agent-prompt.md +0 -0
- package/docs/agent/._card-action.md +0 -0
- package/docs/agent/._card.md +0 -0
- package/docs/agent/._conversation.md +0 -0
- package/docs/agent/._kit.md +0 -0
- package/docs/agent/._shell.md +0 -0
- package/docs/agent/._state.md +0 -0
- package/docs/agent/._style.md +0 -0
- package/docs/agent/._tool-emits-card.md +0 -0
- package/docs/agent/._tool.md +0 -0
- package/docs/agent/._verify.md +0 -0
- package/docs/agent/agent-prompt.md +38 -0
- package/docs/agent/card-action.md +101 -0
- package/docs/agent/card.md +159 -0
- package/docs/agent/conversation.md +52 -0
- package/docs/agent/kit.md +80 -0
- package/docs/agent/shell.md +77 -0
- package/docs/agent/state.md +85 -0
- package/docs/agent/style.md +107 -0
- package/docs/agent/tool-emits-card.md +62 -0
- package/docs/agent/tool.md +71 -0
- package/docs/agent/verify.md +188 -0
- package/eslint.config.mjs +18 -0
- package/modules/provider-custom/._AGENTS.md +0 -0
- package/modules/provider-custom/._INTEGRATION.md +0 -0
- package/modules/provider-custom/._LICENSE +0 -0
- package/modules/provider-custom/._README.md +0 -0
- package/modules/provider-custom/._package.json +0 -0
- package/modules/provider-custom/._tbox.module.json +0 -0
- package/modules/provider-custom/._tsconfig.json +0 -0
- package/modules/provider-custom/._tsup.config.ts +0 -0
- package/{packages → modules}/provider-custom/AGENTS.md +6 -6
- package/modules/provider-custom/INTEGRATION.md +10 -0
- package/{packages → modules}/provider-custom/package.json +1 -0
- package/modules/provider-custom/src/._index.ts +0 -0
- package/modules/provider-custom/src/server/._example-adapter.ts +0 -0
- package/modules/provider-custom/src/server/._index.ts +0 -0
- package/{packages → modules}/provider-custom/src/server/example-adapter.ts +2 -2
- package/{packages → modules}/provider-custom/src/server/index.ts +1 -1
- package/modules/provider-custom/tests/._provider-custom.test.ts +0 -0
- package/package.json +38 -7
- package/packages/agent-ui-kit/._AGENTS.md +0 -0
- package/packages/agent-ui-kit/._LICENSE +0 -0
- package/packages/agent-ui-kit/._README.md +0 -0
- package/packages/agent-ui-kit/._catalog.json +0 -0
- package/packages/agent-ui-kit/._package.json +0 -0
- package/packages/agent-ui-kit/._tsconfig.json +0 -0
- package/packages/agent-ui-kit/._vitest.config.ts +0 -0
- package/packages/agent-ui-kit/AGENTS.md +8 -0
- package/packages/agent-ui-kit/README.md +59 -6
- package/packages/agent-ui-kit/assets/._keyboard-circle.svg +0 -0
- package/packages/agent-ui-kit/assets/._more-circle.svg +0 -0
- package/packages/agent-ui-kit/assets/._new-chat.svg +0 -0
- package/packages/agent-ui-kit/assets/._quick-command-star.svg +0 -0
- package/packages/agent-ui-kit/assets/._send-gradient.svg +0 -0
- package/packages/agent-ui-kit/assets/._stop@2x.png +0 -0
- package/packages/agent-ui-kit/assets/._voice-circle.svg +0 -0
- package/packages/agent-ui-kit/catalog.json +855 -0
- package/packages/agent-ui-kit/package.json +24 -9
- package/packages/agent-ui-kit/src/._ChatPage.tsx +0 -0
- package/packages/agent-ui-kit/src/._chat-config.test.ts +0 -0
- package/packages/agent-ui-kit/src/._chat-config.ts +0 -0
- package/packages/agent-ui-kit/src/._icons.ts +0 -0
- package/packages/agent-ui-kit/src/._index.ts +0 -0
- package/packages/agent-ui-kit/src/._preview-provider.tsx +0 -0
- package/packages/agent-ui-kit/src/._shell.contract.json +0 -0
- package/packages/agent-ui-kit/src/._shell.test.ts +0 -0
- package/packages/agent-ui-kit/src/._shell.ts +0 -0
- package/packages/agent-ui-kit/src/._store-context.tsx +0 -0
- package/packages/agent-ui-kit/src/._surface.test.tsx +0 -0
- package/packages/agent-ui-kit/src/._surface.tsx +0 -0
- package/packages/agent-ui-kit/src/._types.ts +0 -0
- package/packages/agent-ui-kit/src/._vite-env.d.ts +0 -0
- package/packages/agent-ui-kit/src/ChatPage.tsx +115 -20
- package/packages/agent-ui-kit/src/card/._action-list-pending.test.tsx +0 -0
- package/packages/agent-ui-kit/src/card/._define-card.test.ts +0 -0
- package/packages/agent-ui-kit/src/card/._define-card.ts +0 -0
- package/packages/agent-ui-kit/src/card/._primitives.test.tsx +0 -0
- package/packages/agent-ui-kit/src/card/._primitives.tsx +0 -0
- package/packages/agent-ui-kit/src/card/._use-card-actions.ts +0 -0
- package/packages/agent-ui-kit/src/card/._view-card-inline.test.tsx +0 -0
- package/packages/agent-ui-kit/src/card/._view-card.test.tsx +0 -0
- package/packages/agent-ui-kit/src/card/._view-card.tsx +0 -0
- package/packages/agent-ui-kit/src/card/action-list-pending.test.tsx +91 -0
- package/packages/agent-ui-kit/src/card/define-card.test.ts +25 -0
- package/packages/agent-ui-kit/src/card/define-card.ts +47 -0
- package/packages/agent-ui-kit/src/card/primitives.test.tsx +157 -0
- package/packages/agent-ui-kit/src/card/primitives.tsx +717 -0
- package/packages/agent-ui-kit/src/card/use-card-actions.ts +86 -0
- package/packages/agent-ui-kit/src/card/view-card-inline.test.tsx +42 -0
- package/packages/agent-ui-kit/src/card/view-card.test.tsx +79 -0
- package/packages/agent-ui-kit/src/card/view-card.tsx +250 -0
- package/packages/agent-ui-kit/src/chat-config.test.ts +35 -71
- package/packages/agent-ui-kit/src/chat-config.ts +29 -7
- package/packages/agent-ui-kit/src/components/._CardRenderer.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ActionBar/._DebugButton.test.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ActionBar/._DebugButton.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ActionBar/._index.test.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ActionBar/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ActionBar/DebugButton.test.tsx +3 -0
- package/packages/agent-ui-kit/src/components/ActionBar/DebugButton.tsx +5 -10
- package/packages/agent-ui-kit/src/components/ActionBar/index.tsx +13 -14
- package/packages/agent-ui-kit/src/components/BottomSheet/._index.test.tsx +0 -0
- package/packages/agent-ui-kit/src/components/BottomSheet/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/BottomSheet/index.test.tsx +97 -0
- package/packages/agent-ui-kit/src/components/BottomSheet/index.tsx +49 -0
- package/packages/agent-ui-kit/src/components/ChatHeader/._index.test.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ChatHeader/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ChatHeader/index.tsx +19 -17
- package/packages/agent-ui-kit/src/components/ChatInput/._index.test.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ChatInput/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ChatInput/index.test.tsx +2 -2
- package/packages/agent-ui-kit/src/components/ChatInput/index.tsx +44 -33
- package/packages/agent-ui-kit/src/components/ChatInput/voice/._VoicePressField.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ChatInput/voice/._VoiceRecordingOverlay.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ChatInput/voice/._machine.ts +0 -0
- package/packages/agent-ui-kit/src/components/ChatInput/voice/._useVoicePress.ts +0 -0
- package/packages/agent-ui-kit/src/components/ChatInput/voice/VoicePressField.tsx +12 -3
- package/packages/agent-ui-kit/src/components/ChatInput/voice/VoiceRecordingOverlay.tsx +9 -9
- package/packages/agent-ui-kit/src/components/ChatInput/voice/useVoicePress.ts +1 -1
- package/packages/agent-ui-kit/src/components/HistoryEntry/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/HistoryEntry/index.tsx +4 -4
- package/packages/agent-ui-kit/src/components/MediaList/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/MediaList/index.tsx +42 -28
- package/packages/agent-ui-kit/src/components/MessageBubble/._index.test.tsx +0 -0
- package/packages/agent-ui-kit/src/components/MessageBubble/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/MessageBubble/index.tsx +59 -28
- package/packages/agent-ui-kit/src/components/PullDownIndicator/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/PullDownIndicator/index.tsx +3 -4
- package/packages/agent-ui-kit/src/components/QuickCommands/._index.test.tsx +0 -0
- package/packages/agent-ui-kit/src/components/QuickCommands/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/QuickCommands/index.test.tsx +3 -1
- package/packages/agent-ui-kit/src/components/QuickCommands/index.tsx +33 -10
- package/packages/agent-ui-kit/src/components/ReasoningBlock/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ReasoningBlock/index.tsx +14 -9
- package/packages/agent-ui-kit/src/components/ScrollToBottomButton/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ScrollToBottomButton/index.tsx +7 -5
- package/packages/agent-ui-kit/src/components/ToolCallBlock/._detail.test.ts +0 -0
- package/packages/agent-ui-kit/src/components/ToolCallBlock/._detail.ts +0 -0
- package/packages/agent-ui-kit/src/components/ToolCallBlock/._index.test.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ToolCallBlock/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ToolCallBlock/._titles.ts +0 -0
- package/packages/agent-ui-kit/src/components/ToolCallBlock/index.tsx +58 -38
- package/packages/agent-ui-kit/src/hooks/._use-drag-gesture.test.ts +0 -0
- package/packages/agent-ui-kit/src/hooks/._use-drag-gesture.ts +0 -0
- package/packages/agent-ui-kit/src/hooks/._use-pull-down-history.ts +0 -0
- package/packages/agent-ui-kit/src/hooks/._use-pull-down-wheel-native.test.ts +0 -0
- package/packages/agent-ui-kit/src/hooks/._useMediaUpload.ts +0 -0
- package/packages/agent-ui-kit/src/hooks/._useTTSAutoPlay.ts +0 -0
- package/packages/agent-ui-kit/src/icons.ts +39 -0
- package/packages/agent-ui-kit/src/index.ts +76 -2
- package/packages/agent-ui-kit/src/overlay/._Overlay.tsx +0 -0
- package/packages/agent-ui-kit/src/overlay/._focus.ts +0 -0
- package/packages/agent-ui-kit/src/overlay/._index.ts +0 -0
- package/packages/agent-ui-kit/src/overlay/._inert.ts +0 -0
- package/packages/agent-ui-kit/src/overlay/._layers.ts +0 -0
- package/packages/agent-ui-kit/src/overlay/._overlay.ssr.test.tsx +0 -0
- package/packages/agent-ui-kit/src/overlay/._overlay.test.tsx +0 -0
- package/packages/agent-ui-kit/src/overlay/._presence.ts +0 -0
- package/packages/agent-ui-kit/src/overlay/._scroll-lock.ts +0 -0
- package/packages/agent-ui-kit/src/overlay/._stack.ts +0 -0
- package/packages/agent-ui-kit/src/overlay/._use-overlay.ts +0 -0
- package/packages/agent-ui-kit/src/overlay/Overlay.tsx +154 -0
- package/packages/agent-ui-kit/src/overlay/focus.ts +53 -0
- package/packages/agent-ui-kit/src/overlay/index.ts +16 -0
- package/packages/agent-ui-kit/src/overlay/inert.ts +27 -0
- package/packages/agent-ui-kit/src/overlay/layers.ts +21 -0
- package/packages/agent-ui-kit/src/overlay/overlay.ssr.test.tsx +27 -0
- package/packages/agent-ui-kit/src/overlay/overlay.test.tsx +209 -0
- package/packages/agent-ui-kit/src/overlay/presence.ts +86 -0
- package/packages/agent-ui-kit/src/overlay/scroll-lock.ts +62 -0
- package/packages/agent-ui-kit/src/overlay/stack.ts +111 -0
- package/packages/agent-ui-kit/src/overlay/use-overlay.ts +80 -0
- package/packages/agent-ui-kit/src/preview-provider.tsx +47 -0
- package/packages/agent-ui-kit/src/shell.contract.json +75 -0
- package/packages/agent-ui-kit/src/shell.test.ts +72 -0
- package/packages/agent-ui-kit/src/shell.ts +60 -0
- package/packages/agent-ui-kit/src/surface.test.tsx +35 -0
- package/packages/agent-ui-kit/src/surface.tsx +44 -0
- package/packages/agent-ui-kit/src/test/._setup.ts +0 -0
- package/packages/agent-ui-kit/src/theme/._base.css +0 -0
- package/packages/agent-ui-kit/src/theme/._contract.json +0 -0
- package/packages/agent-ui-kit/src/theme/._motion.css +0 -0
- package/packages/agent-ui-kit/src/theme/._theme-contract.test.ts +0 -0
- package/packages/agent-ui-kit/src/theme/._theme.ts +0 -0
- package/packages/agent-ui-kit/src/theme/._tokens.css +0 -0
- package/packages/agent-ui-kit/src/theme/base.css +167 -0
- package/packages/agent-ui-kit/src/theme/contract.json +123 -2
- package/packages/agent-ui-kit/src/theme/theme-contract.test.ts +19 -3
- package/packages/agent-ui-kit/src/theme/{tokens.less → tokens.css} +19 -20
- package/packages/agent-ui-kit/src/utils/._copyText.ts +0 -0
- package/packages/agent-ui-kit/src/utils/._haptics.test.ts +0 -0
- package/packages/agent-ui-kit/src/utils/._haptics.ts +0 -0
- package/packages/agent-ui-kit/src/utils/._image-preview-host.tsx +0 -0
- package/packages/agent-ui-kit/src/utils/._imagePreview.test.ts +0 -0
- package/packages/agent-ui-kit/src/utils/._imagePreview.ts +0 -0
- package/packages/agent-ui-kit/src/utils/._pull-down-machine.test.ts +0 -0
- package/packages/agent-ui-kit/src/utils/._pull-down-machine.ts +0 -0
- package/packages/agent-ui-kit/src/utils/._session-error.ts +0 -0
- package/packages/agent-ui-kit/src/utils/._toast.test.ts +0 -0
- package/packages/agent-ui-kit/src/utils/._toast.ts +0 -0
- package/packages/agent-ui-kit/src/utils/._tool-call-display.test.ts +0 -0
- package/packages/agent-ui-kit/src/utils/._tool-call-display.ts +0 -0
- package/packages/agent-ui-kit/src/utils/image-preview-host.tsx +95 -0
- package/packages/agent-ui-kit/src/utils/imagePreview.test.ts +32 -0
- package/packages/agent-ui-kit/src/utils/imagePreview.ts +14 -5
- package/packages/agent-ui-kit/src/utils/toast.test.ts +64 -0
- package/packages/agent-ui-kit/src/utils/toast.ts +100 -7
- package/packages/contracts-mall/._package.json +0 -0
- package/packages/contracts-mall/._tsconfig.json +0 -0
- package/packages/contracts-mall/src/._index.ts +0 -0
- package/packages/contracts-mall/src/._runtime.ts +0 -0
- package/packages/contracts-mall/src/server/._index.ts +0 -0
- package/packages/shared/._AGENTS.md +0 -0
- package/packages/shared/._package.json +0 -0
- package/packages/shared/._tsconfig.json +0 -0
- package/packages/shared/AGENTS.md +13 -0
- package/packages/shared/package.json +20 -0
- package/packages/shared/src/._index.ts +0 -0
- package/packages/shared/src/index.ts +8 -0
- package/packages/shared/tsconfig.json +7 -0
- package/pnpm-lock.template.yaml +781 -846
- package/pnpm-workspace.template.yaml +19 -11
- package/profiles/._mall.json +0 -0
- package/profiles/mall/._TEMPLATE.md +0 -0
- package/profiles/mall/._chat.overrides.json +0 -0
- package/profiles/mall/chat.overrides.json +12 -0
- package/profiles/mall/config/._agent.jsonc +0 -0
- package/profiles/mall/config/._chat.json +0 -0
- package/profiles/mall/config/._knowledge.json +0 -0
- package/profiles/mall/config/chat.json +14 -6
- package/profiles/mall.json +2 -2
- package/scenarios/._README.md +0 -0
- package/scenarios/README.md +7 -0
- package/scripts/._assert-pack.mjs +0 -0
- package/scripts/._build.sh +0 -0
- package/scripts/._check-css-target.mjs +0 -0
- package/scripts/._check-fast.mjs +0 -0
- package/scripts/._check-workspace.mjs +0 -0
- package/scripts/._checks.json +0 -0
- package/scripts/._deliver.mjs +0 -0
- package/scripts/._dev-alipay.mjs +0 -0
- package/scripts/._dev.sh +0 -0
- package/scripts/._generate.mjs +0 -0
- package/scripts/._prepare.sh +0 -0
- package/scripts/._shell-probe.mjs +0 -0
- package/scripts/._smoke.mjs +0 -0
- package/scripts/._start.sh +0 -0
- package/scripts/._stop.sh +0 -0
- package/scripts/._storyboard.mjs +0 -0
- package/scripts/._verify-generated.mjs +0 -0
- package/scripts/assert-pack.mjs +48 -0
- package/scripts/check-css-target.mjs +54 -0
- package/scripts/check-fast.mjs +119 -0
- package/scripts/check-workspace.mjs +68 -19
- package/scripts/checks.json +627 -0
- package/scripts/deliver.mjs +183 -0
- package/scripts/dev-alipay.mjs +1 -1
- package/scripts/generate.mjs +3 -0
- package/scripts/lib/._chrome-pipe.mjs +0 -0
- package/scripts/lib/._geometry-kernel.mjs +0 -0
- package/scripts/lib/chrome-pipe.mjs +95 -0
- package/scripts/lib/geometry-kernel.mjs +137 -0
- package/scripts/shell-probe.mjs +280 -0
- package/scripts/storyboard.mjs +350 -0
- package/scripts/verify-generated.mjs +22 -127
- package/tsconfig.base.json +1 -0
- package/apps/client/STYLE_GUIDE.md +0 -81
- package/apps/client/VISUAL_RESTORE.md +0 -90
- package/apps/client/src/app.tsx +0 -11
- package/apps/client/src/business/App.tsx +0 -11
- package/apps/client/src/business/README.md +0 -99
- package/apps/client/src/business/routes.json +0 -3
- package/apps/client/src/main.tsx +0 -17
- package/apps/client/src/modules.ts +0 -33
- package/apps/client/src/platform/AgentChatApp.tsx +0 -14
- package/apps/client/src/platform/AppShell.tsx +0 -42
- package/apps/client/src/platform/agent-runtime.ts +0 -16
- package/apps/client/src/platform/bootstrap.ts +0 -55
- package/apps/client/src/platform/card-preview-page.tsx +0 -12
- package/apps/client/src/platform/mount-page.tsx +0 -25
- package/apps/client/src/platform/state/createPersistedStore.ts +0 -19
- package/apps/server/src/app-tools.ts +0 -14
- package/apps/server/src/modules.ts +0 -38
- package/apps/server/src/tools/clock.ts +0 -24
- package/apps/server/src/tools/translate.ts +0 -47
- package/packages/agent-ui-kit/src/ChatPage.less +0 -66
- package/packages/agent-ui-kit/src/components/ActionBar/index.less +0 -123
- package/packages/agent-ui-kit/src/components/ChatHeader/index.less +0 -148
- package/packages/agent-ui-kit/src/components/ChatInput/index.less +0 -394
- package/packages/agent-ui-kit/src/components/HistoryEntry/index.less +0 -49
- package/packages/agent-ui-kit/src/components/MediaList/index.less +0 -241
- package/packages/agent-ui-kit/src/components/MessageBubble/index.less +0 -325
- package/packages/agent-ui-kit/src/components/PullDownIndicator/index.less +0 -32
- package/packages/agent-ui-kit/src/components/QuickCommands/index.less +0 -63
- package/packages/agent-ui-kit/src/components/ReasoningBlock/index.less +0 -90
- package/packages/agent-ui-kit/src/components/ScrollToBottomButton/index.less +0 -32
- package/packages/agent-ui-kit/src/components/ToolCallBlock/index.less +0 -312
- package/packages/agent-ui-kit/src/theme/global.less +0 -99
- package/profiles/mall/config/llm_provider.json +0 -5
- package/profiles/mall/config/plugins.json +0 -3
- /package/{packages → modules}/provider-custom/LICENSE +0 -0
- /package/{packages → modules}/provider-custom/README.md +0 -0
- /package/{packages → modules}/provider-custom/src/index.ts +0 -0
- /package/{packages → modules}/provider-custom/tbox.module.json +0 -0
- /package/{packages → modules}/provider-custom/tests/provider-custom.test.ts +0 -0
- /package/{packages → modules}/provider-custom/tsconfig.json +0 -0
- /package/{packages → modules}/provider-custom/tsup.config.ts +0 -0
- /package/packages/agent-ui-kit/src/theme/{motion.less → motion.css} +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "对话壳契约数据(docs/agent/kit.md 与 shell.test.ts 的共同来源;改这里 = 改壳的对外承诺)。regions = ChatPage 渲染的区域;internal = 不承诺稳定的内部结构。",
|
|
3
|
+
"regions": [
|
|
4
|
+
{
|
|
5
|
+
"id": "brand",
|
|
6
|
+
"area": "brand",
|
|
7
|
+
"selector": ".chat-page__brand",
|
|
8
|
+
"drivenBy": ["chat.json identity.name", "chat.json identity.tagline", "HELLO_ACK mallScope.mallName(缺省回落)"],
|
|
9
|
+
"brandable": true
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "welcome",
|
|
13
|
+
"area": "welcome",
|
|
14
|
+
"selector": ".chat-page__welcome",
|
|
15
|
+
"drivenBy": ["chat.json welcome.title", "chat.json welcome.subtitle", "chat.json identity(缺省回落)"],
|
|
16
|
+
"brandable": true
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": "messages",
|
|
20
|
+
"area": "messages",
|
|
21
|
+
"selector": ".chat-page__body",
|
|
22
|
+
"drivenBy": ["chat store messages / historyMessages"],
|
|
23
|
+
"brandable": false
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "history-entry",
|
|
27
|
+
"area": "history",
|
|
28
|
+
"selector": ".history-entry",
|
|
29
|
+
"drivenBy": ["chat store historyHasMore / isLoadingHistory"],
|
|
30
|
+
"brandable": false
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "home-slot",
|
|
34
|
+
"area": "home",
|
|
35
|
+
"selector": ".chat-page__home-slot",
|
|
36
|
+
"drivenBy": ["客户端槽 home"],
|
|
37
|
+
"brandable": false
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": "conversation-overlay",
|
|
41
|
+
"area": "conversation-overlay",
|
|
42
|
+
"selector": ".chat-page__conversation-overlay",
|
|
43
|
+
"drivenBy": ["客户端槽 conversationOverlay"],
|
|
44
|
+
"brandable": false
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "quick-commands",
|
|
48
|
+
"area": "quick-commands",
|
|
49
|
+
"selector": ".quick-commands",
|
|
50
|
+
"drivenBy": ["chat.json quickCommands"],
|
|
51
|
+
"brandable": true
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "input",
|
|
55
|
+
"area": "input",
|
|
56
|
+
"selector": ".tbox-chat-input",
|
|
57
|
+
"drivenBy": ["chat.json(enableTTS 等)", "chat store runtimeStatus / isGenerating"],
|
|
58
|
+
"brandable": false
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"controls": [
|
|
62
|
+
{ "id": "new-chat", "selector": "[data-tbox-control='new-chat']", "name": "新建对话", "minHit": 44 },
|
|
63
|
+
{ "id": "voice-toggle", "selector": "[data-tbox-control='voice-toggle']", "name": "语音输入", "minHit": 44, "capability": "input.voice" },
|
|
64
|
+
{ "id": "send", "selector": "[data-tbox-control='send']", "name": "发送", "minHit": 44 },
|
|
65
|
+
{ "id": "stop", "selector": "[data-tbox-control='stop']", "name": "停止生成", "minHit": 44 },
|
|
66
|
+
{ "id": "media-add", "selector": "[data-tbox-control='media-add']", "name": "添加图片或视频", "minHit": 44, "capability": ["input.image", "input.video"] },
|
|
67
|
+
{ "id": "history", "selector": "[data-tbox-control='history']", "name": "历史记录", "minHit": 44 },
|
|
68
|
+
{ "id": "scroll-bottom", "selector": "[data-tbox-control='scroll-bottom']", "name": "回到底部", "minHit": 44 }
|
|
69
|
+
],
|
|
70
|
+
"internal": [
|
|
71
|
+
"MessageBubble 内部结构(.msg-row / .msg-main / .msg-thinking)",
|
|
72
|
+
"ChatInput 内部结构(.tbox-media-picker、发送按钮)",
|
|
73
|
+
"卡片渲染器内部结构(.tbox-card-*)"
|
|
74
|
+
]
|
|
75
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { SHELL_CONTRACT, resolveBrandName } from './shell';
|
|
6
|
+
|
|
7
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const read = (rel: string) => readFileSync(path.join(here, rel), 'utf8');
|
|
9
|
+
|
|
10
|
+
/** 契约声明的选择器必须真的出现在源码里——「文档说有、代码没接」在这里失败。 */
|
|
11
|
+
const SELECTOR_SOURCES: Record<string, string[]> = {
|
|
12
|
+
'.chat-page__brand': ['ChatPage.tsx'],
|
|
13
|
+
'.chat-page__welcome': ['ChatPage.tsx'],
|
|
14
|
+
'.chat-page__body': ['ChatPage.tsx'],
|
|
15
|
+
'.history-entry': ['components/HistoryEntry/index.tsx'],
|
|
16
|
+
'.chat-page__home-slot': ['ChatPage.tsx'],
|
|
17
|
+
'.chat-page__conversation-overlay': ['ChatPage.tsx'],
|
|
18
|
+
'.quick-commands': ['components/QuickCommands/index.tsx'],
|
|
19
|
+
'.tbox-chat-input': ['components/ChatInput/index.tsx'],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe('壳契约', () => {
|
|
23
|
+
it('区域 id 唯一且每个选择器都有源码出处', () => {
|
|
24
|
+
const ids = SHELL_CONTRACT.regions.map((region) => region.id);
|
|
25
|
+
expect(new Set(ids).size).toBe(ids.length);
|
|
26
|
+
for (const region of SHELL_CONTRACT.regions) {
|
|
27
|
+
const sources = SELECTOR_SOURCES[region.selector];
|
|
28
|
+
expect(sources, `壳契约新增选择器 ${region.selector} 时同步补源码映射`).toBeDefined();
|
|
29
|
+
const className = region.selector.replace(/^\./, '');
|
|
30
|
+
const found = sources.some((file) => read(file).includes(className));
|
|
31
|
+
expect(found, `${region.id}: ${region.selector} 在源码里不存在`).toBe(true);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('可覆写区域只限壳层类名,内部结构排除在外', () => {
|
|
36
|
+
for (const region of SHELL_CONTRACT.regions.filter((item) => item.brandable)) {
|
|
37
|
+
expect(region.selector.startsWith('.chat-page__') || region.selector === '.quick-commands').toBe(true);
|
|
38
|
+
}
|
|
39
|
+
expect(SHELL_CONTRACT.internal.length).toBeGreaterThan(0);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('每个区域都写明驱动来源', () => {
|
|
43
|
+
for (const region of SHELL_CONTRACT.regions) {
|
|
44
|
+
expect(region.drivenBy.length, `${region.id} 缺 drivenBy`).toBeGreaterThan(0);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('控件契约的 data-tbox-control 都在源码里', () => {
|
|
49
|
+
const sources = ['components/ChatInput/index.tsx', 'components/HistoryEntry/index.tsx', 'components/ScrollToBottomButton/index.tsx'];
|
|
50
|
+
for (const control of SHELL_CONTRACT.controls ?? []) {
|
|
51
|
+
const attr = /data-tbox-control=['"]([^'"]+)['"]/.exec(control.selector)?.[1];
|
|
52
|
+
expect(attr, `控件 ${control.id} 的选择器必须用 data-tbox-control`).toBeTruthy();
|
|
53
|
+
expect(sources.some((file) => read(file).includes('data-tbox-control="' + attr + '"')), `控件 ${control.id} 在源码里不存在`).toBe(true);
|
|
54
|
+
expect(control.minHit).toBeGreaterThanOrEqual(44);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('品牌名三级来源', () => {
|
|
60
|
+
it('identity.name 优先', () => {
|
|
61
|
+
expect(resolveBrandName({ name: '悦享里', tagline: '商圈助手' }, '某商场')).toBe('悦享里');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('缺 identity 时回落 HELLO_ACK 的 mallName', () => {
|
|
65
|
+
expect(resolveBrandName(undefined, '某商场')).toBe('某商场');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('都没有则不渲染', () => {
|
|
69
|
+
expect(resolveBrandName(undefined, undefined)).toBeUndefined();
|
|
70
|
+
expect(resolveBrandName({ name: '' }, undefined)).toBeUndefined();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 对话壳契约:哪些区域由什么驱动、哪些选择器可以覆写。
|
|
3
|
+
*
|
|
4
|
+
* 数据在 `shell.contract.json`(`docs/agent/kit.md` 与 `shell.test.ts` 的共同来源);
|
|
5
|
+
* 本文件只做类型收口与品牌名解析。
|
|
6
|
+
*
|
|
7
|
+
* - `docs/agent/shell.md` 的「能改什么」表由契约数据生成,杜绝「文档说有、代码没接」;
|
|
8
|
+
* - `shell.test.ts` 断言每条声明在源码里真的成立,声明与实现漂移即失败。
|
|
9
|
+
*
|
|
10
|
+
* 只描述壳层(ChatPage 渲染的区域)。kit 内部组件(MessageBubble、ChatInput 的内部结构)
|
|
11
|
+
* 不承诺稳定;改样式请用契约里 `brandable: true` 的选择器。
|
|
12
|
+
*/
|
|
13
|
+
import type { ChatIdentity } from './chat-config';
|
|
14
|
+
import contract from './shell.contract.json';
|
|
15
|
+
|
|
16
|
+
export type ShellArea = 'brand' | 'welcome' | 'messages' | 'history' | 'home' | 'quick-commands' | 'input' | 'conversation-overlay';
|
|
17
|
+
|
|
18
|
+
export interface ShellRegion {
|
|
19
|
+
/** 稳定 id(文档与测试引用) */
|
|
20
|
+
id: string;
|
|
21
|
+
/** 作用区域 */
|
|
22
|
+
area: ShellArea;
|
|
23
|
+
/** 根类名(应用可据此覆写) */
|
|
24
|
+
selector: string;
|
|
25
|
+
/** 由什么驱动:配置键、槽或 store 字段 */
|
|
26
|
+
drivenBy: string[];
|
|
27
|
+
/** 可覆写(`brand.css` 里改它算受支持用法) */
|
|
28
|
+
brandable: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ShellControl {
|
|
32
|
+
/** 稳定 id(探针与文档引用) */
|
|
33
|
+
id: string;
|
|
34
|
+
/** 可定位的选择器(data-tbox-control) */
|
|
35
|
+
selector: string;
|
|
36
|
+
/** 可访问名 */
|
|
37
|
+
name: string;
|
|
38
|
+
/** 最小命中区(px) */
|
|
39
|
+
minHit: number;
|
|
40
|
+
/** 能力开关(关闭时控件可缺席) */
|
|
41
|
+
capability?: string | string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ShellContract {
|
|
45
|
+
regions: ShellRegion[];
|
|
46
|
+
/** 交互控件契约:探针按它查,不按内部类名猜 */
|
|
47
|
+
controls?: ShellControl[];
|
|
48
|
+
/** 不承诺稳定、不要覆写的内部结构 */
|
|
49
|
+
internal: string[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const SHELL_CONTRACT: ShellContract = contract as ShellContract;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 品牌名三级来源:`chat.json identity.name` → `HELLO_ACK mallScope.mallName` → 无(不渲染品牌条)。
|
|
56
|
+
* 智能体身份是配置项,不是代码:应用只改 `config/chat.json`。
|
|
57
|
+
*/
|
|
58
|
+
export function resolveBrandName(identity: ChatIdentity | undefined, mallName: string | undefined): string | undefined {
|
|
59
|
+
return identity?.name || mallName || undefined;
|
|
60
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
4
|
+
import { Card, CardButton, CardHeader, defineCard, useCardActions } from './index';
|
|
5
|
+
import { createSurfaceHarness } from './surface';
|
|
6
|
+
|
|
7
|
+
/** 一张用 kit 动作的卡:没有 provider 会抛「KitChatProvider 缺席」。 */
|
|
8
|
+
const DemoCard = defineCard({ type: 'demo-card' }, ({ data, cardId, isHistory }) => {
|
|
9
|
+
const api = useCardActions({ cardId, isHistory });
|
|
10
|
+
return (
|
|
11
|
+
<Card>
|
|
12
|
+
<CardHeader title={String((data as { title: string }).title)} />
|
|
13
|
+
<CardButton onClick={() => api.send('继续')}>继续</CardButton>
|
|
14
|
+
</Card>
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('createSurfaceHarness', () => {
|
|
19
|
+
it('给出与运行时同形的 provider,kit 卡片可直接渲染', () => {
|
|
20
|
+
const harness = createSurfaceHarness({ cards: { 'demo-card': DemoCard } });
|
|
21
|
+
const html = renderToStaticMarkup(
|
|
22
|
+
harness.wrap(createElement(DemoCard, { data: { title: '停车订单' }, cardId: 'c1', isHistory: false })),
|
|
23
|
+
);
|
|
24
|
+
expect(html).toContain('停车订单');
|
|
25
|
+
expect(html).toContain('继续');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('历史态可渲染且动作禁用', () => {
|
|
29
|
+
const harness = createSurfaceHarness({ cards: { 'demo-card': DemoCard } });
|
|
30
|
+
const html = renderToStaticMarkup(
|
|
31
|
+
harness.wrap(createElement(DemoCard, { data: { title: '停车订单' }, cardId: 'c1', isHistory: true })),
|
|
32
|
+
);
|
|
33
|
+
expect(html).toContain('disabled');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SurfaceHarness:卡片/聊天表面的唯一装配入口。
|
|
3
|
+
*
|
|
4
|
+
* 证据(check:fast)、截图(card render)、预览页都要渲染真实组件——但每个入口都手搭
|
|
5
|
+
* provider 栈,就会出现「预览崩、证据过、运行时坏」的分裂。这里把 store + provider 收成
|
|
6
|
+
* 一个工厂:看到的就是运行时看到的。
|
|
7
|
+
*
|
|
8
|
+
* 用法:
|
|
9
|
+
* const harness = createSurfaceHarness({ cards, state });
|
|
10
|
+
* renderToStaticMarkup(harness.wrap(<MyCard ... />));
|
|
11
|
+
*/
|
|
12
|
+
import type { ReactNode } from 'react';
|
|
13
|
+
import type { CardComponent } from '@tbox.cn/app-contracts';
|
|
14
|
+
import type { ClientSlotRegistry, CoreChatState } from '@tbox.cn/app-agent-sdk-client';
|
|
15
|
+
import { KitChatProvider } from './store-context';
|
|
16
|
+
import { createPreviewStore } from './preview-provider';
|
|
17
|
+
|
|
18
|
+
export interface SurfaceHarnessOptions {
|
|
19
|
+
/** cards = 组合层注册表(含覆盖);rawCards 缺省同 cards。 */
|
|
20
|
+
cards?: Record<string, CardComponent>;
|
|
21
|
+
rawCards?: Record<string, CardComponent>;
|
|
22
|
+
/** 客户端槽(home);缺省无。 */
|
|
23
|
+
slots?: ClientSlotRegistry;
|
|
24
|
+
/** store 初值覆盖(如 isGenerating / 历史态)。 */
|
|
25
|
+
state?: Partial<CoreChatState>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface SurfaceHarness {
|
|
29
|
+
store: ReturnType<typeof createPreviewStore>;
|
|
30
|
+
/** 把一个元素包进与运行时同形的 provider 树。 */
|
|
31
|
+
wrap: (node: ReactNode) => ReactNode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function createSurfaceHarness(options: SurfaceHarnessOptions = {}): SurfaceHarness {
|
|
35
|
+
const cards = options.cards ?? {};
|
|
36
|
+
const rawCards = options.rawCards ?? cards;
|
|
37
|
+
const store = createPreviewStore(options.state);
|
|
38
|
+
const wrap = (node: ReactNode): ReactNode => (
|
|
39
|
+
<KitChatProvider store={store} cards={cards} rawCards={rawCards} {...(options.slots ? { slots: options.slots } : {})}>
|
|
40
|
+
{node}
|
|
41
|
+
</KitChatProvider>
|
|
42
|
+
);
|
|
43
|
+
return { store, wrap };
|
|
44
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 基座重置(进 `@layer base`):盒模型、文档级字体、卡框与重置规则都在这一层,
|
|
3
|
+
* 组件上的工具类可以覆写它们;层外的跨组件规则见文件末尾(有意留层外)。
|
|
4
|
+
* token 来自 tokens.css / motion.css。
|
|
5
|
+
*/
|
|
6
|
+
@import './tokens.css';
|
|
7
|
+
@import './motion.css';
|
|
8
|
+
|
|
9
|
+
@layer base {
|
|
10
|
+
* {
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
html,
|
|
15
|
+
body,
|
|
16
|
+
#root {
|
|
17
|
+
margin: 0;
|
|
18
|
+
padding: 0;
|
|
19
|
+
height: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
body {
|
|
23
|
+
/* mall-vis 字栈:demo 拉丁栈 + 显式 CJK(demo 依赖容器隐式 CJK,模板面向开放浏览器) */
|
|
24
|
+
font-family:
|
|
25
|
+
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC',
|
|
26
|
+
'Microsoft YaHei', sans-serif;
|
|
27
|
+
font-size: var(--tbox-fs-body);
|
|
28
|
+
color: var(--tbox-text-primary);
|
|
29
|
+
background: var(--tbox-bg-page);
|
|
30
|
+
-webkit-font-smoothing: antialiased;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* 顶层容器全宽(渐变底铺满),内容区由各处 max-width:800px 居中(对齐原模板 #app)。 */
|
|
34
|
+
#root {
|
|
35
|
+
width: 100%;
|
|
36
|
+
position: relative;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* 去掉移动端点击高亮 */
|
|
40
|
+
* {
|
|
41
|
+
-webkit-tap-highlight-color: transparent;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* 卡片统一外层 = 卡片「卡框」。所有卡片共有的框在这里,单卡组件别重复写:
|
|
45
|
+
- 间距:卡片与上下元素(工具调用 / 气泡)的间距,与 .tool-calls 一致;
|
|
46
|
+
- 外观:默认背景(白) / 1px 边框 / 圆角 / 阴影;`overflow:hidden` 把内容裁进圆角;
|
|
47
|
+
- 入场动效:mount 即播(0.36s 上浮淡入,对齐 mall-vis 消息卡节奏)。
|
|
48
|
+
值为物理 px(大写 PX):圆角 var(--tbox-radius-lg)=24、边框 1、阴影 var(--tbox-shadow-sm)=0 4 13。
|
|
49
|
+
⚠️ **内边距不在卡框里**——由卡片自己写。卡框给 padding 会让「自带背景色的卡」在外面露一圈白边(卡里套卡)。
|
|
50
|
+
宽度也不在卡框里:默认占满整列(≈移动端 350~400px 设计宽),紧凑卡自己写 max-width。
|
|
51
|
+
单卡组件(.tbox-<type>)只画内容;**要整卡换底色 / 出血图,直接在自己 root 上 `background:<色>` 或铺满图**——
|
|
52
|
+
会铺满卡框、裁进圆角、不出白边(别再自己设圆角,卡框已裁)。不写背景则露卡框默认白底,不透明。 */
|
|
53
|
+
.tbox-card {
|
|
54
|
+
margin-bottom: 6PX;
|
|
55
|
+
background: var(--tbox-bg-card);
|
|
56
|
+
border: 1PX solid var(--tbox-border);
|
|
57
|
+
border-radius: var(--tbox-radius-lg);
|
|
58
|
+
box-shadow: var(--tbox-shadow-sm);
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
animation: tbox-card-enter var(--tbox-motion-duration-slow) ease;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@keyframes tbox-card-enter {
|
|
64
|
+
from {
|
|
65
|
+
opacity: 0;
|
|
66
|
+
transform: translateY(8PX);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
to {
|
|
70
|
+
opacity: 1;
|
|
71
|
+
transform: translateY(0);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@media (prefers-reduced-motion: reduce) {
|
|
76
|
+
.tbox-card {
|
|
77
|
+
animation: none;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* ===== 弹层进出场(kit overlay 内核;工具类 animate-[tbox-sheet-in_…] 引用) =====
|
|
82
|
+
只做 transform / opacity(两个属性在所有兼容基线内且可合成)。退出动画配 `both` 填充,
|
|
83
|
+
保证动画结束后元素停在收起位,等 usePresence 卸载。 */
|
|
84
|
+
@keyframes tbox-sheet-in {
|
|
85
|
+
from {
|
|
86
|
+
transform: translateY(100%);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
to {
|
|
90
|
+
transform: translateY(0);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@keyframes tbox-sheet-out {
|
|
95
|
+
from {
|
|
96
|
+
transform: translateY(0);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
to {
|
|
100
|
+
transform: translateY(100%);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@keyframes tbox-fade-in {
|
|
105
|
+
from {
|
|
106
|
+
opacity: 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
to {
|
|
110
|
+
opacity: 1;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@keyframes tbox-fade-out {
|
|
115
|
+
from {
|
|
116
|
+
opacity: 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
to {
|
|
120
|
+
opacity: 0;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* 多卡纵向容器(SDK CardCarousel 多卡分支):容器内卡片关闭逐卡入场动画——
|
|
125
|
+
同屏多卡逐张挂载时 0.36s 上浮淡入会交叠抖动;单卡直出与其他场景的入场动画保留
|
|
126
|
+
(命中卡片本体 .tbox-card:卡框动画在自身规则上,item 中间层无动画规则) */
|
|
127
|
+
.tbox-card-stack .tbox-card {
|
|
128
|
+
animation: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* 兜底态(未知 cardType / 渲染出错,由 CardRenderer 给外层加此修饰类):
|
|
132
|
+
复用卡框,弱化成无阴影的虚线提示框(内边距自带,因为卡框不再给 padding) */
|
|
133
|
+
.tbox-card--fallback {
|
|
134
|
+
max-width: 80%;
|
|
135
|
+
padding: 16PX 12PX;
|
|
136
|
+
background: var(--tbox-bg-subtle);
|
|
137
|
+
border: 0.5PX dashed var(--tbox-border);
|
|
138
|
+
box-shadow: none;
|
|
139
|
+
color: var(--tbox-text-muted);
|
|
140
|
+
font-size: var(--tbox-fs-caption);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
/* 表单控件继承排版:模板不引 preflight,原生 button/input 否则落到浏览器默认 13.33px(越档字号)。
|
|
145
|
+
作用域限定在壳与卡片内,工具类仍可覆写。 */
|
|
146
|
+
:where(.tbox-app, .chat-page, .tbox-card) :where(button, input, textarea, select) {
|
|
147
|
+
font: inherit;
|
|
148
|
+
color: inherit;
|
|
149
|
+
letter-spacing: inherit;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* 基元/模块迁移后不再各自写 margin reset:标题、段落、列表统一归零(在 base 层,工具类可覆写)。 */
|
|
153
|
+
h1, h2, h3, h4, h5, h6, p, dl, dd, dt, ul, ol {
|
|
154
|
+
margin: 0;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* ── 层外:壳的跨组件覆写(必须压过工具类,故不进 @layer) ── */
|
|
159
|
+
/* 录音期间锁页面(由 useVoicePress 在 document.body 上 toggle,不是 TSX 元素):
|
|
160
|
+
禁选中/拖拽/长按菜单,必须压过浏览器默认与页面内联样式。 */
|
|
161
|
+
.tbox-voice-page-lock,
|
|
162
|
+
.tbox-voice-page-lock * {
|
|
163
|
+
-webkit-user-select: none !important;
|
|
164
|
+
user-select: none !important;
|
|
165
|
+
-webkit-touch-callout: none !important;
|
|
166
|
+
-webkit-user-drag: none !important;
|
|
167
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$comment": "主题可覆写变量封闭清单(主题轨 W-T2;doctor theme-package-structure 消费——超集即 error;theme-contract.test.ts 锁 tokens.
|
|
2
|
+
"$comment": "主题可覆写变量封闭清单(主题轨 W-T2;doctor theme-package-structure 消费——超集即 error;theme-contract.test.ts 锁 tokens.css+motion.css 的平台键 ⊆ platform 段)。domains 段 = 域色两段式通道(identity/surface/border 三角色,v1 封闭;promotion 按域色矩阵无描边列)。assets 段 = 素材变量链语义位(W-T3 铺开,铺开后逐一核对)。 pairs 段 = 对比度对账清单(fg/bg 都是 platform 键;min 为 WCAG 阈值;color-mix 派生的由浏览器车道补验)。",
|
|
3
3
|
"platform": [
|
|
4
4
|
"--tbox-accent",
|
|
5
5
|
"--tbox-accent-light",
|
|
@@ -68,5 +68,126 @@
|
|
|
68
68
|
"--tbox-asset-promotion-activity-header",
|
|
69
69
|
"--tbox-asset-promotion-coupon-header",
|
|
70
70
|
"--tbox-asset-sg-header"
|
|
71
|
-
]
|
|
71
|
+
],
|
|
72
|
+
"pairs": [
|
|
73
|
+
{
|
|
74
|
+
"fg": "--tbox-text-primary",
|
|
75
|
+
"bg": "--tbox-bg-card",
|
|
76
|
+
"min": 4.5,
|
|
77
|
+
"usage": "正文"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"fg": "--tbox-text-primary",
|
|
81
|
+
"bg": "--tbox-bg-page",
|
|
82
|
+
"min": 4.5,
|
|
83
|
+
"usage": "正文"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"fg": "--tbox-text-secondary",
|
|
87
|
+
"bg": "--tbox-bg-card",
|
|
88
|
+
"min": 4.5,
|
|
89
|
+
"usage": "次要文字"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"fg": "--tbox-text-secondary",
|
|
93
|
+
"bg": "--tbox-bg-page",
|
|
94
|
+
"min": 4.5,
|
|
95
|
+
"usage": "次要文字"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"fg": "--tbox-text-muted",
|
|
99
|
+
"bg": "--tbox-bg-card",
|
|
100
|
+
"min": 4.5,
|
|
101
|
+
"usage": "说明文字"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"fg": "--tbox-text-muted",
|
|
105
|
+
"bg": "--tbox-bg-page",
|
|
106
|
+
"min": 4.5,
|
|
107
|
+
"usage": "说明文字"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"fg": "--tbox-primary",
|
|
111
|
+
"bg": "--tbox-bg-card",
|
|
112
|
+
"min": 4.5,
|
|
113
|
+
"usage": "链接与主色文字"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"fg": "--tbox-primary-light",
|
|
117
|
+
"bg": "--tbox-primary-dark",
|
|
118
|
+
"min": 4.5,
|
|
119
|
+
"usage": "深底主视觉文字(hero tone=inverse)"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"derive": {
|
|
123
|
+
"$comment": "浅色模式派生规则(pnpm exec tbox-app theme derive 消费):from = seed | accent;l 为相对种子的 L 增量,L/C 为绝对目标;派生结果须 pairs 全部闭合。键必须 ⊆ platform。",
|
|
124
|
+
"--tbox-primary": {
|
|
125
|
+
"from": "seed"
|
|
126
|
+
},
|
|
127
|
+
"--tbox-primary-dark": {
|
|
128
|
+
"from": "seed",
|
|
129
|
+
"l": -0.12
|
|
130
|
+
},
|
|
131
|
+
"--tbox-primary-light": {
|
|
132
|
+
"from": "seed",
|
|
133
|
+
"L": 0.96,
|
|
134
|
+
"C": 0.03
|
|
135
|
+
},
|
|
136
|
+
"--tbox-accent": {
|
|
137
|
+
"from": "accent"
|
|
138
|
+
},
|
|
139
|
+
"--tbox-accent-light": {
|
|
140
|
+
"from": "accent",
|
|
141
|
+
"L": 0.96,
|
|
142
|
+
"C": 0.03
|
|
143
|
+
},
|
|
144
|
+
"--tbox-bg-page": {
|
|
145
|
+
"from": "seed",
|
|
146
|
+
"L": 0.975,
|
|
147
|
+
"C": 0.008,
|
|
148
|
+
"mood": {
|
|
149
|
+
"warm": {
|
|
150
|
+
"H": 80
|
|
151
|
+
},
|
|
152
|
+
"cool": {
|
|
153
|
+
"H": 240
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"--tbox-bg-card": {
|
|
158
|
+
"from": "seed",
|
|
159
|
+
"L": 0.99,
|
|
160
|
+
"C": 0.004
|
|
161
|
+
},
|
|
162
|
+
"--tbox-bg-subtle": {
|
|
163
|
+
"from": "seed",
|
|
164
|
+
"L": 0.95,
|
|
165
|
+
"C": 0.01
|
|
166
|
+
},
|
|
167
|
+
"--tbox-text-primary": {
|
|
168
|
+
"from": "seed",
|
|
169
|
+
"L": 0.25,
|
|
170
|
+
"C": 0.02
|
|
171
|
+
},
|
|
172
|
+
"--tbox-text-secondary": {
|
|
173
|
+
"from": "seed",
|
|
174
|
+
"L": 0.42,
|
|
175
|
+
"C": 0.02
|
|
176
|
+
},
|
|
177
|
+
"--tbox-text-muted": {
|
|
178
|
+
"from": "seed",
|
|
179
|
+
"L": 0.52,
|
|
180
|
+
"C": 0.015
|
|
181
|
+
},
|
|
182
|
+
"--tbox-border": {
|
|
183
|
+
"from": "seed",
|
|
184
|
+
"L": 0.9,
|
|
185
|
+
"C": 0.01
|
|
186
|
+
},
|
|
187
|
+
"--tbox-border-strong": {
|
|
188
|
+
"from": "seed",
|
|
189
|
+
"L": 0.82,
|
|
190
|
+
"C": 0.015
|
|
191
|
+
}
|
|
192
|
+
}
|
|
72
193
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* 主题契约锁(主题轨 W-T2):contract.json 单一真源 ↔ kit css 机械一致。
|
|
3
3
|
*
|
|
4
4
|
* 断言:
|
|
5
|
-
* ① tokens.
|
|
5
|
+
* ① tokens.css + motion.css 的 :root 变量集 ⊆ contract.platform(css 演进不漂移清单);
|
|
6
6
|
* ② contract 三段非空且全局唯一(无重复键);
|
|
7
7
|
* ③ domains/assets 段命名空间前缀正确(--tbox-domain-* / --tbox-asset-*)。
|
|
8
8
|
*
|
|
@@ -18,6 +18,7 @@ const contract = JSON.parse(readFileSync(path.join(themeDir, 'contract.json'), '
|
|
|
18
18
|
platform: string[];
|
|
19
19
|
domains: string[];
|
|
20
20
|
assets: string[];
|
|
21
|
+
derive?: Record<string, { from: 'seed' | 'accent'; L?: number; C?: number; l?: number; mood?: Record<string, { H: number }> }>;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
function extractRootVars(file: string): string[] {
|
|
@@ -37,8 +38,8 @@ function extractRootVars(file: string): string[] {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
describe('主题契约(contract.json)', () => {
|
|
40
|
-
it('tokens.
|
|
41
|
-
const cssVars = [...extractRootVars('tokens.
|
|
41
|
+
it('tokens.css + motion.css 的 :root 变量 ⊆ contract.platform', () => {
|
|
42
|
+
const cssVars = [...extractRootVars('tokens.css'), ...extractRootVars('motion.css')];
|
|
42
43
|
expect(cssVars.length).toBeGreaterThan(40);
|
|
43
44
|
const allowed = new Set(contract.platform);
|
|
44
45
|
const drift = cssVars.filter((v) => !allowed.has(v));
|
|
@@ -55,6 +56,21 @@ describe('主题契约(contract.json)', () => {
|
|
|
55
56
|
for (const key of contract.assets) expect(key.startsWith('--tbox-asset-')).toBe(true);
|
|
56
57
|
});
|
|
57
58
|
|
|
59
|
+
it('derive 段的键 ⊆ platform,且带 from 来源', () => {
|
|
60
|
+
const derive = contract.derive ?? {};
|
|
61
|
+
const allowed = new Set(contract.platform);
|
|
62
|
+
const drift = Object.entries(derive)
|
|
63
|
+
.filter(([key]) => !key.startsWith('$'))
|
|
64
|
+
.filter(([key]) => !allowed.has(key))
|
|
65
|
+
.map(([key]) => key);
|
|
66
|
+
expect(drift, 'derive 声明了契约外的令牌:' + drift.join(', ')).toEqual([]);
|
|
67
|
+
for (const [key, rule] of Object.entries(derive)) {
|
|
68
|
+
if (key.startsWith('$')) continue;
|
|
69
|
+
expect(['seed', 'accent']).toContain(rule.from);
|
|
70
|
+
}
|
|
71
|
+
expect(Object.keys(derive).length).toBeGreaterThan(8);
|
|
72
|
+
});
|
|
73
|
+
|
|
58
74
|
it('motion 族 5 键在清单内(主题轨 T-2.1 契约)', () => {
|
|
59
75
|
for (const key of [
|
|
60
76
|
'--tbox-motion-duration-fast',
|