@promptev/context-engine 0.0.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 (68) hide show
  1. package/LICENSE.md +202 -0
  2. package/NOTICE +17 -0
  3. package/README.md +112 -0
  4. package/dist/cli.js +11998 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/config-Bl9U789m.d.cts +174 -0
  7. package/dist/config-Bt9bUQqU.d.ts +174 -0
  8. package/dist/embeddings-B-jZ42mk.d.cts +67 -0
  9. package/dist/embeddings-DaSdAZN3.d.ts +67 -0
  10. package/dist/express.cjs +3173 -0
  11. package/dist/express.cjs.map +1 -0
  12. package/dist/express.d.cts +24 -0
  13. package/dist/express.d.ts +24 -0
  14. package/dist/express.js +3170 -0
  15. package/dist/express.js.map +1 -0
  16. package/dist/fastify.cjs +3184 -0
  17. package/dist/fastify.cjs.map +1 -0
  18. package/dist/fastify.d.cts +16 -0
  19. package/dist/fastify.d.ts +16 -0
  20. package/dist/fastify.js +3181 -0
  21. package/dist/fastify.js.map +1 -0
  22. package/dist/governance-BDkcv4qZ.d.cts +79 -0
  23. package/dist/governance-XIScatRO.d.ts +79 -0
  24. package/dist/graph/index.cjs +1428 -0
  25. package/dist/graph/index.cjs.map +1 -0
  26. package/dist/graph/index.d.cts +104 -0
  27. package/dist/graph/index.d.ts +104 -0
  28. package/dist/graph/index.js +1413 -0
  29. package/dist/graph/index.js.map +1 -0
  30. package/dist/hono.cjs +3183 -0
  31. package/dist/hono.cjs.map +1 -0
  32. package/dist/hono.d.cts +39 -0
  33. package/dist/hono.d.ts +39 -0
  34. package/dist/hono.js +3179 -0
  35. package/dist/hono.js.map +1 -0
  36. package/dist/index.cjs +11731 -0
  37. package/dist/index.cjs.map +1 -0
  38. package/dist/index.d.cts +851 -0
  39. package/dist/index.d.ts +851 -0
  40. package/dist/index.js +11676 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/mcp.cjs +181 -0
  43. package/dist/mcp.cjs.map +1 -0
  44. package/dist/mcp.d.cts +26 -0
  45. package/dist/mcp.d.ts +26 -0
  46. package/dist/mcp.js +179 -0
  47. package/dist/mcp.js.map +1 -0
  48. package/dist/migrations/sql/0001.sql +119 -0
  49. package/dist/migrations/sql/0002_graph.sql +48 -0
  50. package/dist/migrations/sql/0003_tools.sql +61 -0
  51. package/dist/migrations/sql/0004_acl_indexes.sql +4 -0
  52. package/dist/redaction-BmDSWJ7h.d.cts +98 -0
  53. package/dist/redaction-BmDSWJ7h.d.ts +98 -0
  54. package/dist/redaction-presidio.cjs +79 -0
  55. package/dist/redaction-presidio.cjs.map +1 -0
  56. package/dist/redaction-presidio.d.cts +22 -0
  57. package/dist/redaction-presidio.d.ts +22 -0
  58. package/dist/redaction-presidio.js +73 -0
  59. package/dist/redaction-presidio.js.map +1 -0
  60. package/dist/router-CrxZ2y_Z.d.ts +82 -0
  61. package/dist/router-OPgSoYAB.d.cts +82 -0
  62. package/dist/skills/context-engine/SKILL.md +160 -0
  63. package/package.json +184 -0
  64. package/src/migrations/sql/0001.sql +119 -0
  65. package/src/migrations/sql/0002_graph.sql +48 -0
  66. package/src/migrations/sql/0003_tools.sql +61 -0
  67. package/src/migrations/sql/0004_acl_indexes.sql +4 -0
  68. package/src/skills/context-engine/SKILL.md +160 -0
