clay-server 4.0.0-beta.6 → 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);
@@ -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()
@@ -76,7 +90,7 @@ function attachMessageProcessor(ctx) {
76
90
  sendToSession(session, {
77
91
  type: "auth_required",
78
92
  text: authTitle,
79
- vendor: session.vendor || "claude",
93
+ vendor: vendor,
80
94
  loginCommand: loginCommand,
81
95
  linuxUser: authLinuxUser,
82
96
  canAutoLogin: canAutoLogin,
@@ -88,7 +102,7 @@ function attachMessageProcessor(ctx) {
88
102
  slug: slug,
89
103
  sessionId: session.localId,
90
104
  ownerId: session.ownerId || null,
91
- vendor: session.vendor || "claude",
105
+ vendor: vendor,
92
106
  loginCommand: loginCommand,
93
107
  linuxUser: authLinuxUser,
94
108
  canAutoLogin: canAutoLogin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clay-server",
3
- "version": "4.0.0-beta.6",
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",