@cortex-agent/server 2026.5.25 → 2026.6.11
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/defaults/config/thread-templates.json +28 -1
- package/defaults/hooks/cortex-md-injector.mjs +47 -31
- package/defaults/hooks/post-task-hook.mjs +6 -0
- package/defaults/hooks/task-status-check.mjs +8 -0
- package/defaults/mcp-config-slack.json +11 -0
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +18 -0
- package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +5 -6
- package/defaults/prompts/directives/manager.md +67 -0
- package/dist/agent-adapter/claude/adapter-tui.d.ts +35 -3
- package/dist/agent-adapter/claude/adapter-tui.js +91 -12
- package/dist/agent-adapter/claude/adapter.js +11 -0
- package/dist/agent-adapter/claude/defaults.d.ts +30 -0
- package/dist/agent-adapter/claude/defaults.js +30 -0
- package/dist/agent-adapter/claude/jsonl-tail.d.ts +2 -2
- package/dist/agent-adapter/claude/jsonl-tail.js +25 -20
- package/dist/agent-adapter/claude/spawn-args.d.ts +11 -0
- package/dist/agent-adapter/claude/spawn-args.js +49 -7
- package/dist/agent-adapter/claude/tmux-control.d.ts +20 -0
- package/dist/agent-adapter/claude/tmux-control.js +54 -8
- package/dist/agent-adapter/codex/adapter.js +1 -1
- package/dist/agent-adapter/normalize/event-types.d.ts +1 -0
- package/dist/agent-adapter/pi/adapter.js +46 -19
- package/dist/agent-adapter/pi/agent-dir.d.ts +21 -0
- package/dist/agent-adapter/pi/agent-dir.js +53 -2
- package/dist/agent-adapter/pi/event-parser.js +13 -1
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +12 -0
- package/dist/agent-adapter/pi/mcp-bridge.js +47 -9
- package/dist/agent-adapter/pi/tool-shims.d.ts +14 -0
- package/dist/agent-adapter/pi/tool-shims.js +167 -140
- package/dist/agent-adapter/types.d.ts +7 -2
- package/dist/core/atomic-write.js +21 -0
- package/dist/core/config-generator.d.ts +10 -0
- package/dist/core/config-generator.js +28 -0
- package/dist/core/gateway-generator.d.ts +77 -7
- package/dist/core/gateway-generator.js +301 -29
- package/dist/core/icons.d.ts +68 -0
- package/dist/core/icons.js +67 -0
- package/dist/core/profile-generator.d.ts +6 -0
- package/dist/core/profile-generator.js +35 -7
- package/dist/core/running-executions.d.ts +51 -41
- package/dist/core/running-executions.js +120 -73
- package/dist/core/status-format.js +3 -2
- package/dist/core/task-parser.d.ts +3 -0
- package/dist/core/task-parser.js +3 -1
- package/dist/core/types/thread-types.d.ts +54 -8
- package/dist/domain/agents/facade.d.ts +18 -0
- package/dist/domain/agents/facade.js +26 -3
- package/dist/domain/agents/profile-manager.d.ts +11 -0
- package/dist/domain/agents/profile-manager.js +21 -2
- package/dist/domain/costs/codex-usage-monitor.js +2 -1
- package/dist/domain/costs/rate-limit-throttle.js +14 -2
- package/dist/domain/executions/registry.d.ts +24 -0
- package/dist/domain/executions/registry.js +38 -0
- package/dist/domain/mcp/core-server.js +15 -3
- package/dist/domain/mcp/feishu/bitable.d.ts +3 -0
- package/dist/domain/mcp/feishu/bitable.js +168 -0
- package/dist/domain/mcp/feishu/block-types.d.ts +44 -0
- package/dist/domain/mcp/feishu/block-types.js +127 -0
- package/dist/domain/mcp/feishu/blocks-to-text.d.ts +19 -0
- package/dist/domain/mcp/feishu/blocks-to-text.js +43 -0
- package/dist/domain/mcp/feishu/client.d.ts +46 -0
- package/dist/domain/mcp/feishu/client.js +87 -0
- package/dist/domain/mcp/feishu/docx.d.ts +3 -0
- package/dist/domain/mcp/feishu/docx.js +163 -0
- package/dist/domain/mcp/feishu/drive.d.ts +23 -0
- package/dist/domain/mcp/feishu/drive.js +66 -0
- package/dist/domain/mcp/feishu/file.d.ts +14 -0
- package/dist/domain/mcp/feishu/file.js +107 -0
- package/dist/domain/mcp/feishu/index.d.ts +6 -0
- package/dist/domain/mcp/feishu/index.js +61 -0
- package/dist/domain/mcp/feishu/markdown-to-blocks.d.ts +40 -0
- package/dist/domain/mcp/feishu/markdown-to-blocks.js +191 -0
- package/dist/domain/mcp/feishu/sheets.d.ts +3 -0
- package/dist/domain/mcp/feishu/sheets.js +119 -0
- package/dist/domain/mcp/feishu/types.d.ts +26 -0
- package/dist/domain/mcp/feishu/types.js +38 -0
- package/dist/domain/mcp/feishu/user-auth.d.ts +140 -0
- package/dist/domain/mcp/feishu/user-auth.js +286 -0
- package/dist/domain/mcp/feishu/wiki.d.ts +3 -0
- package/dist/domain/mcp/feishu/wiki.js +77 -0
- package/dist/domain/mcp/feishu-server.d.ts +2 -0
- package/dist/domain/mcp/feishu-server.js +33 -0
- package/dist/domain/mcp/server.d.ts +0 -1
- package/dist/domain/mcp/server.js +6 -25
- package/dist/domain/mcp/slack-server.d.ts +3 -0
- package/dist/domain/mcp/slack-server.js +46 -0
- package/dist/domain/mcp/tools/context.js +1 -1
- package/dist/domain/mcp/tools/schedule.d.ts +1 -1
- package/dist/domain/mcp/tools/schedule.js +6 -20
- package/dist/domain/mcp/tools/slack.js +20 -7
- package/dist/domain/mcp/tools/thread-ops.d.ts +2 -0
- package/dist/domain/mcp/tools/thread-ops.js +121 -0
- package/dist/domain/mcp/tools/time.d.ts +2 -0
- package/dist/domain/mcp/tools/time.js +66 -0
- package/dist/domain/mcp/tools/tui-ask.js +1 -1
- package/dist/domain/mcp/tools/tui-plan.js +2 -2
- package/dist/domain/mcp/tui-server.js +1 -0
- package/dist/domain/monitor/disk-monitor.js +2 -1
- package/dist/domain/monitor/gpu-monitor.js +2 -1
- package/dist/domain/remote/client-hot-reload.js +3 -2
- package/dist/domain/remote/client-manager.js +8 -6
- package/dist/domain/scheduling/job-registry.d.ts +4 -0
- package/dist/domain/scheduling/job-registry.js +1 -0
- package/dist/domain/scheduling/jobs/_shared.js +2 -1
- package/dist/domain/scheduling/jobs/memory-index-regen.js +3 -2
- package/dist/domain/scheduling/jobs/scheduled-task.js +9 -23
- package/dist/domain/scheduling/jobs/sync-public.js +4 -3
- package/dist/domain/scheduling/jobs/target-dispatch.d.ts +1 -8
- package/dist/domain/scheduling/jobs/target-dispatch.js +0 -7
- package/dist/domain/scheduling/jobs/task-archive.js +3 -2
- package/dist/domain/scheduling/jobs/task-dispatch.js +120 -10
- package/dist/domain/scheduling/schedule-command.js +16 -15
- package/dist/domain/scheduling/scheduler.d.ts +1 -1
- package/dist/domain/scheduling/scheduler.js +2 -1
- package/dist/domain/sessions/session-hooks.d.ts +2 -2
- package/dist/domain/sessions/session-hooks.js +19 -18
- package/dist/domain/sessions/session-lifecycle.d.ts +38 -0
- package/dist/domain/sessions/session-lifecycle.js +44 -0
- package/dist/domain/system/install-cli.d.ts +7 -0
- package/dist/domain/system/install-cli.js +106 -0
- package/dist/domain/system/server-update-check.js +2 -2
- package/dist/domain/tasks/dispatch-utils.d.ts +58 -1
- package/dist/domain/tasks/dispatch-utils.js +53 -4
- package/dist/domain/tasks/dispatcher.js +26 -0
- package/dist/domain/tasks/lint.js +28 -0
- package/dist/domain/tasks/mutator.d.ts +16 -3
- package/dist/domain/tasks/mutator.js +41 -12
- package/dist/domain/tasks/pending-tracker.js +6 -5
- package/dist/domain/tasks/system/task-cli.d.ts +2 -0
- package/dist/domain/tasks/system/task-cli.js +37 -6
- package/dist/domain/tasks/system/task-lifecycle-edit.js +6 -1
- package/dist/domain/tasks/system/task-mutations.d.ts +41 -3
- package/dist/domain/tasks/system/task-mutations.js +166 -8
- package/dist/domain/threads/contract.d.ts +17 -0
- package/dist/domain/threads/contract.js +59 -0
- package/dist/domain/threads/hook-runner.js +7 -6
- package/dist/domain/threads/index.d.ts +2 -0
- package/dist/domain/threads/index.js +3 -1
- package/dist/domain/threads/prompt-builder.d.ts +15 -1
- package/dist/domain/threads/prompt-builder.js +41 -2
- package/dist/domain/threads/runner.d.ts +6 -5
- package/dist/domain/threads/runner.js +128 -79
- package/dist/domain/threads/state-machine.d.ts +23 -21
- package/dist/domain/threads/state-machine.js +113 -54
- package/dist/domain/threads/template-loader.js +3 -2
- package/dist/domain/threads/tree.d.ts +45 -0
- package/dist/domain/threads/tree.js +171 -0
- package/dist/domain/tui-session/index.d.ts +2 -0
- package/dist/domain/tui-session/index.js +3 -0
- package/dist/domain/tui-session/tui-session-service.d.ts +2 -0
- package/dist/domain/tui-session/tui-session-service.js +103 -0
- package/dist/domain/tui-session/types.d.ts +67 -0
- package/dist/domain/tui-session/types.js +4 -0
- package/dist/domain/ui-service/index.d.ts +5 -0
- package/dist/domain/ui-service/index.js +3 -0
- package/dist/domain/ui-service/mutate/executions.d.ts +4 -0
- package/dist/domain/ui-service/mutate/executions.js +15 -0
- package/dist/domain/ui-service/mutate/schedules.d.ts +10 -0
- package/dist/domain/ui-service/mutate/schedules.js +39 -0
- package/dist/domain/ui-service/mutate/tasks.d.ts +23 -0
- package/dist/domain/ui-service/mutate/tasks.js +59 -0
- package/dist/domain/ui-service/mutate/threads.d.ts +4 -0
- package/dist/domain/ui-service/mutate/threads.js +21 -0
- package/dist/domain/ui-service/query/cost.d.ts +3 -0
- package/dist/domain/ui-service/query/cost.js +6 -0
- package/dist/domain/ui-service/query/executions.d.ts +2 -0
- package/dist/domain/ui-service/query/executions.js +35 -0
- package/dist/domain/ui-service/query/projects.d.ts +2 -0
- package/dist/domain/ui-service/query/projects.js +30 -0
- package/dist/domain/ui-service/query/schedules.d.ts +2 -0
- package/dist/domain/ui-service/query/schedules.js +23 -0
- package/dist/domain/ui-service/query/sessions.d.ts +2 -0
- package/dist/domain/ui-service/query/sessions.js +35 -0
- package/dist/domain/ui-service/query/tasks.d.ts +2 -0
- package/dist/domain/ui-service/query/tasks.js +30 -0
- package/dist/domain/ui-service/query/threads.d.ts +2 -0
- package/dist/domain/ui-service/query/threads.js +27 -0
- package/dist/domain/ui-service/subscribe.d.ts +5 -0
- package/dist/domain/ui-service/subscribe.js +118 -0
- package/dist/domain/ui-service/types.d.ts +237 -0
- package/dist/domain/ui-service/types.js +5 -0
- package/dist/domain/ui-service/ui-service.d.ts +2 -0
- package/dist/domain/ui-service/ui-service.js +83 -0
- package/dist/entry/app.js +94 -5
- package/dist/entry/cli.d.ts +12 -0
- package/dist/entry/cli.js +122 -12
- package/dist/entry/feishu-login.d.ts +28 -0
- package/dist/entry/feishu-login.js +218 -0
- package/dist/entry/init.d.ts +25 -2
- package/dist/entry/init.js +211 -64
- package/dist/events/event-types.d.ts +14 -0
- package/dist/hooks/cortex-md-injector.mjs +47 -31
- package/dist/hooks/post-task-hook.mjs +6 -0
- package/dist/hooks/task-status-check.mjs +8 -0
- package/dist/orchestration/agent-runner.d.ts +2 -1
- package/dist/orchestration/agent-runner.js +55 -55
- package/dist/orchestration/conduit-queue.d.ts +18 -0
- package/dist/orchestration/conduit-queue.js +32 -0
- package/dist/orchestration/conversation-runner.d.ts +48 -0
- package/dist/orchestration/conversation-runner.js +109 -0
- package/dist/orchestration/dispatch-reconciler.js +8 -1
- package/dist/orchestration/interactions/ask-user-question.d.ts +1 -1
- package/dist/orchestration/interactions/ask-user-question.js +3 -3
- package/dist/orchestration/interactions/interaction-handlers.js +48 -17
- package/dist/orchestration/interactions/plan-handler.d.ts +2 -2
- package/dist/orchestration/interactions/plan-handler.js +4 -3
- package/dist/orchestration/interactions/update-prompt.d.ts +6 -0
- package/dist/orchestration/interactions/update-prompt.js +100 -0
- package/dist/orchestration/lifecycle.d.ts +4 -4
- package/dist/orchestration/lifecycle.js +24 -22
- package/dist/orchestration/orchestrator.d.ts +1 -1
- package/dist/orchestration/routing/commands/cancel.js +39 -47
- package/dist/orchestration/routing/commands/channel.js +24 -11
- package/dist/orchestration/routing/commands/cost.js +2 -1
- package/dist/orchestration/routing/commands/device.js +3 -2
- package/dist/orchestration/routing/commands/dispatch.js +6 -5
- package/dist/orchestration/routing/commands/index.d.ts +1 -1
- package/dist/orchestration/routing/commands/index.js +11 -10
- package/dist/orchestration/routing/commands/mode.js +19 -18
- package/dist/orchestration/routing/commands/nvtop.js +10 -9
- package/dist/orchestration/routing/commands/sendfile.js +7 -6
- package/dist/orchestration/routing/commands/session.d.ts +1 -1
- package/dist/orchestration/routing/commands/session.js +17 -33
- package/dist/orchestration/routing/commands/tail.js +4 -3
- package/dist/orchestration/routing/commands/task.js +4 -3
- package/dist/orchestration/routing/commands/thread-handlers.js +16 -6
- package/dist/orchestration/routing/edit-handler.js +8 -7
- package/dist/orchestration/routing/hook-bridge-subscribers.js +17 -1
- package/dist/orchestration/routing/message-router.d.ts +1 -1
- package/dist/orchestration/routing/message-router.js +9 -9
- package/dist/orchestration/routing/webhook.js +233 -2
- package/dist/orchestration/status-helpers.d.ts +5 -1
- package/dist/orchestration/status-helpers.js +7 -6
- package/dist/orchestration/thread-callback.d.ts +67 -0
- package/dist/orchestration/thread-callback.js +465 -0
- package/dist/orchestration/thread-executor.d.ts +22 -1
- package/dist/orchestration/thread-executor.js +85 -36
- package/dist/platform/adapter.d.ts +6 -2
- package/dist/platform/adapters/composite-adapter.d.ts +89 -0
- package/dist/platform/adapters/composite-adapter.js +318 -0
- package/dist/platform/adapters/feishu-output-stream.d.ts +26 -4
- package/dist/platform/adapters/feishu-output-stream.js +274 -36
- package/dist/platform/adapters/feishu.d.ts +50 -5
- package/dist/platform/adapters/feishu.js +370 -116
- package/dist/platform/adapters/index.d.ts +24 -3
- package/dist/platform/adapters/index.js +89 -11
- package/dist/platform/adapters/project-conduits.d.ts +9 -0
- package/dist/platform/adapters/project-conduits.js +42 -0
- package/dist/platform/adapters/slack-project-conduits.d.ts +1 -9
- package/dist/platform/adapters/slack-project-conduits.js +6 -40
- package/dist/platform/adapters/slack.d.ts +9 -2
- package/dist/platform/adapters/slack.js +83 -39
- package/dist/platform/adapters/tui/index.d.ts +9 -0
- package/dist/platform/adapters/tui/index.js +10 -0
- package/dist/platform/adapters/tui/ports.d.ts +20 -0
- package/dist/platform/adapters/tui/ports.js +4 -0
- package/dist/platform/adapters/tui/tui-conduit-state.d.ts +10 -0
- package/dist/platform/adapters/tui/tui-conduit-state.js +17 -0
- package/dist/platform/adapters/tui/tui-connection.d.ts +30 -0
- package/dist/platform/adapters/tui/tui-connection.js +53 -0
- package/dist/platform/adapters/tui/tui-gateway.d.ts +120 -0
- package/dist/platform/adapters/tui/tui-gateway.js +919 -0
- package/dist/platform/adapters/tui/tui-notifications.d.ts +12 -0
- package/dist/platform/adapters/tui/tui-notifications.js +60 -0
- package/dist/platform/adapters/tui/tui-output-stream.d.ts +36 -0
- package/dist/platform/adapters/tui/tui-output-stream.js +99 -0
- package/dist/platform/adapters/tui/tui-transcript.d.ts +8 -0
- package/dist/platform/adapters/tui/tui-transcript.js +56 -0
- package/dist/platform/index.d.ts +1 -0
- package/dist/platform/index.js +2 -1
- package/dist/platform/interactive-builder.js +3 -2
- package/dist/platform/output-stream.d.ts +5 -0
- package/dist/platform/testing.d.ts +7 -11
- package/dist/platform/testing.js +18 -15
- package/dist/platform/tool-trace.js +15 -5
- package/dist/platform/tui/protocol.d.ts +355 -0
- package/dist/platform/tui/protocol.js +199 -0
- package/dist/platform/types.d.ts +12 -3
- package/dist/store/execution-repo.d.ts +6 -1
- package/dist/store/execution-repo.js +13 -3
- package/dist/store/hook-sync.d.ts +18 -0
- package/dist/store/hook-sync.js +92 -0
- package/dist/store/outbound-queue.js +2 -2
- package/dist/store/profile-repo.js +3 -2
- package/dist/store/schedule-repo.d.ts +1 -8
- package/dist/store/session-registry-repo.d.ts +9 -1
- package/dist/store/session-registry-repo.js +19 -3
- package/dist/store/session-repo.d.ts +14 -0
- package/dist/store/session-repo.js +23 -0
- package/dist/store/thread-repo.d.ts +3 -0
- package/dist/store/thread-repo.js +49 -2
- package/dist/store/version-migrations.js +95 -0
- package/dist/tui/App.d.ts +27 -0
- package/dist/tui/App.js +219 -0
- package/dist/tui/components/AskUserModal.d.ts +11 -0
- package/dist/tui/components/AskUserModal.js +364 -0
- package/dist/tui/components/ConfirmModal.d.ts +12 -0
- package/dist/tui/components/ConfirmModal.js +31 -0
- package/dist/tui/components/Dashboard.d.ts +23 -0
- package/dist/tui/components/Dashboard.js +80 -0
- package/dist/tui/components/DashboardCostTab.d.ts +7 -0
- package/dist/tui/components/DashboardCostTab.js +16 -0
- package/dist/tui/components/DashboardExecutionsTab.d.ts +11 -0
- package/dist/tui/components/DashboardExecutionsTab.js +94 -0
- package/dist/tui/components/DashboardSchedulesTab.d.ts +11 -0
- package/dist/tui/components/DashboardSchedulesTab.js +124 -0
- package/dist/tui/components/DashboardTasksTab.d.ts +12 -0
- package/dist/tui/components/DashboardTasksTab.js +200 -0
- package/dist/tui/components/DashboardThreadsTab.d.ts +11 -0
- package/dist/tui/components/DashboardThreadsTab.js +81 -0
- package/dist/tui/components/Header.d.ts +11 -0
- package/dist/tui/components/Header.js +5 -0
- package/dist/tui/components/InputBox.d.ts +10 -0
- package/dist/tui/components/InputBox.js +19 -0
- package/dist/tui/components/MessageRow.d.ts +7 -0
- package/dist/tui/components/MessageRow.js +10 -0
- package/dist/tui/components/Notifications.d.ts +19 -0
- package/dist/tui/components/Notifications.js +72 -0
- package/dist/tui/components/PlanFeedbackModal.d.ts +11 -0
- package/dist/tui/components/PlanFeedbackModal.js +161 -0
- package/dist/tui/components/ProjectSwitcher.d.ts +18 -0
- package/dist/tui/components/ProjectSwitcher.js +43 -0
- package/dist/tui/components/SessionPicker.d.ts +14 -0
- package/dist/tui/components/SessionPicker.js +34 -0
- package/dist/tui/components/SidePanel.d.ts +19 -0
- package/dist/tui/components/SidePanel.js +8 -0
- package/dist/tui/components/StatusLine.d.ts +10 -0
- package/dist/tui/components/StatusLine.js +29 -0
- package/dist/tui/components/Transcript.d.ts +13 -0
- package/dist/tui/components/Transcript.js +56 -0
- package/dist/tui/hooks/useDashboardData.d.ts +32 -0
- package/dist/tui/hooks/useDashboardData.js +104 -0
- package/dist/tui/hooks/useKeybindings.d.ts +19 -0
- package/dist/tui/hooks/useKeybindings.js +87 -0
- package/dist/tui/hooks/useMutate.d.ts +22 -0
- package/dist/tui/hooks/useMutate.js +56 -0
- package/dist/tui/hooks/useNotifications.d.ts +28 -0
- package/dist/tui/hooks/useNotifications.js +70 -0
- package/dist/tui/hooks/useTranscript.d.ts +39 -0
- package/dist/tui/hooks/useTranscript.js +265 -0
- package/dist/tui/hooks/useWsClient.d.ts +29 -0
- package/dist/tui/hooks/useWsClient.js +69 -0
- package/dist/tui/index.d.ts +2 -0
- package/dist/tui/index.js +210 -0
- package/dist/tui/logic.d.ts +16 -0
- package/dist/tui/logic.js +49 -0
- package/dist/tui/render/markdown.d.ts +10 -0
- package/dist/tui/render/markdown.js +38 -0
- package/dist/tui/render/rich-blocks.d.ts +11 -0
- package/dist/tui/render/rich-blocks.js +24 -0
- package/dist/tui/ws-client.d.ts +44 -0
- package/dist/tui/ws-client.js +157 -0
- package/package.json +11 -3
- package/dist/orchestration/channel-queue.d.ts +0 -18
- package/dist/orchestration/channel-queue.js +0 -32
|
@@ -1,11 +1,65 @@
|
|
|
1
1
|
// input: FeishuAdapter + output-stream interfaces
|
|
2
|
-
// output: FeishuOutputStream
|
|
3
|
-
// pos: Feishu-specific OutputStream —
|
|
4
|
-
//
|
|
2
|
+
// output: FeishuOutputStream — coalescing OutputStream for Feishu
|
|
3
|
+
// pos: Feishu-specific OutputStream — coalesces streamed text into one growing
|
|
4
|
+
// card via card patch (im.v1.message.patch), backs openMutable with a real
|
|
5
|
+
// updatable region (so tool-call traces render), and threads overflow
|
|
6
|
+
// chunks under the first message (reply_in_thread, Slack-style).
|
|
5
7
|
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
6
8
|
import { createLogger } from '../../core/log.js';
|
|
7
|
-
import { chunkText, DEFAULT_MAX_CHUNK } from '../output-stream-chunk.js';
|
|
9
|
+
import { needsSplit, chunkText, DEFAULT_MAX_CHUNK } from '../output-stream-chunk.js';
|
|
8
10
|
const log = createLogger('feishu-output-stream');
|
|
11
|
+
const SEPARATOR = '\n';
|
|
12
|
+
const TAIL_SEPARATOR = '\n';
|
|
13
|
+
const DEFAULT_RETRY_DELAYS_MS = [200, 600, 1500];
|
|
14
|
+
let retryDelaysMs = DEFAULT_RETRY_DELAYS_MS;
|
|
15
|
+
function sleep(ms) {
|
|
16
|
+
if (ms <= 0)
|
|
17
|
+
return Promise.resolve();
|
|
18
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
19
|
+
}
|
|
20
|
+
async function withRetries(fn, label) {
|
|
21
|
+
let lastError;
|
|
22
|
+
const delays = retryDelaysMs;
|
|
23
|
+
for (let attempt = 0; attempt <= delays.length; attempt++) {
|
|
24
|
+
try {
|
|
25
|
+
return await fn();
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
lastError = e;
|
|
29
|
+
if (attempt < delays.length) {
|
|
30
|
+
const delay = delays[attempt];
|
|
31
|
+
log.warn(`${label} attempt ${attempt + 1} failed (${e.message}); retrying in ${delay}ms`);
|
|
32
|
+
await sleep(delay);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
throw lastError;
|
|
37
|
+
}
|
|
38
|
+
/** Test-only: override retry delays to skip real wall-clock waits. */
|
|
39
|
+
export function _testSetRetryDelays(delays) {
|
|
40
|
+
retryDelaysMs = delays;
|
|
41
|
+
}
|
|
42
|
+
/** Test-only: restore production retry delays. */
|
|
43
|
+
export function _testResetRetryDelays() {
|
|
44
|
+
retryDelaysMs = DEFAULT_RETRY_DELAYS_MS;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A MutableRegion handle tied to a FeishuOutputStream.
|
|
48
|
+
* Stale after the stream opens a new region or emits committed text.
|
|
49
|
+
*/
|
|
50
|
+
class FeishuMutableRegion {
|
|
51
|
+
_stream;
|
|
52
|
+
_generation;
|
|
53
|
+
constructor(stream, generation) {
|
|
54
|
+
this._stream = stream;
|
|
55
|
+
this._generation = generation;
|
|
56
|
+
}
|
|
57
|
+
update(text) {
|
|
58
|
+
if (!text?.trim())
|
|
59
|
+
return;
|
|
60
|
+
this._stream._regionUpdate(this._generation, text);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
9
63
|
export class FeishuOutputStream {
|
|
10
64
|
adapter;
|
|
11
65
|
destination;
|
|
@@ -13,10 +67,25 @@ export class FeishuOutputStream {
|
|
|
13
67
|
onMessagePosted;
|
|
14
68
|
maxChunk;
|
|
15
69
|
durable;
|
|
70
|
+
get _logChannel() {
|
|
71
|
+
if (this.destination.type === 'interactive-reply')
|
|
72
|
+
return this.destination.conduit;
|
|
73
|
+
if (this.destination.type === 'project-report')
|
|
74
|
+
return this.destination.projectId;
|
|
75
|
+
return 'system-notice';
|
|
76
|
+
}
|
|
16
77
|
parentRef = null;
|
|
78
|
+
currentRef = null;
|
|
79
|
+
currentContent = '';
|
|
80
|
+
// Unsealed tail text on the current Feishu card. Display = currentContent
|
|
81
|
+
// [+ SEP + mutableTail]. openMutable opens/rotates; MutableRegion.update replaces;
|
|
82
|
+
// emitText or postInteractive auto-seals by folding mutableTail into currentContent.
|
|
83
|
+
mutableTail = '';
|
|
17
84
|
allRefs = [];
|
|
18
85
|
queue = Promise.resolve();
|
|
19
86
|
lastError = null;
|
|
87
|
+
/** Generation counter for MutableRegion staleness tracking. */
|
|
88
|
+
_regionGeneration = 0;
|
|
20
89
|
constructor(adapter, destination, opts) {
|
|
21
90
|
this.adapter = adapter;
|
|
22
91
|
this.destination = destination;
|
|
@@ -28,25 +97,38 @@ export class FeishuOutputStream {
|
|
|
28
97
|
emitText(text) {
|
|
29
98
|
if (!text?.trim())
|
|
30
99
|
return;
|
|
31
|
-
this.
|
|
32
|
-
|
|
100
|
+
++this._regionGeneration; // seal any open mutable region synchronously
|
|
101
|
+
this.queue = this.queue.then(() => this._processAppend(text)).catch(e => {
|
|
102
|
+
log.error(`Queue error in channel ${this._logChannel} (text len=${text.length}):`, e.message);
|
|
33
103
|
this.lastError = e instanceof Error ? e : new Error(String(e));
|
|
34
104
|
});
|
|
35
105
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
106
|
+
openMutable(text) {
|
|
107
|
+
if (!text?.trim())
|
|
108
|
+
return this._noopRegion();
|
|
109
|
+
const generation = ++this._regionGeneration;
|
|
110
|
+
this.queue = this.queue.then(() => this._processOpenMutable(text)).catch(e => {
|
|
111
|
+
log.error(`Queue error in openMutable (channel ${this._logChannel}, len=${text.length}):`, e.message);
|
|
112
|
+
this.lastError = e instanceof Error ? e : new Error(String(e));
|
|
113
|
+
});
|
|
114
|
+
return new FeishuMutableRegion(this, generation);
|
|
39
115
|
}
|
|
40
116
|
postInteractive(text, opts) {
|
|
41
117
|
const richBlocks = opts?.richBlocks;
|
|
42
118
|
const actions = opts?.actions;
|
|
119
|
+
++this._regionGeneration; // seal any open mutable region synchronously
|
|
43
120
|
return new Promise((resolve, reject) => {
|
|
44
121
|
this.queue = this.queue.then(async () => {
|
|
122
|
+
this.currentRef = null;
|
|
123
|
+
this.currentContent = '';
|
|
124
|
+
this.mutableTail = '';
|
|
125
|
+
const effectiveThreadId = this.threadId || this.parentRef?.messageId || undefined;
|
|
45
126
|
try {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
127
|
+
const ref = await withRetries(async () => {
|
|
128
|
+
return actions && actions.length > 0
|
|
129
|
+
? await this.adapter.postInteractive(this.destination, { text, richBlocks, actions }, { threadId: effectiveThreadId })
|
|
130
|
+
: await this.adapter.postMessage(this.destination, { text, richBlocks }, { threadId: effectiveThreadId });
|
|
131
|
+
}, 'postInteractive');
|
|
50
132
|
if (!this.parentRef && !this.threadId)
|
|
51
133
|
this.parentRef = ref;
|
|
52
134
|
this.allRefs.push(ref);
|
|
@@ -56,7 +138,7 @@ export class FeishuOutputStream {
|
|
|
56
138
|
}
|
|
57
139
|
catch (e) {
|
|
58
140
|
const err = e instanceof Error ? e : new Error(String(e));
|
|
59
|
-
log.error(`postInteractive failed:`, err.message);
|
|
141
|
+
log.error(`postInteractive failed after retries in channel ${this._logChannel}:`, err.message);
|
|
60
142
|
this.lastError = err;
|
|
61
143
|
reject(err);
|
|
62
144
|
throw err;
|
|
@@ -82,33 +164,189 @@ export class FeishuOutputStream {
|
|
|
82
164
|
getParentRef() {
|
|
83
165
|
return this.parentRef;
|
|
84
166
|
}
|
|
85
|
-
|
|
167
|
+
// --- Internal: MutableRegion staleness ---
|
|
168
|
+
/** Called by FeishuMutableRegion.update(). No-op if the generation is stale. */
|
|
169
|
+
_regionUpdate(generation, text) {
|
|
170
|
+
if (generation !== this._regionGeneration)
|
|
171
|
+
return; // stale region — no-op
|
|
172
|
+
this.queue = this.queue.then(() => this._processEditMutableTail(text)).catch(e => {
|
|
173
|
+
log.error(`Queue error in _regionUpdate (channel ${this._logChannel}, len=${text.length}):`, e.message);
|
|
174
|
+
this.lastError = e instanceof Error ? e : new Error(String(e));
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
_noopRegion() {
|
|
178
|
+
return { update: () => { } };
|
|
179
|
+
}
|
|
180
|
+
// --- Internal: queue processors ---
|
|
181
|
+
async _processAppend(text) {
|
|
182
|
+
this._sealMutableTailNow();
|
|
183
|
+
if (this.currentRef === null) {
|
|
184
|
+
await this._postNew(text);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const combined = this.currentContent + SEPARATOR + text;
|
|
188
|
+
if (needsSplit(combined, this.maxChunk)) {
|
|
189
|
+
await this._postNew(text);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const delivered = await this._updateCurrent(combined);
|
|
193
|
+
if (delivered) {
|
|
194
|
+
this.currentContent = combined;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
log.error(`Update permanently failed in channel ${this._logChannel}; falling back to new post`);
|
|
198
|
+
await this._postNew(text);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
async _processOpenMutable(text) {
|
|
202
|
+
this._sealMutableTailNow();
|
|
203
|
+
const combined = this._renderWithTail(text);
|
|
204
|
+
if (this.currentRef === null) {
|
|
205
|
+
await this._postNew(combined);
|
|
206
|
+
this.currentContent = '';
|
|
207
|
+
this.mutableTail = text;
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (needsSplit(combined, this.maxChunk)) {
|
|
211
|
+
await this._postNew(text);
|
|
212
|
+
this.currentContent = '';
|
|
213
|
+
this.mutableTail = text;
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const delivered = await this._updateCurrent(combined);
|
|
217
|
+
if (delivered) {
|
|
218
|
+
this.mutableTail = text;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
log.error(`Update failed in openMutable (channel ${this._logChannel}); falling back to new post`);
|
|
222
|
+
await this._postNew(text);
|
|
223
|
+
this.currentContent = '';
|
|
224
|
+
this.mutableTail = text;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
async _processEditMutableTail(text) {
|
|
228
|
+
if (!this.mutableTail)
|
|
229
|
+
return;
|
|
230
|
+
const combined = this._renderWithTail(text);
|
|
231
|
+
if (this.currentRef === null) {
|
|
232
|
+
await this._postNew(combined);
|
|
233
|
+
this.currentContent = '';
|
|
234
|
+
this.mutableTail = text;
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (needsSplit(combined, this.maxChunk)) {
|
|
238
|
+
this._sealMutableTailNow();
|
|
239
|
+
await this._postNew(text);
|
|
240
|
+
this.currentContent = '';
|
|
241
|
+
this.mutableTail = text;
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const delivered = await this._updateCurrent(combined);
|
|
245
|
+
if (delivered) {
|
|
246
|
+
this.mutableTail = text;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
log.error(`Update failed in mutable-tail edit (channel ${this._logChannel}); falling back to new post`);
|
|
250
|
+
this._sealMutableTailNow();
|
|
251
|
+
await this._postNew(text);
|
|
252
|
+
this.currentContent = '';
|
|
253
|
+
this.mutableTail = text;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/** Combined display = currentContent [+ SEP + mutableTail]. */
|
|
257
|
+
_renderWithTail(tail) {
|
|
258
|
+
if (!this.currentContent)
|
|
259
|
+
return tail;
|
|
260
|
+
if (!tail)
|
|
261
|
+
return this.currentContent;
|
|
262
|
+
return this.currentContent + TAIL_SEPARATOR + tail;
|
|
263
|
+
}
|
|
264
|
+
/** Synchronously move mutableTail into currentContent. */
|
|
265
|
+
_sealMutableTailNow() {
|
|
266
|
+
if (!this.mutableTail)
|
|
267
|
+
return;
|
|
268
|
+
this.currentContent = this.currentContent
|
|
269
|
+
? this.currentContent + TAIL_SEPARATOR + this.mutableTail
|
|
270
|
+
: this.mutableTail;
|
|
271
|
+
this.mutableTail = '';
|
|
272
|
+
}
|
|
273
|
+
async _postNew(text) {
|
|
86
274
|
const chunks = chunkText(text, this.maxChunk);
|
|
275
|
+
let lastChunkSentIndex = -1;
|
|
87
276
|
for (let i = 0; i < chunks.length; i++) {
|
|
88
277
|
const chunk = chunks[i];
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
: null;
|
|
95
|
-
const ref = await this.adapter.postMessage(this.destination, { text: chunk }, { threadId: effectiveThreadId });
|
|
96
|
-
if (walId && this.durable) {
|
|
97
|
-
await this.durable.afterSent(walId, ref.messageId).catch(() => { });
|
|
98
|
-
}
|
|
99
|
-
if (!this.parentRef && !this.threadId && this.allRefs.length === 0 && i === 0) {
|
|
100
|
-
this.parentRef = ref;
|
|
101
|
-
}
|
|
102
|
-
this.allRefs.push(ref);
|
|
103
|
-
if (this.onMessagePosted)
|
|
104
|
-
this.onMessagePosted(ref);
|
|
278
|
+
// Slack-style threading: first message → channel, subsequent → thread under
|
|
279
|
+
// the first (parentRef). FeishuAdapter.replyInThread sets reply_in_thread.
|
|
280
|
+
let effectiveThreadId;
|
|
281
|
+
if (this.threadId) {
|
|
282
|
+
effectiveThreadId = this.threadId;
|
|
105
283
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
throw
|
|
284
|
+
else if (this.parentRef === null && i === 0) {
|
|
285
|
+
effectiveThreadId = undefined;
|
|
286
|
+
}
|
|
287
|
+
else if (this.parentRef === null) {
|
|
288
|
+
throw new Error(`[feishu-output-stream] aborting chunk ${i} — chunk 0 failed to post and would orphan subsequent chunks`);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
effectiveThreadId = this.parentRef.messageId;
|
|
292
|
+
}
|
|
293
|
+
const ref = await this._postOne(chunk, effectiveThreadId);
|
|
294
|
+
if (this.parentRef === null && !this.threadId) {
|
|
295
|
+
this.parentRef = ref;
|
|
296
|
+
}
|
|
297
|
+
this.allRefs.push(ref);
|
|
298
|
+
if (this.onMessagePosted)
|
|
299
|
+
this.onMessagePosted(ref);
|
|
300
|
+
lastChunkSentIndex = i;
|
|
301
|
+
}
|
|
302
|
+
if (lastChunkSentIndex >= 0) {
|
|
303
|
+
this.currentRef = this.allRefs[this.allRefs.length - 1];
|
|
304
|
+
this.currentContent = chunks[lastChunkSentIndex];
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
async _postOne(chunk, threadId) {
|
|
308
|
+
const richBlocks = [{ type: 'markdown', text: chunk }];
|
|
309
|
+
const richContent = { text: chunk, richBlocks };
|
|
310
|
+
const walId = this.durable
|
|
311
|
+
? await this.durable.beforePost(this.destination, chunk, { threadId, richBlocks })
|
|
312
|
+
: null;
|
|
313
|
+
try {
|
|
314
|
+
const ref = await withRetries(() => this.adapter.postMessage(this.destination, richContent, { threadId }), `postMessage(channel=${this._logChannel}, len=${chunk.length})`);
|
|
315
|
+
if (walId && this.durable) {
|
|
316
|
+
await this.durable.afterSent(walId, ref.messageId).catch(e => {
|
|
317
|
+
log.warn(`afterSent failed for walId=${walId}:`, e.message);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
return ref;
|
|
321
|
+
}
|
|
322
|
+
catch (e) {
|
|
323
|
+
if (walId && this.durable?.onSendFailed) {
|
|
324
|
+
this.durable.onSendFailed(walId);
|
|
111
325
|
}
|
|
326
|
+
throw e;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/** Patch the current card with the combined content. Returns delivered. */
|
|
330
|
+
async _updateCurrent(content) {
|
|
331
|
+
if (!this.currentRef)
|
|
332
|
+
return true;
|
|
333
|
+
const ref = this.currentRef;
|
|
334
|
+
const richBlocks = [{ type: 'markdown', text: content }];
|
|
335
|
+
const richContent = { text: content, richBlocks };
|
|
336
|
+
const walId = this.durable
|
|
337
|
+
? await this.durable.beforeUpdate(this._logChannel, ref.messageId, content, { richBlocks })
|
|
338
|
+
: null;
|
|
339
|
+
try {
|
|
340
|
+
await withRetries(() => this.adapter.updateMessage(ref, richContent), `updateMessage(channel=${this._logChannel}, len=${content.length})`);
|
|
341
|
+
if (walId && this.durable) {
|
|
342
|
+
await this.durable.afterSent(walId).catch(e => {
|
|
343
|
+
log.warn(`afterSent failed for walId=${walId}:`, e.message);
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
catch {
|
|
349
|
+
return false;
|
|
112
350
|
}
|
|
113
351
|
}
|
|
114
352
|
}
|
|
@@ -14,12 +14,21 @@ export declare class FeishuAdapter implements PlatformAdapter {
|
|
|
14
14
|
readonly capabilities: PlatformCapabilities;
|
|
15
15
|
private client;
|
|
16
16
|
private wsClient;
|
|
17
|
+
private readonly domain;
|
|
17
18
|
private eventDispatcher;
|
|
18
19
|
private config;
|
|
19
20
|
private messageHandler;
|
|
20
21
|
private actionHandlers;
|
|
21
22
|
private modalHandlers;
|
|
23
|
+
private _adminAutoDetected;
|
|
22
24
|
constructor(config: FeishuAdapterConfig);
|
|
25
|
+
private static readonly PREFIX;
|
|
26
|
+
/** Add the `feishu:` prefix (idempotent; passes through empty strings). */
|
|
27
|
+
private _wrap;
|
|
28
|
+
/** Strip the `feishu:` prefix (tolerates already-bare values for back-compat). */
|
|
29
|
+
private _unwrap;
|
|
30
|
+
/** True if this conduit belongs to the Feishu adapter. */
|
|
31
|
+
ownsConduit(conduit: string): boolean;
|
|
23
32
|
start(): Promise<void>;
|
|
24
33
|
stop(): Promise<void>;
|
|
25
34
|
onMessage(handler: (ctx: MessageContext) => Promise<void>): void;
|
|
@@ -33,13 +42,14 @@ export declare class FeishuAdapter implements PlatformAdapter {
|
|
|
33
42
|
actions: ActionElement[];
|
|
34
43
|
}, opts?: PostMessageOpts): Promise<MessageRef>;
|
|
35
44
|
openModal(triggerId: string, modal: ModalDefinition): Promise<void>;
|
|
36
|
-
|
|
45
|
+
private _addHourglassReaction;
|
|
46
|
+
markQueued(ref: MessageRef): Promise<void>;
|
|
37
47
|
uploadFile(destination: Destination, filePath: string, opts?: FileUploadOpts): Promise<void>;
|
|
38
48
|
downloadFile(fileRef: PlatformFileRef, destDir: string): Promise<DownloadedFile>;
|
|
39
49
|
getPermalink(_ref: MessageRef): Promise<string | null>;
|
|
40
|
-
postEphemeral(_channel: string, _userId: string, _text: string): Promise<void>;
|
|
41
50
|
openOutputStream(destination: Destination, opts?: OpenOutputStreamOpts): OutputStream;
|
|
42
|
-
private
|
|
51
|
+
private _conduitsStore;
|
|
52
|
+
private _getConduitsStore;
|
|
43
53
|
bindProjectConduit(projectId: string, conduitHint: string): Promise<void>;
|
|
44
54
|
unbindProjectConduit(projectId: string): Promise<void>;
|
|
45
55
|
getProjectConduits(): Promise<Record<string, string>>;
|
|
@@ -50,15 +60,46 @@ export declare class FeishuAdapter implements PlatformAdapter {
|
|
|
50
60
|
* (unconfigured admin channel).
|
|
51
61
|
*/
|
|
52
62
|
private resolveDestination;
|
|
63
|
+
/**
|
|
64
|
+
* Upsert FEISHU_ADMIN_CHANNEL=<chatId> into <CONFIG_DIR>/.env so the detected
|
|
65
|
+
* admin DM survives restarts. Mirrors SlackAdapter._persistAdminChannel.
|
|
66
|
+
*/
|
|
67
|
+
private _persistAdminChannel;
|
|
53
68
|
private handleIncomingMessage;
|
|
69
|
+
/**
|
|
70
|
+
* Build PlatformFileRef[] from a parsed Feishu message content payload.
|
|
71
|
+
* Feishu stores the resource key inside `content` (not on the message object):
|
|
72
|
+
* - file / media (video): { file_key, file_name? }
|
|
73
|
+
* - image: { image_key }
|
|
74
|
+
* - audio: { file_key }
|
|
75
|
+
* message_id + resourceType are stashed in `raw` so downloadFile() can call
|
|
76
|
+
* im.v1.messageResource.get (which requires both message_id and a type param).
|
|
77
|
+
*/
|
|
78
|
+
private extractInboundFiles;
|
|
54
79
|
private handleCardAction;
|
|
55
80
|
private buildMessagePayload;
|
|
56
81
|
private buildCardJson;
|
|
57
82
|
private replyInThread;
|
|
58
83
|
/** Convert RichBlock[] to Feishu card schema 2.0 elements. */
|
|
59
84
|
private richBlocksToFeishuElements;
|
|
60
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Convert a ButtonElement to a Feishu card **schema 2.0** button.
|
|
87
|
+
*
|
|
88
|
+
* Card 2.0 buttons carry their interaction in a `behaviors` callback (the old
|
|
89
|
+
* top-level `value` field is form-only in 2.0). `name` is preserved so
|
|
90
|
+
* handleCardAction's `action.name` lookup keeps working; the callback `value`
|
|
91
|
+
* delivers `{ actionId, value }`, which arrives as `event.action.value`.
|
|
92
|
+
*/
|
|
61
93
|
private actionElementToFeishu;
|
|
94
|
+
/**
|
|
95
|
+
* Lay buttons out as a wrapping `column_set` (one auto-width column per button).
|
|
96
|
+
* Feishu card schema 2.0 removed the `action` container tag (error 200861:
|
|
97
|
+
* "unsupported tag action"), so buttons must be direct body elements.
|
|
98
|
+
* `flex_mode: 'flow'` + per-column `width: 'auto'` makes the buttons size to
|
|
99
|
+
* their text and wrap onto multiple rows — without `flow` many buttons get
|
|
100
|
+
* crushed into one unreadable row.
|
|
101
|
+
*/
|
|
102
|
+
private buttonsToColumnSet;
|
|
62
103
|
/**
|
|
63
104
|
* Convert ModalDefinition to a Feishu card with embedded form container.
|
|
64
105
|
* Since Feishu has no native modal, we post a card message containing a
|
|
@@ -67,7 +108,11 @@ export declare class FeishuAdapter implements PlatformAdapter {
|
|
|
67
108
|
private modalToFeishuCard;
|
|
68
109
|
/**
|
|
69
110
|
* Normalize Feishu form_value into the platform-agnostic ModalFieldValue format.
|
|
70
|
-
* Feishu form_value is a flat dict { field_name: value }
|
|
111
|
+
* Feishu form_value is a flat dict { field_name: value } where field_name follows
|
|
112
|
+
* our convention "{blockId}::{actionId}::{kind}" (kind ∈ select | multi | text).
|
|
113
|
+
* The kind segment is what lets us map a single-select (a bare string) to
|
|
114
|
+
* `selectedOption` rather than `value` — the downstream consumer
|
|
115
|
+
* (interaction-handlers.ts) reads `selectedOption.value` for single-select.
|
|
71
116
|
* We reconstruct the two-level { blockId: { actionId: ModalFieldValue } } structure.
|
|
72
117
|
*/
|
|
73
118
|
private normalizeFormValues;
|