@causyne/agent 1.20.127 → 1.20.128

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/docs/THIRD_PARTY_NOTICES.md +36 -2
  2. package/package.json +3 -1
  3. package/src/agentLoop.js +59 -26
  4. package/src/agentLoop.ts +59 -24
  5. package/src/browser/causyneBrowser.js +31 -0
  6. package/src/browser/causyneBrowser.ts +32 -0
  7. package/src/commands.js +177 -13
  8. package/src/commands.ts +194 -13
  9. package/src/memory/episodicStore.js +40 -0
  10. package/src/memory/episodicStore.ts +46 -0
  11. package/src/memory.js +67 -0
  12. package/src/memory.ts +65 -0
  13. package/src/personalization.js +365 -0
  14. package/src/personalization.ts +471 -0
  15. package/src/projectInstructions.js +30 -10
  16. package/src/projectInstructions.ts +31 -12
  17. package/src/providers/acp.js +3 -2
  18. package/src/providers/acp.ts +3 -2
  19. package/src/providers/antigravity.js +2 -0
  20. package/src/providers/antigravity.ts +2 -0
  21. package/src/tools/memoryWrite.js +15 -1
  22. package/src/tools/memoryWrite.ts +16 -1
  23. package/src/tools/osSandbox.js +1 -1
  24. package/src/tools/osSandbox.ts +1 -1
  25. package/src/tools/ptyTerminal.js +17 -5
  26. package/src/tools/ptyTerminal.ts +19 -5
  27. package/src/web/client/browserPanel.js +234 -31
  28. package/src/web/client/browserPanel.ts +240 -31
  29. package/src/web/client/chatStream.js +19 -7
  30. package/src/web/client/chatStream.ts +17 -9
  31. package/src/web/client/cliPanel.js +3 -3
  32. package/src/web/client/cliPanel.ts +3 -3
  33. package/src/web/client/dom.js +53 -2
  34. package/src/web/client/dom.ts +54 -3
  35. package/src/web/client/filesAndCanvas.js +3 -1
  36. package/src/web/client/filesAndCanvas.ts +3 -1
  37. package/src/web/client/main.js +28 -13
  38. package/src/web/client/main.ts +35 -12
  39. package/src/web/client/settingsModal.js +641 -8
  40. package/src/web/client/settingsModal.ts +791 -8
  41. package/src/web/client/state.js +31 -1
  42. package/src/web/client/state.ts +27 -1
  43. package/src/web/client/studioLayout.js +39 -4
  44. package/src/web/client/studioLayout.ts +47 -4
  45. package/src/web/client/studioShell.js +370 -37
  46. package/src/web/client/studioShell.ts +368 -36
  47. package/src/web/client/terminalPanel.js +378 -129
  48. package/src/web/client/terminalPanel.ts +394 -107
  49. package/src/web/client/terminalTheme.js +249 -0
  50. package/src/web/client/terminalTheme.ts +258 -0
  51. package/src/web/client/types.ts +3 -0
  52. package/src/web/client/validators.js +51 -10
  53. package/src/web/client/validators.ts +54 -10
  54. package/src/web/server/routesBrowser.js +64 -10
  55. package/src/web/server/routesBrowser.ts +62 -13
  56. package/src/web/server/routesSettings.js +344 -0
  57. package/src/web/server/routesSettings.ts +397 -0
  58. package/src/web/server/staticAssets.js +24 -0
  59. package/src/web/server/staticAssets.ts +25 -0
  60. package/src/web/skybridgeServer.js +3 -0
  61. package/src/web/skybridgeServer.ts +2 -0
  62. package/src/web/skybridgeUi.js +5 -1
  63. package/src/web/skybridgeUi.ts +8 -1
  64. package/src/web/styles/overlays.css +499 -0
  65. package/src/web/styles/studio.css +274 -46
  66. package/src/web/ui/modalsTemplate.js +320 -71
  67. package/src/web/ui/modalsTemplate.ts +320 -71
  68. package/src/web/ui/studioTemplate.js +19 -21
  69. package/src/web/ui/studioTemplate.ts +19 -21
