larness 0.5.0 → 0.6.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 (63) hide show
  1. package/apps/server/dist/{managed-Cw3MVilO.js → address-DpgJ0siq.js} +317 -183
  2. package/apps/server/dist/{args-CrKTPT06.js → args-BdJc1CBU.js} +29 -22
  3. package/apps/server/dist/cli.js +28 -7
  4. package/apps/server/dist/client-CBpatu1B.js +28 -0
  5. package/apps/server/dist/{client-D_Ni3Zpx.js → client-CoxHAiNW.js} +1 -1
  6. package/apps/server/dist/doctor-CGNZt_v3.js +1 -0
  7. package/apps/server/dist/{doctor-CE6cONuz.js → doctor-rpwPrkoS.js} +4 -3
  8. package/apps/server/dist/doctor.js +1 -1
  9. package/apps/server/dist/index.js +1424 -507
  10. package/apps/server/dist/{inspect-XgAc84F9.js → inspect-DUe_-Yma.js} +89 -1
  11. package/apps/server/dist/{lifecycle-C3KV3-Ax.js → lifecycle-Ck4LRKft.js} +7 -4
  12. package/apps/server/dist/managed-CpNf_iJZ.js +191 -0
  13. package/apps/server/dist/status-B6kiOT0f.js +94 -0
  14. package/apps/server/dist/status-C0hriYPD.js +681 -0
  15. package/apps/server/dist/status.js +1 -58
  16. package/apps/server/dist/{supervisor-IYDKL4iU.js → supervisor-BvHyiN7Z.js} +3 -2
  17. package/apps/server/dist/tui.js +5 -5
  18. package/apps/server/dist/unlock-hrRXYx4L.js +87 -0
  19. package/apps/server/drizzle/0001_auth.sql +109 -109
  20. package/apps/server/drizzle/0002_projects.sql +12 -12
  21. package/apps/server/drizzle/0003_workspace.sql +80 -80
  22. package/apps/server/drizzle/0004_models.sql +30 -30
  23. package/apps/server/drizzle/0005_resources.sql +54 -54
  24. package/apps/server/drizzle/0006_commands.sql +23 -23
  25. package/apps/server/drizzle/0007_terminals.sql +41 -41
  26. package/apps/server/drizzle/0008_resource_actions.sql +23 -23
  27. package/apps/server/drizzle/0010_services.sql +31 -31
  28. package/apps/server/drizzle/0039_user_input_requests.sql +20 -0
  29. package/apps/server/drizzle/meta/0039_snapshot.json +5907 -0
  30. package/apps/server/drizzle/meta/_journal.json +7 -0
  31. package/apps/web/dist/assets/{FileEditor-DnQa6Owc.js → FileEditor-Cm9Wkyig.js} +1 -1
  32. package/apps/web/dist/assets/{FileViewer-DKlF-CWF.js → FileViewer-CZH6oX37.js} +1 -1
  33. package/apps/web/dist/assets/{cssMode-C9KmpsHc.js → cssMode-CAew8VW7.js} +1 -1
  34. package/apps/web/dist/assets/{editor.api-BwfHyHQ6.js → editor.api-CzAuy9rK.js} +1 -1
  35. package/apps/web/dist/assets/{freemarker2-D41RlIQ5.js → freemarker2-BucrIW4m.js} +1 -1
  36. package/apps/web/dist/assets/{handlebars-D-7R6ic0.js → handlebars-PSDIVzvE.js} +1 -1
  37. package/apps/web/dist/assets/{html-CUME4rt-.js → html-BAsmazci.js} +1 -1
  38. package/apps/web/dist/assets/{htmlMode-8w7WLhnL.js → htmlMode-Dc7T3d51.js} +1 -1
  39. package/apps/web/dist/assets/{index-BOS3UrP1.js → index-BzvuZhoD.js} +2 -2
  40. package/apps/web/dist/assets/{javascript-_3pdDG34.js → javascript-BOV99GQZ.js} +1 -1
  41. package/apps/web/dist/assets/{jsonMode-DiqocFCf.js → jsonMode-NusHHC7o.js} +1 -1
  42. package/apps/web/dist/assets/{liquid-j0FoiTXN.js → liquid-CNm5kTmC.js} +1 -1
  43. package/apps/web/dist/assets/{lspLanguageFeatures-Zj7K2sG4.js → lspLanguageFeatures-Cqpje4pY.js} +1 -1
  44. package/apps/web/dist/assets/main-ACTS2h7h.js +157 -0
  45. package/apps/web/dist/assets/main-DLLJi8c-.css +1 -0
  46. package/apps/web/dist/assets/{mdx-CGQ8Cw6J.js → mdx-CiTFZ2Bw.js} +1 -1
  47. package/apps/web/dist/assets/{monaco-CyMA3azg.js → monaco-A0m6b37p.js} +3 -3
  48. package/apps/web/dist/assets/{python-BtY34Z9A.js → python-CB1KNVKd.js} +1 -1
  49. package/apps/web/dist/assets/{razor-CzYHpLv5.js → razor-CWXh8JSQ.js} +1 -1
  50. package/apps/web/dist/assets/{tsMode-GZx3VEv9.js → tsMode-DML0dqzP.js} +1 -1
  51. package/apps/web/dist/assets/{typescript-CAfvuTDQ.js → typescript-BVEQXq27.js} +1 -1
  52. package/apps/web/dist/assets/{workers-C5BOxOmH.js → workers-DOOC_w8B.js} +1 -1
  53. package/apps/web/dist/assets/{xml-BGX4mtH7.js → xml-kLrSHWW0.js} +1 -1
  54. package/apps/web/dist/assets/{yaml-B2AgBtJB.js → yaml-CclA2znJ.js} +1 -1
  55. package/apps/web/dist/favicon.svg +4 -4
  56. package/apps/web/dist/index.html +1 -1
  57. package/docs/guides/install.md +3 -0
  58. package/package.json +1 -1
  59. package/apps/server/dist/address-D0ZG5qR4.js +0 -97
  60. package/apps/server/dist/doctor-sPRlI92N.js +0 -1
  61. package/apps/server/dist/status-CV_zWfs6.js +0 -62
  62. package/apps/web/dist/assets/main-DZIruO5x.js +0 -157
  63. package/apps/web/dist/assets/main-gq3n_vn8.css +0 -1
