@oxmumu3/dsh-agent-twin 0.6.1 → 0.6.2
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/README.md +8 -3
- package/client.js +344 -0
- package/lib/guest-server.js +565 -194
- package/lib/host.js +9 -0
- package/lib/mtn-provider.js +1 -0
- package/lib/routes.js +7 -0
- package/lib/scanner.js +48 -6
- package/lib/service.js +25 -2
- package/lib/store.js +150 -16
- package/lib/twin-engine.js +835 -466
- package/package.json +3 -3
- package/shared/schema.js +63 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxmumu3/dsh-agent-twin",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "DSH AI 分身工作台(满血隔离 DSH Agent + 0.2.3
|
|
3
|
+
"version": "0.6.2",
|
|
4
|
+
"description": "DSH AI 分身工作台(满血隔离 DSH Agent + 公开扫码真体验大厅 /try + 0.2.3 官方飞书/企微与真个人微信 iLink + 对话流与手机拍板 + MTN 图谱)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "牛村木木山 <157776623+oxmumu3@users.noreply.github.com>",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "node scripts/build-client.mjs",
|
|
47
47
|
"check:client": "node scripts/check-client.cjs",
|
|
48
|
-
"test": "node --test test/scanner.test.mjs test/twin-engine.test.mjs test/channels-and-guest.test.mjs test/routes-and-store.test.mjs test/legacy-compat.test.mjs test/v6-connectors-and-fullblood.test.mjs test/v61-p0-p2-features.test.mjs"
|
|
48
|
+
"test": "node --test test/scanner.test.mjs test/twin-engine.test.mjs test/channels-and-guest.test.mjs test/routes-and-store.test.mjs test/legacy-compat.test.mjs test/v6-connectors-and-fullblood.test.mjs test/v61-p0-p2-features.test.mjs test/v62-public-lobby.test.mjs"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"qrcode": "^1.5.4"
|
package/shared/schema.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
export const PLUGIN_ID = '@oxmumu3/dsh-agent-twin';
|
|
7
7
|
export const DEFAULT_DAILY_TURN_CAP = 30;
|
|
8
|
+
export const DEFAULT_PUBLIC_VISITOR_DAILY_LIMIT = 5;
|
|
9
|
+
export const DEFAULT_PUBLIC_GLOBAL_DAILY_LIMIT = 200;
|
|
8
10
|
export const PRESENCE_YIELD_MS = 15 * 60 * 1000;
|
|
9
11
|
export const WECHAT_QR_TTL_MS = 5 * 60 * 1000;
|
|
10
12
|
|
|
@@ -115,6 +117,66 @@ export function createDefaultRules() {
|
|
|
115
117
|
];
|
|
116
118
|
}
|
|
117
119
|
|
|
120
|
+
export function createDefaultPublicLobby() {
|
|
121
|
+
return {
|
|
122
|
+
enabled: false,
|
|
123
|
+
publicBaseUrl: '',
|
|
124
|
+
title: '',
|
|
125
|
+
intro: '',
|
|
126
|
+
mode: 'summary',
|
|
127
|
+
visitorDailyLimit: DEFAULT_PUBLIC_VISITOR_DAILY_LIMIT,
|
|
128
|
+
globalDailyLimit: DEFAULT_PUBLIC_GLOBAL_DAILY_LIMIT,
|
|
129
|
+
pushOwner: false,
|
|
130
|
+
capIds: [],
|
|
131
|
+
starterPrompts: []
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function normalizePublicBaseUrl(rawUrl) {
|
|
136
|
+
const s = typeof rawUrl === 'string' ? rawUrl.trim() : '';
|
|
137
|
+
if (!s) return '';
|
|
138
|
+
let parsed;
|
|
139
|
+
try {
|
|
140
|
+
parsed = new URL(s);
|
|
141
|
+
} catch {
|
|
142
|
+
throw new Error('公开访问基址 URL 格式无效,请填写如 https://twin.finvo.ai 的完整地址');
|
|
143
|
+
}
|
|
144
|
+
const isLoopback = ['127.0.0.1', 'localhost', '[::1]'].includes(parsed.hostname);
|
|
145
|
+
if (parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && isLoopback)) {
|
|
146
|
+
throw new Error('公开访问基址仅支持 https:// 公网隧道域名或本机回环地址');
|
|
147
|
+
}
|
|
148
|
+
return parsed.origin;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function normalizePublicLobbyConfig(raw = {}, prev = null) {
|
|
152
|
+
const base = createDefaultPublicLobby();
|
|
153
|
+
const src = { ...base, ...(prev && typeof prev === 'object' ? prev : {}), ...(raw && typeof raw === 'object' ? raw : {}) };
|
|
154
|
+
let safeUrl = '';
|
|
155
|
+
if (typeof src.publicBaseUrl === 'string' && src.publicBaseUrl.trim()) {
|
|
156
|
+
try {
|
|
157
|
+
safeUrl = normalizePublicBaseUrl(src.publicBaseUrl);
|
|
158
|
+
} catch {
|
|
159
|
+
safeUrl = typeof prev?.publicBaseUrl === 'string' ? prev.publicBaseUrl : '';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const vLimit = Number(src.visitorDailyLimit);
|
|
163
|
+
const gLimit = Number(src.globalDailyLimit);
|
|
164
|
+
return {
|
|
165
|
+
enabled: Boolean(src.enabled),
|
|
166
|
+
publicBaseUrl: safeUrl,
|
|
167
|
+
title: sanitizeSurfaceText(String(src.title || '').trim()).slice(0, 48),
|
|
168
|
+
intro: sanitizeSurfaceText(String(src.intro || '').trim()).slice(0, 180),
|
|
169
|
+
mode: src.mode === 'direct' ? 'direct' : 'summary',
|
|
170
|
+
visitorDailyLimit: Number.isFinite(vLimit) && vLimit >= 1 ? Math.min(100, Math.round(vLimit)) : DEFAULT_PUBLIC_VISITOR_DAILY_LIMIT,
|
|
171
|
+
globalDailyLimit: Number.isFinite(gLimit) && gLimit >= 1 ? Math.min(5000, Math.round(gLimit)) : DEFAULT_PUBLIC_GLOBAL_DAILY_LIMIT,
|
|
172
|
+
pushOwner: Boolean(src.pushOwner),
|
|
173
|
+
capIds: Array.isArray(src.capIds) ? [...new Set(src.capIds.map(x => String(x || '').trim()).filter(Boolean))] : [],
|
|
174
|
+
starterPrompts: Array.isArray(src.starterPrompts)
|
|
175
|
+
? src.starterPrompts.map(q => sanitizeSurfaceText(String(q || '').trim())).filter(Boolean).slice(0, 4)
|
|
176
|
+
: []
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
118
180
|
export const CHANNEL_GUIDE_MAP = Object.freeze({
|
|
119
181
|
'ch-feishu': {
|
|
120
182
|
title: '接入飞书 / Lark 机器人(本机直连)',
|
|
@@ -190,6 +252,7 @@ export function channelSelectionLabel(channelId) {
|
|
|
190
252
|
case 'ch-feishu': return '飞书';
|
|
191
253
|
case 'ch-wecom': return '企业微信';
|
|
192
254
|
case 'ch-slack': return '合作方 Slack';
|
|
255
|
+
case 'ch-public-try': return '公开扫码体验';
|
|
193
256
|
default: return '免装试用网页';
|
|
194
257
|
}
|
|
195
258
|
}
|