Logos LexiconIntegrationsAgent Tool Adapter
Adapter primitive

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

1
Compile vocabulary

Register the intent names and handlers your runtime is willing to execute.

2
Map tool name

Bind a tool such as deploy_service to a vocabulary intent such as infra.deploy.

3
Create token

Convert the tool input into token params and validate context and required proof.

4
Verify before dispatch

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.

bash
npm install @silentauth/logos-lexicon@beta
Treat this as a beta SDK. Keep framework-specific wrappers thin until the vocabulary and signing model are frozen.

1. Compile and Register Vocabulary

The vocabulary defines which actions can ever resolve. Tool wrappers should not invent intent meaning at runtime.

typescript
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.

typescript
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.

typescript
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.

typescript
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.

typescript
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_001high

Search, reads, GET calls, database reads

Standard agent execution with approval or proof as configured.

CSIV_EXEC_002critical

File writes, shell execution, database mutations

Critical execution with stronger proof or dual approval.

CSIV_TXN_002critical

Wire transfers, payroll, high-value payments

Value transfer with explicit proof and approval requirements.

CSIV_INFRA_001critical

Deploy, scale, destroy, DNS changes

Infrastructure mutations with maintainer proof or change-window policy.

CSIV_KEY_001critical

Key rotation, certificate issuance, HSM access

Key ceremonies that should usually require quorum.