pygmalion 0.2.0 → 0.2.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 +1 -1
- package/docs/DEVELOPMENT.md +6 -1
- package/docs/UPGRADE-0.2.md +5 -1
- package/package.json +4 -4
- package/src/roleplay-generation.js +12 -2
- package/src/roleplay-session.js +6 -0
- package/src/skills.js +11 -9
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Pygmalion 是一个运行在 DeepSeek Harness(dsh)上的 AI 角色聊天插
|
|
|
8
8
|
|
|
9
9
|
### 1. 安装并启动
|
|
10
10
|
|
|
11
|
-
需要 Node.js 22.19 或更高的 22.x 版本,或 Node.js 24
|
|
11
|
+
需要 Node.js 22.19 或更高的 22.x 版本,或 Node.js 24 及以上版本。自插件 **0.2.1** 起同时支持 **dsh 0.2.1-rc.2、0.2.2-rc.1**;已发布的插件 0.2.0 仍只声明支持前者。宿主版本须使用完整版本号,不能只比较 rc 后缀。
|
|
12
12
|
|
|
13
13
|
安装 dsh 和它管理插件时使用的 pnpm:
|
|
14
14
|
|
package/docs/DEVELOPMENT.md
CHANGED
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
| `preset/`、`skills/` | 声明式会话预设与按需工作流 |
|
|
15
15
|
| `scripts/` | 自测和开发启动脚本 |
|
|
16
16
|
|
|
17
|
-
源码使用 JavaScript ESM
|
|
17
|
+
源码使用 JavaScript ESM,无额外构建步骤。支持的宿主为 dsh 0.2.1-rc.2 和 0.2.2-rc.1,开发依赖仍固定旧版以保留回归基线。
|
|
18
|
+
|
|
19
|
+
宿主差异仅在两个边界处理:`roleplay-generation.js` 在新版通过工具注册的 `when` 条件控制每步可见性和执行准入,旧版保留提示词工具筛选;`roleplay-session.js` 在新版通过公开的 `agent.model.select()` 设置角色路由,确保宿主先恢复的空白会话也使用角色指定模型。不要用 `result.tools ?? []` 掩盖宿主契约变化,也不要引入另一套角色状态或发送管线。关闭生成后的业务返回仍由原有生成服务处理。
|
|
20
|
+
|
|
21
|
+
原生宿主测试可通过 `PYGMALION_DSH_RUNTIME` 指定隔离运行时。模块必须从同一运行时解析,避免混用两版 Cordis/tools。新增 `self-test-roleplay-visibility.mjs` 覆盖开关变化、跨角色隔离、恢复及新版工具执行准入。双版本已验证角色生成、原生会话恢复、通信扩展、语音、设备扩展,以及旧记忆/skill/后台隔离契约;使用本地假模型与合成数据,不等同于 Android 真机后台存活验收。
|
|
18
22
|
|
|
19
23
|
角色生成配置不提供输出 token 上限,旧版 `maxTokens` 被忽略,角色请求 hook 也会剥离旧会话继承的限制。dsh 使用的 pi-ai SDK 仍可能按模型能力填写协议中的输出参数;这是宿主行为,应与插件自行设置的限制分别核查,不能把移除插件限制描述成模型没有输出边界。
|
|
20
24
|
|
|
@@ -43,6 +47,7 @@ node scripts/start-local-test.mjs --install
|
|
|
43
47
|
| `node scripts/self-test-peer-identity.mjs` | 身份作用域、首聊并发绑定、解绑代次及删除竞态 |
|
|
44
48
|
| `node scripts/self-test-device-extensions.mjs` | 独立开关/只读事件驱动、动态 skill、工具/脚本、管理 API 与卸载 |
|
|
45
49
|
| `node scripts/self-test-voice-dsh.mjs` | 独立 TTS 插件、真实宿主工具派发及结构回执落盘 |
|
|
50
|
+
| `node scripts/self-test-meme-read-dsh.mjs` | skill 成功后第一步即暴露 meme_read、视觉子代理读真实 PNG、图片字节进入模型请求及结果回传(本地假模型) |
|
|
46
51
|
| `node scripts/self-test-phase4.mjs` | 生活脚本监管 |
|
|
47
52
|
| `node scripts/self-test-phase5.mjs` | 管理 API、安全与隔离 |
|
|
48
53
|
| `node scripts/self-test-dsh-021.mjs` | 新版宿主、旧记忆、skills 与后台隔离 |
|
package/docs/UPGRADE-0.2.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# 升级与回滚
|
|
2
2
|
|
|
3
|
-
本文面向通过 npm 安装 Pygmalion
|
|
3
|
+
本文面向通过 npm 安装 Pygmalion 的用户,说明如何更新插件、保留自己的数据,以及恢复到升级前的版本。Pygmalion 0.2.0 支持 dsh 0.2.1-rc.2;0.2.1 同时支持 dsh 0.2.1-rc.2 与 0.2.2-rc.1,无需迁移角色或记忆数据。
|
|
4
|
+
|
|
5
|
+
## 0.2.2 修复
|
|
6
|
+
|
|
7
|
+
修复 dsh 0.2.2-rc.1 中调用 `skill` 成功后,`meme_read` 等按需工具晚一个模型步才可见的问题。工具注册现在在宿主等待的结果处理阶段完成;保持 dsh 0.2.1-rc.2 兼容。升级后重启引擎生效,无需迁移数据。
|
|
4
8
|
|
|
5
9
|
## 升级前记录版本并备份
|
|
6
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pygmalion",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Pygmalion:将 DeepSeek Harness(dsh)改造为「拟真 AI 好友」服务的 dsh 插件——QQ 官方机器人接入、文件系统双索引长期记忆、heartbeat+脚本+hook 主动交互,一次安装即用(含管理网页)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": "^22.19.0 || >=24.0.0",
|
|
38
|
-
"dsh": "0.2.1-rc.2"
|
|
38
|
+
"dsh": "0.2.1-rc.2 || 0.2.2-rc.1"
|
|
39
39
|
},
|
|
40
40
|
"packageManager": "pnpm@10.33.2",
|
|
41
41
|
"dependencies": {
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"ws": "^8.21.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@deepseek-ai/cordis": "~4.0.5",
|
|
47
|
-
"@deepseek-ai/dsh-tools": "0.2.1-rc.2"
|
|
46
|
+
"@deepseek-ai/cordis": "~4.0.5 || ~4.1.0",
|
|
47
|
+
"@deepseek-ai/dsh-tools": "0.2.1-rc.2 || 0.2.2-rc.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@deepseek-ai/dsh-tools": "0.2.1-rc.2"
|
|
@@ -15,6 +15,16 @@ additionalInformation 只交代聊天之外必需的客观事实、来源、实
|
|
|
15
15
|
不需要发言时可不调用生成器,你的最终 assistant 文本不会送往聊天端。长期事实以真实用户消息、实际发送的角色消息及既有记忆为准;不把系统注入、未送达内容或推测写成用户事实。设备、脚本和表情包维护仍按各自 skill 执行。`;
|
|
16
16
|
|
|
17
17
|
export function registerRoleplayTools(ctx,director,service){
|
|
18
|
+
// 0.2.2 在模型步开始时统一决定工具可见性与可执行性;旧宿主仍由提示词钩子筛选。
|
|
19
|
+
const conditionalTools=typeof ctx.tools.resolve==='function' && typeof ctx.tools.executable==='function';
|
|
20
|
+
const available=async({agent,signal})=>{
|
|
21
|
+
signal?.throwIfAborted();
|
|
22
|
+
const header=agent?.session?.header;
|
|
23
|
+
if(!header||header.parentSession||header.agentPreset===ROLEPLAY_PRESET)return false;
|
|
24
|
+
const role=await director.roleForWorkspace(header.cwd);
|
|
25
|
+
signal?.throwIfAborted();
|
|
26
|
+
return role?.roleplay?.enabled===true;
|
|
27
|
+
};
|
|
18
28
|
ctx.tools.register({name:'roleplay_generate',description:'让可复用的角色会话生成最终消息。程序自动装载完整人设和关于TA、同步新增真实往来;你选择有关原始文件并补充额外客观事实。全部返回 messages 按原顺序原文交给现有发送工具,生成器不发送角色消息。',
|
|
19
29
|
parameters:{type:'object',additionalProperties:false,required:['files','additionalInformation'],properties:{
|
|
20
30
|
files:{type:'array',maxItems:32,items:{type:'string'},description:'当前角色工作区内本轮有关的 UTF-8 文本文件路径;不限 memory 目录,程序读原文并去重。没有时用 []。'},
|
|
@@ -25,12 +35,12 @@ export function registerRoleplayTools(ctx,director,service){
|
|
|
25
35
|
const deps=await director.depsFor(exec.agent.id);const role=deps?.roleId?await director.roleForWorkspace(await deps.workspaceOf?.()):undefined;const target=deps?.target?.();
|
|
26
36
|
if(!role||role.roleId!==deps.roleId||!matchesRoleTarget(role,target,deps.identityScope))throw new Error('角色生成仅供当前角色绑定的私人会话使用');
|
|
27
37
|
return service.generate(deps,args,exec);
|
|
28
|
-
}});
|
|
38
|
+
}},conditionalTools?{when:available}:undefined);
|
|
29
39
|
ctx.on('system-prompt/assemble',async(assembly,context,next)=>{
|
|
30
40
|
const result=await next();const agent=context.agent;
|
|
31
41
|
if(!agent||agent.session.header.parentSession||agent.session.header.agentPreset===ROLEPLAY_PRESET)return result;
|
|
32
42
|
const role=await director.roleForWorkspace(agent.session.header.cwd);
|
|
33
|
-
if(!role?.roleplay?.enabled)return {...result,tools:result.tools.filter(tool=>tool.name!=='roleplay_generate')};
|
|
43
|
+
if(!role?.roleplay?.enabled)return conditionalTools?result:{...result,tools:result.tools.filter(tool=>tool.name!=='roleplay_generate')};
|
|
34
44
|
return {...result,sections:result.sections.map(section=>section.name==='deployment:persona-prefix'?{...section,text:ORCHESTRATOR_INSTRUCTION,interpolate:false}:section)};
|
|
35
45
|
});
|
|
36
46
|
}
|
package/src/roleplay-session.js
CHANGED
|
@@ -74,6 +74,12 @@ export function createRoleplaySessionBackend({ agents, agentPresets, persistence
|
|
|
74
74
|
async run({sessionId,workspace,options,requestId,payload,signal,onCheckpoint}) {
|
|
75
75
|
const agent = await open({sessionId,workspace,options});
|
|
76
76
|
signal.throwIfAborted();
|
|
77
|
+
// 新宿主在提示词组装之前固定模型路由;借用宿主恢复的会话也必须使用角色配置。
|
|
78
|
+
// 只调用公开模型选择接口,旧宿主继续由既有提示词/请求钩子保持路由。
|
|
79
|
+
if(typeof agent.model?.select==='function'){
|
|
80
|
+
const {provider,model,reasoningEffort}=options;
|
|
81
|
+
agent.model.select({provider,model,...(reasoningEffort?{reasoningEffort}:{})});
|
|
82
|
+
}
|
|
77
83
|
const checkpoint={seq:agent.session.seq,nodes:[...agent.session.surface.nodes]};
|
|
78
84
|
await onCheckpoint?.(checkpoint);
|
|
79
85
|
const abort=()=>agent.cancel({kind:'user',reason:'角色生成请求终止'});
|
package/src/skills.js
CHANGED
|
@@ -52,12 +52,17 @@ export function registerPygmalionSkills(ctx, director, mode = 'chat') {
|
|
|
52
52
|
owned.set(name, { release, entry: definition.entry }); grants.set(agent, owned);
|
|
53
53
|
set.add(name); active.set(agent, set);
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
// 两版宿主都会等待 post-execute;0.2.2 在 pre-step 之前已冻结工具列表,不能延迟至下一步注册。
|
|
56
|
+
ctx.on('tools/post-execute', async (exec, result, next) => {
|
|
57
|
+
const decision = await next();
|
|
58
|
+
const value = Object.hasOwn(decision, 'value') ? decision.value : result.value;
|
|
59
|
+
if (decision.kind === 'accept' && !Object.hasOwn(decision, 'content')
|
|
60
|
+
&& exec.name === 'skill' && !result.isError && value?.provider === provider && exec.agent) {
|
|
61
|
+
exec.signal?.throwIfAborted();
|
|
62
|
+
await activate(exec.agent, value.name);
|
|
63
|
+
}
|
|
64
|
+
return decision;
|
|
65
|
+
}, { prepend: true });
|
|
61
66
|
ctx.on('agent/pre-step', async ({ agent }, next) => {
|
|
62
67
|
const role = await director.roleForWorkspace(agent.session.header.cwd);
|
|
63
68
|
const current = await available(role);
|
|
@@ -89,9 +94,6 @@ export function registerPygmalionSkills(ctx, director, mode = 'chat') {
|
|
|
89
94
|
for (const message of decision.messages) {
|
|
90
95
|
if (message.source?.kind === 'skill-invocation') await activate(agent, message.source.name);
|
|
91
96
|
}
|
|
92
|
-
for (const name of [...(active.get(agent) ?? [])].filter(name => name.startsWith('pending:'))) {
|
|
93
|
-
await activate(agent, name.slice(8)); active.get(agent)?.delete(name);
|
|
94
|
-
}
|
|
95
97
|
return decision;
|
|
96
98
|
});
|
|
97
99
|
}
|