@@ -0,0 +1,174 @@
1
+ import { z } from 'zod';
2
+ import { R as RedactionPolicy, b as RedactionRuleInit } from './redaction-BmDSWJ7h.cjs';
3
+
4
+ declare const embeddingSchema: z.ZodObject<{
5
+ provider: z.ZodEnum<["openai", "azure_openai", "gemini", "voyage", "cohere", "custom"]>;
6
+ model: z.ZodString;
7
+ dim: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodNumber>>>;
8
+ apiKey: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
9
+ baseUrl: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "voyage" | "cohere";
12
+ model: string;
13
+ dim: number | null;
14
+ apiKey: string | null;
15
+ baseUrl: string | null;
16
+ }, {
17
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "voyage" | "cohere";
18
+ model: string;
19
+ dim?: number | null | undefined;
20
+ apiKey?: string | null | undefined;
21
+ baseUrl?: string | null | undefined;
22
+ }>;
23
+ declare const llmSchema: z.ZodObject<{
24
+ provider: z.ZodEnum<["anthropic", "openai", "azure_openai", "gemini", "bedrock", "custom"]>;
25
+ model: z.ZodString;
26
+ apiKey: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
27
+ baseUrl: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "anthropic" | "bedrock";
30
+ model: string;
31
+ apiKey: string | null;
32
+ baseUrl: string | null;
33
+ }, {
34
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "anthropic" | "bedrock";
35
+ model: string;
36
+ apiKey?: string | null | undefined;
37
+ baseUrl?: string | null | undefined;
38
+ }>;
39
+ declare const graphSchema: z.ZodObject<{
40
+ enabled: z.ZodDefault<z.ZodBoolean>;
41
+ neo4jUri: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
42
+ neo4jUser: z.ZodDefault<z.ZodString>;
43
+ neo4jPassword: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
44
+ neo4jDatabase: z.ZodDefault<z.ZodString>;
45
+ extractionLlm: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodObject<{
46
+ provider: z.ZodEnum<["anthropic", "openai", "azure_openai", "gemini", "bedrock", "custom"]>;
47
+ model: z.ZodString;
48
+ apiKey: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
49
+ baseUrl: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "anthropic" | "bedrock";
52
+ model: string;
53
+ apiKey: string | null;
54
+ baseUrl: string | null;
55
+ }, {
56
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "anthropic" | "bedrock";
57
+ model: string;
58
+ apiKey?: string | null | undefined;
59
+ baseUrl?: string | null | undefined;
60
+ }>>>>;
61
+ }, "strip", z.ZodTypeAny, {
62
+ enabled: boolean;
63
+ neo4jUri: string | null;
64
+ neo4jUser: string;
65
+ neo4jPassword: string | null;
66
+ neo4jDatabase: string;
67
+ extractionLlm: {
68
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "anthropic" | "bedrock";
69
+ model: string;
70
+ apiKey: string | null;
71
+ baseUrl: string | null;
72
+ } | null;
73
+ }, {
74
+ enabled?: boolean | undefined;
75
+ neo4jUri?: string | null | undefined;
76
+ neo4jUser?: string | undefined;
77
+ neo4jPassword?: string | null | undefined;
78
+ neo4jDatabase?: string | undefined;
79
+ extractionLlm?: {
80
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "anthropic" | "bedrock";
81
+ model: string;
82
+ apiKey?: string | null | undefined;
83
+ baseUrl?: string | null | undefined;
84
+ } | null | undefined;
85
+ }>;
86
+ declare const rerankerSchema: z.ZodObject<{
87
+ enabled: z.ZodDefault<z.ZodBoolean>;
88
+ provider: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodEnum<["cohere", "voyage", "jina", "custom"]>>>>;
89
+ model: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
90
+ apiKey: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
91
+ baseUrl: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
92
+ candidates: z.ZodDefault<z.ZodNumber>;
93
+ }, "strip", z.ZodTypeAny, {
94
+ provider: "custom" | "voyage" | "cohere" | "jina" | null;
95
+ model: string | null;
96
+ apiKey: string | null;
97
+ baseUrl: string | null;
98
+ enabled: boolean;
99
+ candidates: number;
100
+ }, {
101
+ provider?: "custom" | "voyage" | "cohere" | "jina" | null | undefined;
102
+ model?: string | null | undefined;
103
+ apiKey?: string | null | undefined;
104
+ baseUrl?: string | null | undefined;
105
+ enabled?: boolean | undefined;
106
+ candidates?: number | undefined;
107
+ }>;
108
+ declare const fusionSchema: z.ZodObject<{
109
+ method: z.ZodDefault<z.ZodLiteral<"rrf">>;
110
+ k: z.ZodDefault<z.ZodNumber>;
111
+ weights: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
112
+ }, "strip", z.ZodTypeAny, {
113
+ method: "rrf";
114
+ k: number;
115
+ weights: Record<string, number>;
116
+ }, {
117
+ method?: "rrf" | undefined;
118
+ k?: number | undefined;
119
+ weights?: Record<string, number> | undefined;
120
+ }>;
121
+ declare const storageSchema: z.ZodObject<{
122
+ backend: z.ZodDefault<z.ZodLiteral<"postgres">>;
123
+ annExactThreshold: z.ZodDefault<z.ZodNumber>;
124
+ }, "strip", z.ZodTypeAny, {
125
+ backend: "postgres";
126
+ annExactThreshold: number;
127
+ }, {
128
+ backend?: "postgres" | undefined;
129
+ annExactThreshold?: number | undefined;
130
+ }>;
131
+ type EmbeddingConfig = z.infer<typeof embeddingSchema>;
132
+ type LLMConfig = z.infer<typeof llmSchema>;
133
+ type GraphConfig = z.infer<typeof graphSchema>;
134
+ type RerankerConfig = z.infer<typeof rerankerSchema>;
135
+ type FusionConfig = z.infer<typeof fusionSchema>;
136
+ type StorageConfig = z.infer<typeof storageSchema>;
137
+ interface ContextEngineConfigInit {
138
+ databaseUrl: string;
139
+ storage?: Partial<StorageConfig>;
140
+ defaultMode?: "hybrid" | "graph";
141
+ embedding: EmbeddingConfig;
142
+ llm?: LLMConfig | null;
143
+ visionLlm?: LLMConfig | null;
144
+ graph?: Partial<GraphConfig>;
145
+ reranker?: Partial<RerankerConfig>;
146
+ fusion?: Partial<FusionConfig>;
147
+ enableCodeExecution?: boolean;
148
+ secretKey?: string | null;
149
+ redaction?: RedactionPolicy | {
150
+ rules?: RedactionRuleInit[];
151
+ customDetectors?: RedactionPolicy["customDetectors"];
152
+ };
153
+ }
154
+ declare class ContextEngineConfig {
155
+ databaseUrl: string;
156
+ storage: StorageConfig;
157
+ defaultMode: "hybrid" | "graph";
158
+ embedding: EmbeddingConfig;
159
+ llm: LLMConfig | null;
160
+ visionLlm: LLMConfig | null;
161
+ graph: GraphConfig;
162
+ reranker: RerankerConfig;
163
+ fusion: FusionConfig;
164
+ enableCodeExecution: boolean;
165
+ secretKey: string | null;
166
+ redaction: RedactionPolicy;
167
+ constructor(init: ContextEngineConfigInit);
168
+ private validate;
169
+ static fromEnv(overrides?: Partial<ContextEngineConfigInit> & {
170
+ embedding?: EmbeddingConfig;
171
+ }): ContextEngineConfig;
172
+ }
173
+
174
+ export { ContextEngineConfig as C, type EmbeddingConfig as E, type FusionConfig as F, type GraphConfig as G, type LLMConfig as L, type RerankerConfig as R, type StorageConfig as S, type ContextEngineConfigInit as a };
@@ -0,0 +1,174 @@
1
+ import { z } from 'zod';
2
+ import { R as RedactionPolicy, b as RedactionRuleInit } from './redaction-BmDSWJ7h.js';
3
+
4
+ declare const embeddingSchema: z.ZodObject<{
5
+ provider: z.ZodEnum<["openai", "azure_openai", "gemini", "voyage", "cohere", "custom"]>;
6
+ model: z.ZodString;
7
+ dim: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodNumber>>>;
8
+ apiKey: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
9
+ baseUrl: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "voyage" | "cohere";
12
+ model: string;
13
+ dim: number | null;
14
+ apiKey: string | null;
15
+ baseUrl: string | null;
16
+ }, {
17
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "voyage" | "cohere";
18
+ model: string;
19
+ dim?: number | null | undefined;
20
+ apiKey?: string | null | undefined;
21
+ baseUrl?: string | null | undefined;
22
+ }>;
23
+ declare const llmSchema: z.ZodObject<{
24
+ provider: z.ZodEnum<["anthropic", "openai", "azure_openai", "gemini", "bedrock", "custom"]>;
25
+ model: z.ZodString;
26
+ apiKey: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
27
+ baseUrl: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "anthropic" | "bedrock";
30
+ model: string;
31
+ apiKey: string | null;
32
+ baseUrl: string | null;
33
+ }, {
34
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "anthropic" | "bedrock";
35
+ model: string;
36
+ apiKey?: string | null | undefined;
37
+ baseUrl?: string | null | undefined;
38
+ }>;
39
+ declare const graphSchema: z.ZodObject<{
40
+ enabled: z.ZodDefault<z.ZodBoolean>;
41
+ neo4jUri: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
42
+ neo4jUser: z.ZodDefault<z.ZodString>;
43
+ neo4jPassword: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
44
+ neo4jDatabase: z.ZodDefault<z.ZodString>;
45
+ extractionLlm: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodObject<{
46
+ provider: z.ZodEnum<["anthropic", "openai", "azure_openai", "gemini", "bedrock", "custom"]>;
47
+ model: z.ZodString;
48
+ apiKey: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
49
+ baseUrl: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "anthropic" | "bedrock";
52
+ model: string;
53
+ apiKey: string | null;
54
+ baseUrl: string | null;
55
+ }, {
56
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "anthropic" | "bedrock";
57
+ model: string;
58
+ apiKey?: string | null | undefined;
59
+ baseUrl?: string | null | undefined;
60
+ }>>>>;
61
+ }, "strip", z.ZodTypeAny, {
62
+ enabled: boolean;
63
+ neo4jUri: string | null;
64
+ neo4jUser: string;
65
+ neo4jPassword: string | null;
66
+ neo4jDatabase: string;
67
+ extractionLlm: {
68
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "anthropic" | "bedrock";
69
+ model: string;
70
+ apiKey: string | null;
71
+ baseUrl: string | null;
72
+ } | null;
73
+ }, {
74
+ enabled?: boolean | undefined;
75
+ neo4jUri?: string | null | undefined;
76
+ neo4jUser?: string | undefined;
77
+ neo4jPassword?: string | null | undefined;
78
+ neo4jDatabase?: string | undefined;
79
+ extractionLlm?: {
80
+ provider: "custom" | "openai" | "azure_openai" | "gemini" | "anthropic" | "bedrock";
81
+ model: string;
82
+ apiKey?: string | null | undefined;
83
+ baseUrl?: string | null | undefined;
84
+ } | null | undefined;
85
+ }>;
86
+ declare const rerankerSchema: z.ZodObject<{
87
+ enabled: z.ZodDefault<z.ZodBoolean>;
88
+ provider: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodEnum<["cohere", "voyage", "jina", "custom"]>>>>;
89
+ model: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
90
+ apiKey: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
91
+ baseUrl: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
92
+ candidates: z.ZodDefault<z.ZodNumber>;
93
+ }, "strip", z.ZodTypeAny, {
94
+ provider: "custom" | "voyage" | "cohere" | "jina" | null;
95
+ model: string | null;
96
+ apiKey: string | null;
97
+ baseUrl: string | null;
98
+ enabled: boolean;
99
+ candidates: number;
100
+ }, {
101
+ provider?: "custom" | "voyage" | "cohere" | "jina" | null | undefined;
102
+ model?: string | null | undefined;
103
+ apiKey?: string | null | undefined;
104
+ baseUrl?: string | null | undefined;
105
+ enabled?: boolean | undefined;
106
+ candidates?: number | undefined;
107
+ }>;
108
+ declare const fusionSchema: z.ZodObject<{
109
+ method: z.ZodDefault<z.ZodLiteral<"rrf">>;
110
+ k: z.ZodDefault<z.ZodNumber>;
111
+ weights: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
112
+ }, "strip", z.ZodTypeAny, {
113
+ method: "rrf";
114
+ k: number;
115
+ weights: Record<string, number>;
116
+ }, {
117
+ method?: "rrf" | undefined;
118
+ k?: number | undefined;
119
+ weights?: Record<string, number> | undefined;
120
+ }>;
121
+ declare const storageSchema: z.ZodObject<{
122
+ backend: z.ZodDefault<z.ZodLiteral<"postgres">>;
123
+ annExactThreshold: z.ZodDefault<z.ZodNumber>;
124
+ }, "strip", z.ZodTypeAny, {
125
+ backend: "postgres";
126
+ annExactThreshold: number;
127
+ }, {
128
+ backend?: "postgres" | undefined;
129
+ annExactThreshold?: number | undefined;
130
+ }>;
131
+ type EmbeddingConfig = z.infer<typeof embeddingSchema>;
132
+ type LLMConfig = z.infer<typeof llmSchema>;
133
+ type GraphConfig = z.infer<typeof graphSchema>;
134
+ type RerankerConfig = z.infer<typeof rerankerSchema>;
135
+ type FusionConfig = z.infer<typeof fusionSchema>;
136
+ type StorageConfig = z.infer<typeof storageSchema>;
137
+ interface ContextEngineConfigInit {
138
+ databaseUrl: string;
139
+ storage?: Partial<StorageConfig>;
140
+ defaultMode?: "hybrid" | "graph";
141
+ embedding: EmbeddingConfig;
142
+ llm?: LLMConfig | null;
143
+ visionLlm?: LLMConfig | null;
144
+ graph?: Partial<GraphConfig>;
145
+ reranker?: Partial<RerankerConfig>;
146
+ fusion?: Partial<FusionConfig>;
147
+ enableCodeExecution?: boolean;
148
+ secretKey?: string | null;
149
+ redaction?: RedactionPolicy | {
150
+ rules?: RedactionRuleInit[];
151
+ customDetectors?: RedactionPolicy["customDetectors"];
152
+ };
153
+ }
154
+ declare class ContextEngineConfig {
155
+ databaseUrl: string;
156
+ storage: StorageConfig;
157
+ defaultMode: "hybrid" | "graph";
158
+ embedding: EmbeddingConfig;
159
+ llm: LLMConfig | null;
160
+ visionLlm: LLMConfig | null;
161
+ graph: GraphConfig;
162
+ reranker: RerankerConfig;
163
+ fusion: FusionConfig;
164
+ enableCodeExecution: boolean;
165
+ secretKey: string | null;
166
+ redaction: RedactionPolicy;
167
+ constructor(init: ContextEngineConfigInit);
168
+ private validate;
169
+ static fromEnv(overrides?: Partial<ContextEngineConfigInit> & {
170
+ embedding?: EmbeddingConfig;
171
+ }): ContextEngineConfig;
172
+ }
173
+
174
+ export { ContextEngineConfig as C, type EmbeddingConfig as E, type FusionConfig as F, type GraphConfig as G, type LLMConfig as L, type RerankerConfig as R, type StorageConfig as S, type ContextEngineConfigInit as a };
@@ -0,0 +1,67 @@
1
+ import { E as EmbeddingConfig } from './config-Bl9U789m.cjs';
2
+
3
+ /**
4
+ * Pluggable embeddings provider.
5
+ *
6
+ * openai / azure_openai / custom → OpenAI SDK (OpenAI-compatible, including TEI/vLLM).
7
+ * gemini → lazy `@google/genai` (optional extra "gemini").
8
+ * voyage / cohere → fetch against their public REST APIs.
9
+ *
10
+ * `kind` is accepted everywhere but only voyage/cohere act on it.
11
+ * 30s timeout, no retries. Injectable `client` / `fetch` for tests.
12
+ */
13
+
14
+ type EmbedKind = "document" | "query";
15
+ type FetchImpl = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
16
+ type EmbeddingsClient = {
17
+ embeddings: {
18
+ create(body: {
19
+ model: string;
20
+ input: string[];
21
+ }): Promise<{
22
+ data: Array<{
23
+ embedding: number[];
24
+ }>;
25
+ usage?: {
26
+ total_tokens?: number;
27
+ } | null;
28
+ }>;
29
+ };
30
+ close?: () => void | Promise<void>;
31
+ timeout?: number;
32
+ baseURL?: string;
33
+ };
34
+ type EmbedderOpts = {
35
+ client?: EmbeddingsClient | null;
36
+ fetch?: FetchImpl | null;
37
+ fetchImpl?: FetchImpl | null;
38
+ };
39
+ declare class Embedder {
40
+ cfg: EmbeddingConfig;
41
+ provider: EmbeddingConfig["provider"];
42
+ model: string;
43
+ dim: number | null;
44
+ client: EmbeddingsClient | null;
45
+ fetchImpl: FetchImpl | null;
46
+ private genaiClient;
47
+ constructor(cfg: EmbeddingConfig, opts?: EmbedderOpts);
48
+ aclose(): Promise<void>;
49
+ [Symbol.asyncDispose](): Promise<void>;
50
+ /**
51
+ * Embed `texts`, returning `[vectors, tokenCount]`.
52
+ * Auto-detects `this.dim` on first success; raises on mismatch.
53
+ */
54
+ embed(texts: string[], opts?: {
55
+ kind?: EmbedKind;
56
+ }): Promise<[number[][], number]>;
57
+ /** Provider dispatch. Overridable per-instance (tests stub this). */
58
+ rawEmbed(texts: string[], kind?: EmbedKind): Promise<[number[][], number]>;
59
+ private embedOpenAI;
60
+ private embedGemini;
61
+ private embedVoyage;
62
+ private embedCohere;
63
+ private requireFetch;
64
+ }
65
+ declare function buildEmbedder(cfg: EmbeddingConfig, opts?: EmbedderOpts): Embedder;
66
+
67
+ export { Embedder as E, type FetchImpl as F, type EmbedKind as a, buildEmbedder as b };
@@ -0,0 +1,67 @@
1
+ import { E as EmbeddingConfig } from './config-Bt9bUQqU.js';
2
+
3
+ /**
4
+ * Pluggable embeddings provider.
5
+ *
6
+ * openai / azure_openai / custom → OpenAI SDK (OpenAI-compatible, including TEI/vLLM).
7
+ * gemini → lazy `@google/genai` (optional extra "gemini").
8
+ * voyage / cohere → fetch against their public REST APIs.
9
+ *
10
+ * `kind` is accepted everywhere but only voyage/cohere act on it.
11
+ * 30s timeout, no retries. Injectable `client` / `fetch` for tests.
12
+ */
13
+
14
+ type EmbedKind = "document" | "query";
15
+ type FetchImpl = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
16
+ type EmbeddingsClient = {
17
+ embeddings: {
18
+ create(body: {
19
+ model: string;
20
+ input: string[];
21
+ }): Promise<{
22
+ data: Array<{
23
+ embedding: number[];
24
+ }>;
25
+ usage?: {
26
+ total_tokens?: number;
27
+ } | null;
28
+ }>;
29
+ };
30
+ close?: () => void | Promise<void>;
31
+ timeout?: number;
32
+ baseURL?: string;
33
+ };
34
+ type EmbedderOpts = {
35
+ client?: EmbeddingsClient | null;
36
+ fetch?: FetchImpl | null;
37
+ fetchImpl?: FetchImpl | null;
38
+ };
39
+ declare class Embedder {
40
+ cfg: EmbeddingConfig;
41
+ provider: EmbeddingConfig["provider"];
42
+ model: string;
43
+ dim: number | null;
44
+ client: EmbeddingsClient | null;
45
+ fetchImpl: FetchImpl | null;
46
+ private genaiClient;
47
+ constructor(cfg: EmbeddingConfig, opts?: EmbedderOpts);
48
+ aclose(): Promise<void>;
49
+ [Symbol.asyncDispose](): Promise<void>;
50
+ /**
51
+ * Embed `texts`, returning `[vectors, tokenCount]`.
52
+ * Auto-detects `this.dim` on first success; raises on mismatch.
53
+ */
54
+ embed(texts: string[], opts?: {
55
+ kind?: EmbedKind;
56
+ }): Promise<[number[][], number]>;
57
+ /** Provider dispatch. Overridable per-instance (tests stub this). */
58
+ rawEmbed(texts: string[], kind?: EmbedKind): Promise<[number[][], number]>;
59
+ private embedOpenAI;
60
+ private embedGemini;
61
+ private embedVoyage;
62
+ private embedCohere;
63
+ private requireFetch;
64
+ }
65
+ declare function buildEmbedder(cfg: EmbeddingConfig, opts?: EmbedderOpts): Embedder;
66
+
67
+ export { Embedder as E, type FetchImpl as F, type EmbedKind as a, buildEmbedder as b };