@@ -0,0 +1,397 @@
1
+ import type http from 'node:http';
2
+ import path from 'node:path';
3
+ import { loadConfig, resolveProviderApiKey, saveConfig } from '../../config.js';
4
+ import { DEFAULT_MODEL_BY_PROVIDER } from '../../modelCatalogue.js';
5
+ import {
6
+ getDefaultPermissionPreset,
7
+ normalizePermissionPreset,
8
+ setDefaultPermissionPreset
9
+ } from '../../permissionPresets.js';
10
+ import { probeOsSandbox, resolveOsSandboxMode } from '../../tools/osSandbox.js';
11
+ import {
12
+ deleteCausyneMemories,
13
+ readPersonalizationOverview,
14
+ saveMemoryPreferences,
15
+ savePersonalizationInstructions,
16
+ type PersonalizationScope
17
+ } from '../../personalization.js';
18
+ import { discoverProjectMcpServers, serverStatus } from '../../mcp/mcpRegistry.js';
19
+ import { disablePlugin, enablePlugin, listPlugins, PLUGIN_ROOT } from '../../plugins/pluginManager.js';
20
+ import { auditLog } from '../../auditLog.js';
21
+ import { readJsonBody, sendJson } from './security.js';
22
+ import type { SkybridgeContext } from './types.js';
23
+
24
+ const VAULT_PROVIDER_IDS = [
25
+ 'deepseek',
26
+ 'qwen',
27
+ 'dashscope-byok',
28
+ 'anthropic',
29
+ 'openai',
30
+ 'gemini',
31
+ 'moonshot',
32
+ 'xai',
33
+ 'openrouter',
34
+ 'groq',
35
+ 'cerebras',
36
+ 'mistral'
37
+ ] as const;
38
+
39
+ const ALLOWED_OS_SANDBOX_MODES = new Set([
40
+ 'off',
41
+ 'workspace-write',
42
+ 'strict',
43
+ 'read-only',
44
+ 'read-only-strict'
45
+ ]);
46
+
47
+ const ALLOWED_EFFORT_LEVELS = new Set(['', 'off', 'low', 'medium', 'high', 'max']);
48
+
49
+ function buildHooksOverview(config: Record<string, unknown>): Array<{
50
+ index: number;
51
+ name: string;
52
+ event: string;
53
+ tools: string[];
54
+ commandPreview: string;
55
+ timeoutMs: number;
56
+ enabled: boolean;
57
+ }> {
58
+ const rawHooks = Array.isArray(config.hooks) ? config.hooks : [];
59
+ const items: Array<{
60
+ index: number;
61
+ name: string;
62
+ event: string;
63
+ tools: string[];
64
+ commandPreview: string;
65
+ timeoutMs: number;
66
+ enabled: boolean;
67
+ }> = [];
68
+ for (let i = 0; i < rawHooks.length && i < 64; i++) {
69
+ const entry = rawHooks[i];
70
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry)) continue;
71
+ const rec = entry as Record<string, unknown>;
72
+ const event = typeof rec.event === 'string' && rec.event.trim() ? rec.event.trim() : 'PreToolUse';
73
+ const tools = Array.isArray(rec.tools)
74
+ ? rec.tools.filter((t): t is string => typeof t === 'string' && t.trim().length > 0)
75
+ : [typeof rec.tool === 'string' && rec.tool.trim() ? rec.tool.trim() : '*'];
76
+ const command = Array.isArray(rec.command)
77
+ ? rec.command.map((c) => String(c)).join(' ')
78
+ : '';
79
+ const name = typeof rec.name === 'string' && rec.name.trim()
80
+ ? rec.name.trim().slice(0, 120)
81
+ : `${event}:${tools[0] || '*'}`;
82
+ const timeoutMs = typeof rec.timeoutMs === 'number' && Number.isFinite(rec.timeoutMs)
83
+ ? Math.max(100, Math.min(10_000, Math.round(rec.timeoutMs)))
84
+ : 5_000;
85
+ items.push({
86
+ index: i,
87
+ name,
88
+ event,
89
+ tools,
90
+ commandPreview: command.slice(0, 180),
91
+ timeoutMs,
92
+ enabled: rec.enabled !== false
93
+ });
94
+ }
95
+ return items;
96
+ }
97
+
98
+ function buildSettingsOverviewPayload(ctx: SkybridgeContext): Record<string, unknown> {
99
+ const config = loadConfig();
100
+ const osSandboxCap = probeOsSandbox();
101
+ const osSandboxResolved = resolveOsSandboxMode(process.env, config.osSandbox);
102
+ const configuredOsSandbox = typeof config.osSandbox === 'string' && ALLOWED_OS_SANDBOX_MODES.has(config.osSandbox.trim().toLowerCase())
103
+ ? config.osSandbox.trim().toLowerCase()
104
+ : 'workspace-write';
105
+
106
+ const rawBudget = config.tokenBudget && typeof config.tokenBudget === 'object' && !Array.isArray(config.tokenBudget)
107
+ ? (config.tokenBudget as Record<string, unknown>)
108
+ : {};
109
+ const tokenBudget = {
110
+ enabled: rawBudget.enabled === true,
111
+ maxTokensPerTask: typeof rawBudget.maxTokensPerTask === 'number' && Number.isFinite(rawBudget.maxTokensPerTask)
112
+ ? Math.max(1000, Math.round(rawBudget.maxTokensPerTask))
113
+ : 150000,
114
+ maxTokensPerDay: typeof rawBudget.maxTokensPerDay === 'number' && Number.isFinite(rawBudget.maxTokensPerDay)
115
+ ? Math.max(1000, Math.round(rawBudget.maxTokensPerDay))
116
+ : 1000000,
117
+ maxCostUsd: typeof rawBudget.maxCostUsd === 'number' && Number.isFinite(rawBudget.maxCostUsd)
118
+ ? Math.max(0.1, Number(rawBudget.maxCostUsd))
119
+ : 5,
120
+ hardStop: rawBudget.hardStop === true
121
+ };
122
+
123
+ const rawCompact = config.contextCompaction && typeof config.contextCompaction === 'object' && !Array.isArray(config.contextCompaction)
124
+ ? (config.contextCompaction as Record<string, unknown>)
125
+ : {};
126
+ const autoCompact = {
127
+ enabled: rawCompact.enabled !== false,
128
+ thresholdPercent: typeof rawCompact.thresholdPercent === 'number' && Number.isFinite(rawCompact.thresholdPercent)
129
+ ? Math.max(40, Math.min(95, Math.round(rawCompact.thresholdPercent)))
130
+ : 78
131
+ };
132
+
133
+ const configuredProviders = VAULT_PROVIDER_IDS.filter((id) => Boolean(resolveProviderApiKey(config, id)));
134
+ const projectMcp = discoverProjectMcpServers(ctx.workspaceRoot);
135
+
136
+ let pluginItems: ReturnType<typeof listPlugins> = [];
137
+ try {
138
+ pluginItems = listPlugins();
139
+ } catch {
140
+ pluginItems = [];
141
+ }
142
+
143
+ return {
144
+ ok: true,
145
+ general: {
146
+ workspaceRoot: ctx.workspaceRoot,
147
+ workspaceName: path.basename(ctx.workspaceRoot),
148
+ version: ctx.version,
149
+ platform: process.platform,
150
+ provider: config.provider || 'unconfigured',
151
+ model: config.model || DEFAULT_MODEL_BY_PROVIDER[String(config.provider || '')] || 'default'
152
+ },
153
+ configuration: {
154
+ defaultPermissionPreset: getDefaultPermissionPreset(),
155
+ reasoningEffort: typeof config.reasoningEffort === 'string' ? config.reasoningEffort.trim().toLowerCase() : '',
156
+ osSandbox: {
157
+ configuredMode: configuredOsSandbox,
158
+ effectiveMode: osSandboxResolved.mode,
159
+ strict: osSandboxResolved.strict,
160
+ allowNetwork: osSandboxResolved.allowNetwork,
161
+ backend: osSandboxCap.backend,
162
+ available: osSandboxCap.available,
163
+ reason: osSandboxCap.reason
164
+ },
165
+ tokenBudget,
166
+ autoCompact
167
+ },
168
+ personalization: readPersonalizationOverview(ctx.workspaceRoot),
169
+ vault: {
170
+ activeProvider: config.provider || '',
171
+ configuredProviders
172
+ },
173
+ mcp: {
174
+ servers: serverStatus(),
175
+ projectDiscovered: projectMcp.servers.map((srv) => ({
176
+ name: srv.name,
177
+ transport: srv.url ? 'http' : 'stdio',
178
+ target: srv.url ?? [srv.command, ...(srv.args ?? [])].filter(Boolean).join(' ')
179
+ })),
180
+ projectWarnings: projectMcp.warnings,
181
+ projectFile: projectMcp.filePath
182
+ },
183
+ hooks: buildHooksOverview(config),
184
+ plugins: {
185
+ root: PLUGIN_ROOT,
186
+ items: pluginItems
187
+ }
188
+ };
189
+ }
190
+
191
+ function invalidateActiveLoopStaticContexts(ctx: SkybridgeContext): void {
192
+ for (const run of ctx.activeRuns.values()) {
193
+ const loopObj = run.loop as unknown as { staticContext?: unknown };
194
+ if (loopObj && typeof loopObj === 'object' && 'staticContext' in loopObj) {
195
+ loopObj.staticContext = null;
196
+ }
197
+ }
198
+ }
199
+
200
+ export async function handleSettingsRoutes(
201
+ req: http.IncomingMessage,
202
+ res: http.ServerResponse,
203
+ parsedUrl: URL,
204
+ ctx: SkybridgeContext
205
+ ): Promise<boolean> {
206
+ const pathname = parsedUrl.pathname;
207
+
208
+ if (req.method === 'GET' && pathname === '/api/settings/overview') {
209
+ sendJson(res, 200, buildSettingsOverviewPayload(ctx));
210
+ return true;
211
+ }
212
+
213
+ if (req.method === 'POST' && pathname === '/api/settings/configuration') {
214
+ const body = await readJsonBody(req);
215
+ const config = loadConfig();
216
+
217
+ if (body.defaultPermissionPreset !== undefined) {
218
+ const preset = normalizePermissionPreset(body.defaultPermissionPreset);
219
+ if (!preset) {
220
+ sendJson(res, 400, { error: 'Invalid defaultPermissionPreset value.' });
221
+ return true;
222
+ }
223
+ setDefaultPermissionPreset(preset);
224
+ config.defaultPermissionPreset = preset;
225
+ }
226
+
227
+ if (typeof body.osSandbox === 'string') {
228
+ const mode = body.osSandbox.trim().toLowerCase();
229
+ if (!ALLOWED_OS_SANDBOX_MODES.has(mode)) {
230
+ sendJson(res, 400, { error: 'Invalid osSandbox mode.' });
231
+ return true;
232
+ }
233
+ config.osSandbox = mode;
234
+ }
235
+
236
+ if (typeof body.reasoningEffort === 'string') {
237
+ const effort = body.reasoningEffort.trim().toLowerCase();
238
+ if (!ALLOWED_EFFORT_LEVELS.has(effort)) {
239
+ sendJson(res, 400, { error: 'Invalid reasoningEffort level.' });
240
+ return true;
241
+ }
242
+ if (!effort) delete config.reasoningEffort;
243
+ else config.reasoningEffort = effort;
244
+ }
245
+
246
+ if (body.tokenBudget && typeof body.tokenBudget === 'object' && !Array.isArray(body.tokenBudget)) {
247
+ const raw = body.tokenBudget as Record<string, unknown>;
248
+ const prev = config.tokenBudget && typeof config.tokenBudget === 'object'
249
+ ? (config.tokenBudget as Record<string, unknown>)
250
+ : {};
251
+ const nextBudget: Record<string, unknown> = { ...prev };
252
+ if (typeof raw.enabled === 'boolean') nextBudget.enabled = raw.enabled;
253
+ if (typeof raw.hardStop === 'boolean') nextBudget.hardStop = raw.hardStop;
254
+ if (typeof raw.maxTokensPerTask === 'number' && Number.isFinite(raw.maxTokensPerTask)) {
255
+ nextBudget.maxTokensPerTask = Math.max(1000, Math.min(100_000_000, Math.round(raw.maxTokensPerTask)));
256
+ }
257
+ if (typeof raw.maxTokensPerDay === 'number' && Number.isFinite(raw.maxTokensPerDay)) {
258
+ nextBudget.maxTokensPerDay = Math.max(1000, Math.min(1_000_000_000, Math.round(raw.maxTokensPerDay)));
259
+ }
260
+ if (typeof raw.maxCostUsd === 'number' && Number.isFinite(raw.maxCostUsd)) {
261
+ nextBudget.maxCostUsd = Math.max(0.1, Math.min(10_000, Number(raw.maxCostUsd.toFixed(2))));
262
+ }
263
+ config.tokenBudget = nextBudget;
264
+ }
265
+
266
+ if (body.autoCompact && typeof body.autoCompact === 'object' && !Array.isArray(body.autoCompact)) {
267
+ const raw = body.autoCompact as Record<string, unknown>;
268
+ const prev = config.contextCompaction && typeof config.contextCompaction === 'object'
269
+ ? (config.contextCompaction as Record<string, unknown>)
270
+ : {};
271
+ const nextCompact: Record<string, unknown> = { ...prev };
272
+ if (typeof raw.enabled === 'boolean') nextCompact.enabled = raw.enabled;
273
+ if (typeof raw.thresholdPercent === 'number' && Number.isFinite(raw.thresholdPercent)) {
274
+ nextCompact.thresholdPercent = Math.max(40, Math.min(95, Math.round(raw.thresholdPercent)));
275
+ }
276
+ config.contextCompaction = nextCompact;
277
+ }
278
+
279
+ saveConfig(config);
280
+ auditLog.log({ event: 'skybridge_configuration_updated' });
281
+ sendJson(res, 200, buildSettingsOverviewPayload(ctx));
282
+ return true;
283
+ }
284
+
285
+ if (req.method === 'POST' && pathname === '/api/settings/personalization') {
286
+ const body = await readJsonBody(req);
287
+ const scope: PersonalizationScope = body.scope === 'global' ? 'global' : 'project';
288
+
289
+ try {
290
+ if (typeof body.instructions === 'string') {
291
+ savePersonalizationInstructions(ctx.workspaceRoot, scope, body.instructions);
292
+ }
293
+
294
+ const memPatch: { enabled?: boolean | null | undefined; allowToolAssisted?: boolean | null | undefined } = {};
295
+ if (typeof body.memoryEnabled === 'boolean' || body.memoryEnabled === null) {
296
+ memPatch.enabled = body.memoryEnabled;
297
+ }
298
+ if (typeof body.allowToolAssisted === 'boolean' || body.allowToolAssisted === null) {
299
+ memPatch.allowToolAssisted = body.allowToolAssisted;
300
+ }
301
+ if (memPatch.enabled !== undefined || memPatch.allowToolAssisted !== undefined) {
302
+ saveMemoryPreferences(ctx.workspaceRoot, scope, memPatch);
303
+ }
304
+
305
+ invalidateActiveLoopStaticContexts(ctx);
306
+ auditLog.log({
307
+ event: 'skybridge_personalization_updated',
308
+ scope,
309
+ updatedInstructions: typeof body.instructions === 'string',
310
+ updatedMemory: memPatch.enabled !== undefined || memPatch.allowToolAssisted !== undefined
311
+ });
312
+ sendJson(res, 200, {
313
+ ok: true,
314
+ scope,
315
+ personalization: readPersonalizationOverview(ctx.workspaceRoot)
316
+ });
317
+ return true;
318
+ } catch (err: unknown) {
319
+ const rawMsg = err instanceof Error ? err.message : '';
320
+ const safeMsg = rawMsg.includes('exceed maximum size')
321
+ ? 'Personalization instructions exceed the 16 KB limit.'
322
+ : rawMsg.includes('symlink')
323
+ ? 'Refusing to write personalization through a symbolic link.'
324
+ : 'Could not save personalization settings.';
325
+ sendJson(res, 400, { error: safeMsg });
326
+ return true;
327
+ }
328
+ }
329
+
330
+ if (req.method === 'POST' && pathname === '/api/settings/memories/delete') {
331
+ const body = await readJsonBody(req);
332
+ const scope = body.scope === 'all' ? 'all' : 'project';
333
+ const result = deleteCausyneMemories(ctx.workspaceRoot, scope);
334
+ invalidateActiveLoopStaticContexts(ctx);
335
+ auditLog.log({
336
+ event: 'skybridge_memories_deleted',
337
+ scope,
338
+ factsRemoved: result.factsRemoved,
339
+ observationsRemoved: result.observationsRemoved,
340
+ summariesRemoved: result.summariesRemoved
341
+ });
342
+ sendJson(res, 200, {
343
+ ok: true,
344
+ ...result,
345
+ personalization: readPersonalizationOverview(ctx.workspaceRoot)
346
+ });
347
+ return true;
348
+ }
349
+
350
+ if (req.method === 'POST' && pathname === '/api/settings/hooks/toggle') {
351
+ const body = await readJsonBody(req);
352
+ const index = typeof body.index === 'number' && Number.isInteger(body.index) ? body.index : -1;
353
+ const enabled = typeof body.enabled === 'boolean' ? body.enabled : null;
354
+ if (index < 0 || enabled === null) {
355
+ sendJson(res, 400, { error: 'Valid hook index and boolean enabled flag are required.' });
356
+ return true;
357
+ }
358
+ const config = loadConfig();
359
+ if (!Array.isArray(config.hooks) || index >= config.hooks.length) {
360
+ sendJson(res, 404, { error: 'Configured hook entry not found.' });
361
+ return true;
362
+ }
363
+ const target = config.hooks[index];
364
+ if (!target || typeof target !== 'object' || Array.isArray(target)) {
365
+ sendJson(res, 400, { error: 'Hook entry is malformed.' });
366
+ return true;
367
+ }
368
+ (target as Record<string, unknown>).enabled = enabled;
369
+ saveConfig(config);
370
+ auditLog.log({ event: 'skybridge_hook_toggled', index, enabled });
371
+ sendJson(res, 200, { ok: true, hooks: buildHooksOverview(config) });
372
+ return true;
373
+ }
374
+
375
+ if (req.method === 'POST' && pathname === '/api/settings/plugins/toggle') {
376
+ const body = await readJsonBody(req);
377
+ const name = typeof body.name === 'string' ? body.name.trim() : '';
378
+ const enabled = typeof body.enabled === 'boolean' ? body.enabled : null;
379
+ if (!name || enabled === null) {
380
+ sendJson(res, 400, { error: 'Valid plugin name and boolean enabled flag are required.' });
381
+ return true;
382
+ }
383
+ const outcome = enabled ? enablePlugin(name) : disablePlugin(name);
384
+ if (!outcome.ok) {
385
+ sendJson(res, 400, { error: 'Could not update plugin trust state.' });
386
+ return true;
387
+ }
388
+ auditLog.log({ event: 'skybridge_plugin_toggled', name, enabled });
389
+ sendJson(res, 200, {
390
+ ok: true,
391
+ plugins: { root: PLUGIN_ROOT, items: listPlugins() }
392
+ });
393
+ return true;
394
+ }
395
+
396
+ return false;
397
+ }
@@ -1,6 +1,8 @@
1
1
  import fs from 'node:fs';
