-
-
Notifications
You must be signed in to change notification settings - Fork 372
Expand file tree
/
Copy pathschema.ts
More file actions
124 lines (116 loc) · 4.42 KB
/
Copy pathschema.ts
File metadata and controls
124 lines (116 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import { index, integer, primaryKey, sqliteTable, text } from "drizzle-orm/sqlite-core";
export const workspaceSessions = sqliteTable(
"workspace_sessions",
{
id: text("id").primaryKey(),
root: text("root").notNull(),
status: text("status").notNull().default("active"),
mode: text("mode").notNull().default("checkout"),
sourceRoot: text("source_root"),
baseRef: text("base_ref"),
baseSha: text("base_sha"),
managed: text("managed").notNull().default("false"),
createdAt: text("created_at").notNull(),
lastUsedAt: text("last_used_at").notNull(),
},
(table) => [
index("workspace_sessions_root_idx").on(table.root, table.lastUsedAt),
index("workspace_sessions_status_idx").on(table.status, table.lastUsedAt),
],
);
export const loadedAgentFiles = sqliteTable(
"loaded_agent_files",
{
workspaceSessionId: text("workspace_session_id")
.notNull()
.references(() => workspaceSessions.id, { onDelete: "cascade" }),
path: text("path").notNull(),
contentHash: text("content_hash").notNull(),
content: text("content").notNull(),
loadedAt: text("loaded_at").notNull(),
lastSeenAt: text("last_seen_at").notNull(),
},
(table) => [
primaryKey({ columns: [table.workspaceSessionId, table.path] }),
index("loaded_agent_files_path_idx").on(table.path),
],
);
export const workspaceConversationBindings = sqliteTable(
"workspace_conversation_bindings",
{
conversationScopeHash: text("conversation_scope_hash").notNull(),
targetKey: text("target_key").notNull(),
workspaceSessionId: text("workspace_session_id")
.notNull()
.references(() => workspaceSessions.id, { onDelete: "cascade" }),
createdAt: text("created_at").notNull(),
lastUsedAt: text("last_used_at").notNull(),
},
(table) => [
primaryKey({ columns: [table.conversationScopeHash, table.targetKey] }),
index("workspace_conversation_bindings_workspace_idx").on(table.workspaceSessionId),
],
);
export const oauthClients = sqliteTable(
"oauth_clients",
{
clientId: text("client_id").primaryKey(),
clientJson: text("client_json").notNull(),
issuedAt: integer("issued_at").notNull(),
},
);
export const oauthAccessTokens = sqliteTable(
"oauth_access_tokens",
{
tokenHash: text("token_hash").primaryKey(),
clientId: text("client_id")
.notNull()
.references(() => oauthClients.clientId, { onDelete: "cascade" }),
scopesJson: text("scopes_json").notNull(),
expiresAt: integer("expires_at").notNull(),
resource: text("resource"),
},
);
export const oauthRefreshTokens = sqliteTable(
"oauth_refresh_tokens",
{
tokenHash: text("token_hash").primaryKey(),
clientId: text("client_id")
.notNull()
.references(() => oauthClients.clientId, { onDelete: "cascade" }),
scopesJson: text("scopes_json").notNull(),
expiresAt: integer("expires_at").notNull(),
resource: text("resource"),
},
);
export const localAgentSessions = sqliteTable(
"local_agent_sessions",
{
id: text("id").primaryKey(),
workspaceId: text("workspace_id"),
workspaceRoot: text("workspace_root").notNull(),
profileName: text("profile_name").notNull(),
provider: text("provider").notNull(),
model: text("model"),
thinking: text("thinking"),
providerSessionId: text("provider_session_id"),
status: text("status").notNull(),
latestResponse: text("latest_response"),
error: text("error"),
createdAt: text("created_at").notNull(),
updatedAt: text("updated_at").notNull(),
},
(table) => [
index("local_agent_sessions_workspace_id_idx").on(table.workspaceId, table.updatedAt),
index("local_agent_sessions_workspace_root_idx").on(table.workspaceRoot, table.updatedAt),
index("local_agent_sessions_provider_session_id_idx").on(table.providerSessionId),
],
);
export type WorkspaceSessionRow = typeof workspaceSessions.$inferSelect;
export type NewWorkspaceSessionRow = typeof workspaceSessions.$inferInsert;
export type LoadedAgentFileRow = typeof loadedAgentFiles.$inferSelect;
export type NewLoadedAgentFileRow = typeof loadedAgentFiles.$inferInsert;
export type WorkspaceConversationBindingRow = typeof workspaceConversationBindings.$inferSelect;
export type NewWorkspaceConversationBindingRow = typeof workspaceConversationBindings.$inferInsert;
export type LocalAgentSessionRow = typeof localAgentSessions.$inferSelect;
export type NewLocalAgentSessionRow = typeof localAgentSessions.$inferInsert;