@clagentic/console 1.9.0-beta.3 → 1.10.0-beta.1

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 (146) hide show
  1. package/LICENSE +117 -12
  2. package/LICENSES/MIT-legacy.txt +22 -0
  3. package/LICENSES/README.md +15 -0
  4. package/README.md +8 -2
  5. package/bin/cli.js +30 -5
  6. package/deploy/clagentic-console.service +10 -6
  7. package/lib/audit.js +3 -2
  8. package/lib/build-sha.json +2 -2
  9. package/lib/build-update-check.js +138 -0
  10. package/lib/cli/daemon-launch.js +17 -17
  11. package/lib/config.js +32 -20
  12. package/lib/daemon-env-settings.js +84 -0
  13. package/lib/daemon-projects.js +38 -0
  14. package/lib/daemon.js +202 -158
  15. package/lib/drain.js +74 -17
  16. package/lib/env-compat.js +61 -0
  17. package/lib/extension-commands.js +45 -0
  18. package/lib/history-visibility.js +4 -0
  19. package/lib/idle-adapter-reaper.js +71 -0
  20. package/lib/link-trap.js +78 -0
  21. package/lib/lore-attestation.js +73 -0
  22. package/lib/mcp-local.js +8 -6
  23. package/lib/mcp-tool-input.js +116 -0
  24. package/lib/mcp-tool-schema.js +179 -0
  25. package/lib/memory-limits.js +61 -5
  26. package/lib/memory-setting-validate.js +65 -0
  27. package/lib/new-work-gate.js +47 -0
  28. package/lib/os-users.js +5 -3
  29. package/lib/project-access.js +139 -0
  30. package/lib/project-connection.js +23 -22
  31. package/lib/project-external-trigger.js +103 -10
  32. package/lib/project-file-scope.js +172 -0
  33. package/lib/project-file-watch.js +86 -61
  34. package/lib/project-filesystem.js +144 -128
  35. package/lib/project-git.js +119 -0
  36. package/lib/project-http.js +44 -28
  37. package/lib/project-loop.js +12 -5
  38. package/lib/project-mcp.js +53 -72
  39. package/lib/project-message-gate.js +70 -0
  40. package/lib/project-notifications.js +31 -4
  41. package/lib/project-prompt-responses.js +216 -0
  42. package/lib/project-sessions.js +164 -302
  43. package/lib/project-user-message.js +36 -11
  44. package/lib/project.js +189 -142
  45. package/lib/projects-dir.js +90 -0
  46. package/lib/prompt-access.js +22 -0
  47. package/lib/prompt-kinds/answer-limits.js +15 -0
  48. package/lib/prompt-kinds/ask-user.js +58 -0
  49. package/lib/prompt-kinds/codecs.js +97 -0
  50. package/lib/prompt-kinds/elicitation.js +77 -0
  51. package/lib/prompt-kinds/extension.js +39 -0
  52. package/lib/prompt-kinds/index.js +68 -0
  53. package/lib/prompt-kinds/permission.js +114 -0
  54. package/lib/prompt-kinds/plan.js +79 -0
  55. package/lib/prompt-kinds/tool-call.js +38 -0
  56. package/lib/prompt-registry.js +673 -0
  57. package/lib/public/app.js +1 -1
  58. package/lib/public/css/diagnostics.css +50 -0
  59. package/lib/public/css/input.css +17 -3
  60. package/lib/public/css/menus.css +10 -0
  61. package/lib/public/css/messages.css +5 -0
  62. package/lib/public/css/rewind.css +22 -0
  63. package/lib/public/index.html +4 -12
  64. package/lib/public/modules/app-connection.js +7 -0
  65. package/lib/public/modules/app-cursors.js +7 -5
  66. package/lib/public/modules/app-messages.js +45 -45
  67. package/lib/public/modules/app-notifications.js +47 -71
  68. package/lib/public/modules/app-panels.js +61 -58
  69. package/lib/public/modules/app-projects.js +2 -1
  70. package/lib/public/modules/app-rendering.js +4 -10
  71. package/lib/public/modules/diagnostics.js +60 -16
  72. package/lib/public/modules/filebrowser.js +18 -16
  73. package/lib/public/modules/history-visibility.js +4 -0
  74. package/lib/public/modules/mention.js +3 -2
  75. package/lib/public/modules/mode-options.js +38 -0
  76. package/lib/public/modules/project-settings.js +19 -8
  77. package/lib/public/modules/prompt-banner.js +78 -0
  78. package/lib/public/modules/prompt-card.js +201 -0
  79. package/lib/public/modules/prompt-kinds/ask-user-codec.js +131 -0
  80. package/lib/public/modules/prompt-kinds/ask-user.js +213 -0
  81. package/lib/public/modules/prompt-kinds/elicitation-codec.js +343 -0
  82. package/lib/public/modules/prompt-kinds/elicitation.js +176 -0
  83. package/lib/public/modules/prompt-kinds/index.js +18 -0
  84. package/lib/public/modules/prompt-kinds/own-key.js +29 -0
  85. package/lib/public/modules/prompt-kinds/package.json +3 -0
  86. package/lib/public/modules/prompt-kinds/permission-choices.js +31 -0
  87. package/lib/public/modules/prompt-kinds/permission.js +209 -0
  88. package/lib/public/modules/prompt-kinds/plan.js +102 -0
  89. package/lib/public/modules/prompt-state.js +142 -0
  90. package/lib/public/modules/prompts.js +134 -0
  91. package/lib/public/modules/rewind.js +4 -1
  92. package/lib/public/modules/server-settings.js +2 -4
  93. package/lib/public/modules/sidebar-mobile.js +19 -9
  94. package/lib/public/modules/sidebar-sessions.js +21 -14
  95. package/lib/public/modules/sticky-notes.js +3 -2
  96. package/lib/public/modules/team-panel.js +5 -4
  97. package/lib/public/modules/tools.js +67 -904
  98. package/lib/public/modules/vendor-picker.js +53 -0
  99. package/lib/public/modules/vendor-registry.js +133 -0
  100. package/lib/public/sw.js +3 -1
  101. package/lib/rc-migrate.js +44 -0
  102. package/lib/runtime-env-keys.js +109 -0
  103. package/lib/runtime-env.js +236 -0
  104. package/lib/sdk-bridge.js +290 -273
  105. package/lib/sdk-message-processor.js +125 -145
  106. package/lib/server-hub-sessions.js +13 -10
  107. package/lib/server-palette.js +28 -19
  108. package/lib/server.js +141 -113
  109. package/lib/service-install.js +96 -0
  110. package/lib/session-capabilities.js +76 -0
  111. package/lib/sessions.js +45 -28
  112. package/lib/users-permissions.js +9 -6
  113. package/lib/users.js +9 -0
  114. package/lib/utils.js +4 -2
  115. package/lib/vendor-auth.js +22 -0
  116. package/lib/vendor-registry-message.js +65 -0
  117. package/lib/ws-origin.js +99 -0
  118. package/lib/ws-schema.js +33 -22
  119. package/lib/yoke/adapters/claude-capabilities.js +38 -0
  120. package/lib/yoke/adapters/claude-vendor.js +35 -0
  121. package/lib/yoke/adapters/claude-worker.js +55 -87
  122. package/lib/yoke/adapters/claude.js +156 -62
  123. package/lib/yoke/adapters/codex-capabilities.js +37 -0
  124. package/lib/yoke/adapters/codex-vendor.js +46 -0
  125. package/lib/yoke/adapters/codex.js +347 -156
  126. package/lib/yoke/adapters/effort-control.js +34 -0
  127. package/lib/yoke/adapters/permission-relay.js +58 -0
  128. package/lib/yoke/adapters/worker-mcp-servers.js +81 -0
  129. package/lib/yoke/auth-checks.js +104 -0
  130. package/lib/yoke/capabilities.js +49 -0
  131. package/lib/yoke/codex-app-server.js +23 -5
  132. package/lib/yoke/env-ownership.js +40 -0
  133. package/lib/yoke/index.js +67 -173
  134. package/lib/yoke/install-probe.js +121 -0
  135. package/lib/yoke/instructions.js +7 -11
  136. package/lib/yoke/interface.js +199 -3
  137. package/lib/yoke/package.json +1 -1
  138. package/lib/yoke/provider-credentials.js +96 -0
  139. package/lib/yoke/registry.js +340 -0
  140. package/package.json +12 -8
  141. package/scripts/check-sdk-lock-drift.js +160 -0
  142. package/scripts/check-test-count.js +76 -1
  143. package/scripts/postinstall.js +218 -136
  144. package/scripts/prompt-harness-history.js +202 -0
  145. package/scripts/verify-installed.js +67 -0
  146. package/lib/sdk-permission-ownership.js +0 -136
