@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
package/README.md CHANGED
@@ -147,6 +147,29 @@ trusted caller and returns the entire corpus. Use `[]` or `TRUSTED` explicitly.
147
147
  npx context-engine install-skill
148
148
  ```
149
149
 
150
+ ## Compute over tables
151
+
152
+ `engine.compute()` turns the in-scope CSV/XLSX documents into row tables and has
153
+ the LLM write code against them. `computeOverFrames()` is the same path for
154
+ tables you already hold — an uploaded workbook, a connector's sheet, a query
155
+ result — with no document to point at:
156
+
157
+ ```ts
158
+ import { computeOverFrames } from "@promptev/context-engine";
159
+
160
+ const out = await computeOverFrames(
161
+ { expenses: rows }, // { sheetName: Array<Record<string, unknown>> }
162
+ "total the amount column",
163
+ { config: engine.config },
164
+ );
165
+ out.result;
166
+ ```
167
+
168
+ Both are **off by default** (`enableCodeExecution: true` turns them on — only
169
+ behind real OS-level isolation) and both apply `config.redaction` before the LLM
170
+ sees anything: every string cell *and* every column header is masked, and the
171
+ returned object — generated code included — is swept on the way out.
172
+
150
173
  ## Serve
151
174
 
152
175
  ```ts
@@ -157,6 +180,63 @@ const router = createHonoRouter(engine, { auth: myAuth, principals: myPrincipals
157
180
 
158
181
  `auth` and `principals` are required. Identical routes exist for Express and Fastify.
159
182
 
183
+ ## The knowledge tool
184
+
185
+ One tool with actions:
186
+
187
+ | Action | What it is for |
188
+ |---|---|
189
+ | `discover` | what documents there are and what each action can do — call it first |
190
+ | `search` | passages by meaning or keywords |
191
+ | `get_doc` / `get_docs` | one whole document by id, or several at once |
192
+ | `get_chunks` | walk one long document in order, a piece at a time |
193
+ | `list` | browse the documents without searching |
194
+ | `query_meta` | filter documents by their structured fields |
195
+ | `compute` | a figure derived from the spreadsheets, over every row |
196
+ | `map_reduce` | the same question asked of every document in scope |
197
+ | `get_neighbors` / `traverse` | what is one step, or a few steps, from a named thing |
198
+ | `find_related` | connections of a kind across the corpus |
199
+ | `community_summary` | the themes the corpus groups into |
200
+
201
+ One description carries the decision rules once and there is one name for a
202
+ model to route through. An action this deployment cannot service is advertised
203
+ as off rather than hidden, and called anyway it answers `{ success: false,
204
+ error }` the model can relay. A truncated answer carries the `next_page` call
205
+ that reads the rest.
206
+
207
+ Omit `mode` on a search and it is worked out from the documents in scope — the
208
+ graph leg is added when the deployment has a graph and something in scope was
209
+ ingested that way, and it runs beside the other legs rather than ahead of
210
+ them. Naming `"hybrid"` or `"graph"` forces one.
211
+
212
+ ```ts
213
+ import { UNSCOPED } from "@promptev/context-engine";
214
+
215
+ const answer = await engine.searchKnowledgeBase({
216
+ action: "search",
217
+ query: "annual leave",
218
+ principals: caller,
219
+ scope: ["hr"],
220
+ });
221
+ ```
222
+
223
+ `createMcpApp` serves that same function, so an application driving its own
224
+ agent loop needs no MCP and cannot get a different answer.
225
+ `knowledgeToolDefinition()` exports the tool as data — name, description and
226
+ input schema as JSON Schema — so a host never hand-writes it. `createMcpApp`
227
+ also takes `redaction` (applied per call), and `compute` / `mapReduce`
228
+ callables that REPLACE the built-in ones, which is where a host applies its own
229
+ rules for permission, billing and approval.
230
+
231
+ `scope` is REQUIRED on both: the ceiling of source ids (or a `Scope` with
232
+ document ids) the tool may ever reach. It is host-supplied and resolved per
233
+ call like `principals`, and never a tool argument — a model can name any
234
+ source id, and a tool that believed it would let one caller read another's
235
+ documents. Map your own word onto it: a project, a matter, a customer. A
236
+ caller narrows within the ceiling and never past it; an id outside is dropped
237
+ silently; a request left with nothing in scope returns nothing. A host with
238
+ one shared corpus writes `scope: UNSCOPED` on purpose.
239
+
160
240
  ## Tools
161
241
 
162
242
  Register a governed tool — HTTP, SQL, MCP, or a plain function — and every call