@promptev/context-engine 0.0.1 → 0.0.3
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 +80 -0
- package/dist/cli.js +11990 -10954
- 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.cjs.map +1 -1
- package/dist/express.d.cts +3 -3
- package/dist/express.d.ts +3 -3
- package/dist/express.js.map +1 -1
- package/dist/fastify.cjs.map +1 -1
- package/dist/fastify.d.cts +3 -3
- package/dist/fastify.d.ts +3 -3
- package/dist/fastify.js.map +1 -1
- 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 +57 -23
- 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 +57 -23
- package/dist/graph/index.js.map +1 -1
- package/dist/hono.cjs.map +1 -1
- package/dist/hono.d.cts +3 -3
- package/dist/hono.d.ts +3 -3
- package/dist/hono.js.map +1 -1
- package/dist/index.cjs +7559 -6464
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +154 -32
- package/dist/index.d.ts +154 -32
- package/dist/index.js +7543 -6450
- package/dist/index.js.map +1 -1
- package/dist/mcp-BKSmxayM.d.cts +204 -0
- package/dist/mcp-BKSmxayM.d.ts +204 -0
- package/dist/mcp.cjs +896 -70
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.d.cts +2 -31
- package/dist/mcp.d.ts +2 -31
- package/dist/mcp.js +896 -70
- package/dist/mcp.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 +35 -3
- 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 +35 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Pool } from 'pg';
|
|
2
|
-
import { C as ContextEngineConfig } from './config-
|
|
2
|
+
import { C as ContextEngineConfig } from './config-BODDdXJ7.js';
|
|
3
3
|
import { H as Hooks } from './redaction-BqD_DEUQ.js';
|
|
4
4
|
|
|
5
5
|
type ToolKind = "http" | "db" | "mcp" | "function";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Pool } from 'pg';
|
|
2
|
-
import { C as ContextEngineConfig } from './config-
|
|
2
|
+
import { C as ContextEngineConfig } from './config-C5RZ00W6.cjs';
|
|
3
3
|
import { H as Hooks } from './redaction-BqD_DEUQ.cjs';
|
|
4
4
|
|
|
5
5
|
type ToolKind = "http" | "db" | "mcp" | "function";
|
package/dist/graph/index.cjs
CHANGED
|
@@ -65,6 +65,47 @@ var init_hooks = __esm({
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
+
// src/providers/google.ts
|
|
69
|
+
async function buildGenaiClient(cfg, timeoutMs, purpose) {
|
|
70
|
+
const specifier = "@google/genai";
|
|
71
|
+
let mod;
|
|
72
|
+
try {
|
|
73
|
+
mod = await import(specifier);
|
|
74
|
+
} catch {
|
|
75
|
+
throw new ExtraMissingError("gemini", specifier, purpose);
|
|
76
|
+
}
|
|
77
|
+
const Ctor = mod.GoogleGenAI ?? mod.Client;
|
|
78
|
+
if (!Ctor) {
|
|
79
|
+
throw new ExtraMissingError("gemini", specifier, purpose);
|
|
80
|
+
}
|
|
81
|
+
const opts = { httpOptions: { timeout: timeoutMs } };
|
|
82
|
+
if (cfg.provider === "vertex_ai") {
|
|
83
|
+
opts.vertexai = true;
|
|
84
|
+
if (cfg.project || cfg.location) {
|
|
85
|
+
if (cfg.project) opts.project = cfg.project;
|
|
86
|
+
if (cfg.location) opts.location = cfg.location;
|
|
87
|
+
} else if (cfg.apiKey) {
|
|
88
|
+
opts.apiKey = cfg.apiKey;
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
opts.apiKey = cfg.apiKey ?? null;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
return new Ctor(opts);
|
|
95
|
+
} catch (err) {
|
|
96
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
97
|
+
if (!message.includes("Authentication is not set up")) throw err;
|
|
98
|
+
throw new Error(
|
|
99
|
+
`${message} Set \`project\` on the provider config, or export GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION. Credentials themselves come from Application Default Credentials.`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
var init_google = __esm({
|
|
104
|
+
"src/providers/google.ts"() {
|
|
105
|
+
init_errors();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
68
109
|
// src/providers/llm.ts
|
|
69
110
|
var llm_exports = {};
|
|
70
111
|
__export(llm_exports, {
|
|
@@ -100,20 +141,6 @@ function buildOpenAIChatClient(cfg) {
|
|
|
100
141
|
maxRetries: 0
|
|
101
142
|
});
|
|
102
143
|
}
|
|
103
|
-
async function loadGeminiChatClient(apiKey) {
|
|
104
|
-
const specifier = "@google/genai";
|
|
105
|
-
let mod;
|
|
106
|
-
try {
|
|
107
|
-
mod = await import(specifier);
|
|
108
|
-
} catch {
|
|
109
|
-
throw new ExtraMissingError("gemini", specifier, "gemini llm");
|
|
110
|
-
}
|
|
111
|
-
const Ctor = mod.GoogleGenAI ?? mod.Client;
|
|
112
|
-
if (!Ctor) {
|
|
113
|
-
throw new ExtraMissingError("gemini", specifier, "gemini llm");
|
|
114
|
-
}
|
|
115
|
-
return new Ctor({ apiKey: apiKey ?? null, httpOptions: { timeout: GEMINI_CALL_TIMEOUT_MS } });
|
|
116
|
-
}
|
|
117
144
|
async function loadBedrockSdk() {
|
|
118
145
|
const specifier = "@aws-sdk/client-bedrock-runtime";
|
|
119
146
|
try {
|
|
@@ -132,7 +159,7 @@ function buildLlmClient(cfg, opts) {
|
|
|
132
159
|
if (OPENAI_FAMILY.has(cfg.provider)) {
|
|
133
160
|
return new LLMClient(cfg, { client: buildOpenAIChatClient(cfg) });
|
|
134
161
|
}
|
|
135
|
-
if (cfg.provider
|
|
162
|
+
if (GOOGLE_FAMILY.has(cfg.provider) || cfg.provider === "bedrock") {
|
|
136
163
|
return new LLMClient(cfg);
|
|
137
164
|
}
|
|
138
165
|
throw new Error(`unknown llm provider: ${JSON.stringify(cfg.provider)}`);
|
|
@@ -149,16 +176,18 @@ async function callLlm(cfg, opts) {
|
|
|
149
176
|
await owned.aclose();
|
|
150
177
|
}
|
|
151
178
|
}
|
|
152
|
-
var CALL_TIMEOUT_MS, TIMEOUT_MS, GEMINI_CALL_TIMEOUT_MS, ANTHROPIC_VERSION, ANTHROPIC_MAX_TOKENS, OPENAI_FAMILY, LLMClient;
|
|
179
|
+
var CALL_TIMEOUT_MS, TIMEOUT_MS, GEMINI_CALL_TIMEOUT_MS, ANTHROPIC_VERSION, ANTHROPIC_MAX_TOKENS, OPENAI_FAMILY, GOOGLE_FAMILY, LLMClient;
|
|
153
180
|
var init_llm = __esm({
|
|
154
181
|
"src/providers/llm.ts"() {
|
|
155
182
|
init_errors();
|
|
183
|
+
init_google();
|
|
156
184
|
CALL_TIMEOUT_MS = 24e4;
|
|
157
185
|
TIMEOUT_MS = CALL_TIMEOUT_MS;
|
|
158
186
|
GEMINI_CALL_TIMEOUT_MS = CALL_TIMEOUT_MS;
|
|
159
187
|
ANTHROPIC_VERSION = "2023-06-01";
|
|
160
188
|
ANTHROPIC_MAX_TOKENS = 4096;
|
|
161
189
|
OPENAI_FAMILY = /* @__PURE__ */ new Set(["openai", "azure_openai", "custom"]);
|
|
190
|
+
GOOGLE_FAMILY = /* @__PURE__ */ new Set(["gemini", "vertex_ai"]);
|
|
162
191
|
LLMClient = class {
|
|
163
192
|
cfg;
|
|
164
193
|
provider;
|
|
@@ -198,7 +227,7 @@ var init_llm = __esm({
|
|
|
198
227
|
if (OPENAI_FAMILY.has(this.provider)) {
|
|
199
228
|
return this.callOpenAI(system, user, jsonMode, images, maxTokens, temperature);
|
|
200
229
|
}
|
|
201
|
-
if (this.provider
|
|
230
|
+
if (GOOGLE_FAMILY.has(this.provider)) {
|
|
202
231
|
return this.callGemini(system, user, jsonMode, images, maxTokens, thinkingBudget, temperature);
|
|
203
232
|
}
|
|
204
233
|
if (this.provider === "bedrock") {
|
|
@@ -281,7 +310,11 @@ Respond with valid JSON only.`;
|
|
|
281
310
|
}
|
|
282
311
|
async callGemini(system, user, jsonMode, images, maxTokens, thinkingBudget = null, temperature = null) {
|
|
283
312
|
if (!this.genaiClient) {
|
|
284
|
-
this.genaiClient = await
|
|
313
|
+
this.genaiClient = await buildGenaiClient(
|
|
314
|
+
this.cfg,
|
|
315
|
+
GEMINI_CALL_TIMEOUT_MS,
|
|
316
|
+
"gemini llm"
|
|
317
|
+
);
|
|
285
318
|
}
|
|
286
319
|
const parts = [];
|
|
287
320
|
for (const img of images ?? []) {
|
|
@@ -592,9 +625,9 @@ function buildPrompt(fullText) {
|
|
|
592
625
|
DOCUMENT TEXT:
|
|
593
626
|
${fullText}
|
|
594
627
|
|
|
595
|
-
ENTITY TYPES:
|
|
628
|
+
ENTITY TYPES: ${exports.ENTITY_TYPES.join(", ")}
|
|
596
629
|
|
|
597
|
-
RELATIONSHIP CATEGORIES:
|
|
630
|
+
RELATIONSHIP CATEGORIES: ${RELATIONSHIP_CATEGORY_VALUES.join(", ")}
|
|
598
631
|
|
|
599
632
|
OUTPUT FORMAT (STRICT JSON):
|
|
600
633
|
{
|
|
@@ -873,7 +906,7 @@ async function extractEntitiesForDocument(documentId, opts) {
|
|
|
873
906
|
if (opts.graphStore) await syncToNeo4j(opts.pool, documentId, chunkSnaps, opts.graphStore);
|
|
874
907
|
return stats;
|
|
875
908
|
}
|
|
876
|
-
exports.ENTITY_TYPES = void 0; var RELATIONSHIP_CATEGORIES; exports.CHUNKS_PER_BATCH = void 0; var EXTRACTION_SYSTEM;
|
|
909
|
+
exports.ENTITY_TYPES = void 0; var RELATIONSHIP_CATEGORY_VALUES, RELATIONSHIP_CATEGORIES; exports.CHUNKS_PER_BATCH = void 0; var EXTRACTION_SYSTEM;
|
|
877
910
|
var init_entities = __esm({
|
|
878
911
|
"src/graph/entities.ts"() {
|
|
879
912
|
exports.ENTITY_TYPES = [
|
|
@@ -885,7 +918,7 @@ var init_entities = __esm({
|
|
|
885
918
|
"TEMPORAL",
|
|
886
919
|
"CONCEPT"
|
|
887
920
|
];
|
|
888
|
-
|
|
921
|
+
RELATIONSHIP_CATEGORY_VALUES = [
|
|
889
922
|
"HIERARCHICAL",
|
|
890
923
|
"MEMBERSHIP",
|
|
891
924
|
"CREATION",
|
|
@@ -894,7 +927,8 @@ var init_entities = __esm({
|
|
|
894
927
|
"REFERENCE",
|
|
895
928
|
"FUNCTIONAL",
|
|
896
929
|
"QUANTITATIVE"
|
|
897
|
-
]
|
|
930
|
+
];
|
|
931
|
+
RELATIONSHIP_CATEGORIES = new Set(RELATIONSHIP_CATEGORY_VALUES);
|
|
898
932
|
exports.CHUNKS_PER_BATCH = 11;
|
|
899
933
|
EXTRACTION_SYSTEM = "You are a STRICT JSON entity and relationship extraction engine.";
|
|
900
934
|
}
|