larness 0.7.0 → 0.7.1

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.
Files changed (39) hide show
  1. package/apps/server/dist/cli.js +4 -4
  2. package/apps/server/dist/{lifecycle-0-9eT-gl.js → lifecycle-KNpzUqgr.js} +29 -11
  3. package/apps/server/drizzle/0001_auth.sql +109 -109
  4. package/apps/server/drizzle/0002_projects.sql +12 -12
  5. package/apps/server/drizzle/0003_workspace.sql +80 -80
  6. package/apps/server/drizzle/0004_models.sql +30 -30
  7. package/apps/server/drizzle/0005_resources.sql +54 -54
  8. package/apps/server/drizzle/0006_commands.sql +23 -23
  9. package/apps/server/drizzle/0007_terminals.sql +41 -41
  10. package/apps/server/drizzle/0008_resource_actions.sql +23 -23
  11. package/apps/server/drizzle/0010_services.sql +31 -31
  12. package/apps/web/dist/assets/{FileEditor-DvUvGBju.js → FileEditor-Cbzk-DmS.js} +1 -1
  13. package/apps/web/dist/assets/{FileViewer-DuLi65JA.js → FileViewer-DTTdGSZE.js} +1 -1
  14. package/apps/web/dist/assets/{cssMode-BFtqV8eS.js → cssMode-B1l_VoIr.js} +1 -1
  15. package/apps/web/dist/assets/{editor.api-B-Hf6DWT.js → editor.api-HTScrQO7.js} +1 -1
  16. package/apps/web/dist/assets/{freemarker2-QsBG6rLF.js → freemarker2-DhqUgB8y.js} +1 -1
  17. package/apps/web/dist/assets/{handlebars-BIDqo3ET.js → handlebars-BKiIG0Ab.js} +1 -1
  18. package/apps/web/dist/assets/{html-BoeVeWBr.js → html-X5Kfon6v.js} +1 -1
  19. package/apps/web/dist/assets/{htmlMode-pBOumAql.js → htmlMode-DfGydjmC.js} +1 -1
  20. package/apps/web/dist/assets/{index-BcXxWUCA.js → index-fFmmQJpA.js} +2 -2
  21. package/apps/web/dist/assets/{javascript-z49fO24y.js → javascript-Cl2c5f-8.js} +1 -1
  22. package/apps/web/dist/assets/{jsonMode-CcjrUe-N.js → jsonMode-BcMYLYO6.js} +1 -1
  23. package/apps/web/dist/assets/{liquid-Bel5uheg.js → liquid-CdSt757W.js} +1 -1
  24. package/apps/web/dist/assets/{lspLanguageFeatures-BqS1Q85I.js → lspLanguageFeatures-CkEij87I.js} +1 -1
  25. package/apps/web/dist/assets/main-CBrJksrH.css +1 -0
  26. package/apps/web/dist/assets/{main-B0YUBq2Q.js → main-CzIrOqUk.js} +5 -5
  27. package/apps/web/dist/assets/{mdx-m5Iaur5H.js → mdx-DMxSoCwm.js} +1 -1
  28. package/apps/web/dist/assets/{monaco-b438wjl8.js → monaco-_0qbFB9V.js} +3 -3
  29. package/apps/web/dist/assets/{python-tC-5HtXS.js → python-B1cu1eP-.js} +1 -1
  30. package/apps/web/dist/assets/{razor-DmUARTT5.js → razor-DXx8evJz.js} +1 -1
  31. package/apps/web/dist/assets/{tsMode-BUABwVTd.js → tsMode-COCLvdXn.js} +1 -1
  32. package/apps/web/dist/assets/{typescript-sTt0HE01.js → typescript-BZheDEVE.js} +1 -1
  33. package/apps/web/dist/assets/{workers-D6L1Qkzp.js → workers-DomC9MTB.js} +1 -1
  34. package/apps/web/dist/assets/{xml-asYBWpFY.js → xml-C70yjRn0.js} +1 -1
  35. package/apps/web/dist/assets/{yaml-DWoILemf.js → yaml-BrMtNiQA.js} +1 -1
  36. package/apps/web/dist/favicon.svg +4 -4
  37. package/apps/web/dist/index.html +1 -1
  38. package/package.json +1 -1
  39. package/apps/web/dist/assets/main-B6xFa89X.css +0 -1
