@abhishek944/pi-embeddings 0.0.0-stage → 0.1.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.
Files changed (51) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +87 -2
  3. package/dist/errors.d.ts +21 -0
  4. package/dist/errors.js +41 -0
  5. package/dist/execute.d.ts +25 -0
  6. package/dist/execute.js +229 -0
  7. package/dist/extension.d.ts +2 -0
  8. package/dist/extension.js +195 -0
  9. package/dist/index.d.ts +5 -0
  10. package/dist/index.js +4 -0
  11. package/dist/local-runtime.d.ts +14 -0
  12. package/dist/local-runtime.js +246 -0
  13. package/dist/mcp-cli.d.ts +2 -0
  14. package/dist/mcp-cli.js +46 -0
  15. package/dist/mcp-server.d.ts +23 -0
  16. package/dist/mcp-server.js +154 -0
  17. package/dist/provider-http.d.ts +11 -0
  18. package/dist/provider-http.js +60 -0
  19. package/dist/provider-types.d.ts +30 -0
  20. package/dist/provider-types.js +1 -0
  21. package/dist/providers.d.ts +18 -0
  22. package/dist/providers.js +265 -0
  23. package/dist/response.d.ts +11 -0
  24. package/dist/response.js +62 -0
  25. package/dist/runtime.d.ts +19 -0
  26. package/dist/runtime.js +121 -0
  27. package/dist/schemas.d.ts +431 -0
  28. package/dist/schemas.js +214 -0
  29. package/dist/settings-write.d.ts +9 -0
  30. package/dist/settings-write.js +77 -0
  31. package/dist/settings.d.ts +8 -0
  32. package/dist/settings.js +97 -0
  33. package/dist/tool-contracts.d.ts +200 -0
  34. package/dist/tool-contracts.js +19 -0
  35. package/package.json +83 -4
  36. package/src/errors.ts +52 -0
  37. package/src/execute.ts +261 -0
  38. package/src/extension.ts +245 -0
  39. package/src/index.ts +37 -0
  40. package/src/local-runtime.ts +273 -0
  41. package/src/mcp-cli.ts +52 -0
  42. package/src/mcp-server.ts +206 -0
  43. package/src/provider-http.ts +67 -0
  44. package/src/provider-types.ts +33 -0
  45. package/src/providers.ts +335 -0
  46. package/src/response.ts +74 -0
  47. package/src/runtime.ts +146 -0
  48. package/src/schemas.ts +326 -0
  49. package/src/settings-write.ts +96 -0
  50. package/src/settings.ts +115 -0
  51. package/src/tool-contracts.ts +34 -0
