@tbox.cn/app-template-agent 1.0.0-alpha.18 → 1.0.0-alpha.19

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.
@@ -1,6 +1,6 @@
1
1
  [
2
2
  {
3
3
  "package": "@tbox.cn/app-module-ai-payment",
4
- "version": "1.0.0-alpha.18"
4
+ "version": "1.0.0-alpha.19"
5
5
  }
6
6
  ]
@@ -1,6 +1,6 @@
1
1
  [
2
2
  {
3
3
  "platform": "alipay",
4
- "source": "@tbox.cn/app-miniapp-container-alipay@1.0.0-alpha.18"
4
+ "source": "@tbox.cn/app-miniapp-container-alipay@1.0.0-alpha.19"
5
5
  }
6
6
  ]
package/AGENTS.md CHANGED
@@ -78,6 +78,10 @@ export type OrderStatusCardData = z.infer<typeof orderStatusCardSchema>;
78
78
 
79
79
  服务端卡片 meta 从 `@app/shared/cards/<id>` 引用同一份 schema;客户端只 `import type`(eslint 拦截值导入,zod 不进客户端产物)。样例由 `sampleState` / `samples` 派生(三件套写在声明里)——`card render` 与场景断言读派生结果。不 import React、Node、`apps/*`、`modules/*`、数据库或网络;不要创建 `apps/shared/`。
80
80
 
81
+ ## 图标
82
+
83
+ phosphor 已预装(`apps/client` 直接依赖,与壳/模块同一版本),按单个导入:`import { BellIcon } from '@phosphor-icons/react/Bell'`(路径是图标名,导出名带 `Icon` 后缀),类型从 `'@phosphor-icons/react/lib'` 导入。不要从包根 `'@phosphor-icons/react'` 导入(值导入与类型导入都不行)——会把全部 1512 个图标拉进构建与类型检查,lint 会报错。尺寸写 `className="size-4 shrink-0"`,颜色随文字色(不传 `color` 属性),纯装饰图标加 `aria-hidden`;常见误名对照见 `docs/agent/kit.md` 图标节。
84
+
81
85
  ## 模块
82
86
 
83
87
  模块是双端单包,必须用 `satisfies`:
@@ -12,6 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@app/shared": "file:../../packages/shared",
15
+ "@phosphor-icons/react": "catalog:",
15
16
  "@tbox.cn/app-contracts": "catalog:",
16
17
  "@tbox.cn/app-theme-tbox": "catalog:",
17
18
  "react": "catalog:",
@@ -6,7 +6,7 @@ import { createServer } from 'node:http';
6
6
  import path from 'node:path';
7
7
  import { existsSync } from 'node:fs';
8
8
  import { fileURLToPath } from 'node:url';
