@tbox.cn/app-template-agent 1.0.0-alpha.12 → 1.0.0-alpha.14
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/.tbox/._app.json +0 -0
- package/.tbox/._default-modules.json +0 -0
- package/.tbox/._miniapp-containers.json +0 -0
- package/.tbox/app.json +1 -1
- package/.tbox/default-modules.json +1 -1
- package/.tbox/factory/._chat.json +0 -0
- package/.tbox/factory/chat.json +5 -1
- package/.tbox/miniapp-containers.json +1 -1
- package/AGENTS.md +6 -4
- package/apps/._AGENTS.md +0 -0
- package/apps/AGENTS.md +8 -7
- 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/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/check-evidence.mjs +45 -18
- package/apps/client/scripts/evidence-gate.mjs +21 -4
- package/apps/client/scripts/evidence-gate.test.mjs +22 -0
- package/apps/client/scripts/experience-checks.mjs +131 -75
- 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/probe-checks.mjs +6 -2
- package/apps/client/src/._app.config.ts +0 -0
- package/apps/client/src/._vite-env.d.ts +0 -0
- package/apps/client/src/cards/._AGENTS.md +0 -0
- package/apps/client/src/cards/._registry.ts +0 -0
- package/apps/client/src/cards/registry.ts +20 -4
- package/apps/client/src/pages/._page.tsx +0 -0
- package/apps/client/src/pages/index/._index.tsx +0 -0
- package/apps/client/src/store/._chat.ts +0 -0
- package/apps/client/src/store/chat.ts +3 -2
- package/apps/client/src/styles/._brand.css +0 -0
- package/apps/client/src/styles/._tailwind.css +0 -0
- package/apps/client/src/test/._setup.ts +0 -0
- package/apps/client/vite.config.ts +3 -0
- 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/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/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/{packages/agent-ui-kit/src/components/ChatHeader/._index.test.tsx → apps/server/src/actions/._AGENTS.md} +0 -0
- package/apps/server/src/actions/AGENTS.md +9 -0
- package/apps/server/src/cards/._AGENTS.md +0 -0
- package/apps/server/src/cards/AGENTS.md +8 -18
- 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/config/._integration.ts +0 -0
- package/apps/server/src/tools/._AGENTS.md +0 -0
- package/apps/server/src/tools/AGENTS.md +7 -21
- 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/helpers/._register.ts +0 -0
- 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 +8 -13
- package/config/chat.json +9 -21
- 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/{packages/agent-ui-kit/src/components/ChatHeader/._index.tsx → docs/agent/._errors.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/card-action.md +14 -6
- package/docs/agent/card.md +1 -1
- package/docs/agent/conversation.md +3 -3
- package/docs/agent/errors.md +66 -0
- package/docs/agent/kit.md +6 -7
- package/docs/agent/shell.md +15 -10
- package/docs/agent/verify.md +21 -72
- 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/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/modules/provider-custom/tests/._provider-custom.test.ts +0 -0
- package/package.json +4 -4
- 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/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 +7 -17
- package/packages/agent-ui-kit/package.json +1 -1
- 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 +77 -151
- 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 +96 -31
- package/packages/agent-ui-kit/src/card/primitives.test.tsx +20 -7
- package/packages/agent-ui-kit/src/card/primitives.tsx +54 -41
- package/packages/agent-ui-kit/src/card/use-card-actions.ts +23 -14
- package/packages/agent-ui-kit/src/card/view-card-inline.test.tsx +34 -2
- package/packages/agent-ui-kit/src/card/view-card.test.tsx +3 -3
- package/packages/agent-ui-kit/src/card/view-card.tsx +24 -29
- package/packages/agent-ui-kit/src/chat-config.test.ts +13 -8
- package/packages/agent-ui-kit/src/chat-config.ts +29 -8
- package/packages/agent-ui-kit/src/components/._CardRenderer.tsx +0 -0
- package/packages/agent-ui-kit/src/components/._HistoryList.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/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/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/._use-auto-rows.test.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ChatInput/._use-auto-rows.ts +0 -0
- package/packages/agent-ui-kit/src/components/ChatInput/index.test.tsx +37 -0
- package/packages/agent-ui-kit/src/components/ChatInput/index.tsx +19 -6
- package/packages/agent-ui-kit/src/components/ChatInput/use-auto-rows.test.tsx +78 -0
- package/packages/agent-ui-kit/src/components/ChatInput/use-auto-rows.ts +68 -0
- 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/HistoryEntry/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/HistoryEntry/index.tsx +3 -1
- package/packages/agent-ui-kit/src/components/HistoryList.tsx +52 -0
- package/packages/agent-ui-kit/src/components/MediaList/._index.tsx +0 -0
- 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 +2 -3
- package/packages/agent-ui-kit/src/components/PullDownIndicator/._index.tsx +0 -0
- 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 +25 -5
- package/packages/agent-ui-kit/src/components/QuickCommands/index.tsx +30 -27
- package/packages/agent-ui-kit/src/components/ReasoningBlock/._index.tsx +0 -0
- package/packages/agent-ui-kit/src/components/ScrollToBottomButton/._index.tsx +0 -0
- 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/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/._use-stick-to-bottom.test.tsx +0 -0
- package/packages/agent-ui-kit/src/hooks/._use-stick-to-bottom.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/hooks/use-pull-down-history.ts +3 -4
- package/packages/agent-ui-kit/src/hooks/use-pull-down-wheel-native.test.ts +4 -8
- package/packages/agent-ui-kit/src/hooks/use-stick-to-bottom.test.tsx +142 -0
- package/packages/agent-ui-kit/src/hooks/use-stick-to-bottom.ts +218 -0
- package/packages/agent-ui-kit/src/index.ts +1 -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/preview-provider.tsx +2 -1
- package/packages/agent-ui-kit/src/shell.contract.json +12 -13
- package/packages/agent-ui-kit/src/shell.test.ts +107 -11
- package/packages/agent-ui-kit/src/shell.ts +13 -10
- package/packages/agent-ui-kit/src/test/._setup.ts +0 -0
- package/packages/agent-ui-kit/src/test/setup.ts +31 -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 +5 -0
- package/packages/agent-ui-kit/src/theme/contract.json +1 -0
- package/packages/agent-ui-kit/src/theme/tokens.css +1 -0
- 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/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/src/._index.ts +0 -0
- package/pnpm-lock.template.yaml +245 -241
- package/pnpm-workspace.template.yaml +11 -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 +5 -1
- 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 +8 -8
- package/profiles/mall.json +2 -1
- package/scenarios/._README.md +0 -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/checks.json +107 -75
- package/scripts/deliver.mjs +26 -8
- package/scripts/lib/._chrome-pipe.mjs +0 -0
- package/scripts/lib/._geometry-kernel.mjs +0 -0
- package/scripts/lib/chrome-pipe.mjs +2 -1
- package/scripts/shell-probe.mjs +119 -21
- package/packages/agent-ui-kit/src/components/ChatHeader/index.test.tsx +0 -74
- package/packages/agent-ui-kit/src/components/ChatHeader/index.tsx +0 -77
|
@@ -9,6 +9,114 @@ import path from 'node:path';
|
|
|
9
9
|
import { scanColorLiterals } from './color-scan.mjs';
|
|
10
10
|
import { nearestToken, readTokens } from './theme-kernel.mjs';
|
|
11
11
|
|
|
12
|
+
/** 字符串结束位置:单双引号只看本行,模板字符串可跨行;找不到就按普通字符处理。 */
|
|
13
|
+
function closingQuote(source, index, quote) {
|
|
14
|
+
let stop = source.length;
|
|
15
|
+
if (quote !== '`') {
|
|
16
|
+
const newline = source.indexOf('\n', index);
|
|
17
|
+
if (newline >= 0) stop = newline;
|
|
18
|
+
}
|
|
19
|
+
for (let cursor = index + 1; cursor < stop; cursor += 1) {
|
|
20
|
+
if (source[cursor] === '\\') {
|
|
21
|
+
cursor += 1;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (source[cursor] === quote) return cursor;
|
|
25
|
+
}
|
|
26
|
+
return -1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** 注释抹成等长空白(保留换行,行号不变);字符串原样保留,避免把说明文字当成代码。 */
|
|
30
|
+
export function blankComments(source, extension) {
|
|
31
|
+
const css = extension === '.css';
|
|
32
|
+
let output = '';
|
|
33
|
+
let quote = '';
|
|
34
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
35
|
+
const char = source[index];
|
|
36
|
+
const next = source[index + 1];
|
|
37
|
+
if (quote) {
|
|
38
|
+
output += char;
|
|
39
|
+
if (char === '\\' && index + 1 < source.length) {
|
|
40
|
+
output += source[index + 1];
|
|
41
|
+
index += 1;
|
|
42
|
+
} else if (char === quote) {
|
|
43
|
+
quote = '';
|
|
44
|
+
}
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (char === '/' && next === '*') {
|
|
48
|
+
const end = source.indexOf('*/', index + 2);
|
|
49
|
+
const stop = end < 0 ? source.length : end + 2;
|
|
50
|
+
for (let cursor = index; cursor < stop; cursor += 1) output += source[cursor] === '\n' ? '\n' : ' ';
|
|
51
|
+
index = stop - 1;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (!css && char === '/' && next === '/') {
|
|
55
|
+
const end = source.indexOf('\n', index + 2);
|
|
56
|
+
const stop = end < 0 ? source.length : end;
|
|
57
|
+
output += ' '.repeat(stop - index);
|
|
58
|
+
index = stop - 1;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
// JSX 文本里的撇号(Don't)没有配对引号,不能当成字符串起点,否则会漏掉后续注释。
|
|
62
|
+
if (!css && (char === "'" || char === '"' || char === '`') && closingQuote(source, index, char) >= 0) quote = char;
|
|
63
|
+
output += char;
|
|
64
|
+
}
|
|
65
|
+
return output;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** 固定/吸顶定位与 Tailwind fixed/sticky 类;行内 tbox-allow: fixed 豁免。 */
|
|
69
|
+
const CUSTOM_CHROME = /position:\s*(?:fixed|sticky)|(?:^|[\s"'`])(?:fixed|sticky)(?:[\s"'`]|$)/;
|
|
70
|
+
const CUSTOM_CHROME_ALLOW = 'tbox-allow: fixed';
|
|
71
|
+
const CUSTOM_CHROME_DETAIL = '壳没有页头:身份写进 welcome.title,页面标题写进 page.title';
|
|
72
|
+
|
|
73
|
+
/** 扫 apps/client/src 的源码与样式;返回命中文件(相对 client 目录)与行号。 */
|
|
74
|
+
export function findCustomChrome(clientDir) {
|
|
75
|
+
const root = path.join(clientDir, 'src');
|
|
76
|
+
const offenders = [];
|
|
77
|
+
if (!existsSync(root)) return offenders;
|
|
78
|
+
const walk = (dir) => {
|
|
79
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
80
|
+
const full = path.join(dir, entry.name);
|
|
81
|
+
if (entry.isDirectory()) {
|
|
82
|
+
walk(full);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (!/\.(?:tsx?|css)$/.test(entry.name)) continue;
|
|
86
|
+
// 测试夹具不是交付面:夹具里的 position: fixed 不该阻断交付
|
|
87
|
+
if (/\.(?:test|spec)\.[jt]sx?$/.test(entry.name)) continue;
|
|
88
|
+
const source = readFileSync(full, 'utf8');
|
|
89
|
+
const rawLines = source.split('\n');
|
|
90
|
+
const stripped = blankComments(source, path.extname(entry.name));
|
|
91
|
+
let hit = false;
|
|
92
|
+
// position: 可以跨行(冒号后换行再写 fixed);豁免按命中涉及的行判断。
|
|
93
|
+
const position = /position:\s*(?:fixed|sticky)/g;
|
|
94
|
+
let positionMatch;
|
|
95
|
+
while ((positionMatch = position.exec(stripped))) {
|
|
96
|
+
const startLine = stripped.slice(0, positionMatch.index).split('\n').length - 1;
|
|
97
|
+
const endLine = stripped.slice(0, positionMatch.index + positionMatch[0].length).split('\n').length - 1;
|
|
98
|
+
const allowed = rawLines.slice(startLine, endLine + 1).some((line) => line.includes(CUSTOM_CHROME_ALLOW));
|
|
99
|
+
if (allowed) continue;
|
|
100
|
+
offenders.push(path.relative(clientDir, full) + ':' + (startLine + 1));
|
|
101
|
+
hit = true;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (hit) continue;
|
|
105
|
+
const lines = stripped.split('\n');
|
|
106
|
+
for (const [index, line] of lines.entries()) {
|
|
107
|
+
// 豁免写在注释里也能生效:按原始行判断,扫描注释前先看标记。
|
|
108
|
+
if (rawLines[index].includes(CUSTOM_CHROME_ALLOW)) continue;
|
|
109
|
+
if (CUSTOM_CHROME.test(line)) {
|
|
110
|
+
offenders.push(path.relative(clientDir, full) + ':' + (index + 1));
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
walk(root);
|
|
117
|
+
return offenders;
|
|
118
|
+
}
|
|
119
|
+
|
|
12
120
|
export const STATIC_CHECKS = {
|
|
13
121
|
'boot.inline-script': ({ clientDir }) => {
|
|
14
122
|
try {
|
|
@@ -20,15 +128,6 @@ export const STATIC_CHECKS = {
|
|
|
20
128
|
}
|
|
21
129
|
},
|
|
22
130
|
|
|
23
|
-
'shell.identity': ({ appDir }) => {
|
|
24
|
-
try {
|
|
25
|
-
const source = readFileSync(path.join(appDir, 'packages/agent-ui-kit/src/components/MessageBubble/index.tsx'), 'utf8');
|
|
26
|
-
return { status: source.includes('identity?.name') ? 'pass' : 'fail', detail: '发送者名取 identity.name' };
|
|
27
|
-
} catch (error) {
|
|
28
|
-
return { status: 'deferred', detail: 'kit 副本不在预期位置:' + (error?.message ?? error) };
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
|
|
32
131
|
'quick.label-query': ({ appDir }) => {
|
|
33
132
|
try {
|
|
34
133
|
const chat = JSON.parse(readFileSync(path.join(appDir, 'config/chat.json'), 'utf8'));
|
|
@@ -43,50 +142,6 @@ export const STATIC_CHECKS = {
|
|
|
43
142
|
}
|
|
44
143
|
},
|
|
45
144
|
|
|
46
|
-
'meta.brand': ({ appDir }) => {
|
|
47
|
-
try {
|
|
48
|
-
const chatPage = readFileSync(path.join(appDir, 'packages/agent-ui-kit/src/ChatPage.tsx'), 'utf8');
|
|
49
|
-
const ok = chatPage.includes('document.title') && chatPage.includes('theme-color');
|
|
50
|
-
return { status: ok ? 'pass' : 'fail', detail: ok ? '标题与主题色跟身份注入' : 'kit 未注入标题/主题色' };
|
|
51
|
-
} catch {
|
|
52
|
-
return { status: 'deferred', detail: 'kit 副本不在预期位置' };
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
'style.url-quoted': ({ appDir }) => {
|
|
57
|
-
try {
|
|
58
|
-
const files = ['components/QuickCommands/index.tsx', 'components/ChatInput/index.tsx'];
|
|
59
|
-
const offenders = files.filter((file) => {
|
|
60
|
-
const full = path.join(appDir, 'packages/agent-ui-kit/src', file);
|
|
61
|
-
if (!existsSync(full)) return false;
|
|
62
|
-
return /url\(\$\{/.test(readFileSync(full, 'utf8'));
|
|
63
|
-
});
|
|
64
|
-
return {
|
|
65
|
-
status: offenders.length > 0 ? 'fail' : 'pass',
|
|
66
|
-
detail: offenders.length > 0 ? '未加引号的 url():' + offenders.join('、') : 'url() 均已加引号',
|
|
67
|
-
};
|
|
68
|
-
} catch {
|
|
69
|
-
return { status: 'deferred', detail: 'kit 源码不可读' };
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
'kit.color-literal': ({ appDir }) => {
|
|
74
|
-
try {
|
|
75
|
-
const cardDir = path.join(appDir, 'packages/agent-ui-kit/src/card');
|
|
76
|
-
const sources = ['primitives.tsx', 'view-card.tsx']
|
|
77
|
-
.filter((file) => existsSync(path.join(cardDir, file)))
|
|
78
|
-
.map((file) => readFileSync(path.join(cardDir, file), 'utf8'))
|
|
79
|
-
.join('\n');
|
|
80
|
-
const literals = sources.match(/#[0-9a-fA-F]{3,8}\b|rgba?\(/g) ?? [];
|
|
81
|
-
return {
|
|
82
|
-
status: literals.length > 0 ? 'fail' : 'pass',
|
|
83
|
-
detail: literals.length > 0 ? '卡片基元里有 ' + literals.length + ' 处非令牌色值' : '卡片基元零色值字面量',
|
|
84
|
-
};
|
|
85
|
-
} catch {
|
|
86
|
-
return { status: 'deferred', detail: 'kit 卡片源码不可读' };
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
|
|
90
145
|
// 同一色值三处以上就该进契约(style.md 的规则由检查兜住);只提示不阻断。
|
|
91
146
|
'style.color-repeat': ({ appDir }) => {
|
|
92
147
|
try {
|
|
@@ -121,36 +176,37 @@ export const STATIC_CHECKS = {
|
|
|
121
176
|
}
|
|
122
177
|
},
|
|
123
178
|
|
|
124
|
-
'card.action-primary': ({ appDir }) => {
|
|
125
|
-
try {
|
|
126
|
-
const viewCard = readFileSync(path.join(appDir, 'packages/agent-ui-kit/src/card/view-card.tsx'), 'utf8');
|
|
127
|
-
const ok = viewCard.includes('index === 0') && viewCard.includes("'primary'") && viewCard.includes("'secondary'");
|
|
128
|
-
return { status: ok ? 'pass' : 'fail', detail: ok ? '首个动作为主按钮' : '视图卡未按序分主次' };
|
|
129
|
-
} catch {
|
|
130
|
-
return { status: 'deferred', detail: '视图卡源码不可读' };
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
|
|
134
179
|
'shell.type-scale': ({ appDir, clientDir }) => {
|
|
135
180
|
const offScale = [];
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
181
|
+
const root = path.join(clientDir ?? path.join(appDir, 'apps/client'), 'src');
|
|
182
|
+
if (!existsSync(root)) return { status: 'pass', detail: '档外字号 0 处' };
|
|
183
|
+
const walk = (dir) => {
|
|
184
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
185
|
+
const full = path.join(dir, entry.name);
|
|
186
|
+
if (entry.isDirectory()) walk(full);
|
|
187
|
+
else if (/\.(tsx?|css)$/.test(entry.name) && !entry.name.endsWith('.test.tsx')) {
|
|
188
|
+
if (/text-\[\d+(?:\.\d+)?px\]/.test(readFileSync(full, 'utf8'))) offScale.push(path.relative(appDir, full));
|
|
145
189
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
walk(root);
|
|
149
193
|
return {
|
|
150
194
|
status: offScale.length === 0 ? 'pass' : 'fail',
|
|
151
195
|
detail: offScale.length === 0 ? '档外字号 0 处' : '档外字号:' + offScale.slice(0, 5).join('、'),
|
|
152
196
|
};
|
|
153
197
|
},
|
|
198
|
+
|
|
199
|
+
'shell.no-custom-chrome': ({ appDir, clientDir }) => {
|
|
200
|
+
const base = clientDir ?? path.join(appDir, 'apps/client');
|
|
201
|
+
const offenders = findCustomChrome(base);
|
|
202
|
+
return {
|
|
203
|
+
status: offenders.length === 0 ? 'pass' : 'fail',
|
|
204
|
+
// 阻塞级报错必须给位置,否则用户在整棵 apps/client/src 里找不到那一行
|
|
205
|
+
detail: offenders.length === 0
|
|
206
|
+
? '应用源码没有固定/吸顶区'
|
|
207
|
+
: CUSTOM_CHROME_DETAIL + ':' + offenders.slice(0, 5).join('、') + (offenders.length > 5 ? ` 等 ${offenders.length} 处` : ''),
|
|
208
|
+
};
|
|
209
|
+
},
|
|
154
210
|
};
|
|
155
211
|
|
|
156
212
|
/** 按 checks.json 的 phase=static 顺序执行;未知 id 明确失败,避免「登记了但静默没跑」。 */
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -11,8 +11,10 @@ export const PROBE_CHECKS = {
|
|
|
11
11
|
'shell.controls-semantic': { lane: 'layout', title: '控件为语义按钮' },
|
|
12
12
|
'shell.control-present': { lane: 'layout', title: '能力开启时控件在场' },
|
|
13
13
|
'shell.a11y-name': { lane: 'layout', title: '控件有可访问名' },
|
|
14
|
-
'shell.blank': { lane: 'layout', title: '
|
|
15
|
-
'shell.
|
|
14
|
+
'shell.blank': { lane: 'layout', title: '首页块间空白 ≤35%(聊天流不适用)' },
|
|
15
|
+
'shell.no-fixed-chrome': { lane: 'layout', title: '滚动区之上无常驻元素' },
|
|
16
|
+
'shell.input-rows': { lane: 'layout', title: '空输入框单行且命中区达标' },
|
|
17
|
+
'shell.follow-latest': { lane: 'runtime', title: '内容增长跟到底、上滑停止跟随' },
|
|
16
18
|
'shell.console-clean': { lane: 'runtime', title: '控制台无告警' },
|
|
17
19
|
};
|
|
18
20
|
|
|
@@ -71,6 +73,8 @@ export function mergeProbeChecks({ probe, ids, policy, stale = '' }) {
|
|
|
71
73
|
}
|
|
72
74
|
const found = Array.isArray(probe?.items) ? probe.items.find((item) => item.id === id) : undefined;
|
|
73
75
|
if (found) {
|
|
76
|
+
// na = 应用形态决定不适用(如聊天流不量首屏密度);deferred = 该跑没跑
|
|
77
|
+
if (found.status === 'na') return { id, lane: found.lane ?? meta.lane, status: 'na', detail: found.detail };
|
|
74
78
|
return { id, lane: found.lane ?? meta.lane, status: found.status === 'not-run' ? 'deferred' : found.status, detail: found.detail };
|
|
75
79
|
}
|
|
76
80
|
return {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* 卡片注册表 + 客户端组装上下文(模块加载期快照)。
|
|
3
3
|
* 注册由生成 entry 的 registerClientModules 完成;本文件只读取同一 ClientContext。
|
|
4
4
|
*/
|
|
5
|
-
import type { CardComponent, TboxCardPayload } from '@tbox.cn/app-contracts';
|
|
6
|
-
import
|
|
5
|
+
import type { CardComponent, HomeSlotValue, TboxCardPayload } from '@tbox.cn/app-contracts';
|
|
6
|
+
import deploymentChat from '@config/chat.json';
|
|
7
|
+
import { ClientSlotRegistry, getClientContext } from '@tbox.cn/app-agent-sdk-client';
|
|
7
8
|
|
|
8
9
|
const ctx = getClientContext();
|
|
9
10
|
|
|
@@ -20,5 +21,20 @@ export const CHAT_REGISTRY: Record<string, CardComponent> = {
|
|
|
20
21
|
export const INLINE_CARD_FILTER = (cards: readonly TboxCardPayload[]): TboxCardPayload[] =>
|
|
21
22
|
ctx.cards.applyInlineFilters(cards);
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
function pageSlots() {
|
|
25
|
+
if (ctx.slots.has('home') || !('homePreset' in deploymentChat) || deploymentChat.homePreset !== 'mall-home') {
|
|
26
|
+
return ctx.slots;
|
|
27
|
+
}
|
|
28
|
+
// mall 画像才安装此模块。无模块的基础模板也能构建。
|
|
29
|
+
const homes = import.meta.glob<HomeSlotValue>('@app-module/module-mall-core/src/client/home-slot.tsx', {
|
|
30
|
+
eager: true, import: 'homeSlotValue',
|
|
31
|
+
});
|
|
32
|
+
const home = Object.values(homes)[0];
|
|
33
|
+
if (!home) throw new Error('homePreset=mall-home 需要安装 module-mall-core');
|
|
34
|
+
// 此预置包含完整的会员门禁。使用页面自己的槽表,避免同一门禁再挂载一份。
|
|
35
|
+
const slots = new ClientSlotRegistry();
|
|
36
|
+
slots.register('home', home);
|
|
37
|
+
return slots;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const CLIENT_SLOTS = pageSlots();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -41,11 +41,12 @@ export const useChatStore = create<CoreChatState>()((set, get) => ({
|
|
|
41
41
|
// 停车缴费按用户就近车场查(服务端 #ensureParkingId 用 lbs 反查 cityId→最近车场),
|
|
42
42
|
// 故伴采集实时 lbs(best-effort:H5/无定位权限时静默丢弃,服务端自行降级 plaza)。
|
|
43
43
|
// getter 同步签名,不能现 await getLocation() → 装配期先发起,缓存供 getter 同步读取。
|
|
44
|
-
let cachedLbs: { latitude: string; longitude: string } | undefined;
|
|
44
|
+
let cachedLbs: { latitude: string; longitude: string; cityCode?: string } | undefined;
|
|
45
45
|
void getLocation()
|
|
46
46
|
.then((loc) => {
|
|
47
47
|
if (Number.isFinite(loc.latitude) && Number.isFinite(loc.longitude)) {
|
|
48
|
-
|
|
48
|
+
const cityCode = typeof loc.cityCode === 'string' && /^\d{6}$/.test(loc.cityCode) ? loc.cityCode : undefined;
|
|
49
|
+
cachedLbs = { latitude: String(loc.latitude), longitude: String(loc.longitude), ...(cityCode ? { cityCode } : {}) };
|
|
49
50
|
}
|
|
50
51
|
})
|
|
51
52
|
.catch(() => {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -29,6 +29,7 @@ export default defineConfig(async ({ command }) => {
|
|
|
29
29
|
const { default: tboxDevOverride } = await import(pathToFileURL(devOverridePath).href);
|
|
30
30
|
devPlugins.push(tboxDevOverride());
|
|
31
31
|
}
|
|
32
|
+
const configuredChat = process.env.TBOX_CONFIG_DIR && resolve(process.env.TBOX_CONFIG_DIR, 'chat.json');
|
|
32
33
|
return {
|
|
33
34
|
plugins: [
|
|
34
35
|
tboxModuleSourcesPlugin({ appRoot: resolve(__dirname, '../..') }),
|
|
@@ -44,7 +45,9 @@ export default defineConfig(async ({ command }) => {
|
|
|
44
45
|
resolve: {
|
|
45
46
|
alias: {
|
|
46
47
|
'@': resolve(__dirname, 'src'),
|
|
48
|
+
'@app-module': resolve(__dirname, '../../modules'),
|
|
47
49
|
// 应用配置面锚(chat.json 等):根除 src 层级相对路径深度耦合(bootstrap 消费)
|
|
50
|
+
...(configuredChat && existsSync(configuredChat) ? { '@config/chat.json': configuredChat } : {}),
|
|
48
51
|
'@config': resolve(__dirname, '../../config'),
|
|
49
52
|
},
|
|
50
53
|
// dev 域 React 单实例(G1/G2 防线):双 dev 入口经本文件合并生效(middleware
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/apps/server/src/._app.ts
CHANGED
|
Binary file
|
package/apps/server/src/._dev.ts
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<!-- agent-surface:subdir begin(由 scripts/sync-agent-surface.mjs 生成,不要手改) -->
|
|
2
|
+
# apps/server/src/actions
|
|
3
|
+
|
|
4
|
+
- 一个动作一个 `*.action.ts`,导出 `defineAction({ id, cardType, inputSchema, singleUse, execute })`;`cardType` 是字符串字面量或数组。
|
|
5
|
+
- 本卡状态变了用 `updateResult(card, 领域数据)`;出另一类结果用 `cardResult(card, 数据)`;只要一句提示用 `actionResult.notice(text)`。
|
|
6
|
+
- 视图卡传领域数据,转换由卡片自己的 `view` 完成;不要手写视图 JSON,也不要同时返回 card 与 update。
|
|
7
|
+
- 动作结果不进模型上下文;写操作先判幂等再落副作用,`singleUse: true` 防重复提交。
|
|
8
|
+
- 写法:[card-action](../../../../docs/agent/card-action.md)。
|
|
9
|
+
<!-- agent-surface:subdir end -->
|
|
Binary file
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- agent-surface:subdir begin(由 scripts/sync-agent-surface.mjs 生成,不要手改) -->
|
|
2
|
+
# apps/server/src/cards(默认视图卡)
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
`apps/client/src/cards
|
|
5
|
-
`
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
cardType: 'order-status',
|
|
10
|
-
dataSchema: orderStatusCardSchema, // 与客户端共用 @app/shared/cards/<id>
|
|
11
|
-
displayName: '订单状态',
|
|
12
|
-
description: '一句话说明这张卡展示什么',
|
|
13
|
-
sampleData: { /* 必须能过 dataSchema,供预览与场景断言 */ },
|
|
14
|
-
schemaVersion: 1,
|
|
15
|
-
} satisfies CardMeta<typeof orderStatusCardSchema>;
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
- 只有服务端文件、没有客户端文件的卡片不会被注册。
|
|
19
|
-
- 字段形状、样例与注意项见 `docs/agent/card.md`。
|
|
4
|
+
- 默认写视图卡:`defineViewCard` + `view(data)`,一张卡只有服务端这一个文件;客户端由 app-build 派生。
|
|
5
|
+
- 三件套只在需要自定义图形或富交互时写:本目录 meta + `apps/client/src/cards/<cardType>.card.tsx` + `packages/shared/src/cards/<cardType>.ts`。
|
|
6
|
+
- 视图卡的 data 是领域数据;`view(data)` 只做「领域数据 → 视图 JSON」,不读 IO、不依赖 React。
|
|
7
|
+
- `cardType` 用字符串字面量;样例由 `sampleState`(视图卡)或 `sampleData`(三件套)派生,`card render` 与场景断言都读它。
|
|
8
|
+
- 字段、样例与三件套写法:[card](../../../../docs/agent/card.md)。
|
|
9
|
+
<!-- agent-surface:subdir end -->
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,23 +1,9 @@
|
|
|
1
|
+
<!-- agent-surface:subdir begin(由 scripts/sync-agent-surface.mjs 生成,不要手改) -->
|
|
1
2
|
# apps/server/src/tools
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export const tool = defineTool({
|
|
10
|
-
id: 'order-status', // 字符串字面量,扫描器读静态值
|
|
11
|
-
description: '…命中数据时结果附可展示卡片(cards)。',
|
|
12
|
-
inputSchema: z.object({}),
|
|
13
|
-
execute: async (_args, { userId, identity }) => {
|
|
14
|
-
// 用户身份从 execute 第二参取;不要兜底成固定 id。
|
|
15
|
-
const facts = { title: 'order-status', userId, source: identity.source };
|
|
16
|
-
return { ...facts, cards: [cardOf(orderStatusCard, facts, '一句话摘要')] };
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
- 出卡用 `cardOf(meta, data, note)`:`cardType` 由卡片 meta 推导,不写字符串。
|
|
22
|
-
- 不要声明 `outputSchema`:出参解析会剥掉保留字段 `cards`(详见 `docs/agent/tool-emits-card.md`)。
|
|
23
|
-
- 完整示例见 `docs/agent/tool.md`;新增工具优先 `pnpm exec tbox-app new feature <name>`(连带生成配套卡片)。
|
|
4
|
+
- 一个工具一个 `*.tool.ts`,导出 `defineTool({ id, description, inputSchema, cards, execute })`;`id` / `description` 用字符串字面量。
|
|
5
|
+
- 出卡:视图卡用 `cardOfView(card, 领域数据, note)`;普通卡用 `cardOf(card, 数据, note)`。
|
|
6
|
+
- 不要声明 `outputSchema`:出参解析会剥掉保留字段 `cards`。
|
|
7
|
+
- 工具只做薄适配(查状态、拼事实、出卡);写操作放动作,复用同一份领域逻辑。
|
|
8
|
+
- 写法:[tool](../../../../docs/agent/tool.md);出卡协议:[tool-emits-card](../../../../docs/agent/tool-emits-card.md)。
|
|
9
|
+
<!-- agent-surface:subdir end -->
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/config/._AGENTS.md
CHANGED
|
Binary file
|
package/config/._README.md
CHANGED
|
Binary file
|
package/config/._chat.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/config/._plugins.json
CHANGED
|
Binary file
|
package/config/AGENTS.md
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- agent-surface:subdir begin(由 scripts/sync-agent-surface.mjs 生成,不要手改) -->
|
|
2
|
+
# config(应用配置面)
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
| `plugins.json` | 插件开关 | — |
|
|
10
|
-
|
|
11
|
-
- 形状以 schema 命令输出为准,不要照抄文档里的示例字段。
|
|
12
|
-
- `chat.json` 不列出厂能力开关(语音输入/播报、图片/视频上传):缺省即开启;只有用户明确要求时才写 false,并在交付说明里声明。
|
|
13
|
-
- 配置在服务启动时读取;改完需重启进程。
|
|
14
|
-
- 提示词写法与常见规则见 `docs/agent/agent-prompt.md`,壳配置见 `docs/agent/shell.md`。
|
|
4
|
+
- 文件:`chat.json`(对话壳)、`agent.jsonc`(提示词)、`integrations.json`(服务槽)、`llm_provider.json`(模型)、`plugins.json`(插件)。
|
|
5
|
+
- 形状查 `pnpm exec tbox-app schema config/chat.json` 等;配置在服务启动时读取,改完重启。
|
|
6
|
+
- `chat.json` 不列出厂能力开关(语音输入/播报、图片/视频上传):缺省即开启,只有用户明确要求才写 false。
|
|
7
|
+
- `identity` 已退役:身份写进 `welcome.title`,页面标题写进 `page.title`(`apps/client/src/pages/page.tsx`);壳没有页头。
|
|
8
|
+
- 写法:[shell](../docs/agent/shell.md)(壳与欢迎区)、[agent-prompt](../docs/agent/agent-prompt.md)(提示词)。
|
|
9
|
+
<!-- agent-surface:subdir end -->
|
package/config/chat.json
CHANGED
|
@@ -1,29 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"identity": {
|
|
3
|
-
"name": "悦享里",
|
|
4
|
-
"tagline": "商圈智能服务"
|
|
5
|
-
},
|
|
6
|
-
"welcome": {
|
|
7
|
-
"title": "今天想逛点什么?",
|
|
8
|
-
"subtitle": "停车、入会、积分、商户、导航、活动和优惠券都能问我"
|
|
9
|
-
},
|
|
10
2
|
"retryOnError": true,
|
|
11
3
|
"quickCommands": [
|
|
12
4
|
{
|
|
13
|
-
"label": "
|
|
14
|
-
"query": "
|
|
5
|
+
"label": "你能做什么",
|
|
6
|
+
"query": "你能做什么?"
|
|
15
7
|
},
|
|
16
8
|
{
|
|
17
|
-
"label": "
|
|
18
|
-
"query": "
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"label": "推荐一家餐厅",
|
|
22
|
-
"query": "推荐一家餐厅"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"label": "今天有什么活动",
|
|
26
|
-
"query": "今天有什么活动"
|
|
9
|
+
"label": "开始对话",
|
|
10
|
+
"query": "开始对话"
|
|
27
11
|
}
|
|
28
|
-
]
|
|
12
|
+
],
|
|
13
|
+
"input": {
|
|
14
|
+
"minRows": 1,
|
|
15
|
+
"maxRows": 4
|
|
16
|
+
}
|
|
29
17
|
}
|
|
Binary file
|
|
Binary file
|
package/docs/agent/._card.md
CHANGED
|
Binary file
|
|
Binary file
|
package/{packages/agent-ui-kit/src/components/ChatHeader/._index.tsx → docs/agent/._errors.md}
RENAMED
|
Binary file
|
package/docs/agent/._kit.md
CHANGED
|
Binary file
|
package/docs/agent/._shell.md
CHANGED
|
Binary file
|
package/docs/agent/._state.md
CHANGED
|
Binary file
|
package/docs/agent/._style.md
CHANGED
|
Binary file
|
|
Binary file
|
package/docs/agent/._tool.md
CHANGED
|
Binary file
|
package/docs/agent/._verify.md
CHANGED
|
Binary file
|