femo-plugin 1.0.4 → 1.0.5
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/docs/ActiveRoadmaps/Func/345/201/234/346/255/242/350/257/255/344/271/211-/351/201/227/345/274/203/346/216/245/347/273/255-/346/226/275/345/267/245/346/270/205/345/215/225.md +91 -0
- package/docs/ActiveRoadmaps//345/217/214user/346/226/275/345/267/245/346/270/205/345/215/225.md +326 -0
- package/docs/Specs//346/212/225/345/275/261/344/270/255/345/277/203/350/241/214/345/215/217/350/256/256.md +616 -569
- package/femo2host/AGENTS.md +1 -1
- package/femo2host/femoGenConnector/engine-client.mjs +7 -2
- package/femo2host/femoGenConnector/file-dialogs.mjs +108 -2
- package/femo2host/femoToolcall/chronica.py +99 -19
- package/femo2host/femo_api.py +14 -1
- package/femo2host/host/actor-core.d.mts +25 -0
- package/femo2host/host/actor-core.mjs +72 -0
- package/femo2host/host/cast-core.d.mts +3 -0
- package/femo2host/host/cast-core.mjs +14 -0
- package/femo2host/host/daemon-client.mjs +59 -10
- package/femo2host/host/hub-render-core.d.mts +2 -0
- package/femo2host/host/hub-render-core.mjs +6 -2
- package/femo2host/host/run-state-core.d.mts +4 -0
- package/femo2host/host/run-state-core.mjs +4 -0
- package/femo2host/host/speech-core.mjs +11 -4
- package/femo2host/host/tools-core.d.mts +11 -0
- package/femo2host/host/tools-core.mjs +39 -0
- package/femo2host/mailbox.py +66 -20
- package/femo2host/projectionCenter/app.css +61 -0
- package/femo2host/projectionCenter/composer.mjs +69 -11
- package/femo2host/projectionCenter/identity.mjs +131 -0
- package/femo2host/projectionCenter/index.html +54 -1
- package/femo2host/projectionCenter/main.mjs +209 -33
- package/femo2host/projectionCenter/panels.mjs +108 -16
- package/femo2host/projectionCenter/render.mjs +813 -695
- package/femo2host/projectionCenter/state.mjs +30 -0
- package/femo2host/projectionCenter/util.mjs +28 -0
- package/femo2host/projection_hub.py +9917 -8422
- package/femo2host/python/femo_bridge.py +270 -32
- package/femo2host/python/femo_daemon.py +1528 -1209
- package/femo2host/python/mirror_window.py +237 -0
- package/femoBridges/ContextExample.py +113 -71
- package/femoCompiler/AGENTS.md +1 -0
- package/femoCompiler/FEMO_parser.py +2641 -2567
- package/femoCompiler/FEMO_runtime.py +201 -44
- package/femoCompiler/FEMO_scope_resolver.py +26 -12
- package/femoCompiler/block_collector.py +24 -27
- package/femoCompiler/db_utils.py +560 -503
- package/femoCompiler/femoAsync.py +466 -436
- package/femoCompiler/func_registry.py +74 -0
- package/femoCompiler/protocol.py +127 -127
- package/femoCompiler/save_dialog.py +497 -446
- package/femoExamples/AI/350/201/212/345/244/251/345/256/244/AI/350/201/212/345/244/251/345/256/244-/345/270/246agent/347/211/210.femo +229 -142
- package/femoExamples/AI/350/201/212/345/244/251/345/256/244/random_wait_time.py +91 -2
- package/femoExamples/LuxFiat/luxfiat-loop.femo +0 -1
- package/femoExamples/LuxFiat/luxfiat-simple.femo +23 -24
- package/femoExamples/debug/347/245/236/345/231/250/debug/347/245/236/345/231/250.femo +221 -222
- package/femoExamples/discussion.femo +72 -72
- package/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200-/350/255/246/351/225/277/347/211/210-9/344/272/272/351/242/204/345/245/263/347/214/216.femo +1 -2
- package/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200-/350/255/246/351/225/277/347/211/210.femo +1 -2
- package/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200.femo +1 -2
- package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225//350/260/201/346/230/257/345/215/247/345/272/225-/350/217/234/345/270/202/345/234/272/345/261/200.femo +1 -1
- package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225//350/260/201/346/230/257/345/215/247/345/272/225.femo +1 -1
- package/femoGen/src/femoParser.jsx +14 -0
- package/hostAdapter/dshAdapter/host/femo-skill.ts +23 -10
- package/hostAdapter/dshAdapter/host/routes/projection-input.ts +3 -0
- package/hostAdapter/dshAdapter/lib/client.js +20 -2
- package/hostAdapter/dshAdapter/lib/client.js.map +2 -2
- package/hostAdapter/dshAdapter/lib/main.js +161 -18
- package/hostAdapter/dshAdapter/lib/main.js.map +3 -3
- package/hostAdapter/dshAdapter/package.json +1 -1
- package/hostAdapter/webAdapter/console/index.html +12 -4
- package/hostAdapter/webAdapter/extension/background.js +16 -5
- package/hostAdapter/webAdapter/extension/seat-agent-core.js +2 -1
- package/hostAdapter/webAdapter/extension/sidepanel/actors.mjs +101 -0
- package/hostAdapter/webAdapter/extension/sidepanel/main.mjs +81 -20
- package/hostAdapter/webAdapter/extension/sidepanel/reconnect.mjs +33 -0
- package/hostAdapter/webAdapter/extension/sidepanel/run-control.mjs +22 -11
- package/hostAdapter/webAdapter/extension/sidepanel/seats.mjs +6 -20
- package/hostAdapter/webAdapter/extension/sidepanel.html +30 -8
- package/hostAdapter/webAdapter/native/install-native-host.mjs +1 -0
- package/hostAdapter/webAdapter/native/register-core.mjs +69 -28
- package/hostAdapter/webAdapter/native/web-launcher.sh +37 -0
- package/hostAdapter/webAdapter/readme.md +51 -10
- package/hostAdapter/webAdapter/server/bridge.mjs +1 -1
- package/hostAdapter/webAdapter/server/runtime.mjs +51 -5
- package/hostAdapter/webAdapter/server/seats.mjs +11 -6
- package/hostAdapter/webAdapter/server/service.mjs +108 -15
- package/hostAdapter/webAdapter/shared/seats-core.mjs +31 -6
- package/hostAdapter/webAdapter/sites/chatglm.cn/inject.js +76 -4
- package/hostAdapter/webAdapter/sites/chatgpt.com/SITE.md +1 -0
- package/hostAdapter/webAdapter/sites/chatgpt.com/content.js +13 -4
- package/hostAdapter/webAdapter/sites/chatgpt.com/inject.js +40 -4
- package/hostAdapter/webAdapter/start-service.command +16 -0
- package/hostAdapter/webAdapter/tests/chatgpt-parser.test.mjs +37 -0
- package/hostAdapter/webAdapter/tests/runtime.test.mjs +42 -0
- package/hostAdapter/webAdapter/tests/seats-core.test.mjs +37 -1
- package/hostAdapter/webAdapter/tests/smoke-service.mjs +261 -232
- package/hostAdapter/zcodeAdapter/runtime/speech-collect.mjs +6 -0
- package/hostAdapter/zcodeAdapter/tests/unbound-actors.test.mjs +51 -0
- package/package.json +1 -1
- package//350/257/255/346/263/225/346/226/207/346/241/243.md +1222 -1202
|
@@ -12,22 +12,28 @@
|
|
|
12
12
|
* 启动」此后永远可用。install-native-host.mjs 降级为手动重跑入口(改了 key、
|
|
13
13
|
* 或不想启动服务只想登记时用),与本件同吃一份实现。
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* 登记做三件事(按平台分流,幂等可重复跑;实测坑全保留):
|
|
16
16
|
* 1) 写 host manifest JSON(com.femo.web_launcher.json):allowed_origins 锁
|
|
17
|
-
* 钉死的扩展 ID,type=stdio,path
|
|
18
|
-
* Chromium/Edge 对 Native Messaging
|
|
19
|
-
* 批处理壳起不来,扩展只见「Error when communicating with the
|
|
20
|
-
* messaging host」;exe 壳把标准句柄显式传给 node
|
|
21
|
-
*
|
|
22
|
-
*
|
|
17
|
+
* 钉死的扩展 ID,type=stdio,path 指向启动壳——Windows=web-launcher.exe
|
|
18
|
+
* (实测坑:新版 Chromium/Edge 对 Native Messaging 宿主走「可执行文件直启」,
|
|
19
|
+
* .cmd/.bat 批处理壳起不来,扩展只见「Error when communicating with the
|
|
20
|
+
* native messaging host」;exe 壳把标准句柄显式传给 node 子进程,帧零接触
|
|
21
|
+
* 过手);macOS=web-launcher.sh(exec 直替进程,stdio 帧原样继承,无需
|
|
22
|
+
* 编译,见 web-launcher.sh 文件头);
|
|
23
|
+
* 2) 启动壳就位 + 写 node.path 提示文件(本机 node 不在系统 PATH 时壳靠它找
|
|
23
24
|
* node——实案:机器上只有 AutoClaw 自带的 node,Chrome 拉起的宿主进程
|
|
24
|
-
* PATH
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* host
|
|
25
|
+
* PATH 里没有它)。Windows 侧壳=编译 web-launcher.exe(csc.exe,.NET
|
|
26
|
+
* Framework 自带;exe 缺或比 .cs 旧才重编);macOS 侧壳=web-launcher.sh
|
|
27
|
+
* 兜底 chmod +x(git/tar 都可能丢执行位);
|
|
28
|
+
* 3) 逐家浏览器登记:Windows 写 HKCU 注册表两处(Chrome 与 Edge 同名键各
|
|
29
|
+
* 一处,各写缺省值 = host manifest 的完整路径)——实测坑:只登记 Chrome
|
|
30
|
+
* 键时,用户在 Edge 里用扩展,一键启动报「Access to the specified native
|
|
31
|
+
* messaging host is forbidden」(浏览器只认自家的键,两家不互通);macOS
|
|
32
|
+
* 把 host manifest 投进三家浏览器的 NativeMessagingHosts 目录(Chrome/
|
|
33
|
+
* Edge/Chromium,~/Library/Application Support/ 下,免管理员)——同一款
|
|
34
|
+
* 脾气:浏览器只认自家目录里的登记。
|
|
29
35
|
*
|
|
30
|
-
* 仓库挪窝后 host manifest
|
|
36
|
+
* 仓库挪窝后 host manifest 里的壳路径会失效——服务下次启动自动重写(幂等)。
|
|
31
37
|
* manifest.json 的 key 一动 ID 就变——所有已装机器须重载扩展,服务下次启动
|
|
32
38
|
* 会自动按新 ID 重登记。
|
|
33
39
|
*/
|
|
@@ -37,10 +43,20 @@ import { execSync } from 'node:child_process';
|
|
|
37
43
|
import { fileURLToPath } from 'node:url';
|
|
38
44
|
import path from 'node:path';
|
|
39
45
|
import fs from 'node:fs';
|
|
46
|
+
import os from 'node:os';
|
|
40
47
|
|
|
41
48
|
export const ADAPTER_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
42
49
|
export const HOST_NAME = 'com.femo.web_launcher';
|
|
43
50
|
|
|
51
|
+
// macOS 登记:浏览器只认自家 NativeMessagingHosts 目录里的 host manifest
|
|
52
|
+
// (与 Windows 只认自家注册表键同款脾气),Chrome / Edge / Chromium 三家各投
|
|
53
|
+
// 一份,免管理员,幂等。其他 Chromium 系(Brave/Arc 等)目录各异,用到再补。
|
|
54
|
+
const DARWIN_HOST_DIRS = [
|
|
55
|
+
'Library/Application Support/Google/Chrome/NativeMessagingHosts',
|
|
56
|
+
'Library/Application Support/Microsoft Edge/NativeMessagingHosts',
|
|
57
|
+
'Library/Application Support/Chromium/NativeMessagingHosts',
|
|
58
|
+
];
|
|
59
|
+
|
|
44
60
|
const CSC_CANDIDATES = [
|
|
45
61
|
'C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\csc.exe',
|
|
46
62
|
'C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\csc.exe',
|
|
@@ -67,35 +83,60 @@ export function registerNativeHost({ root = ADAPTER_ROOT, nodeExe = process.exec
|
|
|
67
83
|
const hostManifestPath = path.join(nativeDir, `${HOST_NAME}.json`);
|
|
68
84
|
const launcherExe = path.join(nativeDir, 'web-launcher.exe');
|
|
69
85
|
const launcherCs = path.join(nativeDir, 'web-launcher.cs');
|
|
86
|
+
const launcherSh = path.join(nativeDir, 'web-launcher.sh');
|
|
70
87
|
const nodeHint = path.join(nativeDir, 'node.path');
|
|
71
88
|
|
|
72
89
|
// ── 1) host manifest ──
|
|
73
|
-
// path
|
|
90
|
+
// path 按平台分流:Windows=exe 壳(批处理壳在新内核上起不来,见文件头实测坑);
|
|
91
|
+
// macOS=sh 壳(exec 直替进程,stdio 帧原样继承,无需编译,见 web-launcher.sh)。
|
|
74
92
|
const manifest = {
|
|
75
93
|
name: HOST_NAME,
|
|
76
94
|
description: 'FEMO 网页座席:按侧栏指令拉起本地服务(node server/service.mjs)。',
|
|
77
|
-
path: launcherExe,
|
|
95
|
+
path: process.platform === 'win32' ? launcherExe : launcherSh,
|
|
78
96
|
type: 'stdio',
|
|
79
97
|
allowed_origins: [`chrome-extension://${extId}/`],
|
|
80
98
|
};
|
|
81
99
|
fs.writeFileSync(hostManifestPath, JSON.stringify(manifest, null, 2), 'utf8');
|
|
82
100
|
|
|
83
|
-
// ── 2) exe 壳:缺或比源码旧就编译;node.path 提示文件同批写 ──
|
|
84
101
|
let compiled = false;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
102
|
+
const registered = [];
|
|
103
|
+
|
|
104
|
+
if (process.platform === 'win32') {
|
|
105
|
+
// ── 2) exe 壳:缺或比源码旧就编译;node.path 提示文件同批写(Windows 专用)──
|
|
106
|
+
if (!fs.existsSync(launcherExe) || fs.statSync(launcherExe).mtimeMs < fs.statSync(launcherCs).mtimeMs) {
|
|
107
|
+
const csc = CSC_CANDIDATES.find(p => fs.existsSync(p));
|
|
108
|
+
if (!csc) {
|
|
109
|
+
throw new Error('找不到 csc.exe(.NET Framework 自带),编不了 web-launcher.exe;请装 .NET Framework 4.x 或手动编译后重跑');
|
|
110
|
+
}
|
|
111
|
+
execSync(`"${csc}" /nologo /out:"${launcherExe}" /target:exe "${launcherCs}"`, { stdio: 'pipe' });
|
|
112
|
+
compiled = true;
|
|
89
113
|
}
|
|
90
|
-
|
|
91
|
-
compiled = true;
|
|
92
|
-
}
|
|
93
|
-
fs.writeFileSync(nodeHint, nodeExe + '\n', 'utf8');
|
|
114
|
+
fs.writeFileSync(nodeHint, nodeExe + '\n', 'utf8');
|
|
94
115
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
116
|
+
// ── 3) HKCU 注册表(Chrome 与 Edge 双键同登)──
|
|
117
|
+
for (const hive of ['Google\\Chrome', 'Microsoft\\Edge']) {
|
|
118
|
+
execSync(`reg add "HKCU\\Software\\${hive}\\NativeMessagingHosts\\${HOST_NAME}" /ve /d "${hostManifestPath}" /f`, { stdio: 'pipe' });
|
|
119
|
+
registered.push(`HKCU\\Software\\${hive}\\NativeMessagingHosts\\${HOST_NAME}`);
|
|
120
|
+
}
|
|
121
|
+
} else if (process.platform === 'darwin') {
|
|
122
|
+
// ── 2) sh 壳可执行位兜底(git/tar 都可能丢 x 位)+ node.path 提示文件同款写 ──
|
|
123
|
+
if (!fs.existsSync(launcherSh)) {
|
|
124
|
+
throw new Error('native/web-launcher.sh 不见了——它是 macOS 版 Native Messaging 宿主壳,登记无从谈起');
|
|
125
|
+
}
|
|
126
|
+
fs.chmodSync(launcherSh, 0o755);
|
|
127
|
+
fs.writeFileSync(nodeHint, nodeExe + '\n', 'utf8');
|
|
128
|
+
|
|
129
|
+
// ── 3) 三家浏览器 NativeMessagingHosts 目录各投一份 host manifest(免管理员,幂等)──
|
|
130
|
+
for (const rel of DARWIN_HOST_DIRS) {
|
|
131
|
+
const dir = path.join(os.homedir(), rel);
|
|
132
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
133
|
+
const dst = path.join(dir, `${HOST_NAME}.json`);
|
|
134
|
+
fs.writeFileSync(dst, JSON.stringify(manifest, null, 2), 'utf8');
|
|
135
|
+
registered.push(dst);
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
throw new Error(`暂不支持的平台 ${process.platform}:原生宿主登记只做了 Windows(exe+注册表)与 macOS(sh 壳+NativeMessagingHosts 目录)`);
|
|
98
139
|
}
|
|
99
140
|
|
|
100
|
-
return { extId, hostManifestPath, compiled, nodeHint };
|
|
141
|
+
return { extId, hostManifestPath, compiled, nodeHint, registered };
|
|
101
142
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# web-launcher.sh — macOS 版 Native Messaging 宿主壳(web-launcher.exe 的 mac 对应物)。
|
|
3
|
+
#
|
|
4
|
+
# 链路:扩展 background 经 chrome.runtime.sendNativeMessage 发一帧 {"cmd":"start"}
|
|
5
|
+
# → Chrome 按 NativeMessagingHosts 目录登记的 host manifest 拉起本脚本
|
|
6
|
+
# → 本脚本定位 node 后用 exec 把自己替换成 `node web-launcher.mjs`:
|
|
7
|
+
# exec 不开子进程、stdio(含 4 字节小端长度前缀帧)原样继承,帧零改写——
|
|
8
|
+
# 所以 mac 上不需要像 Windows 那样编译 exe 壳(Windows 是批处理壳起不来才编译的)。
|
|
9
|
+
# 全部真实逻辑在 web-launcher.mjs;本壳只负责找到 node(与 web-launcher.cs 同一套
|
|
10
|
+
# 查找顺序:PATH → 常见安装位 → node.path 提示文件。Chrome 拉起的进程 PATH 极简,
|
|
11
|
+
# 提示文件是主用例——register-core.mjs 在服务启动时写入本机 node 绝对路径)。
|
|
12
|
+
DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
13
|
+
|
|
14
|
+
NODE_BIN=""
|
|
15
|
+
if command -v node >/dev/null 2>&1; then
|
|
16
|
+
NODE_BIN="$(command -v node)"
|
|
17
|
+
else
|
|
18
|
+
for c in /opt/homebrew/bin/node /usr/local/bin/node; do
|
|
19
|
+
[ -x "$c" ] && NODE_BIN="$c" && break
|
|
20
|
+
done
|
|
21
|
+
fi
|
|
22
|
+
if [ -z "$NODE_BIN" ] && [ -f "$DIR/node.path" ]; then
|
|
23
|
+
HINT="$(tr -d '\r\n ' < "$DIR/node.path")"
|
|
24
|
+
[ -x "$HINT" ] && NODE_BIN="$HINT"
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
if [ -z "$NODE_BIN" ]; then
|
|
28
|
+
# 找不到 node:按 Native Messaging 帧格式回一帧错误(4 字节小端长度 + JSON),
|
|
29
|
+
# 与 web-launcher.cs 的 ReplyError 同款,别让扩展只见「host 无响应」。
|
|
30
|
+
MSG='{"ok":false,"error":"node not found: install Node.js 18+, put node on PATH, or start the local service once so the node.path hint file gets written"}'
|
|
31
|
+
LEN=$(printf '%s' "$MSG" | wc -c | tr -d ' ')
|
|
32
|
+
# 长度按 4 字节小端写出(现实假设:LEN < 256,消息是固定短句)
|
|
33
|
+
printf "$(printf '\\%03o\\000\\000\\000' "$LEN")%s" "$MSG"
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
exec "$NODE_BIN" "$DIR/web-launcher.mjs" "$@"
|
|
@@ -136,12 +136,15 @@ webAdapter/ ← chrome://extensions 加载这个目录
|
|
|
136
136
|
│ │ (多站点:按注册表匹配标签页/围栏/开页/补注入;SW=module)
|
|
137
137
|
│ ├── bubble.js FEMO 悬浮球——机器公共 UI:在役站点都亮(background 按
|
|
138
138
|
│ │ PROBE_MODE 统一附加),取证站点不亮;点击开侧栏、拖拽、右键暂隐
|
|
139
|
-
│ ├── sidepanel.html
|
|
140
|
-
│ │
|
|
141
|
-
│ │
|
|
139
|
+
│ ├── sidepanel.html 席位面板壳(四标签页:演员/灵魂/投影中心/调试——演员页
|
|
140
|
+
│ │ 2026-10-10 由灵魂页复制,卡序=人类席/FEMO脚本/席位/
|
|
141
|
+
│ │ 快捷;投影中心标签内嵌本地 hub 页;样式内联;字体链
|
|
142
|
+
│ │ 首位带生僻字补字字体(数据内嵌,同上口径,2026-10-08))
|
|
142
143
|
│ └── sidepanel/ 面板逻辑模块(module):main 总装(状态线/轮询/标签页/
|
|
143
|
-
│
|
|
144
|
-
│
|
|
144
|
+
│ 共享卡按页归位/投影 iframe)+ seats 席位卡 / actors 演员
|
|
145
|
+
│ 席位卡(真绑定,@ 全名)/ reconnect 状态点重连(两个
|
|
146
|
+
│ 席位页共吃)/ feeds 收话与流水 / human-seat 人类席 /
|
|
147
|
+
│ run-control 挂载运行与状态线(点名含演员两桶)/
|
|
145
148
|
│ svclog 服务日志 / conn 通道
|
|
146
149
|
├── tests/ node --test 单测 + 真引擎/服务冒烟
|
|
147
150
|
└── web.host.manifest.json 宿主清单(host=web)
|
|
@@ -167,6 +170,27 @@ webAdapter/ ← chrome://extensions 加载这个目录
|
|
|
167
170
|
赋值契约、运行回执措辞——唯一活在 `shared/`,画法(侧栏卡片/操作台表格)
|
|
168
171
|
留各页。同一把尺子:同样的判断写两份就必然漂移(操作台人类席漏变量赋值
|
|
169
172
|
就是实案)。
|
|
173
|
+
- **演员标签页(2026-10-10)**:侧栏「演员」标签(在灵魂页左边,用户拍板),版式
|
|
174
|
+
自灵魂页复制、卡序改「FEMO脚本在前、席位在后」(快捷卡照旧压底,人类席卡照旧
|
|
175
|
+
最顶上);两页的席位卡各养各的容器、各画各的文案,但**人类席卡/FEMO脚本卡/
|
|
176
|
+
快捷卡三张共用同一份 DOM**——切页时总装按各页版式搬运归位,不复制第二份模块
|
|
177
|
+
逻辑(绑定/挂载/运行的状态两页天然一致);点状态点重连的流程也收成一份
|
|
178
|
+
(reconnect 件)。
|
|
179
|
+
- **演员绑定账——第二本账(2026-10-10)**:与 cast 选角账(键=soul)平行的第二本
|
|
180
|
+
账,键=**@actor 全名照抄**(@ 是名字的一部分,语法文档铁律「任何地方不得去掉」),
|
|
181
|
+
正身住 hub `actor-preferences.json`(与 cast-preferences 同构:提名制、一席一格、
|
|
182
|
+
seq 选举),公共层 `actor-core.mjs` 是宿主侧唯一读写口。条目带 **type** 格:
|
|
183
|
+
`ai`=绑定指向某宿主某会话(host+sid 正身)、`human`=绑定指向人(user_id 格先立
|
|
184
|
+
框架——**待补充 user id 存储逻辑**,多 user 是并行会话的活)、缺省=只提名未
|
|
185
|
+
定性(@actor 只带名字、开演前再定性为 ai/human 的预备基础设施)。本宿主 AI
|
|
186
|
+
会话绑定走 `/seats/actor-bind`,恒 type='ai'。
|
|
187
|
+
- **演员校验以 femo 脚本为先(2026-10-10 用户拍板,判据与灵魂不同)**:绑定与
|
|
188
|
+
点名都拿**已挂载脚本的演员表**(tools-core `scriptActors`——actors 区全量解析,
|
|
189
|
+
ai/human 都收、@ 全名、source:main 也在内)对账:绑了剧本里没有的演员=绑错
|
|
190
|
+
名字,**报错拦下**(绑定当场 404;换剧本后点名再拦);少绑=**warning 不拦运行**
|
|
191
|
+
(点名 actorCheck.warnings 随回执上墙,文案自带「不拦运行」)。引擎的四桶错误
|
|
192
|
+
分类(FEMO_errors.py)住引擎进程内,femo2host 不引引擎件——宿主侧校验口径
|
|
193
|
+
照例住 shared/ 与公共层解析件。
|
|
170
194
|
- **本宿主拉起的引擎不开窗,关灯走侧栏「关闭服务」(2026-09-29)**:常驻引擎
|
|
171
195
|
被代拉时桌面那间日志镜窗是引擎自己开的(femo_daemon._open_console)——本
|
|
172
196
|
适配器拉桥时注入 hideConsole,引擎就自不开窗,桌面不再长黑窗。引擎的关灯
|
|
@@ -262,7 +286,7 @@ webAdapter/ ← chrome://extensions 加载这个目录
|
|
|
262
286
|
|
|
263
287
|
## 跑起来
|
|
264
288
|
|
|
265
|
-
|
|
289
|
+
**首选:侧栏一键启动**(新装机只需双击一次启动脚本:Windows `start-service.cmd`,macOS `start-service.command`)
|
|
266
290
|
|
|
267
291
|
1. 浏览器扩展页(chrome://extensions 或 edge://extensions)→ 开发者模式 →
|
|
268
292
|
加载解压扩展 → 选 webAdapter/ 本身(manifest.json 在适配器根,代码在
|
|
@@ -282,6 +306,21 @@ webAdapter/ ← chrome://extensions 加载这个目录
|
|
|
282
306
|
里的「一键启动本地服务」按钮也能靠 Native Messaging 把它拉起来(扩展→
|
|
283
307
|
Chrome→native/web-launcher → 拉起 node 服务,分离启动不随浏览器关闭而死;
|
|
284
308
|
已在跑时幂等不重复拉)。
|
|
309
|
+
**macOS 对应物**:双击 `femo-plugin/hostAdapter/webAdapter/start-service.command`
|
|
310
|
+
(Finder 双击=Terminal 打开;语义与 cmd 版同款:cd 到目录→`node server/service.mjs`,
|
|
311
|
+
启动即自动登记)。登记是同款三件套的 mac 版:host manifest 的 path 指向
|
|
312
|
+
`native/web-launcher.sh`(exec 直替进程的壳,stdio 帧原样继承,无需编译二进制),
|
|
313
|
+
`node.path` 提示文件同款写入(Chrome 拉起的宿主进程 PATH 极简,靠它找 node;
|
|
314
|
+
壳内查找顺序 PATH→/opt/homebrew/bin→/usr/local/bin→提示文件,与 exe 壳同款),
|
|
315
|
+
登记文件投进 `~/Library/Application Support/` 下 Google Chrome、Microsoft Edge、
|
|
316
|
+
Chromium 三家浏览器的 `NativeMessagingHosts/com.femo.web_launcher.json`
|
|
317
|
+
(免管理员,幂等;浏览器只认自家目录,与 Windows 只认自家注册表键同款脾气)。
|
|
318
|
+
侧栏横幅与一键启动报错指路按 `navigator.userAgent` 平台分流:mac 指
|
|
319
|
+
`.command`,Windows 指 `.cmd`。
|
|
320
|
+
**换电脑拷贝须知**:`native/com.femo.web_launcher.json` 与 `native/node.path`
|
|
321
|
+
是服务每次启动自动重写的**本机生成物**(内含本机绝对路径)——整包拷去别的
|
|
322
|
+
电脑不用带、也不该手动改,新机首次双击启动脚本即自动重生成;`user_data/`
|
|
323
|
+
是你的数据世界(角色库/台账/日志),带不带随你,不带则新机从零建世界。
|
|
285
324
|
3. `native/install-native-host.mjs` 降级为手动登记入口(改了 manifest 的 key
|
|
286
325
|
之后想立刻重登记、或不想启动服务只想登记时用),日常不用跑。
|
|
287
326
|
|
|
@@ -305,15 +344,17 @@ node server/service.mjs # 监听 127.0.0.1:8796;FEMO_WEB_PORT 可
|
|
|
305
344
|
**侧栏点「一键启动」报启动失败**——按顺序查:
|
|
306
345
|
|
|
307
346
|
1. 报错里含「原生消息宿主」字样 = 没登记:首次使用由于系统限制,必须由人
|
|
308
|
-
|
|
347
|
+
亲手双击启动脚本(Windows `femo-plugin\hostAdapter\webAdapter\start-service.cmd` /
|
|
348
|
+
macOS `femo-plugin/hostAdapter/webAdapter/start-service.command`)启动一次
|
|
309
349
|
(启动即自动登记;之后边栏一键启动永久可用),或手动
|
|
310
350
|
`node native/install-native-host.mjs`。报
|
|
311
351
|
「Access … forbidden」= 浏览器扩展页里的 ID 与登记的 allowed_origins 对不上
|
|
312
352
|
(多半是扩展没重载、还在用改 key 之前的旧 ID):重载扩展再看 ID。
|
|
313
353
|
报「Error when communicating with the native messaging host」= 宿主进程没
|
|
314
|
-
跑起来或帧没送到:新版 Chromium/Edge
|
|
315
|
-
|
|
316
|
-
|
|
354
|
+
跑起来或帧没送到:新版 Chromium/Edge 对宿主走「可执行文件直启」,Windows 上
|
|
355
|
+
批处理壳起不来——确认 host manifest 的 path 指的是启动壳(Windows=
|
|
356
|
+
`web-launcher.exe`,登记器会自动编译,缺 csc.exe 时按报错装 .NET Framework 4.x
|
|
357
|
+
后重跑;macOS=`web-launcher.sh`,登记器自动 chmod +x);本机 node 不在
|
|
317
358
|
系统 PATH 时靠 native/node.path 提示文件,别删它,node 挪窝后重启服务
|
|
318
359
|
(自动登记会刷新)。
|
|
319
360
|
2. 已登记还报「探活超时」= 服务拉起后起不来:手动跑 `node server/service.mjs`
|
|
@@ -37,7 +37,7 @@ export const PUSH_PATH = '/femo-plugin/mailbox-push';
|
|
|
37
37
|
* 常驻引擎直连客户端(对外接口 = 旧 BridgeClient:start/send/stop/alive/
|
|
38
38
|
* onEvent/onExited…)。
|
|
39
39
|
* @param {object} [opts]
|
|
40
|
-
* @param {string} [opts.python] Python 可执行名/路径(缺省 FEMO_PYTHON env >
|
|
40
|
+
* @param {string} [opts.python] Python 可执行名/路径(缺省 resolvePythonExe:FEMO_PYTHON env > python3 > python)
|
|
41
41
|
* @param {string} [opts.femoRoot] 引擎根(缺省 = 仓库根)
|
|
42
42
|
* @param {string} [opts.hostManifestPath] 宿主清单(缺省 = 适配器根 web.host.manifest.json)
|
|
43
43
|
* @param {(eventType: string, data: unknown) => void} [opts.onEvent] 引擎事件上抛
|
|
@@ -288,10 +288,10 @@ export function createFemoRuntime({ bridge, log = () => {}, deliverFrame, surfac
|
|
|
288
288
|
// ── 回合簿记 ────────────────────────────────────────────────────────
|
|
289
289
|
const turnId = (jobId, waitKey, attempt) => `${jobId}/${waitKey}/${attempt ?? 0}`;
|
|
290
290
|
|
|
291
|
-
function dropTurn(deliveryId) {
|
|
291
|
+
function dropTurn(deliveryId, { mark = true } = {}) {
|
|
292
292
|
const turn = inflight.get(deliveryId);
|
|
293
293
|
if (!turn) return undefined;
|
|
294
|
-
markTurnDone(turn);
|
|
294
|
+
if (mark) markTurnDone(turn);
|
|
295
295
|
clearTimeout(turn.execTimer);
|
|
296
296
|
clearTimeout(turn.stallTimer);
|
|
297
297
|
clearTimeout(turn.doneTimer);
|
|
@@ -617,7 +617,9 @@ export function createFemoRuntime({ bridge, log = () => {}, deliverFrame, surfac
|
|
|
617
617
|
return enterTurnGate(deliveryId, async () => {
|
|
618
618
|
let seat;
|
|
619
619
|
try {
|
|
620
|
-
|
|
620
|
+
// actor(2026-10-10「mailbox 认演员」):信上的执行者名(@ 全名)随行
|
|
621
|
+
// 进座位解析——演员定格账优先,cast 兜底在 resolveSeat 内部。
|
|
622
|
+
seat = await resolveSeat(jobId, soulId, d.actor_name || d.actor);
|
|
621
623
|
} catch (e) {
|
|
622
624
|
// 绑定在别家宿主:不是我们的活(信留驿站等对方自取)——静默跳过,放闸。
|
|
623
625
|
const foreign = foreignHostOf(e);
|
|
@@ -683,7 +685,11 @@ export function createFemoRuntime({ bridge, log = () => {}, deliverFrame, surfac
|
|
|
683
685
|
return enterTurnGate(deliveryId, async () => {
|
|
684
686
|
let seat;
|
|
685
687
|
try {
|
|
686
|
-
|
|
688
|
+
// 重演同款双读(2026-10-10):actor_name 是显示形态(@名(soul名)),
|
|
689
|
+
// 演员定格账键是 @ 全名基名——先拆括号再查,拆完原样传(@ 不去不加)。
|
|
690
|
+
const _retryActor = String(d.actor_name || actorName || '')
|
|
691
|
+
.replace(/([^)]*)$/, '').trim();
|
|
692
|
+
seat = await resolveSeat(jid, soulId, _retryActor);
|
|
687
693
|
} catch (e) {
|
|
688
694
|
// 绑定在别家宿主:重演也不归本宿主办(同首发裁决)——静默跳过,不弹提醒。
|
|
689
695
|
const foreign = foreignHostOf(e);
|
|
@@ -836,7 +842,12 @@ export function createFemoRuntime({ bridge, log = () => {}, deliverFrame, surfac
|
|
|
836
842
|
function abortAll(reason) {
|
|
837
843
|
seqQueue.length = 0; // 先清队:占闸回合的 dropTurn 放闸时不会再唤醒任何排队者
|
|
838
844
|
for (const turn of [...inflight.values()]) {
|
|
839
|
-
|
|
845
|
+
// 中止 ≠ 交卷(2026-10-11 j2731 实案):被按停的回合一个字节都没交,
|
|
846
|
+
// 绝不能落「已交卷」防重账——落了下一次续跑重发的同号拍会被「双来路
|
|
847
|
+
// 迟到拍」那条闸挡在门外,引擎在节点上永等(实案:停→续,重发的 _1
|
|
848
|
+
// 连吃两记 dedup,@DeepSeek 哑火)。页面随后完成的那段由交卷口按
|
|
849
|
+
// 「未知 deliveryId」丢弃,顺理成章。
|
|
850
|
+
dropTurn(turn.deliveryId, { mark: false });
|
|
840
851
|
log(`turn aborted (${reason}): ${turn.actorName} wait_key=${turn.waitKey}`);
|
|
841
852
|
}
|
|
842
853
|
if (rt.humanWait !== undefined) {
|
|
@@ -847,11 +858,46 @@ export function createFemoRuntime({ bridge, log = () => {}, deliverFrame, surfac
|
|
|
847
858
|
takeHumanWaitHead('any');
|
|
848
859
|
}
|
|
849
860
|
|
|
861
|
+
/** 续跑代际重置(2026-10-11 j2731 实案):引擎续跑重建 Runtime,拍子编号
|
|
862
|
+
* 计数器(内存态、不进断点档案)从 0 重计——(job, waitKey) 身份跨代作废。
|
|
863
|
+
* 不清账的话,上一代刚完成/刚被按停的 (job, ref=_1) 会把这代重发的同号
|
|
864
|
+
* 请求误判成「已在本场交卷」丢弃,引擎在 [AI发言] 上永等(实案取证:
|
|
865
|
+
* stop→abort 落了 _1 的已交卷账,续跑重发的 _1 双来路连吃两记 dedup)。
|
|
866
|
+
* 触发点选 flow_start(引擎 run 起点事件,每次开演/续跑都发、带 job_id):
|
|
867
|
+
* 与 ai_request 走同一条事件流 FIFO,先于本代任何派工到达,重置与判重
|
|
868
|
+
* 天然无竞态(play_start push 是另一条 HTTP 通道,排序无保障,不选它)。
|
|
869
|
+
* 只清本场防重账 + 释放在飞(释而不落账)——doneByWait(重试牌座位记忆)
|
|
870
|
+
* 不清:座位解析跨代仍然有效。 */
|
|
871
|
+
function resetJobGeneration(jobId) {
|
|
872
|
+
const jid = Number(jobId ?? 0);
|
|
873
|
+
if (!jid) return;
|
|
874
|
+
let released = 0;
|
|
875
|
+
let purged = 0;
|
|
876
|
+
for (const turn of [...inflight.values()]) {
|
|
877
|
+
if (turn.jobId === jid) {
|
|
878
|
+
dropTurn(turn.deliveryId, { mark: false });
|
|
879
|
+
released += 1;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
const prefix = `${jid}/`;
|
|
883
|
+
for (const id of [...doneLedger.keys()]) {
|
|
884
|
+
if (String(id).startsWith(prefix)) {
|
|
885
|
+
doneLedger.delete(id);
|
|
886
|
+
purged += 1;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
if (released || purged) {
|
|
890
|
+
log(`generation reset: job=${jid} 释放在飞 ${released} / 清防重账 ${purged}(续跑拍号从头数,跨代身份作废)`);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
850
894
|
// ── 桥事件接线(事件通道;push 通道在 service.mjs 的收件口路由里)──────
|
|
851
895
|
bridge.onEvent = (eventType, d) => {
|
|
852
896
|
const data = d ?? {};
|
|
853
897
|
rt.lastEventAt = Date.now();
|
|
854
898
|
try {
|
|
899
|
+
// 续跑代际重置:flow_start 先于本代任何 ai_request 到达(同一 FIFO)。
|
|
900
|
+
if (eventType === 'flow_start') resetJobGeneration(Number(data.job_id ?? 0));
|
|
855
901
|
if (eventType === 'ai_request') {
|
|
856
902
|
if (String(data.source ?? '') === 'main') {
|
|
857
903
|
// 主Agent回合双来路去重:push 先到已登记 → 事件现场跳过。
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
* 【灵魂绑定不住这里(2026-09-25 用户定案:全系统只记一笔账)】soul ↔ 会话的
|
|
12
12
|
* 映射正身住 hub cast 账(cast-preferences 偏好账,开演定格进 cast/<jobId>.json),
|
|
13
13
|
* 席位路由经 runtime 的 resolveSeat 查 hub(dsh 收件口同款 readJobCast 姿势)。
|
|
14
|
-
* 本文件早先自养的 soulOwner
|
|
14
|
+
* 本文件早先自养的 soulOwner 映射账已删——第二本账必然漂移。演员绑定账
|
|
15
|
+
* (actor↔会话/人类,2026-10-10)同款正身住 hub(actor-preferences.json),
|
|
16
|
+
* 两本账都只把展示镜像喂进 publicSeat。
|
|
15
17
|
*
|
|
16
18
|
* 在线/offline 由扩展连接(connId)的存在性推导:连接断 = 该连接的全部席位
|
|
17
19
|
* 离线(回来即复活)。pending 队列按席位挂:席位忙(上一轮还在回)时任务排队,
|
|
@@ -196,16 +198,18 @@ export function createSeatBoard({ log = () => {} } = {}) {
|
|
|
196
198
|
return seat ? seat.pending.length : 0;
|
|
197
199
|
}
|
|
198
200
|
|
|
199
|
-
/**
|
|
201
|
+
/** 展示镜像取值:先按席位引用精确对,再按裸 id 兼容对(hub 旧绑定存的
|
|
200
202
|
* 是无前缀的裸 id)。 */
|
|
201
|
-
function
|
|
203
|
+
function mirrorOf(seat, map) {
|
|
202
204
|
if (!map) return undefined;
|
|
203
205
|
if (map[seat.sessionId]) return map[seat.sessionId];
|
|
204
206
|
const i = seat.sessionId.indexOf(':');
|
|
205
207
|
return i > 0 ? map[seat.sessionId.slice(i + 1)] : undefined;
|
|
206
208
|
}
|
|
207
209
|
|
|
208
|
-
|
|
210
|
+
const soulOf = (seat, map) => mirrorOf(seat, map); // 灵魂展示镜像(cast 选角账喂入)
|
|
211
|
+
|
|
212
|
+
function publicSeat(seat, soulBySession, actorBySession) {
|
|
209
213
|
// 展示派生(账本不记):来源显示名与短 id 从会话引用拆出(sites.mjs 接缝);
|
|
210
214
|
// 引用拆不开(旧扩展上报的裸 id)时按席位物理账的 site 格认站补标签——
|
|
211
215
|
// 两样都没有的旧账,标签缺位、短 id 整串截断(一眼可辨=该重载扩展了)。
|
|
@@ -221,14 +225,15 @@ export function createSeatBoard({ log = () => {} } = {}) {
|
|
|
221
225
|
present: seat.present, // 标签页开着(哪怕休眠)——派工/点名按需唤醒的判据
|
|
222
226
|
busy: seat.busy,
|
|
223
227
|
soul: soulOf(seat, soulBySession) || undefined, // 展示镜像:调用方从 hub 偏好账视图算好传入
|
|
228
|
+
actor: mirrorOf(seat, actorBySession) || undefined, // 演员展示镜像(演员绑定账喂入,@全名)
|
|
224
229
|
isMain: mainSessionId === seat.sessionId,
|
|
225
230
|
pending: seat.pending.length,
|
|
226
231
|
lastSeenAt: seat.lastSeenAt,
|
|
227
232
|
};
|
|
228
233
|
}
|
|
229
234
|
|
|
230
|
-
function list(soulBySession) {
|
|
231
|
-
return [...seats.values()].map(s => publicSeat(s, soulBySession));
|
|
235
|
+
function list(soulBySession, actorBySession) {
|
|
236
|
+
return [...seats.values()].map(s => publicSeat(s, soulBySession, actorBySession));
|
|
232
237
|
}
|
|
233
238
|
|
|
234
239
|
return {
|