femo-plugin 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +632 -635
- package/docs/ActiveRoadmaps/ARCHITECTURE.md +466 -0
- package/docs/ActiveRoadmaps/compiler/345/244/232job/345/220/214/350/267/221/346/224/271/351/200/240-/346/226/275/345/267/245/346/270/205/345/215/225.md +164 -0
- package/docs/ActiveRoadmaps/dshAdapter-/351/207/215/346/236/204/346/226/275/345/267/245/346/270/205/345/215/225.md +154 -0
- package/docs/ActiveRoadmaps/hub/345/224/257/344/270/200/345/214/226/350/256/276/350/256/241.md +107 -0
- package/docs/ActiveRoadmaps/webAdapter-/351/235/231/351/273/230/351/230/266/346/242/257/346/226/275/345/267/245/344/272/244/346/216/245.md +158 -0
- package/docs/ActiveRoadmaps/zcode-/346/227/240/345/255/220/344/273/243/347/220/206/345/214/226/346/226/275/345/267/245/346/270/205/345/215/225.md +166 -0
- package/docs/ActiveRoadmaps//345/274/225/346/223/216/345/270/270/351/251/273/345/214/226/347/254/2542/346/255/245/344/272/244/346/216/245.md +108 -0
- package/docs/ActiveRoadmaps//345/274/225/346/223/216/345/270/270/351/251/273/350/277/233/347/250/213/346/226/275/345/267/245/346/270/205/345/215/225.md +178 -0
- package/docs/ActiveRoadmaps//346/212/225/345/275/261/345/256/277/344/270/273/346/240/207/346/263/250/344/277/256/346/255/243/350/256/276/350/256/241.md +61 -0
- package/docs/ActiveRoadmaps//346/212/225/345/275/261/351/241/265/346/213/206/345/210/206/346/226/275/345/267/245/346/270/205/345/215/225.md +116 -0
- package/docs/ActiveRoadmaps//347/224/273/345/270/203/347/233/264/350/277/236/345/274/225/346/223/216/346/226/275/345/267/245/346/270/205/345/215/225.md +259 -0
- package/docs/README.md +38 -0
- package/docs/Specs//345/205/254/345/205/261/345/261/202/350/256/276/350/256/241/347/272/246/346/235/237.md +63 -0
- package/docs/Specs//345/256/277/344/270/273/346/216/245/345/205/245/346/270/205/345/215/225.md +137 -0
- package/docs/Specs//346/212/225/345/275/261/344/270/255/345/277/203/350/241/214/345/215/217/350/256/256.md +569 -0
- package/docs/Specs//350/267/250/345/256/277/344/270/273/345/257/271/350/257/235/346/223/215/344/275/234/346/214/207/345/215/227.md +124 -0
- package/femo2host/AGENTS.md +165 -0
- package/femo2host/femoGenConnector/SKILL.common.md +232 -0
- package/femo2host/femoGenConnector/engine-client.mjs +255 -0
- package/femo2host/femoGenConnector/femogen-canvas-state.mjs +56 -0
- package/femo2host/femoGenConnector/femogen-files.d.mts +22 -0
- package/femo2host/femoGenConnector/femogen-files.mjs +208 -0
- package/femo2host/femoGenConnector/file-dialogs.d.mts +15 -0
- package/femo2host/femoGenConnector/file-dialogs.mjs +131 -0
- package/femo2host/femoGenConnector/sse-core.d.mts +40 -0
- package/femo2host/femoGenConnector/sse-core.mjs +95 -0
- package/femo2host/femoRoot.d.mts +7 -0
- package/femo2host/femoRoot.mjs +44 -0
- package/femo2host/femoToolcall/chronica.py +159 -156
- package/femo2host/femoToolcall/femo_debugger.py +1518 -1515
- package/femo2host/femo_api.py +472 -437
- package/femo2host/femo_gen_api.jsx +90 -77
- package/femo2host/host/api-retry.d.mts +44 -0
- package/femo2host/host/api-retry.mjs +155 -0
- package/femo2host/host/cast-core.d.mts +20 -0
- package/femo2host/host/cast-core.mjs +113 -0
- package/femo2host/host/daemon-client.d.mts +63 -0
- package/femo2host/host/daemon-client.mjs +606 -0
- package/femo2host/host/debug-run-core.d.mts +121 -0
- package/femo2host/host/debug-run-core.mjs +531 -0
- package/femo2host/host/delivery-queue.d.mts +18 -0
- package/femo2host/host/delivery-queue.mjs +101 -0
- package/femo2host/host/event-core.d.mts +84 -0
- package/femo2host/host/event-core.mjs +356 -0
- package/femo2host/host/femo-relation.d.mts +22 -0
- package/femo2host/host/femo-relation.mjs +39 -0
- package/femo2host/host/hub-client.d.mts +11 -0
- package/femo2host/host/hub-client.mjs +74 -0
- package/femo2host/host/hub-feed-core.d.mts +68 -0
- package/femo2host/host/hub-feed-core.mjs +274 -0
- package/femo2host/host/hub-render-core.d.mts +43 -0
- package/femo2host/host/hub-render-core.mjs +140 -0
- package/femo2host/host/mailbox-push-core.d.mts +40 -0
- package/femo2host/host/mailbox-push-core.mjs +113 -0
- package/femo2host/host/mount-registry.mjs +110 -0
- package/femo2host/host/node-retry.d.mts +37 -0
- package/femo2host/host/node-retry.mjs +200 -0
- package/femo2host/host/notice-core.d.mts +33 -0
- package/femo2host/host/notice-core.mjs +83 -0
- package/femo2host/host/projection-core.d.mts +78 -0
- package/femo2host/host/projection-core.mjs +279 -0
- package/femo2host/host/run-control-core.d.mts +23 -0
- package/femo2host/host/run-control-core.mjs +72 -0
- package/femo2host/host/run-state-core.d.mts +59 -0
- package/femo2host/host/run-state-core.mjs +173 -0
- package/femo2host/host/session-registry.mjs +56 -0
- package/femo2host/host/skill-expand.d.mts +11 -0
- package/femo2host/host/skill-expand.mjs +51 -0
- package/femo2host/host/speech-core.d.mts +43 -0
- package/femo2host/host/speech-core.mjs +75 -0
- package/femo2host/host/state-files.d.mts +35 -0
- package/femo2host/host/state-files.mjs +267 -0
- package/femo2host/host/subagent-core.d.mts +81 -0
- package/femo2host/host/subagent-core.mjs +303 -0
- package/femo2host/host/tools-core.d.mts +72 -0
- package/femo2host/host/tools-core.mjs +684 -0
- package/femo2host/host/variable-api.d.mts +23 -0
- package/femo2host/host/variable-api.mjs +90 -0
- package/femo2host/mail_courier.py +104 -0
- package/femo2host/mailbox.py +545 -0
- package/femo2host/projectionCenter/app.css +848 -0
- package/femo2host/projectionCenter/composer.mjs +272 -0
- package/femo2host/projectionCenter/debug-panel.mjs +131 -0
- package/femo2host/projectionCenter/index.html +96 -0
- package/femo2host/projectionCenter/main.mjs +479 -0
- package/femo2host/projectionCenter/panels.mjs +280 -0
- package/femo2host/projectionCenter/render.mjs +695 -0
- package/femo2host/projectionCenter/sessions.mjs +138 -0
- package/femo2host/projectionCenter/state.mjs +105 -0
- package/femo2host/projectionCenter/theme.css +250 -0
- package/femo2host/projectionCenter/util.mjs +96 -0
- package/femo2host/projection_hub.py +8422 -0
- package/femo2host/python/femo_bridge.py +2131 -0
- package/femo2host/python/femo_daemon.py +1209 -0
- package/femo2host/python/setting.py +153 -0
- package/femoBridges/ContextExample.py +167 -42
- package/femoBridges/MemoryExample.py +33 -30
- package/femoBridges/getDir/get_dir.py +32 -18
- 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 +1 -1
- package/femoBridges/llmBridge.py +1 -1
- package/femoBridges/llmProviders.py +39 -35
- package/femoCompiler/AGENTS.md +185 -0
- package/femoCompiler/FEMO_CLIrenderer.py +50 -30
- package/femoCompiler/FEMO_config.py +2 -1
- package/femoCompiler/FEMO_errors.py +286 -278
- package/femoCompiler/FEMO_normalizer.py +12 -7
- package/femoCompiler/FEMO_parser.py +217 -118
- package/femoCompiler/FEMO_runtime.py +491 -251
- package/femoCompiler/FEMO_scope_resolver.py +6 -3
- package/femoCompiler/actor_resolver.py +3 -3
- package/femoCompiler/block_collector.py +31 -28
- package/femoCompiler/db_utils.py +18 -0
- package/femoCompiler/femoAsync.py +436 -401
- package/femoCompiler/host_manifest.py +22 -2
- package/femoCompiler/job_manager.py +203 -61
- package/femoCompiler/protocol.py +13 -12
- package/femoCompiler/save_dialog.py +103 -59
- package/femoCompiler/task_world.py +579 -544
- package/femoCompiler/vars/checkpoint.py +3 -3
- package/femoCompiler/vars/env.py +77 -12
- package/femoCompiler/vars/evaluator.py +11 -6
- package/femoCompiler/vars/join.py +1 -1
- package/femoCompiler/vars/model.py +7 -7
- package/femoExamples/AI/345/211/252/350/247/206/351/242/221/AI/345/211/252/350/247/206/351/242/221.femo +5 -5
- 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 +142 -0
- package/femoExamples/AI/350/201/212/345/244/251/345/256/244/AI/350/201/212/345/244/251/345/256/244.femo +111 -0
- package/femoExamples/AI/350/201/212/345/244/251/345/256/244/random_wait_time.py +80 -10
- package/{hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/LuxFiat/luxfiat.femo → femoExamples/LuxFiat/luxfiat-loop.femo} +67 -38
- package/femoExamples/LuxFiat/{luxfiat.femo → luxfiat-simple.femo} +1 -15
- package/femoExamples/LuxFiat/wait.py +2 -2
- package/femoExamples/_join_wiring_tlib.py +28 -0
- package/femoExamples/discussion.femo +7 -5
- package/femoExamples/mt_test/file_a.py +5 -0
- package/femoExamples/plan-mode.femo +55 -0
- package/femoExamples//345/237/272/347/241/200/350/277/236/351/200/232/346/265/213/350/257/225.femo +38 -0
- package/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils2.py +248 -20
- package/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils9.py +609 -0
- package/{hostAdapter/zcodeAdapter/femo-zcode-dist/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 → 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} +308 -53
- 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 +222 -47
- package/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200.femo +4 -4
- package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225/undercover_utils.py +286 -2
- package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225//350/260/201/346/230/257/345/215/247/345/272/225-/350/217/234/345/270/202/345/234/272/345/261/200.femo +95 -3
- 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 +126 -42
- package/femoGen/AGENTS.md +145 -0
- package/femoGen/document_ch.html +20 -13
- package/femoGen/document_en.html +9 -2
- package/femoGen/index.html +4 -2
- package/femoGen/intro_ch.html +28 -26
- package/femoGen/intro_en.html +9 -2
- package/femoGen/src/FemoWorAuto.jsx +1215 -257
- package/femoGen/src/actionModal.jsx +2 -2
- package/femoGen/src/bubbleOverlay.jsx +7 -5
- package/femoGen/src/canvasNodes.jsx +261 -61
- package/femoGen/src/common.jsx +94 -20
- package/femoGen/src/debugPanel.jsx +170 -43
- package/femoGen/src/engineWatch.jsx +323 -0
- package/femoGen/src/faIcons.jsx +11 -4
- package/femoGen/src/femoDiagnostics.js +1 -1
- package/femoGen/src/femoDirBrowse.jsx +430 -0
- package/femoGen/src/femoFileList.jsx +36 -6
- package/femoGen/src/femoGenerator.jsx +9 -9
- package/femoGen/src/femoParser.jsx +2276 -2255
- package/femoGen/src/femoPreview.jsx +30 -0
- package/femoGen/src/femoSaveReminder.jsx +75 -0
- package/femoGen/src/graphBuilder.jsx +2 -2
- package/femoGen/src/indentEdit.js +81 -0
- package/femoGen/src/libPanel.jsx +1 -1
- package/femoGen/src/mobileView.jsx +2871 -2796
- package/femoGen/src/projectPanel.jsx +2 -2
- package/femoGen/src/snap.js +101 -0
- package/femoGen/src/soulModal.jsx +4 -2
- package/femoGen/src/styles/font.css +13 -10
- package/femoGen/src/themes.js +297 -12
- package/femoGen/src/watchMirror.js +170 -0
- package/femoGen/vite.config.js +33 -28
- package/hostAdapter/dshAdapter/README.md +112 -68
- package/hostAdapter/dshAdapter/build.mjs +49 -6
- package/hostAdapter/dshAdapter/check-imports.mjs +85 -0
- package/hostAdapter/dshAdapter/client/client-ui/cast-button.tsx +232 -0
- package/hostAdapter/dshAdapter/client/{lineage-fork-native.jsx → client-ui/catalog-dropdown.jsx} +689 -624
- package/hostAdapter/dshAdapter/client/client-ui/chat-node.tsx +12 -9
- package/hostAdapter/dshAdapter/client/client-ui/composer-common.tsx +74 -0
- package/hostAdapter/dshAdapter/client/client-ui/composer-permission.tsx +183 -0
- package/hostAdapter/dshAdapter/client/client-ui/composer-ring.tsx +196 -0
- package/hostAdapter/dshAdapter/client/client-ui/composer-run-state.tsx +134 -0
- package/hostAdapter/dshAdapter/client/client-ui/composer-stats.tsx +163 -0
- package/hostAdapter/dshAdapter/client/client-ui/composer.tsx +417 -1100
- package/hostAdapter/dshAdapter/client/client-ui/editor-page.tsx +747 -726
- package/hostAdapter/dshAdapter/client/client-ui/editor-view.tsx +89 -88
- package/hostAdapter/dshAdapter/client/client-ui/hub-constants.ts +10 -0
- package/hostAdapter/dshAdapter/client/client-ui/hub-window.tsx +545 -0
- package/hostAdapter/dshAdapter/client/client-ui/primitives-compat.ts +39 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/frame-router.ts +17 -52
- package/hostAdapter/dshAdapter/client/client-ui/proj2/index.ts +1 -1
- package/hostAdapter/dshAdapter/client/client-ui/proj2/ledger.ts +12 -12
- package/hostAdapter/dshAdapter/client/client-ui/proj2/turn-view.tsx +8 -16
- package/hostAdapter/dshAdapter/client/client-ui/proj2/window-id.ts +8 -9
- package/hostAdapter/dshAdapter/client/client-ui/stream-store.ts +187 -550
- package/hostAdapter/dshAdapter/client/client-ui/styles.ts +4 -10
- package/hostAdapter/dshAdapter/client/client-ui/view-button.tsx +550 -572
- package/hostAdapter/dshAdapter/client/client-ui/view-state.ts +1 -1
- package/hostAdapter/dshAdapter/client/client.tsx +611 -518
- package/hostAdapter/dshAdapter/client/femo-reasoning-row.tsx +104 -103
- package/hostAdapter/dshAdapter/client/femo-tool-row.tsx +264 -0
- package/hostAdapter/dshAdapter/client/lineage-fork.jsx +55 -570
- package/hostAdapter/dshAdapter/dshPatch/DSH-0.1.2-fork/344/277/256/346/224/271/351/234/200/346/261/202.md +4 -4
- package/hostAdapter/dshAdapter/dshPatch/patch-dsh-0.1.2-alpha.1.py +1 -1
- package/{femo2host/femoToolcall → hostAdapter/dshAdapter}/femo-chat.mjs +4 -2
- package/hostAdapter/dshAdapter/host/actor-name.ts +30 -0
- package/hostAdapter/dshAdapter/host/actor-usage.ts +54 -0
- package/hostAdapter/dshAdapter/host/actors/dispatch.ts +152 -0
- package/hostAdapter/dshAdapter/host/actors/main/capture.ts +219 -0
- package/hostAdapter/dshAdapter/host/actors/main/delivery.ts +233 -0
- package/hostAdapter/dshAdapter/host/actors/main/index.ts +420 -0
- package/hostAdapter/dshAdapter/host/actors/main/notice.ts +180 -0
- package/hostAdapter/dshAdapter/host/actors/native/child-setup.ts +103 -0
- package/hostAdapter/dshAdapter/host/actors/native/index.ts +672 -0
- package/hostAdapter/dshAdapter/host/actors/native/registry.ts +55 -0
- package/hostAdapter/dshAdapter/host/actors/native/turn-watch.ts +159 -0
- package/hostAdapter/dshAdapter/host/api-retry.ts +30 -123
- package/hostAdapter/dshAdapter/host/bridge-supervisor.ts +96 -0
- package/hostAdapter/dshAdapter/host/bridge.ts +147 -224
- package/hostAdapter/dshAdapter/host/compat/dsh-session-host.ts +46 -0
- package/hostAdapter/dshAdapter/host/{list-cache.ts → compat/list-cache.ts} +1 -1
- package/hostAdapter/dshAdapter/host/compat/plugin-source.ts +41 -0
- package/hostAdapter/dshAdapter/host/config.ts +149 -124
- package/hostAdapter/dshAdapter/host/debug-run.ts +274 -793
- package/hostAdapter/dshAdapter/host/diag/debug-log.ts +44 -0
- package/hostAdapter/dshAdapter/host/{diag-feed.ts → diag/diag-feed.ts} +11 -18
- package/hostAdapter/dshAdapter/host/{host-log.ts → diag/host-log.ts} +1 -1
- package/hostAdapter/dshAdapter/host/engine-transcript.ts +2 -2
- package/hostAdapter/dshAdapter/host/events/engine-events.ts +747 -0
- package/hostAdapter/dshAdapter/host/events/mailbox-push.ts +332 -0
- package/hostAdapter/dshAdapter/host/{pre-step-gate.ts → events/pre-step-gate.ts} +26 -32
- package/hostAdapter/dshAdapter/host/femo-files.ts +6 -207
- package/hostAdapter/dshAdapter/host/femo-skill.ts +153 -0
- package/hostAdapter/dshAdapter/host/femoIdentity.ts +101 -0
- package/hostAdapter/dshAdapter/host/http.ts +10 -12
- package/hostAdapter/dshAdapter/host/hub/god-mirror.ts +307 -0
- package/hostAdapter/dshAdapter/host/hub/hub-feed.ts +129 -0
- package/hostAdapter/dshAdapter/host/hub/hub-proxy.ts +203 -0
- package/hostAdapter/dshAdapter/host/{stream-frames.ts → hub/stream-frames.ts} +36 -77
- package/hostAdapter/dshAdapter/host/index.ts +354 -638
- package/hostAdapter/dshAdapter/host/job-index.ts +36 -0
- package/hostAdapter/dshAdapter/host/main-actor.ts +24 -853
- package/hostAdapter/dshAdapter/host/main-delivery-queue.ts +5 -112
- package/hostAdapter/dshAdapter/host/node-retry.ts +22 -246
- package/hostAdapter/dshAdapter/host/persona.ts +50 -96
- package/hostAdapter/dshAdapter/host/projection/hub-anchor.ts +21 -0
- package/hostAdapter/dshAdapter/host/{projection.ts → projection/projection.ts} +112 -188
- package/hostAdapter/dshAdapter/host/{windowing-native.ts → projection/windowing-native.ts} +35 -37
- package/hostAdapter/dshAdapter/host/routes/dialogs.ts +63 -0
- package/hostAdapter/dshAdapter/host/routes/engine-gateway.ts +128 -0
- package/hostAdapter/dshAdapter/host/routes/index.ts +603 -0
- package/hostAdapter/dshAdapter/host/{projection-input.ts → routes/projection-input.ts} +255 -246
- package/hostAdapter/dshAdapter/host/routes/projection.ts +174 -0
- package/hostAdapter/dshAdapter/host/routes/run.ts +127 -0
- package/hostAdapter/dshAdapter/host/routes/script-files.ts +68 -0
- package/hostAdapter/dshAdapter/host/routes/state.ts +273 -0
- package/hostAdapter/dshAdapter/host/run-control.ts +687 -641
- package/hostAdapter/dshAdapter/host/session-roster.ts +407 -0
- package/hostAdapter/dshAdapter/host/sse.ts +27 -0
- package/hostAdapter/dshAdapter/host/state-files.ts +13 -301
- package/hostAdapter/dshAdapter/host/tool-deps.ts +299 -0
- package/hostAdapter/dshAdapter/host/tools.ts +395 -486
- package/hostAdapter/dshAdapter/host/verbs.ts +81 -0
- package/hostAdapter/dshAdapter/host.manifest.json +2 -1
- package/hostAdapter/dshAdapter/lib/client.js +9209 -6558
- package/hostAdapter/dshAdapter/lib/client.js.map +4 -4
- package/hostAdapter/dshAdapter/lib/index.js +13 -8213
- package/hostAdapter/dshAdapter/lib/index.js.map +4 -4
- package/hostAdapter/dshAdapter/lib/main.js +10154 -0
- package/hostAdapter/dshAdapter/lib/main.js.map +7 -0
- package/hostAdapter/dshAdapter/package.json +5 -4
- package/hostAdapter/dshAdapter/pnpm-lock.yaml +606 -596
- package/hostAdapter/dshAdapter/shared/window-id.d.mts +5 -0
- package/hostAdapter/dshAdapter/shared/window-id.mjs +22 -0
- package/hostAdapter/dshAdapter/tsconfig.host-verify.json +6 -0
- package/hostAdapter/dshAdapter/tsconfig.json +1 -3
- package/hostAdapter/webAdapter/AGENTS.md +203 -0
- package/hostAdapter/webAdapter/console/index.html +760 -0
- package/hostAdapter/webAdapter/extension/background.js +738 -0
- package/hostAdapter/webAdapter/extension/bubble.js +201 -0
- package/hostAdapter/webAdapter/extension/icons/icon128.png +0 -0
- package/hostAdapter/webAdapter/extension/icons/icon16.png +0 -0
- package/hostAdapter/webAdapter/extension/icons/icon32.png +0 -0
- package/hostAdapter/webAdapter/extension/icons/icon48.png +0 -0
- package/hostAdapter/webAdapter/extension/seat-agent-core.js +791 -0
- package/hostAdapter/webAdapter/extension/sidepanel/conn.mjs +25 -0
- package/hostAdapter/webAdapter/extension/sidepanel/feeds.mjs +57 -0
- package/hostAdapter/webAdapter/extension/sidepanel/human-seat.mjs +111 -0
- package/hostAdapter/webAdapter/extension/sidepanel/main.mjs +186 -0
- package/hostAdapter/webAdapter/extension/sidepanel/run-control.mjs +183 -0
- package/hostAdapter/webAdapter/extension/sidepanel/seats.mjs +172 -0
- package/hostAdapter/webAdapter/extension/sidepanel/svclog.mjs +78 -0
- package/hostAdapter/webAdapter/extension/sidepanel.html +600 -0
- package/hostAdapter/webAdapter/manifest.json +158 -0
- package/hostAdapter/webAdapter/native/install-native-host.cmd +8 -0
- package/hostAdapter/webAdapter/native/install-native-host.mjs +27 -0
- package/hostAdapter/webAdapter/native/register-core.mjs +101 -0
- package/hostAdapter/webAdapter/native/web-launcher.cs +141 -0
- package/hostAdapter/webAdapter/native/web-launcher.mjs +160 -0
- package/hostAdapter/webAdapter/package.json +13 -0
- package/hostAdapter/webAdapter/readme.md +365 -0
- package/hostAdapter/webAdapter/server/board.mjs +42 -0
- package/hostAdapter/webAdapter/server/bridge.mjs +68 -0
- package/hostAdapter/webAdapter/server/canvas.mjs +520 -0
- package/hostAdapter/webAdapter/server/http-io.mjs +20 -0
- package/hostAdapter/webAdapter/server/keeper.mjs +114 -0
- package/hostAdapter/webAdapter/server/mailbox-push.mjs +184 -0
- package/hostAdapter/webAdapter/server/runtime.mjs +1025 -0
- package/hostAdapter/webAdapter/server/seats.mjs +239 -0
- package/hostAdapter/webAdapter/server/service.mjs +1051 -0
- package/hostAdapter/webAdapter/shared/dom.mjs +33 -0
- package/hostAdapter/webAdapter/shared/femo-logo.mjs +36 -0
- package/hostAdapter/webAdapter/shared/guard.mjs +28 -0
- package/hostAdapter/webAdapter/shared/human-seat-core.mjs +56 -0
- package/hostAdapter/webAdapter/shared/run-core.mjs +20 -0
- package/hostAdapter/webAdapter/shared/seats-core.mjs +73 -0
- package/hostAdapter/webAdapter/sites/aistudio.google.com/SITE.md +66 -0
- package/hostAdapter/webAdapter/sites/aistudio.google.com/content.js +144 -0
- package/hostAdapter/webAdapter/sites/aistudio.google.com/inject.js +240 -0
- package/hostAdapter/webAdapter/sites/aistudio.google.com/site.mjs +70 -0
- package/hostAdapter/webAdapter/sites/chat.deepseek.com/SITE.md +77 -0
- package/hostAdapter/webAdapter/sites/chat.deepseek.com/content.js +103 -0
- package/hostAdapter/webAdapter/sites/chat.deepseek.com/inject.js +181 -0
- package/hostAdapter/webAdapter/sites/chat.deepseek.com/site.mjs +73 -0
- package/hostAdapter/webAdapter/sites/chatglm.cn/SITE.md +63 -0
- package/hostAdapter/webAdapter/sites/chatglm.cn/content.js +121 -0
- package/hostAdapter/webAdapter/sites/chatglm.cn/inject.js +190 -0
- package/hostAdapter/webAdapter/sites/chatglm.cn/site.mjs +63 -0
- package/hostAdapter/webAdapter/sites/chatgpt.com/SITE.md +58 -0
- package/hostAdapter/webAdapter/sites/chatgpt.com/content.js +124 -0
- package/hostAdapter/webAdapter/sites/chatgpt.com/inject.js +404 -0
- package/hostAdapter/webAdapter/sites/chatgpt.com/site.mjs +68 -0
- package/hostAdapter/webAdapter/sites/grok.com/SITE.md +42 -0
- package/hostAdapter/webAdapter/sites/grok.com/content.js +120 -0
- package/hostAdapter/webAdapter/sites/grok.com/inject.js +259 -0
- package/hostAdapter/webAdapter/sites/grok.com/site.mjs +73 -0
- package/hostAdapter/webAdapter/sites/www.doubao.com/SITE.md +62 -0
- package/hostAdapter/webAdapter/sites/www.doubao.com/content.js +115 -0
- package/hostAdapter/webAdapter/sites/www.doubao.com/inject.js +232 -0
- package/hostAdapter/webAdapter/sites/www.doubao.com/site.mjs +62 -0
- package/hostAdapter/webAdapter/sites/www.kimi.com/SITE.md +57 -0
- package/hostAdapter/webAdapter/sites/www.kimi.com/content.js +117 -0
- package/hostAdapter/webAdapter/sites/www.kimi.com/inject.js +194 -0
- package/hostAdapter/webAdapter/sites/www.kimi.com/site.mjs +61 -0
- package/hostAdapter/webAdapter/sites/www.qianwen.com/SITE.md +43 -0
- package/hostAdapter/webAdapter/sites/www.qianwen.com/content.js +123 -0
- package/hostAdapter/webAdapter/sites/www.qianwen.com/inject.js +273 -0
- package/hostAdapter/webAdapter/sites/www.qianwen.com/site.mjs +72 -0
- package/hostAdapter/webAdapter/sites.mjs +67 -0
- package/hostAdapter/webAdapter/start-service.cmd +13 -0
- package/hostAdapter/webAdapter/tests/canvas-files.test.mjs +134 -0
- package/hostAdapter/webAdapter/tests/chatgpt-parser.test.mjs +161 -0
- package/hostAdapter/webAdapter/tests/doubao-parser.test.mjs +151 -0
- package/hostAdapter/webAdapter/tests/keeper.test.mjs +108 -0
- package/hostAdapter/webAdapter/tests/runtime.test.mjs +962 -0
- package/hostAdapter/webAdapter/tests/seats-core.test.mjs +134 -0
- package/hostAdapter/webAdapter/tests/site-boundary.test.mjs +161 -0
- package/hostAdapter/webAdapter/tests/smoke-bridge.mjs +65 -0
- package/hostAdapter/webAdapter/tests/smoke-service.mjs +232 -0
- package/hostAdapter/webAdapter/web.host.manifest.json +6 -0
- package/hostAdapter/zcodeAdapter/.zcode-plugin/plugin.json +23 -23
- package/hostAdapter/zcodeAdapter/README.md +73 -61
- package/hostAdapter/zcodeAdapter/commands/femo.md +8 -9
- package/hostAdapter/zcodeAdapter/hooks/hooks.json +13 -16
- package/hostAdapter/zcodeAdapter/hooks/lib.mjs +318 -59
- package/hostAdapter/zcodeAdapter/hooks/mail-context.mjs +4 -0
- package/hostAdapter/zcodeAdapter/hooks/stop-intent.mjs +4 -3
- package/hostAdapter/zcodeAdapter/hooks/turn-collect.mjs +3 -0
- package/hostAdapter/zcodeAdapter/icon.png +0 -0
- package/hostAdapter/zcodeAdapter/mcp/engine-bind.mjs +56 -0
- package/hostAdapter/zcodeAdapter/mcp/event-router.mjs +42 -258
- package/hostAdapter/zcodeAdapter/mcp/femo-server.mjs +198 -320
- package/hostAdapter/zcodeAdapter/paths.mjs +78 -0
- package/hostAdapter/zcodeAdapter/runtime/femo-possess.mjs +356 -0
- package/hostAdapter/zcodeAdapter/runtime/femo-stream-watcher.mjs +214 -0
- package/hostAdapter/zcodeAdapter/runtime/mailbox-cli.mjs +33 -0
- package/hostAdapter/zcodeAdapter/runtime/pulled-letter.mjs +36 -0
- package/hostAdapter/zcodeAdapter/runtime/speech-collect.mjs +547 -0
- package/hostAdapter/zcodeAdapter/skills/femo/SKILL.md +52 -89
- package/hostAdapter/zcodeAdapter/tests/bridge-smoke.mjs +16 -6
- package/hostAdapter/zcodeAdapter/tests/event-router.test.mjs +160 -157
- package/hostAdapter/zcodeAdapter/tests/harness.mjs +91 -0
- package/hostAdapter/zcodeAdapter/tests/hooks-smoke.mjs +205 -0
- package/hostAdapter/zcodeAdapter/tests/integration-human.mjs +34 -17
- package/hostAdapter/zcodeAdapter/tests/main-actor.mjs +203 -107
- package/hostAdapter/zcodeAdapter/tests/mcp-smoke.mjs +100 -130
- package/hostAdapter/zcodeAdapter/tests/memory-store.mjs +72 -0
- package/hostAdapter/zcodeAdapter/tests/modelio-weave.test.mjs +82 -0
- package/hostAdapter/zcodeAdapter/tests/mount-state.test.mjs +150 -0
- package/hostAdapter/zcodeAdapter/tests/pulled-letter.test.mjs +77 -0
- package/hostAdapter/zcodeAdapter/tests/run-state-core.test.mjs +95 -0
- package/hostAdapter/zcodeAdapter/tests/speech-draft.mjs +163 -0
- package/hostAdapter/zcodeAdapter/tests/stream-watcher.test.mjs +154 -0
- package/hostAdapter/zcodeAdapter/tests/turn-marker.test.mjs +110 -0
- package/hostAdapter/zcodeAdapter/tests/unbound-actors.test.mjs +48 -0
- package/hostAdapter/zcodeAdapter/tests/variable-api.test.mjs +79 -0
- package/hostAdapter/zcodeAdapter/zcode.host.manifest.json +2 -1
- package/package.json +2 -2
- package//350/257/255/346/263/225/346/226/207/346/241/243.md +1202 -1136
- package/FEMO_logo.svg +0 -55
- package/FEMO_logo_slogan.svg +0 -29
- package/_tmp/fallback/driver2.py +0 -176
- package/_tmp/fallback/events.jsonl +0 -108
- package/_tmp/fallback/gateway_ui.py +0 -325
- package/_tmp/fallback/outbox/j1553_human_[/347/234/213/347/211/214]_1.done +0 -1
- package/_tmp/fallback/outbox/r1.done +0 -1
- package/_tmp/fallback/outbox/r2.done +0 -1
- package/_tmp/fallback/outbox/r3.done +0 -1
- package/_tmp/fallback/outbox/r4.done +0 -1
- package/_tmp/fallback/outbox/r5.done +0 -1
- package/femoExamples/AI/350/201/212/345/244/251/345/256/244/group-chat.femo +0 -42
- package/femoGen/src/useCanvasInteraction.jsx +0 -319
- package/hostAdapter/dshAdapter/client/client-ui/femo-stream-live.tsx +0 -264
- package/hostAdapter/dshAdapter/dshPatch/MEOW_MODIFICATIONS.md +0 -3105
- package/hostAdapter/dshAdapter/host/debug-log.ts +0 -29
- package/hostAdapter/dshAdapter/host/engine-events.ts +0 -894
- package/hostAdapter/dshAdapter/host/god-mirror.ts +0 -234
- package/hostAdapter/dshAdapter/host/preset-install.ts +0 -59
- package/hostAdapter/dshAdapter/host/proj-trace.ts +0 -49
- package/hostAdapter/dshAdapter/host/routes.ts +0 -1196
- package/hostAdapter/dshAdapter/host/section-gate.ts +0 -108
- package/hostAdapter/dshAdapter/host/subagent-native.ts +0 -997
- package/hostAdapter/dshAdapter/host/subagent.ts +0 -1205
- package/hostAdapter/dshAdapter/package-lock.json +0 -500
- package/hostAdapter/dshAdapter/preset/agent.cordis.yml +0 -220
- package/hostAdapter/dshAdapter/preset/preset.yml +0 -3
- package/hostAdapter/dshAdapter/python/dev-bridge-test.py +0 -43
- package/hostAdapter/dshAdapter/python/femo_bridge.py +0 -533
- package/hostAdapter/zcodeAdapter/.tmp/femo/host-history/gateway.port +0 -1
- package/hostAdapter/zcodeAdapter/.tmp/femo/host-history/proj-mirror/femo-main-a-_40_52a9_624b.jsonl +0 -3
- package/hostAdapter/zcodeAdapter/.tmp/femo/host-history/proj-mirror/femo-main-a-_40_6211.jsonl +0 -10
- package/hostAdapter/zcodeAdapter/.tmp/femo/host-history/proj-mirror/femo-main-god.jsonl +0 -11
- package/hostAdapter/zcodeAdapter/.tmp/femo/host-history/proj-mirror/femo-main-stage.jsonl +0 -11
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/.zcode-plugin/plugin.json +0 -23
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/LICENSE +0 -201
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/README.md +0 -635
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/commands/femo.md +0 -9
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femo2host/__init__.py +0 -4
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femo2host/femoToolcall/chronica.py +0 -156
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femo2host/femoToolcall/femo-chat.mjs +0 -69
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femo2host/femoToolcall/femo_debugger.py +0 -1515
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femo2host/femo_api.py +0 -437
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femo2host/femo_gen_api.jsx +0 -77
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoBridges/ContextExample.py +0 -555
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoBridges/MemoryExample.py +0 -163
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoBridges/__init__.py +0 -1
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoBridges/getDir/get_dir.py +0 -56
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/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 +0 -10
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoBridges/llmBridge.py +0 -247
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoBridges/llmProviders.py +0 -308
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_CLIrenderer.py +0 -198
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_config.py +0 -35
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_errors.py +0 -278
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_interpreter.py +0 -163
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_normalizer.py +0 -396
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_parser.py +0 -2468
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_runtime.py +0 -3630
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_scope_resolver.py +0 -209
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/__init__.py +0 -1
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/actor_resolver.py +0 -86
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/block_collector.py +0 -441
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/db_utils.py +0 -485
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/femoAsync.py +0 -401
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/host_manifest.py +0 -68
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/job_manager.py +0 -767
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/protocol.py +0 -126
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/save_dialog.py +0 -402
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/task_world.py +0 -544
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/__init__.py +0 -19
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/checkpoint.py +0 -113
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/env.py +0 -686
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/evaluator.py +0 -567
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/join.py +0 -303
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/merge.py +0 -157
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/model.py +0 -245
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/AI/345/211/252/350/247/206/351/242/221/AI/345/211/252/350/247/206/351/242/221.femo +0 -192
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/AI/350/201/212/345/244/251/345/256/244/group-chat.femo +0 -42
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/AI/350/201/212/345/244/251/345/256/244/random_wait_time.py +0 -10
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/LuxFiat/wait.py +0 -29
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/debug/347/245/236/345/231/250/debug/347/245/236/345/231/250.femo +0 -222
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/discussion.femo +0 -70
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/goal-mode.femo +0 -23
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples//345/270/270/347/224/250/345/267/245/345/205/267python/wait.py +0 -29
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils.py +0 -205
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils2.py +0 -324
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200.femo +0 -331
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225/undercover_utils.py +0 -683
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/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 +0 -348
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/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 +0 -393
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/hooks/after-tool.mjs +0 -3
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/hooks/hooks.json +0 -16
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/hooks/lib.mjs +0 -59
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/hooks/prompt-state.mjs +0 -3
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/hooks/session-start.mjs +0 -3
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/hooks/stop-intent.mjs +0 -3
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/hostAdapter/dshAdapter/python/dev-bridge-test.py +0 -43
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/hostAdapter/dshAdapter/python/femo_bridge.py +0 -533
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/mcp/bridge-manager.mjs +0 -192
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/mcp/event-router.mjs +0 -258
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/mcp/femo-server.mjs +0 -429
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/mcp/gateway.mjs +0 -163
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/mcp/projection-writer.mjs +0 -294
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/skills/femo/SKILL.md +0 -93
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/bridge-smoke.mjs +0 -26
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/event-router.test.mjs +0 -157
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/gateway-smoke.mjs +0 -107
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/integration-human.mjs +0 -111
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/main-actor.mjs +0 -107
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/mcp-smoke.mjs +0 -130
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/projection-writer.test.mjs +0 -144
- package/hostAdapter/zcodeAdapter/femo-zcode-dist/zcode.host.manifest.json +0 -5
- package/hostAdapter/zcodeAdapter/femo-zcode-dist//346/212/225/345/275/261/347/252/227/351/207/215/350/256/276/350/256/241-/350/256/250/350/256/272/347/250/277.md +0 -113
- package/hostAdapter/zcodeAdapter/femo-zcode-dist//350/257/255/346/263/225/346/226/207/346/241/243.md +0 -1136
- package/hostAdapter/zcodeAdapter/hooks/after-tool.mjs +0 -3
- package/hostAdapter/zcodeAdapter/hooks/prompt-state.mjs +0 -3
- package/hostAdapter/zcodeAdapter/hooks/session-start.mjs +0 -3
- package/hostAdapter/zcodeAdapter/mcp/bridge-manager.mjs +0 -192
- package/hostAdapter/zcodeAdapter/mcp/gateway.mjs +0 -163
- package/hostAdapter/zcodeAdapter/mcp/projection-writer.mjs +0 -294
- package/hostAdapter/zcodeAdapter/tests/gateway-smoke.mjs +0 -107
- package/hostAdapter/zcodeAdapter/tests/projection-writer.test.mjs +0 -144
- package/hostAdapter/zcodeAdapter//346/212/225/345/275/261/347/252/227/351/207/215/350/256/276/350/256/241-/350/256/250/350/256/272/347/250/277.md +0 -113
- package/scripts/diag-find-redblue.mjs +0 -38
- package/scripts/diag-god-log.mjs +0 -31
- package/scripts/diag-god-log2.mjs +0 -39
- package/scripts/diag-god-log3.mjs +0 -35
- package/scripts/diag-god-log4.mjs +0 -59
- package/scripts/diag-god-log4b.mjs +0 -39
- package/scripts/diag-redblue-god.mjs +0 -39
- package/scripts/diag-redblue-log.mjs +0 -37
- package/scripts/diag-redblue-span.mjs +0 -41
- package/scripts/diag-stage-1017.mjs +0 -63
- package/scripts/dump_session.py +0 -36
- package/scripts/link-workspace.ps1 +0 -51
- package/scripts/list_souls.py +0 -18
- package/scripts/probe-composer-refresh.mjs +0 -197
- package/scripts/seed_story_souls.py +0 -86
- package/scripts/sync-zcode-dist.ps1 +0 -55
- package/scripts/theme-tokenize/color-extract.txt +0 -288
- package/scripts/theme-tokenize/round1-quoted.ps1 +0 -149
- package/scripts/theme-tokenize/round2-bare.ps1 +0 -138
- package/scripts/theme-tokenize/round3-shape.ps1 +0 -110
- package/tests/_diag_r4_join.femo +0 -32
- package/tests/conftest.py +0 -95
- package/tests/diag-subagent-dir-3081.mjs +0 -101
- package/tests/femoGenerator.test.mjs +0 -3909
- package/tests/femoParser.test.mjs +0 -4813
- package/tests/femogen_notice.test.mjs +0 -109
- package/tests/femoparser_validation.test.mjs +0 -84
- package/tests/main-delivery-queue.test.mjs +0 -329
- package/tests/pre-step-gate.test.mjs +0 -282
- package/tests/read-subagent-model.mjs +0 -24
- package/tests/run-script-tests.py +0 -97
- package/tests/safe-steer.test.mjs +0 -59
- package/tests/strip_comments.test.mjs +0 -164
- package/tests/test_actor_failed.py +0 -92
- package/tests/test_compile_warnings.py +0 -99
- package/tests/test_debug_log_bus.py +0 -108
- package/tests/test_debugger_module_mode.py +0 -141
- package/tests/test_error_buckets.py +0 -117
- package/tests/test_error_dispatcher.py +0 -261
- package/tests/test_exec_ai_retry.py +0 -155
- package/tests/test_exec_human_retry.py +0 -159
- package/tests/test_file_resolve.py +0 -104
- package/tests/test_flow_events.py +0 -311
- package/tests/test_flow_ref_validation.py +0 -92
- package/tests/test_func_dict_fallback.py +0 -39
- package/tests/test_job_lifecycle.py +0 -236
- package/tests/test_job_manager.py +0 -424
- package/tests/test_mind.py +0 -99
- package/tests/test_module_call_args.py +0 -258
- package/tests/test_module_visibility.py +0 -238
- package/tests/test_notice.py +0 -143
- package/tests/test_out_whitelist.py +0 -83
- package/tests/test_par_if_dispatch.py +0 -64
- package/tests/test_par_nested_for.py +0 -78
- package/tests/test_parser.py +0 -494
- package/tests/test_pause.py +0 -102
- package/tests/test_pause_contract.py +0 -135
- package/tests/test_protocol_transcript.py +0 -158
- package/tests/test_scope_self.py +0 -202
- package/tests/test_source_validate.py +0 -113
- package/tests/test_task_world.py +0 -447
- package/tests/test_town_structure.py +0 -70
- package/tests/test_v2_checkpoint.py +0 -115
- package/tests/test_v2_env.py +0 -383
- package/tests/test_v2_evaluator.py +0 -227
- package/tests/test_v2_join.py +0 -315
- package/tests/test_v2_join_wiring.py +0 -429
- package/tests/test_v2_merge.py +0 -167
- package/tests/test_v2_model.py +0 -143
- package/tests/test_v2_resume_e2e.py +0 -472
- package/tests/test_var_decls.py +0 -271
- package/tests/verify-model-functions.mjs +0 -90
- package/tests/verify-subagent-model-3081.mjs +0 -153
- package//346/226/275/345/267/245/346/270/205/345/215/225/node-notice-/346/226/275/345/267/245/346/270/205/345/215/225.md +0 -395
- package//346/226/275/345/267/245/346/270/205/345/215/225//344/270/244/344/270/252/345/276/205/350/247/243/345/206/263/347/232/204/351/227/256/351/242/230.MD +0 -66
- package//346/226/275/345/267/245/346/270/205/345/215/225//345/201/234/346/255/242/351/223/276/344/277/256/345/244/215-/346/226/275/345/267/245/346/270/205/345/215/225.md +0 -475
- package//346/226/275/345/267/245/346/270/205/345/215/225//345/217/230/351/207/217/344/270/216task/347/263/273/347/273/237/351/207/215/346/236/204-/346/226/275/345/267/245/346/270/205/345/215/225-v2.md +0 -847
- package//346/226/275/345/267/245/346/270/205/345/215/225//350/277/220/350/241/214/347/212/266/346/200/201/351/223/276/350/267/257/351/207/215/346/236/204-/346/226/275/345/267/245/346/270/205/345/215/225v4.md +0 -654
- package//346/226/275/345/267/245/346/270/205/345/215/225//351/224/231/350/257/257/346/263/250/345/205/245/347/273/255/350/201/212-/346/226/275/345/267/245/346/270/205/345/215/225.md +0 -471
- /package/hostAdapter/dshAdapter/host/{native-state.ts → compat/native-state.ts} +0 -0
- /package/hostAdapter/dshAdapter/host/{session-events.ts → compat/session-events.ts} +0 -0
|
@@ -5,30 +5,41 @@
|
|
|
5
5
|
|
|
6
6
|
import React, { useState, useEffect, useRef, useCallback, useMemo, forwardRef, useImperativeHandle } from 'react';
|
|
7
7
|
import {
|
|
8
|
-
ErrorBoundary, FontStyle,
|
|
9
|
-
nid, eid, mid,
|
|
10
|
-
getNodeSize, getSmartPorts, smartBezier,
|
|
8
|
+
ErrorBoundary, FontStyle, SINK_ONLY,
|
|
9
|
+
nid, eid, mid, SPW, SPH,
|
|
10
|
+
getNodeSize, getSmartPorts, smartBezier,
|
|
11
11
|
computeEdgeGeometry,
|
|
12
|
-
findBackEdges, findAllCycleEdges, inp,
|
|
13
|
-
|
|
12
|
+
findBackEdges, findAllCycleEdges, inp, btnS, Field,
|
|
13
|
+
PR, makeDefaultNodes, applyForLinkage,
|
|
14
|
+
SNAP_PX, snapAndLink,
|
|
15
|
+
// 已注释死导入(观察期 2026-09-26 死代码排查,全仓零引用):TYPES, ti, SPECIAL_COLORS,
|
|
16
|
+
// NW, NH, MW, MH, PSW, PSH, PortCircle, btnP, getControlPoints, bezierMidpoint, getAllNames
|
|
14
17
|
} from './common';
|
|
15
18
|
import { parseFEMO } from './femoParser';
|
|
16
19
|
import { warningsFromThrowable } from './femoDiagnostics';
|
|
17
20
|
import { buildFEMO } from './femoGenerator';
|
|
18
21
|
import { parsedToGraph } from './graphBuilder';
|
|
19
|
-
import { ActionNodeView, PositionNodeView, SpecialNodeView, ForOutNodeView, ParOutNodeView } from './canvasNodes';
|
|
22
|
+
import { ActionNodeView, PositionNodeView, SpecialNodeView, ForOutNodeView, ParOutNodeView, SnapGuides } from './canvasNodes';
|
|
20
23
|
import { LibPanel } from './libPanel';
|
|
21
24
|
import { ProjPanel } from './projectPanel';
|
|
22
25
|
import { ActionModal } from './actionModal';
|
|
23
26
|
import { SoulModal } from './soulModal';
|
|
24
27
|
import { FemoFileList } from './femoFileList';
|
|
28
|
+
import { FemoDirBrowse } from './femoDirBrowse';
|
|
29
|
+
import { FemoSaveReminder } from './femoSaveReminder';
|
|
25
30
|
import { BubbleOverlay } from './bubbleOverlay';
|
|
26
31
|
import { DebugPanel } from './debugPanel';
|
|
27
32
|
import { installFemoLogCapture, subscribeFemoLog, femoLogTail, clearFemoLog } from './femoLog';
|
|
28
33
|
import { FemoPreview } from './femoPreview';
|
|
29
34
|
import { MobileLayout, useMobile } from './mobileView';
|
|
30
35
|
import { FEMO_THEMES } from './themes';
|
|
31
|
-
import { FaPalette, FaUserPlus, FaTerminal, FaPlay,
|
|
36
|
+
import { FaPalette, FaUserPlus, FaTerminal, FaPlay, FaStop, FaForward, FaFolderOpen, FaFloppyDisk, FaSpinner } from './faIcons';
|
|
37
|
+
// 【画布直连引擎·刀2(2026-10-05)】引擎直连客户端(公共层浏览器版)、观演
|
|
38
|
+
// 镜像(纯计算件)与观演视图组件——画布成为常驻引擎一等客户端的三件套。
|
|
39
|
+
import { createEngineClient, discoverEngine, pickFollowJob, pickJob, sameScriptText } from '../../femo2host/femoGenConnector/engine-client.mjs';
|
|
40
|
+
import { createWatchState, applyWatchEvent } from './watchMirror';
|
|
41
|
+
import { WatchView, ViewSwitcher, buildWatchGraph, STATUS_COLOR, STATUS_TEXT } from './engineWatch';
|
|
42
|
+
import { createPortal } from 'react-dom';
|
|
32
43
|
|
|
33
44
|
// 前端日志采集(2026-09-11):模块加载即装钩子——femoGen 两种入口(插件内嵌经
|
|
34
45
|
// editor-page 引入本模块 / 独立 vite 经 main.jsx)都会走到这里,等于"页面一加载
|
|
@@ -39,13 +50,22 @@ installFemoLogCapture();
|
|
|
39
50
|
// 桌面右上角(运行控制 + 文件读写)一组成员的唯一施工图:同一高度/内边距/圆角/
|
|
40
51
|
// 字号/图标尺寸 + 短文案,**每枚都带 FA 图标**,只靠色调分语义——
|
|
41
52
|
// 绿=从头跑 / 红=暂停 / 琥珀=续跑 / 中性=文件读写(导入·导出)。
|
|
53
|
+
// 三个运行控制语义色(success/danger/warning)一律实心彩底 + on-accent 白字
|
|
54
|
+
// (2026-09-21:warning 原为浅底描边幽灵款,与实心的运行/暂停同排不同款——
|
|
55
|
+
// 归一;neutral 浅底描边只留给文件读写族)。
|
|
42
56
|
// 配方与底部三键(.femo-setting-btn 家族)同源:minHeight 30 芯片家族高度、
|
|
43
57
|
// gap 6、FA 图标 size 12、按压回缩反馈(hover 规则会被内联底色盖掉,同底部三键)。
|
|
44
58
|
// 与手机端 32×32 图标芯片同族(同图标、同语义色),桌面端多带文字标签。
|
|
45
59
|
const TOOL_CHIP_TONES = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
// 底色走 --femo-btn-* 按钮专用口(2026-09-21):浅色=主语义色原值;
|
|
61
|
+
// 深色主题下由 themes.js 覆盖为「更深更灰」版(主语义色留给状态点/文字保持亮)。
|
|
62
|
+
// 字色走 --femo-btn-fg-* 专用口(2026-09-28):默认同 on-accent;
|
|
63
|
+
// 按钮底改中性深芯片的主题(web)覆盖为亮字——实心彩底主题零变化。
|
|
64
|
+
success: { bg: 'var(--femo-btn-success)', fg: 'var(--femo-btn-fg-success)', border: 'var(--femo-btn-success)' },
|
|
65
|
+
// danger/warning 边框走带回退的专用口:主题给 --femo-btn-*-border 就用(翡翠=绿描边),
|
|
66
|
+
// 没给回退同底色 token(DSH 深/浅=边框同色无描边观感,零变化)
|
|
67
|
+
danger: { bg: 'var(--femo-btn-danger)', fg: 'var(--femo-btn-fg-danger)', border: 'var(--femo-btn-danger-border, var(--femo-btn-danger))' },
|
|
68
|
+
warning: { bg: 'var(--femo-btn-warning)', fg: 'var(--femo-btn-fg-warning)', border: 'var(--femo-btn-warning-border, var(--femo-btn-warning))' },
|
|
49
69
|
neutral: { bg: 'var(--femo-surface)', fg: 'var(--femo-text-2)', border: 'var(--femo-border-strong)' },
|
|
50
70
|
};
|
|
51
71
|
function ToolChip({ icon: Icon, children, onClick, tone = 'neutral', title, disabled = false }) {
|
|
@@ -128,6 +148,21 @@ function getBackendBaseUrl() {
|
|
|
128
148
|
return `${host}:${port}`;
|
|
129
149
|
}
|
|
130
150
|
|
|
151
|
+
// ── 独立模式的文件面调用约定(2026-09-30)──
|
|
152
|
+
// 与 /api/run 同一姿势:fetch 对非 2xx 不抛错,错误无人看就被静默吞——统一
|
|
153
|
+
// 翻成 throw(!ok、ok:false、error 三种失败形状都接住)。插件模式不走这里,
|
|
154
|
+
// 导入导出归宿主回调(editor-page 的五回调)。
|
|
155
|
+
async function apiPost(pathname, body) {
|
|
156
|
+
const resp = await fetch(getBackendBaseUrl() + pathname, {
|
|
157
|
+
method: 'POST',
|
|
158
|
+
headers: { 'content-type': 'application/json' },
|
|
159
|
+
body: JSON.stringify(body ?? {}),
|
|
160
|
+
});
|
|
161
|
+
const data = await resp.json().catch(() => ({}));
|
|
162
|
+
if (!resp.ok || data.ok === false || data.error) throw new Error(data.error || `HTTP ${resp.status}`);
|
|
163
|
+
return data;
|
|
164
|
+
}
|
|
165
|
+
|
|
131
166
|
// ── 零 token 调试干跑(2026-09-08):DebugLogBus 记录 → 调试窗一行文本 ──
|
|
132
167
|
// Print 效果的格式化层:每条结构化记录渲染成一条可读流水;返回 null 的
|
|
133
168
|
// kind 不上屏(edge 高频噪音、flow_outcome 与 run_end 重复、正常收尾哨兵)。
|
|
@@ -200,7 +235,7 @@ function debugRecToLine(rec) {
|
|
|
200
235
|
|
|
201
236
|
// 结构签名:只取拓扑相关字段做比较,忽略坐标 (x/y) 与瞬时态 (selected/dragging)——
|
|
202
237
|
// 用于判定「图是否被结构性修改」;拖动节点只改坐标不算修改。
|
|
203
|
-
function structuralSignature(nodes, edges) {
|
|
238
|
+
function structuralSignature(nodes, edges, actions) {
|
|
204
239
|
const ns = (nodes || []).map((n) => {
|
|
205
240
|
const c = { ...n };
|
|
206
241
|
delete c.x; delete c.y; delete c.selected; delete c.dragging; delete c.width; delete c.height;
|
|
@@ -211,20 +246,23 @@ function structuralSignature(nodes, edges) {
|
|
|
211
246
|
delete c.selected; delete c.dragging;
|
|
212
247
|
return JSON.stringify(c);
|
|
213
248
|
}).sort();
|
|
214
|
-
|
|
249
|
+
// 动作内容(prompt/showprompt 等,住 actionStore)也是图数据的一半:
|
|
250
|
+
// 内联编辑/编辑弹窗改了文本而结构没动,run 守卫同样要能看见(2026-09-30)
|
|
251
|
+
const as = (actions || []).map((a) => JSON.stringify(a)).sort();
|
|
252
|
+
return JSON.stringify({ ns, es, as });
|
|
215
253
|
}
|
|
216
254
|
|
|
217
255
|
// ── SSE 事件 → 调试窗口日志条目摘要(模块级纯函数)──
|
|
218
|
-
// 级别:error
|
|
256
|
+
// 级别:error=FEMO脚本/引擎报错;warn=重试、警告等值得知情;info=常规运行信息。
|
|
219
257
|
// 返回单条 { level, text }、多条数组(compile_warnings 逐条一条目),
|
|
220
258
|
// 或 null(内部同步信号不喂日志,见尾部 skip 名单)。
|
|
221
259
|
function summarizeDebugEvent(type, data) {
|
|
222
260
|
const d = data || {};
|
|
223
261
|
const node = d.node_name ? `[${d.node_name}] ` : '';
|
|
224
262
|
switch (type) {
|
|
225
|
-
case 'flow_start': return { level: 'info', text: `${node}
|
|
226
|
-
case 'flow_done': return { level: 'info', text: '
|
|
227
|
-
case 'flow_paused': return { level: 'info', text: '
|
|
263
|
+
case 'flow_start': return { level: 'info', text: `${node}FEMO脚本开始运行` };
|
|
264
|
+
case 'flow_done': return { level: 'info', text: 'FEMO 运行完成' };
|
|
265
|
+
case 'flow_paused': return { level: 'info', text: 'FEMO 已暂停' };
|
|
228
266
|
case 'flow_error': return { level: 'error', text: `${node}${d.error || '未知错误'}` };
|
|
229
267
|
case 'notify_author': {
|
|
230
268
|
// 后端字段=severity('fatal' | 'agent_error' | 'agent_giveup' | 'warning')。
|
|
@@ -281,10 +319,16 @@ function summarizeDebugEvent(type, data) {
|
|
|
281
319
|
// 引擎内部信号/状态同步帧:高频且无叙事价值,喂进日志只会刷屏淹没报错
|
|
282
320
|
// (checkpoint 每节点一帧全量变量世界、projection_state 每次状态变化、
|
|
283
321
|
// node_settled 停靠经纪人信号、script_changed 存稿同步)——不喂。
|
|
322
|
+
// 2026-09-24 追加两处画布假 warn 源(用户点名「到底是标错了还是真错误」
|
|
323
|
+
// ——是标错了):ai_request 料包自 mailbox 化后走宿主 mailbox-push 单通
|
|
324
|
+
// 道、事件只剩记账价值;femo_actor_usage=宿主角色占用圆环的旁路帧。
|
|
325
|
+
// 画布对两者零消费者,喂日志也只是 JSON 刷屏——一并静音。
|
|
284
326
|
case 'checkpoint':
|
|
285
327
|
case 'node_settled':
|
|
286
328
|
case 'projection_state':
|
|
287
329
|
case 'script_changed':
|
|
330
|
+
case 'ai_request':
|
|
331
|
+
case 'femo_actor_usage':
|
|
288
332
|
return null;
|
|
289
333
|
default:
|
|
290
334
|
return {
|
|
@@ -311,10 +355,12 @@ const mainCheckpointLabel = (checkpoint) => {
|
|
|
311
355
|
return typeof first === 'string' && first.length > 0 ? first : null;
|
|
312
356
|
};
|
|
313
357
|
|
|
314
|
-
const FEMOEditor = forwardRef(function FEMOEditor({ plugin = false, onRun, onPause, initialScript, initialCheckpoint, initialRunning = false, onExport, onImport, onListFemoFiles, onPickFemoFile, onForgetFemoFile, savedPath, onBackToShell, onRestoreError, onPersistScript, getRecordScript, sessionId = '', enginePending = false, initialJobId, jobIds, initialWaitingHuman, initialLastError } = {}, ref) {
|
|
358
|
+
const FEMOEditor = forwardRef(function FEMOEditor({ plugin = false, onRun, onPause, initialScript, initialCheckpoint, initialRunning = false, sessionStateLoaded = false, onExport, onImport, onListFemoFiles, onPickFemoFile, onForgetFemoFile, savedPath, onBackToShell, onRestoreError, onPersistScript, getRecordScript, sessionId = '', enginePending = false, onEngineRetry, initialJobId, jobIds, initialWaitingHuman, initialLastError } = {}, ref) {
|
|
315
359
|
// 插件模式:由 femo-plugin 注入(plugin=true)——运行/暂停走插件回调,
|
|
316
360
|
// SSE 连插件广播路由;独立模式保留原后端调用(getBackendBaseUrl)。
|
|
317
361
|
// initialScript/initialCheckpoint/initialRunning:会话恢复(刷新/重启/运行中打开)。
|
|
362
|
+
// sessionStateLoaded:宿主会话态(session-state)是否已取回——未取回前恢复
|
|
363
|
+
// effect 不裁决有/无FEMO脚本(2026-09-24 补帧撞空画布修复,见恢复 effect 处注释)。
|
|
318
364
|
// initialJobId/jobIds:宿主会话记录的 currentJobId + 激活过的全部 Job(2026-09-06
|
|
319
365
|
// job 快照改造)——暂停/继续显式带号(镜像滞后也能停),jobIds 供历史场次 UI。
|
|
320
366
|
// initialLastError:上一个 failed Job 的存档错误(2026-09-10)——只进调试窗
|
|
@@ -324,12 +370,13 @@ const FEMOEditor = forwardRef(function FEMOEditor({ plugin = false, onRun, onPau
|
|
|
324
370
|
// 原话上浮——比对职责不再经过宿主。
|
|
325
371
|
// onPersistScript(femo):定稿按钮(图生文本/文本生图)显式落盘会话记录;
|
|
326
372
|
// 2026-08-22 起不再有画布防抖自动回写,原文以用户输入为准。
|
|
327
|
-
// savedPath
|
|
373
|
+
// savedPath:会话脚本文件地址(导出/导入产生)——空=未保存(提示+绝对寻址)。
|
|
328
374
|
// onExport(femo, name):导出(三态行为在 host 侧 editor-page 实现,返回 undefined=用户选了返回画布);
|
|
329
375
|
// onImport():导入=host 弹系统文件选择器→{path, content}(引用原始位置,2026-08-30),null=用户取消。
|
|
330
376
|
// onBackToShell:插件模式手机端返回键回调(femo-plugin 传 ctx.layout.toggleSidebar)。
|
|
331
377
|
// sessionId:本编辑器所属会话(Job 模型 §11.1:SSE 信封按 sid 过滤)。
|
|
332
|
-
// enginePending:引擎冷启动(bridge
|
|
378
|
+
// enginePending:引擎冷启动(bridge 未就绪)——运行键换「引擎启动中…」;
|
|
379
|
+
// 2026-09-19 起不再死等:宿主侧自动轮询补拉 + 芯片可点立即重探(onEngineRetry)。
|
|
333
380
|
//console.log('✅ FEMOEditor 已进入渲染');
|
|
334
381
|
// ── 主题:auto=跟随 dsh 本体(body[data-ds-dark-theme] 白天→dsh / 黑夜→dsh-dark),
|
|
335
382
|
// 或手动固定 dsh / dsh-dark。localStorage 'femo_theme' 持久化,默认 auto。──
|
|
@@ -426,6 +473,9 @@ const FEMOEditor = forwardRef(function FEMOEditor({ plugin = false, onRun, onPau
|
|
|
426
473
|
|
|
427
474
|
useEffect(() => {
|
|
428
475
|
const handler = (e) => {
|
|
476
|
+
// buttons===0 的 mousedown 不是真实按键按下(触控/远程桌面等合成事件),
|
|
477
|
+
// 放过它避免误清在途手势;真实点击取消手势的语义保持不变。2026-09-20
|
|
478
|
+
if (e.buttons === 0) return;
|
|
429
479
|
if (dragRef.current || connRef.current || isPanningRef.current) {
|
|
430
480
|
setDrag(null);
|
|
431
481
|
setConn(null);
|
|
@@ -482,7 +532,7 @@ const FEMOEditor = forwardRef(function FEMOEditor({ plugin = false, onRun, onPau
|
|
|
482
532
|
// 后端编译器/引擎运行时 print 的原文。数据源:宿主 bridge 把引擎 stdout 的
|
|
483
533
|
// 非 JSON 行逐行 pushDiag('engine', ...) 进 diag-feed → SSE femo_diag 实时
|
|
484
534
|
// 广播;开面板时另拉 /femo-plugin/diag-tail 补历史(页面刷新后也有内容)。
|
|
485
|
-
//
|
|
535
|
+
// 与『FEMO脚本』页完全分账:那边是画布事件/干跑流水(level 三态),这边是原样
|
|
486
536
|
// 打印文本(无级别,故不上色)。
|
|
487
537
|
const [compilerLog, setCompilerLog] = useState([]); // [{ id, ts, text }],新在前
|
|
488
538
|
const compilerSeqRef = useRef(0);
|
|
@@ -577,7 +627,7 @@ const FEMOEditor = forwardRef(function FEMOEditor({ plugin = false, onRun, onPau
|
|
|
577
627
|
// AI 实例的 node_start/ai_token 会把人类实例的 human_wait 状态整个冲掉,
|
|
578
628
|
// 输入框「闪一下就被 AI 气泡取代」。humanWaits 是 AI 事件碰不到的独立账本
|
|
579
629
|
// (nodeId → {wait_key,context,memory,showprompt,prompt,outVars,inputError}),
|
|
580
|
-
//
|
|
630
|
+
// 人类输入面板由它驱动,常驻气泡顶端直到提交/本次结束。
|
|
581
631
|
const [humanWaits, setHumanWaits] = useState({});
|
|
582
632
|
const humanWaitsRef = useRef({});
|
|
583
633
|
const setHumanWaitsBoth = useCallback((updater) => {
|
|
@@ -599,7 +649,7 @@ const FEMOEditor = forwardRef(function FEMOEditor({ plugin = false, onRun, onPau
|
|
|
599
649
|
if (exportToastTimerRef.current) clearTimeout(exportToastTimerRef.current);
|
|
600
650
|
setExportToast({ text, id: Date.now() });
|
|
601
651
|
// 调试窗口留档:toast 4s 就消失,日志里常驻可查
|
|
602
|
-
pushDebug('info', '
|
|
652
|
+
pushDebug('info', '保存', text);
|
|
603
653
|
exportToastTimerRef.current = setTimeout(() => {
|
|
604
654
|
setExportToast(null);
|
|
605
655
|
exportToastTimerRef.current = null;
|
|
@@ -728,7 +778,111 @@ const [userApiModel, setUserApiModel] = useState(() => {
|
|
|
728
778
|
/** 正在移出清单(2026-09-13):移除请求在途时全表 ⊖ 键防连点。 */
|
|
729
779
|
const [femoFileForgetBusy, setFemoFileForgetBusy] = useState(false);
|
|
730
780
|
|
|
781
|
+
// ── 独立模式的文档锚与文件面(2026-09-30)──
|
|
782
|
+
// 插件模式 savedPath 归宿主会话账(props,dsh 的 scriptPath);独立模式没有
|
|
783
|
+
// 会话账,「当前文件」记在服务端数据根 femogen_canvas.json(公共层
|
|
784
|
+
// femogen-canvas-state),开页拉来播种。undefined=还没拉到(不当未保存亮
|
|
785
|
+
// 警示条),null=确认没保存过,string=当前文件的绝对路径。
|
|
786
|
+
const [standaloneSavedPath, setStandaloneSavedPath] = useState(undefined);
|
|
787
|
+
const effectiveSavedPath = plugin ? savedPath : standaloneSavedPath;
|
|
788
|
+
|
|
789
|
+
// 开页播种(独立模式专属):读服务端 path 槽。拉不到(纯 vite dev 无服务)
|
|
790
|
+
// 按 null 落定——回到「未保存」状态,警示条与首存流程照常工作。
|
|
791
|
+
useEffect(() => {
|
|
792
|
+
if (plugin) return undefined;
|
|
793
|
+
let gone = false;
|
|
794
|
+
fetch(`${getBackendBaseUrl()}/api/canvas/path`)
|
|
795
|
+
.then((r) => r.json())
|
|
796
|
+
.then((d) => { if (!gone) setStandaloneSavedPath(typeof d?.path === 'string' ? d.path : null); })
|
|
797
|
+
.catch(() => { if (!gone) setStandaloneSavedPath(null); });
|
|
798
|
+
return () => { gone = true; };
|
|
799
|
+
}, [plugin]);
|
|
800
|
+
|
|
801
|
+
// 工程目录浮层(手机端选路径的一腿,组件=femoDirBrowse;数据面=/api/projects/*,
|
|
802
|
+
// 服务端有 projects/ 围栏)+「未改动」提醒挂起(导出三态的中拍)。
|
|
803
|
+
const [dirBrowseOpen, setDirBrowseOpen] = useState(false);
|
|
804
|
+
const [dirBrowseMode, setDirBrowseMode] = useState('save');
|
|
805
|
+
const [dirBrowseDir, setDirBrowseDir] = useState('');
|
|
806
|
+
const [dirBrowseDirs, setDirBrowseDirs] = useState([]);
|
|
807
|
+
const [dirBrowseFiles, setDirBrowseFiles] = useState([]);
|
|
808
|
+
const [dirBrowseLoading, setDirBrowseLoading] = useState(false);
|
|
809
|
+
const [dirBrowseError, setDirBrowseError] = useState('');
|
|
810
|
+
const [dirBrowseBusy, setDirBrowseBusy] = useState(false);
|
|
811
|
+
const [saveReminder, setSaveReminder] = useState(null); // {path, resolve}
|
|
812
|
+
|
|
731
813
|
const cvRef = useRef(null);
|
|
814
|
+
|
|
815
|
+
// ── window 级 mouseup/mousemove 兜底(2026-09-20,修"松手后节点粘鼠标")──
|
|
816
|
+
// 手势收尾此前完全依赖画布 div 的 onMouseUp,三种情形收不到 mouseup:
|
|
817
|
+
// ① 松手点在选中节点自己的端口圈上(PortCircle 对合成事件 stopPropagation,
|
|
818
|
+
// canvas onMU 被跳过);② 鼠标已滑出画布(弹窗/侧栏/画布外);③ 在浏览器
|
|
819
|
+
// 窗口外松手(浏览器不派发 mouseup)。收不到 → drag/conn 清不掉 → 节点粘鼠标。
|
|
820
|
+
// 方案:window 上兜底补送 onMU/onMM。拖拽/平移的收尾放捕获阶段(先于
|
|
821
|
+
// React——端口圈对合成事件 stopPropagation 会拦断冒泡链,bubble 阶段的
|
|
822
|
+
// window 监听收不到 mouseup);连线的收尾留在 bubble 阶段(React 端口/
|
|
823
|
+
// 节点体的落点建边要先跑完,捕获阶段清 conn 会吞掉建边)。onMU 幂等:
|
|
824
|
+
// 入口归零有一次性闩 entryRezeroDoneRef,其余清态天然幂等;画布内
|
|
825
|
+
// mousemove 兜底不干预,只补画布外的跟手。
|
|
826
|
+
const onMURef = useRef(null);
|
|
827
|
+
const onMMRef = useRef(null);
|
|
828
|
+
// (onMU/onMM 的同步 effect 移至下方两声明之后——2026-09-21 TDZ 修复:
|
|
829
|
+
// 依赖数组 [onMU]/[onMM] 在渲染期立即求值,写在声明前会
|
|
830
|
+
// ReferenceError: Cannot access 'onMU' before initialization,
|
|
831
|
+
// FEMOEditor 整树崩、femogen 不渲染。)
|
|
832
|
+
|
|
833
|
+
useEffect(() => {
|
|
834
|
+
const active = () => !!(dragRef.current || connRef.current || isPanningRef.current);
|
|
835
|
+
const finish = () => { if (active()) onMURef.current?.(); };
|
|
836
|
+
const follow = (e) => {
|
|
837
|
+
if (!active()) return;
|
|
838
|
+
if (e.buttons === 0) { finish(); return; } // 按键已全松 = 漏掉的 mouseup,补收尾
|
|
839
|
+
// 画布内的移动 canvas onMM 已处理,兜底只负责画布外(弹窗/侧栏/页面其它区域)
|
|
840
|
+
if (cvRef.current && e.target instanceof Node && cvRef.current.contains(e.target)) return;
|
|
841
|
+
onMMRef.current?.(e);
|
|
842
|
+
};
|
|
843
|
+
const onKey = (e) => { if (e.key === 'Escape') finish(); };
|
|
844
|
+
// 捕获阶段收尾:只管 drag/pan(conn 必须留给 bubble——端口/节点体的
|
|
845
|
+
// 落点建边在 React 里要先跑完,捕获阶段清 conn 会吞掉建边)。
|
|
846
|
+
const finishCapture = () => {
|
|
847
|
+
if (!connRef.current && (dragRef.current || isPanningRef.current)) onMURef.current?.();
|
|
848
|
+
};
|
|
849
|
+
window.addEventListener('mouseup', finishCapture, true);
|
|
850
|
+
window.addEventListener('mouseup', finish);
|
|
851
|
+
window.addEventListener('mousemove', follow);
|
|
852
|
+
window.addEventListener('dragend', finish); // HTML5 拖拽抢占鼠标的异常出口
|
|
853
|
+
window.addEventListener('blur', finish); // Alt+Tab / 切窗丢 mouseup 的出口
|
|
854
|
+
window.addEventListener('keydown', onKey); // Esc 手动收尾
|
|
855
|
+
return () => {
|
|
856
|
+
window.removeEventListener('mouseup', finishCapture, true);
|
|
857
|
+
window.removeEventListener('mouseup', finish);
|
|
858
|
+
window.removeEventListener('mousemove', follow);
|
|
859
|
+
window.removeEventListener('dragend', finish);
|
|
860
|
+
window.removeEventListener('blur', finish);
|
|
861
|
+
window.removeEventListener('keydown', onKey);
|
|
862
|
+
};
|
|
863
|
+
}, []);
|
|
864
|
+
|
|
865
|
+
// START/IN 入口归零的"每次手势只跑一次"闩:window 兜底会对同一次松手补一次
|
|
866
|
+
// onMU,而归零的 dx/dy 取自 nodesRef 快照 + 函数式 setNodes——不设闩双跑会把
|
|
867
|
+
// 其余节点平移两次。drag 清空后闩自动复位(下一次拖拽重新可用)。
|
|
868
|
+
const entryRezeroDoneRef = useRef(false);
|
|
869
|
+
useEffect(() => { if (!drag) entryRezeroDoneRef.current = false; }, [drag]);
|
|
870
|
+
// 拖拽吸附的"中心连线"({x1,y1,x2,y2} 画布坐标,null=无吸附):桌面端 onMM 与
|
|
871
|
+
// 手机端 nodeDrag 算完吸附后写这里,两端各自在画布坐标系里渲染。松手时清空。
|
|
872
|
+
const [snapGuides, setSnapGuides] = useState(null);
|
|
873
|
+
// 连线未变就不 setState——避免拖拽中每帧触发整树重渲染
|
|
874
|
+
const updateGuides = useCallback((d) => {
|
|
875
|
+
const n = d || null;
|
|
876
|
+
setSnapGuides((prev) => {
|
|
877
|
+
if (prev === n) return prev;
|
|
878
|
+
if (!prev || !n) return n;
|
|
879
|
+
return (
|
|
880
|
+
prev.x1 === n.x1 && prev.y1 === n.y1 && prev.x2 === n.x2 && prev.y2 === n.y2
|
|
881
|
+
? prev
|
|
882
|
+
: n
|
|
883
|
+
);
|
|
884
|
+
});
|
|
885
|
+
}, []);
|
|
732
886
|
// 编辑器根容器(桌面分支外层 div):内嵌 dsh tab 时「编辑器以为的屏幕」
|
|
733
887
|
// 以它为准(2026-08-26 容器感知,右面板 resize 等)。
|
|
734
888
|
const editorRootRef = useRef(null);
|
|
@@ -738,9 +892,10 @@ const [userApiModel, setUserApiModel] = useState(() => {
|
|
|
738
892
|
const moduleStoreRef = useRef(moduleStore); // 绕闭包,持有最新 moduleStore
|
|
739
893
|
const locationPathRef = useRef(locationPath); // 绕闭包,持有最新 locationPath
|
|
740
894
|
// 【刷新恢复(2026-09-06)】restoreDoneRef=画布已从会话快照恢复完(applyFEMOText
|
|
741
|
-
//
|
|
895
|
+
// 跑过/确认无FEMO脚本);恢复完成前 SSE 重放的节点事件在空画布上全部匹配不上会被
|
|
742
896
|
// 丢弃——先入 pendingReplayRef 缓冲,恢复完成后按序补放,运行中小气泡才
|
|
743
|
-
// 能在刷新后重建。
|
|
897
|
+
// 能在刷新后重建。2026-09-24 起「恢复完」还要求宿主会话态已取回
|
|
898
|
+
// (sessionStateLoaded)——否则挂载首拍就误开闸,补发帧撞空画布报错。
|
|
744
899
|
const restoreDoneRef = useRef(false);
|
|
745
900
|
const pendingReplayRef = useRef([]);
|
|
746
901
|
const [canvasOpacity, setCanvasOpacity] = useState(1); // 淡入动效
|
|
@@ -1070,8 +1225,9 @@ const parOutNodeMap = useMemo(() => {
|
|
|
1070
1225
|
const s = nm.get(e.src), t = nm.get(e.tgt);
|
|
1071
1226
|
if (!s || !t) return;
|
|
1072
1227
|
if (e.src === e.tgt) return; // 自环不参与
|
|
1073
|
-
|
|
1074
|
-
|
|
1228
|
+
// 2026-09-19:与 computeEdgeGeometry 同口径——环边也选最优端口(不再
|
|
1229
|
+
// preferDifferent),分组偏移才能作用在真实渲染端口上,对向同廊道边形成平行双车道。
|
|
1230
|
+
const { srcDir, tgtDir } = getSmartPorts(s, t);
|
|
1075
1231
|
// 排除 for_out 节点
|
|
1076
1232
|
const srcKey = (s.type === 'for_out' || s.type === 'par_out') ? null : `${e.src}:${srcDir}`;
|
|
1077
1233
|
const tgtKey = (t.type === 'for_out' || t.type === 'par_out') ? null : `${e.tgt}:${tgtDir}`;
|
|
@@ -1233,11 +1389,13 @@ const parOutNodeMap = useMemo(() => {
|
|
|
1233
1389
|
// 文本生图(handleApplyFemo)/ 图生文本(handleGraphToTextCommit)。
|
|
1234
1390
|
|
|
1235
1391
|
// 图修改检测:与上次统一点的结构基线比较(忽略坐标),漂移即置脏。
|
|
1392
|
+
// 基线含动作内容(actionStore)——节点名说明框的内联编辑、编辑弹窗改
|
|
1393
|
+
// prompt 而不改名,都算「图被修改」(2026-09-30 起)。
|
|
1236
1394
|
useEffect(() => {
|
|
1237
1395
|
if (!plugin) return;
|
|
1238
1396
|
if (!lastSyncedGraphRef.current) return; // 尚未 restore,无基线
|
|
1239
|
-
setGraphDirty(structuralSignature(nodes, edges) !== lastSyncedGraphRef.current);
|
|
1240
|
-
}, [plugin, nodes, edges]);
|
|
1397
|
+
setGraphDirty(structuralSignature(nodes, edges, actionStore) !== lastSyncedGraphRef.current);
|
|
1398
|
+
}, [plugin, nodes, edges, actionStore]);
|
|
1241
1399
|
|
|
1242
1400
|
// 初始化时加载状态(插件模式跳过:画布状态按会话快照恢复,不读 localStorage)
|
|
1243
1401
|
useEffect(() => {
|
|
@@ -1264,12 +1422,22 @@ const parOutNodeMap = useMemo(() => {
|
|
|
1264
1422
|
}
|
|
1265
1423
|
}, []); // 仅挂载时运行一次
|
|
1266
1424
|
|
|
1267
|
-
//
|
|
1425
|
+
// 插件模式会话恢复:FEMO脚本快照 → 文本到图加载画布 + 代码框;断点 → 「继续」+ 高亮。
|
|
1268
1426
|
// 依赖 props(session-state 异步返回后才会触发),且 props 稳定后只执行一次。
|
|
1269
1427
|
useEffect(() => {
|
|
1270
1428
|
if (!plugin) return;
|
|
1271
|
-
// [femo-diag] 恢复触发器:undefined
|
|
1272
|
-
try { console.log('[femo-diag] restore-effect script=' + (initialScript === undefined ? 'undefined' : String(initialScript.length)) + 'ch running=' + String(initialRunning) + ' ckpt=' + String(initialCheckpoint ?? 'none')); } catch {}
|
|
1429
|
+
// [femo-diag] 恢复触发器:undefined=会话无FEMO脚本记录;空串=记录异常;loaded=false=session-state 未回(本轮跳过)
|
|
1430
|
+
try { console.log('[femo-diag] restore-effect loaded=' + String(sessionStateLoaded) + ' script=' + (initialScript === undefined ? 'undefined' : String(initialScript.length)) + 'ch running=' + String(initialRunning) + ' ckpt=' + String(initialCheckpoint ?? 'none')); } catch {}
|
|
1431
|
+
// 【2026-09-24 补帧撞空画布修复】session-state 没回来前不开闸:挂载首拍
|
|
1432
|
+
// initialScript 必然 undefined(editor-page 无挂载守卫,state 异步后到),
|
|
1433
|
+
// 旧代码在此时点就进「无FEMO脚本=恢复完成」分支把 restoreDoneRef 置真——而
|
|
1434
|
+
// SSE 连接 effect(声明在后、同批提交)已把宿主 /events 接上,宿主连接
|
|
1435
|
+
// 即补发重放环(replay:true),这几帧比 session-state 先到、穿过提前打开
|
|
1436
|
+
// 的闸撞上空画布:node_settled/ai_done 全数「无法匹配节点」报错丢弃
|
|
1437
|
+
// (j2476 散场闲聊收尾帧实锤)。现在等 sessionStateLoaded=true 才裁决
|
|
1438
|
+
// 有/无FEMO脚本;期间的节点事件照常入 pendingReplayRef,真恢复完成后由补放
|
|
1439
|
+
// effect 按序回放。
|
|
1440
|
+
if (!sessionStateLoaded) return;
|
|
1273
1441
|
if (initialScript && initialScript.trim().length > 0) {
|
|
1274
1442
|
try {
|
|
1275
1443
|
applyFEMOText(initialScript);
|
|
@@ -1278,9 +1446,9 @@ const parOutNodeMap = useMemo(() => {
|
|
|
1278
1446
|
} catch (e) {
|
|
1279
1447
|
console.warn('[FEMOEditor] 会话快照恢复失败:', e);
|
|
1280
1448
|
// 不再静默:画布面板可见 + 上抛给插件层(回传主模型)。
|
|
1281
|
-
// 2026-08-26
|
|
1449
|
+
// 2026-08-26:解析失败的坏FEMO脚本也把【原文】载入输入框(画布留空)——
|
|
1282
1450
|
// ①人类能就地改文本修复;②AI 触发 run 时 handleRunWorkflow 的
|
|
1283
|
-
// parseFEMO
|
|
1451
|
+
// parseFEMO 会拿真实错误回传(而不是「请先编写或打开 FEMO脚本」)。
|
|
1284
1452
|
const msg = e instanceof Error ? e.message : String(e);
|
|
1285
1453
|
setFemoText(initialScript);
|
|
1286
1454
|
setFemoError(`会话快照恢复失败:${msg}`);
|
|
@@ -1292,8 +1460,13 @@ const parOutNodeMap = useMemo(() => {
|
|
|
1292
1460
|
restoreDoneRef.current = true;
|
|
1293
1461
|
}
|
|
1294
1462
|
} else {
|
|
1295
|
-
//
|
|
1463
|
+
// 无FEMO脚本:无可恢复画布,恢复视为完成(缓冲事件直接放行)。
|
|
1296
1464
|
restoreDoneRef.current = true;
|
|
1465
|
+
// 【刀2】恢复完成(空稿也算落定):补做挂起的引擎校准。
|
|
1466
|
+
if (pendingCalibrateRef.current) {
|
|
1467
|
+
pendingCalibrateRef.current = false;
|
|
1468
|
+
void engineCalibrate();
|
|
1469
|
+
}
|
|
1297
1470
|
}
|
|
1298
1471
|
if (initialCheckpoint) {
|
|
1299
1472
|
setFlowStatus('paused'); // 按钮显示「继续」= 断点续跑(host 代理的
|
|
@@ -1301,12 +1474,12 @@ const parOutNodeMap = useMemo(() => {
|
|
|
1301
1474
|
// 前端不再给"必假继续")
|
|
1302
1475
|
}
|
|
1303
1476
|
if (initialRunning) {
|
|
1304
|
-
//
|
|
1477
|
+
// 会话已在运行(比如对话窗先启动的):按钮显示运行态。【刀2】流连接
|
|
1478
|
+
// 已上移到挂载即连的引擎直连(connectEngine)——这里只校按钮态。
|
|
1305
1479
|
setFlowStatus('running');
|
|
1306
|
-
connectSse();
|
|
1307
1480
|
}
|
|
1308
1481
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1309
|
-
}, [plugin, initialScript, initialCheckpoint, initialRunning]);
|
|
1482
|
+
}, [plugin, sessionStateLoaded, initialScript, initialCheckpoint, initialRunning]);
|
|
1310
1483
|
|
|
1311
1484
|
// 【上次运行报错留档(2026-09-10)】存档里的 failed 错误只进调试窗日志:
|
|
1312
1485
|
// 画布恢复不再被报错拦路(宿主侧已修),错误以一行日志形态可查——刷新/
|
|
@@ -1360,6 +1533,9 @@ const parOutNodeMap = useMemo(() => {
|
|
|
1360
1533
|
const handleGlobalWheel = (e) => {
|
|
1361
1534
|
// 画布内的所有 wheel 事件:全面阻止浏览器默认行为(横向滑动、返回手势、缩放等)
|
|
1362
1535
|
if (cvRef.current?.contains(e.target)) {
|
|
1536
|
+
// 节点名说明框例外(2026-09-30):框体自身要滚——放行默认滚动;
|
|
1537
|
+
// 画布缩放由说明框自己的 onWheel stopPropagation 挡住
|
|
1538
|
+
if (e.target.closest?.('[data-femo-info-popup]')) return;
|
|
1363
1539
|
e.preventDefault();
|
|
1364
1540
|
return;
|
|
1365
1541
|
}
|
|
@@ -1659,6 +1835,7 @@ if (specialType === 'FOR') {
|
|
|
1659
1835
|
}, []);
|
|
1660
1836
|
|
|
1661
1837
|
|
|
1838
|
+
/* ═══ 已退役(观察期起 2026-09-26 死代码排查,全仓零引用;观察无误后连块删除):handleCreateSoul(死回调:两处 <SoulModal> 传的都是内联 lambda,创建逻辑在 SoulModal 内部自包含) ═══
|
|
1662
1839
|
// ── 新建 SOUL ID ──
|
|
1663
1840
|
const handleCreateSoul = useCallback(async () => {
|
|
1664
1841
|
setSoulFormError('');
|
|
@@ -1695,6 +1872,7 @@ if (specialType === 'FOR') {
|
|
|
1695
1872
|
setSoulFormSubmitting(false);
|
|
1696
1873
|
}
|
|
1697
1874
|
}, [soulForm]);
|
|
1875
|
+
═══ 已退役块结束 ═══ */
|
|
1698
1876
|
|
|
1699
1877
|
// ── 工作流运行:启动运行 ──
|
|
1700
1878
|
// 【run_request/run-result 链退役(§11.4)】isAi 特判与 onRunResult 回传整体
|
|
@@ -1736,7 +1914,7 @@ if (specialType === 'FOR') {
|
|
|
1736
1914
|
// femOverride 供「放弃修改直接跑」传入 record 原文。
|
|
1737
1915
|
const femo = typeof femOverride === 'string' && femOverride.trim() ? femOverride : femoText;
|
|
1738
1916
|
if (!femo || !femo.trim()) {
|
|
1739
|
-
alert('
|
|
1917
|
+
alert('请先编写或打开 FEMO脚本');
|
|
1740
1918
|
return;
|
|
1741
1919
|
}
|
|
1742
1920
|
// ★ 前端语法检查(各自闭环:femogen 不依赖后端也能检查语法)。
|
|
@@ -1784,10 +1962,10 @@ if (specialType === 'FOR') {
|
|
|
1784
1962
|
|
|
1785
1963
|
try {
|
|
1786
1964
|
if (plugin) {
|
|
1787
|
-
// 插件模式:交给 femo-plugin
|
|
1965
|
+
// 插件模式:交给 femo-plugin 运行(保存FEMO脚本 + 启动引擎,同一 run
|
|
1788
1966
|
// 也驱动聊天窗角色气泡);SSE 连插件广播路由(相对路径,同源)。
|
|
1789
1967
|
// 按钮恒定(2026-09-11 定型):三枚键各钉死一个动作,调用不再随状态漂移——
|
|
1790
|
-
// 绿「▶ 运行」= reset:true(fresh_start
|
|
1968
|
+
// 绿「▶ 运行」= reset:true(fresh_start 从头运行,未开跑/挂起态同一句调用);
|
|
1791
1969
|
// 琥珀「继续」= handleResumeWorkflow(resume:reset:false + jobId 指名续跑)。
|
|
1792
1970
|
// 显式 reset 优先;未显式给的调用方(AI 话术/人类触发/换稿重跑)沿用原判定
|
|
1793
1971
|
// (paused 外=从头、paused=续跑)。resumeJobId:显式续跑目标 Job 号
|
|
@@ -1802,54 +1980,33 @@ if (specialType === 'FOR') {
|
|
|
1802
1980
|
await onRun(femo, runOpts);
|
|
1803
1981
|
}
|
|
1804
1982
|
setRunId(null);
|
|
1805
|
-
connectSse
|
|
1983
|
+
// 【刀2】connectSse 调用点已拔:引擎直连常驻(挂载即连),开跑后事件
|
|
1984
|
+
// 由观察者流送达;新场 flow_start 触发重新校准跟随。
|
|
1806
1985
|
return;
|
|
1807
1986
|
}
|
|
1808
|
-
// 1. 发送 FEMO
|
|
1987
|
+
// 1. 发送 FEMO脚本到后端,启动运行(独立模式)
|
|
1809
1988
|
const resp = await fetch(getBackendBaseUrl() + '/api/run', {
|
|
1810
1989
|
method: 'POST',
|
|
1811
1990
|
headers: {
|
|
1812
1991
|
'Content-Type': 'application/json',
|
|
1813
1992
|
'X-API-Key': userApiKey,
|
|
1814
1993
|
'X-API-Provider': userApiProvider,
|
|
1815
|
-
'X-API-Model': apiModelInput,
|
|
1994
|
+
'X-API-Model': apiModelInput,
|
|
1816
1995
|
'X-API-Url': userApiUrl,
|
|
1817
1996
|
},
|
|
1818
1997
|
body: JSON.stringify({ femo: femo }),
|
|
1819
1998
|
});
|
|
1820
1999
|
const data = await resp.json();
|
|
2000
|
+
// 启动失败要让弹窗说话(2026-09-28 web 接入补):fetch 对 500 不抛错,
|
|
2001
|
+
// data.error 无人看就静默回闲、错误全吞。
|
|
2002
|
+
if (data.error) throw new Error(data.error);
|
|
1821
2003
|
const newRunId = data.run_id;
|
|
1822
2004
|
setRunId(newRunId);
|
|
1823
2005
|
|
|
1824
|
-
// 2. 连接 SSE 流
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
eventSourceRef.current = es;
|
|
1829
|
-
|
|
1830
|
-
es.onmessage = (event) => {
|
|
1831
|
-
let evt;
|
|
1832
|
-
try {
|
|
1833
|
-
evt = JSON.parse(event.data);
|
|
1834
|
-
} catch (e) {
|
|
1835
|
-
console.error('SSE parse error:', e);
|
|
1836
|
-
return;
|
|
1837
|
-
}
|
|
1838
|
-
if (evt.type === 'heartbeat') return;
|
|
1839
|
-
|
|
1840
|
-
console.log('[SSE onmessage]', event.data);
|
|
1841
|
-
handleWorkflowEvent(evt);
|
|
1842
|
-
};
|
|
1843
|
-
|
|
1844
|
-
es.onerror = (event) => {
|
|
1845
|
-
console.error('[SSE] 连接出错或关闭', event);
|
|
1846
|
-
console.log('[SSE] readyState:', es.readyState, '(0=CONNECTING, 1=OPEN, 2=CLOSED)');
|
|
1847
|
-
es.close();
|
|
1848
|
-
eventSourceRef.current = null;
|
|
1849
|
-
setFlowStatus('idle');
|
|
1850
|
-
// 清空所有活跃节点(SSE 意外断开时安全清空)
|
|
1851
|
-
setActiveNodeIds(new Set());
|
|
1852
|
-
};
|
|
2006
|
+
// 2. 连接 SSE 流 ——【已退役-观察期(刀2,2026-10-05)】按场事件流退役:
|
|
2007
|
+
// 画布开机即直连引擎(mount effect 的 connectEngine),自己的场与别家的
|
|
2008
|
+
// 场同走一条观察者流,run-scoped 流成了第二份(双吃禁止)。运行态由
|
|
2009
|
+
// 直连帧回填(flow_start 已在飞行路上)。
|
|
1853
2010
|
} catch (err) {
|
|
1854
2011
|
console.error('Failed to start workflow:', err);
|
|
1855
2012
|
setFlowStatus('idle');
|
|
@@ -1894,27 +2051,32 @@ const handlePauseWorkflow = useCallback(async () => {
|
|
|
1894
2051
|
lastActionAtRef.current = Date.now();
|
|
1895
2052
|
clearPauseConfirmTimer();
|
|
1896
2053
|
try {
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
const resp = await fetch(getBackendBaseUrl() + `/api/run/${runId}/pause`, { method: 'POST' });
|
|
1912
|
-
data = await resp.json().catch(() => ({}));
|
|
1913
|
-
if (!resp.ok) throw new Error(data?.error ?? `pause HTTP ${resp.status}`);
|
|
1914
|
-
}
|
|
2054
|
+
// 【刀2 直发引擎】停止=引擎命令直发(不再经宿主回调/宿主路由转手)。
|
|
2055
|
+
// 目标场次:插件模式跟当前 Job 号;独立模式 runId 即 Job 号。
|
|
2056
|
+
// 【观演原位版 2026-10-08】正在观看某场时,停止/继续的作用对象=当前
|
|
2057
|
+
// 观看的场(header 别变的另一半:按钮在原位,但服务于看到的场)。
|
|
2058
|
+
const client = engineClientRef.current;
|
|
2059
|
+
const watchedId = activeViewRef.current !== 'edit'
|
|
2060
|
+
? Number(String(activeViewRef.current).slice(4)) : NaN;
|
|
2061
|
+
const target = (Number.isFinite(watchedId) && watchedId > 0) ? watchedId
|
|
2062
|
+
: (pluginJobId ?? runId);
|
|
2063
|
+
if (!client) throw new Error('引擎直连未就绪(引擎离线或伺候方未给地址)');
|
|
2064
|
+
if (!target) throw new Error('没有可暂停的 Job(未知场次号)');
|
|
2065
|
+
const body = await client.pause(target);
|
|
2066
|
+
if (!body?.ok) throw new Error(body?.detail || body?.error || '引擎拒绝暂停');
|
|
2067
|
+
const data = body.result ?? {};
|
|
1915
2068
|
if (data && data.paused === false) {
|
|
1916
|
-
//
|
|
2069
|
+
// 宿主说没有可暂停的活跃执行体:按引擎回执校准按钮(2026-09-20 挂起态
|
|
2070
|
+
// 暂停键常驻后,幂等按压的落点)——引擎说 suspended=保持挂起态(继续键
|
|
2071
|
+
// 还在,附知情提示);其他态/没带态=回空闲(页面状态残留)。
|
|
2072
|
+
if (data.state === 'suspended') {
|
|
2073
|
+
setFlowStatus('paused');
|
|
2074
|
+
showPauseNotice('info', '该 Job 已处于挂起状态(断点保留,可点「继续」续跑)');
|
|
2075
|
+
return;
|
|
2076
|
+
}
|
|
1917
2077
|
setFlowStatus('idle');
|
|
2078
|
+
// 2026-09-24 暂停键全状态常驻后的空闲按压落点:明确知情,不留「按了没反应」。
|
|
2079
|
+
showPauseNotice('info', '当前没有可暂停的运行(引擎侧无活跃执行体)');
|
|
1918
2080
|
return;
|
|
1919
2081
|
}
|
|
1920
2082
|
const st = data && data.state;
|
|
@@ -1948,30 +2110,37 @@ const handlePauseWorkflow = useCallback(async () => {
|
|
|
1948
2110
|
// 请求失败=动作被拒:红条可见报错(宿主侧同款已进错误面板),按钮不回退。
|
|
1949
2111
|
showPauseNotice('error', `暂停失败:${err?.message ?? err}`);
|
|
1950
2112
|
}
|
|
1951
|
-
}, [runId, plugin,
|
|
2113
|
+
}, [runId, plugin, pluginJobId, showPauseNotice, clearPauseConfirmTimer]);
|
|
1952
2114
|
|
|
1953
2115
|
// ── 继续工作流 ──
|
|
2116
|
+
// 【刀2 直发引擎(2026-10-05)】继续=三步走直发引擎命令(投影中心继续钮
|
|
2117
|
+
// 同款):档案取剧本原文快照 → job_resume(六关裁决全在引擎侧,改稿对不上
|
|
2118
|
+
// 指纹的错误按引擎原话上浮)。旧路(宿主 onRun 转手/独立模式 /api 路由)
|
|
2119
|
+
// 随直连退役。
|
|
1954
2120
|
const handleResumeWorkflow = useCallback(async () => {
|
|
1955
2121
|
lastActionAtRef.current = Date.now();
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
}
|
|
1964
|
-
if (!runId) return;
|
|
2122
|
+
const client = engineClientRef.current;
|
|
2123
|
+
// 【观演原位版 2026-10-08】继续同停止:正在观看某场时服务当前观看的场。
|
|
2124
|
+
const watchedIdR = activeViewRef.current !== 'edit'
|
|
2125
|
+
? Number(String(activeViewRef.current).slice(4)) : NaN;
|
|
2126
|
+
const target = (Number.isFinite(watchedIdR) && watchedIdR > 0) ? watchedIdR
|
|
2127
|
+
: (pluginJobId ?? runId);
|
|
2128
|
+
if (!client) { pushDebug('error', '继续', '引擎直连未就绪(引擎离线或伺候方未给地址)'); return; }
|
|
2129
|
+
if (!target) { pushDebug('error', '继续', '没有可续跑的 Job(未知场次号)'); return; }
|
|
1965
2130
|
try {
|
|
1966
|
-
|
|
2131
|
+
const full = await client.getJobState(target);
|
|
2132
|
+
if (!full || !full.script_text) throw new Error('档案读不到剧本快照(该 Job 不存在?)');
|
|
2133
|
+
const body = await client.resume(target, full.script_text);
|
|
2134
|
+
if (!body?.ok) throw new Error(body?.detail || body?.error || '引擎拒绝续跑');
|
|
1967
2135
|
setFlowStatus('running');
|
|
1968
2136
|
} catch (err) {
|
|
1969
2137
|
console.error('继续失败:', err);
|
|
2138
|
+
pushDebug('error', '继续', `续跑失败:${err?.message ?? err}`);
|
|
1970
2139
|
}
|
|
1971
|
-
}, [runId, plugin,
|
|
2140
|
+
}, [runId, plugin, pluginJobId, pushDebug]);
|
|
1972
2141
|
|
|
1973
2142
|
// ── 零 token 调试干跑(2026-09-08):「🐞 调试」按钮 ──
|
|
1974
|
-
// femo_debugger FakeHost 替 AI/human
|
|
2143
|
+
// femo_debugger FakeHost 替 AI/human 发言,引擎真实链路干跑FEMO脚本;
|
|
1975
2144
|
// /femo-plugin/debug-run 以 NDJSON 流式回传 DebugLogBus 记录,这里逐行
|
|
1976
2145
|
// 渲染进调试窗(Print 效果)。与正式运行状态机完全独立——任何 flowStatus
|
|
1977
2146
|
// 下都可用,不碰 job/SSE 链路;仅插件模式提供(独立后端无此路由)。
|
|
@@ -1988,11 +2157,11 @@ const handlePauseWorkflow = useCallback(async () => {
|
|
|
1988
2157
|
}
|
|
1989
2158
|
const femo = femoText;
|
|
1990
2159
|
if (!femo || !femo.trim()) {
|
|
1991
|
-
alert('
|
|
2160
|
+
alert('请先编写或打开 FEMO脚本');
|
|
1992
2161
|
return;
|
|
1993
2162
|
}
|
|
1994
2163
|
// 调试范围跟画布走(2026-09-12):在哪个画布按「调试」就调试哪个范围——
|
|
1995
|
-
//
|
|
2164
|
+
// 主画布=整个FEMO脚本;模块子画布(含嵌套层级)=只跑该模块。locationPath 形如
|
|
1996
2165
|
// ['mainflow','外层','内层'],去掉首段拼点路径即调试器的模块参数。
|
|
1997
2166
|
// 读 ref(locationPathRef)不进依赖:按下瞬间的画布位置即权威,且不重建回调。
|
|
1998
2167
|
const lp = locationPathRef.current || ['mainflow'];
|
|
@@ -2001,19 +2170,20 @@ const handlePauseWorkflow = useCallback(async () => {
|
|
|
2001
2170
|
setDebugOpen(true); // 按了就开调试窗,日志实时流入
|
|
2002
2171
|
pushDebug('info', '调试', debugModule
|
|
2003
2172
|
? `零 token 干跑启动——只跑模块 ${debugModule}(当前在它的子画布;AI/人类节点由调试器替答)…`
|
|
2004
|
-
: '零 token
|
|
2173
|
+
: '零 token 干跑启动——整个FEMO脚本(当前在主画布;AI/人类节点由调试器替答)…');
|
|
2005
2174
|
const controller = new AbortController();
|
|
2006
2175
|
debugRunAbortRef.current = controller;
|
|
2007
2176
|
try {
|
|
2008
2177
|
const resp = await fetch('/femo-plugin/debug-run', {
|
|
2009
2178
|
method: 'POST',
|
|
2010
2179
|
headers: { 'Content-Type': 'application/json' },
|
|
2011
|
-
// scriptPath=savedPath
|
|
2012
|
-
//
|
|
2013
|
-
//
|
|
2180
|
+
// scriptPath=effectiveSavedPath(插件=会话账的 savedPath;独立=服务端
|
|
2181
|
+
// path 槽):code: file:"xxx.py" 相对引用按原FEMO脚本目录解析(与正式
|
|
2182
|
+
// 运行同语义;未保存过的脚本回退沙盒目录)。
|
|
2183
|
+
// module:主画布=整个FEMO脚本;模块子画布=只跑该模块(嵌套点路径)。
|
|
2014
2184
|
body: JSON.stringify({
|
|
2015
2185
|
femo: femo,
|
|
2016
|
-
scriptPath:
|
|
2186
|
+
scriptPath: effectiveSavedPath || undefined,
|
|
2017
2187
|
module: debugModule,
|
|
2018
2188
|
}),
|
|
2019
2189
|
signal: controller.signal,
|
|
@@ -2063,7 +2233,7 @@ const handlePauseWorkflow = useCallback(async () => {
|
|
|
2063
2233
|
// 【2026-08-30 状态实时化】只关 run-scoped 的独立模式流(/api/run/<id>/stream,
|
|
2064
2234
|
// 运行结束=流终,不关会被 EventSource 当 404 反复重连);插件模式
|
|
2065
2235
|
// /femo-plugin/events 是页面级常驻广播——连接必须保留才能收到后续场次事件
|
|
2066
|
-
// (flow_start/flow_paused
|
|
2236
|
+
// (flow_start/flow_paused 等),关了就退回「外部启动运行看不见」的老坑。
|
|
2067
2237
|
const closeRunScopedSse = useCallback(() => {
|
|
2068
2238
|
const es = eventSourceRef.current;
|
|
2069
2239
|
if (es && !String(es.url ?? '').includes('/femo-plugin/events')) {
|
|
@@ -2077,7 +2247,7 @@ const handlePauseWorkflow = useCallback(async () => {
|
|
|
2077
2247
|
// 把整场弹过的输入浮层"走马灯"一遍);②运行态刷页面=只弹"当前在跑的节点",
|
|
2078
2248
|
// 有人类输入则优先人类输入。三个门(缺一不可):
|
|
2079
2249
|
// - 门一(帧源):只有"活帧"能弹——replay/_replayed 追平帧一律只恢复状态;
|
|
2080
|
-
// -
|
|
2250
|
+
// - 门二(场态):只有本次真在跑才弹(挂起/空闲=零浮层,不再依赖宿主是否
|
|
2081
2251
|
// 清了 waitingHuman);
|
|
2082
2252
|
// - 门三(目标):接通时的浮层由 /session-state 权威快照指定——人类等待
|
|
2083
2253
|
// 快照优先,否则引擎 checkpoint(=进入节点前记录的位置,运行中即当前节点)。
|
|
@@ -2197,7 +2367,31 @@ const handleWorkflowEvent = useCallback((evt) => {
|
|
|
2197
2367
|
console.log('[SSE event]', evt);
|
|
2198
2368
|
console.log('[handleWorkflowEvent] 收到事件', evt);
|
|
2199
2369
|
}
|
|
2200
|
-
|
|
2370
|
+
// 【变量世界记录(2026-09-24)】宿主 Variable API 定向供给(引擎 func_result/
|
|
2371
|
+
// assign_result/checkpoint 在宿主侧改走 variable-api.mjs 归一分发、不再进
|
|
2372
|
+
// 通用代播,dsh engine-events 以 variable_record 补回画布供给)。翻译回引擎
|
|
2373
|
+
// 事件形状,复用下方既有分支(调试窗摘要、节点匹配、In/Out 气泡全部照旧);
|
|
2374
|
+
// 独立模式直连引擎仍收原生 func_result/assign_result,两路并存。
|
|
2375
|
+
// 【checkpoint 活供给(2026-09-23 补全,用户令「画布上会显示断点」)】宿主
|
|
2376
|
+
// 以 brief 档上线 checkpoint(位置+label,变量世界整包 state 不外发)——
|
|
2377
|
+
// 画布此前对 checkpoint 事件零消费(断点显示只靠 /session-state 拉),现
|
|
2378
|
+
// 由 variable_record 实时驱动断点/当前节点高亮:运行中=当前节点、挂起后
|
|
2379
|
+
// 留在原地=断点标记。
|
|
2380
|
+
let { type, data } = evt;
|
|
2381
|
+
if (type === 'variable_record') {
|
|
2382
|
+
const r = (data && typeof data === 'object') ? data : {};
|
|
2383
|
+
if (r.kind === 'checkpoint') {
|
|
2384
|
+
const label = mainCheckpointLabel(r.checkpoints);
|
|
2385
|
+
if (label) {
|
|
2386
|
+
const node = findNodeByLabel(label);
|
|
2387
|
+
if (node) setActiveNodeIds(new Set([node.id]));
|
|
2388
|
+
}
|
|
2389
|
+
return;
|
|
2390
|
+
}
|
|
2391
|
+
if (r.kind !== 'func_result' && r.kind !== 'assign_result') return;
|
|
2392
|
+
type = r.kind;
|
|
2393
|
+
data = { ...r, node_name: r.node, job_id: r.job_id ?? r.jobId };
|
|
2394
|
+
}
|
|
2201
2395
|
console.log('[SSE event]', evt);
|
|
2202
2396
|
|
|
2203
2397
|
// 无需节点匹配的事件:直接处理或忽略
|
|
@@ -2226,6 +2420,32 @@ const handleWorkflowEvent = useCallback((evt) => {
|
|
|
2226
2420
|
if (Array.isArray(sum)) sum.forEach((s) => pushDebug(s.level, type, s.text));
|
|
2227
2421
|
else if (sum) pushDebug(sum.level, type, sum.text);
|
|
2228
2422
|
}
|
|
2423
|
+
// ═══ 引擎直连·观演路由(刀2,2026-10-05)═══
|
|
2424
|
+
// 直连帧不带宿主章(sid),天然全局;按场分派:跟随场=编辑稿这一版 →
|
|
2425
|
+
// 既有链路原样走(return false 放行);不是 → 喂观演镜像(编辑现场零
|
|
2426
|
+
// 触碰);别家的场 → 只进过上面的调试窗,这里安静丢弃。引擎脸没接通时
|
|
2427
|
+
// 路由不接管(一切照旧——过渡期宿主转播帧继续走老路)。
|
|
2428
|
+
{
|
|
2429
|
+
const route = engineRouteRef.current;
|
|
2430
|
+
if (route && route(type, data, evt)) return;
|
|
2431
|
+
}
|
|
2432
|
+
// 直连原生 checkpoint 帧(不经宿主 Variable API 翻译的正身形状,与
|
|
2433
|
+
// variable_record brief 同名字段):断点标签→编辑图亮点,运行中=当前
|
|
2434
|
+
// 节点、挂起后留在原地=断点。观演路线已在上面分派走。
|
|
2435
|
+
if (type === 'checkpoint') {
|
|
2436
|
+
const label = mainCheckpointLabel(data?.checkpoints);
|
|
2437
|
+
if (label) {
|
|
2438
|
+
const node = findNodeByLabel(label);
|
|
2439
|
+
if (node) setActiveNodeIds(new Set([node.id]));
|
|
2440
|
+
}
|
|
2441
|
+
return;
|
|
2442
|
+
}
|
|
2443
|
+
// 【2026-09-24 假 warn 消音(用户点名)】ai_request(料包走 mailbox 后只剩
|
|
2444
|
+
// 记账价值)与 femo_actor_usage(宿主角色占用圆环旁路帧)画布均无消费者
|
|
2445
|
+
// ——原本一个坠进「收到未知事件类型」、一个坠进「事件缺少 node_name」
|
|
2446
|
+
// 两处 console.warn,每场必响、淹没真错误。在节点匹配关卡前显式忽略
|
|
2447
|
+
// (调试窗一侧已由 summarize 的 skip 名单静音)。
|
|
2448
|
+
if (type === 'ai_request' || type === 'femo_actor_usage') return;
|
|
2229
2449
|
if (type === 'run_state') {
|
|
2230
2450
|
// 【flowStatus 快照驱动(§11.2)】状态判定以宿主广播的快照为准
|
|
2231
2451
|
// (B7 死于结构:不再有本地兜底覆盖)。
|
|
@@ -2244,6 +2464,8 @@ const handleWorkflowEvent = useCallback((evt) => {
|
|
|
2244
2464
|
if (plugin && !restoreDoneRef.current) {
|
|
2245
2465
|
const nodeScoped = !['flow_start', 'flow_done', 'flow_paused', 'done', 'module_enter', 'module_exit', 'flow_error', 'notify_author'].includes(type);
|
|
2246
2466
|
if (nodeScoped) {
|
|
2467
|
+
// 缓冲上限对齐宿主重放环(sse-core cap400):恢复面长期不可得时缓冲不无界涨。
|
|
2468
|
+
if (pendingReplayRef.current.length >= 400) pendingReplayRef.current.shift();
|
|
2247
2469
|
pendingReplayRef.current.push({ ...evt, _replayed: true });
|
|
2248
2470
|
return;
|
|
2249
2471
|
}
|
|
@@ -2426,7 +2648,7 @@ case 'human_wait':
|
|
|
2426
2648
|
inputError: null, // 新一轮等待:清掉上一轮的拒绝/失败红条
|
|
2427
2649
|
},
|
|
2428
2650
|
}));
|
|
2429
|
-
// 【浮层门卫(2026-09-11 v9
|
|
2651
|
+
// 【浮层门卫(2026-09-11 v9)】活帧才弹、且本次在跑才弹——追平帧(宿主重放/
|
|
2430
2652
|
// 前端补放)只恢复状态;挂起/空闲态零浮层(用户点名)。
|
|
2431
2653
|
if (!isCatchUpFrame(evt) && canPopOverlay()) setBubbleOverlay({ nodeId });
|
|
2432
2654
|
// 独立账本:par 并发时 AI 实例事件会覆盖 nodeStates[nodeId](同 node_id),
|
|
@@ -2487,7 +2709,7 @@ case 'node_retry': {
|
|
|
2487
2709
|
...existing,
|
|
2488
2710
|
context: data.context || '',
|
|
2489
2711
|
showprompt: data.showprompt || null,
|
|
2490
|
-
|
|
2712
|
+
actor_name: data.actor_name || 'AI',
|
|
2491
2713
|
},
|
|
2492
2714
|
};
|
|
2493
2715
|
});
|
|
@@ -2624,16 +2846,16 @@ case 'node_retry': {
|
|
|
2624
2846
|
|
|
2625
2847
|
|
|
2626
2848
|
case 'flow_start': {
|
|
2627
|
-
// 【2026-08-30
|
|
2628
|
-
// 都把按钮切进运行态——SSE
|
|
2849
|
+
// 【2026-08-30 状态实时化】任何来源的启动运行(本页/电脑端/AI/断点续跑)
|
|
2850
|
+
// 都把按钮切进运行态——SSE 常驻后本页靠它跟上外部启动运行。
|
|
2629
2851
|
// 【2026-09-11 v9】但**追平帧不驱动运行态**:历史 flow_start(挂起前
|
|
2630
|
-
//
|
|
2852
|
+
// 那一次留下的重放帧)不代表"现在在跑",旧写法会把挂起态的刷新页点成
|
|
2631
2853
|
// 运行态(浮层门卫失守、按钮也跟着错)。运行态由权威源裁决:
|
|
2632
2854
|
// /session-state 的 running、run_state 广播、本页的运行时回调。
|
|
2633
2855
|
if (!isCatchUpFrame(evt)) setFlowStatus('running');
|
|
2634
2856
|
setNodeStates({});
|
|
2635
2857
|
setActiveNodeIds(new Set());
|
|
2636
|
-
//
|
|
2858
|
+
// 新场次启动运行:上一次残留的人类等待一并清账(等待随引擎重启作废)
|
|
2637
2859
|
setHumanWaitsBoth({});
|
|
2638
2860
|
break;
|
|
2639
2861
|
}
|
|
@@ -2668,7 +2890,7 @@ case 'node_retry': {
|
|
|
2668
2890
|
// 终态:不再有活着的引擎等待,撤下常驻人类输入面板
|
|
2669
2891
|
setHumanWaitsBoth({});
|
|
2670
2892
|
break;
|
|
2671
|
-
break;
|
|
2893
|
+
// break; // 已退役(观察期 2026-09-26 死代码排查):不可达的第二个 break(笔误)
|
|
2672
2894
|
|
|
2673
2895
|
case 'flow_error':
|
|
2674
2896
|
// 工作流出错(Job failed 终态路径):nodeId 匹配得到就标红节点
|
|
@@ -2685,7 +2907,7 @@ case 'node_retry': {
|
|
|
2685
2907
|
// 确保该节点仍在活跃集合中(可能有并发分支还在跑)
|
|
2686
2908
|
setActiveNodeIds(prev => new Set([...prev, nodeId]));
|
|
2687
2909
|
}
|
|
2688
|
-
alert('❌
|
|
2910
|
+
alert('❌ FEMO 运行出错: ' + (data.error || '未知错误'));
|
|
2689
2911
|
// ★ 出错时清空模块栈(不切画布,让用户看错误)
|
|
2690
2912
|
moduleStackRef.current = [];
|
|
2691
2913
|
break;
|
|
@@ -2718,7 +2940,7 @@ case 'node_retry': {
|
|
|
2718
2940
|
setFlowStatus('idle');
|
|
2719
2941
|
// 清空所有活跃节点(done 事件不携带具体节点信息)
|
|
2720
2942
|
setActiveNodeIds(new Set());
|
|
2721
|
-
//
|
|
2943
|
+
// 流终了=本次收尾,等待账本不会还有活口(flow_done/bridge_run_ended
|
|
2722
2944
|
// 已清);再兜一次防鬼影输入框
|
|
2723
2945
|
setHumanWaitsBoth({});
|
|
2724
2946
|
if (eventSourceRef.current) {
|
|
@@ -2734,9 +2956,12 @@ case 'node_retry': {
|
|
|
2734
2956
|
console.warn('[FEMO] 收到未知事件类型:', type, data);
|
|
2735
2957
|
break;
|
|
2736
2958
|
}
|
|
2737
|
-
}, [closeRunScopedSse, clearPauseConfirmTimer, pushDebug]);
|
|
2959
|
+
}, [closeRunScopedSse, clearPauseConfirmTimer, pushDebug, findNodeByLabel]);
|
|
2738
2960
|
|
|
2739
2961
|
// 连接插件 SSE 广播(运行中打开标签页也实时接入;已连接则先关闭重连)。
|
|
2962
|
+
// 【已退役-观察期(刀2,2026-10-05)】宿主 SSE 转播订阅退役——画布改直连
|
|
2963
|
+
// 引擎(connectEngine,观察者身份全收);按会话裁剪的耳朵换成引擎全场。
|
|
2964
|
+
// 函数保留观察,调用点已拔;观察期无回归后随批次删除。
|
|
2740
2965
|
const connectSse = useCallback(() => {
|
|
2741
2966
|
if (eventSourceRef.current) {
|
|
2742
2967
|
eventSourceRef.current.close();
|
|
@@ -2746,7 +2971,7 @@ case 'node_retry': {
|
|
|
2746
2971
|
eventSourceRef.current = es;
|
|
2747
2972
|
es.onopen = () => {
|
|
2748
2973
|
// 【2026-09-06 多端状态统一】接通/重连即拉权威快照校准 flowStatus:
|
|
2749
|
-
// host /events 的重放缓冲只有 100
|
|
2974
|
+
// host /events 的重放缓冲只有 100 条,长跑FEMO脚本一开跑就把 run_state
|
|
2750
2975
|
// 快照挤出去——手机/睡眠唤醒等后连设备靠重放学不到状态切换,按钮会
|
|
2751
2976
|
// 卡在旧态(桌面端点了暂停→挂起,手机端不知道,右上角没有「从头」)。
|
|
2752
2977
|
// 判定与恢复 effect 同源:running→运行;有断点→继续+从头;否则运行。
|
|
@@ -2804,14 +3029,298 @@ case 'node_retry': {
|
|
|
2804
3029
|
}
|
|
2805
3030
|
}, []);
|
|
2806
3031
|
|
|
2807
|
-
//
|
|
2808
|
-
//
|
|
2809
|
-
//
|
|
2810
|
-
//
|
|
3032
|
+
// ═══ 引擎直连(画布直连引擎·刀2,2026-10-05)═══
|
|
3033
|
+
// 画布成为常驻引擎的一等客户端:事件流/开机校准/观演直连引擎 HTTP 面,
|
|
3034
|
+
// 宿主退回「告诉地址 + 远程时当透明管子」。显示面全走引擎;控制面边界
|
|
3035
|
+
// 不动——运行=宿主回调(守卫/record/挂载是宿主职责),停止/继续=引擎命令
|
|
3036
|
+
// 直发,人类输入=引擎命令直发(wait_key 引擎自己裁决)。
|
|
3037
|
+
const engineClientRef = useRef(null);
|
|
3038
|
+
const engineEventsRef = useRef(null);
|
|
3039
|
+
const engineWatchdogRef = useRef(null);
|
|
3040
|
+
const engineOfflineTimerRef = useRef(null);
|
|
3041
|
+
const engineFailRef = useRef(0);
|
|
3042
|
+
const pendingCalibrateRef = useRef(false);
|
|
3043
|
+
// 通路状态:直连(本机)| 转发(远程后备)| 重连中 | 离线——观演头与状态灯显示
|
|
3044
|
+
const [engineTransport, setEngineTransport] = useState('离线');
|
|
3045
|
+
const engineTransportRef = useRef('离线');
|
|
3046
|
+
engineTransportRef.current = engineTransport;
|
|
3047
|
+
const engineDirectRef = useRef(false); // 引擎脸接通即 true(路由接管开关)
|
|
3048
|
+
// ── 视图登记制(多 job 下拉的铺垫):当前视图 id + 登记表,切换机制只有一套 ──
|
|
3049
|
+
const [activeViewId, setActiveViewId] = useState('edit'); // 'edit' | 'job:<N>'
|
|
3050
|
+
const activeViewRef = useRef('edit');
|
|
3051
|
+
activeViewRef.current = activeViewId;
|
|
3052
|
+
const [watchJobId, setWatchJobId] = useState(null); // 当前跟随的场
|
|
3053
|
+
const watchJobRef = useRef(null); // 同步权威:engineCalibrate 直写(flush 同拍路由靠它,不等渲染)
|
|
3054
|
+
const [editMatchesJob, setEditMatchesJob] = useState(true); // 跟随场=编辑稿这一版?
|
|
3055
|
+
const editMatchesJobRef = useRef(true);
|
|
3056
|
+
editMatchesJobRef.current = editMatchesJob;
|
|
3057
|
+
const [watchViews, setWatchViews] = useState({}); // 登记表 {'<jobId>': 观演条目}
|
|
3058
|
+
const watchViewsRef = useRef(watchViews);
|
|
3059
|
+
watchViewsRef.current = watchViews;
|
|
3060
|
+
const watchExitedRef = useRef(null); // 用户手动退出的场:该场不自动再进(新场重置)
|
|
3061
|
+
const femoTextRef = useRef('');
|
|
3062
|
+
femoTextRef.current = femoText;
|
|
3063
|
+
const handleWorkflowEventRef = useRef(null);
|
|
3064
|
+
handleWorkflowEventRef.current = handleWorkflowEvent;
|
|
3065
|
+
const engineRouteRef = useRef(null); // handleWorkflowEvent 的直连分派(渲染期赋值)
|
|
3066
|
+
// 校准竞态闸(2026-10-05 夹具实测抓到):SSE 一开帧就到,而校准(清单→档案)
|
|
3067
|
+
// 要两个往返——这窗口里的帧既不能投编辑图(还没判「是不是同一版」)也没处投
|
|
3068
|
+
// 观演(登记表还没建)。照恢复期同款纪律:宁可排队,校准落定后按序重放。
|
|
3069
|
+
const engineCalibratedRef = useRef(false);
|
|
3070
|
+
const enginePendingRef = useRef([]);
|
|
3071
|
+
|
|
3072
|
+
/** 观演视图登记(剧本与编辑稿不一致才建):档案剧本→图解析一次,mirror 随事件涨。 */
|
|
3073
|
+
function ensureWatchView(job) {
|
|
3074
|
+
setWatchViews((prev) => {
|
|
3075
|
+
if (prev[job.job_id]) return prev;
|
|
3076
|
+
const next = { ...prev, [job.job_id]: {
|
|
3077
|
+
jobId: job.job_id,
|
|
3078
|
+
meta: { scriptName: job.script_name || '', hostRefs: job.host_refs || {} },
|
|
3079
|
+
graph: buildWatchGraph(job.script_text),
|
|
3080
|
+
mirror: { ...createWatchState(), status: job.state || 'idle' },
|
|
3081
|
+
} };
|
|
3082
|
+
// 登记表不封顶(2026-10-08 用户拍板「有多少收多少」):runners 有几场
|
|
3083
|
+
// 登记几场;终局条目由用户手动切走(历史定格还在,不自动挤掉)。
|
|
3084
|
+
return next;
|
|
3085
|
+
});
|
|
3086
|
+
}
|
|
3087
|
+
|
|
3088
|
+
/** 开机/重连校准:健康口(runners) → 清单 → 挑跟随场 → 档案。显示面的
|
|
3089
|
+
* 权威全在引擎内存真相——盘上台账的 running 会有大量僵尸(没人收尸的账),
|
|
3090
|
+
* 跟随只认 runners(2026-10-08 用户拍板「应该盯 runners,有多少收多少」);
|
|
3091
|
+
* 老引擎/健康口没答=退回旧台账口径,零回归。 */
|
|
3092
|
+
async function engineCalibrate() {
|
|
3093
|
+
const client = engineClientRef.current;
|
|
3094
|
+
if (!client) return;
|
|
3095
|
+
const [jobs, h] = await Promise.all([
|
|
3096
|
+
client.listJobs().catch(() => []),
|
|
3097
|
+
client.health().catch(() => false),
|
|
3098
|
+
]);
|
|
3099
|
+
const runners = (h && Array.isArray(h.runners)) ? h.runners : null;
|
|
3100
|
+
const target = runners ? pickFollowJob(runners, jobs, { hostGrid: '' })
|
|
3101
|
+
: pickJob(jobs, { hostGrid: '' });
|
|
3102
|
+
if (!target) {
|
|
3103
|
+
// 引擎空闲:跟随目标摘除(观演登记表保留——历史定格还在)
|
|
3104
|
+
setWatchJobId(null);
|
|
3105
|
+
watchJobRef.current = null;
|
|
3106
|
+
setEditMatchesJob(true); editMatchesJobRef.current = true;
|
|
3107
|
+
engineDirectRef.current = true;
|
|
3108
|
+
if (activeViewRef.current !== 'edit') setActiveViewId('edit');
|
|
3109
|
+
engineCalibratedRef.current = true;
|
|
3110
|
+
const queued0 = enginePendingRef.current;
|
|
3111
|
+
enginePendingRef.current = [];
|
|
3112
|
+
for (const f of queued0) handleWorkflowEventRef.current?.({ type: f.type, data: f.data, replay: f.replay });
|
|
3113
|
+
return;
|
|
3114
|
+
}
|
|
3115
|
+
const full = await client.getJobState(target.job_id).catch(() => null);
|
|
3116
|
+
if (!full || full.state === undefined) {
|
|
3117
|
+
// 档案读不到(引擎刚散场/瞬时故障):按未跟随放行(退化=旧行为),
|
|
3118
|
+
// 不让帧无限期压在缓冲里。
|
|
3119
|
+
watchJobRef.current = null;
|
|
3120
|
+
engineCalibratedRef.current = true;
|
|
3121
|
+
const queuedE = enginePendingRef.current;
|
|
3122
|
+
enginePendingRef.current = [];
|
|
3123
|
+
for (const f of queuedE) handleWorkflowEventRef.current?.({ type: f.type, data: f.data, replay: f.replay });
|
|
3124
|
+
return;
|
|
3125
|
+
}
|
|
3126
|
+
setWatchJobId(target.job_id);
|
|
3127
|
+
watchJobRef.current = target.job_id; // 同步直写:flush 就在同一拍,路由立刻认场
|
|
3128
|
+
const matches = sameScriptText(full.script_text, femoTextRef.current);
|
|
3129
|
+
setEditMatchesJob(matches); editMatchesJobRef.current = matches;
|
|
3130
|
+
engineDirectRef.current = true;
|
|
3131
|
+
if (matches) {
|
|
3132
|
+
// 这场戏就是编辑稿这一版:校准编辑图按钮与断点亮点(与宿主快照校准同口径)
|
|
3133
|
+
setFlowStatus(full.state === 'running' ? 'running' : full.state === 'suspended' ? 'paused' : 'idle');
|
|
3134
|
+
const label = mainCheckpointLabel(full.checkpoint_labels || {});
|
|
3135
|
+
if (label) {
|
|
3136
|
+
const node = findNodeByLabel(label);
|
|
3137
|
+
if (node) setActiveNodeIds(new Set([node.id]));
|
|
3138
|
+
}
|
|
3139
|
+
if (activeViewRef.current !== 'edit') setActiveViewId('edit');
|
|
3140
|
+
} else {
|
|
3141
|
+
// 别家开的场/画的不是这一版:观演登记 + 自动进入(已拍板;手动退出过的场不扰)
|
|
3142
|
+
ensureWatchView(full);
|
|
3143
|
+
if (watchExitedRef.current !== target.job_id) setActiveViewId(`job:${target.job_id}`);
|
|
3144
|
+
}
|
|
3145
|
+
// runners 全量登记(2026-10-08「有多少收多少」):除跟随目标外的每一场
|
|
3146
|
+
// 真在跑的戏都进观演下拉——只登记不抢屏;已登记的不重拉档案;拉不到的
|
|
3147
|
+
// 下轮校准(新场 flow_start 也触发)再来。老引擎无 runners 口=跳过。
|
|
3148
|
+
if (runners) {
|
|
3149
|
+
for (const rid of runners) {
|
|
3150
|
+
const ridN = Number(rid);
|
|
3151
|
+
if (!Number.isFinite(ridN) || ridN === Number(target.job_id)) continue;
|
|
3152
|
+
if (watchViewsRef.current[ridN]) continue;
|
|
3153
|
+
const f = await client.getJobState(ridN).catch(() => null);
|
|
3154
|
+
if (f && f.state !== undefined) ensureWatchView(f);
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
// 校准落定:重放竞态窗里排队的帧(此刻「是不是同一版/登记表」都已就位,
|
|
3158
|
+
// 帧会按 routing 各归各家——观演进镜像,编辑稿的场走既有链路)
|
|
3159
|
+
engineCalibratedRef.current = true;
|
|
3160
|
+
const queued = enginePendingRef.current;
|
|
3161
|
+
enginePendingRef.current = [];
|
|
3162
|
+
for (const f of queued) handleWorkflowEventRef.current?.({ type: f.type, data: f.data, replay: f.replay });
|
|
3163
|
+
}
|
|
3164
|
+
|
|
3165
|
+
/** 校准就绪闸:插件模式等画布从会话快照恢复完(编辑稿落定才判「是不是同一版」)。 */
|
|
3166
|
+
function engineCalibrateWhenReady() {
|
|
3167
|
+
if (!plugin || restoreDoneRef.current) { void engineCalibrate(); return; }
|
|
3168
|
+
pendingCalibrateRef.current = true;
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
/** 事件流接线(直连失败自动切伺候方透明转发——管子换人,协议还是引擎的)。 */
|
|
3172
|
+
function attachEngineEvents(client, disc, state) {
|
|
3173
|
+
return client.openEvents({
|
|
3174
|
+
onOpen: () => {
|
|
3175
|
+
state.opened = true;
|
|
3176
|
+
engineFailRef.current = 0;
|
|
3177
|
+
engineDirectRef.current = true;
|
|
3178
|
+
setEngineTransport(client.isRelay() ? '转发' : '直连');
|
|
3179
|
+
engineCalibrateWhenReady();
|
|
3180
|
+
// 兜底校准(恢复竞态双保险,幂等)
|
|
3181
|
+
setTimeout(() => engineCalibrateWhenReady(), 1500);
|
|
3182
|
+
},
|
|
3183
|
+
onFrame: (frame) => { handleWorkflowEventRef.current?.(frame); },
|
|
3184
|
+
onError: () => {
|
|
3185
|
+
// 浏览器自动重连管断线;「从没开过就一直错」=直连被拦(CSP/网络)——
|
|
3186
|
+
// 有转发路就切过去重连,语义不变(门0 的后备半场)。
|
|
3187
|
+
if (!state.opened && !client.isRelay() && disc.relay) {
|
|
3188
|
+
client.useRelay();
|
|
3189
|
+
engineEventsRef.current?.close();
|
|
3190
|
+
engineEventsRef.current = attachEngineEvents(client, disc, state);
|
|
3191
|
+
}
|
|
3192
|
+
},
|
|
3193
|
+
});
|
|
3194
|
+
}
|
|
3195
|
+
|
|
3196
|
+
/** 连引擎:发现 → 客户端 → 观察者订阅 → 健康看门狗。显示面绝不代拉引擎。 */
|
|
3197
|
+
async function connectEngine() {
|
|
3198
|
+
clearTimeout(engineOfflineTimerRef.current);
|
|
3199
|
+
const disc = await discoverEngine();
|
|
3200
|
+
if (!disc) {
|
|
3201
|
+
engineDirectRef.current = false;
|
|
3202
|
+
setEngineTransport('离线');
|
|
3203
|
+
// 伺候方没给地址(引擎离线/无宿主伺候):周期重问——任何宿主客户端的
|
|
3204
|
+
// 探活会顺手把引擎代拉回来,这里只等地址。
|
|
3205
|
+
engineOfflineTimerRef.current = setTimeout(() => { void connectEngine(); }, 15000);
|
|
3206
|
+
return;
|
|
3207
|
+
}
|
|
3208
|
+
const client = createEngineClient({
|
|
3209
|
+
base: disc.base, relay: disc.relay,
|
|
3210
|
+
onLog: (m) => pushDebug('info', '引擎', m),
|
|
3211
|
+
});
|
|
3212
|
+
engineClientRef.current = client;
|
|
3213
|
+
engineCalibratedRef.current = false; // 新连接=重新校准(地址都可能换了)
|
|
3214
|
+
engineEventsRef.current?.close();
|
|
3215
|
+
const state = { opened: false };
|
|
3216
|
+
engineEventsRef.current = attachEngineEvents(client, disc, state);
|
|
3217
|
+
// 健康看门狗(投影页欠账判据的画布版):问过没回×3=管道实死 → 重新发现
|
|
3218
|
+
// (引擎代拉重生可能换端口)+ 换新线。不用「多久没听到帧」——浏览器把
|
|
3219
|
+
// 后台页计时器冻到一分钟一拍,墙钟静默是假证据(投影页实测教训)。
|
|
3220
|
+
clearInterval(engineWatchdogRef.current);
|
|
3221
|
+
engineWatchdogRef.current = setInterval(async () => {
|
|
3222
|
+
const h = await client.health();
|
|
3223
|
+
if (!h) {
|
|
3224
|
+
engineFailRef.current += 1;
|
|
3225
|
+
if (engineFailRef.current >= 3) {
|
|
3226
|
+
engineFailRef.current = 0;
|
|
3227
|
+
engineDirectRef.current = false;
|
|
3228
|
+
setEngineTransport('重连中');
|
|
3229
|
+
engineEventsRef.current?.close();
|
|
3230
|
+
void connectEngine();
|
|
3231
|
+
}
|
|
3232
|
+
return;
|
|
3233
|
+
}
|
|
3234
|
+
engineFailRef.current = 0;
|
|
3235
|
+
if (engineTransportRef.current === '重连中') setEngineTransport(client.isRelay() ? '转发' : '直连');
|
|
3236
|
+
// 帧龄自愈(2026-10-08):引擎心跳已是 JS 可见的 ping 数据帧(15s 一拍),
|
|
3237
|
+
// 健康口活着却长期无帧=直播线半死(TCP 无声断开,onerror 永不来)——
|
|
3238
|
+
// 关旧线原地重订(地址没变,不必重新发现)。判据是「同一条管子有没有
|
|
3239
|
+
// 帧」而非「多久没听到戏」:戏间歇本是常态,ping 不间歇;90s=连续六拍
|
|
3240
|
+
// 无帧,远超正常节拍又远短于「用户发现画布凉了」。老引擎心跳是注释行
|
|
3241
|
+
// (JS 看不见),健康口无 ssePing 标记就不启用,防误杀空转管道。
|
|
3242
|
+
if (h.ssePing && state.opened) {
|
|
3243
|
+
const lastAt = client.lastEventAt();
|
|
3244
|
+
if (lastAt > 0 && Date.now() - lastAt > 90000) {
|
|
3245
|
+
pushDebug('info', '引擎', '直播线 90 秒无帧(管道半死)——换新线重订');
|
|
3246
|
+
engineEventsRef.current?.close();
|
|
3247
|
+
engineEventsRef.current = attachEngineEvents(client, disc, state);
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
}, 20000);
|
|
3251
|
+
}
|
|
3252
|
+
|
|
3253
|
+
function engineTeardown() {
|
|
3254
|
+
clearInterval(engineWatchdogRef.current);
|
|
3255
|
+
clearTimeout(engineOfflineTimerRef.current);
|
|
3256
|
+
engineEventsRef.current?.close();
|
|
3257
|
+
engineEventsRef.current = null;
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3260
|
+
// 直连分派(handleWorkflowEvent 每帧问一次;返回 true=已接管)。规则:
|
|
3261
|
+
// 跟随场=编辑稿这一版 → 既有链路直走;不是 → 喂观演镜像(编辑现场零触碰);
|
|
3262
|
+
// 别家的场 → 只进调试窗(喂食在分派之前),这里丢弃。新场 flow_start →
|
|
3263
|
+
// 重新校准(观演登记表自动长出/翻面)。
|
|
3264
|
+
engineRouteRef.current = (type, data, evt) => {
|
|
3265
|
+
if (!engineDirectRef.current) return false; // 引擎脸没接通:一切照旧
|
|
3266
|
+
if (!engineCalibratedRef.current) {
|
|
3267
|
+
// 校准未落定:入缓冲(追平帧也照收——重放环可能正好在这窗口里补历史)
|
|
3268
|
+
if (enginePendingRef.current.length >= 400) enginePendingRef.current.shift();
|
|
3269
|
+
enginePendingRef.current.push({ type, data, replay: evt?.replay === true });
|
|
3270
|
+
return true;
|
|
3271
|
+
}
|
|
3272
|
+
const jid = Number(data?.job_id);
|
|
3273
|
+
const known = Number.isFinite(jid) && jid > 0;
|
|
3274
|
+
// 【观演原位版 2026-10-08】帧喂给登记表里对上号的观演条目(有登记才喂):
|
|
3275
|
+
// 跟随场与其余 runners 的镜像都保持新鲜——切换视图零缺帧,不用等重连重放。
|
|
3276
|
+
const feedRegistered = () => {
|
|
3277
|
+
if (!known) return;
|
|
3278
|
+
setWatchViews((prev) => {
|
|
3279
|
+
const v = prev[jid];
|
|
3280
|
+
if (!v) return prev;
|
|
3281
|
+
return { ...prev, [jid]: { ...v, mirror: applyWatchEvent(v.mirror, type, data, { replay: evt?.replay === true }) } };
|
|
3282
|
+
});
|
|
3283
|
+
};
|
|
3284
|
+
if (editMatchesJobRef.current) {
|
|
3285
|
+
if (!known || jid === watchJobRef.current) return false; // 编辑稿这一版 → 编辑图链路
|
|
3286
|
+
feedRegistered();
|
|
3287
|
+
return true;
|
|
3288
|
+
}
|
|
3289
|
+
if (watchJobRef.current == null) {
|
|
3290
|
+
feedRegistered();
|
|
3291
|
+
return known;
|
|
3292
|
+
}
|
|
3293
|
+
if (known && jid !== watchJobRef.current) {
|
|
3294
|
+
if (type === 'flow_start' && evt?.replay !== true) void engineCalibrate();
|
|
3295
|
+
feedRegistered();
|
|
3296
|
+
return true;
|
|
3297
|
+
}
|
|
3298
|
+
feedRegistered();
|
|
3299
|
+
return true;
|
|
3300
|
+
};
|
|
3301
|
+
|
|
3302
|
+
// 【画布直连(刀2)】两种形态开机即连引擎。插件模式替换宿主 SSE 转播
|
|
3303
|
+
// (connectSse 退役观察——按会话裁剪的耳朵换成引擎全场观察者);独立模式
|
|
3304
|
+
// 替换「点运行才连」的按场流(别处开的场从此也能看,刷新也没用的一抹黑
|
|
3305
|
+
// 就此了账)。
|
|
3306
|
+
useEffect(() => {
|
|
3307
|
+
void connectEngine();
|
|
3308
|
+
return () => engineTeardown();
|
|
3309
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3310
|
+
}, []);
|
|
3311
|
+
|
|
3312
|
+
// 后台切回体检(2026-10-08):后台页计时器被浏览器冻结(实测一分钟一拍),
|
|
3313
|
+
// 帧龄看门狗在后台跑不动;切回前台这一拍立即重新校准——后台期间错过的
|
|
3314
|
+
// 新场开演由 runners 全量登记补上,半死的直播线由看门狗帧龄判死换线。
|
|
2811
3315
|
useEffect(() => {
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
3316
|
+
const onVisible = () => {
|
|
3317
|
+
if (document.visibilityState !== 'visible') return;
|
|
3318
|
+
if (engineDirectRef.current) engineCalibrateWhenReady();
|
|
3319
|
+
};
|
|
3320
|
+
document.addEventListener('visibilitychange', onVisible);
|
|
3321
|
+
return () => document.removeEventListener('visibilitychange', onVisible);
|
|
3322
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3323
|
+
}, []);
|
|
2815
3324
|
|
|
2816
3325
|
// 【刷新恢复·补放(2026-09-06)】画布恢复完成后的首次 nodes/flowStore
|
|
2817
3326
|
// 提交时,按序补放恢复期间缓冲的 SSE 节点事件——运行中的节点状态
|
|
@@ -2824,6 +3333,11 @@ case 'node_retry': {
|
|
|
2824
3333
|
pendingReplayRef.current = [];
|
|
2825
3334
|
console.log('[FEMOEditor] 恢复完成,补放缓冲事件:', queued.length);
|
|
2826
3335
|
for (const evt of queued) handleWorkflowEvent(evt);
|
|
3336
|
+
// 【刀2】恢复完成=编辑稿落定:补做挂起的引擎校准(判「跟随场是不是这一版」)
|
|
3337
|
+
if (pendingCalibrateRef.current) {
|
|
3338
|
+
pendingCalibrateRef.current = false;
|
|
3339
|
+
void engineCalibrate();
|
|
3340
|
+
}
|
|
2827
3341
|
}, [plugin, nodes, flowStore, handleWorkflowEvent]);
|
|
2828
3342
|
|
|
2829
3343
|
// ═══ 接通快照 → 浮层(2026-09-11 v9)═══
|
|
@@ -2890,11 +3404,6 @@ const submitHumanInput = useCallback(
|
|
|
2890
3404
|
};
|
|
2891
3405
|
const hasChat = chatText && chatText.trim();
|
|
2892
3406
|
const hasVars = assignments && Object.keys(assignments).length > 0;
|
|
2893
|
-
// runId 守卫只约束独立模式:插件模式 runId 恒 null(运行由 host 驱动,
|
|
2894
|
-
// handleRunWorkflow 显式 setRunId(null))——旧写法 `!runId ||` 让插件模式
|
|
2895
|
-
// 的气泡输入永远在第一行静默返回。与 handlePauseWorkflow 的
|
|
2896
|
-
// `!runId && !plugin` 同款口径(2026-09-06 修复)。
|
|
2897
|
-
if (!plugin && !runId) return fail('提交失败:运行未启动(独立模式缺 runId)。');
|
|
2898
3407
|
if (!hasChat && !hasVars) return false;
|
|
2899
3408
|
|
|
2900
3409
|
// 直接从独立账本取(par 并发下 nodeStates[nodeId] 可能已被 AI 实例事件
|
|
@@ -2906,28 +3415,17 @@ const submitHumanInput = useCallback(
|
|
|
2906
3415
|
return fail('提交失败:引擎等待状态未同步(缺 wait_key)。请回到对话窗口输入,或重新运行。');
|
|
2907
3416
|
}
|
|
2908
3417
|
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
3418
|
+
// 【刀2 直发引擎(2026-10-05)】人类席交卷=引擎命令直发(信封词汇=公共层
|
|
3419
|
+
// speech-core 人类席形状 {chat_text, variables?},wait_key 对不对得上由
|
|
3420
|
+
// 引擎裁决——不盲投)。旧路(宿主路由/独立模式 /api 转手)随直连退役。
|
|
3421
|
+
const client = engineClientRef.current;
|
|
3422
|
+
const targetJob = watchJobRef.current ?? pluginJobId ?? runId;
|
|
3423
|
+
if (!client) return fail('提交失败:引擎直连未就绪(引擎离线)。');
|
|
3424
|
+
if (!targetJob) return fail('提交失败:未知场次号(Job 未登记)。');
|
|
2917
3425
|
try {
|
|
2918
|
-
const
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
body: JSON.stringify(payload),
|
|
2922
|
-
});
|
|
2923
|
-
const data = await resp.json().catch(() => null);
|
|
2924
|
-
if (!resp.ok) {
|
|
2925
|
-
return fail(`提交失败:HTTP ${resp.status}${data?.error ? ` ${data.error}` : ''}`);
|
|
2926
|
-
}
|
|
2927
|
-
// host 回执 delivered:false = B6 拦截(无活跃 Job/等待态已失效)——
|
|
2928
|
-
// 此前被当成功误标 human_done,引擎实际没收到。
|
|
2929
|
-
if (data && data.delivered === false) {
|
|
2930
|
-
return fail(`提交未送达引擎(${data.note || 'no active job'})。可回对话窗口输入,或重试。`);
|
|
3426
|
+
const body = await client.humanInput(targetJob, waitKey, chatText || '', assignments || {});
|
|
3427
|
+
if (!body?.ok) {
|
|
3428
|
+
return fail(`提交未送达引擎(${body?.detail || body?.error || '未知拒绝'})。可回对话窗口输入,或重试。`);
|
|
2931
3429
|
}
|
|
2932
3430
|
} catch (err) {
|
|
2933
3431
|
return fail(`提交失败:${String(err?.message ?? err)}`);
|
|
@@ -2990,13 +3488,17 @@ const submitHumanInput = useCallback(
|
|
|
2990
3488
|
// 节点拖拽、连线时,无需检查 isMouseDownRef
|
|
2991
3489
|
if (drag) {
|
|
2992
3490
|
const z = effectiveZoom(cvRef.current);
|
|
3491
|
+
// 缩放折算吸附阈值:屏幕上始终是 SNAP_PX 像素的手感
|
|
3492
|
+
const th = SNAP_PX / Math.max(0.05, scale * z);
|
|
2993
3493
|
setNodes((p) => {
|
|
2994
3494
|
const draggedNode = p.find(n => n.id === drag.id);
|
|
2995
3495
|
if (!draggedNode) return p;
|
|
2996
3496
|
const newX = drag.ox + (e.clientX - drag.sx) / (scale * z);
|
|
2997
3497
|
const newY = drag.oy + (e.clientY - drag.sy) / (scale * z);
|
|
2998
|
-
// FOR↔for_out
|
|
2999
|
-
|
|
3498
|
+
// 先吸附对齐,再走 FOR↔for_out 联动(两件事都在 common/snap 里)
|
|
3499
|
+
const r = snapAndLink(p, draggedNode, newX, newY, th, applyForLinkage);
|
|
3500
|
+
updateGuides(r.guides);
|
|
3501
|
+
return r.nodes;
|
|
3000
3502
|
});
|
|
3001
3503
|
return;
|
|
3002
3504
|
}
|
|
@@ -3065,7 +3567,8 @@ const submitHumanInput = useCallback(
|
|
|
3065
3567
|
const onMU = useCallback(() => {
|
|
3066
3568
|
if (drag) {
|
|
3067
3569
|
const draggedNode = nodesRef.current.find(n => n.id === drag.id);
|
|
3068
|
-
if (draggedNode && (draggedNode.specialType === 'START' || draggedNode.specialType === 'IN')) {
|
|
3570
|
+
if (draggedNode && (draggedNode.specialType === 'START' || draggedNode.specialType === 'IN') && !entryRezeroDoneRef.current) {
|
|
3571
|
+
entryRezeroDoneRef.current = true; // 本次手势只归零一次(window 兜底会补跑 onMU)
|
|
3069
3572
|
const dx = draggedNode.x;
|
|
3070
3573
|
const dy = draggedNode.y;
|
|
3071
3574
|
//console.log('[DEBUG] 入口归零前坐标:', draggedNode.x, draggedNode.y);
|
|
@@ -3098,10 +3601,19 @@ const submitHumanInput = useCallback(
|
|
|
3098
3601
|
setDrag(null);
|
|
3099
3602
|
setConn(null);
|
|
3100
3603
|
setIsPanning(false);
|
|
3604
|
+
// 松手清吸附连线(手机端在 finishGesture 里清,这里覆盖桌面端)
|
|
3605
|
+
setSnapGuides(null);
|
|
3101
3606
|
isDraggingRef.current = false;
|
|
3102
3607
|
isMouseDownRef.current = false;
|
|
3103
3608
|
}, [drag, nodesRef]);
|
|
3104
3609
|
|
|
3610
|
+
// onMU/onMM 的 ref 同步 effect(自上方 window 兜底块移来,必须在声明后,
|
|
3611
|
+
// 否则依赖数组渲染期求值触发 TDZ——2026-09-21 修复,见上)。
|
|
3612
|
+
// 注意:必须用无 deps 形式——deps 数组在 render 期求值,而 onMU/onMM 声明
|
|
3613
|
+
// 在组件体更后面,写 [onMU] 会在挂载时 TDZ ReferenceError 直接白屏。
|
|
3614
|
+
useEffect(() => { onMURef.current = onMU; });
|
|
3615
|
+
useEffect(() => { onMMRef.current = onMM; });
|
|
3616
|
+
|
|
3105
3617
|
// Canvas mouse down (for panning)
|
|
3106
3618
|
const onCanvasDown = useCallback(
|
|
3107
3619
|
(e) => {
|
|
@@ -3133,10 +3645,15 @@ const submitHumanInput = useCallback(
|
|
|
3133
3645
|
// 如果提供了实际端口坐标(FOR 出圆圈),使用它;否则从节点坐标计算
|
|
3134
3646
|
let srcX = portX, srcY = portY;
|
|
3135
3647
|
if (srcX === undefined || srcY === undefined) {
|
|
3136
|
-
//
|
|
3648
|
+
// 没拿到端口坐标:按方向从节点矩形推算,别退回中心(中心会让连线起点错位)
|
|
3137
3649
|
const size = getNodeSize(node);
|
|
3138
|
-
|
|
3139
|
-
|
|
3650
|
+
switch (portDir) {
|
|
3651
|
+
case 'top': srcX = node.x + size.w / 2; srcY = node.y; break;
|
|
3652
|
+
case 'bottom': srcX = node.x + size.w / 2; srcY = node.y + size.h; break;
|
|
3653
|
+
case 'left': srcX = node.x; srcY = node.y + size.h / 2; break;
|
|
3654
|
+
case 'right': srcX = node.x + size.w; srcY = node.y + size.h / 2; break;
|
|
3655
|
+
default: srcX = node.x + size.w / 2; srcY = node.y + size.h / 2;
|
|
3656
|
+
}
|
|
3140
3657
|
}
|
|
3141
3658
|
setConn({ srcId: nodeId, srcDir: portDir, mx: cx, my: cy, srcX, srcY });
|
|
3142
3659
|
}
|
|
@@ -3182,13 +3699,110 @@ const submitHumanInput = useCallback(
|
|
|
3182
3699
|
}
|
|
3183
3700
|
}
|
|
3184
3701
|
|
|
3702
|
+
// 节点名说明框的内联编辑落账口:改 actionStore(画布图的动作数据本体)。
|
|
3703
|
+
// 图守卫基线含 actionStore,落账后 run 守卫立刻能看见未同步的图修改。
|
|
3704
|
+
function patchAction(actionId, patch) {
|
|
3705
|
+
setActionStore((prev) => prev.map((a) => (a.id === actionId ? { ...a, ...patch } : a)));
|
|
3706
|
+
}
|
|
3707
|
+
|
|
3708
|
+
// ═══ 仓库 → 面包屑拖拽:跨画布仓库挪 action(2026-10-05)═══
|
|
3709
|
+
// 模块子画布里把仓库的 action 卡拖到 header 的「主流程/上级模块」芯片上松手,
|
|
3710
|
+
// 该 action 定义就挪进那个画布的仓库。拖拽进行中的条目记在 ref 里:
|
|
3711
|
+
// dataTransfer 的数据在 dragover 阶段读不到(浏览器安全限制),类型判断只能
|
|
3712
|
+
// 靠 dragstart 记账;window 级 dragend/drop 清账——Esc 取消、落到无效区、
|
|
3713
|
+
// 正常投放都能归零,防陈旧账目让下一次无关拖拽误亮/误挪。
|
|
3714
|
+
const libDragItemRef = useRef(null);
|
|
3715
|
+
const [crumbDropHover, setCrumbDropHover] = useState(null); // 悬停中的投放目标 key(path.join('/'))
|
|
3716
|
+
useEffect(() => {
|
|
3717
|
+
const clear = () => {
|
|
3718
|
+
libDragItemRef.current = null;
|
|
3719
|
+
setCrumbDropHover(null);
|
|
3720
|
+
};
|
|
3721
|
+
window.addEventListener('dragend', clear);
|
|
3722
|
+
window.addEventListener('drop', clear);
|
|
3723
|
+
return () => {
|
|
3724
|
+
window.removeEventListener('dragend', clear);
|
|
3725
|
+
window.removeEventListener('drop', clear);
|
|
3726
|
+
};
|
|
3727
|
+
}, []);
|
|
3728
|
+
|
|
3185
3729
|
// Drag from library
|
|
3186
3730
|
function handleLibDragStart(e, type, idOrType) {
|
|
3187
3731
|
e.dataTransfer.setData(
|
|
3188
3732
|
'application/femo-item',
|
|
3189
3733
|
JSON.stringify({ type, id: idOrType })
|
|
3190
3734
|
);
|
|
3191
|
-
|
|
3735
|
+
// copyMove:画布投放=copy(复制节点实例),面包屑投放=move(挪仓库)。
|
|
3736
|
+
// effectAllowed 若锁死 'copy',面包屑 dragover 里 dropEffect='move' 会被
|
|
3737
|
+
// 浏览器判成不可投放(拖过去直接显示禁止光标)。
|
|
3738
|
+
e.dataTransfer.effectAllowed = 'copyMove';
|
|
3739
|
+
libDragItemRef.current = { type, id: idOrType };
|
|
3740
|
+
}
|
|
3741
|
+
|
|
3742
|
+
// 把 action 定义挪到另一个画布的仓库:改 path 一处,下游全自动跟随——
|
|
3743
|
+
// 生成端 emitAction 按 path 决定落脚本级还是模块内,planAutoVars 按新 path
|
|
3744
|
+
// 重新规划变量声明;结构签名含 actionStore,run 守卫照常看见「图被修改」。
|
|
3745
|
+
// 名字全域唯一(ActionModal 以 allNames 查重),挪动不产生重名;引用它的
|
|
3746
|
+
// 节点 label 不动。挪进更深的模块而外部画布仍有引用时,断引用交给语法
|
|
3747
|
+
// 检查/编译器报错(报错纪律:能跑的挪法不拦,断引用不兜底)。
|
|
3748
|
+
function moveActionToCanvas(action, targetPath) {
|
|
3749
|
+
if (!action || !Array.isArray(targetPath) || !targetPath.length) return;
|
|
3750
|
+
const ap = action.path || ['mainflow'];
|
|
3751
|
+
const same =
|
|
3752
|
+
ap.length === targetPath.length && ap.every((s, i) => s === targetPath[i]);
|
|
3753
|
+
if (same) return; // 已住这个画布,原地不动
|
|
3754
|
+
setActionStore((prev) =>
|
|
3755
|
+
prev.map((a) => (a.id === action.id ? { ...a, path: [...targetPath] } : a))
|
|
3756
|
+
);
|
|
3757
|
+
const toName =
|
|
3758
|
+
targetPath.length === 1
|
|
3759
|
+
? '主流程'
|
|
3760
|
+
: `模块「${targetPath[targetPath.length - 1]}」`;
|
|
3761
|
+
showExportToast(`✓ 已把「${action.name}」挪到 ${toName}的仓库`);
|
|
3762
|
+
}
|
|
3763
|
+
|
|
3764
|
+
// 面包屑芯片的投放接线(桌面 HTML5 拖放):只有 action 卡能挪仓库,
|
|
3765
|
+
// module/特殊节点/POSITION 卡不接(dragover 不 preventDefault=浏览器
|
|
3766
|
+
// 原生禁止光标,drop 也不会来)。拖着的 action 已住在目标画布时也不亮
|
|
3767
|
+
// 不接——放下本来就是原地不动。落账前以 dataTransfer 载荷为准再验一遍,
|
|
3768
|
+
// ref 只管悬停高亮与放行判断。
|
|
3769
|
+
function crumbDropProps(targetPath) {
|
|
3770
|
+
const key = targetPath.join('/');
|
|
3771
|
+
const wouldMove = () => {
|
|
3772
|
+
const item = libDragItemRef.current;
|
|
3773
|
+
if (item?.type !== 'action') return false;
|
|
3774
|
+
const action = actionStore.find((a) => a.id === item.id);
|
|
3775
|
+
if (!action) return false;
|
|
3776
|
+
const ap = action.path || ['mainflow'];
|
|
3777
|
+
return !(ap.length === targetPath.length && ap.every((s, i) => s === targetPath[i]));
|
|
3778
|
+
};
|
|
3779
|
+
return {
|
|
3780
|
+
onDragOver: (e) => {
|
|
3781
|
+
if (libDragItemRef.current?.type !== 'action') return;
|
|
3782
|
+
if (!wouldMove()) return;
|
|
3783
|
+
e.preventDefault();
|
|
3784
|
+
e.dataTransfer.dropEffect = 'move';
|
|
3785
|
+
setCrumbDropHover((prev) => (prev === key ? prev : key));
|
|
3786
|
+
},
|
|
3787
|
+
onDragLeave: () => {
|
|
3788
|
+
setCrumbDropHover((prev) => (prev === key ? null : prev));
|
|
3789
|
+
},
|
|
3790
|
+
onDrop: (e) => {
|
|
3791
|
+
e.preventDefault();
|
|
3792
|
+
e.stopPropagation();
|
|
3793
|
+
setCrumbDropHover(null);
|
|
3794
|
+
libDragItemRef.current = null;
|
|
3795
|
+
let data;
|
|
3796
|
+
try {
|
|
3797
|
+
data = JSON.parse(e.dataTransfer.getData('application/femo-item'));
|
|
3798
|
+
} catch {
|
|
3799
|
+
return;
|
|
3800
|
+
}
|
|
3801
|
+
if (data?.type !== 'action' || !data.id) return;
|
|
3802
|
+
const action = actionStore.find((a) => a.id === data.id);
|
|
3803
|
+
if (action) moveActionToCanvas(action, targetPath);
|
|
3804
|
+
},
|
|
3805
|
+
};
|
|
3192
3806
|
}
|
|
3193
3807
|
|
|
3194
3808
|
function handleCanvasDragOver(e) {
|
|
@@ -3244,24 +3858,29 @@ const submitHumanInput = useCallback(
|
|
|
3244
3858
|
}
|
|
3245
3859
|
|
|
3246
3860
|
// 导入(2026-09-11 改两级):一级=导入清单(导入过/导出过的 .femo 历史,
|
|
3247
|
-
//
|
|
3248
|
-
//
|
|
3249
|
-
//
|
|
3861
|
+
// 权威=公共层 femogen-files 账本),二级=系统文件对话框(电脑端)。
|
|
3862
|
+
// 手机端只有一级+目录浮层:系统对话框开在电脑屏幕上,手机上够不着。
|
|
3863
|
+
// 2026-09-30 起独立模式也进两级流程——账本是公共层单源,web 服务
|
|
3864
|
+
// /api/femo-files 直接喂同一本(插件模式仍走宿主回调,行为零变化)。
|
|
3250
3865
|
function handleToolbarImport() {
|
|
3251
|
-
if (plugin && typeof onListFemoFiles
|
|
3252
|
-
|
|
3253
|
-
setFemoFileError('');
|
|
3254
|
-
loadFemoFileList();
|
|
3866
|
+
if (plugin && typeof onListFemoFiles !== 'function') {
|
|
3867
|
+
handleBrowseImport(); // 插件模式却没接清单回调:维持旧直通(理论外形态)
|
|
3255
3868
|
return;
|
|
3256
3869
|
}
|
|
3257
|
-
|
|
3870
|
+
setFemoFileOpen(true);
|
|
3871
|
+
setFemoFileError('');
|
|
3872
|
+
loadFemoFileList();
|
|
3258
3873
|
}
|
|
3259
3874
|
|
|
3260
|
-
/** 拉清单数据(不动弹窗开关,也不清错误位——错误位由打开弹窗/成功动作管)。
|
|
3875
|
+
/** 拉清单数据(不动弹窗开关,也不清错误位——错误位由打开弹窗/成功动作管)。
|
|
3876
|
+
* 插件模式走宿主回调;独立模式打 web 服务(同一条公共层账本)。 */
|
|
3261
3877
|
function loadFemoFileList() {
|
|
3262
3878
|
setFemoFileLoading(true);
|
|
3879
|
+
const fetchList = (plugin && typeof onListFemoFiles === 'function')
|
|
3880
|
+
? onListFemoFiles()
|
|
3881
|
+
: apiPost('/api/femo-files', {}).then((d) => d.files ?? []);
|
|
3263
3882
|
return Promise.resolve()
|
|
3264
|
-
.then(() =>
|
|
3883
|
+
.then(() => fetchList)
|
|
3265
3884
|
.then(
|
|
3266
3885
|
(list) => { setFemoFileList(Array.isArray(list) ? list : []); },
|
|
3267
3886
|
(err) => {
|
|
@@ -3273,11 +3892,11 @@ const submitHumanInput = useCallback(
|
|
|
3273
3892
|
.finally(() => { setFemoFileLoading(false); });
|
|
3274
3893
|
}
|
|
3275
3894
|
|
|
3276
|
-
/**
|
|
3277
|
-
*
|
|
3895
|
+
/** 二级:系统文件选择器(电脑端专属)。插件模式走宿主 onImport;独立模式打
|
|
3896
|
+
* 服务端系统对话框(真路径入账本+path 槽)——2026-09-30 起不再用浏览器
|
|
3897
|
+
* file input(FileReader 拿不到路径,引用式导入必须由 host 侧选;浏览器
|
|
3898
|
+
* input 如今只剩 web 宿主自动挂载 ?mount=1 在用)。 */
|
|
3278
3899
|
function handleBrowseImport() {
|
|
3279
|
-
// 插件模式:host 弹系统文件选择器(引用原始位置,2026-08-30)→ 画布载入;
|
|
3280
|
-
// 独立模式:浏览器 file input + FileReader。
|
|
3281
3900
|
if (plugin && typeof onImport === 'function') {
|
|
3282
3901
|
onImport().then((picked) => {
|
|
3283
3902
|
if (picked === null) return; // 用户取消
|
|
@@ -3289,15 +3908,33 @@ const submitHumanInput = useCallback(
|
|
|
3289
3908
|
});
|
|
3290
3909
|
return;
|
|
3291
3910
|
}
|
|
3292
|
-
|
|
3911
|
+
apiPost('/api/pick-script', {})
|
|
3912
|
+
.then((d) => {
|
|
3913
|
+
if (d.path === null || d.path === undefined) return; // 用户取消
|
|
3914
|
+
setFemoFileOpen(false);
|
|
3915
|
+
setStandaloneSavedPath(d.path);
|
|
3916
|
+
applyFEMOText(d.content);
|
|
3917
|
+
})
|
|
3918
|
+
.catch((err) => {
|
|
3919
|
+
console.warn('[导入 .femo] 失败:', err);
|
|
3920
|
+
alert(String(err?.message ?? err));
|
|
3921
|
+
});
|
|
3293
3922
|
}
|
|
3294
3923
|
|
|
3295
|
-
/**
|
|
3296
|
-
*
|
|
3924
|
+
/** 从清单里挑一条:读盘取正文 → 载入画布。插件模式=宿主回调(宿主侧记账
|
|
3925
|
+
* +会话记录);独立模式=web 服务读盘(账本门禁+path 槽都在服务端完成)。
|
|
3926
|
+
* 两条入口落点一致:画布、editor 文本全部跟上。 */
|
|
3297
3927
|
function handlePickFromList(path) {
|
|
3298
|
-
if (typeof onPickFemoFile !== 'function') return;
|
|
3928
|
+
if (plugin && typeof onPickFemoFile !== 'function') return;
|
|
3299
3929
|
setFemoFileBusyPath(path);
|
|
3300
|
-
|
|
3930
|
+
Promise.resolve()
|
|
3931
|
+
.then(() => {
|
|
3932
|
+
if (plugin && typeof onPickFemoFile === 'function') return onPickFemoFile(path);
|
|
3933
|
+
return apiPost('/api/femo-files/open', { path }).then((d) => {
|
|
3934
|
+
setStandaloneSavedPath(d.path);
|
|
3935
|
+
return { path: d.path, content: d.content };
|
|
3936
|
+
});
|
|
3937
|
+
})
|
|
3301
3938
|
.then((picked) => {
|
|
3302
3939
|
setFemoFileOpen(false);
|
|
3303
3940
|
setFemoFileError('');
|
|
@@ -3313,14 +3950,17 @@ const submitHumanInput = useCallback(
|
|
|
3313
3950
|
}
|
|
3314
3951
|
|
|
3315
3952
|
// ── 移出清单(2026-09-13)──
|
|
3316
|
-
//
|
|
3317
|
-
//
|
|
3318
|
-
//
|
|
3953
|
+
// 只把这条记录从清单里划掉,**源文件零接触**(账本只删条目)。成功后本地
|
|
3954
|
+
// 同步剔除,不等重拉——清单是纯账本,本地删了服务端必然也删了;失败则亮
|
|
3955
|
+
// 错误条并重拉对账。插件/独立两模式同一个账本,只是走宿主回调还是直打服务。
|
|
3319
3956
|
function handleForgetFromList(path) {
|
|
3320
|
-
if (typeof onForgetFemoFile !== 'function'
|
|
3957
|
+
if (typeof onForgetFemoFile !== 'function' && plugin) return;
|
|
3958
|
+
if (femoFileForgetBusy) return;
|
|
3321
3959
|
setFemoFileForgetBusy(true);
|
|
3322
|
-
|
|
3323
|
-
.
|
|
3960
|
+
const forget = (plugin && typeof onForgetFemoFile === 'function')
|
|
3961
|
+
? Promise.resolve(onForgetFemoFile(path))
|
|
3962
|
+
: apiPost('/api/femo-files/forget', { path });
|
|
3963
|
+
forget
|
|
3324
3964
|
.then(() => {
|
|
3325
3965
|
setFemoFileError('');
|
|
3326
3966
|
setFemoFileList((list) => list.filter((f) => f.path !== path));
|
|
@@ -3333,13 +3973,82 @@ const submitHumanInput = useCallback(
|
|
|
3333
3973
|
.finally(() => { setFemoFileForgetBusy(false); });
|
|
3334
3974
|
}
|
|
3335
3975
|
|
|
3976
|
+
// ── 工程目录浮层的动作面(2026-09-30,手机端选路径的一腿;桌面导出走系统
|
|
3977
|
+
// 对话框)。数据面=/api/projects/*,服务端有 projects/ 围栏;save 键直接
|
|
3978
|
+
// 落盘(三态/账本/path 槽都在服务端一处管齐),open 模式=读盘入账。──
|
|
3979
|
+
function loadDirBrowse(dir) {
|
|
3980
|
+
setDirBrowseLoading(true);
|
|
3981
|
+
setDirBrowseError('');
|
|
3982
|
+
return apiPost('/api/projects/browser', { dir })
|
|
3983
|
+
.then((d) => {
|
|
3984
|
+
setDirBrowseDir(d.dir ?? '');
|
|
3985
|
+
setDirBrowseDirs(d.dirs ?? []);
|
|
3986
|
+
setDirBrowseFiles(d.files ?? []);
|
|
3987
|
+
})
|
|
3988
|
+
.catch((err) => {
|
|
3989
|
+
setDirBrowseError(String(err?.message ?? err));
|
|
3990
|
+
setDirBrowseDirs([]);
|
|
3991
|
+
setDirBrowseFiles([]);
|
|
3992
|
+
})
|
|
3993
|
+
.finally(() => setDirBrowseLoading(false));
|
|
3994
|
+
}
|
|
3995
|
+
function openDirBrowse(mode) {
|
|
3996
|
+
setDirBrowseMode(mode);
|
|
3997
|
+
setDirBrowseOpen(true);
|
|
3998
|
+
loadDirBrowse('');
|
|
3999
|
+
}
|
|
4000
|
+
function handleDirEnter(name) {
|
|
4001
|
+
loadDirBrowse(dirBrowseDir ? `${dirBrowseDir}/${name}` : name);
|
|
4002
|
+
}
|
|
4003
|
+
function handleDirUp() {
|
|
4004
|
+
const segs = dirBrowseDir.split('/').filter(Boolean);
|
|
4005
|
+
segs.pop();
|
|
4006
|
+
loadDirBrowse(segs.join('/'));
|
|
4007
|
+
}
|
|
4008
|
+
function handleDirMkdir(name) {
|
|
4009
|
+
setDirBrowseBusy(true);
|
|
4010
|
+
apiPost('/api/projects/mkdir', { dir: dirBrowseDir, name })
|
|
4011
|
+
.then((d) => loadDirBrowse(d.dir ?? dirBrowseDir))
|
|
4012
|
+
.catch((err) => setDirBrowseError(String(err?.message ?? err)))
|
|
4013
|
+
.finally(() => setDirBrowseBusy(false));
|
|
4014
|
+
}
|
|
4015
|
+
function handleDirOpenFile(name) {
|
|
4016
|
+
setDirBrowseBusy(true);
|
|
4017
|
+
apiPost('/api/projects/open', { dir: dirBrowseDir, name })
|
|
4018
|
+
.then((d) => {
|
|
4019
|
+
setDirBrowseOpen(false);
|
|
4020
|
+
setStandaloneSavedPath(d.path);
|
|
4021
|
+
applyFEMOText(d.content);
|
|
4022
|
+
})
|
|
4023
|
+
.catch((err) => setDirBrowseError(String(err?.message ?? err)))
|
|
4024
|
+
.finally(() => setDirBrowseBusy(false));
|
|
4025
|
+
}
|
|
4026
|
+
function handleDirSave(name) {
|
|
4027
|
+
setDirBrowseBusy(true);
|
|
4028
|
+
// 保存时现取画布文本(浮层开着时画布被遮住改不了,取当下总没错)
|
|
4029
|
+
apiPost('/api/save-script', { dir: dirBrowseDir, name, femo: handleGraphToFemo() })
|
|
4030
|
+
.then((d) => {
|
|
4031
|
+
setDirBrowseOpen(false);
|
|
4032
|
+
setStandaloneSavedPath(d.path);
|
|
4033
|
+
showExportToast(`✓ 已保存到 ${d.path}${d.changed === false ? '(内容与文件一致)' : (d.existed ? '(覆盖原文件)' : '')}`);
|
|
4034
|
+
})
|
|
4035
|
+
.catch((err) => setDirBrowseError(String(err?.message ?? err)))
|
|
4036
|
+
.finally(() => setDirBrowseBusy(false));
|
|
4037
|
+
}
|
|
4038
|
+
/** 「未改动」提醒三选——resolve 回 handleToolbarExport 的挂起点。 */
|
|
4039
|
+
function resolveSaveReminder(choice) {
|
|
4040
|
+
const r = saveReminder;
|
|
4041
|
+
setSaveReminder(null);
|
|
4042
|
+
r?.resolve?.(choice);
|
|
4043
|
+
}
|
|
4044
|
+
|
|
3336
4045
|
async function handleToolbarExport() {
|
|
3337
4046
|
if (exportBusy) return;
|
|
3338
4047
|
console.log('[导出 .femo] 开始即时生成');
|
|
3339
4048
|
const exportText = handleGraphToFemo();
|
|
3340
4049
|
console.log('[导出 .femo] 生成完成, 长度:', exportText.length);
|
|
3341
4050
|
if (plugin && typeof onExport === 'function') {
|
|
3342
|
-
//
|
|
4051
|
+
// 插件模式:三态行为在宿主 editor-page(系统对话框+会话记录),画布零感知。
|
|
3343
4052
|
setExportBusy(true);
|
|
3344
4053
|
try {
|
|
3345
4054
|
const path = await onExport(exportText, proj.name || 'flow');
|
|
@@ -3356,18 +4065,65 @@ const submitHumanInput = useCallback(
|
|
|
3356
4065
|
}
|
|
3357
4066
|
return;
|
|
3358
4067
|
}
|
|
3359
|
-
//
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
4068
|
+
// 独立模式三态(2026-09-30,与 dsh 同语义;落盘/账本/path 槽都在服务端):
|
|
4069
|
+
// 有 path → 直存(与盘上一致先提醒);无 path → 首存(桌面=系统对话框、
|
|
4070
|
+
// 手机=工程目录浮层)。
|
|
4071
|
+
setExportBusy(true);
|
|
4072
|
+
try {
|
|
4073
|
+
if (standaloneSavedPath) {
|
|
4074
|
+
const d = await apiPost('/api/save-script', { path: standaloneSavedPath, femo: exportText });
|
|
4075
|
+
if (d.changed === false) {
|
|
4076
|
+
const choice = await new Promise((resolve) => setSaveReminder({ path: d.path, resolve }));
|
|
4077
|
+
if (choice === 'back') return; // 返回画布:静默(与 dsh「返回编辑画布」同口径)
|
|
4078
|
+
if (choice === 'save') {
|
|
4079
|
+
const d2 = await apiPost('/api/save-script', { path: d.path, femo: exportText, force: true });
|
|
4080
|
+
setStandaloneSavedPath(d2.path);
|
|
4081
|
+
showExportToast(`✓ 已保存到 ${d2.path}`);
|
|
4082
|
+
} else {
|
|
4083
|
+
await startSaveAs(exportText); // 另存为:换地址,记录跟过去
|
|
4084
|
+
}
|
|
4085
|
+
} else {
|
|
4086
|
+
setStandaloneSavedPath(d.path);
|
|
4087
|
+
showExportToast(`✓ 已保存到 ${d.path}`);
|
|
4088
|
+
}
|
|
4089
|
+
} else {
|
|
4090
|
+
await startSaveAs(exportText);
|
|
4091
|
+
}
|
|
4092
|
+
} catch (err) {
|
|
4093
|
+
console.warn('[导出 .femo] 保存失败:', err);
|
|
4094
|
+
alert(String(err?.message ?? err));
|
|
4095
|
+
} finally {
|
|
4096
|
+
setExportBusy(false);
|
|
4097
|
+
}
|
|
3369
4098
|
}
|
|
3370
4099
|
|
|
4100
|
+
/** 首存/另存为的选位置(独立模式):桌面弹服务端系统保存对话框(起始目录
|
|
4101
|
+
* =projects/,取消静默——与 dsh 同口径);手机开工程目录浮层,保存键走
|
|
4102
|
+
* handleDirSave 接手(开层即返回,exportBusy 已在 finally 里松开)。 */
|
|
4103
|
+
async function startSaveAs(exportText) {
|
|
4104
|
+
if (isMobile) {
|
|
4105
|
+
openDirBrowse('save');
|
|
4106
|
+
return;
|
|
4107
|
+
}
|
|
4108
|
+
const safe = (proj.name || 'flow').replace(/[\\/:*?"<>|]/g, '_');
|
|
4109
|
+
const d = await apiPost('/api/pick-save-path', { name: safe });
|
|
4110
|
+
if (d.path === null || d.path === undefined) return; // 用户取消:静默
|
|
4111
|
+
const d2 = await apiPost('/api/save-script', { path: d.path, femo: exportText });
|
|
4112
|
+
setStandaloneSavedPath(d2.path);
|
|
4113
|
+
showExportToast(`✓ 已保存到 ${d2.path}`);
|
|
4114
|
+
}
|
|
4115
|
+
|
|
4116
|
+
// ── 旧「浏览器 Blob 下载」路径(已退役,观察期 2026-09-30,连块删除)──
|
|
4117
|
+
// 独立模式导出改走服务端存盘三态(上文),下载不再可达;若观察期后无回退
|
|
4118
|
+
// 诉求,连同本注释一起删。
|
|
4119
|
+
// const blob = new Blob([exportText], { type: 'text/plain' });
|
|
4120
|
+
// const a = document.createElement('a');
|
|
4121
|
+
// a.href = URL.createObjectURL(blob);
|
|
4122
|
+
// a.download = `${proj.name || 'flow'}.femo`;
|
|
4123
|
+
// a.click();
|
|
4124
|
+
// console.log('[导出 .femo] 下载已触发');
|
|
4125
|
+
// showExportToast(`✓ 已开始下载 ${proj.name || 'flow'}.femo`);
|
|
4126
|
+
|
|
3371
4127
|
// Apply FEMO text (from preview or import)
|
|
3372
4128
|
function applyFEMOText(text) {
|
|
3373
4129
|
console.log('1. 开始解析');
|
|
@@ -3446,7 +4202,7 @@ const submitHumanInput = useCallback(
|
|
|
3446
4202
|
setLastValidFemo(text);
|
|
3447
4203
|
setSel(null);
|
|
3448
4204
|
// 建立结构基线:此刻画布与原文一致,之后的结构性变化才计为「图被修改」。
|
|
3449
|
-
lastSyncedGraphRef.current = structuralSignature(newNodes, newEdges);
|
|
4205
|
+
lastSyncedGraphRef.current = structuralSignature(newNodes, newEdges, libActions);
|
|
3450
4206
|
console.log('7. 全部完成');
|
|
3451
4207
|
}
|
|
3452
4208
|
|
|
@@ -3515,7 +4271,7 @@ const submitHumanInput = useCallback(
|
|
|
3515
4271
|
setFEMOrnings([]);
|
|
3516
4272
|
setFemoDirty(false);
|
|
3517
4273
|
setGraphDirty(false);
|
|
3518
|
-
lastSyncedGraphRef.current = structuralSignature(nodes, edges);
|
|
4274
|
+
lastSyncedGraphRef.current = structuralSignature(nodes, edges, actionStore);
|
|
3519
4275
|
// 链路②:把生成文本写入会话 record(带 baseRev,冲突走 409 弹窗)。
|
|
3520
4276
|
if (typeof onPersistScript === 'function') onPersistScript(out);
|
|
3521
4277
|
}
|
|
@@ -3651,13 +4407,37 @@ const selNode = sel?.type === 'node' ? nm.get(sel.id) : null;
|
|
|
3651
4407
|
setModal({ type: 'editNode', action: selAction, nodeId: selNode.id });
|
|
3652
4408
|
};
|
|
3653
4409
|
|
|
4410
|
+
// 【刀2】视图登记制当前条目(activeViewId='job:<N>' → 登记表行);观演
|
|
4411
|
+
// 覆盖层在桌面 CENTER 与手机树各挂一份,编辑现场原封不动地垫在下面。
|
|
4412
|
+
const activeWatchView = activeViewId !== 'edit'
|
|
4413
|
+
? watchViews[Number(String(activeViewId).slice(4))]
|
|
4414
|
+
: null;
|
|
4415
|
+
// 【下拉版(2026-10-05 用户拍板提前落刀6 菜单)】视图清单:正在编辑 + 各场
|
|
4416
|
+
// 观演(新场次在前);切到「编辑」=退出观演(该场不再自动抢屏,新场例外)。
|
|
4417
|
+
const switcherViews = [
|
|
4418
|
+
{ id: 'edit', label: '正在编辑(未跑的稿)', status: null },
|
|
4419
|
+
...Object.keys(watchViews).map(Number).sort((a, b) => b - a)
|
|
4420
|
+
.map((jid) => ({ id: `job:${jid}`, label: `Job ${jid}${watchViews[jid].meta?.scriptName ? ` · ${watchViews[jid].meta.scriptName}` : ''}`, status: watchViews[jid].mirror?.status || 'idle' })),
|
|
4421
|
+
];
|
|
4422
|
+
function handleSwitchView(id) {
|
|
4423
|
+
if (id === 'edit') {
|
|
4424
|
+
watchExitedRef.current = watchJobRef.current;
|
|
4425
|
+
setActiveViewId('edit');
|
|
4426
|
+
return;
|
|
4427
|
+
}
|
|
4428
|
+
watchExitedRef.current = null;
|
|
4429
|
+
setActiveViewId(id);
|
|
4430
|
+
}
|
|
4431
|
+
|
|
3654
4432
|
if (isMobile) {
|
|
3655
4433
|
// 窄视口(手机/平板竖屏):提供移动端布局。
|
|
3656
4434
|
// 插件模式同样支持——手机通过 tailscale 访问 dsh 时自动呈现手机版。
|
|
3657
4435
|
return (
|
|
3658
4436
|
<ErrorBoundary>
|
|
3659
4437
|
<FontStyle scoped={plugin} />
|
|
3660
|
-
{/*
|
|
4438
|
+
{/* 隐藏 file input——如今只剩 web 宿主自动挂载(?mount=1 的播种脚本按
|
|
4439
|
+
`input[type=file][accept=".femo"]` 唯一选择器找它注入)在用;人工
|
|
4440
|
+
导入 2026-09-30 起走系统对话框/目录浮层(FileReader 拿不到路径)。
|
|
3661
4441
|
桌面工具栏那份在手机端不渲染,故此处补一份——与桌面共用同一个
|
|
3662
4442
|
fileInputRef / handleImportFile,两条分支互斥挂载不冲突。 */}
|
|
3663
4443
|
<input
|
|
@@ -3672,7 +4452,7 @@ const selNode = sel?.type === 'node' ? nm.get(sel.id) : null;
|
|
|
3672
4452
|
<div style={{ position: 'fixed', inset: 0, zIndex: 1000, background: 'rgba(0,0,0,0.35)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
3673
4453
|
<div style={{
|
|
3674
4454
|
maxWidth: 430, width: 'calc(100% - 48px)', padding: '18px 20px', borderRadius: 12,
|
|
3675
|
-
background: 'var(--femo-
|
|
4455
|
+
background: 'var(--femo-modal-bg, #fff)', border: '1px solid var(--femo-border, #e0e0e0)',
|
|
3676
4456
|
boxShadow: '0 8px 28px rgba(0,0,0,0.22)', fontSize: 13, lineHeight: 1.6,
|
|
3677
4457
|
}}>
|
|
3678
4458
|
<div style={{ fontWeight: 700, marginBottom: 6 }}>⚠️ 有未落盘修改</div>
|
|
@@ -3737,6 +4517,7 @@ nodes={nodes}
|
|
|
3737
4517
|
handlePortUp={handlePortUp}
|
|
3738
4518
|
handleCanvasDragOver={handleCanvasDragOver}
|
|
3739
4519
|
handleCanvasDrop={handleCanvasDrop}
|
|
4520
|
+
setGuides={updateGuides}
|
|
3740
4521
|
canvasOpacity={canvasOpacity}
|
|
3741
4522
|
canvasContent={
|
|
3742
4523
|
<>
|
|
@@ -3824,6 +4605,7 @@ nodes={nodes}
|
|
|
3824
4605
|
})}
|
|
3825
4606
|
{conn && (() => { const d = getTempConnLine(); return d ? <path d={d} fill="none" stroke="var(--femo-primary)" strokeWidth={2} strokeDasharray="6,3" style={{pointerEvents:'none'}} /> : null; })()}
|
|
3826
4607
|
</svg>
|
|
4608
|
+
<SnapGuides guides={snapGuides} scale={scale} />
|
|
3827
4609
|
{nodes.map((n) => {
|
|
3828
4610
|
const enrichedNode = n.type === 'action' ? { ...n, action: actionMap.get(n.actionId) } : n;
|
|
3829
4611
|
const commonProps = {
|
|
@@ -3834,7 +4616,7 @@ nodes={nodes}
|
|
|
3834
4616
|
setSel({ type: 'node', id: enrichedNode.id });
|
|
3835
4617
|
setDrag({ id: enrichedNode.id, sx: e.clientX, sy: e.clientY, ox: enrichedNode.x, oy: enrichedNode.y });
|
|
3836
4618
|
},
|
|
3837
|
-
onPortDown: (e, dir) => handlePortDown(e, enrichedNode.id, dir),
|
|
4619
|
+
onPortDown: (e, dir, x, y) => handlePortDown(e, enrichedNode.id, dir, x, y),
|
|
3838
4620
|
onPortUp: (e, dir) => handlePortUp(e, enrichedNode.id, dir),
|
|
3839
4621
|
onBodyMouseUp: (e) => handleBodyMouseUp(e, enrichedNode.id),
|
|
3840
4622
|
};
|
|
@@ -3843,9 +4625,9 @@ nodes={nodes}
|
|
|
3843
4625
|
const motherNode = enrichedNode.forNodeId ? nm.get(enrichedNode.forNodeId) : null;
|
|
3844
4626
|
return <ForOutNodeView key={enrichedNode.id} node={enrichedNode} sel={sel?.type==='node'&&sel.id===enrichedNode.id} forSpecialType={motherNode?.specialType||'FOR'} onBodyMouseUp={(e) => handleBodyMouseUp(e, enrichedNode.id)} onBubbleClick={(nid) => { setDrag(null); setConn(null); setIsPanning(false); setSel({ type: 'node', id: nid }); }} onPortDown={(e, dir, x, y) => handlePortDown(e, enrichedNode.id, dir, x, y)} onPortUp={(e, dir) => handlePortUp(e, enrichedNode.id, dir)} />;
|
|
3845
4627
|
}
|
|
3846
|
-
if (enrichedNode.type === 'par_out') return <ParOutNodeView key={enrichedNode.id} node={enrichedNode} sel={sel?.type==='node'&&sel.id===enrichedNode.id} onBody={(e) => { e.stopPropagation(); if (drag||isPanning||conn){setDrag(null);setIsPanning(false);setConn(null);return;} setSel({type:'node',id:enrichedNode.id}); setDrag({id:enrichedNode.id,sx:e.clientX,sy:e.clientY,ox:enrichedNode.x,oy:enrichedNode.y}); }} onPortDown={(e, dir) => handlePortDown(e, enrichedNode.id, dir)} onPortUp={(e, dir) => handlePortUp(e, enrichedNode.id, dir)} onBodyMouseUp={(e) => handleBodyMouseUp(e, enrichedNode.id)} />;
|
|
4628
|
+
if (enrichedNode.type === 'par_out') return <ParOutNodeView key={enrichedNode.id} node={enrichedNode} sel={sel?.type==='node'&&sel.id===enrichedNode.id} onBody={(e) => { e.stopPropagation(); if (drag||isPanning||conn){setDrag(null);setIsPanning(false);setConn(null);return;} setSel({type:'node',id:enrichedNode.id}); setDrag({id:enrichedNode.id,sx:e.clientX,sy:e.clientY,ox:enrichedNode.x,oy:enrichedNode.y}); }} onPortDown={(e, dir, x, y) => handlePortDown(e, enrichedNode.id, dir, x, y)} onPortUp={(e, dir) => handlePortUp(e, enrichedNode.id, dir)} onBodyMouseUp={(e) => handleBodyMouseUp(e, enrichedNode.id)} />;
|
|
3847
4629
|
if (enrichedNode.type === 'position') return <PositionNodeView key={enrichedNode.id} node={enrichedNode} {...commonProps} />;
|
|
3848
|
-
return <ActionNodeView key={enrichedNode.id} node={enrichedNode} {...commonProps} onBubbleClick={handleBubbleClick} nodeState={nodeStates[enrichedNode.id]} isActive={activeNodeIds.has(enrichedNode.id)} errorNodeIds={errorNodeIds} onDbl={() => { if (enrichedNode.type==='action'&&enrichedNode.action) setModal({type:'editNode',action:enrichedNode.action,nodeId:enrichedNode.id}); else if (enrichedNode.type==='module') { const mod=enrichedNode.modDef; if(mod) editModule(mod); } }} />;
|
|
4630
|
+
return <ActionNodeView key={enrichedNode.id} node={enrichedNode} {...commonProps} onBubbleClick={handleBubbleClick} onActionPatch={patchAction} nodeState={nodeStates[enrichedNode.id]} isActive={activeNodeIds.has(enrichedNode.id)} errorNodeIds={errorNodeIds} onDbl={() => { if (enrichedNode.type==='action'&&enrichedNode.action) setModal({type:'editNode',action:enrichedNode.action,nodeId:enrichedNode.id}); else if (enrichedNode.type==='module') { const mod=enrichedNode.modDef; if(mod) editModule(mod); } }} />;
|
|
3849
4631
|
})}
|
|
3850
4632
|
</>
|
|
3851
4633
|
}
|
|
@@ -3868,6 +4650,7 @@ nodes={nodes}
|
|
|
3868
4650
|
}}
|
|
3869
4651
|
onNavigatePath={(path) => { saveCurrentFlow(); setLocationPath(path); }}
|
|
3870
4652
|
onEnterModuleNode={(nodeId) => { const mod = nm.get(nodeId)?.modDef; if (mod) editModule(mod); }}
|
|
4653
|
+
onMoveLibAction={moveActionToCanvas}
|
|
3871
4654
|
onDragStart={handleLibDragStart}
|
|
3872
4655
|
onSelectLib={handleSelectLib}
|
|
3873
4656
|
onNewModule={(name) => {
|
|
@@ -3958,6 +4741,8 @@ nodes={nodes}
|
|
|
3958
4741
|
/>
|
|
3959
4742
|
{/* 导入清单(第一级,2026-09-11):**特意不传 onBrowse**——手机端的
|
|
3960
4743
|
系统文件对话框开在电脑屏幕上,按了也够不着,留着只会让人以为按坏了。
|
|
4744
|
+
2026-09-30 起传 onBrowseDir:手机端自己的一腿=工程目录浮层(服务端
|
|
4745
|
+
projects/ 围栏内浏览/打开)。
|
|
3961
4746
|
挂在这里而不是 MobileLayout 内部:zIndex 9999 的 fixed 浮层盖住
|
|
3962
4747
|
移动端布局(900)与运行守卫(1000)即可,无需穿参数。 */}
|
|
3963
4748
|
<FemoFileList
|
|
@@ -3967,9 +4752,61 @@ nodes={nodes}
|
|
|
3967
4752
|
error={femoFileError}
|
|
3968
4753
|
busyPath={femoFileBusyPath}
|
|
3969
4754
|
onPick={handlePickFromList}
|
|
3970
|
-
onForget={
|
|
4755
|
+
onForget={handleForgetFromList}
|
|
4756
|
+
onBrowseDir={plugin ? undefined : () => openDirBrowse('open')}
|
|
3971
4757
|
onClose={() => setFemoFileOpen(false)}
|
|
3972
4758
|
/>
|
|
4759
|
+
<FemoDirBrowse
|
|
4760
|
+
open={dirBrowseOpen}
|
|
4761
|
+
mode={dirBrowseMode}
|
|
4762
|
+
dir={dirBrowseDir}
|
|
4763
|
+
dirs={dirBrowseDirs}
|
|
4764
|
+
files={dirBrowseFiles}
|
|
4765
|
+
loading={dirBrowseLoading}
|
|
4766
|
+
error={dirBrowseError}
|
|
4767
|
+
busy={dirBrowseBusy}
|
|
4768
|
+
defaultName={proj.name || 'flow'}
|
|
4769
|
+
onEnterDir={handleDirEnter}
|
|
4770
|
+
onUpDir={handleDirUp}
|
|
4771
|
+
onCreateFolder={handleDirMkdir}
|
|
4772
|
+
onOpenFile={handleDirOpenFile}
|
|
4773
|
+
onSave={handleDirSave}
|
|
4774
|
+
onClose={() => setDirBrowseOpen(false)}
|
|
4775
|
+
/>
|
|
4776
|
+
<FemoSaveReminder reminder={saveReminder} onChoice={resolveSaveReminder} />
|
|
4777
|
+
{/* 【刀2·下拉版】观演视图(手机端):portal 到 body 顶层(z 3000)——
|
|
4778
|
+
dsh 聊天窗等 embedding 的层叠怪癖一概逃掉(用户实测旧 absolute/fixed
|
|
4779
|
+
被宿主皮顶穿);编辑现场零触碰,退出即原样回来。 */}
|
|
4780
|
+
{activeWatchView && createPortal(
|
|
4781
|
+
<WatchView
|
|
4782
|
+
jobId={activeWatchView.jobId}
|
|
4783
|
+
meta={activeWatchView.meta}
|
|
4784
|
+
graph={activeWatchView.graph}
|
|
4785
|
+
mirror={activeWatchView.mirror}
|
|
4786
|
+
transport={engineTransport}
|
|
4787
|
+
fixed
|
|
4788
|
+
onExit={() => { watchExitedRef.current = activeWatchView.jobId; setActiveViewId('edit'); }}
|
|
4789
|
+
views={switcherViews}
|
|
4790
|
+
currentId={activeViewId}
|
|
4791
|
+
onSwitch={handleSwitchView}
|
|
4792
|
+
theme={theme}
|
|
4793
|
+
/>,
|
|
4794
|
+
document.body,
|
|
4795
|
+
)}
|
|
4796
|
+
{/* 【刀2·下拉版】编辑态的观演入口(手机端):浮游芯片(portal 顶层),
|
|
4797
|
+
点开下拉选场——标题栏是宿主/布局的,不往里塞东西。 */}
|
|
4798
|
+
{!activeWatchView && switcherViews.length > 1 && createPortal(
|
|
4799
|
+
<div
|
|
4800
|
+
data-femo-theme={theme}
|
|
4801
|
+
style={{ position: 'fixed', left: 10, bottom: 14, zIndex: 3000 }}
|
|
4802
|
+
>
|
|
4803
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 6, padding: '5px 8px', borderRadius: 999, background: 'var(--femo-panel-bg, #fff)', border: '1px solid var(--femo-border-strong, #ccc)', boxShadow: '0 4px 14px rgba(0,0,0,0.18)' }}>
|
|
4804
|
+
<span style={{ width: 8, height: 8, borderRadius: 99, flexShrink: 0, background: 'var(--femo-warning, #d99a2b)' }} />
|
|
4805
|
+
<ViewSwitcher views={switcherViews} currentId="edit" onSelect={handleSwitchView} fontSize={11.5} />
|
|
4806
|
+
</div>
|
|
4807
|
+
</div>,
|
|
4808
|
+
document.body,
|
|
4809
|
+
)}
|
|
3973
4810
|
</ErrorBoundary>
|
|
3974
4811
|
);
|
|
3975
4812
|
}
|
|
@@ -4027,7 +4864,7 @@ nodes={nodes}
|
|
|
4027
4864
|
letterSpacing: '-0.03em',
|
|
4028
4865
|
}}
|
|
4029
4866
|
>
|
|
4030
|
-
<span style={{ color: 'var(--femo-primary)' }}>FEMO</span>
|
|
4867
|
+
<span style={{ color: 'var(--femo-primary)' }}>FEMO</span> Generator
|
|
4031
4868
|
</div>
|
|
4032
4869
|
<div
|
|
4033
4870
|
style={{
|
|
@@ -4037,7 +4874,7 @@ nodes={nodes}
|
|
|
4037
4874
|
letterSpacing: '0.01em',
|
|
4038
4875
|
}}
|
|
4039
4876
|
>
|
|
4040
|
-
Flow
|
|
4877
|
+
Flow Emerges Mag Opus.
|
|
4041
4878
|
</div>
|
|
4042
4879
|
</div>
|
|
4043
4880
|
|
|
@@ -4175,7 +5012,8 @@ nodes={nodes}
|
|
|
4175
5012
|
}}>
|
|
4176
5013
|
{/* 底部三键(2026-09-08):与手机端设置三键同套配方——等宽 flex:1 1 0 +
|
|
4177
5014
|
FA 图标(FaPalette 主题 / FaUserPlus 新建SOUL / FaTerminal 调试)+
|
|
4178
|
-
minHeight 30
|
|
5015
|
+
minHeight 30 芯片家族高度;2026-09-29 文字去掉改纯图标,
|
|
5016
|
+
语义靠 title 悬停提示交代。桌面端有指针,反馈走
|
|
4179
5017
|
hover 提亮 + 按压回缩(.femo-setting-btn,FontStyle 全局块)。
|
|
4180
5018
|
顺序与手机端对齐:主题 → 新建 SOUL → 调试。红点内移防裁剪。 */}
|
|
4181
5019
|
<button
|
|
@@ -4197,9 +5035,6 @@ nodes={nodes}
|
|
|
4197
5035
|
}}
|
|
4198
5036
|
>
|
|
4199
5037
|
<FaPalette size={12} style={{ flexShrink: 0 }} />
|
|
4200
|
-
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis', minWidth: 0 }}>
|
|
4201
|
-
{FEMO_THEMES.find((t) => t.id === themeSel)?.name || themeSel}
|
|
4202
|
-
</span>
|
|
4203
5038
|
</button>
|
|
4204
5039
|
<button
|
|
4205
5040
|
onClick={() => { setSoulForm({ soul_id: '', soul_name: '', description: '' }); setSoulFormError(''); setSoulModalOpen(true); }}
|
|
@@ -4220,7 +5055,6 @@ nodes={nodes}
|
|
|
4220
5055
|
}}
|
|
4221
5056
|
>
|
|
4222
5057
|
<FaUserPlus size={12} style={{ flexShrink: 0 }} />
|
|
4223
|
-
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis', minWidth: 0 }}>新建 SOUL</span>
|
|
4224
5058
|
</button>
|
|
4225
5059
|
<button
|
|
4226
5060
|
onClick={() => setDebugOpen(true)}
|
|
@@ -4242,7 +5076,6 @@ nodes={nodes}
|
|
|
4242
5076
|
}}
|
|
4243
5077
|
>
|
|
4244
5078
|
<FaTerminal size={12} style={{ flexShrink: 0 }} />
|
|
4245
|
-
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis', minWidth: 0 }}>调试</span>
|
|
4246
5079
|
{debugLog.some((e) => e.level === 'error') && (
|
|
4247
5080
|
<span
|
|
4248
5081
|
style={{
|
|
@@ -4285,9 +5118,49 @@ nodes={nodes}
|
|
|
4285
5118
|
display: 'flex',
|
|
4286
5119
|
flexDirection: 'column',
|
|
4287
5120
|
minWidth: 0,
|
|
5121
|
+
position: 'relative', // 【刀2】观演覆盖层的定位锚
|
|
4288
5122
|
}}
|
|
4289
5123
|
>
|
|
4290
|
-
{/*
|
|
5124
|
+
{/* 【刀2→下拉版】视图切换条(编辑态):有观演条目且不在观演时,顶端
|
|
5125
|
+
常驻一条切换器——点开下拉选「正在编辑 / 各场戏」(2026-10-05 用户
|
|
5126
|
+
拍板:显示互斥、选择性的显示;自动进入只在新场开演时)。 */}
|
|
5127
|
+
{activeViewId === 'edit' && switcherViews.length > 1 && (
|
|
5128
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '4px 14px', flexShrink: 0, borderBottom: '1px solid var(--femo-border)', background: 'var(--femo-warning-soft, rgba(217,154,43,0.12))' }}>
|
|
5129
|
+
<span style={{ width: 8, height: 8, borderRadius: 99, flexShrink: 0, background: 'var(--femo-warning, #d99a2b)' }} />
|
|
5130
|
+
<span style={{ fontSize: 11.5, color: 'var(--femo-text-2)' }}>
|
|
5131
|
+
{editMatchesJob ? '引擎有场次可看' : `引擎在跑 Job ${watchJobId}(与当前编辑稿不是同一版)`}——
|
|
5132
|
+
</span>
|
|
5133
|
+
<ViewSwitcher views={switcherViews} currentId="edit" onSelect={handleSwitchView} fontSize={11.5} />
|
|
5134
|
+
</div>
|
|
5135
|
+
)}
|
|
5136
|
+
{/* 【观演切换条·观演态同款(2026-10-08 用户拍板「header 别变」)】观演
|
|
5137
|
+
时这条也常驻:左侧黄点换绿点、文案换成观演知情(看的是哪场、与
|
|
5138
|
+
编辑稿是否同版),右侧同一个 ViewSwitcher 下拉——与编辑态唯一
|
|
5139
|
+
差异是文案,位置/形状/皮肤完全一致。 */}
|
|
5140
|
+
{activeViewId !== 'edit' && switcherViews.length > 1 && (() => {
|
|
5141
|
+
const watchedN = Number(String(activeViewId).slice(4));
|
|
5142
|
+
const watchedEntry = watchViews[watchedN];
|
|
5143
|
+
const wStatus = watchedEntry?.mirror?.status || 'idle';
|
|
5144
|
+
return (
|
|
5145
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '4px 14px', flexShrink: 0, borderBottom: '1px solid var(--femo-border)', background: 'var(--femo-warning-soft, rgba(217,154,43,0.12))' }}>
|
|
5146
|
+
<span style={{ width: 8, height: 8, borderRadius: 99, flexShrink: 0, background: STATUS_COLOR[wStatus] || STATUS_COLOR.idle }} title={`观演状态:${STATUS_TEXT[wStatus] || wStatus}`} />
|
|
5147
|
+
<span style={{ fontSize: 11.5, color: 'var(--femo-text-2)' }}>
|
|
5148
|
+
正在观看 Job {watchedN}{watchedEntry?.meta?.scriptName ? ` · ${watchedEntry.meta.scriptName}` : ''}
|
|
5149
|
+
(状态:{STATUS_TEXT[wStatus] || wStatus}
|
|
5150
|
+
{editMatchesJob ? ' · 与当前编辑稿同一版' : ' · 与当前编辑稿不是同一版'})——
|
|
5151
|
+
</span>
|
|
5152
|
+
<ViewSwitcher views={switcherViews} currentId={activeViewId} onSelect={handleSwitchView} fontSize={11.5} />
|
|
5153
|
+
</div>
|
|
5154
|
+
);
|
|
5155
|
+
})()}
|
|
5156
|
+
{/* 【刀2→原位版(2026-10-08 用户拍板「header 别变,只改画布内容」)】
|
|
5157
|
+
观演覆盖层退役——旧法 absolute 盖住整个 CENTER(连工具栏一起盖
|
|
5158
|
+
且自带一套观演 header),观演时 header 全乱、透明底让编辑画布
|
|
5159
|
+
透出来叠成两场。新法:观演内容只住画布那格(见下方 Canvas 容器
|
|
5160
|
+
处的三元渲染),编辑画布同拍收起——结构性杜绝两场叠画;工具栏
|
|
5161
|
+
恒在原位(运行/停止/打开/保存照常),观演时停止/继续的作用对象
|
|
5162
|
+
即当前观看的场。 */}
|
|
5163
|
+
{/* Toolbar(恒在——观演不隐藏,2026-10-08 拍板) */}
|
|
4291
5164
|
<div
|
|
4292
5165
|
style={{
|
|
4293
5166
|
height: 50,
|
|
@@ -4305,6 +5178,7 @@ nodes={nodes}
|
|
|
4305
5178
|
位置
|
|
4306
5179
|
</span>
|
|
4307
5180
|
<button
|
|
5181
|
+
{...crumbDropProps(['mainflow'])}
|
|
4308
5182
|
onClick={() => {
|
|
4309
5183
|
if (
|
|
4310
5184
|
locationPath.length !== 1 ||
|
|
@@ -4325,16 +5199,28 @@ nodes={nodes}
|
|
|
4325
5199
|
fontWeight: 700,
|
|
4326
5200
|
fontFamily: 'var(--femo-font-sans)',
|
|
4327
5201
|
border: `var(--femo-border-w-strong) solid ${
|
|
4328
|
-
|
|
5202
|
+
crumbDropHover === 'mainflow' || mode === 'mainflow'
|
|
5203
|
+
? 'var(--femo-primary)'
|
|
5204
|
+
: 'var(--femo-border-strong)'
|
|
4329
5205
|
}`,
|
|
4330
|
-
background:
|
|
4331
|
-
|
|
5206
|
+
background:
|
|
5207
|
+
crumbDropHover === 'mainflow' || mode === 'mainflow'
|
|
5208
|
+
? 'var(--femo-primary-soft-2)'
|
|
5209
|
+
: 'var(--femo-surface)',
|
|
5210
|
+
color:
|
|
5211
|
+
crumbDropHover === 'mainflow' || mode === 'mainflow'
|
|
5212
|
+
? 'var(--femo-primary)'
|
|
5213
|
+
: 'var(--femo-text-3)',
|
|
4332
5214
|
opacity: mode === 'mainflow' ? 0.7 : 1,
|
|
4333
5215
|
}}
|
|
4334
5216
|
>
|
|
4335
5217
|
主流程
|
|
4336
5218
|
</button>
|
|
4337
|
-
{locationPath.map((seg, idx) =>
|
|
5219
|
+
{locationPath.map((seg, idx) => {
|
|
5220
|
+
const segPath = locationPath.slice(0, idx + 1);
|
|
5221
|
+
const segKey = segPath.join('/');
|
|
5222
|
+
const crumbHot = crumbDropHover === segKey;
|
|
5223
|
+
return (
|
|
4338
5224
|
<React.Fragment key={idx}>
|
|
4339
5225
|
{idx > 0 && (
|
|
4340
5226
|
<span
|
|
@@ -4345,6 +5231,7 @@ nodes={nodes}
|
|
|
4345
5231
|
)}
|
|
4346
5232
|
{idx === 0 ? null : (
|
|
4347
5233
|
<button
|
|
5234
|
+
{...crumbDropProps(segPath)}
|
|
4348
5235
|
onClick={() => {
|
|
4349
5236
|
saveCurrentFlow();
|
|
4350
5237
|
const newPath = locationPath.slice(0, idx + 1);
|
|
@@ -4356,16 +5243,25 @@ nodes={nodes}
|
|
|
4356
5243
|
cursor: 'pointer',
|
|
4357
5244
|
fontSize: 12,
|
|
4358
5245
|
fontWeight: 700,
|
|
4359
|
-
border: `var(--femo-border-w-strong) solid
|
|
4360
|
-
|
|
4361
|
-
|
|
5246
|
+
border: `var(--femo-border-w-strong) solid ${
|
|
5247
|
+
crumbHot
|
|
5248
|
+
? 'var(--femo-primary)'
|
|
5249
|
+
: 'var(--femo-border-strong)'
|
|
5250
|
+
}`,
|
|
5251
|
+
background: crumbHot
|
|
5252
|
+
? 'var(--femo-primary-soft-2)'
|
|
5253
|
+
: 'var(--femo-surface)',
|
|
5254
|
+
color: crumbHot
|
|
5255
|
+
? 'var(--femo-primary)'
|
|
5256
|
+
: 'var(--femo-text-3)',
|
|
4362
5257
|
}}
|
|
4363
5258
|
>
|
|
4364
5259
|
{seg}
|
|
4365
5260
|
</button>
|
|
4366
5261
|
)}
|
|
4367
5262
|
</React.Fragment>
|
|
4368
|
-
|
|
5263
|
+
);
|
|
5264
|
+
})}
|
|
4369
5265
|
{mode === 'module' && (
|
|
4370
5266
|
<button
|
|
4371
5267
|
onClick={() => {
|
|
@@ -4412,7 +5308,9 @@ nodes={nodes}
|
|
|
4412
5308
|
</div>
|
|
4413
5309
|
)}
|
|
4414
5310
|
{/* 暂停反馈条(2026-09-07 静默吞错修复):error=请求失败(红);
|
|
4415
|
-
warning
|
|
5311
|
+
warning=受理未确认/幂等无操作(黄)。与 exportToast 同位——
|
|
5312
|
+
锚在工具栏右下方、保存按钮信息条的位置(2026-09-27 用户点名:
|
|
5313
|
+
原先上提 44px 会盖住运行/暂停等按钮,移下来让开按钮)。
|
|
4416
5314
|
8s 自动消失(showPauseNotice 统一管理)。 */}
|
|
4417
5315
|
{pauseNotice !== null && (
|
|
4418
5316
|
<div
|
|
@@ -4421,7 +5319,6 @@ nodes={nodes}
|
|
|
4421
5319
|
position: 'absolute',
|
|
4422
5320
|
top: 'calc(100% + 6px)',
|
|
4423
5321
|
right: 12,
|
|
4424
|
-
transform: 'translateY(-44px)',
|
|
4425
5322
|
zIndex: 91,
|
|
4426
5323
|
maxWidth: 'min(560px, 100%)',
|
|
4427
5324
|
padding: '7px 12px',
|
|
@@ -4444,16 +5341,35 @@ nodes={nodes}
|
|
|
4444
5341
|
钉死一个动作/一套样式/一句文案,从生到死不变;运行阶段只决定渲染
|
|
4445
5342
|
哪几枚(三枚与「导入/导出」同为 ToolChip 家族:同高度/内边距/圆角/
|
|
4446
5343
|
字号 + 各带一枚 FA 图标,只靠色调分语义):
|
|
4447
|
-
绿「运行」(FaPlay) = fresh_start(reset:true
|
|
4448
|
-
|
|
4449
|
-
用户点名 stop→pause
|
|
5344
|
+
绿「运行」(FaPlay) = fresh_start(reset:true 从头运行;未开跑与挂起态都出现)
|
|
5345
|
+
红「停止」(FaStop) = pause(running 与挂起态都出现;2026-09-12
|
|
5346
|
+
用户点名 stop→pause 全链路改名,2026-09-30 再点名改回「停止」+fa-stop
|
|
5347
|
+
方块——引擎语义不变,pause=suspended 挂起可续跑;
|
|
5348
|
+
2026-09-20 拍板挂起态也保留此键——前后端状态混乱时的强停入口,
|
|
5349
|
+
显式带 pluginJobId 走引擎档案裁决,重复按=幂等知情不误报)
|
|
4450
5350
|
琥珀「继续」(FaForward) = resume(从断点续跑;只在暂停之后的挂起态出现)
|
|
4451
5351
|
挂起态顺序=常驻的运行键在前、挂起专属的继续键在后。(引擎无独立
|
|
4452
5352
|
硬暂停语义——pause=suspended 可续跑)。状态实时化=run_state
|
|
4453
|
-
快照驱动。
|
|
5353
|
+
快照驱动。2026-09-24 用户点名暂停键全状态常驻(idle 也显示——
|
|
5354
|
+
没有可停执行体时按压=幂等知情回执,见 handlePauseWorkflow)。 */}
|
|
4454
5355
|
{(flowStatus === 'idle' || flowStatus === 'paused') && (
|
|
4455
5356
|
enginePending ? (
|
|
4456
|
-
|
|
5357
|
+
// 【2026-09-19 冷启动补拉】芯片可点:宿主自动 2s 轮询为主,
|
|
5358
|
+
// 这里给用户一个立即重探的抓手(点了重拉 session-state,
|
|
5359
|
+
// 引擎就绪即换回运行/继续键,不再永远卡在加载态)。
|
|
5360
|
+
<ToolChip
|
|
5361
|
+
icon={FaSpinner}
|
|
5362
|
+
tone="neutral"
|
|
5363
|
+
onClick={() => {
|
|
5364
|
+
if (typeof onEngineRetry === 'function') {
|
|
5365
|
+
pushDebug('info', '引擎', '手动重探引擎状态…');
|
|
5366
|
+
onEngineRetry();
|
|
5367
|
+
}
|
|
5368
|
+
}}
|
|
5369
|
+
title={typeof onEngineRetry === 'function'
|
|
5370
|
+
? '引擎冷启动中——就绪后自动恢复;点此立即重新探测'
|
|
5371
|
+
: '引擎冷启动中(bridge 未就绪)——就绪后即可启动运行'}
|
|
5372
|
+
>
|
|
4457
5373
|
引擎启动中…
|
|
4458
5374
|
</ToolChip>
|
|
4459
5375
|
) : (
|
|
@@ -4461,22 +5377,22 @@ nodes={nodes}
|
|
|
4461
5377
|
icon={FaPlay}
|
|
4462
5378
|
tone="success"
|
|
4463
5379
|
onClick={() => handleRunWorkflow(undefined, 'human', { reset: true })}
|
|
4464
|
-
title="
|
|
5380
|
+
title="从头运行整个FEMO脚本(fresh start;挂起的一次会自动存档)"
|
|
4465
5381
|
>
|
|
4466
5382
|
运行
|
|
4467
5383
|
</ToolChip>
|
|
4468
5384
|
)
|
|
4469
5385
|
)}
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
5386
|
+
{
|
|
5387
|
+
<ToolChip
|
|
5388
|
+
icon={FaStop}
|
|
5389
|
+
tone="danger"
|
|
5390
|
+
onClick={handlePauseWorkflow}
|
|
5391
|
+
title="停止(可续跑:断点保留,之后可点「继续」接着跑;挂起态重复按=幂等,状态混乱时可校正)"
|
|
5392
|
+
>
|
|
5393
|
+
停止
|
|
5394
|
+
</ToolChip>
|
|
5395
|
+
}
|
|
4480
5396
|
{flowStatus === 'paused' && (
|
|
4481
5397
|
<ToolChip
|
|
4482
5398
|
icon={FaForward}
|
|
@@ -4489,7 +5405,8 @@ nodes={nodes}
|
|
|
4489
5405
|
)}
|
|
4490
5406
|
{/* 文件读写(2026-09-11 用户点名调序:从运行控制左侧移到右侧,与手机端
|
|
4491
5407
|
标题栏同序;同日工具栏统一重造:与运行控制同款芯片、同带 FA 图标)。
|
|
4492
|
-
隐藏 file input
|
|
5408
|
+
隐藏 file input 只服务 web 自动挂载(人工导入走对话框/目录浮层);
|
|
5409
|
+
导出回执 toast 仍锚在工具栏右下方。 */}
|
|
4493
5410
|
<input
|
|
4494
5411
|
ref={fileInputRef}
|
|
4495
5412
|
type="file"
|
|
@@ -4501,25 +5418,42 @@ nodes={nodes}
|
|
|
4501
5418
|
icon={FaFolderOpen}
|
|
4502
5419
|
tone="neutral"
|
|
4503
5420
|
onClick={handleToolbarImport}
|
|
4504
|
-
title="
|
|
5421
|
+
title="打开 .femo(选择本地脚本文件)"
|
|
4505
5422
|
>
|
|
4506
|
-
|
|
5423
|
+
打开
|
|
4507
5424
|
</ToolChip>
|
|
4508
5425
|
<ToolChip
|
|
4509
5426
|
icon={FaFloppyDisk}
|
|
4510
5427
|
tone="neutral"
|
|
4511
5428
|
onClick={handleToolbarExport}
|
|
4512
5429
|
disabled={exportBusy}
|
|
4513
|
-
title={exportBusy ? '保存中…' : '
|
|
5430
|
+
title={exportBusy ? '保存中…' : '保存 .femo(把当前FEMO脚本保存到本地)'}
|
|
4514
5431
|
>
|
|
4515
|
-
{exportBusy ? '保存中…' : '
|
|
5432
|
+
{exportBusy ? '保存中…' : '保存'}
|
|
4516
5433
|
</ToolChip>
|
|
4517
5434
|
{/* 编译(零 token 干跑)入口 2026-09-08 迁入调试窗头部——
|
|
4518
5435
|
工具栏位置退役:编译的日志就显示在调试窗,按钮放窗里语义更顺,
|
|
4519
5436
|
工具栏只保留运行控制与文件读写。 */}
|
|
4520
5437
|
</div>
|
|
4521
5438
|
|
|
4522
|
-
{/* Canvas
|
|
5439
|
+
{/* Canvas(观演原位版:观演时编辑画布收起、观演画布顶上——同一格
|
|
5440
|
+
互斥渲染,绝不叠画。观演头不再单独占一条:场号/状态/通路知情
|
|
5441
|
+
由上方观演切换条交代,观演画布整体就是编辑画布的同格替身) */}
|
|
5442
|
+
{activeWatchView ? (
|
|
5443
|
+
<div style={{ flex: 1, position: 'relative', overflow: 'hidden', background: 'var(--femo-bg)' }}>
|
|
5444
|
+
<WatchView
|
|
5445
|
+
jobId={activeWatchView.jobId}
|
|
5446
|
+
meta={activeWatchView.meta}
|
|
5447
|
+
graph={activeWatchView.graph}
|
|
5448
|
+
mirror={activeWatchView.mirror}
|
|
5449
|
+
transport={engineTransport}
|
|
5450
|
+
embedded
|
|
5451
|
+
onExit={() => { watchExitedRef.current = activeWatchView.jobId; setActiveViewId('edit'); }}
|
|
5452
|
+
onToggleDebug={() => setDebugOpen(true)}
|
|
5453
|
+
theme={theme}
|
|
5454
|
+
/>
|
|
5455
|
+
</div>
|
|
5456
|
+
) : (
|
|
4523
5457
|
<div
|
|
4524
5458
|
ref={cvRef}
|
|
4525
5459
|
style={{
|
|
@@ -4779,6 +5713,7 @@ nodes={nodes}
|
|
|
4779
5713
|
) : null;
|
|
4780
5714
|
})()}
|
|
4781
5715
|
</svg>
|
|
5716
|
+
<SnapGuides guides={snapGuides} scale={scale * effectiveZoom(cvRef.current)} />
|
|
4782
5717
|
|
|
4783
5718
|
{/* Nodes */}
|
|
4784
5719
|
{nodes.map((n) => {
|
|
@@ -4805,7 +5740,7 @@ nodes={nodes}
|
|
|
4805
5740
|
oy: enrichedNode.y,
|
|
4806
5741
|
});
|
|
4807
5742
|
},
|
|
4808
|
-
onPortDown: (e, dir) => handlePortDown(e, enrichedNode.id, dir),
|
|
5743
|
+
onPortDown: (e, dir, x, y) => handlePortDown(e, enrichedNode.id, dir, x, y),
|
|
4809
5744
|
onPortUp: (e, dir) => handlePortUp(e, enrichedNode.id, dir),
|
|
4810
5745
|
onBodyMouseUp: (e) => handleBodyMouseUp(e, enrichedNode.id),
|
|
4811
5746
|
};
|
|
@@ -4860,7 +5795,7 @@ if (enrichedNode.type === 'par_out') {
|
|
|
4860
5795
|
setSel({ type: 'node', id: enrichedNode.id });
|
|
4861
5796
|
setDrag({ id: enrichedNode.id, sx: e.clientX, sy: e.clientY, ox: enrichedNode.x, oy: enrichedNode.y });
|
|
4862
5797
|
}}
|
|
4863
|
-
onPortDown={(e, dir) => handlePortDown(e, enrichedNode.id, dir)}
|
|
5798
|
+
onPortDown={(e, dir, x, y) => handlePortDown(e, enrichedNode.id, dir, x, y)}
|
|
4864
5799
|
onPortUp={(e, dir) => handlePortUp(e, enrichedNode.id, dir)}
|
|
4865
5800
|
onBodyMouseUp={(e) => handleBodyMouseUp(e, enrichedNode.id)}
|
|
4866
5801
|
/>
|
|
@@ -4877,6 +5812,7 @@ if (enrichedNode.type === 'par_out') {
|
|
|
4877
5812
|
node={enrichedNode}
|
|
4878
5813
|
{...commonProps}
|
|
4879
5814
|
onBubbleClick={handleBubbleClick}
|
|
5815
|
+
onActionPatch={patchAction}
|
|
4880
5816
|
nodeState={nodeStates[enrichedNode.id]}
|
|
4881
5817
|
isActive={activeNodeIds.has(enrichedNode.id)}
|
|
4882
5818
|
errorNodeIds={errorNodeIds}
|
|
@@ -4930,6 +5866,7 @@ if (enrichedNode.type === 'par_out') {
|
|
|
4930
5866
|
</div>
|
|
4931
5867
|
</div>
|
|
4932
5868
|
</div>
|
|
5869
|
+
)}
|
|
4933
5870
|
</div>
|
|
4934
5871
|
|
|
4935
5872
|
{/* ── RIGHT PANEL ── */}
|
|
@@ -5296,7 +6233,9 @@ if (enrichedNode.type === 'par_out') {
|
|
|
5296
6233
|
</div>
|
|
5297
6234
|
|
|
5298
6235
|
{/* FEMO Preview */}
|
|
5299
|
-
{
|
|
6236
|
+
{/* 未保存警示条:插件=会话账里没有 scriptPath;独立=服务端 path 槽为空
|
|
6237
|
+
(undefined=槽还没拉到,不闪这条)。 */}
|
|
6238
|
+
{(plugin ? savedPath === undefined : standaloneSavedPath === null) && (
|
|
5300
6239
|
<div style={{
|
|
5301
6240
|
fontSize: 11,
|
|
5302
6241
|
color: 'var(--femo-warning-strong)',
|
|
@@ -5307,7 +6246,7 @@ if (enrichedNode.type === 'par_out') {
|
|
|
5307
6246
|
marginBottom: 4,
|
|
5308
6247
|
lineHeight: 1.4,
|
|
5309
6248
|
}}>
|
|
5310
|
-
⚠
|
|
6249
|
+
⚠ 脚本未保存。外接依赖文件只支持绝对地址。
|
|
5311
6250
|
</div>
|
|
5312
6251
|
)}
|
|
5313
6252
|
<FemoPreview
|
|
@@ -5424,8 +6363,9 @@ if (enrichedNode.type === 'par_out') {
|
|
|
5424
6363
|
createUrl={plugin ? '/femo-plugin/souls' : getBackendBaseUrl() + '/api/souls/create'}
|
|
5425
6364
|
/>
|
|
5426
6365
|
|
|
5427
|
-
{/* 导入清单(第一级,2026-09-11
|
|
5428
|
-
|
|
6366
|
+
{/* 导入清单(第一级,2026-09-11):桌面端带右上角「浏览…」=二级系统文件
|
|
6367
|
+
对话框(插件=宿主 onImport;独立=服务端系统对话框,2026-09-30 起)。
|
|
6368
|
+
清单两模式都开:账本是公共层单源(插件走宿主回调、独立打 web 服务)。 */}
|
|
5429
6369
|
<FemoFileList
|
|
5430
6370
|
open={femoFileOpen}
|
|
5431
6371
|
files={femoFileList}
|
|
@@ -5433,10 +6373,28 @@ if (enrichedNode.type === 'par_out') {
|
|
|
5433
6373
|
error={femoFileError}
|
|
5434
6374
|
busyPath={femoFileBusyPath}
|
|
5435
6375
|
onPick={handlePickFromList}
|
|
5436
|
-
onForget={
|
|
6376
|
+
onForget={handleForgetFromList}
|
|
5437
6377
|
onBrowse={handleBrowseImport}
|
|
5438
6378
|
onClose={() => setFemoFileOpen(false)}
|
|
5439
6379
|
/>
|
|
6380
|
+
<FemoDirBrowse
|
|
6381
|
+
open={dirBrowseOpen}
|
|
6382
|
+
mode={dirBrowseMode}
|
|
6383
|
+
dir={dirBrowseDir}
|
|
6384
|
+
dirs={dirBrowseDirs}
|
|
6385
|
+
files={dirBrowseFiles}
|
|
6386
|
+
loading={dirBrowseLoading}
|
|
6387
|
+
error={dirBrowseError}
|
|
6388
|
+
busy={dirBrowseBusy}
|
|
6389
|
+
defaultName={proj.name || 'flow'}
|
|
6390
|
+
onEnterDir={handleDirEnter}
|
|
6391
|
+
onUpDir={handleDirUp}
|
|
6392
|
+
onCreateFolder={handleDirMkdir}
|
|
6393
|
+
onOpenFile={handleDirOpenFile}
|
|
6394
|
+
onSave={handleDirSave}
|
|
6395
|
+
onClose={() => setDirBrowseOpen(false)}
|
|
6396
|
+
/>
|
|
6397
|
+
<FemoSaveReminder reminder={saveReminder} onChoice={resolveSaveReminder} />
|
|
5440
6398
|
</div> {/* 闭合最外层 flex 容器 */}
|
|
5441
6399
|
</ErrorBoundary>
|
|
5442
6400
|
);
|