@noorm/marie-cli 0.1.18 → 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/App.js +16 -63
- package/dist/cli-new/components/App.js.map +1 -1
- package/dist/cli-new/components/ApprovalDialog.js +2 -1
- package/dist/cli-new/components/ApprovalDialog.js.map +1 -1
- package/dist/cli-new/components/Banner.js +4 -3
- 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 +13 -7
- package/dist/cli-new/components/Header.js.map +1 -1
- package/dist/cli-new/components/InputArea.js +73 -12
- package/dist/cli-new/components/InputArea.js.map +1 -1
- package/dist/cli-new/components/MessageBubble.js +26 -18
- package/dist/cli-new/components/MessageBubble.js.map +1 -1
- package/dist/cli-new/components/SessionSwitcher.js +4 -7
- 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/utils/version.js +24 -0
- package/dist/cli-new/utils/version.js.map +1 -0
- package/dist/monolith/adapters/CliMarieAdapter.js +12 -11
- 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 +39 -31
- package/dist/monolith/cli/MarieToolDefinitionsCLI.js.map +1 -1
- package/dist/monolith/cli/index.js +5 -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 +142 -72
- 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 +6 -27
- package/dist/monolith/infrastructure/ai/context/ContextArchiveService.js.map +1 -1
- package/dist/monolith/infrastructure/ai/context/ContextManager.js +142 -131
- package/dist/monolith/infrastructure/ai/context/ContextManager.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieEngine.js +115 -1077
- 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 +6 -1
- package/dist/monolith/infrastructure/ai/core/MarieLockManager.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieProgressTracker.js +172 -221
- package/dist/monolith/infrastructure/ai/core/MarieProgressTracker.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieSanitizer.js +292 -141
- package/dist/monolith/infrastructure/ai/core/MarieSanitizer.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieToolProcessor.js +331 -614
- 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/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 -392
- 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 -503
- package/dist/monolith/infrastructure/config/ConfigService.js.map +1 -1
- package/dist/monolith/infrastructure/joy/CognitiveRituals.js +4 -165
- package/dist/monolith/infrastructure/joy/CognitiveRituals.js.map +1 -1
- package/dist/monolith/infrastructure/joy/JoyTools.js +14 -47
- 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 +123 -106
- package/dist/monolith/infrastructure/persistence/NoormmeAutonomics.js.map +1 -1
- package/dist/monolith/infrastructure/persistence/NoormmeEngine.js +508 -63
- package/dist/monolith/infrastructure/persistence/NoormmeEngine.js.map +1 -1
- package/dist/monolith/infrastructure/persistence/NoormmeSchema.js +68 -39
- package/dist/monolith/infrastructure/persistence/NoormmeSchema.js.map +1 -1
- package/dist/monolith/infrastructure/persistence/NoormmeSeeder.js +80 -67
- package/dist/monolith/infrastructure/persistence/NoormmeSeeder.js.map +1 -1
- package/dist/monolith/infrastructure/persistence/NoormmeTools.js +122 -75
- package/dist/monolith/infrastructure/persistence/NoormmeTools.js.map +1 -1
- 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 -30
- 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 +39 -153
- package/dist/monolith/infrastructure/tools/definitions/AnalysisTools.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/AutomationTools.js +31 -46
- package/dist/monolith/infrastructure/tools/definitions/AutomationTools.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/ContextTools.js +41 -13
- package/dist/monolith/infrastructure/tools/definitions/ContextTools.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/CoreTools.js +10 -14
- package/dist/monolith/infrastructure/tools/definitions/CoreTools.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/DiagnosticTools.js +39 -70
- package/dist/monolith/infrastructure/tools/definitions/DiagnosticTools.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/NavigationTools.js +30 -181
- package/dist/monolith/infrastructure/tools/definitions/NavigationTools.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/PlanningTools.js +12 -9
- package/dist/monolith/infrastructure/tools/definitions/PlanningTools.js.map +1 -1
- 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 -268
- 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 -141
- 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/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 -499
- 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 -173
- 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 -89
- package/run_test.js +5 -0
- package/.marie_visual_verify_1771225696548/progress_bar_check.txt +0 -1
- package/dist/extension.cjs +0 -1155
- package/dist/extension.js +0 -474
- 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/infrastructure/ai/core/GhostPort.js +0 -2
- package/dist/monolith/infrastructure/ai/core/GhostPort.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 -154
- package/dist/monolith/infrastructure/ai/providers/AnthropicProvider.js.map +0 -1
- package/dist/monolith/infrastructure/ai/providers/CerebrasProvider.js +0 -214
- 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/webview-ui/main.css +0 -1
- package/dist/webview-ui/main.js +0 -108
- package/lint_output.txt +0 -705
- package/lint_output_v2.txt +0 -711
- package/test-mind-p6.sqlite +0 -0
- package/test-mind-p6.sqlite-shm +0 -0
- package/test-mind-p6.sqlite-wal +0 -0
|
@@ -1,552 +1,129 @@
|
|
|
1
|
-
import { ToolRegistry } from "../infrastructure/tools/ToolRegistry.js";
|
|
2
|
-
import { ConfigService } from "../infrastructure/config/ConfigService.js";
|
|
3
1
|
import { MarieEngine } from "../infrastructure/ai/core/MarieEngine.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { NoormmeEngine } from "../infrastructure/persistence/NoormmeEngine.js";
|
|
7
|
-
import { StringUtils } from "../plumbing/utils/StringUtils.js";
|
|
8
|
-
import { MarieMutex } from "../plumbing/utils/MutexUtils.js";
|
|
2
|
+
import { MarieMutex } from "../plumbing/utils/PlumbingCore.js";
|
|
3
|
+
import { plan, processSessionEnd, renderMessage } from "../services/MarieServices.js";
|
|
9
4
|
export class MarieRuntime {
|
|
10
5
|
options;
|
|
11
6
|
provider;
|
|
12
|
-
lastProviderKey;
|
|
13
|
-
toolRegistry;
|
|
14
7
|
currentSessionId = "default";
|
|
15
8
|
messages = [];
|
|
16
|
-
sequenceNumber = 0;
|
|
17
9
|
abortController = null;
|
|
18
|
-
currentRun;
|
|
19
10
|
initPromise;
|
|
20
|
-
pendingApprovals = new Map();
|
|
21
11
|
processingMutex = new MarieMutex("ProcessingLock");
|
|
22
|
-
persistenceMutex = new MarieMutex("PersistenceLock");
|
|
23
|
-
onStateChangedCallbacks = [];
|
|
24
12
|
constructor(options) {
|
|
25
13
|
this.options = options;
|
|
26
|
-
this.
|
|
27
|
-
this.options.toolRegistrar(this.toolRegistry, this.options.automationService);
|
|
14
|
+
this.options.toolRegistrar(this.options.automationService);
|
|
28
15
|
this.initPromise = this.initialize();
|
|
29
16
|
}
|
|
30
17
|
async initialize() {
|
|
31
|
-
this.currentSessionId =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
async ensureInitialized() {
|
|
36
|
-
await this.initPromise;
|
|
37
|
-
}
|
|
38
|
-
createProvider(providerType) {
|
|
39
|
-
const typedProvider = providerType;
|
|
40
|
-
const key = this.options.config.getApiKey(typedProvider) || "";
|
|
41
|
-
return this.options.providerFactory(typedProvider, key);
|
|
18
|
+
this.currentSessionId = (await this.options.sessionStore.getCurrentSessionId()) || "default";
|
|
19
|
+
const historyMap = await this.options.sessionStore.getSessions();
|
|
20
|
+
this.messages = historyMap[this.currentSessionId] || [];
|
|
42
21
|
}
|
|
22
|
+
ensureInitialized() { return this.initPromise; }
|
|
43
23
|
initializeProvider() {
|
|
44
24
|
const providerType = this.options.config.getAiProvider();
|
|
45
25
|
const key = this.options.config.getApiKey(providerType) || "";
|
|
46
|
-
const cacheKey = `${providerType}:${key}`;
|
|
47
|
-
if (this.provider && this.lastProviderKey === cacheKey) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
this.lastProviderKey = cacheKey;
|
|
51
26
|
this.provider = this.options.providerFactory(providerType, key);
|
|
52
27
|
}
|
|
53
|
-
async loadHistory() {
|
|
54
|
-
const historyMap = await this.options.sessionStore.getSessions();
|
|
55
|
-
this.messages = historyMap[this.currentSessionId] || [];
|
|
56
|
-
}
|
|
57
|
-
onStateChanged(callback) {
|
|
58
|
-
this.onStateChangedCallbacks.push(callback);
|
|
59
|
-
return () => {
|
|
60
|
-
this.onStateChangedCallbacks = this.onStateChangedCallbacks.filter((c) => c !== callback);
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
emitStateChanged() {
|
|
64
|
-
const state = {
|
|
65
|
-
messages: [...this.messages],
|
|
66
|
-
currentSessionId: this.currentSessionId,
|
|
67
|
-
sequenceNumber: ++this.sequenceNumber,
|
|
68
|
-
};
|
|
69
|
-
for (const callback of this.onStateChangedCallbacks) {
|
|
70
|
-
try {
|
|
71
|
-
callback(state);
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
console.error("[MarieRuntime] Error in state change callback", e);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async saveHistoryInternal(telemetry, specificSessionId, runStartTime) {
|
|
79
|
-
if (this.messages.length > 50) {
|
|
80
|
-
this.messages = this.messages.slice(this.messages.length - 50);
|
|
81
|
-
}
|
|
82
|
-
const sid = specificSessionId || this.currentSessionId;
|
|
83
|
-
const historyMap = await this.options.sessionStore.getSessions();
|
|
84
|
-
const currentSessionMatches = sid === this.currentSessionId;
|
|
85
|
-
const isSessionStillValid = runStartTime ? true : currentSessionMatches;
|
|
86
|
-
if (sid === this.currentSessionId && isSessionStillValid) {
|
|
87
|
-
historyMap[sid] = this.messages;
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
if (!historyMap[sid]) {
|
|
91
|
-
historyMap[sid] = [];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
await this.options.sessionStore.saveSessions(historyMap);
|
|
95
|
-
const sessionMetadata = await this.options.sessionStore.getSessionMetadata();
|
|
96
|
-
const index = sessionMetadata.findIndex((s) => s.id === sid);
|
|
97
|
-
const targetMessages = sid === this.currentSessionId ? this.messages : historyMap[sid];
|
|
98
|
-
const firstMsg = targetMessages && targetMessages.length > 0
|
|
99
|
-
? targetMessages[0].content
|
|
100
|
-
: "";
|
|
101
|
-
const title = targetMessages && targetMessages.length > 0
|
|
102
|
-
? this.generateSessionTitle(firstMsg)
|
|
103
|
-
: "New Session";
|
|
104
|
-
if (index >= 0) {
|
|
105
|
-
sessionMetadata[index].lastModified = Date.now();
|
|
106
|
-
if (sessionMetadata[index].title === "New Session") {
|
|
107
|
-
sessionMetadata[index].title = title;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else if (sid !== "default") {
|
|
111
|
-
sessionMetadata.unshift({
|
|
112
|
-
id: sid,
|
|
113
|
-
title,
|
|
114
|
-
lastModified: Date.now(),
|
|
115
|
-
isPinned: false,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
await this.options.sessionStore.saveSessionMetadata(sessionMetadata);
|
|
119
|
-
if (sid === this.currentSessionId) {
|
|
120
|
-
await this.options.sessionStore.setCurrentSessionId(sid);
|
|
121
|
-
}
|
|
122
|
-
if (telemetry !== undefined) {
|
|
123
|
-
await this.options.sessionStore.setLastTelemetry(telemetry === null ? undefined : telemetry);
|
|
124
|
-
}
|
|
125
|
-
if (sid === this.currentSessionId) {
|
|
126
|
-
this.emitStateChanged();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
async saveHistory(telemetry, specificSessionId, runStartTime) {
|
|
130
|
-
const unlock = await this.persistenceMutex.acquire();
|
|
131
|
-
try {
|
|
132
|
-
await this.saveHistoryInternal(telemetry, specificSessionId, runStartTime);
|
|
133
|
-
}
|
|
134
|
-
finally {
|
|
135
|
-
unlock();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
generateSessionTitle(firstMessage) {
|
|
139
|
-
const response = MarieResponse.wrap(firstMessage);
|
|
140
|
-
const text = response.getText();
|
|
141
|
-
const goalMatch = text.match(/(?:Goal|Objective|Task):\s*([^\n.]+)/i);
|
|
142
|
-
if (goalMatch && goalMatch[1].trim()) {
|
|
143
|
-
return this.formatTitle(goalMatch[1].trim());
|
|
144
|
-
}
|
|
145
|
-
const lines = text
|
|
146
|
-
.split("\n")
|
|
147
|
-
.map((l) => l.trim())
|
|
148
|
-
.filter((l) => l.length > 5);
|
|
149
|
-
if (lines.length > 0 && lines[0].length < 60) {
|
|
150
|
-
return this.formatTitle(lines[0]);
|
|
151
|
-
}
|
|
152
|
-
const summary = text.trim() || "New Session";
|
|
153
|
-
return this.formatTitle(summary);
|
|
154
|
-
}
|
|
155
|
-
formatTitle(text) {
|
|
156
|
-
const clean = text.replace(/^[#\-*\s]+/, "").trim();
|
|
157
|
-
if (clean.length > 30) {
|
|
158
|
-
return clean.substring(0, 27) + "...";
|
|
159
|
-
}
|
|
160
|
-
return clean || "New Session";
|
|
161
|
-
}
|
|
162
|
-
async createSession() {
|
|
163
|
-
await this.ensureInitialized();
|
|
164
|
-
const unlock = await this.persistenceMutex.acquire();
|
|
165
|
-
try {
|
|
166
|
-
this.currentSessionId = `session_${Date.now()}`;
|
|
167
|
-
this.messages = [];
|
|
168
|
-
await this.saveHistoryInternal();
|
|
169
|
-
return this.currentSessionId;
|
|
170
|
-
}
|
|
171
|
-
finally {
|
|
172
|
-
unlock();
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
async listSessions() {
|
|
176
|
-
await this.ensureInitialized();
|
|
177
|
-
return this.options.sessionStore.getSessionMetadata();
|
|
178
|
-
}
|
|
179
|
-
async loadSession(id) {
|
|
180
|
-
await this.ensureInitialized();
|
|
181
|
-
const unlock = await this.persistenceMutex.acquire();
|
|
182
|
-
try {
|
|
183
|
-
this.stopGeneration();
|
|
184
|
-
this.currentSessionId = id;
|
|
185
|
-
await this.loadHistory();
|
|
186
|
-
await this.options.sessionStore.setCurrentSessionId(id);
|
|
187
|
-
this.emitStateChanged();
|
|
188
|
-
return this.currentSessionId;
|
|
189
|
-
}
|
|
190
|
-
finally {
|
|
191
|
-
unlock();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
async deleteSession(id) {
|
|
195
|
-
await this.ensureInitialized();
|
|
196
|
-
let firstSessionId;
|
|
197
|
-
let shouldLoadFirst = false;
|
|
198
|
-
let shouldCreateNew = false;
|
|
199
|
-
const unlock = await this.persistenceMutex.acquire();
|
|
200
|
-
try {
|
|
201
|
-
if (this.currentSessionId === id) {
|
|
202
|
-
this.stopGeneration();
|
|
203
|
-
}
|
|
204
|
-
const historyMap = await this.options.sessionStore.getSessions();
|
|
205
|
-
delete historyMap[id];
|
|
206
|
-
await this.options.sessionStore.saveSessions(historyMap);
|
|
207
|
-
const sessionMetadata = await this.options.sessionStore.getSessionMetadata();
|
|
208
|
-
const filteredMetadata = sessionMetadata.filter((s) => s.id !== id);
|
|
209
|
-
await this.options.sessionStore.saveSessionMetadata(filteredMetadata);
|
|
210
|
-
if (this.currentSessionId === id) {
|
|
211
|
-
if (filteredMetadata.length > 0) {
|
|
212
|
-
shouldLoadFirst = true;
|
|
213
|
-
firstSessionId = filteredMetadata[0].id;
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
shouldCreateNew = true;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
if (shouldLoadFirst && firstSessionId) {
|
|
220
|
-
this.currentSessionId = firstSessionId;
|
|
221
|
-
await this.loadHistory();
|
|
222
|
-
await this.options.sessionStore.setCurrentSessionId(this.currentSessionId);
|
|
223
|
-
this.emitStateChanged();
|
|
224
|
-
}
|
|
225
|
-
else if (shouldCreateNew) {
|
|
226
|
-
this.currentSessionId = `session_${Date.now()}`;
|
|
227
|
-
this.messages = [];
|
|
228
|
-
await this.saveHistoryInternal();
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
finally {
|
|
232
|
-
unlock();
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
async renameSession(id, newTitle) {
|
|
236
|
-
const unlock = await this.persistenceMutex.acquire();
|
|
237
|
-
try {
|
|
238
|
-
await this.ensureInitialized();
|
|
239
|
-
const sessionMetadata = await this.options.sessionStore.getSessionMetadata();
|
|
240
|
-
const index = sessionMetadata.findIndex((s) => s.id === id);
|
|
241
|
-
if (index >= 0) {
|
|
242
|
-
sessionMetadata[index].title = newTitle;
|
|
243
|
-
await this.options.sessionStore.saveSessionMetadata(sessionMetadata);
|
|
244
|
-
this.emitStateChanged();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
finally {
|
|
248
|
-
unlock();
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
async togglePinSession(id) {
|
|
252
|
-
const unlock = await this.persistenceMutex.acquire();
|
|
253
|
-
try {
|
|
254
|
-
await this.ensureInitialized();
|
|
255
|
-
const sessionMetadata = await this.options.sessionStore.getSessionMetadata();
|
|
256
|
-
const index = sessionMetadata.findIndex((s) => s.id === id);
|
|
257
|
-
if (index >= 0) {
|
|
258
|
-
sessionMetadata[index].isPinned = !sessionMetadata[index].isPinned;
|
|
259
|
-
await this.options.sessionStore.saveSessionMetadata(sessionMetadata);
|
|
260
|
-
this.emitStateChanged();
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
finally {
|
|
264
|
-
unlock();
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
28
|
async handleMessage(text, callbacks) {
|
|
268
|
-
|
|
269
|
-
let attempts = 0;
|
|
270
|
-
const maxAttempts = 3;
|
|
271
|
-
while (attempts < maxAttempts) {
|
|
272
|
-
try {
|
|
273
|
-
unlock = await this.processingMutex.acquire(10000); // 10s timeout per attempt
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
catch (e) {
|
|
277
|
-
attempts++;
|
|
278
|
-
if (attempts >= maxAttempts) {
|
|
279
|
-
return `Error: System is currently busy with another task. Please wait a moment and try again. (Mutex Timeout)`;
|
|
280
|
-
}
|
|
281
|
-
console.warn(`[MarieRuntime] Mutex acquisition attempt ${attempts} failed, retrying...`);
|
|
282
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
283
|
-
}
|
|
284
|
-
}
|
|
29
|
+
const unlock = await this.processingMutex.acquire(100000);
|
|
285
30
|
try {
|
|
286
31
|
await this.ensureInitialized();
|
|
287
32
|
this.initializeProvider();
|
|
288
|
-
if (!this.provider)
|
|
289
|
-
return "Please configure your API key
|
|
290
|
-
}
|
|
33
|
+
if (!this.provider)
|
|
34
|
+
return "Please configure your API key.";
|
|
291
35
|
const lastTelemetry = await this.options.sessionStore.getLastTelemetry();
|
|
292
|
-
const originatingSessionId = this.currentSessionId;
|
|
293
36
|
const run = {
|
|
294
37
|
runId: `run_${Date.now()}`,
|
|
295
38
|
startedAt: Date.now(),
|
|
296
39
|
steps: 0,
|
|
297
40
|
tools: 0,
|
|
298
|
-
objectives: [
|
|
299
|
-
{
|
|
300
|
-
id: "understand_request",
|
|
301
|
-
label: "Understand request",
|
|
302
|
-
status: "in_progress",
|
|
303
|
-
},
|
|
304
|
-
{ id: "execute_plan", label: "Execute plan", status: "pending" },
|
|
305
|
-
{ id: "deliver_result", label: "Deliver result", status: "pending" },
|
|
306
|
-
],
|
|
307
|
-
activeObjectiveId: "understand_request",
|
|
41
|
+
objectives: [],
|
|
308
42
|
achieved: [],
|
|
309
|
-
currentPass: lastTelemetry?.currentPass,
|
|
310
|
-
totalPasses: lastTelemetry?.totalPasses,
|
|
311
|
-
passFocus: lastTelemetry?.passFocus,
|
|
312
43
|
isResuming: !!lastTelemetry,
|
|
313
|
-
originatingSessionId,
|
|
44
|
+
originatingSessionId: this.currentSessionId,
|
|
314
45
|
};
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
onToolDelta: (delta) => callbacks?.onToolDelta?.(delta, run.runId, originatingSessionId),
|
|
320
|
-
onEvent: (event) => {
|
|
321
|
-
event.originatingSessionId = originatingSessionId;
|
|
322
|
-
if (event.type === "progress_update" ||
|
|
323
|
-
event.type === "session_persistence_update" ||
|
|
324
|
-
event.type === "file_stream_delta") {
|
|
325
|
-
this.options.onProgressEvent?.(event);
|
|
326
|
-
}
|
|
327
|
-
callbacks?.onEvent?.(event);
|
|
328
|
-
},
|
|
329
|
-
}, run);
|
|
330
|
-
this.currentRun = run;
|
|
331
|
-
this.options.automationService.setCurrentRun(run);
|
|
332
|
-
const approvalRequester = async (name, input, diff) => {
|
|
333
|
-
if (this.options.shouldBypassApprovals?.()) {
|
|
334
|
-
return true;
|
|
335
|
-
}
|
|
336
|
-
const request = {
|
|
337
|
-
id: `approval_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`,
|
|
338
|
-
toolName: name,
|
|
339
|
-
toolInput: input,
|
|
340
|
-
diff,
|
|
341
|
-
};
|
|
342
|
-
const hasHandlers = Boolean(callbacks?.onApprovalRequest || this.options.onApprovalRequest);
|
|
343
|
-
if (!hasHandlers) {
|
|
46
|
+
const cortexPlan = await plan(text, this.messages);
|
|
47
|
+
this.messages.push({ role: "user", content: text, timestamp: Date.now() });
|
|
48
|
+
const engine = new MarieEngine(this.provider, undefined, async (name, input) => {
|
|
49
|
+
if (this.options.shouldBypassApprovals?.())
|
|
344
50
|
return true;
|
|
345
|
-
}
|
|
346
|
-
const approvalPromise = new Promise((resolve) => {
|
|
347
|
-
this.pendingApprovals.set(request.id, {
|
|
348
|
-
resolve,
|
|
349
|
-
toolName: name,
|
|
350
|
-
timestamp: Date.now(),
|
|
351
|
-
});
|
|
352
|
-
});
|
|
353
|
-
callbacks?.onApprovalRequest?.(request, run.runId, originatingSessionId);
|
|
354
51
|
if (this.options.onApprovalRequest) {
|
|
355
|
-
|
|
356
|
-
this.resolveApproval(request.id, approved);
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
return approvalPromise;
|
|
360
|
-
};
|
|
361
|
-
const engine = new MarieEngine(this.provider, this.toolRegistry, approvalRequester, this.createProvider.bind(this), this.options.fs, this.options.ghostPort);
|
|
362
|
-
tracker.emitEvent({
|
|
363
|
-
type: "run_started",
|
|
364
|
-
runId: run.runId,
|
|
365
|
-
startedAt: run.startedAt,
|
|
366
|
-
});
|
|
367
|
-
tracker.emitProgressUpdate("Thinking...");
|
|
368
|
-
this.messages.push({
|
|
369
|
-
role: "user",
|
|
370
|
-
content: text,
|
|
371
|
-
timestamp: Date.now(),
|
|
372
|
-
});
|
|
373
|
-
await this.saveHistory();
|
|
374
|
-
if (this.abortController) {
|
|
375
|
-
this.abortController.abort();
|
|
376
|
-
}
|
|
377
|
-
this.abortController = new AbortController();
|
|
378
|
-
const runStartTime = Date.now();
|
|
379
|
-
try {
|
|
380
|
-
const response = await engine.chatLoop(this.messages, tracker, (t) => this.saveHistory(t, originatingSessionId, runStartTime), this.abortController.signal);
|
|
381
|
-
if (this.messages.length >= 6 && this.messages.length <= 10) {
|
|
382
|
-
const sessionMetadata = await this.options.sessionStore.getSessionMetadata();
|
|
383
|
-
const session = sessionMetadata.find((s) => s.id === this.currentSessionId);
|
|
384
|
-
if (session &&
|
|
385
|
-
(session.title === "New Session" || session.title.length > 50)) {
|
|
386
|
-
this.summarizeSession(this.currentSessionId).catch(console.error);
|
|
387
|
-
}
|
|
52
|
+
return await this.options.onApprovalRequest({ id: `req_${Date.now()}`, toolName: name, toolInput: input });
|
|
388
53
|
}
|
|
389
|
-
return
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
runId: run.runId,
|
|
395
|
-
elapsedMs: tracker.elapsedMs(),
|
|
396
|
-
message: String(error),
|
|
397
|
-
});
|
|
398
|
-
return `Error: ${error}`;
|
|
54
|
+
return true;
|
|
55
|
+
}, this.options.providerFactory);
|
|
56
|
+
const response = await engine.chatLoop(this.messages, run, callbacks || {}, async (t) => await this.options.sessionStore.setLastTelemetry(t));
|
|
57
|
+
if (this.messages.length > 5) {
|
|
58
|
+
processSessionEnd(this.currentSessionId, this.messages, this.options.providerFactory, this.options.config).catch(() => { });
|
|
399
59
|
}
|
|
60
|
+
return renderMessage(response);
|
|
400
61
|
}
|
|
401
62
|
finally {
|
|
402
|
-
|
|
403
|
-
this.currentRun = undefined;
|
|
404
|
-
if (unlock)
|
|
405
|
-
unlock();
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
async summarizeSession(id) {
|
|
409
|
-
this.initializeProvider();
|
|
410
|
-
if (!this.provider)
|
|
411
|
-
return;
|
|
412
|
-
const historyMap = await this.options.sessionStore.getSessions();
|
|
413
|
-
const messages = historyMap[id] || [];
|
|
414
|
-
if (messages.length < 2)
|
|
415
|
-
return;
|
|
416
|
-
const engine = new MarieEngine(this.provider, this.toolRegistry, async () => true);
|
|
417
|
-
// 1. Title Generation
|
|
418
|
-
const prompt = "Based on our conversation so far, generate a very concise (3-5 words) and descriptive title for this session. Respond ONLY with the title. No quotes, no intro.";
|
|
419
|
-
try {
|
|
420
|
-
const summary = await engine.chatLoop([...messages, { role: "user", content: prompt }], { emitProgressUpdate: () => { }, emitEvent: () => { } }, async () => { });
|
|
421
|
-
if (summary && typeof summary === "string" && summary.length < 60) {
|
|
422
|
-
await this.renameSession(id, summary.trim().replace(/^"|"$/g, ""));
|
|
423
|
-
}
|
|
424
|
-
else if (summary && String(summary).length < 60) {
|
|
425
|
-
const text = StringUtils.extractText(summary).trim();
|
|
426
|
-
await this.renameSession(id, text.replace(/^"|"$/g, ""));
|
|
427
|
-
}
|
|
428
|
-
// 2. Knowledge Distillation
|
|
429
|
-
const knowledgePrompt = "Extract 3-5 key structured facts or entities from our conversation. Format each as 'Entity | Fact'. One per line. Only output the facts.";
|
|
430
|
-
const factsResponse = await engine.chatLoop([...messages, { role: "user", content: knowledgePrompt }], { emitProgressUpdate: () => { }, emitEvent: () => { } }, async () => { });
|
|
431
|
-
if (factsResponse) {
|
|
432
|
-
const db = await NoormmeEngine.getInstance();
|
|
433
|
-
const lines = factsResponse.split("\n").filter(l => l.includes("|"));
|
|
434
|
-
for (const line of lines) {
|
|
435
|
-
const [entity, fact] = line.split("|").map(s => s.trim());
|
|
436
|
-
if (entity && fact) {
|
|
437
|
-
await db.agent.cortex.knowledge.distill(entity, fact, 0.8, // confidence
|
|
438
|
-
id, // sourceSessionId
|
|
439
|
-
["automated-distillation"]);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
console.log(`[MarieRuntime] Distilled ${lines.length} facts from session ${id}`);
|
|
443
|
-
// PHASE 8.2: Hive Pulse Synchronization & Hardening
|
|
444
|
-
try {
|
|
445
|
-
await db.agent.cortex.hive.broadcastKnowledge();
|
|
446
|
-
await db.agent.cortex.hive.broadcastSkills();
|
|
447
|
-
// Action Refinement: Learn from failures
|
|
448
|
-
const recommendations = await db.agent.cortex.refiner.refineActions();
|
|
449
|
-
if (recommendations.length > 0) {
|
|
450
|
-
console.log(`[MarieRuntime] ActionRefiner proposed ${recommendations.length} improvements.`);
|
|
451
|
-
}
|
|
452
|
-
// Mind Compression: Ablation Pruning (Every 5th session approx or just let it run)
|
|
453
|
-
await db.agent.cortex.ablation.pruneZombies(30); // Prune 30-day-old zombies
|
|
454
|
-
// PHASE 8.3: Recursive Consciousness & Narrative
|
|
455
|
-
// 1. Complete Narrative Episode
|
|
456
|
-
try {
|
|
457
|
-
const recentEpisodes = await db.agent.cortex.episodes.getSessionEpisodes(id, { limit: 1 });
|
|
458
|
-
if (recentEpisodes.length > 0 && recentEpisodes[0].status === 'active') {
|
|
459
|
-
await db.agent.cortex.episodes.completeEpisode(recentEpisodes[0].id, `Session concluded with ${lines.length} facts distilled. Overall success in objective: ${name}.`);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
catch (e) {
|
|
463
|
-
console.warn("[MarieRuntime] Narrative completion failed", e);
|
|
464
|
-
}
|
|
465
|
-
// 2. Recursive Paradox & Lesson Synthesis
|
|
466
|
-
try {
|
|
467
|
-
const paradoxes = await db.agent.cortex.reasoner.detectContradictions();
|
|
468
|
-
if (paradoxes.length > 0) {
|
|
469
|
-
console.warn(`[MarieRuntime] ⚠️ LOGICAL PARADOXES DETECTED: \n- ${paradoxes.join("\n- ")}`);
|
|
470
|
-
}
|
|
471
|
-
const lessons = await db.agent.cortex.reasoner.synthesizeLessons();
|
|
472
|
-
const totalLessons = Object.values(lessons).reduce((acc, curr) => acc + curr.length, 0);
|
|
473
|
-
console.log(`[MarieRuntime] Recursive synthesis complete. Clustered ${totalLessons} lessons across your history.`);
|
|
474
|
-
}
|
|
475
|
-
catch (e) {
|
|
476
|
-
console.warn("[MarieRuntime] Recursive reasoning failed", e);
|
|
477
|
-
}
|
|
478
|
-
console.log(`[MarieRuntime] Phase 3 Recursive Consciousness complete for session ${id}`);
|
|
479
|
-
// 3. Autonomous Self-Experimentation (Ablation)
|
|
480
|
-
try {
|
|
481
|
-
if (ConfigService.getAutonomyMode() === "ascension") {
|
|
482
|
-
console.log("[MarieRuntime] Initiating autonomous ablation experiment...");
|
|
483
|
-
const dbInternal = db.agent.cortex.ablation.db;
|
|
484
|
-
const randomItem = await dbInternal
|
|
485
|
-
.selectFrom(db.agent.cortex.ablation.knowledgeTable)
|
|
486
|
-
.select("id")
|
|
487
|
-
.limit(1)
|
|
488
|
-
.executeTakeFirst();
|
|
489
|
-
if (randomItem) {
|
|
490
|
-
await db.agent.cortex.ablation.testAblation(randomItem.id);
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
catch (e) {
|
|
495
|
-
console.warn("[MarieRuntime] Ablation experiment failed", e);
|
|
496
|
-
}
|
|
497
|
-
console.log(`[MarieRuntime] Phase 4 Sovereign Reliability pass complete for session ${id}`);
|
|
498
|
-
}
|
|
499
|
-
catch (e) {
|
|
500
|
-
console.warn("[MarieRuntime] Phase 4 Pass failed", e);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
catch (e) {
|
|
505
|
-
console.error("Failed to summarize or distill session", e);
|
|
63
|
+
unlock();
|
|
506
64
|
}
|
|
507
65
|
}
|
|
508
|
-
async
|
|
66
|
+
async createSession() {
|
|
509
67
|
await this.ensureInitialized();
|
|
68
|
+
this.currentSessionId = `session_${Date.now()}`;
|
|
510
69
|
this.messages = [];
|
|
511
|
-
await this.
|
|
512
|
-
|
|
513
|
-
stopGeneration() {
|
|
514
|
-
if (this.abortController) {
|
|
515
|
-
this.abortController.abort();
|
|
516
|
-
this.abortController = null;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
updateSettings() {
|
|
520
|
-
this.initializeProvider();
|
|
70
|
+
await this.options.sessionStore.setCurrentSessionId(this.currentSessionId);
|
|
71
|
+
return this.currentSessionId;
|
|
521
72
|
}
|
|
522
|
-
async
|
|
73
|
+
async listSessions() {
|
|
523
74
|
await this.ensureInitialized();
|
|
524
|
-
this.
|
|
525
|
-
return this.provider?.listModels() || [];
|
|
526
|
-
}
|
|
527
|
-
getMessages() {
|
|
528
|
-
return this.messages;
|
|
75
|
+
return await this.options.sessionStore.getSessionMetadata();
|
|
529
76
|
}
|
|
530
|
-
|
|
531
|
-
|
|
77
|
+
async loadSession(id) {
|
|
78
|
+
await this.ensureInitialized();
|
|
79
|
+
this.currentSessionId = id;
|
|
80
|
+
const historyMap = await this.options.sessionStore.getSessions();
|
|
81
|
+
this.messages = historyMap[id] || [];
|
|
82
|
+
await this.options.sessionStore.setCurrentSessionId(id);
|
|
83
|
+
return id;
|
|
532
84
|
}
|
|
533
|
-
|
|
534
|
-
|
|
85
|
+
async togglePinSession(id) {
|
|
86
|
+
await this.ensureInitialized();
|
|
87
|
+
const metadata = await this.options.sessionStore.getSessionMetadata();
|
|
88
|
+
const item = metadata.find(m => m.id === id);
|
|
89
|
+
if (item) {
|
|
90
|
+
item.isPinned = !item.isPinned;
|
|
91
|
+
await this.options.sessionStore.saveSessionMetadata(metadata);
|
|
92
|
+
}
|
|
535
93
|
}
|
|
536
|
-
|
|
537
|
-
|
|
94
|
+
async renameSession(id, name) {
|
|
95
|
+
await this.ensureInitialized();
|
|
96
|
+
const metadata = await this.options.sessionStore.getSessionMetadata();
|
|
97
|
+
const item = metadata.find(m => m.id === id);
|
|
98
|
+
if (item) {
|
|
99
|
+
item.title = name;
|
|
100
|
+
await this.options.sessionStore.saveSessionMetadata(metadata);
|
|
101
|
+
}
|
|
538
102
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
this.
|
|
544
|
-
entry.resolve(approved);
|
|
545
|
-
return true;
|
|
103
|
+
async deleteSession(id) {
|
|
104
|
+
await this.ensureInitialized();
|
|
105
|
+
const historyMap = await this.options.sessionStore.getSessions();
|
|
106
|
+
delete historyMap[id];
|
|
107
|
+
await this.options.sessionStore.saveSessions(historyMap);
|
|
546
108
|
}
|
|
547
|
-
|
|
548
|
-
this.
|
|
549
|
-
this.
|
|
109
|
+
async clearCurrentSession() {
|
|
110
|
+
await this.ensureInitialized();
|
|
111
|
+
this.messages = [];
|
|
550
112
|
}
|
|
113
|
+
stopGeneration() { this.abortController?.abort(); }
|
|
114
|
+
setMode(mode) { }
|
|
115
|
+
getMode() { return global.MARIE_MODE || "meditative"; }
|
|
116
|
+
updateSettings() { }
|
|
117
|
+
async getModels() { return []; }
|
|
118
|
+
getMessages() { return this.messages; }
|
|
119
|
+
getCurrentSessionId() { return this.currentSessionId; }
|
|
120
|
+
getSequenceNumber() { return this.messages.length; }
|
|
121
|
+
getCurrentRun() { return this.options.automationService.getCurrentRun(); }
|
|
122
|
+
resolveApproval(id, approved) { }
|
|
123
|
+
onStateChanged(cb) {
|
|
124
|
+
cb({ messages: this.messages, currentSessionId: this.currentSessionId });
|
|
125
|
+
return () => { };
|
|
126
|
+
}
|
|
127
|
+
dispose() { this.options.automationService.dispose?.(); }
|
|
551
128
|
}
|
|
552
129
|
//# sourceMappingURL=MarieRuntime.js.map
|