feat(storage): gate JSON write operations on OpenCode beta, document degraded features
- Gate session-recovery writes: injectTextPart, prependThinkingPart, replaceEmptyTextParts, stripThinkingParts - Gate context-window-recovery writes: truncateToolResult - Add isSqliteBackend() checks with log warnings - Create beta-degraded-features.md documentation
This commit is contained in:
parent
e34fbd08a9
commit
49dafd3c91
@ -51,7 +51,7 @@ export function truncateToolResult(partPath: string): {
|
|||||||
originalSize?: number
|
originalSize?: number
|
||||||
} {
|
} {
|
||||||
if (isSqliteBackend()) {
|
if (isSqliteBackend()) {
|
||||||
log.warn("[context-window-recovery] Disabled on SQLite backend: truncateToolResult")
|
log("[context-window-recovery] Disabled on SQLite backend: truncateToolResult")
|
||||||
return { success: false }
|
return { success: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,8 +4,14 @@ import { PART_STORAGE } from "../constants"
|
|||||||
import type { StoredPart, StoredTextPart } from "../types"
|
import type { StoredPart, StoredTextPart } from "../types"
|
||||||
import { readMessages } from "./messages-reader"
|
import { readMessages } from "./messages-reader"
|
||||||
import { readParts } from "./parts-reader"
|
import { readParts } from "./parts-reader"
|
||||||
|
import { log, isSqliteBackend } from "../../../shared"
|
||||||
|
|
||||||
export function replaceEmptyTextParts(messageID: string, replacementText: string): boolean {
|
export function replaceEmptyTextParts(messageID: string, replacementText: string): boolean {
|
||||||
|
if (isSqliteBackend()) {
|
||||||
|
log("[session-recovery] Disabled on SQLite backend: replaceEmptyTextParts")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
const partDir = join(PART_STORAGE, messageID)
|
const partDir = join(PART_STORAGE, messageID)
|
||||||
if (!existsSync(partDir)) return false
|
if (!existsSync(partDir)) return false
|
||||||
|
|
||||||
|
|||||||
@ -3,8 +3,14 @@ import { join } from "node:path"
|
|||||||
import { PART_STORAGE } from "../constants"
|
import { PART_STORAGE } from "../constants"
|
||||||
import type { StoredTextPart } from "../types"
|
import type { StoredTextPart } from "../types"
|
||||||
import { generatePartId } from "./part-id"
|
import { generatePartId } from "./part-id"
|
||||||
|
import { log, isSqliteBackend } from "../../../shared"
|
||||||
|
|
||||||
export function injectTextPart(sessionID: string, messageID: string, text: string): boolean {
|
export function injectTextPart(sessionID: string, messageID: string, text: string): boolean {
|
||||||
|
if (isSqliteBackend()) {
|
||||||
|
log("[session-recovery] Disabled on SQLite backend: injectTextPart")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
const partDir = join(PART_STORAGE, messageID)
|
const partDir = join(PART_STORAGE, messageID)
|
||||||
|
|
||||||
if (!existsSync(partDir)) {
|
if (!existsSync(partDir)) {
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { join } from "node:path"
|
|||||||
import { PART_STORAGE, THINKING_TYPES } from "../constants"
|
import { PART_STORAGE, THINKING_TYPES } from "../constants"
|
||||||
import { readMessages } from "./messages-reader"
|
import { readMessages } from "./messages-reader"
|
||||||
import { readParts } from "./parts-reader"
|
import { readParts } from "./parts-reader"
|
||||||
|
import { log, isSqliteBackend } from "../../../shared"
|
||||||
|
|
||||||
function findLastThinkingContent(sessionID: string, beforeMessageID: string): string {
|
function findLastThinkingContent(sessionID: string, beforeMessageID: string): string {
|
||||||
const messages = readMessages(sessionID)
|
const messages = readMessages(sessionID)
|
||||||
@ -31,6 +32,11 @@ function findLastThinkingContent(sessionID: string, beforeMessageID: string): st
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function prependThinkingPart(sessionID: string, messageID: string): boolean {
|
export function prependThinkingPart(sessionID: string, messageID: string): boolean {
|
||||||
|
if (isSqliteBackend()) {
|
||||||
|
log("[session-recovery] Disabled on SQLite backend: prependThinkingPart")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
const partDir = join(PART_STORAGE, messageID)
|
const partDir = join(PART_STORAGE, messageID)
|
||||||
|
|
||||||
if (!existsSync(partDir)) {
|
if (!existsSync(partDir)) {
|
||||||
|
|||||||
@ -2,8 +2,14 @@ import { existsSync, readdirSync, readFileSync, unlinkSync } from "node:fs"
|
|||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
import { PART_STORAGE, THINKING_TYPES } from "../constants"
|
import { PART_STORAGE, THINKING_TYPES } from "../constants"
|
||||||
import type { StoredPart } from "../types"
|
import type { StoredPart } from "../types"
|
||||||
|
import { log, isSqliteBackend } from "../../../shared"
|
||||||
|
|
||||||
export function stripThinkingParts(messageID: string): boolean {
|
export function stripThinkingParts(messageID: string): boolean {
|
||||||
|
if (isSqliteBackend()) {
|
||||||
|
log("[session-recovery] Disabled on SQLite backend: stripThinkingParts")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
const partDir = join(PART_STORAGE, messageID)
|
const partDir = join(PART_STORAGE, messageID)
|
||||||
if (!existsSync(partDir)) return false
|
if (!existsSync(partDir)) return false
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user