LangChain.js Integration
JACS provides two integration patterns for LangChain.js:
- Full toolkit -- expose all JACS operations as LangChain tools your agent can call
- Auto-signing wrappers -- transparently sign existing tool outputs
5-Minute Quickstart
1. Install
npm install @hai.ai/jacs @langchain/core
2. Create a JACS client
import { JacsClient } from '@hai.ai/jacs/client';
const client = await JacsClient.quickstart();
3. Sign tool outputs
import { signedTool } from '@hai.ai/jacs/langchain';
const signed = signedTool(mySearchTool, { client });
const result = await signed.invoke({ query: 'hello' }); // result is JACS-signed
Or give your agent the full JACS toolkit:
import { createJacsTools } from '@hai.ai/jacs/langchain';
const jacsTools = createJacsTools({ client });
const allTools = [...myTools, ...jacsTools];
const llmWithTools = model.bindTools(allTools);
Full Toolkit
createJacsTools() returns an array of LangChain DynamicStructuredTool instances wrapping the full JacsClient API. Bind these to your LLM so the agent can sign, verify, create agreements, manage trust, and audit -- all as part of its reasoning.
import { JacsClient } from '@hai.ai/jacs/client';
import { createJacsTools } from '@hai.ai/jacs/langchain';
const client = await JacsClient.quickstart();
const jacsTools = createJacsTools({ client });
// Combine with your own tools and bind to an LLM
const allTools = [...myTools, ...jacsTools];
const llmWithTools = model.bindTools(allTools);
Available Tools
| Tool | Description |
|---|---|
jacs_sign | Sign arbitrary JSON data with cryptographic provenance |
jacs_verify | Verify a signed document |
jacs_create_agreement | Create a multi-party agreement |
jacs_sign_agreement | Sign an existing agreement |
jacs_check_agreement | Check agreement status (signatures, completeness) |
jacs_verify_self | Verify this agent's integrity |
jacs_trust_agent | Add an agent to the local trust store |
jacs_list_trusted | List all trusted agent IDs |
jacs_is_trusted | Check if a specific agent is trusted |
jacs_audit | Run a security audit |
jacs_agent_info | Get agent ID, name, and status |
Strict Mode
Pass strict: true to make tools throw on errors instead of returning error JSON:
const tools = createJacsTools({ client, strict: true });
Auto-Signing Wrappers
signedTool
Wraps any LangChain BaseTool so its output is automatically signed:
import { signedTool } from '@hai.ai/jacs/langchain';
const signed = signedTool(mySearchTool, { client });
const result = await signed.invoke({ query: 'hello' }); // result is JACS-signed
jacsToolNode (LangGraph)
Creates a LangGraph ToolNode where every tool's output is signed:
import { jacsToolNode } from '@hai.ai/jacs/langchain';
const node = jacsToolNode([tool1, tool2], { client });
Requires @langchain/langgraph.
jacsWrapToolCall
Returns an async wrapper for manual tool execution in custom LangGraph workflows:
import { jacsWrapToolCall } from '@hai.ai/jacs/langchain';
const wrapFn = jacsWrapToolCall({ client });
// Use in custom graph: const result = await wrapFn(toolCall, runnable);
Installation
npm install @hai.ai/jacs @langchain/core
# Optional for jacsToolNode:
npm install @langchain/langgraph
All @langchain/* imports are lazy -- the module can be imported without LangChain installed.
Next Steps
- MCP Integration -- Full JACS tool suite for MCP servers
- Vercel AI SDK -- AI model provenance signing
- Express Middleware -- HTTP API signing