@telsoncc/opencode-commandcode 1.2.32 → 1.2.34
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/CHANGELOG.md +6 -220
- package/_version.txt +1 -1
- package/dist/_version.txt +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +19 -0
- package/dist/manifest.json +28 -0
- package/dist/models.json +3334 -0
- package/dist/plugin-opencode2.d.ts +30 -0
- package/dist/plugin-opencode2.js +127 -0
- package/dist/plugin.d.ts +27 -0
- package/dist/plugin.js +192 -0
- package/dist/src/auth.d.ts +5 -0
- package/dist/src/auth.js +38 -0
- package/dist/src/catalog-break.d.ts +12 -0
- package/dist/src/catalog-break.js +33 -0
- package/dist/src/catalog-release-notes.d.ts +30 -0
- package/dist/src/catalog-release-notes.js +106 -0
- package/dist/src/catalog.d.ts +160 -0
- package/dist/src/catalog.js +786 -0
- package/dist/src/convert.d.ts +71 -0
- package/dist/src/convert.js +154 -0
- package/dist/src/costs-docs.d.ts +13 -0
- package/dist/src/costs-docs.js +170 -0
- package/dist/src/costs-models-dev.d.ts +68 -0
- package/dist/src/costs-models-dev.js +303 -0
- package/dist/src/cut-changelog.d.ts +1 -0
- package/dist/src/cut-changelog.js +43 -0
- package/dist/src/manifest.d.ts +72 -0
- package/dist/src/manifest.js +111 -0
- package/dist/src/model.d.ts +18 -0
- package/dist/src/model.js +138 -0
- package/dist/src/opencode2.d.ts +179 -0
- package/dist/src/opencode2.js +386 -0
- package/dist/src/pack-contract.d.ts +25 -0
- package/dist/src/pack-contract.js +42 -0
- package/dist/src/publish-policy.d.ts +18 -0
- package/dist/src/publish-policy.js +16 -0
- package/dist/src/startup.d.ts +18 -0
- package/dist/src/startup.js +31 -0
- package/dist/src/stream.d.ts +2 -0
- package/dist/src/stream.js +203 -0
- package/manifest.json +7 -7
- package/models.json +38 -66
- package/package.json +12 -7
- package/plugin.ts +14 -3
- package/src/cut-changelog.ts +6 -1
- package/src/opencode2.ts +14 -3
- package/src/pack-contract.ts +51 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export declare const NPM_PACKAGE = "command-code";
|
|
2
|
+
export interface ModelEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
tier: "premium" | "open-source";
|
|
6
|
+
reasoning: boolean;
|
|
7
|
+
reasoningEfforts?: string[];
|
|
8
|
+
tool_call: boolean;
|
|
9
|
+
cost: {
|
|
10
|
+
input: number;
|
|
11
|
+
output: number;
|
|
12
|
+
cache_read?: number;
|
|
13
|
+
cache_write?: number;
|
|
14
|
+
};
|
|
15
|
+
limit: {
|
|
16
|
+
context: number;
|
|
17
|
+
output: number;
|
|
18
|
+
};
|
|
19
|
+
attachment?: boolean;
|
|
20
|
+
modalities?: {
|
|
21
|
+
input: string[];
|
|
22
|
+
output: string[];
|
|
23
|
+
};
|
|
24
|
+
/** Runtime estimate from models.dev — replaced on the next catalog sync. */
|
|
25
|
+
estimated?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Wire endpoints the gateway serves this model on, as advertised by the
|
|
28
|
+
* vendor `/models` payload (`supported_endpoints`). Absent on catalogs
|
|
29
|
+
* extracted before the field existed; `modelTransport` falls back to the
|
|
30
|
+
* model family in that case.
|
|
31
|
+
*/
|
|
32
|
+
supportedEndpoints?: string[];
|
|
33
|
+
}
|
|
34
|
+
/** OpenAI-shaped wire (`/chat/completions`) vs Anthropic Messages (`/messages`). */
|
|
35
|
+
export type ModelTransport = "chat" | "messages";
|
|
36
|
+
/**
|
|
37
|
+
* Which wire shape a model is served on. A model that is Messages-only cannot
|
|
38
|
+
* be called through `/chat/completions` — the gateway rejects it with
|
|
39
|
+
* `must be called via /provider/v1/messages` — so the transport has to be
|
|
40
|
+
* resolved per model, not per provider.
|
|
41
|
+
*
|
|
42
|
+
* Falls back to the model family when the catalog carries no
|
|
43
|
+
* `supported_endpoints`: the `claude-*` family is the only Messages-only group
|
|
44
|
+
* the gateway serves, so the heuristic is exact for catalogs that predate the
|
|
45
|
+
* field. Family matching runs on the config key, so a vendor-prefixed id like
|
|
46
|
+
* `anthropic/claude-sonnet-5` resolves the same as a bare one.
|
|
47
|
+
*/
|
|
48
|
+
export declare function modelTransport(entry: Pick<ModelEntry, "id" | "supportedEndpoints">): ModelTransport;
|
|
49
|
+
export interface CostEntry {
|
|
50
|
+
id: string;
|
|
51
|
+
provider: string;
|
|
52
|
+
category: string;
|
|
53
|
+
promptCost: number;
|
|
54
|
+
completionCost: number;
|
|
55
|
+
cacheWrite5mCost: number;
|
|
56
|
+
cacheWrite1hCost: number;
|
|
57
|
+
cacheHitCost: number;
|
|
58
|
+
}
|
|
59
|
+
export interface SnEntry {
|
|
60
|
+
id: string;
|
|
61
|
+
provider: string;
|
|
62
|
+
spec: string;
|
|
63
|
+
label: string;
|
|
64
|
+
name: string;
|
|
65
|
+
description: string;
|
|
66
|
+
reasoning?: boolean;
|
|
67
|
+
reasoningEfforts?: string[];
|
|
68
|
+
contextWindow?: number;
|
|
69
|
+
inputModalities?: string[];
|
|
70
|
+
maxOutputTokens?: number;
|
|
71
|
+
}
|
|
72
|
+
export interface ResolvedCommandCodePackage {
|
|
73
|
+
root: string;
|
|
74
|
+
bundlePath: string;
|
|
75
|
+
version: string;
|
|
76
|
+
}
|
|
77
|
+
export interface LocalCatalogResult {
|
|
78
|
+
models: ModelEntry[];
|
|
79
|
+
version: string;
|
|
80
|
+
root: string;
|
|
81
|
+
bundleSource: string;
|
|
82
|
+
}
|
|
83
|
+
export declare const FALLBACK_LIMITS: Record<string, {
|
|
84
|
+
context: number;
|
|
85
|
+
output: number;
|
|
86
|
+
}>;
|
|
87
|
+
export declare const HARDCODED_EXTRAS: SnEntry[];
|
|
88
|
+
export declare const TIER_MAP: Record<string, "premium" | "open-source">;
|
|
89
|
+
/** Object after `(` (legacy IIFE / enum form): `(Wt={...})` */
|
|
90
|
+
export declare function findBalancedObject(source: string, anchor: string): string;
|
|
91
|
+
/** All balanced `{...}` spans that contain the anchor, innermost → outermost. */
|
|
92
|
+
export declare function findEnclosingObjectCandidates(source: string, anchor: string, fromIndex?: number): string[];
|
|
93
|
+
/** Default: innermost enclosing object (good for plain catalogs). */
|
|
94
|
+
export declare function findEnclosingObject(source: string, anchor: string, fromIndex?: number): string;
|
|
95
|
+
export declare function evaluateWithContext(code: string, context: Record<string, unknown>): any;
|
|
96
|
+
export declare function normalizeForEval(code: string): string;
|
|
97
|
+
/** Prefer provider enums that include gateway/openai keys over UI-only enums. */
|
|
98
|
+
export declare function extractBestProviderEnum(source: string): {
|
|
99
|
+
name: string;
|
|
100
|
+
value: Record<string, string>;
|
|
101
|
+
} | null;
|
|
102
|
+
export declare function extractWt(source: string): Record<string, string>;
|
|
103
|
+
export declare function getWtVarName(source: string): string;
|
|
104
|
+
/** Collect nearby `name="value"` bindings and simple aliases (`tI=Qx`). */
|
|
105
|
+
export declare function extractStringBindings(source: string, endIdx: number, window?: number): Record<string, string>;
|
|
106
|
+
export declare function extractSpecConstants(source: string): {
|
|
107
|
+
chatComplete: string;
|
|
108
|
+
responses: string;
|
|
109
|
+
qt: string;
|
|
110
|
+
};
|
|
111
|
+
export declare function extractModelCatalog(source: string, wt?: Record<string, string>, wtName?: string, spec?: ReturnType<typeof extractSpecConstants>): Record<string, SnEntry>;
|
|
112
|
+
export declare function extractCostData(source: string, wt?: Record<string, string>, wtName?: string): Record<string, CostEntry[]>;
|
|
113
|
+
export declare function buildCostMap(costs: Record<string, CostEntry[]>): Map<string, CostEntry>;
|
|
114
|
+
export declare function buildModelEntry(entry: SnEntry, costMap: Map<string, CostEntry>): ModelEntry | null;
|
|
115
|
+
export declare function disambiguateModelNames(entries: ModelEntry[]): ModelEntry[];
|
|
116
|
+
export declare function sortModelEntries(entries: ModelEntry[]): ModelEntry[];
|
|
117
|
+
export declare function loadCatalogFromBundle(source: string): ModelEntry[];
|
|
118
|
+
export declare function resolveCommandCodePackage(options?: {
|
|
119
|
+
packagePath?: string;
|
|
120
|
+
}): ResolvedCommandCodePackage | null;
|
|
121
|
+
export declare function loadCatalogFromLocalCommandCode(options?: {
|
|
122
|
+
packagePath?: string;
|
|
123
|
+
}): LocalCatalogResult | null;
|
|
124
|
+
export declare function toConfigKey(id: string): string;
|
|
125
|
+
export declare function generateOpencodeModels(entries: ModelEntry[]): Record<string, unknown>;
|
|
126
|
+
export declare const MODELS_API_URL = "https://api.commandcode.ai/provider/v1/models";
|
|
127
|
+
export interface FilteredCatalog<T extends {
|
|
128
|
+
id: string;
|
|
129
|
+
}> {
|
|
130
|
+
retained: T[];
|
|
131
|
+
unavailable: string[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* One row of the vendor availability payload. `supported_endpoints` is
|
|
135
|
+
* optional upstream data: it is kept only when it is an array of non-empty
|
|
136
|
+
* strings, so a schema nudge there can never fail a whole catalog sync.
|
|
137
|
+
*/
|
|
138
|
+
export interface AvailabilityModel {
|
|
139
|
+
id: string;
|
|
140
|
+
supportedEndpoints?: string[];
|
|
141
|
+
}
|
|
142
|
+
/** Validate the OpenAI-style `{ object: "list", data: [{ id }] }` availability payload. */
|
|
143
|
+
export declare function parseAvailability(payload: unknown): AvailabilityModel[];
|
|
144
|
+
/** Validate the OpenAI-style `{ object: "list", data: [{ id }] }` availability payload. */
|
|
145
|
+
export declare function parseAvailabilityIds(payload: unknown): string[];
|
|
146
|
+
/**
|
|
147
|
+
* Copy `supported_endpoints` from the availability payload onto matching
|
|
148
|
+
* entries. Entries the payload omits, or lists without usable endpoints, are
|
|
149
|
+
* left untouched — a partial payload never strips transport data already on
|
|
150
|
+
* the catalog. Returns how many entries were updated.
|
|
151
|
+
*/
|
|
152
|
+
export declare function applyAvailabilityEndpoints<T extends {
|
|
153
|
+
id: string;
|
|
154
|
+
supportedEndpoints?: string[];
|
|
155
|
+
}>(entries: T[], availability: readonly AvailabilityModel[]): number;
|
|
156
|
+
/** Retain only candidates whose exact ID is callable; collect sorted excluded IDs. */
|
|
157
|
+
export declare function filterCatalogByAvailability<T extends {
|
|
158
|
+
id: string;
|
|
159
|
+
}>(candidates: T[], availableIds: string[]): FilteredCatalog<T>;
|
|
160
|
+
export declare function catalogModuleDir(): string;
|