@archstone/agent

中文文档
0.35.0发布于 2026/10/22Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 1806

直接将Archstone能力嵌入到你自己的代理循环中:为Anthropic,OpenAI,双子座和平原JSON Schema打入了工具定义,加上在编译的IR上失败关闭执行——不需要MCP服务器进程.

中文使用文档

@ archstone/ 代理服务器

嵌入剂 SDK(RFC-0008 / ADD-0008):装入已编译的 Archstone IR 文物,生成打字器 工具定义(Anthropic · OpenAI Chat 补全 · OpenAI 响应 · 双子座- JSON-Schema), 以 在采掘边界上判断模型制作的文件 - 全部不运行单独的 MCP 服务器进程.

两个切入点:

  • 根号 (单位:千美元)@archstone/agent: fromIR(json) 构造嵌入式实例; tools(format) 生成已键入的工具 defs; execute(capabilityId, input) 引用绘图能力 适用; extractor(resource, format) 将一个已申报资源绑在一个目标上——计划 给出一个模型,其答案作为一个物体(ADR-0011)通过边界。 无 MCP SDK, 无 node:fs ——安全地捆绑并跑到任何地方(浏览器,工人,本地应用).
  • /mcp 子路径 (单位:千美元)@archstone/agent/mcp: mcpHandler(archstone, {bearerToken}) a 包括: 可挂载,可失效的闭塞 嵌入实例作为 MCP 服务器( 如 Claude API) mcp_servers, ChatGPT 连接器).

快开始

import { fromIR } from "@archstone/agent";
import { readFileSync } from "node:fs";

// Load a compiled IR (produced by `archstone build manifest/`)
const ir = JSON.parse(readFileSync("archstone.ir.json", "utf-8"));
const archstone = fromIR(ir);

// Get tool definitions in your preferred format
const anthropicTools = archstone.tools("anthropic");
const openaiChatTools = archstone.tools("openai-chat");        // Chat Completions
const openaiResponsesTools = archstone.tools("openai-responses"); // Responses API
const geminiTools = archstone.tools("gemini");
// "openai" still works but is a deprecated alias of "openai-chat" — migrate explicitly.

// Invoke a capability — accepts both raw dotted id or sanitized tool name
const result = await archstone.execute("tourism.search", {
  location: "Paris",
  checkInDate: "2026-08-01",
});
// Same call with sanitized tool name (as returned by tools()):
// const result = await archstone.execute("tourism_search", {...});

if (result.status === "ok") {
  console.log("Success:", result.data);
} else if (result.status === "degraded") {
  console.log("Partial:", result.data, "Missing:", result.degraded);
} else if (result.status === "violation") {
  console.log("Contract violation:", result.missing);
} else {
  console.log("Error:", result.error);
}
// `result.withheld` (optional) names any `web-page` field whose value was outside the binding's
// declared origins and was therefore withheld — field names only, never the value.

工具定义信封只包含输入方案, 所以输出字段的语义类型 联合国 web-page 例如,链接)没有在其中表示; execute() 仍然应用来源 检查并返回正态链接或扣取.

从无结构输入中提取业务数据(ADR-0011):

《资源定义》已经描述了提供者的反应。 一样 定义说模型必须做什么 生产,以及 extractor() 两者兼有: 模型被给出了计划,验证器的答案被判断——所以两者不能漂移 分开.

const stay = archstone.extractor("tourism.Stay", "anthropic");

// Give the model the schema — either axis, same schema underneath.
stay.structuredOutput;   // native structured output, in the envelope your provider expects:
                         //   Anthropic:        output_config.format
                         //   OpenAI-chat:      response_format.json_schema (Chat Completions)
                         //   OpenAI-responses: text.format (Responses API)
                         //   Gemini:           response_format

// ...or extraction as a forced tool call, in the same envelopes tools() emits. The
// instruction is required and never defaulted: it says what to DO on this occasion, which
// no Resource Definition can know.
stay.tool("Record the stay described in this booking email.");

// Judge what comes back, at a boundary Archstone owns.
const result = stay.validate(modelOutput);

if (result.status === "ok") {
  save(result.data);
} else if (result.status === "degraded") {
  save(result.data); // declared optional fields absent: result.degraded
} else {
  reject(result.missing, result.invalid); // withheld whole — result.data is absent
}

// Undeclared keys never reach `result.data`, at any depth, and are named in
// `result.undeclared`. There is no passthrough option, for the same reason there is none
// in ADR-0008.

status 证明 形状,从不真实:一个能创造出可信,正确类型值的模型 返回时 ok,在这个边界上,除了一个真实的,没有任何东西可以分辨出来。 错误消息 从未对文档中的值进行回声 — 提取输入是构造中最 在部署中的敏感文字.

对于基于 HTTP 的 MCP :

import { mcpHandler } from "@archstone/agent/mcp";

const handler = mcpHandler(archstone, {
  bearerToken: process.env.ARCHSTONE_TOKEN,
  invoke: { env: process.env }, // optional: env injection for REST connectors
});

// Mount on your framework (e.g., Hono, Express, fetch-based)
const response = await handler(new Request(...));

部分 拱顶石,开源 能力平台. 完整文件见 archstone/packages/agent 编辑 主要 README.md。 。 。 .

许可证

阿帕奇 - 2.0

版本与发布记录

@archstone/agent 共发布 50 个版本,首次发布于 2026/07/18;过去 12 个月发布了 50 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.35.0latest2026/10/2216 天前
0.34.02026/10/1227 天前
0.33.02026/10/1128 天前
0.32.02026/10/1029 天前
0.29.02026/10/071 个月前
0.28.02026/10/061 个月前

关于 @archstone/agent 的常见问题

@archstone/agent 是什么?

直接将Archstone能力嵌入到你自己的代理循环中:为Anthropic,OpenAI,双子座和平原JSON Schema打入了工具定义,加上在编译的IR上失败关闭执行——不需要MCP服务器进程.

如何安装 @archstone/agent?

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

@archstone/agent 支持 TypeScript 吗?

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

@archstone/agent 支持 ESM 还是 CommonJS?

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

@archstone/agent 可以商用吗?

@archstone/agent 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@archstone/agent 的下载量有多少?

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

@archstone/agent 还在维护吗?

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