@skj1724/oh-my-opencode 3.19.6 → 3.19.8
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/dist/cli/index.js +40 -3
- package/dist/config/index.d.ts +2 -2
- package/dist/config/schema.d.ts +270 -0
- package/dist/features/background-agent/manager.d.ts +6 -2
- package/dist/features/background-agent/types.d.ts +6 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/runtime-fallback/index.d.ts +27 -0
- package/dist/hooks/runtime-fallback/index.test.d.ts +1 -0
- package/dist/index.js +838 -46
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/provider-error-classifier.d.ts +23 -0
- package/dist/shared/provider-error-classifier.test.d.ts +1 -0
- package/dist/shared/retry-strategy.d.ts +39 -0
- package/dist/shared/retry-strategy.test.d.ts +1 -0
- package/dist/shared/runtime-fallback.d.ts +60 -0
- package/dist/shared/runtime-fallback.test.d.ts +1 -0
- package/dist/tools/delegate-task/tools.d.ts +3 -1
- package/package.json +1 -1
package/dist/shared/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export * from "./agent-tool-restrictions";
|
|
|
28
28
|
export * from "./model-requirements";
|
|
29
29
|
export * from "./model-resolver";
|
|
30
30
|
export * from "./model-availability";
|
|
31
|
+
export * from "./runtime-fallback";
|
|
31
32
|
export * from "./perf-timer";
|
|
32
33
|
export * from "./perf-tracer";
|
|
33
34
|
export * from "./case-insensitive";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Error Classifier
|
|
3
|
+
*
|
|
4
|
+
* 统一的 provider 错误分类逻辑,用于判断错误类型和是否可重试/fallback。
|
|
5
|
+
* 支持 OpenAI、Anthropic、Gemini、xAI、Zhipu 等主流 provider。
|
|
6
|
+
*/
|
|
7
|
+
export type ErrorCategory = "rate_limit" | "quota" | "overloaded" | "context_overflow" | "auth" | "bad_request" | "model_unavailable" | "provider_unavailable" | "unknown";
|
|
8
|
+
export interface ProviderErrorClassification {
|
|
9
|
+
category: ErrorCategory;
|
|
10
|
+
retryable: boolean;
|
|
11
|
+
shouldFallback: boolean;
|
|
12
|
+
statusCode?: number;
|
|
13
|
+
providerGuess?: string;
|
|
14
|
+
retryAfterMs?: number;
|
|
15
|
+
reason: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 分类 provider 错误
|
|
19
|
+
*
|
|
20
|
+
* @param error - 未知类型的错误对象
|
|
21
|
+
* @returns 包含错误分类、可重试性、是否应该 fallback 等信息
|
|
22
|
+
*/
|
|
23
|
+
export declare function classifyProviderError(error: unknown): ProviderErrorClassification;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry/backoff 策略服务
|
|
3
|
+
*
|
|
4
|
+
* 提供纯函数式的重试决策计算,支持指数退避、Retry-After 和 Jitter。
|
|
5
|
+
*/
|
|
6
|
+
export interface RetryConfig {
|
|
7
|
+
/** 最大重试次数 */
|
|
8
|
+
max_attempts: number;
|
|
9
|
+
/** 初始延迟(毫秒) */
|
|
10
|
+
initial_delay_ms: number;
|
|
11
|
+
/** 退避因子 */
|
|
12
|
+
backoff_factor: number;
|
|
13
|
+
/** 最大延迟(毫秒) */
|
|
14
|
+
max_delay_ms: number;
|
|
15
|
+
/** 是否启用 jitter */
|
|
16
|
+
jitter: boolean;
|
|
17
|
+
/** 是否尊重 Retry-After 头 */
|
|
18
|
+
respect_retry_after: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface RetryDecision {
|
|
21
|
+
/** 是否可重试 */
|
|
22
|
+
retryable: boolean;
|
|
23
|
+
/** 延迟时间(毫秒) */
|
|
24
|
+
delay_ms: number;
|
|
25
|
+
/** 当前尝试次数 */
|
|
26
|
+
attempt: number;
|
|
27
|
+
/** 决策原因 */
|
|
28
|
+
reason: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const DEFAULT_RETRY_CONFIG: RetryConfig;
|
|
31
|
+
/**
|
|
32
|
+
* 计算重试延迟
|
|
33
|
+
*
|
|
34
|
+
* @param attempt - 当前尝试次数(从 0 开始)
|
|
35
|
+
* @param config - 重试配置
|
|
36
|
+
* @param retryAfterMs - 可选的 Retry-After 值(毫秒)
|
|
37
|
+
* @returns 重试决策
|
|
38
|
+
*/
|
|
39
|
+
export declare function calculateRetryDelay(attempt: number, config: RetryConfig, retryAfterMs?: number): RetryDecision;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Fallback Decision Service
|
|
3
|
+
*
|
|
4
|
+
* 纯函数:根据 agent/category 的 fallback chain,结合当前失败状态和可用模型,
|
|
5
|
+
* 决定下一个要尝试的模型。
|
|
6
|
+
*/
|
|
7
|
+
import type { ProviderErrorClassification } from "./provider-error-classifier";
|
|
8
|
+
export interface FallbackModel {
|
|
9
|
+
providerID: string;
|
|
10
|
+
modelID: string;
|
|
11
|
+
variant?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface FallbackAttempt {
|
|
14
|
+
model: FallbackModel;
|
|
15
|
+
error?: ProviderErrorClassification;
|
|
16
|
+
}
|
|
17
|
+
export interface FallbackSkip {
|
|
18
|
+
model?: FallbackModel;
|
|
19
|
+
reason: string;
|
|
20
|
+
}
|
|
21
|
+
export interface FallbackNextResult {
|
|
22
|
+
kind: "next";
|
|
23
|
+
model: FallbackModel;
|
|
24
|
+
attempts: FallbackAttempt[];
|
|
25
|
+
skipped?: FallbackSkip[];
|
|
26
|
+
}
|
|
27
|
+
export interface FallbackExhaustedResult {
|
|
28
|
+
kind: "exhausted";
|
|
29
|
+
attempts: FallbackAttempt[];
|
|
30
|
+
reason: string;
|
|
31
|
+
skipped?: FallbackSkip[];
|
|
32
|
+
lastErrorClassification?: ProviderErrorClassification;
|
|
33
|
+
}
|
|
34
|
+
export interface FallbackUnconfiguredResult {
|
|
35
|
+
kind: "unconfigured";
|
|
36
|
+
reason: string;
|
|
37
|
+
skipped?: FallbackSkip[];
|
|
38
|
+
}
|
|
39
|
+
export type FallbackResult = FallbackNextResult | FallbackExhaustedResult | FallbackUnconfiguredResult;
|
|
40
|
+
export interface RuntimeFallbackInput {
|
|
41
|
+
agent?: string;
|
|
42
|
+
category?: string;
|
|
43
|
+
currentModel: FallbackModel;
|
|
44
|
+
attempts: FallbackAttempt[];
|
|
45
|
+
availableModels?: Set<string>;
|
|
46
|
+
lastErrorClassification?: ProviderErrorClassification;
|
|
47
|
+
configuredFallbackModels?: FallbackModel[];
|
|
48
|
+
maxAttempts?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 解析下一个 fallback 模型
|
|
52
|
+
*
|
|
53
|
+
* 逻辑:
|
|
54
|
+
* 1. 从 AGENT_MODEL_REQUIREMENTS 或 CATEGORY_MODEL_REQUIREMENTS 获取 fallbackChain
|
|
55
|
+
* 2. 将 chain 展开为候选列表(每个 provider × model 组合,保持顺序)
|
|
56
|
+
* 3. 跳过 currentModel 和 attempts 中的 model
|
|
57
|
+
* 4. 如果 availableModels 非空,使用 fuzzyMatchModel 检查可用性
|
|
58
|
+
* 5. 返回第一个有效候选,或 exhausted
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveNextFallbackModel(input: RuntimeFallbackInput): FallbackResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PluginInput, type ToolDefinition } from "@opencode-ai/plugin";
|
|
2
2
|
import type { BackgroundManager } from "../../features/background-agent";
|
|
3
|
-
import type { CategoryConfig, CategoriesConfig, GitMasterConfig } from "../../config/schema";
|
|
3
|
+
import type { CategoryConfig, CategoriesConfig, FallbackModelEntry, GitMasterConfig, RuntimeFallbackConfig } from "../../config/schema";
|
|
4
4
|
type OpencodeClient = PluginInput["client"];
|
|
5
5
|
export declare function resolveCategoryConfig(categoryName: string, options: {
|
|
6
6
|
userCategories?: CategoriesConfig;
|
|
@@ -18,6 +18,8 @@ export interface DelegateTaskToolOptions {
|
|
|
18
18
|
userCategories?: CategoriesConfig;
|
|
19
19
|
gitMasterConfig?: GitMasterConfig;
|
|
20
20
|
sisyphusJuniorModel?: string;
|
|
21
|
+
runtimeFallbackConfig?: RuntimeFallbackConfig;
|
|
22
|
+
agentFallbackModels?: Record<string, FallbackModelEntry[] | undefined>;
|
|
21
23
|
}
|
|
22
24
|
export interface BuildSystemContentInput {
|
|
23
25
|
skillContent?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skj1724/oh-my-opencode",
|
|
3
|
-
"version": "3.19.
|
|
3
|
+
"version": "3.19.8",
|
|
4
4
|
"description": "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|