Integrations
LangChain
Add Treeship to LangChain agents. Receipts for every chain and tool call.
Two approaches
If your LangChain agent is in TypeScript:
import { ship } from '@treeship/sdk'
const s = ship()
// Before the chain runs
const { artifactId: intentId } = await s.attest.action({
actor: 'agent://langchain',
action: 'chain.invoke',
meta: { chain: 'research-chain', input_digest: sha256(input) },
})
// Run the chain
const result = await chain.invoke(input)
// After the chain completes
await s.attest.action({
actor: 'agent://langchain',
action: 'chain.result',
parentId: intentId,
meta: { output_digest: sha256(JSON.stringify(result)) },
})Wrap the agent script itself:
treeship wrap --actor agent://langchain -- python agent.pyOr from within Python, call treeship via subprocess:
import subprocess, json
def attest(action, meta=None):
args = ["treeship", "attest", "action",
"--actor", "agent://langchain",
"--action", action,
"--format", "json"]
if meta:
args += ["--meta", json.dumps(meta)]
result = subprocess.run(args, capture_output=True, text=True)
return json.loads(result.stdout) if result.returncode == 0 else None
# Use it
attest("chain.invoke", {"chain": "research", "query": "AI safety"})The CLI approach works with any language. The SDK approach gives you tighter integration but requires the treeship binary in PATH.