kompass-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a2a/agent-card.d.ts +13 -0
- package/dist/a2a/agent-card.d.ts.map +1 -0
- package/dist/a2a/agent-card.js +52 -0
- package/dist/a2a/agent-card.js.map +1 -0
- package/dist/a2a/bridge.d.ts +52 -0
- package/dist/a2a/bridge.d.ts.map +1 -0
- package/dist/a2a/bridge.js +123 -0
- package/dist/a2a/bridge.js.map +1 -0
- package/dist/a2a/client.d.ts +34 -0
- package/dist/a2a/client.d.ts.map +1 -0
- package/dist/a2a/client.js +65 -0
- package/dist/a2a/client.js.map +1 -0
- package/dist/a2a/server.d.ts +17 -0
- package/dist/a2a/server.d.ts.map +1 -0
- package/dist/a2a/server.js +194 -0
- package/dist/a2a/server.js.map +1 -0
- package/dist/abi.d.ts +1068 -0
- package/dist/abi.d.ts.map +1 -0
- package/dist/abi.js +1372 -0
- package/dist/abi.js.map +1 -0
- package/dist/adapters/agentkit.d.ts +41 -0
- package/dist/adapters/agentkit.d.ts.map +1 -0
- package/dist/adapters/agentkit.js +67 -0
- package/dist/adapters/agentkit.js.map +1 -0
- package/dist/adapters/generic.d.ts +35 -0
- package/dist/adapters/generic.d.ts.map +1 -0
- package/dist/adapters/generic.js +47 -0
- package/dist/adapters/generic.js.map +1 -0
- package/dist/adapters/index.d.ts +5 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +5 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/langchain.d.ts +26 -0
- package/dist/adapters/langchain.d.ts.map +1 -0
- package/dist/adapters/langchain.js +228 -0
- package/dist/adapters/langchain.js.map +1 -0
- package/dist/adapters/openclaw.d.ts +18 -0
- package/dist/adapters/openclaw.d.ts.map +1 -0
- package/dist/adapters/openclaw.js +168 -0
- package/dist/adapters/openclaw.js.map +1 -0
- package/dist/aggregator.d.ts +36 -0
- package/dist/aggregator.d.ts.map +1 -0
- package/dist/aggregator.js +168 -0
- package/dist/aggregator.js.map +1 -0
- package/dist/backends/acp.d.ts +29 -0
- package/dist/backends/acp.d.ts.map +1 -0
- package/dist/backends/acp.js +126 -0
- package/dist/backends/acp.js.map +1 -0
- package/dist/backends/types.d.ts +59 -0
- package/dist/backends/types.d.ts.map +1 -0
- package/dist/backends/types.js +2 -0
- package/dist/backends/types.js.map +1 -0
- package/dist/bridge.d.ts +35 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +192 -0
- package/dist/bridge.js.map +1 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +331 -0
- package/dist/cli.js.map +1 -0
- package/dist/discover.d.ts +15 -0
- package/dist/discover.d.ts.map +1 -0
- package/dist/discover.js +163 -0
- package/dist/discover.js.map +1 -0
- package/dist/escrow.d.ts +45 -0
- package/dist/escrow.d.ts.map +1 -0
- package/dist/escrow.js +243 -0
- package/dist/escrow.js.map +1 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +145 -0
- package/dist/index.js.map +1 -0
- package/dist/intents.d.ts +28 -0
- package/dist/intents.d.ts.map +1 -0
- package/dist/intents.js +111 -0
- package/dist/intents.js.map +1 -0
- package/dist/matching.d.ts +29 -0
- package/dist/matching.d.ts.map +1 -0
- package/dist/matching.js +147 -0
- package/dist/matching.js.map +1 -0
- package/dist/pipelineAbi.d.ts +113 -0
- package/dist/pipelineAbi.d.ts.map +1 -0
- package/dist/pipelineAbi.js +74 -0
- package/dist/pipelineAbi.js.map +1 -0
- package/dist/pipelines.d.ts +42 -0
- package/dist/pipelines.d.ts.map +1 -0
- package/dist/pipelines.js +185 -0
- package/dist/pipelines.js.map +1 -0
- package/dist/registry.d.ts +36 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +187 -0
- package/dist/registry.js.map +1 -0
- package/dist/reputation.d.ts +10 -0
- package/dist/reputation.d.ts.map +1 -0
- package/dist/reputation.js +33 -0
- package/dist/reputation.js.map +1 -0
- package/dist/router.d.ts +72 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +190 -0
- package/dist/router.js.map +1 -0
- package/dist/simple.d.ts +160 -0
- package/dist/simple.d.ts.map +1 -0
- package/dist/simple.js +237 -0
- package/dist/simple.js.map +1 -0
- package/dist/sources/a2a-wellknown.d.ts +8 -0
- package/dist/sources/a2a-wellknown.d.ts.map +1 -0
- package/dist/sources/a2a-wellknown.js +104 -0
- package/dist/sources/a2a-wellknown.js.map +1 -0
- package/dist/sources/acp.d.ts +7 -0
- package/dist/sources/acp.d.ts.map +1 -0
- package/dist/sources/acp.js +86 -0
- package/dist/sources/acp.js.map +1 -0
- package/dist/sources/adp.d.ts +7 -0
- package/dist/sources/adp.d.ts.map +1 -0
- package/dist/sources/adp.js +59 -0
- package/dist/sources/adp.js.map +1 -0
- package/dist/sources/erc8004.d.ts +7 -0
- package/dist/sources/erc8004.d.ts.map +1 -0
- package/dist/sources/erc8004.js +150 -0
- package/dist/sources/erc8004.js.map +1 -0
- package/dist/sources/index.d.ts +17 -0
- package/dist/sources/index.d.ts.map +1 -0
- package/dist/sources/index.js +35 -0
- package/dist/sources/index.js.map +1 -0
- package/dist/sources/kompass-registry.d.ts +8 -0
- package/dist/sources/kompass-registry.d.ts.map +1 -0
- package/dist/sources/kompass-registry.js +62 -0
- package/dist/sources/kompass-registry.js.map +1 -0
- package/dist/sources/l402-directory.d.ts +7 -0
- package/dist/sources/l402-directory.d.ts.map +1 -0
- package/dist/sources/l402-directory.js +42 -0
- package/dist/sources/l402-directory.js.map +1 -0
- package/dist/sources/mcp-registry.d.ts +8 -0
- package/dist/sources/mcp-registry.d.ts.map +1 -0
- package/dist/sources/mcp-registry.js +85 -0
- package/dist/sources/mcp-registry.js.map +1 -0
- package/dist/sources/skills.d.ts +8 -0
- package/dist/sources/skills.d.ts.map +1 -0
- package/dist/sources/skills.js +153 -0
- package/dist/sources/skills.js.map +1 -0
- package/dist/sources/types.d.ts +72 -0
- package/dist/sources/types.d.ts.map +1 -0
- package/dist/sources/types.js +8 -0
- package/dist/sources/types.js.map +1 -0
- package/dist/sources/x402-ecosystem.d.ts +7 -0
- package/dist/sources/x402-ecosystem.d.ts.map +1 -0
- package/dist/sources/x402-ecosystem.js +78 -0
- package/dist/sources/x402-ecosystem.js.map +1 -0
- package/dist/types.d.ts +133 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/unified.d.ts +90 -0
- package/dist/unified.d.ts.map +1 -0
- package/dist/unified.js +107 -0
- package/dist/unified.js.map +1 -0
- package/dist/x402.d.ts +30 -0
- package/dist/x402.d.ts.map +1 -0
- package/dist/x402.js +79 -0
- package/dist/x402.js.map +1 -0
- package/package.json +61 -0
- package/scripts/bootstrap-agents.mjs +246 -0
- package/src/.gitkeep +0 -0
- package/src/a2a/agent-card.ts +66 -0
- package/src/a2a/bridge.ts +168 -0
- package/src/a2a/client.ts +92 -0
- package/src/a2a/server.ts +234 -0
- package/src/abi.ts +1373 -0
- package/src/adapters/agentkit.ts +83 -0
- package/src/adapters/generic.ts +62 -0
- package/src/adapters/index.ts +4 -0
- package/src/adapters/langchain.ts +282 -0
- package/src/adapters/openclaw.ts +203 -0
- package/src/aggregator.ts +203 -0
- package/src/backends/acp.ts +199 -0
- package/src/backends/types.ts +78 -0
- package/src/bridge.ts +263 -0
- package/src/cli.ts +397 -0
- package/src/discover.ts +187 -0
- package/src/escrow.ts +284 -0
- package/src/index.ts +245 -0
- package/src/intents.ts +166 -0
- package/src/matching.ts +192 -0
- package/src/pipelineAbi.ts +74 -0
- package/src/pipelines.ts +253 -0
- package/src/registry.ts +232 -0
- package/src/reputation.ts +43 -0
- package/src/router.ts +279 -0
- package/src/simple.ts +366 -0
- package/src/sources/a2a-wellknown.ts +120 -0
- package/src/sources/acp.ts +91 -0
- package/src/sources/adp.ts +64 -0
- package/src/sources/erc8004.ts +166 -0
- package/src/sources/index.ts +52 -0
- package/src/sources/kompass-registry.ts +67 -0
- package/src/sources/l402-directory.ts +51 -0
- package/src/sources/mcp-registry.ts +104 -0
- package/src/sources/skills.ts +161 -0
- package/src/sources/types.ts +82 -0
- package/src/sources/x402-ecosystem.ts +86 -0
- package/src/types.ts +147 -0
- package/src/unified.ts +155 -0
- package/src/x402.ts +122 -0
- package/tests/pipelineFlow.test.ts +239 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createPublicClient, createWalletClient, custom, http, type Address } from "viem";
|
|
2
|
+
import { baseSepolia } from "viem/chains";
|
|
3
|
+
import { Kompass, type KompassConfig } from "../index.js";
|
|
4
|
+
|
|
5
|
+
export interface AgentKitAdapterOptions {
|
|
6
|
+
/** CDP AgentKit instance (any version — we only need .wallet) */
|
|
7
|
+
agentKit: { wallet: { address: Address; sendTransaction: (...args: unknown[]) => Promise<unknown> } };
|
|
8
|
+
rpcUrl?: string;
|
|
9
|
+
escrowAddress: Address;
|
|
10
|
+
registryAddress: Address;
|
|
11
|
+
reputationRegistryAddress: Address;
|
|
12
|
+
indexerUrl: string;
|
|
13
|
+
pipelineAddress?: Address;
|
|
14
|
+
paymentTokenAddress?: Address;
|
|
15
|
+
defaultHookAddress?: Address;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a Kompass instance from a Coinbase AgentKit wallet.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { AgentKit } from "@coinbase/agentkit";
|
|
24
|
+
* import { fromAgentKit } from "@kompass/sdk/adapters/agentkit";
|
|
25
|
+
*
|
|
26
|
+
* const agentKit = await AgentKit.from({ wallet: "..." });
|
|
27
|
+
* const kompass = fromAgentKit({
|
|
28
|
+
* agentKit,
|
|
29
|
+
* escrowAddress: "0x...",
|
|
30
|
+
* registryAddress: "0x...",
|
|
31
|
+
* reputationRegistryAddress: "0x...",
|
|
32
|
+
* indexerUrl: "http://localhost:42069/graphql",
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* const agents = await kompass.discover({ category: "defi" });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function fromAgentKit(options: AgentKitAdapterOptions): Kompass {
|
|
39
|
+
const rpcUrl = options.rpcUrl ?? "https://sepolia.base.org";
|
|
40
|
+
const wallet = options.agentKit.wallet;
|
|
41
|
+
|
|
42
|
+
const publicClient = createPublicClient({
|
|
43
|
+
chain: baseSepolia,
|
|
44
|
+
transport: http(rpcUrl),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// AgentKit wallets expose address and sendTransaction — we create a
|
|
48
|
+
// minimal viem-compatible WalletClient using the custom transport pattern.
|
|
49
|
+
// For the hackathon demo, we pass the AgentKit wallet's address as a
|
|
50
|
+
// local account and rely on the AgentKit wallet for signing.
|
|
51
|
+
// In production, use @coinbase/agentkit's viem adapter.
|
|
52
|
+
const walletClient = createWalletClient({
|
|
53
|
+
account: wallet.address,
|
|
54
|
+
chain: baseSepolia,
|
|
55
|
+
transport: custom({
|
|
56
|
+
async request({ method, params }: { method: string; params: unknown[] }) {
|
|
57
|
+
if (method === "eth_sendTransaction") {
|
|
58
|
+
return wallet.sendTransaction(params[0]);
|
|
59
|
+
}
|
|
60
|
+
// Fall back to RPC for read methods
|
|
61
|
+
const response = await fetch(rpcUrl, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers: { "Content-Type": "application/json" },
|
|
64
|
+
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
|
|
65
|
+
});
|
|
66
|
+
const result = await response.json() as { result: unknown };
|
|
67
|
+
return result.result;
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return new Kompass({
|
|
73
|
+
publicClient,
|
|
74
|
+
walletClient,
|
|
75
|
+
escrowAddress: options.escrowAddress,
|
|
76
|
+
registryAddress: options.registryAddress,
|
|
77
|
+
reputationRegistryAddress: options.reputationRegistryAddress,
|
|
78
|
+
pipelineAddress: options.pipelineAddress,
|
|
79
|
+
paymentTokenAddress: options.paymentTokenAddress,
|
|
80
|
+
defaultHookAddress: options.defaultHookAddress,
|
|
81
|
+
indexerUrl: options.indexerUrl,
|
|
82
|
+
} as KompassConfig);
|
|
83
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createPublicClient, createWalletClient, http, type Address, type Account } from "viem";
|
|
2
|
+
import { baseSepolia } from "viem/chains";
|
|
3
|
+
import { Kompass, type KompassConfig } from "../index.js";
|
|
4
|
+
|
|
5
|
+
export interface GenericAdapterOptions {
|
|
6
|
+
account: Account;
|
|
7
|
+
rpcUrl?: string;
|
|
8
|
+
escrowAddress: Address;
|
|
9
|
+
registryAddress: Address;
|
|
10
|
+
reputationRegistryAddress: Address;
|
|
11
|
+
indexerUrl: string;
|
|
12
|
+
pipelineAddress?: Address;
|
|
13
|
+
paymentTokenAddress?: Address;
|
|
14
|
+
defaultHookAddress?: Address;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Create a Kompass instance from any viem-compatible account.
|
|
19
|
+
* This is the simplest integration path — 3 lines for any agent framework.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { privateKeyToAccount } from "viem/accounts";
|
|
24
|
+
* import { createKompass } from "@kompass/sdk/adapters/generic";
|
|
25
|
+
*
|
|
26
|
+
* const kompass = createKompass({
|
|
27
|
+
* account: privateKeyToAccount("0x..."),
|
|
28
|
+
* escrowAddress: "0x...",
|
|
29
|
+
* registryAddress: "0x...",
|
|
30
|
+
* reputationRegistryAddress: "0x...",
|
|
31
|
+
* indexerUrl: "http://localhost:42069/graphql",
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* const agents = await kompass.discover({ category: "defi" });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function createKompass(options: GenericAdapterOptions): Kompass {
|
|
38
|
+
const rpcUrl = options.rpcUrl ?? "https://sepolia.base.org";
|
|
39
|
+
|
|
40
|
+
const publicClient = createPublicClient({
|
|
41
|
+
chain: baseSepolia,
|
|
42
|
+
transport: http(rpcUrl),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const walletClient = createWalletClient({
|
|
46
|
+
account: options.account,
|
|
47
|
+
chain: baseSepolia,
|
|
48
|
+
transport: http(rpcUrl),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return new Kompass({
|
|
52
|
+
publicClient,
|
|
53
|
+
walletClient,
|
|
54
|
+
escrowAddress: options.escrowAddress,
|
|
55
|
+
registryAddress: options.registryAddress,
|
|
56
|
+
reputationRegistryAddress: options.reputationRegistryAddress,
|
|
57
|
+
pipelineAddress: options.pipelineAddress,
|
|
58
|
+
paymentTokenAddress: options.paymentTokenAddress,
|
|
59
|
+
defaultHookAddress: options.defaultHookAddress,
|
|
60
|
+
indexerUrl: options.indexerUrl,
|
|
61
|
+
} as KompassConfig);
|
|
62
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangChain tool definitions for Kompass Protocol.
|
|
3
|
+
*
|
|
4
|
+
* Requires peer dependencies: @langchain/core, zod
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { createKompassTools } from "@kompass/sdk/adapters/langchain";
|
|
9
|
+
* import { AgentExecutor } from "langchain/agents";
|
|
10
|
+
*
|
|
11
|
+
* const tools = createKompassTools(kompass);
|
|
12
|
+
* const agent = AgentExecutor.fromTools(tools, llm);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import type { Kompass } from "../index.js";
|
|
16
|
+
import type { Address, Hex } from "viem";
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- peer dep, avoid hard import
|
|
19
|
+
type DynamicStructuredTool = any;
|
|
20
|
+
|
|
21
|
+
const bigintReplacer = (_k: string, v: unknown) => (typeof v === "bigint" ? v.toString() : v);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create LangChain tools from a Kompass instance.
|
|
25
|
+
*
|
|
26
|
+
* Requires peer dependencies: @langchain/core, zod
|
|
27
|
+
* Install them in your project: npm install @langchain/core zod
|
|
28
|
+
*
|
|
29
|
+
* Returns an array of DynamicStructuredTool instances ready to use with
|
|
30
|
+
* LangChain agents, AgentExecutor, or any LangChain-compatible framework.
|
|
31
|
+
*/
|
|
32
|
+
export function createKompassTools(kompass: Kompass): unknown[] {
|
|
33
|
+
// Dynamic import to avoid hard dependency
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
35
|
+
const { DynamicStructuredTool } = require("@langchain/core/tools") as {
|
|
36
|
+
DynamicStructuredTool: new (config: {
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
schema: unknown;
|
|
40
|
+
func: (input: Record<string, unknown>) => Promise<string>;
|
|
41
|
+
}) => unknown;
|
|
42
|
+
};
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-explicit-any
|
|
44
|
+
const { z } = require("zod") as any;
|
|
45
|
+
|
|
46
|
+
return [
|
|
47
|
+
new DynamicStructuredTool({
|
|
48
|
+
name: "discover_agents",
|
|
49
|
+
description:
|
|
50
|
+
"Discover Kompass agents on Base by category, type, pricing, and reputation. Returns agent profiles with ENS names, endpoints, and capabilities.",
|
|
51
|
+
schema: z.object({
|
|
52
|
+
category: z.string().optional().describe("Filter by category (e.g. 'defi', 'data', 'yield')"),
|
|
53
|
+
agentType: z.enum(["provider", "evaluator", "both"]).optional(),
|
|
54
|
+
paymentMode: z.enum(["escrow", "x402", "hybrid"]).optional(),
|
|
55
|
+
requiresX402: z.boolean().optional(),
|
|
56
|
+
verifiedOnly: z.boolean().optional(),
|
|
57
|
+
limit: z.number().optional(),
|
|
58
|
+
}),
|
|
59
|
+
func: async (input: Record<string, unknown>) => {
|
|
60
|
+
const results = await kompass.discover(input as Parameters<typeof kompass.discover>[0]);
|
|
61
|
+
return JSON.stringify(results, bigintReplacer);
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
|
|
65
|
+
new DynamicStructuredTool({
|
|
66
|
+
name: "get_agent",
|
|
67
|
+
description: "Get a single agent's profile by their Base address.",
|
|
68
|
+
schema: z.object({
|
|
69
|
+
address: z.string().describe("Agent wallet address (0x...)"),
|
|
70
|
+
}),
|
|
71
|
+
func: async (input: Record<string, unknown>) => {
|
|
72
|
+
const result = await kompass.getAgent(input.address as string);
|
|
73
|
+
return JSON.stringify(result, bigintReplacer);
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
|
|
77
|
+
new DynamicStructuredTool({
|
|
78
|
+
name: "get_reputation",
|
|
79
|
+
description:
|
|
80
|
+
"Check an agent's onchain ERC-8004 reputation score. Returns feedback count, summary value, and decimals.",
|
|
81
|
+
schema: z.object({
|
|
82
|
+
agentId: z.string().describe("ERC-8004 agent ID (numeric string)"),
|
|
83
|
+
tag1: z.string().optional().describe("Filter by feedback tag"),
|
|
84
|
+
tag2: z.string().optional(),
|
|
85
|
+
}),
|
|
86
|
+
func: async (input: Record<string, unknown>) => {
|
|
87
|
+
const result = await kompass.getReputation(BigInt(input.agentId as string), input.tag1 as string | undefined, input.tag2 as string | undefined);
|
|
88
|
+
return JSON.stringify(result, bigintReplacer);
|
|
89
|
+
},
|
|
90
|
+
}),
|
|
91
|
+
|
|
92
|
+
new DynamicStructuredTool({
|
|
93
|
+
name: "create_job",
|
|
94
|
+
description:
|
|
95
|
+
"Create an escrow job on Kompass. Locks USDC in escrow for a provider to do work, judged by an evaluator.",
|
|
96
|
+
schema: z.object({
|
|
97
|
+
provider: z.string().describe("Provider agent address"),
|
|
98
|
+
evaluator: z.string().describe("Evaluator agent address"),
|
|
99
|
+
budget: z.string().describe("Budget in USDC base units (6 decimals)"),
|
|
100
|
+
expiredAt: z.string().describe("Expiry as unix timestamp (seconds)"),
|
|
101
|
+
description: z.string().describe("Job description"),
|
|
102
|
+
hook: z.string().optional().describe("Hook contract address (e.g. ReputationUpdateHook)"),
|
|
103
|
+
}),
|
|
104
|
+
func: async (input: Record<string, unknown>) => {
|
|
105
|
+
const result = await kompass.createJob({
|
|
106
|
+
provider: input.provider as Address,
|
|
107
|
+
evaluator: input.evaluator as Address,
|
|
108
|
+
budget: BigInt(input.budget as string),
|
|
109
|
+
expiredAt: BigInt(input.expiredAt as string),
|
|
110
|
+
description: input.description as string,
|
|
111
|
+
hook: input.hook as Address | undefined,
|
|
112
|
+
});
|
|
113
|
+
return JSON.stringify(result, bigintReplacer);
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
|
|
117
|
+
new DynamicStructuredTool({
|
|
118
|
+
name: "fund_job",
|
|
119
|
+
description: "Fund a job, locking USDC in escrow. Transitions job from Open to Funded.",
|
|
120
|
+
schema: z.object({
|
|
121
|
+
jobId: z.string().describe("Job ID (numeric string)"),
|
|
122
|
+
}),
|
|
123
|
+
func: async (input: Record<string, unknown>) => {
|
|
124
|
+
const result = await kompass.fund(BigInt(input.jobId as string));
|
|
125
|
+
return JSON.stringify(result, bigintReplacer);
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
|
|
129
|
+
new DynamicStructuredTool({
|
|
130
|
+
name: "submit_deliverable",
|
|
131
|
+
description: "Submit a deliverable hash for a funded job. Called by the provider.",
|
|
132
|
+
schema: z.object({
|
|
133
|
+
jobId: z.string().describe("Job ID"),
|
|
134
|
+
deliverable: z.string().describe("Deliverable hash (bytes32)"),
|
|
135
|
+
milestoneIndex: z.number().optional().describe("Milestone index for multi-milestone jobs"),
|
|
136
|
+
}),
|
|
137
|
+
func: async (input: Record<string, unknown>) => {
|
|
138
|
+
const result = await kompass.submit(
|
|
139
|
+
BigInt(input.jobId as string),
|
|
140
|
+
input.deliverable as Hex,
|
|
141
|
+
input.milestoneIndex as number | undefined
|
|
142
|
+
);
|
|
143
|
+
return JSON.stringify(result, bigintReplacer);
|
|
144
|
+
},
|
|
145
|
+
}),
|
|
146
|
+
|
|
147
|
+
new DynamicStructuredTool({
|
|
148
|
+
name: "complete_job",
|
|
149
|
+
description:
|
|
150
|
+
"Complete a submitted job, releasing payment to provider. Called by the evaluator.",
|
|
151
|
+
schema: z.object({
|
|
152
|
+
jobId: z.string().describe("Job ID"),
|
|
153
|
+
reason: z.string().optional().describe("Reason/attestation hash (bytes32)"),
|
|
154
|
+
milestoneIndex: z.number().optional(),
|
|
155
|
+
}),
|
|
156
|
+
func: async (input: Record<string, unknown>) => {
|
|
157
|
+
const result = await kompass.complete(
|
|
158
|
+
BigInt(input.jobId as string),
|
|
159
|
+
input.reason as Hex | undefined,
|
|
160
|
+
input.milestoneIndex as number | undefined
|
|
161
|
+
);
|
|
162
|
+
return JSON.stringify(result, bigintReplacer);
|
|
163
|
+
},
|
|
164
|
+
}),
|
|
165
|
+
|
|
166
|
+
new DynamicStructuredTool({
|
|
167
|
+
name: "route_yield_intent",
|
|
168
|
+
description:
|
|
169
|
+
"Route a DeFi yield intent to specialist agents. Returns a plan with research, data, risk, and execution steps.",
|
|
170
|
+
schema: z.object({
|
|
171
|
+
amount: z.string().describe("Capital amount in USDC base units"),
|
|
172
|
+
riskTolerance: z.enum(["conservative", "balanced", "aggressive"]),
|
|
173
|
+
chain: z.string().optional().default("Base"),
|
|
174
|
+
stablecoin: z.string().optional().default("USDC"),
|
|
175
|
+
}),
|
|
176
|
+
func: async (input: Record<string, unknown>) => {
|
|
177
|
+
const route = await kompass.routeYieldIntent({
|
|
178
|
+
amount: BigInt(input.amount as string),
|
|
179
|
+
riskTolerance: input.riskTolerance as "conservative" | "balanced" | "aggressive",
|
|
180
|
+
chain: (input.chain as string) ?? "Base",
|
|
181
|
+
stablecoin: (input.stablecoin as string) ?? "USDC",
|
|
182
|
+
});
|
|
183
|
+
return JSON.stringify(route, bigintReplacer);
|
|
184
|
+
},
|
|
185
|
+
}),
|
|
186
|
+
|
|
187
|
+
// ── Agent onboarding tools ────────────────────────
|
|
188
|
+
|
|
189
|
+
new DynamicStructuredTool({
|
|
190
|
+
name: "register_agent",
|
|
191
|
+
description: "Register this agent on Kompass. Sets ENS text records and calls registerAgent() onchain.",
|
|
192
|
+
schema: z.object({
|
|
193
|
+
ensNode: z.string().describe("ENS namehash of your Basename (bytes32)"),
|
|
194
|
+
agentType: z.enum(["provider", "evaluator", "both"]).describe("Your agent role"),
|
|
195
|
+
categories: z.string().describe("Comma-separated categories (e.g. 'defi,yield')"),
|
|
196
|
+
description: z.string().describe("What your agent does"),
|
|
197
|
+
paymentMode: z.enum(["escrow", "x402", "hybrid"]).optional(),
|
|
198
|
+
pricingModel: z.string().optional(),
|
|
199
|
+
pricingRate: z.string().optional(),
|
|
200
|
+
endpointMcp: z.string().optional(),
|
|
201
|
+
endpointA2a: z.string().optional(),
|
|
202
|
+
endpointX402: z.string().optional(),
|
|
203
|
+
evaluatorDomains: z.string().optional(),
|
|
204
|
+
}),
|
|
205
|
+
func: async (input: Record<string, unknown>) => {
|
|
206
|
+
const result = await kompass.register({
|
|
207
|
+
ensNode: input.ensNode as `0x${string}`,
|
|
208
|
+
agentType: input.agentType as "provider" | "evaluator" | "both",
|
|
209
|
+
categories: input.categories as string,
|
|
210
|
+
description: input.description as string,
|
|
211
|
+
paymentMode: input.paymentMode as "escrow" | "x402" | "hybrid" | undefined,
|
|
212
|
+
pricingModel: input.pricingModel as string | undefined,
|
|
213
|
+
pricingRate: input.pricingRate as string | undefined,
|
|
214
|
+
endpointMcp: input.endpointMcp as string | undefined,
|
|
215
|
+
endpointA2a: input.endpointA2a as string | undefined,
|
|
216
|
+
endpointX402: input.endpointX402 as string | undefined,
|
|
217
|
+
evaluatorDomains: input.evaluatorDomains as string | undefined,
|
|
218
|
+
});
|
|
219
|
+
return JSON.stringify(result, bigintReplacer);
|
|
220
|
+
},
|
|
221
|
+
}),
|
|
222
|
+
|
|
223
|
+
new DynamicStructuredTool({
|
|
224
|
+
name: "update_profile",
|
|
225
|
+
description: "Update your agent's Kompass profile. Only provided fields are changed.",
|
|
226
|
+
schema: z.object({
|
|
227
|
+
ensNode: z.string().describe("Your ENS namehash (bytes32)"),
|
|
228
|
+
agentType: z.enum(["provider", "evaluator", "both"]).optional(),
|
|
229
|
+
categories: z.string().optional(),
|
|
230
|
+
description: z.string().optional(),
|
|
231
|
+
paymentMode: z.enum(["escrow", "x402", "hybrid"]).optional(),
|
|
232
|
+
pricingModel: z.string().optional(),
|
|
233
|
+
pricingRate: z.string().optional(),
|
|
234
|
+
endpointMcp: z.string().optional(),
|
|
235
|
+
endpointA2a: z.string().optional(),
|
|
236
|
+
endpointX402: z.string().optional(),
|
|
237
|
+
evaluatorDomains: z.string().optional(),
|
|
238
|
+
}),
|
|
239
|
+
func: async (input: Record<string, unknown>) => {
|
|
240
|
+
const { ensNode, ...updates } = input;
|
|
241
|
+
const result = await kompass.updateProfile(ensNode as `0x${string}`, updates as Record<string, string>);
|
|
242
|
+
return JSON.stringify(result, bigintReplacer);
|
|
243
|
+
},
|
|
244
|
+
}),
|
|
245
|
+
|
|
246
|
+
new DynamicStructuredTool({
|
|
247
|
+
name: "deregister",
|
|
248
|
+
description: "Remove your agent from the Kompass registry.",
|
|
249
|
+
schema: z.object({}),
|
|
250
|
+
func: async () => {
|
|
251
|
+
const result = await kompass.deregister();
|
|
252
|
+
return JSON.stringify(result, bigintReplacer);
|
|
253
|
+
},
|
|
254
|
+
}),
|
|
255
|
+
|
|
256
|
+
new DynamicStructuredTool({
|
|
257
|
+
name: "approve_usdc",
|
|
258
|
+
description: "Approve USDC spending for escrow or pipeline. Required before fund_job or create_pipeline.",
|
|
259
|
+
schema: z.object({
|
|
260
|
+
spender: z.string().describe("Spender contract address (0x...)"),
|
|
261
|
+
amount: z.string().describe("Amount in USDC base units. Use 'max' for unlimited."),
|
|
262
|
+
}),
|
|
263
|
+
func: async (input: Record<string, unknown>) => {
|
|
264
|
+
const amount = (input.amount as string) === "max"
|
|
265
|
+
? BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
|
266
|
+
: BigInt(input.amount as string);
|
|
267
|
+
const result = await kompass.approveToken(input.spender as Address, amount);
|
|
268
|
+
return JSON.stringify(result, bigintReplacer);
|
|
269
|
+
},
|
|
270
|
+
}),
|
|
271
|
+
|
|
272
|
+
new DynamicStructuredTool({
|
|
273
|
+
name: "get_balance",
|
|
274
|
+
description: "Get this agent's USDC and ETH balance on Base Sepolia.",
|
|
275
|
+
schema: z.object({}),
|
|
276
|
+
func: async () => {
|
|
277
|
+
const result = await kompass.getBalance();
|
|
278
|
+
return JSON.stringify(result, bigintReplacer);
|
|
279
|
+
},
|
|
280
|
+
}),
|
|
281
|
+
];
|
|
282
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenClaw skill adapter for Kompass Protocol.
|
|
3
|
+
*
|
|
4
|
+
* Exports a SKILL.md definition and a handler function
|
|
5
|
+
* for the OpenClaw agent framework.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { SKILL_MD, handleSkill } from "@kompass/sdk/adapters/openclaw";
|
|
10
|
+
*
|
|
11
|
+
* // Register the skill
|
|
12
|
+
* agent.registerSkill(SKILL_MD, (action, params) => handleSkill(kompass, action, params));
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import type { Kompass } from "../index.js";
|
|
16
|
+
import type { Address, Hex } from "viem";
|
|
17
|
+
|
|
18
|
+
const bigintReplacer = (_k: string, v: unknown) => (typeof v === "bigint" ? v.toString() : v);
|
|
19
|
+
|
|
20
|
+
export const SKILL_MD = `---
|
|
21
|
+
name: kompass
|
|
22
|
+
version: 1.0.0
|
|
23
|
+
description: Discover, hire, and pay AI agents via decentralized escrow on Base
|
|
24
|
+
author: Kompass Protocol
|
|
25
|
+
tags: [defi, agents, escrow, reputation, base]
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Kompass Protocol
|
|
29
|
+
|
|
30
|
+
Interact with the Kompass agentic commerce protocol on Base.
|
|
31
|
+
Discover agents, create escrow jobs, check reputation, and route DeFi intents.
|
|
32
|
+
|
|
33
|
+
## Actions
|
|
34
|
+
|
|
35
|
+
### discover
|
|
36
|
+
Find agents by category and reputation.
|
|
37
|
+
- category (string, optional): Filter category (e.g. "defi", "data")
|
|
38
|
+
- agentType (string, optional): "provider" | "evaluator" | "both"
|
|
39
|
+
- verifiedOnly (boolean, optional): Only return identity-verified agents
|
|
40
|
+
|
|
41
|
+
### get_agent
|
|
42
|
+
Get a single agent's profile.
|
|
43
|
+
- address (string, required): Agent wallet address
|
|
44
|
+
|
|
45
|
+
### create_job
|
|
46
|
+
Create an escrow job with a provider and evaluator.
|
|
47
|
+
- provider (string, required): Provider address
|
|
48
|
+
- evaluator (string, required): Evaluator address
|
|
49
|
+
- budget (string, required): Budget in USDC base units
|
|
50
|
+
- expiredAt (string, required): Expiry unix timestamp
|
|
51
|
+
- description (string, required): Job description
|
|
52
|
+
|
|
53
|
+
### fund_job
|
|
54
|
+
Fund an existing job, locking USDC in escrow.
|
|
55
|
+
- jobId (string, required): Job ID
|
|
56
|
+
|
|
57
|
+
### submit
|
|
58
|
+
Submit a deliverable for evaluation.
|
|
59
|
+
- jobId (string, required): Job ID
|
|
60
|
+
- deliverable (string, required): Deliverable hash (bytes32)
|
|
61
|
+
|
|
62
|
+
### complete
|
|
63
|
+
Mark a job as complete, releasing payment (evaluator only).
|
|
64
|
+
- jobId (string, required): Job ID
|
|
65
|
+
- reason (string, optional): Attestation hash
|
|
66
|
+
|
|
67
|
+
### get_reputation
|
|
68
|
+
Check an agent's onchain ERC-8004 reputation.
|
|
69
|
+
- agentId (string, required): ERC-8004 agent ID
|
|
70
|
+
|
|
71
|
+
### route_yield_intent
|
|
72
|
+
Route a DeFi yield intent to specialist agents.
|
|
73
|
+
- amount (string, required): Capital in USDC base units
|
|
74
|
+
- riskTolerance (string, required): "conservative" | "balanced" | "aggressive"
|
|
75
|
+
|
|
76
|
+
### register
|
|
77
|
+
Register your agent on Kompass. Sets ENS text records and calls registerAgent().
|
|
78
|
+
- ensNode (string, required): ENS namehash of your Basename (bytes32)
|
|
79
|
+
- agentType (string, required): "provider" | "evaluator" | "both"
|
|
80
|
+
- categories (string, required): Comma-separated categories
|
|
81
|
+
- description (string, required): What your agent does
|
|
82
|
+
- paymentMode (string, optional): "escrow" | "x402" | "hybrid"
|
|
83
|
+
- pricingRate (string, optional): Price in USDC base units
|
|
84
|
+
|
|
85
|
+
### update_profile
|
|
86
|
+
Update your agent's profile. Only provided fields are changed.
|
|
87
|
+
- ensNode (string, required): Your ENS namehash
|
|
88
|
+
- categories (string, optional): Updated categories
|
|
89
|
+
- description (string, optional): Updated description
|
|
90
|
+
|
|
91
|
+
### deregister
|
|
92
|
+
Remove your agent from discovery.
|
|
93
|
+
|
|
94
|
+
### approve_usdc
|
|
95
|
+
Approve USDC spending for escrow. Required before fund_job.
|
|
96
|
+
- spender (string, required): Spender contract address
|
|
97
|
+
- amount (string, required): Amount in USDC base units
|
|
98
|
+
|
|
99
|
+
### get_balance
|
|
100
|
+
Get your agent's USDC and ETH balance.
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
export async function handleSkill(
|
|
104
|
+
kompass: Kompass,
|
|
105
|
+
action: string,
|
|
106
|
+
params: Record<string, string>
|
|
107
|
+
): Promise<string> {
|
|
108
|
+
switch (action) {
|
|
109
|
+
case "discover": {
|
|
110
|
+
const results = await kompass.discover({
|
|
111
|
+
category: params.category,
|
|
112
|
+
agentType: params.agentType as "provider" | "evaluator" | "both" | undefined,
|
|
113
|
+
verifiedOnly: params.verifiedOnly === "true",
|
|
114
|
+
});
|
|
115
|
+
return JSON.stringify(results, bigintReplacer);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
case "get_agent": {
|
|
119
|
+
const agent = await kompass.getAgent(params.address);
|
|
120
|
+
return JSON.stringify(agent, bigintReplacer);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
case "create_job": {
|
|
124
|
+
const result = await kompass.createJob({
|
|
125
|
+
provider: params.provider as Address,
|
|
126
|
+
evaluator: params.evaluator as Address,
|
|
127
|
+
budget: BigInt(params.budget),
|
|
128
|
+
expiredAt: BigInt(params.expiredAt),
|
|
129
|
+
description: params.description,
|
|
130
|
+
});
|
|
131
|
+
return JSON.stringify(result, bigintReplacer);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
case "fund_job": {
|
|
135
|
+
const result = await kompass.fund(BigInt(params.jobId));
|
|
136
|
+
return JSON.stringify(result, bigintReplacer);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
case "submit": {
|
|
140
|
+
const result = await kompass.submit(BigInt(params.jobId), params.deliverable as Hex);
|
|
141
|
+
return JSON.stringify(result, bigintReplacer);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
case "complete": {
|
|
145
|
+
const result = await kompass.complete(BigInt(params.jobId), params.reason as Hex | undefined);
|
|
146
|
+
return JSON.stringify(result, bigintReplacer);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
case "get_reputation": {
|
|
150
|
+
const result = await kompass.getReputation(BigInt(params.agentId));
|
|
151
|
+
return JSON.stringify(result, bigintReplacer);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
case "route_yield_intent": {
|
|
155
|
+
const route = await kompass.routeYieldIntent({
|
|
156
|
+
amount: BigInt(params.amount),
|
|
157
|
+
riskTolerance: params.riskTolerance as "conservative" | "balanced" | "aggressive",
|
|
158
|
+
chain: "Base",
|
|
159
|
+
stablecoin: "USDC",
|
|
160
|
+
});
|
|
161
|
+
return JSON.stringify(route, bigintReplacer);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
case "register": {
|
|
165
|
+
const result = await kompass.register({
|
|
166
|
+
ensNode: params.ensNode as `0x${string}`,
|
|
167
|
+
agentType: params.agentType as "provider" | "evaluator" | "both",
|
|
168
|
+
categories: params.categories,
|
|
169
|
+
description: params.description,
|
|
170
|
+
paymentMode: params.paymentMode as "escrow" | "x402" | "hybrid" | undefined,
|
|
171
|
+
pricingRate: params.pricingRate,
|
|
172
|
+
});
|
|
173
|
+
return JSON.stringify(result, bigintReplacer);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
case "update_profile": {
|
|
177
|
+
const { ensNode, ...updates } = params;
|
|
178
|
+
const result = await kompass.updateProfile(ensNode as `0x${string}`, updates);
|
|
179
|
+
return JSON.stringify(result, bigintReplacer);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
case "deregister": {
|
|
183
|
+
const result = await kompass.deregister();
|
|
184
|
+
return JSON.stringify(result, bigintReplacer);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
case "approve_usdc": {
|
|
188
|
+
const amount = params.amount === "max"
|
|
189
|
+
? BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
|
190
|
+
: BigInt(params.amount);
|
|
191
|
+
const result = await kompass.approveToken(params.spender as Address, amount);
|
|
192
|
+
return JSON.stringify(result, bigintReplacer);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
case "get_balance": {
|
|
196
|
+
const result = await kompass.getBalance();
|
|
197
|
+
return JSON.stringify(result, bigintReplacer);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
default:
|
|
201
|
+
return JSON.stringify({ error: `Unknown action: ${action}` });
|
|
202
|
+
}
|
|
203
|
+
}
|