@clagentic/console 1.12.0 → 1.13.0-beta.1
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 +7 -1
- package/bin/cli.js +18 -15
- package/lib/agent-roster-ws.js +38 -13
- package/lib/agent-roster.js +111 -12
- package/lib/agents.js +68 -33
- package/lib/atomic-install.js +334 -0
- package/lib/build-changes.js +33 -4
- package/lib/build-sha.json +2 -2
- package/lib/build-update-offer.js +12 -0
- package/lib/chat-width.js +31 -0
- package/lib/cli/agent-usage.js +126 -0
- package/lib/cli/arg-validation.js +1 -1
- package/lib/cli/compact-output.js +69 -0
- package/lib/cli/ipc-subcommands.js +92 -67
- package/lib/cli/output.js +28 -0
- package/lib/cli/restart-verb.js +132 -0
- package/lib/cli/schedule-input-subcommands.js +45 -8
- package/lib/cli/session-subcommands.js +37 -11
- package/lib/cli/settings-subcommands.js +74 -0
- package/lib/cli-transcript-title.js +56 -3
- package/lib/client-files.js +79 -0
- package/lib/daemon.js +100 -28
- package/lib/default-avatar-color.js +4 -0
- package/lib/drain.js +58 -10
- package/lib/mcp-tool-input.js +2 -2
- package/lib/model-families.js +49 -1
- package/lib/notify/type-registry.js +4 -0
- package/lib/notify/types.js +7 -4
- package/lib/pages.js +13 -63
- package/lib/permission-summary.js +12 -16
- package/lib/plan-usage-reader.js +70 -0
- package/lib/project-connection.js +4 -2
- package/lib/project-filesystem.js +6 -7
- package/lib/project-notifications.js +55 -8
- package/lib/project-prompt-expiry-settings.js +42 -0
- package/lib/project-sessions.js +52 -0
- package/lib/project-settings-gate.js +98 -0
- package/lib/project-user-mention.js +3 -2
- package/lib/project.js +1 -1
- package/lib/prompt-expiry-settings.js +49 -0
- package/lib/prompt-expiry.js +24 -3
- package/lib/prompt-kinds/codecs.js +6 -2
- package/lib/public/app.js +36 -36
- package/lib/public/css/admin.css +156 -170
- package/lib/public/css/agent-messages.css +24 -24
- package/lib/public/css/agent-picker.css +90 -38
- package/lib/public/css/agent-roster.css +61 -27
- package/lib/public/css/at-agents.css +10 -10
- package/lib/public/css/base.css +207 -184
- package/lib/public/css/chat-layout.css +228 -0
- package/lib/public/css/command-palette.css +86 -88
- package/lib/public/css/diagnostics.css +78 -204
- package/lib/public/css/diff.css +10 -10
- package/lib/public/css/filebrowser.css +32 -60
- package/lib/public/css/home-hub.css +100 -100
- package/lib/public/css/icon-strip.css +195 -238
- package/lib/public/css/input.css +191 -212
- package/lib/public/css/login-panel.css +16 -16
- package/lib/public/css/loop.css +96 -187
- package/lib/public/css/mention.css +49 -110
- package/lib/public/css/menus.css +162 -169
- package/lib/public/css/messages.css +49 -123
- package/lib/public/css/mobile-nav.css +207 -264
- package/lib/public/css/notifications-center.css +45 -124
- package/lib/public/css/overlay.css +269 -0
- package/lib/public/css/overlays.css +134 -156
- package/lib/public/css/playbook.css +41 -41
- package/lib/public/css/profile.css +43 -112
- package/lib/public/css/rewind.css +112 -112
- package/lib/public/css/scheduler-modal.css +27 -135
- package/lib/public/css/scheduler.css +204 -210
- package/lib/public/css/server-settings.css +173 -239
- package/lib/public/css/session-search.css +20 -20
- package/lib/public/css/settings-nav.css +197 -0
- package/lib/public/css/sidebar.css +213 -304
- package/lib/public/css/skills.css +121 -135
- package/lib/public/css/sticky-notes.css +114 -200
- package/lib/public/css/stt.css +17 -26
- package/lib/public/css/team-panel.css +36 -36
- package/lib/public/css/team-view.css +9 -9
- package/lib/public/css/title-bar.css +83 -100
- package/lib/public/css/tooltip.css +10 -10
- package/lib/public/css/user-settings.css +78 -131
- package/lib/public/css/user-shell.css +125 -29
- package/lib/public/index.html +178 -177
- package/lib/public/manifest.json +0 -2
- package/lib/public/modules/admin.js +54 -92
- package/lib/public/modules/agent-avatar.js +134 -3
- package/lib/public/modules/agent-messages.js +2 -1
- package/lib/public/modules/agent-picker.js +23 -21
- package/lib/public/modules/agent-roster-groups.js +128 -0
- package/lib/public/modules/agent-roster.js +40 -11
- package/lib/public/modules/app-connection.js +13 -1
- package/lib/public/modules/app-cursors.js +9 -9
- package/lib/public/modules/app-favicon.js +8 -16
- package/lib/public/modules/app-header.js +28 -19
- package/lib/public/modules/app-history-replay.js +67 -4
- package/lib/public/modules/app-home-hub.js +15 -0
- package/lib/public/modules/app-loop-ui.js +41 -47
- package/lib/public/modules/app-loop-wizard.js +9 -10
- package/lib/public/modules/app-messages.js +32 -36
- package/lib/public/modules/app-misc.js +22 -92
- package/lib/public/modules/app-modals.js +98 -0
- package/lib/public/modules/app-notifications.js +124 -135
- package/lib/public/modules/app-panels.js +28 -32
- package/lib/public/modules/app-projects.js +30 -40
- package/lib/public/modules/app-rate-limit.js +26 -9
- package/lib/public/modules/app-rendering.js +128 -110
- package/lib/public/modules/app-skills-install.js +6 -4
- package/lib/public/modules/assistant-identity.js +55 -0
- package/lib/public/modules/at-agents.js +3 -0
- package/lib/public/modules/build-guard.js +25 -11
- package/lib/public/modules/chat-width-choice.js +75 -0
- package/lib/public/modules/chat-width-prefs.js +52 -0
- package/lib/public/modules/chat-width.js +102 -0
- package/lib/public/modules/collapsible-text.js +36 -4
- package/lib/public/modules/command-palette.js +28 -34
- package/lib/public/modules/context-sources.js +3 -5
- package/lib/public/modules/diagnostics.js +130 -129
- package/lib/public/modules/info-panel.js +31 -0
- package/lib/public/modules/injected-identity.js +8 -8
- package/lib/public/modules/input-list-menu.js +39 -0
- package/lib/public/modules/input.js +22 -21
- package/lib/public/modules/markdown.js +10 -11
- package/lib/public/modules/mcp-ui.js +4 -14
- package/lib/public/modules/mention.js +100 -229
- package/lib/public/modules/message-header.js +80 -0
- package/lib/public/modules/message-participants.js +39 -0
- package/lib/public/modules/mobile-action-sheet.js +46 -0
- package/lib/public/modules/mobile-nav-sheet.js +104 -0
- package/lib/public/modules/model-families.js +41 -4
- package/lib/public/modules/note-order.js +39 -0
- package/lib/public/modules/notifications.js +35 -52
- package/lib/public/modules/overlay-history.js +73 -19
- package/lib/public/modules/overlay-menu.js +123 -0
- package/lib/public/modules/overlay-modal.js +186 -0
- package/lib/public/modules/overlay-registry.js +392 -0
- package/lib/public/modules/overlay-stack.js +110 -0
- package/lib/public/modules/overlay.js +117 -0
- package/lib/public/modules/popover-position.js +18 -2
- package/lib/public/modules/preference-sync.js +28 -0
- package/lib/public/modules/profile.js +24 -49
- package/lib/public/modules/project-settings.js +27 -172
- package/lib/public/modules/prompt-expiry-controls.js +46 -0
- package/lib/public/modules/prompt-kinds/command-summary.js +149 -0
- package/lib/public/modules/prompt-kinds/permission.js +70 -92
- package/lib/public/modules/prompts.js +1 -2
- package/lib/public/modules/qrcode.js +6 -21
- package/lib/public/modules/queued-button.js +15 -2
- package/lib/public/modules/rewind.js +9 -3
- package/lib/public/modules/schedule-time.js +32 -7
- package/lib/public/modules/scheduled-outbox.js +51 -18
- package/lib/public/modules/scheduler-config.js +87 -127
- package/lib/public/modules/scheduler.js +29 -26
- package/lib/public/modules/serialized-save.js +79 -0
- package/lib/public/modules/server-settings.js +75 -65
- package/lib/public/modules/session-grants.js +16 -19
- package/lib/public/modules/session-list-avatars.js +98 -0
- package/lib/public/modules/session-vendor-state.js +86 -0
- package/lib/public/modules/settings-access.js +35 -0
- package/lib/public/modules/settings-hub.js +125 -0
- package/lib/public/modules/settings-nav.js +182 -0
- package/lib/public/modules/shell-line.js +24 -0
- package/lib/public/modules/sidebar-mobile.js +151 -195
- package/lib/public/modules/sidebar-projects.js +88 -129
- package/lib/public/modules/sidebar-sessions.js +66 -34
- package/lib/public/modules/sidebar.js +2 -2
- package/lib/public/modules/skills.js +11 -26
- package/lib/public/modules/sticky-notes.js +19 -16
- package/lib/public/modules/stt.js +9 -23
- package/lib/public/modules/terminal.js +86 -90
- package/lib/public/modules/theme-choice.js +126 -0
- package/lib/public/modules/theme-colors.js +19 -0
- package/lib/public/modules/theme-prefs.js +121 -0
- package/lib/public/modules/theme.js +227 -605
- package/lib/public/modules/tool-palette.js +7 -17
- package/lib/public/modules/tools.js +8 -10
- package/lib/public/modules/user-settings.js +59 -115
- package/lib/public/modules/user-shell.js +9 -2
- package/lib/public/modules/utils.js +10 -12
- package/lib/public/modules/vendor-picker.js +4 -2
- package/lib/public/modules/vendor-registry.js +1 -2
- package/lib/public/style.css +3 -1
- package/lib/public/sw.js +9 -2
- package/lib/public/theme-core.js +411 -0
- package/lib/request-body.js +70 -0
- package/lib/sdk-bridge.js +227 -88
- package/lib/sdk-message-processor.js +44 -16
- package/lib/server-admin.js +198 -200
- package/lib/server-auth.js +16 -13
- package/lib/server-dm.js +4 -3
- package/lib/server-settings.js +177 -130
- package/lib/server.js +87 -36
- package/lib/session-background-tasks.js +79 -0
- package/lib/session-directory.js +138 -13
- package/lib/session-input-ipc.js +2 -0
- package/lib/session-input.js +39 -5
- package/lib/session-list-avatars.js +16 -0
- package/lib/session-reclaim.js +37 -25
- package/lib/session-vendor.js +37 -0
- package/lib/sessions.js +99 -34
- package/lib/settings-ipc.js +60 -0
- package/lib/settings-registry.js +86 -0
- package/lib/terminal-manager.js +17 -5
- package/lib/theme-files.js +132 -0
- package/lib/theme-seed.js +136 -0
- package/lib/themes/clagentic-dark.json +13 -6
- package/lib/themes/clagentic-light.json +12 -5
- package/lib/updater.js +6 -4
- package/lib/usage-store.js +97 -10
- package/lib/users-preferences.js +118 -19
- package/lib/users.js +19 -10
- package/lib/vendor-catalog.js +130 -0
- package/lib/ws-schema.js +4 -2
- package/lib/yoke/adapters/claude.js +81 -1
- package/lib/yoke/adapters/codex-user-shell.js +87 -23
- package/lib/yoke/adapters/codex.js +89 -5
- package/lib/yoke/codex-binary.js +59 -0
- package/package.json +1 -1
- package/scripts/check-test-count.js +5 -0
- package/scripts/install-local-test.js +50 -9
- package/scripts/write-build-sha.js +18 -2
- package/lib/public/css/channel-layout.css +0 -329
- package/lib/themes/ayu-light.json +0 -9
- package/lib/themes/catppuccin-latte.json +0 -9
- package/lib/themes/catppuccin-mocha.json +0 -9
- package/lib/themes/dracula.json +0 -9
- package/lib/themes/everforest-light.json +0 -9
- package/lib/themes/everforest.json +0 -9
- package/lib/themes/github-light.json +0 -9
- package/lib/themes/gruvbox-dark.json +0 -9
- package/lib/themes/gruvbox-light.json +0 -9
- package/lib/themes/monokai.json +0 -9
- package/lib/themes/nord-light.json +0 -9
- package/lib/themes/nord.json +0 -9
- package/lib/themes/one-dark.json +0 -9
- package/lib/themes/one-light.json +0 -9
- package/lib/themes/rose-pine-dawn.json +0 -9
- package/lib/themes/rose-pine.json +0 -9
- package/lib/themes/solarized-dark.json +0 -9
- package/lib/themes/solarized-light.json +0 -9
- package/lib/themes/tokyo-night-light.json +0 -9
- package/lib/themes/tokyo-night.json +0 -9
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
// The one place a theme's colours become CSS variables.
|
|
2
|
+
//
|
|
3
|
+
// A theme is sixteen base16 colours (base00..base0F), an optional accent2, and
|
|
4
|
+
// an optional `tokens` object that names exact values for a few surface and
|
|
5
|
+
// state colours (TOKEN_KEYS). deriveVars() turns that into every CSS variable
|
|
6
|
+
// the console draws with. A token the theme names is used as written; any
|
|
7
|
+
// other is derived from the base colours, so a theme file with only the
|
|
8
|
+
// sixteen colours is fully styled.
|
|
9
|
+
//
|
|
10
|
+
// Plain script on purpose: Node loads it with require() (the server builds the
|
|
11
|
+
// first-paint stylesheet, the auth and setup pages, the manifest and the
|
|
12
|
+
// offline page from it) and the browser loads it as a script, so no copy of
|
|
13
|
+
// the derivation exists anywhere else. It also sets
|
|
14
|
+
// globalThis.ClagenticThemeCore; modules/theme-colors.js is the module-side
|
|
15
|
+
// handle on it.
|
|
16
|
+
function readBuiltin() {
|
|
17
|
+
var fs = require("fs");
|
|
18
|
+
var path = require("path");
|
|
19
|
+
function load(id) {
|
|
20
|
+
return JSON.parse(fs.readFileSync(path.join(__dirname, "..", "themes", id + ".json"), "utf8"));
|
|
21
|
+
}
|
|
22
|
+
return { dark: load("clagentic-dark"), light: load("clagentic-light") };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
(function (root, factory) {
|
|
26
|
+
var core = factory();
|
|
27
|
+
// Always on the global: a browser module that imports this file runs it
|
|
28
|
+
// wherever the host decides (as a script, or, under Node, as CommonJS), and
|
|
29
|
+
// theme-colors.js reads it from there. require() gets the same object.
|
|
30
|
+
root.ClagenticThemeCore = core;
|
|
31
|
+
if (typeof module === "object" && module && module.exports) {
|
|
32
|
+
// Under Node the palettes come straight from the theme files. In a browser
|
|
33
|
+
// the server appends them to this script (lib/theme-seed.js).
|
|
34
|
+
core.builtin = readBuiltin();
|
|
35
|
+
module.exports = core;
|
|
36
|
+
}
|
|
37
|
+
})(typeof self !== "undefined" ? self : globalThis, function () {
|
|
38
|
+
"use strict";
|
|
39
|
+
|
|
40
|
+
var BASE_KEYS = ["base00", "base01", "base02", "base03", "base04", "base05", "base06", "base07",
|
|
41
|
+
"base08", "base09", "base0A", "base0B", "base0C", "base0D", "base0E", "base0F"];
|
|
42
|
+
|
|
43
|
+
// Colours a theme file may state exactly (the "tokens" object). Everything
|
|
44
|
+
// else is derived.
|
|
45
|
+
var TOKEN_KEYS = ["sidebar-bg", "sidebar-active", "user-bubble", "input-bg", "code-bg",
|
|
46
|
+
"border-subtle", "border-strong", "warning", "on-accent", "on-av",
|
|
47
|
+
"av0", "av1", "av2", "av3"];
|
|
48
|
+
|
|
49
|
+
var HEX6 = /^[0-9a-fA-F]{6}$/;
|
|
50
|
+
|
|
51
|
+
// --- Colour maths ---
|
|
52
|
+
|
|
53
|
+
function hexToRgb(hex) {
|
|
54
|
+
var h = hex.replace("#", "");
|
|
55
|
+
return {
|
|
56
|
+
r: parseInt(h.substring(0, 2), 16),
|
|
57
|
+
g: parseInt(h.substring(2, 4), 16),
|
|
58
|
+
b: parseInt(h.substring(4, 6), 16)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function rgbToHex(r, g, b) {
|
|
63
|
+
return "#" + [r, g, b].map(function (v) {
|
|
64
|
+
var c = Math.max(0, Math.min(255, Math.round(v)));
|
|
65
|
+
var s = c.toString(16);
|
|
66
|
+
return (s.length < 2 ? "0" + s : s).toUpperCase();
|
|
67
|
+
}).join("");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function darken(hex, amount) {
|
|
71
|
+
var c = hexToRgb(hex);
|
|
72
|
+
var f = 1 - amount;
|
|
73
|
+
return rgbToHex(c.r * f, c.g * f, c.b * f);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function lighten(hex, amount) {
|
|
77
|
+
var c = hexToRgb(hex);
|
|
78
|
+
return rgbToHex(
|
|
79
|
+
c.r + (255 - c.r) * amount,
|
|
80
|
+
c.g + (255 - c.g) * amount,
|
|
81
|
+
c.b + (255 - c.b) * amount
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// weight is the share of hex1.
|
|
86
|
+
function mix(hex1, hex2, weight) {
|
|
87
|
+
var c1 = hexToRgb(hex1);
|
|
88
|
+
var c2 = hexToRgb(hex2);
|
|
89
|
+
return rgbToHex(
|
|
90
|
+
c1.r * weight + c2.r * (1 - weight),
|
|
91
|
+
c1.g * weight + c2.g * (1 - weight),
|
|
92
|
+
c1.b * weight + c2.b * (1 - weight)
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function rgba(hex, alpha) {
|
|
97
|
+
var c = hexToRgb(hex);
|
|
98
|
+
return "rgba(" + c.r + ", " + c.g + ", " + c.b + ", " + alpha + ")";
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function triplet(hex) {
|
|
102
|
+
var c = hexToRgb(hex);
|
|
103
|
+
return c.r + ", " + c.g + ", " + c.b;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// WCAG 2.x relative luminance and contrast ratio.
|
|
107
|
+
function relativeLuminance(hex) {
|
|
108
|
+
var c = hexToRgb(hex);
|
|
109
|
+
var lin = [c.r, c.g, c.b].map(function (v) {
|
|
110
|
+
var s = v / 255;
|
|
111
|
+
return s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
|
|
112
|
+
});
|
|
113
|
+
return 0.2126 * lin[0] + 0.7152 * lin[1] + 0.0722 * lin[2];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function contrast(hexA, hexB) {
|
|
117
|
+
var a = relativeLuminance(hexA);
|
|
118
|
+
var b = relativeLuminance(hexB);
|
|
119
|
+
return (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// The more readable of two colours on `fill`.
|
|
123
|
+
function readableOn(fill, optionA, optionB) {
|
|
124
|
+
return contrast(fill, optionA) >= contrast(fill, optionB) ? optionA : optionB;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// The option that reads best on the worst of `fills`.
|
|
128
|
+
function readableOnAll(fills, optionA, optionB) {
|
|
129
|
+
function worst(option) {
|
|
130
|
+
return Math.min.apply(null, fills.map(function (f) { return contrast(f, option); }));
|
|
131
|
+
}
|
|
132
|
+
return worst(optionA) >= worst(optionB) ? optionA : optionB;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// "dark" or "light" for a theme file that does not say. `base00` is six hex
|
|
136
|
+
// digits with or without a leading "#".
|
|
137
|
+
function inferVariant(base00) {
|
|
138
|
+
var c = hexToRgb(base00);
|
|
139
|
+
return (0.299 * c.r + 0.587 * c.g + 0.114 * c.b) / 255 > 0.5 ? "light" : "dark";
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// --- Theme shape ---
|
|
143
|
+
|
|
144
|
+
// The "tokens" object of a theme, checked: undefined when the theme has none,
|
|
145
|
+
// null when it is malformed (not an object, or a known key that is not six
|
|
146
|
+
// hex digits), else a copy holding only the known keys. Unknown keys are
|
|
147
|
+
// dropped so a file cannot smuggle extra properties into the page.
|
|
148
|
+
function readTokens(raw) {
|
|
149
|
+
if (raw === undefined || raw === null) return undefined;
|
|
150
|
+
if (typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
151
|
+
var out = {};
|
|
152
|
+
for (var i = 0; i < TOKEN_KEYS.length; i++) {
|
|
153
|
+
var v = raw[TOKEN_KEYS[i]];
|
|
154
|
+
if (v === undefined || v === null) continue;
|
|
155
|
+
if (typeof v !== "string" || !HEX6.test(v)) return null;
|
|
156
|
+
out[TOKEN_KEYS[i]] = v;
|
|
157
|
+
}
|
|
158
|
+
return out;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function baseColors(theme) {
|
|
162
|
+
var b = {};
|
|
163
|
+
for (var i = 0; i < BASE_KEYS.length; i++) b[BASE_KEYS[i]] = "#" + theme[BASE_KEYS[i]];
|
|
164
|
+
return b;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// --- Derivation ---
|
|
168
|
+
|
|
169
|
+
// The colours a theme either states or derives (TOKEN_KEYS), as "#RRGGBB".
|
|
170
|
+
function resolveTokens(theme) {
|
|
171
|
+
var b = baseColors(theme);
|
|
172
|
+
var light = theme.variant === "light";
|
|
173
|
+
var stated = readTokens(theme.tokens) || {};
|
|
174
|
+
var sources = [b.base09, b.base0E, b.base0B, b.base0A];
|
|
175
|
+
var derived = {
|
|
176
|
+
"sidebar-bg": light ? darken(b.base00, 0.03) : darken(b.base00, 0.30),
|
|
177
|
+
"sidebar-active": light ? darken(b.base01, 0.06) : mix(b.base01, b.base02, 0.4),
|
|
178
|
+
"user-bubble": light ? darken(b.base01, 0.03) : mix(b.base01, b.base02, 0.3),
|
|
179
|
+
"input-bg": light ? darken(b.base00, 0.04) : mix(b.base01, b.base02, 0.5),
|
|
180
|
+
"code-bg": light ? darken(b.base00, 0.03) : darken(b.base00, 0.15),
|
|
181
|
+
"border-subtle": mix(b.base00, b.base02, 0.6),
|
|
182
|
+
// A control outline has to be seen against the page, so it leans on the
|
|
183
|
+
// secondary text colour rather than the decorative divider.
|
|
184
|
+
"border-strong": mix(b.base04, b.base00, 0.7),
|
|
185
|
+
"warning": b.base0A,
|
|
186
|
+
"on-accent": readableOn(b.base09, b.base00, b.base06),
|
|
187
|
+
"av0": light ? darken(sources[0], 0.2) : lighten(sources[0], 0.35),
|
|
188
|
+
"av1": light ? darken(sources[1], 0.2) : lighten(sources[1], 0.35),
|
|
189
|
+
"av2": light ? darken(sources[2], 0.2) : lighten(sources[2], 0.35),
|
|
190
|
+
"av3": light ? darken(sources[3], 0.2) : lighten(sources[3], 0.35)
|
|
191
|
+
};
|
|
192
|
+
// Fills first (a stated token wins over a derived one), then the colours
|
|
193
|
+
// that sit on them, so a foreground is chosen against the fill that is shown.
|
|
194
|
+
var out = {};
|
|
195
|
+
var i;
|
|
196
|
+
for (i = 0; i < TOKEN_KEYS.length; i++) {
|
|
197
|
+
var k = TOKEN_KEYS[i];
|
|
198
|
+
out[k] = stated[k] ? "#" + stated[k] : derived[k];
|
|
199
|
+
}
|
|
200
|
+
if (!stated["on-av"]) {
|
|
201
|
+
out["on-av"] = readableOnAll([out.av0, out.av1, out.av2, out.av3], b.base00, b.base06);
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Every CSS variable for a theme: { "--bg": "#...", ... }.
|
|
207
|
+
function deriveVars(theme) {
|
|
208
|
+
var b = baseColors(theme);
|
|
209
|
+
var light = theme.variant === "light";
|
|
210
|
+
var t = resolveTokens(theme);
|
|
211
|
+
var accent2 = theme.accent2 ? "#" + theme.accent2 : b.base0D;
|
|
212
|
+
var overlay = light ? "0, 0, 0" : "255, 255, 255";
|
|
213
|
+
var overlayHex = light ? "#000000" : "#FFFFFF";
|
|
214
|
+
var hover = rgba(overlayHex, 0.06);
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
// Surfaces
|
|
218
|
+
"--bg": b.base00,
|
|
219
|
+
"--bg-alt": b.base01,
|
|
220
|
+
"--sidebar-bg": t["sidebar-bg"],
|
|
221
|
+
"--sidebar-hover": mix(t["sidebar-bg"], t["sidebar-active"], 0.5),
|
|
222
|
+
"--sidebar-active": t["sidebar-active"],
|
|
223
|
+
"--user-bubble": t["user-bubble"],
|
|
224
|
+
"--input-bg": t["input-bg"],
|
|
225
|
+
"--ask-mate-bg": mix(b.base00, t["input-bg"], 0.6),
|
|
226
|
+
"--code-bg": t["code-bg"],
|
|
227
|
+
"--filebrowser-bg": b.base01,
|
|
228
|
+
"--filebrowser-border": t["border-subtle"],
|
|
229
|
+
// Text
|
|
230
|
+
"--text": b.base06,
|
|
231
|
+
"--text-secondary": b.base05,
|
|
232
|
+
"--text-muted": b.base04,
|
|
233
|
+
"--text-dimmer": b.base03,
|
|
234
|
+
// Borders
|
|
235
|
+
"--border": b.base02,
|
|
236
|
+
"--border-subtle": t["border-subtle"],
|
|
237
|
+
"--border-strong": t["border-strong"],
|
|
238
|
+
// Accent
|
|
239
|
+
"--accent": b.base09,
|
|
240
|
+
"--accent-hover": light ? darken(b.base09, 0.12) : lighten(b.base09, 0.12),
|
|
241
|
+
"--accent-bg": rgba(b.base09, 0.12),
|
|
242
|
+
"--accent-8": rgba(b.base09, 0.08),
|
|
243
|
+
"--accent-12": rgba(b.base09, 0.12),
|
|
244
|
+
"--accent-15": rgba(b.base09, 0.15),
|
|
245
|
+
"--accent-20": rgba(b.base09, 0.20),
|
|
246
|
+
"--accent-25": rgba(b.base09, 0.25),
|
|
247
|
+
"--accent-30": rgba(b.base09, 0.30),
|
|
248
|
+
"--accent-rgb": triplet(b.base09),
|
|
249
|
+
"--on-accent": t["on-accent"],
|
|
250
|
+
// The text colour on a solid status or accent2 fill. Each fill differs per
|
|
251
|
+
// theme (a pale error in Dark, a deep one in Light), so none of them can
|
|
252
|
+
// share --on-accent and still meet AA on every fill.
|
|
253
|
+
"--on-accent2": readableOn(accent2, b.base00, b.base06),
|
|
254
|
+
"--on-error": readableOn(b.base08, b.base00, b.base06),
|
|
255
|
+
"--on-success": readableOn(b.base0B, b.base00, b.base06),
|
|
256
|
+
"--on-warning": readableOn(t["warning"], b.base00, b.base06),
|
|
257
|
+
"--accent2": accent2,
|
|
258
|
+
"--accent2-hover": light ? darken(accent2, 0.12) : lighten(accent2, 0.12),
|
|
259
|
+
"--accent2-bg": rgba(accent2, 0.12),
|
|
260
|
+
"--accent2-8": rgba(accent2, 0.08),
|
|
261
|
+
"--accent2-12": rgba(accent2, 0.12),
|
|
262
|
+
"--accent2-15": rgba(accent2, 0.15),
|
|
263
|
+
"--accent2-20": rgba(accent2, 0.20),
|
|
264
|
+
"--accent2-25": rgba(accent2, 0.25),
|
|
265
|
+
"--accent2-30": rgba(accent2, 0.30),
|
|
266
|
+
// State
|
|
267
|
+
"--error": b.base08,
|
|
268
|
+
"--error-8": rgba(b.base08, 0.08),
|
|
269
|
+
"--error-12": rgba(b.base08, 0.12),
|
|
270
|
+
"--error-15": rgba(b.base08, 0.15),
|
|
271
|
+
"--error-25": rgba(b.base08, 0.25),
|
|
272
|
+
"--success": b.base0B,
|
|
273
|
+
"--success-8": rgba(b.base0B, 0.08),
|
|
274
|
+
"--success-12": rgba(b.base0B, 0.12),
|
|
275
|
+
"--success-15": rgba(b.base0B, 0.15),
|
|
276
|
+
"--success-25": rgba(b.base0B, 0.25),
|
|
277
|
+
"--success-rgb": triplet(b.base0B),
|
|
278
|
+
"--warning": t["warning"],
|
|
279
|
+
"--warning-bg": rgba(t["warning"], 0.12),
|
|
280
|
+
"--warning-rgb": triplet(t["warning"]),
|
|
281
|
+
"--overlay-rgb": overlay.replace(/ /g, ""),
|
|
282
|
+
"--shadow-rgb": "0,0,0",
|
|
283
|
+
// Avatars
|
|
284
|
+
"--av0": t["av0"],
|
|
285
|
+
"--av1": t["av1"],
|
|
286
|
+
"--av2": t["av2"],
|
|
287
|
+
"--av3": t["av3"],
|
|
288
|
+
"--on-av": t["on-av"],
|
|
289
|
+
// Code highlighting
|
|
290
|
+
"--hl-comment": b.base03,
|
|
291
|
+
"--hl-keyword": b.base0E,
|
|
292
|
+
"--hl-string": b.base0B,
|
|
293
|
+
"--hl-number": b.base09,
|
|
294
|
+
"--hl-function": b.base0D,
|
|
295
|
+
"--hl-variable": b.base08,
|
|
296
|
+
"--hl-type": b.base0A,
|
|
297
|
+
"--hl-constant": b.base09,
|
|
298
|
+
"--hl-tag": b.base08,
|
|
299
|
+
"--hl-attr": b.base0D,
|
|
300
|
+
"--hl-regexp": b.base0C,
|
|
301
|
+
"--hl-meta": b.base0F,
|
|
302
|
+
"--hl-builtin": b.base09,
|
|
303
|
+
"--hl-symbol": b.base0F,
|
|
304
|
+
"--hl-addition": b.base0B,
|
|
305
|
+
"--hl-deletion": b.base08,
|
|
306
|
+
// Names the stylesheets use for a colour that already has a token above;
|
|
307
|
+
// each is the same value, so a use never falls back to a literal.
|
|
308
|
+
"--text-primary": b.base06,
|
|
309
|
+
"--text-dim": b.base04,
|
|
310
|
+
"--text-tertiary": b.base03,
|
|
311
|
+
"--bg-secondary": b.base01,
|
|
312
|
+
"--bg-elevated": b.base01,
|
|
313
|
+
"--bg-surface": b.base01,
|
|
314
|
+
"--bg-tertiary": t["user-bubble"],
|
|
315
|
+
"--bg-deep": t["code-bg"],
|
|
316
|
+
"--bg-dim": t["code-bg"],
|
|
317
|
+
"--bg-deeper": t["code-bg"],
|
|
318
|
+
"--hover": hover,
|
|
319
|
+
"--hover-bg": hover,
|
|
320
|
+
"--bg-hover": hover,
|
|
321
|
+
"--bg-active": rgba(overlayHex, 0.10),
|
|
322
|
+
"--surface-2": rgba(overlayHex, 0.04),
|
|
323
|
+
"--overlay-soft": rgba(b.base09, 0.08),
|
|
324
|
+
"--accent-text": t["on-accent"],
|
|
325
|
+
"--warn": t["warning"],
|
|
326
|
+
"--green": b.base0B,
|
|
327
|
+
"--border-bright": t["border-strong"],
|
|
328
|
+
"--danger": b.base08,
|
|
329
|
+
"--activity-other": b.base0E
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// xterm theme for the active theme.
|
|
334
|
+
function deriveTerminalTheme(theme) {
|
|
335
|
+
var b = baseColors(theme);
|
|
336
|
+
var light = theme.variant === "light";
|
|
337
|
+
var v = deriveVars(theme);
|
|
338
|
+
function bright(hex) { return light ? darken(hex, 0.1) : lighten(hex, 0.1); }
|
|
339
|
+
return {
|
|
340
|
+
background: v["--code-bg"],
|
|
341
|
+
foreground: v["--text-secondary"],
|
|
342
|
+
cursor: v["--text"],
|
|
343
|
+
selectionBackground: rgba(b.base02, 0.5),
|
|
344
|
+
black: light ? b.base07 : b.base00,
|
|
345
|
+
red: v["--error"],
|
|
346
|
+
green: v["--success"],
|
|
347
|
+
yellow: v["--warning"],
|
|
348
|
+
blue: v["--accent2"],
|
|
349
|
+
magenta: b.base0E,
|
|
350
|
+
cyan: v["--accent"],
|
|
351
|
+
white: light ? b.base00 : b.base05,
|
|
352
|
+
brightBlack: b.base03,
|
|
353
|
+
brightRed: bright(v["--error"]),
|
|
354
|
+
brightGreen: bright(v["--success"]),
|
|
355
|
+
brightYellow: bright(v["--warning"]),
|
|
356
|
+
brightBlue: bright(v["--accent2"]),
|
|
357
|
+
brightMagenta: bright(b.base0E),
|
|
358
|
+
brightCyan: bright(v["--accent"]),
|
|
359
|
+
brightWhite: b.base07
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Mermaid theme variables for the active theme (use with Mermaid's "base"
|
|
364
|
+
// theme, the one that honours them).
|
|
365
|
+
function deriveMermaidVars(theme) {
|
|
366
|
+
var v = deriveVars(theme);
|
|
367
|
+
return {
|
|
368
|
+
darkMode: theme.variant !== "light",
|
|
369
|
+
background: v["--code-bg"],
|
|
370
|
+
mainBkg: v["--bg-alt"],
|
|
371
|
+
primaryColor: v["--bg-alt"],
|
|
372
|
+
primaryTextColor: v["--text"],
|
|
373
|
+
primaryBorderColor: v["--accent"],
|
|
374
|
+
secondaryColor: v["--user-bubble"],
|
|
375
|
+
secondaryTextColor: v["--text"],
|
|
376
|
+
tertiaryColor: v["--bg"],
|
|
377
|
+
tertiaryTextColor: v["--text"],
|
|
378
|
+
textColor: v["--text"],
|
|
379
|
+
titleColor: v["--text"],
|
|
380
|
+
lineColor: v["--text-muted"],
|
|
381
|
+
nodeBorder: v["--accent"],
|
|
382
|
+
clusterBkg: v["--bg"],
|
|
383
|
+
clusterBorder: v["--border-strong"],
|
|
384
|
+
noteBkgColor: v["--bg-alt"],
|
|
385
|
+
noteTextColor: v["--text"],
|
|
386
|
+
edgeLabelBackground: v["--bg-alt"]
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// "--name:value;" text for a vars object.
|
|
391
|
+
function varsToCss(vars) {
|
|
392
|
+
var text = "";
|
|
393
|
+
var names = Object.keys(vars);
|
|
394
|
+
for (var i = 0; i < names.length; i++) text += names[i] + ":" + vars[names[i]] + ";";
|
|
395
|
+
return text;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return {
|
|
399
|
+
BASE_KEYS: BASE_KEYS,
|
|
400
|
+
TOKEN_KEYS: TOKEN_KEYS,
|
|
401
|
+
HEX6: HEX6,
|
|
402
|
+
contrast: contrast,
|
|
403
|
+
inferVariant: inferVariant,
|
|
404
|
+
readTokens: readTokens,
|
|
405
|
+
resolveTokens: resolveTokens,
|
|
406
|
+
deriveVars: deriveVars,
|
|
407
|
+
deriveTerminalTheme: deriveTerminalTheme,
|
|
408
|
+
deriveMermaidVars: deriveMermaidVars,
|
|
409
|
+
varsToCss: varsToCss
|
|
410
|
+
};
|
|
411
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Request-body helpers shared by the HTTP route modules (server-settings.js,
|
|
2
|
+
// server-admin.js). One definition each, so every JSON route answers a bad body,
|
|
3
|
+
// an oversized body and a persistence failure the same way.
|
|
4
|
+
|
|
5
|
+
// Parse a JSON request body. A body that is not a JSON object is a client error:
|
|
6
|
+
// answer 400 here and return null. Only the parse is guarded, so a failure while
|
|
7
|
+
// persisting is never reported as a bad request.
|
|
8
|
+
function parseJsonObjectBody(body, res) {
|
|
9
|
+
var data = null;
|
|
10
|
+
try {
|
|
11
|
+
data = JSON.parse(body);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
data = null;
|
|
14
|
+
}
|
|
15
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
16
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
17
|
+
res.end('{"error":"Invalid request"}');
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// JSON route payloads are a few fields or short lists. The cap is a resource bound
|
|
24
|
+
// on what one request can make the daemon buffer, not a validation rule.
|
|
25
|
+
var JSON_BODY_CAP_BYTES = 64 * 1024;
|
|
26
|
+
|
|
27
|
+
// Read a JSON request body with a byte cap, then hand the parsed object to
|
|
28
|
+
// onData. Over the cap: answer 413, pause the request so no further data is
|
|
29
|
+
// read, drop what was buffered and close the connection once the answer is out.
|
|
30
|
+
// A body that is not a JSON object is answered 400 (see parseJsonObjectBody).
|
|
31
|
+
function readJsonObjectBody(req, res, onData) {
|
|
32
|
+
var chunks = [];
|
|
33
|
+
var size = 0;
|
|
34
|
+
var tooLarge = false;
|
|
35
|
+
req.on("data", function (chunk) {
|
|
36
|
+
if (tooLarge) return;
|
|
37
|
+
var piece = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
|
|
38
|
+
size += piece.length;
|
|
39
|
+
if (size > JSON_BODY_CAP_BYTES) {
|
|
40
|
+
tooLarge = true;
|
|
41
|
+
chunks = [];
|
|
42
|
+
req.pause();
|
|
43
|
+
res.writeHead(413, { "Content-Type": "application/json", "Connection": "close" });
|
|
44
|
+
res.end('{"error":"Request body too large"}', function () { req.destroy(); });
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
chunks.push(piece);
|
|
48
|
+
});
|
|
49
|
+
req.on("end", function () {
|
|
50
|
+
if (tooLarge) return;
|
|
51
|
+
var data = parseJsonObjectBody(Buffer.concat(chunks).toString("utf8"), res);
|
|
52
|
+
if (!data) return;
|
|
53
|
+
onData(data);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// A setter or the users-file write threw: the request was fine, the server could
|
|
58
|
+
// not keep it. Log it and answer 500.
|
|
59
|
+
function respondPersistFailure(res, what, e) {
|
|
60
|
+
console.error("[request-body] saving " + what + " failed:", e && e.message ? e.message : e);
|
|
61
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
62
|
+
res.end('{"error":"Could not save"}');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module.exports = {
|
|
66
|
+
parseJsonObjectBody: parseJsonObjectBody,
|
|
67
|
+
readJsonObjectBody: readJsonObjectBody,
|
|
68
|
+
respondPersistFailure: respondPersistFailure,
|
|
69
|
+
JSON_BODY_CAP_BYTES: JSON_BODY_CAP_BYTES,
|
|
70
|
+
};
|