@clagentic/console 1.4.1 → 1.5.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 +47 -21
- package/bin/cli.js +163 -60
- package/deploy/clagentic-console.service +2 -0
- package/lib/agents-favorites.js +3 -1
- package/lib/agents.js +75 -5
- package/lib/browser-mcp-server.js +5 -5
- package/lib/clone-validate.js +44 -0
- package/lib/config.js +75 -0
- package/lib/daemon.js +116 -8
- package/lib/dm.js +12 -1
- package/lib/ipc.js +12 -0
- package/lib/lite-detect.js +92 -0
- package/lib/os-users.js +8 -8
- package/lib/project-connection.js +7 -1
- package/lib/project-external-trigger.js +65 -6
- package/lib/project-loop.js +44 -3
- package/lib/project-sessions.js +95 -37
- package/lib/project.js +6 -1
- package/lib/public/app.js +6 -3
- package/lib/public/css/at-agents.css +68 -0
- package/lib/public/index.html +60 -0
- package/lib/public/modules/app-messages.js +38 -4
- package/lib/public/modules/at-agents.js +248 -0
- package/lib/public/modules/escape-html.js +19 -0
- package/lib/public/modules/filebrowser.js +12 -9
- package/lib/public/modules/input.js +26 -4
- package/lib/public/modules/pending-navigate.js +28 -0
- package/lib/public/modules/playbook.js +1 -1
- package/lib/public/modules/project-settings.js +75 -0
- package/lib/public/modules/project-switcher.js +1 -1
- package/lib/public/modules/server-settings.js +33 -0
- package/lib/public/modules/sticky-notes-fmt.js +52 -0
- package/lib/public/modules/sticky-notes.js +23 -5
- package/lib/public/modules/theme.js +1 -1
- package/lib/public/modules/tool-palette.js +1 -1
- package/lib/public/modules/utils.js +1 -3
- package/lib/public/style.css +1 -0
- package/lib/push.js +13 -2
- package/lib/scheduler.js +26 -2
- package/lib/sdk-bridge.js +7 -4
- package/lib/server-dm.js +16 -0
- package/lib/server-settings.js +42 -0
- package/lib/server-skills.js +10 -7
- package/lib/server.js +14 -3
- package/lib/sessions.js +4 -0
- package/lib/ws-schema.js +11 -1
- package/lib/yoke/adapters/claude-worker.js +2 -2
- package/lib/yoke/adapters/claude.js +47 -10
- package/lib/yoke/adapters/codex.js +14 -3
- package/lib/yoke/mcp-bridge-server.js +7 -7
- package/package.json +1 -1
- package/lib/relay-agent-claims.js +0 -480
package/lib/public/index.html
CHANGED
|
@@ -568,6 +568,7 @@
|
|
|
568
568
|
<div class="settings-nav-category">Config</div>
|
|
569
569
|
<button class="settings-nav-item" data-section="instructions"><span>Instructions</span></button>
|
|
570
570
|
<button class="settings-nav-item" data-section="environment"><span>Environment</span></button>
|
|
571
|
+
<button class="settings-nav-item hidden" data-section="lite" id="ps-nav-lite"><span>Lite</span></button>
|
|
571
572
|
</div>
|
|
572
573
|
</div>
|
|
573
574
|
</div>
|
|
@@ -683,6 +684,25 @@
|
|
|
683
684
|
</div>
|
|
684
685
|
</div>
|
|
685
686
|
</div>
|
|
687
|
+
<!-- Clagentic: Lite -->
|
|
688
|
+
<div class="ps-section hidden" data-section="lite" id="ps-section-lite">
|
|
689
|
+
<h2>Clagentic: Lite</h2>
|
|
690
|
+
<p class="ps-section-desc">Clagentic: Lite adds agentic gates, memory, and audit trails to this project.</p>
|
|
691
|
+
<div class="settings-card">
|
|
692
|
+
<div class="settings-field-row">
|
|
693
|
+
<div>
|
|
694
|
+
<label class="settings-label">Enrollment Status</label>
|
|
695
|
+
<div class="settings-hint">Whether this project is enrolled in Clagentic: Lite.</div>
|
|
696
|
+
</div>
|
|
697
|
+
<span class="settings-value settings-badge" id="ps-lite-status-text">-</span>
|
|
698
|
+
</div>
|
|
699
|
+
<div class="settings-field-row" style="margin-top: 8px;">
|
|
700
|
+
<button class="settings-btn-sm hidden" id="ps-lite-enroll-btn">Enroll</button>
|
|
701
|
+
<button class="settings-btn-sm hidden" id="ps-lite-unenroll-btn">Unenroll</button>
|
|
702
|
+
</div>
|
|
703
|
+
<div class="settings-hint" id="ps-lite-error" style="color: var(--error, #f38ba8); margin-top: 6px;"></div>
|
|
704
|
+
</div>
|
|
705
|
+
</div>
|
|
686
706
|
<!-- Environment -->
|
|
687
707
|
<div class="ps-section" data-section="environment">
|
|
688
708
|
<h2>Environment</h2>
|
|
@@ -1018,6 +1038,9 @@
|
|
|
1018
1038
|
<button class="settings-nav-item settings-admin-only" data-section="admin-projects"><span>Projects</span></button>
|
|
1019
1039
|
<button class="settings-nav-item settings-admin-only" data-section="admin-smtp"><span>Email</span></button>
|
|
1020
1040
|
<div class="settings-nav-separator"></div>
|
|
1041
|
+
<div class="settings-nav-category">Clagentic</div>
|
|
1042
|
+
<button class="settings-nav-item" data-section="lite" id="settings-clagentic-nav"><span>Lite</span></button>
|
|
1043
|
+
<div class="settings-nav-separator"></div>
|
|
1021
1044
|
<div class="settings-nav-category">Server</div>
|
|
1022
1045
|
<button class="settings-nav-item hidden" data-section="keep-awake" id="settings-keep-awake-nav"><span>Keep Awake</span></button>
|
|
1023
1046
|
<button class="settings-nav-item" data-section="restart"><span>Restart</span></button>
|
|
@@ -1265,6 +1288,43 @@
|
|
|
1265
1288
|
</label>
|
|
1266
1289
|
</div>
|
|
1267
1290
|
</div>
|
|
1291
|
+
<!-- Clagentic: Lite — always rendered; JS toggles installed vs not-installed sub-states -->
|
|
1292
|
+
<div class="server-settings-section" data-section="lite" id="settings-clagentic-section">
|
|
1293
|
+
<h2>Clagentic: Lite</h2>
|
|
1294
|
+
<!-- shown when Lite is installed -->
|
|
1295
|
+
<div id="settings-clagentic-installed" class="hidden">
|
|
1296
|
+
<div class="settings-card">
|
|
1297
|
+
<label class="settings-toggle-row">
|
|
1298
|
+
<div>
|
|
1299
|
+
<span class="settings-label">Auto-enroll new projects</span>
|
|
1300
|
+
<div class="settings-hint">Automatically enroll projects in Clagentic: Lite when they are added.</div>
|
|
1301
|
+
</div>
|
|
1302
|
+
<input type="checkbox" id="settings-lite-auto-enroll">
|
|
1303
|
+
<span class="toggle-track"><span class="toggle-thumb"></span></span>
|
|
1304
|
+
</label>
|
|
1305
|
+
</div>
|
|
1306
|
+
</div>
|
|
1307
|
+
<!-- shown when Lite is not installed -->
|
|
1308
|
+
<div id="settings-clagentic-not-installed">
|
|
1309
|
+
<p class="settings-hint" style="margin-bottom: 16px;">Clagentic: Lite adds agentic gates, session memory, and audit trails to any repo.</p>
|
|
1310
|
+
<div class="settings-card" style="opacity:0.8;">
|
|
1311
|
+
<div class="settings-field">
|
|
1312
|
+
<label class="settings-label">Install</label>
|
|
1313
|
+
<code class="settings-mono" style="display:block;margin:6px 0 4px;font-size:12px;user-select:all;">curl -sSL https://clagentic.ai/lite/install.sh | sh</code>
|
|
1314
|
+
</div>
|
|
1315
|
+
<div class="settings-field" style="border-top:none;padding-top:0;">
|
|
1316
|
+
<a href="https://clagentic.ai" target="_blank" rel="noopener" class="settings-hint" style="color:var(--accent);">Learn more at clagentic.ai</a>
|
|
1317
|
+
</div>
|
|
1318
|
+
</div>
|
|
1319
|
+
<p class="settings-hint" style="margin-top:12px;">After installing, restart the daemon to enable enrollment controls.</p>
|
|
1320
|
+
</div>
|
|
1321
|
+
<div class="settings-card" style="margin-top:20px;">
|
|
1322
|
+
<div class="settings-field">
|
|
1323
|
+
<span class="settings-label">Discover more</span>
|
|
1324
|
+
<a href="https://clagentic.ai/tools" target="_blank" rel="noopener" class="settings-value" style="color:var(--accent);text-decoration:none;font-size:13px;">clagentic.ai/tools ↗</a>
|
|
1325
|
+
</div>
|
|
1326
|
+
</div>
|
|
1327
|
+
</div>
|
|
1268
1328
|
<!-- Auto-continue moved to User Settings > Behavior -->
|
|
1269
1329
|
<div class="server-settings-section hidden" data-section="keep-awake" id="settings-keep-awake-section">
|
|
1270
1330
|
<h2>Keep Awake</h2>
|
|
@@ -15,13 +15,15 @@ import { updateDmBadge, renderSidebarPresence, setMentionActive, renderUserStrip
|
|
|
15
15
|
import { refreshMobileChatSheet } from './sidebar-mobile.js';
|
|
16
16
|
import { handlePaletteSessionSwitch, setPaletteVersion } from './command-palette.js';
|
|
17
17
|
import { handleAgentsList, handleAgentFavoriteToggled } from './agent-picker.js';
|
|
18
|
+
import { handleProjectAgentsList, requestProjectAgents } from './at-agents.js';
|
|
18
19
|
import { handleFindInSessionResults } from './session-search.js';
|
|
19
20
|
import { handleInputSync, autoResize, resetAutoResize, builtinCommands, setScheduleBtnDisabled } from './input.js';
|
|
20
21
|
import { startThinking, appendThinking, stopThinking, resetThinkingGroup, createToolItem, updateToolExecuting, updateToolResult, markAllToolsDone, closeToolGroup, removeToolFromGroup, resetToolState, getTools, getPlanContent, setPlanContent, renderPlanBanner, renderPlanCard, getTodoTools, handleTodoWrite, handleTaskCreate, handleTaskUpdate, applyDeadSessionTodoCompaction, isPlanFilePath, enableMainInput, addTurnMeta, updateSubagentActivity, addSubagentToolEntry, markSubagentDone, initSubagentStop, updateSubagentProgress, updateSubagentTaskStatus, renderAskUserQuestion, markAskUserAnswered, renderPermissionRequest, markPermissionCancelled, markPermissionResolved, renderElicitationRequest, markElicitationResolved } from './tools.js';
|
|
21
22
|
import { showDoneNotification, playDoneSound, isNotifAlertEnabled, isNotifSoundEnabled } from './notifications.js';
|
|
22
|
-
import { handleFsList, handleFsRead, handleFileChanged, handleDirChanged, handleFileHistory, handleGitDiff, handleFileAt, refreshIfOpen,
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
23
|
+
import { handleFsList, handleFsRead, handleFileChanged, handleDirChanged, handleFileHistory, handleGitDiff, handleFileAt, refreshIfOpen, handleFsSearch } from './filebrowser.js';
|
|
24
|
+
import { getPendingNavigate, peekPendingNavigate } from './pending-navigate.js';
|
|
25
|
+
import { isProjectSettingsOpen, refreshProjectSettingsModels, handleInstructionsRead, handleInstructionsWrite, handleProjectEnv, handleProjectEnvSaved, handleProjectSharedEnv, handleProjectSharedEnvSaved, handleProjectOwnerChanged, updateLiteVisibility, handleLiteProjectStatus, handleLiteEnrollResult, handleLiteUnenrollResult } from './project-settings.js';
|
|
26
|
+
import { updateSettingsModels, updateSettingsStats, updateDaemonConfig, handleSetPinResult, handleKeepAwakeChanged, handleAutoContinueChanged, handleRestartResult, handleShutdownResult, handleSharedEnv, handleSharedEnvSaved, handleGlobalClaudeMdRead, handleGlobalClaudeMdWrite, updateSsLiteVisibility } from './server-settings.js';
|
|
25
27
|
import { handleTermList, handleTermCreated, sendTerminalCommand, handleTermOutput, handleTermResized, handleTermExited, handleTermClosed } from './terminal.js';
|
|
26
28
|
import { updateTerminalList, handleContextSourcesState } from './context-sources.js';
|
|
27
29
|
import { handleNotesList, handleNoteCreated, handleNoteUpdated, handleNoteDeleted } from './sticky-notes.js';
|
|
@@ -69,7 +71,11 @@ export function processMessage(msg) {
|
|
|
69
71
|
// append sequence. Without this, scroll events fired during DOM growth
|
|
70
72
|
// can set isUserScrolledUp=true before history_done's arm fires, leaving
|
|
71
73
|
// the user stranded mid-conversation on resume (especially on mobile).
|
|
72
|
-
|
|
74
|
+
// Peek without consuming — getPendingNavigate() is the single consumer
|
|
75
|
+
// in the history_done branch below. Calling getPendingNavigate() here
|
|
76
|
+
// would clear the value before history_done can use it.
|
|
77
|
+
var _metaNav = peekPendingNavigate();
|
|
78
|
+
if (!_metaNav || !(_metaNav.toolId || _metaNav.assistantUuid)) {
|
|
73
79
|
armStickyBottom(5000, true); // force: history replay must scroll to bottom
|
|
74
80
|
}
|
|
75
81
|
break;
|
|
@@ -225,6 +231,10 @@ export function processMessage(msg) {
|
|
|
225
231
|
}
|
|
226
232
|
}
|
|
227
233
|
updateProjectList(msg);
|
|
234
|
+
if (msg.liteInstalled !== undefined) {
|
|
235
|
+
updateLiteVisibility(!!msg.liteInstalled);
|
|
236
|
+
updateSsLiteVisibility(!!msg.liteInstalled);
|
|
237
|
+
}
|
|
228
238
|
break;
|
|
229
239
|
|
|
230
240
|
case "update_available":
|
|
@@ -454,6 +464,10 @@ export function processMessage(msg) {
|
|
|
454
464
|
handleAgentFavoriteToggled(msg);
|
|
455
465
|
break;
|
|
456
466
|
|
|
467
|
+
case "project_agents_list":
|
|
468
|
+
handleProjectAgentsList(msg);
|
|
469
|
+
break;
|
|
470
|
+
|
|
457
471
|
case "session_presence":
|
|
458
472
|
updateSessionPresence(msg.presence || {});
|
|
459
473
|
break;
|
|
@@ -493,6 +507,10 @@ export function processMessage(msg) {
|
|
|
493
507
|
break;
|
|
494
508
|
|
|
495
509
|
case "session_switched":
|
|
510
|
+
// Prefetch project agents so the @ menu is ready without a round-trip
|
|
511
|
+
// the first time the user types @. Best-effort; at-agents.js handles
|
|
512
|
+
// an empty list gracefully.
|
|
513
|
+
requestProjectAgents();
|
|
496
514
|
hideHomeHub();
|
|
497
515
|
// Clear any stale replay indicator from a prior interrupted switch
|
|
498
516
|
if (replayLoadingEl) replayLoadingEl.classList.add("hidden");
|
|
@@ -1494,5 +1512,21 @@ export function processMessage(msg) {
|
|
|
1494
1512
|
case "notification_dismissed_all":
|
|
1495
1513
|
handleNotificationDismissedAll();
|
|
1496
1514
|
break;
|
|
1515
|
+
|
|
1516
|
+
case "daemon_config_changed":
|
|
1517
|
+
updateDaemonConfig(msg);
|
|
1518
|
+
break;
|
|
1519
|
+
|
|
1520
|
+
case "lite_project_status":
|
|
1521
|
+
handleLiteProjectStatus(msg);
|
|
1522
|
+
break;
|
|
1523
|
+
|
|
1524
|
+
case "lite_enroll_result":
|
|
1525
|
+
handleLiteEnrollResult(msg);
|
|
1526
|
+
break;
|
|
1527
|
+
|
|
1528
|
+
case "lite_unenroll_result":
|
|
1529
|
+
handleLiteUnenrollResult(msg);
|
|
1530
|
+
break;
|
|
1497
1531
|
}
|
|
1498
1532
|
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
// at-agents.js — inline @ mention dropdown for project-local agents (lr-c1a2).
|
|
2
|
+
//
|
|
3
|
+
// When the user types @ in the session input this module shows a small inline
|
|
4
|
+
// autocomplete dropdown listing all agents defined in .claude/agents/ for the
|
|
5
|
+
// active project (from the server via the get_agents / project_agents_list WS
|
|
6
|
+
// round-trip).
|
|
7
|
+
//
|
|
8
|
+
// Selecting an agent starts a new session with that agentName — identical to
|
|
9
|
+
// what the "Agent Chat" button does in the sidebar. The @ text is cleared from
|
|
10
|
+
// the input after selection (the session switch replaces the conversation).
|
|
11
|
+
//
|
|
12
|
+
// The dropdown is hidden when the agent list is empty (no .claude/agents/).
|
|
13
|
+
// When no named agents are installed, the @ keystroke falls through to the
|
|
14
|
+
// mention menu (mention.js), which handles @user / @plain-vendor (including
|
|
15
|
+
// plain:codex) sends within an existing session.
|
|
16
|
+
//
|
|
17
|
+
// Integration with input.js:
|
|
18
|
+
// - input.js calls showAgentMenu(query) first; if the agent menu ends up
|
|
19
|
+
// empty (no matching agents) it falls through to showMentionMenu(query).
|
|
20
|
+
// - The two menus are mutually exclusive: if the agent menu is visible the
|
|
21
|
+
// mention menu is hidden, and vice versa.
|
|
22
|
+
// - input.js calls hideAgentMenu() on Escape, slash menu open, or send.
|
|
23
|
+
// - input.js checks isAgentMenuActive() before routing keydown events here.
|
|
24
|
+
//
|
|
25
|
+
// This module does NOT conflict with mention.js. Mention.js handles
|
|
26
|
+
// @user / @plain-vendor sends within an existing session. This module handles
|
|
27
|
+
// @agent, which *starts a new session* rather than sending a mention. Codex
|
|
28
|
+
// appears only in the mention menu (plain:codex) — it is NOT shown here so
|
|
29
|
+
// that the two entry points remain semantically distinct and Codex does not
|
|
30
|
+
// appear twice.
|
|
31
|
+
|
|
32
|
+
import { escapeHtml } from './utils.js';
|
|
33
|
+
import { getWs } from './ws-ref.js';
|
|
34
|
+
|
|
35
|
+
// --- Module state ---
|
|
36
|
+
var _ctx = null;
|
|
37
|
+
var _menuEl = null;
|
|
38
|
+
var _agents = []; // project-local agents from server: [{name, slug, description}]
|
|
39
|
+
var _items = []; // rendered items (filtered from _agents + codex entry)
|
|
40
|
+
var _activeIdx = -1;
|
|
41
|
+
var _menuVisible = false;
|
|
42
|
+
var _menuBound = false;
|
|
43
|
+
var _currentQuery = "";
|
|
44
|
+
|
|
45
|
+
// --- Public API ---
|
|
46
|
+
|
|
47
|
+
export function initAtAgents(ctx) {
|
|
48
|
+
_ctx = ctx;
|
|
49
|
+
_ensureMenu();
|
|
50
|
+
if (!_menuBound) {
|
|
51
|
+
_menuBound = true;
|
|
52
|
+
document.addEventListener("click", function (e) {
|
|
53
|
+
if (!_menuEl) return;
|
|
54
|
+
var item = e.target.closest(".at-agents-item");
|
|
55
|
+
if (item) {
|
|
56
|
+
var idx = parseInt(item.dataset.idx, 10);
|
|
57
|
+
if (!isNaN(idx) && idx >= 0 && idx < _items.length) {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
e.stopPropagation();
|
|
60
|
+
_activateItem(_items[idx]);
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
// Click outside the menu — hide it.
|
|
65
|
+
if (!_menuEl.contains(e.target)) {
|
|
66
|
+
hideAgentMenu();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Returns true when the @ agent menu is currently visible.
|
|
73
|
+
export function isAgentMenuActive() {
|
|
74
|
+
return _menuVisible;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Request a fresh project agent list from the server. Called once on WS open
|
|
78
|
+
// (or on session switch). The response arrives as project_agents_list and
|
|
79
|
+
// calls handleProjectAgentsList().
|
|
80
|
+
export function requestProjectAgents() {
|
|
81
|
+
var ws = getWs();
|
|
82
|
+
if (!ws || ws.readyState !== 1) return;
|
|
83
|
+
ws.send(JSON.stringify({ type: "get_agents" }));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Called from app-messages.js when project_agents_list arrives.
|
|
87
|
+
export function handleProjectAgentsList(msg) {
|
|
88
|
+
_agents = Array.isArray(msg.agents) ? msg.agents : [];
|
|
89
|
+
// Re-render if the menu is currently open.
|
|
90
|
+
if (_menuVisible) {
|
|
91
|
+
_render(_currentQuery);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Show the dropdown at the position of the input element. Filter by query.
|
|
96
|
+
// Called from input.js when @ is active.
|
|
97
|
+
export function showAgentMenu(query) {
|
|
98
|
+
_currentQuery = query || "";
|
|
99
|
+
_ensureMenu();
|
|
100
|
+
_render(_currentQuery);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Hide and clear the dropdown.
|
|
104
|
+
export function hideAgentMenu() {
|
|
105
|
+
if (!_menuVisible && !_menuEl) return;
|
|
106
|
+
_menuVisible = false;
|
|
107
|
+
_activeIdx = -1;
|
|
108
|
+
_items = [];
|
|
109
|
+
_currentQuery = "";
|
|
110
|
+
if (_menuEl) {
|
|
111
|
+
_menuEl.classList.remove("visible");
|
|
112
|
+
_menuEl.innerHTML = "";
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Keyboard navigation. Returns true if the event was consumed.
|
|
117
|
+
export function agentMenuKeydown(e) {
|
|
118
|
+
if (!_menuVisible || _items.length === 0) return false;
|
|
119
|
+
if (e.key === "ArrowDown") {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
_setActive((_activeIdx + 1) % _items.length);
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
if (e.key === "ArrowUp") {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
_setActive((_activeIdx - 1 + _items.length) % _items.length);
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
if (e.key === "Tab" || (e.key === "Enter" && !e.shiftKey)) {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
if (_activeIdx >= 0 && _activeIdx < _items.length) {
|
|
132
|
+
_activateItem(_items[_activeIdx]);
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
if (e.key === "Escape") {
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
hideAgentMenu();
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// --- Private helpers ---
|
|
145
|
+
|
|
146
|
+
function _ensureMenu() {
|
|
147
|
+
if (_menuEl) return;
|
|
148
|
+
_menuEl = document.createElement("div");
|
|
149
|
+
_menuEl.id = "at-agents-menu";
|
|
150
|
+
_menuEl.className = "at-agents-menu";
|
|
151
|
+
// #input-wrapper has position:relative and is the direct parent of #mention-menu
|
|
152
|
+
// and #slash-menu. Attaching here ensures bottom:100% positions the menu above
|
|
153
|
+
// the input row, matching the other menus. #input-area has no position:relative
|
|
154
|
+
// and would mis-place the absolute element.
|
|
155
|
+
var inputWrapper = document.getElementById("input-wrapper");
|
|
156
|
+
if (inputWrapper) {
|
|
157
|
+
inputWrapper.appendChild(_menuEl);
|
|
158
|
+
} else {
|
|
159
|
+
document.body.appendChild(_menuEl);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function _buildItems(query) {
|
|
164
|
+
var q = (query || "").toLowerCase().trim();
|
|
165
|
+
var result = [];
|
|
166
|
+
|
|
167
|
+
// Project-local named agents from .claude/agents/ only.
|
|
168
|
+
// Codex is intentionally excluded — it appears in the mention menu
|
|
169
|
+
// (plain:codex) where it has the correct in-session semantics. Showing it
|
|
170
|
+
// here as well would present two entry points with different behaviours.
|
|
171
|
+
for (var i = 0; i < _agents.length; i++) {
|
|
172
|
+
var a = _agents[i];
|
|
173
|
+
if (!a || !a.name) continue;
|
|
174
|
+
if (q && a.name.toLowerCase().indexOf(q) === -1 &&
|
|
175
|
+
(a.description || "").toLowerCase().indexOf(q) === -1) continue;
|
|
176
|
+
result.push(a);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function _render(query) {
|
|
183
|
+
_items = _buildItems(query);
|
|
184
|
+
if (_items.length === 0) {
|
|
185
|
+
hideAgentMenu();
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
_menuVisible = true;
|
|
189
|
+
_activeIdx = 0;
|
|
190
|
+
|
|
191
|
+
var html = "";
|
|
192
|
+
for (var i = 0; i < _items.length; i++) {
|
|
193
|
+
var item = _items[i];
|
|
194
|
+
var desc = item.description ? escapeHtml(item.description) : "";
|
|
195
|
+
html +=
|
|
196
|
+
'<div class="at-agents-item' + (i === 0 ? " active" : "") + '" data-idx="' + i + '">' +
|
|
197
|
+
'<span class="at-agents-name">' + escapeHtml(item.name) + '</span>' +
|
|
198
|
+
'<span class="at-agents-badge">agent</span>' +
|
|
199
|
+
(desc ? '<span class="at-agents-desc">' + desc + '</span>' : '') +
|
|
200
|
+
'</div>';
|
|
201
|
+
}
|
|
202
|
+
_menuEl.innerHTML = html;
|
|
203
|
+
_menuEl.classList.add("visible");
|
|
204
|
+
|
|
205
|
+
// Bind mouseenter for hover highlighting.
|
|
206
|
+
var itemEls = _menuEl.querySelectorAll(".at-agents-item");
|
|
207
|
+
for (var j = 0; j < itemEls.length; j++) {
|
|
208
|
+
(function (el) {
|
|
209
|
+
el.addEventListener("mouseenter", function () {
|
|
210
|
+
_setActive(parseInt(el.dataset.idx, 10), true);
|
|
211
|
+
});
|
|
212
|
+
})(itemEls[j]);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function _setActive(idx, skipScroll) {
|
|
217
|
+
if (_items.length === 0) return;
|
|
218
|
+
if (idx < 0) idx = _items.length - 1;
|
|
219
|
+
if (idx >= _items.length) idx = 0;
|
|
220
|
+
_activeIdx = idx;
|
|
221
|
+
var els = _menuEl.querySelectorAll(".at-agents-item");
|
|
222
|
+
for (var i = 0; i < els.length; i++) {
|
|
223
|
+
els[i].classList.toggle("active", i === idx);
|
|
224
|
+
}
|
|
225
|
+
if (!skipScroll && els[idx]) {
|
|
226
|
+
els[idx].scrollIntoView({ block: "nearest" });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function _activateItem(item) {
|
|
231
|
+
hideAgentMenu();
|
|
232
|
+
// Clear the @ text from the input.
|
|
233
|
+
if (_ctx && _ctx.inputEl) {
|
|
234
|
+
var val = _ctx.inputEl.value;
|
|
235
|
+
// Remove everything from the last @ to the cursor.
|
|
236
|
+
var cursor = _ctx.inputEl.selectionStart;
|
|
237
|
+
var atIdx = val.lastIndexOf("@", cursor - 1);
|
|
238
|
+
if (atIdx !== -1) {
|
|
239
|
+
_ctx.inputEl.value = val.substring(0, atIdx) + val.substring(cursor);
|
|
240
|
+
_ctx.inputEl.selectionStart = _ctx.inputEl.selectionEnd = atIdx;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// Start (or switch to) the named agent session.
|
|
244
|
+
var ws = getWs();
|
|
245
|
+
if (ws && ws.readyState === 1) {
|
|
246
|
+
ws.send(JSON.stringify({ type: "new_session", agentName: item.name }));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Shared HTML escaping — importable in both browser (ESM) and Node (for tests).
|
|
2
|
+
//
|
|
3
|
+
// Encodes the five characters that can break out of HTML text and attribute
|
|
4
|
+
// contexts. Coerces non-string input so callers never throw on null/undefined.
|
|
5
|
+
//
|
|
6
|
+
// Character coverage:
|
|
7
|
+
// & -> & (entity ambiguity)
|
|
8
|
+
// < -> < (tag open)
|
|
9
|
+
// > -> > (tag close)
|
|
10
|
+
// " -> " (double-quoted attribute breakout)
|
|
11
|
+
// ' -> ' (single-quoted attribute breakout)
|
|
12
|
+
export function escapeHtml(s) {
|
|
13
|
+
return String(s == null ? "" : s)
|
|
14
|
+
.replace(/&/g, "&")
|
|
15
|
+
.replace(/</g, "<")
|
|
16
|
+
.replace(/>/g, ">")
|
|
17
|
+
.replace(/"/g, """)
|
|
18
|
+
.replace(/'/g, "'");
|
|
19
|
+
}
|
|
@@ -5,6 +5,12 @@ import { closeSidebar } from './sidebar.js';
|
|
|
5
5
|
import { closeTerminal } from './terminal.js';
|
|
6
6
|
import { renderUnifiedDiff, renderSplitDiff } from './diff.js';
|
|
7
7
|
import { initFileIcons, getFileIconSvg, getFolderIconSvg } from './fileicons.js';
|
|
8
|
+
import {
|
|
9
|
+
setPendingNavigate as _setPendingNavigate,
|
|
10
|
+
clearPendingNavigate as _clearPendingNavigate,
|
|
11
|
+
peekPendingNavigate,
|
|
12
|
+
getPendingNavigate,
|
|
13
|
+
} from './pending-navigate.js';
|
|
8
14
|
|
|
9
15
|
var ctx;
|
|
10
16
|
var showDropHint = function () {};
|
|
@@ -15,7 +21,7 @@ var isRendered = false; // markdown render toggle state
|
|
|
15
21
|
var currentIsMarkdown = false;
|
|
16
22
|
var historyVisible = false;
|
|
17
23
|
var currentHistoryEntries = [];
|
|
18
|
-
|
|
24
|
+
// pendingNavigate state delegated to ./pending-navigate.js (DOM-free, testable)
|
|
19
25
|
var selectedEntries = []; // up to 2 selected for compare
|
|
20
26
|
var compareMode = false;
|
|
21
27
|
var inlineDiffActive = false;
|
|
@@ -419,7 +425,7 @@ export function resetFileBrowser() {
|
|
|
419
425
|
currentIsMarkdown = false;
|
|
420
426
|
historyVisible = false;
|
|
421
427
|
currentHistoryEntries = [];
|
|
422
|
-
|
|
428
|
+
_clearPendingNavigate();
|
|
423
429
|
selectedEntries = [];
|
|
424
430
|
compareMode = false;
|
|
425
431
|
inlineDiffActive = false;
|
|
@@ -1929,11 +1935,11 @@ function navigateToEdit(edit) {
|
|
|
1929
1935
|
return;
|
|
1930
1936
|
}
|
|
1931
1937
|
|
|
1932
|
-
|
|
1938
|
+
_setPendingNavigate({
|
|
1933
1939
|
sessionLocalId: edit.sessionLocalId,
|
|
1934
1940
|
assistantUuid: edit.assistantUuid,
|
|
1935
1941
|
toolId: edit.toolId,
|
|
1936
|
-
};
|
|
1942
|
+
});
|
|
1937
1943
|
|
|
1938
1944
|
if (ctx.ws && ctx.connected) {
|
|
1939
1945
|
ctx.ws.send(JSON.stringify({ type: "switch_session", id: edit.sessionLocalId }));
|
|
@@ -1959,8 +1965,5 @@ function scrollToToolElement(toolId, assistantUuid) {
|
|
|
1959
1965
|
});
|
|
1960
1966
|
}
|
|
1961
1967
|
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
pendingNavigate = null;
|
|
1965
|
-
return nav;
|
|
1966
|
-
}
|
|
1968
|
+
// peekPendingNavigate and getPendingNavigate are imported from
|
|
1969
|
+
// ./pending-navigate.js and re-exported from the import statement at the top.
|
|
@@ -2,6 +2,7 @@ import { iconHtml, refreshIcons } from './icons.js';
|
|
|
2
2
|
import { setRewindMode, isRewindMode } from './rewind.js';
|
|
3
3
|
import { renderPicker as renderContextPicker } from './context-sources.js';
|
|
4
4
|
import { checkForMention, showMentionMenu, hideMentionMenu, isMentionMenuVisible, mentionMenuKeydown, setMentionAtIdx, parseMentionFromInput, clearMentionState, stickyReapplyMention, sendUserMention, renderUserMention, removeMentionChip } from './mention.js';
|
|
5
|
+
import { initAtAgents, showAgentMenu, hideAgentMenu, isAgentMenuActive, agentMenuKeydown, requestProjectAgents } from './at-agents.js';
|
|
5
6
|
import { store } from './store.js';
|
|
6
7
|
import { sendWsQuiet } from './ws-ref.js';
|
|
7
8
|
|
|
@@ -101,6 +102,7 @@ export function sendMessage() {
|
|
|
101
102
|
if (!text && images.length === 0 && pendingPastes.length === 0 && pendingFiles.length === 0) return;
|
|
102
103
|
if (uploadingCount > 0) return; // wait for uploads to finish
|
|
103
104
|
hideSlashMenu();
|
|
105
|
+
hideAgentMenu();
|
|
104
106
|
if (ctx.hideSuggestionChips) ctx.hideSuggestionChips();
|
|
105
107
|
|
|
106
108
|
if (text === "/clear") {
|
|
@@ -738,6 +740,9 @@ function createFileInput(accept, capture, multiple) {
|
|
|
738
740
|
export function initInput(_ctx) {
|
|
739
741
|
ctx = _ctx;
|
|
740
742
|
|
|
743
|
+
// Initialise the @ agent menu with the input context.
|
|
744
|
+
initAtAgents(ctx);
|
|
745
|
+
|
|
741
746
|
if (!slashMenuBound && ctx.slashMenu) {
|
|
742
747
|
slashMenuBound = true;
|
|
743
748
|
ctx.slashMenu.addEventListener("click", function (e) {
|
|
@@ -988,22 +993,35 @@ export function initInput(_ctx) {
|
|
|
988
993
|
if (val.startsWith("/") && !val.includes(" ") && val.length > 1) {
|
|
989
994
|
showSlashMenu(val.substring(1));
|
|
990
995
|
hideMentionMenu();
|
|
996
|
+
hideAgentMenu();
|
|
991
997
|
} else if (val === "/") {
|
|
992
998
|
showSlashMenu("");
|
|
993
999
|
hideMentionMenu();
|
|
1000
|
+
hideAgentMenu();
|
|
994
1001
|
} else {
|
|
995
1002
|
hideSlashMenu();
|
|
996
|
-
// Check for @mention — skip selectionStart read (forced layout)
|
|
997
|
-
// there is no @ in the value at all.
|
|
1003
|
+
// Check for @mention / @agent — skip selectionStart read (forced layout)
|
|
1004
|
+
// when there is no @ in the value at all.
|
|
998
1005
|
if (val.indexOf("@") !== -1) {
|
|
999
1006
|
var mentionCheck = checkForMention(val, ctx.inputEl.selectionStart);
|
|
1000
1007
|
if (mentionCheck.active) {
|
|
1001
1008
|
setMentionAtIdx(mentionCheck.startIdx);
|
|
1002
|
-
|
|
1009
|
+
// Agent menu takes priority: show it first. If it ends up empty (no
|
|
1010
|
+
// named agents match the query) fall through to the mention menu so
|
|
1011
|
+
// @user / plain:codex are still reachable. The two menus are mutually
|
|
1012
|
+
// exclusive — whichever is shown hides the other.
|
|
1013
|
+
showAgentMenu(mentionCheck.query);
|
|
1014
|
+
if (isAgentMenuActive()) {
|
|
1015
|
+
hideMentionMenu();
|
|
1016
|
+
} else {
|
|
1017
|
+
showMentionMenu(mentionCheck.query);
|
|
1018
|
+
}
|
|
1003
1019
|
} else {
|
|
1020
|
+
hideAgentMenu();
|
|
1004
1021
|
hideMentionMenu();
|
|
1005
1022
|
}
|
|
1006
1023
|
} else {
|
|
1024
|
+
hideAgentMenu();
|
|
1007
1025
|
hideMentionMenu();
|
|
1008
1026
|
}
|
|
1009
1027
|
}
|
|
@@ -1017,7 +1035,11 @@ export function initInput(_ctx) {
|
|
|
1017
1035
|
ctx.inputEl.addEventListener("compositionend", function () { isComposing = false; });
|
|
1018
1036
|
|
|
1019
1037
|
ctx.inputEl.addEventListener("keydown", function (e) {
|
|
1020
|
-
// @
|
|
1038
|
+
// @ Agent menu keyboard navigation — takes priority over mention menu.
|
|
1039
|
+
if (isAgentMenuActive()) {
|
|
1040
|
+
if (agentMenuKeydown(e)) return;
|
|
1041
|
+
}
|
|
1042
|
+
// @Mention menu keyboard navigation (user-to-user / plain vendor)
|
|
1021
1043
|
if (isMentionMenuVisible()) {
|
|
1022
1044
|
if (mentionMenuKeydown(e)) return;
|
|
1023
1045
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// pendingNavigate state machine — no DOM dependencies.
|
|
2
|
+
// Imported by filebrowser.js (browser) and by test/pending-navigate.test.js
|
|
3
|
+
// (Node ESM import — no DOM shim needed).
|
|
4
|
+
//
|
|
5
|
+
// Extracted for lr-a3ca: history_meta must peek without consuming so that
|
|
6
|
+
// history_done remains the sole consumer.
|
|
7
|
+
|
|
8
|
+
var pendingNavigate = null;
|
|
9
|
+
|
|
10
|
+
export function setPendingNavigate(nav) {
|
|
11
|
+
pendingNavigate = nav;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function clearPendingNavigate() {
|
|
15
|
+
pendingNavigate = null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Non-consuming read — use in history_meta guard.
|
|
19
|
+
export function peekPendingNavigate() {
|
|
20
|
+
return pendingNavigate;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Consuming read — use in history_done only.
|
|
24
|
+
export function getPendingNavigate() {
|
|
25
|
+
var nav = pendingNavigate;
|
|
26
|
+
pendingNavigate = null;
|
|
27
|
+
return nav;
|
|
28
|
+
}
|
|
@@ -558,7 +558,7 @@ function registerBuiltinPlaybooks() {
|
|
|
558
558
|
try {
|
|
559
559
|
var n = new Notification("Clagentic:Console", {
|
|
560
560
|
body: "Notifications are working! 🎉",
|
|
561
|
-
tag: "
|
|
561
|
+
tag: "clagentic-test-" + Date.now(),
|
|
562
562
|
});
|
|
563
563
|
n.onclick = function () { window.focus(); n.close(); };
|
|
564
564
|
setTimeout(function () { try { n.close(); } catch (e) {} }, 5000);
|