fix(hooks/anthropic-context-window-limit-recovery): remove @ts-ignore comments and fix parameter types
Remove @ts-ignore and eslint-disable comments from executor.ts and recovery-hook.ts - Change client: any to client: Client with proper import - Rename experimental to _experimental for unused parameter - Remove @ts-ignore for ctx.client casts Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
41880f8ffb
commit
ac3a9fd272
@ -16,20 +16,15 @@ export async function executeCompact(
|
|||||||
sessionID: string,
|
sessionID: string,
|
||||||
msg: Record<string, unknown>,
|
msg: Record<string, unknown>,
|
||||||
autoCompactState: AutoCompactState,
|
autoCompactState: AutoCompactState,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
client: Client,
|
||||||
// @ts-ignore
|
|
||||||
pluginConfig: OhMyOpenCodeConfig,
|
|
||||||
// @ts-ignore
|
|
||||||
client: any,
|
|
||||||
// @ts-ignore
|
|
||||||
directory: string,
|
directory: string,
|
||||||
// @ts-ignore
|
pluginConfig: OhMyOpenCodeConfig,
|
||||||
experimental?: ExperimentalConfig
|
_experimental?: ExperimentalConfig
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
void experimental
|
void _experimental
|
||||||
|
|
||||||
if (autoCompactState.compactionInProgress.has(sessionID)) {
|
if (autoCompactState.compactionInProgress.has(sessionID)) {
|
||||||
await (client as Client).tui
|
await client.tui
|
||||||
.showToast({
|
.showToast({
|
||||||
body: {
|
body: {
|
||||||
title: "Compact In Progress",
|
title: "Compact In Progress",
|
||||||
@ -61,7 +56,7 @@ export async function executeCompact(
|
|||||||
const result = await runAggressiveTruncationStrategy({
|
const result = await runAggressiveTruncationStrategy({
|
||||||
sessionID,
|
sessionID,
|
||||||
autoCompactState,
|
autoCompactState,
|
||||||
client: client as Client,
|
client: client,
|
||||||
directory,
|
directory,
|
||||||
truncateAttempt: truncateState.truncateAttempt,
|
truncateAttempt: truncateState.truncateAttempt,
|
||||||
currentTokens: errorData.currentTokens,
|
currentTokens: errorData.currentTokens,
|
||||||
@ -76,13 +71,11 @@ export async function executeCompact(
|
|||||||
sessionID,
|
sessionID,
|
||||||
msg,
|
msg,
|
||||||
autoCompactState,
|
autoCompactState,
|
||||||
client: client as Client,
|
client: client,
|
||||||
directory,
|
directory,
|
||||||
// @ts-ignore
|
|
||||||
pluginConfig,
|
pluginConfig,
|
||||||
errorType: errorData?.errorType,
|
errorType: errorData?.errorType,
|
||||||
messageIndex: errorData?.messageIndex,
|
messageIndex: errorData?.messageIndex,
|
||||||
// @ts-ignore
|
|
||||||
})
|
})
|
||||||
} finally {
|
} finally {
|
||||||
autoCompactState.compactionInProgress.delete(sessionID);
|
autoCompactState.compactionInProgress.delete(sessionID);
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import type { PluginInput } from "@opencode-ai/plugin"
|
import type { PluginInput } from "@opencode-ai/plugin"
|
||||||
|
import type { Client } from "./client"
|
||||||
import type { AutoCompactState, ParsedTokenLimitError } from "./types"
|
import type { AutoCompactState, ParsedTokenLimitError } from "./types"
|
||||||
import type { ExperimentalConfig } from "../../config"
|
import type { ExperimentalConfig, OhMyOpenCodeConfig } from "../../config"
|
||||||
import { parseAnthropicTokenLimitError } from "./parser"
|
import { parseAnthropicTokenLimitError } from "./parser"
|
||||||
import { executeCompact, getLastAssistant } from "./executor"
|
import { executeCompact, getLastAssistant } from "./executor"
|
||||||
import { attemptDeduplicationRecovery } from "./deduplication-recovery"
|
import { attemptDeduplicationRecovery } from "./deduplication-recovery"
|
||||||
@ -8,6 +9,7 @@ import { log } from "../../shared/logger"
|
|||||||
|
|
||||||
export interface AnthropicContextWindowLimitRecoveryOptions {
|
export interface AnthropicContextWindowLimitRecoveryOptions {
|
||||||
experimental?: ExperimentalConfig
|
experimental?: ExperimentalConfig
|
||||||
|
pluginConfig: OhMyOpenCodeConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRecoveryState(): AutoCompactState {
|
function createRecoveryState(): AutoCompactState {
|
||||||
@ -28,6 +30,7 @@ export function createAnthropicContextWindowLimitRecoveryHook(
|
|||||||
) {
|
) {
|
||||||
const autoCompactState = createRecoveryState()
|
const autoCompactState = createRecoveryState()
|
||||||
const experimental = options?.experimental
|
const experimental = options?.experimental
|
||||||
|
const pluginConfig = options?.pluginConfig!
|
||||||
const pendingCompactionTimeoutBySession = new Map<string, ReturnType<typeof setTimeout>>()
|
const pendingCompactionTimeoutBySession = new Map<string, ReturnType<typeof setTimeout>>()
|
||||||
|
|
||||||
const eventHandler = async ({ event }: { event: { type: string; properties?: unknown } }) => {
|
const eventHandler = async ({ event }: { event: { type: string; properties?: unknown } }) => {
|
||||||
@ -89,9 +92,9 @@ export function createAnthropicContextWindowLimitRecoveryHook(
|
|||||||
sessionID,
|
sessionID,
|
||||||
{ providerID, modelID },
|
{ providerID, modelID },
|
||||||
autoCompactState,
|
autoCompactState,
|
||||||
// @ts-ignore
|
ctx.client as Client,
|
||||||
ctx.client,
|
|
||||||
ctx.directory,
|
ctx.directory,
|
||||||
|
pluginConfig,
|
||||||
experimental,
|
experimental,
|
||||||
)
|
)
|
||||||
}, 300)
|
}, 300)
|
||||||
@ -157,9 +160,9 @@ export function createAnthropicContextWindowLimitRecoveryHook(
|
|||||||
sessionID,
|
sessionID,
|
||||||
{ providerID, modelID },
|
{ providerID, modelID },
|
||||||
autoCompactState,
|
autoCompactState,
|
||||||
// @ts-ignore
|
ctx.client as Client,
|
||||||
ctx.client,
|
|
||||||
ctx.directory,
|
ctx.directory,
|
||||||
|
pluginConfig,
|
||||||
experimental,
|
experimental,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user