@leashmarket/mcp-core 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/helpers/base64-json.d.ts +9 -0
- package/dist/helpers/base64-json.d.ts.map +1 -0
- package/dist/helpers/base64-json.js +16 -0
- package/dist/helpers/base64-json.js.map +1 -0
- package/dist/helpers/discover-reputation.d.ts +118 -0
- package/dist/helpers/discover-reputation.d.ts.map +1 -0
- package/dist/helpers/discover-reputation.js +148 -0
- package/dist/helpers/discover-reputation.js.map +1 -0
- package/dist/helpers/index.d.ts +6 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +6 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/probe-payment-link.d.ts +22 -0
- package/dist/helpers/probe-payment-link.d.ts.map +1 -0
- package/dist/helpers/probe-payment-link.js +78 -0
- package/dist/helpers/probe-payment-link.js.map +1 -0
- package/dist/helpers/solana-address.d.ts +8 -0
- package/dist/helpers/solana-address.d.ts.map +1 -0
- package/dist/helpers/solana-address.js +15 -0
- package/dist/helpers/solana-address.js.map +1 -0
- package/dist/helpers/token-catalog.d.ts +35 -0
- package/dist/helpers/token-catalog.d.ts.map +1 -0
- package/dist/helpers/token-catalog.js +83 -0
- package/dist/helpers/token-catalog.js.map +1 -0
- package/dist/host.d.ts +326 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +20 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/tool.d.ts +64 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +40 -0
- package/dist/tool.js.map +1 -0
- package/dist/tools/check-balances.d.ts +2 -0
- package/dist/tools/check-balances.d.ts.map +1 -0
- package/dist/tools/check-balances.js +15 -0
- package/dist/tools/check-balances.js.map +1 -0
- package/dist/tools/create-payment-link.d.ts +2 -0
- package/dist/tools/create-payment-link.d.ts.map +1 -0
- package/dist/tools/create-payment-link.js +28 -0
- package/dist/tools/create-payment-link.js.map +1 -0
- package/dist/tools/daily-transactions.d.ts +26 -0
- package/dist/tools/daily-transactions.d.ts.map +1 -0
- package/dist/tools/daily-transactions.js +47 -0
- package/dist/tools/daily-transactions.js.map +1 -0
- package/dist/tools/discover.d.ts +2 -0
- package/dist/tools/discover.d.ts.map +1 -0
- package/dist/tools/discover.js +40 -0
- package/dist/tools/discover.js.map +1 -0
- package/dist/tools/get-identity.d.ts +2 -0
- package/dist/tools/get-identity.d.ts.map +1 -0
- package/dist/tools/get-identity.js +14 -0
- package/dist/tools/get-identity.js.map +1 -0
- package/dist/tools/get-receipt.d.ts +22 -0
- package/dist/tools/get-receipt.d.ts.map +1 -0
- package/dist/tools/get-receipt.js +41 -0
- package/dist/tools/get-receipt.js.map +1 -0
- package/dist/tools/get-spend-limit.d.ts +14 -0
- package/dist/tools/get-spend-limit.d.ts.map +1 -0
- package/dist/tools/get-spend-limit.js +31 -0
- package/dist/tools/get-spend-limit.js.map +1 -0
- package/dist/tools/index.d.ts +28 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +43 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/pay-payment-link.d.ts +2 -0
- package/dist/tools/pay-payment-link.d.ts.map +1 -0
- package/dist/tools/pay-payment-link.js +18 -0
- package/dist/tools/pay-payment-link.js.map +1 -0
- package/dist/tools/pay-skills-endpoints.d.ts +2 -0
- package/dist/tools/pay-skills-endpoints.d.ts.map +1 -0
- package/dist/tools/pay-skills-endpoints.js +28 -0
- package/dist/tools/pay-skills-endpoints.js.map +1 -0
- package/dist/tools/receipts.d.ts +2 -0
- package/dist/tools/receipts.d.ts.map +1 -0
- package/dist/tools/receipts.js +26 -0
- package/dist/tools/receipts.js.map +1 -0
- package/dist/tools/register-agent.d.ts +2 -0
- package/dist/tools/register-agent.d.ts.map +1 -0
- package/dist/tools/register-agent.js +62 -0
- package/dist/tools/register-agent.js.map +1 -0
- package/dist/tools/reputation.d.ts +2 -0
- package/dist/tools/reputation.d.ts.map +1 -0
- package/dist/tools/reputation.js +24 -0
- package/dist/tools/reputation.js.map +1 -0
- package/dist/tools/set-spend-limit.d.ts +23 -0
- package/dist/tools/set-spend-limit.d.ts.map +1 -0
- package/dist/tools/set-spend-limit.js +52 -0
- package/dist/tools/set-spend-limit.js.map +1 -0
- package/dist/tools/transaction-history.d.ts +23 -0
- package/dist/tools/transaction-history.d.ts.map +1 -0
- package/dist/tools/transaction-history.js +55 -0
- package/dist/tools/transaction-history.js.map +1 -0
- package/dist/tools/withdraw-treasury.d.ts +2 -0
- package/dist/tools/withdraw-treasury.d.ts.map +1 -0
- package/dist/tools/withdraw-treasury.js +29 -0
- package/dist/tools/withdraw-treasury.js.map +1 -0
- package/package.json +41 -0
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `LeashHost` is the runtime contract every Leash MCP host (chat
|
|
3
|
+
* product, standalone STDIO MCP, CLI, etc.) implements. The shared
|
|
4
|
+
* tool definitions in `./tools` delegate to this interface, so the
|
|
5
|
+
* same tool name + schema works across surfaces with completely
|
|
6
|
+
* different settlement semantics:
|
|
7
|
+
*
|
|
8
|
+
* - Chat product: `pay()` returns a `payment_request` artifact (the
|
|
9
|
+
* UI renders a "Pay" card; the user signs in their browser via
|
|
10
|
+
* Privy). Treasury reads happen server-side over the cluster RPC.
|
|
11
|
+
*
|
|
12
|
+
* - Standalone MCP / CLI: `pay()` actually settles the payment by
|
|
13
|
+
* signing the buyer-kit transfer with the local executive
|
|
14
|
+
* keypair and returns the receipt. No human in the loop.
|
|
15
|
+
*
|
|
16
|
+
* Adding a new tool is one file in `./tools` plus one method on each
|
|
17
|
+
* implementer of this interface.
|
|
18
|
+
*/
|
|
19
|
+
import type { LeashToolResult } from './tool.js';
|
|
20
|
+
/** SVM cluster slugs as used by the Leash API + Metaplex SDK. */
|
|
21
|
+
export type SvmNetwork = 'solana-devnet' | 'solana-mainnet';
|
|
22
|
+
/** Stablecoins the Leash treasury supports across networks. */
|
|
23
|
+
export type StableSymbol = 'USDC' | 'USDG' | 'USDT';
|
|
24
|
+
/** Tokens supported by the withdraw tool — adds SOL on top of stables. */
|
|
25
|
+
export type WithdrawableToken = 'SOL' | StableSymbol;
|
|
26
|
+
export type CreatePaymentLinkArgs = {
|
|
27
|
+
amount: number;
|
|
28
|
+
currency: StableSymbol;
|
|
29
|
+
label: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
};
|
|
32
|
+
export type PayArgs = {
|
|
33
|
+
url: string;
|
|
34
|
+
};
|
|
35
|
+
export type WithdrawArgs = {
|
|
36
|
+
token: WithdrawableToken;
|
|
37
|
+
amount: number;
|
|
38
|
+
destination: string;
|
|
39
|
+
};
|
|
40
|
+
export type CheckTreasuryBalanceArgs = {
|
|
41
|
+
symbol?: string;
|
|
42
|
+
};
|
|
43
|
+
export type RegisterAgentArgs = {
|
|
44
|
+
/**
|
|
45
|
+
* Friendly agent name recorded in MPL Core metadata. Optional —
|
|
46
|
+
* defaults to `Agent <executive_pubkey[0..8]>` when omitted.
|
|
47
|
+
*/
|
|
48
|
+
name?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Free-text description recorded in the MPL Core asset and the
|
|
51
|
+
* EIP-8004 RegistrationV1 metadata doc.
|
|
52
|
+
*/
|
|
53
|
+
description?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Optional public image URL written into the RegistrationV1
|
|
56
|
+
* metadata's `image` field (e.g. an avatar / logo).
|
|
57
|
+
*/
|
|
58
|
+
image_url?: string;
|
|
59
|
+
/**
|
|
60
|
+
* EIP-8004 RegistrationV1 `services[]` entries the agent
|
|
61
|
+
* advertises. Threaded into three places at mint time:
|
|
62
|
+
* 1. On-chain MPL Core `agentMetadata.services[]`.
|
|
63
|
+
* 2. Off-chain RegistrationV1 doc embedded in the asset `uri`.
|
|
64
|
+
* 3. Platform `services` column written by `/v1/agents/record`.
|
|
65
|
+
* The Leash protocol always auto-injects a `receipts` entry, so
|
|
66
|
+
* callers don't need to supply one. Each entry must be `{ name,
|
|
67
|
+
* endpoint }` where `endpoint` is a valid URL.
|
|
68
|
+
*
|
|
69
|
+
* Persisted alongside the executive in `pending_register` so the
|
|
70
|
+
* SECOND `leash_register_agent` call (after the user funds the
|
|
71
|
+
* pubkey) doesn't need to re-collect them.
|
|
72
|
+
*/
|
|
73
|
+
services?: {
|
|
74
|
+
name: string;
|
|
75
|
+
endpoint: string;
|
|
76
|
+
}[];
|
|
77
|
+
/**
|
|
78
|
+
* Owner-keypair source.
|
|
79
|
+
* - `'generate'` (default) — host generates a fresh ed25519 keypair
|
|
80
|
+
* locally, persists it to `~/.config/leash/agent.json` under
|
|
81
|
+
* `pending_register`, and asks the user to fund it.
|
|
82
|
+
* - `'import'` — caller supplies an existing keypair via
|
|
83
|
+
* `executive_secret_base58`. Same persistence + funding-check
|
|
84
|
+
* path; the caller stays in control of the signing key.
|
|
85
|
+
*
|
|
86
|
+
* The mode is only consulted on the FIRST call. Subsequent calls
|
|
87
|
+
* (after the user funds the executive) ignore `mode` and resume
|
|
88
|
+
* from `pending_register`.
|
|
89
|
+
*/
|
|
90
|
+
mode?: 'generate' | 'import';
|
|
91
|
+
/**
|
|
92
|
+
* Required when `mode === 'import'`. The executive's 64-byte
|
|
93
|
+
* ed25519 secret key, base58-encoded. The host validates the
|
|
94
|
+
* length + curve before persisting and never echoes the secret
|
|
95
|
+
* back in any tool response.
|
|
96
|
+
*/
|
|
97
|
+
executive_secret_base58?: string;
|
|
98
|
+
};
|
|
99
|
+
export type GetIdentityArgs = Record<string, never>;
|
|
100
|
+
export type ReceiptsArgs = {
|
|
101
|
+
/** Filter by direction. `'both'` returns spend + earn receipts. */
|
|
102
|
+
direction?: 'both' | 'outgoing' | 'incoming';
|
|
103
|
+
/** Max items to return. Capped server-side. */
|
|
104
|
+
limit?: number;
|
|
105
|
+
};
|
|
106
|
+
export type DiscoverArgs = {
|
|
107
|
+
/** Free-text capability label (e.g. "ocr", "weather"). */
|
|
108
|
+
capability?: string;
|
|
109
|
+
/** Maximum decimal USDC price per call. */
|
|
110
|
+
max_price_usdc?: number;
|
|
111
|
+
/** Pricing-type filter. */
|
|
112
|
+
pricing_type?: 'free' | 'per_call' | 'variable';
|
|
113
|
+
/**
|
|
114
|
+
* Restrict to a single catalogue:
|
|
115
|
+
* - `'leash'`: agents listed on the Leash marketplace.
|
|
116
|
+
* - `'pay-skills'`: providers in the Solana Foundation
|
|
117
|
+
* `pay-skills` registry.
|
|
118
|
+
* - `'all'` (default): merged.
|
|
119
|
+
*/
|
|
120
|
+
source?: 'leash' | 'pay-skills' | 'all';
|
|
121
|
+
/** Max items to return. Server-capped. */
|
|
122
|
+
limit?: number;
|
|
123
|
+
};
|
|
124
|
+
export type ReputationArgs = {
|
|
125
|
+
agent_mint: string;
|
|
126
|
+
network?: SvmNetwork;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Inputs for `leash_pay_skills_endpoints` — expand a chosen
|
|
130
|
+
* `pay-skills` provider (returned by `leash_discover`) into its
|
|
131
|
+
* paid endpoint list. Mirrors `pay skills endpoints <fqn>` from the
|
|
132
|
+
* pay.sh CLI.
|
|
133
|
+
*/
|
|
134
|
+
export type PaySkillsProviderArgs = {
|
|
135
|
+
/**
|
|
136
|
+
* Fully-qualified provider name as published in the catalogue.
|
|
137
|
+
* Two- or three-segment paths, e.g. `agentmail/email` or
|
|
138
|
+
* `coinbase-cdp/coinbase-developer-platform/baseSepoliaWalletApi`.
|
|
139
|
+
* Lift this verbatim from a `leash_discover` item that has
|
|
140
|
+
* `source === 'pay-skills'` (the FQN lives in `slug`).
|
|
141
|
+
*/
|
|
142
|
+
fqn: string;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Inputs for `leash_set_spend_limit`. Lets the owner change the cap
|
|
146
|
+
* the agent treasury PDA delegates to the executive keypair for an
|
|
147
|
+
* SPL stable. `unlimited` writes `u64::MAX`; `revoke` zeros the
|
|
148
|
+
* delegation; an explicit decimal amount sets that cap (in
|
|
149
|
+
* human-readable units of the token).
|
|
150
|
+
*/
|
|
151
|
+
export type SetSpendLimitArgs = {
|
|
152
|
+
/** SPL stable to update the delegation for. Defaults to USDC. */
|
|
153
|
+
symbol?: StableSymbol;
|
|
154
|
+
/**
|
|
155
|
+
* What to write.
|
|
156
|
+
* - `'unlimited'` (default) — `u64::MAX`, the protocol default.
|
|
157
|
+
* - `'revoke'` — drop the delegation; the executive can no
|
|
158
|
+
* longer move funds from the treasury until re-approved.
|
|
159
|
+
* - `'amount'` — set a custom cap from `amount`.
|
|
160
|
+
*/
|
|
161
|
+
mode?: 'unlimited' | 'revoke' | 'amount';
|
|
162
|
+
/**
|
|
163
|
+
* Required when `mode === 'amount'`. Decimal amount in
|
|
164
|
+
* human-readable units of the token (e.g. `100` = $100 USDC).
|
|
165
|
+
* Server applies the mint's `decimals` before broadcasting.
|
|
166
|
+
*/
|
|
167
|
+
amount?: number;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Inputs for `leash_get_spend_limit`. No knobs beyond the symbol —
|
|
171
|
+
* the host already knows the agent + network from session state.
|
|
172
|
+
*/
|
|
173
|
+
export type GetSpendLimitArgs = {
|
|
174
|
+
/** SPL stable to inspect. Defaults to USDC. */
|
|
175
|
+
symbol?: StableSymbol;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Inputs for `leash_get_receipt`. Looks up one ReceiptV1 by its
|
|
179
|
+
* deterministic `receipt_hash` (the same hash the explorer URL
|
|
180
|
+
* carries: `/receipt/{hash}`). Network is host-bound so a hash from
|
|
181
|
+
* the sibling cluster returns `not_found`.
|
|
182
|
+
*/
|
|
183
|
+
export type GetReceiptArgs = {
|
|
184
|
+
/** 64-hex-char receipt_hash from the seller-side ReceiptV1. */
|
|
185
|
+
receipt_hash: string;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Inputs for `leash_transaction_history`. Lists every receipt for the
|
|
189
|
+
* active agent within the last `days` days, both directions by
|
|
190
|
+
* default. The host paginates the underlying `/v1/receipts/{agent}`
|
|
191
|
+
* feed and trims to the day window client-side.
|
|
192
|
+
*/
|
|
193
|
+
export type TransactionHistoryArgs = {
|
|
194
|
+
/** Window size in days (1 ≤ N ≤ 90). Defaults to 7. */
|
|
195
|
+
days?: number;
|
|
196
|
+
/** Filter by direction. Defaults to `both`. */
|
|
197
|
+
direction?: 'both' | 'outgoing' | 'incoming';
|
|
198
|
+
/** Hard cap on the total receipts returned (default 200, max 1000). */
|
|
199
|
+
limit?: number;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Inputs for `leash_daily_transactions`. Same window as
|
|
203
|
+
* `transaction_history` but the host bins receipts by UTC ingest
|
|
204
|
+
* date and returns per-day aggregates (count + USD-equivalent sums)
|
|
205
|
+
* plus grand totals. Stables (USDC/USDG/USDT) are summed as USD 1:1.
|
|
206
|
+
*/
|
|
207
|
+
export type DailyTransactionsArgs = {
|
|
208
|
+
/** Window size in days (1 ≤ N ≤ 90). Defaults to 7. */
|
|
209
|
+
days?: number;
|
|
210
|
+
};
|
|
211
|
+
export interface LeashHost {
|
|
212
|
+
/** The agent's MPL Core asset address. `null` while the user is in onboarding. */
|
|
213
|
+
agentMint: string | null;
|
|
214
|
+
/** Pubkey of the wallet that owns the agent (Privy embedded wallet OR local executive). */
|
|
215
|
+
ownerWallet: string | null;
|
|
216
|
+
/** Cluster the agent is registered on. */
|
|
217
|
+
network: SvmNetwork;
|
|
218
|
+
/** RPC URL the host's tools should use for direct chain reads. */
|
|
219
|
+
rpcUrl: string;
|
|
220
|
+
/** Base URL of the Leash API (`https://api.leash.market` in prod). */
|
|
221
|
+
apiBaseUrl: string;
|
|
222
|
+
/**
|
|
223
|
+
* Mint a real x402 payment link. Implementations decide how the call
|
|
224
|
+
* authenticates with the Leash API (chat product reveals a stored
|
|
225
|
+
* platform API key; standalone MCP signs an X-Leash-Sig header).
|
|
226
|
+
*/
|
|
227
|
+
createPaymentLink(args: CreatePaymentLinkArgs): Promise<LeashToolResult>;
|
|
228
|
+
/**
|
|
229
|
+
* Pay an x402 link.
|
|
230
|
+
* - chat product impl: probes the URL, returns a `payment_request`
|
|
231
|
+
* artifact for the UI to settle.
|
|
232
|
+
* - standalone MCP impl: probes, signs, settles, and returns the
|
|
233
|
+
* `payment_receipt` blob with the on-chain signature.
|
|
234
|
+
*/
|
|
235
|
+
pay(args: PayArgs): Promise<LeashToolResult>;
|
|
236
|
+
/**
|
|
237
|
+
* Withdraw SOL or an SPL stable from the agent treasury.
|
|
238
|
+
* - chat product impl: validates + returns a `withdraw_request`
|
|
239
|
+
* artifact for the UI.
|
|
240
|
+
* - standalone MCP impl: actually constructs and signs the
|
|
241
|
+
* `mpl-core::Execute` instruction with the local owner key.
|
|
242
|
+
*/
|
|
243
|
+
withdraw(args: WithdrawArgs): Promise<LeashToolResult>;
|
|
244
|
+
/**
|
|
245
|
+
* Read the agent treasury balance. Both surfaces return the same
|
|
246
|
+
* shape (network/RPC reads are host-agnostic).
|
|
247
|
+
*/
|
|
248
|
+
checkTreasuryBalance(args: CheckTreasuryBalanceArgs): Promise<LeashToolResult>;
|
|
249
|
+
/**
|
|
250
|
+
* Provision a new on-chain agent for the caller.
|
|
251
|
+
* - standalone MCP impl: hits `POST /v1/sandbox/agent` (devnet),
|
|
252
|
+
* writes `~/.config/leash/agent.json` with the returned secret,
|
|
253
|
+
* returns the funding details.
|
|
254
|
+
* - chat product impl: returns a `kind: 'register_agent', status:
|
|
255
|
+
* 'manual'` blob telling the model to direct the user to
|
|
256
|
+
* "Profile → Agent" (the chat UI handles minting today).
|
|
257
|
+
*/
|
|
258
|
+
registerAgent(args: RegisterAgentArgs): Promise<LeashToolResult>;
|
|
259
|
+
/**
|
|
260
|
+
* Self-introspection — what agent am I, what's my network, who's
|
|
261
|
+
* the executive. Both impls read from local context and never hit
|
|
262
|
+
* the network. Cheap by design so the LLM can call it freely.
|
|
263
|
+
*/
|
|
264
|
+
getIdentity(args: GetIdentityArgs): Promise<LeashToolResult>;
|
|
265
|
+
/**
|
|
266
|
+
* List recent receipts for the active agent. Both impls call the
|
|
267
|
+
* Leash API; the standalone host uses the legacy API-key bearer
|
|
268
|
+
* until X-Leash-Sig auth lands in batch 6.
|
|
269
|
+
*/
|
|
270
|
+
receipts(args: ReceiptsArgs): Promise<LeashToolResult>;
|
|
271
|
+
/**
|
|
272
|
+
* Search the Leash marketplace for paid services by capability +
|
|
273
|
+
* price. Public — both hosts hit `GET /v1/discover` directly.
|
|
274
|
+
*/
|
|
275
|
+
discover(args: DiscoverArgs): Promise<LeashToolResult>;
|
|
276
|
+
/**
|
|
277
|
+
* Pull the live reputation snapshot for any on-chain agent. Public
|
|
278
|
+
* — both hosts hit `GET /v1/agents/:mint/reputation` directly.
|
|
279
|
+
*/
|
|
280
|
+
reputation(args: ReputationArgs): Promise<LeashToolResult>;
|
|
281
|
+
/**
|
|
282
|
+
* Expand a `pay-skills` discover item into its paid endpoints.
|
|
283
|
+
* Public — hits `GET /v1/discover/pay-skills/:fqn` directly. The
|
|
284
|
+
* returned `endpoint_urls[]` are absolute URLs the agent can pay
|
|
285
|
+
* via `pay()` without any extra plumbing.
|
|
286
|
+
*/
|
|
287
|
+
paySkillsProvider(args: PaySkillsProviderArgs): Promise<LeashToolResult>;
|
|
288
|
+
/**
|
|
289
|
+
* Owner-driven update of the SPL `Approve` delegation that lets
|
|
290
|
+
* the executive spend stables out of the agent treasury PDA.
|
|
291
|
+
* Standalone MCP / CLI signs the `mpl-core::Execute(SPL.Approve|Revoke)`
|
|
292
|
+
* tx with the local owner key; chat product returns a
|
|
293
|
+
* `kind: 'spend_limit', status: 'manual'` artifact pointing the
|
|
294
|
+
* user at the Profile → Agent UI.
|
|
295
|
+
*/
|
|
296
|
+
setSpendLimit(args: SetSpendLimitArgs): Promise<LeashToolResult>;
|
|
297
|
+
/**
|
|
298
|
+
* Read the current delegation + treasury balance for an SPL stable.
|
|
299
|
+
* Cheap — host-agnostic RPC read. Returns delegate pubkey,
|
|
300
|
+
* delegated atomic amount + decimal-formatted version, and current
|
|
301
|
+
* balance.
|
|
302
|
+
*/
|
|
303
|
+
getSpendLimit(args: GetSpendLimitArgs): Promise<LeashToolResult>;
|
|
304
|
+
/**
|
|
305
|
+
* Look up a single receipt by its `receipt_hash`. Returns the full
|
|
306
|
+
* ReceiptV1 (the same JSON the explorer renders at
|
|
307
|
+
* `/receipt/{hash}`) plus a few convenience fields the LLM can
|
|
308
|
+
* inline into a reply (explorer URL, direction, ingested_at).
|
|
309
|
+
*/
|
|
310
|
+
getReceipt(args: GetReceiptArgs): Promise<LeashToolResult>;
|
|
311
|
+
/**
|
|
312
|
+
* List every receipt for the active agent within the last `days`
|
|
313
|
+
* days, both directions by default. The host paginates the
|
|
314
|
+
* underlying `/v1/receipts/{agent}` feed and trims to the window
|
|
315
|
+
* client-side. Returns the receipts plus running USD totals.
|
|
316
|
+
*/
|
|
317
|
+
transactionHistory(args: TransactionHistoryArgs): Promise<LeashToolResult>;
|
|
318
|
+
/**
|
|
319
|
+
* Bin the same receipts as `transactionHistory` by UTC ingest date
|
|
320
|
+
* and return per-day aggregates (count + USD-equivalent sums for
|
|
321
|
+
* each direction) plus grand totals. Useful for "show me last
|
|
322
|
+
* week's revenue" style prompts.
|
|
323
|
+
*/
|
|
324
|
+
dailyTransactions(args: DailyTransactionsArgs): Promise<LeashToolResult>;
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,gBAAgB,CAA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;IACH,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE3D;;;;;OAKG;IACH,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEzE;;;;;;;OAOG;IACH,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEjE;;;;;OAKG;IACH,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEjE;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE3D;;;;;OAKG;IACH,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE3E;;;;;OAKG;IACH,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC1E"}
|
package/dist/host.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `LeashHost` is the runtime contract every Leash MCP host (chat
|
|
3
|
+
* product, standalone STDIO MCP, CLI, etc.) implements. The shared
|
|
4
|
+
* tool definitions in `./tools` delegate to this interface, so the
|
|
5
|
+
* same tool name + schema works across surfaces with completely
|
|
6
|
+
* different settlement semantics:
|
|
7
|
+
*
|
|
8
|
+
* - Chat product: `pay()` returns a `payment_request` artifact (the
|
|
9
|
+
* UI renders a "Pay" card; the user signs in their browser via
|
|
10
|
+
* Privy). Treasury reads happen server-side over the cluster RPC.
|
|
11
|
+
*
|
|
12
|
+
* - Standalone MCP / CLI: `pay()` actually settles the payment by
|
|
13
|
+
* signing the buyer-kit transfer with the local executive
|
|
14
|
+
* keypair and returns the receipt. No human in the loop.
|
|
15
|
+
*
|
|
16
|
+
* Adding a new tool is one file in `./tools` plus one method on each
|
|
17
|
+
* implementer of this interface.
|
|
18
|
+
*/
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=host.js.map
|
package/dist/host.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@leashmarket/mcp-core` — host-agnostic core for every Leash MCP surface.
|
|
3
|
+
*
|
|
4
|
+
* What lives here
|
|
5
|
+
* ---------------
|
|
6
|
+
* - `LeashHost` : runtime contract every host implements
|
|
7
|
+
* - `LeashTool` : tool-definition primitive (name, schema, handler)
|
|
8
|
+
* - `LEASH_TOOLS` : the canonical tool list adapters iterate
|
|
9
|
+
* - `helpers/*` : pure utilities (probe, address-shape, token catalog)
|
|
10
|
+
*
|
|
11
|
+
* What does NOT live here
|
|
12
|
+
* -----------------------
|
|
13
|
+
* Anything that takes a hard dep on a specific runtime (Claude Agent
|
|
14
|
+
* SDK, `@modelcontextprotocol/sdk`, Node-only modules, browser-only
|
|
15
|
+
* modules). Adapters glue this package to those runtimes.
|
|
16
|
+
*/
|
|
17
|
+
export type { LeashHost, SvmNetwork, StableSymbol, WithdrawableToken, CreatePaymentLinkArgs, PayArgs, WithdrawArgs, CheckTreasuryBalanceArgs, RegisterAgentArgs, GetIdentityArgs, ReceiptsArgs, DiscoverArgs, PaySkillsProviderArgs, ReputationArgs, SetSpendLimitArgs, GetSpendLimitArgs, GetReceiptArgs, TransactionHistoryArgs, DailyTransactionsArgs, } from './host.js';
|
|
18
|
+
export { defineTool, jsonResult, noAgentResult, type LeashTool, type LeashToolResult, } from './tool.js';
|
|
19
|
+
export { LEASH_TOOLS, checkBalancesTool, createPaymentLinkTool, dailyTransactionsTool, discoverTool, getIdentityTool, getReceiptTool, getSpendLimitTool, payPaymentLinkTool, paySkillsEndpointsTool, receiptsTool, registerAgentTool, reputationTool, setSpendLimitTool, transactionHistoryTool, withdrawTreasuryTool, } from './tools/index.js';
|
|
20
|
+
export { isLikelyBase58Address, lookupTokenBySymbolSafe, symbolForMintSafe, decodeBase64Json, probePaymentLink, fetchDiscover, fetchPaySkillsProvider, fetchReputation, type TokenMeta, type TokenProgramId, type PaymentRequirementPreview, type DiscoverItem, type DiscoverSource, type PaySkillsEndpoint, type PaySkillsProvider, type ReputationSnapshot, } from './helpers/index.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,YAAY,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,OAAO,EACP,YAAY,EACZ,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAC9B,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@leashmarket/mcp-core` — host-agnostic core for every Leash MCP surface.
|
|
3
|
+
*
|
|
4
|
+
* What lives here
|
|
5
|
+
* ---------------
|
|
6
|
+
* - `LeashHost` : runtime contract every host implements
|
|
7
|
+
* - `LeashTool` : tool-definition primitive (name, schema, handler)
|
|
8
|
+
* - `LEASH_TOOLS` : the canonical tool list adapters iterate
|
|
9
|
+
* - `helpers/*` : pure utilities (probe, address-shape, token catalog)
|
|
10
|
+
*
|
|
11
|
+
* What does NOT live here
|
|
12
|
+
* -----------------------
|
|
13
|
+
* Anything that takes a hard dep on a specific runtime (Claude Agent
|
|
14
|
+
* SDK, `@modelcontextprotocol/sdk`, Node-only modules, browser-only
|
|
15
|
+
* modules). Adapters glue this package to those runtimes.
|
|
16
|
+
*/
|
|
17
|
+
export { defineTool, jsonResult, noAgentResult, } from './tool.js';
|
|
18
|
+
export { LEASH_TOOLS, checkBalancesTool, createPaymentLinkTool, dailyTransactionsTool, discoverTool, getIdentityTool, getReceiptTool, getSpendLimitTool, payPaymentLinkTool, paySkillsEndpointsTool, receiptsTool, registerAgentTool, reputationTool, setSpendLimitTool, transactionHistoryTool, withdrawTreasuryTool, } from './tools/index.js';
|
|
19
|
+
export { isLikelyBase58Address, lookupTokenBySymbolSafe, symbolForMintSafe, decodeBase64Json, probePaymentLink, fetchDiscover, fetchPaySkillsProvider, fetchReputation, } from './helpers/index.js';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAwBH,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,GAGd,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACtB,eAAe,GAShB,MAAM,oBAAoB,CAAC"}
|
package/dist/tool.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-definition primitive shared by every Leash MCP surface. A
|
|
3
|
+
* `LeashTool` is host-agnostic data — name, description, Zod input
|
|
4
|
+
* schema, and a handler that dispatches to the host's typed methods.
|
|
5
|
+
*
|
|
6
|
+
* Each runtime adapter (Claude Agent SDK in `apps/agents`, MCP SDK in
|
|
7
|
+
* `packages/mcp`, CLI in `packages/cli`) wraps these definitions in
|
|
8
|
+
* its own tool-registration call.
|
|
9
|
+
*/
|
|
10
|
+
import type { z } from 'zod';
|
|
11
|
+
import type { LeashHost } from './host.js';
|
|
12
|
+
/**
|
|
13
|
+
* Result shape both Anthropic's Claude Agent SDK and `@modelcontextprotocol/sdk`
|
|
14
|
+
* accept verbatim — a list of typed content parts. We only emit text
|
|
15
|
+
* parts; the JSON payload is stringified into the single text content
|
|
16
|
+
* (downstream models parse it as JSON).
|
|
17
|
+
*/
|
|
18
|
+
export type LeashToolResult = {
|
|
19
|
+
content: {
|
|
20
|
+
type: 'text';
|
|
21
|
+
text: string;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A tool definition is intentionally non-generic on its `inputSchema`
|
|
26
|
+
* so the canonical `LEASH_TOOLS` array can hold tools that have
|
|
27
|
+
* different schemas without TypeScript variance complaints. Use the
|
|
28
|
+
* `defineTool` helper below to author tools with type-safe arguments.
|
|
29
|
+
*/
|
|
30
|
+
export interface LeashTool {
|
|
31
|
+
/** Tool name as exposed to the LLM (`leash_*` prefix is convention). */
|
|
32
|
+
name: string;
|
|
33
|
+
/** Description the LLM sees when deciding whether to call this tool. */
|
|
34
|
+
description: string;
|
|
35
|
+
/** Zod schema for the structured input arguments. */
|
|
36
|
+
inputSchema: z.ZodTypeAny;
|
|
37
|
+
/** Async handler. Returns whatever JSON shape makes sense for the host. */
|
|
38
|
+
handler: (args: unknown, ctx: LeashHost) => Promise<LeashToolResult>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Authoring helper that preserves type-safe `args` inside the handler
|
|
42
|
+
* while erasing the schema generic on the returned `LeashTool` so it
|
|
43
|
+
* fits in the canonical array.
|
|
44
|
+
*/
|
|
45
|
+
export declare function defineTool<TSchema extends z.ZodTypeAny>(def: {
|
|
46
|
+
name: string;
|
|
47
|
+
description: string;
|
|
48
|
+
inputSchema: TSchema;
|
|
49
|
+
handler: (args: z.infer<TSchema>, ctx: LeashHost) => Promise<LeashToolResult>;
|
|
50
|
+
}): LeashTool;
|
|
51
|
+
/**
|
|
52
|
+
* Wrap an arbitrary JSON-serializable payload into the
|
|
53
|
+
* `{ content: [{ type: 'text', text: <stringified> }] }` shape both
|
|
54
|
+
* SDKs expect. Used by every tool's handler so the on-the-wire format
|
|
55
|
+
* stays consistent.
|
|
56
|
+
*/
|
|
57
|
+
export declare function jsonResult(payload: unknown): LeashToolResult;
|
|
58
|
+
/**
|
|
59
|
+
* Helper for the `agentMint == null` branch most tools share — surfaces
|
|
60
|
+
* a `no_agent` JSON blob the LLM is trained to format as "ask the user
|
|
61
|
+
* to mint an agent first".
|
|
62
|
+
*/
|
|
63
|
+
export declare function noAgentResult(kind: string, message?: string): LeashToolResult;
|
|
64
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC3C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,WAAW,EAAE,CAAC,CAAC,UAAU,CAAC;IAC1B,2EAA2E;IAC3E,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;CACtE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,UAAU,EAAE,GAAG,EAAE;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;CAC/E,GAAG,SAAS,CAEZ;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,eAAe,CAQ7E"}
|
package/dist/tool.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-definition primitive shared by every Leash MCP surface. A
|
|
3
|
+
* `LeashTool` is host-agnostic data — name, description, Zod input
|
|
4
|
+
* schema, and a handler that dispatches to the host's typed methods.
|
|
5
|
+
*
|
|
6
|
+
* Each runtime adapter (Claude Agent SDK in `apps/agents`, MCP SDK in
|
|
7
|
+
* `packages/mcp`, CLI in `packages/cli`) wraps these definitions in
|
|
8
|
+
* its own tool-registration call.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Authoring helper that preserves type-safe `args` inside the handler
|
|
12
|
+
* while erasing the schema generic on the returned `LeashTool` so it
|
|
13
|
+
* fits in the canonical array.
|
|
14
|
+
*/
|
|
15
|
+
export function defineTool(def) {
|
|
16
|
+
return def;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Wrap an arbitrary JSON-serializable payload into the
|
|
20
|
+
* `{ content: [{ type: 'text', text: <stringified> }] }` shape both
|
|
21
|
+
* SDKs expect. Used by every tool's handler so the on-the-wire format
|
|
22
|
+
* stays consistent.
|
|
23
|
+
*/
|
|
24
|
+
export function jsonResult(payload) {
|
|
25
|
+
return { content: [{ type: 'text', text: JSON.stringify(payload) }] };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Helper for the `agentMint == null` branch most tools share — surfaces
|
|
29
|
+
* a `no_agent` JSON blob the LLM is trained to format as "ask the user
|
|
30
|
+
* to mint an agent first".
|
|
31
|
+
*/
|
|
32
|
+
export function noAgentResult(kind, message) {
|
|
33
|
+
return jsonResult({
|
|
34
|
+
kind,
|
|
35
|
+
status: 'no_agent',
|
|
36
|
+
message: message ??
|
|
37
|
+
'No on-chain agent yet. Mint one with the leash_register_agent tool (or under Profile → Agent in the chat UI) before calling this tool.',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=tool.js.map
|
package/dist/tool.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAiCH;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAA+B,GAKxD;IACC,OAAO,GAA2B,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,OAAgB;IACzC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;AACxE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,OAAgB;IAC1D,OAAO,UAAU,CAAC;QAChB,IAAI;QACJ,MAAM,EAAE,UAAU;QAClB,OAAO,EACL,OAAO;YACP,wIAAwI;KAC3I,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-balances.d.ts","sourceRoot":"","sources":["../../src/tools/check-balances.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,iBAAiB,gCAM5B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineTool } from '../tool.js';
|
|
3
|
+
const inputSchema = z.object({
|
|
4
|
+
symbol: z
|
|
5
|
+
.string()
|
|
6
|
+
.optional()
|
|
7
|
+
.describe('Optional ticker filter — e.g. "USDC". When omitted, returns all balances.'),
|
|
8
|
+
});
|
|
9
|
+
export const checkBalancesTool = defineTool({
|
|
10
|
+
name: 'leash_check_treasury_balance',
|
|
11
|
+
description: 'Read the agent treasury balance — SOL plus every SPL token held (USDC, USDG, USDT pinned even when zero).',
|
|
12
|
+
inputSchema,
|
|
13
|
+
handler: async (args, ctx) => ctx.checkTreasuryBalance(args),
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=check-balances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-balances.js","sourceRoot":"","sources":["../../src/tools/check-balances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,2EAA2E,CAAC;CACzF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;IAC1C,IAAI,EAAE,8BAA8B;IACpC,WAAW,EACT,2GAA2G;IAC7G,WAAW;IACX,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,CAAC;CAC7D,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-payment-link.d.ts","sourceRoot":"","sources":["../../src/tools/create-payment-link.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,qBAAqB,gCAQhC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineTool } from '../tool.js';
|
|
3
|
+
const inputSchema = z.object({
|
|
4
|
+
amount: z
|
|
5
|
+
.number()
|
|
6
|
+
.positive()
|
|
7
|
+
.describe('Amount the buyer must pay. Use whole units (e.g. 20 for 20 USDC).'),
|
|
8
|
+
currency: z
|
|
9
|
+
.enum(['USDC', 'USDG', 'USDT'])
|
|
10
|
+
.default('USDC')
|
|
11
|
+
.describe('Stablecoin to charge in. Defaults to USDC.'),
|
|
12
|
+
label: z
|
|
13
|
+
.string()
|
|
14
|
+
.min(1)
|
|
15
|
+
.max(120)
|
|
16
|
+
.describe('Human-readable label for the link (e.g. "Coffee — large").'),
|
|
17
|
+
description: z.string().max(500).optional(),
|
|
18
|
+
});
|
|
19
|
+
export const createPaymentLinkTool = defineTool({
|
|
20
|
+
name: 'leash_create_payment_link',
|
|
21
|
+
description: [
|
|
22
|
+
'Create an x402 payment link the user (or another agent) can call to pay this agent in USDC/USDG/USDT.',
|
|
23
|
+
'Requires an on-chain agent (treasury). Returns the public share URL on success — quote it back as a markdown link.',
|
|
24
|
+
].join(' '),
|
|
25
|
+
inputSchema,
|
|
26
|
+
handler: async (args, ctx) => ctx.createPaymentLink(args),
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=create-payment-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-payment-link.js","sourceRoot":"","sources":["../../src/tools/create-payment-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,mEAAmE,CAAC;IAChF,QAAQ,EAAE,CAAC;SACR,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;SAC9B,OAAO,CAAC,MAAM,CAAC;SACf,QAAQ,CAAC,4CAA4C,CAAC;IACzD,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,CAAC,4DAA4D,CAAC;IACzE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CAC5C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAC;IAC9C,IAAI,EAAE,2BAA2B;IACjC,WAAW,EAAE;QACX,uGAAuG;QACvG,oHAAoH;KACrH,CAAC,IAAI,CAAC,GAAG,CAAC;IACX,WAAW;IACX,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC;CAC1D,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `leash_daily_transactions` — bin the active agent's earn + spend
|
|
3
|
+
* receipts by UTC day for a rolling window and return per-day
|
|
4
|
+
* aggregates plus grand totals.
|
|
5
|
+
*
|
|
6
|
+
* Operates on the same underlying `/v1/receipts/{agent}` feed as
|
|
7
|
+
* `leash_transaction_history`, but folds individual receipts into
|
|
8
|
+
* per-date buckets. Each bucket reports:
|
|
9
|
+
*
|
|
10
|
+
* - `date` `YYYY-MM-DD` (UTC of `ingested_at`).
|
|
11
|
+
* - `sent_count` # of outgoing (spend) receipts that day.
|
|
12
|
+
* - `sent_usd` USD-equivalent total sent that day.
|
|
13
|
+
* - `received_count` # of incoming (earn) receipts that day.
|
|
14
|
+
* - `received_usd` USD-equivalent total received that day.
|
|
15
|
+
* - `net_usd` `received_usd - sent_usd`.
|
|
16
|
+
*
|
|
17
|
+
* Days with zero activity are still emitted (filled with zeros) so
|
|
18
|
+
* the LLM can render a continuous row without holes. Days are sorted
|
|
19
|
+
* newest-first to match the rest of the receipt surface.
|
|
20
|
+
*
|
|
21
|
+
* Stables (USDC/USDG/USDT) are summed as USD 1:1; receipts in other
|
|
22
|
+
* currencies are counted but excluded from the USD totals (with a
|
|
23
|
+
* `non_usd_count` callout in the response).
|
|
24
|
+
*/
|
|
25
|
+
export declare const dailyTransactionsTool: import("../tool.js").LeashTool;
|
|
26
|
+
//# sourceMappingURL=daily-transactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daily-transactions.d.ts","sourceRoot":"","sources":["../../src/tools/daily-transactions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAkBH,eAAO,MAAM,qBAAqB,gCAUhC,CAAC"}
|