dsh-opencode-go 0.1.24 → 0.2.1
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 +66 -12
- package/README.md +172 -79
- package/THIRD_PARTY_NOTICES.md +6 -2
- package/assets/icon.png +0 -0
- package/docs/advanced.en.md +32 -35
- package/docs/advanced.md +33 -35
- package/docs/assets/logo-dark.png +0 -0
- package/docs/assets/logo-light.png +0 -0
- package/docs/assets/usage-history-desktop.jpg +0 -0
- package/docs/assets/usage-history-mobile.jpg +0 -0
- package/docs/assets/usage-history-models.jpg +0 -0
- package/docs/development.md +61 -119
- package/docs/independent-package.md +4 -2
- package/docs/usage-analytics.en.md +57 -0
- package/docs/usage-analytics.md +57 -0
- package/docs/verification.md +51 -917
- package/lib/build-info.json +1 -1
- package/lib/client.js +3429 -2618
- package/lib/free-http-worker.js +32 -0
- package/lib/index.js +5135 -3746
- package/lib/types/accounts.d.ts +96 -31
- package/lib/types/adapter.d.ts +63 -51
- package/lib/types/analytics.d.ts +35 -0
- package/lib/types/catalog.d.ts +109 -44
- package/lib/types/client/AnalyticsDialog.d.ts +18 -0
- package/lib/types/client/Section.d.ts +41 -7
- package/lib/types/client/UsagePill.d.ts +15 -6
- package/lib/types/client/controller.d.ts +178 -0
- package/lib/types/client/dashboard-copy.d.ts +58 -0
- package/lib/types/client/index.d.ts +18 -12
- package/lib/types/client/{locales.d.ts → presentation.d.ts} +97 -9
- package/lib/types/config.d.ts +14 -15
- package/lib/types/contracts.d.ts +338 -0
- package/lib/types/conversion.d.ts +155 -0
- package/lib/types/free-channel.d.ts +21 -0
- package/lib/types/free-http-worker.d.ts +1 -0
- package/lib/types/free-policy.d.ts +4 -0
- package/lib/types/free-protocol.d.ts +16 -0
- package/lib/types/free-runtime.d.ts +2 -0
- package/lib/types/free-socks-tunnel.d.ts +4 -0
- package/lib/types/free-transport.d.ts +19 -0
- package/lib/types/index.d.ts +8 -40
- package/lib/types/pricing.d.ts +29 -0
- package/lib/types/sdk-types.d.ts +1540 -2902
- package/lib/types/transport.d.ts +71 -0
- package/lib/vendor-licenses.txt +55 -31
- package/package.json +77 -78
- package/docs/assets/usage-panel.png +0 -0
- package/docs/fork-review-2026-09-25.md +0 -191
- package/docs/native-call-comparison-v020-rc2.md +0 -116
- package/lib/types/account-manager.d.ts +0 -25
- package/lib/types/account-operations.d.ts +0 -31
- package/lib/types/account-policy.d.ts +0 -16
- package/lib/types/account-recovery.d.ts +0 -2
- package/lib/types/account-selection.d.ts +0 -30
- package/lib/types/account-service.d.ts +0 -12
- package/lib/types/accounts-contract.d.ts +0 -38
- package/lib/types/call-trace.d.ts +0 -54
- package/lib/types/catalog-manager.d.ts +0 -20
- package/lib/types/client/AccountsCard.d.ts +0 -19
- package/lib/types/client/ModelEditor.d.ts +0 -20
- package/lib/types/client/accounts-controller.d.ts +0 -71
- package/lib/types/client/hint-mark.d.ts +0 -17
- package/lib/types/client/host-compat.d.ts +0 -7
- package/lib/types/client/host-primitives.d.ts +0 -11
- package/lib/types/client/section-controller.d.ts +0 -202
- package/lib/types/client/settings.d.ts +0 -18
- package/lib/types/client/staged-form.d.ts +0 -201
- package/lib/types/client/usage.d.ts +0 -4
- package/lib/types/config-contract.d.ts +0 -70
- package/lib/types/conversion/config.d.ts +0 -4
- package/lib/types/conversion/context.d.ts +0 -56
- package/lib/types/conversion/image-offload.d.ts +0 -13
- package/lib/types/conversion/image-pool.d.ts +0 -24
- package/lib/types/conversion/index.d.ts +0 -5
- package/lib/types/conversion/replay.d.ts +0 -66
- package/lib/types/conversion/stream.d.ts +0 -44
- package/lib/types/gateway-diagnostics.d.ts +0 -23
- package/lib/types/gateway-error.d.ts +0 -2
- package/lib/types/gateway-url.d.ts +0 -6
- package/lib/types/google-fetch.d.ts +0 -6
- package/lib/types/host-settings.d.ts +0 -11
- package/lib/types/json-response.d.ts +0 -14
- package/lib/types/metadata-cache.d.ts +0 -12
- package/lib/types/model-metadata.d.ts +0 -21
- package/lib/types/models-contract.d.ts +0 -66
- package/lib/types/models.d.ts +0 -13
- package/lib/types/protocol-contract.d.ts +0 -5
- package/lib/types/protocol-policy.d.ts +0 -4
- package/lib/types/provider-identity.d.ts +0 -4
- package/lib/types/proxy-url.d.ts +0 -2
- package/lib/types/proxy.d.ts +0 -11
- package/lib/types/reasoning.d.ts +0 -40
- package/lib/types/remote-contract.d.ts +0 -3
- package/lib/types/remotes.d.ts +0 -3
- package/lib/types/request-budget.d.ts +0 -12
- package/lib/types/request-control.d.ts +0 -2
- package/lib/types/settings-bridge.d.ts +0 -22
- package/lib/types/usage-contract.d.ts +0 -35
- package/lib/types/usage-display.d.ts +0 -4
- package/lib/types/usage.d.ts +0 -27
- /package/lib/types/{google-generative-ai.d.ts → google.d.ts} +0 -0
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Harness request-history conversion into pi-ai's Context vocabulary.
|
|
3
|
-
*
|
|
4
|
-
* @module dsh-opencode-go/conversion/context
|
|
5
|
-
*/
|
|
6
|
-
import type { GenerateOptions, ImageAttachmentAccessResolver } from '@deepseek-ai/dsh-llm';
|
|
7
|
-
import type { AttachmentStore } from '@deepseek-ai/dsh-attachment';
|
|
8
|
-
import type { Context as PiContext } from '../sdk-types.ts';
|
|
9
|
-
import { ImagePayloadLease, type ImagePoolObserver } from './image-pool.ts';
|
|
10
|
-
/** Inputs that bind deterministic request images to one current tool execution world. */
|
|
11
|
-
export interface PiImageRequestContext {
|
|
12
|
-
/** Durable provider that resolves request-image bytes and provider-owned host objects. */
|
|
13
|
-
attachments: AttachmentStore;
|
|
14
|
-
/** Resolve current tool access separately from deterministic request-image versions. */
|
|
15
|
-
resolveImageAccess: ImageAttachmentAccessResolver;
|
|
16
|
-
/** Maximum retained image occurrences across request history; omission leaves the count unlimited. */
|
|
17
|
-
maxImages?: number;
|
|
18
|
-
/** Request-level bound on the base64-encoded payload of retained images; omission leaves the bound unchecked. */
|
|
19
|
-
maxRequestImageBytes?: number;
|
|
20
|
-
/** Route pixel and raw encoded-byte budgets. */
|
|
21
|
-
requestImagePolicy?: PiImageRequestBudget;
|
|
22
|
-
/** Adapter-owned lease retains its charge through provider streaming. */
|
|
23
|
-
payloadLease?: ImagePayloadLease;
|
|
24
|
-
onImagePool?: ImagePoolObserver;
|
|
25
|
-
}
|
|
26
|
-
/** Per-route budgets from which each request image's target is derived. */
|
|
27
|
-
export interface PiImageRequestBudget {
|
|
28
|
-
/** Total-pixel budget; larger sources are downscaled proportionally. */
|
|
29
|
-
maxPixels: number;
|
|
30
|
-
/** Encoded-byte target for one request image. */
|
|
31
|
-
maxBytes: number;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Convert text-only harness history to a synchronous pi-ai Context. Tool
|
|
35
|
-
* result names are recovered from preceding assistant tool calls.
|
|
36
|
-
* @param options - the harness request; `options.system`, else a leading `system` message, maps to pi-ai's single `systemPrompt` slot.
|
|
37
|
-
* @param images - absent; selects the synchronous conversion.
|
|
38
|
-
* @param onReplayDegrade - forwarded to {@link toPiAssistant} for each assistant message.
|
|
39
|
-
* @returns the pi-ai context; `tools` is omitted when the request declares none.
|
|
40
|
-
* @throws {LlmError} `UNSUPPORTED_CONTENT` for a `developer` history message, a tool-change block, a deferred tool, or an image in any history role, including a leading system message.
|
|
41
|
-
*/
|
|
42
|
-
export declare function toPiContext(options: GenerateOptions, images?: undefined, onReplayDegrade?: (reason: string) => void): PiContext;
|
|
43
|
-
/**
|
|
44
|
-
* Convert harness history to a pi-ai Context while resolving durable images.
|
|
45
|
-
* Tool result names are recovered from preceding assistant tool calls. On DSH
|
|
46
|
-
* 0.1.5, oldest images over the request budget become transient placeholders.
|
|
47
|
-
* On newer hosts, occurrences the surface marks offloaded become placeholders; when the
|
|
48
|
-
* retained occurrences exceed `maxImages` or their exact base64 payload exceeds
|
|
49
|
-
* `maxRequestImageBytes`, the call fails with `IMAGE_OFFLOAD_REQUIRED` naming
|
|
50
|
-
* how many more oldest occurrences must be offloaded.
|
|
51
|
-
* @param options - the harness request; `options.system`, else a leading `system` message, maps to pi-ai's single `systemPrompt` slot.
|
|
52
|
-
* @param images - attachment provider, current path resolver, and request limits.
|
|
53
|
-
* @param onReplayDegrade - forwarded to {@link toPiAssistant} for each assistant message.
|
|
54
|
-
* @returns the asynchronously resolved pi-ai context.
|
|
55
|
-
*/
|
|
56
|
-
export declare function toPiContext(options: GenerateOptions, images: PiImageRequestContext, onReplayDegrade?: (reason: string) => void): Promise<PiContext>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Message } from '@deepseek-ai/dsh-llm';
|
|
2
|
-
import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
|
|
3
|
-
interface ImageProjectionPolicy {
|
|
4
|
-
maxImages?: number;
|
|
5
|
-
maxBytes?: number;
|
|
6
|
-
byteLength: (ref: ImageAttachmentRef) => number;
|
|
7
|
-
placeholder: (ref: ImageAttachmentRef) => string;
|
|
8
|
-
/** False before preparing image bytes, true once encoded sizes are known. */
|
|
9
|
-
exact: boolean;
|
|
10
|
-
}
|
|
11
|
-
/** Preserve the host generation's image policy, using estimates first and exact sizes second. */
|
|
12
|
-
export declare function projectRequestImages(messages: readonly Message[], policy: ImageProjectionPolicy): readonly Message[];
|
|
13
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
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>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** History, image, and stream conversion shared by this plugin's protocol adapters. */
|
|
2
|
-
export { toPiContext } from './context.ts';
|
|
3
|
-
export type { PiImageRequestContext } from './context.ts';
|
|
4
|
-
export { toStreamChunks } from './stream.ts';
|
|
5
|
-
export { DEFAULT_MAX_REQUEST_IMAGE_BYTES, DEFAULT_REQUEST_IMAGE_MAX_BYTES, DEFAULT_REQUEST_IMAGE_PIXEL_BUDGET, } from './config.ts';
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Durable pi-ai replay metadata and assistant-history reconstruction.
|
|
3
|
-
*
|
|
4
|
-
* Harness content remains the durable source for text and tool calls. This
|
|
5
|
-
* module stores only the provider-native metadata needed to reconstruct a
|
|
6
|
-
* pi-ai assistant message on a later request.
|
|
7
|
-
*
|
|
8
|
-
* @module dsh-opencode-go/conversion/replay
|
|
9
|
-
*/
|
|
10
|
-
import type { Message, ReplayEnvelope } from '@deepseek-ai/dsh-llm';
|
|
11
|
-
import type { Api, AssistantMessage } from '../sdk-types.ts';
|
|
12
|
-
/** Per-block half of the pi-ai replay envelope, one entry per content block. */
|
|
13
|
-
export type PiAiReplayBlock = {
|
|
14
|
-
type: 'text';
|
|
15
|
-
textSignature?: string;
|
|
16
|
-
} | {
|
|
17
|
-
type: 'reasoning';
|
|
18
|
-
thinkingSignature?: string;
|
|
19
|
-
redacted?: boolean;
|
|
20
|
-
} | {
|
|
21
|
-
type: 'tool-call';
|
|
22
|
-
thoughtSignature?: string;
|
|
23
|
-
};
|
|
24
|
-
/** Versioned response-level half of the pi-ai replay envelope. */
|
|
25
|
-
export interface PiAiReplayResponse {
|
|
26
|
-
kind: 'pi-ai';
|
|
27
|
-
version: 2;
|
|
28
|
-
api: Api;
|
|
29
|
-
/** Requested DSH provider identity, matching the durable assistant source. */
|
|
30
|
-
provider: string;
|
|
31
|
-
/** Native SDK provider when it differs from the DSH route. */
|
|
32
|
-
sdkProvider?: string;
|
|
33
|
-
/** Requested model identity, matching the durable assistant source. */
|
|
34
|
-
model: string;
|
|
35
|
-
/** Provider-reported model; informational only, so requested identity still matches replay signatures. */
|
|
36
|
-
responseModel?: string;
|
|
37
|
-
responseId?: string;
|
|
38
|
-
/** Provider-native effort for historical replay; absence is preserved. */
|
|
39
|
-
providerThinkingLevel?: string;
|
|
40
|
-
stopReason: AssistantMessage['stopReason'];
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Project a successful pi-ai response into the minimal durable replay state.
|
|
44
|
-
* The per-block half is index-aligned with the streamed blocks (pi-ai content
|
|
45
|
-
* order), so `BlockAssembler` prunes an entry with its block whenever assembly
|
|
46
|
-
* removes one.
|
|
47
|
-
* @param message - completed native pi-ai assistant response.
|
|
48
|
-
* @param requestedModel - request identity stored in the assistant source; defaults to the native model.
|
|
49
|
-
* @param requestedProvider - DSH route stored in the assistant source; defaults to the native provider.
|
|
50
|
-
* @returns the versioned lossless-JSON replay projection.
|
|
51
|
-
*/
|
|
52
|
-
export declare function toPiReplayState(message: AssistantMessage, requestedModel?: string, requestedProvider?: string): ReplayEnvelope;
|
|
53
|
-
/**
|
|
54
|
-
* Convert one durable Harness assistant message into pi-ai history.
|
|
55
|
-
*
|
|
56
|
-
* Durable content is the authoritative record; replay metadata only restores
|
|
57
|
-
* native fidelity (ids, signatures). A replay state this build cannot use —
|
|
58
|
-
* another adapter's kind, another version, a malformed value, or metadata that
|
|
59
|
-
* no longer matches the content — therefore degrades the one message to
|
|
60
|
-
* provider-neutral history instead of failing the request.
|
|
61
|
-
* @param message - assistant content with required source and optional adapter-owned replay metadata.
|
|
62
|
-
* @param onDegrade - called with the diagnostic reason when an unusable replay
|
|
63
|
-
* state falls back to provider-neutral conversion.
|
|
64
|
-
* @returns a native pi-ai assistant message reconstructed from durable content.
|
|
65
|
-
*/
|
|
66
|
-
export declare function toPiAssistant(message: Message, onDegrade?: (reason: string) => void): AssistantMessage;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* pi-ai assistant event translation into the Harness streaming protocol.
|
|
3
|
-
*
|
|
4
|
-
* pi-ai tool-call arguments are parsed objects while the Harness keeps their
|
|
5
|
-
* raw JSON representation. pi-ai also reports failures as terminal stream
|
|
6
|
-
* events, which this module maps into Harness finish chunks.
|
|
7
|
-
*
|
|
8
|
-
* @module dsh-opencode-go/conversion/stream
|
|
9
|
-
*/
|
|
10
|
-
import type { FinishReason, StreamChunk, TokenUsage } from '@deepseek-ai/dsh-llm';
|
|
11
|
-
import type { AssistantMessage, AssistantMessageEvent, Usage as PiUsage } from '../sdk-types.ts';
|
|
12
|
-
/**
|
|
13
|
-
* Map pi-ai usage (reasoning folded into output by pi-ai).
|
|
14
|
-
* @param usage - cumulative usage from the terminal pi-ai event.
|
|
15
|
-
* @returns harness counts with pi-ai's exact total; cache fields appear only
|
|
16
|
-
* when non-zero (pi-ai reports zeros, not absence).
|
|
17
|
-
*/
|
|
18
|
-
export declare function mapUsage(usage: PiUsage): TokenUsage;
|
|
19
|
-
/**
|
|
20
|
-
* Map a terminal pi-ai event to the harness finish reason.
|
|
21
|
-
* @param message - the assistant message carried by the `done` or `error` event.
|
|
22
|
-
* @param contextWindow - resolved catalog capacity for usage-based overflow detection.
|
|
23
|
-
* @returns the mapped harness reason. Recognized error text, `stop` usage above
|
|
24
|
-
* `contextWindow`, and zero-output `length` usage that fills the window map
|
|
25
|
-
* to `CONTEXT_WINDOW_EXCEEDED`; a `stop` with no content blocks maps to an
|
|
26
|
-
* `EMPTY_RESPONSE` error, while terminal `pending` and `deferred` states map
|
|
27
|
-
* to non-retryable `PI_AI_ERROR` failures.
|
|
28
|
-
*/
|
|
29
|
-
export declare function mapStopReason(message: AssistantMessage, contextWindow?: number): FinishReason;
|
|
30
|
-
/**
|
|
31
|
-
* Translate the pi-ai event stream into StreamChunks. pi-ai never throws
|
|
32
|
-
* mid-stream — failures arrive as `error` events, which become error/aborted
|
|
33
|
-
* `finish` chunks (the harness protocol's other error-delivery style).
|
|
34
|
-
* @param events - one assistant turn's pi-ai event stream.
|
|
35
|
-
* @param contextWindow - resolved catalog capacity for usage-based overflow detection.
|
|
36
|
-
* @param callerSignal - caller cancellation state; an aborted caller makes any
|
|
37
|
-
* in-band terminal error an aborted finish.
|
|
38
|
-
* @param requestedModel - request model identity recorded for durable replay.
|
|
39
|
-
* @param requestedProvider - DSH provider identity recorded for durable replay.
|
|
40
|
-
* @returns the harness chunks, ending with measured `usage` then `finish`;
|
|
41
|
-
* failures with no measured tokens omit usage to preserve context pressure. Throws
|
|
42
|
-
* `LlmError` (`STREAM_CLOSED`) if the source ends without a terminal event.
|
|
43
|
-
*/
|
|
44
|
-
export declare function toStreamChunks(events: AsyncIterable<AssistantMessageEvent>, contextWindow?: number, callerSignal?: AbortSignal, requestedModel?: string, requestedProvider?: string): AsyncGenerator<StreamChunk>;
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
contextWindow?: number;
|
|
17
|
-
onResponse?: (status: number, requestId?: string) => void;
|
|
18
|
-
});
|
|
19
|
-
private redact;
|
|
20
|
-
readonly fetch: typeof globalThis.fetch;
|
|
21
|
-
failureCode(fallback: string): Promise<string>;
|
|
22
|
-
failureMessage(original: string): Promise<string>;
|
|
23
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
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
|
-
*/
|
|
6
|
-
export declare function migrateGatewayBaseURL(baseURL: string): string;
|
|
@@ -1,6 +0,0 @@
|
|
|
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;
|
|
@@ -1,11 +0,0 @@
|
|
|
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;
|
|
@@ -1,14 +0,0 @@
|
|
|
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, encoding?: 'identity' | 'gzip', fetcher?: typeof globalThis.fetch): Promise<{
|
|
7
|
-
response: Response;
|
|
8
|
-
body: unknown;
|
|
9
|
-
}>;
|
|
10
|
-
/** Fetch normally decodes HTTP; only negotiated gzip may recover a raw gzip body (#7). */
|
|
11
|
-
export declare function readJsonResponse(response: Response, maxBytes: number, options?: {
|
|
12
|
-
gzip?: boolean;
|
|
13
|
-
signal?: AbortSignal | null;
|
|
14
|
-
}): Promise<unknown>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const MODEL_METADATA_MAX_BYTES: number;
|
|
2
|
-
export interface CachedMetadata {
|
|
3
|
-
readonly body: unknown;
|
|
4
|
-
readonly etag?: string;
|
|
5
|
-
/** Last successful download or HTTP 304 verification. */
|
|
6
|
-
readonly savedAtMs: number;
|
|
7
|
-
}
|
|
8
|
-
export declare function metadataCachePath(): string;
|
|
9
|
-
/** Only persist validators that can safely become an HTTP request header. */
|
|
10
|
-
export declare function metadataETag(value: unknown): string | undefined;
|
|
11
|
-
export declare function readMetadataCache(path: string): Promise<CachedMetadata | undefined>;
|
|
12
|
-
export declare function writeMetadataCache(path: string, value: CachedMetadata): Promise<void>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** Convert OpenCode's online models.dev metadata into the supported SDK wire protocols. */
|
|
2
|
-
import type { Api, Model } from './sdk-types.ts';
|
|
3
|
-
import { type GoModel } from './models-contract.ts';
|
|
4
|
-
export declare const MODEL_METADATA_URL = "https://models.dev/api.json";
|
|
5
|
-
/** Lifecycle and capability data the online catalog adds to a gateway listing. */
|
|
6
|
-
export type ModelDetails = Pick<GoModel, 'deprecated' | 'releaseDate' | 'inputModalities'>;
|
|
7
|
-
export interface ModelMetadata {
|
|
8
|
-
readonly models: ReadonlyMap<string, Model<Api>>;
|
|
9
|
-
readonly details: ReadonlyMap<string, ModelDetails>;
|
|
10
|
-
readonly errors: ReadonlyMap<string, string>;
|
|
11
|
-
}
|
|
12
|
-
/** Use the current gateway for every protocol, then normalize SDK paths. */
|
|
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']>;
|
|
16
|
-
/**
|
|
17
|
-
* Only read the opencode-go record. Online endpoints, headers and credentials
|
|
18
|
-
* are deliberately ignored: model traffic always stays on the configured gateway.
|
|
19
|
-
* A bad entry is isolated instead of discarding every other model.
|
|
20
|
-
*/
|
|
21
|
-
export declare function readModelMetadata(body: unknown, baseURL: string, builtin: ReadonlyMap<string, Model<Api>>): ModelMetadata;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/** Settings discovery includes lifecycle data that the host's generic model DTO omits. */
|
|
2
|
-
import type { RemoteResult, TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol';
|
|
3
|
-
export interface GoModel {
|
|
4
|
-
id: string;
|
|
5
|
-
name?: string;
|
|
6
|
-
contextWindow?: number;
|
|
7
|
-
maxTokens?: number;
|
|
8
|
-
/** Token budget controls available to this model, including their catalog bounds. */
|
|
9
|
-
reasoningBudget?: ThinkingBudgetRange;
|
|
10
|
-
deprecated?: boolean;
|
|
11
|
-
releaseDate?: string;
|
|
12
|
-
/** Input modalities models.dev declares, in {@link INPUT_MODALITIES} order. */
|
|
13
|
-
inputModalities?: readonly InputModality[];
|
|
14
|
-
/** Advertised by the gateway but lacking a usable protocol and capability configuration. */
|
|
15
|
-
configurationMissing?: boolean;
|
|
16
|
-
}
|
|
17
|
-
export interface ThinkingBudgetRange {
|
|
18
|
-
min: number;
|
|
19
|
-
max: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Input modalities this page can name. models.dev uses these same five tokens, so
|
|
23
|
-
* an unknown token is dropped rather than rendered as an untranslatable chip.
|
|
24
|
-
*/
|
|
25
|
-
export declare const INPUT_MODALITIES: readonly ["text", "image", "audio", "video", "pdf"];
|
|
26
|
-
export type InputModality = typeof INPUT_MODALITIES[number];
|
|
27
|
-
/**
|
|
28
|
-
* Normalize one `modalities.input` array into display order.
|
|
29
|
-
* @param value - the raw declaration read from models.dev or from a Host response.
|
|
30
|
-
* @returns the declared modalities in {@link INPUT_MODALITIES} order, or
|
|
31
|
-
* `undefined` when nothing recognizable was declared.
|
|
32
|
-
*/
|
|
33
|
-
export declare function normalizeInputModalities(value: unknown): readonly InputModality[] | undefined;
|
|
34
|
-
/** Last successful check of one catalog source, plus any current refresh failure. */
|
|
35
|
-
export interface GoCatalogSourceStatus {
|
|
36
|
-
readonly updatedAt?: number;
|
|
37
|
-
readonly error?: string;
|
|
38
|
-
readonly warning?: string;
|
|
39
|
-
}
|
|
40
|
-
/** A failed refresh retains the Host's usable data with an explicit diagnostic. */
|
|
41
|
-
export interface GoModelCatalog {
|
|
42
|
-
readonly models: readonly GoModel[];
|
|
43
|
-
readonly stale: boolean;
|
|
44
|
-
readonly error?: string;
|
|
45
|
-
/** Optional for clients reading an older Host response. Timestamps are Unix milliseconds. */
|
|
46
|
-
readonly sources?: {
|
|
47
|
-
readonly listing: GoCatalogSourceStatus;
|
|
48
|
-
readonly metadata: GoCatalogSourceStatus;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
/** Missing configuration cannot be enabled; configured models follow explicit switches or lifecycle defaults. */
|
|
52
|
-
export declare function isModelEnabled(model: Pick<GoModel, 'id' | 'deprecated' | 'configurationMissing'>, modelVisibility?: Readonly<Record<string, boolean>>): boolean;
|
|
53
|
-
export declare function validReleaseDate(value: unknown): value is string;
|
|
54
|
-
/** Calendar dates are supplied without a timezone; compare UTC dates consistently. */
|
|
55
|
-
export declare function isNewModel(model: GoModel, now?: number): boolean;
|
|
56
|
-
export declare function sortModels(models: readonly GoModel[], now?: number): GoModel[];
|
|
57
|
-
export declare function parseGoModels(value: unknown): GoModel[];
|
|
58
|
-
export declare function parseGoModelCatalog(value: unknown): GoModelCatalog;
|
|
59
|
-
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
60
|
-
interface TypertRemoteNamespaceMap {
|
|
61
|
-
opencodeGoModels: {
|
|
62
|
-
read(): Promise<RemoteResult<GoModelCatalog>>;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
export declare const modelsRemote: TypertRemoteContribution;
|
package/lib/types/models.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
-
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
3
|
-
import { type OpencodeGoCatalog } from './catalog.ts';
|
|
4
|
-
import type { GoModelCatalog } from './models-contract.ts';
|
|
5
|
-
/** Uses the same gateway snapshot as the adapter, including models hidden from pickers. */
|
|
6
|
-
export declare class GoModelsService extends TypertRemoteService {
|
|
7
|
-
private readonly options;
|
|
8
|
-
constructor(ctx: Context, options: {
|
|
9
|
-
catalog: () => OpencodeGoCatalog;
|
|
10
|
-
onRefresh?: () => void;
|
|
11
|
-
});
|
|
12
|
-
read(): Promise<GoModelCatalog>;
|
|
13
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
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;
|
|
@@ -1,4 +0,0 @@
|
|
|
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/proxy-url.d.ts
DELETED
package/lib/types/proxy.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** Per-mount transport. Fetch closures retain their address across settings changes. */
|
|
2
|
-
export declare class ProxyTransport {
|
|
3
|
-
private current;
|
|
4
|
-
private readonly retired;
|
|
5
|
-
private disposed;
|
|
6
|
-
forProxy(raw?: string): typeof globalThis.fetch | undefined;
|
|
7
|
-
/** Close replaced pools after their in-flight response bodies have finished. */
|
|
8
|
-
private retire;
|
|
9
|
-
/** Unloading the mount cancels remaining requests and releases every pool. */
|
|
10
|
-
dispose(): Promise<void>;
|
|
11
|
-
}
|
package/lib/types/reasoning.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { Api, Model, ModelThinkingLevel, ThinkingBudgets, ThinkingLevelMap } from './sdk-types.ts';
|
|
2
|
-
import type { ThinkingBudgetRange } from './models-contract.ts';
|
|
3
|
-
export declare const THINKING_LEVELS: readonly ModelThinkingLevel[];
|
|
4
|
-
/** Protocol formats whose switch/budget is understood by pi-ai. */
|
|
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;
|
|
9
|
-
export declare function unsupportedThinkingLevels(): ThinkingLevelMap;
|
|
10
|
-
/** Exact model/protocol controls verified against OpenCode Go. */
|
|
11
|
-
export declare function withGatewayReasoning(model: Model<Api>): Model<Api>;
|
|
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
|
-
};
|
package/lib/types/remotes.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** Output allowance shared by model resolution and request dispatch. */
|
|
2
|
-
import type { OpencodeGoModelLimits } from './config-contract.ts';
|
|
3
|
-
/**
|
|
4
|
-
* Reserve 64k by default only for deepseek-v4.1-flash. Other models retain the
|
|
5
|
-
* SDK's default when neither the caller nor settings specify an allowance.
|
|
6
|
-
* Per-model settings continue to cap caller values for every model. The model
|
|
7
|
-
* has already had capacity overrides applied.
|
|
8
|
-
*/
|
|
9
|
-
export declare function requestMaxTokens(model: {
|
|
10
|
-
id: string;
|
|
11
|
-
maxTokens: number;
|
|
12
|
-
}, limits: OpencodeGoModelLimits, requested?: number): number | undefined;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface AccountSettingsWriter {
|
|
2
|
-
describe(): readonly {
|
|
3
|
-
ns: string;
|
|
4
|
-
revision: number;
|
|
5
|
-
value: unknown;
|
|
6
|
-
}[];
|
|
7
|
-
mutate(ns: string, ops: readonly {
|
|
8
|
-
op: 'set';
|
|
9
|
-
path: string[];
|
|
10
|
-
value: unknown;
|
|
11
|
-
}[], expectedRevision?: number): Promise<unknown>;
|
|
12
|
-
}
|
|
13
|
-
/** Prefer the live profile entry when a legacy section also exists. */
|
|
14
|
-
export declare function accountSettingsRow(settings: AccountSettingsWriter): {
|
|
15
|
-
ns: string;
|
|
16
|
-
revision: number;
|
|
17
|
-
value: unknown;
|
|
18
|
-
} | undefined;
|
|
19
|
-
export type SettingsWriteResult = 'applied' | 'rejected' | 'unknown';
|
|
20
|
-
/** A modern verdict is authoritative; legacy writes need a committed-state check. */
|
|
21
|
-
export declare function settingsWriteResult(verdict: unknown, committed: () => boolean): SettingsWriteResult;
|
|
22
|
-
export declare function isSettingsConflict(error: unknown): boolean;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { RemoteResult, TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol';
|
|
2
|
-
import type { GoAccountSwitch } from './accounts.ts';
|
|
3
|
-
export interface UsageWindow {
|
|
4
|
-
status: 'ok' | 'rate-limited';
|
|
5
|
-
percent: number;
|
|
6
|
-
resetsAt: string;
|
|
7
|
-
}
|
|
8
|
-
export interface GoUsage {
|
|
9
|
-
/** Opaque Host identity for this endpoint/account; never a credential or its hash. */
|
|
10
|
-
source?: string;
|
|
11
|
-
lastSwitch?: GoAccountSwitch;
|
|
12
|
-
rolling: UsageWindow;
|
|
13
|
-
weekly: UsageWindow;
|
|
14
|
-
monthly: UsageWindow;
|
|
15
|
-
}
|
|
16
|
-
export declare function parseAccountSwitch(value: unknown): GoAccountSwitch;
|
|
17
|
-
/** Reject missing statistics rather than turning unavailable data into zero. */
|
|
18
|
-
export declare function parseGoUsage(value: unknown): GoUsage;
|
|
19
|
-
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
20
|
-
interface RemoteErrorDetailsMap {
|
|
21
|
-
'opencode-go/usage-unavailable': {
|
|
22
|
-
readonly retryable: boolean;
|
|
23
|
-
readonly retainPrevious: boolean;
|
|
24
|
-
readonly source?: string;
|
|
25
|
-
readonly lastSwitch?: GoAccountSwitch;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
interface TypertRemoteNamespaceMap {
|
|
29
|
-
opencodeGoUsage: {
|
|
30
|
-
read(): Promise<RemoteResult<GoUsage>>;
|
|
31
|
-
readAccount(ref: string): Promise<RemoteResult<GoUsage>>;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export declare const usageRemote: TypertRemoteContribution;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/** Usage visibility shared by the Host schema and the browser settings. */
|
|
2
|
-
export declare const USAGE_DISPLAY_MODES: readonly ["auto", "always", "off"];
|
|
3
|
-
export type UsageDisplayMode = typeof USAGE_DISPLAY_MODES[number];
|
|
4
|
-
export declare const DEFAULT_USAGE_DISPLAY: UsageDisplayMode;
|
package/lib/types/usage.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
-
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
3
|
-
import { type GoUsage } from './usage-contract.ts';
|
|
4
|
-
import type { GoAccountSwitch } from './accounts.ts';
|
|
5
|
-
import { ProxyTransport } from './proxy.ts';
|
|
6
|
-
interface UsageOptions {
|
|
7
|
-
baseURL: () => string;
|
|
8
|
-
proxyURL?: () => string;
|
|
9
|
-
transport?: ProxyTransport;
|
|
10
|
-
resolveApiKey: (ref?: string) => Promise<string | undefined>;
|
|
11
|
-
activeRef?: () => string;
|
|
12
|
-
accountRefs?: () => readonly string[];
|
|
13
|
-
lastSwitch?: () => GoAccountSwitch | undefined;
|
|
14
|
-
}
|
|
15
|
-
/** Account statistics are fetched on the Host; credentials never enter the browser. */
|
|
16
|
-
export declare class GoUsageService extends TypertRemoteService {
|
|
17
|
-
private readonly options;
|
|
18
|
-
private readonly identities;
|
|
19
|
-
private readonly pending;
|
|
20
|
-
private readonly transport;
|
|
21
|
-
constructor(ctx: Context, options: UsageOptions);
|
|
22
|
-
read(): Promise<GoUsage>;
|
|
23
|
-
readAccount(ref: string): Promise<GoUsage>;
|
|
24
|
-
private readRef;
|
|
25
|
-
private fetchUsage;
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
File without changes
|