@aragon-agent/core

中文文档
0.2.67发布于 2026/11/06MITTypeScriptES Module零依赖近 30 天下载 6643

AragonAgent core engine — LLM provider adapters, streaming, tool registry/execution, steering, idle watchdog, and an optional isolated-vm sandbox.

原始使用文档
文档目录8 节
  1. Requirements
  2. Install
  3. Usage
  4. Entry points
  5. Build
  6. Verifying reuse
  7. Publishing
  8. License

@aragon-agent/core

The publishable AragonAgent engine: a zero-coupling, dependency-injected TypeScript agent runtime.

Requirements

  • Node.js ≥ 18 — the engine relies on the global fetch / AbortController built into Node 18+.
  • ESM-only — this package ships as native ES modules ("type": "module"). Consume it with import; it cannot be require()-d from CommonJS.
  • Optional native deps — ajv and isolated-vm are optionalDependencies: the package works without them (a built-in validator fallback is used, and the sandbox modules are lazy-loaded). Install isolated-vm only if you use the @aragon-agent/core/sandbox/* CodeAct sandbox.

Install

npm install @aragon-agent/core
# optional — only if you use the isolated-vm CodeAct sandbox:
npm install isolated-vm

ajv and isolated-vm are optional dependencies:

  • ajv — used by the tool param validator when present; a built-in fallback validator is used otherwise.
  • isolated-vm — used only by the @aragon-agent/core/sandbox/* modules, which are lazy-loaded and never imported from the package root (isolated-vm is incompatible with some embedded V8 runtimes such as Electron's).

Usage

import { AragonAgent, getProviderRegistry, initProviders } from '@aragon-agent/core';

initProviders();

const agent = new AragonAgent({
  systemPrompt: 'You are a coding agent.',
  model: { providerId: 'anthropic', modelId: 'claude-...', baseUrl: '...' },
  tools: [],
  providerRegistry: getProviderRegistry(),
  getApiKey: () => process.env.ANTHROPIC_API_KEY,
});

await agent.prompt('Hello');

AragonAgent is an alias of the engine's Agent class.

A complete, type-checked version of this snippet (a dummy tool + provider setup

  • agent construction) lives in examples/minimal.ts. It is compile-only (never hits the network) and is not part of the published tarball.

Entry points

Import pathContents
@aragon-agent/coreFull barrel (engine, LLM, tools, types).
@aragon-agent/core/llm/typesLLM message / streaming / model types.
@aragon-agent/core/llm/providersProvider registry + streamLLM/completeLLM.
@aragon-agent/core/tools/typesTool system types.
@aragon-agent/core/tools/helperstextResult / errorResult / defineTool.
@aragon-agent/core/sandbox/*Optional isolated-vm CodeAct sandbox.

Build

npm run build   # tsc → dist/*.js + *.d.ts
npm test        # vitest (smoke + public-api contract + no-host-coupling guard)

Verifying reuse

npm test and examples/minimal.ts only prove the package compiles. To prove the built dist/ can actually be run by an external consumer:

npm run verify:dist   # build dist/, then run examples/consumer-smoke/run.mjs

run.mjs imports this package by its own name (@aragon-agent/core) via Node's package self-referencing, so Node resolves it through package.json#exports → ./dist/index.js — the same (exports map + NodeNext + .js extension) path that an external project's npm install @aragon-agent/core hits, without placing the package in node_modules. It injects an offline stub LLM provider, runs one AragonAgent.prompt() turn end-to-end (zero network), and asserts the exports subpaths all resolve at runtime. Success prints [consumer-smoke] OK.

For the unambiguous "another project installs and reuses it" check (which also covers running without the optional ajv / isolated-vm deps), see the pack-into-a-fresh-project golden verification in examples/consumer-smoke/README.md.

The runtime public-API surface is frozen by src/__tests__/public-api.test.ts and documented for humans in API.md; a no-host-coupling test keeps the package free of host-repo imports and legacy brand leakage.

Publishing

This package is published to the public npm registry. Run the release from the package directory so the package-level prepublishOnly hook fires and a fresh dist/ is built:

cd packages/core
npm run build                 # produce dist/
npm pack --dry-run --json     # inspect the tarball file list (no upload)
npm publish                   # publishConfig.access:"public" is baked in

(From the repo root you can equivalently run npm publish -w packages/core.)

Notes:

  • publishConfig.access is set to "public", so no --access public flag is needed — scoped packages would otherwise default to restricted/private.

  • The publishing account must own the @aragon-agent npm scope/org before the first publish. Even with access:"public", publishing under a scope you do not own fails with 403/404. Create the @aragon-agent org on npmjs (or switch to a scope your account owns and rename the package accordingly).

  • files is the load-bearing whitelist. The repo's .gitignore ignores dist/, but npm's files: ["dist", "CHANGELOG.md"] takes precedence and ships the built output. Do not "simplify" the files field away, or the published tarball will be empty. npm pack --dry-run --json should always list dist/index.js.

  • Repository metadata points to https://github.com/xdrshjr/AragonAgent.

    If the repository moves, use the helper script or update repository / homepage / bugs before publishing:

    node scripts/stamp-org.mjs <org>     # or: ARAGON_REPO_ORG=<org> node scripts/stamp-org.mjs
    node scripts/check-publishable.mjs   # exits non-zero if the placeholder remains in package.json
    

    prepublishOnly runs check-publishable.mjs before the build, so any publish attempt with an unstamped placeholder is hard-blocked automatically.

License

MIT.

版本与发布记录

@aragon-agent/core 共发布 66 个版本,首次发布于 2026/07/27;过去 12 个月发布了 66 个版本。

版本发布日期距今
0.2.67latest2026/11/061 天前
0.2.662026/11/052 天前
0.2.652026/11/034 天前
0.2.642026/11/017 天前
0.2.632026/10/299 天前
0.2.622026/10/299 天前

关于 @aragon-agent/core 的常见问题

@aragon-agent/core 是什么?

AragonAgent core engine — LLM provider adapters, streaming, tool registry/execution, steering, idle watchdog, and an optional isolated-vm sandbox.

如何安装 @aragon-agent/core?

在项目目录运行 npm install @aragon-agent/core,或使用 pnpm add / yarn add / bun add。

@aragon-agent/core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aragon-agent/core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@aragon-agent/core 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@aragon-agent/core 可以商用吗?

@aragon-agent/core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@aragon-agent/core 的下载量有多少?

根据 npm 官方下载统计,@aragon-agent/core 在 2026/10/07 – 2026/11/05 这 30 天内被下载 6,643 次,日均约 221 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aragon-agent/core 还在维护吗?

最新版本 0.2.67 发布于 2026/11/06(1 天前);至今共发布 66 个版本,其中过去 12 个月发布了 66 个;首次发布于 2026/07/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。