dsh-llm-fallbacks 0.4.4 → 0.5.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 +81 -24
- package/README.zh-CN.md +81 -24
- package/dist/client/index.js +12 -8
- package/dist/client/locales.d.ts +2 -0
- package/dist/events.d.ts +2 -2
- package/dist/index.d.ts +6 -4
- package/dist/index.js +156 -63
- package/dist/role-resolution.d.ts +11 -0
- package/dist/roles.d.ts +4 -1
- package/dist/seeds.d.ts +63 -21
- package/dist/time-slots.d.ts +3 -2
- package/dist/virtual-adapter.d.ts +42 -6
- package/package.json +4 -3
- package/scripts/repair-session-logs.ts +1858 -0
- package/scripts/session-logs/catalog.ts +547 -0
- package/scripts/session-logs/classify.ts +47 -0
- package/scripts/session-logs/publish.ts +530 -0
- package/scripts/session-logs/rules.ts +1227 -0
- package/scripts/repair-fallbacks-switch-logs.ts +0 -342
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* reconcile thunk, wired by `apply()`) plus child activation. The row is
|
|
15
15
|
* visible whenever the plugin is enabled — a non-conforming all-day chain
|
|
16
16
|
* does NOT hide it (PR #62 feedback); conformance still gates a
|
|
17
|
-
* successful
|
|
17
|
+
* successful delegate (`effectiveHeadOf` below refuses a
|
|
18
18
|
* non-conforming all-day). The condition deliberately ignores `timeSlots`
|
|
19
19
|
* and conformance, so slot-row edits and chain edits never churn
|
|
20
20
|
* registration.
|
|
@@ -26,12 +26,14 @@
|
|
|
26
26
|
* `agent/request-error`, where the existing engine walks from there).
|
|
27
27
|
* `resolveModel` proxies the current effective head's metadata when
|
|
28
28
|
* resolvable (modalities/context-window/reasoning follow the head) with a
|
|
29
|
-
* permissive default otherwise — never throws.
|
|
29
|
+
* permissive default otherwise — never throws. `providerRetryPolicy` and
|
|
30
|
+
* `imageRequestPricing` mirror the same head for the host-captured retry
|
|
31
|
+
* policy and the token meter — also never throwing.
|
|
30
32
|
*
|
|
31
33
|
* @module dsh-llm-fallbacks/virtual-adapter
|
|
32
34
|
*/
|
|
33
35
|
import type { Context } from '@deepseek-ai/cordis';
|
|
34
|
-
import { LlmAdapter, type GenerateOptions, type LlmImageRequestPricing, type LlmModelInfo, type LlmResolvedModelInfo, type LlmRuntime, type StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
36
|
+
import { LlmAdapter, type GenerateOptions, type LlmImageRequestPricing, type LlmModelInfo, type LlmResolvedModelInfo, type LlmRuntime, type ResolvedRetryPolicy, type StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
35
37
|
import type { FallbacksConfig } from './config.ts';
|
|
36
38
|
/** Provider route of the virtual adapter (exact string, spec lock). */
|
|
37
39
|
export declare const FALLBACKS_PROVIDER = "FallbacksChain";
|
|
@@ -62,15 +64,33 @@ export interface EffectiveHead {
|
|
|
62
64
|
}
|
|
63
65
|
/**
|
|
64
66
|
* The FIRST DISPATCHABLE exact head of a chain — the single definition of
|
|
65
|
-
* "effective head" (F-001) shared by the
|
|
66
|
-
*
|
|
67
|
-
* chain `resolveEffectiveChain` produces,
|
|
67
|
+
* "effective head" (F-001) shared by the virtual adapter's delegate paths and
|
|
68
|
+
* the routing engine's served-route anchor (`anchorServedRoute` in
|
|
69
|
+
* `src/index.ts`). Walks the SAME chain `resolveEffectiveChain` produces,
|
|
70
|
+
* skipping entries that can never
|
|
68
71
|
* be dispatched: malformed selectors (config-warning path), `provider/*`
|
|
69
72
|
* `provider/*` wildcards (no real pair), and self-routes back to
|
|
70
73
|
* `FallbacksChain/*` (the P1 recursion guard). `undefined` when the chain
|
|
71
74
|
* is empty or no entry is dispatchable.
|
|
72
75
|
*/
|
|
73
76
|
export declare function firstDispatchableExactHead(chain: readonly string[]): EffectiveHead | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* The effective chain head at `now` (P1): the first DISPATCHABLE exact head
|
|
79
|
+
* of the SAME `resolveEffectiveChain` the routing engine uses — thin
|
|
80
|
+
* config+clock entry into the shared {@link firstDispatchableExactHead} (no
|
|
81
|
+
* divergent skip/walk rules). `undefined` when the chain is empty or no
|
|
82
|
+
* entry is dispatchable (wildcard, self-route to `FallbacksChain/*`,
|
|
83
|
+
* malformed selector).
|
|
84
|
+
*
|
|
85
|
+
* Conformance gate (PR #62 feedback): the all-day `rootChain` must be
|
|
86
|
+
* conforming (exactly one official model — Flash or Pro)
|
|
87
|
+
* for a successful delegate —
|
|
88
|
+
* a legacy multi-model (or empty) all-day chain earns no primary
|
|
89
|
+
* semantics even though the picker row is visible. `resolveModel` then
|
|
90
|
+
* falls back to the permissive default and `stream()` throws
|
|
91
|
+
* {@link UNDISPATCHABLE_HEAD_CODE}.
|
|
92
|
+
*/
|
|
93
|
+
export declare function effectiveHeadOf(config: FallbacksConfig, now: Date): EffectiveHead | undefined;
|
|
74
94
|
/**
|
|
75
95
|
* Host picker label: `Auto: <displayName>[<slot>]`.
|
|
76
96
|
* Display name first so the trigger stays readable and platforms stay
|
|
@@ -104,6 +124,22 @@ export declare class FallbacksChainAdapter extends LlmAdapter {
|
|
|
104
124
|
* answer for the CURRENT head. Permissive default otherwise; never throws.
|
|
105
125
|
*/
|
|
106
126
|
resolveModel(provider: string, model: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
|
|
127
|
+
/**
|
|
128
|
+
* Route-accurate retry attribution: the virtual row declares no policy of
|
|
129
|
+
* its own — the virtual `provider` argument is intentionally ignored. The
|
|
130
|
+
* host captures `adapter.providerRetryPolicy(provider) ??
|
|
131
|
+
* resolveRetryPolicy(void 0, …)` ONCE, when a route is registered, so
|
|
132
|
+
* answering here with the SAME policy the concrete head route declared
|
|
133
|
+
* (e.g. a user's `llm-deepseek.retryPolicy`, including `mode: 'always'`)
|
|
134
|
+
* keeps retries behaving exactly as they do on the head `stream()`
|
|
135
|
+
* dispatches. Never throws: an unresolvable head, a vanished `llm`, or an
|
|
136
|
+
* unregistered head provider degrades to `undefined` — the host's own
|
|
137
|
+
* default. That last arm matters: the runtime's lookup THROWS `NO_ADAPTER`
|
|
138
|
+
* for an unknown provider, and this call happens inside the plugin's
|
|
139
|
+
* `registerAdapter`, so an escaping throw would take the whole virtual
|
|
140
|
+
* route down instead of just degrading its policy.
|
|
141
|
+
*/
|
|
142
|
+
providerRetryPolicy(_provider: string): ResolvedRetryPolicy | undefined;
|
|
107
143
|
/**
|
|
108
144
|
* Route-accurate image pricing (0.1.2 adoption): the virtual row has no
|
|
109
145
|
* pricing of its own — the virtual `provider`/`model` arguments are
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"dsh",
|
|
6
6
|
"dsh-plugin"
|
|
7
7
|
],
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.5.0",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"main": "./dist/index.js",
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
@@ -47,9 +47,10 @@
|
|
|
47
47
|
"build-client": "tsx scripts/build-client.ts",
|
|
48
48
|
"release:prepare": "tsx scripts/prepare-release.ts",
|
|
49
49
|
"release:validate": "tsx scripts/validate-release-version.ts",
|
|
50
|
-
"repair:
|
|
50
|
+
"repair:session-logs": "tsx scripts/repair-session-logs.ts",
|
|
51
51
|
"test": "vitest run",
|
|
52
|
-
"typecheck": "tsc -p tsconfig.build.json --noEmit && tsc --noEmit",
|
|
52
|
+
"typecheck": "tsc -p tsconfig.build.json --noEmit && tsc --noEmit && pnpm run typecheck:scripts",
|
|
53
|
+
"typecheck:scripts": "tsc -p tsconfig.scripts.json",
|
|
53
54
|
"prepare": "pnpm run build"
|
|
54
55
|
},
|
|
55
56
|
"engines": {
|