femo-plugin 1.0.4 → 1.0.6

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.
Files changed (112) hide show
  1. package/LICENSE +1 -1
  2. package/NOTICE +8 -0
  3. package/README.md +12 -1
  4. 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
  5. package/docs/ActiveRoadmaps//345/217/214user/346/226/275/345/267/245/346/270/205/345/215/225.md +326 -0
  6. 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
  7. package/femo2host/AGENTS.md +1 -1
  8. package/femo2host/femoGenConnector/engine-client.mjs +7 -2
  9. package/femo2host/femoGenConnector/file-dialogs.mjs +108 -2
  10. package/femo2host/femoToolcall/chronica.py +99 -19
  11. package/femo2host/femo_api.py +14 -1
  12. package/femo2host/host/actor-core.d.mts +25 -0
  13. package/femo2host/host/actor-core.mjs +72 -0
  14. package/femo2host/host/cast-core.d.mts +3 -0
  15. package/femo2host/host/cast-core.mjs +14 -0
  16. package/femo2host/host/daemon-client.mjs +59 -10
  17. package/femo2host/host/hub-render-core.d.mts +2 -0
  18. package/femo2host/host/hub-render-core.mjs +6 -2
  19. package/femo2host/host/run-state-core.d.mts +4 -0
  20. package/femo2host/host/run-state-core.mjs +4 -0
  21. package/femo2host/host/speech-core.mjs +11 -4
  22. package/femo2host/host/tools-core.d.mts +11 -0
  23. package/femo2host/host/tools-core.mjs +39 -0
  24. package/femo2host/mailbox.py +630 -545
  25. package/femo2host/projectionCenter/app.css +61 -0
  26. package/femo2host/projectionCenter/composer.mjs +233 -20
  27. package/femo2host/projectionCenter/identity.mjs +131 -0
  28. package/femo2host/projectionCenter/index.html +55 -1
  29. package/femo2host/projectionCenter/main.mjs +231 -35
  30. package/femo2host/projectionCenter/panels.mjs +108 -16
  31. package/femo2host/projectionCenter/render.mjs +813 -695
  32. package/femo2host/projectionCenter/state.mjs +30 -0
  33. package/femo2host/projectionCenter/util.mjs +28 -0
  34. package/femo2host/projection_hub.py +1796 -230
  35. package/femo2host/python/femo_bridge.py +303 -33
  36. package/femo2host/python/femo_daemon.py +1528 -1209
  37. package/femo2host/python/mirror_window.py +237 -0
  38. package/femoBridges/ContextExample.py +113 -71
  39. package/femoCompiler/AGENTS.md +1 -0
  40. package/femoCompiler/FEMO_parser.py +2641 -2567
  41. package/femoCompiler/FEMO_runtime.py +217 -44
  42. package/femoCompiler/FEMO_scope_resolver.py +26 -12
  43. package/femoCompiler/block_collector.py +24 -27
  44. package/femoCompiler/db_utils.py +560 -503
  45. package/femoCompiler/femoAsync.py +466 -436
  46. package/femoCompiler/func_registry.py +74 -0
  47. package/femoCompiler/protocol.py +127 -127
  48. package/femoCompiler/save_dialog.py +497 -446
  49. 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
  50. package/femoExamples/AI/350/201/212/345/244/251/345/256/244/random_wait_time.py +91 -2
  51. package/femoExamples/LuxFiat/luxfiat-loop.femo +0 -1
  52. package/femoExamples/LuxFiat/luxfiat-simple.femo +23 -24
  53. package/femoExamples/debug/347/245/236/345/231/250/debug/347/245/236/345/231/250.femo +221 -222
  54. package/femoExamples/discussion.femo +72 -72
  55. 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
  56. 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
  57. package/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200.femo +1 -2
  58. 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
  59. 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
  60. package/femoGen/document_ch.html +1 -0
  61. package/femoGen/document_en.html +1 -0
  62. package/femoGen/index.html +1 -0
  63. package/femoGen/intro_ch.html +1 -0
  64. package/femoGen/intro_en.html +1 -0
  65. package/femoGen/package.json +7 -0
  66. package/femoGen/public/femo-logo-slogan.svg +5 -0
  67. package/femoGen/public/femo-logo.svg +6 -1
  68. package/femoGen/src/femoParser.jsx +14 -0
  69. package/hostAdapter/dshAdapter/host/femo-skill.ts +23 -10
  70. package/hostAdapter/dshAdapter/host/routes/projection-input.ts +3 -0
  71. package/hostAdapter/dshAdapter/lib/client.js +20 -2
  72. package/hostAdapter/dshAdapter/lib/client.js.map +2 -2
  73. package/hostAdapter/dshAdapter/lib/main.js +161 -18
  74. package/hostAdapter/dshAdapter/lib/main.js.map +3 -3
  75. package/hostAdapter/dshAdapter/package.json +11 -1
  76. package/hostAdapter/webAdapter/console/index.html +13 -4
  77. package/hostAdapter/webAdapter/extension/background.js +16 -5
  78. package/hostAdapter/webAdapter/extension/seat-agent-core.js +836 -791
  79. package/hostAdapter/webAdapter/extension/sidepanel/actors.mjs +101 -0
  80. package/hostAdapter/webAdapter/extension/sidepanel/main.mjs +81 -20
  81. package/hostAdapter/webAdapter/extension/sidepanel/reconnect.mjs +33 -0
  82. package/hostAdapter/webAdapter/extension/sidepanel/run-control.mjs +22 -11
  83. package/hostAdapter/webAdapter/extension/sidepanel/seats.mjs +6 -20
  84. package/hostAdapter/webAdapter/extension/sidepanel.html +31 -8
  85. package/hostAdapter/webAdapter/native/install-native-host.mjs +1 -0
  86. package/hostAdapter/webAdapter/native/register-core.mjs +69 -28
  87. package/hostAdapter/webAdapter/native/web-launcher.sh +37 -0
  88. package/hostAdapter/webAdapter/package.json +7 -0
  89. package/hostAdapter/webAdapter/readme.md +51 -10
  90. package/hostAdapter/webAdapter/server/bridge.mjs +1 -1
  91. package/hostAdapter/webAdapter/server/runtime.mjs +51 -5
  92. package/hostAdapter/webAdapter/server/seats.mjs +11 -6
  93. package/hostAdapter/webAdapter/server/service.mjs +108 -15
  94. package/hostAdapter/webAdapter/shared/seats-core.mjs +31 -6
  95. package/hostAdapter/webAdapter/sites/chat.deepseek.com/SITE.md +7 -0
  96. package/hostAdapter/webAdapter/sites/chat.deepseek.com/content.js +83 -68
  97. package/hostAdapter/webAdapter/sites/chatglm.cn/inject.js +76 -4
  98. package/hostAdapter/webAdapter/sites/chatgpt.com/SITE.md +7 -1
  99. package/hostAdapter/webAdapter/sites/chatgpt.com/content.js +37 -5
  100. package/hostAdapter/webAdapter/sites/chatgpt.com/inject.js +40 -4
  101. package/hostAdapter/webAdapter/start-service.command +16 -0
  102. package/hostAdapter/webAdapter/tests/chatgpt-input.test.mjs +58 -0
  103. package/hostAdapter/webAdapter/tests/chatgpt-parser.test.mjs +37 -0
  104. package/hostAdapter/webAdapter/tests/deepseek-sanitize.test.mjs +68 -0
  105. package/hostAdapter/webAdapter/tests/runtime.test.mjs +42 -0
  106. package/hostAdapter/webAdapter/tests/seats-core.test.mjs +37 -1
  107. package/hostAdapter/webAdapter/tests/smoke-service.mjs +261 -232
  108. package/hostAdapter/zcodeAdapter/runtime/speech-collect.mjs +6 -0
  109. package/hostAdapter/zcodeAdapter/skills/femo/SKILL.md +3 -0
  110. package/hostAdapter/zcodeAdapter/tests/unbound-actors.test.mjs +51 -0
  111. package/package.json +7 -1
  112. package//350/257/255/346/263/225/346/226/207/346/241/243.md +1224 -1202
