fix(anthropic-auto-compact): use correct MESSAGE_STORAGE path for session messages
The DCP pruning modules were using a hardcoded path (~/.config/opencode/sessions) that doesn't exist. Sessions are actually stored at ~/.local/share/opencode/storage/message. All pruning modules now import MESSAGE_STORAGE from hook-message-injector, which uses the correct path via getOpenCodeStorageDir(). This fixes the issue where DCP would fail with 'message dir not found' when trying to recover from token limit errors. 🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
@@ -3,19 +3,13 @@ import { join } from "node:path"
|
|||||||
import type { PruningState, ToolCallSignature } from "./pruning-types"
|
import type { PruningState, ToolCallSignature } from "./pruning-types"
|
||||||
import { estimateTokens } from "./pruning-types"
|
import { estimateTokens } from "./pruning-types"
|
||||||
import { log } from "../../shared/logger"
|
import { log } from "../../shared/logger"
|
||||||
|
import { MESSAGE_STORAGE } from "../../features/hook-message-injector"
|
||||||
|
|
||||||
export interface DeduplicationConfig {
|
export interface DeduplicationConfig {
|
||||||
enabled: boolean
|
enabled: boolean
|
||||||
protectedTools?: string[]
|
protectedTools?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const MESSAGE_STORAGE = join(
|
|
||||||
process.env.HOME || process.env.USERPROFILE || "",
|
|
||||||
".config",
|
|
||||||
"opencode",
|
|
||||||
"sessions"
|
|
||||||
)
|
|
||||||
|
|
||||||
interface ToolPart {
|
interface ToolPart {
|
||||||
type: string
|
type: string
|
||||||
callID?: string
|
callID?: string
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { join } from "node:path"
|
|||||||
import type { PruningState, ErroredToolCall } from "./pruning-types"
|
import type { PruningState, ErroredToolCall } from "./pruning-types"
|
||||||
import { estimateTokens } from "./pruning-types"
|
import { estimateTokens } from "./pruning-types"
|
||||||
import { log } from "../../shared/logger"
|
import { log } from "../../shared/logger"
|
||||||
|
import { MESSAGE_STORAGE } from "../../features/hook-message-injector"
|
||||||
|
|
||||||
export interface PurgeErrorsConfig {
|
export interface PurgeErrorsConfig {
|
||||||
enabled: boolean
|
enabled: boolean
|
||||||
@@ -10,13 +11,6 @@ export interface PurgeErrorsConfig {
|
|||||||
protectedTools?: string[]
|
protectedTools?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const MESSAGE_STORAGE = join(
|
|
||||||
process.env.HOME || process.env.USERPROFILE || "",
|
|
||||||
".config",
|
|
||||||
"opencode",
|
|
||||||
"sessions"
|
|
||||||
)
|
|
||||||
|
|
||||||
interface ToolPart {
|
interface ToolPart {
|
||||||
type: string
|
type: string
|
||||||
callID?: string
|
callID?: string
|
||||||
|
|||||||
@@ -3,13 +3,7 @@ import { join } from "node:path"
|
|||||||
import type { PruningState } from "./pruning-types"
|
import type { PruningState } from "./pruning-types"
|
||||||
import { estimateTokens } from "./pruning-types"
|
import { estimateTokens } from "./pruning-types"
|
||||||
import { log } from "../../shared/logger"
|
import { log } from "../../shared/logger"
|
||||||
|
import { MESSAGE_STORAGE } from "../../features/hook-message-injector"
|
||||||
const MESSAGE_STORAGE = join(
|
|
||||||
process.env.HOME || process.env.USERPROFILE || "",
|
|
||||||
".config",
|
|
||||||
"opencode",
|
|
||||||
"sessions"
|
|
||||||
)
|
|
||||||
|
|
||||||
function getMessageDir(sessionID: string): string | null {
|
function getMessageDir(sessionID: string): string | null {
|
||||||
if (!existsSync(MESSAGE_STORAGE)) return null
|
if (!existsSync(MESSAGE_STORAGE)) return null
|
||||||
|
|||||||
@@ -3,19 +3,13 @@ import { join } from "node:path"
|
|||||||
import type { PruningState, FileOperation } from "./pruning-types"
|
import type { PruningState, FileOperation } from "./pruning-types"
|
||||||
import { estimateTokens } from "./pruning-types"
|
import { estimateTokens } from "./pruning-types"
|
||||||
import { log } from "../../shared/logger"
|
import { log } from "../../shared/logger"
|
||||||
|
import { MESSAGE_STORAGE } from "../../features/hook-message-injector"
|
||||||
|
|
||||||
export interface SupersedeWritesConfig {
|
export interface SupersedeWritesConfig {
|
||||||
enabled: boolean
|
enabled: boolean
|
||||||
aggressive: boolean
|
aggressive: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const MESSAGE_STORAGE = join(
|
|
||||||
process.env.HOME || process.env.USERPROFILE || "",
|
|
||||||
".config",
|
|
||||||
"opencode",
|
|
||||||
"sessions"
|
|
||||||
)
|
|
||||||
|
|
||||||
interface ToolPart {
|
interface ToolPart {
|
||||||
type: string
|
type: string
|
||||||
callID?: string
|
callID?: string
|
||||||
|
|||||||
Reference in New Issue
Block a user