@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
|
@@ -6,8 +6,7 @@ import {
|
|
|
6
6
|
createInMemoryMemoryStore,
|
|
7
7
|
resolveMemoryStore,
|
|
8
8
|
} from '@tbox.cn/app-agent-sdk-server';
|
|
9
|
-
import { registerAll } from '
|
|
10
|
-
import { translateTool } from '../src/tools/translate.js';
|
|
9
|
+
import { registerAll } from './helpers/register.js';
|
|
11
10
|
|
|
12
11
|
describe('tool runtime 宿主装配(自注册闭环)', () => {
|
|
13
12
|
it('空装配(mall 模板):无模块工具,app 级工具正常注册', async () => {
|
|
@@ -35,32 +34,6 @@ describe('tool runtime 宿主装配(自注册闭环)', () => {
|
|
|
35
34
|
expect(runtime.tools.notExistedTool).toBeUndefined();
|
|
36
35
|
});
|
|
37
36
|
|
|
38
|
-
describe('translate 参数规范(D11:string 形态 + 工具内 normalize)', () => {
|
|
39
|
-
// mastra Tool.execute 为可选 + 双参签名(input, context)——测试经非空断言直调
|
|
40
|
-
const callExecute = (input: { text: string; targetLang?: string }) =>
|
|
41
|
-
translateTool.execute!(input, {} as never);
|
|
42
|
-
|
|
43
|
-
it('合法 targetLang(zh/en)→ 生效', async () => {
|
|
44
|
-
const r = await callExecute({ text: '你好', targetLang: 'en' });
|
|
45
|
-
expect(r).toMatchObject({ targetLang: 'en' });
|
|
46
|
-
const r2 = await callExecute({ text: 'hello', targetLang: 'zh' });
|
|
47
|
-
expect(r2).toMatchObject({ targetLang: 'zh' });
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('非法 targetLang → 回落自动检测(不抛)', async () => {
|
|
51
|
-
const r = await callExecute({ text: '你好', targetLang: 'fr' });
|
|
52
|
-
expect(r).toMatchObject({ targetLang: 'en' }); // 中文输入 → 自动检测回落英文
|
|
53
|
-
const r2 = await callExecute({ text: 'hello', targetLang: 'xx' });
|
|
54
|
-
expect(r2).toMatchObject({ targetLang: 'zh' }); // 英文输入 → 自动检测回落中文
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('缺省 targetLang → 自动检测', async () => {
|
|
58
|
-
const r = await callExecute({ text: '你好' });
|
|
59
|
-
expect(r).toMatchObject({ targetLang: 'en' });
|
|
60
|
-
const r2 = await callExecute({ text: 'hello' });
|
|
61
|
-
expect(r2).toMatchObject({ targetLang: 'zh' });
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
37
|
});
|
|
65
38
|
|
|
66
39
|
describe('长期记忆装配(017:mall 域默认 inmemory + mallId 隔离 scope)', () => {
|
|
@@ -9,9 +9,8 @@ export default defineConfig({
|
|
|
9
9
|
clean: true,
|
|
10
10
|
sourcemap: true,
|
|
11
11
|
// 本地 workspace 源码包(exports 指向 src/*.ts,node 无法直接加载)必须内联:@app/*。
|
|
12
|
-
// @tbox.cn
|
|
13
|
-
|
|
14
|
-
noExternal: [/^@app\//],
|
|
12
|
+
// @tbox.cn/* 同样内联:模板源/生成应用验证态消费 workspace 源码,离线启动不依赖发布态 dist。
|
|
13
|
+
noExternal: [/^@app\//, /^@tbox\.cn\//],
|
|
15
14
|
// vite 不进 bundle 的结构防线:静态入口图(entry: index.ts → app.ts 链)任何 vite 引用
|
|
16
15
|
// (含 dev.ts 误入 entry)在 onResolve 即失败——dev 形态仅存在于 src/dev.ts(tsx 运行)。
|
|
17
16
|
esbuildPlugins: [
|
|
@@ -35,4 +34,8 @@ export default defineConfig({
|
|
|
35
34
|
'http',
|
|
36
35
|
'fs',
|
|
37
36
|
],
|
|
37
|
+
// 内联 CJS 依赖(ws 等)的 require() 在 ESM 输出中经真实 createRequire 落地。
|
|
38
|
+
banner: {
|
|
39
|
+
js: "import { createRequire as __tboxCreateRequire } from 'module';const require=__tboxCreateRequire(import.meta.url);",
|
|
40
|
+
},
|
|
38
41
|
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/config/AGENTS.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# config
|
|
2
|
+
|
|
3
|
+
| 文件 | 内容 | 形状查询 |
|
|
4
|
+
|---|---|---|
|
|
5
|
+
| `chat.json` | 对话壳配置:快捷问题、TTS、上传等 | `pnpm exec tbox-app schema config/chat.json` |
|
|
6
|
+
| `agent.jsonc` | 智能体提示词与行为规则(支持注释) | `pnpm exec tbox-app schema config/agent.jsonc` |
|
|
7
|
+
| `integrations.json` | 服务集成槽绑定 | `pnpm exec tbox-app schema config/integrations.json` |
|
|
8
|
+
| `llm_provider.json` | 模型 provider 选择 | `pnpm exec tbox-app schema config/llm_provider.json` |
|
|
9
|
+
| `plugins.json` | 插件开关 | — |
|
|
10
|
+
|
|
11
|
+
- 形状以 schema 命令输出为准,不要照抄文档里的示例字段。
|
|
12
|
+
- `chat.json` 不列出厂能力开关(语音输入/播报、图片/视频上传):缺省即开启;只有用户明确要求时才写 false,并在交付说明里声明。
|
|
13
|
+
- 配置在服务启动时读取;改完需重启进程。
|
|
14
|
+
- 提示词写法与常见规则见 `docs/agent/agent-prompt.md`,壳配置见 `docs/agent/shell.md`。
|
package/config/README.md
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
| `knowledge.json` | 知识库资源(按需生成) | fail-soft |
|
|
11
11
|
| `service-slots.json` | 服务词汇引导快照(create 按需生成;可由 module sync 重算) | fail-soft |
|
|
12
12
|
|
|
13
|
-
- 形状查询:`
|
|
14
|
-
- 全部配置面:`
|
|
15
|
-
- 流程知识:`
|
|
16
|
-
- 校验:`
|
|
13
|
+
- 形状查询:`pnpm exec tbox-app schema config/integrations.json`
|
|
14
|
+
- 全部配置面:`pnpm exec tbox-app schema`
|
|
15
|
+
- 流程知识:`pnpm exec tbox-app skills get integration` / `skills get provider-custom`
|
|
16
|
+
- 校验:`pnpm exec tbox-app module doctor`(㉙ config-schema)
|
|
17
17
|
- 密钥真值只放平台凭据/环境变量,**不要写进本目录的 `config.*` 字段**。
|
|
18
18
|
|
|
19
19
|
元键 `$comment` / `$schema` 仅作为文档指针,行为惰性;`agent.jsonc` 与 `plugins.json`
|
package/config/chat.json
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
2
|
+
"identity": {
|
|
3
|
+
"name": "悦享里",
|
|
4
|
+
"tagline": "商圈智能服务"
|
|
5
|
+
},
|
|
6
|
+
"welcome": {
|
|
7
|
+
"title": "今天想逛点什么?",
|
|
8
|
+
"subtitle": "停车、入会、积分、商户、导航、活动和优惠券都能问我"
|
|
9
|
+
},
|
|
10
|
+
"retryOnError": true,
|
|
7
11
|
"quickCommands": [
|
|
8
|
-
{
|
|
9
|
-
|
|
12
|
+
{
|
|
13
|
+
"label": "停车缴费",
|
|
14
|
+
"query": "我要停车缴费"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"label": "碰一下入会",
|
|
18
|
+
"query": "我要碰一下入会"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"label": "推荐一家餐厅",
|
|
22
|
+
"query": "推荐一家餐厅"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"label": "今天有什么活动",
|
|
26
|
+
"query": "今天有什么活动"
|
|
27
|
+
}
|
|
10
28
|
]
|
|
11
29
|
}
|
package/config/integrations.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$comment": "配置形状:
|
|
2
|
+
"$comment": "配置形状: pnpm exec tbox-app schema config/integrations.json;接入流程: pnpm exec tbox-app skills get integration",
|
|
3
3
|
"services": {}
|
|
4
4
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# 提示词与对话配置
|
|
2
|
+
|
|
3
|
+
> 本页管:`config/agent.jsonc`(提示词)与 `config/chat.json`(壳行为)怎么改、写什么。|不管:壳组件与槽位 → [shell](shell.md)。
|
|
4
|
+
|
|
5
|
+
## 先查形状
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm exec tbox-app schema config/agent.jsonc
|
|
9
|
+
pnpm exec tbox-app schema config/chat.json
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
以命令输出为准,不要照抄本文的字段片段——形状由 schema 定义。
|
|
13
|
+
|
|
14
|
+
## 提示词
|
|
15
|
+
|
|
16
|
+
`config/agent.jsonc` 不存在时新建。要点:
|
|
17
|
+
|
|
18
|
+
- `instructions` 是字符串数组,一行一条,拼接时按换行连接。
|
|
19
|
+
- 平台规则段(出卡协议、消息格式)由 SDK 注入,**你写的是业务段**;与平台协议冲突的指令会被协议压过,写了也没用。
|
|
20
|
+
- 首行写身份句(「你是谁、服务谁」),随后按「服务范围 / 业务规则 / 沟通风格」分段。
|
|
21
|
+
- 数据类问题一律要求「先调工具拿本轮结果再回答」,不要凭历史结论作答。
|
|
22
|
+
- 操作类流程写清楚三类动作:什么时候只给信息、什么时候出确认卡、什么时候执行。
|
|
23
|
+
- 按钮语义要写明:「卡片按钮优先走确定性动作(invoke),不需要模型再判断;只有需要模型补充信息时才走发消息(send)。收到动作结果直接执行,不要重复追问」——否则模型会把每个按钮都当成一轮对话。
|
|
24
|
+
|
|
25
|
+
## 对话配置
|
|
26
|
+
|
|
27
|
+
`config/chat.json` 控制壳的行为,常用字段:
|
|
28
|
+
|
|
29
|
+
| 字段 | 作用 |
|
|
30
|
+
|---|---|
|
|
31
|
+
| `quickCommands` | 首屏快捷问题:`[{ label, query }]`,点击即发送 `query` |
|
|
32
|
+
| `enableImageUpload` / `enableVideoUpload` | 上传入口 |
|
|
33
|
+
| `enableTTS` / `enableVoiceInput` | 语音相关 |
|
|
34
|
+
| `defaultInputMode` | `TEXT` / `VOICE` |
|
|
35
|
+
|
|
36
|
+
## 生效方式
|
|
37
|
+
|
|
38
|
+
两个文件都在服务启动时读取,改完重启进程。配置是 fail-soft 的:解析失败不会崩,但该段配置不生效——改完先看启动日志有没有 warn。
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# 卡片上的按钮
|
|
2
|
+
|
|
3
|
+
> 本页管:卡片按钮的两种语义(发消息 / 触发动作)、确认弹层、禁用规则、动作的入参与返回值。|不管:卡片结构 → [card](card.md);工具出卡 → [tool-emits-card](tool-emits-card.md);基元 props → [kit](kit.md)。
|
|
4
|
+
|
|
5
|
+
> 视图卡的动作与三件套同形:`invoke` / `send` / `confirm` 写在 `view()` 的 `actions` 里,确认弹层、禁用与历史态由平台统一处理。
|
|
6
|
+
> 自己渲染动作的卡(`ActionList`)在 `defineCard` 里写 `actions: 'self'`;不写时 SDK 默认按钮条照旧渲染,容易出现两条动作。
|
|
7
|
+
|
|
8
|
+
## 两种按钮
|
|
9
|
+
|
|
10
|
+
`useCardActions()` 给两个方法:
|
|
11
|
+
|
|
12
|
+
| 方法 | 走哪条路 | 什么时候用 |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| `send(text, { displayText })` | 作为用户消息发回,模型接管 | 需要模型再判断、或要让对话记住这一步 |
|
|
15
|
+
| `invoke(actionId, input)` | 直接调用卡片动作,不过模型 | 入参确定、结果确定的写操作(领券、支付、报名) |
|
|
16
|
+
|
|
17
|
+
`input` 会作为本次调用的入参(协议里的 `formData` 通道)交给服务端 `inputSchema` 校验;不传按空对象校验。**列表卡的逐项操作靠它**——把条目 id 放进 `input`。
|
|
18
|
+
|
|
19
|
+
`send` 的第二个参数可以给 `displayText`:气泡显示这句话,实际发给模型的 `value` 可以更长。
|
|
20
|
+
|
|
21
|
+
## 门控
|
|
22
|
+
|
|
23
|
+
`disabled` 在两种情况下为 true:
|
|
24
|
+
|
|
25
|
+
- `isHistory`:历史消息里的卡片只读,点击只提示「历史卡片仅供查看」;
|
|
26
|
+
- `isGenerating`:正在生成回复,点击提示稍候。
|
|
27
|
+
|
|
28
|
+
按钮的 `disabled` 一定要接这个值,否则用户会在错误时机触发写操作。
|
|
29
|
+
|
|
30
|
+
`ActionList` 点击后进入 pending:同一张卡只允许一次在途(连点同 tick 也只执行一次),生成结束自动解除,20 秒兜底。手写按钮时用本地 pending 并把 `disabled` 一并接上。
|
|
31
|
+
|
|
32
|
+
## 令牌
|
|
33
|
+
|
|
34
|
+
`invoke` 需要动作令牌:卡片 payload 的 `actionTokens[actionId]`,由服务端在出卡时签发,随卡片数据传给组件(`CardRenderProps.actionTokens`)。没有令牌时 `invoke` 只提示「该操作不可用」——说明这张卡上的该动作没有注册或没有签发。
|
|
35
|
+
|
|
36
|
+
令牌绑定卡片实例与会话:换会话、换卡实例即失效,历史卡片不能重放。
|
|
37
|
+
|
|
38
|
+
## 应用级动作
|
|
39
|
+
|
|
40
|
+
应用自己的动作放在 `apps/server/src/actions/*.action.ts`,用 `defineAction` 声明:
|
|
41
|
+
|
|
42
|
+
<!-- recipe:action ts -->
|
|
43
|
+
```ts
|
|
44
|
+
import { actionResult, defineAction } from '@tbox.cn/app-agent-sdk-server';
|
|
45
|
+
import { z } from 'zod';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* order status 动作:卡片上的确定性入口,点击后直接执行,不过模型。
|
|
49
|
+
*
|
|
50
|
+
* - `id` 全局唯一,卡片里用 `invoke('order-status')` 触发;
|
|
51
|
+
* - `cardType` 决定这张动作挂在哪种卡上(出卡时平台按它签发令牌);
|
|
52
|
+
* - 写操作用 `singleUse: true` 防重复提交;
|
|
53
|
+
* - 结果用 `actionResult.notice` / `updateResult(card, data)` / `cardResult(card, data)` 构造:
|
|
54
|
+
* 本卡状态变了用 update,另一类结果用 card,只要一句提示用 notice;不要同时返回 card 与 update。
|
|
55
|
+
*/
|
|
56
|
+
export const action = defineAction({
|
|
57
|
+
id: 'order-status',
|
|
58
|
+
cardType: 'order-status',
|
|
59
|
+
inputSchema: z.object({}),
|
|
60
|
+
singleUse: true,
|
|
61
|
+
label: 'order status',
|
|
62
|
+
async execute(_input, { userId }) {
|
|
63
|
+
// 幂等判断放在写副作用之前:同一业务键只生效一次
|
|
64
|
+
return actionResult.notice(`已处理(${userId})`);
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- `id` 全局唯一;`cardType` 决定它挂在哪张卡上(数组表示同一操作出现在多张卡上),出卡时平台按被点卡签发令牌;
|
|
70
|
+
- `inputSchema` 校验卡片传入的 `input`;无参动作写 `z.object({})`;
|
|
71
|
+
- `execute(input, ctx)` 的 `ctx` 是 `{ userId, cardId?, cardType? }`——`userId` 来自授权令牌绑定的会话身份,**不要信客户端传上来的 userId**;`cardType` 是被点击那张卡的类型;
|
|
72
|
+
- 返回值三选一:`updateResult(card, data)` 原地更新被点的卡(`data` 必须过该卡 schema)、`cardResult(card, data)` 出一张结果卡、`actionResult.notice(text)` 只给一条提示。`update` 与 `card` 互斥;
|
|
73
|
+
- 写操作用 `singleUse: true` 防重复提交;幂等判断放在副作用之前;
|
|
74
|
+
- 动作结果只回给客户端(`tbox:card-update` / `tbox:notice`),**不进模型上下文**——需要模型知道的事实,让它在下一轮用工具查。
|
|
75
|
+
- 生成:`pnpm exec tbox-app new action <name>`,或 `new feature <name> --action` 一并产出。
|
|
76
|
+
|
|
77
|
+
## 按钮组(描述对象)
|
|
78
|
+
|
|
79
|
+
一个动作一个 `ActionRow`、再自己管确认弹层太啰嗦。用 `ActionList` 一次说清:
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
const api = useCardActions({ cardId, isHistory, actionTokens });
|
|
83
|
+
<ActionList
|
|
84
|
+
api={api}
|
|
85
|
+
actions={[
|
|
86
|
+
{ label: '确认支付 ¥5', invoke: { id: 'pay-parking', input: { plate: data.plate } }, confirm: { title: '确认支付 ¥5?' }, style: 'primary' },
|
|
87
|
+
{ label: '先不付', send: '先不付,稍后再说' },
|
|
88
|
+
]}
|
|
89
|
+
/>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`confirm` 会把点击先收进 `ConfirmSheet`,确认后才执行;`api.disabled` 自动接到每个按钮。
|
|
93
|
+
|
|
94
|
+
## 没有动作时的退路
|
|
95
|
+
|
|
96
|
+
如果这张卡只有 `send` 一条路,就用 `send` + 工具内状态机完成确认流程,别在客户端伪造写操作。此时「按钮 → 工具」链路里模型仍是必经环节(每点一次一轮模型调用),提示词要写明「收到这类消息就当作确认,直接执行,不要重复追问」。
|
|
97
|
+
|
|
98
|
+
## 页尾
|
|
99
|
+
|
|
100
|
+
- 卡片结构 → [card](card.md)
|
|
101
|
+
- 工具出卡 → [tool-emits-card](tool-emits-card.md)
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# 新增一张卡片
|
|
2
|
+
|
|
3
|
+
> 本页管:卡片的两种写法(视图卡默认 / 三件套仅富交互)、落点与成对规则。|不管:出卡协议 → [tool-emits-card](tool-emits-card.md);按钮 → [card-action](card-action.md)。
|
|
4
|
+
|
|
5
|
+
## 先选写法:默认视图卡
|
|
6
|
+
|
|
7
|
+
卡片默认写**视图卡**:服务端一个文件,`view(data)` 返回可序列化的视图 JSON(积木 + 动作规格),客户端由 `app-build` 自动派生 `ViewCard`——没有 `apps/client/src/cards/<id>.card.tsx`,也不会报 `CARD_PAIR_MISSING`。
|
|
8
|
+
|
|
9
|
+
只有需要局部自定义图形或富交互时,才写「数据契约 + 服务端声明 + 客户端渲染」三件套(L3,见本页末节)。
|
|
10
|
+
|
|
11
|
+
### 视图卡(默认)
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { defineViewCard } from '@tbox.cn/app-agent-sdk-server';
|
|
15
|
+
|
|
16
|
+
interface ParkingOrder {
|
|
17
|
+
plate: string;
|
|
18
|
+
payable: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const card = defineViewCard<ParkingOrder>({
|
|
22
|
+
cardType: 'parking-order',
|
|
23
|
+
displayName: '停车订单',
|
|
24
|
+
description: '待支付停车订单与支付结果',
|
|
25
|
+
sampleState: { plate: '浙A·12345', payable: 5 },
|
|
26
|
+
view: (order) => ({
|
|
27
|
+
header: { title: '停车订单', status: { text: '待支付', tone: 'warning' } },
|
|
28
|
+
blocks: [
|
|
29
|
+
{ kind: 'facts', items: [['车牌', order.plate]] },
|
|
30
|
+
{ kind: 'bill', lines: [['停车费', '¥15']], total: ['应付', '¥' + order.payable] },
|
|
31
|
+
],
|
|
32
|
+
actions: [{ label: '确认支付', invoke: { id: 'pay-parking', input: { plate: order.plate } }, confirm: { title: '确认支付?' } }],
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- 积木:`hero` / `facts` / `bill` / `notice` / `tags` / `steps` / `list` / `ticket` / `timeline` / `empty`;动作规格与 `ActionList` 同形(label / send / invoke / confirm / style)。
|
|
38
|
+
- `hero` 的 `tone`:`primary`(缺省)/ `warm` / `jade` / `inverse`。**要深色主视觉(金额、路线、会员等级)用 `inverse`**——它用 `--tbox-primary-dark` 底 + `--tbox-primary-light` 字,对比度由门禁 `shell.contrast` 兜底;不要为了深色底去写 `bg-[#173F33]` 这类字面量(`style.color-repeat` 会点名)。
|
|
39
|
+
- 预算写进 schema:积木 ≤4、提示 ≤1、属性 ≤5、列表 ≤3、账单行 ≤8、步骤 ≤5、时间线 ≤6、标签 ≤6、卡级动作 ≤2;作者期 `defineViewCard` 直接报错,生产侧 `cardOfView` 先截断再校验,不整张卡丢弃。
|
|
40
|
+
- 样例由 `sampleState` 与 `samples` 派生,不用手写大段 `sampleData`。
|
|
41
|
+
- 出卡用 `cardOfView(card, domainData, note)`:它先跑 `view()`,再走统一的出卡校验。
|
|
42
|
+
- `pnpm exec tbox-app new card <name> --view` 直接生成视图卡单文件;不带 `--view` 才生成三件套(仅富交互卡)。
|
|
43
|
+
- `pnpm exec tbox-app new feature <name> --view` 生成视图卡竖切(工具用 `cardOfView` 出卡);不带 `--view` 才是三件套起手(工具返回 `cards`)。
|
|
44
|
+
- 卡片自己渲染动作(`ActionList` / `ViewCard`)时,`defineCard` 必须写 `actions: 'self'`,否则 SDK 默认按钮条会叠加;不写动作的卡保持默认 `auto`。
|
|
45
|
+
|
|
46
|
+
### 三件套(仅富交互卡)
|
|
47
|
+
|
|
48
|
+
一张卡要有三样东西:
|
|
49
|
+
|
|
50
|
+
| 位置 | 文件 | 作用 |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| 数据契约 | `packages/shared/src/cards/<id>.ts` | 两端共用的 zod schema 与类型 |
|
|
53
|
+
| 服务端声明 | `apps/server/src/cards/<id>.card.ts` | `cardType`、schema、展示名、样例 |
|
|
54
|
+
| 客户端渲染 | `apps/client/src/cards/<id>.card.tsx` | 组件 + `defineCard({ type })` |
|
|
55
|
+
|
|
56
|
+
服务端与客户端文件名必须同 base,`cardType` 与 `type` 必须相同——缺一半或对不上,`pnpm generate` 会报 `CARD_PAIR_MISSING` 或 `CARD_TYPE_MISMATCH`。
|
|
57
|
+
|
|
58
|
+
## 数据契约
|
|
59
|
+
|
|
60
|
+
<!-- recipe:card-schema ts -->
|
|
61
|
+
```ts
|
|
62
|
+
import { z } from 'zod';
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* order-status 卡片的数据形状:两端共用的唯一声明。
|
|
66
|
+
*
|
|
67
|
+
* - schema 与类型由 `z.infer` 单点推导,不再手写第二份 interface;
|
|
68
|
+
* - 服务端 `apps/server/src/cards/order-status.card.ts` 直接引用本 schema;
|
|
69
|
+
* - 客户端只允许 `import type`,schema 的运行时(zod)不进客户端产物。
|
|
70
|
+
*/
|
|
71
|
+
export const orderStatusCardSchema = z.object({
|
|
72
|
+
title: z.string(),
|
|
73
|
+
status: z.string(),
|
|
74
|
+
rows: z.array(z.object({ label: z.string(), value: z.string() })),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export type OrderStatusCardData = z.infer<typeof orderStatusCardSchema>;
|
|
78
|
+
```
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 服务端声明
|
|
82
|
+
|
|
83
|
+
<!-- recipe:card-meta ts -->
|
|
84
|
+
```ts
|
|
85
|
+
import type { CardMeta } from '@tbox.cn/app-contracts';
|
|
86
|
+
import { orderStatusCardSchema } from '@app/shared/cards/order-status';
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* order-status 卡片的服务端声明。三条约束:
|
|
90
|
+
* - `cardType` 必须是字符串字面量(app-build 扫描器读静态值),且与客户端 `defineCard` 的 `type` 相同;
|
|
91
|
+
* - `dataSchema` 直接引用 `@app/shared` 的 schema(形状只写一处,客户端只 import 类型);
|
|
92
|
+
* - `sampleData` / `samples` 必须是静态字面量:`card render` 与场景断言按字面量读取,
|
|
93
|
+
* 引用常量或函数会读不到(doctor 与 check:fast 都会提示)。
|
|
94
|
+
*/
|
|
95
|
+
export const card = {
|
|
96
|
+
cardType: 'order-status',
|
|
97
|
+
dataSchema: orderStatusCardSchema,
|
|
98
|
+
displayName: 'order status',
|
|
99
|
+
description: 'order status 卡片(待补充说明)',
|
|
100
|
+
sampleData: {
|
|
101
|
+
title: 'order status',
|
|
102
|
+
status: '示例状态',
|
|
103
|
+
rows: [{ label: '示例字段', value: '示例值' }],
|
|
104
|
+
},
|
|
105
|
+
schemaVersion: 1,
|
|
106
|
+
} satisfies CardMeta<typeof orderStatusCardSchema>;
|
|
107
|
+
```
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 客户端渲染
|
|
111
|
+
|
|
112
|
+
<!-- recipe:card-client tsx -->
|
|
113
|
+
```tsx
|
|
114
|
+
import type { OrderStatusCardData } from '@app/shared/cards/order-status';
|
|
115
|
+
import { Card, CardHeader, KeyValueList, StatusTag, defineCard } from '@tbox.cn/app-agent-ui-kit';
|
|
116
|
+
import type { CardRenderProps } from '@tbox.cn/app-agent-ui-kit';
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* order-status 卡片的客户端渲染。
|
|
120
|
+
* - `type` 与同 base 的服务端 `cardType` 必须相同;
|
|
121
|
+
* - 组件入参由 `defineCard` 固定(data / cardId / isHistory / actionTokens);
|
|
122
|
+
* - 排版用 kit 基元(Card / KeyValueList / StatusTag …),基元表达不了的用工具类,不新建样式文件;
|
|
123
|
+
* - 要加按钮时用 `useCardActions()`:`send` 走模型、`invoke` 走卡片动作、`disabled` 统一门控。
|
|
124
|
+
*/
|
|
125
|
+
function OrderStatusCard({ data }: CardRenderProps<OrderStatusCardData>) {
|
|
126
|
+
return (
|
|
127
|
+
<Card>
|
|
128
|
+
<CardHeader title={data.title} status={<StatusTag tone="info">{data.status}</StatusTag>} />
|
|
129
|
+
<KeyValueList items={data.rows.map((row) => ({ label: row.label, value: row.value }))} />
|
|
130
|
+
</Card>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export const card = defineCard({ type: 'order-status' }, OrderStatusCard);
|
|
135
|
+
```
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## 视觉基线
|
|
139
|
+
|
|
140
|
+
```sh
|
|
141
|
+
pnpm card:render --type <cardType> --screenshot --baseline
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
首次运行把截图写到 `.tbox/card-render/baseline/<type>.png`;之后逐像素比对(需 Pillow),差异 >0.5% 失败;没有 Pillow 时退回字节比对。改样式后用 `--baseline` 重跑,确认差异符合预期再删除对应基线、重新生成。
|
|
145
|
+
|
|
146
|
+
`--audit` 同时列出字号分布:每张卡的文字必须落在 12 / 14 / 16 / 18 / 20 五档,越档会单独列一行。
|
|
147
|
+
|
|
148
|
+
## 要点
|
|
149
|
+
|
|
150
|
+
- `sampleData` 必须能过 `dataSchema`:卡片预览页与场景断言都用它。
|
|
151
|
+
- `cardType` / `type` 都写成字符串字面量(扫描器读静态值)。
|
|
152
|
+
- 客户端组件入参固定为 `CardRenderProps<T>`:`data`、`cardId`、`isHistory`、`actionTokens`。
|
|
153
|
+
- 信息类卡片先用 kit 基元拼;确实需要自定义布局再写结构,样式规则见 [style](style.md)。
|
|
154
|
+
|
|
155
|
+
## 校验
|
|
156
|
+
|
|
157
|
+
```sh
|
|
158
|
+
pnpm check:fast
|
|
159
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# 多轮联动与指代
|
|
2
|
+
|
|
3
|
+
> 本页管:怎么让「第一家」「那就这个」「带孩子呢」「怎么走」这类表达在下一轮接得上,以及跨工具的事实放哪。|不管:工具写法 → [tool](tool.md);按钮与确认 → [card-action](card-action.md);状态 → [state](state.md)。
|
|
4
|
+
|
|
5
|
+
## 原则:指代交给模型,事实交给状态
|
|
6
|
+
|
|
7
|
+
模型能从对话历史里解出「第一家」「那就这个」——前提是上一条工具结果里带着**可引用的条目**。服务端不要维护「上一轮推荐列表」再做二次解析:那是第二份真源,和模型看到的上下文必然漂移。
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
// 工具出参:一句结论 + 关键事实 + 可引用条目
|
|
11
|
+
return {
|
|
12
|
+
ok: true,
|
|
13
|
+
message: '按亲子需求推荐 3 家:江南小馆、童梦乐园、茶有间',
|
|
14
|
+
items: [
|
|
15
|
+
{ id: 'jiangnan', name: '江南小馆', floor: 'L1', avg: 80 },
|
|
16
|
+
{ id: 'tongmeng', name: '童梦乐园', floor: 'L3', avg: 68 },
|
|
17
|
+
],
|
|
18
|
+
cards: [/* … */],
|
|
19
|
+
};
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- `items` 用**稳定 id** + 展示名;后续工具按 id 或名字都能定位(详情工具两者都收)。
|
|
23
|
+
- 一句 `message` 让模型不用读整个对象就知道这轮发生了什么。
|
|
24
|
+
- 条目不要超过一屏;要更多就分页,别把上下文塞满。
|
|
25
|
+
|
|
26
|
+
## 跨工具的事实
|
|
27
|
+
|
|
28
|
+
「已成为会员」「已领的券」「当前车牌」这些跨工具事实放 `createUserState`(见 [state](state.md)),每个工具读它再决定怎么做;不要靠模型复述这些事实。
|
|
29
|
+
|
|
30
|
+
## 确认类交互
|
|
31
|
+
|
|
32
|
+
写操作要么走确定性动作 + `confirm`(见 [card-action](card-action.md)),要么在提示词里写明「收到这类消息就当作确认,直接执行,不要重复追问」。两者不要混用:动作走动作,消息走消息。
|
|
33
|
+
|
|
34
|
+
## 出卡与后续引用
|
|
35
|
+
|
|
36
|
+
- 每张卡带 `note`(一句话说明这张卡是什么),模型在后续轮次里引用它更准。
|
|
37
|
+
- 同一轮多张卡时,先给「结论卡」再给「细节卡」;模型倾向引用最后一张。
|
|
38
|
+
- 卡片按钮用 `invoke` 走动作时,入参里带上业务 id(`{ merchantId }`),不要依赖「当前卡片」。
|
|
39
|
+
|
|
40
|
+
## 反例
|
|
41
|
+
|
|
42
|
+
| 写法 | 为什么不行 |
|
|
43
|
+
|---|---|
|
|
44
|
+
| 服务端缓存「上一次推荐列表」并在详情工具里兜底解析 | 与模型上下文双源,指代一变就错;本次真实构建为此花了 77 秒 |
|
|
45
|
+
| 工具只返回一段自然语言 | 模型没有可引用条目,「第一家」无从对齐 |
|
|
46
|
+
| 指代解析写成前端规则 | 绕过模型,卡片与状态不再可用 |
|
|
47
|
+
| 每轮都重新查全量再筛 | 上下文膨胀;用 `items` 收敛 |
|
|
48
|
+
|
|
49
|
+
## 页尾
|
|
50
|
+
|
|
51
|
+
- 工具出参与卡片 → [tool-emits-card](tool-emits-card.md)
|
|
52
|
+
- 状态与身份 → [state](state.md)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# 卡片基元与主题
|
|
2
|
+
|
|
3
|
+
> 本页管:卡片用哪些基元拼、每个基元的 props、图标清单、可覆写的主题变量、壳能改到哪。|不管:卡片数据与双端配对 → [card](card.md);工具出卡 → [tool-emits-card](tool-emits-card.md);样式细则 → [style](style.md)。
|
|
4
|
+
|
|
5
|
+
本页由 `scripts/gen-kit-catalog.mjs` 从 kit 源码生成(基元 = `src/card/primitives.tsx`,变量 = `theme/contract.json`,壳契约 = `shell.contract.json`)。**不要手改**:改源码后跑 `pnpm gen:kit-catalog`。
|
|
6
|
+
|
|
7
|
+
## 先选基元,再考虑写样式
|
|
8
|
+
|
|
9
|
+
信息类卡片用基元拼出来就是完整的:零样式文件、跟随主题变量、深浅色一致。基元表达不了的布局用 Tailwind 工具类包一层 `div`(语义色名单与标度见 [style](style.md))。
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { Card, CardHeader, KeyValueList, StatusTag } from '@tbox.cn/app-agent-ui-kit';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 基元(20)
|
|
16
|
+
|
|
17
|
+
| 基元 | 用途 | props |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| `Card` | 卡片容器:统一背景、圆角、内边距与阴影。 * | `children: ReactNode` `footer?: ReactNode` `className?: string` |
|
|
20
|
+
| `CardHeader` | — | `title: ReactNode` `eyebrow?: ReactNode` `status?: ReactNode` `icon?: ReactNode` |
|
|
21
|
+
| `KeyValueList` | 属性列表:左标签右值,逐行。 * | `items: KeyValueItem[]` |
|
|
22
|
+
| `Bill` | 明细 + 合计:金额、积分、费用清单通用。 * | `lines: BillLine[]` `total?: { label: ReactNode; value: ReactNode }` |
|
|
23
|
+
| `StatusTag` | 状态标签。 * | `children: ReactNode` `tone?: Tone` |
|
|
24
|
+
| `Notice` | 提示条:说明、限制、下一步指引。 * | `children: ReactNode` `tone?: Tone` `icon?: ReactNode` |
|
|
25
|
+
| `ActionRow` | 按钮行:主次两级,禁用整行。 * | `primary?: ReactNode` `secondary?: ReactNode` `disabled?: boolean` |
|
|
26
|
+
| `CardButton` | — | `children: ReactNode` `onClick?: () => void` `variant?: 'primary' \| 'secondary' \| 'link'` `disabled?: boolean` `busy?: boolean` |
|
|
27
|
+
| `ConfirmSheet` | 确认弹层:写操作前的一次确认(走 kit 统一弹层内核:传送、滚动锁、Escape、焦点循环与恢复)。 | `open: boolean` `title: ReactNode` `description?: ReactNode` `confirmText?: string` `cancelText?: string` `onConfirm: () => void` `onCancel: () => void` |
|
|
28
|
+
| `Ticket` | 票券形:券、凭证、卡包条目。 | `amount: ReactNode` `condition?: ReactNode` `meta?: ReactNode` `status?: ReactNode` `tone?: 'primary' \| 'muted'` |
|
|
29
|
+
| `Steps` | 步骤/路线:取车路线、办理进度。 | `steps: StepItem[]` |
|
|
30
|
+
| `MediaRow` | 图文条目:门店、商品、活动。 | `title: ReactNode` `meta?: ReactNode` `tags?: ReactNode` `action?: ReactNode` `thumb?: ReactNode` |
|
|
31
|
+
| `Hero` | 品牌色块:主数值 + 说明,用于会员、积分、钱包类卡片的头部。 | `eyebrow?: ReactNode` `title: ReactNode` `value?: ReactNode` `unit?: ReactNode` `footnote?: ReactNode` `icon?: ReactNode` `tone?: 'primary' \| 'warm' \| 'jade' \| 'inverse' \| 'neutral'` |
|
|
32
|
+
| `StatGrid` | 并列数值格(两到三格):积分/余额、车位/时长。 | `items: StatItem[]` |
|
|
33
|
+
| `EntityRow` | 实体行(MediaRow 的超集):商户、活动、券包条目,支持价格与展开说明。 | `title: ReactNode` `meta?: ReactNode` `tags?: ReactNode` `price?: ReactNode` `action?: ReactNode` `thumb?: ReactNode` `description?: ReactNode` |
|
|
34
|
+
| `CheckRow` | 勾选行:用券、同意条款、选择车位。 | `label: ReactNode` `description?: ReactNode` `checked: boolean` `onChange?: (checked: boolean) => void` `disabled?: boolean` `trailing?: ReactNode` |
|
|
35
|
+
| `Timeline` | 明细时间线:积分收支、停车计费。 * | `items: TimelineItem[]` |
|
|
36
|
+
| `EmptyState` | 空态:没券、没订单、没记录时给一句解释与一个下一步。 * | `title: ReactNode` `description?: ReactNode` `action?: ReactNode` |
|
|
37
|
+
| `TagList` | 标签组:口味、距离、适用条件。 * | `tags: ReactNode[]` `tone?: Tone` |
|
|
38
|
+
| `ActionList` | — | `actions: CardActionSpec[]` `api: CardActions` |
|
|
39
|
+
|
|
40
|
+
## 图标
|
|
41
|
+
|
|
42
|
+
从 `@tbox.cn/app-agent-ui-kit/icons` 具名导入;需要新图标时先看这里有没有,没有再评估是否值得扩;不要在应用里直接依赖 `@phosphor-icons/react`。
|
|
43
|
+
|
|
44
|
+
共 31 个:`ArrowRight`、`ArrowsClockwise`、`Calendar`、`CaretDown`、`CaretRight`、`Check`、`CheckCircle`、`Clock`、`Coins`、`Copy`、`CreditCard`、`CurrencyCny`、`Gift`、`Info`、`MapPin`、`MapTrifold`、`Plus`、`QrCode`、`Receipt`、`SealCheck`、`ShareNetwork`、`Sparkle`、`Star`、`Storefront`、`Ticket`、`Trash`、`User`、`UserCircle`、`Warning`、`WarningCircle`、`X`。
|
|
45
|
+
|
|
46
|
+
## 主题变量
|
|
47
|
+
|
|
48
|
+
在 `html[data-theme='tbox']` 段里覆写;变量名逐字照抄,写错不会报错、只会静默不生效。
|
|
49
|
+
|
|
50
|
+
| 组 | 变量 |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `platform` | `--tbox-accent`、`--tbox-accent-light`、`--tbox-bg-card`、`--tbox-bg-page`、`--tbox-bg-subtle`、`--tbox-bg-warm`、`--tbox-border`、`--tbox-border-strong`、`--tbox-content-max-width`、`--tbox-error`、`--tbox-fs-body`、`--tbox-fs-caption`、`--tbox-fs-heading`、`--tbox-icon-color`、`--tbox-ink`、`--tbox-input-bg`、`--tbox-input-padding`、`--tbox-input-radius`、`--tbox-media-item-radius`、`--tbox-media-item-size`、`--tbox-motion-duration-base`、`--tbox-motion-duration-fast`、`--tbox-motion-duration-slow`、`--tbox-motion-easing-emphasized`、`--tbox-motion-easing-standard`、`--tbox-page-gutter`、`--tbox-primary`、`--tbox-primary-dark`、`--tbox-primary-light`、`--tbox-radius-lg`、`--tbox-radius-md`、`--tbox-radius-sm`、`--tbox-send-btn-size`、`--tbox-shadow-lg`、`--tbox-shadow-md`、`--tbox-shadow-sm`、`--tbox-success`、`--tbox-text-muted`、`--tbox-text-primary`、`--tbox-text-secondary`、`--tbox-transition-base`、`--tbox-transition-fast`、`--tbox-warning` |
|
|
53
|
+
| `domains` | `--tbox-domain-member-accent`、`--tbox-domain-member-border`、`--tbox-domain-member-surface`、`--tbox-domain-parking-accent`、`--tbox-domain-parking-border`、`--tbox-domain-parking-surface`、`--tbox-domain-promotion-accent`、`--tbox-domain-promotion-surface`、`--tbox-domain-sg-accent`、`--tbox-domain-sg-border`、`--tbox-domain-sg-surface` |
|
|
54
|
+
| `assets` | `--tbox-asset-bumpin-bg`、`--tbox-asset-home-poster-compact`、`--tbox-asset-home-poster-stage`、`--tbox-asset-member-login-hero`、`--tbox-asset-member-mascot`、`--tbox-asset-parking-hero`、`--tbox-asset-promotion-activity-header`、`--tbox-asset-promotion-coupon-header`、`--tbox-asset-sg-header` |
|
|
55
|
+
|
|
56
|
+
## 壳能改到哪
|
|
57
|
+
|
|
58
|
+
ChatPage 渲染的区域如下;`可覆写` 为 true 的选择器可以在 `brand.css` 里改外观,其余是内部实现。
|
|
59
|
+
|
|
60
|
+
| 区域 | 选择器 | 由什么驱动 | 可覆写 |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| `brand` | `.chat-page__brand` | chat.json identity.name;chat.json identity.tagline;HELLO_ACK mallScope.mallName(缺省回落) | 是 |
|
|
63
|
+
| `welcome` | `.chat-page__welcome` | chat.json welcome.title;chat.json welcome.subtitle;chat.json identity(缺省回落) | 是 |
|
|
64
|
+
| `messages` | `.chat-page__body` | chat store messages / historyMessages | 否 |
|
|
65
|
+
| `history-entry` | `.history-entry` | chat store historyHasMore / isLoadingHistory | 否 |
|
|
66
|
+
| `home-slot` | `.chat-page__home-slot` | 客户端槽 home | 否 |
|
|
67
|
+
| `conversation-overlay` | `.chat-page__conversation-overlay` | 客户端槽 conversationOverlay | 否 |
|
|
68
|
+
| `quick-commands` | `.quick-commands` | chat.json quickCommands | 是 |
|
|
69
|
+
| `input` | `.tbox-chat-input` | chat.json(enableTTS 等);chat store runtimeStatus / isGenerating | 否 |
|
|
70
|
+
|
|
71
|
+
不承诺稳定(不要覆写):
|
|
72
|
+
|
|
73
|
+
- MessageBubble 内部结构(.msg-row / .msg-main / .msg-thinking)
|
|
74
|
+
- ChatInput 内部结构(.tbox-media-picker、发送按钮)
|
|
75
|
+
- 卡片渲染器内部结构(.tbox-card-*)
|
|
76
|
+
|
|
77
|
+
## 页尾
|
|
78
|
+
|
|
79
|
+
- 写一张新卡 → [card](card.md)
|
|
80
|
+
- 改颜色与布局 → [style](style.md)
|