@tbox.cn/app-template-agent 0.10.30 → 1.0.0-alpha.1

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.
Files changed (65) hide show
  1. package/.tbox/app.json +3 -19
  2. package/.tbox/default-modules.json +4 -1
  3. package/.tbox/miniapp-containers.json +1 -1
  4. package/AGENTS.md +52 -148
  5. package/README.md +10 -8
  6. package/apps/AGENTS.md +13 -0
  7. package/apps/client/.tbox-gen/app-kind.ts +1 -0
  8. package/apps/client/.tbox-gen/documents/_tbox/card-preview.html +38 -0
  9. package/apps/client/.tbox-gen/documents/index.html +39 -0
  10. package/apps/client/.tbox-gen/entries/card-preview.tsx +18 -0
  11. package/apps/client/.tbox-gen/entries/index.tsx +18 -0
  12. package/apps/client/.tbox-gen/manifest.json +17 -0
  13. package/apps/client/.tbox-gen/registry.client.ts +6 -0
  14. package/apps/client/.tbox-gen/registry.server.ts +15 -0
  15. package/apps/client/index.html +1 -1
  16. package/apps/client/package.json +3 -2
  17. package/apps/client/src/cards/registry.ts +6 -19
  18. package/apps/client/src/pages/page.tsx +11 -0
  19. package/apps/client/src/platform/AgentChatApp.tsx +2 -10
  20. package/apps/client/src/platform/card-preview-page.tsx +3 -5
  21. package/apps/client/src/platform/mount-page.tsx +9 -14
  22. package/apps/client/vite.config.ts +3 -32
  23. package/apps/server/package.json +1 -1
  24. package/apps/server/src/app.ts +7 -14
  25. package/apps/server/src/cli/collect-registry.ts +7 -11
  26. package/apps/server/src/dev.ts +38 -64
  27. package/apps/server/src/index.ts +27 -45
  28. package/apps/server/src/pre-tools.ts +1 -1
  29. package/apps/server/src/tools/{clock.ts → clock.tool.ts} +1 -1
  30. package/apps/server/src/tools/{translate.ts → translate.tool.ts} +1 -1
  31. package/apps/server/tests/cards-registry.test.ts +1 -1
  32. package/apps/server/tests/helpers/register.ts +10 -0
  33. package/apps/server/tests/tool-runtime.test.ts +2 -2
  34. package/apps/server/tsconfig.json +1 -1
  35. package/apps/server/tsup.config.ts +6 -3
  36. package/{packages → modules}/provider-custom/AGENTS.md +1 -1
  37. package/modules/provider-custom/INTEGRATION.md +10 -0
  38. package/{packages → modules}/provider-custom/package.json +1 -0
  39. package/package.json +11 -6
  40. package/packages/agent-ui-kit/package.json +1 -1
  41. package/packages/shared/AGENTS.md +11 -0
  42. package/packages/shared/package.json +13 -0
  43. package/packages/shared/src/index.ts +8 -0
  44. package/packages/shared/tsconfig.json +7 -0
  45. package/pnpm-lock.template.yaml +183 -155
  46. package/pnpm-workspace.template.yaml +10 -8
  47. package/scripts/generate.mjs +3 -0
  48. package/scripts/verify-generated.mjs +22 -127
  49. package/apps/client/src/app.tsx +0 -11
  50. package/apps/client/src/business/App.tsx +0 -11
  51. package/apps/client/src/business/README.md +0 -99
  52. package/apps/client/src/business/routes.json +0 -3
  53. package/apps/client/src/main.tsx +0 -17
  54. package/apps/client/src/modules.ts +0 -33
  55. package/apps/server/src/app-tools.ts +0 -14
  56. package/apps/server/src/modules.ts +0 -38
  57. /package/{packages → modules}/provider-custom/LICENSE +0 -0
  58. /package/{packages → modules}/provider-custom/README.md +0 -0
  59. /package/{packages → modules}/provider-custom/src/index.ts +0 -0
  60. /package/{packages → modules}/provider-custom/src/server/example-adapter.ts +0 -0
  61. /package/{packages → modules}/provider-custom/src/server/index.ts +0 -0
  62. /package/{packages → modules}/provider-custom/tbox.module.json +0 -0
  63. /package/{packages → modules}/provider-custom/tests/provider-custom.test.ts +0 -0
  64. /package/{packages → modules}/provider-custom/tsconfig.json +0 -0
  65. /package/{packages → modules}/provider-custom/tsup.config.ts +0 -0