@@ -0,0 +1,142 @@
1
+ // prompt-state.js - client copy of the server's operator-prompt state.
2
+ //
3
+ // The server owns every prompt's lifecycle (lib/prompt-registry.js); this
4
+ // store only mirrors what the server has said about each requestId, from
5
+ // whichever message said it first: a live event, a replayed request stamped
6
+ // with promptState, or the pending snapshot sent on connect. Terminal states
7
+ // are final on the server, so they are final here too - a later "pending"
8
+ // can never reopen a settled prompt, which is what makes card rendering
9
+ // independent of message order (paged history delivers outcomes before the
10
+ // requests they close).
11
+ //
12
+ // Deliberately free of imports so it can be exercised without the rest of the
13
+ // frontend module graph.
14
+
15
+ /**
16
+ * @typedef {{state: "pending"|"resolved"|"cancelled", decision?: ?string,
17
+ * answers?: ?object, skipped?: boolean, action?: ?string,
18
+ * reason?: ?string}} PromptState
19
+ */
20
+
21
+ var OUTCOME_FIELDS = ["decision", "answers", "skipped", "action"];
22
+
23
+ export function isTerminal(st) {
24
+ return !!st && (st.state === "resolved" || st.state === "cancelled");
25
+ }
26
+
27
+ function normalizeState(next) {
28
+ var out = { state: next.state, reason: next.reason || null };
29
+ OUTCOME_FIELDS.forEach(function (k) { out[k] = next[k] === undefined ? null : next[k]; });
30
+ return out;
31
+ }
32
+
33
+ export function createPromptStates() {
34
+ var states = Object.create(null);
35
+
36
+ return {
37
+ /**
38
+ * Merge what the server said about requestId; returns the effective state.
39
+ * @param {string} requestId
40
+ * @param {PromptState} next
41
+ * @returns {?PromptState}
42
+ */
43
+ apply: function (requestId, next) {
44
+ var cur = states[requestId];
45
+ if (!next || isTerminal(cur)) return cur || null;
46
+ if (isTerminal(next) || !cur) states[requestId] = normalizeState(next);
47
+ return states[requestId];
48
+ },
49
+
50
+ /** @returns {?PromptState} */
51
+ get: function (requestId) {
52
+ return states[requestId] || null;
53
+ },
54
+
55
+ /** Whether any prompt is still awaiting the operator. */
56
+ hasPending: function () {
57
+ return Object.keys(states).some(function (id) { return !isTerminal(states[id]); });
58
+ },
59
+
60
+ clear: function () {
61
+ states = Object.create(null);
62
+ },
63
+ };
64
+ }
65
+
66
+ function pick(msg, keys) {
67
+ var out = {};
68
+ keys.forEach(function (k) { if (msg[k] !== undefined) out[k] = msg[k]; });
69
+ return out;
70
+ }
71
+
72
+ function toolApprovalKind(toolName) {
73
+ return toolName === "ExitPlanMode" ? "plan" : "permission";
74
+ }
75
+
76
+ /**
77
+ * One prompt event in the single client shape, or null for a message that
78
+ * is not about a prompt. Accepts the prompt_* messages and the per-kind
79
+ * messages recorded in history before prompts had one shape (and the
80
+ * AskUserQuestion tool call, which draws that prompt's card).
81
+ *
82
+ * @returns {?{phase: "request"|"pending"|"resolved"|"cancel", requestId: string,
83
+ * kind: ?string, fields: object, serverState: ?PromptState}}
84
+ */
85
+ export function normalizePromptMessage(msg) {
86
+ if (!msg || typeof msg.type !== "string") return null;
87
+ switch (msg.type) {
88
+ case "prompt_request":
89
+ case "prompt_pending":
90
+ return {
91
+ phase: msg.type === "prompt_pending" ? "pending" : "request",
92
+ requestId: msg.requestId,
93
+ kind: msg.kind,
94
+ fields: msg,
95
+ serverState: msg.promptState || null,
96
+ };
97
+ case "permission_request":
98
+ case "permission_request_pending":
99
+ return {
100
+ phase: msg.type === "permission_request_pending" ? "pending" : "request",
101
+ requestId: msg.requestId,
102
+ kind: toolApprovalKind(msg.toolName),
103
+ fields: msg,
104
+ serverState: msg.promptState || msg.permissionState || null,
105
+ };
106
+ case "elicitation_request":
107
+ return { phase: "request", requestId: msg.requestId, kind: "elicitation", fields: msg, serverState: msg.promptState || null };
108
+ case "tool_executing":
109
+ if (msg.name !== "AskUserQuestion" || !msg.input || !msg.input.questions) return null;
110
+ return {
111
+ phase: "request",
112
+ requestId: msg.id,
113
+ kind: "ask_user",
114
+ fields: { input: msg.input, toolUseId: msg.id },
115
+ serverState: msg.promptState || null,
116
+ };
117
+ case "prompt_resolved":
118
+ case "permission_resolved":
119
+ case "elicitation_resolved":
120
+ return {
121
+ phase: "resolved",
122
+ requestId: msg.requestId,
123
+ kind: msg.kind || null,
124
+ fields: pick(msg, OUTCOME_FIELDS),
125
+ serverState: null,
126
+ };
127
+ case "ask_user_answered":
128
+ if (msg.answers && Object.keys(msg.answers).length) {
129
+ return { phase: "resolved", requestId: msg.toolId, kind: "ask_user", fields: { answers: msg.answers }, serverState: null };
130
+ }
131
+ // A recorded skip is an answer, not an ending nobody chose.
132
+ if (msg.skipped === true) {
133
+ return { phase: "resolved", requestId: msg.toolId, kind: "ask_user", fields: { skipped: true }, serverState: null };
134
+ }
135
+ return { phase: "cancel", requestId: msg.toolId, kind: "ask_user", fields: { reason: null }, serverState: null };
136
+ case "prompt_cancel":
137
+ case "permission_cancel":
138
+ return { phase: "cancel", requestId: msg.requestId, kind: msg.kind || null, fields: { reason: msg.reason || null }, serverState: null };
139
+ default:
140
+ return null;
141
+ }
142
+ }
@@ -0,0 +1,134 @@
1
+ // prompts.js - the client's single owner of operator-prompt cards.
2
+ //
3
+ // Every prompt message, whatever its kind and whether it arrives live, in a
4
+ // replayed history page or in the pending snapshot sent on connect, goes
5
+ // through apply(). A card is a pure function of the server's state for its
6
+ // requestId (prompt-state.js), never of the order messages arrived in; the
7
+ // kind renderer (prompt-kinds/) only draws the body and answer controls.
8
+ //
9
+ // Deliberately free of DOM globals beyond document.createElement (via the
10
+ // renderers), so a host can drive it with a hand-built DOM.
11
+
12
+ import { createPromptStates, normalizePromptMessage, isTerminal } from './prompt-state.js';
13
+ import {
14
+ submitPromptResponse, restorePromptCard, settlePromptCard, isUnconfirmed,
15
+ showOutcome, cancelledLabel,
16
+ } from './prompt-card.js';
17
+ import { PROMPT_KINDS } from './prompt-kinds/index.js';
18
+ import { ownValue } from './prompt-kinds/own-key.js';
19
+
20
+ /**
21
+ * @param {object} host
22
+ * @param {function(Element, ?string)} host.place - insert a new card into
23
+ * the transcript, focusing the element matching the selector if given.
24
+ * @param {function(object): boolean} host.send - send a WS message; false
25
+ * when the socket is unusable.
26
+ * @param {function(): string} host.layout - "channel" or "bubble".
27
+ * @param {function(string, object): string} host.toolSummary
28
+ * @param {function(?string): {name: string, avatar: string}} host.vendorIdentity
29
+ * @param {function(): number} host.getContextPercent
30
+ * @param {function(): ?string} host.getPlanContent
31
+ * @param {function(boolean)} host.setMainInputDisabled
32
+ * @param {function(Element): boolean} host.contains - whether an element is
33
+ * still in the transcript.
34
+ * @param {function(string): ?Element} host.findInTranscript - the card for a
35
+ * requestId in the transcript, if one is there.
36
+ */
37
+ export function createPromptController(host) {
38
+ var states = createPromptStates();
39
+ // requestId -> { container, kind, fields }
40
+ var cards = Object.create(null);
41
+
42
+ // The card currently in the transcript for requestId, if any. A transcript
43
+ // rebuilt without clear() leaves a detached element behind; it is looked
44
+ // up again rather than updated out of sight.
45
+ function cardFor(requestId) {
46
+ var rec = cards[requestId];
47
+ if (!rec) return null;
48
+ if (rec.container && host.contains(rec.container)) return rec;
49
+ rec.container = host.findInTranscript(requestId);
50
+ return rec.container ? rec : null;
51
+ }
52
+
53
+ function respond(requestId, kind, container, fields) {
54
+ var payload = Object.assign({ type: "prompt_response", requestId: requestId, kind: kind }, fields);
55
+ submitPromptResponse(container, function () { return host.send(payload); });
56
+ }
57
+
58
+ function draw(n) {
59
+ var renderer = ownValue(PROMPT_KINDS, n.kind);
60
+ if (!renderer) return null;
61
+ var rendererHost = Object.assign({}, host, {
62
+ respond: function (container, fields) { respond(n.requestId, n.kind, container, fields); },
63
+ });
64
+ var container = renderer.draw(n.fields, n.requestId, rendererHost);
65
+ container.dataset.promptKind = n.kind;
66
+ cards[n.requestId] = { container: container, kind: n.kind, fields: n.fields, host: rendererHost };
67
+ host.place(container, renderer.focusSelector || null);
68
+ return cards[n.requestId];
69
+ }
70
+
71
+ function settle(rec, st) {
72
+ var renderer = ownValue(PROMPT_KINDS, rec.kind);
73
+ if (rec.container.classList.contains("resolved")) return;
74
+ settlePromptCard(rec.container);
75
+ var outcome = st.state === "cancelled"
76
+ ? { text: cancelledLabel(st.reason), tone: "cancelled" }
77
+ : renderer.outcome(st);
78
+ showOutcome(rec.container, outcome);
79
+ if (renderer.settle) renderer.settle(rec.container, st, rec.fields, outcome, rec.host);
80
+ }
81
+
82
+ // Bring a card in line with its requestId's state. serverPending is the
83
+ // server's assertion that the prompt is still unanswered: a card left
84
+ // mid-send by a dropped socket becomes answerable again.
85
+ function sync(requestId, serverPending) {
86
+ var st = states.get(requestId);
87
+ var rec = cardFor(requestId);
88
+ if (!st || !rec) return;
89
+ if (isTerminal(st)) settle(rec, st);
90
+ else if (serverPending && isUnconfirmed(rec.container)) restorePromptCard(rec.container);
91
+ }
92
+
93
+ return {
94
+ /**
95
+ * Apply one prompt message (any kind, current or legacy shape). Returns
96
+ * the prompt's effective state, or null for an unrelated message.
97
+ */
98
+ apply: function (msg) {
99
+ var n = normalizePromptMessage(msg);
100
+ if (!n || !n.requestId) return null;
101
+ if (n.phase === "request" || n.phase === "pending") {
102
+ states.apply(n.requestId, n.serverState || { state: "pending" });
103
+ if (!cardFor(n.requestId)) draw(n);
104
+ sync(n.requestId, n.phase === "pending");
105
+ } else if (n.phase === "resolved") {
106
+ states.apply(n.requestId, Object.assign({ state: "resolved" }, n.fields));
107
+ sync(n.requestId);
108
+ } else {
109
+ states.apply(n.requestId, { state: "cancelled", reason: n.fields.reason });
110
+ sync(n.requestId);
111
+ }
112
+ return states.get(n.requestId);
113
+ },
114
+
115
+ /** Return every card awaiting a server confirmation to its answerable state. */
116
+ restoreUnconfirmed: function (message) {
117
+ Object.keys(cards).forEach(function (id) {
118
+ var rec = cards[id];
119
+ if (rec.container && isUnconfirmed(rec.container)) restorePromptCard(rec.container, message);
120
+ });
121
+ },
122
+
123
+ /** Forget everything (a different session's transcript is shown). */
124
+ clear: function () {
125
+ states.clear();
126
+ cards = Object.create(null);
127
+ },
128
+
129
+ get: function (requestId) { return states.get(requestId); },
130
+
131
+ /** Whether any prompt, of any kind, is still awaiting the operator. */
132
+ hasPending: function () { return states.hasPending(); },
133
+ };
134
+ }
@@ -1,5 +1,6 @@
1
1
  import { escapeHtml } from './utils.js';