@@ -322,19 +322,19 @@ async function runCli(argv, io) {
322
322
  case "logs": return await runLogs(parsed, io);
323
323
  case "doctor": return await runDoctorCommand(io);
324
324
  case "start": {
325
- const { startCommand } = await import("./lifecycle-0-9eT-gl.js");
325
+ const { startCommand } = await import("./lifecycle-KNpzUqgr.js");
326
326
  return await startCommand(io);
327
327
  }
328
328
  case "stop": {
329
- const { stopCommand } = await import("./lifecycle-0-9eT-gl.js");
329
+ const { stopCommand } = await import("./lifecycle-KNpzUqgr.js");
330
330
  return await stopCommand(io);
331
331
  }
332
332
  case "restart": {
333
- const { restartCommand } = await import("./lifecycle-0-9eT-gl.js");
333
+ const { restartCommand } = await import("./lifecycle-KNpzUqgr.js");
334
334
  return await restartCommand(io);
335
335
  }
336
336
  case "tui": {
337
- const { tuiCommand } = await import("./lifecycle-0-9eT-gl.js");
337
+ const { tuiCommand } = await import("./lifecycle-KNpzUqgr.js");
338
338
  return await tuiCommand(io);
339
339
  }
340
340
  case "unlock": {
@@ -12,6 +12,8 @@ import { chmod, mkdir, open, rename, stat } from "node:fs/promises";
12
12
  // src/cli/lifecycle.ts
13
13
  const READY_TIMEOUT_MS = 9e4;
14
14
  const STOP_TIMEOUT_MS = 15e3;
15
+ const STOP_EXIT_GRACE_MS = 2e3;
16
+ const STOP_KILL_TIMEOUT_MS = 3e3;
15
17
  const DAEMON_LOG_LIMIT_BYTES = 5242880;
16
18
  function serverRoot() {
17
19
  return findServerRoot(path.dirname(fileURLToPath(import.meta.url)));
@@ -201,24 +203,40 @@ async function stopCommand(io, options = {}) {
201
203
  const selfPid = options.selfPid ?? process.pid;
202
204
  const timeoutMs = options.stopTimeoutMs ?? STOP_TIMEOUT_MS;
203
205
  if (!await waitUntil(async () => {
204
- if ((await inspectInstanceLock(dataDir))?.alive === true) return false;
205
- if (pid === null || pid === selfPid) return true;
206
- return !isAlive(pid);
206
+ return (await inspectInstanceLock(dataDir))?.alive !== true;
207
207
  }, timeoutMs)) {
208
- if ((await inspectInstanceLock(dataDir))?.alive !== true) {
209
- io.stderr(`[larness] the server released its lock but pid ${pid ?? "unknown"} is still running.\n`);
210
- io.stderr("[larness] end that process manually before upgrading or starting another.\n");
211
- io.stderr("[larness] no signal was sent.\n");
212
- } else {
213
- io.stderr(`[larness] the server did not stop within ${timeoutMs / 1e3}s.\n`);
214
- io.stderr(`[larness] pid ${pid ?? "unknown"}; it may still be running.\n`);
215
- }
208
+ io.stderr(`[larness] the server did not stop within ${timeoutMs / 1e3}s.\n`);
209
+ io.stderr(`[larness] pid ${pid ?? "unknown"}; it may still be running.\n`);
216
210
  return 1;
217
211
  }
212
+ if (pid !== null && pid !== selfPid && isAlive(pid)) {
213
+ if (!await waitUntil(async () => !isAlive(pid), options.exitGraceMs ?? STOP_EXIT_GRACE_MS)) {
214
+ try {
215
+ (options.terminate ?? terminateProcess)(pid);
216
+ } catch {
217
+ io.stderr(`[larness] unable to terminate pid ${pid} after graceful shutdown.\n`);
218
+ io.stderr("[larness] end that process manually before upgrading or starting another.\n");
219
+ return 1;
220
+ }
221
+ if (!await waitUntil(async () => !isAlive(pid), options.killTimeoutMs ?? STOP_KILL_TIMEOUT_MS)) {
222
+ io.stderr(`[larness] pid ${pid} is still running after forced termination.\n`);
223
+ io.stderr("[larness] end that process manually before upgrading or starting another.\n");
224
+ return 1;
225
+ }
226
+ io.stderr(`[larness] graceful shutdown released the lock but pid ${pid} did not exit; the process was terminated.\n`);
227
+ }
228
+ }
218
229
  io.stdout("[larness] management server stopped.\n");
219
230
  io.stdout("[larness] PM2 services and deployments keep running.\n");
220
231
  return 0;
221
232
  }
233
+ function terminateProcess(pid) {
234
+ try {
235
+ process.kill(pid, "SIGKILL");
236
+ } catch (error) {
237
+ if (error.code !== "ESRCH") throw error;
238
+ }
239
+ }
222
240
  async function restartCommand(io) {
223
241
  const dataDir = resolveDataDir(io.env);
224
242
  const lock = await inspectInstanceLock(dataDir);
@@ -1,110 +1,110 @@
1
- CREATE TABLE `app_meta` (
2
- `key` text PRIMARY KEY NOT NULL,
3
- `value` text NOT NULL,
4
- `updated_at` integer NOT NULL
5
- );
6
- --> statement-breakpoint
7
- CREATE TABLE `audit_logs` (
8
- `id` text PRIMARY KEY NOT NULL,
9
- `client_session_id` text,
10
- `session_id` text,
11
- `action` text NOT NULL,
12
- `resource_type` text,
13
- `resource_id` text,
14
- `decision` text,
15
- `details_json` text DEFAULT '{}' NOT NULL,
16
- `created_at` integer NOT NULL
17
- );
18
- --> statement-breakpoint
19
- CREATE INDEX `idx_audit_created` ON `audit_logs` (`created_at`);--> statement-breakpoint
20
- CREATE INDEX `idx_audit_action` ON `audit_logs` (`action`,`created_at`);--> statement-breakpoint
21
- CREATE TABLE `auth_settings` (
22
- `id` integer PRIMARY KEY NOT NULL,
23
- `admin_hash` text NOT NULL,
24
- `admin_updated_at` integer NOT NULL,
25
- `initialized_at` integer NOT NULL,
26
- CONSTRAINT "auth_settings_single_row" CHECK("auth_settings"."id" = 1)
27
- );
28
- --> statement-breakpoint
29
- CREATE TABLE `browser_sessions` (
30
- `id` text PRIMARY KEY NOT NULL,
31
- `device_id` text,
32
- `token_hash` text NOT NULL,
33
- `kind` text NOT NULL,
34
- `ip` text,
35
- `user_agent` text,
36
- `created_at` integer NOT NULL,
37
- `last_seen_at` integer NOT NULL,
38
- `expires_at` integer NOT NULL,
39
- `revoked_at` integer,
40
- FOREIGN KEY (`device_id`) REFERENCES `trusted_devices`(`id`) ON UPDATE no action ON DELETE no action
41
- );
42
- --> statement-breakpoint
43
- CREATE UNIQUE INDEX `browser_sessions_token_hash_unique` ON `browser_sessions` (`token_hash`);--> statement-breakpoint
44
- CREATE INDEX `idx_browser_sessions_device` ON `browser_sessions` (`device_id`);--> statement-breakpoint
45
- CREATE TABLE `device_requests` (
46
- `id` text PRIMARY KEY NOT NULL,
47
- `short_code` text NOT NULL,
48
- `status` text NOT NULL,
49
- `decision` text,
50
- `client_label` text,
51
- `user_agent` text,
52
- `ip` text,
53
- `client_origin` text,
54
- `poll_token_hash` text NOT NULL,
55
- `code_hash` text,
56
- `code_expires_at` integer,
57
- `attempts` integer DEFAULT 0 NOT NULL,
58
- `enrollment_token_hash` text,
59
- `enrollment_expires_at` integer,
60
- `created_at` integer NOT NULL,
61
- `expires_at` integer NOT NULL,
62
- `decided_at` integer,
63
- `redeemed_at` integer
64
- );
65
- --> statement-breakpoint
66
- CREATE UNIQUE INDEX `device_requests_short_code_unique` ON `device_requests` (`short_code`);--> statement-breakpoint
67
- CREATE INDEX `idx_device_requests_status` ON `device_requests` (`status`,`expires_at`);--> statement-breakpoint
68
- CREATE TABLE `trusted_devices` (
69
- `id` text PRIMARY KEY NOT NULL,
70
- `label` text NOT NULL,
71
- `created_by_request_id` text,
72
- `user_agent` text,
73
- `created_at` integer NOT NULL,
74
- `last_seen_at` integer,
75
- `revoked_at` integer,
76
- FOREIGN KEY (`created_by_request_id`) REFERENCES `device_requests`(`id`) ON UPDATE no action ON DELETE no action
77
- );
78
- --> statement-breakpoint
79
- CREATE TABLE `webauthn_challenges` (
80
- `id` text PRIMARY KEY NOT NULL,
81
- `type` text NOT NULL,
82
- `challenge` text NOT NULL,
83
- `request_id` text,
84
- `device_id` text,
85
- `created_at` integer NOT NULL,
86
- `expires_at` integer NOT NULL,
87
- `consumed_at` integer,
88
- FOREIGN KEY (`request_id`) REFERENCES `device_requests`(`id`) ON UPDATE no action ON DELETE no action,
89
- FOREIGN KEY (`device_id`) REFERENCES `trusted_devices`(`id`) ON UPDATE no action ON DELETE no action
90
- );
91
- --> statement-breakpoint
92
- CREATE INDEX `idx_webauthn_challenges_expiry` ON `webauthn_challenges` (`expires_at`);--> statement-breakpoint
93
- CREATE TABLE `webauthn_credentials` (
94
- `id` text PRIMARY KEY NOT NULL,
95
- `device_id` text NOT NULL,
96
- `credential_id` text NOT NULL,
97
- `public_key` text NOT NULL,
98
- `counter` integer DEFAULT 0 NOT NULL,
99
- `transports_json` text DEFAULT '[]' NOT NULL,
100
- `aaguid` text,
101
- `backup_eligible` integer DEFAULT false NOT NULL,
102
- `backup_state` integer DEFAULT false NOT NULL,
103
- `created_at` integer NOT NULL,
104
- `last_used_at` integer,
105
- `revoked_at` integer,
106
- FOREIGN KEY (`device_id`) REFERENCES `trusted_devices`(`id`) ON UPDATE no action ON DELETE no action
107
- );
108
- --> statement-breakpoint
109
- CREATE UNIQUE INDEX `webauthn_credentials_credential_id_unique` ON `webauthn_credentials` (`credential_id`);--> statement-breakpoint
1
+ CREATE TABLE `app_meta` (
2
+ `key` text PRIMARY KEY NOT NULL,
3
+ `value` text NOT NULL,
4
+ `updated_at` integer NOT NULL
5
+ );
6
+ --> statement-breakpoint
7
+ CREATE TABLE `audit_logs` (
8
+ `id` text PRIMARY KEY NOT NULL,
9
+ `client_session_id` text,
10
+ `session_id` text,
11
+ `action` text NOT NULL,
12
+ `resource_type` text,
13
+ `resource_id` text,
14
+ `decision` text,
15
+ `details_json` text DEFAULT '{}' NOT NULL,
16
+ `created_at` integer NOT NULL
17
+ );
18
+ --> statement-breakpoint
19
+ CREATE INDEX `idx_audit_created` ON `audit_logs` (`created_at`);--> statement-breakpoint
20
+ CREATE INDEX `idx_audit_action` ON `audit_logs` (`action`,`created_at`);--> statement-breakpoint
21
+ CREATE TABLE `auth_settings` (
22
+ `id` integer PRIMARY KEY NOT NULL,
23
+ `admin_hash` text NOT NULL,
24
+ `admin_updated_at` integer NOT NULL,
25
+ `initialized_at` integer NOT NULL,
26
+ CONSTRAINT "auth_settings_single_row" CHECK("auth_settings"."id" = 1)
27
+ );
28
+ --> statement-breakpoint
29
+ CREATE TABLE `browser_sessions` (
30
+ `id` text PRIMARY KEY NOT NULL,
31
+ `device_id` text,
32
+ `token_hash` text NOT NULL,
33
+ `kind` text NOT NULL,
34
+ `ip` text,
35
+ `user_agent` text,
36
+ `created_at` integer NOT NULL,
37
+ `last_seen_at` integer NOT NULL,
38
+ `expires_at` integer NOT NULL,
39
+ `revoked_at` integer,
40
+ FOREIGN KEY (`device_id`) REFERENCES `trusted_devices`(`id`) ON UPDATE no action ON DELETE no action
41
+ );
42
+ --> statement-breakpoint
43
+ CREATE UNIQUE INDEX `browser_sessions_token_hash_unique` ON `browser_sessions` (`token_hash`);--> statement-breakpoint
44
+ CREATE INDEX `idx_browser_sessions_device` ON `browser_sessions` (`device_id`);--> statement-breakpoint
45
+ CREATE TABLE `device_requests` (
46
+ `id` text PRIMARY KEY NOT NULL,
47
+ `short_code` text NOT NULL,
48
+ `status` text NOT NULL,
49
+ `decision` text,
50
+ `client_label` text,
51
+ `user_agent` text,
52
+ `ip` text,
53
+ `client_origin` text,
54
+ `poll_token_hash` text NOT NULL,
55
+ `code_hash` text,
56
+ `code_expires_at` integer,
57
+ `attempts` integer DEFAULT 0 NOT NULL,
58
+ `enrollment_token_hash` text,
59
+ `enrollment_expires_at` integer,
60
+ `created_at` integer NOT NULL,
61
+ `expires_at` integer NOT NULL,
62
+ `decided_at` integer,
63
+ `redeemed_at` integer
64
+ );
65
+ --> statement-breakpoint
66
+ CREATE UNIQUE INDEX `device_requests_short_code_unique` ON `device_requests` (`short_code`);--> statement-breakpoint
67
+ CREATE INDEX `idx_device_requests_status` ON `device_requests` (`status`,`expires_at`);--> statement-breakpoint
68
+ CREATE TABLE `trusted_devices` (
69
+ `id` text PRIMARY KEY NOT NULL,
70
+ `label` text NOT NULL,
71
+ `created_by_request_id` text,
72
+ `user_agent` text,
73
+ `created_at` integer NOT NULL,
74
+ `last_seen_at` integer,
75
+ `revoked_at` integer,
76
+ FOREIGN KEY (`created_by_request_id`) REFERENCES `device_requests`(`id`) ON UPDATE no action ON DELETE no action
77
+ );
78
+ --> statement-breakpoint
79
+ CREATE TABLE `webauthn_challenges` (
80
+ `id` text PRIMARY KEY NOT NULL,
81
+ `type` text NOT NULL,
82
+ `challenge` text NOT NULL,
83
+ `request_id` text,
84
+ `device_id` text,
85
+ `created_at` integer NOT NULL,
86
+ `expires_at` integer NOT NULL,
87
+ `consumed_at` integer,
88
+ FOREIGN KEY (`request_id`) REFERENCES `device_requests`(`id`) ON UPDATE no action ON DELETE no action,
89
+ FOREIGN KEY (`device_id`) REFERENCES `trusted_devices`(`id`) ON UPDATE no action ON DELETE no action
90
+ );
91
+ --> statement-breakpoint
92
+ CREATE INDEX `idx_webauthn_challenges_expiry` ON `webauthn_challenges` (`expires_at`);--> statement-breakpoint
93
+ CREATE TABLE `webauthn_credentials` (
94
+ `id` text PRIMARY KEY NOT NULL,
95
+ `device_id` text NOT NULL,
96
+ `credential_id` text NOT NULL,
97
+ `public_key` text NOT NULL,
98
+ `counter` integer DEFAULT 0 NOT NULL,
99
+ `transports_json` text DEFAULT '[]' NOT NULL,
100
+ `aaguid` text,
101
+ `backup_eligible` integer DEFAULT false NOT NULL,
102
+ `backup_state` integer DEFAULT false NOT NULL,
103
+ `created_at` integer NOT NULL,
104
+ `last_used_at` integer,
105
+ `revoked_at` integer,
106
+ FOREIGN KEY (`device_id`) REFERENCES `trusted_devices`(`id`) ON UPDATE no action ON DELETE no action
107
+ );
108
+ --> statement-breakpoint
109
+ CREATE UNIQUE INDEX `webauthn_credentials_credential_id_unique` ON `webauthn_credentials` (`credential_id`);--> statement-breakpoint
110
110
  CREATE INDEX `idx_webauthn_credentials_device` ON `webauthn_credentials` (`device_id`);
@@ -1,13 +1,13 @@
1
- CREATE TABLE `projects` (
2
- `id` text PRIMARY KEY NOT NULL,
3
- `name` text NOT NULL,
4
- `root_path` text NOT NULL,
5
- `real_path` text NOT NULL,
6
- `settings_json` text DEFAULT '{}' NOT NULL,
7
- `git_detected` integer DEFAULT false NOT NULL,
8
- `created_at` integer NOT NULL,
9
- `updated_at` integer NOT NULL
10
- );
11
- --> statement-breakpoint
12
- CREATE UNIQUE INDEX `projects_real_path_unique` ON `projects` (`real_path`);--> statement-breakpoint
1
+ CREATE TABLE `projects` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `name` text NOT NULL,
4
+ `root_path` text NOT NULL,
5
+ `real_path` text NOT NULL,
6
+ `settings_json` text DEFAULT '{}' NOT NULL,
7
+ `git_detected` integer DEFAULT false NOT NULL,
8
+ `created_at` integer NOT NULL,
9
+ `updated_at` integer NOT NULL
10
+ );
11
+ --> statement-breakpoint
12
+ CREATE UNIQUE INDEX `projects_real_path_unique` ON `projects` (`real_path`);--> statement-breakpoint
13
13
  CREATE INDEX `idx_projects_updated` ON `projects` (`updated_at`);
@@ -1,81 +1,81 @@
1
- CREATE TABLE `agent_events` (
2
- `id` text PRIMARY KEY NOT NULL,
3
- `session_id` text NOT NULL,
4
- `turn_id` text,
5
- `seq` integer NOT NULL,
6
- `type` text NOT NULL,
7
- `payload_json` text DEFAULT '{}' NOT NULL,
8
- `created_at` integer NOT NULL,
9
- FOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade,
10
- FOREIGN KEY (`turn_id`) REFERENCES `turns`(`id`) ON UPDATE no action ON DELETE cascade
11
- );
12
- --> statement-breakpoint
13
- CREATE UNIQUE INDEX `agent_events_session_seq_unique` ON `agent_events` (`session_id`,`seq`);--> statement-breakpoint
14
- CREATE TABLE `approvals` (
15
- `id` text PRIMARY KEY NOT NULL,
16
- `turn_id` text NOT NULL,
17
- `tool_call_id` text NOT NULL,
18
- `tool_name` text NOT NULL,
19
- `risk` text NOT NULL,
20
- `status` text DEFAULT 'pending' NOT NULL,
21
- `scope_json` text DEFAULT '{}' NOT NULL,
22
- `params_hash` text NOT NULL,
23
- `expires_at` integer NOT NULL,
24
- `decided_at` integer,
25
- `decided_by` text,
26
- `created_at` integer NOT NULL,
27
- FOREIGN KEY (`turn_id`) REFERENCES `turns`(`id`) ON UPDATE no action ON DELETE cascade
28
- );
29
- --> statement-breakpoint
30
- CREATE INDEX `idx_approvals_turn_status` ON `approvals` (`turn_id`,`status`);--> statement-breakpoint
31
- CREATE INDEX `idx_approvals_expiry` ON `approvals` (`expires_at`);--> statement-breakpoint
32
- CREATE TABLE `resource_locks` (
33
- `id` text PRIMARY KEY NOT NULL,
34
- `resource_type` text NOT NULL,
35
- `resource_id` text NOT NULL,
36
- `owner` text NOT NULL,
37
- `execution_id` text NOT NULL,
38
- `fencing_token` integer NOT NULL,
39
- `expires_at` integer NOT NULL,
40
- `heartbeat_at` integer NOT NULL,
41
- `created_at` integer NOT NULL
42
- );
43
- --> statement-breakpoint
44
- CREATE UNIQUE INDEX `resource_locks_resource_unique` ON `resource_locks` (`resource_type`,`resource_id`);--> statement-breakpoint
45
- CREATE INDEX `idx_resource_locks_expiry` ON `resource_locks` (`expires_at`);--> statement-breakpoint
46
- CREATE TABLE `sessions` (
47
- `id` text PRIMARY KEY NOT NULL,
48
- `project_id` text,
49
- `workspace_path` text NOT NULL,
50
- `title` text NOT NULL,
51
- `status` text DEFAULT 'active' NOT NULL,
52
- `model_profile_id` text,
53
- `approval_policy_id` text DEFAULT 'standard' NOT NULL,
54
- `created_at` integer NOT NULL,
55
- `updated_at` integer NOT NULL,
56
- `last_activity_at` integer NOT NULL,
57
- FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE set null
58
- );
59
- --> statement-breakpoint
60
- CREATE INDEX `idx_sessions_project_updated` ON `sessions` (`project_id`,`updated_at`);--> statement-breakpoint
61
- CREATE INDEX `idx_sessions_updated` ON `sessions` (`updated_at`);--> statement-breakpoint
62
- CREATE TABLE `turns` (
63
- `id` text PRIMARY KEY NOT NULL,
64
- `session_id` text NOT NULL,
65
- `model_profile_id` text,
66
- `provider` text,
67
- `model` text,
68
- `status` text NOT NULL,
69
- `input_json` text NOT NULL,
70
- `usage_json` text,
71
- `error_json` text,
72
- `idempotency_key` text,
73
- `created_at` integer NOT NULL,
74
- `started_at` integer,
75
- `ended_at` integer,
76
- FOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade
77
- );
78
- --> statement-breakpoint
79
- CREATE UNIQUE INDEX `turns_session_idempotency_unique` ON `turns` (`session_id`,`idempotency_key`);--> statement-breakpoint
80
- CREATE INDEX `idx_turns_session_created` ON `turns` (`session_id`,`created_at`);--> statement-breakpoint
1
+ CREATE TABLE `agent_events` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `session_id` text NOT NULL,
4
+ `turn_id` text,
5
+ `seq` integer NOT NULL,
6
+ `type` text NOT NULL,
7
+ `payload_json` text DEFAULT '{}' NOT NULL,
8
+ `created_at` integer NOT NULL,
9
+ FOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade,
10
+ FOREIGN KEY (`turn_id`) REFERENCES `turns`(`id`) ON UPDATE no action ON DELETE cascade
11
+ );
12
+ --> statement-breakpoint
13
+ CREATE UNIQUE INDEX `agent_events_session_seq_unique` ON `agent_events` (`session_id`,`seq`);--> statement-breakpoint
14
+ CREATE TABLE `approvals` (
15
+ `id` text PRIMARY KEY NOT NULL,
16
+ `turn_id` text NOT NULL,
17
+ `tool_call_id` text NOT NULL,
18
+ `tool_name` text NOT NULL,
19
+ `risk` text NOT NULL,
20
+ `status` text DEFAULT 'pending' NOT NULL,
21
+ `scope_json` text DEFAULT '{}' NOT NULL,
22
+ `params_hash` text NOT NULL,
23
+ `expires_at` integer NOT NULL,
24
+ `decided_at` integer,
25
+ `decided_by` text,
26
+ `created_at` integer NOT NULL,
27
+ FOREIGN KEY (`turn_id`) REFERENCES `turns`(`id`) ON UPDATE no action ON DELETE cascade
28
+ );
29
+ --> statement-breakpoint
30
+ CREATE INDEX `idx_approvals_turn_status` ON `approvals` (`turn_id`,`status`);--> statement-breakpoint
31
+ CREATE INDEX `idx_approvals_expiry` ON `approvals` (`expires_at`);--> statement-breakpoint
32
+ CREATE TABLE `resource_locks` (
33
+ `id` text PRIMARY KEY NOT NULL,
34
+ `resource_type` text NOT NULL,
35
+ `resource_id` text NOT NULL,
36
+ `owner` text NOT NULL,
37
+ `execution_id` text NOT NULL,
38
+ `fencing_token` integer NOT NULL,
39
+ `expires_at` integer NOT NULL,
40
+ `heartbeat_at` integer NOT NULL,
41
+ `created_at` integer NOT NULL
42
+ );
43
+ --> statement-breakpoint
44
+ CREATE UNIQUE INDEX `resource_locks_resource_unique` ON `resource_locks` (`resource_type`,`resource_id`);--> statement-breakpoint
45
+ CREATE INDEX `idx_resource_locks_expiry` ON `resource_locks` (`expires_at`);--> statement-breakpoint
46
+ CREATE TABLE `sessions` (
47
+ `id` text PRIMARY KEY NOT NULL,
48
+ `project_id` text,
49
+ `workspace_path` text NOT NULL,
50
+ `title` text NOT NULL,
51
+ `status` text DEFAULT 'active' NOT NULL,
52
+ `model_profile_id` text,
53
+ `approval_policy_id` text DEFAULT 'standard' NOT NULL,
54
+ `created_at` integer NOT NULL,
55
+ `updated_at` integer NOT NULL,
56
+ `last_activity_at` integer NOT NULL,
57
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE set null
58
+ );
59
+ --> statement-breakpoint
60
+ CREATE INDEX `idx_sessions_project_updated` ON `sessions` (`project_id`,`updated_at`);--> statement-breakpoint
61
+ CREATE INDEX `idx_sessions_updated` ON `sessions` (`updated_at`);--> statement-breakpoint
62
+ CREATE TABLE `turns` (
63
+ `id` text PRIMARY KEY NOT NULL,
64
+ `session_id` text NOT NULL,
65
+ `model_profile_id` text,
66
+ `provider` text,
67
+ `model` text,
68
+ `status` text NOT NULL,
69
+ `input_json` text NOT NULL,
70
+ `usage_json` text,
71
+ `error_json` text,
72
+ `idempotency_key` text,
73
+ `created_at` integer NOT NULL,
74
+ `started_at` integer,
75
+ `ended_at` integer,
76
+ FOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade
77
+ );
78
+ --> statement-breakpoint
79
+ CREATE UNIQUE INDEX `turns_session_idempotency_unique` ON `turns` (`session_id`,`idempotency_key`);--> statement-breakpoint
80
+ CREATE INDEX `idx_turns_session_created` ON `turns` (`session_id`,`created_at`);--> statement-breakpoint
81
81
  CREATE INDEX `idx_turns_session_status` ON `turns` (`session_id`,`status`);
@@ -1,30 +1,30 @@
1
- CREATE TABLE `credential_profiles` (
2
- `id` text PRIMARY KEY NOT NULL,
3
- `provider` text NOT NULL,
4
- `label` text NOT NULL,
5
- `secret_ref` text NOT NULL,
6
- `created_at` integer NOT NULL,
7
- FOREIGN KEY (`secret_ref`) REFERENCES `secrets`(`id`) ON UPDATE no action ON DELETE cascade
8
- );
9
- --> statement-breakpoint
10
- CREATE INDEX `idx_credential_profiles_provider` ON `credential_profiles` (`provider`);--> statement-breakpoint
11
- CREATE TABLE `model_profiles` (
12
- `id` text PRIMARY KEY NOT NULL,
13
- `label` text NOT NULL,
14
- `provider` text NOT NULL,
15
- `model` text NOT NULL,
16
- `credential_profile_id` text,
17
- `endpoint` text,
18
- `capabilities_json` text DEFAULT '{}' NOT NULL,
19
- `created_at` integer NOT NULL,
20
- FOREIGN KEY (`credential_profile_id`) REFERENCES `credential_profiles`(`id`) ON UPDATE no action ON DELETE set null
21
- );
22
- --> statement-breakpoint
23
- CREATE INDEX `idx_model_profiles_provider` ON `model_profiles` (`provider`);--> statement-breakpoint
24
- CREATE TABLE `secrets` (
25
- `id` text PRIMARY KEY NOT NULL,
26
- `ciphertext` text NOT NULL,
27
- `nonce` text NOT NULL,
28
- `tag` text NOT NULL,
29
- `created_at` integer NOT NULL
30
- );
1
+ CREATE TABLE `credential_profiles` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `provider` text NOT NULL,
4
+ `label` text NOT NULL,
5
+ `secret_ref` text NOT NULL,
6
+ `created_at` integer NOT NULL,
7
+ FOREIGN KEY (`secret_ref`) REFERENCES `secrets`(`id`) ON UPDATE no action ON DELETE cascade
8
+ );
9
+ --> statement-breakpoint
10
+ CREATE INDEX `idx_credential_profiles_provider` ON `credential_profiles` (`provider`);--> statement-breakpoint
11
+ CREATE TABLE `model_profiles` (
12
+ `id` text PRIMARY KEY NOT NULL,
13
+ `label` text NOT NULL,
14
+ `provider` text NOT NULL,
15
+ `model` text NOT NULL,
16
+ `credential_profile_id` text,
17
+ `endpoint` text,
18
+ `capabilities_json` text DEFAULT '{}' NOT NULL,
19
+ `created_at` integer NOT NULL,
20
+ FOREIGN KEY (`credential_profile_id`) REFERENCES `credential_profiles`(`id`) ON UPDATE no action ON DELETE set null
21
+ );
22
+ --> statement-breakpoint
23
+ CREATE INDEX `idx_model_profiles_provider` ON `model_profiles` (`provider`);--> statement-breakpoint
24
+ CREATE TABLE `secrets` (
25
+ `id` text PRIMARY KEY NOT NULL,
26
+ `ciphertext` text NOT NULL,
27
+ `nonce` text NOT NULL,
28
+ `tag` text NOT NULL,
29
+ `created_at` integer NOT NULL
30
+ );
@@ -1,54 +1,54 @@
1
- CREATE TABLE `file_versions` (
2
- `scope_key` text NOT NULL,
3
- `path` text NOT NULL,
4
- `real_path` text NOT NULL,
5
- `version_hash` text NOT NULL,
6
- `size` integer NOT NULL,
7
- `mtime` integer NOT NULL,
8
- `updated_at` integer NOT NULL
9
- );
10
- --> statement-breakpoint
11
- CREATE UNIQUE INDEX `file_versions_scope_path` ON `file_versions` (`scope_key`,`path`);--> statement-breakpoint
12
- CREATE TABLE `resource_events` (
13
- `id` text PRIMARY KEY NOT NULL,
14
- `stream_id` text NOT NULL,
15
- `seq` integer NOT NULL,
16
- `type` text NOT NULL,
17
- `payload_json` text NOT NULL,
18
- `created_at` integer NOT NULL,
19
- FOREIGN KEY (`stream_id`) REFERENCES `resource_streams`(`stream_id`) ON UPDATE no action ON DELETE no action
20
- );
21
- --> statement-breakpoint
22
- CREATE UNIQUE INDEX `resource_events_stream_seq` ON `resource_events` (`stream_id`,`seq`);--> statement-breakpoint
23
- CREATE TABLE `resource_operations` (
24
- `id` text PRIMARY KEY NOT NULL,
25
- `scope_key` text NOT NULL,
26
- `root_real_path` text NOT NULL,
27
- `kind` text NOT NULL,
28
- `status` text NOT NULL,
29
- `params_hash` text NOT NULL,
30
- `idempotency_key` text NOT NULL,
31
- `client_session_id` text NOT NULL,
32
- `path` text NOT NULL,
33
- `expected_version` text NOT NULL,
34
- `target_version` text NOT NULL,
35
- `lock_id` text NOT NULL,
36
- `fencing_token` integer NOT NULL,
37
- `result_json` text,
38
- `error_code` text,
39
- `created_at` integer NOT NULL,
40
- `updated_at` integer NOT NULL
41
- );
42
- --> statement-breakpoint
43
- CREATE UNIQUE INDEX `resource_operations_client_kind_key` ON `resource_operations` (`client_session_id`,`kind`,`idempotency_key`);--> statement-breakpoint
44
- CREATE INDEX `resource_operations_status` ON `resource_operations` (`status`);--> statement-breakpoint
45
- CREATE TABLE `resource_streams` (
46
- `stream_id` text PRIMARY KEY NOT NULL,
47
- `last_seq` integer DEFAULT 0 NOT NULL
48
- );
49
- --> statement-breakpoint
50
- ALTER TABLE `resource_locks` ADD `root_real_path` text;
51
- --> statement-breakpoint
52
- UPDATE `resource_locks` SET `root_real_path` = (
53
- SELECT `real_path` FROM `projects` WHERE `projects`.`id` = `resource_locks`.`resource_id`
54
- ) WHERE `resource_type` = 'project';
1
+ CREATE TABLE `file_versions` (
2
+ `scope_key` text NOT NULL,
3
+ `path` text NOT NULL,
4
+ `real_path` text NOT NULL,
5
+ `version_hash` text NOT NULL,
6
+ `size` integer NOT NULL,
7
+ `mtime` integer NOT NULL,
8
+ `updated_at` integer NOT NULL
9
+ );
10
+ --> statement-breakpoint
11
+ CREATE UNIQUE INDEX `file_versions_scope_path` ON `file_versions` (`scope_key`,`path`);--> statement-breakpoint
12
+ CREATE TABLE `resource_events` (
13
+ `id` text PRIMARY KEY NOT NULL,
14
+ `stream_id` text NOT NULL,
15
+ `seq` integer NOT NULL,
16
+ `type` text NOT NULL,
17
+ `payload_json` text NOT NULL,
18
+ `created_at` integer NOT NULL,
19
+ FOREIGN KEY (`stream_id`) REFERENCES `resource_streams`(`stream_id`) ON UPDATE no action ON DELETE no action
20
+ );
21
+ --> statement-breakpoint
22
+ CREATE UNIQUE INDEX `resource_events_stream_seq` ON `resource_events` (`stream_id`,`seq`);--> statement-breakpoint
23
+ CREATE TABLE `resource_operations` (
24
+ `id` text PRIMARY KEY NOT NULL,
25
+ `scope_key` text NOT NULL,
26
+ `root_real_path` text NOT NULL,
27
+ `kind` text NOT NULL,
28
+ `status` text NOT NULL,
29
+ `params_hash` text NOT NULL,
30
+ `idempotency_key` text NOT NULL,
31
+ `client_session_id` text NOT NULL,
32
+ `path` text NOT NULL,
33
+ `expected_version` text NOT NULL,
34
+ `target_version` text NOT NULL,
35
+ `lock_id` text NOT NULL,
36
+ `fencing_token` integer NOT NULL,
37
+ `result_json` text,
38
+ `error_code` text,
39
+ `created_at` integer NOT NULL,
40
+ `updated_at` integer NOT NULL
41
+ );
42
+ --> statement-breakpoint
43
+ CREATE UNIQUE INDEX `resource_operations_client_kind_key` ON `resource_operations` (`client_session_id`,`kind`,`idempotency_key`);--> statement-breakpoint
44
+ CREATE INDEX `resource_operations_status` ON `resource_operations` (`status`);--> statement-breakpoint
45
+ CREATE TABLE `resource_streams` (
46
+ `stream_id` text PRIMARY KEY NOT NULL,
47
+ `last_seq` integer DEFAULT 0 NOT NULL
48
+ );
49
+ --> statement-breakpoint
50
+ ALTER TABLE `resource_locks` ADD `root_real_path` text;
51
+ --> statement-breakpoint
52
+ UPDATE `resource_locks` SET `root_real_path` = (
53
+ SELECT `real_path` FROM `projects` WHERE `projects`.`id` = `resource_locks`.`resource_id`
54
+ ) WHERE `resource_type` = 'project';