Feat/agent runtime local cloud orchestration - #467
Conversation
0dd7418 to
6fa18be
Compare
Bumps [resend](https://github.com/resend/resend-node) from 6.17.1 to 6.17.2. - [Release notes](https://github.com/resend/resend-node/releases) - [Changelog](https://github.com/resend/resend-node/blob/canary/CHANGELOG.md) - [Commits](resend/resend-node@v6.17.1...v6.17.2) --- updated-dependencies: - dependency-name: resend dependency-version: 6.17.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
6fa18be to
d42d9c0
Compare
|
This PR is blocked by one check, and nobody told youHeads up: the only thing standing between this PR and a merge is the SonarCloud Code Analysis quality gate, which is red. Everything else passes. That failure has been sitting here without anyone explaining it, which is on us, not on you. What to do: open the SonarCloud link in the failed check (or the
Push a fix to the same branch and the gate re-runs on its own. Comment here when it is green and it gets merged. If you think the gate is wrong about something, say so in a comment rather than working around it — sometimes it is, and we would rather discuss it than have you contort the code. |




Implementation Summary: [EPIC] Agent Runtime — Local Lightweight Agents + Cloud Orchestration
Executive Overview
We implemented the real backend Agent Runtime for Open-Stellar, transforming agents from static UI state into real, executable TypeScript actors capable of receiving tasks, executing custom handlers, emitting lifecycle events, passing messages, persisting state across server restarts, and deploying locally via CLI or to serverless edge platforms (Vercel Edge Functions).
🚀 Key Features Implemented
1. TypeScript Agent SDK & Lifecycle Hooks
lib/agent-runtime/sdk.ts): Created the high-levelAgentSDKclass andcreateAgent()builder function allowing developer-friendly agent creation.lib/agent-runtime/agent.ts): Implemented event hooks for full agent lifecycle management:onStart: Triggered when agent process starts running.onStop: Triggered when agent shuts down cleanly.onTask: Custom task handler for receiving and processing incoming tasks.onMessage: Handles inter-agent communication messages.onError: Intercepts runtime task execution errors.onStateChange: Monitors agent state transitions (idlerunningworkingstopped/degraded).2. Local CLI Tool (
bin/open-stellar.js)open-stellar): Built a Node CLI executable with permissions (#!/usr/bin/env node) registered inpackage.jsonunder"bin": { "open-stellar": "./bin/open-stellar.js" }.npx open-stellar agent start --name <Name> --district <District>: Instantiates an agent, registers its metadata, updates status toactive, and persists state to disk.npx open-stellar agent list: Displays registered and persisted agents formatted in an ASCII table.npx open-stellar agent task --id <AgentID> --title <TaskTitle>: Dispatches tasks directly to active agents via CLI.3. State Persistence (
lib/agent-runtime/persistence.ts).data/agent-state.json): Implemented safe local state persistence for agents and their runtime metrics.eval("require")checks to ensure serverless Edge Function bundles (such as/api/og/agent/[id]) compile cleanly without bundling native filesystem modules (node:fs,node:path).4. Cloud & Serverless Deployments (
lib/agent-runtime/cloud-deploy.ts)createServerlessAgentHandler()(for standard Node.js serverless functions) andcreateEdgeAgentHandler()(for Vercel Edge Runtime / Cloudflare Workers).POST /api/agents/:id/taskand returning JSON task results.5. Canvas & UI Dynamic Hydration (
lib/data.ts)createAgents()inlib/data.tsto dynamically merge persisted and CLI-started agents into the frontend canvas state, ensuring agents started via CLI instantly appear on the canvas and interactive UI.6. Store File Locking Reliability Fixes
copyFileSync): Updatedlib/protocols/x402-receipt-store.ts,lib/agents/agent-error-store.ts, andlib/agent-runtime/persistence.tswithcopyFileSyncandunlinkSyncfallback handling. This eliminates WindowsEPERMfile locking errors when running parallel tests or background file updates.🧪 Comprehensive Testing & Verification
Unit Test Suites Created
__tests__/agent-runtime/sdk.test.ts: Validates agent creation, task execution, lifecycle hooks (onStart,onStop,onError), and metrics tracking.__tests__/agent-runtime/persistence.test.ts: Verifies JSON state persistence, empty file recovery, and agent state upserts.__tests__/agent-runtime/cli.test.ts: End-to-end testing ofopen-stellar agent startandopen-stellar agent listprocess execution.Full Test Suite Results (
npx vitest run)🛡️ Code Quality & Build Checks
npm run lintnpx tsc --noEmitnpm run secretlintnpx prettier --checknpm run build📦 Git Branch & Remote Sync
feat/agent-runtime-local-cloud-orchestrationorigin/feat/agent-runtime-local-cloud-orchestration.Closes #17