@abhishek944/pi-embeddings 0.0.0-stage → 0.2.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 +97 -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 +264 -0
  7. package/dist/extension.d.ts +2 -0
  8. package/dist/extension.js +164 -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 +141 -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 +25 -0
  22. package/dist/providers.js +415 -0
  23. package/dist/response.d.ts +17 -0
  24. package/dist/response.js +105 -0
  25. package/dist/runtime.d.ts +39 -0
  26. package/dist/runtime.js +130 -0
  27. package/dist/schemas.d.ts +758 -0
  28. package/dist/schemas.js +244 -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 +99 -0
  33. package/dist/tool-contracts.d.ts +343 -0
  34. package/dist/tool-contracts.js +10 -0
  35. package/package.json +83 -4
  36. package/src/errors.ts +52 -0
  37. package/src/execute.ts +300 -0
  38. package/src/extension.ts +210 -0
  39. package/src/index.ts +36 -0
  40. package/src/local-runtime.ts +273 -0
  41. package/src/mcp-cli.ts +52 -0
  42. package/src/mcp-server.ts +187 -0
  43. package/src/provider-http.ts +67 -0
  44. package/src/provider-types.ts +33 -0
  45. package/src/providers.ts +517 -0
  46. package/src/response.ts +125 -0
  47. package/src/runtime.ts +184 -0
  48. package/src/schemas.ts +368 -0
  49. package/src/settings-write.ts +96 -0
  50. package/src/settings.ts +119 -0
  51. package/src/tool-contracts.ts +22 -0