9
- import { build as viteBuild, createServer as createViteServer, searchForWorkspaceRoot } from 'vite';
9
+ import { createServer as createViteServer, searchForWorkspaceRoot } from 'vite';
10
10
  import {
11
11
  createTboxDevRuntime,
12
12
  injectScript,
@@ -14,7 +14,7 @@ import {
14
14
  resolveDevTokenFromEnv,
15
15
  } from '@tbox.cn/app-agent-sdk-server/platform';
16
16
  import { createApp, createLogger, getRequestContext } from '@tbox.cn/app-agent-sdk-server';
17
- import { generateApp } from '@tbox.cn/app-build';
17
+ import { generateApp, startStaticBuild } from '@tbox.cn/app-build';
18
18
  import { app as legacyApp, ctx, registerUpgradeDelegate, setupTboxDev, start } from './app.js';
19
19
 
20
20
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -93,19 +93,6 @@ legacyApp.get('/__tbox_dev_freezone_probe', (_req, res) => {
93
93
  legacyApp.use(runtime.final);
94
94
  registerUpgradeDelegate(runtime.handleUpgrade);
95
95
 
96
- if (protectedMode) {
97
- viteBuild({ root: clientRoot, build: { watch: {}, sourcemap: false } })
98
- .then((result) => {
99
- const watcher = Array.isArray(result) ? result[0] : result;
100
- if (!watcher || !('on' in watcher)) return;
101
- watcher.on('event', (e) => {
102
- if (e.code === 'BUNDLE_START') runtime.notifyBuildStart();
103
- if (e.code === 'BUNDLE_END') runtime.notifyBuildEnd();
104
- });
105
- })
106
- .catch((err) => serverLogger.error('[dev] watch build failed:', err));
107
- }
108
-
109
96
  const app = await createApp({
110
97
  ctx,
111
98
  manifest: generated.manifest,
@@ -120,7 +107,26 @@ const app = await createApp({
120
107
  },
121
108
  });
122
109
 
123
- start(app).catch((err) => {
124
- serverLogger.error('Failed to start:', err);
125
- process.exit(1);
126
- });
110
+ start(app)
111
+ .then(() => {
112
+ if (!protectedMode) return;
113
+ // 静态面 watch 构建走 app-build 子进程编排(production 构建 + 暂存原子切换 dist):
114
+ // dev 进程主线程不再被构建阻塞,构建失败经 notifyBuildError 复位且 dist 保持上次产物。
115
+ // 监听先于 fork,让 dev 面与沙箱就绪探测优先;装配异常只上报,不退出 dev。
116
+ try {
117
+ startStaticBuild({
118
+ clientRoot,
119
+ logger: serverLogger,
120
+ onBuildStart: () => runtime.notifyBuildStart(),
121
+ onBuildEnd: () => runtime.notifyBuildEnd(),
122
+ onBuildError: (info) => runtime.notifyBuildError(info),
123
+ });
124
+ } catch (err) {
125
+ serverLogger.error('[dev] static build assembly failed:', err);
126
+ runtime.notifyBuildError({ reason: 'worker-exit', message: err instanceof Error ? err.message : String(err) });
127
+ }
128
+ })
129
+ .catch((err) => {
130
+ serverLogger.error('Failed to start:', err);
131
+ process.exit(1);
132
+ });
package/docs/agent/kit.md CHANGED
@@ -40,9 +40,28 @@ import { Card, CardHeader, KeyValueList, StatusTag } from '@tbox.cn/app-agent-ui
40
40
 
41
41
  ## 图标
42
42
 
43
- 从 `@tbox.cn/app-agent-ui-kit/icons` 具名导入;需要新图标时先看这里有没有,没有再评估是否值得扩;不要在应用里直接依赖 `@phosphor-icons/react`。
43
+ phosphor 已预装,按单个导入:`import { GearIcon } from '@phosphor-icons/react/Gear'`(路径是图标名,导出名带 `Icon` 后缀),类型从 `'@phosphor-icons/react/lib'` 导入。
44
+ 不要从包根 `'@phosphor-icons/react'` 导入(值导入与类型导入都不行)——会把全部 1512 个图标拉进构建与类型检查,lint 会报错。
45
+ 尺寸用类名控制(`className="size-4 shrink-0"`),颜色随文字色(不传 `color` 属性),纯装饰图标加 `aria-hidden`。
44
46
 
45
- 共 31 个:`ArrowRight`、`ArrowsClockwise`、`Calendar`、`CaretDown`、`CaretRight`、`Check`、`CheckCircle`、`Clock`、`Coins`、`Copy`、`CreditCard`、`CurrencyCny`、`Gift`、`Info`、`MapPin`、`MapTrifold`、`Plus`、`QrCode`、`Receipt`、`SealCheck`、`ShareNetwork`、`Sparkle`、`Star`、`Storefront`、`Ticket`、`Trash`、`User`、`UserCircle`、`Warning`、`WarningCircle`、`X`。
47
+ 常用清单(`@tbox.cn/app-agent-ui-kit` 兼容入口,共 31 个):`ArrowRight`、`ArrowsClockwise`、`Calendar`、`CaretDown`、`CaretRight`、`Check`、`CheckCircle`、`Clock`、`Coins`、`Copy`、`CreditCard`、`CurrencyCny`、`Gift`、`Info`、`MapPin`、`MapTrifold`、`Plus`、`QrCode`、`Receipt`、`SealCheck`、`ShareNetwork`、`Sparkle`、`Star`、`Storefront`、`Ticket`、`Trash`、`User`、`UserCircle`、`Warning`、`WarningCircle`、`X`。
48
+
49
+ 常见误名对照(目标名已验证存在):
50
+
51
+ | 写法 | phosphor 组件 |
52
+ |---|---|
53
+ | `Settings` | `GearIcon` |
54
+ | `Home` | `HouseIcon` |
55
+ | `Search` | `MagnifyingGlassIcon` |
56
+ | `Menu` | `ListIcon` |
57
+ | `Edit` | `PencilSimpleIcon` |
58
+ | `Close` | `XIcon` |
59
+ | `Cart` | `ShoppingCartIcon` |
60
+ | `Filter` | `FunnelIcon` |
61
+ | `Send` | `PaperPlaneRightIcon` |
62
+ | `Mail` | `EnvelopeIcon` |
63
+ | `Refresh` | `ArrowClockwiseIcon` |
64
+ | `Loading` | `CircleNotchIcon` |
46
65
 
47
66
  ## 主题变量
48
67
 
@@ -133,7 +133,7 @@ html[data-theme='tbox'] {
133
133
 
134
134
  ## 卡片排版
135
135
 
136
- - flex 里的图标/图片加 `shrink-0` 与显式尺寸,否则被长文本压扁:`<Icon className="shrink-0" size={18} />`。
136
+ - flex 里的图标/图片加 `shrink-0` 与显式尺寸,否则被长文本压扁:图标写 `<GearIcon className="size-4 shrink-0" />`(phosphor 按 `docs/agent/kit.md` 的方式导入),图片写 `max-w-full`。
137
137
  - 可滚动容器隐藏滚动条:`[scrollbar-width:none] [&::-webkit-scrollbar]:hidden`。
138
138
  - 卡片宽度由容器决定,不要写死宽度。
139
139
  - 文字截断用 `truncate`(单行)或 `line-clamp-2`(两行),不要手写 `-webkit-box`。
package/eslint.config.mjs CHANGED
@@ -19,6 +19,16 @@ export default [
19
19
  },
20
20
  rules: {
21
21
  "quotes": ["error", "single", { "avoidEscape": true }],
22
+ "no-restricted-imports": [
23
+ "error",
24
+ {
25
+ paths: ["@phosphor-icons/react", "@phosphor-icons/react/ssr", "@phosphor-icons/react/dist/ssr"].map((name) => ({
26
+ name,
27
+ message:
28
+ "图标按单个导入:import { BellIcon } from '@phosphor-icons/react/Bell'(名字带 Icon 后缀);类型从 '@phosphor-icons/react/lib' 导入。包根导入会把全部 1512 个图标拉进构建与类型检查。",
29
+ })),
30
+ },
31
+ ],
22
32
  "no-restricted-syntax": [
23
33
  "error",
24
34
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-template-agent",
3
- "version": "1.0.0-alpha.18",
3
+ "version": "1.0.0-alpha.19",
4
4
  "description": "tbox AI Agent 全栈模板(多包 pnpm workspace):apps/client + apps/server。唯一模板(W4 单一模板统一化:缺省带 AI 支付体验的 chat 形态;mall 能力经 profiles/mall 加装),能力经 CLI module add 模块扩展(shopping-guide/member 等)。",
5
5
  "engines": {
6
6
  "node": ">=24.0.0 <25.0.0",
@@ -49,9 +49,9 @@
49
49
  "typescript-eslint": "8.67.0",
50
50
  "eslint-plugin-react-hooks": "5.2.0",
51
51
  "vite": "6.4.3",
52
- "@tbox.cn/app-sdk-server": "1.0.0-alpha.18",
53
- "@tbox.cn/app-build": "1.0.0-alpha.18",
54
- "@tbox.cn/app-cli": "1.0.0-alpha.18"
52
+ "@tbox.cn/app-sdk-server": "1.0.0-alpha.19",
53
+ "@tbox.cn/app-build": "1.0.0-alpha.19",
54
+ "@tbox.cn/app-cli": "1.0.0-alpha.19"
55
55
  },
56
56
  "license": "MIT",
57
57
  "publishConfig": {
@@ -824,6 +824,20 @@
824
824
  "WarningCircle",
825
825
  "X"
826
826
  ],
827
+ "iconAliases": {
828
+ "Settings": "Gear",
829
+ "Home": "House",
830
+ "Search": "MagnifyingGlass",
831
+ "Menu": "List",
832
+ "Edit": "PencilSimple",
833
+ "Close": "X",
834
+ "Cart": "ShoppingCart",
835
+ "Filter": "Funnel",
836
+ "Send": "PaperPlaneRight",
837
+ "Mail": "Envelope",
838
+ "Refresh": "ArrowClockwise",
839
+ "Loading": "CircleNotch"
840
+ },
827
841
  "tokens": {
828
842
  "platform": [
829
843
  "--tbox-accent",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-agent-ui-kit",
3
- "version": "1.0.0-alpha.18",
3
+ "version": "1.0.0-alpha.19",
4
4
  "type": "module",
5
5
  "description": "Agent 对话壳 UI 组件包(源码发布,单一模板统一化 W2-1):ChatPage/壳组件族/主题 tokens。",
6
6
  "exports": {
@@ -2,7 +2,7 @@ import { createLogger } from '@tbox.cn/app-agent-sdk-client';
2
2
 
3
3
  const debugLogger = createLogger('DebugButton');
4
4
 
5
- import { Bug } from '@phosphor-icons/react';
5
+ import { BugIcon as Bug } from '@phosphor-icons/react/Bug';
6
6
 
7
7
  /**
8
8
  * 调试按钮:点击把本轮 requestId / conversationId / messageId / messageCreatedAt
@@ -2,7 +2,10 @@ import { useEffect, useState, useSyncExternalStore } from 'react';
2
2
  import { createLogger } from '@tbox.cn/app-agent-sdk-client';
3
3
 
4
4
  const ttsActionLogger = createLogger('tts');
5
- import { Copy, SpeakerHigh, ThumbsDown, ThumbsUp } from '@phosphor-icons/react';
5
+ import { CopyIcon as Copy } from '@phosphor-icons/react/Copy';
6
+ import { SpeakerHighIcon as SpeakerHigh } from '@phosphor-icons/react/SpeakerHigh';
7
+ import { ThumbsDownIcon as ThumbsDown } from '@phosphor-icons/react/ThumbsDown';
8
+ import { ThumbsUpIcon as ThumbsUp } from '@phosphor-icons/react/ThumbsUp';
6
9
  import { useChatStore } from '../../store-context';
7
10
  import { useChatConfigStore } from '../../chat-config';
8
11
  import { useFeedbackAdapter, useRefreshSession, useTTSAdapter } from '@tbox.cn/app-agent-sdk-client';
@@ -1,5 +1,9 @@
1
1
  import { useCallback, useEffect, useState } from 'react';
2
- import { X, Warning, Prohibit, Plus, VideoCamera } from '@phosphor-icons/react';
2
+ import { XIcon as X } from '@phosphor-icons/react/X';
3
+ import { WarningIcon as Warning } from '@phosphor-icons/react/Warning';
4
+ import { ProhibitIcon as Prohibit } from '@phosphor-icons/react/Prohibit';
5
+ import { PlusIcon as Plus } from '@phosphor-icons/react/Plus';
6
+ import { VideoCameraIcon as VideoCamera } from '@phosphor-icons/react/VideoCamera';
3
7
  import { previewImages } from '../../utils/imagePreview';
4
8
  import { toast } from '../../utils/toast';
5
9
  import type { MediaItem } from '../../types';
@@ -1,7 +1,7 @@
1
1
  import { useMemo } from 'react';
2
2
  import ReactMarkdown from 'react-markdown';
3
3
  import remarkGfm from 'remark-gfm';
4
- import { Copy } from '@phosphor-icons/react';
4
+ import { CopyIcon as Copy } from '@phosphor-icons/react/Copy';
5
5
  import { previewImages } from '../../utils/imagePreview';
6
6
  import type { ChatMessage } from '../../types';
7
7
  import ReasoningBlock from '../../components/ReasoningBlock';
@@ -1,5 +1,8 @@
1
1
  import { useId, useMemo, useState } from 'react';
2
- import { CaretDown, Check, Copy, X } from '@phosphor-icons/react';
2
+ import { CaretDownIcon as CaretDown } from '@phosphor-icons/react/CaretDown';
3
+ import { CheckIcon as Check } from '@phosphor-icons/react/Check';
4
+ import { CopyIcon as Copy } from '@phosphor-icons/react/Copy';
5
+ import { XIcon as X } from '@phosphor-icons/react/X';
3
6
  import type { ToolCallInfo } from '../../types';
4
7
  import { formatCompactToolIo } from '../../utils/tool-call-display';
5
8
  import { buildSummaryText, deriveSummary, deriveToolCallItem, prettyDetailText } from './detail';
@@ -1,39 +1,38 @@
1
1
  /**
2
- * 图标入口:应用侧不再直接依赖 `@phosphor-icons/react`。
2
+ * 图标兼容入口:卡片与空态常用的一组,含义稳定、体积可控。
3
3
  *
4
- * 只再导出卡片与空态常用的一组,含义稳定、体积可控;需要新图标时在此增补,
5
- * 应用侧 `import { IconName } from '@tbox.cn/app-agent-ui-kit/icons'`。
4
+ * 主路径是按单个导入 `import { BellIcon } from '@phosphor-icons/react/Bell'`(名字带
5
+ * `Icon` 后缀;从包根导入会把全部 1512 个图标拉进构建与类型检查,lint 报错)。
6
+ * 本入口只作兼容消费面,新代码优先用主路径;清单见 docs/agent/kit.md 图标节。
6
7
  */
7
- export {
8
- ArrowRight,
9
- ArrowsClockwise,
10
- Calendar,
11
- CaretDown,
12
- CaretRight,
13
- Check,
14
- CheckCircle,
15
- Clock,
16
- Coins,
17
- Copy,
18
- CreditCard,
19
- CurrencyCny,
20
- Gift,
21
- Info,
22
- MapPin,
23
- MapTrifold,
24
- Plus,
25
- QrCode,
26
- Receipt,
27
- SealCheck,
28
- ShareNetwork,
29
- Sparkle,
30
- Star,
31
- Storefront,
32
- Ticket,
33
- Trash,
34
- User,
35
- UserCircle,
36
- Warning,
37
- WarningCircle,
38
- X,
39
- } from '@phosphor-icons/react';
8
+ export { ArrowRightIcon as ArrowRight } from '@phosphor-icons/react/ArrowRight';
9
+ export { ArrowsClockwiseIcon as ArrowsClockwise } from '@phosphor-icons/react/ArrowsClockwise';
10
+ export { CalendarIcon as Calendar } from '@phosphor-icons/react/Calendar';
11
+ export { CaretDownIcon as CaretDown } from '@phosphor-icons/react/CaretDown';
12
+ export { CaretRightIcon as CaretRight } from '@phosphor-icons/react/CaretRight';
13
+ export { CheckIcon as Check } from '@phosphor-icons/react/Check';
14
+ export { CheckCircleIcon as CheckCircle } from '@phosphor-icons/react/CheckCircle';
15
+ export { ClockIcon as Clock } from '@phosphor-icons/react/Clock';
16
+ export { CoinsIcon as Coins } from '@phosphor-icons/react/Coins';
17
+ export { CopyIcon as Copy } from '@phosphor-icons/react/Copy';
18
+ export { CreditCardIcon as CreditCard } from '@phosphor-icons/react/CreditCard';
19
+ export { CurrencyCnyIcon as CurrencyCny } from '@phosphor-icons/react/CurrencyCny';
20
+ export { GiftIcon as Gift } from '@phosphor-icons/react/Gift';
21
+ export { InfoIcon as Info } from '@phosphor-icons/react/Info';
22
+ export { MapPinIcon as MapPin } from '@phosphor-icons/react/MapPin';
23
+ export { MapTrifoldIcon as MapTrifold } from '@phosphor-icons/react/MapTrifold';
24
+ export { PlusIcon as Plus } from '@phosphor-icons/react/Plus';
25
+ export { QrCodeIcon as QrCode } from '@phosphor-icons/react/QrCode';
26
+ export { ReceiptIcon as Receipt } from '@phosphor-icons/react/Receipt';
27
+ export { SealCheckIcon as SealCheck } from '@phosphor-icons/react/SealCheck';
28
+ export { ShareNetworkIcon as ShareNetwork } from '@phosphor-icons/react/ShareNetwork';
29
+ export { SparkleIcon as Sparkle } from '@phosphor-icons/react/Sparkle';
30
+ export { StarIcon as Star } from '@phosphor-icons/react/Star';
31
+ export { StorefrontIcon as Storefront } from '@phosphor-icons/react/Storefront';
32
+ export { TicketIcon as Ticket } from '@phosphor-icons/react/Ticket';
33
+ export { TrashIcon as Trash } from '@phosphor-icons/react/Trash';
34
+ export { UserIcon as User } from '@phosphor-icons/react/User';
35
+ export { UserCircleIcon as UserCircle } from '@phosphor-icons/react/UserCircle';
36
+ export { WarningIcon as Warning } from '@phosphor-icons/react/Warning';
37
+ export { WarningCircleIcon as WarningCircle } from '@phosphor-icons/react/WarningCircle';
38
+ export { XIcon as X } from '@phosphor-icons/react/X';