Docs menuAgent Tool Adapter
Agent Tool Adapter
Use the beta SDK to map LangChain, MCP, or custom agent tool calls into CSIV intent tokens before a tool executes. A full LangChain package can come later; the current stable primitive is createToolCallToken().
How it works
Register the intent names and handlers your runtime is willing to execute.
Bind a tool such as deploy_service to a vocabulary intent such as infra.deploy.
Convert the tool input into token params and validate context and required proof.
Sign or receive an envelope, call verifyAndResolve, then execute only the resolved local handler.
Installation
The adapter primitive is included in the beta TypeScript SDK.
npm install @silentauth/logos-lexicon@beta
1. Compile and Register Vocabulary
The vocabulary defines which actions can ever resolve. Tool wrappers should not invent intent meaning at runtime.
import {
compileLogos,
createToolCallToken,
LogosLexicon
} from "@silentauth/logos-lexicon";
const { vocabulary } = compileLogos(`
vocabulary silentauth.infra.v1
intent CSIV_INFRA_001 infra.deploy {
risk: 4
context: ci_cd
params: service, environment, commit
proofs: maintainer_approval
handler: deployments.release
}
`);
const lexicon = new LogosLexicon();
lexicon.registerVocabulary(vocabulary);2. Map Tool Inputs to Intent Params
The mapping converts a framework-specific tool payload into the parameter names declared in the vocabulary.
const mappings = [{
toolName: "deploy_service",
vocabularyVersion: "silentauth.infra.v1",
intent: "infra.deploy",
context: "ci_cd",
paramMap: {
service: "service",
environment: "environment",
commitSha: "commit"
}
}];3. Guard the Tool Invocation
Call the adapter before the tool runs. In production, the proof list should come from the approval control plane or a local gateway proof result, not from the agent.
async function guardedInvoke(tool, input, satisfiedProofs) {
const mapped = createToolCallToken(
lexicon,
{ name: tool.name, input },
mappings,
{ context: "ci_cd", satisfiedProofs },
crypto.randomUUID()
);
if (!mapped.validation.ok) {
throw new Error(mapped.validation.reason);
}
const signed = await lexicon.sign(mapped.token, {
keyId: "server-key-1",
secret: process.env.LOGOS_HS256_SECRET!,
expiresAt: new Date(Date.now() + 300_000).toISOString()
});
const checked = await lexicon.verifyAndResolve(signed, {
secret: process.env.LOGOS_HS256_SECRET!,
resolution: { context: "ci_cd", satisfiedProofs }
});
if (!checked.ok) {
throw new Error(`Logos denied: ${checked.reason}`);
}
return tool.invoke(input);
}4. Missing Proof Fails Closed
Required proof names are part of the vocabulary. If a deployment requires maintainer approval, a raw tool call cannot bypass it.
const mapped = createToolCallToken(
lexicon,
{
name: "deploy_service",
input: { service: "api", environment: "prod", commitSha: "abc123" }
},
mappings,
{ context: "ci_cd", satisfiedProofs: [] },
"fresh-nonce"
);
// mapped.validation.ok === false
// mapped.validation.reason === "missing_required_proof"
// mapped.validation.missingProofs === ["maintainer_approval"]LangChain Wrapper Shape
For LangChain, start with a thin wrapper around each tool. Later we can publish a first-class package once the core adapter is stable.
const guardedTools = rawTools.map((tool) => ({
...tool,
invoke: async (input) => {
try {
return await guardedInvoke(tool, input, ["maintainer_approval"]);
} catch (error) {
return {
error: "LOGOS_BLOCKED",
reason: error instanceof Error ? error.message : "unknown"
};
}
}
}));Token Selection Guide
CSIV_EXEC_001highSearch, reads, GET calls, database reads
Standard agent execution with approval or proof as configured.
CSIV_EXEC_002criticalFile writes, shell execution, database mutations
Critical execution with stronger proof or dual approval.
CSIV_TXN_002criticalWire transfers, payroll, high-value payments
Value transfer with explicit proof and approval requirements.
CSIV_INFRA_001criticalDeploy, scale, destroy, DNS changes
Infrastructure mutations with maintainer proof or change-window policy.
CSIV_KEY_001criticalKey rotation, certificate issuance, HSM access
Key ceremonies that should usually require quorum.