@@ -0,0 +1,343 @@
1
+ export declare const EMBED_TOOL = "embed";
2
+ export declare const EMBED_COMPARE_TOOL = "embed_compare";
3
+ export declare const EMBED_TOOL_DESCRIPTION = "Embed one or more text inputs with the server-configured embedding route. Provider, model, fallback routes and credentials stay in trusted settings; this tool cannot override them. Returns vectors and their actual generating space as structured data. Full text is preserved; the package owns prefixing and provider batching. Use embed_compare only for an explicit comparison.";
4
+ export declare const EMBED_COMPARE_TOOL_DESCRIPTION = "Explicitly compare the same text inputs using exactly the configured compare routes. Every entry is a separate request and may incur charges. No implicit default, fallback, ranking or settings mutation.";
5
+ export declare const embedParameters: import("typebox").TObject<{
6
+ inputs: import("typebox").TArray<import("typebox").TString>;
7
+ }>;
8
+ export declare const embedCompareParameters: import("typebox").TObject<{
9
+ inputs: import("typebox").TArray<import("typebox").TString>;
10
+ }>;
11
+ export declare const embedOutput: import("typebox").TObject<{
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").TNull]>;
14
+ model: import("typebox").TUnion<[import("typebox").TString, import("typebox").TNull]>;
15
+ space: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TObject<{
16
+ provider: import("typebox").TLiteral<"local">;
17
+ model: import("typebox").TLiteral<"embeddinggemma-2">;
18
+ revision: import("typebox").TString;
19
+ quantization: import("typebox").TLiteral<"Q8_0">;
20
+ runtime: import("typebox").TString;
21
+ dimensions: import("typebox").TLiteral<768>;
22
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
23
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
24
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
25
+ }>, import("typebox").TObject<{
26
+ provider: import("typebox").TLiteral<"openai">;
27
+ model: import("typebox").TLiteral<"text-embedding-3-small">;
28
+ revision: import("typebox").TNull;
29
+ quantization: import("typebox").TNull;
30
+ runtime: import("typebox").TNull;
31
+ dimensions: import("typebox").TLiteral<1536>;
32
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
33
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
34
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
35
+ }>, import("typebox").TObject<{
36
+ provider: import("typebox").TLiteral<"sarvam">;
37
+ model: import("typebox").TLiteral<"embeddinggemma-2">;
38
+ revision: import("typebox").TNull;
39
+ quantization: import("typebox").TNull;
40
+ runtime: import("typebox").TLiteral<"sarvam-v2">;
41
+ dimensions: import("typebox").TLiteral<768>;
42
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
43
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
44
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
45
+ }>, import("typebox").TObject<{
46
+ provider: import("typebox").TLiteral<"cloudflare">;
47
+ model: import("typebox").TLiteral<"@cf/baai/bge-base-en-v1.5">;
48
+ revision: import("typebox").TNull;
49
+ quantization: import("typebox").TNull;
50
+ runtime: import("typebox").TLiteral<"cloudflare-workers-ai">;
51
+ dimensions: import("typebox").TLiteral<768>;
52
+ pooling: import("typebox").TUnion<[import("typebox").TLiteral<"mean">, import("typebox").TLiteral<"cls">]>;
53
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
54
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
55
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
56
+ }>]>, import("typebox").TNull]>;
57
+ generations: import("typebox").TArray<import("typebox").TObject<{
58
+ 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">]>;
59
+ model: import("typebox").TString;
60
+ space: import("typebox").TUnion<[import("typebox").TObject<{
61
+ provider: import("typebox").TLiteral<"local">;
62
+ model: import("typebox").TLiteral<"embeddinggemma-2">;
63
+ revision: import("typebox").TString;
64
+ quantization: import("typebox").TLiteral<"Q8_0">;
65
+ runtime: import("typebox").TString;
66
+ dimensions: import("typebox").TLiteral<768>;
67
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
68
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
69
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
70
+ }>, import("typebox").TObject<{
71
+ provider: import("typebox").TLiteral<"openai">;
72
+ model: import("typebox").TLiteral<"text-embedding-3-small">;
73
+ revision: import("typebox").TNull;
74
+ quantization: import("typebox").TNull;
75
+ runtime: import("typebox").TNull;
76
+ dimensions: import("typebox").TLiteral<1536>;
77
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
78
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
79
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
80
+ }>, import("typebox").TObject<{
81
+ provider: import("typebox").TLiteral<"sarvam">;
82
+ model: import("typebox").TLiteral<"embeddinggemma-2">;
83
+ revision: import("typebox").TNull;
84
+ quantization: import("typebox").TNull;
85
+ runtime: import("typebox").TLiteral<"sarvam-v2">;
86
+ dimensions: import("typebox").TLiteral<768>;
87
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
88
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
89
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
90
+ }>, import("typebox").TObject<{
91
+ provider: import("typebox").TLiteral<"cloudflare">;
92
+ model: import("typebox").TLiteral<"@cf/baai/bge-base-en-v1.5">;
93
+ revision: import("typebox").TNull;
94
+ quantization: import("typebox").TNull;
95
+ runtime: import("typebox").TLiteral<"cloudflare-workers-ai">;
96
+ dimensions: import("typebox").TLiteral<768>;
97
+ pooling: import("typebox").TUnion<[import("typebox").TLiteral<"mean">, import("typebox").TLiteral<"cls">]>;
98
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
99
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
100
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
101
+ }>]>;
102
+ }>>;
103
+ outcomes: import("typebox").TArray<import("typebox").TUnion<[import("typebox").TObject<{
104
+ status: import("typebox").TLiteral<"success">;
105
+ index: import("typebox").TInteger;
106
+ vector: import("typebox").TArray<import("typebox").TNumber>;
107
+ 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">]>;
108
+ model: import("typebox").TString;
109
+ space: import("typebox").TUnion<[import("typebox").TObject<{
110
+ provider: import("typebox").TLiteral<"local">;
111
+ model: import("typebox").TLiteral<"embeddinggemma-2">;
112
+ revision: import("typebox").TString;
113
+ quantization: import("typebox").TLiteral<"Q8_0">;
114
+ runtime: import("typebox").TString;
115
+ dimensions: import("typebox").TLiteral<768>;
116
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
117
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
118
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
119
+ }>, import("typebox").TObject<{
120
+ provider: import("typebox").TLiteral<"openai">;
121
+ model: import("typebox").TLiteral<"text-embedding-3-small">;
122
+ revision: import("typebox").TNull;
123
+ quantization: import("typebox").TNull;
124
+ runtime: import("typebox").TNull;
125
+ dimensions: import("typebox").TLiteral<1536>;
126
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
127
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
128
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
129
+ }>, import("typebox").TObject<{
130
+ provider: import("typebox").TLiteral<"sarvam">;
131
+ model: import("typebox").TLiteral<"embeddinggemma-2">;
132
+ revision: import("typebox").TNull;
133
+ quantization: import("typebox").TNull;
134
+ runtime: import("typebox").TLiteral<"sarvam-v2">;
135
+ dimensions: import("typebox").TLiteral<768>;
136
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
137
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
138
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
139
+ }>, import("typebox").TObject<{
140
+ provider: import("typebox").TLiteral<"cloudflare">;
141
+ model: import("typebox").TLiteral<"@cf/baai/bge-base-en-v1.5">;
142
+ revision: import("typebox").TNull;
143
+ quantization: import("typebox").TNull;
144
+ runtime: import("typebox").TLiteral<"cloudflare-workers-ai">;
145
+ dimensions: import("typebox").TLiteral<768>;
146
+ pooling: import("typebox").TUnion<[import("typebox").TLiteral<"mean">, import("typebox").TLiteral<"cls">]>;
147
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
148
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
149
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
150
+ }>]>;
151
+ attemptId: import("typebox").TString;
152
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
153
+ }>, import("typebox").TObject<{
154
+ status: import("typebox").TLiteral<"error">;
155
+ index: import("typebox").TInteger;
156
+ code: import("typebox").TUnion<[import("typebox").TLiteral<"configuration-invalid">, import("typebox").TLiteral<"route-unconfigured">, import("typebox").TLiteral<"missing-credentials">, import("typebox").TLiteral<"http-auth">, import("typebox").TLiteral<"http-not-found">, import("typebox").TLiteral<"http-rate-limit">, import("typebox").TLiteral<"http-forbidden">, import("typebox").TLiteral<"http-bad-request">, import("typebox").TLiteral<"http-server-error">, import("typebox").TLiteral<"transport-failed">, import("typebox").TLiteral<"provider-response-invalid">, import("typebox").TLiteral<"provider-response-mismatch">, import("typebox").TLiteral<"vector-invalid">, import("typebox").TLiteral<"vector-zero">, import("typebox").TLiteral<"input-empty">, import("typebox").TLiteral<"input-too-long">, import("typebox").TLiteral<"tokenizer-roundtrip-failed">, import("typebox").TLiteral<"attribution-unavailable">, import("typebox").TLiteral<"local-resources-unavailable">, import("typebox").TLiteral<"local-model-mismatch">, import("typebox").TLiteral<"local-runtime-mismatch">, import("typebox").TLiteral<"local-startup-failed">, import("typebox").TLiteral<"local-cpu-startup-invalid">, import("typebox").TLiteral<"cancelled">, import("typebox").TLiteral<"unstarted">]>;
157
+ attemptId: import("typebox").TUnion<[import("typebox").TString, import("typebox").TNull]>;
158
+ }>]>>;
159
+ attempts: import("typebox").TArray<import("typebox").TObject<{
160
+ id: import("typebox").TString;
161
+ 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">]>;
162
+ model: import("typebox").TString;
163
+ routeIndex: import("typebox").TInteger;
164
+ status: import("typebox").TUnion<[import("typebox").TLiteral<"success">, import("typebox").TLiteral<"error">, import("typebox").TLiteral<"cancelled">]>;
165
+ usage: import("typebox").TUnion<[import("typebox").TObject<{
166
+ providerReportedInputTokens: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
167
+ preparedInputTokens: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
168
+ billedTokens: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
169
+ }>, import("typebox").TNull]>;
170
+ errorCode: import("typebox").TOptional<import("typebox").TUnion<[import("typebox").TLiteral<"configuration-invalid">, import("typebox").TLiteral<"route-unconfigured">, import("typebox").TLiteral<"missing-credentials">, import("typebox").TLiteral<"http-auth">, import("typebox").TLiteral<"http-not-found">, import("typebox").TLiteral<"http-rate-limit">, import("typebox").TLiteral<"http-forbidden">, import("typebox").TLiteral<"http-bad-request">, import("typebox").TLiteral<"http-server-error">, import("typebox").TLiteral<"transport-failed">, import("typebox").TLiteral<"provider-response-invalid">, import("typebox").TLiteral<"provider-response-mismatch">, import("typebox").TLiteral<"vector-invalid">, import("typebox").TLiteral<"vector-zero">, import("typebox").TLiteral<"input-empty">, import("typebox").TLiteral<"input-too-long">, import("typebox").TLiteral<"tokenizer-roundtrip-failed">, import("typebox").TLiteral<"attribution-unavailable">, import("typebox").TLiteral<"local-resources-unavailable">, import("typebox").TLiteral<"local-model-mismatch">, import("typebox").TLiteral<"local-runtime-mismatch">, import("typebox").TLiteral<"local-startup-failed">, import("typebox").TLiteral<"local-cpu-startup-invalid">, import("typebox").TLiteral<"cancelled">, import("typebox").TLiteral<"unstarted">]>>;
171
+ }>>;
172
+ }>;
173
+ export declare const embedCompareOutput: import("typebox").TObject<{
174
+ schemaVersion: import("typebox").TLiteral<2>;
175
+ entries: import("typebox").TArray<import("typebox").TObject<{
176
+ 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">]>;
177
+ model: import("typebox").TString;
178
+ status: import("typebox").TUnion<[import("typebox").TLiteral<"success">, import("typebox").TLiteral<"error">, import("typebox").TLiteral<"cancelled">]>;
179
+ result: import("typebox").TObject<{
180
+ schemaVersion: import("typebox").TLiteral<2>;
181
+ 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").TNull]>;
182
+ model: import("typebox").TUnion<[import("typebox").TString, import("typebox").TNull]>;
183
+ space: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TObject<{
184
+ provider: import("typebox").TLiteral<"local">;
185
+ model: import("typebox").TLiteral<"embeddinggemma-2">;
186
+ revision: import("typebox").TString;
187
+ quantization: import("typebox").TLiteral<"Q8_0">;
188
+ runtime: import("typebox").TString;
189
+ dimensions: import("typebox").TLiteral<768>;
190
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
191
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
192
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
193
+ }>, import("typebox").TObject<{
194
+ provider: import("typebox").TLiteral<"openai">;
195
+ model: import("typebox").TLiteral<"text-embedding-3-small">;
196
+ revision: import("typebox").TNull;
197
+ quantization: import("typebox").TNull;
198
+ runtime: import("typebox").TNull;
199
+ dimensions: import("typebox").TLiteral<1536>;
200
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
201
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
202
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
203
+ }>, import("typebox").TObject<{
204
+ provider: import("typebox").TLiteral<"sarvam">;
205
+ model: import("typebox").TLiteral<"embeddinggemma-2">;
206
+ revision: import("typebox").TNull;
207
+ quantization: import("typebox").TNull;
208
+ runtime: import("typebox").TLiteral<"sarvam-v2">;
209
+ dimensions: import("typebox").TLiteral<768>;
210
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
211
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
212
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
213
+ }>, import("typebox").TObject<{
214
+ provider: import("typebox").TLiteral<"cloudflare">;
215
+ model: import("typebox").TLiteral<"@cf/baai/bge-base-en-v1.5">;
216
+ revision: import("typebox").TNull;
217
+ quantization: import("typebox").TNull;
218
+ runtime: import("typebox").TLiteral<"cloudflare-workers-ai">;
219
+ dimensions: import("typebox").TLiteral<768>;
220
+ pooling: import("typebox").TUnion<[import("typebox").TLiteral<"mean">, import("typebox").TLiteral<"cls">]>;
221
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
222
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
223
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
224
+ }>]>, import("typebox").TNull]>;
225
+ generations: import("typebox").TArray<import("typebox").TObject<{
226
+ 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">]>;
227
+ model: import("typebox").TString;
228
+ space: import("typebox").TUnion<[import("typebox").TObject<{
229
+ provider: import("typebox").TLiteral<"local">;
230
+ model: import("typebox").TLiteral<"embeddinggemma-2">;
231
+ revision: import("typebox").TString;
232
+ quantization: import("typebox").TLiteral<"Q8_0">;
233
+ runtime: import("typebox").TString;
234
+ dimensions: import("typebox").TLiteral<768>;
235
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
236
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
237
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
238
+ }>, import("typebox").TObject<{
239
+ provider: import("typebox").TLiteral<"openai">;
240
+ model: import("typebox").TLiteral<"text-embedding-3-small">;
241
+ revision: import("typebox").TNull;
242
+ quantization: import("typebox").TNull;
243
+ runtime: import("typebox").TNull;
244
+ dimensions: import("typebox").TLiteral<1536>;
245
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
246
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
247
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
248
+ }>, import("typebox").TObject<{
249
+ provider: import("typebox").TLiteral<"sarvam">;
250
+ model: import("typebox").TLiteral<"embeddinggemma-2">;
251
+ revision: import("typebox").TNull;
252
+ quantization: import("typebox").TNull;
253
+ runtime: import("typebox").TLiteral<"sarvam-v2">;
254
+ dimensions: import("typebox").TLiteral<768>;
255
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
256
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
257
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
258
+ }>, import("typebox").TObject<{
259
+ provider: import("typebox").TLiteral<"cloudflare">;
260
+ model: import("typebox").TLiteral<"@cf/baai/bge-base-en-v1.5">;
261
+ revision: import("typebox").TNull;
262
+ quantization: import("typebox").TNull;
263
+ runtime: import("typebox").TLiteral<"cloudflare-workers-ai">;
264
+ dimensions: import("typebox").TLiteral<768>;
265
+ pooling: import("typebox").TUnion<[import("typebox").TLiteral<"mean">, import("typebox").TLiteral<"cls">]>;
266
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
267
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
268
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
269
+ }>]>;
270
+ }>>;
271
+ outcomes: import("typebox").TArray<import("typebox").TUnion<[import("typebox").TObject<{
272
+ status: import("typebox").TLiteral<"success">;
273
+ index: import("typebox").TInteger;
274
+ vector: import("typebox").TArray<import("typebox").TNumber>;
275
+ 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">]>;
276
+ model: import("typebox").TString;
277
+ space: import("typebox").TUnion<[import("typebox").TObject<{
278
+ provider: import("typebox").TLiteral<"local">;
279
+ model: import("typebox").TLiteral<"embeddinggemma-2">;
280
+ revision: import("typebox").TString;
281
+ quantization: import("typebox").TLiteral<"Q8_0">;
282
+ runtime: import("typebox").TString;
283
+ dimensions: import("typebox").TLiteral<768>;
284
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
285
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
286
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
287
+ }>, import("typebox").TObject<{
288
+ provider: import("typebox").TLiteral<"openai">;
289
+ model: import("typebox").TLiteral<"text-embedding-3-small">;
290
+ revision: import("typebox").TNull;
291
+ quantization: import("typebox").TNull;
292
+ runtime: import("typebox").TNull;
293
+ dimensions: import("typebox").TLiteral<1536>;
294
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
295
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
296
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
297
+ }>, import("typebox").TObject<{
298
+ provider: import("typebox").TLiteral<"sarvam">;
299
+ model: import("typebox").TLiteral<"embeddinggemma-2">;
300
+ revision: import("typebox").TNull;
301
+ quantization: import("typebox").TNull;
302
+ runtime: import("typebox").TLiteral<"sarvam-v2">;
303
+ dimensions: import("typebox").TLiteral<768>;
304
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
305
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
306
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
307
+ }>, import("typebox").TObject<{
308
+ provider: import("typebox").TLiteral<"cloudflare">;
309
+ model: import("typebox").TLiteral<"@cf/baai/bge-base-en-v1.5">;
310
+ revision: import("typebox").TNull;
311
+ quantization: import("typebox").TNull;
312
+ runtime: import("typebox").TLiteral<"cloudflare-workers-ai">;
313
+ dimensions: import("typebox").TLiteral<768>;
314
+ pooling: import("typebox").TUnion<[import("typebox").TLiteral<"mean">, import("typebox").TLiteral<"cls">]>;
315
+ format: import("typebox").TLiteral<"host-display-attributes-v1">;
316
+ prefix: import("typebox").TLiteral<"title: none | text: ">;
317
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
318
+ }>]>;
319
+ attemptId: import("typebox").TString;
320
+ normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
321
+ }>, import("typebox").TObject<{
322
+ status: import("typebox").TLiteral<"error">;
323
+ index: import("typebox").TInteger;
324
+ code: import("typebox").TUnion<[import("typebox").TLiteral<"configuration-invalid">, import("typebox").TLiteral<"route-unconfigured">, import("typebox").TLiteral<"missing-credentials">, import("typebox").TLiteral<"http-auth">, import("typebox").TLiteral<"http-not-found">, import("typebox").TLiteral<"http-rate-limit">, import("typebox").TLiteral<"http-forbidden">, import("typebox").TLiteral<"http-bad-request">, import("typebox").TLiteral<"http-server-error">, import("typebox").TLiteral<"transport-failed">, import("typebox").TLiteral<"provider-response-invalid">, import("typebox").TLiteral<"provider-response-mismatch">, import("typebox").TLiteral<"vector-invalid">, import("typebox").TLiteral<"vector-zero">, import("typebox").TLiteral<"input-empty">, import("typebox").TLiteral<"input-too-long">, import("typebox").TLiteral<"tokenizer-roundtrip-failed">, import("typebox").TLiteral<"attribution-unavailable">, import("typebox").TLiteral<"local-resources-unavailable">, import("typebox").TLiteral<"local-model-mismatch">, import("typebox").TLiteral<"local-runtime-mismatch">, import("typebox").TLiteral<"local-startup-failed">, import("typebox").TLiteral<"local-cpu-startup-invalid">, import("typebox").TLiteral<"cancelled">, import("typebox").TLiteral<"unstarted">]>;
325
+ attemptId: import("typebox").TUnion<[import("typebox").TString, import("typebox").TNull]>;
326
+ }>]>>;
327
+ attempts: import("typebox").TArray<import("typebox").TObject<{
328
+ id: import("typebox").TString;
329
+ 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">]>;
330
+ model: import("typebox").TString;
331
+ routeIndex: import("typebox").TInteger;
332
+ status: import("typebox").TUnion<[import("typebox").TLiteral<"success">, import("typebox").TLiteral<"error">, import("typebox").TLiteral<"cancelled">]>;
333
+ usage: import("typebox").TUnion<[import("typebox").TObject<{
334
+ providerReportedInputTokens: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
335
+ preparedInputTokens: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
336
+ billedTokens: import("typebox").TUnion<[import("typebox").TInteger, import("typebox").TNull]>;
337
+ }>, import("typebox").TNull]>;
338
+ errorCode: import("typebox").TOptional<import("typebox").TUnion<[import("typebox").TLiteral<"configuration-invalid">, import("typebox").TLiteral<"route-unconfigured">, import("typebox").TLiteral<"missing-credentials">, import("typebox").TLiteral<"http-auth">, import("typebox").TLiteral<"http-not-found">, import("typebox").TLiteral<"http-rate-limit">, import("typebox").TLiteral<"http-forbidden">, import("typebox").TLiteral<"http-bad-request">, import("typebox").TLiteral<"http-server-error">, import("typebox").TLiteral<"transport-failed">, import("typebox").TLiteral<"provider-response-invalid">, import("typebox").TLiteral<"provider-response-mismatch">, import("typebox").TLiteral<"vector-invalid">, import("typebox").TLiteral<"vector-zero">, import("typebox").TLiteral<"input-empty">, import("typebox").TLiteral<"input-too-long">, import("typebox").TLiteral<"tokenizer-roundtrip-failed">, import("typebox").TLiteral<"attribution-unavailable">, import("typebox").TLiteral<"local-resources-unavailable">, import("typebox").TLiteral<"local-model-mismatch">, import("typebox").TLiteral<"local-runtime-mismatch">, import("typebox").TLiteral<"local-startup-failed">, import("typebox").TLiteral<"local-cpu-startup-invalid">, import("typebox").TLiteral<"cancelled">, import("typebox").TLiteral<"unstarted">]>>;
339
+ }>>;
340
+ }>;
341
+ }>>;
342
+ }>;
343
+ export declare const EMBEDDINGS_TOOL_NAMES: readonly ["embed", "embed_compare"];
@@ -0,0 +1,10 @@
1
+ import { embeddingCompareResultSchema, embeddingRequestSchema, embeddingResultSchema, } from './schemas.js';
2
+ export const EMBED_TOOL = 'embed';
3
+ export const EMBED_COMPARE_TOOL = 'embed_compare';
4
+ export const EMBED_TOOL_DESCRIPTION = 'Embed one or more text inputs with the server-configured embedding route. Provider, model, fallback routes and credentials stay in trusted settings; this tool cannot override them. Returns vectors and their actual generating space as structured data. Full text is preserved; the package owns prefixing and provider batching. Use embed_compare only for an explicit comparison.';
5
+ export const EMBED_COMPARE_TOOL_DESCRIPTION = 'Explicitly compare the same text inputs using exactly the configured compare routes. Every entry is a separate request and may incur charges. No implicit default, fallback, ranking or settings mutation.';
6
+ export const embedParameters = embeddingRequestSchema;
7
+ export const embedCompareParameters = embeddingRequestSchema;
8
+ export const embedOutput = embeddingResultSchema;
9
+ export const embedCompareOutput = embeddingCompareResultSchema;
10
+ export const EMBEDDINGS_TOOL_NAMES = [EMBED_TOOL, EMBED_COMPARE_TOOL];
package/package.json CHANGED
@@ -1,6 +1,85 @@
1
1
  {
2
2
  "name": "@abhishek944/pi-embeddings",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Config-driven text embeddings for Pi and MCP with local, OpenAI, Sarvam and gateway routes, ordered fallback and explicit comparisons.",
5
+ "keywords": [
6
+ "pi-package",
7
+ "pi",
8
+ "embeddings",
9
+ "mcp",
10
+ "openai",
11
+ "sarvam",
12
+ "embeddinggemma",
13
+ "litellm"
14
+ ],
15
+ "license": "Apache-2.0",
16
+ "type": "module",
17
+ "engines": {
18
+ "node": ">=22.19.0"
19
+ },
20
+ "sideEffects": false,
21
+ "main": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "bin": {
24
+ "pi-embeddings-mcp": "dist/mcp-cli.js"
25
+ },
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
30
+ },
31
+ "./schemas": {
32
+ "types": "./dist/schemas.d.ts",
33
+ "import": "./dist/schemas.js"
34
+ },
35
+ "./extension": {
36
+ "types": "./dist/extension.d.ts",
37
+ "import": "./dist/extension.js"
38
+ },
39
+ "./mcp": {
40
+ "types": "./dist/mcp-server.d.ts",
41
+ "import": "./dist/mcp-server.js"
42
+ },
43
+ "./package.json": "./package.json"
44
+ },
45
+ "files": [
46
+ "dist",
47
+ "src",
48
+ "README.md",
49
+ "LICENSE"
50
+ ],
51
+ "pi": {
52
+ "extensions": [
53
+ "./dist/extension.js"
54
+ ]
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "scripts": {
60
+ "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
61
+ "build": "npm run clean && tsc -p tsconfig.build.json",
62
+ "typecheck": "tsc -p tsconfig.json --noEmit --pretty false",
63
+ "check": "npm run typecheck && npm run build && npm pack --dry-run"
64
+ },
65
+ "dependencies": {
66
+ "@amaster.ai/pi-shared": "^0.1.10",
67
+ "@modelcontextprotocol/sdk": "1.32.1",
68
+ "js-tiktoken": "1.0.21"
69
+ },
70
+ "peerDependencies": {
71
+ "@earendil-works/pi-coding-agent": ">=1.2.0",
72
+ "typebox": "*"
73
+ },
74
+ "peerDependenciesMeta": {
75
+ "@earendil-works/pi-coding-agent": {
76
+ "optional": true
77
+ }
78
+ },
79
+ "devDependencies": {
80
+ "@earendil-works/pi-coding-agent": "1.5.2",
81
+ "@types/node": "24.19.2",
82
+ "typebox": "1.3.27",
83
+ "typescript": "5.9.3"
84
+ }
85
+ }
package/src/errors.ts ADDED
@@ -0,0 +1,52 @@
1
+ import type { EmbeddingErrorCode } from './schemas.js';
2
+
3
+ /** Fixed, redacted diagnostics. Provider bodies, input text and credentials never enter an error. */
4
+ export type KnownUsage = Readonly<{
5
+ readonly providerReportedInputTokens?: number | null | undefined;
6
+ readonly preparedInputTokens?: number | null | undefined;
7
+ }>;
8
+
9
+ export class EmbeddingsError extends Error {
10
+ readonly code: EmbeddingErrorCode;
11
+ readonly httpStatus: number | undefined;
12
+ /** Counts already known when a later validation or transport step failed; billing stays unknown. */
13
+ readonly knownUsage: KnownUsage | undefined;
14
+
15
+ constructor(
16
+ code: EmbeddingErrorCode,
17
+ options?: { httpStatus?: number; knownUsage?: KnownUsage }
18
+ ) {
19
+ super(code);
20
+ this.code = code;
21
+ this.httpStatus = options?.httpStatus;
22
+ this.knownUsage = options?.knownUsage;
23
+ this.name = 'EmbeddingsError';
24
+ }
25
+ }
26
+
27
+ export const codeOf = (error: unknown): EmbeddingErrorCode =>
28
+ error instanceof EmbeddingsError ? error.code : 'transport-failed';
29
+
30
+ /** Only these typed failures may advance an ordinary call to the next configured fallback route. */
31
+ export const fallbackCodeForStatus = (status: number): EmbeddingErrorCode | undefined => {
32
+ if (status === 401) return 'http-auth';
33
+ if (status === 404) return 'http-not-found';
34
+ if (status === 429) return 'http-rate-limit';
35
+ return undefined;
36
+ };
37
+
38
+ export const isFallbackError = (error: unknown): boolean =>
39
+ error instanceof EmbeddingsError &&
40
+ (error.code === 'missing-credentials' ||
41
+ error.code === 'http-auth' ||
42
+ error.code === 'http-not-found' ||
43
+ error.code === 'http-rate-limit');
44
+
45
+ export const statusCode = (status: number): EmbeddingErrorCode => {
46
+ const fallback = fallbackCodeForStatus(status);
47
+ if (fallback !== undefined) return fallback;
48
+ if (status === 403) return 'http-forbidden';
49
+ if (status === 400 || status === 422) return 'http-bad-request';
50
+ if (status >= 500) return 'http-server-error';
51
+ return 'http-bad-request';
52
+ };