n8n-nodes-engram 0.5.1 → 0.7.0
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.
- package/README.md +154 -3
- package/dist/descriptions.js +1 -1
- package/dist/descriptions.js.map +1 -1
- package/dist/embeddings/EmbeddingService.d.ts +5 -1
- package/dist/embeddings/EmbeddingService.js +97 -37
- package/dist/embeddings/EmbeddingService.js.map +1 -1
- package/dist/extraction/AssertionEvidence.d.ts +1 -0
- package/dist/extraction/AssertionEvidence.js +21 -0
- package/dist/extraction/AssertionEvidence.js.map +1 -0
- package/dist/extraction/BoundedExtraction.d.ts +15 -0
- package/dist/extraction/BoundedExtraction.js +380 -0
- package/dist/extraction/BoundedExtraction.js.map +1 -0
- package/dist/extraction/ContradictionDetector.d.ts +3 -1
- package/dist/extraction/ContradictionDetector.js +34 -18
- package/dist/extraction/ContradictionDetector.js.map +1 -1
- package/dist/extraction/DurableExtraction.d.ts +22 -0
- package/dist/extraction/DurableExtraction.js +363 -0
- package/dist/extraction/DurableExtraction.js.map +1 -0
- package/dist/extraction/EdgeDeduplicator.d.ts +3 -1
- package/dist/extraction/EdgeDeduplicator.js +63 -32
- package/dist/extraction/EdgeDeduplicator.js.map +1 -1
- package/dist/extraction/EntityDeduplicator.d.ts +3 -1
- package/dist/extraction/EntityDeduplicator.js +44 -24
- package/dist/extraction/EntityDeduplicator.js.map +1 -1
- package/dist/extraction/EntityExtractor.d.ts +3 -1
- package/dist/extraction/EntityExtractor.js +56 -33
- package/dist/extraction/EntityExtractor.js.map +1 -1
- package/dist/extraction/ExtractionDiagnostics.d.ts +35 -0
- package/dist/extraction/ExtractionDiagnostics.js +283 -0
- package/dist/extraction/ExtractionDiagnostics.js.map +1 -0
- package/dist/extraction/ExtractionPipeline.d.ts +5 -2
- package/dist/extraction/ExtractionPipeline.js +83 -20
- package/dist/extraction/ExtractionPipeline.js.map +1 -1
- package/dist/extraction/ExtractionSource.d.ts +1 -0
- package/dist/extraction/ExtractionSource.js.map +1 -1
- package/dist/extraction/LlmClient.d.ts +14 -3
- package/dist/extraction/LlmClient.js +71 -27
- package/dist/extraction/LlmClient.js.map +1 -1
- package/dist/extraction/QueueState.d.ts +294 -0
- package/dist/extraction/QueueState.js +668 -0
- package/dist/extraction/QueueState.js.map +1 -0
- package/dist/extraction/RelationshipExtractor.d.ts +3 -1
- package/dist/extraction/RelationshipExtractor.js +62 -37
- package/dist/extraction/RelationshipExtractor.js.map +1 -1
- package/dist/extraction/RequestBudget.d.ts +17 -0
- package/dist/extraction/RequestBudget.js +80 -0
- package/dist/extraction/RequestBudget.js.map +1 -0
- package/dist/extraction/StagedGraph.d.ts +21 -0
- package/dist/extraction/StagedGraph.js +273 -0
- package/dist/extraction/StagedGraph.js.map +1 -0
- package/dist/extraction/TemporalEvidence.d.ts +2 -0
- package/dist/extraction/TemporalEvidence.js +87 -0
- package/dist/extraction/TemporalEvidence.js.map +1 -0
- package/dist/memory/EngramChatMemory.d.ts +31 -0
- package/dist/memory/EngramChatMemory.js +352 -33
- package/dist/memory/EngramChatMemory.js.map +1 -1
- package/dist/memory/EngramChatMessageHistory.d.ts +17 -2
- package/dist/memory/EngramChatMessageHistory.js +89 -12
- package/dist/memory/EngramChatMessageHistory.js.map +1 -1
- package/dist/memory/HistorySelection.d.ts +6 -0
- package/dist/memory/HistorySelection.js +86 -0
- package/dist/memory/HistorySelection.js.map +1 -0
- package/dist/memory/MessagePolicy.d.ts +5 -0
- package/dist/memory/MessagePolicy.js +64 -0
- package/dist/memory/MessagePolicy.js.map +1 -0
- package/dist/nodes/EngramAdmin/EngramAdmin.node.js +467 -14
- package/dist/nodes/EngramAdmin/EngramAdmin.node.js.map +1 -1
- package/dist/nodes/EngramMemory/EngramMemory.node.js +230 -1
- package/dist/nodes/EngramMemory/EngramMemory.node.js.map +1 -1
- package/dist/schemas/ExtractionOutcome.schema.d.ts +1233 -0
- package/dist/schemas/ExtractionOutcome.schema.js +116 -0
- package/dist/schemas/ExtractionOutcome.schema.js.map +1 -0
- package/dist/schemas/ExtractionPolicy.schema.d.ts +310 -0
- package/dist/schemas/ExtractionPolicy.schema.js +103 -0
- package/dist/schemas/ExtractionPolicy.schema.js.map +1 -0
- package/dist/schemas/ExtractionQueue.schema.d.ts +11492 -0
- package/dist/schemas/ExtractionQueue.schema.js +194 -0
- package/dist/schemas/ExtractionQueue.schema.js.map +1 -0
- package/dist/schemas/GraphData.schema.d.ts +20 -0
- package/dist/schemas/GraphData.schema.js +1 -0
- package/dist/schemas/GraphData.schema.js.map +1 -1
- package/dist/schemas/MemoryPolicy.schema.d.ts +2972 -0
- package/dist/schemas/MemoryPolicy.schema.js +73 -0
- package/dist/schemas/MemoryPolicy.schema.js.map +1 -0
- package/dist/schemas/StorageObservation.schema.d.ts +117 -0
- package/dist/schemas/StorageObservation.schema.js +41 -0
- package/dist/schemas/StorageObservation.schema.js.map +1 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.js +19 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/search/GovernedContext.d.ts +29 -0
- package/dist/search/GovernedContext.js +232 -0
- package/dist/search/GovernedContext.js.map +1 -0
- package/dist/search/HybridSearchEngine.d.ts +4 -1
- package/dist/search/HybridSearchEngine.js +18 -10
- package/dist/search/HybridSearchEngine.js.map +1 -1
- package/dist/search/RetrievalGovernance.d.ts +7 -4
- package/dist/search/RetrievalGovernance.js +25 -6
- package/dist/search/RetrievalGovernance.js.map +1 -1
- package/dist/storage/GraphologyStorage.d.ts +20 -2
- package/dist/storage/GraphologyStorage.js +247 -19
- package/dist/storage/GraphologyStorage.js.map +1 -1
- package/dist/storage/IGraphStorage.d.ts +21 -2
- package/dist/storage/Neo4jStorage.d.ts +22 -2
- package/dist/storage/Neo4jStorage.js +324 -21
- package/dist/storage/Neo4jStorage.js.map +1 -1
- package/dist/storage/StorageDiagnostics.d.ts +6 -0
- package/dist/storage/StorageDiagnostics.js +64 -0
- package/dist/storage/StorageDiagnostics.js.map +1 -0
- package/dist/utils/advancedExtraction.d.ts +11 -0
- package/dist/utils/advancedExtraction.js +87 -0
- package/dist/utils/advancedExtraction.js.map +1 -0
- package/dist/utils/logWrapper.js +115 -2
- package/dist/utils/logWrapper.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
<a href="https://github.com/casistack/n8n-nodes-engram/blob/main/LICENSE">
|
|
20
20
|
<img src="https://img.shields.io/badge/license-AGPL--3.0-blue.svg" alt="License: AGPL-3.0" />
|
|
21
21
|
</a>
|
|
22
|
-
<img src="https://img.shields.io/badge/node-%3E%
|
|
22
|
+
<img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg" alt="Node.js" />
|
|
23
23
|
<img src="https://img.shields.io/badge/n8n-community%20node-ff6d5a.svg" alt="n8n community node" />
|
|
24
24
|
</p>
|
|
25
25
|
|
|
26
26
|
<p align="center">
|
|
27
27
|
<a href="#installation">Installation</a> ·
|
|
28
|
-
<a href="#upgrading-
|
|
28
|
+
<a href="#upgrading-to-v070">Upgrade</a> ·
|
|
29
29
|
<a href="#node-reference">Nodes</a> ·
|
|
30
30
|
<a href="#storage-backends">Storage</a> ·
|
|
31
31
|
<a href="#knowledge-extraction">Extraction</a> ·
|
|
@@ -101,6 +101,110 @@ npm install n8n-nodes-engram
|
|
|
101
101
|
|
|
102
102
|
---
|
|
103
103
|
|
|
104
|
+
## Upgrading to v0.7.0
|
|
105
|
+
|
|
106
|
+
These Memory v2 controls are optional. Existing workflows keep **Entity Resolution > Legacy**, **Knowledge Selection > Legacy**, **Extraction Execution > Synchronous** and **Graph Context Policy > Legacy**. Installing a newer package does not enable them or rewrite existing knowledge.
|
|
107
|
+
|
|
108
|
+
### Back Up and Install v0.7.0
|
|
109
|
+
|
|
110
|
+
1. Back up current workflows and n8n configuration. Preserve exact namespace keys and any existing alias mapping.
|
|
111
|
+
2. **Embedded:** pause writers and preserve each producer workflow's graph file, storage directory and workflow-to-file mapping. Use a separate restored store for upgrade trials. Once durable work exists, use **Extraction Queue > Export Queue Backup** for portable queue-aware recovery.
|
|
112
|
+
3. **Neo4j:** take a consistent database backup using your normal recovery procedure. Retain the same database and namespace identities. Graph writers coordinate through a shared store lock; validate concurrent write throughput during rollout.
|
|
113
|
+
4. Install `n8n-nodes-engram@0.7.0`, restart n8n, refresh the editor and confirm the installed version. Node.js 20 or newer is required. Existing v2 stores load without a bulk migration or re-extraction; earlier provenance/schema upgrades remain separate.
|
|
114
|
+
5. Run **Engram Admin > Monitoring > Diagnostics**. Saved Memory v1 nodes remain v1; upgrade selected nodes explicitly to **Memory v2** on an inactive workflow copy before enabling the new controls. Check that the copy points to the intended restored store.
|
|
115
|
+
|
|
116
|
+
### Activate Bounded Extraction First
|
|
117
|
+
|
|
118
|
+
Back up current workflows and both the graph and conversation records before changing settings. Preserve the exact namespace, including whitespace, and the existing embedded workflow-to-file mapping or Neo4j database. Begin with one conversation workflow and keep the current model, session identity and conversation window.
|
|
119
|
+
|
|
120
|
+
Select **Entity Resolution > Bounded** and **Message Write Policy > Final Turns**. Keep eligible human/final-assistant sources stored; system/tool extraction is unsupported in this mode. Exact names and explicitly verified aliases resolve before model comparisons. Defaults limit each extraction to an eight-candidate shortlist, 16 fuzzy comparisons, 32 model/embedding requests and a 30-second shared deadline. Identity ambiguity, pruned candidates and exhausted budgets remain proposed or deferred; they are not permission to merge existing identities. Legacy contradiction expiry and automatic summary updates are not performed by the bounded path.
|
|
121
|
+
|
|
122
|
+
Select **Knowledge Selection > Durable and Temporal** to keep temporary requests in conversation history without automatically accepting them as durable facts. Automatic acceptance requires accepted human provenance and complete, literal assertion evidence. Paraphrases, quotations, hypothetical or qualified statements and uncertain identities require review. This conservative policy can produce more proposed records. It does not reclassify, re-extract or delete previously stored facts. **Source Timezone** must be an explicit IANA zone such as `Europe/London`; omit it when unknown. Calendar-day resolution supports today/tomorrow/yesterday and a single explicit date. Other relative expressions remain uncertain.
|
|
123
|
+
|
|
124
|
+
**Graph Context Policy > Governed Current** reconciles search/traversal duplicates by relationship UUID, omits ungrounded entity summaries and excludes unresolved or out-of-interval plans from current context. **Governed Historical** retains historical evidence with source attribution; map historical intent explicitly in the workflow. **Governed As Of** requires an ISO timestamp with `Z` or a numeric offset and tests event-interval relevance, not what the system knew at that time. Separate **Durable Fact Token Allowance** (4096) and **Historical Evidence Token Allowance** (2048) stay within the overall graph context token cap; the recent-message window remains independent. A zero allowance disables that evidence category. Governed search and traversal share a 512-source-reference hydration allowance; candidates whose complete provenance does not fit are deferred, with `source_reference_deferred` and truncation diagnostics. Existing accepted legacy records are not automatically corrected. Genuine human JSON and quoted conversation remain in the episode ledger.
|
|
125
|
+
|
|
126
|
+
Inspect save diagnostics for per-stage elapsed time, model-call counts, available token usage, candidate/deferral counts and storage timing. Unavailable provider/backend measurements are `null`; overlapping stage/request/storage times must not be added together. Agree latency targets from your own normal and tool-assisted workloads before expanding the rollout.
|
|
127
|
+
|
|
128
|
+
### Activate a Durable Extraction Worker
|
|
129
|
+
|
|
130
|
+
Durable Queue removes model extraction from the chat save path by persisting the episode and its extraction job together. Graph facts become available only after a worker completes. It requires persistent storage, bounded resolution, Final Turns and **Retention Policy > Keep Forever**; unsupported combinations fail before the write. Use stable per-turn message/idempotency keys for retries.
|
|
131
|
+
|
|
132
|
+
1. Create a separate workflow with **Schedule Trigger > Engram Admin v2 > Extraction Queue > Process Jobs**. Start with **Worker Batch Size > 1**; each execution processes at most ten jobs sequentially. No worker runs automatically merely because the package is installed.
|
|
133
|
+
2. Configure the same backend and exact **Queue Group ID** as Memory. For embedded storage, set **Memory Workflow ID** to the original producer workflow ID and use the same custom storage directory. The worker's own workflow ID is not the producer's store. The existing producer file must be present. For Neo4j, use the same database and appropriate credentials.
|
|
134
|
+
3. Match the producer's extraction credential endpoint, model, temperature mode/value, entity types, thresholds, embedding configuration and all bounded/quality settings. Set the same nonsecret **Extraction Route ID** on producer and worker. API keys are not stored in jobs; credential rotation can retain the binding when these settings are unchanged. Route URLs containing credentials, query strings or fragments are rejected.
|
|
135
|
+
4. Activate the scheduled worker, then select **Extraction Execution > Durable Queue** on the producer. Inspect `delivery.status=queued`, job IDs, enqueue timing and `graph_fresh=false`; this is not a successful extraction result. Use **Extraction Queue > Status** for pending/failed counts, oldest pending time and bounded job summaries, then inspect worker outcomes and actual graph facts.
|
|
136
|
+
5. Verify an ordinary turn, a real tool-assisted turn, a durable preference, older-fact recall and an explicit historical query. Confirm the final pair is saved once, audits remain outside conversational context, original records retain their identity and the queue drains. Only then activate additional namespaces. Evaluate passive ingestion separately.
|
|
137
|
+
|
|
138
|
+
Jobs use fenced leases, bounded retry/backoff and atomic graph/completion writes. Restarts can recover work; retries do not resend chat messages. Configuration mismatch leaves work unclaimed. Use **Rebind Job** with an operator and reason only after reviewing corrected settings; this preserves the source/job identity and clears stale staged work. Pause, resume, retry and cancel are explicit reviewed operations. Capacity or durable-storage failures can reject the conversation write; monitor workflow errors rather than assuming every queued save is fail-soft. Snapshot preparation is capped at 100,000 records/100 MiB; source, request, response and staged-plan byte limits can defer oversized work without truncating original messages.
|
|
139
|
+
|
|
140
|
+
### Backups, Historical Artifacts and Rollback
|
|
141
|
+
|
|
142
|
+
Use **Extraction Queue > Export Queue Backup** to preserve jobs, ownership and completion markers along with graph/episode records. A generic graph export alone is not the queue recovery procedure. Imports verify checksums, namespace/endpoints and collisions; incomplete legacy source/chain references are retained with warnings. Imported active jobs are paused pending configuration review. Creating a fresh embedded import destination requires explicit review and a custom directory. Never import over newer live conversations.
|
|
143
|
+
|
|
144
|
+
The historical-artifact inspection and dry-run steps below still apply. This feature does not reinterpret historical records already labelled as genuine conversation, automatically delete extracted facts or provide a record-specific correction migration.
|
|
145
|
+
|
|
146
|
+
For rollback, first stop producers and workers and take a fresh queue-aware backup. Prefer restoring the previous policy settings on the new package. Before using an older binary, complete or explicitly cancel outstanding jobs and verify no worker remains active. Older binaries do not enforce queue ownership, leases or disk-sync protections; do not run old and new writers concurrently against a queue-bearing store. Keep the queue-aware backup and all new legitimate records. If an older package cannot safely read the retained operational metadata, use a separately reviewed recovery/export procedure; never overwrite live history with an old snapshot as routine rollback. Existing no-queue embedded stores retain their prior disk-sync behavior. Neo4j graph writers coordinate through a shared store lock to protect atomic extraction commits; measure concurrent write throughput before expanding a busy deployment.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Upgrading to v0.6.0
|
|
151
|
+
|
|
152
|
+
**Installing this release makes the controls available; it does not automatically activate history filtering or final-turn writes.** Existing saved settings retain temperature `0`, History Filter `Off`, Message Write Policy `Legacy`, and Store Tool Audit `Disabled`. Saved Memory v1 nodes remain v1 until explicitly upgraded. The temperature control is available in both v1 and v2; the history/write/query controls require Memory v2.
|
|
153
|
+
|
|
154
|
+
### Back Up and Install
|
|
155
|
+
|
|
156
|
+
1. Back up your workflows and n8n instance configuration using your normal recovery procedure. Create current Engram exports and backend backups before changing package or node settings.
|
|
157
|
+
2. **Embedded:** preserve each workflow's graph file while writes are paused, or take a consistent Engram export. Keep the original storage directory, workflow-to-file mapping, and session/group keys. A copied workflow can have a different default storage filename; validate against a separately restored test copy rather than accidentally testing a new empty graph.
|
|
158
|
+
3. **Neo4j:** take a database backup or consistent export using your normal Neo4j recovery procedure. Keep the same database, credentials, and session/group keys for the existing deployment.
|
|
159
|
+
4. Upgrade the existing community-node installation to `n8n-nodes-engram@0.6.0`, restart n8n, refresh the editor, and confirm the installed version. Node.js 20 or newer is required by the package.
|
|
160
|
+
5. For stores already running `0.5.1`, this release requires **no storage schema migration** on either backend. Run **Engram Admin > Monitoring > Diagnostics** to confirm storage health. If upgrading from `0.4.x` or earlier, complete the existing provenance/schema migration instructions separately.
|
|
161
|
+
|
|
162
|
+
### Activate Deliberately, One Memory Workflow at a Time
|
|
163
|
+
|
|
164
|
+
Start with one backed-up direct-conversation workflow, then validate before updating the remaining Memory nodes. If it still uses Memory v1, use n8n's node upgrade action in an inactive workflow copy to adopt **Memory v2**. Preserve its intended storage and canonical session key; do not replace session keys or use display-name changes as an identity migration.
|
|
165
|
+
|
|
166
|
+
| Setting | Initial activation |
|
|
167
|
+
| --- | --- |
|
|
168
|
+
| Extraction Temperature Mode | Select **Provider Default** when the extraction model rejects temperature `0`; this truly omits the request field. Otherwise retain a mode supported by that model. |
|
|
169
|
+
| History Filter | Select **Provenance** to exclude known tool-output, monitor-summary, and audit episodes from context. |
|
|
170
|
+
| Message Write Policy | Select **Final Turns** to apply storage/extraction controls to both normal saves and native bulk tool-assisted saves. |
|
|
171
|
+
| Store Tool Audit | Keep **Disabled** initially. Enable only if audit retention is needed; retained audits stay outside conversation context under Final Turns. |
|
|
172
|
+
| Current Human Query | Map to the same current-human-message expression used by the agent prompt. The default accepts string `chatInput`, then string `input`; a different webhook shape needs an explicit mapping. |
|
|
173
|
+
| Store Human / AI Episodes | Review the intended retention; both default to Enabled in v2. |
|
|
174
|
+
| Extract from Human / AI / System and Tool Content | Human extraction defaults Enabled; AI and System/Tool extraction default Disabled. Review these when upgrading a v1 node. |
|
|
175
|
+
| Human Episode Kind | Keep **Active Human** for direct conversations; use **Passive Human** for observed/curated human ingestion. |
|
|
176
|
+
| Source Message ID / Idempotency Key | Use a stable **per-message/per-turn** identity for retry deduplication. A static session key or phone number is not a turn identity and can collapse distinct messages. |
|
|
177
|
+
|
|
178
|
+
The context window counts messages/episodes, not user turns or days. With filtering enabled, older eligible messages refill that window within **Maximum History Scan** (default 1000, maximum 10000). Load diagnostics distinguish snapshot overflow from scan-budget truncation. n8n subnode expressions can have different item-resolution behavior from regular nodes; validate mappings for independent conversations rather than assuming a batch resolves each item separately.
|
|
179
|
+
|
|
180
|
+
### Historical Artifacts: Inspect and Dry-Run First
|
|
181
|
+
|
|
182
|
+
This release does not delete historical episodes or graph facts. Provenance filtering cannot automatically prove that an unlabelled legacy JSON message is a tool artifact.
|
|
183
|
+
|
|
184
|
+
1. Use **Engram Explorer > Episode > List/Get** with the exact group, date, and provenance filters to inspect candidate records, their source identities, and `previous_episode_uuid` links. Preserve genuine human JSON, quoted content, and ambiguous messages.
|
|
185
|
+
2. For a bounded preview, use **Engram Admin > Lifecycle > Purge Episodes**, keep **Execution Mode > Dry Run**, and set the same exact group/provenance/date scope with a small **Maximum Episodes** limit. **Malformed Content Rule > Empty Assistant Output** can locate empty assistant records; inspect their neighboring episodes separately. **Content Contains** should use a distinctive reviewed marker, not generic JSON keys. Do not select **Delete** or confirm a purge as part of this upgrade. Dry-run results are preview candidates, not automatic approval for deletion or filtering.
|
|
186
|
+
3. There is no separate History Filter dry-run switch. Preview filtering in an **inactive workflow copy backed by a separate restored store**, compare its Memory load output before/after, and inspect `history.excluded_legacy`, `legacy_candidates`, `returned`, and `scan_truncated`.
|
|
187
|
+
4. If an exact legacy payload is confirmed to be an artifact, calculate its lowercase SHA256 from the **exact UTF-8 episode content**, including whitespace. Select **History Filter > Provenance and Reviewed Legacy** and add that digest to **Reviewed Legacy Content Hashes** (up to 100 comma-separated hashes). A matching hash still requires strict legacy role, adjacency, chain, and source checks. The neighboring empty assistant and reviewed payload are excluded only from context; original records and facts remain intact. Unapproved or ambiguous JSON stays visible.
|
|
188
|
+
|
|
189
|
+
### Verify Before Expanding the Rollout
|
|
190
|
+
|
|
191
|
+
- **Extraction:** inspect the Memory save/bulk-write `extraction` outcome and verify expected accepted entities/relationships in Explorer. A green overall chat execution or a valid empty extraction response alone does not prove fact creation.
|
|
192
|
+
- **Older recall:** query a known older accepted fact after its episode has fallen outside the recent-message window. Confirm the configured current query and relevant graph context, including any governance filters.
|
|
193
|
+
- **Tool-assisted conversation:** exercise a real tool, confirm the real human/final-assistant messages are retained, and verify tool results are not new human sources. Inspect bulk write and extraction diagnostics.
|
|
194
|
+
- **Filtered history:** confirm useful messages refill the window, reviewed exclusions match expectations, genuine JSON/quotes remain, and scan truncation is understood. Re-run one explicit turn identity to check retry behavior without reusing that identity for new turns.
|
|
195
|
+
|
|
196
|
+
After these checks pass, apply the intended controls to the remaining Memory nodes in stages. Extraction and persistence are not a transactional exactly-once pipeline: retrying an already-stored source does not automatically recover extraction interrupted after persistence. Storage-disabled extraction has no durable retry ledger.
|
|
197
|
+
|
|
198
|
+
### Rollback
|
|
199
|
+
|
|
200
|
+
Keep the pre-upgrade workflows, exports, and backend backups unchanged until rollout validation finishes. To roll back, pause writes, restore the saved workflow configuration, reinstall `n8n-nodes-engram@0.5.1` through the same installation method, and restart n8n. This returns the prior behavior, including its extraction-model limitations.
|
|
201
|
+
|
|
202
|
+
No store restore is required merely to undo a non-destructive history filter. However, if **Store Tool Audit** was enabled, `0.5.1` does not implement the new audit-context exclusion and may replay those new records. Review that history before downgrading; keeping `0.6.0` with the intended controls or using a separately restored pre-upgrade store may be preferable. Turning filtering off does not delete audit records.
|
|
203
|
+
|
|
204
|
+
If a store restore is necessary, use the backed-up embedded file/Engram export or your Neo4j recovery procedure while writes are paused. Reconcile messages created since the backup before replacing live data; restoring an older snapshot can discard newer conversations. Never wipe groups, trim/change session keys, or delete graph facts as an automatic rollback step.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
104
208
|
## Upgrading from v0.4.x
|
|
105
209
|
|
|
106
210
|
Version `0.5.0` adds episode provenance and governance fields. Storage migration and n8n node-version upgrades are separate steps.
|
|
@@ -184,6 +288,7 @@ On each conversation turn, Engram Memory:
|
|
|
184
288
|
| --- | --- | --- |
|
|
185
289
|
| Storage Backend | Embedded (Graphology) or Neo4j | Embedded |
|
|
186
290
|
| Knowledge Extraction | LLM-powered entity extraction | Disabled |
|
|
291
|
+
| Extraction Temperature Mode | Legacy (0), Provider Default (omit), or Custom | Legacy (0) |
|
|
187
292
|
| Store Human Episodes | Persist human messages as episodes (v2) | Enabled |
|
|
188
293
|
| Human Episode Kind | Classify human input as active or passive provenance (v2) | Active Human |
|
|
189
294
|
| Store AI Episodes | Persist assistant replies as episodes (v2) | Enabled |
|
|
@@ -191,13 +296,33 @@ On each conversation turn, Engram Memory:
|
|
|
191
296
|
| Extract from AI Messages | Allow assistant content to produce facts (v2) | Disabled |
|
|
192
297
|
| Semantic Search | Vector embeddings for hybrid search | Disabled |
|
|
193
298
|
| Graph Traversal | BFS enrichment from matched entities | Disabled |
|
|
194
|
-
| Context Window | Recent
|
|
299
|
+
| Context Window | Recent messages/episodes to include | 10 |
|
|
195
300
|
| Max Facts per Query | Facts injected as context | 10 |
|
|
196
301
|
| Min Relevance Score | Threshold for inclusion (0–1) | 0.5 |
|
|
197
302
|
| Retention Policy | Episode lifecycle management | Forever |
|
|
198
303
|
|
|
199
304
|
Existing saved Engram Memory nodes retain their original node version and behavior when the package is upgraded. Use n8n's node upgrade action on a workflow copy to adopt v2 controls. Passive ingestion workflows should select **Human Episode Kind > Passive Human**, while direct agent conversations should keep the default **Active Human** classification.
|
|
200
305
|
|
|
306
|
+
### History Filtering and Final-Turn Writes (Memory v2)
|
|
307
|
+
|
|
308
|
+
These controls are opt-in. Existing saved settings keep **History Filter > Off** and **Message Write Policy > Legacy**. Upgrade a v1 Memory node through n8n's node upgrade action on a workflow copy before adopting the v2 controls. Session keys and existing episodes are preserved.
|
|
309
|
+
|
|
310
|
+
- Select **History Filter > Provenance** to exclude tool-output, monitor-summary, and audit episodes from conversation context.
|
|
311
|
+
- Select **Provenance and Reviewed Legacy** to additionally exclude an exact reviewed legacy artifact pair: an empty assistant `[]` immediately chained to an unlabelled legacy human array of response/error objects. The human payload must match a configured **Reviewed Legacy Content Hash**, and source/chain checks must agree. Without that approval, ambiguous JSON remains. Genuine human JSON, quoted messages, and graph fact SystemMessages are retained.
|
|
312
|
+
- **Reviewed Legacy Content Hashes** accepts up to 100 comma-separated lowercase SHA256 hashes of exact UTF-8 episode content, including its whitespace. Review the original episodes before supplying hashes. Filtering changes only the context read; it does not delete records, rewrite chains, or remove graph facts.
|
|
313
|
+
|
|
314
|
+
The context window counts eligible messages. Engram captures one bounded recent-episode snapshot and scans it in local pages of 100, refilling from older eligible messages. **Maximum History Scan** defaults to 1000 and is capped at 10000; one extra prefetched episode supports boundary evidence and overflow detection. This is bounded snapshot prefetch with local paging, not backend cursor pagination. Load diagnostics show `fetched`, `examined`, `pages`, exclusion counts, and `returned`. `snapshot_overflow` means more history existed than the scan allowance; `scan_truncated` means that allowance prevented filling the window. No new appends are fetched during the scan.
|
|
315
|
+
|
|
316
|
+
Select **Message Write Policy > Final Turns** to apply the same storage, extraction, and provenance controls when n8n saves a normal turn or calls the native bulk-message tool-save path. Engram retains real human input and the final assistant reply after identified tool calls have closed. Native tool/function messages and intermediate assistant tool calls are classified distinctly and never become human input. **Store Tool Audit** optionally retains those messages as unverified tool-output episodes; they stay outside conversation context even with History Filter set to Off. Tool extraction remains a separate explicit control and is disabled by default.
|
|
317
|
+
|
|
318
|
+
Set a stable per-turn **Idempotency Key** or human **Source Message ID** to deduplicate retries across both write paths. Final-role keys are independent of intermediate tool count. Repeated identical turns without an explicit identity remain distinct. Existing stored sources are not re-extracted on an ordinary duplicate write; persistence followed by extraction is not a transactional exactly-once guarantee. If storage is disabled, extraction uses transient sources and has no durable retry ledger. Native bulk-save diagnostics report confirmed writes, duplicates, audits, skipped messages, and the extraction outcome.
|
|
319
|
+
|
|
320
|
+
### Current Query for Empty Memory Loads
|
|
321
|
+
|
|
322
|
+
Some n8n agent versions call memory loading with empty values. Configure **Current Human Query** to the same current-message expression used by the agent prompt. Its default reads string `chatInput`, then string `input`, and otherwise leaves the query empty. Explicit input passed by the agent takes precedence. Engram does not infer a current query from old history.
|
|
323
|
+
|
|
324
|
+
The expression is resolved in n8n's subnode item context when memory is supplied. Subnode expression behavior can differ from regular-node per-item evaluation; process independent conversations separately and validate mappings in your workflow. Load diagnostics expose `retrieval.query_source` (`input`, `configured`, or `none`), query availability, and the number of graph fact context messages without including query text. If no current query is available, history still loads but graph search is not attempted. Validate graph recall with a known older accepted fact beyond the recent-message window.
|
|
325
|
+
|
|
201
326
|
### Engram Explorer
|
|
202
327
|
|
|
203
328
|
> Regular node—CRUD operations on the knowledge graph.
|
|
@@ -289,6 +414,32 @@ User message + AI response
|
|
|
289
414
|
|
|
290
415
|
Extracted entities and relationships include `attributes.engram_extraction` provenance metadata with source, extraction timestamp, confidence placeholder, review status, and related episode UUIDs where available.
|
|
291
416
|
|
|
417
|
+
### Extraction Model Compatibility
|
|
418
|
+
|
|
419
|
+
**Extraction Temperature Mode** applies to every extraction stage in Engram Memory v1 and v2:
|
|
420
|
+
|
|
421
|
+
- **Legacy (0)** sends temperature `0` and preserves existing workflow behavior.
|
|
422
|
+
- **Provider Default** omits the temperature field. Select this when your model rejects custom temperatures or requires its own default.
|
|
423
|
+
- **Custom** sends the **Extraction Temperature** value. Use a finite number supported by your provider and model; supported ranges vary.
|
|
424
|
+
|
|
425
|
+
Upgrading the package alone retains Legacy (0). To resolve an unsupported-temperature error, select Provider Default explicitly in the affected Memory node and validate the workflow before activating it. No storage migration or Memory node-version upgrade is required for these settings. Engram does not automatically change models or retry rejected requests with guessed settings. Extraction still uses Chat Completions JSON-object mode; confirm that your provider and model support it.
|
|
426
|
+
|
|
427
|
+
### Extraction Outcomes
|
|
428
|
+
|
|
429
|
+
In an execution, open the Engram Memory save output and inspect `extraction`. Conversation history saves before extraction, so an overall successful conversation can still have a failed extraction outcome.
|
|
430
|
+
|
|
431
|
+
| Status | Meaning |
|
|
432
|
+
| --- | --- |
|
|
433
|
+
| `disabled` | Knowledge extraction is disabled. |
|
|
434
|
+
| `skipped` | No eligible, nonempty source messages were selected. |
|
|
435
|
+
| `succeeded` | Attempted stages completed; finding zero entities is also successful. |
|
|
436
|
+
| `partial` | An optional stage failed, malformed records were excluded, or a required stage failed after some graph changes succeeded. |
|
|
437
|
+
| `failed` | A required stage failed before any graph changes succeeded, or extraction configuration is missing. |
|
|
438
|
+
|
|
439
|
+
Outcomes include duration, stage status, confirmed mutation counts, filtered/malformed record counts, and bounded error classifications such as `unsupported_parameter`, `authentication`, `rate_limit`, and `timeout`. Update counts include metadata-only updates; edge expirations are counted separately. Partial extraction does not roll back completed graph changes. Provider error bodies and message content are excluded from extraction error diagnostics; normal n8n conversation previews still contain message content.
|
|
440
|
+
|
|
441
|
+
Extraction outcomes belong to their execution's save output. Engram Admin storage diagnostics do not provide a persistent extraction event history. A failed history preview is reported separately from the completed save. The context window counts messages, not user turns or days; graph recall operates independently of that window.
|
|
442
|
+
|
|
292
443
|
---
|
|
293
444
|
|
|
294
445
|
## Search
|
package/dist/descriptions.js
CHANGED
|
@@ -36,7 +36,7 @@ exports.contextWindowLengthProperty = {
|
|
|
36
36
|
name: 'contextWindowLength',
|
|
37
37
|
type: 'number',
|
|
38
38
|
default: 5,
|
|
39
|
-
hint: '
|
|
39
|
+
hint: 'Number of recent messages (episodes) to include, not user turns or days',
|
|
40
40
|
};
|
|
41
41
|
exports.customStoragePathProperty = {
|
|
42
42
|
displayName: 'Custom Storage Path',
|
package/dist/descriptions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptions.js","sourceRoot":"","sources":["../src/descriptions.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAoB;IAC9C,WAAW,EAAE,YAAY;IACzB,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE;QACP;YAEE,IAAI,EAAE,uCAAuC;YAC7C,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,2CAA2C;SACzD;QACD;YAEE,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,4EAA4E;SAC1F;KACF;IACD,OAAO,EAAE,WAAW;CACrB,CAAC;AAEW,QAAA,kBAAkB,GAAoB;IACjD,WAAW,EAAE,KAAK;IAClB,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,EAAE;IACX,WAAW,EAAE,kDAAkD;IAC/D,cAAc,EAAE;QACd,IAAI,EAAE;YACJ,aAAa,EAAE,CAAC,WAAW,CAAC;SAC7B;KACF;CACF,CAAC;AAEW,QAAA,2BAA2B,GAAoB;IAC1D,WAAW,EAAE,uBAAuB;IACpC,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,CAAC;IACV,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"descriptions.js","sourceRoot":"","sources":["../src/descriptions.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAoB;IAC9C,WAAW,EAAE,YAAY;IACzB,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE;QACP;YAEE,IAAI,EAAE,uCAAuC;YAC7C,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,2CAA2C;SACzD;QACD;YAEE,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,4EAA4E;SAC1F;KACF;IACD,OAAO,EAAE,WAAW;CACrB,CAAC;AAEW,QAAA,kBAAkB,GAAoB;IACjD,WAAW,EAAE,KAAK;IAClB,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,EAAE;IACX,WAAW,EAAE,kDAAkD;IAC/D,cAAc,EAAE;QACd,IAAI,EAAE;YACJ,aAAa,EAAE,CAAC,WAAW,CAAC;SAC7B;KACF;CACF,CAAC;AAEW,QAAA,2BAA2B,GAAoB;IAC1D,WAAW,EAAE,uBAAuB;IACpC,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,CAAC;IACV,IAAI,EAAE,yEAAyE;CAChF,CAAC;AAEW,QAAA,yBAAyB,GAAoB;IACxD,WAAW,EAAE,qBAAqB;IAClC,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,EAAE;IACX,WAAW,EAAE,cAAc;IAE3B,WAAW,EACT,+SAA+S;IACjT,cAAc,EAAE;QACd,IAAI,EAAE;YACJ,OAAO,EAAE,CAAC,UAAU,CAAC;SACtB;KACF;CACF,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { RequestBudget } from '../extraction/RequestBudget';
|
|
2
|
+
import { type ExtractionDiagnostics } from '../extraction/ExtractionDiagnostics';
|
|
1
3
|
export interface EmbeddingConfig {
|
|
2
4
|
apiKey: string;
|
|
3
5
|
baseUrl: string;
|
|
@@ -13,12 +15,14 @@ export interface EmbeddingResult {
|
|
|
13
15
|
};
|
|
14
16
|
}
|
|
15
17
|
export declare class EmbeddingService {
|
|
18
|
+
private diagnostics?;
|
|
19
|
+
private budget?;
|
|
16
20
|
private apiKey;
|
|
17
21
|
private baseUrl;
|
|
18
22
|
private model;
|
|
19
23
|
private dimensions;
|
|
20
24
|
private timeoutMs;
|
|
21
|
-
constructor(config: EmbeddingConfig);
|
|
25
|
+
constructor(config: EmbeddingConfig, diagnostics?: ExtractionDiagnostics | undefined, budget?: RequestBudget | undefined);
|
|
22
26
|
embed(text: string): Promise<EmbeddingResult>;
|
|
23
27
|
embedBatch(texts: string[]): Promise<EmbeddingResult[]>;
|
|
24
28
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EmbeddingService = void 0;
|
|
4
|
+
const RequestBudget_1 = require("../extraction/RequestBudget");
|
|
4
5
|
const url_1 = require("../utils/url");
|
|
6
|
+
const ExtractionDiagnostics_1 = require("../extraction/ExtractionDiagnostics");
|
|
5
7
|
class EmbeddingService {
|
|
6
|
-
constructor(config) {
|
|
8
|
+
constructor(config, diagnostics, budget) {
|
|
7
9
|
var _a;
|
|
10
|
+
this.diagnostics = diagnostics;
|
|
11
|
+
this.budget = budget;
|
|
8
12
|
this.apiKey = config.apiKey;
|
|
9
13
|
this.baseUrl = (0, url_1.normalizeHttpBaseUrl)(config.baseUrl, 'Embedding API baseUrl');
|
|
10
14
|
this.model = config.model;
|
|
@@ -16,49 +20,105 @@ class EmbeddingService {
|
|
|
16
20
|
return results[0];
|
|
17
21
|
}
|
|
18
22
|
async embedBatch(texts) {
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
19
24
|
if (texts.length === 0)
|
|
20
25
|
return [];
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
model: this.model,
|
|
24
|
-
input: texts,
|
|
25
|
-
};
|
|
26
|
-
if (this.dimensions) {
|
|
27
|
-
body.dimensions = this.dimensions;
|
|
28
|
-
}
|
|
29
|
-
const controller = new AbortController();
|
|
30
|
-
const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
31
|
-
let response;
|
|
26
|
+
const end = (_a = this.diagnostics) === null || _a === void 0 ? void 0 : _a.begin('embeddings');
|
|
27
|
+
let failed = true;
|
|
32
28
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
body
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
const url = `${this.baseUrl}/embeddings`;
|
|
30
|
+
const body = {
|
|
31
|
+
model: this.model,
|
|
32
|
+
input: texts,
|
|
33
|
+
};
|
|
34
|
+
if (this.dimensions) {
|
|
35
|
+
body.dimensions = this.dimensions;
|
|
36
|
+
}
|
|
37
|
+
const serializedBody = JSON.stringify(body);
|
|
38
|
+
const remaining = (_b = this.budget) === null || _b === void 0 ? void 0 : _b.reserve(Buffer.byteLength(serializedBody));
|
|
39
|
+
const controller = new AbortController();
|
|
40
|
+
const abort = () => controller.abort();
|
|
41
|
+
(_c = this.budget) === null || _c === void 0 ? void 0 : _c.controller.signal.addEventListener('abort', abort, { once: true });
|
|
42
|
+
const timeout = setTimeout(abort, Math.min(remaining !== null && remaining !== void 0 ? remaining : this.timeoutMs, this.timeoutMs));
|
|
43
|
+
const metric = (_d = this.diagnostics) === null || _d === void 0 ? void 0 : _d.beginRequest('embeddings');
|
|
44
|
+
try {
|
|
45
|
+
let response;
|
|
46
|
+
try {
|
|
47
|
+
response = await fetch(url, {
|
|
48
|
+
method: 'POST',
|
|
49
|
+
headers: {
|
|
50
|
+
'Content-Type': 'application/json',
|
|
51
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
52
|
+
},
|
|
53
|
+
body: serializedBody,
|
|
54
|
+
signal: controller.signal,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (this.budget)
|
|
59
|
+
throw new ExtractionDiagnostics_1.ExtractionError(controller.signal.aborted ? 'timeout' : 'network');
|
|
60
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
61
|
+
throw new Error(`Embedding API request timed out after ${this.timeoutMs}ms`);
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
metric === null || metric === void 0 ? void 0 : metric.headers();
|
|
66
|
+
if (!response.ok) {
|
|
67
|
+
const errorText = this.budget
|
|
68
|
+
? await (0, RequestBudget_1.readBoundedResponse)(response, this.budget.maxResponseBytes)
|
|
69
|
+
: await response.text();
|
|
70
|
+
if (this.budget)
|
|
71
|
+
throw new ExtractionDiagnostics_1.ExtractionError(response.status === 401 || response.status === 403
|
|
72
|
+
? 'authentication'
|
|
73
|
+
: response.status === 429
|
|
74
|
+
? 'rate_limit'
|
|
75
|
+
: response.status >= 500
|
|
76
|
+
? 'provider_server'
|
|
77
|
+
: 'invalid_request', response.status);
|
|
78
|
+
throw new Error(`Embedding API error (${response.status}): ${errorText}`);
|
|
79
|
+
}
|
|
80
|
+
const data = (this.budget
|
|
81
|
+
? JSON.parse(await (0, RequestBudget_1.readBoundedResponse)(response, this.budget.maxResponseBytes))
|
|
82
|
+
: await response.json());
|
|
83
|
+
(_e = this.budget) === null || _e === void 0 ? void 0 : _e.check();
|
|
84
|
+
if (this.budget &&
|
|
85
|
+
(!Array.isArray(data === null || data === void 0 ? void 0 : data.data) ||
|
|
86
|
+
data.data.length !== texts.length ||
|
|
87
|
+
data.data.some((item) => !item ||
|
|
88
|
+
!Number.isInteger(item.index) ||
|
|
89
|
+
item.index < 0 ||
|
|
90
|
+
item.index >= texts.length ||
|
|
91
|
+
!Array.isArray(item.embedding) ||
|
|
92
|
+
!item.embedding.length ||
|
|
93
|
+
!item.embedding.every(Number.isFinite)) ||
|
|
94
|
+
new Set(data.data.map((item) => item.index)).size !== texts.length))
|
|
95
|
+
throw new Error('Invalid embedding response');
|
|
96
|
+
const sorted = [...data.data].sort((a, b) => a.index - b.index);
|
|
97
|
+
metric === null || metric === void 0 ? void 0 : metric.end('completed', data.usage, true);
|
|
98
|
+
const results = sorted.map((item) => ({
|
|
99
|
+
embedding: item.embedding,
|
|
100
|
+
usage: data.usage,
|
|
101
|
+
}));
|
|
102
|
+
failed = false;
|
|
103
|
+
return results;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if ((_f = this.budget) === null || _f === void 0 ? void 0 : _f.controller.signal.aborted)
|
|
107
|
+
this.budget.check();
|
|
108
|
+
if (this.budget && controller.signal.aborted)
|
|
109
|
+
throw new ExtractionDiagnostics_1.ExtractionError('timeout');
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
if (failed)
|
|
114
|
+
metric === null || metric === void 0 ? void 0 : metric.end(controller.signal.aborted ? 'cancelled' : 'failed', undefined, true);
|
|
115
|
+
clearTimeout(timeout);
|
|
116
|
+
(_g = this.budget) === null || _g === void 0 ? void 0 : _g.controller.signal.removeEventListener('abort', abort);
|
|
46
117
|
}
|
|
47
|
-
throw error;
|
|
48
118
|
}
|
|
49
119
|
finally {
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
if (!response.ok) {
|
|
53
|
-
const errorText = await response.text();
|
|
54
|
-
throw new Error(`Embedding API error (${response.status}): ${errorText}`);
|
|
120
|
+
end === null || end === void 0 ? void 0 : end(failed);
|
|
55
121
|
}
|
|
56
|
-
const data = (await response.json());
|
|
57
|
-
const sorted = [...data.data].sort((a, b) => a.index - b.index);
|
|
58
|
-
return sorted.map((item) => ({
|
|
59
|
-
embedding: item.embedding,
|
|
60
|
-
usage: data.usage,
|
|
61
|
-
}));
|
|
62
122
|
}
|
|
63
123
|
}
|
|
64
124
|
exports.EmbeddingService = EmbeddingService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddingService.js","sourceRoot":"","sources":["../../src/embeddings/EmbeddingService.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"EmbeddingService.js","sourceRoot":"","sources":["../../src/embeddings/EmbeddingService.ts"],"names":[],"mappings":";;;AAAA,+DAAiF;AAMjF,sCAAoD;AACpD,+EAAkG;AAiBlG,MAAa,gBAAgB;IAO3B,YACE,MAAuB,EACf,WAAmC,EACnC,MAAsB;;QADtB,gBAAW,GAAX,WAAW,CAAwB;QACnC,WAAM,GAAN,MAAM,CAAgB;QAE9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAA,0BAAoB,EAAC,MAAM,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC;QAC7E,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,MAAA,MAAM,CAAC,SAAS,mCAAI,KAAM,CAAC;IAC9C,CAAC;IAGD,KAAK,CAAC,KAAK,CAAC,IAAY;QACtB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9C,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAGD,KAAK,CAAC,UAAU,CAAC,KAAe;;QAC9B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAElC,MAAM,GAAG,GAAG,MAAA,IAAI,CAAC,WAAW,0CAAE,KAAK,CAAC,YAAY,CAAC,CAAC;QAClD,IAA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C,CAAC;QAChB,CAAC;IACH,CAAC;CACF;AA9ID,4CA8IC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isDurableAssertion(content: string, start: number, end: number): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDurableAssertion = isDurableAssertion;
|
|
4
|
+
function isDurableAssertion(content, start, end) {
|
|
5
|
+
if (start < 0 || end <= start || end > content.length)
|
|
6
|
+
return false;
|
|
7
|
+
const text = content.slice(start, end).trim();
|
|
8
|
+
const before = content.slice(0, start).trimEnd();
|
|
9
|
+
const after = content.slice(end).trimStart();
|
|
10
|
+
if (before && !/[.!?\n]$/.test(before))
|
|
11
|
+
return false;
|
|
12
|
+
if (after && !/[.!?]$/.test(text))
|
|
13
|
+
return false;
|
|
14
|
+
if (content.includes('"') || /[“”]|^\s*>/m.test(content))
|
|
15
|
+
return false;
|
|
16
|
+
return (!text.includes('?') &&
|
|
17
|
+
!/\b(said|says|according to|hypothetical|might|maybe|not|never|false|denies|denied|without|no longer|if|unless|would|suppose|supposing|assuming|incorrect|untrue)\b|\b\w+n['’]t\b/i.test(text) &&
|
|
18
|
+
!/^\s*(what|when|where|which|who|how|can you|could you|please|tell me|show me|find me|asks?\b)/i.test(text) &&
|
|
19
|
+
!/\b(today|tomorrow|yesterday|later|next\s+(week|month|tuesday|monday|wednesday|thursday|friday|saturday|sunday)|this weekend)\b/i.test(text));
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=AssertionEvidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssertionEvidence.js","sourceRoot":"","sources":["../../src/extraction/AssertionEvidence.ts"],"names":[],"mappings":";;AACA,gDAqBC;AArBD,SAAgB,kBAAkB,CAAC,OAAe,EAAE,KAAa,EAAE,GAAW;IAC5E,IAAI,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,GAAG,OAAO,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;IACjD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC;IAE7C,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IACrD,IAAI,KAAK,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAChD,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IACvE,OAAO,CACL,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QACnB,CAAC,kLAAkL,CAAC,IAAI,CACtL,IAAI,CACL;QACD,CAAC,+FAA+F,CAAC,IAAI,CACnG,IAAI,CACL;QACD,CAAC,iIAAiI,CAAC,IAAI,CACrI,IAAI,CACL,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type EmbeddingConfig } from '../embeddings';
|
|
2
|
+
import type { IGraphStorage } from '../storage/IGraphStorage';
|
|
3
|
+
import { type ExtractionPolicyInput, type ExtractionThresholdPolicy } from '../schemas';
|
|
4
|
+
import { type LlmClientConfig } from './LlmClient';
|
|
5
|
+
import { ExtractionDiagnostics } from './ExtractionDiagnostics';
|
|
6
|
+
import type { ExtractionSource } from './ExtractionSource';
|
|
7
|
+
export declare function boundedExtract(storage: IGraphStorage, group: string, sources: ExtractionSource[], config: {
|
|
8
|
+
llm: LlmClientConfig;
|
|
9
|
+
policy?: ExtractionPolicyInput;
|
|
10
|
+
types: string[];
|
|
11
|
+
threshold?: ExtractionThresholdPolicy;
|
|
12
|
+
embeddings?: EmbeddingConfig;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
deadlineMs?: number;
|
|
15
|
+
}, diagnostics: ExtractionDiagnostics): Promise<void>;
|