@clagentic/console 1.10.0 → 1.11.0-beta.2

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.
Files changed (97) hide show
  1. package/README.md +14 -1
  2. package/bin/cli.js +38 -16
  3. package/lib/agents.js +1 -55
  4. package/lib/bash-auto-approve.js +133 -0
  5. package/lib/build-identity.js +23 -5
  6. package/lib/build-sha.json +2 -2
  7. package/lib/build-update-check.js +0 -62
  8. package/lib/build-update-offer.js +23 -13
  9. package/lib/build-update-restart.js +59 -43
  10. package/lib/cli/arg-validation.js +50 -0
  11. package/lib/cli/daemon-launch.js +5 -4
  12. package/lib/cli/menus.js +2 -2
  13. package/lib/cli/schedule-input-subcommands.js +327 -0
  14. package/lib/cli/session-subcommands.js +101 -17
  15. package/lib/client-build-id.js +56 -0
  16. package/lib/daemon.js +38 -6
  17. package/lib/identity/index.js +9 -4
  18. package/lib/injected-sender.js +225 -0
  19. package/lib/message-sender-record.js +133 -0
  20. package/lib/pending-prompts.js +55 -0
  21. package/lib/permission-mode-policy.js +63 -0
  22. package/lib/permission-settings.js +96 -0
  23. package/lib/permission-summary.js +67 -0
  24. package/lib/project-connection.js +10 -11
  25. package/lib/project-external-trigger.js +9 -1
  26. package/lib/project-loop.js +50 -23
  27. package/lib/project-permission-settings.js +59 -0
  28. package/lib/project-prompt-responses.js +25 -15
  29. package/lib/project-sessions.js +164 -60
  30. package/lib/project-user-message.js +18 -47
  31. package/lib/project.js +46 -74
  32. package/lib/public/app.js +4 -7
  33. package/lib/public/css/channel-layout.css +20 -0
  34. package/lib/public/css/diagnostics.css +7 -0
  35. package/lib/public/css/input.css +78 -0
  36. package/lib/public/css/menus.css +17 -0
  37. package/lib/public/css/overlays.css +0 -3
  38. package/lib/public/css/scheduler-modal.css +5 -0
  39. package/lib/public/index.html +44 -8
  40. package/lib/public/modules/app-connection.js +18 -1
  41. package/lib/public/modules/app-loop-ui.js +11 -1
  42. package/lib/public/modules/app-messages.js +23 -30
  43. package/lib/public/modules/app-panels.js +10 -3
  44. package/lib/public/modules/app-rate-limit.js +64 -88
  45. package/lib/public/modules/app-rendering.js +37 -6
  46. package/lib/public/modules/approve-tools-toggle.js +33 -0
  47. package/lib/public/modules/at-agents.js +8 -0
  48. package/lib/public/modules/build-guard.js +61 -0
  49. package/lib/public/modules/build-update-detail.js +1 -4
  50. package/lib/public/modules/diagnostics.js +98 -9
  51. package/lib/public/modules/injected-identity.js +78 -0
  52. package/lib/public/modules/injected-label.js +62 -0
  53. package/lib/public/modules/input.js +64 -114
  54. package/lib/public/modules/loop-hooks-warning.js +20 -0
  55. package/lib/public/modules/mode-options.js +35 -16
  56. package/lib/public/modules/permission-settings.js +56 -0
  57. package/lib/public/modules/project-settings.js +3 -0
  58. package/lib/public/modules/rate-limit-state.js +47 -22
  59. package/lib/public/modules/schedule-panel.js +234 -0
  60. package/lib/public/modules/schedule-time.js +193 -0
  61. package/lib/public/modules/scheduled-input-actions.js +19 -0
  62. package/lib/public/modules/scheduler-config.js +12 -0
  63. package/lib/public/modules/scheduler.js +8 -0
  64. package/lib/public/modules/server-settings.js +5 -9
  65. package/lib/public/modules/settings-defaults.js +18 -4
  66. package/lib/runtime-env.js +4 -0
  67. package/lib/scheduled-input/ipc.js +92 -0
  68. package/lib/scheduled-input/rate-limit-resume.js +53 -0
  69. package/lib/scheduled-input/records.js +350 -0
  70. package/lib/scheduled-input/service.js +743 -0
  71. package/lib/scheduled-input/store.js +132 -0
  72. package/lib/scheduled-input/ws.js +194 -0
  73. package/lib/scheduler.js +4 -0
  74. package/lib/sdk-bridge.js +194 -175
  75. package/lib/sdk-message-processor.js +13 -5
  76. package/lib/sdk-skill-discovery.js +17 -0
  77. package/lib/sender-ref.js +109 -0
  78. package/lib/server.js +37 -11
  79. package/lib/session-directory.js +224 -0
  80. package/lib/session-file-scan.js +55 -0
  81. package/lib/session-input-ipc.js +21 -0
  82. package/lib/session-input.js +396 -23
  83. package/lib/session-name-holder.js +82 -0
  84. package/lib/session-resume.js +3 -0
  85. package/lib/sessions.js +111 -2
  86. package/lib/turn-initiator.js +6 -2
  87. package/lib/updater.js +8 -2
  88. package/lib/ws-schema.js +20 -9
  89. package/lib/yoke/adapters/claude-worker.js +3 -1
  90. package/lib/yoke/adapters/claude.js +13 -17
  91. package/lib/yoke/adapters/codex.js +18 -5
  92. package/lib/yoke/adapters/permission-relay.js +9 -0
  93. package/lib/yoke/interface.js +7 -1
  94. package/package.json +1 -1
  95. package/scripts/check-test-count.js +1 -1
  96. package/scripts/install-local-test.js +45 -1
  97. package/scripts/postinstall.js +1 -0
