@myagentroam/node 0.9.120 → 0.9.122
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/dist/connector.js +10 -3
- package/dist/database.js +53 -167
- package/dist/migrations/demo.js +9 -0
- package/dist/migrations/types.js +1 -0
- package/dist/migrations/v013.js +327 -0
- package/dist/runner/mar-agent/managed-run-controller.js +1 -0
- package/dist/service/conversation-template-node-service.js +2 -35
- package/dist/service/goal-mcp-server.js +7 -1
- package/dist/service/hosted-conversation-node-service.js +17 -72
- package/dist/service/workspace-change-service.js +1 -0
- package/package.json +4 -4
- package/dist/migrations/v004.js +0 -91
- package/dist/migrations/v005.js +0 -33
- package/dist/migrations/v006.js +0 -191
- package/dist/migrations/v007.js +0 -52
- package/dist/migrations/v008.js +0 -28
- package/dist/migrations/v009.js +0 -163
- package/dist/migrations/v010.js +0 -96
- package/dist/migrations/v011.js +0 -67
- package/dist/migrations/v012.js +0 -8
package/dist/migrations/v008.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const NODE_SCHEMA_VERSION_V8 = 8;
|
|
2
|
-
/** Adds hosted conversation pin metadata and its authoritative list order. */
|
|
3
|
-
export const NODE_SCHEMA_MIGRATION_V8 = String.raw `
|
|
4
|
-
ALTER TABLE hosted_conversations
|
|
5
|
-
ADD COLUMN pinned_at INTEGER CHECK (pinned_at IS NULL OR pinned_at >= 0);
|
|
6
|
-
DROP INDEX hosted_conversations_user_activity;
|
|
7
|
-
CREATE INDEX hosted_conversations_user_pin_activity
|
|
8
|
-
ON hosted_conversations(
|
|
9
|
-
user_storage_key,
|
|
10
|
-
(pinned_at IS NOT NULL) DESC,
|
|
11
|
-
last_activity_at DESC,
|
|
12
|
-
id DESC
|
|
13
|
-
);
|
|
14
|
-
`;
|
|
15
|
-
export function assertNodeSchemaV8(database) {
|
|
16
|
-
const conversationColumns = database
|
|
17
|
-
.prepare('PRAGMA table_info(hosted_conversations)')
|
|
18
|
-
.all();
|
|
19
|
-
if (!conversationColumns.some((column) => column.name === 'pinned_at'))
|
|
20
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:hosted_conversations');
|
|
21
|
-
const index = database
|
|
22
|
-
.prepare("SELECT sql FROM sqlite_master WHERE type='index' AND name='hosted_conversations_user_pin_activity'")
|
|
23
|
-
.get();
|
|
24
|
-
if (typeof index?.sql !== 'string' ||
|
|
25
|
-
!index.sql.includes('(pinned_at IS NOT NULL) DESC') ||
|
|
26
|
-
!index.sql.includes('last_activity_at DESC'))
|
|
27
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:hosted_conversations');
|
|
28
|
-
}
|
package/dist/migrations/v009.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
export const NODE_SCHEMA_VERSION_V9 = 9;
|
|
2
|
-
/**
|
|
3
|
-
* Persists title/message metadata, removes recovery states, and restores failed upgrades to the
|
|
4
|
-
* active version. This unreleased migration is the single boundary from v8.
|
|
5
|
-
*/
|
|
6
|
-
const NODE_SCHEMA_MIGRATION_V9_METADATA = String.raw `
|
|
7
|
-
ALTER TABLE hosted_conversations
|
|
8
|
-
ADD COLUMN title_source TEXT NOT NULL DEFAULT 'CUSTOM'
|
|
9
|
-
CHECK (title_source IN ('AUTO','CUSTOM'));
|
|
10
|
-
|
|
11
|
-
ALTER TABLE hosted_conversation_messages
|
|
12
|
-
ADD COLUMN user_text_present INTEGER NOT NULL DEFAULT 1
|
|
13
|
-
CHECK (user_text_present IN (0,1));
|
|
14
|
-
`;
|
|
15
|
-
export const NODE_SCHEMA_MIGRATION_V9_FINALIZE = String.raw `
|
|
16
|
-
DELETE FROM conversation_files
|
|
17
|
-
WHERE conversation_id IN (
|
|
18
|
-
SELECT id
|
|
19
|
-
FROM hosted_conversations
|
|
20
|
-
WHERE status IN ('RECOVERABLE_DELETED','DELETING')
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
DELETE FROM hosted_conversation_messages
|
|
24
|
-
WHERE conversation_id IN (
|
|
25
|
-
SELECT id
|
|
26
|
-
FROM hosted_conversations
|
|
27
|
-
WHERE status IN ('RECOVERABLE_DELETED','DELETING')
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
DELETE FROM hosted_conversations
|
|
31
|
-
WHERE status IN ('RECOVERABLE_DELETED','DELETING');
|
|
32
|
-
|
|
33
|
-
UPDATE hosted_conversations
|
|
34
|
-
SET pending_version_id = NULL,
|
|
35
|
-
status = 'ACTIVE'
|
|
36
|
-
WHERE status = 'UPGRADE_FAILED';
|
|
37
|
-
|
|
38
|
-
UPDATE conversation_template_versions
|
|
39
|
-
SET reference_count = (
|
|
40
|
-
SELECT COUNT(*)
|
|
41
|
-
FROM (
|
|
42
|
-
SELECT id AS conversation_id, active_version_id AS version_id
|
|
43
|
-
FROM hosted_conversations
|
|
44
|
-
UNION
|
|
45
|
-
SELECT id AS conversation_id, pending_version_id AS version_id
|
|
46
|
-
FROM hosted_conversations
|
|
47
|
-
WHERE pending_version_id IS NOT NULL
|
|
48
|
-
AND pending_version_id <> active_version_id
|
|
49
|
-
) AS active_references
|
|
50
|
-
WHERE active_references.version_id = conversation_template_versions.id
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
CREATE TABLE hosted_conversations_v9 (
|
|
54
|
-
id TEXT PRIMARY KEY,
|
|
55
|
-
user_storage_key TEXT NOT NULL,
|
|
56
|
-
conversation_storage_key TEXT NOT NULL,
|
|
57
|
-
client_request_id TEXT,
|
|
58
|
-
node_id TEXT NOT NULL,
|
|
59
|
-
session_id TEXT NOT NULL,
|
|
60
|
-
template_id TEXT NOT NULL,
|
|
61
|
-
template_name TEXT NOT NULL,
|
|
62
|
-
active_version_id TEXT NOT NULL REFERENCES conversation_template_versions(id),
|
|
63
|
-
pending_version_id TEXT REFERENCES conversation_template_versions(id),
|
|
64
|
-
title TEXT NOT NULL,
|
|
65
|
-
status TEXT NOT NULL CHECK (status IN ('ACTIVE','UPGRADE_PENDING')),
|
|
66
|
-
model_id TEXT NOT NULL,
|
|
67
|
-
template_deleted INTEGER NOT NULL DEFAULT 0 CHECK (template_deleted IN (0,1)),
|
|
68
|
-
used_bytes INTEGER NOT NULL DEFAULT 0 CHECK (used_bytes >= 0),
|
|
69
|
-
max_bytes INTEGER NOT NULL CHECK (max_bytes > 0),
|
|
70
|
-
created_at INTEGER NOT NULL CHECK (created_at >= 0),
|
|
71
|
-
updated_at INTEGER NOT NULL CHECK (updated_at >= 0),
|
|
72
|
-
last_activity_at INTEGER NOT NULL CHECK (last_activity_at >= 0),
|
|
73
|
-
pinned_at INTEGER CHECK (pinned_at IS NULL OR pinned_at >= 0),
|
|
74
|
-
title_source TEXT NOT NULL DEFAULT 'CUSTOM' CHECK (title_source IN ('AUTO','CUSTOM')),
|
|
75
|
-
UNIQUE (user_storage_key, conversation_storage_key),
|
|
76
|
-
UNIQUE (user_storage_key, client_request_id)
|
|
77
|
-
) STRICT;
|
|
78
|
-
|
|
79
|
-
INSERT INTO hosted_conversations_v9
|
|
80
|
-
(id,user_storage_key,conversation_storage_key,client_request_id,node_id,session_id,
|
|
81
|
-
template_id,template_name,active_version_id,pending_version_id,title,status,model_id,
|
|
82
|
-
template_deleted,used_bytes,max_bytes,created_at,updated_at,last_activity_at,pinned_at,
|
|
83
|
-
title_source)
|
|
84
|
-
SELECT id,user_storage_key,conversation_storage_key,client_request_id,node_id,session_id,
|
|
85
|
-
template_id,template_name,active_version_id,pending_version_id,title,status,model_id,
|
|
86
|
-
template_deleted,used_bytes,max_bytes,created_at,updated_at,last_activity_at,pinned_at,
|
|
87
|
-
title_source
|
|
88
|
-
FROM hosted_conversations;
|
|
89
|
-
|
|
90
|
-
DROP TABLE hosted_conversations;
|
|
91
|
-
ALTER TABLE hosted_conversations_v9 RENAME TO hosted_conversations;
|
|
92
|
-
|
|
93
|
-
CREATE INDEX hosted_conversations_user_pin_activity
|
|
94
|
-
ON hosted_conversations(
|
|
95
|
-
user_storage_key,
|
|
96
|
-
(pinned_at IS NOT NULL) DESC,
|
|
97
|
-
last_activity_at DESC,
|
|
98
|
-
id DESC
|
|
99
|
-
);
|
|
100
|
-
CREATE INDEX hosted_conversations_template
|
|
101
|
-
ON hosted_conversations(template_id, status, id);
|
|
102
|
-
`;
|
|
103
|
-
export const NODE_SCHEMA_MIGRATION_V9 = `${NODE_SCHEMA_MIGRATION_V9_METADATA}\n${NODE_SCHEMA_MIGRATION_V9_FINALIZE}`;
|
|
104
|
-
export function isDraftNodeSchemaV9(database) {
|
|
105
|
-
const conversationColumns = database
|
|
106
|
-
.prepare('PRAGMA table_info(hosted_conversations)')
|
|
107
|
-
.all();
|
|
108
|
-
const titleSource = conversationColumns.find((column) => column.name === 'title_source');
|
|
109
|
-
const conversationTable = database
|
|
110
|
-
.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name='hosted_conversations'")
|
|
111
|
-
.get();
|
|
112
|
-
const messageColumns = database
|
|
113
|
-
.prepare('PRAGMA table_info(hosted_conversation_messages)')
|
|
114
|
-
.all();
|
|
115
|
-
const userTextPresent = messageColumns.find((column) => column.name === 'user_text_present');
|
|
116
|
-
return (titleSource?.notnull === 1 &&
|
|
117
|
-
titleSource.dflt_value === "'CUSTOM'" &&
|
|
118
|
-
conversationColumns.some((column) => column.name === 'recoverable_until') &&
|
|
119
|
-
conversationColumns.some((column) => column.name === 'pinned_at') &&
|
|
120
|
-
!conversationColumns.some((column) => column.name === 'reasoning_effort') &&
|
|
121
|
-
typeof conversationTable?.sql === 'string' &&
|
|
122
|
-
conversationTable.sql.includes("status IN ('ACTIVE','UPGRADE_PENDING','UPGRADE_FAILED','RECOVERABLE_DELETED','DELETING')") &&
|
|
123
|
-
userTextPresent?.notnull === 1 &&
|
|
124
|
-
userTextPresent.dflt_value === '1');
|
|
125
|
-
}
|
|
126
|
-
export function assertNodeSchemaV9(database) {
|
|
127
|
-
const conversationColumns = database
|
|
128
|
-
.prepare('PRAGMA table_info(hosted_conversations)')
|
|
129
|
-
.all();
|
|
130
|
-
const titleSource = conversationColumns.find((column) => column.name === 'title_source');
|
|
131
|
-
if (titleSource?.notnull !== 1 ||
|
|
132
|
-
titleSource.dflt_value !== "'CUSTOM'" ||
|
|
133
|
-
conversationColumns.some((column) => column.name === 'recoverable_until'))
|
|
134
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:hosted_conversations');
|
|
135
|
-
const conversationTable = database
|
|
136
|
-
.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name='hosted_conversations'")
|
|
137
|
-
.get();
|
|
138
|
-
if (typeof conversationTable?.sql !== 'string' ||
|
|
139
|
-
!conversationTable.sql.includes("status IN ('ACTIVE','UPGRADE_PENDING')") ||
|
|
140
|
-
conversationTable.sql.includes('UPGRADE_FAILED') ||
|
|
141
|
-
conversationTable.sql.includes('RECOVERABLE_DELETED') ||
|
|
142
|
-
conversationTable.sql.includes('DELETING'))
|
|
143
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:hosted_conversations');
|
|
144
|
-
const messageColumns = database
|
|
145
|
-
.prepare('PRAGMA table_info(hosted_conversation_messages)')
|
|
146
|
-
.all();
|
|
147
|
-
const userTextPresent = messageColumns.find((column) => column.name === 'user_text_present');
|
|
148
|
-
if (userTextPresent?.notnull !== 1 || userTextPresent.dflt_value !== '1')
|
|
149
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:hosted_conversation_messages');
|
|
150
|
-
const foreignKeys = database.prepare('PRAGMA foreign_keys').get();
|
|
151
|
-
if (foreignKeys?.foreign_keys !== 1)
|
|
152
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:foreign_keys');
|
|
153
|
-
if (database.prepare('PRAGMA foreign_key_check(hosted_conversations)').get() !== undefined)
|
|
154
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:foreign_keys');
|
|
155
|
-
for (const table of ['conversation_files', 'hosted_conversation_messages']) {
|
|
156
|
-
const foreignKeys = database.prepare(`PRAGMA foreign_key_list(${table})`).all();
|
|
157
|
-
if (!foreignKeys.some((foreignKey) => foreignKey.table === 'hosted_conversations' &&
|
|
158
|
-
foreignKey.from === 'conversation_id' &&
|
|
159
|
-
foreignKey.to === 'id' &&
|
|
160
|
-
foreignKey.on_delete === 'CASCADE'))
|
|
161
|
-
throw new Error(`NODE_DATABASE_SCHEMA_INVALID:${table}`);
|
|
162
|
-
}
|
|
163
|
-
}
|
package/dist/migrations/v010.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
export const NODE_SCHEMA_VERSION_V10 = 10;
|
|
2
|
-
/** Removes persistent hosted-conversation upgrade scheduling state. */
|
|
3
|
-
export const NODE_SCHEMA_MIGRATION_V10 = String.raw `
|
|
4
|
-
UPDATE conversation_template_versions
|
|
5
|
-
SET reference_count = (
|
|
6
|
-
SELECT COUNT(*)
|
|
7
|
-
FROM hosted_conversations
|
|
8
|
-
WHERE active_version_id = conversation_template_versions.id
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
CREATE TABLE hosted_conversations_v10 (
|
|
12
|
-
id TEXT PRIMARY KEY,
|
|
13
|
-
user_storage_key TEXT NOT NULL,
|
|
14
|
-
conversation_storage_key TEXT NOT NULL,
|
|
15
|
-
client_request_id TEXT,
|
|
16
|
-
node_id TEXT NOT NULL,
|
|
17
|
-
session_id TEXT NOT NULL,
|
|
18
|
-
template_id TEXT NOT NULL,
|
|
19
|
-
template_name TEXT NOT NULL,
|
|
20
|
-
active_version_id TEXT NOT NULL REFERENCES conversation_template_versions(id),
|
|
21
|
-
title TEXT NOT NULL,
|
|
22
|
-
status TEXT NOT NULL CHECK (status IN ('ACTIVE')),
|
|
23
|
-
model_id TEXT NOT NULL,
|
|
24
|
-
template_deleted INTEGER NOT NULL DEFAULT 0 CHECK (template_deleted IN (0,1)),
|
|
25
|
-
used_bytes INTEGER NOT NULL DEFAULT 0 CHECK (used_bytes >= 0),
|
|
26
|
-
max_bytes INTEGER NOT NULL CHECK (max_bytes > 0),
|
|
27
|
-
created_at INTEGER NOT NULL CHECK (created_at >= 0),
|
|
28
|
-
updated_at INTEGER NOT NULL CHECK (updated_at >= 0),
|
|
29
|
-
last_activity_at INTEGER NOT NULL CHECK (last_activity_at >= 0),
|
|
30
|
-
pinned_at INTEGER CHECK (pinned_at IS NULL OR pinned_at >= 0),
|
|
31
|
-
title_source TEXT NOT NULL DEFAULT 'CUSTOM' CHECK (title_source IN ('AUTO','CUSTOM')),
|
|
32
|
-
UNIQUE (user_storage_key, conversation_storage_key),
|
|
33
|
-
UNIQUE (user_storage_key, client_request_id)
|
|
34
|
-
) STRICT;
|
|
35
|
-
|
|
36
|
-
INSERT INTO hosted_conversations_v10
|
|
37
|
-
(id,user_storage_key,conversation_storage_key,client_request_id,node_id,session_id,
|
|
38
|
-
template_id,template_name,active_version_id,title,status,model_id,template_deleted,
|
|
39
|
-
used_bytes,max_bytes,created_at,updated_at,last_activity_at,pinned_at,title_source)
|
|
40
|
-
SELECT id,user_storage_key,conversation_storage_key,client_request_id,node_id,session_id,
|
|
41
|
-
template_id,template_name,active_version_id,title,'ACTIVE',model_id,template_deleted,
|
|
42
|
-
used_bytes,max_bytes,created_at,updated_at,last_activity_at,pinned_at,title_source
|
|
43
|
-
FROM hosted_conversations;
|
|
44
|
-
|
|
45
|
-
DROP TABLE hosted_conversations;
|
|
46
|
-
ALTER TABLE hosted_conversations_v10 RENAME TO hosted_conversations;
|
|
47
|
-
|
|
48
|
-
CREATE INDEX hosted_conversations_user_pin_activity
|
|
49
|
-
ON hosted_conversations(
|
|
50
|
-
user_storage_key,
|
|
51
|
-
(pinned_at IS NOT NULL) DESC,
|
|
52
|
-
last_activity_at DESC,
|
|
53
|
-
id DESC
|
|
54
|
-
);
|
|
55
|
-
CREATE INDEX hosted_conversations_template
|
|
56
|
-
ON hosted_conversations(template_id, status, id);
|
|
57
|
-
`;
|
|
58
|
-
export function assertNodeSchemaV10(database) {
|
|
59
|
-
const conversationColumns = database
|
|
60
|
-
.prepare('PRAGMA table_info(hosted_conversations)')
|
|
61
|
-
.all();
|
|
62
|
-
const titleSource = conversationColumns.find((column) => column.name === 'title_source');
|
|
63
|
-
if (titleSource?.notnull !== 1 ||
|
|
64
|
-
titleSource.dflt_value !== "'CUSTOM'" ||
|
|
65
|
-
conversationColumns.some((column) => column.name === 'pending_version_id' || column.name === 'recoverable_until'))
|
|
66
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:hosted_conversations');
|
|
67
|
-
const conversationTable = database
|
|
68
|
-
.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name='hosted_conversations'")
|
|
69
|
-
.get();
|
|
70
|
-
if (typeof conversationTable?.sql !== 'string' ||
|
|
71
|
-
!conversationTable.sql.includes("status IN ('ACTIVE')") ||
|
|
72
|
-
conversationTable.sql.includes('UPGRADE_PENDING') ||
|
|
73
|
-
conversationTable.sql.includes('UPGRADE_FAILED') ||
|
|
74
|
-
conversationTable.sql.includes('RECOVERABLE_DELETED') ||
|
|
75
|
-
conversationTable.sql.includes('DELETING'))
|
|
76
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:hosted_conversations');
|
|
77
|
-
const messageColumns = database
|
|
78
|
-
.prepare('PRAGMA table_info(hosted_conversation_messages)')
|
|
79
|
-
.all();
|
|
80
|
-
const userTextPresent = messageColumns.find((column) => column.name === 'user_text_present');
|
|
81
|
-
if (userTextPresent?.notnull !== 1 || userTextPresent.dflt_value !== '1')
|
|
82
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:hosted_conversation_messages');
|
|
83
|
-
const foreignKeys = database.prepare('PRAGMA foreign_keys').get();
|
|
84
|
-
if (foreignKeys?.foreign_keys !== 1)
|
|
85
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:foreign_keys');
|
|
86
|
-
if (database.prepare('PRAGMA foreign_key_check(hosted_conversations)').get() !== undefined)
|
|
87
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:foreign_keys');
|
|
88
|
-
for (const table of ['conversation_files', 'hosted_conversation_messages']) {
|
|
89
|
-
const foreignKeys = database.prepare(`PRAGMA foreign_key_list(${table})`).all();
|
|
90
|
-
if (!foreignKeys.some((foreignKey) => foreignKey.table === 'hosted_conversations' &&
|
|
91
|
-
foreignKey.from === 'conversation_id' &&
|
|
92
|
-
foreignKey.to === 'id' &&
|
|
93
|
-
foreignKey.on_delete === 'CASCADE'))
|
|
94
|
-
throw new Error(`NODE_DATABASE_SCHEMA_INVALID:${table}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
package/dist/migrations/v011.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export const NODE_SCHEMA_VERSION_V11 = 11;
|
|
2
|
-
/** Adds the fixed localized-display marker for new hosted conversations. */
|
|
3
|
-
export const NODE_SCHEMA_MIGRATION_V11 = String.raw `
|
|
4
|
-
CREATE TABLE hosted_conversations_v11 (
|
|
5
|
-
id TEXT PRIMARY KEY,
|
|
6
|
-
user_storage_key TEXT NOT NULL,
|
|
7
|
-
conversation_storage_key TEXT NOT NULL,
|
|
8
|
-
client_request_id TEXT,
|
|
9
|
-
node_id TEXT NOT NULL,
|
|
10
|
-
session_id TEXT NOT NULL,
|
|
11
|
-
template_id TEXT NOT NULL,
|
|
12
|
-
template_name TEXT NOT NULL,
|
|
13
|
-
active_version_id TEXT NOT NULL REFERENCES conversation_template_versions(id),
|
|
14
|
-
title TEXT NOT NULL,
|
|
15
|
-
status TEXT NOT NULL CHECK (status IN ('ACTIVE')),
|
|
16
|
-
model_id TEXT NOT NULL,
|
|
17
|
-
template_deleted INTEGER NOT NULL DEFAULT 0 CHECK (template_deleted IN (0,1)),
|
|
18
|
-
used_bytes INTEGER NOT NULL DEFAULT 0 CHECK (used_bytes >= 0),
|
|
19
|
-
max_bytes INTEGER NOT NULL CHECK (max_bytes > 0),
|
|
20
|
-
created_at INTEGER NOT NULL CHECK (created_at >= 0),
|
|
21
|
-
updated_at INTEGER NOT NULL CHECK (updated_at >= 0),
|
|
22
|
-
last_activity_at INTEGER NOT NULL CHECK (last_activity_at >= 0),
|
|
23
|
-
pinned_at INTEGER CHECK (pinned_at IS NULL OR pinned_at >= 0),
|
|
24
|
-
title_source TEXT NOT NULL DEFAULT 'CUSTOM'
|
|
25
|
-
CHECK (title_source IN ('DEFAULT','AUTO','CUSTOM')),
|
|
26
|
-
UNIQUE (user_storage_key, conversation_storage_key),
|
|
27
|
-
UNIQUE (user_storage_key, client_request_id)
|
|
28
|
-
) STRICT;
|
|
29
|
-
|
|
30
|
-
INSERT INTO hosted_conversations_v11
|
|
31
|
-
(id,user_storage_key,conversation_storage_key,client_request_id,node_id,session_id,
|
|
32
|
-
template_id,template_name,active_version_id,title,status,model_id,template_deleted,
|
|
33
|
-
used_bytes,max_bytes,created_at,updated_at,last_activity_at,pinned_at,title_source)
|
|
34
|
-
SELECT id,user_storage_key,conversation_storage_key,client_request_id,node_id,session_id,
|
|
35
|
-
template_id,template_name,active_version_id,title,status,model_id,template_deleted,
|
|
36
|
-
used_bytes,max_bytes,created_at,updated_at,last_activity_at,pinned_at,title_source
|
|
37
|
-
FROM hosted_conversations;
|
|
38
|
-
|
|
39
|
-
DROP TABLE hosted_conversations;
|
|
40
|
-
ALTER TABLE hosted_conversations_v11 RENAME TO hosted_conversations;
|
|
41
|
-
|
|
42
|
-
CREATE INDEX hosted_conversations_user_pin_activity
|
|
43
|
-
ON hosted_conversations(
|
|
44
|
-
user_storage_key,
|
|
45
|
-
(pinned_at IS NOT NULL) DESC,
|
|
46
|
-
last_activity_at DESC,
|
|
47
|
-
id DESC
|
|
48
|
-
);
|
|
49
|
-
CREATE INDEX hosted_conversations_template
|
|
50
|
-
ON hosted_conversations(template_id, status, id);
|
|
51
|
-
`;
|
|
52
|
-
export function assertNodeSchemaV11(database) {
|
|
53
|
-
const conversationColumns = database
|
|
54
|
-
.prepare('PRAGMA table_info(hosted_conversations)')
|
|
55
|
-
.all();
|
|
56
|
-
const titleSource = conversationColumns.find((column) => column.name === 'title_source');
|
|
57
|
-
const conversationTable = database
|
|
58
|
-
.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name='hosted_conversations'")
|
|
59
|
-
.get();
|
|
60
|
-
if (titleSource?.notnull !== 1 ||
|
|
61
|
-
titleSource.dflt_value !== "'CUSTOM'" ||
|
|
62
|
-
typeof conversationTable?.sql !== 'string' ||
|
|
63
|
-
!conversationTable.sql.includes("title_source IN ('DEFAULT','AUTO','CUSTOM')"))
|
|
64
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:hosted_conversations');
|
|
65
|
-
if (database.prepare('PRAGMA foreign_key_check(hosted_conversations)').get() !== undefined)
|
|
66
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:foreign_keys');
|
|
67
|
-
}
|
package/dist/migrations/v012.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export const NODE_SCHEMA_VERSION_V12 = 12;
|
|
2
|
-
export const NODE_SCHEMA_MIGRATION_V12 = 'ALTER TABLE workspaces ADD COLUMN preserve_git_config INTEGER NOT NULL DEFAULT 1 CHECK (preserve_git_config IN (0,1));';
|
|
3
|
-
export function assertNodeSchemaV12(database) {
|
|
4
|
-
const columns = database.prepare('PRAGMA table_info(workspaces)').all();
|
|
5
|
-
const column = columns.find((value) => value.name === 'preserve_git_config');
|
|
6
|
-
if (column?.notnull !== 1 || column.dflt_value !== '1')
|
|
7
|
-
throw new Error('NODE_DATABASE_SCHEMA_INVALID:workspaces');
|
|
8
|
-
}
|