@ 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