Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat(teams): ship the /teams page with live 3D squads, a streaming findings board, the owner console and docs

nirholas0dc35ee03611
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b2f14679c..88d527829 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,8 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Approvals** (`/approvals`): Approve or deny the transfers and swaps your agents paused to ask you about, set auto-approve rules, and review every decision.
- **Docs · Local agent runtime for the desktop app** (`/docs/desktop-local-runtime`): Run agents, paper and live strategies, limit orders and automations on your own machine: keys in the OS keychain, native approvals with the same payload hash as the web flow, a tray menu, and a mascot that shows agent state.
+- **Docs · Specialist teams** (`/docs/teams`): How specialist teams work: the four roles and their permission ceilings, the shared findings board and its live stream, the cite-or-research rule the Trader follows, launch prep you sign yourself, and the full API.
+- **Specialist Teams: four agents, one board** (`/teams`): Assemble a squad of four 3D agents (a Researcher, an Entry scout, a Trader and a Launcher) under one spend policy. They post to a shared live findings board, the Trader only acts on research it can cite, and the Launcher prepares plans you sign yourself.
- **Approve or deny your agent's requests from Telegram and Discord**: When your agent asks before a transfer or a trade, the request now lands in your paired Telegram or Discord chat with the full confirmation table (recipient, amount, asset, chain, risk notes and deadline) and Approve and Deny buttons. Each button is signed for that exact request, your chat and your account, so a changed request, an expired one, a copied button or someone else in a group chat can never trigger it, and pressing Approve twice runs the action once. The chat now also answers /approvals to list everything waiting, /positions for open positions and their live value, /pause to stop one agent and /kill to stop every agent and deny every pending request. A chat can stop your agents but never unfreeze them; that is done on the web. Forwarded messages are never treated as instructions. (`/approvals`) `[feature, security]`
- **Approve your agents' payments from a notification**: Set any agent spend rule to Ask me and the agent now waits for your yes instead of failing. You get a notification with the recipient, amount, token and network spelled out, and can approve or deny right from it, from email, or from the new Approvals inbox. Approving runs exactly what you were shown, once; denying or letting it expire runs nothing. You can also create auto-approve rules for small swaps and transfers to addresses you have paid before, and revoke them any time. (`/approvals`) `[feature]`
- **Coin logos, agent art and IPFS images load again**: Several public IPFS gateways started refusing image and metadata requests from websites this month, which left coin logos, the 3D coin face, agent cards and on-chain agent art blank or broken across the site. Every page and API now reads IPFS content through gateways that still answer, races them so the fastest wins, and quietly rewrites links that point at the refusing gateways, so art that was published long ago still shows up. Images from a host that no longer serves them now fall back to a clean placeholder instead of a broken-image icon. (`/launches`) `[fix, improvement]`
@@ -15,6 +17,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Quieter, cleaner pages: dead links fixed and console errors gone**: We swept every page on three.ws with the browser developer console open and fixed what it found. Links to pages that moved now redirect to where they live today, share buttons always have a destination, 3D viewers decode compressed models on every page, the missing bow animation thumbnail is back on the choreography and gestures pages, and pages full of brand-new coins or agents without a wallet no longer fill the console with errors while they wait for data. (`/gestures`) `[fix]`
- **Run your agents on your own desktop**: The three.ws desktop app can now run agents, strategies, limit orders and automations on your machine. Signing keys stay in your operating system keychain, paper strategies keep working with no account or cloud connection, and every live trade waits for your approval in a native window that shows the exact recipient, amount, asset and chain. A tray menu lists each agent with pause, kill and review, and the mascot shows when an agent is working, waiting for you or in trouble. (`/docs/desktop-local-runtime`) `[feature]`
- **Set up your AI client with one command, and check it with doctor**: Run npx three-ws --claude (or --cursor, --codex, --vscode, --windsurf) and the CLI signs you in, connects three.ws and verifies it, with no prompts. Keys never land in your client's config file, and running it twice changes nothing. New installers at three.ws/cli/install and three.ws/cli/claude come with a checksum and a signature so you can read and verify them before you run them. npx three-ws doctor finds a broken config, an expired sign-in or an unreachable server and tells you the fix. agent status and team show your agents, wallets and teams from the terminal. (`/docs/cli`) `[feature, improvement]`
+- **Specialist teams: four agents that research before they trade**: Assemble a squad of four 3D agents in one click: a Researcher that vets a token and posts a scored verdict, an Entry scout that checks fresh launches against your entry gates, a Trader that quotes, simulates or trades inside one spend policy, and a Launcher that prepares a launch plan for you to sign. They share a live findings board. The Trader only acts on research it can cite, reuses a fresh verdict instead of redoing it, and every refusal is posted with its reason. Only the Trader can ever sign, and only a live trade you confirm. (`/teams`) `[feature]`
## 2026-10-09
diff --git a/STRUCTURE.md b/STRUCTURE.md
index 67818558c..78fb795a7 100644
--- a/STRUCTURE.md
+++ b/STRUCTURE.md
@@ -328,6 +328,7 @@ bottom.
| Meta-Allocator (the ETF of degens) | [pages/meta-allocator.html](pages/meta-allocator.html) + [src/meta-allocator.js](src/meta-allocator.js) `→ /meta-allocator`, brain [api/_lib/meta-allocator.js](api/_lib/meta-allocator.js), endpoint [api/meta-allocator.js](api/meta-allocator.js) | Live (non-custodial planning) | Spreads a budget across the top verified pump.fun leader agents, ranked by risk-adjusted on-chain track record (win rate, realized ROI, peak-to-trough max drawdown from `agent_sniper_positions`) and diversified across derived correlation groups, then returns a rebalance rule. Free-first `llmComplete` shaping with a deterministic same-shape fallback so it never fails. Returns a plan (weights + suggested sizes), never a transaction; users act one leader at a time via [/vaults](pages/vaults.html). Doc: [docs/meta-allocator.md](docs/meta-allocator.md). |
| Alpha-drip (a leader prices their signal latency) | Ladder rules [api/\_lib/alpha-drip.js](api/_lib/alpha-drip.js), fanout half [api/\_lib/copy-drip-runtime.js](api/_lib/copy-drip-runtime.js), measured edge half-life [api/\_lib/alpha-drip-stats.js](api/_lib/alpha-drip-stats.js), endpoint [api/copy/alpha-drip.js](api/copy/alpha-drip.js) `-> /api/copy/alpha-drip`, leader editor [src/alpha-drip-panel.js](src/alpha-drip-panel.js) mounted on [/dashboard/copy](src/dashboard-next/pages/copy.js), copier seat on the trader page [src/copy-panel.js](src/copy-panel.js), schema [api/\_lib/migrations/20260903235500\_copy\_alpha\_drip.sql](api/_lib/migrations/20260903235500_copy_alpha_drip.sql) | Live (off unless a leader turns it on) | The $THREE sink on the copy rail: a leader sets how long each holder tier waits before a copy intent is revealed to them, so the thing being sold is latency rather than only a share of the profit. Two rules are structural and enforced server-side: a higher tier can never wait longer than a lower one, and **a drip delays the reveal, never the record** (the intent row is written in full at fanout time and the public track record is untouched, so there are no hidden trades). The copier is shown the seat their balance buys BEFORE they subscribe, not after; a locked intent renders as a countdown that unlocks in place, and `POST /api/copy/executions` refuses an unreleased one in the same statement that changes its status, so the guard cannot be raced. Tier size caps are applied after the copy engine has sized and gated the order, never before, so the copier's own caps still bind first. The edge half-life the fairness warning judges a ladder against is measured from the leader's own profitable closes, and is null rather than guessed below five of them. Release runs inside [api/cron/copy-fanout.js](api/cron/copy-fanout.js) rather than a second cron, so the release cadence is the fanout cadence. Doc: [docs/alpha-drip.md](docs/alpha-drip.md). Tests: [tests/alpha-drip.test.js](tests/alpha-drip.test.js) |
| Ghost-copy (paper-copy a leader) | [pages/ghost-copy.html](pages/ghost-copy.html) + [src/ghost-copy.js](src/ghost-copy.js) `→ /ghost-copy`, simulator [api/_lib/ghost-copy.js](api/_lib/ghost-copy.js), endpoint [api/pump/ghost-copy.js](api/pump/ghost-copy.js), tests [tests/ghost-copy.test.js](tests/ghost-copy.test.js) | Live (paper only, zero custody) | The bridge between the leaderboard and actually copying someone. Pick a verified trader agent, a budget and a window, and it replays that agent's real closed on-chain round-trips (`agent_sniper_positions`) against a wallet that does not exist, sizing every order through `planCopyOrder`, the SAME function the live [copy-fanout cron](api/cron/copy-fanout.js) uses, so the result is what the copy engine would actually have generated rather than a marketing figure. Deliberately unflattering: P&L per trade is derived from exact chain lamports (never the stored pct column), losing round-trips all count, the ghost wallet has a real cash constraint so capital locked in an open copy blocks the next one, every skip carries a machine reason plus a human sentence, and the leader's still-open positions are marked at THEIR last on-chain quote and reported as unrealized outside the realized headline. Needs no account, no wallet, no signature and no funded signer, so it ships ahead of any custody decision; state lives in the query string so a result is deep-linkable and shareable. Converts into [/vaults](pages/vaults.html) for real money. Doc: [docs/ghost-copy.md](docs/ghost-copy.md). |
+| Specialist teams (four role agents, one board) | Page [pages/teams.html](pages/teams.html) + [src/teams.js](src/teams.js) + [src/teams.css](src/teams.css) `→ /teams` and `/teams/:id`; runtime [api/_lib/teams/](api/_lib/teams/) (roles and ceilings `roles.js`, board `findings.js`, Researcher `research.js`, runners `runtime.js`), endpoints [api/teams/](api/teams/), migration [api/_lib/migrations/20261010120000_teams.sql](api/_lib/migrations/20261010120000_teams.sql), tests [tests/teams-runtime.test.js](tests/teams-runtime.test.js) | Live | Finish order 941. Creating a team provisions a Researcher, Entry, Trader and Launcher agent (3D body, wallet, public page) under one spend policy mirrored onto the Trader's trade limits. Every run posts to `team_findings`; the Trader cites a live research finding or runs research and writes it back (reuse, never redo). Role ceilings are server-enforced and only the Trader can sign, and only a confirmed live trade. The Launcher prepares a native-lane plan and hands off to `/three-launchpad` for the owner to sign. The board streams over SSE. Doc: [docs/teams.md](docs/teams.md). |
| Syndicates (copy-trade as a team) | Board [pages/syndicates.html](pages/syndicates.html) + [src/syndicates.js](src/syndicates.js) `→ /syndicates`, detail [pages/syndicate.html](pages/syndicate.html) + [src/syndicate.js](src/syndicate.js) `→ /syndicates/:slug`, shared [src/syndicate-shared.js](src/syndicate-shared.js) + [src/syndicates.css](src/syndicates.css), trader-profile widget [src/trader-syndicates.js](src/trader-syndicates.js); model [api/_lib/syndicates.js](api/_lib/syndicates.js), guarded follow path [api/_lib/copy-subscribe.js](api/_lib/copy-subscribe.js), endpoints [api/syndicates/](api/syndicates/), migration [api/_lib/migrations/20260929120000_copy_syndicates.sql](api/_lib/migrations/20260929120000_copy_syndicates.sql), tests [tests/syndicates.test.js](tests/syndicates.test.js) | Live (non-custodial) | Roadmap 917 item 12.7. A named team (flag, motto, color) following one to three copyable leaders. Joining creates ordinary `copy_subscriptions` through the same guarded path as a single follow (self-copy refusal, copyable bar, the member's own caps); an existing subscription is linked, never overwritten; a join is all or nothing; leaving stops only what the join created. One team per copier per network. Group P&L, the curve and the rival standing are computed on read from members' real `copy_executions` inside their membership window, priced like the performance fee. The empty board lists today's copyable leaders with whole records. Linked from `/trader/:id`, `/dashboard/copy` and `/play/arena`. Doc: [docs/syndicates.md](docs/syndicates.md). |
| Daily trading quests | [pages/quests.html](pages/quests.html) + [src/quests.js](src/quests.js) `→ /quests`; model [api/_lib/trading-quests.js](api/_lib/trading-quests.js), disarmed $THREE payout [api/_lib/quest-rewards.js](api/_lib/quest-rewards.js), endpoints [api/quests/](api/quests/), trade proof recorded in [api/pump/[action].js](api/pump/[action].js) buy/sell-confirm, migration [api/_lib/migrations/20260929121000_trading_quests.sql](api/_lib/migrations/20260929121000_trading_quests.sql), tests [tests/trading-quests.test.js](tests/trading-quests.test.js), [tests/quest-rewards.test.js](tests/quest-rewards.test.js) | Live (XP + badges); $THREE rewards disarmed | Roadmap 917 item 12.11. Five daily quests scored from proof: verified trades from a linked wallet or owned-agent Co-Pilot, forks, first ghost-copies per leader, acted copy intents, an owned agent's profitable live close. Three a day is a daily clear. XP is an insert-only ledger; badges go to `user_badges`. The $THREE daily-clear reward is complete and tested but inert until `TRADING_QUEST_THREE_REWARDS=on` plus an amount and payout key are set (owner gate). Doc: [docs/trading-quests.md](docs/trading-quests.md). |
| Trader duels (points-only skill predictions) | Board [pages/duels.html](pages/duels.html) + [src/duels.js](src/duels.js) `→ /duels`, detail [pages/duel.html](pages/duel.html) + [src/duel.js](src/duel.js) `→ /duels/:id`, shared [src/duels-shared.js](src/duels-shared.js) + [src/duels.css](src/duels.css), trader-profile widget [src/trader-duels.js](src/trader-duels.js); model [api/_lib/trader-duels.js](api/_lib/trader-duels.js), endpoints [api/duels/](api/duels/), cron [api/cron/duels-tick.js](api/cron/duels-tick.js), migration [api/_lib/migrations/20260930150000_trader_duels.sql](api/_lib/migrations/20260930150000_trader_duels.sql), tests [tests/trader-duels.test.js](tests/trader-duels.test.js) | Live (points only) | Roadmap 917 item 12.6, built free to play: no token, deposit, escrow or payout, and points have no cash value. The cron opens 24h and week duels for neighbouring traders from the rivalry engine, locks calls at window start, and resolves from `agent_sniper_positions` + `agent_strategy_positions` through `computeTraderMetrics`. Ties, empty windows and private/deleted traders void and refund; an idle trader counts as flat. A correct call pays 2x and 15 XP into `trading_quest_completions`; daily 100-point allowance, monthly season board, four badges. One call per user per duel, no calls on your own agent, overdraft and double payout refused by constraints. Linked from `/trader/:id`, `/trade-rooms`, `/quests` and `/play/arena`. Doc: [docs/trader-duels.md](docs/trader-duels.md). |
diff --git a/api/_lib/teams/research.js b/api/_lib/teams/research.js
index 8dc6fb0c0..d39b20b30 100644
--- a/api/_lib/teams/research.js
+++ b/api/_lib/teams/research.js
@@ -85,14 +85,30 @@ export function scoreResearch({ safety, intel, smartMoney }) {
else if (score >= PASS_AT && safety?.verdict === 'allow' && intel && !smartMoney?.sybil_flag && !intel.dev_sold) verdict = 'pass';
else verdict = 'caution';
+ // The summary leads with reasons[0], so a downgraded verdict leads with what
+ // downgraded it rather than with a check that passed.
+ const cause = verdict === 'pass' ? null : downgradeCause({ safety, intel, smartMoney, score });
+ const ordered = cause ? [cause, ...reasons.filter((r) => r !== cause)] : reasons;
+
return {
verdict,
score,
subscores: { safety: safetyScore, quality, smart_money: smScore },
- reasons: reasons.slice(0, 6),
+ reasons: ordered.slice(0, 6),
};
}
+function downgradeCause({ safety, intel, smartMoney, score }) {
+ if (safety?.verdict && safety.verdict !== 'allow') {
+ return safety.reasons?.[0] || `The safety check returned ${safety.verdict}.`;
+ }
+ if (!intel) return 'No intelligence record yet: holder structure and bundle risk are unverified.';
+ if (intel.dev_sold) return 'The creator has sold.';
+ if (smartMoney?.sybil_flag) return 'Most buying comes from one linked wallet cluster.';
+ if (score < PASS_AT) return `Combined score ${score} is below the ${PASS_AT} needed to pass.`;
+ return null;
+}
+
export function researchSummary({ verdict, score, reasons }) {
const label = { pass: 'Pass', caution: 'Caution', avoid: 'Avoid' }[verdict];
const lead = reasons[0] ? ` ${reasons[0]}` : '';
diff --git a/api/_lib/teams/runtime.js b/api/_lib/teams/runtime.js
index 04cbbf2fe..48a9dea53 100644
--- a/api/_lib/teams/runtime.js
+++ b/api/_lib/teams/runtime.js
@@ -490,7 +490,7 @@ function entryFinding(team, member, row, scored, strategy) {
verdict: setup ? 'setup' : 'no_setup',
score: quality,
summary: setup
- ? `Cleared the entry gates with a strategy score of ${scored.score}.`
+ ? `Cleared the entry gates${quality != null ? ` at quality ${Math.round(quality)}/100` : ''}, strategy score ${Number(scored.score).toFixed(2)}.`
: `Did not clear the entry gates (${scored.reasons[0] || 'no reason recorded'}).`,
evidence: {
network: team.network,
diff --git a/data/changelog.json b/data/changelog.json
index 05a991bff..5acb1bf3e 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -29458,6 +29458,15 @@
"feature"
],
"link": "/docs/desktop-local-runtime"
+ },
+ {
+ "date": "2026-10-10",
+ "title": "Specialist teams: four agents that research before they trade",
+ "summary": "Assemble a squad of four 3D agents in one click: a Researcher that vets a token and posts a scored verdict, an Entry scout that checks fresh launches against your entry gates, a Trader that quotes, simulates or trades inside one spend policy, and a Launcher that prepares a launch plan for you to sign. They share a live findings board. The Trader only acts on research it can cite, reuses a fresh verdict instead of redoing it, and every refusal is posted with its reason. Only the Trader can ever sign, and only a live trade you confirm.",
+ "tags": [
+ "feature"
+ ],
+ "link": "/teams"
}
]
}
diff --git a/data/pages.json b/data/pages.json
index b448d236b..99b3c9116 100644
--- a/data/pages.json
+++ b/data/pages.json
@@ -1932,6 +1932,14 @@
"changefreq": "daily",
"added": "2026-09-29"
},
+ {
+ "path": "/teams",
+ "title": "Specialist Teams: four agents, one board",
+ "description": "Assemble a squad of four 3D agents (a Researcher, an Entry scout, a Trader and a Launcher) under one spend policy. They post to a shared live findings board, the Trader only acts on research it can cite, and the Launcher prepares plans you sign yourself.",
+ "priority": 0.7,
+ "changefreq": "daily",
+ "added": "2026-10-10"
+ },
{
"path": "/quests",
"title": "Daily Trading Quests",
@@ -6319,6 +6327,14 @@
"changefreq": "monthly",
"added": "2026-09-29"
},
+ {
+ "path": "/docs/teams",
+ "title": "Docs · Specialist teams",
+ "description": "How specialist teams work: the four roles and their permission ceilings, the shared findings board and its live stream, the cite-or-research rule the Trader follows, launch prep you sign yourself, and the full API.",
+ "priority": 0.6,
+ "changefreq": "monthly",
+ "added": "2026-10-10"
+ },
{
"path": "/docs/trader-duels",
"title": "Docs · Trader duels",
diff --git a/docs/api-reference.md b/docs/api-reference.md
index 81cc1ebed..36981a954 100644
--- a/docs/api-reference.md
+++ b/docs/api-reference.md
@@ -9441,6 +9441,54 @@ Details: [docs/home-privacy.md](./home-privacy.md).
---
+## Specialist teams
+
+A team is four role agents (Researcher, Entry, Trader, Launcher) under one spend policy, sharing a findings board. Concepts, the role table and the trade rule: [docs/teams.md](./teams.md). Page: [/teams](/teams).
+
+Auth: the session cookie (plus `x-csrf-token` on writes) or a bearer token. Reads of a public team are open to anyone; everything else needs the owner. Writes share a limit of 20 an hour, specialist runs 60 every 10 minutes (`429 rate_limited`).
+
+| Method | Path | Body or query | Returns |
+| --- | --- | --- | --- |
+| `GET` | `/api/teams` | | `{ data: [team summary] }`: id, name, status, network, member_count, last_finding_at, roster, page_url |
+| `POST` | `/api/teams` | `{ name, description?, network?: "mainnet" \| "devnet", is_public?, policy? }` | `201 { data: team }` with four provisioned members |
+| `GET` | `/api/teams/:id` | | `{ data: team }` |
+| `PATCH` | `/api/teams/:id` | `{ name?, description?, is_public?, status?: "active" \| "paused", policy? }` | `{ data: team }` |
+| `DELETE` | `/api/teams/:id` | | archives; the agents stay in the account |
+| `GET` | `/api/teams/:id/findings` | `?kind=&subject=&before=&limit=` (limit up to 100) | `{ data: [finding], next_before }` |
+| `GET` | `/api/teams/:id/findings/stream` | `?since=<ISO>` or `Last-Event-ID` | `text/event-stream` |
+| `POST` | `/api/teams/:id/run` | `{ action, role? \| member_id?, input }` | `{ data: result }` |
+| `POST` | `/api/teams/:id/repair` | | `{ data: { created, team } }`: provisions any missing role |
+| `POST` | `/api/teams/:id/members` | `{ agent_id, permissions? }` | `201 { data: { member_id } }`: add a custom specialist (max 4) |
+| `PATCH` | `/api/teams/:id/members/:memberId` | `{ permissions }` | narrows or restores a grant within the role ceiling |
+| `DELETE` | `/api/teams/:id/members/:memberId` | | removes a custom specialist |
+
+**Policy.** `per_trade_sol` (0.001 to 50, default 0.05), `daily_budget_sol` (0.001 to 500, default 0.25), `finding_ttl_seconds` (60 to 86400, default 900), `allow_caution` (default false), and `entry`: `min_quality_score` (0 to 100, default 60), `max_bundle_score` (0 to 1, default 0.5), `require_two_sided_market` (default true), `require_smart_money` (default false), `min_market_cap_usd` and `max_market_cap_usd` (null for no bound). The caps are mirrored onto the Trader agent's trade limits.
+
+**Run actions.**
+
+| `action` | Role | `input` | `data` |
+| --- | --- | --- | --- |
+| `research` | Researcher | `{ mint, refresh? }` | `{ reused, finding }`: reuses a live verdict unless `refresh` |
+| `scan` | Entry | `{ mint? }` | `{ scanned, setups, findings }`, or the one mint's verdict |
+| `trade` | Trader | `{ mint, side: "buy" \| "sell", amount, mode: "quote" \| "simulate" \| "live", slippageBps?, confirm? }` | `{ finding, research, outcome }` |
+| `launch` | Launcher | `{ name, symbol, description? }` | `{ finding, ready, blockers }`; the finding's `evidence.launch_url` opens the prefilled launchpad |
+
+`amount` is SOL for a buy and tokens (or `"max"`) for a sell. A `live` trade needs `confirm: true`, the real-funds agreement (`403 agreement_required` otherwise) and, for a bearer, the `wallet:write` scope. A run on a paused team is `409 paused`; on a team missing a role, `409 not_ready`. A member without the permission is `403 permission_denied`; a grant above the role ceiling is `403 permission_above_role`.
+
+**Finding.** `{ id, team_id, member_id, author_role, kind, subject, subject_kind, verdict, score, summary, evidence, cites, expires_at, receipt_id, created_at }`. `kind` is `research` (`pass`, `caution`, `avoid`), `entry_signal` (`setup`, `no_setup`), `trade` (`quoted`, `simulated`, `executed`, `refused`, `failed`) or `launch_prep` (`ready`, `blocked`). A trade finding's `cites` holds the research finding id it acted on, and its `evidence.research_source` is `reused` or `ran`.
+
+**Stream events.** `hello` `{ team_id, status, network, since }`, `finding` (a finding; the event id is its `created_at`, so a reconnect resumes), `status` `{ status }`, `gone` (archived or no longer visible), and a heartbeat comment every 15 seconds. The server ends a stream after about 280 seconds and `EventSource` reconnects with `Last-Event-ID`.
+
+```js
+const es = new EventSource(`/api/teams/${teamId}/findings/stream`, { withCredentials: true });
+es.addEventListener('finding', (e) => {
+ const f = JSON.parse(e.data);
+ console.log(f.author_role, f.kind, f.verdict, f.summary, f.cites);
+});
+```
+
+---
+
## Pagination
Paginated list endpoints use `limit`/`offset` query parameters unless noted otherwise (each endpoint's own parameter table is authoritative; some small per-user lists, like `/api/agents` and `/api/widgets`, return everything with no pagination).
diff --git a/docs/start-here.md b/docs/start-here.md
index 77d2f11b1..8cde4dba0 100644
--- a/docs/start-here.md
+++ b/docs/start-here.md
@@ -161,6 +161,7 @@ Want the model in your hands rather than on a screen? [Materialize](./materializ
- **Never copied a trader and want to start safely?** → [Copy Coach](./copy-coach.md): a real win shown next to the full record behind it, a ghost copy with fake money, then one tiny copy the server caps and you sign yourself. The coach answers questions from the real numbers on the page and never promises returns
- **Want momentum you can actually check?** → [Sentiment Scout](./sentiment-scout.md): the last hour of pump.fun launches ranked by momentum, every claim linked to the post or read it came from, timestamped, and checked against the chain, with a track record graded against real outcomes
- **Not ready to risk money on a trader yet?** → [Ghost-copy](./ghost-copy.md): paper-copy any verified agent over their real closed on-chain trades and see the equity curve your budget would have had, sized by the same engine that runs live copy trades. No wallet, no signature, no account, and every trade your budget could not reach is listed with the reason
+- **Want a squad that researches before it trades?** → [Specialist teams](./teams.md): four 3D agents (a Researcher, an Entry scout, a Trader and a Launcher) under one spend policy, posting to one live findings board. The Trader only acts on research it can cite, reuses verdicts instead of redoing them, and the Launcher prepares plans you sign yourself
- **Rather copy with a crew?** → [Syndicates](./syndicates.md): a named team that follows the same verified traders together, each member from their own wallet under their own caps. A live group curve from members' real copies, a roster, and a rival on the board. Nothing pooled, nothing custodied, and leaving stops only what joining started
- **Want a reason to show up tomorrow?** → [Daily trading quests](./trading-quests.md): five small goals a day scored from on-chain proof (verified trades, forks, first ghost-copies, acted copy intents, your agent's live wins), with XP, levels, a clear streak and badges
- **Think you can call the winner?** → [Trader duels](./trader-duels.md): free-to-play calls on which of two neighbouring traders books more realized profit over a UTC day or week, resolved from the on-chain ledger. Daily free points (no cash value), XP, a monthly season board and badges
diff --git a/docs/teams.md b/docs/teams.md
new file mode 100644
index 000000000..ea2ab02f4
--- /dev/null
+++ b/docs/teams.md
@@ -0,0 +1,134 @@
+# Specialist teams: four agents, one policy, one board
+
+A specialist team is a squad of four 3D agents that work one market together
+under one spend policy you set. Each specialist has a single job, and all four
+post what they learn to a shared, live **findings board**. The Trader only acts
+on research it can cite from that board, so no trade ever happens on a hunch,
+and no specialist redoes work another one already did.
+
+Pages: [/teams](https://three.ws/teams) (your teams, assemble a new one) ·
+`/teams/<id>` (one team: the squad, the console, the board) · API: `/api/teams`
+
+## The four roles
+
+| Role | Job | What it may do | Signs? |
+| --- | --- | --- | --- |
+| **Researcher** | Vets one token and posts a scored verdict: `pass`, `caution` or `avoid`. | read board, post, research | Never |
+| **Entry** | Scores finished launches against your entry gates and posts the setups worth acting on. | read board, post, scan | Never |
+| **Trader** | Quotes, simulates or trades a token inside the spend policy, citing live research. | read board, post, research, quote, sign trades | Only a live trade you confirm |
+| **Launcher** | Prepares a launch plan for the native launchpad and hands it to you to sign. | read board, post, launch prep | Never |
+
+Every role has a fixed **ceiling**. You can narrow a specialist's grant from
+Settings (for example, take `sign trades` away from the Trader to keep the team
+quote-only), but no grant can ever widen past its role. The server enforces the
+ceiling on every run, whatever a client sends. Only the Trader's ceiling holds
+`trade.execute`, so a Researcher, an Entry scout, a Launcher or a custom
+specialist can never sign anything.
+
+You can add up to four **custom specialists** from agents you already own. Their
+ceiling is every permission except signing.
+
+## How it works
+
+1. **Assemble.** Name the team, pick mainnet or devnet, and set the per trade
+ cap, the daily budget and how long a verdict stays citable (the finding
+ lifetime, 15 minutes by default). three.ws creates four agents in your
+ account, each with a 3D body, a custodial wallet and a public agent page, and
+ writes the caps onto the Trader agent's own trade limits so the platform
+ spend guards enforce them. Nothing is funded and nothing is signed.
+2. **Research.** The Researcher checks the mint's on-chain authorities, its
+ venue, holder structure, bundle risk and smart-money presence, and posts a
+ verdict with a 0 to 100 score and the evidence behind it. A brand-new token
+ with no launch intelligence yet is judged on what is known and capped at
+ `caution`, and the summary says so. If a live verdict on the same mint is
+ already on the board, the Researcher reuses it instead of running again.
+3. **Scout.** The Entry agent scores every launch whose observation window
+ closed in the last two hours (or one mint you name) with the same scorer the
+ sniper uses, against the team's entry gates: minimum quality, maximum bundle
+ score, a two-sided market, smart money, and a market-cap band. It posts the
+ best setups and never trades.
+4. **Trade.** The Trader looks for a live research verdict on the mint. If there
+ is one it cites it; if not, it runs the research itself, posts that verdict
+ to the board, and cites it (reuse, never redo). Then it applies the rule:
+
+ | Research | Buy | Sell |
+ | --- | --- | --- |
+ | `pass` | allowed | allowed |
+ | `caution` | allowed only if the policy allows caution | allowed |
+ | `avoid` | refused | allowed |
+
+ Exits are never blocked by research. Every outcome, including a refusal, is
+ posted as a `trade` finding that names the research it cited. Quote and
+ Simulate never sign. Live signs from the Trader's wallet through the same
+ guarded trade path every agent uses, after you confirm the exact action,
+ amount, mint, network and wallet in a dialog.
+5. **Prepare a launch.** The Launcher checks the native launch lane is open on
+ the team's network, validates the name, ticker and description, and posts a
+ `launch_prep` finding with the lane, fees and a link to the launchpad
+ prefilled with the plan and the Launcher's 3D body as the coin image. You
+ review and sign it there yourself. The Launcher never builds or signs a
+ transaction.
+
+## The findings board
+
+Every finding records who posted it (role and member), its kind (`research`,
+`entry_signal`, `trade`, `launch_prep`), its subject (a mint, or `launch:<TICKER>`),
+a verdict, an optional score, a one-line summary, structured evidence, the
+findings it cites, and when it stops being citable. Expired findings stay on
+the board as history; they just can no longer be cited.
+
+The board streams live. The team page subscribes over Server-Sent Events and
+shows each finding as it lands, pulses the specialist who posted it, and lets
+you jump from a trade to the exact research it cited.
+
+## Visibility
+
+A team is private by default. Making it public opens the team page and its
+board to anyone with the link, read-only. The spend policy, wallet balances and
+trade limits stay visible to the owner only.
+
+## API
+
+All endpoints accept the session cookie (with an `x-csrf-token` header on
+writes) or a bearer token. Errors use the standard `{ error, error_description }`
+body. Full reference: [API reference: specialist teams](./api-reference.md#specialist-teams).
+
+```bash
+# Assemble a devnet team (cookie session shown; a bearer works the same way)
+curl -X POST https://three.ws/api/teams \
+ -H 'content-type: application/json' -H "x-csrf-token: $CSRF" -b cookies.txt \
+ -d '{"name":"Morning desk","network":"devnet","policy":{"per_trade_sol":0.05,"daily_budget_sol":0.25}}'
+
+# Run the Researcher on a mint (reuses a live verdict when one exists)
+curl -X POST https://three.ws/api/teams/$TEAM/run \
+ -H 'content-type: application/json' -H "x-csrf-token: $CSRF" -b cookies.txt \
+ -d '{"action":"research","input":{"mint":"FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump"}}'
+
+# Ask the Trader for a quote: it cites research or runs it first
+curl -X POST https://three.ws/api/teams/$TEAM/run \
+ -H 'content-type: application/json' -H "x-csrf-token: $CSRF" -b cookies.txt \
+ -d '{"action":"trade","input":{"mint":"FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump","side":"buy","amount":0.01,"mode":"quote"}}'
+
+# Watch the board live
+curl -N -b cookies.txt https://three.ws/api/teams/$TEAM/findings/stream
+```
+
+## Limits
+
+- 12 teams per account, 4 custom specialists per team.
+- Per trade cap 0.001 to 50 SOL, daily budget 0.001 to 500 SOL, finding lifetime
+ 1 minute to 24 hours.
+- Writes are limited to 20 an hour and specialist runs to 60 every 10 minutes
+ per account.
+- A live trade needs the signed real-funds agreement, `confirm: true`, and for a
+ bearer token the `wallet:write` scope.
+
+## Where it lives
+
+Runtime [api/_lib/teams/](../api/_lib/teams/) (roles and ceilings, the board,
+research, the runners), endpoints [api/teams/](../api/teams/), migration
+`api/_lib/migrations/20261010120000_teams.sql`, page
+[pages/teams.html](../pages/teams.html) with [src/teams.js](../src/teams.js),
+tests [tests/teams-runtime.test.js](../tests/teams-runtime.test.js). Related:
+[Trading swarms](./swarms.md) pool capital across agents; a team keeps every
+agent in one owner's account.
diff --git a/public/changelog-recent.json b/public/changelog-recent.json
index 67eefbf95..5805e3db1 100644
--- a/public/changelog-recent.json
+++ b/public/changelog-recent.json
@@ -1,11 +1,11 @@
{
- "generated_at": "2026-10-10T06:05:36.959Z",
+ "generated_at": "2026-10-10T06:12:03.237Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
"url": "https://three.ws"
},
- "total": 3893,
+ "total": 3896,
"complete": false,
"full_feed": "/changelog.json",
"entries": [
@@ -29,6 +29,26 @@
"launch"
]
},
+ {
+ "date": "2026-10-10",
+ "type": "launch",
+ "title": "Docs · Specialist teams",
+ "summary": "How specialist teams work: the four roles and their permission ceilings, the shared findings board and its live stream, the cite-or-research rule the Trader follows, launch prep you sign yourself, and the full API.",
+ "link": "/docs/teams",
+ "tags": [
+ "launch"
+ ]
+ },
+ {
+ "date": "2026-10-10",
+ "type": "launch",
+ "title": "Specialist Teams: four agents, one board",
+ "summary": "Assemble a squad of four 3D agents (a Researcher, an Entry scout, a Trader and a Launcher) under one spend policy. They post to a shared live findings board, the Trader only acts on research it can cite, and the Launcher prepares plans you sign yourself.",
+ "link": "/teams",
+ "tags": [
+ "launch"
+ ]
+ },
{
"date": "2026-10-10",
"type": "update",
@@ -102,6 +122,16 @@
"improvement"
]
},
+ {
+ "date": "2026-10-10",
+ "type": "update",
+ "title": "Specialist teams: four agents that research before they trade",
+ "summary": "Assemble a squad of four 3D agents in one click: a Researcher that vets a token and posts a scored verdict, an Entry scout that checks fresh launches against your entry gates, a Trader that quotes, simulates or trades inside one spend policy, and a Launcher that prepares a launch plan for you to sign. They share a live findings board. The Trader only acts on research it can cite, reuses a fresh verdict instead of redoing it, and every refusal is posted with its reason. Only the Trader can ever sign, and only a live trade you confirm.",
+ "link": "/teams",
+ "tags": [
+ "feature"
+ ]
+ },
{
"date": "2026-10-09",
"type": "launch",
@@ -1508,38 +1538,6 @@
"tags": [
"feature"
]
- },
- {
- "date": "2026-09-22",
- "type": "update",
- "title": "Claude and other AI clients can now read your three.ws account and follow guided flows",
- "summary": "Every hosted three.ws MCP server now publishes live, read-only views of your account as resources: your agents, each agent's Solana wallet with balances, limits and freeze state, usage and costs, chat history, runs, open orders, DCA plans and intents, plus the marketplace, the model catalog with prices, your token launches and the x402 service catalog. Clients like Claude Desktop show them in the attachment picker, and a client can subscribe to an agent's wallet to be told the moment a transfer lands. Each server also offers guided prompts, such as get-started, create-agent, setup-wallet, trade, hire-agent and review-costs, that walk you through a flow tool by tool and always show the recipient, amount, token and chain before anything that moves money. A new create_agent tool lets a model create an agent for you, and read_resource gives the same data to clients without a resource reader.",
- "link": "/docs/mcp",
- "tags": [
- "feature",
- "sdk"
- ]
- },
- {
- "date": "2026-09-22",
- "type": "update",
- "title": "The agent economy now pays from thousands of distinct wallets, and only from ones that hold funds",
- "summary": "The x402 ring, the closed loop where three.ws agents pay each other for services, has a pool of 2,000 payer wallets to rotate through instead of a single seed wallet, so on-chain activity reflects many participants rather than one cron. Rotation now checks each wallet's recorded SOL and USDC before handing it a payment and falls back to the seed payer when nothing in the pool can cover the call, so a freshly minted or thinly funded pool never produces failed payments. The funder that keeps the pool topped up only submits transfers its own wallets can pay for, and the ring status endpoint reports how many pool wallets are minted and how many are ready to pay.",
- "link": null,
- "tags": [
- "infra",
- "improvement"
- ]
- },
- {
- "date": "2026-09-21",
- "type": "update",
- "title": "Forge now asks what your model is for",
- "summary": "Under a finished model in Forge there is a new one-tap row: Game, Web, Avatar, Simulation, Print, AR, or Just playing. It is optional, it is remembered in your browser so you are only asked once, and it rides along on your later generations. We are using it to see which kinds of work Forge does well and which it does not, by use, instead of one blended number for everyone. Developers calling the Forge API can send the same thing as a destination field.",
- "link": "/forge",
- "tags": [
- "improvement"
- ]
}
]
}
diff --git a/public/changelog.json b/public/changelog.json
index 2c8ddb14f..9c504d437 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-10-10T06:05:36.855Z",
+ "generated_at": "2026-10-10T06:12:03.140Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -26,6 +26,26 @@
"launch"
]
},
+ {
+ "date": "2026-10-10",
+ "type": "launch",
+ "title": "Docs · Specialist teams",
+ "summary": "How specialist teams work: the four roles and their permission ceilings, the shared findings board and its live stream, the cite-or-research rule the Trader follows, launch prep you sign yourself, and the full API.",
+ "link": "/docs/teams",
+ "tags": [
+ "launch"
+ ]
+ },
+ {
+ "date": "2026-10-10",
+ "type": "launch",
+ "title": "Specialist Teams: four agents, one board",
+ "summary": "Assemble a squad of four 3D agents (a Researcher, an Entry scout, a Trader and a Launcher) under one spend policy. They post to a shared live findings board, the Trader only acts on research it can cite, and the Launcher prepares plans you sign yourself.",
+ "link": "/teams",
+ "tags": [
+ "launch"
+ ]
+ },
{
"date": "2026-10-10",
"type": "update",
@@ -99,6 +119,16 @@
"improvement"
]
},
+ {
+ "date": "2026-10-10",
+ "type": "update",
+ "title": "Specialist teams: four agents that research before they trade",
+ "summary": "Assemble a squad of four 3D agents in one click: a Researcher that vets a token and posts a scored verdict, an Entry scout that checks fresh launches against your entry gates, a Trader that quotes, simulates or trades inside one spend policy, and a Launcher that prepares a launch plan for you to sign. They share a live findings board. The Trader only acts on research it can cite, reuses a fresh verdict instead of redoing it, and every refusal is posted with its reason. Only the Trader can ever sign, and only a live trade you confirm.",
+ "link": "/teams",
+ "tags": [
+ "feature"
+ ]
+ },
{
"date": "2026-10-09",
"type": "launch",
diff --git a/public/changelog.xml b/public/changelog.xml
index 6302ec01c..92fa97e3e 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -22,6 +22,22 @@
<category>launch</category>
<description>Run agents, paper and live strategies, limit orders and automations on your own machine: keys in the OS keychain, native approvals with the same payload hash as the web flow, a tray menu, and a mascot that shows agent state.</description>
</item>
+ <item>
+ <title>Docs · Specialist teams</title>
+ <link>https://three.ws/docs/teams</link>
+ <guid isPermaLink="false">2026-10-10:Docs · Specialist teams</guid>
+ <pubDate>Sat, 10 Oct 2026 12:00:00 GMT</pubDate>
+ <category>launch</category>
+ <description>How specialist teams work: the four roles and their permission ceilings, the shared findings board and its live stream, the cite-or-research rule the Trader follows, launch prep you sign yourself, and the full API.</description>
+ </item>
+ <item>
+ <title>Specialist Teams: four agents, one board</title>
+ <link>https://three.ws/teams</link>
+ <guid isPermaLink="false">2026-10-10:Specialist Teams: four agents, one board</guid>
+ <pubDate>Sat, 10 Oct 2026 12:00:00 GMT</pubDate>
+ <category>launch</category>
+ <description>Assemble a squad of four 3D agents (a Researcher, an Entry scout, a Trader and a Launcher) under one spend policy. They post to a shared live findings board, the Trader only acts on research it can cite, and the Launcher prepares plans you sign yourself.</description>
+ </item>
<item>
<title>Approve or deny your agent's requests from Telegram and Discord</title>
<link>https://three.ws/approvals</link>
@@ -78,6 +94,14 @@
<category>feature</category>
<description>Run npx three-ws --claude (or --cursor, --codex, --vscode, --windsurf) and the CLI signs you in, connects three.ws and verifies it, with no prompts. Keys never land in your client's config file, and running it twice changes nothing. New installers at three.ws/cli/install and three.ws/cli/claude come with a checksum and a signature so you can read and verify them before you run them. npx three-ws doctor finds a broken config, an expired sign-in or an unreachable server and tells you the fix. agent status and team show your agents, wallets and teams from the terminal.</description>
</item>
+ <item>
+ <title>Specialist teams: four agents that research before they trade</title>
+ <link>https://three.ws/teams</link>
+ <guid isPermaLink="false">2026-10-10:Specialist teams: four agents that research before they trade</guid>
+ <pubDate>Sat, 10 Oct 2026 12:00:00 GMT</pubDate>
+ <category>feature</category>
+ <description>Assemble a squad of four 3D agents in one click: a Researcher that vets a token and posts a scored verdict, an Entry scout that checks fresh launches against your entry gates, a Trader that quotes, simulates or trades inside one spend policy, and a Launcher that prepares a launch plan for you to sign. They share a live findings board. The Trader only acts on research it can cite, reuses a fresh verdict instead of redoing it, and every refusal is posted with its reason. Only the Trader can ever sign, and only a live trade you confirm.</description>
+ </item>
<item>
<title>CAD Forge</title>
<link>https://three.ws/cad</link>
diff --git a/public/features.json b/public/features.json
index c6ffcdddf..c2a216ef6 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-10-10T05:45:10.365Z",
+ "generated_at": "2026-10-10T06:12:03.084Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
@@ -2388,6 +2388,16 @@
"tags": [],
"showcase": false
},
+ {
+ "path": "/teams",
+ "title": "Specialist Teams: four agents, one board",
+ "description": "Assemble a squad of four 3D agents (a Researcher, an Entry scout, a Trader and a Launcher) under one spend policy. They post to a shared live findings board, the Trader only acts on research it can cite, and the Launcher prepares plans you sign yourself.",
+ "added": "2026-10-10",
+ "auth": null,
+ "indexable": true,
+ "tags": [],
+ "showcase": false
+ },
{
"path": "/quests",
"title": "Daily Trading Quests",
@@ -4319,6 +4329,16 @@
"tags": [],
"showcase": false
},
+ {
+ "path": "/docs/desktop-local-runtime",
+ "title": "Docs · Local agent runtime for the desktop app",
+ "description": "Run agents, paper and live strategies, limit orders and automations on your own machine: keys in the OS keychain, native approvals with the same payload hash as the web flow, a tray menu, and a mascot that shows agent state.",
+ "added": "2026-10-10",
+ "auth": null,
+ "indexable": true,
+ "tags": [],
+ "showcase": false
+ },
{
"path": "/docs/how-forge-works",
"title": "Docs · How the Forge works, in plain language",
@@ -8169,6 +8189,16 @@
"tags": [],
"showcase": false
},
+ {
+ "path": "/docs/teams",
+ "title": "Docs · Specialist teams",
+ "description": "How specialist teams work: the four roles and their permission ceilings, the shared findings board and its live stream, the cite-or-research rule the Trader follows, launch prep you sign yourself, and the full API.",
+ "added": "2026-10-10",
+ "auth": null,
+ "indexable": true,
+ "tags": [],
+ "showcase": false
+ },
{
"path": "/docs/trader-duels",
"title": "Docs · Trader duels",
diff --git a/public/llms-full.txt b/public/llms-full.txt
index 5b3871899..8f10aa3ea 100644
--- a/public/llms-full.txt
+++ b/public/llms-full.txt
@@ -1418,6 +1418,12 @@ URL: https://three.ws/syndicates
Named teams of copiers who follow the same verified pump.fun trader agents together. Each member copies from their own wallet under their own caps; the team shares a flag, a live equity curve from members' real copies, and a rival on the board. No pooled funds, no custody.
+### Specialist Teams: four agents, one board
+
+URL: https://three.ws/teams
+
+Assemble a squad of four 3D agents (a Researcher, an Entry scout, a Trader and a Launcher) under one spend policy. They post to a shared live findings board, the Trader only acts on research it can cite, and the Launcher prepares plans you sign yourself.
+
### Daily Trading Quests
URL: https://three.ws/quests
@@ -2598,6 +2604,12 @@ URL: https://three.ws/docs/materialize
How to print any three.ws model for real: the printability report, preparation and repair, materials and how pricing is computed, USDC checkout on Solana, the x402 lane an AI agent uses to order manufacturing, on-chain certificates of authenticity, and the fabrication content policy.
+### Docs · Local agent runtime for the desktop app
+
+URL: https://three.ws/docs/desktop-local-runtime
+
+Run agents, paper and live strategies, limit orders and automations on your own machine: keys in the OS keychain, native approvals with the same payload hash as the web flow, a tray menu, and a mascot that shows agent state.
+
### Docs · How the Forge works, in plain language
URL: https://three.ws/docs/how-forge-works
@@ -4908,6 +4920,12 @@ URL: https://three.ws/docs/syndicates
How copy-trading syndicates work: founding around copyable leaders, joining with your own wallet and caps, how the group curve and rival standing are computed from real copies, and the full API.
+### Docs · Specialist teams
+
+URL: https://three.ws/docs/teams
+
+How specialist teams work: the four roles and their permission ceilings, the shared findings board and its live stream, the cite-or-research rule the Trader follows, launch prep you sign yourself, and the full API.
+
### Docs · Trader duels
URL: https://three.ws/docs/trader-duels
diff --git a/public/llms.txt b/public/llms.txt
index 2b736a98c..74ff16694 100644
--- a/public/llms.txt
+++ b/public/llms.txt
@@ -98,6 +98,6 @@ Machine-readable entry points. Fetch these instead of scraping HTML.
## Optional
-- [llms-full.txt](https://three.ws/llms-full.txt): Every public page (947), grouped by section, with full descriptions.
+- [llms-full.txt](https://three.ws/llms-full.txt): Every public page (950), grouped by section, with full descriptions.
- [Sitemap](https://three.ws/sitemap): The same index for people, with search.
- [sitemap.xml](https://three.ws/sitemap.xml): XML sitemap for crawlers, including every agent and avatar page.
diff --git a/public/nav-data.js b/public/nav-data.js
index 19849c71c..f9e22e0fc 100644
--- a/public/nav-data.js
+++ b/public/nav-data.js
@@ -469,6 +469,13 @@ export const NAV_GROUPS = [
href: '/swarms',
desc: 'Pool capital with other agents into one auditable treasury — it trades on reputation-weighted consensus and pays profit back pro-rata on-chain',
},
+ {
+ title: 'Specialist Teams',
+ href: '/teams',
+ badge: 'New',
+ badgeTone: 'new',
+ desc: 'Four 3D agents under one spend policy: a Researcher, an Entry scout, a Trader and a Launcher sharing one live findings board',
+ },
{
title: 'Reputation Staking',
href: '/reputation/market',
diff --git a/public/sitemap/index.html b/public/sitemap/index.html
index 23cb2d94f..1508170d2 100644
--- a/public/sitemap/index.html
+++ b/public/sitemap/index.html
@@ -96,7 +96,7 @@
<main class="sm-wrap">
<div class="sm-hero">
<h1 data-i18n="sitemap_index.sitemap">Sitemap</h1>
- <p><span>999</span> <span data-i18n="sitemap_index.pages_grouped">pages on three.ws, grouped by purpose. Looking for the machine-readable versions?</span></p>
+ <p><span>1002</span> <span data-i18n="sitemap_index.pages_grouped">pages on three.ws, grouped by purpose. Looking for the machine-readable versions?</span></p>
<div class="sm-formats">
<a href="/sitemap.xml" data-i18n-html="sitemap_index.for_search_engines"><code>sitemap.xml</code> · for search engines</a>
<a href="/llms.txt" data-i18n-html="sitemap_index.for_ai_agents"><code>llms.txt</code> · for AI agents</a>
@@ -108,7 +108,7 @@
</div>
<div class="sm-filter">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg>
- <input id="sm-filter-input" type="search" placeholder="Filter 999 pages by name, path, or description…" aria-label="Filter pages" autocomplete="off" spellcheck="false" />
+ <input id="sm-filter-input" type="search" placeholder="Filter 1002 pages by name, path, or description…" aria-label="Filter pages" autocomplete="off" spellcheck="false" />
<kbd id="sm-filter-kbd" aria-hidden="true">/</kbd>
</div>
<p class="sm-filter-count" role="status" aria-live="polite"><span id="sm-filter-count"></span><span id="sm-filter-hint" aria-hidden="true"></span></p>
@@ -116,6 +116,30 @@
<h2 id="sm-new-title" data-i18n-html="sitemap_index.newestfull_changelog">Newest<a class="sm-new-more" href="/changelog">full changelog &rarr;</a></h2>
<p class="sm-section-desc" data-i18n="sitemap_index.the_9_most_recently_launched_pages_straight">The 9 most recently launched pages, straight to the live surface.</p>
<ul class="sm-list">
+ <li>
+ <a href="/teams">
+ <span class="sm-new-date" translate="no">Oct 10, 2026</span>
+ <span class="sm-title"><span data-i18n="sitemap_index.t_teams">Specialist Teams: four agents, one board</span></span>
+ <span class="sm-path" translate="no">/teams</span>
+ <span class="sm-desc" data-i18n="sitemap_index.d_teams">Assemble a squad of four 3D agents (a Researcher, an Entry scout, a Trader and a Launcher) under one spend policy. They post to a shared live findings board, the Trader only acts on research it can cite, and the Launcher prepares plans you sign yourself.</span>
+ </a>
+ </li>
+ <li>
+ <a href="/docs/desktop-local-runtime">
+ <span class="sm-new-date" translate="no">Oct 10, 2026</span>
+ <span class="sm-title"><span data-i18n="sitemap_index.t_docs_desktop_local_runtime">Docs · Local agent runtime for the desktop app</span></span>
+ <span class="sm-path" translate="no">/docs/desktop-local-runtime</span>
+ <span class="sm-desc" data-i18n="sitemap_index.d_docs_desktop_local_runtime">Run agents, paper and live strategies, limit orders and automations on your own machine: keys in the OS keychain, native approvals with the same payload hash as the web flow, a tray menu, and a mascot that shows agent state.</span>
+ </a>
+ </li>
+ <li>
+ <a href="/docs/teams">
+ <span class="sm-new-date" translate="no">Oct 10, 2026</span>
+ <span class="sm-title"><span data-i18n="sitemap_index.t_docs_teams">Docs · Specialist teams</span></span>
+ <span class="sm-path" translate="no">/docs/teams</span>
+ <span class="sm-desc" data-i18n="sitemap_index.d_docs_teams">How specialist teams work: the four roles and their permission ceilings, the shared findings board and its live stream, the cite-or-research rule the Trader follows, launch prep you sign yourself, and the full API.</span>
+ </a>
+ </li>
<li>
<a href="/cad">
<span class="sm-new-date" translate="no">Oct 9, 2026</span>
@@ -164,30 +188,6 @@
<span class="sm-desc" data-i18n="sitemap_index.d_forge_desktop">Download three.ws Forge, the free desktop 3D studio for Windows, Linux and Apple silicon Macs. Turn a photo into a 3D model with open-source generators on your own GPU or the three.ws cloud, chain repair, remeshing, rigging and export in node workflows, import free CC0 models and publish to your three.ws account in one click. Based on Modly (MIT).</span>
</a>
</li>
- <li>
- <a href="/forge/workflows">
- <span class="sm-new-date" translate="no">Oct 9, 2026</span>
- <span class="sm-title"><span data-i18n="sitemap_index.t_forge_workflows">Forge Workflows: Chain 3D Tools into One Run</span></span>
- <span class="sm-path" translate="no">/forge/workflows</span>
- <span class="sm-desc" data-i18n="sitemap_index.d_forge_workflows">A visual workflow builder for the Forge. Link a prompt or a photo to any live 3D engine, then remesh, rig, segment, restyle or make it game-ready, preview it inline, export the GLB and save it to your library, all in one run. Batch many prompts with ForEach, re-run from a failed step without redoing the rest, or generate on your own GPU with Modly. Starts from four templates.</span>
- </a>
- </li>
- <li>
- <a href="/docs/forge-desktop">
- <span class="sm-new-date" translate="no">Oct 9, 2026</span>
- <span class="sm-title"><span data-i18n="sitemap_index.t_docs_forge_desktop">Docs · three.ws Forge for desktop</span></span>
- <span class="sm-path" translate="no">/docs/forge-desktop</span>
- <span class="sm-desc" data-i18n="sitemap_index.d_docs_forge_desktop">How to install and use three.ws Forge, the desktop 3D studio: run it from source or an installer, generate on your own GPU or the three.ws cloud, build node workflows, import CC0 models, sign in and publish to three.ws, and fix common setup problems.</span>
- </a>
- </li>
- <li>
- <a href="/docs/cad-forge">
- <span class="sm-new-date" translate="no">Oct 9, 2026</span>
- <span class="sm-title"><span data-i18n="sitemap_index.t_docs_cad_forge">Docs · CAD Forge (text to parametric CAD)</span></span>
- <span class="sm-path" translate="no">/docs/cad-forge</span>
- <span class="sm-desc" data-i18n="sitemap_index.d_docs_cad_forge">How a sentence becomes a kernel-checked build123d part: the write, build and repair loop, dimension parameters, the design page, the /api/cad HTTP API, the cad_generate and cad_rebuild MCP tools, and the sandbox that runs model-written code.</span>
- </a>
- </li>
</ul>
</section>
<nav class="sm-toc" aria-label="Sections">
@@ -1464,7 +1464,7 @@
<section class="sm-section" id="crypto">
<header>
- <h2><span data-i18n="sitemap_index.section_crypto">Crypto</span><span class="sm-count" data-count>159</span></h2>
+ <h2><span data-i18n="sitemap_index.section_crypto">Crypto</span><span class="sm-count" data-count>160</span></h2>
<p class="sm-section-desc" data-i18n="sitemap_index.on_chain_features_pay_per_call_token">On-chain features: pay-per-call, token launches, vanity wallets.</p>
</header>
<ul class="sm-list">
@@ -1818,6 +1818,13 @@
<span class="sm-desc" data-i18n="sitemap_index.d_syndicates">Named teams of copiers who follow the same verified pump.fun trader agents together. Each member copies from their own wallet under their own caps; the team shares a flag, a live equity curve from members' real copies, and a rival on the board. No pooled funds, no custody.</span>
</a>
</li>
+ <li>
+ <a href="/teams">
+ <span class="sm-title"><span data-i18n="sitemap_index.t_teams">Specialist Teams: four agents, one board</span></span>
+ <span class="sm-path" translate="no">/teams</span>
+ <span class="sm-desc" data-i18n="sitemap_index.d_teams">Assemble a squad of four 3D agents (a Researcher, an Entry scout, a Trader and a Launcher) under one spend policy. They post to a shared live findings board, the Trader only acts on research it can cite, and the Launcher prepares plans you sign yourself.</span>
+ </a>
+ </li>
<li>
<a href="/quests">
<span class="sm-title"><span data-i18n="sitemap_index.t_quests">Daily Trading Quests</span></span>
@@ -2772,7 +2779,7 @@
<section class="sm-section" id="learn">
<header>
- <h2><span data-i18n="sitemap_index.section_learn">Learn</span><span class="sm-count" data-count>462</span></h2>
+ <h2><span data-i18n="sitemap_index.section_learn">Learn</span><span class="sm-count" data-count>464</span></h2>
<p class="sm-section-desc" data-i18n="sitemap_index.docs_tutorials_and_reference">Docs, tutorials, and reference.</p>
</header>
<ul class="sm-list">
@@ -3182,6 +3189,13 @@
<span class="sm-desc" data-i18n="sitemap_index.d_docs_materialize">How to print any three.ws model for real: the printability report, preparation and repair, materials and how pricing is computed, USDC checkout on Solana, the x402 lane an AI agent uses to order manufacturing, on-chain certificates of authenticity, and the fabrication content policy.</span>
</a>
</li>
+ <li>
+ <a href="/docs/desktop-local-runtime">
+ <span class="sm-title"><span data-i18n="sitemap_index.t_docs_desktop_local_runtime">Docs · Local agent runtime for the desktop app</span></span>
+ <span class="sm-path" translate="no">/docs/desktop-local-runtime</span>
+ <span class="sm-desc" data-i18n="sitemap_index.d_docs_desktop_local_runtime">Run agents, paper and live strategies, limit orders and automations on your own machine: keys in the OS keychain, native approvals with the same payload hash as the web flow, a tray menu, and a mascot that shows agent state.</span>
+ </a>
+ </li>
<li>
<a href="/docs/how-forge-works">
<span class="sm-title"><span data-i18n="sitemap_index.t_docs_how_forge_works">Docs · How the Forge works, in plain language</span></span>
@@ -5877,6 +5891,13 @@
<span class="sm-desc" data-i18n="sitemap_index.d_docs_syndicates">How copy-trading syndicates work: founding around copyable leaders, joining with your own wallet and caps, how the group curve and rival standing are computed from real copies, and the full API.</span>
</a>
</li>
+ <li>
+ <a href="/docs/teams">
+ <span class="sm-title"><span data-i18n="sitemap_index.t_docs_teams">Docs · Specialist teams</span></span>
+ <span class="sm-path" translate="no">/docs/teams</span>
+ <span class="sm-desc" data-i18n="sitemap_index.d_docs_teams">How specialist teams work: the four roles and their permission ceilings, the shared findings board and its live stream, the cite-or-research rule the Trader follows, launch prep you sign yourself, and the full API.</span>
+ </a>
+ </li>
<li>
<a href="/docs/trader-duels">
<span class="sm-title"><span data-i18n="sitemap_index.t_docs_trader_duels">Docs · Trader duels</span></span>
diff --git a/src/teams.css b/src/teams.css
index 18c1a3441..7addfc798 100644
--- a/src/teams.css
+++ b/src/teams.css
@@ -167,7 +167,7 @@ textarea.tm-input { min-height: 74px; resize: vertical; }
.tm-member-name { font-weight: 800; font-size: 14px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.tm-member-name:hover { color: var(--tm-accent-2); }
.tm-member-name:focus-visible { outline: 2px solid var(--tm-accent-2); outline-offset: 2px; border-radius: 4px; }
-.tm-member-blurb { font-size: 12px; color: var(--tm-faint); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
+.tm-member-blurb { margin: 0; font-size: 12px; color: var(--tm-faint); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tm-perms { display: flex; flex-wrap: wrap; gap: 4px; }
.tm-perms span { font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: var(--tm-chip); color: var(--tm-dim); }
.tm-perms span.sign { background: color-mix(in srgb, var(--tm-red) 16%, transparent); color: var(--tm-red); }
@@ -176,7 +176,7 @@ textarea.tm-input { min-height: 74px; resize: vertical; }
/* ── workbench ──────────────────────────────────────────────────────── */
.tm-work { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); margin-top: 18px; }
-@media (min-width: 1000px) { .tm-work { grid-template-columns: 400px minmax(0, 1fr); align-items: start; } .tm-work > .tm-console { position: sticky; top: 84px; } }
+@media (min-width: 1000px) { .tm-work:not(.solo) { grid-template-columns: 400px minmax(0, 1fr); align-items: start; } .tm-work > .tm-console { position: sticky; top: 84px; } }
.tm-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.tm-tabs button { appearance: none; font: inherit; font-weight: 700; font-size: 13px; padding: 8px 12px; border-radius: 9px; border: 1px solid var(--tm-line); background: var(--tm-panel-2); color: var(--tm-dim); cursor: pointer; min-height: 38px; display: inline-flex; align-items: center; gap: 7px; transition: border-color var(--tm-fast), color var(--tm-fast), background var(--tm-fast); }
.tm-tabs button::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--role); }
@@ -251,6 +251,13 @@ dialog.tm-dialog[open] { animation: tm-in var(--tm-base) ease both; }
.tm-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(8px); background: var(--tm-text); color: var(--tm-bg); font-size: 13.5px; font-weight: 700; padding: 11px 18px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity var(--tm-base), transform var(--tm-base); z-index: 80; max-width: calc(100vw - 32px); text-align: center; }
.tm-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
+/* settings fieldsets, permission pickers and inline cited findings */
+.tm-fieldset { border: 1px solid var(--tm-line); border-radius: 12px; padding: 14px 16px 16px; margin: 0; display: grid; gap: 12px; min-width: 0; }
+.tm-fieldset > legend { padding: 0 6px; font-size: 13px; font-weight: 600; color: var(--tm-text); display: inline-flex; gap: 8px; align-items: center; }
+.tm-perms-pick { display: grid; gap: 8px; }
+.tm-cited:empty { display: none; }
+.tm-cited > .tm-feed > .tm-finding { border-left: 3px solid var(--role, var(--tm-line)); }
+
@media (prefers-reduced-motion: reduce) {
.tm-card, .tm-finding, dialog.tm-dialog[open], .tm-skel, .tm-live.on i, .tm-spin { animation: none; }
.tm-btn, .tm-card, .tm-stage agent-3d { transition: none; }
diff --git a/src/teams.js b/src/teams.js
new file mode 100644
index 000000000..cf409fb99
--- /dev/null
+++ b/src/teams.js
@@ -0,0 +1,1389 @@
+// /teams and /teams/:id: specialist teams.
+//
+// /teams lists the caller's squads and assembles new ones (POST /api/teams
+// provisions four role agents under one spend policy). /teams/:id shows the
+// squad as four 3D agents, runs each specialist through /api/teams/:id/run,
+// streams the shared findings board over SSE, and edits the policy.
+//
+// Every string that came from a token or an agent (names, symbols, summaries,
+// evidence) is untrusted data and goes through esc() before it touches the DOM.
+
+import { consumeCsrfToken } from './api.js';
+import { agentAvatarGlb } from './shared/agent-3d.js';
+import { resolveDevR2Url } from './shared/dev-r2-proxy.js';
+
+const ROOT = document.getElementById('tmRoot');
+const CONTENT = document.getElementById('tmContent');
+const REDUCED = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
+
+const FIXED = ['researcher', 'entry', 'trader', 'launcher'];
+const ROLE_TITLE = { researcher: 'Researcher', entry: 'Entry', trader: 'Trader', launcher: 'Launcher', custom: 'Specialist' };
+const ROLE_PITCH = {
+ researcher: 'Vets a token and posts a scored verdict the whole squad cites.',
+ entry: 'Scores finished launches against your entry gates and posts setups. Never trades.',
+ trader: 'Quotes, simulates or trades inside the spend policy, only on research it can cite.',
+ launcher: 'Prepares a launch plan for you to review and sign. Never launches on its own.',
+};
+const KIND_LABEL = { research: 'Research', entry_signal: 'Entry signal', trade: 'Trade', launch_prep: 'Launch prep' };
+const VERDICT_TONE = {
+ pass: 'good', caution: 'warn', avoid: 'bad',
+ setup: 'good', no_setup: '',
+ quoted: 'info', simulated: 'info', executed: 'good', refused: 'bad', failed: 'bad',
+ ready: 'good', blocked: 'warn',
+};
+const STATUS_TONE = { active: 'good', paused: 'warn', provisioning: 'info', failed: 'bad', archived: '' };
+const PERM_SHORT = {
+ 'findings.read': 'read board',
+ 'findings.write': 'post',
+ 'research.run': 'research',
+ 'signals.scan': 'scan',
+ 'trade.quote': 'quote',
+ 'trade.execute': 'sign trades',
+ 'launch.prepare': 'launch prep',
+};
+const FILTERS = [['', 'All'], ['research', 'Research'], ['entry_signal', 'Entry'], ['trade', 'Trades'], ['launch_prep', 'Launch']];
+const PAGE = 30;
+
+// ── small helpers ────────────────────────────────────────────────────────────
+
+const $ = (sel, root = document) => root.querySelector(sel);
+const $$ = (sel, root = document) => [...root.querySelectorAll(sel)];
+const esc = (v) => String(v ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
+const short = (a) => (typeof a === 'string' && a.length > 12 ? `${a.slice(0, 4)}…${a.slice(-4)}` : a || '');
+const label = (s) => String(s || '').replace(/_/g, ' ').replace(/^./, (c) => c.toUpperCase());
+const num = (n, digits = 4) => Number(n).toLocaleString(undefined, { maximumFractionDigits: digits });
+const sol = (n) => (n == null || !Number.isFinite(Number(n)) ? 'n/a' : `${num(n)} SOL`);
+const roleVar = (role) => `--role:var(--role-${FIXED.includes(role) ? role : 'custom'})`;
+
+function ago(iso) {
+ if (!iso) return 'never';
+ const s = Math.max(0, (Date.now() - new Date(iso).getTime()) / 1000);
+ if (s < 45) return 'just now';
+ if (s < 3600) return `${Math.round(s / 60)}m ago`;
+ if (s < 86_400) return `${Math.round(s / 3600)}h ago`;
+ return new Date(iso).toLocaleDateString();
+}
+
+function timeLeft(iso) {
+ const ms = new Date(iso).getTime() - Date.now();
+ if (!(ms > 0)) return null;
+ const s = Math.floor(ms / 1000);
+ if (s < 60) return `${s}s`;
+ const m = Math.floor(s / 60);
+ if (m < 60) return `${m}m ${s % 60}s`;
+ return `${Math.floor(m / 60)}h ${m % 60}m`;
+}
+
+async function api(url, { method = 'GET', body } = {}) {
+ const opts = { method, credentials: 'include', headers: { accept: 'application/json' } };
+ if (body !== undefined) {
+ opts.headers['content-type'] = 'application/json';
+ opts.body = JSON.stringify(body);
+ }
+ if (method !== 'GET') {
+ const token = await consumeCsrfToken().catch(() => null);
+ if (token) opts.headers['x-csrf-token'] = token;
+ }
+ let r;
+ try {
+ r = await fetch(url, opts);
+ } catch {
+ return { ok: false, status: 0, code: 'network', message: 'Could not reach three.ws. Check your connection and try again.' };
+ }
+ let j = null;
+ try {
+ j = await r.json();
+ } catch {
+ j = null;
+ }
+ if (!r.ok) {
+ return {
+ ok: false,
+ status: r.status,
+ code: j?.error || 'error',
+ message: j?.error_description || j?.message || `Request failed (${r.status}).`,
+ detail: j?.detail || null,
+ };
+ }
+ return { ok: true, status: r.status, data: j?.data ?? null, body: j };
+}
+
+async function currentUser() {
+ try {
+ const r = await fetch('/api/auth/me', { credentials: 'include' });
+ if (!r.ok) return null;
+ const d = await r.json();
+ return d?.user || null;
+ } catch {
+ return null;
+ }
+}
+
+let toastTimer = 0;
+function toast(msg) {
+ const el = $('#tmToast');
+ el.textContent = msg;
+ el.classList.add('show');
+ clearTimeout(toastTimer);
+ toastTimer = setTimeout(() => el.classList.remove('show'), 3600);
+}
+
+function confirmDialog({ title, html, okLabel = 'Confirm', tone = 'primary' }) {
+ const dlg = $('#tmConfirm');
+ $('#tmConfirmTitle').textContent = title;
+ $('#tmConfirmBody').innerHTML = html;
+ const ok = $('#tmConfirmOk');
+ ok.textContent = okLabel;
+ ok.className = `tm-btn ${tone}`;
+ dlg.returnValue = '';
+ return new Promise((resolve) => {
+ dlg.addEventListener('close', () => resolve(dlg.returnValue === 'ok'), { once: true });
+ dlg.showModal();
+ });
+}
+
+function errorHtml(e) {
+ const signIn = e.status === 401
+ ? ` <a href="/login?next=${encodeURIComponent(location.pathname)}">Sign in again</a>.`
+ : '';
+ const agree = e.code === 'agreement_required'
+ ? `<p style="margin:10px 0 0"><a class="tm-btn sm primary" href="/legal/agreements?next=${encodeURIComponent(location.pathname)}">Sign the real-funds agreement</a></p>`
+ : '';
+ return `<div class="tm-err" role="alert">${esc(e.message)}${signIn}${agree}</div>`;
+}
+
+function busy(btn, text) {
+ const prev = btn.innerHTML;
+ btn.disabled = true;
+ btn.innerHTML = `<span class="tm-spin" aria-hidden="true"></span>${esc(text)}`;
+ return () => {
+ btn.disabled = false;
+ btn.innerHTML = prev;
+ };
+}
+
+function wireSeg(root) {
+ for (const seg of $$('.tm-seg[data-seg]', root)) {
+ seg.addEventListener('click', (e) => {
+ const b = e.target.closest('button[data-v]');
+ if (!b) return;
+ for (const x of $$('button', seg)) x.setAttribute('aria-pressed', String(x === b));
+ seg.dataset.value = b.dataset.v;
+ seg.dispatchEvent(new CustomEvent('seg-change', { detail: b.dataset.v }));
+ });
+ }
+}
+
+function seg(name, options, value) {
+ return `<div class="tm-seg" role="group" aria-label="${esc(name)}" data-seg="${esc(name)}" data-value="${esc(value)}">${options
+ .map(([v, text]) => `<button type="button" data-v="${esc(v)}" aria-pressed="${v === value}">${esc(text)}</button>`)
+ .join('')}</div>`;
+}
+
+// Broken thumbnails fall back to the role initial instead of a broken image.
+document.addEventListener('error', (e) => {
+ const img = e.target;
+ if (!(img instanceof HTMLImageElement) || !img.dataset.fallback) return;
+ const span = document.createElement('span');
+ span.className = img.dataset.fallbackClass || 'tm-ava';
+ span.textContent = img.dataset.fallback;
+ span.setAttribute('aria-hidden', 'true');
+ img.replaceWith(span);
+}, true);
+
+function done() {
+ ROOT.setAttribute('aria-busy', 'false');
+}
+
+// ── /teams ───────────────────────────────────────────────────────────────────
+
+function heroHtml(compact) {
+ return `
+ <section class="tm-hero">
+ <p class="tm-kicker">Specialist teams</p>
+ <h1 class="tm-title">Four agents. One policy. One board.</h1>
+ <p class="tm-sub">A team is a squad of four 3D agents that work one market together. They post everything they learn to a shared findings board, and the Trader only acts on research it can cite, inside a spend policy you set.</p>
+ ${compact ? '' : ''}
+ <ul class="tm-roles">
+ ${FIXED.map((r) => `<li style="${roleVar(r)}"><b>${ROLE_TITLE[r]}</b>${esc(ROLE_PITCH[r])}</li>`).join('')}
+ </ul>
+ </section>`;
+}
+
+function createFormHtml() {
+ return `
+ <form class="tm-panel tm-form" id="tmCreate" novalidate aria-labelledby="tmCreateH">
+ <h2 class="tm-h2" id="tmCreateH">Assemble a team</h2>
+ <label class="tm-field"><span class="tm-label">Team name</span>
+ <input class="tm-input" name="name" maxlength="60" required autocomplete="off" placeholder="Morning desk" /></label>
+ <label class="tm-field"><span class="tm-label">What it works on (optional)</span>
+ <textarea class="tm-input" name="description" maxlength="500" placeholder="New launches with a two-sided market and no bundles."></textarea></label>
+ <div class="tm-field"><span class="tm-label">Network</span>
+ ${seg('Network', [['mainnet', 'Mainnet'], ['devnet', 'Devnet']], 'mainnet')}
+ <span class="tm-hint">Devnet runs on test SOL. A live mainnet trade also needs the signed real-funds agreement.</span></div>
+ <div class="tm-grid2">
+ <label class="tm-field"><span class="tm-label">Per trade (SOL)</span>
+ <input class="tm-input" name="per_trade_sol" type="number" inputmode="decimal" min="0.001" max="50" step="0.001" value="0.05" required /></label>
+ <label class="tm-field"><span class="tm-label">Daily budget (SOL)</span>
+ <input class="tm-input" name="daily_budget_sol" type="number" inputmode="decimal" min="0.001" max="500" step="0.001" value="0.25" required /></label>
+ </div>
+ <label class="tm-field"><span class="tm-label">Finding lifetime (minutes)</span>
+ <input class="tm-input" name="ttl_minutes" type="number" inputmode="numeric" min="1" max="1440" step="1" value="15" required />
+ <span class="tm-hint">How long a verdict stays citable. After that the Trader researches the mint again.</span></label>
+ <label class="tm-check"><input type="checkbox" name="allow_caution" /> Let the Trader buy on a "caution" verdict, not only on a "pass".</label>
+ <label class="tm-check"><input type="checkbox" name="is_public" /> Make the team page and its board public.</label>
+ <div id="tmCreateErr"></div>
+ <button class="tm-btn primary" type="submit">Assemble four agents</button>
+ <p class="tm-hint">Creates four agents you own, each with a 3D body, a wallet and a public page. Nothing is funded and nothing is signed.</p>
+ </form>`;
+}
+
+function rosterHtml(roster) {
+ return (roster || []).slice(0, 5).map((r) => {
+ const initial = esc((ROLE_TITLE[r.role] || r.role || '?')[0]);
+ const style = roleVar(r.role);
+ return r.thumbnail_url
+ ? `<img class="tm-ava" style="${style}" src="${esc(resolveDevR2Url(r.thumbnail_url))}" alt="${esc(r.name || ROLE_TITLE[r.role])}" loading="lazy" decoding="async" data-fallback="${initial}" />`
+ : `<span class="tm-ava" style="${style}" aria-hidden="true">${initial}</span>`;
+ }).join('');
+}
+
+function teamCardHtml(t) {
+ const statusTone = STATUS_TONE[t.status] ?? '';
+ return `
+ <li><a class="tm-card" href="${esc(t.page_url)}">
+ <span class="tm-roster" aria-hidden="true">${rosterHtml(t.roster)}</span>
+ <span style="min-width:0">
+ <span class="tm-card-name">${esc(t.name)}</span>
+ <span class="tm-card-meta">
+ <span>${t.member_count} ${t.member_count === 1 ? 'agent' : 'agents'}</span>
+ <span>${esc(label(t.network))}</span>
+ <span>${t.last_finding_at ? `Last finding ${esc(ago(t.last_finding_at))}` : 'No findings yet'}</span>
+ ${t.is_public ? '<span>Public</span>' : ''}
+ </span>
+ </span>
+ <span class="tm-chip ${statusTone}">${esc(label(t.status))}</span>
+ </a></li>`;
+}
+
+async function renderList() {
+ document.title = 'Specialist Teams · three.ws';
+ const user = await currentUser();
+ if (!user) {
+ CONTENT.innerHTML = `
+ ${heroHtml(false)}
+ <div class="tm-state tm-section">
+ <h2>Sign in to assemble a team</h2>
+ <p>Your squad's agents, wallets and findings belong to your account. Sign in and you can have four specialists working a market in under a minute.</p>
+ <div class="tm-actions" style="justify-content:center">
+ <a class="tm-btn primary" href="/login?next=${encodeURIComponent('/teams')}">Sign in</a>
+ <a class="tm-btn" href="/register?next=${encodeURIComponent('/teams')}">Create an account</a>
+ </div>
+ </div>`;
+ done();
+ return;
+ }
+
+ CONTENT.innerHTML = `
+ ${heroHtml(true)}
+ <div class="tm-layout">
+ <section aria-labelledby="tmYourH">
+ <h2 class="tm-h2" id="tmYourH">Your teams <small id="tmCount"></small></h2>
+ <div id="tmList"></div>
+ </section>
+ <aside>${createFormHtml()}</aside>
+ </div>`;
+ wireSeg(CONTENT);
+ wireCreate();
+ await loadTeams();
+ done();
+}
+
+async function loadTeams() {
+ const box = $('#tmList');
+ box.innerHTML = `<div class="tm-stack">${'<div class="tm-skel" style="height:76px"></div>'.repeat(3)}</div>`;
+ const res = await api('/api/teams');
+ if (!res.ok) {
+ box.innerHTML = `
+ <div class="tm-state">
+ <h3>Your teams did not load</h3>
+ <p>${esc(res.message)}</p>
+ <button class="tm-btn" type="button" id="tmRetry">Try again</button>
+ </div>`;
+ $('#tmRetry').addEventListener('click', loadTeams);
+ return;
+ }
+ const teams = res.data || [];
+ $('#tmCount').textContent = teams.length ? `${teams.length}` : '';
+ if (!teams.length) {
+ box.innerHTML = `
+ <div class="tm-state">
+ <h3>No teams yet</h3>
+ <p>Name a team, set how much the Trader may spend, and three.ws provisions a Researcher, an Entry scout, a Trader and a Launcher for you.</p>
+ <button class="tm-btn primary" type="button" id="tmStart">Assemble your first team</button>
+ </div>`;
+ $('#tmStart').addEventListener('click', () => {
+ const input = $('#tmCreate input[name="name"]');
+ input.scrollIntoView({ behavior: REDUCED ? 'auto' : 'smooth', block: 'center' });
+ input.focus({ preventScroll: true });
+ });
+ return;
+ }
+ box.innerHTML = `<ul class="tm-cards">${teams.map(teamCardHtml).join('')}</ul>`;
+}
+
+function wireCreate() {
+ const form = $('#tmCreate');
+ form.addEventListener('submit', async (e) => {
+ e.preventDefault();
+ const errBox = $('#tmCreateErr');
+ errBox.innerHTML = '';
+ const fd = new FormData(form);
+ const name = String(fd.get('name') || '').trim();
+ if (!name) {
+ errBox.innerHTML = errorHtml({ message: 'Give the team a name.' });
+ form.name.focus();
+ return;
+ }
+ const body = {
+ name,
+ description: String(fd.get('description') || '').trim() || null,
+ network: $('.tm-seg[data-seg="Network"]', form).dataset.value,
+ is_public: fd.get('is_public') === 'on',
+ policy: {
+ per_trade_sol: Number(fd.get('per_trade_sol')),
+ daily_budget_sol: Number(fd.get('daily_budget_sol')),
+ finding_ttl_seconds: Math.round(Number(fd.get('ttl_minutes')) * 60),
+ allow_caution: fd.get('allow_caution') === 'on',
+ },
+ };
+ const btn = $('button[type="submit"]', form);
+ const restore = busy(btn, 'Provisioning four agents…');
+ ROOT.setAttribute('aria-busy', 'true');
+ const res = await api('/api/teams', { method: 'POST', body });
+ ROOT.setAttribute('aria-busy', 'false');
+ if (res.ok) {
+ location.assign(res.data.page_url);
+ return;
+ }
+ restore();
+ // Partial provisioning still created the team: send the owner to repair it.
+ if (res.detail?.team_id) {
+ toast('The team was created but a role agent was not. Opening it so you can repair it.');
+ location.assign(`/teams/${encodeURIComponent(res.detail.team_id)}`);
+ return;
+ }
+ errBox.innerHTML = errorHtml(res);
+ });
+}
+
+// ── /teams/:id ───────────────────────────────────────────────────────────────
+
+const state = {
+ id: null,
+ team: null,
+ user: null,
+ findings: new Map(),
+ filter: '',
+ nextBefore: null,
+ since: null,
+ es: null,
+ retryTimer: 0,
+ observer: null,
+};
+
+async function renderDetail(id) {
+ state.id = id;
+ const [user, res] = await Promise.all([currentUser(), api(`/api/teams/${id}`)]);
+ state.user = user;
+ if (!res.ok) {
+ CONTENT.innerHTML = res.status === 404
+ ? `<div class="tm-state">
+ <h2>This team is private or does not exist</h2>
+ <p>${user ? 'It may have been archived, or its owner keeps it private.' : 'If it is yours, sign in to open it.'}</p>
+ <div class="tm-actions" style="justify-content:center">
+ ${user ? '' : `<a class="tm-btn primary" href="/login?next=${encodeURIComponent(location.pathname)}">Sign in</a>`}
+ <a class="tm-btn" href="/teams">Specialist teams</a>
+ </div>
+ </div>`
+ : `<div class="tm-state">
+ <h2>The team did not load</h2>
+ <p>${esc(res.message)}</p>
+ <button class="tm-btn" type="button" id="tmRetry">Try again</button>
+ </div>`;
+ $('#tmRetry')?.addEventListener('click', () => renderDetail(id));
+ done();
+ return;
+ }
+ state.team = res.data;
+ paintDetail();
+ done();
+ await loadFindings(true);
+ openStream();
+}
+
+function paintDetail() {
+ const t = state.team;
+ document.title = `${t.name} · Specialist Teams · three.ws`;
+ const owner = t.is_owner;
+ CONTENT.innerHTML = `
+ <a class="tm-back" href="/teams">‹ ${owner ? 'Your teams' : 'Specialist teams'}</a>
+ <header class="tm-head">
+ <div style="min-width:0">
+ <h1>${esc(t.name)}</h1>
+ ${t.description ? `<p class="tm-desc">${esc(t.description)}</p>` : ''}
+ <div class="tm-head-meta" id="tmChips"></div>
+ </div>
+ ${owner ? '<div class="tm-actions" id="tmHeadActions"></div>' : ''}
+ </header>
+ <div id="tmBanners"></div>
+ <dl class="tm-tiles" id="tmTiles"></dl>
+ <section class="tm-section" aria-labelledby="tmSquadH">
+ <h2 class="tm-h2" id="tmSquadH">The squad <small>Each specialist is a full agent with its own page</small></h2>
+ <ul class="tm-squad" id="tmSquad"></ul>
+ </section>
+ <div class="tm-work${owner ? '' : ' solo'}">
+ ${owner ? consoleHtml() : ''}
+ <section class="tm-panel" aria-labelledby="tmBoardH">
+ <div class="tm-board-head">
+ <h2 class="tm-h2" id="tmBoardH" style="margin:0">Findings board</h2>
+ <span class="tm-live" id="tmLive" role="status"><i aria-hidden="true"></i><span>Connecting</span></span>
+ </div>
+ <div style="margin-bottom:12px">${seg('Filter findings', FILTERS, state.filter)}</div>
+ <ul class="tm-feed" id="tmFeed"></ul>
+ <div class="tm-more" id="tmMore"></div>
+ </section>
+ </div>
+ ${owner ? settingsHtml() : ''}`;
+ wireSeg(CONTENT);
+ paintChrome();
+ paintSquad();
+ if (owner) {
+ wireConsole();
+ wireSettings();
+ }
+ $('.tm-seg[data-seg="Filter findings"]').addEventListener('seg-change', (e) => {
+ state.filter = e.detail;
+ loadFindings(true);
+ });
+ $('#tmFeed').addEventListener('click', onFeedClick);
+}
+
+/** Chips, header actions, banners and stat tiles: everything a status change touches. */
+function paintChrome() {
+ const t = state.team;
+ const owner = t.is_owner;
+ $('#tmChips').innerHTML = `
+ <span class="tm-chip ${STATUS_TONE[t.status] ?? ''}">${esc(label(t.status))}</span>
+ <span class="tm-chip ${t.network === 'devnet' ? 'info' : ''}">${esc(label(t.network))}</span>
+ <span class="tm-chip">${t.is_public ? 'Public' : 'Private'}</span>`;
+
+ if (owner) {
+ const canToggle = t.status === 'active' || t.status === 'paused';
+ $('#tmHeadActions').innerHTML = `
+ ${canToggle ? `<button class="tm-btn sm" type="button" id="tmToggle">${t.status === 'paused' ? 'Resume' : 'Pause'}</button>` : ''}
+ <a class="tm-btn sm" href="#tmSettings">Settings</a>`;
+ $('#tmToggle')?.addEventListener('click', (e) => setStatus(t.status === 'paused' ? 'active' : 'paused', e.currentTarget));
+ }
+
+ const banners = [];
+ const needsRepair = t.missing_roles.length > 0 || t.status === 'provisioning' || t.status === 'failed';
+ if (needsRepair) {
+ const missing = t.missing_roles.map((r) => ROLE_TITLE[r]).join(', ');
+ banners.push(owner
+ ? `<div class="tm-note bad tm-banner"><span><b>${missing ? `Missing: ${esc(missing)}.` : 'This team is not fully assembled.'}</b> ${t.last_error ? esc(t.last_error) : 'Repair provisions any role agent that was not created.'}</span>
+ <button class="tm-btn sm primary" type="button" id="tmRepair">Repair team</button></div>`
+ : '<div class="tm-note warn tm-banner"><span><b>This team is still being assembled.</b> Its specialists have not all joined yet.</span></div>');
+ } else if (t.status === 'paused') {
+ banners.push(owner
+ ? `<div class="tm-note warn tm-banner"><span><b>Paused.</b> No specialist runs until you resume the team. The board stays readable.</span>
+ <button class="tm-btn sm primary" type="button" id="tmResume">Resume</button></div>`
+ : '<div class="tm-note warn tm-banner"><span><b>Paused by its owner.</b> The board below is the record so far.</span></div>');
+ }
+ $('#tmBanners').innerHTML = banners.join('');
+ $('#tmRepair')?.addEventListener('click', (e) => repairTeam(e.currentTarget));
+ $('#tmResume')?.addEventListener('click', (e) => setStatus('active', e.currentTarget));
+
+ const ttlMin = Math.round((t.policy?.finding_ttl_seconds ?? 900) / 60);
+ const tiles = [
+ ['Findings', num(t.findings.total, 0)],
+ ['Last 24h', num(t.findings.last_24h, 0)],
+ ['Last finding', esc(ago(t.findings.last_at))],
+ ['Verdicts live for', `${ttlMin} min`],
+ ];
+ if (owner) {
+ tiles.push(['Trader wallet', esc(sol(t.trader_balance_sol))]);
+ tiles.push(['Per trade cap', esc(sol(t.policy.per_trade_sol))]);
+ tiles.push(['Daily budget', esc(sol(t.policy.daily_budget_sol))]);
+ }
+ $('#tmTiles').innerHTML = tiles.map(([k, v]) => `<div class="tm-tile"><dt>${k}</dt><dd>${v}</dd></div>`).join('');
+
+ const runnable = t.status === 'active';
+ for (const b of $$('.tm-console button[type="submit"]')) b.disabled = !runnable;
+ const gateNote = $('#tmConsoleGate');
+ if (gateNote) {
+ gateNote.hidden = runnable;
+ gateNote.textContent = t.status === 'paused' ? 'Resume the team to run its specialists.' : 'Repair the team before running its specialists.';
+ }
+}
+
+function memberHtml(m) {
+ const a = m.agent;
+ const glb = agentAvatarGlb({ model_url: a.model_url });
+ const initial = esc((m.title || '?')[0]);
+ const thumb = a.thumbnail_url
+ ? `<img class="tm-stage-img" src="${esc(resolveDevR2Url(a.thumbnail_url))}" alt="" loading="lazy" decoding="async" data-fallback="${initial}" data-fallback-class="tm-stage-initial" />`
+ : `<span class="tm-stage-initial" aria-hidden="true">${initial}</span>`;
+ const perms = m.permissions.map((p) => `<span class="${p === 'trade.execute' ? 'sign' : ''}" title="${esc(state.team.permission_catalog?.[p] || p)}">${esc(PERM_SHORT[p] || p)}</span>`).join('');
+ return `
+ <li class="tm-member" data-member="${esc(m.id)}" style="${roleVar(m.role)}">
+ <div class="tm-stage" data-glb="${esc(glb)}" data-name="${esc(a.name)}">${thumb}</div>
+ <div class="tm-member-body">
+ <div class="tm-actions" style="gap:6px">
+ <span class="tm-chip role">${esc(m.title)}</span>
+ ${m.can_sign ? '<span class="tm-chip bad" title="Can sign trades from its wallet, inside the spend policy">Can sign</span>' : '<span class="tm-chip" title="Holds no signing permission">No signing</span>'}
+ </div>
+ <a class="tm-member-name" href="${esc(a.page_url)}">${esc(a.name)}</a>
+ <p class="tm-member-blurb">${esc(m.blurb)}</p>
+ <div class="tm-perms" aria-label="Permissions">${perms || '<span>no permissions</span>'}</div>
+ ${m.budget_sol != null ? `<span class="tm-hint">Budget ${esc(sol(m.budget_sol))} a day</span>` : ''}
+ ${a.wallet ? `<span class="tm-hint tm-mono" title="${esc(a.wallet)}">${esc(short(a.wallet))}</span>` : ''}
+ </div>
+ </li>`;
+}
+
+function missingHtml(role) {
+ return `
+ <li class="tm-member" style="${roleVar(role)}">
+ <div class="tm-missing">No ${ROLE_TITLE[role]} yet.<br />${state.team.is_owner ? 'Repair the team to provision one.' : 'Its owner has not finished assembling the team.'}</div>
+ <div class="tm-member-body"><span class="tm-chip role">${ROLE_TITLE[role]}</span></div>
+ </li>`;
+}
+
+function paintSquad() {
+ const t = state.team;
+ const byRole = new Map(t.members.filter((m) => m.role !== 'custom').map((m) => [m.role, m]));
+ const custom = t.members.filter((m) => m.role === 'custom');
+ $('#tmSquad').innerHTML = [
+ ...FIXED.map((r) => (byRole.has(r) ? memberHtml(byRole.get(r)) : missingHtml(r))),
+ ...custom.map(memberHtml),
+ ].join('');
+ mountFigures();
+}
+
+// The squad renders a live <agent-3d> per member, mounted only once its card is
+// on screen so four WebGL contexts never compete during first paint.
+let elementReady = null;
+function loadElement() {
+ elementReady ??= import('./element.js').then(() => true, () => false);
+ return elementReady;
+}
+
+function mountFigures() {
+ state.observer?.disconnect();
+ if (!('IntersectionObserver' in window)) return;
+ state.observer = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (!entry.isIntersecting) continue;
+ state.observer.unobserve(entry.target);
+ mountFigure(entry.target);
+ }
+ }, { rootMargin: '120px' });
+ for (const stage of $$('#tmSquad .tm-stage[data-glb]')) state.observer.observe(stage);
+}
+
+async function mountFigure(stage) {
+ if (!(await loadElement())) return;
+ const el = document.createElement('agent-3d');
+ el.setAttribute('body', resolveDevR2Url(stage.dataset.glb));
+ el.setAttribute('mode', 'inline');
+ el.setAttribute('responsive', '');
+ el.setAttribute('background', 'transparent');
+ el.setAttribute('name-plate', 'off');
+ el.setAttribute('avatar-chat', 'off');
+ el.setAttribute('kiosk', '');
+ el.setAttribute('aria-label', `${stage.dataset.name} in 3D`);
+ el.addEventListener('agent:ready', () => {
+ el.classList.add('ready');
+ $('.tm-stage-img, .tm-stage-initial', stage)?.classList.add('gone');
+ }, { once: true });
+ stage.append(el);
+}
+
+function pulseMember(memberId) {
+ const card = memberId && $(`.tm-member[data-member="${CSS.escape(memberId)}"]`);
+ if (!card) return;
+ card.classList.add('pulse');
+ setTimeout(() => card.classList.remove('pulse'), 1800);
+}
+
+// ── owner actions ────────────────────────────────────────────────────────────
+
+const TABS = [
+ ['research', 'researcher', 'Research'],
+ ['scan', 'entry', 'Entry scan'],
+ ['trade', 'trader', 'Trade'],
+ ['launch', 'launcher', 'Launch prep'],
+];
+
+const MINT_ATTRS = 'class="tm-input tm-mono" name="mint" autocomplete="off" spellcheck="false" maxlength="44" pattern="[1-9A-HJ-NP-Za-km-z]{32,44}"';
+
+function consoleHtml() {
+ const panes = {
+ research: `
+ <label class="tm-field"><span class="tm-label">Token mint</span><input ${MINT_ATTRS} required placeholder="Mint address" /></label>
+ <label class="tm-check"><input type="checkbox" name="refresh" /> Research again even if a live verdict is on the board.</label>
+ <p class="tm-hint">Checks mint and freeze authority, venue, holders, bundles and smart money, then posts a verdict that stays citable for the finding lifetime.</p>
+ <button class="tm-btn primary" type="submit">Research</button>`,
+ scan: `
+ <label class="tm-field"><span class="tm-label">Token mint (optional)</span><input ${MINT_ATTRS} placeholder="Leave empty to scan recent launches" /></label>
+ <p class="tm-hint">Without a mint, scores every launch whose observation window closed in the last two hours against the entry gates in Settings and posts the best setups. The Entry agent never trades.</p>
+ <button class="tm-btn primary" type="submit">Scan</button>`,
+ trade: `
+ <label class="tm-field"><span class="tm-label">Token mint</span><input ${MINT_ATTRS} required placeholder="Mint address" /></label>
+ <div class="tm-grid2">
+ <div class="tm-field"><span class="tm-label">Side</span>${seg('Side', [['buy', 'Buy'], ['sell', 'Sell']], 'buy')}</div>
+ <div class="tm-field"><span class="tm-label">Mode</span>${seg('Mode', [['quote', 'Quote'], ['simulate', 'Simulate'], ['live', 'Live']], 'quote')}</div>
+ </div>
+ <div class="tm-grid2">
+ <label class="tm-field"><span class="tm-label" id="tmAmountL">Amount (SOL)</span><input class="tm-input" name="amount" inputmode="decimal" autocomplete="off" required placeholder="0.01" /></label>
+ <label class="tm-field"><span class="tm-label">Slippage (bps, optional)</span><input class="tm-input" name="slippage" type="number" inputmode="numeric" min="1" max="5000" step="1" placeholder="Default" /></label>
+ </div>
+ <p class="tm-hint" id="tmTradeHint">The Trader cites a live research verdict on this mint, or researches it first and posts that verdict too. Quote and Simulate never sign.</p>
+ <button class="tm-btn primary" type="submit" id="tmTradeGo">Get quote</button>`,
+ launch: `
+ <div class="tm-grid2">
+ <label class="tm-field"><span class="tm-label">Coin name</span><input class="tm-input" name="name" maxlength="32" required autocomplete="off" /></label>
+ <label class="tm-field"><span class="tm-label">Ticker</span><input class="tm-input tm-mono" name="symbol" maxlength="10" required autocomplete="off" style="text-transform:uppercase" /></label>
+ </div>
+ <label class="tm-field"><span class="tm-label">Description (optional)</span><textarea class="tm-input" name="description" maxlength="500"></textarea></label>
+ <p class="tm-hint">The Launcher checks the launch lane and writes a plan. You review and sign it yourself on the launchpad, with the Launcher's 3D body as the coin image.</p>
+ <button class="tm-btn primary" type="submit">Prepare plan</button>`,
+ };
+ return `
+ <section class="tm-panel tm-console" aria-labelledby="tmConsoleH">
+ <h2 class="tm-h2" id="tmConsoleH">Run a specialist</h2>
+ <p class="tm-note warn" id="tmConsoleGate" hidden></p>
+ <div class="tm-tabs" role="tablist" aria-label="Specialist">
+ ${TABS.map(([action, role, text], i) => `<button type="button" role="tab" id="tmTab-${action}" aria-controls="tmPane-${action}" aria-selected="${i === 0}" tabindex="${i === 0 ? 0 : -1}" style="${roleVar(role)}">${text}</button>`).join('')}
+ </div>
+ ${TABS.map(([action, role], i) => `
+ <div role="tabpanel" id="tmPane-${action}" aria-labelledby="tmTab-${action}" ${i === 0 ? '' : 'hidden'}>
+ <form class="tm-form" data-action="${action}" data-role="${role}" novalidate>${panes[action]}</form>
+ <div class="tm-result" aria-live="polite"></div>
+ </div>`).join('')}
+ </section>`;
+}
+
+function wireConsole() {
+ const tabs = $$('.tm-tabs [role="tab"]');
+ const select = (tab) => {
+ for (const t of tabs) {
+ const on = t === tab;
+ t.setAttribute('aria-selected', String(on));
+ t.tabIndex = on ? 0 : -1;
+ $(`#${t.getAttribute('aria-controls')}`).hidden = !on;
+ }
+ };
+ for (const tab of tabs) {
+ tab.addEventListener('click', () => select(tab));
+ tab.addEventListener('keydown', (e) => {
+ const i = tabs.indexOf(tab);
+ const next = e.key === 'ArrowRight' ? tabs[(i + 1) % tabs.length] : e.key === 'ArrowLeft' ? tabs[(i - 1 + tabs.length) % tabs.length] : null;
+ if (!next) return;
+ e.preventDefault();
+ select(next);
+ next.focus();
+ });
+ }
+
+ const tradeForm = $('form[data-action="trade"]');
+ const sideSeg = $('.tm-seg[data-seg="Side"]', tradeForm);
+ const modeSeg = $('.tm-seg[data-seg="Mode"]', tradeForm);
+ const syncTrade = () => {
+ const sell = sideSeg.dataset.value === 'sell';
+ const mode = modeSeg.dataset.value;
+ $('#tmAmountL').textContent = sell ? 'Amount (tokens, or max)' : 'Amount (SOL)';
+ tradeForm.amount.placeholder = sell ? 'max' : '0.01';
+ const go = $('#tmTradeGo');
+ go.textContent = mode === 'live' ? 'Review live trade' : mode === 'simulate' ? 'Simulate' : 'Get quote';
+ go.className = `tm-btn ${mode === 'live' ? 'live' : 'primary'}`;
+ $('#tmTradeHint').textContent = mode === 'live'
+ ? 'Live signs and sends from the Trader wallet, inside the per trade cap and daily budget. You confirm the exact amount first.'
+ : 'The Trader cites a live research verdict on this mint, or researches it first and posts that verdict too. Quote and Simulate never sign.';
+ };
+ sideSeg.addEventListener('seg-change', syncTrade);
+ modeSeg.addEventListener('seg-change', syncTrade);
+
+ for (const form of $$('.tm-console form')) form.addEventListener('submit', onRun);
+ paintChrome();
+}
+
+function readInput(form) {
+ const action = form.dataset.action;
+ const fd = new FormData(form);
+ const mint = String(fd.get('mint') || '').trim();
+ if (action === 'research') return { mint, refresh: fd.get('refresh') === 'on' };
+ if (action === 'scan') return mint ? { mint } : {};
+ if (action === 'launch') {
+ return {
+ name: String(fd.get('name') || '').trim(),
+ symbol: String(fd.get('symbol') || '').trim().toUpperCase(),
+ description: String(fd.get('description') || '').trim(),
+ };
+ }
+ const side = $('.tm-seg[data-seg="Side"]', form).dataset.value;
+ const rawAmount = String(fd.get('amount') || '').trim();
+ const slippage = String(fd.get('slippage') || '').trim();
+ return {
+ mint,
+ side,
+ amount: side === 'sell' && rawAmount.toLowerCase() === 'max' ? 'max' : Number(rawAmount),
+ mode: $('.tm-seg[data-seg="Mode"]', form).dataset.value,
+ ...(slippage ? { slippageBps: Number(slippage) } : {}),
+ };
+}
+
+function validate(form, input) {
+ const action = form.dataset.action;
+ const mintRe = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
+ if ((action === 'research' || action === 'trade') && !mintRe.test(input.mint)) return 'Paste a valid Solana token mint address.';
+ if (action === 'scan' && input.mint && !mintRe.test(input.mint)) return 'That is not a valid Solana mint address. Leave it empty to scan recent launches.';
+ if (action === 'trade' && input.amount !== 'max' && !(input.amount > 0)) return input.side === 'sell' ? 'Enter a token amount, or max.' : 'Enter how much SOL to spend.';
+ if (action === 'launch' && !input.name) return 'Give the coin a name.';
+ if (action === 'launch' && !/^[A-Z0-9]{1,10}$/.test(input.symbol)) return 'The ticker must be 1 to 10 letters or digits.';
+ return null;
+}
+
+function liveTradeHtml(input) {
+ const t = state.team;
+ const trader = t.members.find((m) => m.role === 'trader');
+ const amount = input.side === 'buy' ? `${num(input.amount, 9)} SOL` : input.amount === 'max' ? 'Entire token balance' : `${num(input.amount, 9)} tokens`;
+ const rows = [
+ ['Action', input.side === 'buy' ? 'Buy' : 'Sell'],
+ ['Amount', amount],
+ ['Token mint', `<span class="tm-mono">${esc(input.mint)}</span>`],
+ ['Network', esc(label(t.network))],
+ ['From wallet', trader?.agent.wallet ? `<span class="tm-mono">${esc(trader.agent.wallet)}</span>` : 'Trader wallet'],
+ ['Per trade cap', esc(sol(t.policy.per_trade_sol))],
+ ['Daily budget', esc(sol(t.policy.daily_budget_sol))],
+ ];
+ return `
+ <table>${rows.map(([k, v]) => `<tr><th scope="row">${k}</th><td>${v}</td></tr>`).join('')}</table>
+ <p>${t.network === 'mainnet'
+ ? '<b>This signs and sends a real mainnet transaction.</b> It cannot be undone. The Trader still refuses it if research says avoid or a spend guard trips.'
+ : 'This signs a devnet transaction with test SOL. The Trader still refuses it if research says avoid or a spend guard trips.'}</p>`;
+}
+
+async function onRun(e) {
+ e.preventDefault();
+ const form = e.currentTarget;
+ const action = form.dataset.action;
+ const result = form.nextElementSibling;
+ result.innerHTML = '';
+ const input = readInput(form);
+ const problem = validate(form, input);
+ if (problem) {
+ result.innerHTML = errorHtml({ message: problem });
+ return;
+ }
+ if (action === 'trade' && input.mode === 'live') {
+ const ok = await confirmDialog({ title: 'Confirm live trade', html: liveTradeHtml(input), okLabel: 'Sign and send', tone: 'live' });
+ if (!ok) return;
+ input.confirm = true;
+ }
+ const btn = $('button[type="submit"]', form);
+ const restore = busy(btn, { research: 'Researching…', scan: 'Scanning…', trade: 'Working…', launch: 'Preparing…' }[action]);
+ const res = await api(`/api/teams/${state.id}/run`, { method: 'POST', body: { action, role: form.dataset.role, input } });
+ restore();
+ if (!res.ok) {
+ result.innerHTML = errorHtml(res);
+ return;
+ }
+ const findings = runFindings(action, res.data);
+ for (const f of findings) addFinding(f);
+ result.innerHTML = runResultHtml(action, res.data);
+}
+
+function runFindings(action, data) {
+ if (action === 'scan') return data.findings || [];
+ if (action === 'trade') return [data.research, data.finding].filter(Boolean);
+ return data.finding ? [data.finding] : [];
+}
+
+function runResultHtml(action, data) {
+ if (action === 'research') {
+ return `<div class="tm-note"><b>${data.reused ? 'Reused a live verdict' : 'Posted a fresh verdict'}</b>: ${esc(label(data.finding.verdict))}${data.finding.score != null ? `, score ${data.finding.score}/100` : ''}. ${data.reused ? 'Nothing was redone.' : ''}</div>`;
+ }
+ if (action === 'scan') {
+ if (data.setups === undefined) return `<div class="tm-note"><b>${esc(label(data.findings[0]?.verdict))}</b>: ${esc(data.findings[0]?.summary)}</div>`;
+ return `<div class="tm-note"><b>Scanned ${data.scanned} ${data.scanned === 1 ? 'launch' : 'launches'}.</b> ${data.setups ? `Posted ${data.setups} ${data.setups === 1 ? 'setup' : 'setups'} to the board.` : 'None cleared the entry gates, so nothing was posted.'}</div>`;
+ }
+ if (action === 'launch') {
+ const url = data.finding.evidence?.launch_url;
+ return data.ready && url
+ ? `<div class="tm-note"><b>Plan ready.</b> Review it and sign it yourself on the launchpad.<p style="margin:10px 0 0"><a class="tm-btn sm primary" href="${esc(url)}">Review and sign on the launchpad</a></p></div>`
+ : `<div class="tm-note bad"><b>Blocked.</b> ${esc((data.blockers || [])[0] || data.finding.summary)}</div>`;
+ }
+ const f = data.finding;
+ const cite = data.research
+ ? `Cited research: <b>${esc(label(data.research.verdict))}</b> (${f.evidence?.research_source === 'ran' ? 'researched just now' : 'reused from the board'}).`
+ : 'No research cited (exits are never blocked by research).';
+ const tone = f.verdict === 'refused' || f.verdict === 'failed' ? 'bad' : '';
+ const explorer = f.evidence?.result?.explorer;
+ return `<div class="tm-note ${tone}"><b>${esc(label(f.verdict))}.</b> ${esc(f.summary)}<br />${cite}${explorer ? ` <a href="${esc(explorer)}" target="_blank" rel="noopener">View transaction</a>` : ''}</div>`;
+}
+
+async function setStatus(status, btn) {
+ const restore = busy(btn, status === 'paused' ? 'Pausing…' : 'Resuming…');
+ const res = await api(`/api/teams/${state.id}`, { method: 'PATCH', body: { status } });
+ if (!res.ok) {
+ restore();
+ toast(res.message);
+ return;
+ }
+ state.team = res.data;
+ paintChrome();
+ toast(status === 'paused' ? 'Team paused.' : 'Team resumed.');
+}
+
+async function repairTeam(btn) {
+ const restore = busy(btn, 'Provisioning…');
+ const res = await api(`/api/teams/${state.id}/repair`, { method: 'POST' });
+ if (!res.ok) {
+ restore();
+ toast(res.message);
+ return;
+ }
+ state.team = res.data.team;
+ paintChrome();
+ paintSquad();
+ paintMembers();
+ const n = res.data.created?.length || 0;
+ toast(n ? `Provisioned ${n} ${n === 1 ? 'agent' : 'agents'}.` : 'Nothing was missing.');
+}
+
+// ── findings board ───────────────────────────────────────────────────────────
+
+function subjectHtml(f) {
+ if (f.subject_kind !== 'mint') {
+ const text = f.subject.startsWith('launch:') ? `Launch plan $${f.subject.slice(7)}` : f.subject;
+ return `<span class="tm-f-subject">${esc(text)}</span>`;
+ }
+ const sym = f.evidence?.identity?.symbol;
+ return `<a class="tm-f-subject" href="/coin/${encodeURIComponent(f.subject)}" title="${esc(f.subject)}">${sym ? `$${esc(String(sym).slice(0, 16))} ` : ''}<span class="tm-mono">${esc(short(f.subject))}</span></a>`;
+}
+
+function expiryHtml(f) {
+ if (!f.expires_at) return '';
+ const left = timeLeft(f.expires_at);
+ return `<span data-expires="${esc(f.expires_at)}">${left ? `Citable for ${left}` : 'Expired'}</span>`;
+}
+
+function citeHtml(f) {
+ return (f.cites || []).map((id) => {
+ const cited = state.findings.get(id);
+ const text = cited ? `Cites ${KIND_LABEL[cited.kind] || 'finding'}: ${label(cited.verdict)}` : 'Cites research';
+ return `<button type="button" class="tm-cite" data-cite="${esc(id)}" data-subject="${esc(f.subject)}">${esc(text)}</button>`;
+ }).join('');
+}
+
+function row(k, v) {
+ if (v == null || v === '' || (Array.isArray(v) && !v.length)) return '';
+ return `<dt>${esc(k)}</dt><dd>${v}</dd>`;
+}
+const list = (items) => `<ul>${items.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>`;
+const val = (v) => (v == null ? null : esc(typeof v === 'number' ? num(v, 6) : typeof v === 'boolean' ? (v ? 'yes' : 'no') : v));
+
+function evidenceRows(f) {
+ const ev = f.evidence || {};
+ if (f.kind === 'research') {
+ return [
+ row('Reasons', ev.reasons?.length ? list(ev.reasons) : null),
+ row('Safety', ev.safety ? `${esc(label(ev.safety.verdict))}${ev.safety.score != null ? `, ${esc(ev.safety.score)}/100` : ''}` : null),
+ row('Checks', ev.safety?.checks?.length ? list(ev.safety.checks.map((c) => `${label(c.name)}: ${c.status}${c.reason ? ` (${c.reason})` : ''}`)) : null),
+ row('Subscores', ev.subscores ? list(Object.entries(ev.subscores).map(([k, v]) => `${label(k)}: ${v ?? 'n/a'}`)) : null),
+ row('Smart money', ev.smart_money ? `${ev.smart_money.count} wallets${ev.smart_money.score != null ? `, score ${esc(ev.smart_money.score)}` : ''}${ev.smart_money.sybil_flag ? ', sybil flagged' : ''}` : null),
+ row('Sources', ev.sources?.length ? list(ev.sources.map((s) => `${label(s.name)}${s.at ? ` at ${new Date(s.at).toLocaleTimeString()}` : ': unavailable'}`)) : null),
+ ];
+ }
+ if (f.kind === 'entry_signal') {
+ return [
+ row('Strategy score', val(ev.strategy_score)),
+ row('Reasons', ev.reasons?.length ? list(ev.reasons) : null),
+ row('Market cap', ev.market_cap_usd != null ? `$${num(ev.market_cap_usd, 0)}` : null),
+ row('Gates', ev.gates ? list(Object.entries(ev.gates).filter(([, v]) => v != null).map(([k, v]) => `${label(k)}: ${v}`)) : null),
+ row('Scorer', val(ev.scorer)),
+ ];
+ }
+ if (f.kind === 'trade') {
+ const q = ev.quote;
+ const r = ev.result;
+ const req = ev.request || {};
+ return [
+ row('Rule', ev.rule ? `${esc(label(ev.rule))}: ${esc(ev.rule_reason)}` : null),
+ row('Research', ev.research_verdict ? `${esc(label(ev.research_verdict))} (${ev.research_source === 'ran' ? 'researched for this trade' : 'reused from the board'})` : null),
+ row('Request', esc(`${label(req.side)} ${req.amount ?? ''} ${req.side === 'buy' ? 'SOL' : req.amount === 'max' ? '' : 'tokens'}, ${req.mode}, ${req.network}`)),
+ row('Expected out', q ? (q.side === 'buy' ? `${val(q.expected_tokens_out)} tokens` : `${val(q.expected_sol_out)} SOL`) : null),
+ row('Price impact', q?.price_impact_pct != null ? `${num(q.price_impact_pct, 2)}%` : null),
+ row('USD value', q?.usd_value != null ? `$${num(q.usd_value, 2)}` : null),
+ row('Spend guard', q ? (q.allowed ? 'Pass' : esc(q.blocked_reason?.message || 'Blocked')) : null),
+ row('Signature', r?.signature ? `<span class="tm-mono">${esc(short(r.signature))}</span>` : null),
+ row('Engine', r?.message ? esc(r.message) : null),
+ ];
+ }
+ const plan = ev.plan || {};
+ const lane = ev.lane || {};
+ return [
+ row('Plan', esc(`${plan.name || ''} ($${plan.symbol || ''})`)),
+ row('Description', val(plan.description)),
+ row('Lane', lane.label ? esc(`${lane.label} on ${lane.network}, quoted in ${lane.quote}`) : null),
+ row('Trade fee', lane.trade_fee_bps != null ? `${num(lane.trade_fee_bps / 100, 2)}%` : null),
+ row('Creator share', lane.creator_fee_percent != null ? `${num(lane.creator_fee_percent, 2)}% of fees` : null),
+ row('Blockers', ev.blockers?.length ? list(ev.blockers) : null),
+ row('Signer', ev.signer === 'owner' ? 'You, on the launchpad' : null),
+ ];
+}
+
+function findingHtml(f) {
+ const ev = f.evidence || {};
+ const tone = VERDICT_TONE[f.verdict] ?? '';
+ const stale = f.expires_at && !timeLeft(f.expires_at);
+ const explorer = ev.result?.explorer;
+ const rows = evidenceRows(f).join('');
+ return `
+ <li class="tm-finding${stale ? ' stale' : ''}" id="f-${esc(f.id)}" style="${roleVar(f.author_role)}" tabindex="-1">
+ <div class="tm-f-top">
+ <span class="tm-chip role">${esc(ROLE_TITLE[f.author_role] || f.author_role)}</span>
+ <span class="tm-chip">${esc(KIND_LABEL[f.kind] || f.kind)}</span>
+ <span class="tm-chip ${tone}">${esc(label(f.verdict))}</span>
+ ${subjectHtml(f)}
+ <time class="tm-f-time" datetime="${esc(f.created_at)}" title="${esc(new Date(f.created_at).toLocaleString())}">${esc(ago(f.created_at))}</time>
+ </div>
+ <p class="tm-f-summary">${esc(f.summary)}</p>
+ <div class="tm-f-meta">
+ ${f.score != null ? `<span>Score ${esc(f.score)}/100</span>` : ''}
+ ${citeHtml(f)}
+ ${expiryHtml(f)}
+ ${f.receipt_id ? `<span>Receipt <span class="tm-mono">${esc(short(f.receipt_id))}</span></span>` : ''}
+ ${explorer ? `<a href="${esc(explorer)}" target="_blank" rel="noopener">View transaction</a>` : ''}
+ ${ev.launch_url ? `<a href="${esc(ev.launch_url)}">Review and sign on the launchpad</a>` : ''}
+ </div>
+ ${rows ? `<details class="tm-ev"><summary>Evidence</summary><dl>${rows}</dl></details>` : ''}
+ <div class="tm-cited"></div>
+ </li>`;
+}
+
+function feedEmptyHtml() {
+ const kind = FILTERS.find(([v]) => v === state.filter)?.[1];
+ if (state.filter) return `<li class="tm-state" data-empty><h3>No ${esc(kind.toLowerCase())} findings yet</h3><p>Switch the filter to All to see everything the squad posted.</p></li>`;
+ return state.team.is_owner
+ ? '<li class="tm-state" data-empty><h3>Nothing on the board yet</h3><p>Run the Researcher on a mint, or let the Entry agent scan recent launches. Every finding lands here live.</p></li>'
+ : '<li class="tm-state" data-empty><h3>Nothing on the board yet</h3><p>Findings appear here live as the squad works.</p></li>';
+}
+
+async function loadFindings(reset) {
+ const feed = $('#tmFeed');
+ const more = $('#tmMore');
+ if (reset) {
+ state.nextBefore = null;
+ feed.innerHTML = '<li class="tm-skel" style="height:96px"></li><li class="tm-skel" style="height:96px"></li><li class="tm-skel" style="height:96px"></li>';
+ more.innerHTML = '';
+ }
+ const q = new URLSearchParams({ limit: String(PAGE) });
+ if (state.filter) q.set('kind', state.filter);
+ if (!reset && state.nextBefore) q.set('before', state.nextBefore);
+ const res = await api(`/api/teams/${state.id}/findings?${q}`);
+ if (!res.ok) {
+ if (reset) {
+ feed.innerHTML = `<li class="tm-state"><h3>The board did not load</h3><p>${esc(res.message)}</p><button class="tm-btn" type="button" data-retry>Try again</button></li>`;
+ } else {
+ more.innerHTML = `<button class="tm-btn" type="button" id="tmLoadMore">Try again</button>`;
+ $('#tmLoadMore').addEventListener('click', () => loadFindings(false));
+ }
+ return;
+ }
+ const rows = res.data || [];
+ for (const f of rows) state.findings.set(f.id, f);
+ if (reset) {
+ feed.innerHTML = rows.length ? rows.map(findingHtml).join('') : feedEmptyHtml();
+ if (!state.since) state.since = rows.length && !state.filter ? new Date(rows[0].created_at).toISOString() : new Date().toISOString();
+ } else {
+ feed.insertAdjacentHTML('beforeend', rows.map(findingHtml).join(''));
+ }
+ refreshCites();
+ state.nextBefore = res.body?.next_before || null;
+ more.innerHTML = state.nextBefore ? '<button class="tm-btn" type="button" id="tmLoadMore">Load older findings</button>' : '';
+ $('#tmLoadMore')?.addEventListener('click', async (e) => {
+ busy(e.currentTarget, 'Loading…');
+ await loadFindings(false);
+ });
+}
+
+/** Relabel cite buttons once the finding they point at is known. */
+function refreshCites() {
+ for (const b of $$('#tmFeed .tm-cite')) {
+ const cited = state.findings.get(b.dataset.cite);
+ if (cited) b.textContent = `Cites ${KIND_LABEL[cited.kind] || 'finding'}: ${label(cited.verdict)}`;
+ }
+}
+
+function addFinding(f) {
+ const fresh = !state.findings.has(f.id);
+ state.findings.set(f.id, f);
+ if (!fresh || $(`#f-${CSS.escape(f.id)}`)) return;
+ if (state.team && fresh) {
+ state.team.findings.total += 1;
+ state.team.findings.last_24h += 1;
+ state.team.findings.last_at = f.created_at;
+ paintChrome();
+ }
+ pulseMember(f.member_id);
+ if (state.filter && f.kind !== state.filter) return;
+ const feed = $('#tmFeed');
+ $('[data-empty]', feed)?.remove();
+ feed.insertAdjacentHTML('afterbegin', findingHtml(f));
+ refreshCites();
+}
+
+async function onFeedClick(e) {
+ if (e.target.closest('[data-retry]')) {
+ loadFindings(true);
+ return;
+ }
+ const btn = e.target.closest('.tm-cite');
+ if (!btn) return;
+ const id = btn.dataset.cite;
+ const target = $(`#f-${CSS.escape(id)}`);
+ if (target) {
+ target.scrollIntoView({ behavior: REDUCED ? 'auto' : 'smooth', block: 'center' });
+ target.focus({ preventScroll: true });
+ target.classList.add('flash');
+ setTimeout(() => target.classList.remove('flash'), 1800);
+ return;
+ }
+ // The cited finding is older than the loaded page or hidden by the filter:
+ // show it inline under the finding that cites it.
+ const slot = $('.tm-cited', btn.closest('.tm-finding'));
+ if (slot.childElementCount) {
+ slot.innerHTML = '';
+ return;
+ }
+ let cited = state.findings.get(id);
+ if (!cited) {
+ const q = new URLSearchParams({ kind: 'research', subject: btn.dataset.subject, limit: '100' });
+ const res = await api(`/api/teams/${state.id}/findings?${q}`);
+ cited = res.ok ? (res.data || []).find((x) => x.id === id) : null;
+ if (cited) state.findings.set(cited.id, cited);
+ }
+ if (!cited) {
+ toast('That finding is no longer on the board.');
+ return;
+ }
+ slot.innerHTML = `<ul class="tm-feed" style="margin-top:10px">${findingHtml(cited).replace(`id="f-${esc(cited.id)}"`, '')}</ul>`;
+}
+
+function setLive(mode, text) {
+ const el = $('#tmLive');
+ if (!el) return;
+ el.className = `tm-live${mode ? ` ${mode}` : ''}`;
+ $('span', el).textContent = text;
+}
+
+function openStream() {
+ state.es?.close();
+ clearTimeout(state.retryTimer);
+ if (!('EventSource' in window)) {
+ setLive('', 'Live updates unavailable in this browser');
+ return;
+ }
+ const q = new URLSearchParams();
+ if (state.since) q.set('since', state.since);
+ const es = new EventSource(`/api/teams/${state.id}/findings/stream?${q}`, { withCredentials: true });
+ state.es = es;
+ es.addEventListener('open', () => setLive('on', 'Live'));
+ es.addEventListener('hello', () => setLive('on', 'Live'));
+ es.addEventListener('finding', (ev) => {
+ try {
+ const f = JSON.parse(ev.data);
+ state.since = new Date(f.created_at).toISOString();
+ addFinding(f);
+ } catch {
+ /* a malformed frame is skipped; the next poll carries the row again */
+ }
+ });
+ es.addEventListener('status', async () => {
+ const res = await api(`/api/teams/${state.id}`);
+ if (res.ok) {
+ state.team = res.data;
+ paintChrome();
+ }
+ });
+ es.addEventListener('gone', () => {
+ es.close();
+ setLive('', 'Stopped');
+ toast('This team was archived or made private.');
+ });
+ es.addEventListener('error', () => {
+ if (es.readyState === EventSource.CLOSED) {
+ // The browser gave up (an HTTP error, not a dropped socket). Retry with
+ // a fresh connection resuming from the last finding we saw.
+ setLive('retry', 'Reconnecting');
+ state.retryTimer = setTimeout(openStream, 5000);
+ } else {
+ setLive('retry', 'Reconnecting');
+ }
+ });
+}
+
+// Keep expiry countdowns honest without re-rendering the board.
+setInterval(() => {
+ for (const el of $$('[data-expires]')) {
+ const left = timeLeft(el.dataset.expires);
+ el.textContent = left ? `Citable for ${left}` : 'Expired';
+ el.closest('.tm-finding')?.classList.toggle('stale', !left);
+ }
+}, 5000);
+
+window.addEventListener('pagehide', () => state.es?.close());
+
+// ── settings ─────────────────────────────────────────────────────────────────
+
+function settingsHtml() {
+ const t = state.team;
+ const p = t.policy;
+ const g = p.entry || {};
+ return `
+ <section class="tm-section tm-panel" id="tmSettings" aria-labelledby="tmSetH">
+ <h2 class="tm-h2" id="tmSetH">Settings</h2>
+ <form class="tm-form" id="tmSetForm" novalidate>
+ <div class="tm-grid2">
+ <label class="tm-field"><span class="tm-label">Team name</span><input class="tm-input" name="name" maxlength="60" required value="${esc(t.name)}" /></label>
+ <label class="tm-field"><span class="tm-label">Description</span><input class="tm-input" name="description" maxlength="500" value="${esc(t.description || '')}" /></label>
+ </div>
+ <fieldset class="tm-fieldset">
+ <legend>Spend policy</legend>
+ <div class="tm-grid2">
+ <label class="tm-field"><span class="tm-label">Per trade (SOL)</span><input class="tm-input" name="per_trade_sol" type="number" min="0.001" max="50" step="0.001" value="${esc(p.per_trade_sol)}" /></label>
+ <label class="tm-field"><span class="tm-label">Daily budget (SOL)</span><input class="tm-input" name="daily_budget_sol" type="number" min="0.001" max="500" step="0.001" value="${esc(p.daily_budget_sol)}" /></label>
+ <label class="tm-field"><span class="tm-label">Finding lifetime (minutes)</span><input class="tm-input" name="ttl_minutes" type="number" min="1" max="1440" step="1" value="${Math.round(p.finding_ttl_seconds / 60)}" /></label>
+ </div>
+ <label class="tm-check"><input type="checkbox" name="allow_caution" ${p.allow_caution ? 'checked' : ''} /> Let the Trader buy on a "caution" verdict, not only on a "pass".</label>
+ <p class="tm-hint">The caps are written onto the Trader agent's own trade limits, so the platform spend guards enforce them on every trade.</p>
+ </fieldset>
+ <fieldset class="tm-fieldset">
+ <legend>Entry gates</legend>
+ <div class="tm-grid2">
+ <label class="tm-field"><span class="tm-label">Min quality (0 to 100)</span><input class="tm-input" name="min_quality_score" type="number" min="0" max="100" step="1" value="${esc(g.min_quality_score ?? '')}" /></label>
+ <label class="tm-field"><span class="tm-label">Max bundle score (0 to 1)</span><input class="tm-input" name="max_bundle_score" type="number" min="0" max="1" step="0.05" value="${esc(g.max_bundle_score ?? '')}" /></label>
+ <label class="tm-field"><span class="tm-label">Min market cap (USD)</span><input class="tm-input" name="min_market_cap_usd" type="number" min="0" step="1000" value="${esc(g.min_market_cap_usd ?? '')}" placeholder="No floor" /></label>
+ <label class="tm-field"><span class="tm-label">Max market cap (USD)</span><input class="tm-input" name="max_market_cap_usd" type="number" min="0" step="1000" value="${esc(g.max_market_cap_usd ?? '')}" placeholder="No ceiling" /></label>
+ </div>
+ <label class="tm-check"><input type="checkbox" name="require_two_sided_market" ${g.require_two_sided_market ? 'checked' : ''} /> Require a two-sided market (real buyers and sellers).</label>
+ <label class="tm-check"><input type="checkbox" name="require_smart_money" ${g.require_smart_money ? 'checked' : ''} /> Require smart-money wallets in the early holders.</label>
+ </fieldset>
+ <label class="tm-check"><input type="checkbox" name="is_public" ${t.is_public ? 'checked' : ''} /> Public: anyone with the link can watch the squad and its board. Policy and wallet balances stay private.</label>
+ <div id="tmSetErr"></div>
+ <div class="tm-actions"><button class="tm-btn primary" type="submit">Save settings</button></div>
+ </form>
+
+ <h3 class="tm-h2 tm-section">Members and permissions <small>A grant can only narrow a role, never widen it</small></h3>
+ <div id="tmMembers" class="tm-stack"></div>
+
+ <h3 class="tm-h2 tm-section">Add a specialist <small>One of your agents, with a read-mostly grant</small></h3>
+ <form class="tm-form" id="tmAddForm" novalidate>
+ <label class="tm-field"><span class="tm-label">Agent</span><select class="tm-input" name="agent_id" required><option value="">Loading your agents…</option></select></label>
+ <div class="tm-perms-pick" id="tmAddPerms"></div>
+ <div id="tmAddErr"></div>
+ <div class="tm-actions"><button class="tm-btn" type="submit">Add to team</button></div>
+ </form>
+
+ <h3 class="tm-h2 tm-section">Archive</h3>
+ <div class="tm-note bad tm-banner"><span>Archiving stops the team and hides its page. The four agents stay in your account with their wallets.</span>
+ <button class="tm-btn sm danger" type="button" id="tmArchive">Archive team</button></div>
+ </section>`;
+}
+
+function permChecks(name, perms, checked) {
+ const catalog = state.team.permission_catalog || {};
+ return perms.map((p) => `
+ <label class="tm-check"><input type="checkbox" name="${esc(name)}" value="${esc(p)}" ${checked.includes(p) ? 'checked' : ''} />
+ <span><b>${esc(PERM_SHORT[p] || p)}</b>: ${esc(catalog[p] || '')}</span></label>`).join('');
+}
+
+function paintMembers() {
+ const box = $('#tmMembers');
+ if (!box) return;
+ const members = state.team.members;
+ if (!members.length) {
+ box.innerHTML = '<p class="tm-muted">No members yet. Repair the team to provision its four specialists.</p>';
+ return;
+ }
+ box.innerHTML = members.map((m) => `
+ <form class="tm-fieldset tm-form" data-member-form="${esc(m.id)}" style="${roleVar(m.role)}">
+ <legend><span class="tm-chip role">${esc(m.title)}</span> ${esc(m.agent.name)}</legend>
+ ${permChecks('perm', m.ceiling || m.permissions, m.permissions)}
+ <div class="tm-actions">
+ <button class="tm-btn sm" type="submit">Save grant</button>
+ ${m.role === 'custom' ? '<button class="tm-btn sm danger" type="button" data-remove>Remove</button>' : ''}
+ </div>
+ </form>`).join('');
+ for (const form of $$('[data-member-form]', box)) {
+ const id = form.dataset.memberForm;
+ form.addEventListener('submit', async (e) => {
+ e.preventDefault();
+ const permissions = $$('input[name="perm"]:checked', form).map((i) => i.value);
+ const restore = busy($('button[type="submit"]', form), 'Saving…');
+ const res = await api(`/api/teams/${state.id}/members/${id}`, { method: 'PATCH', body: { permissions } });
+ restore();
+ if (!res.ok) return toast(res.message);
+ await reloadTeam();
+ toast('Grant saved.');
+ });
+ $('[data-remove]', form)?.addEventListener('click', async (e) => {
+ const restore = busy(e.currentTarget, 'Removing…');
+ const res = await api(`/api/teams/${state.id}/members/${id}`, { method: 'DELETE' });
+ if (!res.ok) {
+ restore();
+ return toast(res.message);
+ }
+ await reloadTeam();
+ toast('Specialist removed. The agent stays in your account.');
+ });
+ }
+}
+
+async function reloadTeam() {
+ const res = await api(`/api/teams/${state.id}`);
+ if (!res.ok) return;
+ state.team = res.data;
+ paintChrome();
+ paintSquad();
+ paintMembers();
+ fillAddForm();
+}
+
+let ownedAgents = null;
+async function fillAddForm() {
+ const form = $('#tmAddForm');
+ if (!form) return;
+ const submit = $('button[type="submit"]', form);
+ if (!ownedAgents) {
+ const res = await api('/api/agents');
+ if (!res.ok) {
+ form.agent_id.innerHTML = '<option value="">Your agents did not load</option>';
+ form.agent_id.disabled = true;
+ submit.disabled = true;
+ $('#tmAddErr').innerHTML = `<div class="tm-err" role="alert">${esc(res.message)} <button class="tm-btn sm" type="button" id="tmAgentsRetry">Try again</button></div>`;
+ $('#tmAgentsRetry').addEventListener('click', () => {
+ $('#tmAddErr').innerHTML = '';
+ fillAddForm();
+ });
+ return;
+ }
+ ownedAgents = res.body?.agents || [];
+ }
+ const taken = new Set(state.team.members.map((m) => m.agent.id));
+ const free = ownedAgents.filter((a) => !taken.has(a.id));
+ form.agent_id.innerHTML = free.length
+ ? `<option value="">Choose an agent</option>${free.map((a) => `<option value="${esc(a.id)}">${esc(a.name || a.display_name || 'Agent')}</option>`).join('')}`
+ : '<option value="">All of your agents are already on this team</option>';
+ form.agent_id.disabled = !free.length;
+ submit.disabled = !free.length;
+ const customCeiling = Object.keys(state.team.permission_catalog || {}).filter((p) => p !== 'trade.execute');
+ $('#tmAddPerms').innerHTML = permChecks('perm', customCeiling, ['findings.read', 'findings.write', 'research.run']);
+}
+
+function wireSettings() {
+ paintMembers();
+ fillAddForm();
+
+ $('#tmSetForm').addEventListener('submit', async (e) => {
+ e.preventDefault();
+ const form = e.currentTarget;
+ const fd = new FormData(form);
+ const opt = (k) => (String(fd.get(k) ?? '').trim() === '' ? null : Number(fd.get(k)));
+ const body = {
+ name: String(fd.get('name') || '').trim(),
+ description: String(fd.get('description') || '').trim(),
+ is_public: fd.get('is_public') === 'on',
+ policy: {
+ per_trade_sol: Number(fd.get('per_trade_sol')),
+ daily_budget_sol: Number(fd.get('daily_budget_sol')),
+ finding_ttl_seconds: Math.round(Number(fd.get('ttl_minutes')) * 60),
+ allow_caution: fd.get('allow_caution') === 'on',
+ entry: {
+ min_quality_score: opt('min_quality_score'),
+ max_bundle_score: opt('max_bundle_score'),
+ min_market_cap_usd: opt('min_market_cap_usd'),
+ max_market_cap_usd: opt('max_market_cap_usd'),
+ require_two_sided_market: fd.get('require_two_sided_market') === 'on',
+ require_smart_money: fd.get('require_smart_money') === 'on',
+ },
+ },
+ };
+ const errBox = $('#tmSetErr');
+ errBox.innerHTML = '';
+ if (!body.name) {
+ errBox.innerHTML = errorHtml({ message: 'Give the team a name.' });
+ return;
+ }
+ const restore = busy($('button[type="submit"]', form), 'Saving…');
+ const res = await api(`/api/teams/${state.id}`, { method: 'PATCH', body });
+ restore();
+ if (!res.ok) {
+ errBox.innerHTML = errorHtml(res);
+ return;
+ }
+ state.team = res.data;
+ $('.tm-head h1').textContent = state.team.name;
+ document.title = `${state.team.name} · Specialist Teams · three.ws`;
+ paintChrome();
+ toast('Settings saved.');
+ });
+
+ $('#tmAddForm').addEventListener('submit', async (e) => {
+ e.preventDefault();
+ const form = e.currentTarget;
+ const errBox = $('#tmAddErr');
+ errBox.innerHTML = '';
+ const agentId = form.agent_id.value;
+ if (!agentId) {
+ errBox.innerHTML = errorHtml({ message: 'Choose one of your agents.' });
+ return;
+ }
+ const permissions = $$('input[name="perm"]:checked', form).map((i) => i.value);
+ const restore = busy($('button[type="submit"]', form), 'Adding…');
+ const res = await api(`/api/teams/${state.id}/members`, { method: 'POST', body: { agent_id: agentId, permissions } });
+ restore();
+ if (!res.ok) {
+ errBox.innerHTML = errorHtml(res);
+ return;
+ }
+ await reloadTeam();
+ toast('Specialist added.');
+ });
+
+ $('#tmArchive').addEventListener('click', async (e) => {
+ const ok = await confirmDialog({
+ title: 'Archive this team?',
+ html: `<p><b>${esc(state.team.name)}</b> stops running and its page goes away. Its agents, their wallets and any funds in them stay in your account.</p>`,
+ okLabel: 'Archive team',
+ tone: 'live',
+ });
+ if (!ok) return;
+ const restore = busy(e.currentTarget, 'Archiving…');
+ const res = await api(`/api/teams/${state.id}`, { method: 'DELETE' });
+ if (!res.ok) {
+ restore();
+ return toast(res.message);
+ }
+ location.assign('/teams');
+ });
+}
+
+// ── route ────────────────────────────────────────────────────────────────────
+
+const match = location.pathname.match(/^\/teams\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/?$/i);
+if (match) renderDetail(match[1].toLowerCase());
+else renderList();
diff --git a/tests/teams-runtime.test.js b/tests/teams-runtime.test.js
index a41664d21..4d06ba4c0 100644
--- a/tests/teams-runtime.test.js
+++ b/tests/teams-runtime.test.js
@@ -46,7 +46,7 @@ import {
import {
POLICY_DEFAULTS, normalizeTeamPolicy, expiryFor, isLive, pickReusableResearch, traderClearance,
} from '../api/_lib/teams/findings.js';
-import { scoreResearch } from '../api/_lib/teams/research.js';
+import { scoreResearch, researchSummary } from '../api/_lib/teams/research.js';
// Synthetic 32-byte keys: valid Solana address shapes that are nobody's coin.
const MINT = (n) => new PublicKey(Uint8Array.from({ length: 32 }, (_, i) => (i * 7 + n) & 255)).toBase58();
@@ -204,6 +204,16 @@ describe('research scoring', () => {
expect(r.verdict).toBe('caution');
expect(r.subscores).toEqual({ safety: 90, quality: null, smart_money: null });
});
+
+ it('leads a downgraded verdict with the reason it was downgraded', () => {
+ const safety = { verdict: 'allow', score: 95, reasons: ['Mint authority is revoked.'] };
+ const r = scoreResearch({ safety, intel: null, smartMoney: null });
+ expect(r.reasons[0]).toMatch(/No intelligence record yet/);
+ expect(researchSummary(r)).toBe(`Caution at 95/100. ${r.reasons[0]}`);
+ const sold = scoreResearch({ safety, intel: { ...goodIntel, dev_sold: true }, smartMoney: null });
+ expect(sold.reasons[0]).toBe('The creator has sold.');
+ expect(sold.reasons.filter((x) => x === 'The creator has sold.')).toHaveLength(1);
+ });
});
// ── the board and the Trader on Postgres ─────────────────────────────────────
diff --git a/vite.config.js b/vite.config.js
index d74a611d6..16a1848c5 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -872,6 +872,7 @@ const appConfig = {
'ghost-copy': resolve(__dirname, 'pages/ghost-copy.html'),
'copy-coach': resolve(__dirname, 'pages/copy-coach.html'),
syndicates: resolve(__dirname, 'pages/syndicates.html'),
+ teams: resolve(__dirname, 'pages/teams.html'),
syndicate: resolve(__dirname, 'pages/syndicate.html'),
quests: resolve(__dirname, 'pages/quests.html'),
approvals: resolve(__dirname, 'pages/approvals.html'),
@@ -2351,6 +2352,10 @@ const appConfig = {
// `/syndicates/([^/.]+)/?`; the board itself is /syndicates.
else if (!filePath && /^\/syndicates\/[^/.]+\/?$/.test(path))
filePath = resolve(root, 'pages/syndicate.html');
+ // /teams/:id → one specialist team. Mirrors vercel.json's
+ // `/teams/([0-9a-fA-F-]{36})/?`; the list itself is /teams.
+ else if (!filePath && /^\/teams\/[0-9a-fA-F-]{36}\/?$/.test(path))
+ filePath = resolve(root, 'pages/teams.html');
// /duels/:id → one trader duel. Mirrors vercel.json's
// `/duels/([^/.]+)/?`; the board itself is /duels.
else if (!filePath && /^\/duels\/[^/.]+\/?$/.test(path))