larness 0.0.0-stage → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +40 -2
- package/app.js +122 -0
- package/apps/server/dist/address-BE25lU9-.js +94 -0
- package/apps/server/dist/client-Co1thYbK.js +120 -0
- package/apps/server/dist/doctor-ClvbJZvj.js +127 -0
- package/apps/server/dist/doctor.js +12 -0
- package/apps/server/dist/index.js +27349 -0
- package/apps/server/dist/lock-DyEoZgG_.js +101 -0
- package/apps/server/dist/managed-CLFUiDbj.js +2138 -0
- package/apps/server/dist/paths-BHryFHwq.js +2337 -0
- package/apps/server/dist/status-idXF0pm6.js +49 -0
- package/apps/server/dist/status.js +30 -0
- package/apps/server/dist/tui.js +1626 -0
- package/apps/server/drizzle/0001_auth.sql +110 -0
- package/apps/server/drizzle/0002_projects.sql +13 -0
- package/apps/server/drizzle/0003_workspace.sql +81 -0
- package/apps/server/drizzle/0004_models.sql +30 -0
- package/apps/server/drizzle/0005_resources.sql +54 -0
- package/apps/server/drizzle/0006_commands.sql +24 -0
- package/apps/server/drizzle/0007_terminals.sql +42 -0
- package/apps/server/drizzle/0008_resource_actions.sql +24 -0
- package/apps/server/drizzle/0009_terminal_title.sql +1 -0
- package/apps/server/drizzle/0010_services.sql +32 -0
- package/apps/server/drizzle/0011_deployments.sql +88 -0
- package/apps/server/drizzle/0012_deployment_authorizations.sql +67 -0
- package/apps/server/drizzle/0013_service_ops.sql +64 -0
- package/apps/server/drizzle/0014_service_actions.sql +36 -0
- package/apps/server/drizzle/0015_model_catalog.sql +17 -0
- package/apps/server/drizzle/0016_multi_provider.sql +2 -0
- package/apps/server/drizzle/0017_model_visibility.sql +10 -0
- package/apps/server/drizzle/0018_model_defaults.sql +9 -0
- package/apps/server/drizzle/0019_credential_endpoint.sql +1 -0
- package/apps/server/drizzle/0020_compatible_context.sql +1 -0
- package/apps/server/drizzle/0021_context_summaries.sql +13 -0
- package/apps/server/drizzle/0022_scheduler.sql +58 -0
- package/apps/server/drizzle/0023_turn_terminal_reason.sql +1 -0
- package/apps/server/drizzle/0024_turn_checkpoints.sql +4 -0
- package/apps/server/drizzle/0025_turn_resume.sql +1 -0
- package/apps/server/drizzle/0026_session_pin.sql +1 -0
- package/apps/server/drizzle/0027_project_sort_order.sql +2 -0
- package/apps/server/drizzle/meta/0001_snapshot.json +705 -0
- package/apps/server/drizzle/meta/0002_snapshot.json +784 -0
- package/apps/server/drizzle/meta/0003_snapshot.json +1300 -0
- package/apps/server/drizzle/meta/0004_snapshot.json +1489 -0
- package/apps/server/drizzle/meta/0005_snapshot.json +1794 -0
- package/apps/server/drizzle/meta/0006_snapshot.json +1953 -0
- package/apps/server/drizzle/meta/0007_snapshot.json +2232 -0
- package/apps/server/drizzle/meta/0008_snapshot.json +2391 -0
- package/apps/server/drizzle/meta/0009_snapshot.json +2398 -0
- package/apps/server/drizzle/meta/0010_snapshot.json +2601 -0
- package/apps/server/drizzle/meta/0015_snapshot.json +4332 -0
- package/apps/server/drizzle/meta/0016_snapshot.json +4346 -0
- package/apps/server/drizzle/meta/0017_snapshot.json +4408 -0
- package/apps/server/drizzle/meta/0018_snapshot.json +4468 -0
- package/apps/server/drizzle/meta/0019_snapshot.json +4475 -0
- package/apps/server/drizzle/meta/0020_snapshot.json +4482 -0
- package/apps/server/drizzle/meta/0021_snapshot.json +4565 -0
- package/apps/server/drizzle/meta/0022_snapshot.json +4960 -0
- package/apps/server/drizzle/meta/0023_snapshot.json +4967 -0
- package/apps/server/drizzle/meta/0024_snapshot.json +4994 -0
- package/apps/server/drizzle/meta/0025_snapshot.json +5001 -0
- package/apps/server/drizzle/meta/0026_snapshot.json +5008 -0
- package/apps/server/drizzle/meta/0027_snapshot.json +5021 -0
- package/apps/server/drizzle/meta/_journal.json +195 -0
- package/apps/server/package.json +57 -0
- package/apps/web/dist/assets/FileEditor-twkRcPR8.js +1 -0
- package/apps/web/dist/assets/FileViewer-B6J1gfWW.js +1 -0
- package/apps/web/dist/assets/abap-08VXUWAP.js +1 -0
- package/apps/web/dist/assets/apex-BWPQTe0t.js +1 -0
- package/apps/web/dist/assets/azcli-Bc_sGQ0U.js +1 -0
- package/apps/web/dist/assets/bat-i0X4ZdIN.js +1 -0
- package/apps/web/dist/assets/bicep-B5-_aFwp.js +2 -0
- package/apps/web/dist/assets/cameligo-DMUM7wLl.js +1 -0
- package/apps/web/dist/assets/clojure-Cm7r79vr.js +1 -0
- package/apps/web/dist/assets/codicon-DF1abBS2.ttf +0 -0
- package/apps/web/dist/assets/coffee-Ba7i2nA0.js +1 -0
- package/apps/web/dist/assets/cpp-C7h46wYY.js +1 -0
- package/apps/web/dist/assets/csharp-BKxtCVv1.js +1 -0
- package/apps/web/dist/assets/csp-bTuwJoIa.js +1 -0
- package/apps/web/dist/assets/css-DIMkf-bt.js +3 -0
- package/apps/web/dist/assets/css.worker-C5TGqYcS.js +96 -0
- package/apps/web/dist/assets/cssMode-B2gCrV51.js +1 -0
- package/apps/web/dist/assets/cypher-CVaqCwHa.js +1 -0
- package/apps/web/dist/assets/dart-onAF5SnQ.js +1 -0
- package/apps/web/dist/assets/dockerfile-DZFCIeNp.js +1 -0
- package/apps/web/dist/assets/ecl-94qehhXe.js +1 -0
- package/apps/web/dist/assets/editor-B8GMDV7_.css +1 -0
- package/apps/web/dist/assets/editor.api-TQGsXQVT.js +908 -0
- package/apps/web/dist/assets/editor.worker-uJzjfcWc.js +33 -0
- package/apps/web/dist/assets/elixir-6RTg0lbw.js +1 -0
- package/apps/web/dist/assets/flow9-C5_-GSwl.js +1 -0
- package/apps/web/dist/assets/freemarker2-Due01FLd.js +3 -0
- package/apps/web/dist/assets/fsharp-C8Ef5oNN.js +1 -0
- package/apps/web/dist/assets/go-C-y9NEjX.js +1 -0
- package/apps/web/dist/assets/graphql-fmXr3nnJ.js +1 -0
- package/apps/web/dist/assets/handlebars-Cbmho-0R.js +1 -0
- package/apps/web/dist/assets/hcl-CpzslTdj.js +1 -0
- package/apps/web/dist/assets/html-1Ke8CI8o.js +1 -0
- package/apps/web/dist/assets/html.worker-DthhmbAk.js +509 -0
- package/apps/web/dist/assets/htmlMode-KxcipU--.js +1 -0
- package/apps/web/dist/assets/index-BvfzAW2A.js +158 -0
- package/apps/web/dist/assets/index-DxcI8GSl.css +1 -0
- package/apps/web/dist/assets/ini-sBoK_t0W.js +1 -0
- package/apps/web/dist/assets/java-BEtHBSE6.js +1 -0
- package/apps/web/dist/assets/javascript-DMPkDcJu.js +1 -0
- package/apps/web/dist/assets/json.worker-BGaEIa3n.js +65 -0
- package/apps/web/dist/assets/jsonMode-CLqudskm.js +7 -0
- package/apps/web/dist/assets/julia-Bri6UV-V.js +1 -0
- package/apps/web/dist/assets/kotlin-BOotOW0E.js +1 -0
- package/apps/web/dist/assets/less-B9JPFI3C.js +2 -0
- package/apps/web/dist/assets/lexon-CfSJPG6W.js +1 -0
- package/apps/web/dist/assets/liquid-bIUiAHG1.js +1 -0
- package/apps/web/dist/assets/lspLanguageFeatures-CplKbdW4.js +4 -0
- package/apps/web/dist/assets/lua-CsQS60Ue.js +1 -0
- package/apps/web/dist/assets/m3-D-oSqn_W.js +1 -0
- package/apps/web/dist/assets/markdown-Cimd5fb3.js +1 -0
- package/apps/web/dist/assets/mdx-DiInMCu3.js +1 -0
- package/apps/web/dist/assets/mips-CIPQ_RoX.js +1 -0
- package/apps/web/dist/assets/monaco-D_A7VB90.js +68 -0
- package/apps/web/dist/assets/monaco-n7clI0si.css +1 -0
- package/apps/web/dist/assets/msdax-DauUninz.js +1 -0
- package/apps/web/dist/assets/mysql-SOo6toE5.js +1 -0
- package/apps/web/dist/assets/objective-c-FvmIjYaQ.js +1 -0
- package/apps/web/dist/assets/pascal-DrH0SRf2.js +1 -0
- package/apps/web/dist/assets/pascaligo-D-ptJ9y-.js +1 -0
- package/apps/web/dist/assets/perl-oz_6vUea.js +1 -0
- package/apps/web/dist/assets/pgsql-DTj74zXo.js +1 -0
- package/apps/web/dist/assets/php-nr791fC2.js +1 -0
- package/apps/web/dist/assets/pla-CopQ2nXW.js +1 -0
- package/apps/web/dist/assets/postiats-43DmfD33.js +1 -0
- package/apps/web/dist/assets/powerquery-D3hlyOfw.js +1 -0
- package/apps/web/dist/assets/powershell-DmHpPYUd.js +1 -0
- package/apps/web/dist/assets/protobuf-C531GsRP.js +2 -0
- package/apps/web/dist/assets/pug-Z5eAx3Zn.js +1 -0
- package/apps/web/dist/assets/python-O93J5sRJ.js +1 -0
- package/apps/web/dist/assets/qsharp-DkqhCAOL.js +1 -0
- package/apps/web/dist/assets/r-BwWrilGY.js +1 -0
- package/apps/web/dist/assets/razor-DpA8sAYd.js +1 -0
- package/apps/web/dist/assets/redis-ClamHrr6.js +1 -0
- package/apps/web/dist/assets/redshift-DT7zqm-g.js +1 -0
- package/apps/web/dist/assets/restructuredtext-BYgofb2h.js +1 -0
- package/apps/web/dist/assets/ruby-DezsRK8O.js +1 -0
- package/apps/web/dist/assets/rust-DdL9SqIa.js +1 -0
- package/apps/web/dist/assets/sb-CcwsVR0C.js +1 -0
- package/apps/web/dist/assets/scala-DHpiXF5c.js +1 -0
- package/apps/web/dist/assets/scheme-BeGwcela.js +1 -0
- package/apps/web/dist/assets/scss-gp-XZpBa.js +3 -0
- package/apps/web/dist/assets/shell-CC2rA5mh.js +1 -0
- package/apps/web/dist/assets/solidity-BEEn4gHE.js +1 -0
- package/apps/web/dist/assets/sophia-CRfGWb83.js +1 -0
- package/apps/web/dist/assets/sparql-D_Lu-MrJ.js +1 -0
- package/apps/web/dist/assets/sql-NEE52Syq.js +1 -0
- package/apps/web/dist/assets/st-DbInun42.js +1 -0
- package/apps/web/dist/assets/swift-Bxkupp3x.js +1 -0
- package/apps/web/dist/assets/systemverilog-Bz4Y3fRF.js +1 -0
- package/apps/web/dist/assets/tcl-DISqw1ZD.js +1 -0
- package/apps/web/dist/assets/ts.worker-CUR_zL4j.js +67741 -0
- package/apps/web/dist/assets/tsMode-qBmFN2NS.js +11 -0
- package/apps/web/dist/assets/twig-De2hgUGE.js +1 -0
- package/apps/web/dist/assets/typescript-BjR2yH8S.js +1 -0
- package/apps/web/dist/assets/typespec-B8J7ngcE.js +1 -0
- package/apps/web/dist/assets/vb-DV3o63ZY.js +1 -0
- package/apps/web/dist/assets/wgsl-DpFanUEy.js +298 -0
- package/apps/web/dist/assets/workers-x9_8y1ur.js +1 -0
- package/apps/web/dist/assets/xml-CL70_TAY.js +1 -0
- package/apps/web/dist/assets/yaml-qno5z39m.js +1 -0
- package/apps/web/dist/favicon.svg +4 -0
- package/apps/web/dist/index.html +15 -0
- package/docs/README.md +26 -0
- package/docs/guides/install.md +88 -0
- package/package.json +95 -4
|
@@ -0,0 +1,2337 @@
|
|
|
1
|
+
import { closeSync, constants, existsSync, fsyncSync, openSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { access, chmod, mkdir, readFile, stat } from "node:fs/promises";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { eq, sql } from "drizzle-orm";
|
|
8
|
+
import { check, index, integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
|
|
9
|
+
import BetterSqlite3 from "better-sqlite3";
|
|
10
|
+
import { migrate } from "drizzle-orm/better-sqlite3/migrator";
|
|
11
|
+
import envPaths from "env-paths";
|
|
12
|
+
// \0rolldown/runtime.js
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __exportAll = (all, flags) => {
|
|
15
|
+
let target = Object.setPrototypeOf({}, null);
|
|
16
|
+
for (var name in all) __defProp(target, name, {
|
|
17
|
+
get: all[name],
|
|
18
|
+
enumerable: true
|
|
19
|
+
});
|
|
20
|
+
if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
21
|
+
return flags & 2 ? target : Object.preventExtensions(target);
|
|
22
|
+
};
|
|
23
|
+
z.enum([
|
|
24
|
+
"project",
|
|
25
|
+
"default",
|
|
26
|
+
"session"
|
|
27
|
+
]);
|
|
28
|
+
const MAX_EDITABLE_FILE_BYTES = 524288;
|
|
29
|
+
const resourceId = z.string().min(1).max(128);
|
|
30
|
+
const FileScopeSchema = z.union([
|
|
31
|
+
z.object({ workspace: z.literal("default") }).strict(),
|
|
32
|
+
z.object({ projectId: resourceId }).strict(),
|
|
33
|
+
z.object({ sessionId: resourceId }).strict()
|
|
34
|
+
]);
|
|
35
|
+
const FilePathSchema = z.string().min(1).max(4096).refine((value) => {
|
|
36
|
+
const normalized = value.replaceAll("\\", "/");
|
|
37
|
+
return !normalized.startsWith("/") && !normalized.includes("\0") && normalized.split("/").every((part) => part !== ".." && !part.includes(":"));
|
|
38
|
+
}, "Expected a relative path inside the authorized root").transform((value) => value.replaceAll("\\", "/"));
|
|
39
|
+
const FileVersionSchema = z.string().regex(/^[a-f0-9]{64}$/);
|
|
40
|
+
const FileSaveSchema = z.object({
|
|
41
|
+
scope: FileScopeSchema,
|
|
42
|
+
path: FilePathSchema,
|
|
43
|
+
content: z.string().max(1048576),
|
|
44
|
+
expectedVersion: FileVersionSchema
|
|
45
|
+
}).strict();
|
|
46
|
+
const FileReadQuerySchema = z.union([
|
|
47
|
+
z.object({
|
|
48
|
+
workspace: z.literal("default"),
|
|
49
|
+
path: FilePathSchema,
|
|
50
|
+
version: FileVersionSchema.optional()
|
|
51
|
+
}).strict(),
|
|
52
|
+
z.object({
|
|
53
|
+
projectId: resourceId,
|
|
54
|
+
path: FilePathSchema,
|
|
55
|
+
version: FileVersionSchema.optional()
|
|
56
|
+
}).strict(),
|
|
57
|
+
z.object({
|
|
58
|
+
sessionId: resourceId,
|
|
59
|
+
path: FilePathSchema,
|
|
60
|
+
version: FileVersionSchema.optional()
|
|
61
|
+
}).strict()
|
|
62
|
+
]);
|
|
63
|
+
const FileListQuerySchema = z.object({
|
|
64
|
+
path: FilePathSchema.default("."),
|
|
65
|
+
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
66
|
+
cursor: z.string().min(1).max(2048).optional()
|
|
67
|
+
}).strict();
|
|
68
|
+
const FileSaveResultSchema = z.object({
|
|
69
|
+
path: z.string(),
|
|
70
|
+
realPath: z.string(),
|
|
71
|
+
content: z.string(),
|
|
72
|
+
version: FileVersionSchema,
|
|
73
|
+
size: z.number().int().nonnegative(),
|
|
74
|
+
encoding: z.literal("utf-8")
|
|
75
|
+
}).omit({
|
|
76
|
+
content: true,
|
|
77
|
+
encoding: true
|
|
78
|
+
}).extend({ previousVersion: FileVersionSchema });
|
|
79
|
+
const FileEntrySchema = z.object({
|
|
80
|
+
path: z.string(),
|
|
81
|
+
name: z.string(),
|
|
82
|
+
type: z.enum(["file", "directory"]),
|
|
83
|
+
size: z.number().int().nonnegative().optional()
|
|
84
|
+
});
|
|
85
|
+
z.object({
|
|
86
|
+
items: z.array(FileEntrySchema),
|
|
87
|
+
nextCursor: z.string().nullable(),
|
|
88
|
+
revision: FileVersionSchema
|
|
89
|
+
});
|
|
90
|
+
const FileResultTargetSchema = z.object({
|
|
91
|
+
kind: z.literal("file"),
|
|
92
|
+
scope: FileScopeSchema,
|
|
93
|
+
path: FilePathSchema,
|
|
94
|
+
version: FileVersionSchema.optional()
|
|
95
|
+
}).strict();
|
|
96
|
+
// ../../packages/shared/src/commands.ts
|
|
97
|
+
const CommandParamsSchema = z.object({
|
|
98
|
+
executable: z.string().min(1).max(4096).refine((value) => !value.includes("\0")),
|
|
99
|
+
args: z.array(z.string().max(8192).refine((value) => !value.includes("\0"))).max(256),
|
|
100
|
+
cwd: FilePathSchema.default("."),
|
|
101
|
+
timeoutMs: z.number().int().min(1).max(6e5).default(12e4)
|
|
102
|
+
}).strict().refine((value) => value.args.reduce((size, arg) => size + arg.length, value.executable.length) <= 65536);
|
|
103
|
+
const CommandStatusSchema = z.enum([
|
|
104
|
+
"CREATED",
|
|
105
|
+
"RUNNING",
|
|
106
|
+
"CANCELLING",
|
|
107
|
+
"COMPLETED",
|
|
108
|
+
"FAILED",
|
|
109
|
+
"CANCELLED",
|
|
110
|
+
"TIMED_OUT",
|
|
111
|
+
"INTERRUPTED"
|
|
112
|
+
]);
|
|
113
|
+
const CommandOutputQuerySchema = z.object({
|
|
114
|
+
after: z.coerce.number().int().min(0).max(Number.MAX_SAFE_INTEGER).default(0),
|
|
115
|
+
limit: z.coerce.number().int().min(1).max(500).default(100)
|
|
116
|
+
}).strict();
|
|
117
|
+
const CommandOutputChunkSchema = z.object({
|
|
118
|
+
cursor: z.number().int().positive(),
|
|
119
|
+
data: z.string().max(16384).refine((data) => new TextEncoder().encode(data).byteLength <= 16384),
|
|
120
|
+
channel: z.enum(["stdout", "stderr"]),
|
|
121
|
+
timestamp: z.number().int()
|
|
122
|
+
}).strict();
|
|
123
|
+
const CommandStatusPayloadSchema = z.object({
|
|
124
|
+
status: CommandStatusSchema,
|
|
125
|
+
exitCode: z.number().int().nullable(),
|
|
126
|
+
reasonCode: z.string().nullable(),
|
|
127
|
+
truncated: z.boolean(),
|
|
128
|
+
startedAt: z.number().nullable(),
|
|
129
|
+
endedAt: z.number().nullable()
|
|
130
|
+
});
|
|
131
|
+
const CommandCancelSchema = z.object({}).strict();
|
|
132
|
+
const COMMAND_OUTPUT_RETENTION_MS = 6048e5;
|
|
133
|
+
const COMMAND_RETENTION_MS = 2592e6;
|
|
134
|
+
const CommandIdSchema = z.string().regex(/^cmd_[a-f0-9-]{36}$/);
|
|
135
|
+
const CommandSubscriptionSchema = z.object({
|
|
136
|
+
topic: z.literal("command"),
|
|
137
|
+
resourceId: CommandIdSchema,
|
|
138
|
+
after: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).default(0)
|
|
139
|
+
}).strict();
|
|
140
|
+
const CommandStatusEventSchema = z.object({
|
|
141
|
+
kind: z.literal("event"),
|
|
142
|
+
protocolVersion: z.literal(1),
|
|
143
|
+
topic: z.literal("command"),
|
|
144
|
+
eventId: z.string(),
|
|
145
|
+
streamId: CommandIdSchema,
|
|
146
|
+
resourceId: CommandIdSchema,
|
|
147
|
+
sequence: z.number().int().nonnegative(),
|
|
148
|
+
timestamp: z.number(),
|
|
149
|
+
type: z.literal("command.status"),
|
|
150
|
+
payload: CommandStatusPayloadSchema
|
|
151
|
+
});
|
|
152
|
+
z.object({
|
|
153
|
+
id: CommandIdSchema,
|
|
154
|
+
scope: z.object({ projectId: z.string() }).strict().or(z.object({ sessionId: z.string() }).strict()),
|
|
155
|
+
status: CommandStatusSchema,
|
|
156
|
+
exitCode: z.number().nullable(),
|
|
157
|
+
reasonCode: z.string().nullable(),
|
|
158
|
+
truncated: z.boolean(),
|
|
159
|
+
startedAt: z.number().nullable(),
|
|
160
|
+
endedAt: z.number().nullable(),
|
|
161
|
+
currentSequence: z.number().int().nonnegative()
|
|
162
|
+
});
|
|
163
|
+
z.object({
|
|
164
|
+
chunks: z.array(CommandOutputChunkSchema).max(500),
|
|
165
|
+
oldestCursor: z.number().int().positive(),
|
|
166
|
+
nextCursor: z.number().int().nonnegative(),
|
|
167
|
+
truncated: z.boolean(),
|
|
168
|
+
resyncRequired: z.boolean()
|
|
169
|
+
});
|
|
170
|
+
CommandOutputChunkSchema.extend({
|
|
171
|
+
kind: z.literal("command.output"),
|
|
172
|
+
resourceId: CommandIdSchema
|
|
173
|
+
}).strict();
|
|
174
|
+
// ../../packages/shared/src/config.ts
|
|
175
|
+
const LOG_LEVELS = [
|
|
176
|
+
"trace",
|
|
177
|
+
"debug",
|
|
178
|
+
"info",
|
|
179
|
+
"warn",
|
|
180
|
+
"error",
|
|
181
|
+
"fatal"
|
|
182
|
+
];
|
|
183
|
+
const UPDATE_CHANNELS = ["stable", "beta"];
|
|
184
|
+
const LogLevelSchema = z.enum(LOG_LEVELS);
|
|
185
|
+
const UpdateChannelSchema = z.enum(UPDATE_CHANNELS);
|
|
186
|
+
function isOriginUrl(value) {
|
|
187
|
+
let url;
|
|
188
|
+
try {
|
|
189
|
+
url = new URL(value);
|
|
190
|
+
} catch {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.username === "" && url.password === "" && url.pathname === "/" && url.search === "" && url.hash === "";
|
|
194
|
+
}
|
|
195
|
+
const OriginUrlSchema = z.string().max(2048).refine(isOriginUrl, "must be an http(s) origin without path, query or credentials");
|
|
196
|
+
const ServerConfigSchema = z.strictObject({
|
|
197
|
+
host: z.string().min(1).max(255),
|
|
198
|
+
port: z.int().min(1).max(65535),
|
|
199
|
+
publicUrl: OriginUrlSchema.nullable(),
|
|
200
|
+
trustedProxies: z.array(z.string().min(1)).max(64)
|
|
201
|
+
});
|
|
202
|
+
const AuthConfigSchema = z.strictObject({
|
|
203
|
+
sessionTtlMinutes: z.int().min(1).max(43200),
|
|
204
|
+
idleTtlMinutes: z.int().min(1).max(43200),
|
|
205
|
+
requireHttpsForRemote: z.boolean()
|
|
206
|
+
});
|
|
207
|
+
const WebAuthnConfigSchema = z.strictObject({
|
|
208
|
+
rpId: z.string().min(1).max(253),
|
|
209
|
+
rpName: z.string().min(1).max(128),
|
|
210
|
+
origin: OriginUrlSchema
|
|
211
|
+
});
|
|
212
|
+
const LoggingConfigSchema = z.strictObject({
|
|
213
|
+
level: LogLevelSchema,
|
|
214
|
+
retentionDays: z.int().min(1).max(3650)
|
|
215
|
+
});
|
|
216
|
+
const UpdatesConfigSchema = z.strictObject({
|
|
217
|
+
channel: UpdateChannelSchema,
|
|
218
|
+
autoCheck: z.boolean(),
|
|
219
|
+
autoInstall: z.boolean()
|
|
220
|
+
});
|
|
221
|
+
const PreviewConfigSchema = z.strictObject({
|
|
222
|
+
enabled: z.boolean(),
|
|
223
|
+
port: z.number().int().min(1).max(65535).default(3211)
|
|
224
|
+
});
|
|
225
|
+
const CleanupRetentionSchema = z.strictObject({
|
|
226
|
+
events: z.number().int().min(1).max(3650).default(90),
|
|
227
|
+
turns: z.number().int().min(1).max(3650).default(180),
|
|
228
|
+
summaries: z.number().int().min(1).max(3650).default(90)
|
|
229
|
+
});
|
|
230
|
+
/**
|
|
231
|
+
* Retention cleanup is opt-in (ADR-058 decision 4): disabled by default and
|
|
232
|
+
* dry-run only until a human turns it on.
|
|
233
|
+
*/
|
|
234
|
+
const CleanupConfigSchema = z.strictObject({
|
|
235
|
+
enabled: z.boolean().default(false),
|
|
236
|
+
/** Remove the session row as well; default keeps history entries visible. */
|
|
237
|
+
deleteSessions: z.boolean().default(false),
|
|
238
|
+
keepPinned: z.boolean().default(true),
|
|
239
|
+
retentionDays: CleanupRetentionSchema.default({
|
|
240
|
+
events: 90,
|
|
241
|
+
turns: 180,
|
|
242
|
+
summaries: 90
|
|
243
|
+
}),
|
|
244
|
+
/** Hard size budget in bytes; 0 disables the check. */
|
|
245
|
+
maxBytes: z.number().int().min(0).default(0)
|
|
246
|
+
});
|
|
247
|
+
const DEFAULT_CLEANUP_CONFIG = CleanupConfigSchema.parse({});
|
|
248
|
+
const AppConfigSchema = z.strictObject({
|
|
249
|
+
version: z.literal(1),
|
|
250
|
+
server: ServerConfigSchema,
|
|
251
|
+
auth: AuthConfigSchema,
|
|
252
|
+
webauthn: WebAuthnConfigSchema,
|
|
253
|
+
logging: LoggingConfigSchema,
|
|
254
|
+
updates: UpdatesConfigSchema,
|
|
255
|
+
preview: PreviewConfigSchema,
|
|
256
|
+
cleanup: CleanupConfigSchema.default(DEFAULT_CLEANUP_CONFIG)
|
|
257
|
+
});
|
|
258
|
+
const DEFAULT_APP_CONFIG = {
|
|
259
|
+
version: 1,
|
|
260
|
+
server: {
|
|
261
|
+
host: "127.0.0.1",
|
|
262
|
+
port: 3210,
|
|
263
|
+
publicUrl: null,
|
|
264
|
+
trustedProxies: []
|
|
265
|
+
},
|
|
266
|
+
auth: {
|
|
267
|
+
sessionTtlMinutes: 720,
|
|
268
|
+
idleTtlMinutes: 30,
|
|
269
|
+
requireHttpsForRemote: true
|
|
270
|
+
},
|
|
271
|
+
webauthn: {
|
|
272
|
+
rpId: "localhost",
|
|
273
|
+
rpName: "Larness",
|
|
274
|
+
origin: "http://localhost:3210"
|
|
275
|
+
},
|
|
276
|
+
logging: {
|
|
277
|
+
level: "info",
|
|
278
|
+
retentionDays: 14
|
|
279
|
+
},
|
|
280
|
+
updates: {
|
|
281
|
+
channel: "stable",
|
|
282
|
+
autoCheck: true,
|
|
283
|
+
autoInstall: false
|
|
284
|
+
},
|
|
285
|
+
preview: {
|
|
286
|
+
enabled: false,
|
|
287
|
+
port: 3211
|
|
288
|
+
},
|
|
289
|
+
cleanup: DEFAULT_CLEANUP_CONFIG
|
|
290
|
+
};
|
|
291
|
+
function isIpHostname(hostname) {
|
|
292
|
+
const host = hostname.replace(/^\[/, "").replace(/\]$/, "");
|
|
293
|
+
if (/^\d{1,3}(\.\d{1,3}){3}$/.test(host)) return true;
|
|
294
|
+
return host.includes(":") && /^[0-9a-f:]+$/i.test(host);
|
|
295
|
+
}
|
|
296
|
+
function deriveWebAuthn(server, rpName) {
|
|
297
|
+
const url = new URL(server.publicUrl ?? `http://localhost:${server.port}`);
|
|
298
|
+
const rpId = url.hostname;
|
|
299
|
+
const reason = isIpHostname(rpId) ? "rp_id_is_ip" : url.protocol === "http:" && rpId !== "localhost" ? "remote_http" : null;
|
|
300
|
+
return {
|
|
301
|
+
enabled: reason === null,
|
|
302
|
+
origin: url.origin,
|
|
303
|
+
rpId,
|
|
304
|
+
rpName,
|
|
305
|
+
reason
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
// ../../packages/shared/src/deployments.ts
|
|
309
|
+
const ServiceControlInputSchema = z.object({
|
|
310
|
+
action: z.enum([
|
|
311
|
+
"start",
|
|
312
|
+
"stop",
|
|
313
|
+
"restart"
|
|
314
|
+
]),
|
|
315
|
+
expectedPm2Name: z.string().min(1).max(256),
|
|
316
|
+
requestKey: z.string().min(1).max(256),
|
|
317
|
+
confirmed: z.literal(true)
|
|
318
|
+
}).strict();
|
|
319
|
+
const UUID = "[0-9a-f-]{36}";
|
|
320
|
+
const DeploymentTargetIdSchema = z.string().regex(new RegExp(`^tgt_${UUID}$`));
|
|
321
|
+
const DeploymentBuildIdSchema = z.string().regex(new RegExp(`^bld_${UUID}$`));
|
|
322
|
+
const DeploymentArtifactIdSchema = z.string().regex(new RegExp(`^art_${UUID}$`));
|
|
323
|
+
const DeploymentPlanIdSchema = z.string().regex(new RegExp(`^plan_${UUID}$`));
|
|
324
|
+
const DeploymentTargetNameSchema = z.string().trim().min(1).max(80).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/, "must be a simple service name");
|
|
325
|
+
const DeploymentVersionSchema = z.string().trim().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._+-]*$/, "must be a simple version label");
|
|
326
|
+
function hasControlCharacters(value) {
|
|
327
|
+
for (const character of value) {
|
|
328
|
+
const code = character.codePointAt(0) ?? 0;
|
|
329
|
+
if (code <= 31 || code === 127) return true;
|
|
330
|
+
}
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
const noControl = (value) => !hasControlCharacters(value);
|
|
334
|
+
function safeRelative(value, allowDot) {
|
|
335
|
+
if (!value || value.length > 1024 || hasControlCharacters(value) || value.includes("\\")) return false;
|
|
336
|
+
if (value === ".") return allowDot;
|
|
337
|
+
if (value.startsWith("/") || /^[A-Za-z]:/.test(value)) return false;
|
|
338
|
+
return value.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
|
|
339
|
+
}
|
|
340
|
+
const DeploymentCwdSchema = z.string().min(1).max(1024).refine((value) => safeRelative(value, true), "must be a relative path inside the project");
|
|
341
|
+
const DeploymentOutputDirSchema = z.string().min(1).max(1024).refine((value) => safeRelative(value, false), "must be a relative directory inside the project");
|
|
342
|
+
const DeploymentHealthPathSchema = z.string().min(1).max(1024).refine((value) => value.startsWith("/") && !value.includes("..") && !hasControlCharacters(value), "must be an absolute HTTP path without traversal");
|
|
343
|
+
const CommandSchema = z.array(z.string().min(1).max(4096).refine(noControl, "must not contain control characters")).min(1).max(64);
|
|
344
|
+
const DeploymentBuildSpecSchema = z.strictObject({
|
|
345
|
+
command: CommandSchema,
|
|
346
|
+
cwd: DeploymentCwdSchema.default("."),
|
|
347
|
+
outputDir: DeploymentOutputDirSchema,
|
|
348
|
+
timeoutMs: z.int().min(1e3).max(6e5).default(3e5)
|
|
349
|
+
});
|
|
350
|
+
const DeploymentStartSpecSchema = z.strictObject({
|
|
351
|
+
command: CommandSchema,
|
|
352
|
+
cwd: DeploymentCwdSchema.default(".")
|
|
353
|
+
});
|
|
354
|
+
const DeploymentHealthSchema = z.strictObject({
|
|
355
|
+
path: DeploymentHealthPathSchema,
|
|
356
|
+
port: z.int().min(1024).max(65535),
|
|
357
|
+
timeoutMs: z.int().min(1e3).max(12e4).default(3e4),
|
|
358
|
+
intervalMs: z.int().min(100).max(1e4).default(500)
|
|
359
|
+
});
|
|
360
|
+
const DeploymentRecoverySchema = z.strictObject({
|
|
361
|
+
strategy: z.enum(["restart", "none"]),
|
|
362
|
+
maxAttempts: z.int().min(0).max(10).default(3)
|
|
363
|
+
});
|
|
364
|
+
const DeploymentSpecSchema = z.strictObject({
|
|
365
|
+
version: DeploymentVersionSchema,
|
|
366
|
+
build: DeploymentBuildSpecSchema,
|
|
367
|
+
start: DeploymentStartSpecSchema,
|
|
368
|
+
health: DeploymentHealthSchema,
|
|
369
|
+
recovery: DeploymentRecoverySchema
|
|
370
|
+
});
|
|
371
|
+
const DeploymentTargetRefSchema = z.union([z.strictObject({ targetId: DeploymentTargetIdSchema }), z.strictObject({ name: DeploymentTargetNameSchema })]);
|
|
372
|
+
const DeploymentSourceSchema = z.strictObject({
|
|
373
|
+
branch: z.string().max(255).nullable(),
|
|
374
|
+
commit: z.string().max(128).nullable(),
|
|
375
|
+
dirty: z.boolean().nullable()
|
|
376
|
+
});
|
|
377
|
+
z.object({
|
|
378
|
+
id: DeploymentTargetIdSchema,
|
|
379
|
+
projectId: z.string().min(1).max(128),
|
|
380
|
+
name: DeploymentTargetNameSchema,
|
|
381
|
+
currentArtifactId: DeploymentArtifactIdSchema.nullable(),
|
|
382
|
+
currentVersion: DeploymentVersionSchema.nullable(),
|
|
383
|
+
createdAt: z.int(),
|
|
384
|
+
updatedAt: z.int()
|
|
385
|
+
});
|
|
386
|
+
const DeploymentBuildStatusSchema = z.enum([
|
|
387
|
+
"RUNNING",
|
|
388
|
+
"SUCCEEDED",
|
|
389
|
+
"FAILED",
|
|
390
|
+
"CANCELLED"
|
|
391
|
+
]);
|
|
392
|
+
z.object({
|
|
393
|
+
id: DeploymentBuildIdSchema,
|
|
394
|
+
targetId: DeploymentTargetIdSchema,
|
|
395
|
+
projectId: z.string().min(1).max(128),
|
|
396
|
+
status: DeploymentBuildStatusSchema,
|
|
397
|
+
spec: DeploymentSpecSchema,
|
|
398
|
+
specHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
399
|
+
reasonCode: z.string().max(64).nullable(),
|
|
400
|
+
logRef: z.string().min(1).max(1024),
|
|
401
|
+
startedAt: z.int().nullable(),
|
|
402
|
+
endedAt: z.int().nullable(),
|
|
403
|
+
createdAt: z.int()
|
|
404
|
+
});
|
|
405
|
+
z.object({
|
|
406
|
+
id: DeploymentArtifactIdSchema,
|
|
407
|
+
buildId: DeploymentBuildIdSchema,
|
|
408
|
+
targetId: DeploymentTargetIdSchema,
|
|
409
|
+
projectId: z.string().min(1).max(128),
|
|
410
|
+
version: DeploymentVersionSchema,
|
|
411
|
+
artifactHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
412
|
+
sizeBytes: z.int().nonnegative(),
|
|
413
|
+
fileCount: z.int().nonnegative(),
|
|
414
|
+
source: DeploymentSourceSchema,
|
|
415
|
+
createdAt: z.int()
|
|
416
|
+
});
|
|
417
|
+
const DeploymentPlanStatusSchema = z.enum([
|
|
418
|
+
"READY",
|
|
419
|
+
"WAITING_APPROVAL",
|
|
420
|
+
"AUTHORIZED",
|
|
421
|
+
"APPLYING",
|
|
422
|
+
"HEALTH_CHECK",
|
|
423
|
+
"SUCCEEDED",
|
|
424
|
+
"FAILED",
|
|
425
|
+
"CANCELLED",
|
|
426
|
+
"EXPIRED",
|
|
427
|
+
"INVALIDATED",
|
|
428
|
+
"UNKNOWN"
|
|
429
|
+
]);
|
|
430
|
+
const DeploymentRecoveryPlanSchema = z.strictObject({
|
|
431
|
+
strategy: z.enum(["restart", "none"]),
|
|
432
|
+
maxAttempts: z.int().min(0).max(10),
|
|
433
|
+
previousArtifactAvailable: z.boolean(),
|
|
434
|
+
databaseRollback: z.literal("unsupported")
|
|
435
|
+
});
|
|
436
|
+
const DeploymentImpactSchema = z.strictObject({
|
|
437
|
+
scope: z.literal("single-service"),
|
|
438
|
+
firstDeploy: z.boolean(),
|
|
439
|
+
restartRequired: z.literal(true),
|
|
440
|
+
downtime: z.literal("brief"),
|
|
441
|
+
replacesVersion: DeploymentVersionSchema.nullable(),
|
|
442
|
+
replacesArtifact: DeploymentArtifactIdSchema.nullable()
|
|
443
|
+
});
|
|
444
|
+
const DeploymentPlanDocumentSchema = z.strictObject({
|
|
445
|
+
version: z.literal(1),
|
|
446
|
+
targetId: DeploymentTargetIdSchema,
|
|
447
|
+
projectId: z.string().min(1).max(128),
|
|
448
|
+
artifactId: DeploymentArtifactIdSchema,
|
|
449
|
+
artifactHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
450
|
+
artifactVersion: DeploymentVersionSchema,
|
|
451
|
+
previousArtifactId: DeploymentArtifactIdSchema.nullable(),
|
|
452
|
+
previousVersion: DeploymentVersionSchema.nullable(),
|
|
453
|
+
specHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
454
|
+
source: DeploymentSourceSchema,
|
|
455
|
+
health: DeploymentHealthSchema,
|
|
456
|
+
recovery: DeploymentRecoveryPlanSchema,
|
|
457
|
+
impact: DeploymentImpactSchema,
|
|
458
|
+
expiresAt: z.int().positive()
|
|
459
|
+
});
|
|
460
|
+
z.object({
|
|
461
|
+
id: DeploymentPlanIdSchema,
|
|
462
|
+
targetId: DeploymentTargetIdSchema,
|
|
463
|
+
projectId: z.string().min(1).max(128),
|
|
464
|
+
artifactId: DeploymentArtifactIdSchema,
|
|
465
|
+
previousArtifactId: DeploymentArtifactIdSchema.nullable(),
|
|
466
|
+
previousVersion: DeploymentVersionSchema.nullable(),
|
|
467
|
+
version: DeploymentVersionSchema,
|
|
468
|
+
status: DeploymentPlanStatusSchema,
|
|
469
|
+
plan: DeploymentPlanDocumentSchema,
|
|
470
|
+
planHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
471
|
+
expiresAt: z.int(),
|
|
472
|
+
requestedBy: z.string().min(1).max(128),
|
|
473
|
+
createdAt: z.int()
|
|
474
|
+
});
|
|
475
|
+
const DeploymentAuthorizationIdSchema = z.string().regex(new RegExp(`^dauth_${UUID}$`));
|
|
476
|
+
const DeploymentApprovalIdSchema = z.string().regex(new RegExp(`^dapv_${UUID}$`));
|
|
477
|
+
const DeploymentActionSchema = z.enum([
|
|
478
|
+
"apply",
|
|
479
|
+
"start",
|
|
480
|
+
"stop",
|
|
481
|
+
"restart",
|
|
482
|
+
"recover"
|
|
483
|
+
]);
|
|
484
|
+
const DeploymentPolicySchema = z.enum([
|
|
485
|
+
"standard",
|
|
486
|
+
"strict",
|
|
487
|
+
"readonly",
|
|
488
|
+
"autonomous"
|
|
489
|
+
]);
|
|
490
|
+
const DeploymentActorSchema = z.strictObject({
|
|
491
|
+
type: z.enum(["human", "agent"]),
|
|
492
|
+
id: z.string().min(1).max(128)
|
|
493
|
+
});
|
|
494
|
+
const DeploymentAuthorizationContextSchema = z.strictObject({
|
|
495
|
+
domain: z.literal("service-ops"),
|
|
496
|
+
projectId: z.string().min(1).max(128),
|
|
497
|
+
targetId: DeploymentTargetIdSchema,
|
|
498
|
+
action: DeploymentActionSchema.default("apply"),
|
|
499
|
+
policy: DeploymentPolicySchema,
|
|
500
|
+
policySnapshotId: z.string().min(1).max(128),
|
|
501
|
+
actor: DeploymentActorSchema,
|
|
502
|
+
clientSessionId: z.string().min(1).max(128).nullable().default(null),
|
|
503
|
+
sessionId: z.string().min(1).max(128).nullable().default(null),
|
|
504
|
+
turnId: z.string().min(1).max(128).nullable().default(null)
|
|
505
|
+
});
|
|
506
|
+
const DeploymentAuthorizationScopeSchema = z.strictObject({
|
|
507
|
+
domain: z.literal("service-ops"),
|
|
508
|
+
projectId: z.string().min(1).max(128),
|
|
509
|
+
targetId: DeploymentTargetIdSchema,
|
|
510
|
+
planId: DeploymentPlanIdSchema,
|
|
511
|
+
action: DeploymentActionSchema,
|
|
512
|
+
planHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
513
|
+
artifactHash: z.string().regex(/^[a-f0-9]{64}$/)
|
|
514
|
+
});
|
|
515
|
+
const DeploymentAuthorizationStatusSchema = z.enum([
|
|
516
|
+
"PENDING",
|
|
517
|
+
"AUTHORIZED",
|
|
518
|
+
"DENIED",
|
|
519
|
+
"EXPIRED",
|
|
520
|
+
"REVOKED",
|
|
521
|
+
"CONSUMED",
|
|
522
|
+
"INVALIDATED"
|
|
523
|
+
]);
|
|
524
|
+
const DeploymentApprovalStatusSchema = z.enum([
|
|
525
|
+
"PENDING",
|
|
526
|
+
"APPROVED",
|
|
527
|
+
"DENIED",
|
|
528
|
+
"EXPIRED",
|
|
529
|
+
"REVOKED"
|
|
530
|
+
]);
|
|
531
|
+
z.object({
|
|
532
|
+
id: DeploymentAuthorizationIdSchema,
|
|
533
|
+
planId: DeploymentPlanIdSchema,
|
|
534
|
+
targetId: DeploymentTargetIdSchema,
|
|
535
|
+
projectId: z.string().min(1).max(128),
|
|
536
|
+
action: DeploymentActionSchema,
|
|
537
|
+
actorType: z.enum(["human", "agent"]),
|
|
538
|
+
actorId: z.string().min(1).max(128),
|
|
539
|
+
clientSessionId: z.string().min(1).max(128).nullable(),
|
|
540
|
+
sessionId: z.string().min(1).max(128).nullable(),
|
|
541
|
+
turnId: z.string().min(1).max(128).nullable(),
|
|
542
|
+
policy: DeploymentPolicySchema,
|
|
543
|
+
policySnapshotId: z.string().min(1).max(128),
|
|
544
|
+
status: DeploymentAuthorizationStatusSchema,
|
|
545
|
+
planHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
546
|
+
artifactHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
547
|
+
scope: DeploymentAuthorizationScopeSchema,
|
|
548
|
+
scopeHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
549
|
+
approvalId: DeploymentApprovalIdSchema.nullable(),
|
|
550
|
+
expiresAt: z.int(),
|
|
551
|
+
decidedAt: z.int().nullable(),
|
|
552
|
+
consumedAt: z.int().nullable(),
|
|
553
|
+
reasonCode: z.string().max(64).nullable(),
|
|
554
|
+
createdAt: z.int()
|
|
555
|
+
});
|
|
556
|
+
z.object({
|
|
557
|
+
id: DeploymentApprovalIdSchema,
|
|
558
|
+
authorizationId: DeploymentAuthorizationIdSchema,
|
|
559
|
+
planId: DeploymentPlanIdSchema,
|
|
560
|
+
targetId: DeploymentTargetIdSchema,
|
|
561
|
+
projectId: z.string().min(1).max(128),
|
|
562
|
+
status: DeploymentApprovalStatusSchema,
|
|
563
|
+
planHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
564
|
+
artifactHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
565
|
+
requestedBy: z.string().min(1).max(128),
|
|
566
|
+
decidedBy: z.string().min(1).max(128).nullable(),
|
|
567
|
+
expiresAt: z.int(),
|
|
568
|
+
decidedAt: z.int().nullable(),
|
|
569
|
+
createdAt: z.int()
|
|
570
|
+
});
|
|
571
|
+
const ServiceOpsDeploymentIdSchema = z.string().regex(new RegExp(`^dep_${UUID}$`));
|
|
572
|
+
const ServiceOpsDesiredStateSchema = z.enum(["running", "stopped"]);
|
|
573
|
+
const ServiceOpsObservedStateSchema = z.enum([
|
|
574
|
+
"stopped",
|
|
575
|
+
"starting",
|
|
576
|
+
"running",
|
|
577
|
+
"unhealthy",
|
|
578
|
+
"stopping",
|
|
579
|
+
"failed",
|
|
580
|
+
"unknown"
|
|
581
|
+
]);
|
|
582
|
+
const ServiceOpsServiceDtoSchema = z.object({
|
|
583
|
+
targetId: DeploymentTargetIdSchema,
|
|
584
|
+
projectId: z.string().min(1).max(128),
|
|
585
|
+
name: DeploymentTargetNameSchema,
|
|
586
|
+
pm2Name: z.string().min(1).max(256),
|
|
587
|
+
projectName: z.string().nullable(),
|
|
588
|
+
source: z.enum(["pm2-cli", "deployment"]),
|
|
589
|
+
version: DeploymentVersionSchema.nullable(),
|
|
590
|
+
artifactHash: z.string().regex(/^[a-f0-9]{64}$/).nullable(),
|
|
591
|
+
desiredState: ServiceOpsDesiredStateSchema,
|
|
592
|
+
observedState: ServiceOpsObservedStateSchema,
|
|
593
|
+
pid: z.int().positive().nullable(),
|
|
594
|
+
lastHealthAt: z.int().nullable(),
|
|
595
|
+
reasonCode: z.string().max(64).nullable(),
|
|
596
|
+
updatedAt: z.int()
|
|
597
|
+
});
|
|
598
|
+
z.object({
|
|
599
|
+
pm2Home: z.string().min(1).max(4096).optional(),
|
|
600
|
+
items: z.array(ServiceOpsServiceDtoSchema),
|
|
601
|
+
unassociated: z.array(z.object({
|
|
602
|
+
pm2Name: z.string(),
|
|
603
|
+
reason: z.string()
|
|
604
|
+
}))
|
|
605
|
+
});
|
|
606
|
+
const ServiceOpsDeploymentStatusSchema = z.enum([
|
|
607
|
+
"APPLYING",
|
|
608
|
+
"HEALTH_CHECK",
|
|
609
|
+
"SUCCEEDED",
|
|
610
|
+
"FAILED",
|
|
611
|
+
"UNKNOWN"
|
|
612
|
+
]);
|
|
613
|
+
z.object({
|
|
614
|
+
id: ServiceOpsDeploymentIdSchema,
|
|
615
|
+
targetId: DeploymentTargetIdSchema,
|
|
616
|
+
planId: DeploymentPlanIdSchema,
|
|
617
|
+
authorizationId: DeploymentAuthorizationIdSchema,
|
|
618
|
+
artifactId: DeploymentArtifactIdSchema,
|
|
619
|
+
previousArtifactId: DeploymentArtifactIdSchema.nullable(),
|
|
620
|
+
previousVersion: DeploymentVersionSchema.nullable(),
|
|
621
|
+
version: DeploymentVersionSchema,
|
|
622
|
+
status: ServiceOpsDeploymentStatusSchema,
|
|
623
|
+
planHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
624
|
+
artifactHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
625
|
+
reasonCode: z.string().max(64).nullable(),
|
|
626
|
+
startedAt: z.int(),
|
|
627
|
+
endedAt: z.int().nullable(),
|
|
628
|
+
createdAt: z.int()
|
|
629
|
+
});
|
|
630
|
+
const ServiceOpsSubscriptionSchema = z.object({
|
|
631
|
+
topic: z.literal("service-ops"),
|
|
632
|
+
resourceId: DeploymentTargetIdSchema,
|
|
633
|
+
after: z.int().min(0).max(Number.MAX_SAFE_INTEGER).default(0)
|
|
634
|
+
}).strict();
|
|
635
|
+
const ServiceOpsEventPayloadSchema = z.object({
|
|
636
|
+
observedState: ServiceOpsObservedStateSchema,
|
|
637
|
+
desiredState: ServiceOpsDesiredStateSchema,
|
|
638
|
+
version: DeploymentVersionSchema.nullable(),
|
|
639
|
+
artifactHash: z.string().regex(/^[a-f0-9]{64}$/).nullable(),
|
|
640
|
+
pid: z.int().positive().nullable(),
|
|
641
|
+
deploymentId: ServiceOpsDeploymentIdSchema.nullable(),
|
|
642
|
+
reasonCode: z.string().max(64).nullable()
|
|
643
|
+
});
|
|
644
|
+
const ServiceActionAuthorizationIdSchema = z.string().regex(new RegExp(`^sauth_${UUID}$`));
|
|
645
|
+
const ServiceActionSchema = z.enum([
|
|
646
|
+
"start",
|
|
647
|
+
"stop",
|
|
648
|
+
"restart",
|
|
649
|
+
"recover"
|
|
650
|
+
]);
|
|
651
|
+
const ServiceActionStatusSchema = z.enum([
|
|
652
|
+
"PENDING",
|
|
653
|
+
"AUTHORIZED",
|
|
654
|
+
"DENIED",
|
|
655
|
+
"EXPIRED",
|
|
656
|
+
"REVOKED",
|
|
657
|
+
"CONSUMED"
|
|
658
|
+
]);
|
|
659
|
+
const ServiceActionScopeSchema = z.strictObject({
|
|
660
|
+
domain: z.literal("service-ops"),
|
|
661
|
+
projectId: z.string().min(1).max(128),
|
|
662
|
+
targetId: DeploymentTargetIdSchema,
|
|
663
|
+
action: ServiceActionSchema,
|
|
664
|
+
artifactHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
665
|
+
version: DeploymentVersionSchema
|
|
666
|
+
});
|
|
667
|
+
const ServiceActionAuthorizationDtoSchema = z.object({
|
|
668
|
+
id: ServiceActionAuthorizationIdSchema,
|
|
669
|
+
targetId: DeploymentTargetIdSchema,
|
|
670
|
+
projectId: z.string().min(1).max(128),
|
|
671
|
+
action: ServiceActionSchema,
|
|
672
|
+
actorType: z.enum(["human", "agent"]),
|
|
673
|
+
actorId: z.string().min(1).max(128),
|
|
674
|
+
clientSessionId: z.string().min(1).max(128).nullable(),
|
|
675
|
+
sessionId: z.string().min(1).max(128).nullable(),
|
|
676
|
+
turnId: z.string().min(1).max(128).nullable(),
|
|
677
|
+
policy: DeploymentPolicySchema,
|
|
678
|
+
policySnapshotId: z.string().min(1).max(128),
|
|
679
|
+
status: ServiceActionStatusSchema,
|
|
680
|
+
artifactHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
681
|
+
version: DeploymentVersionSchema,
|
|
682
|
+
scopeHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
683
|
+
expiresAt: z.int(),
|
|
684
|
+
decidedAt: z.int().nullable(),
|
|
685
|
+
decidedBy: z.string().min(1).max(128).nullable(),
|
|
686
|
+
consumedAt: z.int().nullable(),
|
|
687
|
+
reasonCode: z.string().max(64).nullable(),
|
|
688
|
+
createdAt: z.int()
|
|
689
|
+
});
|
|
690
|
+
const DEPLOYMENT_APPROVAL_TTL_MS = 3e5;
|
|
691
|
+
const DeploymentArtifactManifestSchema = z.strictObject({
|
|
692
|
+
version: z.literal(1),
|
|
693
|
+
artifactId: DeploymentArtifactIdSchema,
|
|
694
|
+
targetId: DeploymentTargetIdSchema,
|
|
695
|
+
hash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
696
|
+
files: z.array(z.strictObject({
|
|
697
|
+
path: z.string().min(1).max(1024),
|
|
698
|
+
size: z.int().nonnegative(),
|
|
699
|
+
hash: z.string().regex(/^[a-f0-9]{64}$/)
|
|
700
|
+
}))
|
|
701
|
+
});
|
|
702
|
+
const DEPLOYMENT_PLAN_TTL_MS = 18e5;
|
|
703
|
+
const DEPLOYMENT_ARTIFACT_MAX_BYTES = 536870912;
|
|
704
|
+
const DEPLOYMENT_ARTIFACT_MAX_FILES = 2e4;
|
|
705
|
+
const DEPLOYMENT_ARTIFACT_MAX_PATH = 1024;
|
|
706
|
+
const DEPLOYMENT_BUILD_LOG_MAX_BYTES = 1048576;
|
|
707
|
+
z.object({
|
|
708
|
+
available: z.boolean(),
|
|
709
|
+
nodeExecutable: z.string(),
|
|
710
|
+
entry: z.string().nullable(),
|
|
711
|
+
version: z.string().nullable(),
|
|
712
|
+
home: z.string(),
|
|
713
|
+
namespace: z.literal("larness"),
|
|
714
|
+
serviceNamePattern: z.literal("larness:<projectId>:<serviceKey>"),
|
|
715
|
+
project: z.object({
|
|
716
|
+
id: z.string(),
|
|
717
|
+
name: z.string(),
|
|
718
|
+
root: z.string(),
|
|
719
|
+
releaseRoot: z.string()
|
|
720
|
+
}).nullable(),
|
|
721
|
+
unassociatedServices: z.array(z.object({
|
|
722
|
+
pm2Name: z.string(),
|
|
723
|
+
reason: z.string()
|
|
724
|
+
})).optional(),
|
|
725
|
+
services: z.array(z.object({
|
|
726
|
+
projectId: z.string(),
|
|
727
|
+
projectName: z.string(),
|
|
728
|
+
name: z.string(),
|
|
729
|
+
pm2Name: z.string(),
|
|
730
|
+
observedState: ServiceOpsObservedStateSchema,
|
|
731
|
+
pid: z.int().nullable(),
|
|
732
|
+
updatedAt: z.int()
|
|
733
|
+
}))
|
|
734
|
+
});
|
|
735
|
+
// ../../packages/shared/src/domain.ts
|
|
736
|
+
const DEFAULT_PROJECT_ID = "prj_default";
|
|
737
|
+
z.boolean().default(false);
|
|
738
|
+
// ../../packages/shared/src/events.ts
|
|
739
|
+
const WORKSPACE_SESSIONS_CHANGED = "workspace.sessions.changed";
|
|
740
|
+
const WORKSPACE_JOBS_CHANGED = "workspace.jobs.changed";
|
|
741
|
+
z.discriminatedUnion("kind", [z.object({
|
|
742
|
+
kind: z.literal("subscribed"),
|
|
743
|
+
subscription: z.object({
|
|
744
|
+
topic: z.literal("system"),
|
|
745
|
+
resourceId: z.literal("system")
|
|
746
|
+
})
|
|
747
|
+
}), z.object({ kind: z.literal(WORKSPACE_SESSIONS_CHANGED) })]);
|
|
748
|
+
z.object({ kind: z.literal(WORKSPACE_JOBS_CHANGED) });
|
|
749
|
+
const TurnFileResultSchema = z.object({
|
|
750
|
+
path: z.string().min(1),
|
|
751
|
+
changeType: z.enum(["created", "modified"]),
|
|
752
|
+
version: z.string().min(1),
|
|
753
|
+
existed: z.boolean(),
|
|
754
|
+
category: z.enum(["deliverable", "process"])
|
|
755
|
+
});
|
|
756
|
+
z.array(TurnFileResultSchema);
|
|
757
|
+
// ../../packages/shared/src/git.ts
|
|
758
|
+
const GitPathSchema = z.string().min(1).max(4096).refine((value) => !value.includes("\0"), "Git path cannot contain NUL");
|
|
759
|
+
const GitBranchNameSchema = z.string().min(1).max(255).refine((value) => !value.includes("\0") && !value.startsWith("-"), "Invalid branch name");
|
|
760
|
+
const GitAddActionSchema = z.object({
|
|
761
|
+
action: z.literal("add"),
|
|
762
|
+
paths: z.array(GitPathSchema).min(1).max(200)
|
|
763
|
+
}).strict();
|
|
764
|
+
const GitUnstageActionSchema = z.object({
|
|
765
|
+
action: z.literal("unstage"),
|
|
766
|
+
paths: z.array(GitPathSchema).min(1).max(200)
|
|
767
|
+
}).strict();
|
|
768
|
+
const GitDiscardActionSchema = z.object({
|
|
769
|
+
action: z.literal("discard"),
|
|
770
|
+
path: GitPathSchema,
|
|
771
|
+
confirmed: z.literal(true)
|
|
772
|
+
}).strict();
|
|
773
|
+
const GitCommitActionSchema = z.object({
|
|
774
|
+
action: z.literal("commit"),
|
|
775
|
+
message: z.string().min(1).max(4e3)
|
|
776
|
+
}).strict();
|
|
777
|
+
const GitCreateBranchActionSchema = z.object({
|
|
778
|
+
action: z.literal("createBranch"),
|
|
779
|
+
name: GitBranchNameSchema
|
|
780
|
+
}).strict();
|
|
781
|
+
const GitSwitchBranchActionSchema = z.object({
|
|
782
|
+
action: z.literal("switchBranch"),
|
|
783
|
+
name: GitBranchNameSchema
|
|
784
|
+
}).strict();
|
|
785
|
+
const GitPullActionSchema = z.object({ action: z.literal("pull") }).strict();
|
|
786
|
+
const GitPushActionSchema = z.object({ action: z.literal("push") }).strict();
|
|
787
|
+
const GitActionSchema = z.union([
|
|
788
|
+
GitAddActionSchema,
|
|
789
|
+
GitUnstageActionSchema,
|
|
790
|
+
GitDiscardActionSchema,
|
|
791
|
+
GitCommitActionSchema,
|
|
792
|
+
GitCreateBranchActionSchema,
|
|
793
|
+
GitSwitchBranchActionSchema,
|
|
794
|
+
GitPullActionSchema,
|
|
795
|
+
GitPushActionSchema
|
|
796
|
+
]);
|
|
797
|
+
const GitActionDecisionSchema = z.object({ decision: z.enum(["approve", "reject"]) }).strict();
|
|
798
|
+
const GitDiffQuerySchema = z.object({
|
|
799
|
+
path: z.string().min(1).max(4096),
|
|
800
|
+
staged: z.enum(["true", "false"]).default("false")
|
|
801
|
+
}).strict();
|
|
802
|
+
const GitLogQuerySchema = z.object({
|
|
803
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
804
|
+
cursor: z.coerce.number().int().nonnegative().default(0)
|
|
805
|
+
}).strict();
|
|
806
|
+
const GitBranchesQuerySchema = z.object({
|
|
807
|
+
limit: z.coerce.number().int().min(1).max(200).default(100),
|
|
808
|
+
cursor: z.coerce.number().int().nonnegative().default(0)
|
|
809
|
+
}).strict();
|
|
810
|
+
z.enum(["script", "agent"]);
|
|
811
|
+
const ScheduledJobMissedPolicySchema = z.enum(["skip", "run_once"]);
|
|
812
|
+
const ScheduledJobApprovalPolicySchema = z.enum(["readonly", "autonomous"]);
|
|
813
|
+
z.enum([
|
|
814
|
+
"scheduled",
|
|
815
|
+
"manual",
|
|
816
|
+
"catch_up"
|
|
817
|
+
]);
|
|
818
|
+
z.enum([
|
|
819
|
+
"queued",
|
|
820
|
+
"running",
|
|
821
|
+
"succeeded",
|
|
822
|
+
"failed",
|
|
823
|
+
"timed_out",
|
|
824
|
+
"cancelled",
|
|
825
|
+
"interrupted",
|
|
826
|
+
"skipped"
|
|
827
|
+
]);
|
|
828
|
+
z.enum([
|
|
829
|
+
"JOB_SCRIPT_FAILED",
|
|
830
|
+
"JOB_TIMEOUT",
|
|
831
|
+
"JOB_RUN_CANCELLED",
|
|
832
|
+
"JOB_AGENT_FAILED",
|
|
833
|
+
"JOB_AGENT_INCOMPLETE",
|
|
834
|
+
"JOB_INTERRUPTED",
|
|
835
|
+
"JOB_OVERLAP"
|
|
836
|
+
]);
|
|
837
|
+
const CronExpressionSchema = z.string().min(9).max(128).refine((value) => value.trim().split(/\s+/).length === 5, "Cron 必须是 5 字段");
|
|
838
|
+
const TimezoneSchema = z.string().min(1).max(64);
|
|
839
|
+
const ScheduledJobScheduleSchema = z.discriminatedUnion("type", [z.object({
|
|
840
|
+
type: z.literal("cron"),
|
|
841
|
+
expression: CronExpressionSchema,
|
|
842
|
+
timezone: TimezoneSchema
|
|
843
|
+
}).strict(), z.object({
|
|
844
|
+
type: z.literal("interval"),
|
|
845
|
+
seconds: z.number().int().min(60).max(604800),
|
|
846
|
+
timezone: TimezoneSchema
|
|
847
|
+
}).strict()]);
|
|
848
|
+
const BaseJobInput = {
|
|
849
|
+
name: z.string().trim().min(1).max(80),
|
|
850
|
+
projectId: z.string().min(1).max(128).nullable(),
|
|
851
|
+
schedule: ScheduledJobScheduleSchema,
|
|
852
|
+
enabled: z.boolean().default(true),
|
|
853
|
+
timeoutSeconds: z.number().int().min(60).max(3600).default(600),
|
|
854
|
+
missedPolicy: ScheduledJobMissedPolicySchema.default("skip")
|
|
855
|
+
};
|
|
856
|
+
const ScriptJobInputSchema = z.object({
|
|
857
|
+
...BaseJobInput,
|
|
858
|
+
kind: z.literal("script"),
|
|
859
|
+
script: z.object({ source: z.string().min(1).max(65536) }).strict()
|
|
860
|
+
}).strict();
|
|
861
|
+
const AgentJobInputSchema = z.object({
|
|
862
|
+
...BaseJobInput,
|
|
863
|
+
kind: z.literal("agent"),
|
|
864
|
+
agent: z.object({
|
|
865
|
+
prompt: z.string().trim().min(1).max(10240),
|
|
866
|
+
model: z.string().min(1).max(128).nullable().optional(),
|
|
867
|
+
credentialProfileId: z.string().min(1).max(128).nullable().optional(),
|
|
868
|
+
thinking: z.string().min(1).max(32).nullable().optional(),
|
|
869
|
+
approvalPolicy: ScheduledJobApprovalPolicySchema.default("readonly")
|
|
870
|
+
}).strict()
|
|
871
|
+
}).strict();
|
|
872
|
+
const ScheduledJobInputSchema = z.discriminatedUnion("kind", [ScriptJobInputSchema, AgentJobInputSchema]);
|
|
873
|
+
/** PATCH body: all mutable fields optional; kind/projectId retained from the existing job. */
|
|
874
|
+
const ScheduledJobPatchSchema = z.object({
|
|
875
|
+
name: z.string().trim().min(1).max(80).optional(),
|
|
876
|
+
enabled: z.boolean().optional(),
|
|
877
|
+
schedule: ScheduledJobScheduleSchema.optional(),
|
|
878
|
+
timeoutSeconds: z.number().int().min(60).max(3600).optional(),
|
|
879
|
+
missedPolicy: ScheduledJobMissedPolicySchema.optional(),
|
|
880
|
+
script: z.object({ source: z.string().min(1).max(65536) }).strict().optional(),
|
|
881
|
+
agent: z.object({
|
|
882
|
+
prompt: z.string().trim().min(1).max(10240).optional(),
|
|
883
|
+
model: z.string().min(1).max(128).nullable().optional(),
|
|
884
|
+
credentialProfileId: z.string().min(1).max(128).nullable().optional(),
|
|
885
|
+
thinking: z.string().min(1).max(32).nullable().optional(),
|
|
886
|
+
approvalPolicy: ScheduledJobApprovalPolicySchema.optional()
|
|
887
|
+
}).strict().optional()
|
|
888
|
+
}).strict();
|
|
889
|
+
// ../../packages/shared/src/plans.ts
|
|
890
|
+
const PlanStepSchema = z.object({
|
|
891
|
+
id: z.string().min(1).max(80),
|
|
892
|
+
title: z.string().trim().min(1).max(200),
|
|
893
|
+
detail: z.string().max(500).optional(),
|
|
894
|
+
status: z.enum([
|
|
895
|
+
"pending",
|
|
896
|
+
"running",
|
|
897
|
+
"done",
|
|
898
|
+
"failed"
|
|
899
|
+
])
|
|
900
|
+
}).strict();
|
|
901
|
+
const PlanParamsSchema = z.object({
|
|
902
|
+
title: z.string().trim().min(1).max(200),
|
|
903
|
+
steps: z.array(PlanStepSchema).min(1).max(12)
|
|
904
|
+
}).strict().superRefine((plan, context) => {
|
|
905
|
+
if (new Set(plan.steps.map((step) => step.id)).size !== plan.steps.length) context.addIssue({
|
|
906
|
+
code: "custom",
|
|
907
|
+
message: "Step IDs must be unique"
|
|
908
|
+
});
|
|
909
|
+
if (plan.steps.filter((step) => step.status === "running").length > 1) context.addIssue({
|
|
910
|
+
code: "custom",
|
|
911
|
+
message: "Only one step can be running"
|
|
912
|
+
});
|
|
913
|
+
});
|
|
914
|
+
PlanParamsSchema.safeExtend({
|
|
915
|
+
id: z.string().min(1),
|
|
916
|
+
kind: z.literal("plan"),
|
|
917
|
+
createdAt: z.number().int().nonnegative(),
|
|
918
|
+
turnId: z.string().optional()
|
|
919
|
+
});
|
|
920
|
+
// ../../packages/shared/src/terminals.ts
|
|
921
|
+
const TerminalIdSchema = z.string().regex(/^term_[a-f0-9-]{36}$/);
|
|
922
|
+
const TerminalRenameSchema = z.object({ title: z.string().min(1).max(80).refine((value) => [...value].every((char) => {
|
|
923
|
+
const code = char.codePointAt(0) ?? 0;
|
|
924
|
+
return code >= 32 && (code < 127 || code > 159);
|
|
925
|
+
})).transform((value) => value.trim()).pipe(z.string().min(1)) }).strict();
|
|
926
|
+
const TerminalRoleSchema = z.string().regex(/^[a-zA-Z0-9_-]{1,64}$/);
|
|
927
|
+
const TerminalStatusSchema = z.enum([
|
|
928
|
+
"CREATED",
|
|
929
|
+
"RUNNING",
|
|
930
|
+
"STOPPING",
|
|
931
|
+
"EXITED",
|
|
932
|
+
"TERMINATED",
|
|
933
|
+
"INTERRUPTED"
|
|
934
|
+
]);
|
|
935
|
+
const TerminalCreateSchema = z.object({
|
|
936
|
+
scope: FileScopeSchema.optional(),
|
|
937
|
+
cwd: FilePathSchema.default("."),
|
|
938
|
+
sourceSessionId: z.string().min(1).max(128).optional(),
|
|
939
|
+
riskAcknowledged: z.literal(true)
|
|
940
|
+
}).strict();
|
|
941
|
+
const TerminalDevSchema = z.object({
|
|
942
|
+
role: TerminalRoleSchema,
|
|
943
|
+
executable: z.string(),
|
|
944
|
+
args: z.array(z.string()),
|
|
945
|
+
cwd: FilePathSchema.default(".").describe("Project-relative working directory. Defaults to the project root (.). Use the package directory for a direct package command.")
|
|
946
|
+
}).strict().superRefine((value, ctx) => {
|
|
947
|
+
if (!CommandParamsSchema.safeParse(value && {
|
|
948
|
+
executable: value.executable,
|
|
949
|
+
args: value.args,
|
|
950
|
+
cwd: value.cwd
|
|
951
|
+
}).success) ctx.addIssue({
|
|
952
|
+
code: "custom",
|
|
953
|
+
message: "Invalid program parameters"
|
|
954
|
+
});
|
|
955
|
+
});
|
|
956
|
+
const ReadTerminalOutputParamsSchema = z.object({
|
|
957
|
+
terminalId: TerminalIdSchema,
|
|
958
|
+
after: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).default(0),
|
|
959
|
+
limit: z.number().int().min(1).max(500).default(100)
|
|
960
|
+
}).strict();
|
|
961
|
+
const StopProjectTerminalParamsSchema = z.object({ terminalId: TerminalIdSchema }).strict();
|
|
962
|
+
const TerminalResultTargetSchema = z.object({
|
|
963
|
+
kind: z.literal("terminal"),
|
|
964
|
+
projectId: z.string().min(1),
|
|
965
|
+
terminalId: TerminalIdSchema,
|
|
966
|
+
role: TerminalRoleSchema.nullable()
|
|
967
|
+
}).strict();
|
|
968
|
+
const PreviewResultTargetSchema = z.object({
|
|
969
|
+
kind: z.literal("preview"),
|
|
970
|
+
projectId: z.string().min(1).max(128),
|
|
971
|
+
serviceId: z.string().regex(/^svc_[a-f0-9-]{36}$/),
|
|
972
|
+
path: z.string().min(1).max(2048),
|
|
973
|
+
name: z.string().min(1).max(128).optional()
|
|
974
|
+
}).strict();
|
|
975
|
+
z.union([
|
|
976
|
+
FileResultTargetSchema,
|
|
977
|
+
TerminalResultTargetSchema,
|
|
978
|
+
PreviewResultTargetSchema
|
|
979
|
+
]);
|
|
980
|
+
const TerminalTakeoverSchema = z.object({ connectionId: z.string().uuid() }).strict();
|
|
981
|
+
const AcquireTerminalControlParamsSchema = z.object({ terminalId: TerminalIdSchema }).strict();
|
|
982
|
+
const SendTerminalInputParamsSchema = z.object({
|
|
983
|
+
terminalId: TerminalIdSchema,
|
|
984
|
+
leaseGeneration: z.number().int().positive(),
|
|
985
|
+
inputSequence: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
986
|
+
data: z.string().min(1).max(8192).refine((data) => new TextEncoder().encode(data).length <= 8192)
|
|
987
|
+
}).strict();
|
|
988
|
+
const InterruptTerminalParamsSchema = z.object({
|
|
989
|
+
terminalId: TerminalIdSchema,
|
|
990
|
+
leaseGeneration: z.number().int().positive()
|
|
991
|
+
}).strict();
|
|
992
|
+
const ReleaseTerminalControlParamsSchema = z.object({
|
|
993
|
+
terminalId: TerminalIdSchema,
|
|
994
|
+
leaseGeneration: z.number().int().positive()
|
|
995
|
+
}).strict();
|
|
996
|
+
const TerminalLeaseSchema = z.object({
|
|
997
|
+
action: z.enum([
|
|
998
|
+
"acquire",
|
|
999
|
+
"renew",
|
|
1000
|
+
"release"
|
|
1001
|
+
]),
|
|
1002
|
+
connectionId: z.string().uuid(),
|
|
1003
|
+
leaseGeneration: z.number().int().positive().optional()
|
|
1004
|
+
}).strict();
|
|
1005
|
+
const TerminalResizeSchema = z.object({
|
|
1006
|
+
connectionId: z.string().uuid(),
|
|
1007
|
+
leaseGeneration: z.number().int().positive(),
|
|
1008
|
+
cols: z.number().int().min(2).max(500),
|
|
1009
|
+
rows: z.number().int().min(1).max(300)
|
|
1010
|
+
}).strict();
|
|
1011
|
+
const TerminalInputSchema = z.object({
|
|
1012
|
+
type: z.literal("terminal.input"),
|
|
1013
|
+
terminalId: TerminalIdSchema,
|
|
1014
|
+
leaseGeneration: z.number().int().positive(),
|
|
1015
|
+
inputSequence: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
1016
|
+
data: z.string().max(8192).refine((data) => new TextEncoder().encode(data).length <= 8192)
|
|
1017
|
+
}).strict();
|
|
1018
|
+
const TerminalSubscriptionSchema = z.object({
|
|
1019
|
+
topic: z.literal("terminal"),
|
|
1020
|
+
resourceId: TerminalIdSchema,
|
|
1021
|
+
after: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).default(0)
|
|
1022
|
+
}).strict();
|
|
1023
|
+
const TerminalOutputChunkSchema = z.object({
|
|
1024
|
+
cursor: z.number().int().positive(),
|
|
1025
|
+
data: z.string().max(16384).refine((data) => new TextEncoder().encode(data).length <= 16384),
|
|
1026
|
+
timestamp: z.number().int()
|
|
1027
|
+
}).strict();
|
|
1028
|
+
TerminalOutputChunkSchema.extend({
|
|
1029
|
+
kind: z.literal("terminal.output"),
|
|
1030
|
+
resourceId: TerminalIdSchema
|
|
1031
|
+
}).strict();
|
|
1032
|
+
const TerminalLeaseViewSchema = z.object({
|
|
1033
|
+
ownerType: z.enum(["human", "agent"]),
|
|
1034
|
+
ownerClientSessionId: z.string(),
|
|
1035
|
+
ownerConnectionId: z.string().nullable(),
|
|
1036
|
+
ownerTurnId: z.string().nullable(),
|
|
1037
|
+
ownerExecutionId: z.string().nullable(),
|
|
1038
|
+
generation: z.number().int().positive(),
|
|
1039
|
+
expiresAt: z.number().int()
|
|
1040
|
+
});
|
|
1041
|
+
const TerminalPayloadSchema = z.object({
|
|
1042
|
+
status: TerminalStatusSchema,
|
|
1043
|
+
exitCode: z.number().int().nullable(),
|
|
1044
|
+
reasonCode: z.string().nullable(),
|
|
1045
|
+
lease: TerminalLeaseViewSchema.nullable()
|
|
1046
|
+
});
|
|
1047
|
+
const TerminalEventSchema = z.object({
|
|
1048
|
+
kind: z.literal("event"),
|
|
1049
|
+
protocolVersion: z.literal(1),
|
|
1050
|
+
topic: z.literal("terminal"),
|
|
1051
|
+
eventId: z.string(),
|
|
1052
|
+
streamId: TerminalIdSchema,
|
|
1053
|
+
resourceId: TerminalIdSchema,
|
|
1054
|
+
sequence: z.number().int().positive(),
|
|
1055
|
+
timestamp: z.number(),
|
|
1056
|
+
type: z.enum([
|
|
1057
|
+
"terminal.created",
|
|
1058
|
+
"terminal.status",
|
|
1059
|
+
"terminal.exit",
|
|
1060
|
+
"terminal.lease"
|
|
1061
|
+
]),
|
|
1062
|
+
payload: TerminalPayloadSchema
|
|
1063
|
+
});
|
|
1064
|
+
const TERMINAL_LEASE_TTL_MS = 3e4;
|
|
1065
|
+
const TerminalSchema = z.object({
|
|
1066
|
+
writeBlocked: z.boolean(),
|
|
1067
|
+
id: TerminalIdSchema,
|
|
1068
|
+
projectId: z.string().nullable(),
|
|
1069
|
+
workspaceSessionId: z.string().nullable(),
|
|
1070
|
+
sourceSessionId: z.string().nullable(),
|
|
1071
|
+
cwd: z.string(),
|
|
1072
|
+
shell: z.string(),
|
|
1073
|
+
mode: z.enum(["shell", "dev"]),
|
|
1074
|
+
role: z.string().nullable(),
|
|
1075
|
+
title: z.string().nullable().default(null),
|
|
1076
|
+
status: TerminalStatusSchema,
|
|
1077
|
+
exitCode: z.number().nullable(),
|
|
1078
|
+
reasonCode: z.string().nullable(),
|
|
1079
|
+
currentSequence: z.number().int(),
|
|
1080
|
+
lease: TerminalLeaseViewSchema.nullable()
|
|
1081
|
+
});
|
|
1082
|
+
z.object({
|
|
1083
|
+
chunks: z.array(TerminalOutputChunkSchema).max(500),
|
|
1084
|
+
nextCursor: z.number().int(),
|
|
1085
|
+
oldestCursor: z.number().int(),
|
|
1086
|
+
truncated: z.boolean(),
|
|
1087
|
+
resyncRequired: z.boolean()
|
|
1088
|
+
});
|
|
1089
|
+
z.object({
|
|
1090
|
+
kind: z.literal("subscribed"),
|
|
1091
|
+
connectionId: z.string().uuid(),
|
|
1092
|
+
subscription: z.object({
|
|
1093
|
+
topic: z.literal("terminal"),
|
|
1094
|
+
resourceId: z.string()
|
|
1095
|
+
})
|
|
1096
|
+
});
|
|
1097
|
+
z.object({
|
|
1098
|
+
kind: z.literal("terminal.input.ack"),
|
|
1099
|
+
inputSequence: z.number().int(),
|
|
1100
|
+
accepted: z.boolean()
|
|
1101
|
+
});
|
|
1102
|
+
z.object({
|
|
1103
|
+
kind: z.literal("error"),
|
|
1104
|
+
code: z.string()
|
|
1105
|
+
});
|
|
1106
|
+
z.object({
|
|
1107
|
+
items: z.array(TerminalSchema),
|
|
1108
|
+
nextCursor: TerminalIdSchema.nullable()
|
|
1109
|
+
});
|
|
1110
|
+
// ../../packages/shared/src/services.ts
|
|
1111
|
+
const ServiceIdSchema = z.string().regex(/^svc_[a-f0-9-]{36}$/);
|
|
1112
|
+
const ServiceStatusSchema = z.enum([
|
|
1113
|
+
"REGISTERING",
|
|
1114
|
+
"STARTING",
|
|
1115
|
+
"RUNNING",
|
|
1116
|
+
"UNKNOWN",
|
|
1117
|
+
"UNREGISTERED"
|
|
1118
|
+
]);
|
|
1119
|
+
const ServiceKindSchema = z.literal("temporary");
|
|
1120
|
+
const ServiceEndpointSchema = z.object({
|
|
1121
|
+
host: z.enum(["127.0.0.1", "::1"]),
|
|
1122
|
+
port: z.number().int().min(1).max(65535),
|
|
1123
|
+
protocol: z.literal("http")
|
|
1124
|
+
}).strict();
|
|
1125
|
+
const ServiceRegisterInputSchema = z.object({
|
|
1126
|
+
kind: ServiceKindSchema.describe("temporary development preview only; registration does not create a persistent PM2 service"),
|
|
1127
|
+
terminalId: TerminalIdSchema.describe("Managed terminal owning the real listening process; not a PM2 targetId or pm2Name"),
|
|
1128
|
+
name: z.string().trim().min(1).max(80),
|
|
1129
|
+
endpoint: ServiceEndpointSchema.describe("Use the terminal listener's port and a loopback host value. The backend discovers the actual bind address, including wildcard listeners.")
|
|
1130
|
+
}).strict();
|
|
1131
|
+
const ServiceDtoSchema = z.object({
|
|
1132
|
+
id: ServiceIdSchema,
|
|
1133
|
+
projectId: z.string().min(1).max(128),
|
|
1134
|
+
sourceSessionId: z.string().min(1).max(128).nullable(),
|
|
1135
|
+
name: z.string().min(1).max(80),
|
|
1136
|
+
kind: ServiceKindSchema,
|
|
1137
|
+
status: ServiceStatusSchema,
|
|
1138
|
+
terminalId: TerminalIdSchema,
|
|
1139
|
+
terminalExecutionId: z.string().min(1).max(128),
|
|
1140
|
+
endpointGeneration: z.number().int().nonnegative(),
|
|
1141
|
+
endpoint: ServiceEndpointSchema,
|
|
1142
|
+
previewEligible: z.boolean(),
|
|
1143
|
+
reasonCode: z.string().nullable(),
|
|
1144
|
+
createdAt: z.number().int(),
|
|
1145
|
+
updatedAt: z.number().int(),
|
|
1146
|
+
endedAt: z.number().int().nullable()
|
|
1147
|
+
});
|
|
1148
|
+
z.object({
|
|
1149
|
+
items: z.array(ServiceDtoSchema),
|
|
1150
|
+
nextCursor: z.string().nullable()
|
|
1151
|
+
});
|
|
1152
|
+
z.object({
|
|
1153
|
+
id: z.string().min(1).max(128),
|
|
1154
|
+
projectId: z.string().min(1).max(128),
|
|
1155
|
+
kind: z.literal("service.register"),
|
|
1156
|
+
risk: z.literal("L2"),
|
|
1157
|
+
status: z.enum([
|
|
1158
|
+
"PREPARED",
|
|
1159
|
+
"WAITING_APPROVAL",
|
|
1160
|
+
"APPROVED",
|
|
1161
|
+
"RUNNING",
|
|
1162
|
+
"COMPLETED",
|
|
1163
|
+
"FAILED",
|
|
1164
|
+
"REJECTED",
|
|
1165
|
+
"EXPIRED",
|
|
1166
|
+
"INTERRUPTED"
|
|
1167
|
+
]),
|
|
1168
|
+
params: ServiceRegisterInputSchema,
|
|
1169
|
+
paramsHash: z.string(),
|
|
1170
|
+
snapshotVersion: z.string(),
|
|
1171
|
+
requestedBy: z.string(),
|
|
1172
|
+
decidedBy: z.string().nullable(),
|
|
1173
|
+
expiresAt: z.number().int(),
|
|
1174
|
+
decidedAt: z.number().int().nullable(),
|
|
1175
|
+
startedAt: z.number().int().nullable(),
|
|
1176
|
+
endedAt: z.number().int().nullable(),
|
|
1177
|
+
result: z.unknown(),
|
|
1178
|
+
createdAt: z.number().int()
|
|
1179
|
+
});
|
|
1180
|
+
const ServiceEventPayloadSchema = z.object({
|
|
1181
|
+
status: ServiceStatusSchema,
|
|
1182
|
+
terminalId: TerminalIdSchema,
|
|
1183
|
+
terminalExecutionId: z.string().min(1).max(128),
|
|
1184
|
+
endpointGeneration: z.number().int().nonnegative(),
|
|
1185
|
+
reasonCode: z.string().nullable()
|
|
1186
|
+
});
|
|
1187
|
+
const ServiceSubscriptionSchema = z.object({
|
|
1188
|
+
topic: z.literal("service"),
|
|
1189
|
+
resourceId: ServiceIdSchema,
|
|
1190
|
+
after: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).default(0)
|
|
1191
|
+
}).strict();
|
|
1192
|
+
// ../../packages/shared/src/resources.ts
|
|
1193
|
+
const RESOURCE_EVENT_RETENTION_MS = 2592e6;
|
|
1194
|
+
const FileResourceIdSchema = z.string().regex(/^(?:(?:project|session):[a-zA-Z0-9_-]{1,128}|workspace:default)$/);
|
|
1195
|
+
const FileStreamIdSchema = z.string().regex(/^file:(?:(?:project|session):[a-zA-Z0-9_-]{1,128}|workspace:default)$/);
|
|
1196
|
+
const FileSubscriptionSchema = z.object({
|
|
1197
|
+
topic: z.literal("file"),
|
|
1198
|
+
resourceId: FileResourceIdSchema,
|
|
1199
|
+
paths: z.array(FilePathSchema).min(1).max(128).default(["."]),
|
|
1200
|
+
after: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).default(0)
|
|
1201
|
+
}).strict();
|
|
1202
|
+
const ServiceOpsStreamIdSchema = z.string().regex(/^ops:tgt_[0-9a-f-]{36}$/);
|
|
1203
|
+
const ResourceEventsQuerySchema = z.object({
|
|
1204
|
+
streamId: z.union([
|
|
1205
|
+
FileStreamIdSchema,
|
|
1206
|
+
CommandIdSchema,
|
|
1207
|
+
TerminalIdSchema,
|
|
1208
|
+
ServiceIdSchema,
|
|
1209
|
+
ServiceOpsStreamIdSchema
|
|
1210
|
+
]),
|
|
1211
|
+
after: z.coerce.number().int().min(0).max(Number.MAX_SAFE_INTEGER).default(0),
|
|
1212
|
+
limit: z.coerce.number().int().min(1).max(500).default(100)
|
|
1213
|
+
}).strict();
|
|
1214
|
+
const FileChangedPayloadSchema = z.object({
|
|
1215
|
+
path: FilePathSchema,
|
|
1216
|
+
version: FileVersionSchema.optional(),
|
|
1217
|
+
changeType: z.enum([
|
|
1218
|
+
"created",
|
|
1219
|
+
"modified",
|
|
1220
|
+
"deleted"
|
|
1221
|
+
])
|
|
1222
|
+
});
|
|
1223
|
+
const FileResyncPayloadSchema = z.object({ reasonCode: z.enum([
|
|
1224
|
+
"WATCH_UNAVAILABLE",
|
|
1225
|
+
"WATCH_LIMIT",
|
|
1226
|
+
"SCAN_LIMIT",
|
|
1227
|
+
"QUEUE_OVERFLOW",
|
|
1228
|
+
"ROOT_UNAVAILABLE",
|
|
1229
|
+
"DIRECTORY_REPLACED",
|
|
1230
|
+
"RECOVERED",
|
|
1231
|
+
"SCAN_FAILED"
|
|
1232
|
+
]) });
|
|
1233
|
+
const FileEventBase = z.object({
|
|
1234
|
+
kind: z.literal("event"),
|
|
1235
|
+
protocolVersion: z.literal(1),
|
|
1236
|
+
topic: z.literal("file"),
|
|
1237
|
+
eventId: z.string(),
|
|
1238
|
+
streamId: FileStreamIdSchema,
|
|
1239
|
+
sequence: z.number().int().nonnegative(),
|
|
1240
|
+
timestamp: z.number()
|
|
1241
|
+
});
|
|
1242
|
+
const FileNotificationSchema = z.union([FileEventBase.extend({
|
|
1243
|
+
type: z.literal("file.changed"),
|
|
1244
|
+
payload: FileChangedPayloadSchema
|
|
1245
|
+
}), FileEventBase.extend({
|
|
1246
|
+
type: z.literal("file.resync.required"),
|
|
1247
|
+
payload: FileResyncPayloadSchema
|
|
1248
|
+
})]);
|
|
1249
|
+
const ServiceEventBase = z.object({
|
|
1250
|
+
kind: z.literal("event"),
|
|
1251
|
+
protocolVersion: z.literal(1),
|
|
1252
|
+
topic: z.literal("service"),
|
|
1253
|
+
eventId: z.string(),
|
|
1254
|
+
streamId: ServiceIdSchema,
|
|
1255
|
+
sequence: z.number().int().nonnegative(),
|
|
1256
|
+
timestamp: z.number(),
|
|
1257
|
+
projectId: z.string().optional()
|
|
1258
|
+
});
|
|
1259
|
+
const ServiceNotificationSchema = z.union([ServiceEventBase.extend({
|
|
1260
|
+
type: z.enum([
|
|
1261
|
+
"service.registered",
|
|
1262
|
+
"service.status",
|
|
1263
|
+
"service.unregistered"
|
|
1264
|
+
]),
|
|
1265
|
+
payload: ServiceEventPayloadSchema
|
|
1266
|
+
})]);
|
|
1267
|
+
z.object({
|
|
1268
|
+
items: z.array(z.union([
|
|
1269
|
+
FileNotificationSchema,
|
|
1270
|
+
CommandStatusEventSchema,
|
|
1271
|
+
TerminalEventSchema,
|
|
1272
|
+
ServiceNotificationSchema
|
|
1273
|
+
])),
|
|
1274
|
+
currentSequence: z.number().int().nonnegative(),
|
|
1275
|
+
resyncRequired: z.boolean()
|
|
1276
|
+
});
|
|
1277
|
+
z.object({
|
|
1278
|
+
kind: z.literal("subscribed"),
|
|
1279
|
+
subscription: z.object({
|
|
1280
|
+
topic: z.literal("file"),
|
|
1281
|
+
resourceId: FileResourceIdSchema
|
|
1282
|
+
}),
|
|
1283
|
+
currentSequence: z.number().int().nonnegative(),
|
|
1284
|
+
resyncRequired: z.boolean(),
|
|
1285
|
+
partial: z.boolean()
|
|
1286
|
+
});
|
|
1287
|
+
z.object({
|
|
1288
|
+
kind: z.literal("error"),
|
|
1289
|
+
code: z.string(),
|
|
1290
|
+
message: z.string()
|
|
1291
|
+
});
|
|
1292
|
+
// src/db/ids.ts
|
|
1293
|
+
function newId(prefix) {
|
|
1294
|
+
return `${prefix}_${randomUUID()}`;
|
|
1295
|
+
}
|
|
1296
|
+
// src/db/schema.ts
|
|
1297
|
+
var schema_exports = /* @__PURE__ */ __exportAll({
|
|
1298
|
+
agentEvents: () => agentEvents,
|
|
1299
|
+
appMeta: () => appMeta,
|
|
1300
|
+
approvals: () => approvals,
|
|
1301
|
+
auditLogs: () => auditLogs,
|
|
1302
|
+
authSettings: () => authSettings,
|
|
1303
|
+
browserSessions: () => browserSessions,
|
|
1304
|
+
commandExecutions: () => commandExecutions,
|
|
1305
|
+
credentialProfiles: () => credentialProfiles,
|
|
1306
|
+
deploymentApprovals: () => deploymentApprovals,
|
|
1307
|
+
deploymentArtifacts: () => deploymentArtifacts,
|
|
1308
|
+
deploymentAuthorizations: () => deploymentAuthorizations,
|
|
1309
|
+
deploymentBuilds: () => deploymentBuilds,
|
|
1310
|
+
deploymentPlans: () => deploymentPlans,
|
|
1311
|
+
deploymentTargets: () => deploymentTargets,
|
|
1312
|
+
deviceRequests: () => deviceRequests,
|
|
1313
|
+
fileVersions: () => fileVersions,
|
|
1314
|
+
modelCatalogCache: () => modelCatalogCache,
|
|
1315
|
+
modelDefaults: () => modelDefaults,
|
|
1316
|
+
modelProfiles: () => modelProfiles,
|
|
1317
|
+
modelVisibility: () => modelVisibility,
|
|
1318
|
+
projects: () => projects,
|
|
1319
|
+
resourceActions: () => resourceActions,
|
|
1320
|
+
resourceEvents: () => resourceEvents,
|
|
1321
|
+
resourceLocks: () => resourceLocks,
|
|
1322
|
+
resourceOperations: () => resourceOperations,
|
|
1323
|
+
resourceStreams: () => resourceStreams,
|
|
1324
|
+
scheduledJobRuns: () => scheduledJobRuns,
|
|
1325
|
+
scheduledJobs: () => scheduledJobs,
|
|
1326
|
+
secrets: () => secrets,
|
|
1327
|
+
serviceActionAuthorizations: () => serviceActionAuthorizations,
|
|
1328
|
+
serviceOpsDeployments: () => serviceOpsDeployments,
|
|
1329
|
+
serviceOpsServices: () => serviceOpsServices,
|
|
1330
|
+
services: () => services,
|
|
1331
|
+
sessionContextSummaries: () => sessionContextSummaries,
|
|
1332
|
+
sessions: () => sessions,
|
|
1333
|
+
terminalLeases: () => terminalLeases,
|
|
1334
|
+
terminals: () => terminals,
|
|
1335
|
+
trustedDevices: () => trustedDevices,
|
|
1336
|
+
turns: () => turns,
|
|
1337
|
+
webauthnChallenges: () => webauthnChallenges,
|
|
1338
|
+
webauthnCredentials: () => webauthnCredentials
|
|
1339
|
+
});
|
|
1340
|
+
const appMeta = sqliteTable("app_meta", {
|
|
1341
|
+
key: text("key").primaryKey(),
|
|
1342
|
+
value: text("value").notNull(),
|
|
1343
|
+
updatedAt: integer("updated_at").notNull()
|
|
1344
|
+
});
|
|
1345
|
+
const projects = sqliteTable("projects", {
|
|
1346
|
+
id: text("id").primaryKey(),
|
|
1347
|
+
name: text("name").notNull(),
|
|
1348
|
+
rootPath: text("root_path").notNull(),
|
|
1349
|
+
realPath: text("real_path").notNull().unique(),
|
|
1350
|
+
settingsJson: text("settings_json").notNull().default("{}"),
|
|
1351
|
+
gitDetected: integer("git_detected", { mode: "boolean" }).notNull().default(false),
|
|
1352
|
+
/** User-defined project list order; lower values appear first. */
|
|
1353
|
+
sortOrder: integer("sort_order").notNull().default(0),
|
|
1354
|
+
createdAt: integer("created_at").notNull(),
|
|
1355
|
+
updatedAt: integer("updated_at").notNull()
|
|
1356
|
+
}, (table) => [index("idx_projects_updated").on(table.updatedAt), index("idx_projects_order").on(table.sortOrder, table.updatedAt)]);
|
|
1357
|
+
const sessions = sqliteTable("sessions", {
|
|
1358
|
+
id: text("id").primaryKey(),
|
|
1359
|
+
projectId: text("project_id").references(() => projects.id, { onDelete: "set null" }),
|
|
1360
|
+
workspacePath: text("workspace_path").notNull(),
|
|
1361
|
+
title: text("title").notNull(),
|
|
1362
|
+
status: text("status").$type().notNull().default("active"),
|
|
1363
|
+
origin: text("origin").$type().notNull().default("user"),
|
|
1364
|
+
modelProfileId: text("model_profile_id"),
|
|
1365
|
+
credentialProfileId: text("credential_profile_id"),
|
|
1366
|
+
model: text("model"),
|
|
1367
|
+
thinking: text("thinking"),
|
|
1368
|
+
approvalPolicyId: text("approval_policy_id").notNull().default("standard"),
|
|
1369
|
+
createdAt: integer("created_at").notNull(),
|
|
1370
|
+
updatedAt: integer("updated_at").notNull(),
|
|
1371
|
+
lastActivityAt: integer("last_activity_at").notNull(),
|
|
1372
|
+
/** Set when the user explicitly keeps this session out of retention cleanup. */
|
|
1373
|
+
pinnedAt: integer("pinned_at")
|
|
1374
|
+
}, (table) => [
|
|
1375
|
+
index("idx_sessions_project_updated").on(table.projectId, table.updatedAt),
|
|
1376
|
+
index("idx_sessions_updated").on(table.updatedAt),
|
|
1377
|
+
index("idx_sessions_origin").on(table.origin, table.updatedAt)
|
|
1378
|
+
]);
|
|
1379
|
+
const turns = sqliteTable("turns", {
|
|
1380
|
+
id: text("id").primaryKey(),
|
|
1381
|
+
sessionId: text("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
|
|
1382
|
+
modelProfileId: text("model_profile_id"),
|
|
1383
|
+
credentialProfileId: text("credential_profile_id"),
|
|
1384
|
+
provider: text("provider"),
|
|
1385
|
+
model: text("model"),
|
|
1386
|
+
thinking: text("thinking"),
|
|
1387
|
+
contextWindow: integer("context_window"),
|
|
1388
|
+
status: text("status").$type().notNull(),
|
|
1389
|
+
inputJson: text("input_json").notNull(),
|
|
1390
|
+
usageJson: text("usage_json"),
|
|
1391
|
+
errorJson: text("error_json"),
|
|
1392
|
+
terminalReason: text("terminal_reason").$type(),
|
|
1393
|
+
/** Set when this Turn continues an interrupted Turn. */
|
|
1394
|
+
resumedFromTurnId: text("resumed_from_turn_id"),
|
|
1395
|
+
idempotencyKey: text("idempotency_key"),
|
|
1396
|
+
createdAt: integer("created_at").notNull(),
|
|
1397
|
+
startedAt: integer("started_at"),
|
|
1398
|
+
endedAt: integer("ended_at")
|
|
1399
|
+
}, (table) => [
|
|
1400
|
+
uniqueIndex("turns_session_idempotency_unique").on(table.sessionId, table.idempotencyKey),
|
|
1401
|
+
index("idx_turns_session_created").on(table.sessionId, table.createdAt),
|
|
1402
|
+
index("idx_turns_session_status").on(table.sessionId, table.status)
|
|
1403
|
+
]);
|
|
1404
|
+
const agentEvents = sqliteTable("agent_events", {
|
|
1405
|
+
id: text("id").primaryKey(),
|
|
1406
|
+
sessionId: text("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
|
|
1407
|
+
turnId: text("turn_id").references(() => turns.id, { onDelete: "cascade" }),
|
|
1408
|
+
seq: integer("seq").notNull(),
|
|
1409
|
+
type: text("type").notNull(),
|
|
1410
|
+
payloadJson: text("payload_json").notNull().default("{}"),
|
|
1411
|
+
createdAt: integer("created_at").notNull()
|
|
1412
|
+
}, (table) => [uniqueIndex("agent_events_session_seq_unique").on(table.sessionId, table.seq)]);
|
|
1413
|
+
const approvals = sqliteTable("approvals", {
|
|
1414
|
+
id: text("id").primaryKey(),
|
|
1415
|
+
turnId: text("turn_id").notNull().references(() => turns.id, { onDelete: "cascade" }),
|
|
1416
|
+
toolCallId: text("tool_call_id").notNull(),
|
|
1417
|
+
toolName: text("tool_name").notNull(),
|
|
1418
|
+
risk: text("risk").notNull(),
|
|
1419
|
+
status: text("status").$type().notNull().default("pending"),
|
|
1420
|
+
scopeJson: text("scope_json").notNull().default("{}"),
|
|
1421
|
+
paramsHash: text("params_hash").notNull(),
|
|
1422
|
+
expiresAt: integer("expires_at").notNull(),
|
|
1423
|
+
decidedAt: integer("decided_at"),
|
|
1424
|
+
decidedBy: text("decided_by"),
|
|
1425
|
+
createdAt: integer("created_at").notNull()
|
|
1426
|
+
}, (table) => [index("idx_approvals_turn_status").on(table.turnId, table.status), index("idx_approvals_expiry").on(table.expiresAt)]);
|
|
1427
|
+
const resourceLocks = sqliteTable("resource_locks", {
|
|
1428
|
+
id: text("id").primaryKey(),
|
|
1429
|
+
resourceType: text("resource_type").$type().notNull(),
|
|
1430
|
+
resourceId: text("resource_id").notNull(),
|
|
1431
|
+
rootRealPath: text("root_real_path"),
|
|
1432
|
+
owner: text("owner").notNull(),
|
|
1433
|
+
executionId: text("execution_id").notNull(),
|
|
1434
|
+
fencingToken: integer("fencing_token").notNull(),
|
|
1435
|
+
expiresAt: integer("expires_at").notNull(),
|
|
1436
|
+
heartbeatAt: integer("heartbeat_at").notNull(),
|
|
1437
|
+
createdAt: integer("created_at").notNull()
|
|
1438
|
+
}, (table) => [uniqueIndex("resource_locks_resource_unique").on(table.resourceType, table.resourceId), index("idx_resource_locks_expiry").on(table.expiresAt)]);
|
|
1439
|
+
const secrets = sqliteTable("secrets", {
|
|
1440
|
+
id: text("id").primaryKey(),
|
|
1441
|
+
ciphertext: text("ciphertext").notNull(),
|
|
1442
|
+
nonce: text("nonce").notNull(),
|
|
1443
|
+
tag: text("tag").notNull(),
|
|
1444
|
+
createdAt: integer("created_at").notNull()
|
|
1445
|
+
});
|
|
1446
|
+
const credentialProfiles = sqliteTable("credential_profiles", {
|
|
1447
|
+
id: text("id").primaryKey(),
|
|
1448
|
+
provider: text("provider").$type().notNull(),
|
|
1449
|
+
label: text("label").notNull(),
|
|
1450
|
+
secretRef: text("secret_ref").notNull().references(() => secrets.id, { onDelete: "cascade" }),
|
|
1451
|
+
endpoint: text("endpoint"),
|
|
1452
|
+
contextWindow: integer("context_window"),
|
|
1453
|
+
createdAt: integer("created_at").notNull()
|
|
1454
|
+
}, (table) => [index("idx_credential_profiles_provider").on(table.provider)]);
|
|
1455
|
+
const modelProfiles = sqliteTable("model_profiles", {
|
|
1456
|
+
id: text("id").primaryKey(),
|
|
1457
|
+
label: text("label").notNull(),
|
|
1458
|
+
provider: text("provider").$type().notNull(),
|
|
1459
|
+
model: text("model").notNull(),
|
|
1460
|
+
credentialProfileId: text("credential_profile_id").references(() => credentialProfiles.id, { onDelete: "set null" }),
|
|
1461
|
+
endpoint: text("endpoint"),
|
|
1462
|
+
capabilitiesJson: text("capabilities_json").notNull().default("{}"),
|
|
1463
|
+
createdAt: integer("created_at").notNull()
|
|
1464
|
+
}, (table) => [index("idx_model_profiles_provider").on(table.provider)]);
|
|
1465
|
+
const modelCatalogCache = sqliteTable("model_catalog_cache", {
|
|
1466
|
+
credentialProfileId: text("credential_profile_id").primaryKey().references(() => credentialProfiles.id, { onDelete: "cascade" }),
|
|
1467
|
+
provider: text("provider").$type().notNull(),
|
|
1468
|
+
endpoint: text("endpoint").notNull(),
|
|
1469
|
+
modelsJson: text("models_json").notNull().default("[]"),
|
|
1470
|
+
syncedAt: integer("synced_at"),
|
|
1471
|
+
lastAttemptAt: integer("last_attempt_at"),
|
|
1472
|
+
lastErrorCode: text("last_error_code")
|
|
1473
|
+
});
|
|
1474
|
+
const modelVisibility = sqliteTable("model_visibility", {
|
|
1475
|
+
id: text("id").primaryKey(),
|
|
1476
|
+
credentialProfileId: text("credential_profile_id").notNull().references(() => credentialProfiles.id, { onDelete: "cascade" }),
|
|
1477
|
+
modelId: text("model_id").notNull(),
|
|
1478
|
+
visible: integer("visible").notNull().default(1),
|
|
1479
|
+
updatedAt: integer("updated_at").notNull()
|
|
1480
|
+
}, (table) => [uniqueIndex("model_visibility_credential_model").on(table.credentialProfileId, table.modelId)]);
|
|
1481
|
+
const sessionContextSummaries = sqliteTable("session_context_summaries", {
|
|
1482
|
+
id: text("id").primaryKey(),
|
|
1483
|
+
sessionId: text("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
|
|
1484
|
+
coveredUpToSeq: integer("covered_up_to_seq").notNull(),
|
|
1485
|
+
summary: text("summary").notNull(),
|
|
1486
|
+
tokensBefore: integer("tokens_before").notNull(),
|
|
1487
|
+
tokensAfter: integer("tokens_after").notNull(),
|
|
1488
|
+
degraded: integer("degraded").notNull().default(0),
|
|
1489
|
+
/** `session`: cross-Turn compression; `turn`: in-Turn checkpoint. */
|
|
1490
|
+
scope: text("scope").$type().notNull().default("session"),
|
|
1491
|
+
turnId: text("turn_id"),
|
|
1492
|
+
reason: text("reason"),
|
|
1493
|
+
createdAt: integer("created_at").notNull()
|
|
1494
|
+
}, (table) => [index("idx_context_summaries_session").on(table.sessionId, table.createdAt), index("idx_summaries_session_scope_created").on(table.sessionId, table.scope, table.createdAt)]);
|
|
1495
|
+
const modelDefaults = sqliteTable("model_defaults", {
|
|
1496
|
+
id: text("id").primaryKey(),
|
|
1497
|
+
credentialProfileId: text("credential_profile_id").notNull().references(() => credentialProfiles.id, { onDelete: "cascade" }),
|
|
1498
|
+
model: text("model").notNull(),
|
|
1499
|
+
thinking: text("thinking").notNull(),
|
|
1500
|
+
updatedAt: integer("updated_at").notNull()
|
|
1501
|
+
}, (table) => [check("model_defaults_single_row", sql`${table.id} = 'default'`)]);
|
|
1502
|
+
const authSettings = sqliteTable("auth_settings", {
|
|
1503
|
+
id: integer("id").primaryKey(),
|
|
1504
|
+
adminHash: text("admin_hash").notNull(),
|
|
1505
|
+
adminUpdatedAt: integer("admin_updated_at").notNull(),
|
|
1506
|
+
initializedAt: integer("initialized_at").notNull()
|
|
1507
|
+
}, (table) => [check("auth_settings_single_row", sql`${table.id} = 1`)]);
|
|
1508
|
+
const deviceRequests = sqliteTable("device_requests", {
|
|
1509
|
+
id: text("id").primaryKey(),
|
|
1510
|
+
shortCode: text("short_code").notNull().unique(),
|
|
1511
|
+
status: text("status").$type().notNull(),
|
|
1512
|
+
decision: text("decision").$type(),
|
|
1513
|
+
clientLabel: text("client_label"),
|
|
1514
|
+
userAgent: text("user_agent"),
|
|
1515
|
+
ip: text("ip"),
|
|
1516
|
+
clientOrigin: text("client_origin"),
|
|
1517
|
+
pollTokenHash: text("poll_token_hash").notNull(),
|
|
1518
|
+
codeHash: text("code_hash"),
|
|
1519
|
+
codeExpiresAt: integer("code_expires_at"),
|
|
1520
|
+
attempts: integer("attempts").notNull().default(0),
|
|
1521
|
+
enrollmentTokenHash: text("enrollment_token_hash"),
|
|
1522
|
+
enrollmentExpiresAt: integer("enrollment_expires_at"),
|
|
1523
|
+
createdAt: integer("created_at").notNull(),
|
|
1524
|
+
expiresAt: integer("expires_at").notNull(),
|
|
1525
|
+
decidedAt: integer("decided_at"),
|
|
1526
|
+
redeemedAt: integer("redeemed_at")
|
|
1527
|
+
}, (table) => [index("idx_device_requests_status").on(table.status, table.expiresAt)]);
|
|
1528
|
+
const trustedDevices = sqliteTable("trusted_devices", {
|
|
1529
|
+
id: text("id").primaryKey(),
|
|
1530
|
+
label: text("label").notNull(),
|
|
1531
|
+
createdByRequestId: text("created_by_request_id").references(() => deviceRequests.id),
|
|
1532
|
+
userAgent: text("user_agent"),
|
|
1533
|
+
createdAt: integer("created_at").notNull(),
|
|
1534
|
+
lastSeenAt: integer("last_seen_at"),
|
|
1535
|
+
revokedAt: integer("revoked_at")
|
|
1536
|
+
});
|
|
1537
|
+
const webauthnCredentials = sqliteTable("webauthn_credentials", {
|
|
1538
|
+
id: text("id").primaryKey(),
|
|
1539
|
+
deviceId: text("device_id").notNull().references(() => trustedDevices.id),
|
|
1540
|
+
credentialId: text("credential_id").notNull().unique(),
|
|
1541
|
+
publicKey: text("public_key").notNull(),
|
|
1542
|
+
counter: integer("counter").notNull().default(0),
|
|
1543
|
+
transportsJson: text("transports_json").notNull().default("[]"),
|
|
1544
|
+
aaguid: text("aaguid"),
|
|
1545
|
+
backupEligible: integer("backup_eligible", { mode: "boolean" }).notNull().default(false),
|
|
1546
|
+
backupState: integer("backup_state", { mode: "boolean" }).notNull().default(false),
|
|
1547
|
+
createdAt: integer("created_at").notNull(),
|
|
1548
|
+
lastUsedAt: integer("last_used_at"),
|
|
1549
|
+
revokedAt: integer("revoked_at")
|
|
1550
|
+
}, (table) => [index("idx_webauthn_credentials_device").on(table.deviceId)]);
|
|
1551
|
+
const webauthnChallenges = sqliteTable("webauthn_challenges", {
|
|
1552
|
+
id: text("id").primaryKey(),
|
|
1553
|
+
type: text("type").$type().notNull(),
|
|
1554
|
+
challenge: text("challenge").notNull(),
|
|
1555
|
+
requestId: text("request_id").references(() => deviceRequests.id),
|
|
1556
|
+
deviceId: text("device_id").references(() => trustedDevices.id),
|
|
1557
|
+
createdAt: integer("created_at").notNull(),
|
|
1558
|
+
expiresAt: integer("expires_at").notNull(),
|
|
1559
|
+
consumedAt: integer("consumed_at")
|
|
1560
|
+
}, (table) => [index("idx_webauthn_challenges_expiry").on(table.expiresAt)]);
|
|
1561
|
+
const browserSessions = sqliteTable("browser_sessions", {
|
|
1562
|
+
id: text("id").primaryKey(),
|
|
1563
|
+
deviceId: text("device_id").references(() => trustedDevices.id),
|
|
1564
|
+
tokenHash: text("token_hash").notNull().unique(),
|
|
1565
|
+
kind: text("kind").$type().notNull(),
|
|
1566
|
+
ip: text("ip"),
|
|
1567
|
+
userAgent: text("user_agent"),
|
|
1568
|
+
createdAt: integer("created_at").notNull(),
|
|
1569
|
+
lastSeenAt: integer("last_seen_at").notNull(),
|
|
1570
|
+
expiresAt: integer("expires_at").notNull(),
|
|
1571
|
+
revokedAt: integer("revoked_at")
|
|
1572
|
+
}, (table) => [index("idx_browser_sessions_device").on(table.deviceId)]);
|
|
1573
|
+
const auditLogs = sqliteTable("audit_logs", {
|
|
1574
|
+
id: text("id").primaryKey(),
|
|
1575
|
+
clientSessionId: text("client_session_id"),
|
|
1576
|
+
sessionId: text("session_id"),
|
|
1577
|
+
action: text("action").notNull(),
|
|
1578
|
+
resourceType: text("resource_type"),
|
|
1579
|
+
resourceId: text("resource_id"),
|
|
1580
|
+
decision: text("decision").$type(),
|
|
1581
|
+
detailsJson: text("details_json").notNull().default("{}"),
|
|
1582
|
+
createdAt: integer("created_at").notNull()
|
|
1583
|
+
}, (table) => [index("idx_audit_created").on(table.createdAt), index("idx_audit_action").on(table.action, table.createdAt)]);
|
|
1584
|
+
const fileVersions = sqliteTable("file_versions", {
|
|
1585
|
+
scopeKey: text("scope_key").notNull(),
|
|
1586
|
+
path: text("path").notNull(),
|
|
1587
|
+
realPath: text("real_path").notNull(),
|
|
1588
|
+
versionHash: text("version_hash").notNull(),
|
|
1589
|
+
size: integer("size").notNull(),
|
|
1590
|
+
mtime: integer("mtime").notNull(),
|
|
1591
|
+
updatedAt: integer("updated_at").notNull()
|
|
1592
|
+
}, (table) => [uniqueIndex("file_versions_scope_path").on(table.scopeKey, table.path)]);
|
|
1593
|
+
const resourceStreams = sqliteTable("resource_streams", {
|
|
1594
|
+
streamId: text("stream_id").primaryKey(),
|
|
1595
|
+
lastSeq: integer("last_seq").notNull().default(0)
|
|
1596
|
+
});
|
|
1597
|
+
const resourceEvents = sqliteTable("resource_events", {
|
|
1598
|
+
id: text("id").primaryKey(),
|
|
1599
|
+
streamId: text("stream_id").notNull().references(() => resourceStreams.streamId),
|
|
1600
|
+
seq: integer("seq").notNull(),
|
|
1601
|
+
type: text("type").notNull(),
|
|
1602
|
+
payloadJson: text("payload_json").notNull(),
|
|
1603
|
+
createdAt: integer("created_at").notNull()
|
|
1604
|
+
}, (table) => [uniqueIndex("resource_events_stream_seq").on(table.streamId, table.seq)]);
|
|
1605
|
+
const resourceOperations = sqliteTable("resource_operations", {
|
|
1606
|
+
id: text("id").primaryKey(),
|
|
1607
|
+
scopeKey: text("scope_key").notNull(),
|
|
1608
|
+
rootRealPath: text("root_real_path").notNull(),
|
|
1609
|
+
kind: text("kind").notNull(),
|
|
1610
|
+
status: text("status").$type().notNull(),
|
|
1611
|
+
paramsHash: text("params_hash").notNull(),
|
|
1612
|
+
idempotencyKey: text("idempotency_key").notNull(),
|
|
1613
|
+
clientSessionId: text("client_session_id").notNull(),
|
|
1614
|
+
path: text("path").notNull(),
|
|
1615
|
+
expectedVersion: text("expected_version").notNull(),
|
|
1616
|
+
targetVersion: text("target_version").notNull(),
|
|
1617
|
+
lockId: text("lock_id").notNull(),
|
|
1618
|
+
fencingToken: integer("fencing_token").notNull(),
|
|
1619
|
+
resultJson: text("result_json"),
|
|
1620
|
+
errorCode: text("error_code"),
|
|
1621
|
+
createdAt: integer("created_at").notNull(),
|
|
1622
|
+
updatedAt: integer("updated_at").notNull()
|
|
1623
|
+
}, (table) => [uniqueIndex("resource_operations_client_kind_key").on(table.clientSessionId, table.kind, table.idempotencyKey), index("resource_operations_status").on(table.status)]);
|
|
1624
|
+
const commandExecutions = sqliteTable("command_executions", {
|
|
1625
|
+
id: text("id").primaryKey(),
|
|
1626
|
+
operationId: text("operation_id").notNull().references(() => resourceOperations.id),
|
|
1627
|
+
projectId: text("project_id"),
|
|
1628
|
+
workspaceSessionId: text("workspace_session_id"),
|
|
1629
|
+
sessionId: text("session_id").notNull(),
|
|
1630
|
+
turnId: text("turn_id").notNull(),
|
|
1631
|
+
toolCallId: text("tool_call_id").notNull(),
|
|
1632
|
+
policySnapshotId: text("policy_snapshot_id").notNull(),
|
|
1633
|
+
paramsHash: text("params_hash").notNull(),
|
|
1634
|
+
status: text("status").$type().notNull(),
|
|
1635
|
+
exitCode: integer("exit_code"),
|
|
1636
|
+
reasonCode: text("reason_code"),
|
|
1637
|
+
truncated: integer("truncated", { mode: "boolean" }).notNull().default(false),
|
|
1638
|
+
processIdentityJson: text("process_identity_json"),
|
|
1639
|
+
outputCursor: integer("output_cursor").notNull().default(0),
|
|
1640
|
+
createdAt: integer("created_at").notNull(),
|
|
1641
|
+
startedAt: integer("started_at"),
|
|
1642
|
+
endedAt: integer("ended_at")
|
|
1643
|
+
}, (table) => [uniqueIndex("command_executions_operation").on(table.operationId), index("command_executions_status").on(table.status)]);
|
|
1644
|
+
const terminals = sqliteTable("terminals", {
|
|
1645
|
+
id: text("id").primaryKey(),
|
|
1646
|
+
operationId: text("operation_id").notNull().references(() => resourceOperations.id),
|
|
1647
|
+
projectId: text("project_id"),
|
|
1648
|
+
workspaceSessionId: text("workspace_session_id"),
|
|
1649
|
+
sourceSessionId: text("source_session_id"),
|
|
1650
|
+
cwd: text("cwd").notNull(),
|
|
1651
|
+
shell: text("shell").notNull(),
|
|
1652
|
+
mode: text("mode").$type().notNull(),
|
|
1653
|
+
role: text("role"),
|
|
1654
|
+
title: text("title"),
|
|
1655
|
+
launchParamsJson: text("launch_params_json"),
|
|
1656
|
+
launchParamsHash: text("launch_params_hash"),
|
|
1657
|
+
createdByTurnId: text("created_by_turn_id"),
|
|
1658
|
+
status: text("status").$type().notNull(),
|
|
1659
|
+
processIdentityJson: text("process_identity_json"),
|
|
1660
|
+
reasonCode: text("reason_code"),
|
|
1661
|
+
outputCursor: integer("output_cursor").notNull().default(0),
|
|
1662
|
+
createdAt: integer("created_at").notNull(),
|
|
1663
|
+
startedAt: integer("started_at"),
|
|
1664
|
+
endedAt: integer("ended_at"),
|
|
1665
|
+
exitCode: integer("exit_code")
|
|
1666
|
+
}, (table) => [
|
|
1667
|
+
uniqueIndex("terminals_operation").on(table.operationId),
|
|
1668
|
+
index("terminals_status").on(table.status),
|
|
1669
|
+
uniqueIndex("terminals_active_role").on(table.projectId, table.role).where(sql`${table.mode} = 'dev' AND ${table.status} IN ('CREATED', 'RUNNING', 'STOPPING')`)
|
|
1670
|
+
]);
|
|
1671
|
+
const services = sqliteTable("services", {
|
|
1672
|
+
id: text("id").primaryKey(),
|
|
1673
|
+
operationId: text("operation_id").notNull().references(() => resourceOperations.id),
|
|
1674
|
+
projectId: text("project_id").notNull().references(() => projects.id),
|
|
1675
|
+
sourceSessionId: text("source_session_id"),
|
|
1676
|
+
terminalId: text("terminal_id").notNull().references(() => terminals.id),
|
|
1677
|
+
name: text("name").notNull(),
|
|
1678
|
+
kind: text("kind").$type().notNull(),
|
|
1679
|
+
status: text("status").$type().notNull(),
|
|
1680
|
+
terminalExecutionId: text("terminal_execution_id").notNull(),
|
|
1681
|
+
endpointGeneration: integer("endpoint_generation").notNull(),
|
|
1682
|
+
endpointHost: text("endpoint_host").notNull(),
|
|
1683
|
+
endpointPort: integer("endpoint_port").notNull(),
|
|
1684
|
+
endpointProtocol: text("endpoint_protocol").$type().notNull(),
|
|
1685
|
+
identityJson: text("identity_json").notNull(),
|
|
1686
|
+
reasonCode: text("reason_code"),
|
|
1687
|
+
createdAt: integer("created_at").notNull(),
|
|
1688
|
+
updatedAt: integer("updated_at").notNull(),
|
|
1689
|
+
endedAt: integer("ended_at")
|
|
1690
|
+
}, (table) => [
|
|
1691
|
+
uniqueIndex("services_operation").on(table.operationId),
|
|
1692
|
+
index("services_project_status").on(table.projectId, table.status),
|
|
1693
|
+
index("services_terminal").on(table.terminalId),
|
|
1694
|
+
uniqueIndex("services_active_endpoint").on(table.terminalId, table.endpointHost, table.endpointPort).where(sql`${table.status} IN ('REGISTERING', 'STARTING', 'RUNNING')`),
|
|
1695
|
+
check("services_status", sql`${table.status} IN ('REGISTERING', 'STARTING', 'RUNNING', 'UNKNOWN', 'UNREGISTERED')`),
|
|
1696
|
+
check("services_host", sql`${table.endpointHost} IN ('127.0.0.1', '::1')`),
|
|
1697
|
+
check("services_port", sql`${table.endpointPort} BETWEEN 1 AND 65535`),
|
|
1698
|
+
check("services_protocol", sql`${table.endpointProtocol} = 'http'`)
|
|
1699
|
+
]);
|
|
1700
|
+
const resourceActions = sqliteTable("resource_actions", {
|
|
1701
|
+
id: text("id").primaryKey(),
|
|
1702
|
+
operationId: text("operation_id").notNull().references(() => resourceOperations.id),
|
|
1703
|
+
projectId: text("project_id").notNull().references(() => projects.id),
|
|
1704
|
+
kind: text("kind").notNull(),
|
|
1705
|
+
risk: text("risk").$type().notNull(),
|
|
1706
|
+
status: text("status").$type().notNull(),
|
|
1707
|
+
paramsJson: text("params_json").notNull(),
|
|
1708
|
+
paramsHash: text("params_hash").notNull(),
|
|
1709
|
+
snapshotHash: text("snapshot_hash").notNull(),
|
|
1710
|
+
requestedBy: text("requested_by").notNull(),
|
|
1711
|
+
decidedBy: text("decided_by"),
|
|
1712
|
+
expiresAt: integer("expires_at").notNull(),
|
|
1713
|
+
decidedAt: integer("decided_at"),
|
|
1714
|
+
startedAt: integer("started_at"),
|
|
1715
|
+
endedAt: integer("ended_at"),
|
|
1716
|
+
resultJson: text("result_json"),
|
|
1717
|
+
createdAt: integer("created_at").notNull()
|
|
1718
|
+
}, (table) => [uniqueIndex("resource_actions_operation").on(table.operationId), index("resource_actions_project_status").on(table.projectId, table.status)]);
|
|
1719
|
+
const terminalLeases = sqliteTable("terminal_leases", {
|
|
1720
|
+
terminalId: text("terminal_id").primaryKey().references(() => terminals.id),
|
|
1721
|
+
generation: integer("generation").notNull().default(0),
|
|
1722
|
+
ownerType: text("owner_type").$type(),
|
|
1723
|
+
ownerClientSessionId: text("owner_client_session_id"),
|
|
1724
|
+
ownerConnectionId: text("owner_connection_id"),
|
|
1725
|
+
ownerSessionId: text("owner_session_id"),
|
|
1726
|
+
ownerTurnId: text("owner_turn_id"),
|
|
1727
|
+
ownerExecutionId: text("owner_execution_id"),
|
|
1728
|
+
expiresAt: integer("expires_at").notNull().default(0),
|
|
1729
|
+
heartbeatAt: integer("heartbeat_at").notNull().default(0),
|
|
1730
|
+
inputSequence: integer("input_sequence").notNull().default(0)
|
|
1731
|
+
});
|
|
1732
|
+
const deploymentTargets = sqliteTable("deployment_targets", {
|
|
1733
|
+
id: text("id").primaryKey(),
|
|
1734
|
+
projectId: text("project_id").notNull().references(() => projects.id),
|
|
1735
|
+
name: text("name").notNull(),
|
|
1736
|
+
currentArtifactId: text("current_artifact_id"),
|
|
1737
|
+
currentVersion: text("current_version"),
|
|
1738
|
+
createdAt: integer("created_at").notNull(),
|
|
1739
|
+
updatedAt: integer("updated_at").notNull()
|
|
1740
|
+
}, (table) => [
|
|
1741
|
+
uniqueIndex("deployment_targets_project_name").on(table.projectId, table.name),
|
|
1742
|
+
index("deployment_targets_project_updated").on(table.projectId, table.updatedAt),
|
|
1743
|
+
check("deployment_targets_current", sql`(${table.currentArtifactId} IS NULL) = (${table.currentVersion} IS NULL)`)
|
|
1744
|
+
]);
|
|
1745
|
+
const deploymentBuilds = sqliteTable("deployment_builds", {
|
|
1746
|
+
id: text("id").primaryKey(),
|
|
1747
|
+
targetId: text("target_id").notNull().references(() => deploymentTargets.id),
|
|
1748
|
+
projectId: text("project_id").notNull().references(() => projects.id),
|
|
1749
|
+
requestKey: text("request_key").notNull(),
|
|
1750
|
+
requestedBy: text("requested_by").notNull(),
|
|
1751
|
+
status: text("status").$type().notNull(),
|
|
1752
|
+
specJson: text("spec_json").notNull(),
|
|
1753
|
+
specHash: text("spec_hash").notNull(),
|
|
1754
|
+
reasonCode: text("reason_code"),
|
|
1755
|
+
logRef: text("log_ref").notNull(),
|
|
1756
|
+
startedAt: integer("started_at"),
|
|
1757
|
+
endedAt: integer("ended_at"),
|
|
1758
|
+
createdAt: integer("created_at").notNull()
|
|
1759
|
+
}, (table) => [
|
|
1760
|
+
uniqueIndex("deployment_builds_request").on(table.requestKey),
|
|
1761
|
+
index("deployment_builds_target_created").on(table.targetId, table.createdAt),
|
|
1762
|
+
index("deployment_builds_status").on(table.status),
|
|
1763
|
+
check("deployment_builds_status", sql`${table.status} IN ('RUNNING', 'SUCCEEDED', 'FAILED', 'CANCELLED')`)
|
|
1764
|
+
]);
|
|
1765
|
+
const deploymentArtifacts = sqliteTable("deployment_artifacts", {
|
|
1766
|
+
id: text("id").primaryKey(),
|
|
1767
|
+
buildId: text("build_id").notNull().references(() => deploymentBuilds.id),
|
|
1768
|
+
targetId: text("target_id").notNull().references(() => deploymentTargets.id),
|
|
1769
|
+
projectId: text("project_id").notNull().references(() => projects.id),
|
|
1770
|
+
version: text("version").notNull(),
|
|
1771
|
+
artifactHash: text("artifact_hash").notNull(),
|
|
1772
|
+
artifactPath: text("artifact_path").notNull(),
|
|
1773
|
+
sizeBytes: integer("size_bytes").notNull(),
|
|
1774
|
+
fileCount: integer("file_count").notNull(),
|
|
1775
|
+
specJson: text("spec_json").notNull(),
|
|
1776
|
+
specHash: text("spec_hash").notNull(),
|
|
1777
|
+
sourceJson: text("source_json").notNull(),
|
|
1778
|
+
createdAt: integer("created_at").notNull()
|
|
1779
|
+
}, (table) => [
|
|
1780
|
+
uniqueIndex("deployment_artifacts_build").on(table.buildId),
|
|
1781
|
+
uniqueIndex("deployment_artifacts_target_version").on(table.targetId, table.version),
|
|
1782
|
+
index("deployment_artifacts_target_created").on(table.targetId, table.createdAt),
|
|
1783
|
+
check("deployment_artifacts_hash", sql`length(${table.artifactHash}) = 64`),
|
|
1784
|
+
check("deployment_artifacts_size", sql`${table.sizeBytes} >= 0`),
|
|
1785
|
+
check("deployment_artifacts_count", sql`${table.fileCount} >= 0`)
|
|
1786
|
+
]);
|
|
1787
|
+
const deploymentPlans = sqliteTable("deployment_plans", {
|
|
1788
|
+
id: text("id").primaryKey(),
|
|
1789
|
+
targetId: text("target_id").notNull().references(() => deploymentTargets.id),
|
|
1790
|
+
projectId: text("project_id").notNull().references(() => projects.id),
|
|
1791
|
+
artifactId: text("artifact_id").notNull().references(() => deploymentArtifacts.id),
|
|
1792
|
+
previousArtifactId: text("previous_artifact_id").references(() => deploymentArtifacts.id),
|
|
1793
|
+
previousVersion: text("previous_version"),
|
|
1794
|
+
version: text("version").notNull(),
|
|
1795
|
+
planJson: text("plan_json").notNull(),
|
|
1796
|
+
planHash: text("plan_hash").notNull(),
|
|
1797
|
+
status: text("status").$type().notNull(),
|
|
1798
|
+
expiresAt: integer("expires_at").notNull(),
|
|
1799
|
+
requestKey: text("request_key").notNull(),
|
|
1800
|
+
requestedBy: text("requested_by").notNull(),
|
|
1801
|
+
createdAt: integer("created_at").notNull()
|
|
1802
|
+
}, (table) => [
|
|
1803
|
+
uniqueIndex("deployment_plans_request").on(table.requestKey),
|
|
1804
|
+
index("deployment_plans_target_created").on(table.targetId, table.createdAt),
|
|
1805
|
+
index("deployment_plans_status_expires").on(table.status, table.expiresAt),
|
|
1806
|
+
check("deployment_plans_status", sql`${table.status} IN ('READY', 'WAITING_APPROVAL', 'AUTHORIZED', 'APPLYING', 'HEALTH_CHECK', 'SUCCEEDED', 'FAILED', 'CANCELLED', 'EXPIRED', 'INVALIDATED', 'UNKNOWN')`),
|
|
1807
|
+
check("deployment_plans_hash", sql`length(${table.planHash}) = 64`),
|
|
1808
|
+
check("deployment_plans_previous", sql`(${table.previousArtifactId} IS NULL) = (${table.previousVersion} IS NULL)`)
|
|
1809
|
+
]);
|
|
1810
|
+
const deploymentAuthorizations = sqliteTable("deployment_authorizations", {
|
|
1811
|
+
id: text("id").primaryKey(),
|
|
1812
|
+
planId: text("plan_id").notNull().references(() => deploymentPlans.id),
|
|
1813
|
+
targetId: text("target_id").notNull().references(() => deploymentTargets.id),
|
|
1814
|
+
projectId: text("project_id").notNull().references(() => projects.id),
|
|
1815
|
+
action: text("action").$type().notNull(),
|
|
1816
|
+
actorType: text("actor_type").$type().notNull(),
|
|
1817
|
+
actorId: text("actor_id").notNull(),
|
|
1818
|
+
clientSessionId: text("client_session_id"),
|
|
1819
|
+
sessionId: text("session_id"),
|
|
1820
|
+
turnId: text("turn_id"),
|
|
1821
|
+
policy: text("policy").$type().notNull(),
|
|
1822
|
+
policySnapshotId: text("policy_snapshot_id").notNull(),
|
|
1823
|
+
status: text("status").$type().notNull(),
|
|
1824
|
+
planHash: text("plan_hash").notNull(),
|
|
1825
|
+
artifactHash: text("artifact_hash").notNull(),
|
|
1826
|
+
scopeJson: text("scope_json").notNull(),
|
|
1827
|
+
scopeHash: text("scope_hash").notNull(),
|
|
1828
|
+
approvalId: text("approval_id"),
|
|
1829
|
+
requestKey: text("request_key").notNull(),
|
|
1830
|
+
expiresAt: integer("expires_at").notNull(),
|
|
1831
|
+
decidedAt: integer("decided_at"),
|
|
1832
|
+
consumedAt: integer("consumed_at"),
|
|
1833
|
+
consumeKey: text("consume_key"),
|
|
1834
|
+
reasonCode: text("reason_code"),
|
|
1835
|
+
createdAt: integer("created_at").notNull()
|
|
1836
|
+
}, (table) => [
|
|
1837
|
+
uniqueIndex("deployment_authorizations_request").on(table.requestKey),
|
|
1838
|
+
index("deployment_authorizations_plan_status").on(table.planId, table.status),
|
|
1839
|
+
index("deployment_authorizations_target_status").on(table.targetId, table.status),
|
|
1840
|
+
index("deployment_authorizations_status_expires").on(table.status, table.expiresAt),
|
|
1841
|
+
check("deployment_authorizations_action", sql`${table.action} = 'apply'`),
|
|
1842
|
+
check("deployment_authorizations_actor", sql`${table.actorType} IN ('human', 'agent')`),
|
|
1843
|
+
check("deployment_authorizations_policy", sql`${table.policy} IN ('standard', 'strict', 'readonly', 'autonomous')`),
|
|
1844
|
+
check("deployment_authorizations_status", sql`${table.status} IN ('PENDING', 'AUTHORIZED', 'DENIED', 'EXPIRED', 'REVOKED', 'CONSUMED', 'INVALIDATED')`),
|
|
1845
|
+
check("deployment_authorizations_plan_hash", sql`length(${table.planHash}) = 64`),
|
|
1846
|
+
check("deployment_authorizations_artifact_hash", sql`length(${table.artifactHash}) = 64`),
|
|
1847
|
+
check("deployment_authorizations_scope_hash", sql`length(${table.scopeHash}) = 64`)
|
|
1848
|
+
]);
|
|
1849
|
+
const deploymentApprovals = sqliteTable("deployment_approvals", {
|
|
1850
|
+
id: text("id").primaryKey(),
|
|
1851
|
+
authorizationId: text("authorization_id").notNull().references(() => deploymentAuthorizations.id),
|
|
1852
|
+
planId: text("plan_id").notNull().references(() => deploymentPlans.id),
|
|
1853
|
+
targetId: text("target_id").notNull().references(() => deploymentTargets.id),
|
|
1854
|
+
projectId: text("project_id").notNull().references(() => projects.id),
|
|
1855
|
+
status: text("status").$type().notNull(),
|
|
1856
|
+
planHash: text("plan_hash").notNull(),
|
|
1857
|
+
artifactHash: text("artifact_hash").notNull(),
|
|
1858
|
+
requestedBy: text("requested_by").notNull(),
|
|
1859
|
+
decidedBy: text("decided_by"),
|
|
1860
|
+
expiresAt: integer("expires_at").notNull(),
|
|
1861
|
+
decidedAt: integer("decided_at"),
|
|
1862
|
+
createdAt: integer("created_at").notNull()
|
|
1863
|
+
}, (table) => [
|
|
1864
|
+
uniqueIndex("deployment_approvals_authorization").on(table.authorizationId),
|
|
1865
|
+
index("deployment_approvals_status_expires").on(table.status, table.expiresAt),
|
|
1866
|
+
check("deployment_approvals_status", sql`${table.status} IN ('PENDING', 'APPROVED', 'DENIED', 'EXPIRED', 'REVOKED')`),
|
|
1867
|
+
check("deployment_approvals_plan_hash", sql`length(${table.planHash}) = 64`),
|
|
1868
|
+
check("deployment_approvals_artifact_hash", sql`length(${table.artifactHash}) = 64`)
|
|
1869
|
+
]);
|
|
1870
|
+
const serviceOpsServices = sqliteTable("service_ops_services", {
|
|
1871
|
+
targetId: text("target_id").primaryKey().references(() => deploymentTargets.id),
|
|
1872
|
+
projectId: text("project_id").notNull().references(() => projects.id),
|
|
1873
|
+
name: text("name").notNull(),
|
|
1874
|
+
namespace: text("namespace").notNull(),
|
|
1875
|
+
pm2Name: text("pm2_name").notNull().unique(),
|
|
1876
|
+
desiredState: text("desired_state").$type().notNull(),
|
|
1877
|
+
observedState: text("observed_state").$type().notNull(),
|
|
1878
|
+
currentArtifactId: text("current_artifact_id").references(() => deploymentArtifacts.id),
|
|
1879
|
+
currentVersion: text("current_version"),
|
|
1880
|
+
configJson: text("config_json").notNull(),
|
|
1881
|
+
pid: integer("pid"),
|
|
1882
|
+
lastHealthAt: integer("last_health_at"),
|
|
1883
|
+
reasonCode: text("reason_code"),
|
|
1884
|
+
createdAt: integer("created_at").notNull(),
|
|
1885
|
+
updatedAt: integer("updated_at").notNull()
|
|
1886
|
+
}, (table) => [
|
|
1887
|
+
index("service_ops_services_project").on(table.projectId, table.updatedAt),
|
|
1888
|
+
check("service_ops_services_desired", sql`${table.desiredState} IN ('running', 'stopped')`),
|
|
1889
|
+
check("service_ops_services_observed", sql`${table.observedState} IN ('stopped', 'starting', 'running', 'unhealthy', 'stopping', 'failed', 'unknown')`)
|
|
1890
|
+
]);
|
|
1891
|
+
const serviceOpsDeployments = sqliteTable("service_ops_deployments", {
|
|
1892
|
+
id: text("id").primaryKey(),
|
|
1893
|
+
targetId: text("target_id").notNull().references(() => deploymentTargets.id),
|
|
1894
|
+
projectId: text("project_id").notNull().references(() => projects.id),
|
|
1895
|
+
planId: text("plan_id").notNull().references(() => deploymentPlans.id),
|
|
1896
|
+
authorizationId: text("authorization_id").notNull().references(() => deploymentAuthorizations.id),
|
|
1897
|
+
artifactId: text("artifact_id").notNull().references(() => deploymentArtifacts.id),
|
|
1898
|
+
previousArtifactId: text("previous_artifact_id").references(() => deploymentArtifacts.id),
|
|
1899
|
+
previousVersion: text("previous_version"),
|
|
1900
|
+
version: text("version").notNull(),
|
|
1901
|
+
status: text("status").$type().notNull(),
|
|
1902
|
+
planHash: text("plan_hash").notNull(),
|
|
1903
|
+
artifactHash: text("artifact_hash").notNull(),
|
|
1904
|
+
actorType: text("actor_type").$type().notNull(),
|
|
1905
|
+
actorId: text("actor_id").notNull(),
|
|
1906
|
+
policy: text("policy").$type().notNull(),
|
|
1907
|
+
policySnapshotId: text("policy_snapshot_id").notNull(),
|
|
1908
|
+
reasonCode: text("reason_code"),
|
|
1909
|
+
healthJson: text("health_json"),
|
|
1910
|
+
resultJson: text("result_json"),
|
|
1911
|
+
startedAt: integer("started_at").notNull(),
|
|
1912
|
+
endedAt: integer("ended_at"),
|
|
1913
|
+
createdAt: integer("created_at").notNull()
|
|
1914
|
+
}, (table) => [
|
|
1915
|
+
uniqueIndex("service_ops_deployments_plan").on(table.planId),
|
|
1916
|
+
uniqueIndex("service_ops_deployments_authorization").on(table.authorizationId),
|
|
1917
|
+
index("service_ops_deployments_target_created").on(table.targetId, table.createdAt),
|
|
1918
|
+
index("service_ops_deployments_status").on(table.status),
|
|
1919
|
+
check("service_ops_deployments_status", sql`${table.status} IN ('APPLYING', 'HEALTH_CHECK', 'SUCCEEDED', 'FAILED', 'UNKNOWN')`),
|
|
1920
|
+
check("service_ops_deployments_plan_hash", sql`length(${table.planHash}) = 64`),
|
|
1921
|
+
check("service_ops_deployments_artifact_hash", sql`length(${table.artifactHash}) = 64`),
|
|
1922
|
+
check("service_ops_deployments_previous", sql`(${table.previousArtifactId} IS NULL) = (${table.previousVersion} IS NULL)`)
|
|
1923
|
+
]);
|
|
1924
|
+
const serviceActionAuthorizations = sqliteTable("service_action_authorizations", {
|
|
1925
|
+
id: text("id").primaryKey(),
|
|
1926
|
+
targetId: text("target_id").notNull().references(() => deploymentTargets.id),
|
|
1927
|
+
projectId: text("project_id").notNull().references(() => projects.id),
|
|
1928
|
+
action: text("action").$type().notNull(),
|
|
1929
|
+
actorType: text("actor_type").$type().notNull(),
|
|
1930
|
+
actorId: text("actor_id").notNull(),
|
|
1931
|
+
clientSessionId: text("client_session_id"),
|
|
1932
|
+
sessionId: text("session_id"),
|
|
1933
|
+
turnId: text("turn_id"),
|
|
1934
|
+
policy: text("policy").$type().notNull(),
|
|
1935
|
+
policySnapshotId: text("policy_snapshot_id").notNull(),
|
|
1936
|
+
status: text("status").$type().notNull(),
|
|
1937
|
+
artifactHash: text("artifact_hash").notNull(),
|
|
1938
|
+
version: text("version").notNull(),
|
|
1939
|
+
scopeJson: text("scope_json").notNull(),
|
|
1940
|
+
scopeHash: text("scope_hash").notNull(),
|
|
1941
|
+
requestKey: text("request_key").notNull(),
|
|
1942
|
+
expiresAt: integer("expires_at").notNull(),
|
|
1943
|
+
decidedAt: integer("decided_at"),
|
|
1944
|
+
decidedBy: text("decided_by"),
|
|
1945
|
+
consumedAt: integer("consumed_at"),
|
|
1946
|
+
consumeKey: text("consume_key"),
|
|
1947
|
+
reasonCode: text("reason_code"),
|
|
1948
|
+
createdAt: integer("created_at").notNull()
|
|
1949
|
+
}, (table) => [
|
|
1950
|
+
uniqueIndex("service_action_authorizations_request").on(table.requestKey),
|
|
1951
|
+
index("service_action_authorizations_target_status").on(table.targetId, table.status),
|
|
1952
|
+
index("service_action_authorizations_status_expires").on(table.status, table.expiresAt),
|
|
1953
|
+
check("service_action_authorizations_action", sql`${table.action} IN ('start', 'stop', 'restart', 'recover')`),
|
|
1954
|
+
check("service_action_authorizations_status", sql`${table.status} IN ('PENDING', 'AUTHORIZED', 'DENIED', 'EXPIRED', 'REVOKED', 'CONSUMED')`),
|
|
1955
|
+
check("service_action_authorizations_artifact_hash", sql`length(${table.artifactHash}) = 64`),
|
|
1956
|
+
check("service_action_authorizations_scope_hash", sql`length(${table.scopeHash}) = 64`)
|
|
1957
|
+
]);
|
|
1958
|
+
const scheduledJobs = sqliteTable("scheduled_jobs", {
|
|
1959
|
+
id: text("id").primaryKey(),
|
|
1960
|
+
name: text("name").notNull(),
|
|
1961
|
+
projectId: text("project_id").references(() => projects.id, { onDelete: "cascade" }),
|
|
1962
|
+
kind: text("kind").$type().notNull(),
|
|
1963
|
+
scheduleType: text("schedule_type").$type().notNull(),
|
|
1964
|
+
cronExpression: text("cron_expression"),
|
|
1965
|
+
intervalSeconds: integer("interval_seconds"),
|
|
1966
|
+
timezone: text("timezone").notNull(),
|
|
1967
|
+
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
|
1968
|
+
overlapPolicy: text("overlap_policy").notNull().default("skip"),
|
|
1969
|
+
missedPolicy: text("missed_policy").notNull().default("skip"),
|
|
1970
|
+
timeoutSeconds: integer("timeout_seconds").notNull().default(600),
|
|
1971
|
+
scriptSource: text("script_source"),
|
|
1972
|
+
agentPrompt: text("agent_prompt"),
|
|
1973
|
+
agentModel: text("agent_model"),
|
|
1974
|
+
agentCredentialProfileId: text("agent_credential_profile_id").references(() => credentialProfiles.id, { onDelete: "set null" }),
|
|
1975
|
+
agentThinking: text("agent_thinking"),
|
|
1976
|
+
agentApprovalPolicy: text("agent_approval_policy").$type(),
|
|
1977
|
+
sessionId: text("session_id").references(() => sessions.id, { onDelete: "set null" }),
|
|
1978
|
+
nextRunAt: integer("next_run_at"),
|
|
1979
|
+
lastRunAt: integer("last_run_at"),
|
|
1980
|
+
lastStatus: text("last_status").$type(),
|
|
1981
|
+
createdAt: integer("created_at").notNull(),
|
|
1982
|
+
updatedAt: integer("updated_at").notNull(),
|
|
1983
|
+
archivedAt: integer("archived_at")
|
|
1984
|
+
}, (table) => [index("idx_scheduled_jobs_due").on(table.enabled, table.archivedAt, table.nextRunAt), index("idx_scheduled_jobs_project").on(table.projectId, table.updatedAt)]);
|
|
1985
|
+
const scheduledJobRuns = sqliteTable("scheduled_job_runs", {
|
|
1986
|
+
id: text("id").primaryKey(),
|
|
1987
|
+
jobId: text("job_id").notNull().references(() => scheduledJobs.id, { onDelete: "cascade" }),
|
|
1988
|
+
trigger: text("trigger").$type().notNull(),
|
|
1989
|
+
status: text("status").$type().notNull(),
|
|
1990
|
+
scheduledFor: integer("scheduled_for").notNull(),
|
|
1991
|
+
startedAt: integer("started_at"),
|
|
1992
|
+
endedAt: integer("ended_at"),
|
|
1993
|
+
durationMs: integer("duration_ms"),
|
|
1994
|
+
sessionId: text("session_id").references(() => sessions.id, { onDelete: "set null" }),
|
|
1995
|
+
turnId: text("turn_id").references(() => turns.id, { onDelete: "set null" }),
|
|
1996
|
+
exitCode: integer("exit_code"),
|
|
1997
|
+
output: text("output"),
|
|
1998
|
+
errorCode: text("error_code"),
|
|
1999
|
+
errorMessage: text("error_message"),
|
|
2000
|
+
createdAt: integer("created_at").notNull()
|
|
2001
|
+
}, (table) => [index("idx_scheduled_job_runs_job").on(table.jobId, table.createdAt), index("idx_scheduled_job_runs_status").on(table.status, table.createdAt)]);
|
|
2002
|
+
// src/db/repositories/meta.ts
|
|
2003
|
+
function getMeta(db, key) {
|
|
2004
|
+
return db.select().from(appMeta).where(eq(appMeta.key, key)).get()?.value ?? null;
|
|
2005
|
+
}
|
|
2006
|
+
function setMeta(db, key, value, now = Date.now()) {
|
|
2007
|
+
db.insert(appMeta).values({
|
|
2008
|
+
key,
|
|
2009
|
+
value,
|
|
2010
|
+
updatedAt: now
|
|
2011
|
+
}).onConflictDoUpdate({
|
|
2012
|
+
target: appMeta.key,
|
|
2013
|
+
set: {
|
|
2014
|
+
value,
|
|
2015
|
+
updatedAt: now
|
|
2016
|
+
}
|
|
2017
|
+
}).run();
|
|
2018
|
+
}
|
|
2019
|
+
function ensureInstanceId(db, now = Date.now()) {
|
|
2020
|
+
const existing = getMeta(db, "instance_id");
|
|
2021
|
+
if (existing !== null) return existing;
|
|
2022
|
+
const instanceId = newId("inst");
|
|
2023
|
+
setMeta(db, "instance_id", instanceId, now);
|
|
2024
|
+
return instanceId;
|
|
2025
|
+
}
|
|
2026
|
+
function deleteMeta(db, key) {
|
|
2027
|
+
db.delete(appMeta).where(eq(appMeta.key, key)).run();
|
|
2028
|
+
}
|
|
2029
|
+
// src/version.ts
|
|
2030
|
+
function readPackageMetadata() {
|
|
2031
|
+
try {
|
|
2032
|
+
return JSON.parse(readFileSync(new URL("../../../package.json", import.meta.url), "utf8")) ?? {};
|
|
2033
|
+
} catch {
|
|
2034
|
+
return {};
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
const metadata = readPackageMetadata();
|
|
2038
|
+
const SERVER_VERSION = typeof metadata.version === "string" ? metadata.version : "0.0.0";
|
|
2039
|
+
const SUPPORTED_NODE_RANGE = typeof metadata.engines?.node === "string" ? metadata.engines.node : "^22.22.0 || >=24";
|
|
2040
|
+
// src/db/migrate.ts
|
|
2041
|
+
const SERVER_PACKAGE_NAME = "@larness/server";
|
|
2042
|
+
function findServerRoot(startDirectory) {
|
|
2043
|
+
let directory = startDirectory;
|
|
2044
|
+
for (;;) {
|
|
2045
|
+
const packageFile = path.join(directory, "package.json");
|
|
2046
|
+
if (existsSync(packageFile)) try {
|
|
2047
|
+
if (JSON.parse(readFileSync(packageFile, "utf8")).name === SERVER_PACKAGE_NAME) return directory;
|
|
2048
|
+
} catch {}
|
|
2049
|
+
const parent = path.dirname(directory);
|
|
2050
|
+
if (parent === directory) throw new Error(`cannot locate the ${SERVER_PACKAGE_NAME} package root`);
|
|
2051
|
+
directory = parent;
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
function migrationsDirectory() {
|
|
2055
|
+
const here = fileURLToPath(new URL(".", import.meta.url));
|
|
2056
|
+
return path.join(findServerRoot(here), "drizzle");
|
|
2057
|
+
}
|
|
2058
|
+
function runMigrations(db, folder = migrationsDirectory()) {
|
|
2059
|
+
if (!existsSync(path.join(folder, "meta", "_journal.json"))) throw new Error(`migration directory is invalid or empty: ${folder}`);
|
|
2060
|
+
migrate(db, { migrationsFolder: folder });
|
|
2061
|
+
}
|
|
2062
|
+
function appliedMigrationCount(sqlite) {
|
|
2063
|
+
if (sqlite.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = '__drizzle_migrations'").get() === void 0) return 0;
|
|
2064
|
+
return sqlite.prepare("SELECT count(*) AS count FROM __drizzle_migrations").get()?.count ?? 0;
|
|
2065
|
+
}
|
|
2066
|
+
function expectedMigrationCount(folder = migrationsDirectory()) {
|
|
2067
|
+
const journalFile = path.join(folder, "meta", "_journal.json");
|
|
2068
|
+
try {
|
|
2069
|
+
return JSON.parse(readFileSync(journalFile, "utf8")).entries?.length ?? 0;
|
|
2070
|
+
} catch {
|
|
2071
|
+
return 0;
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
function quickCheck(sqlite) {
|
|
2075
|
+
return sqlite.pragma("quick_check", { simple: true }) === "ok";
|
|
2076
|
+
}
|
|
2077
|
+
// src/bootstrap/config.ts
|
|
2078
|
+
var ConfigError = class extends Error {
|
|
2079
|
+
issues;
|
|
2080
|
+
constructor(message, issues = []) {
|
|
2081
|
+
super(message);
|
|
2082
|
+
this.name = "ConfigError";
|
|
2083
|
+
this.issues = issues;
|
|
2084
|
+
}
|
|
2085
|
+
};
|
|
2086
|
+
function configFilePath(dataDir) {
|
|
2087
|
+
return path.join(dataDir, "config.json");
|
|
2088
|
+
}
|
|
2089
|
+
function formatIssues(issues) {
|
|
2090
|
+
return issues.map((issue) => {
|
|
2091
|
+
return `${issue.path.length > 0 ? issue.path.map(String).join(".") : "(root)"}: ${issue.message}`;
|
|
2092
|
+
});
|
|
2093
|
+
}
|
|
2094
|
+
function applyEnvOverrides(config, env) {
|
|
2095
|
+
const host = env.LARNESS_HOST?.trim();
|
|
2096
|
+
if (host) config.server.host = host;
|
|
2097
|
+
const rawPort = env.LARNESS_PORT?.trim();
|
|
2098
|
+
if (rawPort) {
|
|
2099
|
+
const port = Number(rawPort);
|
|
2100
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new ConfigError(`LARNESS_PORT must be an integer between 1 and 65535, received "${rawPort}"`);
|
|
2101
|
+
config.server.port = port;
|
|
2102
|
+
}
|
|
2103
|
+
if (env.LARNESS_PUBLIC_URL !== void 0) {
|
|
2104
|
+
const value = env.LARNESS_PUBLIC_URL.trim();
|
|
2105
|
+
if (value === "") config.server.publicUrl = null;
|
|
2106
|
+
else {
|
|
2107
|
+
const parsed = OriginUrlSchema.safeParse(value);
|
|
2108
|
+
if (!parsed.success) throw new ConfigError(`LARNESS_PUBLIC_URL must be an http(s) origin, received "${value}"`);
|
|
2109
|
+
config.server.publicUrl = new URL(parsed.data).origin;
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
const rawLevel = env.LARNESS_LOG_LEVEL?.trim();
|
|
2113
|
+
if (rawLevel) {
|
|
2114
|
+
const parsed = LogLevelSchema.safeParse(rawLevel);
|
|
2115
|
+
if (!parsed.success) throw new ConfigError(`LARNESS_LOG_LEVEL must be one of: ${LogLevelSchema.options.join(", ")}`);
|
|
2116
|
+
config.logging.level = parsed.data;
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
async function loadConfig(options) {
|
|
2120
|
+
const env = options.env ?? process.env;
|
|
2121
|
+
const file = configFilePath(options.dataDir);
|
|
2122
|
+
let raw;
|
|
2123
|
+
let source = "defaults";
|
|
2124
|
+
let text = null;
|
|
2125
|
+
try {
|
|
2126
|
+
text = await readFile(file, "utf8");
|
|
2127
|
+
} catch (error) {
|
|
2128
|
+
if (error.code !== "ENOENT") throw new ConfigError(`cannot read config.json at ${file}: ${error.code}`);
|
|
2129
|
+
}
|
|
2130
|
+
if (text !== null) {
|
|
2131
|
+
source = "file";
|
|
2132
|
+
try {
|
|
2133
|
+
raw = JSON.parse(text);
|
|
2134
|
+
} catch {
|
|
2135
|
+
throw new ConfigError(`config.json is not valid JSON: ${file}`);
|
|
2136
|
+
}
|
|
2137
|
+
} else raw = structuredClone(DEFAULT_APP_CONFIG);
|
|
2138
|
+
return {
|
|
2139
|
+
...resolveConfig(raw, env),
|
|
2140
|
+
source,
|
|
2141
|
+
path: file
|
|
2142
|
+
};
|
|
2143
|
+
}
|
|
2144
|
+
function resolveConfig(raw, env) {
|
|
2145
|
+
const parsed = AppConfigSchema.safeParse(raw);
|
|
2146
|
+
if (!parsed.success) {
|
|
2147
|
+
const issues = formatIssues(parsed.error.issues);
|
|
2148
|
+
throw new ConfigError(`invalid config.json: ${issues.join("; ")}`, issues);
|
|
2149
|
+
}
|
|
2150
|
+
const config = parsed.data;
|
|
2151
|
+
applyEnvOverrides(config, env);
|
|
2152
|
+
const validated = AppConfigSchema.safeParse(config);
|
|
2153
|
+
if (!validated.success) {
|
|
2154
|
+
const issues = formatIssues(validated.error.issues);
|
|
2155
|
+
throw new ConfigError(`invalid config after environment overrides: ${issues.join("; ")}`, issues);
|
|
2156
|
+
}
|
|
2157
|
+
const webAuthn = deriveWebAuthn(validated.data.server, validated.data.webauthn.rpName);
|
|
2158
|
+
return {
|
|
2159
|
+
config: {
|
|
2160
|
+
...validated.data,
|
|
2161
|
+
webauthn: {
|
|
2162
|
+
rpId: webAuthn.rpId,
|
|
2163
|
+
rpName: webAuthn.rpName,
|
|
2164
|
+
origin: webAuthn.origin
|
|
2165
|
+
}
|
|
2166
|
+
},
|
|
2167
|
+
webAuthn
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
// src/init/recovery.ts
|
|
2171
|
+
const InitPendingSchema = z.strictObject({
|
|
2172
|
+
version: z.literal(1),
|
|
2173
|
+
config: AppConfigSchema
|
|
2174
|
+
});
|
|
2175
|
+
function recoverInitialization(db, dataDir) {
|
|
2176
|
+
const raw = getMeta(db, "init_pending");
|
|
2177
|
+
if (raw === null) return false;
|
|
2178
|
+
let pending;
|
|
2179
|
+
try {
|
|
2180
|
+
pending = InitPendingSchema.parse(JSON.parse(raw));
|
|
2181
|
+
} catch {
|
|
2182
|
+
throw new Error("invalid initialization recovery record; restore the database backup");
|
|
2183
|
+
}
|
|
2184
|
+
const target = configFilePath(dataDir);
|
|
2185
|
+
const temporary = `${target}.tmp-${randomUUID()}`;
|
|
2186
|
+
try {
|
|
2187
|
+
const fd = openSync(temporary, "wx", 384);
|
|
2188
|
+
try {
|
|
2189
|
+
writeFileSync(fd, `${JSON.stringify(pending.config, null, 2)}\n`);
|
|
2190
|
+
fsyncSync(fd);
|
|
2191
|
+
} finally {
|
|
2192
|
+
closeSync(fd);
|
|
2193
|
+
}
|
|
2194
|
+
renameSync(temporary, target);
|
|
2195
|
+
if (process.platform !== "win32") {
|
|
2196
|
+
const directory = openSync(dataDir, "r");
|
|
2197
|
+
try {
|
|
2198
|
+
fsyncSync(directory);
|
|
2199
|
+
} finally {
|
|
2200
|
+
closeSync(directory);
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
deleteMeta(db, "init_pending");
|
|
2204
|
+
return true;
|
|
2205
|
+
} finally {
|
|
2206
|
+
rmSync(temporary, { force: true });
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
// src/db/inspect.ts
|
|
2210
|
+
function hasAuthSettings(sqlite) {
|
|
2211
|
+
try {
|
|
2212
|
+
const row = sqlite.prepare("SELECT count(*) AS count FROM auth_settings").get();
|
|
2213
|
+
const pending = sqlite.prepare("SELECT value FROM app_meta WHERE key = ?").get("init_pending");
|
|
2214
|
+
return (row?.count ?? 0) > 0 && pending === void 0;
|
|
2215
|
+
} catch {
|
|
2216
|
+
return false;
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
function inspectDatabase(file) {
|
|
2220
|
+
if (!existsSync(file)) return null;
|
|
2221
|
+
let sqlite = null;
|
|
2222
|
+
try {
|
|
2223
|
+
sqlite = new BetterSqlite3(file, {
|
|
2224
|
+
readonly: true,
|
|
2225
|
+
fileMustExist: true
|
|
2226
|
+
});
|
|
2227
|
+
const schemaVersion = appliedMigrationCount(sqlite);
|
|
2228
|
+
const ok = quickCheck(sqlite);
|
|
2229
|
+
return {
|
|
2230
|
+
ok,
|
|
2231
|
+
schemaVersion,
|
|
2232
|
+
initialized: hasAuthSettings(sqlite),
|
|
2233
|
+
detail: ok ? "quick_check ok" : "quick_check failed"
|
|
2234
|
+
};
|
|
2235
|
+
} catch (error) {
|
|
2236
|
+
return {
|
|
2237
|
+
ok: false,
|
|
2238
|
+
schemaVersion: 0,
|
|
2239
|
+
initialized: false,
|
|
2240
|
+
detail: error instanceof Error ? error.message : String(error)
|
|
2241
|
+
};
|
|
2242
|
+
} finally {
|
|
2243
|
+
sqlite?.close();
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
function inspectPendingInitialization(file) {
|
|
2247
|
+
if (!existsSync(file)) return null;
|
|
2248
|
+
const sqlite = new BetterSqlite3(file, {
|
|
2249
|
+
readonly: true,
|
|
2250
|
+
fileMustExist: true
|
|
2251
|
+
});
|
|
2252
|
+
try {
|
|
2253
|
+
if (!sqlite.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'app_meta'").get()) return null;
|
|
2254
|
+
const row = sqlite.prepare("SELECT value FROM app_meta WHERE key = ?").get("init_pending");
|
|
2255
|
+
if (!row) return null;
|
|
2256
|
+
try {
|
|
2257
|
+
return InitPendingSchema.parse(JSON.parse(row.value)).config;
|
|
2258
|
+
} catch {
|
|
2259
|
+
throw new Error("invalid initialization recovery record; restore the database backup");
|
|
2260
|
+
}
|
|
2261
|
+
} finally {
|
|
2262
|
+
sqlite.close();
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
// src/platform/paths.ts
|
|
2266
|
+
const DATA_SUBDIRS = [
|
|
2267
|
+
"logs",
|
|
2268
|
+
"backups",
|
|
2269
|
+
"tmp",
|
|
2270
|
+
"sessions",
|
|
2271
|
+
"artifacts",
|
|
2272
|
+
"secrets",
|
|
2273
|
+
"ipc"
|
|
2274
|
+
];
|
|
2275
|
+
var DataDirError = class extends Error {
|
|
2276
|
+
constructor(message) {
|
|
2277
|
+
super(message);
|
|
2278
|
+
this.name = "DataDirError";
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
function defaultDataDir() {
|
|
2282
|
+
return envPaths("larness", { suffix: "" }).data;
|
|
2283
|
+
}
|
|
2284
|
+
function resolveDataDir(env = process.env) {
|
|
2285
|
+
const override = env.LARNESS_DATA_DIR?.trim();
|
|
2286
|
+
return override ? path.resolve(override) : defaultDataDir();
|
|
2287
|
+
}
|
|
2288
|
+
async function ensureDir(dir) {
|
|
2289
|
+
try {
|
|
2290
|
+
const info = await stat(dir);
|
|
2291
|
+
if (!info.isDirectory()) throw new DataDirError(`data directory path is not a directory: ${dir}`);
|
|
2292
|
+
let hardened = false;
|
|
2293
|
+
if (process.platform !== "win32" && (info.mode & 63) !== 0) try {
|
|
2294
|
+
await chmod(dir, 448);
|
|
2295
|
+
hardened = true;
|
|
2296
|
+
} catch (error) {
|
|
2297
|
+
throw new DataDirError(`cannot restrict permissions on ${dir}: ${error.code}`);
|
|
2298
|
+
}
|
|
2299
|
+
return {
|
|
2300
|
+
created: false,
|
|
2301
|
+
hardened
|
|
2302
|
+
};
|
|
2303
|
+
} catch (error) {
|
|
2304
|
+
if (error instanceof DataDirError) throw error;
|
|
2305
|
+
if (error.code !== "ENOENT") throw new DataDirError(`cannot access data directory ${dir}: ${error.code}`);
|
|
2306
|
+
try {
|
|
2307
|
+
await mkdir(dir, {
|
|
2308
|
+
recursive: true,
|
|
2309
|
+
mode: 448
|
|
2310
|
+
});
|
|
2311
|
+
} catch (mkdirError) {
|
|
2312
|
+
throw new DataDirError(`cannot create data directory ${dir}: ${mkdirError.code}`);
|
|
2313
|
+
}
|
|
2314
|
+
return {
|
|
2315
|
+
created: true,
|
|
2316
|
+
hardened: false
|
|
2317
|
+
};
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
async function ensureDataDirs(dataDir) {
|
|
2321
|
+
const root = await ensureDir(dataDir);
|
|
2322
|
+
let hardened = root.hardened;
|
|
2323
|
+
for (const name of DATA_SUBDIRS) {
|
|
2324
|
+
const result = await ensureDir(path.join(dataDir, name));
|
|
2325
|
+
hardened = hardened || result.hardened;
|
|
2326
|
+
}
|
|
2327
|
+
try {
|
|
2328
|
+
await access(dataDir, constants.W_OK);
|
|
2329
|
+
} catch {
|
|
2330
|
+
throw new DataDirError(`data directory is not writable: ${dataDir}`);
|
|
2331
|
+
}
|
|
2332
|
+
return {
|
|
2333
|
+
created: root.created,
|
|
2334
|
+
hardened
|
|
2335
|
+
};
|
|
2336
|
+
}
|
|
2337
|
+
export { sessions as $, DEPLOYMENT_BUILD_LOG_MAX_BYTES as $t, deploymentPlans as A, FileReadQuerySchema as An, TerminalLeaseSchema as At, resourceEvents as B, ScheduledJobPatchSchema as Bt, browserSessions as C, CommandOutputChunkSchema as Cn, SendTerminalInputParamsSchema as Ct, deploymentArtifacts as D, CommandSubscriptionSchema as Dn, TerminalDevSchema as Dt, deploymentApprovals as E, CommandStatusPayloadSchema as En, TerminalCreateSchema as Et, modelDefaults as F, MAX_EDITABLE_FILE_BYTES as Fn, TerminalResultTargetSchema as Ft, scheduledJobs as G, GitLogQuerySchema as Gt, resourceOperations as H, GitActionSchema as Ht, modelProfiles as I, TerminalSubscriptionSchema as It, serviceActionAuthorizations as J, DEFAULT_PROJECT_ID as Jt, schema_exports as K, WORKSPACE_JOBS_CHANGED as Kt, modelVisibility as L, TerminalTakeoverSchema as Lt, deviceRequests as M, FileSaveResultSchema as Mn, TerminalPayloadSchema as Mt, fileVersions as N, FileSaveSchema as Nn, TerminalRenameSchema as Nt, deploymentAuthorizations as O, FileListQuerySchema as On, TerminalIdSchema as Ot, modelCatalogCache as P, FileScopeSchema as Pn, TerminalResizeSchema as Pt, sessionContextSummaries as Q, DEPLOYMENT_ARTIFACT_MAX_PATH as Qt, projects as R, PlanParamsSchema as Rt, authSettings as S, CommandIdSchema as Sn, ReleaseTerminalControlParamsSchema as St, credentialProfiles as T, CommandParamsSchema as Tn, TERMINAL_LEASE_TTL_MS as Tt, resourceStreams as U, GitBranchesQuerySchema as Ut, resourceLocks as V, GitActionDecisionSchema as Vt, scheduledJobRuns as W, GitDiffQuerySchema as Wt, serviceOpsServices as X, DEPLOYMENT_ARTIFACT_MAX_BYTES as Xt, serviceOpsDeployments as Y, DEPLOYMENT_APPROVAL_TTL_MS as Yt, services as Z, DEPLOYMENT_ARTIFACT_MAX_FILES as Zt, getMeta as _, OriginUrlSchema as _n, ServiceSubscriptionSchema as _t, inspectPendingInitialization as a, DeploymentSourceSchema as an, webauthnCredentials as at, approvals as b, COMMAND_RETENTION_MS as bn, PreviewResultTargetSchema as bt, loadConfig as c, DeploymentTargetRefSchema as cn, FileResyncPayloadSchema as ct, expectedMigrationCount as d, ServiceControlInputSchema as dn, RESOURCE_EVENT_RETENTION_MS as dt, DEPLOYMENT_PLAN_TTL_MS as en, terminalLeases as et, findServerRoot as f, ServiceOpsEventPayloadSchema as fn, ResourceEventsQuerySchema as ft, ensureInstanceId as g, DEFAULT_APP_CONFIG as gn, ServiceStatusSchema as gt, SUPPORTED_NODE_RANGE as h, AppConfigSchema as hn, ServiceRegisterInputSchema as ht, inspectDatabase as i, DeploymentPlanDocumentSchema as in, webauthnChallenges as it, deploymentTargets as j, FileResultTargetSchema as jn, TerminalOutputChunkSchema as jt, deploymentBuilds as k, FilePathSchema as kn, TerminalInputSchema as kt, resolveConfig as l, ServiceActionAuthorizationDtoSchema as ln, FileStreamIdSchema as lt, SERVER_VERSION as m, hasControlCharacters as mn, ServiceIdSchema as mt, ensureDataDirs as n, DeploymentAuthorizationContextSchema as nn, trustedDevices as nt, recoverInitialization as o, DeploymentSpecSchema as on, newId as ot, runMigrations as p, ServiceOpsSubscriptionSchema as pn, ServiceEventPayloadSchema as pt, secrets as q, WORKSPACE_SESSIONS_CHANGED as qt, resolveDataDir as r, DeploymentAuthorizationScopeSchema as rn, turns as rt, configFilePath as s, DeploymentTargetNameSchema as sn, FileChangedPayloadSchema as st, DATA_SUBDIRS as t, DeploymentArtifactManifestSchema as tn, terminals as tt, appliedMigrationCount as u, ServiceActionScopeSchema as un, FileSubscriptionSchema as ut, setMeta as v, deriveWebAuthn as vn, AcquireTerminalControlParamsSchema as vt, commandExecutions as w, CommandOutputQuerySchema as wn, StopProjectTerminalParamsSchema as wt, auditLogs as x, CommandCancelSchema as xn, ReadTerminalOutputParamsSchema as xt, agentEvents as y, COMMAND_OUTPUT_RETENTION_MS as yn, InterruptTerminalParamsSchema as yt, resourceActions as z, ScheduledJobInputSchema as zt };
|