@vinihcrosa/lumem-os 0.1.0

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 (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +107 -0
  3. package/bin/lumem.mjs +4605 -0
  4. package/bin/postinstall.mjs +55 -0
  5. package/dist/server/main.mjs +95446 -0
  6. package/dist/web/assets/codemirror-setup-Csmyc9rQ.js +18 -0
  7. package/dist/web/assets/core-rofTMs1b.js +12 -0
  8. package/dist/web/assets/css-CLj8gQPS.js +1 -0
  9. package/dist/web/assets/diff-D97Zzqfu.js +1 -0
  10. package/dist/web/assets/docker-BcOcwvcX.js +1 -0
  11. package/dist/web/assets/engine-javascript-DBd1bXLz.js +141 -0
  12. package/dist/web/assets/html-pp8916En.js +1 -0
  13. package/dist/web/assets/index-BlWx0v0O.js +101 -0
  14. package/dist/web/assets/index-jS7lSqBc.css +32 -0
  15. package/dist/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  16. package/dist/web/assets/javascript-wDzz0qaB.js +1 -0
  17. package/dist/web/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  18. package/dist/web/assets/json-Cp-IABpG.js +1 -0
  19. package/dist/web/assets/jsx-g9-lgVsj.js +1 -0
  20. package/dist/web/assets/make-CHLpvVh8.js +1 -0
  21. package/dist/web/assets/markdown-Cvjx9yec.js +1 -0
  22. package/dist/web/assets/python-B6aJPvgy.js +1 -0
  23. package/dist/web/assets/shellscript-Yzrsuije.js +1 -0
  24. package/dist/web/assets/sql-CRqJ_cUM.js +1 -0
  25. package/dist/web/assets/toml-vGWfd6FD.js +1 -0
  26. package/dist/web/assets/tsx-COt5Ahok.js +1 -0
  27. package/dist/web/assets/typescript-BPQ3VLAy.js +1 -0
  28. package/dist/web/assets/yaml-Buea-lGh.js +1 -0
  29. package/dist/web/index.html +13 -0
  30. package/drizzle/0000_initial.sql +68 -0
  31. package/drizzle/0001_adorable_joshua_kane.sql +71 -0
  32. package/drizzle/0002_striped_trish_tilby.sql +1 -0
  33. package/drizzle/0003_memoria_do_workspace.sql +127 -0
  34. package/drizzle/0004_memoria_no_nucleo.sql +1 -0
  35. package/drizzle/0005_playbooks.sql +21 -0
  36. package/drizzle/0006_consumo_por_turno.sql +15 -0
  37. package/drizzle/0007_project_origin_and_management.sql +2 -0
  38. package/drizzle/0008_sessao_de_script.sql +40 -0
  39. package/drizzle/0009_porta_por_checkout.sql +13 -0
  40. package/drizzle/0010_confianca_no_scripts.sql +1 -0
  41. package/drizzle/0011_fase_de_teste.sql +40 -0
  42. package/drizzle/meta/0000_snapshot.json +450 -0
  43. package/drizzle/meta/0001_snapshot.json +515 -0
  44. package/drizzle/meta/0002_snapshot.json +522 -0
  45. package/drizzle/meta/0003_snapshot.json +1292 -0
  46. package/drizzle/meta/0004_snapshot.json +1300 -0
  47. package/drizzle/meta/0005_snapshot.json +1445 -0
  48. package/drizzle/meta/0006_snapshot.json +1544 -0
  49. package/drizzle/meta/0007_snapshot.json +1559 -0
  50. package/drizzle/meta/0008_snapshot.json +1570 -0
  51. package/drizzle/meta/0009_snapshot.json +1649 -0
  52. package/drizzle/meta/0010_snapshot.json +1656 -0
  53. package/drizzle/meta/0011_snapshot.json +1656 -0
  54. package/drizzle/meta/_journal.json +90 -0
  55. package/package.json +47 -0
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Lumem-OS</title>
7
+ <script type="module" crossorigin src="/assets/index-BlWx0v0O.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-jS7lSqBc.css">
9
+ </head>
10
+ <body>
11
+ <div id="root"></div>
12
+ </body>
13
+ </html>
@@ -0,0 +1,68 @@
1
+ CREATE TABLE `agent_config` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `name` text NOT NULL,
4
+ `command` text NOT NULL,
5
+ `args` text DEFAULT '[]' NOT NULL,
6
+ `env` text DEFAULT '{}' NOT NULL,
7
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
8
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL
9
+ );
10
+ --> statement-breakpoint
11
+ CREATE UNIQUE INDEX `agent_config_name_unique` ON `agent_config` (`name`);--> statement-breakpoint
12
+ CREATE TABLE `project` (
13
+ `id` text PRIMARY KEY NOT NULL,
14
+ `workspace_id` text NOT NULL,
15
+ `name` text NOT NULL,
16
+ `path` text NOT NULL,
17
+ `default_branch` text NOT NULL,
18
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
19
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
20
+ FOREIGN KEY (`workspace_id`) REFERENCES `workspace`(`id`) ON UPDATE no action ON DELETE restrict
21
+ );
22
+ --> statement-breakpoint
23
+ CREATE UNIQUE INDEX `project_path_unique` ON `project` (`path`);--> statement-breakpoint
24
+ CREATE UNIQUE INDEX `project_name_per_workspace` ON `project` (`workspace_id`,`name`);--> statement-breakpoint
25
+ CREATE TABLE `session` (
26
+ `id` text PRIMARY KEY NOT NULL,
27
+ `kind` text NOT NULL,
28
+ `agent_config_id` text,
29
+ `scope_type` text NOT NULL,
30
+ `scope_id` text NOT NULL,
31
+ `cwd` text NOT NULL,
32
+ `command` text NOT NULL,
33
+ `state` text DEFAULT 'running' NOT NULL,
34
+ `exit_code` integer,
35
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
36
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
37
+ FOREIGN KEY (`agent_config_id`) REFERENCES `agent_config`(`id`) ON UPDATE no action ON DELETE restrict,
38
+ CONSTRAINT "session_kind" CHECK("session"."kind" IN ('shell', 'agent')),
39
+ CONSTRAINT "session_scope_type" CHECK("session"."scope_type" IN ('project', 'worktree')),
40
+ CONSTRAINT "session_state" CHECK("session"."state" IN ('running', 'exited')),
41
+ CONSTRAINT "session_agent_config" CHECK(("session"."kind" = 'agent' AND "session"."agent_config_id" IS NOT NULL)
42
+ OR ("session"."kind" = 'shell' AND "session"."agent_config_id" IS NULL)),
43
+ CONSTRAINT "session_exit_code" CHECK(("session"."state" = 'running' AND "session"."exit_code" IS NULL)
44
+ OR ("session"."state" = 'exited'))
45
+ );
46
+ --> statement-breakpoint
47
+ CREATE TABLE `workspace` (
48
+ `id` text PRIMARY KEY NOT NULL,
49
+ `name` text NOT NULL,
50
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
51
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL
52
+ );
53
+ --> statement-breakpoint
54
+ CREATE UNIQUE INDEX `workspace_name_unique` ON `workspace` (`name`);--> statement-breakpoint
55
+ CREATE TABLE `worktree` (
56
+ `id` text PRIMARY KEY NOT NULL,
57
+ `project_id` text NOT NULL,
58
+ `name` text NOT NULL,
59
+ `branch` text NOT NULL,
60
+ `path` text NOT NULL,
61
+ `state` text DEFAULT 'active' NOT NULL,
62
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
63
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
64
+ FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON UPDATE no action ON DELETE restrict,
65
+ CONSTRAINT "worktree_state" CHECK("worktree"."state" IN ('active', 'missing'))
66
+ );
67
+ --> statement-breakpoint
68
+ CREATE UNIQUE INDEX `worktree_name_per_project` ON `worktree` (`project_id`,`name`);
@@ -0,0 +1,71 @@
1
+ --> The pragma below is inert, and it is left exactly as drizzle-kit emits it so
2
+ --> that regenerating this file produces no diff. SQLite ignores
3
+ --> `foreign_keys` inside a transaction, which is where the migrator runs it, so
4
+ --> the rebuild's `DROP TABLE agent_config` used to fail on any database with a
5
+ --> session attached to a configuration. The pragma that actually matters is set
6
+ --> before the transaction opens, in `openDatabase` — see the note there.
7
+ PRAGMA foreign_keys=OFF;--> statement-breakpoint
8
+ CREATE TABLE `__new_agent_config` (
9
+ `id` text PRIMARY KEY NOT NULL,
10
+ `name` text NOT NULL,
11
+ `command` text NOT NULL,
12
+ `args` text DEFAULT '[]' NOT NULL,
13
+ `env` text DEFAULT '{}' NOT NULL,
14
+ `transport` text DEFAULT 'pty' NOT NULL,
15
+ `adapter_version` text,
16
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
17
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
18
+ CONSTRAINT "agent_config_transport" CHECK("__new_agent_config"."transport" IN ('pty', 'acp')),
19
+ CONSTRAINT "agent_config_adapter_version" CHECK(("__new_agent_config"."transport" = 'acp' AND "__new_agent_config"."adapter_version" IS NOT NULL)
20
+ OR ("__new_agent_config"."transport" = 'pty' AND "__new_agent_config"."adapter_version" IS NULL))
21
+ );
22
+ --> statement-breakpoint
23
+ --> Written by hand, and this is the reason: drizzle-kit generated
24
+ --> `SELECT "transport", "adapter_version" FROM agent_config`, reading the two
25
+ --> columns this very migration is adding. The table being copied FROM does not
26
+ --> have them, so the statement fails with `no such column: "transport"` on any
27
+ --> database that is actually being upgraded. It passes on an empty one, because
28
+ --> there is nothing to copy — which is why only `migrations.test.ts` caught it.
29
+ --> The literals below are A11 in SQL: everything that already worked was a PTY
30
+ --> configuration, and it stays one.
31
+ INSERT INTO `__new_agent_config`("id", "name", "command", "args", "env", "transport", "adapter_version", "created_at", "updated_at") SELECT "id", "name", "command", "args", "env", 'pty', NULL, "created_at", "updated_at" FROM `agent_config`;--> statement-breakpoint
32
+ DROP TABLE `agent_config`;--> statement-breakpoint
33
+ ALTER TABLE `__new_agent_config` RENAME TO `agent_config`;--> statement-breakpoint
34
+ PRAGMA foreign_keys=ON;--> statement-breakpoint
35
+ CREATE UNIQUE INDEX `agent_config_name_unique` ON `agent_config` (`name`);--> statement-breakpoint
36
+ CREATE TABLE `__new_session` (
37
+ `id` text PRIMARY KEY NOT NULL,
38
+ `kind` text NOT NULL,
39
+ `agent_config_id` text,
40
+ `scope_type` text NOT NULL,
41
+ `scope_id` text NOT NULL,
42
+ `cwd` text NOT NULL,
43
+ `command` text NOT NULL,
44
+ `state` text DEFAULT 'running' NOT NULL,
45
+ `exit_code` integer,
46
+ `transport` text DEFAULT 'pty' NOT NULL,
47
+ `acp_session_id` text,
48
+ `mode` text,
49
+ `model` text,
50
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
51
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
52
+ FOREIGN KEY (`agent_config_id`) REFERENCES `agent_config`(`id`) ON UPDATE no action ON DELETE restrict,
53
+ CONSTRAINT "session_kind" CHECK("__new_session"."kind" IN ('shell', 'agent')),
54
+ CONSTRAINT "session_scope_type" CHECK("__new_session"."scope_type" IN ('project', 'worktree')),
55
+ CONSTRAINT "session_state" CHECK("__new_session"."state" IN ('running', 'exited')),
56
+ CONSTRAINT "session_agent_config" CHECK(("__new_session"."kind" = 'agent' AND "__new_session"."agent_config_id" IS NOT NULL)
57
+ OR ("__new_session"."kind" = 'shell' AND "__new_session"."agent_config_id" IS NULL)),
58
+ CONSTRAINT "session_exit_code" CHECK(("__new_session"."state" = 'running' AND "__new_session"."exit_code" IS NULL)
59
+ OR ("__new_session"."state" = 'exited')),
60
+ CONSTRAINT "session_transport" CHECK("__new_session"."transport" IN ('pty', 'acp')),
61
+ CONSTRAINT "session_shell_transport" CHECK("__new_session"."kind" = 'agent' OR "__new_session"."transport" = 'pty'),
62
+ CONSTRAINT "session_acp_id" CHECK(("__new_session"."transport" = 'acp' AND "__new_session"."acp_session_id" IS NOT NULL)
63
+ OR ("__new_session"."transport" = 'pty' AND "__new_session"."acp_session_id" IS NULL))
64
+ );
65
+ --> statement-breakpoint
66
+ --> Same correction, same reason. Every session that exists is a PTY session
67
+ --> with no conversation attached, so `mode` and `model` are unknown rather than
68
+ --> guessed — the adapter is the only thing that can report them.
69
+ INSERT INTO `__new_session`("id", "kind", "agent_config_id", "scope_type", "scope_id", "cwd", "command", "state", "exit_code", "transport", "acp_session_id", "mode", "model", "created_at", "updated_at") SELECT "id", "kind", "agent_config_id", "scope_type", "scope_id", "cwd", "command", "state", "exit_code", 'pty', NULL, NULL, NULL, "created_at", "updated_at" FROM `session`;--> statement-breakpoint
70
+ DROP TABLE `session`;--> statement-breakpoint
71
+ ALTER TABLE `__new_session` RENAME TO `session`;
@@ -0,0 +1 @@
1
+ ALTER TABLE `session` ADD `resumed_from_id` text;
@@ -0,0 +1,127 @@
1
+ CREATE TABLE `action_signal` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `kind` text NOT NULL,
4
+ `target` text NOT NULL,
5
+ `workspace_id` text,
6
+ `project_id` text,
7
+ `worktree_id` text,
8
+ `session_id` text,
9
+ `detail` integer,
10
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
11
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
12
+ CONSTRAINT "action_signal_kind" CHECK("action_signal"."kind" IN (
13
+ 'user_edited_after_agent',
14
+ 'user_reverted_agent_commit',
15
+ 'worktree_discarded',
16
+ 'session_killed_early'
17
+ )),
18
+ CONSTRAINT "action_signal_detail_number" CHECK("action_signal"."detail" IS NULL OR typeof("action_signal"."detail") = 'integer'),
19
+ CONSTRAINT "action_signal_target_shape" CHECK(length("action_signal"."target") BETWEEN 1 AND 1024
20
+ AND instr("action_signal"."target", char(10)) = 0)
21
+ );
22
+ --> statement-breakpoint
23
+ CREATE TABLE `memory_access` (
24
+ `id` text PRIMARY KEY NOT NULL,
25
+ `workspace_id` text,
26
+ `from_project_id` text,
27
+ `target_project_id` text,
28
+ `kind` text NOT NULL,
29
+ `target` text NOT NULL,
30
+ `decision` text NOT NULL,
31
+ `reason` text,
32
+ `actor` text NOT NULL,
33
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
34
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
35
+ CONSTRAINT "memory_access_kind" CHECK("memory_access"."kind" IN ('memory', 'repository')),
36
+ CONSTRAINT "memory_access_decision" CHECK("memory_access"."decision" IN ('allowed', 'denied'))
37
+ );
38
+ --> statement-breakpoint
39
+ CREATE TABLE `memory_decision` (
40
+ `id` text PRIMARY KEY NOT NULL,
41
+ `idempotency_key` text NOT NULL,
42
+ `path` text NOT NULL,
43
+ `operation` text NOT NULL,
44
+ `outcome` text NOT NULL,
45
+ `actor` text NOT NULL,
46
+ `confidence` text NOT NULL,
47
+ `candidate_hash` text NOT NULL,
48
+ `rule_trace` text DEFAULT '[]' NOT NULL,
49
+ `source_sessions` text DEFAULT '[]' NOT NULL,
50
+ `reason` text,
51
+ `commit_sha` text,
52
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
53
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
54
+ CONSTRAINT "memory_decision_operation" CHECK("memory_decision"."operation" IN ('add', 'update', 'delete')),
55
+ CONSTRAINT "memory_decision_outcome" CHECK("memory_decision"."outcome" IN ('applied', 'noop', 'rejected'))
56
+ );
57
+ --> statement-breakpoint
58
+ CREATE UNIQUE INDEX `memory_decision_idempotency_key_unique` ON `memory_decision` (`idempotency_key`);--> statement-breakpoint
59
+ CREATE TABLE `memory_entry` (
60
+ `id` text PRIMARY KEY NOT NULL,
61
+ `path` text NOT NULL,
62
+ `type` text NOT NULL,
63
+ `scope` text NOT NULL,
64
+ `slug` text NOT NULL,
65
+ `workspace_id` text DEFAULT '' NOT NULL,
66
+ `project_id` text DEFAULT '' NOT NULL,
67
+ `name` text NOT NULL,
68
+ `description` text NOT NULL,
69
+ `source_actor` text NOT NULL,
70
+ `confidence` text NOT NULL,
71
+ `content_hash` text NOT NULL,
72
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
73
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
74
+ CONSTRAINT "memory_entry_type" CHECK("memory_entry"."type" IN ('user', 'feedback', 'project', 'domain', 'process', 'contract', 'reference')),
75
+ CONSTRAINT "memory_entry_scope" CHECK("memory_entry"."scope" IN ('global', 'workspace', 'project'))
76
+ );
77
+ --> statement-breakpoint
78
+ CREATE UNIQUE INDEX `memory_entry_path_unique` ON `memory_entry` (`path`);--> statement-breakpoint
79
+ CREATE UNIQUE INDEX `memory_entry_identity` ON `memory_entry` (`scope`,`workspace_id`,`project_id`,`type`,`slug`);--> statement-breakpoint
80
+ CREATE TABLE `memory_proposal` (
81
+ `id` text PRIMARY KEY NOT NULL,
82
+ `path` text NOT NULL,
83
+ `type` text NOT NULL,
84
+ `scope` text NOT NULL,
85
+ `slug` text NOT NULL,
86
+ `workspace_id` text,
87
+ `project_id` text,
88
+ `name` text NOT NULL,
89
+ `description` text NOT NULL,
90
+ `body` text DEFAULT '' NOT NULL,
91
+ `actor` text NOT NULL,
92
+ `from_project_id` text,
93
+ `session_id` text,
94
+ `confidence` text NOT NULL,
95
+ `evidence` text,
96
+ `status` text DEFAULT 'pending' NOT NULL,
97
+ `resolved_at` integer,
98
+ `resolution_note` text,
99
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
100
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
101
+ CONSTRAINT "memory_proposal_status" CHECK("memory_proposal"."status" IN ('pending', 'approved', 'rejected')),
102
+ CONSTRAINT "memory_proposal_type" CHECK("memory_proposal"."type" IN ('user', 'feedback', 'project', 'domain', 'process', 'contract', 'reference')),
103
+ CONSTRAINT "memory_proposal_scope" CHECK("memory_proposal"."scope" IN ('global', 'workspace', 'project')),
104
+ CONSTRAINT "memory_proposal_actor" CHECK("memory_proposal"."actor" IN ('human', 'agent', 'distiller', 'auto_research', 'import')),
105
+ CONSTRAINT "memory_proposal_confidence" CHECK("memory_proposal"."confidence" IN ('low', 'medium', 'high'))
106
+ );
107
+ --> statement-breakpoint
108
+ CREATE TABLE `memory_signal` (
109
+ `path` text PRIMARY KEY NOT NULL,
110
+ `recall_count` integer DEFAULT 0 NOT NULL,
111
+ `last_recalled_at` integer,
112
+ `best_score` real DEFAULT 0 NOT NULL,
113
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
114
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL
115
+ );
116
+ --> statement-breakpoint
117
+ CREATE TABLE `memory_usage` (
118
+ `id` text PRIMARY KEY NOT NULL,
119
+ `kind` text NOT NULL,
120
+ `session_id` text,
121
+ `workspace_id` text,
122
+ `project_id` text,
123
+ `amount` integer DEFAULT 0 NOT NULL,
124
+ `duration_ms` integer DEFAULT 0 NOT NULL,
125
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
126
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL
127
+ );
@@ -0,0 +1 @@
1
+ ALTER TABLE `memory_entry` ADD `pinned` integer DEFAULT false NOT NULL;
@@ -0,0 +1,21 @@
1
+ CREATE TABLE `playbook` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `path` text NOT NULL,
4
+ `scope` text NOT NULL,
5
+ `slug` text NOT NULL,
6
+ `workspace_id` text DEFAULT '' NOT NULL,
7
+ `project_id` text DEFAULT '' NOT NULL,
8
+ `task_class` text NOT NULL,
9
+ `description` text NOT NULL,
10
+ `pinned` integer DEFAULT false NOT NULL,
11
+ `archived` integer DEFAULT false NOT NULL,
12
+ `loads` integer DEFAULT 0 NOT NULL,
13
+ `last_loaded_at` integer,
14
+ `content_hash` text NOT NULL,
15
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
16
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
17
+ CONSTRAINT "playbook_scope" CHECK("playbook"."scope" IN ('workspace', 'project'))
18
+ );
19
+ --> statement-breakpoint
20
+ CREATE UNIQUE INDEX `playbook_path_unique` ON `playbook` (`path`);--> statement-breakpoint
21
+ CREATE UNIQUE INDEX `playbook_identity` ON `playbook` (`scope`,`workspace_id`,`project_id`,`slug`);
@@ -0,0 +1,15 @@
1
+ CREATE TABLE `session_usage` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `session_id` text NOT NULL,
4
+ `project_id` text NOT NULL,
5
+ `worktree_id` text DEFAULT '' NOT NULL,
6
+ `tokens` integer DEFAULT 0 NOT NULL,
7
+ `cost` real,
8
+ `currency` text,
9
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
10
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
11
+ CONSTRAINT "session_usage_tokens" CHECK("session_usage"."tokens" >= 0)
12
+ );
13
+ --> statement-breakpoint
14
+ CREATE INDEX `session_usage_project_at` ON `session_usage` (`project_id`,`created_at`);--> statement-breakpoint
15
+ CREATE INDEX `session_usage_worktree_at` ON `session_usage` (`worktree_id`,`created_at`);
@@ -0,0 +1,2 @@
1
+ ALTER TABLE `project` ADD `remote_url` text;--> statement-breakpoint
2
+ ALTER TABLE `project` ADD `managed` integer DEFAULT false NOT NULL;
@@ -0,0 +1,40 @@
1
+ PRAGMA foreign_keys=OFF;--> statement-breakpoint
2
+ CREATE TABLE `__new_session` (
3
+ `id` text PRIMARY KEY NOT NULL,
4
+ `kind` text NOT NULL,
5
+ `script_name` text,
6
+ `agent_config_id` text,
7
+ `scope_type` text NOT NULL,
8
+ `scope_id` text NOT NULL,
9
+ `cwd` text NOT NULL,
10
+ `command` text NOT NULL,
11
+ `state` text DEFAULT 'running' NOT NULL,
12
+ `exit_code` integer,
13
+ `transport` text DEFAULT 'pty' NOT NULL,
14
+ `acp_session_id` text,
15
+ `mode` text,
16
+ `model` text,
17
+ `resumed_from_id` text,
18
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
19
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
20
+ FOREIGN KEY (`agent_config_id`) REFERENCES `agent_config`(`id`) ON UPDATE no action ON DELETE restrict,
21
+ CONSTRAINT "session_kind" CHECK("__new_session"."kind" IN ('shell', 'agent', 'script')),
22
+ CONSTRAINT "session_scope_type" CHECK("__new_session"."scope_type" IN ('project', 'worktree')),
23
+ CONSTRAINT "session_state" CHECK("__new_session"."state" IN ('running', 'exited')),
24
+ CONSTRAINT "session_agent_config" CHECK(("__new_session"."kind" = 'agent' AND "__new_session"."agent_config_id" IS NOT NULL)
25
+ OR ("__new_session"."kind" <> 'agent' AND "__new_session"."agent_config_id" IS NULL)),
26
+ CONSTRAINT "session_script_name" CHECK(("__new_session"."kind" = 'script' AND "__new_session"."script_name" IS NOT NULL
27
+ AND "__new_session"."script_name" IN ('setup', 'run', 'teardown'))
28
+ OR ("__new_session"."kind" <> 'script' AND "__new_session"."script_name" IS NULL)),
29
+ CONSTRAINT "session_exit_code" CHECK(("__new_session"."state" = 'running' AND "__new_session"."exit_code" IS NULL)
30
+ OR ("__new_session"."state" = 'exited')),
31
+ CONSTRAINT "session_transport" CHECK("__new_session"."transport" IN ('pty', 'acp')),
32
+ CONSTRAINT "session_shell_transport" CHECK("__new_session"."kind" = 'agent' OR "__new_session"."transport" = 'pty'),
33
+ CONSTRAINT "session_acp_id" CHECK(("__new_session"."transport" = 'acp' AND "__new_session"."acp_session_id" IS NOT NULL)
34
+ OR ("__new_session"."transport" = 'pty' AND "__new_session"."acp_session_id" IS NULL))
35
+ );
36
+ --> statement-breakpoint
37
+ INSERT INTO `__new_session`("id", "kind", "script_name", "agent_config_id", "scope_type", "scope_id", "cwd", "command", "state", "exit_code", "transport", "acp_session_id", "mode", "model", "resumed_from_id", "created_at", "updated_at") SELECT "id", "kind", NULL, "agent_config_id", "scope_type", "scope_id", "cwd", "command", "state", "exit_code", "transport", "acp_session_id", "mode", "model", "resumed_from_id", "created_at", "updated_at" FROM `session`;--> statement-breakpoint
38
+ DROP TABLE `session`;--> statement-breakpoint
39
+ ALTER TABLE `__new_session` RENAME TO `session`;--> statement-breakpoint
40
+ PRAGMA foreign_keys=ON;
@@ -0,0 +1,13 @@
1
+ CREATE TABLE `checkout_port` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `scope_type` text NOT NULL,
4
+ `scope_id` text NOT NULL,
5
+ `port` integer NOT NULL,
6
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
7
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
8
+ CONSTRAINT "checkout_port_scope_type" CHECK("checkout_port"."scope_type" IN ('project', 'worktree')),
9
+ CONSTRAINT "checkout_port_range" CHECK("checkout_port"."port" > 0 AND "checkout_port"."port" < 65536)
10
+ );
11
+ --> statement-breakpoint
12
+ CREATE UNIQUE INDEX `checkout_port_scope` ON `checkout_port` (`scope_type`,`scope_id`);--> statement-breakpoint
13
+ CREATE UNIQUE INDEX `checkout_port_port` ON `checkout_port` (`port`);
@@ -0,0 +1 @@
1
+ ALTER TABLE `project` ADD `scripts_trusted_hash` text;
@@ -0,0 +1,40 @@
1
+ PRAGMA foreign_keys=OFF;--> statement-breakpoint
2
+ CREATE TABLE `__new_session` (
3
+ `id` text PRIMARY KEY NOT NULL,
4
+ `kind` text NOT NULL,
5
+ `script_name` text,
6
+ `agent_config_id` text,
7
+ `scope_type` text NOT NULL,
8
+ `scope_id` text NOT NULL,
9
+ `cwd` text NOT NULL,
10
+ `command` text NOT NULL,
11
+ `state` text DEFAULT 'running' NOT NULL,
12
+ `exit_code` integer,
13
+ `transport` text DEFAULT 'pty' NOT NULL,
14
+ `acp_session_id` text,
15
+ `mode` text,
16
+ `model` text,
17
+ `resumed_from_id` text,
18
+ `created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
19
+ `updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
20
+ FOREIGN KEY (`agent_config_id`) REFERENCES `agent_config`(`id`) ON UPDATE no action ON DELETE restrict,
21
+ CONSTRAINT "session_kind" CHECK("__new_session"."kind" IN ('shell', 'agent', 'script')),
22
+ CONSTRAINT "session_scope_type" CHECK("__new_session"."scope_type" IN ('project', 'worktree')),
23
+ CONSTRAINT "session_state" CHECK("__new_session"."state" IN ('running', 'exited')),
24
+ CONSTRAINT "session_agent_config" CHECK(("__new_session"."kind" = 'agent' AND "__new_session"."agent_config_id" IS NOT NULL)
25
+ OR ("__new_session"."kind" <> 'agent' AND "__new_session"."agent_config_id" IS NULL)),
26
+ CONSTRAINT "session_script_name" CHECK(("__new_session"."kind" = 'script' AND "__new_session"."script_name" IS NOT NULL
27
+ AND "__new_session"."script_name" IN ('setup', 'run', 'teardown', 'test'))
28
+ OR ("__new_session"."kind" <> 'script' AND "__new_session"."script_name" IS NULL)),
29
+ CONSTRAINT "session_exit_code" CHECK(("__new_session"."state" = 'running' AND "__new_session"."exit_code" IS NULL)
30
+ OR ("__new_session"."state" = 'exited')),
31
+ CONSTRAINT "session_transport" CHECK("__new_session"."transport" IN ('pty', 'acp')),
32
+ CONSTRAINT "session_shell_transport" CHECK("__new_session"."kind" = 'agent' OR "__new_session"."transport" = 'pty'),
33
+ CONSTRAINT "session_acp_id" CHECK(("__new_session"."transport" = 'acp' AND "__new_session"."acp_session_id" IS NOT NULL)
34
+ OR ("__new_session"."transport" = 'pty' AND "__new_session"."acp_session_id" IS NULL))
35
+ );
36
+ --> statement-breakpoint
37
+ INSERT INTO `__new_session`("id", "kind", "script_name", "agent_config_id", "scope_type", "scope_id", "cwd", "command", "state", "exit_code", "transport", "acp_session_id", "mode", "model", "resumed_from_id", "created_at", "updated_at") SELECT "id", "kind", "script_name", "agent_config_id", "scope_type", "scope_id", "cwd", "command", "state", "exit_code", "transport", "acp_session_id", "mode", "model", "resumed_from_id", "created_at", "updated_at" FROM `session`;--> statement-breakpoint
38
+ DROP TABLE `session`;--> statement-breakpoint
39
+ ALTER TABLE `__new_session` RENAME TO `session`;--> statement-breakpoint
40
+ PRAGMA foreign_keys=ON;