Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.sigilcore.com/llms.txt

Use this file to discover all available pages before exploring further.

Installation

npm install @sigilcore/agent-hooks

Usage

import { wrapLangChainTool } from '@sigilcore/agent-hooks';

const config = {
  apiKey: process.env.SIGIL_API_KEY!,
  agentId: 'my-langchain-agent',
};

// Wrap any LangChain tool:
const safeTool = wrapLangChainTool(myTool, config);

// safeTool.call() now checks Sigil policy before executing
// If denied, returns a JSON rejection string the agent can parse

How It Works

wrapLangChainTool wraps the tool’s call() method. When the agent invokes the tool, Sigil evaluates the intent against your warranty.md policy first. On approval, the original call() executes. On denial or hold, a typed JSON rejection is returned as the tool output.
// The wrapped tool behaves identically to the original
// Except every call() is gated by Sigil policy first
const result = await safeTool.call('rm -rf /tmp/important');
// result = '{"sigil_decision":"DENIED","sigil_error_code":"SIGIL_POLICY_VIOLATION_BLOCKED_COMMAND"...}'
The JSON rejection is returned as the tool output string — LangChain agents receive it as a tool result and adjust their reasoning accordingly.

Configuration

FieldTypeRequiredDefaultDescription
apiKeystringYesSigil API key (sk_sigil_...)
apiUrlstringNohttps://sign.sigilcore.comSigil Sign endpoint
agentIdstringNo'agent'Agent identifier
onDeniedfunctionNoCalled when action is denied
onPendingfunctionNoCalled when action is held
onErrorfunctionNoCalled on network error