@zhanguym/chatroom 1.3.2 → 1.3.3
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.
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { agentSessionsSchema, DATABASE_SCHEMA, WORKSPACES_SCHEMA, } from "./schema.js";
|
|
3
3
|
const SCHEMA_VERSION = 1;
|
|
4
|
+
const LEGACY_SESSION_COLUMNS = [
|
|
5
|
+
"id",
|
|
6
|
+
"workspace_root",
|
|
7
|
+
"provider",
|
|
8
|
+
"status",
|
|
9
|
+
"created_at",
|
|
10
|
+
"updated_at",
|
|
11
|
+
];
|
|
4
12
|
export function initializeDatabase(database) {
|
|
5
13
|
const version = database.prepare("PRAGMA user_version").get().user_version;
|
|
6
|
-
if (version > SCHEMA_VERSION)
|
|
7
|
-
throw new Error(`Unsupported newer ChatRoom database schema: ${version}`);
|
|
8
14
|
const columns = database
|
|
9
15
|
.prepare("PRAGMA table_info(agent_sessions)")
|
|
10
16
|
.all();
|
|
11
17
|
const legacySessions = columns.some((column) => column.name === "workspace_root");
|
|
18
|
+
const recognizedLegacySessions = columns.length === LEGACY_SESSION_COLUMNS.length &&
|
|
19
|
+
columns.every((column, index) => column.name === LEGACY_SESSION_COLUMNS[index]);
|
|
20
|
+
// Older installations can have user_version=2 while still retaining the
|
|
21
|
+
// original 1.2.0 agent_sessions layout. Accept that specific layout only;
|
|
22
|
+
// never downgrade an unknown newer database.
|
|
23
|
+
if (version > SCHEMA_VERSION && !(version === 2 && recognizedLegacySessions))
|
|
24
|
+
throw new Error(`Unsupported newer ChatRoom database schema: ${version}`);
|
|
25
|
+
if (legacySessions && !recognizedLegacySessions)
|
|
26
|
+
throw new Error("Unrecognized ChatRoom agent_sessions schema");
|
|
12
27
|
if (columns.length > 0 &&
|
|
13
28
|
!legacySessions &&
|
|
14
29
|
!columns.some((column) => column.name === "workspace_id"))
|
package/dist/native/macos/ChatRoomComputerHelper.app/Contents/MacOS/chatroom-computer-helper
CHANGED
|
Binary file
|
|
Binary file
|