@clagentic/console 1.0.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/CREDITS.md +3 -0
- package/LICENSE +21 -0
- package/README.md +250 -0
- package/bin/cli.js +2812 -0
- package/lib/agents-favorites.js +164 -0
- package/lib/agents.js +282 -0
- package/lib/ask-user-mcp-server.js +120 -0
- package/lib/browser-mcp-server.js +484 -0
- package/lib/build-user-env.js +63 -0
- package/lib/certs/fullchain.pem +47 -0
- package/lib/certs/privkey.pem +5 -0
- package/lib/cli-sessions.js +265 -0
- package/lib/codex-defaults.js +18 -0
- package/lib/config.js +332 -0
- package/lib/crisis-safety.js +60 -0
- package/lib/daemon-projects.js +164 -0
- package/lib/daemon.js +1602 -0
- package/lib/dm.js +128 -0
- package/lib/ipc.js +125 -0
- package/lib/ipv4-only.js +39 -0
- package/lib/mcp-local.js +385 -0
- package/lib/notes.js +141 -0
- package/lib/os-users.js +529 -0
- package/lib/pages.js +1325 -0
- package/lib/project-connection.js +302 -0
- package/lib/project-external-trigger.js +236 -0
- package/lib/project-file-watch.js +120 -0
- package/lib/project-filesystem.js +528 -0
- package/lib/project-http.js +753 -0
- package/lib/project-image.js +95 -0
- package/lib/project-knowledge.js +88 -0
- package/lib/project-loop.js +1304 -0
- package/lib/project-mcp.js +374 -0
- package/lib/project-memory.js +39 -0
- package/lib/project-notifications.js +262 -0
- package/lib/project-sessions.js +1581 -0
- package/lib/project-user-mention.js +193 -0
- package/lib/project-user-message.js +628 -0
- package/lib/project.js +1303 -0
- package/lib/public/app.js +1031 -0
- package/lib/public/apple-touch-icon.png +0 -0
- package/lib/public/claude-code-avatar.png +0 -0
- package/lib/public/codex-avatar.png +0 -0
- package/lib/public/console-icon.png +0 -0
- package/lib/public/css/admin.css +736 -0
- package/lib/public/css/agent-picker.css +119 -0
- package/lib/public/css/base.css +235 -0
- package/lib/public/css/channel-layout.css +441 -0
- package/lib/public/css/command-palette.css +559 -0
- package/lib/public/css/debate.css +1609 -0
- package/lib/public/css/diff.css +139 -0
- package/lib/public/css/filebrowser.css +1976 -0
- package/lib/public/css/highlight.css +144 -0
- package/lib/public/css/home-hub.css +545 -0
- package/lib/public/css/icon-strip.css +1856 -0
- package/lib/public/css/input.css +1349 -0
- package/lib/public/css/loop.css +1248 -0
- package/lib/public/css/mention.css +317 -0
- package/lib/public/css/menus.css +857 -0
- package/lib/public/css/messages.css +1833 -0
- package/lib/public/css/mobile-nav.css +1332 -0
- package/lib/public/css/notifications-center.css +296 -0
- package/lib/public/css/overlays.css +1273 -0
- package/lib/public/css/playbook.css +264 -0
- package/lib/public/css/profile.css +397 -0
- package/lib/public/css/rewind.css +671 -0
- package/lib/public/css/scheduler-modal.css +1495 -0
- package/lib/public/css/scheduler.css +1420 -0
- package/lib/public/css/server-settings.css +909 -0
- package/lib/public/css/session-search.css +159 -0
- package/lib/public/css/sidebar.css +2012 -0
- package/lib/public/css/skills.css +789 -0
- package/lib/public/css/sticky-notes.css +854 -0
- package/lib/public/css/stt.css +155 -0
- package/lib/public/css/title-bar.css +674 -0
- package/lib/public/css/tooltip.css +67 -0
- package/lib/public/css/user-settings.css +702 -0
- package/lib/public/emoji-data.json +1 -0
- package/lib/public/favicon-banded-32.png +0 -0
- package/lib/public/favicon-banded.png +0 -0
- package/lib/public/favicon-dark.svg +32 -0
- package/lib/public/favicon.svg +32 -0
- package/lib/public/icon-192.png +0 -0
- package/lib/public/icon-512.png +0 -0
- package/lib/public/icon-banded-76.png +0 -0
- package/lib/public/icon-banded-96.png +0 -0
- package/lib/public/icon-mono.svg +25 -0
- package/lib/public/icons/email/gmail.svg +7 -0
- package/lib/public/icons/email/outlook.svg +35 -0
- package/lib/public/icons/email/yahoo.svg +1 -0
- package/lib/public/index.html +1946 -0
- package/lib/public/manifest.json +27 -0
- package/lib/public/markdown-worker.js +43 -0
- package/lib/public/marked.min.js +6 -0
- package/lib/public/modules/admin.js +954 -0
- package/lib/public/modules/agent-picker.js +429 -0
- package/lib/public/modules/app-connection.js +216 -0
- package/lib/public/modules/app-cursors.js +492 -0
- package/lib/public/modules/app-dm.js +265 -0
- package/lib/public/modules/app-favicon.js +231 -0
- package/lib/public/modules/app-header.js +242 -0
- package/lib/public/modules/app-home-hub.js +432 -0
- package/lib/public/modules/app-loop-ui.js +691 -0
- package/lib/public/modules/app-loop-wizard.js +439 -0
- package/lib/public/modules/app-messages.js +1415 -0
- package/lib/public/modules/app-misc.js +463 -0
- package/lib/public/modules/app-notifications.js +651 -0
- package/lib/public/modules/app-panels.js +1061 -0
- package/lib/public/modules/app-projects.js +875 -0
- package/lib/public/modules/app-rate-limit.js +529 -0
- package/lib/public/modules/app-rendering.js +739 -0
- package/lib/public/modules/app-skills-install.js +285 -0
- package/lib/public/modules/avatar.js +36 -0
- package/lib/public/modules/command-palette.js +491 -0
- package/lib/public/modules/console-logo.js +162 -0
- package/lib/public/modules/context-sources.js +365 -0
- package/lib/public/modules/diff.js +412 -0
- package/lib/public/modules/dom-refs.js +21 -0
- package/lib/public/modules/emoji-picker.js +222 -0
- package/lib/public/modules/events.js +21 -0
- package/lib/public/modules/filebrowser.js +1966 -0
- package/lib/public/modules/fileicons.js +172 -0
- package/lib/public/modules/icons.js +80 -0
- package/lib/public/modules/input.js +1102 -0
- package/lib/public/modules/longpress.js +74 -0
- package/lib/public/modules/markdown.js +486 -0
- package/lib/public/modules/mcp-ui.js +295 -0
- package/lib/public/modules/mention.js +1093 -0
- package/lib/public/modules/notifications.js +613 -0
- package/lib/public/modules/playbook.js +578 -0
- package/lib/public/modules/profile.js +594 -0
- package/lib/public/modules/project-settings.js +849 -0
- package/lib/public/modules/project-switcher.js +375 -0
- package/lib/public/modules/qrcode.js +87 -0
- package/lib/public/modules/rewind.js +381 -0
- package/lib/public/modules/scheduler-config.js +1611 -0
- package/lib/public/modules/scheduler-history.js +131 -0
- package/lib/public/modules/scheduler.js +1689 -0
- package/lib/public/modules/server-settings.js +842 -0
- package/lib/public/modules/session-search.js +456 -0
- package/lib/public/modules/settings-defaults.js +253 -0
- package/lib/public/modules/sidebar-mobile.js +1425 -0
- package/lib/public/modules/sidebar-projects.js +2022 -0
- package/lib/public/modules/sidebar-sessions.js +1548 -0
- package/lib/public/modules/sidebar-users.js +449 -0
- package/lib/public/modules/sidebar.js +348 -0
- package/lib/public/modules/skills.js +793 -0
- package/lib/public/modules/state.js +3 -0
- package/lib/public/modules/sticky-notes.js +1221 -0
- package/lib/public/modules/store.js +34 -0
- package/lib/public/modules/stt.js +266 -0
- package/lib/public/modules/terminal.js +987 -0
- package/lib/public/modules/theme.js +812 -0
- package/lib/public/modules/tool-palette.js +562 -0
- package/lib/public/modules/tools.js +2285 -0
- package/lib/public/modules/tooltip.js +150 -0
- package/lib/public/modules/user-settings.js +544 -0
- package/lib/public/modules/utils.js +56 -0
- package/lib/public/modules/ws-ref.js +26 -0
- package/lib/public/style.css +34 -0
- package/lib/public/sw.js +159 -0
- package/lib/push.js +149 -0
- package/lib/scheduler.js +471 -0
- package/lib/sdk-bridge.js +1792 -0
- package/lib/sdk-message-processor.js +740 -0
- package/lib/sdk-message-queue.js +42 -0
- package/lib/sdk-skill-discovery.js +131 -0
- package/lib/sdk-worker.js +677 -0
- package/lib/server-admin.js +712 -0
- package/lib/server-auth.js +737 -0
- package/lib/server-dm.js +170 -0
- package/lib/server-palette.js +104 -0
- package/lib/server-settings.js +553 -0
- package/lib/server-skills.js +280 -0
- package/lib/server.js +1390 -0
- package/lib/session-search.js +693 -0
- package/lib/sessions.js +946 -0
- package/lib/smtp.js +221 -0
- package/lib/terminal-manager.js +219 -0
- package/lib/terminal.js +39 -0
- package/lib/themes/ayu-light.json +9 -0
- package/lib/themes/catppuccin-latte.json +9 -0
- package/lib/themes/catppuccin-mocha.json +9 -0
- package/lib/themes/clagentic-dark.json +10 -0
- package/lib/themes/clagentic-light.json +10 -0
- package/lib/themes/dracula.json +9 -0
- package/lib/themes/everforest-light.json +9 -0
- package/lib/themes/everforest.json +9 -0
- package/lib/themes/github-light.json +9 -0
- package/lib/themes/gruvbox-dark.json +9 -0
- package/lib/themes/gruvbox-light.json +9 -0
- package/lib/themes/monokai.json +9 -0
- package/lib/themes/nord-light.json +9 -0
- package/lib/themes/nord.json +9 -0
- package/lib/themes/one-dark.json +9 -0
- package/lib/themes/one-light.json +9 -0
- package/lib/themes/rose-pine-dawn.json +9 -0
- package/lib/themes/rose-pine.json +9 -0
- package/lib/themes/solarized-dark.json +9 -0
- package/lib/themes/solarized-light.json +9 -0
- package/lib/themes/tokyo-night-light.json +9 -0
- package/lib/themes/tokyo-night.json +9 -0
- package/lib/updater.js +124 -0
- package/lib/user-presence.js +92 -0
- package/lib/users-auth.js +146 -0
- package/lib/users-permissions.js +118 -0
- package/lib/users-preferences.js +254 -0
- package/lib/users.js +465 -0
- package/lib/utils.js +64 -0
- package/lib/worktree.js +134 -0
- package/lib/ws-schema.js +464 -0
- package/lib/yoke/adapters/claude-worker.js +759 -0
- package/lib/yoke/adapters/claude.js +1599 -0
- package/lib/yoke/adapters/codex.js +1559 -0
- package/lib/yoke/codex-app-server.js +352 -0
- package/lib/yoke/index.js +319 -0
- package/lib/yoke/instructions.js +61 -0
- package/lib/yoke/interface.js +98 -0
- package/lib/yoke/mcp-bridge-server.js +302 -0
- package/lib/yoke/package.json +7 -0
- package/package.json +72 -0
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
// app-notifications.js - Notification banners (Apple banner style)
|
|
2
|
+
// New notifications appear as individual banners top-right, auto-dismiss after 3s.
|
|
3
|
+
// Bell button click shows all stored notifications as banners.
|
|
4
|
+
|
|
5
|
+
import { refreshIcons, iconHtml } from './icons.js';
|
|
6
|
+
import { escapeHtml } from './utils.js';
|
|
7
|
+
import { store } from './store.js';
|
|
8
|
+
import { getWs } from './ws-ref.js';
|
|
9
|
+
import { getCachedProjects } from './app-projects.js';
|
|
10
|
+
import { switchProject } from './app-projects.js';
|
|
11
|
+
import { userAvatarUrl } from './avatar.js';
|
|
12
|
+
import { openTerminal } from './terminal.js';
|
|
13
|
+
var notifications = [];
|
|
14
|
+
var unreadCount = 0;
|
|
15
|
+
var bannerContainer = null;
|
|
16
|
+
var bellBtn = null;
|
|
17
|
+
var badgeEl = null;
|
|
18
|
+
|
|
19
|
+
// --- Update available banner state ---
|
|
20
|
+
// Server pushes update_available on an hourly boundary; dismissal is
|
|
21
|
+
// per-banner-instance and doesn't need to persist. The next server push
|
|
22
|
+
// (next hour) acts as a fresh ping.
|
|
23
|
+
var pendingUpdateMsg = null;
|
|
24
|
+
var activeAuthRequiredMsg = null;
|
|
25
|
+
var authReminderVisible = false;
|
|
26
|
+
|
|
27
|
+
// ========================================================
|
|
28
|
+
// Init
|
|
29
|
+
// ========================================================
|
|
30
|
+
|
|
31
|
+
export function initAppNotifications() {
|
|
32
|
+
bellBtn = document.getElementById("notif-center-btn");
|
|
33
|
+
badgeEl = document.getElementById("notif-center-badge");
|
|
34
|
+
|
|
35
|
+
// Create banner container
|
|
36
|
+
bannerContainer = document.createElement("div");
|
|
37
|
+
bannerContainer.className = "notif-banner-container";
|
|
38
|
+
document.body.appendChild(bannerContainer);
|
|
39
|
+
|
|
40
|
+
if (bellBtn) {
|
|
41
|
+
bellBtn.addEventListener("click", function (e) {
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
showAllBanners();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ========================================================
|
|
49
|
+
// Show all stored notifications as banners
|
|
50
|
+
// ========================================================
|
|
51
|
+
|
|
52
|
+
function showAllBanners() {
|
|
53
|
+
// Clear existing banners first
|
|
54
|
+
if (bannerContainer) bannerContainer.innerHTML = "";
|
|
55
|
+
|
|
56
|
+
// Re-add update banner if present (may be suppressed by recent dismiss)
|
|
57
|
+
if (pendingUpdateMsg) showUpdateBanner(pendingUpdateMsg);
|
|
58
|
+
|
|
59
|
+
for (var i = 0; i < notifications.length; i++) {
|
|
60
|
+
showBanner(notifications[i], false);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (activeAuthRequiredMsg) showAuthRequiredBanner(activeAuthRequiredMsg);
|
|
64
|
+
if (authReminderVisible) showLoginReminderBanner();
|
|
65
|
+
|
|
66
|
+
// Check if any banner actually got rendered (update/auth banners can be suppressed)
|
|
67
|
+
var hasVisibleBanner = bannerContainer.children.length > 0;
|
|
68
|
+
if (notifications.length === 0 && !hasVisibleBanner) {
|
|
69
|
+
showBanner({
|
|
70
|
+
id: "_empty",
|
|
71
|
+
type: "info",
|
|
72
|
+
title: randomEmptyMessage(),
|
|
73
|
+
body: "",
|
|
74
|
+
slug: "",
|
|
75
|
+
}, 3000);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ========================================================
|
|
80
|
+
// Banner
|
|
81
|
+
// ========================================================
|
|
82
|
+
|
|
83
|
+
function showBanner(notif, autoDismissMs) {
|
|
84
|
+
if (!bannerContainer) return;
|
|
85
|
+
|
|
86
|
+
var isEmpty = notif.id === "_empty";
|
|
87
|
+
var isPermission = notif.type === "permission_request" && notif.meta && notif.meta.requestId;
|
|
88
|
+
var isAuthRequired = notif.type === "auth_required";
|
|
89
|
+
var isUserMention = notif.type === "user_mention";
|
|
90
|
+
var projectIcon = isEmpty ? null : getProjectIcon(notif.slug);
|
|
91
|
+
var projectName = isEmpty ? "" : (isAuthRequired ? "CLAY" : getProjectName(notif.slug));
|
|
92
|
+
var userMentionAvatarSrc = isUserMention ? buildUserMentionAvatarSrc(notif) : null;
|
|
93
|
+
|
|
94
|
+
var banner = document.createElement("div");
|
|
95
|
+
banner.className = "notif-banner" + (isAuthRequired ? " notif-banner-update notif-banner-auth" : isPermission ? " notif-banner-permission" : isUserMention ? " notif-banner-user-mention" : "");
|
|
96
|
+
if (!isEmpty) banner.setAttribute("data-notif-id", notif.id);
|
|
97
|
+
if (isAuthRequired) banner.setAttribute("data-auth-banner", "true");
|
|
98
|
+
|
|
99
|
+
var iconHtmlStr = userMentionAvatarSrc
|
|
100
|
+
? '<img class="notif-banner-avatar" src="' + escapeHtml(userMentionAvatarSrc) + '" alt="' + escapeHtml((notif.meta && notif.meta.fromName) || "User") + '">'
|
|
101
|
+
: isAuthRequired
|
|
102
|
+
? '<img src="/icon-banded-76.png" width="32" height="32" alt="Clagentic:Console" style="border-radius:8px">'
|
|
103
|
+
: projectIcon
|
|
104
|
+
? '<span class="notif-banner-emoji">' + projectIcon + '</span>'
|
|
105
|
+
: isEmpty
|
|
106
|
+
? '<img src="/icon-banded-76.png" width="32" height="32" alt="Clagentic:Console" style="border-radius:8px">'
|
|
107
|
+
: iconHtml("folder");
|
|
108
|
+
|
|
109
|
+
// Format permission title as "Can I ..." style
|
|
110
|
+
if (isPermission && notif.meta) {
|
|
111
|
+
var permInfo = formatPermissionInfo(notif.meta.toolName, notif.meta.toolInput);
|
|
112
|
+
if (permInfo) {
|
|
113
|
+
notif = Object.assign({}, notif, { title: "Can I " + permInfo.verb + (permInfo.target ? " " + permInfo.target : "") + "?" });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
var actionsHtml = "";
|
|
118
|
+
if (isPermission) {
|
|
119
|
+
actionsHtml =
|
|
120
|
+
'<div class="notif-banner-actions">' +
|
|
121
|
+
'<button class="notif-banner-allow">Sure</button>' +
|
|
122
|
+
'<button class="notif-banner-always">Allow for session</button>' +
|
|
123
|
+
'<button class="notif-banner-deny">No</button>' +
|
|
124
|
+
'<button class="notif-banner-goto" title="Go to session">' + iconHtml("external-link") + '</button>' +
|
|
125
|
+
'</div>';
|
|
126
|
+
} else if (isAuthRequired) {
|
|
127
|
+
actionsHtml =
|
|
128
|
+
'<div class="notif-banner-actions">' +
|
|
129
|
+
'<button class="notif-banner-auth-login notif-banner-update-now">Open terminal & log in</button>' +
|
|
130
|
+
'</div>';
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
banner.innerHTML =
|
|
134
|
+
'<div class="notif-banner-icon">' + iconHtmlStr + '</div>' +
|
|
135
|
+
'<div class="notif-banner-body">' +
|
|
136
|
+
(projectName ? '<div class="notif-banner-project">' + escapeHtml(projectName) + '</div>' : '') +
|
|
137
|
+
'<div class="notif-banner-title">' + escapeHtml(notif.title) + '</div>' +
|
|
138
|
+
(notif.body ? '<div class="notif-banner-text">' + escapeHtml(notif.body) + '</div>' : '') +
|
|
139
|
+
actionsHtml +
|
|
140
|
+
'</div>' +
|
|
141
|
+
(!isEmpty ? '<button class="notif-banner-close">' + iconHtml("x") + '</button>' : '');
|
|
142
|
+
|
|
143
|
+
bannerContainer.appendChild(banner);
|
|
144
|
+
refreshIcons();
|
|
145
|
+
ensureClearAllButton();
|
|
146
|
+
|
|
147
|
+
requestAnimationFrame(function () {
|
|
148
|
+
banner.classList.add("show");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
if (!isEmpty) {
|
|
152
|
+
if (!isAuthRequired) {
|
|
153
|
+
// Click banner body -> navigate + dismiss
|
|
154
|
+
banner.addEventListener("click", function (e) {
|
|
155
|
+
if (e.target.closest(".notif-banner-close")) return;
|
|
156
|
+
removeBanner(banner);
|
|
157
|
+
dismissNotif(notif.id);
|
|
158
|
+
navigateToNotification(notif);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Close button -> dismiss
|
|
163
|
+
var closeBtn = banner.querySelector(".notif-banner-close");
|
|
164
|
+
if (closeBtn) {
|
|
165
|
+
closeBtn.addEventListener("click", function (e) {
|
|
166
|
+
e.stopPropagation();
|
|
167
|
+
if (isAuthRequired) activeAuthRequiredMsg = null;
|
|
168
|
+
removeBanner(banner);
|
|
169
|
+
dismissNotif(notif.id);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Permission actions
|
|
174
|
+
if (isPermission) {
|
|
175
|
+
var sureBtn = banner.querySelector(".notif-banner-allow");
|
|
176
|
+
var alwaysBtn = banner.querySelector(".notif-banner-always");
|
|
177
|
+
var noBtn = banner.querySelector(".notif-banner-deny");
|
|
178
|
+
var gotoBtn = banner.querySelector(".notif-banner-goto");
|
|
179
|
+
|
|
180
|
+
if (sureBtn) {
|
|
181
|
+
sureBtn.addEventListener("click", function (e) {
|
|
182
|
+
e.stopPropagation();
|
|
183
|
+
sendPermissionResponse(notif.meta.requestId, true, notif.slug);
|
|
184
|
+
removeBanner(banner);
|
|
185
|
+
dismissNotif(notif.id);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (alwaysBtn) {
|
|
189
|
+
alwaysBtn.addEventListener("click", function (e) {
|
|
190
|
+
e.stopPropagation();
|
|
191
|
+
sendPermissionResponse(notif.meta.requestId, "always", notif.slug);
|
|
192
|
+
removeBanner(banner);
|
|
193
|
+
dismissNotif(notif.id);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
if (noBtn) {
|
|
197
|
+
noBtn.addEventListener("click", function (e) {
|
|
198
|
+
e.stopPropagation();
|
|
199
|
+
sendPermissionResponse(notif.meta.requestId, false, notif.slug);
|
|
200
|
+
removeBanner(banner);
|
|
201
|
+
dismissNotif(notif.id);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
if (gotoBtn) {
|
|
205
|
+
gotoBtn.addEventListener("click", function (e) {
|
|
206
|
+
e.stopPropagation();
|
|
207
|
+
navigateToNotification(notif);
|
|
208
|
+
removeBanner(banner);
|
|
209
|
+
dismissNotif(notif.id);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (isAuthRequired) {
|
|
215
|
+
var loginBtn = banner.querySelector(".notif-banner-auth-login");
|
|
216
|
+
if (loginBtn) {
|
|
217
|
+
loginBtn.addEventListener("click", function (e) {
|
|
218
|
+
e.stopPropagation();
|
|
219
|
+
activeAuthRequiredMsg = null;
|
|
220
|
+
removeBanner(banner);
|
|
221
|
+
dismissNotif(notif.id);
|
|
222
|
+
var authMeta = notif.meta || {};
|
|
223
|
+
startLoginCommand(authMeta.loginCommand || ((authMeta.vendor || "claude") === "codex" ? "codex login --device-auth" : "claude login"));
|
|
224
|
+
showLoginReminderBanner();
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Auto-dismiss (number = ms, false = stay)
|
|
231
|
+
if (typeof autoDismissMs === "number") {
|
|
232
|
+
setTimeout(function () { removeBanner(banner); }, autoDismissMs);
|
|
233
|
+
} else if (autoDismissMs === true) {
|
|
234
|
+
setTimeout(function () { removeBanner(banner); }, 3000);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function startLoginCommand(loginCommand) {
|
|
239
|
+
var ws = getWs();
|
|
240
|
+
if (!ws || ws.readyState !== 1) return;
|
|
241
|
+
var termCommand = (loginCommand || "claude login") + "\n";
|
|
242
|
+
store.set({ pendingTermCommand: termCommand });
|
|
243
|
+
ws.send(JSON.stringify({ type: "term_create", cols: 80, rows: 24 }));
|
|
244
|
+
openTerminal();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function showLoginReminderBanner() {
|
|
248
|
+
if (!bannerContainer) return;
|
|
249
|
+
authReminderVisible = true;
|
|
250
|
+
var existing = bannerContainer.querySelector('[data-auth-reminder="true"]');
|
|
251
|
+
if (existing) removeBanner(existing);
|
|
252
|
+
var banner = document.createElement("div");
|
|
253
|
+
banner.className = "notif-banner notif-banner-update";
|
|
254
|
+
banner.setAttribute("data-notif-id", "_auth_reminder");
|
|
255
|
+
banner.setAttribute("data-auth-reminder", "true");
|
|
256
|
+
banner.innerHTML =
|
|
257
|
+
'<div class="notif-banner-icon">' + iconHtml("check-circle") + '</div>' +
|
|
258
|
+
'<div class="notif-banner-body">' +
|
|
259
|
+
'<div class="notif-banner-project">CONSOLE</div>' +
|
|
260
|
+
'<div class="notif-banner-title">Login started</div>' +
|
|
261
|
+
'<div class="notif-banner-text">After the login completes, open a new session so Clagentic:Console picks up the fresh auth state.</div>' +
|
|
262
|
+
'<div class="notif-banner-actions">' +
|
|
263
|
+
'<button class="notif-banner-new-session notif-banner-update-now">Open new session</button>' +
|
|
264
|
+
'</div>' +
|
|
265
|
+
'</div>' +
|
|
266
|
+
'<button class="notif-banner-close">' + iconHtml("x") + '</button>';
|
|
267
|
+
|
|
268
|
+
bannerContainer.appendChild(banner);
|
|
269
|
+
refreshIcons();
|
|
270
|
+
|
|
271
|
+
requestAnimationFrame(function () {
|
|
272
|
+
banner.classList.add("show");
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
var newSessionBtn = banner.querySelector(".notif-banner-new-session");
|
|
276
|
+
if (newSessionBtn) {
|
|
277
|
+
newSessionBtn.addEventListener("click", function (e) {
|
|
278
|
+
e.stopPropagation();
|
|
279
|
+
authReminderVisible = false;
|
|
280
|
+
var ws = getWs();
|
|
281
|
+
if (ws && ws.readyState === 1) {
|
|
282
|
+
ws.send(JSON.stringify({ type: "new_session" }));
|
|
283
|
+
}
|
|
284
|
+
removeBanner(banner);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
var closeBtn = banner.querySelector(".notif-banner-close");
|
|
289
|
+
if (closeBtn) {
|
|
290
|
+
closeBtn.addEventListener("click", function (e) {
|
|
291
|
+
e.stopPropagation();
|
|
292
|
+
authReminderVisible = false;
|
|
293
|
+
removeBanner(banner);
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export function showAuthRequiredBanner(msg) {
|
|
299
|
+
if (!bannerContainer) return;
|
|
300
|
+
var vendor = (msg && (msg.vendor || (msg.meta && msg.meta.vendor))) || "claude";
|
|
301
|
+
var loginCommand = (msg && (msg.loginCommand || (msg.meta && msg.meta.loginCommand))) || (vendor === "codex" ? "codex login --device-auth" : "claude login");
|
|
302
|
+
activeAuthRequiredMsg = Object.assign({}, msg || {}, {
|
|
303
|
+
id: (msg && msg.id) || ("_auth_" + Date.now()),
|
|
304
|
+
type: "auth_required",
|
|
305
|
+
vendor: vendor,
|
|
306
|
+
loginCommand: loginCommand,
|
|
307
|
+
meta: Object.assign({}, msg && msg.meta ? msg.meta : {}, {
|
|
308
|
+
vendor: vendor,
|
|
309
|
+
loginCommand: loginCommand,
|
|
310
|
+
}),
|
|
311
|
+
});
|
|
312
|
+
var existing = bannerContainer.querySelector('[data-auth-banner="true"]');
|
|
313
|
+
if (existing) removeBanner(existing);
|
|
314
|
+
showBanner(activeAuthRequiredMsg, false);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function removeBanner(banner) {
|
|
318
|
+
if (!banner || !banner.parentNode) return;
|
|
319
|
+
banner.classList.remove("show");
|
|
320
|
+
banner.classList.add("hide");
|
|
321
|
+
// Update the clear-all button right away so it disappears before the
|
|
322
|
+
// last banner finishes animating out, and again after the node is
|
|
323
|
+
// actually removed in case the count check depends on DOM presence.
|
|
324
|
+
ensureClearAllButton();
|
|
325
|
+
setTimeout(function () {
|
|
326
|
+
if (banner.parentNode) banner.parentNode.removeChild(banner);
|
|
327
|
+
ensureClearAllButton();
|
|
328
|
+
}, 300);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Count real (non-"_empty", not in hide animation) banners to decide
|
|
332
|
+
// whether a Clear-all affordance is worth showing.
|
|
333
|
+
function countActiveBanners() {
|
|
334
|
+
if (!bannerContainer) return 0;
|
|
335
|
+
var banners = bannerContainer.querySelectorAll('.notif-banner');
|
|
336
|
+
var n = 0;
|
|
337
|
+
for (var i = 0; i < banners.length; i++) {
|
|
338
|
+
if (banners[i].classList.contains('hide')) continue;
|
|
339
|
+
if (banners[i].getAttribute('data-notif-id')) n++;
|
|
340
|
+
}
|
|
341
|
+
return n;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function ensureClearAllButton() {
|
|
345
|
+
if (!bannerContainer) return;
|
|
346
|
+
var existing = bannerContainer.querySelector('.notif-banner-clear-all');
|
|
347
|
+
if (countActiveBanners() >= 2) {
|
|
348
|
+
if (existing) return;
|
|
349
|
+
var btn = document.createElement('button');
|
|
350
|
+
btn.type = 'button';
|
|
351
|
+
btn.className = 'notif-banner-clear-all';
|
|
352
|
+
btn.innerHTML = iconHtml('x') + '<span>Clear all</span>';
|
|
353
|
+
btn.addEventListener('click', clearAllBanners);
|
|
354
|
+
bannerContainer.insertBefore(btn, bannerContainer.firstChild);
|
|
355
|
+
refreshIcons();
|
|
356
|
+
} else if (existing && existing.parentNode) {
|
|
357
|
+
existing.parentNode.removeChild(existing);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function clearAllBanners() {
|
|
362
|
+
var ws = getWs();
|
|
363
|
+
if (ws && ws.readyState === 1) {
|
|
364
|
+
ws.send(JSON.stringify({ type: 'notification_dismiss_all' }));
|
|
365
|
+
}
|
|
366
|
+
// Dismiss visually right away — the server will broadcast
|
|
367
|
+
// notification_dismissed_all too, but doing it optimistically makes
|
|
368
|
+
// the click feel instant.
|
|
369
|
+
if (bannerContainer) {
|
|
370
|
+
var banners = bannerContainer.querySelectorAll('.notif-banner[data-notif-id]');
|
|
371
|
+
for (var i = 0; i < banners.length; i++) removeBanner(banners[i]);
|
|
372
|
+
}
|
|
373
|
+
var btn = bannerContainer && bannerContainer.querySelector('.notif-banner-clear-all');
|
|
374
|
+
if (btn && btn.parentNode) btn.parentNode.removeChild(btn);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function sendPermissionResponse(requestId, decision, slug) {
|
|
378
|
+
var ws = getWs();
|
|
379
|
+
if (ws && ws.readyState === 1) {
|
|
380
|
+
var d = decision === "always" ? "allow_always" : decision ? "allow" : "deny";
|
|
381
|
+
var msg = { type: "permission_response", requestId: requestId, decision: d };
|
|
382
|
+
if (slug) msg.targetSlug = slug;
|
|
383
|
+
ws.send(JSON.stringify(msg));
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function dismissNotif(id) {
|
|
388
|
+
var ws = getWs();
|
|
389
|
+
if (ws && ws.readyState === 1) {
|
|
390
|
+
ws.send(JSON.stringify({ type: "notification_dismiss", ids: [id] }));
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// ========================================================
|
|
395
|
+
// Message handlers
|
|
396
|
+
// ========================================================
|
|
397
|
+
|
|
398
|
+
export function handleNotificationsState(msg) {
|
|
399
|
+
notifications = msg.notifications || [];
|
|
400
|
+
unreadCount = msg.unreadCount || 0;
|
|
401
|
+
updateBadge();
|
|
402
|
+
|
|
403
|
+
// Check for pending session navigation after project switch
|
|
404
|
+
try {
|
|
405
|
+
var pendingSession = sessionStorage.getItem("pending-notif-session");
|
|
406
|
+
if (pendingSession) {
|
|
407
|
+
sessionStorage.removeItem("pending-notif-session");
|
|
408
|
+
var ws = getWs();
|
|
409
|
+
if (ws && ws.readyState === 1) {
|
|
410
|
+
ws.send(JSON.stringify({ type: "switch_session", id: parseInt(pendingSession, 10) }));
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
} catch (e) {}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export function handleNotificationCreated(msg) {
|
|
417
|
+
var notif = msg.notification;
|
|
418
|
+
|
|
419
|
+
// Auto-dismiss if it's for the session the user is currently viewing
|
|
420
|
+
var activeSession = store.get('activeSessionId') || null;
|
|
421
|
+
console.log("[notif] created:", notif.type, "sessionId=" + notif.sessionId + "(" + typeof notif.sessionId + ")", "active=" + activeSession + "(" + typeof activeSession + ")", "match=" + (notif.sessionId == activeSession));
|
|
422
|
+
if (notif.type !== "auth_required" && notif.sessionId && String(notif.sessionId) === String(activeSession)) {
|
|
423
|
+
dismissNotif(notif.id);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
notifications.unshift(notif);
|
|
428
|
+
unreadCount = msg.unreadCount;
|
|
429
|
+
updateBadge();
|
|
430
|
+
|
|
431
|
+
// user_mention banners are persistent (no auto-dismiss). They go away when:
|
|
432
|
+
// 1. The user clicks the banner (which navigates to the session — see
|
|
433
|
+
// banner click handler in showBanner / navigateToNotification), OR
|
|
434
|
+
// 2. The user navigates to the target session by some other path, in which
|
|
435
|
+
// case handleNotificationCreated above already dismissed the notif on
|
|
436
|
+
// activeSessionId match, OR
|
|
437
|
+
// 3. The user clicks the X close button.
|
|
438
|
+
// Permission and auth banners are also persistent for the same UX reason.
|
|
439
|
+
var _autoDismiss = (notif.type === "permission_request" || notif.type === "auth_required" || notif.type === "user_mention") ? false : true;
|
|
440
|
+
showBanner(notif, _autoDismiss);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export function handleNotificationDismissed(msg) {
|
|
444
|
+
var ids = msg.ids || [];
|
|
445
|
+
notifications = notifications.filter(function (n) { return ids.indexOf(n.id) === -1; });
|
|
446
|
+
unreadCount = msg.unreadCount;
|
|
447
|
+
updateBadge();
|
|
448
|
+
// Remove corresponding banners if visible
|
|
449
|
+
if (bannerContainer) {
|
|
450
|
+
for (var i = 0; i < ids.length; i++) {
|
|
451
|
+
var el = bannerContainer.querySelector('[data-notif-id="' + ids[i] + '"]');
|
|
452
|
+
if (el) removeBanner(el);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export function handleNotificationDismissedAll() {
|
|
458
|
+
notifications = [];
|
|
459
|
+
unreadCount = 0;
|
|
460
|
+
updateBadge();
|
|
461
|
+
if (bannerContainer) bannerContainer.innerHTML = "";
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// ========================================================
|
|
465
|
+
// Badge
|
|
466
|
+
// ========================================================
|
|
467
|
+
|
|
468
|
+
function updateBadge() {
|
|
469
|
+
if (!badgeEl) return;
|
|
470
|
+
if (unreadCount > 0) {
|
|
471
|
+
badgeEl.textContent = unreadCount > 99 ? "99+" : String(unreadCount);
|
|
472
|
+
badgeEl.classList.remove("hidden");
|
|
473
|
+
} else {
|
|
474
|
+
badgeEl.classList.add("hidden");
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// ========================================================
|
|
479
|
+
// Navigation
|
|
480
|
+
// ========================================================
|
|
481
|
+
|
|
482
|
+
function navigateToNotification(notif) {
|
|
483
|
+
var currentSlug = store.get('currentSlug') || "";
|
|
484
|
+
var needsProjectSwitch = notif.slug && notif.slug !== currentSlug;
|
|
485
|
+
|
|
486
|
+
if (needsProjectSwitch) {
|
|
487
|
+
// Store target session for after project switch
|
|
488
|
+
if (notif.sessionId) {
|
|
489
|
+
try { sessionStorage.setItem("pending-notif-session", notif.sessionId); } catch (e) {}
|
|
490
|
+
}
|
|
491
|
+
switchProject(notif.slug);
|
|
492
|
+
} else if (notif.sessionId) {
|
|
493
|
+
var ws = getWs();
|
|
494
|
+
if (ws && ws.readyState === 1) {
|
|
495
|
+
ws.send(JSON.stringify({ type: "switch_session", id: notif.sessionId }));
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// Build the sender avatar URL for a user_mention notification banner.
|
|
501
|
+
// Prefers the avatar fields stashed in `notif.meta` (set by the server when the
|
|
502
|
+
// notification is created), and falls back to the cached user list from
|
|
503
|
+
// `cachedAllUsers` so the banner still has a face even if meta is missing.
|
|
504
|
+
function buildUserMentionAvatarSrc(notif) {
|
|
505
|
+
var meta = (notif && notif.meta) || {};
|
|
506
|
+
if (meta.fromAvatarStyle || meta.fromAvatarSeed || meta.fromAvatarCustom) {
|
|
507
|
+
return userAvatarUrl({
|
|
508
|
+
avatarStyle: meta.fromAvatarStyle,
|
|
509
|
+
avatarSeed: meta.fromAvatarSeed,
|
|
510
|
+
avatarCustom: meta.fromAvatarCustom || "",
|
|
511
|
+
username: meta.fromName,
|
|
512
|
+
id: meta.fromUserId,
|
|
513
|
+
}, 32);
|
|
514
|
+
}
|
|
515
|
+
if (meta.fromUserId) {
|
|
516
|
+
var users = store.get('cachedAllUsers') || [];
|
|
517
|
+
for (var i = 0; i < users.length; i++) {
|
|
518
|
+
if (users[i] && users[i].id === meta.fromUserId) return userAvatarUrl(users[i], 32);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return null;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// ========================================================
|
|
525
|
+
// Update available banner
|
|
526
|
+
// ========================================================
|
|
527
|
+
|
|
528
|
+
export function showUpdateBanner(msg) {
|
|
529
|
+
if (!msg || !msg.version) return;
|
|
530
|
+
pendingUpdateMsg = msg;
|
|
531
|
+
if (!bannerContainer) return;
|
|
532
|
+
|
|
533
|
+
// Remove any existing update banner
|
|
534
|
+
var existing = bannerContainer.querySelector('[data-notif-id="_update"]');
|
|
535
|
+
if (existing) removeBanner(existing);
|
|
536
|
+
|
|
537
|
+
var isHeadless = store.get('isHeadlessMode');
|
|
538
|
+
var updTag = msg.version.indexOf("-beta") !== -1 ? "beta" : "latest";
|
|
539
|
+
|
|
540
|
+
var banner = document.createElement("div");
|
|
541
|
+
banner.className = "notif-banner notif-banner-update";
|
|
542
|
+
banner.setAttribute("data-notif-id", "_update");
|
|
543
|
+
|
|
544
|
+
var actionsHtml = '';
|
|
545
|
+
if (!isHeadless) {
|
|
546
|
+
actionsHtml =
|
|
547
|
+
'<div class="notif-banner-actions">' +
|
|
548
|
+
'<button class="notif-banner-update-now">Update now</button>' +
|
|
549
|
+
'</div>';
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
banner.innerHTML =
|
|
553
|
+
'<div class="notif-banner-icon"><img src="/icon-banded-76.png" width="32" height="32" alt="Clagentic:Console" style="border-radius:8px"></div>' +
|
|
554
|
+
'<div class="notif-banner-body">' +
|
|
555
|
+
'<div class="notif-banner-project">CLAY</div>' +
|
|
556
|
+
'<div class="notif-banner-title">v' + escapeHtml(msg.version) + ' is available</div>' +
|
|
557
|
+
(isHeadless
|
|
558
|
+
? '<div class="notif-banner-text">Run: npx clay-server@' + escapeHtml(updTag) + '</div>'
|
|
559
|
+
: '') +
|
|
560
|
+
actionsHtml +
|
|
561
|
+
'</div>' +
|
|
562
|
+
'<button class="notif-banner-close">' + iconHtml("x") + '</button>';
|
|
563
|
+
|
|
564
|
+
bannerContainer.appendChild(banner);
|
|
565
|
+
refreshIcons();
|
|
566
|
+
|
|
567
|
+
requestAnimationFrame(function () {
|
|
568
|
+
banner.classList.add("show");
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
// "Update now" button
|
|
572
|
+
var updateBtn = banner.querySelector(".notif-banner-update-now");
|
|
573
|
+
if (updateBtn) {
|
|
574
|
+
updateBtn.addEventListener("click", function (e) {
|
|
575
|
+
e.stopPropagation();
|
|
576
|
+
var ws = getWs();
|
|
577
|
+
if (ws && ws.readyState === 1) {
|
|
578
|
+
ws.send(JSON.stringify({ type: "update_now" }));
|
|
579
|
+
updateBtn.textContent = "Updating...";
|
|
580
|
+
updateBtn.disabled = true;
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// Close button -> dismiss. No local throttle; the server pushes a new
|
|
586
|
+
// update_available on the next hour boundary, which re-shows naturally.
|
|
587
|
+
var closeBtn = banner.querySelector(".notif-banner-close");
|
|
588
|
+
if (closeBtn) {
|
|
589
|
+
closeBtn.addEventListener("click", function (e) {
|
|
590
|
+
e.stopPropagation();
|
|
591
|
+
removeBanner(banner);
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// ========================================================
|
|
597
|
+
// Helpers
|
|
598
|
+
// ========================================================
|
|
599
|
+
|
|
600
|
+
function formatPermissionInfo(toolName, toolInput) {
|
|
601
|
+
if (!toolName) return null;
|
|
602
|
+
var input = toolInput && typeof toolInput === "object" ? toolInput : {};
|
|
603
|
+
var verb = "use " + toolName;
|
|
604
|
+
var target = "";
|
|
605
|
+
var shortPath = function (p) { return p ? p.split(/[/\\]/).pop() : ""; };
|
|
606
|
+
|
|
607
|
+
switch (toolName) {
|
|
608
|
+
case "Write": verb = "write to"; target = shortPath(input.file_path); break;
|
|
609
|
+
case "Edit": verb = "edit"; target = shortPath(input.file_path); break;
|
|
610
|
+
case "Read": verb = "read"; target = shortPath(input.file_path); break;
|
|
611
|
+
case "Bash": verb = "run"; target = input.description || (input.command || "").substring(0, 80); break;
|
|
612
|
+
case "Grep": verb = "search"; target = input.pattern || ""; break;
|
|
613
|
+
case "Glob": verb = "search for files in"; target = input.pattern || ""; break;
|
|
614
|
+
case "WebFetch": verb = "fetch"; target = input.url || ""; break;
|
|
615
|
+
case "WebSearch": verb = "search the web for"; target = input.query || ""; break;
|
|
616
|
+
}
|
|
617
|
+
return { verb: verb, target: target };
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
var EMPTY_MESSAGES = [
|
|
621
|
+
"Quiet. Too quiet.",
|
|
622
|
+
"Nothing. Suspiciously nothing.",
|
|
623
|
+
"Inbox zero. Brag about it.",
|
|
624
|
+
"No notifications. Are you even working?",
|
|
625
|
+
"All clear. For now.",
|
|
626
|
+
"The void stares back.",
|
|
627
|
+
"Notification-free since just now.",
|
|
628
|
+
"You have 0 problems. Allegedly.",
|
|
629
|
+
"Tumbleweeds.",
|
|
630
|
+
"Your agents are napping.",
|
|
631
|
+
];
|
|
632
|
+
|
|
633
|
+
function randomEmptyMessage() {
|
|
634
|
+
return EMPTY_MESSAGES[Math.floor(Math.random() * EMPTY_MESSAGES.length)];
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
function getProjectIcon(slug) {
|
|
638
|
+
var projects = getCachedProjects();
|
|
639
|
+
for (var i = 0; i < projects.length; i++) {
|
|
640
|
+
if (projects[i].slug === slug) return projects[i].icon || null;
|
|
641
|
+
}
|
|
642
|
+
return null;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
function getProjectName(slug) {
|
|
646
|
+
var projects = getCachedProjects();
|
|
647
|
+
for (var i = 0; i < projects.length; i++) {
|
|
648
|
+
if (projects[i].slug === slug) return projects[i].title || projects[i].name || slug;
|
|
649
|
+
}
|
|
650
|
+
return slug;
|
|
651
|
+
}
|