@clagentic/console 1.12.0-beta.1 → 1.12.0-beta.3
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/LICENSES/README.md +5 -0
- package/README.md +1 -0
- package/bin/cli.js +5 -2
- package/lib/agent-roster-ws.js +84 -0
- package/lib/agent-roster.js +312 -0
- package/lib/auth-required-notify.js +42 -0
- package/lib/build-changes.js +8 -2
- package/lib/build-sha.json +2 -2
- package/lib/build-update-notify.js +45 -0
- package/lib/build-update-offer.js +34 -11
- package/lib/build-update-standing.js +34 -14
- package/lib/claude-settings-env.js +142 -0
- package/lib/cli/duration.js +27 -0
- package/lib/cli/schedule-input-subcommands.js +1 -22
- package/lib/cli/session-subcommands.js +60 -11
- package/lib/client-address.js +44 -0
- package/lib/daemon.js +31 -10
- package/lib/idle-compaction-setting.js +203 -0
- package/lib/mcp-bridge-credential.js +41 -0
- package/lib/notification-prefs.js +18 -22
- package/lib/notify/core.js +210 -0
- package/lib/notify/index.js +31 -0
- package/lib/notify/live-prompts.js +36 -0
- package/lib/notify/payload.js +62 -0
- package/lib/notify/target.js +5 -0
- package/lib/notify/type-registry.js +81 -0
- package/lib/notify/types.js +57 -0
- package/lib/open-sockets.js +27 -0
- package/lib/outbound-access.js +85 -0
- package/lib/outbound-entry.js +116 -0
- package/lib/outbound-ledger.js +306 -0
- package/lib/outbound-query.js +153 -0
- package/lib/pending-prompts.js +31 -16
- package/lib/project-connection.js +48 -8
- package/lib/project-filesystem.js +43 -5
- package/lib/project-http.js +9 -1
- package/lib/project-loop.js +38 -26
- package/lib/project-notifications.js +122 -39
- package/lib/project-prompt-responses.js +1 -1
- package/lib/project-sessions.js +11 -1
- package/lib/project-user-mention.js +22 -34
- package/lib/project-user-message.js +208 -4
- package/lib/project-user-shell.js +298 -0
- package/lib/project.js +41 -5
- package/lib/prompt-answer.js +145 -0
- package/lib/prompt-expiry.js +50 -0
- package/lib/prompt-registry.js +98 -25
- package/lib/prompt-reminders.js +38 -33
- package/lib/prompt-source.js +59 -8
- package/lib/public/app.js +32 -2
- package/lib/public/css/agent-messages.css +96 -0
- package/lib/public/css/agent-roster.css +93 -0
- package/lib/public/css/diagnostics.css +29 -1
- package/lib/public/css/home-hub.css +12 -0
- package/lib/public/css/icon-strip.css +9 -0
- package/lib/public/css/input.css +20 -141
- package/lib/public/css/login-panel.css +73 -0
- package/lib/public/css/menus.css +2 -2
- package/lib/public/css/mobile-nav.css +11 -0
- package/lib/public/css/sidebar.css +18 -0
- package/lib/public/css/team-panel.css +1 -6
- package/lib/public/css/team-view.css +101 -0
- package/lib/public/css/title-bar.css +10 -0
- package/lib/public/css/user-shell.css +144 -0
- package/lib/public/index.html +44 -7
- package/lib/public/modules/activity-state.js +20 -4
- package/lib/public/modules/agent-avatar-picker.js +162 -0
- package/lib/public/modules/agent-avatar.js +153 -0
- package/lib/public/modules/agent-messages.js +285 -0
- package/lib/public/modules/agent-roster.js +157 -0
- package/lib/public/modules/app-connection.js +34 -5
- package/lib/public/modules/app-messages.js +55 -16
- package/lib/public/modules/app-notifications.js +104 -75
- package/lib/public/modules/app-panels.js +26 -3
- package/lib/public/modules/app-projects.js +3 -1
- package/lib/public/modules/app-rate-limit.js +8 -165
- package/lib/public/modules/app-rendering.js +32 -7
- package/lib/public/modules/build-update-sessions.js +81 -0
- package/lib/public/modules/collapsible-text.js +33 -18
- package/lib/public/modules/compaction-state.js +34 -0
- package/lib/public/modules/custom-icons.js +23 -5
- package/lib/public/modules/diagnostics.js +61 -57
- package/lib/public/modules/env-shadow-notice.js +34 -0
- package/lib/public/modules/injected-identity.js +24 -21
- package/lib/public/modules/input.js +176 -15
- package/lib/public/modules/login-panel.js +136 -0
- package/lib/public/modules/login-parser.js +73 -0
- package/lib/public/modules/login-tab.js +66 -0
- package/lib/public/modules/notifications.js +9 -1
- package/lib/public/modules/notify-client.js +246 -0
- package/lib/public/modules/pending-term-request.js +30 -0
- package/lib/public/modules/project-icon.js +22 -2
- package/lib/public/modules/project-settings.js +5 -0
- package/lib/public/modules/prompt-state.js +3 -3
- package/lib/public/modules/prompts.js +1 -1
- package/lib/public/modules/queued-button.js +11 -0
- package/lib/public/modules/scheduled-input-actions.js +12 -4
- package/lib/public/modules/scheduled-outbox.js +230 -0
- package/lib/public/modules/send-now.js +200 -0
- package/lib/public/modules/server-settings.js +50 -1
- package/lib/public/modules/shell-card.js +76 -0
- package/lib/public/modules/shell-line.js +49 -0
- package/lib/public/modules/shell-queue.js +253 -0
- package/lib/public/modules/shell-settings-controls.js +76 -0
- package/lib/public/modules/sidebar-mobile.js +3 -3
- package/lib/public/modules/sidebar-sessions.js +8 -0
- package/lib/public/modules/sidebar-users.js +5 -7
- package/lib/public/modules/team-panel.js +30 -88
- package/lib/public/modules/team-view.js +211 -0
- package/lib/public/modules/terminal-links.js +193 -0
- package/lib/public/modules/terminal.js +84 -107
- package/lib/public/modules/tools.js +19 -0
- package/lib/public/modules/user-shell.js +824 -0
- package/lib/public/notify-sw-logic.js +252 -0
- package/lib/public/notify-target.js +157 -0
- package/lib/public/style.css +5 -0
- package/lib/public/sw.js +20 -69
- package/lib/push.js +63 -19
- package/lib/queued-chat.js +392 -0
- package/lib/runtime-env.js +1 -0
- package/lib/scheduled-input/ws.js +67 -9
- package/lib/sdk-bridge.js +184 -73
- package/lib/sdk-message-processor.js +124 -76
- package/lib/server-auth.js +6 -4
- package/lib/server-dm.js +11 -20
- package/lib/server-settings.js +39 -1
- package/lib/server.js +112 -16
- package/lib/session-directory.js +39 -12
- package/lib/session-end.js +97 -0
- package/lib/session-input-ipc.js +37 -1
- package/lib/session-input.js +263 -21
- package/lib/session-liveness.js +53 -0
- package/lib/session-reclaim.js +37 -2
- package/lib/session-resume.js +1 -0
- package/lib/session-settings-file.js +53 -0
- package/lib/sessions.js +80 -9
- package/lib/team-traffic-ws.js +68 -0
- package/lib/team-traffic.js +318 -0
- package/lib/usage-store.js +36 -7
- package/lib/user-shell-settings.js +105 -0
- package/lib/vendor-auth.js +33 -2
- package/lib/ws-schema.js +33 -5
- package/lib/yoke/adapters/claude-capabilities.js +2 -0
- package/lib/yoke/adapters/claude-vendor.js +17 -1
- package/lib/yoke/adapters/claude-worker.js +39 -11
- package/lib/yoke/adapters/claude.js +225 -6
- package/lib/yoke/adapters/codex-capabilities.js +6 -1
- package/lib/yoke/adapters/codex-user-shell.js +265 -0
- package/lib/yoke/adapters/codex-vendor.js +7 -0
- package/lib/yoke/adapters/codex.js +186 -52
- package/lib/yoke/auth-checks.js +17 -2
- package/lib/yoke/codex-app-server.js +8 -2
- package/lib/yoke/index.js +21 -3
- package/lib/yoke/interface.js +54 -1
- package/lib/yoke/mcp-bridge-server.js +12 -8
- package/lib/yoke/provider-credentials.js +24 -0
- package/lib/yoke/registry.js +40 -1
- package/lib/yoke/user-shell.js +224 -0
- package/package.json +2 -2
- package/scripts/check-test-count.js +14 -0
- package/lib/public/modules/build-notice-gate.js +0 -73
|
@@ -27,11 +27,15 @@ import { iconHtml, refreshIcons } from './icons.js';
|
|
|
27
27
|
import { formatDiagnosticSource as _formatSource } from './diagnostic-format.js';
|
|
28
28
|
import { sendWs } from './ws-ref.js';
|
|
29
29
|
import { buildUpdateDetailEl } from './build-update-detail.js';
|
|
30
|
-
import {
|
|
31
|
-
BUILD_NOTICE_SOURCE, BUILD_NOTICE_ACTION, noticeKeyOf, cooldownOf, createNoticeGate,
|
|
32
|
-
} from './build-notice-gate.js';
|
|
30
|
+
import { sessionLinesOf, messageWithoutSessions, buildSessionsEl } from './build-update-sessions.js';
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
// The build-update offer's diagnostics entry: where its restart action lives.
|
|
33
|
+
// The offer itself is a core notification (build_update_offer); the page builds
|
|
34
|
+
// this entry from it, and its collapse and close come from the core.
|
|
35
|
+
var BUILD_NOTICE_SOURCE = 'build-update';
|
|
36
|
+
var BUILD_NOTICE_ACTION = 'restart_for_build_update';
|
|
37
|
+
// The notification the held offer entry was built from.
|
|
38
|
+
var _offerNotifId = null;
|
|
35
39
|
|
|
36
40
|
// Allowlist of actionable.action values this client will act on.
|
|
37
41
|
// A diagnostic's `actionable.action` string is never sent to the server
|
|
@@ -280,9 +284,6 @@ export function addDiagnostic(msg, opts) {
|
|
|
280
284
|
ts: now,
|
|
281
285
|
id: _nextDiagnosticId++,
|
|
282
286
|
};
|
|
283
|
-
var gate = _gateBuildNotice(msg, now);
|
|
284
|
-
if (gate.action === "skip") return;
|
|
285
|
-
entry.noticeKey = gate.key;
|
|
286
287
|
diagnostics.push(entry);
|
|
287
288
|
|
|
288
289
|
// Render the new entry in the panel list.
|
|
@@ -292,7 +293,7 @@ export function addDiagnostic(msg, opts) {
|
|
|
292
293
|
_updateBadge();
|
|
293
294
|
|
|
294
295
|
// Toast for warning and error severity only.
|
|
295
|
-
var toastAllowed = !(opts && opts.toast === false)
|
|
296
|
+
var toastAllowed = !(opts && opts.toast === false);
|
|
296
297
|
if (toastAllowed && (entry.severity === "warning" || entry.severity === "error")) {
|
|
297
298
|
_showDiagnosticToast(entry);
|
|
298
299
|
}
|
|
@@ -312,49 +313,48 @@ function _arrivalTime(msg) {
|
|
|
312
313
|
return Date.now();
|
|
313
314
|
}
|
|
314
315
|
|
|
315
|
-
// The standing build-update notice is replayed to every connection and refreshed
|
|
316
|
-
// while the build is stale; build-notice-gate.js decides whether this arrival
|
|
317
|
-
// adds, replaces, re-toasts or is dropped. Anything else passes through.
|
|
318
|
-
function _gateBuildNotice(msg, now) {
|
|
319
|
-
var key = noticeKeyOf(msg);
|
|
320
|
-
if (!key) return { action: "add", toast: true, key: null };
|
|
321
|
-
var held = diagnostics.filter(function (e) {
|
|
322
|
-
return e.source === BUILD_NOTICE_SOURCE && _actionOf(e) === BUILD_NOTICE_ACTION;
|
|
323
|
-
})[0] || null;
|
|
324
|
-
var decision = _noticeGate.decide({
|
|
325
|
-
key: key,
|
|
326
|
-
heldKey: held ? held.noticeKey || null : null,
|
|
327
|
-
toastOnScreen: held ? _toastsFor(BUILD_NOTICE_SOURCE, BUILD_NOTICE_ACTION).length > 0 : false,
|
|
328
|
-
now: now,
|
|
329
|
-
cooldownMs: cooldownOf(msg),
|
|
330
|
-
});
|
|
331
|
-
if (decision.action === "replace" || decision.action === "retract") {
|
|
332
|
-
retractDiagnostics(BUILD_NOTICE_SOURCE, BUILD_NOTICE_ACTION);
|
|
333
|
-
}
|
|
334
|
-
if (decision.action === "retract") return { action: "skip", toast: false, key: key };
|
|
335
|
-
if (decision.action === "retoast") {
|
|
336
|
-
_showDiagnosticToast(held);
|
|
337
|
-
return { action: "skip", toast: false, key: key };
|
|
338
|
-
}
|
|
339
|
-
return { action: decision.action, toast: decision.toast, key: key };
|
|
340
|
-
}
|
|
341
|
-
|
|
342
316
|
/**
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
317
|
+
* Shows the build-update offer a notification carries, as the diagnostics entry
|
|
318
|
+
* with the restart action. The core already collapsed repeats into the one
|
|
319
|
+
* notification, so this only replaces the entry it built from an earlier one;
|
|
320
|
+
* the same notification again (a reconnect's state) changes nothing. No toast:
|
|
321
|
+
* the notification's banner is the alert.
|
|
322
|
+
* @param {object} notif a build_update_offer notification.
|
|
347
323
|
*/
|
|
348
|
-
export function
|
|
349
|
-
var
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
324
|
+
export function applyBuildOffer(notif) {
|
|
325
|
+
var meta = notif && notif.meta;
|
|
326
|
+
if (!meta || !meta.buildUpdate) return;
|
|
327
|
+
var held = diagnostics.some(function (e) { return e.source === BUILD_NOTICE_SOURCE && _actionOf(e) === BUILD_NOTICE_ACTION; });
|
|
328
|
+
if (held && _offerNotifId === notif.id) return;
|
|
329
|
+
retractDiagnostics(BUILD_NOTICE_SOURCE, BUILD_NOTICE_ACTION);
|
|
330
|
+
_offerNotifId = notif.id;
|
|
331
|
+
addDiagnostic({
|
|
332
|
+
severity: 'warning',
|
|
333
|
+
source: BUILD_NOTICE_SOURCE,
|
|
334
|
+
message: meta.message || '',
|
|
335
|
+
buildUpdate: meta.buildUpdate,
|
|
336
|
+
actionable: meta.actionable || null,
|
|
337
|
+
}, { toast: false });
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** The offer was closed (installed, declined anywhere, or no longer stale). */
|
|
341
|
+
export function withdrawBuildOffer() {
|
|
342
|
+
_offerNotifId = null;
|
|
343
|
+
retractDiagnostics(BUILD_NOTICE_SOURCE, BUILD_NOTICE_ACTION);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/** Opens the panel the offer's restart action lives in. */
|
|
347
|
+
export function openDiagnosticsPanel() {
|
|
348
|
+
openPanel();
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// The operator closed the offer here: close its notification, which the core
|
|
352
|
+
// then closes on every other surface and device.
|
|
353
|
+
function _declineBuildOffer() {
|
|
354
|
+
if (!_offerNotifId) return;
|
|
355
|
+
var id = _offerNotifId;
|
|
356
|
+
_offerNotifId = null;
|
|
357
|
+
sendWs({ type: 'notification_dismiss', ids: [id] });
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
function _actionOf(entry) {
|
|
@@ -477,11 +477,15 @@ function _showDiagnosticToast(entry) {
|
|
|
477
477
|
|
|
478
478
|
var msgEl = document.createElement("div");
|
|
479
479
|
msgEl.className = "toast-diagnostic-msg diagnostic-multiline";
|
|
480
|
-
|
|
480
|
+
var sessionLines = sessionLinesOf(entry.buildUpdate);
|
|
481
|
+
msgEl.textContent = messageWithoutSessions(entry.message, sessionLines);
|
|
481
482
|
|
|
482
483
|
el.appendChild(headerEl);
|
|
483
484
|
el.appendChild(msgEl);
|
|
485
|
+
var sessionsEl = buildSessionsEl(sessionLines);
|
|
486
|
+
if (sessionsEl) el.appendChild(sessionsEl);
|
|
484
487
|
var hasAction = _appendToastActions(el, entry, function () {
|
|
488
|
+
if (entry.source === BUILD_NOTICE_SOURCE) _declineBuildOffer();
|
|
485
489
|
clearTimeout(timer);
|
|
486
490
|
_removeDiagnosticToast(el);
|
|
487
491
|
});
|
|
@@ -501,7 +505,6 @@ function _showDiagnosticToast(entry) {
|
|
|
501
505
|
// Manual dismiss.
|
|
502
506
|
dismissBtn.addEventListener("click", function () {
|
|
503
507
|
clearTimeout(timer);
|
|
504
|
-
_noticeGate.toastClosed(entry.noticeKey, Date.now());
|
|
505
508
|
_removeDiagnosticToast(el);
|
|
506
509
|
});
|
|
507
510
|
|
|
@@ -511,8 +514,7 @@ function _showDiagnosticToast(entry) {
|
|
|
511
514
|
var fromButton = e.target && e.target.tagName === "BUTTON";
|
|
512
515
|
if (e.key === "Escape" || ((e.key === "Enter" || e.key === " ") && !fromButton)) {
|
|
513
516
|
clearTimeout(timer);
|
|
514
|
-
|
|
515
|
-
_removeDiagnosticToast(el);
|
|
517
|
+
_removeDiagnosticToast(el);
|
|
516
518
|
}
|
|
517
519
|
});
|
|
518
520
|
}
|
|
@@ -587,10 +589,13 @@ function _appendEntry(entry) {
|
|
|
587
589
|
|
|
588
590
|
var msgEl = document.createElement("div");
|
|
589
591
|
msgEl.className = "diagnostics-message diagnostic-multiline";
|
|
590
|
-
|
|
592
|
+
var panelSessionLines = sessionLinesOf(entry.buildUpdate);
|
|
593
|
+
msgEl.textContent = messageWithoutSessions(entry.message, panelSessionLines);
|
|
591
594
|
|
|
592
595
|
item.appendChild(meta);
|
|
593
596
|
item.appendChild(msgEl);
|
|
597
|
+
var panelSessions = buildSessionsEl(panelSessionLines);
|
|
598
|
+
if (panelSessions) item.appendChild(panelSessions);
|
|
594
599
|
var panelDetail = buildUpdateDetailEl(entry.buildUpdate);
|
|
595
600
|
if (panelDetail) item.appendChild(panelDetail);
|
|
596
601
|
|
|
@@ -663,7 +668,7 @@ function dismissDiagnostic(id) {
|
|
|
663
668
|
if (diagnostics[i].id === id) { idx = i; break; }
|
|
664
669
|
}
|
|
665
670
|
if (idx === -1) return;
|
|
666
|
-
|
|
671
|
+
if (diagnostics[idx].source === BUILD_NOTICE_SOURCE) _declineBuildOffer();
|
|
667
672
|
diagnostics.splice(idx, 1);
|
|
668
673
|
|
|
669
674
|
if (panelListEl) {
|
|
@@ -682,8 +687,7 @@ function dismissDiagnostic(id) {
|
|
|
682
687
|
* no server-side dismiss contract (see module header note).
|
|
683
688
|
*/
|
|
684
689
|
function clearAllDiagnostics() {
|
|
685
|
-
|
|
686
|
-
diagnostics.forEach(function (entry) { _noticeGate.entryDismissed(entry.noticeKey, clearedAt); });
|
|
690
|
+
if (diagnostics.some(function (entry) { return entry.source === BUILD_NOTICE_SOURCE; })) _declineBuildOffer();
|
|
687
691
|
// Toasts for the cleared entries go too, so clear-all leaves nothing on screen.
|
|
688
692
|
Array.prototype.slice.call(_getToastContainer().querySelectorAll("[data-diag-source]")).forEach(_removeDiagnosticToast);
|
|
689
693
|
diagnostics = [];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// env-shadow-notice.js - the warning shown under an environment editor when the
|
|
2
|
+
// Claude user settings file sets a variable the editor also sets. That file
|
|
3
|
+
// wins at the runtime, so the saved value has no effect for those names.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {string} elementId the notice element
|
|
7
|
+
* @param {?string[]} keys names set in both places (empty or absent hides it unless configDirNote is set)
|
|
8
|
+
* @param {boolean} [configDirNote] the edited text sets CLAUDE_CONFIG_DIR,
|
|
9
|
+
* which the console does not consult: say the check covers one file only
|
|
10
|
+
*/
|
|
11
|
+
export function renderShadowNotice(elementId, keys, configDirNote) {
|
|
12
|
+
var el = document.getElementById(elementId);
|
|
13
|
+
if (!el) return;
|
|
14
|
+
var names = Array.isArray(keys) ? keys : [];
|
|
15
|
+
var scopeNote = "This check covers that user's Claude settings only; a CLAUDE_CONFIG_DIR set here is not consulted.";
|
|
16
|
+
// The scope note matters most when nothing overlaps: the admin would
|
|
17
|
+
// otherwise read the empty result as covering the directory they set.
|
|
18
|
+
if (names.length === 0 && configDirNote) {
|
|
19
|
+
el.textContent = scopeNote;
|
|
20
|
+
el.classList.remove("hidden");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (names.length === 0) {
|
|
24
|
+
el.textContent = "";
|
|
25
|
+
el.classList.add("hidden");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
el.textContent = (names.length === 1 ? "The variable " : "The variables ") + names.join(", ") +
|
|
29
|
+
(names.length === 1 ? " is" : " are") +
|
|
30
|
+
" also set in the Claude settings file of the user running Clagentic: Console. That file wins, so the value saved here has no effect for " +
|
|
31
|
+
(names.length === 1 ? "it." : "them.") +
|
|
32
|
+
(configDirNote ? " " + scopeNote : "");
|
|
33
|
+
el.classList.remove("hidden");
|
|
34
|
+
}
|
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
// name and avatar helpers. A sender only gains identity here when it matches a
|
|
3
3
|
// known mate or agent; the match changes the display name and avatar and
|
|
4
4
|
// nothing else, so an injected entry never reads as the operator.
|
|
5
|
+
//
|
|
6
|
+
// The avatar of a sender that names an agent comes from the shared resolver
|
|
7
|
+
// (agent-avatar.js): the operator's choice for that agent when there is one,
|
|
8
|
+
// otherwise the avatar this module always gave it.
|
|
5
9
|
|
|
6
10
|
import { mateAvatarUrl } from "./avatar.js";
|
|
7
11
|
import { injectedSenderName } from "./injected-label.js";
|
|
12
|
+
import { resolveAgentAvatar, robotAvatarUrl, senderAgentKey } from "./agent-avatar.js";
|
|
8
13
|
|
|
9
14
|
// Fixed seeds keep the avatar of anonymous senders stable across renders.
|
|
10
15
|
var UNDECLARED_SEED = "undeclared-sender";
|
|
@@ -29,9 +34,17 @@ function findKnownIdentity(known, fromId, fromName) {
|
|
|
29
34
|
return null;
|
|
30
35
|
}
|
|
31
36
|
|
|
37
|
+
// agentKey is the roster key the sender is recorded under (null when it names no
|
|
38
|
+
// agent); defaultAvatarUrl is what it shows when the operator chose nothing.
|
|
39
|
+
function identityOf(injected, name, defaultAvatarUrl, matched, size) {
|
|
40
|
+
var agentKey = senderAgentKey(injected);
|
|
41
|
+
var avatarUrl = agentKey ? resolveAgentAvatar(agentKey, size, defaultAvatarUrl).url : defaultAvatarUrl;
|
|
42
|
+
return { name: name, avatarUrl: avatarUrl, defaultAvatarUrl: defaultAvatarUrl, agentKey: agentKey, matched: matched };
|
|
43
|
+
}
|
|
44
|
+
|
|
32
45
|
// injected: { senderKind, fromName, ... }; fromId: the recorded `from`;
|
|
33
46
|
// known: mates and agents as { id, name, agentName?, slug?, avatar fields }.
|
|
34
|
-
// Returns { name, avatarUrl, matched }.
|
|
47
|
+
// Returns { name, avatarUrl, defaultAvatarUrl, agentKey, matched }.
|
|
35
48
|
export function resolveInjectedIdentity(injected, fromId, known, size) {
|
|
36
49
|
var extracted = injected.senderKind === "extracted";
|
|
37
50
|
var declared = injected.senderKind === "declared" || extracted;
|
|
@@ -42,37 +55,27 @@ export function resolveInjectedIdentity(injected, fromId, known, size) {
|
|
|
42
55
|
? findKnownIdentity(known, undefined, injected.senderAgent)
|
|
43
56
|
: findKnownIdentity(known, fromId, injected.fromName);
|
|
44
57
|
if (hit) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
avatarUrl: mateAvatarUrl(hit, size),
|
|
48
|
-
matched: true,
|
|
49
|
-
};
|
|
58
|
+
var hitName = extracted ? injectedSenderName(injected) : (hit.name || hit.agentName || injectedSenderName(injected));
|
|
59
|
+
return identityOf(injected, hitName, mateAvatarUrl(hit, size), true, size);
|
|
50
60
|
}
|
|
51
61
|
}
|
|
52
62
|
// An extracted agent keeps its own avatar when the receiving project does not
|
|
53
63
|
// list it: same id the list would give it.
|
|
54
64
|
if (extracted && injected.senderAgentSlug) {
|
|
55
|
-
return {
|
|
56
|
-
name: injectedSenderName(injected),
|
|
57
|
-
avatarUrl: mateAvatarUrl({ id: injected.senderAgentSlug }, size),
|
|
58
|
-
matched: false,
|
|
59
|
-
};
|
|
65
|
+
return identityOf(injected, injectedSenderName(injected), mateAvatarUrl({ id: injected.senderAgentSlug }, size), false, size);
|
|
60
66
|
}
|
|
61
67
|
// The console's own automations keep one avatar each, whichever session or
|
|
62
68
|
// project they run in, and never match a mate or agent by name.
|
|
63
69
|
if (injected.senderKind === "automation") {
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
avatarUrl: mateAvatarUrl({ avatarStyle: "bottts", avatarSeed: AUTOMATION_SEED_PREFIX + (injected.fromName || "console") }, size),
|
|
67
|
-
matched: false,
|
|
68
|
-
};
|
|
70
|
+
return identityOf(injected, injectedSenderName(injected),
|
|
71
|
+
mateAvatarUrl({ avatarStyle: "bottts", avatarSeed: AUTOMATION_SEED_PREFIX + (injected.fromName || "console") }, size), false, size);
|
|
69
72
|
}
|
|
73
|
+
// A sender that names an agent shows that agent's seeded robot, the same one
|
|
74
|
+
// the roster and every other place that draws the agent start from.
|
|
75
|
+
var agentKey = senderAgentKey(injected);
|
|
76
|
+
if (agentKey) return identityOf(injected, injectedSenderName(injected), robotAvatarUrl(agentKey, size), false, size);
|
|
70
77
|
var seed = declared
|
|
71
78
|
? (injected.fromName || fromId || UNDECLARED_SEED)
|
|
72
79
|
: (injected.senderKind === "undeclared" ? UNDECLARED_SEED : UNRECORDED_SEED);
|
|
73
|
-
return {
|
|
74
|
-
name: injectedSenderName(injected),
|
|
75
|
-
avatarUrl: mateAvatarUrl({ avatarStyle: "bottts", avatarSeed: seed }, size),
|
|
76
|
-
matched: false,
|
|
77
|
-
};
|
|
80
|
+
return identityOf(injected, injectedSenderName(injected), mateAvatarUrl({ avatarStyle: "bottts", avatarSeed: seed }, size), false, size);
|
|
78
81
|
}
|
|
@@ -9,6 +9,9 @@ import { getScheduleDelayMs, getArmedSchedule, setArmedSchedule, canArmScheduled
|
|
|
9
9
|
import { createSchedulePanel } from './schedule-panel.js';
|
|
10
10
|
import { scheduleMessageFor, specLabel, specTitle } from './schedule-time.js';
|
|
11
11
|
import { sendScheduledNow, cancelScheduledInput } from './scheduled-input-actions.js';
|
|
12
|
+
import { currentSendNowState, isSendNowKey, isMacPlatform, initSendLongPress } from './send-now.js';
|
|
13
|
+
import { parseShellLine } from './shell-line.js';
|
|
14
|
+
import { isShellModeOn, isShellPending, hasQueuedChat, sendShellCommand, queueShellCommand, isTurnRunning, queueChatMessage, flushQueuedChat, restoreSetAsideDraft, registerComposer, registerChatSender, runQueuedShellNext, takeBackLastQueued, registerFrameSender, registerSocketProbe, registerDeliveredRenderer, chatQueuesWithAgent, trackSentChat, newMessageId } from './user-shell.js';
|
|
12
15
|
|
|
13
16
|
var ctx;
|
|
14
17
|
|
|
@@ -137,7 +140,31 @@ export var builtinCommands = [
|
|
|
137
140
|
];
|
|
138
141
|
|
|
139
142
|
// --- Send ---
|
|
140
|
-
|
|
143
|
+
// Whether the composer holds a ! command line that would be sent as a command.
|
|
144
|
+
function draftIsShellLine() {
|
|
145
|
+
var attached = pendingFiles.length > 0 || pendingPastes.length > 0 || pendingImages.length > 0;
|
|
146
|
+
return !attached && isShellModeOn() && parseShellLine(ctx.inputEl.value) !== null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Send-now (Ctrl/Cmd+Enter, or a long press of the send button on touch): the
|
|
150
|
+
// queued ! commands are set to run next (they still wait for a running turn),
|
|
151
|
+
// and the draft goes right away: into the running turn when the agent can take
|
|
152
|
+
// it, a normal send when no turn runs, and a stated refusal (the draft stays in
|
|
153
|
+
// the composer) when a turn runs on an agent that cannot take one. A ! draft
|
|
154
|
+
// is a command, which never goes into a turn: it queues like Enter.
|
|
155
|
+
export function sendNow() {
|
|
156
|
+
runQueuedShellNext();
|
|
157
|
+
if (!hasSendableContent()) return;
|
|
158
|
+
if (draftIsShellLine()) { sendMessage(); return; }
|
|
159
|
+
var st = currentSendNowState("chat");
|
|
160
|
+
if (st.mode === "disabled") {
|
|
161
|
+
ctx.addSystemMessage("Send now is unavailable: " + st.reason + " Use send to queue it for the next turn.", true);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
sendMessage({ sendNow: st.mode === "steer" });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function sendMessage(opts) {
|
|
141
168
|
// DM mode intercept: if in DM mode, route to DM handler instead
|
|
142
169
|
if (ctx.isDmMode && ctx.isDmMode() && ctx.handleDmSend) {
|
|
143
170
|
ctx.handleDmSend();
|
|
@@ -282,10 +309,93 @@ export function sendMessage() {
|
|
|
282
309
|
return;
|
|
283
310
|
}
|
|
284
311
|
|
|
285
|
-
|
|
286
|
-
|
|
312
|
+
// A line that starts with ! is a shell command, not a chat message: it goes as
|
|
313
|
+
// its own request, which the server checks and answers with a result card. The
|
|
314
|
+
// command is read from the composer as typed (parseShellLine drops only the !
|
|
315
|
+
// and the whitespace after it). Anything attached keeps it a chat message, and
|
|
316
|
+
// so does the mode being off: the line is then sent as ordinary text.
|
|
317
|
+
var hasAttachments = files.length > 0 || pendingPastes.length > 0 || images.length > 0;
|
|
318
|
+
var shellCommand = hasAttachments ? null : parseShellLine(ctx.inputEl.value);
|
|
319
|
+
if (shellCommand !== null && isShellModeOn()) {
|
|
320
|
+
// Held like native Claude Code does: a command typed during a turn, during
|
|
321
|
+
// another command, or behind earlier unsent entries waits in the queue and
|
|
322
|
+
// runs in order once the session is free.
|
|
323
|
+
if (isTurnRunning() || isShellPending() || hasQueuedChat()) {
|
|
324
|
+
queueShellCommand(shellCommand);
|
|
325
|
+
flushQueuedChat();
|
|
326
|
+
finishSend();
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (!sendShellCommand(shellCommand, transmitFrame)) {
|
|
330
|
+
ctx.addSystemMessage("Not connected — command not sent.", true);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
finishSend();
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
var steerNow = !!(opts && opts.sendNow);
|
|
338
|
+
// Chat waits on the page, shown as queued, while a command of this session
|
|
339
|
+
// runs, and behind any earlier message that is still unsent, so the order typed
|
|
340
|
+
// is the order sent. Otherwise it is sent now; if that cannot be done it stays
|
|
341
|
+
// in the composer.
|
|
342
|
+
// A message sent now into the running turn does not wait behind queued ! lines:
|
|
343
|
+
// they wait for the turn to end, and it goes into the turn at once.
|
|
344
|
+
if (steerNow && isTurnRunning() && !isShellPending()) {
|
|
345
|
+
if (!dispatchChat(text, images, pastes, steerNow)) {
|
|
346
|
+
ctx.addSystemMessage("Not connected — message not sent.", true);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
} else if (isShellPending() || hasQueuedChat()) {
|
|
350
|
+
queueChatMessage({ text: text, images: images, pastes: pastes, steerNow: steerNow });
|
|
351
|
+
flushQueuedChat();
|
|
352
|
+
} else if (!dispatchChat(text, images, pastes, steerNow)) {
|
|
353
|
+
ctx.addSystemMessage("Not connected — message not sent.", true);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
finishSend();
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Clears the composer after a send and brings back a draft an Edit set aside.
|
|
361
|
+
function finishSend() {
|
|
362
|
+
ctx.inputEl.value = "";
|
|
363
|
+
sendInputSync();
|
|
364
|
+
clearPendingImages();
|
|
365
|
+
autoResize();
|
|
366
|
+
ctx.inputEl.focus();
|
|
367
|
+
restoreSetAsideDraft();
|
|
368
|
+
// Input cleared — switch back to stop mode if still processing
|
|
369
|
+
if ((ctx.processing || isShellPending()) && ctx.setSendBtnMode) {
|
|
370
|
+
ctx.setSendBtnMode("stop");
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Sends one frame; true only when the socket was open and took it. A frame that
|
|
375
|
+
// was not sent is never treated as sent by the caller.
|
|
376
|
+
function transmitFrame(payload) {
|
|
377
|
+
var ws = ctx.ws;
|
|
378
|
+
if (!ws || ws.readyState !== 1) return false;
|
|
379
|
+
try {
|
|
380
|
+
ws.send(JSON.stringify(payload));
|
|
381
|
+
return true;
|
|
382
|
+
} catch (err) {
|
|
383
|
+
console.warn("[input] could not send:", (err && err.message) || err);
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
287
387
|
|
|
388
|
+
// Sends a chat message and, only once it was sent, records it in the
|
|
389
|
+
// conversation, so a send that fails shows nothing twice when it is tried again.
|
|
390
|
+
function dispatchChat(text, images, pastes, steerNow) {
|
|
288
391
|
var payload = { type: "message", text: text || "" };
|
|
392
|
+
if (steerNow) payload.sendNow = true;
|
|
393
|
+
// Sent into a running turn, a message waits at the agent until it takes it in;
|
|
394
|
+
// it is drawn as queued (with an id the server echoes back) until then. A
|
|
395
|
+
// message sent now into the turn, or to an agent that cannot withdraw one, is
|
|
396
|
+
// shown as sent, as it always was.
|
|
397
|
+
var messageId = !steerNow && chatQueuesWithAgent() ? newMessageId() : null;
|
|
398
|
+
if (messageId) payload.messageId = messageId;
|
|
289
399
|
if (images.length > 0) {
|
|
290
400
|
payload.images = images;
|
|
291
401
|
}
|
|
@@ -295,12 +405,28 @@ export function sendMessage() {
|
|
|
295
405
|
// Include selected vendor for session binding (server uses on first message)
|
|
296
406
|
var _selVendor = store.get("currentVendor") || null;
|
|
297
407
|
if (_selVendor) payload.vendor = _selVendor;
|
|
298
|
-
|
|
408
|
+
if (!transmitFrame(payload)) return false;
|
|
409
|
+
|
|
410
|
+
ctx.currentMsgTs = Date.now();
|
|
411
|
+
if (messageId) {
|
|
412
|
+
trackSentChat({ messageId: messageId, text: text, images: images, pastes: pastes });
|
|
413
|
+
} else {
|
|
414
|
+
showSentMessage(text, images, pastes);
|
|
415
|
+
}
|
|
299
416
|
|
|
300
417
|
// Hide vendor toggle after first message (vendor is locked to this session)
|
|
301
418
|
var _vtw2 = document.getElementById("vendor-toggle-wrap");
|
|
302
419
|
if (_vtw2) { _vtw2.classList.remove("hidden"); _vtw2.classList.add("locked"); }
|
|
303
420
|
store.set({ vendorSelectionLocked: false });
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// Records a chat message in the conversation: when it was sent, or, for one that
|
|
425
|
+
// waited as queued, when the agent took it in.
|
|
426
|
+
function showSentMessage(text, images, pastes) {
|
|
427
|
+
// Not marked here: whether the message reached the running turn is only known
|
|
428
|
+
// to the server, which records the mark with the message.
|
|
429
|
+
ctx.addUserMessage(text, images.length > 0 ? images : null, pastes.length > 0 ? pastes : null);
|
|
304
430
|
|
|
305
431
|
// Show pre-thinking dots before server responds.
|
|
306
432
|
// Channel layout: rich pre-thinking bubble via showClaudePreThinking().
|
|
@@ -311,16 +437,6 @@ export function sendMessage() {
|
|
|
311
437
|
if (!document.body.classList.contains("wide-view") && ctx.setActivity) {
|
|
312
438
|
ctx.setActivity("thinking");
|
|
313
439
|
}
|
|
314
|
-
|
|
315
|
-
ctx.inputEl.value = "";
|
|
316
|
-
sendInputSync();
|
|
317
|
-
clearPendingImages();
|
|
318
|
-
autoResize();
|
|
319
|
-
ctx.inputEl.focus();
|
|
320
|
-
// Input cleared — switch back to stop mode if still processing
|
|
321
|
-
if (ctx.processing && ctx.setSendBtnMode) {
|
|
322
|
-
ctx.setSendBtnMode("stop");
|
|
323
|
-
}
|
|
324
440
|
}
|
|
325
441
|
|
|
326
442
|
var INPUT_MAX_HEIGHT = 120;
|
|
@@ -821,6 +937,15 @@ function createFileInput(accept, capture, multiple) {
|
|
|
821
937
|
input.click();
|
|
822
938
|
}
|
|
823
939
|
|
|
940
|
+
// Replaces the composer's text (a queued command taken back for editing).
|
|
941
|
+
function writeComposer(text) {
|
|
942
|
+
ctx.inputEl.value = text;
|
|
943
|
+
resetAutoResize();
|
|
944
|
+
autoResize();
|
|
945
|
+
ctx.inputEl.focus();
|
|
946
|
+
if (ctx.processing && ctx.setSendBtnMode) ctx.setSendBtnMode(hasSendableContent() ? "send" : "stop");
|
|
947
|
+
}
|
|
948
|
+
|
|
824
949
|
// --- Init ---
|
|
825
950
|
export function initInput(_ctx) {
|
|
826
951
|
ctx = _ctx;
|
|
@@ -828,6 +953,19 @@ export function initInput(_ctx) {
|
|
|
828
953
|
// Initialise the @ agent menu with the input context.
|
|
829
954
|
initAtAgents(ctx);
|
|
830
955
|
|
|
956
|
+
// The ! command line draws into the composer and sends queued chat through it.
|
|
957
|
+
registerComposer({
|
|
958
|
+
read: function () { return ctx.inputEl.value; },
|
|
959
|
+
write: writeComposer,
|
|
960
|
+
});
|
|
961
|
+
registerFrameSender(transmitFrame);
|
|
962
|
+
registerSocketProbe(function () { return ctx.ws; });
|
|
963
|
+
registerDeliveredRenderer(function (m) { showSentMessage(m.text, m.images, m.pastes); });
|
|
964
|
+
registerChatSender(function (entry) {
|
|
965
|
+
if (entry.kind === "shell") return sendShellCommand(entry.command, transmitFrame);
|
|
966
|
+
return dispatchChat(entry.text, entry.images, entry.pastes, entry.steerNow);
|
|
967
|
+
});
|
|
968
|
+
|
|
831
969
|
if (!slashMenuBound && ctx.slashMenu) {
|
|
832
970
|
slashMenuBound = true;
|
|
833
971
|
ctx.slashMenu.addEventListener("click", function (e) {
|
|
@@ -1113,6 +1251,25 @@ export function initInput(_ctx) {
|
|
|
1113
1251
|
return;
|
|
1114
1252
|
}
|
|
1115
1253
|
|
|
1254
|
+
if (isSendNowKey(e, isMacPlatform()) && !isComposing) {
|
|
1255
|
+
e.preventDefault();
|
|
1256
|
+
sendNow();
|
|
1257
|
+
return;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
// Up on an empty composer takes back ONE queued entry for editing, as native
|
|
1261
|
+
// does: the last queued ! command when nothing but ! commands is held on the
|
|
1262
|
+
// page, otherwise the last chat message still waiting to be delivered (it is
|
|
1263
|
+
// withdrawn at the agent first, then put in the composer). Anything else
|
|
1264
|
+
// leaves Up alone.
|
|
1265
|
+
if (e.key === "ArrowUp" && !e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey && !isComposing &&
|
|
1266
|
+
ctx.inputEl.value === "" && !hasSendableContent()) {
|
|
1267
|
+
if (takeBackLastQueued(writeComposer)) {
|
|
1268
|
+
e.preventDefault();
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1116
1273
|
if (e.key === "Enter" && !e.shiftKey && !isComposing) {
|
|
1117
1274
|
// Mobile: Enter inserts newline, send via button only — except when
|
|
1118
1275
|
// input is empty and a ghost suggestion is showing, in which case
|
|
@@ -1160,6 +1317,10 @@ export function initInput(_ctx) {
|
|
|
1160
1317
|
ctx.inputEl.setAttribute("enterkeyhint", "enter");
|
|
1161
1318
|
}
|
|
1162
1319
|
|
|
1320
|
+
// Touch has no Ctrl key: a long press of the send button, with a message ready
|
|
1321
|
+
// during a turn, is send-now. Registered first so it can swallow its own click.
|
|
1322
|
+
initSendLongPress(ctx.sendBtn, function () { return !!ctx.processing && hasSendableContent(); }, sendNow);
|
|
1323
|
+
|
|
1163
1324
|
// Send/Stop button — gate on live state, not the button's CSS class.
|
|
1164
1325
|
// If Claude is processing and the user has nothing queued, the click
|
|
1165
1326
|
// is a Stop, never a send (no ghost-suggestion adoption from a Stop
|
|
@@ -1167,7 +1328,7 @@ export function initInput(_ctx) {
|
|
|
1167
1328
|
// and can drift on mobile after backgrounding/reconnect; predicating
|
|
1168
1329
|
// user-facing behavior on it wedges the input on mobile. (lr-e6b5 follow-up)
|
|
1169
1330
|
ctx.sendBtn.addEventListener("click", function () {
|
|
1170
|
-
if (ctx.processing && !hasSendableContent()) {
|
|
1331
|
+
if ((ctx.processing || isShellPending()) && !hasSendableContent()) {
|
|
1171
1332
|
if (ctx.connected) {
|
|
1172
1333
|
ctx.ws.send(JSON.stringify({ type: "stop" }));
|
|
1173
1334
|
}
|