@absol-labs/agent 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/LICENSE +21 -0
- package/README.md +196 -0
- package/dist/discovery/registry.d.ts +68 -0
- package/dist/discovery/registry.d.ts.map +1 -0
- package/dist/discovery/registry.js +148 -0
- package/dist/discovery/registry.js.map +1 -0
- package/dist/frameworks/agentkit.d.ts +158 -0
- package/dist/frameworks/agentkit.d.ts.map +1 -0
- package/dist/frameworks/agentkit.js +339 -0
- package/dist/frameworks/agentkit.js.map +1 -0
- package/dist/frameworks/crewai.d.ts +19 -0
- package/dist/frameworks/crewai.d.ts.map +1 -0
- package/dist/frameworks/crewai.js +73 -0
- package/dist/frameworks/crewai.js.map +1 -0
- package/dist/frameworks/eliza.d.ts +393 -0
- package/dist/frameworks/eliza.d.ts.map +1 -0
- package/dist/frameworks/eliza.js +542 -0
- package/dist/frameworks/eliza.js.map +1 -0
- package/dist/frameworks/langchain.d.ts +31 -0
- package/dist/frameworks/langchain.d.ts.map +1 -0
- package/dist/frameworks/langchain.js +206 -0
- package/dist/frameworks/langchain.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/mandates/env.d.ts +51 -0
- package/dist/mandates/env.d.ts.map +1 -0
- package/dist/mandates/env.js +148 -0
- package/dist/mandates/env.js.map +1 -0
- package/dist/mandates/mandate.d.ts +214 -0
- package/dist/mandates/mandate.d.ts.map +1 -0
- package/dist/mandates/mandate.js +172 -0
- package/dist/mandates/mandate.js.map +1 -0
- package/dist/mcp/http-server.d.ts +2 -0
- package/dist/mcp/http-server.d.ts.map +1 -0
- package/dist/mcp/http-server.js +32 -0
- package/dist/mcp/http-server.js.map +1 -0
- package/dist/mcp/http.d.ts +114 -0
- package/dist/mcp/http.d.ts.map +1 -0
- package/dist/mcp/http.js +428 -0
- package/dist/mcp/http.js.map +1 -0
- package/dist/mcp/server.d.ts +119 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +679 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/stdio.d.ts +2 -0
- package/dist/mcp/stdio.d.ts.map +1 -0
- package/dist/mcp/stdio.js +6 -0
- package/dist/mcp/stdio.js.map +1 -0
- package/dist/sdk/client.d.ts +78 -0
- package/dist/sdk/client.d.ts.map +1 -0
- package/dist/sdk/client.js +99 -0
- package/dist/sdk/client.js.map +1 -0
- package/dist/wallet/provider.d.ts +51 -0
- package/dist/wallet/provider.d.ts.map +1 -0
- package/dist/wallet/provider.js +107 -0
- package/dist/wallet/provider.js.map +1 -0
- package/dist/x402/facilitator.d.ts +315 -0
- package/dist/x402/facilitator.d.ts.map +1 -0
- package/dist/x402/facilitator.js +194 -0
- package/dist/x402/facilitator.js.map +1 -0
- package/dist/zktls/reclaim.d.ts +137 -0
- package/dist/zktls/reclaim.d.ts.map +1 -0
- package/dist/zktls/reclaim.js +245 -0
- package/dist/zktls/reclaim.js.map +1 -0
- package/package.json +86 -0
- package/src/discovery/registry.ts +255 -0
- package/src/frameworks/agentkit.ts +537 -0
- package/src/frameworks/crewai.ts +102 -0
- package/src/frameworks/eliza.ts +776 -0
- package/src/frameworks/langchain.ts +325 -0
- package/src/index.ts +179 -0
- package/src/mandates/env.ts +222 -0
- package/src/mandates/mandate.ts +280 -0
- package/src/mcp/http-server.ts +38 -0
- package/src/mcp/http.ts +620 -0
- package/src/mcp/server.ts +1006 -0
- package/src/mcp/stdio.ts +8 -0
- package/src/sdk/client.ts +222 -0
- package/src/wallet/provider.ts +197 -0
- package/src/x402/facilitator.ts +336 -0
- package/src/zktls/reclaim.ts +424 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import "reflect-metadata";
|
|
11
|
+
import { ActionProvider, CreateAction, WalletProvider, } from "@coinbase/agentkit";
|
|
12
|
+
import { isAddress, isHex } from "viem";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import { discoverServices as defaultDiscoverServices, } from "../discovery/registry.js";
|
|
15
|
+
import { checkMandate } from "../mandates/mandate.js";
|
|
16
|
+
import { MandateDeniedError, VerifiedStreamAgentClient, } from "../sdk/client.js";
|
|
17
|
+
/**
|
|
18
|
+
* Base Sepolia is the only settlement network Metrik supports today (Model A,
|
|
19
|
+
* single-chain USDC on Base). Every action fails closed on any other network.
|
|
20
|
+
*/
|
|
21
|
+
export const METRIK_BASE_SEPOLIA_CHAIN_ID = 84532;
|
|
22
|
+
const addressSchema = z
|
|
23
|
+
.string()
|
|
24
|
+
.refine((value) => isAddress(value), "must be an EVM address");
|
|
25
|
+
const bytes32Schema = z
|
|
26
|
+
.string()
|
|
27
|
+
.refine((value) => isHex(value, { strict: true }) && value.length === 66, "must be bytes32 hex");
|
|
28
|
+
const decimalStringSchema = z.preprocess((value) => typeof value === "bigint" || typeof value === "number"
|
|
29
|
+
? value.toString()
|
|
30
|
+
: value, z
|
|
31
|
+
.string()
|
|
32
|
+
.regex(/^(0|[1-9]\d*)$/, "must be a base-10 integer string (USDC atomic units, 6 decimals)"));
|
|
33
|
+
export const discoverServicesSchema = z.object({
|
|
34
|
+
category: z
|
|
35
|
+
.string()
|
|
36
|
+
.min(1)
|
|
37
|
+
.optional()
|
|
38
|
+
.describe("Optional marketplace category to filter listings by."),
|
|
39
|
+
limit: z
|
|
40
|
+
.number()
|
|
41
|
+
.int()
|
|
42
|
+
.positive()
|
|
43
|
+
.optional()
|
|
44
|
+
.describe("Optional cap on the number of verified listings to return."),
|
|
45
|
+
});
|
|
46
|
+
export const hireVerifiedServiceSchema = z.object({
|
|
47
|
+
operator: addressSchema.describe("Seller payout wallet (EVM address) that receives USDC for verified delivery."),
|
|
48
|
+
serviceRef: bytes32Schema.describe("bytes32 service identifier the oracle verifies delivery against."),
|
|
49
|
+
budgetUsdc: decimalStringSchema.describe("Total USDC to escrow for this stream, in atomic units (6 decimals)."),
|
|
50
|
+
ratePerSecondUsdc: decimalStringSchema.describe("Accrual rate to the seller per verified second, in USDC atomic units."),
|
|
51
|
+
durationSeconds: z
|
|
52
|
+
.number()
|
|
53
|
+
.int()
|
|
54
|
+
.positive()
|
|
55
|
+
.optional()
|
|
56
|
+
.describe("Optional max stream lifetime in seconds. Defaults to the mandate's max duration."),
|
|
57
|
+
publicUrl: z
|
|
58
|
+
.string()
|
|
59
|
+
.url()
|
|
60
|
+
.optional()
|
|
61
|
+
.describe("Optional service endpoint URL, recorded in the human summary."),
|
|
62
|
+
});
|
|
63
|
+
export const checkStreamStatusSchema = z.object({
|
|
64
|
+
streamId: bytes32Schema.describe("The stream id returned by hire_verified_service."),
|
|
65
|
+
});
|
|
66
|
+
export const reclaimUnspentSchema = z.object({
|
|
67
|
+
streamId: bytes32Schema.describe("The stream id to reclaim unspent USDC from."),
|
|
68
|
+
closeFirst: z
|
|
69
|
+
.boolean()
|
|
70
|
+
.optional()
|
|
71
|
+
.describe("Close the stream before reclaiming. Use when the stream is still active."),
|
|
72
|
+
});
|
|
73
|
+
export const closeStreamSchema = z.object({
|
|
74
|
+
streamId: bytes32Schema.describe("The stream id to close."),
|
|
75
|
+
});
|
|
76
|
+
const DEFAULT_MANDATE_STATE_RESOLVER = {
|
|
77
|
+
getSpentSoFarUsdc: async () => 0n,
|
|
78
|
+
getRevokedMandateIds: async () => [],
|
|
79
|
+
};
|
|
80
|
+
const warnedAgentKitGaps = new Set();
|
|
81
|
+
/** Emits a stderr warning at most once per process for a given key. */
|
|
82
|
+
function warnAgentKitOnce(key, message) {
|
|
83
|
+
if (warnedAgentKitGaps.has(key)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
warnedAgentKitGaps.add(key);
|
|
87
|
+
console.error(message);
|
|
88
|
+
}
|
|
89
|
+
export class MetrikActionProviderConfigError extends Error {
|
|
90
|
+
constructor(message) {
|
|
91
|
+
super(message);
|
|
92
|
+
this.name = "MetrikActionProviderConfigError";
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Coinbase AgentKit action provider that lets any AgentKit-based agent hire and
|
|
97
|
+
* pay third-party services through Metrik's verified USDC escrow. Every action
|
|
98
|
+
* is fail-closed and buyer-favoring; a hire is refused before any transaction if
|
|
99
|
+
* it would breach the configured spend mandate.
|
|
100
|
+
*/
|
|
101
|
+
export class MetrikActionProvider extends ActionProvider {
|
|
102
|
+
#client;
|
|
103
|
+
#signedMandate;
|
|
104
|
+
#resolver;
|
|
105
|
+
#now;
|
|
106
|
+
#chainId;
|
|
107
|
+
#discover;
|
|
108
|
+
constructor(config) {
|
|
109
|
+
super("metrik", []);
|
|
110
|
+
this.#chainId = config.chainId ?? METRIK_BASE_SEPOLIA_CHAIN_ID;
|
|
111
|
+
if (this.#chainId !== METRIK_BASE_SEPOLIA_CHAIN_ID) {
|
|
112
|
+
// Fail closed: Model A settles only on Base Sepolia today.
|
|
113
|
+
throw new MetrikActionProviderConfigError(`unsupported chainId ${this.#chainId}: Metrik settles only on Base Sepolia (${METRIK_BASE_SEPOLIA_CHAIN_ID})`);
|
|
114
|
+
}
|
|
115
|
+
this.#client = resolveClient(config);
|
|
116
|
+
this.#signedMandate = config.signedMandate;
|
|
117
|
+
this.#resolver = {
|
|
118
|
+
...DEFAULT_MANDATE_STATE_RESOLVER,
|
|
119
|
+
...config.mandateStateResolver,
|
|
120
|
+
};
|
|
121
|
+
// Fail-loud on the two mandate controls that require external state. The
|
|
122
|
+
// action provider holds no stream registry, so without a wired resolver the
|
|
123
|
+
// cumulative cap (maxTotalUsdc) and revocation are not enforced. Warn once.
|
|
124
|
+
if (config.mandateStateResolver?.getSpentSoFarUsdc === undefined) {
|
|
125
|
+
warnAgentKitOnce("agentkit-spent", "[metrik] AgentKit provider: no getSpentSoFarUsdc wired — the mandate cumulative cap (maxTotalUsdc) is NOT enforced across hires (per-stream/rate/duration/operator/expiry still are).");
|
|
126
|
+
}
|
|
127
|
+
if (config.mandateStateResolver?.getRevokedMandateIds === undefined) {
|
|
128
|
+
warnAgentKitOnce("agentkit-revocation", "[metrik] AgentKit provider: no getRevokedMandateIds wired — revoked mandates will NOT be rejected until you wire a revocation store.");
|
|
129
|
+
}
|
|
130
|
+
this.#now = config.now ?? (() => Math.floor(Date.now() / 1000));
|
|
131
|
+
this.#discover = config.discoverServices ?? defaultDiscoverServices;
|
|
132
|
+
}
|
|
133
|
+
async discoverServices(_walletProvider, args) {
|
|
134
|
+
const listings = await this.#discover({
|
|
135
|
+
...(args.category === undefined ? {} : { category: args.category }),
|
|
136
|
+
...(args.limit === undefined ? {} : { limit: args.limit }),
|
|
137
|
+
});
|
|
138
|
+
if (listings.length === 0) {
|
|
139
|
+
return "No verified Metrik services discovered.";
|
|
140
|
+
}
|
|
141
|
+
const lines = listings.map((listing) => `- ${listing.serviceRef} operator=${listing.operator} url=${listing.publicUrl}${listing.category ? ` category=${listing.category}` : ""}`);
|
|
142
|
+
return (`Discovered ${listings.length} verified Metrik service${listings.length === 1 ? "" : "s"} ` +
|
|
143
|
+
`(each operator signature verified). Hire one with hire_verified_service using its operator + serviceRef:\n` +
|
|
144
|
+
lines.join("\n"));
|
|
145
|
+
}
|
|
146
|
+
async hireVerifiedService(walletProvider, args) {
|
|
147
|
+
this.#assertWalletNetwork(walletProvider);
|
|
148
|
+
const owner = this.#signedMandate.owner;
|
|
149
|
+
const nowSeconds = this.#now();
|
|
150
|
+
const [spentSoFarUsdc, revokedMandateIds] = await Promise.all([
|
|
151
|
+
this.#resolver.getSpentSoFarUsdc(owner),
|
|
152
|
+
this.#resolver.getRevokedMandateIds(owner),
|
|
153
|
+
]);
|
|
154
|
+
const operator = args.operator;
|
|
155
|
+
const serviceRef = args.serviceRef;
|
|
156
|
+
const budgetUsdc = BigInt(args.budgetUsdc);
|
|
157
|
+
const ratePerSecondUsdc = BigInt(args.ratePerSecondUsdc);
|
|
158
|
+
const maxDurationSeconds = args.durationSeconds ?? this.#signedMandate.mandate.maxDurationSeconds;
|
|
159
|
+
// Mandate guard runs BEFORE any transaction — fail closed on breach.
|
|
160
|
+
const decision = await checkMandate(this.#signedMandate, {
|
|
161
|
+
operator,
|
|
162
|
+
budgetUsdc,
|
|
163
|
+
ratePerSecondUsdc,
|
|
164
|
+
maxDurationSeconds,
|
|
165
|
+
}, spentSoFarUsdc, { nowSeconds, revokedMandateIds });
|
|
166
|
+
if (!decision.allowed) {
|
|
167
|
+
throw new MandateDeniedError(decision.reason ?? "mandate-expired");
|
|
168
|
+
}
|
|
169
|
+
const result = await this.#client.openVerifiedStream({
|
|
170
|
+
operator,
|
|
171
|
+
serviceRef,
|
|
172
|
+
budgetUsdc,
|
|
173
|
+
ratePerSecondUsdc,
|
|
174
|
+
maxDurationSeconds,
|
|
175
|
+
signedMandate: this.#signedMandate,
|
|
176
|
+
spentSoFarUsdc,
|
|
177
|
+
nowSeconds,
|
|
178
|
+
revokedMandateIds,
|
|
179
|
+
});
|
|
180
|
+
const urlLine = args.publicUrl ? ` Endpoint: ${args.publicUrl}.` : "";
|
|
181
|
+
return (`Hired verified service via Metrik. Stream ${result.streamId} opened on Base Sepolia (escrow ${result.handle.escrow}). ` +
|
|
182
|
+
`Escrowed ${formatUsdc(budgetUsdc)} USDC at ${formatUsdc(ratePerSecondUsdc)} USDC/sec to operator ${operator} for service ${serviceRef}, ` +
|
|
183
|
+
`max ${maxDurationSeconds}s. Payment accrues only for oracle-verified delivery; unspent USDC is reclaimable.${urlLine} ` +
|
|
184
|
+
`tx=${result.txHash}${result.approveTxHash ? ` approve=${result.approveTxHash}` : ""}`);
|
|
185
|
+
}
|
|
186
|
+
async checkStreamStatus(walletProvider, args) {
|
|
187
|
+
this.#assertWalletNetwork(walletProvider);
|
|
188
|
+
const streamId = args.streamId;
|
|
189
|
+
const { stream, claimable, reclaimable } = await this.#client.getStreamStatus(streamId);
|
|
190
|
+
const paused = stream.status !== "active";
|
|
191
|
+
return (`Stream ${streamId} is ${stream.status}${paused ? " (payment halted)" : ""}. ` +
|
|
192
|
+
`Verified accrued: ${formatUsdc(stream.accrued)} USDC of ${formatUsdc(stream.deposit)} deposited. ` +
|
|
193
|
+
`Claimable by seller: ${formatUsdc(claimable)} USDC. Reclaimable by buyer: ${formatUsdc(reclaimable)} USDC. ` +
|
|
194
|
+
`Consecutive failed checks: ${stream.consecutiveFailures}.`);
|
|
195
|
+
}
|
|
196
|
+
async reclaimUnspent(walletProvider, args) {
|
|
197
|
+
this.#assertWalletNetwork(walletProvider);
|
|
198
|
+
const result = await this.#client.reclaimStream(await this.#authorizedStreamAction(args.streamId, {
|
|
199
|
+
...(args.closeFirst === undefined
|
|
200
|
+
? {}
|
|
201
|
+
: { closeFirst: args.closeFirst }),
|
|
202
|
+
}));
|
|
203
|
+
return (`Reclaimed unspent USDC from stream ${args.streamId} to the buyer. ` +
|
|
204
|
+
`${result.closeResult ? `Closed first (tx=${result.closeResult.txHash}). ` : ""}` +
|
|
205
|
+
`reclaim tx=${result.reclaimResult.txHash}`);
|
|
206
|
+
}
|
|
207
|
+
async closeStream(walletProvider, args) {
|
|
208
|
+
this.#assertWalletNetwork(walletProvider);
|
|
209
|
+
const result = await this.#client.closeStream(await this.#authorizedStreamAction(args.streamId, {}));
|
|
210
|
+
return `Closed stream ${args.streamId}. tx=${result.txHash}`;
|
|
211
|
+
}
|
|
212
|
+
supportsNetwork(network) {
|
|
213
|
+
// Fail closed: EVM Base Sepolia only.
|
|
214
|
+
return (network.protocolFamily === "evm" &&
|
|
215
|
+
network.chainId === String(this.#chainId));
|
|
216
|
+
}
|
|
217
|
+
#assertWalletNetwork(walletProvider) {
|
|
218
|
+
const network = walletProvider.getNetwork();
|
|
219
|
+
if (!this.supportsNetwork(network)) {
|
|
220
|
+
throw new MetrikActionProviderConfigError(`unsupported network ${network.protocolFamily}:${network.chainId ?? "unknown"}: Metrik requires Base Sepolia (evm:${this.#chainId})`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async #authorizedStreamAction(streamId, extra) {
|
|
224
|
+
const owner = this.#signedMandate.owner;
|
|
225
|
+
const nowSeconds = this.#now();
|
|
226
|
+
const [spentSoFarUsdc, revokedMandateIds] = await Promise.all([
|
|
227
|
+
this.#resolver.getSpentSoFarUsdc(owner),
|
|
228
|
+
this.#resolver.getRevokedMandateIds(owner),
|
|
229
|
+
]);
|
|
230
|
+
return {
|
|
231
|
+
streamId,
|
|
232
|
+
signedMandate: this.#signedMandate,
|
|
233
|
+
spentSoFarUsdc,
|
|
234
|
+
nowSeconds,
|
|
235
|
+
revokedMandateIds,
|
|
236
|
+
...extra,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
__decorate([
|
|
241
|
+
CreateAction({
|
|
242
|
+
name: "discover_services",
|
|
243
|
+
description: "Discover verified third-party services on the Metrik marketplace. Returns each seller's payout operator, bytes32 serviceRef, and endpoint URL — but only for listings whose operator signature is cryptographically verified, so the agent can go straight from discovery to hire_verified_service without pre-known addresses.",
|
|
244
|
+
schema: discoverServicesSchema,
|
|
245
|
+
}),
|
|
246
|
+
__metadata("design:type", Function),
|
|
247
|
+
__metadata("design:paramtypes", [WalletProvider, void 0]),
|
|
248
|
+
__metadata("design:returntype", Promise)
|
|
249
|
+
], MetrikActionProvider.prototype, "discoverServices", null);
|
|
250
|
+
__decorate([
|
|
251
|
+
CreateAction({
|
|
252
|
+
name: "hire_verified_service",
|
|
253
|
+
description: "Hire a third-party service through Metrik: escrow USDC on Base for a per-second verified-delivery stream to the seller. Payment accrues only for delivery the oracle proves, and unspent funds are reclaimable. Refuses before any transaction if the hire would exceed the signed spend mandate.",
|
|
254
|
+
schema: hireVerifiedServiceSchema,
|
|
255
|
+
}),
|
|
256
|
+
__metadata("design:type", Function),
|
|
257
|
+
__metadata("design:paramtypes", [WalletProvider, void 0]),
|
|
258
|
+
__metadata("design:returntype", Promise)
|
|
259
|
+
], MetrikActionProvider.prototype, "hireVerifiedService", null);
|
|
260
|
+
__decorate([
|
|
261
|
+
CreateAction({
|
|
262
|
+
name: "check_stream_status",
|
|
263
|
+
description: "Read a Metrik stream's status: verified accrued amount, whether it is active or paused (two failed checks auto-pause), claimable-by-seller, and reclaimable-by-buyer USDC.",
|
|
264
|
+
schema: checkStreamStatusSchema,
|
|
265
|
+
}),
|
|
266
|
+
__metadata("design:type", Function),
|
|
267
|
+
__metadata("design:paramtypes", [WalletProvider, void 0]),
|
|
268
|
+
__metadata("design:returntype", Promise)
|
|
269
|
+
], MetrikActionProvider.prototype, "checkStreamStatus", null);
|
|
270
|
+
__decorate([
|
|
271
|
+
CreateAction({
|
|
272
|
+
name: "reclaim_unspent",
|
|
273
|
+
description: "Reclaim unspent escrowed USDC from a Metrik stream back to the buyer. Set closeFirst to close an active stream before reclaiming. Runs under the same signed mandate controls.",
|
|
274
|
+
schema: reclaimUnspentSchema,
|
|
275
|
+
}),
|
|
276
|
+
__metadata("design:type", Function),
|
|
277
|
+
__metadata("design:paramtypes", [WalletProvider, void 0]),
|
|
278
|
+
__metadata("design:returntype", Promise)
|
|
279
|
+
], MetrikActionProvider.prototype, "reclaimUnspent", null);
|
|
280
|
+
__decorate([
|
|
281
|
+
CreateAction({
|
|
282
|
+
name: "close_stream",
|
|
283
|
+
description: "Close a Metrik stream, finalizing accrual and stopping further payment. Runs under the same signed mandate controls.",
|
|
284
|
+
schema: closeStreamSchema,
|
|
285
|
+
}),
|
|
286
|
+
__metadata("design:type", Function),
|
|
287
|
+
__metadata("design:paramtypes", [WalletProvider, void 0]),
|
|
288
|
+
__metadata("design:returntype", Promise)
|
|
289
|
+
], MetrikActionProvider.prototype, "closeStream", null);
|
|
290
|
+
/**
|
|
291
|
+
* Factory mirroring AgentKit's `xxxActionProvider()` convention.
|
|
292
|
+
*/
|
|
293
|
+
export function metrikActionProvider(config) {
|
|
294
|
+
return new MetrikActionProvider(config);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Convenience that composes Metrik into an AgentKit instance alongside the CDP
|
|
298
|
+
* wallet provider. From the returned `AgentKit` you can expose Metrik natively
|
|
299
|
+
* via `getLangChainTools`, `getVercelAITools`, or the AgentKit MCP server.
|
|
300
|
+
*/
|
|
301
|
+
export async function createMetrikAgentKit(options) {
|
|
302
|
+
const { AgentKit } = await import("@coinbase/agentkit");
|
|
303
|
+
return AgentKit.from({
|
|
304
|
+
walletProvider: options.walletProvider,
|
|
305
|
+
actionProviders: [
|
|
306
|
+
metrikActionProvider(options.metrik),
|
|
307
|
+
...(options.additionalActionProviders ?? []),
|
|
308
|
+
],
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
function resolveClient(config) {
|
|
312
|
+
if (config.agentClient !== undefined) {
|
|
313
|
+
if (config.sdkConfig !== undefined) {
|
|
314
|
+
throw new MetrikActionProviderConfigError("provide either agentClient or sdkConfig, not both");
|
|
315
|
+
}
|
|
316
|
+
return config.agentClient;
|
|
317
|
+
}
|
|
318
|
+
if (config.sdkConfig !== undefined) {
|
|
319
|
+
return new VerifiedStreamAgentClient(config.sdkConfig, config.createSdkClient === undefined
|
|
320
|
+
? {}
|
|
321
|
+
: { createSdkClient: config.createSdkClient });
|
|
322
|
+
}
|
|
323
|
+
throw new MetrikActionProviderConfigError("MetrikActionProvider requires either an injected agentClient or an sdkConfig (escrow address, chain, rpc, signing account)");
|
|
324
|
+
}
|
|
325
|
+
const USDC_DECIMALS = 6n;
|
|
326
|
+
const USDC_SCALE = 10n ** USDC_DECIMALS;
|
|
327
|
+
function formatUsdc(atomic) {
|
|
328
|
+
const whole = atomic / USDC_SCALE;
|
|
329
|
+
const fraction = atomic % USDC_SCALE;
|
|
330
|
+
if (fraction === 0n) {
|
|
331
|
+
return whole.toString();
|
|
332
|
+
}
|
|
333
|
+
const fractionStr = fraction
|
|
334
|
+
.toString()
|
|
335
|
+
.padStart(Number(USDC_DECIMALS), "0")
|
|
336
|
+
.replace(/0+$/, "");
|
|
337
|
+
return `${whole.toString()}.${fractionStr}`;
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=agentkit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentkit.js","sourceRoot":"","sources":["../../src/frameworks/agentkit.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,kBAAkB,CAAC;AAM1B,OAAO,EACL,cAAc,EACd,YAAY,EACZ,cAAc,GAEf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,gBAAgB,IAAI,uBAAuB,GAG5C,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAA2B,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EACL,kBAAkB,EAClB,yBAAyB,GAQ1B,MAAM,kBAAkB,CAAC;AAE1B;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAElD,MAAM,aAAa,GAAG,CAAC;KACpB,MAAM,EAAE;KACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,wBAAwB,CAAC,CAAC;AACjE,MAAM,aAAa,GAAG,CAAC;KACpB,M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CAAC;AACzB,MAAM,UAAU,GAAG,GAAG,IAAI,aAAa,CAAC;AAExC,SAAS,UAAU,CAAC,MAAc;IAChC,MAAM,KAAK,GAAG,MAAM,GAAG,UAAU,CAAC;IAClC,MAAM,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACrC,IAAI,QAAQ,KAAK,EAAE,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IACD,MAAM,WAAW,GAAG,QAAQ;SACzB,QAAQ,EAAE;SACV,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,GAAG,CAAC;SACpC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACtB,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,WAAW,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const CREWAI_VERIFIED_STREAM_TOOL_NAMES: readonly ["discover_services", "hire_verified_service", "check_stream_status", "reclaim_unspent", "list_streams"];
|
|
2
|
+
export interface CrewAiVerifiedStreamMcpConfig {
|
|
3
|
+
readonly transport: "stdio";
|
|
4
|
+
readonly command: string;
|
|
5
|
+
readonly args: readonly string[];
|
|
6
|
+
readonly env: Readonly<Record<string, string>>;
|
|
7
|
+
readonly allowedToolNames: readonly string[];
|
|
8
|
+
readonly cacheToolsList: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface CrewAiVerifiedStreamMcpConfigOptions {
|
|
11
|
+
readonly command?: string;
|
|
12
|
+
readonly args?: readonly string[];
|
|
13
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
14
|
+
readonly allowedToolNames?: readonly string[];
|
|
15
|
+
readonly cacheToolsList?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function createCrewAiVerifiedStreamMcpConfig(options?: CrewAiVerifiedStreamMcpConfigOptions): CrewAiVerifiedStreamMcpConfig;
|
|
18
|
+
export declare function renderCrewAiVerifiedStreamPythonExample(options?: CrewAiVerifiedStreamMcpConfigOptions): string;
|
|
19
|
+
//# sourceMappingURL=crewai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crewai.d.ts","sourceRoot":"","sources":["../../src/frameworks/crewai.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iCAAiC,mHAMpC,CAAC;AAEX,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/C,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,oCAAoC;IACnD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,wBAAgB,mCAAmC,CACjD,OAAO,GAAE,oCAAyC,GACjD,6BAA6B,CAU/B;AAED,wBAAgB,uCAAuC,CACrD,OAAO,GAAE,oCAAyC,GACjD,MAAM,CAiDR"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export const CREWAI_VERIFIED_STREAM_TOOL_NAMES = [
|
|
2
|
+
"discover_services",
|
|
3
|
+
"hire_verified_service",
|
|
4
|
+
"check_stream_status",
|
|
5
|
+
"reclaim_unspent",
|
|
6
|
+
"list_streams",
|
|
7
|
+
];
|
|
8
|
+
export function createCrewAiVerifiedStreamMcpConfig(options = {}) {
|
|
9
|
+
return {
|
|
10
|
+
transport: "stdio",
|
|
11
|
+
command: options.command ?? "pnpm",
|
|
12
|
+
args: options.args ?? ["mcp:stdio"],
|
|
13
|
+
env: options.env ?? {},
|
|
14
|
+
allowedToolNames: options.allowedToolNames ?? CREWAI_VERIFIED_STREAM_TOOL_NAMES,
|
|
15
|
+
cacheToolsList: options.cacheToolsList ?? true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function renderCrewAiVerifiedStreamPythonExample(options = {}) {
|
|
19
|
+
const config = createCrewAiVerifiedStreamMcpConfig(options);
|
|
20
|
+
const envEntries = Object.entries(config.env)
|
|
21
|
+
.map(([key, value]) => ` "${escapePythonString(key)}": "${escapePythonString(value)}",`)
|
|
22
|
+
.join("\n");
|
|
23
|
+
const toolNames = config.allowedToolNames
|
|
24
|
+
.map((name) => ` "${escapePythonString(name)}",`)
|
|
25
|
+
.join("\n");
|
|
26
|
+
return [
|
|
27
|
+
"from crewai import Agent, Crew, Task",
|
|
28
|
+
"from crewai.mcp import MCPServerStdio",
|
|
29
|
+
"from crewai.mcp.filters import create_static_tool_filter",
|
|
30
|
+
"",
|
|
31
|
+
"metrik_mcp = MCPServerStdio(",
|
|
32
|
+
` command="${escapePythonString(config.command)}",`,
|
|
33
|
+
` args=${renderPythonList(config.args)},`,
|
|
34
|
+
" env={",
|
|
35
|
+
envEntries,
|
|
36
|
+
" },",
|
|
37
|
+
" tool_filter=create_static_tool_filter(",
|
|
38
|
+
" allowed_tool_names=[",
|
|
39
|
+
toolNames,
|
|
40
|
+
" ]",
|
|
41
|
+
" ),",
|
|
42
|
+
` cache_tools_list=${config.cacheToolsList ? "True" : "False"},`,
|
|
43
|
+
")",
|
|
44
|
+
"",
|
|
45
|
+
"buyer_agent = Agent(",
|
|
46
|
+
' role="Verified Compute Buyer",',
|
|
47
|
+
' goal="Hire a verified service and stop work when the stream pauses.",',
|
|
48
|
+
' backstory="An operator that only pays for oracle-verified delivery.",',
|
|
49
|
+
" mcps=[metrik_mcp],",
|
|
50
|
+
")",
|
|
51
|
+
"",
|
|
52
|
+
"task = Task(",
|
|
53
|
+
' description="Use hire_verified_service to open a stream, then call check_stream_status to monitor it.",',
|
|
54
|
+
' expected_output="A stream id plus the current verified stream status.",',
|
|
55
|
+
" agent=buyer_agent,",
|
|
56
|
+
")",
|
|
57
|
+
"",
|
|
58
|
+
"crew = Crew(agents=[buyer_agent], tasks=[task])",
|
|
59
|
+
"result = crew.kickoff()",
|
|
60
|
+
"print(result)",
|
|
61
|
+
"",
|
|
62
|
+
].join("\n");
|
|
63
|
+
}
|
|
64
|
+
function renderPythonList(values) {
|
|
65
|
+
const rendered = values
|
|
66
|
+
.map((value) => `"${escapePythonString(value)}"`)
|
|
67
|
+
.join(", ");
|
|
68
|
+
return `[${rendered}]`;
|
|
69
|
+
}
|
|
70
|
+
function escapePythonString(value) {
|
|
71
|
+
return value.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=crewai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crewai.js","sourceRoot":"","sources":["../../src/frameworks/crewai.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,mBAAmB;IACnB,uBAAuB;IACvB,qBAAqB;IACrB,iBAAiB;IACjB,cAAc;CACN,CAAC;AAmBX,MAAM,UAAU,mCAAmC,CACjD,UAAgD,EAAE;IAElD,OAAO;QACL,SAAS,EAAE,OAAO;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,MAAM;QAClC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC;QACnC,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE;QACtB,g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