@@ -9,6 +9,8 @@ import { showConfirm } from './app-misc.js';
9
9
  import { openRalphWizard } from './app-loop-wizard.js';
10
10
  import { openSchedulerToTab } from './scheduler.js';
11
11
  import { renderModelList, renderModeList, renderEffortBar, renderThinkingBar } from './settings-defaults.js';
12
+ import { approveToolsCardHtml, bindApproveToolsToggle } from './approve-tools-toggle.js';
13
+ import { loopHooksWarningHtml } from './loop-hooks-warning.js';
12
14
 
13
15
  // Execution modal: module-internal UI var (not in store)
14
16
  var pendingIterations = 20;
@@ -167,7 +169,7 @@ function startLoopFromUi() {
167
169
  function sendLoopStart() {
168
170
  var ws = getWs();
169
171
  if (ws && ws.readyState === 1) {
170
- var msg = { type: "loop_start", maxIterations: pendingIterations };
172
+ var msg = { type: "loop_start", maxIterations: pendingIterations, approveToolsAutomatically: _previewApproveTools };
171
173
  if (Object.keys(_previewLoopSettings).length > 0) {
172
174
  msg.settings = _previewLoopSettings;
173
175
  }
@@ -806,6 +808,7 @@ export function openRalphPreviewModal() {
806
808
  if (runBtn) runBtn.disabled = !store.get('ralphFilesReady').bothReady;
807
809
 
808
810
  _previewLoopSettings = {};
811
+ _previewApproveTools = true;
809
812
  showRalphPreviewTab("prompt");
810
813
  modal.classList.remove("hidden");
811
814
  refreshIcons();
@@ -819,6 +822,9 @@ function closeRalphPreviewModal() {
819
822
 
820
823
  // Pending loop settings for the preview modal (saved to LOOP.json on launch)
821
824
  var _previewLoopSettings = {};
825
+ // "Approve tools automatically during this loop" for the loop being started;
826
+ // on until the person turns it off.
827
+ var _previewApproveTools = true;
822
828
 
823
829
  function getPreviewLoopSettings() { return _previewLoopSettings; }
824
830
 
@@ -878,6 +884,8 @@ function renderPreviewModelTab(bodyEl) {
878
884
  '<input id="rp-thinking-budget" type="number" class="settings-budget-input" min="1024" max="128000" step="1024" value="10000">' +
879
885
  '</div>' +
880
886
  '</div></div>' +
887
+ approveToolsCardHtml("rp") +
888
+ loopHooksWarningHtml(_previewLoopSettings) +
881
889
  '</div>';
882
890
 
883
891
  function savePreviewSetting(key, value) {
@@ -912,4 +920,6 @@ function renderPreviewModelTab(bodyEl) {
912
920
  renderModeList("rp", opts);
913
921
  renderEffortBar("rp", opts);
914
922
  renderThinkingBar("rp", opts);
923
+ // Sent with loop_start, which puts it on the loop's record.
924
+ bindApproveToolsToggle("rp", _previewApproveTools, function (approve) { _previewApproveTools = approve; });
915
925
  }
@@ -34,13 +34,14 @@ import { handlePaletteSessionSwitch, setPaletteVersion } from './command-palette
34
34
  import { handleAgentsList, handleAgentFavoriteToggled } from './agent-picker.js';
35
35
  import { handleProjectAgentsList, requestProjectAgents } from './at-agents.js';
36
36
  import { handleFindInSessionResults } from './session-search.js';
37
- import { handleInputSync, autoResize, resetAutoResize, builtinCommands, setScheduleBtnDisabled } from './input.js';
37
+ import { handleInputSync, autoResize, resetAutoResize, builtinCommands } from './input.js';
38
38
  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, applyPromptMessage, hasPendingPrompts } from './tools.js';
39
39
  import { showDoneNotification, playDoneSound, isNotifAlertEnabled, isNotifSoundEnabled } from './notifications.js';
40
40
  import { handleFsRead, refreshIfOpen } from './filebrowser.js';
41
41
  import { isProjectSettingsOpen, refreshProjectSettingsModels, handleInstructionsRead, handleInstructionsWrite, handleProjectEnv, handleProjectEnvSaved, handleProjectSharedEnv, handleProjectSharedEnvSaved, handleProjectOwnerChanged, updateLiteVisibility, handleLiteProjectStatus, handleLiteEnrollResult, handleLiteUnenrollResult } from './project-settings.js';
42
42
  import { updateSettingsModels, updateSettingsStats, updateDaemonConfig, handleSharedEnv, handleSharedEnvSaved, updateSsLiteVisibility } from './server-settings.js';
43
43
  import { handleRenameCustomIconResult } from './custom-icons-settings.js';
44
+ import { handlePermissionSettings, handlePermissionModeApplied } from './permission-settings.js';
44
45
  import { handleTermList, handleTermCreated, sendTerminalCommand, handleTermOutput, handleTermResized, handleTermExited, handleTermClosed } from './terminal.js';
45
46
  import { updateTerminalList, handleContextSourcesState } from './context-sources.js';
46
47
  import { handleNotesList, handleNoteCreated, handleNoteUpdated, handleNoteDeleted } from './sticky-notes.js';
@@ -53,15 +54,16 @@ import { handleMcpServersState } from './mcp-ui.js';
53
54
  import { handleLoopRegistryUpdated, handleScheduleRunStarted, handleScheduleRunFinished, handleLoopScheduled, isSchedulerOpen, enterCraftingMode, exitCraftingMode, handleLoopRegistryFiles } from './scheduler.js';
54
55
 
55
56
  // --- App module imports ---
57
+ import { injectedFromMessage } from './injected-label.js';
56
58
  import { scrollToBottom, addToMessages, addUserMessage, addSystemMessage, appendDelta, finalizeAssistantBlock, addConflictMessage, addContextOverflowMessage, showSuggestionChips, removePreThinking } from './app-rendering.js';
57
59
  import { startUrgentBlink, stopUrgentBlink, blinkSessionDot, updateCrossProjectBlink, reconcileActivityFooter } from './app-favicon.js';
58
- import { setStatus } from './app-connection.js';
60
+ import { setStatus, observeBuildInfo } from './app-connection.js';
59
61
  import { getModelEffortLevels, accumulateUsage, setSessionUsage, updateUsagePanel, accumulateContext, updateContextPanel, renderCtxPopover, updateStatusPanel } from './app-panels.js';
60
62
  import { updateProjectList, resetClientState, showUpdateAvailable, handleRemoveProjectCheckResult, handleRemoveProjectResult, handleBrowseDirResult, handleAddProjectResult, handleCloneProgress } from './app-projects.js';
61
63
  import { updateHistorySentinel, prependOlderHistory } from './app-header.js';
62
64
  import { hideHomeHub, handleHubSchedules, handleHubRecentSessions } from './app-home-hub.js';
63
65
  import { openDm, enterDmMode, exitDmMode, appendDmMessage, showDmTypingIndicator } from './app-dm.js';
64
- import { handleRateLimitEvent, updateRateLimitUsage, addScheduledMessageBubble, removeScheduledMessageBubble, clearScheduledMessage, handleFastModeState, restoreRateLimitStateForSession, forgetSessionRateLimitState } from './app-rate-limit.js';
66
+ import { handleRateLimitEvent, updateRateLimitUsage, applyScheduledInputList, handleFastModeState, restoreRateLimitStateForSession, forgetSessionRateLimitState } from './app-rate-limit.js';
65
67
  import { handleRemoteCursorMove, handleRemoteCursorLeave, handleRemoteSelection, clearRemoteCursors } from './app-cursors.js';
66
68
  import { showLoopBanner, updateLoopBanner, updateLoopInputVisibility, updateLoopPendingBanner, showRalphApprovalBar, updateRalphApprovalStatus, openRalphPreviewModal, showExecModal, updateExecModalStatus } from './app-loop-ui.js';
67
69
  import { handleSkillInstallWs } from './app-skills-install.js';
@@ -69,7 +71,7 @@ import { handleSessionGrants } from './session-grants.js';
69
71
  import { handleNotificationsState, handleNotificationCreated, handleNotificationDismissed, handleNotificationDismissedAll, showUpdateBanner } from './app-notifications.js';
70
72
  import { handleMentionStart, handleMentionActivity, handleMentionStream, handleMentionDone, handleMentionError, renderMentionUser, renderMentionResponse, renderUserMention } from './mention.js';
71
73
  import { handleTeamState, handleTeamMemberUpdate, handleTeamTaskUpdate, handleTeamMessage as handleTeamMsg, handleTeamGone } from './team-panel.js';
72
- import { addDiagnostic, refreshDiagnostic, retractDiagnostics } from './diagnostics.js';
74
+ import { addDiagnostic, refreshDiagnostic, retractDiagnostics, settleBuildUpdateRequest } from './diagnostics.js';
73
75
  import { handleHistoryMeta, handleHistoryDone } from './app-history-replay.js';
74
76
  import { shouldApplyActivityEdge } from './activity-latch.js';
75
77
  import { deriveSessionListProcessing } from './activity-state.js';
@@ -180,6 +182,7 @@ registerHandlers({
180
182
  var tbProjectName = document.getElementById("title-bar-project-name");
181
183
  if (tbProjectName) tbProjectName.textContent = msg.title || store.get('projectName');
182
184
  updatePageTitle();
185
+ observeBuildInfo(msg);
183
186
  if (msg.version) {
184
187
  setPaletteVersion(msg.version);
185
188
  var serverVersionEl = document.getElementById("settings-server-version");
@@ -189,19 +192,6 @@ registerHandlers({
189
192
  if (msg.ownerLocked !== undefined) store.set({ ownerLocked: !!msg.ownerLocked });
190
193
  if (msg.osUsers !== undefined) store.set({ isOsUsers: !!msg.osUsers });
191
194
  if (msg.lanHost) window.__lanHost = msg.lanHost;
192
- if (msg.dangerouslySkipPermissions) {
193
- store.set({ skipPermsEnabled: true });
194
- var spBanner = document.getElementById("skip-perms-pill");
195
- if (spBanner) spBanner.classList.remove("hidden");
196
- }
197
- if (msg.dangerouslySkipPermissionsBlocked) {
198
- // The server config has dangerouslySkipPermissions=true but it is disabled
199
- // because multi-user mode is active. Warn admins so they know the config
200
- // flag has no effect and remove it to avoid confusion.
201
- if (store.get('permissions') && store.get('permissions').projectSettings !== false) {
202
- showToast("dangerouslySkipPermissions is set in config but is disabled in multi-user mode. All users have normal tool-approval rules.", "warn");
203
- }
204
- }
205
195
  updateProjectList(msg);
206
196
  if (msg.liteInstalled !== undefined) {
207
197
  updateLiteVisibility(!!msg.liteInstalled);
@@ -301,6 +291,9 @@ registerHandlers({
301
291
  applyVendorRegistry(msg);
302
292
  },
303
293
 
294
+ permission_settings: handlePermissionSettings,
295
+ permission_mode_applied: handlePermissionModeApplied,
296
+
304
297
  config_state: function (msg) {
305
298
  var _cs = {};
306
299
  if (msg.model) _cs.currentModel = msg.model;
@@ -654,7 +647,8 @@ registerHandlers({
654
647
  renderPlanCard(msg.planContent);
655
648
  addUserMessage("Execute the following plan. Do NOT re-enter plan mode — just implement it step by step.", msg.images || null, msg.pastes || null, msg.from, msg.fromName);
656
649
  } else {
657
- addUserMessage(msg.text, msg.images || null, msg.pastes || null, msg.from, msg.fromName);
650
+ // Injected input names its sender; it never takes the local user's place.
651
+ addUserMessage(msg.text, msg.images || null, msg.pastes || null, msg.from, msg.fromName, injectedFromMessage(msg));
658
652
  }
659
653
  },
660
654
 
@@ -1018,25 +1012,22 @@ registerHandlers({
1018
1012
  rate_limit: handleRateLimitEvent,
1019
1013
  rate_limit_usage: updateRateLimitUsage,
1020
1014
 
1021
- scheduled_message_queued: function (msg) {
1022
- // lr-0827ba: msg.localId identifies the session this schedule
1023
- // actually belongs to — may not be the currently focused session.
1024
- addScheduledMessageBubble(msg.text, msg.resetsAt, msg.localId);
1025
- if (msg.localId == null || msg.localId === store.get('activeSessionId')) setScheduleBtnDisabled(true);
1026
- },
1015
+ // The session's armed scheduled inputs, in full, after every change. This is
1016
+ // the only source of the bubbles, the panel list and the clock button; msg.localId
1017
+ // names the session, which may not be the one on screen (lr-0827ba).
1018
+ scheduled_input_list: applyScheduledInputList,
1019
+
1020
+ // The original scheduled-message names, still sent for a browser running an
1021
+ // older client; this client takes its state from scheduled_input_list alone.
1022
+ scheduled_message_queued: function () {},
1027
1023
 
1028
1024
  scheduled_message_sent: function (msg) {
1029
- clearScheduledMessage(msg.localId);
1030
1025
  if (msg.localId == null || msg.localId === store.get('activeSessionId')) {
1031
- setScheduleBtnDisabled(false);
1032
1026
  setStatus("processing");
1033
1027
  }
1034
1028
  },
1035
1029
 
1036
- scheduled_message_cancelled: function (msg) {
1037
- clearScheduledMessage(msg.localId);
1038
- if (msg.localId == null || msg.localId === store.get('activeSessionId')) setScheduleBtnDisabled(false);
1039
- },
1030
+ scheduled_message_cancelled: function () {},
1040
1031
 
1041
1032
  auto_continue_scheduled: function (msg) {
1042
1033
  // Scheduler auto-continue, just show info
@@ -1306,6 +1297,8 @@ registerHandlers({
1306
1297
  retractDiagnostics(msg.source);
1307
1298
  },
1308
1299
 
1300
+ restart_for_build_update_result: settleBuildUpdateRequest,
1301
+
1309
1302
  daemon_config: function (msg) {
1310
1303
  if (msg.config && msg.config.headless) store.set({ isHeadlessMode: true });
1311
1304
  updateDaemonConfig(msg.config);
@@ -267,14 +267,21 @@ function rebuildModeList() {
267
267
  appendUnavailableNote(configModeList, modeGate.reason);
268
268
  return;
269
269
  }
270
- var options = modeOptions(currentCapabilities(), store.get('skipPermsEnabled'));
270
+ var options = modeOptions(currentCapabilities(), false);
271
271
  for (var i = 0; i < options.length; i++) {
272
272
  var opt = options[i];
273
273
  var btn = document.createElement("button");
274
- btn.className = "config-radio-item";
274
+ btn.className = "config-radio-item config-mode-item";
275
275
  if (opt.value === store.get('currentMode')) btn.classList.add("active");
276
276
  btn.dataset.mode = opt.value;
277
- btn.textContent = opt.label;
277
+ var labelEl = document.createElement("span");
278
+ labelEl.className = "config-mode-label";
279
+ labelEl.textContent = opt.label;
280
+ var hintEl = document.createElement("span");
281
+ hintEl.className = "config-mode-hint";
282
+ hintEl.textContent = opt.hint;
283
+ btn.appendChild(labelEl);
284
+ btn.appendChild(hintEl);
278
285
  btn.addEventListener("click", function () {
279
286
  var mode = this.dataset.mode;
280
287
  var ws = getWs();
@@ -3,22 +3,23 @@
3
3
 
4
4
  import { iconHtml, refreshIcons } from './icons.js';
5
5
  import { store } from './store.js';
6
- import { getWs } from './ws-ref.js';
7
6
  import { addToMessages, scrollToBottom } from './app-rendering.js';
8
7
  import { userAvatarUrl } from './avatar.js';
9
- import { clearScheduleDelay, setScheduleDelayForSession, clearScheduleDelayForSession, restoreScheduleDelayUi } from './input.js';
8
+ import { clearScheduleDelay, setScheduleDelayForSession, clearScheduleDelayForSession, restoreScheduleDelayUi, refreshScheduleControls } from './input.js';
10
9
  import { isSonnetModel, isOpusModel } from './model-families.js';
11
10
  import {
12
11
  getRateLimitResetsAt, setRateLimitResetsAt,
13
12
  getRateLimitResetTimer, setRateLimitResetTimer,
14
13
  getRateLimitResetState,
15
- setScheduledMsg, clearScheduledMsg, getScheduledMsg,
14
+ setScheduledInputs, getScheduledInputs,
16
15
  clearSession as clearSessionRateLimitState,
17
16
  } from './rate-limit-state.js';
17
+ import { countdownText } from './schedule-time.js';
18
+ import { sendScheduledNow, cancelScheduledInput, requestScheduledInputList } from './scheduled-input-actions.js';
18
19
 
19
20
  // --- Module-owned state ---
20
21
  // lr-0827ba: rateLimitResetsAt / rateLimitResetTimer / rateLimitResetState /
21
- // the scheduled-message bubble text are now owned per-session by
22
+ // the session's scheduled inputs are now owned per-session by
22
23
  // rate-limit-state.js (see imports above) — arming one project's rate-limit
23
24
  // auto-schedule no longer clobbers another project's armed state. The
24
25
  // variables below remain module-scoped because they are references to the
@@ -29,8 +30,11 @@ var rateLimitIndicatorEl = null;
29
30
  var rateLimitUsageEl = null;
30
31
  var rateLimitTickTimer = null;
31
32
  var _rateLimitUsageLastHtml = null; // guard against redundant innerHTML + refreshIcons()
33
+ // The scheduled-message bubbles of the session on screen share one container;
34
+ // each has a countdown the one interval below keeps current.
32
35
  var scheduledMsgEl = null;
33
36
  var scheduledCountdownTimer = null;
37
+ var scheduledCountdowns = [];
34
38
  var fastModeIndicatorEl = null;
35
39
 
36
40
  function currentSessionId() {
@@ -233,7 +237,7 @@ export function handleRateLimitEvent(msg) {
233
237
  // that gets its schedule armed, NOT necessarily the currently-focused
234
238
  // session — a rate limit hit in a background session must still arm that
235
239
  // session's auto-schedule and keep its reset timer running, exactly like
236
- // server-side session.scheduledMessage already does. Fall back to the
240
+ // the server's per-session scheduled inputs do. Fall back to the
237
241
  // active session for events from servers/replays that predate the localId
238
242
  // stamp (older recorded history entries).
239
243
  var eventSessionId = msg.localId != null ? msg.localId : currentSessionId();
@@ -323,7 +327,7 @@ export function updateRateLimitUsage(msg) {
323
327
  rateLimitUsageEl.className = "top-bar-pill pill-dim usage-check-link";
324
328
  rateLimitUsageEl.target = "_blank";
325
329
  rateLimitUsageEl.rel = "noopener";
326
- var ref = document.getElementById("skip-perms-pill");
330
+ var ref = document.getElementById("client-count");
327
331
  topBarActions.insertBefore(rateLimitUsageEl, ref);
328
332
  }
329
333
 
@@ -365,22 +369,49 @@ export function updateRateLimitUsage(msg) {
365
369
  }
366
370
  }
367
371
 
368
- // lr-0827ba: msg carries the server-stamped localId of the session the
369
- // scheduled message actually belongs to. Persist the queued text/resetsAt
370
- // for that session regardless of focus (so switching back in later can
371
- // redraw it), but only render the visible bubble into the DOM when the
372
- // event's session is the one currently in view — otherwise a background
373
- // project's scheduled message would render into whatever session's message
374
- // list happens to be on screen.
375
- export function addScheduledMessageBubble(text, resetsAt, sessionId) {
376
- var targetSessionId = sessionId != null ? sessionId : currentSessionId();
377
- setScheduledMsg(targetSessionId, text, resetsAt);
378
- if (targetSessionId !== currentSessionId()) return;
372
+ // The server's list of a session's armed scheduled inputs is the only source of
373
+ // the bubbles, the panel list and the clock button's state. msg.localId names
374
+ // the session the list belongs to (lr-0827ba): it may not be the one on screen,
375
+ // so it is stored either way and switching back in finds it, and only the
376
+ // session on screen is drawn, never into another session's message list.
377
+ export function applyScheduledInputList(msg) {
378
+ var targetSessionId = msg.localId != null ? msg.localId : currentSessionId();
379
+ setScheduledInputs(targetSessionId, msg.inputs, msg.limit);
380
+ refreshScheduleControls();
381
+ if (targetSessionId === currentSessionId()) renderScheduledBubbles(targetSessionId);
382
+ }
383
+
384
+ // Draws one bubble per armed input of the session on screen, in one container
385
+ // so the message list keeps them together at its end.
386
+ function renderScheduledBubbles(sessionId) {
379
387
  removeScheduledMessageBubble();
388
+ var inputs = getScheduledInputs(sessionId);
389
+ if (inputs.length === 0) return;
390
+ var container = document.createElement("div");
391
+ container.className = "scheduled-msgs";
392
+ inputs.forEach(function (input) {
393
+ var built = buildScheduledBubble(input);
394
+ container.appendChild(built.wrap);
395
+ scheduledCountdowns.push({ el: built.countdownEl, input: input });
396
+ });
397
+ addToMessages(container);
398
+ scheduledMsgEl = container;
399
+ scrollToBottom();
400
+ updateScheduledCountdowns();
401
+ scheduledCountdownTimer = setInterval(updateScheduledCountdowns, 1000);
402
+ }
403
+
404
+ function updateScheduledCountdowns() {
405
+ var now = Date.now();
406
+ scheduledCountdowns.forEach(function (c) { c.el.textContent = countdownText(c.input, now); });
407
+ }
408
+
409
+ function buildScheduledBubble(input) {
410
+ var text = input.text;
380
411
  var isChannel = document.body.classList.contains("wide-view");
381
412
  var wrap = document.createElement("div");
382
413
  wrap.className = "msg-user scheduled-msg-wrap";
383
- wrap.id = "scheduled-msg-bubble";
414
+ wrap.setAttribute("data-id", input.id);
384
415
 
385
416
  var countdownEl;
386
417
  var cancelBtn;
@@ -421,12 +452,7 @@ export function addScheduledMessageBubble(text, resetsAt, sessionId) {
421
452
  var sendNowBtn = document.createElement("button");
422
453
  sendNowBtn.className = "scheduled-msg-send-now";
423
454
  sendNowBtn.textContent = "Send now";
424
- sendNowBtn.addEventListener("click", function () {
425
- var ws = getWs();
426
- if (ws && ws.readyState === 1) {
427
- ws.send(JSON.stringify({ type: "send_scheduled_now" }));
428
- }
429
- });
455
+ sendNowBtn.addEventListener("click", function () { sendScheduledNow(input.id); });
430
456
  actions.appendChild(sendNowBtn);
431
457
 
432
458
  var sep = document.createElement("span");
@@ -437,12 +463,7 @@ export function addScheduledMessageBubble(text, resetsAt, sessionId) {
437
463
  cancelBtn = document.createElement("button");
438
464
  cancelBtn.className = "scheduled-msg-cancel";
439
465
  cancelBtn.textContent = "Cancel";
440
- cancelBtn.addEventListener("click", function () {
441
- var ws = getWs();
442
- if (ws && ws.readyState === 1) {
443
- ws.send(JSON.stringify({ type: "cancel_scheduled_message" }));
444
- }
445
- });
466
+ cancelBtn.addEventListener("click", function () { cancelScheduledInput(input.id); });
446
467
  actions.appendChild(cancelBtn);
447
468
 
448
469
  header.appendChild(actions);
@@ -481,12 +502,7 @@ export function addScheduledMessageBubble(text, resetsAt, sessionId) {
481
502
  var sendNowBtn2 = document.createElement("button");
482
503
  sendNowBtn2.className = "scheduled-msg-send-now";
483
504
  sendNowBtn2.textContent = "Send now";
484
- sendNowBtn2.addEventListener("click", function () {
485
- var ws = getWs();
486
- if (ws && ws.readyState === 1) {
487
- ws.send(JSON.stringify({ type: "send_scheduled_now" }));
488
- }
489
- });
505
+ sendNowBtn2.addEventListener("click", function () { sendScheduledNow(input.id); });
490
506
  metaEl.appendChild(sendNowBtn2);
491
507
 
492
508
  var sep2 = document.createElement("span");
@@ -497,71 +513,31 @@ export function addScheduledMessageBubble(text, resetsAt, sessionId) {
497
513
  cancelBtn = document.createElement("button");
498
514
  cancelBtn.className = "scheduled-msg-cancel";
499
515
  cancelBtn.textContent = "Cancel";
500
- cancelBtn.addEventListener("click", function () {
501
- var ws = getWs();
502
- if (ws && ws.readyState === 1) {
503
- ws.send(JSON.stringify({ type: "cancel_scheduled_message" }));
504
- }
505
- });
516
+ cancelBtn.addEventListener("click", function () { cancelScheduledInput(input.id); });
506
517
  metaEl.appendChild(cancelBtn);
507
518
 
508
519
  wrap.appendChild(bubble);
509
520
  wrap.appendChild(metaEl);
510
521
  }
511
522
 
512
- addToMessages(wrap);
513
- scheduledMsgEl = wrap;
514
- scrollToBottom();
515
-
516
- // Start countdown
517
- function updateCountdown() {
518
- var remaining = resetsAt - Date.now();
519
- if (remaining <= 0) {
520
- countdownEl.textContent = "Sending...";
521
- if (scheduledCountdownTimer) { clearInterval(scheduledCountdownTimer); scheduledCountdownTimer = null; }
522
- return;
523
- }
524
- var hrs = Math.floor(remaining / 3600000);
525
- var mins = Math.floor((remaining % 3600000) / 60000);
526
- var secs = Math.floor((remaining % 60000) / 1000);
527
- var timeStr = "";
528
- if (hrs > 0) timeStr += hrs + "h ";
529
- if (mins > 0 || hrs > 0) timeStr += mins + "m ";
530
- timeStr += secs + "s";
531
-
532
- var sendDate = new Date(resetsAt);
533
- var absTime = sendDate.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
534
- countdownEl.textContent = "Sends at " + absTime + " (" + timeStr + ")";
535
- }
536
- updateCountdown();
537
- scheduledCountdownTimer = setInterval(updateCountdown, 1000);
523
+ return { wrap: wrap, countdownEl: countdownEl };
538
524
  }
539
525
 
540
- // Clears the visible DOM bubble/countdown only — does not touch the
541
- // per-session persisted state. Used internally when re-rendering the bubble
542
- // for the same session (addScheduledMessageBubble) and by
543
- // clearScheduledMessage() below.
526
+ // Clears the visible DOM bubbles and their countdown only; the per-session
527
+ // list is untouched. Used when re-drawing for the same session and when the
528
+ // view moves to another project.
544
529
  export function removeScheduledMessageBubble() {
545
530
  if (scheduledMsgEl) {
546
531
  scheduledMsgEl.remove();
547
532
  scheduledMsgEl = null;
548
533
  }
534
+ scheduledCountdowns = [];
549
535
  if (scheduledCountdownTimer) {
550
536
  clearInterval(scheduledCountdownTimer);
551
537
  scheduledCountdownTimer = null;
552
538
  }
553
539
  }
554
540
 
555
- // lr-0827ba: clears both the persisted per-session scheduled-message state
556
- // and (if that session is currently focused) the visible bubble. sessionId
557
- // defaults to the currently active session for existing call sites that
558
- // don't yet carry a server-stamped localId (older history entries).
559
- export function clearScheduledMessage(sessionId) {
560
- var targetSessionId = sessionId != null ? sessionId : currentSessionId();
561
- clearScheduledMsg(targetSessionId);
562
- if (targetSessionId === currentSessionId()) removeScheduledMessageBubble();
563
- }
564
-
565
541
  export function handleFastModeState(state) {
566
542
  var statusArea = document.querySelector(".title-bar-content .status");
567
543
  if (!statusArea) return;
@@ -596,8 +572,8 @@ export function getScheduledMsgEl() { return scheduledMsgEl; }
596
572
  // which meant switching projects silently canceled the OUTGOING session's
597
573
  // rate-limit reset timer and armed schedule, exactly the bug this task
598
574
  // fixes. Reset timers and armed state are per-session now (rate-limit-state.js)
599
- // and must keep running in the background regardless of focus, mirroring
600
- // server-side session.scheduledMessage. This function now only tears down
575
+ // and must keep running in the background regardless of focus, mirroring the
576
+ // server's scheduled inputs. This function now only tears down
601
577
  // the visible DOM/UI-timer for whichever session was previously focused —
602
578
  // it does not touch any session's persisted arming state. Callers switching
603
579
  // into a different session must call restoreRateLimitStateForSession() for
@@ -630,13 +606,13 @@ export function forgetSessionRateLimitState(sessionId) {
630
606
  // the new session is focused (store.activeSessionId already updated).
631
607
  export function restoreRateLimitStateForSession(sessionId) {
632
608
  restoreScheduleDelayUi();
609
+ refreshScheduleControls();
633
610
  var resetsAt = getRateLimitResetsAt(sessionId);
634
611
  if (resetsAt && resetsAt > Date.now()) {
635
612
  updateRateLimitIndicator({ status: "rejected", resetsAt: resetsAt });
636
613
  startRateLimitCountdown(null, resetsAt, null);
637
614
  }
638
- var queued = getScheduledMsg(sessionId);
639
- if (queued && queued.resetsAt > Date.now()) {
640
- addScheduledMessageBubble(queued.text, queued.resetsAt, sessionId);
641
- }
615
+ renderScheduledBubbles(sessionId);
616
+ // The list held here may be older than the server's; ask for the current one.
617
+ requestScheduledInputList();
642
618
  }
@@ -8,6 +8,9 @@ import { escapeHtml, copyToClipboard } from './utils.js';
8
8
  import { renderMarkdown, renderMarkdownAsync, highlightCodeBlocks, renderMermaidBlocks } from './markdown.js';
9
9
  import { iconHtml, refreshIcons } from './icons.js';
10
10
  import { userAvatarUrl } from './avatar.js';
11
+ import { injectedSenderName, injectedLabel, injectedSessionNote } from './injected-label.js';
12
+ import { resolveInjectedIdentity } from './injected-identity.js';
13
+ import { getProjectAgents } from './at-agents.js';
11
14
  import { closeToolGroup } from './tools.js';
12
15
  import { showImageModal, showPasteModal } from './app-misc.js';
13
16
  import { sendMessage, hasSendableContent } from './input.js';
@@ -471,16 +474,20 @@ export function finalizeAssistantBlock() {
471
474
  }
472
475
  }
473
476
 
474
- export function addUserMessage(text, images, pastes, fromUserId, fromUserName) {
477
+ // injected (optional): { senderKind, fromName, initiator, contextNote } of a
478
+ // message another process sent into the session. It always renders through the
479
+ // other-sender path, never as the local user. All of its text is untrusted and
480
+ // is set with textContent.
481
+ export function addUserMessage(text, images, pastes, fromUserId, fromUserName, injected) {
475
482
  if (!text && (!images || images.length === 0) && (!pastes || pastes.length === 0)) return;
476
483
  var myUserId = store.get('myUserId');
477
484
  // Only treat as "other user" if we're in multi-user mode AND myUserId is
478
485
  // already known AND the message is from a different user. If myUserId is
479
486
  // null (init race — /api/me hasn't returned yet), assume the message is
480
487
  // from the local user to prevent avatar/name bleed-through in bubble view.
481
- var isOtherUser = myUserId && fromUserId && fromUserId !== myUserId;
488
+ var isOtherUser = injected ? true : (myUserId && fromUserId && fromUserId !== myUserId);
482
489
  var div = document.createElement("div");
483
- div.className = "msg-user" + (isOtherUser ? " msg-user-other" : "");
490
+ div.className = "msg-user" + (isOtherUser ? " msg-user-other" : "") + (injected ? " msg-user-injected" : "");
484
491
  div.dataset.turn = ++turnCounter;
485
492
  if (shouldGroupMessage("msg-user")) div.classList.add("grouped");
486
493
  var bubble = document.createElement("div");
@@ -541,7 +548,11 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName) {
541
548
  var cachedAllUsers = store.get('cachedAllUsers');
542
549
  var _targetUser;
543
550
  var _displayName;
544
- if (isOtherUser) {
551
+ var _injectedIdentity = null;
552
+ if (injected) {
553
+ _injectedIdentity = resolveInjectedIdentity(injected, fromUserId, getProjectAgents(), 36);
554
+ _displayName = _injectedIdentity.name;
555
+ } else if (isOtherUser) {
545
556
  _targetUser = cachedAllUsers.find(function (u) { return u.id === fromUserId; });
546
557
  _displayName = fromUserName || (_targetUser && (_targetUser.displayName || _targetUser.username)) || "User";
547
558
  } else {
@@ -557,7 +568,7 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName) {
557
568
 
558
569
  var avi = document.createElement("img");
559
570
  avi.className = "dm-bubble-avatar" + (isOtherUser ? " dm-bubble-avatar-other" : " dm-bubble-avatar-me");
560
- avi.src = isOtherUser
571
+ avi.src = _injectedIdentity ? _injectedIdentity.avatarUrl : isOtherUser
561
572
  ? userAvatarUrl(_targetUser || { id: fromUserId }, 36)
562
573
  : (document.body.dataset.myAvatarUrl || userAvatarUrl(_targetUser || { id: myUserId }, 36));
563
574
  div.appendChild(avi);
@@ -576,6 +587,25 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName) {
576
587
  timeSpan.textContent = getMsgTime();
577
588
  header.appendChild(timeSpan);
578
589
  contentWrap.appendChild(header);
590
+ if (injected) {
591
+ var labelEl = document.createElement("div");
592
+ labelEl.className = "injected-label";
593
+ labelEl.textContent = injectedLabel(injected);
594
+ contentWrap.appendChild(labelEl);
595
+ // The full sender session id: on hover (title) and on tap, which a phone has
596
+ // no hover for. Not part of the label itself.
597
+ var sessionNote = injectedSessionNote(injected);
598
+ if (sessionNote) {
599
+ nameSpan.title = sessionNote;
600
+ nameSpan.dataset.senderSession = injected.senderSessionId;
601
+ nameSpan.classList.add("dm-bubble-name-tappable");
602
+ nameSpan.addEventListener("click", function () {
603
+ var shown = labelEl.dataset.showSession === "1";
604
+ labelEl.dataset.showSession = shown ? "0" : "1";
605
+ labelEl.textContent = injectedLabel(injected) + (shown ? "" : " · " + sessionNote);
606
+ });
607
+ }
608
+ }
579
609
  contentWrap.appendChild(bubble);
580
610
  div.appendChild(contentWrap);
581
611
 
@@ -591,7 +621,8 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName) {
591
621
 
592
622
  actions.querySelector(".msg-action-copy").addEventListener("click", function () {
593
623
  var self = this;
594
- copyToClipboard(text || "");
624
+ // A copied injected message keeps its sender, so it cannot be pasted as the operator's words.
625
+ copyToClipboard(injected ? "[" + injectedSenderName(injected) + " · " + injectedLabel(injected) + "] " + (text || "") : (text || ""));
595
626
  self.innerHTML = iconHtml("check");
596
627
  refreshIcons(actions);
597
628
  setTimeout(function () { self.innerHTML = iconHtml("copy"); refreshIcons(actions); }, 1200);
@@ -0,0 +1,33 @@
1
+ // approve-tools-toggle.js - the "Approve tools automatically during this loop"
2
+ // choice, shown on a loop's settings (the task detail panel and the loop preview
3
+ // before it starts). On is the default and what every loop did before the
4
+ // choice existed; off makes the loop's tool calls ask like any other session's.
5
+ // The loop's questions and plan mode stay refused either way.
6
+
7
+ /** The settings card for the choice; `prefix` keeps the element ids apart. */
8
+ export function approveToolsCardHtml(prefix) {
9
+ return '<div class="settings-card"><div class="settings-field">' +
10
+ '<label class="settings-toggle-row">' +
11
+ '<div>' +
12
+ '<span class="settings-label">Approve tools automatically during this loop</span>' +
13
+ '<div class="settings-hint">On: the loop runs every tool without asking. Off: its tool calls ask first, like any session. The loop still cannot ask you questions or enter plan mode.</div>' +
14
+ '</div>' +
15
+ '<input type="checkbox" id="' + prefix + '-approve-tools">' +
16
+ '<span class="toggle-track"><span class="toggle-thumb"></span></span>' +
17
+ '</label>' +
18
+ '</div></div>';
19
+ }
20
+
21
+ /**
22
+ * Sets the checkbox from the record's value (absent means on) and reports a
23
+ * change as true or false.
24
+ * @param {string} prefix
25
+ * @param {*} value - the record's approveToolsAutomatically
26
+ * @param {function(boolean): void} onChange
27
+ */
28
+ export function bindApproveToolsToggle(prefix, value, onChange) {
29
+ var el = document.getElementById(prefix + "-approve-tools");
30
+ if (!el) return;
31
+ el.checked = value !== false;
32
+ el.onchange = function () { onChange(el.checked); };
33
+ }
@@ -92,6 +92,14 @@ export function handleProjectAgentsList(msg) {
92
92
  }
93
93
  }
94
94
 
95
+ // The project agents last sent by the server, for callers that need to match a
96
+ // name to a known agent identity (injected-message sender display).
97
+ export function getProjectAgents() {
98
+ return _agents.map(function (a) {
99
+ return { id: a.slug || a.name, name: a.name, agentName: a.name, slug: a.slug };
100
+ });
101
+ }
102
+
95
103
  // Show the dropdown at the position of the input element. Filter by query.
96
104
  // Called from input.js when @ is active.
97
105
  export function showAgentMenu(query) {