RUNNABLE TYPESCRIPT INTEGRATION

Jev × LangChain

Wrap Jev as a real LangChain tool. Return a policy-checked routing decision to your host application.

LangChain .invoke()Jev closed-set choicePolicy gateTyped result

Invoke the routing tool

@langchain/core

Both buttons invoke a real LangChain structured tool on the server. Live mode uses Jev; mock mode substitutes seeded predictions. Neither executes a downstream action.

What this integration guarantees
  • Zod validates the request and the two supported routing points.
  • Blocked requests stop before Jev; forbidden nodes never enter the candidate set.
  • Both scores must reach 85%. Low confidence asks for clarification.
  • Configuration changes return an approval requirement, not permission to execute.

Tool response

A tool result your application can use

Inspect the selected node, policy override and confidence as structured data. The host retains control of execution.

Use it in your TypeScript app

Local integration example · not a published LangChain plugin package

import { createJevRoutingTool } from "./lib/langchain/jev-tool";
import { serverJevTransport } from "./lib/serverJev";

const jevRouter = createJevRoutingTool({
  transport: serverJevTransport,
});

const decision = await jevRouter.invoke({
  request: "Check the current rate limit settings",
  current_node: "ops_agent",
});

// Route only after your host enforces policy and approval.
// decision.executed is always false.
console.log(decision);

Try locally: npm run example:langchain runs the actual tool through a RunnableLambda chain with mock predictions.

Use live Jev: set TYPESAFE_API_KEY in your server environment or .env.local, then run npm run example:langchain -- --live.

The factory is in lib/langchain/jev-tool.ts. Pass it as a tool to your LangChain host or call .invoke() directly. No OpenAI or LangSmith key is required for this example.