Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

langchain-js-basic-agent

Requirement Version
Agent Assembly Node.js SDK (@agent-assembly/sdk) 0.0.1-rc.6

Install:

pnpm add @agent-assembly/sdk@0.0.1-rc.6
# or
npm install @agent-assembly/sdk@0.0.1-rc.6
# or
yarn add @agent-assembly/sdk@0.0.1-rc.6

A LangChain.js-style agent example showing how to integrate the Agent Assembly Node.js SDK for tool governance.

What this example demonstrates

  • Wrapping tools with withAssembly() + a custom GatewayClient that enforces a local policy
  • Governing every tool call through a local policy before execution
  • One allowed tool call (get_weather) — executes and logs output
  • One denied tool call (delete_file) — blocked at the policy layer
  • A denied tool throws PolicyViolationError; runs fully offline (no gateway, no @langchain/core)

Prerequisites

  • Node.js >= 20 LTS
  • pnpm (npm install -g pnpm)

Install

pnpm install

Run

pnpm start

Expected output

=== LangChain.js-style Agent Assembly Example ===

Running allowed tool: get_weather
  [ALLOW] Weather in Taipei: 22°C, partly cloudy. [mock]

Running denied tool: delete_file
  [BLOCKED] Tool 'delete_file' blocked: Destructive filesystem operations require human approval.

Done. Tool calls governed by withAssembly + the local policy.

Test

pnpm test

Tests run in offline mode — no gateway or API keys required.

TypeScript type check

pnpm typecheck

Real-provider mode (optional)

Copy .env.example to .env and fill in your values:

cp .env.example .env
# Edit .env: set AAASM_GATEWAY_URL and optionally OPENAI_API_KEY

Then pnpm start will connect to the real gateway and real OpenAI API if configured.

Troubleshooting

Problem Solution
Cannot find module '@agent-assembly/sdk' Run pnpm install
Gateway connection refused Omit AAASM_GATEWAY_URL to use offline mode
TypeScript errors Run pnpm typecheck and check Node.js version

Links