JSPM

  • Created
  • Published
  • Downloads 21
  • Score
    100M100P100Q88469F
  • License AGPL-3.0

YUAN Agent Core Runtime

Package Exports

  • @yuaone/core
  • @yuaone/core/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@yuaone/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@yuaone/core

Agent runtime for YUAN coding agent.

npm install @yuaone/core

Usage

import { AgentLoop, createAgentLoop } from "@yuaone/core";

const loop = createAgentLoop({
  provider: "anthropic",
  apiKey: process.env.ANTHROPIC_API_KEY,
  model: "claude-sonnet-4-6",
  workDir: process.cwd(),
});

for await (const event of loop.run("refactor auth.ts to async/await")) {
  if (event.kind === "agent:token") process.stdout.write(event.content);
  if (event.kind === "agent:completed") break;
}

Architecture

Module Description
AgentLoop Core tool-use loop — LLM ↔ tools ↔ approval
HierarchicalPlanner Task decomposition with dependency ordering
ExecutionPolicyEngine Token/cost budget per iteration
ContinuationEngine Checkpoint every 3 iters, recovery on error
ReflexionEngine Per-iteration self-reflection & insight injection
WorldStateCollector Tracks file changes across iterations
QAPipeline Quick + thorough quality checks post-execution
Governor Safety/security scanning before tool execution
AutoFix Automatic lint/type error repair
ContextManager Token budget management & compaction

Events

type AgentEvent =
  | { kind: "agent:thinking"; content: string }
  | { kind: "agent:token"; content: string }
  | { kind: "agent:tool_call"; toolName: string; arguments: unknown }
  | { kind: "agent:tool_result"; toolName: string; result: string; durationMs: number }
  | { kind: "agent:approval_needed"; action: { tool: string; input: unknown } }
  | { kind: "agent:completed"; message: string }
  | { kind: "agent:error"; message: string; retryable: boolean }
  | { kind: "agent:token_usage"; input: number; output: number }
  | { kind: "agent:qa_result"; stage: "quick" | "thorough"; passed: boolean; issues: string[] }

License

AGPL-3.0 — part of YUAN.