Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions typescript/agentkit/src/action-providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export * from "./opensea";
export * from "./spl";
export * from "./superfluid";
export * from "./sushi";
export * from "./thoughtproof";
export * from "./truemarkets";
export * from "./twitter";
export * from "./wallet";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const THOUGHTPROOF_API_BASE_URL = "https://api.thoughtproof.ai";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { ThoughtProofActionProvider, thoughtproofActionProvider } from "./thoughtproofActionProvider";
export { VerifyReasoningSchema } from "./schemas";
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { z } from "zod";

export const VerifyReasoningSchema = z
.object({
claim: z
.string()
.describe("The claim, decision, or action to verify (e.g. 'Swap 100 USDC for TOKEN_X at market price')"),
stakeLevel: z
.enum(["low", "medium", "high", "critical"])
.describe("The stakes of the decision. Use 'high' or 'critical' for transactions above $1000 or irreversible actions."),
domain: z
.enum(["financial", "security", "legal", "medical", "general"])
.optional()
.describe("The domain of the claim. Defaults to 'financial' for DeFi actions."),
})
.strip()
.describe("Input schema for verifying a reasoning claim before executing an action");
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { z } from "zod";
import { ActionProvider } from "../actionProvider";
import { CreateAction } from "../actionDecorator";
import { VerifyReasoningSchema } from "./schemas";
import { THOUGHTPROOF_API_BASE_URL } from "./constants";

/**
* ThoughtProofActionProvider is an action provider for reasoning verification.
* Runs adversarial multi-model critique (Claude + Grok + DeepSeek) on any claim
* before the agent executes it. Returns ALLOW or HOLD with a signed attestation.
*
* Uses x402 micropayments on Base (USDC). No API key required.
* Docs: https://thoughtproof.ai/skill.md
*/
export class ThoughtProofActionProvider extends ActionProvider {
constructor() {
super("thoughtproof", []);
}

/**
* Verifies a claim or decision using adversarial multi-model reasoning.
* Call this before executing high-stakes or irreversible actions.
*
* @param args - The verification parameters (claim, stakeLevel, domain)
* @returns Verification result with verdict (ALLOW/HOLD), confidence, and objections
*/
@CreateAction({
name: "verify_reasoning",
description:
"Verify a claim or decision using adversarial multi-model reasoning before executing. " +
"Returns ALLOW or HOLD with confidence score and key objections. " +
"Use before irreversible actions, large transactions, or high-stakes decisions.",
schema: VerifyReasoningSchema,
})
async verifyReasoning(args: z.infer<typeof VerifyReasoningSchema>): Promise<string> {
try {
const response = await fetch(`${THOUGHTPROOF_API_BASE_URL}/v1/check`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
claim: args.claim,
stakeLevel: args.stakeLevel ?? "medium",
domain: args.domain ?? "financial",
}),
});

if (!response.ok) {
return `ThoughtProof verification failed: HTTP ${response.status}. Proceed with caution.`;
}

const data = await response.json();
const verdict = data.verdict ?? "UNCERTAIN";
const confidence = data.confidence ?? 0;
const objections = data.objections ?? [];

if (verdict === "ALLOW") {
return (
`✅ ThoughtProof: ALLOW (confidence: ${confidence}%)\n` +
(objections.length > 0 ? `Minor concerns: ${objections.join("; ")}` : "No objections raised.")
);
} else {
return (
`🚫 ThoughtProof: HOLD — do not proceed.\n` +
`Confidence: ${confidence}%\n` +
`Objections:\n${objections.map((o: string) => `- ${o}`).join("\n")}`
);
}
} catch (error) {
return `🚫 ThoughtProof: HOLD — verification service unavailable (${error}). Do not proceed until reasoning can be verified.`;
}
}

supportsNetwork = () => true;
}

export const thoughtproofActionProvider = () => new ThoughtProofActionProvider();
Loading