dsh-lowtide 0.2.1 → 0.2.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/LICENSE +21 -0
- package/README.md +168 -166
- package/cordis.patch.yml +47 -39
- package/lib/client.js +1519 -287
- package/lib/client.js.map +1 -1
- package/lib/index.js +199 -67
- package/lib/types/client/api.d.ts +3 -1
- package/lib/types/client/components/InterceptCard.d.ts +3 -0
- package/lib/types/client/components/atoms.d.ts +7 -0
- package/lib/types/client/i18n.d.ts +4 -0
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/lib/tierClock.d.ts +81 -0
- package/lib/types/client/store.d.ts +34 -1
- package/lib/types/src/models.d.ts +5 -1
- package/lib/types/src/routes.d.ts +8 -0
- package/lib/types/src/runner.d.ts +3 -3
- package/package.json +36 -37
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import type { WindowCfg } from 'lowtide-core';
|
|
2
|
+
import { type TierSnapshot } from './lib/tierClock.ts';
|
|
3
|
+
/** Re-exported so components (the pill) share one staleness definition. */
|
|
4
|
+
export { SSE_STALE_MS } from './lib/tierClock.ts';
|
|
1
5
|
export interface HostState {
|
|
2
6
|
ok: boolean;
|
|
3
7
|
time: string;
|
|
8
|
+
/** Snapshot instant (epoch ms) — lets the client spot clock skew. */
|
|
9
|
+
serverNow?: number;
|
|
4
10
|
autonomy: string;
|
|
5
11
|
level: {
|
|
6
12
|
level: string;
|
|
@@ -12,8 +18,12 @@ export interface HostState {
|
|
|
12
18
|
end: string;
|
|
13
19
|
};
|
|
14
20
|
} | null;
|
|
21
|
+
/** Raw effective windows (own tz/days) — the client tier clock's input. */
|
|
22
|
+
windows?: WindowCfg[];
|
|
15
23
|
price: {
|
|
16
24
|
model: string;
|
|
25
|
+
/** Billing id after alias/route resolution (optional on older hosts). */
|
|
26
|
+
priceModel?: string;
|
|
17
27
|
input: number;
|
|
18
28
|
inputCached: number;
|
|
19
29
|
output: number;
|
|
@@ -28,6 +38,8 @@ export interface HostState {
|
|
|
28
38
|
offInput: number;
|
|
29
39
|
offOutput: number;
|
|
30
40
|
};
|
|
41
|
+
/** Billing notice for the selected model (e.g. V4 Pro retired → Flash). */
|
|
42
|
+
priceNotice?: string | null;
|
|
31
43
|
nextBatchAt: number;
|
|
32
44
|
countdownMs: number;
|
|
33
45
|
nextOffPeakAt: number | null;
|
|
@@ -40,6 +52,8 @@ export interface HostState {
|
|
|
40
52
|
end: string;
|
|
41
53
|
crossesDay: boolean;
|
|
42
54
|
}>;
|
|
55
|
+
/** True when the saved windows drifted from the official schedule. */
|
|
56
|
+
officialDrift?: boolean;
|
|
43
57
|
batch: {
|
|
44
58
|
window: string;
|
|
45
59
|
paused: boolean;
|
|
@@ -177,12 +191,31 @@ export interface ClientUiState {
|
|
|
177
191
|
lastReportId: string | null;
|
|
178
192
|
/** Active locale id ('zh' | 'en'), synced from the host locale service. */
|
|
179
193
|
activeLocale: string;
|
|
194
|
+
/**
|
|
195
|
+
* Tier derived from the local clock + the host's windows. This is what the
|
|
196
|
+
* pill and the intercept card DISPLAY, so a stalled stream can never freeze
|
|
197
|
+
* 闲时/忙时; the host's `price.tier` stays the pricing/ledger authority.
|
|
198
|
+
*/
|
|
199
|
+
tier: TierSnapshot;
|
|
200
|
+
/** When `tier` was last derived (epoch ms). */
|
|
201
|
+
tierAt: number;
|
|
202
|
+
/** Newest state frame seen from either transport (epoch ms, 0 = never). */
|
|
203
|
+
lastFrameAt: number;
|
|
204
|
+
/** False while the live push is silent/absent and polling carries the UI. */
|
|
205
|
+
sseHealthy: boolean;
|
|
180
206
|
}
|
|
181
|
-
export declare const lowtideStore: import("@deepseek-ai/dsh-client-
|
|
207
|
+
export declare const lowtideStore: import("@deepseek-ai/dsh-client-store").SnapshotStore<ClientUiState>;
|
|
182
208
|
export declare function showToast(text: string): void;
|
|
183
209
|
export declare function clearToast(): void;
|
|
210
|
+
/** Reset the UI slice (plugin unload) — the full field list lives here so a
|
|
211
|
+
* new field can never be forgotten by a caller's hand-written literal. */
|
|
212
|
+
export declare function resetUiState(): void;
|
|
184
213
|
/** Trigger one immediate poll (used after write actions for fast refresh). */
|
|
185
214
|
export declare function refreshNow(): void;
|
|
215
|
+
/** Re-derive the displayed tier right now (after a window edit, say). */
|
|
216
|
+
export declare function refreshTier(): void;
|
|
217
|
+
/** Feed the clock from a config payload when no host frame is available yet. */
|
|
218
|
+
export declare function setTierWindows(windows: WindowCfg[] | null, tz?: string | null): void;
|
|
186
219
|
export declare function startPolling(): () => void;
|
|
187
220
|
export declare function useHost<T>(selector: (host: HostState) => T): T | undefined;
|
|
188
221
|
export declare function useLowtide<T>(selector: (state: ClientUiState) => T): T;
|
|
@@ -12,8 +12,10 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
12
12
|
export interface AvailableModel {
|
|
13
13
|
id: string;
|
|
14
14
|
name: string;
|
|
15
|
-
/** Whether this model has an official/override price entry (
|
|
15
|
+
/** Whether this model has an official/override price entry (aliases count). */
|
|
16
16
|
priceKnown: boolean;
|
|
17
|
+
/** The id that actually gets billed (legacy alias / dated route resolved). */
|
|
18
|
+
priceModel: string;
|
|
17
19
|
/** Adapter-declared input modalities (e.g. ["text", "image"]) — optional. */
|
|
18
20
|
inputModalities?: string[];
|
|
19
21
|
/** Supported reasoning efforts with the adapter's native labels. */
|
|
@@ -24,6 +26,8 @@ export interface AvailableModel {
|
|
|
24
26
|
}>;
|
|
25
27
|
/** The model's default reasoning effort id, when the adapter declares one. */
|
|
26
28
|
defaultReasoningEffort?: string;
|
|
29
|
+
/** Billing notice (e.g. a retired model routed to a cheaper one). */
|
|
30
|
+
notice?: string;
|
|
27
31
|
}
|
|
28
32
|
export interface AvailableProvider {
|
|
29
33
|
provider: string;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* loopback only and the README deployment guidance (SSH tunnel) is Phase 4.
|
|
6
6
|
*/
|
|
7
7
|
import type { Context } from '@deepseek-ai/cordis';
|
|
8
|
+
import { type WindowCfg, type WindowLocal } from 'lowtide-core';
|
|
8
9
|
import type { Scheduler } from './scheduler.ts';
|
|
9
10
|
import { LowtideStore } from './store.ts';
|
|
10
11
|
export type { TriageAction } from './state-machine.ts';
|
|
@@ -14,3 +15,10 @@ export interface Routes {
|
|
|
14
15
|
scheduler: Scheduler;
|
|
15
16
|
}
|
|
16
17
|
export declare function registerRoutes(ctx: Context, routes: Routes): void;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the configured peak windows still match the official schedule
|
|
20
|
+
* (official hours converted into this machine's clock). A mismatch means
|
|
21
|
+
* DeepSeek changed its peak hours since the user last adopted them, and the
|
|
22
|
+
* UI offers a one-click re-adopt instead of silently billing on stale hours.
|
|
23
|
+
*/
|
|
24
|
+
export declare function officialScheduleDrift(configured: WindowCfg[], officialLocal: WindowLocal[]): boolean;
|
|
@@ -32,9 +32,9 @@ type PriceTable = Record<string, {
|
|
|
32
32
|
};
|
|
33
33
|
}>;
|
|
34
34
|
/** Hypothetical peak-hour cost of a usage — the "what you saved" baseline.
|
|
35
|
-
* Only models with a real price entry (official table
|
|
36
|
-
* deepseek-v4-flash-vision-exp
|
|
37
|
-
* anything else yields 0 so no fake savings are
|
|
35
|
+
* Only models with a real price entry (the official table — including legacy
|
|
36
|
+
* aliases such as deepseek-v4-flash-vision-exp — or a user price override)
|
|
37
|
+
* get a baseline; anything else yields 0 so no fake savings are reported. */
|
|
38
38
|
export declare function peakCostOf(usage: UsageLike, modelId: string, prices: PriceTable | undefined): number;
|
|
39
39
|
/** Retrying a quota/balance rejection is pointless (and costly): the account
|
|
40
40
|
* state cannot change inside one batch. Matches deepseek's 402 payload. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-lowtide",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "lowtide: human-adjudicated off-peak batch task pipeline for dsh (peak/valley pricing aware)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -23,11 +23,8 @@
|
|
|
23
23
|
"client": {
|
|
24
24
|
"inject": [
|
|
25
25
|
"@deepseek-ai/dsh-client-locale",
|
|
26
|
-
"@deepseek-ai/dsh-client-runtime",
|
|
27
26
|
"@deepseek-ai/dsh-client-ui-conversation",
|
|
28
|
-
"@deepseek-ai/dsh-client-ui-primitives",
|
|
29
27
|
"@deepseek-ai/dsh-client-ui-settings",
|
|
30
|
-
"@deepseek-ai/dsh-client-ui-slots",
|
|
31
28
|
"@deepseek-ai/dsh-client-connection"
|
|
32
29
|
],
|
|
33
30
|
"platform": "web"
|
|
@@ -40,13 +37,6 @@
|
|
|
40
37
|
"lib/types/**/*.d.ts",
|
|
41
38
|
"cordis.patch.yml"
|
|
42
39
|
],
|
|
43
|
-
"scripts": {
|
|
44
|
-
"bundle": "tsdown && tsc -p tsconfig.build.json",
|
|
45
|
-
"watch": "tsdown --watch",
|
|
46
|
-
"typecheck": "tsc --noEmit",
|
|
47
|
-
"test": "vitest run",
|
|
48
|
-
"dev": "npx @deepseek-ai/dsh@0.1.0-rc.7 web --patch ./cordis.dev.yml"
|
|
49
|
-
},
|
|
50
40
|
"license": "MIT",
|
|
51
41
|
"keywords": [
|
|
52
42
|
"dsh-plugin",
|
|
@@ -65,41 +55,50 @@
|
|
|
65
55
|
"directory": "packages/dsh-lowtide"
|
|
66
56
|
},
|
|
67
57
|
"peerDependencies": {
|
|
68
|
-
"@deepseek-ai/dsh-agent": "^0.1.
|
|
69
|
-
"@deepseek-ai/dsh-llm": "^0.1.
|
|
70
|
-
"@deepseek-ai/dsh-session": "^0.1.
|
|
71
|
-
"@deepseek-ai/dsh-settings": "^0.1.
|
|
72
|
-
"@deepseek-ai/dsh-storage-domain": "^0.1.
|
|
58
|
+
"@deepseek-ai/dsh-agent": "^0.1.5-rc.1",
|
|
59
|
+
"@deepseek-ai/dsh-llm": "^0.1.5-rc.1",
|
|
60
|
+
"@deepseek-ai/dsh-session": "^0.1.5-rc.1",
|
|
61
|
+
"@deepseek-ai/dsh-settings": "^0.1.5-rc.1",
|
|
62
|
+
"@deepseek-ai/dsh-storage-domain": "^0.1.5-rc.1"
|
|
73
63
|
},
|
|
74
64
|
"devDependencies": {
|
|
75
65
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
76
|
-
"@deepseek-ai/dsh-agent": "^0.1.
|
|
77
|
-
"@deepseek-ai/dsh-agent-default-model": "^0.1.
|
|
78
|
-
"@deepseek-ai/dsh-agent-presets": "0.1.
|
|
79
|
-
"@deepseek-ai/dsh-client-connection": "^0.1.
|
|
80
|
-
"@deepseek-ai/dsh-client-locale": "^0.1.
|
|
81
|
-
"@deepseek-ai/dsh-client-
|
|
82
|
-
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.
|
|
83
|
-
"@deepseek-ai/dsh-client-ui-layout": "0.1.
|
|
84
|
-
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.
|
|
85
|
-
"@deepseek-ai/dsh-client-ui-
|
|
86
|
-
"@deepseek-ai/dsh-client-ui-
|
|
87
|
-
"@deepseek-ai/dsh-
|
|
88
|
-
"@deepseek-ai/dsh-host-webserver": "^0.1.
|
|
89
|
-
"@deepseek-ai/dsh-llm": "^0.1.
|
|
90
|
-
"@deepseek-ai/dsh-permission-presets": "^0.1.
|
|
91
|
-
"@deepseek-ai/dsh-session": "^0.1.
|
|
92
|
-
"@deepseek-ai/dsh-settings": "^0.1.
|
|
93
|
-
"@deepseek-ai/dsh-storage-domain": "^0.1.
|
|
66
|
+
"@deepseek-ai/dsh-agent": "^0.1.5-rc.1",
|
|
67
|
+
"@deepseek-ai/dsh-agent-default-model": "^0.1.5-rc.1",
|
|
68
|
+
"@deepseek-ai/dsh-agent-presets": "^0.1.5-rc.1",
|
|
69
|
+
"@deepseek-ai/dsh-client-connection": "^0.1.5-rc.1",
|
|
70
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.5-rc.1",
|
|
71
|
+
"@deepseek-ai/dsh-client-store": "^0.1.5-rc.1",
|
|
72
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.5-rc.1",
|
|
73
|
+
"@deepseek-ai/dsh-client-ui-layout": "^0.1.5-rc.1",
|
|
74
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.5-rc.1",
|
|
75
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.1.5-rc.1",
|
|
76
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.1.5-rc.1",
|
|
77
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.5-rc.1",
|
|
78
|
+
"@deepseek-ai/dsh-host-webserver": "^0.1.5-rc.1",
|
|
79
|
+
"@deepseek-ai/dsh-llm": "^0.1.5-rc.1",
|
|
80
|
+
"@deepseek-ai/dsh-permission-presets": "^0.1.5-rc.1",
|
|
81
|
+
"@deepseek-ai/dsh-session": "^0.1.5-rc.1",
|
|
82
|
+
"@deepseek-ai/dsh-settings": "^0.1.5-rc.1",
|
|
83
|
+
"@deepseek-ai/dsh-storage-domain": "^0.1.5-rc.1",
|
|
94
84
|
"@playwright/test": "^1.62.1",
|
|
95
85
|
"@types/node": "^22.20.0",
|
|
96
86
|
"@types/react": "~18.3.1",
|
|
87
|
+
"immer": "^10.1.1",
|
|
97
88
|
"lightningcss": "^1.32.0",
|
|
98
|
-
"lowtide-core": "workspace:*",
|
|
99
89
|
"react": "^18.2.0",
|
|
100
90
|
"tsdown": "^0.22.2",
|
|
101
91
|
"typescript": "^6.0.3",
|
|
102
92
|
"vitest": "^4.1.8",
|
|
103
|
-
"zod": "^4.4.3"
|
|
93
|
+
"zod": "^4.4.3",
|
|
94
|
+
"zustand": "~4.4.7",
|
|
95
|
+
"lowtide-core": "0.2.3"
|
|
96
|
+
},
|
|
97
|
+
"scripts": {
|
|
98
|
+
"bundle": "tsdown && tsc -p tsconfig.build.json",
|
|
99
|
+
"watch": "tsdown --watch",
|
|
100
|
+
"typecheck": "tsc --noEmit",
|
|
101
|
+
"test": "vitest run",
|
|
102
|
+
"dev": "npx @deepseek-ai/dsh@0.1.5-rc.1 web --patch ./cordis.dev.yml"
|
|
104
103
|
}
|
|
105
|
-
}
|
|
104
|
+
}
|