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.
Files changed (102) hide show
  1. package/README.en.md +66 -12
  2. package/README.md +172 -79
  3. package/THIRD_PARTY_NOTICES.md +6 -2
  4. package/assets/icon.png +0 -0
  5. package/docs/advanced.en.md +32 -35
  6. package/docs/advanced.md +33 -35
  7. package/docs/assets/logo-dark.png +0 -0
  8. package/docs/assets/logo-light.png +0 -0
  9. package/docs/assets/usage-history-desktop.jpg +0 -0
  10. package/docs/assets/usage-history-mobile.jpg +0 -0
  11. package/docs/assets/usage-history-models.jpg +0 -0
  12. package/docs/development.md +61 -119
  13. package/docs/independent-package.md +4 -2
  14. package/docs/usage-analytics.en.md +57 -0
  15. package/docs/usage-analytics.md +57 -0
  16. package/docs/verification.md +51 -917
  17. package/lib/build-info.json +1 -1
  18. package/lib/client.js +3429 -2618
  19. package/lib/free-http-worker.js +32 -0
  20. package/lib/index.js +5135 -3746
  21. package/lib/types/accounts.d.ts +96 -31
  22. package/lib/types/adapter.d.ts +63 -51
  23. package/lib/types/analytics.d.ts +35 -0
  24. package/lib/types/catalog.d.ts +109 -44
  25. package/lib/types/client/AnalyticsDialog.d.ts +18 -0
  26. package/lib/types/client/Section.d.ts +41 -7
  27. package/lib/types/client/UsagePill.d.ts +15 -6
  28. package/lib/types/client/controller.d.ts +178 -0
  29. package/lib/types/client/dashboard-copy.d.ts +58 -0
  30. package/lib/types/client/index.d.ts +18 -12
  31. package/lib/types/client/{locales.d.ts → presentation.d.ts} +97 -9
  32. package/lib/types/config.d.ts +14 -15
  33. package/lib/types/contracts.d.ts +338 -0
  34. package/lib/types/conversion.d.ts +155 -0
  35. package/lib/types/free-channel.d.ts +21 -0
  36. package/lib/types/free-http-worker.d.ts +1 -0
  37. package/lib/types/free-policy.d.ts +4 -0
  38. package/lib/types/free-protocol.d.ts +16 -0
  39. package/lib/types/free-runtime.d.ts +2 -0
  40. package/lib/types/free-socks-tunnel.d.ts +4 -0
  41. package/lib/types/free-transport.d.ts +19 -0
  42. package/lib/types/index.d.ts +8 -40
  43. package/lib/types/pricing.d.ts +29 -0
  44. package/lib/types/sdk-types.d.ts +1540 -2902
  45. package/lib/types/transport.d.ts +71 -0
  46. package/lib/vendor-licenses.txt +55 -31
  47. package/package.json +77 -78
  48. package/docs/assets/usage-panel.png +0 -0
  49. package/docs/fork-review-2026-09-25.md +0 -191
  50. package/docs/native-call-comparison-v020-rc2.md +0 -116
  51. package/lib/types/account-manager.d.ts +0 -25
  52. package/lib/types/account-operations.d.ts +0 -31
  53. package/lib/types/account-policy.d.ts +0 -16
  54. package/lib/types/account-recovery.d.ts +0 -2
  55. package/lib/types/account-selection.d.ts +0 -30
  56. package/lib/types/account-service.d.ts +0 -12
  57. package/lib/types/accounts-contract.d.ts +0 -38
  58. package/lib/types/call-trace.d.ts +0 -54
  59. package/lib/types/catalog-manager.d.ts +0 -20
  60. package/lib/types/client/AccountsCard.d.ts +0 -19
  61. package/lib/types/client/ModelEditor.d.ts +0 -20
  62. package/lib/types/client/accounts-controller.d.ts +0 -71
  63. package/lib/types/client/hint-mark.d.ts +0 -17
  64. package/lib/types/client/host-compat.d.ts +0 -7
  65. package/lib/types/client/host-primitives.d.ts +0 -11
  66. package/lib/types/client/section-controller.d.ts +0 -202
  67. package/lib/types/client/settings.d.ts +0 -18
  68. package/lib/types/client/staged-form.d.ts +0 -201
  69. package/lib/types/client/usage.d.ts +0 -4
  70. package/lib/types/config-contract.d.ts +0 -70
  71. package/lib/types/conversion/config.d.ts +0 -4
  72. package/lib/types/conversion/context.d.ts +0 -56
  73. package/lib/types/conversion/image-offload.d.ts +0 -13
  74. package/lib/types/conversion/image-pool.d.ts +0 -24
  75. package/lib/types/conversion/index.d.ts +0 -5
  76. package/lib/types/conversion/replay.d.ts +0 -66
  77. package/lib/types/conversion/stream.d.ts +0 -44
  78. package/lib/types/gateway-diagnostics.d.ts +0 -23
  79. package/lib/types/gateway-error.d.ts +0 -2
  80. package/lib/types/gateway-url.d.ts +0 -6
  81. package/lib/types/google-fetch.d.ts +0 -6
  82. package/lib/types/host-settings.d.ts +0 -11
  83. package/lib/types/json-response.d.ts +0 -14
  84. package/lib/types/metadata-cache.d.ts +0 -12
  85. package/lib/types/model-metadata.d.ts +0 -21
  86. package/lib/types/models-contract.d.ts +0 -66
  87. package/lib/types/models.d.ts +0 -13
  88. package/lib/types/protocol-contract.d.ts +0 -5
  89. package/lib/types/protocol-policy.d.ts +0 -4
  90. package/lib/types/provider-identity.d.ts +0 -4
  91. package/lib/types/proxy-url.d.ts +0 -2
  92. package/lib/types/proxy.d.ts +0 -11
  93. package/lib/types/reasoning.d.ts +0 -40
  94. package/lib/types/remote-contract.d.ts +0 -3
  95. package/lib/types/remotes.d.ts +0 -3
  96. package/lib/types/request-budget.d.ts +0 -12
  97. package/lib/types/request-control.d.ts +0 -2
  98. package/lib/types/settings-bridge.d.ts +0 -22
  99. package/lib/types/usage-contract.d.ts +0 -35
  100. package/lib/types/usage-display.d.ts +0 -4
  101. package/lib/types/usage.d.ts +0 -27
  102. /package/lib/types/{google-generative-ai.d.ts → google.d.ts} +0 -0
