@smart-coders-hq/opencode-model-fallback 1.2.0 → 1.3.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.md +12 -4
- package/dist/index.js +102 -37
- package/dist/src/logging/logger.d.ts +1 -0
- package/dist/src/logging/logger.d.ts.map +1 -1
- package/dist/src/plugin.d.ts +1 -0
- package/dist/src/plugin.d.ts.map +1 -1
- package/dist/src/replay/orchestrator.d.ts +1 -0
- package/dist/src/replay/orchestrator.d.ts.map +1 -1
- package/dist/src/state/model-health.d.ts.map +1 -1
- package/dist/src/state/session-state.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ OpenCode plugin that adds automatic model fallback when your primary model hits
|
|
|
5
5
|
## How it works
|
|
6
6
|
|
|
7
7
|
1. **Preemptive redirect** — intercepts outgoing messages via `chat.message` hook; if the target model is known to be rate-limited, redirects the message to a healthy fallback _before_ it hits the provider (no 429 round-trip)
|
|
8
|
-
2. **Reactive fallback** — if a
|
|
8
|
+
2. **Reactive fallback** — if a fallback-triggering error still occurs (first hit, or preemptive not available), listens for both `session.status: retry` and `session.error` (`APIError`) events, aborts the retry loop, reverts the failed message, and replays it with the next healthy fallback model
|
|
9
9
|
3. Shows an inline toast notification and logs the event
|
|
10
10
|
4. Tracks model health globally (rate limits are account-wide) — automatically recovers after configurable cooldown periods
|
|
11
11
|
5. **Depth reset** — when the TUI reverts to the original model between messages, `fallbackDepth` resets so `maxFallbackDepth` only guards true cascading failures within a single message
|
|
@@ -176,6 +176,8 @@ With the `verbose` flag:
|
|
|
176
176
|
|
|
177
177
|
Includes token/cost breakdown per model period.
|
|
178
178
|
|
|
179
|
+
When enabled, the plugin auto-creates `~/.config/opencode/commands/fallback-status.md` at startup so the slash command is available without manual setup.
|
|
180
|
+
|
|
179
181
|
## Health state machine
|
|
180
182
|
|
|
181
183
|
```
|
|
@@ -187,7 +189,7 @@ cooldown ──[retryOriginalAfterMs elapsed]──→ healthy
|
|
|
187
189
|
- **healthy** — model is usable; preferred for fallback selection
|
|
188
190
|
- **rate_limited** — recently hit a limit; skipped when walking fallback chain
|
|
189
191
|
- **cooldown** — cooling off; used as last resort if no healthy model is available
|
|
190
|
-
- State transitions are checked every 30 seconds via a background timer
|
|
192
|
+
- State transitions are checked every 30 seconds via a background timer (the timer is unref'ed so it does not keep the process alive)
|
|
191
193
|
- When the original model recovers to healthy, a toast appears on the next `session.idle`
|
|
192
194
|
|
|
193
195
|
## Troubleshooting
|
|
@@ -195,6 +197,9 @@ cooldown ──[retryOriginalAfterMs elapsed]──→ healthy
|
|
|
195
197
|
**Toast doesn't appear**
|
|
196
198
|
The TUI notification requires an active OpenCode TUI session. Headless/API usage won't show toasts but logs are always written.
|
|
197
199
|
|
|
200
|
+
**`/fallback-status` command is missing**
|
|
201
|
+
The plugin writes `~/.config/opencode/commands/fallback-status.md` on startup. If the command does not appear, verify the directory is writable and check for `fallback-status.command.write.failed` in OpenCode logs.
|
|
202
|
+
|
|
198
203
|
**"no fallback chain configured"**
|
|
199
204
|
Your `model-fallback.json` has no `agents["*"].fallbackModels` (or no entry for the active agent). Add at least a wildcard entry with one model.
|
|
200
205
|
|
|
@@ -214,11 +219,14 @@ Key log events: `plugin.init`, `retry.detected`, `fallback.success`, `fallback.e
|
|
|
214
219
|
|
|
215
220
|
To see the full event stream (including `event.received` and `retry.nomatch`), set `"logLevel": "debug"` in your config and restart OpenCode.
|
|
216
221
|
|
|
222
|
+
For safety, free-form provider error text is redacted in plugin logs; use category/model/session fields for diagnosis.
|
|
223
|
+
|
|
217
224
|
## Release automation
|
|
218
225
|
|
|
219
226
|
- Uses **Conventional Commits** + `semantic-release` for automated versioning/changelog/release notes
|
|
220
227
|
- CI runs lint, tests, type check, and build on every push/PR via `.github/workflows/ci.yml`
|
|
221
|
-
-
|
|
228
|
+
- Trusted release gate runs on pushes to `main` via `.github/workflows/release-gate.yml`
|
|
229
|
+
- Release workflow (`.github/workflows/release.yml`) runs on successful `Release Gate` completion (`workflow_run`), only for `push` events on `main`, and only when `head_sha` matches `github.sha`
|
|
222
230
|
- Published as `@smart-coders-hq/opencode-model-fallback`
|
|
223
231
|
- To publish to npm, set repository secret `NPM_TOKEN`
|
|
224
232
|
|
|
@@ -227,7 +235,7 @@ To see the full event stream (including `event.received` and `retry.nomatch`), s
|
|
|
227
235
|
```bash
|
|
228
236
|
bun install
|
|
229
237
|
bun run lint # lint checks
|
|
230
|
-
bun test #
|
|
238
|
+
bun test # 163 tests across 16 files
|
|
231
239
|
bunx tsc --noEmit # type check
|
|
232
240
|
bun run build # build to dist/
|
|
233
241
|
```
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/plugin.ts
|
|
2
|
-
import {
|
|
2
|
+
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
3
3
|
import { homedir as homedir5 } from "os";
|
|
4
4
|
import { dirname as dirname2, join as join4 } from "path";
|
|
5
5
|
|
|
@@ -3305,7 +3305,7 @@ function labelModel(key) {
|
|
|
3305
3305
|
}
|
|
3306
3306
|
|
|
3307
3307
|
// src/logging/logger.ts
|
|
3308
|
-
import { appendFileSync,
|
|
3308
|
+
import { appendFileSync, mkdirSync, writeFileSync } from "fs";
|
|
3309
3309
|
import { dirname } from "path";
|
|
3310
3310
|
|
|
3311
3311
|
class Logger {
|
|
@@ -3314,6 +3314,7 @@ class Logger {
|
|
|
3314
3314
|
enabled;
|
|
3315
3315
|
minLevel;
|
|
3316
3316
|
dirCreated = false;
|
|
3317
|
+
fileErrorNotified = false;
|
|
3317
3318
|
constructor(client, logPath, enabled, minLevel = "info") {
|
|
3318
3319
|
this.client = client;
|
|
3319
3320
|
this.logPath = logPath;
|
|
@@ -3321,18 +3322,19 @@ class Logger {
|
|
|
3321
3322
|
this.minLevel = minLevel;
|
|
3322
3323
|
}
|
|
3323
3324
|
log(level, event, fields = {}) {
|
|
3325
|
+
const sanitizedFields = sanitizeFields(fields);
|
|
3324
3326
|
const entry = {
|
|
3325
3327
|
ts: new Date().toISOString(),
|
|
3326
3328
|
level,
|
|
3327
3329
|
event,
|
|
3328
|
-
...
|
|
3330
|
+
...sanitizedFields
|
|
3329
3331
|
};
|
|
3330
3332
|
const shouldWrite = this.enabled && (this.minLevel === "debug" || level !== "debug");
|
|
3331
3333
|
if (shouldWrite) {
|
|
3332
3334
|
this.writeToFile(entry);
|
|
3333
3335
|
}
|
|
3334
3336
|
if (level !== "debug") {
|
|
3335
|
-
const message = `[model-fallback] ${event}${Object.keys(
|
|
3337
|
+
const message = `[model-fallback] ${event}${Object.keys(sanitizedFields).length ? " " + JSON.stringify(sanitizedFields) : ""}`;
|
|
3336
3338
|
this.client.app.log({
|
|
3337
3339
|
body: { service: "model-fallback", level, message }
|
|
3338
3340
|
}).catch(() => {});
|
|
@@ -3356,13 +3358,65 @@ class Logger {
|
|
|
3356
3358
|
mkdirSync(dirname(this.logPath), { recursive: true, mode: 448 });
|
|
3357
3359
|
this.dirCreated = true;
|
|
3358
3360
|
}
|
|
3359
|
-
|
|
3360
|
-
writeFileSync(this.logPath, "", { mode: 384 });
|
|
3361
|
-
}
|
|
3361
|
+
try {
|
|
3362
|
+
writeFileSync(this.logPath, "", { mode: 384, flag: "ax" });
|
|
3363
|
+
} catch {}
|
|
3362
3364
|
appendFileSync(this.logPath, JSON.stringify(entry) + `
|
|
3363
3365
|
`, "utf-8");
|
|
3364
|
-
} catch {
|
|
3366
|
+
} catch (err) {
|
|
3367
|
+
if (!this.fileErrorNotified) {
|
|
3368
|
+
this.fileErrorNotified = true;
|
|
3369
|
+
const message = `[model-fallback] logging.file.write.failed ${JSON.stringify({
|
|
3370
|
+
logPath: this.logPath,
|
|
3371
|
+
error: summarizeError(err)
|
|
3372
|
+
})}`;
|
|
3373
|
+
this.client.app.log({
|
|
3374
|
+
body: { service: "model-fallback", level: "warn", message }
|
|
3375
|
+
}).catch(() => {});
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
function sanitizeFields(fields) {
|
|
3381
|
+
const out = {};
|
|
3382
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
3383
|
+
out[key] = sanitizeValue(key, value);
|
|
3384
|
+
}
|
|
3385
|
+
return out;
|
|
3386
|
+
}
|
|
3387
|
+
function sanitizeValue(key, value) {
|
|
3388
|
+
if (value === null || value === undefined)
|
|
3389
|
+
return value;
|
|
3390
|
+
if (isSensitiveKey(key)) {
|
|
3391
|
+
if (typeof value === "string") {
|
|
3392
|
+
return { redacted: true, length: value.length };
|
|
3393
|
+
}
|
|
3394
|
+
if (value instanceof Error) {
|
|
3395
|
+
return { redacted: true, type: value.name, code: getErrorCode(value) };
|
|
3396
|
+
}
|
|
3397
|
+
return { redacted: true, type: typeof value };
|
|
3398
|
+
}
|
|
3399
|
+
if (value instanceof Error) {
|
|
3400
|
+
return { name: value.name, message: value.message };
|
|
3401
|
+
}
|
|
3402
|
+
return value;
|
|
3403
|
+
}
|
|
3404
|
+
function isSensitiveKey(key) {
|
|
3405
|
+
return /(?:^|_)(message|prompt|content|parts|error|err|stack|body)(?:$|_)/i.test(key);
|
|
3406
|
+
}
|
|
3407
|
+
function getErrorCode(err) {
|
|
3408
|
+
const code = err.code;
|
|
3409
|
+
return typeof code === "string" ? code : undefined;
|
|
3410
|
+
}
|
|
3411
|
+
function summarizeError(err) {
|
|
3412
|
+
if (err && typeof err === "object") {
|
|
3413
|
+
const e = err;
|
|
3414
|
+
return {
|
|
3415
|
+
type: typeof e.name === "string" ? e.name : "Error",
|
|
3416
|
+
code: typeof e.code === "string" ? e.code : undefined
|
|
3417
|
+
};
|
|
3365
3418
|
}
|
|
3419
|
+
return { type: typeof err };
|
|
3366
3420
|
}
|
|
3367
3421
|
|
|
3368
3422
|
// src/resolution/agent-resolver.ts
|
|
@@ -3505,7 +3559,7 @@ async function attemptFallback(sessionId, reason, client, store, config, logger,
|
|
|
3505
3559
|
const result = await client.session.messages({ path: { id: sessionId } });
|
|
3506
3560
|
messageEntries = Array.isArray(result.data) ? result.data : [];
|
|
3507
3561
|
} catch (err) {
|
|
3508
|
-
logger.error("replay.messages.failed", { sessionId, err
|
|
3562
|
+
logger.error("replay.messages.failed", { sessionId, err });
|
|
3509
3563
|
return { success: false, error: "messages fetch failed" };
|
|
3510
3564
|
}
|
|
3511
3565
|
let lastUserEntry = null;
|
|
@@ -3575,7 +3629,7 @@ async function attemptFallback(sessionId, reason, client, store, config, logger,
|
|
|
3575
3629
|
return { success: false, error: "all fallback models exhausted" };
|
|
3576
3630
|
}
|
|
3577
3631
|
const currentModel = sessionState.currentModel;
|
|
3578
|
-
if (currentModel) {
|
|
3632
|
+
if (currentModel && shouldMarkRateLimited(reason)) {
|
|
3579
3633
|
store.health.markRateLimited(currentModel, config.defaults.cooldownMs, config.defaults.retryOriginalAfterMs);
|
|
3580
3634
|
}
|
|
3581
3635
|
sessionState.lastFallbackAt = Date.now();
|
|
@@ -3583,7 +3637,7 @@ async function attemptFallback(sessionId, reason, client, store, config, logger,
|
|
|
3583
3637
|
await client.session.abort({ path: { id: sessionId } });
|
|
3584
3638
|
logger.debug("replay.abort.ok", { sessionId });
|
|
3585
3639
|
} catch (err) {
|
|
3586
|
-
logger.error("replay.abort.failed", { sessionId, err
|
|
3640
|
+
logger.error("replay.abort.failed", { sessionId, err });
|
|
3587
3641
|
return { success: false, error: "abort failed" };
|
|
3588
3642
|
}
|
|
3589
3643
|
try {
|
|
@@ -3596,7 +3650,7 @@ async function attemptFallback(sessionId, reason, client, store, config, logger,
|
|
|
3596
3650
|
messageID: lastUserEntry.id
|
|
3597
3651
|
});
|
|
3598
3652
|
} catch (err) {
|
|
3599
|
-
logger.error("replay.revert.failed", { sessionId, err
|
|
3653
|
+
logger.error("replay.revert.failed", { sessionId, err });
|
|
3600
3654
|
return { success: false, error: "revert failed" };
|
|
3601
3655
|
}
|
|
3602
3656
|
const promptParts = convertPartsForPrompt(lastUserEntry.parts);
|
|
@@ -3619,7 +3673,7 @@ async function attemptFallback(sessionId, reason, client, store, config, logger,
|
|
|
3619
3673
|
logger.error("replay.prompt.failed", {
|
|
3620
3674
|
sessionId,
|
|
3621
3675
|
fallbackModel,
|
|
3622
|
-
err
|
|
3676
|
+
err
|
|
3623
3677
|
});
|
|
3624
3678
|
return { success: false, error: "prompt failed" };
|
|
3625
3679
|
}
|
|
@@ -3634,11 +3688,14 @@ async function attemptFallback(sessionId, reason, client, store, config, logger,
|
|
|
3634
3688
|
reason,
|
|
3635
3689
|
depth: newDepth
|
|
3636
3690
|
});
|
|
3637
|
-
return { success: true, fallbackModel };
|
|
3691
|
+
return { success: true, fallbackModel, fromModel: currentModel };
|
|
3638
3692
|
} finally {
|
|
3639
3693
|
store.sessions.releaseLock(sessionId);
|
|
3640
3694
|
}
|
|
3641
3695
|
}
|
|
3696
|
+
function shouldMarkRateLimited(reason) {
|
|
3697
|
+
return reason === "rate_limit" || reason === "quota_exceeded";
|
|
3698
|
+
}
|
|
3642
3699
|
function sanitizeParts(parts) {
|
|
3643
3700
|
if (!Array.isArray(parts))
|
|
3644
3701
|
return [];
|
|
@@ -3652,7 +3709,7 @@ class ModelHealthStore {
|
|
|
3652
3709
|
onTransition;
|
|
3653
3710
|
constructor(opts) {
|
|
3654
3711
|
this.onTransition = opts?.onTransition;
|
|
3655
|
-
this.timer = setInterval(() => this.tick(), 30000);
|
|
3712
|
+
this.timer = setInterval(() => this.tick(), 30000).unref();
|
|
3656
3713
|
}
|
|
3657
3714
|
get(modelKey2) {
|
|
3658
3715
|
return this.store.get(modelKey2) ?? this.newHealth(modelKey2);
|
|
@@ -3782,6 +3839,7 @@ class SessionStateStore {
|
|
|
3782
3839
|
agentName
|
|
3783
3840
|
};
|
|
3784
3841
|
state.currentModel = toModel;
|
|
3842
|
+
state.fallbackDepth++;
|
|
3785
3843
|
state.recoveryNotifiedForModel = null;
|
|
3786
3844
|
state.fallbackHistory.push(event);
|
|
3787
3845
|
if (agentName)
|
|
@@ -4026,22 +4084,25 @@ function getLastUserModelAndAgent(data) {
|
|
|
4026
4084
|
}
|
|
4027
4085
|
|
|
4028
4086
|
// src/plugin.ts
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4087
|
+
function resolveFallbackStatusCommandPath() {
|
|
4088
|
+
return join4(homedir5(), ".config", "opencode", "commands", "fallback-status.md");
|
|
4089
|
+
}
|
|
4090
|
+
function ensureFallbackStatusCommand(logger, cmdPath) {
|
|
4033
4091
|
try {
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
}
|
|
4039
|
-
} catch (err) {
|
|
4040
|
-
logger.warn("fallback-status.command.write.failed", {
|
|
4041
|
-
cmdPath,
|
|
4042
|
-
err: String(err)
|
|
4092
|
+
mkdirSync2(dirname2(cmdPath), { recursive: true, mode: 448 });
|
|
4093
|
+
writeFileSync2(cmdPath, `Call the fallback-status tool and display the full output.
|
|
4094
|
+
`, {
|
|
4095
|
+
flag: "wx"
|
|
4043
4096
|
});
|
|
4097
|
+
} catch (err) {
|
|
4098
|
+
if (err.code !== "EEXIST") {
|
|
4099
|
+
logger.warn("fallback-status.command.write.failed", { cmdPath, err });
|
|
4100
|
+
}
|
|
4044
4101
|
}
|
|
4102
|
+
}
|
|
4103
|
+
var createPlugin = async ({ client, directory }) => {
|
|
4104
|
+
const { config, path: configPath, warnings, migrated } = loadConfig(directory);
|
|
4105
|
+
const logger = new Logger(client, config.logPath, config.logging, config.logLevel);
|
|
4045
4106
|
logger.info("plugin.init", {
|
|
4046
4107
|
configPath,
|
|
4047
4108
|
enabled: config.enabled,
|
|
@@ -4049,17 +4110,19 @@ var createPlugin = async ({ client, directory }) => {
|
|
|
4049
4110
|
agentCount: Object.keys(config.agents).length
|
|
4050
4111
|
});
|
|
4051
4112
|
for (const w of warnings) {
|
|
4052
|
-
logger.warn("config.warning", {
|
|
4113
|
+
logger.warn("config.warning", { warning: w });
|
|
4053
4114
|
}
|
|
4054
4115
|
if (migrated) {
|
|
4055
4116
|
logger.info("config.migrated", {
|
|
4056
|
-
|
|
4117
|
+
note: "Auto-migrated from old rate-limit-fallback.json format"
|
|
4057
4118
|
});
|
|
4058
4119
|
}
|
|
4059
4120
|
if (!config.enabled) {
|
|
4060
4121
|
logger.info("plugin.disabled");
|
|
4061
4122
|
return {};
|
|
4062
4123
|
}
|
|
4124
|
+
const cmdPath = resolveFallbackStatusCommandPath();
|
|
4125
|
+
ensureFallbackStatusCommand(logger, cmdPath);
|
|
4063
4126
|
const store = new FallbackStore(config, logger);
|
|
4064
4127
|
const hooks = {
|
|
4065
4128
|
async event({ event }) {
|
|
@@ -4124,8 +4187,7 @@ async function handleEvent(event, client, store, config, logger, directory) {
|
|
|
4124
4187
|
if (config.defaults.fallbackOn.includes(category)) {
|
|
4125
4188
|
const result = await attemptFallback(sessionID, category, client, store, config, logger, directory);
|
|
4126
4189
|
if (result.success && result.fallbackModel) {
|
|
4127
|
-
|
|
4128
|
-
await notifyFallback(client, state.originalModel, result.fallbackModel, category);
|
|
4190
|
+
await notifyFallback(client, result.fromModel ?? null, result.fallbackModel, category);
|
|
4129
4191
|
}
|
|
4130
4192
|
}
|
|
4131
4193
|
}
|
|
@@ -4145,12 +4207,16 @@ async function handleEvent(event, client, store, config, logger, directory) {
|
|
|
4145
4207
|
}
|
|
4146
4208
|
async function handleRetry(sessionId, message, client, store, config, logger, directory) {
|
|
4147
4209
|
if (!matchesAnyPattern(message, config.patterns)) {
|
|
4148
|
-
logger.debug("retry.nomatch", { sessionId, message });
|
|
4210
|
+
logger.debug("retry.nomatch", { sessionId, messageLength: message.length });
|
|
4149
4211
|
return;
|
|
4150
4212
|
}
|
|
4151
4213
|
const category = classifyError(message);
|
|
4152
4214
|
if (!config.defaults.fallbackOn.includes(category)) {
|
|
4153
|
-
logger.debug("retry.ignored", {
|
|
4215
|
+
logger.debug("retry.ignored", {
|
|
4216
|
+
sessionId,
|
|
4217
|
+
category,
|
|
4218
|
+
messageLength: message.length
|
|
4219
|
+
});
|
|
4154
4220
|
return;
|
|
4155
4221
|
}
|
|
4156
4222
|
const sessionState = store.sessions.get(sessionId);
|
|
@@ -4178,15 +4244,14 @@ async function handleRetry(sessionId, message, client, store, config, logger, di
|
|
|
4178
4244
|
}
|
|
4179
4245
|
logger.info("retry.detected", {
|
|
4180
4246
|
sessionId,
|
|
4181
|
-
message,
|
|
4247
|
+
messageLength: message.length,
|
|
4182
4248
|
category,
|
|
4183
4249
|
agentName: sessionState.agentName,
|
|
4184
4250
|
agentFile: sessionState.agentFile
|
|
4185
4251
|
});
|
|
4186
4252
|
const result = await attemptFallback(sessionId, category, client, store, config, logger, directory);
|
|
4187
4253
|
if (result.success && result.fallbackModel) {
|
|
4188
|
-
|
|
4189
|
-
await notifyFallback(client, state.originalModel, result.fallbackModel, category);
|
|
4254
|
+
await notifyFallback(client, result.fromModel ?? null, result.fallbackModel, category);
|
|
4190
4255
|
}
|
|
4191
4256
|
}
|
|
4192
4257
|
async function handleIdle(sessionId, client, store, _config, logger) {
|
|
@@ -13,6 +13,7 @@ export declare class Logger {
|
|
|
13
13
|
private enabled;
|
|
14
14
|
private minLevel;
|
|
15
15
|
private dirCreated;
|
|
16
|
+
private fileErrorNotified;
|
|
16
17
|
constructor(client: Client, logPath: string, enabled: boolean, minLevel?: "debug" | "info");
|
|
17
18
|
log(level: LogLevel, event: string, fields?: Record<string, unknown>): void;
|
|
18
19
|
info(event: string, fields?: Record<string, unknown>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/logging/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,KAAK,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;AAEpC,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAA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AAO,CAAM,GAAG,IAAI;IA2B/E,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI3D,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI3D,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI5D,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI5D,OAAO,CAAC,WAAW;CA8BpB"}
|
package/dist/src/plugin.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Event } from "@opencode-ai/sdk";
|
|
|
3
3
|
import { loadConfig } from "./config/loader.js";
|
|
4
4
|
import { Logger } from "./logging/logger.js";
|
|
5
5
|
import { FallbackStore } from "./state/store.js";
|
|
6
|
+
export declare function ensureFallbackStatusCommand(logger: Logger, cmdPath: string): void;
|
|
6
7
|
export declare const createPlugin: Plugin;
|
|
7
8
|
export declare function handleEvent(event: Event, client: Parameters<Plugin>[0]["client"], store: FallbackStore, config: ReturnType<typeof loadConfig>["config"], logger: Logger, directory: string): Promise<void>;
|
|
8
9
|
export declare function handleIdle(sessionId: string, client: Parameters<Plugin>[0]["client"], store: FallbackStore, _config: ReturnType<typeof loadConfig>["config"], logger: Logger): Promise<void>;
|
package/dist/src/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;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6 +6,7 @@ type Client = PluginInput["client"];
|
|
|
6
6
|
export interface ReplayResult {
|
|
7
7
|
success: boolean;
|
|
8
8
|
fallbackModel?: ModelKey;
|
|
9
|
+
fromModel?: ModelKey | null;
|
|
9
10
|
error?: string;
|
|
10
11
|
}
|
|
11
12
|
export declare function attemptFallback(sessionId: string, reason: ErrorCategory, client: Client, store: FallbackStore, config: PluginConfig, logger: Logger, directory: string): Promise<ReplayResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../src/replay/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGzE,KAAK,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;AAEpC,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,CAAC,CAwOvB"}
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../src/replay/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGzE,KAAK,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;AAEpC,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB,SAAS,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,CAAC,CAwOvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-health.d.ts","sourceRoot":"","sources":["../../../src/state/model-health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtE,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAoC;IACjD,OAAO,CAAC,KAAK,CAA+C;IAC5D,OAAO,CAAC,YAAY,CAAC,CAAmE;gBAE5E,IAAI,CAAC,EAAE;QACjB,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC;KACjF;
|
|
1
|
+
{"version":3,"file":"model-health.d.ts","sourceRoot":"","sources":["../../../src/state/model-health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE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AE,MAAM,GAAG,IAAI;IAI/B,MAAM,IAAI,oBAAoB,EAAE;IAIhC,OAAO,CAAC,QAAQ;CAcjB"}
|
package/package.json
CHANGED
package/plugin.json
CHANGED