@morlay/session-rdb 0.1.4 → 0.1.6
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 +4 -7
- package/dist/artifact.d.mts +2 -1
- package/dist/{src-BmogreEz.mjs → deletion-ODZFcbZm.mjs} +134 -90
- package/dist/deletion.d.mts +1 -1
- package/dist/deletion.mjs +1 -1
- package/dist/export.d.mts +1 -1
- package/dist/gc.d.mts +1 -1
- package/dist/import.d.mts +2 -2
- package/dist/import.mjs +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/log-C0q5svm7.d.mts +594 -0
- package/dist/{sqlite-YCr2-Fov.mjs → sqlite-DjOnMRh2.mjs} +73 -2
- package/dist/storage.d.mts +2 -2
- package/dist/storage.mjs +1 -2
- package/dist/testing.d.mts +2 -2
- package/dist/testing.mjs +95 -14669
- package/dist/usage.d.mts +1 -1
- package/drizzle/postgres/20261008103001_v3_schedule_tasks/migration.sql +11 -0
- package/drizzle/sqlite/20261008103000_v3_schedule_tasks/migration.sql +14 -0
- package/package.json +60 -42
- package/src/branch.ts +1 -1
- package/src/entities/v3/index.ts +4 -0
- package/src/entities/v3/schedule-tasks.ts +16 -0
- package/src/index.ts +2 -1
- package/src/schema.ts +2 -0
- package/src/sqlite.ts +5 -2
- package/src/storage-takeover/repository.ts +61 -0
- package/src/storage-takeover/storage-backend.ts +120 -42
- package/src/storage-takeover/types.ts +9 -0
- package/dist/dist-DHer1cql.mjs +0 -1531
- package/dist/invariant.d.mts +0 -6
- package/dist/invariant.mjs +0 -8
- package/dist/log-DYyxRh7j.d.mts +0 -6078
- package/dist/rolldown-runtime-EAsCxrDo.mjs +0 -14
- package/src/invariant.ts +0 -13
- package/dist/{branch-aiXPmnKC.mjs → branch-DbFW3rJX.mjs} +1 -1
package/README.md
CHANGED
|
@@ -15,19 +15,16 @@ provider 面),并接管 `ctx.sessionQuery`(全文检索 disabled)与 `$D
|
|
|
15
15
|
name: "@morlay/session-rdb"
|
|
16
16
|
config:
|
|
17
17
|
type: sqlite
|
|
18
|
-
|
|
19
|
-
# 自定义路径请用绝对路径字符串。
|
|
20
|
-
path: /absolute/path/to/sessions.sqlite
|
|
18
|
+
path: /absolute/path/to/sessions.sqlite # 自定义路径请用绝对路径;省略则由 bundle patch 的默认值兜底
|
|
21
19
|
journalMode: wal
|
|
22
20
|
busyTimeout: 5000
|
|
23
21
|
```
|
|
24
22
|
|
|
25
|
-
PostgreSQL 同理:`type: postgres` + `connectionString`(可加 `schema`,默认 `public
|
|
26
|
-
|
|
27
|
-
[设计总览](.agents/designs/20260917-设计总览.md) 的「配置门面」。
|
|
23
|
+
PostgreSQL 同理:`type: postgres` + `connectionString`(可加 `schema`,默认 `public`)。字段、默认值、装配默认值的
|
|
24
|
+
来源与「改配置由 Loader 重挂这一行生效」见[设计总览](./.agents/designs/20260917-设计总览.md)的「配置门面」。
|
|
28
25
|
|
|
29
26
|
管理面的 HTTP 通道统一挂在 `/api/morlay/v1/session` 前缀下(均为 `POST`,body `{ sessionId }` 或列表请求
|
|
30
27
|
`{ query?, includeSubagents?, page?, pageSize? }`):`/rows`(完整语料,含归档)、`/export`、`/import`、
|
|
31
28
|
`/delete`、`/gc`、`/usage`(前缀与上游分家的理由见
|
|
32
|
-
[ADR-管理面HTTP路由前缀与上游分家](
|
|
29
|
+
[ADR-管理面HTTP路由前缀与上游分家](./.agents/adrs/20260929-管理面HTTP路由前缀与上游分家.md))。旧
|
|
33
30
|
`$DSH_HOME/storages` JSON 的导入是包内 API `importStorages`(`src/import-storages.ts`,不在包出口里)。
|
package/dist/artifact.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { C as usageRowOf,
|
|
1
|
+
import { C as usageRowOf, Ft as SESSION_IMPORT_PATH, S as toJsonlArtifact, _ as sealOwnEvents, a as normalizeToCurrentShape, b as syncMeteringRanges, c as renameLegacyPtcEvents, d as repairReadView, f as repairRequestHeaders, g as scanRows, h as rowToMeta, i as needsShapeAdoption, l as repairAssistantSettlement, m as rowToEvent, n as OWN_EVENT_TYPES, o as orphanInboxSpliceSeqs, p as repairSurfaceOps, r as findSurfaceRepairs, s as recomputeReplaceProvenance, t as EventUsageRow, u as repairOrphanInboxSplices, v as sessionConflictRow, x as titleOfEventData, y as sessionInsertRow } from "./log-C0q5svm7.mjs";
|
|
2
2
|
import { SESSION_LOG_ARTIFACT_FILENAME, parseImportZip, parseJsonlArtifact, persistImport, registerSessionImport } from "./import.mjs";
|
|
3
|
+
//#endregion
|
|
3
4
|
export { EventUsageRow, OWN_EVENT_TYPES, SESSION_IMPORT_PATH, SESSION_LOG_ARTIFACT_FILENAME, findSurfaceRepairs, needsShapeAdoption, normalizeToCurrentShape, orphanInboxSpliceSeqs, parseImportZip, parseJsonlArtifact, persistImport, recomputeReplaceProvenance, registerSessionImport, renameLegacyPtcEvents, repairAssistantSettlement, repairOrphanInboxSplices, repairReadView, repairRequestHeaders, repairSurfaceOps, rowToEvent, rowToMeta, scanRows, sealOwnEvents, sessionConflictRow, sessionInsertRow, syncMeteringRanges, titleOfEventData, toJsonlArtifact, usageRowOf };
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { C as postgresTableDefs, T as WriteGuard, a as EVENT_ENCODING, c as eventDimensions, i as DEFAULT_BUSY_TIMEOUT_MS, r as createStorageRepository, t as SqliteBackend, w as toPostgresSchema } from "./sqlite-YCr2-Fov.mjs";
|
|
2
1
|
import { a as SESSION_ROWS_PATH, t as SESSION_DELETE_PATH } from "./routes-DGBlBE_I.mjs";
|
|
3
2
|
import { COUNTED_EVENT_TYPES, addActivityCount, addActivityTotals, addTokenTotals, addTotals, emptyTotals, localDayKey, registerSessionUsage } from "./usage.mjs";
|
|
4
3
|
import { S as usageRowOf, _ as sessionConflictRow, b as titleOfEventData, g as sealOwnEvents, h as scanRows, m as rowToMeta, r as needsShapeAdoption, u as repairReadView, v as sessionInsertRow, x as toJsonlArtifact } from "./log-DYxdjJ-l.mjs";
|
|
5
|
-
import { c as isLegacyVersion, o as adoptLegacyRows, s as convertLegacyRows, t as SessionBranchRdb } from "./branch-
|
|
4
|
+
import { c as isLegacyVersion, o as adoptLegacyRows, s as convertLegacyRows, t as SessionBranchRdb } from "./branch-DbFW3rJX.mjs";
|
|
6
5
|
import { registerSessionImport } from "./import.mjs";
|
|
6
|
+
import { E as WriteGuard, T as toPostgresSchema, a as EVENT_ENCODING, c as eventDimensions, i as DEFAULT_BUSY_TIMEOUT_MS, r as createStorageRepository, t as SqliteBackend, w as postgresTableDefs } from "./sqlite-DjOnMRh2.mjs";
|
|
7
7
|
import { registerSessionExport } from "./export.mjs";
|
|
8
8
|
import { registerSessionGc } from "./gc.mjs";
|
|
9
|
-
import
|
|
9
|
+
import { SESSION_FORMAT_VERSION, SessionLogOffset } from "@deepseek-ai/dsh-session";
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
|
+
import { sessionFormatLogFilename } from "@deepseek-ai/dsh-session-format";
|
|
12
|
+
import { balanceRewindPrefix } from "@morlay/session-branch";
|
|
13
|
+
import z from "@deepseek-ai/schemastery";
|
|
11
14
|
import { Pool } from "pg";
|
|
12
15
|
import { drizzle } from "drizzle-orm/node-postgres";
|
|
13
16
|
import { SessionAlreadyExistsError, SessionAlreadyOwnedError, SessionHandleClosedError, SessionPersistence, SessionPersistenceNotFoundError, SessionPersistenceRevision, SessionReadOnlyError, assertContiguous, assertVersion, materializeAppendBatch, materializeCreateHeader, validateStoredEvents } from "@deepseek-ai/dsh-session-persistence";
|
|
14
|
-
import { SESSION_FORMAT_VERSION, SessionLogOffset } from "@deepseek-ai/dsh-session";
|
|
15
|
-
import { sessionFormatLogFilename } from "@deepseek-ai/dsh-session-format";
|
|
16
17
|
import { and, desc, eq, gte, inArray, lt, notInArray, sql } from "drizzle-orm";
|
|
17
18
|
import { readdir } from "node:fs/promises";
|
|
18
19
|
import { fileURLToPath } from "node:url";
|
|
19
20
|
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
|
20
|
-
import { balanceRewindPrefix } from "@morlay/session-branch";
|
|
21
21
|
import { SessionQueryEngine, SessionQueryError } from "@deepseek-ai/dsh-session-query";
|
|
22
22
|
import { StorageError, storageBackendServiceKey } from "@deepseek-ai/dsh-storage";
|
|
23
23
|
import { Service } from "@deepseek-ai/cordis";
|
|
@@ -641,68 +641,6 @@ var PostgresBackend = class PostgresBackend {
|
|
|
641
641
|
}
|
|
642
642
|
};
|
|
643
643
|
//#endregion
|
|
644
|
-
//#region src/deletion.ts
|
|
645
|
-
const STATUS_OF_DELETION_ERROR = {
|
|
646
|
-
SESSION_NOT_FOUND: 404,
|
|
647
|
-
SESSION_NOT_ARCHIVED: 409,
|
|
648
|
-
SESSION_LIVE: 409
|
|
649
|
-
};
|
|
650
|
-
function registerSessionDeletion(ctx, persistence) {
|
|
651
|
-
ctx.inject(["webServer", "connection"], (webCtx) => {
|
|
652
|
-
const webServer = webCtx.webServer;
|
|
653
|
-
const connection = webCtx.get("connection");
|
|
654
|
-
return webCtx.effect(() => webServer.register({
|
|
655
|
-
kind: "exact",
|
|
656
|
-
path: SESSION_DELETE_PATH,
|
|
657
|
-
handler: async (req, res) => {
|
|
658
|
-
const rejection = connection.requestRejection(req);
|
|
659
|
-
if (rejection !== void 0) {
|
|
660
|
-
res.writeHead(rejection);
|
|
661
|
-
res.end(rejection === 401 ? "unauthorized" : "forbidden");
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
664
|
-
if (req.method !== "POST") {
|
|
665
|
-
res.writeHead(405, { "content-type": "application/json" });
|
|
666
|
-
res.end(JSON.stringify({ error: "method not allowed" }));
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
const chunks = [];
|
|
670
|
-
for await (const chunk of req) chunks.push(chunk);
|
|
671
|
-
let envelope;
|
|
672
|
-
try {
|
|
673
|
-
envelope = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
674
|
-
} catch {
|
|
675
|
-
res.writeHead(400, { "content-type": "application/json" });
|
|
676
|
-
res.end(JSON.stringify({ error: "request body is not JSON" }));
|
|
677
|
-
return;
|
|
678
|
-
}
|
|
679
|
-
if (typeof envelope.sessionId !== "string" || envelope.sessionId === "") {
|
|
680
|
-
res.writeHead(400, { "content-type": "application/json" });
|
|
681
|
-
res.end(JSON.stringify({ error: "missing sessionId field" }));
|
|
682
|
-
return;
|
|
683
|
-
}
|
|
684
|
-
try {
|
|
685
|
-
await persistence.deleteSession(envelope.sessionId);
|
|
686
|
-
} catch (error) {
|
|
687
|
-
if (error instanceof SessionDeletionError) {
|
|
688
|
-
res.writeHead(STATUS_OF_DELETION_ERROR[error.code], { "content-type": "application/json" });
|
|
689
|
-
res.end(JSON.stringify({
|
|
690
|
-
error: error.message,
|
|
691
|
-
code: error.code
|
|
692
|
-
}));
|
|
693
|
-
return;
|
|
694
|
-
}
|
|
695
|
-
res.writeHead(500, { "content-type": "application/json" });
|
|
696
|
-
res.end(JSON.stringify({ error: error instanceof Error ? error.message : "session deletion failed" }));
|
|
697
|
-
return;
|
|
698
|
-
}
|
|
699
|
-
res.writeHead(200, { "content-type": "application/json" });
|
|
700
|
-
res.end(JSON.stringify({ deleted: envelope.sessionId }));
|
|
701
|
-
}
|
|
702
|
-
}));
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
//#endregion
|
|
706
644
|
//#region src/rows.ts
|
|
707
645
|
const MAX_PAGE_SIZE = 200;
|
|
708
646
|
const DEFAULT_PAGE_SIZE = 20;
|
|
@@ -996,6 +934,8 @@ function lifecycleIdentityMatches(stored, expected) {
|
|
|
996
934
|
//#region src/storage-takeover/storage-backend.ts
|
|
997
935
|
const WORKSPACE_UNIT = "workspace";
|
|
998
936
|
const WORKSPACE_TABLE = "workspaces";
|
|
937
|
+
const SCHEDULE_UNIT = "schedule";
|
|
938
|
+
const SCHEDULE_TABLE = "tasks";
|
|
999
939
|
var RdbStorageBackend = class {
|
|
1000
940
|
repository;
|
|
1001
941
|
kv = { open: (descriptor) => this.openUnit(descriptor) };
|
|
@@ -1006,11 +946,9 @@ var RdbStorageBackend = class {
|
|
|
1006
946
|
}
|
|
1007
947
|
async openUnit(descriptor) {
|
|
1008
948
|
if (this.closed) throw new StorageError("closed", "rdb storage backend is closed");
|
|
1009
|
-
if (descriptor.name !== WORKSPACE_UNIT) throw new Error(`rdb storage backend serves only the '${WORKSPACE_UNIT}' domain (requested '${descriptor.name}')`);
|
|
1010
|
-
if (!descriptor.tables.includes(WORKSPACE_TABLE) || descriptor.hasGlobal !== true) throw new Error(`rdb storage backend expects the '${WORKSPACE_UNIT}' domain shape (table '${WORKSPACE_TABLE}' plus a global slot)`);
|
|
1011
949
|
if (descriptor.layout !== void 0 && descriptor.layout !== "single") throw new Error(`rdb storage backend serves only the 'single' layout (domain '${descriptor.name}' declares '${descriptor.layout}')`);
|
|
1012
950
|
if (this.open.has(descriptor.name)) throw new Error(`kv unit '${descriptor.name}' is already open (double-open is a caller bug)`);
|
|
1013
|
-
const unit =
|
|
951
|
+
const unit = this.unitFor(descriptor);
|
|
1014
952
|
this.open.set(descriptor.name, unit);
|
|
1015
953
|
try {
|
|
1016
954
|
const stored = await this.repository.readUnitVersion(descriptor.name);
|
|
@@ -1025,6 +963,17 @@ var RdbStorageBackend = class {
|
|
|
1025
963
|
});
|
|
1026
964
|
return unit;
|
|
1027
965
|
}
|
|
966
|
+
unitFor(descriptor) {
|
|
967
|
+
if (descriptor.name === WORKSPACE_UNIT) {
|
|
968
|
+
if (!descriptor.tables.includes(WORKSPACE_TABLE) || descriptor.hasGlobal !== true) throw new Error(`rdb storage backend expects the '${WORKSPACE_UNIT}' domain shape (table '${WORKSPACE_TABLE}' plus a global slot)`);
|
|
969
|
+
return new WorkspaceKvUnit(this.repository, descriptor);
|
|
970
|
+
}
|
|
971
|
+
if (descriptor.name === SCHEDULE_UNIT) {
|
|
972
|
+
if (!descriptor.tables.includes(SCHEDULE_TABLE) || descriptor.hasGlobal !== false) throw new Error(`rdb storage backend expects the '${SCHEDULE_UNIT}' domain shape (table '${SCHEDULE_TABLE}' without a global slot)`);
|
|
973
|
+
return new ScheduleKvUnit(this.repository, descriptor);
|
|
974
|
+
}
|
|
975
|
+
throw new Error(`rdb storage backend serves only the '${WORKSPACE_UNIT}' and '${SCHEDULE_UNIT}' domains (requested '${descriptor.name}')`);
|
|
976
|
+
}
|
|
1028
977
|
async close() {
|
|
1029
978
|
this.closed = true;
|
|
1030
979
|
const units = [...this.open.values()];
|
|
@@ -1032,7 +981,7 @@ var RdbStorageBackend = class {
|
|
|
1032
981
|
await Promise.all(units.map((unit) => unit.close()));
|
|
1033
982
|
}
|
|
1034
983
|
};
|
|
1035
|
-
var
|
|
984
|
+
var TrackedKvUnit = class {
|
|
1036
985
|
repository;
|
|
1037
986
|
descriptor;
|
|
1038
987
|
closed = false;
|
|
@@ -1045,6 +994,30 @@ var WorkspaceKvUnit = class {
|
|
|
1045
994
|
onClose(release) {
|
|
1046
995
|
this.onClosed = release;
|
|
1047
996
|
}
|
|
997
|
+
async close() {
|
|
998
|
+
if (this.closed) return;
|
|
999
|
+
this.closed = true;
|
|
1000
|
+
while (this.inflight.size > 0) await Promise.allSettled(this.inflight);
|
|
1001
|
+
this.onClosed?.();
|
|
1002
|
+
}
|
|
1003
|
+
async track(operation) {
|
|
1004
|
+
const settled = operation.then(() => void 0, () => void 0);
|
|
1005
|
+
this.inflight.add(settled);
|
|
1006
|
+
try {
|
|
1007
|
+
await operation;
|
|
1008
|
+
} finally {
|
|
1009
|
+
this.inflight.delete(settled);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
assertOpen() {
|
|
1013
|
+
if (this.closed) throw new StorageError("closed", `kv unit '${this.descriptor.name}' is closed`);
|
|
1014
|
+
}
|
|
1015
|
+
assertTable(table) {
|
|
1016
|
+
if (!this.tables.includes(table)) throw new Error(`unit '${this.descriptor.name}' does not declare table '${table}'`);
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
var WorkspaceKvUnit = class extends TrackedKvUnit {
|
|
1020
|
+
tables = [WORKSPACE_TABLE];
|
|
1048
1021
|
async loadAll() {
|
|
1049
1022
|
this.assertOpen();
|
|
1050
1023
|
const records = Object.create(null);
|
|
@@ -1069,26 +1042,30 @@ var WorkspaceKvUnit = class {
|
|
|
1069
1042
|
this.assertOpen();
|
|
1070
1043
|
await this.track(this.repository.writeWorkspaceState(workspaceStateOf(value)));
|
|
1071
1044
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
this.
|
|
1045
|
+
};
|
|
1046
|
+
var ScheduleKvUnit = class extends TrackedKvUnit {
|
|
1047
|
+
tables = [SCHEDULE_TABLE];
|
|
1048
|
+
async loadAll() {
|
|
1049
|
+
this.assertOpen();
|
|
1050
|
+
const records = Object.create(null);
|
|
1051
|
+
for (const { id, task } of await this.repository.listScheduleTasks()) records[id] = task;
|
|
1052
|
+
return {
|
|
1053
|
+
tables: { [SCHEDULE_TABLE]: records },
|
|
1054
|
+
global: null
|
|
1055
|
+
};
|
|
1077
1056
|
}
|
|
1078
|
-
async
|
|
1079
|
-
|
|
1080
|
-
this.
|
|
1081
|
-
|
|
1082
|
-
await operation;
|
|
1083
|
-
} finally {
|
|
1084
|
-
this.inflight.delete(settled);
|
|
1085
|
-
}
|
|
1057
|
+
async putRecord(table, key, value) {
|
|
1058
|
+
this.assertOpen();
|
|
1059
|
+
this.assertTable(table);
|
|
1060
|
+
await this.track(this.repository.putScheduleTask(key, scheduleTaskOf(value)));
|
|
1086
1061
|
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1062
|
+
async deleteRecord(table, key) {
|
|
1063
|
+
this.assertOpen();
|
|
1064
|
+
this.assertTable(table);
|
|
1065
|
+
await this.track(this.repository.deleteScheduleTask(key));
|
|
1089
1066
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1067
|
+
setGlobal(_value) {
|
|
1068
|
+
throw new Error(`unit '${this.descriptor.name}' declares no global slot`);
|
|
1092
1069
|
}
|
|
1093
1070
|
};
|
|
1094
1071
|
function workspaceRecordOf(value) {
|
|
@@ -1113,6 +1090,11 @@ function workspaceStateOf(value) {
|
|
|
1113
1090
|
...state.pendingMutation === void 0 ? {} : { pendingMutation: state.pendingMutation }
|
|
1114
1091
|
};
|
|
1115
1092
|
}
|
|
1093
|
+
function scheduleTaskOf(value) {
|
|
1094
|
+
const task = value;
|
|
1095
|
+
if (typeof task !== "object" || task === null || typeof task.sessionId !== "string" || typeof task.record !== "object" || task.record === null) throw new TypeError("schedule task does not match the stored shape");
|
|
1096
|
+
return task;
|
|
1097
|
+
}
|
|
1116
1098
|
//#endregion
|
|
1117
1099
|
//#region src/storage-takeover/index.ts
|
|
1118
1100
|
function installStorageTakeover(ctx, options) {
|
|
@@ -2171,4 +2153,66 @@ async function appendEventTail(tx, meta, events, anchor, reuse) {
|
|
|
2171
2153
|
};
|
|
2172
2154
|
}
|
|
2173
2155
|
//#endregion
|
|
2174
|
-
|
|
2156
|
+
//#region src/deletion.ts
|
|
2157
|
+
const STATUS_OF_DELETION_ERROR = {
|
|
2158
|
+
SESSION_NOT_FOUND: 404,
|
|
2159
|
+
SESSION_NOT_ARCHIVED: 409,
|
|
2160
|
+
SESSION_LIVE: 409
|
|
2161
|
+
};
|
|
2162
|
+
function registerSessionDeletion(ctx, persistence) {
|
|
2163
|
+
ctx.inject(["webServer", "connection"], (webCtx) => {
|
|
2164
|
+
const webServer = webCtx.webServer;
|
|
2165
|
+
const connection = webCtx.get("connection");
|
|
2166
|
+
return webCtx.effect(() => webServer.register({
|
|
2167
|
+
kind: "exact",
|
|
2168
|
+
path: SESSION_DELETE_PATH,
|
|
2169
|
+
handler: async (req, res) => {
|
|
2170
|
+
const rejection = connection.requestRejection(req);
|
|
2171
|
+
if (rejection !== void 0) {
|
|
2172
|
+
res.writeHead(rejection);
|
|
2173
|
+
res.end(rejection === 401 ? "unauthorized" : "forbidden");
|
|
2174
|
+
return;
|
|
2175
|
+
}
|
|
2176
|
+
if (req.method !== "POST") {
|
|
2177
|
+
res.writeHead(405, { "content-type": "application/json" });
|
|
2178
|
+
res.end(JSON.stringify({ error: "method not allowed" }));
|
|
2179
|
+
return;
|
|
2180
|
+
}
|
|
2181
|
+
const chunks = [];
|
|
2182
|
+
for await (const chunk of req) chunks.push(chunk);
|
|
2183
|
+
let envelope;
|
|
2184
|
+
try {
|
|
2185
|
+
envelope = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
2186
|
+
} catch {
|
|
2187
|
+
res.writeHead(400, { "content-type": "application/json" });
|
|
2188
|
+
res.end(JSON.stringify({ error: "request body is not JSON" }));
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
if (typeof envelope.sessionId !== "string" || envelope.sessionId === "") {
|
|
2192
|
+
res.writeHead(400, { "content-type": "application/json" });
|
|
2193
|
+
res.end(JSON.stringify({ error: "missing sessionId field" }));
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2196
|
+
try {
|
|
2197
|
+
await persistence.deleteSession(envelope.sessionId);
|
|
2198
|
+
} catch (error) {
|
|
2199
|
+
if (error instanceof SessionDeletionError) {
|
|
2200
|
+
res.writeHead(STATUS_OF_DELETION_ERROR[error.code], { "content-type": "application/json" });
|
|
2201
|
+
res.end(JSON.stringify({
|
|
2202
|
+
error: error.message,
|
|
2203
|
+
code: error.code
|
|
2204
|
+
}));
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
2207
|
+
res.writeHead(500, { "content-type": "application/json" });
|
|
2208
|
+
res.end(JSON.stringify({ error: error instanceof Error ? error.message : "session deletion failed" }));
|
|
2209
|
+
return;
|
|
2210
|
+
}
|
|
2211
|
+
res.writeHead(200, { "content-type": "application/json" });
|
|
2212
|
+
res.end(JSON.stringify({ deleted: envelope.sessionId }));
|
|
2213
|
+
}
|
|
2214
|
+
}));
|
|
2215
|
+
});
|
|
2216
|
+
}
|
|
2217
|
+
//#endregion
|
|
2218
|
+
export { SessionDeletionError as n, SessionPersistenceRdb as r, registerSessionDeletion as t };
|
package/dist/deletion.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Mt as SESSION_DELETE_PATH, et as SessionPersistenceRdb } from "./log-C0q5svm7.mjs";
|
|
2
2
|
import { Context } from "@deepseek-ai/cordis";
|
|
3
3
|
//#region src/deletion.d.ts
|
|
4
4
|
export declare function registerSessionDeletion(ctx: Context, persistence: SessionPersistenceRdb): void;
|
package/dist/deletion.mjs
CHANGED
package/dist/export.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Nt as SESSION_EXPORT_PATH, et as SessionPersistenceRdb } from "./log-C0q5svm7.mjs";
|
|
2
2
|
import { Context } from "@deepseek-ai/cordis";
|
|
3
3
|
//#region src/export.d.ts
|
|
4
4
|
export declare function registerSessionExport(ctx: Context, persistence: SessionPersistenceRdb): void;
|
package/dist/gc.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Pt as SESSION_GC_PATH, et as SessionPersistenceRdb } from "./log-C0q5svm7.mjs";
|
|
2
2
|
import { Context } from "@deepseek-ai/cordis";
|
|
3
3
|
//#region src/gc.d.ts
|
|
4
4
|
export declare function registerSessionGc(ctx: Context, persistence: SessionPersistenceRdb): void;
|
package/dist/import.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SessionStorageMetadata } from "@deepseek-ai/dsh-session-persistence";
|
|
1
|
+
import { Ft as SESSION_IMPORT_PATH, et as SessionPersistenceRdb } from "./log-C0q5svm7.mjs";
|
|
3
2
|
import { Session, SessionEvent, SessionId } from "@deepseek-ai/dsh-session";
|
|
3
|
+
import { SessionStorageMetadata } from "@deepseek-ai/dsh-session-persistence";
|
|
4
4
|
import { Context } from "@deepseek-ai/cordis";
|
|
5
5
|
//#region src/import.d.ts
|
|
6
6
|
export declare const SESSION_LOG_ARTIFACT_FILENAME = "session.jsonl";
|
package/dist/import.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as SESSION_IMPORT_PATH } from "./routes-DGBlBE_I.mjs";
|
|
2
|
-
import { i as replaceLiveSessionLog, l as restoreCatalog } from "./branch-
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { i as replaceLiveSessionLog, l as restoreCatalog } from "./branch-DbFW3rJX.mjs";
|
|
4
3
|
import { SESSION_FORMAT_VERSION, SessionLogOffset } from "@deepseek-ai/dsh-session";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { parseSessionFormatLogFilename } from "@deepseek-ai/dsh-session-format";
|
|
6
6
|
import { balanceRewindPrefix } from "@morlay/session-branch";
|
|
7
7
|
import { unzip } from "fflate";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as SessionDeletionErrorCode,
|
|
1
|
+
import { $ as SessionDeletionErrorCode, It as SESSION_ROWS_PATH, Q as SessionDeletionError, X as ProjectionCacheOptions, Y as Config, Z as ResolvedConfig, et as SessionPersistenceRdb, it as locateTurnEnd, nt as SessionBranchRdb, ot as SessionRowsItem, pt as SCHEMA_VERSION, rt as SessionBranchRdbProvider, st as SessionRowsValue, tt as SessionPersistenceRdbInternals } from "./log-C0q5svm7.mjs";
|
|
2
2
|
export { Config, ProjectionCacheOptions, ResolvedConfig, SCHEMA_VERSION, SESSION_ROWS_PATH, SessionBranchRdb, SessionBranchRdbProvider, SessionDeletionError, SessionDeletionErrorCode, SessionPersistenceRdb, SessionPersistenceRdb as default, SessionPersistenceRdbInternals, type SessionRowsItem, type SessionRowsValue, locateTurnEnd };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as SCHEMA_VERSION } from "./sqlite-YCr2-Fov.mjs";
|
|
2
1
|
import { a as SESSION_ROWS_PATH } from "./routes-DGBlBE_I.mjs";
|
|
3
|
-
import { n as
|
|
4
|
-
import {
|
|
2
|
+
import { n as SessionBranchRdbProvider, r as locateTurnEnd, t as SessionBranchRdb } from "./branch-DbFW3rJX.mjs";
|
|
3
|
+
import { o as SCHEMA_VERSION } from "./sqlite-DjOnMRh2.mjs";
|
|
4
|
+
import { n as SessionDeletionError, r as SessionPersistenceRdb } from "./deletion-ODZFcbZm.mjs";
|
|
5
5
|
export { SCHEMA_VERSION, SESSION_ROWS_PATH, SessionBranchRdb, SessionBranchRdbProvider, SessionDeletionError, SessionPersistenceRdb, SessionPersistenceRdb as default, locateTurnEnd };
|