chore: include pre-built dist for github install

This commit is contained in:
Robin Mordasiewicz
2026-03-14 04:56:50 +00:00
parent a7f0a4cf46
commit bce8ff3a75
1011 changed files with 150081 additions and 0 deletions
@@ -0,0 +1,14 @@
import type { AutoCompactState } from "./types";
import type { Client } from "./client";
export declare function runAggressiveTruncationStrategy(params: {
sessionID: string;
autoCompactState: AutoCompactState;
client: Client;
directory: string;
truncateAttempt: number;
currentTokens: number;
maxTokens: number;
}): Promise<{
handled: boolean;
nextTruncateAttempt: number;
}>;
@@ -0,0 +1,29 @@
import type { PluginInput } from "@opencode-ai/plugin";
export type Client = PluginInput["client"] & {
session: {
promptAsync: (opts: {
path: {
id: string;
};
body: {
parts: Array<{
type: string;
text: string;
}>;
};
query: {
directory: string;
};
}) => Promise<unknown>;
};
tui: {
showToast: (opts: {
body: {
title: string;
message: string;
variant: string;
duration: number;
};
}) => Promise<unknown>;
};
};
@@ -0,0 +1,6 @@
import type { PluginInput } from "@opencode-ai/plugin";
import type { ParsedTokenLimitError } from "./types";
import type { ExperimentalConfig } from "../../config";
type OpencodeClient = PluginInput["client"];
export declare function attemptDeduplicationRecovery(sessionID: string, parsed: ParsedTokenLimitError, experimental: ExperimentalConfig | undefined, client?: OpencodeClient): Promise<void>;
export {};
@@ -0,0 +1,11 @@
import type { Client } from "./client";
export declare function fixEmptyMessagesWithSDK(params: {
sessionID: string;
client: Client;
placeholderText: string;
messageIndex?: number;
}): Promise<{
fixed: boolean;
fixedMessageIds: string[];
scannedEmptyCount: number;
}>;
@@ -0,0 +1,8 @@
import type { AutoCompactState } from "./types";
import type { Client } from "./client";
export declare function fixEmptyMessages(params: {
sessionID: string;
autoCompactState: AutoCompactState;
client: Client;
messageIndex?: number;
}): Promise<boolean>;
@@ -0,0 +1,6 @@
import type { AutoCompactState } from "./types";
import type { OhMyOpenCodeConfig } from "../../config";
import type { ExperimentalConfig } from "../../config";
import type { Client } from "./client";
export { getLastAssistant } from "./message-builder";
export declare function executeCompact(sessionID: string, msg: Record<string, unknown>, autoCompactState: AutoCompactState, client: Client, directory: string, pluginConfig: OhMyOpenCodeConfig, _experimental?: ExperimentalConfig): Promise<void>;
@@ -0,0 +1,8 @@
export { createAnthropicContextWindowLimitRecoveryHook } from "./recovery-hook";
export type { AnthropicContextWindowLimitRecoveryOptions } from "./recovery-hook";
export type { AutoCompactState, ParsedTokenLimitError, TruncateState } from "./types";
export { parseAnthropicTokenLimitError } from "./parser";
export { executeCompact, getLastAssistant } from "./executor";
export * from "./state";
export * from "./message-builder";
export * from "./recovery-strategy";
@@ -0,0 +1,7 @@
import type { PluginInput } from "@opencode-ai/plugin";
export declare const PLACEHOLDER_TEXT = "[user interrupted]";
type OpencodeClient = PluginInput["client"];
export declare function sanitizeEmptyMessagesBeforeSummarize(sessionID: string, client?: OpencodeClient): Promise<number>;
export declare function formatBytes(bytes: number): string;
export declare function getLastAssistant(sessionID: string, client: any, directory: string): Promise<Record<string, unknown> | null>;
export {};
@@ -0,0 +1,6 @@
import type { PluginInput } from "@opencode-ai/plugin";
import { getMessageDir } from "../../shared/opencode-message-dir";
export { getMessageDir };
type OpencodeClient = PluginInput["client"];
export declare function getMessageIdsFromSDK(client: OpencodeClient, sessionID: string): Promise<string[]>;
export declare function getMessageIds(sessionID: string): string[];
@@ -0,0 +1,2 @@
import type { ParsedTokenLimitError } from "./types";
export declare function parseAnthropicTokenLimitError(err: unknown): ParsedTokenLimitError | null;
@@ -0,0 +1,10 @@
import type { PluginInput } from "@opencode-ai/plugin";
import type { PruningState } from "./pruning-types";
type OpencodeClient = PluginInput["client"];
export interface DeduplicationConfig {
enabled: boolean;
protectedTools?: string[];
}
export declare function createToolSignature(toolName: string, input: unknown): string;
export declare function executeDeduplication(sessionID: string, state: PruningState, config: DeduplicationConfig, protectedTools: Set<string>, client?: OpencodeClient): Promise<number>;
export {};
@@ -0,0 +1,6 @@
import type { PluginInput } from "@opencode-ai/plugin";
type OpencodeClient = PluginInput["client"];
export declare function truncateToolOutputsByCallId(sessionID: string, callIds: Set<string>, client?: OpencodeClient): Promise<{
truncatedCount: number;
}>;
export {};
@@ -0,0 +1,36 @@
export interface ToolCallSignature {
toolName: string;
signature: string;
callID: string;
turn: number;
}
export interface FileOperation {
callID: string;
tool: string;
filePath: string;
turn: number;
}
export interface ErroredToolCall {
callID: string;
toolName: string;
turn: number;
errorAge: number;
}
export interface PruningResult {
itemsPruned: number;
totalTokensSaved: number;
strategies: {
deduplication: number;
supersedeWrites: number;
purgeErrors: number;
};
}
export interface PruningState {
toolIdsToPrune: Set<string>;
currentTurn: number;
fileOperations: Map<string, FileOperation[]>;
toolSignatures: Map<string, ToolCallSignature[]>;
erroredTools: Map<string, ErroredToolCall>;
}
export declare const CHARS_PER_TOKEN = 4;
export declare function estimateTokens(text: string): number;
@@ -0,0 +1,14 @@
import type { PluginInput } from "@opencode-ai/plugin";
import type { ExperimentalConfig, OhMyOpenCodeConfig } from "../../config";
export interface AnthropicContextWindowLimitRecoveryOptions {
experimental?: ExperimentalConfig;
pluginConfig: OhMyOpenCodeConfig;
}
export declare function createAnthropicContextWindowLimitRecoveryHook(ctx: PluginInput, options?: AnthropicContextWindowLimitRecoveryOptions): {
event: ({ event }: {
event: {
type: string;
properties?: unknown;
};
}) => Promise<void>;
};
@@ -0,0 +1,2 @@
export { runAggressiveTruncationStrategy } from "./aggressive-truncation-strategy";
export { runSummarizeRetryStrategy } from "./summarize-retry-strategy";
@@ -0,0 +1,6 @@
import type { AutoCompactState, RetryState, TruncateState } from "./types";
export declare function getOrCreateRetryState(autoCompactState: AutoCompactState, sessionID: string): RetryState;
export declare function getOrCreateTruncateState(autoCompactState: AutoCompactState, sessionID: string): TruncateState;
export declare function clearSessionState(autoCompactState: AutoCompactState, sessionID: string): void;
export declare function getEmptyContentAttempt(autoCompactState: AutoCompactState, sessionID: string): number;
export declare function incrementEmptyContentAttempt(autoCompactState: AutoCompactState, sessionID: string): number;
@@ -0,0 +1,3 @@
import { MESSAGE_STORAGE, PART_STORAGE } from "../../shared";
export { MESSAGE_STORAGE as MESSAGE_STORAGE_DIR, PART_STORAGE as PART_STORAGE_DIR };
export declare const TRUNCATION_MESSAGE = "[TOOL RESULT TRUNCATED - Context limit exceeded. Original output was too large and has been truncated to recover the session. Please re-run this tool if you need the full output.]";
@@ -0,0 +1,4 @@
export type { AggressiveTruncateResult, ToolResultInfo } from "./tool-part-types";
export { countTruncatedResults, findLargestToolResult, findToolResultsBySize, getTotalToolOutputSize, truncateToolResult, } from "./tool-result-storage";
export { countTruncatedResultsFromSDK, findToolResultsBySizeFromSDK, getTotalToolOutputSizeFromSDK, truncateToolResultAsync, } from "./tool-result-storage-sdk";
export { truncateUntilTargetTokens } from "./target-token-truncation";
@@ -0,0 +1,13 @@
import type { AutoCompactState } from "./types";
import type { OhMyOpenCodeConfig } from "../../config";
import type { Client } from "./client";
export declare function runSummarizeRetryStrategy(params: {
sessionID: string;
msg: Record<string, unknown>;
autoCompactState: AutoCompactState;
client: Client;
directory: string;
pluginConfig: OhMyOpenCodeConfig;
errorType?: string;
messageIndex?: number;
}): Promise<void>;
@@ -0,0 +1,5 @@
import type { PluginInput } from "@opencode-ai/plugin";
import type { AggressiveTruncateResult } from "./tool-part-types";
type OpencodeClient = PluginInput["client"];
export declare function truncateUntilTargetTokens(sessionID: string, currentTokens: number, maxTokens: number, targetRatio?: number, charsPerToken?: number, client?: OpencodeClient): Promise<AggressiveTruncateResult>;
export {};
@@ -0,0 +1,39 @@
export interface StoredToolPart {
id: string;
sessionID: string;
messageID: string;
type: "tool";
callID: string;
tool: string;
state: {
status: "pending" | "running" | "completed" | "error";
input: Record<string, unknown>;
output?: string;
error?: string;
time?: {
start: number;
end?: number;
compacted?: number;
};
};
truncated?: boolean;
originalSize?: number;
}
export interface ToolResultInfo {
partPath: string;
partId: string;
messageID: string;
toolName: string;
outputSize: number;
}
export interface AggressiveTruncateResult {
success: boolean;
sufficient: boolean;
truncatedCount: number;
totalBytesRemoved: number;
targetBytesToRemove: number;
truncatedTools: Array<{
toolName: string;
originalSize: number;
}>;
}
@@ -0,0 +1,29 @@
import type { PluginInput } from "@opencode-ai/plugin";
import type { ToolResultInfo } from "./tool-part-types";
type OpencodeClient = PluginInput["client"];
interface SDKToolPart {
id: string;
type: string;
callID?: string;
tool?: string;
state?: {
status?: string;
input?: Record<string, unknown>;
output?: string;
error?: string;
time?: {
start?: number;
end?: number;
compacted?: number;
};
};
}
export declare function findToolResultsBySizeFromSDK(client: OpencodeClient, sessionID: string): Promise<ToolResultInfo[]>;
export declare function truncateToolResultAsync(client: OpencodeClient, sessionID: string, messageID: string, partId: string, part: SDKToolPart): Promise<{
success: boolean;
toolName?: string;
originalSize?: number;
}>;
export declare function countTruncatedResultsFromSDK(client: OpencodeClient, sessionID: string): Promise<number>;
export declare function getTotalToolOutputSizeFromSDK(client: OpencodeClient, sessionID: string): Promise<number>;
export {};
@@ -0,0 +1,10 @@
import type { ToolResultInfo } from "./tool-part-types";
export declare function findToolResultsBySize(sessionID: string): ToolResultInfo[];
export declare function findLargestToolResult(sessionID: string): ToolResultInfo | null;
export declare function truncateToolResult(partPath: string): {
success: boolean;
toolName?: string;
originalSize?: number;
};
export declare function getTotalToolOutputSize(sessionID: string): number;
export declare function countTruncatedResults(sessionID: string): number;
@@ -0,0 +1,38 @@
export interface ParsedTokenLimitError {
currentTokens: number;
maxTokens: number;
requestId?: string;
errorType: string;
providerID?: string;
modelID?: string;
messageIndex?: number;
}
export interface RetryState {
attempt: number;
lastAttemptTime: number;
firstAttemptTime: number;
}
export interface TruncateState {
truncateAttempt: number;
lastTruncatedPartId?: string;
}
export interface AutoCompactState {
pendingCompact: Set<string>;
errorDataBySession: Map<string, ParsedTokenLimitError>;
retryStateBySession: Map<string, RetryState>;
truncateStateBySession: Map<string, TruncateState>;
emptyContentAttemptBySession: Map<string, number>;
compactionInProgress: Set<string>;
}
export declare const RETRY_CONFIG: {
readonly maxAttempts: 2;
readonly initialDelayMs: 2000;
readonly backoffFactor: 2;
readonly maxDelayMs: 30000;
};
export declare const TRUNCATE_CONFIG: {
readonly maxTruncateAttempts: 20;
readonly minOutputSizeToTruncate: 500;
readonly targetTokenRatio: 0.5;
readonly charsPerToken: 4;
};