@@ -1,58 +1 @@
1
- import { n as connectIpc } from "./client-D_Ni3Zpx.js";
2
- import { r as resolveDataDir } from "./paths-BhVn34MT.js";
3
- import { t as collectStatus } from "./status-CV_zWfs6.js";
4
- import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- // src/cli/status.ts
7
- /**
8
- * Merges the live IPC snapshot over the local report. A server started before
9
- * this CLI version does not send the newer fields, so fall back per field
10
- * instead of formatting an incomplete object.
11
- */
12
- function completeStatus(remote, fallback) {
13
- const defined = Object.fromEntries(Object.entries(remote).filter(([, value]) => value !== void 0));
14
- const merged = {
15
- ...fallback,
16
- ...defined
17
- };
18
- return {
19
- ...merged,
20
- warnings: merged.warnings.filter((warning) => !(merged.running && warning === "server is not running"))
21
- };
22
- }
23
- async function readStatus(options = {}) {
24
- const dataDir = options.dataDir ?? resolveDataDir(options.env ?? process.env);
25
- try {
26
- const client = await connectIpc({
27
- dataDir,
28
- client: "status",
29
- timeoutMs: 1500
30
- });
31
- try {
32
- return completeStatus(await client.request("system.status", {}, 1500), await collectStatus({
33
- dataDir,
34
- ...options.env === void 0 ? {} : { env: options.env }
35
- }));
36
- } finally {
37
- client.close();
38
- }
39
- } catch {
40
- return collectStatus({
41
- dataDir,
42
- ...options.env === void 0 ? {} : { env: options.env }
43
- });
44
- }
45
- }
46
- function isEntryPoint() {
47
- const entry = process.argv[1];
48
- return entry !== void 0 && path.resolve(entry) === fileURLToPath(import.meta.url);
49
- }
50
- if (isEntryPoint()) try {
51
- const status = await readStatus();
52
- process.stdout.write(`${JSON.stringify(status, null, 2)}\n`);
53
- } catch (error) {
54
- const message = error instanceof Error ? error.message : String(error);
55
- process.stderr.write(`[larness] status failed: ${message}\n`);
56
- process.exitCode = 1;
57
- }
58
- export { completeStatus, readStatus };
1
+ export { t as completeStatus, n as readBarrierSummary, r as readStatus } from "./status-B6kiOT0f.js";
@@ -1,5 +1,6 @@
1
- import { a as DevWebControl, c as EntryConfigError, d as devWebCache, i as DevWebAttachedSchema, it as terminateProcessTree, r as waitChildMessage } from "./managed-Cw3MVilO.js";
2
- import { c as configFilePath, l as loadConfig, n as inspectPendingInitialization, p as findServerRoot, u as resolveConfig } from "./inspect-XgAc84F9.js";
1
+ import { dt as terminateProcessTree } from "./address-DpgJ0siq.js";
2
+ import { c as configFilePath, l as loadConfig, n as inspectPendingInitialization, p as findServerRoot, u as resolveConfig } from "./inspect-DUe_-Yma.js";
3
+ import { a as DevWebControl, c as EntryConfigError, d as devWebCache, i as DevWebAttachedSchema, r as waitChildMessage } from "./managed-CpNf_iJZ.js";
3
4
  import { r as resolveDataDir } from "./paths-BhVn34MT.js";
