@promptev/context-engine 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/cli.js +142 -58
- package/dist/cli.js.map +1 -1
- package/dist/{config-CdlSkKgV.d.ts → config-BODDdXJ7.d.ts} +33 -11
- package/dist/{config-CNnASw5X.d.cts → config-C5RZ00W6.d.cts} +33 -11
- package/dist/express.d.cts +3 -3
- package/dist/express.d.ts +3 -3
- package/dist/fastify.d.cts +3 -3
- package/dist/fastify.d.ts +3 -3
- package/dist/{governance-XFVgtEdV.d.ts → governance-BLPK7NMe.d.ts} +1 -1
- package/dist/{governance-D8g6Wyvb.d.cts → governance-P9pRb4Ol.d.cts} +1 -1
- package/dist/graph/index.cjs +51 -18
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +2 -2
- package/dist/graph/index.d.ts +2 -2
- package/dist/graph/index.js +51 -18
- package/dist/graph/index.js.map +1 -1
- package/dist/hono.d.cts +3 -3
- package/dist/hono.d.ts +3 -3
- package/dist/index.cjs +142 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -7
- package/dist/index.d.ts +62 -7
- package/dist/index.js +142 -58
- package/dist/index.js.map +1 -1
- package/dist/{router-Dsv3fv0R.d.cts → router-CiFwC-EN.d.cts} +1 -1
- package/dist/{router-B_DTkQgU.d.ts → router-D8gBzwLd.d.ts} +1 -1
- package/dist/skills/context-engine/SKILL.md +5 -1
- package/dist/{storage-DU1JRno5.d.cts → storage-CJrKgJeJ.d.ts} +5 -2
- package/dist/{storage-Dvt2ZxsV.d.ts → storage-Dvpq2xAC.d.cts} +5 -2
- package/package.json +1 -1
- package/src/skills/context-engine/SKILL.md +5 -1
package/dist/graph/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Pool } from 'pg';
|
|
2
|
-
import { G as GraphConfig, C as ContextEngineConfig } from '../config-
|
|
2
|
+
import { G as GraphConfig, C as ContextEngineConfig } from '../config-C5RZ00W6.cjs';
|
|
3
3
|
import { H as Hooks } from '../redaction-BqD_DEUQ.cjs';
|
|
4
|
-
import { E as Embedder, A as AnnTunable } from '../storage-
|
|
4
|
+
import { E as Embedder, A as AnnTunable } from '../storage-Dvpq2xAC.cjs';
|
|
5
5
|
import 'zod';
|
|
6
6
|
|
|
7
7
|
type Neo4jDriver = {
|
package/dist/graph/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Pool } from 'pg';
|
|
2
|
-
import { G as GraphConfig, C as ContextEngineConfig } from '../config-
|
|
2
|
+
import { G as GraphConfig, C as ContextEngineConfig } from '../config-BODDdXJ7.js';
|
|
3
3
|
import { H as Hooks } from '../redaction-BqD_DEUQ.js';
|
|
4
|
-
import { E as Embedder, A as AnnTunable } from '../storage-
|
|
4
|
+
import { E as Embedder, A as AnnTunable } from '../storage-CJrKgJeJ.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
|
|
7
7
|
type Neo4jDriver = {
|
package/dist/graph/index.js
CHANGED
|
@@ -59,6 +59,47 @@ var init_hooks = __esm({
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
+
// src/providers/google.ts
|
|
63
|
+
async function buildGenaiClient(cfg, timeoutMs, purpose) {
|
|
64
|
+
const specifier = "@google/genai";
|
|
65
|
+
let mod;
|
|
66
|
+
try {
|
|
67
|
+
mod = await import(specifier);
|
|
68
|
+
} catch {
|
|
69
|
+
throw new ExtraMissingError("gemini", specifier, purpose);
|
|
70
|
+
}
|
|
71
|
+
const Ctor = mod.GoogleGenAI ?? mod.Client;
|
|
72
|
+
if (!Ctor) {
|
|
73
|
+
throw new ExtraMissingError("gemini", specifier, purpose);
|
|
74
|
+
}
|
|
75
|
+
const opts = { httpOptions: { timeout: timeoutMs } };
|
|
76
|
+
if (cfg.provider === "vertex_ai") {
|
|
77
|
+
opts.vertexai = true;
|
|
78
|
+
if (cfg.project || cfg.location) {
|
|
79
|
+
if (cfg.project) opts.project = cfg.project;
|
|
80
|
+
if (cfg.location) opts.location = cfg.location;
|
|
81
|
+
} else if (cfg.apiKey) {
|
|
82
|
+
opts.apiKey = cfg.apiKey;
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
opts.apiKey = cfg.apiKey ?? null;
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
return new Ctor(opts);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
91
|
+
if (!message.includes("Authentication is not set up")) throw err;
|
|
92
|
+
throw new Error(
|
|
93
|
+
`${message} Set \`project\` on the provider config, or export GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION. Credentials themselves come from Application Default Credentials.`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
var init_google = __esm({
|
|
98
|
+
"src/providers/google.ts"() {
|
|
99
|
+
init_errors();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
62
103
|
// src/providers/llm.ts
|
|
63
104
|
var llm_exports = {};
|
|
64
105
|
__export(llm_exports, {
|
|
@@ -94,20 +135,6 @@ function buildOpenAIChatClient(cfg) {
|
|
|
94
135
|
maxRetries: 0
|
|
95
136
|
});
|
|
96
137
|
}
|
|
97
|
-
async function loadGeminiChatClient(apiKey) {
|
|
98
|
-
const specifier = "@google/genai";
|
|
99
|
-
let mod;
|
|
100
|
-
try {
|
|
101
|
-
mod = await import(specifier);
|
|
102
|
-
} catch {
|
|
103
|
-
throw new ExtraMissingError("gemini", specifier, "gemini llm");
|
|
104
|
-
}
|
|
105
|
-
const Ctor = mod.GoogleGenAI ?? mod.Client;
|
|
106
|
-
if (!Ctor) {
|
|
107
|
-
throw new ExtraMissingError("gemini", specifier, "gemini llm");
|
|
108
|
-
}
|
|
109
|
-
return new Ctor({ apiKey: apiKey ?? null, httpOptions: { timeout: GEMINI_CALL_TIMEOUT_MS } });
|
|
110
|
-
}
|
|
111
138
|
async function loadBedrockSdk() {
|
|
112
139
|
const specifier = "@aws-sdk/client-bedrock-runtime";
|
|
113
140
|
try {
|
|
@@ -126,7 +153,7 @@ function buildLlmClient(cfg, opts) {
|
|
|
126
153
|
if (OPENAI_FAMILY.has(cfg.provider)) {
|
|
127
154
|
return new LLMClient(cfg, { client: buildOpenAIChatClient(cfg) });
|
|
128
155
|
}
|
|
129
|
-
if (cfg.provider
|
|
156
|
+
if (GOOGLE_FAMILY.has(cfg.provider) || cfg.provider === "bedrock") {
|
|
130
157
|
return new LLMClient(cfg);
|
|
131
158
|
}
|
|
132
159
|
throw new Error(`unknown llm provider: ${JSON.stringify(cfg.provider)}`);
|
|
@@ -143,16 +170,18 @@ async function callLlm(cfg, opts) {
|
|
|
143
170
|
await owned.aclose();
|
|
144
171
|
}
|
|
145
172
|
}
|
|
146
|
-
var CALL_TIMEOUT_MS, TIMEOUT_MS, GEMINI_CALL_TIMEOUT_MS, ANTHROPIC_VERSION, ANTHROPIC_MAX_TOKENS, OPENAI_FAMILY, LLMClient;
|
|
173
|
+
var CALL_TIMEOUT_MS, TIMEOUT_MS, GEMINI_CALL_TIMEOUT_MS, ANTHROPIC_VERSION, ANTHROPIC_MAX_TOKENS, OPENAI_FAMILY, GOOGLE_FAMILY, LLMClient;
|
|
147
174
|
var init_llm = __esm({
|
|
148
175
|
"src/providers/llm.ts"() {
|
|
149
176
|
init_errors();
|
|
177
|
+
init_google();
|
|
150
178
|
CALL_TIMEOUT_MS = 24e4;
|
|
151
179
|
TIMEOUT_MS = CALL_TIMEOUT_MS;
|
|
152
180
|
GEMINI_CALL_TIMEOUT_MS = CALL_TIMEOUT_MS;
|
|
153
181
|
ANTHROPIC_VERSION = "2023-06-01";
|
|
154
182
|
ANTHROPIC_MAX_TOKENS = 4096;
|
|
155
183
|
OPENAI_FAMILY = /* @__PURE__ */ new Set(["openai", "azure_openai", "custom"]);
|
|
184
|
+
GOOGLE_FAMILY = /* @__PURE__ */ new Set(["gemini", "vertex_ai"]);
|
|
156
185
|
LLMClient = class {
|
|
157
186
|
cfg;
|
|
158
187
|
provider;
|
|
@@ -192,7 +221,7 @@ var init_llm = __esm({
|
|
|
192
221
|
if (OPENAI_FAMILY.has(this.provider)) {
|
|
193
222
|
return this.callOpenAI(system, user, jsonMode, images, maxTokens, temperature);
|
|
194
223
|
}
|
|
195
|
-
if (this.provider
|
|
224
|
+
if (GOOGLE_FAMILY.has(this.provider)) {
|
|
196
225
|
return this.callGemini(system, user, jsonMode, images, maxTokens, thinkingBudget, temperature);
|
|
197
226
|
}
|
|
198
227
|
if (this.provider === "bedrock") {
|
|
@@ -275,7 +304,11 @@ Respond with valid JSON only.`;
|
|
|
275
304
|
}
|
|
276
305
|
async callGemini(system, user, jsonMode, images, maxTokens, thinkingBudget = null, temperature = null) {
|
|
277
306
|
if (!this.genaiClient) {
|
|
278
|
-
this.genaiClient = await
|
|
307
|
+
this.genaiClient = await buildGenaiClient(
|
|
308
|
+
this.cfg,
|
|
309
|
+
GEMINI_CALL_TIMEOUT_MS,
|
|
310
|
+
"gemini llm"
|
|
311
|
+
);
|
|
279
312
|
}
|
|
280
313
|
const parts = [];
|
|
281
314
|
for (const img of images ?? []) {
|