@absmartly/claude-code-bridge 1.0.0 → 1.0.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 (2) hide show
  1. package/index.js +59 -21
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -23,37 +23,58 @@ const outputBuffers = new Map()
23
23
  function checkClaudeAuth() {
24
24
  try {
25
25
  const credentialsPath = path.join(os.homedir(), '.claude', '.credentials.json')
26
+ const claudeDir = path.join(os.homedir(), '.claude')
26
27
 
27
- if (!fs.existsSync(credentialsPath)) {
28
- return {
29
- authenticated: false,
30
- error: 'Claude CLI not logged in. Run: npx @anthropic-ai/claude-code login'
28
+ if (fs.existsSync(credentialsPath)) {
29
+ const credentials = JSON.parse(fs.readFileSync(credentialsPath, 'utf8'))
30
+
31
+ if (!credentials.claudeAiOauth) {
32
+ return {
33
+ authenticated: false,
34
+ error: 'No Claude OAuth credentials found'
35
+ }
31
36
  }
32
- }
33
37
 
34
- const credentials = JSON.parse(fs.readFileSync(credentialsPath, 'utf8'))
38
+ const { expiresAt, subscriptionType } = credentials.claudeAiOauth
39
+ const isExpired = new Date(expiresAt) < new Date()
40
+
41
+ if (isExpired) {
42
+ return {
43
+ authenticated: false,
44
+ error: `Claude credentials expired at: ${expiresAt}`
45
+ }
46
+ }
35
47
 
36
- if (!credentials.claudeAiOauth) {
37
48
  return {
38
- authenticated: false,
39
- error: 'No Claude OAuth credentials found'
49
+ authenticated: true,
50
+ subscriptionType,
51
+ expiresAt,
52
+ method: 'credentials file'
40
53
  }
41
54
  }
42
55
 
43
- const { expiresAt, subscriptionType } = credentials.claudeAiOauth
44
- const isExpired = new Date(expiresAt) < new Date()
45
-
46
- if (isExpired) {
47
- return {
48
- authenticated: false,
49
- error: `Claude credentials expired at: ${expiresAt}`
56
+ if (fs.existsSync(claudeDir)) {
57
+ const historyPath = path.join(claudeDir, 'history.jsonl')
58
+ const sessionEnvPath = path.join(claudeDir, 'session-env')
59
+
60
+ if (fs.existsSync(historyPath) || fs.existsSync(sessionEnvPath)) {
61
+ const stats = fs.existsSync(historyPath) ? fs.statSync(historyPath) : null
62
+ const recentlyUsed = stats && (Date.now() - stats.mtimeMs) < 24 * 60 * 60 * 1000
63
+
64
+ return {
65
+ authenticated: true,
66
+ subscriptionType: null,
67
+ subscriptionNote: 'For subscription details, run: npx @anthropic-ai/claude-code login',
68
+ method: 'session detection',
69
+ lastActivity: stats ? new Date(stats.mtime).toISOString() : 'unknown',
70
+ recentlyUsed
71
+ }
50
72
  }
51
73
  }
52
74
 
53
75
  return {
54
- authenticated: true,
55
- subscriptionType,
56
- expiresAt
76
+ authenticated: false,
77
+ error: 'Claude CLI not logged in. Run: npx @anthropic-ai/claude-code login'
57
78
  }
58
79
  } catch (error) {
59
80
  return {
@@ -103,8 +124,9 @@ function spawnClaudeForConversation(conversationId, systemPrompt, sessionId, isR
103
124
  '--output-format', 'stream-json',
104
125
  '--input-format', 'stream-json',
105
126
  '--replay-user-messages',
106
- '--permission-mode', 'plan',
127
+ '--permission-mode', 'default',
107
128
  '--tools', '',
129
+ '--strict-mcp-config',
108
130
  '--settings', JSON.stringify({ disableClaudeMd: true })
109
131
  ]
110
132
 
@@ -432,7 +454,23 @@ function tryStartServer(ports, index = 0) {
432
454
  console.log(`\nAuth Status:`)
433
455
  const authStatus = checkClaudeAuth()
434
456
  if (authStatus.authenticated) {
435
- console.log(`✓ Authenticated (${authStatus.subscriptionType} subscription)`)
457
+ if (authStatus.subscriptionType) {
458
+ console.log(`✓ Authenticated (${authStatus.subscriptionType})`)
459
+ } else {
460
+ console.log(`✓ Authenticated`)
461
+ }
462
+ if (authStatus.method) {
463
+ console.log(` Method: ${authStatus.method}`)
464
+ }
465
+ if (authStatus.lastActivity) {
466
+ console.log(` Last activity: ${authStatus.lastActivity}`)
467
+ }
468
+ if (authStatus.expiresAt) {
469
+ console.log(` Expires: ${authStatus.expiresAt}`)
470
+ }
471
+ if (authStatus.subscriptionNote) {
472
+ console.log(` ${authStatus.subscriptionNote}`)
473
+ }
436
474
  } else {
437
475
  console.log(`✗ Not authenticated`)
438
476
  console.log(` ${authStatus.error}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absmartly/claude-code-bridge",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "HTTP bridge server for ABsmartly Extension to communicate with Claude Code CLI",
5
5
  "main": "index.js",
6
6
  "bin": {