@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.
Files changed (46) hide show
  1. package/README.md +80 -0
  2. package/dist/cli.js +11990 -10954
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{config-CdlSkKgV.d.ts → config-BODDdXJ7.d.ts} +33 -11
  5. package/dist/{config-CNnASw5X.d.cts → config-C5RZ00W6.d.cts} +33 -11
  6. package/dist/express.cjs.map +1 -1
  7. package/dist/express.d.cts +3 -3
  8. package/dist/express.d.ts +3 -3
  9. package/dist/express.js.map +1 -1
  10. package/dist/fastify.cjs.map +1 -1
  11. package/dist/fastify.d.cts +3 -3
  12. package/dist/fastify.d.ts +3 -3
  13. package/dist/fastify.js.map +1 -1
  14. package/dist/{governance-XFVgtEdV.d.ts → governance-BLPK7NMe.d.ts} +1 -1
  15. package/dist/{governance-D8g6Wyvb.d.cts → governance-P9pRb4Ol.d.cts} +1 -1
  16. package/dist/graph/index.cjs +57 -23
  17. package/dist/graph/index.cjs.map +1 -1
  18. package/dist/graph/index.d.cts +2 -2
  19. package/dist/graph/index.d.ts +2 -2
  20. package/dist/graph/index.js +57 -23
  21. package/dist/graph/index.js.map +1 -1
  22. package/dist/hono.cjs.map +1 -1
  23. package/dist/hono.d.cts +3 -3
  24. package/dist/hono.d.ts +3 -3
  25. package/dist/hono.js.map +1 -1
  26. package/dist/index.cjs +7559 -6464
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +154 -32
  29. package/dist/index.d.ts +154 -32
  30. package/dist/index.js +7543 -6450
  31. package/dist/index.js.map +1 -1
  32. package/dist/mcp-BKSmxayM.d.cts +204 -0
  33. package/dist/mcp-BKSmxayM.d.ts +204 -0
  34. package/dist/mcp.cjs +896 -70
  35. package/dist/mcp.cjs.map +1 -1
  36. package/dist/mcp.d.cts +2 -31
  37. package/dist/mcp.d.ts +2 -31
  38. package/dist/mcp.js +896 -70
  39. package/dist/mcp.js.map +1 -1
  40. package/dist/{router-Dsv3fv0R.d.cts → router-CiFwC-EN.d.cts} +1 -1
  41. package/dist/{router-B_DTkQgU.d.ts → router-D8gBzwLd.d.ts} +1 -1
  42. package/dist/skills/context-engine/SKILL.md +35 -3
  43. package/dist/{storage-DU1JRno5.d.cts → storage-CJrKgJeJ.d.ts} +5 -2
  44. package/dist/{storage-Dvt2ZxsV.d.ts → storage-Dvpq2xAC.d.cts} +5 -2
  45. package/package.json +1 -1
  46. package/src/skills/context-engine/SKILL.md +35 -3
@@ -1,7 +1,7 @@
1
1
  import { Pool } from 'pg';
2
- import { G as GraphConfig, C as ContextEngineConfig } from '../config-CNnASw5X.cjs';
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-DU1JRno5.cjs';
4
+ import { E as Embedder, A as AnnTunable } from '../storage-Dvpq2xAC.cjs';
5
5
  import 'zod';
6
6
 
7
7
  type Neo4jDriver = {
@@ -1,7 +1,7 @@
1
1
  import { Pool } from 'pg';
2
- import { G as GraphConfig, C as ContextEngineConfig } from '../config-CdlSkKgV.js';
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-Dvt2ZxsV.js';
4
+ import { E as Embedder, A as AnnTunable } from '../storage-CJrKgJeJ.js';
5
5
  import 'zod';
6
6
 
7
7
  type Neo4jDriver = {
@@ -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 === "gemini" || cfg.provider === "bedrock") {
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 === "gemini") {
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 loadGeminiChatClient(this.cfg.apiKey);
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 ?? []) {
@@ -586,9 +619,9 @@ function buildPrompt(fullText) {
586
619
  DOCUMENT TEXT:
587
620
  ${fullText}
588
621
 
589
- ENTITY TYPES: PERSON, ORG, PRODUCT, LOCATION, REFERENCE, TEMPORAL, CONCEPT
622
+ ENTITY TYPES: ${ENTITY_TYPES.join(", ")}
590
623
 
591
- RELATIONSHIP CATEGORIES: HIERARCHICAL, MEMBERSHIP, CREATION, TEMPORAL, SPATIAL, REFERENCE, FUNCTIONAL, QUANTITATIVE
624
+ RELATIONSHIP CATEGORIES: ${RELATIONSHIP_CATEGORY_VALUES.join(", ")}
592
625
 
593
626
  OUTPUT FORMAT (STRICT JSON):
594
627
  {
@@ -867,7 +900,7 @@ async function extractEntitiesForDocument(documentId, opts) {
867
900
  if (opts.graphStore) await syncToNeo4j(opts.pool, documentId, chunkSnaps, opts.graphStore);
868
901
  return stats;
869
902
  }
870
- var ENTITY_TYPES, RELATIONSHIP_CATEGORIES, CHUNKS_PER_BATCH, EXTRACTION_SYSTEM;
903
+ var ENTITY_TYPES, RELATIONSHIP_CATEGORY_VALUES, RELATIONSHIP_CATEGORIES, CHUNKS_PER_BATCH, EXTRACTION_SYSTEM;
871
904
  var init_entities = __esm({
872
905
  "src/graph/entities.ts"() {
873
906
  ENTITY_TYPES = [
@@ -879,7 +912,7 @@ var init_entities = __esm({
879
912
  "TEMPORAL",
880
913
  "CONCEPT"
881
914
  ];
882
- RELATIONSHIP_CATEGORIES = /* @__PURE__ */ new Set([
915
+ RELATIONSHIP_CATEGORY_VALUES = [
883
916
  "HIERARCHICAL",
884
917
  "MEMBERSHIP",
885
918
  "CREATION",
@@ -888,7 +921,8 @@ var init_entities = __esm({
888
921
  "REFERENCE",
889
922
  "FUNCTIONAL",
890
923
  "QUANTITATIVE"
891
- ]);
924
+ ];
925
+ RELATIONSHIP_CATEGORIES = new Set(RELATIONSHIP_CATEGORY_VALUES);
892
926
  CHUNKS_PER_BATCH = 11;
893
927
  EXTRACTION_SYSTEM = "You are a STRICT JSON entity and relationship extraction engine.";
894
928
  }