dsh-opencode-go 0.1.9 → 0.1.11
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.en.md +36 -7
- package/README.md +36 -7
- package/docs/verification.md +77 -1
- package/lib/client.js +258 -114
- package/lib/index.js +257 -49
- package/lib/types/catalog.d.ts +5 -3
- package/lib/types/client/ModelEditor.d.ts +6 -2
- package/lib/types/client/Section.d.ts +2 -0
- package/lib/types/client/UsagePill.d.ts +1 -0
- package/lib/types/client/locales.d.ts +14 -2
- package/lib/types/client/section-controller.d.ts +16 -11
- package/lib/types/config.d.ts +5 -5
- package/lib/types/json-response.d.ts +11 -0
- package/lib/types/models-contract.d.ts +12 -1
- package/lib/types/models.d.ts +3 -2
- package/lib/types/usage-contract.d.ts +9 -0
- package/lib/types/usage.d.ts +1 -0
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
12
12
|
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol';
|
|
13
|
-
import type { GoModel } from '../models-contract.ts';
|
|
13
|
+
import type { GoModel, GoModelCatalog } from '../models-contract.ts';
|
|
14
14
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
15
15
|
import type { SettingsScope } from './settings.ts';
|
|
16
16
|
import { type FieldState, type FormActions, type FormShell } from './staged-form.ts';
|
|
@@ -20,8 +20,8 @@ export declare const OPENCODE_GO_NS = "llm-opencode-go";
|
|
|
20
20
|
export interface OpencodeGoSettings {
|
|
21
21
|
/** Whether the adapter serves its route; false withdraws it from every picker. */
|
|
22
22
|
enabled?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
|
|
23
|
+
/** Per-model switches; normal models default on, deprecated models default off. */
|
|
24
|
+
modelVisibility?: Record<string, boolean>;
|
|
25
25
|
/** Credential reference naming the environment key. */
|
|
26
26
|
apiKeyEnv?: string;
|
|
27
27
|
/** The gateway endpoint; also the live listing base. */
|
|
@@ -64,11 +64,14 @@ export type OpencodeGoModels =
|
|
|
64
64
|
readonly count: number;
|
|
65
65
|
readonly preview: readonly string[];
|
|
66
66
|
readonly entries: readonly GoModel[];
|
|
67
|
+
readonly stale?: boolean;
|
|
68
|
+
readonly message?: string;
|
|
69
|
+
readonly refreshing?: boolean;
|
|
67
70
|
}
|
|
68
71
|
/** The listing could not be read; `message` is the Host's own diagnostic. */
|
|
69
72
|
| {
|
|
70
73
|
readonly status: 'failed';
|
|
71
|
-
readonly message
|
|
74
|
+
readonly message?: string;
|
|
72
75
|
};
|
|
73
76
|
/** What the settings page renders. */
|
|
74
77
|
export interface OpencodeGoSectionState extends FormShell {
|
|
@@ -78,7 +81,7 @@ export interface OpencodeGoSectionState extends FormShell {
|
|
|
78
81
|
* a withdrawn route is what the user is trying to observe.
|
|
79
82
|
*/
|
|
80
83
|
enabled: boolean;
|
|
81
|
-
|
|
84
|
+
modelVisibility: Readonly<Record<string, boolean>>;
|
|
82
85
|
pickerSaving: boolean;
|
|
83
86
|
pickerFailed: boolean;
|
|
84
87
|
/** Credential reference naming the environment key. */
|
|
@@ -121,7 +124,7 @@ export interface OpencodeGoSectionFace extends FormActions {
|
|
|
121
124
|
* @param next - the state the switch asks for.
|
|
122
125
|
*/
|
|
123
126
|
setEnabled: (next: boolean) => void;
|
|
124
|
-
|
|
127
|
+
setModelEnabled: (id: string, next: boolean) => void;
|
|
125
128
|
}
|
|
126
129
|
/** Bridges the `llm-opencode-go` scope and the credentials domain onto the page. */
|
|
127
130
|
export declare class OpencodeGoSectionController {
|
|
@@ -142,7 +145,7 @@ export declare class OpencodeGoSectionController {
|
|
|
142
145
|
* @param ctx - the page plugin's context, whose `remote.credentials` namespace
|
|
143
146
|
* answers for the credential the section references.
|
|
144
147
|
*/
|
|
145
|
-
constructor(scope: SettingsScope<OpencodeGoSettings>, ctx: ClientContext, readModels?: () => Promise<RemoteResult<
|
|
148
|
+
constructor(scope: SettingsScope<OpencodeGoSettings>, ctx: ClientContext, readModels?: () => Promise<RemoteResult<GoModelCatalog>>);
|
|
146
149
|
/** Release subscriptions without disposing the host's shared form. */
|
|
147
150
|
dispose(): void;
|
|
148
151
|
private projection;
|
|
@@ -161,7 +164,7 @@ export declare class OpencodeGoSectionController {
|
|
|
161
164
|
/**
|
|
162
165
|
* Flip the switch by writing the field on the click itself.
|
|
163
166
|
*
|
|
164
|
-
*
|
|
167
|
+
* Like the per-model switches, this control does not wait for Save: the point
|
|
165
168
|
* of turning it off is to watch the models leave the pickers, and the point
|
|
166
169
|
* of turning it back on is to use the route again — staging either behind a
|
|
167
170
|
* second gesture would report a state the Host does not hold. The write is
|
|
@@ -169,9 +172,11 @@ export declare class OpencodeGoSectionController {
|
|
|
169
172
|
* failed save through the shared shell rather than a silent revert.
|
|
170
173
|
* @param next - the state the switch asks for.
|
|
171
174
|
*/
|
|
172
|
-
setEnabled(next: boolean): void
|
|
173
|
-
/**
|
|
174
|
-
|
|
175
|
+
setEnabled(next: boolean): Promise<void>;
|
|
176
|
+
/** Each model switch has one committed value and takes effect without Save. */
|
|
177
|
+
setModelEnabled(id: string, next: boolean): Promise<void>;
|
|
178
|
+
/** Serialize immediate switches with form saves; refused writes retain committed values. */
|
|
179
|
+
private writePickerSetting;
|
|
175
180
|
/**
|
|
176
181
|
* Read the gateway's model listing through the Host's discovery for this
|
|
177
182
|
* adapter. Called when the page mounts and again from its refresh control.
|
package/lib/types/config.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import z from '@deepseek-ai/schemastery';
|
|
12
12
|
/** Environment variable resolving the OpenCode API key. */
|
|
13
13
|
export declare const DEFAULT_API_KEY_ENV = "OPENCODE_API_KEY";
|
|
14
|
-
/**
|
|
14
|
+
/** Requests and pickers share this cache lifetime; explicit discovery revalidates immediately. */
|
|
15
15
|
export declare const DEFAULT_REFRESH_MINUTES = 60;
|
|
16
16
|
/** Default maximum idle interval while a stream read is outstanding. */
|
|
17
17
|
export declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300000;
|
|
@@ -38,13 +38,13 @@ export interface OpencodeGoConfig {
|
|
|
38
38
|
* false registers nothing.
|
|
39
39
|
*/
|
|
40
40
|
enabled: boolean;
|
|
41
|
-
/**
|
|
42
|
-
|
|
41
|
+
/** Per-model picker switches; absent entries default to enabled unless deprecated. */
|
|
42
|
+
modelVisibility?: Record<string, boolean>;
|
|
43
43
|
/** Credential reference: the environment variable the key resolves from. */
|
|
44
44
|
apiKeyEnv: string;
|
|
45
45
|
/** The gateway endpoint; also the base of the live model listing. */
|
|
46
46
|
baseURL: string;
|
|
47
|
-
/**
|
|
47
|
+
/** Request/picker cache lifetime in minutes; explicit discovery bypasses it. */
|
|
48
48
|
refreshMinutes: number;
|
|
49
49
|
/** Largest idle gap between stream events before the request fails. */
|
|
50
50
|
streamIdleTimeoutMs: number;
|
|
@@ -61,7 +61,7 @@ export interface OpencodeGoConfig {
|
|
|
61
61
|
export declare const PlainConfig: z<OpencodeGoConfig>;
|
|
62
62
|
/** 0.1.7's Loader retains these references when profile fields change. */
|
|
63
63
|
export type LiveConfig = {
|
|
64
|
-
[K in keyof OpencodeGoConfig]
|
|
64
|
+
[K in keyof OpencodeGoConfig]-?: {
|
|
65
65
|
get(): OpencodeGoConfig[K];
|
|
66
66
|
};
|
|
67
67
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Describe transport failures without echoing credentials or upstream response text. */
|
|
2
|
+
export declare function transportFailure(error: unknown): string;
|
|
3
|
+
/** Keep the endpoint useful in diagnostics without user information or query secrets. */
|
|
4
|
+
export declare function diagnosticURL(raw: string): string;
|
|
5
|
+
/** The caller's signal covers both attempts, the retry delay, and all response reads. */
|
|
6
|
+
export declare function fetchJsonResponse(url: string, init: RequestInit, maxBytes: number): Promise<{
|
|
7
|
+
response: Response;
|
|
8
|
+
body: unknown;
|
|
9
|
+
}>;
|
|
10
|
+
/** Fetch handles HTTP decoding; this reader bounds the bytes it delivers. */
|
|
11
|
+
export declare function readJsonResponse(response: Response, maxBytes: number): Promise<unknown>;
|
|
@@ -7,16 +7,27 @@ export interface GoModel {
|
|
|
7
7
|
maxTokens?: number;
|
|
8
8
|
deprecated?: boolean;
|
|
9
9
|
releaseDate?: string;
|
|
10
|
+
/** Advertised by the gateway but lacking a usable protocol and capability configuration. */
|
|
11
|
+
configurationMissing?: boolean;
|
|
10
12
|
}
|
|
13
|
+
/** A failed refresh retains the Host's last successful listing with an explicit diagnostic. */
|
|
14
|
+
export interface GoModelCatalog {
|
|
15
|
+
readonly models: readonly GoModel[];
|
|
16
|
+
readonly stale: boolean;
|
|
17
|
+
readonly error?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Missing configuration cannot be enabled; configured models follow explicit switches or lifecycle defaults. */
|
|
20
|
+
export declare function isModelEnabled(model: Pick<GoModel, 'id' | 'deprecated' | 'configurationMissing'>, modelVisibility?: Readonly<Record<string, boolean>>): boolean;
|
|
11
21
|
export declare function validReleaseDate(value: unknown): value is string;
|
|
12
22
|
/** Calendar dates are supplied without a timezone; compare UTC dates consistently. */
|
|
13
23
|
export declare function isNewModel(model: GoModel, now?: number): boolean;
|
|
14
24
|
export declare function sortModels(models: readonly GoModel[], now?: number): GoModel[];
|
|
15
25
|
export declare function parseGoModels(value: unknown): GoModel[];
|
|
26
|
+
export declare function parseGoModelCatalog(value: unknown): GoModelCatalog;
|
|
16
27
|
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
17
28
|
interface TypertRemoteNamespaceMap {
|
|
18
29
|
opencodeGoModels: {
|
|
19
|
-
read(): Promise<RemoteResult<
|
|
30
|
+
read(): Promise<RemoteResult<GoModelCatalog>>;
|
|
20
31
|
};
|
|
21
32
|
}
|
|
22
33
|
}
|
package/lib/types/models.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
3
3
|
import { type OpencodeGoCatalog } from './catalog.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { GoModelCatalog } from './models-contract.ts';
|
|
5
5
|
/** Uses the same gateway snapshot as the adapter, including models hidden from pickers. */
|
|
6
6
|
export declare class GoModelsService extends TypertRemoteService {
|
|
7
7
|
private readonly options;
|
|
8
8
|
constructor(ctx: Context, options: {
|
|
9
9
|
catalog: () => OpencodeGoCatalog;
|
|
10
|
+
onRefresh?: () => void;
|
|
10
11
|
});
|
|
11
|
-
read(): Promise<
|
|
12
|
+
read(): Promise<GoModelCatalog>;
|
|
12
13
|
}
|
|
@@ -5,6 +5,8 @@ export interface UsageWindow {
|
|
|
5
5
|
resetsAt: string;
|
|
6
6
|
}
|
|
7
7
|
export interface GoUsage {
|
|
8
|
+
/** Opaque Host identity for this endpoint/account; never a credential or its hash. */
|
|
9
|
+
source?: string;
|
|
8
10
|
rolling: UsageWindow;
|
|
9
11
|
weekly: UsageWindow;
|
|
10
12
|
monthly: UsageWindow;
|
|
@@ -12,6 +14,13 @@ export interface GoUsage {
|
|
|
12
14
|
/** Reject missing statistics rather than turning unavailable data into zero. */
|
|
13
15
|
export declare function parseGoUsage(value: unknown): GoUsage;
|
|
14
16
|
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
17
|
+
interface RemoteErrorDetailsMap {
|
|
18
|
+
'opencode-go/usage-unavailable': {
|
|
19
|
+
readonly retryable: boolean;
|
|
20
|
+
readonly retainPrevious: boolean;
|
|
21
|
+
readonly source?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
15
24
|
interface TypertRemoteNamespaceMap {
|
|
16
25
|
opencodeGoUsage: {
|
|
17
26
|
read(): Promise<RemoteResult<GoUsage>>;
|
package/lib/types/usage.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ interface UsageOptions {
|
|
|
8
8
|
/** Account statistics are fetched on the Host; credentials never enter the browser. */
|
|
9
9
|
export declare class GoUsageService extends TypertRemoteService {
|
|
10
10
|
private readonly options;
|
|
11
|
+
private identity?;
|
|
11
12
|
constructor(ctx: Context, options: UsageOptions);
|
|
12
13
|
read(): Promise<GoUsage>;
|
|
13
14
|
}
|