@@ -1,142 +1,37 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * verify:generated 守卫(三项内容):
4
- * ① 装配文件与模块声明一致(漂移 = 0,服务端 modules.ts)
5
- * ② 2 装配文件双锚点完整(imports + register 标记齐全)
6
- * ③ 装配文件无裸露 import(全部 import 行在锚区内;import type 豁免)
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, readFileSync } from 'node:fs';
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 ASSEMBLY_FILES = [
19
- { path: 'apps/server/src/modules.ts', markers: ['imports', 'register'] },
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 IMPORT_LINE = /^import\s+.+from\s+['"][^'"]+['"];\s*$/;
24
-
25
- /**
26
- * 锚点行判定:必须为独立注释行(精确匹配),避免文件头注释中出现
27
- * "@tbox:imports-begin" 字样时把锚区状态机提前置 true,导致"无裸露 import"检查失效。
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
- function extractBlock(content, marker) {
62
- const begin = `// @tbox:${marker}-begin`;
63
- const end = `// @tbox:${marker}-end`;
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
- function idFromPkg(pkg) {
72
- return pkg.replace(/^@[^/]+\//, '').replace(/\/(server|client)$/, '');
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
+ }
@@ -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`。不要修改通用首页入口来写死具体行业内容。
@@ -1,3 +0,0 @@
1
- [
2
- { "id": "index", "path": "/" }
3
- ]
@@ -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
- import type { ServerContext } from '@tbox.cn/app-agent-sdk-server';
2
- import { translateTool } from './tools/translate.js';
3
- import { clockTool } from './tools/clock.js';
4
-
5
- /**
6
- * apps 级工具统一注册面(010:双注册面同步):
7
- * start()(运行时)与 cli/collect-registry.ts(doctor/inspect 视图)两处同调本函数,
8
- * 未来新增 apps 级工具只改此处,避免两处注册面失同步(R 评审修正)。
9
- * mall-info(含 preTool/缓存)迁 module-mall-core(模块注册面自持)。
10
- */
11
- export function registerAppTools(ctx: ServerContext): void {
12
- ctx.tools.register(translateTool);
13
- ctx.tools.register(clockTool);
14
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * 服务端模块注册装配文件(与 apps/client/src/modules.ts 逐行同构)。
3
- * tbox CLI 协助维护锚点区;你也可以直接编辑自由区。
4
- *
5
- * 锚点区:@tbox:imports-begin/end(模块 import 行)+ @tbox:register-begin/end(模块数组)
6
- * CLI 行为:增量插入/删除模块行,保留非标行。
7
- */
8
- import type { ServerContext, InferModuleCards } from '@tbox.cn/app-agent-sdk-server';
9
-
10
- // @tbox:imports-begin
11
- // SDK 装配框架(非模块行,CLI 增量维护保留非标行)
12
- import { registerServerModules } from '@tbox.cn/app-agent-sdk-server';
13
- import { serverModule as providerCustom } from '@app/provider-custom/server';
14
- // @tbox:imports-end
15
-
16
- // @tbox:register-begin
17
- // 单一模板统一化:缺省出厂 = 空装配(仅 provider-custom 自定义 API 落点 + contracts-mall shim)——
18
- // mall 能力(mall-core + 业务模块)经 profiles/mall 加装(npx --yes @tbox.cn/app-cli create --profile mall, 接线)
19
- // footer `] as const` 为空数组类型锚(CLI 增删模块时保留变体)
20
- const modules = [
21
- providerCustom,
22
- ] as const;
23
- // @tbox:register-end
24
-
25
- // 自由区:可做装配级定制——条件注册、顺序调整、包裹中间件
26
- // const dynamicModule = process.env.ENABLE_X ? xModule : null;
27
-
28
- /**
29
- * 注册所有已安装模块(服务端装配——勿与 apps/client/src/modules.ts 混淆)。
30
- * 010 下沉:声明式字段自动注册(skills/preTools)与 async register 等待由
31
- * SDK registerServerModules 承载——未来新增声明式字段只改 SDK,本文件零改动。
32
- */
33
- export function registerAll(ctx: ServerContext): Promise<void> {
34
- return registerServerModules(ctx, modules);
35
- }
36
-
37
- // 类型从运行时装配数组自动推导:增删模块后 CardType 自动收缩/扩展(002 §6.7)
38
- export type CardType = InferModuleCards<(typeof modules)[number]>;
File without changes
File without changes