@clagentic/console 1.11.0 → 1.12.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 (99) hide show
  1. package/README.md +1 -0
  2. package/bin/cli.js +14 -2
  3. package/lib/build-changes.js +8 -2
  4. package/lib/build-sha.json +2 -2
  5. package/lib/build-update-offer.js +31 -7
  6. package/lib/claude-settings-env.js +142 -0
  7. package/lib/cli/arg-validation.js +1 -1
  8. package/lib/cli/duration.js +27 -0
  9. package/lib/cli/ipc-subcommands.js +26 -0
  10. package/lib/cli/schedule-input-subcommands.js +1 -22
  11. package/lib/cli/session-subcommands.js +38 -7
  12. package/lib/daemon.js +26 -0
  13. package/lib/notification-prefs.js +257 -0
  14. package/lib/notify/core.js +175 -0
  15. package/lib/notify/index.js +31 -0
  16. package/lib/notify/live-prompts.js +36 -0
  17. package/lib/notify/payload.js +63 -0
  18. package/lib/notify/target.js +5 -0
  19. package/lib/notify/type-registry.js +64 -0
  20. package/lib/notify/types.js +20 -0
  21. package/lib/open-sockets.js +27 -0
  22. package/lib/outbound-access.js +74 -0
  23. package/lib/outbound-entry.js +109 -0
  24. package/lib/outbound-ledger.js +306 -0
  25. package/lib/outbound-query.js +153 -0
  26. package/lib/pending-prompts.js +31 -16
  27. package/lib/project-connection.js +40 -1
  28. package/lib/project-filesystem.js +20 -5
  29. package/lib/project-http.js +9 -1
  30. package/lib/project-loop.js +25 -13
  31. package/lib/project-notifications.js +206 -42
  32. package/lib/project-prompt-responses.js +1 -1
  33. package/lib/project-sessions.js +30 -1
  34. package/lib/project.js +15 -1
  35. package/lib/prompt-registry.js +92 -24
  36. package/lib/prompt-reminders.js +282 -0
  37. package/lib/prompt-source.js +43 -8
  38. package/lib/public/app.js +1 -0
  39. package/lib/public/css/diagnostics.css +28 -0
  40. package/lib/public/css/home-hub.css +12 -0
  41. package/lib/public/css/icon-strip.css +9 -0
  42. package/lib/public/css/input.css +93 -0
  43. package/lib/public/css/menus.css +22 -0
  44. package/lib/public/css/mobile-nav.css +11 -0
  45. package/lib/public/css/server-settings.css +24 -0
  46. package/lib/public/css/sidebar.css +24 -0
  47. package/lib/public/index.html +6 -0
  48. package/lib/public/modules/activity-state.js +20 -4
  49. package/lib/public/modules/app-connection.js +22 -5
  50. package/lib/public/modules/app-header.js +2 -0
  51. package/lib/public/modules/app-messages.js +6 -2
  52. package/lib/public/modules/app-notifications.js +65 -40
  53. package/lib/public/modules/app-projects.js +3 -1
  54. package/lib/public/modules/app-rate-limit.js +12 -6
  55. package/lib/public/modules/app-rendering.js +26 -3
  56. package/lib/public/modules/build-update-sessions.js +81 -0
  57. package/lib/public/modules/collapsible-text.js +77 -0
  58. package/lib/public/modules/diagnostics.js +9 -2
  59. package/lib/public/modules/env-shadow-notice.js +34 -0
  60. package/lib/public/modules/keep-alive.js +66 -0
  61. package/lib/public/modules/notification-prefs.js +151 -0
  62. package/lib/public/modules/notify-client.js +153 -0
  63. package/lib/public/modules/project-settings.js +5 -0
  64. package/lib/public/modules/prompt-reminders-setting.js +13 -0
  65. package/lib/public/modules/prompt-state.js +3 -3
  66. package/lib/public/modules/prompts.js +1 -1
  67. package/lib/public/modules/server-settings.js +3 -0
  68. package/lib/public/modules/sidebar-mobile.js +8 -0
  69. package/lib/public/modules/sidebar-sessions.js +27 -0
  70. package/lib/public/modules/terminal-links.js +175 -0
  71. package/lib/public/modules/terminal.js +19 -103
  72. package/lib/public/notify-sw-logic.js +300 -0
  73. package/lib/public/notify-target.js +97 -0
  74. package/lib/public/sw.js +15 -62
  75. package/lib/push-audience.js +84 -0
  76. package/lib/push.js +87 -20
  77. package/lib/runtime-env.js +1 -0
  78. package/lib/sdk-bridge.js +83 -36
  79. package/lib/sdk-message-processor.js +148 -49
  80. package/lib/sender-ref.js +3 -0
  81. package/lib/server.js +80 -4
  82. package/lib/session-directory.js +6 -4
  83. package/lib/session-input-ipc.js +11 -1
  84. package/lib/session-input.js +95 -14
  85. package/lib/session-liveness.js +53 -0
  86. package/lib/session-reclaim.js +37 -2
  87. package/lib/sessions.js +58 -4
  88. package/lib/usage-store.js +403 -0
  89. package/lib/vendor-auth.js +33 -2
  90. package/lib/ws-schema.js +13 -2
  91. package/lib/yoke/adapters/claude-vendor.js +11 -1
  92. package/lib/yoke/adapters/claude.js +17 -0
  93. package/lib/yoke/adapters/codex.js +5 -1
  94. package/lib/yoke/auth-checks.js +17 -2
  95. package/lib/yoke/index.js +21 -3
  96. package/lib/yoke/provider-credentials.js +24 -0
  97. package/lib/yoke/registry.js +8 -1
  98. package/package.json +2 -2
  99. package/scripts/check-test-count.js +14 -0
