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,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* client-ui/proj2/ledger.ts — 轮台账(投影窗显示层 v9 的唯一身份判据)。
|
|
3
|
+
*
|
|
4
|
+
* 【为什么要有这个文件】v5/v6/v7 四代渲染链路各自带一套"这块属于谁"的判据
|
|
5
|
+
* (isNewestTurnStream / lastHostKeys / 桶空不空 / directorAnchors),谁先谁后
|
|
6
|
+
* 一变画面就变样——"每次跑表现都不一样"的结构性病因。v9 的边界是:
|
|
7
|
+
*
|
|
8
|
+
* 一轮的身份 = 宿主写下的开轮锚点 `femo-plugin/chat{kind:'live', turn, actor}`
|
|
9
|
+
* 的事件 seq(= 激活时间 = 排序键)。前端不做任何"谁最新/桶空不空/landed"
|
|
10
|
+
* 推断:归属只看 turn(键),排序只看 orderSeq。
|
|
11
|
+
*
|
|
12
|
+
* 本文件是这套判据的**唯一实现**:头节点(femo2-turn)与直播尾节点
|
|
13
|
+
* (femo2-turn-live)共用同一份 match/start/update/锚公式,于是"谁画这一轮"
|
|
14
|
+
* 只有一个答案、不可能两处各画一份。
|
|
15
|
+
*
|
|
16
|
+
* 【start 的唯一性(装配器硬约束)】dsh 装配器对同一 context 的第二条 start
|
|
17
|
+
* 直接抛错(acceptMatch: "received more than one start Match"),且 update 不得
|
|
18
|
+
* 先于 start。故本台账只认**每轮恰好一条**的 kind='live' 开轮锚为 start,
|
|
19
|
+
* 其余(speaker/prompt/error/turn/start/turn/end/内容事件)一律 update——同一
|
|
20
|
+
* baseTurn 会有多条 turn/start(多个子 turn 映射到同一轮),它们绝不能再当
|
|
21
|
+
* start。
|
|
22
|
+
*
|
|
23
|
+
* 【步1 范围】只接管 AI 演员轮;'human' / 'main' 两类轮的接入见步3(同池排序
|
|
24
|
+
* 已在本文件的 kind/orderSeq 里预留)。
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import type { ConversationMatch, ConversationNodeContext } from '@deepseek-ai/dsh-client-runtime/client'
|
|
28
|
+
|
|
29
|
+
/** 轮的类别:三类轮同池排序(激活时间),渲染外观不同。 */
|
|
30
|
+
export type Femo2TurnKind = 'ai' | 'human' | 'main'
|
|
31
|
+
|
|
32
|
+
/** 一轮的全部前端状态(唯一数据源;头/尾两个渲染位共用)。 */
|
|
33
|
+
export interface Femo2TurnState {
|
|
34
|
+
/** 轮号(宿主 baseTurn;本窗内唯一标识一轮)。 */
|
|
35
|
+
readonly turn: number
|
|
36
|
+
/** 角色显示名(开轮锚点带来)。 */
|
|
37
|
+
readonly actor: string
|
|
38
|
+
readonly kind: Femo2TurnKind
|
|
39
|
+
/** 开轮锚点事件 seq = 激活时间;**排序键(唯一权威)**。 */
|
|
40
|
+
readonly orderSeq: number
|
|
41
|
+
/** AI 节点的 showprompt 旁白(📢 条;开轮锚点已带,流式期即可显示)。 */
|
|
42
|
+
readonly showprompt?: string
|
|
43
|
+
/** 本回合失败信息(带 turn 的 error 行)。 */
|
|
44
|
+
readonly error?: string
|
|
45
|
+
/** 本轮回合已收口(turn/end 到达)→ 直播尾永久隐藏。 */
|
|
46
|
+
readonly landed: boolean
|
|
47
|
+
/** 轮内首个已落地事件 seq(turn/start 也算)→ "本段已落盘"的硬信号(直播尾退场用)。 */
|
|
48
|
+
readonly firstBodySeq?: number
|
|
49
|
+
/** 轮内首个**非骨架**内容事件 seq(step/*、assistant/*、tool/*;不含 turn/start)
|
|
50
|
+
* —— "空轮"判据:只有骨架没有它 = 纯自动开合的空回合,名字行永不露面(v9.4)。 */
|
|
51
|
+
readonly firstContentSeq?: number
|
|
52
|
+
/** 轮内首个**回答类**事件 seq(assistant/message、step/start…;不含 turn/start 与 user/message)
|
|
53
|
+
* —— 主 Agent 轮的头锚贴在这里,跳过轮首的 user 消息(见 femo2TurnHeadAnchor)。 */
|
|
54
|
+
readonly firstAnswerSeq?: number
|
|
55
|
+
/** 轮内末个已落地事件 seq(诊断用)。 */
|
|
56
|
+
readonly lastBodySeq?: number
|
|
57
|
+
/** 本行可见的角色名(action scope);缺失=全员可见。 */
|
|
58
|
+
readonly visible?: readonly string[]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** 归约后的事件形态(null = 与本台账无关,不属于任何一轮)。 */
|
|
62
|
+
export interface Femo2TurnEvent {
|
|
63
|
+
readonly turn: number
|
|
64
|
+
/** start 只给开轮锚点(kind='live'),每轮恰好一条。 */
|
|
65
|
+
readonly role: 'start' | 'update'
|
|
66
|
+
readonly actor?: string
|
|
67
|
+
/** 开轮锚点的主 Agent 标记(god 窗的主会话轮)。 */
|
|
68
|
+
readonly main?: boolean
|
|
69
|
+
/** 开轮锚点的戏内下场标记(main:true 且非导演——god 窗的主模型下场轮、
|
|
70
|
+
* stage/角色窗的下场锚)。定位走演员轮公式,与戏外主会话轮分开。 */
|
|
71
|
+
readonly scene?: boolean
|
|
72
|
+
readonly showprompt?: string
|
|
73
|
+
readonly error?: string
|
|
74
|
+
readonly visible?: readonly string[]
|
|
75
|
+
/** 事件是否计入"已落地"(头锚依据):骨架/内容事件。 */
|
|
76
|
+
readonly bodySeq?: number
|
|
77
|
+
/** 该事件是否为非骨架内容(空轮判据;turn/start 不算内容)。 */
|
|
78
|
+
readonly content?: boolean
|
|
79
|
+
/** 该事件是否属"回答类"(判定主 Agent 轮名字行的落点用)。 */
|
|
80
|
+
readonly answer?: boolean
|
|
81
|
+
/** 回合收口(turn/end)。 */
|
|
82
|
+
readonly end?: boolean
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** 落盘后由官方渲染器画成"身"的骨架/内容事件(带 turn 字段)。 */
|
|
86
|
+
const BODY_EVENT_TYPES = new Set([
|
|
87
|
+
'turn/start',
|
|
88
|
+
'step/start', 'step/end',
|
|
89
|
+
'assistant/message', 'assistant/chunk',
|
|
90
|
+
'tool/call', 'tool/result',
|
|
91
|
+
])
|
|
92
|
+
|
|
93
|
+
/** "回答类"事件:主 Agent 的名字行要贴在这类事件的第一个之前。
|
|
94
|
+
*
|
|
95
|
+
* 【2026-09-11 实测修正·第二版】只认 **assistant/message / assistant/chunk**——
|
|
96
|
+
* 不能含 step/start、tool/*。原因:上帝窗里 `user/message` 的镜像是**后写**的
|
|
97
|
+
* (实测 seq:锚2397 → turn/start2398 → step/start2399 → **user/message2400**
|
|
98
|
+
* → assistant/message2401),而官方把 assistant 内容渲染在 2401 那个位置。
|
|
99
|
+
* 用 step/start 算锚(2398.5)会落到用户消息(2400)前面 ⇒ 症状"导演名字行在
|
|
100
|
+
* 用户气泡上面";改用 assistant/message 算(2400.5)即得正确顺序:
|
|
101
|
+
* 你的消息 → 导演 → 我的回复。演员轮轮内没有 user 消息,仍按最早落地事件贴。 */
|
|
102
|
+
const ANSWER_EVENT_TYPES = new Set([
|
|
103
|
+
'assistant/message', 'assistant/chunk',
|
|
104
|
+
])
|
|
105
|
+
|
|
106
|
+
function asRecord(value: unknown): Record<string, unknown> {
|
|
107
|
+
return (value ?? {}) as Record<string, unknown>
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function turnOf(value: unknown): number | undefined {
|
|
111
|
+
return typeof value === 'number' ? value : undefined
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function strOf(value: unknown): string | undefined {
|
|
115
|
+
return typeof value === 'string' && value.length > 0 ? value : undefined
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function visibleOf(value: unknown): readonly string[] | undefined {
|
|
119
|
+
if (!Array.isArray(value)) return undefined
|
|
120
|
+
const list = value.filter((item): item is string => typeof item === 'string')
|
|
121
|
+
return list.length === 0 ? undefined : list
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 事件 → 轮身份(唯一入口)。认得的形态:
|
|
126
|
+
* - `femo-plugin/chat{kind:'live', turn}` —— **开轮锚点**(start,每轮一条)
|
|
127
|
+
* - `femo-plugin/chat{kind:'speaker'|'prompt'|'error', turn}` —— 轮内归属行
|
|
128
|
+
* - `turn/start|step/*|assistant/*|tool/*`(带 turn)—— 落盘骨架/内容
|
|
129
|
+
* - `turn/end{turn}` —— 回合收口
|
|
130
|
+
* 其余(notice/sys/human_wait/role 行、无 turn 的旧行、主会话镜像的无轮事件)不认。
|
|
131
|
+
*/
|
|
132
|
+
export function femo2TurnEventOf(event: ConversationMatch['event']): Femo2TurnEvent | null {
|
|
133
|
+
const type = event.type
|
|
134
|
+
if (type === 'femo-plugin/chat') {
|
|
135
|
+
const d = asRecord(event.data)
|
|
136
|
+
const turn = turnOf(d.turn)
|
|
137
|
+
if (turn === undefined) return null
|
|
138
|
+
const visible = visibleOf(d.visible)
|
|
139
|
+
if (d.kind === 'live') {
|
|
140
|
+
return {
|
|
141
|
+
turn,
|
|
142
|
+
role: 'start',
|
|
143
|
+
...strOf(d.actor) !== undefined ? { actor: strOf(d.actor)! } : {},
|
|
144
|
+
...strOf(d.showprompt) !== undefined ? { showprompt: strOf(d.showprompt)! } : {},
|
|
145
|
+
...d.main === true ? { main: true } : {},
|
|
146
|
+
...d.scene === true ? { scene: true } : {},
|
|
147
|
+
...visible !== undefined ? { visible } : {},
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (d.kind === 'speaker') {
|
|
151
|
+
return {
|
|
152
|
+
turn,
|
|
153
|
+
role: 'update',
|
|
154
|
+
...strOf(d.actor) !== undefined ? { actor: strOf(d.actor)! } : {},
|
|
155
|
+
...visible !== undefined ? { visible } : {},
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (d.kind === 'prompt') {
|
|
159
|
+
return {
|
|
160
|
+
turn,
|
|
161
|
+
role: 'update',
|
|
162
|
+
...strOf(d.text) !== undefined ? { showprompt: strOf(d.text)! } : {},
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (d.kind === 'error') {
|
|
166
|
+
return {
|
|
167
|
+
turn,
|
|
168
|
+
role: 'update',
|
|
169
|
+
...strOf(d.text) !== undefined ? { error: strOf(d.text)! } : {},
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return null
|
|
173
|
+
}
|
|
174
|
+
if (type === 'turn/end') {
|
|
175
|
+
const turn = turnOf(asRecord(event.data).turn)
|
|
176
|
+
return turn === undefined ? null : { turn, role: 'update', end: true }
|
|
177
|
+
}
|
|
178
|
+
if (BODY_EVENT_TYPES.has(type)) {
|
|
179
|
+
const turn = turnOf(asRecord(event.data).turn)
|
|
180
|
+
if (turn === undefined) return null
|
|
181
|
+
return {
|
|
182
|
+
turn,
|
|
183
|
+
role: 'update',
|
|
184
|
+
bodySeq: event.seq,
|
|
185
|
+
...type !== 'turn/start' ? { content: true } : {},
|
|
186
|
+
...ANSWER_EVENT_TYPES.has(type) ? { answer: true } : {},
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return null
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** definition 的 match:两个渲染位共用(同一轮 → 同一 id,两个 kind 各一个 context)。 */
|
|
193
|
+
export function femo2TurnMatch(event: ConversationMatch['event']): { id: string; role: 'start' | 'update' } | null {
|
|
194
|
+
const shape = femo2TurnEventOf(event)
|
|
195
|
+
if (shape === null) return null
|
|
196
|
+
return { id: String(shape.turn), role: shape.role }
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** start(只在开轮锚点上调用):本轮的身份证。 */
|
|
200
|
+
export function femo2TurnStart(match: ConversationMatch): Femo2TurnState {
|
|
201
|
+
const shape = femo2TurnEventOf(match.event)
|
|
202
|
+
return {
|
|
203
|
+
turn: shape?.turn ?? 0,
|
|
204
|
+
actor: shape?.actor ?? '',
|
|
205
|
+
// 开轮锚点带 main 标记 ⇒ 主 Agent 轮(god 窗的主会话轮);否则 AI 演员轮。
|
|
206
|
+
kind: shape?.main === true ? 'main' : 'ai',
|
|
207
|
+
orderSeq: match.event.seq,
|
|
208
|
+
landed: false,
|
|
209
|
+
...shape?.showprompt !== undefined ? { showprompt: shape.showprompt } : {},
|
|
210
|
+
...shape?.scene === true ? { scene: true } : {},
|
|
211
|
+
...shape?.visible !== undefined ? { visible: shape.visible } : {},
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** update:轮内一切后续事件归约进同一份状态(纯函数,无外部推断)。 */
|
|
216
|
+
export function femo2TurnUpdate(
|
|
217
|
+
context: ConversationNodeContext<Femo2TurnState>,
|
|
218
|
+
match: ConversationMatch,
|
|
219
|
+
): Femo2TurnState {
|
|
220
|
+
const prev = context.state
|
|
221
|
+
// 无 start 的轮(异常/旧数据):状态建不起来,直接不产节点(安全降级)。
|
|
222
|
+
if (prev === undefined) return femo2TurnStart(match)
|
|
223
|
+
const shape = femo2TurnEventOf(match.event)
|
|
224
|
+
if (shape === null) return prev
|
|
225
|
+
let next = prev
|
|
226
|
+
if (shape.actor !== undefined && shape.actor !== prev.actor) next = { ...next, actor: shape.actor }
|
|
227
|
+
if (shape.showprompt !== undefined && shape.showprompt !== prev.showprompt) next = { ...next, showprompt: shape.showprompt }
|
|
228
|
+
if (shape.error !== undefined && shape.error !== prev.error) next = { ...next, error: shape.error }
|
|
229
|
+
if (shape.visible !== undefined && prev.visible === undefined) next = { ...next, visible: shape.visible }
|
|
230
|
+
if (shape.bodySeq !== undefined) {
|
|
231
|
+
const first = prev.firstBodySeq === undefined ? shape.bodySeq : Math.min(prev.firstBodySeq, shape.bodySeq)
|
|
232
|
+
const last = prev.lastBodySeq === undefined ? shape.bodySeq : Math.max(prev.lastBodySeq, shape.bodySeq)
|
|
233
|
+
if (first !== prev.firstBodySeq || last !== prev.lastBodySeq) {
|
|
234
|
+
next = { ...next, firstBodySeq: first, lastBodySeq: last }
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// 非骨架内容的首个 seq(空轮判据:turn/start 不算内容,v9.4)。
|
|
238
|
+
if (shape.content === true) {
|
|
239
|
+
const fc = prev.firstContentSeq === undefined ? match.event.seq : Math.min(prev.firstContentSeq, match.event.seq)
|
|
240
|
+
if (fc !== prev.firstContentSeq) next = { ...next, firstContentSeq: fc }
|
|
241
|
+
}
|
|
242
|
+
// 回答类事件的首个 seq(主 Agent 轮里 user 消息在轮首,名字行要跳过它)。
|
|
243
|
+
if (shape.answer === true) {
|
|
244
|
+
const ans = prev.firstAnswerSeq === undefined ? match.event.seq : Math.min(prev.firstAnswerSeq, match.event.seq)
|
|
245
|
+
if (ans !== prev.firstAnswerSeq) next = { ...next, firstAnswerSeq: ans }
|
|
246
|
+
}
|
|
247
|
+
if (shape.end === true && !prev.landed) {
|
|
248
|
+
next = { ...next, landed: true }
|
|
249
|
+
// 【诊断】turn/end 有没有真的喂进本 context("直播尾赖着不走"就靠这条判定:
|
|
250
|
+
// 是事件没到,还是渲染判据错)。
|
|
251
|
+
}
|
|
252
|
+
return next
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* 头锚:本轮已落地内容的首个事件 seq − 0.5(恒在本段所有官方节点之前)。
|
|
257
|
+
*
|
|
258
|
+
* 【v9.4 2026-09-11 Job 2945 用户拍板:戏内 / 戏外分开定位】
|
|
259
|
+
* · 戏内下场轮(scene:true,main:true 且非导演)→ **演员轮公式贴段首**
|
|
260
|
+
* (firstBody −0.5)。god 窗实测:锚在开场 user 消息之前的节点会被官方
|
|
261
|
+
* turn-process 呈现逻辑提升到"用户气泡之后、思考/工具过程行之前"
|
|
262
|
+
* (openingHumanAnchor 提升,rank2 按原始锚点稳定排序)——正是想要的
|
|
263
|
+
* 「上场注入 → @戏内名 → 已思考 → 回答」。
|
|
264
|
+
* · 戏外主会话轮 → 保持 v9.2 已验收公式(首个回答 −0.5),一字不动:
|
|
265
|
+
* 物理顺序是 锚→turn/start→step/start→user→assistant,用 step/start 算锚
|
|
266
|
+
* 会把名字顶到用户气泡上面(v9.2 已修过的坑,别退回去)。
|
|
267
|
+
* · AI 演员轮轮内没有 user 消息,仍按最早落地事件贴。
|
|
268
|
+
* 流式期(本段还没落盘)→ orderSeq + 0.5(贴窗底、在直播尾之前)。
|
|
269
|
+
*/
|
|
270
|
+
export function femo2TurnHeadAnchor(context: ConversationNodeContext<Femo2TurnState>): number {
|
|
271
|
+
const state = context.state
|
|
272
|
+
if (state === undefined) return 0
|
|
273
|
+
if (state.kind === 'main' && state.scene === true) {
|
|
274
|
+
if (state.firstBodySeq !== undefined) return state.firstBodySeq - 0.5
|
|
275
|
+
return state.orderSeq + 0.5
|
|
276
|
+
}
|
|
277
|
+
if (state.kind === 'main' && state.firstAnswerSeq !== undefined) return state.firstAnswerSeq - 0.5
|
|
278
|
+
if (state.firstBodySeq !== undefined) return state.firstBodySeq - 0.5
|
|
279
|
+
return state.orderSeq + 0.5
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* 直播尾锚:1e12 + orderSeq —— 恒在窗内一切已落盘内容之后,且多名并发演员
|
|
284
|
+
* 按**激活顺序**(开轮锚点 seq)排列,互不穿插。
|
|
285
|
+
*/
|
|
286
|
+
export function femo2TurnLiveAnchor(context: ConversationNodeContext<Femo2TurnState>): number {
|
|
287
|
+
const state = context.state
|
|
288
|
+
if (state === undefined) return 1e12
|
|
289
|
+
return 1e12 + state.orderSeq
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** 头节点是否该露面:本段已落盘(有骨架/内容事件)或已收口(空回合也要有名字)。
|
|
293
|
+
* 主会话轮等"回答"落地——否则名字行会在用户消息旁空转。 */
|
|
294
|
+
export function femo2TurnHeadVisible(state: Femo2TurnState | undefined): boolean {
|
|
295
|
+
if (state === undefined) return false
|
|
296
|
+
if (state.kind === 'main') {
|
|
297
|
+
// 【v9.4 Job 2945】已收口但连一个非骨架内容事件都没有 = 自动开合的空轮
|
|
298
|
+
// (实测 turn=2:turn/start 与 turn/end 之间什么都没有)——名字行永不露面,
|
|
299
|
+
// 否则就是"剧本已开始后多出来的孤立导演行"。landed 兜底保留给
|
|
300
|
+
// "有内容但无 assistant/message"的轮(纯工具轮)。
|
|
301
|
+
return state.firstAnswerSeq !== undefined || (state.landed && state.firstContentSeq !== undefined)
|
|
302
|
+
}
|
|
303
|
+
return state.firstBodySeq !== undefined || state.landed
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* 直播尾是否还该露面:**本段一旦开始落盘就让位**(firstBodySeq 是宿主整段落盘
|
|
308
|
+
* 的确定信号),不只看 turn/end。
|
|
309
|
+
*
|
|
310
|
+
* 【2026-09-11 实跑修正】Job 787 实测:闭轮帧到了、头节点也出现了,直播尾却还
|
|
311
|
+
* 挂着一条空名字行 25 秒才消失(同一轮名字出现两次)。原因是 turn/end 是否被
|
|
312
|
+
* 装配器喂进 context 取决于投递链路(同一批帧实测会被重投一次;装配器对
|
|
313
|
+
* "非递增 seq"直接抛错,抛错即该轮 update 断流)——**不能再让渲染位的生死
|
|
314
|
+
* 依赖某一条事件**。改用"本段已落盘"这个更早、更硬的信号:段落落盘是宿主
|
|
315
|
+
* 闸门整段写的(turn/start 起、turn/end 收),turn/start 一到,官方区块已在
|
|
316
|
+
* 窗内就位、轮头也已接棒,直播尾必须当场退场。
|
|
317
|
+
*/
|
|
318
|
+
export function femo2TurnLiveVisible(state: Femo2TurnState | undefined): boolean {
|
|
319
|
+
if (state === undefined) return false
|
|
320
|
+
if (state.landed) return false
|
|
321
|
+
return state.firstBodySeq === undefined
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** 本轮在给定视角下是否可见(scope 过滤;visible 缺失=全员可见)。 */
|
|
325
|
+
export function femo2TurnVisibleTo(view: string, visible: readonly string[] | undefined): boolean {
|
|
326
|
+
if (view === 'god') return true
|
|
327
|
+
if (visible === undefined) return true
|
|
328
|
+
return visible.includes(view)
|
|
329
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* client-ui/proj2/turn-view.tsx — 显示层 v9 的唯一渲染器(头 / 直播尾两段)。
|
|
3
|
+
*
|
|
4
|
+
* 一轮 = 一个身份(turn)+ 两个渲染位,两个位共用同一份台账(ledger.ts):
|
|
5
|
+
*
|
|
6
|
+
* femo2-turn 轮头:showprompt📢 + 角色名 + 失败条。**本段落盘后才露面**
|
|
7
|
+
* (锚=段首内容 seq−0.5)——流式期由直播尾承担,避免"名字和
|
|
8
|
+
* 内容分家"(那种"甲头 乙头 甲内容"的错位正是旧链路病症)。
|
|
9
|
+
* femo2-turn-live 直播尾:showprompt + 角色名 + 直播块(cot/工具/回答)+ Deep
|
|
10
|
+
* diving。锚=1e12+开轮 seq(窗底,按激活顺序排列,并发不穿插)。
|
|
11
|
+
* 段落落盘(turn/end)即永久隐藏,内容交给官方区块。
|
|
12
|
+
*
|
|
13
|
+
* 「身」(cot / 工具调用 / 回答 / 轮内 steer)不由本文件画——那是官方渲染器
|
|
14
|
+
* 按段落闸门整段落盘的原生事件画的。本文件只画 femo 自己的 meta(📢/名字/失败)
|
|
15
|
+
* 与零落盘的直播流。这条分工是 v9 能"不再打架"的前提。
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { useMemo } from 'react'
|
|
19
|
+
import type { ConversationNodeDefinition } from '@deepseek-ai/dsh-client-runtime/client'
|
|
20
|
+
import type { ChatNodeViewProps } from '@deepseek-ai/dsh-client-ui-conversation/client'
|
|
21
|
+
import {
|
|
22
|
+
femo2TurnHeadAnchor, femo2TurnHeadVisible, femo2TurnLiveAnchor, femo2TurnLiveVisible,
|
|
23
|
+
femo2TurnMatch, femo2TurnStart, femo2TurnUpdate, femo2TurnVisibleTo,
|
|
24
|
+
type Femo2TurnState,
|
|
25
|
+
} from './ledger'
|
|
26
|
+
import { useFemo2Live } from './frame-router'
|
|
27
|
+
import { projectionWindowOf, windowShowsActor } from './window-id'
|
|
28
|
+
import { FemoStreamLive, FemoTurnStatus } from '../femo-stream-live'
|
|
29
|
+
import { useView } from '../view-state'
|
|
30
|
+
import { actorColor, LeadingIconText } from '../chat-node'
|
|
31
|
+
import { femoProjectionActorKey } from '../stream-store'
|
|
32
|
+
|
|
33
|
+
/** 轮头渲染载荷。 */
|
|
34
|
+
export interface Femo2TurnData {
|
|
35
|
+
readonly turn: number
|
|
36
|
+
readonly actor: string
|
|
37
|
+
readonly showprompt?: string
|
|
38
|
+
readonly error?: string
|
|
39
|
+
readonly visible?: readonly string[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 直播尾渲染载荷。 */
|
|
43
|
+
export interface Femo2TurnLiveData {
|
|
44
|
+
readonly turn: number
|
|
45
|
+
readonly actor: string
|
|
46
|
+
readonly actorKey: string
|
|
47
|
+
readonly showprompt?: string
|
|
48
|
+
readonly visible?: readonly string[]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare module '@deepseek-ai/dsh-client-ui-conversation/client' {
|
|
52
|
+
interface ChatNodeDataMap {
|
|
53
|
+
'femo2-turn': Femo2TurnData
|
|
54
|
+
'femo2-turn-live': Femo2TurnLiveData
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ── 轮头 ──────────────────────────────────────────────────────────────────
|
|
59
|
+
|
|
60
|
+
export const femo2TurnDefinition: ConversationNodeDefinition<Femo2TurnState> = {
|
|
61
|
+
kind: 'femo2-turn',
|
|
62
|
+
target: 'chat',
|
|
63
|
+
match: femo2TurnMatch,
|
|
64
|
+
start: (_context, match) => femo2TurnStart(match),
|
|
65
|
+
update: femo2TurnUpdate,
|
|
66
|
+
publication: () => 'immediate',
|
|
67
|
+
buildViewNode: (context) => {
|
|
68
|
+
const state = context.state
|
|
69
|
+
// ⚠️【2026-09-11 Job 790 实锤】**发布过的 target 绝不能再 return null**——
|
|
70
|
+
// 官方装配器 buildTargetUpserts 对"已物化节点被撤回"直接抛错:
|
|
71
|
+
// "withdrew materialized target 'chat'; return the same key with hidden visibility instead"
|
|
72
|
+
// 流式期本节点不露面,改成"同 key + visibility:'hidden'"。只有从未 start
|
|
73
|
+
// (state undefined,从未发布过)才允许返回 null。
|
|
74
|
+
if (state === undefined) return null
|
|
75
|
+
const shown = state.actor !== '' && femo2TurnHeadVisible(state)
|
|
76
|
+
return {
|
|
77
|
+
key: context.key,
|
|
78
|
+
kind: 'femo2-turn',
|
|
79
|
+
id: context.id,
|
|
80
|
+
target: 'chat',
|
|
81
|
+
anchorSeq: femo2TurnHeadAnchor(context),
|
|
82
|
+
location: { kind: 'unresolved' },
|
|
83
|
+
visibility: shown ? 'visible' : 'hidden',
|
|
84
|
+
data: {
|
|
85
|
+
turn: state.turn,
|
|
86
|
+
actor: state.actor,
|
|
87
|
+
...state.showprompt !== undefined ? { showprompt: state.showprompt } : {},
|
|
88
|
+
...state.error !== undefined ? { error: state.error } : {},
|
|
89
|
+
...state.visible !== undefined ? { visible: state.visible } : {},
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** 📢 showprompt 条(样式与 femo-role 的 prompt 行同款)。 */
|
|
96
|
+
function ShowpromptBar({ text }: { text: string }) {
|
|
97
|
+
return (
|
|
98
|
+
<div style={{
|
|
99
|
+
margin: '6px 0',
|
|
100
|
+
padding: '6px 12px',
|
|
101
|
+
borderRadius: '6px',
|
|
102
|
+
borderLeft: '3px solid var(--dsw-alias-button-info-fill, #4a9eff)',
|
|
103
|
+
background: 'color-mix(in srgb, var(--dsw-alias-button-info-fill, #4a9eff) 6%, transparent)',
|
|
104
|
+
color: 'var(--dsw-alias-label-secondary, #666)',
|
|
105
|
+
fontSize: '12px',
|
|
106
|
+
lineHeight: 1.5,
|
|
107
|
+
whiteSpace: 'pre-wrap',
|
|
108
|
+
wordBreak: 'break-word',
|
|
109
|
+
}}>
|
|
110
|
+
<LeadingIconText iconSize={11} text={text.startsWith('📢') ? text : `📢 ${text}`} />
|
|
111
|
+
</div>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** 角色名行(名字彩色,非气泡)。 */
|
|
116
|
+
function ActorLine({ actor }: { actor: string }) {
|
|
117
|
+
return (
|
|
118
|
+
<div style={{ fontWeight: 700, fontSize: '12.5px', color: actorColor(actor) }}>
|
|
119
|
+
{actor}
|
|
120
|
+
</div>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function Femo2TurnNodeView({ node, useSession, t: _t }: ChatNodeViewProps<'femo2-turn'>) {
|
|
125
|
+
const sessionId = useSession(snapshot => snapshot.sessionId)
|
|
126
|
+
const view = useView(sessionId)
|
|
127
|
+
const { actor, showprompt, error, visible } = node.data
|
|
128
|
+
if (view === 'offstage') return null
|
|
129
|
+
if (!femo2TurnVisibleTo(view, visible)) return null
|
|
130
|
+
return (
|
|
131
|
+
<div style={{ margin: '8px 0 2px' }}>
|
|
132
|
+
{showprompt !== undefined && <ShowpromptBar text={showprompt} />}
|
|
133
|
+
<ActorLine actor={actor} />
|
|
134
|
+
{error !== undefined && (
|
|
135
|
+
<div style={{
|
|
136
|
+
margin: '2px 0 4px',
|
|
137
|
+
color: 'var(--dsw-alias-state-error-primary, #e5484d)',
|
|
138
|
+
fontSize: '12px',
|
|
139
|
+
lineHeight: 1.5,
|
|
140
|
+
whiteSpace: 'pre-wrap',
|
|
141
|
+
wordBreak: 'break-word',
|
|
142
|
+
}}>
|
|
143
|
+
<LeadingIconText iconSize={11} text={error} />
|
|
144
|
+
</div>
|
|
145
|
+
)}
|
|
146
|
+
</div>
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ── 直播尾 ────────────────────────────────────────────────────────────────
|
|
151
|
+
|
|
152
|
+
export const femo2TurnLiveDefinition: ConversationNodeDefinition<Femo2TurnState> = {
|
|
153
|
+
kind: 'femo2-turn-live',
|
|
154
|
+
target: 'chat',
|
|
155
|
+
match: femo2TurnMatch,
|
|
156
|
+
start: (_context, match) => femo2TurnStart(match),
|
|
157
|
+
update: femo2TurnUpdate,
|
|
158
|
+
publication: () => 'immediate',
|
|
159
|
+
buildViewNode: (context) => {
|
|
160
|
+
const state = context.state
|
|
161
|
+
// 同轮头:发布过的节点只能"隐藏"不能"撤回"(官方装配器会抛错,见文件头注释)。
|
|
162
|
+
if (state === undefined) return null
|
|
163
|
+
// 本段一落盘(turn/start 到达)直播尾当场退场:官方区块已在窗内就位、
|
|
164
|
+
// 轮头已接棒,此处再画就是同一轮两个名字。判据见 femo2TurnLiveVisible
|
|
165
|
+
// (不再依赖 turn/end 是否被装配器喂进来——Job 787 实测它可能被投递链路
|
|
166
|
+
// 吞掉,导致空名字行赖着不走 25 秒)。
|
|
167
|
+
const shown = state.actor !== '' && femo2TurnLiveVisible(state)
|
|
168
|
+
return {
|
|
169
|
+
key: context.key,
|
|
170
|
+
kind: 'femo2-turn-live',
|
|
171
|
+
id: context.id,
|
|
172
|
+
target: 'chat',
|
|
173
|
+
anchorSeq: femo2TurnLiveAnchor(context),
|
|
174
|
+
location: { kind: 'unresolved' },
|
|
175
|
+
visibility: shown ? 'visible' : 'hidden',
|
|
176
|
+
data: {
|
|
177
|
+
turn: state.turn,
|
|
178
|
+
actor: state.actor,
|
|
179
|
+
actorKey: femoProjectionActorKey(state.actor),
|
|
180
|
+
...state.showprompt !== undefined ? { showprompt: state.showprompt } : {},
|
|
181
|
+
...state.visible !== undefined ? { visible: state.visible } : {},
|
|
182
|
+
},
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
export function Femo2TurnLiveNodeView({ node, useSession, t }: ChatNodeViewProps<'femo2-turn-live'>) {
|
|
189
|
+
const sessionId = useSession(snapshot => snapshot.sessionId)
|
|
190
|
+
const view = useView(sessionId)
|
|
191
|
+
const win = useMemo(() => projectionWindowOf(sessionId), [sessionId])
|
|
192
|
+
const { turn, actor, actorKey, showprompt, visible } = node.data
|
|
193
|
+
const inWindow = windowShowsActor(win.winActorKey, actorKey)
|
|
194
|
+
const eligible = view !== 'offstage' && inWindow && femo2TurnVisibleTo(view, visible) && win.mainSid !== undefined
|
|
195
|
+
const live = useFemo2Live(eligible ? win.mainSid : undefined, eligible ? turn : undefined)
|
|
196
|
+
// 【2026-09-11 v9.3 修正·用户实测】必须"**有内容 或 在飞**"才露面——不能"锚一到就画"。
|
|
197
|
+
// 开轮锚点由宿主在 turn/start 写下,而主模型可能还在思考/调工具(几十秒没有输出),
|
|
198
|
+
// 此时飘一个孤零零的名字行会看起来像"上一轮末尾又冒出个导演"(用户原话:复制点赞
|
|
199
|
+
// 那堆按钮之前怎么又出现一个导演)。窗底本来就有官方的 turn-tail 做"进行中"指示,
|
|
200
|
+
// 我们不需要挂空壳。
|
|
201
|
+
const showLive = live.blocks.length > 0 || live.running
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<div style={{ margin: '10px 0 4px' }}>
|
|
205
|
+
{showprompt !== undefined && <ShowpromptBar text={showprompt} />}
|
|
206
|
+
<ActorLine actor={actor} />
|
|
207
|
+
{live.blocks.length > 0 && <FemoStreamLive blocks={live.blocks} t={t} />}
|
|
208
|
+
{live.running && <FemoTurnStatus startTime={live.since} />}
|
|
209
|
+
</div>
|
|
210
|
+
)
|
|
211
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* client-ui/proj2/window-id.ts — 投影窗 id 解析(一处分身,处处同源)。
|
|
3
|
+
*
|
|
4
|
+
* 窗 id 规则(宿主 projection.ts projectionId):`femo-proj-<主会话id>-<actorKey>`,
|
|
5
|
+
* actorKey 不含 '-'(非 [A-Za-z0-9_-] 字符编码成 _<hex>),故末段必属 actorKey。
|
|
6
|
+
* 旧链路里这段推导在 chat-node / turn-nodes / director-node 各写了一遍,v9 收在一处。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface ProjectionWindow {
|
|
10
|
+
/** 主会话 id(SSE 帧的 sid 就是它)。 */
|
|
11
|
+
readonly mainSid?: string
|
|
12
|
+
/** 窗身份段:god / stage / <角色 actorKey>。 */
|
|
13
|
+
readonly winActorKey?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function projectionWindowOf(sessionId: string | undefined): ProjectionWindow {
|
|
17
|
+
if (sessionId === undefined || !sessionId.startsWith('femo-proj-')) return {}
|
|
18
|
+
const suffix = sessionId.slice('femo-proj-'.length)
|
|
19
|
+
const cut = suffix.lastIndexOf('-')
|
|
20
|
+
if (cut <= 0) return {}
|
|
21
|
+
return { mainSid: suffix.slice(0, cut), winActorKey: suffix.slice(cut + 1) }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** 本窗是否该渲染该角色的轮(god/stage 全显;角色窗只认自己的 actorKey)。 */
|
|
25
|
+
export function windowShowsActor(winActorKey: string | undefined, actorKey: string): boolean {
|
|
26
|
+
if (winActorKey === undefined) return false
|
|
27
|
+
return winActorKey === 'god' || winActorKey === 'stage' || winActorKey === actorKey
|
|
28
|
+
}
|