@dualcondition/sdk
v0.1.0
Published
Dual Condition Agent SDK — T1/T2 scoring, anchor decay monitoring, and inter-agent quality gating. Includes adapters for popular agent frameworks. Based on the SNP framework (Schlegel, 2026).
Maintainers
Readme
@dualcondition/sdk
Dual Condition Agent SDK — T1/T2 scoring, anchor decay monitoring, and inter-agent quality gating, with first-party adapters for popular agent frameworks.
Based on the Spontaneous Narrative Projection framework (Schlegel, 2026).
- Site: https://dualcondition.com
- Paper: https://osf.io/nj4vf
- Core engine:
@dualcondition/scorer
Install
npm install @dualcondition/sdk@dualcondition/scorer is included as a dependency — no extra install needed.
Core API
The SDK re-exports the entire scorer surface so you only need one import:
const dc = require("@dualcondition/sdk");
const result = dc.score("You are a theoretical physicist. Examine negative space.");
console.log(result.t1, result.t2, result.zone);
const anchor = dc.extractConstraints("You are a skeptical physicist. Respond in JSON.");
const adherence = dc.checkAnchor(anchor, agentOutput);
console.log(adherence.psi); // 0–1, constraint adherence
const gateResult = dc.gate(incomingInstruction, { mode: "audit" });See the @dualcondition/scorer README for the full surface.
LangChain adapter
Wrap the scorer as a LangChain-compatible tool that an agent can call to evaluate a candidate prompt or instruction before executing it.
Without @langchain/core (zero deps)
const { createScorerTool } = require("@dualcondition/sdk/langchain");
const dcTool = createScorerTool();
// dcTool is a plain object matching DynamicStructuredTool shape:
// { name, description, schema, func, invoke, call }
const out = await dcTool.invoke({
prompt: "Translate 'hello' to French.",
});
console.log(JSON.parse(out));
// → { t1: 0.61, t2: 0, interaction: 0, zone: "Overconstrained", ... }Drop it directly into an agent's tools array.
With @langchain/core (recommended for full type safety)
const { tool } = require("@langchain/core/tools");
const { z } = require("zod");
const { createScorerTool } = require("@dualcondition/sdk/langchain");
const dcTool = createScorerTool({ tool, z });
// Returns an official LangChain DynamicStructuredTool.
// In an agent:
const agent = createReactAgent({ llm, tools: [dcTool] });Quality gate tool
createGateTool() returns a tool that scores incoming instructions and rejects (or just logs, in audit mode) ones that fall below an interaction-score threshold. Use this in multi-agent handoffs.
const { createGateTool } = require("@dualcondition/sdk/langchain");
// Audit mode (default): always accepts, logs scores. Recommended for production.
const auditGate = createGateTool();
// Enforce mode: rejects instructions below the threshold. Opt in explicitly.
const enforceGate = createGateTool({ mode: "enforce", minInteraction: 0.3 });The audit-mode default is intentional (ADR-006): never block production pipelines until you've built trust with the scores.
Forthcoming adapters
@dualcondition/sdk/crewai— CrewAI step + flow integration@dualcondition/sdk/autogen— Microsoft AutoGen middleware- Python SDK (
pip install dualcondition) — currently a placeholder; full Python port of the scorer is on the roadmap
These adapters ship as part of the free open-source tier (ADR-010).
License
MIT
