Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions install-guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
78 changes: 78 additions & 0 deletions install-guide/github-token.md
Original file line number Diff line number Diff line change
@@ -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/<owner>/<repo>.git
# edit, commit…
git push origin <branch>
```

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/<owner>/<repo>.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 <https://github.com/settings/tokens> 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`).
11 changes: 6 additions & 5 deletions surfaces/webview/src/i18n/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
61 changes: 35 additions & 26 deletions surfaces/webview/src/unlock/UnlockProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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.
Expand All @@ -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<UnlockScreen, string> = { 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<UnlockScreen, string> = { 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;
Expand Down Expand Up @@ -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<UnlockReason>("identity");
const [screen, setScreen] = useState<UnlockScreen>("creating");
const [screen, setScreen] = useState<UnlockScreen>("choose");
const [celebrating, setCelebrating] = useState(false);
const pending = useRef<UnlockAction | null>(null);
const wasUnlocked = useRef(unlocked);
Expand All @@ -75,26 +78,26 @@ 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);
return;
}
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();
}
Expand All @@ -114,7 +117,7 @@ export function UnlockProvider({ children }: { children: ReactNode }) {
function dismiss() {
setOpen(false);
pending.current = null;
setScreen("creating");
setScreen("choose");
if (unlocked) startBadgeReveal();
}

Expand Down Expand Up @@ -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. */}
<div key={screen} className="min-h-0 flex-1 overflow-y-auto px-5 py-5">
{screen === "creating" && <CreatingWallet />}
{screen === "choose" && <ChooseWallet />}
{screen === "fund" && (
<StepScreen step={1} title={t(M.unlock.fund.title)} status={t(M.unlock.fund.status)} detail={t(M.unlock.fund.detail)} icon={ICON_FUND}>
<FundControls address={state.walletAddress ?? ""} onDone={enterCloud} />
Expand Down Expand Up @@ -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 (
<div className="mx-auto max-w-sm py-8 text-center">
<span className="an-term-mono mx-auto grid h-12 w-12 place-items-center border" style={{ borderColor: "var(--an-green)", background: "var(--an-green)", color: "var(--an-on-green)" }}>{ICON_FUND}</span>
<p className="an-term-mono mt-4 text-[10px] uppercase tracking-[0.14em] text-[color:var(--an-fg-dim)]">&gt;CREATING_WALLET<span className="unlock-cursor">_</span></p>
<h3 className="an-term-mono mt-1.5 text-[19px] font-bold uppercase tracking-[0.06em] text-[color:var(--an-fg)]">{t(M.unlock.creatingTitle)}</h3>
<p className="mx-auto mt-2 max-w-xs text-body-dense leading-relaxed text-[color:var(--an-fg-dim)]">{t(M.unlock.creatingBody)}</p>
<span className="mx-auto mt-6 block h-5 w-5 animate-spin rounded-full border-2 border-t-transparent" style={{ borderColor: "var(--an-green)", borderTopColor: "transparent" }} />
<div className="mx-auto max-w-sm py-4">
<div className="text-center">
<span className="an-term-mono mx-auto grid h-12 w-12 place-items-center border" style={{ borderColor: "var(--an-green)", background: "var(--an-green)", color: "var(--an-on-green)" }}>{ICON_FUND}</span>
<p className="an-term-mono mt-4 text-[10px] uppercase tracking-[0.14em] text-[color:var(--an-fg-dim)]">&gt;SELECT_WALLET · <span className="text-[color:var(--an-green)]">{t(M.unlock.chooseStatus)}</span></p>
<h3 className="an-term-mono mt-1.5 text-[19px] font-bold uppercase tracking-[0.06em] text-[color:var(--an-fg)]">{t(M.unlock.chooseTitle)}</h3>
<p className="mx-auto mt-2 max-w-xs text-body-dense leading-relaxed text-[color:var(--an-fg-dim)]">{t(M.unlock.chooseBody)}</p>
</div>
<div className="mt-6"><ConnectWallet embedded /></div>
</div>
);
}
Expand Down
Loading