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.

chore: update talk scene and add skill NFT gate migration

nirholas3214753839eb
diff --git a/api/_lib/migrations/20260627120000_skill_nft_gate.sql b/api/_lib/migrations/20260627120000_skill_nft_gate.sql
new file mode 100644
index 000000000..1badba016
--- /dev/null
+++ b/api/_lib/migrations/20260627120000_skill_nft_gate.sql
@@ -0,0 +1,67 @@
+-- Migration: NFT-gated skills.
+-- ============================================================================
+-- Lets a creator restrict a skill to holders of a specific NFT collection
+-- instead of (or as well as) selling it for a price. Two new columns on
+-- agent_skill_prices:
+--
+-- • gate_type — how access is granted:
+-- 'price' (default, unchanged) — pay to unlock, or
+-- 'nft' — hold ≥1 NFT from `nft_collection_mint`.
+-- • nft_collection_mint — Solana collection mint (base58) required by an NFT
+-- gate; NULL for price gates.
+--
+-- An NFT gate is NOT a purchase: there is no x402 charge, no skill_purchases
+-- row, no fee split. Access is the live answer to "does the caller's wallet
+-- currently hold an asset grouped under this collection?" — verified via the
+-- Helius DAS API (api/_lib/nft-gate.js) on every execution, fail-closed.
+--
+-- For an NFT gate the existing fixed-price columns (amount, currency_mint,
+-- time_pass_*, pricing_type) are inert: `amount` is stored as 0 so the row stays
+-- a valid agent_skill_prices entry (it keeps the skill classified "premium", not
+-- "free", in marketplace filters) while the access decision is driven entirely
+-- by the on-chain holding check. Skills with no row at all remain free.
+--
+-- A CHECK constraint keeps the two columns coherent: an 'nft' gate must carry a
+-- collection mint; a 'price' gate must not. Both columns are additive with
+-- safe defaults, so existing rows become explicit 'price' gates unchanged.
+--
+-- Apply: psql "$DATABASE_URL" -f api/_lib/migrations/20260627120000_skill_nft_gate.sql
+-- Idempotent. Migration-only — schema.sql is left untouched per repo policy.
+begin;
+
+alter table agent_skill_prices
+ add column if not exists gate_type text not null default 'price',
+ add column if not exists nft_collection_mint text;
+
+-- Constrain gate_type to the known set, added separately + guarded so the
+-- migration is safe to re-run.
+do $$
+begin
+ if not exists (
+ select 1 from pg_constraint
+ where conname = 'agent_skill_prices_gate_type_chk'
+ ) then
+ alter table agent_skill_prices
+ add constraint agent_skill_prices_gate_type_chk
+ check (gate_type in ('price', 'nft'));
+ end if;
+end $$;
+
+-- Coherence: an NFT gate must name a collection; a price gate must not carry one.
+do $$
+begin
+ if not exists (
+ select 1 from pg_constraint
+ where conname = 'agent_skill_prices_nft_gate_chk'
+ ) then
+ alter table agent_skill_prices
+ add constraint agent_skill_prices_nft_gate_chk
+ check (
+ (gate_type = 'nft' and nft_collection_mint is not null and length(nft_collection_mint) > 0)
+ or
+ (gate_type = 'price' and nft_collection_mint is null)
+ );
+ end if;
+end $$;
+
+commit;
diff --git a/src/voice/talk-scene.js b/src/voice/talk-scene.js
index 94da8e68e..8de154265 100644
--- a/src/voice/talk-scene.js
+++ b/src/voice/talk-scene.js
@@ -54,6 +54,12 @@ export class TalkScene {
this._mouthTarget = null;
this._cameraPreset = 'full';
this._emotes = null;
+ // Optional render throttle. 0 = uncapped (rAF native, ~60fps). A positive
+ // cap (e.g. 30) skips render frames that arrive sooner than the budget so
+ // an embedded preview doesn't monopolise the main thread — the elapsed dt
+ // still accumulates across skipped frames, so motion stays time-correct.
+ this._minFrameMs = 0;
+ this._lastFrameAt = 0;
// External per-frame subscribers (idle animation, custom drivers).
// Receive dt in seconds. Use addOnTick() to register, call the returned
// dispose function to unsubscribe.
@@ -321,11 +327,30 @@ export class TalkScene {
this._resizeObserver.observe(this.container);
}
+ /**
+ * Cap the render loop to `fps` frames per second (0 disables the cap). Used by
+ * the editor's walk preview to hold the canvas at 30fps so sculpt sliders and
+ * the rest of the UI stay responsive while a full locomotion loop runs.
+ * @param {number} fps
+ */
+ setFpsCap(fps) {
+ this._minFrameMs = fps && fps > 0 ? 1000 / fps : 0;
+ this._lastFrameAt = 0;
+ }
+
_start() {
if (this._running) return;
this._running = true;
- const tick = () => {
+ const tick = (now) => {
if (!this._running) return;
+ this._rafId = requestAnimationFrame(tick);
+ // Honour an optional fps cap: bail before any work (and before the
+ // clock ticks) so the accumulated dt lands on the frame we do render.
+ if (this._minFrameMs) {
+ const t = now || 0;
+ if (this._lastFrameAt && t - this._lastFrameAt < this._minFrameMs) return;
+ this._lastFrameAt = t;
+ }
this._clock.update();
const dt = this._clock.getDelta();
this.controls?.update();
@@ -333,7 +358,6 @@ export class TalkScene {
this._emotes?.update(dt);
for (const fn of this._onTickFns) fn(dt);
this.renderer?.render(this.scene, this.camera);
- this._rafId = requestAnimationFrame(tick);
};
this._rafId = requestAnimationFrame(tick);
}