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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(notifications): add notify method to Agent3DElement for avatar messaging feat(tools): introduce see_screen tool for capturing and describing visible content feat(migrations): create plugins table for community-published plugin manifests with seed data
nirholas9a03f23ccca7
diff --git a/api/_lib/migrations/2026-05-01-plugins.sql b/api/_lib/migrations/2026-05-01-plugins.sqlnew file mode 100644index 000000000..d59e072c1--- /dev/null+++ b/api/_lib/migrations/2026-05-01-plugins.sql@@ -0,0 +1,76 @@+-- ── plugins — JSON manifest plugin marketplace ───────────────────────────────+-- Each row is a community-published plugin manifest.+-- Plugins are keyed by (identifier, author_id) so the same identifier can be+-- published by different authors without conflict.++create table if not exists plugins (+ id uuid primary key default gen_random_uuid(),+ author_id uuid references users(id) on delete set null,+ identifier text not null,+ manifest_url text,+ manifest_json jsonb not null,+ name text not null,+ description text not null default '',+ category text not null default 'general',+ tags text[] not null default '{}',+ is_public boolean not null default true,+ install_count integer not null default 0,+ avg_rating numeric(3,2) not null default 0,+ rating_count integer not null default 0,+ deleted_at timestamptz,+ created_at timestamptz not null default now(),+ updated_at timestamptz not null default now(),+ unique (identifier, author_id)+);++create index if not exists plugins_category_idx on plugins(category);+create index if not exists plugins_author_idx on plugins(author_id);+create index if not exists plugins_popular_idx on plugins(install_count desc);+create index if not exists plugins_new_idx on plugins(created_at desc);+create index if not exists plugins_identifier_idx on plugins(identifier);++do $$ begin+ create trigger plugins_set_updated_at before update on plugins+ for each row execute function set_updated_at();+exception when duplicate_object then null; end $$;++-- ── Seed: built-in community plugins ─────────────────────────────────────────++insert into plugins (identifier, name, description, category, tags, manifest_json, is_public) values++('web-search', 'Web Search', 'Search the web for up-to-date information and return top results inline.',+ 'utility', '{"search","web","utility"}',+ '{"schema_version":"plugin/1.0","identifier":"web-search","version":"1.0.0","meta":{"title":"Web Search","description":"Search the web for up-to-date information and return top results inline.","tags":["search","web","utility"],"category":"utility"},"api":[{"name":"search_web","description":"Search the web for a query and return relevant results","url":null,"method":"POST","parameters":{"type":"object","properties":{"query":{"type":"string","description":"The search query"},"max_results":{"type":"integer","description":"Maximum number of results to return (default 5)","default":5}},"required":["query"]}}],"system_role":"You can search the web for current information. Use search_web when the user asks about recent events, current data, or anything you may not have up-to-date knowledge about."}',+ true),++('datetime', 'Date & Time', 'Get the current date, time, and timezone in any conversation.',+ 'utility', '{"time","date","timezone","utility"}',+ '{"schema_version":"plugin/1.0","identifier":"datetime","version":"1.0.0","meta":{"title":"Date & Time","description":"Get the current date, time, and timezone in any conversation.","tags":["time","date","timezone","utility"],"category":"utility"},"api":[{"name":"get_current_time","description":"Get the current date and time for a given timezone","url":null,"method":"POST","parameters":{"type":"object","properties":{"timezone":{"type":"string","description":"IANA timezone name (e.g. America/New_York). Defaults to UTC.","default":"UTC"}},"required":[]}},{"name":"convert_timezone","description":"Convert a time from one timezone to another","url":null,"method":"POST","parameters":{"type":"object","properties":{"time":{"type":"string","description":"ISO 8601 datetime string"},"from_tz":{"type":"string","description":"Source IANA timezone"},"to_tz":{"type":"string","description":"Target IANA timezone"}},"required":["time","from_tz","to_tz"]}}],"system_role":"You can retrieve the current date and time and convert between timezones. Use get_current_time when the user asks what time or date it is."}',+ true),++('calculator', 'Calculator', 'Perform precise arithmetic calculations and unit conversions.',+ 'utility', '{"math","calculator","arithmetic","utility"}',+ '{"schema_version":"plugin/1.0","identifier":"calculator","version":"1.0.0","meta":{"title":"Calculator","description":"Perform precise arithmetic calculations and unit conversions.","tags":["math","calculator","arithmetic","utility"],"category":"utility"},"api":[{"name":"calculate","description":"Evaluate a mathematical expression and return the result","url":null,"method":"POST","parameters":{"type":"object","properties":{"expression":{"type":"string","description":"Mathematical expression to evaluate (e.g. 2 + 2, sqrt(16), sin(pi/2))"}},"required":["expression"]}}],"system_role":"You have access to a calculator. Use calculate for any arithmetic, algebra, or trigonometry the user requests."}',+ true),++('image-gen', 'Image Generator', 'Generate images from text descriptions using AI.',+ 'creative', '{"image","ai","creative","generation"}',+ '{"schema_version":"plugin/1.0","identifier":"image-gen","version":"1.0.0","meta":{"title":"Image Generator","description":"Generate images from text descriptions using AI.","tags":["image","ai","creative","generation"],"category":"creative"},"api":[{"name":"generate_image","description":"Generate an image from a text prompt","url":null,"method":"POST","parameters":{"type":"object","properties":{"prompt":{"type":"string","description":"Detailed description of the image to generate"},"style":{"type":"string","description":"Art style (e.g. photorealistic, cartoon, watercolor)","default":"photorealistic"},"size":{"type":"string","description":"Image dimensions","enum":["512x512","1024x1024","1792x1024"],"default":"1024x1024"}},"required":["prompt"]}}],"system_role":"You can generate images from text descriptions. Use generate_image when the user asks you to create, draw, or visualize something."}',+ true),++('weather', 'Weather', 'Get real-time weather conditions and forecasts for any location.',+ 'utility', '{"weather","forecast","location","utility"}',+ '{"schema_version":"plugin/1.0","identifier":"weather","version":"1.0.0","meta":{"title":"Weather","description":"Get real-time weather conditions and forecasts for any location.","tags":["weather","forecast","location","utility"],"category":"utility"},"api":[{"name":"get_weather","description":"Get current weather conditions for a location","url":null,"method":"POST","parameters":{"type":"object","properties":{"location":{"type":"string","description":"City name or coordinates (lat,lon)"},"units":{"type":"string","description":"Temperature units","enum":["celsius","fahrenheit"],"default":"celsius"}},"required":["location"]}},{"name":"get_forecast","description":"Get a multi-day weather forecast for a location","url":null,"method":"POST","parameters":{"type":"object","properties":{"location":{"type":"string","description":"City name or coordinates"},"days":{"type":"integer","description":"Number of forecast days (1-7)","default":3},"units":{"type":"string","description":"Temperature units","enum":["celsius","fahrenheit"],"default":"celsius"}},"required":["location"]}}],"system_role":"You can retrieve live weather conditions and forecasts. Use get_weather for current conditions and get_forecast for multi-day outlooks."}',+ true),++('code-runner', 'Code Runner', 'Execute Python, JavaScript, or shell code snippets in a sandbox.',+ 'developer', '{"code","python","javascript","developer","sandbox"}',+ '{"schema_version":"plugin/1.0","identifier":"code-runner","version":"1.0.0","meta":{"title":"Code Runner","description":"Execute Python, JavaScript, or shell code snippets in a sandbox.","tags":["code","python","javascript","developer","sandbox"],"category":"developer"},"api":[{"name":"run_code","description":"Execute a code snippet in a sandboxed environment","url":null,"method":"POST","parameters":{"type":"object","properties":{"code":{"type":"string","description":"The code to execute"},"language":{"type":"string","description":"Programming language","enum":["python","javascript","bash"],"default":"python"}},"required":["code"]}}],"system_role":"You can run code in a secure sandbox. Use run_code when the user wants to test code, run calculations, or verify logic."}',+ true),++('tradingview', 'TradingView Charts', 'Embed live candlestick charts for any crypto or stock symbol.',+ 'finance', '{"finance","crypto","stocks","charts","tradingview"}',+ '{"schema_version":"plugin/1.0","identifier":"tradingview","version":"1.0.0","meta":{"title":"TradingView Charts","description":"Embed live candlestick charts for any crypto or stock symbol.","tags":["finance","crypto","stocks","charts","tradingview"],"category":"finance"},"api":[{"name":"show_chart","description":"Display a TradingView chart for a symbol","url":null,"method":"POST","parameters":{"type":"object","properties":{"symbol":{"type":"string","description":"Ticker symbol (e.g. BTCUSDT, AAPL, EURUSD)"},"interval":{"type":"string","description":"Chart interval","enum":["1m","5m","15m","1h","4h","1D","1W"],"default":"1D"},"theme":{"type":"string","description":"Chart color theme","enum":["dark","light"],"default":"dark"}},"required":["symbol"]}}],"system_role":"You can show live TradingView charts. Use show_chart when the user asks about price action, charts, or technical analysis for any tradable symbol."}',+ true)++on conflict (identifier, author_id) do nothing;diff --git a/api/marketplace/[action].js b/api/marketplace/[action].jsindex d2c76b392..d24f1a603 100644--- a/api/marketplace/[action].js+++ b/api/marketplace/[action].js@@ -137,6 +137,106 @@ async function handleCategories(req, res) {);}+// ── Create ─────────────────────────────────────────────────────────────────++async function handleCreate(req, res) {+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;+ if (!method(req, res, ['POST'])) return;++ const auth = await resolveAuth(req);+ if (!auth) return error(res, 401, 'unauthorized', 'sign in required');++ const rl = await limits.authIp(clientIp(req));+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');++ let body = await readJson(req).catch(() => null);+ if (!body) return error(res, 400, 'validation_error', 'request body required');++ // Accept LobeHub-compatible JSON import: { json: { config, meta } }+ if (body.json && typeof body.json === 'object') {+ const j = body.json;+ body = {+ name: j.meta?.title || j.meta?.name || '',+ description: j.meta?.description || '',+ system_prompt: j.config?.systemRole || '',+ greeting: j.config?.greeting || null,+ category: j.meta?.category || 'general',+ tags: j.meta?.tags || [],+ capabilities: j.meta?.capabilities || {},+ publish: false,+ };+ }++ const parsed = createAgentSchema.safeParse(body);+ if (!parsed.success) {+ const msg = parsed.error.issues[0]?.message || 'validation error';+ return error(res, 400, 'validation_error', msg);+ }++ const { name, description, system_prompt, greeting, category, tags, capabilities, publish } =+ parsed.data;+ const publishedAt = publish ? new Date().toISOString() : null;++ const [agent] = await sql`+ INSERT INTO agent_identities (+ user_id, name, description, system_prompt, greeting,+ category, tags, capabilities, is_published, published_at+ )+ VALUES (+ ${auth.userId}, ${name}, ${description}, ${system_prompt}, ${greeting ?? null},+ ${category}, ${tags}, ${JSON.stringify(capabilities)}::jsonb,+ ${publish}, ${publishedAt}+ )+ RETURNING *+ `;++ if (publish) {+ await sql`+ INSERT INTO agent_versions (+ agent_id, version, system_prompt, greeting, category, tags, capabilities, changelog, created_by+ )+ VALUES (+ ${agent.id}, 1, ${system_prompt}, ${greeting ?? null}, ${category}, ${tags},+ ${JSON.stringify(capabilities)}::jsonb, 'Initial release', ${auth.userId}+ )+ `;+ }++ return json(res, 201, {+ data: { agent: toDetail({ ...agent, author_name: null, author_avatar: null }) },+ });+}++// ── Mine ───────────────────────────────────────────────────────────────────++async function handleMine(req, res) {+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: true })) return;+ if (!method(req, res, ['GET'])) return;++ const auth = await resolveAuth(req);+ if (!auth) return error(res, 401, 'unauthorized', 'sign in required');++ const rl = await limits.widgetRead(clientIp(req));+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');++ const rows = await sql`+ SELECT ai.id, ai.name, ai.description, ai.category, ai.tags, ai.avatar_id, ai.user_id,+ ai.forks_count, ai.views_count, ai.published_at, ai.created_at, ai.skills,+ ai.is_published, av.thumbnail_key+ FROM agent_identities ai+ LEFT JOIN avatars av ON av.id = ai.avatar_id AND av.deleted_at IS NULL+ WHERE ai.user_id = ${auth.userId} AND ai.deleted_at IS NULL+ ORDER BY ai.created_at DESC+ LIMIT 100+ `;++ return json(res, 200, {+ data: {+ items: rows.map((r) => ({ ...toCard(r), is_published: r.is_published })),+ },+ });+}+// ── List ───────────────────────────────────────────────────────────────────async function handleList(req, res, url) {diff --git a/marketplace.html b/marketplace.htmlindex 12bd7357d..e1a350e50 100644--- a/marketplace.html+++ b/marketplace.html@@ -41,7 +41,9 @@<a href="/marketplace?tab=tools" data-nav="tools"><span class="ico">⚙</span> Tools</a><a href="/features" data-nav="skills"><span class="ico">≡</span> Skills</a><a href="/dashboard" data-nav="model"><span class="ico">◉</span> Model</a>+ <a href="/marketplace?tab=mine" data-nav="mine"><span class="ico">◱</span> My Agents</a></nav>+ <button class="market-submit-btn market-sidebar-submit" id="market-submit-btn">+ Submit Agent</button></aside><main class="market-main" id="market-main">@@ -59,6 +61,7 @@<option value="recent">Recent</option><option value="popular">Popular</option></select>+ <button class="market-submit-btn" id="market-submit-btn-top">+ Submit Agent</button></header><div class="market-body">@@ -139,6 +142,7 @@<aside class="market-detail-side"><button class="market-fork" id="d-fork">Fork & Chat</button>+ <button class="market-export-btn" id="d-export-json">↓ Export JSON</button><div class="market-card market-overview-card"><div class="row"><span>What can you do with this Agent?</span>@@ -150,6 +154,17 @@</div></section>+ <!-- My Agents tab -->+ <section class="market-mine" id="market-mine" hidden>+ <header class="market-topbar">+ <h2 class="market-section-heading">My Agents</h2>+ <button class="market-submit-btn" id="market-new-agent-btn">+ New Agent</button>+ </header>+ <div class="market-mine-body">+ <div class="market-grid" id="mine-grid"></div>+ </div>+ </section>+<!-- Tools tab --><section class="market-tools" id="market-tools" hidden><header class="market-topbar">diff --git a/src/CLAUDE.md b/src/CLAUDE.mdindex f0679991f..d290e309f 100644--- a/src/CLAUDE.md+++ b/src/CLAUDE.md@@ -78,6 +78,7 @@ All events are `CustomEvent` with `detail = { type, payload, timestamp, agentId,| `validate` | `{ errors, warnings }` | validator | avatar, identity || `presence` | `{ state }` | element | home || `interrupted` | `{}` | speech.js (TTS cancel) | avatar (startle + curiosity) |+| `notify` | `{ message, priority, duration }` | element.notify(), data-reactive | AgentNotifier (enter/exit frame + speak) |**Identity records these to the backend:** `speak`, `remember`, `sign`, `skill-done`, `validate`, `load-end`. Fire-and-forget via `POST /api/agent-actions`.diff --git a/src/agent-avatar.js b/src/agent-avatar.jsindex d58278423..b8a0c13b6 100644--- a/src/agent-avatar.js+++ b/src/agent-avatar.js@@ -35,6 +35,7 @@ const DECAY = {patience: 0.035, // half-life ~20s — sustained waiting statecuriosity: 0.12, // half-life ~8s — alert, engagedempathy: 0.055, // half-life ~13s — slow to fade, like real empathy+ uncertain: 0.10, // half-life ~7s — hedged speech signal};// Vocabulary scored for emotional valence@@ -109,6 +110,27 @@ const VOCAB = {'oops','unfortunately',],+ uncertain: [+ 'i think',+ 'not sure',+ 'might be',+ 'probably',+ 'possibly',+ 'i believe',+ "i'm not certain",+ 'could be',+ 'maybe',+ 'roughly',+ 'approximately',+ 'unclear',+ 'uncertain',+ 'hard to say',+ 'it depends',+ "i'd guess",+ 'seems like',+ 'appears to',+ 'not entirely sure',+ ],};export class AgentAvatar {@@ -130,6 +152,7 @@ export class AgentAvatar {patience: 0.0,curiosity: 0.0,empathy: 0.0,+ uncertain: 0.0,};// Head look-at state@@ -184,7 +207,7 @@ export class AgentAvatar {/** Call after viewer.setContent() loads the avatar model */attach() {// Reset emotion to neutral so re-attaching a previously emotional avatar starts clean- this._emotion = { neutral: 1.0, concern: 0, celebration: 0, patience: 0, curiosity: 0, empathy: 0 };+ this._emotion = { neutral: 1.0, concern: 0, celebration: 0, patience: 0, curiosity: 0, empathy: 0, uncertain: 0 };// Build the morph mesh cache once instead of traversing every framethis._buildMorphCache();@@ -359,6 +382,10 @@ export class AgentAvatar {// High-arousal text (questions, exclamations) → curiosityif (arousal > 0.5) this._injectStimulus('curiosity', arousal * 0.5);+ // Hedging language → uncertain+ const uncertainScore = this._scoreVocab(text, 'uncertain');+ if (uncertainScore > 0) this._injectStimulus('uncertain', Math.min(uncertainScore * 0.4, 0.8));+// Trigger mouth/talk animation hintconst duration = Math.max(1.5, text.split(' ').length * 0.3);this._triggerOneShot('talk', duration);@@ -548,7 +575,9 @@ export class AgentAvatar {(this._isPlayingOneShot && this._oneShotAction === 'talk' ? 0.4 : 0),);this._setMorphTarget('mouthFrown', w.concern * 0.55);- this._setMorphTarget('browInnerUp', (w.concern + w.empathy * 0.5) * 0.6);+ this._setMorphTarget('mouthPressLeft', w.uncertain * 0.35);+ this._setMorphTarget('mouthPressRight', w.uncertain * 0.35);+ this._setMorphTarget('browInnerUp', Math.max(w.concern * 0.6, w.uncertain * 0.45, w.empathy * 0.5));this._setMorphTarget('browOuterUpLeft', w.curiosity * 0.7);this._setMorphTarget('browOuterUpRight', w.curiosity * 0.5);this._setMorphTarget('eyeSquintLeft', w.empathy * 0.4);@@ -562,6 +591,9 @@ export class AgentAvatar {const lerpSpeed = dt * 4.0; // smooth interpolation, not snappingthis._lerpMorphTargets(lerpSpeed);+ // Propagate uncertainty to idle animation (modulates hip drift amplitude)+ this._idle?.setUncertainty(w.uncertain);+// ── Head tilt (curiosity + empathy both tilt the head) ────────────this._targetTilt = (w.curiosity * 12 + w.empathy * 9 + w.concern * 4) * DEG2RAD;@@ -822,6 +854,27 @@ export class AgentAvatar {};}++ /**+ * Score a single emotion bucket against the text.+ * Mirrors the per-bucket logic inside _analyzeSentiment.+ * @param {string} text+ * @param {string} bucket — key in VOCAB+ * @returns {number} 0..1+ */+ _scoreVocab(text, bucket) {+ const keywords = VOCAB[bucket];+ if (!keywords) return 0;+ const lower = text.toLowerCase();+ const wordSet = new Set(lower.split(/\s+/));+ const total = Math.max(wordSet.size, 1);+ let hits = 0;+ for (const kw of keywords) {+ if (kw.includes(' ') ? lower.includes(kw) : wordSet.has(kw)) hits++;+ }+ return Math.min((hits / total) * 3.0, 1.0);+ }+// ── Utility ───────────────────────────────────────────────────────────────_sub(type, handler) {diff --git a/src/element.js b/src/element.jsindex 449015110..d141f97d6 100644--- a/src/element.js+++ b/src/element.js@@ -1716,6 +1716,16 @@ class Agent3DElement extends HTMLElement {this._teardown();}+ /**+ * Slide the avatar into frame, speak a message, then retreat.+ * Queued — back-to-back calls wait for the previous to finish.+ * @param {string} message+ * @param {{ priority?: 'low'|'normal'|'high', duration?: number }} [opts]+ */+ notify(message, { priority = 'normal', duration = 6000 } = {}) {+ protocol.emit({ type: ACTION_TYPES.NOTIFY, payload: { message, priority, duration } });+ }+/*** Trigger an emotion stimulus on the running avatar(s) via the protocol bus.* Trigger names match the avatar's emotion vocabulary:diff --git a/src/runtime/index.js b/src/runtime/index.jsindex 68c16cc4c..a739f91c7 100644--- a/src/runtime/index.js+++ b/src/runtime/index.js@@ -150,7 +150,33 @@ export class Runtime extends EventTarget {);results.push({ id: call.id, output, isError });}- this.messages.push(this.provider.formatToolResults(results));+ const hasImage = results.some((r) => r.output?.imageData);+ if (hasImage) {+ const content = results.map((r) => {+ const block = {+ type: 'tool_result',+ tool_use_id: r.id,+ is_error: !!r.isError,+ };+ if (r.output?.imageData) {+ const b64 = r.output.imageData.replace(/^data:[^;]+;base64,/, '');+ block.content = [+ { type: 'text', text: r.output.description || 'Screen captured.' },+ {+ type: 'image',+ source: { type: 'base64', media_type: 'image/jpeg', data: b64 },+ },+ ];+ } else {+ block.content =+ typeof r.output === 'string' ? r.output : JSON.stringify(r.output);+ }+ return block;+ });+ this.messages.push({ role: 'user', content });+ } else {+ this.messages.push(this.provider.formatToolResults(results));+ }}return { text: finalText };diff --git a/src/runtime/tools.js b/src/runtime/tools.jsindex e0202b941..a6763af74 100644--- a/src/runtime/tools.js+++ b/src/runtime/tools.js@@ -81,6 +81,23 @@ export const BUILTIN_TOOLS = [required: ['key', 'name', 'description', 'type', 'body'],},},+ {+ name: 'see_screen',+ description:+ 'Capture what is currently visible on screen and describe it to inform your response.',+ input_schema: {+ type: 'object',+ properties: {+ mode: {+ type: 'string',+ enum: ['canvas', 'text', 'screen'],+ description:+ 'canvas=3D viewport only (default), text=page text content, screen=full screen capture (requires user permission)',+ },+ },+ required: [],+ },+ },];// Stage-scoped tools — appended to an agent's tool list only when Runtime is@@ -154,6 +171,20 @@ export const BUILTIN_HANDLERS = {return { ok: true, saved: key };},+ async see_screen(args, ctx) {+ const { captureContext } = await import('./screen-context.js');+ const mode = args.mode ?? 'canvas';+ try {+ const result = await captureContext(ctx.viewer.renderer, { mode });+ if (result.type === 'image') {+ return { ok: true, imageData: result.data, description: 'Screen captured.' };+ }+ return { ok: true, text: result.data };+ } catch (err) {+ return { ok: false, error: err.message || 'Screen capture failed.' };+ }+ },+async observe_agents(args, ctx) {if (!ctx.stage) return { ok: false, error: 'not on a stage' };const others = ctx.stage