@axiom-lattice/local-stores 3.1.12 → 3.1.14
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +16 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/LocalProjectRoomStores.test.ts +17 -0
- package/src/stores/LocalProjectRoomMessageStore.ts +19 -0
- package/src/stores/project-room-schema.ts +16 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/local-stores@3.1.
|
|
2
|
+
> @axiom-lattice/local-stores@3.1.14 build /home/runner/work/agentic/agentic/packages/local-stores
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts --sourcemap
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
[34mCLI[39m Target: es2020
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
12
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[
|
|
13
|
-
[32mESM[39m ⚡️ Build success in
|
|
14
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
15
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
16
|
-
[32mCJS[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m223.79 KB[39m
|
|
12
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m410.00 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 451ms
|
|
14
|
+
[32mCJS[39m [1mdist/index.js [22m[32m228.32 KB[39m
|
|
15
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m413.67 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 453ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m41.
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m41.
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 12478ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m41.91 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m41.91 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @axiom-lattice/local-stores
|
|
2
2
|
|
|
3
|
+
## 3.1.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [693a1ab]
|
|
8
|
+
- Updated dependencies [d36a7b6]
|
|
9
|
+
- @axiom-lattice/protocols@4.3.0
|
|
10
|
+
- @axiom-lattice/core@4.2.14
|
|
11
|
+
|
|
12
|
+
## 3.1.13
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [669fadb]
|
|
17
|
+
- @axiom-lattice/core@4.2.13
|
|
18
|
+
|
|
3
19
|
## 3.1.12
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -365,6 +365,17 @@ declare class LocalProjectRoomMessageStore implements ProjectRoomMessageStore {
|
|
|
365
365
|
after: Date;
|
|
366
366
|
excludeAuthorUserId?: string;
|
|
367
367
|
}): Promise<number>;
|
|
368
|
+
/**
|
|
369
|
+
* Deletes one bounded batch of chat messages older than a horizon.
|
|
370
|
+
*
|
|
371
|
+
* @param input Exclusive upper time bound and requested batch size (clamped to 1..1000).
|
|
372
|
+
* @returns The number of deleted rows.
|
|
373
|
+
* @remarks Only `source: "user" | "agent"` rows are eligible; task/system events are retained.
|
|
374
|
+
*/
|
|
375
|
+
deleteChatOlderThan(input: {
|
|
376
|
+
before: Date;
|
|
377
|
+
limit: number;
|
|
378
|
+
}): Promise<number>;
|
|
368
379
|
private insert;
|
|
369
380
|
private byId;
|
|
370
381
|
private byKey;
|
package/dist/index.d.ts
CHANGED
|
@@ -365,6 +365,17 @@ declare class LocalProjectRoomMessageStore implements ProjectRoomMessageStore {
|
|
|
365
365
|
after: Date;
|
|
366
366
|
excludeAuthorUserId?: string;
|
|
367
367
|
}): Promise<number>;
|
|
368
|
+
/**
|
|
369
|
+
* Deletes one bounded batch of chat messages older than a horizon.
|
|
370
|
+
*
|
|
371
|
+
* @param input Exclusive upper time bound and requested batch size (clamped to 1..1000).
|
|
372
|
+
* @returns The number of deleted rows.
|
|
373
|
+
* @remarks Only `source: "user" | "agent"` rows are eligible; task/system events are retained.
|
|
374
|
+
*/
|
|
375
|
+
deleteChatOlderThan(input: {
|
|
376
|
+
before: Date;
|
|
377
|
+
limit: number;
|
|
378
|
+
}): Promise<number>;
|
|
368
379
|
private insert;
|
|
369
380
|
private byId;
|
|
370
381
|
private byKey;
|
package/dist/index.js
CHANGED
|
@@ -888,6 +888,8 @@ CREATE UNIQUE INDEX IF NOT EXISTS uq_lt_project_room_messages_idempotency
|
|
|
888
888
|
ON lt_project_room_messages (tenant_id, room_id, idempotency_key) WHERE idempotency_key IS NOT NULL;
|
|
889
889
|
CREATE INDEX IF NOT EXISTS idx_lt_project_room_messages_room_created
|
|
890
890
|
ON lt_project_room_messages (tenant_id, room_id, created_at DESC, id DESC);
|
|
891
|
+
CREATE INDEX IF NOT EXISTS idx_lt_project_room_messages_chat_created
|
|
892
|
+
ON lt_project_room_messages (created_at) WHERE source IN ('user','agent');
|
|
891
893
|
CREATE TABLE IF NOT EXISTS lt_project_room_read_states (
|
|
892
894
|
tenant_id TEXT NOT NULL, room_id TEXT NOT NULL, user_id TEXT NOT NULL,
|
|
893
895
|
last_read_at TEXT NOT NULL, updated_at TEXT NOT NULL,
|
|
@@ -1044,6 +1046,25 @@ function ensureProjectRoomSchema(db) {
|
|
|
1044
1046
|
}
|
|
1045
1047
|
}
|
|
1046
1048
|
validateProjectRoomSchema(db);
|
|
1049
|
+
const hasRetentionIndex = rows(db, "SELECT name FROM sqlite_master WHERE type = 'index' AND name = 'idx_lt_project_room_messages_chat_created'").length > 0;
|
|
1050
|
+
if (!hasRetentionIndex) {
|
|
1051
|
+
raw.exec("BEGIN IMMEDIATE");
|
|
1052
|
+
try {
|
|
1053
|
+
raw.exec("CREATE INDEX IF NOT EXISTS idx_lt_project_room_messages_chat_created ON lt_project_room_messages (created_at) WHERE source IN ('user','agent');");
|
|
1054
|
+
raw.run(
|
|
1055
|
+
"INSERT INTO lattice_schema_migrations (store_name, name, version, applied_at) VALUES (?, ?, ?, ?)",
|
|
1056
|
+
["project_room", "add_project_room_message_retention_index", 3, (/* @__PURE__ */ new Date()).toISOString()]
|
|
1057
|
+
);
|
|
1058
|
+
raw.exec("COMMIT");
|
|
1059
|
+
db.save();
|
|
1060
|
+
} catch (error) {
|
|
1061
|
+
try {
|
|
1062
|
+
raw.exec("ROLLBACK");
|
|
1063
|
+
} catch {
|
|
1064
|
+
}
|
|
1065
|
+
throw error;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1047
1068
|
marked[schemaMarker] = true;
|
|
1048
1069
|
return;
|
|
1049
1070
|
}
|
|
@@ -1510,6 +1531,26 @@ var LocalProjectRoomMessageStore = class {
|
|
|
1510
1531
|
return !(record(parsed) && parsed.type === "human" && parsed.userId === input.excludeAuthorUserId);
|
|
1511
1532
|
}).length;
|
|
1512
1533
|
}
|
|
1534
|
+
/**
|
|
1535
|
+
* Deletes one bounded batch of chat messages older than a horizon.
|
|
1536
|
+
*
|
|
1537
|
+
* @param input Exclusive upper time bound and requested batch size (clamped to 1..1000).
|
|
1538
|
+
* @returns The number of deleted rows.
|
|
1539
|
+
* @remarks Only `source: "user" | "agent"` rows are eligible; task/system events are retained.
|
|
1540
|
+
*/
|
|
1541
|
+
async deleteChatOlderThan(input) {
|
|
1542
|
+
if (!validDate(input.before)) throw new RangeError("Project room message retention horizon date is invalid");
|
|
1543
|
+
const limit = Math.min(1e3, Math.max(1, Math.trunc(Number.isFinite(input.limit) ? input.limit : 1)));
|
|
1544
|
+
return transaction(this.db, () => write(
|
|
1545
|
+
this.db,
|
|
1546
|
+
`DELETE FROM lt_project_room_messages WHERE rowid IN (
|
|
1547
|
+
SELECT rowid FROM lt_project_room_messages
|
|
1548
|
+
WHERE created_at < ? AND source IN ('user','agent')
|
|
1549
|
+
ORDER BY created_at ASC LIMIT ?
|
|
1550
|
+
)`,
|
|
1551
|
+
[input.before.toISOString(), limit]
|
|
1552
|
+
));
|
|
1553
|
+
}
|
|
1513
1554
|
insert(input, idempotent) {
|
|
1514
1555
|
return transaction(this.db, () => {
|
|
1515
1556
|
if (idempotent && input.idempotencyKey) {
|