@promptev/context-engine 0.0.3 → 0.0.4

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.
@@ -74,7 +74,35 @@ await engine.search(q, { principals: user.groups }); // scoped
74
74
  `compute`, `map_reduce`, `get_neighbors`, `traverse`, `find_related`,
75
75
  `community_summary`.
76
76
  `engine.searchKnowledgeBase({ action, principals, scope })` is the
77
- same function `createMcpApp` serves. `knowledgeToolDefinition()` gives
77
+ same function `createMcpApp` serves. `discover` returns the SCHEMA, not
78
+ just an inventory, and for EVERY document type. Each listed document carries
79
+ `structure` — `sheets` (name, column headers, row count; the sheet name is
80
+ the key `compute` exposes in `dfs`) for a workbook, `sections` and
81
+ `last_page` for a document with headings, `keys` for JSON, and `chunks` for
82
+ anything else — plus `document_type` and `mode`. Every list inside a
83
+ `structure` is capped, with the remainder reported as `more_columns` /
84
+ `more_sections` / `more_keys` / `more_sheets` (absent when nothing was cut)
85
+ and, while the remainder is worth fetching, a filled-in `next_action`. Past
86
+ `MAX_INVITED_ITEMS` the invitation is WITHHELD and replaced by `instead` —
87
+ a model cannot know what a full list costs until it has paid for it, so
88
+ offering a sixteen-thousand-column fetch would be the tool's decision, not
89
+ the caller's; a list that long is a signal to compute over the sheet or read
90
+ the document, never to list it. **The cap is for the call that did NOT name
91
+ its documents:** `discover` (and `list`) now accept `document_ids`, filtered
92
+ in SQL, and a `discover` scoped to specific documents answers their
93
+ structure WHOLE and narrows `fields_by_type` and `document_types` to them
94
+ too. The host's `scope` ceiling still wins — a named id outside it is
95
+ dropped, never reached.
96
+ Alongside them, `fields_by_type` and `document_types` are BOTH keyed by
97
+ `(kind, type)` — a `document_type` is a label an LLM wrote, so a PDF invoice
98
+ and a CSV of invoice rows can share one, and keying on the label alone would
99
+ merge their fields. `fields_by_type` rows carry `fields` (name, data type,
100
+ how many in-scope documents) plus `more_fields` (names past the cap);
101
+ `document_types` rows carry `documents` and `with_fields`. `type` is written
102
+ only where `extract_structured` was opted into, so it is null on a default
103
+ deployment — which is why `kind` is there. All of it is ACL- and
104
+ scope-filtered and masked by an output redaction policy. `list` returns the
105
+ same page WITHOUT the structure — browsing does not pay for it. `knowledgeToolDefinition()` gives
78
106
  the name, description and JSON Schema if you are wiring it into your own
79
107
  agent loop. `compute` and `mapReduce` accept a host callable that REPLACES
80
108
  the built-in one — that is the seam for your own permission, billing and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptev/context-engine",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Promptev Context Engine — language-agnostic ingestion + hybrid retrieval (TypeScript)",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Promptev Inc",
@@ -74,7 +74,35 @@ await engine.search(q, { principals: user.groups }); // scoped
74
74
  `compute`, `map_reduce`, `get_neighbors`, `traverse`, `find_related`,
75
75
  `community_summary`.
76
76
  `engine.searchKnowledgeBase({ action, principals, scope })` is the
77
- same function `createMcpApp` serves. `knowledgeToolDefinition()` gives
77
+ same function `createMcpApp` serves. `discover` returns the SCHEMA, not
78
+ just an inventory, and for EVERY document type. Each listed document carries
79
+ `structure` — `sheets` (name, column headers, row count; the sheet name is
80
+ the key `compute` exposes in `dfs`) for a workbook, `sections` and
81
+ `last_page` for a document with headings, `keys` for JSON, and `chunks` for
82
+ anything else — plus `document_type` and `mode`. Every list inside a
83
+ `structure` is capped, with the remainder reported as `more_columns` /
84
+ `more_sections` / `more_keys` / `more_sheets` (absent when nothing was cut)
85
+ and, while the remainder is worth fetching, a filled-in `next_action`. Past
86
+ `MAX_INVITED_ITEMS` the invitation is WITHHELD and replaced by `instead` —
87
+ a model cannot know what a full list costs until it has paid for it, so
88
+ offering a sixteen-thousand-column fetch would be the tool's decision, not
89
+ the caller's; a list that long is a signal to compute over the sheet or read
90
+ the document, never to list it. **The cap is for the call that did NOT name
91
+ its documents:** `discover` (and `list`) now accept `document_ids`, filtered
92
+ in SQL, and a `discover` scoped to specific documents answers their
93
+ structure WHOLE and narrows `fields_by_type` and `document_types` to them
94
+ too. The host's `scope` ceiling still wins — a named id outside it is
95
+ dropped, never reached.
96
+ Alongside them, `fields_by_type` and `document_types` are BOTH keyed by
97
+ `(kind, type)` — a `document_type` is a label an LLM wrote, so a PDF invoice
98
+ and a CSV of invoice rows can share one, and keying on the label alone would
99
+ merge their fields. `fields_by_type` rows carry `fields` (name, data type,
100
+ how many in-scope documents) plus `more_fields` (names past the cap);
101
+ `document_types` rows carry `documents` and `with_fields`. `type` is written
102
+ only where `extract_structured` was opted into, so it is null on a default
103
+ deployment — which is why `kind` is there. All of it is ACL- and
104
+ scope-filtered and masked by an output redaction policy. `list` returns the
105
+ same page WITHOUT the structure — browsing does not pay for it. `knowledgeToolDefinition()` gives
78
106
  the name, description and JSON Schema if you are wiring it into your own
79
107
  agent loop. `compute` and `mapReduce` accept a host callable that REPLACES
80
108
  the built-in one — that is the seam for your own permission, billing and