rebrand better-clawd and ship initial npm-ready release
This commit is contained in:
83
src/services/compact/cachedMicrocompact.ts
Normal file
83
src/services/compact/cachedMicrocompact.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
export type CacheEditsBlock = {
|
||||
type: 'cache_edits'
|
||||
delete_tool_result_ids: string[]
|
||||
}
|
||||
|
||||
export type PinnedCacheEdits = {
|
||||
userMessageIndex: number
|
||||
block: CacheEditsBlock
|
||||
}
|
||||
|
||||
export type CachedMCState = {
|
||||
registeredTools: Set<string>
|
||||
deletedRefs: Set<string>
|
||||
toolOrder: string[]
|
||||
pinnedEdits: PinnedCacheEdits[]
|
||||
}
|
||||
|
||||
export function isCachedMicrocompactEnabled(): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
export function isModelSupportedForCacheEditing(_model: string): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
export function getCachedMCConfig() {
|
||||
return {
|
||||
triggerThreshold: 0,
|
||||
keepRecent: 0,
|
||||
supportedModels: [] as string[],
|
||||
}
|
||||
}
|
||||
|
||||
export function createCachedMCState(): CachedMCState {
|
||||
return {
|
||||
registeredTools: new Set(),
|
||||
deletedRefs: new Set(),
|
||||
toolOrder: [],
|
||||
pinnedEdits: [],
|
||||
}
|
||||
}
|
||||
|
||||
export function registerToolResult(
|
||||
state: CachedMCState,
|
||||
toolUseId: string,
|
||||
): void {
|
||||
if (state.registeredTools.has(toolUseId)) {
|
||||
return
|
||||
}
|
||||
state.registeredTools.add(toolUseId)
|
||||
state.toolOrder.push(toolUseId)
|
||||
}
|
||||
|
||||
export function registerToolMessage(
|
||||
_state: CachedMCState,
|
||||
_groupIds: string[],
|
||||
): void {}
|
||||
|
||||
export function getToolResultsToDelete(_state: CachedMCState): string[] {
|
||||
return []
|
||||
}
|
||||
|
||||
export function createCacheEditsBlock(
|
||||
_state: CachedMCState,
|
||||
toolIds: string[],
|
||||
): CacheEditsBlock | null {
|
||||
if (toolIds.length === 0) {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
type: 'cache_edits',
|
||||
delete_tool_result_ids: toolIds,
|
||||
}
|
||||
}
|
||||
|
||||
export function markToolsSentToAPI(_state: CachedMCState): void {}
|
||||
|
||||
export function resetCachedMCState(state: CachedMCState): void {
|
||||
state.registeredTools.clear()
|
||||
state.deletedRefs.clear()
|
||||
state.toolOrder.length = 0
|
||||
state.pinnedEdits.length = 0
|
||||
}
|
||||
@@ -748,8 +748,9 @@ export async function compactConversation(
|
||||
}
|
||||
} catch (error) {
|
||||
// Only show the error notification for manual /compact.
|
||||
// Auto-compact failures are retried on the next turn and the
|
||||
// notification is confusing when compaction eventually succeeds.
|
||||
// Auto-compact failures are retried silently until the session-level
|
||||
// circuit breaker trips, and a user-facing notification here would be
|
||||
// noisy for failures that recover on a later turn.
|
||||
if (!isAutoCompact) {
|
||||
addErrorNotificationIfNeeded(error, context)
|
||||
}
|
||||
|
||||
25
src/services/compact/snipCompact.ts
Normal file
25
src/services/compact/snipCompact.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { Message, SystemMessage } from '../../types/message.js'
|
||||
|
||||
export type SnipCompactResult = {
|
||||
messages: Message[]
|
||||
tokensFreed: number
|
||||
boundaryMessage?: SystemMessage
|
||||
}
|
||||
|
||||
export function isSnipRuntimeEnabled(): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
export function isSnipMarkerMessage(_message: Message): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
export function snipCompactIfNeeded(
|
||||
messages: Message[],
|
||||
_options?: { force?: boolean },
|
||||
): SnipCompactResult {
|
||||
return {
|
||||
messages,
|
||||
tokensFreed: 0,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user