indusagi-coding-agent 0.1.42 → 0.1.43
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/CHANGELOG.md +13 -2
- package/README.md +3 -0
- package/dist/command-line/args.js +1 -1
- package/dist/command-line/args.js.map +1 -1
- package/dist/command-line/login-handler.d.ts.map +1 -1
- package/dist/command-line/login-handler.js +7 -0
- package/dist/command-line/login-handler.js.map +1 -1
- package/dist/dev/observe-deep.d.ts +2 -0
- package/dist/dev/observe-deep.d.ts.map +1 -0
- package/dist/dev/observe-deep.js +333 -0
- package/dist/dev/observe-deep.js.map +1 -0
- package/dist/dev/observe-smoke.d.ts +2 -0
- package/dist/dev/observe-smoke.d.ts.map +1 -0
- package/dist/dev/observe-smoke.js +264 -0
- package/dist/dev/observe-smoke.js.map +1 -0
- package/dist/interfaces/terminal-ui/components/oauth-selector.d.ts.map +1 -1
- package/dist/interfaces/terminal-ui/components/oauth-selector.js +1 -0
- package/dist/interfaces/terminal-ui/components/oauth-selector.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +40 -18
- package/dist/main.js.map +1 -1
- package/dist/observe.d.ts +2 -0
- package/dist/observe.d.ts.map +1 -0
- package/dist/observe.js +2 -0
- package/dist/observe.js.map +1 -0
- package/dist/runtime/agent-session.d.ts +11 -0
- package/dist/runtime/agent-session.d.ts.map +1 -1
- package/dist/runtime/agent-session.js +391 -201
- package/dist/runtime/agent-session.js.map +1 -1
- package/dist/runtime/model-resolver.d.ts.map +1 -1
- package/dist/runtime/model-resolver.js +1 -0
- package/dist/runtime/model-resolver.js.map +1 -1
- package/dist/runtime/observe.d.ts +50 -0
- package/dist/runtime/observe.d.ts.map +1 -0
- package/dist/runtime/observe.js +233 -0
- package/dist/runtime/observe.js.map +1 -0
- package/dist/runtime/sdk.d.ts +2 -0
- package/dist/runtime/sdk.d.ts.map +1 -1
- package/dist/runtime/sdk.js +19 -6
- package/dist/runtime/sdk.js.map +1 -1
- package/dist/vendor/observe/adapters/agent-event-adapter.d.ts +28 -0
- package/dist/vendor/observe/adapters/agent-event-adapter.d.ts.map +1 -0
- package/dist/vendor/observe/adapters/agent-event-adapter.js +136 -0
- package/dist/vendor/observe/adapters/agent-event-adapter.js.map +1 -0
- package/dist/vendor/observe/adapters/ai-stream-adapter.d.ts +24 -0
- package/dist/vendor/observe/adapters/ai-stream-adapter.d.ts.map +1 -0
- package/dist/vendor/observe/adapters/ai-stream-adapter.js +118 -0
- package/dist/vendor/observe/adapters/ai-stream-adapter.js.map +1 -0
- package/dist/vendor/observe/artifacts/content-store.d.ts +12 -0
- package/dist/vendor/observe/artifacts/content-store.d.ts.map +1 -0
- package/dist/vendor/observe/artifacts/content-store.js +2 -0
- package/dist/vendor/observe/artifacts/content-store.js.map +1 -0
- package/dist/vendor/observe/artifacts/file-content-store.d.ts +16 -0
- package/dist/vendor/observe/artifacts/file-content-store.d.ts.map +1 -0
- package/dist/vendor/observe/artifacts/file-content-store.js +43 -0
- package/dist/vendor/observe/artifacts/file-content-store.js.map +1 -0
- package/dist/vendor/observe/batcher.d.ts +27 -0
- package/dist/vendor/observe/batcher.d.ts.map +1 -0
- package/dist/vendor/observe/batcher.js +66 -0
- package/dist/vendor/observe/batcher.js.map +1 -0
- package/dist/vendor/observe/client/artifacts-manager.d.ts +29 -0
- package/dist/vendor/observe/client/artifacts-manager.d.ts.map +1 -0
- package/dist/vendor/observe/client/artifacts-manager.js +120 -0
- package/dist/vendor/observe/client/artifacts-manager.js.map +1 -0
- package/dist/vendor/observe/client/datasets-manager.d.ts +16 -0
- package/dist/vendor/observe/client/datasets-manager.d.ts.map +1 -0
- package/dist/vendor/observe/client/datasets-manager.js +27 -0
- package/dist/vendor/observe/client/datasets-manager.js.map +1 -0
- package/dist/vendor/observe/client/experiments-manager.d.ts +61 -0
- package/dist/vendor/observe/client/experiments-manager.d.ts.map +1 -0
- package/dist/vendor/observe/client/experiments-manager.js +132 -0
- package/dist/vendor/observe/client/experiments-manager.js.map +1 -0
- package/dist/vendor/observe/client/index.d.ts +9 -0
- package/dist/vendor/observe/client/index.d.ts.map +1 -0
- package/dist/vendor/observe/client/index.js +9 -0
- package/dist/vendor/observe/client/index.js.map +1 -0
- package/dist/vendor/observe/client/observe-client.d.ts +30 -0
- package/dist/vendor/observe/client/observe-client.d.ts.map +1 -0
- package/dist/vendor/observe/client/observe-client.js +22 -0
- package/dist/vendor/observe/client/observe-client.js.map +1 -0
- package/dist/vendor/observe/client/prompts-manager.d.ts +17 -0
- package/dist/vendor/observe/client/prompts-manager.d.ts.map +1 -0
- package/dist/vendor/observe/client/prompts-manager.js +38 -0
- package/dist/vendor/observe/client/prompts-manager.js.map +1 -0
- package/dist/vendor/observe/client/scores-manager.d.ts +10 -0
- package/dist/vendor/observe/client/scores-manager.d.ts.map +1 -0
- package/dist/vendor/observe/client/scores-manager.js +15 -0
- package/dist/vendor/observe/client/scores-manager.js.map +1 -0
- package/dist/vendor/observe/client/sessions-manager.d.ts +15 -0
- package/dist/vendor/observe/client/sessions-manager.d.ts.map +1 -0
- package/dist/vendor/observe/client/sessions-manager.js +24 -0
- package/dist/vendor/observe/client/sessions-manager.js.map +1 -0
- package/dist/vendor/observe/client/traces-manager.d.ts +23 -0
- package/dist/vendor/observe/client/traces-manager.d.ts.map +1 -0
- package/dist/vendor/observe/client/traces-manager.js +39 -0
- package/dist/vendor/observe/client/traces-manager.js.map +1 -0
- package/dist/vendor/observe/console-exporter.d.ts +11 -0
- package/dist/vendor/observe/console-exporter.d.ts.map +1 -0
- package/dist/vendor/observe/console-exporter.js +18 -0
- package/dist/vendor/observe/console-exporter.js.map +1 -0
- package/dist/vendor/observe/context.d.ts +4 -0
- package/dist/vendor/observe/context.d.ts.map +1 -0
- package/dist/vendor/observe/context.js +9 -0
- package/dist/vendor/observe/context.js.map +1 -0
- package/dist/vendor/observe/entities/artifacts.d.ts +46 -0
- package/dist/vendor/observe/entities/artifacts.d.ts.map +1 -0
- package/dist/vendor/observe/entities/artifacts.js +2 -0
- package/dist/vendor/observe/entities/artifacts.js.map +1 -0
- package/dist/vendor/observe/entities/datasets.d.ts +37 -0
- package/dist/vendor/observe/entities/datasets.d.ts.map +1 -0
- package/dist/vendor/observe/entities/datasets.js +2 -0
- package/dist/vendor/observe/entities/datasets.js.map +1 -0
- package/dist/vendor/observe/entities/experiments.d.ts +66 -0
- package/dist/vendor/observe/entities/experiments.d.ts.map +1 -0
- package/dist/vendor/observe/entities/experiments.js +2 -0
- package/dist/vendor/observe/entities/experiments.js.map +1 -0
- package/dist/vendor/observe/entities/index.d.ts +9 -0
- package/dist/vendor/observe/entities/index.d.ts.map +1 -0
- package/dist/vendor/observe/entities/index.js +9 -0
- package/dist/vendor/observe/entities/index.js.map +1 -0
- package/dist/vendor/observe/entities/prompts.d.ts +25 -0
- package/dist/vendor/observe/entities/prompts.d.ts.map +1 -0
- package/dist/vendor/observe/entities/prompts.js +2 -0
- package/dist/vendor/observe/entities/prompts.js.map +1 -0
- package/dist/vendor/observe/entities/scores.d.ts +28 -0
- package/dist/vendor/observe/entities/scores.d.ts.map +1 -0
- package/dist/vendor/observe/entities/scores.js +2 -0
- package/dist/vendor/observe/entities/scores.js.map +1 -0
- package/dist/vendor/observe/entities/sessions.d.ts +36 -0
- package/dist/vendor/observe/entities/sessions.d.ts.map +1 -0
- package/dist/vendor/observe/entities/sessions.js +2 -0
- package/dist/vendor/observe/entities/sessions.js.map +1 -0
- package/dist/vendor/observe/entities/shared.d.ts +26 -0
- package/dist/vendor/observe/entities/shared.d.ts.map +1 -0
- package/dist/vendor/observe/entities/shared.js +2 -0
- package/dist/vendor/observe/entities/shared.js.map +1 -0
- package/dist/vendor/observe/entities/traces.d.ts +59 -0
- package/dist/vendor/observe/entities/traces.d.ts.map +1 -0
- package/dist/vendor/observe/entities/traces.js +2 -0
- package/dist/vendor/observe/entities/traces.js.map +1 -0
- package/dist/vendor/observe/exporter.d.ts +2 -0
- package/dist/vendor/observe/exporter.d.ts.map +1 -0
- package/dist/vendor/observe/exporter.js +2 -0
- package/dist/vendor/observe/exporter.js.map +1 -0
- package/dist/vendor/observe/file-exporter.d.ts +16 -0
- package/dist/vendor/observe/file-exporter.d.ts.map +1 -0
- package/dist/vendor/observe/file-exporter.js +39 -0
- package/dist/vendor/observe/file-exporter.js.map +1 -0
- package/dist/vendor/observe/global.d.ts +6 -0
- package/dist/vendor/observe/global.d.ts.map +1 -0
- package/dist/vendor/observe/global.js +17 -0
- package/dist/vendor/observe/global.js.map +1 -0
- package/dist/vendor/observe/index.d.ts +24 -0
- package/dist/vendor/observe/index.d.ts.map +1 -0
- package/dist/vendor/observe/index.js +24 -0
- package/dist/vendor/observe/index.js.map +1 -0
- package/dist/vendor/observe/noop.d.ts +17 -0
- package/dist/vendor/observe/noop.d.ts.map +1 -0
- package/dist/vendor/observe/noop.js +80 -0
- package/dist/vendor/observe/noop.js.map +1 -0
- package/dist/vendor/observe/privacy.d.ts +18 -0
- package/dist/vendor/observe/privacy.d.ts.map +1 -0
- package/dist/vendor/observe/privacy.js +160 -0
- package/dist/vendor/observe/privacy.js.map +1 -0
- package/dist/vendor/observe/query/simple-query-client.d.ts +11 -0
- package/dist/vendor/observe/query/simple-query-client.d.ts.map +1 -0
- package/dist/vendor/observe/query/simple-query-client.js +31 -0
- package/dist/vendor/observe/query/simple-query-client.js.map +1 -0
- package/dist/vendor/observe/replay/session-replay.d.ts +20 -0
- package/dist/vendor/observe/replay/session-replay.d.ts.map +1 -0
- package/dist/vendor/observe/replay/session-replay.js +180 -0
- package/dist/vendor/observe/replay/session-replay.js.map +1 -0
- package/dist/vendor/observe/runtime.d.ts +27 -0
- package/dist/vendor/observe/runtime.d.ts.map +1 -0
- package/dist/vendor/observe/runtime.js +177 -0
- package/dist/vendor/observe/runtime.js.map +1 -0
- package/dist/vendor/observe/server/dashboard-html.d.ts +6 -0
- package/dist/vendor/observe/server/dashboard-html.d.ts.map +1 -0
- package/dist/vendor/observe/server/dashboard-html.js +305 -0
- package/dist/vendor/observe/server/dashboard-html.js.map +1 -0
- package/dist/vendor/observe/server/http-observe-server.d.ts +62 -0
- package/dist/vendor/observe/server/http-observe-server.d.ts.map +1 -0
- package/dist/vendor/observe/server/http-observe-server.js +418 -0
- package/dist/vendor/observe/server/http-observe-server.js.map +1 -0
- package/dist/vendor/observe/server/in-memory-observe-server.d.ts +20 -0
- package/dist/vendor/observe/server/in-memory-observe-server.d.ts.map +1 -0
- package/dist/vendor/observe/server/in-memory-observe-server.js +76 -0
- package/dist/vendor/observe/server/in-memory-observe-server.js.map +1 -0
- package/dist/vendor/observe/span.d.ts +45 -0
- package/dist/vendor/observe/span.d.ts.map +1 -0
- package/dist/vendor/observe/span.js +110 -0
- package/dist/vendor/observe/span.js.map +1 -0
- package/dist/vendor/observe/store/contracts.d.ts +59 -0
- package/dist/vendor/observe/store/contracts.d.ts.map +1 -0
- package/dist/vendor/observe/store/contracts.js +2 -0
- package/dist/vendor/observe/store/contracts.js.map +1 -0
- package/dist/vendor/observe/store/file-control-plane-store.d.ts +33 -0
- package/dist/vendor/observe/store/file-control-plane-store.d.ts.map +1 -0
- package/dist/vendor/observe/store/file-control-plane-store.js +146 -0
- package/dist/vendor/observe/store/file-control-plane-store.js.map +1 -0
- package/dist/vendor/observe/store/in-memory-control-plane-store.d.ts +84 -0
- package/dist/vendor/observe/store/in-memory-control-plane-store.d.ts.map +1 -0
- package/dist/vendor/observe/store/in-memory-control-plane-store.js +447 -0
- package/dist/vendor/observe/store/in-memory-control-plane-store.js.map +1 -0
- package/dist/vendor/observe/store/index.d.ts +4 -0
- package/dist/vendor/observe/store/index.d.ts.map +1 -0
- package/dist/vendor/observe/store/index.js +4 -0
- package/dist/vendor/observe/store/index.js.map +1 -0
- package/dist/vendor/observe/types.d.ts +246 -0
- package/dist/vendor/observe/types.d.ts.map +1 -0
- package/dist/vendor/observe/types.js +152 -0
- package/dist/vendor/observe/types.js.map +1 -0
- package/dist/vendor/observe/worker/in-memory-observe-worker.d.ts +25 -0
- package/dist/vendor/observe/worker/in-memory-observe-worker.d.ts.map +1 -0
- package/dist/vendor/observe/worker/in-memory-observe-worker.js +82 -0
- package/dist/vendor/observe/worker/in-memory-observe-worker.js.map +1 -0
- package/guides/INDUSVX_OBSERVE_FULL_INTEGRATION_REPORT.md +543 -0
- package/guides/OBSERVE_DEEP_VALIDATION.md +252 -0
- package/guides/OBSERVE_LOCAL_TESTING.md +183 -0
- package/package.json +11 -4
|
@@ -220,8 +220,10 @@
|
|
|
220
220
|
import { readFileSync } from "node:fs";
|
|
221
221
|
import { join } from "node:path";
|
|
222
222
|
import { isContextOverflow, modelsAreEqual, resetApiProviders, supportsXhigh } from "indusagi/ai";
|
|
223
|
+
import { AgentEventObserveAdapter } from "../observe.js";
|
|
223
224
|
import { getAgentDir, getDocsPath } from "../config.js";
|
|
224
225
|
import { theme } from "../interfaces/terminal-ui/theme/theme.js";
|
|
226
|
+
import { runObserveOperation } from "./observe.js";
|
|
225
227
|
import { stripFrontmatter } from "../helpers/frontmatter.js";
|
|
226
228
|
import { sleep } from "../helpers/sleep.js";
|
|
227
229
|
import { executeBash as executeBashCommand, executeBashWithOperations } from "./bash-executor.js";
|
|
@@ -342,6 +344,7 @@ export class AgentSession {
|
|
|
342
344
|
this._subagentStore = new SubagentStore({ cwd: this._cwd, agentDir: this._agentDir });
|
|
343
345
|
this._extensionRunnerRef = config.extensionRunnerRef;
|
|
344
346
|
this._hookRunnerRef = config.hookRunnerRef;
|
|
347
|
+
this._observe = config.observe;
|
|
345
348
|
this._initialActiveToolNames = config.initialActiveToolNames;
|
|
346
349
|
this._baseToolsOverride = config.baseToolsOverride;
|
|
347
350
|
this._wireAgentEventHandlers();
|
|
@@ -354,6 +357,27 @@ export class AgentSession {
|
|
|
354
357
|
get modelRegistry() {
|
|
355
358
|
return this._modelRegistry;
|
|
356
359
|
}
|
|
360
|
+
async initializeObserve() {
|
|
361
|
+
if (!this._observe)
|
|
362
|
+
return;
|
|
363
|
+
await this._observe.initializeSession(this._getObserveSessionSnapshot());
|
|
364
|
+
if (!this._observeAgentEventsUnsubscribe) {
|
|
365
|
+
const adapter = new AgentEventObserveAdapter({
|
|
366
|
+
sink: this._observe.sink,
|
|
367
|
+
includeMessageText: this._observe.captureAgentEventText,
|
|
368
|
+
});
|
|
369
|
+
this._observeAgentEventsUnsubscribe = adapter.attach(this.agent);
|
|
370
|
+
}
|
|
371
|
+
await this._observe.log({
|
|
372
|
+
sessionId: this.sessionId,
|
|
373
|
+
name: "session.initialize",
|
|
374
|
+
summary: "observe session initialized",
|
|
375
|
+
attributes: {
|
|
376
|
+
sessionFile: this.sessionFile,
|
|
377
|
+
activeToolCount: this.getActiveToolNames().length,
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
}
|
|
357
381
|
// =========================================================================
|
|
358
382
|
// Event Subscription
|
|
359
383
|
// =========================================================================
|
|
@@ -431,6 +455,42 @@ export class AgentSession {
|
|
|
431
455
|
this._retryPromise = undefined;
|
|
432
456
|
}
|
|
433
457
|
}
|
|
458
|
+
_getObserveSessionSnapshot() {
|
|
459
|
+
return {
|
|
460
|
+
id: this.sessionId,
|
|
461
|
+
cwd: this._cwd,
|
|
462
|
+
sessionFile: this.sessionFile,
|
|
463
|
+
model: this.model ? { provider: this.model.provider, id: this.model.id } : undefined,
|
|
464
|
+
activeToolNames: this.getActiveToolNames(),
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
async _refreshObserveSession() {
|
|
468
|
+
await this._observe?.initializeSession(this._getObserveSessionSnapshot());
|
|
469
|
+
}
|
|
470
|
+
async _endObserveSession(sessionId, status = "ended") {
|
|
471
|
+
await this._observe?.endSession(sessionId, status);
|
|
472
|
+
}
|
|
473
|
+
async _logObserve(options) {
|
|
474
|
+
await this._observe?.log({
|
|
475
|
+
sessionId: this.sessionId,
|
|
476
|
+
...options,
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
async _runObserveOperation(name, kind, fn, options = {}) {
|
|
480
|
+
return runObserveOperation(this._observe, {
|
|
481
|
+
sessionId: this.sessionId,
|
|
482
|
+
name,
|
|
483
|
+
kind,
|
|
484
|
+
input: options.input,
|
|
485
|
+
attributes: {
|
|
486
|
+
sessionFile: this.sessionFile,
|
|
487
|
+
modelId: this.model?.id,
|
|
488
|
+
provider: this.model?.provider,
|
|
489
|
+
...options.attributes,
|
|
490
|
+
},
|
|
491
|
+
output: options.output,
|
|
492
|
+
}, fn);
|
|
493
|
+
}
|
|
434
494
|
/** Extract text content from a message */
|
|
435
495
|
_getUserMessageText(message) {
|
|
436
496
|
if (message.role !== "user")
|
|
@@ -532,6 +592,8 @@ export class AgentSession {
|
|
|
532
592
|
*/
|
|
533
593
|
dispose() {
|
|
534
594
|
this._disconnectFromAgent();
|
|
595
|
+
this._observeAgentEventsUnsubscribe?.();
|
|
596
|
+
this._observeAgentEventsUnsubscribe = undefined;
|
|
535
597
|
this._eventListeners = [];
|
|
536
598
|
}
|
|
537
599
|
// =========================================================================
|
|
@@ -786,8 +848,21 @@ export class AgentSession {
|
|
|
786
848
|
this.agent.setSystemPrompt(this._baseSystemPrompt);
|
|
787
849
|
}
|
|
788
850
|
}
|
|
851
|
+
await this._logObserve({
|
|
852
|
+
name: "session.prompt",
|
|
853
|
+
summary: "prompt submitted to agent",
|
|
854
|
+
attributes: {
|
|
855
|
+
textLength: expandedText.length,
|
|
856
|
+
imageCount: currentImages?.length ?? 0,
|
|
857
|
+
pendingNextTurnMessages: messages.length - 1,
|
|
858
|
+
},
|
|
859
|
+
data: {
|
|
860
|
+
imageCount: currentImages?.length ?? 0,
|
|
861
|
+
},
|
|
862
|
+
});
|
|
789
863
|
await this.agent.prompt(messages);
|
|
790
864
|
await this.waitForRetry();
|
|
865
|
+
await this._refreshObserveSession();
|
|
791
866
|
}
|
|
792
867
|
/**
|
|
793
868
|
* Try to execute an extension command. Returns true if command was found and executed.
|
|
@@ -1044,38 +1119,55 @@ export class AgentSession {
|
|
|
1044
1119
|
* @returns true if completed, false if cancelled by extension
|
|
1045
1120
|
*/
|
|
1046
1121
|
async newSession(options) {
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1122
|
+
return this._runObserveOperation("session.new", "session_switch", async () => {
|
|
1123
|
+
const previousSessionFile = this.sessionFile;
|
|
1124
|
+
const previousSessionId = this.sessionId;
|
|
1125
|
+
// Emit session_before_switch event with reason "new" (can be cancelled)
|
|
1126
|
+
if (this._extensionRunner?.hasHandlers("session_before_switch")) {
|
|
1127
|
+
const result = (await this._extensionRunner.emit({
|
|
1128
|
+
type: "session_before_switch",
|
|
1129
|
+
reason: "new",
|
|
1130
|
+
}));
|
|
1131
|
+
if (result?.cancel) {
|
|
1132
|
+
return false;
|
|
1133
|
+
}
|
|
1056
1134
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1135
|
+
this._disconnectFromAgent();
|
|
1136
|
+
await this.abort();
|
|
1137
|
+
this.agent.reset();
|
|
1138
|
+
this.sessionManager.newSession(options);
|
|
1139
|
+
this._rebuildTodoStore();
|
|
1140
|
+
this.agent.sessionId = this.sessionManager.getSessionId();
|
|
1141
|
+
this._memoryThreadId = this.sessionManager.getSessionId();
|
|
1142
|
+
this._steeringMessages = [];
|
|
1143
|
+
this._followUpMessages = [];
|
|
1144
|
+
this._pendingNextTurnMessages = [];
|
|
1145
|
+
this._reconnectToAgent();
|
|
1146
|
+
await this._endObserveSession(previousSessionId);
|
|
1147
|
+
await this._refreshObserveSession();
|
|
1148
|
+
await this._logObserve({
|
|
1149
|
+
name: "session.new",
|
|
1150
|
+
summary: "created new session",
|
|
1151
|
+
attributes: {
|
|
1152
|
+
previousSessionId,
|
|
1153
|
+
previousSessionFile,
|
|
1154
|
+
},
|
|
1075
1155
|
});
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1156
|
+
// Emit session_switch event with reason "new" to extensions
|
|
1157
|
+
if (this._extensionRunner) {
|
|
1158
|
+
await this._extensionRunner.emit({
|
|
1159
|
+
type: "session_switch",
|
|
1160
|
+
reason: "new",
|
|
1161
|
+
previousSessionFile,
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
return true;
|
|
1165
|
+
}, {
|
|
1166
|
+
attributes: {
|
|
1167
|
+
previousSessionFile: this.sessionFile,
|
|
1168
|
+
},
|
|
1169
|
+
output: (completed) => ({ completed }),
|
|
1170
|
+
});
|
|
1079
1171
|
}
|
|
1080
1172
|
// =========================================================================
|
|
1081
1173
|
// Model Management
|
|
@@ -1905,31 +1997,57 @@ export class AgentSession {
|
|
|
1905
1997
|
* @param options.operations Custom BashOperations for remote execution
|
|
1906
1998
|
*/
|
|
1907
1999
|
async executeBash(command, onChunk, options) {
|
|
1908
|
-
this.
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
2000
|
+
return this._runObserveOperation("session.execute_bash", "command_execution", async () => {
|
|
2001
|
+
this._bashAbortController = new AbortController();
|
|
2002
|
+
// Apply command prefix if configured (e.g., "shopt -s expand_aliases" for alias support)
|
|
2003
|
+
const prefix = this.settingsManager.getShellCommandPrefix();
|
|
2004
|
+
const resolvedCommand = prefix ? `${prefix}\n${command}` : command;
|
|
2005
|
+
const hookEnv = this._hookRunner?.hasHandlers("shell.env")
|
|
2006
|
+
? (await this._hookRunner.trigger("shell.env", { cwd: process.cwd() }, { env: {} })).env
|
|
2007
|
+
: undefined;
|
|
2008
|
+
try {
|
|
2009
|
+
const result = options?.operations
|
|
2010
|
+
? await executeBashWithOperations(resolvedCommand, process.cwd(), options.operations, {
|
|
2011
|
+
onChunk,
|
|
2012
|
+
signal: this._bashAbortController.signal,
|
|
2013
|
+
env: hookEnv,
|
|
2014
|
+
})
|
|
2015
|
+
: await executeBashCommand(resolvedCommand, {
|
|
2016
|
+
onChunk,
|
|
2017
|
+
signal: this._bashAbortController.signal,
|
|
2018
|
+
env: hookEnv,
|
|
2019
|
+
});
|
|
2020
|
+
this.recordBashResult(command, result, options);
|
|
2021
|
+
await this._logObserve({
|
|
2022
|
+
name: "session.execute_bash",
|
|
2023
|
+
summary: "bash command completed",
|
|
2024
|
+
attributes: {
|
|
2025
|
+
commandLength: command.length,
|
|
2026
|
+
exitCode: result.exitCode,
|
|
2027
|
+
cancelled: result.cancelled,
|
|
2028
|
+
truncated: result.truncated,
|
|
2029
|
+
excludeFromContext: options?.excludeFromContext ?? false,
|
|
2030
|
+
},
|
|
1926
2031
|
});
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
}
|
|
2032
|
+
return result;
|
|
2033
|
+
}
|
|
2034
|
+
finally {
|
|
2035
|
+
this._bashAbortController = undefined;
|
|
2036
|
+
}
|
|
2037
|
+
}, {
|
|
2038
|
+
input: {
|
|
2039
|
+
commandLength: command.length,
|
|
2040
|
+
excludeFromContext: options?.excludeFromContext ?? false,
|
|
2041
|
+
},
|
|
2042
|
+
attributes: {
|
|
2043
|
+
hasCustomOperations: !!options?.operations,
|
|
2044
|
+
},
|
|
2045
|
+
output: (result) => ({
|
|
2046
|
+
exitCode: result.exitCode,
|
|
2047
|
+
cancelled: result.cancelled,
|
|
2048
|
+
truncated: result.truncated,
|
|
2049
|
+
}),
|
|
2050
|
+
});
|
|
1933
2051
|
}
|
|
1934
2052
|
/**
|
|
1935
2053
|
* Record a bash execution result in session history.
|
|
@@ -1998,56 +2116,72 @@ export class AgentSession {
|
|
|
1998
2116
|
* @returns true if switch completed, false if cancelled by extension
|
|
1999
2117
|
*/
|
|
2000
2118
|
async switchSession(sessionPath) {
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2119
|
+
return this._runObserveOperation("session.switch", "session_switch", async () => {
|
|
2120
|
+
const previousSessionFile = this.sessionManager.getSessionFile();
|
|
2121
|
+
const previousSessionId = this.sessionId;
|
|
2122
|
+
// Emit session_before_switch event (can be cancelled)
|
|
2123
|
+
if (this._extensionRunner?.hasHandlers("session_before_switch")) {
|
|
2124
|
+
const result = (await this._extensionRunner.emit({
|
|
2125
|
+
type: "session_before_switch",
|
|
2126
|
+
reason: "resume",
|
|
2127
|
+
targetSessionFile: sessionPath,
|
|
2128
|
+
}));
|
|
2129
|
+
if (result?.cancel) {
|
|
2130
|
+
return false;
|
|
2131
|
+
}
|
|
2011
2132
|
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
});
|
|
2032
|
-
}
|
|
2033
|
-
// Emit session event to custom tools
|
|
2034
|
-
this.agent.replaceMessages(sessionContext.messages);
|
|
2035
|
-
// Restore model if saved
|
|
2036
|
-
if (sessionContext.model) {
|
|
2037
|
-
const previousModel = this.model;
|
|
2038
|
-
const availableModels = await this._modelRegistry.getAvailable();
|
|
2039
|
-
const match = availableModels.find((m) => m.provider === sessionContext.model.provider && m.id === sessionContext.model.modelId);
|
|
2040
|
-
if (match) {
|
|
2041
|
-
this.agent.setModel(match);
|
|
2042
|
-
await this._emitModelSelect(match, previousModel, "restore");
|
|
2133
|
+
this._disconnectFromAgent();
|
|
2134
|
+
await this.abort();
|
|
2135
|
+
this._steeringMessages = [];
|
|
2136
|
+
this._followUpMessages = [];
|
|
2137
|
+
this._pendingNextTurnMessages = [];
|
|
2138
|
+
// Set new session
|
|
2139
|
+
this.sessionManager.setSessionFile(sessionPath);
|
|
2140
|
+
this._rebuildTodoStore();
|
|
2141
|
+
this.agent.sessionId = this.sessionManager.getSessionId();
|
|
2142
|
+
this._memoryThreadId = this.sessionManager.getSessionId();
|
|
2143
|
+
// Reload messages
|
|
2144
|
+
const sessionContext = this.sessionManager.buildSessionContext();
|
|
2145
|
+
// Emit session_switch event to extensions
|
|
2146
|
+
if (this._extensionRunner) {
|
|
2147
|
+
await this._extensionRunner.emit({
|
|
2148
|
+
type: "session_switch",
|
|
2149
|
+
reason: "resume",
|
|
2150
|
+
previousSessionFile,
|
|
2151
|
+
});
|
|
2043
2152
|
}
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2153
|
+
this.agent.replaceMessages(sessionContext.messages);
|
|
2154
|
+
// Restore model if saved
|
|
2155
|
+
if (sessionContext.model) {
|
|
2156
|
+
const previousModel = this.model;
|
|
2157
|
+
const availableModels = await this._modelRegistry.getAvailable();
|
|
2158
|
+
const match = availableModels.find((m) => m.provider === sessionContext.model.provider && m.id === sessionContext.model.modelId);
|
|
2159
|
+
if (match) {
|
|
2160
|
+
this.agent.setModel(match);
|
|
2161
|
+
await this._emitModelSelect(match, previousModel, "restore");
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
// Restore thinking level if saved (setThinkingLevel clamps to model capabilities)
|
|
2165
|
+
if (sessionContext.thinkingLevel) {
|
|
2166
|
+
this.setThinkingLevel(sessionContext.thinkingLevel);
|
|
2167
|
+
}
|
|
2168
|
+
this._reconnectToAgent();
|
|
2169
|
+
await this._endObserveSession(previousSessionId);
|
|
2170
|
+
await this._refreshObserveSession();
|
|
2171
|
+
await this._logObserve({
|
|
2172
|
+
name: "session.switch",
|
|
2173
|
+
summary: "switched session",
|
|
2174
|
+
attributes: {
|
|
2175
|
+
previousSessionId,
|
|
2176
|
+
previousSessionFile,
|
|
2177
|
+
targetSessionFile: sessionPath,
|
|
2178
|
+
},
|
|
2179
|
+
});
|
|
2180
|
+
return true;
|
|
2181
|
+
}, {
|
|
2182
|
+
input: { targetSessionFile: sessionPath },
|
|
2183
|
+
output: (completed) => ({ completed }),
|
|
2184
|
+
});
|
|
2051
2185
|
}
|
|
2052
2186
|
/**
|
|
2053
2187
|
* Create a fork from a specific entry.
|
|
@@ -2059,49 +2193,66 @@ export class AgentSession {
|
|
|
2059
2193
|
* - cancelled: True if an extension cancelled the fork
|
|
2060
2194
|
*/
|
|
2061
2195
|
async fork(entryId) {
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
let skipConversationRestore = false;
|
|
2069
|
-
// Emit session_before_fork event (can be cancelled)
|
|
2070
|
-
if (this._extensionRunner?.hasHandlers("session_before_fork")) {
|
|
2071
|
-
const result = (await this._extensionRunner.emit({
|
|
2072
|
-
type: "session_before_fork",
|
|
2073
|
-
entryId,
|
|
2074
|
-
}));
|
|
2075
|
-
if (result?.cancel) {
|
|
2076
|
-
return { selectedText, cancelled: true };
|
|
2196
|
+
return this._runObserveOperation("session.fork", "session_fork", async () => {
|
|
2197
|
+
const previousSessionFile = this.sessionFile;
|
|
2198
|
+
const previousSessionId = this.sessionId;
|
|
2199
|
+
const selectedEntry = this.sessionManager.getEntry(entryId);
|
|
2200
|
+
if (!selectedEntry || selectedEntry.type !== "message" || selectedEntry.message.role !== "user") {
|
|
2201
|
+
throw new Error("Invalid entry ID for forking");
|
|
2077
2202
|
}
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2203
|
+
const selectedText = this._extractUserMessageText(selectedEntry.message.content);
|
|
2204
|
+
let skipConversationRestore = false;
|
|
2205
|
+
// Emit session_before_fork event (can be cancelled)
|
|
2206
|
+
if (this._extensionRunner?.hasHandlers("session_before_fork")) {
|
|
2207
|
+
const result = (await this._extensionRunner.emit({
|
|
2208
|
+
type: "session_before_fork",
|
|
2209
|
+
entryId,
|
|
2210
|
+
}));
|
|
2211
|
+
if (result?.cancel) {
|
|
2212
|
+
return { selectedText, cancelled: true };
|
|
2213
|
+
}
|
|
2214
|
+
skipConversationRestore = result?.skipConversationRestore ?? false;
|
|
2215
|
+
}
|
|
2216
|
+
// Clear pending messages (bound to old session state)
|
|
2217
|
+
this._pendingNextTurnMessages = [];
|
|
2218
|
+
if (!selectedEntry.parentId) {
|
|
2219
|
+
this.sessionManager.newSession();
|
|
2220
|
+
}
|
|
2221
|
+
else {
|
|
2222
|
+
this.sessionManager.createBranchedSession(selectedEntry.parentId);
|
|
2223
|
+
}
|
|
2224
|
+
this.agent.sessionId = this.sessionManager.getSessionId();
|
|
2225
|
+
this._memoryThreadId = this.sessionManager.getSessionId();
|
|
2226
|
+
this._rebuildTodoStore();
|
|
2227
|
+
// Reload messages from entries (works for both file and in-memory mode)
|
|
2228
|
+
const sessionContext = this.sessionManager.buildSessionContext();
|
|
2229
|
+
// Emit session_fork event to extensions (after fork completes)
|
|
2230
|
+
if (this._extensionRunner) {
|
|
2231
|
+
await this._extensionRunner.emit({
|
|
2232
|
+
type: "session_fork",
|
|
2233
|
+
previousSessionFile,
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
if (!skipConversationRestore) {
|
|
2237
|
+
this.agent.replaceMessages(sessionContext.messages);
|
|
2238
|
+
}
|
|
2239
|
+
await this._endObserveSession(previousSessionId);
|
|
2240
|
+
await this._refreshObserveSession();
|
|
2241
|
+
await this._logObserve({
|
|
2242
|
+
name: "session.fork",
|
|
2243
|
+
summary: "forked session branch",
|
|
2244
|
+
attributes: {
|
|
2245
|
+
entryId,
|
|
2246
|
+
previousSessionId,
|
|
2247
|
+
previousSessionFile,
|
|
2248
|
+
skipConversationRestore,
|
|
2249
|
+
},
|
|
2098
2250
|
});
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
}
|
|
2104
|
-
return { selectedText, cancelled: false };
|
|
2251
|
+
return { selectedText, cancelled: false };
|
|
2252
|
+
}, {
|
|
2253
|
+
input: { entryId },
|
|
2254
|
+
output: (result) => ({ cancelled: result.cancelled, selectedTextLength: result.selectedText.length }),
|
|
2255
|
+
});
|
|
2105
2256
|
}
|
|
2106
2257
|
// =========================================================================
|
|
2107
2258
|
// Tree Navigation
|
|
@@ -2451,13 +2602,22 @@ export class AgentSession {
|
|
|
2451
2602
|
}
|
|
2452
2603
|
// Rebuild active tools to include MCP tools
|
|
2453
2604
|
const currentActive = this.getActiveToolNames();
|
|
2454
|
-
const mcpToolNames = tools.map(t => t.name);
|
|
2605
|
+
const mcpToolNames = tools.map((t) => t.name);
|
|
2455
2606
|
this.setActiveToolsByName([...currentActive, ...mcpToolNames]);
|
|
2456
2607
|
// Rebuild runtime to include MCP tools in agent
|
|
2457
2608
|
this._rebuildRuntimeState({
|
|
2458
2609
|
activeToolNames: [...currentActive, ...mcpToolNames],
|
|
2459
2610
|
includeAllExtensionTools: true,
|
|
2460
2611
|
});
|
|
2612
|
+
void this._refreshObserveSession();
|
|
2613
|
+
void this._logObserve({
|
|
2614
|
+
name: "mcp.register_tools",
|
|
2615
|
+
summary: "registered MCP tools",
|
|
2616
|
+
attributes: {
|
|
2617
|
+
toolCount: tools.length,
|
|
2618
|
+
toolNames: tools.map((tool) => tool.name),
|
|
2619
|
+
},
|
|
2620
|
+
});
|
|
2461
2621
|
}
|
|
2462
2622
|
/**
|
|
2463
2623
|
* Get MCP server status.
|
|
@@ -2499,16 +2659,22 @@ export class AgentSession {
|
|
|
2499
2659
|
* @returns Promise resolving to the number of tools loaded
|
|
2500
2660
|
*/
|
|
2501
2661
|
async reconnectMCP(configPath) {
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2662
|
+
return this._runObserveOperation("mcp.reconnect", "mcp_call", async () => {
|
|
2663
|
+
// First disconnect existing connections
|
|
2664
|
+
await this.disconnectMCP();
|
|
2665
|
+
// Load new tools
|
|
2666
|
+
const { createMCPTools } = await import("./tooling/index.js");
|
|
2667
|
+
const result = await createMCPTools(configPath);
|
|
2668
|
+
// Register tools
|
|
2669
|
+
if (result.tools.length > 0) {
|
|
2670
|
+
this.registerMCPTools(result.tools, result.pool);
|
|
2671
|
+
}
|
|
2672
|
+
await this._refreshObserveSession();
|
|
2673
|
+
return result.tools.length;
|
|
2674
|
+
}, {
|
|
2675
|
+
input: { configPath },
|
|
2676
|
+
output: (toolCount) => ({ toolCount }),
|
|
2677
|
+
});
|
|
2512
2678
|
}
|
|
2513
2679
|
// =========================================================================
|
|
2514
2680
|
// Memory System
|
|
@@ -2529,73 +2695,97 @@ export class AgentSession {
|
|
|
2529
2695
|
}
|
|
2530
2696
|
// Rebuild active tools to include memory tools
|
|
2531
2697
|
const currentActive = this.getActiveToolNames();
|
|
2532
|
-
const memoryToolNames = tools.map(t => t.name);
|
|
2698
|
+
const memoryToolNames = tools.map((t) => t.name);
|
|
2533
2699
|
this.setActiveToolsByName([...currentActive, ...memoryToolNames]);
|
|
2534
2700
|
// Rebuild runtime to include memory tools in agent
|
|
2535
2701
|
this._rebuildRuntimeState({
|
|
2536
2702
|
activeToolNames: [...currentActive, ...memoryToolNames],
|
|
2537
2703
|
includeAllExtensionTools: true,
|
|
2538
2704
|
});
|
|
2705
|
+
void this._refreshObserveSession();
|
|
2706
|
+
void this._logObserve({
|
|
2707
|
+
name: "memory.register_tools",
|
|
2708
|
+
summary: "registered memory tools",
|
|
2709
|
+
attributes: {
|
|
2710
|
+
toolCount: tools.length,
|
|
2711
|
+
toolNames: tools.map((tool) => tool.name),
|
|
2712
|
+
},
|
|
2713
|
+
});
|
|
2539
2714
|
}
|
|
2540
2715
|
/**
|
|
2541
2716
|
* Enable memory for the current and future sessions.
|
|
2542
2717
|
* Optionally persists an OpenAI API key before initializing memory.
|
|
2543
2718
|
*/
|
|
2544
2719
|
async enableMemory(options) {
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2720
|
+
await this._runObserveOperation("memory.enable", "custom", async () => {
|
|
2721
|
+
const persistSettings = options?.persistSettings ?? true;
|
|
2722
|
+
if (this._memory) {
|
|
2723
|
+
await this.disableMemory({ persistSettings: false });
|
|
2724
|
+
}
|
|
2725
|
+
if (options?.apiKey) {
|
|
2726
|
+
this._modelRegistry.authStorage.set("openai", "default", {
|
|
2727
|
+
type: "api_key",
|
|
2728
|
+
key: options.apiKey,
|
|
2729
|
+
accountName: "Default",
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
const openaiKey = options?.apiKey ?? (await this._modelRegistry.getApiKeyForProvider("openai"));
|
|
2733
|
+
if (!openaiKey) {
|
|
2734
|
+
throw new Error("OpenAI API key not found. Run /memory setup <OPENAI_API_KEY> first.");
|
|
2735
|
+
}
|
|
2736
|
+
const memory = await createMemory({
|
|
2737
|
+
apiKey: openaiKey,
|
|
2738
|
+
lastMessages: this.settingsManager.getMemoryLastMessages(),
|
|
2739
|
+
workingMemory: this.settingsManager.getMemoryWorkingMemoryEnabled()
|
|
2740
|
+
? { enabled: true, scope: "resource", template: DEFAULT_WORKING_MEMORY_TEMPLATE }
|
|
2741
|
+
: undefined,
|
|
2742
|
+
semanticRecall: this.settingsManager.getMemorySemanticRecallEnabled()
|
|
2743
|
+
? { topK: 5, messageRange: 2 }
|
|
2744
|
+
: undefined,
|
|
2745
|
+
observationalMemory: this.settingsManager.getMemoryObservationalMemoryEnabled()
|
|
2746
|
+
? { enabled: true, scope: "thread" }
|
|
2747
|
+
: undefined,
|
|
2554
2748
|
});
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
observationalMemory: this.settingsManager.getMemoryObservationalMemoryEnabled()
|
|
2570
|
-
? { enabled: true, scope: "thread" }
|
|
2571
|
-
: undefined,
|
|
2572
|
-
});
|
|
2573
|
-
const memoryTools = createMemoryTools(memory, {
|
|
2574
|
-
threadId: this.sessionManager.getSessionId(),
|
|
2575
|
-
resourceId: this._memoryResourceId,
|
|
2749
|
+
const memoryTools = createMemoryTools(memory, {
|
|
2750
|
+
threadId: this.sessionManager.getSessionId(),
|
|
2751
|
+
resourceId: this._memoryResourceId,
|
|
2752
|
+
});
|
|
2753
|
+
this.registerMemoryTools(memoryTools, memory);
|
|
2754
|
+
if (persistSettings) {
|
|
2755
|
+
this.settingsManager.setMemorySettings({ enabled: true, autoConnect: true });
|
|
2756
|
+
}
|
|
2757
|
+
await this._refreshObserveSession();
|
|
2758
|
+
}, {
|
|
2759
|
+
attributes: {
|
|
2760
|
+
persistSettings: options?.persistSettings ?? true,
|
|
2761
|
+
hasApiKeyOverride: !!options?.apiKey,
|
|
2762
|
+
},
|
|
2576
2763
|
});
|
|
2577
|
-
this.registerMemoryTools(memoryTools, memory);
|
|
2578
|
-
if (persistSettings) {
|
|
2579
|
-
this.settingsManager.setMemorySettings({ enabled: true, autoConnect: true });
|
|
2580
|
-
}
|
|
2581
2764
|
}
|
|
2582
2765
|
/**
|
|
2583
2766
|
* Disable memory for the current and future sessions.
|
|
2584
2767
|
*/
|
|
2585
2768
|
async disableMemory(options) {
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2769
|
+
await this._runObserveOperation("memory.disable", "custom", async () => {
|
|
2770
|
+
const persistSettings = options?.persistSettings ?? true;
|
|
2771
|
+
const memoryToolNames = new Set(this._memoryTools.map((tool) => tool.name));
|
|
2772
|
+
const activeWithoutMemory = this.getActiveToolNames().filter((name) => !memoryToolNames.has(name));
|
|
2773
|
+
this._memory = undefined;
|
|
2774
|
+
this._memoryTools = [];
|
|
2775
|
+
this._memoryThreadId = "";
|
|
2776
|
+
this._rebuildRuntimeState({
|
|
2777
|
+
activeToolNames: activeWithoutMemory,
|
|
2778
|
+
includeAllExtensionTools: true,
|
|
2779
|
+
});
|
|
2780
|
+
if (persistSettings) {
|
|
2781
|
+
this.settingsManager.setMemorySettings({ enabled: false, autoConnect: false });
|
|
2782
|
+
}
|
|
2783
|
+
await this._refreshObserveSession();
|
|
2784
|
+
}, {
|
|
2785
|
+
attributes: {
|
|
2786
|
+
persistSettings: options?.persistSettings ?? true,
|
|
2787
|
+
},
|
|
2595
2788
|
});
|
|
2596
|
-
if (persistSettings) {
|
|
2597
|
-
this.settingsManager.setMemorySettings({ enabled: false, autoConnect: false });
|
|
2598
|
-
}
|
|
2599
2789
|
}
|
|
2600
2790
|
/**
|
|
2601
2791
|
* Get the memory instance.
|