@@ -2,6 +2,8 @@ export type MirrorState = 'running' | 'suspended' | 'finished' | 'failed'
2
2
  export interface WaitingHumanLike {
3
3
  waitKey: string
4
4
  nodeName?: string
5
+ /** 2026-10-10 actor 随行格:引擎报的执行者显示名(可选,交卷透传用)。 */
6
+ actor?: string
5
7
  context?: string
6
8
  memory?: string
7
9
  showprompt?: string
@@ -46,6 +48,8 @@ export declare function noteNodeShowprompt(mirror: JobMirrorLike, nodeName: stri
46
48
  export interface WaitingHumanSnapshot {
47
49
  waitKey: string
48
50
  nodeName?: string
51
+ /** 2026-10-10 actor 随行格:老引擎事件无此键时 undefined。 */
52
+ actor?: string
49
53
  context: string
50
54
  memory: string
51
55
  showprompt?: string
@@ -136,6 +136,10 @@ export function waitingHumanFromEvent(d) {
136
136
  return {
137
137
  waitKey: String(d.wait_key ?? ''),
138
138
  nodeName: typeof d.node_name === 'string' ? d.node_name : undefined,
139
+ // actor(2026-10-10 随行格):引擎报的执行者显示名,原样随行;交卷时
140
+ // 透传 post_speech 信封(mailbox.actor 只入账不路由)。老引擎无此键时
141
+ // 为 undefined,交卷侧自然不填。
142
+ actor: typeof d.actor_name === 'string' && d.actor_name ? d.actor_name : undefined,
139
143
  context: typeof d.context === 'string' ? d.context : '',
140
144
  memory: typeof d.memory === 'string' ? d.memory : '',
141
145
  showprompt: typeof d.showprompt === 'string' ? d.showprompt : undefined,
@@ -34,25 +34,30 @@ export function lastStepReply(steps) {
34
34
  }
35
35
 
36
36
  /** 人类席交卷信封(post_speech 参数)。soul 缺省 'human';dsh 传等待 scope
37
- * 首选、投影页传引擎报的执行者名——soul 只进驿站账本,引擎路由只认 ref。 */
38
- export function humanSpeechArgs({ jobId, waitKey, soul, node, text, variables = {} }) {
37
+ * 首选、投影页传引擎报的执行者名——soul 只进驿站账本,引擎路由只认 ref。
38
+ * actor(2026-10-10 随行格):剧本角色名,可选;只随信入账不路由(mailbox
39
+ * 头注旁注),不带则信封无此格——老调用方零改动。 */
40
+ export function humanSpeechArgs({ jobId, waitKey, soul, node, text, variables = {}, actor }) {
39
41
  const cleanVars = {}
40
42
  for (const [k, v] of Object.entries(variables ?? {})) {
41
43
  if (typeof v === 'string' && v.trim().length > 0) cleanVars[k] = v.trim()
42
44
  }
45
+ const actorClean = String(actor ?? '').trim()
43
46
  return {
44
47
  job_id: jobId,
45
48
  wait_key: waitKey,
46
49
  soul: soul || 'human',
47
50
  ...(node ? { node } : {}),
51
+ ...(actorClean ? { actor: actorClean } : {}),
48
52
  payload: text,
49
53
  body: { chat_text: text, ...(Object.keys(cleanVars).length > 0 ? { variables: cleanVars } : {}) },
50
54
  }
51
55
  }
52
56
 
53
57
  /** 执行体(主Agent/AI 角色)交卷信封(post_speech 参数)。output 参数=台词
54
- * 文本(构造时合并进末步 reply,信封上不再有 output 字段);steps 可不给。 */
55
- export function executorSpeechArgs({ jobId, waitKey, soul = 'main', node, output, steps, modelId }) {
58
+ * 文本(构造时合并进末步 reply,信封上不再有 output 字段);steps 可不给。
59
+ * actor(2026-10-10 随行格):可选,剧本角色名;不带则信封无此格。 */
60
+ export function executorSpeechArgs({ jobId, waitKey, soul = 'main', node, output, steps, modelId, actor }) {
56
61
  const merged = (Array.isArray(steps) ? steps : [])
57
62
  .map(s => (s && typeof s === 'object' ? { ...s } : { reply: String(s ?? '') }))
58
63
  if (merged.length > 0) {
@@ -61,11 +66,13 @@ export function executorSpeechArgs({ jobId, waitKey, soul = 'main', node, output
61
66
  } else {
62
67
  merged.push({ step: 0, reply: output })
63
68
  }
69
+ const actorClean = String(actor ?? '').trim()
64
70
  return {
65
71
  job_id: jobId,
66
72
  wait_key: waitKey,
67
73
  soul,
68
74
  ...(node ? { node } : {}),
75
+ ...(actorClean ? { actor: actorClean } : {}),
69
76
  payload: output,
70
77
  body: {
71
78
  steps: merged,
@@ -26,6 +26,17 @@ export declare function normalizeChronicaOpts(args: Record<string, unknown>): {
26
26
  export declare function chronicaCliArgs(opts: { show?: number; list?: number; scope?: boolean; full?: boolean }): string[]
27
27
  export declare function validateSoulCreate(args: Record<string, unknown>): string | null
28
28
 
29
+ /** 剧本演员表解析(actors 区全量,actor 带 @ 全名;见 tools-core.mjs)。 */
30
+ export interface ScriptActorEntry {
31
+ actor: string
32
+ kind: 'ai' | 'human'
33
+ }
34
+ export declare function scriptActors(femoText: unknown): ScriptActorEntry[]
35
+ export declare function actorBindingDeltas(actors: ScriptActorEntry[], boundActorNames: unknown): {
36
+ errors: string[]
37
+ warnings: string[]
38
+ }
39
+
29
40
  /** 挂载状态(运行时内一份)。 */
30
41
  export interface MountState {
31
42
  get(): { femoText: string; scriptPath?: string; baseDir?: string; scriptName: string } | undefined
@@ -272,6 +272,45 @@ export function unboundActorSouls(femoText, nominatedSouls) {
272
272
  });
273
273
  }
274
274
 
275
+ /** 剧本演员表·全量版(2026-10-10 演员绑定账 accompanying 解析):提取 actors 区
276
+ * 全部角色 [{actor, kind}]——actor 带 @ 全名(@ 是名字的一部分,语法文档铁律
277
+ * 「代码中任何地方不得去掉」),kind=声明类型 'ai'|'human'(blueprint 蓝图角色
278
+ * 尚未实现、不收)。与 scriptActorSouls 是两把尺:那把服务「绑定窗口出演」
279
+ * (只收 ai、按 soul 对账),这把服务「演员绑定账」(ai/human 都记,账键=
280
+ * @全名)。source:main 是导演亲自出演,也算一个角色(他的戏份也要有人接——
281
+ * 演员绑定按戏内角色对账,不分谁演)。纯函数:femoText → 名单,方便单测。 */
282
+ export function scriptActors(femoText) {
283
+ const out = [];
284
+ let inActors = false;
285
+ for (const line of String(femoText ?? '').split(/\r?\n/)) {
286
+ if (/^\s*(meta|actors|vars|code|mainflow|module|action)\s*:/.test(line) || /^action\s/.test(line)) {
287
+ inActors = /^\s*actors\s*:/.test(line);
288
+ continue;
289
+ }
290
+ if (!inActors) continue;
291
+ const decl = line.match(/^\s*(ai|human)\s+@(\S+?)\s*=/);
292
+ if (!decl) continue;
293
+ out.push({ actor: `@${decl[2]}`, kind: decl[1] });
294
+ }
295
+ return out;
296
+ }
297
+
298
+ /** 演员绑定点名(web 宿主 /seats/attendance 用,2026-10-10):已挂载剧本的演员
299
+ * 逐个 × 演员绑定账——
300
+ * · 账里绑了剧本里没有的演员 = 多绑(绑错名字),每条一句报错(error);
301
+ * · 剧本要的演员账里没有 = 少绑,每条一句提醒(warning——不拦运行);
302
+ * 返回 {errors, warnings} 两个字符串数组。纯函数:演员表 + 已绑演员全名数组
303
+ * → 两桶,方便单测。 */
304
+ export function actorBindingDeltas(actors, boundActorNames) {
305
+ const bound = new Set((boundActorNames ?? []).map(n => String(n)));
306
+ const declared = new Set((actors ?? []).map(a => a.actor));
307
+ const errors = (boundActorNames ?? []).map(String).filter(n => n && !declared.has(n))
308
+ .map(n => `绑定的演员 ${n} 不在剧本演员表里——检查名字(演员名带 @,照剧本里写的那样)`);
309
+ const warnings = (actors ?? []).map(a => a.actor).filter(n => !bound.has(n))
310
+ .map(n => `演员 ${n} 还没绑定——轮到它时按缺员处置`);
311
+ return { errors, warnings };
312
+ }
313
+
275
314
  // ── 直连桥形态的完整执行体(zcode 用;dsh 的会话型执行体自备)────────
276
315
 
277
316
  /**