@clagentic/console 1.12.0-beta.1 → 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 (82) hide show
  1. package/README.md +1 -0
  2. package/bin/cli.js +2 -1
  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/duration.js +27 -0
  8. package/lib/cli/schedule-input-subcommands.js +1 -22
  9. package/lib/cli/session-subcommands.js +38 -7
  10. package/lib/daemon.js +6 -0
  11. package/lib/notification-prefs.js +2 -0
  12. package/lib/notify/core.js +175 -0
  13. package/lib/notify/index.js +31 -0
  14. package/lib/notify/live-prompts.js +36 -0
  15. package/lib/notify/payload.js +63 -0
  16. package/lib/notify/target.js +5 -0
  17. package/lib/notify/type-registry.js +64 -0
  18. package/lib/notify/types.js +20 -0
  19. package/lib/open-sockets.js +27 -0
  20. package/lib/outbound-access.js +74 -0
  21. package/lib/outbound-entry.js +109 -0
  22. package/lib/outbound-ledger.js +306 -0
  23. package/lib/outbound-query.js +153 -0
  24. package/lib/pending-prompts.js +31 -16
  25. package/lib/project-connection.js +40 -1
  26. package/lib/project-filesystem.js +20 -5
  27. package/lib/project-http.js +9 -1
  28. package/lib/project-loop.js +22 -7
  29. package/lib/project-notifications.js +54 -32
  30. package/lib/project-prompt-responses.js +1 -1
  31. package/lib/project-sessions.js +2 -1
  32. package/lib/project.js +15 -1
  33. package/lib/prompt-registry.js +74 -24
  34. package/lib/prompt-reminders.js +38 -33
  35. package/lib/prompt-source.js +43 -8
  36. package/lib/public/app.js +1 -0
  37. package/lib/public/css/diagnostics.css +28 -0
  38. package/lib/public/css/home-hub.css +12 -0
  39. package/lib/public/css/icon-strip.css +9 -0
  40. package/lib/public/css/mobile-nav.css +11 -0
  41. package/lib/public/css/sidebar.css +7 -0
  42. package/lib/public/index.html +3 -0
  43. package/lib/public/modules/activity-state.js +20 -4
  44. package/lib/public/modules/app-connection.js +22 -5
  45. package/lib/public/modules/app-notifications.js +47 -48
  46. package/lib/public/modules/app-projects.js +3 -1
  47. package/lib/public/modules/app-rendering.js +10 -0
  48. package/lib/public/modules/build-update-sessions.js +81 -0
  49. package/lib/public/modules/diagnostics.js +9 -2
  50. package/lib/public/modules/env-shadow-notice.js +34 -0
  51. package/lib/public/modules/notify-client.js +153 -0
  52. package/lib/public/modules/project-settings.js +5 -0
  53. package/lib/public/modules/prompt-state.js +3 -3
  54. package/lib/public/modules/prompts.js +1 -1
  55. package/lib/public/modules/server-settings.js +3 -0
  56. package/lib/public/modules/terminal-links.js +175 -0
  57. package/lib/public/modules/terminal.js +19 -103
  58. package/lib/public/notify-sw-logic.js +300 -0
  59. package/lib/public/notify-target.js +97 -0
  60. package/lib/public/sw.js +15 -68
  61. package/lib/push.js +63 -19
  62. package/lib/runtime-env.js +1 -0
  63. package/lib/sdk-bridge.js +62 -30
  64. package/lib/sdk-message-processor.js +78 -37
  65. package/lib/server.js +34 -2
  66. package/lib/session-directory.js +6 -4
  67. package/lib/session-input-ipc.js +11 -1
  68. package/lib/session-input.js +89 -14
  69. package/lib/session-liveness.js +53 -0
  70. package/lib/session-reclaim.js +37 -2
  71. package/lib/sessions.js +31 -4
  72. package/lib/usage-store.js +29 -7
  73. package/lib/vendor-auth.js +33 -2
  74. package/lib/ws-schema.js +6 -1
  75. package/lib/yoke/adapters/claude-vendor.js +11 -1
  76. package/lib/yoke/adapters/claude.js +7 -0
  77. package/lib/yoke/auth-checks.js +17 -2
  78. package/lib/yoke/index.js +21 -3
  79. package/lib/yoke/provider-credentials.js +24 -0
  80. package/lib/yoke/registry.js +8 -1
  81. package/package.json +2 -2
  82. package/scripts/check-test-count.js +14 -0
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
@@ -889,6 +906,7 @@ function createSessionManager(opts) {
889
906
  title: s.title || "New Session",
890
907
  active: isActive,
891
908
  isProcessing: s.isProcessing,
909
+ waiting: sessionLiveness.activityOf(s) === sessionLiveness.ACTIVITY.WAITING,
892
910
  lastActivity: s.lastActivity || s.createdAt || 0,
893
911
  loop: loop,
894
912
  ownerId: s.ownerId || null,
@@ -990,7 +1008,15 @@ function createSessionManager(opts) {
990
1008
  };
991
1009
  giveStartingMode(session, sessionOpts);
992
1010
  sessions.set(localId, session);
993
- 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
+ }
994
1020
  return session;
