@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
|
@@ -1,142 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* verify:generated
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* 自包含实现(模板独立于 CLI 包),全量校验以 CLI `module doctor` / `module diff` 为准。
|
|
3
|
+
* verify:generated 守卫(v1):
|
|
4
|
+
* - 调用 app-build checkApp:apps/布局、无 legacy 装配面、shared 包、agent 卡片预览;
|
|
5
|
+
* - 确认 .tbox-gen/manifest.json 已生成;
|
|
6
|
+
* - 不再维护双端 modules.ts 锚点。
|
|
8
7
|
*/
|
|
9
|
-
import { existsSync
|
|
10
|
-
import { readdir } from 'node:fs/promises';
|
|
8
|
+
import { existsSync } from 'node:fs';
|
|
11
9
|
import path from 'node:path';
|
|
12
10
|
import process from 'node:process';
|
|
11
|
+
import { checkApp } from '@tbox.cn/app-build';
|
|
13
12
|
|
|
14
13
|
const appDir = path.resolve(process.argv[2] ?? path.join(import.meta.dirname, '..'));
|
|
15
14
|
const failures = [];
|
|
16
15
|
const warnings = [];
|
|
17
16
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
{ path: 'apps/client/src/modules.ts', markers: ['imports', 'register'] },
|
|
21
|
-
];
|
|
17
|
+
const manifest = path.join(appDir, 'apps/client/.tbox-gen/manifest.json');
|
|
18
|
+
if (!existsSync(manifest)) failures.push('apps/client/.tbox-gen/manifest.json: 缺失(先运行 pnpm generate)');
|
|
22
19
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
function isAnchorBegin(line) {
|
|
30
|
-
return line.trim() === '// @tbox:imports-begin';
|
|
31
|
-
}
|
|
32
|
-
function isAnchorEnd(line) {
|
|
33
|
-
return line.trim() === '// @tbox:imports-end';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** 读取 .tbox/app.json 的 npm 模块清单 */
|
|
37
|
-
function readManifestModules() {
|
|
38
|
-
try {
|
|
39
|
-
const raw = JSON.parse(readFileSync(path.join(appDir, '.tbox/app.json'), 'utf8'));
|
|
40
|
-
return Array.isArray(raw?.npmModules) ? raw.npmModules : [];
|
|
41
|
-
} catch {
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** 收集 packages/* 下本地模块 id(有 tbox.module.json) */
|
|
47
|
-
async function listLocalModuleIds() {
|
|
48
|
-
const packagesDir = path.join(appDir, 'packages');
|
|
49
|
-
if (!existsSync(packagesDir)) return [];
|
|
50
|
-
const entries = await readdir(packagesDir, { withFileTypes: true });
|
|
51
|
-
const ids = [];
|
|
52
|
-
for (const entry of entries) {
|
|
53
|
-
if (!entry.isDirectory()) continue;
|
|
54
|
-
if (existsSync(path.join(packagesDir, entry.name, 'tbox.module.json'))) {
|
|
55
|
-
ids.push(entry.name);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return ids;
|
|
20
|
+
const result = await checkApp({ root: appDir });
|
|
21
|
+
for (const issue of result.issues) {
|
|
22
|
+
const line = `${issue.file ? issue.file + ': ' : ''}${issue.message}`;
|
|
23
|
+
if (issue.severity === 'error') failures.push(line);
|
|
24
|
+
else warnings.push(line);
|
|
59
25
|
}
|
|
60
26
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
const b = content.indexOf(begin);
|
|
65
|
-
if (b === -1) return null;
|
|
66
|
-
const e = content.indexOf(end, b);
|
|
67
|
-
if (e === -1) return null;
|
|
68
|
-
return content.slice(b + begin.length, e);
|
|
27
|
+
if (warnings.length > 0) {
|
|
28
|
+
console.warn('[verify:generated] 告警:');
|
|
29
|
+
for (const w of warnings) console.warn(` - ${w}`);
|
|
69
30
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async function main() {
|
|
76
|
-
// ② 锚点完整 + ③ 无裸露 import
|
|
77
|
-
for (const file of ASSEMBLY_FILES) {
|
|
78
|
-
const full = path.join(appDir, file.path);
|
|
79
|
-
if (!existsSync(full)) {
|
|
80
|
-
failures.push(`${file.path}: 缺失`);
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
const content = readFileSync(full, 'utf8');
|
|
84
|
-
for (const marker of file.markers) {
|
|
85
|
-
const block = extractBlock(content, marker);
|
|
86
|
-
if (block === null) {
|
|
87
|
-
failures.push(`${file.path}: 缺 ${marker} 锚区`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const lines = content.split(/\r?\n/);
|
|
91
|
-
let inAnchor = false;
|
|
92
|
-
lines.forEach((line, i) => {
|
|
93
|
-
if (isAnchorBegin(line)) inAnchor = true;
|
|
94
|
-
else if (isAnchorEnd(line)) inAnchor = false;
|
|
95
|
-
// import type 属类型导入(非模块装配),锚区外合法,不视为裸露
|
|
96
|
-
else if (IMPORT_LINE.test(line.trim()) && !line.trim().startsWith('import type') && !inAnchor) {
|
|
97
|
-
failures.push(`${file.path}:${i + 1} 裸露 import(不在 imports 锚区内): ${line.trim()}`);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// ① 漂移 = 0:声明(manifest + 本地模块)vs 服务端 modules.ts 实际装配
|
|
103
|
-
// 契约包(无 tbox.module.json / 无 serverModule)不参与 modules.ts 装配,不计入声明
|
|
104
|
-
// (客户端 modules.ts 装配漂移由 CLI module doctor 全量校验兜底)
|
|
105
|
-
const npmModules = readManifestModules();
|
|
106
|
-
const declared = new Set([
|
|
107
|
-
...npmModules
|
|
108
|
-
.filter((m) => existsSync(path.join(appDir, 'packages', m.id, 'tbox.module.json')))
|
|
109
|
-
.map((m) => m.id),
|
|
110
|
-
...(await listLocalModuleIds()),
|
|
111
|
-
]);
|
|
112
|
-
const modulesTs = existsSync(path.join(appDir, 'apps/server/src/modules.ts'))
|
|
113
|
-
? readFileSync(path.join(appDir, 'apps/server/src/modules.ts'), 'utf8')
|
|
114
|
-
: '';
|
|
115
|
-
const importsBlock = extractBlock(modulesTs, 'imports') ?? '';
|
|
116
|
-
const actual = new Set(
|
|
117
|
-
[...importsBlock.matchAll(/from\s+['"]([^'"]+)['"]/g)].map((m) => idFromPkg(m[1])),
|
|
118
|
-
);
|
|
119
|
-
for (const id of declared) {
|
|
120
|
-
if (!actual.has(id)) failures.push(`模块 ${id} 已声明未装配(modules.ts imports 锚区)`);
|
|
121
|
-
}
|
|
122
|
-
for (const id of actual) {
|
|
123
|
-
if (!declared.has(id)) warnings.push(`模块 ${id} 已装配未声明(仅告警,可能为手接)`);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (warnings.length > 0) {
|
|
127
|
-
console.warn('[verify:generated] 告警:');
|
|
128
|
-
for (const w of warnings) console.warn(` - ${w}`);
|
|
129
|
-
}
|
|
130
|
-
if (failures.length > 0) {
|
|
131
|
-
console.error('[verify:generated] 校验失败:');
|
|
132
|
-
for (const f of failures) console.error(` - ${f}`);
|
|
133
|
-
process.exitCode = 1;
|
|
134
|
-
} else {
|
|
135
|
-
console.log('[verify:generated] 通过(装配一致 + 锚点完整 + 无裸露 import)');
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
main().catch((err) => {
|
|
140
|
-
console.error('[verify:generated] 执行失败:', err);
|
|
31
|
+
if (failures.length > 0) {
|
|
32
|
+
console.error('[verify:generated] 校验失败:');
|
|
33
|
+
for (const f of failures) console.error(` - ${f}`);
|
|
141
34
|
process.exitCode = 1;
|
|
142
|
-
}
|
|
35
|
+
} else {
|
|
36
|
+
console.log('[verify:generated] 通过(apps/ 布局 + generated manifest + 无 legacy 装配面)');
|
|
37
|
+
}
|
package/tsconfig.base.json
CHANGED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# STYLE_GUIDE.md — `client/`
|
|
2
|
-
|
|
3
|
-
纯 web(Vite + React + Less)的 CSS 约定。只列对本项目仍适用的几条;本项目是 web-view H5、不是原生小程序,**没有小程序 CSS 限制**。
|
|
4
|
-
|
|
5
|
-
## 1. 大写 `PX` 跳过 px→rem 转换
|
|
6
|
-
|
|
7
|
-
`postcss-pxtorem` 把 `px` 自动转 `rem`(写设计稿 px 即可)。当某个值需要**固定屏幕像素、不随 rem 缩放**时(典型:PC 端内容区限宽),用**大写 `PX`** —— 转换器大小写敏感,`PX` 不会被转。
|
|
8
|
-
|
|
9
|
-
```less
|
|
10
|
-
.box {
|
|
11
|
-
max-width: 800PX; /* 固定 800px,不转 rem */
|
|
12
|
-
padding: 24px; /* 24px → 0.24rem,随屏缩放 */
|
|
13
|
-
}
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
内容区最大宽度统一用 token,别到处写 `800PX`:
|
|
17
|
-
|
|
18
|
-
```less
|
|
19
|
-
max-width: var(--tbox-content-max-width); /* = 800PX */
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
> `1px` 边框默认不转(`minPixelValue`)。本项目无 stylelint,无需 `unit-case` 注释。
|
|
23
|
-
|
|
24
|
-
## 2. flex 里图标 / 图片别被压扁或溢出
|
|
25
|
-
|
|
26
|
-
flex 容器里,固定尺寸的图标 / 图片若不约束,会在同行文本触发 `text-overflow: ellipsis` 时被压缩变形,或撑开布局。
|
|
27
|
-
|
|
28
|
-
**规则:固定尺寸的 flex 子项加 `flex-shrink: 0` + 显式宽高。**
|
|
29
|
-
|
|
30
|
-
```less
|
|
31
|
-
/* 标题行:右侧箭头图标别被长标题挤压 */
|
|
32
|
-
.title-row {
|
|
33
|
-
display: flex;
|
|
34
|
-
align-items: center;
|
|
35
|
-
justify-content: space-between;
|
|
36
|
-
|
|
37
|
-
.icon { flex-shrink: 0; } /* Phosphor / img 都加 */
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/* 列表项左侧图标:固定尺寸 + 不收缩 + 裁切 */
|
|
41
|
-
.item-icon {
|
|
42
|
-
width: 72px;
|
|
43
|
-
height: 72px;
|
|
44
|
-
flex-shrink: 0;
|
|
45
|
-
overflow: hidden;
|
|
46
|
-
|
|
47
|
-
img { width: 72px; height: 72px; object-fit: contain; }
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## 3. 隐藏滚动条(移动端观感)
|
|
52
|
-
|
|
53
|
-
应用为移动端设计,滚动容器在 PC / web-view 里会冒出滚动条,与设计不符。
|
|
54
|
-
|
|
55
|
-
**规则:可滚动容器隐藏滚动条。**
|
|
56
|
-
|
|
57
|
-
```less
|
|
58
|
-
.scroll-container {
|
|
59
|
-
-ms-overflow-style: none; /* IE/Edge */
|
|
60
|
-
scrollbar-width: none; /* Firefox */
|
|
61
|
-
|
|
62
|
-
&::-webkit-scrollbar { /* Chrome/Safari/WebKit */
|
|
63
|
-
display: none;
|
|
64
|
-
width: 0;
|
|
65
|
-
height: 0;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## 4. 颜色用 `rgba()` 传统语法(web-view 兼容)
|
|
71
|
-
|
|
72
|
-
CSS Color 4 的空格分隔 `rgb(r g b / a)` 语法在**部分旧机型的支付宝 web-view(旧 WebKit)**可能不支持,导致**整条属性失效**(不是降级,是消失)。新写代码优先用 `rgba()`:
|
|
73
|
-
|
|
74
|
-
```less
|
|
75
|
-
/* ✅ 安全 */
|
|
76
|
-
box-shadow: 0 3px 8px rgba(1, 112, 254, 0.04);
|
|
77
|
-
color: rgba(31, 59, 99, 0.85);
|
|
78
|
-
|
|
79
|
-
/* ⚠️ 旧 web-view 风险:整条可能失效 */
|
|
80
|
-
box-shadow: 0 3px 8px rgb(1 112 254 / 3.92%);
|
|
81
|
-
```
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# VISUAL_RESTORE.md — 视觉还原 / 图片驱动开发
|
|
2
|
-
|
|
3
|
-
用户给一张设计图 / 截图 / 原型图,要你照着改本模版时读这份。先解析、出设计指南、用户确认,再写代码——**禁止跳过解析直接开发**。
|
|
4
|
-
|
|
5
|
-
## 流程
|
|
6
|
-
|
|
7
|
-
1. **解析图片** → 按下方「设计指南输出模板」产出完整文档(颜色给 `#xxxxxx`、文案给完整原文、尺寸给具体 px)。
|
|
8
|
-
2. **用户确认** → 等确认或调整。
|
|
9
|
-
3. **按指南开发** → 遵守下方「还原硬规则」+ `../../AGENTS.md`(模板根:web-view 样式约定/组件策略/工程边界)。
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## 还原硬规则(确定性,必须遵守 —— 这些有明确对错、最值钱)
|
|
14
|
-
|
|
15
|
-
1. **模块顺序 / 位置 1:1**:解析先产出"自上而下的模块清单 + 每块位置(左/右/居中)和层级",落地严格按清单顺序和位置写 DOM。**禁止重排模块、改上下顺序、把"左立绘右文字"改成"上下排列"。**
|
|
16
|
-
2. **文案 1:1 完整**:可见文字逐字照搬,**不截断 / 不省略 / 不用"示例 / xx / xxxx"占位**;卡片的 `sampleData` 和 dataSchema 的 `.default(...)` 都填**真实文案**(default 尤其不能是占位词,它是兜底展示值)。长文案换行容纳,别截短。
|
|
17
|
-
3. **截断不补全(红线)**:截图边缘被裁、半露、折叠态的区块是**不完整信息**。**唯一允许**保留完整可见的折叠态(只渲染「标题 + 箭头」,到此为止);**严禁**补全 / 展开 / 推测内容,**严禁**拿其它元素(尤其快捷指令 chip)填充充数。口诀:**看不全,就不做。**
|
|
18
|
-
4. **网格用 CSS Grid**:固定列数一律 `grid-template-columns: repeat(N, 1fr)` + `gap`(grid 自动处理间距、任意列数不溢出);**不要用 `flex + width: 25%`**(忘减 gap 会换行成 N-1 列、还会横向溢出)。
|
|
19
|
-
5. **热区 ≠ 视觉高度**:设计规范里"可点击热区 ≥ 44px"指**点击范围**,不是视觉高度。热区不足用**透明 padding** 扩,**不要用 `min-height` 把 tab / 小标签撑高**(content-box 下还会叠加 padding,撑出 64px)。
|
|
20
|
-
6. **高度与留白贴合**:模块间距、整体高度照设计稿,**不无脑拉长、不挤扁**。
|
|
21
|
-
7. **不溢出**:放可变长文本的 flex 子项加 `min-width: 0`,文本用 `overflow-wrap` / `-webkit-line-clamp` 换行或省略——别让长文本撑爆、把按钮 / 步进器挤出。
|
|
22
|
-
8. **富文本分色**:部分高亮 / 分色的文字(如满赠文案里某几个字是橙色)拆成独立 `<span>` 分别上色,别整段一个颜色。
|
|
23
|
-
|
|
24
|
-
## 平台固定组件:不碰、不另画、不挪位
|
|
25
|
-
|
|
26
|
-
对话基础设施是平台封装好的——**识别到就跳过,只还原它们之间的业务内容区**:
|
|
27
|
-
- `ChatInput`(输入框/上传/语音)、`MessageBubble`(气泡/Markdown/思考)、`ActionBar`(朗读/复制/赞踩/调试)、`ChatHeader`、`ScrollToBottomButton` / `PullDownIndicator` / `HistoryEntry`(顶部历史入口胶囊)、`CardRenderer`。
|
|
28
|
-
- **快捷指令 = `QuickCommands`**:不管设计稿里它在哪个位置、标题叫什么(千问/推荐/常见问题),**都只配 `client/config/chat.json` 的 `quickCommands`,绝不在页面里再画一份**(否则和底部重复成两排);`label` 只写纯文字、图案走 `icon` 字段(别把 ✦/emoji 写进 label)。
|
|
29
|
-
- 详见 `../../AGENTS.md`(模板根:「双运行时与插件」与工程边界)。
|
|
30
|
-
|
|
31
|
-
## 技术路线判断(判错全盘皆错)
|
|
32
|
-
|
|
33
|
-
- **整屏 App 页**(带状态栏 / 导航 / 输入框的一整屏,如智能体首页)→ 改 `client/src/pages/index`,**复用现成模块**(欢迎/轮播/宫格/提问建议)改数据,**禁止做成卡片**。
|
|
34
|
-
- **对话气泡里的一块结构化内容**(点单/确认/推荐)→ 走**卡片(C 方案)**:server `cards/<type>/meta.ts` 数据契约 + client `cards/<type>/index.tsx` React 渲染。见 `../../AGENTS.md`「模块开发」(卡片双端形态与铁律)。
|
|
35
|
-
|
|
36
|
-
## 素材
|
|
37
|
-
|
|
38
|
-
- **图标**:`@phosphor-icons/react`——**线性用默认、设计稿是实心图标就 `weight="fill"`**(别再退回 `<img>`);具名导出,名字按语义猜、拼错会编译报错。`size` 偏大就取小(16–24、宫格/导航 28)。只有**品牌/插画/定制图标**(图库字体都给不了的)才用 `<img>` 素材槽位。
|
|
39
|
-
- **图片**:除 icon 外(含品牌 / 立绘 / logo 等,不区分)一律**先取一张 Unsplash 真图**(有 key 走 API、无 key 拼 `images.unsplash.com/photo-<id>?w=800&q=80`;精确词不行就用泛词、示意到位即可)、**必须 `curl` 验证 `200 + image/ + 体积` 通过才用**,验不过换 id/换词、多次不行才降级成渐变块。**别用孤零零小 emoji 充当主视觉**。
|
|
40
|
-
|
|
41
|
-
## 卡片还原(C 方案的落地路线)
|
|
42
|
-
|
|
43
|
-
判断为卡片后(见上「技术路线判断」),按这条链走,各步细节指向真源、不在此复述:
|
|
44
|
-
|
|
45
|
-
1. **拆解** → 按下面「图片解析」「设计指南输出模板」出设计指南。含 tab / 步进 / 表单 / 派生值的交互卡,额外列 **source / derived / emit**:source→`useState`、derived→渲染时由 state 算、emit→`sendUiAction(cardId, …)` 的 payload 读当前 state(交互卡纪律见 `../../AGENTS.md`「模块开发」)。
|
|
46
|
-
2. **落地** → 按 `../../AGENTS.md`「模块开发」:server `meta.ts`(dataSchema 字段全 `.default` / `.optional`)+ 两端 `registry` 注册 + 触发 tool 接 `TOOL_CARD_MAP`;client `index.tsx`(`data` 用 `import type` 从 meta 推导)。
|
|
47
|
-
3. **数据** → 还原出的文案 **1:1 落进 `sampleData` 和 dataSchema `.default`**(真实文案,default 不能是占位词——它是兜底展示值)。
|
|
48
|
-
4. **样式** → 字号按 2x 梯度;圆角 / 阴影 / 默认白底走 `.tbox-card` 卡框(已裁圆角)、**内边距和宽度自己写**;整卡换底色 / 出血图就在卡片 root 设 `background` / 铺满图(会裁进圆角、不出白边),**别再套一层带圆角容器**;宽度占满整列。详见 `../../AGENTS.md`「模块开发」(卡片双端形态与铁律)。
|
|
49
|
-
5. **图片** → 除 icon 外先取 Unsplash 直链(有 key 走 API、无 key 拼 `images.unsplash.com/photo-<id>`)+ `curl` 验证 `200 + image/ + 体积` 通过才用,`<img>` 加 `onError` 占位(见上「素材」)。
|
|
50
|
-
|
|
51
|
-
**收尾自检**:模块 / 文案 1:1?折叠区没补全?字号已 ×2(没照抄 1x 截图)?容器没重画?图片都校验过 + 带 `onError`?`sampleData` / `.default` 是真实文案?server `build` 与 client `typecheck` / `build` 通过?
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## 图片解析基础要求(出设计指南前)
|
|
56
|
-
|
|
57
|
-
- **深度拆解**:不要只描述整体外观,**逐层拆解内部结构**——子元素组成、排列(水平/垂直/网格)、对齐、嵌套。如一张卡:左图标+右文字还是上图下文?文字有无主标题+副标题层级?有无右侧箭头/标签?
|
|
58
|
-
- **尺寸精度**:所有尺寸给**具体 px**(以屏宽 375 或设计稿标注宽为基准按比例反推),禁止"较大/适中/紧凑"。必标:整体宽高、内边距(上右下左)、子元素间距 gap、圆角、图标/头像尺寸、行高。判断不准的给估计值并标"(估计值)"。
|
|
59
|
-
- ⚠️ **量出来的是屏上(1x)px**;写进卡片 `.less` 时是 **2x 源码 px(CSS px 会折半渲染),一律 ×2**;字号别自定、直接用 `src/styles/tokens.less` 的字号梯度注释(2x 真源)。图标 `size`(屏幕 px)与热区 44 不折半、不 ×2。
|
|
60
|
-
- **完整文案提取**:所有可见文字逐字抄录(标题/副标题/按钮/placeholder/提示/标签/声明),不可"类似 xxx"。
|
|
61
|
-
|
|
62
|
-
## 设计指南输出模板(每节必填,占位符替换成真实值)
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
1. 品牌定位:应用名称 / 类型 / 设计风格(3-4 关键词) / 目标用户 / 核心价值(3-5 项)
|
|
66
|
-
2. 配色方案:
|
|
67
|
-
- 主色 Primary / PrimaryDark / PrimaryLight: #xxxxxx
|
|
68
|
-
- 辅助:成功 / 警告 / 错误: #xxxxxx
|
|
69
|
-
- 中性:标题文本 / 正文 / 辅助 / 边框 / 背景 / 纯白: #xxxxxx
|
|
70
|
-
- 渐变:完整 linear-gradient(...) 值
|
|
71
|
-
3. 字体规范:H1/H2/H3/正文/辅助/小字 各 xxpx + 字重
|
|
72
|
-
4. 间距与圆角:左右安全边距 / 顶部底部 / 区块间距 / 同级间距 / 组件内 padding(上右下左) / 行高 / 各处圆角 各 xxpx
|
|
73
|
-
5. 业务内容区组件:对每个组件按"外观(尺寸/底色/边框/圆角/阴影/外距) → 内部结构(子元素排列/对齐/间距/各自尺寸色字号) → 状态(默认/按下/禁用)"三层描述。
|
|
74
|
-
(卡片**最外层容器**的圆角/阴影/默认白底由 `.tbox-card` 卡框提供并裁圆角,**内边距自己写**;整卡换底色就在卡片 root 设 `background`(会裁进圆角、不出白边)、别再套一层带圆角容器;平台固定组件——气泡/输入框/操作栏/导航/快捷指令——只标注"复用平台组件",不解析其内部、不重造。)
|
|
75
|
-
6. 页面结构:ASCII 线框图 + 各模块自上而下顺序与位置。
|
|
76
|
-
7. 交互规范:发送 / 快捷问题点击行为 / 滚动行为 / 其它可见交互。
|
|
77
|
-
8. Agent 人设:角色定义 / 核心能力 / 能力边界 / 回复风格 / 特殊规则(写进 system instructions)。
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
> 所有 `xxpx` / `#xxxxxx` 必须替换为从图中提取的实际值;某区域不可见就显式写"图中未体现,建议 xxx"并给合理默认。
|
|
81
|
-
|
|
82
|
-
---
|
|
83
|
-
|
|
84
|
-
## 还原边界(避免过度抠像素)
|
|
85
|
-
|
|
86
|
-
- 字体度量、leading 留白不强行消除;颜色精度差 1-2 hex 视为 OK。
|
|
87
|
-
- 完成后简要说明哪些细节做了让步、原因。
|
|
88
|
-
|
|
89
|
-
## 一句话
|
|
90
|
-
**先解析出完整设计指南 → 用户确认 → 严格按"模块 1:1 / 文案 1:1 / 看不全不做 / Grid / 热区非视觉高 / 平台组件不碰 / 整屏走 pages、内容块走卡片"开发。** Web 端 CSS 细节(大写 PX / 滚动条 / rgba)见 `client/STYLE_GUIDE.md`。
|
package/apps/client/src/app.tsx
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import BusinessApp from '@/business/App';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 应用根组件(根 entry main.tsx 的唯一渲染点)。
|
|
5
|
-
* 平台页(/_tbox/card-preview)经 MPA 生成 entry(`.tbox-gen/card-preview.ts` → mountPage)
|
|
6
|
-
* 独立成文档服务——根 entry 不再做 pathname 分支(v6 统一文档形态:与 build 面单一装配路径)。
|
|
7
|
-
* 业务能力经 `npx --yes @tbox.cn/app-cli module add` 扩展。
|
|
8
|
-
*/
|
|
9
|
-
export default function App() {
|
|
10
|
-
return <BusinessApp />;
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import AgentChatApp from '@/platform/AgentChatApp';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 业务应用唯一入口。
|
|
5
|
-
* mall 模板:空态首屏由 IndexPage 内 MallHome 呈现(商圈主屏),无需 landing 注入;
|
|
6
|
-
* 业务能力经 `npx --yes @tbox.cn/app-cli module add` 扩展(shopping-guide/member 等)。
|
|
7
|
-
* 新应用替换本组件;需要定制首屏时组合 AgentChatApp 或改 pages/index。
|
|
8
|
-
*/
|
|
9
|
-
export default function BusinessApp() {
|
|
10
|
-
return <AgentChatApp />;
|
|
11
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
# Business application entry
|
|
2
|
-
|
|
3
|
-
`App.tsx` 是业务应用的唯一入口。缺省出厂 = 空装配 chat 形态(`AgentChatApp` 直出对话流,无 landing 注入——014 已退役)。商圈形态经 `npx --yes @tbox.cn/app-cli create --profile mall` 加装:mall-core 模块经 home 槽供给联单式主屏(欢迎区 + 单一联单活动主卡 + 会员/停车双快览 + 四域开发测试入口),消息追加在首页内容下方,底部保留三枚快捷指令与输入区。四域开发测试入口可见性由后端开关控制(`MALL_HOME_DEV_SERVICES` env → `GET /api/m/mall-core/config`,fail-closed 缺省隐藏;详见模板 ENV.md)。会员快览严格区分登录与入会状态,仅对已入会用户展示服务端返回的真实积分。
|
|
4
|
-
|
|
5
|
-
业务能力经 `npx --yes @tbox.cn/app-cli module add` 扩展(shopping-guide/member/parking/promotion/alipay-activity),安装后自动装配进双端 `modules.ts`;联单节点是支付宝活动回执的支付笔数投影(mall-core 家页面),不从会话业务卡或本地默认值派生。生成完成后运行 `pnpm verify:generated`。
|
|
6
|
-
|
|
7
|
-
## 页面清单(v3.2 MPA 文档模式)
|
|
8
|
-
|
|
9
|
-
`routes.json` 是应用页面清单的唯一真源(在场 ⇔ 端到端文档模式;删除文件 = 回到单页 legacy):
|
|
10
|
-
|
|
11
|
-
```json
|
|
12
|
-
[
|
|
13
|
-
{ "id": "index", "path": "/", "title": "AI 助手" },
|
|
14
|
-
{ "id": "orders", "path": "/orders", "title": "订单" }
|
|
15
|
-
]
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
- 每条路由物化一个物理 HTML 文档(`orders/index.html`)+ 独立 entry chunk——未知页面
|
|
19
|
-
404 是文件系统的自然结果;
|
|
20
|
-
- `path` 纯静态段(每段 `^[a-z0-9][a-z0-9-]*$`,禁点号/冒号/通配)——动态路由已按
|
|
21
|
-
方案裁决放弃,实体详情走 query 参数(`/order?id=`);
|
|
22
|
-
- 页面组件默认 `@/pages/<id>`(可 `page` 字段覆盖;根路由 `/` 禁用 page——恒走根 entry);
|
|
23
|
-
- `title`/`meta` 注入生成文档 `<head>`(dev 面沿用根骨架值);
|
|
24
|
-
- 首段不得落在保留命名空间(`api`/`ws`/`assets`/`_tbox`);
|
|
25
|
-
- 增删路由需重启 dev 进程(input 集会话期一次);修改既有页面 HMR 正常;
|
|
26
|
-
- 页面间跳转 = `<a href>` 整文档导航(跨页状态走 URL/localStorage/服务端会话)。
|
|
27
|
-
|
|
28
|
-
页面组件从 `pages/<id>/index.tsx` 开始写;共享视觉经共享组件显式组合(无嵌套布局)。
|
|
29
|
-
|
|
30
|
-
## 本地交互应用
|
|
31
|
-
|
|
32
|
-
当需求当前只涉及客户端本地行为时:
|
|
33
|
-
|
|
34
|
-
1. 直接替换 `App.tsx`。
|
|
35
|
-
2. 页面、feature、业务 store 和本地规则引擎都放在当前目录。
|
|
36
|
-
3. 持久化状态使用 `@/platform/state/createPersistedStore`。
|
|
37
|
-
4. 起始阶段无需展开 `server/`、`adapters/`、`bridge/`、chat store。
|
|
38
|
-
5. 保留根 `client/src/app.tsx`、inspector 和 Vite 配置。
|
|
39
|
-
|
|
40
|
-
首次编辑前不需要读取根目录结构、`client/src` 目录结构、`vite.config.ts`、`index.html` 或默认对话实现。除上面的入口和 tokens 外,只按实际功能读取持久化 store、Toast 等直接依赖。
|
|
41
|
-
|
|
42
|
-
以上是起始范围,不是永久限制。首次编辑后,直接依赖、远端契约、测试或构建结果证明需求跨层时,应进入对应所有者模块,不要在 `business/` 内重复实现平台能力。
|
|
43
|
-
|
|
44
|
-
推荐结构:
|
|
45
|
-
|
|
46
|
-
```text
|
|
47
|
-
business/
|
|
48
|
-
App.tsx
|
|
49
|
-
features/
|
|
50
|
-
store/
|
|
51
|
-
data/
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## 图标视觉基线
|
|
55
|
-
|
|
56
|
-
图标用于辅助识别,不应压过标题、数据和主要内容。生成或修改业务页面时遵守以下约束:
|
|
57
|
-
|
|
58
|
-
- 优先使用 `@phosphor-icons/react`(模板缺省未内置,按需 `pnpm add @phosphor-icons/react` 引入;pnpm 严格 node_modules 下不随 kit 传递解析),同一区域统一图标系列、`weight`、底板形状和用色方式。浅色底板上的普通入口默认使用 `weight="regular"`;不要为了缩小图标而统一改成 `bold`,否则线条会显得拥挤、厚重。`bold` 只用于确实需要强调的单个操作,`fill` 只用于选中态或少量主操作,不要整页铺满粗线或实心图标。
|
|
59
|
-
- **Phosphor 的 `size` 属性是最终屏幕 CSS 像素,不会经过 PostCSS 的 750 稿换算。** 不要按设计稿尺寸写 `size={36}`、`size={48}`。普通导航/按钮使用 `18~24`,网格入口使用 `20~24`,列表或卡片前导图标使用 `24~28`;只有真正的空状态或主视觉才能更大。
|
|
60
|
-
- 图标底板写 Less 的 750 稿尺寸:四宫格/八宫格入口建议 `72~80px`,列表前导图标建议 `80~96px`。内部图形的视觉宽高不超过底板的 `55%~60%`。
|
|
61
|
-
- 点击热区和图标视觉尺寸分开处理。按钮可以保持足够大的可点击区域,但不要靠放大图标填满热区。
|
|
62
|
-
- 同屏多个入口默认使用浅色底板配单色图标;强渐变和高饱和底板只留给一个主操作或少量重点入口。图标容器不要同时使用大圆角、强渐变和重阴影。
|
|
63
|
-
- 列表和卡片以文字、真实图片或业务数据为主体。纯图标占位不得超过列表项高度的约 `60%`,也不得挤压标题和摘要宽度。
|
|
64
|
-
- 尺寸和颜色通过局部 class 或变量统一管理,不要在每个 JSX 图标上散落互不一致的 `size`、渐变和圆角。
|
|
65
|
-
|
|
66
|
-
示例:
|
|
67
|
-
|
|
68
|
-
```tsx
|
|
69
|
-
<button className="feature-entry">
|
|
70
|
-
<span className="feature-entry__icon">
|
|
71
|
-
<Ticket size={22} weight="regular" />
|
|
72
|
-
</span>
|
|
73
|
-
<span>优惠券</span>
|
|
74
|
-
</button>
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
```less
|
|
78
|
-
.feature-entry {
|
|
79
|
-
min-height: 112px; // 点击热区可以大于视觉图标
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.feature-entry__icon {
|
|
83
|
-
width: 76px; // 750 稿尺寸,实际约 38 CSS px
|
|
84
|
-
height: 76px;
|
|
85
|
-
border-radius: 16px;
|
|
86
|
-
display: flex;
|
|
87
|
-
align-items: center;
|
|
88
|
-
justify-content: center;
|
|
89
|
-
flex-shrink: 0;
|
|
90
|
-
color: var(--tbox-primary);
|
|
91
|
-
background: var(--tbox-primary-light);
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## 对话智能体应用
|
|
96
|
-
|
|
97
|
-
保留平台对话能力时继续使用 `AgentChatApp`。缺省无 landing 注入:空态首屏 = 平台对话,服务端欢迎卡经 `engine.emitCard` 旁路呈现(012 出卡协议);mall 形态(`--profile mall`)下首屏由 home 槽供给(`MallHome`,来源 = `mall-core 模块`)。生成欢迎卡的智能体可直接由服务端出卡,无需改 `App.tsx`。
|
|
98
|
-
|
|
99
|
-
修改对话组件、卡片或服务端工具时再读取对应目录的 `AGENTS.md`。不要修改通用首页入口来写死具体行业内容。
|
package/apps/client/src/main.tsx
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { StrictMode } from 'react';
|
|
2
|
-
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import App from './app';
|
|
4
|
-
import { bootstrap } from './platform/bootstrap';
|
|
5
|
-
|
|
6
|
-
// 启动层(主题/运行时/错误兜底/chat 配置快照/壳参数观测)——与生成 entry(mount-page)共享
|
|
7
|
-
bootstrap();
|
|
8
|
-
|
|
9
|
-
const el = document.getElementById('root');
|
|
10
|
-
|
|
11
|
-
if (el) {
|
|
12
|
-
createRoot(el).render(
|
|
13
|
-
<StrictMode>
|
|
14
|
-
<App />
|
|
15
|
-
</StrictMode>,
|
|
16
|
-
);
|
|
17
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 客户端模块注册装配文件(与 apps/server/src/modules.ts 逐行同构)。
|
|
3
|
-
* tbox CLI 协助维护锚点区;你也可以直接编辑自由区。
|
|
4
|
-
*
|
|
5
|
-
* 锚点区:@tbox:imports-begin/end(模块 import 行)+ @tbox:register-begin/end(模块数组)
|
|
6
|
-
* CLI 行为:增量插入/删除模块行,保留非标行。
|
|
7
|
-
*/
|
|
8
|
-
import type { ClientContext, InferModuleCards } from '@tbox.cn/app-agent-sdk-client';
|
|
9
|
-
|
|
10
|
-
// @tbox:imports-begin
|
|
11
|
-
// 其余能力经 `npx --yes @tbox.cn/app-cli module add` 扩展(shopping-guide/member 等商圈模块;mall-core 经 profiles/mall)
|
|
12
|
-
// @tbox:imports-end
|
|
13
|
-
|
|
14
|
-
// @tbox:register-begin
|
|
15
|
-
// 单一模板统一化:缺省出厂 = 空装配(chat 流;home 槽缺席 → chat 形态派生)——
|
|
16
|
-
// mall-core(home 槽/覆盖卡/内联过滤)经 profiles/mall 加装(接线)。
|
|
17
|
-
// 形态约定:数组恒多行(register 锚区行式插入依赖换行结构;单行 [] 会让 add 只插 import 不插注册行)
|
|
18
|
-
const modules = [
|
|
19
|
-
] as const;
|
|
20
|
-
// @tbox:register-end
|
|
21
|
-
|
|
22
|
-
// 自由区:可做装配级定制——条件注册、顺序调整
|
|
23
|
-
|
|
24
|
-
/** 注册所有已安装模块(客户端装配——勿与 apps/server/src/modules.ts 混淆) */
|
|
25
|
-
export function registerAll(ctx: ClientContext): void {
|
|
26
|
-
// 空装配下 (typeof modules)[number] = never:经最小注册面断言遍历(add 模块后自动收缩为具体类型)
|
|
27
|
-
for (const m of modules as readonly { register(ctx: ClientContext): void }[]) {
|
|
28
|
-
m.register(ctx);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// 类型从运行时装配数组自动推导:增删模块后 CardType 自动收缩/扩展(002 §6.7)
|
|
33
|
-
export type CardType = InferModuleCards<(typeof modules)[number]>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 平台默认的全栈对话运行时。普通本地应用无需读取或修改。
|
|
3
|
-
* 外壳(session/适配器)抽至 AppShell 共享——MPA 生成 entry 与本入口同一平台能力面。
|
|
4
|
-
*/
|
|
5
|
-
import IndexPage from '@/pages/index/index';
|
|
6
|
-
import { AppShell } from './AppShell';
|
|
7
|
-
|
|
8
|
-
export default function AgentChatApp() {
|
|
9
|
-
return (
|
|
10
|
-
<AppShell>
|
|
11
|
-
<IndexPage />
|
|
12
|
-
</AppShell>
|
|
13
|
-
);
|
|
14
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 应用外壳(平台运行时供给层):session 引导 + 平台适配器(TTS 等)。
|
|
3
|
-
* 从 AgentChatApp 抽出的共享外壳——MPA 生成 entry(mount-page)与根 entry
|
|
4
|
-
* (AgentChatApp → BusinessApp)共用,保证任何页面的平台能力面一致。
|
|
5
|
-
*/
|
|
6
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
7
|
-
import { AdapterProvider, createPlatformAdapters, type AdapterContextValue } from '@tbox.cn/app-agent-sdk-client';
|
|
8
|
-
import type { TboxSessionData } from '@tbox.cn/app-contracts';
|
|
9
|
-
import { authClient, platformApi } from './agent-runtime';
|
|
10
|
-
import { createLogger } from '@tbox.cn/app-agent-sdk-client';
|
|
11
|
-
|
|
12
|
-
const appLogger = createLogger('AppShell');
|
|
13
|
-
|
|
14
|
-
export function AppShell({ children }: { children: React.ReactNode }) {
|
|
15
|
-
const [session, setSession] = useState<TboxSessionData | null>(null);
|
|
16
|
-
// TTS 不依赖 session,恒可用且保持同一实例(播放状态不因会话刷新丢失)
|
|
17
|
-
const tts = useMemo(() => createPlatformAdapters().tts, []);
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
authClient
|
|
21
|
-
.ensureAuth()
|
|
22
|
-
// 会话 β 收口:身份恒取 token(服务端 401/403),userId 不再上行
|
|
23
|
-
.then(() => platformApi.getTboxSession())
|
|
24
|
-
.then(setSession)
|
|
25
|
-
.catch((err: unknown) => appLogger.error('tbox session init failed:', err));
|
|
26
|
-
}, []);
|
|
27
|
-
|
|
28
|
-
const refreshSession = useCallback(async (): Promise<AdapterContextValue> => {
|
|
29
|
-
platformApi.clearTboxSession();
|
|
30
|
-
await authClient.refreshAuth();
|
|
31
|
-
const data = await platformApi.getTboxSession(true);
|
|
32
|
-
setSession(data);
|
|
33
|
-
return { tts, ...createPlatformAdapters(data, { tts }), refreshSession };
|
|
34
|
-
}, [tts]);
|
|
35
|
-
|
|
36
|
-
const adapters = useMemo<AdapterContextValue>(() => {
|
|
37
|
-
if (!session) return { tts, refreshSession };
|
|
38
|
-
return { tts, ...createPlatformAdapters(session, { tts }), refreshSession };
|
|
39
|
-
}, [session, tts, refreshSession]);
|
|
40
|
-
|
|
41
|
-
return <AdapterProvider value={adapters}>{children}</AdapterProvider>;
|
|
42
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 平台运行时装配(client 平台轴,已下沉 @tbox.cn/app-agent-sdk-client)。
|
|
3
|
-
* 模板唯一的 SDK 单例持有点:authClient(鉴权)+ platformApi(能力凭证/会话/历史)。
|
|
4
|
-
* 环境值(VITE_API_URL)由 main.tsx 经 configureRuntime 注入(H1)。
|
|
5
|
-
*/
|
|
6
|
-
import { createAuthClient, createPlatformApi } from '@tbox.cn/app-agent-sdk-client';
|
|
7
|
-
// 读源归位 TIER1():mall-scope-url 契约助手(search-only 语义;壳 URL 改写层契约见包注释)
|
|
8
|
-
import { readMallIdFromUrl } from '@app/contracts-mall';
|
|
9
|
-
|
|
10
|
-
export const authClient = createAuthClient({
|
|
11
|
-
// SPEZ-017:token 缓存域键——URL mallId 变更即失效旧 token 重登(跨 mall 防串域)。
|
|
12
|
-
// 读源与 chat.ts configureHelloContext 逐字符同源(mall-scope-url.ts 唯一真源,search-only)
|
|
13
|
-
scopeKey: () => readMallIdFromUrl() ?? '',
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export const platformApi = createPlatformApi();
|