@clagentic/console 1.12.0-beta.2 → 1.12.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/LICENSES/README.md +5 -0
  2. package/bin/cli.js +4 -2
  3. package/lib/agent-roster-ws.js +84 -0
  4. package/lib/agent-roster.js +312 -0
  5. package/lib/auth-required-notify.js +42 -0
  6. package/lib/build-sha.json +2 -2
  7. package/lib/build-update-notify.js +45 -0
  8. package/lib/build-update-offer.js +3 -4
  9. package/lib/build-update-standing.js +34 -14
  10. package/lib/cli/session-subcommands.js +26 -8
  11. package/lib/client-address.js +44 -0
  12. package/lib/daemon.js +25 -10
  13. package/lib/idle-compaction-setting.js +203 -0
  14. package/lib/mcp-bridge-credential.js +41 -0
  15. package/lib/notification-prefs.js +16 -22
  16. package/lib/notify/core.js +53 -18
  17. package/lib/notify/payload.js +2 -3
  18. package/lib/notify/type-registry.js +17 -0
  19. package/lib/notify/types.js +38 -1
  20. package/lib/outbound-access.js +12 -1
  21. package/lib/outbound-entry.js +8 -1
  22. package/lib/project-connection.js +9 -8
  23. package/lib/project-filesystem.js +23 -0
  24. package/lib/project-loop.js +16 -19
  25. package/lib/project-notifications.js +68 -7
  26. package/lib/project-sessions.js +9 -0
  27. package/lib/project-user-mention.js +22 -34
  28. package/lib/project-user-message.js +208 -4
  29. package/lib/project-user-shell.js +298 -0
  30. package/lib/project.js +26 -4
  31. package/lib/prompt-answer.js +145 -0
  32. package/lib/prompt-expiry.js +50 -0
  33. package/lib/prompt-registry.js +24 -1
  34. package/lib/prompt-source.js +16 -0
  35. package/lib/public/app.js +31 -2
  36. package/lib/public/css/agent-messages.css +96 -0
  37. package/lib/public/css/agent-roster.css +93 -0
  38. package/lib/public/css/diagnostics.css +1 -1
  39. package/lib/public/css/input.css +20 -141
  40. package/lib/public/css/login-panel.css +73 -0
  41. package/lib/public/css/menus.css +2 -2
  42. package/lib/public/css/sidebar.css +11 -0
  43. package/lib/public/css/team-panel.css +1 -6
  44. package/lib/public/css/team-view.css +101 -0
  45. package/lib/public/css/title-bar.css +10 -0
  46. package/lib/public/css/user-shell.css +144 -0
  47. package/lib/public/index.html +41 -7
  48. package/lib/public/modules/agent-avatar-picker.js +162 -0
  49. package/lib/public/modules/agent-avatar.js +153 -0
  50. package/lib/public/modules/agent-messages.js +285 -0
  51. package/lib/public/modules/agent-roster.js +157 -0
  52. package/lib/public/modules/app-connection.js +12 -0
  53. package/lib/public/modules/app-messages.js +55 -16
  54. package/lib/public/modules/app-notifications.js +59 -29
  55. package/lib/public/modules/app-panels.js +26 -3
  56. package/lib/public/modules/app-rate-limit.js +8 -165
  57. package/lib/public/modules/app-rendering.js +22 -7
  58. package/lib/public/modules/collapsible-text.js +33 -18
  59. package/lib/public/modules/compaction-state.js +34 -0
  60. package/lib/public/modules/custom-icons.js +23 -5
  61. package/lib/public/modules/diagnostics.js +52 -55
  62. package/lib/public/modules/injected-identity.js +24 -21
  63. package/lib/public/modules/input.js +176 -15
  64. package/lib/public/modules/login-panel.js +136 -0
  65. package/lib/public/modules/login-parser.js +73 -0
  66. package/lib/public/modules/login-tab.js +66 -0
  67. package/lib/public/modules/notifications.js +9 -1
  68. package/lib/public/modules/notify-client.js +114 -21
  69. package/lib/public/modules/pending-term-request.js +30 -0
  70. package/lib/public/modules/project-icon.js +22 -2
  71. package/lib/public/modules/queued-button.js +11 -0
  72. package/lib/public/modules/scheduled-input-actions.js +12 -4
  73. package/lib/public/modules/scheduled-outbox.js +230 -0
  74. package/lib/public/modules/send-now.js +200 -0
  75. package/lib/public/modules/server-settings.js +47 -1
  76. package/lib/public/modules/shell-card.js +76 -0
  77. package/lib/public/modules/shell-line.js +49 -0
  78. package/lib/public/modules/shell-queue.js +253 -0
  79. package/lib/public/modules/shell-settings-controls.js +76 -0
  80. package/lib/public/modules/sidebar-mobile.js +3 -3
  81. package/lib/public/modules/sidebar-sessions.js +8 -0
  82. package/lib/public/modules/sidebar-users.js +5 -7
  83. package/lib/public/modules/team-panel.js +30 -88
  84. package/lib/public/modules/team-view.js +211 -0
  85. package/lib/public/modules/terminal-links.js +18 -0
  86. package/lib/public/modules/terminal.js +65 -4
  87. package/lib/public/modules/tools.js +19 -0
  88. package/lib/public/modules/user-shell.js +824 -0
  89. package/lib/public/notify-sw-logic.js +35 -83
  90. package/lib/public/notify-target.js +70 -10
  91. package/lib/public/style.css +5 -0
  92. package/lib/public/sw.js +7 -3
  93. package/lib/queued-chat.js +392 -0
  94. package/lib/scheduled-input/ws.js +67 -9
  95. package/lib/sdk-bridge.js +122 -43
  96. package/lib/sdk-message-processor.js +46 -39
  97. package/lib/server-auth.js +6 -4
  98. package/lib/server-dm.js +11 -20
  99. package/lib/server-settings.js +39 -1
  100. package/lib/server.js +83 -19
  101. package/lib/session-directory.js +33 -8
  102. package/lib/session-end.js +97 -0
  103. package/lib/session-input-ipc.js +26 -0
  104. package/lib/session-input.js +176 -9
  105. package/lib/session-resume.js +1 -0
  106. package/lib/session-settings-file.js +53 -0
  107. package/lib/sessions.js +49 -5
  108. package/lib/team-traffic-ws.js +68 -0
  109. package/lib/team-traffic.js +318 -0
  110. package/lib/usage-store.js +7 -0
  111. package/lib/user-shell-settings.js +105 -0
  112. package/lib/ws-schema.js +27 -4
  113. package/lib/yoke/adapters/claude-capabilities.js +2 -0
  114. package/lib/yoke/adapters/claude-vendor.js +6 -0
  115. package/lib/yoke/adapters/claude-worker.js +39 -11
  116. package/lib/yoke/adapters/claude.js +218 -6
  117. package/lib/yoke/adapters/codex-capabilities.js +6 -1
  118. package/lib/yoke/adapters/codex-user-shell.js +265 -0
  119. package/lib/yoke/adapters/codex-vendor.js +7 -0
  120. package/lib/yoke/adapters/codex.js +186 -52
  121. package/lib/yoke/codex-app-server.js +8 -2
  122. package/lib/yoke/interface.js +54 -1
  123. package/lib/yoke/mcp-bridge-server.js +12 -8
  124. package/lib/yoke/registry.js +32 -0
  125. package/lib/yoke/user-shell.js +224 -0
  126. package/package.json +1 -1
  127. package/lib/public/modules/build-notice-gate.js +0 -73
