@graphitti/privy-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/README.md +39 -0
- package/dist/catalog.d.ts +7 -0
- package/dist/catalog.js +491 -0
- package/dist/chains.d.ts +9 -0
- package/dist/chains.js +37 -0
- package/dist/credentials.d.ts +20 -0
- package/dist/credentials.js +32 -0
- package/dist/execute.d.ts +5 -0
- package/dist/execute.js +28 -0
- package/dist/graphitti-actions.d.ts +14 -0
- package/dist/graphitti-actions.js +170 -0
- package/dist/http.d.ts +9 -0
- package/dist/http.js +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/mcp-server.d.ts +2 -0
- package/dist/mcp-server.js +75 -0
- package/dist/native-actions.d.ts +23 -0
- package/dist/native-actions.js +494 -0
- package/dist/privy-client.d.ts +93 -0
- package/dist/privy-client.js +133 -0
- package/dist/privy-signer.d.ts +30 -0
- package/dist/privy-signer.js +45 -0
- package/dist/shared.d.ts +3 -0
- package/dist/shared.js +17 -0
- package/dist/types.d.ts +24 -0
- package/dist/types.js +1 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @graphitti/privy-core
|
|
2
|
+
|
|
3
|
+
Shared tool catalog and MCP stdio server for Privy wallet and treasury agent plugins. Exposes `privy_*` tools for native Privy REST (wallets, signing, transfers, policies, intents) and Graphitti-backed workflows and org treasury.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @graphitti/privy-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## MCP server
|
|
12
|
+
|
|
13
|
+
Run the stdio MCP server after setting credentials:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
export PRIVY_APP_ID=your_app_id
|
|
17
|
+
export PRIVY_APP_SECRET=your_app_secret
|
|
18
|
+
npx privy-mcp
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Credentials
|
|
22
|
+
|
|
23
|
+
| Variable | Required | Purpose |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| `PRIVY_APP_ID` | Yes | Privy application ID |
|
|
26
|
+
| `PRIVY_APP_SECRET` | Yes | Privy application secret |
|
|
27
|
+
| `PRIVY_AUTHORIZATION_KEY` | No | Policy-gated wallet RPC signing |
|
|
28
|
+
| `GRAPHITTI_BASE_URL` | No | Graphitti host override |
|
|
29
|
+
| `GRAPHITTI_API_KEY` | No | Graphitti B2B, treasury, and marketplace APIs |
|
|
30
|
+
|
|
31
|
+
## Programmatic use
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { executePrivyTool, listAvailableTools } from "@graphitti/privy-core";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Documentation
|
|
38
|
+
|
|
39
|
+
See [Privy agent plugins](https://github.com/Bleyle823/Graphitti/blob/main/docs/plugins/agent-privy.mdx) in the Graphitti repo.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ExecuteParams, PrivyCredentials, PrivyToolDefinition, ToolResult } from "./types.js";
|
|
2
|
+
export type ToolHandler = (params: ExecuteParams, credentials: PrivyCredentials) => Promise<ToolResult>;
|
|
3
|
+
export declare const PRIVY_TOOL_HANDLERS: Record<string, ToolHandler>;
|
|
4
|
+
export declare const PRIVY_TOOLS: PrivyToolDefinition[];
|
|
5
|
+
export declare function listAvailableTools(credentials: PrivyCredentials): PrivyToolDefinition[];
|
|
6
|
+
export declare function isGraphittiTool(name: string): boolean;
|
|
7
|
+
export declare function getToolDefinition(name: string): PrivyToolDefinition | undefined;
|
package/dist/catalog.js
ADDED
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import { privyAddPayee, privyApproveTreasuryIntent, privyCallWorkflow, privyCreateTreasuryIntent, privyExecuteWorkflow, privyGetExecution, privyGetLinkedWallet, privyGetListing, privyGetTreasury, privyGetTreasuryIntent, privyListPayees, privySearchWorkflows, privyWhoami, } from "./graphitti-actions.js";
|
|
2
|
+
import { privyCreateKeyQuorum, privyCreatePolicy, privyCreateRpcIntent, privyCreateTransferIntent, privyCreateWallet, privyGetBalance, privyGetIntent, privyGetKeyQuorum, privyGetPolicy, privyGetTransaction, privyGetUser, privyGetWallet, privyGetWalletByAddress, privyListIntents, privyListUsers, privyListWallets, privySendTransaction, privySignMessage, privySignTypedData, privyTransfer, privyWalletSwap, privyWalletTransfer, } from "./native-actions.js";
|
|
3
|
+
const walletIdProp = { type: "string", description: "Privy wallet ID (wallet_...)" };
|
|
4
|
+
const networkProp = { type: "string", description: "Network (ethereum, base, base_sepolia, ...)" };
|
|
5
|
+
export const PRIVY_TOOL_HANDLERS = {
|
|
6
|
+
privy_get_user: privyGetUser,
|
|
7
|
+
privy_list_users: privyListUsers,
|
|
8
|
+
privy_list_wallets: privyListWallets,
|
|
9
|
+
privy_create_wallet: privyCreateWallet,
|
|
10
|
+
privy_get_wallet: privyGetWallet,
|
|
11
|
+
privy_get_wallet_by_address: privyGetWalletByAddress,
|
|
12
|
+
privy_get_balance: privyGetBalance,
|
|
13
|
+
privy_get_transaction: privyGetTransaction,
|
|
14
|
+
privy_sign_message: privySignMessage,
|
|
15
|
+
privy_sign_typed_data: privySignTypedData,
|
|
16
|
+
privy_send_transaction: privySendTransaction,
|
|
17
|
+
privy_transfer: privyTransfer,
|
|
18
|
+
privy_wallet_transfer: privyWalletTransfer,
|
|
19
|
+
privy_wallet_swap: privyWalletSwap,
|
|
20
|
+
privy_create_policy: privyCreatePolicy,
|
|
21
|
+
privy_get_policy: privyGetPolicy,
|
|
22
|
+
privy_create_key_quorum: privyCreateKeyQuorum,
|
|
23
|
+
privy_get_key_quorum: privyGetKeyQuorum,
|
|
24
|
+
privy_create_transfer_intent: privyCreateTransferIntent,
|
|
25
|
+
privy_create_rpc_intent: privyCreateRpcIntent,
|
|
26
|
+
privy_get_intent: privyGetIntent,
|
|
27
|
+
privy_list_intents: privyListIntents,
|
|
28
|
+
privy_whoami: privyWhoami,
|
|
29
|
+
privy_search_workflows: privySearchWorkflows,
|
|
30
|
+
privy_get_listing: privyGetListing,
|
|
31
|
+
privy_call_workflow: privyCallWorkflow,
|
|
32
|
+
privy_execute_workflow: privyExecuteWorkflow,
|
|
33
|
+
privy_get_execution: privyGetExecution,
|
|
34
|
+
privy_get_linked_wallet: privyGetLinkedWallet,
|
|
35
|
+
privy_get_treasury: privyGetTreasury,
|
|
36
|
+
privy_list_payees: privyListPayees,
|
|
37
|
+
privy_add_payee: privyAddPayee,
|
|
38
|
+
privy_create_treasury_intent: privyCreateTreasuryIntent,
|
|
39
|
+
privy_get_treasury_intent: privyGetTreasuryIntent,
|
|
40
|
+
privy_approve_treasury_intent: privyApproveTreasuryIntent,
|
|
41
|
+
};
|
|
42
|
+
export const PRIVY_TOOLS = [
|
|
43
|
+
{
|
|
44
|
+
name: "privy_get_user",
|
|
45
|
+
description: "Fetch a Privy user by ID from api.privy.io.",
|
|
46
|
+
category: "users",
|
|
47
|
+
parameters: {
|
|
48
|
+
type: "object",
|
|
49
|
+
properties: { privy_user_id: { type: "string" } },
|
|
50
|
+
required: ["privy_user_id"],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "privy_list_users",
|
|
55
|
+
description: "Search Privy users by email or identifier.",
|
|
56
|
+
category: "users",
|
|
57
|
+
parameters: {
|
|
58
|
+
type: "object",
|
|
59
|
+
properties: { query: { type: "string" } },
|
|
60
|
+
required: ["query"],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "privy_list_wallets",
|
|
65
|
+
description: "List server wallets in the Privy app.",
|
|
66
|
+
category: "wallets",
|
|
67
|
+
parameters: { type: "object", properties: {} },
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "privy_create_wallet",
|
|
71
|
+
description: "Create a new Privy server wallet.",
|
|
72
|
+
category: "wallets",
|
|
73
|
+
optional: true,
|
|
74
|
+
parameters: {
|
|
75
|
+
type: "object",
|
|
76
|
+
properties: { chain_type: { type: "string" } },
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "privy_get_wallet",
|
|
81
|
+
description: "Fetch a Privy wallet by wallet ID (native REST).",
|
|
82
|
+
category: "wallets",
|
|
83
|
+
parameters: {
|
|
84
|
+
type: "object",
|
|
85
|
+
properties: { wallet_id: walletIdProp },
|
|
86
|
+
required: ["wallet_id"],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "privy_get_wallet_by_address",
|
|
91
|
+
description: "Find Privy wallets by onchain address.",
|
|
92
|
+
category: "wallets",
|
|
93
|
+
parameters: {
|
|
94
|
+
type: "object",
|
|
95
|
+
properties: { address: { type: "string" } },
|
|
96
|
+
required: ["address"],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "privy_get_balance",
|
|
101
|
+
description: "Read wallet balance from Privy.",
|
|
102
|
+
category: "wallets",
|
|
103
|
+
parameters: {
|
|
104
|
+
type: "object",
|
|
105
|
+
properties: { wallet_id: walletIdProp, asset: { type: "string" } },
|
|
106
|
+
required: ["wallet_id"],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "privy_get_transaction",
|
|
111
|
+
description: "Fetch a Privy wallet transaction by ID.",
|
|
112
|
+
category: "wallets",
|
|
113
|
+
parameters: {
|
|
114
|
+
type: "object",
|
|
115
|
+
properties: {
|
|
116
|
+
wallet_id: walletIdProp,
|
|
117
|
+
transaction_id: { type: "string" },
|
|
118
|
+
},
|
|
119
|
+
required: ["wallet_id", "transaction_id"],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "privy_sign_message",
|
|
124
|
+
description: "Sign a message with a Privy wallet.",
|
|
125
|
+
category: "sign",
|
|
126
|
+
optional: true,
|
|
127
|
+
parameters: {
|
|
128
|
+
type: "object",
|
|
129
|
+
properties: {
|
|
130
|
+
wallet_id: walletIdProp,
|
|
131
|
+
message: { type: "string" },
|
|
132
|
+
network: networkProp,
|
|
133
|
+
},
|
|
134
|
+
required: ["wallet_id", "message"],
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "privy_sign_typed_data",
|
|
139
|
+
description: "Sign EIP-712 typed data with a Privy wallet.",
|
|
140
|
+
category: "sign",
|
|
141
|
+
optional: true,
|
|
142
|
+
parameters: {
|
|
143
|
+
type: "object",
|
|
144
|
+
properties: {
|
|
145
|
+
wallet_id: walletIdProp,
|
|
146
|
+
typed_data: { type: "string" },
|
|
147
|
+
network: networkProp,
|
|
148
|
+
},
|
|
149
|
+
required: ["wallet_id", "typed_data"],
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: "privy_send_transaction",
|
|
154
|
+
description: "Send a gas-sponsored transaction from a Privy wallet.",
|
|
155
|
+
category: "sign",
|
|
156
|
+
optional: true,
|
|
157
|
+
parameters: {
|
|
158
|
+
type: "object",
|
|
159
|
+
properties: {
|
|
160
|
+
wallet_id: walletIdProp,
|
|
161
|
+
network: networkProp,
|
|
162
|
+
to: { type: "string" },
|
|
163
|
+
data: { type: "string" },
|
|
164
|
+
value: { type: "string" },
|
|
165
|
+
},
|
|
166
|
+
required: ["wallet_id", "to"],
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "privy_transfer",
|
|
171
|
+
description: "Transfer native tokens with Privy gas sponsorship.",
|
|
172
|
+
category: "sign",
|
|
173
|
+
optional: true,
|
|
174
|
+
parameters: {
|
|
175
|
+
type: "object",
|
|
176
|
+
properties: {
|
|
177
|
+
wallet_id: walletIdProp,
|
|
178
|
+
network: networkProp,
|
|
179
|
+
to: { type: "string" },
|
|
180
|
+
amount: { type: "string" },
|
|
181
|
+
},
|
|
182
|
+
required: ["wallet_id", "to", "amount"],
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: "privy_wallet_transfer",
|
|
187
|
+
description: "Direct Privy USDC wallet transfer via api.privy.io. For listed Graphitti payroll flows use privy_call_workflow.",
|
|
188
|
+
category: "sign",
|
|
189
|
+
optional: true,
|
|
190
|
+
parameters: {
|
|
191
|
+
type: "object",
|
|
192
|
+
properties: {
|
|
193
|
+
wallet_id: walletIdProp,
|
|
194
|
+
source_chain: { type: "string" },
|
|
195
|
+
source_asset: { type: "string" },
|
|
196
|
+
amount: { type: "string" },
|
|
197
|
+
destination_address: { type: "string" },
|
|
198
|
+
},
|
|
199
|
+
required: ["wallet_id", "amount", "destination_address", "source_chain", "source_asset"],
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: "privy_wallet_swap",
|
|
204
|
+
description: "Swap assets via Privy wallet actions API.",
|
|
205
|
+
category: "sign",
|
|
206
|
+
optional: true,
|
|
207
|
+
parameters: {
|
|
208
|
+
type: "object",
|
|
209
|
+
properties: {
|
|
210
|
+
wallet_id: walletIdProp,
|
|
211
|
+
chain: { type: "string" },
|
|
212
|
+
from_asset: { type: "string" },
|
|
213
|
+
to_asset: { type: "string" },
|
|
214
|
+
amount: { type: "string" },
|
|
215
|
+
},
|
|
216
|
+
required: ["wallet_id", "from_asset", "to_asset", "amount"],
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: "privy_create_policy",
|
|
221
|
+
description: "Create a Privy authorization policy.",
|
|
222
|
+
category: "controls",
|
|
223
|
+
optional: true,
|
|
224
|
+
parameters: {
|
|
225
|
+
type: "object",
|
|
226
|
+
properties: {
|
|
227
|
+
name: { type: "string" },
|
|
228
|
+
rules_json: { type: "string" },
|
|
229
|
+
owner_id: { type: "string" },
|
|
230
|
+
},
|
|
231
|
+
required: ["name", "rules_json"],
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name: "privy_get_policy",
|
|
236
|
+
description: "Fetch a Privy policy by ID.",
|
|
237
|
+
category: "controls",
|
|
238
|
+
parameters: {
|
|
239
|
+
type: "object",
|
|
240
|
+
properties: { policy_id: { type: "string" } },
|
|
241
|
+
required: ["policy_id"],
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: "privy_create_key_quorum",
|
|
246
|
+
description: "Create a Privy key quorum for org approvals.",
|
|
247
|
+
category: "controls",
|
|
248
|
+
optional: true,
|
|
249
|
+
parameters: {
|
|
250
|
+
type: "object",
|
|
251
|
+
properties: {
|
|
252
|
+
display_name: { type: "string" },
|
|
253
|
+
authorization_threshold: { type: "string" },
|
|
254
|
+
user_ids_json: { type: "string" },
|
|
255
|
+
},
|
|
256
|
+
required: ["display_name", "authorization_threshold"],
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: "privy_get_key_quorum",
|
|
261
|
+
description: "Fetch a Privy key quorum by ID.",
|
|
262
|
+
category: "controls",
|
|
263
|
+
parameters: {
|
|
264
|
+
type: "object",
|
|
265
|
+
properties: { quorum_id: { type: "string" } },
|
|
266
|
+
required: ["quorum_id"],
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
name: "privy_create_transfer_intent",
|
|
271
|
+
description: "Propose a transfer intent for owner quorum approval.",
|
|
272
|
+
category: "intents",
|
|
273
|
+
optional: true,
|
|
274
|
+
parameters: {
|
|
275
|
+
type: "object",
|
|
276
|
+
properties: {
|
|
277
|
+
wallet_id: walletIdProp,
|
|
278
|
+
source_chain: { type: "string" },
|
|
279
|
+
source_asset: { type: "string" },
|
|
280
|
+
amount: { type: "string" },
|
|
281
|
+
destination_address: { type: "string" },
|
|
282
|
+
},
|
|
283
|
+
required: ["wallet_id", "amount", "destination_address", "source_chain", "source_asset"],
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
name: "privy_create_rpc_intent",
|
|
288
|
+
description: "Create an RPC intent for quorum approval.",
|
|
289
|
+
category: "intents",
|
|
290
|
+
optional: true,
|
|
291
|
+
parameters: {
|
|
292
|
+
type: "object",
|
|
293
|
+
properties: {
|
|
294
|
+
wallet_id: walletIdProp,
|
|
295
|
+
rpc_body: { type: "string" },
|
|
296
|
+
},
|
|
297
|
+
required: ["wallet_id", "rpc_body"],
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
name: "privy_get_intent",
|
|
302
|
+
description: "Fetch Privy intent status from api.privy.io.",
|
|
303
|
+
category: "intents",
|
|
304
|
+
parameters: {
|
|
305
|
+
type: "object",
|
|
306
|
+
properties: { intent_id: { type: "string" } },
|
|
307
|
+
required: ["intent_id"],
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
name: "privy_list_intents",
|
|
312
|
+
description: "List Privy intents, optionally filtered by wallet.",
|
|
313
|
+
category: "intents",
|
|
314
|
+
parameters: {
|
|
315
|
+
type: "object",
|
|
316
|
+
properties: { wallet_id: walletIdProp },
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
name: "privy_whoami",
|
|
321
|
+
description: "Graphitti B2B: authenticated user and org when GRAPHITTI_API_KEY is set.",
|
|
322
|
+
category: "graphitti",
|
|
323
|
+
requiresGraphittiKey: true,
|
|
324
|
+
parameters: { type: "object", properties: {} },
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: "privy_search_workflows",
|
|
328
|
+
description: "Graphitti B2B: search listed workflows (default category privy).",
|
|
329
|
+
category: "graphitti",
|
|
330
|
+
parameters: {
|
|
331
|
+
type: "object",
|
|
332
|
+
properties: { q: { type: "string" }, category: { type: "string" } },
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: "privy_get_listing",
|
|
337
|
+
description: "Graphitti B2B: get marketplace listing metadata by slug.",
|
|
338
|
+
category: "graphitti",
|
|
339
|
+
parameters: {
|
|
340
|
+
type: "object",
|
|
341
|
+
properties: { slug: { type: "string" } },
|
|
342
|
+
required: ["slug"],
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
name: "privy_call_workflow",
|
|
347
|
+
description: "Graphitti B2B: execute a listed payroll/treasury workflow by slug (402 if unpaid).",
|
|
348
|
+
category: "graphitti",
|
|
349
|
+
optional: true,
|
|
350
|
+
parameters: {
|
|
351
|
+
type: "object",
|
|
352
|
+
properties: { slug: { type: "string" }, input: { type: "object" } },
|
|
353
|
+
required: ["slug"],
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
name: "privy_execute_workflow",
|
|
358
|
+
description: "Graphitti B2B: execute an owned workflow by id.",
|
|
359
|
+
category: "graphitti",
|
|
360
|
+
optional: true,
|
|
361
|
+
requiresGraphittiKey: true,
|
|
362
|
+
parameters: {
|
|
363
|
+
type: "object",
|
|
364
|
+
properties: { workflow_id: { type: "string" }, input: { type: "object" } },
|
|
365
|
+
required: ["workflow_id"],
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
name: "privy_get_execution",
|
|
370
|
+
description: "Graphitti B2B: poll workflow execution status.",
|
|
371
|
+
category: "graphitti",
|
|
372
|
+
requiresGraphittiKey: true,
|
|
373
|
+
parameters: {
|
|
374
|
+
type: "object",
|
|
375
|
+
properties: { execution_id: { type: "string" } },
|
|
376
|
+
required: ["execution_id"],
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
name: "privy_get_linked_wallet",
|
|
381
|
+
description: "Graphitti B2B: read the user's linked embedded wallet.",
|
|
382
|
+
category: "graphitti",
|
|
383
|
+
requiresGraphittiKey: true,
|
|
384
|
+
parameters: { type: "object", properties: {} },
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
name: "privy_get_treasury",
|
|
388
|
+
description: "Graphitti B2B: org treasury wallet, payees, and recent intents. Not the same as privy_get_wallet.",
|
|
389
|
+
category: "graphitti",
|
|
390
|
+
requiresGraphittiKey: true,
|
|
391
|
+
requiresTreasuryScope: true,
|
|
392
|
+
parameters: { type: "object", properties: {} },
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: "privy_list_payees",
|
|
396
|
+
description: "Graphitti B2B: list org treasury payees.",
|
|
397
|
+
category: "graphitti",
|
|
398
|
+
requiresGraphittiKey: true,
|
|
399
|
+
requiresTreasuryScope: true,
|
|
400
|
+
parameters: { type: "object", properties: {} },
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
name: "privy_add_payee",
|
|
404
|
+
description: "Graphitti B2B: add an org treasury payee.",
|
|
405
|
+
category: "graphitti",
|
|
406
|
+
optional: true,
|
|
407
|
+
requiresGraphittiKey: true,
|
|
408
|
+
requiresTreasuryScope: true,
|
|
409
|
+
parameters: {
|
|
410
|
+
type: "object",
|
|
411
|
+
properties: {
|
|
412
|
+
label: { type: "string" },
|
|
413
|
+
address: { type: "string" },
|
|
414
|
+
default_amount_usdc: { type: "string" },
|
|
415
|
+
chain: { type: "string" },
|
|
416
|
+
},
|
|
417
|
+
required: ["label", "address"],
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
name: "privy_create_treasury_intent",
|
|
422
|
+
description: "Graphitti B2B: create an org treasury payment intent.",
|
|
423
|
+
category: "graphitti",
|
|
424
|
+
optional: true,
|
|
425
|
+
requiresGraphittiKey: true,
|
|
426
|
+
requiresTreasuryScope: true,
|
|
427
|
+
parameters: {
|
|
428
|
+
type: "object",
|
|
429
|
+
properties: {
|
|
430
|
+
amount_usdc: { type: "string" },
|
|
431
|
+
to_address: { type: "string" },
|
|
432
|
+
payee_id: { type: "string" },
|
|
433
|
+
},
|
|
434
|
+
required: ["amount_usdc", "to_address"],
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
name: "privy_get_treasury_intent",
|
|
439
|
+
description: "Graphitti B2B: read org treasury intent status.",
|
|
440
|
+
category: "graphitti",
|
|
441
|
+
requiresGraphittiKey: true,
|
|
442
|
+
requiresTreasuryScope: true,
|
|
443
|
+
parameters: {
|
|
444
|
+
type: "object",
|
|
445
|
+
properties: { intent_id: { type: "string" } },
|
|
446
|
+
required: ["intent_id"],
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
name: "privy_approve_treasury_intent",
|
|
451
|
+
description: "Graphitti B2B: approve and sign an org treasury intent.",
|
|
452
|
+
category: "graphitti",
|
|
453
|
+
optional: true,
|
|
454
|
+
requiresGraphittiKey: true,
|
|
455
|
+
requiresTreasuryScope: true,
|
|
456
|
+
parameters: {
|
|
457
|
+
type: "object",
|
|
458
|
+
properties: { intent_id: { type: "string" } },
|
|
459
|
+
required: ["intent_id"],
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
];
|
|
463
|
+
const GRAPHITTI_NATIVE_PREFIXES = [
|
|
464
|
+
"privy_whoami",
|
|
465
|
+
"privy_search_workflows",
|
|
466
|
+
"privy_get_listing",
|
|
467
|
+
"privy_call_workflow",
|
|
468
|
+
"privy_execute_workflow",
|
|
469
|
+
"privy_get_execution",
|
|
470
|
+
"privy_get_linked_wallet",
|
|
471
|
+
"privy_get_treasury",
|
|
472
|
+
"privy_list_payees",
|
|
473
|
+
"privy_add_payee",
|
|
474
|
+
"privy_create_treasury_intent",
|
|
475
|
+
"privy_get_treasury_intent",
|
|
476
|
+
"privy_approve_treasury_intent",
|
|
477
|
+
];
|
|
478
|
+
export function listAvailableTools(credentials) {
|
|
479
|
+
return PRIVY_TOOLS.filter((tool) => {
|
|
480
|
+
if (tool.requiresGraphittiKey && !credentials.GRAPHITTI_API_KEY?.trim()) {
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
return true;
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
export function isGraphittiTool(name) {
|
|
487
|
+
return GRAPHITTI_NATIVE_PREFIXES.includes(name);
|
|
488
|
+
}
|
|
489
|
+
export function getToolDefinition(name) {
|
|
490
|
+
return PRIVY_TOOLS.find((tool) => tool.name === name);
|
|
491
|
+
}
|
package/dist/chains.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type SupportedChain = {
|
|
2
|
+
id: string;
|
|
3
|
+
chainId: number;
|
|
4
|
+
explorerUrl: string;
|
|
5
|
+
nativeDecimals: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function requireChain(network: string): SupportedChain;
|
|
8
|
+
export declare function toCaip2(chain: SupportedChain): string;
|
|
9
|
+
export declare function parseUnits(value: string, decimals: number): bigint;
|
package/dist/chains.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const CHAINS = {
|
|
2
|
+
ethereum: { id: "ethereum", chainId: 1, explorerUrl: "https://etherscan.io", nativeDecimals: 18 },
|
|
3
|
+
base: { id: "base", chainId: 8453, explorerUrl: "https://basescan.org", nativeDecimals: 18 },
|
|
4
|
+
base_sepolia: {
|
|
5
|
+
id: "base_sepolia",
|
|
6
|
+
chainId: 84_532,
|
|
7
|
+
explorerUrl: "https://sepolia.basescan.org",
|
|
8
|
+
nativeDecimals: 18,
|
|
9
|
+
},
|
|
10
|
+
sepolia: {
|
|
11
|
+
id: "sepolia",
|
|
12
|
+
chainId: 11_155_111,
|
|
13
|
+
explorerUrl: "https://sepolia.etherscan.io",
|
|
14
|
+
nativeDecimals: 18,
|
|
15
|
+
},
|
|
16
|
+
ethereum_sepolia: {
|
|
17
|
+
id: "ethereum_sepolia",
|
|
18
|
+
chainId: 11_155_111,
|
|
19
|
+
explorerUrl: "https://sepolia.etherscan.io",
|
|
20
|
+
nativeDecimals: 18,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
export function requireChain(network) {
|
|
24
|
+
const chain = CHAINS[network];
|
|
25
|
+
if (!chain) {
|
|
26
|
+
throw new Error(`Unsupported network: ${network}`);
|
|
27
|
+
}
|
|
28
|
+
return chain;
|
|
29
|
+
}
|
|
30
|
+
export function toCaip2(chain) {
|
|
31
|
+
return `eip155:${chain.chainId}`;
|
|
32
|
+
}
|
|
33
|
+
export function parseUnits(value, decimals) {
|
|
34
|
+
const [whole, fraction = ""] = value.split(".");
|
|
35
|
+
const padded = `${fraction}${"0".repeat(decimals)}`.slice(0, decimals);
|
|
36
|
+
return BigInt(`${whole}${padded}`);
|
|
37
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PrivyCredentials } from "./types.js";
|
|
2
|
+
export declare function resolveCredentials(env?: NodeJS.ProcessEnv): PrivyCredentials;
|
|
3
|
+
export declare function validatePrivyCredentials(credentials: PrivyCredentials): {
|
|
4
|
+
ok: false;
|
|
5
|
+
error: string;
|
|
6
|
+
appId?: undefined;
|
|
7
|
+
appSecret?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
ok: true;
|
|
10
|
+
appId: string;
|
|
11
|
+
appSecret: string;
|
|
12
|
+
error?: undefined;
|
|
13
|
+
};
|
|
14
|
+
export declare function requirePrivyCredentials(credentials: PrivyCredentials): string | {
|
|
15
|
+
ok: true;
|
|
16
|
+
appId: string;
|
|
17
|
+
appSecret: string;
|
|
18
|
+
error?: undefined;
|
|
19
|
+
};
|
|
20
|
+
export declare function hasGraphittiKey(credentials: PrivyCredentials): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function resolveCredentials(env = process.env) {
|
|
2
|
+
return {
|
|
3
|
+
PRIVY_APP_ID: env.PRIVY_APP_ID?.trim() || env.NEXT_PUBLIC_PRIVY_APP_ID?.trim(),
|
|
4
|
+
PRIVY_APP_SECRET: env.PRIVY_APP_SECRET?.trim(),
|
|
5
|
+
PRIVY_AUTHORIZATION_KEY: env.PRIVY_AUTHORIZATION_KEY?.trim(),
|
|
6
|
+
GRAPHITTI_BASE_URL: env.GRAPHITTI_BASE_URL?.trim() || "https://graphitti-five.vercel.app",
|
|
7
|
+
GRAPHITTI_API_KEY: env.GRAPHITTI_API_KEY?.trim(),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function validatePrivyCredentials(credentials) {
|
|
11
|
+
if (!credentials.PRIVY_APP_ID?.trim()) {
|
|
12
|
+
return { ok: false, error: "PRIVY_APP_ID is not configured." };
|
|
13
|
+
}
|
|
14
|
+
if (!credentials.PRIVY_APP_SECRET?.trim()) {
|
|
15
|
+
return { ok: false, error: "PRIVY_APP_SECRET is not configured." };
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
ok: true,
|
|
19
|
+
appId: credentials.PRIVY_APP_ID.trim(),
|
|
20
|
+
appSecret: credentials.PRIVY_APP_SECRET.trim(),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function requirePrivyCredentials(credentials) {
|
|
24
|
+
const validated = validatePrivyCredentials(credentials);
|
|
25
|
+
if (!validated.ok) {
|
|
26
|
+
return validated.error;
|
|
27
|
+
}
|
|
28
|
+
return validated;
|
|
29
|
+
}
|
|
30
|
+
export function hasGraphittiKey(credentials) {
|
|
31
|
+
return Boolean(credentials.GRAPHITTI_API_KEY?.trim());
|
|
32
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExecuteParams, PrivyCredentials, ToolResult } from "./types.js";
|
|
2
|
+
export declare function executePrivyTool(name: string, params: ExecuteParams, credentials: PrivyCredentials): Promise<ToolResult>;
|
|
3
|
+
export { listAvailableTools, PRIVY_TOOL_HANDLERS, PRIVY_TOOLS, getToolDefinition, isGraphittiTool, } from "./catalog.js";
|
|
4
|
+
export { resolveCredentials, validatePrivyCredentials } from "./credentials.js";
|
|
5
|
+
export type { PrivyCredentials, PrivyToolDefinition, ToolResult } from "./types.js";
|
package/dist/execute.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { validatePrivyCredentials } from "./credentials.js";
|
|
2
|
+
import { listAvailableTools, PRIVY_TOOL_HANDLERS, isGraphittiTool } from "./catalog.js";
|
|
3
|
+
import { fail } from "./http.js";
|
|
4
|
+
export async function executePrivyTool(name, params, credentials) {
|
|
5
|
+
const handler = PRIVY_TOOL_HANDLERS[name];
|
|
6
|
+
if (!handler) {
|
|
7
|
+
return fail(`Unknown tool: ${name}`);
|
|
8
|
+
}
|
|
9
|
+
const tool = listAvailableTools(credentials).find((item) => item.name === name);
|
|
10
|
+
if (!tool) {
|
|
11
|
+
return fail(`Tool ${name} is not available with current credentials.`);
|
|
12
|
+
}
|
|
13
|
+
if (!isGraphittiTool(name)) {
|
|
14
|
+
const privy = validatePrivyCredentials(credentials);
|
|
15
|
+
if (!privy.ok) {
|
|
16
|
+
return fail(privy.error);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else if (name !== "privy_search_workflows" &&
|
|
20
|
+
name !== "privy_get_listing" &&
|
|
21
|
+
name !== "privy_call_workflow" &&
|
|
22
|
+
!credentials.GRAPHITTI_API_KEY?.trim()) {
|
|
23
|
+
return fail("GRAPHITTI_API_KEY is required for this tool.");
|
|
24
|
+
}
|
|
25
|
+
return handler(params, credentials);
|
|
26
|
+
}
|
|
27
|
+
export { listAvailableTools, PRIVY_TOOL_HANDLERS, PRIVY_TOOLS, getToolDefinition, isGraphittiTool, } from "./catalog.js";
|
|
28
|
+
export { resolveCredentials, validatePrivyCredentials } from "./credentials.js";
|