@ contextgraph/ sdk — TypeScript (英语)
用于构建的零依赖性类型SDK 符合者 背景图 礼宾提供者。 执行一个接口,把它交给运行时间,然后你 有个供货商会用线形JSON线 绕过楼梯 和评断Rust参考商的套房一样.
这是第二次独立执行(在Rust提及之后),以及 它传递了完全符合的套件,即: 协议的"通过合同强制执行,而非约定"索赔. 见
sdk/README.md为多语言图片.
安装
npm install @contextgraph/sdk
写入提供者
import { runStdioProvider, budgetTokens, type Provider } from "@contextgraph/sdk";
const provider: Provider = {
info: () => ({
name: "my-docs-provider",
version: "0.1.0",
// Nothing leaves the machine ⇒ declare the honest local-only egress scope.
data_flow: { reads: true, writes: false, egress: false, egress_scopes: ["local-only"] },
}),
capabilities: () => ({ query: { kinds: ["doc"] }, correlation: true, verify: true }),
query: () => ({
frames: [
{
id: "doc:1",
kind: "doc",
title: "Getting started",
content: "Install the binding, then implement the required methods.",
content_digest: `sha256:${"11".repeat(32)}`,
score: 0.9,
// token_cost MUST equal ceil(utf8_len(content)/4) — the SDK computes it.
token_cost: budgetTokens("Install the binding, then implement the required methods."),
valid_from: "2026-01-01T00:00:00Z",
provenance: [{ type: "file", uri: "file:///docs/start.md", range: "L1-10", digest: `sha256:${"11".repeat(32)}` }],
citation_label: "start.md L1-10",
relations: [],
},
],
truncated: false,
}),
};
runStdioProvider(provider);
运行时间处理一个主机驱动器的整个生命周期——握手,查询
(选择相关性) id),核实,关闭——并保持与打入的活
错误在错误的行上而不是崩溃 .
它给你什么
- 电线类型 (单位:千美元)
ContextFrame, (中文(简体) ),ContextQuery, (中文(简体) ),Capabilities, (中文(简体) ),Envelope, (...) (中文(简体) ) 由JSON Schema所镜出——语言中性的真理来源. runStdioProvider(provider)——stdio生命周期循环.budgetTokens(content)峡谷B3成本,ceil(utf8_len/4)。 。 。 .- 一个可运行 实例提供者 (单位:千美元)
examples/example-docs.ts传递所有 7次合规检查.
证明它符合规定
构建, 然后对您的提供者运行参考套件 :
npm run build
# from the repository root, with the Rust bins built (cargo build --workspace --bins):
./.github/scripts/conformance-external.sh -- node sdk/typescript/dist/examples/example-docs.js
绿色跑步是机器可以检查的声称 你的提供者尊重 议定书——每次执行都要遵守同一条.
许可证
MIT OR Apache-2.0,匹配上下文图形协议的框.