@tbox.cn/app-template-agent 0.10.15 → 0.10.16
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/.tbox/miniapp-containers.json +6 -0
- package/README.md +5 -1
- package/package.json +2 -2
- package/pnpm-lock.template.yaml +39 -0
- package/profiles/mall.json +3 -2
- package/scripts/dev.mjs +91 -0
- package/scripts/dev.sh +1 -1
package/README.md
CHANGED
|
@@ -4,11 +4,15 @@ tbox AI Agent 全栈模板(npm 包名 `@tbox.cn/app-template-agent`,唯一
|
|
|
4
4
|
缺省出厂 = 空装配(chat 形态);**商圈形态经 `profiles/mall` 画像加装**(`tbox-app create --profile mall`:mall-core + 六业务模块 + 商圈配置叠加)。
|
|
5
5
|
客户端同时支持浏览器和支付宝小程序 web-view;平台能力(鉴权/会话/TTS/ASR/上传/反馈)经 `@tbox.cn/app-sdk` 统一提供(007 下沉)。
|
|
6
6
|
|
|
7
|
+
创建应用时默认生成 `apps/miniapp-container-alipay`,容器计划见 `.tbox/miniapp-containers.json`。使用前配置小程序 AppId 和 H5 地址;重复创建保留已登记的容器。
|
|
8
|
+
|
|
9
|
+
`pnpm dev` 始终启动原有 H5/server;容器已安装且 PATH 中有 `minidev` 时同时启动容器,否则跳过。容器异常退出不影响 H5/server,Ctrl+C 统一停止本次启动的进程。
|
|
10
|
+
|
|
7
11
|
## 快速开始
|
|
8
12
|
|
|
9
13
|
```sh
|
|
10
14
|
pnpm install
|
|
11
|
-
pnpm dev #
|
|
15
|
+
pnpm dev # H5/server + 可选 minidev 小程序容器
|
|
12
16
|
pnpm verify # typecheck + test + build
|
|
13
17
|
```
|
|
14
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-template-agent",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.16",
|
|
4
4
|
"description": "tbox AI Agent 全栈模板(多包 pnpm workspace):apps/client + apps/server。唯一模板(W4 单一模板统一化:缺省空装配 chat 形态;mall 能力经 profiles/mall 加装),能力经 tbox-app module add 模块扩展(shopping-guide/member 等)。",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0 <25.0.0"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"dev": "
|
|
47
|
+
"dev": "node scripts/dev.mjs",
|
|
48
48
|
"build": "pnpm check && pnpm --filter ./apps/server build && pnpm --filter ./apps/client build",
|
|
49
49
|
"build:client": "pnpm check && pnpm --filter ./apps/client build",
|
|
50
50
|
"typecheck": "pnpm -r --filter \"./{apps,packages}/*\" typecheck",
|
package/pnpm-lock.template.yaml
CHANGED
|
@@ -27,6 +27,9 @@ catalogs:
|
|
|
27
27
|
'@tbox.cn/app-contracts-mall':
|
|
28
28
|
specifier: 0.13.0
|
|
29
29
|
version: 0.13.0
|
|
30
|
+
'@tbox.cn/app-sdk-client':
|
|
31
|
+
specifier: 0.21.3
|
|
32
|
+
version: 0.21.3
|
|
30
33
|
'@tbox.cn/app-sdk-server':
|
|
31
34
|
specifier: 0.25.0
|
|
32
35
|
version: 0.25.0
|
|
@@ -190,6 +193,24 @@ importers:
|
|
|
190
193
|
specifier: 'catalog:'
|
|
191
194
|
version: 4.1.10(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(happy-dom@20.11.2)(vite@6.4.3(@types/node@24.13.3)(less@4.8.1)(tsx@4.23.11))
|
|
192
195
|
|
|
196
|
+
apps/miniapp-container-alipay:
|
|
197
|
+
devDependencies:
|
|
198
|
+
'@mini-types/alipay':
|
|
199
|
+
specifier: ^3.0.14
|
|
200
|
+
version: 3.0.14
|
|
201
|
+
'@tbox.cn/app-sdk-client':
|
|
202
|
+
specifier: 'catalog:'
|
|
203
|
+
version: 0.21.3
|
|
204
|
+
'@tbox.cn/app-sdk-server':
|
|
205
|
+
specifier: 'catalog:'
|
|
206
|
+
version: 0.25.0
|
|
207
|
+
typescript:
|
|
208
|
+
specifier: 'catalog:'
|
|
209
|
+
version: 5.9.3
|
|
210
|
+
vitest:
|
|
211
|
+
specifier: 'catalog:'
|
|
212
|
+
version: 4.1.10(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(happy-dom@20.11.2)(vite@6.4.3(@types/node@24.13.3)(less@4.8.1)(tsx@4.23.11))
|
|
213
|
+
|
|
193
214
|
apps/server:
|
|
194
215
|
dependencies:
|
|
195
216
|
'@app/contracts-mall':
|
|
@@ -1101,6 +1122,15 @@ packages:
|
|
|
1101
1122
|
peerDependencies:
|
|
1102
1123
|
zod: ^3.25.0 || ^4.0.0
|
|
1103
1124
|
|
|
1125
|
+
'@mini-types/alipay@3.0.14':
|
|
1126
|
+
resolution: {integrity: sha512-FakzSsKvybtWlEIVTIRlr89kuQFn+XY86Ho9VUFFaKLplhW6Wx8FUxTDE7IzV7B9rT8DP/Icy637vUHlXPsw1g==}
|
|
1127
|
+
|
|
1128
|
+
'@mini-types/global@3.0.14':
|
|
1129
|
+
resolution: {integrity: sha512-St2ucFRfKRskposOqV/9iNJTKn1MbyqDypQiy/0DaVJjEm2MFi82RJjX9sBz1uWhQIqzu741PgTjGSy7L/Qj9g==}
|
|
1130
|
+
|
|
1131
|
+
'@mini-types/my@3.0.14':
|
|
1132
|
+
resolution: {integrity: sha512-aEgmM+rbEvEzTvqltCFRAg/h6KKs14M1y+FrOkz+hn2EyNpOVPesUzTjbRhSiFFsE3WdfBh54lHNYBahAmHq7w==}
|
|
1133
|
+
|
|
1104
1134
|
'@modelcontextprotocol/core@2.0.0':
|
|
1105
1135
|
resolution: {integrity: sha512-pJCEwGG7Lfr/+PQp9ZTwKXNeO5wzbfKL7H3MYpCorM4oFBoQrdjnBgEoqG+RjhsvS1FKrDbKux+M1HhlnGWqcA==}
|
|
1106
1136
|
engines: {node: '>=20'}
|
|
@@ -3907,6 +3937,15 @@ snapshots:
|
|
|
3907
3937
|
zod: 3.25.76
|
|
3908
3938
|
zod-from-json-schema: 0.5.6
|
|
3909
3939
|
|
|
3940
|
+
'@mini-types/alipay@3.0.14':
|
|
3941
|
+
dependencies:
|
|
3942
|
+
'@mini-types/global': 3.0.14
|
|
3943
|
+
'@mini-types/my': 3.0.14
|
|
3944
|
+
|
|
3945
|
+
'@mini-types/global@3.0.14': {}
|
|
3946
|
+
|
|
3947
|
+
'@mini-types/my@3.0.14': {}
|
|
3948
|
+
|
|
3910
3949
|
'@modelcontextprotocol/core@2.0.0':
|
|
3911
3950
|
dependencies:
|
|
3912
3951
|
zod: 4.4.3
|
package/profiles/mall.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$comment": "mall 画像(单一模板统一化 W4):create --profile mall 执行器(W5 接线)按 modules 序列加装 + configOverlay 叠加(--config-dir 通道)+ rootFiles 根文件落地(TEMPLATE.md 使用指南 → 应用根)。provider 轴独立(缺省 mock-only 演示态;vendor 档由部署者后续 add)。",
|
|
3
3
|
"name": "mall",
|
|
4
|
-
"description": "商圈 AI Agent:家页形态(home 槽)+ 域装配 +
|
|
4
|
+
"description": "商圈 AI Agent:家页形态(home 槽)+ 域装配 + 七业务域(导购/会员/停车/营销/活动/客服/AI 支付)",
|
|
5
5
|
"modules": [
|
|
6
6
|
"@tbox.cn/app-module-mall-core",
|
|
7
7
|
"@tbox.cn/app-module-shopping-guide",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"@tbox.cn/app-module-parking",
|
|
10
10
|
"@tbox.cn/app-module-promotion",
|
|
11
11
|
"@tbox.cn/app-module-alipay-activity",
|
|
12
|
-
"@tbox.cn/app-module-customer-service"
|
|
12
|
+
"@tbox.cn/app-module-customer-service",
|
|
13
|
+
"@tbox.cn/app-module-ai-payment"
|
|
13
14
|
],
|
|
14
15
|
"configOverlay": "profiles/mall/config",
|
|
15
16
|
"rootFiles": ["TEMPLATE.md"]
|
package/scripts/dev.mjs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { accessSync, constants, existsSync, statSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
export function hasCommand(command, env = process.env) {
|
|
7
|
+
const extensions = process.platform === 'win32' ? (env.PATHEXT ?? '.EXE;.CMD;.BAT').split(';') : [''];
|
|
8
|
+
return (env.PATH ?? '').split(path.delimiter).some(dir => extensions.some(extension => {
|
|
9
|
+
try {
|
|
10
|
+
const executable = path.join(dir || '.', command + extension);
|
|
11
|
+
accessSync(executable, constants.X_OK);
|
|
12
|
+
return statSync(executable).isFile();
|
|
13
|
+
}
|
|
14
|
+
catch { return false; }
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function stopChild(child, signal) {
|
|
19
|
+
if (!child?.pid) return;
|
|
20
|
+
try {
|
|
21
|
+
if (process.platform === 'win32') child.kill(signal);
|
|
22
|
+
else process.kill(-child.pid, signal);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error.code !== 'ESRCH') throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** H5/server 为主进程;可选容器失败不终止主进程。 */
|
|
29
|
+
export function startDev({
|
|
30
|
+
projectDir,
|
|
31
|
+
spawnProcess = spawn,
|
|
32
|
+
commandExists = hasCommand,
|
|
33
|
+
stopProcess = stopChild,
|
|
34
|
+
signals = process,
|
|
35
|
+
log = console,
|
|
36
|
+
finish = code => { process.exitCode = code; },
|
|
37
|
+
}) {
|
|
38
|
+
const options = { cwd: projectDir, detached: process.platform !== 'win32', shell: process.platform === 'win32' };
|
|
39
|
+
const containerInstalled = existsSync(path.join(projectDir, 'apps/miniapp-container-alipay/package.json'));
|
|
40
|
+
const containerEnabled = containerInstalled && commandExists('minidev');
|
|
41
|
+
const server = spawnProcess('pnpm', ['--filter', './apps/server', 'dev'], {
|
|
42
|
+
...options, stdio: containerEnabled ? ['ignore', 'inherit', 'inherit'] : 'inherit',
|
|
43
|
+
});
|
|
44
|
+
let container;
|
|
45
|
+
let stopping = false;
|
|
46
|
+
let requestedCode;
|
|
47
|
+
let completed = false;
|
|
48
|
+
const stop = code => {
|
|
49
|
+
if (stopping) return;
|
|
50
|
+
stopping = true;
|
|
51
|
+
requestedCode = code;
|
|
52
|
+
stopProcess(server, 'SIGTERM');
|
|
53
|
+
stopProcess(container, 'SIGTERM');
|
|
54
|
+
setTimeout(() => {
|
|
55
|
+
stopProcess(server, 'SIGKILL');
|
|
56
|
+
stopProcess(container, 'SIGKILL');
|
|
57
|
+
}, 2000);
|
|
58
|
+
};
|
|
59
|
+
const interrupt = () => stop(130);
|
|
60
|
+
const terminate = () => stop(143);
|
|
61
|
+
signals.on('SIGINT', interrupt);
|
|
62
|
+
signals.on('SIGTERM', terminate);
|
|
63
|
+
const complete = code => {
|
|
64
|
+
if (completed) return;
|
|
65
|
+
completed = true;
|
|
66
|
+
stop(code);
|
|
67
|
+
signals.removeListener('SIGINT', interrupt);
|
|
68
|
+
signals.removeListener('SIGTERM', terminate);
|
|
69
|
+
finish(requestedCode ?? code);
|
|
70
|
+
};
|
|
71
|
+
server.once('error', error => { log.error(`H5/server 启动失败:${error.message}`); complete(1); });
|
|
72
|
+
server.once('exit', (code, signal) => complete(code ?? (signal ? 1 : 0)));
|
|
73
|
+
|
|
74
|
+
if (!containerInstalled) {
|
|
75
|
+
log.info('未安装支付宝小程序容器,仅启动 H5/server。');
|
|
76
|
+
} else if (!containerEnabled) {
|
|
77
|
+
log.info('未找到 minidev,跳过小程序容器,H5/server 正常启动。');
|
|
78
|
+
} else {
|
|
79
|
+
log.info('同时启动支付宝小程序容器(minidev)。');
|
|
80
|
+
container = spawnProcess('pnpm', ['--filter', '@app/miniapp-container-alipay', 'dev'], { ...options, stdio: 'inherit' });
|
|
81
|
+
container.once('error', error => log.warn(`小程序容器启动失败,H5/server 继续运行:${error.message}`));
|
|
82
|
+
container.once('exit', code => {
|
|
83
|
+
if (!stopping) log.info(`小程序容器已退出(${code ?? 'signal'}),H5/server 继续运行。`);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return { server, get container() { return container; }, stop };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
90
|
+
startDev({ projectDir: path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..') });
|
|
91
|
+
}
|
package/scripts/dev.sh
CHANGED