@clagentic/console 1.12.0-beta.2 → 1.12.0
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/bin/cli.js +4 -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-sha.json +2 -2
- package/lib/build-update-notify.js +45 -0
- package/lib/build-update-offer.js +3 -4
- package/lib/build-update-standing.js +34 -14
- package/lib/cli/session-subcommands.js +26 -8
- package/lib/client-address.js +44 -0
- package/lib/daemon.js +25 -10
- package/lib/idle-compaction-setting.js +203 -0
- package/lib/mcp-bridge-credential.js +41 -0
- package/lib/notification-prefs.js +16 -22
- package/lib/notify/core.js +53 -18
- package/lib/notify/payload.js +2 -3
- package/lib/notify/type-registry.js +17 -0
- package/lib/notify/types.js +38 -1
- package/lib/outbound-access.js +12 -1
- package/lib/outbound-entry.js +8 -1
- package/lib/project-connection.js +9 -8
- package/lib/project-filesystem.js +23 -0
- package/lib/project-loop.js +16 -19
- package/lib/project-notifications.js +68 -7
- package/lib/project-sessions.js +9 -0
- 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 +26 -4
- package/lib/prompt-answer.js +145 -0
- package/lib/prompt-expiry.js +50 -0
- package/lib/prompt-registry.js +24 -1
- package/lib/prompt-source.js +16 -0
- package/lib/public/app.js +31 -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 +1 -1
- 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/sidebar.css +11 -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 +41 -7
- 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 +12 -0
- package/lib/public/modules/app-messages.js +55 -16
- package/lib/public/modules/app-notifications.js +59 -29
- package/lib/public/modules/app-panels.js +26 -3
- package/lib/public/modules/app-rate-limit.js +8 -165
- package/lib/public/modules/app-rendering.js +22 -7
- 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 +52 -55
- 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 +114 -21
- package/lib/public/modules/pending-term-request.js +30 -0
- package/lib/public/modules/project-icon.js +22 -2
- 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 +47 -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 +18 -0
- package/lib/public/modules/terminal.js +65 -4
- package/lib/public/modules/tools.js +19 -0
- package/lib/public/modules/user-shell.js +824 -0
- package/lib/public/notify-sw-logic.js +35 -83
- package/lib/public/notify-target.js +70 -10
- package/lib/public/style.css +5 -0
- package/lib/public/sw.js +7 -3
- package/lib/queued-chat.js +392 -0
- package/lib/scheduled-input/ws.js +67 -9
- package/lib/sdk-bridge.js +122 -43
- package/lib/sdk-message-processor.js +46 -39
- 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 +83 -19
- package/lib/session-directory.js +33 -8
- package/lib/session-end.js +97 -0
- package/lib/session-input-ipc.js +26 -0
- package/lib/session-input.js +176 -9
- package/lib/session-resume.js +1 -0
- package/lib/session-settings-file.js +53 -0
- package/lib/sessions.js +49 -5
- package/lib/team-traffic-ws.js +68 -0
- package/lib/team-traffic.js +318 -0
- package/lib/usage-store.js +7 -0
- package/lib/user-shell-settings.js +105 -0
- package/lib/ws-schema.js +27 -4
- package/lib/yoke/adapters/claude-capabilities.js +2 -0
- package/lib/yoke/adapters/claude-vendor.js +6 -0
- package/lib/yoke/adapters/claude-worker.js +39 -11
- package/lib/yoke/adapters/claude.js +218 -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/codex-app-server.js +8 -2
- package/lib/yoke/interface.js +54 -1
- package/lib/yoke/mcp-bridge-server.js +12 -8
- package/lib/yoke/registry.js +32 -0
- package/lib/yoke/user-shell.js +224 -0
- package/package.json +1 -1
- package/lib/public/modules/build-notice-gate.js +0 -73
|
@@ -10,6 +10,7 @@ import { renderVendorPicker } from './vendor-picker.js';
|
|
|
10
10
|
import { splitModelsByTier } from './settings-defaults.js';
|
|
11
11
|
import { isSonnetModel } from './model-families.js';
|
|
12
12
|
import { modeOptions } from './mode-options.js';
|
|
13
|
+
import { isNearingCompaction } from './compaction-state.js';
|
|
13
14
|
|
|
14
15
|
// --- Module-owned state (not in store) ---
|
|
15
16
|
// sessionUsage.context = last-turn context fill (lastStreamInputTokens) — not cumulative,
|
|
@@ -489,7 +490,8 @@ export function initPanels() {
|
|
|
489
490
|
}
|
|
490
491
|
|
|
491
492
|
// --- Reactive UI sync ---
|
|
492
|
-
store.subscribe(['availableVendors', 'installedVendors', 'vendorRegistry', 'currentVendor', 'richContextUsage', 'ctxPopoverVisible', 'currentModel', 'currentModels', 'currentMode', 'currentEffort', 'currentBetas', 'currentThinking', 'vendorCapabilities'], function (state, prev) {
|
|
493
|
+
store.subscribe(['availableVendors', 'installedVendors', 'vendorRegistry', 'currentVendor', 'richContextUsage', 'ctxPopoverVisible', 'currentModel', 'currentModels', 'currentMode', 'currentEffort', 'currentBetas', 'currentThinking', 'vendorCapabilities', 'sessionCompacting'], function (state, prev) {
|
|
494
|
+
if (state.sessionCompacting !== prev.sessionCompacting) renderCompactingChip(state.sessionCompacting);
|
|
493
495
|
// Agent picker state
|
|
494
496
|
if (state.availableVendors !== prev.availableVendors ||
|
|
495
497
|
state.installedVendors !== prev.installedVendors ||
|
|
@@ -913,6 +915,24 @@ export function getEffectiveContextFill() {
|
|
|
913
915
|
return { used: contextData.input, win: resolveContextWindow(contextData.contextWindow) };
|
|
914
916
|
}
|
|
915
917
|
|
|
918
|
+
// The session view's compacting state: a chip in the header status area for
|
|
919
|
+
// exactly the span the server reports (compacting active true to false).
|
|
920
|
+
function renderCompactingChip(active) {
|
|
921
|
+
var statusArea = document.querySelector(".title-bar-content .status");
|
|
922
|
+
if (!statusArea) return;
|
|
923
|
+
var chip = statusArea.querySelector(".header-compacting");
|
|
924
|
+
if (!active) {
|
|
925
|
+
if (chip) chip.remove();
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
if (chip) return;
|
|
929
|
+
chip = document.createElement("span");
|
|
930
|
+
chip.className = "header-compacting";
|
|
931
|
+
chip.setAttribute("role", "status");
|
|
932
|
+
chip.textContent = "Compacting context...";
|
|
933
|
+
statusArea.insertBefore(chip, statusArea.firstChild);
|
|
934
|
+
}
|
|
935
|
+
|
|
916
936
|
export function updateContextPanel() {
|
|
917
937
|
if (!contextUsedEl) return;
|
|
918
938
|
var fill = getEffectiveContextFill();
|
|
@@ -941,7 +961,7 @@ export function updateContextPanel() {
|
|
|
941
961
|
if (statusArea && !hCtxEl) {
|
|
942
962
|
hCtxEl = document.createElement("div");
|
|
943
963
|
hCtxEl.className = "header-context";
|
|
944
|
-
hCtxEl.innerHTML = '<div class="header-context-bar"><div class="header-context-fill"></div></div><span class="header-context-label"></span>';
|
|
964
|
+
hCtxEl.innerHTML = '<div class="header-context-bar"><div class="header-context-fill"></div></div><span class="header-context-label"></span><span class="header-context-nearing hidden">Nearing auto-compaction</span>';
|
|
945
965
|
statusArea.insertBefore(hCtxEl, statusArea.firstChild);
|
|
946
966
|
hCtxEl.addEventListener("mouseenter", function() {
|
|
947
967
|
if (store.get('richContextUsage')) {
|
|
@@ -959,6 +979,9 @@ export function updateContextPanel() {
|
|
|
959
979
|
hFill.style.width = pct.toFixed(1) + "%";
|
|
960
980
|
hFill.className = "header-context-fill" + cls;
|
|
961
981
|
hLabel.textContent = pct.toFixed(0) + "%";
|
|
982
|
+
var nearing = isNearingCompaction(store.get('richContextUsage'));
|
|
983
|
+
hCtxEl.classList.toggle("nearing", nearing);
|
|
984
|
+
hCtxEl.querySelector(".header-context-nearing").classList.toggle("hidden", !nearing);
|
|
962
985
|
// Use data-tip as fallback when rich data is not yet loaded
|
|
963
986
|
if (store.get('richContextUsage')) {
|
|
964
987
|
hCtxEl.removeAttribute("data-tip");
|
|
@@ -1226,7 +1249,7 @@ export function renderCtxPopover() {
|
|
|
1226
1249
|
|
|
1227
1250
|
// Auto-compact note
|
|
1228
1251
|
if (d.isAutoCompactEnabled && d.autoCompactThreshold) {
|
|
1229
|
-
html += '<div class="ctx-pop-note">' + em("\u267b\ufe0f") + ' Auto-compact at ' + formatTokens(d.autoCompactThreshold) + '</div>';
|
|
1252
|
+
html += '<div class="ctx-pop-note">' + em("\u267b\ufe0f") + ' Auto-compact at ' + formatTokens(d.autoCompactThreshold) + (isNearingCompaction(d) ? ' (nearing)' : '') + '</div>';
|
|
1230
1253
|
}
|
|
1231
1254
|
|
|
1232
1255
|
ctxPopoverEl.innerHTML = html;
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import { iconHtml, refreshIcons } from './icons.js';
|
|
5
5
|
import { store } from './store.js';
|
|
6
|
-
import { addToMessages, scrollToBottom } from './app-rendering.js';
|
|
7
|
-
import { userAvatarUrl } from './avatar.js';
|
|
8
6
|
import { clearScheduleDelay, setScheduleDelayForSession, clearScheduleDelayForSession, restoreScheduleDelayUi, refreshScheduleControls } from './input.js';
|
|
9
7
|
import { isSonnetModel, isOpusModel } from './model-families.js';
|
|
10
8
|
import {
|
|
@@ -14,9 +12,8 @@ import {
|
|
|
14
12
|
setScheduledInputs, getScheduledInputs,
|
|
15
13
|
clearSession as clearSessionRateLimitState,
|
|
16
14
|
} from './rate-limit-state.js';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { sendScheduledNow, cancelScheduledInput, requestScheduledInputList } from './scheduled-input-actions.js';
|
|
15
|
+
import { requestScheduledInputList } from './scheduled-input-actions.js';
|
|
16
|
+
import { renderScheduledOutbox, removeScheduledOutbox, resetScheduledOutboxRequests, getScheduledOutboxEl } from './scheduled-outbox.js';
|
|
20
17
|
|
|
21
18
|
// --- Module-owned state ---
|
|
22
19
|
// lr-0827ba: rateLimitResetsAt / rateLimitResetTimer / rateLimitResetState /
|
|
@@ -31,11 +28,6 @@ var rateLimitIndicatorEl = null;
|
|
|
31
28
|
var rateLimitUsageEl = null;
|
|
32
29
|
var rateLimitTickTimer = null;
|
|
33
30
|
var _rateLimitUsageLastHtml = null; // guard against redundant innerHTML + refreshIcons()
|
|
34
|
-
// The scheduled-message bubbles of the session on screen share one container;
|
|
35
|
-
// each has a countdown the one interval below keeps current.
|
|
36
|
-
var scheduledMsgEl = null;
|
|
37
|
-
var scheduledCountdownTimer = null;
|
|
38
|
-
var scheduledCountdowns = [];
|
|
39
31
|
var fastModeIndicatorEl = null;
|
|
40
32
|
|
|
41
33
|
function currentSessionId() {
|
|
@@ -382,166 +374,16 @@ export function applyScheduledInputList(msg) {
|
|
|
382
374
|
if (targetSessionId === currentSessionId()) renderScheduledBubbles(targetSessionId);
|
|
383
375
|
}
|
|
384
376
|
|
|
385
|
-
// Draws
|
|
386
|
-
// so the message list keeps them together at its end.
|
|
377
|
+
// Draws the session on screen's armed inputs as outbox items (scheduled-outbox.js).
|
|
387
378
|
function renderScheduledBubbles(sessionId) {
|
|
388
|
-
|
|
389
|
-
var inputs = getScheduledInputs(sessionId);
|
|
390
|
-
if (inputs.length === 0) return;
|
|
391
|
-
var container = document.createElement("div");
|
|
392
|
-
container.className = "scheduled-msgs";
|
|
393
|
-
inputs.forEach(function (input) {
|
|
394
|
-
var built = buildScheduledBubble(input);
|
|
395
|
-
container.appendChild(built.wrap);
|
|
396
|
-
scheduledCountdowns.push({ el: built.countdownEl, input: input });
|
|
397
|
-
});
|
|
398
|
-
addToMessages(container);
|
|
399
|
-
scheduledMsgEl = container;
|
|
400
|
-
scrollToBottom();
|
|
401
|
-
updateScheduledCountdowns();
|
|
402
|
-
scheduledCountdownTimer = setInterval(updateScheduledCountdowns, 1000);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function updateScheduledCountdowns() {
|
|
406
|
-
var now = Date.now();
|
|
407
|
-
scheduledCountdowns.forEach(function (c) { c.el.textContent = countdownText(c.input, now); });
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
function buildScheduledBubble(input) {
|
|
411
|
-
var text = input.text;
|
|
412
|
-
var isChannel = document.body.classList.contains("wide-view");
|
|
413
|
-
var wrap = document.createElement("div");
|
|
414
|
-
wrap.className = "msg-user scheduled-msg-wrap";
|
|
415
|
-
wrap.setAttribute("data-id", input.id);
|
|
416
|
-
|
|
417
|
-
var countdownEl;
|
|
418
|
-
var cancelBtn;
|
|
419
|
-
|
|
420
|
-
// Collapsed by default to one line; the card's own state, not persisted.
|
|
421
|
-
var collapsible = buildCollapsibleText(text, {
|
|
422
|
-
onChange: function (collapsed) { wrap.classList.toggle("is-collapsed", collapsed); },
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
if (isChannel) {
|
|
426
|
-
// Channel mode: avatar + header with scheduled badge + message
|
|
427
|
-
var _me = store.get('cachedAllUsers').find(function (u) { return u.id === store.get('myUserId'); });
|
|
428
|
-
if (!_me) { try { _me = JSON.parse(localStorage.getItem("clagentic_my_user") || localStorage.getItem("clay_my_user") || "null"); } catch(e) {} }
|
|
429
|
-
var _myName = document.body.dataset.myDisplayName || (_me && (_me.displayName || _me.username)) || "Me";
|
|
430
|
-
|
|
431
|
-
var avi = document.createElement("img");
|
|
432
|
-
avi.className = "dm-bubble-avatar dm-bubble-avatar-me";
|
|
433
|
-
avi.src = document.body.dataset.myAvatarUrl || userAvatarUrl(_me || { id: store.get('myUserId') }, 36);
|
|
434
|
-
wrap.appendChild(avi);
|
|
435
|
-
|
|
436
|
-
var content = document.createElement("div");
|
|
437
|
-
content.className = "dm-bubble-content";
|
|
438
|
-
|
|
439
|
-
var header = document.createElement("div");
|
|
440
|
-
header.className = "dm-bubble-header";
|
|
441
|
-
|
|
442
|
-
var nameSpan = document.createElement("span");
|
|
443
|
-
nameSpan.className = "dm-bubble-name";
|
|
444
|
-
nameSpan.textContent = _myName;
|
|
445
|
-
header.appendChild(nameSpan);
|
|
446
|
-
|
|
447
|
-
var badge = document.createElement("span");
|
|
448
|
-
badge.className = "scheduled-msg-badge";
|
|
449
|
-
badge.innerHTML = iconHtml("clock");
|
|
450
|
-
countdownEl = document.createElement("span");
|
|
451
|
-
countdownEl.className = "scheduled-msg-countdown";
|
|
452
|
-
badge.appendChild(countdownEl);
|
|
453
|
-
header.appendChild(badge);
|
|
454
|
-
|
|
455
|
-
var actions = document.createElement("span");
|
|
456
|
-
actions.className = "scheduled-msg-actions";
|
|
457
|
-
|
|
458
|
-
actions.appendChild(collapsible.button);
|
|
459
|
-
|
|
460
|
-
var sendNowBtn = document.createElement("button");
|
|
461
|
-
sendNowBtn.className = "scheduled-msg-send-now";
|
|
462
|
-
sendNowBtn.textContent = "Send now";
|
|
463
|
-
sendNowBtn.addEventListener("click", function () { sendScheduledNow(input.id); });
|
|
464
|
-
actions.appendChild(sendNowBtn);
|
|
465
|
-
|
|
466
|
-
var sep = document.createElement("span");
|
|
467
|
-
sep.className = "scheduled-msg-sep";
|
|
468
|
-
sep.textContent = "\u00b7";
|
|
469
|
-
actions.appendChild(sep);
|
|
470
|
-
|
|
471
|
-
cancelBtn = document.createElement("button");
|
|
472
|
-
cancelBtn.className = "scheduled-msg-cancel";
|
|
473
|
-
cancelBtn.textContent = "Cancel";
|
|
474
|
-
cancelBtn.addEventListener("click", function () { cancelScheduledInput(input.id); });
|
|
475
|
-
actions.appendChild(cancelBtn);
|
|
476
|
-
|
|
477
|
-
header.appendChild(actions);
|
|
478
|
-
|
|
479
|
-
content.appendChild(header);
|
|
480
|
-
|
|
481
|
-
var bubble = document.createElement("div");
|
|
482
|
-
bubble.className = "bubble scheduled-msg-bubble";
|
|
483
|
-
bubble.appendChild(collapsible.el);
|
|
484
|
-
content.appendChild(bubble);
|
|
485
|
-
|
|
486
|
-
wrap.appendChild(content);
|
|
487
|
-
} else {
|
|
488
|
-
// Bubble mode: original layout
|
|
489
|
-
var bubble = document.createElement("div");
|
|
490
|
-
bubble.className = "bubble scheduled-msg-bubble";
|
|
491
|
-
|
|
492
|
-
bubble.appendChild(collapsible.el);
|
|
493
|
-
|
|
494
|
-
var metaEl = document.createElement("div");
|
|
495
|
-
metaEl.className = "scheduled-msg-meta";
|
|
496
|
-
|
|
497
|
-
var clockIcon = document.createElement("span");
|
|
498
|
-
clockIcon.className = "scheduled-msg-icon";
|
|
499
|
-
clockIcon.innerHTML = iconHtml("clock");
|
|
500
|
-
metaEl.appendChild(clockIcon);
|
|
501
|
-
|
|
502
|
-
countdownEl = document.createElement("span");
|
|
503
|
-
countdownEl.className = "scheduled-msg-countdown";
|
|
504
|
-
metaEl.appendChild(countdownEl);
|
|
505
|
-
|
|
506
|
-
metaEl.appendChild(collapsible.button);
|
|
507
|
-
|
|
508
|
-
var sendNowBtn2 = document.createElement("button");
|
|
509
|
-
sendNowBtn2.className = "scheduled-msg-send-now";
|
|
510
|
-
sendNowBtn2.textContent = "Send now";
|
|
511
|
-
sendNowBtn2.addEventListener("click", function () { sendScheduledNow(input.id); });
|
|
512
|
-
metaEl.appendChild(sendNowBtn2);
|
|
513
|
-
|
|
514
|
-
var sep2 = document.createElement("span");
|
|
515
|
-
sep2.className = "scheduled-msg-sep";
|
|
516
|
-
sep2.textContent = "\u00b7";
|
|
517
|
-
metaEl.appendChild(sep2);
|
|
518
|
-
|
|
519
|
-
cancelBtn = document.createElement("button");
|
|
520
|
-
cancelBtn.className = "scheduled-msg-cancel";
|
|
521
|
-
cancelBtn.textContent = "Cancel";
|
|
522
|
-
cancelBtn.addEventListener("click", function () { cancelScheduledInput(input.id); });
|
|
523
|
-
metaEl.appendChild(cancelBtn);
|
|
524
|
-
|
|
525
|
-
wrap.appendChild(bubble);
|
|
526
|
-
wrap.appendChild(metaEl);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
return { wrap: wrap, countdownEl: countdownEl };
|
|
379
|
+
renderScheduledOutbox(getScheduledInputs(sessionId));
|
|
530
380
|
}
|
|
531
381
|
|
|
532
|
-
// Clears the
|
|
382
|
+
// Clears the drawn outbox rows and their countdown only; the per-session
|
|
533
383
|
// list is untouched. Used when re-drawing for the same session and when the
|
|
534
384
|
// view moves to another project.
|
|
535
385
|
export function removeScheduledMessageBubble() {
|
|
536
|
-
|
|
537
|
-
scheduledMsgEl.remove();
|
|
538
|
-
scheduledMsgEl = null;
|
|
539
|
-
}
|
|
540
|
-
scheduledCountdowns = [];
|
|
541
|
-
if (scheduledCountdownTimer) {
|
|
542
|
-
clearInterval(scheduledCountdownTimer);
|
|
543
|
-
scheduledCountdownTimer = null;
|
|
544
|
-
}
|
|
386
|
+
removeScheduledOutbox();
|
|
545
387
|
}
|
|
546
388
|
|
|
547
389
|
export function handleFastModeState(state) {
|
|
@@ -571,7 +413,7 @@ export function handleFastModeState(state) {
|
|
|
571
413
|
refreshIcons();
|
|
572
414
|
}
|
|
573
415
|
|
|
574
|
-
export function getScheduledMsgEl() { return
|
|
416
|
+
export function getScheduledMsgEl() { return getScheduledOutboxEl(); }
|
|
575
417
|
|
|
576
418
|
// lr-0827ba: this used to also null out the bare module-scoped
|
|
577
419
|
// rateLimitResetsAt/rateLimitResetTimer/rateLimitResetState variables —
|
|
@@ -594,6 +436,7 @@ export function resetRateLimitState() {
|
|
|
594
436
|
if (rateLimitUsageEl) { rateLimitUsageEl.remove(); rateLimitUsageEl = null; }
|
|
595
437
|
if (fastModeIndicatorEl) { fastModeIndicatorEl.remove(); fastModeIndicatorEl = null; }
|
|
596
438
|
removeScheduledMessageBubble();
|
|
439
|
+
resetScheduledOutboxRequests();
|
|
597
440
|
}
|
|
598
441
|
|
|
599
442
|
// Called when a session is actually destroyed/removed (not merely
|
|
@@ -9,8 +9,9 @@ import { renderMarkdown, renderMarkdownAsync, highlightCodeBlocks, renderMermaid
|
|
|
9
9
|
import { iconHtml, refreshIcons } from './icons.js';
|
|
10
10
|
import { userAvatarUrl } from './avatar.js';
|
|
11
11
|
import { injectedSenderName, injectedLabel, injectedSessionNote } from './injected-label.js';
|
|
12
|
-
import { buildCollapsibleText, needsCollapse,
|
|
12
|
+
import { buildCollapsibleText, needsCollapse, isNonTypedInput } from './collapsible-text.js';
|
|
13
13
|
import { resolveInjectedIdentity } from './injected-identity.js';
|
|
14
|
+
import { applyIdentityAvatar } from './agent-avatar.js';
|
|
14
15
|
import { getProjectAgents } from './at-agents.js';
|
|
15
16
|
import { closeToolGroup } from './tools.js';
|
|
16
17
|
import { showImageModal, showPasteModal } from './app-misc.js';
|
|
@@ -489,7 +490,7 @@ export function finalizeAssistantBlock() {
|
|
|
489
490
|
// message another process sent into the session. It always renders through the
|
|
490
491
|
// other-sender path, never as the local user. All of its text is untrusted and
|
|
491
492
|
// is set with textContent.
|
|
492
|
-
export function addUserMessage(text, images, pastes, fromUserId, fromUserName, injected) {
|
|
493
|
+
export function addUserMessage(text, images, pastes, fromUserId, fromUserName, injected, sentMidTurn) {
|
|
493
494
|
if (!text && (!images || images.length === 0) && (!pastes || pastes.length === 0)) return;
|
|
494
495
|
var myUserId = store.get('myUserId');
|
|
495
496
|
// Only treat as "other user" if we're in multi-user mode AND myUserId is
|
|
@@ -549,11 +550,12 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName, i
|
|
|
549
550
|
bubble.appendChild(pasteRow);
|
|
550
551
|
}
|
|
551
552
|
|
|
552
|
-
//
|
|
553
|
+
// Long input pushed into the session (trigger, loop, scheduled) collapses to a
|
|
554
|
+
// few lines; the operator's own typed message never does.
|
|
553
555
|
// Labelling of injected input is untouched; only the text node is swapped.
|
|
554
556
|
var firedCollapse = null;
|
|
555
557
|
if (text) {
|
|
556
|
-
if (
|
|
558
|
+
if (isNonTypedInput(injected) && needsCollapse(text)) {
|
|
557
559
|
firedCollapse = buildCollapsibleText(text);
|
|
558
560
|
bubble.appendChild(firedCollapse.el);
|
|
559
561
|
} else {
|
|
@@ -563,6 +565,14 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName, i
|
|
|
563
565
|
}
|
|
564
566
|
}
|
|
565
567
|
|
|
568
|
+
// A message delivered into a running turn says so, in place in the transcript.
|
|
569
|
+
if (sentMidTurn) {
|
|
570
|
+
var midTurnMark = document.createElement("span");
|
|
571
|
+
midTurnMark.className = "msg-sent-midturn";
|
|
572
|
+
midTurnMark.textContent = "Sent mid-turn";
|
|
573
|
+
bubble.appendChild(midTurnMark);
|
|
574
|
+
}
|
|
575
|
+
|
|
566
576
|
|
|
567
577
|
var cachedAllUsers = store.get('cachedAllUsers');
|
|
568
578
|
var _targetUser;
|
|
@@ -587,9 +597,13 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName, i
|
|
|
587
597
|
|
|
588
598
|
var avi = document.createElement("img");
|
|
589
599
|
avi.className = "dm-bubble-avatar" + (isOtherUser ? " dm-bubble-avatar-other" : " dm-bubble-avatar-me");
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
600
|
+
if (_injectedIdentity) {
|
|
601
|
+
applyIdentityAvatar(avi, _injectedIdentity, 36);
|
|
602
|
+
} else {
|
|
603
|
+
avi.src = isOtherUser
|
|
604
|
+
? userAvatarUrl(_targetUser || { id: fromUserId }, 36)
|
|
605
|
+
: (document.body.dataset.myAvatarUrl || userAvatarUrl(_targetUser || { id: myUserId }, 36));
|
|
606
|
+
}
|
|
593
607
|
div.appendChild(avi);
|
|
594
608
|
|
|
595
609
|
var contentWrap = document.createElement("div");
|
|
@@ -663,6 +677,7 @@ export function addSystemMessage(text, isError) {
|
|
|
663
677
|
div.querySelector(".sys-text").textContent = text;
|
|
664
678
|
addToMessages(div);
|
|
665
679
|
scrollToBottom();
|
|
680
|
+
return div;
|
|
666
681
|
}
|
|
667
682
|
|
|
668
683
|
export function addConflictMessage(msg) {
|
|
@@ -1,31 +1,46 @@
|
|
|
1
|
-
// collapsible-text.js -
|
|
2
|
-
// real expand/collapse button.
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
1
|
+
// collapsible-text.js - a collapsed view of long input that was pushed into a
|
|
2
|
+
// session, with a real expand/collapse button. The one component for every
|
|
3
|
+
// surface that shows such input: a delivered trigger, loop or scheduled message
|
|
4
|
+
// in the transcript and an armed schedule's row in the composer outbox, so they
|
|
5
|
+
// cannot drift apart. The stored text is never cut: the preview carries the
|
|
6
|
+
// first lines and CSS clamps it with an ellipsis; the full text stays in the DOM
|
|
7
|
+
// and is only hidden while collapsed. State lives in the closure, so it is per
|
|
8
|
+
// message and gone on reload.
|
|
7
9
|
|
|
8
|
-
//
|
|
10
|
+
// Lines the collapsed view shows; a text of more lines collapses.
|
|
11
|
+
export var COLLAPSE_LINES = 3;
|
|
12
|
+
|
|
13
|
+
// A text collapses when it has more than COLLAPSE_LINES lines or is longer than
|
|
9
14
|
// this many characters.
|
|
10
15
|
export var COLLAPSE_CHAR_LIMIT = 280;
|
|
11
16
|
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
// Input pushed into a session rather than typed by the operator. The injected
|
|
18
|
+
// descriptor (injected-label.js injectedFromMessage) is null for the operator's
|
|
19
|
+
// own entry, so any descriptor means a trigger, loop, scheduled or scheduled-now
|
|
20
|
+
// input, or a legacy entry another process sent. The session agent's replies
|
|
21
|
+
// are not user input and never pass through here.
|
|
22
|
+
export function isNonTypedInput(injected) {
|
|
23
|
+
if (!injected) return false;
|
|
24
|
+
return !(injected.initiator === "human" && !injected.senderKind);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function lineList(text) {
|
|
28
|
+
return String(text == null ? "" : text).trim().split(/\r?\n/);
|
|
15
29
|
}
|
|
16
30
|
|
|
17
31
|
export function needsCollapse(text) {
|
|
18
32
|
var s = String(text == null ? "" : text).trim();
|
|
19
|
-
return s.
|
|
33
|
+
return lineList(s).length > COLLAPSE_LINES || s.length > COLLAPSE_CHAR_LIMIT;
|
|
20
34
|
}
|
|
21
35
|
|
|
22
|
-
//
|
|
23
|
-
export function
|
|
36
|
+
// The first COLLAPSE_LINES non-empty lines, for the collapsed preview.
|
|
37
|
+
export function previewLines(text) {
|
|
38
|
+
var out = [];
|
|
24
39
|
var lines = String(text == null ? "" : text).split(/\r?\n/);
|
|
25
|
-
for (var i = 0; i < lines.length; i++) {
|
|
26
|
-
if (lines[i].trim() !== "")
|
|
40
|
+
for (var i = 0; i < lines.length && out.length < COLLAPSE_LINES; i++) {
|
|
41
|
+
if (lines[i].trim() !== "") out.push(lines[i]);
|
|
27
42
|
}
|
|
28
|
-
return "";
|
|
43
|
+
return out.join("\n");
|
|
29
44
|
}
|
|
30
45
|
|
|
31
46
|
// Builds { el, button }. `el` holds the preview and the full text; `button`
|
|
@@ -40,12 +55,12 @@ export function buildCollapsibleText(text, opts) {
|
|
|
40
55
|
el.className = "collapsible-text";
|
|
41
56
|
|
|
42
57
|
// One line of text needs no second copy: the one node is the preview while
|
|
43
|
-
// collapsed (CSS
|
|
58
|
+
// collapsed (CSS clamps it) and the whole text once expanded. Several lines get
|
|
44
59
|
// a preview node and the full node, one shown at a time.
|
|
45
60
|
var single = String(text == null ? "" : text).indexOf("\n") === -1;
|
|
46
61
|
var preview = document.createElement("span");
|
|
47
62
|
preview.className = "collapsible-preview";
|
|
48
|
-
preview.textContent = single ? text :
|
|
63
|
+
preview.textContent = single ? text : previewLines(text);
|
|
49
64
|
el.appendChild(preview);
|
|
50
65
|
if (single) {
|
|
51
66
|
el.classList.add("collapsible-single");
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// compaction-state.js - DOM-free derivations for the compaction signals the
|
|
2
|
+
// session view shows: whether the active session is compacting, and whether its
|
|
3
|
+
// context is nearing the vendor's auto-compaction point.
|
|
4
|
+
|
|
5
|
+
// Fraction of the vendor-reported auto-compact threshold at which the meter
|
|
6
|
+
// starts to say compaction is near. A fixed margin: the threshold itself always
|
|
7
|
+
// comes from the vendor (getContextUsage), never from a table of model windows.
|
|
8
|
+
export var NEARING_FRACTION = 0.9;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {?object} usage vendor context usage (getContextUsage shape)
|
|
12
|
+
* @returns {boolean} true only when the vendor reports auto-compaction on with a
|
|
13
|
+
* threshold and usage is within the margin of it (or already past it)
|
|
14
|
+
*/
|
|
15
|
+
export function isNearingCompaction(usage) {
|
|
16
|
+
if (!usage || usage.isAutoCompactEnabled !== true) return false;
|
|
17
|
+
var threshold = usage.autoCompactThreshold;
|
|
18
|
+
var total = usage.totalTokens;
|
|
19
|
+
if (typeof threshold !== "number" || !(threshold > 0)) return false;
|
|
20
|
+
if (typeof total !== "number" || !(total >= 0)) return false;
|
|
21
|
+
return total >= threshold * NEARING_FRACTION;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {object[]} sessions a session_list payload
|
|
26
|
+
* @param {?number} activeSessionId
|
|
27
|
+
* @returns {{found: boolean, compacting: boolean}}
|
|
28
|
+
*/
|
|
29
|
+
export function compactingFromSessionList(sessions, activeSessionId) {
|
|
30
|
+
for (var i = 0; i < sessions.length; i++) {
|
|
31
|
+
if (sessions[i].id === activeSessionId) return { found: true, compacting: !!sessions[i].compacting };
|
|
32
|
+
}
|
|
33
|
+
return { found: false, compacting: false };
|
|
34
|
+
}
|
|
@@ -35,10 +35,25 @@ export function slugifyFilename(filename) {
|
|
|
35
35
|
* @returns {Promise<Array<{slug: string, url: string, size?: number, ext?: string}>>}
|
|
36
36
|
*/
|
|
37
37
|
export function fetchCustomIconList() {
|
|
38
|
+
return fetchCustomIconListStrict().catch(function () { return []; });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The same list, but a failed request rejects, for a caller that must tell
|
|
43
|
+
* "no icons" from "could not load them".
|
|
44
|
+
*
|
|
45
|
+
* @returns {Promise<Array<{slug: string, url: string, size?: number, ext?: string}>>}
|
|
46
|
+
*/
|
|
47
|
+
export function fetchCustomIconListStrict() {
|
|
38
48
|
return fetch("/api/custom-emoji")
|
|
39
|
-
.then(function (r) {
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
.then(function (r) {
|
|
50
|
+
if (r.ok === false) throw new Error("HTTP " + r.status);
|
|
51
|
+
return r.json();
|
|
52
|
+
})
|
|
53
|
+
.then(function (data) {
|
|
54
|
+
if (!Array.isArray(data)) throw new Error("unexpected response");
|
|
55
|
+
return data;
|
|
56
|
+
});
|
|
42
57
|
}
|
|
43
58
|
|
|
44
59
|
/**
|
|
@@ -48,9 +63,12 @@ export function fetchCustomIconList() {
|
|
|
48
63
|
*
|
|
49
64
|
* @param {string} slug
|
|
50
65
|
* @param {File|Blob} file
|
|
66
|
+
* @param {{createOnly?: boolean}} [opts] createOnly: the server refuses a slug
|
|
67
|
+
* that already exists instead of replacing its image.
|
|
51
68
|
* @returns {Promise<{ok: boolean, slug?: string, url?: string, error?: string}>}
|
|
52
69
|
*/
|
|
53
|
-
export function uploadCustomIcon(slug, file) {
|
|
70
|
+
export function uploadCustomIcon(slug, file, opts) {
|
|
71
|
+
var query = opts && opts.createOnly ? "?create=1" : "";
|
|
54
72
|
return new Promise(function (resolve) {
|
|
55
73
|
// Defense-in-depth (lr-6c9930): FileReader.readAsArrayBuffer(null/undefined)
|
|
56
74
|
// throws synchronously inside the Promise executor rather than firing
|
|
@@ -64,7 +82,7 @@ export function uploadCustomIcon(slug, file) {
|
|
|
64
82
|
}
|
|
65
83
|
var reader = new FileReader();
|
|
66
84
|
reader.onload = function (ev) {
|
|
67
|
-
fetch("/api/custom-emoji/" + encodeURIComponent(slug), {
|
|
85
|
+
fetch("/api/custom-emoji/" + encodeURIComponent(slug) + query, {
|
|
68
86
|
method: "POST",
|
|
69
87
|
body: ev.target.result,
|
|
70
88
|
}).then(function (r) {
|