切换到使用pg数据库
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { tool } from "@opencode-ai/plugin";
|
||||
import { MemoryStore } from "../../src/memory/store.js";
|
||||
import { ToolSessionContextStore } from "../../src/session/toolContextStore.js";
|
||||
import { RuntimeSessionStore } from "../../src/session/runtimeSessionStore.js";
|
||||
|
||||
const memoryStore = new MemoryStore();
|
||||
const toolContextStore = new ToolSessionContextStore();
|
||||
const runtimeSessionStore = new RuntimeSessionStore();
|
||||
const initializePromise = Promise.all([
|
||||
memoryStore.initialize(),
|
||||
toolContextStore.initialize(),
|
||||
runtimeSessionStore.initialize(),
|
||||
]);
|
||||
|
||||
export default tool({
|
||||
@@ -37,7 +37,7 @@ export default tool({
|
||||
},
|
||||
async execute(args, context) {
|
||||
await initializePromise;
|
||||
const sessionContext = await toolContextStore.read(context.sessionID);
|
||||
const sessionContext = await runtimeSessionStore.read(context.sessionID);
|
||||
if (!sessionContext) {
|
||||
throw new Error(`session context not found for ${context.sessionID}`);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ export default tool({
|
||||
if (args.action === "add") {
|
||||
const result = await memoryStore.upsert(scope, scopeKey, {
|
||||
content: args.content ?? "",
|
||||
sessionId: sessionContext.clientSessionId,
|
||||
sessionId: sessionContext.sessionId,
|
||||
source: "tool",
|
||||
traceId: sessionContext.traceId,
|
||||
});
|
||||
@@ -105,7 +105,7 @@ export default tool({
|
||||
if (args.action === "replace") {
|
||||
const result = await memoryStore.replace(scope, scopeKey, args.target_id ?? "", {
|
||||
content: args.content ?? "",
|
||||
sessionId: sessionContext.clientSessionId,
|
||||
sessionId: sessionContext.sessionId,
|
||||
source: "tool",
|
||||
traceId: sessionContext.traceId,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user