yao Documentation

repository·main·Indexed 27 days ago

https://github.com/yaoapp/yao

A single-binary app runtime for the AI era designed for building AI agents and full-stack web applications. It features built-in TypeScript execution, memory management, and search capabilities, utilizing a Provider and Capability Adapter architecture to support various LLM API formats and model features like vision, tool calling, audio, and reasoning.

Tokens
253.4K
Snippets
659
Records
1.2K
Agent score
92%

What's inside yao

  1. Overview of YAO OpenAPI Request Design

    main

    The YAO OpenAPI Request module provides a unified middleware layer for managing API lifecycle tasks. It is designed to handle:

    1. Request Tracking: Assigning unique IDs to all API requests.
    2. Billing: Tracking token usage and API call counts.
    3. Rate Limiting: Enforcing request limits at the user, team, or endpoint level.
    4. Auditing: Maintaining an audit trail for compliance.

    This module applies to all /api/* endpoints and includes request duration metrics and token usage tracking, but does not handle static file serving, detailed request/response body logging, or response caching.

  2. Overview of Yao App Runtime

    main
    Yao is an open-source, single-binary runtime designed for building AI agents and web applications. It provides a controlled environment (a "cage") for AI behavior using a standardized request pipeline. It features a built-in V8 engine for TypeScript execution, eliminating the need for external runtimes like Node.js or Python on the host machine.
  3. Overview of Yao gRPC Server Architecture

    main

    The Yao gRPC server provides a high-performance interface for interacting with Yao's core capabilities, including LLM/Agent streaming, API proxying, and MCP (Model Context Protocol) handlers.

    V1 Capabilities:

    • Authentication
    • Unary RPCs
    • LLM and Agent streaming
    • Container client support

    V2 Capabilities (Planned):

    • Base streaming (Stream, ShellStream)
    • gou/stream package integration
    • V8 integration
  4. Overview of Pipe Widget

    main

    The Pipe Widget is used for complex logic orchestration and serves as an alternative to Flow. It is primarily used for generating DSL (Domain Specific Language) from graphical interfaces or implementing simple functional logic extensions on the application side.

    Warning: Pipe Widget is an experimental feature and is not recommended for production use.

  5. Overview of the Yao Excel Module

    main
    The Yao Excel Module is a Go-based module designed for manipulating Excel files, providing a TypeScript API for seamless integration within the Yao runtime. It allows for opening, reading, writing, and styling Excel files through the Process function.
  6. Overview of the User API Module

    main

    The User API Module provides a comprehensive set of interfaces for managing users within the Yao ecosystem. It covers the following functional areas:

    • Authentication & Security: Handling user login, account security settings, and Multi-Factor Authentication (MFA).
    • Profile Management: Managing user identity and profile information.
    • Integrations: OAuth and third-party service integrations.
    • Access Control: API Keys management.
    • Financials: Managing credits, top-ups, subscriptions, billing, and invoices.
    • Analytics: Accessing usage statistics.
  7. Overview of Knowledge Base Providers

    main

    The Knowledge Base (KB) system in Yao uses a modular provider architecture to handle document processing pipelines. Providers are categorized by their specific role in the workflow:

    • Chunking Providers: Responsible for splitting documents into smaller, manageable pieces.
    • Embedding Providers: Responsible for converting text into vector representations.
    • Extraction Providers: Responsible for extracting entities and relationships to build knowledge graphs.
    • Fetcher Providers: Responsible for retrieving documents from various external or internal sources.
    • Converter Providers: Responsible for transforming various file formats into a standardized, processable text format.
  8. Overview of the Context API (ctx)

    main
    The ctx object is the central interface in Yao, providing access to messaging, memory, tracing, MCP (Model Context Protocol) operations, search, agent-to-agent communication, and LLM calls. It contains session metadata like chat_id, assistant_id, locale, and metadata.
  9. Overview of Yao — AI App Runtime

    main

    Yao is an open-source runtime for AI Agents and Web applications delivered as a single binary for immediate use. It provides a controlled environment (a "cage") where AI performs tasks within defined boundaries.

    Key capabilities include:

    • Agent Framework: TypeScript-based hooks, native MCP support, multi-scope Memory API, and multi-agent collaboration.
    • Full-Stack Runtime: Built-in data modeling (JSON/YAML), REST API generation, SUI (Server-side UI) pages, and a built-in Chat UI (CUI).
    • Built-in Search: Supports Vector Search (OpenAI/FastEmbed), Knowledge Graphs, and GraphRAG.
    • Sandboxed CLI Agents: Runs CLI programs like Claude Code in isolated containers with VNC desktop support.
  10. Overview of the Yao Utils Module

    main
    The Yao Utils Module is a Go module providing a collection of utility functions. It includes TypeScript API support, allowing developers to consume these utilities within TypeScript environments.
  11. Understand the OpenAPI Request Data Model

    main

    Yao uses a hybrid two-layer storage strategy for OpenAPI requests.

    1. KV Storage (Hot Data): Used for high-frequency, short-lived data like rate limiting, request status tracking, and daily token usage. This layer uses TTLs (Time-To-Live) to manage data expiration.
    2. SQL Storage (Archive Data): The openapi_request table provides long-term storage for billing reports, audit logs, and analytics. It tracks detailed request metadata, token counts, and service-specific information.
  12. Understand the ACL Enforcement Logic

    main

    The Access Control List (ACL) enforcement system validates permissions for OAuth-protected APIs using a multi-layered approach. It follows an AND logic principle: all applicable validation steps must pass for access to be granted. If any single check fails, access is immediately denied.

    The validation layers include:

    1. Client: Validates the OAuth client's permissions.
    2. Token Scope: Validates explicit scopes granted within the OAuth token.
    3. Team/Member/User: Validates permissions based on the login type (Team, Team Member, or individual User).