clay-server 4.0.0-beta.5 → 4.0.0-beta.7

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.
@@ -20,6 +20,7 @@
20
20
  // auth_required forever.
21
21
 
22
22
  var vendorRegistry = require("./yoke/vendor-registry");
23
+ var yoke = require("./yoke");
23
24
 
24
25
  // Login CLIs print a success line and then hand the shell back, so the PTY
25
26
  // itself does not exit. Watch the output stream instead. Deliberately narrow:
@@ -209,6 +210,10 @@ function attachVendorLogin(ctx) {
209
210
  flow.finishing = true;
210
211
  flow.completed = !!succeeded;
211
212
 
213
+ // The next session must not reuse the pre-login "not authenticated"
214
+ // result. Re-check before restarting the runtime, which will then read
215
+ // the newly written credential file.
216
+ if (succeeded) yoke.invalidateAuthCache();
212
217
  var refresh = succeeded ? refreshVendorAuth(vendor) : Promise.resolve(false);
213
218
  refresh.then(function (restarted) {
214
219
  discardFlow(vendor);
@@ -1300,10 +1300,10 @@ export function processMessage(msg) {
1300
1300
  appendDelta((msg.text || "Authentication required.") + "\n");
1301
1301
  setStatus("connected");
1302
1302
  if (!store.get('loopActive')) enableMainInput();
1303
- // Open the login flow for this vendor. The server keeps exactly one
1304
- // login terminal per vendor, so repeat auth_required events (other
1305
- // sessions, split panes, a 401 retry burst) do not stack up.
1306
- autoStartLoginIfNeeded(msg);
1303
+ // Open the login flow only for a live auth failure. Older Clay
1304
+ // versions recorded this transient event in session history; replaying
1305
+ // one must not reopen a login terminal after the user signed in.
1306
+ if (!store.get('replayingHistory')) autoStartLoginIfNeeded(msg);
1307
1307
  break;
1308
1308
 
1309
1309
  case "vendor_login_ready":
@@ -61,6 +61,20 @@ function attachMessageProcessor(ctx) {
61
61
  if (session._lastAuthEmit && (now - session._lastAuthEmit) < 5000) return;
62
62
  session._lastAuthEmit = now;
63
63
 
64
+ // Codex can leave a transient 401 in its app-server event stream after a
65
+ // successful device login. Confirm the CLI's current credential state
66
+ // before interrupting another session with a login modal.
67
+ var vendor = session.vendor || "claude";
68
+ yoke.invalidateAuthCache();
69
+ var authState = yoke.checkAuth();
70
+ if (authState[vendor]) {
71
+ sendAndRecord(session, {
72
+ type: "error",
73
+ text: "Authentication is available, but " + vendor + " reported an auth-like error. Try again.",
74
+ });
75
+ return;
76
+ }
77
+
64
78
  var authUser = session.ownerId ? usersModule.findUserById(session.ownerId) : null;
65
79
  var authLinuxUser = authUser && authUser.linuxUser ? authUser.linuxUser : null;
66
80
  var canAutoLogin = !usersModule.isMultiUser()
@@ -70,10 +84,13 @@ function attachMessageProcessor(ctx) {
70
84
  var authTitle = ((vendorInfo && vendorInfo.displayName) || "Claude Code") + " is not logged in.";
71
85
  var loginCommand = (vendorInfo && vendorInfo.loginCommand) || "claude login";
72
86
  var _nmLogin = getNotificationsModule();
73
- sendAndRecord(session, {
87
+ // Authentication recovery is transient UI state, not transcript content.
88
+ // Recording it makes history replay look like a fresh auth failure and
89
+ // re-opens the login terminal after a successful sign-in.
90
+ sendToSession(session, {
74
91
  type: "auth_required",
75
92
  text: authTitle,
76
- vendor: session.vendor || "claude",
93
+ vendor: vendor,
77
94
  loginCommand: loginCommand,
78
95
  linuxUser: authLinuxUser,
79
96
  canAutoLogin: canAutoLogin,
@@ -85,7 +102,7 @@ function attachMessageProcessor(ctx) {
85
102
  slug: slug,
86
103
  sessionId: session.localId,
87
104
  ownerId: session.ownerId || null,
88
- vendor: session.vendor || "claude",
105
+ vendor: vendor,
89
106
  loginCommand: loginCommand,
90
107
  linuxUser: authLinuxUser,
91
108
  canAutoLogin: canAutoLogin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clay-server",
3
- "version": "4.0.0-beta.5",
3
+ "version": "4.0.0-beta.7",
4
4
  "description": "Self-hosted team workspace for Claude Code and Codex. Multi-user, browser-based, with persistent AI mates.",
5
5
  "bin": {
6
6
  "clay-server": "./bin/cli.js",