@zhin.js/agent 1.1.7 → 1.1.9
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 +15 -23
- package/lib/activity-feedback/adapter-integration.d.ts +1 -2
- package/lib/activity-feedback/adapter-integration.d.ts.map +1 -1
- package/lib/activity-feedback/adapter-integration.js +43 -13
- package/lib/activity-feedback/adapter-integration.js.map +1 -1
- package/lib/assistant/index.d.ts +1 -1
- package/lib/assistant/index.d.ts.map +1 -1
- package/lib/assistant/index.js +1 -1
- package/lib/assistant/index.js.map +1 -1
- package/lib/assistant/job-creator.d.ts +0 -7
- package/lib/assistant/job-creator.d.ts.map +1 -1
- package/lib/assistant/job-creator.js +1 -12
- package/lib/assistant/job-creator.js.map +1 -1
- package/lib/builtin/five-agent/index.d.ts +6 -3
- package/lib/builtin/five-agent/index.d.ts.map +1 -1
- package/lib/builtin/five-agent/index.js +6 -4
- package/lib/builtin/five-agent/index.js.map +1 -1
- package/lib/builtin/five-agent/prompts.d.ts +3 -3
- package/lib/builtin/five-agent/prompts.d.ts.map +1 -1
- package/lib/builtin/five-agent/prompts.js +3 -3
- package/lib/builtin/five-agent/prompts.js.map +1 -1
- package/lib/builtin/five-agent/role-capability-policy.d.ts +9 -0
- package/lib/builtin/five-agent/role-capability-policy.d.ts.map +1 -0
- package/lib/builtin/five-agent/role-capability-policy.js +22 -0
- package/lib/builtin/five-agent/role-capability-policy.js.map +1 -0
- package/lib/builtin/five-agent/roles.d.ts +5 -0
- package/lib/builtin/five-agent/roles.d.ts.map +1 -0
- package/lib/builtin/five-agent/roles.js +12 -0
- package/lib/builtin/five-agent/roles.js.map +1 -0
- package/lib/builtin/orchestration-tools.d.ts.map +1 -1
- package/lib/builtin/orchestration-tools.js +12 -38
- package/lib/builtin/orchestration-tools.js.map +1 -1
- package/lib/builtin/spawn-task-tool.js +2 -2
- package/lib/builtin/spawn-task-tool.js.map +1 -1
- package/lib/config/agent-interfaces.d.ts +2 -2
- package/lib/config/agent-interfaces.d.ts.map +1 -1
- package/lib/config/fix-ai-config.d.ts.map +1 -1
- package/lib/config/fix-ai-config.js +1 -38
- package/lib/config/fix-ai-config.js.map +1 -1
- package/lib/config/index.d.ts +1 -1
- package/lib/config/index.d.ts.map +1 -1
- package/lib/config/index.js +1 -1
- package/lib/config/index.js.map +1 -1
- package/lib/config/resolve-five-agent-binding.d.ts +10 -0
- package/lib/config/resolve-five-agent-binding.d.ts.map +1 -0
- package/lib/config/resolve-five-agent-binding.js +31 -0
- package/lib/config/resolve-five-agent-binding.js.map +1 -0
- package/lib/context/context-system.d.ts +2 -2
- package/lib/context/context-system.d.ts.map +1 -1
- package/lib/context/context-system.js +2 -3
- package/lib/context/context-system.js.map +1 -1
- package/lib/context/context-tail-limit.d.ts +0 -2
- package/lib/context/context-tail-limit.d.ts.map +1 -1
- package/lib/context/context-tail-limit.js +1 -3
- package/lib/context/context-tail-limit.js.map +1 -1
- package/lib/context/default-builders.d.ts +0 -4
- package/lib/context/default-builders.d.ts.map +1 -1
- package/lib/context/default-builders.js +0 -14
- package/lib/context/default-builders.js.map +1 -1
- package/lib/context/envelope-parts.d.ts +0 -1
- package/lib/context/envelope-parts.d.ts.map +1 -1
- package/lib/context/index.d.ts +2 -2
- package/lib/context/index.d.ts.map +1 -1
- package/lib/context/index.js +2 -2
- package/lib/context/index.js.map +1 -1
- package/lib/context/turn-envelope.d.ts +0 -1
- package/lib/context/turn-envelope.d.ts.map +1 -1
- package/lib/context/turn-envelope.js +0 -2
- package/lib/context/turn-envelope.js.map +1 -1
- package/lib/core/agent-loop-standalone.d.ts +2 -1
- package/lib/core/agent-loop-standalone.d.ts.map +1 -1
- package/lib/core/agent-loop-standalone.js.map +1 -1
- package/lib/event/agent-stream-bus.d.ts +0 -1
- package/lib/event/agent-stream-bus.d.ts.map +1 -1
- package/lib/event/agent-stream-bus.js.map +1 -1
- package/lib/event/publish-agent-stream.js +2 -2
- package/lib/event/publish-agent-stream.js.map +1 -1
- package/lib/event/turn-event.d.ts +11 -1
- package/lib/event/turn-event.d.ts.map +1 -1
- package/lib/event/turn-event.js.map +1 -1
- package/lib/index.d.ts +13 -21
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -15
- package/lib/index.js.map +1 -1
- package/lib/init/activate-ai-database-storage.d.ts +2 -2
- package/lib/init/activate-ai-database-storage.d.ts.map +1 -1
- package/lib/init/activate-ai-database-storage.js +1 -3
- package/lib/init/activate-ai-database-storage.js.map +1 -1
- package/lib/init/define-ai-database-models.d.ts +1 -1
- package/lib/init/define-ai-database-models.d.ts.map +1 -1
- package/lib/init/define-ai-database-models.js +1 -9
- package/lib/init/define-ai-database-models.js.map +1 -1
- package/lib/init/runtime-management-commands.d.ts +2 -3
- package/lib/init/runtime-management-commands.d.ts.map +1 -1
- package/lib/init/runtime-management-commands.js +6 -6
- package/lib/init/runtime-management-commands.js.map +1 -1
- package/lib/internal/agent-host.d.ts +2 -3
- package/lib/internal/agent-host.d.ts.map +1 -1
- package/lib/internal/host-types.d.ts +0 -28
- package/lib/internal/host-types.d.ts.map +1 -1
- package/lib/memory/context-repository-store.js +1 -1
- package/lib/memory/context-repository-store.js.map +1 -1
- package/lib/memory/memory-system.d.ts +1 -2
- package/lib/memory/memory-system.d.ts.map +1 -1
- package/lib/memory/memory-system.js +1 -3
- package/lib/memory/memory-system.js.map +1 -1
- package/lib/orchestrator/bootstrap-executors.d.ts +0 -4
- package/lib/orchestrator/bootstrap-executors.d.ts.map +1 -1
- package/lib/orchestrator/bootstrap-executors.js +11 -137
- package/lib/orchestrator/bootstrap-executors.js.map +1 -1
- package/lib/orchestrator/orchestration-mappers.d.ts +1 -1
- package/lib/orchestrator/orchestration-mappers.d.ts.map +1 -1
- package/lib/orchestrator/orchestration-mappers.js +4 -49
- package/lib/orchestrator/orchestration-mappers.js.map +1 -1
- package/lib/orchestrator/orchestration-service.d.ts.map +1 -1
- package/lib/orchestrator/orchestration-service.js +2 -5
- package/lib/orchestrator/orchestration-service.js.map +1 -1
- package/lib/orchestrator/orchestration-source.d.ts +5 -0
- package/lib/orchestrator/orchestration-source.d.ts.map +1 -0
- package/lib/orchestrator/orchestration-source.js +22 -0
- package/lib/orchestrator/orchestration-source.js.map +1 -0
- package/lib/outbound/send-proactive.d.ts +3 -13
- package/lib/outbound/send-proactive.d.ts.map +1 -1
- package/lib/outbound/send-proactive.js +1 -53
- package/lib/outbound/send-proactive.js.map +1 -1
- package/lib/plugin-runtime/agent-host-port.d.ts +12 -3
- package/lib/plugin-runtime/agent-host-port.d.ts.map +1 -1
- package/lib/plugin-runtime/agent-host-port.js +1 -1
- package/lib/plugin-runtime/agent-host-port.js.map +1 -1
- package/lib/plugin-runtime/agent-runtime.d.ts +7 -4
- package/lib/plugin-runtime/agent-runtime.d.ts.map +1 -1
- package/lib/plugin-runtime/agent-runtime.js +3 -2
- package/lib/plugin-runtime/agent-runtime.js.map +1 -1
- package/lib/plugin-runtime/capability-tools.d.ts.map +1 -1
- package/lib/plugin-runtime/capability-tools.js +3 -0
- package/lib/plugin-runtime/capability-tools.js.map +1 -1
- package/lib/plugin-runtime/deferred-capability-plan.d.ts +1 -0
- package/lib/plugin-runtime/deferred-capability-plan.d.ts.map +1 -1
- package/lib/plugin-runtime/deferred-capability-plan.js +1 -1
- package/lib/plugin-runtime/deferred-capability-plan.js.map +1 -1
- package/lib/plugin-runtime/full-agent-turn-engine.d.ts.map +1 -1
- package/lib/plugin-runtime/full-agent-turn-engine.js +102 -0
- package/lib/plugin-runtime/full-agent-turn-engine.js.map +1 -1
- package/lib/plugin-runtime/host-mcp-projection.d.ts.map +1 -1
- package/lib/plugin-runtime/host-mcp-projection.js +17 -2
- package/lib/plugin-runtime/host-mcp-projection.js.map +1 -1
- package/lib/plugin-runtime/schedule-capability-plan.d.ts +20 -0
- package/lib/plugin-runtime/schedule-capability-plan.d.ts.map +1 -0
- package/lib/plugin-runtime/schedule-capability-plan.js +88 -0
- package/lib/plugin-runtime/schedule-capability-plan.js.map +1 -0
- package/lib/prompt/assembly.d.ts.map +1 -1
- package/lib/prompt/assembly.js +2 -0
- package/lib/prompt/assembly.js.map +1 -1
- package/lib/prompt/index.d.ts +5 -1
- package/lib/prompt/index.d.ts.map +1 -1
- package/lib/prompt/index.js +3 -1
- package/lib/prompt/index.js.map +1 -1
- package/lib/prompt/prompt-assembly-registry.d.ts +25 -0
- package/lib/prompt/prompt-assembly-registry.d.ts.map +1 -0
- package/lib/prompt/prompt-assembly-registry.js +43 -0
- package/lib/prompt/prompt-assembly-registry.js.map +1 -0
- package/lib/prompt/prompt-budget.d.ts +9 -0
- package/lib/prompt/prompt-budget.d.ts.map +1 -0
- package/lib/prompt/prompt-budget.js +28 -0
- package/lib/prompt/prompt-budget.js.map +1 -0
- package/lib/prompt/prompt-builder.js +1 -1
- package/lib/prompt/prompt-builder.js.map +1 -1
- package/lib/prompt/system-prompt.d.ts +5 -8
- package/lib/prompt/system-prompt.d.ts.map +1 -1
- package/lib/prompt/system-prompt.js +159 -78
- package/lib/prompt/system-prompt.js.map +1 -1
- package/lib/prompt/tokens.d.ts +8 -0
- package/lib/prompt/tokens.d.ts.map +1 -0
- package/lib/prompt/tokens.js +2 -0
- package/lib/prompt/tokens.js.map +1 -0
- package/lib/prompt/turn-prompt-profile.d.ts +1 -2
- package/lib/prompt/turn-prompt-profile.d.ts.map +1 -1
- package/lib/schedule-domain/audit-logger.d.ts +2 -2
- package/lib/schedule-domain/audit-logger.d.ts.map +1 -1
- package/lib/schedule-domain/execution-domain.d.ts +21 -17
- package/lib/schedule-domain/execution-domain.d.ts.map +1 -1
- package/lib/schedule-domain/execution-domain.js +41 -23
- package/lib/schedule-domain/execution-domain.js.map +1 -1
- package/lib/schedule-domain/index.d.ts +0 -1
- package/lib/schedule-domain/index.d.ts.map +1 -1
- package/lib/schedule-domain/index.js +0 -1
- package/lib/schedule-domain/index.js.map +1 -1
- package/lib/schedule-domain/prompt-assembler.d.ts +3 -4
- package/lib/schedule-domain/prompt-assembler.d.ts.map +1 -1
- package/lib/schedule-domain/prompt-assembler.js +0 -16
- package/lib/schedule-domain/prompt-assembler.js.map +1 -1
- package/lib/schedule-domain/security-harness.d.ts +10 -15
- package/lib/schedule-domain/security-harness.d.ts.map +1 -1
- package/lib/schedule-domain/security-harness.js +5 -78
- package/lib/schedule-domain/security-harness.js.map +1 -1
- package/lib/security/exec-policy.d.ts +2 -0
- package/lib/security/exec-policy.d.ts.map +1 -1
- package/lib/security/exec-policy.js +21 -0
- package/lib/security/exec-policy.js.map +1 -1
- package/lib/security/owner-approve-always-store.d.ts +8 -3
- package/lib/security/owner-approve-always-store.d.ts.map +1 -1
- package/lib/security/owner-approve-always-store.js +160 -173
- package/lib/security/owner-approve-always-store.js.map +1 -1
- package/lib/security/policy-facade.d.ts.map +1 -1
- package/lib/security/policy-facade.js +11 -1
- package/lib/security/policy-facade.js.map +1 -1
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +0 -7
- package/lib/service.js.map +1 -1
- package/lib/session/index.d.ts +3 -3
- package/lib/session/index.d.ts.map +1 -1
- package/lib/session/index.js +3 -3
- package/lib/session/index.js.map +1 -1
- package/lib/session/passive-group-session.js +1 -1
- package/lib/session/session-key.d.ts +4 -0
- package/lib/session/session-key.d.ts.map +1 -0
- package/lib/session/session-key.js +6 -0
- package/lib/session/session-key.js.map +1 -0
- package/lib/session/session-system.d.ts.map +1 -1
- package/lib/session/session-system.js +4 -4
- package/lib/session/session-system.js.map +1 -1
- package/lib/session/session-tree-commands.d.ts +2 -3
- package/lib/session/session-tree-commands.d.ts.map +1 -1
- package/lib/session/session-tree-commands.js +2 -5
- package/lib/session/session-tree-commands.js.map +1 -1
- package/lib/session/strategies.d.ts +1 -1
- package/lib/session/strategies.d.ts.map +1 -1
- package/lib/session/strategies.js +2 -2
- package/lib/session/strategies.js.map +1 -1
- package/lib/subagent/im-result-sink.d.ts.map +1 -1
- package/lib/subagent/im-result-sink.js +0 -1
- package/lib/subagent/im-result-sink.js.map +1 -1
- package/lib/subagent-goal-notify.d.ts +0 -9
- package/lib/subagent-goal-notify.d.ts.map +1 -1
- package/lib/subagent-goal-notify.js +0 -13
- package/lib/subagent-goal-notify.js.map +1 -1
- package/lib/task-executor.d.ts +14 -3
- package/lib/task-executor.d.ts.map +1 -1
- package/lib/task-executor.js +48 -61
- package/lib/task-executor.js.map +1 -1
- package/lib/tool/classic-tool-execution-authority.d.ts.map +1 -1
- package/lib/tool/classic-tool-execution-authority.js +4 -3
- package/lib/tool/classic-tool-execution-authority.js.map +1 -1
- package/lib/tool/prepare-turn-tools.d.ts +0 -2
- package/lib/tool/prepare-turn-tools.d.ts.map +1 -1
- package/lib/tool/prepare-turn-tools.js +1 -55
- package/lib/tool/prepare-turn-tools.js.map +1 -1
- package/lib/tool/tool-runtime.d.ts +1 -1
- package/lib/tool/tool-runtime.d.ts.map +1 -1
- package/lib/turn/auto-continue.js +1 -1
- package/lib/turn/auto-continue.js.map +1 -1
- package/lib/turn/persist-deferred-context.js +1 -1
- package/lib/turn/persist-deferred-context.js.map +1 -1
- package/lib/turn/persist-subagent-context.js +1 -1
- package/lib/turn/persist-subagent-context.js.map +1 -1
- package/lib/turn/process-stream.d.ts.map +1 -1
- package/lib/turn/process-stream.js +0 -2
- package/lib/turn/process-stream.js.map +1 -1
- package/lib/turn/turn-ingress.d.ts +21 -1
- package/lib/turn/turn-ingress.d.ts.map +1 -1
- package/lib/turn/turn-ingress.js +29 -0
- package/lib/turn/turn-ingress.js.map +1 -1
- package/lib/turn/turn-pipeline.d.ts +0 -5
- package/lib/turn/turn-pipeline.d.ts.map +1 -1
- package/lib/turn/turn-pipeline.js +12 -32
- package/lib/turn/turn-pipeline.js.map +1 -1
- package/lib/typing-indicator/adapter-integration.d.ts +1 -2
- package/lib/typing-indicator/adapter-integration.d.ts.map +1 -1
- package/lib/typing-indicator/adapter-integration.js.map +1 -1
- package/lib/typing-indicator/integration.d.ts +2 -3
- package/lib/typing-indicator/integration.d.ts.map +1 -1
- package/lib/typing-indicator/integration.js +48 -11
- package/lib/typing-indicator/integration.js.map +1 -1
- package/lib/zhin-agent/index.d.ts +5 -8
- package/lib/zhin-agent/index.d.ts.map +1 -1
- package/lib/zhin-agent/index.js +13 -15
- package/lib/zhin-agent/index.js.map +1 -1
- package/package.json +9 -9
- package/lib/aop/index.d.ts +0 -11
- package/lib/aop/index.d.ts.map +0 -1
- package/lib/aop/index.js +0 -11
- package/lib/aop/index.js.map +0 -1
- package/lib/aop/pipeline/index.d.ts +0 -12
- package/lib/aop/pipeline/index.d.ts.map +0 -1
- package/lib/aop/pipeline/index.js +0 -12
- package/lib/aop/pipeline/index.js.map +0 -1
- package/lib/aop/pipeline/pipeline-flow.d.ts +0 -25
- package/lib/aop/pipeline/pipeline-flow.d.ts.map +0 -1
- package/lib/aop/pipeline/pipeline-flow.js +0 -115
- package/lib/aop/pipeline/pipeline-flow.js.map +0 -1
- package/lib/aop/pipeline/pipeline-mode.d.ts +0 -10
- package/lib/aop/pipeline/pipeline-mode.d.ts.map +0 -1
- package/lib/aop/pipeline/pipeline-mode.js +0 -16
- package/lib/aop/pipeline/pipeline-mode.js.map +0 -1
- package/lib/aop/pipeline/pipeline-service.d.ts +0 -123
- package/lib/aop/pipeline/pipeline-service.d.ts.map +0 -1
- package/lib/aop/pipeline/pipeline-service.js +0 -238
- package/lib/aop/pipeline/pipeline-service.js.map +0 -1
- package/lib/aop/pipeline/pipeline-transitions.d.ts +0 -14
- package/lib/aop/pipeline/pipeline-transitions.d.ts.map +0 -1
- package/lib/aop/pipeline/pipeline-transitions.js +0 -31
- package/lib/aop/pipeline/pipeline-transitions.js.map +0 -1
- package/lib/aop/pipeline/ports.d.ts +0 -16
- package/lib/aop/pipeline/ports.d.ts.map +0 -1
- package/lib/aop/pipeline/ports.js +0 -2
- package/lib/aop/pipeline/ports.js.map +0 -1
- package/lib/aop/pipeline/role-capability-policy.d.ts +0 -16
- package/lib/aop/pipeline/role-capability-policy.d.ts.map +0 -1
- package/lib/aop/pipeline/role-capability-policy.js +0 -29
- package/lib/aop/pipeline/role-capability-policy.js.map +0 -1
- package/lib/aop/runtime/index.d.ts +0 -9
- package/lib/aop/runtime/index.d.ts.map +0 -1
- package/lib/aop/runtime/index.js +0 -9
- package/lib/aop/runtime/index.js.map +0 -1
- package/lib/collaboration/collab-admin-gate.d.ts +0 -21
- package/lib/collaboration/collab-admin-gate.d.ts.map +0 -1
- package/lib/collaboration/collab-admin-gate.js +0 -74
- package/lib/collaboration/collab-admin-gate.js.map +0 -1
- package/lib/collaboration/collab-utils.d.ts +0 -15
- package/lib/collaboration/collab-utils.d.ts.map +0 -1
- package/lib/collaboration/collab-utils.js +0 -37
- package/lib/collaboration/collab-utils.js.map +0 -1
- package/lib/collaboration/collaboration-artifact-repository.d.ts +0 -48
- package/lib/collaboration/collaboration-artifact-repository.d.ts.map +0 -1
- package/lib/collaboration/collaboration-artifact-repository.js +0 -114
- package/lib/collaboration/collaboration-artifact-repository.js.map +0 -1
- package/lib/collaboration/collaboration-commands.d.ts +0 -38
- package/lib/collaboration/collaboration-commands.d.ts.map +0 -1
- package/lib/collaboration/collaboration-commands.js +0 -373
- package/lib/collaboration/collaboration-commands.js.map +0 -1
- package/lib/collaboration/collaboration-config.d.ts +0 -30
- package/lib/collaboration/collaboration-config.d.ts.map +0 -1
- package/lib/collaboration/collaboration-config.js +0 -170
- package/lib/collaboration/collaboration-config.js.map +0 -1
- package/lib/collaboration/collaboration-context.d.ts +0 -15
- package/lib/collaboration/collaboration-context.d.ts.map +0 -1
- package/lib/collaboration/collaboration-context.js +0 -101
- package/lib/collaboration/collaboration-context.js.map +0 -1
- package/lib/collaboration/collaboration-db-model.d.ts +0 -350
- package/lib/collaboration/collaboration-db-model.d.ts.map +0 -1
- package/lib/collaboration/collaboration-db-model.js +0 -112
- package/lib/collaboration/collaboration-db-model.js.map +0 -1
- package/lib/collaboration/collaboration-delegation.d.ts +0 -21
- package/lib/collaboration/collaboration-delegation.d.ts.map +0 -1
- package/lib/collaboration/collaboration-delegation.js +0 -221
- package/lib/collaboration/collaboration-delegation.js.map +0 -1
- package/lib/collaboration/collaboration-dispatch.d.ts +0 -32
- package/lib/collaboration/collaboration-dispatch.d.ts.map +0 -1
- package/lib/collaboration/collaboration-dispatch.js +0 -93
- package/lib/collaboration/collaboration-dispatch.js.map +0 -1
- package/lib/collaboration/collaboration-kernel-bridge.d.ts +0 -23
- package/lib/collaboration/collaboration-kernel-bridge.d.ts.map +0 -1
- package/lib/collaboration/collaboration-kernel-bridge.js +0 -105
- package/lib/collaboration/collaboration-kernel-bridge.js.map +0 -1
- package/lib/collaboration/collaboration-outbound.d.ts +0 -64
- package/lib/collaboration/collaboration-outbound.d.ts.map +0 -1
- package/lib/collaboration/collaboration-outbound.js +0 -312
- package/lib/collaboration/collaboration-outbound.js.map +0 -1
- package/lib/collaboration/collaboration-scene-repository.d.ts +0 -154
- package/lib/collaboration/collaboration-scene-repository.d.ts.map +0 -1
- package/lib/collaboration/collaboration-scene-repository.js +0 -451
- package/lib/collaboration/collaboration-scene-repository.js.map +0 -1
- package/lib/collaboration/collaboration-turn-snapshot.d.ts +0 -18
- package/lib/collaboration/collaboration-turn-snapshot.d.ts.map +0 -1
- package/lib/collaboration/collaboration-turn-snapshot.js +0 -35
- package/lib/collaboration/collaboration-turn-snapshot.js.map +0 -1
- package/lib/collaboration/delegation-state.d.ts +0 -30
- package/lib/collaboration/delegation-state.d.ts.map +0 -1
- package/lib/collaboration/delegation-state.js +0 -86
- package/lib/collaboration/delegation-state.js.map +0 -1
- package/lib/collaboration/endpoint-identity.d.ts +0 -28
- package/lib/collaboration/endpoint-identity.d.ts.map +0 -1
- package/lib/collaboration/endpoint-identity.js +0 -80
- package/lib/collaboration/endpoint-identity.js.map +0 -1
- package/lib/collaboration/group-feed.d.ts +0 -30
- package/lib/collaboration/group-feed.d.ts.map +0 -1
- package/lib/collaboration/group-feed.js +0 -150
- package/lib/collaboration/group-feed.js.map +0 -1
- package/lib/collaboration/group-message.d.ts +0 -53
- package/lib/collaboration/group-message.d.ts.map +0 -1
- package/lib/collaboration/group-message.js +0 -101
- package/lib/collaboration/group-message.js.map +0 -1
- package/lib/collaboration/im-mention-delegate.d.ts +0 -22
- package/lib/collaboration/im-mention-delegate.d.ts.map +0 -1
- package/lib/collaboration/im-mention-delegate.js +0 -15
- package/lib/collaboration/im-mention-delegate.js.map +0 -1
- package/lib/collaboration/inbound-peer-handback.d.ts +0 -18
- package/lib/collaboration/inbound-peer-handback.d.ts.map +0 -1
- package/lib/collaboration/inbound-peer-handback.js +0 -65
- package/lib/collaboration/inbound-peer-handback.js.map +0 -1
- package/lib/collaboration/inbound-spawn-task.d.ts +0 -29
- package/lib/collaboration/inbound-spawn-task.d.ts.map +0 -1
- package/lib/collaboration/inbound-spawn-task.js +0 -96
- package/lib/collaboration/inbound-spawn-task.js.map +0 -1
- package/lib/collaboration/inbound-turn-endpoint.d.ts +0 -16
- package/lib/collaboration/inbound-turn-endpoint.d.ts.map +0 -1
- package/lib/collaboration/inbound-turn-endpoint.js +0 -26
- package/lib/collaboration/inbound-turn-endpoint.js.map +0 -1
- package/lib/collaboration/inbound-turn-tools.d.ts +0 -13
- package/lib/collaboration/inbound-turn-tools.d.ts.map +0 -1
- package/lib/collaboration/inbound-turn-tools.js +0 -24
- package/lib/collaboration/inbound-turn-tools.js.map +0 -1
- package/lib/collaboration/index.d.ts +0 -21
- package/lib/collaboration/index.d.ts.map +0 -1
- package/lib/collaboration/index.js +0 -19
- package/lib/collaboration/index.js.map +0 -1
- package/lib/collaboration/init-observe-hook.d.ts +0 -56
- package/lib/collaboration/init-observe-hook.d.ts.map +0 -1
- package/lib/collaboration/init-observe-hook.js +0 -168
- package/lib/collaboration/init-observe-hook.js.map +0 -1
- package/lib/collaboration/init-wizard-service.d.ts +0 -57
- package/lib/collaboration/init-wizard-service.d.ts.map +0 -1
- package/lib/collaboration/init-wizard-service.js +0 -187
- package/lib/collaboration/init-wizard-service.js.map +0 -1
- package/lib/collaboration/outbound-resolver.d.ts +0 -37
- package/lib/collaboration/outbound-resolver.d.ts.map +0 -1
- package/lib/collaboration/outbound-resolver.js +0 -189
- package/lib/collaboration/outbound-resolver.js.map +0 -1
- package/lib/collaboration/peer-policy.d.ts +0 -29
- package/lib/collaboration/peer-policy.d.ts.map +0 -1
- package/lib/collaboration/peer-policy.js +0 -118
- package/lib/collaboration/peer-policy.js.map +0 -1
- package/lib/collaboration/resolve-agent-session-key.d.ts +0 -21
- package/lib/collaboration/resolve-agent-session-key.d.ts.map +0 -1
- package/lib/collaboration/resolve-agent-session-key.js +0 -61
- package/lib/collaboration/resolve-agent-session-key.js.map +0 -1
- package/lib/collaboration/runtime-inbound-gate.d.ts +0 -35
- package/lib/collaboration/runtime-inbound-gate.d.ts.map +0 -1
- package/lib/collaboration/runtime-inbound-gate.js +0 -105
- package/lib/collaboration/runtime-inbound-gate.js.map +0 -1
- package/lib/collaboration/scene-context.d.ts +0 -17
- package/lib/collaboration/scene-context.d.ts.map +0 -1
- package/lib/collaboration/scene-context.js +0 -22
- package/lib/collaboration/scene-context.js.map +0 -1
- package/lib/collaboration/scene-identity-service.d.ts +0 -169
- package/lib/collaboration/scene-identity-service.d.ts.map +0 -1
- package/lib/collaboration/scene-identity-service.js +0 -479
- package/lib/collaboration/scene-identity-service.js.map +0 -1
- package/lib/collaboration/scene-service.d.ts +0 -67
- package/lib/collaboration/scene-service.d.ts.map +0 -1
- package/lib/collaboration/scene-service.js +0 -157
- package/lib/collaboration/scene-service.js.map +0 -1
- package/lib/collaboration/structured-ai-outbound.d.ts +0 -25
- package/lib/collaboration/structured-ai-outbound.d.ts.map +0 -1
- package/lib/collaboration/structured-ai-outbound.js +0 -179
- package/lib/collaboration/structured-ai-outbound.js.map +0 -1
- package/lib/collaboration/turn-plan-resolver.d.ts +0 -17
- package/lib/collaboration/turn-plan-resolver.d.ts.map +0 -1
- package/lib/collaboration/turn-plan-resolver.js +0 -63
- package/lib/collaboration/turn-plan-resolver.js.map +0 -1
- package/lib/collaboration/types.d.ts +0 -147
- package/lib/collaboration/types.d.ts.map +0 -1
- package/lib/collaboration/types.js +0 -16
- package/lib/collaboration/types.js.map +0 -1
- package/lib/collaboration/wire-collaboration-storage.d.ts +0 -4
- package/lib/collaboration/wire-collaboration-storage.d.ts.map +0 -1
- package/lib/collaboration/wire-collaboration-storage.js +0 -26
- package/lib/collaboration/wire-collaboration-storage.js.map +0 -1
- package/lib/config/resolve-pipeline-binding.d.ts +0 -16
- package/lib/config/resolve-pipeline-binding.d.ts.map +0 -1
- package/lib/config/resolve-pipeline-binding.js +0 -35
- package/lib/config/resolve-pipeline-binding.js.map +0 -1
- package/lib/discovery/register-agent-surface.d.ts +0 -33
- package/lib/discovery/register-agent-surface.d.ts.map +0 -1
- package/lib/discovery/register-agent-surface.js +0 -170
- package/lib/discovery/register-agent-surface.js.map +0 -1
- package/lib/init/create-zhin-agent.d.ts +0 -3
- package/lib/init/create-zhin-agent.d.ts.map +0 -1
- package/lib/init/create-zhin-agent.js +0 -401
- package/lib/init/create-zhin-agent.js.map +0 -1
- package/lib/init/register-ai-service.d.ts +0 -7
- package/lib/init/register-ai-service.d.ts.map +0 -1
- package/lib/init/register-ai-service.js +0 -45
- package/lib/init/register-ai-service.js.map +0 -1
- package/lib/init/register-builtin-tools.d.ts +0 -3
- package/lib/init/register-builtin-tools.d.ts.map +0 -1
- package/lib/init/register-builtin-tools.js +0 -411
- package/lib/init/register-builtin-tools.js.map +0 -1
- package/lib/init/register-capability-features.d.ts +0 -2
- package/lib/init/register-capability-features.d.ts.map +0 -1
- package/lib/init/register-capability-features.js +0 -28
- package/lib/init/register-capability-features.js.map +0 -1
- package/lib/init/register-collaboration-commands.d.ts +0 -2
- package/lib/init/register-collaboration-commands.d.ts.map +0 -1
- package/lib/init/register-collaboration-commands.js +0 -110
- package/lib/init/register-collaboration-commands.js.map +0 -1
- package/lib/init/register-db-models.d.ts +0 -2
- package/lib/init/register-db-models.d.ts.map +0 -1
- package/lib/init/register-db-models.js +0 -18
- package/lib/init/register-db-models.js.map +0 -1
- package/lib/init/register-db-upgrade.d.ts +0 -7
- package/lib/init/register-db-upgrade.d.ts.map +0 -1
- package/lib/init/register-db-upgrade.js +0 -79
- package/lib/init/register-db-upgrade.js.map +0 -1
- package/lib/init/register-group-session-passive.d.ts +0 -3
- package/lib/init/register-group-session-passive.d.ts.map +0 -1
- package/lib/init/register-group-session-passive.js +0 -61
- package/lib/init/register-group-session-passive.js.map +0 -1
- package/lib/init/register-im-segment-filter.d.ts +0 -2
- package/lib/init/register-im-segment-filter.d.ts.map +0 -1
- package/lib/init/register-im-segment-filter.js +0 -23
- package/lib/init/register-im-segment-filter.js.map +0 -1
- package/lib/init/register-init-wizard-guardrail.d.ts +0 -2
- package/lib/init/register-init-wizard-guardrail.d.ts.map +0 -1
- package/lib/init/register-init-wizard-guardrail.js +0 -41
- package/lib/init/register-init-wizard-guardrail.js.map +0 -1
- package/lib/init/register-introspection-commands.d.ts +0 -3
- package/lib/init/register-introspection-commands.d.ts.map +0 -1
- package/lib/init/register-introspection-commands.js +0 -107
- package/lib/init/register-introspection-commands.js.map +0 -1
- package/lib/init/register-management-tools.d.ts +0 -10
- package/lib/init/register-management-tools.d.ts.map +0 -1
- package/lib/init/register-management-tools.js +0 -42
- package/lib/init/register-management-tools.js.map +0 -1
- package/lib/init/register-mcp-from-config.d.ts +0 -2
- package/lib/init/register-mcp-from-config.d.ts.map +0 -1
- package/lib/init/register-mcp-from-config.js +0 -87
- package/lib/init/register-mcp-from-config.js.map +0 -1
- package/lib/init/register-orchestrator.d.ts +0 -2
- package/lib/init/register-orchestrator.d.ts.map +0 -1
- package/lib/init/register-orchestrator.js +0 -15
- package/lib/init/register-orchestrator.js.map +0 -1
- package/lib/init/register-tool-service.d.ts +0 -2
- package/lib/init/register-tool-service.d.ts.map +0 -1
- package/lib/init/register-tool-service.js +0 -9
- package/lib/init/register-tool-service.js.map +0 -1
- package/lib/init/shared-refs.d.ts +0 -14
- package/lib/init/shared-refs.d.ts.map +0 -1
- package/lib/init/shared-refs.js +0 -7
- package/lib/init/shared-refs.js.map +0 -1
- package/lib/init/types.d.ts +0 -26
- package/lib/init/types.d.ts.map +0 -1
- package/lib/init/types.js +0 -7
- package/lib/init/types.js.map +0 -1
- package/lib/init.d.ts +0 -7
- package/lib/init.d.ts.map +0 -1
- package/lib/init.js +0 -11
- package/lib/init.js.map +0 -1
- package/lib/schedule-domain/tool-resolver.d.ts +0 -20
- package/lib/schedule-domain/tool-resolver.d.ts.map +0 -1
- package/lib/schedule-domain/tool-resolver.js +0 -80
- package/lib/schedule-domain/tool-resolver.js.map +0 -1
- package/lib/schedule-domain/turn-context.d.ts +0 -9
- package/lib/schedule-domain/turn-context.d.ts.map +0 -1
- package/lib/schedule-domain/turn-context.js +0 -36
- package/lib/schedule-domain/turn-context.js.map +0 -1
- package/lib/session/agent-session-host-port.d.ts +0 -23
- package/lib/session/agent-session-host-port.d.ts.map +0 -1
- package/lib/session/agent-session-host-port.js +0 -61
- package/lib/session/agent-session-host-port.js.map +0 -1
- package/lib/session/http-agent-session-store.d.ts +0 -76
- package/lib/session/http-agent-session-store.d.ts.map +0 -1
- package/lib/session/http-agent-session-store.js +0 -211
- package/lib/session/http-agent-session-store.js.map +0 -1
- package/lib/session/http-approval-adapter.d.ts +0 -11
- package/lib/session/http-approval-adapter.d.ts.map +0 -1
- package/lib/session/http-approval-adapter.js +0 -19
- package/lib/session/http-approval-adapter.js.map +0 -1
- package/lib/session/http-approval-waiter.d.ts +0 -11
- package/lib/session/http-approval-waiter.d.ts.map +0 -1
- package/lib/session/http-approval-waiter.js +0 -61
- package/lib/session/http-approval-waiter.js.map +0 -1
- package/lib/session/http-session-persistence.d.ts +0 -28
- package/lib/session/http-session-persistence.d.ts.map +0 -1
- package/lib/session/http-session-persistence.js +0 -60
- package/lib/session/http-session-persistence.js.map +0 -1
- package/lib/session/http-session-sink.d.ts +0 -11
- package/lib/session/http-session-sink.d.ts.map +0 -1
- package/lib/session/http-session-sink.js +0 -32
- package/lib/session/http-session-sink.js.map +0 -1
- package/lib/session/http-step-projector.d.ts +0 -16
- package/lib/session/http-step-projector.d.ts.map +0 -1
- package/lib/session/http-step-projector.js +0 -118
- package/lib/session/http-step-projector.js.map +0 -1
- package/lib/session/http-turn-runner.d.ts +0 -16
- package/lib/session/http-turn-runner.d.ts.map +0 -1
- package/lib/session/http-turn-runner.js +0 -57
- package/lib/session/http-turn-runner.js.map +0 -1
- package/lib/session/park-controller.d.ts +0 -24
- package/lib/session/park-controller.d.ts.map +0 -1
- package/lib/session/park-controller.js +0 -58
- package/lib/session/park-controller.js.map +0 -1
- package/lib/session/resolve-approval-port.d.ts +0 -7
- package/lib/session/resolve-approval-port.d.ts.map +0 -1
- package/lib/session/resolve-approval-port.js +0 -13
- package/lib/session/resolve-approval-port.js.map +0 -1
- package/lib/session/session-event-log.d.ts +0 -17
- package/lib/session/session-event-log.d.ts.map +0 -1
- package/lib/session/session-event-log.js +0 -56
- package/lib/session/session-event-log.js.map +0 -1
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CellContext session key — cross-endpoint coordination projection layer.
|
|
3
|
-
* Does not replace transport session keys (per ADR 0023 D4).
|
|
4
|
-
*/
|
|
5
|
-
import { getSceneIdentityService } from './scene-identity-service.js';
|
|
6
|
-
export function resolveCollaborationSceneContextKey(adapter, sceneId) {
|
|
7
|
-
const svc = getSceneIdentityService();
|
|
8
|
-
const cell = svc.resolveLogicalScene(adapter, sceneId);
|
|
9
|
-
if (cell)
|
|
10
|
-
return `collab-scene:${cell.id}`;
|
|
11
|
-
return `collab-scene:${String(adapter || 'unknown')}:${String(sceneId || 'unknown')}`;
|
|
12
|
-
}
|
|
13
|
-
export function resolveCollaborationSceneContextKeyFromMessage(message) {
|
|
14
|
-
const scope = message.$channel?.type || 'private';
|
|
15
|
-
if (scope !== 'group' && scope !== 'channel')
|
|
16
|
-
return undefined;
|
|
17
|
-
const sceneId = message.$channel?.id;
|
|
18
|
-
if (!sceneId)
|
|
19
|
-
return undefined;
|
|
20
|
-
return resolveCollaborationSceneContextKey(String(message.$adapter || ''), sceneId);
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=scene-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scene-context.js","sourceRoot":"","sources":["../../src/collaboration/scene-context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,MAAM,UAAU,mCAAmC,CAAC,OAAe,EAAE,OAAe;IAClF,MAAM,GAAG,GAAG,uBAAuB,EAAE,CAAC;IACtC,MAAM,IAAI,GAAG,GAAG,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvD,IAAI,IAAI;QAAE,OAAO,gBAAgB,IAAI,CAAC,EAAE,EAAE,CAAC;IAC3C,OAAO,gBAAgB,MAAM,CAAC,OAAO,IAAI,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,IAAI,SAAS,CAAC,EAAE,CAAC;AACxF,CAAC;AAED,MAAM,UAAU,8CAA8C,CAAC,OAI9D;IACC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,IAAI,IAAI,SAAS,CAAC;IAClD,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;IACrC,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,OAAO,mCAAmC,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;AACtF,CAAC"}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SceneIdentityService — 逻辑 Cell 解析 + scene_aliases 管理。
|
|
3
|
-
*
|
|
4
|
-
* 同一物理协作群 = 一个逻辑 Cell + 多 adapter 下的 scene/user 视角表。
|
|
5
|
-
* 入站消息通过 `resolveLogicalScene(adapter, sceneId)` 得到逻辑 Cell。
|
|
6
|
-
*/
|
|
7
|
-
import { type CollaborationScene } from './types.js';
|
|
8
|
-
import { type GenerationStoreContext } from '@zhin.js/plugin-runtime';
|
|
9
|
-
export interface SceneAliasRecord {
|
|
10
|
-
logicalSceneId: string;
|
|
11
|
-
adapter: string;
|
|
12
|
-
sceneId: string;
|
|
13
|
-
}
|
|
14
|
-
export interface InitSessionRecord {
|
|
15
|
-
id: string;
|
|
16
|
-
logicalSceneId: string;
|
|
17
|
-
plannerEndpointKey: string;
|
|
18
|
-
plannerAdapter: string;
|
|
19
|
-
plannerSceneId: string;
|
|
20
|
-
status: string;
|
|
21
|
-
wizardStep: string;
|
|
22
|
-
createdAt: number;
|
|
23
|
-
updatedAt: number;
|
|
24
|
-
}
|
|
25
|
-
export interface InitObservationRecord {
|
|
26
|
-
sessionId: string;
|
|
27
|
-
observerEndpointKey: string;
|
|
28
|
-
observerAdapter: string;
|
|
29
|
-
observerSceneId: string;
|
|
30
|
-
atTargetPlatformId: string;
|
|
31
|
-
wizardStep: string;
|
|
32
|
-
observedAt: number;
|
|
33
|
-
}
|
|
34
|
-
export interface MemberChannelRecord {
|
|
35
|
-
logicalSceneId: string;
|
|
36
|
-
endpointKey: string;
|
|
37
|
-
pipelineRole: string;
|
|
38
|
-
adapter: string;
|
|
39
|
-
sceneId: string;
|
|
40
|
-
botId: string;
|
|
41
|
-
}
|
|
42
|
-
/** 协作群全景图输出格式。 */
|
|
43
|
-
export interface GroupViewAgent {
|
|
44
|
-
name: string;
|
|
45
|
-
channels: Array<{
|
|
46
|
-
adapter: string;
|
|
47
|
-
scene_id: string;
|
|
48
|
-
bot_id: string;
|
|
49
|
-
}>;
|
|
50
|
-
}
|
|
51
|
-
export interface GroupView {
|
|
52
|
-
group_id: string;
|
|
53
|
-
group_name: string;
|
|
54
|
-
agents: GroupViewAgent[];
|
|
55
|
-
}
|
|
56
|
-
type DbModel = {
|
|
57
|
-
select(...fields: string[]): {
|
|
58
|
-
where(condition: Record<string, unknown>): Promise<Record<string, unknown>[]>;
|
|
59
|
-
};
|
|
60
|
-
create(data: Record<string, unknown>): Promise<unknown>;
|
|
61
|
-
update(data: Record<string, unknown>): {
|
|
62
|
-
where(condition: Record<string, unknown>): Promise<unknown>;
|
|
63
|
-
};
|
|
64
|
-
delete?(): {
|
|
65
|
-
where(condition: Record<string, unknown>): Promise<unknown>;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
export declare class SceneIdentityService {
|
|
69
|
-
private sceneModel?;
|
|
70
|
-
private sessionModel?;
|
|
71
|
-
private observationModel?;
|
|
72
|
-
private channelModel?;
|
|
73
|
-
private sceneIndex;
|
|
74
|
-
private memorySessions;
|
|
75
|
-
private memoryObservations;
|
|
76
|
-
private memoryChannels;
|
|
77
|
-
constructor(sceneModel?: DbModel | undefined, sessionModel?: DbModel | undefined, observationModel?: DbModel | undefined, channelModel?: DbModel | undefined);
|
|
78
|
-
private sceneKey;
|
|
79
|
-
loadSceneIndex(): Promise<void>;
|
|
80
|
-
/**
|
|
81
|
-
* 解析逻辑 Cell:先 scene_aliases 表,再 fallback 到 CellService.findByScene。
|
|
82
|
-
*/
|
|
83
|
-
resolveLogicalScene(adapter: string, sceneId: string, endpointKey?: string): CollaborationScene | undefined;
|
|
84
|
-
registerSceneAlias(logicalSceneId: string, adapter: string, sceneId: string): Promise<void>;
|
|
85
|
-
listAliases(logicalSceneId: string): Promise<SceneAliasRecord[]>;
|
|
86
|
-
createInitSession(input: {
|
|
87
|
-
id: string;
|
|
88
|
-
logicalSceneId: string;
|
|
89
|
-
plannerEndpointKey: string;
|
|
90
|
-
plannerAdapter: string;
|
|
91
|
-
plannerSceneId: string;
|
|
92
|
-
}): Promise<InitSessionRecord>;
|
|
93
|
-
getActiveInitSession(adapter: string, sceneId: string): Promise<InitSessionRecord | null>;
|
|
94
|
-
getInitSession(sessionId: string): Promise<InitSessionRecord | null>;
|
|
95
|
-
findActiveInitSessionForScene(adapter: string, sceneId: string): Promise<InitSessionRecord | null>;
|
|
96
|
-
listActiveInitSessions(): Promise<InitSessionRecord[]>;
|
|
97
|
-
/**
|
|
98
|
-
* 入站 bot 查找进行中的 init 向导(stash 阶段)。
|
|
99
|
-
* 1. planner 视角 scene 精确匹配
|
|
100
|
-
* 2. 已有 observation 来自同一 adapter+scene(跨 bot 复用 session)
|
|
101
|
-
* 3. 全局仅一个 wizard session(同物理群跨 adapter 冷启动)
|
|
102
|
-
*/
|
|
103
|
-
findActiveInitSessionForInbound(adapter: string, sceneId: string): Promise<InitSessionRecord | null>;
|
|
104
|
-
updateInitSessionStep(sessionId: string, wizardStep: string): Promise<void>;
|
|
105
|
-
/**
|
|
106
|
-
* CAS 推进向导步骤,避免同一 @ 消息并发处理时连跳两步。
|
|
107
|
-
*/
|
|
108
|
-
advanceInitSessionStepIf(sessionId: string, expectedStep: string, nextStep: string): Promise<boolean>;
|
|
109
|
-
updateInitSessionStatus(sessionId: string, status: string, logicalSceneId?: string): Promise<void>;
|
|
110
|
-
addObservation(input: {
|
|
111
|
-
sessionId: string;
|
|
112
|
-
observerEndpointKey: string;
|
|
113
|
-
observerAdapter: string;
|
|
114
|
-
observerSceneId: string;
|
|
115
|
-
atTargetPlatformId: string;
|
|
116
|
-
wizardStep: string;
|
|
117
|
-
}): Promise<void>;
|
|
118
|
-
listObservations(sessionId: string): Promise<InitObservationRecord[]>;
|
|
119
|
-
/**
|
|
120
|
-
* 从 stash observations 计算 init 计划(不写 Cell / alias / channel)。
|
|
121
|
-
*/
|
|
122
|
-
planInitFromObservations(logicalSceneId: string, observations: InitObservationRecord[], registeredEndpoints: Map<string, {
|
|
123
|
-
adapter: string;
|
|
124
|
-
endpointKey: string;
|
|
125
|
-
}>, options?: {
|
|
126
|
-
plannerEndpointKey?: string;
|
|
127
|
-
}): {
|
|
128
|
-
sceneAliases: SceneAliasRecord[];
|
|
129
|
-
members: Array<{
|
|
130
|
-
endpointKey: string;
|
|
131
|
-
adapter: string;
|
|
132
|
-
pipelineRole: string;
|
|
133
|
-
}>;
|
|
134
|
-
channels: MemberChannelRecord[];
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* /collab inited 一次性提交:写 scene_aliases + member_channels(Cell 由上层 upsert)。
|
|
138
|
-
*/
|
|
139
|
-
commitInitPlan(input: {
|
|
140
|
-
logicalSceneId: string;
|
|
141
|
-
sceneAliases: SceneAliasRecord[];
|
|
142
|
-
channels: MemberChannelRecord[];
|
|
143
|
-
}): Promise<void>;
|
|
144
|
-
/** @deprecated 使用 planInitFromObservations + commitInitPlan */
|
|
145
|
-
aggregateObservations(sessionId: string, logicalSceneId: string, registeredEndpoints: Map<string, {
|
|
146
|
-
adapter: string;
|
|
147
|
-
endpointKey: string;
|
|
148
|
-
}>): Promise<{
|
|
149
|
-
sceneAliases: SceneAliasRecord[];
|
|
150
|
-
members: Array<{
|
|
151
|
-
endpointKey: string;
|
|
152
|
-
adapter: string;
|
|
153
|
-
pipelineRole: string;
|
|
154
|
-
}>;
|
|
155
|
-
channels: MemberChannelRecord[];
|
|
156
|
-
}>;
|
|
157
|
-
saveMemberChannels(logicalSceneId: string, channels: MemberChannelRecord[]): Promise<void>;
|
|
158
|
-
listMemberChannels(logicalSceneId: string): Promise<MemberChannelRecord[]>;
|
|
159
|
-
/**
|
|
160
|
-
* 构建协作群全景图 — 输出 { group_id, group_name, agents[].channels[] }。
|
|
161
|
-
*/
|
|
162
|
-
buildGroupView(logicalSceneId: string, groupName?: string): Promise<GroupView>;
|
|
163
|
-
}
|
|
164
|
-
export declare function getSceneIdentityService(): SceneIdentityService;
|
|
165
|
-
export declare function provideSceneIdentityService(context: GenerationStoreContext, svc: SceneIdentityService): void;
|
|
166
|
-
export declare function setSceneIdentityService(svc: SceneIdentityService | null): void;
|
|
167
|
-
export declare function createSceneIdentityService(sceneModel?: DbModel, sessionModel?: DbModel, observationModel?: DbModel, channelModel?: DbModel): SceneIdentityService;
|
|
168
|
-
export {};
|
|
169
|
-
//# sourceMappingURL=scene-identity-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scene-identity-service.d.ts","sourceRoot":"","sources":["../../src/collaboration/scene-identity-service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,kBAAkB,EAAkB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAyB,KAAK,sBAAsB,EAAgB,MAAM,yBAAyB,CAAC;AAQ3G,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;A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AY,CAAC,EAAE,OAAO,EACtB,gBAAgB,CAAC,EAAE,OAAO,EAC1B,YAAY,CAAC,EAAE,OAAO,GACrB,oBAAoB,CAEtB"}
|
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SceneIdentityService — 逻辑 Cell 解析 + scene_aliases 管理。
|
|
3
|
-
*
|
|
4
|
-
* 同一物理协作群 = 一个逻辑 Cell + 多 adapter 下的 scene/user 视角表。
|
|
5
|
-
* 入站消息通过 `resolveLogicalScene(adapter, sceneId)` 得到逻辑 Cell。
|
|
6
|
-
*/
|
|
7
|
-
import { isPipelineRole } from './types.js';
|
|
8
|
-
import { createGenerationStore, DisposeStack } from '@zhin.js/plugin-runtime';
|
|
9
|
-
import { getCollaborationSceneService } from './scene-service.js';
|
|
10
|
-
function rowToSceneAlias(row) {
|
|
11
|
-
return {
|
|
12
|
-
logicalSceneId: String(row.logical_scene_id ?? ''),
|
|
13
|
-
adapter: String(row.adapter ?? ''),
|
|
14
|
-
sceneId: String(row.scene_id ?? ''),
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function rowToInitSession(row) {
|
|
18
|
-
return {
|
|
19
|
-
id: String(row.id ?? ''),
|
|
20
|
-
logicalSceneId: String(row.logical_scene_id ?? ''),
|
|
21
|
-
plannerEndpointKey: String(row.planner_endpoint_id ?? ''),
|
|
22
|
-
plannerAdapter: String(row.planner_adapter ?? ''),
|
|
23
|
-
plannerSceneId: String(row.planner_scene_id ?? ''),
|
|
24
|
-
status: String(row.status ?? ''),
|
|
25
|
-
wizardStep: String(row.wizard_step ?? ''),
|
|
26
|
-
createdAt: Number(row.created_at ?? 0),
|
|
27
|
-
updatedAt: Number(row.updated_at ?? 0),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function rowToObservation(row) {
|
|
31
|
-
return {
|
|
32
|
-
sessionId: String(row.session_id ?? ''),
|
|
33
|
-
observerEndpointKey: String(row.observer_endpoint_id ?? ''),
|
|
34
|
-
observerAdapter: String(row.observer_adapter ?? ''),
|
|
35
|
-
observerSceneId: String(row.observer_scene_id ?? ''),
|
|
36
|
-
atTargetPlatformId: String(row.at_target_platform_id ?? ''),
|
|
37
|
-
wizardStep: String(row.wizard_step ?? ''),
|
|
38
|
-
observedAt: Number(row.observed_at ?? 0),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export class SceneIdentityService {
|
|
42
|
-
sceneModel;
|
|
43
|
-
sessionModel;
|
|
44
|
-
observationModel;
|
|
45
|
-
channelModel;
|
|
46
|
-
sceneIndex = new Map();
|
|
47
|
-
memorySessions = new Map();
|
|
48
|
-
memoryObservations = [];
|
|
49
|
-
memoryChannels = [];
|
|
50
|
-
constructor(sceneModel, sessionModel, observationModel, channelModel) {
|
|
51
|
-
this.sceneModel = sceneModel;
|
|
52
|
-
this.sessionModel = sessionModel;
|
|
53
|
-
this.observationModel = observationModel;
|
|
54
|
-
this.channelModel = channelModel;
|
|
55
|
-
}
|
|
56
|
-
sceneKey(adapter, sceneId) {
|
|
57
|
-
return `${adapter}:${sceneId}`;
|
|
58
|
-
}
|
|
59
|
-
async loadSceneIndex() {
|
|
60
|
-
this.sceneIndex.clear();
|
|
61
|
-
if (!this.sceneModel)
|
|
62
|
-
return;
|
|
63
|
-
const rows = await this.sceneModel.select().where({});
|
|
64
|
-
for (const row of rows) {
|
|
65
|
-
const alias = rowToSceneAlias(row);
|
|
66
|
-
this.sceneIndex.set(this.sceneKey(alias.adapter, alias.sceneId), alias.logicalSceneId);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* 解析逻辑 Cell:先 scene_aliases 表,再 fallback 到 CellService.findByScene。
|
|
71
|
-
*/
|
|
72
|
-
resolveLogicalScene(adapter, sceneId, endpointKey) {
|
|
73
|
-
const svc = getCollaborationSceneService();
|
|
74
|
-
const logicalSceneId = this.sceneIndex.get(this.sceneKey(adapter, sceneId));
|
|
75
|
-
if (logicalSceneId) {
|
|
76
|
-
const cell = svc.getScene(logicalSceneId);
|
|
77
|
-
if (cell)
|
|
78
|
-
return cell;
|
|
79
|
-
}
|
|
80
|
-
const direct = svc.findByScene(adapter, sceneId);
|
|
81
|
-
if (direct)
|
|
82
|
-
return direct;
|
|
83
|
-
if (!endpointKey)
|
|
84
|
-
return undefined;
|
|
85
|
-
return svc.listScenes().find((c) => c.members.some((m) => m.endpointKey === endpointKey && (m.adapter ?? c.adapter) === adapter));
|
|
86
|
-
}
|
|
87
|
-
async registerSceneAlias(logicalSceneId, adapter, sceneId) {
|
|
88
|
-
const key = this.sceneKey(adapter, sceneId);
|
|
89
|
-
if (this.sceneIndex.get(key) === logicalSceneId)
|
|
90
|
-
return;
|
|
91
|
-
this.sceneIndex.set(key, logicalSceneId);
|
|
92
|
-
if (!this.sceneModel)
|
|
93
|
-
return;
|
|
94
|
-
const existing = await this.sceneModel.select().where({ adapter, scene_id: sceneId });
|
|
95
|
-
if (existing.length > 0) {
|
|
96
|
-
await this.sceneModel.update({ logical_scene_id: logicalSceneId }).where({ adapter, scene_id: sceneId });
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
await this.sceneModel.create({
|
|
100
|
-
logical_scene_id: logicalSceneId,
|
|
101
|
-
adapter,
|
|
102
|
-
scene_id: sceneId,
|
|
103
|
-
created_at: Date.now(),
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
async listAliases(logicalSceneId) {
|
|
108
|
-
const out = [];
|
|
109
|
-
for (const [key, collaborationSceneId] of this.sceneIndex) {
|
|
110
|
-
if (collaborationSceneId !== logicalSceneId)
|
|
111
|
-
continue;
|
|
112
|
-
const [adapter, ...rest] = key.split(':');
|
|
113
|
-
out.push({ logicalSceneId: collaborationSceneId, adapter: adapter, sceneId: rest.join(':') });
|
|
114
|
-
}
|
|
115
|
-
return out;
|
|
116
|
-
}
|
|
117
|
-
// ─── Init session management ───
|
|
118
|
-
async createInitSession(input) {
|
|
119
|
-
const now = Date.now();
|
|
120
|
-
const record = {
|
|
121
|
-
id: input.id,
|
|
122
|
-
logicalSceneId: input.logicalSceneId,
|
|
123
|
-
plannerEndpointKey: input.plannerEndpointKey,
|
|
124
|
-
plannerAdapter: input.plannerAdapter,
|
|
125
|
-
plannerSceneId: input.plannerSceneId,
|
|
126
|
-
status: 'wizard',
|
|
127
|
-
wizardStep: 'researcher',
|
|
128
|
-
createdAt: now,
|
|
129
|
-
updatedAt: now,
|
|
130
|
-
};
|
|
131
|
-
this.memorySessions.set(input.id, record);
|
|
132
|
-
if (this.sessionModel) {
|
|
133
|
-
await this.sessionModel.create({
|
|
134
|
-
id: record.id,
|
|
135
|
-
logical_scene_id: record.logicalSceneId,
|
|
136
|
-
planner_endpoint_id: record.plannerEndpointKey,
|
|
137
|
-
planner_adapter: record.plannerAdapter,
|
|
138
|
-
planner_scene_id: record.plannerSceneId,
|
|
139
|
-
status: record.status,
|
|
140
|
-
wizard_step: record.wizardStep,
|
|
141
|
-
created_at: now,
|
|
142
|
-
updated_at: now,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
return record;
|
|
146
|
-
}
|
|
147
|
-
async getActiveInitSession(adapter, sceneId) {
|
|
148
|
-
if (this.sessionModel) {
|
|
149
|
-
const rows = await this.sessionModel.select().where({
|
|
150
|
-
planner_adapter: adapter,
|
|
151
|
-
planner_scene_id: sceneId,
|
|
152
|
-
status: 'wizard',
|
|
153
|
-
});
|
|
154
|
-
if (rows.length > 0)
|
|
155
|
-
return rowToInitSession(rows[0]);
|
|
156
|
-
}
|
|
157
|
-
for (const s of this.memorySessions.values()) {
|
|
158
|
-
if (s.plannerAdapter === adapter && s.plannerSceneId === sceneId && s.status === 'wizard') {
|
|
159
|
-
return s;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
async getInitSession(sessionId) {
|
|
165
|
-
const mem = this.memorySessions.get(sessionId);
|
|
166
|
-
if (mem)
|
|
167
|
-
return mem;
|
|
168
|
-
if (!this.sessionModel)
|
|
169
|
-
return null;
|
|
170
|
-
const rows = await this.sessionModel.select().where({ id: sessionId });
|
|
171
|
-
if (rows.length === 0)
|
|
172
|
-
return null;
|
|
173
|
-
return rowToInitSession(rows[0]);
|
|
174
|
-
}
|
|
175
|
-
async findActiveInitSessionForScene(adapter, sceneId) {
|
|
176
|
-
return this.findActiveInitSessionForInbound(adapter, sceneId);
|
|
177
|
-
}
|
|
178
|
-
async listActiveInitSessions() {
|
|
179
|
-
const out = [];
|
|
180
|
-
if (this.sessionModel) {
|
|
181
|
-
const rows = await this.sessionModel.select().where({ status: 'wizard' });
|
|
182
|
-
for (const row of rows)
|
|
183
|
-
out.push(rowToInitSession(row));
|
|
184
|
-
}
|
|
185
|
-
for (const s of this.memorySessions.values()) {
|
|
186
|
-
if (s.status !== 'wizard')
|
|
187
|
-
continue;
|
|
188
|
-
if (!out.some((x) => x.id === s.id))
|
|
189
|
-
out.push(s);
|
|
190
|
-
}
|
|
191
|
-
return out;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* 入站 bot 查找进行中的 init 向导(stash 阶段)。
|
|
195
|
-
* 1. planner 视角 scene 精确匹配
|
|
196
|
-
* 2. 已有 observation 来自同一 adapter+scene(跨 bot 复用 session)
|
|
197
|
-
* 3. 全局仅一个 wizard session(同物理群跨 adapter 冷启动)
|
|
198
|
-
*/
|
|
199
|
-
async findActiveInitSessionForInbound(adapter, sceneId) {
|
|
200
|
-
const direct = await this.getActiveInitSession(adapter, sceneId);
|
|
201
|
-
if (direct)
|
|
202
|
-
return direct;
|
|
203
|
-
const sessions = await this.listActiveInitSessions();
|
|
204
|
-
for (const session of sessions) {
|
|
205
|
-
const obs = await this.listObservations(session.id);
|
|
206
|
-
if (obs.some((o) => o.observerAdapter === adapter && o.observerSceneId === sceneId)) {
|
|
207
|
-
return session;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
if (sessions.length === 1)
|
|
211
|
-
return sessions[0];
|
|
212
|
-
return null;
|
|
213
|
-
}
|
|
214
|
-
async updateInitSessionStep(sessionId, wizardStep) {
|
|
215
|
-
const mem = this.memorySessions.get(sessionId);
|
|
216
|
-
if (mem) {
|
|
217
|
-
mem.wizardStep = wizardStep;
|
|
218
|
-
mem.updatedAt = Date.now();
|
|
219
|
-
}
|
|
220
|
-
if (this.sessionModel) {
|
|
221
|
-
await this.sessionModel.update({
|
|
222
|
-
wizard_step: wizardStep,
|
|
223
|
-
updated_at: Date.now(),
|
|
224
|
-
}).where({ id: sessionId });
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* CAS 推进向导步骤,避免同一 @ 消息并发处理时连跳两步。
|
|
229
|
-
*/
|
|
230
|
-
async advanceInitSessionStepIf(sessionId, expectedStep, nextStep) {
|
|
231
|
-
const mem = this.memorySessions.get(sessionId);
|
|
232
|
-
if (mem) {
|
|
233
|
-
if (mem.wizardStep !== expectedStep)
|
|
234
|
-
return false;
|
|
235
|
-
mem.wizardStep = nextStep;
|
|
236
|
-
mem.updatedAt = Date.now();
|
|
237
|
-
}
|
|
238
|
-
else if (this.sessionModel) {
|
|
239
|
-
const rows = await this.sessionModel.select().where({
|
|
240
|
-
id: sessionId,
|
|
241
|
-
wizard_step: expectedStep,
|
|
242
|
-
status: 'wizard',
|
|
243
|
-
});
|
|
244
|
-
if (rows.length === 0)
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
return false;
|
|
249
|
-
}
|
|
250
|
-
if (this.sessionModel) {
|
|
251
|
-
await this.sessionModel.update({
|
|
252
|
-
wizard_step: nextStep,
|
|
253
|
-
updated_at: Date.now(),
|
|
254
|
-
}).where({ id: sessionId, wizard_step: expectedStep });
|
|
255
|
-
}
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
async updateInitSessionStatus(sessionId, status, logicalSceneId) {
|
|
259
|
-
const mem = this.memorySessions.get(sessionId);
|
|
260
|
-
if (mem) {
|
|
261
|
-
mem.status = status;
|
|
262
|
-
mem.updatedAt = Date.now();
|
|
263
|
-
if (logicalSceneId)
|
|
264
|
-
mem.logicalSceneId = logicalSceneId;
|
|
265
|
-
}
|
|
266
|
-
if (this.sessionModel) {
|
|
267
|
-
const patch = { status, updated_at: Date.now() };
|
|
268
|
-
if (logicalSceneId)
|
|
269
|
-
patch.logical_scene_id = logicalSceneId;
|
|
270
|
-
await this.sessionModel.update(patch).where({ id: sessionId });
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
// ─── Observation management ───
|
|
274
|
-
async addObservation(input) {
|
|
275
|
-
const record = {
|
|
276
|
-
sessionId: input.sessionId,
|
|
277
|
-
observerEndpointKey: input.observerEndpointKey,
|
|
278
|
-
observerAdapter: input.observerAdapter,
|
|
279
|
-
observerSceneId: input.observerSceneId,
|
|
280
|
-
atTargetPlatformId: input.atTargetPlatformId,
|
|
281
|
-
wizardStep: input.wizardStep,
|
|
282
|
-
observedAt: Date.now(),
|
|
283
|
-
};
|
|
284
|
-
this.memoryObservations.push(record);
|
|
285
|
-
if (this.observationModel) {
|
|
286
|
-
await this.observationModel.create({
|
|
287
|
-
session_id: record.sessionId,
|
|
288
|
-
observer_endpoint_id: record.observerEndpointKey,
|
|
289
|
-
observer_adapter: record.observerAdapter,
|
|
290
|
-
observer_scene_id: record.observerSceneId,
|
|
291
|
-
at_target_platform_id: record.atTargetPlatformId,
|
|
292
|
-
wizard_step: record.wizardStep,
|
|
293
|
-
observed_at: record.observedAt,
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
async listObservations(sessionId) {
|
|
298
|
-
if (this.observationModel) {
|
|
299
|
-
const rows = await this.observationModel.select().where({ session_id: sessionId });
|
|
300
|
-
return rows.map(rowToObservation);
|
|
301
|
-
}
|
|
302
|
-
return this.memoryObservations.filter((o) => o.sessionId === sessionId);
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* 从 stash observations 计算 init 计划(不写 Cell / alias / channel)。
|
|
306
|
-
*/
|
|
307
|
-
planInitFromObservations(logicalSceneId, observations, registeredEndpoints, options) {
|
|
308
|
-
const sceneSet = new Map();
|
|
309
|
-
for (const obs of observations) {
|
|
310
|
-
const key = this.sceneKey(obs.observerAdapter, obs.observerSceneId);
|
|
311
|
-
if (!sceneSet.has(key)) {
|
|
312
|
-
sceneSet.set(key, {
|
|
313
|
-
logicalSceneId,
|
|
314
|
-
adapter: obs.observerAdapter,
|
|
315
|
-
sceneId: obs.observerSceneId,
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
const roleMap = new Map();
|
|
320
|
-
const channelDedup = new Set();
|
|
321
|
-
const channels = [];
|
|
322
|
-
const roleObs = options?.plannerEndpointKey
|
|
323
|
-
? observations.filter((o) => o.observerEndpointKey === options.plannerEndpointKey)
|
|
324
|
-
: observations;
|
|
325
|
-
const assignRole = (obs) => {
|
|
326
|
-
if (!obs.wizardStep || !obs.atTargetPlatformId)
|
|
327
|
-
return;
|
|
328
|
-
if (!isPipelineRole(obs.wizardStep))
|
|
329
|
-
return;
|
|
330
|
-
const ep = registeredEndpoints.get(obs.atTargetPlatformId);
|
|
331
|
-
if (!ep)
|
|
332
|
-
return;
|
|
333
|
-
if (roleMap.has(obs.wizardStep))
|
|
334
|
-
return;
|
|
335
|
-
roleMap.set(obs.wizardStep, {
|
|
336
|
-
endpointKey: ep.endpointKey,
|
|
337
|
-
adapter: ep.adapter,
|
|
338
|
-
pipelineRole: obs.wizardStep,
|
|
339
|
-
});
|
|
340
|
-
};
|
|
341
|
-
for (const obs of roleObs)
|
|
342
|
-
assignRole(obs);
|
|
343
|
-
if (options?.plannerEndpointKey) {
|
|
344
|
-
for (const obs of observations)
|
|
345
|
-
assignRole(obs);
|
|
346
|
-
}
|
|
347
|
-
for (const obs of observations) {
|
|
348
|
-
if (!obs.wizardStep || !obs.atTargetPlatformId)
|
|
349
|
-
continue;
|
|
350
|
-
if (!isPipelineRole(obs.wizardStep))
|
|
351
|
-
continue;
|
|
352
|
-
const ep = registeredEndpoints.get(obs.atTargetPlatformId);
|
|
353
|
-
if (!ep)
|
|
354
|
-
continue;
|
|
355
|
-
const chKey = `${obs.wizardStep}:${obs.observerAdapter}:${obs.observerSceneId}:${obs.atTargetPlatformId}`;
|
|
356
|
-
if (!channelDedup.has(chKey)) {
|
|
357
|
-
channelDedup.add(chKey);
|
|
358
|
-
channels.push({
|
|
359
|
-
logicalSceneId,
|
|
360
|
-
endpointKey: ep.endpointKey,
|
|
361
|
-
pipelineRole: obs.wizardStep,
|
|
362
|
-
adapter: obs.observerAdapter,
|
|
363
|
-
sceneId: obs.observerSceneId,
|
|
364
|
-
botId: obs.atTargetPlatformId,
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
return {
|
|
369
|
-
sceneAliases: [...sceneSet.values()],
|
|
370
|
-
members: [...roleMap.values()],
|
|
371
|
-
channels,
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* /collab inited 一次性提交:写 scene_aliases + member_channels(Cell 由上层 upsert)。
|
|
376
|
-
*/
|
|
377
|
-
async commitInitPlan(input) {
|
|
378
|
-
for (const alias of input.sceneAliases) {
|
|
379
|
-
await this.registerSceneAlias(input.logicalSceneId, alias.adapter, alias.sceneId);
|
|
380
|
-
}
|
|
381
|
-
await this.saveMemberChannels(input.logicalSceneId, input.channels);
|
|
382
|
-
}
|
|
383
|
-
/** @deprecated 使用 planInitFromObservations + commitInitPlan */
|
|
384
|
-
async aggregateObservations(sessionId, logicalSceneId, registeredEndpoints) {
|
|
385
|
-
const observations = await this.listObservations(sessionId);
|
|
386
|
-
const plan = this.planInitFromObservations(logicalSceneId, observations, registeredEndpoints);
|
|
387
|
-
await this.commitInitPlan({
|
|
388
|
-
logicalSceneId,
|
|
389
|
-
sceneAliases: plan.sceneAliases,
|
|
390
|
-
channels: plan.channels,
|
|
391
|
-
});
|
|
392
|
-
return plan;
|
|
393
|
-
}
|
|
394
|
-
// ─── Member channel (identity edge) management ───
|
|
395
|
-
async saveMemberChannels(logicalSceneId, channels) {
|
|
396
|
-
this.memoryChannels = this.memoryChannels.filter((c) => c.logicalSceneId !== logicalSceneId);
|
|
397
|
-
this.memoryChannels.push(...channels);
|
|
398
|
-
if (!this.channelModel)
|
|
399
|
-
return;
|
|
400
|
-
if (this.channelModel.delete) {
|
|
401
|
-
await this.channelModel.delete().where({ logical_scene_id: logicalSceneId });
|
|
402
|
-
}
|
|
403
|
-
for (const ch of channels) {
|
|
404
|
-
await this.channelModel.create({
|
|
405
|
-
logical_scene_id: ch.logicalSceneId,
|
|
406
|
-
endpoint_id: ch.endpointKey,
|
|
407
|
-
pipeline_role: ch.pipelineRole,
|
|
408
|
-
adapter: ch.adapter,
|
|
409
|
-
scene_id: ch.sceneId,
|
|
410
|
-
bot_id: ch.botId,
|
|
411
|
-
created_at: Date.now(),
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
async listMemberChannels(logicalSceneId) {
|
|
416
|
-
if (this.channelModel) {
|
|
417
|
-
const rows = await this.channelModel.select().where({ logical_scene_id: logicalSceneId });
|
|
418
|
-
return rows.map((row) => ({
|
|
419
|
-
logicalSceneId: String(row.logical_scene_id ?? ''),
|
|
420
|
-
endpointKey: String(row.endpoint_id ?? ''),
|
|
421
|
-
pipelineRole: String(row.pipeline_role ?? ''),
|
|
422
|
-
adapter: String(row.adapter ?? ''),
|
|
423
|
-
sceneId: String(row.scene_id ?? ''),
|
|
424
|
-
botId: String(row.bot_id ?? ''),
|
|
425
|
-
}));
|
|
426
|
-
}
|
|
427
|
-
return this.memoryChannels.filter((c) => c.logicalSceneId === logicalSceneId);
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* 构建协作群全景图 — 输出 { group_id, group_name, agents[].channels[] }。
|
|
431
|
-
*/
|
|
432
|
-
async buildGroupView(logicalSceneId, groupName) {
|
|
433
|
-
const channels = await this.listMemberChannels(logicalSceneId);
|
|
434
|
-
const cellSvc = getCollaborationSceneService();
|
|
435
|
-
const cell = cellSvc.getScene(logicalSceneId);
|
|
436
|
-
const agentMap = new Map();
|
|
437
|
-
for (const ch of channels) {
|
|
438
|
-
let agent = agentMap.get(ch.pipelineRole);
|
|
439
|
-
if (!agent) {
|
|
440
|
-
agent = { name: ch.pipelineRole, channels: [] };
|
|
441
|
-
agentMap.set(ch.pipelineRole, agent);
|
|
442
|
-
}
|
|
443
|
-
agent.channels.push({
|
|
444
|
-
adapter: ch.adapter,
|
|
445
|
-
scene_id: ch.sceneId,
|
|
446
|
-
bot_id: ch.botId,
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
return {
|
|
450
|
-
group_id: logicalSceneId,
|
|
451
|
-
group_name: groupName ?? cell?.goal ?? '',
|
|
452
|
-
agents: [...agentMap.values()],
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
const sceneIdentityStore = createGenerationStore('zhin.agent.scene-identity-service');
|
|
457
|
-
let _fallbackSceneIdentity = null;
|
|
458
|
-
export function getSceneIdentityService() {
|
|
459
|
-
return sceneIdentityStore.tryUse() ?? (_fallbackSceneIdentity ??= new SceneIdentityService());
|
|
460
|
-
}
|
|
461
|
-
export function provideSceneIdentityService(context, svc) {
|
|
462
|
-
sceneIdentityStore.provide(context, svc);
|
|
463
|
-
}
|
|
464
|
-
let _sceneIdentityLegacy = null;
|
|
465
|
-
export function setSceneIdentityService(svc) {
|
|
466
|
-
if (_sceneIdentityLegacy) {
|
|
467
|
-
void _sceneIdentityLegacy.dispose();
|
|
468
|
-
_sceneIdentityLegacy = null;
|
|
469
|
-
}
|
|
470
|
-
_fallbackSceneIdentity = null;
|
|
471
|
-
if (svc) {
|
|
472
|
-
_sceneIdentityLegacy = new DisposeStack();
|
|
473
|
-
sceneIdentityStore.provide({ lifecycle: _sceneIdentityLegacy }, svc);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
export function createSceneIdentityService(sceneModel, sessionModel, observationModel, channelModel) {
|
|
477
|
-
return new SceneIdentityService(sceneModel, sessionModel, observationModel, channelModel);
|
|
478
|
-
}
|
|
479
|
-
//# sourceMappingURL=scene-identity-service.js.map
|