@equationalapplications/core-llm-wiki 4.8.0 → 4.10.1
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 +23 -6
- package/dist/{chunk-2FGDZKC2.mjs → chunk-6FWG2DG4.mjs} +2 -2
- package/dist/chunk-6FWG2DG4.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +45 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -10
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-hfpeX01Q.d.mts → testing-CDIDE4Jd.d.mts} +31 -2
- package/dist/{testing-hfpeX01Q.d.ts → testing-CDIDE4Jd.d.ts} +31 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +24 -2
- package/dist/chunk-2FGDZKC2.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MemoryBundle, F as FormatContextOptions, a as MemoryDump, b as FormattedMemoryDump, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-
|
|
2
|
-
export { E as EntityStatus, d as ExtractedFact, e as ExtractedTask, H as HOOK_TIMEOUT_MARKER, L as LLMProvider, P as PromptOverrides, f as PromptService, g as PrunePartialFailureError, V as VectorRanker, h as VectorRankerFallback, i as VectorRankerRankArgs, j as VectorRankerSemanticResult, k as WikiBusyError, l as WikiBusyOperation, m as WikiCheckpoint, n as WikiConfig, o as WikiEvent, p as WikiFact, q as WikiMemoryTestAccess, r as WikiTask } from './testing-
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, a as MemoryDump, b as FormattedMemoryDump, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-CDIDE4Jd.js';
|
|
2
|
+
export { E as EntityStatus, d as ExtractedFact, e as ExtractedTask, H as HOOK_TIMEOUT_MARKER, L as LLMProvider, P as PromptOverrides, f as PromptService, g as PrunePartialFailureError, V as VectorRanker, h as VectorRankerFallback, i as VectorRankerRankArgs, j as VectorRankerSemanticResult, k as WikiBusyError, l as WikiBusyOperation, m as WikiCheckpoint, n as WikiConfig, o as WikiEvent, p as WikiFact, q as WikiMemoryTestAccess, r as WikiOutboxEvent, s as WikiTask } from './testing-CDIDE4Jd.js';
|
|
3
3
|
import 'minisearch';
|
|
4
4
|
|
|
5
5
|
declare function formatContext(bundle: MemoryBundle, options?: FormatContextOptions): string;
|
package/dist/index.js
CHANGED
|
@@ -89,6 +89,9 @@ async function setupDatabase(db, prefix) {
|
|
|
89
89
|
|
|
90
90
|
CREATE INDEX IF NOT EXISTS ${prefix}outbox_entity_id_created_at
|
|
91
91
|
ON ${prefix}outbox (entity_id, created_at);
|
|
92
|
+
|
|
93
|
+
CREATE INDEX IF NOT EXISTS ${prefix}outbox_created_at
|
|
94
|
+
ON ${prefix}outbox (created_at);
|
|
92
95
|
`);
|
|
93
96
|
}
|
|
94
97
|
|
|
@@ -927,12 +930,18 @@ function generateId(prefix = "") {
|
|
|
927
930
|
|
|
928
931
|
// src/repositories/OutboxRepository.ts
|
|
929
932
|
var OutboxRepository = class extends BaseRepository {
|
|
933
|
+
constructor(db, prefix, enableOutbox = false) {
|
|
934
|
+
super(db, prefix);
|
|
935
|
+
this.enableOutbox = enableOutbox;
|
|
936
|
+
}
|
|
930
937
|
/**
|
|
931
938
|
* Insert a new outbox event within the provided transaction.
|
|
939
|
+
* No-op when enableOutbox is false.
|
|
932
940
|
* `tx` is required — callers must always pass the active transaction
|
|
933
941
|
* so the write is atomic with the main table mutation.
|
|
934
942
|
*/
|
|
935
943
|
async push(params, tx) {
|
|
944
|
+
if (!this.enableOutbox) return;
|
|
936
945
|
const executor = this.getExecutor(tx);
|
|
937
946
|
const id = generateId("out_");
|
|
938
947
|
const now = Date.now();
|
|
@@ -943,12 +952,12 @@ var OutboxRepository = class extends BaseRepository {
|
|
|
943
952
|
);
|
|
944
953
|
}
|
|
945
954
|
/**
|
|
946
|
-
* Fetch pending outbox rows ordered by created_at ASC.
|
|
955
|
+
* Fetch pending outbox rows ordered by created_at ASC, rowid ASC.
|
|
947
956
|
* Reads directly from `this.db` (not a transaction).
|
|
948
957
|
*/
|
|
949
958
|
async fetchPending(limit = 50) {
|
|
950
959
|
return this.db.getAllAsync(
|
|
951
|
-
`SELECT * FROM ${this.prefix}outbox ORDER BY created_at ASC LIMIT ?`,
|
|
960
|
+
`SELECT * FROM ${this.prefix}outbox ORDER BY created_at ASC, rowid ASC LIMIT ?`,
|
|
952
961
|
[limit]
|
|
953
962
|
);
|
|
954
963
|
}
|
|
@@ -959,11 +968,15 @@ var OutboxRepository = class extends BaseRepository {
|
|
|
959
968
|
*/
|
|
960
969
|
async acknowledge(ids) {
|
|
961
970
|
if (ids.length === 0) return;
|
|
962
|
-
const
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
971
|
+
const chunkSize = 500;
|
|
972
|
+
for (let i = 0; i < ids.length; i += chunkSize) {
|
|
973
|
+
const chunk = ids.slice(i, i + chunkSize);
|
|
974
|
+
const placeholders = chunk.map(() => "?").join(", ");
|
|
975
|
+
await this.db.runAsync(
|
|
976
|
+
`DELETE FROM ${this.prefix}outbox WHERE id IN (${placeholders})`,
|
|
977
|
+
chunk
|
|
978
|
+
);
|
|
979
|
+
}
|
|
967
980
|
}
|
|
968
981
|
};
|
|
969
982
|
|
|
@@ -3951,7 +3964,7 @@ var WikiMemory = class {
|
|
|
3951
3964
|
this.db = db;
|
|
3952
3965
|
this.options = options;
|
|
3953
3966
|
this.prefix = options.config?.tablePrefix || "llm_wiki_";
|
|
3954
|
-
this.outboxRepo = new OutboxRepository(db, this.prefix);
|
|
3967
|
+
this.outboxRepo = new OutboxRepository(db, this.prefix, !!options.config?.enableOutbox);
|
|
3955
3968
|
this.entryRepo = new EntryRepository(db, this.prefix, this.outboxRepo);
|
|
3956
3969
|
this.taskRepo = new TaskRepository(db, this.prefix, this.outboxRepo);
|
|
3957
3970
|
this.eventRepo = new EventRepository(db, this.prefix);
|
|
@@ -4150,6 +4163,30 @@ var WikiMemory = class {
|
|
|
4150
4163
|
async ingestDocument(entityId, params) {
|
|
4151
4164
|
return this.ingestionService.ingestDocument(entityId, params);
|
|
4152
4165
|
}
|
|
4166
|
+
/**
|
|
4167
|
+
* Returns up to `limit` unprocessed outbox events, oldest first.
|
|
4168
|
+
* Works regardless of enableOutbox value — allows draining after disabling.
|
|
4169
|
+
*/
|
|
4170
|
+
async getUnprocessedOutboxEvents(limit = 100) {
|
|
4171
|
+
if (Number.isFinite(limit) && limit <= 0) return [];
|
|
4172
|
+
const safeLimit = Number.isFinite(limit) && limit >= 1 ? Math.trunc(limit) : 100;
|
|
4173
|
+
const rows = await this.outboxRepo.fetchPending(safeLimit);
|
|
4174
|
+
return rows.map((row) => {
|
|
4175
|
+
let payload = null;
|
|
4176
|
+
try {
|
|
4177
|
+
payload = JSON.parse(row.payload);
|
|
4178
|
+
} catch {
|
|
4179
|
+
}
|
|
4180
|
+
return { ...row, payload };
|
|
4181
|
+
});
|
|
4182
|
+
}
|
|
4183
|
+
/**
|
|
4184
|
+
* Deletes the given event IDs from the outbox table.
|
|
4185
|
+
* Call after successfully committing events to the external system.
|
|
4186
|
+
*/
|
|
4187
|
+
async markOutboxEventsProcessed(eventIds) {
|
|
4188
|
+
await this.outboxRepo.acknowledge(eventIds);
|
|
4189
|
+
}
|
|
4153
4190
|
};
|
|
4154
4191
|
_testAccessNonTestEnvWarned = new WeakMap();
|
|
4155
4192
|
|