@@ -0,0 +1,121 @@
1
+ import { acquireProvider, routeDiagnostics, routeKey, spaceForRoute } from './providers.js';
2
+ import { configuredDefault, configuredRoutes, validateEmbeddingSettings } from './settings.js';
3
+ import { executeCompare, executeEmbeddings } from './execute.js';
4
+ import { EmbeddingsError } from './errors.js';
5
+ import { EMBEDDINGS_PROTOCOL_VERSION, } from './schemas.js';
6
+ const noSignal = (signal) => signal ?? new AbortController().signal;
7
+ export function createEmbeddingsRuntime(args) {
8
+ const settings = validateEmbeddingSettings(args.settings);
9
+ const defaultRoute = configuredDefault(settings);
10
+ const fallbackRoutes = configuredRoutes(settings, 'fallback');
11
+ const compareRoutes = configuredRoutes(settings, 'compare');
12
+ const acquired = new Map();
13
+ const pending = new Map();
14
+ const lateReleases = [];
15
+ const lifetime = new AbortController();
16
+ let closed = false;
17
+ let closing;
18
+ /**
19
+ * Acquisitions belong to the runtime, not to one call. A caller's cancellation only stops waiting;
20
+ * it never releases a shared local child that another call may be using.
21
+ */
22
+ const acquireShared = (route) => {
23
+ const key = routeKey(route);
24
+ const cached = acquired.get(key);
25
+ if (cached !== undefined)
26
+ return Promise.resolve(cached);
27
+ const inFlight = pending.get(key);
28
+ if (inFlight !== undefined)
29
+ return inFlight;
30
+ const promise = acquireProvider({ settings, route, signal: lifetime.signal })
31
+ .then((entry) => {
32
+ pending.delete(key);
33
+ if (closed || closing !== undefined) {
34
+ lateReleases.push(entry.release());
35
+ throw new Error('The embeddings runtime is closed.');
36
+ }
37
+ acquired.set(key, entry);
38
+ return entry;
39
+ })
40
+ .catch((error) => {
41
+ pending.delete(key);
42
+ throw error;
43
+ });
44
+ pending.set(key, promise);
45
+ return promise;
46
+ };
47
+ const acquire = (route, signal) => {
48
+ if (closed || closing !== undefined)
49
+ return Promise.reject(new Error('The embeddings runtime is closed.'));
50
+ if (signal.aborted)
51
+ return Promise.reject(new EmbeddingsError('cancelled'));
52
+ let listener;
53
+ const cancelled = new Promise((_resolve, reject) => {
54
+ listener = () => reject(new EmbeddingsError('cancelled'));
55
+ signal.addEventListener('abort', listener, { once: true });
56
+ });
57
+ return Promise.race([acquireShared(route), cancelled]).finally(() => {
58
+ if (listener !== undefined)
59
+ signal.removeEventListener('abort', listener);
60
+ });
61
+ };
62
+ return {
63
+ async start() {
64
+ if (defaultRoute.provider === 'local')
65
+ await acquire(defaultRoute, lifetime.signal);
66
+ },
67
+ async embed(request, options) {
68
+ return executeEmbeddings({
69
+ routes: [defaultRoute, ...fallbackRoutes],
70
+ request,
71
+ context: options?.context,
72
+ signal: noSignal(options?.signal),
73
+ allowFallback: true,
74
+ acquire,
75
+ });
76
+ },
77
+ async compare(request, options) {
78
+ return executeCompare({
79
+ routes: compareRoutes,
80
+ request,
81
+ context: options?.context,
82
+ signal: noSignal(options?.signal),
83
+ acquire,
84
+ });
85
+ },
86
+ describe() {
87
+ const defaultDiagnostics = routeDiagnostics(settings, defaultRoute);
88
+ const diagnostics = [...defaultDiagnostics];
89
+ for (const route of fallbackRoutes)
90
+ diagnostics.push(...routeDiagnostics(settings, route).map((entry) => ({
91
+ ...entry,
92
+ severity: 'warning',
93
+ })));
94
+ return {
95
+ schemaVersion: EMBEDDINGS_PROTOCOL_VERSION,
96
+ ready: defaultDiagnostics.length === 0,
97
+ selected: defaultRoute,
98
+ space: spaceForRoute(defaultRoute),
99
+ default: defaultRoute,
100
+ fallback: [...fallbackRoutes],
101
+ compare: [...compareRoutes],
102
+ diagnostics,
103
+ };
104
+ },
105
+ close() {
106
+ closing ??= (async () => {
107
+ closed = true;
108
+ lifetime.abort();
109
+ const inFlight = [...pending.values()];
110
+ const entries = [...acquired.values()];
111
+ acquired.clear();
112
+ await Promise.allSettled(inFlight);
113
+ await Promise.allSettled(lateReleases);
114
+ for (const entry of entries)
115
+ await entry.release();
116
+ pending.clear();
117
+ })();
118
+ return closing;
119
+ },
120
+ };
121
+ }
@@ -0,0 +1,431 @@
1
+ /**
2
+ * Authoritative public schemas for pi-embeddings.
3
+ *
4
+ * Types across the library, Pi extension and MCP server derive from this file. The descriptor shape
5
+ * deliberately matches the stored HighSKU vector space document, so legacy vectors remain compatible
6
+ * without rewriting stored bytes or inventing unknown provenance.
7
+ */
8
+ import { Type, type Static } from 'typebox';
9
+ export declare const EMBEDDINGS_SETTINGS_KEY = "pi-embeddings";
10
+ export declare const EMBEDDINGS_PROTOCOL_VERSION = 1;
11
+ export declare const EMBEDDING_FORMAT_VERSION = "host-display-attributes-v1";
12
+ export declare const EMBEDDING_DOCUMENT_PREFIX = "title: none | text: ";
13
+ export declare const EMBEDDING_NORMALIZATION_VERSION = "finite-nonzero-l2-v1";
14
+ export declare const EMBEDDING_CONTEXT_META_KEY = "pi-embeddings/context";
15
+ export declare const EMBEDDING_ROUTE_IDS: readonly ["local", "openai", "sarvam", "gateway"];
16
+ export type EmbeddingRouteId = (typeof EMBEDDING_ROUTE_IDS)[number];
17
+ export declare const GATEWAY_EMBEDDING_MODELS: readonly ["text-embedding-3-small", "openai/text-embedding-3-small"];
18
+ export declare const EMBEDDING_ERROR_CODES: readonly ["configuration-invalid", "route-unconfigured", "missing-credentials", "http-auth", "http-not-found", "http-rate-limit", "http-forbidden", "http-bad-request", "http-server-error", "transport-failed", "provider-response-invalid", "provider-response-mismatch", "vector-invalid", "vector-zero", "input-empty", "input-too-long", "tokenizer-roundtrip-failed", "attribution-unavailable", "local-resources-unavailable", "local-model-mismatch", "local-runtime-mismatch", "local-startup-failed", "local-cpu-startup-invalid", "cancelled", "unstarted"];
19
+ export type EmbeddingErrorCode = (typeof EMBEDDING_ERROR_CODES)[number];
20
+ export declare const embeddingRouteSchema: Type.TObject<{
21
+ provider: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
22
+ model: Type.TString;
23
+ }>;
24
+ /**
25
+ * Complete generating-space identity. `provider` is canonical: the gateway route deliberately
26
+ * reports the OpenAI recipe it declares, not its transport alias.
27
+ */
28
+ export declare const embeddingSpaceSchema: Type.TUnion<[Type.TObject<{
29
+ provider: Type.TLiteral<"local">;
30
+ model: Type.TLiteral<"embeddinggemma-2">;
31
+ revision: Type.TString;
32
+ quantization: Type.TLiteral<"Q8_0">;
33
+ runtime: Type.TString;
34
+ dimensions: Type.TLiteral<768>;
35
+ format: Type.TLiteral<"host-display-attributes-v1">;
36
+ prefix: Type.TLiteral<"title: none | text: ">;
37
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
38
+ }>, Type.TObject<{
39
+ provider: Type.TLiteral<"openai">;
40
+ model: Type.TLiteral<"text-embedding-3-small">;
41
+ revision: Type.TNull;
42
+ quantization: Type.TNull;
43
+ runtime: Type.TNull;
44
+ dimensions: Type.TLiteral<1536>;
45
+ format: Type.TLiteral<"host-display-attributes-v1">;
46
+ prefix: Type.TLiteral<"title: none | text: ">;
47
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
48
+ }>, Type.TObject<{
49
+ provider: Type.TLiteral<"sarvam">;
50
+ model: Type.TLiteral<"embeddinggemma-2">;
51
+ revision: Type.TNull;
52
+ quantization: Type.TNull;
53
+ runtime: Type.TLiteral<"sarvam-v2">;
54
+ dimensions: Type.TLiteral<768>;
55
+ format: Type.TLiteral<"host-display-attributes-v1">;
56
+ prefix: Type.TLiteral<"title: none | text: ">;
57
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
58
+ }>]>;
59
+ export declare const embeddingSettingsSchema: Type.TObject<{
60
+ version: Type.TOptional<Type.TLiteral<1>>;
61
+ default: Type.TObject<{
62
+ provider: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
63
+ model: Type.TString;
64
+ }>;
65
+ fallback: Type.TOptional<Type.TArray<Type.TObject<{
66
+ provider: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
67
+ model: Type.TString;
68
+ }>>>;
69
+ compare: Type.TOptional<Type.TArray<Type.TObject<{
70
+ provider: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
71
+ model: Type.TString;
72
+ }>>>;
73
+ providers: Type.TOptional<Type.TObject<{
74
+ local: Type.TOptional<Type.TObject<{
75
+ executable: Type.TString;
76
+ modelPath: Type.TString;
77
+ port: Type.TOptional<Type.TInteger>;
78
+ }>>;
79
+ openai: Type.TOptional<Type.TObject<{
80
+ apiKey: Type.TOptional<Type.TString>;
81
+ }>>;
82
+ sarvam: Type.TOptional<Type.TObject<{
83
+ apiKey: Type.TOptional<Type.TString>;
84
+ }>>;
85
+ gateway: Type.TOptional<Type.TObject<{
86
+ baseUrl: Type.TString;
87
+ apiKey: Type.TString;
88
+ model: Type.TUnion<[Type.TLiteral<"text-embedding-3-small">, Type.TLiteral<"openai/text-embedding-3-small">]>;
89
+ stage: Type.TUnion<[Type.TLiteral<"dev">, Type.TLiteral<"prod">]>;
90
+ }>>;
91
+ }>>;
92
+ }>;
93
+ export declare const embeddingRequestSchema: Type.TObject<{
94
+ inputs: Type.TArray<Type.TString>;
95
+ }>;
96
+ /** Generic, host-owned attribution. It is never a model argument or proof of ownership. */
97
+ export declare const embeddingContextSchema: Type.TObject<{
98
+ endUser: Type.TString;
99
+ tags: Type.TArray<Type.TString>;
100
+ }>;
101
+ export declare const embeddingUsageSchema: Type.TObject<{
102
+ providerReportedInputTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
103
+ preparedInputTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
104
+ billedTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
105
+ }>;
106
+ export declare const embeddingAttemptSchema: Type.TObject<{
107
+ id: Type.TString;
108
+ route: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
109
+ model: Type.TString;
110
+ routeIndex: Type.TInteger;
111
+ status: Type.TUnion<[Type.TLiteral<"success">, Type.TLiteral<"error">, Type.TLiteral<"cancelled">]>;
112
+ usage: Type.TUnion<[Type.TObject<{
113
+ providerReportedInputTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
114
+ preparedInputTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
115
+ billedTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
116
+ }>, Type.TNull]>;
117
+ errorCode: Type.TOptional<Type.TUnion<[Type.TLiteral<"configuration-invalid">, Type.TLiteral<"route-unconfigured">, Type.TLiteral<"missing-credentials">, Type.TLiteral<"http-auth">, Type.TLiteral<"http-not-found">, Type.TLiteral<"http-rate-limit">, Type.TLiteral<"http-forbidden">, Type.TLiteral<"http-bad-request">, Type.TLiteral<"http-server-error">, Type.TLiteral<"transport-failed">, Type.TLiteral<"provider-response-invalid">, Type.TLiteral<"provider-response-mismatch">, Type.TLiteral<"vector-invalid">, Type.TLiteral<"vector-zero">, Type.TLiteral<"input-empty">, Type.TLiteral<"input-too-long">, Type.TLiteral<"tokenizer-roundtrip-failed">, Type.TLiteral<"attribution-unavailable">, Type.TLiteral<"local-resources-unavailable">, Type.TLiteral<"local-model-mismatch">, Type.TLiteral<"local-runtime-mismatch">, Type.TLiteral<"local-startup-failed">, Type.TLiteral<"local-cpu-startup-invalid">, Type.TLiteral<"cancelled">, Type.TLiteral<"unstarted">]>>;
118
+ }>;
119
+ export declare const embeddingOutcomeSchema: Type.TUnion<[Type.TObject<{
120
+ status: Type.TLiteral<"success">;
121
+ index: Type.TInteger;
122
+ vector: Type.TArray<Type.TNumber>;
123
+ route: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
124
+ model: Type.TString;
125
+ space: Type.TUnion<[Type.TObject<{
126
+ provider: Type.TLiteral<"local">;
127
+ model: Type.TLiteral<"embeddinggemma-2">;
128
+ revision: Type.TString;
129
+ quantization: Type.TLiteral<"Q8_0">;
130
+ runtime: Type.TString;
131
+ dimensions: Type.TLiteral<768>;
132
+ format: Type.TLiteral<"host-display-attributes-v1">;
133
+ prefix: Type.TLiteral<"title: none | text: ">;
134
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
135
+ }>, Type.TObject<{
136
+ provider: Type.TLiteral<"openai">;
137
+ model: Type.TLiteral<"text-embedding-3-small">;
138
+ revision: Type.TNull;
139
+ quantization: Type.TNull;
140
+ runtime: Type.TNull;
141
+ dimensions: Type.TLiteral<1536>;
142
+ format: Type.TLiteral<"host-display-attributes-v1">;
143
+ prefix: Type.TLiteral<"title: none | text: ">;
144
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
145
+ }>, Type.TObject<{
146
+ provider: Type.TLiteral<"sarvam">;
147
+ model: Type.TLiteral<"embeddinggemma-2">;
148
+ revision: Type.TNull;
149
+ quantization: Type.TNull;
150
+ runtime: Type.TLiteral<"sarvam-v2">;
151
+ dimensions: Type.TLiteral<768>;
152
+ format: Type.TLiteral<"host-display-attributes-v1">;
153
+ prefix: Type.TLiteral<"title: none | text: ">;
154
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
155
+ }>]>;
156
+ attemptId: Type.TString;
157
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
158
+ }>, Type.TObject<{
159
+ status: Type.TLiteral<"error">;
160
+ index: Type.TInteger;
161
+ code: Type.TUnion<[Type.TLiteral<"configuration-invalid">, Type.TLiteral<"route-unconfigured">, Type.TLiteral<"missing-credentials">, Type.TLiteral<"http-auth">, Type.TLiteral<"http-not-found">, Type.TLiteral<"http-rate-limit">, Type.TLiteral<"http-forbidden">, Type.TLiteral<"http-bad-request">, Type.TLiteral<"http-server-error">, Type.TLiteral<"transport-failed">, Type.TLiteral<"provider-response-invalid">, Type.TLiteral<"provider-response-mismatch">, Type.TLiteral<"vector-invalid">, Type.TLiteral<"vector-zero">, Type.TLiteral<"input-empty">, Type.TLiteral<"input-too-long">, Type.TLiteral<"tokenizer-roundtrip-failed">, Type.TLiteral<"attribution-unavailable">, Type.TLiteral<"local-resources-unavailable">, Type.TLiteral<"local-model-mismatch">, Type.TLiteral<"local-runtime-mismatch">, Type.TLiteral<"local-startup-failed">, Type.TLiteral<"local-cpu-startup-invalid">, Type.TLiteral<"cancelled">, Type.TLiteral<"unstarted">]>;
162
+ attemptId: Type.TUnion<[Type.TString, Type.TNull]>;
163
+ }>]>;
164
+ export declare const embeddingResultSchema: Type.TObject<{
165
+ schemaVersion: Type.TLiteral<1>;
166
+ outcomes: Type.TArray<Type.TUnion<[Type.TObject<{
167
+ status: Type.TLiteral<"success">;
168
+ index: Type.TInteger;
169
+ vector: Type.TArray<Type.TNumber>;
170
+ route: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
171
+ model: Type.TString;
172
+ space: Type.TUnion<[Type.TObject<{
173
+ provider: Type.TLiteral<"local">;
174
+ model: Type.TLiteral<"embeddinggemma-2">;
175
+ revision: Type.TString;
176
+ quantization: Type.TLiteral<"Q8_0">;
177
+ runtime: Type.TString;
178
+ dimensions: Type.TLiteral<768>;
179
+ format: Type.TLiteral<"host-display-attributes-v1">;
180
+ prefix: Type.TLiteral<"title: none | text: ">;
181
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
182
+ }>, Type.TObject<{
183
+ provider: Type.TLiteral<"openai">;
184
+ model: Type.TLiteral<"text-embedding-3-small">;
185
+ revision: Type.TNull;
186
+ quantization: Type.TNull;
187
+ runtime: Type.TNull;
188
+ dimensions: Type.TLiteral<1536>;
189
+ format: Type.TLiteral<"host-display-attributes-v1">;
190
+ prefix: Type.TLiteral<"title: none | text: ">;
191
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
192
+ }>, Type.TObject<{
193
+ provider: Type.TLiteral<"sarvam">;
194
+ model: Type.TLiteral<"embeddinggemma-2">;
195
+ revision: Type.TNull;
196
+ quantization: Type.TNull;
197
+ runtime: Type.TLiteral<"sarvam-v2">;
198
+ dimensions: Type.TLiteral<768>;
199
+ format: Type.TLiteral<"host-display-attributes-v1">;
200
+ prefix: Type.TLiteral<"title: none | text: ">;
201
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
202
+ }>]>;
203
+ attemptId: Type.TString;
204
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
205
+ }>, Type.TObject<{
206
+ status: Type.TLiteral<"error">;
207
+ index: Type.TInteger;
208
+ code: Type.TUnion<[Type.TLiteral<"configuration-invalid">, Type.TLiteral<"route-unconfigured">, Type.TLiteral<"missing-credentials">, Type.TLiteral<"http-auth">, Type.TLiteral<"http-not-found">, Type.TLiteral<"http-rate-limit">, Type.TLiteral<"http-forbidden">, Type.TLiteral<"http-bad-request">, Type.TLiteral<"http-server-error">, Type.TLiteral<"transport-failed">, Type.TLiteral<"provider-response-invalid">, Type.TLiteral<"provider-response-mismatch">, Type.TLiteral<"vector-invalid">, Type.TLiteral<"vector-zero">, Type.TLiteral<"input-empty">, Type.TLiteral<"input-too-long">, Type.TLiteral<"tokenizer-roundtrip-failed">, Type.TLiteral<"attribution-unavailable">, Type.TLiteral<"local-resources-unavailable">, Type.TLiteral<"local-model-mismatch">, Type.TLiteral<"local-runtime-mismatch">, Type.TLiteral<"local-startup-failed">, Type.TLiteral<"local-cpu-startup-invalid">, Type.TLiteral<"cancelled">, Type.TLiteral<"unstarted">]>;
209
+ attemptId: Type.TUnion<[Type.TString, Type.TNull]>;
210
+ }>]>>;
211
+ attempts: Type.TArray<Type.TObject<{
212
+ id: Type.TString;
213
+ route: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
214
+ model: Type.TString;
215
+ routeIndex: Type.TInteger;
216
+ status: Type.TUnion<[Type.TLiteral<"success">, Type.TLiteral<"error">, Type.TLiteral<"cancelled">]>;
217
+ usage: Type.TUnion<[Type.TObject<{
218
+ providerReportedInputTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
219
+ preparedInputTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
220
+ billedTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
221
+ }>, Type.TNull]>;
222
+ errorCode: Type.TOptional<Type.TUnion<[Type.TLiteral<"configuration-invalid">, Type.TLiteral<"route-unconfigured">, Type.TLiteral<"missing-credentials">, Type.TLiteral<"http-auth">, Type.TLiteral<"http-not-found">, Type.TLiteral<"http-rate-limit">, Type.TLiteral<"http-forbidden">, Type.TLiteral<"http-bad-request">, Type.TLiteral<"http-server-error">, Type.TLiteral<"transport-failed">, Type.TLiteral<"provider-response-invalid">, Type.TLiteral<"provider-response-mismatch">, Type.TLiteral<"vector-invalid">, Type.TLiteral<"vector-zero">, Type.TLiteral<"input-empty">, Type.TLiteral<"input-too-long">, Type.TLiteral<"tokenizer-roundtrip-failed">, Type.TLiteral<"attribution-unavailable">, Type.TLiteral<"local-resources-unavailable">, Type.TLiteral<"local-model-mismatch">, Type.TLiteral<"local-runtime-mismatch">, Type.TLiteral<"local-startup-failed">, Type.TLiteral<"local-cpu-startup-invalid">, Type.TLiteral<"cancelled">, Type.TLiteral<"unstarted">]>>;
223
+ }>>;
224
+ }>;
225
+ export declare const embeddingCompareEntrySchema: Type.TObject<{
226
+ route: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
227
+ model: Type.TString;
228
+ status: Type.TUnion<[Type.TLiteral<"success">, Type.TLiteral<"error">, Type.TLiteral<"cancelled">]>;
229
+ result: Type.TObject<{
230
+ schemaVersion: Type.TLiteral<1>;
231
+ outcomes: Type.TArray<Type.TUnion<[Type.TObject<{
232
+ status: Type.TLiteral<"success">;
233
+ index: Type.TInteger;
234
+ vector: Type.TArray<Type.TNumber>;
235
+ route: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
236
+ model: Type.TString;
237
+ space: Type.TUnion<[Type.TObject<{
238
+ provider: Type.TLiteral<"local">;
239
+ model: Type.TLiteral<"embeddinggemma-2">;
240
+ revision: Type.TString;
241
+ quantization: Type.TLiteral<"Q8_0">;
242
+ runtime: Type.TString;
243
+ dimensions: Type.TLiteral<768>;
244
+ format: Type.TLiteral<"host-display-attributes-v1">;
245
+ prefix: Type.TLiteral<"title: none | text: ">;
246
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
247
+ }>, Type.TObject<{
248
+ provider: Type.TLiteral<"openai">;
249
+ model: Type.TLiteral<"text-embedding-3-small">;
250
+ revision: Type.TNull;
251
+ quantization: Type.TNull;
252
+ runtime: Type.TNull;
253
+ dimensions: Type.TLiteral<1536>;
254
+ format: Type.TLiteral<"host-display-attributes-v1">;
255
+ prefix: Type.TLiteral<"title: none | text: ">;
256
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
257
+ }>, Type.TObject<{
258
+ provider: Type.TLiteral<"sarvam">;
259
+ model: Type.TLiteral<"embeddinggemma-2">;
260
+ revision: Type.TNull;
261
+ quantization: Type.TNull;
262
+ runtime: Type.TLiteral<"sarvam-v2">;
263
+ dimensions: Type.TLiteral<768>;
264
+ format: Type.TLiteral<"host-display-attributes-v1">;
265
+ prefix: Type.TLiteral<"title: none | text: ">;
266
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
267
+ }>]>;
268
+ attemptId: Type.TString;
269
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
270
+ }>, Type.TObject<{
271
+ status: Type.TLiteral<"error">;
272
+ index: Type.TInteger;
273
+ code: Type.TUnion<[Type.TLiteral<"configuration-invalid">, Type.TLiteral<"route-unconfigured">, Type.TLiteral<"missing-credentials">, Type.TLiteral<"http-auth">, Type.TLiteral<"http-not-found">, Type.TLiteral<"http-rate-limit">, Type.TLiteral<"http-forbidden">, Type.TLiteral<"http-bad-request">, Type.TLiteral<"http-server-error">, Type.TLiteral<"transport-failed">, Type.TLiteral<"provider-response-invalid">, Type.TLiteral<"provider-response-mismatch">, Type.TLiteral<"vector-invalid">, Type.TLiteral<"vector-zero">, Type.TLiteral<"input-empty">, Type.TLiteral<"input-too-long">, Type.TLiteral<"tokenizer-roundtrip-failed">, Type.TLiteral<"attribution-unavailable">, Type.TLiteral<"local-resources-unavailable">, Type.TLiteral<"local-model-mismatch">, Type.TLiteral<"local-runtime-mismatch">, Type.TLiteral<"local-startup-failed">, Type.TLiteral<"local-cpu-startup-invalid">, Type.TLiteral<"cancelled">, Type.TLiteral<"unstarted">]>;
274
+ attemptId: Type.TUnion<[Type.TString, Type.TNull]>;
275
+ }>]>>;
276
+ attempts: Type.TArray<Type.TObject<{
277
+ id: Type.TString;
278
+ route: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
279
+ model: Type.TString;
280
+ routeIndex: Type.TInteger;
281
+ status: Type.TUnion<[Type.TLiteral<"success">, Type.TLiteral<"error">, Type.TLiteral<"cancelled">]>;
282
+ usage: Type.TUnion<[Type.TObject<{
283
+ providerReportedInputTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
284
+ preparedInputTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
285
+ billedTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
286
+ }>, Type.TNull]>;
287
+ errorCode: Type.TOptional<Type.TUnion<[Type.TLiteral<"configuration-invalid">, Type.TLiteral<"route-unconfigured">, Type.TLiteral<"missing-credentials">, Type.TLiteral<"http-auth">, Type.TLiteral<"http-not-found">, Type.TLiteral<"http-rate-limit">, Type.TLiteral<"http-forbidden">, Type.TLiteral<"http-bad-request">, Type.TLiteral<"http-server-error">, Type.TLiteral<"transport-failed">, Type.TLiteral<"provider-response-invalid">, Type.TLiteral<"provider-response-mismatch">, Type.TLiteral<"vector-invalid">, Type.TLiteral<"vector-zero">, Type.TLiteral<"input-empty">, Type.TLiteral<"input-too-long">, Type.TLiteral<"tokenizer-roundtrip-failed">, Type.TLiteral<"attribution-unavailable">, Type.TLiteral<"local-resources-unavailable">, Type.TLiteral<"local-model-mismatch">, Type.TLiteral<"local-runtime-mismatch">, Type.TLiteral<"local-startup-failed">, Type.TLiteral<"local-cpu-startup-invalid">, Type.TLiteral<"cancelled">, Type.TLiteral<"unstarted">]>>;
288
+ }>>;
289
+ }>;
290
+ }>;
291
+ export declare const embeddingCompareResultSchema: Type.TObject<{
292
+ schemaVersion: Type.TLiteral<1>;
293
+ entries: Type.TArray<Type.TObject<{
294
+ route: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
295
+ model: Type.TString;
296
+ status: Type.TUnion<[Type.TLiteral<"success">, Type.TLiteral<"error">, Type.TLiteral<"cancelled">]>;
297
+ result: Type.TObject<{
298
+ schemaVersion: Type.TLiteral<1>;
299
+ outcomes: Type.TArray<Type.TUnion<[Type.TObject<{
300
+ status: Type.TLiteral<"success">;
301
+ index: Type.TInteger;
302
+ vector: Type.TArray<Type.TNumber>;
303
+ route: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
304
+ model: Type.TString;
305
+ space: Type.TUnion<[Type.TObject<{
306
+ provider: Type.TLiteral<"local">;
307
+ model: Type.TLiteral<"embeddinggemma-2">;
308
+ revision: Type.TString;
309
+ quantization: Type.TLiteral<"Q8_0">;
310
+ runtime: Type.TString;
311
+ dimensions: Type.TLiteral<768>;
312
+ format: Type.TLiteral<"host-display-attributes-v1">;
313
+ prefix: Type.TLiteral<"title: none | text: ">;
314
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
315
+ }>, Type.TObject<{
316
+ provider: Type.TLiteral<"openai">;
317
+ model: Type.TLiteral<"text-embedding-3-small">;
318
+ revision: Type.TNull;
319
+ quantization: Type.TNull;
320
+ runtime: Type.TNull;
321
+ dimensions: Type.TLiteral<1536>;
322
+ format: Type.TLiteral<"host-display-attributes-v1">;
323
+ prefix: Type.TLiteral<"title: none | text: ">;
324
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
325
+ }>, Type.TObject<{
326
+ provider: Type.TLiteral<"sarvam">;
327
+ model: Type.TLiteral<"embeddinggemma-2">;
328
+ revision: Type.TNull;
329
+ quantization: Type.TNull;
330
+ runtime: Type.TLiteral<"sarvam-v2">;
331
+ dimensions: Type.TLiteral<768>;
332
+ format: Type.TLiteral<"host-display-attributes-v1">;
333
+ prefix: Type.TLiteral<"title: none | text: ">;
334
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
335
+ }>]>;
336
+ attemptId: Type.TString;
337
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
338
+ }>, Type.TObject<{
339
+ status: Type.TLiteral<"error">;
340
+ index: Type.TInteger;
341
+ code: Type.TUnion<[Type.TLiteral<"configuration-invalid">, Type.TLiteral<"route-unconfigured">, Type.TLiteral<"missing-credentials">, Type.TLiteral<"http-auth">, Type.TLiteral<"http-not-found">, Type.TLiteral<"http-rate-limit">, Type.TLiteral<"http-forbidden">, Type.TLiteral<"http-bad-request">, Type.TLiteral<"http-server-error">, Type.TLiteral<"transport-failed">, Type.TLiteral<"provider-response-invalid">, Type.TLiteral<"provider-response-mismatch">, Type.TLiteral<"vector-invalid">, Type.TLiteral<"vector-zero">, Type.TLiteral<"input-empty">, Type.TLiteral<"input-too-long">, Type.TLiteral<"tokenizer-roundtrip-failed">, Type.TLiteral<"attribution-unavailable">, Type.TLiteral<"local-resources-unavailable">, Type.TLiteral<"local-model-mismatch">, Type.TLiteral<"local-runtime-mismatch">, Type.TLiteral<"local-startup-failed">, Type.TLiteral<"local-cpu-startup-invalid">, Type.TLiteral<"cancelled">, Type.TLiteral<"unstarted">]>;
342
+ attemptId: Type.TUnion<[Type.TString, Type.TNull]>;
343
+ }>]>>;
344
+ attempts: Type.TArray<Type.TObject<{
345
+ id: Type.TString;
346
+ route: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
347
+ model: Type.TString;
348
+ routeIndex: Type.TInteger;
349
+ status: Type.TUnion<[Type.TLiteral<"success">, Type.TLiteral<"error">, Type.TLiteral<"cancelled">]>;
350
+ usage: Type.TUnion<[Type.TObject<{
351
+ providerReportedInputTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
352
+ preparedInputTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
353
+ billedTokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
354
+ }>, Type.TNull]>;
355
+ errorCode: Type.TOptional<Type.TUnion<[Type.TLiteral<"configuration-invalid">, Type.TLiteral<"route-unconfigured">, Type.TLiteral<"missing-credentials">, Type.TLiteral<"http-auth">, Type.TLiteral<"http-not-found">, Type.TLiteral<"http-rate-limit">, Type.TLiteral<"http-forbidden">, Type.TLiteral<"http-bad-request">, Type.TLiteral<"http-server-error">, Type.TLiteral<"transport-failed">, Type.TLiteral<"provider-response-invalid">, Type.TLiteral<"provider-response-mismatch">, Type.TLiteral<"vector-invalid">, Type.TLiteral<"vector-zero">, Type.TLiteral<"input-empty">, Type.TLiteral<"input-too-long">, Type.TLiteral<"tokenizer-roundtrip-failed">, Type.TLiteral<"attribution-unavailable">, Type.TLiteral<"local-resources-unavailable">, Type.TLiteral<"local-model-mismatch">, Type.TLiteral<"local-runtime-mismatch">, Type.TLiteral<"local-startup-failed">, Type.TLiteral<"local-cpu-startup-invalid">, Type.TLiteral<"cancelled">, Type.TLiteral<"unstarted">]>>;
356
+ }>>;
357
+ }>;
358
+ }>>;
359
+ }>;
360
+ export declare const embeddingDiagnosticSchema: Type.TObject<{
361
+ code: Type.TString;
362
+ severity: Type.TUnion<[Type.TLiteral<"error">, Type.TLiteral<"warning">, Type.TLiteral<"info">]>;
363
+ }>;
364
+ export declare const embeddingDescribeSchema: Type.TObject<{
365
+ schemaVersion: Type.TLiteral<1>;
366
+ ready: Type.TBoolean;
367
+ selected: Type.TObject<{
368
+ provider: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
369
+ model: Type.TString;
370
+ }>;
371
+ space: Type.TUnion<[Type.TUnion<[Type.TObject<{
372
+ provider: Type.TLiteral<"local">;
373
+ model: Type.TLiteral<"embeddinggemma-2">;
374
+ revision: Type.TString;
375
+ quantization: Type.TLiteral<"Q8_0">;
376
+ runtime: Type.TString;
377
+ dimensions: Type.TLiteral<768>;
378
+ format: Type.TLiteral<"host-display-attributes-v1">;
379
+ prefix: Type.TLiteral<"title: none | text: ">;
380
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
381
+ }>, Type.TObject<{
382
+ provider: Type.TLiteral<"openai">;
383
+ model: Type.TLiteral<"text-embedding-3-small">;
384
+ revision: Type.TNull;
385
+ quantization: Type.TNull;
386
+ runtime: Type.TNull;
387
+ dimensions: Type.TLiteral<1536>;
388
+ format: Type.TLiteral<"host-display-attributes-v1">;
389
+ prefix: Type.TLiteral<"title: none | text: ">;
390
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
391
+ }>, Type.TObject<{
392
+ provider: Type.TLiteral<"sarvam">;
393
+ model: Type.TLiteral<"embeddinggemma-2">;
394
+ revision: Type.TNull;
395
+ quantization: Type.TNull;
396
+ runtime: Type.TLiteral<"sarvam-v2">;
397
+ dimensions: Type.TLiteral<768>;
398
+ format: Type.TLiteral<"host-display-attributes-v1">;
399
+ prefix: Type.TLiteral<"title: none | text: ">;
400
+ normalization: Type.TLiteral<"finite-nonzero-l2-v1">;
401
+ }>]>, Type.TNull]>;
402
+ default: Type.TObject<{
403
+ provider: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
404
+ model: Type.TString;
405
+ }>;
406
+ fallback: Type.TArray<Type.TObject<{
407
+ provider: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
408
+ model: Type.TString;
409
+ }>>;
410
+ compare: Type.TArray<Type.TObject<{
411
+ provider: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"openai">, Type.TLiteral<"sarvam">, Type.TLiteral<"gateway">]>;
412
+ model: Type.TString;
413
+ }>>;
414
+ diagnostics: Type.TArray<Type.TObject<{
415
+ code: Type.TString;
416
+ severity: Type.TUnion<[Type.TLiteral<"error">, Type.TLiteral<"warning">, Type.TLiteral<"info">]>;
417
+ }>>;
418
+ }>;
419
+ export type EmbeddingSettings = Static<typeof embeddingSettingsSchema>;
420
+ export type EmbeddingRoute = Static<typeof embeddingRouteSchema>;
421
+ export type EmbeddingSpace = Static<typeof embeddingSpaceSchema>;
422
+ export type EmbeddingRequest = Static<typeof embeddingRequestSchema>;
423
+ export type EmbeddingContext = Static<typeof embeddingContextSchema>;
424
+ export type EmbeddingUsage = Static<typeof embeddingUsageSchema>;
425
+ export type EmbeddingAttempt = Static<typeof embeddingAttemptSchema>;
426
+ export type EmbeddingOutcome = Static<typeof embeddingOutcomeSchema>;
427
+ export type EmbeddingResult = Static<typeof embeddingResultSchema>;
428
+ export type EmbeddingCompareEntry = Static<typeof embeddingCompareEntrySchema>;
429
+ export type EmbeddingCompareResult = Static<typeof embeddingCompareResultSchema>;
430
+ export type EmbeddingDiagnostic = Static<typeof embeddingDiagnosticSchema>;
431
+ export type EmbeddingDescribe = Static<typeof embeddingDescribeSchema>;