diff --git a/install-guide/README.md b/install-guide/README.md index 42f336e6..2a08528b 100644 --- a/install-guide/README.md +++ b/install-guide/README.md @@ -20,3 +20,9 @@ Building from source instead (developers): see [android.md](android.md) — the > AgentNet is **one codebase, many surfaces** (Android, VS Code, a local web server). They > share the same core; each guide here is just how to install and launch that one surface. + +## Giving your agent GitHub access + +Want your agent to clone, push, or open PRs? Register a GitHub token once in +**Settings → GitHub**. See **[github-token.md](github-token.md)** — how the token is found and +used (and how agents should discover it, so they don't get stuck looking). diff --git a/install-guide/github-token.md b/install-guide/github-token.md new file mode 100644 index 00000000..64bdcecc --- /dev/null +++ b/install-guide/github-token.md @@ -0,0 +1,78 @@ +# GitHub token — for agents doing git work + +AgentNet lets your agent clone, push, and open PRs on GitHub using a token **you** register +in the app. The token stays on the host (never in the webview, never in chat) and is injected +into the agent's environment when it runs. This page explains how an agent should find and use +it — and what to tell the user when it isn't there. + +## For agents: how to use it + +**Your git is already authenticated.** When AgentNet spawns you, it injects the user's GitHub +token into your environment as `GH_TOKEN` and `GITHUB_TOKEN`, plus a `github.com`-only git +credential helper (`GIT_CONFIG_*`). You do **not** need to put a token in remote URLs. + +Just clone/push over HTTPS: + +```bash +git clone https://github.com//.git +# edit, commit… +git push origin +``` + +The `gh` CLI and any scripts pick up `GH_TOKEN`/`GITHUB_TOKEN` automatically too. Public +clones work with no token at all; the helper only kicks in on a 401 (private repos, pushes). + +### Verify before you assume it's missing + +```bash +# Is a token present in this environment? +test -n "$GH_TOKEN" && echo "token: present" || echo "token: NOT in env" + +# Does auth actually work against the repo you want? +git ls-remote https://github.com//.git >/dev/null 2>&1 \ + && echo "auth: ok" || echo "auth: failed" +``` + +If `GH_TOKEN` is empty in a plain shell, that alone doesn't mean the user never registered +one — a shell you opened yourself may not inherit the injected env. The token is persisted on +the host at: + +``` +~/.agentnet/tokens/github.json # { "token": "ghp_..." } (0600, owner-only) +``` + +(Or `$AGENTNET_HOME/tokens/github.json` if `AGENTNET_HOME` is set.) If that file has a +`token`, auth is available even when your current shell's env is bare — re-run git the way +AgentNet spawns it, or read the token from that file for a one-off command. **Never print the +token, paste it into a URL you log, or copy it into chat.** + +## If there is NO token: tell the user to register one + +When `~/.agentnet/tokens/github.json` is absent (or `git ls-remote` on a private repo returns +`Authentication failed`), the user hasn't added a token yet. Don't guess or ask for it in +chat — point them at the in-app setting: + +> **AgentNet → Settings → GitHub → paste a GitHub token.** +> Create the token at with the **`repo`** scope +> (classic PAT) or an equivalent fine-grained token with Contents + Pull requests +> read/write on the repos you want. Paste it once; it's stored on the device only. + +The same screen shows the current status (`connected · ••••abcd`) and a **Register GitHub +work** action for linking a repo to your agent. + +## Finding the AgentNet source repo + +AgentNet is one codebase, many surfaces. The source lives at: + +``` +https://github.com/IQCoreTeam/AgentNet +``` + +Clone it like any other repo (public, so no token needed to read): + +```bash +git clone https://github.com/IQCoreTeam/AgentNet.git +``` + +Layout: pnpm monorepo — `packages/core` (shared engine), `packages/mcp`, and one folder per +surface under `surfaces/` (`android`, `cli`, `desktop`, `localhost`, `vscode`, `webview`). diff --git a/surfaces/webview/src/i18n/messages.ts b/surfaces/webview/src/i18n/messages.ts index 18d8c428..f32d75dd 100644 --- a/surfaces/webview/src/i18n/messages.ts +++ b/surfaces/webview/src/i18n/messages.ts @@ -70,11 +70,12 @@ export const M = { unlock: { titleBar: m("AgentNet Full Unlock", "에이전트넷 풀 언락", "AgentNet Полная Разблокировка"), progress: m("Unlock_Progress", "잠금해제_진행도", "Прогресс_Разблокировки"), - creatingTitle: m("Setting up", "준비 중", "Подготовка"), - creatingBody: m( - "Creating your wallet. No signature, no payment. This just takes a moment.", - "지갑을 만들고 있어요. 서명도, 결제도 없어요. 잠깐이면 됩니다.", - "Создаём ваш кошелёк. Без подписи, без оплаты. Это займёт мгновение.", + chooseTitle: m("Choose your wallet", "지갑 선택", "Выберите кошелёк"), + chooseStatus: m("Pick_One", "하나_선택", "Выбор"), + chooseBody: m( + "Use the device wallet (no signature, no payment), or connect Phantom. You can switch any time by disconnecting.", + "이 기기 지갑을 쓰거나(서명·결제 없음), Phantom을 연결하세요. 연결 해제하면 언제든 바꿀 수 있어요.", + "Используйте кошелёк устройства (без подписи и оплаты) или подключите Phantom. Отключившись, вы можете сменить его в любой момент.", ), locked: m("Locked", "잠김", "Заблокировано"), fund: { diff --git a/surfaces/webview/src/unlock/UnlockProvider.tsx b/surfaces/webview/src/unlock/UnlockProvider.tsx index 3162169f..45c3d025 100644 --- a/surfaces/webview/src/unlock/UnlockProvider.tsx +++ b/surfaces/webview/src/unlock/UnlockProvider.tsx @@ -2,6 +2,7 @@ import { createContext, useContext, useEffect, useMemo, useRef, useState, type C import { useStore } from "../state/store"; import { HeliusKeyForm } from "../settings/HeliusKeyForm"; import { ConnectDriveForm } from "../settings/ConnectDriveForm"; +import { ConnectWallet } from "../onboarding/ConnectWallet"; import { CheckIcon, LockIcon } from "../icons"; import { useT } from "../i18n"; import { M } from "../i18n/messages"; @@ -10,10 +11,12 @@ import { haptics } from "../haptics"; export type UnlockReason = "skills" | "buy" | "publish" | "comment" | "identity" | "sync"; // The second tutorial: Full Unlock (setup). Opened from Settings or when an action needs it. -// The wallet is auto-created on open (device-local keypair, no signature), so the flow is just -// three optional steps: fund the wallet, back up to cloud, add a market RPC. `creating` is the -// brief auto-create wait before Fund. No pitch, no App_Installed, no signature connect step. -type UnlockScreen = "creating" | "fund" | "cloud" | "advanced" | "done"; +// The wallet is CHOSEN on open (device-local keypair, or Phantom/web wallet) rather than +// silently minted — a returning user who disconnected must be able to pick a different wallet, +// and a present device keypair must not skip the step. After a wallet lands the flow is three +// optional steps: fund the wallet, back up to cloud, add a market RPC. `choose` is the wallet +// picker before Fund. No pitch, no App_Installed step. +type UnlockScreen = "choose" | "fund" | "cloud" | "advanced" | "done"; // Beginner-friendly funding explainer (buy with a card, or transfer from an exchange). One // source of truth, shared by the unlock Fund step and Settings > My Wallet. @@ -24,8 +27,8 @@ type UnlockAction = (walletAddress: string) => void; // Exported so the first-boot Welcome tutorial textures its title bar identically. export const SCANLINES = "repeating-linear-gradient(0deg, rgba(0,0,0,0.11) 0, rgba(0,0,0,0.11) 1px, transparent 1px, transparent 4px)"; -// Three steps: fund 01, cloud 02, rpc 03. `creating` is the pre-step wallet mint (no number). -const SEQ: Record = { creating: "00", fund: "01", cloud: "02", advanced: "03", done: "03" }; +// Three steps: fund 01, cloud 02, rpc 03. `choose` is the pre-step wallet picker (no number). +const SEQ: Record = { choose: "00", fund: "01", cloud: "02", advanced: "03", done: "03" }; // Per-reason unlock title + return-action label; copy lives in the central dictionary. const REASON_COPY = M.unlock.reason; @@ -54,12 +57,12 @@ export function useUnlock(): UnlockContextValue { } export function UnlockProvider({ children }: { children: ReactNode }) { - const { state, send } = useStore(); + const { state } = useStore(); const t = useT(); const unlocked = !!state.walletAddress; const [open, setOpen] = useState(false); const [reason, setReason] = useState("identity"); - const [screen, setScreen] = useState("creating"); + const [screen, setScreen] = useState("choose"); const [celebrating, setCelebrating] = useState(false); const pending = useRef(null); const wasUnlocked = useRef(unlocked); @@ -75,9 +78,11 @@ export function UnlockProvider({ children }: { children: ReactNode }) { }, 1150); } - // Full Unlock. The wallet is created for the user (device-local keypair, no signature): with - // no wallet yet, mint one and wait on `creating` until it lands, then the effect below advances - // to Fund. If a wallet already exists, the gated action just proceeds (nothing to unlock). + // Full Unlock. The user picks a wallet on the `choose` step (device-local keypair, or + // Phantom/web wallet) — we do NOT silently mint one, so a returning user who disconnected can + // switch wallets and a present device keypair never auto-skips this step. Once a wallet lands + // the effect below advances to Fund. If a wallet is already connected, the gated action just + // proceeds (nothing to unlock). function requestUnlock(nextReason: UnlockReason, onUnlocked?: UnlockAction) { if (unlocked && state.walletAddress) { onUnlocked?.(state.walletAddress); @@ -85,16 +90,14 @@ export function UnlockProvider({ children }: { children: ReactNode }) { } pending.current = onUnlocked ?? null; setReason(nextReason); - setScreen("creating"); + setScreen("choose"); setOpen(true); - // Recommended path: a device-local keypair minted server-side. No wallet app, no signature. - send({ type: "makeLocalWallet" }); } useEffect(() => { if (!wasUnlocked.current && unlocked && open) { - // Wallet just created → step 01 (Fund_Wallet), then the optional Cloud_Backup and Market - // RPC before the Unlocked screen. Every step here is skippable. + // Wallet just picked (local or Phantom) → step 01 (Fund_Wallet), then the optional + // Cloud_Backup and Market RPC before the Unlocked screen. Every step here is skippable. setScreen("fund"); haptics.unlock(); } @@ -114,7 +117,7 @@ export function UnlockProvider({ children }: { children: ReactNode }) { function dismiss() { setOpen(false); pending.current = null; - setScreen("creating"); + setScreen("choose"); if (unlocked) startBadgeReveal(); } @@ -154,7 +157,7 @@ export function UnlockProvider({ children }: { children: ReactNode }) { {/* key={screen} remounts the content on each step swap so the icon replays its flicker. */}
- {screen === "creating" && } + {screen === "choose" && } {screen === "fund" && ( @@ -249,16 +252,22 @@ export function LinkRow({ label, sub, href, className = "" }: { label: string; s ); } -// The pre-step wait while the device-local keypair is minted server-side (no signature, no pay). -function CreatingWallet() { +// The pre-step wallet picker. Reuses the canonical ConnectWallet chooser (device-local keypair +// vs Phantom/web wallet) so there is one source of truth for wallet detection and connect — +// no duplicated picker logic here. Both paths end in a `walletConnected` push that flips +// `unlocked`, and the effect above advances to Fund. Shown even when a device keypair already +// exists on disk, so a returning user can deliberately choose Phantom instead. +function ChooseWallet() { const t = useT(); return ( -
- {ICON_FUND} -

>CREATING_WALLET_

-

{t(M.unlock.creatingTitle)}

-

{t(M.unlock.creatingBody)}

- +
+
+ {ICON_FUND} +

>SELECT_WALLET · {t(M.unlock.chooseStatus)}

+

{t(M.unlock.chooseTitle)}

+

{t(M.unlock.chooseBody)}

+
+
); }