myaiforone 1.1.34 → 1.1.35

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.
@@ -46,6 +46,8 @@ Check these prerequisites. If any fail, help the user fix them before continuing
46
46
 
47
47
  Note: Claude Code CLI is already proven to work — the user is running this wizard inside it. No need to check.
48
48
 
49
+ **Claude is optional.** If the user says they won't use Claude (they plan to use Venice, Ollama, or another provider), skip any Claude auth steps and continue. They can add provider API keys in Admin → Settings after setup.
50
+
49
51
  Detect platform via `process.platform` (darwin = Mac, win32 = Windows, linux = Linux).
50
52
 
51
53
  After checks pass, print:
package/bin/cli.js CHANGED
@@ -170,20 +170,7 @@ async function checkClaude() {
170
170
  }
171
171
 
172
172
  console.log(' Claude Code CLI is installed but not authenticated.');
173
- console.log(' Running: claude auth login');
174
- console.log(' A browser window will open — sign in with your Anthropic account.');
175
- console.log('');
176
-
177
- try {
178
- execSync('claude auth login', { stdio: 'inherit' });
179
- } catch {
180
- fail(1,
181
- 'Claude Code authentication failed.',
182
- 'Run "claude auth login" manually. You need a Claude Pro/Max subscription or an Anthropic API key.'
183
- );
184
- }
185
-
186
- stepDone(`Claude Code CLI ${version} (authenticated)`);
173
+ await runClaudeAuth(version);
187
174
  return;
188
175
  }
189
176
 
@@ -204,21 +191,41 @@ async function checkClaude() {
204
191
  const newVersion = run('claude --version', { silent: true }) || 'installed';
205
192
  console.log(` Installed Claude Code CLI ${newVersion}`);
206
193
  console.log('');
207
- console.log(' Now we need to log you in.');
194
+ await runClaudeAuth(newVersion);
195
+ }
196
+
197
+ async function runClaudeAuth(version) {
208
198
  console.log(' Running: claude auth login');
209
- console.log(' A browser window will open — sign in with your Anthropic account.');
199
+ console.log('');
200
+ console.log(' This will either:');
201
+ console.log(' A) Open a browser window automatically — just sign in and come back');
202
+ console.log(' B) Show a URL + ask for a code (common on Windows):');
203
+ console.log(' 1. Copy the URL and open it in your browser');
204
+ console.log(' 2. Sign in and approve access');
205
+ console.log(' 3. Copy the short code shown and paste it back here');
210
206
  console.log('');
211
207
 
212
- try {
213
- execSync('claude auth login', { stdio: 'inherit' });
214
- } catch {
215
- fail(1,
216
- 'Claude Code authentication failed.',
217
- 'Run "claude auth login" manually. You need a Claude Pro/Max subscription or an Anthropic API key.'
218
- );
208
+ let authenticated = false;
209
+ while (!authenticated) {
210
+ try {
211
+ execSync('claude auth login', { stdio: 'inherit' });
212
+ authenticated = true;
213
+ } catch {
214
+ console.log('');
215
+ console.log(' Authentication did not complete.');
216
+ const retry = await ask(' Try again? (y/n) ');
217
+ if (retry.toLowerCase() !== 'y') {
218
+ console.log('');
219
+ console.log(' Skipping Claude authentication. You can run "claude auth login" later.');
220
+ console.log('');
221
+ stepDone('Claude Code CLI (skipped auth)');
222
+ return;
223
+ }
224
+ console.log('');
225
+ }
219
226
  }
220
227
 
221
- stepDone(`Claude Code CLI ${newVersion} (authenticated)`);
228
+ stepDone(`Claude Code CLI ${version} (authenticated)`);
222
229
  }
223
230
 
224
231
  // ── Step 2: Install dependencies ─────────────────────────────────────────────
@@ -1 +1 @@
1
- {"version":3,"file":"web-ui.d.ts","sourceRoot":"","sources":["../src/web-ui.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAa7C,UAAU,YAAY;IACpB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrG,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,qBAAqB,EAAE,aAAa,CAAC,CAAC;CACtE;AAyBD,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAoqLnD"}
1
+ {"version":3,"file":"web-ui.d.ts","sourceRoot":"","sources":["../src/web-ui.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAa7C,UAAU,YAAY;IACpB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrG,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,qBAAqB,EAAE,aAAa,CAAC,CAAC;CACtE;AAyBD,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CA0sLnD"}
package/dist/web-ui.js CHANGED
@@ -5294,41 +5294,84 @@ Project context and credentials are at: ${projectDir}/context.md and ${projectDi
5294
5294
  res.status(500).json({ error: e.message });
5295
5295
  }
5296
5296
  });
5297
- // POST /api/update — clear npx cache and restart with latest version
5297
+ // POST /api/update — update to latest version and restart
5298
5298
  app.post("/api/update", async (_req, res) => {
5299
5299
  try {
5300
5300
  const platform = process.platform;
5301
5301
  log.info("[Update] Platform update triggered via API");
5302
- // Clear npx cache for myaiforone
5303
- const npxDir = platform === "win32"
5304
- ? join(process.env.LOCALAPPDATA || "", "npm-cache", "_npx")
5305
- : join(process.env.HOME || "", ".npm", "_npx");
5306
- if (existsSync(npxDir)) {
5307
- for (const d of readdirSync(npxDir)) {
5308
- const candidate = join(npxDir, d, "node_modules", "myaiforone");
5309
- if (existsSync(candidate)) {
5310
- rmSync(join(npxDir, d), { recursive: true, force: true });
5311
- log.info(`[Update] Cleared npx cache: ${d}`);
5312
- }
5302
+ // Detect if managed by a system service (launchd on Mac, Task Scheduler on Windows)
5303
+ // These services auto-restart the process when it exits, so we just need to update
5304
+ // the global package and exit — no need to spawn a competing npx process.
5305
+ const launchdPlist = join(homedir(), "Library", "LaunchAgents", "com.agenticledger.channelToAgentToClaude.plist");
5306
+ const isMacService = platform === "darwin" && existsSync(launchdPlist);
5307
+ const isWinService = platform === "win32" &&
5308
+ opts.baseDir.includes("node_modules") &&
5309
+ (opts.baseDir.includes("npm") || opts.baseDir.includes("yarn")) &&
5310
+ !opts.baseDir.includes("_npx");
5311
+ const isManagedService = isMacService || isWinService;
5312
+ // NOTE: We intentionally do NOT delete the npx cache here.
5313
+ // Deleting it before the new version downloads can leave the app with no files at all
5314
+ // if the download fails. npx myaiforone@latest already fetches the latest version from
5315
+ // npm automatically — manual cache clearing is unnecessary and was causing data loss.
5316
+ if (isManagedService) {
5317
+ // Try to update the global package so the service manager restarts with new version
5318
+ log.info(`[Update] Managed service detected (${platform}) — running npm install -g myaiforone@latest`);
5319
+ let globalUpdateOk = false;
5320
+ try {
5321
+ execSync("npm install -g myaiforone@latest", { timeout: 120_000, stdio: "ignore" });
5322
+ log.info("[Update] Global install updated successfully");
5323
+ globalUpdateOk = true;
5324
+ }
5325
+ catch (installErr) {
5326
+ log.warn(`[Update] Global install failed: ${installErr.message}`);
5327
+ }
5328
+ if (globalUpdateOk) {
5329
+ res.json({ ok: true, message: "Updated. Service will restart automatically..." });
5330
+ // Just exit — launchd / Task Scheduler will restart with the updated package
5331
+ setTimeout(() => process.exit(0), 1000);
5332
+ }
5333
+ else if (isMacService) {
5334
+ // Permissions issue — unload launchd so it doesn't restart the old version,
5335
+ // then spawn npx to pull and run the latest
5336
+ res.json({ ok: true, message: "Updating via npx (run `sudo npm install -g myaiforone@latest` in Terminal for faster updates)..." });
5337
+ setTimeout(() => {
5338
+ log.info("[Update] Unloading launchd service before npx spawn...");
5339
+ try {
5340
+ execSync(`launchctl unload "${launchdPlist}"`, { timeout: 5_000, stdio: "ignore" });
5341
+ }
5342
+ catch { }
5343
+ const child = cpSpawn("npx", ["myaiforone@latest"], {
5344
+ cwd: process.cwd(),
5345
+ env: { ...process.env },
5346
+ stdio: "ignore",
5347
+ detached: true,
5348
+ shell: true,
5349
+ });
5350
+ child.unref();
5351
+ process.exit(0);
5352
+ }, 1000);
5353
+ }
5354
+ else {
5355
+ // Windows with no write access — nothing we can do automatically
5356
+ res.json({ ok: false, message: "Update failed: permission denied. Run `npm install -g myaiforone@latest` as Administrator." });
5313
5357
  }
5314
5358
  }
5315
5359
  else {
5316
- log.warn(`[Update] npx cache dir not found: ${npxDir}`);
5317
- }
5318
- res.json({ ok: true, message: "Cache cleared. Restarting with latest version..." });
5319
- // Respawn via npx to pull latest, then exit current process
5320
- setTimeout(() => {
5321
- log.info("[Update] Spawning npx myaiforone@latest to pull latest...");
5322
- const child = cpSpawn("npx", ["myaiforone@latest"], {
5323
- cwd: process.cwd(),
5324
- env: { ...process.env },
5325
- stdio: "ignore",
5326
- detached: true,
5327
- shell: true,
5328
- });
5329
- child.unref();
5330
- process.exit(0);
5331
- }, 1000);
5360
+ // Running via npx or direct node — clear cache and spawn new process
5361
+ res.json({ ok: true, message: "Clearing cache and restarting with latest version..." });
5362
+ setTimeout(() => {
5363
+ log.info("[Update] Spawning npx myaiforone@latest...");
5364
+ const child = cpSpawn("npx", ["myaiforone@latest"], {
5365
+ cwd: process.cwd(),
5366
+ env: { ...process.env },
5367
+ stdio: "ignore",
5368
+ detached: true,
5369
+ shell: true,
5370
+ });
5371
+ child.unref();
5372
+ process.exit(0);
5373
+ }, 1000);
5374
+ }
5332
5375
  }
5333
5376
  catch (e) {
5334
5377
  res.status(500).json({ error: e.message });