4
5
  import { createRequire } from "node:module";
5
6
  import { randomUUID } from "node:crypto";
@@ -1,11 +1,11 @@
1
- import { i as inspectInstanceLock, jn as deriveWebAuthn, kn as DEFAULT_APP_CONFIG } from "./inspect-XgAc84F9.js";
2
- import { c as EntryConfigError, s as DevWebUnavailable } from "./managed-Cw3MVilO.js";
3
- import { n as connectIpc, t as IpcClientError } from "./client-D_Ni3Zpx.js";
1
+ import { Bn as deriveWebAuthn, Rn as DEFAULT_APP_CONFIG, i as inspectInstanceLock } from "./inspect-DUe_-Yma.js";
2
+ import { c as EntryConfigError, s as DevWebUnavailable } from "./managed-CpNf_iJZ.js";
3
+ import { n as connectIpc, t as IpcClientError } from "./client-CoxHAiNW.js";
4
4
  import { r as resolveDataDir } from "./paths-BhVn34MT.js";
5
5
  import { t as SERVER_VERSION } from "./version-ui_X8H2k.js";
6
- import { s as InitApplyParamsSchema } from "./address-D0ZG5qR4.js";
6
+ import { s as InitApplyParamsSchema } from "./address-DpgJ0siq.js";
7
7
  import { i as formatPairingCode } from "./code-B2JBoV4x.js";
8
- import { n as startManagedRuntime } from "./supervisor-IYDKL4iU.js";
8
+ import { n as startManagedRuntime } from "./supervisor-BvHyiN7Z.js";
9
9
  import path from "node:path";
10
10
  import { z } from "zod";
11
11
  import { stripVTControlCharacters } from "node:util";
