@agfpd/iapeer 0.4.113 → 0.4.114

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/package.json +1 -1
  2. package/src/cli/index.ts +30 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agfpd/iapeer",
3
- "version": "0.4.113",
3
+ "version": "0.4.114",
4
4
  "description": "Run Claude Code and Codex CLI as local background agents that message each other, wake on demand, and share one memory.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "agfpd",
package/src/cli/index.ts CHANGED
@@ -530,7 +530,14 @@ export async function defaultRuntime(
530
530
  const index = readPeersIndex({ env })
531
531
  const targets = opts.all === true ? index.peers : index.peers.filter(p => p.personality === opts.peer)
532
532
  if (targets.length === 0) throw new Error(opts.peer ? `peer "${opts.peer}" is not registered` : 'no targets — pass --peer <p> or --all')
533
+ // Cross-peer: strip the caller's identity env (same reason as add-runtime).
534
+ const cleanEnv: NodeJS.ProcessEnv = { ...env }
535
+ delete cleanEnv.PEER_PERSONALITY
536
+ delete cleanEnv.PEER_RUNTIME
537
+ delete cleanEnv.PEER_IDENTITY
538
+ const { initPeer, hasClaudeMcpWiring } = await import('../init/index.ts')
533
539
  const out: DefaultRuntimeOutcome[] = []
540
+ let rewired = false
534
541
  for (const p of targets) {
535
542
  if (isInfraRuntime(p.runtime)) {
536
543
  out.push({ personality: p.personality, action: 'skipped-infra-peer', detail: `default runtime "${p.runtime}" is infra` })
@@ -542,10 +549,6 @@ export async function defaultRuntime(
542
549
  out.push({ personality: p.personality, action: 'failed', detail: `no local profile at ${p.cwd}` })
543
550
  continue
544
551
  }
545
- if (profile.runtime === runtime) {
546
- out.push({ personality: p.personality, action: 'already' })
547
- continue
548
- }
549
552
  if (!profile.runtimes.includes(runtime as Runtime)) {
550
553
  out.push({
551
554
  personality: p.personality,
@@ -554,15 +557,35 @@ export async function defaultRuntime(
554
557
  })
555
558
  continue
556
559
  }
557
- writePeerProfileAtomic(p.cwd, { ...profile, runtime: runtime as Runtime })
558
- out.push({ personality: p.personality, action: 'flipped' })
560
+ // DECLARED ≠ REALIZED (live 2026-10-17: the fleet flipped codex→claude onto peers
561
+ // that declared claude but were never wired — no `.mcp.json` iapeer server, no
562
+ // memory-slot surfaces → claude sessions without send_to_peer). Routing must never
563
+ // sit on an unwired runtime: converge FIRST via initPeer (idempotent: MCP wiring +
564
+ // slot provision for every declared agentic runtime) — also for an ALREADY-flipped
565
+ // peer, so re-running the verb is the repair for a fleet flipped by an older binary.
566
+ let detail: string | undefined
567
+ if (runtime === 'claude' && !hasClaudeMcpWiring(p.cwd)) {
568
+ const warns: string[] = []
569
+ await initPeer({ cwd: p.cwd, runtime: runtime as Runtime, env: cleanEnv, warn: m => warns.push(m) })
570
+ detail = ['declared but not wired — runtime re-provisioned', ...warns].join(' | ')
571
+ rewired = true
572
+ }
573
+ if (profile.runtime === runtime) {
574
+ out.push({ personality: p.personality, action: 'already', detail })
575
+ continue
576
+ }
577
+ // Re-read: initPeer's merge-writer may have touched the profile.
578
+ writePeerProfileAtomic(p.cwd, { ...(readPeerProfile(p.cwd) ?? profile), runtime: runtime as Runtime })
579
+ out.push({ personality: p.personality, action: 'flipped', detail })
559
580
  } catch (e) {
560
581
  out.push({ personality: p.personality, action: 'failed', detail: e instanceof Error ? e.message : String(e) })
561
582
  }
562
583
  }
563
584
  // Self-heal the registry from the flipped locals so routing flips in the same
564
585
  // command (REPLACE projection — the verify --fix rail).
565
- if (out.some(o => o.action === 'flipped')) await reindexFromLocals({ env })
586
+ // initPeer's upsert sets the registry default to the provisioned runtime — reindex
587
+ // after a rewire too, so an `already` peer's registry stays projected from its local.
588
+ if (rewired || out.some(o => o.action === 'flipped')) await reindexFromLocals({ env })
566
589
  return out
567
590
  }
568
591