2
+ import { createRequire } from 'node:module';
2
3
  import { fileURLToPath } from 'node:url';
3
4
  export const SKYBRIDGE_STYLESHEET_URLS = [
5
+ '/assets/vendor/xterm.css',
4
6
  '/assets/styles/tokens.css',
5
7
  '/assets/styles/shell.css',
6
8
  '/assets/styles/thread.css',
@@ -9,6 +11,10 @@ export const SKYBRIDGE_STYLESHEET_URLS = [
9
11
  '/assets/styles/studio.css',
10
12
  '/assets/styles/overlays.css'
11
13
  ];
14
+ export const SKYBRIDGE_VENDOR_SCRIPT_URLS = [
15
+ '/assets/vendor/xterm.js',
16
+ '/assets/vendor/addon-fit.js'
17
+ ];
12
18
  export const SKYBRIDGE_CLIENT_MODULE_FILES = [
13
19
  'types.js',
14
20
  'dom.js',
@@ -23,6 +29,7 @@ export const SKYBRIDGE_CLIENT_MODULE_FILES = [
23
29
  'filesAndCanvas.js',
24
30
  'diffPanel.js',
25
31
  'browserPanel.js',
32
+ 'terminalTheme.js',
26
33
  'terminalPanel.js',
27
34
  'cliPanel.js',
28
35
  'gameLauncherUi.js',
@@ -36,6 +43,23 @@ export const SKYBRIDGE_CLIENT_MODULE_FILES = [
36
43
  ];
37
44
  const STATIC_ASSET_MAP = (() => {
38
45
  const map = new Map();
46
+ const req = createRequire(import.meta.url);
47
+ const vendorEntries = [
48
+ ['/assets/vendor/xterm.css', '@xterm/xterm/css/xterm.css', 'text/css; charset=utf-8'],
49
+ ['/assets/vendor/xterm.js', '@xterm/xterm/lib/xterm.js', 'text/javascript; charset=utf-8'],
50
+ ['/assets/vendor/addon-fit.js', '@xterm/addon-fit/lib/addon-fit.js', 'text/javascript; charset=utf-8']
51
+ ];
52
+ for (const [route, pkgSpecifier, contentType] of vendorEntries) {
53
+ try {
54
+ map.set(route, {
55
+ filePath: req.resolve(pkgSpecifier),
56
+ contentType
57
+ });
58
+ }
59
+ catch {
60
+ // Vendor asset unavailable in minimal test install; handled cleanly with 404.
61
+ }
62
+ }
39
63
  const styleFiles = [
40
64
  'tokens.css',
41
65
  'shell.css',
@@ -1,5 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import type http from 'node:http';
3
+ import { createRequire } from 'node:module';
3
4
  import { fileURLToPath } from 'node:url';
4
5
 
5
6
  interface StaticAssetEntry {
@@ -8,6 +9,7 @@ interface StaticAssetEntry {
8
9
  }
9
10
 
10
11
  export const SKYBRIDGE_STYLESHEET_URLS: readonly string[] = [
12
+ '/assets/vendor/xterm.css',
11
13
  '/assets/styles/tokens.css',
12
14
  '/assets/styles/shell.css',
13
15
  '/assets/styles/thread.css',
@@ -17,6 +19,11 @@ export const SKYBRIDGE_STYLESHEET_URLS: readonly string[] = [
17
19
  '/assets/styles/overlays.css'
18
20
  ];
19
21
 
22
+ export const SKYBRIDGE_VENDOR_SCRIPT_URLS: readonly string[] = [
23
+ '/assets/vendor/xterm.js',
24
+ '/assets/vendor/addon-fit.js'
25
+ ];
26
+
20
27
  export const SKYBRIDGE_CLIENT_MODULE_FILES: readonly string[] = [
21
28
  'types.js',
22
29
  'dom.js',
@@ -31,6 +38,7 @@ export const SKYBRIDGE_CLIENT_MODULE_FILES: readonly string[] = [
31
38
  'filesAndCanvas.js',
32
39
  'diffPanel.js',
33
40
  'browserPanel.js',
41
+ 'terminalTheme.js',
34
42
  'terminalPanel.js',
35
43
  'cliPanel.js',
36
44
  'gameLauncherUi.js',
@@ -45,6 +53,23 @@ export const SKYBRIDGE_CLIENT_MODULE_FILES: readonly string[] = [
45
53
 
46
54
  const STATIC_ASSET_MAP: ReadonlyMap<string, StaticAssetEntry> = (() => {
47
55
  const map = new Map<string, StaticAssetEntry>();
56
+ const req = createRequire(import.meta.url);
57
+ const vendorEntries: ReadonlyArray<readonly [string, string, string]> = [
58
+ ['/assets/vendor/xterm.css', '@xterm/xterm/css/xterm.css', 'text/css; charset=utf-8'],
59
+ ['/assets/vendor/xterm.js', '@xterm/xterm/lib/xterm.js', 'text/javascript; charset=utf-8'],
60
+ ['/assets/vendor/addon-fit.js', '@xterm/addon-fit/lib/addon-fit.js', 'text/javascript; charset=utf-8']
61
+ ];
62
+ for (const [route, pkgSpecifier, contentType] of vendorEntries) {
63
+ try {
64
+ map.set(route, {
65
+ filePath: req.resolve(pkgSpecifier),
66
+ contentType
67
+ });
68
+ } catch {
69
+ // Vendor asset unavailable in minimal test install; handled cleanly with 404.
70
+ }
71
+ }
72
+
48
73
  const styleFiles = [
49
74
  'tokens.css',
50
75
  'shell.css',
@@ -17,6 +17,7 @@ import { serveStaticAsset } from './server/staticAssets.js';
17
17
  import { extractSessionFileEvidence, extractSessionTouchedFiles, normalizeWorkspaceRelCandidate } from './server/sessionTranscript.js';
18
18
  import { attachRunStream, createDefaultLoopFactory, pushRunFrame } from './server/activeRuns.js';
19
19
  import { handleCoreRoutes } from './server/routesCore.js';
20
+ import { handleSettingsRoutes } from './server/routesSettings.js';
20
21
  import { handleWorkspaceRoutes } from './server/routesWorkspace.js';
21
22
  import { handleBrowserRoutes } from './server/routesBrowser.js';
22
23
  import { handleTerminalRoutes } from './server/routesTerminal.js';
@@ -168,6 +169,8 @@ export async function startSkybridgeServer(options = {}) {
168
169
  try {
169
170
  if (await handleCoreRoutes(req, res, parsedUrl, ctx))
170
171
  return;
172
+ if (await handleSettingsRoutes(req, res, parsedUrl, ctx))
173
+ return;
171
174
  if (await handleWorkspaceRoutes(req, res, parsedUrl, ctx))
172
175
  return;
173
176
  if (await handleBrowserRoutes(req, res, parsedUrl, ctx))
@@ -34,6 +34,7 @@ import {
34
34
  pushRunFrame
35
35
  } from './server/activeRuns.js';
36
36
  import { handleCoreRoutes } from './server/routesCore.js';
37
+ import { handleSettingsRoutes } from './server/routesSettings.js';
37
38
  import { handleWorkspaceRoutes } from './server/routesWorkspace.js';
38
39
  import { handleBrowserRoutes } from './server/routesBrowser.js';
39
40
  import { handleTerminalRoutes } from './server/routesTerminal.js';
@@ -230,6 +231,7 @@ export async function startSkybridgeServer(options: StartSkybridgeOptions = {}):
230
231
 
231
232
  try {
232
233
  if (await handleCoreRoutes(req, res, parsedUrl, ctx)) return;
234
+ if (await handleSettingsRoutes(req, res, parsedUrl, ctx)) return;
233
235
  if (await handleWorkspaceRoutes(req, res, parsedUrl, ctx)) return;
234
236
  if (await handleBrowserRoutes(req, res, parsedUrl, ctx)) return;
235
237
  if (await handleTerminalRoutes(req, res, parsedUrl, ctx)) return;
@@ -3,7 +3,7 @@ import { renderSidebarHtml } from './ui/sidebarTemplate.js';
3
3
  import { renderWorkspaceHtml } from './ui/workspaceTemplate.js';
4
4
  import { renderStudioHtml } from './ui/studioTemplate.js';
5
5
  import { renderModalsHtml } from './ui/modalsTemplate.js';
6
- import { SKYBRIDGE_STYLESHEET_URLS } from './server/staticAssets.js';
6
+ import { SKYBRIDGE_STYLESHEET_URLS, SKYBRIDGE_VENDOR_SCRIPT_URLS } from './server/staticAssets.js';
7
7
  export { getCausyneFaviconSvg };
8
8
  export function renderSkybridgeHtml(options) {
9
9
  const nonce = escapeHtmlAttr(options.cspNonce);
@@ -12,6 +12,9 @@ export function renderSkybridgeHtml(options) {
12
12
  const styleLinks = SKYBRIDGE_STYLESHEET_URLS
13
13
  .map((href) => `<link rel="stylesheet" href="${href}">`)
14
14
  .join('\n');
15
+ const vendorScripts = SKYBRIDGE_VENDOR_SCRIPT_URLS
16
+ .map((src) => `<script nonce="${nonce}" src="${src}"></script>`)
17
+ .join('\n');
15
18
  return [
16
19
  '<!DOCTYPE html>',
17
20
  '<html lang="en" data-theme="dark">',
@@ -31,6 +34,7 @@ export function renderSkybridgeHtml(options) {
31
34
  renderStudioHtml(),
32
35
  '</div>',
33
36
  renderModalsHtml(),
37
+ vendorScripts,
34
38
  `<script type="module" nonce="${nonce}" src="/assets/client/main.js"></script>`,
35
39
  '</body>',
36
40
  '</html>'
@@ -3,7 +3,10 @@ import { renderSidebarHtml } from './ui/sidebarTemplate.js';
3
3
  import { renderWorkspaceHtml } from './ui/workspaceTemplate.js';
4
4
  import { renderStudioHtml } from './ui/studioTemplate.js';
5
5
  import { renderModalsHtml } from './ui/modalsTemplate.js';
6
- import { SKYBRIDGE_STYLESHEET_URLS } from './server/staticAssets.js';
6
+ import {
7
+ SKYBRIDGE_STYLESHEET_URLS,
8
+ SKYBRIDGE_VENDOR_SCRIPT_URLS
9
+ } from './server/staticAssets.js';
7
10
 
8
11
  export { getCausyneFaviconSvg };
9
12
 
@@ -20,6 +23,9 @@ export function renderSkybridgeHtml(options: SkybridgeUiRenderOptions): string {
20
23
  const styleLinks = SKYBRIDGE_STYLESHEET_URLS
21
24
  .map((href) => `<link rel="stylesheet" href="${href}">`)
22
25
  .join('\n');
26
+ const vendorScripts = SKYBRIDGE_VENDOR_SCRIPT_URLS
27
+ .map((src) => `<script nonce="${nonce}" src="${src}"></script>`)
28
+ .join('\n');
23
29
 
24
30
  return [
25
31
  '<!DOCTYPE html>',
@@ -40,6 +46,7 @@ export function renderSkybridgeHtml(options: SkybridgeUiRenderOptions): string {
40
46
  renderStudioHtml(),
41
47
  '</div>',
42
48
  renderModalsHtml(),
49
+ vendorScripts,
43
50
  `<script type="module" nonce="${nonce}" src="/assets/client/main.js"></script>`,
44
51
  '</body>',
45
52
  '</html>'