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,246 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
import { createPublicClient, createWalletClient, http } from "viem";
|
|
3
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
4
|
+
import { baseSepolia } from "viem/chains";
|
|
5
|
+
|
|
6
|
+
const PROVIDER_NODE = "0x5911e072e7bfa6e0e7b169372a608d2418d358dcb44de82c3e98f339c02346de";
|
|
7
|
+
const EVALUATOR_NODE = "0x475c4b427ef8efb13b7107f791462e2d5a0ebd0e325215c29049d875e83d05d0";
|
|
8
|
+
|
|
9
|
+
const resolverAbi = [
|
|
10
|
+
{
|
|
11
|
+
type: "function",
|
|
12
|
+
name: "setText",
|
|
13
|
+
stateMutability: "nonpayable",
|
|
14
|
+
inputs: [
|
|
15
|
+
{ name: "node", type: "bytes32" },
|
|
16
|
+
{ name: "key", type: "string" },
|
|
17
|
+
{ name: "value", type: "string" },
|
|
18
|
+
],
|
|
19
|
+
outputs: [],
|
|
20
|
+
},
|
|
21
|
+
] ;
|
|
22
|
+
|
|
23
|
+
const registryAbi = [
|
|
24
|
+
{
|
|
25
|
+
type: "function",
|
|
26
|
+
name: "isRegistered",
|
|
27
|
+
stateMutability: "view",
|
|
28
|
+
inputs: [{ name: "agent", type: "address" }],
|
|
29
|
+
outputs: [{ name: "", type: "bool" }],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "function",
|
|
33
|
+
name: "registerAgent",
|
|
34
|
+
stateMutability: "nonpayable",
|
|
35
|
+
inputs: [{ name: "ensNode", type: "bytes32" }],
|
|
36
|
+
outputs: [],
|
|
37
|
+
},
|
|
38
|
+
] ;
|
|
39
|
+
|
|
40
|
+
function requireEnv(name) {
|
|
41
|
+
const value = process.env[name];
|
|
42
|
+
if (!value) {
|
|
43
|
+
throw new Error(`Missing required environment variable: ${name}`);
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function createClients(privateKey, rpcUrl) {
|
|
49
|
+
const account = privateKeyToAccount(privateKey);
|
|
50
|
+
return {
|
|
51
|
+
account,
|
|
52
|
+
publicClient: createPublicClient({
|
|
53
|
+
chain: baseSepolia,
|
|
54
|
+
transport: http(rpcUrl),
|
|
55
|
+
}),
|
|
56
|
+
walletClient: createWalletClient({
|
|
57
|
+
account,
|
|
58
|
+
chain: baseSepolia,
|
|
59
|
+
transport: http(rpcUrl),
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function writeContractWithNonce({
|
|
65
|
+
publicClient,
|
|
66
|
+
walletClient,
|
|
67
|
+
nonceState,
|
|
68
|
+
request,
|
|
69
|
+
}) {
|
|
70
|
+
const hash = await walletClient.writeContract({
|
|
71
|
+
...request,
|
|
72
|
+
nonce: nonceState.value,
|
|
73
|
+
});
|
|
74
|
+
nonceState.value += 1;
|
|
75
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
76
|
+
return hash;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function writeTextRecords({ label, node, resolverAddress, records, publicClient, walletClient, nonceState }) {
|
|
80
|
+
for (const [key, value] of records) {
|
|
81
|
+
if (!value) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const hash = await writeContractWithNonce({
|
|
86
|
+
publicClient,
|
|
87
|
+
walletClient,
|
|
88
|
+
nonceState,
|
|
89
|
+
request: {
|
|
90
|
+
address: resolverAddress,
|
|
91
|
+
abi: resolverAbi,
|
|
92
|
+
functionName: "setText",
|
|
93
|
+
args: [node, key, value],
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
console.log(`${label}: set ${key} (${hash})`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function ensureRegistered({ label, node, registryAddress, publicClient, walletClient, account, nonceState }) {
|
|
101
|
+
const isRegistered = await publicClient.readContract({
|
|
102
|
+
address: registryAddress,
|
|
103
|
+
abi: registryAbi,
|
|
104
|
+
functionName: "isRegistered",
|
|
105
|
+
args: [account.address],
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
if (isRegistered) {
|
|
109
|
+
console.log(`${label}: already registered (${account.address})`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const hash = await writeContractWithNonce({
|
|
114
|
+
publicClient,
|
|
115
|
+
walletClient,
|
|
116
|
+
nonceState,
|
|
117
|
+
request: {
|
|
118
|
+
address: registryAddress,
|
|
119
|
+
abi: registryAbi,
|
|
120
|
+
functionName: "registerAgent",
|
|
121
|
+
args: [node],
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
console.log(`${label}: registered (${hash})`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function bootstrapAgent({ label, privateKey, node, profile, resolverAddress, registryAddress, rpcUrl }) {
|
|
128
|
+
const { account, publicClient, walletClient } = createClients(privateKey, rpcUrl);
|
|
129
|
+
const nonceState = {
|
|
130
|
+
value: await publicClient.getTransactionCount({
|
|
131
|
+
address: account.address,
|
|
132
|
+
blockTag: "pending",
|
|
133
|
+
}),
|
|
134
|
+
};
|
|
135
|
+
const verificationKey = `agent-registration[${registryAddress.toLowerCase()}][${account.address.toLowerCase()}]`;
|
|
136
|
+
const records = [
|
|
137
|
+
["com.kompass.identity.name", profile.ensName],
|
|
138
|
+
["com.kompass.type", profile.agentType],
|
|
139
|
+
["com.kompass.categories", profile.categories],
|
|
140
|
+
["com.kompass.erc8004.id", profile.erc8004Id],
|
|
141
|
+
["com.kompass.identity.verification", verificationKey],
|
|
142
|
+
[verificationKey, "verified"],
|
|
143
|
+
["com.kompass.payment.mode", profile.paymentMode],
|
|
144
|
+
["com.kompass.pricing.model", profile.pricingModel],
|
|
145
|
+
["com.kompass.pricing.rate", profile.pricingRate],
|
|
146
|
+
["com.kompass.pricing.token", profile.pricingToken],
|
|
147
|
+
["com.kompass.endpoint.mcp", profile.endpointMcp],
|
|
148
|
+
["com.kompass.endpoint.a2a", profile.endpointA2a],
|
|
149
|
+
["com.kompass.endpoint.x402", profile.endpointX402],
|
|
150
|
+
["com.kompass.evaluator.domains", profile.evaluatorDomains],
|
|
151
|
+
["com.kompass.description", profile.description],
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
console.log(`${label}: bootstrapping ${account.address}`);
|
|
155
|
+
await writeTextRecords({
|
|
156
|
+
label,
|
|
157
|
+
node,
|
|
158
|
+
resolverAddress,
|
|
159
|
+
records,
|
|
160
|
+
publicClient,
|
|
161
|
+
walletClient,
|
|
162
|
+
nonceState,
|
|
163
|
+
});
|
|
164
|
+
await ensureRegistered({
|
|
165
|
+
label,
|
|
166
|
+
node,
|
|
167
|
+
registryAddress,
|
|
168
|
+
publicClient,
|
|
169
|
+
walletClient,
|
|
170
|
+
account,
|
|
171
|
+
nonceState,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async function main() {
|
|
176
|
+
const selection = process.argv
|
|
177
|
+
.find((arg) => arg.startsWith("--agent="))
|
|
178
|
+
?.split("=")[1];
|
|
179
|
+
const rpcUrl = requireEnv("BASE_SEPOLIA_RPC");
|
|
180
|
+
const registryAddress = requireEnv("REGISTRY_ADDRESS");
|
|
181
|
+
const resolverAddress = requireEnv("ENS_L2_RESOLVER");
|
|
182
|
+
const usdcAddress = requireEnv("USDC_ADDRESS");
|
|
183
|
+
const providerKey = requireEnv("AGENT_A_PRIVATE_KEY");
|
|
184
|
+
const evaluatorKey = requireEnv("AGENT_B_PRIVATE_KEY");
|
|
185
|
+
|
|
186
|
+
const agents = [
|
|
187
|
+
{
|
|
188
|
+
label: "provider",
|
|
189
|
+
privateKey: providerKey,
|
|
190
|
+
node: PROVIDER_NODE,
|
|
191
|
+
profile: {
|
|
192
|
+
ensName: "kompassprovider.base.eth",
|
|
193
|
+
agentType: "provider",
|
|
194
|
+
categories: "defi,analytics,research,yield,data,signals,swap",
|
|
195
|
+
erc8004Id: "",
|
|
196
|
+
paymentMode: "hybrid",
|
|
197
|
+
pricingModel: "fixed",
|
|
198
|
+
pricingRate: "500000",
|
|
199
|
+
pricingToken: usdcAddress,
|
|
200
|
+
endpointMcp: "",
|
|
201
|
+
endpointA2a: "",
|
|
202
|
+
endpointX402: "",
|
|
203
|
+
evaluatorDomains: "",
|
|
204
|
+
description: "Kompass DeFi strategy, premium data, and execution provider on Base.",
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
label: "evaluator",
|
|
209
|
+
privateKey: evaluatorKey,
|
|
210
|
+
node: EVALUATOR_NODE,
|
|
211
|
+
profile: {
|
|
212
|
+
ensName: "kompassevaluator.base.eth",
|
|
213
|
+
agentType: "evaluator",
|
|
214
|
+
categories: "risk,security,defi,evaluation",
|
|
215
|
+
erc8004Id: "",
|
|
216
|
+
paymentMode: "escrow",
|
|
217
|
+
pricingModel: "fixed",
|
|
218
|
+
pricingRate: "300000",
|
|
219
|
+
pricingToken: usdcAddress,
|
|
220
|
+
endpointMcp: "",
|
|
221
|
+
endpointA2a: "",
|
|
222
|
+
endpointX402: "",
|
|
223
|
+
evaluatorDomains: "yield-risk,execution-safety,data-quality",
|
|
224
|
+
description: "Kompass evaluator for DeFi risk, execution safety, and data quality.",
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
];
|
|
228
|
+
|
|
229
|
+
for (const agent of agents) {
|
|
230
|
+
if (selection && selection !== agent.label) {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
await bootstrapAgent({
|
|
235
|
+
...agent,
|
|
236
|
+
resolverAddress,
|
|
237
|
+
registryAddress,
|
|
238
|
+
rpcUrl,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
main().catch((error) => {
|
|
244
|
+
console.error(error instanceof Error ? error.message : error);
|
|
245
|
+
process.exitCode = 1;
|
|
246
|
+
});
|
package/src/.gitkeep
ADDED
|
File without changes
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kompass Agent Card Generator
|
|
3
|
+
* Creates an A2A-compatible agent card for Kompass discovery + coordination
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { AgentCard } from "@a2a-js/sdk";
|
|
7
|
+
|
|
8
|
+
export interface KompassAgentCardOptions {
|
|
9
|
+
url: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function createKompassAgentCard(options: KompassAgentCardOptions): AgentCard {
|
|
16
|
+
return {
|
|
17
|
+
name: options.name ?? "Kompass",
|
|
18
|
+
description:
|
|
19
|
+
options.description ??
|
|
20
|
+
"Universal agent discovery + coordination. Searches ACP, MCP, x402, ERC-8004, A2A, L402 registries in one query. Bridges non-A2A agents to A2A protocol.",
|
|
21
|
+
url: options.url,
|
|
22
|
+
provider: {
|
|
23
|
+
organization: "Kompass Protocol",
|
|
24
|
+
url: "https://github.com/kompass-protocol",
|
|
25
|
+
},
|
|
26
|
+
version: options.version ?? "1.0.0",
|
|
27
|
+
capabilities: {
|
|
28
|
+
streaming: true,
|
|
29
|
+
pushNotifications: false,
|
|
30
|
+
},
|
|
31
|
+
skills: [
|
|
32
|
+
{
|
|
33
|
+
id: "universal-discovery",
|
|
34
|
+
name: "Universal Agent Discovery",
|
|
35
|
+
description:
|
|
36
|
+
"Search for agents across 8+ registries (ACP, MCP Registry, ERC-8004, x402, A2A, L402, ADP). Returns ranked results with reputation scores.",
|
|
37
|
+
inputModes: ["text"],
|
|
38
|
+
outputModes: ["text", "data"],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "cross-protocol-hire",
|
|
42
|
+
name: "Cross-Protocol Agent Hiring",
|
|
43
|
+
description:
|
|
44
|
+
"Hire any agent regardless of protocol. Kompass bridges ACP, x402, MCP, and A2A automatically.",
|
|
45
|
+
inputModes: ["text"],
|
|
46
|
+
outputModes: ["text", "data"],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "multi-agent-coordination",
|
|
50
|
+
name: "Multi-Agent Coordination",
|
|
51
|
+
description:
|
|
52
|
+
"Coordinate multiple agents across different protocols into a pipeline. Discovers agents, assigns roles, manages task dependencies.",
|
|
53
|
+
inputModes: ["text"],
|
|
54
|
+
outputModes: ["text", "data"],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "reputation-check",
|
|
58
|
+
name: "Agent Reputation Check",
|
|
59
|
+
description:
|
|
60
|
+
"Check an agent's on-chain reputation via ERC-8004. Aggregates trust signals across protocols.",
|
|
61
|
+
inputModes: ["text"],
|
|
62
|
+
outputModes: ["data"],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
} as AgentCard;
|
|
66
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kompass A2A Bridge
|
|
3
|
+
* Translates between A2A tasks and non-A2A protocols (ACP, x402, MCP)
|
|
4
|
+
* Makes every agent A2A-compatible through Kompass
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { UnifiedAgent } from "../sources/types.js";
|
|
8
|
+
import { KompassA2AClient, type A2ATaskResult } from "./client.js";
|
|
9
|
+
import { ProtocolBridge } from "../bridge.js";
|
|
10
|
+
|
|
11
|
+
export class A2ABridge {
|
|
12
|
+
private a2aClient: KompassA2AClient;
|
|
13
|
+
private protocolBridge: ProtocolBridge;
|
|
14
|
+
|
|
15
|
+
constructor(protocolBridge: ProtocolBridge) {
|
|
16
|
+
this.a2aClient = new KompassA2AClient();
|
|
17
|
+
this.protocolBridge = protocolBridge;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Send a task to any agent, regardless of protocol.
|
|
22
|
+
* If A2A-native → direct A2A task
|
|
23
|
+
* If not → bridge through protocol-specific path, wrap result as A2A
|
|
24
|
+
*/
|
|
25
|
+
async sendTask(agent: UnifiedAgent, task: string, contextId?: string): Promise<A2ATaskResult> {
|
|
26
|
+
// Check if agent has an A2A endpoint
|
|
27
|
+
if (agent.protocol === "a2a" && agent.endpoints.a2a) {
|
|
28
|
+
// Direct A2A communication
|
|
29
|
+
return this.a2aClient.sendTask({
|
|
30
|
+
agentUrl: agent.endpoints.a2a,
|
|
31
|
+
message: task,
|
|
32
|
+
contextId,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Bridge non-A2A agents
|
|
37
|
+
const bridgeResult = await this.protocolBridge.hire(agent, { task });
|
|
38
|
+
|
|
39
|
+
// Wrap the result as an A2A-compatible response
|
|
40
|
+
return {
|
|
41
|
+
taskId: bridgeResult.jobId ?? `kompass-bridge-${Date.now()}`,
|
|
42
|
+
state: bridgeResult.success ? "completed" : "failed",
|
|
43
|
+
artifacts: bridgeResult.deliverable
|
|
44
|
+
? [
|
|
45
|
+
{
|
|
46
|
+
type: "data",
|
|
47
|
+
parts: [
|
|
48
|
+
{
|
|
49
|
+
type: "text",
|
|
50
|
+
text:
|
|
51
|
+
typeof bridgeResult.deliverable === "string"
|
|
52
|
+
? bridgeResult.deliverable
|
|
53
|
+
: JSON.stringify(bridgeResult.deliverable),
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
metadata: {
|
|
57
|
+
bridgedFrom: agent.protocol,
|
|
58
|
+
source: agent.source,
|
|
59
|
+
agentName: agent.name,
|
|
60
|
+
txHash: bridgeResult.txHash,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
]
|
|
64
|
+
: [],
|
|
65
|
+
messages: [],
|
|
66
|
+
error: bridgeResult.error,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Coordinate a multi-step pipeline across protocols.
|
|
72
|
+
* Each step: discover → send task (A2A or bridged) → pass result to next step.
|
|
73
|
+
*/
|
|
74
|
+
async coordinate(
|
|
75
|
+
steps: CoordinationStep[],
|
|
76
|
+
findAgent: (query: string) => Promise<UnifiedAgent | null>
|
|
77
|
+
): Promise<CoordinationResult> {
|
|
78
|
+
const results: StepResult[] = [];
|
|
79
|
+
const context = new Map<string, unknown>();
|
|
80
|
+
|
|
81
|
+
for (const step of steps) {
|
|
82
|
+
// Wait for dependencies
|
|
83
|
+
if (step.dependsOn) {
|
|
84
|
+
const depResult = results.find((r) => r.stepId === step.dependsOn);
|
|
85
|
+
if (depResult && !depResult.success) {
|
|
86
|
+
results.push({
|
|
87
|
+
stepId: step.id,
|
|
88
|
+
role: step.role,
|
|
89
|
+
success: false,
|
|
90
|
+
error: `Dependency "${step.dependsOn}" failed`,
|
|
91
|
+
skipped: true,
|
|
92
|
+
});
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Find agent for this step
|
|
98
|
+
const agent = step.agent ?? (await findAgent(step.query ?? step.role));
|
|
99
|
+
if (!agent) {
|
|
100
|
+
results.push({
|
|
101
|
+
stepId: step.id,
|
|
102
|
+
role: step.role,
|
|
103
|
+
success: false,
|
|
104
|
+
error: `No agent found for role: ${step.role}`,
|
|
105
|
+
skipped: true,
|
|
106
|
+
});
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Build task with context from previous steps
|
|
111
|
+
let taskMessage = step.task ?? step.query ?? step.role;
|
|
112
|
+
if (step.dependsOn && context.has(step.dependsOn)) {
|
|
113
|
+
const prevData = context.get(step.dependsOn);
|
|
114
|
+
taskMessage += `\n\nContext from previous step:\n${JSON.stringify(prevData, null, 2).slice(0, 2000)}`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Send task via A2A (or bridge)
|
|
118
|
+
const taskResult = await this.sendTask(agent, taskMessage);
|
|
119
|
+
|
|
120
|
+
const success = taskResult.state === "completed";
|
|
121
|
+
if (success && taskResult.artifacts.length > 0) {
|
|
122
|
+
context.set(step.id, taskResult.artifacts);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
results.push({
|
|
126
|
+
stepId: step.id,
|
|
127
|
+
role: step.role,
|
|
128
|
+
agent: { name: agent.name, source: agent.source, protocol: agent.protocol },
|
|
129
|
+
success,
|
|
130
|
+
result: taskResult,
|
|
131
|
+
error: taskResult.error,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
steps: results,
|
|
137
|
+
completedCount: results.filter((r) => r.success).length,
|
|
138
|
+
totalCount: steps.length,
|
|
139
|
+
context: Object.fromEntries(context),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface CoordinationStep {
|
|
145
|
+
id: string;
|
|
146
|
+
role: string;
|
|
147
|
+
query?: string;
|
|
148
|
+
task?: string;
|
|
149
|
+
agent?: UnifiedAgent;
|
|
150
|
+
dependsOn?: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface StepResult {
|
|
154
|
+
stepId: string;
|
|
155
|
+
role: string;
|
|
156
|
+
agent?: { name: string; source: string; protocol: string };
|
|
157
|
+
success: boolean;
|
|
158
|
+
result?: A2ATaskResult;
|
|
159
|
+
error?: string;
|
|
160
|
+
skipped?: boolean;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface CoordinationResult {
|
|
164
|
+
steps: StepResult[];
|
|
165
|
+
completedCount: number;
|
|
166
|
+
totalCount: number;
|
|
167
|
+
context: Record<string, unknown>;
|
|
168
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kompass A2A Client
|
|
3
|
+
* Sends tasks to A2A-compatible agents
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ClientFactory, JsonRpcTransportFactory, RestTransportFactory } from "@a2a-js/sdk/client";
|
|
7
|
+
import type { Task, Message, Artifact, TaskState } from "@a2a-js/sdk";
|
|
8
|
+
|
|
9
|
+
export interface A2ATaskOptions {
|
|
10
|
+
/** The A2A agent URL (where agent-card.json is hosted) */
|
|
11
|
+
agentUrl: string;
|
|
12
|
+
/** Task message text */
|
|
13
|
+
message: string;
|
|
14
|
+
/** Optional context from previous tasks */
|
|
15
|
+
contextId?: string;
|
|
16
|
+
/** Timeout in ms */
|
|
17
|
+
timeout?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface A2ATaskResult {
|
|
21
|
+
taskId: string;
|
|
22
|
+
state: string;
|
|
23
|
+
artifacts: unknown[];
|
|
24
|
+
messages: unknown[];
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class KompassA2AClient {
|
|
29
|
+
private factory: ClientFactory;
|
|
30
|
+
|
|
31
|
+
constructor() {
|
|
32
|
+
this.factory = new ClientFactory({
|
|
33
|
+
transports: [new JsonRpcTransportFactory(), new RestTransportFactory()],
|
|
34
|
+
} as any);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Send a task to an A2A-compatible agent and wait for completion.
|
|
39
|
+
*/
|
|
40
|
+
async sendTask(options: A2ATaskOptions): Promise<A2ATaskResult> {
|
|
41
|
+
try {
|
|
42
|
+
const client = await this.factory.createFromUrl(options.agentUrl);
|
|
43
|
+
|
|
44
|
+
// Send message and get task
|
|
45
|
+
const response = await client.sendMessage({
|
|
46
|
+
message: {
|
|
47
|
+
role: "user",
|
|
48
|
+
parts: [{ type: "text", text: options.message }],
|
|
49
|
+
},
|
|
50
|
+
configuration: {
|
|
51
|
+
blocking: true, // Wait for completion
|
|
52
|
+
},
|
|
53
|
+
} as any);
|
|
54
|
+
|
|
55
|
+
// Extract task info from response
|
|
56
|
+
const task = (response as any)?.result;
|
|
57
|
+
|
|
58
|
+
if (!task) {
|
|
59
|
+
return {
|
|
60
|
+
taskId: "unknown",
|
|
61
|
+
state: "failed",
|
|
62
|
+
artifacts: [],
|
|
63
|
+
messages: [],
|
|
64
|
+
error: "No task returned from agent",
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
taskId: task.id ?? task.taskId ?? "unknown",
|
|
70
|
+
state: task.status?.state ?? task.state ?? "completed",
|
|
71
|
+
artifacts: task.artifacts ?? [],
|
|
72
|
+
messages: task.history ?? [],
|
|
73
|
+
};
|
|
74
|
+
} catch (err) {
|
|
75
|
+
return {
|
|
76
|
+
taskId: "error",
|
|
77
|
+
state: "failed",
|
|
78
|
+
artifacts: [],
|
|
79
|
+
messages: [],
|
|
80
|
+
error: err instanceof Error ? err.message : String(err),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Send a streaming task to an A2A agent and collect results.
|
|
87
|
+
*/
|
|
88
|
+
async sendStreamingTask(options: A2ATaskOptions): Promise<A2ATaskResult> {
|
|
89
|
+
// Streaming falls back to blocking send for compatibility
|
|
90
|
+
return this.sendTask(options);
|
|
91
|
+
}
|
|
92
|
+
}
|