diff --git a/typescript/agentkit/src/action-providers/index.ts b/typescript/agentkit/src/action-providers/index.ts index e95ce5e5b..0002397de 100644 --- a/typescript/agentkit/src/action-providers/index.ts +++ b/typescript/agentkit/src/action-providers/index.ts @@ -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"; diff --git a/typescript/agentkit/src/action-providers/thoughtproof/constants.ts b/typescript/agentkit/src/action-providers/thoughtproof/constants.ts new file mode 100644 index 000000000..a3161b78d --- /dev/null +++ b/typescript/agentkit/src/action-providers/thoughtproof/constants.ts @@ -0,0 +1 @@ +export const THOUGHTPROOF_API_BASE_URL = "https://api.thoughtproof.ai"; diff --git a/typescript/agentkit/src/action-providers/thoughtproof/index.ts b/typescript/agentkit/src/action-providers/thoughtproof/index.ts new file mode 100644 index 000000000..4afe7b9fc --- /dev/null +++ b/typescript/agentkit/src/action-providers/thoughtproof/index.ts @@ -0,0 +1,2 @@ +export { ThoughtProofActionProvider, thoughtproofActionProvider } from "./thoughtproofActionProvider"; +export { VerifyReasoningSchema } from "./schemas"; diff --git a/typescript/agentkit/src/action-providers/thoughtproof/schemas.ts b/typescript/agentkit/src/action-providers/thoughtproof/schemas.ts new file mode 100644 index 000000000..23caa6c38 --- /dev/null +++ b/typescript/agentkit/src/action-providers/thoughtproof/schemas.ts @@ -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"); diff --git a/typescript/agentkit/src/action-providers/thoughtproof/thoughtproofActionProvider.ts b/typescript/agentkit/src/action-providers/thoughtproof/thoughtproofActionProvider.ts new file mode 100644 index 000000000..66e076c83 --- /dev/null +++ b/typescript/agentkit/src/action-providers/thoughtproof/thoughtproofActionProvider.ts @@ -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, BLOCK, or UNCERTAIN 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/BLOCK/UNCERTAIN), confidence, and objections + */ + @CreateAction({ + name: "verify_reasoning", + description: + "Verify a claim or decision using adversarial multi-model reasoning before executing. " + + "Returns ALLOW, BLOCK, or UNCERTAIN with confidence score and key objections. " + + "Use before irreversible actions, large transactions, or high-stakes decisions.", + schema: VerifyReasoningSchema, + }) + async verifyReasoning(args: z.infer): Promise { + 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 if (verdict === "BLOCK") { + return ( + `🚫 ThoughtProof: BLOCK — do not proceed.\n` + + `Confidence: ${confidence}%\n` + + `Objections:\n${objections.map((o: string) => `- ${o}`).join("\n")}` + ); + } + } catch (error) { + return `🚫 ThoughtProof: BLOCK — verification service unavailable (${error}). Do not proceed until reasoning can be verified.`; + } + } + + supportsNetwork = () => true; +} + +export const thoughtproofActionProvider = () => new ThoughtProofActionProvider();