oh-my-opencode 3.7.4 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +206 -243
- package/README.ko.md +205 -244
- package/README.md +176 -174
- package/README.zh-cn.md +211 -255
- package/dist/agents/atlas/default.d.ts +1 -1
- package/dist/agents/atlas/gpt.d.ts +1 -1
- package/dist/agents/atlas/prompt-section-builder.d.ts +1 -1
- package/dist/agents/builtin-agents/environment-context.d.ts +5 -1
- package/dist/agents/builtin-agents/general-agents.d.ts +1 -0
- package/dist/agents/builtin-agents/hephaestus-agent.d.ts +1 -0
- package/dist/agents/builtin-agents/sisyphus-agent.d.ts +1 -0
- package/dist/agents/builtin-agents.d.ts +1 -1
- package/dist/agents/dynamic-agent-prompt-builder.d.ts +0 -5
- package/dist/agents/index.d.ts +2 -1
- package/dist/agents/prometheus/gpt.d.ts +24 -0
- package/dist/agents/prometheus/index.d.ts +3 -1
- package/dist/agents/prometheus/system-prompt.d.ts +12 -1
- package/dist/agents/types.d.ts +1 -0
- package/dist/cli/fallback-chain-resolution.d.ts +1 -1
- package/dist/cli/index.js +366 -118
- package/dist/cli/model-fallback-requirements.d.ts +3 -0
- package/dist/cli/model-fallback-types.d.ts +0 -5
- package/dist/cli/provider-model-id-transform.d.ts +1 -1
- package/dist/cli/run/timestamp-output.d.ts +5 -0
- package/dist/cli/run/types.d.ts +1 -0
- package/dist/config/index.d.ts +2 -2
- package/dist/config/schema/agent-overrides.d.ts +75 -60
- package/dist/config/schema/categories.d.ts +2 -0
- package/dist/config/schema/experimental.d.ts +2 -0
- package/dist/config/schema/fallback-models.d.ts +3 -0
- package/dist/config/schema/hooks.d.ts +3 -3
- package/dist/config/schema/oh-my-opencode-config.d.ts +87 -104
- package/dist/config/schema/ralph-loop.d.ts +4 -0
- package/dist/config/schema/runtime-fallback.d.ts +10 -0
- package/dist/config/schema.d.ts +2 -0
- package/dist/create-hooks.d.ts +7 -5
- package/dist/features/background-agent/manager.d.ts +3 -0
- package/dist/features/background-agent/types.d.ts +7 -0
- package/dist/features/builtin-commands/templates/ralph-loop.d.ts +1 -1
- package/dist/features/claude-code-session-state/state.d.ts +1 -0
- package/dist/features/task-toast-manager/manager.d.ts +5 -0
- package/dist/features/task-toast-manager/types.d.ts +2 -1
- package/dist/features/tmux-subagent/action-executor.d.ts +10 -3
- package/dist/features/tmux-subagent/grid-planning.d.ts +5 -3
- package/dist/features/tmux-subagent/manager.d.ts +12 -0
- package/dist/features/tmux-subagent/pane-split-availability.d.ts +0 -1
- package/dist/features/tmux-subagent/spawn-target-finder.d.ts +2 -2
- package/dist/features/tmux-subagent/tmux-grid-constants.d.ts +4 -0
- package/dist/features/tmux-subagent/types.d.ts +2 -0
- package/dist/hooks/hashline-edit-diff-enhancer/hook.d.ts +28 -0
- package/dist/hooks/hashline-edit-diff-enhancer/index.d.ts +1 -0
- package/dist/hooks/index.d.ts +4 -2
- package/dist/hooks/model-fallback/hook.d.ts +60 -0
- package/dist/hooks/no-hephaestus-non-gpt/hook.d.ts +16 -0
- package/dist/hooks/no-hephaestus-non-gpt/index.d.ts +1 -0
- package/dist/hooks/ralph-loop/command-arguments.d.ts +8 -0
- package/dist/hooks/ralph-loop/continuation-prompt-injector.d.ts +1 -0
- package/dist/hooks/ralph-loop/iteration-continuation.d.ts +12 -0
- package/dist/hooks/ralph-loop/loop-state-controller.d.ts +2 -0
- package/dist/hooks/ralph-loop/ralph-loop-event-handler.d.ts +1 -0
- package/dist/hooks/ralph-loop/ralph-loop-hook.d.ts +1 -0
- package/dist/hooks/ralph-loop/session-reset-strategy.d.ts +3 -0
- package/dist/hooks/ralph-loop/types.d.ts +1 -0
- package/dist/hooks/runtime-fallback/agent-resolver.d.ts +5 -0
- package/dist/hooks/runtime-fallback/auto-retry.d.ts +10 -0
- package/dist/hooks/runtime-fallback/chat-message-handler.d.ts +20 -0
- package/dist/hooks/runtime-fallback/constants.d.ts +19 -0
- package/dist/hooks/runtime-fallback/error-classifier.d.ts +17 -0
- package/dist/hooks/runtime-fallback/event-handler.d.ts +8 -0
- package/dist/hooks/runtime-fallback/fallback-models.d.ts +2 -0
- package/dist/hooks/runtime-fallback/fallback-state.d.ts +6 -0
- package/dist/hooks/runtime-fallback/hook.d.ts +3 -0
- package/dist/hooks/runtime-fallback/index.d.ts +2 -0
- package/dist/hooks/runtime-fallback/message-update-handler.d.ts +5 -0
- package/dist/hooks/runtime-fallback/types.d.ts +59 -0
- package/dist/hooks/session-recovery/detect-error-type.d.ts +2 -1
- package/dist/hooks/session-recovery/recover-unavailable-tool.d.ts +5 -0
- package/dist/hooks/todo-continuation-enforcer/continuation-injection.d.ts +1 -0
- package/dist/hooks/todo-continuation-enforcer/countdown.d.ts +1 -0
- package/dist/hooks/write-existing-file-guard/hook.d.ts +1 -0
- package/dist/index.js +6179 -2820
- package/dist/oh-my-opencode.schema.json +3681 -0
- package/dist/plugin/chat-headers.d.ts +4 -0
- package/dist/plugin/chat-message.d.ts +9 -8
- package/dist/plugin/chat-params.d.ts +2 -3
- package/dist/plugin/event.d.ts +2 -6
- package/dist/plugin/hooks/create-core-hooks.d.ts +7 -5
- package/dist/plugin/hooks/create-session-hooks.d.ts +6 -6
- package/dist/plugin/hooks/create-tool-guard-hooks.d.ts +2 -1
- package/dist/plugin/hooks/create-transform-hooks.d.ts +1 -1
- package/dist/plugin/system-transform.d.ts +5 -0
- package/dist/plugin/types.d.ts +7 -1
- package/dist/plugin/ultrawork-db-model-override.d.ts +11 -0
- package/dist/plugin/ultrawork-model-override.d.ts +37 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/internal-initiator-marker.d.ts +5 -0
- package/dist/shared/model-error-classifier.d.ts +31 -0
- package/dist/shared/model-resolution-pipeline.d.ts +1 -0
- package/dist/shared/model-resolver.d.ts +6 -0
- package/dist/shared/provider-model-id-transform.d.ts +1 -0
- package/dist/shared/session-category-registry.d.ts +32 -0
- package/dist/shared/session-model-state.d.ts +7 -0
- package/dist/shared/tmux/tmux-utils/layout.d.ts +17 -2
- package/dist/tools/delegate-task/background-task.d.ts +2 -1
- package/dist/tools/delegate-task/category-resolver.d.ts +2 -0
- package/dist/tools/delegate-task/skill-resolver.d.ts +1 -0
- package/dist/tools/delegate-task/subagent-resolver.d.ts +2 -0
- package/dist/tools/delegate-task/sync-task.d.ts +1 -1
- package/dist/tools/hashline-edit/constants.d.ts +5 -2
- package/dist/tools/hashline-edit/diff-utils.d.ts +6 -0
- package/dist/tools/hashline-edit/edit-operations.d.ts +4 -4
- package/dist/tools/hashline-edit/hash-computation.d.ts +1 -1
- package/dist/tools/hashline-edit/index.d.ts +1 -1
- package/dist/tools/hashline-edit/types.d.ts +4 -4
- package/dist/tools/hashline-edit/validation.d.ts +1 -0
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/skill/constants.d.ts +2 -2
- package/dist/tools/skill/types.d.ts +4 -0
- package/dist/tools/slashcommand/index.d.ts +1 -1
- package/dist/tools/slashcommand/types.d.ts +1 -7
- package/package.json +10 -10
- package/dist/hooks/ultrawork-model-override/hook.d.ts +0 -6
- package/dist/hooks/ultrawork-model-override/index.d.ts +0 -1
- package/dist/tools/slashcommand/skill-command-converter.d.ts +0 -3
- package/dist/tools/slashcommand/slashcommand-description.d.ts +0 -3
- package/dist/tools/slashcommand/slashcommand-tool.d.ts +0 -4
- package/dist/tools/slashcommand/tools.d.ts +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TmuxPaneInfo } from "./types";
|
|
1
|
+
import type { CapacityConfig, TmuxPaneInfo } from "./types";
|
|
2
2
|
export interface GridCapacity {
|
|
3
3
|
cols: number;
|
|
4
4
|
rows: number;
|
|
@@ -14,6 +14,8 @@ export interface GridPlan {
|
|
|
14
14
|
slotWidth: number;
|
|
15
15
|
slotHeight: number;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
export declare function
|
|
17
|
+
type CapacityOptions = CapacityConfig | number | undefined;
|
|
18
|
+
export declare function calculateCapacity(windowWidth: number, windowHeight: number, options?: CapacityOptions, mainPaneWidth?: number): GridCapacity;
|
|
19
|
+
export declare function computeGridPlan(windowWidth: number, windowHeight: number, paneCount: number, options?: CapacityOptions, mainPaneWidth?: number): GridPlan;
|
|
19
20
|
export declare function mapPaneToSlot(pane: TmuxPaneInfo, plan: GridPlan, mainPaneWidth: number): GridSlot;
|
|
21
|
+
export {};
|
|
@@ -33,14 +33,26 @@ export declare class TmuxSessionManager {
|
|
|
33
33
|
private sourcePaneId;
|
|
34
34
|
private sessions;
|
|
35
35
|
private pendingSessions;
|
|
36
|
+
private spawnQueue;
|
|
37
|
+
private deferredSessions;
|
|
38
|
+
private deferredQueue;
|
|
39
|
+
private deferredAttachInterval?;
|
|
40
|
+
private deferredAttachTickScheduled;
|
|
41
|
+
private nullStateCount;
|
|
36
42
|
private deps;
|
|
37
43
|
private pollingManager;
|
|
38
44
|
constructor(ctx: PluginInput, tmuxConfig: TmuxConfig, deps?: TmuxUtilDeps);
|
|
39
45
|
private isEnabled;
|
|
40
46
|
private getCapacityConfig;
|
|
41
47
|
private getSessionMappings;
|
|
48
|
+
private enqueueDeferredSession;
|
|
49
|
+
private removeDeferredSession;
|
|
50
|
+
private startDeferredAttachLoop;
|
|
51
|
+
private stopDeferredAttachLoop;
|
|
52
|
+
private tryAttachDeferredSession;
|
|
42
53
|
private waitForSessionReady;
|
|
43
54
|
onSessionCreated(event: SessionCreatedEvent): Promise<void>;
|
|
55
|
+
private enqueueSpawn;
|
|
44
56
|
onSessionDeleted(event: {
|
|
45
57
|
sessionID: string;
|
|
46
58
|
}): Promise<void>;
|
|
@@ -5,5 +5,4 @@ export declare function isSplittableAtCount(agentAreaWidth: number, paneCount: n
|
|
|
5
5
|
export declare function findMinimalEvictions(agentAreaWidth: number, currentCount: number, minPaneWidth?: number): number | null;
|
|
6
6
|
export declare function canSplitPane(pane: TmuxPaneInfo, direction: SplitDirection, minPaneWidth?: number): boolean;
|
|
7
7
|
export declare function canSplitPaneAnyDirection(pane: TmuxPaneInfo, minPaneWidth?: number): boolean;
|
|
8
|
-
export declare function canSplitPaneAnyDirectionWithMinWidth(pane: TmuxPaneInfo, minPaneWidth?: number): boolean;
|
|
9
8
|
export declare function getBestSplitDirection(pane: TmuxPaneInfo, minPaneWidth?: number): SplitDirection | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { SplitDirection, WindowState } from "./types";
|
|
1
|
+
import type { CapacityConfig, SplitDirection, WindowState } from "./types";
|
|
2
2
|
export interface SpawnTarget {
|
|
3
3
|
targetPaneId: string;
|
|
4
4
|
splitDirection: SplitDirection;
|
|
5
5
|
}
|
|
6
|
-
export declare function findSpawnTarget(state: WindowState,
|
|
6
|
+
export declare function findSpawnTarget(state: WindowState, config: CapacityConfig): SpawnTarget | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CapacityConfig } from "./types";
|
|
1
2
|
export declare const MAIN_PANE_RATIO = 0.5;
|
|
2
3
|
export declare const MAX_COLS = 2;
|
|
3
4
|
export declare const MAX_ROWS = 3;
|
|
@@ -5,3 +6,6 @@ export declare const MAX_GRID_SIZE = 4;
|
|
|
5
6
|
export declare const DIVIDER_SIZE = 1;
|
|
6
7
|
export declare const MIN_SPLIT_WIDTH: number;
|
|
7
8
|
export declare const MIN_SPLIT_HEIGHT: number;
|
|
9
|
+
export declare function getMainPaneSizePercent(config?: CapacityConfig): number;
|
|
10
|
+
export declare function computeMainPaneWidth(windowWidth: number, config?: CapacityConfig): number;
|
|
11
|
+
export declare function computeAgentAreaWidth(windowWidth: number, config?: CapacityConfig): number;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface HashlineEditDiffEnhancerConfig {
|
|
2
|
+
hashline_edit?: {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
type BeforeInput = {
|
|
7
|
+
tool: string;
|
|
8
|
+
sessionID: string;
|
|
9
|
+
callID: string;
|
|
10
|
+
};
|
|
11
|
+
type BeforeOutput = {
|
|
12
|
+
args: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
type AfterInput = {
|
|
15
|
+
tool: string;
|
|
16
|
+
sessionID: string;
|
|
17
|
+
callID: string;
|
|
18
|
+
};
|
|
19
|
+
type AfterOutput = {
|
|
20
|
+
title: string;
|
|
21
|
+
output: string;
|
|
22
|
+
metadata: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
export declare function createHashlineEditDiffEnhancerHook(config: HashlineEditDiffEnhancerConfig): {
|
|
25
|
+
"tool.execute.before": (input: BeforeInput, output: BeforeOutput) => Promise<void>;
|
|
26
|
+
"tool.execute.after": (input: AfterInput, output: AfterOutput) => Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createHashlineEditDiffEnhancerHook } from "./hook";
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export { createDirectoryReadmeInjectorHook } from "./directory-readme-injector";
|
|
|
13
13
|
export { createEmptyTaskResponseDetectorHook } from "./empty-task-response-detector";
|
|
14
14
|
export { createAnthropicContextWindowLimitRecoveryHook, type AnthropicContextWindowLimitRecoveryOptions } from "./anthropic-context-window-limit-recovery";
|
|
15
15
|
export { createThinkModeHook } from "./think-mode";
|
|
16
|
+
export { createModelFallbackHook, setPendingModelFallback, clearPendingModelFallback, type ModelFallbackState } from "./model-fallback/hook";
|
|
16
17
|
export { createClaudeCodeHooksHook } from "./claude-code-hooks";
|
|
17
18
|
export { createRulesInjectorHook } from "./rules-injector";
|
|
18
19
|
export { createBackgroundNotificationHook } from "./background-notification";
|
|
@@ -25,9 +26,9 @@ export { createThinkingBlockValidatorHook } from "./thinking-block-validator";
|
|
|
25
26
|
export { createCategorySkillReminderHook } from "./category-skill-reminder";
|
|
26
27
|
export { createRalphLoopHook, type RalphLoopHook } from "./ralph-loop";
|
|
27
28
|
export { createNoSisyphusGptHook } from "./no-sisyphus-gpt";
|
|
29
|
+
export { createNoHephaestusNonGptHook } from "./no-hephaestus-non-gpt";
|
|
28
30
|
export { createAutoSlashCommandHook } from "./auto-slash-command";
|
|
29
31
|
export { createEditErrorRecoveryHook } from "./edit-error-recovery";
|
|
30
|
-
export { createJsonErrorRecoveryHook } from "./json-error-recovery";
|
|
31
32
|
export { createPrometheusMdOnlyHook } from "./prometheus-md-only";
|
|
32
33
|
export { createSisyphusJuniorNotepadHook } from "./sisyphus-junior-notepad";
|
|
33
34
|
export { createTaskResumeInfoHook } from "./task-resume-info";
|
|
@@ -41,6 +42,7 @@ export { createCompactionTodoPreserverHook } from "./compaction-todo-preserver";
|
|
|
41
42
|
export { createUnstableAgentBabysitterHook } from "./unstable-agent-babysitter";
|
|
42
43
|
export { createPreemptiveCompactionHook } from "./preemptive-compaction";
|
|
43
44
|
export { createTasksTodowriteDisablerHook } from "./tasks-todowrite-disabler";
|
|
45
|
+
export { createRuntimeFallbackHook, type RuntimeFallbackHook, type RuntimeFallbackOptions } from "./runtime-fallback";
|
|
44
46
|
export { createWriteExistingFileGuardHook } from "./write-existing-file-guard";
|
|
45
47
|
export { createHashlineReadEnhancerHook } from "./hashline-read-enhancer";
|
|
46
|
-
export {
|
|
48
|
+
export { createJsonErrorRecoveryHook, JSON_ERROR_TOOL_EXCLUDE_LIST, JSON_ERROR_PATTERNS, JSON_ERROR_REMINDER } from "./json-error-recovery";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { FallbackEntry } from "../../shared/model-requirements";
|
|
2
|
+
import type { ChatMessageInput, ChatMessageHandlerOutput } from "../../plugin/chat-message";
|
|
3
|
+
type FallbackToast = (input: {
|
|
4
|
+
title: string;
|
|
5
|
+
message: string;
|
|
6
|
+
variant?: "info" | "success" | "warning" | "error";
|
|
7
|
+
duration?: number;
|
|
8
|
+
}) => void | Promise<void>;
|
|
9
|
+
type FallbackCallback = (input: {
|
|
10
|
+
sessionID: string;
|
|
11
|
+
providerID: string;
|
|
12
|
+
modelID: string;
|
|
13
|
+
variant?: string;
|
|
14
|
+
}) => void | Promise<void>;
|
|
15
|
+
export type ModelFallbackState = {
|
|
16
|
+
providerID: string;
|
|
17
|
+
modelID: string;
|
|
18
|
+
fallbackChain: FallbackEntry[];
|
|
19
|
+
attemptCount: number;
|
|
20
|
+
pending: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare function setSessionFallbackChain(sessionID: string, fallbackChain: FallbackEntry[] | undefined): void;
|
|
23
|
+
export declare function clearSessionFallbackChain(sessionID: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Sets a pending model fallback for a session.
|
|
26
|
+
* Called when a model error is detected in session.error handler.
|
|
27
|
+
*/
|
|
28
|
+
export declare function setPendingModelFallback(sessionID: string, agentName: string, currentProviderID: string, currentModelID: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the next fallback model for a session.
|
|
31
|
+
* Increments attemptCount each time called.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getNextFallback(sessionID: string): {
|
|
34
|
+
providerID: string;
|
|
35
|
+
modelID: string;
|
|
36
|
+
variant?: string;
|
|
37
|
+
} | null;
|
|
38
|
+
/**
|
|
39
|
+
* Clears the pending fallback for a session.
|
|
40
|
+
* Called after fallback is successfully applied.
|
|
41
|
+
*/
|
|
42
|
+
export declare function clearPendingModelFallback(sessionID: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if there's a pending fallback for a session.
|
|
45
|
+
*/
|
|
46
|
+
export declare function hasPendingModelFallback(sessionID: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Gets the current fallback state for a session (for debugging).
|
|
49
|
+
*/
|
|
50
|
+
export declare function getFallbackState(sessionID: string): ModelFallbackState | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a chat.message hook that applies model fallbacks when pending.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createModelFallbackHook(args?: {
|
|
55
|
+
toast?: FallbackToast;
|
|
56
|
+
onApplied?: FallbackCallback;
|
|
57
|
+
}): {
|
|
58
|
+
"chat.message": (input: ChatMessageInput, output: ChatMessageHandlerOutput) => Promise<void>;
|
|
59
|
+
};
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
export declare function createNoHephaestusNonGptHook(ctx: PluginInput): {
|
|
3
|
+
"chat.message": (input: {
|
|
4
|
+
sessionID: string;
|
|
5
|
+
agent?: string;
|
|
6
|
+
model?: {
|
|
7
|
+
providerID: string;
|
|
8
|
+
modelID: string;
|
|
9
|
+
};
|
|
10
|
+
}, output?: {
|
|
11
|
+
message?: {
|
|
12
|
+
agent?: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createNoHephaestusNonGptHook } from "./hook";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type RalphLoopStrategy = "reset" | "continue";
|
|
2
|
+
export type ParsedRalphLoopArguments = {
|
|
3
|
+
prompt: string;
|
|
4
|
+
maxIterations?: number;
|
|
5
|
+
completionPromise?: string;
|
|
6
|
+
strategy?: RalphLoopStrategy;
|
|
7
|
+
};
|
|
8
|
+
export declare function parseRalphLoopArguments(rawArguments: string): ParsedRalphLoopArguments;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
import type { RalphLoopState } from "./types";
|
|
3
|
+
type ContinuationOptions = {
|
|
4
|
+
directory: string;
|
|
5
|
+
apiTimeoutMs: number;
|
|
6
|
+
previousSessionID: string;
|
|
7
|
+
loopState: {
|
|
8
|
+
setSessionID: (sessionID: string) => RalphLoopState | null;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare function continueIteration(ctx: PluginInput, state: RalphLoopState, options: ContinuationOptions): Promise<void>;
|
|
12
|
+
export {};
|
|
@@ -8,9 +8,11 @@ export declare function createLoopStateController(options: {
|
|
|
8
8
|
maxIterations?: number;
|
|
9
9
|
completionPromise?: string;
|
|
10
10
|
ultrawork?: boolean;
|
|
11
|
+
strategy?: "reset" | "continue";
|
|
11
12
|
}): boolean;
|
|
12
13
|
cancelLoop(sessionID: string): boolean;
|
|
13
14
|
getState(): RalphLoopState | null;
|
|
14
15
|
clear(): boolean;
|
|
15
16
|
incrementIteration(): RalphLoopState | null;
|
|
17
|
+
setSessionID(sessionID: string): RalphLoopState | null;
|
|
16
18
|
};
|
|
@@ -9,6 +9,7 @@ type LoopStateController = {
|
|
|
9
9
|
getState: () => RalphLoopState | null;
|
|
10
10
|
clear: () => boolean;
|
|
11
11
|
incrementIteration: () => RalphLoopState | null;
|
|
12
|
+
setSessionID: (sessionID: string) => RalphLoopState | null;
|
|
12
13
|
};
|
|
13
14
|
type RalphLoopEventHandlerOptions = {
|
|
14
15
|
directory: string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
export declare function createIterationSession(ctx: PluginInput, parentSessionID: string, directory: string): Promise<string | null>;
|
|
3
|
+
export declare function selectSessionInTui(client: PluginInput["client"], sessionID: string): Promise<boolean>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const AGENT_NAMES: string[];
|
|
2
|
+
export declare const agentPattern: RegExp;
|
|
3
|
+
export declare function detectAgentFromSession(sessionID: string): string | undefined;
|
|
4
|
+
export declare function normalizeAgentName(agent: string | undefined): string | undefined;
|
|
5
|
+
export declare function resolveAgentForSession(sessionID: string, eventAgent?: string): string | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HookDeps } from "./types";
|
|
2
|
+
export declare function createAutoRetryHelpers(deps: HookDeps): {
|
|
3
|
+
abortSessionRequest: (sessionID: string, source: string) => Promise<void>;
|
|
4
|
+
clearSessionFallbackTimeout: (sessionID: string) => void;
|
|
5
|
+
scheduleSessionFallbackTimeout: (sessionID: string, resolvedAgent?: string) => void;
|
|
6
|
+
autoRetryWithFallback: (sessionID: string, newModel: string, resolvedAgent: string | undefined, source: string) => Promise<void>;
|
|
7
|
+
resolveAgentForSessionFromContext: (sessionID: string, eventAgent?: string) => Promise<string | undefined>;
|
|
8
|
+
cleanupStaleSessions: () => void;
|
|
9
|
+
};
|
|
10
|
+
export type AutoRetryHelpers = ReturnType<typeof createAutoRetryHelpers>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { HookDeps } from "./types";
|
|
2
|
+
export declare function createChatMessageHandler(deps: HookDeps): (input: {
|
|
3
|
+
sessionID: string;
|
|
4
|
+
agent?: string;
|
|
5
|
+
model?: {
|
|
6
|
+
providerID: string;
|
|
7
|
+
modelID: string;
|
|
8
|
+
};
|
|
9
|
+
}, output: {
|
|
10
|
+
message: {
|
|
11
|
+
model?: {
|
|
12
|
+
providerID: string;
|
|
13
|
+
modelID: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
parts?: Array<{
|
|
17
|
+
type: string;
|
|
18
|
+
text?: string;
|
|
19
|
+
}>;
|
|
20
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Fallback Hook - Constants
|
|
3
|
+
*
|
|
4
|
+
* Default values and configuration constants for the runtime fallback feature.
|
|
5
|
+
*/
|
|
6
|
+
import type { RuntimeFallbackConfig } from "../../config";
|
|
7
|
+
/**
|
|
8
|
+
* Default configuration values for runtime fallback
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_CONFIG: Required<RuntimeFallbackConfig>;
|
|
11
|
+
/**
|
|
12
|
+
* Error patterns that indicate rate limiting or temporary failures
|
|
13
|
+
* These are checked in addition to HTTP status codes
|
|
14
|
+
*/
|
|
15
|
+
export declare const RETRYABLE_ERROR_PATTERNS: RegExp[];
|
|
16
|
+
/**
|
|
17
|
+
* Hook name for identification and logging
|
|
18
|
+
*/
|
|
19
|
+
export declare const HOOK_NAME = "runtime-fallback";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function getErrorMessage(error: unknown): string;
|
|
2
|
+
export declare function extractStatusCode(error: unknown, retryOnErrors?: number[]): number | undefined;
|
|
3
|
+
export declare function extractErrorName(error: unknown): string | undefined;
|
|
4
|
+
export declare function classifyErrorType(error: unknown): string | undefined;
|
|
5
|
+
export interface AutoRetrySignal {
|
|
6
|
+
signal: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const AUTO_RETRY_PATTERNS: Array<(combined: string) => boolean>;
|
|
9
|
+
export declare function extractAutoRetrySignal(info: Record<string, unknown> | undefined): AutoRetrySignal | undefined;
|
|
10
|
+
export declare function containsErrorContent(parts: Array<{
|
|
11
|
+
type?: string;
|
|
12
|
+
text?: string;
|
|
13
|
+
}> | undefined): {
|
|
14
|
+
hasError: boolean;
|
|
15
|
+
errorMessage?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function isRetryableError(error: unknown, retryOnErrors: number[]): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HookDeps } from "./types";
|
|
2
|
+
import type { AutoRetryHelpers } from "./auto-retry";
|
|
3
|
+
export declare function createEventHandler(deps: HookDeps, helpers: AutoRetryHelpers): ({ event }: {
|
|
4
|
+
event: {
|
|
5
|
+
type: string;
|
|
6
|
+
properties?: unknown;
|
|
7
|
+
};
|
|
8
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FallbackState, FallbackResult } from "./types";
|
|
2
|
+
import type { RuntimeFallbackConfig } from "../../config";
|
|
3
|
+
export declare function createFallbackState(originalModel: string): FallbackState;
|
|
4
|
+
export declare function isModelInCooldown(model: string, state: FallbackState, cooldownSeconds: number): boolean;
|
|
5
|
+
export declare function findNextAvailableFallback(state: FallbackState, fallbackModels: string[], cooldownSeconds: number): string | undefined;
|
|
6
|
+
export declare function prepareFallback(sessionID: string, state: FallbackState, fallbackModels: string[], config: Required<RuntimeFallbackConfig>): FallbackResult;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { HookDeps } from "./types";
|
|
2
|
+
import type { AutoRetryHelpers } from "./auto-retry";
|
|
3
|
+
import { extractAutoRetrySignal } from "./error-classifier";
|
|
4
|
+
export declare function hasVisibleAssistantResponse(extractAutoRetrySignalFn: typeof extractAutoRetrySignal): (ctx: HookDeps["ctx"], sessionID: string, _info: Record<string, unknown> | undefined) => Promise<boolean>;
|
|
5
|
+
export declare function createMessageUpdateHandler(deps: HookDeps, helpers: AutoRetryHelpers): (props: Record<string, unknown> | undefined) => Promise<void>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
import type { RuntimeFallbackConfig, OhMyOpenCodeConfig } from "../../config";
|
|
3
|
+
export interface FallbackState {
|
|
4
|
+
originalModel: string;
|
|
5
|
+
currentModel: string;
|
|
6
|
+
fallbackIndex: number;
|
|
7
|
+
failedModels: Map<string, number>;
|
|
8
|
+
attemptCount: number;
|
|
9
|
+
pendingFallbackModel?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface FallbackResult {
|
|
12
|
+
success: boolean;
|
|
13
|
+
newModel?: string;
|
|
14
|
+
error?: string;
|
|
15
|
+
maxAttemptsReached?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface RuntimeFallbackOptions {
|
|
18
|
+
config?: RuntimeFallbackConfig;
|
|
19
|
+
pluginConfig?: OhMyOpenCodeConfig;
|
|
20
|
+
session_timeout_ms?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface RuntimeFallbackHook {
|
|
23
|
+
event: (input: {
|
|
24
|
+
event: {
|
|
25
|
+
type: string;
|
|
26
|
+
properties?: unknown;
|
|
27
|
+
};
|
|
28
|
+
}) => Promise<void>;
|
|
29
|
+
"chat.message"?: (input: {
|
|
30
|
+
sessionID: string;
|
|
31
|
+
agent?: string;
|
|
32
|
+
model?: {
|
|
33
|
+
providerID: string;
|
|
34
|
+
modelID: string;
|
|
35
|
+
};
|
|
36
|
+
}, output: {
|
|
37
|
+
message: {
|
|
38
|
+
model?: {
|
|
39
|
+
providerID: string;
|
|
40
|
+
modelID: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
parts?: Array<{
|
|
44
|
+
type: string;
|
|
45
|
+
text?: string;
|
|
46
|
+
}>;
|
|
47
|
+
}) => Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
export interface HookDeps {
|
|
50
|
+
ctx: PluginInput;
|
|
51
|
+
config: Required<RuntimeFallbackConfig>;
|
|
52
|
+
options: RuntimeFallbackOptions | undefined;
|
|
53
|
+
pluginConfig: OhMyOpenCodeConfig | undefined;
|
|
54
|
+
sessionStates: Map<string, FallbackState>;
|
|
55
|
+
sessionLastAccess: Map<string, number>;
|
|
56
|
+
sessionRetryInFlight: Set<string>;
|
|
57
|
+
sessionAwaitingFallbackResult: Set<string>;
|
|
58
|
+
sessionFallbackTimeouts: Map<string, ReturnType<typeof setTimeout>>;
|
|
59
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export type RecoveryErrorType = "tool_result_missing" | "thinking_block_order" | "thinking_disabled_violation" | "assistant_prefill_unsupported" | null;
|
|
1
|
+
export type RecoveryErrorType = "tool_result_missing" | "thinking_block_order" | "thinking_disabled_violation" | "assistant_prefill_unsupported" | "unavailable_tool" | null;
|
|
2
2
|
export declare function extractMessageIndex(error: unknown): number | null;
|
|
3
|
+
export declare function extractUnavailableToolName(error: unknown): string | null;
|
|
3
4
|
export declare function detectErrorType(error: unknown): RecoveryErrorType;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { createOpencodeClient } from "@opencode-ai/sdk";
|
|
2
|
+
import type { MessageData } from "./types";
|
|
3
|
+
type Client = ReturnType<typeof createOpencodeClient>;
|
|
4
|
+
export declare function recoverUnavailableTool(client: Client, sessionID: string, failedAssistantMsg: MessageData): Promise<boolean>;
|
|
5
|
+
export {};
|