package/lib/project.js CHANGED
@@ -32,6 +32,7 @@ var { savedModeOrDefault } = require("./permission-mode-policy");
32
32
  var { logField } = require("./log-field");
33
33
  var { attachSessions } = require("./project-sessions");
34
34
  var { attachUserMessage } = require("./project-user-message");
35
+ var { attachUserShell } = require("./project-user-shell");
35
36
  var { attachConnection } = require("./project-connection");
36
37
  var { detectLite } = require("./lite-detect");
37
38
  var { attachMcp } = require("./project-mcp");
@@ -155,7 +156,6 @@ function createProjectContext(opts) {
155
156
  var onCreateWorktree = opts.onCreateWorktree || null;
156
157
  var serverPort = opts.port || 2633;
157
158
  var serverTls = opts.tls || false;
158
- var serverAuthToken = opts.authToken || null;
159
159
  // lr-2ea2a7: daemon.json knob overriding the in-heap session-history tail
160
160
  // cap (default HISTORY_INMEM_MAX_DEFAULT=1000 in lib/sessions.js).
161
161
  var historyInMemMax = opts.historyInMemMax;
@@ -616,11 +616,11 @@ function createProjectContext(opts) {
616
616
  getRemoteMcpServers: function () { return _mcp.getMcpServers(); },
617
617
  clayPort: serverPort,
618
618
  clayTls: serverTls,
619
- clayAuthToken: serverAuthToken,
620
619
  onProcessingChanged: onProcessingChanged,
621
620
  onTurnDone: null,
622
621
  onTeamCreate: function (teamId, cliSessionId, cwd) { _team.onTeamCreate(teamId, cliSessionId, cwd); },
623
622
  onTeamDelete: function () { _team.onTeamDelete(); },
623
+ onAgentSeen: opts.onAgentSeen || null,
624
624
  scheduleRateLimitResume: function (session, resetsAt) { rateLimitResume.schedule(session, resetsAt); },
625
625
  hasRateLimitResume: function (session) { return rateLimitResume.has(session); },
626
626
  getAutoContinueSetting: function (session) {
@@ -733,6 +733,8 @@ function createProjectContext(opts) {
733
733
  // agent's alike; this project only hands it the rate-limit resume. A context
734
734
  // built without one (unit harnesses) schedules nothing.
735
735
  var scheduledInput = opts.scheduledInput || null;
736
+ // The Team view's agent-messages query (lib/team-traffic.js); null in a bare harness.
737
+ var teamTraffic = opts.teamTraffic || null;
736
738
 
737
739
  // The automatic "continue" after a rate limit: one once record on the session,
738
740
  // timed after the limit resets. This is the only caller that adds the
@@ -800,7 +802,6 @@ function createProjectContext(opts) {
800
802
  osUsers: osUsers,
801
803
  clayPort: serverPort,
802
804
  clayTls: serverTls,
803
- clayAuthToken: serverAuthToken,
804
805
  slug: slug,
805
806
  runtimeEnv: sdk.getRuntimeEnvOverlay(),
806
807
  }, recordInit);
@@ -809,7 +810,6 @@ function createProjectContext(opts) {
809
810
  cwd: cwd,
810
811
  clayPort: serverPort,
811
812
  clayTls: serverTls,
812
- clayAuthToken: serverAuthToken,
813
813
  slug: slug,
814
814
  runtimeEnv: sdk.getRuntimeEnvOverlay(),
815
815
  }));
@@ -856,6 +856,9 @@ function createProjectContext(opts) {
856
856
  // --- Notifications (delegated to project-notifications.js) ---
857
857
  if (_notifications.handleNotificationMessage(ws, msg)) return;
858
858
 
859
+ // --- The ! command line (delegated to project-user-shell.js) ---
860
+ if (_userShell.handleUserShellMessage(ws, msg)) return;
861
+
859
862
  // --- Sessions, config, project mgmt (delegated to project-sessions.js) ---
860
863
  if (_sessions.handleSessionsMessage(ws, msg)) return;
861
864
 
@@ -1014,6 +1017,8 @@ function createProjectContext(opts) {
1014
1017
  sendExtensionCommandAny: sendExtensionCommandAny,
1015
1018
  requestTabContext: requestTabContext,
1016
1019
  scheduledInput: scheduledInput,
1020
+ teamTraffic: teamTraffic,
1021
+ agentRoster: opts.agentRoster || null,
1017
1022
  loadContextSources: loadContextSources,
1018
1023
  saveContextSources: saveContextSources,
1019
1024
  escapeRegex: escapeRegex,
@@ -1022,6 +1027,21 @@ function createProjectContext(opts) {
1022
1027
  getProjectOwnerId: function () { return projectOwnerId; },
1023
1028
  });
1024
1029
 
1030
+ // --- The ! command line (delegated to project-user-shell.js) ---
1031
+ var _userShell = attachUserShell({
1032
+ slug: slug,
1033
+ cwd: cwd,
1034
+ osUsers: osUsers,
1035
+ sm: sm,
1036
+ sdk: sdk,
1037
+ send: send,
1038
+ sendTo: sendTo,
1039
+ usersModule: usersModule,
1040
+ projectAccess: projectAccess,
1041
+ opts: opts,
1042
+ getSessionForWs: getSessionForWs,
1043
+ });
1044
+
1025
1045
  // --- Filesystem handler (delegated to project-filesystem.js) ---
1026
1046
  var _filesystem = attachFilesystem({
1027
1047
  cwd: cwd,
@@ -1413,6 +1433,8 @@ function createProjectContext(opts) {
1413
1433
  // The shared mode check for a session on its vendor, for a caller outside
1414
1434
  // the WebSocket handlers (session-input.js, which opens sessions).
1415
1435
  checkPermissionModeFor: function (session, mode) { return sdk.checkModeFor(session, mode, true); },
1436
+ // Whether the session's vendor takes an additive settings file.
1437
+ supportsSettingsFileFor: function (session) { return sdk.supportsSettingsFile(session); },
1416
1438
  // Ends the adapters' runtimes that nothing is using (see idle-adapter-reaper.js).
1417
1439
  reclaimIdleAdapters: function (idleMs) {
1418
1440
  return reclaimIdleAdapters(adapters, idleMs);
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+
3
+ // prompt-answer.js - answers one pending operator prompt for the answer-prompt
4
+ // verb. The answer goes through the prompt registry's respond(), the call a
5
+ // browser answer takes, so the kind validates it, the resolution effects run
6
+ // and the settle is recorded with its source; this module only finds the
7
+ // prompt and shapes the decision into the message the browser would have sent
8
+ // for that kind.
9
+ //
10
+ // Exactly once is the registry's: respond() settles a prompt or reports it
11
+ // stale, and it runs without yielding, so a browser answer and this one cannot
12
+ // both win.
13
+
14
+ var { promptsFor } = require("./prompt-registry");
15
+ var promptKinds = require("./prompt-kinds");
16
+ var codecs = require("./prompt-kinds/codecs");
17
+
18
+ var RESULT = Object.freeze({
19
+ ANSWERED: "answered",
20
+ NOT_FOUND: "not-found",
21
+ ALREADY_SETTLED: "already-settled",
22
+ INVALID: "invalid",
23
+ });
24
+
25
+ // Words that are verbs about a prompt, never the text of an answer.
26
+ var VERBS = ["allow", "allow_always", "deny"];
27
+
28
+ // History events that end a prompt, by the field that names its request.
29
+ var SETTLED_EVENTS = {
30
+ prompt_resolved: "requestId",
31
+ permission_resolved: "requestId",
32
+ elicitation_resolved: "requestId",
33
+ prompt_cancel: "requestId",
34
+ permission_cancel: "requestId",
35
+ ask_user_answered: "toolId",
36
+ };
37
+
38
+ function invalid(reason) {
39
+ return { invalid: reason };
40
+ }
41
+
42
+ // The message the browser sends for a decision on this kind of prompt, or
43
+ // { invalid } when the kind does not accept the decision. The registry's own
44
+ // parse() is more forgiving (an unknown permission decision reads as a deny), so
45
+ // the words are checked here: a typo must leave the prompt pending, not deny it.
46
+ function shapeDecision(prompt, decision) {
47
+ switch (prompt.kind) {
48
+ case "permission":
49
+ if (VERBS.indexOf(decision) === -1) return invalid("a permission prompt takes allow, allow_always or deny");
50
+ return { decision: decision };
51
+ case "plan": {
52
+ var planKind = promptKinds.KINDS.plan;
53
+ if (decision === "deny_with_feedback") return invalid("a plan rejected with feedback needs the feedback text, which this verb does not carry; use deny");
54
+ if (VERBS.indexOf(decision) === -1 && planKind.decisions.indexOf(decision) === -1) {
55
+ return invalid("a plan takes " + planKind.decisions.filter(function (d) { return d !== "deny_with_feedback"; }).concat(["allow_always"]).join(", "));
56
+ }
57
+ return { decision: decision };
58
+ }
59
+ case "ask_user": {
60
+ if (decision === "skip") return { decision: "skip" };
61
+ if (VERBS.indexOf(decision) !== -1) return invalid("a question takes the answer text, or skip");
62
+ var input = prompt.request && prompt.request.input;
63
+ if (!input || !Array.isArray(input.questions) || input.questions.length !== 1) {
64
+ return invalid("this prompt asks several questions at once; this verb answers a single question, or skips");
65
+ }
66
+ var answers = { 0: decision };
67
+ if (!Object.keys(codecs.askUser().normalizeAnswers(input, answers)).length) {
68
+ return invalid("the answer is empty or too long");
69
+ }
70
+ return { answers: answers };
71
+ }
72
+ case "elicitation":
73
+ if (decision === "allow") return { action: "accept" };
74
+ if (decision === "deny") return { action: "reject" };
75
+ return invalid("a request for input takes allow or deny");
76
+ default:
77
+ return invalid("this kind of prompt is not answered with a decision");
78
+ }
79
+ }
80
+
81
+ // Whether the session's recorded history shows the prompt as settled, and by
82
+ // whom: { settled, source }. A prompt that is not pending and was never
83
+ // recorded is unknown, not settled.
84
+ function settledInHistory(session, requestId) {
85
+ var history = session && Array.isArray(session.history) ? session.history : [];
86
+ for (var i = history.length - 1; i >= 0; i--) {
87
+ var e = history[i];
88
+ var field = e && SETTLED_EVENTS[e.type];
89
+ if (field && e[field] === requestId) return { settled: true, source: e.source || null };
90
+ }
91
+ return { settled: false, source: null };
92
+ }
93
+
94
+ function outcome(result, requestId, kind, source, extra) {
95
+ var out = Object.assign({ ok: result === RESULT.ANSWERED, result: result, requestId: requestId, kind: kind || null, source: source }, extra || {});
96
+ return out;
97
+ }
98
+
99
+ // req: { session, requestId, decision, source }
100
+ // session is the live session the request names. Returns the outcome object:
101
+ // { ok, result, requestId, kind, source, reason? }. Never resolves a prompt of
102
+ // another session, and never throws for a request that cannot be answered.
103
+ function answerPrompt(req) {
104
+ var session = req.session;
105
+ var registry = promptsFor(req.sm);
106
+ var found = registry.lookup(req.requestId, session);
107
+
108
+ if (!found || found.session !== session) {
109
+ var history = settledInHistory(session, req.requestId);
110
+ if (history.settled) {
111
+ return outcome(RESULT.ALREADY_SETTLED, req.requestId, null, req.source, {
112
+ reason: "the request is already settled",
113
+ settledBy: history.source,
114
+ });
115
+ }
116
+ return outcome(RESULT.NOT_FOUND, req.requestId, null, req.source, { reason: "no pending request with this id in the session" });
117
+ }
118
+
119
+ var kind = found.prompt.kind;
120
+ if (!promptKinds.operatorMayAnswer(kind)) {
121
+ return outcome(RESULT.NOT_FOUND, req.requestId, kind, req.source, { reason: "a request of kind " + kind + " is not answered by an operator" });
122
+ }
123
+ var shaped = shapeDecision(found.prompt, req.decision);
124
+ if (shaped.invalid) return outcome(RESULT.INVALID, req.requestId, kind, req.source, { reason: shaped.invalid });
125
+
126
+ var settled = registry.respond(req.requestId, shaped, {
127
+ session: session,
128
+ kinds: [kind],
129
+ responder: null,
130
+ source: req.source,
131
+ });
132
+ if (settled.status === "resolved") return outcome(RESULT.ANSWERED, req.requestId, kind, req.source);
133
+ if (settled.status === "invalid") {
134
+ return outcome(RESULT.INVALID, req.requestId, kind, req.source, { reason: String(settled.reason) });
135
+ }
136
+ // Settled between the lookup and the answer: the prompt is gone and its
137
+ // settle is in the history.
138
+ var after = settledInHistory(session, req.requestId);
139
+ return outcome(RESULT.ALREADY_SETTLED, req.requestId, kind, req.source, {
140
+ reason: "the request is already settled",
141
+ settledBy: after.source,
142
+ });
143
+ }
144
+
145
+ module.exports = { answerPrompt: answerPrompt, shapeDecision: shapeDecision, RESULT: RESULT };
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ // The registry-wide bound on an unanswered operator prompt: daemon.json
4
+ // `promptExpiryMinutes`. Read at each open(), so an edit applies to the next
5
+ // prompt; a prompt already open keeps the deadline it was given.
6
+ //
7
+ // absent -> 1440 (24 hours)
8
+ // 0 -> no expiry
9
+ // positive number -> that many minutes
10
+ // anything else -> the default, with one warning naming the key
11
+ //
12
+ // Malformed means: not a number, negative, not finite, or beyond what a timer
13
+ // can hold (a larger value would make setTimeout fire at once).
14
+
15
+ var KEY = "promptExpiryMinutes";
16
+ var DEFAULT_MINUTES = 1440;
17
+ var MAX_TIMER_MS = 2147483647;
18
+
19
+ /**
20
+ * @returns {function(?object): number} (daemon config) -> expiry in ms, 0 for
21
+ * none. One reader per registry: it warns once per malformed value.
22
+ */
23
+ function createExpiryReader() {
24
+ var warned = Object.create(null);
25
+
26
+ function warnOnce(value) {
27
+ var id = typeof value + ":" + String(value);
28
+ if (warned[id]) return;
29
+ warned[id] = true;
30
+ console.warn("[prompt-registry] " + KEY + " must be 0 (no expiry) or a positive number of minutes; using the default of " + DEFAULT_MINUTES);
31
+ }
32
+
33
+ return function expiryMs(cfg) {
34
+ var v = cfg ? cfg[KEY] : undefined;
35
+ if (v === undefined || v === null) return DEFAULT_MINUTES * 60000;
36
+ if (typeof v !== "number" || !isFinite(v) || v < 0) {
37
+ warnOnce(v);
38
+ return DEFAULT_MINUTES * 60000;
39
+ }
40
+ if (v === 0) return 0;
41
+ var ms = Math.max(1, Math.round(v * 60000));
42
+ if (ms > MAX_TIMER_MS) {
43
+ warnOnce(v);
44
+ return DEFAULT_MINUTES * 60000;
45
+ }
46
+ return ms;
47
+ };
48
+ }
49
+
50
+ module.exports = { createExpiryReader: createExpiryReader, KEY: KEY, DEFAULT_MINUTES: DEFAULT_MINUTES };
@@ -49,6 +49,7 @@ var grantKeys = require("./grant-keys");
49
49
  var sessionReclaim = require("./session-reclaim");
50
50
  var { promptLabel } = require("./prompt-label");
51
51
  var promptSource = require("./prompt-source");
52
+ var { createExpiryReader } = require("./prompt-expiry");
52
53
  var { logField } = require("./log-field");
53
54
  var { notifyFor } = require("./notify");
54
55
  var { withPromptLabel } = require("./prompt-label");
@@ -133,6 +134,8 @@ function openedBy(item) {
133
134
  * @param {function()} [deps.onProcessingChanged] - cross-project badge refresh.
134
135
  * @param {function(): string} [deps.getProjectName] - the project's display
135
136
  * name, read at each prompt so a rename shows on the next one.
137
+ * @param {function(): ?object} [deps.getConfig] - daemon.json, read at each
138
+ * open() for the unanswered-prompt bound (lib/prompt-expiry.js).
136
139
  * @param {function(): string} [deps.getProjectSlug] - the project's slug, which
137
140
  * the lifecycle log lines carry because console session ids repeat across
138
141
  * projects.
@@ -147,6 +150,9 @@ function createPromptRegistry(deps) {
147
150
  var getProjectName = deps.getProjectName || function () { return ""; };
148
151
  var getProjectSlug = deps.getProjectSlug || function () { return ""; };
149
152
  var getPushModule = deps.getPushModule || function () { return null; };
153
+ // daemon.json, read at each open(); null when there is none.
154
+ var getConfig = deps.getConfig || function () { return null; };
155
+ var expiryMs = createExpiryReader();
150
156
 
151
157
  // Project-scope prompts (no session): requestId -> record.
152
158
  var projectPrompts = Object.create(null);
@@ -358,7 +364,9 @@ function createPromptRegistry(deps) {
358
364
  * decides sub-agent ownership.
359
365
  * @param {AbortSignal} [opts.signal] - ends the prompt (aborted, or
360
366
  * expired when the signal's reason is "expired").
361
- * @param {number} [opts.timeoutMs] - ends the prompt as expired.
367
+ * @param {number} [opts.timeoutMs] - ends the prompt as expired. A prompt
368
+ * with neither this nor a kind default that a person answers is bounded
369
+ * by daemon.json promptExpiryMinutes instead.
362
370
  * @param {object} [opts.notification] - permission_request banner
363
371
  * content (title, body, slug, ...), delivered through the notification
364
372
  * core and closed with it when the prompt settles.
@@ -419,16 +427,31 @@ function createPromptRegistry(deps) {
419
427
  }
420
428
  }
421
429
  var timeoutMs = opts.timeoutMs != null ? opts.timeoutMs : kind.defaultTimeoutMs;
430
+ // The deadline is fixed here, from the opening, and nothing later (a
431
+ // reconnect, a replay, a history page) touches the timer. A kind's own
432
+ // timeout wins; the setting bounds only a prompt a person answers.
433
+ var bounded = timeoutMs != null;
434
+ if (!bounded && kind.journal) timeoutMs = expiryMs(getConfig());
422
435
  if (timeoutMs) {
423
436
  var timer = setTimeout(function () {
424
437
  cancelEntry(owner, requestId, entry, "expired", { source: promptSource.CANCEL.TIMEOUT });
425
438
  }, timeoutMs);
439
+ // The long default must not hold a process open; a kind's own short
440
+ // timeout keeps its existing behaviour.
441
+ if (!bounded && typeof timer.unref === "function") timer.unref();
426
442
  cleanups.push(function () { clearTimeout(timer); });
427
443
  }
428
444
  if (cleanups.length) {
429
445
  detachers.set(record, function () { cleanups.forEach(function (fn) { fn(); }); });
430
446
  }
431
447
 
448
+ // No banner for a sessionless prompt, by design and symmetrically with the
449
+ // close: a prompt without a session is a project-scope kind (the browser
450
+ // extension's commands), which a program answers, never a person, and is
451
+ // not journalled. There is nothing to alert, so nothing is created that a
452
+ // later close would have to retire. A journalled kind is always scoped to
453
+ // a session, so this guard never withholds a banner from a prompt a person
454
+ // answers.
432
455
  if (kind.journal && opts.notification && session) {
433
456
  var kindFields = typeof kind.notificationFields === "function" ? kind.notificationFields(record) : {};
434
457
  var pushText = opts.notification.push || null;
@@ -7,6 +7,8 @@
7
7
  //
8
8
  // { kind: "ws", clientId, user } an answer from a browser connection
9
9
  // { kind: "push", action, user } an answer from a push notification
10
+ // user | caller:<name> an answer from the answer-prompt verb: the
11
+ // same strings a cancel's source uses
10
12
  //
11
13
  // A prompt that ends without an answer carries a cancel source instead: one
12
14
  // string from a stable vocabulary, recorded on the prompt_cancel event, in the
@@ -66,6 +68,19 @@ function isCancelSource(value) {
66
68
  return typeof value === "string" && (FIXED_CANCEL_SOURCES.indexOf(value) !== -1 || CALLER_SOURCE.test(value));
67
69
  }
68
70
 
71
+ // The source of an act by an outside caller: caller:<from> when the caller named
72
+ // itself, else user (the operator's own CLI). Returns { source } or { error };
73
+ // what names the act in the error ("an end", "an answer"). The name is the
74
+ // caller's own label under OS-user trust, never interpreted.
75
+ function callerSource(from, what) {
76
+ if (from === undefined || from === null || from === "") return { source: CANCEL.USER };
77
+ var source = "caller:" + from;
78
+ if (!isCancelSource(source)) {
79
+ return { error: "from " + JSON.stringify(String(from).slice(0, 64)) + " cannot name " + what + ": use 1 to 64 of letters, digits and . _ @ / + -" };
80
+ }
81
+ return { source: source };
82
+ }
83
+
69
84
  // The one rule for a cancel's source: a value from the vocabulary is kept; a
70
85
  // missing or unknown one becomes "unspecified" and is warned about, so a
71
86
  // settle always carries a source and never an undefined one.
@@ -95,6 +110,7 @@ module.exports = {
95
110
  CANCEL: CANCEL,
96
111
  isCancelSource: isCancelSource,
97
112
  cancelSource: cancelSource,
113
+ callerSource: callerSource,
98
114
  describe: describe,
99
115
  clientIdOf: clientIdOf,
100
116
  };
package/lib/public/app.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  updateDmBadge, renderSidebarPresence, setMentionActive, clearAllMentionActive,
16
16
  initSidebarUsers
17
17
  } from './modules/sidebar-users.js';
18
- import { openMobileSheet, updateMobileProjectsTabBadge } from './modules/sidebar-mobile.js';
18
+ import { openMobileSheet, closeMobileSheetThen, updateMobileProjectsTabBadge } from './modules/sidebar-mobile.js';
19
19
  import { initRewind, setRewindMode, showRewindModal, clearPendingRewindUuid, addRewindButton, onRewindComplete, onRewindError } from './modules/rewind.js';
20
20
  import { initNotifications, showDoneNotification, playDoneSound, isNotifAlertEnabled, isNotifSoundEnabled } from './modules/notifications.js';
21
21
  import { initInput, clearPendingImages, handleInputSync, autoResize, builtinCommands, sendMessage, hasSendableContent, setScheduleDelayMs, clearScheduleDelay } from './modules/input.js';
@@ -66,6 +66,9 @@ import { initRendering, addToMessages as _renAddToMessages, scrollToBottom as _r
66
66
  import { initDm, openDm as _dmOpenDm, enterDmMode as _dmEnterDmMode, exitDmMode as _dmExitDmMode, appendDmMessage as _dmAppendDmMessage, showDmTypingIndicator as _dmShowDmTypingIndicator, handleDmSend as _dmHandleDmSend } from './modules/app-dm.js';
67
67
  import { initMention, handleMentionStart, handleMentionStream, handleMentionDone, handleMentionError, handleMentionActivity, renderMentionUser, renderMentionResponse } from './modules/mention.js';
68
68
  import { initTeamPanel } from './modules/team-panel.js';
69
+ import { initTeamView } from './modules/team-view.js';
70
+ import { initAgentMessages } from './modules/agent-messages.js';
71
+ import { getProjectAgents } from './modules/at-agents.js';
69
72
  import { initDiagnostics } from './modules/diagnostics.js';
70
73
 
71
74
  // --- Base path for multi-project routing ---
@@ -267,6 +270,8 @@ import { initDiagnostics } from './modules/diagnostics.js';
267
270
  dmKey: null,
268
271
  cachedDmFavorites: [],
269
272
  pendingTermCommand: null,
273
+ pendingLoginVendor: "",
274
+ pendingTermRequestId: "",
270
275
  myUserId: null,
271
276
  isMultiUserMode: true,
272
277
  dmUnread: {},
@@ -279,6 +284,7 @@ import { initDiagnostics } from './modules/diagnostics.js';
279
284
  // rendering
280
285
  currentMsgTs: null,
281
286
  richContextUsage: null,
287
+ sessionCompacting: false,
282
288
  currentMsgEl: null,
283
289
  currentFullText: "",
284
290
  // panels
@@ -375,7 +381,30 @@ import { initDiagnostics } from './modules/diagnostics.js';
375
381
  initToolPalettes();
376
382
  initSidebar(sidebarCtx);
377
383
  initSidebarUsers();
384
+ initTeamView();
378
385
  initTeamPanel();
386
+ initAgentMessages({
387
+ knownAgents: getProjectAgents,
388
+ // The same two paths the Home Hub uses: another project is switched to with
389
+ // the session id parked for the new connection, this project switches in place.
390
+ openSession: function (slug, id) {
391
+ closeMobileSheetThen(function () {
392
+ if (slug !== store.get('currentSlug')) {
393
+ try {
394
+ sessionStorage.setItem("pending-hub-session", String(id));
395
+ } catch (e) {
396
+ // Storage can be unavailable (private mode, quota). The project still
397
+ // switches; only the jump to that one session is lost.
398
+ console.warn("[agent-messages] could not park the session to open after the project switch:", e && e.message ? e.message : e);
399
+ }
400
+ switchProject(slug);
401
+ return;
402
+ }
403
+ var _ws = _getWsRef();
404
+ if (_ws && _ws.readyState === 1) _ws.send(JSON.stringify({ type: "switch_session", id: id }));
405
+ });
406
+ },
407
+ });
379
408
 
380
409
  initCommandPalette({
381
410
  switchProject: function (slug) { switchProject(slug); },
@@ -587,7 +616,7 @@ import { initDiagnostics } from './modules/diagnostics.js';
587
616
  // AskUserQuestion, PermissionRequest, Plan, Todo, Thinking, Tool items -> modules/tools.js
588
617
 
589
618
  // --- DOM: Messages (delegated to app-rendering.js) ---
590
- function addUserMessage(text, images, pastes, fromUserId, fromUserName, injected) { _renAddUserMessage(text, images, pastes, fromUserId, fromUserName, injected); }
619
+ function addUserMessage(text, images, pastes, fromUserId, fromUserName, injected, sentMidTurn) { _renAddUserMessage(text, images, pastes, fromUserId, fromUserName, injected, sentMidTurn); }
591
620
  function getMsgTime() { return _renGetMsgTime(); }
592
621
  function shouldGroupMessage(senderClass) { return _renShouldGroupMessage(senderClass); }
593
622
  function ensureAssistantBlock() { return _renEnsureAssistantBlock(); }
@@ -0,0 +1,96 @@
1
+ /* agent-messages.css - the agent-messages section of the Team view: a map of
2
+ sender and target pairs, and the thread of the selected pair. Drawn in the
3
+ desktop view and the phone sheet alike; the phone shows the map or the
4
+ thread, one at a time. */
5
+
6
+ .am-layout {
7
+ display: grid;
8
+ grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr);
9
+ gap: 16px;
10
+ align-items: start;
11
+ }
12
+
13
+ .am-layout.phone { grid-template-columns: minmax(0, 1fr); }
14
+
15
+ .am-map { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
16
+
17
+ .am-pair {
18
+ display: flex;
19
+ flex-wrap: wrap;
20
+ align-items: center;
21
+ gap: 6px;
22
+ width: 100%;
23
+ padding: 8px 10px;
24
+ text-align: left;
25
+ font: inherit;
26
+ font-size: 13px;
27
+ color: var(--text);
28
+ background: none;
29
+ border: 1px solid var(--border-subtle);
30
+ border-radius: 8px;
31
+ cursor: pointer;
32
+ min-height: 44px;
33
+ }
34
+
35
+ .am-pair:hover { background: rgba(var(--overlay-rgb), 0.05); }
36
+ .am-pair.selected { border-color: var(--accent, var(--text)); }
37
+
38
+ .am-pair-name { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
39
+ .am-arrow { color: var(--text-dimmer); }
40
+ .am-count { margin-left: auto; font-weight: 700; }
41
+ .am-last { color: var(--text-dim); font-size: 12px; }
42
+
43
+ .am-avatar { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; }
44
+
45
+ .am-thread { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
46
+ .am-thread-head { display: flex; align-items: center; gap: 10px; font-weight: 700; }
47
+ .am-thread-title { overflow-wrap: anywhere; }
48
+
49
+ .am-back, .am-link {
50
+ font: inherit;
51
+ font-size: 12px;
52
+ color: var(--text-muted);
53
+ background: none;
54
+ border: 1px solid var(--border-subtle);
55
+ border-radius: 6px;
56
+ padding: 6px 10px;
57
+ min-height: 32px;
58
+ cursor: pointer;
59
+ }
60
+
61
+ .am-back:hover, .am-link:hover { color: var(--text); background: rgba(var(--overlay-rgb), 0.06); }
62
+
63
+ .am-message {
64
+ display: flex;
65
+ flex-direction: column;
66
+ gap: 6px;
67
+ padding: 10px 12px;
68
+ border: 1px solid var(--border-subtle);
69
+ border-radius: 8px;
70
+ min-width: 0;
71
+ }
72
+
73
+ .am-message.pending { border-style: dashed; }
74
+
75
+ .am-message-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; }
76
+ .am-sender { font-weight: 600; overflow-wrap: anywhere; }
77
+ .am-time { color: var(--text-dim); }
78
+ .am-note { color: var(--text-dim); font-size: 12px; overflow-wrap: anywhere; }
79
+ .am-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; max-height: 240px; overflow-y: auto; }
80
+ .am-links { display: flex; flex-wrap: wrap; gap: 8px; }
81
+
82
+ .am-chip {
83
+ font-size: 10px;
84
+ font-weight: 600;
85
+ letter-spacing: 0.04em;
86
+ text-transform: uppercase;
87
+ padding: 2px 6px;
88
+ border-radius: 4px;
89
+ background: rgba(var(--overlay-rgb), 0.08);
90
+ color: var(--text-muted);
91
+ }
92
+
93
+ .am-chip.pending { color: var(--text); border: 1px dashed var(--text-dimmer); background: none; }
94
+
95
+ .am-empty, .am-hint { color: var(--text-dim); font-size: 13px; padding: 12px 0; }
96
+ .am-footnote { color: var(--text-dimmer); font-size: 12px; margin-top: 10px; }
@@ -0,0 +1,93 @@
1
+ /* agent-roster.css - the agent roster section of the Team view, the avatar
2
+ picker, and the sub-agent label in the transcript. Drawn in the desktop view
3
+ and the phone sheet alike; the phone stacks each row's parts. */
4
+
5
+ .ar-list { display: flex; flex-direction: column; gap: 8px; }
6
+
7
+ .ar-row {
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: 10px;
11
+ padding: 10px 12px;
12
+ border: 1px solid var(--border-subtle);
13
+ border-radius: 8px;
14
+ min-width: 0;
15
+ }
16
+
17
+ .ar-row.open { border-color: var(--accent, var(--text)); }
18
+
19
+ .ar-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
20
+
21
+ .ar-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
22
+
23
+ .ar-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
24
+ .ar-name { font-weight: 700; overflow-wrap: anywhere; }
25
+ .ar-seen { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--text-dim); font-size: 12px; }
26
+ .ar-places { display: flex; flex-wrap: wrap; gap: 4px 6px; }
27
+
28
+ .ar-place {
29
+ font-size: 11px;
30
+ padding: 2px 6px;
31
+ border-radius: 4px;
32
+ background: rgba(var(--overlay-rgb), 0.08);
33
+ color: var(--text-muted);
34
+ overflow-wrap: anywhere;
35
+ }
36
+
37
+ .ar-change, .ar-reset {
38
+ font: inherit;
39
+ font-size: 12px;
40
+ color: var(--text-muted);
41
+ background: none;
42
+ border: 1px solid var(--border-subtle);
43
+ border-radius: 6px;
44
+ padding: 6px 10px;
45
+ min-height: 44px;
46
+ cursor: pointer;
47
+ flex-shrink: 0;
48
+ }
49
+
50
+ .ar-change:hover, .ar-reset:hover { color: var(--text); background: rgba(var(--overlay-rgb), 0.06); }
51
+
52
+ .ar-picker { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
53
+ .ar-picker-title { font-size: 12px; font-weight: 700; color: var(--text-muted); }
54
+
55
+ .ar-seed-row, .ar-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
56
+ .ar-seed { flex: 1; min-width: 120px; min-height: 36px; font: inherit; font-size: 16px; }
57
+
58
+ .ar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
59
+
60
+ .ar-choice {
61
+ display: flex;
62
+ flex-direction: column;
63
+ align-items: center;
64
+ gap: 4px;
65
+ min-height: 44px;
66
+ padding: 6px;
67
+ font: inherit;
68
+ font-size: 11px;
69
+ color: var(--text);
70
+ background: none;
71
+ border: 1px solid var(--border-subtle);
72
+ border-radius: 8px;
73
+ cursor: pointer;
74
+ min-width: 0;
75
+ }
76
+
77
+ .ar-choice:hover { background: rgba(var(--overlay-rgb), 0.06); }
78
+ .ar-choice.selected { border-color: var(--accent, var(--text)); }
79
+ .ar-choice-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
80
+ .ar-preview { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
81
+
82
+ .ar-note, .ar-failure, .ar-empty { color: var(--text-dim); font-size: 12px; }
83
+ .ar-failure { color: var(--text); }
84
+ .ar-empty { font-size: 13px; padding: 12px 0; }
85
+
86
+ .tool-agent { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; margin-right: 6px; }
87
+ .tool-agent-avatar { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; }
88
+ .tool-agent-name { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
89
+
90
+ @media (max-width: 768px) {
91
+ .ar-head { flex-wrap: wrap; }
92
+ .ar-change { width: 100%; }
93
+ }
@@ -39,7 +39,7 @@
39
39
 
40
40
  /* --------------------------------------------------------
41
41
  Diagnostics panel (inside #info-panels)
42
- Follows the usage-panel / team-panel pattern.
42
+ Follows the usage-panel pattern.
43
43
  -------------------------------------------------------- */
44
44
  #diagnostics-panel {
45
45
  display: flex;