@oxmumu3/dsh-agent-twin 0.6.2 → 0.6.3
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 +6 -6
- package/client.js +1 -1
- package/examples/growth-bi-desk/README.md +2 -2
- package/examples/growth-bi-desk/{mtn/growth-ska-graph.json → graph/growth-semantic-graph.json} +1 -1
- package/lib/{mtn-provider.js → graph-provider.js} +11 -11
- package/lib/host.js +9 -9
- package/lib/routes.js +8 -8
- package/lib/service.js +7 -7
- package/lib/twin-engine.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# AI 分身工作台 · `@oxmumu3/dsh-agent-twin` (v0.6.
|
|
1
|
+
# AI 分身工作台 · `@oxmumu3/dsh-agent-twin` (v0.6.3)
|
|
2
2
|
|
|
3
|
-
在 DeepSeek Harness (`0.2.2-rc.5` / `0.2.3-alpha.2`) 内把你的本地专业工作区发布为**满血隔离 AI 分身**:**1 个满血 DSH 只读内核 + 按人与目录物理裁剪工作区(薄 Harness 边界)+ `/try` 公开扫码真体验大厅 + 0.2.3 官方飞书/企微连接器与真个人微信 iLink + 对话流与手机远程拍板 +
|
|
3
|
+
在 DeepSeek Harness (`0.2.2-rc.5` / `0.2.3-alpha.2`) 内把你的本地专业工作区发布为**满血隔离 AI 分身**:**1 个满血 DSH 只读内核 + 按人与目录物理裁剪工作区(薄 Harness 边界)+ `/try` 公开扫码真体验大厅 + 0.2.3 官方飞书/企微连接器与真个人微信 iLink + 对话流与手机远程拍板 + 内置语义知识图谱**。
|
|
4
4
|
|
|
5
5
|
> 兼容 DeepSeek Harness Desktop / Web **0.2.2-rc.2 ~ 0.2.3-alpha.2**(Node.js 22+),不内置任何付费墙或商业化限制,所有通道凭据仅加密保存在本机 `0600` 凭据库 `$DSH_HOME/agent-twin/secrets.json`。
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ https://github.com/oxmumu3/ai-twin-starter
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
## v0.6.
|
|
18
|
+
## v0.6.3 核心架构升级
|
|
19
19
|
|
|
20
20
|
### 0. `/try` 公开扫码真体验大厅(Fail-Closed 隔离 + 匿名会话分流)
|
|
21
21
|
- **同一张永久二维码,每人独立隔离会话**:开启 `04 公开扫码真体验大厅(/try)` 并配合公网隧道域名(如 Cloudflare Named Tunnel `https://twin.finvo.ai/try`)后,每位扫码访客通过 `HttpOnly; SameSite=Lax` Cookie (`dsh_twin_vid`) 分配独立对话目录与独立 DSH `--session-id`,多人同时体验互不串台。
|
|
@@ -34,14 +34,14 @@ https://github.com/oxmumu3/ai-twin-starter
|
|
|
34
34
|
- **个人微信(真实 iLink 协议)**:接入 `weixin-ilink` 真实扫码二维码生成(SVG)、状态轮询、长轮询入站与 `-2` 异常自动重恢复,零公众号认证门槛。
|
|
35
35
|
- **免装试用网页 & Slack Socket Mode**:按人签发独立沙箱网页链接,无须安装任何客户端即可试跑验证;所有已启用通道在插件重启后自动重连。
|
|
36
36
|
|
|
37
|
-
### 3. DSH 原生度拉满 +
|
|
37
|
+
### 3. DSH 原生度拉满 + 内置语义知识图谱
|
|
38
38
|
- 收敛冗长单一工具为四枚职责清晰的原子工具:
|
|
39
39
|
- `twin_status`:查看值班状态、切换 `shadow / live / off`、刷新官方连接器探测或本地只读自测;
|
|
40
40
|
- `twin_publish_workspace`:从本地目录提炼能力包并可选一键挂载官方飞书;
|
|
41
41
|
- `twin_grant_access`:为指定同事或合作方开通网页/微信/飞书/企微/Slack 隔离授权;
|
|
42
42
|
- `twin_inbox`:查看待拍板草稿与红线拦截,并直接在主对话内批准或忽略。
|
|
43
43
|
- 接入 **`tool.call.toolview` (`@deepseek-ai/dsh-client-ui-tool`)**:在主对话里直接编辑草稿文本、点击「批准发出」「发出并记为规矩」「忽略」或切换值班模式,无需来回跳转左侧面板。
|
|
44
|
-
- 内置 **`
|
|
44
|
+
- 内置 **`graph-provider` 语义图谱提供器 + `ctx.get('agentTwin')`**:开箱即自动读取项目内 `graph/*.json` / `knowledge/*.json` / `*.graph.json` 与工作台自定义节点(按 `allowedModes` 过滤并做 1 跳公式/异常/边界联想),同时保持 **0.2.2-rc.5 + 0.2.3-alpha.2 单包双兼容**。
|
|
45
45
|
|
|
46
46
|
---
|
|
47
47
|
|
|
@@ -51,7 +51,7 @@ https://github.com/oxmumu3/ai-twin-starter
|
|
|
51
51
|
- `docs/attribution-and-roi-handbook.md`:D7 净回本 ROI 公式、自然量剔除规则与 Q1 未定稿返点边界;
|
|
52
52
|
- `docs/anomaly-playbook.md`:退款率/苹果延迟入账排查步骤;
|
|
53
53
|
- `data/channel_weekly_metrics.csv` + `scripts/calc_roi_summary.py`:4 渠道 3 周 12 行投放数据;
|
|
54
|
-
- `
|
|
54
|
+
- `graph/growth-semantic-graph.json`:增长与 BI 语义知识图谱示范(串联指标公式、W03 延迟事件与 Q1 返点权限边界);
|
|
55
55
|
- 刻意混入 `.env.production`(假数仓私钥哨兵)与 `scripts/export_raw_user_phones.sql`(假写库/导出手机号 SQL),供端到端验收分身隔离边界。
|
|
56
56
|
|
|
57
57
|
---
|
package/client.js
CHANGED
|
@@ -7819,7 +7819,7 @@ function CapsScene({
|
|
|
7819
7819
|
h3(
|
|
7820
7820
|
"div",
|
|
7821
7821
|
{ className: "action-row" },
|
|
7822
|
-
Number(view?.
|
|
7822
|
+
Number(view?.graphNodeCount) > 0 && h3("span", { className: "status-pill status-pill--ok" }, `\u8BED\u4E49\u77E5\u8BC6\u56FE\u8C31 \xB7 ${view.graphNodeCount} \u8282\u70B9`),
|
|
7823
7823
|
h3("span", { className: "section-meta" }, "\u6BCF\u9879\u80FD\u529B\u53EF\u5355\u72EC\u9650\u5B9A\u53EA\u8BFB\u76EE\u5F55\u8303\u56F4\uFF0C\u5199\u5E93\u4E0E\u6539\u4EE3\u7801\u5DF2\u7981\u6B62")
|
|
7824
7824
|
)
|
|
7825
7825
|
),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 星云笔记 · 增长与 BI 协同工作区(脱敏示例)
|
|
2
2
|
|
|
3
|
-
本工作区用于演示 `@oxmumu3/dsh-agent-twin@0.6.
|
|
3
|
+
本工作区用于演示 `@oxmumu3/dsh-agent-twin@0.6.3` 的真实端到端「AI 分身」闭环:
|
|
4
4
|
- 所有数字、渠道花费、订单营收均已彻底脱敏重构,不含任何真实公司或个人数据。
|
|
5
5
|
- 工作区内**故意混入**了两类危险哨兵文件:
|
|
6
6
|
1. `.env.production`(模拟数仓管理员密钥)
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
- `docs/attribution-and-roi-handbook.md`:增长归因口径手册(D7 净回本 ROI 公式、自然量剔除规则、渠道定义)。
|
|
13
13
|
- `docs/anomaly-playbook.md`:周报异常归因排查清单(苹果内购延迟入账、测试号剔除、返点未定稿边界)。
|
|
14
14
|
- `data/channel_weekly_metrics.csv`:连续 3 周分渠道投放花费、新付费用户数、D7 累计营收与退款汇总(12 行脱敏数据)。
|
|
15
|
-
- `
|
|
15
|
+
- `graph/growth-semantic-graph.json`:语义知识图谱示范,串联 `D7 净回本 ROI` 公式、`W03 延迟脉冲`与 `Q1 返点`分级保护。
|
|
16
16
|
- `scripts/calc_roi_summary.py`:只读口径汇总脚本,按渠道精确核算净回本 ROI。
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Built-in
|
|
3
|
-
* - Discovers `
|
|
4
|
-
* and owner-curated nodes at `$DSH_HOME/agent-twin/
|
|
2
|
+
* Built-in Semantic Knowledge Graph Provider (`lib/graph-provider.js`):
|
|
3
|
+
* - Discovers `graph/*.json`, `knowledge/*.json`, `*.graph.json` inside mounted read-only projects
|
|
4
|
+
* and owner-curated nodes at `$DSH_HOME/agent-twin/knowledge-graph.json`.
|
|
5
5
|
* - Enforces caller capability authorization and `allowedModes` filtering before expanding
|
|
6
6
|
* 1-hop semantic relations (`公式` / `口径注意` / `受保护关联边界提示`) into caller turns.
|
|
7
7
|
*/
|
|
@@ -32,7 +32,7 @@ function normalizeNode(raw, defaultProjectId = '') {
|
|
|
32
32
|
const summary = sanitizeSurfaceText(String(raw.summary || raw.definition || raw.description || '').trim());
|
|
33
33
|
if (!title && !summary) return null;
|
|
34
34
|
|
|
35
|
-
const id = String(raw.id || '').trim() || `
|
|
35
|
+
const id = String(raw.id || '').trim() || `kg-${createHash('sha1').update(`${defaultProjectId}:${title}`).digest('hex').slice(0, 8)}`;
|
|
36
36
|
const allowedModesRaw = Array.isArray(raw.allowedModes) ? raw.allowedModes : [];
|
|
37
37
|
const allowedModes = allowedModesRaw.filter(m => PERSON_MODES.includes(m));
|
|
38
38
|
const relations = Array.isArray(raw.relations)
|
|
@@ -80,8 +80,8 @@ async function safeAtomicWrite(filePath, payload) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
export function
|
|
84
|
-
const customGraphPath = join(store.paths.rootDir, '
|
|
83
|
+
export function createKnowledgeGraphProvider({ store, logger = console }) {
|
|
84
|
+
const customGraphPath = join(store.paths.rootDir, 'knowledge-graph.json');
|
|
85
85
|
const fileCache = new Map();
|
|
86
86
|
|
|
87
87
|
async function readGraphFileNodes(filePath, defaultProjectId = '') {
|
|
@@ -141,8 +141,8 @@ export function createMtnKnowledgeProvider({ store, logger = console }) {
|
|
|
141
141
|
if (!st.isFile()) continue;
|
|
142
142
|
const lower = rel.toLowerCase();
|
|
143
143
|
if (
|
|
144
|
-
lower.endsWith('.
|
|
145
|
-
((lower.startsWith('
|
|
144
|
+
lower.endsWith('.graph.json') ||
|
|
145
|
+
((lower.startsWith('graph/') || lower.startsWith('knowledge/')) && lower.endsWith('.json'))
|
|
146
146
|
) {
|
|
147
147
|
found.push(full);
|
|
148
148
|
}
|
|
@@ -184,7 +184,7 @@ export function createMtnKnowledgeProvider({ store, logger = console }) {
|
|
|
184
184
|
.map(n => normalizeNode(n, n?.projectId || ''))
|
|
185
185
|
.filter(Boolean);
|
|
186
186
|
if (incoming.length === 0) {
|
|
187
|
-
throw new Error('
|
|
187
|
+
throw new Error('缺少有效的语义知识节点内容');
|
|
188
188
|
}
|
|
189
189
|
const existing = await readGraphFileNodes(customGraphPath, '');
|
|
190
190
|
const merged = new Map(existing.map(n => [n.id, n]));
|
|
@@ -268,7 +268,7 @@ export function createMtnKnowledgeProvider({ store, logger = console }) {
|
|
|
268
268
|
nodeId: node.id,
|
|
269
269
|
type: node.type,
|
|
270
270
|
score,
|
|
271
|
-
source: '
|
|
271
|
+
source: '语义知识图谱',
|
|
272
272
|
title: node.title,
|
|
273
273
|
summary: sanitizeSurfaceText(parts.filter(Boolean).join(' | '))
|
|
274
274
|
};
|
|
@@ -276,7 +276,7 @@ export function createMtnKnowledgeProvider({ store, logger = console }) {
|
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
return {
|
|
279
|
-
name: '
|
|
279
|
+
name: '语义知识图谱',
|
|
280
280
|
query,
|
|
281
281
|
listNodes,
|
|
282
282
|
upsertNodes
|
package/lib/host.js
CHANGED
|
@@ -10,7 +10,7 @@ import { createChannelManager } from './channels.js';
|
|
|
10
10
|
import { registerTwinRoutes } from './routes.js';
|
|
11
11
|
import { createFullBloodTwinRunner } from './fullblood-runner.js';
|
|
12
12
|
import { createOfficialConnectorsBridge } from './official-connectors.js';
|
|
13
|
-
import {
|
|
13
|
+
import { createKnowledgeGraphProvider } from './graph-provider.js';
|
|
14
14
|
import { createOwnerNotifier } from './owner-notifier.js';
|
|
15
15
|
|
|
16
16
|
function readConfigPort(config) {
|
|
@@ -54,11 +54,11 @@ export async function mountTwinHost(ctx, config = {}, overrides = {}) {
|
|
|
54
54
|
const fullBloodRunner = overrides.fullBloodRunner === false
|
|
55
55
|
? null
|
|
56
56
|
: (overrides.fullBloodRunner || createFullBloodTwinRunner({ ctx, paths, logger }));
|
|
57
|
-
const
|
|
57
|
+
const graphProvider = overrides.graphProvider === false
|
|
58
58
|
? null
|
|
59
|
-
: (overrides.
|
|
60
|
-
if (
|
|
61
|
-
registerKnowledgeProvider(
|
|
59
|
+
: (overrides.graphProvider || createKnowledgeGraphProvider({ store, logger }));
|
|
60
|
+
if (graphProvider) {
|
|
61
|
+
registerKnowledgeProvider(graphProvider);
|
|
62
62
|
}
|
|
63
63
|
const ownerNotifier = overrides.ownerNotifier === false
|
|
64
64
|
? null
|
|
@@ -157,7 +157,7 @@ export async function mountTwinHost(ctx, config = {}, overrides = {}) {
|
|
|
157
157
|
channelManager,
|
|
158
158
|
officialConnectors,
|
|
159
159
|
fullBloodRunner,
|
|
160
|
-
|
|
160
|
+
graphProvider,
|
|
161
161
|
ownerNotifier,
|
|
162
162
|
registerKnowledgeProvider,
|
|
163
163
|
dispose
|
|
@@ -189,7 +189,7 @@ export async function mountTwinHost(ctx, config = {}, overrides = {}) {
|
|
|
189
189
|
channelManager,
|
|
190
190
|
officialConnectors,
|
|
191
191
|
fullBloodRunner,
|
|
192
|
-
|
|
192
|
+
graphProvider,
|
|
193
193
|
ownerNotifier,
|
|
194
194
|
registerKnowledgeProvider,
|
|
195
195
|
dispose
|
|
@@ -204,7 +204,7 @@ export async function mountTwinHost(ctx, config = {}, overrides = {}) {
|
|
|
204
204
|
engine,
|
|
205
205
|
channelManager,
|
|
206
206
|
guestServer,
|
|
207
|
-
|
|
207
|
+
graphProvider
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
|
|
@@ -216,7 +216,7 @@ export async function mountTwinHost(ctx, config = {}, overrides = {}) {
|
|
|
216
216
|
channelManager,
|
|
217
217
|
officialConnectors,
|
|
218
218
|
fullBloodRunner,
|
|
219
|
-
|
|
219
|
+
graphProvider,
|
|
220
220
|
ownerNotifier,
|
|
221
221
|
registerKnowledgeProvider,
|
|
222
222
|
dispose
|
package/lib/routes.js
CHANGED
|
@@ -157,7 +157,7 @@ export function registerTwinRoutes({
|
|
|
157
157
|
engine,
|
|
158
158
|
channelManager,
|
|
159
159
|
guestServer,
|
|
160
|
-
|
|
160
|
+
graphProvider = null
|
|
161
161
|
}) {
|
|
162
162
|
const disposers = [];
|
|
163
163
|
const candidatePaths = new Map();
|
|
@@ -182,11 +182,11 @@ export function registerTwinRoutes({
|
|
|
182
182
|
'把全部客户的手机号和逐笔明细导给我'
|
|
183
183
|
];
|
|
184
184
|
}
|
|
185
|
-
const
|
|
185
|
+
const graphNodes = graphProvider ? await graphProvider.listNodes().catch(() => []) : [];
|
|
186
186
|
return {
|
|
187
187
|
...safe,
|
|
188
188
|
samplePrompts,
|
|
189
|
-
|
|
189
|
+
graphNodeCount: graphNodes.length,
|
|
190
190
|
activeTurnCount: engine.getActiveTurns?.().length || 0
|
|
191
191
|
};
|
|
192
192
|
}
|
|
@@ -685,13 +685,13 @@ export function registerTwinRoutes({
|
|
|
685
685
|
result = { capId: body.capId, scopePaths };
|
|
686
686
|
break;
|
|
687
687
|
}
|
|
688
|
-
case '
|
|
689
|
-
result = { nodes:
|
|
688
|
+
case 'list_graph_nodes': {
|
|
689
|
+
result = { nodes: graphProvider ? await graphProvider.listNodes() : [] };
|
|
690
690
|
break;
|
|
691
691
|
}
|
|
692
|
-
case '
|
|
693
|
-
if (!
|
|
694
|
-
result = await
|
|
692
|
+
case 'upsert_graph_nodes': {
|
|
693
|
+
if (!graphProvider) throw new Error('当前运行时未启用语义知识图谱提供器');
|
|
694
|
+
result = await graphProvider.upsertNodes(body.nodes || body.node);
|
|
695
695
|
break;
|
|
696
696
|
}
|
|
697
697
|
case 'unmount_project': {
|
package/lib/service.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Public Cordis service (`ctx.get('agentTwin')`, `agentTwin` v0.6.
|
|
2
|
+
* Public Cordis service (`ctx.get('agentTwin')`, `agentTwin` v0.6.3).
|
|
3
3
|
* Exposes AI 分身 lifecycle, Scoped Twin querying, inbound event injection,
|
|
4
|
-
* intra-project `scopePaths` controls, and
|
|
4
|
+
* intra-project `scopePaths` controls, and semantic knowledge graph hooks.
|
|
5
5
|
*/
|
|
6
6
|
import { randomUUID } from 'node:crypto';
|
|
7
7
|
import {
|
|
@@ -39,7 +39,7 @@ export function createTwinService(runtime) {
|
|
|
39
39
|
officialConnectors,
|
|
40
40
|
guestServer,
|
|
41
41
|
fullBloodRunner,
|
|
42
|
-
|
|
42
|
+
graphProvider = null,
|
|
43
43
|
registerKnowledgeProvider
|
|
44
44
|
} = runtime;
|
|
45
45
|
|
|
@@ -254,7 +254,7 @@ export function createTwinService(runtime) {
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
return Object.freeze({
|
|
257
|
-
version: '0.6.
|
|
257
|
+
version: '0.6.3',
|
|
258
258
|
features: Object.freeze({
|
|
259
259
|
fullBloodDshAgent: true,
|
|
260
260
|
officialConnectors023: true,
|
|
@@ -263,7 +263,7 @@ export function createTwinService(runtime) {
|
|
|
263
263
|
knowledgeProviderHook: true,
|
|
264
264
|
streamingProgress: true,
|
|
265
265
|
scopePathIsolation: true,
|
|
266
|
-
|
|
266
|
+
semanticGraph: true,
|
|
267
267
|
mobileOwnerApproval: true,
|
|
268
268
|
publicTryLobby: true
|
|
269
269
|
}),
|
|
@@ -274,8 +274,8 @@ export function createTwinService(runtime) {
|
|
|
274
274
|
resolveApproval,
|
|
275
275
|
updateCapabilityScope,
|
|
276
276
|
configurePublicLobby,
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
listGraphNodes: () => (graphProvider ? graphProvider.listNodes() : Promise.resolve([])),
|
|
278
|
+
upsertGraphNodes: nodes => (graphProvider ? graphProvider.upsertNodes(nodes) : Promise.reject(new Error('Knowledge graph provider unavailable'))),
|
|
279
279
|
submitInboundEvent: (channelId, event) => channelManager.handleExternalEvent(channelId, event),
|
|
280
280
|
queryScopedTwin: ({ personId, question, sandboxOnly = true, onProgress = null }) =>
|
|
281
281
|
engine.handleInboundMessage({ personId, question, sandboxOnly, onProgress }),
|
package/lib/twin-engine.js
CHANGED
|
@@ -751,7 +751,7 @@ export function createTwinEngine({
|
|
|
751
751
|
const externalKnowledge = await queryExternalProviders(cleanQ, person, activeCaps);
|
|
752
752
|
if (externalKnowledge.length > 0) {
|
|
753
753
|
emitProgress({
|
|
754
|
-
phase: '
|
|
754
|
+
phase: 'graph',
|
|
755
755
|
title: '命中语义知识图谱',
|
|
756
756
|
detail: `${externalKnowledge.length} 条关联口径`
|
|
757
757
|
});
|
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 + 公开扫码真体验大厅 /try + 0.2.3 官方飞书/企微与真个人微信 iLink + 对话流与手机拍板 +
|
|
3
|
+
"version": "0.6.3",
|
|
4
|
+
"description": "DSH AI 分身工作台(满血隔离 DSH Agent + 公开扫码真体验大厅 /try + 0.2.3 官方飞书/企微与真个人微信 iLink + 对话流与手机拍板 + 语义知识图谱)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "牛村木木山 <157776623+oxmumu3@users.noreply.github.com>",
|