@peculis/provenance-langgraph
v0.2.0
Published
LangGraph.js capture adapter for Provenance
Readme
@peculis/provenance-langgraph
LangGraph.js / LangChain capture adapter for
@peculis/provenance-sdk.
Pass one callback handler into graph.invoke and model_call / tool_call
events are recorded automatically — declared governance calls
(gate / accessed / humanApproval) inside your nodes resolve the active
session via async context.
Early/WIP (0.x).
Install
pnpm add @peculis/provenance-sdk @peculis/provenance-langgraph @langchain/core@peculis/provenance-sdk and @langchain/core are peer dependencies.
Use
import { init } from "@peculis/provenance-sdk";
import { withSession, currentSession } from "@peculis/provenance-langgraph";
const provenance = init({
projectKey: process.env.PROVENANCE_PROJECT_KEY!,
endpoint: "https://ingest.your-provenance.example",
});
await withSession(provenance, { agentId: "refund-agent" }, async ({ handler }) => {
// pass `handler` as a callback — model_call / tool_call captured automatically
await graph.invoke({ input }, { callbacks: [handler] });
});
// declared calls inside your tools/nodes resolve the active session:
const lookup = tool(async ({ id }) => {
currentSession().accessed("crm.customers", "lookup", { recordCount: 1 });
return fetchCustomer(id);
}, { name: "lookup_customer", schema: z.object({ id: z.number() }) });withSession starts/ends the session (one graph invocation = one session),
records an error_abort on throw, and binds the writer so declared calls and
delegated sub-graphs attach to the right session. A delegated sub-graph calls
withSession again with metadata.parent_session_id to link the child.
See the quickstart.
