From 77b52b2480ed648532b2830d08a21fbdfab5babe Mon Sep 17 00:00:00 2001 From: Mohamed Abdelaziz Date: Mon, 25 May 2026 02:58:13 +0300 Subject: [PATCH 01/14] fix: status enum values to uppercase (ACTIVE/INACTIVE) - agent/activate/route.ts: 'active' -> 'ACTIVE' - agent/main/route.ts: 'active' -> 'ACTIVE' - agent/route.ts: 'inactive' -> 'INACTIVE' - lib/agent-flow.ts: AgentStatus type updated to match Prisma enum --- apps/axiomid/src/app/api/agent/activate/route.ts | 2 +- apps/axiomid/src/app/api/agent/main/route.ts | 4 ++-- apps/axiomid/src/app/api/agent/route.ts | 2 +- apps/axiomid/src/lib/agent-flow.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/axiomid/src/app/api/agent/activate/route.ts b/apps/axiomid/src/app/api/agent/activate/route.ts index 3aa907f..91bc019 100644 --- a/apps/axiomid/src/app/api/agent/activate/route.ts +++ b/apps/axiomid/src/app/api/agent/activate/route.ts @@ -47,7 +47,7 @@ export async function POST(request: Request) { const agent = await prisma.userAgent.update({ where: { userId: user.id }, data: { - status: 'active', + status: 'ACTIVE', lastActive: new Date(), }, select: { diff --git a/apps/axiomid/src/app/api/agent/main/route.ts b/apps/axiomid/src/app/api/agent/main/route.ts index 5894b90..b079d8d 100644 --- a/apps/axiomid/src/app/api/agent/main/route.ts +++ b/apps/axiomid/src/app/api/agent/main/route.ts @@ -50,7 +50,7 @@ export async function POST(request: Request) { if (existing) { const updated = await prisma.userAgent.update({ where: { userId: user.id }, - data: { name: name || existing.name, status: 'active', lastActive: new Date() }, + data: { name: name || existing.name, status: 'ACTIVE', lastActive: new Date() }, select: agentSelect, }); @@ -78,7 +78,7 @@ export async function POST(request: Request) { data: { userId: user.id, name: name || 'My Agent', - status: 'active', + status: 'ACTIVE', apiKeyHash, permissions: JSON.stringify(['claim', 'verify']), lastActive: new Date(), diff --git a/apps/axiomid/src/app/api/agent/route.ts b/apps/axiomid/src/app/api/agent/route.ts index e46e5bb..f1f70fd 100644 --- a/apps/axiomid/src/app/api/agent/route.ts +++ b/apps/axiomid/src/app/api/agent/route.ts @@ -62,7 +62,7 @@ export async function POST(request: Request) { data: { userId: user.id, name: name || 'My Agent', - status: 'inactive', + status: 'INACTIVE', apiKeyHash, permissions: JSON.stringify(['claim', 'verify']), }, diff --git a/apps/axiomid/src/lib/agent-flow.ts b/apps/axiomid/src/lib/agent-flow.ts index 17cac94..5b67328 100644 --- a/apps/axiomid/src/lib/agent-flow.ts +++ b/apps/axiomid/src/lib/agent-flow.ts @@ -1,4 +1,4 @@ -export type AgentStatus = 'inactive' | 'active' | 'paused'; +export type AgentStatus = 'INACTIVE' | 'ACTIVE' | 'PAUSED' | 'SLEEPING'; export interface AgentState { id: string; From cef2829181de1cfd37018fa29869667f4fecdc36 Mon Sep 17 00:00:00 2001 From: Mohamed Abdelaziz Date: Mon, 25 May 2026 03:02:53 +0300 Subject: [PATCH 02/14] fix: enable Pi SDK on desktop with sandbox mode --- apps/axiomid/src/app/context/wallet-context.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/axiomid/src/app/context/wallet-context.tsx b/apps/axiomid/src/app/context/wallet-context.tsx index 28a5d76..271b220 100644 --- a/apps/axiomid/src/app/context/wallet-context.tsx +++ b/apps/axiomid/src/app/context/wallet-context.tsx @@ -106,7 +106,7 @@ export function WalletProvider({ children }: { children: ReactNode }) { debug("inIframe", inIframe); debug("hasPi", typeof window !== "undefined" && !!window.Pi); - const usePi = inPiBrowser || (isSandbox && inIframe); + const usePi = inPiBrowser || isSandbox; debug("usePi", usePi); if (usePi) { @@ -188,7 +188,7 @@ export function WalletProvider({ children }: { children: ReactNode }) { const inPiBrowser = detectPiBrowser(); const isSandbox = getSandboxFlag(); const inIframe = typeof window !== "undefined" && window.self !== window.parent; - const isPiEnv = inPiBrowser || (isSandbox && inIframe); + const isPiEnv = inPiBrowser || isSandbox; console.log("[AUTH DEBUG] auto-auth: SANDBOX=", isSandbox, "PiBrowser=", inPiBrowser, "inIframe=", inIframe, "isPiEnv=", isPiEnv); if (isPiEnv) { From dbc1933f9f88779cc12008b0aa2475aced004023 Mon Sep 17 00:00:00 2001 From: Mohamed Abdelaziz Date: Mon, 25 May 2026 03:03:48 +0300 Subject: [PATCH 03/14] fix: detect native Pi SDK + fix scope scopes param --- apps/axiomid/src/app/context/wallet-context.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/axiomid/src/app/context/wallet-context.tsx b/apps/axiomid/src/app/context/wallet-context.tsx index 271b220..92693df 100644 --- a/apps/axiomid/src/app/context/wallet-context.tsx +++ b/apps/axiomid/src/app/context/wallet-context.tsx @@ -50,6 +50,7 @@ const AUTH_TIMEOUT_MS = 15000; function detectPiBrowser(): boolean { if (typeof navigator === "undefined") return false; + if (typeof window !== "undefined" && !!(window as any)?.Pi?.authenticate) return true; return /Pi Browser|minepi/i.test(navigator.userAgent); } @@ -123,7 +124,7 @@ export function WalletProvider({ children }: { children: ReactNode }) { debug("scopes requested:", scopes); const auth = (await withTimeout( pi.authenticate({ - scope: scopes, + scopes, onIncompletePaymentFound: (payment: any) => { console.warn("Incomplete payment:", payment?.identifier); } From c442617e3456fb3aa24ff92fa5dc31e3eb0ac155 Mon Sep 17 00:00:00 2001 From: Mohamed Abdelaziz Date: Mon, 25 May 2026 03:08:56 +0300 Subject: [PATCH 04/14] fix: call Pi.init() before checking Pi.authenticate --- apps/axiomid/src/lib/pi-sdk.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/axiomid/src/lib/pi-sdk.ts b/apps/axiomid/src/lib/pi-sdk.ts index 0e249b3..cd182ea 100644 --- a/apps/axiomid/src/lib/pi-sdk.ts +++ b/apps/axiomid/src/lib/pi-sdk.ts @@ -124,13 +124,15 @@ function injectPiSdkScript(sandbox?: boolean): Promise { async function loadFromCdnWithRetry(sandbox?: boolean): Promise { for (let attempt = 0; attempt < 3; attempt++) { await injectPiSdkScript(sandbox); - if ((window as any)?.Pi?.authenticate) { + if ((window as any)?.Pi?.init) { try { (window as any).Pi.init({ version: "2.0", sandbox: !!sandbox }); } catch { // init may already have been called; safe to ignore } - return; + if ((window as any)?.Pi?.authenticate) { + return; + } } await new Promise((r) => setTimeout(r, 300)); } From abfd68e6730daf66d292d4c8b496ac316f223c77 Mon Sep 17 00:00:00 2001 From: Mohamed Abdelaziz Date: Mon, 25 May 2026 03:11:41 +0300 Subject: [PATCH 05/14] fix: correct Pi SDK init/authenticate API per official docs - pi-sdk.ts: rewritten ensurePiSdk to await Pi.init() before checking Pi.authenticate - wallet-context.tsx: Pi.authenticate(scopes, callback) not object syntax - pi-wallet.ts: same fix - layout.tsx: added