SuperAPIAI Directory

cloud-agent

github.com · AI agents

cloud-agent is a TypeScript agent runtime and multi-protocol LLM client for multi-replica cloud services, open-sourced by nia-teams. It primarily addresses the problems of session mutual exclusion, streaming reconnection, and crash recovery when agents run across multiple service replicas: the same session executes on only one replica at a time, and messages received by other replicas enter a pending queue; openSnapshotStream first sends a session snapshot, then pushes real-time incremental events; upon receiving SIGTERM it waits for in-progress turns to finish, and after an abnormal crash another replica takes over the session once the lease expires and recovers unfinished sub-agents from checkpoints. The project also uses MediaStore and MediaRef to separate media storage from model transmission for multimodal tool outputs; session history retains only lightweight references, which are resolved before each request according to the current model's mediaInput transport method, and base64 media has a 20 MiB raw byte budget. The repository contains two packages, @nia-teams/agent-core and @nia-teams/ai, and provides quick examples of the single-process AgentRuntime and the HTTP service AgentHost. Running requires Node.js 20 or above (ESM); examples must be run with tsx or built with tsc first; the project does not bundle a database, cache, or HTTP framework driver, multi-process deployment requires integrating a shared adapter yourself, and it does not manage model aliases, billing, or credentials; HTTP authentication, session ownership validation, and rate limiting must be implemented at the service layer.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)

About this tool

cloud-agent is a TypeScript agent runtime and multi-protocol LLM client open-sourced by nia-teams, positioned as agent infrastructure that supports multi-replica cloud service deployment. The repository provides two packages, @nia-teams/agent-core and @nia-teams/ai, along with in-package skill documentation files that can be loaded by AI coding assistants.

Purpose and core problems When an agent runs across multiple service replicas, AgentHost handles three types of problems: session mutual exclusion, meaning a session executes on at most one replica at a time, and messages sent to other replicas enter a pending queue; streaming reconnection, where openSnapshotStream first sends a session snapshot and then pushes real-time incremental events; and crash recovery, where upon receiving SIGTERM it waits for in-progress turns to complete, and after an abnormal crash another replica reclaims the session once the lease expires and recovers unfinished sub-agents from checkpoints.

Multimodal media handling @nia-teams/agent-core and @nia-teams/ai separate media storage from model transmission via MediaStore and MediaRef. Tools store normalized image, audio, video, or PDF artifacts in MediaStore, and the conversation history retains only lightweight MediaRef pointers. Before each request, the runtime resolves references according to the current model's mediaInput transport method (url or base64), and base64 media has a fixed 20 MiB raw byte budget, after which the protocol client encodes it at the transport layer. This avoids bloating session storage with base64, avoids re-reading or re-transcoding source files every turn, and supports switching between URL-oriented and base64-oriented models without changing tool code. Built-in AgentHost turns require mediaStore and mediaInput to be set in the resolved AgentConfig; when a user intervenes in a running turn, tool media is retained; applications can use mediaStore.delete(sessionId) to clear all media of a retired session.

Usage The repository provides a single-process AgentRuntime example (examples/quickstart-single.ts, saved as agent.ts and run with tsx) and an HTTP service AgentHost example (examples/quickstart-http.ts, save it as server.ts and run it with tsx). The runtime requires Node.js >= 20 (ESM); running the TypeScript examples requires tsx (npx tsx ...) or building first with tsc.

Limitations and caveats @nia-teams/agent-core does not bundle database, cache, or HTTP framework drivers; createMemoryDocStore() and createMemoryPubSub() only keep state within a single Node.js process, so multi-process or multi-host deployments must use shared adapters (such as @nia-teams/agent-core/docstore-mongo and @nia-teams/agent-core/pubsub-redis), otherwise the multi-replica mechanisms described above cannot take effect across processes. @nia-teams/ai does not manage model alias tables, billing configuration, or credential storage. Crash recovery does not roll back external writes already performed by tools; tools that modify external state require idempotency keys or manual confirmation. HTTP authentication, session ownership validation, and rate limiting must be implemented by the consumer at the service layer.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools