dsh-opencode-go 0.1.21 → 0.1.23
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 +1 -0
- package/README.en.md +74 -194
- package/README.md +73 -184
- package/THIRD_PARTY_NOTICES.md +7 -1
- package/docs/advanced.en.md +137 -0
- package/docs/advanced.md +135 -0
- package/docs/assets/accounts.png +0 -0
- package/docs/assets/advanced-settings.png +0 -0
- package/docs/assets/model-settings.png +0 -0
- package/docs/assets/usage-panel.png +0 -0
- package/docs/development.md +65 -7
- package/docs/fork-review-2026-09-25.md +191 -0
- package/docs/independent-package.md +2 -2
- package/docs/verification.md +283 -0
- package/lib/build-info.json +8 -1
- package/lib/client.js +830 -635
- package/lib/index.js +52687 -856
- package/lib/types/account-manager.d.ts +25 -0
- package/lib/types/account-operations.d.ts +31 -0
- package/lib/types/account-policy.d.ts +16 -0
- package/lib/types/account-recovery.d.ts +2 -0
- package/lib/types/account-selection.d.ts +30 -0
- package/lib/types/account-service.d.ts +12 -0
- package/lib/types/accounts-contract.d.ts +38 -0
- package/lib/types/accounts.d.ts +8 -1
- package/lib/types/adapter.d.ts +33 -11
- package/lib/types/call-trace.d.ts +54 -0
- package/lib/types/catalog-manager.d.ts +20 -0
- package/lib/types/catalog.d.ts +6 -4
- package/lib/types/client/accounts-controller.d.ts +8 -17
- package/lib/types/client/hint-mark.d.ts +17 -0
- package/lib/types/client/host-compat.d.ts +7 -0
- package/lib/types/client/host-primitives.d.ts +11 -0
- package/lib/types/client/locales.d.ts +14 -3
- package/lib/types/client/section-controller.d.ts +11 -48
- package/lib/types/client/staged-form.d.ts +1 -3
- package/lib/types/client/usage.d.ts +1 -1
- package/lib/types/config-contract.d.ts +70 -0
- package/lib/types/config.d.ts +13 -54
- package/lib/types/conversion/context.d.ts +5 -1
- package/lib/types/conversion/image-pool.d.ts +24 -0
- package/lib/types/conversion/replay.d.ts +1 -1
- package/lib/types/conversion/stream.d.ts +1 -1
- package/lib/types/gateway-diagnostics.d.ts +22 -0
- package/lib/types/gateway-error.d.ts +2 -0
- package/lib/types/gateway-url.d.ts +7 -0
- package/lib/types/google-fetch.d.ts +6 -0
- package/lib/types/google-generative-ai.d.ts +3 -0
- package/lib/types/host-settings.d.ts +11 -0
- package/lib/types/index.d.ts +2 -2
- package/lib/types/model-metadata.d.ts +5 -3
- package/lib/types/models-contract.d.ts +7 -0
- package/lib/types/protocol-contract.d.ts +5 -0
- package/lib/types/protocol-policy.d.ts +4 -0
- package/lib/types/reasoning.d.ts +36 -6
- package/lib/types/request-control.d.ts +2 -0
- package/lib/types/sdk-types.d.ts +3156 -0
- package/lib/types/settings-bridge.d.ts +22 -0
- package/lib/vendor-licenses.txt +1861 -0
- package/package.json +7 -2
|
@@ -4,58 +4,21 @@
|
|
|
4
4
|
*
|
|
5
5
|
* The key is the one control that does not live in the section: its literal
|
|
6
6
|
* never rides a response, so the page learns only whether one is configured
|
|
7
|
-
* and writes it through the
|
|
8
|
-
*
|
|
7
|
+
* and writes it through the host account service, pinned to the account where
|
|
8
|
+
* the draft began. It is still staged with the rest of the form, so one save
|
|
9
9
|
* covers everything the page shows.
|
|
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
13
|
import type { GoModel, GoModelCatalog } from '../models-contract.ts';
|
|
14
|
-
import { type UsageDisplayMode } from '../usage-display.ts';
|
|
15
14
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
16
15
|
import type { SettingsScope } from './settings.ts';
|
|
17
|
-
import type {
|
|
18
|
-
|
|
16
|
+
import type { OpencodeGoSettings, OpencodeGoModelLimits } from '../config-contract.ts';
|
|
17
|
+
export type { OpencodeGoSettings, OpencodeGoModelLimit, OpencodeGoModelLimits } from '../config-contract.ts';
|
|
18
|
+
import { type GoAccountsState, type GoAccountsActions, type ExecuteAccountCommand } from './accounts-controller.ts';
|
|
19
19
|
import { type FieldState, type FormActions, type FormShell } from './staged-form.ts';
|
|
20
|
-
/** Namespace
|
|
20
|
+
/** Namespace shared with the host through the browser-safe configuration contract. */
|
|
21
21
|
export declare const OPENCODE_GO_NS = "llm-opencode-go";
|
|
22
|
-
/** The adapter fields this page edits. */
|
|
23
|
-
export interface OpencodeGoSettings {
|
|
24
|
-
/** Whether the adapter serves its route; false withdraws it from every picker. */
|
|
25
|
-
enabled?: boolean;
|
|
26
|
-
/** Usage pill visibility, independent of the selected model in always mode. */
|
|
27
|
-
usageDisplay?: UsageDisplayMode;
|
|
28
|
-
/** Per-model switches; normal models default on, deprecated models default off. */
|
|
29
|
-
modelVisibility?: Record<string, boolean>;
|
|
30
|
-
/** Credential reference naming the environment key. */
|
|
31
|
-
apiKeyEnv?: string;
|
|
32
|
-
accounts?: GoAccount[] | null;
|
|
33
|
-
autoSwitch?: boolean;
|
|
34
|
-
/** The gateway endpoint; also the live listing base. */
|
|
35
|
-
baseURL?: string;
|
|
36
|
-
/** Optional network proxy used by the Host. */
|
|
37
|
-
proxyURL?: string;
|
|
38
|
-
/** Live catalog re-resolution interval, in minutes. */
|
|
39
|
-
refreshMinutes?: number;
|
|
40
|
-
/** Largest idle gap between stream events, in milliseconds. */
|
|
41
|
-
streamIdleTimeoutMs?: number;
|
|
42
|
-
/** Optional retained image occurrence cap per request. */
|
|
43
|
-
maxImages?: number | null;
|
|
44
|
-
/** Accumulated base64 image payload bound for one request. */
|
|
45
|
-
maxRequestImageBytes?: number;
|
|
46
|
-
/** Total-pixel budget for one request image. */
|
|
47
|
-
requestImagePixelBudget?: number;
|
|
48
|
-
/** Raw encoded-byte target for one request image. */
|
|
49
|
-
requestImageMaxBytes?: number;
|
|
50
|
-
/** Per-model capacity overrides, keyed by the gateway model id. */
|
|
51
|
-
modelLimits?: OpencodeGoModelLimits;
|
|
52
|
-
}
|
|
53
|
-
/** The two capacity values the settings table can override. */
|
|
54
|
-
export interface OpencodeGoModelLimit {
|
|
55
|
-
contextWindow?: number | null;
|
|
56
|
-
maxTokens?: number | null;
|
|
57
|
-
}
|
|
58
|
-
export type OpencodeGoModelLimits = Record<string, OpencodeGoModelLimit | null>;
|
|
59
22
|
/** The gateway's model listing as the page reports it. */
|
|
60
23
|
export type OpencodeGoModels =
|
|
61
24
|
/** Not asked for yet; the page asks once it mounts. */
|
|
@@ -96,11 +59,10 @@ export interface OpencodeGoSectionState extends FormShell {
|
|
|
96
59
|
*/
|
|
97
60
|
enabled: boolean;
|
|
98
61
|
usageDisplay: FieldState;
|
|
62
|
+
protocolOverrides: FieldState;
|
|
99
63
|
modelVisibility: Readonly<Record<string, boolean>>;
|
|
100
64
|
pickerSaving: boolean;
|
|
101
65
|
pickerFailed: boolean;
|
|
102
|
-
/** Credential reference naming the environment key. */
|
|
103
|
-
apiKeyEnv: FieldState;
|
|
104
66
|
/** The gateway endpoint. */
|
|
105
67
|
baseURL: FieldState;
|
|
106
68
|
proxyURL: FieldState;
|
|
@@ -149,6 +111,7 @@ export declare class OpencodeGoSectionController {
|
|
|
149
111
|
private readonly scope;
|
|
150
112
|
private readonly ctx;
|
|
151
113
|
private readonly readModels;
|
|
114
|
+
private readonly executeAccountCommand;
|
|
152
115
|
private readonly form;
|
|
153
116
|
private readonly store;
|
|
154
117
|
private credential;
|
|
@@ -166,7 +129,7 @@ export declare class OpencodeGoSectionController {
|
|
|
166
129
|
* @param ctx - the page plugin's context, whose `remote.credentials` namespace
|
|
167
130
|
* answers for the credential the section references.
|
|
168
131
|
*/
|
|
169
|
-
constructor(scope: SettingsScope<OpencodeGoSettings>, ctx: ClientContext, readModels?: () => Promise<RemoteResult<GoModelCatalog>>, readUsage?: (ref: string) => Promise<import('../usage-contract.ts').GoUsage
|
|
132
|
+
constructor(scope: SettingsScope<OpencodeGoSettings>, ctx: ClientContext, readModels?: () => Promise<RemoteResult<GoModelCatalog>>, readUsage?: (ref: string) => Promise<import('../usage-contract.ts').GoUsage>, executeAccountCommand?: ExecuteAccountCommand);
|
|
170
133
|
/** Release subscriptions without disposing the host's shared form. */
|
|
171
134
|
dispose(): void;
|
|
172
135
|
private projection;
|
|
@@ -231,9 +194,9 @@ export declare class OpencodeGoSectionController {
|
|
|
231
194
|
*/
|
|
232
195
|
inject(): OpencodeGoSectionFace;
|
|
233
196
|
/**
|
|
234
|
-
*
|
|
197
|
+
* Ask the account service to write the staged key, then refresh its display.
|
|
235
198
|
* @param value - the staged credential literal.
|
|
236
|
-
* @returns whether the Host
|
|
199
|
+
* @returns whether the Host confirmed the write.
|
|
237
200
|
*/
|
|
238
201
|
private writeKey;
|
|
239
202
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The staged form behind the OpenCode Go settings page.
|
|
3
3
|
*
|
|
4
4
|
* The page stages what the user types and writes it only when they save. Each
|
|
5
|
-
* settings
|
|
5
|
+
* settings batch is a durable, revision-fenced document mutation, so a control
|
|
6
6
|
* that committed as it settled turned one edit into a write the user never
|
|
7
7
|
* asked for and could not preview; staged text makes what is on screen exactly
|
|
8
8
|
* what a save would store.
|
|
@@ -182,8 +182,6 @@ export declare class StagedForm {
|
|
|
182
182
|
* @returns the planned writes, in the order the fields were staged.
|
|
183
183
|
*/
|
|
184
184
|
private plan;
|
|
185
|
-
private clear;
|
|
186
|
-
private store;
|
|
187
185
|
private stage;
|
|
188
186
|
private spec;
|
|
189
187
|
private snapshotOf;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import type { SettingsScope } from './settings.ts';
|
|
3
3
|
import type { OpencodeGoSettings } from './section-controller.ts';
|
|
4
|
-
export declare function registerUsagePill(ctx: Context, settings: SettingsScope<OpencodeGoSettings>): void;
|
|
4
|
+
export declare function registerUsagePill(ctx: Context, settings: SettingsScope<OpencodeGoSettings>, selectAccount?: (ref: string) => Promise<boolean>): void;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Browser-safe configuration vocabulary shared by both plugin faces. */
|
|
2
|
+
import type { GoAccount } from './accounts.ts';
|
|
3
|
+
import type { GoAccountOperation } from './account-operations.ts';
|
|
4
|
+
import type { UsageDisplayMode } from './usage-display.ts';
|
|
5
|
+
import type { GoProtocolOverrides } from './protocol-contract.ts';
|
|
6
|
+
export declare const SETTINGS_NAMESPACE = "llm-opencode-go";
|
|
7
|
+
export declare const PROFILE_ENTRY_ID = "opencode-go";
|
|
8
|
+
/**
|
|
9
|
+
* One model's configured capacities. Every field is optional so a deployment
|
|
10
|
+
* can override only the value it needs. Null explicitly selects the catalog
|
|
11
|
+
* value even when a lower profile/settings layer supplies an override.
|
|
12
|
+
*/
|
|
13
|
+
export interface OpencodeGoModelLimit {
|
|
14
|
+
/** Context window in tokens, overriding what the catalog advertised. */
|
|
15
|
+
contextWindow?: number | null;
|
|
16
|
+
/** Output cap per request, overriding what the catalog advertised. */
|
|
17
|
+
maxTokens?: number | null;
|
|
18
|
+
/** Additional selectable thinking budgets, in tokens; null keeps the standard presets. */
|
|
19
|
+
thinkingBudgets?: number[] | null;
|
|
20
|
+
}
|
|
21
|
+
/** Per-model capacities; a null entry selects both original catalog values. */
|
|
22
|
+
export type OpencodeGoModelLimits = Record<string, OpencodeGoModelLimit | null>;
|
|
23
|
+
/** Runtime configuration for one plugin mount. */
|
|
24
|
+
export interface OpencodeGoConfig {
|
|
25
|
+
/**
|
|
26
|
+
* Whether this adapter serves its route at all. False withdraws the
|
|
27
|
+
* `dsh-opencode-go` route and its models from every picker without unloading the
|
|
28
|
+
* plugin, so the settings page that owns this switch stays reachable to turn
|
|
29
|
+
* it back on. Independent of the credential: a key present while this is
|
|
30
|
+
* false registers nothing.
|
|
31
|
+
*/
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
/** Usage pill visibility; auto follows this plugin's selected provider. */
|
|
34
|
+
usageDisplay: UsageDisplayMode;
|
|
35
|
+
/** Per-model picker switches; absent entries default to enabled unless deprecated. */
|
|
36
|
+
modelVisibility?: Record<string, boolean>;
|
|
37
|
+
/** Experimental opt-in routing; omitted/null entries follow the catalog. */
|
|
38
|
+
protocolOverrides?: GoProtocolOverrides;
|
|
39
|
+
/** Legacy credential reference, kept in sync with the first/current account. */
|
|
40
|
+
apiKeyEnv: string;
|
|
41
|
+
/** The first account is current; subsequent accounts are tried in order. */
|
|
42
|
+
accounts?: GoAccount[] | null;
|
|
43
|
+
accountOperations?: GoAccountOperation[];
|
|
44
|
+
/** Try other saved accounts on quota/credential rejection before any content is emitted. */
|
|
45
|
+
autoSwitch?: boolean;
|
|
46
|
+
/** Shared gateway base for model discovery, inference and usage requests. */
|
|
47
|
+
baseURL: string;
|
|
48
|
+
/** Optional HTTP(S) or SOCKS5 proxy; blank uses the default network transport. */
|
|
49
|
+
proxyURL: string;
|
|
50
|
+
/** Request/picker cache lifetime in minutes; explicit discovery bypasses it. */
|
|
51
|
+
refreshMinutes: number;
|
|
52
|
+
/** Largest idle gap between stream events before the request fails. */
|
|
53
|
+
streamIdleTimeoutMs: number;
|
|
54
|
+
/** Bound discovery and each attempt's credential/image preparation. */
|
|
55
|
+
requestPreparationTimeoutMs?: number;
|
|
56
|
+
/** Whole dispatch deadline, including discovery and account fallback. */
|
|
57
|
+
requestTimeoutMs?: number;
|
|
58
|
+
/** Optional retained image occurrence cap per request; omission or null leaves the count unlimited. */
|
|
59
|
+
maxImages?: number | null;
|
|
60
|
+
/** Request-level bound on base64-encoded image payload, in bytes. */
|
|
61
|
+
maxRequestImageBytes: number;
|
|
62
|
+
/** Total-pixel budget for one request image. */
|
|
63
|
+
requestImagePixelBudget: number;
|
|
64
|
+
/** Raw encoded-byte target for one request image before base64 expansion. */
|
|
65
|
+
requestImageMaxBytes: number;
|
|
66
|
+
/** Per-model capacity overrides; an absent field inherits the catalog value. */
|
|
67
|
+
modelLimits: OpencodeGoModelLimits;
|
|
68
|
+
}
|
|
69
|
+
/** Settings snapshots may omit fields inherited from their base layer. */
|
|
70
|
+
export type OpencodeGoSettings = Partial<OpencodeGoConfig>;
|
package/lib/types/config.d.ts
CHANGED
|
@@ -9,65 +9,16 @@
|
|
|
9
9
|
* @module dsh-llm-opencode-go/config
|
|
10
10
|
*/
|
|
11
11
|
import z from '@deepseek-ai/schemastery';
|
|
12
|
-
import {
|
|
13
|
-
|
|
12
|
+
import type { OpencodeGoConfig } from './config-contract.ts';
|
|
13
|
+
export type { OpencodeGoConfig, OpencodeGoModelLimit, OpencodeGoModelLimits } from './config-contract.ts';
|
|
14
14
|
/** Environment variable resolving the OpenCode API key. */
|
|
15
15
|
export declare const DEFAULT_API_KEY_ENV = "OPENCODE_API_KEY";
|
|
16
16
|
/** Successful refresh lifetime; failed refreshes retry sooner and explicit discovery revalidates immediately. */
|
|
17
17
|
export declare const DEFAULT_REFRESH_MINUTES = 60;
|
|
18
18
|
/** Default maximum idle interval while a stream read is outstanding. */
|
|
19
19
|
export declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300000;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* can override only the value it needs. Null explicitly selects the catalog
|
|
23
|
-
* value even when a lower profile/settings layer supplies an override.
|
|
24
|
-
*/
|
|
25
|
-
export interface OpencodeGoModelLimit {
|
|
26
|
-
/** Context window in tokens, overriding what the catalog advertised. */
|
|
27
|
-
contextWindow?: number | null;
|
|
28
|
-
/** Output cap per request, overriding what the catalog advertised. */
|
|
29
|
-
maxTokens?: number | null;
|
|
30
|
-
}
|
|
31
|
-
/** Per-model capacities; a null entry selects both original catalog values. */
|
|
32
|
-
export type OpencodeGoModelLimits = Record<string, OpencodeGoModelLimit | null>;
|
|
33
|
-
/** Runtime configuration for one plugin mount. */
|
|
34
|
-
export interface OpencodeGoConfig {
|
|
35
|
-
/**
|
|
36
|
-
* Whether this adapter serves its route at all. False withdraws the
|
|
37
|
-
* `dsh-opencode-go` route and its models from every picker without unloading the
|
|
38
|
-
* plugin, so the settings page that owns this switch stays reachable to turn
|
|
39
|
-
* it back on. Independent of the credential: a key present while this is
|
|
40
|
-
* false registers nothing.
|
|
41
|
-
*/
|
|
42
|
-
enabled: boolean;
|
|
43
|
-
/** Usage pill visibility; auto follows this plugin's selected provider. */
|
|
44
|
-
usageDisplay: UsageDisplayMode;
|
|
45
|
-
/** Per-model picker switches; absent entries default to enabled unless deprecated. */
|
|
46
|
-
modelVisibility?: Record<string, boolean>;
|
|
47
|
-
/** Credential reference: the environment variable the key resolves from. */
|
|
48
|
-
apiKeyEnv: string;
|
|
49
|
-
accounts?: GoAccount[] | null;
|
|
50
|
-
/** Try other saved accounts on quota/credential rejection before any content is emitted. */
|
|
51
|
-
autoSwitch?: boolean;
|
|
52
|
-
/** The gateway endpoint; also the base of the live model listing. */
|
|
53
|
-
baseURL: string;
|
|
54
|
-
/** Optional HTTP(S) or SOCKS5 proxy; blank uses the default network transport. */
|
|
55
|
-
proxyURL: string;
|
|
56
|
-
/** Request/picker cache lifetime in minutes; explicit discovery bypasses it. */
|
|
57
|
-
refreshMinutes: number;
|
|
58
|
-
/** Largest idle gap between stream events before the request fails. */
|
|
59
|
-
streamIdleTimeoutMs: number;
|
|
60
|
-
/** Optional retained image occurrence cap per request; omission or null leaves the count unlimited. */
|
|
61
|
-
maxImages?: number | null;
|
|
62
|
-
/** Request-level bound on base64-encoded image payload, in bytes. */
|
|
63
|
-
maxRequestImageBytes: number;
|
|
64
|
-
/** Total-pixel budget for one request image. */
|
|
65
|
-
requestImagePixelBudget: number;
|
|
66
|
-
/** Raw encoded-byte target for one request image before base64 expansion. */
|
|
67
|
-
requestImageMaxBytes: number;
|
|
68
|
-
/** Per-model capacity overrides; an absent field inherits the catalog value. */
|
|
69
|
-
modelLimits: OpencodeGoModelLimits;
|
|
70
|
-
}
|
|
20
|
+
export declare const DEFAULT_REQUEST_PREPARATION_TIMEOUT_MS = 60000;
|
|
21
|
+
export declare const DEFAULT_REQUEST_TIMEOUT_MS: number;
|
|
71
22
|
/** Plain values used by the adapter and by pre-0.1.7 settings documents. */
|
|
72
23
|
export declare const PlainConfig: z<OpencodeGoConfig>;
|
|
73
24
|
/** 0.1.7's Loader retains these references when profile fields change. */
|
|
@@ -84,6 +35,14 @@ export declare function readConfig(config: LiveConfig): OpencodeGoConfig;
|
|
|
84
35
|
* the composition layer and as the settings section's write validator, so a
|
|
85
36
|
* bad URL fails where it is written, never at first request.
|
|
86
37
|
* @param raw - the configured base URL.
|
|
87
|
-
* @returns the
|
|
38
|
+
* @returns the current gateway base URL without trailing slashes.
|
|
88
39
|
*/
|
|
89
40
|
export declare function assertBaseURL(raw: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Reject a selected credential reference that is not a bare environment
|
|
43
|
+
* variable name. The schema pattern above fails the composition layer and the
|
|
44
|
+
* settings write; this assert gives the load and validate paths a message that
|
|
45
|
+
* names the field, instead of schemastery's generic regexp complaint.
|
|
46
|
+
* @param raw - the configured credential reference.
|
|
47
|
+
*/
|
|
48
|
+
export declare function assertApiKeyEnv(raw: string): void;
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { GenerateOptions, ImageAttachmentAccessResolver } from '@deepseek-ai/dsh-llm';
|
|
7
7
|
import type { AttachmentStore } from '@deepseek-ai/dsh-attachment';
|
|
8
|
-
import type { Context as PiContext } from '
|
|
8
|
+
import type { Context as PiContext } from '../sdk-types.ts';
|
|
9
|
+
import { ImagePayloadLease, type ImagePoolObserver } from './image-pool.ts';
|
|
9
10
|
/** Inputs that bind deterministic request images to one current tool execution world. */
|
|
10
11
|
export interface PiImageRequestContext {
|
|
11
12
|
/** Durable provider that resolves request-image bytes and provider-owned host objects. */
|
|
@@ -18,6 +19,9 @@ export interface PiImageRequestContext {
|
|
|
18
19
|
maxRequestImageBytes?: number;
|
|
19
20
|
/** Route pixel and raw encoded-byte budgets. */
|
|
20
21
|
requestImagePolicy?: PiImageRequestBudget;
|
|
22
|
+
/** Adapter-owned lease retains its charge through provider streaming. */
|
|
23
|
+
payloadLease?: ImagePayloadLease;
|
|
24
|
+
onImagePool?: ImagePoolObserver;
|
|
21
25
|
}
|
|
22
26
|
/** Per-route budgets from which each request image's target is derived. */
|
|
23
27
|
export interface PiImageRequestBudget {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Shared across requests so concurrent conversations cannot multiply image work. */
|
|
2
|
+
export declare const IMAGE_PREPARATION_CONCURRENCY = 4;
|
|
3
|
+
export declare const IMAGE_PREPARATION_QUEUE_LIMIT = 32;
|
|
4
|
+
/** Raw prepared bytes plus base64 payloads, not a bound on native decoder RSS. */
|
|
5
|
+
export declare const IMAGE_PAYLOAD_BUDGET_BYTES: number;
|
|
6
|
+
export interface ImagePoolObservation {
|
|
7
|
+
queueWaitMs: number;
|
|
8
|
+
active: number;
|
|
9
|
+
queued: number;
|
|
10
|
+
retainedBytes: number;
|
|
11
|
+
rejected?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export type ImagePoolObserver = (observation: ImagePoolObservation) => void;
|
|
14
|
+
/** Held by the adapter until an attempt ends, including streaming and fallback. */
|
|
15
|
+
export declare class ImagePayloadLease {
|
|
16
|
+
private readonly observer?;
|
|
17
|
+
private bytes;
|
|
18
|
+
private closed;
|
|
19
|
+
constructor(observer?: ImagePoolObserver | undefined);
|
|
20
|
+
reserve(bytes: number): void;
|
|
21
|
+
[Symbol.dispose](): void;
|
|
22
|
+
}
|
|
23
|
+
/** Keep the permit until real work settles, even if its caller stops waiting. */
|
|
24
|
+
export declare function withImagePermit<T>(work: () => Promise<T>, signal?: AbortSignal, observer?: ImagePoolObserver): Promise<T>;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @module dsh-opencode-go/conversion/replay
|
|
9
9
|
*/
|
|
10
10
|
import type { Message, ReplayEnvelope } from '@deepseek-ai/dsh-llm';
|
|
11
|
-
import type { Api, AssistantMessage } from '
|
|
11
|
+
import type { Api, AssistantMessage } from '../sdk-types.ts';
|
|
12
12
|
/** Per-block half of the pi-ai replay envelope, one entry per content block. */
|
|
13
13
|
export type PiAiReplayBlock = {
|
|
14
14
|
type: 'text';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @module dsh-opencode-go/conversion/stream
|
|
9
9
|
*/
|
|
10
10
|
import type { FinishReason, StreamChunk, TokenUsage } from '@deepseek-ai/dsh-llm';
|
|
11
|
-
import type { AssistantMessage, AssistantMessageEvent, Usage as PiUsage } from '
|
|
11
|
+
import type { AssistantMessage, AssistantMessageEvent, Usage as PiUsage } from '../sdk-types.ts';
|
|
12
12
|
/**
|
|
13
13
|
* Map pi-ai usage (reasoning folded into output by pi-ai).
|
|
14
14
|
* @param usage - cumulative usage from the terminal pi-ai event.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** One SDK attempt owns its capture; simultaneous requests cannot share evidence. */
|
|
2
|
+
export declare class GatewayDiagnostics {
|
|
3
|
+
private readonly options;
|
|
4
|
+
private evidence;
|
|
5
|
+
private code;
|
|
6
|
+
private readonly secrets;
|
|
7
|
+
constructor(options: {
|
|
8
|
+
provider: string;
|
|
9
|
+
model: string;
|
|
10
|
+
apiKey: string;
|
|
11
|
+
proxyURL?: string;
|
|
12
|
+
fetch?: typeof globalThis.fetch;
|
|
13
|
+
directory?: string;
|
|
14
|
+
callId?: string;
|
|
15
|
+
attempt?: number;
|
|
16
|
+
onResponse?: (status: number, requestId?: string) => void;
|
|
17
|
+
});
|
|
18
|
+
private redact;
|
|
19
|
+
readonly fetch: typeof globalThis.fetch;
|
|
20
|
+
failureCode(fallback: string): Promise<string>;
|
|
21
|
+
failureMessage(original: string): Promise<string>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Public Go gateway shared by discovery, inference and usage. */
|
|
2
|
+
export declare const DEFAULT_BASE_URL = "https://opencode.ai/inference/go/v1";
|
|
3
|
+
/**
|
|
4
|
+
* Migrate the legacy official address before any request is constructed.
|
|
5
|
+
* Keep this callback self-contained: settings schemas serialize its source.
|
|
6
|
+
*/
|
|
7
|
+
export declare function migrateGatewayBaseURL(baseURL: string): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function withGoogleFetch<T>(options: {
|
|
2
|
+
fetch?: typeof globalThis.fetch;
|
|
3
|
+
headers?: Record<string, string | null>;
|
|
4
|
+
} | undefined, request: () => T): T;
|
|
5
|
+
/** The pinned Google SDK's HTTP call uses this binding in builds and tests. */
|
|
6
|
+
export declare const googleFetch: typeof globalThis.fetch;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { OpencodeGoConfig } from './config-contract.ts';
|
|
3
|
+
import type { AccountSettingsWriter } from './settings-bridge.ts';
|
|
4
|
+
export declare function validateGoConfig(value: OpencodeGoConfig): void;
|
|
5
|
+
/** Version-specific settings attachment and validation stay at the host boundary. */
|
|
6
|
+
export declare function installHostSettings(ctx: Context, entry: OpencodeGoConfig, options: {
|
|
7
|
+
connect: (settings: AccountSettingsWriter) => () => void;
|
|
8
|
+
setSource: (source: () => OpencodeGoConfig) => void;
|
|
9
|
+
onChange: () => void;
|
|
10
|
+
recover: () => void;
|
|
11
|
+
}): void;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* config:
|
|
18
18
|
* enabled: true # false withdraws the route; the plugin stays mounted
|
|
19
19
|
* apiKeyEnv: OPENCODE_API_KEY # default
|
|
20
|
-
* baseURL: https://opencode.ai/
|
|
20
|
+
* baseURL: https://opencode.ai/inference/go/v1 # default
|
|
21
21
|
* refreshMinutes: 60 # live catalog re-resolution interval
|
|
22
22
|
* ```
|
|
23
23
|
*
|
|
@@ -38,7 +38,7 @@ declare module '@deepseek-ai/cordis' {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
export { OpencodeGoAdapter } from './adapter.ts';
|
|
41
|
-
export type { OpencodeGoAdapterOptions, OpencodeGoImageAccess } from './adapter.ts';
|
|
41
|
+
export type { OpencodeGoAdapterOptions, OpencodeGoImageAccess, GoAccountSettlement, GoCallTrace } from './adapter.ts';
|
|
42
42
|
export { DEFAULT_BASE_URL, DISPLAY_NAME, PROVIDER_ID, OpencodeGoCatalog, discoverCatalogModels, readLiveModelIds, } from './catalog.ts';
|
|
43
43
|
export { Config, PlainConfig, assertBaseURL } from './config.ts';
|
|
44
44
|
export { assertProxyURL } from './proxy-url.ts';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** Convert OpenCode's online models.dev metadata into the SDK
|
|
2
|
-
import type { Api, Model } from '
|
|
1
|
+
/** Convert OpenCode's online models.dev metadata into the supported SDK wire protocols. */
|
|
2
|
+
import type { Api, Model } from './sdk-types.ts';
|
|
3
3
|
import { type GoModel } from './models-contract.ts';
|
|
4
4
|
export declare const MODEL_METADATA_URL = "https://models.dev/api.json";
|
|
5
5
|
/** Lifecycle and capability data the online catalog adds to a gateway listing. */
|
|
@@ -9,8 +9,10 @@ export interface ModelMetadata {
|
|
|
9
9
|
readonly details: ReadonlyMap<string, ModelDetails>;
|
|
10
10
|
readonly errors: ReadonlyMap<string, string>;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
12
|
+
/** Use the current gateway for every protocol, then normalize SDK paths. */
|
|
13
13
|
export declare function modelBaseURL(api: Api, baseURL: string): string;
|
|
14
|
+
/** Shared Responses defaults for declared models and explicit protocol overrides. */
|
|
15
|
+
export declare function responsesCompatibility(): NonNullable<Model<'openai-responses'>['compat']>;
|
|
14
16
|
/**
|
|
15
17
|
* Only read the opencode-go record. Online endpoints, headers and credentials
|
|
16
18
|
* are deliberately ignored: model traffic always stays on the configured gateway.
|
|
@@ -5,6 +5,8 @@ export interface GoModel {
|
|
|
5
5
|
name?: string;
|
|
6
6
|
contextWindow?: number;
|
|
7
7
|
maxTokens?: number;
|
|
8
|
+
/** Token budget controls available to this model, including their catalog bounds. */
|
|
9
|
+
reasoningBudget?: ThinkingBudgetRange;
|
|
8
10
|
deprecated?: boolean;
|
|
9
11
|
releaseDate?: string;
|
|
10
12
|
/** Input modalities models.dev declares, in {@link INPUT_MODALITIES} order. */
|
|
@@ -12,6 +14,10 @@ export interface GoModel {
|
|
|
12
14
|
/** Advertised by the gateway but lacking a usable protocol and capability configuration. */
|
|
13
15
|
configurationMissing?: boolean;
|
|
14
16
|
}
|
|
17
|
+
export interface ThinkingBudgetRange {
|
|
18
|
+
min: number;
|
|
19
|
+
max: number;
|
|
20
|
+
}
|
|
15
21
|
/**
|
|
16
22
|
* Input modalities this page can name. models.dev uses these same five tokens, so
|
|
17
23
|
* an unknown token is dropped rather than rendered as an untranslatable chip.
|
|
@@ -29,6 +35,7 @@ export declare function normalizeInputModalities(value: unknown): readonly Input
|
|
|
29
35
|
export interface GoCatalogSourceStatus {
|
|
30
36
|
readonly updatedAt?: number;
|
|
31
37
|
readonly error?: string;
|
|
38
|
+
readonly warning?: string;
|
|
32
39
|
}
|
|
33
40
|
/** A failed refresh retains the Host's usable data with an explicit diagnostic. */
|
|
34
41
|
export interface GoModelCatalog {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The supported experimental override surface, shared with the settings UI. */
|
|
2
|
+
export declare const RESPONSES_OVERRIDE_MODEL = "deepseek-v4.1-flash";
|
|
3
|
+
export type GoProtocolOverrides = Partial<Record<typeof RESPONSES_OVERRIDE_MODEL, 'openai-responses' | null>>;
|
|
4
|
+
/** Null selects catalog routing even when a lower settings layer overrides it. */
|
|
5
|
+
export declare function assertProtocolOverrides(value: unknown): asserts value is GoProtocolOverrides | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Api, Model } from './sdk-types.ts';
|
|
2
|
+
import type { OpencodeGoConfig } from './config-contract.ts';
|
|
3
|
+
/** Resolve a request's wire model without mutating the shared metadata catalog. */
|
|
4
|
+
export declare function withProtocolOverride(model: Model<Api>, config: OpencodeGoConfig): Model<Api>;
|
package/lib/types/reasoning.d.ts
CHANGED
|
@@ -1,10 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
1
|
+
import type { Api, Model, ModelThinkingLevel, ThinkingBudgets, ThinkingLevelMap } from './sdk-types.ts';
|
|
2
|
+
import type { ThinkingBudgetRange } from './models-contract.ts';
|
|
3
3
|
export declare const THINKING_LEVELS: readonly ModelThinkingLevel[];
|
|
4
|
-
/**
|
|
4
|
+
/** Protocol formats whose switch/budget is understood by pi-ai. */
|
|
5
5
|
export declare const NATIVE_THINKING_FLAGS: ReadonlySet<string>;
|
|
6
|
+
/** Expose budgets only when the SDK knows where to serialize a numeric limit. */
|
|
7
|
+
export declare function supportsThinkingBudget(api: Api, compat: Model<Api>['compat']): boolean;
|
|
8
|
+
export declare function reasoningBudgetRange(model: Model<Api>): ThinkingBudgetRange | undefined;
|
|
6
9
|
export declare function unsupportedThinkingLevels(): ThinkingLevelMap;
|
|
7
|
-
/** Exact model/protocol
|
|
10
|
+
/** Exact model/protocol controls verified against OpenCode Go. */
|
|
8
11
|
export declare function withGatewayReasoning(model: Model<Api>): Model<Api>;
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
export declare function reasoningChoices(model: Model<Api>): readonly {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
}[];
|
|
16
|
+
export type ReasoningIntent = {
|
|
17
|
+
kind: 'default';
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'off';
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'on';
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'effort';
|
|
24
|
+
level: Exclude<ModelThinkingLevel, 'off'>;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'budget';
|
|
27
|
+
tokens: number;
|
|
28
|
+
min: number;
|
|
29
|
+
};
|
|
30
|
+
/** Called after validation against the model's choices. */
|
|
31
|
+
export declare function reasoningIntent(model: Model<Api>, level: string | undefined): ReasoningIntent;
|
|
32
|
+
/**
|
|
33
|
+
* The SDK serializes explicit choices. Default must leave all thinking controls
|
|
34
|
+
* to the service; a switch's On must not acquire an invented effort spelling.
|
|
35
|
+
*/
|
|
36
|
+
export declare function reasoningRequest(intent: ReasoningIntent): {
|
|
37
|
+
reasoning?: Exclude<ModelThinkingLevel, 'off'>;
|
|
38
|
+
thinkingBudgets?: ThinkingBudgets;
|
|
39
|
+
onPayload: (payload: unknown) => unknown;
|
|
40
|
+
};
|