2
2
  import { iconHtml, refreshIcons } from './icons.js';
3
+ import { capabilityGate } from './vendor-registry.js';
3
4
 
4
5
  var ctx;
5
6
  var rewindMode = false;
@@ -337,7 +338,9 @@ export function addRewindButton(msgEl) {
337
338
  var btn = document.createElement("button");
338
339
  btn.className = "msg-user-rewind-btn";
339
340
  btn.type = "button";
340
- btn.title = "Rewind to here";
341
+ var gate = capabilityGate("rewind");
342
+ btn.title = gate.enabled ? "Rewind to here" : "Rewind to here (unavailable): " + gate.reason;
343
+ btn.disabled = !gate.enabled;
341
344
  btn.innerHTML = iconHtml("rotate-ccw");
342
345
  msgEl.appendChild(btn);
343
346
  refreshIcons();
@@ -1351,11 +1351,9 @@ function autoSaveSharedEnv() {
1351
1351
  var ws = ctx.ws;
1352
1352
  if (ws && ws.readyState === 1) {
1353
1353
  ws.send(JSON.stringify({ type: "set_shared_env", envrc: envrc }));
1354
+ // "Saved" or the reason it was refused is shown when the server answers.
1354
1355
  var saveStatus = document.getElementById("ss-env-save-status");
1355
- if (saveStatus) {
1356
- saveStatus.textContent = "Saved";
1357
- setTimeout(function () { saveStatus.textContent = ""; }, 2000);
1358
- }
1356
+ if (saveStatus) saveStatus.textContent = "Saving...";
1359
1357
  }
1360
1358
  }, 800);
