pygmalion-osr6 0.1.2 → 0.1.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 +4 -2
- package/package.json +1 -1
- package/src/controller.js +1 -1
- package/src/index.js +1 -1
- package/src/share.js +17 -5
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
### 手机:连接后直接分享到 QQ
|
|
10
10
|
|
|
11
|
-
首次安装 pygmalion >=0.2.
|
|
11
|
+
首次安装 pygmalion >=0.2.6、本插件及 OSR6 连接器 APK,已有角色需正常接入 QQ 并绑定主人。主人在 QQ 发来连接时,宿主自动登记设备并赋予该角色使用权限,无需进入管理页添加设备。
|
|
12
12
|
|
|
13
13
|
1. 同一手机的 dsh Go / Pygmalion 已在后台运行(安装后首次需启动引擎;连接器不能代替未运行的角色宿主)。
|
|
14
14
|
2. 打开 OSR6 连接器,点击“连接并分享到 QQ”;首次允许系统蓝牙权限并选择设备。
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
常用设备会记住,下次点击同一按钮即可连接并分享。QQ 的选择联系人与发送步骤由 QQ 提供。没有要求先打开 dsh 面板、复制票据、切到 APK 再切回的步骤。手动配对在连接器的“高级”与 dsh 面板中保留,适用于不使用 QQ 的独立 dsh。
|
|
18
18
|
|
|
19
|
+
0.1.3 配合 pygmalion 0.2.6 将手机分享接入后的消息统一为 Windows 的 `[设备就绪]` 格式,包含 deviceId 与 skill,并使用 `pygmalion-device-ready / instructions` 来源,不记成用户聊天。兼容旧 APK 的自动说明文字;用户随附的真实文字仍保留。APK 0.1.2 也为 QQ 分享文本增加 `[设备就绪]` 标识;凭据仅由宿主解析,不能靠文字标识跳过授权。
|
|
20
|
+
|
|
19
21
|
本机 `0.371b-sr6-fix7` 固件默认使用经典蓝牙,连接器选择 `TCodeESP32 · SPP`。手机执行超过 300 秒的整段计划需要更新连接器 APK 至 0.1.1,并更新 dsh 插件;旧 APK 自身仍有 300 秒/31000 帧校验。Windows 无需 APK。
|
|
20
22
|
|
|
21
23
|
两个程序必须运行在同一 Android 手机:连接兑换只使用 127.0.0.1。本版不能把手机分享链接发给服务器或另一台 Windows 的 dsh 来控制。连接文本包含一次性连接凭据,不转发给其他人;它不会发给模型,沿用宿主的连接输入剥离逻辑。凭据使用或重新生成后失效,没有控制有效期。
|
|
@@ -31,7 +33,7 @@ Pygmalion 模式下在同一面板选择活跃角色,点击“关联并通知
|
|
|
31
33
|
手机与 Windows 的 npm 安装/更新(一行):
|
|
32
34
|
|
|
33
35
|
```sh
|
|
34
|
-
dsh plugin --profile web add pygmalion@0.2.
|
|
36
|
+
dsh plugin --profile web add pygmalion@0.2.6 pygmalion-osr6@0.1.3 --config.strict-dep-builds=false
|
|
35
37
|
```
|
|
36
38
|
|
|
37
39
|
安装后重启引擎一次;日常连接/分享仅操作连接器与 QQ,不需要切换到 dsh Go 面板。
|
package/package.json
CHANGED
package/src/controller.js
CHANGED
|
@@ -51,7 +51,7 @@ export class Controller extends EventEmitter {
|
|
|
51
51
|
this.assertConnected();
|
|
52
52
|
if(this.managed)throw Error('请在设备面板选择角色并关联,手机也可分享连接到 QQ');
|
|
53
53
|
if(!sessionId||!await this.resolveSession?.(sessionId))throw Error('请从已打开对话的 OSR6 面板发送就绪通知');
|
|
54
|
-
await this.notify(sessionId,'[
|
|
54
|
+
await this.notify(sessionId,'[设备就绪] OSR6 六轴设备已连接,可以直接使用 osr6_play / osr6_edit / osr6_stop。无需预检或轮询。计划结束后自动从头循环,并通知一次。位置是指令估计,不是传感器或力度反馈。');
|
|
55
55
|
}
|
|
56
56
|
assertConnected(){if(!this.transport?.open)throw Error('OSR6 尚未连接');}
|
|
57
57
|
cancelReplay(){clearTimeout(this.replayTimer);this.replay=null;this.replayGeneration=(this.replayGeneration??0)+1;}
|
package/src/index.js
CHANGED
|
@@ -17,7 +17,7 @@ export async function apply(ctx,config={}) {
|
|
|
17
17
|
const controller=new Controller(bridge,{
|
|
18
18
|
tcodeProfile:config.tcodeProfile??'sr6-alpha4',
|
|
19
19
|
resolveSession:id=>ctx.agents.get(id),
|
|
20
|
-
notify:async(id,text)=>{const agent=ctx.agents.get(id);if(!agent)throw Error('对话已关闭');await agent.send({id:'osr6:'+randomUUID(),role:'user',content:[{type:'text',text}],source:{kind:'pygmalion-
|
|
20
|
+
notify:async(id,text)=>{const agent=ctx.agents.get(id);if(!agent)throw Error('对话已关闭');await agent.send({id:'osr6:'+randomUUID(),role:'user',content:[{type:'text',text}],source:{kind:text.startsWith('[设备就绪]')?'pygmalion-device-ready':'pygmalion-device-event',form:'instructions'}},'next-turn',true);}
|
|
21
21
|
});
|
|
22
22
|
ctx.effect(()=>()=>controller.dispose());
|
|
23
23
|
registerTools(ctx,controller);registerPygmalion(ctx,controller);const action=createActions(controller);
|
package/src/share.js
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import {randomBytes,timingSafeEqual} from 'node:crypto';
|
|
2
2
|
const secret=()=>randomBytes(32).toString('base64url');
|
|
3
3
|
export const encodeShare=value=>'osr6://connect/'+Buffer.from(JSON.stringify(value)).toString('base64url');
|
|
4
|
+
export const SHARE_MESSAGE_PREFIX='[设备就绪] OSR6 六轴设备已连接,请关联当前角色。';
|
|
4
5
|
export function matchShare(text){
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
text=String(text);
|
|
7
|
+
const found=text.match(/osr6:\/\/connect\/[A-Za-z0-9_-]+/);
|
|
8
|
+
if(!found)return null;
|
|
9
|
+
const url=found[0];
|
|
10
|
+
let raw=url;
|
|
11
|
+
// 连同连接器自动附带的说明一起消费;不能将其记成用户发言。兼容已发出的旧 APK。
|
|
12
|
+
const before=text.slice(0,found.index);
|
|
13
|
+
for(const prefix of [SHARE_MESSAGE_PREFIX,'OSR6 已连接,把此连接发给绑定角色即可使用:']){
|
|
14
|
+
const start=before.lastIndexOf(prefix);
|
|
15
|
+
if(start>=0 && (start===0 || before[start-1]==='\n') && !before.slice(start+prefix.length).trim()){
|
|
16
|
+
raw=text.slice(start,found.index+url.length);break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
7
19
|
// 即使内容无效也返回匹配,使宿主从模型/记忆文本中去除连接凭据。
|
|
8
20
|
try{
|
|
9
|
-
if(
|
|
10
|
-
const value=JSON.parse(Buffer.from(
|
|
21
|
+
if(url.length>2048)throw Error();
|
|
22
|
+
const value=JSON.parse(Buffer.from(url.split('/').at(-1),'base64url').toString());
|
|
11
23
|
if(value.v!==1||!['local','phone'].includes(value.mode)||!/^[-\w]{43}$/.test(value.token))throw Error();
|
|
12
24
|
if(value.mode==='phone'&&(!Number.isInteger(value.port)||value.port<1024||value.port>65535))throw Error();
|
|
13
|
-
return {raw
|
|
25
|
+
return {...value,raw};
|
|
14
26
|
}catch{return {raw,invalid:true};}
|
|
15
27
|
}
|
|
16
28
|
export function createShare(controller){
|