@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,4 +1,4 @@
1
- import { T as ToolEngine, a as ToolConfig } from './governance-D8g6Wyvb.cjs';
1
+ import { T as ToolEngine, a as ToolConfig } from './governance-P9pRb4Ol.cjs';
2
2
 
3
3
  type ContextEngineLike = {
4
4
  ingest: (args: Record<string, unknown>) => Promise<unknown>;
@@ -1,4 +1,4 @@
1
- import { T as ToolEngine, a as ToolConfig } from './governance-XFVgtEdV.js';
1
+ import { T as ToolEngine, a as ToolConfig } from './governance-BLPK7NMe.js';
2
2
 
3
3
  type ContextEngineLike = {
4
4
  ingest: (args: Record<string, unknown>) => Promise<unknown>;
@@ -62,6 +62,31 @@ await engine.search(q, { principals: user.groups }); // scoped
62
62
  no default. If you hit a `TypeError`, supply real ones — do **not** silence
63
63
  it with `principals: () => null`, which disables access control on a public
64
64
  port. Anonymous is `() => []`. Trusted is `() => TRUSTED`.
65
+ - **Search picks its own mode unless you name one.** `search({ mode: null })` (the
66
+ default) adds the graph leg when the deployment has a graph AND something in
67
+ scope was ingested with `mode: "graph"` — a model cannot know which documents
68
+ those are, so it is not asked. Pass `mode: "hybrid"` to force the old
69
+ behaviour. INGESTION is unchanged and stays explicit. An unreachable graph
70
+ database is skipped rather than waited on, and every graph failure degrades
71
+ to the hybrid legs instead of failing the search.
72
+ - **The knowledge tool is one call with THIRTEEN actions** — `discover`,
73
+ `search`, `get_doc`, `get_docs`, `get_chunks`, `list`, `query_meta`,
74
+ `compute`, `map_reduce`, `get_neighbors`, `traverse`, `find_related`,
75
+ `community_summary`.
76
+ `engine.searchKnowledgeBase({ action, principals, scope })` is the
77
+ same function `createMcpApp` serves. `knowledgeToolDefinition()` gives
78
+ the name, description and JSON Schema if you are wiring it into your own
79
+ agent loop. `compute` and `mapReduce` accept a host callable that REPLACES
80
+ the built-in one — that is the seam for your own permission, billing and
81
+ approval rules, and supplying one makes the action available regardless of
82
+ the deployment's own gate.
83
+ - **`scope` is REQUIRED on `createMcpApp`** and on
84
+ `engine.searchKnowledgeBase`: the ceiling of source ids the tool may ever
85
+ reach. Like `principals` it is host-supplied and NEVER a tool argument — a
86
+ model can name any source id, and a tool that believed it would cross
87
+ tenants. Pass `scope: UNSCOPED` only to mean the whole corpus on purpose. A
88
+ caller narrows within the ceiling; an id outside it is dropped silently, and
89
+ a request left with nothing returns nothing (never everything).
65
90
  - **`acl=null` on `updateDocument` UNRESTRICTS the document.** "Leave it
66
91
  alone" is expressed by omitting the argument (the `UNSET` sentinel), because
67
92
  `null` already means unrestricted and cannot also mean absent. Same for
@@ -70,7 +95,11 @@ await engine.search(q, { principals: user.groups }); // scoped
70
95
  silently loses recall — queries return fewer rows than match, or none, with
71
96
  no error. The library cannot compensate.
72
97
  - **`config.enableCodeExecution` is `false` on purpose.** `engine.compute()`
73
- executes generated code. Turn it on only deliberately.
98
+ and `computeOverFrames()` execute generated code. Turn it on only
99
+ deliberately. `computeOverFrames({ sheet: rows }, instruction, { config:
100
+ engine.config })` is the same guarded path for tables the host already holds
101
+ (no document to point at); redaction masks every string cell AND every column
102
+ header before the LLM sees a schema, and sweeps the result.
74
103
  - Filing a document under an ACL the caller does not hold returns **403**, on
75
104
  ingest and on PATCH alike.
76
105
 
@@ -126,11 +155,14 @@ app.route(
126
155
  `createFastifyPlugin` (`@promptev/context-engine/fastify`) and
127
156
  `createMcpApp` (`@promptev/context-engine/mcp`) take the same two
128
157
  arguments. MCP has no request object: `principals` is a zero-argument
129
- callable resolved fresh on every tool call. The CLI `context-engine mcp`
158
+ callable resolved fresh on every tool call, and `createMcpApp` also requires
159
+ `scope` — the source-id ceiling, resolved the same way. The CLI `context-engine mcp`
130
160
  binds `127.0.0.1` and answers as anonymous (`principals=[]`).
131
161
 
132
162
  Not on a supported framework? Call `engine.search()` / `engine.ingest()`
133
- from your own handler — the routers are thin wrappers over the same core.
163
+ from your own handler — the routers are thin wrappers over the same core. For
164
+ an agent, `engine.searchKnowledgeBase({ action, principals, scope })` is the
165
+ same one tool the MCP server serves, with no transport in the way.
134
166
 
135
167
  ## Lifecycle
136
168
 
@@ -1,11 +1,14 @@
1
- import { b as EmbeddingConfig } from './config-CNnASw5X.cjs';
1
+ import { b as EmbeddingConfig } from './config-BODDdXJ7.js';
2
2
  import { PoolClient, Pool } from 'pg';
3
3
 
4
4
  /**
5
5
  * Pluggable embeddings provider.
6
6
  *
7
7
  * openai / azure_openai / custom → OpenAI SDK (OpenAI-compatible, including TEI/vLLM).
8
- * gemini → lazy `@google/genai` (optional extra "gemini").
8
+ * gemini / vertex_ai → lazy `@google/genai` (optional extra "gemini"). One
9
+ * code path: same SDK and models, differing only in how the client
10
+ * authenticates (API key vs ADC against a GCP project) — see
11
+ * `providers/google.ts`.
9
12
  * voyage / cohere → fetch against their public REST APIs.
10
13
  *
11
14
  * `kind` is accepted everywhere but only voyage/cohere act on it.
@@ -1,11 +1,14 @@
1
- import { b as EmbeddingConfig } from './config-CdlSkKgV.js';
1
+ import { b as EmbeddingConfig } from './config-C5RZ00W6.cjs';
2
2
  import { PoolClient, Pool } from 'pg';
3
3
 
4
4
  /**
5
5
  * Pluggable embeddings provider.
6
6
  *
7
7
  * openai / azure_openai / custom → OpenAI SDK (OpenAI-compatible, including TEI/vLLM).
8
- * gemini → lazy `@google/genai` (optional extra "gemini").
8
+ * gemini / vertex_ai → lazy `@google/genai` (optional extra "gemini"). One
9
+ * code path: same SDK and models, differing only in how the client
10
+ * authenticates (API key vs ADC against a GCP project) — see
11
+ * `providers/google.ts`.
9
12
  * voyage / cohere → fetch against their public REST APIs.
10
13
  *
11
14
  * `kind` is accepted everywhere but only voyage/cohere act on it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptev/context-engine",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Promptev Context Engine — language-agnostic ingestion + hybrid retrieval (TypeScript)",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Promptev Inc",
@@ -62,6 +62,31 @@ await engine.search(q, { principals: user.groups }); // scoped
62
62
  no default. If you hit a `TypeError`, supply real ones — do **not** silence
63
63
  it with `principals: () => null`, which disables access control on a public
64
64
  port. Anonymous is `() => []`. Trusted is `() => TRUSTED`.
65
+ - **Search picks its own mode unless you name one.** `search({ mode: null })` (the
66
+ default) adds the graph leg when the deployment has a graph AND something in
67
+ scope was ingested with `mode: "graph"` — a model cannot know which documents
68
+ those are, so it is not asked. Pass `mode: "hybrid"` to force the old
69
+ behaviour. INGESTION is unchanged and stays explicit. An unreachable graph
70
+ database is skipped rather than waited on, and every graph failure degrades
71
+ to the hybrid legs instead of failing the search.
72
+ - **The knowledge tool is one call with THIRTEEN actions** — `discover`,
73
+ `search`, `get_doc`, `get_docs`, `get_chunks`, `list`, `query_meta`,
74
+ `compute`, `map_reduce`, `get_neighbors`, `traverse`, `find_related`,
75
+ `community_summary`.
76
+ `engine.searchKnowledgeBase({ action, principals, scope })` is the
77
+ same function `createMcpApp` serves. `knowledgeToolDefinition()` gives
78
+ the name, description and JSON Schema if you are wiring it into your own
79
+ agent loop. `compute` and `mapReduce` accept a host callable that REPLACES
80
+ the built-in one — that is the seam for your own permission, billing and
81
+ approval rules, and supplying one makes the action available regardless of
82
+ the deployment's own gate.
83
+ - **`scope` is REQUIRED on `createMcpApp`** and on
84
+ `engine.searchKnowledgeBase`: the ceiling of source ids the tool may ever
85
+ reach. Like `principals` it is host-supplied and NEVER a tool argument — a
86
+ model can name any source id, and a tool that believed it would cross
87
+ tenants. Pass `scope: UNSCOPED` only to mean the whole corpus on purpose. A
88
+ caller narrows within the ceiling; an id outside it is dropped silently, and
89
+ a request left with nothing returns nothing (never everything).
65
90
  - **`acl=null` on `updateDocument` UNRESTRICTS the document.** "Leave it
66
91
  alone" is expressed by omitting the argument (the `UNSET` sentinel), because
67
92
  `null` already means unrestricted and cannot also mean absent. Same for
@@ -70,7 +95,11 @@ await engine.search(q, { principals: user.groups }); // scoped
70
95
  silently loses recall — queries return fewer rows than match, or none, with
71
96
  no error. The library cannot compensate.
72
97
  - **`config.enableCodeExecution` is `false` on purpose.** `engine.compute()`
73
- executes generated code. Turn it on only deliberately.
98
+ and `computeOverFrames()` execute generated code. Turn it on only
99
+ deliberately. `computeOverFrames({ sheet: rows }, instruction, { config:
100
+ engine.config })` is the same guarded path for tables the host already holds
101
+ (no document to point at); redaction masks every string cell AND every column
102
+ header before the LLM sees a schema, and sweeps the result.
74
103
  - Filing a document under an ACL the caller does not hold returns **403**, on
75
104
  ingest and on PATCH alike.
76
105
 
@@ -126,11 +155,14 @@ app.route(
126
155
  `createFastifyPlugin` (`@promptev/context-engine/fastify`) and
127
156
  `createMcpApp` (`@promptev/context-engine/mcp`) take the same two
128
157
  arguments. MCP has no request object: `principals` is a zero-argument
129
- callable resolved fresh on every tool call. The CLI `context-engine mcp`
158
+ callable resolved fresh on every tool call, and `createMcpApp` also requires
159
+ `scope` — the source-id ceiling, resolved the same way. The CLI `context-engine mcp`
130
160
  binds `127.0.0.1` and answers as anonymous (`principals=[]`).
131
161
 
132
162
  Not on a supported framework? Call `engine.search()` / `engine.ingest()`
133
- from your own handler — the routers are thin wrappers over the same core.
163
+ from your own handler — the routers are thin wrappers over the same core. For
164
+ an agent, `engine.searchKnowledgeBase({ action, principals, scope })` is the
165
+ same one tool the MCP server serves, with no transport in the way.
134
166
 
135
167
  ## Lifecycle
136
168