@noorm/marie-cli 0.1.17 → 0.1.25
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 +7 -15
- package/SENTINEL.md +4 -7
- package/dist/cli-new/components/AgenticSpinner.js +28 -0
- package/dist/cli-new/components/AgenticSpinner.js.map +1 -0
- package/dist/cli-new/components/App.js +16 -63
- package/dist/cli-new/components/App.js.map +1 -1
- package/dist/cli-new/components/ApprovalDialog.js +3 -2
- package/dist/cli-new/components/ApprovalDialog.js.map +1 -1
- package/dist/cli-new/components/Banner.js +16 -5
- package/dist/cli-new/components/Banner.js.map +1 -1
- package/dist/cli-new/components/ChatArea.js +6 -7
- package/dist/cli-new/components/ChatArea.js.map +1 -1
- package/dist/cli-new/components/Header.js +14 -8
- package/dist/cli-new/components/Header.js.map +1 -1
- package/dist/cli-new/components/InputArea.js +98 -31
- package/dist/cli-new/components/InputArea.js.map +1 -1
- package/dist/cli-new/components/MessageBubble.js +28 -19
- package/dist/cli-new/components/MessageBubble.js.map +1 -1
- package/dist/cli-new/components/SessionSwitcher.js +6 -9
- package/dist/cli-new/components/SessionSwitcher.js.map +1 -1
- package/dist/cli-new/components/SetupWizard.js +80 -257
- package/dist/cli-new/components/SetupWizard.js.map +1 -1
- package/dist/cli-new/components/ToolCallDisplay.js +20 -5
- package/dist/cli-new/components/ToolCallDisplay.js.map +1 -1
- package/dist/cli-new/components/WizardSteps.js +22 -0
- package/dist/cli-new/components/WizardSteps.js.map +1 -0
- package/dist/cli-new/constants/SetupConstants.js +42 -0
- package/dist/cli-new/constants/SetupConstants.js.map +1 -0
- package/dist/cli-new/hooks/useGit.js +19 -62
- package/dist/cli-new/hooks/useGit.js.map +1 -1
- package/dist/cli-new/hooks/useMarie.js +26 -18
- package/dist/cli-new/hooks/useMarie.js.map +1 -1
- package/dist/cli-new/hooks/useSessions.js +1 -1
- package/dist/cli-new/hooks/useSessions.js.map +1 -1
- package/dist/cli-new/hooks/useSetupWizard.js +88 -0
- package/dist/cli-new/hooks/useSetupWizard.js.map +1 -0
- package/dist/cli-new/hooks/useUpdateCheck.js +4 -3
- package/dist/cli-new/hooks/useUpdateCheck.js.map +1 -1
- package/dist/cli-new/index.js +2 -4
- package/dist/cli-new/index.js.map +1 -1
- package/dist/cli-new/services/CommandService.js +104 -0
- package/dist/cli-new/services/CommandService.js.map +1 -0
- package/dist/cli-new/services/GitService.js +91 -0
- package/dist/cli-new/services/GitService.js.map +1 -0
- package/dist/cli-new/services/MarieService.js +77 -0
- package/dist/cli-new/services/MarieService.js.map +1 -0
- package/dist/cli-new/services/auth-server.js +128 -0
- package/dist/cli-new/services/auth-server.js.map +1 -0
- package/dist/cli-new/styles/theme.js +17 -17
- package/dist/cli-new/styles/theme.js.map +1 -1
- package/dist/cli-new/utils/version.js +24 -0
- package/dist/cli-new/utils/version.js.map +1 -0
- package/dist/monolith/adapters/CliMarieAdapter.js +19 -18
- package/dist/monolith/adapters/CliMarieAdapter.js.map +1 -1
- package/dist/monolith/cli/CliFileSystemPort.js +17 -3
- package/dist/monolith/cli/CliFileSystemPort.js.map +1 -1
- package/dist/monolith/cli/MarieToolDefinitionsCLI.js +44 -33
- package/dist/monolith/cli/MarieToolDefinitionsCLI.js.map +1 -1
- package/dist/monolith/cli/index.js +11 -20
- package/dist/monolith/cli/index.js.map +1 -1
- package/dist/monolith/cli/services/JoyAutomationServiceCLI.js +15 -62
- package/dist/monolith/cli/services/JoyAutomationServiceCLI.js.map +1 -1
- package/dist/monolith/cli/storage.js +154 -65
- package/dist/monolith/cli/storage.js.map +1 -1
- package/dist/monolith/domain/joy/RitualService.js +44 -46
- package/dist/monolith/domain/joy/RitualService.js.map +1 -1
- package/dist/monolith/domain/marie/MarieCortex.js +148 -0
- package/dist/monolith/domain/marie/MarieCortex.js.map +1 -0
- package/dist/monolith/domain/marie/PersonalityRenderer.js +97 -0
- package/dist/monolith/domain/marie/PersonalityRenderer.js.map +1 -0
- package/dist/monolith/infrastructure/Configuration.js +68 -0
- package/dist/monolith/infrastructure/Configuration.js.map +1 -0
- package/dist/monolith/infrastructure/CoreInfrastructure.js +204 -0
- package/dist/monolith/infrastructure/CoreInfrastructure.js.map +1 -0
- package/dist/monolith/infrastructure/ai/agents/MarieAscendant.js +3 -3
- package/dist/monolith/infrastructure/ai/agents/MarieAscendant.js.map +1 -1
- package/dist/monolith/infrastructure/ai/context/ContextArchiveService.js +51 -57
- package/dist/monolith/infrastructure/ai/context/ContextArchiveService.js.map +1 -1
- package/dist/monolith/infrastructure/ai/context/ContextManager.js +142 -98
- package/dist/monolith/infrastructure/ai/context/ContextManager.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieEngine.js +104 -556
- package/dist/monolith/infrastructure/ai/core/MarieEngine.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieEventDispatcher.js +1 -37
- package/dist/monolith/infrastructure/ai/core/MarieEventDispatcher.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieLockManager.js +30 -5
- package/dist/monolith/infrastructure/ai/core/MarieLockManager.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieProgressTracker.js +176 -196
- package/dist/monolith/infrastructure/ai/core/MarieProgressTracker.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MariePulseService.js +41 -7
- package/dist/monolith/infrastructure/ai/core/MariePulseService.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieSanitizer.js +303 -63
- package/dist/monolith/infrastructure/ai/core/MarieSanitizer.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieSemaphore.js +47 -4
- package/dist/monolith/infrastructure/ai/core/MarieSemaphore.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieSession.js +95 -15
- package/dist/monolith/infrastructure/ai/core/MarieSession.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieStabilityMonitor.js +21 -0
- package/dist/monolith/infrastructure/ai/core/MarieStabilityMonitor.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieToolMender.js +12 -0
- package/dist/monolith/infrastructure/ai/core/MarieToolMender.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieToolProcessor.js +339 -481
- package/dist/monolith/infrastructure/ai/core/MarieToolProcessor.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieVitality.js +238 -0
- package/dist/monolith/infrastructure/ai/core/MarieVitality.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/ReasoningBudget.js +23 -12
- package/dist/monolith/infrastructure/ai/core/ReasoningBudget.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/SessionLogService.js +9 -2
- package/dist/monolith/infrastructure/ai/core/SessionLogService.js.map +1 -1
- package/dist/monolith/infrastructure/ai/providers/AIProvider.js +402 -1
- package/dist/monolith/infrastructure/ai/providers/AIProvider.js.map +1 -1
- package/dist/monolith/infrastructure/ai/providers/DreamBeesProvider.js +114 -0
- package/dist/monolith/infrastructure/ai/providers/DreamBeesProvider.js.map +1 -0
- package/dist/monolith/infrastructure/ai/providers/OpenRouterProvider.js +426 -370
- package/dist/monolith/infrastructure/ai/providers/OpenRouterProvider.js.map +1 -1
- package/dist/monolith/infrastructure/ai/providers/OpenRouterStreamParser.js +235 -241
- package/dist/monolith/infrastructure/ai/providers/OpenRouterStreamParser.js.map +1 -1
- package/dist/monolith/infrastructure/ai/workerAi.js +185 -0
- package/dist/monolith/infrastructure/ai/workerAi.js.map +1 -0
- package/dist/monolith/infrastructure/config/ConfigService.js +216 -359
- package/dist/monolith/infrastructure/config/ConfigService.js.map +1 -1
- package/dist/monolith/infrastructure/joy/CognitiveRituals.js +8 -0
- package/dist/monolith/infrastructure/joy/CognitiveRituals.js.map +1 -0
- package/dist/monolith/infrastructure/joy/JoyTools.js +23 -43
- package/dist/monolith/infrastructure/joy/JoyTools.js.map +1 -1
- package/dist/monolith/infrastructure/persistence/MarieMindAutonomics.js +4 -0
- package/dist/monolith/infrastructure/persistence/MarieMindAutonomics.js.map +1 -0
- package/dist/monolith/infrastructure/persistence/MarieMindEngine.js +11 -0
- package/dist/monolith/infrastructure/persistence/MarieMindEngine.js.map +1 -0
- package/dist/monolith/infrastructure/persistence/NoormmeAutonomics.js +135 -0
- package/dist/monolith/infrastructure/persistence/NoormmeAutonomics.js.map +1 -0
- package/dist/monolith/infrastructure/persistence/NoormmeEngine.js +523 -0
- package/dist/monolith/infrastructure/persistence/NoormmeEngine.js.map +1 -0
- package/dist/monolith/infrastructure/persistence/NoormmeSchema.js +179 -0
- package/dist/monolith/infrastructure/persistence/NoormmeSchema.js.map +1 -0
- package/dist/monolith/infrastructure/persistence/NoormmeSeeder.js +94 -0
- package/dist/monolith/infrastructure/persistence/NoormmeSeeder.js.map +1 -0
- package/dist/monolith/infrastructure/persistence/NoormmeTools.js +371 -0
- package/dist/monolith/infrastructure/persistence/NoormmeTools.js.map +1 -0
- package/dist/monolith/infrastructure/services/MarieMemoryStore.js +133 -134
- package/dist/monolith/infrastructure/services/MarieMemoryStore.js.map +1 -1
- package/dist/monolith/infrastructure/tools/MarieToolDefinitions.js +6 -1578
- package/dist/monolith/infrastructure/tools/MarieToolDefinitions.js.map +1 -1
- package/dist/monolith/infrastructure/tools/PureStreamParser.js +68 -80
- package/dist/monolith/infrastructure/tools/PureStreamParser.js.map +1 -1
- package/dist/monolith/infrastructure/tools/SharedToolDefinitions.js +12 -11
- package/dist/monolith/infrastructure/tools/SharedToolDefinitions.js.map +1 -1
- package/dist/monolith/infrastructure/tools/SovereignTools.js +326 -0
- package/dist/monolith/infrastructure/tools/SovereignTools.js.map +1 -0
- package/dist/monolith/infrastructure/tools/ToolRegistry.js +45 -26
- package/dist/monolith/infrastructure/tools/ToolRegistry.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/AnalysisTools.js +232 -0
- package/dist/monolith/infrastructure/tools/definitions/AnalysisTools.js.map +1 -0
- package/dist/monolith/infrastructure/tools/definitions/AutomationTools.js +274 -0
- package/dist/monolith/infrastructure/tools/definitions/AutomationTools.js.map +1 -0
- package/dist/monolith/infrastructure/tools/definitions/ContextTools.js +71 -0
- package/dist/monolith/infrastructure/tools/definitions/ContextTools.js.map +1 -0
- package/dist/monolith/infrastructure/tools/definitions/CoreTools.js +37 -0
- package/dist/monolith/infrastructure/tools/definitions/CoreTools.js.map +1 -0
- package/dist/monolith/infrastructure/tools/definitions/DiagnosticTools.js +154 -0
- package/dist/monolith/infrastructure/tools/definitions/DiagnosticTools.js.map +1 -0
- package/dist/monolith/infrastructure/tools/definitions/NavigationTools.js +197 -0
- package/dist/monolith/infrastructure/tools/definitions/NavigationTools.js.map +1 -0
- package/dist/monolith/infrastructure/tools/definitions/PlanningTools.js +300 -0
- package/dist/monolith/infrastructure/tools/definitions/PlanningTools.js.map +1 -0
- package/dist/monolith/plumbing/Plumbing.js +238 -0
- package/dist/monolith/plumbing/Plumbing.js.map +1 -0
- package/dist/monolith/plumbing/PlumbingAnalysis.js +109 -0
- package/dist/monolith/plumbing/PlumbingAnalysis.js.map +1 -0
- package/dist/monolith/plumbing/PlumbingSystem.js +169 -0
- package/dist/monolith/plumbing/PlumbingSystem.js.map +1 -0
- package/dist/monolith/plumbing/analysis/ComplexityService.js +30 -34
- package/dist/monolith/plumbing/analysis/ComplexityService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/DependencyService.js +55 -44
- package/dist/monolith/plumbing/analysis/DependencyService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/DiscoveryService.js +40 -42
- package/dist/monolith/plumbing/analysis/DiscoveryService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/JoyMapService.js +52 -56
- package/dist/monolith/plumbing/analysis/JoyMapService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/LintService.js +118 -118
- package/dist/monolith/plumbing/analysis/LintService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/MarieSentinelService.js +278 -269
- package/dist/monolith/plumbing/analysis/MarieSentinelService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/QualityGuardrailService.js +116 -114
- package/dist/monolith/plumbing/analysis/QualityGuardrailService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/SurgicalMender.js +57 -59
- package/dist/monolith/plumbing/analysis/SurgicalMender.js.map +1 -1
- package/dist/monolith/plumbing/analysis/TestService.js +89 -89
- package/dist/monolith/plumbing/analysis/TestService.js.map +1 -1
- package/dist/monolith/plumbing/filesystem/FileService.js +123 -195
- package/dist/monolith/plumbing/filesystem/FileService.js.map +1 -1
- package/dist/monolith/plumbing/filesystem/PathResolver.js +7 -8
- package/dist/monolith/plumbing/filesystem/PathResolver.js.map +1 -1
- package/dist/monolith/plumbing/git/GitService.js +4 -4
- package/dist/monolith/plumbing/git/GitService.js.map +1 -1
- package/dist/monolith/plumbing/lsp/SymbolService.js +5 -34
- package/dist/monolith/plumbing/lsp/SymbolService.js.map +1 -1
- package/dist/monolith/plumbing/terminal/ProcessRegistry.js +20 -22
- package/dist/monolith/plumbing/terminal/ProcessRegistry.js.map +1 -1
- package/dist/monolith/plumbing/terminal/TerminalService.js +127 -136
- package/dist/monolith/plumbing/terminal/TerminalService.js.map +1 -1
- package/dist/monolith/plumbing/utils/EnvironmentUtils.js +3 -23
- package/dist/monolith/plumbing/utils/EnvironmentUtils.js.map +1 -1
- package/dist/monolith/plumbing/utils/JsonUtils.js +252 -311
- package/dist/monolith/plumbing/utils/JsonUtils.js.map +1 -1
- package/dist/monolith/plumbing/utils/MutexUtils.js.map +1 -1
- package/dist/monolith/plumbing/utils/PlumbingCore.js +549 -0
- package/dist/monolith/plumbing/utils/PlumbingCore.js.map +1 -0
- package/dist/monolith/plumbing/utils/PrefixTree.js +61 -114
- package/dist/monolith/plumbing/utils/PrefixTree.js.map +1 -1
- package/dist/monolith/plumbing/utils/StreamTagDetector.js +89 -127
- package/dist/monolith/plumbing/utils/StreamTagDetector.js.map +1 -1
- package/dist/monolith/plumbing/utils/StringUtils.js +87 -89
- package/dist/monolith/plumbing/utils/StringUtils.js.map +1 -1
- package/dist/monolith/runtime/MarieRuntime.js +76 -417
- package/dist/monolith/runtime/MarieRuntime.js.map +1 -1
- package/dist/monolith/runtime/RuntimeAdapterBase.js +1 -1
- package/dist/monolith/runtime/RuntimeAdapterBase.js.map +1 -1
- package/dist/monolith/runtime/providerFactory.js +1 -7
- package/dist/monolith/runtime/providerFactory.js.map +1 -1
- package/dist/monolith/services/HealthService.js +29 -32
- package/dist/monolith/services/HealthService.js.map +1 -1
- package/dist/monolith/services/JoyAutomationService.js +58 -95
- package/dist/monolith/services/JoyAutomationService.js.map +1 -1
- package/dist/monolith/services/MarieAutomationService.js +59 -0
- package/dist/monolith/services/MarieAutomationService.js.map +1 -0
- package/dist/monolith/services/MarieGhostService.js +46 -161
- package/dist/monolith/services/MarieGhostService.js.map +1 -1
- package/dist/monolith/services/MarieServices.js +102 -0
- package/dist/monolith/services/MarieServices.js.map +1 -0
- package/dist/monolith/services/MarieTypes.js +2 -0
- package/dist/monolith/services/MarieTypes.js.map +1 -0
- package/dist/monolith/services/UpdateService.js +47 -49
- package/dist/monolith/services/UpdateService.js.map +1 -1
- package/dist/prompts.js +11 -5
- package/dist/prompts.js.map +1 -1
- package/dist/test_prefix_tree.js +9 -9
- package/dist/test_prefix_tree.js.map +1 -1
- package/package.json +18 -88
- package/run_test.js +5 -0
- package/.marie_visual_verify_1771225696548/progress_bar_check.txt +0 -1
- package/dist/extension.cjs +0 -635
- package/dist/extension.js +0 -473
- package/dist/extension.js.map +0 -1
- package/dist/monolith/adapters/VscodeMarieAdapter.js +0 -81
- package/dist/monolith/adapters/VscodeMarieAdapter.js.map +0 -1
- package/dist/monolith/domain/joy/JoyTools.js +0 -535
- package/dist/monolith/domain/joy/JoyTools.js.map +0 -1
- package/dist/monolith/infrastructure/ai/agents/MarieYOLO.js +0 -207
- package/dist/monolith/infrastructure/ai/agents/MarieYOLO.js.map +0 -1
- package/dist/monolith/infrastructure/ai/core/GhostPort.js +0 -2
- package/dist/monolith/infrastructure/ai/core/GhostPort.js.map +0 -1
- package/dist/monolith/infrastructure/ai/core/MarieYOLOTypes.js +0 -2
- package/dist/monolith/infrastructure/ai/core/MarieYOLOTypes.js.map +0 -1
- package/dist/monolith/infrastructure/ai/core/VscodeFileSystemPort.js +0 -33
- package/dist/monolith/infrastructure/ai/core/VscodeFileSystemPort.js.map +0 -1
- package/dist/monolith/infrastructure/ai/providers/AnthropicProvider.js +0 -148
- package/dist/monolith/infrastructure/ai/providers/AnthropicProvider.js.map +0 -1
- package/dist/monolith/infrastructure/ai/providers/CerebrasProvider.js +0 -208
- package/dist/monolith/infrastructure/ai/providers/CerebrasProvider.js.map +0 -1
- package/dist/monolith/plumbing/ui/DecorationService.js +0 -54
- package/dist/monolith/plumbing/ui/DecorationService.js.map +0 -1
- package/dist/monolith/services/JoyLogService.js +0 -48
- package/dist/monolith/services/JoyLogService.js.map +0 -1
- package/dist/monolith/services/JoyService.js +0 -209
- package/dist/monolith/services/JoyService.js.map +0 -1
- package/dist/monolith/services/MarieSCMProvider.js +0 -41
- package/dist/monolith/services/MarieSCMProvider.js.map +0 -1
- package/dist/test_agent_stream_control_plane.js +0 -170
- package/dist/test_agent_stream_control_plane.js.map +0 -1
- package/dist/test_strategy_integration.js +0 -114
- package/dist/test_strategy_integration.js.map +0 -1
- package/dist/test_streaming_fragility.js +0 -191
- package/dist/test_streaming_fragility.js.map +0 -1
- package/dist/webview-ui/App.js +0 -16
- package/dist/webview-ui/App.js.map +0 -1
- package/dist/webview-ui/Providers.js +0 -6
- package/dist/webview-ui/Providers.js.map +0 -1
- package/dist/webview-ui/components/ApprovalPanel.js +0 -8
- package/dist/webview-ui/components/ApprovalPanel.js.map +0 -1
- package/dist/webview-ui/components/ChatPanel.js +0 -19
- package/dist/webview-ui/components/ChatPanel.js.map +0 -1
- package/dist/webview-ui/components/Composer.js +0 -19
- package/dist/webview-ui/components/Composer.js.map +0 -1
- package/dist/webview-ui/components/HeaderBar.js +0 -5
- package/dist/webview-ui/components/HeaderBar.js.map +0 -1
- package/dist/webview-ui/components/SessionList.js +0 -14
- package/dist/webview-ui/components/SessionList.js.map +0 -1
- package/dist/webview-ui/context/WebviewStateContext.js +0 -146
- package/dist/webview-ui/context/WebviewStateContext.js.map +0 -1
- package/dist/webview-ui/main.css +0 -1
- package/dist/webview-ui/main.js +0 -108
- package/dist/webview-ui/main.js.map +0 -1
- package/dist/webview-ui/types.js +0 -2
- package/dist/webview-ui/types.js.map +0 -1
- package/dist/webview-ui/vscode.js +0 -4
- package/dist/webview-ui/vscode.js.map +0 -1
- package/lint_output.txt +0 -705
- package/lint_output_v2.txt +0 -711
- package/marie-coder-0.1.16.vsix +0 -0
|
@@ -1,587 +1,135 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { MarieLockManager } from "./MarieLockManager.js";
|
|
7
|
-
import { MarieToolMender } from "./MarieToolMender.js";
|
|
8
|
-
import { MariePulseService } from "./MariePulseService.js";
|
|
9
|
-
import { MarieStabilityMonitor } from "./MarieStabilityMonitor.js";
|
|
10
|
-
import { ReasoningBudget } from "./ReasoningBudget.js";
|
|
11
|
-
import { SessionLogService } from "./SessionLogService.js";
|
|
12
|
-
import { MarieSemaphore } from "./MarieSemaphore.js";
|
|
13
|
-
export function getPromptProfileForDepth(depth) {
|
|
14
|
-
return depth > 0 ? "continuation" : "full";
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Entry point for the AI Engine. YOLO Supremacy Edition.
|
|
18
|
-
*/
|
|
1
|
+
import { getTool, getRegisteredTools } from "../../tools/SovereignTools.js";
|
|
2
|
+
import { getModel, getMaxRecursiveDepth, } from "../../Configuration.js";
|
|
3
|
+
import { manageContext } from "../../CoreInfrastructure.js";
|
|
4
|
+
import { SYSTEM_CONTINUATION_PROMPT, SYSTEM_PROMPT } from "../../../../prompts.js";
|
|
5
|
+
import { safeStringify, safeSpread } from "../../../plumbing/utils/PlumbingCore.js";
|
|
19
6
|
export class MarieEngine {
|
|
20
7
|
provider;
|
|
21
8
|
toolRegistry;
|
|
22
9
|
approvalRequester;
|
|
23
10
|
providerFactory;
|
|
24
|
-
fs;
|
|
25
|
-
ghostPort;
|
|
26
|
-
static CONTENT_BUFFER_MAX_BYTES = 1024 * 1024;
|
|
27
|
-
static GLOBAL_CONCURRENCY_LIMIT = 5;
|
|
28
|
-
static globalSemaphore = new MarieSemaphore(MarieEngine.GLOBAL_CONCURRENCY_LIMIT);
|
|
29
|
-
ascendant;
|
|
30
11
|
state;
|
|
31
|
-
|
|
32
|
-
toolMender;
|
|
33
|
-
pulseService;
|
|
34
|
-
reasoningBudget;
|
|
35
|
-
toolCallCounter = 0;
|
|
36
|
-
contentBuffer = "";
|
|
37
|
-
lastContentEmit = 0;
|
|
12
|
+
pulse;
|
|
38
13
|
activeTurn = null;
|
|
39
14
|
disposed = false;
|
|
40
|
-
|
|
41
|
-
|
|
15
|
+
heartbeatTimer = null;
|
|
16
|
+
watchdogTimer = null;
|
|
17
|
+
iterations = [];
|
|
18
|
+
static toolsInFlight = new Map();
|
|
19
|
+
logPath;
|
|
20
|
+
logQueue = [];
|
|
21
|
+
isWritingLog = false;
|
|
22
|
+
constructor(provider, toolRegistry, approvalRequester = async () => true, providerFactory) {
|
|
42
23
|
this.provider = provider;
|
|
43
24
|
this.toolRegistry = toolRegistry;
|
|
44
25
|
this.approvalRequester = approvalRequester;
|
|
45
26
|
this.providerFactory = providerFactory;
|
|
46
|
-
this.
|
|
47
|
-
this.ghostPort = ghostPort;
|
|
48
|
-
this.ascendant = new MarieAscendant(this.provider);
|
|
49
|
-
this.state = this.initializeState();
|
|
50
|
-
this.lockManager = new MarieLockManager();
|
|
51
|
-
this.toolMender = new MarieToolMender(this.toolRegistry);
|
|
52
|
-
this.reasoningBudget = new ReasoningBudget();
|
|
53
|
-
}
|
|
54
|
-
initializeState() {
|
|
55
|
-
return {
|
|
56
|
-
errorHotspots: {},
|
|
57
|
-
totalErrorCount: 0,
|
|
58
|
-
spiritPressure: 50,
|
|
59
|
-
recentFiles: [],
|
|
60
|
-
toolHistory: [],
|
|
61
|
-
techniqueExecutions: [],
|
|
62
|
-
victoryStreak: 0,
|
|
63
|
-
shakyResponseDensity: 0,
|
|
64
|
-
writtenFiles: [],
|
|
65
|
-
actionDiffs: {},
|
|
66
|
-
wiringAlerts: [],
|
|
67
|
-
mood: "STABLE",
|
|
68
|
-
isSpiritBurstActive: false,
|
|
69
|
-
isAwakened: false,
|
|
70
|
-
karmaBond: undefined,
|
|
71
|
-
panicCoolDown: 0,
|
|
72
|
-
environment: this.fs?.type === "vscode" ? "vscode" : "cli",
|
|
73
|
-
lastFailedFile: undefined,
|
|
74
|
-
};
|
|
27
|
+
this.state = { totalErrorCount: 0, confidenceLevel: 80, recentFiles: [], executionHistory: [] };
|
|
75
28
|
}
|
|
76
|
-
async chatLoop(messages,
|
|
77
|
-
if (this.disposed)
|
|
78
|
-
throw new Error("
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
console.warn("[MarieEngine] INSTANCE RE-ENTRY DETECTED. Waiting for previous turn to finalize...");
|
|
84
|
-
await this.activeTurn;
|
|
85
|
-
}
|
|
86
|
-
// GLOBAL SEMAPHORE: Acquire slot before proceeding
|
|
87
|
-
await MarieEngine.globalSemaphore.acquire();
|
|
88
|
-
let resolveTurn = () => { };
|
|
89
|
-
this.activeTurn = new Promise((resolve) => {
|
|
90
|
-
resolveTurn = resolve;
|
|
91
|
-
});
|
|
92
|
-
try {
|
|
93
|
-
const result = await this._executeChatLoop(messages, tracker, saveHistory, signal, consecutiveErrorCount, depth, accumulatedContent);
|
|
94
|
-
console.log(`[MarieEngine] chatLoop finished at depth ${depth}. Final content length: ${result.length}`);
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
97
|
-
finally {
|
|
98
|
-
MarieEngine.globalSemaphore.release();
|
|
99
|
-
resolveTurn();
|
|
100
|
-
this.activeTurn = null;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async _executeChatLoop(messages, tracker, saveHistory, signal, consecutiveErrorCount = 0, depth = 0, accumulatedContent = "") {
|
|
104
|
-
if (signal?.aborted) {
|
|
105
|
-
throw new Error("Execution aborted by user.");
|
|
106
|
-
}
|
|
107
|
-
const pulse = this.ensurePulseService(tracker);
|
|
108
|
-
// Initialize incremental logging
|
|
109
|
-
const originatingSessionId = tracker.getRun().originatingSessionId || "default";
|
|
110
|
-
if (!this.logService) {
|
|
111
|
-
this.logService = new SessionLogService(originatingSessionId);
|
|
112
|
-
}
|
|
113
|
-
const logService = this.logService;
|
|
114
|
-
logService.setProgressCallback((totalBytes, eventCount) => {
|
|
115
|
-
tracker.emitEvent({
|
|
116
|
-
type: "session_persistence_update",
|
|
117
|
-
runId: tracker.getRun().runId,
|
|
118
|
-
sessionId: originatingSessionId,
|
|
119
|
-
totalBytes,
|
|
120
|
-
elapsedMs: tracker.elapsedMs(),
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
// Override tracker emit to persist every event
|
|
124
|
-
const originalEmit = tracker.emitEvent.bind(tracker);
|
|
125
|
-
tracker.emitEvent = (event) => {
|
|
126
|
-
void logService.appendEvent(event);
|
|
127
|
-
originalEmit(event);
|
|
128
|
-
};
|
|
129
|
-
if (depth > 20) {
|
|
130
|
-
// Graceful Stability Limit Reached
|
|
131
|
-
const msg = "⚠️ Stability Alert: Maximum reasoning depth (20) reached. Returning current accumulation to prevent infinite loop.";
|
|
132
|
-
console.warn(msg);
|
|
133
|
-
// Return currently accumulated content so the user sees *something*
|
|
134
|
-
return accumulatedContent + "\n\n" + msg;
|
|
135
|
-
}
|
|
136
|
-
tracker.resetReasoningBudget();
|
|
137
|
-
this.lockManager = new MarieLockManager(tracker);
|
|
138
|
-
const dispatcher = new MarieEventDispatcher(tracker, this.ghostPort);
|
|
139
|
-
MarieStabilityMonitor.start();
|
|
140
|
-
if (tracker.getRun().steps === 0 && !tracker.getRun().isResuming) {
|
|
141
|
-
tracker.emitEvent({
|
|
142
|
-
type: "reasoning",
|
|
143
|
-
runId: tracker.getRun().runId,
|
|
144
|
-
text: "🔥 Ascension protocol initiated. Hero's conviction rising.",
|
|
145
|
-
elapsedMs: tracker.elapsedMs(),
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
// SPIRIT BURST & AWAKENING DETECTION
|
|
149
|
-
const wasBurstActive = this.state.isSpiritBurstActive;
|
|
150
|
-
const wasAwakened = this.state.isAwakened;
|
|
151
|
-
this.state.isSpiritBurstActive = this.state.spiritPressure > 85;
|
|
152
|
-
this.state.isAwakened = this.state.spiritPressure > 95;
|
|
153
|
-
if (this.state.isAwakened && !wasAwakened) {
|
|
154
|
-
tracker.emitEvent({
|
|
155
|
-
type: "reasoning",
|
|
156
|
-
runId: tracker.getRun().runId,
|
|
157
|
-
text: "✨ AWAKENED! Ultra Instinct achieved. Full codebase sovereignty established.",
|
|
158
|
-
elapsedMs: tracker.elapsedMs(),
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
else if (this.state.isSpiritBurstActive && !wasBurstActive) {
|
|
162
|
-
tracker.emitEvent({
|
|
163
|
-
type: "reasoning",
|
|
164
|
-
runId: tracker.getRun().runId,
|
|
165
|
-
text: "💥 SPIRIT BURST! Conviction is absolute. Auto-approval mandate expanded.",
|
|
166
|
-
elapsedMs: tracker.elapsedMs(),
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
// Decay spirit pressure if stale
|
|
170
|
-
if (Date.now() -
|
|
171
|
-
(this.state.techniqueExecutions.slice(-1)[0]?.timestamp || 0) >
|
|
172
|
-
300000) {
|
|
173
|
-
this.state.spiritPressure = Math.max(30, this.state.spiritPressure - 10);
|
|
174
|
-
}
|
|
175
|
-
const processor = new MarieToolProcessor(this.toolRegistry, tracker, async (name, input) => {
|
|
176
|
-
// YOLO AUTO-APPROVAL: Tiered risk assessment
|
|
177
|
-
if (this.shouldAutoApprove(name, input)) {
|
|
178
|
-
tracker.emitEvent({
|
|
179
|
-
type: "checkpoint",
|
|
180
|
-
runId: tracker.getRun().runId,
|
|
181
|
-
status: "approved",
|
|
182
|
-
toolName: name,
|
|
183
|
-
summary: {
|
|
184
|
-
what: "Ascension Auto-Approved",
|
|
185
|
-
why: "Heroic Conviction",
|
|
186
|
-
impact: "Maximum Speed",
|
|
187
|
-
},
|
|
188
|
-
elapsedMs: tracker.elapsedMs(),
|
|
189
|
-
});
|
|
190
|
-
return true;
|
|
191
|
-
}
|
|
192
|
-
return this.approvalRequester(name, input);
|
|
193
|
-
}, this.state, this.fs);
|
|
194
|
-
let turnContent = "";
|
|
195
|
-
const toolBuffer = new Map();
|
|
196
|
-
const parsedInputCache = new Map();
|
|
197
|
-
const toolResultBlocks = [];
|
|
198
|
-
let turnFailureCount = 0;
|
|
199
|
-
let totalToolCount = 0;
|
|
200
|
-
let lastTokenTime = Date.now();
|
|
201
|
-
const MAX_TOOLS_PER_TURN = 30;
|
|
202
|
-
const executeTool = async (toolCall) => {
|
|
203
|
-
const tool = this.toolRegistry.getTool(toolCall.name);
|
|
204
|
-
if (!tool) {
|
|
205
|
-
const repairResult = await this.toolMender.performFuzzyRepair(toolCall, "Tool not found", tracker, processor, this.state, signal);
|
|
206
|
-
if (repairResult) {
|
|
207
|
-
this.toolCallCounter++;
|
|
208
|
-
return {
|
|
209
|
-
type: "tool_result",
|
|
210
|
-
tool_use_id: toolCall.id,
|
|
211
|
-
content: repairResult,
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
this.updateShakyResponse();
|
|
215
|
-
return {
|
|
216
|
-
type: "tool_result",
|
|
217
|
-
tool_use_id: toolCall.id,
|
|
218
|
-
content: `Error: Tool "${toolCall.name}" not found.`,
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
const startTime = Date.now();
|
|
222
|
-
pulse.startHeartbeat();
|
|
223
|
-
try {
|
|
224
|
-
// Determine if we need to transition objectives
|
|
225
|
-
if (tracker.getRun().activeObjectiveId === "understand_request") {
|
|
226
|
-
tracker.setObjectiveStatus("understand_request", "completed");
|
|
227
|
-
tracker.setObjectiveStatus("execute_plan", "in_progress");
|
|
228
|
-
tracker.getRun().activeObjectiveId = "execute_plan";
|
|
229
|
-
tracker.emitProgressUpdate(`Executing technique: ${toolCall.name}`);
|
|
230
|
-
}
|
|
231
|
-
let toolResult = await processor.process(toolCall, signal);
|
|
232
|
-
// Buffer Hard-Cap
|
|
233
|
-
if (typeof toolResult === "string" && toolResult.length > 1024 * 1024) {
|
|
234
|
-
toolResult =
|
|
235
|
-
toolResult.substring(0, 1024 * 1024) + "\n\n🚨 Truncated at 1MB.";
|
|
236
|
-
}
|
|
237
|
-
const durationMs = Date.now() - startTime;
|
|
238
|
-
const targetFile = toolCall.input?.path ||
|
|
239
|
-
toolCall.input?.targetFile ||
|
|
240
|
-
toolCall.input?.file;
|
|
241
|
-
if (typeof toolResult === "string" && toolResult.startsWith("Error")) {
|
|
242
|
-
this.handleFailure(tracker, toolCall.name, toolResult, targetFile);
|
|
243
|
-
turnFailureCount++;
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
this.handleSuccess(tracker, toolCall.name, durationMs, targetFile, signal);
|
|
247
|
-
}
|
|
248
|
-
this.toolCallCounter++;
|
|
249
|
-
return {
|
|
250
|
-
type: "tool_result",
|
|
251
|
-
tool_use_id: toolCall.id,
|
|
252
|
-
content: toolResult,
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
finally {
|
|
256
|
-
pulse.stopHeartbeat();
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
const promptProfile = getPromptProfileForDepth(depth);
|
|
260
|
-
const session = new MarieSession(this.provider, this.toolRegistry, saveHistory, messages, tracker, this.providerFactory, promptProfile);
|
|
261
|
-
const toolExecutions = [];
|
|
29
|
+
async chatLoop(messages, run, callbacks, saveHistory, signal) {
|
|
30
|
+
if (this.disposed)
|
|
31
|
+
throw new Error("Engine disposed.");
|
|
32
|
+
this.pulse = { pendingContent: "", pendingToolDeltas: new Map(), throttleTimer: null, toolThrottleTimer: null, run, callbacks };
|
|
33
|
+
let depth = 0;
|
|
34
|
+
let accumulatedContent = "";
|
|
35
|
+
const maxDepth = getMaxRecursiveDepth();
|
|
262
36
|
try {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
this.
|
|
278
|
-
if (
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if (event.name && !tb.name)
|
|
292
|
-
tb.name = event.name;
|
|
293
|
-
}
|
|
294
|
-
if (event.argumentsDelta)
|
|
295
|
-
tb.inputString += event.argumentsDelta;
|
|
296
|
-
if (tb.name && this.isLikelyCompleteJson(tb.inputString)) {
|
|
297
|
-
const input = this.tryParseToolInput(tb.inputString, tb.name, parsedInputCache);
|
|
298
|
-
if (!input)
|
|
299
|
-
continue;
|
|
300
|
-
toolBuffer.delete(event.index);
|
|
301
|
-
totalToolCount++;
|
|
302
|
-
if (totalToolCount > MAX_TOOLS_PER_TURN)
|
|
303
|
-
break;
|
|
304
|
-
const target = input.path || input.targetFile || input.file || "GLOBAL";
|
|
305
|
-
const isWrite = [
|
|
306
|
-
"write_to_file",
|
|
307
|
-
"replace_file_content",
|
|
308
|
-
"multi_replace_file_content",
|
|
309
|
-
"run_command",
|
|
310
|
-
"delete_file",
|
|
311
|
-
].includes(tb.name);
|
|
312
|
-
// Execute concurrently
|
|
313
|
-
const executionPromise = (async () => {
|
|
314
|
-
await this.lockManager.acquireLock(target, isWrite, signal, tracker.getRun().runId);
|
|
315
|
-
const promise = executeTool({
|
|
316
|
-
id: tb.id,
|
|
317
|
-
name: tb.name,
|
|
318
|
-
input,
|
|
319
|
-
});
|
|
320
|
-
this.lockManager.registerExecution(target, isWrite, promise, tracker.getRun().runId);
|
|
321
|
-
return await promise;
|
|
322
|
-
})();
|
|
323
|
-
toolExecutions.push(executionPromise);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
else if (event.type === "usage") {
|
|
327
|
-
tracker.getRun().usage = event.usage;
|
|
37
|
+
while (depth <= maxDepth) {
|
|
38
|
+
await this.align(messages);
|
|
39
|
+
const prompt = depth > 0 ? SYSTEM_CONTINUATION_PROMPT : SYSTEM_PROMPT;
|
|
40
|
+
const tools = this.getEffectiveTools();
|
|
41
|
+
const managedMessages = await manageContext(messages, this.provider, this.state);
|
|
42
|
+
let turnContent = "";
|
|
43
|
+
const toolExecutions = [];
|
|
44
|
+
const buffer = new Map();
|
|
45
|
+
await this.provider.createMessageStream({
|
|
46
|
+
model: getModel(),
|
|
47
|
+
messages: managedMessages,
|
|
48
|
+
system: prompt,
|
|
49
|
+
tools,
|
|
50
|
+
}, (event) => {
|
|
51
|
+
this.dispatchPulse(event);
|
|
52
|
+
if (event.type === "content_delta")
|
|
53
|
+
turnContent += event.text;
|
|
54
|
+
else if (event.type === "tool_call_delta")
|
|
55
|
+
this.onToolDelta(event, buffer, toolExecutions, signal);
|
|
56
|
+
else if (event.type === "usage")
|
|
57
|
+
this.onUsage(event);
|
|
58
|
+
}, signal);
|
|
59
|
+
this.flushPulse();
|
|
60
|
+
const results = await Promise.all(toolExecutions);
|
|
61
|
+
accumulatedContent += turnContent;
|
|
62
|
+
if (results.length > 0) {
|
|
63
|
+
messages.push({ role: "user", content: results });
|
|
64
|
+
depth++;
|
|
328
65
|
}
|
|
66
|
+
else
|
|
67
|
+
break;
|
|
329
68
|
}
|
|
69
|
+
return accumulatedContent;
|
|
330
70
|
}
|
|
331
71
|
finally {
|
|
332
|
-
|
|
72
|
+
this.cleanupPulse();
|
|
333
73
|
}
|
|
334
|
-
// POST-LOOP FLUSH: Handle any tools that arrived at the very end but missed the stream evaluation
|
|
335
|
-
for (const [index, tb] of toolBuffer.entries()) {
|
|
336
|
-
if (tb.name) {
|
|
337
|
-
const input = this.tryParseToolInput(tb.inputString, tb.name, parsedInputCache);
|
|
338
|
-
if (input) {
|
|
339
|
-
totalToolCount++;
|
|
340
|
-
const target = input.path || input.targetFile || input.file || "GLOBAL";
|
|
341
|
-
const isWrite = [
|
|
342
|
-
"write_to_file",
|
|
343
|
-
"replace_file_content",
|
|
344
|
-
"multi_replace_file_content",
|
|
345
|
-
"run_command",
|
|
346
|
-
"delete_file",
|
|
347
|
-
].includes(tb.name);
|
|
348
|
-
const executionPromise = (async () => {
|
|
349
|
-
await this.lockManager.acquireLock(target, isWrite, signal, tracker.getRun().runId);
|
|
350
|
-
const promise = executeTool({ id: tb.id, name: tb.name, input });
|
|
351
|
-
this.lockManager.registerExecution(target, isWrite, promise, tracker.getRun().runId);
|
|
352
|
-
return await promise;
|
|
353
|
-
})();
|
|
354
|
-
toolExecutions.push(executionPromise);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
toolBuffer.clear();
|
|
359
|
-
const currentAccumulatedContent = accumulatedContent + turnContent;
|
|
360
|
-
console.log(`[MarieEngine] Depth ${depth}: Turn content length: ${turnContent.length}. New accumulated length: ${currentAccumulatedContent.length}`);
|
|
361
|
-
if (this.contentBuffer.length > 0) {
|
|
362
|
-
this.contentBuffer = "";
|
|
363
|
-
}
|
|
364
|
-
// Await all concurrent tool executions
|
|
365
|
-
const results = await Promise.all(toolExecutions);
|
|
366
|
-
toolResultBlocks.push(...results);
|
|
367
|
-
await this.lockManager.waitForAll();
|
|
368
|
-
if (signal?.aborted) {
|
|
369
|
-
throw new Error("Execution aborted by user after tool execution.");
|
|
370
|
-
}
|
|
371
|
-
// Final tool processing if results were returned
|
|
372
|
-
if (totalToolCount > 0) {
|
|
373
|
-
messages.push({ role: "user", content: toolResultBlocks });
|
|
374
|
-
// ASCENSION EVALUATION: Local decree (NO API CALL)
|
|
375
|
-
const decree = await this.ascendant.evaluate(messages, this.state);
|
|
376
|
-
this.state.lastDecree = decree;
|
|
377
|
-
// Visual feedback only — no state mutations from decree
|
|
378
|
-
tracker.emitEvent({
|
|
379
|
-
type: "reasoning",
|
|
380
|
-
runId: tracker.getRun().runId,
|
|
381
|
-
text: `⚡ Decree: ${decree.strategy} @ ${decree.confidence.toFixed(2)} — ${decree.reason}`,
|
|
382
|
-
elapsedMs: tracker.elapsedMs(),
|
|
383
|
-
});
|
|
384
|
-
if (decree.heroicVow) {
|
|
385
|
-
tracker.emitEvent({
|
|
386
|
-
type: "reasoning",
|
|
387
|
-
runId: tracker.getRun().runId,
|
|
388
|
-
text: `🗡️ VOW: "${decree.heroicVow}"`,
|
|
389
|
-
elapsedMs: tracker.elapsedMs(),
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
saveHistory(tracker.getRun()).catch((e) => console.error("History Save Error:", e));
|
|
393
|
-
return await this._executeChatLoop(messages, tracker, saveHistory, signal, turnFailureCount > 0 ? consecutiveErrorCount + 1 : 0, depth + 1, currentAccumulatedContent);
|
|
394
|
-
}
|
|
395
|
-
// End of turn logic
|
|
396
|
-
tracker.setObjectiveStatus("execute_plan", "completed");
|
|
397
|
-
tracker.setObjectiveStatus("deliver_result", "completed");
|
|
398
|
-
tracker.emitEvent({
|
|
399
|
-
type: "reasoning",
|
|
400
|
-
runId: tracker.getRun().runId,
|
|
401
|
-
text: "✨ Convergence achieved. The pattern sparks joy.",
|
|
402
|
-
elapsedMs: tracker.elapsedMs(),
|
|
403
|
-
});
|
|
404
|
-
dispatcher.clear();
|
|
405
|
-
return currentAccumulatedContent;
|
|
406
74
|
}
|
|
407
|
-
|
|
408
|
-
this.
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
timestamp: Date.now(),
|
|
416
|
-
filePath,
|
|
417
|
-
});
|
|
418
|
-
this.state.toolHistory.push(toolName);
|
|
419
|
-
if (this.state.victoryStreak % 3 === 0) {
|
|
420
|
-
tracker.emitEvent({
|
|
421
|
-
type: "reasoning",
|
|
422
|
-
runId: tracker.getRun().runId,
|
|
423
|
-
text: `✨ Technique Mastery! ${toolName} executed perfectly. Victory Streak: ${this.state.victoryStreak}.`,
|
|
424
|
-
elapsedMs: tracker.elapsedMs(),
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
if (filePath && !this.state.recentFiles.includes(filePath)) {
|
|
428
|
-
this.state.recentFiles.push(filePath);
|
|
429
|
-
if (this.state.recentFiles.length > 10)
|
|
430
|
-
this.state.recentFiles.shift();
|
|
431
|
-
// ZENITH AUTONOMY: Proactive Context Anchoring
|
|
432
|
-
this.proactiveContextAnchoring(filePath, tracker, signal);
|
|
75
|
+
dispatchPulse(event) {
|
|
76
|
+
if (!this.pulse)
|
|
77
|
+
return;
|
|
78
|
+
switch (event.type) {
|
|
79
|
+
case "content_delta":
|
|
80
|
+
this.pulse.pendingContent += event.text;
|
|
81
|
+
break;
|
|
82
|
+
case "tool_call_delta": break;
|
|
433
83
|
}
|
|
434
84
|
}
|
|
435
|
-
|
|
436
|
-
this.
|
|
437
|
-
|
|
438
|
-
this.
|
|
439
|
-
|
|
440
|
-
durationMs: 0,
|
|
441
|
-
success: false,
|
|
442
|
-
timestamp: Date.now(),
|
|
443
|
-
filePath,
|
|
444
|
-
});
|
|
445
|
-
const hotspotCount = (this.state.errorHotspots[filePath || "system"] || 0) + 1;
|
|
446
|
-
if (filePath) {
|
|
447
|
-
this.state.errorHotspots[filePath] = hotspotCount;
|
|
448
|
-
this.state.totalErrorCount++;
|
|
449
|
-
this.state.lastFailedFile = filePath;
|
|
450
|
-
}
|
|
451
|
-
tracker.emitEvent({
|
|
452
|
-
type: "reasoning",
|
|
453
|
-
runId: tracker.getRun().runId,
|
|
454
|
-
text: `⚠️ Technique Falter! ${toolName} failed in ${filePath || "system"}. Resistance: ${hotspotCount}x. Regrouping...`,
|
|
455
|
-
elapsedMs: tracker.elapsedMs(),
|
|
456
|
-
});
|
|
85
|
+
flushPulse() {
|
|
86
|
+
if (!this.pulse || !this.pulse.pendingContent)
|
|
87
|
+
return;
|
|
88
|
+
this.pulse.callbacks?.onStream?.(this.pulse.pendingContent, this.pulse.run.runId);
|
|
89
|
+
this.pulse.pendingContent = "";
|
|
457
90
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
];
|
|
470
|
-
if (safeTools.includes(toolName))
|
|
471
|
-
return true;
|
|
472
|
-
// SPIRIT PRESSURE & KARMA NEUTERED:
|
|
473
|
-
// We no longer auto-approve based on pressure/streak to prevent "crashes" or unintended loops.
|
|
474
|
-
// The visual feedback remains, but the functional override is disabled.
|
|
475
|
-
return false;
|
|
476
|
-
}
|
|
477
|
-
tryParseToolInput(rawInput, toolName, cache) {
|
|
478
|
-
try {
|
|
479
|
-
return JSON.parse(rawInput);
|
|
480
|
-
}
|
|
481
|
-
catch (e) {
|
|
482
|
-
const repaired = this.toolMender.repairJsonString(rawInput);
|
|
91
|
+
cleanupPulse() { this.pulse = undefined; }
|
|
92
|
+
onToolDelta(event, buffer, executions, signal) {
|
|
93
|
+
let tb = buffer.get(event.index) || { id: event.id, name: event.name, inputString: "" };
|
|
94
|
+
if (event.id)
|
|
95
|
+
tb.id = event.id;
|
|
96
|
+
if (event.name)
|
|
97
|
+
tb.name = event.name;
|
|
98
|
+
if (event.argumentsDelta)
|
|
99
|
+
tb.inputString += event.argumentsDelta;
|
|
100
|
+
buffer.set(event.index, tb);
|
|
101
|
+
if (tb.name && this.isJsonComplete(tb.inputString)) {
|
|
483
102
|
try {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
console.warn(`[MarieEngine] JSON Parse Failed for ${toolName}: ${e instanceof Error ? e.message : String(e)}`);
|
|
488
|
-
return null;
|
|
103
|
+
const input = JSON.parse(tb.inputString);
|
|
104
|
+
buffer.delete(event.index);
|
|
105
|
+
executions.push(this.runTool(tb.id, tb.name, input, signal));
|
|
489
106
|
}
|
|
107
|
+
catch { }
|
|
490
108
|
}
|
|
491
109
|
}
|
|
492
|
-
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
if (text[i] === "{" || text[i] === "[")
|
|
503
|
-
stack++;
|
|
504
|
-
if (text[i] === "}" || text[i] === "]")
|
|
505
|
-
stack--;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
return stack === 0 && text.length >= 2;
|
|
509
|
-
}
|
|
510
|
-
suggestSelfHealing(tracker, messages) {
|
|
511
|
-
// SPIRIT PRESSURE & KARMA NEUTERED:
|
|
512
|
-
// We calculate the values for UI visuals but DO NOT inject mandatory recovery protocols.
|
|
513
|
-
// This prevents the "crash" loop the user described.
|
|
514
|
-
const pressure = this.state.spiritPressure;
|
|
515
|
-
const hotspots = Object.entries(this.state.errorHotspots).filter(([_, count]) => count >= 2);
|
|
516
|
-
if (pressure < 40 || hotspots.length > 0) {
|
|
517
|
-
const hotspotFiles = hotspots.map(([f]) => path.basename(f)).join(", ");
|
|
518
|
-
const reason = pressure < 40
|
|
519
|
-
? "Low spirit pressure (instability detected)"
|
|
520
|
-
: `Repeated failures in: ${hotspotFiles}`;
|
|
521
|
-
// Log only - do not force the user/agent into a recovery loop
|
|
522
|
-
console.log(`[MarieEngine] Suggestion: ${reason}. (Auto-recovery disabled for stability)`);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
dispose() {
|
|
526
|
-
this.disposed = true;
|
|
527
|
-
this.pulseService?.cleanup();
|
|
528
|
-
this.pulseService = undefined;
|
|
529
|
-
this.contentBuffer = "";
|
|
530
|
-
}
|
|
531
|
-
ensurePulseService(tracker) {
|
|
532
|
-
if (!this.pulseService)
|
|
533
|
-
this.pulseService = new MariePulseService(tracker);
|
|
534
|
-
return this.pulseService;
|
|
535
|
-
}
|
|
536
|
-
calibrateStrategicTrajectory(decree, tracker) {
|
|
537
|
-
const run = tracker.getRun();
|
|
538
|
-
if (decree.strategy === "RESEARCH" ||
|
|
539
|
-
(decree.urgency === "HIGH" && decree.confidence > 2.0)) {
|
|
540
|
-
const oldPasses = run.totalPasses || 3;
|
|
541
|
-
if (oldPasses < 10) {
|
|
542
|
-
run.totalPasses = oldPasses + 1;
|
|
543
|
-
tracker.emitEvent({
|
|
544
|
-
type: "reasoning",
|
|
545
|
-
runId: run.runId,
|
|
546
|
-
text: `🌌 ZENITH: Autonomously expanded roadmap to ${run.totalPasses} passes. Focus sharpened: ${decree.reason}`,
|
|
547
|
-
elapsedMs: tracker.elapsedMs(),
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
}
|
|
110
|
+
async runTool(id, name, input, signal) {
|
|
111
|
+
const start = Date.now();
|
|
112
|
+
const tool = this.getTool(name);
|
|
113
|
+
if (!tool)
|
|
114
|
+
return { type: "tool_result", tool_use_id: id, content: `Error: Tool ${name} not found.` };
|
|
115
|
+
this.pulse?.callbacks?.onEvent?.({ type: "tool", runId: this.pulse.run.runId, id, phase: "start", name, input: safeSpread(input), elapsedMs: Date.now() - this.pulse.run.startedAt });
|
|
116
|
+
const result = await tool.execute(input);
|
|
117
|
+
const final = typeof result === "string" ? result : safeStringify(result);
|
|
118
|
+
this.pulse?.callbacks?.onEvent?.({ type: "tool", runId: this.pulse.run.runId, id, phase: "complete", name, message: final.substring(0, 50), elapsedMs: Date.now() - this.pulse.run.startedAt });
|
|
119
|
+
return { type: "tool_result", tool_use_id: id, content: final };
|
|
551
120
|
}
|
|
552
|
-
async
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
const { ContextArchiveService } = await import("../../../infrastructure/ai/context/ContextArchiveService.js");
|
|
560
|
-
const { readFile } = await import("../../../plumbing/filesystem/FileService.js");
|
|
561
|
-
const content = await readFile(filePath, undefined, undefined, signal);
|
|
562
|
-
if (signal?.aborted)
|
|
563
|
-
return;
|
|
564
|
-
await ContextArchiveService.getInstance().anchor({
|
|
565
|
-
id: `proactive_${filePath.split("/").pop()}`,
|
|
566
|
-
label: `Strategic: ${filePath.split("/").pop()}`,
|
|
567
|
-
content: content.substring(0, 2000), // Cap at 2k chars
|
|
568
|
-
type: "file_ref",
|
|
569
|
-
});
|
|
570
|
-
if (signal?.aborted)
|
|
571
|
-
return;
|
|
572
|
-
tracker.emitEvent({
|
|
573
|
-
type: "reasoning",
|
|
574
|
-
runId: tracker.getRun().runId,
|
|
575
|
-
text: `⚓ ZENITH: Proactively anchored \`${filePath.split("/").pop()}\` to strategic memory.`,
|
|
576
|
-
elapsedMs: tracker.elapsedMs(),
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
catch (e) {
|
|
580
|
-
if (!signal?.aborted) {
|
|
581
|
-
console.warn("[Zenith] Failed proactive anchoring", e);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
}
|
|
121
|
+
async align(messages) { }
|
|
122
|
+
onUsage(e) { if (this.pulse)
|
|
123
|
+
this.pulse.run.usage = e.usage; }
|
|
124
|
+
getEffectiveTools() { return this.toolRegistry ? this.toolRegistry.getRegisteredTools() : getRegisteredTools(); }
|
|
125
|
+
isJsonComplete(s) { try {
|
|
126
|
+
JSON.parse(s);
|
|
127
|
+
return true;
|
|
585
128
|
}
|
|
129
|
+
catch {
|
|
130
|
+
return false;
|
|
131
|
+
} }
|
|
132
|
+
getTool(name) { return this.toolRegistry ? this.toolRegistry.get(name) : getTool(name); }
|
|
133
|
+
dispose() { this.disposed = true; }
|
|
586
134
|
}
|
|
587
135
|
//# sourceMappingURL=MarieEngine.js.map
|