LangChain.js Integration

JACS provides two integration patterns for LangChain.js:

  1. Full toolkit -- expose all JACS operations as LangChain tools your agent can call
  2. 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

ToolDescription
jacs_signSign arbitrary JSON data with cryptographic provenance
jacs_verifyVerify a signed document
jacs_create_agreementCreate a multi-party agreement
jacs_sign_agreementSign an existing agreement
jacs_check_agreementCheck agreement status (signatures, completeness)
jacs_verify_selfVerify this agent's integrity
jacs_trust_agentAdd an agent to the local trust store
jacs_list_trustedList all trusted agent IDs
jacs_is_trustedCheck if a specific agent is trusted
jacs_auditRun a security audit
jacs_agent_infoGet 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