@@ -1,19 +0,0 @@
1
- import type { GoAccountsActions, GoAccountsState } from './accounts-controller.ts';
2
- import type { en } from './locales.ts';
3
- type Translate = (key: keyof typeof en, params?: Record<string, unknown>) => string;
4
- /**
5
- * The account card: a folded header that summarizes the set, and one row per
6
- * account inside. Rows keep the identity, key state, rolling quota and its reset
7
- * countdown; everything else opens under the row. The handle is the drag source —
8
- * dragging it, or the arrow keys on it, reorders the list, and the first row is
9
- * the preferred account. Every row is read in the same pass, so the one refresh
10
- * stamp belongs to the card and sits in its header.
11
- */
12
- export declare function AccountsCard({ state, actions, writable, t, locale }: {
13
- state: GoAccountsState;
14
- actions: GoAccountsActions;
15
- writable: boolean;
16
- t: Translate;
17
- locale?: string;
18
- }): import("react").JSX.Element;
19
- export {};
@@ -1,20 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- import type { OpencodeGoModelLimit, OpencodeGoModelLimits, OpencodeGoModels } from './section-controller.ts';
3
- import type { en } from './locales.ts';
4
- type Translate = (key: keyof typeof en, params?: Record<string, unknown>) => string;
5
- export declare function hasCapacityOverride(limit: OpencodeGoModelLimit | null | undefined): boolean;
6
- /** Per-model switches apply immediately; capacity edits stay in the staged form. */
7
- export declare function ModelEditor({ models, draft, modelVisibility, t, locale, disabled, visibilitySaving, filterAction, onEdit, onModelEnabled }: {
8
- models: OpencodeGoModels;
9
- draft: OpencodeGoModelLimits;
10
- modelVisibility: Readonly<Record<string, boolean>>;
11
- t: Translate;
12
- locale?: string;
13
- disabled: boolean;
14
- visibilitySaving: boolean;
15
- /** Optional control pinned to the right of the filter row, such as a refresh. */
16
- filterAction?: ReactNode;
17
- onEdit: (next: OpencodeGoModelLimits) => void;
18
- onModelEnabled: (id: string, enabled: boolean) => void;
19
- }): import("react").JSX.Element;
20
- export {};
@@ -1,71 +0,0 @@
1
- import type { Context } from '@deepseek-ai/cordis';
2
- import { type AccountSettings, type GoAccount } from '../accounts.ts';
3
- import type { GoUsage } from '../usage-contract.ts';
4
- import type { SettingsScope } from './settings.ts';
5
- import type { AccountCommand } from '../accounts-contract.ts';
6
- import type { SettingsWriteResult } from '../settings-bridge.ts';
7
- export type ExecuteAccountCommand = (command: AccountCommand) => Promise<SettingsWriteResult>;
8
- export interface GoAccountView extends GoAccount {
9
- configured?: boolean;
10
- writable?: boolean;
11
- usage?: GoUsage;
12
- updatedAt?: number;
13
- stale?: boolean;
14
- loading?: boolean;
15
- failed?: boolean;
16
- /** Why the last quota read failed, safe to show: it carries no credential value. */
17
- problem?: string;
18
- }
19
- export interface GoAccountsState {
20
- entries: readonly GoAccountView[];
21
- activeRef: string;
22
- autoSwitch: boolean;
23
- busy: boolean;
24
- blocked: boolean;
25
- refreshing: boolean;
26
- failure?: 'write' | 'cleanup' | 'remove' | 'read';
27
- }
28
- export interface GoAccountsActions {
29
- loadAccounts: () => void;
30
- addAccount: (name: string, key: string) => Promise<boolean>;
31
- /** A newly opened addition form owns a fresh ID; retries keep its existing ID. */
32
- resetAddition?: () => void;
33
- renameAccount: (ref: string, name: string) => Promise<boolean>;
34
- removeAccount: (ref: string) => Promise<boolean>;
35
- selectAccount: (ref: string) => Promise<boolean>;
36
- setAutoSwitch: (next: boolean) => Promise<boolean>;
37
- replaceAccountKey: (ref: string, key: string) => Promise<boolean>;
38
- /** Move one account to a new position; the first row becomes the preferred account. */
39
- moveAccount: (ref: string, toIndex: number) => Promise<boolean>;
40
- }
41
- /** Immediate account operations, separate from the page's staged tuning form. */
42
- export declare class GoAccountsController {
43
- private readonly scope;
44
- private readonly ctx;
45
- private readonly readUsage;
46
- private readonly publish;
47
- private readonly blocked;
48
- private readonly execute;
49
- private rows;
50
- private busy;
51
- private refreshing;
52
- private failure;
53
- private epoch;
54
- private identity;
55
- private loaded;
56
- private disposed;
57
- private addition;
58
- constructor(scope: SettingsScope<AccountSettings & {
59
- baseURL?: string;
60
- proxyURL?: string;
61
- }>, ctx: Context, readUsage: (ref: string) => Promise<GoUsage>, publish: () => void, blocked: () => boolean, execute?: ExecuteAccountCommand);
62
- snapshot(): GoAccountsState;
63
- sync(): void;
64
- dispose(): void;
65
- invalidate(ref: string): void;
66
- refresh(): Promise<void>;
67
- /** Mark every account row as unreadable with the Host's own diagnostic. */
68
- private markUnreadable;
69
- actions(): GoAccountsActions;
70
- private run;
71
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * The hint mark a label carries and the sentence behind it.
3
- *
4
- * The Host's own Tooltip opens the sentence on hover and on keyboard focus, while
5
- * the same sentence stays in the document so assistive technology reads it without
6
- * opening anything. A Host that ships no question glyph still gets a mark, and a
7
- * Host with no Tooltip keeps the sentence visible instead of hiding it.
8
- */
9
- /** A focusable help trigger; fields also retain their {@link HintText} description. */
10
- export declare function HintMark(props: {
11
- hint: string;
12
- }): import("react").JSX.Element;
13
- /** The hint sentence, at the id a control points its `aria-describedby` at. */
14
- export declare function HintText(props: {
15
- id: string;
16
- hint: string;
17
- }): import("react").JSX.Element;
@@ -1,7 +0,0 @@
1
- import type { Context } from '@deepseek-ai/cordis';
2
- import { type OpencodeGoSettings } from '../config-contract.ts';
3
- import type { SettingsScope } from './settings.ts';
4
- import type { ExecuteAccountCommand } from './accounts-controller.ts';
5
- /** Only the boundary knows whether the host exposes profile forms or legacy scopes. */
6
- export declare function mountSettingsScopes(ctx: Context, mount: (ctx: Context, scope: SettingsScope<OpencodeGoSettings>) => void): void;
7
- export declare function accountCommands(ctx: Context): ExecuteAccountCommand;
@@ -1,11 +0,0 @@
1
- /**
2
- * Host UI atoms this page reaches for across DSH generations.
3
- *
4
- * Icon names moved from pixel size (`IconQuestionOutline14`, DSH 0.1.6 and older) to
5
- * stroke weight (`IconQuestionOutlineRegular`, 0.1.7 and later), and the old alias is
6
- * gone in 0.2. A missing atom is not a cosmetic loss here: React throws on an
7
- * undefined element type, which takes the whole settings surface down with it, so
8
- * every lookup resolves the current name first and keeps the older one behind it.
9
- */
10
- /** The atom's component, or undefined when this Host ships neither name. */
11
- export declare function hostAtom<T>(host: Record<string, unknown>, current: string, previous: string): T | undefined;
@@ -1,202 +0,0 @@
1
- /**
2
- * The OpenCode Go settings page's staged form over the `llm-opencode-go`
3
- * settings namespace, plus the gateway model listing the page reports.
4
- *
5
- * The key is the one control that does not live in the section: its literal
6
- * never rides a response, so the page learns only whether one is configured
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
- * covers everything the page shows.
10
- */
11
- import type { Context as ClientContext } from '@deepseek-ai/cordis';
12
- import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol';
13
- import type { GoModel, GoModelCatalog } from '../models-contract.ts';
14
- import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
15
- import type { SettingsScope } from './settings.ts';
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
- import { type FieldState, type FormActions, type FormShell } from './staged-form.ts';
20
- /** Namespace shared with the host through the browser-safe configuration contract. */
21
- export declare const OPENCODE_GO_NS = "llm-opencode-go";
22
- /** The gateway's model listing as the page reports it. */
23
- export type OpencodeGoModels =
24
- /** Not asked for yet; the page asks once it mounts. */
25
- {
26
- readonly status: 'idle';
27
- }
28
- /** A listing request is outstanding. */
29
- | {
30
- readonly status: 'loading';
31
- }
32
- /**
33
- * The gateway answered: a count/preview for the compact summary plus every
34
- * discovered entry used by the capacity editor.
35
- */
36
- | {
37
- readonly status: 'ready';
38
- readonly count: number;
39
- readonly preview: readonly string[];
40
- readonly entries: readonly GoModel[];
41
- readonly stale?: boolean;
42
- readonly message?: string;
43
- readonly refreshing?: boolean;
44
- readonly sources?: GoModelCatalog['sources'];
45
- }
46
- /** The listing could not be read; `message` is the Host's own diagnostic. */
47
- | {
48
- readonly status: 'failed';
49
- readonly message?: string;
50
- readonly sources?: GoModelCatalog['sources'];
51
- };
52
- /** What the settings page renders. */
53
- export interface OpencodeGoSectionState extends FormShell {
54
- accounts?: GoAccountsState;
55
- /**
56
- * Whether the adapter currently serves its route. Resolved from the section
57
- * rather than staged: the switch writes on the click that flips it, because
58
- * a withdrawn route is what the user is trying to observe.
59
- */
60
- enabled: boolean;
61
- usageDisplay: FieldState;
62
- protocolOverrides: FieldState;
63
- modelVisibility: Readonly<Record<string, boolean>>;
64
- pickerSaving: boolean;
65
- pickerFailed: boolean;
66
- /** The gateway endpoint. */
67
- baseURL: FieldState;
68
- proxyURL: FieldState;
69
- /** Live catalog re-resolution interval, in minutes. */
70
- refreshMinutes: FieldState;
71
- /** Largest idle gap between stream events, in milliseconds. */
72
- streamIdleTimeoutMs: FieldState;
73
- /** Optional retained image occurrence cap; blank inherits the base configuration. */
74
- maxImages: FieldState;
75
- /** Accumulated base64 image payload bound for one request. */
76
- maxRequestImageBytes: FieldState;
77
- /** Total-pixel budget for one request image. */
78
- requestImagePixelBudget: FieldState;
79
- /** Raw encoded-byte target for one request image. */
80
- requestImageMaxBytes: FieldState;
81
- /** The staged credential, which starts blank on every load. */
82
- apiKey: FieldState;
83
- /** Whether the Host reports a credential configured for the referenced key. */
84
- apiKeyConfigured: boolean;
85
- /** Whether the credentials domain accepts a write for it; false disables the control. */
86
- apiKeyWritable: boolean;
87
- /** The gateway's current model listing. */
88
- models: OpencodeGoModels;
89
- /** The staged JSON field backing the capacity table. */
90
- modelLimits: FieldState;
91
- /** The parsed overrides currently shown by the capacity table. */
92
- modelLimitDraft: OpencodeGoModelLimits;
93
- }
94
- /** The registration-side face the page's slot entry injects. */
95
- export interface OpencodeGoSectionFace extends FormActions, GoAccountsActions {
96
- hooks: {
97
- /** Page snapshot bound by the UI renderer as useOpencodeGo. */
98
- opencodeGo: SnapshotStore<OpencodeGoSectionState>;
99
- };
100
- /** Read the gateway's model listing, now or again after a failure. */
101
- loadModels: () => void;
102
- /**
103
- * Turn the adapter's route on or off, writing immediately.
104
- * @param next - the state the switch asks for.
105
- */
106
- setEnabled: (next: boolean) => void;
107
- setModelEnabled: (id: string, next: boolean) => void;
108
- }
109
- /** Bridges the `llm-opencode-go` scope and the credentials domain onto the page. */
110
- export declare class OpencodeGoSectionController {
111
- private readonly scope;
112
- private readonly ctx;
113
- private readonly readModels;
114
- private readonly executeAccountCommand;
115
- private readonly form;
116
- private readonly store;
117
- private credential;
118
- private models;
119
- private modelsRequest;
120
- private pickerSaving;
121
- private pickerFailed;
122
- private face;
123
- private readonly unsubscribe;
124
- private accounts;
125
- private credentialRequest;
126
- private keyDraftRef;
127
- /**
128
- * @param scope - the bound settings scope for the `llm-opencode-go` namespace.
129
- * @param ctx - the page plugin's context, whose `remote.credentials` namespace
130
- * answers for the credential the section references.
131
- */
132
- constructor(scope: SettingsScope<OpencodeGoSettings>, ctx: ClientContext, readModels?: () => Promise<RemoteResult<GoModelCatalog>>, readUsage?: (ref: string) => Promise<import('../usage-contract.ts').GoUsage>, executeAccountCommand?: ExecuteAccountCommand);
133
- /** Release subscriptions without disposing the host's shared form. */
134
- dispose(): void;
135
- private projection;
136
- /**
137
- * Read the overrides as the page currently shows them. A staged JSON draft
138
- * wins while it is valid; malformed text falls back to the last accepted
139
- * settings value so the table never renders phantom rows.
140
- */
141
- private limitDraft;
142
- /**
143
- * The adapter's effective switch state: the resolved section's value, over
144
- * the Host's own default when the section carries none.
145
- * @returns whether the route is currently served.
146
- */
147
- private enabled;
148
- /**
149
- * Flip the switch by writing the field on the click itself.
150
- *
151
- * Like the per-model switches, this control does not wait for Save: the point
152
- * of turning it off is to watch the models leave the pickers, and the point
153
- * of turning it back on is to use the route again — staging either behind a
154
- * second gesture would report a state the Host does not hold. The write is
155
- * revision-fenced by the scope like every other, and a refusal surfaces as a
156
- * failed save through the shared shell rather than a silent revert.
157
- * @param next - the state the switch asks for.
158
- */
159
- setEnabled(next: boolean): Promise<void>;
160
- /** Each model switch has one committed value and takes effect without Save. */
161
- setModelEnabled(id: string, next: boolean): Promise<void>;
162
- /** Serialize immediate switches with form saves; refused writes retain committed values. */
163
- private writePickerSetting;
164
- /**
165
- * Read the gateway's model listing through the Host's discovery for this
166
- * adapter. Called when the page mounts and again from its refresh control.
167
- * A rejection settles as a failure too: the refresh control is disabled
168
- * while loading and the next read starts only from `idle`, so leaving the
169
- * state loading would strand the page with no way to ask the gateway again.
170
- */
171
- loadModels(): void;
172
- /**
173
- * Ask the credentials domain about the reference the section currently names.
174
- *
175
- * The answer is stored with the reference it describes: `apiKeyEnv` can
176
- * change between the request and its response, and two reads can settle out
177
- * of order, so a response is published only while it still answers for the
178
- * reference in force.
179
- */
180
- private readCredential;
181
- /**
182
- * Re-read after the Host reports a change to the reference this page watches.
183
- *
184
- * A key can be written from somewhere else — the Models page addresses the
185
- * same reference — and the settings section does not change when it is, so
186
- * without this the badge keeps reporting a state the Host already replaced.
187
- * @param ref - the reference the Host reports as changed.
188
- */
189
- refreshCredential(ref: string): void;
190
- /**
191
- * Build the face the page's slot registration injects. Built once: the store
192
- * is what changes, and the renderer binds the same callbacks across renders.
193
- * @returns the page snapshot and its form actions.
194
- */
195
- inject(): OpencodeGoSectionFace;
196
- /**
197
- * Ask the account service to write the staged key, then refresh its display.
198
- * @param value - the staged credential literal.
199
- * @returns whether the Host confirmed the write.
200
- */
201
- private writeKey;
202
- }
@@ -1,18 +0,0 @@
1
- import type { SettingsPathOpView } from '@deepseek-ai/dsh-api-remotes/client';
2
- /** Common read/write contract of legacy SettingsScope and 0.1.7 ConfigForm. */
3
- export interface SettingsScopeSnapshot<T> {
4
- status: 'loading' | 'ready' | 'unavailable';
5
- value: T | undefined;
6
- base: unknown;
7
- user: unknown;
8
- revision: number | undefined;
9
- writable: boolean;
10
- mode: 'host' | 'memory';
11
- }
12
- export interface SettingsScope<T> {
13
- getSnapshot(): SettingsScopeSnapshot<T>;
14
- subscribe(listener: () => void): () => void;
15
- mutate(ops: readonly SettingsPathOpView[], expectedRevision?: number): Promise<void | boolean>;
16
- set(field: string, value: unknown): Promise<void | boolean>;
17
- unset(field: string): Promise<void | boolean>;
18
- }
@@ -1,201 +0,0 @@
1
- /**
2
- * The staged form behind the OpenCode Go settings page.
3
- *
4
- * The page stages what the user types and writes it only when they save. Each
5
- * settings batch is a durable, revision-fenced document mutation, so a control
6
- * that committed as it settled turned one edit into a write the user never
7
- * asked for and could not preview; staged text makes what is on screen exactly
8
- * what a save would store.
9
- *
10
- * A field shows its effective value — the user layer over the composition
11
- * layer over the schema default — and whether the user layer carries it. That
12
- * presence, not a value comparison, is what marks a field overridden: an
13
- * override equal to the composition default is still an override.
14
- *
15
- * Copied from the plugin-configuration card form (`ui-settings-plugins`): the
16
- * client bundle purity gate forbids importing it across packages, and the two
17
- * forms evolve independently anyway.
18
- */
19
- import { type SnapshotStore } from '@deepseek-ai/dsh-client-store';
20
- import type { SettingsScope } from './settings.ts';
21
- /** The write one field's staged text performs when the page is saved. */
22
- export type FieldWrite = {
23
- kind: 'set';
24
- value: unknown;
25
- } | {
26
- kind: 'clear';
27
- };
28
- /** How one section field converts between its stored value and its draft text. */
29
- export interface FieldSpec {
30
- /** Field name inside the namespace section. */
31
- field: string;
32
- /** Render a stored value as draft text; the empty string when the section carries none. */
33
- format: (value: unknown) => string;
34
- /**
35
- * The write this draft text stages, or undefined when the text is not a
36
- * value this field accepts — which blocks the save rather than discarding it.
37
- */
38
- parse: (text: string) => FieldWrite | undefined;
39
- }
40
- /**
41
- * A control whose value is written outside the settings section. A credential
42
- * literal never rides a response, so its draft has nothing to seed from: it is
43
- * blank until typed, and a blank draft writes nothing.
44
- */
45
- export interface SecretSpec {
46
- /** Field name addressing this control inside the page's form. */
47
- field: string;
48
- /** Write the staged text; resolves to whether the Host accepted it. */
49
- write: (text: string) => Promise<boolean>;
50
- }
51
- /** One field as the page's control renders it. */
52
- export interface FieldState {
53
- /** Draft text the control renders. */
54
- text: string;
55
- /**
56
- * Whether saving would leave a user-layer entry for this field. A staged
57
- * edit answers for itself, so the badge previews the save rather than
58
- * reporting a state the pending edit already contradicts.
59
- */
60
- overridden: boolean;
61
- /** Whether the draft is not a value this field accepts, which blocks saving. */
62
- invalid: boolean;
63
- }
64
- /** Form state the page shell shares across its controls. */
65
- export interface FormShell {
66
- /** False while the namespace is not served to this client; the page renders nothing. */
67
- available: boolean;
68
- /** Whether the Host document accepts writes. */
69
- writable: boolean;
70
- /** Whether the form holds edits that a save would write. */
71
- dirty: boolean;
72
- /** Whether any staged draft is invalid, which blocks the save. */
73
- invalid: boolean;
74
- /** Whether a save is crossing the wire. */
75
- saving: boolean;
76
- /** Whether the last save did not land as staged; cleared by the next edit or save. */
77
- failed: boolean;
78
- }
79
- /** The write actions the page's slot entry injects. */
80
- export interface FormActions {
81
- /** Stage draft text for one field. */
82
- edit: (field: string, text: string) => void;
83
- /** Stage a clear, so saving lets the field re-inherit the composition layer. */
84
- resetField: (field: string) => void;
85
- /** Write every staged edit, then re-seed from what the Host accepted. */
86
- save: () => void;
87
- /** Drop every staged edit. */
88
- discard: () => void;
89
- }
90
- /**
91
- * A numeric field. An empty draft clears the field; other drafts must be
92
- * finite numbers and satisfy the optional constraint before saving.
93
- * @param field - field name inside the namespace section.
94
- * @param validate - additional numeric constraint, if needed.
95
- * @returns the field's conversion spec.
96
- */
97
- export declare function numberField(field: string, validate?: (value: number) => boolean): FieldSpec;
98
- /**
99
- * A two-state field. Unlike the text fields, the draft is the boolean itself
100
- * rather than text: the control that renders it reports the state the user
101
- * asked for, and an unset section resolves to the composition default the
102
- * schema supplied. Its draft text is the state's string form so the shared
103
- * override and invalid tracking needs no second branch.
104
- * @param field - field name inside the namespace section.
105
- * @returns the field's conversion spec.
106
- */
107
- export declare function booleanField(field: string): FieldSpec;
108
- /**
109
- * A free-text field. An empty draft clears the field, so emptying the control
110
- * and saving is the same gesture as resetting it.
111
- * @param field - field name inside the namespace section.
112
- * @returns the field's conversion spec.
113
- */
114
- export declare function textField(field: string): FieldSpec;
115
- /**
116
- * A structured field edited as JSON text. Empty text clears the field and
117
- * malformed JSON blocks the save instead of reaching the Host as a string.
118
- * @param field - field name inside the namespace section.
119
- * @returns the field's conversion spec.
120
- */
121
- export declare function jsonField(field: string): FieldSpec;
122
- /**
123
- * Stages the page's edits over the `llm-opencode-go` namespace and writes them
124
- * on save.
125
- *
126
- * The form publishes through a snapshot store because the slot component reads
127
- * through a snapshot selector, while both the scope and the local drafts
128
- * change underneath; every projection is rebuilt from the two together.
129
- */
130
- export declare class StagedForm {
131
- private readonly scope;
132
- private readonly specs;
133
- private readonly secretSpecs;
134
- private readonly staged;
135
- private readonly listeners;
136
- private readonly unsubscribe;
137
- private saving;
138
- private failed;
139
- /**
140
- * @param scope - the bound settings scope for this page's namespace.
141
- * @param specs - the section fields this page edits.
142
- * @param secrets - the page's write-only controls, written outside the section.
143
- */
144
- constructor(scope: SettingsScope<Record<string, unknown>>, specs: FieldSpec[], secrets?: SecretSpec[]);
145
- /** Shared 0.1.7 forms outlive individual settings pages. */
146
- dispose(): void;
147
- /**
148
- * Publish a projection of this form, rebuilt whenever the scope or a draft changes.
149
- * @param project - build the page state from the form's current reads.
150
- * @returns the store the component reads through its bound selector.
151
- */
152
- bind<S>(project: () => S): SnapshotStore<S>;
153
- /**
154
- * Read the page-level state: what the Host serves, and what a save would do.
155
- * @returns the form state the page shell shares.
156
- */
157
- shell(): FormShell;
158
- /**
159
- * Read one control's state.
160
- * @param field - field name of a section field or of a write-only control.
161
- * @returns the draft text, whether a save would leave an override, and whether it is invalid.
162
- */
163
- field(field: string): FieldState;
164
- /**
165
- * Build the edit, reset, save, and discard actions bound to this form.
166
- * @returns the actions the page's slot entry injects.
167
- */
168
- actions(): FormActions;
169
- /**
170
- * Write every staged edit, then re-seed from what the Host accepted.
171
- *
172
- * The Host is the only authority on whether a value was accepted — its
173
- * validators own the constraints no schema can express — so the outcome is
174
- * read back from the section rather than predicted here. A save that did not
175
- * land keeps its drafts, so the user can correct them instead of retyping.
176
- */
177
- save(): Promise<void>;
178
- /**
179
- * Every staged edit a save would write. An entry whose draft is not a value
180
- * its field accepts carries no write: the form is still dirty, and the save
181
- * refuses rather than dropping the edit.
182
- * @returns the planned writes, in the order the fields were staged.
183
- */
184
- private plan;
185
- private stage;
186
- private spec;
187
- private snapshotOf;
188
- private sectionValue;
189
- private baseValue;
190
- private userLayer;
191
- private stored;
192
- /**
193
- * Whether a draft already equals the field's effective value, so a save would
194
- * write nothing. The save plan and the override badge both answer for it.
195
- * @param field - field name inside the namespace section.
196
- * @param staged - the staged edit to test.
197
- * @returns true when the draft is a no-op; a clear is never one.
198
- */
199
- private unchangedDraft;
200
- private publish;
201
- }
@@ -1,4 +0,0 @@
1
- import type { Context } from '@deepseek-ai/cordis';
2
- import type { SettingsScope } from './settings.ts';
3
- import type { OpencodeGoSettings } from './section-controller.ts';
4
- export declare function registerUsagePill(ctx: Context, settings: SettingsScope<OpencodeGoSettings>, selectAccount?: (ref: string) => Promise<boolean>): void;
@@ -1,70 +0,0 @@
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>;
@@ -1,4 +0,0 @@
1
- /** Default image budgets, overridable through the adapter configuration. */
2
- export declare const DEFAULT_MAX_REQUEST_IMAGE_BYTES: number;
3
- export declare const DEFAULT_REQUEST_IMAGE_PIXEL_BUDGET: number;
4
- export declare const DEFAULT_REQUEST_IMAGE_MAX_BYTES: number;