{"_id":"@arcproof/sdk-langchain","name":"@arcproof/sdk-langchain","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@arcproof/sdk-langchain","version":"0.1.0","description":"LangChain.js adapter for @arcproof/sdk -- turn any LangChain.js tool-calling agent into a claim-gathering step for the ArcProof trust layer.","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"publishConfig":{"access":"public"},"scripts":{"build":"tsc","typecheck":"tsc --noEmit"},"keywords":["arcproof","langchain","ai-agents","verification"],"license":"MIT","peerDependencies":{"@arcproof/sdk":"^0.1.0","@langchain/core":"^0.3.30","@langchain/langgraph":"^0.2.41"},"dependencies":{"zod":"^3.24.1"},"devDependencies":{"@arcproof/sdk":"*","@langchain/core":"^0.3.30","@langchain/langgraph":"^0.2.41","typescript":"^5.7.3","@types/node":"^22.10.5"},"gitHead":"edd9dd7e3cdb6e1b91e93b80e7ce53f46553b640","_id":"@arcproof/sdk-langchain@0.1.0","_nodeVersion":"24.12.0","_npmVersion":"11.18.0","dist":{"integrity":"sha512-XdGSa/g+rd/mCml8JJNX10d9lH6fkhUqhd46o9wVP4cOTU3/ScvG4gRhWeFe3ArHZg8OOEonBgXpSf8XzulRJw==","shasum":"fccf9392f489d7c5936b9cd528bd82b10f431ffc","tarball":"https://registry.npmjs.org/@arcproof/sdk-langchain/-/sdk-langchain-0.1.0.tgz","fileCount":8,"unpackedSize":22796,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIE3vb3J7fvLr02fp80zHonv6fGcCgrAcn3KeO43BLAsdAiEA8Qk7F6NUdAniD1qOxTnoU3QhSbuSPKQ4LynFLy2QOPI="}]},"_npmUser":{"name":"yuvan05","email":"yuvan.r2005@gmail.com"},"directories":{},"maintainers":[{"name":"yuvan05","email":"yuvan.r2005@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk-langchain_0.1.0_1783185130074_0.33066462484769454"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-04T17:12:09.844Z","0.1.0":"2026-07-04T17:12:10.205Z","modified":"2026-07-04T17:12:10.410Z"},"maintainers":[{"name":"yuvan05","email":"yuvan.r2005@gmail.com"}],"description":"LangChain.js adapter for @arcproof/sdk -- turn any LangChain.js tool-calling agent into a claim-gathering step for the ArcProof trust layer.","keywords":["arcproof","langchain","ai-agents","verification"],"license":"MIT","readme":"# @arcproof/sdk-langchain\n\nLangChain.js adapter for [`@arcproof/sdk`](../sdk): turn any LangChain.js tool-calling agent into a `gatherClaims()` function usable by `runTrustedJob()`.\n\n## Install\n\n```bash\nnpm install @arcproof/sdk @arcproof/sdk-langchain @langchain/core @langchain/langgraph\n```\n\n## Usage\n\n```ts\nimport { createLangChainClaimGatherer, combineClaimGatherers } from \"@arcproof/sdk-langchain\";\nimport { runTrustedJob, VerifierRegistry, ARC_TESTNET } from \"@arcproof/sdk\";\nimport { ChatGroq } from \"@langchain/groq\";\nimport { tool } from \"@langchain/core/tools\";\nimport { z } from \"zod\";\n\nconst lookupTool = tool(\n  async ({ id }: { id: string }) => JSON.stringify(await lookUpSomething(id)),\n  { name: \"lookup\", description: \"...\", schema: z.object({ id: z.string() }) }\n);\n\nconst gatherClaims = createLangChainClaimGatherer({\n  agentId: \"my-agent-v1\",\n  model: new ChatGroq({ model: \"llama-3.3-70b-versatile\", apiKey: process.env.GROQ_API_KEY }),\n  tools: [lookupTool],\n  claimTypes: [\"some_claim_type\"], // optional -- omit for an open string\n  systemPrompt: \"You are a ... specialist. Use your tools to gather claims, copy values verbatim.\",\n});\n\nconst result = await runTrustedJob(\n  { network: ARC_TESTNET, contractAddress, verifiers: new VerifierRegistry() /* .register(...) your rules */ },\n  {\n    jobId: \"job-1\",\n    budgetAmount: 0.05,\n    requester, settler, // WalletCredential\n    providerAddresses: { \"my-agent-v1\": \"0x...\" },\n    gatherClaims,\n    context: { id: \"loan-001\" },\n  }\n);\n```\n\nMultiple specialists, always engaged: `combineClaimGatherers([aprAgent, feeAgent, complianceAgent])`.\n\nMultiple specialists, an LLM decides which ones this specific request needs (the orchestrator layer -- matches the reference apps' `orchestrator.ts`/`langchainPlanner.ts` pattern, generalized):\n\n```ts\nimport { createLangChainOrchestrator, type SpecialistDescriptor } from \"@arcproof/sdk-langchain\";\n\nconst specialists: SpecialistDescriptor[] = [\n  { id: \"apr-agent-v1\", description: \"Checks true APR and fees -- engage for any cost question.\", gatherClaims: aprGatherer },\n  { id: \"eligibility-agent-v1\", description: \"Checks borrower region eligibility -- engage for any eligibility question.\", gatherClaims: eligibilityGatherer },\n];\n\nconst gatherClaims = createLangChainOrchestrator({ model, specialists });\n// A pure \"what's the APR\" request engages only apr-agent-v1.\n// A request that also asks about eligibility engages both.\n```\n\nThis is the full three-layer pattern, each with a clean separation of concerns:\n\n```text\norchestrator (createLangChainOrchestrator)  -- decides which specialists this request needs\nspecialist   (createLangChainClaimGatherer) -- checks and drafts claims\nevaluator    (@arcproof/sdk's VerifierRegistry) -- independently verifies, zero LLM calls\n```\n\nIf the planning call itself fails outright (not \"returned zero valid ids,\" which defaults to engaging every specialist -- an actual throw), it propagates up to `runTrustedJob`'s existing refund path rather than silently falling back -- same \"agent or loud failure\" rule as everywhere else in this SDK.\n\n## Why `claim_value`/`simulated` are plain strings in the structured-output schema\n\nTwo real, independently-observed provider incompatibilities, not a stylistic choice:\n\n- Gemini's function-calling schema translator rejects JSON Schema `anyOf` unions nested inside array-of-object properties, at any branch count -- including the 2-branch `[string, null]` shape `.nullable()` produces.\n- Groq has been observed returning the JSON string `\"false\"` for a `z.boolean()` field (`\"expected boolean, but got string\"`).\n\nA plain string field with an explicit `\"true\"`/`\"false\"` convention, coerced back to a real boolean in JS, sidesteps both without depending on either provider fixing their schema translation. If you add new structured-output fields to a similar schema, keep this in mind.\n\n## Resilience\n\nIf the underlying LLM call fails (quota, outage, malformed generation), `createLangChainClaimGatherer` logs and returns zero claims rather than throwing. `runTrustedJob`'s built-in `hasCheckableClaims` guard already handles \"this provider contributed nothing\" correctly (refund, not a false accept) -- a single flaky provider never has to crash the whole job.\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-d2e712e315a5f122bc5b76044df88969"}