@theronap/agnoclast-mcp 0.9.291 → 0.9.292

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/lib/login.mjs +26 -0
  2. package/package.json +1 -1
package/lib/login.mjs CHANGED
@@ -1,5 +1,7 @@
1
1
  import os from 'node:os'
2
2
  import { spawn } from 'node:child_process'
3
+ import { chmodSync, mkdirSync, writeFileSync } from 'node:fs'
4
+ import { dirname } from 'node:path'
3
5
  import { resolveBase, CANONICAL_BASE } from './diagnose.mjs'
4
6
 
5
7
  // `cortex-mcp login` — get a token without the human copy-pasting one out of the web console.
@@ -45,6 +47,16 @@ function deviceLabel() {
45
47
  return host || `${os.platform()} device`
46
48
  }
47
49
 
50
+ /**
51
+ * Write the token to a private file and touch nothing else. For an agent that wires itself: the token reaches the
52
+ * file without ever being printed, so it stays out of the chat that started this.
53
+ */
54
+ export function saveTokenFile(path, token) {
55
+ mkdirSync(dirname(path), { recursive: true, mode: 0o700 })
56
+ writeFileSync(path, token + '\n', { mode: 0o600 })
57
+ chmodSync(path, 0o600) // writeFileSync's mode applies only to a new file
58
+ }
59
+
48
60
  export async function runLogin(argv = [], version = 'dev') {
49
61
  const base = resolveBase(process.env.CORTEX_URL) || CANONICAL_BASE
50
62
 
@@ -53,6 +65,14 @@ export async function runLogin(argv = [], version = 'dev') {
53
65
  const labelFlag = argv.indexOf('--label')
54
66
  const label = labelFlag !== -1 && argv[labelFlag + 1] ? argv[labelFlag + 1] : deviceLabel()
55
67
 
68
+ const fileFlag = argv.indexOf('--token-file')
69
+ const tokenFile = fileFlag !== -1 ? argv[fileFlag + 1] : null
70
+ if (fileFlag !== -1 && !tokenFile) {
71
+ process.stderr.write('cortex: --token-file needs a path.\n')
72
+ process.exitCode = 1
73
+ return
74
+ }
75
+
56
76
  let start
57
77
  try {
58
78
  const res = await fetch(`${base}/api/device/start`, {
@@ -134,6 +154,12 @@ export async function runLogin(argv = [], version = 'dev') {
134
154
  return
135
155
  }
136
156
 
157
+ if (tokenFile) {
158
+ saveTokenFile(tokenFile, token)
159
+ process.stdout.write(`\n Approved. Your token is in ${tokenFile}. Do not print it.\n`)
160
+ return
161
+ }
162
+
137
163
  process.stdout.write(`\n Approved. Setting up...\n\n`)
138
164
 
139
165
  // Hand the raw token straight to the existing installer. We never write it anywhere ourselves —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/agnoclast-mcp",
3
- "version": "0.9.291",
3
+ "version": "0.9.292",
4
4
  "description": "Connect your AI assistant to Cortex — your org's projects, activity, gaps, and directives, scoped to you.",
5
5
  "type": "module",
6
6
  "bin": {