larness 0.6.0 → 0.6.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 (38) hide show
  1. package/apps/server/dist/index.js +40 -3
  2. package/apps/server/drizzle/0001_auth.sql +109 -109
  3. package/apps/server/drizzle/0002_projects.sql +12 -12
  4. package/apps/server/drizzle/0003_workspace.sql +80 -80
  5. package/apps/server/drizzle/0004_models.sql +30 -30
  6. package/apps/server/drizzle/0005_resources.sql +54 -54
  7. package/apps/server/drizzle/0006_commands.sql +23 -23
  8. package/apps/server/drizzle/0007_terminals.sql +41 -41
  9. package/apps/server/drizzle/0008_resource_actions.sql +23 -23
  10. package/apps/server/drizzle/0010_services.sql +31 -31
  11. package/apps/web/dist/assets/{FileEditor-Cm9Wkyig.js → FileEditor-2VPjs-RQ.js} +1 -1
  12. package/apps/web/dist/assets/{FileViewer-CZH6oX37.js → FileViewer-CZcKFZJT.js} +1 -1
  13. package/apps/web/dist/assets/{cssMode-CAew8VW7.js → cssMode-D-Rled60.js} +1 -1
  14. package/apps/web/dist/assets/{editor.api-CzAuy9rK.js → editor.api-C3oaU0qj.js} +1 -1
  15. package/apps/web/dist/assets/{freemarker2-BucrIW4m.js → freemarker2-D50E-mj1.js} +1 -1
  16. package/apps/web/dist/assets/{handlebars-PSDIVzvE.js → handlebars-_Xg_xwtq.js} +1 -1
  17. package/apps/web/dist/assets/{html-BAsmazci.js → html-BPuGWYaH.js} +1 -1
  18. package/apps/web/dist/assets/{htmlMode-Dc7T3d51.js → htmlMode-CwmSqoNt.js} +1 -1
  19. package/apps/web/dist/assets/{index-BzvuZhoD.js → index-DPZpqlAG.js} +2 -2
  20. package/apps/web/dist/assets/{javascript-BOV99GQZ.js → javascript-iFH4qFsX.js} +1 -1
  21. package/apps/web/dist/assets/{jsonMode-NusHHC7o.js → jsonMode-On0Ct3VU.js} +1 -1
  22. package/apps/web/dist/assets/{liquid-CNm5kTmC.js → liquid-BX3WY7Z7.js} +1 -1
  23. package/apps/web/dist/assets/{lspLanguageFeatures-Cqpje4pY.js → lspLanguageFeatures-BXlOyN1U.js} +1 -1
  24. package/apps/web/dist/assets/main-Bm74KyWu.css +1 -0
  25. package/apps/web/dist/assets/{main-ACTS2h7h.js → main-GXToakQe.js} +31 -31
  26. package/apps/web/dist/assets/{mdx-CiTFZ2Bw.js → mdx-Bzq19TjL.js} +1 -1
  27. package/apps/web/dist/assets/{monaco-A0m6b37p.js → monaco-DCdDhoJ6.js} +3 -3
  28. package/apps/web/dist/assets/{python-CB1KNVKd.js → python-CaZSKPNI.js} +1 -1
  29. package/apps/web/dist/assets/{razor-CWXh8JSQ.js → razor-CH1GgILn.js} +1 -1
  30. package/apps/web/dist/assets/{tsMode-DML0dqzP.js → tsMode-BWGjCNkx.js} +1 -1
  31. package/apps/web/dist/assets/{typescript-BVEQXq27.js → typescript-D2FxAaol.js} +1 -1
  32. package/apps/web/dist/assets/{workers-DOOC_w8B.js → workers-BUPNyHSF.js} +1 -1
  33. package/apps/web/dist/assets/{xml-kLrSHWW0.js → xml-nOgwOHKV.js} +1 -1
  34. package/apps/web/dist/assets/{yaml-CclA2znJ.js → yaml-CyK2AZ1G.js} +1 -1
  35. package/apps/web/dist/favicon.svg +4 -4
  36. package/apps/web/dist/index.html +1 -1
  37. package/package.json +1 -1
  38. package/apps/web/dist/assets/main-DLLJi8c-.css +0 -1
@@ -22,7 +22,7 @@ import { execFile, spawn } from "node:child_process";
22
22
  import { StringDecoder } from "node:string_decoder";
23
23
  import { isDeepStrictEqual, promisify } from "node:util";
24
24
  import { access, chmod, link, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, stat, statfs, unlink, writeFile } from "node:fs/promises";
