Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Native library reference. Extended CLI examples use jacs-compat. This source reference can include unreleased changes; see the package guide for installation and MCP profiles for available tools.

LangChain.js Integration

Source and published packages: Version 0.16.1 has a recorded release inventory. Version 0.16.0 is the first release whose source includes the native PQ DID/JWK and Agent Card behavior. See the identity integration guide.

Use the LangChain.js adapter when the model already runs inside your Node.js app and you want provenance at the tool boundary.

Choose The Pattern

Give The Agent JACS Tools

Use createJacsTools() when the model should explicitly ask to sign, verify, inspect trust, or create agreements.

import { JacsClient } from '@hai.ai/jacs/client';
import { createJacsTools } from '@hai.ai/jacs/langchain';

const client = await JacsClient.quickstart({
  name: 'my-agent',
  domain: 'my-agent.example.com',
});

const jacsTools = createJacsTools({ client });
const llmWithTools = model.bindTools([...myTools, ...jacsTools]);

The tool set includes 13 tools:

  • jacs_sign
  • jacs_verify
  • jacs_create_agreement
  • jacs_sign_agreement
  • jacs_check_agreement
  • jacs_verify_self
  • jacs_trust_agent
  • jacs_trust_agent_with_key
  • jacs_list_trusted
  • jacs_is_trusted
  • jacs_share_public_key
  • jacs_share_agent
  • jacs_agent_info

Auto-Sign Existing Tools

Use this when the model should keep using your existing tool set but every result needs a signature.

Wrap one tool:

import { signedTool } from '@hai.ai/jacs/langchain';

const signed = signedTool(mySearchTool, { client });

Wrap a LangGraph ToolNode:

import { jacsToolNode } from '@hai.ai/jacs/langchain';

const node = jacsToolNode([tool1, tool2], { client });

For custom graph logic:

import { jacsWrapToolCall } from '@hai.ai/jacs/langchain';

const wrapToolCall = jacsWrapToolCall({ client });

Install

npm install @hai.ai/jacs @langchain/core
npm install @langchain/langgraph

@langchain/langgraph is only required for jacsToolNode().

Strict Mode

Signed wrappers fail closed by default: signing failures withhold the output. The explicit allowUnsignedOutput: true compatibility option permits unsigned fallback; strict: true overrides it. Tool-operation error reporting is separate:

const jacsTools = createJacsTools({ client, strict: true });

Examples In This Repo

  • archive/native/jacsnpm/examples/langchain/basic-agent.ts
  • archive/native/jacsnpm/examples/langchain/signing-callback.ts

When To Use MCP Instead

Choose Node.js MCP Integration instead when:

  • the model is outside your process and connects over MCP
  • you want a shared MCP server usable by multiple clients
  • you need transport-level signing in addition to signed tool outputs