@promptev/context-engine 0.0.2 → 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.
@@ -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
@@ -130,11 +155,14 @@ app.route(
130
155
  `createFastifyPlugin` (`@promptev/context-engine/fastify`) and
131
156
  `createMcpApp` (`@promptev/context-engine/mcp`) take the same two
132
157
  arguments. MCP has no request object: `principals` is a zero-argument
133
- 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`
134
160
  binds `127.0.0.1` and answers as anonymous (`principals=[]`).
135
161
 
136
162
  Not on a supported framework? Call `engine.search()` / `engine.ingest()`
137
- 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.
138
166
 
139
167
  ## Lifecycle
140
168
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptev/context-engine",
3
- "version": "0.0.2",
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
@@ -130,11 +155,14 @@ app.route(
130
155
  `createFastifyPlugin` (`@promptev/context-engine/fastify`) and
131
156
  `createMcpApp` (`@promptev/context-engine/mcp`) take the same two
132
157
  arguments. MCP has no request object: `principals` is a zero-argument
133
- 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`
134
160
  binds `127.0.0.1` and answers as anonymous (`principals=[]`).
135
161
 
136
162
  Not on a supported framework? Call `engine.search()` / `engine.ingest()`
137
- 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.
138
166
 
139
167
  ## Lifecycle
140
168