@openlife/cli 1.7.3
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/INSTALL.md +266 -0
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/bin/openlife.js +3 -0
- package/dist/admin_panel_server.js +66 -0
- package/dist/cli/AgentManager.js +109 -0
- package/dist/cli/AutonomousInstaller.js +134 -0
- package/dist/cli/DreamOrganizer.js +88 -0
- package/dist/cli/HostInstaller.js +426 -0
- package/dist/cli/InstallBanner.js +16 -0
- package/dist/cli/InstallFlow.js +256 -0
- package/dist/cli/InstallHeadless.js +47 -0
- package/dist/cli/InstallModules.js +148 -0
- package/dist/cli/InstallStateStore.js +75 -0
- package/dist/cli/InstallWizard.js +364 -0
- package/dist/cli/ProfileManager.js +163 -0
- package/dist/cli/SystemInstaller.js +89 -0
- package/dist/cli/WorldClassCommands.js +208 -0
- package/dist/design/DesignMdImporter.js +82 -0
- package/dist/design/DesignMdMode.js +93 -0
- package/dist/design/DesignMdRegistry.js +67 -0
- package/dist/index.js +2575 -0
- package/dist/memory/ConversationMemory.js +33 -0
- package/dist/memory/LocalMemoryProvider.js +86 -0
- package/dist/memory/Mem0Provider.js +16 -0
- package/dist/memory/MemoryNamespacePolicy.js +27 -0
- package/dist/memory/MemoryOrchestrator.js +65 -0
- package/dist/memory/MemoryPromotionFlow.js +32 -0
- package/dist/memory/MemoryProvider.js +2 -0
- package/dist/memory/MemoryProviderRegistry.js +27 -0
- package/dist/memory/MemoryRetentionPolicy.js +60 -0
- package/dist/memory/MempalaceProvider.js +72 -0
- package/dist/memory/OmniMemory.js +106 -0
- package/dist/memory/RedisAgentMemoryProvider.js +16 -0
- package/dist/memory/SessionManager.js +86 -0
- package/dist/memory/ZepGraphitiProvider.js +16 -0
- package/dist/orchestrator/AgentRegistry.js +56 -0
- package/dist/orchestrator/AgentScoring.js +82 -0
- package/dist/orchestrator/AgentTeam.js +22 -0
- package/dist/orchestrator/ArbitrationAgent.js +43 -0
- package/dist/orchestrator/ArbitrationScorecard.js +17 -0
- package/dist/orchestrator/AssetPromotionEngine.js +65 -0
- package/dist/orchestrator/AssetReuseRouter.js +63 -0
- package/dist/orchestrator/BenchmarkEngine.js +75 -0
- package/dist/orchestrator/Brain.js +298 -0
- package/dist/orchestrator/CadenceEngine.js +76 -0
- package/dist/orchestrator/CapabilityRouter.js +36 -0
- package/dist/orchestrator/CommandLanguage.js +27 -0
- package/dist/orchestrator/CommandRouter.js +70 -0
- package/dist/orchestrator/ConsequenceForecaster.js +286 -0
- package/dist/orchestrator/CronManager.js +286 -0
- package/dist/orchestrator/DynamicAgentBuilder.js +48 -0
- package/dist/orchestrator/DynamicAgentExecutor.js +15 -0
- package/dist/orchestrator/EnterpriseAgenticCore.js +276 -0
- package/dist/orchestrator/ExecutionBoard.js +86 -0
- package/dist/orchestrator/ExecutionIntent.js +13 -0
- package/dist/orchestrator/ExecutionModePolicy.js +48 -0
- package/dist/orchestrator/ExecutionRouter.js +9 -0
- package/dist/orchestrator/ExecutionState.js +20 -0
- package/dist/orchestrator/ExecutorHealth.js +86 -0
- package/dist/orchestrator/ExternalCatalogRegistry.js +83 -0
- package/dist/orchestrator/Gatekeeper.js +414 -0
- package/dist/orchestrator/Gateway.js +508 -0
- package/dist/orchestrator/GovernanceConsentStore.js +66 -0
- package/dist/orchestrator/GovernanceLayer.js +179 -0
- package/dist/orchestrator/GovernancePolicyStore.js +53 -0
- package/dist/orchestrator/GovernanceScopeLedger.js +134 -0
- package/dist/orchestrator/GovernanceScopePolicy.js +67 -0
- package/dist/orchestrator/IntentClassifier.js +45 -0
- package/dist/orchestrator/JobLifecycle.js +91 -0
- package/dist/orchestrator/LearningRouter.js +24 -0
- package/dist/orchestrator/MediaManager.js +92 -0
- package/dist/orchestrator/MemoryCuratorAgent.js +41 -0
- package/dist/orchestrator/MissionState.js +155 -0
- package/dist/orchestrator/ModelManager.js +84 -0
- package/dist/orchestrator/OperatingSystem.js +71 -0
- package/dist/orchestrator/OperationalMemoryStore.js +94 -0
- package/dist/orchestrator/OptimizationLoop.js +72 -0
- package/dist/orchestrator/OrchestrationLoop.js +905 -0
- package/dist/orchestrator/OrgStructure.js +88 -0
- package/dist/orchestrator/OutcomeSimulator.js +46 -0
- package/dist/orchestrator/ParallelOrchestrationLoop.js +36 -0
- package/dist/orchestrator/PerformanceScorecard.js +105 -0
- package/dist/orchestrator/PlannerAgent.js +46 -0
- package/dist/orchestrator/ProcessSandbox.js +129 -0
- package/dist/orchestrator/PromotionPipeline.js +74 -0
- package/dist/orchestrator/PromotionReviewGate.js +11 -0
- package/dist/orchestrator/QueueScheduler.js +260 -0
- package/dist/orchestrator/ReleaseGate.js +36 -0
- package/dist/orchestrator/ReleaseWorkflow.js +68 -0
- package/dist/orchestrator/RemotePublisher.js +139 -0
- package/dist/orchestrator/ReuseEngine.js +89 -0
- package/dist/orchestrator/ReviewerAgent.js +49 -0
- package/dist/orchestrator/RoleHandoff.js +65 -0
- package/dist/orchestrator/RuntimeHealthMonitor.js +143 -0
- package/dist/orchestrator/RuntimePolicy.js +105 -0
- package/dist/orchestrator/RuntimeProbe.js +97 -0
- package/dist/orchestrator/RuntimeRegistry.js +73 -0
- package/dist/orchestrator/SandboxPolicy.js +22 -0
- package/dist/orchestrator/SecurityDownloadGuard.js +169 -0
- package/dist/orchestrator/SecurityEventStore.js +58 -0
- package/dist/orchestrator/ServiceCompletionPolicy.js +36 -0
- package/dist/orchestrator/ServiceState.js +195 -0
- package/dist/orchestrator/SkillCreator.js +404 -0
- package/dist/orchestrator/SkillLearningLoop.js +57 -0
- package/dist/orchestrator/SkillManager.js +75 -0
- package/dist/orchestrator/SkillNetwork.js +29 -0
- package/dist/orchestrator/SkillRegistryV2.js +28 -0
- package/dist/orchestrator/SkillScoring.js +70 -0
- package/dist/orchestrator/SquadAutoCreator.js +64 -0
- package/dist/orchestrator/SquadCreator.js +727 -0
- package/dist/orchestrator/SquadRegistry.js +28 -0
- package/dist/orchestrator/SquadRouter.js +33 -0
- package/dist/orchestrator/SquadScoring.js +70 -0
- package/dist/orchestrator/SubagentLifecycle.js +90 -0
- package/dist/orchestrator/SynthesizerAgent.js +48 -0
- package/dist/orchestrator/SystemDoctor.js +224 -0
- package/dist/orchestrator/TaskExecutor.js +422 -0
- package/dist/orchestrator/TeammateBoard.js +61 -0
- package/dist/orchestrator/TestHarness.js +184 -0
- package/dist/orchestrator/VoiceManager.js +203 -0
- package/dist/orchestrator/VoiceRouter.js +89 -0
- package/dist/orchestrator/capability/CapabilityGenesisEngine.js +278 -0
- package/dist/orchestrator/capability/CapabilityPackParser.js +223 -0
- package/dist/orchestrator/capability/CapabilityPackSchema.js +62 -0
- package/dist/orchestrator/capability/CapabilityPackState.js +163 -0
- package/dist/orchestrator/providers/AgentProvider.js +2 -0
- package/dist/orchestrator/providers/CapabilityProvider.js +12 -0
- package/dist/orchestrator/providers/CloudAgentProvider.js +55 -0
- package/dist/orchestrator/providers/CloudSkillProvider.js +55 -0
- package/dist/orchestrator/providers/CloudSquadProvider.js +55 -0
- package/dist/orchestrator/providers/CompositeAgentProvider.js +16 -0
- package/dist/orchestrator/providers/CompositeCapabilityProvider.js +25 -0
- package/dist/orchestrator/providers/CompositeSkillProvider.js +16 -0
- package/dist/orchestrator/providers/CompositeSquadProvider.js +16 -0
- package/dist/orchestrator/providers/CompositeWorkflowProvider.js +46 -0
- package/dist/orchestrator/providers/FileAgentProvider.js +105 -0
- package/dist/orchestrator/providers/FileCapabilityProvider.js +106 -0
- package/dist/orchestrator/providers/FileSkillProvider.js +65 -0
- package/dist/orchestrator/providers/FileSquadProvider.js +69 -0
- package/dist/orchestrator/providers/FileWorkflowProvider.js +103 -0
- package/dist/orchestrator/providers/SkillProvider.js +2 -0
- package/dist/orchestrator/providers/SquadProvider.js +2 -0
- package/dist/orchestrator/toolset/ToolsetGuard.js +69 -0
- package/dist/orchestrator/toolset/ToolsetRegistry.js +65 -0
- package/dist/orchestrator/toolset/ToolsetSchema.js +21 -0
- package/dist/orchestrator/util/AtomicWriter.js +204 -0
- package/dist/orchestrator/util/DistributedLock.js +232 -0
- package/dist/orchestrator/util/TemplateRenderer.js +87 -0
- package/dist/orchestrator/util/WatchdogHeartbeat.js +116 -0
- package/dist/orchestrator/workflow/ConditionParser.js +232 -0
- package/dist/orchestrator/workflow/WorkflowEngine.js +379 -0
- package/dist/orchestrator/workflow/WorkflowParser.js +368 -0
- package/dist/orchestrator/workflow/WorkflowSchema.js +65 -0
- package/dist/orchestrator/workflow/WorkflowState.js +11 -0
- package/dist/reversa/ReversaAgent.js +134 -0
- package/dist/reversa/ReversaContracts.js +62 -0
- package/dist/reversa/ReversaExecutors.js +65 -0
- package/dist/skills/SkillRegistry.js +71 -0
- package/dist/squads/SquadManager.js +87 -0
- package/dist/test_admin_teams_networks.js +54 -0
- package/dist/test_agent_team_skill_network.js +15 -0
- package/dist/test_aiobuilder_cli_parity.js +169 -0
- package/dist/test_ask_exit.js +73 -0
- package/dist/test_atomic_writer.js +209 -0
- package/dist/test_autonomous_soak.js +141 -0
- package/dist/test_benchmark_engine.js +41 -0
- package/dist/test_brain_error_diagnostics.js +51 -0
- package/dist/test_brain_fallback_chain.js +93 -0
- package/dist/test_capability_genesis_engine.js +225 -0
- package/dist/test_capability_pack_schema.js +214 -0
- package/dist/test_catalog_quality.js +150 -0
- package/dist/test_cli_crud_roundtrip.js +154 -0
- package/dist/test_cli_diagnostics.js +131 -0
- package/dist/test_cli_doc_parity.js +126 -0
- package/dist/test_cli_help_surface.js +106 -0
- package/dist/test_cli_service_commands.js +83 -0
- package/dist/test_consequence_forecast_brain.js +165 -0
- package/dist/test_consequence_forecaster.js +24 -0
- package/dist/test_conversation_memory.js +36 -0
- package/dist/test_create_entities.js +54 -0
- package/dist/test_creator_placeholders_completed.js +177 -0
- package/dist/test_cron_manager.js +123 -0
- package/dist/test_daemon_sigterm.js +72 -0
- package/dist/test_deep_research_capability.js +87 -0
- package/dist/test_designmd_import_registry.js +16 -0
- package/dist/test_designmd_mode.js +50 -0
- package/dist/test_designmd_mode_workspace.js +13 -0
- package/dist/test_dist_templates_layout.js +135 -0
- package/dist/test_distributed_lock.js +201 -0
- package/dist/test_distribution_installability.js +67 -0
- package/dist/test_doctor_sandbox_check.js +44 -0
- package/dist/test_dream_organizer.js +25 -0
- package/dist/test_dual_mode.js +15 -0
- package/dist/test_enterprise_agentic_core.js +128 -0
- package/dist/test_forecast_brain_wiring.js +87 -0
- package/dist/test_gateway_telegram_guardrails.js +52 -0
- package/dist/test_governance.js +34 -0
- package/dist/test_governance_advanced.js +75 -0
- package/dist/test_governance_scope_ledger.js +147 -0
- package/dist/test_governance_v13_policies.js +44 -0
- package/dist/test_guided_creator_cli.js +100 -0
- package/dist/test_host_install_e2e.js +324 -0
- package/dist/test_host_installer.js +259 -0
- package/dist/test_host_installers_gemini_codex.js +95 -0
- package/dist/test_host_uninstaller.js +295 -0
- package/dist/test_install_flow.js +70 -0
- package/dist/test_install_flow_host_validation.js +143 -0
- package/dist/test_install_wizard.js +272 -0
- package/dist/test_integration_gemini_live.js +95 -0
- package/dist/test_integration_http_trigger_live.js +154 -0
- package/dist/test_integration_telegram_live.js +102 -0
- package/dist/test_job_lifecycle.js +16 -0
- package/dist/test_memory_orchestrator.js +33 -0
- package/dist/test_memory_promotion.js +36 -0
- package/dist/test_memory_retention.js +37 -0
- package/dist/test_mission_checkpoint.js +204 -0
- package/dist/test_multi_host_docs_parity.js +125 -0
- package/dist/test_openlife_auto_creator_routing.js +69 -0
- package/dist/test_openlife_evolution_surface.js +77 -0
- package/dist/test_openlife_gatekeeper_routing.js +15 -0
- package/dist/test_openlife_routing_surface.js +27 -0
- package/dist/test_openlife_runtime_source_truth.js +25 -0
- package/dist/test_operating_system.js +45 -0
- package/dist/test_optimization_loop.js +38 -0
- package/dist/test_orchestration_assets_lifecycle.js +78 -0
- package/dist/test_outcome_simulator.js +38 -0
- package/dist/test_performance_latency.js +215 -0
- package/dist/test_performance_scorecard.js +38 -0
- package/dist/test_phase1_check_exit.js +103 -0
- package/dist/test_phase6_board.js +31 -0
- package/dist/test_phase6_cadence.js +29 -0
- package/dist/test_phase6_ops.js +37 -0
- package/dist/test_post_mission_evaluation.js +190 -0
- package/dist/test_process_sandbox.js +88 -0
- package/dist/test_profile_toolset_mcp.js +125 -0
- package/dist/test_queue_scheduler.js +239 -0
- package/dist/test_release_gate.js +23 -0
- package/dist/test_remote_publish.js +193 -0
- package/dist/test_reversa_contracts_e2e.js +48 -0
- package/dist/test_reversa_export_and_strict.js +51 -0
- package/dist/test_reversa_full_execution.js +12 -0
- package/dist/test_reversa_lite.js +9 -0
- package/dist/test_royal_stack_golden.js +179 -0
- package/dist/test_runtime_health_backoff.js +154 -0
- package/dist/test_runtime_policy.js +26 -0
- package/dist/test_runtime_probe.js +19 -0
- package/dist/test_runtime_profile_oauth_only.js +262 -0
- package/dist/test_runtime_registry.js +11 -0
- package/dist/test_security_download_and_scan.js +103 -0
- package/dist/test_security_download_guard.js +14 -0
- package/dist/test_service_command_surface.js +12 -0
- package/dist/test_service_completion_policy.js +32 -0
- package/dist/test_service_guardrails_delete.js +12 -0
- package/dist/test_service_mode_explicit_only.js +174 -0
- package/dist/test_sources_import_ref.js +46 -0
- package/dist/test_sources_scaffold.js +43 -0
- package/dist/test_squad_skill_creator.js +305 -0
- package/dist/test_squad_skill_design_llm.js +176 -0
- package/dist/test_subsystems_org_state.js +271 -0
- package/dist/test_subsystems_promotion_memory_assets.js +343 -0
- package/dist/test_subsystems_routing_governance.js +234 -0
- package/dist/test_task_executor_sandbox_optin.js +127 -0
- package/dist/test_teammate_learning.js +15 -0
- package/dist/test_telegram_delete_guardrail.js +21 -0
- package/dist/test_toolset_enforcement.js +188 -0
- package/dist/test_trigger_basic_auth.js +112 -0
- package/dist/test_util/doc_parity.js +120 -0
- package/dist/test_v15_e2e_integration.js +207 -0
- package/dist/test_watchdog_heartbeat.js +152 -0
- package/dist/test_workflow_condition_parser.js +63 -0
- package/dist/test_workflow_e2e.js +240 -0
- package/dist/test_workflow_engine.js +330 -0
- package/dist/test_workflow_parser.js +245 -0
- package/dist/test_workflow_schema_backward_compat.js +197 -0
- package/dist-templates/README.md +91 -0
- package/dist-templates/claude-code/agents/openlife-atlas.md +52 -0
- package/dist-templates/claude-code/agents/openlife-forge.md +42 -0
- package/dist-templates/claude-code/agents/openlife-genesis.md +59 -0
- package/dist-templates/claude-code/agents/openlife-lyra.md +40 -0
- package/dist-templates/claude-code/agents/openlife-maestro.md +45 -0
- package/dist-templates/claude-code/commands/openlife/ask.md +14 -0
- package/dist-templates/claude-code/commands/openlife/doctor.md +19 -0
- package/dist-templates/claude-code/commands/openlife/dream.md +20 -0
- package/dist-templates/claude-code/commands/openlife/status.md +14 -0
- package/dist-templates/claude-code/mcp/openlife-orchestrator.json +46 -0
- package/dist-templates/codex/README.md +7 -0
- package/dist-templates/codex/agents/openlife-atlas.md +52 -0
- package/dist-templates/codex/agents/openlife-forge.md +42 -0
- package/dist-templates/codex/agents/openlife-genesis.md +59 -0
- package/dist-templates/codex/agents/openlife-lyra.md +40 -0
- package/dist-templates/codex/agents/openlife-maestro.md +45 -0
- package/dist-templates/codex/commands/openlife/ask.md +14 -0
- package/dist-templates/codex/commands/openlife/doctor.md +19 -0
- package/dist-templates/codex/commands/openlife/dream.md +20 -0
- package/dist-templates/codex/commands/openlife/status.md +14 -0
- package/dist-templates/codex/mcp/openlife-orchestrator.json +46 -0
- package/dist-templates/gemini-cli/README.md +8 -0
- package/dist-templates/gemini-cli/agents/openlife-atlas.md +52 -0
- package/dist-templates/gemini-cli/agents/openlife-forge.md +42 -0
- package/dist-templates/gemini-cli/agents/openlife-genesis.md +59 -0
- package/dist-templates/gemini-cli/agents/openlife-lyra.md +40 -0
- package/dist-templates/gemini-cli/agents/openlife-maestro.md +45 -0
- package/dist-templates/gemini-cli/commands/openlife/ask.md +14 -0
- package/dist-templates/gemini-cli/commands/openlife/doctor.md +19 -0
- package/dist-templates/gemini-cli/commands/openlife/dream.md +20 -0
- package/dist-templates/gemini-cli/commands/openlife/status.md +14 -0
- package/dist-templates/gemini-cli/mcp/openlife-orchestrator.json +46 -0
- package/dist-templates/skill-template/README.md +34 -0
- package/dist-templates/skill-template/SKILL.md.template +59 -0
- package/dist-templates/squad-template/README.md +82 -0
- package/dist-templates/squad-template/SQUAD.md.template +51 -0
- package/dist-templates/squad-template/agent-template.md +51 -0
- package/dist-templates/squad-template/checklist-template.md +25 -0
- package/dist-templates/squad-template/task-template.md +36 -0
- package/dist-templates/workflows/PORTED_WORKFLOWS.md +60 -0
- package/dist-templates/workflows/brownfield-discovery.yaml +137 -0
- package/dist-templates/workflows/greenfield-fullstack.yaml +132 -0
- package/dist-templates/workflows/qa-loop.yaml +125 -0
- package/dist-templates/workflows/story-development-cycle.yaml +80 -0
- package/docs/CHANGELOG_FEATURE_ROLLOUT_DESIGNMD.md +43 -0
- package/docs/EXTERNAL_SOURCES_AND_SECURITY_GUARD.md +33 -0
- package/docs/OPENLIFE_AUDIT_2026-05-06.md +170 -0
- package/docs/OPENLIFE_CONSOLIDATED_PLAN_2026-05-06.md +299 -0
- package/docs/OPENLIFE_DUAL_MODE_IMPLEMENTATION_PLAN.md +205 -0
- package/docs/OPENLIFE_EVOLUTION_SURFACE_2026-05-07.md +53 -0
- package/docs/OPENLIFE_SKILLS_IMPORT_2026-05-07.json +223 -0
- package/docs/OPENLIFE_SQUADS_IMPORT_2026-05-07.json +184 -0
- package/docs/PAPERCLIP_OPENLIFE_INVESTIGATION.md +85 -0
- package/docs/README.md +28 -0
- package/docs/RELEASE_ORGANIZATION_PLAN.md +164 -0
- package/docs/audit/CLI-EXECUTION-RESULTS.md +113 -0
- package/docs/audit/CLI-MATRIX.md +556 -0
- package/docs/audit/DOC-PARITY-GAPS.md +351 -0
- package/docs/audit/ORCHESTRATOR-MATRIX.md +136 -0
- package/docs/audit/TEST-COVERAGE-GAPS.md +334 -0
- package/docs/audit/integrations/SKIPPED.md +101 -0
- package/docs/autonomous-install.md +79 -0
- package/docs/capability-genesis.md +137 -0
- package/docs/capability-pack-schema.md +157 -0
- package/docs/commands.md +82 -0
- package/docs/deep-research-capability.md +114 -0
- package/docs/development/typescript-conventions.md +95 -0
- package/docs/host-installers.md +68 -0
- package/docs/install/aiobuilder.md +70 -0
- package/docs/install/claude-code.md +83 -0
- package/docs/install/codex.md +64 -0
- package/docs/install/gemini-cli.md +64 -0
- package/docs/install/runtime-profiles.md +83 -0
- package/docs/openlife-agent-os-blueprint.md +114 -0
- package/docs/openlife-install-backlog.md +115 -0
- package/docs/openlife-install-spec.md +306 -0
- package/docs/operations/CLOUD_CUTOVER_AUDIT.md +37 -0
- package/docs/operations/PHASE_PROGRESS_CONTINUATION.md +24 -0
- package/docs/performance-benchmarks.md +83 -0
- package/docs/planning/v1.3-capability-genesis.md +157 -0
- package/docs/plans/2026-05-05-admin-interface-professional-dark-premium-plan.md +84 -0
- package/docs/plans/2026-05-05-openlife-autonomous-domain-marketplace-masterplan.md +122 -0
- package/docs/quickstart.md +60 -0
- package/docs/release-process.md +236 -0
- package/docs/roadmap/OPENLIFE_MASTER_PLAN_CLOUD_V3.md +97 -0
- package/docs/sandboxing-research.md +117 -0
- package/docs/stories/epic-feature-audit/1.1.story.md +84 -0
- package/docs/stories/epic-feature-audit/1.2.story.md +102 -0
- package/docs/stories/epic-feature-audit/1.3.story.md +93 -0
- package/docs/stories/epic-feature-audit/1.5.story.md +121 -0
- package/docs/stories/epic-feature-audit/1.6.story.md +80 -0
- package/docs/stories/epic-feature-completeness/2.1.story.md +70 -0
- package/docs/stories/epic-feature-completeness/2.2.story.md +49 -0
- package/docs/stories/epic-feature-completeness/2.3.story.md +74 -0
- package/docs/stories/epic-feature-completeness/2.4.story.md +71 -0
- package/docs/stories/epic-feature-completeness/3.1.story.md +56 -0
- package/docs/stories/epic-feature-completeness/3.2.story.md +80 -0
- package/docs/stories/epic-feature-completeness/3.3.story.md +68 -0
- package/docs/stories/epic-feature-completeness/3.4.story.md +71 -0
- package/docs/stories/epic-feature-completeness/3.5.story.md +72 -0
- package/docs/stories/epic-feature-completeness/3.6.story.md +69 -0
- package/docs/stories/epic-feature-completeness/3.7.story.md +68 -0
- package/docs/stories/epic-feature-completeness/3.8.story.md +57 -0
- package/docs/toolset-enforcement.md +122 -0
- package/docs/v1.4-changelog.md +159 -0
- package/docs/v1.5-changelog.md +106 -0
- package/docs/v1.5-roadmap.md +121 -0
- package/docs/v1.6-changelog.md +67 -0
- package/docs/v1.6-roadmap.md +89 -0
- package/docs/v1.7-changelog.md +98 -0
- package/docs/workflow-schema.md +177 -0
- package/package.json +177 -0
- package/scripts/clean-test-pollution.js +61 -0
- package/scripts/openlife-agent-start.sh +6 -0
- package/scripts/openlife-agent.service.example +13 -0
- package/scripts/openlife-agent.supervisord.conf.example +8 -0
- package/scripts/openlife-autonomous-install.sh +29 -0
- package/scripts/postinstall-check.sh +37 -0
|
@@ -0,0 +1,905 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.OrchestrationLoop = void 0;
|
|
37
|
+
const IntentClassifier_1 = require("./IntentClassifier");
|
|
38
|
+
const ExecutionState_1 = require("./ExecutionState");
|
|
39
|
+
const PlannerAgent_1 = require("./PlannerAgent");
|
|
40
|
+
const ReviewerAgent_1 = require("./ReviewerAgent");
|
|
41
|
+
const SynthesizerAgent_1 = require("./SynthesizerAgent");
|
|
42
|
+
const AgentRegistry_1 = require("./AgentRegistry");
|
|
43
|
+
const CapabilityRouter_1 = require("./CapabilityRouter");
|
|
44
|
+
const MissionState_1 = require("./MissionState");
|
|
45
|
+
const MemoryCuratorAgent_1 = require("./MemoryCuratorAgent");
|
|
46
|
+
const ParallelOrchestrationLoop_1 = require("./ParallelOrchestrationLoop");
|
|
47
|
+
const AgentScoring_1 = require("./AgentScoring");
|
|
48
|
+
const DynamicAgentBuilder_1 = require("./DynamicAgentBuilder");
|
|
49
|
+
const SquadRegistry_1 = require("./SquadRegistry");
|
|
50
|
+
const SquadRouter_1 = require("./SquadRouter");
|
|
51
|
+
const SkillRegistryV2_1 = require("./SkillRegistryV2");
|
|
52
|
+
const LearningRouter_1 = require("./LearningRouter");
|
|
53
|
+
const PromotionPipeline_1 = require("./PromotionPipeline");
|
|
54
|
+
const OperationalMemoryStore_1 = require("./OperationalMemoryStore");
|
|
55
|
+
const AssetPromotionEngine_1 = require("./AssetPromotionEngine");
|
|
56
|
+
const PromotionReviewGate_1 = require("./PromotionReviewGate");
|
|
57
|
+
const ReuseEngine_1 = require("./ReuseEngine");
|
|
58
|
+
const SquadScoring_1 = require("./SquadScoring");
|
|
59
|
+
const SkillScoring_1 = require("./SkillScoring");
|
|
60
|
+
const DynamicAgentExecutor_1 = require("./DynamicAgentExecutor");
|
|
61
|
+
const AssetReuseRouter_1 = require("./AssetReuseRouter");
|
|
62
|
+
const GovernanceLayer_1 = require("./GovernanceLayer");
|
|
63
|
+
const ExecutionModePolicy_1 = require("./ExecutionModePolicy");
|
|
64
|
+
const GovernanceScopePolicy_1 = require("./GovernanceScopePolicy");
|
|
65
|
+
const SecurityEventStore_1 = require("./SecurityEventStore");
|
|
66
|
+
const GovernanceConsentStore_1 = require("./GovernanceConsentStore");
|
|
67
|
+
const SandboxPolicy_1 = require("./SandboxPolicy");
|
|
68
|
+
const RuntimePolicy_1 = require("./RuntimePolicy");
|
|
69
|
+
const PerformanceScorecard_1 = require("./PerformanceScorecard");
|
|
70
|
+
const BenchmarkEngine_1 = require("./BenchmarkEngine");
|
|
71
|
+
const OptimizationLoop_1 = require("./OptimizationLoop");
|
|
72
|
+
const ExecutionBoard_1 = require("./ExecutionBoard");
|
|
73
|
+
const RoleHandoff_1 = require("./RoleHandoff");
|
|
74
|
+
const CadenceEngine_1 = require("./CadenceEngine");
|
|
75
|
+
const OperatingSystem_1 = require("./OperatingSystem");
|
|
76
|
+
const ReleaseGate_1 = require("./ReleaseGate");
|
|
77
|
+
const SquadAutoCreator_1 = require("./SquadAutoCreator");
|
|
78
|
+
const SubagentLifecycle_1 = require("./SubagentLifecycle");
|
|
79
|
+
const ServiceCompletionPolicy_1 = require("./ServiceCompletionPolicy");
|
|
80
|
+
const OutcomeSimulator_1 = require("./OutcomeSimulator");
|
|
81
|
+
const ConsequenceForecaster_1 = require("./ConsequenceForecaster");
|
|
82
|
+
const ServiceState_1 = require("./ServiceState");
|
|
83
|
+
const ExecutionIntent_1 = require("./ExecutionIntent");
|
|
84
|
+
const ExecutionRouter_1 = require("./ExecutionRouter");
|
|
85
|
+
const JobLifecycle_1 = require("./JobLifecycle");
|
|
86
|
+
const AgentTeam_1 = require("./AgentTeam");
|
|
87
|
+
const SkillNetwork_1 = require("./SkillNetwork");
|
|
88
|
+
const fs = __importStar(require("fs"));
|
|
89
|
+
const path = __importStar(require("path"));
|
|
90
|
+
function governancePriorityFromBudget(budget) {
|
|
91
|
+
if (budget >= 5)
|
|
92
|
+
return 'critical';
|
|
93
|
+
if (budget >= 2)
|
|
94
|
+
return 'high';
|
|
95
|
+
if (budget >= 1)
|
|
96
|
+
return 'medium';
|
|
97
|
+
return 'low';
|
|
98
|
+
}
|
|
99
|
+
class OrchestrationLoop {
|
|
100
|
+
brain;
|
|
101
|
+
taskExecutor;
|
|
102
|
+
deriveServiceId(goal) {
|
|
103
|
+
const normalized = goal
|
|
104
|
+
.toLowerCase()
|
|
105
|
+
.normalize('NFD')
|
|
106
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
107
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
108
|
+
.replace(/^-+|-+$/g, '')
|
|
109
|
+
.slice(0, 64);
|
|
110
|
+
return normalized || 'service-unnamed';
|
|
111
|
+
}
|
|
112
|
+
planner;
|
|
113
|
+
reviewer;
|
|
114
|
+
synthesizer;
|
|
115
|
+
registry;
|
|
116
|
+
capabilityRouter;
|
|
117
|
+
missionStore;
|
|
118
|
+
memoryCurator;
|
|
119
|
+
parallelLoop;
|
|
120
|
+
agentScoring;
|
|
121
|
+
dynamicAgentBuilder;
|
|
122
|
+
squadRegistry;
|
|
123
|
+
squadRouter;
|
|
124
|
+
skillRegistry;
|
|
125
|
+
learningRouter;
|
|
126
|
+
promotionPipeline;
|
|
127
|
+
operationalMemory;
|
|
128
|
+
promotionEngine;
|
|
129
|
+
promotionGate;
|
|
130
|
+
reuseEngine;
|
|
131
|
+
squadScoring;
|
|
132
|
+
skillScoring;
|
|
133
|
+
dynamicAgentExecutor;
|
|
134
|
+
assetReuseRouter;
|
|
135
|
+
governance;
|
|
136
|
+
executionModePolicy;
|
|
137
|
+
governanceScopePolicy;
|
|
138
|
+
securityEventStore;
|
|
139
|
+
governanceConsentStore;
|
|
140
|
+
sandboxPolicy;
|
|
141
|
+
runtimePolicy;
|
|
142
|
+
performanceScorecard;
|
|
143
|
+
benchmarkEngine;
|
|
144
|
+
optimizationLoop;
|
|
145
|
+
executionBoard;
|
|
146
|
+
roleHandoff;
|
|
147
|
+
cadenceEngine;
|
|
148
|
+
operatingSystem;
|
|
149
|
+
releaseGate;
|
|
150
|
+
squadAutoCreator;
|
|
151
|
+
subagentLifecycle;
|
|
152
|
+
serviceCompletionPolicy;
|
|
153
|
+
outcomeSimulator;
|
|
154
|
+
consequenceForecaster;
|
|
155
|
+
serviceStateStore;
|
|
156
|
+
executionRouter;
|
|
157
|
+
jobLifecycle;
|
|
158
|
+
agentTeamRegistry;
|
|
159
|
+
skillNetworkRegistry;
|
|
160
|
+
constructor(brain, taskExecutor) {
|
|
161
|
+
this.brain = brain;
|
|
162
|
+
this.taskExecutor = taskExecutor;
|
|
163
|
+
this.planner = new PlannerAgent_1.PlannerAgent(brain);
|
|
164
|
+
this.reviewer = new ReviewerAgent_1.ReviewerAgent(brain);
|
|
165
|
+
this.synthesizer = new SynthesizerAgent_1.SynthesizerAgent(brain);
|
|
166
|
+
this.registry = new AgentRegistry_1.AgentRegistry();
|
|
167
|
+
this.capabilityRouter = new CapabilityRouter_1.CapabilityRouter(this.registry);
|
|
168
|
+
this.missionStore = new MissionState_1.MissionStateStore();
|
|
169
|
+
this.memoryCurator = new MemoryCuratorAgent_1.MemoryCuratorAgent(brain);
|
|
170
|
+
this.parallelLoop = new ParallelOrchestrationLoop_1.ParallelOrchestrationLoop(brain, taskExecutor);
|
|
171
|
+
this.agentScoring = new AgentScoring_1.AgentScoring();
|
|
172
|
+
this.dynamicAgentBuilder = new DynamicAgentBuilder_1.DynamicAgentBuilder(brain);
|
|
173
|
+
this.squadRegistry = new SquadRegistry_1.SquadRegistry();
|
|
174
|
+
this.squadRouter = new SquadRouter_1.SquadRouter(this.squadRegistry);
|
|
175
|
+
this.skillRegistry = new SkillRegistryV2_1.SkillRegistryV2();
|
|
176
|
+
this.learningRouter = new LearningRouter_1.LearningRouter(this.capabilityRouter, this.agentScoring);
|
|
177
|
+
this.promotionPipeline = new PromotionPipeline_1.PromotionPipeline();
|
|
178
|
+
this.operationalMemory = new OperationalMemoryStore_1.OperationalMemoryStore();
|
|
179
|
+
this.promotionEngine = new AssetPromotionEngine_1.AssetPromotionEngine();
|
|
180
|
+
this.promotionGate = new PromotionReviewGate_1.PromotionReviewGate();
|
|
181
|
+
this.reuseEngine = new ReuseEngine_1.ReuseEngine();
|
|
182
|
+
this.squadScoring = new SquadScoring_1.SquadScoring();
|
|
183
|
+
this.skillScoring = new SkillScoring_1.SkillScoring();
|
|
184
|
+
this.dynamicAgentExecutor = new DynamicAgentExecutor_1.DynamicAgentExecutor(taskExecutor);
|
|
185
|
+
this.assetReuseRouter = new AssetReuseRouter_1.AssetReuseRouter();
|
|
186
|
+
this.governance = new GovernanceLayer_1.GovernanceLayer();
|
|
187
|
+
this.executionModePolicy = new ExecutionModePolicy_1.ExecutionModePolicy();
|
|
188
|
+
this.governanceScopePolicy = new GovernanceScopePolicy_1.GovernanceScopePolicy();
|
|
189
|
+
this.securityEventStore = new SecurityEventStore_1.SecurityEventStore();
|
|
190
|
+
this.governanceConsentStore = new GovernanceConsentStore_1.GovernanceConsentStore();
|
|
191
|
+
this.sandboxPolicy = new SandboxPolicy_1.SandboxPolicy();
|
|
192
|
+
this.runtimePolicy = new RuntimePolicy_1.RuntimePolicy();
|
|
193
|
+
this.performanceScorecard = new PerformanceScorecard_1.PerformanceScorecard();
|
|
194
|
+
this.benchmarkEngine = new BenchmarkEngine_1.BenchmarkEngine();
|
|
195
|
+
this.optimizationLoop = new OptimizationLoop_1.OptimizationLoop();
|
|
196
|
+
this.executionBoard = new ExecutionBoard_1.ExecutionBoard();
|
|
197
|
+
this.roleHandoff = new RoleHandoff_1.RoleHandoff();
|
|
198
|
+
this.cadenceEngine = new CadenceEngine_1.CadenceEngine();
|
|
199
|
+
this.operatingSystem = new OperatingSystem_1.OperatingSystem();
|
|
200
|
+
this.releaseGate = new ReleaseGate_1.ReleaseGate();
|
|
201
|
+
this.squadAutoCreator = new SquadAutoCreator_1.SquadAutoCreator();
|
|
202
|
+
this.subagentLifecycle = new SubagentLifecycle_1.SubagentLifecycle();
|
|
203
|
+
this.serviceCompletionPolicy = new ServiceCompletionPolicy_1.ServiceCompletionPolicy();
|
|
204
|
+
this.outcomeSimulator = new OutcomeSimulator_1.OutcomeSimulator();
|
|
205
|
+
this.consequenceForecaster = new ConsequenceForecaster_1.ConsequenceForecaster();
|
|
206
|
+
this.serviceStateStore = new ServiceState_1.ServiceStateStore();
|
|
207
|
+
this.executionRouter = new ExecutionRouter_1.ExecutionRouter();
|
|
208
|
+
this.jobLifecycle = new JobLifecycle_1.JobLifecycleStore();
|
|
209
|
+
const defaultTeams = [
|
|
210
|
+
{ id: 'team-sales-default', domain: 'sales', description: 'Sales execution squad', slaProfile: 'fast', members: [] },
|
|
211
|
+
{ id: 'team-social-default', domain: 'social', description: 'Social ops squad', slaProfile: 'balanced', members: [] },
|
|
212
|
+
{ id: 'team-support-default', domain: 'support', description: 'Support ops squad', slaProfile: 'strict', members: [] }
|
|
213
|
+
];
|
|
214
|
+
const defaultNetworks = [
|
|
215
|
+
{ id: 'net-sales-default', domain: 'sales', nodes: [{ id: 'sales-prospecting', capabilities: ['prospecting', 'lead', 'outbound'] }] },
|
|
216
|
+
{ id: 'net-social-default', domain: 'social', nodes: [{ id: 'social-content', capabilities: ['social', 'post', 'content', 'calendar'] }] },
|
|
217
|
+
{ id: 'net-support-default', domain: 'support', nodes: [{ id: 'support-triage', capabilities: ['support', 'ticket', 'triage', 'sla'] }] }
|
|
218
|
+
];
|
|
219
|
+
const catalogDir = path.join(process.cwd(), '.catalog');
|
|
220
|
+
const teamsFile = path.join(catalogDir, 'teams.json');
|
|
221
|
+
const networksFile = path.join(catalogDir, 'skill-networks.json');
|
|
222
|
+
const fileTeams = fs.existsSync(teamsFile) ? JSON.parse(fs.readFileSync(teamsFile, 'utf-8')) : [];
|
|
223
|
+
const fileNetworks = fs.existsSync(networksFile) ? JSON.parse(fs.readFileSync(networksFile, 'utf-8')) : [];
|
|
224
|
+
this.agentTeamRegistry = new AgentTeam_1.AgentTeamRegistry([...(fileTeams.length ? fileTeams : defaultTeams)]);
|
|
225
|
+
this.skillNetworkRegistry = new SkillNetwork_1.SkillNetworkRegistry([...(fileNetworks.length ? fileNetworks : defaultNetworks)]);
|
|
226
|
+
}
|
|
227
|
+
inferDomainFromGoal(goal) {
|
|
228
|
+
const g = goal.toLowerCase();
|
|
229
|
+
if (/(social|conteudo|content|instagram|youtube|tiktok|linkedin)/i.test(g))
|
|
230
|
+
return 'social';
|
|
231
|
+
if (/(vendas|sales|lead|outbound|pipeline|prospect)/i.test(g))
|
|
232
|
+
return 'sales';
|
|
233
|
+
return 'support';
|
|
234
|
+
}
|
|
235
|
+
persistMissionAndService(state) {
|
|
236
|
+
const missionPath = this.missionStore.persist(state);
|
|
237
|
+
if (state.mode === 'service') {
|
|
238
|
+
this.serviceStateStore.upsertFromMission(state);
|
|
239
|
+
}
|
|
240
|
+
return missionPath;
|
|
241
|
+
}
|
|
242
|
+
async run(task, input, userId, recentHistory, intent) {
|
|
243
|
+
const taskId = `task_${Date.now()}`;
|
|
244
|
+
const workspaceId = intent?.origin === 'telegram' ? 'default' : 'default';
|
|
245
|
+
const job = this.jobLifecycle.enqueue(input, workspaceId);
|
|
246
|
+
this.jobLifecycle.transition(job.jobId, workspaceId, 'claimed', 'Job claimed by orchestration loop', 'orchestration-loop');
|
|
247
|
+
this.jobLifecycle.transition(job.jobId, workspaceId, 'started', 'Job execution started', 'orchestration-loop');
|
|
248
|
+
const baseState = (0, ExecutionState_1.createExecutionState)(taskId, input, userId);
|
|
249
|
+
const ownerRole = task.intent === IntentClassifier_1.TaskIntent.ENGINEERING_BUILD ? 'cto' : task.intent === IntentClassifier_1.TaskIntent.RESEARCH_ANALYSIS ? 'cpo' : 'coo';
|
|
250
|
+
this.executionBoard.add({
|
|
251
|
+
id: taskId,
|
|
252
|
+
title: input.slice(0, 120),
|
|
253
|
+
ownerRole,
|
|
254
|
+
status: 'active',
|
|
255
|
+
priority: governancePriorityFromBudget(task.budgetLimit),
|
|
256
|
+
notes: `user=${userId}`,
|
|
257
|
+
dependencies: [],
|
|
258
|
+
slaHours: task.budgetLimit >= 5 ? 24 : task.budgetLimit >= 1 ? 48 : 72
|
|
259
|
+
});
|
|
260
|
+
this.cadenceEngine.schedule('planning', `Planning ${taskId}`, ownerRole, taskId);
|
|
261
|
+
const governanceDecision = this.governance.evaluate(input);
|
|
262
|
+
let executionPolicy = this.executionModePolicy.decide(task, input);
|
|
263
|
+
const scopeDecision = this.governanceScopePolicy.decide(task, input);
|
|
264
|
+
const reuseHints = this.reuseEngine.findHints(input);
|
|
265
|
+
const reusedAssets = this.assetReuseRouter.find(input);
|
|
266
|
+
const route = this.learningRouter.route(task, input);
|
|
267
|
+
route.agents = this.reuseEngine.enrichAgents(route.agents, reuseHints);
|
|
268
|
+
const squadRoute = this.squadRouter.route(task, input);
|
|
269
|
+
for (const squad of squadRoute.squads) {
|
|
270
|
+
this.squadAutoCreator.create(input, squad.id);
|
|
271
|
+
}
|
|
272
|
+
const capabilityFilter = this.governanceScopePolicy.filterCapabilities(route.capabilities, scopeDecision);
|
|
273
|
+
route.capabilities = capabilityFilter.allowed;
|
|
274
|
+
const chosenSkills = route.capabilities.flatMap(cap => this.skillRegistry.findByCapability(cap)).slice(0, 5);
|
|
275
|
+
const dynamicAgent = await this.dynamicAgentBuilder.propose(input, route.agents);
|
|
276
|
+
if (dynamicAgent) {
|
|
277
|
+
const lifecycleRecord = this.subagentLifecycle.create(dynamicAgent.name, dynamicAgent.capabilities);
|
|
278
|
+
this.subagentLifecycle.transition(lifecycleRecord.id, 'trial');
|
|
279
|
+
this.subagentLifecycle.transition(lifecycleRecord.id, 'active');
|
|
280
|
+
const dyn = {
|
|
281
|
+
id: dynamicAgent.id,
|
|
282
|
+
name: dynamicAgent.name,
|
|
283
|
+
role: dynamicAgent.role,
|
|
284
|
+
capabilities: dynamicAgent.capabilities,
|
|
285
|
+
sourcePath: 'dynamic',
|
|
286
|
+
priority: 4,
|
|
287
|
+
tags: dynamicAgent.capabilities,
|
|
288
|
+
temporary: true
|
|
289
|
+
};
|
|
290
|
+
this.registry.registerTemporary(dyn);
|
|
291
|
+
route.agents.push(dyn);
|
|
292
|
+
}
|
|
293
|
+
const planning = await this.planner.plan(input, recentHistory);
|
|
294
|
+
const normalizedIntent = (0, ExecutionIntent_1.normalizeExecutionIntent)({ ...intent, goal: input });
|
|
295
|
+
const executionPath = this.executionRouter.route(normalizedIntent);
|
|
296
|
+
const inferredDomain = this.inferDomainFromGoal(planning.normalizedGoal);
|
|
297
|
+
const resolvedTeam = this.agentTeamRegistry.resolveByDomain(inferredDomain);
|
|
298
|
+
const networkCapabilities = this.skillNetworkRegistry.resolveCapabilities(inferredDomain, planning.normalizedGoal);
|
|
299
|
+
const state = {
|
|
300
|
+
...baseState,
|
|
301
|
+
workspaceId,
|
|
302
|
+
mode: executionPath,
|
|
303
|
+
chosenAgents: route.agents,
|
|
304
|
+
chosenSquads: squadRoute.squads,
|
|
305
|
+
chosenSkills,
|
|
306
|
+
routeMode: route.mode,
|
|
307
|
+
missionScope: scopeDecision.projectScope,
|
|
308
|
+
allowedCapabilities: capabilityFilter.allowed,
|
|
309
|
+
deniedCapabilities: capabilityFilter.denied,
|
|
310
|
+
memoryCandidates: [],
|
|
311
|
+
teamId: resolvedTeam?.id,
|
|
312
|
+
teamDomain: inferredDomain,
|
|
313
|
+
skillNetworkCapabilities: networkCapabilities
|
|
314
|
+
};
|
|
315
|
+
const governanceLevel = governanceDecision.riskLevel === 'high'
|
|
316
|
+
? 'critical'
|
|
317
|
+
: governanceDecision.riskLevel === 'medium'
|
|
318
|
+
? 'warning'
|
|
319
|
+
: 'info';
|
|
320
|
+
const governanceEvent = {
|
|
321
|
+
type: 'governance_decision',
|
|
322
|
+
level: governanceLevel,
|
|
323
|
+
summary: governanceDecision.auditSummary,
|
|
324
|
+
details: `scope=${governanceDecision.scope}; missionScope=${scopeDecision.projectScope}; requiresConsent=${governanceDecision.requiresConsent}; matchedPolicies=${governanceDecision.matchedPolicies.join(',')}; blockedCapabilities=${governanceDecision.blockedCapabilities.join(',')}; deniedCapabilities=${capabilityFilter.denied.join(',')}`,
|
|
325
|
+
at: new Date().toISOString()
|
|
326
|
+
};
|
|
327
|
+
state.governanceEvents.push(governanceEvent);
|
|
328
|
+
this.securityEventStore.append({ ...governanceEvent, taskId, userId });
|
|
329
|
+
if (!governanceDecision.allowed) {
|
|
330
|
+
const hasConsent = governanceDecision.requiresConsent && this.governanceConsentStore.hasRecentApproval(userId);
|
|
331
|
+
if (hasConsent) {
|
|
332
|
+
state.governanceEvents.push({
|
|
333
|
+
type: 'destructive_consent_required',
|
|
334
|
+
level: 'warning',
|
|
335
|
+
summary: 'Consentimento destrutivo recente encontrado, seguindo com execução restrita.',
|
|
336
|
+
details: input,
|
|
337
|
+
at: new Date().toISOString()
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (hasConsent && governanceDecision.requiresConsent) {
|
|
341
|
+
governanceDecision.allowed = true;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (!governanceDecision.allowed) {
|
|
345
|
+
state.status = 'failed';
|
|
346
|
+
state.updatedAt = new Date().toISOString();
|
|
347
|
+
const blockedEvent = {
|
|
348
|
+
type: governanceDecision.requiresConsent ? 'destructive_action_blocked' : 'prompt_injection_detected',
|
|
349
|
+
level: 'critical',
|
|
350
|
+
summary: governanceDecision.rationale,
|
|
351
|
+
details: input,
|
|
352
|
+
at: new Date().toISOString()
|
|
353
|
+
};
|
|
354
|
+
state.governanceEvents.push(blockedEvent);
|
|
355
|
+
this.securityEventStore.append({ ...blockedEvent, taskId, userId });
|
|
356
|
+
state.attempts.push({
|
|
357
|
+
role: 'planner',
|
|
358
|
+
summary: `Governança bloqueou a missão. Risk=${governanceDecision.riskLevel}. Policies=${governanceDecision.matchedPolicies.join(', ')}`,
|
|
359
|
+
status: 'failed',
|
|
360
|
+
at: new Date().toISOString()
|
|
361
|
+
});
|
|
362
|
+
const blockedResponse = governanceDecision.requiresConsent
|
|
363
|
+
? 'Missão bloqueada por governança: ação destrutiva detectada. Para liberar por 15 minutos, use o comando /consent destructive.'
|
|
364
|
+
: 'Missão bloqueada por governança: sinais de prompt injection ou violação de policy detectados.';
|
|
365
|
+
state.finalAnswer = blockedResponse;
|
|
366
|
+
this.executionBoard.updateStatus(taskId, 'blocked', governanceDecision.rationale);
|
|
367
|
+
this.jobLifecycle.transition(job.jobId, workspaceId, 'blocked', governanceDecision.rationale, 'orchestration-loop', governanceDecision.rationale);
|
|
368
|
+
const missionPath = this.persistMissionAndService(state);
|
|
369
|
+
return { state, response: blockedResponse, missionPath };
|
|
370
|
+
}
|
|
371
|
+
if (capabilityFilter.denied.length > 0) {
|
|
372
|
+
state.governanceEvents.push({
|
|
373
|
+
type: 'scope_violation',
|
|
374
|
+
level: 'warning',
|
|
375
|
+
summary: `Capabilities negadas pelo escopo da missão: ${capabilityFilter.denied.join(', ')}`,
|
|
376
|
+
details: scopeDecision.rationale,
|
|
377
|
+
at: new Date().toISOString()
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
if (ownerRole === 'cpo' && task.intent === IntentClassifier_1.TaskIntent.ENGINEERING_BUILD) {
|
|
381
|
+
this.roleHandoff.create({
|
|
382
|
+
id: `handoff_${taskId}_cpo_cto`,
|
|
383
|
+
fromRole: 'cpo',
|
|
384
|
+
toRole: 'cto',
|
|
385
|
+
missionId: taskId,
|
|
386
|
+
summary: 'Descoberta de produto precisa virar execução técnica.',
|
|
387
|
+
status: 'queued'
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
state.plan = planning.plan;
|
|
391
|
+
state.successCriteria = this.serviceCompletionPolicy.enforceCriteria(planning.successCriteria);
|
|
392
|
+
state.updatedAt = new Date().toISOString();
|
|
393
|
+
state.attempts.push({
|
|
394
|
+
role: 'planner',
|
|
395
|
+
summary: `TOOL_TRACE read_file: Mission context loaded (history/governance/runtime policies) | Plano criado com modo ${planning.executionMode} e routeMode ${route.mode}. ExecutionMode: ${executionPolicy.executionMode}. SwarmMode: ${executionPolicy.swarmMode}. Rationale: ${route.rationale}. Risk: ${governanceDecision.riskLevel}. Scope: ${governanceDecision.scope}. MissionScope: ${scopeDecision.projectScope}. AllowedCapabilities: ${capabilityFilter.allowed.join(',')}. Reuse hints: ${reuseHints.length}. Reused assets: ${reusedAssets.length}`,
|
|
396
|
+
status: 'success',
|
|
397
|
+
at: new Date().toISOString()
|
|
398
|
+
});
|
|
399
|
+
const preRuntimeDecision = this.runtimePolicy.decide(task.intent);
|
|
400
|
+
const forecast = process.env.OPENLIFE_BRAIN_FORECAST === 'on'
|
|
401
|
+
? await this.consequenceForecaster.forecastWithBrain(planning.normalizedGoal, governanceDecision.riskLevel, executionPolicy, preRuntimeDecision.preferred)
|
|
402
|
+
: this.consequenceForecaster.forecast(planning.normalizedGoal, governanceDecision.riskLevel, executionPolicy, preRuntimeDecision.preferred);
|
|
403
|
+
if (forecast.brain) {
|
|
404
|
+
state.attempts.push({
|
|
405
|
+
role: 'planner',
|
|
406
|
+
summary: `Brain forecast (${forecast.brain.source}): verdict=${forecast.brain.overallVerdict}; amplifiers=${forecast.brain.riskAmplifiers.slice(0, 3).join('|') || 'none'}; rationale=${forecast.brain.rationale.slice(0, 200)}`,
|
|
407
|
+
status: forecast.brain.overallVerdict === 'block' ? 'failed' : 'success',
|
|
408
|
+
at: new Date().toISOString()
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
state.consequenceThoughtTrace = {
|
|
412
|
+
schema: 'openlife.consequence-thought-trace',
|
|
413
|
+
traceVersion: '1.0.0',
|
|
414
|
+
serviceContext: {
|
|
415
|
+
serviceId: this.deriveServiceId(planning.normalizedGoal),
|
|
416
|
+
serviceObjective: planning.normalizedGoal,
|
|
417
|
+
taskId
|
|
418
|
+
},
|
|
419
|
+
goal: planning.normalizedGoal,
|
|
420
|
+
governanceRisk: governanceDecision.riskLevel,
|
|
421
|
+
selectedPathId: forecast.selectedPath.id,
|
|
422
|
+
selectedScore: forecast.selectedPath.score,
|
|
423
|
+
candidates: forecast.consideredPaths.map((path) => ({
|
|
424
|
+
id: path.id,
|
|
425
|
+
score: path.score,
|
|
426
|
+
policy: {
|
|
427
|
+
executionMode: path.policy.executionMode,
|
|
428
|
+
swarmMode: path.policy.swarmMode,
|
|
429
|
+
maxBranches: path.policy.maxBranches,
|
|
430
|
+
rationale: path.policy.rationale
|
|
431
|
+
},
|
|
432
|
+
consequences: path.consequences
|
|
433
|
+
})),
|
|
434
|
+
executiveSummary: forecast.executiveSummary,
|
|
435
|
+
generatedAt: new Date().toISOString()
|
|
436
|
+
};
|
|
437
|
+
const simulation = this.outcomeSimulator.simulate({
|
|
438
|
+
goal: planning.normalizedGoal,
|
|
439
|
+
governanceRisk: governanceDecision.riskLevel,
|
|
440
|
+
preferredExecutors: forecast.selectedPath.executors,
|
|
441
|
+
basePolicy: forecast.selectedPath.policy
|
|
442
|
+
});
|
|
443
|
+
executionPolicy = simulation.recommendedPolicy;
|
|
444
|
+
state.attempts.push({
|
|
445
|
+
role: 'planner',
|
|
446
|
+
summary: `TOOL_TRACE search_files: capability route inference for domain=${inferredDomain} | Previsão de consequências: ${forecast.executiveSummary}`,
|
|
447
|
+
status: 'success',
|
|
448
|
+
at: new Date().toISOString()
|
|
449
|
+
});
|
|
450
|
+
state.attempts.push({
|
|
451
|
+
role: 'planner',
|
|
452
|
+
summary: `Pré-simulação: outcome=${simulation.predictedOutcome}; executores=${simulation.recommendedExecutors.join('>')}; ${simulation.rationale}`,
|
|
453
|
+
status: simulation.predictedOutcome === 'blocked' ? 'partial' : 'success',
|
|
454
|
+
at: new Date().toISOString()
|
|
455
|
+
});
|
|
456
|
+
let executorOutput = '';
|
|
457
|
+
let finalStatus = 'success';
|
|
458
|
+
if (dynamicAgent) {
|
|
459
|
+
const dynamicOutput = await this.dynamicAgentExecutor.execute(dynamicAgent, planning.normalizedGoal, taskId);
|
|
460
|
+
state.attempts.push({
|
|
461
|
+
role: 'executor',
|
|
462
|
+
summary: `Dynamic agent output: ${dynamicOutput.slice(0, 400)}`,
|
|
463
|
+
status: 'partial',
|
|
464
|
+
at: new Date().toISOString()
|
|
465
|
+
});
|
|
466
|
+
executorOutput += `\n\n[Dynamic Agent]\n${dynamicOutput}`;
|
|
467
|
+
}
|
|
468
|
+
if ((route.mode === 'parallel' || executionPolicy.swarmMode === 'consensus') && task.intent === IntentClassifier_1.TaskIntent.RESEARCH_ANALYSIS) {
|
|
469
|
+
const parallelResult = await this.parallelLoop.runResearchBranches(planning.normalizedGoal, `orchestration_${taskId}`, executionPolicy.maxBranches);
|
|
470
|
+
executorOutput += `\n\n[Parallel Arbitration]\n${parallelResult.arbitration.synthesis || parallelResult.branches.join('\n\n---\n\n')}`;
|
|
471
|
+
finalStatus = 'partial';
|
|
472
|
+
state.attempts.push({
|
|
473
|
+
role: 'executor',
|
|
474
|
+
summary: `Parallel arbitration: ${parallelResult.arbitration.rationale}. Scorecard: ${parallelResult.scorecard.map(s => `b${s.branchIndex}:${s.finalScore}`).join(', ')}. ${executorOutput.slice(0, 300)}`,
|
|
475
|
+
status: 'partial',
|
|
476
|
+
at: new Date().toISOString()
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
const runtimeDecision = this.runtimePolicy.decide(task.intent, simulation.recommendedExecutors);
|
|
481
|
+
const primaryExecutor = runtimeDecision.preferred[0];
|
|
482
|
+
if (!primaryExecutor) {
|
|
483
|
+
state.attempts.push({
|
|
484
|
+
role: 'executor',
|
|
485
|
+
summary: 'Nenhum executor disponível na cadeia configurada do usuário.',
|
|
486
|
+
status: 'failed',
|
|
487
|
+
at: new Date().toISOString()
|
|
488
|
+
});
|
|
489
|
+
state.status = 'failed';
|
|
490
|
+
state.finalAnswer = '❌ Nenhum executor disponível na cadeia configurada. Ajuste `openlife models set` e `openlife models fallbacks add`.';
|
|
491
|
+
this.executionBoard.updateStatus(taskId, 'blocked', 'Cadeia de execução indisponível sem fallback implícito.');
|
|
492
|
+
this.jobLifecycle.transition(job.jobId, workspaceId, 'failed', state.finalAnswer, 'orchestration-loop');
|
|
493
|
+
const missionPath = this.persistMissionAndService(state);
|
|
494
|
+
return { state, response: state.finalAnswer, missionPath };
|
|
495
|
+
}
|
|
496
|
+
const sandboxDecision = this.sandboxPolicy.evaluate(primaryExecutor, governanceDecision.riskLevel);
|
|
497
|
+
if (!sandboxDecision.allowed) {
|
|
498
|
+
const sandboxEvent = {
|
|
499
|
+
type: 'executor_blocked',
|
|
500
|
+
level: 'critical',
|
|
501
|
+
summary: sandboxDecision.rationale,
|
|
502
|
+
details: `executor=${primaryExecutor}`,
|
|
503
|
+
at: new Date().toISOString()
|
|
504
|
+
};
|
|
505
|
+
state.governanceEvents.push(sandboxEvent);
|
|
506
|
+
this.securityEventStore.append({ ...sandboxEvent, taskId, userId });
|
|
507
|
+
state.status = 'failed';
|
|
508
|
+
state.finalAnswer = `Missão bloqueada por sandbox policy: ${sandboxDecision.rationale}`;
|
|
509
|
+
this.executionBoard.updateStatus(taskId, 'blocked', sandboxDecision.rationale);
|
|
510
|
+
this.jobLifecycle.transition(job.jobId, workspaceId, 'failed', state.finalAnswer, 'orchestration-loop');
|
|
511
|
+
const missionPath = this.persistMissionAndService(state);
|
|
512
|
+
return { state, response: state.finalAnswer, missionPath };
|
|
513
|
+
}
|
|
514
|
+
const governancePrefix = `[Governance]\nRisk: ${governanceDecision.riskLevel}\nScope: ${governanceDecision.scope}\nMissionScope: ${scopeDecision.projectScope}\nSandboxMode: ${sandboxDecision.mode}\nRedactionRequired: ${governanceDecision.redactionRequired ? 'yes' : 'no'}\nPolicies: ${governanceDecision.matchedPolicies.join(', ')}\n\n`;
|
|
515
|
+
let execution = await this.taskExecutor.execute(primaryExecutor, `${governancePrefix}[Plano]\n${planning.plan.join('\n')}\n\n[Objetivo]\n${planning.normalizedGoal}\n\n[Squads]\n${squadRoute.squads.map(s => s.name).join('\n')}\n\n[Skills]\n${chosenSkills.map(s => s.name).join('\n')}\n\n[Reuse Hints]\n${reuseHints.map(h => h.summary).join('\n')}\n\n[Reused Assets]\n${reusedAssets.map(a => a.summary).join('\n')}`, `orchestration_${taskId}`);
|
|
516
|
+
this.runtimePolicy.recordResult(primaryExecutor, execution.ok, execution.stderr || execution.stdout || execution.status);
|
|
517
|
+
if (!execution.ok) {
|
|
518
|
+
const fallbackExecutor = runtimeDecision.preferred.find((executor) => executor !== primaryExecutor);
|
|
519
|
+
if (fallbackExecutor) {
|
|
520
|
+
execution = await this.taskExecutor.execute(fallbackExecutor, `[Plano]\n${planning.plan.join('\n')}\n\n[Objetivo]\n${planning.normalizedGoal}`, `orchestration_${taskId}_fallback`);
|
|
521
|
+
execution.fallbackUsed = true;
|
|
522
|
+
this.runtimePolicy.recordResult(fallbackExecutor, execution.ok, execution.stderr || execution.stdout || execution.status);
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
state.attempts.push({
|
|
526
|
+
role: 'executor',
|
|
527
|
+
summary: 'Executor primário falhou e nenhum fallback foi configurado pelo usuário.',
|
|
528
|
+
status: 'failed',
|
|
529
|
+
at: new Date().toISOString()
|
|
530
|
+
});
|
|
531
|
+
state.status = 'failed';
|
|
532
|
+
state.finalAnswer = '❌ O modelo primário falhou e não há fallback configurado. Defina modelos 2+ em `openlife models fallbacks add <provider/model>`.';
|
|
533
|
+
this.executionBoard.updateStatus(taskId, 'blocked', 'Sem fallback configurado para falha do executor primário.');
|
|
534
|
+
const missionPath = this.persistMissionAndService(state);
|
|
535
|
+
return { state, response: state.finalAnswer, missionPath };
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
const sanitizedOutput = governanceDecision.redactionRequired
|
|
539
|
+
? this.governance.redact(execution.stdout || execution.stderr || '')
|
|
540
|
+
: (execution.stdout || execution.stderr || '');
|
|
541
|
+
executorOutput += `\n\n[Primary Execution]\n${sanitizedOutput}`;
|
|
542
|
+
finalStatus = execution.fallbackUsed ? 'partial' : (execution.status || (execution.ok ? 'success' : 'failed'));
|
|
543
|
+
const traceCmd = String(execution.commandProvenance || execution.command?.join(' ') || '').replace(/\n/g, ' ').slice(0, 180);
|
|
544
|
+
state.attempts.push({
|
|
545
|
+
role: 'executor',
|
|
546
|
+
summary: `TOOL_TRACE write_file: artifact persisted at ${execution.artifactPath || 'n/a'} | TOOL_TRACE terminal: ${traceCmd} | ${sanitizedOutput.slice(0, 320) || 'Sem output útil do executor.'}`,
|
|
547
|
+
artifactPath: execution.artifactPath,
|
|
548
|
+
status: finalStatus,
|
|
549
|
+
at: new Date().toISOString()
|
|
550
|
+
});
|
|
551
|
+
if (execution.artifactPath)
|
|
552
|
+
state.artifacts.push(execution.artifactPath);
|
|
553
|
+
}
|
|
554
|
+
let review = await this.reviewer.review(planning.normalizedGoal, executorOutput, planning.successCriteria);
|
|
555
|
+
state.reviewFindings.push(review);
|
|
556
|
+
state.attempts.push({
|
|
557
|
+
role: 'reviewer',
|
|
558
|
+
summary: review.critique,
|
|
559
|
+
status: review.approved ? 'success' : 'partial',
|
|
560
|
+
at: new Date().toISOString()
|
|
561
|
+
});
|
|
562
|
+
if (!review.approved && planning.executionMode === 'review_loop') {
|
|
563
|
+
const refinedPrompt = `[Objetivo]\n${planning.normalizedGoal}\n\n[Plano]\n${planning.plan.join('\n')}\n\n[Feedback do reviewer]\n${review.critique}`;
|
|
564
|
+
const refinedExecution = await this.taskExecutor.execute('codex', refinedPrompt, `orchestration_${taskId}_refine`);
|
|
565
|
+
executorOutput += `\n\n[Refine]\n${refinedExecution.stdout || refinedExecution.stderr || ''}`;
|
|
566
|
+
finalStatus = refinedExecution.status || (refinedExecution.ok ? 'success' : 'failed');
|
|
567
|
+
state.attempts.push({
|
|
568
|
+
role: 'executor',
|
|
569
|
+
summary: `Refine: ${(refinedExecution.stdout || refinedExecution.stderr || '').slice(0, 500) || 'Sem output útil.'}`,
|
|
570
|
+
artifactPath: refinedExecution.artifactPath,
|
|
571
|
+
status: finalStatus,
|
|
572
|
+
at: new Date().toISOString()
|
|
573
|
+
});
|
|
574
|
+
if (refinedExecution.artifactPath)
|
|
575
|
+
state.artifacts.push(refinedExecution.artifactPath);
|
|
576
|
+
review = await this.reviewer.review(planning.normalizedGoal, executorOutput, planning.successCriteria);
|
|
577
|
+
state.reviewFindings.push(review);
|
|
578
|
+
}
|
|
579
|
+
const finalResponse = await this.synthesizer.synthesize(state, executorOutput, review);
|
|
580
|
+
state.finalAnswer = finalResponse;
|
|
581
|
+
state.status = review.approved ? 'completed' : 'failed';
|
|
582
|
+
state.updatedAt = new Date().toISOString();
|
|
583
|
+
state.attempts.push({
|
|
584
|
+
role: 'synthesizer',
|
|
585
|
+
summary: finalResponse.slice(0, 500),
|
|
586
|
+
status: review.approved ? 'success' : 'partial',
|
|
587
|
+
at: new Date().toISOString()
|
|
588
|
+
});
|
|
589
|
+
state.memoryCandidates = await this.memoryCurator.curate(state);
|
|
590
|
+
const serviceReport = this.serviceCompletionPolicy.evaluate(state);
|
|
591
|
+
if (!serviceReport.complete) {
|
|
592
|
+
state.status = 'failed';
|
|
593
|
+
const serviceFailure = `Serviço incompleto: faltam ${serviceReport.missing.join(', ')}`;
|
|
594
|
+
state.attempts.push({
|
|
595
|
+
role: 'reviewer',
|
|
596
|
+
summary: serviceFailure,
|
|
597
|
+
status: 'failed',
|
|
598
|
+
at: new Date().toISOString()
|
|
599
|
+
});
|
|
600
|
+
state.finalAnswer = `❌ Entrega recusada: serviço não foi concluído ponta a ponta (${serviceReport.missing.join('; ')}).`;
|
|
601
|
+
this.executionBoard.updateStatus(taskId, 'blocked', serviceFailure);
|
|
602
|
+
this.jobLifecycle.transition(job.jobId, workspaceId, 'failed', serviceFailure, 'orchestration-loop', serviceFailure);
|
|
603
|
+
const missionPath = this.persistMissionAndService(state);
|
|
604
|
+
return { state, response: state.finalAnswer, missionPath };
|
|
605
|
+
}
|
|
606
|
+
const scoreStatus = review.approved ? finalStatus : 'failed';
|
|
607
|
+
const numericReviewScore = review.score || 0;
|
|
608
|
+
const durationMs = 0;
|
|
609
|
+
const fallbackUsed = state.attempts.some((attempt) => attempt.role === 'executor' && attempt.status === 'partial');
|
|
610
|
+
for (const agent of state.chosenAgents) {
|
|
611
|
+
this.benchmarkEngine.record({
|
|
612
|
+
benchmarkId: state.taskId,
|
|
613
|
+
label: `agent:${agent.id}`,
|
|
614
|
+
entityId: agent.id,
|
|
615
|
+
entityType: 'agent',
|
|
616
|
+
score: numericReviewScore,
|
|
617
|
+
reviewScore: numericReviewScore,
|
|
618
|
+
durationMs,
|
|
619
|
+
fallbackUsed,
|
|
620
|
+
timestamp: new Date().toISOString()
|
|
621
|
+
});
|
|
622
|
+
this.agentScoring.record(agent.id, scoreStatus);
|
|
623
|
+
this.performanceScorecard.record({
|
|
624
|
+
entityId: agent.id,
|
|
625
|
+
entityType: 'agent',
|
|
626
|
+
status: scoreStatus,
|
|
627
|
+
durationMs,
|
|
628
|
+
reviewScore: numericReviewScore,
|
|
629
|
+
fallbackUsed,
|
|
630
|
+
timestamp: new Date().toISOString()
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
for (const squad of state.chosenSquads) {
|
|
634
|
+
this.benchmarkEngine.record({
|
|
635
|
+
benchmarkId: state.taskId,
|
|
636
|
+
label: `squad:${squad.id}`,
|
|
637
|
+
entityId: squad.id,
|
|
638
|
+
entityType: 'squad',
|
|
639
|
+
score: numericReviewScore,
|
|
640
|
+
reviewScore: numericReviewScore,
|
|
641
|
+
durationMs,
|
|
642
|
+
fallbackUsed,
|
|
643
|
+
timestamp: new Date().toISOString()
|
|
644
|
+
});
|
|
645
|
+
this.squadScoring.record(squad.id, scoreStatus);
|
|
646
|
+
this.performanceScorecard.record({
|
|
647
|
+
entityId: squad.id,
|
|
648
|
+
entityType: 'squad',
|
|
649
|
+
status: scoreStatus,
|
|
650
|
+
durationMs,
|
|
651
|
+
reviewScore: numericReviewScore,
|
|
652
|
+
fallbackUsed,
|
|
653
|
+
timestamp: new Date().toISOString()
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
for (const skill of state.chosenSkills) {
|
|
657
|
+
this.benchmarkEngine.record({
|
|
658
|
+
benchmarkId: state.taskId,
|
|
659
|
+
label: `skill:${skill.id}`,
|
|
660
|
+
entityId: skill.id,
|
|
661
|
+
entityType: 'skill',
|
|
662
|
+
score: numericReviewScore,
|
|
663
|
+
reviewScore: numericReviewScore,
|
|
664
|
+
durationMs,
|
|
665
|
+
fallbackUsed,
|
|
666
|
+
timestamp: new Date().toISOString()
|
|
667
|
+
});
|
|
668
|
+
this.skillScoring.record(skill.id, scoreStatus);
|
|
669
|
+
this.performanceScorecard.record({
|
|
670
|
+
entityId: skill.id,
|
|
671
|
+
entityType: 'skill',
|
|
672
|
+
status: scoreStatus,
|
|
673
|
+
durationMs,
|
|
674
|
+
reviewScore: numericReviewScore,
|
|
675
|
+
fallbackUsed,
|
|
676
|
+
timestamp: new Date().toISOString()
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
this.operationalMemory.add({
|
|
680
|
+
missionId: state.taskId,
|
|
681
|
+
goal: state.goal,
|
|
682
|
+
summary: state.finalAnswer || '',
|
|
683
|
+
lessons: state.memoryCandidates,
|
|
684
|
+
createdAt: new Date().toISOString()
|
|
685
|
+
});
|
|
686
|
+
const candidates = [];
|
|
687
|
+
if (dynamicAgent && scoreStatus !== 'failed') {
|
|
688
|
+
candidates.push({
|
|
689
|
+
id: dynamicAgent.id,
|
|
690
|
+
type: 'agent',
|
|
691
|
+
sourceMissionId: state.taskId,
|
|
692
|
+
summary: `Agente temporário executado com sucesso para a missão: ${state.goal}`,
|
|
693
|
+
createdAt: new Date().toISOString()
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
if (state.memoryCandidates.length > 0) {
|
|
697
|
+
candidates.push({
|
|
698
|
+
id: `playbook-${state.taskId}`,
|
|
699
|
+
type: 'playbook',
|
|
700
|
+
sourceMissionId: state.taskId,
|
|
701
|
+
summary: state.memoryCandidates.join(' | '),
|
|
702
|
+
createdAt: new Date().toISOString()
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
for (const candidate of candidates) {
|
|
706
|
+
this.promotionPipeline.add(candidate);
|
|
707
|
+
if (this.promotionGate.approve(candidate))
|
|
708
|
+
this.promotionEngine.promote(candidate);
|
|
709
|
+
}
|
|
710
|
+
this.optimizationLoop.generateSuggestions();
|
|
711
|
+
this.cadenceEngine.schedule('review', `Review ${taskId}`, ownerRole, taskId);
|
|
712
|
+
this.executionBoard.updateStatus(taskId, review.approved ? 'done' : 'blocked', review.approved ? undefined : review.critique);
|
|
713
|
+
if (review.approved) {
|
|
714
|
+
this.cadenceEngine.schedule('release', `Release ${taskId}`, 'coo', taskId);
|
|
715
|
+
const opsDecision = this.operatingSystem.decide(taskId);
|
|
716
|
+
if (opsDecision.shouldRelease) {
|
|
717
|
+
await this.releaseGate.run(`release_${taskId}`, taskId);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
this.jobLifecycle.transition(job.jobId, workspaceId, review.approved ? 'completed' : 'failed', review.approved ? 'Job completed successfully' : 'Job failed in final review', 'orchestration-loop');
|
|
721
|
+
const missionPath = this.persistMissionAndService(state);
|
|
722
|
+
// v1.3 Story 5.5 — post-mission learning hook (best-effort; non-fatal).
|
|
723
|
+
this.firePostMissionHook(state);
|
|
724
|
+
return { state, response: finalResponse, missionPath };
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Story 5.5 — Post-mission learning hook.
|
|
728
|
+
*
|
|
729
|
+
* Fires after the final return of run(). Best-effort:
|
|
730
|
+
* 1. SkillLearningLoop.add() — record a candidate if the mission
|
|
731
|
+
* surfaced an actionable gap.
|
|
732
|
+
* 2. OmniMemory.saveFact() — index the consequence thought-trace
|
|
733
|
+
* so future missions with similar intent retrieve prior rationale.
|
|
734
|
+
*
|
|
735
|
+
* Disable via OPENLIFE_POST_MISSION_HOOK=off.
|
|
736
|
+
*
|
|
737
|
+
* NOTE: completely silent on failure — this is advisory, never a gate.
|
|
738
|
+
*/
|
|
739
|
+
firePostMissionHook(state) {
|
|
740
|
+
if (process.env.OPENLIFE_POST_MISSION_HOOK === 'off')
|
|
741
|
+
return;
|
|
742
|
+
try {
|
|
743
|
+
// SkillLearningLoop add — only if the mission had reviewFindings
|
|
744
|
+
// (which surface gaps the loop can learn from). Existing
|
|
745
|
+
// SkillLearningLoopStore is robust to missing fields.
|
|
746
|
+
// Loaded lazily to avoid moving heavy imports to module scope.
|
|
747
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
748
|
+
const { SkillLearningLoopStore } = require('./SkillLearningLoop');
|
|
749
|
+
const store = new SkillLearningLoopStore();
|
|
750
|
+
const summary = (state.reviewFindings || [])
|
|
751
|
+
.filter((r) => !r.approved)
|
|
752
|
+
.map((r) => r.critique)
|
|
753
|
+
.filter(Boolean)
|
|
754
|
+
.join(' | ')
|
|
755
|
+
.slice(0, 240);
|
|
756
|
+
if (summary && summary.length > 30) {
|
|
757
|
+
store.add(state.taskId, summary);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
catch { /* non-fatal */ }
|
|
761
|
+
// Story 8.3 — Brain-driven consolidation into OmniMemory.
|
|
762
|
+
// Disable via OPENLIFE_POST_MISSION_CONSOLIDATION=off.
|
|
763
|
+
// Best-effort, async-no-await — never blocks the return path.
|
|
764
|
+
if (process.env.OPENLIFE_POST_MISSION_CONSOLIDATION !== 'off') {
|
|
765
|
+
this.consolidateToMemory(state).catch(() => { });
|
|
766
|
+
}
|
|
767
|
+
// Story 13.1 (v1.5) — Brain-driven post-mission evaluation. Closes the
|
|
768
|
+
// "consolidation only" caveat from v1.4 by judging the mission outcome
|
|
769
|
+
// against successCriteria and persisting a structured evaluation under
|
|
770
|
+
// .openlife/evaluations/ via MissionEvaluationStore. Disable via
|
|
771
|
+
// OPENLIFE_POST_MISSION_EVALUATION=off. Heuristic fallback if no Brain key.
|
|
772
|
+
if (process.env.OPENLIFE_POST_MISSION_EVALUATION !== 'off') {
|
|
773
|
+
this.evaluateMission(state).catch(() => { });
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Story 8.3 helper — summarize the mission's consequence thought-trace
|
|
778
|
+
* via Brain and persist it to OmniMemory so future missions retrieve
|
|
779
|
+
* prior rationale. Silent on every failure path; never blocks.
|
|
780
|
+
*/
|
|
781
|
+
async consolidateToMemory(state) {
|
|
782
|
+
try {
|
|
783
|
+
// Lazy imports — heavy classes stay out of module scope.
|
|
784
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
785
|
+
const { Brain } = require('./Brain');
|
|
786
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
787
|
+
const { OmniMemory } = require('../memory/OmniMemory');
|
|
788
|
+
const brain = new Brain();
|
|
789
|
+
if (!brain.isAnyProviderAvailable())
|
|
790
|
+
return; // no API key → skip
|
|
791
|
+
const trace = state.consequenceThoughtTrace;
|
|
792
|
+
if (!trace)
|
|
793
|
+
return; // nothing to consolidate
|
|
794
|
+
const systemPrompt = 'You are a memory consolidator. Given a mission state + consequence trace, produce ONE SHORT FACT (max 200 chars) capturing what worked or failed. Output a single line of plain text — no markdown, no JSON, no preamble.';
|
|
795
|
+
const userMessage = `Goal: ${state.goal}\nStatus: ${state.status}\nTrace summary: ${JSON.stringify(trace).slice(0, 800)}`;
|
|
796
|
+
const fact = (await brain.think(systemPrompt, userMessage)).trim().slice(0, 240);
|
|
797
|
+
if (!fact)
|
|
798
|
+
return;
|
|
799
|
+
const omni = new OmniMemory();
|
|
800
|
+
await omni.saveFact(fact, {
|
|
801
|
+
source_uri: `mission://${state.taskId}`,
|
|
802
|
+
timestamp: Date.now(),
|
|
803
|
+
}, 'post-mission-consolidation');
|
|
804
|
+
}
|
|
805
|
+
catch { /* non-fatal */ }
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Story 13.1 (v1.5) — Brain-driven post-mission evaluation.
|
|
809
|
+
*
|
|
810
|
+
* Judges the completed mission against its `successCriteria` and writes
|
|
811
|
+
* a structured evaluation to `.openlife/evaluations/<taskId>.json` via
|
|
812
|
+
* `MissionEvaluationStore`. Two paths:
|
|
813
|
+
*
|
|
814
|
+
* • Brain available → asks Brain for `{ score: 0-100, verdict: 'ready_for_review' | 'needs_iteration', risks: string[], rationale: string }`.
|
|
815
|
+
* • No Brain key → falls back to the existing heuristic `judge()` so
|
|
816
|
+
* callers always get a record.
|
|
817
|
+
*
|
|
818
|
+
* Silent on every failure path. The evaluation file is additive — it
|
|
819
|
+
* never overwrites the mission state itself.
|
|
820
|
+
*/
|
|
821
|
+
async evaluateMission(state) {
|
|
822
|
+
try {
|
|
823
|
+
// Lazy imports — heavy classes stay out of module scope.
|
|
824
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
825
|
+
const { MissionEvaluationStore } = require('./EnterpriseAgenticCore');
|
|
826
|
+
const store = new MissionEvaluationStore();
|
|
827
|
+
const criteria = (state.successCriteria || []).filter((c) => typeof c === 'string' && c.trim().length > 0);
|
|
828
|
+
const criteriaCsv = criteria.join(',');
|
|
829
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
830
|
+
const { Brain } = require('./Brain');
|
|
831
|
+
const brain = new Brain();
|
|
832
|
+
if (!brain.isAnyProviderAvailable()) {
|
|
833
|
+
// Heuristic fallback — still produces an evaluation record.
|
|
834
|
+
if (criteria.length > 0)
|
|
835
|
+
store.judge(state.taskId, criteriaCsv);
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
const systemPrompt = [
|
|
839
|
+
'You are a mission outcome evaluator.',
|
|
840
|
+
'Given a goal, status, success criteria, and the consequence trace, judge whether the mission delivered.',
|
|
841
|
+
'Reply with ONE LINE of JSON: { "score": 0-100, "verdict": "ready_for_review" | "needs_iteration", "risks": ["..."], "rationale": "..." }',
|
|
842
|
+
'No markdown, no preamble.',
|
|
843
|
+
].join(' ');
|
|
844
|
+
const userMessage = [
|
|
845
|
+
`Goal: ${state.goal}`,
|
|
846
|
+
`Status: ${state.status}`,
|
|
847
|
+
`Success criteria: ${criteria.length > 0 ? criteria.join(' | ') : '(none specified)'}`,
|
|
848
|
+
`Trace summary: ${state.consequenceThoughtTrace ? JSON.stringify(state.consequenceThoughtTrace).slice(0, 800) : '(no trace)'}`,
|
|
849
|
+
`Reviewer findings: ${(state.reviewFindings || []).map((r) => `${r.approved ? '✅' : '❌'} ${r.critique || ''}`).join(' | ').slice(0, 400) || '(none)'}`,
|
|
850
|
+
].join('\n');
|
|
851
|
+
const raw = await brain.think(systemPrompt, userMessage);
|
|
852
|
+
const parsed = this.parseEvaluationJson(raw);
|
|
853
|
+
if (!parsed) {
|
|
854
|
+
// Parse failed → heuristic fallback so the record still lands.
|
|
855
|
+
if (criteria.length > 0)
|
|
856
|
+
store.judge(state.taskId, criteriaCsv);
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
// Seed the heuristic record so the file exists, then overwrite with
|
|
860
|
+
// Brain-derived fields atomically.
|
|
861
|
+
if (criteria.length > 0)
|
|
862
|
+
store.judge(state.taskId, criteriaCsv);
|
|
863
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
864
|
+
const fs = require('fs');
|
|
865
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
866
|
+
const path = require('path');
|
|
867
|
+
const evalPath = path.join(store.dir(), `${state.taskId}.json`);
|
|
868
|
+
const enriched = {
|
|
869
|
+
mission: state.taskId,
|
|
870
|
+
criteria,
|
|
871
|
+
score: parsed.score,
|
|
872
|
+
verdict: parsed.verdict,
|
|
873
|
+
risks: parsed.risks,
|
|
874
|
+
rationale: parsed.rationale,
|
|
875
|
+
source: 'brain',
|
|
876
|
+
createdAt: new Date().toISOString(),
|
|
877
|
+
path: evalPath,
|
|
878
|
+
};
|
|
879
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
880
|
+
const { writeStringAtomic } = require('./util/AtomicWriter');
|
|
881
|
+
writeStringAtomic(evalPath, JSON.stringify(enriched, null, 2));
|
|
882
|
+
}
|
|
883
|
+
catch { /* non-fatal */ }
|
|
884
|
+
}
|
|
885
|
+
parseEvaluationJson(raw) {
|
|
886
|
+
try {
|
|
887
|
+
const start = raw.indexOf('{');
|
|
888
|
+
const end = raw.lastIndexOf('}');
|
|
889
|
+
if (start < 0 || end <= start)
|
|
890
|
+
return null;
|
|
891
|
+
const parsed = JSON.parse(raw.slice(start, end + 1));
|
|
892
|
+
const score = typeof parsed.score === 'number' ? Math.max(0, Math.min(100, Math.round(parsed.score))) : null;
|
|
893
|
+
const verdict = parsed.verdict === 'ready_for_review' || parsed.verdict === 'needs_iteration' ? parsed.verdict : null;
|
|
894
|
+
const risks = Array.isArray(parsed.risks) ? parsed.risks.filter((r) => typeof r === 'string').slice(0, 10) : [];
|
|
895
|
+
const rationale = typeof parsed.rationale === 'string' ? parsed.rationale.slice(0, 600) : '';
|
|
896
|
+
if (score === null || verdict === null)
|
|
897
|
+
return null;
|
|
898
|
+
return { score, verdict, risks, rationale };
|
|
899
|
+
}
|
|
900
|
+
catch {
|
|
901
|
+
return null;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
exports.OrchestrationLoop = OrchestrationLoop;
|