@@ -0,0 +1,87 @@
1
+ import { i as inspectInstanceLock } from "./inspect-DUe_-Yma.js";
2
+ import { t as openDatabase } from "./client-CBpatu1B.js";
3
+ import { n as barrierReasonLabel, s as settleWriteBarriers } from "./status-C0hriYPD.js";
4
+ import { r as resolveDataDir } from "./paths-BhVn34MT.js";
5
+ import { n as readBarrierSummary } from "./status-B6kiOT0f.js";
6
+ import path from "node:path";
7
+ // src/cli/unlock.ts
8
+ function databasePath(dataDir) {
9
+ return path.join(dataDir, "larness.db");
10
+ }
11
+ function describeItem(item) {
12
+ const where = item.rootRealPath ?? "(no root)";
13
+ const pid = item.pid === null ? "" : ` pid=${item.pid}`;
14
+ return `${item.type} ${item.kind} ${item.status}${pid} · ${item.reason} (${barrierReasonLabel(item.reason)}) · ${where}`;
15
+ }
16
+ function printPreview(io, summary) {
17
+ const settleable = summary.items.filter((item) => item.reason === "settleable");
18
+ const retained = summary.items.filter((item) => item.reason !== "settleable");
19
+ if (settleable.length > 0) {
20
+ io.stdout(`[larness] ${settleable.length} barrier(s) can be cleared at the next start\n`);
21
+ for (const item of settleable) io.stdout(` ${describeItem(item)}\n`);
22
+ }
23
+ if (retained.length > 0) {
24
+ io.stdout(`[larness] ${retained.length} barrier(s) cannot be proven orphaned\n`);
25
+ for (const item of retained) io.stdout(` ${describeItem(item)}\n`);
26
+ io.stdout("[larness] stop the server, then run `larness unlock --force`; add --allow-live to clear a barrier whose process still runs\n");
27
+ }
28
+ if (settleable.length === 0 && retained.length === 0) io.stdout("[larness] no write barriers\n");
29
+ }
30
+ function printRetained(io, items) {
31
+ io.stderr(`[larness] ${items.length} barrier(s) kept: their recorded process is still running\n`);
32
+ io.stderr("[larness] re-run with --allow-live to clear them (processes are not killed)\n");
33
+ for (const item of items) io.stderr(` ${describeItem(item)}\n`);
34
+ }
35
+ async function unlockCommand(io, options) {
36
+ const dataDir = resolveDataDir(io.env);
37
+ const summary = await readBarrierSummary(dataDir).catch(() => null);
38
+ if (summary === null) {
39
+ io.stderr(`[larness] no resource tables under ${dataDir}; start the server once first.\n`);
40
+ return 3;
41
+ }
42
+ if (options.force) {
43
+ if ((await inspectInstanceLock(dataDir))?.alive === true) {
44
+ io.stderr("[larness] the management server is still running; nothing was changed.\n");
45
+ io.stderr("[larness] run `larness stop` first, then retry `larness unlock --force`.\n");
46
+ return 1;
47
+ }
48
+ }
49
+ if (!options.force) {
50
+ if (options.json) io.stdout(`${JSON.stringify(summary, null, 2)}\n`);
51
+ else printPreview(io, summary);
52
+ return 0;
53
+ }
54
+ const opened = openDatabase(databasePath(dataDir));
55
+ let finalizedOperations = 0;
56
+ let releasedLocks = 0;
57
+ try {
58
+ const report = await settleWriteBarriers({
59
+ db: opened.db,
60
+ mode: "force",
61
+ allowLive: options.allowLive
62
+ });
63
+ finalizedOperations = report.finalizedOperations;
64
+ releasedLocks = report.releasedLocks;
65
+ } finally {
66
+ opened.close();
67
+ }
68
+ const retained = (await readBarrierSummary(dataDir).catch(() => null))?.items ?? [];
69
+ if (options.json) {
70
+ io.stdout(`${JSON.stringify({
71
+ mode: "force",
72
+ allowLive: options.allowLive,
73
+ finalizedOperations,
74
+ releasedLocks,
75
+ retained
76
+ }, null, 2)}\n`);
77
+ return retained.length === 0 ? 0 : 1;
78
+ }
79
+ io.stdout(`[larness] cleared ${finalizedOperations} operation(s) and ${releasedLocks} lock(s)\n`);
80
+ if (retained.length > 0) {
81
+ printRetained(io, retained);
82
+ return 1;
83
+ }
84
+ io.stdout("[larness] no write barriers remain\n");
85
+ return 0;
86
+ }
87
+ export { unlockCommand };
@@ -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
+ );