@abhishek944/pi-embeddings 0.4.0 → 0.5.0
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.md +9 -4
- package/dist/execute.js +2 -1
- package/dist/extension.js +23 -5
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/provider-types.d.ts +4 -0
- package/dist/providers.d.ts +13 -4
- package/dist/providers.js +147 -4
- package/dist/response.d.ts +11 -0
- package/dist/response.js +64 -3
- package/dist/runtime.d.ts +6 -1
- package/dist/runtime.js +8 -3
- package/dist/schemas.d.ts +275 -22
- package/dist/schemas.js +65 -0
- package/dist/settings.js +3 -1
- package/dist/tool-contracts.d.ts +129 -9
- package/package.json +3 -2
- package/src/execute.ts +2 -1
- package/src/extension.ts +43 -5
- package/src/index.ts +6 -0
- package/src/provider-types.ts +7 -0
- package/src/providers.ts +200 -2
- package/src/response.ts +73 -3
- package/src/runtime.ts +25 -6
- package/src/schemas.ts +87 -0
- package/src/settings.ts +4 -0
package/dist/schemas.js
CHANGED
|
@@ -21,11 +21,34 @@ export const EMBEDDING_ROUTE_IDS = [
|
|
|
21
21
|
'cloudflare',
|
|
22
22
|
'gemini',
|
|
23
23
|
'vertex',
|
|
24
|
+
'opencode',
|
|
25
|
+
'opencode-go',
|
|
24
26
|
];
|
|
25
27
|
export const GATEWAY_EMBEDDING_MODELS = [
|
|
26
28
|
'text-embedding-3-small',
|
|
27
29
|
'openai/text-embedding-3-small',
|
|
28
30
|
];
|
|
31
|
+
/** Console (pay-as-you-go) embedding model IDs documented by OpenCode. */
|
|
32
|
+
export const OPENCODE_EMBEDDING_MODELS = [
|
|
33
|
+
'text-embedding-3-small',
|
|
34
|
+
'text-embedding-3-large',
|
|
35
|
+
'gemini-embedding-2',
|
|
36
|
+
'gemini-embedding-001',
|
|
37
|
+
'codestral-embed',
|
|
38
|
+
'mistral-embed',
|
|
39
|
+
'cohere-embed-v5-pro',
|
|
40
|
+
'cohere-embed-v5-fast',
|
|
41
|
+
'voyage-4',
|
|
42
|
+
'voyage-code-4',
|
|
43
|
+
'qwen3-embedding-8b',
|
|
44
|
+
'bge-m3',
|
|
45
|
+
];
|
|
46
|
+
/** Go subscription embedding model IDs documented by OpenCode. */
|
|
47
|
+
export const OPENCODE_GO_EMBEDDING_MODELS = [
|
|
48
|
+
'text-embedding-3-small',
|
|
49
|
+
'qwen3-embedding-8b',
|
|
50
|
+
'gemini-embedding-2',
|
|
51
|
+
];
|
|
29
52
|
export const OPENROUTER_EMBEDDING_MODELS = ['openai/text-embedding-3-small'];
|
|
30
53
|
export const CLOUDFLARE_EMBEDDING_MODELS = ['@cf/baai/bge-base-en-v1.5'];
|
|
31
54
|
export const GEMINI_EMBEDDING_MODELS = ['gemini-embedding-2'];
|
|
@@ -61,6 +84,25 @@ const gatewayModelSchema = Type.Union([
|
|
|
61
84
|
const openRouterModelSchema = Type.Literal('openai/text-embedding-3-small');
|
|
62
85
|
const cloudflareModelSchema = Type.Literal('@cf/baai/bge-base-en-v1.5');
|
|
63
86
|
const geminiModelSchema = Type.Literal(GEMINI_EMBEDDING_MODELS[0]);
|
|
87
|
+
const openCodeModelSchema = Type.Union([
|
|
88
|
+
Type.Literal('text-embedding-3-small'),
|
|
89
|
+
Type.Literal('text-embedding-3-large'),
|
|
90
|
+
Type.Literal('gemini-embedding-2'),
|
|
91
|
+
Type.Literal('gemini-embedding-001'),
|
|
92
|
+
Type.Literal('codestral-embed'),
|
|
93
|
+
Type.Literal('mistral-embed'),
|
|
94
|
+
Type.Literal('cohere-embed-v5-pro'),
|
|
95
|
+
Type.Literal('cohere-embed-v5-fast'),
|
|
96
|
+
Type.Literal('voyage-4'),
|
|
97
|
+
Type.Literal('voyage-code-4'),
|
|
98
|
+
Type.Literal('qwen3-embedding-8b'),
|
|
99
|
+
Type.Literal('bge-m3'),
|
|
100
|
+
]);
|
|
101
|
+
const openCodeGoModelSchema = Type.Union([
|
|
102
|
+
Type.Literal('text-embedding-3-small'),
|
|
103
|
+
Type.Literal('qwen3-embedding-8b'),
|
|
104
|
+
Type.Literal('gemini-embedding-2'),
|
|
105
|
+
]);
|
|
64
106
|
export const VERTEX_EMBEDDING_LOCATIONS = ['us', 'eu', 'global'];
|
|
65
107
|
const vertexLocationSchema = Type.Union([
|
|
66
108
|
Type.Literal('us'),
|
|
@@ -144,6 +186,8 @@ const embeddingProviderSchema = Type.Union([
|
|
|
144
186
|
Type.Literal('cloudflare'),
|
|
145
187
|
Type.Literal('gemini'),
|
|
146
188
|
Type.Literal('vertex'),
|
|
189
|
+
Type.Literal('opencode'),
|
|
190
|
+
Type.Literal('opencode-go'),
|
|
147
191
|
]);
|
|
148
192
|
export const embeddingRouteSchema = Type.Object({
|
|
149
193
|
provider: embeddingProviderSchema,
|
|
@@ -154,6 +198,13 @@ const spaceCommon = {
|
|
|
154
198
|
prefix: Type.Literal(EMBEDDING_DOCUMENT_PREFIX),
|
|
155
199
|
normalization: Type.Literal(EMBEDDING_NORMALIZATION_VERSION),
|
|
156
200
|
};
|
|
201
|
+
const openCodeSpaceCommon = {
|
|
202
|
+
...spaceCommon,
|
|
203
|
+
revision: Type.Null(),
|
|
204
|
+
quantization: Type.Null(),
|
|
205
|
+
// Observed only after a successful response; preflight descriptors never invent a dimension.
|
|
206
|
+
dimensions: Type.Union([Type.Integer({ minimum: 1 }), Type.Null()]),
|
|
207
|
+
};
|
|
157
208
|
const geminiSpaceCommon = {
|
|
158
209
|
format: Type.Literal(EMBEDDING_FORMAT_VERSION),
|
|
159
210
|
prefix: Type.Union([
|
|
@@ -225,6 +276,18 @@ export const embeddingSpaceSchema = Type.Union([
|
|
|
225
276
|
dimensions: Type.Literal(768),
|
|
226
277
|
pooling: Type.Union([Type.Literal('mean'), Type.Literal('cls')]),
|
|
227
278
|
}, { additionalProperties: false }),
|
|
279
|
+
Type.Object({
|
|
280
|
+
...openCodeSpaceCommon,
|
|
281
|
+
provider: Type.Literal('opencode'),
|
|
282
|
+
model: openCodeModelSchema,
|
|
283
|
+
runtime: Type.Literal('opencode-console-embeddings-v1'),
|
|
284
|
+
}, { additionalProperties: false }),
|
|
285
|
+
Type.Object({
|
|
286
|
+
...openCodeSpaceCommon,
|
|
287
|
+
provider: Type.Literal('opencode-go'),
|
|
288
|
+
model: openCodeGoModelSchema,
|
|
289
|
+
runtime: Type.Literal('opencode-go-embeddings-v1'),
|
|
290
|
+
}, { additionalProperties: false }),
|
|
228
291
|
]);
|
|
229
292
|
export const embeddingSettingsSchema = Type.Object({
|
|
230
293
|
version: Type.Optional(Type.Literal(1)),
|
|
@@ -264,6 +327,8 @@ export const embeddingSettingsSchema = Type.Object({
|
|
|
264
327
|
dimensions: Type.Optional(geminiDimensionsSchema),
|
|
265
328
|
taskFormat: Type.Optional(geminiTaskFormatSchema),
|
|
266
329
|
}, { additionalProperties: false })),
|
|
330
|
+
opencode: Type.Optional(Type.Object({ apiKey: Type.Optional(Type.String({ minLength: 1 })) }, { additionalProperties: false })),
|
|
331
|
+
'opencode-go': Type.Optional(Type.Object({ apiKey: Type.Optional(Type.String({ minLength: 1 })) }, { additionalProperties: false })),
|
|
267
332
|
}, { additionalProperties: false })),
|
|
268
333
|
}, { additionalProperties: false });
|
|
269
334
|
export const embeddingRequestSchema = Type.Object({
|
package/dist/settings.js
CHANGED
|
@@ -4,7 +4,7 @@ import { join, resolve } from 'node:path';
|
|
|
4
4
|
import { loadPiSettings, resolveConfigDir } from '@amaster.ai/pi-shared/settings';
|
|
5
5
|
import { Value } from 'typebox/value';
|
|
6
6
|
import { EmbeddingsError } from './errors.js';
|
|
7
|
-
import { CLOUDFLARE_EMBEDDING_MODELS, EMBEDDINGS_SETTINGS_KEY, GATEWAY_EMBEDDING_MODELS, GEMINI_EMBEDDING_MODELS, OPENROUTER_EMBEDDING_MODELS, embeddingSettingsSchema, } from './schemas.js';
|
|
7
|
+
import { CLOUDFLARE_EMBEDDING_MODELS, EMBEDDINGS_SETTINGS_KEY, GATEWAY_EMBEDDING_MODELS, GEMINI_EMBEDDING_MODELS, OPENCODE_EMBEDDING_MODELS, OPENCODE_GO_EMBEDDING_MODELS, OPENROUTER_EMBEDDING_MODELS, embeddingSettingsSchema, } from './schemas.js';
|
|
8
8
|
const MODELS_BY_PROVIDER = {
|
|
9
9
|
local: ['embeddinggemma-2'],
|
|
10
10
|
openai: ['text-embedding-3-small'],
|
|
@@ -14,6 +14,8 @@ const MODELS_BY_PROVIDER = {
|
|
|
14
14
|
cloudflare: CLOUDFLARE_EMBEDDING_MODELS,
|
|
15
15
|
gemini: GEMINI_EMBEDDING_MODELS,
|
|
16
16
|
vertex: GEMINI_EMBEDDING_MODELS,
|
|
17
|
+
opencode: OPENCODE_EMBEDDING_MODELS,
|
|
18
|
+
'opencode-go': OPENCODE_GO_EMBEDDING_MODELS,
|
|
17
19
|
};
|
|
18
20
|
export const isEmbeddingSettings = (value) => Value.Check(embeddingSettingsSchema, value);
|
|
19
21
|
function configuration(message) {
|
package/dist/tool-contracts.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const embedCompareParameters: import("typebox").TObject<{
|
|
|
10
10
|
}>;
|
|
11
11
|
export declare const embedOutput: import("typebox").TObject<{
|
|
12
12
|
schemaVersion: import("typebox").TLiteral<2>;
|
|
13
|
-
provider: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>, import("typebox").TNull]>;
|
|
13
|
+
provider: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">, import("typebox").TLiteral<"opencode">, import("typebox").TLiteral<"opencode-go">]>, import("typebox").TNull]>;
|
|
14
14
|
model: import("typebox").TUnion<[import("typebox").TString, import("typebox").TNull]>;
|
|
15
15
|
space: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TObject<{
|
|
16
16
|
provider: import("typebox").TLiteral<"local">;
|
|
@@ -75,9 +75,29 @@ export declare const embedOutput: import("typebox").TObject<{
|
|
|
75
75
|
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
76
76
|
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
77
77
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
78
|
+
}>, import("typebox").TObject<{
|
|
79
|
+
provider: import("typebox").TLiteral<"opencode">;
|
|
80
|
+
model: import("typebox").TUnion<[import("typebox").TLiteral<"text-embedding-3-small">, import("typebox").TLiteral<"text-embedding-3-large">, import("typebox").TLiteral<"gemini-embedding-2">, import("typebox").TLiteral<"gemini-embedding-001">, import("typebox").TLiteral<"codestral-embed">, import("typebox").TLiteral<"mistral-embed">, import("typebox").TLiteral<"cohere-embed-v5-pro">, import("typebox").TLiteral<"cohere-embed-v5-fast">, import("typebox").TLiteral<"voyage-4">, import("typebox").TLiteral<"voyage-code-4">, import("typebox").TLiteral<"qwen3-embedding-8b">, import("typebox").TLiteral<"bge-m3">]>;
|
|
81
|
+
runtime: import("typebox").TLiteral<"opencode-console-embeddings-v1">;
|
|
82
|
+
revision: import("typebox").TNull;
|
|
83
|
+
quantization: import("typebox").TNull;
|
|
84
|
+
dimensions: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
|
|
85
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
86
|
+
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
87
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
88
|
+
}>, import("typebox").TObject<{
|
|
89
|
+
provider: import("typebox").TLiteral<"opencode-go">;
|
|
90
|
+
model: import("typebox").TUnion<[import("typebox").TLiteral<"text-embedding-3-small">, import("typebox").TLiteral<"qwen3-embedding-8b">, import("typebox").TLiteral<"gemini-embedding-2">]>;
|
|
91
|
+
runtime: import("typebox").TLiteral<"opencode-go-embeddings-v1">;
|
|
92
|
+
revision: import("typebox").TNull;
|
|
93
|
+
quantization: import("typebox").TNull;
|
|
94
|
+
dimensions: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
|
|
95
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
96
|
+
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
97
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
78
98
|
}>]>, import("typebox").TNull]>;
|
|
79
99
|
generations: import("typebox").TArray<import("typebox").TObject<{
|
|
80
|
-
provider: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
100
|
+
provider: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">, import("typebox").TLiteral<"opencode">, import("typebox").TLiteral<"opencode-go">]>;
|
|
81
101
|
model: import("typebox").TString;
|
|
82
102
|
space: import("typebox").TUnion<[import("typebox").TObject<{
|
|
83
103
|
provider: import("typebox").TLiteral<"local">;
|
|
@@ -142,13 +162,33 @@ export declare const embedOutput: import("typebox").TObject<{
|
|
|
142
162
|
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
143
163
|
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
144
164
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
165
|
+
}>, import("typebox").TObject<{
|
|
166
|
+
provider: import("typebox").TLiteral<"opencode">;
|
|
167
|
+
model: import("typebox").TUnion<[import("typebox").TLiteral<"text-embedding-3-small">, import("typebox").TLiteral<"text-embedding-3-large">, import("typebox").TLiteral<"gemini-embedding-2">, import("typebox").TLiteral<"gemini-embedding-001">, import("typebox").TLiteral<"codestral-embed">, import("typebox").TLiteral<"mistral-embed">, import("typebox").TLiteral<"cohere-embed-v5-pro">, import("typebox").TLiteral<"cohere-embed-v5-fast">, import("typebox").TLiteral<"voyage-4">, import("typebox").TLiteral<"voyage-code-4">, import("typebox").TLiteral<"qwen3-embedding-8b">, import("typebox").TLiteral<"bge-m3">]>;
|
|
168
|
+
runtime: import("typebox").TLiteral<"opencode-console-embeddings-v1">;
|
|
169
|
+
revision: import("typebox").TNull;
|
|
170
|
+
quantization: import("typebox").TNull;
|
|
171
|
+
dimensions: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
|
|
172
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
173
|
+
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
174
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
175
|
+
}>, import("typebox").TObject<{
|
|
176
|
+
provider: import("typebox").TLiteral<"opencode-go">;
|
|
177
|
+
model: import("typebox").TUnion<[import("typebox").TLiteral<"text-embedding-3-small">, import("typebox").TLiteral<"qwen3-embedding-8b">, import("typebox").TLiteral<"gemini-embedding-2">]>;
|
|
178
|
+
runtime: import("typebox").TLiteral<"opencode-go-embeddings-v1">;
|
|
179
|
+
revision: import("typebox").TNull;
|
|
180
|
+
quantization: import("typebox").TNull;
|
|
181
|
+
dimensions: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
|
|
182
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
183
|
+
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
184
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
145
185
|
}>]>;
|
|
146
186
|
}>>;
|
|
147
187
|
outcomes: import("typebox").TArray<import("typebox").TUnion<[import("typebox").TObject<{
|
|
148
188
|
status: import("typebox").TLiteral<"success">;
|
|
149
189
|
index: import("typebox").TInteger;
|
|
150
190
|
vector: import("typebox").TArray<import("typebox").TNumber>;
|
|
151
|
-
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
191
|
+
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">, import("typebox").TLiteral<"opencode">, import("typebox").TLiteral<"opencode-go">]>;
|
|
152
192
|
model: import("typebox").TString;
|
|
153
193
|
space: import("typebox").TUnion<[import("typebox").TObject<{
|
|
154
194
|
provider: import("typebox").TLiteral<"local">;
|
|
@@ -213,6 +253,26 @@ export declare const embedOutput: import("typebox").TObject<{
|
|
|
213
253
|
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
214
254
|
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
215
255
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
256
|
+
}>, import("typebox").TObject<{
|
|
257
|
+
provider: import("typebox").TLiteral<"opencode">;
|
|
258
|
+
model: import("typebox").TUnion<[import("typebox").TLiteral<"text-embedding-3-small">, import("typebox").TLiteral<"text-embedding-3-large">, import("typebox").TLiteral<"gemini-embedding-2">, import("typebox").TLiteral<"gemini-embedding-001">, import("typebox").TLiteral<"codestral-embed">, import("typebox").TLiteral<"mistral-embed">, import("typebox").TLiteral<"cohere-embed-v5-pro">, import("typebox").TLiteral<"cohere-embed-v5-fast">, import("typebox").TLiteral<"voyage-4">, import("typebox").TLiteral<"voyage-code-4">, import("typebox").TLiteral<"qwen3-embedding-8b">, import("typebox").TLiteral<"bge-m3">]>;
|
|
259
|
+
runtime: import("typebox").TLiteral<"opencode-console-embeddings-v1">;
|
|
260
|
+
revision: import("typebox").TNull;
|
|
261
|
+
quantization: import("typebox").TNull;
|
|
262
|
+
dimensions: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
|
|
263
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
264
|
+
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
265
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
266
|
+
}>, import("typebox").TObject<{
|
|
267
|
+
provider: import("typebox").TLiteral<"opencode-go">;
|
|
268
|
+
model: import("typebox").TUnion<[import("typebox").TLiteral<"text-embedding-3-small">, import("typebox").TLiteral<"qwen3-embedding-8b">, import("typebox").TLiteral<"gemini-embedding-2">]>;
|
|
269
|
+
runtime: import("typebox").TLiteral<"opencode-go-embeddings-v1">;
|
|
270
|
+
revision: import("typebox").TNull;
|
|
271
|
+
quantization: import("typebox").TNull;
|
|
272
|
+
dimensions: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
|
|
273
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
274
|
+
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
275
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
216
276
|
}>]>;
|
|
217
277
|
attemptId: import("typebox").TString;
|
|
218
278
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
@@ -224,7 +284,7 @@ export declare const embedOutput: import("typebox").TObject<{
|
|
|
224
284
|
}>]>>;
|
|
225
285
|
attempts: import("typebox").TArray<import("typebox").TObject<{
|
|
226
286
|
id: import("typebox").TString;
|
|
227
|
-
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
287
|
+
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">, import("typebox").TLiteral<"opencode">, import("typebox").TLiteral<"opencode-go">]>;
|
|
228
288
|
model: import("typebox").TString;
|
|
229
289
|
routeIndex: import("typebox").TInteger;
|
|
230
290
|
status: import("typebox").TUnion<[import("typebox").TLiteral<"success">, import("typebox").TLiteral<"error">, import("typebox").TLiteral<"cancelled">]>;
|
|
@@ -239,12 +299,12 @@ export declare const embedOutput: import("typebox").TObject<{
|
|
|
239
299
|
export declare const embedCompareOutput: import("typebox").TObject<{
|
|
240
300
|
schemaVersion: import("typebox").TLiteral<2>;
|
|
241
301
|
entries: import("typebox").TArray<import("typebox").TObject<{
|
|
242
|
-
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
302
|
+
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">, import("typebox").TLiteral<"opencode">, import("typebox").TLiteral<"opencode-go">]>;
|
|
243
303
|
model: import("typebox").TString;
|
|
244
304
|
status: import("typebox").TUnion<[import("typebox").TLiteral<"success">, import("typebox").TLiteral<"error">, import("typebox").TLiteral<"cancelled">]>;
|
|
245
305
|
result: import("typebox").TObject<{
|
|
246
306
|
schemaVersion: import("typebox").TLiteral<2>;
|
|
247
|
-
provider: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>, import("typebox").TNull]>;
|
|
307
|
+
provider: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">, import("typebox").TLiteral<"opencode">, import("typebox").TLiteral<"opencode-go">]>, import("typebox").TNull]>;
|
|
248
308
|
model: import("typebox").TUnion<[import("typebox").TString, import("typebox").TNull]>;
|
|
249
309
|
space: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TObject<{
|
|
250
310
|
provider: import("typebox").TLiteral<"local">;
|
|
@@ -309,9 +369,29 @@ export declare const embedCompareOutput: import("typebox").TObject<{
|
|
|
309
369
|
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
310
370
|
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
311
371
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
372
|
+
}>, import("typebox").TObject<{
|
|
373
|
+
provider: import("typebox").TLiteral<"opencode">;
|
|
374
|
+
model: import("typebox").TUnion<[import("typebox").TLiteral<"text-embedding-3-small">, import("typebox").TLiteral<"text-embedding-3-large">, import("typebox").TLiteral<"gemini-embedding-2">, import("typebox").TLiteral<"gemini-embedding-001">, import("typebox").TLiteral<"codestral-embed">, import("typebox").TLiteral<"mistral-embed">, import("typebox").TLiteral<"cohere-embed-v5-pro">, import("typebox").TLiteral<"cohere-embed-v5-fast">, import("typebox").TLiteral<"voyage-4">, import("typebox").TLiteral<"voyage-code-4">, import("typebox").TLiteral<"qwen3-embedding-8b">, import("typebox").TLiteral<"bge-m3">]>;
|
|
375
|
+
runtime: import("typebox").TLiteral<"opencode-console-embeddings-v1">;
|
|
376
|
+
revision: import("typebox").TNull;
|
|
377
|
+
quantization: import("typebox").TNull;
|
|
378
|
+
dimensions: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
|
|
379
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
380
|
+
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
381
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
382
|
+
}>, import("typebox").TObject<{
|
|
383
|
+
provider: import("typebox").TLiteral<"opencode-go">;
|
|
384
|
+
model: import("typebox").TUnion<[import("typebox").TLiteral<"text-embedding-3-small">, import("typebox").TLiteral<"qwen3-embedding-8b">, import("typebox").TLiteral<"gemini-embedding-2">]>;
|
|
385
|
+
runtime: import("typebox").TLiteral<"opencode-go-embeddings-v1">;
|
|
386
|
+
revision: import("typebox").TNull;
|
|
387
|
+
quantization: import("typebox").TNull;
|
|
388
|
+
dimensions: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
|
|
389
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
390
|
+
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
391
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
312
392
|
}>]>, import("typebox").TNull]>;
|
|
313
393
|
generations: import("typebox").TArray<import("typebox").TObject<{
|
|
314
|
-
provider: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
394
|
+
provider: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">, import("typebox").TLiteral<"opencode">, import("typebox").TLiteral<"opencode-go">]>;
|
|
315
395
|
model: import("typebox").TString;
|
|
316
396
|
space: import("typebox").TUnion<[import("typebox").TObject<{
|
|
317
397
|
provider: import("typebox").TLiteral<"local">;
|
|
@@ -376,13 +456,33 @@ export declare const embedCompareOutput: import("typebox").TObject<{
|
|
|
376
456
|
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
377
457
|
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
378
458
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
459
|
+
}>, import("typebox").TObject<{
|
|
460
|
+
provider: import("typebox").TLiteral<"opencode">;
|
|
461
|
+
model: import("typebox").TUnion<[import("typebox").TLiteral<"text-embedding-3-small">, import("typebox").TLiteral<"text-embedding-3-large">, import("typebox").TLiteral<"gemini-embedding-2">, import("typebox").TLiteral<"gemini-embedding-001">, import("typebox").TLiteral<"codestral-embed">, import("typebox").TLiteral<"mistral-embed">, import("typebox").TLiteral<"cohere-embed-v5-pro">, import("typebox").TLiteral<"cohere-embed-v5-fast">, import("typebox").TLiteral<"voyage-4">, import("typebox").TLiteral<"voyage-code-4">, import("typebox").TLiteral<"qwen3-embedding-8b">, import("typebox").TLiteral<"bge-m3">]>;
|
|
462
|
+
runtime: import("typebox").TLiteral<"opencode-console-embeddings-v1">;
|
|
463
|
+
revision: import("typebox").TNull;
|
|
464
|
+
quantization: import("typebox").TNull;
|
|
465
|
+
dimensions: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
|
|
466
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
467
|
+
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
468
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
469
|
+
}>, import("typebox").TObject<{
|
|
470
|
+
provider: import("typebox").TLiteral<"opencode-go">;
|
|
471
|
+
model: import("typebox").TUnion<[import("typebox").TLiteral<"text-embedding-3-small">, import("typebox").TLiteral<"qwen3-embedding-8b">, import("typebox").TLiteral<"gemini-embedding-2">]>;
|
|
472
|
+
runtime: import("typebox").TLiteral<"opencode-go-embeddings-v1">;
|
|
473
|
+
revision: import("typebox").TNull;
|
|
474
|
+
quantization: import("typebox").TNull;
|
|
475
|
+
dimensions: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
|
|
476
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
477
|
+
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
478
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
379
479
|
}>]>;
|
|
380
480
|
}>>;
|
|
381
481
|
outcomes: import("typebox").TArray<import("typebox").TUnion<[import("typebox").TObject<{
|
|
382
482
|
status: import("typebox").TLiteral<"success">;
|
|
383
483
|
index: import("typebox").TInteger;
|
|
384
484
|
vector: import("typebox").TArray<import("typebox").TNumber>;
|
|
385
|
-
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
485
|
+
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">, import("typebox").TLiteral<"opencode">, import("typebox").TLiteral<"opencode-go">]>;
|
|
386
486
|
model: import("typebox").TString;
|
|
387
487
|
space: import("typebox").TUnion<[import("typebox").TObject<{
|
|
388
488
|
provider: import("typebox").TLiteral<"local">;
|
|
@@ -447,6 +547,26 @@ export declare const embedCompareOutput: import("typebox").TObject<{
|
|
|
447
547
|
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
448
548
|
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
449
549
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
550
|
+
}>, import("typebox").TObject<{
|
|
551
|
+
provider: import("typebox").TLiteral<"opencode">;
|
|
552
|
+
model: import("typebox").TUnion<[import("typebox").TLiteral<"text-embedding-3-small">, import("typebox").TLiteral<"text-embedding-3-large">, import("typebox").TLiteral<"gemini-embedding-2">, import("typebox").TLiteral<"gemini-embedding-001">, import("typebox").TLiteral<"codestral-embed">, import("typebox").TLiteral<"mistral-embed">, import("typebox").TLiteral<"cohere-embed-v5-pro">, import("typebox").TLiteral<"cohere-embed-v5-fast">, import("typebox").TLiteral<"voyage-4">, import("typebox").TLiteral<"voyage-code-4">, import("typebox").TLiteral<"qwen3-embedding-8b">, import("typebox").TLiteral<"bge-m3">]>;
|
|
553
|
+
runtime: import("typebox").TLiteral<"opencode-console-embeddings-v1">;
|
|
554
|
+
revision: import("typebox").TNull;
|
|
555
|
+
quantization: import("typebox").TNull;
|
|
556
|
+
dimensions: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
|
|
557
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
558
|
+
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
559
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
560
|
+
}>, import("typebox").TObject<{
|
|
561
|
+
provider: import("typebox").TLiteral<"opencode-go">;
|
|
562
|
+
model: import("typebox").TUnion<[import("typebox").TLiteral<"text-embedding-3-small">, import("typebox").TLiteral<"qwen3-embedding-8b">, import("typebox").TLiteral<"gemini-embedding-2">]>;
|
|
563
|
+
runtime: import("typebox").TLiteral<"opencode-go-embeddings-v1">;
|
|
564
|
+
revision: import("typebox").TNull;
|
|
565
|
+
quantization: import("typebox").TNull;
|
|
566
|
+
dimensions: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
|
|
567
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
568
|
+
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
569
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
450
570
|
}>]>;
|
|
451
571
|
attemptId: import("typebox").TString;
|
|
452
572
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
@@ -458,7 +578,7 @@ export declare const embedCompareOutput: import("typebox").TObject<{
|
|
|
458
578
|
}>]>>;
|
|
459
579
|
attempts: import("typebox").TArray<import("typebox").TObject<{
|
|
460
580
|
id: import("typebox").TString;
|
|
461
|
-
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
581
|
+
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">, import("typebox").TLiteral<"opencode">, import("typebox").TLiteral<"opencode-go">]>;
|
|
462
582
|
model: import("typebox").TString;
|
|
463
583
|
routeIndex: import("typebox").TInteger;
|
|
464
584
|
status: import("typebox").TUnion<[import("typebox").TLiteral<"success">, import("typebox").TLiteral<"error">, import("typebox").TLiteral<"cancelled">]>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abhishek944/pi-embeddings",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Config-driven text embeddings for Pi and MCP with local, OpenAI, Sarvam, Gemini, Vertex ADC and gateway routes, ordered fallback and explicit comparisons.",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Config-driven text embeddings for Pi and MCP with local, OpenAI, Sarvam, Gemini, Vertex ADC, OpenCode and gateway routes, ordered fallback and explicit comparisons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
7
7
|
"pi",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"sarvam",
|
|
12
12
|
"gemini",
|
|
13
13
|
"embeddinggemma",
|
|
14
|
+
"opencode",
|
|
14
15
|
"litellm"
|
|
15
16
|
],
|
|
16
17
|
"license": "Apache-2.0",
|
package/src/execute.ts
CHANGED
|
@@ -195,6 +195,7 @@ export async function executeEmbeddings(args: ExecuteArgs): Promise<EmbeddingRes
|
|
|
195
195
|
attempt.usage = result.usage;
|
|
196
196
|
if (result.vectors.length !== captured.length)
|
|
197
197
|
throw new EmbeddingsError('provider-response-mismatch');
|
|
198
|
+
const actualSpace = result.space ?? provider.space;
|
|
198
199
|
for (const [offset, entry] of captured.entries()) {
|
|
199
200
|
const vector = result.vectors[offset];
|
|
200
201
|
if (vector === undefined) throw new EmbeddingsError('provider-response-mismatch');
|
|
@@ -204,7 +205,7 @@ export async function executeEmbeddings(args: ExecuteArgs): Promise<EmbeddingRes
|
|
|
204
205
|
vector: [...vector],
|
|
205
206
|
route: route.provider,
|
|
206
207
|
model: provider.model,
|
|
207
|
-
space:
|
|
208
|
+
space: actualSpace,
|
|
208
209
|
attemptId,
|
|
209
210
|
normalization: EMBEDDING_NORMALIZATION_VERSION,
|
|
210
211
|
};
|
package/src/extension.ts
CHANGED
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
type ExtensionContext,
|
|
6
6
|
} from '@earendil-works/pi-coding-agent';
|
|
7
7
|
import { EmbeddingsError } from './errors.js';
|
|
8
|
+
import type { EmbeddingCredentialResolver } from './provider-types.js';
|
|
9
|
+
import type { OpenCodeCredentialAvailability } from './providers.js';
|
|
8
10
|
import {
|
|
9
11
|
createEmbeddingsRuntimeWithDiagnostics,
|
|
10
12
|
type EmbeddingsRuntimeWithDiagnostics,
|
|
@@ -41,16 +43,44 @@ const codeOf = (error: unknown): string =>
|
|
|
41
43
|
const signalOptions = (signal: AbortSignal | undefined) =>
|
|
42
44
|
signal === undefined ? {} : { signal };
|
|
43
45
|
|
|
46
|
+
type PiCredentials = Readonly<{
|
|
47
|
+
readonly resolver: EmbeddingCredentialResolver;
|
|
48
|
+
readonly available: OpenCodeCredentialAvailability;
|
|
49
|
+
}>;
|
|
50
|
+
|
|
51
|
+
/** Pi exposes provider keys through ModelRegistry; only nonsecret availability is retained. */
|
|
52
|
+
async function piCredentials(ctx: ExtensionContext): Promise<PiCredentials> {
|
|
53
|
+
const opencode = (await ctx.modelRegistry.getApiKeyForProvider('opencode')) !== undefined;
|
|
54
|
+
const go = (await ctx.modelRegistry.getApiKeyForProvider('opencode-go')) !== undefined;
|
|
55
|
+
return {
|
|
56
|
+
available: { opencode, 'opencode-go': go },
|
|
57
|
+
resolver: async (provider) => {
|
|
58
|
+
if (provider === 'opencode' || provider === 'opencode-go')
|
|
59
|
+
return ctx.modelRegistry.getApiKeyForProvider(provider);
|
|
60
|
+
return undefined;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
44
65
|
export default function piEmbeddingsExtension(pi: ExtensionAPI): void {
|
|
45
66
|
let settings: EmbeddingSettings | undefined;
|
|
46
67
|
let runtime: EmbeddingsRuntimeWithDiagnostics | undefined;
|
|
47
68
|
let cwd = process.cwd();
|
|
48
69
|
|
|
49
|
-
const refresh = async (
|
|
70
|
+
const refresh = async (
|
|
71
|
+
next: EmbeddingSettings,
|
|
72
|
+
nextCwd: string,
|
|
73
|
+
credentials: PiCredentials
|
|
74
|
+
): Promise<void> => {
|
|
50
75
|
await runtime?.close();
|
|
51
76
|
settings = next;
|
|
52
77
|
cwd = nextCwd;
|
|
53
|
-
runtime = createEmbeddingsRuntimeWithDiagnostics({
|
|
78
|
+
runtime = createEmbeddingsRuntimeWithDiagnostics({
|
|
79
|
+
settings: next,
|
|
80
|
+
cwd: nextCwd,
|
|
81
|
+
credentialResolver: credentials.resolver,
|
|
82
|
+
piCredentialAvailable: credentials.available,
|
|
83
|
+
});
|
|
54
84
|
};
|
|
55
85
|
|
|
56
86
|
const currentRuntime = (ctx: ExtensionContext): EmbeddingsRuntimeWithDiagnostics => {
|
|
@@ -60,7 +90,11 @@ export default function piEmbeddingsExtension(pi: ExtensionAPI): void {
|
|
|
60
90
|
};
|
|
61
91
|
|
|
62
92
|
pi.on('session_start', async (_event: unknown, ctx: ExtensionContext) => {
|
|
63
|
-
await refresh(
|
|
93
|
+
await refresh(
|
|
94
|
+
loadEmbeddingSettings(ctx.cwd, isProjectTrusted(ctx)),
|
|
95
|
+
ctx.cwd,
|
|
96
|
+
await piCredentials(ctx)
|
|
97
|
+
);
|
|
64
98
|
});
|
|
65
99
|
|
|
66
100
|
pi.on('session_shutdown', async () => {
|
|
@@ -172,7 +206,7 @@ export default function piEmbeddingsExtension(pi: ExtensionAPI): void {
|
|
|
172
206
|
if (command === 'reload') {
|
|
173
207
|
if (parts.length !== 1) throw new EmbeddingsError('configuration-invalid');
|
|
174
208
|
const next = loadEmbeddingSettings(ctx.cwd, isProjectTrusted(ctx));
|
|
175
|
-
await refresh(next, ctx.cwd);
|
|
209
|
+
await refresh(next, ctx.cwd, await piCredentials(ctx));
|
|
176
210
|
reply(pi, ctx, `${EMBEDDINGS_SETTINGS_KEY} settings reloaded. No inference was run.`);
|
|
177
211
|
return;
|
|
178
212
|
}
|
|
@@ -185,7 +219,11 @@ export default function piEmbeddingsExtension(pi: ExtensionAPI): void {
|
|
|
185
219
|
projectTrusted: isProjectTrusted(ctx),
|
|
186
220
|
route,
|
|
187
221
|
});
|
|
188
|
-
await refresh(
|
|
222
|
+
await refresh(
|
|
223
|
+
loadEmbeddingSettings(ctx.cwd, isProjectTrusted(ctx)),
|
|
224
|
+
ctx.cwd,
|
|
225
|
+
await piCredentials(ctx)
|
|
226
|
+
);
|
|
189
227
|
reply(pi, ctx, `Selected ${route.provider}/${route.model} in trusted project settings.`);
|
|
190
228
|
return;
|
|
191
229
|
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export {
|
|
|
7
7
|
isEmbeddingSettings,
|
|
8
8
|
} from './settings.js';
|
|
9
9
|
export { EmbeddingsError } from './errors.js';
|
|
10
|
+
export type { EmbeddingCredentialResolver } from './provider-types.js';
|
|
10
11
|
export {
|
|
11
12
|
EMBEDDINGS_SETTINGS_KEY,
|
|
12
13
|
EMBEDDINGS_PROTOCOL_VERSION,
|
|
@@ -18,6 +19,8 @@ export {
|
|
|
18
19
|
GATEWAY_EMBEDDING_MODELS,
|
|
19
20
|
GEMINI_EMBEDDING_MODELS,
|
|
20
21
|
VERTEX_EMBEDDING_LOCATIONS,
|
|
22
|
+
OPENCODE_EMBEDDING_MODELS,
|
|
23
|
+
OPENCODE_GO_EMBEDDING_MODELS,
|
|
21
24
|
GEMINI_EMBEDDING_MIN_DIMENSIONS,
|
|
22
25
|
GEMINI_EMBEDDING_MAX_DIMENSIONS,
|
|
23
26
|
GEMINI_EMBEDDING_TASK_FORMATS,
|
|
@@ -43,4 +46,7 @@ export type {
|
|
|
43
46
|
EmbeddingErrorCode,
|
|
44
47
|
GeminiEmbeddingDimension,
|
|
45
48
|
GeminiEmbeddingTaskFormat,
|
|
49
|
+
OpenCodeRouteId,
|
|
50
|
+
OpenCodeEmbeddingModel,
|
|
51
|
+
OpenCodeGoEmbeddingModel,
|
|
46
52
|
} from './schemas.js';
|
package/src/provider-types.ts
CHANGED
|
@@ -14,8 +14,15 @@ export type ProviderUsage = Readonly<{
|
|
|
14
14
|
export type ProviderBatchResult = Readonly<{
|
|
15
15
|
readonly vectors: readonly (readonly number[])[];
|
|
16
16
|
readonly usage: ProviderUsage;
|
|
17
|
+
/** Set only when the response establishes a more specific space than the preflight descriptor. */
|
|
18
|
+
readonly space?: EmbeddingSpace | undefined;
|
|
17
19
|
}>;
|
|
18
20
|
|
|
21
|
+
/** Supplied by hosts with a supported provider-key lookup; never invoked with a secret value. */
|
|
22
|
+
export type EmbeddingCredentialResolver = (
|
|
23
|
+
provider: EmbeddingRouteId
|
|
24
|
+
) => Promise<string | undefined>;
|
|
25
|
+
|
|
19
26
|
export interface EmbeddingsProvider {
|
|
20
27
|
readonly route: EmbeddingRouteId;
|
|
21
28
|
readonly model: string;
|