@100xprompt/brain 0.1.1 → 0.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@100xprompt/brain",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "One working session, any AI coding tool: move sessions between Claude Code, Codex, Cursor, Gemini CLI, OpenCode and more, keep what projects learned, spend fewer tokens. Runs on Bun. By 100xprompt.",
5
5
  "license": "MIT",
6
6
  "author": "Nipurn Agarwal",
@@ -8,7 +8,7 @@ import { join } from "node:path"
8
8
  import type { Reader } from "../adapters/types.ts"
9
9
  import { toolLabel } from "../brief.ts"
10
10
  import { DEFAULT_MODEL, DEFAULT_ROUTE, type Env, type GatewaySettings, modelName, statePath } from "../gateway/common.ts"
11
- import { CONNECTORS, hasKey, installedHere } from "../gateway/connect.ts"
11
+ import { CONNECTORS, cliAuthPath, hasKey, installedHere } from "../gateway/connect.ts"
12
12
  import { HOOK_TOOLS, hookInstalled } from "../hooks.ts"
13
13
  import { MCP_TOOLS, statusMcp } from "../memory/mcp-install.ts"
14
14
  import { chittaCandidates, memoryDbPath, openMemory } from "../memory/store.ts"
@@ -182,6 +182,20 @@ export async function harnesses(home: string, counts: Record<string, ToolCount>
182
182
  return false
183
183
  }
184
184
  }
185
+ /**
186
+ * The 100xprompt CLI is the gateway's own client: there is nothing for brain to connect, and it is on the gateway
187
+ * whenever it is signed in (its auth.json holds a key; only its presence is looked at). Signed out, it can be
188
+ * (`100xprompt auth login`). Any other tool: undefined, decided by brain's connectors.
189
+ */
190
+ const ownClient = (id: string, h: string, e: Env): Harness["gateway"] | undefined => {
191
+ if (id !== "100xprompt") return undefined
192
+ try {
193
+ const k = JSON.parse(readFileSync(cliAuthPath(h, e), "utf8"))?.["100xprompt"]?.key
194
+ return typeof k === "string" && k.trim() ? "connected" : "available"
195
+ } catch {
196
+ return "available"
197
+ }
198
+ }
185
199
  const known = new Map<string, { label: string; present: boolean }>()
186
200
  const add = (id: string, label: string, present: boolean) => {
187
201
  const k = known.get(id)
@@ -207,7 +221,7 @@ export async function harnesses(home: string, counts: Record<string, ToolCount>
207
221
  label: clip(k.label, 80),
208
222
  sessions: counts?.[id] ? counts[id]!.sessions : null,
209
223
  lastSessionAt: counts?.[id]?.lastSessionAt ?? null,
210
- gateway: connected[id] ? "connected" : connectorIds.has(id) ? "available" : "unsupported",
224
+ gateway: connected[id] ? "connected" : (ownClient(id, home, env) ?? (connectorIds.has(id) ? "available" : "unsupported")),
211
225
  mcp: mcpIds.has(id) ? mcpInstalled.get(id) === true : null,
212
226
  hooks: HOOK_TOOLS.includes(id) ? hookOn(id) : null,
213
227
  }))