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
+5
View File
@@ -0,0 +1,5 @@
export declare const AGENT_NAMES: string[];
export declare const agentPattern: RegExp;
export declare function detectAgentFromSession(sessionID: string): string | undefined;
export declare function normalizeAgentName(agent: string | undefined): string | undefined;
export declare function resolveAgentForSession(sessionID: string, eventAgent?: string): string | undefined;
+10
View File
@@ -0,0 +1,10 @@
import type { HookDeps } from "./types";
export declare function createAutoRetryHelpers(deps: HookDeps): {
abortSessionRequest: (sessionID: string, source: string) => Promise<void>;
clearSessionFallbackTimeout: (sessionID: string) => void;
scheduleSessionFallbackTimeout: (sessionID: string, resolvedAgent?: string) => void;
autoRetryWithFallback: (sessionID: string, newModel: string, resolvedAgent: string | undefined, source: string) => Promise<void>;
resolveAgentForSessionFromContext: (sessionID: string, eventAgent?: string) => Promise<string | undefined>;
cleanupStaleSessions: () => void;
};
export type AutoRetryHelpers = ReturnType<typeof createAutoRetryHelpers>;
+20
View File
@@ -0,0 +1,20 @@
import type { HookDeps } from "./types";
export declare function createChatMessageHandler(deps: HookDeps): (input: {
sessionID: string;
agent?: string;
model?: {
providerID: string;
modelID: string;
};
}, output: {
message: {
model?: {
providerID: string;
modelID: string;
};
};
parts?: Array<{
type: string;
text?: string;
}>;
}) => Promise<void>;
+19
View File
@@ -0,0 +1,19 @@
/**
* Runtime Fallback Hook - Constants
*
* Default values and configuration constants for the runtime fallback feature.
*/
import type { RuntimeFallbackConfig } from "../../config";
/**
* Default configuration values for runtime fallback
*/
export declare const DEFAULT_CONFIG: Required<RuntimeFallbackConfig>;
/**
* Error patterns that indicate rate limiting or temporary failures
* These are checked in addition to HTTP status codes
*/
export declare const RETRYABLE_ERROR_PATTERNS: RegExp[];
/**
* Hook name for identification and logging
*/
export declare const HOOK_NAME = "runtime-fallback";
+17
View File
@@ -0,0 +1,17 @@
export declare function getErrorMessage(error: unknown): string;
export declare function extractStatusCode(error: unknown, retryOnErrors?: number[]): number | undefined;
export declare function extractErrorName(error: unknown): string | undefined;
export declare function classifyErrorType(error: unknown): string | undefined;
export interface AutoRetrySignal {
signal: string;
}
export declare const AUTO_RETRY_PATTERNS: Array<(combined: string) => boolean>;
export declare function extractAutoRetrySignal(info: Record<string, unknown> | undefined): AutoRetrySignal | undefined;
export declare function containsErrorContent(parts: Array<{
type?: string;
text?: string;
}> | undefined): {
hasError: boolean;
errorMessage?: string;
};
export declare function isRetryableError(error: unknown, retryOnErrors: number[]): boolean;
+8
View File
@@ -0,0 +1,8 @@
import type { HookDeps } from "./types";
import type { AutoRetryHelpers } from "./auto-retry";
export declare function createEventHandler(deps: HookDeps, helpers: AutoRetryHelpers): ({ event }: {
event: {
type: string;
properties?: unknown;
};
}) => Promise<void>;
@@ -0,0 +1,10 @@
import type { OhMyOpenCodeConfig } from "../../config";
type ResolveFallbackBootstrapModelOptions = {
sessionID: string;
source: string;
eventModel?: string;
resolvedAgent?: string;
pluginConfig?: OhMyOpenCodeConfig;
};
export declare function resolveFallbackBootstrapModel(options: ResolveFallbackBootstrapModelOptions): string | undefined;
export {};
+2
View File
@@ -0,0 +1,2 @@
import type { OhMyOpenCodeConfig } from "../../config";
export declare function getFallbackModelsForSession(sessionID: string, agent: string | undefined, pluginConfig: OhMyOpenCodeConfig | undefined): string[];
@@ -0,0 +1,11 @@
import type { AutoRetryHelpers } from "./auto-retry";
import type { HookDeps, FallbackState } from "./types";
type DispatchFallbackRetryOptions = {
sessionID: string;
state: FallbackState;
fallbackModels: string[];
resolvedAgent?: string;
source: string;
};
export declare function dispatchFallbackRetry(deps: HookDeps, helpers: AutoRetryHelpers, options: DispatchFallbackRetryOptions): Promise<void>;
export {};
+6
View File
@@ -0,0 +1,6 @@
import type { FallbackState, FallbackResult } from "./types";
import type { RuntimeFallbackConfig } from "../../config";
export declare function createFallbackState(originalModel: string): FallbackState;
export declare function isModelInCooldown(model: string, state: FallbackState, cooldownSeconds: number): boolean;
export declare function findNextAvailableFallback(state: FallbackState, fallbackModels: string[], cooldownSeconds: number): string | undefined;
export declare function prepareFallback(sessionID: string, state: FallbackState, fallbackModels: string[], config: Required<RuntimeFallbackConfig>): FallbackResult;
+2
View File
@@ -0,0 +1,2 @@
import type { RuntimeFallbackHook, RuntimeFallbackOptions, RuntimeFallbackPluginInput } from "./types";
export declare function createRuntimeFallbackHook(ctx: RuntimeFallbackPluginInput, options?: RuntimeFallbackOptions): RuntimeFallbackHook;
+2
View File
@@ -0,0 +1,2 @@
export { createRuntimeFallbackHook } from "./hook";
export type { RuntimeFallbackHook, RuntimeFallbackOptions } from "./types";
@@ -0,0 +1,4 @@
export declare function getLastUserRetryParts(messagesResponse: unknown): Array<{
type: "text";
text: string;
}>;
@@ -0,0 +1,4 @@
import type { HookDeps } from "./types";
import type { AutoRetryHelpers } from "./auto-retry";
export { hasVisibleAssistantResponse } from "./visible-assistant-response";
export declare function createMessageUpdateHandler(deps: HookDeps, helpers: AutoRetryHelpers): (props: Record<string, unknown> | undefined) => Promise<void>;
+7
View File
@@ -0,0 +1,7 @@
export declare function buildRetryModelPayload(model: string): {
model: {
providerID: string;
modelID: string;
};
variant?: string;
} | undefined;
+9
View File
@@ -0,0 +1,9 @@
export type SessionMessagePart = {
type?: string;
text?: string;
};
export type SessionMessage = {
info?: Record<string, unknown>;
parts?: SessionMessagePart[];
};
export declare function extractSessionMessages(messagesResponse: unknown): SessionMessage[] | undefined;
@@ -0,0 +1,3 @@
import type { HookDeps } from "./types";
import type { AutoRetryHelpers } from "./auto-retry";
export declare function createSessionStatusHandler(deps: HookDeps, helpers: AutoRetryHelpers, sessionStatusRetryKeys: Map<string, string>): (props: Record<string, unknown> | undefined) => Promise<void>;
+113
View File
@@ -0,0 +1,113 @@
import type { RuntimeFallbackConfig, OhMyOpenCodeConfig } from "../../config";
export interface RuntimeFallbackInterval {
unref: () => void;
}
export type RuntimeFallbackTimeout = object | number;
export interface RuntimeFallbackPluginInput {
client: {
session: {
abort: (input: {
path: {
id: string;
};
}) => Promise<unknown>;
messages: (input: {
path: {
id: string;
};
query: {
directory: string;
};
}) => Promise<unknown>;
promptAsync: (input: {
path: {
id: string;
};
body: {
agent?: string;
model: {
providerID: string;
modelID: string;
};
parts: Array<{
type: "text";
text: string;
}>;
};
query: {
directory: string;
};
}) => Promise<unknown>;
};
tui: {
showToast: (input: {
body: {
title: string;
message: string;
variant: "success" | "error" | "info" | "warning";
duration: number;
};
}) => Promise<unknown>;
};
};
directory: string;
}
export interface FallbackState {
originalModel: string;
currentModel: string;
fallbackIndex: number;
failedModels: Map<string, number>;
attemptCount: number;
pendingFallbackModel?: string;
}
export interface FallbackResult {
success: boolean;
newModel?: string;
error?: string;
maxAttemptsReached?: boolean;
}
export interface RuntimeFallbackOptions {
config?: RuntimeFallbackConfig;
pluginConfig?: OhMyOpenCodeConfig;
session_timeout_ms?: number;
}
export interface RuntimeFallbackHook {
event: (input: {
event: {
type: string;
properties?: unknown;
};
}) => Promise<void>;
"chat.message"?: (input: {
sessionID: string;
agent?: string;
model?: {
providerID: string;
modelID: string;
};
}, output: {
message: {
model?: {
providerID: string;
modelID: string;
};
};
parts?: Array<{
type: string;
text?: string;
}>;
}) => Promise<void>;
dispose?: () => void;
}
export interface HookDeps {
ctx: RuntimeFallbackPluginInput;
config: Required<RuntimeFallbackConfig>;
options: RuntimeFallbackOptions | undefined;
pluginConfig: OhMyOpenCodeConfig | undefined;
sessionStates: Map<string, FallbackState>;
sessionLastAccess: Map<string, number>;
sessionRetryInFlight: Set<string>;
sessionAwaitingFallbackResult: Set<string>;
sessionFallbackTimeouts: Map<string, RuntimeFallbackTimeout>;
sessionStatusRetryKeys: Map<string, string>;
}
@@ -0,0 +1,3 @@
import type { HookDeps } from "./types";
import { extractAutoRetrySignal } from "./error-classifier";
export declare function hasVisibleAssistantResponse(extractAutoRetrySignalFn: typeof extractAutoRetrySignal): (ctx: HookDeps["ctx"], sessionID: string, _info: Record<string, unknown> | undefined) => Promise<boolean>;