open-index/open-npm huggingface dataset:
npm package: @oconnector/adapter-langchain
Description: ABS Core Governance Adapter for LangChain
Author: Engº Rodrigo Gomes
Latest version: 10.1.3

# @abscore/adapter-langchain

The official LangChain/LangGraph adapter for **ABS Governance Layer**.

## Features

- **Self-Healing Tools**: Tools that intercept violations and return conversational instructions back to LangChain (`ABSBlockError`) allowing the AI to organically fix mistakes without breaking the app loop.
- **Offline Engines (PAAT)**: Pass your offline Signed Token (PAAT JWT) & Public Key directly, bringing the WebAssembly rust core inside node.js — ZERO latency for your agent!
- **Compliance Attestation Token (CAT)**: The adapter automatically hashes responses and signs cryptographic Proof of Attestation using `jose`, guaranteeing the Agent execution was safe and bounded by limits.

## Installation

```bash
npm install @abscore/adapter-langchain
```

## Basic Usage

Wrap any `DynamicStructuredTool` or structured invocation with `withAbsGuard`:

```typescript
import { withAbsGuard } from '@abscore/adapter-langchain';
import { DynamicStructuredTool } from "@langchain/core/tools";
import { z } from "zod";

const originalTool = new DynamicStructuredTool({
  name: "transfer_funds",
  description: "Triggers a SEPA wire",
  schema: z.object({ amount: z.number() }),
  func: async ({ amount }) => {
    return `Wired ${amount}`;
  }
});

// Create an ABS Gov governed tool
const governedTool = withAbsGuard(originalTool, {
  paatToken: process.env.PAAT_JWT, // The Offline execution token
  publicKey: process.env.PUBLIC_KEY,
  signingKey: process.env.LOCAL_PRIVATE_KEY, // The signature layer for emitting CATs
  agentId: 'ai-financial-bot'
});
```

*(See Phase 2, 3 and 4 of ABS Core Roadmap for deeper dives into `withAbsGuard` limitations and configurations).*
npm package: @oconnectortechnology/abs-langgraph
Description: ABS CORE Governance Adapter for LangGraph/LangChain
Author: Rodrigo Gomes
Latest version: 1.0.0-rc1

# @oconnectortechnology/abs-langgraph

**ABS CORE Governance Adapter for LangGraph/LangChain**

Wrap your LangGraph tools with enterprise-grade governance in one line of code.

## Installation

```bash
npm install @oconnectortechnology/abs-langgraph
```

## Quick Start

```typescript
import { tool } from "@langchain/core/tools";
import { absGuard } from "@oconnectortechnology/abs-langgraph";
import { z } from "zod";

// 1. Define your dangerous tool
const deleteUser = tool(
  async ({ userId }) => {
    return `User ${userId} deleted from production DB.`;
  },
  {
    name: "delete_user",
    description: "Permanently deletes a user.",
    schema: z.object({ userId: z.string() }),
  }
);

// 2. Wrap with ABS governance
const protectedDelete = absGuard(deleteUser, {
  policy: "gdpr-right-to-erasure",
  riskLevel: "critical"
});

// 3. Use in your LangGraph agent
const tools = [protectedDelete];
```

## Configuration

```typescript
interface ABSConfig {
  policy: string;                    // Required: policy tag
  riskLevel?: "critical" | "high" | "medium" | "low";
  runtimeUrl?: string;               // Default: https://api.abscore.app
  apiKey?: string;                   // Default: process.env.ABS_API_KEY
  agentId?: string;                  // Default: "langgraph-agent"
  shadowMode?: boolean;              // Log without blocking
}
```

## Environment Variables

```bash
ABS_API_KEY=your-api-key
ABS_RUNTIME_URL=https://api.abscore.app  # optional
ABS_AGENT_ID=my-agent                     # optional
```

## Batch Protection

```typescript
import { absGuardAll } from "@oconnectortechnology/abs-langgraph";

const protectedTools = absGuardAll([tool1, tool2, tool3], {
  policy: "financial-strict"
});
```

## Factory Pattern

```typescript
import { createABSGuard } from "@oconnectortechnology/abs-langgraph";

const financialGuard = createABSGuard({
  policy: "financial-strict",
  riskLevel: "critical"
});

const safeTool = financialGuard(dangerousTool);
```

## How It Works

1. **INTERCEPT**: Tool call is captured before execution
2. **VALIDATE**: Request sent to ABS Runtime for policy check
3. **JUDGMENT**: Runtime returns ALLOWED or DENIED with audit proof
4. **EXECUTE**: If allowed, original tool runs. If denied, error is thrown.

## Fail-Close

If ABS Runtime is unreachable, the tool is **blocked by default**.
This ensures no action executes without governance approval.

## Shadow Mode

Enable shadow mode to log violations without blocking:

```typescript
absGuard(tool, {
  policy: "pii-protection",
  shadowMode: true  // Violations logged, not blocked
});
```

## License

Apache-2.0