25
- import { cpus, freemem, homedir, totalmem, userInfo } from "node:os";
25
+ import { arch, cpus, freemem, homedir, hostname, totalmem, userInfo } from "node:os";
26
26
  import cookie from "@fastify/cookie";
27
27
  import Fastify from "fastify";
28
28
  import { and, asc, count, desc, eq, exists, gt, gte, inArray, isNotNull, isNull, like, lt, lte, max, ne, notExists, notInArray, or, sql } from "drizzle-orm";
@@ -11474,7 +11474,7 @@ const BLOCKED_SUFFIXES$1 = [
11474
11474
  ".internal",
11475
11475
  ".home.arpa"
11476
11476
  ];
11477
- function normalizeHostname$1(hostname) {
11477
+ function normalizeHostname$2(hostname) {
11478
11478
  const lower = hostname.toLowerCase().replace(/\.$/, "");
11479
11479
  return lower.startsWith("[") && lower.endsWith("]") ? lower.slice(1, -1) : lower;
11480
11480
  }
@@ -11518,7 +11518,7 @@ async function assertSafeEndpoint(raw, resolver = defaultResolver) {
11518
11518
  }
11519
11519
  if (url.protocol !== "https:") throw new EndpointError("endpoint must use https");
11520
11520
  if (url.username.length > 0 || url.password.length > 0) throw new EndpointError("endpoint must not contain credentials");
11521
- const hostname = normalizeHostname$1(url.hostname);
11521
+ const hostname = normalizeHostname$2(url.hostname);
11522
11522
  if (hostname.length === 0) throw new EndpointError("endpoint host is required");
11523
11523
  if (isBlockedHostname(hostname)) throw new EndpointError("endpoint host is not allowed");
11524
11524
  const addresses = isIP(hostname) > 0 ? [hostname] : await resolver(hostname);
@@ -20002,6 +20002,42 @@ function collectResourceDiagnostics(db, now = Date.now()) {
20002
20002
  quarantinedRoots: quarantinedRoots()
20003
20003
  };
20004
20004
  }
20005
+ // src/modules/system/host.ts
20006
+ const HOSTNAME_MAX_LENGTH = 64;
20007
+ const FALLBACK_HOSTNAME = "Larness";
20008
+ const FALLBACK_ARCH = "unknown";
20009
+ /** Strips control characters, collapses whitespace and caps the label at 64 characters. */
20010
+ function normalizeHostname$1(raw) {
20011
+ const capped = Array.from(raw.replace(/[\t\n\r\v\f]/g, " ")).filter((character) => {
20012
+ const code = character.codePointAt(0) ?? 0;
20013
+ return code >= 32 && code !== 127;
20014
+ }).join("").replace(/\s+/g, " ").trim().slice(0, HOSTNAME_MAX_LENGTH).trim();
20015
+ return capped.length === 0 ? FALLBACK_HOSTNAME : capped;
20016
+ }
20017
+ function toServerPlatform(platform) {
20018
+ switch (platform) {
20019
+ case "darwin": return "macos";
20020
+ case "win32": return "windows";
20021
+ case "linux": return "linux";
20022
+ default: return "other";
20023
+ }
20024
+ }
20025
+ function readHostname(read) {
20026
+ try {
20027
+ return normalizeHostname$1(read());
20028
+ } catch {
20029
+ return FALLBACK_HOSTNAME;
20030
+ }
20031
+ }
20032
+ /** Identity of the machine running the Server, never the browser host. */
20033
+ function serverHostInfo(deps = {}) {
20034
+ const arch$1 = (deps.arch?.() ?? arch()).trim();
20035
+ return {
20036
+ hostname: readHostname(deps.hostname ?? hostname),
20037
+ platform: toServerPlatform(deps.platform ?? process.platform),
20038
+ arch: arch$1.length === 0 ? FALLBACK_ARCH : arch$1
20039
+ };
20040
+ }
20005
20041
  // src/modules/system/storage.ts
20006
20042
  const DAY_MS$2 = 864e5;
20007
20043
  /** D2 defaults; a dry-run report only, nothing is deleted. */
@@ -20093,6 +20129,7 @@ function storageReport(db, options) {
20093
20129
  // src/api/system.ts
20094
20130
  function registerSystemRoutes(app, deps) {
20095
20131
  app.get("/api/system/metrics", async () => deps.metrics.sample());
20132
+ app.get("/api/system/host", async () => (deps.host ?? serverHostInfo)());
20096
20133
  app.get("/api/system/storage", async () => storageReport(deps.db, {
20097
20134
  dataDir: deps.dataDir,
20098
20135
  ...deps.now === void 0 ? {} : { now: deps.now() }
@@ -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';