dsh-llm-fallbacks 0.4.2 → 0.4.3
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 +31 -2
- package/README.zh-CN.md +31 -2
- package/dist/chains.d.ts +24 -5
- package/dist/client/SubagentRoleBadge.d.ts +23 -0
- package/dist/client/fallbacks-store.d.ts +58 -17
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +311 -141
- package/dist/client/locales.d.ts +12 -6
- package/dist/config.d.ts +1 -1
- package/dist/gateway.d.ts +55 -2
- package/dist/index.d.ts +34 -5
- package/dist/index.js +194 -60
- package/dist/presets.d.ts +7 -4
- package/dist/seeds.d.ts +61 -7
- package/dist/state.d.ts +20 -0
- package/dist/tui-settings.d.ts +8 -6
- package/dist/tui.d.ts +12 -5
- package/package.json +1 -1
- package/scripts/build-client.ts +6 -1
- package/scripts/prepare-release.ts +1 -1
package/dist/state.d.ts
CHANGED
|
@@ -31,6 +31,19 @@ import type { FallbackSwitchReason } from './events.ts';
|
|
|
31
31
|
import { CooldownStore, StepFailureSet } from './cooldown.ts';
|
|
32
32
|
import { RecoveryStore } from './recovery.ts';
|
|
33
33
|
import type { RecoveryPolicy } from './config.ts';
|
|
34
|
+
/**
|
|
35
|
+
* What a switch's failure was actually about.
|
|
36
|
+
*
|
|
37
|
+
* `'route'` (the default) is every failure the plugin has ever walked: the
|
|
38
|
+
* provider/model itself is unhealthy (auth, quota, rate limit, ...), so the
|
|
39
|
+
* from-route is cooled down and counted as a route failure.
|
|
40
|
+
* `'request'` is a failure of the REQUEST on a healthy route — a
|
|
41
|
+
* `CONTEXT_WINDOW_EXCEEDED` rejection is the request being too big, not the
|
|
42
|
+
* model being down. `commit()` keeps the step-scoped bookkeeping for those
|
|
43
|
+
* but writes no suppression and no recovery failure (see `src/index.ts`
|
|
44
|
+
* `REQUEST_SCOPED_CODES`).
|
|
45
|
+
*/
|
|
46
|
+
export type SwitchScope = 'route' | 'request';
|
|
34
47
|
/** Decision awaiting application at the next `agent/request` boundary (spec §5.1). */
|
|
35
48
|
export interface PendingSwitch {
|
|
36
49
|
from: {
|
|
@@ -43,6 +56,13 @@ export interface PendingSwitch {
|
|
|
43
56
|
};
|
|
44
57
|
role: string;
|
|
45
58
|
reason: FallbackSwitchReason;
|
|
59
|
+
/**
|
|
60
|
+
* What the failure was about — absent means `'route'`, the semantics every
|
|
61
|
+
* switch had before request-scoped codes existed (same optional-with-a-
|
|
62
|
+
* documented-default idiom as `FallbacksRole.fallback`). Only the
|
|
63
|
+
* `agent/request-error` listener ever sets `'request'`.
|
|
64
|
+
*/
|
|
65
|
+
scope?: SwitchScope;
|
|
46
66
|
}
|
|
47
67
|
/**
|
|
48
68
|
* One plugin-originated subagent switch the host allowlist blocked (plan
|
package/dist/tui-settings.d.ts
CHANGED
|
@@ -125,12 +125,14 @@ export declare const JSON_FIELD_MAX_DRAFT_BYTES: number;
|
|
|
125
125
|
export declare function buildFallbacksTuiSection(): TuiSettingsSection;
|
|
126
126
|
/**
|
|
127
127
|
* Register the `fallbacks` section on the optional `tuiSettingsSections`
|
|
128
|
-
* service.
|
|
129
|
-
* `
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
128
|
+
* service. Gated by `serviceOwned` — the optimistic apply-time claim (see
|
|
129
|
+
* `apply()` in src/index.ts) — with a sibling dedupe guard inside the child,
|
|
130
|
+
* mirroring `installTuiClient`: the claim is not a fact, so a fiber applying
|
|
131
|
+
* inside the claim window can race another fiber's registration, and the
|
|
132
|
+
* host registry's duplicate throw must degrade (no-op disposer + debug log)
|
|
133
|
+
* instead of failing the child. Any other error stays loud. The service is
|
|
134
|
+
* optional: a composition without `dsh-tui-settings-sections` keeps the
|
|
135
|
+
* plugin working and simply omits the TUI settings surface.
|
|
134
136
|
*
|
|
135
137
|
* The inject child returns the registry disposer so cordis withdraws the
|
|
136
138
|
* registration when this fiber (or the service) goes away.
|
package/dist/tui.d.ts
CHANGED
|
@@ -42,11 +42,18 @@ export interface TuiCommandTreeProvider {
|
|
|
42
42
|
export declare const FALLBACKS_TUI_ROOT = "fallbacks";
|
|
43
43
|
/**
|
|
44
44
|
* Register the `/fallbacks` provider on the optional `tuiCommandTrees`
|
|
45
|
-
* service.
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
45
|
+
* service. Gated by the OPTIMISTIC `serviceOwned` claim taken at apply time
|
|
46
|
+
* (the service itself is provided inside the settings inject child, after
|
|
47
|
+
* apply returns — see `apply()` in src/index.ts), with the sibling dedupe
|
|
48
|
+
* guard inside the child: the claim is not a fact, so a fiber applying
|
|
49
|
+
* inside the claim window registers here and, when it loses the race for
|
|
50
|
+
* the host registry's root, degrades via the `already registered` catch
|
|
51
|
+
* below — only a post-settlement duplicate fiber skips at this gate (its
|
|
52
|
+
* claim INITIALIZED false: the service was already visible when the claim
|
|
53
|
+
* was taken; the child-side catch correction settles strictly after apply()
|
|
54
|
+
* and can never influence this synchronous read). The service is optional:
|
|
55
|
+
* a composition without `dsh-tui-command-trees` keeps the plugin working
|
|
56
|
+
* and simply omits the TUI surface.
|
|
50
57
|
*
|
|
51
58
|
* The inject child returns the registry disposer so cordis withdraws the
|
|
52
59
|
* registration when this fiber (or the service) goes away.
|
package/package.json
CHANGED
package/scripts/build-client.ts
CHANGED
|
@@ -362,7 +362,12 @@ for (const match of injectedCssMatches) {
|
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
|
-
|
|
365
|
+
// The class-map object literal is FLAT (string → string, emitted by
|
|
366
|
+
// cssModuleContents as one JSON.stringify), so the lazy match to the first
|
|
367
|
+
// `};` is exact for both emit shapes the printer produces — multi-entry maps
|
|
368
|
+
// across lines and a single-entry map inline (`{ "badge": "_<8hex>_badge" };`
|
|
369
|
+
// has no newline before its closing brace).
|
|
370
|
+
const classMapMatches = [...bundleText.matchAll(/\b\w+_module_css_default\s*=\s*(\{[\s\S]*?\});/g)]
|
|
366
371
|
if (classMapMatches.length === 0) {
|
|
367
372
|
throw new Error('client bundle contract: no inlined css-module class map found — check the dsh-css-modules-inline plugin')
|
|
368
373
|
}
|
|
@@ -79,7 +79,7 @@ export function parseArgs(argv: string[]): { version?: string; autoBump: boolean
|
|
|
79
79
|
* version stays in its prerelease line, bumping only the numeric tail.
|
|
80
80
|
*/
|
|
81
81
|
export function autoBumpPatch(current: string): string {
|
|
82
|
-
const m = /^(\d+)\.(\d+)\.(\d+)(?:-(.+))
|
|
82
|
+
const m = current.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/)
|
|
83
83
|
if (!m) throw new Error(`Cannot auto-bump "${current}": not a parseable X.Y.Z[-pre] version`)
|
|
84
84
|
const [, major, minor, patch, pre] = m
|
|
85
85
|
if (pre === undefined) return `${major}.${minor}.${Number(patch) + 1}`
|