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
chore(qa): end-to-end smoke test + surgical fixes
nirholase7c088779899
diff --git a/docs/SMOKE_TEST.md b/docs/SMOKE_TEST.mdindex c6782322e..a6d3467cd 100644--- a/docs/SMOKE_TEST.md+++ b/docs/SMOKE_TEST.md@@ -9,20 +9,20 @@## Summary-| Flow | Result | Notes |-|------|--------|-------|-| A. Wallet sign-in | BLOCKED | No browser or MetaMask in CI environment. Static analysis: SIWE nonce + verify endpoints exist and pass `node --check`. Login page present at `/public/login.html`. |-| B. Selfie → agent | BLOCKED | Requires camera hardware + Avaturn API key. Static analysis: `src/selfie-capture.js`, `src/selfie-pipeline.js`, `src/avaturn-client.js` all pass `node --check`. `/create` route maps to `create.html`. |-| C. Edit + save-back | BLOCKED | Requires authenticated session + owned agent. Static analysis: `src/editor/save-back.js`, `/api/avatars/[id]/versions.js` both present and syntactically valid. |-| D. Share + embed | BLOCKED | Requires browser + running agent. Static analysis: `src/share-panel.js` exports `SharePanel`. CORS headers set in `api/_lib/http.js`. `agent-embed.html` has `frame-ancestors` CSP meta tag. |-| E. Embed bridge round-trip | BLOCKED | Requires browser. Static analysis: `src/embed-host-bridge.js` and `src/embed-action-bridge.js` implement ping/pong handshake. `op: 'speak'` mapped to `speak` action in bridge. |-| F. Idle loop | FAIL | `src/idle-animation.js` exports `IdleAnimation` class but it is **never imported anywhere** in the codebase. Blink + head-drift are not wired into the agent avatar system. Escalated — see defects below. |-| G. Discover page | BLOCKED | Requires seeded Base Sepolia wallet. Static analysis: `/public/explore/index.html` + `explore.js` present. `/api/explore.js` endpoint present. Import flow routes to `/hydrate`. |-| H. Deploy on-chain | BLOCKED | Requires MetaMask + Base Sepolia test ETH. Static analysis: `src/erc8004/agent-registry.js` + `src/agent-home-orphans.js` implement `DeployButton` wiring into `agent-home.html`. |-| I. LobeHub plugin | FAIL | `lobehub-plugin/dev/index.html` dev harness **does not exist** (required by Flow I step 2). `lobehub-plugin/` has `src/`, `dist/`, `package.json` but no `dev/` directory. Escalated — see defects below. |-| J. Dashboard sidebar | BLOCKED | Requires authenticated session. Static analysis: all 6 pages present (`index.html`, `actions.html`, `sessions.html`, `wallets.html`, `usage.html`, `embed-policy.html`). All import from `dashboard.js`. |-| K. Logout + session revocation | BLOCKED | Requires authenticated session. Static analysis: `DELETE /api/auth/sessions` endpoint confirmed — revokes all non-current sessions and returns `{ revoked: N }`. Sessions page calls this correctly. |-| L. Mobile layout | BLOCKED | Requires browser + devtools. Static analysis: all key pages (`index.html`, `agent-home.html`, `agent-embed.html`, `public/dashboard/index.html`) have `<meta name="viewport" content="width=device-width, initial-scale=1">`. |+| Flow | Result | Notes |+| ------------------------------ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| A. Wallet sign-in | BLOCKED | No browser or MetaMask in CI environment. Static analysis: SIWE nonce + verify endpoints exist and pass `node --check`. Login page present at `/public/login.html`. |+| B. Selfie → agent | BLOCKED | Requires camera hardware + Avaturn API key. Static analysis: `src/selfie-capture.js`, `src/selfie-pipeline.js`, `src/avaturn-client.js` all pass `node --check`. `/create` route maps to `create.html`. |+| C. Edit + save-back | BLOCKED | Requires authenticated session + owned agent. Static analysis: `src/editor/save-back.js`, `/api/avatars/[id]/versions.js` both present and syntactically valid. |+| D. Share + embed | BLOCKED | Requires browser + running agent. Static analysis: `src/share-panel.js` exports `SharePanel`. CORS headers set in `api/_lib/http.js`. `agent-embed.html` has `frame-ancestors` CSP meta tag. |+| E. Embed bridge round-trip | BLOCKED | Requires browser. Static analysis: `src/embed-host-bridge.js` and `src/embed-action-bridge.js` implement ping/pong handshake. `op: 'speak'` mapped to `speak` action in bridge. |+| F. Idle loop | FAIL | `src/idle-animation.js` exports `IdleAnimation` class but it is **never imported anywhere** in the codebase. Blink + head-drift are not wired into the agent avatar system. Escalated — see defects below. |+| G. Discover page | BLOCKED | Requires seeded Base Sepolia wallet. Static analysis: `/public/explore/index.html` + `explore.js` present. `/api/explore.js` endpoint present. Import flow routes to `/hydrate`. |+| H. Deploy on-chain | BLOCKED | Requires MetaMask + Base Sepolia test ETH. Static analysis: `src/erc8004/agent-registry.js` + `src/agent-home-orphans.js` implement `DeployButton` wiring into `agent-home.html`. |+| I. LobeHub plugin | FAIL | `lobehub-plugin/dev/index.html` dev harness **does not exist** (required by Flow I step 2). `lobehub-plugin/` has `src/`, `dist/`, `package.json` but no `dev/` directory. Escalated — see defects below. |+| J. Dashboard sidebar | BLOCKED | Requires authenticated session. Static analysis: all 6 pages present (`index.html`, `actions.html`, `sessions.html`, `wallets.html`, `usage.html`, `embed-policy.html`). All import from `dashboard.js`. |+| K. Logout + session revocation | BLOCKED | Requires authenticated session. Static analysis: `DELETE /api/auth/sessions` endpoint confirmed — revokes all non-current sessions and returns `{ revoked: N }`. Sessions page calls this correctly. |+| L. Mobile layout | BLOCKED | Requires browser + devtools. Static analysis: all key pages (`index.html`, `agent-home.html`, `agent-embed.html`, `public/dashboard/index.html`) have `<meta name="viewport" content="width=device-width, initial-scale=1">`. |**Flows fully verified by static analysis:** Build passes (`npm run build` ✓), `npm run verify` passes (✓), all modified JS files pass `node --check`.@@ -55,6 +55,7 @@This smoke test was executed in a headless Codespace environment with no browser, no MetaMask, no camera hardware, and no Base Sepolia test wallet. All flows requiring a browser (A, B, C, D, E, G, H, J, K, L) are marked BLOCKED, not FAIL — the code paths are present and syntactically valid; they simply could not be exercised interactively.**To re-run this test with a browser:**+1. `npm run dev` → open `http://localhost:3000/` in Chrome.2. For Flows A/H: use MetaMask with a fresh account on Base Sepolia. Fund from https://sepoliafaucet.com.3. For Flow B: the Avaturn pipeline requires `VITE_AVATURN_API_KEY` in `.env.local`.@@ -62,6 +63,7 @@ This smoke test was executed in a headless Codespace environment with no browser5. For Flow I: create `lobehub-plugin/dev/index.html` first (see defects above).**Verified without browser:**+- `npm run verify` → exits 0 (prettier + vite build both pass).- `node --check` on all key source files → no syntax errors.- All 12 flow entry points (HTML pages, API routes) confirmed present in filesystem.diff --git a/lobehub-plugin/README.md b/lobehub-plugin/README.mdindex 126ad016a..a21a62520 100644--- a/lobehub-plugin/README.md+++ b/lobehub-plugin/README.md@@ -10,9 +10,9 @@ Render an embodied 3D avatar in the LobeChat sidebar. The avatar reacts to the L1. In LobeChat, open **Plugins → Plugin Store → Custom plugins**.2. Paste the manifest URL:- ```- https://3dagent.vercel.app/.well-known/lobehub-plugin.json- ```+ ```+ https://3dagent.vercel.app/.well-known/lobehub-plugin.json+ ```3. Click **Install**. LobeChat will show the plugin settings dialog.4. Enter your **Agent ID** (UUID from the 3D Agent dashboard at `https://3dagent.vercel.app/dashboard`).5. Click **Save**. The 3D avatar appears in the right sidebar.@@ -21,10 +21,10 @@ Render an embodied 3D avatar in the LobeChat sidebar. The avatar reacts to the L## Configuration-| Setting | Type | Required | Default | Description |-|---|---|---|---|---|-| `agentId` | `string` | Yes | — | Agent UUID from the 3D Agent dashboard |-| `apiOrigin` | `string` | No | `https://3dagent.vercel.app` | Override for self-hosted instances |+| Setting | Type | Required | Default | Description |+| ----------- | -------- | -------- | ---------------------------- | -------------------------------------- |+| `agentId` | `string` | Yes | — | Agent UUID from the 3D Agent dashboard |+| `apiOrigin` | `string` | No | `https://3dagent.vercel.app` | Override for self-hosted instances |---@@ -51,12 +51,12 @@ LobeChat (and `@lobehub/chat-plugin-sdk` internally) sends:```json{- "type": "LobePlugin.renderPlugin",- "payload": {- "apiName": "speak",- "arguments": "{\"text\":\"Hello!\",\"sentiment\":0.5}",- "identifier": "3d-agent"- }+ "type": "LobePlugin.renderPlugin",+ "payload": {+ "apiName": "speak",+ "arguments": "{\"text\":\"Hello!\",\"sentiment\":0.5}",+ "identifier": "3d-agent"+ }}```@@ -68,13 +68,13 @@ Bridge envelope:```json{- "v": 1,- "source": "agent-host",- "id": "<uuid>",- "inReplyTo": "<request-id>",- "kind": "request | response | event",- "op": "speak | gesture | emote | look | setAgent | ping | subscribe",- "payload": {}+ "v": 1,+ "source": "agent-host",+ "id": "<uuid>",+ "inReplyTo": "<request-id>",+ "kind": "request | response | event",+ "op": "speak | gesture | emote | look | setAgent | ping | subscribe",+ "payload": {}}```@@ -84,12 +84,12 @@ Full spec: [`01-embed-bridges.md`](../prompts/final-integration/01-embed-bridges## Available tool ops-| Op | Payload | Description |-|---|---|---|-| `render_agent` | `{ agentId }` | Swap the agent in the sidebar |-| `speak` | `{ text, sentiment? [-1,1] }` | Avatar speaks with emotional valence |-| `gesture` | `{ name: wave\|nod\|point\|shrug }` | Trigger a named gesture |-| `emote` | `{ trigger, weight? [0,1] }` | Inject emotion into the Empathy Layer |+| Op | Payload | Description |+| -------------- | ----------------------------------- | ------------------------------------- |+| `render_agent` | `{ agentId }` | Swap the agent in the sidebar |+| `speak` | `{ text, sentiment? [-1,1] }` | Avatar speaks with emotional valence |+| `gesture` | `{ name: wave\|nod\|point\|shrug }` | Trigger a named gesture |+| `emote` | `{ trigger, weight? [0,1] }` | Inject emotion into the Empathy Layer |---@@ -129,13 +129,13 @@ Output: `dist/bundle.js` — tree-shaken, browser-targeted. React and react-dom## Troubleshooting-| Symptom | Likely cause | Fix |-|---|---|---|-| Avatar never appears | Wrong `agentId` | Copy UUID from dashboard; ensure agent has an avatar |-| "Loading agent…" stuck | Bridge handshake failed | Check browser console for `[3d-agent]` messages; verify `apiOrigin` is reachable |-| `speak` does nothing | LobeChat hasn't installed the plugin | Confirm plugin is active in LobeChat Plugin Store |-| CORS error | Self-hosted origin not allowed | Add origin to `CORS_ORIGINS` in your 3D Agent deployment |-| Timeout errors | Network latency | The bridge has a 10 s timeout; the iframe may still be loading the web component |+| Symptom | Likely cause | Fix |+| ---------------------- | ------------------------------------ | -------------------------------------------------------------------------------- |+| Avatar never appears | Wrong `agentId` | Copy UUID from dashboard; ensure agent has an avatar |+| "Loading agent…" stuck | Bridge handshake failed | Check browser console for `[3d-agent]` messages; verify `apiOrigin` is reachable |+| `speak` does nothing | LobeChat hasn't installed the plugin | Confirm plugin is active in LobeChat Plugin Store |+| CORS error | Self-hosted origin not allowed | Add origin to `CORS_ORIGINS` in your 3D Agent deployment |+| Timeout errors | Network latency | The bridge has a 10 s timeout; the iframe may still be loading the web component |---diff --git a/public/dashboard/avaturn-sdk.js b/public/dashboard/avaturn-sdk.jsindex 8133d66ea..e3ded471c 100644--- a/public/dashboard/avaturn-sdk.js+++ b/public/dashboard/avaturn-sdk.js@@ -1 +1,432 @@-function e(t,s){return e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e(t,s)}var t,s;!function(e){e.AuthError="auth_error",e.AvatarLoadError="avatar_load_error",e.SceneError="scene_error"}(t||(t={})),function(e){e.AskForDefaults="ask_for_defaults",e.SDKHandshake="sdk_handshake",e.SDKHandshakeConfirmation="sdk_handshake_confirmation",e.CallbackEvent="callback_event",e.ReportError="report_error",e.GetAssetList="get_assets_list",e.GetActiveAssets="get_active_assets",e.SetAvailableAssets="set_assets_list",e.SetActiveAsset="set_active_asset",e.GetBodyList="get_bodies_list",e.GetActiveBody="get_avatar_info",e.SetAvailableBodies="set_bodies_list",e.SetActiveBody="set_active_body",e.GetAnimationList="get_animation_list",e.GetActiveAnimation="get_animation_info",e.SetActiveAnimation="set_active_animation",e.ExportAvatar="export_avatar",e.GenerateThumbnail="generate_thumbnail",e.SetParam="set_param",e.SetEyeColor="set_eye_color",e.SetHairColor="set_hair_color",e.SetEyewearColor="set_eyewear_color",e.SetBodyProportions="set_body_proportions",e.SetSkinTone="set_skin_tone",e.GetEyeColor="get_eye_color",e.GetHairColor="get_hair_color",e.GetEyewearColor="get_eyewear_color",e.GetBodyProportions="get_body_proportions",e.GetSkinTone="get_skin_tone",e.GetAvatarId="get_avatar_id"}(s||(s={}));var r=/*#__PURE__*/function(){function e(){this.listeners={}}var t=e.prototype;return t.watch=function(e,t){this.listeners[e]=t},t.unwatch=function(e){delete this.listeners[e]},e}(),n=/*#__PURE__*/function(){function e(e,t){this.handshakeData={},this.recipient=void 0,this.thisSourceName="v1.avaturn-sdk",this.expectedIncomingSourceName="v1.avaturn-sdk-server",this._queue=new r,this._messageHandler=this.messageHandler.bind(this),e&&(this.thisSourceName=e),t&&(this.expectedIncomingSourceName=t)}var t=e.prototype;return t.sendMessage=function(e,t,s,r){var n=this;return void 0===r&&(r=!0),new Promise(function(o,i){var a,c=Date.now(),u=s||e+c;r&&n._queue.watch(u,function(e,t){var s=null!=t?t:null;e?o(s):i(s),n._queue.unwatch(u)}),null==(a=n.recipient)||a.postMessage({type:"MESSAGE",source:n.thisSourceName,eventName:e,key:u,date:c,data:t,isOk:!0},"*"),r||o(null)})},t.messageHandler=function(e){var t=e.data;this.expectedIncomingSourceName==t.source&&("RESPONSE"===t.type&&("sdk_handshake"===t.key&&this.sendMessage(s.SDKHandshakeConfirmation,this.handshakeData,void 0,!1),this._queue.listeners[t.key]&&this._queue.listeners[t.key](t.isOk,t.data)),"MESSAGE"===t.type&&this.handleMessage(t))},t.setupMessaging=function(){window.addEventListener("message",this._messageHandler)},t.destroyMessaging=function(){console.log("destroy"),window.removeEventListener("message",this._messageHandler)},t.sendResponse=function(e,t,s){var r,n=void 0===s?{isOk:!0}:s,o=n.isOk,i=n.data;if(this.recipient){var a={type:"RESPONSE",source:this.thisSourceName,eventName:e,key:t,date:Date.now(),data:i,isOk:o};null==(r=this.recipient)||r.postMessage(a,"*")}else console.log("Recipient is not set.")},t.handleMessage=function(e){},e}(),o=/*#__PURE__*/function(t){function r(){var e;return(e=t.call(this)||this)._version="1.1.4",e.defaultAssets=void 0,e.sceneRef=null,e.callbacks={},e.suppressCallbacks=void 0,e}var n,o;o=t,(n=r).prototype=Object.create(o.prototype),n.prototype.constructor=n,e(n,o);var i=r.prototype;return i.applyStyles=function(e){e.style.width="100%",e.style.height="100%"},i.validateDefaultAssets=function(e){return"object"==typeof e&&"boolean"==typeof e.overrideSaved&&!!Array.isArray(e.assets)},i.setupDOM=function(e,t,s){var r,n=document.querySelector("#avaturn-sdk-iframe");n&&n.remove();var o=document.createElement("iframe");o.setAttribute("src",t),o.setAttribute("id","avaturn-sdk-iframe"),o.setAttribute("allow","camera *; clipboard-write"),o.setAttribute("allowfullscreen",""),o.setAttribute("frameborder","0"),s?o.setAttribute("class",s):this.applyStyles(o),e.appendChild(o),this.sceneRef=document.querySelector("#avaturn-sdk-iframe"),this.recipient=null==(r=this.sceneRef)?void 0:r.contentWindow},i.handleMessage=function(e){var t,r,n,o;switch(e.eventName){case s.AskForDefaults:this.sendResponse(s.AskForDefaults,e.key,{isOk:!0,data:this.defaultAssets});break;case s.CallbackEvent:null==(t=(r=this.callbacks)[e.key])||t.call(r,e.data);break;case s.ReportError:null==(n=(o=this.callbacks).error)||n.call(o,e.data)}},i.init=function(e,t){var r=t.url,n=t.iframeClassName,o=t.disableUi,i=t.defaultAssets;try{var a=this;if(a.suppressCallbacks=o,i&&!a.validateDefaultAssets(i))throw new Error("Field 'defaultAssets' has an invalid format");a.defaultAssets=i;var c=new URL(r||"https://preview.avaturn.dev/editor?avatar_link=https%3A%2F%2Fassets.avaturn.me%2Feditor_resources%2Fdefault_male.glb");return c.searchParams.append("sdk","true"),o&&c.searchParams.append("noui","true"),e?a.setupDOM(e,c.toString(),n):a.recipient=window,a.handshakeData={url:document.location.href,environment:window.avaturnSDKEnvironment,version:a._version},a.setupMessaging(),Promise.resolve(a.sendMessage(s.SDKHandshake,a.handshakeData,"sdk_handshake").then(function(){try{return Promise.resolve(a.sendMessage(s.SDKHandshakeConfirmation,a.handshakeData,void 0,!1)).then(function(){return a})}catch(e){return Promise.reject(e)}}).catch(function(e){throw new Error(e)}))}catch(e){return Promise.reject(e)}},i.destroy=function(){this.destroyMessaging(),this.callbacks={}},i.on=function(e,t){return this.suppressCallbacks&&"load"!=e?(console.log("Can't use callbacks for "+e+" in disableUi mode. Use <action>.then(...) instead."),this):(this.callbacks[e]=t,this)},i.getAssetList=function(){try{return Promise.resolve(this.sendMessage(s.GetAssetList))}catch(e){return Promise.reject(e)}},i.setAvailableAssets=function(e){try{return Promise.resolve(this.sendMessage(s.SetAvailableAssets,e))}catch(e){return Promise.reject(e)}},i.getActiveAssets=function(){try{return Promise.resolve(this.sendMessage(s.GetActiveAssets))}catch(e){return Promise.reject(e)}},i.setActiveAsset=function(e){try{return Promise.resolve(this.sendMessage(s.SetActiveAsset,e))}catch(e){return Promise.reject(e)}},i.setActiveBody=function(e){try{return Promise.resolve(this.sendMessage(s.SetActiveBody,e))}catch(e){return Promise.reject(e)}},i.getBodyList=function(){try{return Promise.resolve(this.sendMessage(s.GetBodyList))}catch(e){return Promise.reject(e)}},i.getActiveBody=function(){try{return Promise.resolve(this.sendMessage(s.GetActiveBody))}catch(e){return Promise.reject(e)}},i.setActiveAnimation=function(e){try{return Promise.resolve(this.sendMessage(s.SetActiveAnimation,e))}catch(e){return Promise.reject(e)}},i.getActiveAnimation=function(){try{return Promise.resolve(this.sendMessage(s.GetActiveAnimation))}catch(e){return Promise.reject(e)}},i.getAnimationList=function(){try{return Promise.resolve(this.sendMessage(s.GetAnimationList))}catch(e){return Promise.reject(e)}},i.exportAvatar=function(){try{return Promise.resolve(this.sendMessage(s.ExportAvatar,void 0,"export_avatar"))}catch(e){return Promise.reject(e)}},i.setEyeColor=function(e){try{return Promise.resolve(this.sendMessage(s.SetEyeColor,e))}catch(e){return Promise.reject(e)}},i.setHairColor=function(e){try{return Promise.resolve(this.sendMessage(s.SetHairColor,e))}catch(e){return Promise.reject(e)}},i.setEyewearColor=function(e){try{return Promise.resolve(this.sendMessage(s.SetEyewearColor,e))}catch(e){return Promise.reject(e)}},i.setBodyProportions=function(e,t){try{return Promise.resolve(this.sendMessage(s.SetBodyProportions,{key:e,value:t}))}catch(e){return Promise.reject(e)}},i.setSkinToneCorrection=function(e){try{return Promise.resolve(this.sendMessage(s.SetSkinTone,e))}catch(e){return Promise.reject(e)}},i.getEyeColor=function(){try{return Promise.resolve(this.sendMessage(s.GetEyeColor))}catch(e){return Promise.reject(e)}},i.getHairColor=function(){try{return Promise.resolve(this.sendMessage(s.GetHairColor))}catch(e){return Promise.reject(e)}},i.getEyewearColor=function(){try{return Promise.resolve(this.sendMessage(s.GetEyewearColor))}catch(e){return Promise.reject(e)}},i.getBodyProportions=function(){try{return Promise.resolve(this.sendMessage(s.GetBodyProportions))}catch(e){return Promise.reject(e)}},i.getSkinToneCorrection=function(){try{return Promise.resolve(this.sendMessage(s.GetSkinTone))}catch(e){return Promise.reject(e)}},i.getAvatarId=function(){return this.sendMessage(s.GetAvatarId)},r}(n);export{o as AvaturnSDK,s as MessageType,n as Messaging,t as SDKErrors};+function e(t, s) {+ return (+ (e = Object.setPrototypeOf+ ? Object.setPrototypeOf.bind()+ : function (e, t) {+ return (e.__proto__ = t), e;+ }),+ e(t, s)+ );+}+var t, s;+!(function (e) {+ (e.AuthError = 'auth_error'),+ (e.AvatarLoadError = 'avatar_load_error'),+ (e.SceneError = 'scene_error');+})(t || (t = {})),+ (function (e) {+ (e.AskForDefaults = 'ask_for_defaults'),+ (e.SDKHandshake = 'sdk_handshake'),+ (e.SDKHandshakeConfirmation = 'sdk_handshake_confirmation'),+ (e.CallbackEvent = 'callback_event'),+ (e.ReportError = 'report_error'),+ (e.GetAssetList = 'get_assets_list'),+ (e.GetActiveAssets = 'get_active_assets'),+ (e.SetAvailableAssets = 'set_assets_list'),+ (e.SetActiveAsset = 'set_active_asset'),+ (e.GetBodyList = 'get_bodies_list'),+ (e.GetActiveBody = 'get_avatar_info'),+ (e.SetAvailableBodies = 'set_bodies_list'),+ (e.SetActiveBody = 'set_active_body'),+ (e.GetAnimationList = 'get_animation_list'),+ (e.GetActiveAnimation = 'get_animation_info'),+ (e.SetActiveAnimation = 'set_active_animation'),+ (e.ExportAvatar = 'export_avatar'),+ (e.GenerateThumbnail = 'generate_thumbnail'),+ (e.SetParam = 'set_param'),+ (e.SetEyeColor = 'set_eye_color'),+ (e.SetHairColor = 'set_hair_color'),+ (e.SetEyewearColor = 'set_eyewear_color'),+ (e.SetBodyProportions = 'set_body_proportions'),+ (e.SetSkinTone = 'set_skin_tone'),+ (e.GetEyeColor = 'get_eye_color'),+ (e.GetHairColor = 'get_hair_color'),+ (e.GetEyewearColor = 'get_eyewear_color'),+ (e.GetBodyProportions = 'get_body_proportions'),+ (e.GetSkinTone = 'get_skin_tone'),+ (e.GetAvatarId = 'get_avatar_id');+ })(s || (s = {}));+var r = /*#__PURE__*/ (function () {+ function e() {+ this.listeners = {};+ }+ var t = e.prototype;+ return (+ (t.watch = function (e, t) {+ this.listeners[e] = t;+ }),+ (t.unwatch = function (e) {+ delete this.listeners[e];+ }),+ e+ );+ })(),+ n = /*#__PURE__*/ (function () {+ function e(e, t) {+ (this.handshakeData = {}),+ (this.recipient = void 0),+ (this.thisSourceName = 'v1.avaturn-sdk'),+ (this.expectedIncomingSourceName = 'v1.avaturn-sdk-server'),+ (this._queue = new r()),+ (this._messageHandler = this.messageHandler.bind(this)),+ e && (this.thisSourceName = e),+ t && (this.expectedIncomingSourceName = t);+ }+ var t = e.prototype;+ return (+ (t.sendMessage = function (e, t, s, r) {+ var n = this;+ return (+ void 0 === r && (r = !0),+ new Promise(function (o, i) {+ var a,+ c = Date.now(),+ u = s || e + c;+ r &&+ n._queue.watch(u, function (e, t) {+ var s = null != t ? t : null;+ e ? o(s) : i(s), n._queue.unwatch(u);+ }),+ null == (a = n.recipient) ||+ a.postMessage(+ {+ type: 'MESSAGE',+ source: n.thisSourceName,+ eventName: e,+ key: u,+ date: c,+ data: t,+ isOk: !0,+ },+ '*',+ ),+ r || o(null);+ })+ );+ }),+ (t.messageHandler = function (e) {+ var t = e.data;+ this.expectedIncomingSourceName == t.source &&+ ('RESPONSE' === t.type &&+ ('sdk_handshake' === t.key &&+ this.sendMessage(+ s.SDKHandshakeConfirmation,+ this.handshakeData,+ void 0,+ !1,+ ),+ this._queue.listeners[t.key] &&+ this._queue.listeners[t.key](t.isOk, t.data)),+ 'MESSAGE' === t.type && this.handleMessage(t));+ }),+ (t.setupMessaging = function () {+ window.addEventListener('message', this._messageHandler);+ }),+ (t.destroyMessaging = function () {+ console.log('destroy'), window.removeEventListener('message', this._messageHandler);+ }),+ (t.sendResponse = function (e, t, s) {+ var r,+ n = void 0 === s ? { isOk: !0 } : s,+ o = n.isOk,+ i = n.data;+ if (this.recipient) {+ var a = {+ type: 'RESPONSE',+ source: this.thisSourceName,+ eventName: e,+ key: t,+ date: Date.now(),+ data: i,+ isOk: o,+ };+ null == (r = this.recipient) || r.postMessage(a, '*');+ } else console.log('Recipient is not set.');+ }),+ (t.handleMessage = function (e) {}),+ e+ );+ })(),+ o = /*#__PURE__*/ (function (t) {+ function r() {+ var e;+ return (+ ((e = t.call(this) || this)._version = '1.1.4'),+ (e.defaultAssets = void 0),+ (e.sceneRef = null),+ (e.callbacks = {}),+ (e.suppressCallbacks = void 0),+ e+ );+ }+ var n, o;+ (o = t),+ ((n = r).prototype = Object.create(o.prototype)),+ (n.prototype.constructor = n),+ e(n, o);+ var i = r.prototype;+ return (+ (i.applyStyles = function (e) {+ (e.style.width = '100%'), (e.style.height = '100%');+ }),+ (i.validateDefaultAssets = function (e) {+ return (+ 'object' == typeof e &&+ 'boolean' == typeof e.overrideSaved &&+ !!Array.isArray(e.assets)+ );+ }),+ (i.setupDOM = function (e, t, s) {+ var r,+ n = document.querySelector('#avaturn-sdk-iframe');+ n && n.remove();+ var o = document.createElement('iframe');+ o.setAttribute('src', t),+ o.setAttribute('id', 'avaturn-sdk-iframe'),+ o.setAttribute('allow', 'camera *; clipboard-write'),+ o.setAttribute('allowfullscreen', ''),+ o.setAttribute('frameborder', '0'),+ s ? o.setAttribute('class', s) : this.applyStyles(o),+ e.appendChild(o),+ (this.sceneRef = document.querySelector('#avaturn-sdk-iframe')),+ (this.recipient = null == (r = this.sceneRef) ? void 0 : r.contentWindow);+ }),+ (i.handleMessage = function (e) {+ var t, r, n, o;+ switch (e.eventName) {+ case s.AskForDefaults:+ this.sendResponse(s.AskForDefaults, e.key, {+ isOk: !0,+ data: this.defaultAssets,+ });+ break;+ case s.CallbackEvent:+ null == (t = (r = this.callbacks)[e.key]) || t.call(r, e.data);+ break;+ case s.ReportError:+ null == (n = (o = this.callbacks).error) || n.call(o, e.data);+ }+ }),+ (i.init = function (e, t) {+ var r = t.url,+ n = t.iframeClassName,+ o = t.disableUi,+ i = t.defaultAssets;+ try {+ var a = this;+ if (((a.suppressCallbacks = o), i && !a.validateDefaultAssets(i)))+ throw new Error("Field 'defaultAssets' has an invalid format");+ a.defaultAssets = i;+ var c = new URL(+ r ||+ 'https://preview.avaturn.dev/editor?avatar_link=https%3A%2F%2Fassets.avaturn.me%2Feditor_resources%2Fdefault_male.glb',+ );+ return (+ c.searchParams.append('sdk', 'true'),+ o && c.searchParams.append('noui', 'true'),+ e ? a.setupDOM(e, c.toString(), n) : (a.recipient = window),+ (a.handshakeData = {+ url: document.location.href,+ environment: window.avaturnSDKEnvironment,+ version: a._version,+ }),+ a.setupMessaging(),+ Promise.resolve(+ a+ .sendMessage(s.SDKHandshake, a.handshakeData, 'sdk_handshake')+ .then(function () {+ try {+ return Promise.resolve(+ a.sendMessage(+ s.SDKHandshakeConfirmation,+ a.handshakeData,+ void 0,+ !1,+ ),+ ).then(function () {+ return a;+ });+ } catch (e) {+ return Promise.reject(e);+ }+ })+ .catch(function (e) {+ throw new Error(e);+ }),+ )+ );+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.destroy = function () {+ this.destroyMessaging(), (this.callbacks = {});+ }),+ (i.on = function (e, t) {+ return this.suppressCallbacks && 'load' != e+ ? (console.log(+ "Can't use callbacks for " ++ e ++ ' in disableUi mode. Use <action>.then(...) instead.',+ ),+ this)+ : ((this.callbacks[e] = t), this);+ }),+ (i.getAssetList = function () {+ try {+ return Promise.resolve(this.sendMessage(s.GetAssetList));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.setAvailableAssets = function (e) {+ try {+ return Promise.resolve(this.sendMessage(s.SetAvailableAssets, e));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.getActiveAssets = function () {+ try {+ return Promise.resolve(this.sendMessage(s.GetActiveAssets));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.setActiveAsset = function (e) {+ try {+ return Promise.resolve(this.sendMessage(s.SetActiveAsset, e));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.setActiveBody = function (e) {+ try {+ return Promise.resolve(this.sendMessage(s.SetActiveBody, e));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.getBodyList = function () {+ try {+ return Promise.resolve(this.sendMessage(s.GetBodyList));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.getActiveBody = function () {+ try {+ return Promise.resolve(this.sendMessage(s.GetActiveBody));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.setActiveAnimation = function (e) {+ try {+ return Promise.resolve(this.sendMessage(s.SetActiveAnimation, e));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.getActiveAnimation = function () {+ try {+ return Promise.resolve(this.sendMessage(s.GetActiveAnimation));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.getAnimationList = function () {+ try {+ return Promise.resolve(this.sendMessage(s.GetAnimationList));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.exportAvatar = function () {+ try {+ return Promise.resolve(+ this.sendMessage(s.ExportAvatar, void 0, 'export_avatar'),+ );+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.setEyeColor = function (e) {+ try {+ return Promise.resolve(this.sendMessage(s.SetEyeColor, e));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.setHairColor = function (e) {+ try {+ return Promise.resolve(this.sendMessage(s.SetHairColor, e));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.setEyewearColor = function (e) {+ try {+ return Promise.resolve(this.sendMessage(s.SetEyewearColor, e));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.setBodyProportions = function (e, t) {+ try {+ return Promise.resolve(+ this.sendMessage(s.SetBodyProportions, { key: e, value: t }),+ );+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.setSkinToneCorrection = function (e) {+ try {+ return Promise.resolve(this.sendMessage(s.SetSkinTone, e));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.getEyeColor = function () {+ try {+ return Promise.resolve(this.sendMessage(s.GetEyeColor));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.getHairColor = function () {+ try {+ return Promise.resolve(this.sendMessage(s.GetHairColor));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.getEyewearColor = function () {+ try {+ return Promise.resolve(this.sendMessage(s.GetEyewearColor));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.getBodyProportions = function () {+ try {+ return Promise.resolve(this.sendMessage(s.GetBodyProportions));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.getSkinToneCorrection = function () {+ try {+ return Promise.resolve(this.sendMessage(s.GetSkinTone));+ } catch (e) {+ return Promise.reject(e);+ }+ }),+ (i.getAvatarId = function () {+ return this.sendMessage(s.GetAvatarId);+ }),+ r+ );+ })(n);+export { o as AvaturnSDK, s as MessageType, n as Messaging, t as SDKErrors };diff --git a/public/dashboard/dashboard.js b/public/dashboard/dashboard.jsindex 65e2d92c5..2039ac2a8 100644--- a/public/dashboard/dashboard.js+++ b/public/dashboard/dashboard.js@@ -433,13 +433,18 @@ function renderCreate(root) {sdk.on('export', async (data) => {const glbUrl = data?.url;- if (!glbUrl) { say('No avatar URL returned', true); return; }+ if (!glbUrl) {+ say('No avatar URL returned', true);+ return;+ }say('Saving avatar…');try {const blob = await fetchGlbBlob(glbUrl, data?.urlType);const avatar = await saveAvaturnAvatar(blob);say(`Saved "${avatar.name}". Redirecting…`);- setTimeout(() => { location.hash = 'avatars'; }, 600);+ setTimeout(() => {+ location.hash = 'avatars';+ }, 600);} catch (err) {say(err.message || 'Failed to save avatar', true);}@@ -452,7 +457,10 @@ function renderCreate(root) {};const stop = () => {- if (sdk) { sdk.destroy(); sdk = null; }+ if (sdk) {+ sdk.destroy();+ sdk = null;+ }container.style.display = 'none';container.innerHTML = '';intro.style.display = 'block';diff --git a/vite.config.js b/vite.config.jsindex e7dcbc983..7fdc83415 100644--- a/vite.config.js+++ b/vite.config.js@@ -33,6 +33,7 @@ const appConfig = {'agent-edit': resolve(__dirname, 'agent-edit.html'),'agent-embed': resolve(__dirname, 'agent-embed.html'),'a-embed': resolve(__dirname, 'a-embed.html'),+ studio: resolve(__dirname, 'public/studio/index.html'),reputation: resolve(__dirname, 'public/reputation/index.html'),hydrate: resolve(__dirname, 'public/hydrate/index.html'),},