femo-plugin 1.0.0
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/LICENSE +201 -0
- package/README.md +627 -0
- package/femo2host/__init__.py +4 -0
- package/femo2host/femoToolcall/chronica.py +156 -0
- package/femo2host/femoToolcall/femo-chat.mjs +69 -0
- package/femo2host/femoToolcall/femo_debugger.py +1515 -0
- package/femo2host/femo_api.py +437 -0
- package/femo2host/femo_gen_api.jsx +77 -0
- package/femoBridges/ContextExample.py +555 -0
- package/femoBridges/MemoryExample.py +163 -0
- package/femoBridges/__init__.py +1 -0
- package/femoBridges/getDir/get_dir.py +56 -0
- package/femoBridges/getDir//344/275/240/345/217/257/344/273/245/350/256/276/345/256/232/344/273/273/346/204/217/346/226/207/344/273/266/345/244/271/344/270/272/347/224/250/346/210/267/346/225/260/346/215/256/346/226/207/344/273/266/345/244/271.txt +10 -0
- package/femoBridges/llmBridge.py +247 -0
- package/femoBridges/llmProviders.py +308 -0
- package/femoCompiler/FEMO_CLIrenderer.py +198 -0
- package/femoCompiler/FEMO_config.py +35 -0
- package/femoCompiler/FEMO_errors.py +278 -0
- package/femoCompiler/FEMO_interpreter.py +163 -0
- package/femoCompiler/FEMO_normalizer.py +396 -0
- package/femoCompiler/FEMO_parser.py +2468 -0
- package/femoCompiler/FEMO_runtime.py +3630 -0
- package/femoCompiler/FEMO_scope_resolver.py +209 -0
- package/femoCompiler/__init__.py +1 -0
- package/femoCompiler/actor_resolver.py +86 -0
- package/femoCompiler/block_collector.py +441 -0
- package/femoCompiler/db_utils.py +485 -0
- package/femoCompiler/femoAsync.py +401 -0
- package/femoCompiler/host_manifest.py +68 -0
- package/femoCompiler/job_manager.py +767 -0
- package/femoCompiler/protocol.py +126 -0
- package/femoCompiler/save_dialog.py +402 -0
- package/femoCompiler/task_world.py +544 -0
- package/femoCompiler/vars/__init__.py +19 -0
- package/femoCompiler/vars/checkpoint.py +113 -0
- package/femoCompiler/vars/env.py +686 -0
- package/femoCompiler/vars/evaluator.py +567 -0
- package/femoCompiler/vars/join.py +303 -0
- package/femoCompiler/vars/merge.py +157 -0
- package/femoCompiler/vars/model.py +245 -0
- package/femoExamples/AI/345/211/252/350/247/206/351/242/221/AI/345/211/252/350/247/206/351/242/221.femo +192 -0
- package/femoExamples/AI/350/201/212/345/244/251/345/256/244/group-chat.femo +42 -0
- package/femoExamples/AI/350/201/212/345/244/251/345/256/244/random_wait_time.py +10 -0
- package/femoExamples/LuxFiat/luxfiat.femo +38 -0
- package/femoExamples/LuxFiat/wait.py +29 -0
- package/femoExamples/debug/347/245/236/345/231/250/debug/347/245/236/345/231/250.femo +222 -0
- package/femoExamples/discussion.femo +70 -0
- package/femoExamples/goal-mode.femo +23 -0
- package/femoExamples//345/270/270/347/224/250/345/267/245/345/205/267python/wait.py +29 -0
- package/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils.py +205 -0
- package/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils2.py +324 -0
- 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 +544 -0
- package/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200.femo +331 -0
- package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225/undercover_utils.py +683 -0
- 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 +348 -0
- 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 +392 -0
- package/femoGen/document_ch.html +2352 -0
- package/femoGen/document_en.html +2279 -0
- package/femoGen/index.html +19 -0
- package/femoGen/intro_ch.html +942 -0
- package/femoGen/intro_en.html +932 -0
- package/femoGen/package-lock.json +1698 -0
- package/femoGen/package.json +19 -0
- package/femoGen/public/character_need.ttf +0 -0
- package/femoGen/public/favicon.ico +0 -0
- package/femoGen/public/femo-logo-slogan.svg +83 -0
- package/femoGen/public/femo-logo.svg +55 -0
- package/femoGen/public/logo-fullsize.ico +0 -0
- package/femoGen/src/FemoWorAuto.jsx +5444 -0
- package/femoGen/src/actionModal.jsx +358 -0
- package/femoGen/src/bubbleOverlay.jsx +701 -0
- package/femoGen/src/canvasNodes.jsx +608 -0
- package/femoGen/src/common.jsx +715 -0
- package/femoGen/src/debugPanel.jsx +530 -0
- package/femoGen/src/faIcons.jsx +84 -0
- package/femoGen/src/femoDiagnostics.js +122 -0
- package/femoGen/src/femoFileList.jsx +357 -0
- package/femoGen/src/femoGenerator.jsx +1198 -0
- package/femoGen/src/femoLog.js +107 -0
- package/femoGen/src/femoParser.jsx +2255 -0
- package/femoGen/src/femoPreview.jsx +297 -0
- package/femoGen/src/graphBuilder.jsx +358 -0
- package/femoGen/src/libPanel.jsx +519 -0
- package/femoGen/src/main.jsx +22 -0
- package/femoGen/src/mobileView.jsx +2796 -0
- package/femoGen/src/projectPanel.jsx +529 -0
- package/femoGen/src/soulModal.jsx +162 -0
- package/femoGen/src/styles/font.css +10 -0
- package/femoGen/src/themes.js +465 -0
- package/femoGen/src/useCanvasInteraction.jsx +319 -0
- package/femoGen/vite.config.js +28 -0
- package/femoGen//347/222/207/345/255/230/346/247/221.txt +15 -0
- package/hostAdapter/dshAdapter/README.md +68 -0
- package/hostAdapter/dshAdapter/build.mjs +75 -0
- package/hostAdapter/dshAdapter/client/client-ui/chat-node.tsx +339 -0
- package/hostAdapter/dshAdapter/client/client-ui/composer.tsx +997 -0
- package/hostAdapter/dshAdapter/client/client-ui/editor-page.tsx +726 -0
- package/hostAdapter/dshAdapter/client/client-ui/editor-view.tsx +88 -0
- package/hostAdapter/dshAdapter/client/client-ui/femo-stream-live.tsx +264 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/frame-router.ts +282 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/index.ts +44 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/ledger.ts +329 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/turn-view.tsx +211 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/window-id.ts +28 -0
- package/hostAdapter/dshAdapter/client/client-ui/stream-store.ts +550 -0
- package/hostAdapter/dshAdapter/client/client-ui/styles.ts +144 -0
- package/hostAdapter/dshAdapter/client/client-ui/view-button.tsx +572 -0
- package/hostAdapter/dshAdapter/client/client-ui/view-state.ts +61 -0
- package/hostAdapter/dshAdapter/client/client.tsx +518 -0
- package/hostAdapter/dshAdapter/client/fa-icons.tsx +112 -0
- package/hostAdapter/dshAdapter/client/femo-reasoning-row.tsx +103 -0
- package/hostAdapter/dshAdapter/client/lineage-fork-native.jsx +624 -0
- package/hostAdapter/dshAdapter/client/lineage-fork.jsx +585 -0
- package/hostAdapter/dshAdapter/cordis.patch.yml +8 -0
- package/hostAdapter/dshAdapter/dshPatch/DSH-0.1.2-fork/344/277/256/346/224/271/351/234/200/346/261/202.md +184 -0
- package/hostAdapter/dshAdapter/dshPatch/MEOW_MODIFICATIONS.md +3105 -0
- package/hostAdapter/dshAdapter/dshPatch/patch-dsh-0.1.2-alpha.1.py +313 -0
- package/hostAdapter/dshAdapter/host/api-retry.ts +141 -0
- package/hostAdapter/dshAdapter/host/bridge.ts +224 -0
- package/hostAdapter/dshAdapter/host/config.ts +124 -0
- package/hostAdapter/dshAdapter/host/debug-log.ts +29 -0
- package/hostAdapter/dshAdapter/host/debug-run.ts +793 -0
- package/hostAdapter/dshAdapter/host/diag-feed.ts +56 -0
- package/hostAdapter/dshAdapter/host/engine-events.ts +891 -0
- package/hostAdapter/dshAdapter/host/engine-transcript.ts +122 -0
- package/hostAdapter/dshAdapter/host/femo-files.ts +210 -0
- package/hostAdapter/dshAdapter/host/god-mirror.ts +234 -0
- package/hostAdapter/dshAdapter/host/host-log.ts +101 -0
- package/hostAdapter/dshAdapter/host/http.ts +66 -0
- package/hostAdapter/dshAdapter/host/index.ts +633 -0
- package/hostAdapter/dshAdapter/host/list-cache.ts +183 -0
- package/hostAdapter/dshAdapter/host/main-actor.ts +853 -0
- package/hostAdapter/dshAdapter/host/main-delivery-queue.ts +115 -0
- package/hostAdapter/dshAdapter/host/native-state.ts +21 -0
- package/hostAdapter/dshAdapter/host/node-retry.ts +246 -0
- package/hostAdapter/dshAdapter/host/persona.ts +146 -0
- package/hostAdapter/dshAdapter/host/pre-step-gate.ts +95 -0
- package/hostAdapter/dshAdapter/host/proj-trace.ts +49 -0
- package/hostAdapter/dshAdapter/host/projection-input.ts +238 -0
- package/hostAdapter/dshAdapter/host/projection.ts +742 -0
- package/hostAdapter/dshAdapter/host/routes.ts +1196 -0
- package/hostAdapter/dshAdapter/host/run-control.ts +641 -0
- package/hostAdapter/dshAdapter/host/safe-steer.ts +33 -0
- package/hostAdapter/dshAdapter/host/section-gate.ts +108 -0
- package/hostAdapter/dshAdapter/host/session-events.ts +45 -0
- package/hostAdapter/dshAdapter/host/state-files.ts +301 -0
- package/hostAdapter/dshAdapter/host/stream-frames.ts +229 -0
- package/hostAdapter/dshAdapter/host/subagent-native.ts +997 -0
- package/hostAdapter/dshAdapter/host/subagent.ts +1205 -0
- package/hostAdapter/dshAdapter/host/tools.ts +486 -0
- package/hostAdapter/dshAdapter/host/windowing-native.ts +294 -0
- package/hostAdapter/dshAdapter/host.manifest.json +6 -0
- package/hostAdapter/dshAdapter/lib/client.js +19161 -0
- package/hostAdapter/dshAdapter/lib/client.js.map +7 -0
- package/hostAdapter/dshAdapter/lib/index.js +8173 -0
- package/hostAdapter/dshAdapter/lib/index.js.map +7 -0
- package/hostAdapter/dshAdapter/package-lock.json +500 -0
- package/hostAdapter/dshAdapter/package.json +55 -0
- package/hostAdapter/dshAdapter/pnpm-lock.yaml +596 -0
- package/hostAdapter/dshAdapter/pnpm-workspace.yaml +2 -0
- package/hostAdapter/dshAdapter/python/dev-bridge-test.py +43 -0
- package/hostAdapter/dshAdapter/python/femo_bridge.py +533 -0
- package/hostAdapter/dshAdapter/tsconfig.host.json +9 -0
- package/hostAdapter/dshAdapter/tsconfig.json +21 -0
- package/package.json +40 -0
- package//350/257/255/346/263/225/346/226/207/346/241/243.md +1136 -0
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* femo-plugin client half (browser) — 浏览器端总装车间。
|
|
3
|
+
*
|
|
4
|
+
* 本文件是插件 web 侧的入口与总装:把 client-ui/ 子目录的各职责模块注册进
|
|
5
|
+
* dsh web 的 slots/conversationEvents。全部 UI 组件、store、样式都在子模块:
|
|
6
|
+
*
|
|
7
|
+
* client-ui/stream-store.ts femo_stream 直播缓冲 + SSE 单例 + useFemoStream
|
|
8
|
+
* client-ui/view-state.ts 视角状态 store + useView/getView/setView
|
|
9
|
+
* client-ui/styles.ts femo-stream 样式表一次性注入
|
|
10
|
+
* client-ui/femo-stream-live.tsx 直播块渲染件(speaker/导演锚点共用)
|
|
11
|
+
* client-ui/chat-node.tsx femo-plugin/chat 节点定义 + 行渲染视图
|
|
12
|
+
* client-ui/director-node.tsx 导演直播锚点节点定义 + 视图
|
|
13
|
+
* client-ui/editor-view.tsx 「Femo 编辑器」标签页(画布宿主壳+冲突弹窗)
|
|
14
|
+
* client-ui/view-button.tsx 视角菜单按钮 + CSS 过滤 + 计数座位
|
|
15
|
+
* client-ui/composer.tsx 投影窗可输入 composer
|
|
16
|
+
*
|
|
17
|
+
* All @deepseek-ai imports are type-only or shell singletons (external in the
|
|
18
|
+
* bundle); the only other runtime dependency is react (shell singleton).
|
|
19
|
+
* (2026-08-26 结构整理:原 2070 行单文件按职责拆分为上述模块,本文件只剩
|
|
20
|
+
* 总装,行为零变化。)
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { SubagentHeaderLineage as FemoLineage } from './lineage-fork.jsx'
|
|
24
|
+
import { SubagentHeaderLineage as FemoLineageNative } from './lineage-fork-native.jsx'
|
|
25
|
+
// client-ui 拆出件。
|
|
26
|
+
import { ensureFemoStreamStyles } from './client-ui/styles'
|
|
27
|
+
import { FemoChatNodeView, femoChatDefinition } from './client-ui/chat-node'
|
|
28
|
+
// 【2026-09-11 步3】director-node(主模型发言的旧锚点注册表)已删除:主 Agent
|
|
29
|
+
// 轮并入统一轮台账(宿主侧 engine-events 写开轮锚点 + 导演流帧带 turn),
|
|
30
|
+
// 打字机由 femo2-turn-live 按轮承担。
|
|
31
|
+
// 【显示层 v9(proj2)】轮台账 + 唯一渲染器(头/直播尾)。
|
|
32
|
+
// 【2026-09-11 步2】V5/V6/V7 三代旧渲染位(turn-nodes.tsx 的 femo-turn-head /
|
|
33
|
+
// femo-turn-stream / femo-live-tail)已删除——它们各自带一套"这块属于谁"的判据,
|
|
34
|
+
// 与新链路同抢一份数据。旧文件留在 client-ui/turn-nodes.tsx.bak-proj2-step2-20260911。
|
|
35
|
+
import {
|
|
36
|
+
Femo2TurnLiveNodeView, Femo2TurnNodeView, proj2Enabled, registerProj2Nodes,
|
|
37
|
+
} from './client-ui/proj2'
|
|
38
|
+
import { FemoEditorView, type ScriptViewInjected } from './client-ui/editor-view'
|
|
39
|
+
import { mountFemoEditorPage } from './client-ui/editor-page'
|
|
40
|
+
import { FemoSubagentCount, FemoViewButton, type FemoViewInjected } from './client-ui/view-button'
|
|
41
|
+
import { ProjectionComposer, type ProjectionComposerInjected } from './client-ui/composer'
|
|
42
|
+
|
|
43
|
+
/** Peer packages this plugin needs injected.
|
|
44
|
+
* (workspaces 原为侧边栏按钮 currentCwd 所需,2026-08-30 随按钮移除。)
|
|
45
|
+
* 2026-09-04:conversationEvents 从 inject 移除——rc.1 改名 uiConversation 且
|
|
46
|
+
* register 挂到 .events 下,静态名单无法双版本声明,改为 apply 内双名探测+重试。 */
|
|
47
|
+
export const inject: string[] = ['slots', 'sessions', 'layout']
|
|
48
|
+
|
|
49
|
+
// ── plugin body ───────────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Browser plugin body: register the chat nodes and all slots.
|
|
53
|
+
* @param ctx - client root context.
|
|
54
|
+
*/
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
export function apply(ctx: any): void {
|
|
57
|
+
ensureFemoStreamStyles()
|
|
58
|
+
// 【2026-09-05 连接池修复】不再页面级预开 SSE:apply() 时无条件 acquire 会让
|
|
59
|
+
// 每个页面(包括纯聊天页)常驻占一条 HTTP/1.1 长连接——HMR ws + mux ws +
|
|
60
|
+
// femo SSE = 3 条/页,同源两个标签就 6/6 饿死连接池(「第二个窗口打不开/
|
|
61
|
+
// 刷新打不开」真凶)。现改为按需连接:consumer 挂载期间各自 acquire/release
|
|
62
|
+
// (useFemoStream / useActorUsage / editor-page 有 target 时 / view-button 在
|
|
63
|
+
// femo 会话头部),非 femo 页面零 femo 长连接,行为对 femo 页面不变。
|
|
64
|
+
const slots = ctx?.get?.('slots') ?? ctx?.slots
|
|
65
|
+
if (slots === undefined || typeof slots.inject !== 'function') {
|
|
66
|
+
console.warn('[femo-plugin] slots service unavailable; UI not registered')
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70
|
+
const sessions = ctx?.get?.('sessions') as {
|
|
71
|
+
open?(id: string): void
|
|
72
|
+
openSubagent?(address: { parentSessionId: string; childSessionId: string; mode: string }): void
|
|
73
|
+
refreshSubagents?(parentSessionId: string): void
|
|
74
|
+
setSubagentCatalogOpen?(parentSessionId: string, open: boolean): void
|
|
75
|
+
/** 官方公开解析面(service.ts binding()):按 id 取会话 outward face。 */
|
|
76
|
+
binding?(id: string): { session?: unknown } | undefined
|
|
77
|
+
} | undefined
|
|
78
|
+
// 【调试面 2026-09-09】0.1.3 无 session 深链,自动化/排障需要从页面直达
|
|
79
|
+
// 会话视图:把只读的 sessions 动作面挂 window(open/refresh/catalog 均为
|
|
80
|
+
// 官方 service 透传,无副作用面;排障结束后可整体移除)。
|
|
81
|
+
;(window as unknown as Record<string, unknown>).__femoSessions = sessions
|
|
82
|
+
// 【版本分流信号】问服务端要 native 标志(0.1.3+ 原生路径)。
|
|
83
|
+
// - 旧版(meow fork):注册 femo 自绘的子代理目录 UI(fork lineage shadow
|
|
84
|
+
// + 计数座位,含 femo-node/femo-proj 过滤)——与历史行为一致。
|
|
85
|
+
// - 0.1.3 原生:注册 lineage-fork-native(结构/样式与本体一致,类名运行时
|
|
86
|
+
// 解析;旧 fork 硬编码的 rc.2 CSS 哈希在 0.1.3 已失效=菜单渲染成"页面最
|
|
87
|
+
// 右侧细竖条"的根因,故不能用旧 fork)。唯一差异=过滤:femo-proj(投影窗)
|
|
88
|
+
// 与 femo-actor(Job×角色常驻执行体子代理)一律不进目录(2026-09-09 晚
|
|
89
|
+
// 改版:重新 ban 节点拉起的子代理,对齐旧版效果——观看面只有视角投影窗);
|
|
90
|
+
// 本体自发子代理零影响。
|
|
91
|
+
// fetch 异常 fail-open 到旧版注册(保持 flag 不可达时的历史行为)。
|
|
92
|
+
;(window as unknown as Record<string, unknown>).__femoNative = false
|
|
93
|
+
void fetch('/femo-plugin/native-flag').then(r => r.json()).then((data: { ok?: boolean; native?: boolean }) => {
|
|
94
|
+
const native = data.ok === true && data.native === true
|
|
95
|
+
;(window as unknown as Record<string, unknown>).__femoNative = native
|
|
96
|
+
if (native) {
|
|
97
|
+
registerNativeCatalogFilter()
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
registerLegacyCatalogUi()
|
|
101
|
+
}).catch(() => {
|
|
102
|
+
registerLegacyCatalogUi()
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
// ── 会话节点注册(2026-09-04 rc.1 双兼容)─────────────────────────────
|
|
106
|
+
// rc.2:服务名 'conversationEvents'(client-runtime),register 直接挂根上;
|
|
107
|
+
// rc.1:服务名 'uiConversation'(ui-conversation),register 挂 .events 下。
|
|
108
|
+
// 两代定义形状一致({kind, match, start, update}),仅服务名/挂载点不同。
|
|
109
|
+
// 服务可能晚于本插件就绪(apply 早期 ctx.get 常为 undefined,探针实证),
|
|
110
|
+
// 双名探测 + 1s×20 重试(meow-memory 同款上限)。
|
|
111
|
+
const proj2 = proj2Enabled()
|
|
112
|
+
const registerFemoNodes = (register: (def: unknown) => void): void => {
|
|
113
|
+
register(femoChatDefinition)
|
|
114
|
+
if (proj2) {
|
|
115
|
+
// 【显示层 v9】只注册两个定义:轮头 + 直播尾,共用一份轮台账。
|
|
116
|
+
registerProj2Nodes(register)
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
// 【2026-09-11 步2】V5/V6/V7 三代渲染位已删(见文件顶 import 处注释)。
|
|
120
|
+
// `?proj2=0` 现在=**降级模式**:只留普通行 + 导演锚,投影窗靠官方区块自绘
|
|
121
|
+
// (有内容、有顺序,但没有角色名行与流式打字机)——保留它是为万一新链路
|
|
122
|
+
// 出问题时还有一个"能看"的退路,日常不该用。
|
|
123
|
+
console.log('[femo-plugin] femo conversation nodes registered (degraded: role only)')
|
|
124
|
+
}
|
|
125
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
126
|
+
const resolveNodeRegistry = (): ((def: unknown) => void) | undefined => {
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
+
const ui = ctx?.get?.('uiConversation') as any
|
|
129
|
+
if (ui?.events?.register !== undefined) {
|
|
130
|
+
return (def: unknown): void => { ui.events.register(def) }
|
|
131
|
+
}
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
+
const legacy = ctx?.get?.('conversationEvents') as any
|
|
134
|
+
if (legacy?.register !== undefined) return (def: unknown): void => { legacy.register(def) }
|
|
135
|
+
return undefined
|
|
136
|
+
}
|
|
137
|
+
const nodeRegistry = resolveNodeRegistry()
|
|
138
|
+
if (nodeRegistry !== undefined) {
|
|
139
|
+
registerFemoNodes(nodeRegistry)
|
|
140
|
+
} else {
|
|
141
|
+
let tries = 0
|
|
142
|
+
const nodeRegistryTimer = setInterval(() => {
|
|
143
|
+
tries += 1
|
|
144
|
+
const found = resolveNodeRegistry()
|
|
145
|
+
if (found !== undefined) {
|
|
146
|
+
clearInterval(nodeRegistryTimer)
|
|
147
|
+
registerFemoNodes(found)
|
|
148
|
+
} else if (tries >= 20) {
|
|
149
|
+
clearInterval(nodeRegistryTimer)
|
|
150
|
+
console.warn('[femo-plugin] conversation node registry unavailable after 20s; femo-role node not registered')
|
|
151
|
+
}
|
|
152
|
+
}, 1000)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// 剧本列表/保存注入面(编辑器页 ScriptView 复用)。原第三字段
|
|
156
|
+
// createFemoSession 与 currentCwd/workspaces 解析链随侧边栏按钮一同移除
|
|
157
|
+
// (2026-08-30,唯一消费者就是该按钮)。
|
|
158
|
+
const injected = () => ({
|
|
159
|
+
listScripts: async (): Promise<string[]> => {
|
|
160
|
+
const response = await fetch('/femo-plugin/scripts')
|
|
161
|
+
if (!response.ok) throw new Error(`scripts HTTP ${response.status}`)
|
|
162
|
+
const data = await response.json() as { ok?: boolean; scripts?: string[]; error?: string }
|
|
163
|
+
if (data.ok !== true || data.scripts === undefined) {
|
|
164
|
+
throw new Error(data.error ?? 'list scripts failed')
|
|
165
|
+
}
|
|
166
|
+
return data.scripts
|
|
167
|
+
},
|
|
168
|
+
saveScript: async (name: string, content: string, sessionId?: string): Promise<string> => {
|
|
169
|
+
// 绝对路径(导出流程选目录拼出的完整路径)→ path 直写;
|
|
170
|
+
// 否则按 name 存 user_data/projects/。
|
|
171
|
+
// sessionId 带上则 host 顺写会话记录 {path, text}(导出/覆盖保存统一格式)。
|
|
172
|
+
const isPath = /^[a-zA-Z]:[\\/]/.test(name) || name.startsWith('/') || name.startsWith('\\\\')
|
|
173
|
+
const response = await fetch('/femo-plugin/save-script', {
|
|
174
|
+
method: 'POST',
|
|
175
|
+
headers: { 'content-type': 'application/json' },
|
|
176
|
+
body: JSON.stringify({
|
|
177
|
+
...(isPath ? { path: name } : { name }),
|
|
178
|
+
content,
|
|
179
|
+
...(sessionId !== undefined ? { sessionId } : {}),
|
|
180
|
+
}),
|
|
181
|
+
})
|
|
182
|
+
if (!response.ok) {
|
|
183
|
+
// 透出服务端 error 正文(如 400 的具体原因),不再只报状态码。
|
|
184
|
+
let detail = ''
|
|
185
|
+
try {
|
|
186
|
+
const errData = await response.json() as { error?: string }
|
|
187
|
+
if (typeof errData.error === 'string' && errData.error.length > 0) detail = `: ${errData.error}`
|
|
188
|
+
} catch {
|
|
189
|
+
// non-JSON body: keep the status-only message
|
|
190
|
+
}
|
|
191
|
+
throw new Error(`save-script HTTP ${response.status}${detail}`)
|
|
192
|
+
}
|
|
193
|
+
const data = await response.json() as { ok?: boolean; path?: string; error?: string }
|
|
194
|
+
if (data.ok !== true || data.path === undefined) {
|
|
195
|
+
throw new Error(data.error ?? 'save-script failed')
|
|
196
|
+
}
|
|
197
|
+
return data.path
|
|
198
|
+
},
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
// FemoViewButton 注入:打开任意会话(视角菜单跳转投影窗用)+ 投影窗 id 查询。
|
|
202
|
+
const viewInjected = (): FemoViewInjected => ({
|
|
203
|
+
// 预热父会话子代理目录(0.1.3 目录冷加载较慢,菜单打开时提前拉)。
|
|
204
|
+
warmCatalog: (sid: string): void => {
|
|
205
|
+
try { sessions?.refreshSubagents?.(sid) } catch { /* 服务不可用忽略 */ }
|
|
206
|
+
},
|
|
207
|
+
openSession: (id: string, parentSessionId?: string): void => {
|
|
208
|
+
// 【0.1.3 API 变更】subagent 来源会话(femo-proj 投影窗)的历史加载必须
|
|
209
|
+
// 用「durable parent address」打开(官方 sessions.openSubagent),普通
|
|
210
|
+
// session 地址被宿主拒绝(session/agent-busy: subagent Sessions require
|
|
211
|
+
// their durable parent address,history.ts validateAddress)。旧版普通
|
|
212
|
+
// id 打开即合法,保持原路径不动。
|
|
213
|
+
// selectSubagent 还要求子项已在父目录缓存里(懒加载)——先 refresh,
|
|
214
|
+
// 轮询重试;目录一直不可得再退回普通打开(报错可见优于静默)。
|
|
215
|
+
const native = (window as unknown as Record<string, unknown>).__femoNative === true
|
|
216
|
+
// 【诊断 2026-09-11】开窗路径全程留痕:用户报"点上帝视角→菜单变了→窗口没切",
|
|
217
|
+
// 靠这条分辨卡在哪一步(native 标志 / 唤醒 fetch / openSubagent 重试/超时)。
|
|
218
|
+
if (native && parentSessionId !== undefined && id.startsWith('femo-proj-')
|
|
219
|
+
&& sessions?.openSubagent !== undefined) {
|
|
220
|
+
void (async (): Promise<void> => {
|
|
221
|
+
// 【2026-09-09 深夜五轮】先等宿主把本剧全部投影窗唤醒(ensure 幂等;
|
|
222
|
+
// 冷装载窗经镜像并集合并补齐内容、成为 live 会话),再开窗——否则
|
|
223
|
+
// history 首拉与唤醒竞速,命中空持久层 → 官方 blank 语义隐藏
|
|
224
|
+
// header/flow(白屏)。fetch 即唤醒载体:宿主 ensure 完成才返回。
|
|
225
|
+
let wakeOk = false
|
|
226
|
+
try {
|
|
227
|
+
const r = await fetch(`/femo-plugin/projection-windows?sessionId=${encodeURIComponent(parentSessionId)}`)
|
|
228
|
+
wakeOk = r.ok
|
|
229
|
+
} catch { /* 唤醒探测失败不阻塞开窗(回退原重试链) */ }
|
|
230
|
+
try { sessions.refreshSubagents?.(parentSessionId); } catch { /* 目录服务不可用则直接尝试 */ }
|
|
231
|
+
// 目录冷加载可能较慢(实测 15s+):重试窗口 20s,期间周期性 refresh。
|
|
232
|
+
for (let attempt = 0; attempt < 40; attempt += 1) {
|
|
233
|
+
try {
|
|
234
|
+
sessions.openSubagent({ parentSessionId, childSessionId: id, mode: 'one-shot' });
|
|
235
|
+
return;
|
|
236
|
+
} catch {
|
|
237
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
238
|
+
if (attempt % 5 === 4) { try { sessions.refreshSubagents?.(parentSessionId); } catch { /* 同上 */ } }
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
console.error('[femo-plugin] projection window open timed out (catalog never listed the child):', id)
|
|
242
|
+
})()
|
|
243
|
+
return
|
|
244
|
+
}
|
|
245
|
+
sessions?.open?.(id)
|
|
246
|
+
},
|
|
247
|
+
listProjectionWindows: async (sid: string): Promise<{ god?: string; stage?: string; actors: Record<string, string> }> => {
|
|
248
|
+
const response = await fetch(`/femo-plugin/projection-windows?sessionId=${encodeURIComponent(sid)}`)
|
|
249
|
+
if (!response.ok) throw new Error(`projection-windows HTTP ${response.status}`)
|
|
250
|
+
const data = await response.json() as { ok?: boolean; god?: string; stage?: string; actors?: Record<string, string> }
|
|
251
|
+
if (data.ok !== true) throw new Error(data.error ?? 'projection-windows failed')
|
|
252
|
+
return { god: data.god, stage: data.stage, actors: data.actors ?? {} }
|
|
253
|
+
},
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
// (侧边栏「🎭 Femo 剧本」入口按钮已于 2026-08-30 移除——sidebar.footer.action
|
|
257
|
+
// 槽位不再注册;新建 Femo 会话仍可用 host POST /femo-plugin/create-session API。)
|
|
258
|
+
|
|
259
|
+
slots.inject('conversation.chat.node', () => slots.register(
|
|
260
|
+
{
|
|
261
|
+
name: 'conversation.chat.node',
|
|
262
|
+
key: 'femo-role',
|
|
263
|
+
// locale 席位(2026-08-25 崩溃修复):不声明则 t 不注入,组件内
|
|
264
|
+
// t('copy') 直接 TypeError → SlotErrorBoundary 吞掉全部 femo 节点
|
|
265
|
+
// (流式锚点也随之消失=「说完才上屏」的真凶)。
|
|
266
|
+
locale: 'conversation',
|
|
267
|
+
},
|
|
268
|
+
FemoChatNodeView,
|
|
269
|
+
))
|
|
270
|
+
// 【2026-09-11 步3】femo-director 槽位随 director-node 定义一同删除。
|
|
271
|
+
if (proj2) {
|
|
272
|
+
// 【显示层 v9】两个渲染位:轮头(📢+名字+失败条)+ 直播尾(流式块+Deep diving)。
|
|
273
|
+
slots.inject('conversation.chat.node', () => slots.register(
|
|
274
|
+
{
|
|
275
|
+
name: 'conversation.chat.node',
|
|
276
|
+
key: 'femo2-turn',
|
|
277
|
+
locale: 'conversation',
|
|
278
|
+
},
|
|
279
|
+
Femo2TurnNodeView,
|
|
280
|
+
))
|
|
281
|
+
slots.inject('conversation.chat.node', () => slots.register(
|
|
282
|
+
{
|
|
283
|
+
name: 'conversation.chat.node',
|
|
284
|
+
key: 'femo2-turn-live',
|
|
285
|
+
locale: 'conversation',
|
|
286
|
+
},
|
|
287
|
+
Femo2TurnLiveNodeView,
|
|
288
|
+
))
|
|
289
|
+
}
|
|
290
|
+
// 【2026-09-11 步2】femo-turn-head / femo-turn-stream / femo-live-tail 三个槽位
|
|
291
|
+
// 随定义一同删除(定义与槽位必须成对,否则装配器找不到渲染件)。
|
|
292
|
+
// FemoViewButton:order -20 = preset 徽章(-10)之前、紧贴面包屑区——主窗口
|
|
293
|
+
// 「name / 👁视角 Femo剧本模式 …」;投影窗「母名 / 👁@演员」(fork 让位后
|
|
294
|
+
// 面包屑只剩斜杠,见 lineage-fork.jsx SubagentHeaderLineage)。
|
|
295
|
+
slots.inject('conversation.session.header.actions', () => slots.register(
|
|
296
|
+
{
|
|
297
|
+
name: 'conversation.session.header.actions',
|
|
298
|
+
id: 'femo-plugin-view',
|
|
299
|
+
order: -20,
|
|
300
|
+
inject: viewInjected,
|
|
301
|
+
},
|
|
302
|
+
FemoViewButton,
|
|
303
|
+
))
|
|
304
|
+
|
|
305
|
+
// ── 子代理计数座位(actions 尾部)【仅旧版注册,见 registerLegacyCatalogUi】──
|
|
306
|
+
// Femo 主会话的官方"N 个子代理"计数菜单:原在面包屑区(lineage 槽),fork
|
|
307
|
+
// 让位后移到这里。order 10 = preset(-10) 之后、job-list(20) 之前,即用户要的
|
|
308
|
+
// 「Femo剧本模式 → 几个子代理 → 几个在跑」。locale 复用官方 'subagent'
|
|
309
|
+
// 命名空间拿文案;仅 Femo 主会话本体渲染,投影窗/普通会话返回 null。
|
|
310
|
+
// (0.1.3 原生版不注册:官方 lineage 槽自带计数菜单,样式与本体一致。)
|
|
311
|
+
const registerCountSeat = (): void => {
|
|
312
|
+
slots.inject('conversation.session.header.actions', () => slots.register(
|
|
313
|
+
{
|
|
314
|
+
name: 'conversation.session.header.actions',
|
|
315
|
+
id: 'femo-plugin-count',
|
|
316
|
+
order: 10,
|
|
317
|
+
locale: 'subagent',
|
|
318
|
+
inject: () => ({
|
|
319
|
+
openChild: (address: { parentSessionId: string; childSessionId: string; mode: string }): void => {
|
|
320
|
+
sessions?.openSubagent?.(address)
|
|
321
|
+
},
|
|
322
|
+
refresh: (parentSessionId: string): void => {
|
|
323
|
+
sessions?.refreshSubagents?.(parentSessionId)
|
|
324
|
+
},
|
|
325
|
+
setCatalogOpen: (parentSessionId: string, open: boolean): void => {
|
|
326
|
+
sessions?.setSubagentCatalogOpen?.(parentSessionId, open)
|
|
327
|
+
},
|
|
328
|
+
}),
|
|
329
|
+
},
|
|
330
|
+
FemoSubagentCount,
|
|
331
|
+
))
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// ── 子代理下拉过滤(shadow 官方 lineage 槽位)【仅旧版注册】──────────────
|
|
335
|
+
// Femo 剧本机制产生的会话——投影窗(id 前缀 femo-proj-)与节点子代理(label
|
|
336
|
+
// 前缀 femo-node-)——不出现在子代理目录里;主模型主动拉起的子代理不受影响
|
|
337
|
+
// (label 无此前缀)。fork 版组件见 lineage-fork.jsx(过滤逻辑全在那里),
|
|
338
|
+
// 非 Femo 会话上行为与官方组件一致(无 femo 条目可滤)。priority -10 shadow
|
|
339
|
+
// 官方默认 0(single 槽 lowest renders,见 ui-slots shadowing 语义)。
|
|
340
|
+
// (2026-08-23 历史注记:布局重排第一版曾整体回退(当时疑似其引入视角切
|
|
341
|
+
// 换卡死),后确认卡死根因在 god 窗 chunk 重放数据层、与本文件无关;布局
|
|
342
|
+
// 重排 v2 已重新落地——视角按钮 order -20 / count 座位 order 10 / 母名
|
|
343
|
+
// 黑化走自有 style 元素(MutationObserver 路线永久弃用)。)
|
|
344
|
+
// (0.1.3 原生版不注册:官方组件原样渲染,femo-node 条目天然可见=角色窗。)
|
|
345
|
+
const registerLineageFork = (): void => {
|
|
346
|
+
slots.inject('conversation.session.header.lineage', () => slots.register(
|
|
347
|
+
{
|
|
348
|
+
name: 'conversation.session.header.lineage',
|
|
349
|
+
priority: -10,
|
|
350
|
+
locale: 'subagent',
|
|
351
|
+
inject: () => ({
|
|
352
|
+
openChild: (address: { parentSessionId: string; childSessionId: string; mode: string }): void => {
|
|
353
|
+
sessions?.openSubagent?.(address)
|
|
354
|
+
},
|
|
355
|
+
refresh: (parentSessionId: string): void => {
|
|
356
|
+
sessions?.refreshSubagents?.(parentSessionId)
|
|
357
|
+
},
|
|
358
|
+
setCatalogOpen: (parentSessionId: string, open: boolean): void => {
|
|
359
|
+
sessions?.setSubagentCatalogOpen?.(parentSessionId, open)
|
|
360
|
+
},
|
|
361
|
+
}),
|
|
362
|
+
},
|
|
363
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
364
|
+
FemoLineage as any,
|
|
365
|
+
))
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** 旧版目录 UI 组装(native-flag fetch 的 legacy 分支/fail-open 调用)。 */
|
|
369
|
+
function registerLegacyCatalogUi(): void {
|
|
370
|
+
registerCountSeat()
|
|
371
|
+
registerLineageFork()
|
|
372
|
+
console.log('[femo-plugin] client legacy mode: femo subagent catalog UI registered (count seat + lineage fork)')
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// ── 0.1.3 原生目录过滤(native 分支注册)─────────────────────────────────
|
|
376
|
+
// 官方 lineage 槽位 shadow(priority -10):组件结构/样式与本体一致(类名
|
|
377
|
+
// 运行时从官方注入的 style 标签解析),唯一差异=显示层过滤——femo-proj
|
|
378
|
+
// (god/stage/角色投影窗)与 femo-actor(Job×角色常驻执行体)一律不进目录
|
|
379
|
+
// (2026-09-09 晚改版:重新 ban 节点拉起的子代理,对齐旧版效果)。计数
|
|
380
|
+
// 触发器留在本体面包屑位(dsh 原生形态),过滤后无子代理时整个隐藏。
|
|
381
|
+
const registerNativeCatalogFilter = (): void => {
|
|
382
|
+
slots.inject('conversation.session.header.lineage', () => slots.register(
|
|
383
|
+
{
|
|
384
|
+
name: 'conversation.session.header.lineage',
|
|
385
|
+
priority: -10,
|
|
386
|
+
locale: 'subagent',
|
|
387
|
+
inject: () => ({
|
|
388
|
+
openChild: (address: { parentSessionId: string; childSessionId: string; mode: string }): void => {
|
|
389
|
+
sessions?.openSubagent?.(address)
|
|
390
|
+
},
|
|
391
|
+
refresh: (parentSessionId: string): void => {
|
|
392
|
+
sessions?.refreshSubagents?.(parentSessionId)
|
|
393
|
+
},
|
|
394
|
+
setCatalogOpen: (parentSessionId: string, open: boolean): void => {
|
|
395
|
+
sessions?.setSubagentCatalogOpen?.(parentSessionId, open)
|
|
396
|
+
},
|
|
397
|
+
}),
|
|
398
|
+
},
|
|
399
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
400
|
+
FemoLineageNative as any,
|
|
401
|
+
))
|
|
402
|
+
console.log('[femo-plugin] client native mode: job-scoped subagent catalog filter registered (lineage slot shadow)')
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const scriptViewInjected = (): ScriptViewInjected => ({
|
|
406
|
+
listScripts: injected().listScripts,
|
|
407
|
+
readScript: async (path: string): Promise<string> => {
|
|
408
|
+
const response = await fetch(`/femo-plugin/script?path=${encodeURIComponent(path)}`)
|
|
409
|
+
if (!response.ok) throw new Error(`script HTTP ${response.status}`)
|
|
410
|
+
const data = await response.json() as { ok?: boolean; content?: string; error?: string }
|
|
411
|
+
if (data.ok !== true || data.content === undefined) {
|
|
412
|
+
throw new Error(data.error ?? 'read script failed')
|
|
413
|
+
}
|
|
414
|
+
return data.content
|
|
415
|
+
},
|
|
416
|
+
saveScript: injected().saveScript,
|
|
417
|
+
// The script panel plays on the CURRENT session (it is a per-session view).
|
|
418
|
+
runScript: async (sid: string, scriptPath?: string): Promise<void> => {
|
|
419
|
+
const body: { sessionId: string; scriptPath?: string } = { sessionId: sid }
|
|
420
|
+
if (scriptPath !== undefined) body.scriptPath = scriptPath
|
|
421
|
+
const response = await fetch('/femo-plugin/run', {
|
|
422
|
+
method: 'POST',
|
|
423
|
+
headers: { 'content-type': 'application/json' },
|
|
424
|
+
body: JSON.stringify(body),
|
|
425
|
+
})
|
|
426
|
+
let message = `run HTTP ${response.status}`
|
|
427
|
+
try {
|
|
428
|
+
const data = await response.json() as { ok?: boolean; error?: string }
|
|
429
|
+
if (data.ok === true) return
|
|
430
|
+
message = data.error ?? message
|
|
431
|
+
} catch {
|
|
432
|
+
// non-JSON body: keep the status message
|
|
433
|
+
}
|
|
434
|
+
throw new Error(message)
|
|
435
|
+
},
|
|
436
|
+
pauseScript: async (sid: string, jobId?: number): Promise<{ paused?: boolean; state?: string } | undefined> => {
|
|
437
|
+
// §8.4 B3:pause 归属解析——sessionId 必填(只认本会话绑定);jobId 可选
|
|
438
|
+
// 显式指定(femoGen 暂停按钮带当前 Job 号,宿主按引擎档案裁决归属)。
|
|
439
|
+
// resolve 值带回执(paused:false=无活跃剧本,femoGen 据此复位按钮;
|
|
440
|
+
// state=引擎侧 Job 现态——paused:true 但 state 已非 running=幂等无操作,
|
|
441
|
+
// femoGen 据此给「引擎没有活跃执行体被停」的知情提示,2026-09-07 214 事故)。
|
|
442
|
+
const qs = new URLSearchParams({ sessionId: sid })
|
|
443
|
+
if (jobId !== undefined) qs.set('jobId', String(jobId))
|
|
444
|
+
const response = await fetch(`/femo-plugin/pause?${qs.toString()}`, {
|
|
445
|
+
method: 'POST',
|
|
446
|
+
headers: { 'content-type': 'application/json' },
|
|
447
|
+
body: '{}',
|
|
448
|
+
})
|
|
449
|
+
let message = `pause HTTP ${response.status}`
|
|
450
|
+
try {
|
|
451
|
+
const data = await response.json() as { ok?: boolean; error?: string; paused?: boolean; state?: string }
|
|
452
|
+
if (data.ok === true) return { paused: data.paused, state: data.state }
|
|
453
|
+
message = data.error ?? message
|
|
454
|
+
} catch {
|
|
455
|
+
// non-JSON body: keep the status message
|
|
456
|
+
}
|
|
457
|
+
throw new Error(message)
|
|
458
|
+
},
|
|
459
|
+
fetchErrors: async (sid: string): Promise<Array<{ ts: number; text: string }>> => {
|
|
460
|
+
const response = await fetch(`/femo-plugin/errors?sessionId=${encodeURIComponent(sid)}`)
|
|
461
|
+
if (!response.ok) throw new Error(`errors HTTP ${response.status}`)
|
|
462
|
+
const data = await response.json() as { ok?: boolean; errors?: Array<{ ts: number; text: string }>; error?: string }
|
|
463
|
+
if (data.ok !== true || data.errors === undefined) {
|
|
464
|
+
throw new Error(data.error ?? 'fetch errors failed')
|
|
465
|
+
}
|
|
466
|
+
return data.errors
|
|
467
|
+
},
|
|
468
|
+
toggleSidebar: () => ctx.layout.toggleSidebar(),
|
|
469
|
+
})
|
|
470
|
+
|
|
471
|
+
slots.inject('conversation.view', () => slots.register(
|
|
472
|
+
{
|
|
473
|
+
name: 'conversation.view',
|
|
474
|
+
id: 'femo',
|
|
475
|
+
order: 20,
|
|
476
|
+
label: () => 'FEMO',
|
|
477
|
+
inject: scriptViewInjected,
|
|
478
|
+
},
|
|
479
|
+
FemoEditorView,
|
|
480
|
+
))
|
|
481
|
+
|
|
482
|
+
// ── 单页常驻编辑器(2026-08-26 v3)───────────────────────────────────────
|
|
483
|
+
// body 级隐藏容器 + createRoot:页面寿命内只有一份 FEMOEditor 实例,内容
|
|
484
|
+
// 跟随打开的 Session(view-button 上报 / 锚点注册)。
|
|
485
|
+
// conversation.view 的 FemoEditorView 只是锚点(激活时接收宿主的 DOM)。
|
|
486
|
+
mountFemoEditorPage(scriptViewInjected)
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
// 投影窗 composer:selector 匹配 femo-proj-* 会话 → 可输入 composer
|
|
490
|
+
// (替代 dsh 默认的 SubagentReadOnlyComposer 只读链)。priority -20
|
|
491
|
+
// < subagent 的 -10:先匹配我们,未命中才落到只读链。inject 提供主会话
|
|
492
|
+
// face 解析(权限菜单/统计行读主会话数据用)。
|
|
493
|
+
const composerInjected = (): ProjectionComposerInjected => ({
|
|
494
|
+
getSessionFace: (sid: string) => {
|
|
495
|
+
try {
|
|
496
|
+
const binding = sessions?.binding?.(sid)
|
|
497
|
+
// SessionFace 鸭子类型由消费端(composer.tsx MainSessionFace)声明。
|
|
498
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
499
|
+
return binding?.session as any
|
|
500
|
+
} catch {
|
|
501
|
+
return undefined
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
})
|
|
505
|
+
slots.inject('conversation.composer', () => slots.register(
|
|
506
|
+
{
|
|
507
|
+
name: 'conversation.composer',
|
|
508
|
+
priority: -20,
|
|
509
|
+
select: (owner: { session?: { sessionId?: string } }): { isProjection: boolean } | null => {
|
|
510
|
+
const sid = owner.session?.sessionId
|
|
511
|
+
if (typeof sid === 'string' && sid.startsWith('femo-proj-')) return { isProjection: true }
|
|
512
|
+
return null
|
|
513
|
+
},
|
|
514
|
+
inject: composerInjected,
|
|
515
|
+
},
|
|
516
|
+
ProjectionComposer,
|
|
517
|
+
))
|
|
518
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
|
|
2
|
+
/** FEMO 品牌 logo(内联自仓库根目录 FEMO_logo.svg,品牌绿 #6FBF3A)。
|
|
3
|
+
* 2026-09-14 拍板:聊天行首 🎭 一律渲染成 femo logo,不再用 FA 面具。
|
|
4
|
+
* 注意:SVG mask id 在全文档必须唯一,多行聊天同屏会重复,故用 useId 生成。 */
|
|
5
|
+
export function FemoLogo({ size = 14, className, style }: FaIconProps) {
|
|
6
|
+
const rawId = useId().replace(/[^a-zA-Z0-9_-]/g, '')
|
|
7
|
+
const maskId = `femo-cut-${rawId}`
|
|
8
|
+
return (
|
|
9
|
+
<svg
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
viewBox="27.169998168945312 30 345.6600341796875 364"
|
|
12
|
+
width={size}
|
|
13
|
+
height={size}
|
|
14
|
+
className={className}
|
|
15
|
+
style={style}
|
|
16
|
+
aria-hidden="true"
|
|
17
|
+
>
|
|
18
|
+
<mask id={maskId}>
|
|
19
|
+
<rect x="0" y="0" width="400" height="480" fill="#ffffff" />
|
|
20
|
+
<path d="M 187.5 200 L 212.5 200 L 262.5 359 L 200 384 L 137.5 359 Z" fill="none" stroke="#000000" strokeWidth="16" strokeLinejoin="round" strokeLinecap="round" />
|
|
21
|
+
<circle cx="200" cy="200" r="15" fill="#000000" />
|
|
22
|
+
<line x1="35" y1="100" x2="200" y2="75" stroke="#000000" strokeWidth="16" strokeLinecap="round" />
|
|
23
|
+
<line x1="200" y1="75" x2="365" y2="100" stroke="#000000" strokeWidth="16" strokeLinecap="round" />
|
|
24
|
+
<line x1="30.92" y1="107.11" x2="91.75" y2="262.5" stroke="#000000" strokeWidth="16" strokeLinecap="round" />
|
|
25
|
+
<line x1="369.08" y1="107.11" x2="308.25" y2="262.5" stroke="#000000" strokeWidth="16" strokeLinecap="round" />
|
|
26
|
+
</mask>
|
|
27
|
+
<g mask={`url(#${maskId})`}>
|
|
28
|
+
<polygon points="200,40 338.56,120 338.56,280 200,360 61.44,280 61.44,120" fill="none" stroke="#6FBF3A" strokeWidth="32" strokeLinejoin="round" strokeLinecap="round" />
|
|
29
|
+
<line x1="200" y1="200" x2="61.44" y2="120" stroke="#6FBF3A" strokeWidth="32" strokeLinecap="round" />
|
|
30
|
+
<line x1="200" y1="200" x2="338.56" y2="120" stroke="#6FBF3A" strokeWidth="32" strokeLinecap="round" />
|
|
31
|
+
<path d="M 187.5 200 L 212.5 200 L 262.5 359 L 200 384 L 137.5 359 Z" fill="#6FBF3A" />
|
|
32
|
+
<path d="M 75.78 197.79 L 37.17 105.58 L 135.99 93.53 L 68.63 132.43 L 75.78 120 Z" fill="#6FBF3A" />
|
|
33
|
+
<path d="M 324.22 197.79 L 362.83 105.58 L 264.01 93.53 L 331.37 132.43 L 324.22 120 Z" fill="#6FBF3A" />
|
|
34
|
+
</g>
|
|
35
|
+
<circle cx="200" cy="200" r="30" fill="none" stroke="#6FBF3A" strokeWidth="32" />
|
|
36
|
+
</svg>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Font Awesome Free 6.5.2 solid icons, inlined as React components
|
|
41
|
+
* (single-path, fill=currentColor — inherits text color like the official
|
|
42
|
+
* primitive icons they replace).
|
|
43
|
+
*
|
|
44
|
+
* Source: @fortawesome/fontawesome-free/svgs/solid/*.svg
|
|
45
|
+
* Icons license: CC BY 4.0 — https://fontawesome.com/license/free
|
|
46
|
+
* Copyright 2024 Fonticons, Inc.
|
|
47
|
+
*/
|
|
48
|
+
import { useId, type CSSProperties } from 'react'
|
|
49
|
+
|
|
50
|
+
interface FaIconProps {
|
|
51
|
+
size?: number
|
|
52
|
+
className?: string
|
|
53
|
+
style?: CSSProperties
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function make(viewBox: string, d: string) {
|
|
57
|
+
return function FaIcon({ size = 14, className, style }: FaIconProps) {
|
|
58
|
+
return (
|
|
59
|
+
<svg
|
|
60
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
61
|
+
viewBox={viewBox}
|
|
62
|
+
width={size}
|
|
63
|
+
height={size}
|
|
64
|
+
className={className}
|
|
65
|
+
style={style}
|
|
66
|
+
aria-hidden="true"
|
|
67
|
+
fill="currentColor"
|
|
68
|
+
>
|
|
69
|
+
<path d={d} />
|
|
70
|
+
</svg>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** fa--eye — Font Awesome Free 6.5.2 (CC BY 4.0, Fonticons Inc.) */
|
|
76
|
+
export const FaEye = make("0 0 576 512", "M288 32c-80.8 0-145.5 36.8-192.6 80.6C48.6 156 17.3 208 2.5 243.7c-3.3 7.9-3.3 16.7 0 24.6C17.3 304 48.6 356 95.4 399.4C142.5 443.2 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C433.5 68.8 368.8 32 288 32zM144 256a144 144 0 1 1 288 0 144 144 0 1 1 -288 0zm144-64c0 35.3-28.7 64-64 64c-7.1 0-13.9-1.2-20.3-3.3c-5.5-1.8-11.9 1.6-11.7 7.4c.3 6.9 1.3 13.8 3.2 20.7c13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-11.1-41.5-47.8-69.4-88.6-71.1c-5.8-.2-9.2 6.1-7.4 11.7c2.1 6.4 3.3 13.2 3.3 20.3z")
|
|
77
|
+
|
|
78
|
+
/** fa--robot — Font Awesome Free 6.5.2 (CC BY 4.0, Fonticons Inc.) */
|
|
79
|
+
export const FaRobot = make("0 0 640 512", "M320 0c17.7 0 32 14.3 32 32V96H472c39.8 0 72 32.2 72 72V440c0 39.8-32.2 72-72 72H168c-39.8 0-72-32.2-72-72V168c0-39.8 32.2-72 72-72H288V32c0-17.7 14.3-32 32-32zM208 384c-8.8 0-16 7.2-16 16s7.2 16 16 16h32c8.8 0 16-7.2 16-16s-7.2-16-16-16H208zm96 0c-8.8 0-16 7.2-16 16s7.2 16 16 16h32c8.8 0 16-7.2 16-16s-7.2-16-16-16H304zm96 0c-8.8 0-16 7.2-16 16s7.2 16 16 16h32c8.8 0 16-7.2 16-16s-7.2-16-16-16H400zM264 256a40 40 0 1 0 -80 0 40 40 0 1 0 80 0zm152 40a40 40 0 1 0 0-80 40 40 0 1 0 0 80zM48 224H64V416H48c-26.5 0-48-21.5-48-48V272c0-26.5 21.5-48 48-48zm544 0c26.5 0 48 21.5 48 48v96c0 26.5-21.5 48-48 48H576V224h16z")
|
|
80
|
+
|
|
81
|
+
/** fa--user-secret — Font Awesome Free 6.5.2 (CC BY 4.0, Fonticons Inc.) */
|
|
82
|
+
export const FaUserSecret = make("0 0 448 512", "M224 16c-6.7 0-10.8-2.8-15.5-6.1C201.9 5.4 194 0 176 0c-30.5 0-52 43.7-66 89.4C62.7 98.1 32 112.2 32 128c0 14.3 25 27.1 64.6 35.9c-.4 4-.6 8-.6 12.1c0 17 3.3 33.2 9.3 48H45.4C38 224 32 230 32 237.4c0 1.7 .3 3.4 1 5l38.8 96.9C28.2 371.8 0 423.8 0 482.3C0 498.7 13.3 512 29.7 512H418.3c16.4 0 29.7-13.3 29.7-29.7c0-58.5-28.2-110.4-71.7-143L415 242.4c.6-1.6 1-3.3 1-5c0-7.4-6-13.4-13.4-13.4H342.7c6-14.8 9.3-31 9.3-48c0-4.1-.2-8.1-.6-12.1C391 155.1 416 142.3 416 128c0-15.8-30.7-29.9-78-38.6C324 43.7 302.5 0 272 0c-18 0-25.9 5.4-32.5 9.9c-4.8 3.3-8.8 6.1-15.5 6.1zm56 208H267.6c-16.5 0-31.1-10.6-36.3-26.2c-2.3-7-12.2-7-14.5 0c-5.2 15.6-19.9 26.2-36.3 26.2H168c-22.1 0-40-17.9-40-40V169.6c28.2 4.1 61 6.4 96 6.4s67.8-2.3 96-6.4V184c0 22.1-17.9 40-40 40zm-88 96l16 32L176 480 128 288l64 32zm128-32L272 480 240 352l16-32 64-32z")
|
|
83
|
+
|
|
84
|
+
/** fa--podcast — Font Awesome Free 6.5.2 (CC BY 4.0, Fonticons Inc.) */
|
|
85
|
+
export const FaPodcast = make("0 0 448 512", "M319.4 372c48.5-31.3 80.6-85.9 80.6-148c0-97.2-78.8-176-176-176S48 126.8 48 224c0 62.1 32.1 116.6 80.6 148c1.2 17.3 4 38 7.2 57.1l.2 1C56 395.8 0 316.5 0 224C0 100.3 100.3 0 224 0S448 100.3 448 224c0 92.5-56 171.9-136 206.1l.2-1.1c3.1-19.2 6-39.8 7.2-57zm-2.3-38.1c-1.6-5.7-3.9-11.1-7-16.2c-5.8-9.7-13.5-17-21.9-22.4c19.5-17.6 31.8-43 31.8-71.3c0-53-43-96-96-96s-96 43-96 96c0 28.3 12.3 53.8 31.8 71.3c-8.4 5.4-16.1 12.7-21.9 22.4c-3.1 5.1-5.4 10.5-7 16.2C99.8 307.5 80 268 80 224c0-79.5 64.5-144 144-144s144 64.5 144 144c0 44-19.8 83.5-50.9 109.9zM224 312c32.9 0 64 8.6 64 43.8c0 33-12.9 104.1-20.6 132.9c-5.1 19-24.5 23.4-43.4 23.4s-38.2-4.4-43.4-23.4c-7.8-28.5-20.6-99.7-20.6-132.8c0-35.1 31.1-43.8 64-43.8zm0-144a56 56 0 1 1 0 112 56 56 0 1 1 0-112z")
|
|
86
|
+
|
|
87
|
+
/** fa--clapperboard — Font Awesome Free 6.7.2 (CC BY 4.0, Fonticons Inc.) */
|
|
88
|
+
export const FaClapperboard = make("0 0 512 512", "M448 32l-86.1 0-1 1-127 127 92.1 0 1-1L453.8 32.3c-1.9-.2-3.8-.3-5.8-.3zm64 128l0-64c0-15.1-5.3-29.1-14-40l-104 104L512 160zM294.1 32l-92.1 0-1 1L73.9 160l92.1 0 1-1 127-127zM64 32C28.7 32 0 60.7 0 96l0 64 6.1 0 1-1 127-127L64 32zM512 192L0 192 0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-224z")
|
|
89
|
+
|
|
90
|
+
/** fa--circle-check — Font Awesome Free 6.5.2 (CC BY 4.0, Fonticons Inc.) */
|
|
91
|
+
export const FaCircleCheck = make("0 0 512 512", "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z")
|
|
92
|
+
|
|
93
|
+
/** fa--circle-stop — Font Awesome Free 6.5.2 (CC BY 4.0, Fonticons Inc.) */
|
|
94
|
+
export const FaCircleStop = make("0 0 512 512", "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM192 160H320c17.7 0 32 14.3 32 32V320c0 17.7-14.3 32-32 32H192c-17.7 0-32-14.3-32-32V192c0-17.7 14.3-32 32-32z")
|
|
95
|
+
|
|
96
|
+
/** fa--circle-xmark — Font Awesome Free 6.5.2 (CC BY 4.0, Fonticons Inc.) */
|
|
97
|
+
export const FaCircleXmark = make("0 0 512 512", "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z")
|
|
98
|
+
|
|
99
|
+
/** fa--circle-play — Font Awesome Free 6.5.2 (CC BY 4.0, Fonticons Inc.) */
|
|
100
|
+
export const FaCirclePlay = make("0 0 512 512", "M0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zM188.3 147.1c-7.6 4.2-12.3 12.3-12.3 20.9V344c0 8.7 4.7 16.7 12.3 20.9s16.8 4.1 24.3-.5l144-88c7.1-4.4 11.5-12.1 11.5-20.5s-4.4-16.1-11.5-20.5l-144-88c-7.4-4.5-16.7-4.7-24.3-.5z")
|
|
101
|
+
|
|
102
|
+
/** fa--triangle-exclamation — Font Awesome Free 6.5.2 (CC BY 4.0, Fonticons Inc.) */
|
|
103
|
+
export const FaTriangleExclamation = make("0 0 512 512", "M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z")
|
|
104
|
+
|
|
105
|
+
/** fa--masks-theater — Font Awesome Free 6.5.2 (CC BY 4.0, Fonticons Inc.) */
|
|
106
|
+
export const FaMasksTheater = make("0 0 640 512", "M74.6 373.2c41.7 36.1 108 82.5 166.1 73.7c6.1-.9 12.1-2.5 18-4.5c-9.2-12.3-17.3-24.4-24.2-35.4c-21.9-35-28.8-75.2-25.9-113.6c-20.6 4.1-39.2 13-54.7 25.4c-6.5 5.2-16.3 1.3-14.8-7c6.4-33.5 33-60.9 68.2-66.3c2.6-.4 5.3-.7 7.9-.8l19.4-131.3c2-13.8 8-32.7 25-45.9C278.2 53.2 310.5 37 363.2 32.2c-.8-.7-1.6-1.4-2.4-2.1C340.6 14.5 288.4-11.5 175.7 5.6S20.5 63 5.7 83.9C0 91.9-.8 102 .6 111.8L24.8 276.1c5.5 37.3 21.5 72.6 49.8 97.2zm87.7-219.6c4.4-3.1 10.8-2 11.8 3.3c.1 .5 .2 1.1 .3 1.6c3.2 21.8-11.6 42-33.1 45.3s-41.5-11.8-44.7-33.5c-.1-.5-.1-1.1-.2-1.6c-.6-5.4 5.2-8.4 10.3-6.7c9 3 18.8 3.9 28.7 2.4s19.1-5.3 26.8-10.8zM261.6 390c29.4 46.9 79.5 110.9 137.6 119.7s124.5-37.5 166.1-73.7c28.3-24.5 44.3-59.8 49.8-97.2l24.2-164.3c1.4-9.8 .6-19.9-5.1-27.9c-14.8-20.9-57.3-61.2-170-78.3S299.4 77.2 279.2 92.8c-7.8 6-11.5 15.4-12.9 25.2L242.1 282.3c-5.5 37.3-.4 75.8 19.6 107.7zM404.5 235.3c-7.7-5.5-16.8-9.3-26.8-10.8s-19.8-.6-28.7 2.4c-5.1 1.7-10.9-1.3-10.3-6.7c.1-.5 .1-1.1 .2-1.6c3.2-21.8 23.2-36.8 44.7-33.5s36.3 23.5 33.1 45.3c-.1 .5-.2 1.1-.3 1.6c-1 5.3-7.4 6.4-11.8 3.3zm136.2 15.5c-1 5.3-7.4 6.4-11.8 3.3c-7.7-5.5-16.8-9.3-26.8-10.8s-19.8-.6-28.7 2.4c-5.1 1.7-10.9-1.3-10.3-6.7c.1-.5 .1-1.1 .2-1.6c3.2-21.8 23.2-36.8 44.7-33.5s36.3 23.5 33.1 45.3c-.1 .5-.2 1.1-.3 1.6zM530 350.2c-19.6 44.7-66.8 72.5-116.8 64.9s-87.1-48.2-93-96.7c-1-8.3 8.9-12.1 15.2-6.7c23.9 20.8 53.6 35.3 87 40.3s66.1 .1 94.9-12.8c7.6-3.4 16 3.2 12.6 10.9z")
|
|
107
|
+
|
|
108
|
+
/** fa--bullhorn — Font Awesome Free 6.5.2 (CC BY 4.0, Fonticons Inc.) */
|
|
109
|
+
export const FaBullhorn = make("0 0 512 512", "M480 32c0-12.9-7.8-24.6-19.8-29.6s-25.7-2.2-34.9 6.9L381.7 53c-48 48-113.1 75-181 75H192 160 64c-35.3 0-64 28.7-64 64v96c0 35.3 28.7 64 64 64l0 128c0 17.7 14.3 32 32 32h64c17.7 0 32-14.3 32-32V352l8.7 0c67.9 0 133 27 181 75l43.6 43.6c9.2 9.2 22.9 11.9 34.9 6.9s19.8-16.6 19.8-29.6V300.4c18.6-8.8 32-32.5 32-60.4s-13.4-51.6-32-60.4V32zm-64 76.7V240 371.3C357.2 317.8 280.5 288 200.7 288H192V192h8.7c79.8 0 156.5-29.8 215.3-83.3z")
|
|
110
|
+
|
|
111
|
+
/** fa--wrench — Font Awesome Free 6.5.2 (CC BY 4.0, Fonticons Inc.) */
|
|
112
|
+
export const FaWrench = make("0 0 512 512", "M352 320c88.4 0 160-71.6 160-160c0-15.3-2.2-30.1-6.2-44.2c-3.1-10.8-16.4-13.2-24.3-5.3l-76.8 76.8c-3 3-7.1 4.7-11.3 4.7H336c-8.8 0-16-7.2-16-16V118.6c0-4.2 1.7-8.3 4.7-11.3l76.8-76.8c7.9-7.9 5.4-21.2-5.3-24.3C382.1 2.2 367.3 0 352 0C263.6 0 192 71.6 192 160c0 19.1 3.4 37.5 9.5 54.5L19.9 396.1C7.2 408.8 0 426.1 0 444.1C0 481.6 30.4 512 67.9 512c18 0 35.3-7.2 48-19.9L297.5 310.5c17 6.2 35.4 9.5 54.5 9.5zM80 408a24 24 0 1 1 0 48 24 24 0 1 1 0-48z")
|