@deedglass/sdk

中文文档
0.15.0发布于 2026/10/28Apache-2.0TypeScriptES Module零依赖构建来源已验证近 30 天下载 2596

Put Deedglass in front of your agent's tools: policy decides, people approve, every call is sealed as a deed you can check offline.

原始使用文档
文档目录8 节
  1. Install
  2. Three ways to use it
  3. Frameworks
  4. Errors
  5. Idempotency and retries
  6. Signed intents
  7. Runtimes
  8. What it doesn't do

@deedglass/sdk

Put Deedglass in front of your agent's tools. Every call is decided by policy, approved by a person when a rule says so, and sealed as a deed you can check offline.

import { Deedglass, wrapTool } from '@deedglass/sdk';

const dg = new Deedglass();            // reads DEEDGLASS_API_KEY and DEEDGLASS_SERVER
const refund = wrapTool(refundCustomer, { client: dg, tool: 'billing.refund_customer' });
await refund({ customer: 'cus_123', amount: 2000 });   // runs only if policy allows it

Works with the Vercel AI SDK, the OpenAI Agents SDK, LangChain.js and the Claude Agent SDK. No runtime dependencies. Node 22.12+, Bun, Deno and edge runtimes.

What it doesn't do: it doesn't sandbox your function (it decides whether it runs), and results your code reports are recorded as reported (L0), not independently checked. Use a Deedglass connector when you need L1 or L2.

Install

npm install @deedglass/sdk

Set DEEDGLASS_API_KEY (an agent key, dg_test_… or dg_live_…, from Console › Agents) and DEEDGLASS_SERVER (default http://127.0.0.1:8080). The package is ESM; on Node 22.12 and newer, require('@deedglass/sdk') works too.

Three ways to use it

1. Your own functions: wrapTool (proxy mode). Deedglass decides; your function runs only after the action is authorized, at most once; its outcome is reported and sealed.

const refund = wrapTool(refundCustomer, {
  client: dg,
  tool: 'billing.refund_customer',
  onPending: 'throw',          // or 'wait' for a person to decide
  failureMeans: 'unknown',     // a thrown error means "it may have run" (the default)
});
  • A denial throws PolicyDeniedError with the policy's sentence. Your function never ran.
  • A pending approval throws ApprovalPendingError (with approvalId and expiresAt). Calling again with the same arguments after a person approves runs your function once; it doesn't ask again.
  • If your function throws, the deed says UNVERIFIABLE ("it may have run") and you get ToolExecutionError with the original as cause. Pass failureMeans: 'not_applied' only when the function fails before any side effect.

2. Connector tools: act (gateway mode). Deedglass runs the tool with the connector's credentials, which never leave it.

const a = await dg.act('stripe.create_refund', { charge: 'ch_3QxZ8f2L', amount: 2000 });
a.status;          // 'executed' · 'pending_approval' · 'failed'
a.witness?.verdict; // 'VERIFIED' at L1: Stripe's own record was read back
a.deed;            // 'deed_01j9…'

A tool that ran and failed returns status: 'failed' with its deed: an action happened, so it isn't an exception.

3. Check deeds offline: @deedglass/sdk/verify. No key needed, same answers as deedglass verify.

import { fetchKeys, verifyDeeds, splitLines } from '@deedglass/sdk/verify';
const { keys } = await fetchKeys('https://deedglass.example/.well-known/deedglass/keys.json');
const report = await verifyDeeds(splitLines(bytes), keys, { keysPinned: true });
report.result;     // 'valid' · 'invalid' · 'cannot_determine'

Frameworks

ImportGovern your tools (proxy)Connector tools (gateway)
@deedglass/sdk/ai-sdkgovernTools(tools, { client })deedglassTools(client)
@deedglass/sdk/openai-agentsgovernTool(tool, { client })deedglassTools(client)
@deedglass/sdk/langchaingovernTool(tool, { client })deedglassTools(client)
@deedglass/sdk/claude-agent-sdkdeedglassHooks({ client }), governSdkTool(def, { client })deedglassMcpServer(client)

Adapters return the denial or pending sentence to the model by default (onDenied: 'message', onPending: 'message'), because frameworks feed tool output back to the model and a throw ends some runs.

Errors

Every error is a DeedglassError with type, code, message (the server's, verbatim), param, status, requestId and docUrl; denials carry the sealed action. Use isDeedglassError(e); it works across copies of the package.

ClassWhen
AuthenticationErrorinvalid_api_key, api_key_revoked, api_key_expired
PermissionDeniedErroragent_stopped, org_stopped, insufficient_scope, intent_*
PolicyDeniedErrorpolicy_denied
BudgetExceededError429 budget_exceeded (never retried)
RateLimitError429 rate_limited, after retries
InvalidRequestErrorvalidation_failed, not_found, conflict, idempotency_conflict
APIError5xx
ConnectionError, TimeoutErrorthe network; a timeout means the action may still be running
ApprovalPendingError, ToolExecutionErrorwrapTool

Idempotency and retries

Every POST carries an Idempotency-Key, the same one on each retry, so the server never runs a tool twice. Network errors, 408, 429 rate_limited, 500, 502, 503 and 504 are retried twice by default with exponential backoff, honouring Retry-After up to 10 s and never past your signal or timeoutMs (30 s per request).

Signed intents

Give the client an Ed25519 key (deedglass agent intent keygen writes one) and every call is signed with deedglass.intent/1:

const dg = new Deedglass({ intentKey: { privateKeyPem: process.env.DEEDGLASS_INTENT_KEY! } });

signIntent, argsDigest, intentKid and generateIntentKey are exported for your own use. Integers above 2^53 − 1 in arguments are refused: send them as strings.

Runtimes

Node 22.12 and newer, Bun, Deno, Cloudflare Workers and Vercel Edge (Ed25519 in WebCrypto). The client refuses to start in a browser page, because an agent key is a secret: call Deedglass from your server. Pass dangerouslyAllowBrowser: true only if you accept that risk. @deedglass/sdk/verify runs anywhere.

What it doesn't do

  • wrapTool decides whether your code runs; it doesn't sandbox what it does.
  • Proxy-mode results are L0 (edge-reported). Independent L1/L2 checks need a Deedglass connector.
  • The Claude hooks see only tools the Agent SDK routes through hooks.
  • Offline verification checks seals and the chain, not whether the action was wise.

Apache-2.0.

版本与发布记录

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

版本发布日期距今
0.15.0latest2026/10/2815 天前
0.14.12026/10/2815 天前
0.14.02026/10/2715 天前
0.13.02026/10/2716 天前
0.12.02026/10/2616 天前
0.11.02026/10/2617 天前

关于 @deedglass/sdk 的常见问题

@deedglass/sdk 是什么?

Put Deedglass in front of your agent's tools: policy decides, people approve, every call is sealed as a deed you can check offline.

如何安装 @deedglass/sdk?

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

@deedglass/sdk 支持 TypeScript 吗?

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

@deedglass/sdk 支持 ESM 还是 CommonJS?

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

@deedglass/sdk 需要什么版本的 Node.js?

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

@deedglass/sdk 可以商用吗?

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

@deedglass/sdk 的下载量有多少?

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

@deedglass/sdk 还在维护吗?

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