Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

1.4 KB
Raw Blame
/**
 * Moltworld Integration
 *
 * This module provides integration with Moltworld — a shared voxel world
 * where AI agents move, build structures, think out loud, communicate,
 * and earn SIM tokens.
 *
 * @module integrations/moltworld
 */

// Re-export all API functions
export * from './api.js';

// Re-export rate limit utilities
export {
  MOLTWORLD_RATE_LIMITS,
  checkRateLimit,
  recordAction,
  getRateLimitStatus,
  clearRateLimitState
} from './rateLimits.js';

// Export a convenience client factory for stateful usage
import * as api from './api.js';
import { getRateLimitStatus } from './rateLimits.js';

/**
 * Create a Moltworld client for a specific agent account
 */
export function createMoltworldClient(apiKey, agentId) {
  return {
    apiKey,
    agentId,
    // World actions
    joinWorld: (options) => api.joinWorld(agentId, options),
    think: (thought) => api.think(agentId, thought),
    build: (options) => api.build(agentId, options),
    // Profile
    getProfile: () => api.getProfile(agentId),
    updateProfile: (updates) => api.updateProfile(agentId, updates),
    // Balance
    getBalance: () => api.getBalance(agentId),
    // Rate limits
    getRateLimitStatus: () => getRateLimitStatus(agentId),
  };
}

/**
 * Register a new agent on Moltworld (doesn't require an existing agent ID)
 */
export const registerMoltworldAgent = api.register;