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
fix(marketplace): sell a fixed time pass for its configured window only, ignoring the caller duration
nirholasa9c0dbc22739
diff --git a/api/_lib/services/MonetizationService.js b/api/_lib/services/MonetizationService.jsindex 82b120aa9..6a934ded7 100644--- a/api/_lib/services/MonetizationService.js+++ b/api/_lib/services/MonetizationService.js@@ -38,6 +38,18 @@ function svcError(status, code, message) {return Object.assign(new Error(message), { status, code });}+/**+ * Hours of access a purchase grants. A skill with a fixed time-pass price sells+ * exactly its configured window, whatever duration the caller asked for;+ * otherwise a caller-chosen duration could stretch a cheap pass to any length.+ * PWYW purchases are permanent and have no window.+ */+export function resolveAccessHours(price, requestedHours, isPwyw) {+ if (isPwyw) return null;+ if (price.time_pass_amount) return price.time_pass_hours || null;+ return requestedHours ?? (price.time_pass_hours || null);+}+export class MonetizationService {/*** @param {object|string|null} user - a session user ({ id }), an auth object@@ -271,7 +283,7 @@ export class MonetizationService {// PWYW is a permanent-purchase pricing mode and takes precedence over the// time-pass path — a buyer who names their own price is buying the skill// outright, not renting a window.- const effectiveDurationHours = isPwyw ? null : (durationHours ?? (price.time_pass_hours || null));+ const effectiveDurationHours = resolveAccessHours(price, durationHours, isPwyw);const isTimePass = effectiveDurationHours != null;// Resolve the amount the buyer will be charged. Fixed skills bill thediff --git a/tests/monetization-service.test.js b/tests/monetization-service.test.jsindex dc534ef77..dcfc59877 100644--- a/tests/monetization-service.test.js+++ b/tests/monetization-service.test.js@@ -89,6 +89,22 @@ beforeEach(() => {// ── 1. Fee calculation (api/_lib/fee.js) ────────────────────────────────────────+describe('resolveAccessHours', () => {+ const pass = { time_pass_amount: '1000', time_pass_hours: 24, amount: '50000' };++ it('ignores the caller duration when the skill has a fixed time-pass price', async () => {+ const { resolveAccessHours } = await import('../api/_lib/services/MonetizationService.js');+ expect(resolveAccessHours(pass, 720, false)).toBe(24);+ expect(resolveAccessHours(pass, null, false)).toBe(24);+ });++ it('honors the caller duration only when no fixed pass price exists', async () => {+ const { resolveAccessHours } = await import('../api/_lib/services/MonetizationService.js');+ expect(resolveAccessHours({ amount: '50000' }, 48, false)).toBe(48);+ expect(resolveAccessHours(pass, 720, true)).toBeNull();+ });+});+describe('calculateFee', () => {it('exposes a sane default fee rate (250 bps = 2.5%)', () => {const bps = getFeeBps();