dsh-opencode-go 0.1.10 → 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 +31 -4
- package/README.md +31 -4
- package/docs/verification.md +60 -2
- package/lib/client.js +258 -114
- package/lib/index.js +220 -70
- 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 +10 -1
- 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
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
|
};
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
/**
|
|
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. */
|
|
2
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
|
}
|