1361
1359
  }
@@ -37,6 +37,7 @@ import {
37
37
  import { sessionActivity, rollupActivity, indicatorClass } from './activity-state.js';
38
38
 
39
39
  import { store } from './store.js';
40
+ import { capabilityGate } from './vendor-registry.js';
40
41
  import { getWs } from './ws-ref.js';
41
42
  import { dismissOverlayPanels, closeSidebar } from './sidebar.js';
42
43
  import { switchProject, getCachedProjects, openAddProjectModal } from './app-projects.js';
@@ -786,9 +787,9 @@ function renderMobileSessionsInto(container) {
786
787
  actionGrid.className = "mobile-session-actions";
787
788
 
788
789
  var isDmMode = store.get('dmMode');
789
- // Agent Chat is Claude Code-only — the Codex adapter has no agent identity
790
- // injection API (no equivalent of the Claude Agent SDK `agent` option).
791
- var isCodexMode = (store.get('currentVendor') || 'claude') === 'codex';
790
+ // Agent Chat needs the agent to take a named identity (the agentInjection
791
+ // capability); otherwise the entry stays visible, disabled, with the reason.
792
+ var agentGate = capabilityGate('agentInjection');
792
793
 
793
794
  // Row 1: New session
794
795
  var newBtn = document.createElement("button");
@@ -802,11 +803,16 @@ function renderMobileSessionsInto(container) {
802
803
  });
803
804
  actionGrid.appendChild(newBtn);
804
805
 
805
- // Row 2: Agent chat (full picker) — hidden in dmMode and Codex mode
806
- if (!isDmMode && !isCodexMode) {
806
+ // Row 2: Agent chat (full picker) — hidden in dmMode, disabled when the
807
+ // agent cannot take a named identity
808
+ if (!isDmMode) {
807
809
  var agentBtn = document.createElement("button");
808
810
  agentBtn.className = "mobile-session-new";
809
811
  agentBtn.innerHTML = '<i data-lucide="message-circle-plus" style="width:16px;height:16px"></i> Agent chat';
812
+ if (!agentGate.enabled) {
813
+ agentBtn.disabled = true;
814
+ agentBtn.title = agentGate.reason;
815
+ }
810
816
  agentBtn.addEventListener("click", function () {
811
817
  closeMobileSheet();
812
818
  setTimeout(function () { openAgentPicker(); }, 250);
@@ -815,7 +821,7 @@ function renderMobileSessionsInto(container) {
815
821
  }
816
822
 
817
823
  // Row 3 (optional): preferred agent quick-launch — only when set, no placeholder
818
- if (!isDmMode && !isCodexMode) {
824
+ if (!isDmMode) {
819
825
  var currentSlugMobile = store.get('currentSlug');
820
826
  var preferredAgentMobile = null;
821
827
  if (currentSlugMobile) {
@@ -831,6 +837,10 @@ function renderMobileSessionsInto(container) {
831
837
  var prefBtn = document.createElement("button");
832
838
  prefBtn.className = "mobile-session-new";
833
839
  prefBtn.innerHTML = '<i data-lucide="bot" style="width:16px;height:16px"></i> ' + escapeHtml(preferredAgentMobile.name);
840
+ if (!agentGate.enabled) {
841
+ prefBtn.disabled = true;
842
+ prefBtn.title = agentGate.reason;
843
+ }
834
844
  prefBtn.addEventListener("click", function () {
835
845
  closeMobileSheet();
836
846
  setTimeout(function () {
@@ -1299,10 +1309,10 @@ export function initSidebarMobile() {
1299
1309
  }
1300
1310
 
1301
1311
  // Re-render the mobile session action grid when vendor changes so the Agent
1302
- // Chat button appears/disappears correctly when the user switches vendors
1312
+ // Chat button enables/disables correctly when the user switches vendors
1303
1313
  // while the mobile sheet is already open.
1304
- store.subscribe(['currentVendor'], function (state, prev) {
1305
- if (state.currentVendor !== prev.currentVendor && mobileChatSheetOpen) {
1314
+ store.subscribe(['currentVendor', 'vendorRegistry'], function (state, prev) {
1315
+ if ((state.currentVendor !== prev.currentVendor || state.vendorRegistry !== prev.vendorRegistry) && mobileChatSheetOpen) {
1306
1316
  refreshMobileChatSheet();
1307
1317
  }
1308
1318
  });
@@ -6,6 +6,7 @@ import { escapeHtml, relativeTime } from './utils.js';
6
6
  import { iconHtml, refreshIcons } from './icons.js';
7
7
  import { openSearch as openSessionSearch } from './session-search.js';
8
8
  import { store } from './store.js';
9
+ import { capabilityGate } from './vendor-registry.js';
9
10
  import { getWs } from './ws-ref.js';
10
11
  import { getSessionListEl } from './dom-refs.js';
11
12
  import { dismissOverlayPanels, closeSidebar, updatePageTitle, spawnDustParticles } from './sidebar.js';
@@ -334,14 +335,14 @@ function renderSessionTopActions() {
334
335
  wrap.className = "session-top-actions";
335
336
 
336
337
  var isDm = store.get('dmMode');
337
- // Agent Chat is Claude Code-only — the Claude Agent SDK supports named-agent
338
- // identity injection; the Codex adapter has no equivalent API surface.
339
- var isCodex = (store.get('currentVendor') || 'claude') === 'codex';
338
+ // Agent Chat needs the agent to take a named identity (the agentInjection
339
+ // capability); otherwise the entry stays visible, disabled, with the reason.
340
+ var agentGate = capabilityGate('agentInjection');
340
341
 
341
342
  // Resolve preferred agent for the current project
342
343
  var currentSlug = store.get('currentSlug');
343
344
  var preferredAgent = null;
344
- if (currentSlug && !isDm && !isCodex) {
345
+ if (currentSlug && !isDm) {
345
346
  var projects = getCachedProjects();
346
347
  for (var pi = 0; pi < projects.length; pi++) {
347
348
  if (projects[pi].slug === currentSlug) {
@@ -363,13 +364,17 @@ function renderSessionTopActions() {
363
364
  });
364
365
  wrap.appendChild(newBtn);
365
366
 
366
- // Agent Chat (full picker) — hidden in dmMode and in Codex mode (no agent
367
- // identity injection available in the Codex adapter).
368
- if (!isDm && !isCodex) {
367
+ // Agent Chat (full picker) — hidden in dmMode, disabled when the agent
368
+ // cannot take a named identity.
369
+ if (!isDm) {
369
370
  var agentBtn = document.createElement("button");
370
371
  agentBtn.className = "session-top-action";
371
372
  agentBtn.type = "button";
372
373
  agentBtn.innerHTML = iconHtml("message-circle-plus") + '<span>Agent Chat</span>';
374
+ if (!agentGate.enabled) {
375
+ agentBtn.disabled = true;
376
+ agentBtn.title = agentGate.reason;
377
+ }
373
378
  agentBtn.addEventListener("click", function () {
374
379
  openAgentPicker();
375
380
  });
@@ -378,12 +383,13 @@ function renderSessionTopActions() {
378
383
 
379
384
  // Row 2 (optional): preferred agent quick-launch — full width, only when set.
380
385
  // Shows nothing when no preferred agent is configured (no placeholder clutter).
381
- if (!isDm && !isCodex && preferredAgent) {
386
+ if (!isDm && preferredAgent) {
382
387
  var favBtn = document.createElement("button");
383
388
  favBtn.type = "button";
384
389
  favBtn.className = "session-top-action session-top-action--preferred";
385
390
  favBtn.innerHTML = iconHtml("bot") + '<span>' + escapeHtml(preferredAgent.name) + '</span>';
386
- favBtn.title = 'Start chat with ' + preferredAgent.name;
391
+ favBtn.title = agentGate.enabled ? 'Start chat with ' + preferredAgent.name : agentGate.reason;
392
+ favBtn.disabled = !agentGate.enabled;
387
393
  favBtn.addEventListener("click", function () {
388
394
  var ws = getWs();
389
395
  if (ws && store.get('connected')) {
@@ -586,11 +592,12 @@ export function initSidebarSessions() {
586
592
  }
587
593
 
588
594
  // --- Reactively update top-actions when vendor changes ---
589
- // Agent Chat is hidden in Codex mode; the vendor toggle in app-panels
590
- // updates the store without triggering a session_list, so we subscribe
591
- // here and swap just the top-actions node to avoid a full list re-render.
592
- store.subscribe(['currentVendor'], function (state, prev) {
593
- if (state.currentVendor !== prev.currentVendor) {
595
+ // Agent Chat is disabled for an agent without named identities; the agent
596
+ // picker in app-panels updates the store without triggering a session_list,
597
+ // so we subscribe here and swap just the top-actions node to avoid a full
598
+ // list re-render.
599
+ store.subscribe(['currentVendor', 'vendorRegistry'], function (state, prev) {
600
+ if (state.currentVendor !== prev.currentVendor || state.vendorRegistry !== prev.vendorRegistry) {
594
601
  refreshSessionTopActions();
595
602
  }
596
603
  });
@@ -6,8 +6,9 @@ var ctx;
6
6
  var notes = new Map(); // id -> { data, el }
7
7
  var notesVisible = false;
8
8
  var archiveOpen = false;
9
- var updateTimers = {};
10
- var textTimers = {};
9
+ // Keyed by note ids from the server: no prototype to answer for them.
10
+ var updateTimers = Object.create(null);
11
+ var textTimers = Object.create(null);
11
12
  var colorPickerEl = null;
12
13
  var formatToolbarEl = null;
13
14
 
@@ -223,8 +223,9 @@ export function initTeamPanel() {
223
223
  export function handleTeamState(msg) {
224
224
  currentTeam = msg.team || null;
225
225
  if (currentTeam) {
226
- currentTeam._memberStatuses = currentTeam._memberStatuses || {};
227
- currentTeam._memberActivities = currentTeam._memberActivities || {};
226
+ // Keyed by agent ids from the server: no prototype to answer for them.
227
+ currentTeam._memberStatuses = currentTeam._memberStatuses || Object.create(null);
228
+ currentTeam._memberActivities = currentTeam._memberActivities || Object.create(null);
228
229
  }
229
230
  teamMessages = msg.messages || [];
230
231
 
@@ -248,8 +249,8 @@ export function handleTeamMemberUpdate(msg) {
248
249
 
249
250
  // Single member status/activity update
250
251
  if (msg.agentId) {
251
- currentTeam._memberStatuses = currentTeam._memberStatuses || {};
252
- currentTeam._memberActivities = currentTeam._memberActivities || {};
252
+ currentTeam._memberStatuses = currentTeam._memberStatuses || Object.create(null);
253
+ currentTeam._memberActivities = currentTeam._memberActivities || Object.create(null);
253
254
  if (msg.status) {
254
255
  currentTeam._memberStatuses[msg.agentId] = msg.status;
255
256
  }