@@ -25,6 +25,7 @@ var directory = require("./session-directory");
25
25
  var permissionSettings = require("./permission-settings");
26
26
  var { checkPermissionMode } = require("./permission-mode-policy");
27
27
  var { slugifyAgentName } = agentsModule;
28
+ var outboundEntry = require("./outbound-entry");
28
29
 
29
30
  // The result vocabulary reported to the caller. "error" is not a verdict on
30
31
  // the request: delivery was attempted and failed, so a caller may retry.
@@ -162,14 +163,23 @@ function logResult(verb, req, out) {
162
163
  console.log(line);
163
164
  }
164
165
 
165
- function logged(verb, fn) {
166
+ // after(verb, req, result), when given, runs once the line is logged. It must
167
+ // not throw into the caller: the result is already decided.
168
+ function logged(verb, fn, after) {
169
+ function finish(req, result) {
170
+ logResult(verb, req, result);
171
+ if (after) {
172
+ try { after(verb, req, result); }
173
+ catch (e) { console.error("[session-input] after-result hook failed:", messageOf(e)); }
174
+ }
175
+ return result;
176
+ }
166
177
  return function (req) {
167
178
  var out = fn(req);
168
179
  if (out && typeof out.then === "function") {
169
- return out.then(function (result) { logResult(verb, req, result); return result; });
180
+ return out.then(function (result) { return finish(req, result); });
170
181
  }
171
- logResult(verb, req, out);
172
- return out;
182
+ return finish(req, out);
173
183
  };
174
184
  }
175
185
 
@@ -183,9 +193,14 @@ function present(value) {
183
193
  // agentCatalog(project) -> [{ name }] named agents on offer (default: the picker's catalog)
184
194
  // getPermissionSettings() -> the server's permission settings (lib/permission-settings.js)
185
195
  // or null (default: the settings' defaults)
196
+ // outboundLedger -> { record(entry) } the sender-side ledger
197
+ // (lib/outbound-ledger.js); default: none kept
198
+ // now() -> ms clock for ledger entries (default Date.now)
186
199
  function createSessionInput(deps) {
187
200
  var getProject = deps.getProject;
188
201
  var listProjects = deps.listProjects || function () { return []; };
202
+ var outboundLedger = deps.outboundLedger || null;
203
+ var clock = deps.now || Date.now;
189
204
 
190
205
  function defaultAgentCatalog(project) {
191
206
  // Neither lookup throws: both answer [] when discovery has not run or the
@@ -333,10 +348,71 @@ function createSessionInput(deps) {
333
348
  return {};
334
349
  }
335
350
 
351
+ // The sender fields of a request. The reference a console-started caller holds
352
+ // is resolved in the daemon's own store; one it does not hold falls through to
353
+ // declared or undeclared.
354
+ function senderOf(req, initiator) {
355
+ var extracted = senderRef.resolve(getProject, { project: req.senderProject, sessionId: req.senderSessionId });
356
+ return senderFields(initiator, validateFrom(req.from).from, extracted, validateFromSession(req.fromSession).fromSession);
357
+ }
358
+
359
+ // Appends to the sender-side ledger. A ledger that cannot be written is
360
+ // logged by the ledger and never changes the answer to the request.
361
+ function writeLedger(entry) {
362
+ if (!outboundLedger) return;
363
+ try { outboundLedger.record(entry); }
364
+ catch (e) { console.error("[session-input] outbound ledger failed:", messageOf(e)); }
365
+ }
366
+
367
+ // The verb a result is logged under, as the ledger names it. Other verbs
368
+ // (listing, a scheduled firing) are not outbound calls of a sender.
369
+ var LEDGER_VERB = { open_session: outboundEntry.VERB.OPEN_SESSION, send_session_input: outboundEntry.VERB.SEND_INPUT };
370
+
371
+ // A delivery, recorded where the history entry is, so both carry the same
372
+ // message id and sender.
373
+ function ledgerDelivery(verb, project, session, req, initiator, messageId, sender) {
374
+ if (!outboundLedger) return;
375
+ // Building the entry reads the session and the project; none of it may
376
+ // throw into the delivery.
377
+ try {
378
+ var linuxUser = typeof project.getLinuxUserForSession === "function" ? project.getLinuxUserForSession(session) : null;
379
+ writeLedger(outboundEntry.buildEntry({
380
+ verb: verb,
381
+ ts: new Date(clock()).toISOString(),
382
+ req: req,
383
+ out: null,
384
+ initiator: initiator,
385
+ messageId: messageId,
386
+ sender: sender,
387
+ target: Object.assign({ project: req.projectSlug, runsAs: linuxUser || outboundEntry.RUNS_AS_DAEMON }, describe(project, session)),
388
+ }));
389
+ } catch (e) {
390
+ console.error("[session-input] outbound ledger entry failed:", messageOf(e));
391
+ }
392
+ }
393
+
394
+ // A request that was not delivered (refused, not found, ambiguous, failed).
395
+ // A delivery already left its entry in recordInjected.
396
+ function ledgerOutcome(verb, req, out) {
397
+ if (!outboundLedger || !LEDGER_VERB[verb] || !out || out.ok === true) return;
398
+ req = req || {};
399
+ var init = resolveInitiator(req.initiator);
400
+ var initiator = init.initiator || null;
401
+ writeLedger(outboundEntry.buildEntry({
402
+ verb: LEDGER_VERB[verb],
403
+ ts: new Date(clock()).toISOString(),
404
+ req: req,
405
+ out: out,
406
+ initiator: initiator,
407
+ sender: senderOf(req, initiator),
408
+ target: { project: req.projectSlug, consoleSessionId: out.consoleSessionId, sessionId: out.sessionId, agent: out.agent, vendor: out.vendor, name: out.name },
409
+ }));
410
+ }
411
+
336
412
  // History entry that marks the turn as injected, not typed. The input is
337
413
  // already delivered when this runs, so a failure to record is logged and does
338
414
  // not turn a delivered turn into an error a caller would retry.
339
- function recordInjected(project, session, req, initiator, messageId) {
415
+ function recordInjected(verb, project, session, req, initiator, messageId) {
340
416
  var entry;
341
417
  if (req.automation) {
342
418
  // A turn the console composed itself (fireScheduled): the console is the
@@ -353,11 +429,9 @@ function createSessionInput(deps) {
353
429
  });
354
430
  if (req.triggerId) entry.triggerId = req.triggerId;
355
431
  if (req.contextNote) entry.contextNote = req.contextNote;
356
- // The reference a console-started caller holds, resolved in the daemon's own
357
- // store; one it does not hold falls through to declared or undeclared.
358
- var extracted = senderRef.resolve(getProject, { project: req.senderProject, sessionId: req.senderSessionId });
359
- var sender = senderFields(initiator, validateFrom(req.from).from, extracted, validateFromSession(req.fromSession).fromSession);
432
+ var sender = senderOf(req, initiator);
360
433
  for (var k in sender) entry[k] = sender[k];
434
+ ledgerDelivery(verb, project, session, req, initiator, messageId, sender);
361
435
  }
362
436
  try {
363
437
  project.sm.recordHistoryEntry(session, entry, true);
@@ -420,7 +494,7 @@ function createSessionInput(deps) {
420
494
  var messageId = newMessageId();
421
495
 
422
496
  function delivered() {
423
- recordInjected(project, session, req, initiator, messageId);
497
+ recordInjected(outboundEntry.VERB.SEND_INPUT, project, session, req, initiator, messageId);
424
498
  if (req.automation && !processing) announceStartedTurn(project, session);
425
499
  var out = describe(project, session);
426
500
  out.ok = true;
@@ -703,7 +777,14 @@ function createSessionInput(deps) {
703
777
  // createSession emits already carries it (not the project default). It is
704
778
  // saved with the session just below: a follow-up from a person, a resume
705
779
  // and a restart all keep it.
706
- var sess = sm.createSession(Object.assign({}, kind.options, { permissionMode: openMode.mode }));
780
+ // A session opened from a console session the daemon identified belongs to
781
+ // that session's owner, so its prompts push to a person who can read it. A
782
+ // declared or undeclared sender is a claim, never an inheritance.
783
+ var openedBy = senderRef.resolve(getProject, { project: req.senderProject, sessionId: req.senderSessionId });
784
+ // activate:false: an opened session is listed but never moves a connected tab.
785
+ var created = Object.assign({}, kind.options, { permissionMode: openMode.mode, activate: false });
786
+ if (openedBy && openedBy.ownerId) created.ownerId = openedBy.ownerId;
787
+ var sess = sm.createSession(created);
707
788
  var label = req.triggerId ? " — " + String(req.triggerId).substring(0, 12) : "";
708
789
  sess.title = (req.contextNote || "External trigger") + label;
709
790
  if (req.cwd) sess.cwd = req.cwd;
@@ -726,7 +807,7 @@ function createSessionInput(deps) {
726
807
  }, function () {
727
808
  // Recorded once, only now that the query has started: a rejected start
728
809
  // leaves no history entry for a prompt that never ran.
729
- recordInjected(project, sess, req, init.initiator, openedMessageId);
810
+ recordInjected(outboundEntry.VERB.OPEN_SESSION, project, sess, req, init.initiator, openedMessageId);
730
811
  // A name has one holder: the claim took effect in memory at open (the new
731
812
  // session is non-reaped and wins over its reaped twins meanwhile), and
732
813
  // only now, with the start done, is it taken from the reaped sessions
@@ -758,8 +839,8 @@ function createSessionInput(deps) {
758
839
  }
759
840
 
760
841
  return {
761
- openSession: logged("open_session", neverThrows(openSession)),
762
- sendInput: logged("send_session_input", neverThrows(sendInput)),
842
+ openSession: logged("open_session", neverThrows(openSession), ledgerOutcome),
843
+ sendInput: logged("send_session_input", neverThrows(sendInput), ledgerOutcome),
763
844
  listSessions: logged("list_sessions", neverThrows(listSessions)),
764
845
  fireScheduled: logged("fire_scheduled_input", neverThrows(fireScheduled)),
765
846
  };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ // session-liveness.js - the one daemon-side derivation of what a session is
4
+ // doing, read by every surface that shows it: the build-update confirm card,
5
+ // the session list served to the client (picker dots, sidebar), and
6
+ // list-sessions.
7
+ //
8
+ // Inputs are the three facts a session holds: whether a runtime is attached,
9
+ // whether a turn is running, and whether an operator prompt is pending.
10
+ //
11
+ // reaped no runtime (idle reaper, daemon restart); input resumes it
12
+ // waiting a runtime is attached and at least one operator prompt is
13
+ // pending: a turn or runtime is blocked on the operator
14
+ // running a runtime is attached, a turn is running, nothing is pending
15
+ // idle a runtime is attached, nothing running, nothing pending
16
+ //
17
+ // A pending prompt outranks a running turn: a turn stopped on a prompt is
18
+ // not progressing, and "running" would hide that the operator is the one
19
+ // being waited on. A prompt on a session with no runtime is not waited on by
20
+ // anything (nothing can use the answer), so that session is reaped; its
21
+ // prompt stays visible in list-sessions pendingPrompts.
22
+ //
23
+ // list-sessions keeps its three-valued `state` (live | idle | reaped); a
24
+ // waiting session is live there. liveStateOf() is that projection.
25
+
26
+ var senderRef = require("./sender-ref");
27
+ var { countPending } = require("./pending-prompts");
28
+
29
+ var ACTIVITY = Object.freeze({ REAPED: "reaped", IDLE: "idle", RUNNING: "running", WAITING: "waiting" });
30
+
31
+ // facts: { attached, turnRunning, pendingCount }
32
+ function derive(facts) {
33
+ if (!facts.attached) return ACTIVITY.REAPED;
34
+ if (facts.pendingCount > 0) return ACTIVITY.WAITING;
35
+ return facts.turnRunning ? ACTIVITY.RUNNING : ACTIVITY.IDLE;
36
+ }
37
+
38
+ // The activity of a session object held by a project's session manager.
39
+ function activityOf(session) {
40
+ return derive({
41
+ attached: senderRef.isLive(session),
42
+ turnRunning: !!session.isProcessing,
43
+ pendingCount: countPending(session),
44
+ });
45
+ }
46
+
47
+ // list-sessions' `state`: waiting and running are both "live".
48
+ function liveStateOf(activity) {
49
+ if (activity === ACTIVITY.REAPED) return "reaped";
50
+ return activity === ACTIVITY.IDLE ? "idle" : "live";
51
+ }
52
+
53
+ module.exports = { ACTIVITY: ACTIVITY, derive: derive, activityOf: activityOf, liveStateOf: liveStateOf };
@@ -7,6 +7,8 @@
7
7
  // announceLiveAgentReclaim: the agents are named, the session is marked as
8
8
  // expected to resume, and both UI surfaces are told.
9
9
 
10
+ var sessionActivity = require("./session-activity");
11
+
10
12
  var LABEL_MAX = 80;
11
13
  var FALLBACK_LABEL = "background agent";
12
14
 
@@ -42,9 +44,16 @@ function noteTaskLabel(session, taskId, input) {
42
44
  * answer instead of guessing at the end event.
43
45
  */
44
46
  function pruneTaskLabels(session) {
45
- var table = session && session.taskLabels;
46
- if (!table) return;
47
+ if (!session) return;
47
48
  var tracked = session.activeTaskToolIds || {};
49
+ var marks = session.backgroundTaskIds;
50
+ if (marks) {
51
+ Object.keys(marks).forEach(function (id) {
52
+ if (!Object.prototype.hasOwnProperty.call(tracked, id) || !tracked[id]) delete marks[id];
53
+ });
54
+ }
55
+ var table = session.taskLabels;
56
+ if (!table) return;
48
57
  Object.keys(table).forEach(function (id) {
49
58
  if (!Object.prototype.hasOwnProperty.call(tracked, id) || !tracked[id]) delete table[id];
50
59
  });
@@ -68,6 +77,30 @@ function liveAgentTasks(session) {
68
77
  });
69
78
  }
70
79
 
80
+ /** Record that a tracked Task was acknowledged as launched in the background. */
81
+ function noteBackgroundLaunch(session, taskId) {
82
+ if (typeof taskId !== "string" || !taskId) return;
83
+ if (!session.backgroundTaskIds) session.backgroundTaskIds = Object.create(null);
84
+ session.backgroundTaskIds[taskId] = true;
85
+ }
86
+
87
+ /**
88
+ * True when the session is busy only because tracked background agents hold
89
+ * activity tokens: no tool call, thinking block or other live work of its own.
90
+ * The idle reaper reads this so a session waiting on silent agents stays
91
+ * reapable (and announced) instead of looking like a running turn.
92
+ */
93
+ function onlyBackgroundAgentsActive(session) {
94
+ var tracked = session && session.activeTaskToolIds;
95
+ var marks = session && session.backgroundTaskIds;
96
+ if (!tracked || !marks) return false;
97
+ var has = Object.prototype.hasOwnProperty;
98
+ var sources = sessionActivity.listActiveSources(session);
99
+ return sources.length > 0 && sources.every(function (s) {
100
+ return has.call(tracked, s.token) && !!tracked[s.token] && has.call(marks, s.token);
101
+ });
102
+ }
103
+
71
104
  /** Operator-facing names of every Task the session still tracks. */
72
105
  function liveAgentLabels(session) {
73
106
  return liveAgentTasks(session).map(function (t) { return t.label; });
@@ -276,6 +309,8 @@ module.exports = {
276
309
  surfaceRestartReclaims: surfaceRestartReclaims,
277
310
  restartDiagnostics: restartDiagnostics,
278
311
  noteTaskLabel: noteTaskLabel,
312
+ noteBackgroundLaunch: noteBackgroundLaunch,
313
+ onlyBackgroundAgentsActive: onlyBackgroundAgentsActive,
279
314
  pruneTaskLabels: pruneTaskLabels,
280
315
  liveAgentLabels: liveAgentLabels,
281
316
  liveAgentTasks: liveAgentTasks,
package/lib/sessions.js CHANGED
@@ -7,8 +7,10 @@ var users = require("./users");
7
7
  var { CODEX_DEFAULTS } = require("./codex-defaults");
8
8
  var { isVisibleHistoryEvent } = require("./history-visibility");
9
9
  var { createPromptRegistry } = require("./prompt-registry");
10
+ var promptSource = require("./prompt-source");
10
11
  var { registerExitFlush } = require("./exit-flush");
11
12
  var sessionReclaim = require("./session-reclaim");
13
+ var sessionLiveness = require("./session-liveness");
12
14
  var sessionFileScan = require("./session-file-scan");
13
15
  var { findNameHolder } = require("./session-name-holder");
14
16
  var { createSenderRecorder } = require("./message-sender-record");
@@ -123,15 +125,30 @@ function createSessionManager(opts) {
123
125
  // Sole writer of every session's operator-prompt state; see
124
126
  // lib/prompt-registry.js. Built before any session exists because
125
127
  // construction itself may create and switch to one.
128
+ // A prompt opening or settling changes what the session list shows (the
129
+ // waiting indicator), and nothing else broadcasts the list for it. Coalesced
130
+ // to one broadcast per tick: a cancelled turn can settle several at once.
131
+ var listBroadcastQueued = false;
132
+ var managerDestroyed = false;
133
+ function onPromptsChanged() {
134
+ if (typeof opts.onProcessingChanged === "function") opts.onProcessingChanged();
135
+ if (listBroadcastQueued || managerDestroyed || (!send && !sendEach)) return;
136
+ listBroadcastQueued = true;
137
+ setImmediate(function () {
138
+ listBroadcastQueued = false;
139
+ if (!managerDestroyed) broadcastSessionList();
140
+ });
141
+ }
126
142
  var prompts = createPromptRegistry({
127
143
  index: permissionRequestIndex,
128
144
  getSession: function (localId) { return sessions.get(localId) || null; },
129
145
  sendAndRecord: function (session, obj) { return doSendAndRecord(session, obj); },
130
146
  saveSessionFile: function (session) { return saveSessionFile(session); },
131
147
  getNotificationsModule: opts.getNotificationsModule,
132
- onProcessingChanged: opts.onProcessingChanged,
148
+ onProcessingChanged: onPromptsChanged,
133
149
  getProjectName: opts.getProjectName,
134
150
  getProjectSlug: opts.getProjectSlug,
151
+ getPushModule: opts.getPushModule,
135
152
  });
136
153
  var capabilitiesByVendor = null; // set by sdk-bridge after adapter init
137
154
  var defaultVendor = null; // set by sdk-bridge
@@ -163,6 +180,13 @@ function createSessionManager(opts) {
163
180
  if (session.vendor) metaObj.vendor = session.vendor;
164
181
  if (session.sessionVisibility) metaObj.sessionVisibility = session.sessionVisibility;
165
182
  if (session.bookmarked) metaObj.bookmarked = true;
183
+ // Operator-set keep-alive: the idle reaper skips the session (see
184
+ // startIdleReaper in lib/sdk-bridge.js). Written only when on, so a
185
+ // session that was never pinned carries no field.
186
+ if (session.keepAlive) metaObj.keepAlive = true;
187
+ // Operator switch: no reminders for this session's unanswered prompts
188
+ // (lib/prompt-reminders.js). Written only when off.
189
+ if (session.promptRemindersOff) metaObj.promptRemindersOff = true;
166
190
  if (typeof session.favoriteOrder === "number") metaObj.favoriteOrder = session.favoriteOrder;
167
191
  if (session.lastRewindUuid) metaObj.lastRewindUuid = session.lastRewindUuid;
168
192
  if (session.agentName) metaObj.agentName = session.agentName;
@@ -814,6 +838,8 @@ function createSessionManager(opts) {
814
838
  if (m.ownerId) session.ownerId = m.ownerId;
815
839
  session.sessionVisibility = m.sessionVisibility || "shared";
816
840
  session.bookmarked = !!m.bookmarked;
841
+ session.keepAlive = m.keepAlive === true;
842
+ session.promptRemindersOff = m.promptRemindersOff === true;
817
843
  session.favoriteOrder = typeof m.favoriteOrder === "number" ? m.favoriteOrder : null;
818
844
  // lr-f36626: restore the durable AUTO-RESUME marker across a daemon
819
845
  // restart — see buildMetaLine's write side for why this must persist.
@@ -880,11 +906,14 @@ function createSessionManager(opts) {
880
906
  title: s.title || "New Session",
881
907
  active: isActive,
882
908
  isProcessing: s.isProcessing,
909
+ waiting: sessionLiveness.activityOf(s) === sessionLiveness.ACTIVITY.WAITING,
883
910
  lastActivity: s.lastActivity || s.createdAt || 0,
884
911
  loop: loop,
885
912
  ownerId: s.ownerId || null,
886
913
  sessionVisibility: s.sessionVisibility || "shared",
887
914
  bookmarked: !!s.bookmarked,
915
+ keepAlive: !!s.keepAlive,
916
+ promptRemindersOff: !!s.promptRemindersOff,
888
917
  favoriteOrder: typeof s.favoriteOrder === "number" ? s.favoriteOrder : null,
889
918
  unread: unreadMap[s.localId] || 0,
890
919
  vendor: s.vendor || null,
@@ -979,7 +1008,15 @@ function createSessionManager(opts) {
979
1008
  };
980
1009
  giveStartingMode(session, sessionOpts);
981
1010
  sessions.set(localId, session);
982
- switchSession(localId, targetWs);
1011
+ // activate:false has the meaning it has in resumeSession: the session is
1012
+ // created and listed, but no client's active session (and not
1013
+ // activeSessionId) changes. For an IPC-opened session nobody asked to look
1014
+ // at: switching would move every connected tab off the session it is on.
1015
+ if (sessionOpts && sessionOpts.activate === false) {
1016
+ broadcastSessionList();
1017
+ } else {
1018
+ switchSession(localId, targetWs);
1019
+ }
983
1020
  return session;
984
1021
  }
985
1022
 
@@ -1270,7 +1307,7 @@ function createSessionManager(opts) {
1270
1307
  cleanupMentionSessions(session);
1271
1308
  // Settled before the abort below so no abort listener records an event
1272
1309
  // into a history that is about to be deleted.
1273
- prompts.cancelSession(session, "session_deleted", { record: false });
1310
+ prompts.cancelSession(session, "session_deleted", { record: false, source: promptSource.CANCEL.SESSION_END });
1274
1311
 
1275
1312
  if (session.abortController) {
1276
1313
  try { session.abortController.abort(); } catch(e) {}
@@ -1319,7 +1356,7 @@ function createSessionManager(opts) {
1319
1356
  _lruRemove(localId);
1320
1357
 
1321
1358
  cleanupMentionSessions(session);
1322
- prompts.cancelSession(session, "session_deleted", { record: false });
1359
+ prompts.cancelSession(session, "session_deleted", { record: false, source: promptSource.CANCEL.SESSION_END });
1323
1360
  if (session.abortController) {
1324
1361
  try { session.abortController.abort(); } catch(e) {}
1325
1362
  }
@@ -1890,6 +1927,22 @@ function createSessionManager(opts) {
1890
1927
  broadcastSessionList();
1891
1928
  return { ok: true };
1892
1929
  },
1930
+ setSessionKeepAlive: function (localId, keepAlive) {
1931
+ var session = sessions.get(localId);
1932
+ if (!session) return { error: "Session not found" };
1933
+ session.keepAlive = !!keepAlive;
1934
+ saveSessionFile(session);
1935
+ broadcastSessionList();
1936
+ return { ok: true };
1937
+ },
1938
+ setSessionPromptReminders: function (localId, enabled) {
1939
+ var session = sessions.get(localId);
1940
+ if (!session) return { error: "Session not found" };
1941
+ session.promptRemindersOff = !enabled;
1942
+ saveSessionFile(session);
1943
+ broadcastSessionList();
1944
+ return { ok: true };
1945
+ },
1893
1946
  reorderBookmarkedSessions: function (sourceId, targetId, insertBefore) {
1894
1947
  var source = sessions.get(sourceId);
1895
1948
  var target = sessions.get(targetId);
@@ -1950,6 +2003,7 @@ function createSessionManager(opts) {
1950
2003
  // outcome is flushed to disk; then the exit flusher registered above is
1951
2004
  // unregistered so nothing accumulates across project open/close cycles.
1952
2005
  destroy: function() {
2006
+ managerDestroyed = true;
1953
2007
  prompts.shutdown();
1954
2008
  _onProcessExit();
1955
2009
  unregisterExitFlush();