@agentage/cli 0.27.0 → 0.29.0

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.
@@ -50,7 +50,7 @@ const disconnect = async (deps) => {
50
50
  return;
51
51
  }
52
52
  await deps.revoke(links(auth.siteFqdn).auth, auth.tokens.accessToken);
53
- deleteAuth();
53
+ await deleteAuth();
54
54
  console.log('Disconnected - local credentials removed.');
55
55
  };
56
56
  // Validate the stored session instead of trusting mere token presence. Returns true to short-circuit
@@ -29,11 +29,13 @@ export const refreshOrThrow = async (auth, links) => {
29
29
  };
30
30
  auth.tokens = tokens; // the caller retries its request with this in-memory copy
31
31
  // Persist under the lock, folding the new tokens onto the freshly-read state so a concurrent
32
- // writer's other fields (clientId, siteFqdn) are not clobbered by a stale in-memory copy.
32
+ // writer's other fields (clientId, siteFqdn) are not clobbered by a stale in-memory copy. A null
33
+ // re-read means a sign-out won the race: skip the write rather than resurrect it (issue #236).
33
34
  await mutateAuth((current) => {
34
- const base = current ?? auth;
35
- base.tokens = tokens;
36
- return base;
35
+ if (!current)
36
+ return null;
37
+ current.tokens = tokens;
38
+ return current;
37
39
  });
38
40
  };
39
41
  // Boolean shim for the request paths that just want "refresh once, then retry": any failure
@@ -17,5 +17,5 @@ export declare const getConfigDir: () => string;
17
17
  export declare const ensureConfigDir: () => string;
18
18
  export declare const readAuth: () => AuthState | null;
19
19
  export declare const saveAuth: (state: AuthState) => void;
20
- export declare const deleteAuth: () => void;
20
+ export declare const deleteAuth: () => Promise<void>;
21
21
  export declare const mutateAuth: (fn: (current: AuthState | null) => AuthState | null | void) => Promise<AuthState | null>;
@@ -33,10 +33,15 @@ export const saveAuth = (state) => {
33
33
  chmodSync(tmp, 0o600);
34
34
  renameSync(tmp, path);
35
35
  };
36
- export const deleteAuth = () => {
36
+ // Sign-out under the same lock mutateAuth takes (issue #236), so a concurrent token refresh can
37
+ // never slip its re-read+save between this existence check and the unlink.
38
+ export const deleteAuth = async () => {
39
+ ensureConfigDir();
37
40
  const path = authPath();
38
- if (existsSync(path))
39
- unlinkSync(path);
41
+ await withFileLock(path, () => {
42
+ if (existsSync(path))
43
+ unlinkSync(path);
44
+ });
40
45
  };
41
46
  // Cross-process-safe read-modify-write on auth.json (issue #231). Under the advisory lock, re-read
42
47
  // FRESH from disk, apply `fn`, then atomic-save - so a foreground sign-in and a background token
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentage/cli",
3
- "version": "0.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "The agentage CLI - connect this machine to agentage from the terminal",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -41,14 +41,14 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@agentage/memory-core": "^0.5.0",
44
- "@agentage/server-memory": "^0.3.0",
44
+ "@agentage/server-memory": "^0.5.0",
45
45
  "@modelcontextprotocol/sdk": "^1.29.0",
46
46
  "chalk": "^6.0.0",
47
47
  "commander": "^15.0.0",
48
48
  "open": "^11.0.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@anthropic-ai/sdk": "0.116.0",
51
+ "@anthropic-ai/sdk": "0.120.0",
52
52
  "@playwright/test": "latest",
53
53
  "@types/node": "latest",
54
54
  "@typescript-eslint/eslint-plugin": "latest",