dsh-opencode-go 0.1.21 → 0.1.22
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 +128 -167
- package/README.md +126 -158
- package/THIRD_PARTY_NOTICES.md +3 -1
- package/docs/development.md +56 -6
- package/docs/fork-review-2026-09-25.md +191 -0
- package/docs/independent-package.md +2 -2
- package/docs/verification.md +154 -0
- package/lib/build-info.json +8 -1
- package/lib/client.js +412 -262
- package/lib/index.js +6763 -428
- package/lib/types/account-manager.d.ts +23 -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 +5 -0
- package/lib/types/adapter.d.ts +30 -10
- package/lib/types/call-trace.d.ts +54 -0
- package/lib/types/catalog-manager.d.ts +20 -0
- package/lib/types/catalog.d.ts +5 -3
- package/lib/types/client/accounts-controller.d.ts +6 -17
- package/lib/types/client/host-compat.d.ts +7 -0
- package/lib/types/client/locales.d.ts +9 -0
- package/lib/types/client/section-controller.d.ts +11 -46
- 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 +69 -0
- package/lib/types/config.d.ts +12 -53
- 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/host-settings.d.ts +11 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/model-metadata.d.ts +3 -1
- 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 +1568 -0
- package/lib/types/settings-bridge.d.ts +22 -0
- package/lib/vendor-licenses.txt +103 -0
- package/package.json +6 -2
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
/** Credential reference: the environment variable the key resolves from. */
|
|
40
|
+
apiKeyEnv: string;
|
|
41
|
+
accounts?: GoAccount[] | null;
|
|
42
|
+
accountOperations?: GoAccountOperation[];
|
|
43
|
+
/** Try other saved accounts on quota/credential rejection before any content is emitted. */
|
|
44
|
+
autoSwitch?: boolean;
|
|
45
|
+
/** The gateway endpoint; also the base of the live model listing. */
|
|
46
|
+
baseURL: string;
|
|
47
|
+
/** Optional HTTP(S) or SOCKS5 proxy; blank uses the default network transport. */
|
|
48
|
+
proxyURL: string;
|
|
49
|
+
/** Request/picker cache lifetime in minutes; explicit discovery bypasses it. */
|
|
50
|
+
refreshMinutes: number;
|
|
51
|
+
/** Largest idle gap between stream events before the request fails. */
|
|
52
|
+
streamIdleTimeoutMs: number;
|
|
53
|
+
/** Bound discovery and each attempt's credential/image preparation. */
|
|
54
|
+
requestPreparationTimeoutMs?: number;
|
|
55
|
+
/** Whole dispatch deadline, including discovery and account fallback. */
|
|
56
|
+
requestTimeoutMs?: number;
|
|
57
|
+
/** Optional retained image occurrence cap per request; omission or null leaves the count unlimited. */
|
|
58
|
+
maxImages?: number | null;
|
|
59
|
+
/** Request-level bound on base64-encoded image payload, in bytes. */
|
|
60
|
+
maxRequestImageBytes: number;
|
|
61
|
+
/** Total-pixel budget for one request image. */
|
|
62
|
+
requestImagePixelBudget: number;
|
|
63
|
+
/** Raw encoded-byte target for one request image before base64 expansion. */
|
|
64
|
+
requestImageMaxBytes: number;
|
|
65
|
+
/** Per-model capacity overrides; an absent field inherits the catalog value. */
|
|
66
|
+
modelLimits: OpencodeGoModelLimits;
|
|
67
|
+
}
|
|
68
|
+
/** Settings snapshots may omit fields inherited from their base layer. */
|
|
69
|
+
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. */
|
|
@@ -87,3 +38,11 @@ export declare function readConfig(config: LiveConfig): OpencodeGoConfig;
|
|
|
87
38
|
* @returns the normalized 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,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
|
@@ -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
1
|
/** Convert OpenCode's online models.dev metadata into the SDK's three wire protocols. */
|
|
2
|
-
import type { Api, Model } from '
|
|
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. */
|
|
@@ -11,6 +11,8 @@ export interface ModelMetadata {
|
|
|
11
11
|
}
|
|
12
12
|
/** Anthropic's SDK appends /v1/messages; the OpenAI SDKs append paths below /v1. */
|
|
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
|
+
};
|