995
1021
  }
996
1022
 
@@ -1281,7 +1307,7 @@ function createSessionManager(opts) {
1281
1307
  cleanupMentionSessions(session);
1282
1308
  // Settled before the abort below so no abort listener records an event
1283
1309
  // into a history that is about to be deleted.
1284
- prompts.cancelSession(session, "session_deleted", { record: false });
1310
+ prompts.cancelSession(session, "session_deleted", { record: false, source: promptSource.CANCEL.SESSION_END });
1285
1311
 
1286
1312
  if (session.abortController) {
1287
1313
  try { session.abortController.abort(); } catch(e) {}
@@ -1330,7 +1356,7 @@ function createSessionManager(opts) {
1330
1356
  _lruRemove(localId);
1331
1357
 
1332
1358
  cleanupMentionSessions(session);
1333
- prompts.cancelSession(session, "session_deleted", { record: false });
1359
+ prompts.cancelSession(session, "session_deleted", { record: false, source: promptSource.CANCEL.SESSION_END });
1334
1360
  if (session.abortController) {
1335
1361
  try { session.abortController.abort(); } catch(e) {}
1336
1362
  }
@@ -1977,6 +2003,7 @@ function createSessionManager(opts) {
1977
2003
  // outcome is flushed to disk; then the exit flusher registered above is
1978
2004
  // unregistered so nothing accumulates across project open/close cycles.
1979
2005
  destroy: function() {
2006
+ managerDestroyed = true;
1980
2007
  prompts.shutdown();
1981
2008
  _onProcessExit();
1982
2009
  unregisterExitFlush();
@@ -40,6 +40,26 @@ function isIsoOrNull(v) {
40
40
  function isStrOrNull(v) {
41
41
  return v === null || typeof v === "string";
42
42
  }
43
+ // Session ids arrive as numbers from the session layer and as strings from
44
+ // older files; both are stored as strings, which is also how confirm() and
45
+ // endProcess() key them. Anything else is not an id.
46
+ function idOrNull(v) {
47
+ if (typeof v === "string") return v;
48
+ if (typeof v === "number" && isFinite(v)) return String(v);
49
+ return null;
50
+ }
51
+ function strOrNull(v) {
52
+ return typeof v === "string" ? v : null;
53
+ }
54
+ function finiteOrNull(v) {
55
+ return typeof v === "number" && isFinite(v) ? v : null;
56
+ }
57
+ // Epoch seconds to ISO, or null when the value is not a representable time.
58
+ function epochSecondsToIsoOrNull(sec) {
59
+ if (typeof sec !== "number" || !isFinite(sec) || sec === 0) return null;
60
+ var ms = sec * 1000;
61
+ return isFinite(new Date(ms).getTime()) ? toIso(ms) : null;
62
+ }
43
63
 
44
64
  // Vendor and bucket names come from persisted JSON and CLI output, so they are
45
65
  // untrusted. Internal maps have no prototype (a name like "constructor" or
@@ -58,7 +78,9 @@ function validRecord(r) {
58
78
  if (typeof r.observedAt !== "string" || !isFinite(Date.parse(r.observedAt))) return null;
59
79
  if (!(r.utilization === null || (typeof r.utilization === "number" && isFinite(r.utilization)))) return null;
60
80
  if (!isIsoOrNull(r.utilizationObservedAt) || !isIsoOrNull(r.resetsAt)) return null;
61
- if (!isStrOrNull(r.status) || !isStrOrNull(r.source) || !isStrOrNull(r.sessionLocalId)) return null;
81
+ if (!isStrOrNull(r.status) || !isStrOrNull(r.source)) return null;
82
+ var sessionLocalId = r.sessionLocalId === undefined ? null : r.sessionLocalId;
83
+ if (sessionLocalId !== null && idOrNull(sessionLocalId) === null) return null;
62
84
  // confirmedAt is absent in files written before confirmation existed.
63
85
  var confirmedAt = r.confirmedAt === undefined ? null : r.confirmedAt;
64
86
  if (!isIsoOrNull(confirmedAt)) return null;
@@ -70,7 +92,7 @@ function validRecord(r) {
70
92
  observedAt: r.observedAt,
71
93
  confirmedAt: confirmedAt,
72
94
  source: r.source,
73
- sessionLocalId: r.sessionLocalId,
95
+ sessionLocalId: idOrNull(sessionLocalId),
74
96
  };
75
97
  }
76
98
 
@@ -201,8 +223,8 @@ function createUsageStore(opts) {
201
223
  if (isUnsafeKey(vendor) || isUnsafeKey(info.rateLimitType)) return;
202
224
  meta = meta || {};
203
225
  var now = meta.now !== undefined ? meta.now : Date.now();
204
- var util = typeof info.utilization === "number" ? info.utilization : null;
205
- var resetsAt = info.resetsAt ? toIso(info.resetsAt * 1000) : null;
226
+ var util = finiteOrNull(info.utilization);
227
+ var resetsAt = epochSecondsToIsoOrNull(info.resetsAt);
206
228
  var byBucket = records[vendor] || (records[vendor] = newMap());
207
229
  var prev = byBucket[info.rateLimitType];
208
230
  var utilizationObservedAt = util !== null ? toIso(now) : null;
@@ -218,11 +240,11 @@ function createUsageStore(opts) {
218
240
  utilization: util,
219
241
  utilizationObservedAt: utilizationObservedAt,
220
242
  resetsAt: resetsAt,
221
- status: info.status || null,
243
+ status: strOrNull(info.status) || null,
222
244
  observedAt: toIso(now),
223
245
  confirmedAt: null,
224
- source: meta.source || null,
225
- sessionLocalId: meta.sessionLocalId || null,
246
+ source: strOrNull(meta.source) || null,
247
+ sessionLocalId: idOrNull(meta.sessionLocalId) || null,
226
248
  };
227
249
  seenThisRun[vendor] = true;
228
250
  if (meta.processKey && meta.sessionLocalId && !isUnsafeKey(String(meta.sessionLocalId))) {
@@ -2,7 +2,9 @@
2
2
  // registry so the title and the login command are written once and every
3
3
  // surface (chat message, notification, terminal launcher) agrees.
4
4
 
5
- var registry = require("./yoke").registry;
5
+ var yoke = require("./yoke");
6
+ var registry = yoke.registry;
7
+ var providerCredentials = yoke.providerCredentials;
6
8
 
7
9
  /**
8
10
  * @param {string} vendor a registered vendor id
@@ -19,4 +21,33 @@ function authRequiredFacts(vendor) {
19
21
  };
20
22
  }
21
23
 
22
- module.exports = { authRequiredFacts: authRequiredFacts };
24
+ /**
25
+ * When the agent talks to a cloud provider (Bedrock, Vertex, Foundry) the
26
+ * session's environment selects, an auth-like error is that provider's
27
+ * credentials failing, not a missing sign-in: there is no login to offer.
28
+ * Only an agent that owns the provider's credential group is attributed to it.
29
+ *
30
+ * @param {string} vendor a registered vendor id
31
+ * @param {?object} env the composed environment the session runs with
32
+ * @param {boolean} [osUsers] os-users mode: no settings file is read
33
+ * @returns {?{provider: string, label: string, message: string}}
34
+ */
35
+ function providerAuthFailure(vendor, env, osUsers) {
36
+ if (!registry.isKnown(vendor)) return null;
37
+ var descriptor = registry.get(vendor);
38
+ var seen = typeof descriptor.effectiveRuntimeEnv === "function" ? descriptor.effectiveRuntimeEnv(env, osUsers) : env;
39
+ var provider = providerCredentials.configuredProvider(seen);
40
+ if (!provider) return null;
41
+ var groups = descriptor.credentialGroups || [];
42
+ var owns = groups.some(function (g) { return g.id === provider; });
43
+ if (!owns) return null;
44
+ var label = providerCredentials.PROVIDER_LABELS[provider];
45
+ return {
46
+ provider: provider,
47
+ label: label,
48
+ message: label + " is configured for " + registry.get(vendor).displayName + " on this host, and its credentials failed. " +
49
+ "Check them in Settings (environment) or on the host. Signing in is not the fix.",
50
+ };
51
+ }
52
+
53
+ module.exports = { authRequiredFacts: authRequiredFacts, providerAuthFailure: providerAuthFailure };
package/lib/ws-schema.js CHANGED
@@ -131,7 +131,7 @@ var schema = {
131
131
  "prompt_pending": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt still awaiting the operator, re-presented on connect and session switch; same fields as prompt_request" },
132
132
  "prompt_response": { direction: "c2s", handler: "lib/project-prompt-responses.js", description: "The operator's answer: {requestId, kind, ...} with decision (+ feedback, planContent) for permission/plan, answers or decision:\"skip\" for ask_user (answers keyed by question index; each a label or text, or for a multi-select question the list of chosen labels), action (+ content, held to the requested schema) for elicitation. The kind is required and must match the prompt's. Decision allow_always grants the whole tool (Skill: the one skill) for the rest of the session, and to a permission prompt that carries suppressAlwaysAllowRule settles nothing: the prompt is sent again as prompt_pending. A prompt of the extension kind is never answered this way" },
133
133
  "prompt_resolved": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt was answered: {requestId, kind, decision|answers|skipped|action, source?}; a permission prompt forced by a user ask rule also carries matchedAskRule. source says who answered, as {kind:\"ws\", clientId, user} for a browser connection (clientId is a per-connection label, user the user id or null) or {kind:\"push\", action, user} for a push notification answer; it is absent when the answering path named none. The same source is written to the journal line the settle logs. Prompt content is never part of a source" },
134
- "prompt_cancel": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt ended without an answer: {requestId, kind, reason}; reason is aborted, expired, turn_ended, query_ended, rewind, cleared or shutdown. Reason \"stale\" is sent only to a client whose prompt_response named a prompt the server no longer holds, and is not recorded in history" },
134
+ "prompt_cancel": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt ended without an answer: {requestId, kind, reason, source}; reason is aborted, expired, turn_ended, query_ended, rewind, cleared or shutdown; source says who or what ended it: user, timeout, session_end, daemon_restart, worker, caller:<name> or unspecified (a replayed ending recorded before cancels carried a source). promptState on a replayed request carries the same source for a cancelled prompt. Reason \"stale\" is sent only to a client whose prompt_response named a prompt the server no longer holds, and is not recorded in history" },
135
135
 
136
136
  // Aliases kept for compatibility: the s2c types appear in history recorded
137
137
  // before prompts had one shape (the client maps them onto the prompt_*
@@ -238,6 +238,11 @@ var schema = {
238
238
 
239
239
  // -----------------------------------------------------------------------
240
240
  // Push notifications
241
+ // notification_created, notification_dismissed and notifications_state carry
242
+ // each banner notification with the fields the notification core sets
243
+ // (lib/notify/): key (the collapse identity), collapse ("request"|"session"),
244
+ // persistent (not auto-dismissed) and liveInState (checkable against the
245
+ // live prompts). notifications_state also carries livePrompts. All additive.
241
246
  // -----------------------------------------------------------------------
242
247
  "set_session_prompt_reminders": { direction: "c2s", handler: "lib/project-sessions.js", description: "Turn reminders for a session's unanswered prompts on or off: {sessionId, enabled}" },
243
248
  "notification_prefs": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The user's per-type notification preferences ({prefs: {banner|sound|push: {category: boolean}}, preset, known, categories, presets}); sent on connect and to every connection of the user after a change" },
@@ -8,8 +8,17 @@
8
8
  var registry = require("../registry");
9
9
  var authChecks = require("../auth-checks");
10
10
  var providerCredentials = require("../provider-credentials");
11
+ var claudeSettingsEnv = require("../../claude-settings-env");
11
12
  var claudeCapabilities = require("./claude-capabilities").claudeCapabilities;
12
13
 
14
+ // The provider variables are Claude Code's, read after its settings file's env
15
+ // block is applied; so the classification is declared here, by the agent that
16
+ // reads them.
17
+ // osUsers: the daemon reads no settings file for another account's session.
18
+ function effectiveRuntimeEnv(env, osUsers) {
19
+ return claudeSettingsEnv.applyUserSettingsEnv(env || {}, { osUsers: !!osUsers });
20
+ }
21
+
13
22
  registry.register({
14
23
  id: "claude",
15
24
  displayName: "Claude Code",
@@ -18,8 +27,9 @@ registry.register({
18
27
  binaryNames: ["claude"],
19
28
  probeInstalled: function(ctx) { return ctx.lookupBinary("claude"); },
20
29
  checkAuth: authChecks.checkClaudeAuth,
30
+ effectiveRuntimeEnv: effectiveRuntimeEnv,
21
31
  installHint: "Install Claude Code (npm install -g @anthropic-ai/claude-code), then sign in.",
22
- loginCommand: "claude login",
32
+ loginCommand: "claude auth login",
23
33
  osUsersSupported: true,
24
34
  needsRuntimeEnv: false,
25
35
  perProjectRuntime: false,
@@ -281,6 +281,13 @@ function flattenEvent(raw) {
281
281
  base.yokeType = "message";
282
282
  base.messageRole = raw.type;
283
283
  base.content = raw.message ? raw.message.content : null;
284
+ // The immediate acknowledgement of a run_in_background Agent call is a
285
+ // launch, not an end: the SDK marks it with the structured tool output
286
+ // (status "async_launched"), so the host never has to read the result text.
287
+ var launch = raw.type === "user" ? raw.tool_use_result : null;
288
+ if (launch && typeof launch === "object" && launch.status === "async_launched") {
289
+ base.asyncLaunch = { agentId: typeof launch.agentId === "string" ? launch.agentId : null };
290
+ }
284
291
  return base;
285
292
  }
286
293
 
@@ -4,6 +4,8 @@
4
4
  var execSync = require("child_process").execSync;
5
5
  var codexCommand = require("./codex-command");
6
6
  var providerCredentials = require("./provider-credentials");
7
+ var runtimeEnv = require("../runtime-env");
8
+ var claudeSettingsEnv = require("../claude-settings-env");
7
9
 
8
10
  function parseClaudeAuthStatusJson(out) {
9
11
  if (!out) return null;
@@ -35,8 +37,21 @@ function hasThirdPartyProviderAuth(env) {
35
37
  return null;
36
38
  }
37
39
 
38
- function checkClaudeAuth() {
39
- var provider = hasThirdPartyProviderAuth();
40
+ /**
41
+ * @param {?object} overlay the Settings variables a Claude runtime is started
42
+ * with (sdk-bridge getRuntimeEnvOverlay), or null. The probe reads the same
43
+ * composed environment the spawn gets, never the daemon's alone.
44
+ * @param {boolean} [osUsers] os-users mode: no settings file is read
45
+ */
46
+ function checkClaudeAuth(overlay, osUsers) {
47
+ var env = runtimeEnv.composeRuntimeEnv(process.env, overlay);
48
+ // Claude applies the user settings file's env block over the environment it
49
+ // is handed, so the provider is decided from that, not from the composed
50
+ // environment alone. The probe below runs with the daemon's own environment
51
+ // as before: it only reports whether the daemon user is signed in, and
52
+ // handing it project or shared text would let that text steer which account
53
+ // it asks about.
54
+ var provider = hasThirdPartyProviderAuth(claudeSettingsEnv.applyUserSettingsEnv(env, { osUsers: !!osUsers }));
40
55
  if (provider) {
41
56
  console.log("[yoke] Claude auth via third-party provider: " + provider);
42
57
  return true;
package/lib/yoke/index.js CHANGED
@@ -6,6 +6,9 @@ var instructions = require("./instructions");
6
6
  var registry = require("./registry");
7
7
  var installProbe = require("./install-probe");
8
8
  var capabilities = require("./capabilities");
9
+ var providerCredentials = require("./provider-credentials");
10
+ var runtimeEnv = require("../runtime-env");
11
+ var claudeSettingsEnv = require("../claude-settings-env");
9
12
  // Requiring the vendor modules registers the shipped agents. They are light on
10
13
  // purpose: the adapters themselves are loaded when one is created.
11
14
  require("./adapters/claude-vendor");
@@ -86,14 +89,28 @@ function logAuthCheck(auth) {
86
89
  console.log("[yoke] Auth check: " + Object.keys(auth).map(function(id) { return id + "=" + auth[id]; }).join(" "));
87
90
  }
88
91
 
89
- function checkAuth() {
90
- if (_authCache) return _authCache;
92
+ // The answer depends on the Settings environment a runtime starts with, so the
93
+ // cache holds one answer for one overlay and a different overlay recomputes.
94
+ var _authCacheSig = null;
95
+
96
+ /**
97
+ * @param {?object} [overlay] the Settings variables of the runtime the answer
98
+ * is for (null: the daemon's own environment)
99
+ * @param {boolean} [osUsers] os-users mode: no settings file is read for it
100
+ */
101
+ function checkAuth(overlay, osUsers) {
102
+ // The same overlay answers differently when the settings file is not read,
103
+ // and when the file the classification reads is edited.
104
+ var sig = runtimeEnv.envSignature(overlay) + "\0" + (osUsers ? "os" : "") +
105
+ "\0" + claudeSettingsEnv.settingsFileStamp({ osUsers: !!osUsers });
106
+ if (_authCache && _authCacheSig === sig) return _authCache;
91
107
 
92
108
  var result = {};
93
109
  registry.list().forEach(function(vendor) {
94
- result[vendor.id] = !!vendor.checkAuth();
110
+ result[vendor.id] = !!vendor.checkAuth(overlay || null, !!osUsers);
95
111
  });
96
112
  _authCache = result;
113
+ _authCacheSig = sig;
97
114
  logAuthCheck(_authCache);
98
115
  return _authCache;
99
116
  }
@@ -212,6 +229,7 @@ async function lazyCreateAdapter(adapters, vendor, opts, onInit) {
212
229
  module.exports = {
213
230
  isKnownVendor: isKnownVendor,
214
231
  registry: registry,
232
+ providerCredentials: providerCredentials,
215
233
  resolveCapabilities: capabilities.resolveCapabilities,
216
234
  completeCapabilities: iface.completeCapabilities,
217
235
  detectInstalledVendors: installProbe.detectInstalledVendors,
@@ -87,7 +87,31 @@ function completeProvider(env) {
87
87
  return null;
88
88
  }
89
89
 
90
+ var PROVIDER_LABELS = {
91
+ bedrock: "Amazon Bedrock",
92
+ vertex: "Google Vertex AI",
93
+ foundry: "Microsoft Foundry",
94
+ };
95
+
96
+ /**
97
+ * Which cloud provider the environment SELECTS, whether or not its credential
98
+ * set is complete. completeProvider answers "can it authenticate"; this answers
99
+ * "is it the provider the session talks to", which is what an auth-like error
100
+ * must be attributed to.
101
+ * @param {object} env process.env-shaped
102
+ * @returns {?string} "bedrock" | "vertex" | "foundry" | null
103
+ */
104
+ function configuredProvider(env) {
105
+ if (!env) return null;
106
+ if (env.CLAUDE_CODE_USE_BEDROCK === "1") return "bedrock";
107
+ if (env.CLAUDE_CODE_USE_VERTEX === "1") return "vertex";
108
+ if (env.CLAUDE_CODE_USE_FOUNDRY === "1") return "foundry";
109
+ return null;
110
+ }
111
+
90
112
  module.exports = {
113
+ PROVIDER_LABELS: PROVIDER_LABELS,
114
+ configuredProvider: configuredProvider,
91
115
  CREDENTIAL_GROUPS: CREDENTIAL_GROUPS,
92
116
  groupOf: groupOf,
93
117
  completeProvider: completeProvider,
@@ -104,7 +104,9 @@ function validateCredentialGroups(descriptor) {
104
104
  * detail ({path, version, reason}) is shown beside the agent
105
105
  * recheck optional function(): forget what the probe remembered, so
106
106
  * the next probe looks again (a user installed or updated it)
107
- * checkAuth function() -> boolean
107
+ * checkAuth function(runtimeEnvOverlay, osUsers) -> boolean; the overlay is the
108
+ * Settings variables of the runtime asked about, or null;
109
+ * osUsers is true under os-users mode
108
110
  * installHint string one line telling the user how to install it
109
111
  * loginCommand string the one place the login command is written
110
112
  * osUsersSupported boolean can run under per-user OS isolation; when false the
@@ -123,6 +125,10 @@ function validateCredentialGroups(descriptor) {
123
125
  * be owned by the descriptor
124
126
  * nativeInstructionFiles string[] project instruction files the agent reads
125
127
  * itself, so the console does not inject them again
128
+ * effectiveRuntimeEnv optional function(env, osUsers) -> env; the environment this
129
+ * agent's CLI actually sees, given the composed one
130
+ * (a file the CLI applies over it). Read only to
131
+ * classify, never handed on
126
132
  * interruptMessage string shown when the user stops a turn
127
133
  * capabilityReasons optional object capability key -> the line shown beside a
128
134
  * control this agent has disabled, in place of the
@@ -151,6 +157,7 @@ function register(descriptor) {
151
157
  requireFunction(descriptor, "checkAuth");
152
158
  requireFunction(descriptor, "createAdapter");
153
159
  if (descriptor.recheck !== undefined) requireFunction(descriptor, "recheck");
160
+ if (descriptor.effectiveRuntimeEnv !== undefined) requireFunction(descriptor, "effectiveRuntimeEnv");
154
161
  requireBoolean(descriptor, "osUsersSupported");
155
162
  requireBoolean(descriptor, "needsRuntimeEnv");
156
163
  if (descriptor.capabilityReasons === undefined) descriptor = Object.assign({}, descriptor, { capabilityReasons: {} });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.12.0-beta.1",
6
+ "version": "1.12.0-beta.2",
7
7
  "description": "Self-hosted console for Claude Code and Codex. Multi-user, browser-based, persistent AI sessions.",
8
8
  "bin": {
9
9
  "clagentic-console": "./bin/cli.js"
@@ -61,7 +61,7 @@
61
61
  "Chad (original Clay author)"
62
62
  ],
63
63
  "dependencies": {
64
- "@anthropic-ai/claude-agent-sdk": "0.3.295",
64
+ "@anthropic-ai/claude-agent-sdk": "0.3.318",
65
65
  "@anthropic-ai/sdk": "0.104.2",
66
66
  "@lydell/node-pty": "^1.2.0-beta.3",
67
67
  "ajv": "^8.20.0",
@@ -392,8 +392,22 @@ if (require.main === module) {
392
392
 
393
393
  var REPORTER_PATH = path.join(__dirname, "test-file-completion-reporter.js");
394
394
 
395
+ // --test-timeout bounds each test and also each file as a whole (measured on
396
+ // Node 22: a file of four 1 s tests is cancelled at --test-timeout=2500, as
397
+ // a file, though no test in it ran past 1 s). There is no separate per-file
398
+ // flag, so this one value is the per-file bound: a file that hangs (an open
399
+ // handle, a child that never connects) fails by name instead of stalling the
400
+ // buffered run, and a file whose tests legitimately add up to more than it
401
+ // is cancelled too. A slow file is therefore split, not given a higher
402
+ // bound (prompt-invariants was one file of 10 slow parts, about 12 minutes
403
+ // alone; split into one file per slice each takes about 15 s). 300 s is
404
+ // about 20 times the slowest file measured on a loaded host. A test that
405
+ // needs its own tighter bound sets the `timeout` option on itself.
406
+ var testTimeoutMs = Number(process.env.CHECK_TEST_COUNT_TEST_TIMEOUT_MS) || 300000;
407
+
395
408
  var result = spawnSync(process.execPath, [
396
409
  "--test",
410
+ "--test-timeout=" + testTimeoutMs,
397
411
  "--test-reporter=tap", "--test-reporter-destination=stdout",
398
412
  "--test-reporter=" + REPORTER_PATH, "--test-reporter-destination=stderr",
399
413
  ].concat(files), {