larness 0.3.1 → 0.4.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/apps/server/dist/{address-Dh8XUuOk.js → address-BDs0FfMq.js} +1 -1
- package/apps/server/dist/{client-D64wZ3lt.js → client-D88ULjn9.js} +1 -1
- package/apps/server/dist/{doctor-rEr7DMMb.js → doctor-dwTQiTef.js} +1 -1
- package/apps/server/dist/doctor.js +1 -1
- package/apps/server/dist/index.js +11987 -5714
- package/apps/server/dist/{managed-nCF4mKiY.js → managed-Br7VqQiP.js} +70 -6
- package/apps/server/dist/{paths-Dds-A0kx.js → paths-DUfwiH2X.js} +641 -19
- package/apps/server/dist/{status-toJt8Dby.js → status-D2oSIMoj.js} +1 -1
- package/apps/server/dist/status.js +3 -3
- package/apps/server/dist/tui.js +4 -4
- package/apps/server/drizzle/0032_agent_profile.sql +1 -0
- package/apps/server/drizzle/0033_agent_profile_service_ops.sql +1 -0
- package/apps/server/drizzle/0034_agent_profile_coding_plan.sql +1 -0
- package/apps/server/drizzle/0035_session_title_source.sql +1 -0
- package/apps/server/drizzle/0036_project_memory.sql +62 -0
- package/apps/server/drizzle/0037_web_search.sql +14 -0
- package/apps/server/drizzle/0038_document_attachments.sql +16 -0
- package/apps/server/drizzle/meta/0032_snapshot.json +5169 -0
- package/apps/server/drizzle/meta/0035_snapshot.json +5177 -0
- package/apps/server/drizzle/meta/0036_snapshot.json +5576 -0
- package/apps/server/drizzle/meta/0037_snapshot.json +5667 -0
- package/apps/server/drizzle/meta/0038_snapshot.json +5776 -0
- package/apps/server/drizzle/meta/_journal.json +49 -0
- package/apps/server/package.json +10 -0
- package/apps/web/dist/assets/{FileEditor-Qgvegzha.js → FileEditor-EgU1WoyG.js} +1 -1
- package/apps/web/dist/assets/{FileViewer-DOkamgXq.js → FileViewer-CK3jt-Kt.js} +1 -1
- package/apps/web/dist/assets/{cssMode-CNLukUsc.js → cssMode-C8rMoO9f.js} +1 -1
- package/apps/web/dist/assets/{editor.api-BGAC2PgT.js → editor.api-oDs5eZGS.js} +1 -1
- package/apps/web/dist/assets/{freemarker2-DmzUAvZs.js → freemarker2-Bpg8JM09.js} +1 -1
- package/apps/web/dist/assets/{handlebars-CMacXF3P.js → handlebars-17J16rlT.js} +1 -1
- package/apps/web/dist/assets/{html-BufzDub2.js → html-DJQFF1_1.js} +1 -1
- package/apps/web/dist/assets/{htmlMode-vSvsTicL.js → htmlMode-H8gHwZ6x.js} +1 -1
- package/apps/web/dist/assets/{index-Pz8dIHnt.js → index-BTVfvWIs.js} +2 -2
- package/apps/web/dist/assets/{javascript-CWkrvOWF.js → javascript-CjeM-nVA.js} +1 -1
- package/apps/web/dist/assets/{jsonMode-D6vtcW2h.js → jsonMode-C6seMV0X.js} +1 -1
- package/apps/web/dist/assets/{liquid-D5KkJyqT.js → liquid-B33LyktO.js} +1 -1
- package/apps/web/dist/assets/{lspLanguageFeatures-DI8_dTOp.js → lspLanguageFeatures-H7IuoVNs.js} +1 -1
- package/apps/web/dist/assets/main-CQzbYrTZ.js +157 -0
- package/apps/web/dist/assets/main-gq3n_vn8.css +1 -0
- package/apps/web/dist/assets/{mdx-BdPaDdpH.js → mdx-CcNcLUd8.js} +1 -1
- package/apps/web/dist/assets/{monaco-EglqICVw.js → monaco-xD43LINc.js} +3 -3
- package/apps/web/dist/assets/{python-BrXsyyj_.js → python-BfhjzxvI.js} +1 -1
- package/apps/web/dist/assets/{razor-xmumdcGT.js → razor-COinq8YD.js} +1 -1
- package/apps/web/dist/assets/{tsMode-CkDNjbjK.js → tsMode-CXpnR4mr.js} +1 -1
- package/apps/web/dist/assets/{typescript-BYDg93Ut.js → typescript-DAgfuTsy.js} +1 -1
- package/apps/web/dist/assets/{workers-CMKTm3o5.js → workers-DI76FldO.js} +1 -1
- package/apps/web/dist/assets/{xml-DLqAxpyK.js → xml-CSNVYs0K.js} +1 -1
- package/apps/web/dist/assets/{yaml-Y5128Ncw.js → yaml-Bzp-4SkQ.js} +1 -1
- package/apps/web/dist/index.html +1 -1
- package/docs/README.md +1 -0
- package/docs/guides/install.md +3 -3
- package/package.json +1 -1
- package/apps/web/dist/assets/main-D1Y-WDQ4.css +0 -1
- package/apps/web/dist/assets/main-LsqGdepC.js +0 -158
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { access, chmod, mkdir, readFile, stat } from "node:fs/promises";
|
|
7
7
|
import { eq, sql } from "drizzle-orm";
|
|
8
|
-
import { blob, check, index, integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
|
|
8
|
+
import { blob, check, index, integer, real, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
|
|
9
9
|
import BetterSqlite3 from "better-sqlite3";
|
|
10
10
|
import { migrate } from "drizzle-orm/better-sqlite3/migrator";
|
|
11
11
|
import envPaths from "env-paths";
|
|
@@ -20,6 +20,257 @@ var __exportAll = (all, flags) => {
|
|
|
20
20
|
if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
21
21
|
return flags & 2 ? target : Object.preventExtensions(target);
|
|
22
22
|
};
|
|
23
|
+
// ../../packages/shared/src/attachments.ts
|
|
24
|
+
/**
|
|
25
|
+
* One whitelist for the whole attachment pipeline. The upload dialog, the
|
|
26
|
+
* client-side guard and the server sniffer all read these constants, so a type
|
|
27
|
+
* accepted in the composer cannot be rejected later (and vice versa).
|
|
28
|
+
*
|
|
29
|
+
* Text formats are source-view capable: the original UTF-8 bytes stay readable
|
|
30
|
+
* through `read_attachment view:"source"`, which is what coding tasks need for
|
|
31
|
+
* HTML/CSS/config files that Markdown conversion would lose.
|
|
32
|
+
*/
|
|
33
|
+
const DOCUMENT_ATTACHMENT_EXTENSIONS = [
|
|
34
|
+
"pdf",
|
|
35
|
+
"docx",
|
|
36
|
+
"pptx",
|
|
37
|
+
"xlsx"
|
|
38
|
+
];
|
|
39
|
+
const IMAGE_ATTACHMENT_EXTENSIONS = [
|
|
40
|
+
"png",
|
|
41
|
+
"jpg",
|
|
42
|
+
"jpeg",
|
|
43
|
+
"webp"
|
|
44
|
+
];
|
|
45
|
+
/** Source code, markup, configuration and other plain-text formats. */
|
|
46
|
+
const TEXT_ATTACHMENT_EXTENSIONS = [
|
|
47
|
+
"txt",
|
|
48
|
+
"md",
|
|
49
|
+
"markdown",
|
|
50
|
+
"rst",
|
|
51
|
+
"log",
|
|
52
|
+
"csv",
|
|
53
|
+
"tsv",
|
|
54
|
+
"html",
|
|
55
|
+
"htm",
|
|
56
|
+
"xml",
|
|
57
|
+
"svg",
|
|
58
|
+
"css",
|
|
59
|
+
"scss",
|
|
60
|
+
"sass",
|
|
61
|
+
"less",
|
|
62
|
+
"vue",
|
|
63
|
+
"svelte",
|
|
64
|
+
"astro",
|
|
65
|
+
"json",
|
|
66
|
+
"jsonc",
|
|
67
|
+
"json5",
|
|
68
|
+
"yaml",
|
|
69
|
+
"yml",
|
|
70
|
+
"toml",
|
|
71
|
+
"ini",
|
|
72
|
+
"conf",
|
|
73
|
+
"cfg",
|
|
74
|
+
"properties",
|
|
75
|
+
"gradle",
|
|
76
|
+
"lock",
|
|
77
|
+
"ts",
|
|
78
|
+
"tsx",
|
|
79
|
+
"mts",
|
|
80
|
+
"cts",
|
|
81
|
+
"js",
|
|
82
|
+
"jsx",
|
|
83
|
+
"mjs",
|
|
84
|
+
"cjs",
|
|
85
|
+
"py",
|
|
86
|
+
"rb",
|
|
87
|
+
"go",
|
|
88
|
+
"rs",
|
|
89
|
+
"java",
|
|
90
|
+
"kt",
|
|
91
|
+
"kts",
|
|
92
|
+
"c",
|
|
93
|
+
"h",
|
|
94
|
+
"cc",
|
|
95
|
+
"cpp",
|
|
96
|
+
"cxx",
|
|
97
|
+
"hpp",
|
|
98
|
+
"cs",
|
|
99
|
+
"php",
|
|
100
|
+
"swift",
|
|
101
|
+
"scala",
|
|
102
|
+
"lua",
|
|
103
|
+
"pl",
|
|
104
|
+
"r",
|
|
105
|
+
"dart",
|
|
106
|
+
"ex",
|
|
107
|
+
"exs",
|
|
108
|
+
"erl",
|
|
109
|
+
"clj",
|
|
110
|
+
"hs",
|
|
111
|
+
"zig",
|
|
112
|
+
"sol",
|
|
113
|
+
"sql",
|
|
114
|
+
"graphql",
|
|
115
|
+
"gql",
|
|
116
|
+
"proto",
|
|
117
|
+
"sh",
|
|
118
|
+
"bash",
|
|
119
|
+
"zsh",
|
|
120
|
+
"ps1"
|
|
121
|
+
];
|
|
122
|
+
/** Basenames without a useful extension that are still plain text. */
|
|
123
|
+
const TEXT_ATTACHMENT_FILENAMES = [
|
|
124
|
+
"dockerfile",
|
|
125
|
+
"makefile",
|
|
126
|
+
"rakefile",
|
|
127
|
+
"gemfile",
|
|
128
|
+
"procfile",
|
|
129
|
+
"brewfile",
|
|
130
|
+
"justfile",
|
|
131
|
+
"license",
|
|
132
|
+
"readme",
|
|
133
|
+
"changelog",
|
|
134
|
+
".gitignore",
|
|
135
|
+
".gitattributes",
|
|
136
|
+
".dockerignore",
|
|
137
|
+
".editorconfig",
|
|
138
|
+
".nvmrc",
|
|
139
|
+
".node-version",
|
|
140
|
+
".python-version",
|
|
141
|
+
".prettierrc",
|
|
142
|
+
".eslintrc",
|
|
143
|
+
".babelrc",
|
|
144
|
+
".env.example",
|
|
145
|
+
".env.sample",
|
|
146
|
+
".env.template"
|
|
147
|
+
];
|
|
148
|
+
/**
|
|
149
|
+
* Credentials are never accepted, not even as text: an attachment is shown in
|
|
150
|
+
* the transcript and injected into the model context, so a pasted key would be
|
|
151
|
+
* logged, cached and sent to the provider.
|
|
152
|
+
*/
|
|
153
|
+
const SECRET_FILENAMES = /* @__PURE__ */ new Set([
|
|
154
|
+
".env",
|
|
155
|
+
".npmrc",
|
|
156
|
+
".netrc",
|
|
157
|
+
".git-credentials",
|
|
158
|
+
".htpasswd",
|
|
159
|
+
"id_rsa",
|
|
160
|
+
"id_dsa",
|
|
161
|
+
"id_ecdsa",
|
|
162
|
+
"id_ed25519",
|
|
163
|
+
"credentials"
|
|
164
|
+
]);
|
|
165
|
+
const SECRET_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
166
|
+
"pem",
|
|
167
|
+
"key",
|
|
168
|
+
"p12",
|
|
169
|
+
"pfx",
|
|
170
|
+
"jks",
|
|
171
|
+
"keystore",
|
|
172
|
+
"ppk",
|
|
173
|
+
"asc",
|
|
174
|
+
"gpg",
|
|
175
|
+
"kdbx"
|
|
176
|
+
]);
|
|
177
|
+
const SECRET_ENV_VARIANTS = /^\.env(\..+)?$/;
|
|
178
|
+
/** Binary or archive formats that v1 rejects outright. */
|
|
179
|
+
const BLOCKED_ATTACHMENT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
180
|
+
"exe",
|
|
181
|
+
"dll",
|
|
182
|
+
"so",
|
|
183
|
+
"dylib",
|
|
184
|
+
"jar",
|
|
185
|
+
"class",
|
|
186
|
+
"msi",
|
|
187
|
+
"apk",
|
|
188
|
+
"wasm",
|
|
189
|
+
"com",
|
|
190
|
+
"scr",
|
|
191
|
+
"cpl",
|
|
192
|
+
"sys",
|
|
193
|
+
"doc",
|
|
194
|
+
"ppt",
|
|
195
|
+
"xls",
|
|
196
|
+
"zip",
|
|
197
|
+
"rar",
|
|
198
|
+
"7z",
|
|
199
|
+
"gz",
|
|
200
|
+
"tgz",
|
|
201
|
+
"bz2",
|
|
202
|
+
"xz",
|
|
203
|
+
"tar",
|
|
204
|
+
"mp3",
|
|
205
|
+
"mp4",
|
|
206
|
+
"mov",
|
|
207
|
+
"avi",
|
|
208
|
+
"wav",
|
|
209
|
+
"ogg",
|
|
210
|
+
"webm",
|
|
211
|
+
"mkv",
|
|
212
|
+
"flac",
|
|
213
|
+
"bmp",
|
|
214
|
+
"tif",
|
|
215
|
+
"tiff",
|
|
216
|
+
"ico",
|
|
217
|
+
"heic",
|
|
218
|
+
"psd",
|
|
219
|
+
"ai",
|
|
220
|
+
"ttf",
|
|
221
|
+
"otf",
|
|
222
|
+
"woff",
|
|
223
|
+
"woff2",
|
|
224
|
+
"eot"
|
|
225
|
+
]);
|
|
226
|
+
/** MIME types whose original bytes are readable as text. */
|
|
227
|
+
const SOURCE_VIEW_MIMES = [
|
|
228
|
+
"text/plain",
|
|
229
|
+
"text/markdown",
|
|
230
|
+
"text/csv",
|
|
231
|
+
"text/html"
|
|
232
|
+
];
|
|
233
|
+
function isSourceViewMime(mime) {
|
|
234
|
+
return SOURCE_VIEW_MIMES.includes(mime);
|
|
235
|
+
}
|
|
236
|
+
/** Lower-cased basename without directories. */
|
|
237
|
+
function attachmentBasename(filename) {
|
|
238
|
+
return (filename.replaceAll("\\", "/").split("/").at(-1) ?? "").toLowerCase();
|
|
239
|
+
}
|
|
240
|
+
/** Lower-cased extension without the dot; "" for dotfiles and bare names. */
|
|
241
|
+
function attachmentExtensionOf(filename) {
|
|
242
|
+
const basename = attachmentBasename(filename);
|
|
243
|
+
const dot = basename.lastIndexOf(".");
|
|
244
|
+
if (dot <= 0 || dot === basename.length - 1) return "";
|
|
245
|
+
return basename.slice(dot + 1);
|
|
246
|
+
}
|
|
247
|
+
function isSecretAttachmentName(filename) {
|
|
248
|
+
const basename = attachmentBasename(filename);
|
|
249
|
+
if (SECRET_FILENAMES.has(basename)) return true;
|
|
250
|
+
const dotenv = SECRET_ENV_VARIANTS.exec(basename);
|
|
251
|
+
if (dotenv !== null) {
|
|
252
|
+
const suffix = dotenv[1] ?? "";
|
|
253
|
+
if (suffix === ".example" || suffix === ".sample" || suffix === ".template") return false;
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
return SECRET_EXTENSIONS.has(attachmentExtensionOf(basename));
|
|
257
|
+
}
|
|
258
|
+
function isBlockedAttachmentName(filename) {
|
|
259
|
+
return BLOCKED_ATTACHMENT_EXTENSIONS.has(attachmentExtensionOf(filename));
|
|
260
|
+
}
|
|
261
|
+
const ACCEPTED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
262
|
+
...DOCUMENT_ATTACHMENT_EXTENSIONS,
|
|
263
|
+
...IMAGE_ATTACHMENT_EXTENSIONS,
|
|
264
|
+
...TEXT_ATTACHMENT_EXTENSIONS
|
|
265
|
+
]);
|
|
266
|
+
const ACCEPTED_FILENAMES = new Set(TEXT_ATTACHMENT_FILENAMES);
|
|
267
|
+
/** Extension or basename allow-list check; secrets are rejected separately. */
|
|
268
|
+
function isAcceptedAttachmentName(filename) {
|
|
269
|
+
const basename = attachmentBasename(filename);
|
|
270
|
+
if (ACCEPTED_FILENAMES.has(basename)) return true;
|
|
271
|
+
return ACCEPTED_EXTENSIONS.has(attachmentExtensionOf(basename));
|
|
272
|
+
}
|
|
273
|
+
[...ACCEPTED_EXTENSIONS].sort().map((extension) => `.${extension}`).join(",");
|
|
23
274
|
z.enum([
|
|
24
275
|
"project",
|
|
25
276
|
"default",
|
|
@@ -136,17 +387,48 @@ const FileActionResultSchema = z.object({
|
|
|
136
387
|
});
|
|
137
388
|
// ../../packages/shared/src/commands.ts
|
|
138
389
|
/**
|
|
139
|
-
* A single command may run for up to 30 minutes. The Turn wall clock
|
|
140
|
-
*
|
|
141
|
-
* left in the Turn, so a long timeout never outlives its Turn.
|
|
390
|
+
* A single command may run for up to 30 minutes. The Turn wall clock remains
|
|
391
|
+
* the outer emergency bound (ADR-071): `CommandManager` further clamps this to
|
|
392
|
+
* the time left in the Turn, so a long timeout never outlives its Turn.
|
|
142
393
|
*/
|
|
143
394
|
const MAX_COMMAND_TIMEOUT_MS = 18e5;
|
|
144
|
-
const
|
|
395
|
+
const DEFAULT_COMMAND_TIMEOUT_MS = 3e5;
|
|
396
|
+
const CommandParamsObject = z.object({
|
|
145
397
|
executable: z.string().min(1).max(4096).refine((value) => !value.includes("\0")),
|
|
146
|
-
args: z.array(z.string().max(8192).refine((value) => !value.includes("\0"))).max(256),
|
|
398
|
+
args: z.array(z.string().max(8192).refine((value) => !value.includes("\0"))).max(256).default([]),
|
|
147
399
|
cwd: FilePathSchema.default("."),
|
|
148
|
-
timeoutMs: z.number().int().min(1).max(MAX_COMMAND_TIMEOUT_MS).default(
|
|
149
|
-
}).strict()
|
|
400
|
+
timeoutMs: z.number().int().min(1).max(MAX_COMMAND_TIMEOUT_MS).default(DEFAULT_COMMAND_TIMEOUT_MS)
|
|
401
|
+
}).strict();
|
|
402
|
+
const CommandParamsSchema = CommandParamsObject.refine((value) => value.args.reduce((size, arg) => size + arg.length, value.executable.length) <= 65536);
|
|
403
|
+
/** Explicit shell escape hatch. The platform shell is selected by the backend. */
|
|
404
|
+
const ShellCommandParamsObject = z.object({
|
|
405
|
+
command: z.string().min(1).max(65536).refine((value) => !value.includes("\0")),
|
|
406
|
+
cwd: FilePathSchema.default("."),
|
|
407
|
+
timeoutMs: z.number().int().min(1).max(MAX_COMMAND_TIMEOUT_MS).default(DEFAULT_COMMAND_TIMEOUT_MS)
|
|
408
|
+
}).strict();
|
|
409
|
+
const ShellCommandParamsSchema = ShellCommandParamsObject;
|
|
410
|
+
/**
|
|
411
|
+
* Internal request consumed by CommandManager. The tools keep `mode` out of
|
|
412
|
+
* their public schemas and set it before calling the shared handler.
|
|
413
|
+
*/
|
|
414
|
+
const CommandRequestSchema = z.discriminatedUnion("mode", [CommandParamsObject.extend({ mode: z.literal("exec") }), ShellCommandParamsObject.extend({ mode: z.literal("shell") })]).superRefine((value, context) => {
|
|
415
|
+
if (value.mode === "exec" && value.args.reduce((size, arg) => size + arg.length, value.executable.length) > 65536) context.addIssue({
|
|
416
|
+
code: "custom",
|
|
417
|
+
message: "command arguments exceed the 64 KiB limit"
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
/**
|
|
421
|
+
* Internal callers may omit `mode`: a `command` field means shell mode, an
|
|
422
|
+
* `executable` field means exec mode. Public tool schemas never expose `mode`.
|
|
423
|
+
*/
|
|
424
|
+
function normalizeCommandRequest(input) {
|
|
425
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) return input;
|
|
426
|
+
if ("mode" in input) return input;
|
|
427
|
+
return {
|
|
428
|
+
...input,
|
|
429
|
+
mode: "command" in input ? "shell" : "exec"
|
|
430
|
+
};
|
|
431
|
+
}
|
|
150
432
|
const CommandStatusSchema = z.enum([
|
|
151
433
|
"CREATED",
|
|
152
434
|
"RUNNING",
|
|
@@ -293,6 +575,36 @@ const CleanupConfigSchema = z.strictObject({
|
|
|
293
575
|
maxBytes: z.number().int().min(0).default(0)
|
|
294
576
|
});
|
|
295
577
|
const DEFAULT_CLEANUP_CONFIG = CleanupConfigSchema.parse({});
|
|
578
|
+
const AgentMemoryConfigSchema = z.strictObject({ enabled: z.boolean().default(true) });
|
|
579
|
+
const AgentConfigSchema = z.strictObject({ memory: AgentMemoryConfigSchema.default({ enabled: true }) });
|
|
580
|
+
const AttachmentOcrConfigSchema = z.strictObject({
|
|
581
|
+
/** `auto-local` never sends documents to a provider; `vision` needs a connection. */
|
|
582
|
+
mode: z.enum([
|
|
583
|
+
"off",
|
|
584
|
+
"auto-local",
|
|
585
|
+
"vision"
|
|
586
|
+
]).default("auto-local"),
|
|
587
|
+
maxPagesPerTurn: z.number().int().min(1).max(200).default(20),
|
|
588
|
+
visionConnectionId: z.string().min(1).max(128).nullable().default(null)
|
|
589
|
+
});
|
|
590
|
+
const AttachmentsConfigSchema = z.strictObject({
|
|
591
|
+
enabled: z.boolean().default(true),
|
|
592
|
+
maxFileBytes: z.number().int().min(1).max(104857600).default(20971520),
|
|
593
|
+
maxFilesPerTurn: z.number().int().min(1).max(32).default(8),
|
|
594
|
+
maxFilesPerSession: z.number().int().min(1).max(2e3).default(200),
|
|
595
|
+
maxExtractedChars: z.number().int().min(1e3).max(2e6).default(2e5),
|
|
596
|
+
maxPdfPages: z.number().int().min(1).max(5e3).default(400),
|
|
597
|
+
inlineTokensPerFile: z.number().int().min(256).max(128e3).default(8e3),
|
|
598
|
+
inlineContextRatio: z.number().min(.01).max(.8).default(.15),
|
|
599
|
+
extractionTimeoutMs: z.number().int().min(1e3).max(6e5).default(6e4),
|
|
600
|
+
ocr: AttachmentOcrConfigSchema.default({
|
|
601
|
+
mode: "auto-local",
|
|
602
|
+
maxPagesPerTurn: 20,
|
|
603
|
+
visionConnectionId: null
|
|
604
|
+
})
|
|
605
|
+
});
|
|
606
|
+
const DEFAULT_ATTACHMENTS_CONFIG = AttachmentsConfigSchema.parse({});
|
|
607
|
+
const DEFAULT_AGENT_CONFIG = AgentConfigSchema.parse({});
|
|
296
608
|
const AppConfigSchema = z.strictObject({
|
|
297
609
|
version: z.literal(1),
|
|
298
610
|
server: ServerConfigSchema,
|
|
@@ -301,7 +613,9 @@ const AppConfigSchema = z.strictObject({
|
|
|
301
613
|
logging: LoggingConfigSchema,
|
|
302
614
|
updates: UpdatesConfigSchema,
|
|
303
615
|
preview: PreviewConfigSchema.default(DEFAULT_PREVIEW_CONFIG),
|
|
304
|
-
cleanup: CleanupConfigSchema.default(DEFAULT_CLEANUP_CONFIG)
|
|
616
|
+
cleanup: CleanupConfigSchema.default(DEFAULT_CLEANUP_CONFIG),
|
|
617
|
+
agent: AgentConfigSchema.default(DEFAULT_AGENT_CONFIG),
|
|
618
|
+
attachments: AttachmentsConfigSchema.default(DEFAULT_ATTACHMENTS_CONFIG)
|
|
305
619
|
});
|
|
306
620
|
const DEFAULT_APP_CONFIG = {
|
|
307
621
|
version: 1,
|
|
@@ -331,7 +645,9 @@ const DEFAULT_APP_CONFIG = {
|
|
|
331
645
|
autoInstall: false
|
|
332
646
|
},
|
|
333
647
|
preview: DEFAULT_PREVIEW_CONFIG,
|
|
334
|
-
cleanup: DEFAULT_CLEANUP_CONFIG
|
|
648
|
+
cleanup: DEFAULT_CLEANUP_CONFIG,
|
|
649
|
+
agent: DEFAULT_AGENT_CONFIG,
|
|
650
|
+
attachments: DEFAULT_ATTACHMENTS_CONFIG
|
|
335
651
|
};
|
|
336
652
|
function isIpHostname(hostname) {
|
|
337
653
|
const host = hostname.replace(/^\[/, "").replace(/\]$/, "");
|
|
@@ -629,6 +945,8 @@ const ServiceOpsServiceDtoSchema = z.object({
|
|
|
629
945
|
projectId: z.string().min(1).max(128),
|
|
630
946
|
name: DeploymentTargetNameSchema,
|
|
631
947
|
pm2Name: z.string().min(1).max(256),
|
|
948
|
+
namespace: z.string().min(1).max(64),
|
|
949
|
+
namespaceMismatch: z.boolean(),
|
|
632
950
|
projectName: z.string().nullable(),
|
|
633
951
|
source: z.enum(["pm2-cli", "deployment"]),
|
|
634
952
|
version: DeploymentVersionSchema.nullable(),
|
|
@@ -783,6 +1101,7 @@ z.boolean().default(false);
|
|
|
783
1101
|
// ../../packages/shared/src/events.ts
|
|
784
1102
|
const WORKSPACE_SESSIONS_CHANGED = "workspace.sessions.changed";
|
|
785
1103
|
const WORKSPACE_JOBS_CHANGED = "workspace.jobs.changed";
|
|
1104
|
+
const WORKSPACE_MEMORY_CHANGED = "memory.changed";
|
|
786
1105
|
z.discriminatedUnion("kind", [z.object({
|
|
787
1106
|
kind: z.literal("subscribed"),
|
|
788
1107
|
subscription: z.object({
|
|
@@ -791,6 +1110,29 @@ z.discriminatedUnion("kind", [z.object({
|
|
|
791
1110
|
})
|
|
792
1111
|
}), z.object({ kind: z.literal(WORKSPACE_SESSIONS_CHANGED) })]);
|
|
793
1112
|
z.object({ kind: z.literal(WORKSPACE_JOBS_CHANGED) });
|
|
1113
|
+
z.object({
|
|
1114
|
+
kind: z.literal(WORKSPACE_MEMORY_CHANGED),
|
|
1115
|
+
scope: z.enum(["project", "global"]),
|
|
1116
|
+
projectId: z.string().optional(),
|
|
1117
|
+
memoryId: z.string(),
|
|
1118
|
+
action: z.enum([
|
|
1119
|
+
"learned",
|
|
1120
|
+
"updated",
|
|
1121
|
+
"reviewed",
|
|
1122
|
+
"forgotten",
|
|
1123
|
+
"evicted",
|
|
1124
|
+
"restored",
|
|
1125
|
+
"purged"
|
|
1126
|
+
]),
|
|
1127
|
+
status: z.enum([
|
|
1128
|
+
"active",
|
|
1129
|
+
"review",
|
|
1130
|
+
"rejected",
|
|
1131
|
+
"superseded",
|
|
1132
|
+
"expired",
|
|
1133
|
+
"evicted"
|
|
1134
|
+
])
|
|
1135
|
+
});
|
|
794
1136
|
const TurnFileResultSchema = z.object({
|
|
795
1137
|
path: z.string().min(1),
|
|
796
1138
|
changeType: z.enum(["created", "modified"]),
|
|
@@ -944,6 +1286,129 @@ const ScheduledJobPatchSchema = z.object({
|
|
|
944
1286
|
approvalPolicy: ScheduledJobApprovalPolicySchema.optional()
|
|
945
1287
|
}).strict().optional()
|
|
946
1288
|
}).strict();
|
|
1289
|
+
// ../../packages/shared/src/memory.ts
|
|
1290
|
+
const MEMORY_SCOPES = ["project", "global"];
|
|
1291
|
+
const MEMORY_KINDS = [
|
|
1292
|
+
"fact",
|
|
1293
|
+
"command",
|
|
1294
|
+
"gotcha",
|
|
1295
|
+
"decision",
|
|
1296
|
+
"preference"
|
|
1297
|
+
];
|
|
1298
|
+
const MEMORY_STATUSES = [
|
|
1299
|
+
"active",
|
|
1300
|
+
"review",
|
|
1301
|
+
"rejected",
|
|
1302
|
+
"superseded",
|
|
1303
|
+
"expired",
|
|
1304
|
+
"evicted"
|
|
1305
|
+
];
|
|
1306
|
+
const MEMORY_EVIDENCE_KINDS = [
|
|
1307
|
+
"user_statement",
|
|
1308
|
+
"command_succeeded",
|
|
1309
|
+
"file_observed",
|
|
1310
|
+
"failure_then_success",
|
|
1311
|
+
"agent_inference"
|
|
1312
|
+
];
|
|
1313
|
+
const MemoryScopeSchema = z.enum(MEMORY_SCOPES);
|
|
1314
|
+
const MemoryKindSchema = z.enum(MEMORY_KINDS);
|
|
1315
|
+
const MemoryStatusSchema = z.enum(MEMORY_STATUSES);
|
|
1316
|
+
const MemoryEvidenceKindSchema = z.enum(MEMORY_EVIDENCE_KINDS);
|
|
1317
|
+
const MemoryKeySchema = z.string().regex(/^[a-z0-9][a-z0-9._-]{2,79}$/, "key must be a lowercase slug");
|
|
1318
|
+
const MemoryTitleSchema = z.string().trim().min(1).max(120);
|
|
1319
|
+
const MemoryBodySchema = z.string().trim().min(1).max(4e3);
|
|
1320
|
+
const MemoryEvidenceSchema = z.object({
|
|
1321
|
+
kind: MemoryEvidenceKindSchema,
|
|
1322
|
+
turnId: z.string().min(1).max(128),
|
|
1323
|
+
eventSeq: z.number().int().positive(),
|
|
1324
|
+
/** Exact user text for `user_statement`; validated against the source event. */
|
|
1325
|
+
quote: z.string().min(1).max(2e3).optional()
|
|
1326
|
+
}).strict();
|
|
1327
|
+
z.object({
|
|
1328
|
+
scope: MemoryScopeSchema,
|
|
1329
|
+
kind: MemoryKindSchema,
|
|
1330
|
+
key: MemoryKeySchema,
|
|
1331
|
+
title: MemoryTitleSchema,
|
|
1332
|
+
body: MemoryBodySchema,
|
|
1333
|
+
evidence: MemoryEvidenceSchema,
|
|
1334
|
+
confidence: z.number().min(0).max(1).optional()
|
|
1335
|
+
}).strict();
|
|
1336
|
+
/** Model-facing shape: turn/event ids are resolved server-side from the current Turn. */
|
|
1337
|
+
const RememberToolInputSchema = z.object({
|
|
1338
|
+
scope: MemoryScopeSchema,
|
|
1339
|
+
kind: MemoryKindSchema,
|
|
1340
|
+
key: MemoryKeySchema,
|
|
1341
|
+
title: MemoryTitleSchema,
|
|
1342
|
+
body: MemoryBodySchema,
|
|
1343
|
+
evidence: z.object({
|
|
1344
|
+
kind: MemoryEvidenceKindSchema,
|
|
1345
|
+
quote: z.string().min(1).max(2e3).optional()
|
|
1346
|
+
}).strict(),
|
|
1347
|
+
confidence: z.number().min(0).max(1).optional()
|
|
1348
|
+
}).strict();
|
|
1349
|
+
const ReadMemoryInputSchema = z.object({
|
|
1350
|
+
keys: z.array(MemoryKeySchema).min(1).max(5).optional(),
|
|
1351
|
+
query: z.string().min(1).max(200).optional(),
|
|
1352
|
+
limit: z.number().int().min(1).max(5).optional()
|
|
1353
|
+
}).strict();
|
|
1354
|
+
z.object({
|
|
1355
|
+
id: z.string(),
|
|
1356
|
+
scope: MemoryScopeSchema,
|
|
1357
|
+
projectId: z.string().nullable(),
|
|
1358
|
+
kind: MemoryKindSchema,
|
|
1359
|
+
key: z.string(),
|
|
1360
|
+
title: z.string(),
|
|
1361
|
+
body: z.string(),
|
|
1362
|
+
status: MemoryStatusSchema,
|
|
1363
|
+
confidence: z.number(),
|
|
1364
|
+
evidenceKind: MemoryEvidenceKindSchema,
|
|
1365
|
+
sourceTurnId: z.string().nullable(),
|
|
1366
|
+
sourceEventSeq: z.number().nullable(),
|
|
1367
|
+
createdBy: z.enum(["agent", "user"]),
|
|
1368
|
+
useCount: z.number(),
|
|
1369
|
+
lastUsedAt: z.number().nullable(),
|
|
1370
|
+
lastConfirmedAt: z.number().nullable(),
|
|
1371
|
+
correctionCount: z.number(),
|
|
1372
|
+
pinned: z.boolean(),
|
|
1373
|
+
bytes: z.number(),
|
|
1374
|
+
verifiedAt: z.number().nullable(),
|
|
1375
|
+
expiresAt: z.number().nullable(),
|
|
1376
|
+
createdAt: z.number(),
|
|
1377
|
+
updatedAt: z.number(),
|
|
1378
|
+
stale: z.boolean(),
|
|
1379
|
+
revisionCount: z.number()
|
|
1380
|
+
});
|
|
1381
|
+
const MemoryLimitsSchema = z.object({
|
|
1382
|
+
activeBytes: z.number(),
|
|
1383
|
+
totalBytes: z.number(),
|
|
1384
|
+
activeCount: z.number()
|
|
1385
|
+
});
|
|
1386
|
+
z.object({
|
|
1387
|
+
scope: MemoryScopeSchema,
|
|
1388
|
+
projectId: z.string().nullable(),
|
|
1389
|
+
activeBytes: z.number(),
|
|
1390
|
+
totalBytes: z.number(),
|
|
1391
|
+
activeCount: z.number(),
|
|
1392
|
+
reviewCount: z.number(),
|
|
1393
|
+
evictedCount: z.number(),
|
|
1394
|
+
limits: MemoryLimitsSchema
|
|
1395
|
+
});
|
|
1396
|
+
const MemoryChangedActionSchema = z.enum([
|
|
1397
|
+
"learned",
|
|
1398
|
+
"updated",
|
|
1399
|
+
"reviewed",
|
|
1400
|
+
"forgotten",
|
|
1401
|
+
"evicted",
|
|
1402
|
+
"restored",
|
|
1403
|
+
"purged"
|
|
1404
|
+
]);
|
|
1405
|
+
z.object({
|
|
1406
|
+
scope: MemoryScopeSchema,
|
|
1407
|
+
projectId: z.string().optional(),
|
|
1408
|
+
memoryId: z.string(),
|
|
1409
|
+
action: MemoryChangedActionSchema,
|
|
1410
|
+
status: MemoryStatusSchema
|
|
1411
|
+
});
|
|
947
1412
|
// ../../packages/shared/src/plans.ts
|
|
948
1413
|
const PlanStepSchema = z.object({
|
|
949
1414
|
id: z.string().min(1).max(80),
|
|
@@ -975,6 +1440,66 @@ PlanParamsSchema.safeExtend({
|
|
|
975
1440
|
createdAt: z.number().int().nonnegative(),
|
|
976
1441
|
turnId: z.string().optional()
|
|
977
1442
|
});
|
|
1443
|
+
// ../../packages/shared/src/processes.ts
|
|
1444
|
+
const ProcessIdSchema = z.string().regex(/^prc_[a-f0-9-]{36}$/);
|
|
1445
|
+
const ProcessStatusSchema = z.enum([
|
|
1446
|
+
"STARTING",
|
|
1447
|
+
"RUNNING",
|
|
1448
|
+
"STOPPING",
|
|
1449
|
+
"EXITED",
|
|
1450
|
+
"STOPPED",
|
|
1451
|
+
"FAILED"
|
|
1452
|
+
]);
|
|
1453
|
+
const CommandArgumentSchema = z.string().max(8192).refine((value) => !value.includes("\0"));
|
|
1454
|
+
const StartProcessParamsSchema = z.object({
|
|
1455
|
+
executable: z.string().min(1).max(4096).refine((value) => !value.includes("\0")),
|
|
1456
|
+
args: z.array(CommandArgumentSchema).max(256).default([]),
|
|
1457
|
+
cwd: FilePathSchema.default("."),
|
|
1458
|
+
/** Stable human-readable name used for idempotent restarts. */
|
|
1459
|
+
name: z.string().min(1).max(80).optional(),
|
|
1460
|
+
/** Port the task will listen on; required for a preview button. */
|
|
1461
|
+
port: z.number().int().min(1).max(65535).optional(),
|
|
1462
|
+
/** Optional HTTP health path used by the UI/preview verification. */
|
|
1463
|
+
healthPath: z.string().min(1).max(2048).optional()
|
|
1464
|
+
}).strict().refine((value) => value.args.reduce((size, arg) => size + arg.length, value.executable.length) <= 65536);
|
|
1465
|
+
const ProcessOutputQuerySchema = z.object({
|
|
1466
|
+
after: z.coerce.number().int().min(0).max(Number.MAX_SAFE_INTEGER).default(0),
|
|
1467
|
+
limit: z.coerce.number().int().min(1).max(500).default(100)
|
|
1468
|
+
}).strict();
|
|
1469
|
+
const ProcessOutputChunkSchema = z.object({
|
|
1470
|
+
cursor: z.number().int().positive(),
|
|
1471
|
+
data: z.string().max(16384).refine((data) => new TextEncoder().encode(data).byteLength <= 16384),
|
|
1472
|
+
channel: z.enum(["stdout", "stderr"]),
|
|
1473
|
+
timestamp: z.number().int()
|
|
1474
|
+
}).strict();
|
|
1475
|
+
z.object({
|
|
1476
|
+
id: ProcessIdSchema,
|
|
1477
|
+
projectId: z.string().nullable(),
|
|
1478
|
+
sessionId: z.string(),
|
|
1479
|
+
name: z.string().nullable(),
|
|
1480
|
+
status: ProcessStatusSchema,
|
|
1481
|
+
executable: z.string(),
|
|
1482
|
+
cwd: z.string(),
|
|
1483
|
+
pid: z.number().int().nullable(),
|
|
1484
|
+
exitCode: z.number().int().nullable(),
|
|
1485
|
+
reasonCode: z.string().nullable(),
|
|
1486
|
+
startedAt: z.number().int().nullable(),
|
|
1487
|
+
endedAt: z.number().int().nullable(),
|
|
1488
|
+
port: z.number().int().min(1).max(65535).nullable(),
|
|
1489
|
+
healthPath: z.string().nullable(),
|
|
1490
|
+
previewEligible: z.boolean(),
|
|
1491
|
+
outputCursor: z.number().int().nonnegative(),
|
|
1492
|
+
truncated: z.boolean()
|
|
1493
|
+
}).strict();
|
|
1494
|
+
z.object({
|
|
1495
|
+
chunks: z.array(ProcessOutputChunkSchema).max(500),
|
|
1496
|
+
oldestCursor: z.number().int().positive(),
|
|
1497
|
+
nextCursor: z.number().int().nonnegative(),
|
|
1498
|
+
truncated: z.boolean(),
|
|
1499
|
+
resyncRequired: z.boolean()
|
|
1500
|
+
}).strict();
|
|
1501
|
+
const PROCESS_OUTPUT_MAX_BYTES = 1048576;
|
|
1502
|
+
const PROCESS_OUTPUT_MAX_CHUNKS = 5e3;
|
|
978
1503
|
// ../../packages/shared/src/terminals.ts
|
|
979
1504
|
const TerminalIdSchema = z.string().regex(/^term_[a-f0-9-]{36}$/);
|
|
980
1505
|
const TerminalRenameSchema = z.object({ title: z.string().min(1).max(80).refine((value) => [...value].every((char) => {
|
|
@@ -1011,12 +1536,12 @@ const TerminalDevSchema = z.object({
|
|
|
1011
1536
|
message: "Invalid program parameters"
|
|
1012
1537
|
});
|
|
1013
1538
|
});
|
|
1014
|
-
|
|
1539
|
+
z.object({
|
|
1015
1540
|
terminalId: TerminalIdSchema,
|
|
1016
1541
|
after: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).default(0),
|
|
1017
1542
|
limit: z.number().int().min(1).max(500).default(100)
|
|
1018
1543
|
}).strict();
|
|
1019
|
-
|
|
1544
|
+
z.object({ terminalId: TerminalIdSchema }).strict();
|
|
1020
1545
|
const TerminalResultTargetSchema = z.object({
|
|
1021
1546
|
kind: z.literal("terminal"),
|
|
1022
1547
|
projectId: z.string().min(1),
|
|
@@ -1036,18 +1561,18 @@ z.union([
|
|
|
1036
1561
|
PreviewResultTargetSchema
|
|
1037
1562
|
]);
|
|
1038
1563
|
const TerminalTakeoverSchema = z.object({ connectionId: z.string().uuid() }).strict();
|
|
1039
|
-
|
|
1040
|
-
|
|
1564
|
+
z.object({ terminalId: TerminalIdSchema }).strict();
|
|
1565
|
+
z.object({
|
|
1041
1566
|
terminalId: TerminalIdSchema,
|
|
1042
1567
|
leaseGeneration: z.number().int().positive(),
|
|
1043
1568
|
inputSequence: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
1044
1569
|
data: z.string().min(1).max(8192).refine((data) => new TextEncoder().encode(data).length <= 8192)
|
|
1045
1570
|
}).strict();
|
|
1046
|
-
|
|
1571
|
+
z.object({
|
|
1047
1572
|
terminalId: TerminalIdSchema,
|
|
1048
1573
|
leaseGeneration: z.number().int().positive()
|
|
1049
1574
|
}).strict();
|
|
1050
|
-
|
|
1575
|
+
z.object({
|
|
1051
1576
|
terminalId: TerminalIdSchema,
|
|
1052
1577
|
leaseGeneration: z.number().int().positive()
|
|
1053
1578
|
}).strict();
|
|
@@ -1354,6 +1879,8 @@ function newId(prefix) {
|
|
|
1354
1879
|
// src/db/schema.ts
|
|
1355
1880
|
var schema_exports = /* @__PURE__ */ __exportAll({
|
|
1356
1881
|
MODEL_PROVIDER_IDS: () => MODEL_PROVIDER_IDS,
|
|
1882
|
+
WEB_SEARCH_PROVIDER_IDS: () => WEB_SEARCH_PROVIDER_IDS,
|
|
1883
|
+
WEB_SEARCH_REGIONS: () => WEB_SEARCH_REGIONS,
|
|
1357
1884
|
agentEvents: () => agentEvents,
|
|
1358
1885
|
appMeta: () => appMeta,
|
|
1359
1886
|
approvals: () => approvals,
|
|
@@ -1370,6 +1897,9 @@ var schema_exports = /* @__PURE__ */ __exportAll({
|
|
|
1370
1897
|
deploymentTargets: () => deploymentTargets,
|
|
1371
1898
|
deviceRequests: () => deviceRequests,
|
|
1372
1899
|
fileVersions: () => fileVersions,
|
|
1900
|
+
memories: () => memories,
|
|
1901
|
+
memoryRevisions: () => memoryRevisions,
|
|
1902
|
+
memorySuppressions: () => memorySuppressions,
|
|
1373
1903
|
modelCatalogCache: () => modelCatalogCache,
|
|
1374
1904
|
modelDefaults: () => modelDefaults,
|
|
1375
1905
|
modelProfiles: () => modelProfiles,
|
|
@@ -1394,6 +1924,7 @@ var schema_exports = /* @__PURE__ */ __exportAll({
|
|
|
1394
1924
|
terminals: () => terminals,
|
|
1395
1925
|
trustedDevices: () => trustedDevices,
|
|
1396
1926
|
turns: () => turns,
|
|
1927
|
+
webSearchConnections: () => webSearchConnections,
|
|
1397
1928
|
webauthnChallenges: () => webauthnChallenges,
|
|
1398
1929
|
webauthnCredentials: () => webauthnCredentials
|
|
1399
1930
|
});
|
|
@@ -1428,13 +1959,17 @@ const sessions = sqliteTable("sessions", {
|
|
|
1428
1959
|
projectId: text("project_id").references(() => projects.id, { onDelete: "set null" }),
|
|
1429
1960
|
workspacePath: text("workspace_path").notNull(),
|
|
1430
1961
|
title: text("title").notNull(),
|
|
1962
|
+
/** `auto` titles may be replaced by generated summaries; `user` titles never are. */
|
|
1963
|
+
titleSource: text("title_source").$type().notNull().default("user"),
|
|
1431
1964
|
status: text("status").$type().notNull().default("active"),
|
|
1432
1965
|
origin: text("origin").$type().notNull().default("user"),
|
|
1433
1966
|
modelProfileId: text("model_profile_id"),
|
|
1434
1967
|
credentialProfileId: text("credential_profile_id"),
|
|
1435
1968
|
model: text("model"),
|
|
1436
1969
|
thinking: text("thinking"),
|
|
1970
|
+
agentProfile: text("agent_profile").$type().notNull().default("coding"),
|
|
1437
1971
|
approvalPolicyId: text("approval_policy_id").notNull().default("standard"),
|
|
1972
|
+
webSearchEnabled: integer("web_search_enabled", { mode: "boolean" }).notNull().default(false),
|
|
1438
1973
|
createdAt: integer("created_at").notNull(),
|
|
1439
1974
|
updatedAt: integer("updated_at").notNull(),
|
|
1440
1975
|
lastActivityAt: integer("last_activity_at").notNull(),
|
|
@@ -1448,13 +1983,31 @@ const sessions = sqliteTable("sessions", {
|
|
|
1448
1983
|
const sessionAttachments = sqliteTable("session_attachments", {
|
|
1449
1984
|
id: text("id").primaryKey(),
|
|
1450
1985
|
sessionId: text("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
|
|
1451
|
-
|
|
1986
|
+
/** Basename only; never used to derive a storage path. */
|
|
1987
|
+
filename: text("filename").notNull().default("screenshot"),
|
|
1988
|
+
mime: text("mime").notNull(),
|
|
1989
|
+
kind: text("kind").$type().notNull().default("image"),
|
|
1990
|
+
sizeBytes: integer("size_bytes").notNull().default(0),
|
|
1452
1991
|
digest: text("digest").notNull(),
|
|
1992
|
+
/** Legacy screenshots stay inline; new uploads write an empty blob. */
|
|
1453
1993
|
bytes: blob("bytes", { mode: "buffer" }).notNull(),
|
|
1994
|
+
/** Relative to the data directory; null means the bytes are still in `bytes`. */
|
|
1995
|
+
storagePath: text("storage_path"),
|
|
1454
1996
|
width: integer("width").notNull(),
|
|
1455
1997
|
height: integer("height").notNull(),
|
|
1998
|
+
status: text("status").$type().notNull().default("ready"),
|
|
1999
|
+
method: text("method").$type().notNull().default("none"),
|
|
2000
|
+
pageCount: integer("page_count"),
|
|
2001
|
+
tokenCount: integer("token_count").notNull().default(0),
|
|
2002
|
+
sectionsJson: text("sections_json"),
|
|
2003
|
+
warningsJson: text("warnings_json"),
|
|
2004
|
+
extractorId: text("extractor_id"),
|
|
2005
|
+
extractorVersion: text("extractor_version"),
|
|
2006
|
+
extractedAt: integer("extracted_at"),
|
|
2007
|
+
/** Stable failure code; never a parser exception message. */
|
|
2008
|
+
errorCode: text("error_code"),
|
|
1456
2009
|
createdAt: integer("created_at").notNull()
|
|
1457
|
-
}, (table) => [uniqueIndex("idx_session_attachments_digest").on(table.sessionId, table.digest)]);
|
|
2010
|
+
}, (table) => [uniqueIndex("idx_session_attachments_digest").on(table.sessionId, table.digest), index("idx_session_attachments_session_created").on(table.sessionId, table.createdAt)]);
|
|
1458
2011
|
const turns = sqliteTable("turns", {
|
|
1459
2012
|
id: text("id").primaryKey(),
|
|
1460
2013
|
sessionId: text("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
|
|
@@ -1469,6 +2022,7 @@ const turns = sqliteTable("turns", {
|
|
|
1469
2022
|
model: text("model"),
|
|
1470
2023
|
thinking: text("thinking"),
|
|
1471
2024
|
contextWindow: integer("context_window"),
|
|
2025
|
+
webSearchEnabled: integer("web_search_enabled", { mode: "boolean" }).notNull().default(false),
|
|
1472
2026
|
status: text("status").$type().notNull(),
|
|
1473
2027
|
inputJson: text("input_json").notNull(),
|
|
1474
2028
|
usageJson: text("usage_json"),
|
|
@@ -1539,6 +2093,18 @@ const credentialProfiles = sqliteTable("credential_profiles", {
|
|
|
1539
2093
|
contextWindow: integer("context_window"),
|
|
1540
2094
|
createdAt: integer("created_at").notNull()
|
|
1541
2095
|
}, (table) => [index("idx_credential_profiles_provider").on(table.provider)]);
|
|
2096
|
+
const WEB_SEARCH_PROVIDER_IDS = ["deepseek", "glm"];
|
|
2097
|
+
const WEB_SEARCH_REGIONS = ["cn", "global"];
|
|
2098
|
+
/** Search credentials are intentionally separate from model credentials. */
|
|
2099
|
+
const webSearchConnections = sqliteTable("web_search_connections", {
|
|
2100
|
+
id: text("id").primaryKey(),
|
|
2101
|
+
provider: text("provider").$type().notNull(),
|
|
2102
|
+
label: text("label").notNull(),
|
|
2103
|
+
region: text("region").$type(),
|
|
2104
|
+
endpoint: text("endpoint").notNull(),
|
|
2105
|
+
secretRef: text("secret_ref").notNull().references(() => secrets.id, { onDelete: "cascade" }),
|
|
2106
|
+
createdAt: integer("created_at").notNull()
|
|
2107
|
+
}, (table) => [index("idx_web_search_connections_provider").on(table.provider)]);
|
|
1542
2108
|
const modelProfiles = sqliteTable("model_profiles", {
|
|
1543
2109
|
id: text("id").primaryKey(),
|
|
1544
2110
|
label: text("label").notNull(),
|
|
@@ -1579,6 +2145,62 @@ const sessionContextSummaries = sqliteTable("session_context_summaries", {
|
|
|
1579
2145
|
reason: text("reason"),
|
|
1580
2146
|
createdAt: integer("created_at").notNull()
|
|
1581
2147
|
}, (table) => [index("idx_context_summaries_session").on(table.sessionId, table.createdAt), index("idx_summaries_session_scope_created").on(table.sessionId, table.scope, table.createdAt)]);
|
|
2148
|
+
const memories = sqliteTable("memories", {
|
|
2149
|
+
id: text("id").primaryKey(),
|
|
2150
|
+
scope: text("scope").$type().notNull(),
|
|
2151
|
+
projectId: text("project_id").references(() => projects.id, { onDelete: "cascade" }),
|
|
2152
|
+
projectKey: text("project_key").notNull(),
|
|
2153
|
+
kind: text("kind").$type().notNull(),
|
|
2154
|
+
key: text("key").notNull(),
|
|
2155
|
+
title: text("title").notNull(),
|
|
2156
|
+
body: text("body").notNull(),
|
|
2157
|
+
status: text("status").$type().notNull(),
|
|
2158
|
+
confidence: real("confidence").notNull(),
|
|
2159
|
+
evidenceKind: text("evidence_kind").$type().notNull(),
|
|
2160
|
+
sourceTurnId: text("source_turn_id"),
|
|
2161
|
+
sourceEventSeq: integer("source_event_seq"),
|
|
2162
|
+
createdBy: text("created_by").$type().notNull(),
|
|
2163
|
+
useCount: integer("use_count").notNull().default(0),
|
|
2164
|
+
lastUsedAt: integer("last_used_at"),
|
|
2165
|
+
lastConfirmedAt: integer("last_confirmed_at"),
|
|
2166
|
+
correctionCount: integer("correction_count").notNull().default(0),
|
|
2167
|
+
pinned: integer("pinned", { mode: "boolean" }).notNull().default(false),
|
|
2168
|
+
bytes: integer("bytes").notNull(),
|
|
2169
|
+
verifiedAt: integer("verified_at"),
|
|
2170
|
+
expiresAt: integer("expires_at"),
|
|
2171
|
+
createdAt: integer("created_at").notNull(),
|
|
2172
|
+
updatedAt: integer("updated_at").notNull()
|
|
2173
|
+
}, (table) => [
|
|
2174
|
+
uniqueIndex("memories_active_key_unique").on(table.scope, table.projectKey, table.key).where(sql`${table.status} = 'active'`),
|
|
2175
|
+
index("idx_memories_scope_project_status").on(table.scope, table.projectId, table.status),
|
|
2176
|
+
index("idx_memories_expires").on(table.expiresAt),
|
|
2177
|
+
check("memories_scope_check", sql`(${table.scope} = 'global' AND ${table.projectId} IS NULL AND ${table.kind} = 'preference') OR (${table.scope} = 'project' AND ${table.projectId} IS NOT NULL)`)
|
|
2178
|
+
]);
|
|
2179
|
+
const memoryRevisions = sqliteTable("memory_revisions", {
|
|
2180
|
+
id: text("id").primaryKey(),
|
|
2181
|
+
memoryId: text("memory_id").notNull().references(() => memories.id, { onDelete: "cascade" }),
|
|
2182
|
+
revision: integer("revision").notNull(),
|
|
2183
|
+
title: text("title").notNull(),
|
|
2184
|
+
body: text("body").notNull(),
|
|
2185
|
+
status: text("status").$type().notNull(),
|
|
2186
|
+
changedBy: text("changed_by").$type().notNull(),
|
|
2187
|
+
changedAt: integer("changed_at").notNull(),
|
|
2188
|
+
reason: text("reason")
|
|
2189
|
+
}, (table) => [uniqueIndex("memory_revisions_unique").on(table.memoryId, table.revision), index("idx_memory_revisions_memory").on(table.memoryId, table.changedAt)]);
|
|
2190
|
+
const memorySuppressions = sqliteTable("memory_suppressions", {
|
|
2191
|
+
id: text("id").primaryKey(),
|
|
2192
|
+
scope: text("scope").$type().notNull(),
|
|
2193
|
+
projectId: text("project_id").references(() => projects.id, { onDelete: "cascade" }),
|
|
2194
|
+
projectKey: text("project_key").notNull(),
|
|
2195
|
+
key: text("key").notNull(),
|
|
2196
|
+
bodyHash: text("body_hash").notNull(),
|
|
2197
|
+
createdAt: integer("created_at").notNull(),
|
|
2198
|
+
expiresAt: integer("expires_at").notNull()
|
|
2199
|
+
}, (table) => [
|
|
2200
|
+
uniqueIndex("memory_suppressions_key_unique").on(table.scope, table.projectKey, table.key),
|
|
2201
|
+
index("idx_memory_suppressions_expiry").on(table.expiresAt),
|
|
2202
|
+
check("memory_suppressions_scope_check", sql`(${table.scope} = 'global' AND ${table.projectId} IS NULL) OR (${table.scope} = 'project' AND ${table.projectId} IS NOT NULL)`)
|
|
2203
|
+
]);
|
|
1582
2204
|
const modelDefaults = sqliteTable("model_defaults", {
|
|
1583
2205
|
id: text("id").primaryKey(),
|
|
1584
2206
|
credentialProfileId: text("credential_profile_id").notNull().references(() => credentialProfiles.id, { onDelete: "cascade" }),
|
|
@@ -2421,4 +3043,4 @@ async function ensureDataDirs(dataDir) {
|
|
|
2421
3043
|
hardened
|
|
2422
3044
|
};
|
|
2423
3045
|
}
|
|
2424
|
-
export {
|
|
3046
|
+
export { secrets as $, FileSaveSchema as $n, GitActionSchema as $t, deploymentArtifacts as A, DEFAULT_APP_CONFIG as An, TerminalInputSchema as At, modelCatalogCache as B, CommandRequestSchema as Bn, ProcessIdSchema as Bt, approvals as C, ServiceActionAuthorizationDtoSchema as Cn, ServiceRegisterInputSchema as Ct, commandExecutions as D, ServiceOpsSubscriptionSchema as Dn, TerminalCreateSchema as Dt, browserSessions as E, ServiceOpsEventPayloadSchema as En, TERMINAL_LEASE_TTL_MS as Et, deviceRequests as F, CommandCancelSchema as Fn, TerminalResizeSchema as Ft, resourceActions as G, normalizeCommandRequest as Gn, MemoryKeySchema as Gt, modelProfiles as H, CommandSubscriptionSchema as Hn, ProcessStatusSchema as Ht, fileVersions as I, CommandIdSchema as In, TerminalSubscriptionSchema as It, resourceOperations as J, FileListQuerySchema as Jn, ReadMemoryInputSchema as Jt, resourceEvents as K, FileActionResultSchema as Kn, MemoryKindSchema as Kt, memories as L, CommandOutputChunkSchema as Ln, TerminalTakeoverSchema as Lt, deploymentBuilds as M, deriveWebAuthn as Mn, TerminalOutputChunkSchema as Mt, deploymentPlans as N, COMMAND_OUTPUT_RETENTION_MS as Nn, TerminalPayloadSchema as Nt, credentialProfiles as O, hasControlCharacters as On, TerminalDevSchema as Ot, deploymentTargets as P, COMMAND_RETENTION_MS as Pn, TerminalRenameSchema as Pt, schema_exports as Q, FileSaveResultSchema as Qn, GitActionDecisionSchema as Qt, memoryRevisions as R, CommandOutputQuerySchema as Rn, PROCESS_OUTPUT_MAX_BYTES as Rt, agentEvents as S, DeploymentTargetRefSchema as Sn, ServiceIdSchema as St, authSettings as T, ServiceControlInputSchema as Tn, ServiceSubscriptionSchema as Tt, modelVisibility as U, MAX_COMMAND_TIMEOUT_MS as Un, StartProcessParamsSchema as Ut, modelDefaults as V, CommandStatusPayloadSchema as Vn, ProcessOutputQuerySchema as Vt, projects as W, ShellCommandParamsSchema as Wn, PlanParamsSchema as Wt, scheduledJobRuns as X, FileReadQuerySchema as Xn, ScheduledJobInputSchema as Xt, resourceStreams as Y, FilePathSchema as Yn, RememberToolInputSchema as Yt, scheduledJobs as Z, FileResultTargetSchema as Zn, ScheduledJobPatchSchema as Zt, getMeta as _, DeploymentPlanDocumentSchema as _n, FileStreamIdSchema as _t, inspectPendingInitialization as a, WORKSPACE_MEMORY_CHANGED as an, isSecretAttachmentName as ar, sessionContextSummaries as at, WEB_SEARCH_PROVIDER_IDS as b, DeploymentTargetIdSchema as bn, ResourceEventsQuerySchema as bt, loadConfig as c, DEPLOYMENT_APPROVAL_TTL_MS as cn, terminals as ct, expectedMigrationCount as d, DEPLOYMENT_ARTIFACT_MAX_PATH as dn, webSearchConnections as dt, GitBranchesQuerySchema as en, FileScopeSchema as er, serviceActionAuthorizations as et, findServerRoot as f, DEPLOYMENT_BUILD_LOG_MAX_BYTES as fn, webauthnChallenges as ft, ensureInstanceId as g, DeploymentAuthorizationScopeSchema as gn, FileResyncPayloadSchema as gt, SUPPORTED_NODE_RANGE as h, DeploymentAuthorizationContextSchema as hn, FileChangedPayloadSchema as ht, inspectDatabase as i, WORKSPACE_JOBS_CHANGED as in, isBlockedAttachmentName as ir, sessionAttachments as it, deploymentAuthorizations as j, OriginUrlSchema as jn, TerminalLeaseSchema as jt, deploymentApprovals as k, AppConfigSchema as kn, TerminalIdSchema as kt, resolveConfig as l, DEPLOYMENT_ARTIFACT_MAX_BYTES as ln, trustedDevices as lt, SERVER_VERSION as m, DeploymentArtifactManifestSchema as mn, newId as mt, ensureDataDirs as n, GitLogQuerySchema as nn, MAX_EDITABLE_FILE_BYTES as nr, serviceOpsServices as nt, recoverInitialization as o, WORKSPACE_SESSIONS_CHANGED as on, isSourceViewMime as or, sessions as ot, runMigrations as p, DEPLOYMENT_PLAN_TTL_MS as pn, webauthnCredentials as pt, resourceLocks as q, FileActionSchema as qn, MemoryStatusSchema as qt, resolveDataDir as r, GitRemoteActionRequestSchema as rn, isAcceptedAttachmentName as rr, services as rt, configFilePath as s, DEFAULT_PROJECT_ID as sn, terminalLeases as st, DATA_SUBDIRS as t, GitDiffQuerySchema as tn, FileSearchQuerySchema as tr, serviceOpsDeployments as tt, appliedMigrationCount as u, DEPLOYMENT_ARTIFACT_MAX_FILES as un, turns as ut, setMeta as v, DeploymentSourceSchema as vn, FileSubscriptionSchema as vt, auditLogs as w, ServiceActionScopeSchema as wn, ServiceStatusSchema as wt, WEB_SEARCH_REGIONS as x, DeploymentTargetNameSchema as xn, ServiceEventPayloadSchema as xt, MODEL_PROVIDER_IDS as y, DeploymentSpecSchema as yn, RESOURCE_EVENT_RETENTION_MS as yt, memorySuppressions as z, CommandParamsSchema as zn, PROCESS_OUTPUT_MAX_CHUNKS as zt };
|