@schlessera/brain-ui-server 0.13.1 → 0.15.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/README.md +51 -12
- package/dist/agent/backend.d.ts +163 -37
- package/dist/agent/backend.d.ts.map +1 -1
- package/dist/agent/backend.js +281 -286
- package/dist/agent/backend.js.map +1 -1
- package/dist/app.d.ts +46 -5
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +94 -35
- package/dist/app.js.map +1 -1
- package/dist/brain/client.d.ts +41 -30
- package/dist/brain/client.d.ts.map +1 -1
- package/dist/brain/client.js +138 -132
- package/dist/brain/client.js.map +1 -1
- package/dist/config/env.d.ts +104 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +296 -0
- package/dist/config/env.js.map +1 -0
- package/dist/cron/scheduler.d.ts +16 -8
- package/dist/cron/scheduler.d.ts.map +1 -1
- package/dist/cron/scheduler.js +54 -53
- package/dist/cron/scheduler.js.map +1 -1
- package/dist/db/brain-db.d.ts +50 -0
- package/dist/db/brain-db.d.ts.map +1 -0
- package/dist/db/brain-db.js +75 -0
- package/dist/db/brain-db.js.map +1 -0
- package/dist/db/client.d.ts +8 -6
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +12 -25
- package/dist/db/client.js.map +1 -1
- package/dist/db/settings.d.ts +5 -4
- package/dist/db/settings.d.ts.map +1 -1
- package/dist/db/settings.js +9 -12
- package/dist/db/settings.js.map +1 -1
- package/dist/files/walker.d.ts +6 -7
- package/dist/files/walker.d.ts.map +1 -1
- package/dist/files/walker.js +6 -9
- package/dist/files/walker.js.map +1 -1
- package/dist/graph/reader.d.ts +6 -6
- package/dist/graph/reader.d.ts.map +1 -1
- package/dist/graph/reader.js +22 -12
- package/dist/graph/reader.js.map +1 -1
- package/dist/index.d.ts +15 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -10
- package/dist/index.js.map +1 -1
- package/dist/middleware/auth.d.ts +17 -6
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +34 -43
- package/dist/middleware/auth.js.map +1 -1
- package/dist/middleware/origin.d.ts +1 -2
- package/dist/middleware/origin.d.ts.map +1 -1
- package/dist/middleware/origin.js +1 -7
- package/dist/middleware/origin.js.map +1 -1
- package/dist/middleware/passkeys.d.ts +29 -5
- package/dist/middleware/passkeys.d.ts.map +1 -1
- package/dist/middleware/passkeys.js +47 -76
- package/dist/middleware/passkeys.js.map +1 -1
- package/dist/middleware/tailscale.d.ts +14 -11
- package/dist/middleware/tailscale.d.ts.map +1 -1
- package/dist/middleware/tailscale.js +11 -10
- package/dist/middleware/tailscale.js.map +1 -1
- package/dist/routes/brain.d.ts +9 -154
- package/dist/routes/brain.d.ts.map +1 -1
- package/dist/routes/brain.js +187 -188
- package/dist/routes/brain.js.map +1 -1
- package/dist/routes/files.d.ts +4 -88
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/files.js +74 -71
- package/dist/routes/files.js.map +1 -1
- package/dist/routes/graph.d.ts +4 -255
- package/dist/routes/graph.d.ts.map +1 -1
- package/dist/routes/graph.js +67 -64
- package/dist/routes/graph.js.map +1 -1
- package/dist/routes/health.d.ts +8 -22
- package/dist/routes/health.d.ts.map +1 -1
- package/dist/routes/health.js +10 -10
- package/dist/routes/health.js.map +1 -1
- package/dist/routes/models.d.ts +7 -90
- package/dist/routes/models.d.ts.map +1 -1
- package/dist/routes/models.js +53 -51
- package/dist/routes/models.js.map +1 -1
- package/dist/routes/providers.d.ts +5 -34
- package/dist/routes/providers.d.ts.map +1 -1
- package/dist/routes/providers.js +13 -11
- package/dist/routes/providers.js.map +1 -1
- package/dist/routes/sessions.d.ts +7 -78
- package/dist/routes/sessions.d.ts.map +1 -1
- package/dist/routes/sessions.js +35 -34
- package/dist/routes/sessions.js.map +1 -1
- package/dist/routes/share.d.ts +7 -60
- package/dist/routes/share.d.ts.map +1 -1
- package/dist/routes/share.js +80 -77
- package/dist/routes/share.js.map +1 -1
- package/dist/routes/voice.d.ts +8 -91
- package/dist/routes/voice.d.ts.map +1 -1
- package/dist/routes/voice.js +62 -59
- package/dist/routes/voice.js.map +1 -1
- package/dist/share/staging.d.ts +4 -4
- package/dist/share/staging.d.ts.map +1 -1
- package/dist/share/staging.js +7 -8
- package/dist/share/staging.js.map +1 -1
- package/dist/voice/deepgram-token.d.ts +1 -1
- package/dist/voice/deepgram-token.d.ts.map +1 -1
- package/dist/voice/deepgram-token.js +1 -2
- package/dist/voice/deepgram-token.js.map +1 -1
- package/dist/voice/keyterm-builder.d.ts +23 -8
- package/dist/voice/keyterm-builder.d.ts.map +1 -1
- package/dist/voice/keyterm-builder.js +67 -43
- package/dist/voice/keyterm-builder.js.map +1 -1
- package/dist/voice/speech-providers.d.ts +6 -4
- package/dist/voice/speech-providers.d.ts.map +1 -1
- package/dist/voice/speech-providers.js +28 -25
- package/dist/voice/speech-providers.js.map +1 -1
- package/dist/ws/bridge.d.ts.map +1 -1
- package/dist/ws/bridge.js +2 -3
- package/dist/ws/bridge.js.map +1 -1
- package/dist/ws/clients.d.ts +18 -10
- package/dist/ws/clients.d.ts.map +1 -1
- package/dist/ws/clients.js +35 -37
- package/dist/ws/clients.js.map +1 -1
- package/dist/ws/connection.d.ts.map +1 -1
- package/dist/ws/connection.js +5 -7
- package/dist/ws/connection.js.map +1 -1
- package/dist/ws/dispatch.d.ts.map +1 -1
- package/dist/ws/dispatch.js +1 -2
- package/dist/ws/dispatch.js.map +1 -1
- package/dist/ws/host.d.ts +16 -12
- package/dist/ws/host.d.ts.map +1 -1
- package/dist/ws/host.js +14 -23
- package/dist/ws/host.js.map +1 -1
- package/dist/ws/routing.d.ts +2 -1
- package/dist/ws/routing.d.ts.map +1 -1
- package/dist/ws/routing.js +5 -6
- package/dist/ws/routing.js.map +1 -1
- package/dist/ws/run-session.js +1 -1
- package/dist/ws/run-session.js.map +1 -1
- package/dist/ws/session-catalog.d.ts +2 -2
- package/dist/ws/session-catalog.d.ts.map +1 -1
- package/dist/ws/session-catalog.js +2 -3
- package/dist/ws/session-catalog.js.map +1 -1
- package/package.json +8 -5
- package/src/agent/backend.ts +509 -340
- package/src/app.ts +157 -36
- package/src/brain/client.ts +166 -143
- package/src/config/env.ts +401 -0
- package/src/cron/scheduler.ts +77 -59
- package/src/db/brain-db.ts +104 -0
- package/src/db/client.ts +12 -31
- package/src/db/settings.ts +12 -14
- package/src/files/walker.ts +6 -10
- package/src/graph/reader.ts +26 -15
- package/src/index.ts +56 -17
- package/src/middleware/auth.ts +51 -45
- package/src/middleware/origin.ts +1 -8
- package/src/middleware/passkeys.ts +72 -68
- package/src/middleware/tailscale.ts +22 -17
- package/src/routes/brain.ts +31 -30
- package/src/routes/files.ts +10 -7
- package/src/routes/graph.ts +9 -6
- package/src/routes/health.ts +17 -10
- package/src/routes/models.ts +19 -15
- package/src/routes/providers.ts +14 -15
- package/src/routes/sessions.ts +18 -11
- package/src/routes/share.ts +35 -24
- package/src/routes/voice.ts +78 -68
- package/src/share/staging.ts +10 -8
- package/src/voice/deepgram-token.ts +4 -2
- package/src/voice/keyterm-builder.ts +90 -56
- package/src/voice/speech-providers.ts +28 -24
- package/src/ws/bridge.ts +2 -3
- package/src/ws/clients.ts +38 -41
- package/src/ws/connection.ts +5 -7
- package/src/ws/dispatch.ts +1 -2
- package/src/ws/host.ts +24 -27
- package/src/ws/routing.ts +6 -10
- package/src/ws/run-session.ts +1 -1
- package/src/ws/session-catalog.ts +2 -3
- package/dist/ws/handler.d.ts +0 -34
- package/dist/ws/handler.d.ts.map +0 -1
- package/dist/ws/handler.js +0 -33
- package/dist/ws/handler.js.map +0 -1
- package/src/ws/handler.ts +0 -50
package/dist/brain/client.js
CHANGED
|
@@ -1,154 +1,160 @@
|
|
|
1
1
|
import { existsSync } from "fs";
|
|
2
2
|
import { join } from "path";
|
|
3
|
-
|
|
3
|
+
import { subprocessEnv } from "../config/env.js";
|
|
4
4
|
/**
|
|
5
|
-
* argv prefix for invoking the brain CLI inside
|
|
5
|
+
* argv prefix for invoking the brain CLI inside `brainPath`.
|
|
6
6
|
*
|
|
7
7
|
* Two brain-repo layouts exist and both must work: a repo that depends on
|
|
8
8
|
* `@schlessera/brain` gets a real bin at `node_modules/.bin/brain`, while the
|
|
9
9
|
* legacy layout vendors `scripts/brain-cli.ts`. Prefer the packaged bin.
|
|
10
10
|
*
|
|
11
|
-
* Resolved per call (a bare `existsSync` stat) rather than at
|
|
11
|
+
* Resolved per call (a bare `existsSync` stat) rather than at construction: in
|
|
12
12
|
* the container the brain repo is cloned and `bun install`ed by entrypoint.sh,
|
|
13
13
|
* and a repo can gain the dependency without restarting this server. The same
|
|
14
14
|
* preference order is mirrored in `scripts/entrypoint.sh`, which links whichever
|
|
15
15
|
* it finds onto PATH for cron.
|
|
16
16
|
*/
|
|
17
|
-
export function brainCliCommand() {
|
|
18
|
-
const packaged = join(
|
|
17
|
+
export function brainCliCommand(brainPath) {
|
|
18
|
+
const packaged = join(brainPath, "node_modules", ".bin", "brain");
|
|
19
19
|
if (existsSync(packaged))
|
|
20
20
|
return [packaged];
|
|
21
21
|
return ["bun", "scripts/brain-cli.ts"];
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
export function createBrainClient(opts) {
|
|
24
|
+
const { brainPath } = opts;
|
|
25
|
+
async function execBrain(args) {
|
|
26
|
+
const proc = Bun.spawn([...brainCliCommand(brainPath), ...args], {
|
|
27
|
+
cwd: brainPath,
|
|
28
|
+
stdout: "pipe",
|
|
29
|
+
stderr: "pipe",
|
|
30
30
|
// Force JSON output when not a TTY
|
|
31
|
-
NO_COLOR: "1",
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return { stdout, stderr, exitCode };
|
|
40
|
-
}
|
|
41
|
-
function parseJsonOutput(result) {
|
|
42
|
-
if (result.exitCode !== 0) {
|
|
43
|
-
throw new Error(`brain CLI failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
return JSON.parse(result.stdout);
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
// Some commands output plain text, not JSON
|
|
50
|
-
return result.stdout;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
export async function brainSearch(query, opts) {
|
|
54
|
-
const args = ["search", query];
|
|
55
|
-
if (opts?.type)
|
|
56
|
-
args.push("--type", opts.type);
|
|
57
|
-
if (opts?.tag)
|
|
58
|
-
args.push("--tag", opts.tag);
|
|
59
|
-
if (opts?.limit)
|
|
60
|
-
args.push("--limit", String(opts.limit));
|
|
61
|
-
if (opts?.mode)
|
|
62
|
-
args.push("--mode", opts.mode);
|
|
63
|
-
const result = await execBrain(args);
|
|
64
|
-
const parsed = parseJsonOutput(result);
|
|
65
|
-
// brain returns {results, warnings} since 22e82e1; tolerate the old bare array
|
|
66
|
-
return Array.isArray(parsed) ? { results: parsed, warnings: [] } : parsed;
|
|
67
|
-
}
|
|
68
|
-
export async function brainBriefing() {
|
|
69
|
-
const result = await execBrain(["briefing"]);
|
|
70
|
-
if (result.exitCode !== 0) {
|
|
71
|
-
throw new Error(`brain briefing failed: ${result.stderr}`);
|
|
72
|
-
}
|
|
73
|
-
return result.stdout;
|
|
74
|
-
}
|
|
75
|
-
export async function brainStats() {
|
|
76
|
-
const result = await execBrain(["stats"]);
|
|
77
|
-
return parseJsonOutput(result);
|
|
78
|
-
}
|
|
79
|
-
export async function brainList(opts) {
|
|
80
|
-
const args = ["list"];
|
|
81
|
-
if (opts?.type)
|
|
82
|
-
args.push("--type", opts.type);
|
|
83
|
-
if (opts?.tag)
|
|
84
|
-
args.push("--tag", opts.tag);
|
|
85
|
-
if (opts?.status)
|
|
86
|
-
args.push("--status", opts.status);
|
|
87
|
-
if (opts?.relevance)
|
|
88
|
-
args.push("--relevance", opts.relevance);
|
|
89
|
-
if (opts?.limit)
|
|
90
|
-
args.push("--limit", String(opts.limit));
|
|
91
|
-
const result = await execBrain(args);
|
|
92
|
-
return parseJsonOutput(result);
|
|
93
|
-
}
|
|
94
|
-
export async function brainRead(path) {
|
|
95
|
-
const result = await execBrain(["read", path]);
|
|
96
|
-
if (result.exitCode !== 0) {
|
|
97
|
-
throw new Error(`brain read failed: ${result.stderr}`);
|
|
98
|
-
}
|
|
99
|
-
return result.stdout;
|
|
100
|
-
}
|
|
101
|
-
export async function brainSync() {
|
|
102
|
-
// Note: brain sync spawns Claude Code internally via the /sync skill.
|
|
103
|
-
// For cron jobs, we use a simpler git-based sync instead.
|
|
104
|
-
const result = await execBrain(["sync"]);
|
|
105
|
-
if (result.exitCode !== 0) {
|
|
106
|
-
return {
|
|
107
|
-
success: false,
|
|
108
|
-
commits: 0,
|
|
109
|
-
conflicts: 0,
|
|
110
|
-
message: result.stderr || result.stdout,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
try {
|
|
114
|
-
return parseJsonOutput(result);
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
return {
|
|
118
|
-
success: true,
|
|
119
|
-
commits: 0,
|
|
120
|
-
conflicts: 0,
|
|
121
|
-
message: result.stdout,
|
|
122
|
-
};
|
|
31
|
+
env: subprocessEnv({ NO_COLOR: "1" }),
|
|
32
|
+
});
|
|
33
|
+
const [stdout, stderr] = await Promise.all([
|
|
34
|
+
new Response(proc.stdout).text(),
|
|
35
|
+
new Response(proc.stderr).text(),
|
|
36
|
+
]);
|
|
37
|
+
const exitCode = await proc.exited;
|
|
38
|
+
return { stdout, stderr, exitCode };
|
|
123
39
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
throw new Error(`brain add failed: ${result.stderr}`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
export async function brainIndex(opts) {
|
|
139
|
-
const args = ["index"];
|
|
140
|
-
if (opts?.force)
|
|
141
|
-
args.push("--force");
|
|
142
|
-
const result = await execBrain(args);
|
|
143
|
-
if (result.exitCode !== 0) {
|
|
144
|
-
throw new Error(`brain index failed: ${result.stderr}`);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
export async function brainValidate() {
|
|
148
|
-
const result = await execBrain(["validate"]);
|
|
149
|
-
if (result.exitCode !== 0) {
|
|
150
|
-
throw new Error(`brain validate failed: ${result.stderr}`);
|
|
40
|
+
function parseJsonOutput(result) {
|
|
41
|
+
if (result.exitCode !== 0) {
|
|
42
|
+
throw new Error(`brain CLI failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(result.stdout);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// Some commands output plain text, not JSON
|
|
49
|
+
return result.stdout;
|
|
50
|
+
}
|
|
151
51
|
}
|
|
152
|
-
return
|
|
52
|
+
return {
|
|
53
|
+
cliCommand() {
|
|
54
|
+
return brainCliCommand(brainPath);
|
|
55
|
+
},
|
|
56
|
+
async search(query, opts) {
|
|
57
|
+
const args = ["search", query];
|
|
58
|
+
if (opts?.type)
|
|
59
|
+
args.push("--type", opts.type);
|
|
60
|
+
if (opts?.tag)
|
|
61
|
+
args.push("--tag", opts.tag);
|
|
62
|
+
if (opts?.limit)
|
|
63
|
+
args.push("--limit", String(opts.limit));
|
|
64
|
+
if (opts?.mode)
|
|
65
|
+
args.push("--mode", opts.mode);
|
|
66
|
+
const result = await execBrain(args);
|
|
67
|
+
const parsed = parseJsonOutput(result);
|
|
68
|
+
// brain returns {results, warnings} since 22e82e1; tolerate the old bare array
|
|
69
|
+
return Array.isArray(parsed) ? { results: parsed, warnings: [] } : parsed;
|
|
70
|
+
},
|
|
71
|
+
async briefing() {
|
|
72
|
+
const result = await execBrain(["briefing"]);
|
|
73
|
+
if (result.exitCode !== 0) {
|
|
74
|
+
throw new Error(`brain briefing failed: ${result.stderr}`);
|
|
75
|
+
}
|
|
76
|
+
return result.stdout;
|
|
77
|
+
},
|
|
78
|
+
async stats() {
|
|
79
|
+
const result = await execBrain(["stats"]);
|
|
80
|
+
return parseJsonOutput(result);
|
|
81
|
+
},
|
|
82
|
+
async list(opts) {
|
|
83
|
+
const args = ["list"];
|
|
84
|
+
if (opts?.type)
|
|
85
|
+
args.push("--type", opts.type);
|
|
86
|
+
if (opts?.tag)
|
|
87
|
+
args.push("--tag", opts.tag);
|
|
88
|
+
if (opts?.status)
|
|
89
|
+
args.push("--status", opts.status);
|
|
90
|
+
if (opts?.relevance)
|
|
91
|
+
args.push("--relevance", opts.relevance);
|
|
92
|
+
if (opts?.limit)
|
|
93
|
+
args.push("--limit", String(opts.limit));
|
|
94
|
+
const result = await execBrain(args);
|
|
95
|
+
return parseJsonOutput(result);
|
|
96
|
+
},
|
|
97
|
+
async read(path) {
|
|
98
|
+
const result = await execBrain(["read", path]);
|
|
99
|
+
if (result.exitCode !== 0) {
|
|
100
|
+
throw new Error(`brain read failed: ${result.stderr}`);
|
|
101
|
+
}
|
|
102
|
+
return result.stdout;
|
|
103
|
+
},
|
|
104
|
+
async sync() {
|
|
105
|
+
// Note: brain sync spawns Claude Code internally via the /sync skill.
|
|
106
|
+
// For cron jobs, we use a simpler git-based sync instead.
|
|
107
|
+
const result = await execBrain(["sync"]);
|
|
108
|
+
if (result.exitCode !== 0) {
|
|
109
|
+
return {
|
|
110
|
+
success: false,
|
|
111
|
+
commits: 0,
|
|
112
|
+
conflicts: 0,
|
|
113
|
+
message: result.stderr || result.stdout,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
return parseJsonOutput(result);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
return {
|
|
121
|
+
success: true,
|
|
122
|
+
commits: 0,
|
|
123
|
+
conflicts: 0,
|
|
124
|
+
message: result.stdout,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
async add(content, opts) {
|
|
129
|
+
const args = ["add", content];
|
|
130
|
+
if (opts?.type)
|
|
131
|
+
args.push("--type", opts.type);
|
|
132
|
+
if (opts?.title)
|
|
133
|
+
args.push("--title", opts.title);
|
|
134
|
+
if (opts?.tags)
|
|
135
|
+
args.push("--tags", opts.tags.join(","));
|
|
136
|
+
const result = await execBrain(args);
|
|
137
|
+
if (result.exitCode !== 0) {
|
|
138
|
+
throw new Error(`brain add failed: ${result.stderr}`);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
async index(opts) {
|
|
142
|
+
const args = ["index"];
|
|
143
|
+
// Full rebuild; indexing is incremental by default since brain 22e82e1.
|
|
144
|
+
if (opts?.force)
|
|
145
|
+
args.push("--force");
|
|
146
|
+
const result = await execBrain(args);
|
|
147
|
+
if (result.exitCode !== 0) {
|
|
148
|
+
throw new Error(`brain index failed: ${result.stderr}`);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
async validate() {
|
|
152
|
+
const result = await execBrain(["validate"]);
|
|
153
|
+
if (result.exitCode !== 0) {
|
|
154
|
+
throw new Error(`brain validate failed: ${result.stderr}`);
|
|
155
|
+
}
|
|
156
|
+
return result.stdout;
|
|
157
|
+
},
|
|
158
|
+
};
|
|
153
159
|
}
|
|
154
160
|
//# sourceMappingURL=client.js.map
|
package/dist/brain/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/brain/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/brain/client.ts"],"names":[],"mappings":"AAAA,OAAO,EA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;YAClD,IAAI,IAAI,EAAE,IAAI;gBAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAEzD,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;YACrC,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,qBAAqB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QAED,KAAK,CAAC,KAAK,CAAC,IAAI;YACd,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;YACvB,wEAAwE;YACxE,IAAI,IAAI,EAAE,KAAK;gBAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAEtC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;YACrC,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;QAED,KAAK,CAAC,QAAQ;YACZ,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;YAC7C,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YAC7D,CAAC;YACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package's ONLY `process.env` reader.
|
|
3
|
+
*
|
|
4
|
+
* Everything `@schlessera/brain-ui-server` can be configured with is declared
|
|
5
|
+
* here twice: once as a runtime descriptor ({@link ENV_VARS}, the artifact the
|
|
6
|
+
* env-parity gate diffs against the documentation) and once as the resolver
|
|
7
|
+
* ({@link resolveServerConfig}) that turns an environment into a plain,
|
|
8
|
+
* fully-resolved {@link ServerConfig}.
|
|
9
|
+
*
|
|
10
|
+
* `createApp()` resolves the environment ONCE, at the edge; every consumer
|
|
11
|
+
* inside the package receives the resolved object (or a slice of it) and never
|
|
12
|
+
* touches `process.env` itself. Tests vary configuration by passing their own
|
|
13
|
+
* env record to the resolver — no global mutation required.
|
|
14
|
+
*/
|
|
15
|
+
export interface EnvVarDescriptor {
|
|
16
|
+
/** The environment variable, exactly as read. */
|
|
17
|
+
name: string;
|
|
18
|
+
/** What it controls. */
|
|
19
|
+
description: string;
|
|
20
|
+
/** Human-readable default applied when unset, or null when there is none. */
|
|
21
|
+
default: string | null;
|
|
22
|
+
/**
|
|
23
|
+
* `false` when optional; otherwise a human-readable statement of the
|
|
24
|
+
* condition under which boot fails without it.
|
|
25
|
+
*/
|
|
26
|
+
required: false | string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Every environment variable this package reads. Order groups by concern.
|
|
30
|
+
* The env-parity gate (G4) asserts this list equals the package's env
|
|
31
|
+
* documentation in both directions — add here and to the docs together.
|
|
32
|
+
*/
|
|
33
|
+
export declare const ENV_VARS: readonly EnvVarDescriptor[];
|
|
34
|
+
export type AuthModeName = "password" | "tailscale" | "proxy" | "none";
|
|
35
|
+
export interface AuthConfig {
|
|
36
|
+
/** Validated AUTH_MODE, or null to auto-detect. */
|
|
37
|
+
mode: AuthModeName | null;
|
|
38
|
+
/** The raw AUTH_MODE value when it did not validate (for the boot warning). */
|
|
39
|
+
invalidMode: string | null;
|
|
40
|
+
passwordHash: string | null;
|
|
41
|
+
cookieSecret: string | null;
|
|
42
|
+
trustProxy: boolean;
|
|
43
|
+
trustProxyHops: number;
|
|
44
|
+
/** Lowercased proxy auth header name. */
|
|
45
|
+
proxyAuthHeader: string;
|
|
46
|
+
dangerouslyDisableAuth: boolean;
|
|
47
|
+
allowPassword: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface WebAuthnConfig {
|
|
50
|
+
rpName: string;
|
|
51
|
+
userName: string;
|
|
52
|
+
userId: string;
|
|
53
|
+
rpId: string | null;
|
|
54
|
+
origins: string[];
|
|
55
|
+
allowLoopbackOrigin: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface AgentConfig {
|
|
58
|
+
/** Trimmed, lowercased AGENT_BACKEND; null when unset (defaults to claude). */
|
|
59
|
+
backend: string | null;
|
|
60
|
+
claudeCodePath: string;
|
|
61
|
+
defaultModel: string;
|
|
62
|
+
/** Raw BRAIN_UI_CLAUDE_PROFILES JSON, parsed lazily by the registry. */
|
|
63
|
+
profilesJson: string | null;
|
|
64
|
+
modelDiscovery: boolean;
|
|
65
|
+
modelTtlMs: number;
|
|
66
|
+
}
|
|
67
|
+
export interface VoiceConfig {
|
|
68
|
+
/** Trimmed, lowercased VOICE_PROVIDER; null when unset (auto-detect). */
|
|
69
|
+
provider: string | null;
|
|
70
|
+
deepgramApiKey: string | null;
|
|
71
|
+
keytermLimit: number;
|
|
72
|
+
/** Resolved keyterm cache directory. */
|
|
73
|
+
cacheDir: string;
|
|
74
|
+
}
|
|
75
|
+
/** Fully-resolved server configuration. Plain data — safe to construct in tests. */
|
|
76
|
+
export interface ServerConfig {
|
|
77
|
+
brainPath: string;
|
|
78
|
+
dbPath: string;
|
|
79
|
+
/** Bind host, for the loopback check in auth validation. Empty when unset. */
|
|
80
|
+
host: string;
|
|
81
|
+
sourceCommit: string;
|
|
82
|
+
allowedOrigins: string[];
|
|
83
|
+
maxConcurrentSessions: number;
|
|
84
|
+
auth: AuthConfig;
|
|
85
|
+
webauthn: WebAuthnConfig;
|
|
86
|
+
agent: AgentConfig;
|
|
87
|
+
voice: VoiceConfig;
|
|
88
|
+
}
|
|
89
|
+
type EnvRecord = Record<string, string | undefined>;
|
|
90
|
+
/**
|
|
91
|
+
* Resolve an environment into a {@link ServerConfig}. Defaults to the real
|
|
92
|
+
* process environment; tests pass their own record instead of mutating it.
|
|
93
|
+
*/
|
|
94
|
+
export declare function resolveServerConfig(env?: EnvRecord): ServerConfig;
|
|
95
|
+
/**
|
|
96
|
+
* The parent environment for spawned subprocesses (brain CLI, whatsup), plus
|
|
97
|
+
* overrides. Child processes legitimately inherit the whole environment
|
|
98
|
+
* (PATH, credentials for the tools they run) — that is process plumbing, not
|
|
99
|
+
* configuration, but it still reads `process.env`, so it lives behind this
|
|
100
|
+
* chokepoint.
|
|
101
|
+
*/
|
|
102
|
+
export declare function subprocessEnv(extra?: Record<string, string>): EnvRecord;
|
|
103
|
+
export {};
|
|
104
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB;;;OAGG;IACH,QAAQ,EAAE,KAAK,GAAG,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,gBAAgB,EAkNtC,CAAC;AAIX,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAEvE,MAAM,WAAW,UAAU;IACzB,mDAAmD;IACnD,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC1B,+EAA+E;IAC/E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,E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