dsh-wtq-pool 0.0.0-stage → 1.0.2

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/lib/index.d.ts ADDED
@@ -0,0 +1,163 @@
1
+ import z from "@deepseek-ai/schemastery";
2
+ import { SettingsPathOp } from "@deepseek-ai/dsh-settings";
3
+ //#region src/host.d.ts
4
+ /**
5
+ * dsh-wtq-pool - the plugin's engine.
6
+ *
7
+ * Merges every WorkBuddy, Trae and Qoder desktop sign-in on this machine into
8
+ * one model pool that fails over on its own:
9
+ *
10
+ * 1. discover every sign-in on this machine (read-only),
11
+ * 2. serve each vendor edition from its own loopback OpenAI-compatible
12
+ * endpoint,
13
+ * 3. publish those endpoints as six providers,
14
+ * 4. rotate to the next account whenever the upstream answers 429.
15
+ *
16
+ * This file is the engine, not the entry: `index.ts` owns the Cordis
17
+ * activation and the provider registrations, and `pi-compat.ts` is the bridge
18
+ * between the two. Everything below is written against that bridge.
19
+ *
20
+ * Upstream traffic uses the platform `fetch` rather than a host network bridge:
21
+ * a bridged response is buffered into text, and a provider contract needs the
22
+ * upstream SSE body relayed as it arrives. Nothing leaves this machine except
23
+ * to the three vendors' own endpoints.
24
+ */
25
+ declare function onPanelInvoke(channel: any, payload: any): Promise<any>;
26
+ declare function onLoad(): Promise<void>;
27
+ declare function onUnload(): Promise<void>;
28
+ //#endregion
29
+ //#region src/index.d.ts
30
+ /** The Cordis row id; also the settings namespace this plugin is served under. */
31
+ declare const name = "llm-dsh-xdpool";
32
+ /**
33
+ * `settings` is declared so the host renders this plugin's own section instead
34
+ * of reading `undefined` while it builds the provider list; `llm` is the seam
35
+ * the six providers register into.
36
+ */
37
+ declare const inject: string[];
38
+ /**
39
+ * Every field is marked volatile.
40
+ *
41
+ * The settings write gate refuses an entry whose schema declares no volatile
42
+ * field at all, and `describe()` skips such an entry, so an unmarked schema
43
+ * means the card can neither render nor save. Reading a volatile field hands
44
+ * back the live value once peeled (see {@link unwrapVolatile}).
45
+ */
46
+ interface Config {
47
+ /** Master switch. A missing value reads as enabled. */
48
+ enabled?: boolean;
49
+ /** Per-vendor switches; a vendor whose switch is off gets no gateway. */
50
+ sourceWorkbuddy?: boolean;
51
+ sourceTrae?: boolean;
52
+ sourceQoder?: boolean;
53
+ /** Explicit WorkBuddy desktop auth-file path override. */
54
+ authFile?: string;
55
+ /** Daily check-in: whether it runs, and at which local hours. */
56
+ autoCheckin?: {
57
+ enabled?: boolean;
58
+ hours?: number[];
59
+ };
60
+ /** Rate-limit cooldown per account, in seconds. */
61
+ cooldownSeconds?: number;
62
+ /** Per-account credit floor, keyed by account id. */
63
+ creditReserves?: Record<string, number>;
64
+ /** Account ids switched off on the panel. */
65
+ disabledAccountIds?: string[];
66
+ /** Regions parked on their own, as `source:region` keys. */
67
+ disabledRegions?: string[];
68
+ /** How the WorkBuddy pool spreads requests. */
69
+ distribution?: 'priority' | 'round-robin' | 'expiry' | 'sticky';
70
+ /** Per-gateway model selection, keyed by gateway. */
71
+ modelSelection?: Record<string, unknown>;
72
+ /** Picked WorkBuddy account per region. */
73
+ preferredAccountIds?: Record<string, string>;
74
+ /** Picked Trae/Qoder account per region. */
75
+ preferredSourceAccounts?: Record<string, string>;
76
+ /** Accounts removed from the pool for good, with their label kept. */
77
+ removedAccounts?: unknown[];
78
+ /** Whether the credits readout is shown beside the composer. */
79
+ showComposerPoints?: boolean;
80
+ /** How each Trae/Qoder region spreads requests. */
81
+ sourceDistributions?: Record<string, string>;
82
+ }
83
+ declare const Config: z<Config>;
84
+ /**
85
+ * The slice of `ctx.llm` this plugin uses.
86
+ *
87
+ * Declared structurally rather than imported so the same source still compiles
88
+ * against a host that predates one of the calls. The return types mirror the
89
+ * published handles: both registrations hand back a disposer (the real ones also
90
+ * carry `replace`, which this plugin does not use), and `registerModelDiscovery`
91
+ * returns the disposer the activation effect relies on. Calling any of them
92
+ * after the fiber is disposed throws, so a stale write cannot leave an orphan.
93
+ */
94
+ interface LlmSeam {
95
+ registerAdapter(providerIds: string[], adapter: unknown): () => void;
96
+ registerConfigurableProviders(rows: Array<{
97
+ provider: string;
98
+ displayName: string;
99
+ settingsNs: string;
100
+ settingsPath: string[];
101
+ declared: boolean;
102
+ }>): () => void;
103
+ registerModelDiscovery(ns: string, fn: (request: {
104
+ provider?: string;
105
+ }, signal?: AbortSignal) => Promise<Array<{
106
+ id: string;
107
+ name: string;
108
+ contextWindow?: number;
109
+ maxTokens?: number;
110
+ inputModalities?: string[];
111
+ }>>): () => void;
112
+ }
113
+ interface SettingsService {
114
+ configure?(presentation: {
115
+ auto?: boolean;
116
+ }, owner?: unknown): (() => void) | undefined;
117
+ mutate?(ns: string, ops: readonly SettingsPathOp[], expectedRevision?: number): Promise<void> | void;
118
+ }
119
+ interface RegisterCommandResult {
120
+ kind: 'success' | 'error';
121
+ text?: string;
122
+ }
123
+ interface CommandsService {
124
+ register(definition: {
125
+ name: string;
126
+ description: string;
127
+ handler: () => RegisterCommandResult | Promise<RegisterCommandResult>;
128
+ }): (() => void) | undefined;
129
+ }
130
+ interface ClientContext {
131
+ llm: LlmSeam;
132
+ settings: SettingsService;
133
+ commands?: CommandsService;
134
+ logger: {
135
+ info?(...args: unknown[]): void;
136
+ warn(...args: unknown[]): void;
137
+ error(...args: unknown[]): void;
138
+ };
139
+ effect(callback: () => unknown, label?: string): unknown;
140
+ inject(names: string[], callback: (scoped: ClientContext) => unknown): unknown;
141
+ on(name: string, listener: (...args: unknown[]) => void): (() => void) | undefined;
142
+ off?(name: string, listener: (...args: unknown[]) => void): void;
143
+ get(name: string): unknown;
144
+ emit(name: string, ...args: unknown[]): void;
145
+ fiber?: {
146
+ entry?: {
147
+ id?: unknown;
148
+ options?: {
149
+ id?: string;
150
+ };
151
+ };
152
+ };
153
+ }
154
+ /**
155
+ * Activate the plugin.
156
+ *
157
+ * Order matters: the core's `onLoad` builds the pool and the account client,
158
+ * its registered background service brings the gateways up, and the declaration
159
+ * pass that follows is what hands the six rows to {@link LlmSeam}.
160
+ */
161
+ declare function apply(ctx: ClientContext, config?: Config): void;
162
+ //#endregion
163
+ export { Config, apply, inject, name, onLoad, onPanelInvoke, onUnload };