{"id":31024946,"url":"https://github.com/rizome-dev/next-rc","last_synced_at":"2025-10-07T01:18:22.885Z","repository":{"id":304031368,"uuid":"1016468469","full_name":"rizome-dev/next-rc","owner":"rizome-dev","description":"next-rc: A Multi-Runtime Architecture for Full-Stack Agentic AI Deployment","archived":false,"fork":false,"pushed_at":"2025-07-12T02:44:02.000Z","size":520,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-08T21:55:06.562Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@rizome/next-rc-core","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rizome-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-09T04:13:41.000Z","updated_at":"2025-07-12T02:44:05.000Z","dependencies_parsed_at":"2025-07-11T00:47:03.894Z","dependency_job_id":"84c44359-4edd-4d0c-9835-6587210d4f80","html_url":"https://github.com/rizome-dev/next-rc","commit_stats":null,"previous_names":["rizome-dev/next-rc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rizome-dev/next-rc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizome-dev%2Fnext-rc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizome-dev%2Fnext-rc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizome-dev%2Fnext-rc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizome-dev%2Fnext-rc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rizome-dev","download_url":"https://codeload.github.com/rizome-dev/next-rc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizome-dev%2Fnext-rc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274563396,"owners_count":25308397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-13T16:16:16.720Z","updated_at":"2025-10-07T01:18:17.836Z","avatar_url":"https://github.com/rizome-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Next.js Runtime Controller (next-rc)\n\n[paper](https://github.com/rizome-dev/next-rc/blob/main/paper.pdf)\n\nbuilt by: [rizome labs](https://rizome.dev)\n\ncontact us: [hi (at) rizome.dev](mailto:hi@rizome.dev)\n\n## Installation\n\n```bash\n# Install the Next.js integration package\nnpm install @rizome/next-rc-integration\n# or\nyarn add @rizome/next-rc-integration\n# or\npnpm add @rizome/next-rc-integration\n\n# For direct runtime controller usage, also install:\nnpm install @rizome/next-rc-core @rizome/next-rc-types\n```\n\n## Package Structure\n\n- `@rizome/next-rc-integration` - Next.js integration with hooks and API routes\n- `@rizome/next-rc-core` - Core runtime controller\n- `@rizome/next-rc-types` - TypeScript type definitions\n- `@rizome/next-rc-v8` - V8 Isolate runtime\n- `@rizome/next-rc-wasm` - WebAssembly runtime\n- `@rizome/next-rc-ebpf` - eBPF runtime\n- `@rizome/next-rc-python` - Python runtime\n- `@rizome/next-rc-lattice` - Distributed orchestration\n- `@rizome/next-rc-native` - Native Rust bridge\n\n## Configuration\n\n### next.config.js\n\n```javascript\nconst { withRuntimeController } = require('@rizome/next-rc-integration');\n\nmodule.exports = withRuntimeController({\n  experimental: {\n    runtimeController: {\n      type: 'hybrid',\n      fluidCompute: {\n        enabled: true,\n        concurrency: 'auto',\n      },\n      edgeRuntime: {\n        engine: 'wasm',\n        preWarm: true,\n      },\n      lattice: {\n        enabled: true,\n        natsUrl: process.env.NATS_URL,\n      },\n    },\n  },\n});\n```\n\n## Basic Usage\n\n### 1. Initialize the Runtime Controller\n\n```typescript\nimport { RuntimeController } from '@rizome/next-rc-core';\nimport { Language, TrustLevel } from '@rizome/next-rc-types';\n\nconst controller = RuntimeController.getInstance({\n  enableScheduler: true,\n  runtimes: {\n    v8: { enabled: true },\n    wasm: { enabled: true },\n    ebpf: { enabled: true },\n  },\n  concurrency: 100,\n});\n\nawait controller.initialize();\n```\n\n### 2. Execute Code in Different Languages\n\n#### JavaScript/TypeScript (V8 Runtime)\n```typescript\nconst jsResult = await controller.executeWithScheduler(\n  `\n    function fibonacci(n) {\n      if (n \u003c= 1) return n;\n      return fibonacci(n - 1) + fibonacci(n - 2);\n    }\n    \n    fibonacci(20);\n  `,\n  Language.JavaScript,\n  {\n    timeout: 5000,\n    memoryLimit: 64 * 1024 * 1024,\n    permissions: {\n      capabilities: new Set(['cpu_intensive']),\n      trustLevel: TrustLevel.High,\n    },\n  }\n);\n\nconsole.log(`JavaScript result: ${jsResult.output}`);\nconsole.log(`Runtime used: ${jsResult.runtime}`); // \"v8isolate\"\nconsole.log(`Execution time: ${jsResult.executionTime}ms`);\n```\n\n#### Rust (WASM Runtime)\n```typescript\nconst rustResult = await controller.executeWithScheduler(\n  `\n    fn fibonacci(n: u32) -\u003e u32 {\n        match n {\n            0 =\u003e 0,\n            1 =\u003e 1,\n            _ =\u003e fibonacci(n - 1) + fibonacci(n - 2),\n        }\n    }\n    \n    #[no_mangle]\n    pub extern \"C\" fn main() -\u003e u32 {\n        fibonacci(20)\n    }\n  `,\n  Language.Rust,\n  {\n    timeout: 3000,\n    memoryLimit: 32 * 1024 * 1024,\n    permissions: {\n      capabilities: new Set(['cpu_intensive']),\n      trustLevel: TrustLevel.Medium,\n    },\n  },\n  {\n    latencyRequirement: 'low',\n    complexity: 'moderate',\n  }\n);\n\nconsole.log(`Rust result: ${rustResult.output}`);\nconsole.log(`Runtime used: ${rustResult.runtime}`); // \"wasm\"\nconsole.log(`Execution time: ${rustResult.executionTime}ms`);\n```\n\n#### C (eBPF Runtime)\n```typescript\nconst ebpfResult = await controller.executeWithScheduler(\n  `\n    int packet_filter(void *data, int data_len) {\n        // Simple packet filter - allow all HTTP traffic\n        if (data_len \u003e 20) {\n            return 1; // Allow\n        }\n        return 0; // Drop\n    }\n  `,\n  Language.C,\n  {\n    timeout: 100,\n    memoryLimit: 1024 * 1024,\n    permissions: {\n      capabilities: new Set(['network_access']),\n      trustLevel: TrustLevel.Low,\n    },\n  },\n  {\n    latencyRequirement: 'ultra-low',\n    complexity: 'simple',\n  }\n);\n\nconsole.log(`eBPF result: ${ebpfResult.output}`);\nconsole.log(`Runtime used: ${ebpfResult.runtime}`); // \"ebpf\"\nconsole.log(`Execution time: ${ebpfResult.executionTime}ms`); // Should be \u003c1ms\n```\n\n#### Python (Hybrid PyO3/WASM)\n```typescript\nconst pythonResult = await controller.executeWithScheduler(\n  `\n    import numpy as np\n    \n    def analyze_data(data):\n        arr = np.array(data)\n        return {\n            'mean': float(np.mean(arr)),\n            'std': float(np.std(arr)),\n            'max': float(np.max(arr)),\n            'min': float(np.min(arr))\n        }\n    \n    data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    result = analyze_data(data)\n    result\n  `,\n  Language.Python,\n  {\n    timeout: 10000,\n    memoryLimit: 128 * 1024 * 1024,\n    permissions: {\n      capabilities: new Set(['cpu_intensive']),\n      trustLevel: TrustLevel.High,\n    },\n  }\n);\n\nconsole.log(`Python result:`, pythonResult.output);\nconsole.log(`Runtime used: ${pythonResult.runtime}`); // Could be \"wasm\" or \"v8isolate\"\n```\n\n## Advanced Usage\n\n### 1. Intelligent Runtime Selection\n\nThe scheduler automatically selects the best runtime based on workload characteristics:\n\n```typescript\n// Ultra-low latency requirement -\u003e eBPF\nconst filterResult = await controller.executeWithScheduler(\n  simpleFilterCode,\n  Language.C,\n  config,\n  {\n    latencyRequirement: 'ultra-low',\n    expectedDuration: 1,\n    complexity: 'simple',\n  }\n);\n\n// High performance requirement -\u003e WASM\nconst computeResult = await controller.executeWithScheduler(\n  computeIntensiveCode,\n  Language.Rust,\n  config,\n  {\n    latencyRequirement: 'low',\n    expectedDuration: 100,\n    complexity: 'complex',\n  }\n);\n\n// JavaScript/TypeScript -\u003e V8\nconst jsResult = await controller.executeWithScheduler(\n  webLogicCode,\n  Language.TypeScript,\n  config,\n  {\n    latencyRequirement: 'normal',\n    complexity: 'moderate',\n  }\n);\n```\n\n### 2. Direct Runtime Control\n\nFor explicit runtime control:\n\n```typescript\n// Compile and execute with specific runtime\nconst moduleId = await controller.compile(code, Language.Rust);\nconst instanceId = await controller.instantiate(moduleId);\n\ntry {\n  const result = await controller.execute(instanceId, {\n    timeout: 5000,\n    memoryLimit: 64 * 1024 * 1024,\n    permissions: {\n      capabilities: new Set(['cpu_intensive']),\n      trustLevel: TrustLevel.High,\n    },\n  });\n  \n  console.log('Execution result:', result);\n} finally {\n  await controller.destroy(instanceId);\n}\n```\n\n### 3. Performance Monitoring\n\n```typescript\n// Get overall metrics\nconst metrics = controller.getMetrics();\nconsole.log('Available runtimes:', metrics.availableRuntimes);\nconsole.log('Queue size:', metrics.queueSize);\nconsole.log('Active executions:', metrics.queuePending);\n\n// Runtime-specific metrics\nconst runtimeMetrics = await controller.getRuntimeMetrics();\nconsole.log('Runtime performance:', runtimeMetrics);\n```\n\n## Next.js Integration\n\n### Using the React Hook\n\n```typescript\n// app/components/CodeRunner.tsx\nimport { useRuntimeController } from '@rizome/next-rc-integration';\nimport { Language, TrustLevel } from '@rizome/next-rc-types';\n\nexport function CodeRunner() {\n  const { execute, loading, error } = useRuntimeController();\n  \n  const runCode = async () =\u003e {\n    const result = await execute({\n      code: 'console.log(\"Hello from runtime!\");',\n      language: Language.JavaScript,\n      config: {\n        timeout: 5000,\n        memoryLimit: 64 * 1024 * 1024,\n        permissions: {\n          capabilities: new Set(['cpu_intensive']),\n          trustLevel: TrustLevel.Medium,\n        },\n      },\n    });\n    \n    console.log('Result:', result);\n  };\n  \n  return (\n    \u003cbutton onClick={runCode} disabled={loading}\u003e\n      {loading ? 'Running...' : 'Run Code'}\n    \u003c/button\u003e\n  );\n}\n```\n\n### API Route Example\n\n```typescript\n// app/api/execute/route.ts\nimport { NextRequest, NextResponse } from 'next/server';\nimport { RuntimeController } from '@rizome/next-rc-core';\nimport { Language, TrustLevel } from '@rizome/next-rc-types';\n\nexport async function POST(request: NextRequest) {\n  const { code, language, config } = await request.json();\n  \n  const controller = RuntimeController.getInstance();\n  \n  try {\n    const result = await controller.executeWithScheduler(\n      code,\n      language as Language,\n      {\n        timeout: config.timeout || 5000,\n        memoryLimit: config.memoryLimit || 64 * 1024 * 1024,\n        permissions: {\n          capabilities: new Set(config.capabilities || []),\n          trustLevel: config.trustLevel || TrustLevel.Medium,\n        },\n      },\n      {\n        latencyRequirement: config.latencyRequirement || 'normal',\n        complexity: config.complexity || 'moderate',\n      }\n    );\n    \n    return NextResponse.json({\n      success: result.success,\n      output: result.output,\n      runtime: result.runtime,\n      executionTime: result.executionTime,\n      memoryUsed: result.memoryUsed,\n    });\n  } catch (error) {\n    return NextResponse.json(\n      { error: error.message },\n      { status: 500 }\n    );\n  }\n}\n```\n\n### Usage in Components\n\n```typescript\n// components/CodeExecutor.tsx\nimport { useState } from 'react';\nimport { Language } from '@rizome/next-rc-types';\n\nexport function CodeExecutor() {\n  const [code, setCode] = useState('');\n  const [language, setLanguage] = useState\u003cLanguage\u003e(Language.JavaScript);\n  const [result, setResult] = useState\u003cany\u003e(null);\n  const [loading, setLoading] = useState(false);\n\n  const executeCode = async () =\u003e {\n    setLoading(true);\n    try {\n      const response = await fetch('/api/execute', {\n        method: 'POST',\n        headers: { 'Content-Type': 'application/json' },\n        body: JSON.stringify({\n          code,\n          language,\n          config: {\n            timeout: 10000,\n            memoryLimit: 128 * 1024 * 1024,\n            capabilities: ['cpu_intensive'],\n            trustLevel: 'high',\n            latencyRequirement: 'normal',\n            complexity: 'moderate',\n          },\n        }),\n      });\n      \n      const data = await response.json();\n      setResult(data);\n    } catch (error) {\n      setResult({ error: error.message });\n    } finally {\n      setLoading(false);\n    }\n  };\n\n  return (\n    \u003cdiv\u003e\n      \u003cselect \n        value={language} \n        onChange={(e) =\u003e setLanguage(e.target.value as Language)}\n      \u003e\n        \u003coption value={Language.JavaScript}\u003eJavaScript\u003c/option\u003e\n        \u003coption value={Language.TypeScript}\u003eTypeScript\u003c/option\u003e\n        \u003coption value={Language.Rust}\u003eRust\u003c/option\u003e\n        \u003coption value={Language.Python}\u003ePython\u003c/option\u003e\n        \u003coption value={Language.C}\u003eC (eBPF)\u003c/option\u003e\n        \u003coption value={Language.Wasm}\u003eWASM\u003c/option\u003e\n      \u003c/select\u003e\n      \n      \u003ctextarea\n        value={code}\n        onChange={(e) =\u003e setCode(e.target.value)}\n        placeholder=\"Enter your code here...\"\n        rows={10}\n        cols={80}\n      /\u003e\n      \n      \u003cbutton onClick={executeCode} disabled={loading}\u003e\n        {loading ? 'Executing...' : 'Execute Code'}\n      \u003c/button\u003e\n      \n      {result \u0026\u0026 (\n        \u003cdiv\u003e\n          \u003ch3\u003eResult:\u003c/h3\u003e\n          \u003cpre\u003e{JSON.stringify(result, null, 2)}\u003c/pre\u003e\n        \u003c/div\u003e\n      )}\n    \u003c/div\u003e\n  );\n}\n```\n\n## Security Considerations\n\n### Trust Levels\n\n```typescript\n// Low trust - Maximum sandboxing\nconst lowTrustConfig = {\n  permissions: {\n    capabilities: new Set(), // No special capabilities\n    trustLevel: TrustLevel.Low,\n  },\n};\n\n// Medium trust - Balanced security/performance\nconst mediumTrustConfig = {\n  permissions: {\n    capabilities: new Set(['cpu_intensive']),\n    trustLevel: TrustLevel.Medium,\n  },\n};\n\n// High trust - Maximum performance\nconst highTrustConfig = {\n  permissions: {\n    capabilities: new Set(['cpu_intensive', 'network_access', 'filesystem_read']),\n    trustLevel: TrustLevel.High,\n  },\n};\n```\n\n### Capability Management\n\n```typescript\nconst capabilities = new Set([\n  'network_access',      // Network operations\n  'filesystem_read',     // File system read access\n  'filesystem_write',    // File system write access\n  'process_spawn',       // Spawn child processes\n  'system_time',         // Access system time\n  'environment_variables', // Access env vars\n  'shared_memory',       // Shared memory access\n  'cpu_intensive',       // CPU-intensive operations\n  'gpu_access',          // GPU access\n]);\n```\n\n## Production Deployment\n\n### Configuration\n\n```typescript\nconst productionConfig = {\n  enableScheduler: true,\n  runtimes: {\n    v8: { enabled: true },\n    wasm: { enabled: true },\n    ebpf: { enabled: true },\n  },\n  concurrency: 1000, // High concurrency for production\n  metrics: {\n    enabled: true,\n    endpoint: '/metrics',\n  },\n  logging: {\n    level: 'info',\n    structured: true,\n  },\n};\n```\n\n### Monitoring\n\n```typescript\n// Set up metrics collection\nconst metrics = controller.getMetrics();\nconst runtimeMetrics = await controller.getRuntimeMetrics();\n\n// Log performance data\nconsole.log('System metrics:', {\n  totalExecutions: metrics.totalExecutions,\n  successRate: metrics.successfulExecutions / metrics.totalExecutions,\n  avgExecutionTime: metrics.avgExecutionTime,\n  activeRuntimes: metrics.availableRuntimes,\n});\n```\n\n### Runtime Selection\n\nThe system automatically selects the optimal runtime based on:\n- **Language**: JavaScript→V8, Rust→WASM, C→eBPF\n- **Latency requirements**: ultra-low→eBPF, low→WASM, normal→V8\n- **Complexity**: simple→eBPF, moderate→WASM, complex→V8\n\nOverride automatic selection:\n```typescript\nconst result = await controller.executeWithScheduler(\n  code,\n  language,\n  config,\n  {\n    latencyRequirement: 'ultra-low', // Forces eBPF for C code\n    complexity: 'simple',\n    expectedDuration: 1 // milliseconds\n  }\n);\n```\n\n## Development\n\n### Building from Source\n\n```bash\n# Clone the repository\ngit clone https://github.com/rizome-dev/next-rc.git\ncd next-rc\n\n# Install dependencies\npnpm install\n\n# Build all packages\npnpm build\n\n# Run tests\npnpm test\n```\n\n### Environment Variables\n\n```env\nRUNTIME_CONTROLLER_TYPE=hybrid\nRUNTIME_CONTROLLER_MAX_WORKERS=4\nRUNTIME_CONTROLLER_TIMEOUT_MS=30000\nNATS_URL=nats://localhost:4222  # Optional, for distributed mode\nHF_TOKEN=your_hugging_face_token # Optional, for AI integrations\n```\n\n### Running Benchmarks\n\nTo validate the performance claims (39x improvement for smolagents):\n```bash\n# From root directory\npnpm benchmark\n\n# Specific benchmark suites\ncd packages/benchmarks\npnpm benchmark:smolagents\n```\n\n## Architecture\n\nThe Next.js Runtime Controller uses a modular architecture:\n\n1. **Core Controller** - Manages runtime lifecycle and scheduling\n2. **Runtime Adapters** - Interfaces for V8, WASM, eBPF, Python\n3. **Intelligent Scheduler** - Selects optimal runtime based on workload\n4. **Security Manager** - Enforces sandboxing and permissions\n5. **Lattice Network** - Optional distributed execution via NATS\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n### Development Setup\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n---\n\nBuilt with ❤️  by Rizome Labs, Inc.\n\n## License\n\nLicensed under either of:\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizome-dev%2Fnext-rc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frizome-dev%2Fnext-rc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizome-dev%2Fnext-rc/lists"}