Skip to content

Latest commit

 

History

History
99 lines (71 loc) · 2.72 KB

File metadata and controls

99 lines (71 loc) · 2.72 KB

AIP TypeScript SDK

TypeScript implementation of the Agent Identity Protocol (AIP) for verifiable, delegable AI agent identity.

Full spec implementation including features not yet available in the Python SDK: DNS-based identity resolution, completion blocks for provenance, HTTP binding, and A2A binding.

Packages

Package Description
@aip-sdk/core Ed25519 identity, key management, identity documents, DNS resolution, completion blocks
@aip-sdk/token Compact (JWT+EdDSA) and chained (Biscuit+Datalog) tokens
@aip-sdk/mcp MCP proxy middleware, audit, token verification, HTTP binding
@aip-sdk/agents Framework adapters (LangChain.js, Vercel AI SDK), A2A binding

Quick Start

npm install @aip-sdk/core @aip-sdk/token
import { KeyPair } from "@aip-sdk/core";
import { CompactToken } from "@aip-sdk/token";

// Generate identity
const keypair = await KeyPair.generate();
const aipId = `aip:key:ed25519:${keypair.publicKeyMultibase()}`;

// Issue token
const token = await CompactToken.create(
  {
    iss: aipId,
    sub: "aip:key:ed25519:zAgent1",
    scope: ["tool:search"],
    max_depth: 0,
    iat: Math.floor(Date.now() / 1000),
    exp: Math.floor(Date.now() / 1000) + 3600,
  },
  keypair
);

// Verify token
const verified = await CompactToken.verify(token, keypair.publicKeyBytes());
console.log("Verified:", verified.claims.scope);

MCP Proxy

Protect MCP servers with token verification:

import { AipProxy, ProxyConfig } from "@aip-sdk/mcp";

const config = new ProxyConfig({
  upstream: "http://localhost:3000",
  port: 8080,
  trustKeys: ["z6MkhaXgBZDvotDkL5LQ..."],
});

const proxy = new AipProxy(config);
proxy.serveForever();

Agent Framework Integration

LangChain.js

import { AIPLangChainPlugin } from "@aip-sdk/agents";

const plugin = new AIPLangChainPlugin();
await plugin.register(agentExecutor, "search-agent");

const headers = await plugin.getToolCallHeaders("search-agent");
// { "X-AIP-Token": "eyJ..." }

Vercel AI SDK

import { AIPVercelAIPlugin } from "@aip-sdk/agents";

const plugin = new AIPVercelAIPlugin();
await plugin.register("assistant", ["search", "calculate"]);

const headers = await plugin.getToolCallHeaders("assistant");

Protocol

License

Apache 2.0