openalmanac 0.2.20 → 0.2.22

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.
@@ -9,4 +9,7 @@ export type LoginResult = {
9
9
  * Core login flow shared by CLI and MCP tool.
10
10
  * Checks for existing valid key, otherwise opens browser for auth.
11
11
  */
12
- export declare function performLogin(signal?: AbortSignal): Promise<LoginResult>;
12
+ export declare function performLogin(options?: {
13
+ signal?: AbortSignal;
14
+ forceNew?: boolean;
15
+ }): Promise<LoginResult>;
@@ -153,21 +153,24 @@ function callbackPage(success) {
153
153
  * Core login flow shared by CLI and MCP tool.
154
154
  * Checks for existing valid key, otherwise opens browser for auth.
155
155
  */
156
- export async function performLogin(signal) {
157
- const existingKey = getApiKey();
158
- if (existingKey) {
159
- try {
160
- const resp = await fetch(`${API_BASE}/api/agents/me`, {
161
- headers: { Authorization: `Bearer ${existingKey}` },
162
- signal: AbortSignal.timeout(10_000),
163
- });
164
- if (resp.ok) {
165
- const data = (await resp.json());
166
- return { status: "already_logged_in", name: data.name ?? "unknown" };
156
+ export async function performLogin(options) {
157
+ const { signal, forceNew } = options ?? {};
158
+ if (!forceNew) {
159
+ const existingKey = getApiKey();
160
+ if (existingKey) {
161
+ try {
162
+ const resp = await fetch(`${API_BASE}/api/agents/me`, {
163
+ headers: { Authorization: `Bearer ${existingKey}` },
164
+ signal: AbortSignal.timeout(10_000),
165
+ });
166
+ if (resp.ok) {
167
+ const data = (await resp.json());
168
+ return { status: "already_logged_in", name: data.name ?? "unknown" };
169
+ }
170
+ }
171
+ catch {
172
+ // Key invalid or network error, continue to login
167
173
  }
168
- }
169
- catch {
170
- // Key invalid or network error, continue to login
171
174
  }
172
175
  }
173
176
  const { token, browserOpened } = await new Promise((resolve, reject) => {
package/dist/setup.js CHANGED
@@ -319,12 +319,14 @@ async function runLoginStep(agent, mcpChanged, toolCount) {
319
319
  });
320
320
  }
321
321
  // Check if already logged in
322
+ let forceNew = false;
322
323
  const auth = await getAuthStatus();
323
324
  if (auth.loggedIn) {
324
325
  const keepAccount = await runLoginChoice(auth.name);
325
326
  if (keepAccount) {
326
327
  return { status: "already", name: auth.name };
327
328
  }
329
+ forceNew = true;
328
330
  }
329
331
  // Show prompt before opening browser
330
332
  process.stdout.write("\x1b[2J\x1b[H");
@@ -357,7 +359,7 @@ async function runLoginStep(agent, mcpChanged, toolCount) {
357
359
  // AbortController so we can kill the HTTP server on retry/cancel
358
360
  const controller = new AbortController();
359
361
  // Race login against keypress
360
- const loginPromise = performLogin(controller.signal).then((result) => result.status === "already_logged_in"
362
+ const loginPromise = performLogin({ signal: controller.signal, forceNew }).then((result) => result.status === "already_logged_in"
361
363
  ? { status: "already", name: result.name }
362
364
  : { status: "done" }, () => ({ status: "skipped" }));
363
365
  let keyOnData = null;
@@ -489,7 +491,7 @@ function printResult(agent, loginResult, mcpChanged, toolCount) {
489
491
  stepDone(`${BLUE}Setup complete${RST}`);
490
492
  w("");
491
493
  // Next steps box
492
- const innerW = 52;
494
+ const innerW = 62;
493
495
  const row = (content) => {
494
496
  const padding = Math.max(0, innerW - vis(content));
495
497
  return ` ${BLUE_DIM}\u2502${RST}${content}${" ".repeat(padding)}${BLUE_DIM}\u2502${RST}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openalmanac",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
4
4
  "description": "OpenAlmanac — pull, edit, and push articles to the open knowledge base",
5
5
  "type": "module",
6
6
  "bin": {