slashvibe-mcp 0.2.2 โ 0.2.4
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 +1 -0
- package/analytics.js +107 -0
- package/config.js +174 -3
- package/index.js +163 -34
- package/intelligence/index.js +45 -0
- package/intelligence/infer.js +316 -0
- package/intelligence/interests.js +369 -0
- package/intelligence/patterns.js +651 -0
- package/intelligence/proactive.js +358 -0
- package/intelligence/serendipity.js +306 -0
- package/notification-emitter.js +77 -0
- package/notify.js +141 -18
- package/package.json +14 -6
- package/presence.js +5 -1
- package/protocol/index.js +88 -1
- package/protocol/telegram-commands.js +199 -0
- package/store/api.js +469 -29
- package/store/index.js +7 -7
- package/store/local.js +67 -11
- package/store/profiles.js +435 -0
- package/store/reservations.js +321 -0
- package/store/skills.js +378 -0
- package/tools/_actions.js +491 -22
- package/tools/_connection-queue.js +257 -0
- package/tools/_discovery-enhanced.js +290 -0
- package/tools/_discovery.js +439 -0
- package/tools/_proactive-discovery.js +301 -0
- package/tools/_shared/index.js +64 -0
- package/tools/_work-context.js +338 -0
- package/tools/_work-context.manual-test.js +199 -0
- package/tools/_work-context.test.js +260 -0
- package/tools/admin-inbox.js +218 -0
- package/tools/agent-treasury.js +288 -0
- package/tools/agents.js +122 -0
- package/tools/analytics.js +191 -0
- package/tools/approve.js +197 -0
- package/tools/arcade.js +173 -0
- package/tools/artifact-create.js +247 -0
- package/tools/artifact-view.js +174 -0
- package/tools/artifacts-price.js +107 -0
- package/tools/ask-expert.js +160 -0
- package/tools/auto-suggest-connections.js +304 -0
- package/tools/away.js +68 -0
- package/tools/back.js +51 -0
- package/tools/become-expert.js +150 -0
- package/tools/bootstrap-skills.js +231 -0
- package/tools/bridge-dashboard.js +342 -0
- package/tools/bridge-health.js +400 -0
- package/tools/bridge-live.js +384 -0
- package/tools/bridges.js +383 -0
- package/tools/broadcast.js +286 -0
- package/tools/bye.js +4 -0
- package/tools/chat.js +202 -0
- package/tools/collaborative-drawing.js +286 -0
- package/tools/colorguess.js +281 -0
- package/tools/crossword.js +369 -0
- package/tools/discover-insights.js +379 -0
- package/tools/discover-momentum.js +256 -0
- package/tools/discover.js +675 -0
- package/tools/discovery-analytics.js +345 -0
- package/tools/discovery-auto-suggest.js +275 -0
- package/tools/discovery-bootstrap.js +267 -0
- package/tools/discovery-daily.js +375 -0
- package/tools/discovery-dashboard.js +385 -0
- package/tools/discovery-digest.js +314 -0
- package/tools/discovery-hub.js +357 -0
- package/tools/discovery-insights.js +384 -0
- package/tools/discovery-momentum.js +281 -0
- package/tools/discovery-monitor.js +319 -0
- package/tools/discovery-proactive.js +300 -0
- package/tools/dm.js +84 -14
- package/tools/draw.js +317 -0
- package/tools/drawing.js +310 -0
- package/tools/earnings.js +126 -0
- package/tools/echo.js +16 -0
- package/tools/farcaster.js +307 -0
- package/tools/feed.js +215 -0
- package/tools/follow.js +224 -0
- package/tools/friends.js +192 -0
- package/tools/game.js +218 -110
- package/tools/games-catalog.js +376 -0
- package/tools/games.js +313 -0
- package/tools/genesis.js +233 -0
- package/tools/gig-browse.js +206 -0
- package/tools/gig-complete.js +139 -0
- package/tools/guessnumber.js +194 -0
- package/tools/hangman.js +129 -0
- package/tools/help.js +269 -0
- package/tools/idea.js +217 -0
- package/tools/inbox.js +291 -25
- package/tools/init.js +657 -33
- package/tools/insights.js +123 -0
- package/tools/invite.js +142 -21
- package/tools/l2-bridge.js +272 -0
- package/tools/l2-status.js +217 -0
- package/tools/l2.js +206 -0
- package/tools/migrate.js +156 -0
- package/tools/mint.js +377 -0
- package/tools/multiplayer-game.js +275 -0
- package/tools/multiplayer-tictactoe.js +303 -0
- package/tools/mute.js +97 -0
- package/tools/notifications.js +415 -0
- package/tools/observe.js +200 -0
- package/tools/onboarding.js +147 -0
- package/tools/open.js +52 -3
- package/tools/party-game.js +314 -0
- package/tools/plan.js +225 -0
- package/tools/presence-agent.js +167 -0
- package/tools/profile.js +219 -0
- package/tools/proof-of-work.js +139 -0
- package/tools/pulse.js +218 -0
- package/tools/react.js +4 -0
- package/tools/release.js +83 -0
- package/tools/report.js +109 -0
- package/tools/reputation.js +175 -0
- package/tools/request.js +231 -0
- package/tools/reservations.js +116 -0
- package/tools/reserve.js +111 -0
- package/tools/riddle.js +240 -0
- package/tools/run-bootstrap.js +69 -0
- package/tools/schedule.js +367 -0
- package/tools/session.js +420 -0
- package/tools/session_price.js +128 -0
- package/tools/settings.js +200 -0
- package/tools/ship.js +188 -0
- package/tools/shipback.js +326 -0
- package/tools/skills-analytics.js +349 -0
- package/tools/skills-bootstrap.js +301 -0
- package/tools/skills-dashboard.js +268 -0
- package/tools/skills-exchange.js +342 -0
- package/tools/skills.js +380 -0
- package/tools/smart-intro.js +353 -0
- package/tools/social-inbox.js +326 -69
- package/tools/social-post.js +251 -66
- package/tools/social-processor.js +445 -0
- package/tools/solo-game.js +390 -0
- package/tools/start.js +296 -81
- package/tools/status.js +53 -6
- package/tools/storybuilder.js +331 -0
- package/tools/stuck.js +297 -0
- package/tools/subscribe.js +148 -0
- package/tools/subscriptions.js +134 -0
- package/tools/suggest-tags.js +184 -0
- package/tools/tag-suggestions.js +257 -0
- package/tools/telegram-bot.js +183 -0
- package/tools/telegram-setup.js +214 -0
- package/tools/tictactoe.js +155 -0
- package/tools/tip.js +120 -0
- package/tools/token.js +103 -0
- package/tools/twentyquestions.js +143 -0
- package/tools/update.js +1 -1
- package/tools/wallet.js +127 -0
- package/tools/watch.js +157 -0
- package/tools/webhook-test.js +388 -0
- package/tools/who.js +118 -25
- package/tools/withdraw.js +145 -0
- package/tools/wordassociation.js +247 -0
- package/tools/work-summary.js +96 -0
- package/tools/workshop-buddy.js +394 -0
- package/tools/workshop.js +327 -0
- package/version.json +12 -3
- package/tools/board.js +0 -130
package/tools/mint.js
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vibe_mint โ Mint a /vibe moment as an NFT
|
|
3
|
+
*
|
|
4
|
+
* Supports multiple chains:
|
|
5
|
+
* - vibe-l2 (default) โ VIBE L2 with Shipback (80% gas fees to creator)
|
|
6
|
+
* - base โ Base mainnet
|
|
7
|
+
* - base-sepolia โ Base testnet
|
|
8
|
+
* - ethereum โ Ethereum mainnet
|
|
9
|
+
*
|
|
10
|
+
* Flow:
|
|
11
|
+
* 1. Upload metadata to IPFS (Pinata)
|
|
12
|
+
* 2. Call VibeArtifacts.mintArtifact() with session provenance
|
|
13
|
+
* 3. Return tx hash + token ID + marketplace links
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// Lazy-load ethers to avoid startup crash if not installed
|
|
17
|
+
let ethers = null;
|
|
18
|
+
function getEthers() {
|
|
19
|
+
if (!ethers) {
|
|
20
|
+
try {
|
|
21
|
+
ethers = require('ethers');
|
|
22
|
+
} catch (e) {
|
|
23
|
+
throw new Error('ethers package not installed. Run: npm install ethers');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return ethers;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Polyfill fetch for Node <18
|
|
30
|
+
const fetch = globalThis.fetch || require('node-fetch');
|
|
31
|
+
|
|
32
|
+
const config = require('../config');
|
|
33
|
+
|
|
34
|
+
// Chain configurations
|
|
35
|
+
// Env var format: VIBE_ARTIFACTS_MAINNET / VIBE_ARTIFACTS_TESTNET (matches deploy script)
|
|
36
|
+
const CHAINS = {
|
|
37
|
+
'vibe-l2': {
|
|
38
|
+
name: 'VIBE L2',
|
|
39
|
+
chainId: 84532000, // Mainnet
|
|
40
|
+
rpcUrl: process.env.VIBE_L2_RPC || 'https://rpc.vibe.network',
|
|
41
|
+
contractAddress: process.env.VIBE_ARTIFACTS_MAINNET,
|
|
42
|
+
explorerUrl: 'https://explorer.vibe.network',
|
|
43
|
+
marketplaceUrl: 'https://slashvibe.dev/a',
|
|
44
|
+
shipbackEnabled: true,
|
|
45
|
+
recommended: true
|
|
46
|
+
},
|
|
47
|
+
'vibe-l2-testnet': {
|
|
48
|
+
name: 'VIBE L2 Testnet',
|
|
49
|
+
chainId: 84532001, // Testnet
|
|
50
|
+
rpcUrl: process.env.VIBE_L2_TESTNET_RPC || 'https://rpc-testnet.vibe.network',
|
|
51
|
+
contractAddress: process.env.VIBE_ARTIFACTS_TESTNET,
|
|
52
|
+
explorerUrl: 'https://explorer-testnet.vibe.network',
|
|
53
|
+
marketplaceUrl: 'https://slashvibe.dev/a',
|
|
54
|
+
shipbackEnabled: true
|
|
55
|
+
},
|
|
56
|
+
'base-sepolia': {
|
|
57
|
+
name: 'Base Sepolia',
|
|
58
|
+
chainId: 84532,
|
|
59
|
+
rpcUrl: process.env.BASE_SEPOLIA_RPC_URL || 'https://sepolia.base.org',
|
|
60
|
+
contractAddress: process.env.VIBE_ARTIFACTS_BASE_SEPOLIA,
|
|
61
|
+
explorerUrl: 'https://sepolia.basescan.org',
|
|
62
|
+
marketplaceUrl: 'https://testnets.opensea.io/assets/base-sepolia',
|
|
63
|
+
shipbackEnabled: false
|
|
64
|
+
},
|
|
65
|
+
'base': {
|
|
66
|
+
name: 'Base',
|
|
67
|
+
chainId: 8453,
|
|
68
|
+
rpcUrl: process.env.BASE_RPC_URL || 'https://mainnet.base.org',
|
|
69
|
+
contractAddress: process.env.VIBE_ARTIFACTS_BASE,
|
|
70
|
+
explorerUrl: 'https://basescan.org',
|
|
71
|
+
marketplaceUrl: 'https://opensea.io/assets/base',
|
|
72
|
+
shipbackEnabled: false
|
|
73
|
+
},
|
|
74
|
+
'ethereum': {
|
|
75
|
+
name: 'Ethereum',
|
|
76
|
+
chainId: 1,
|
|
77
|
+
rpcUrl: process.env.ETH_RPC_URL || 'https://eth.llamarpc.com',
|
|
78
|
+
contractAddress: process.env.VIBE_ARTIFACTS_ADDRESS,
|
|
79
|
+
explorerUrl: 'https://etherscan.io',
|
|
80
|
+
marketplaceUrl: 'https://opensea.io/assets/ethereum',
|
|
81
|
+
shipbackEnabled: false
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Get default chain (prefer VIBE L2 if configured)
|
|
86
|
+
function getDefaultChain() {
|
|
87
|
+
if (CHAINS['vibe-l2'].contractAddress) return 'vibe-l2';
|
|
88
|
+
if (CHAINS['vibe-l2-testnet'].contractAddress) return 'vibe-l2-testnet';
|
|
89
|
+
if (CHAINS['base-sepolia'].contractAddress) return 'base-sepolia';
|
|
90
|
+
if (CHAINS['base'].contractAddress) return 'base';
|
|
91
|
+
return 'ethereum';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Contract ABI (extended for session provenance)
|
|
95
|
+
const VIBE_ARTIFACTS_ABI = [
|
|
96
|
+
// Legacy simple mint
|
|
97
|
+
'function mint(address to, string memory uri) public returns (uint256)',
|
|
98
|
+
// New mint with provenance
|
|
99
|
+
'function mintArtifact(address to, string uri, string sessionId, string creatorHandle, string artifactType, bytes32 sessionHash, address royaltyRecipient, uint96 royaltyBps) returns (uint256)',
|
|
100
|
+
'function totalSupply() public view returns (uint256)',
|
|
101
|
+
'event ArtifactMinted(uint256 indexed tokenId, address indexed creator, string sessionId, string artifactType, bytes32 sessionHash)'
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
const PINATA_JWT = process.env.PINATA_JWT || null;
|
|
105
|
+
const MINTER_PRIVATE_KEY = process.env.VIBE_MINTER_PRIVATE_KEY || null;
|
|
106
|
+
|
|
107
|
+
const definition = {
|
|
108
|
+
name: 'vibe_mint',
|
|
109
|
+
description: 'Mint a /vibe artifact as an NFT. Default: VIBE L2 (80% Shipback). Also supports Base, Ethereum.',
|
|
110
|
+
inputSchema: {
|
|
111
|
+
type: 'object',
|
|
112
|
+
properties: {
|
|
113
|
+
title: {
|
|
114
|
+
type: 'string',
|
|
115
|
+
description: 'Title of the artifact'
|
|
116
|
+
},
|
|
117
|
+
description: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
description: 'Description of what happened'
|
|
120
|
+
},
|
|
121
|
+
chain: {
|
|
122
|
+
type: 'string',
|
|
123
|
+
description: 'Chain to mint on: vibe-l2, base, base-sepolia, ethereum (default: vibe-l2)'
|
|
124
|
+
},
|
|
125
|
+
session_id: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
description: 'Session ID for provenance (ses_xxx)'
|
|
128
|
+
},
|
|
129
|
+
attributes: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
description: 'Optional attributes',
|
|
132
|
+
additionalProperties: true
|
|
133
|
+
},
|
|
134
|
+
image_url: {
|
|
135
|
+
type: 'string',
|
|
136
|
+
description: 'Optional image URL'
|
|
137
|
+
},
|
|
138
|
+
dry_run: {
|
|
139
|
+
type: 'boolean',
|
|
140
|
+
description: 'Preview without minting'
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
required: ['title', 'description']
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
async function uploadToIPFS(metadata) {
|
|
148
|
+
if (!PINATA_JWT) {
|
|
149
|
+
throw new Error('PINATA_JWT not configured');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const response = await fetch('https://api.pinata.cloud/pinning/pinJSONToIPFS', {
|
|
153
|
+
method: 'POST',
|
|
154
|
+
headers: {
|
|
155
|
+
'Content-Type': 'application/json',
|
|
156
|
+
'Authorization': `Bearer ${PINATA_JWT}`
|
|
157
|
+
},
|
|
158
|
+
body: JSON.stringify({
|
|
159
|
+
pinataContent: metadata,
|
|
160
|
+
pinataMetadata: {
|
|
161
|
+
name: `vibe-artifact-${Date.now()}`
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
if (!response.ok) {
|
|
167
|
+
throw new Error(`Pinata upload failed: ${response.statusText}`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const result = await response.json();
|
|
171
|
+
return `ipfs://${result.IpfsHash}`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async function mintOnchain(uri, chain, creatorHandle, sessionId) {
|
|
175
|
+
if (!chain.contractAddress) {
|
|
176
|
+
throw new Error(`Contract not configured for ${chain.name}`);
|
|
177
|
+
}
|
|
178
|
+
if (!MINTER_PRIVATE_KEY) {
|
|
179
|
+
throw new Error('VIBE_MINTER_PRIVATE_KEY not configured');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const ethers = getEthers();
|
|
183
|
+
const crypto = require('crypto');
|
|
184
|
+
|
|
185
|
+
const provider = new ethers.JsonRpcProvider(chain.rpcUrl);
|
|
186
|
+
const wallet = new ethers.Wallet(MINTER_PRIVATE_KEY, provider);
|
|
187
|
+
const contract = new ethers.Contract(chain.contractAddress, VIBE_ARTIFACTS_ABI, wallet);
|
|
188
|
+
|
|
189
|
+
// Compute session hash for provenance
|
|
190
|
+
const sessionData = JSON.stringify({ sessionId, creatorHandle, timestamp: Date.now() });
|
|
191
|
+
const sessionHash = '0x' + crypto.createHash('sha256').update(sessionData).digest('hex');
|
|
192
|
+
|
|
193
|
+
let tx;
|
|
194
|
+
try {
|
|
195
|
+
// Try new mintArtifact with provenance
|
|
196
|
+
tx = await contract.mintArtifact(
|
|
197
|
+
wallet.address, // to
|
|
198
|
+
uri, // metadata URI
|
|
199
|
+
sessionId, // session ID
|
|
200
|
+
creatorHandle, // creator handle
|
|
201
|
+
'session_artifact', // artifact type
|
|
202
|
+
sessionHash, // session hash
|
|
203
|
+
wallet.address, // royalty recipient
|
|
204
|
+
1000 // 10% royalty (1000 bps)
|
|
205
|
+
);
|
|
206
|
+
} catch (e) {
|
|
207
|
+
// Fallback to legacy mint if new function not available
|
|
208
|
+
console.log('[mint] Falling back to legacy mint:', e.message);
|
|
209
|
+
tx = await contract.mint(wallet.address, uri);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const receipt = await tx.wait();
|
|
213
|
+
|
|
214
|
+
// Parse the event to get tokenId
|
|
215
|
+
const event = receipt.logs.find(log => {
|
|
216
|
+
try {
|
|
217
|
+
const parsed = contract.interface.parseLog(log);
|
|
218
|
+
return parsed?.name === 'ArtifactMinted';
|
|
219
|
+
} catch {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
let tokenId = null;
|
|
225
|
+
if (event) {
|
|
226
|
+
const parsed = contract.interface.parseLog(event);
|
|
227
|
+
tokenId = parsed.args.tokenId.toString();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return {
|
|
231
|
+
txHash: receipt.hash,
|
|
232
|
+
tokenId,
|
|
233
|
+
contractAddress: chain.contractAddress
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
async function handler(args) {
|
|
238
|
+
const {
|
|
239
|
+
title,
|
|
240
|
+
description,
|
|
241
|
+
chain: chainArg,
|
|
242
|
+
session_id,
|
|
243
|
+
attributes = {},
|
|
244
|
+
image_url,
|
|
245
|
+
dry_run = false
|
|
246
|
+
} = args;
|
|
247
|
+
|
|
248
|
+
// Get handle from config
|
|
249
|
+
const handle = config.isInitialized() ? config.getHandle() : 'anonymous';
|
|
250
|
+
|
|
251
|
+
// Determine chain
|
|
252
|
+
const chainName = chainArg || getDefaultChain();
|
|
253
|
+
const chain = CHAINS[chainName];
|
|
254
|
+
|
|
255
|
+
if (!chain) {
|
|
256
|
+
return {
|
|
257
|
+
display: `Unknown chain: ${chainArg}\n\nAvailable chains:\n` +
|
|
258
|
+
Object.entries(CHAINS).map(([k, v]) =>
|
|
259
|
+
`โข ${k} - ${v.name}${v.shipbackEnabled ? ' (80% Shipback)' : ''}${v.recommended ? ' โจ' : ''}`
|
|
260
|
+
).join('\n')
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Build metadata with session provenance
|
|
265
|
+
const sessionId = session_id || `ses_${Date.now()}`;
|
|
266
|
+
const metadata = {
|
|
267
|
+
name: title,
|
|
268
|
+
description,
|
|
269
|
+
attributes: [
|
|
270
|
+
{ trait_type: 'Source', value: '/vibe MCP' },
|
|
271
|
+
{ trait_type: 'Minted Via', value: 'Claude Code' },
|
|
272
|
+
{ trait_type: 'Chain', value: chain.name },
|
|
273
|
+
{ trait_type: 'Creator', value: `@${handle}` },
|
|
274
|
+
{ trait_type: 'Session', value: sessionId },
|
|
275
|
+
{ trait_type: 'Date', value: new Date().toISOString().split('T')[0] },
|
|
276
|
+
...Object.entries(attributes).map(([key, value]) => ({
|
|
277
|
+
trait_type: key,
|
|
278
|
+
value: String(value)
|
|
279
|
+
}))
|
|
280
|
+
],
|
|
281
|
+
external_url: `https://slashvibe.dev/a/${sessionId}`,
|
|
282
|
+
// Session provenance
|
|
283
|
+
provenance: {
|
|
284
|
+
sessionId,
|
|
285
|
+
creatorHandle: handle,
|
|
286
|
+
mintedAt: new Date().toISOString(),
|
|
287
|
+
chain: chainName,
|
|
288
|
+
shipbackEnabled: chain.shipbackEnabled
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
if (image_url) {
|
|
293
|
+
metadata.image = image_url;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Dry run - show metadata and chain info
|
|
297
|
+
if (dry_run) {
|
|
298
|
+
let display = `## Dry Run - Metadata Preview\n\n`;
|
|
299
|
+
display += `**Chain:** ${chain.name}${chain.shipbackEnabled ? ' (80% Shipback enabled!)' : ''}\n\n`;
|
|
300
|
+
display += '```json\n' + JSON.stringify(metadata, null, 2) + '\n```\n\n';
|
|
301
|
+
display += `Ready to mint. Run without \`dry_run\` to mint onchain.`;
|
|
302
|
+
return { display };
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Check configuration
|
|
306
|
+
if (!chain.contractAddress) {
|
|
307
|
+
let display = `## Configuration Required\n\n`;
|
|
308
|
+
display += `Chain **${chain.name}** is not configured.\n\n`;
|
|
309
|
+
|
|
310
|
+
if (chain.shipbackEnabled) {
|
|
311
|
+
display += `To use VIBE L2 (recommended - 80% Shipback):\n`;
|
|
312
|
+
display += `1. Sign up at https://conduit.xyz\n`;
|
|
313
|
+
display += `2. Deploy contracts: \`node scripts/deploy-vibe-l2.js\`\n`;
|
|
314
|
+
display += `3. Set env var: \`VIBE_ARTIFACTS_TESTNET=0x...\`\n\n`;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
display += `Available configured chains:\n`;
|
|
318
|
+
Object.entries(CHAINS).forEach(([k, v]) => {
|
|
319
|
+
if (v.contractAddress) {
|
|
320
|
+
display += `โข ${k} - ${v.name}\n`;
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
if (!Object.values(CHAINS).some(c => c.contractAddress)) {
|
|
325
|
+
display += `\nNo chains configured. Set environment variables:\n`;
|
|
326
|
+
display += `โข VIBE_ARTIFACTS_TESTNET (recommended)\n`;
|
|
327
|
+
display += `โข VIBE_ARTIFACTS_BASE_SEPOLIA\n`;
|
|
328
|
+
display += `โข VIBE_MINTER_PRIVATE_KEY\n`;
|
|
329
|
+
display += `โข PINATA_JWT\n`;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return { display };
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
try {
|
|
336
|
+
// 1. Upload to IPFS
|
|
337
|
+
const ipfsUri = await uploadToIPFS(metadata);
|
|
338
|
+
|
|
339
|
+
// 2. Mint onchain
|
|
340
|
+
const { txHash, tokenId } = await mintOnchain(ipfsUri, chain, handle, sessionId);
|
|
341
|
+
|
|
342
|
+
// 3. Build result
|
|
343
|
+
const explorerUrl = `${chain.explorerUrl}/tx/${txHash}`;
|
|
344
|
+
const marketplaceUrl = tokenId
|
|
345
|
+
? `${chain.marketplaceUrl}/${chain.contractAddress}/${tokenId}`
|
|
346
|
+
: null;
|
|
347
|
+
|
|
348
|
+
let display = `## ๐จ VIBE #${tokenId || '?'} Minted on ${chain.name}\n\n`;
|
|
349
|
+
display += `**${title}**\n\n`;
|
|
350
|
+
display += `โข IPFS: \`${ipfsUri}\`\n`;
|
|
351
|
+
display += `โข Tx: [${txHash.slice(0, 10)}...](${explorerUrl})\n`;
|
|
352
|
+
display += `โข Creator: @${handle}\n`;
|
|
353
|
+
display += `โข Session: ${sessionId}\n`;
|
|
354
|
+
|
|
355
|
+
if (marketplaceUrl) {
|
|
356
|
+
display += `โข View: [Marketplace](${marketplaceUrl})\n`;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (chain.shipbackEnabled) {
|
|
360
|
+
display += `\n๐ฐ **Shipback enabled!** You'll earn 80% of all gas fees from interactions.\n`;
|
|
361
|
+
display += `Check earnings: \`vibe l2 shipback\``;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
display += `\n\n_Onchain. Forever._`;
|
|
365
|
+
|
|
366
|
+
return { display };
|
|
367
|
+
|
|
368
|
+
} catch (err) {
|
|
369
|
+
return {
|
|
370
|
+
display: `## Mint Failed\n\n${err.message}\n\n` +
|
|
371
|
+
`Chain: ${chain.name}\n` +
|
|
372
|
+
`Check configuration and try again.`
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
module.exports = { definition, handler };
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vibe multiplayer-game โ Join multiplayer games like drawing, tic-tac-toe rooms, etc.
|
|
3
|
+
*
|
|
4
|
+
* Supports: drawing, multiplayer-tictactoe, wordchain, storybuilder
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const config = require('../config');
|
|
8
|
+
const store = require('../store');
|
|
9
|
+
const { requireInit, normalizeHandle } = require('./_shared');
|
|
10
|
+
|
|
11
|
+
// Game implementations
|
|
12
|
+
const drawing = require('../games/drawing');
|
|
13
|
+
const multiTicTacToe = require('../games/multiplayer-tictactoe');
|
|
14
|
+
const wordchain = require('../games/wordchain');
|
|
15
|
+
const storybuilder = require('../games/storybuilder');
|
|
16
|
+
|
|
17
|
+
// Global game state storage (in memory for now)
|
|
18
|
+
const globalGameRooms = {};
|
|
19
|
+
|
|
20
|
+
const definition = {
|
|
21
|
+
name: 'vibe_multiplayer_game',
|
|
22
|
+
description: 'Join or interact with multiplayer games (drawing, multiplayer-tictactoe, wordchain, storybuilder)',
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
game: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
description: 'Game type to join/play',
|
|
29
|
+
enum: ['drawing', 'multiplayer-tictactoe', 'wordchain', 'storybuilder']
|
|
30
|
+
},
|
|
31
|
+
action: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Action to take (join, leave, draw, move, etc.)',
|
|
34
|
+
enum: ['join', 'leave', 'show', 'draw', 'move', 'clear', 'theme', 'restart', 'spectate', 'word', 'sentence']
|
|
35
|
+
},
|
|
36
|
+
x: {
|
|
37
|
+
type: 'number',
|
|
38
|
+
description: 'X coordinate for drawing (0-19)'
|
|
39
|
+
},
|
|
40
|
+
y: {
|
|
41
|
+
type: 'number',
|
|
42
|
+
description: 'Y coordinate for drawing (0-11)'
|
|
43
|
+
},
|
|
44
|
+
char: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
description: 'Character to draw (empty, dot, circle, square, star, heart, tree, house, sun, moon, water, mountain, person, cat, dog, car, plane, flower, umbrella, rainbow)'
|
|
47
|
+
},
|
|
48
|
+
position: {
|
|
49
|
+
type: 'number',
|
|
50
|
+
description: 'Position for tic-tac-toe (1-9)'
|
|
51
|
+
},
|
|
52
|
+
word: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'Word to add to word chain'
|
|
55
|
+
},
|
|
56
|
+
sentence: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
description: 'Sentence to add to story'
|
|
59
|
+
},
|
|
60
|
+
theme: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'Theme to set for drawing game'
|
|
63
|
+
},
|
|
64
|
+
roomName: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
description: 'Room name for multiplayer-tictactoe'
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
required: ['game', 'action']
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Get or create global game room
|
|
74
|
+
function getGameRoom(gameType, roomId = 'default') {
|
|
75
|
+
const key = `${gameType}:${roomId}`;
|
|
76
|
+
|
|
77
|
+
if (!globalGameRooms[key]) {
|
|
78
|
+
if (gameType === 'drawing') {
|
|
79
|
+
globalGameRooms[key] = drawing.createInitialDrawingState();
|
|
80
|
+
} else if (gameType === 'multiplayer-tictactoe') {
|
|
81
|
+
const myHandle = config.getHandle();
|
|
82
|
+
globalGameRooms[key] = multiTicTacToe.createInitialMultiplayerTicTacToeState(myHandle, roomId);
|
|
83
|
+
} else if (gameType === 'wordchain') {
|
|
84
|
+
globalGameRooms[key] = wordchain.createInitialWordChainState();
|
|
85
|
+
} else if (gameType === 'storybuilder') {
|
|
86
|
+
globalGameRooms[key] = storybuilder.createInitialStoryBuilderState();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return globalGameRooms[key];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Update global game room
|
|
94
|
+
function updateGameRoom(gameType, roomId, newState) {
|
|
95
|
+
const key = `${gameType}:${roomId}`;
|
|
96
|
+
globalGameRooms[key] = newState;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function handler(args) {
|
|
100
|
+
const initCheck = requireInit();
|
|
101
|
+
if (initCheck) return initCheck;
|
|
102
|
+
|
|
103
|
+
const { game, action, x, y, char, position, word, sentence, theme, roomName } = args;
|
|
104
|
+
const myHandle = config.getHandle();
|
|
105
|
+
const roomId = roomName || 'default';
|
|
106
|
+
|
|
107
|
+
// Get current game state
|
|
108
|
+
let gameState = getGameRoom(game, roomId);
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
if (game === 'drawing') {
|
|
112
|
+
if (action === 'join') {
|
|
113
|
+
const result = drawing.addPlayer(gameState, myHandle);
|
|
114
|
+
if (result.error) {
|
|
115
|
+
return { display: `โ ${result.error}` };
|
|
116
|
+
}
|
|
117
|
+
updateGameRoom(game, roomId, result.gameState);
|
|
118
|
+
return { display: `๐จ **Joined Collaborative Drawing!**\n\n${drawing.formatDrawingDisplay(result.gameState)}\n\nUse commands like:\nโข \`vibe multiplayer-game drawing draw --x 10 --y 5 --char star\`\nโข \`vibe multiplayer-game drawing theme --theme "house"\`` };
|
|
119
|
+
|
|
120
|
+
} else if (action === 'draw') {
|
|
121
|
+
if (x === undefined || y === undefined || !char) {
|
|
122
|
+
return { display: 'Need x, y coordinates and character to draw. Example: `vibe multiplayer-game drawing draw --x 10 --y 5 --char star`' };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Convert char name to actual character
|
|
126
|
+
const charMap = drawing.DRAWING_CHARS;
|
|
127
|
+
const actualChar = charMap[char] || char;
|
|
128
|
+
|
|
129
|
+
const result = drawing.makeMove(gameState, x, y, actualChar, myHandle);
|
|
130
|
+
if (result.error) {
|
|
131
|
+
return { display: `โ ${result.error}` };
|
|
132
|
+
}
|
|
133
|
+
updateGameRoom(game, roomId, result.gameState);
|
|
134
|
+
return { display: `๐จ **Drew ${actualChar} at (${x},${y})**\n\n${drawing.formatDrawingDisplay(result.gameState)}` };
|
|
135
|
+
|
|
136
|
+
} else if (action === 'clear') {
|
|
137
|
+
const x0 = x || 0;
|
|
138
|
+
const y0 = y || 0;
|
|
139
|
+
const x1 = args.x1 || x0;
|
|
140
|
+
const y1 = args.y1 || y0;
|
|
141
|
+
|
|
142
|
+
const result = drawing.clearRegion(gameState, x0, y0, x1, y1, myHandle);
|
|
143
|
+
if (result.error) {
|
|
144
|
+
return { display: `โ ${result.error}` };
|
|
145
|
+
}
|
|
146
|
+
updateGameRoom(game, roomId, result.gameState);
|
|
147
|
+
return { display: `๐งน **Cleared region**\n\n${drawing.formatDrawingDisplay(result.gameState)}` };
|
|
148
|
+
|
|
149
|
+
} else if (action === 'theme') {
|
|
150
|
+
if (!theme) {
|
|
151
|
+
return { display: 'Need a theme! Example: `vibe multiplayer-game drawing theme --theme "house"`' };
|
|
152
|
+
}
|
|
153
|
+
const result = drawing.setTheme(gameState, theme, myHandle);
|
|
154
|
+
if (result.error) {
|
|
155
|
+
return { display: `โ ${result.error}` };
|
|
156
|
+
}
|
|
157
|
+
updateGameRoom(game, roomId, result.gameState);
|
|
158
|
+
const tips = drawing.getDrawingTips(theme);
|
|
159
|
+
return { display: `๐ฏ **Set theme: ${theme}**\n\n**Tips:** ${tips.join(', ')}\n\n${drawing.formatDrawingDisplay(result.gameState)}` };
|
|
160
|
+
|
|
161
|
+
} else if (action === 'show') {
|
|
162
|
+
return { display: drawing.formatDrawingDisplay(gameState) };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
} else if (game === 'multiplayer-tictactoe') {
|
|
166
|
+
if (action === 'join') {
|
|
167
|
+
const result = multiTicTacToe.joinRoom(gameState, myHandle, false);
|
|
168
|
+
if (result.error) {
|
|
169
|
+
return { display: `โ ${result.error}` };
|
|
170
|
+
}
|
|
171
|
+
updateGameRoom(game, roomId, result.gameState);
|
|
172
|
+
return { display: `๐ฏ **Joined Multiplayer Tic-Tac-Toe!**\n\n${multiTicTacToe.formatMultiplayerTicTacToeDisplay(result.gameState, myHandle)}` };
|
|
173
|
+
|
|
174
|
+
} else if (action === 'spectate') {
|
|
175
|
+
const result = multiTicTacToe.joinRoom(gameState, myHandle, true);
|
|
176
|
+
if (result.error) {
|
|
177
|
+
return { display: `โ ${result.error}` };
|
|
178
|
+
}
|
|
179
|
+
updateGameRoom(game, roomId, result.gameState);
|
|
180
|
+
return { display: `๐๏ธ **Now spectating Multiplayer Tic-Tac-Toe**\n\n${multiTicTacToe.formatMultiplayerTicTacToeDisplay(result.gameState, myHandle)}` };
|
|
181
|
+
|
|
182
|
+
} else if (action === 'move') {
|
|
183
|
+
if (!position) {
|
|
184
|
+
return { display: 'Need position (1-9)! Example: `vibe multiplayer-game multiplayer-tictactoe move --position 5`' };
|
|
185
|
+
}
|
|
186
|
+
const result = multiTicTacToe.makeMove(gameState, position, myHandle);
|
|
187
|
+
if (result.error) {
|
|
188
|
+
return { display: `โ ${result.error}` };
|
|
189
|
+
}
|
|
190
|
+
updateGameRoom(game, roomId, result.gameState);
|
|
191
|
+
return { display: `๐ฏ **Played position ${position}**\n\n${multiTicTacToe.formatMultiplayerTicTacToeDisplay(result.gameState, myHandle)}` };
|
|
192
|
+
|
|
193
|
+
} else if (action === 'restart') {
|
|
194
|
+
const result = multiTicTacToe.restartGame(gameState, myHandle);
|
|
195
|
+
if (result.error) {
|
|
196
|
+
return { display: `โ ${result.error}` };
|
|
197
|
+
}
|
|
198
|
+
updateGameRoom(game, roomId, result.gameState);
|
|
199
|
+
return { display: `๐ **Restarted game!**\n\n${multiTicTacToe.formatMultiplayerTicTacToeDisplay(result.gameState, myHandle)}` };
|
|
200
|
+
|
|
201
|
+
} else if (action === 'leave') {
|
|
202
|
+
const result = multiTicTacToe.leaveRoom(gameState, myHandle);
|
|
203
|
+
if (result.error) {
|
|
204
|
+
return { display: `โ ${result.error}` };
|
|
205
|
+
}
|
|
206
|
+
updateGameRoom(game, roomId, result.gameState);
|
|
207
|
+
return { display: '๐ Left the game room.' };
|
|
208
|
+
|
|
209
|
+
} else if (action === 'show') {
|
|
210
|
+
return { display: multiTicTacToe.formatMultiplayerTicTacToeDisplay(gameState, myHandle) };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
} else if (game === 'wordchain') {
|
|
214
|
+
if (action === 'join') {
|
|
215
|
+
const result = wordchain.addPlayer && wordchain.addPlayer(gameState, myHandle);
|
|
216
|
+
if (result && result.error) {
|
|
217
|
+
return { display: `โ ${result.error}` };
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// For wordchain, just show the current state since it doesn't have explicit player management
|
|
221
|
+
return { display: `๐ **Joined Word Chain!**\n\n${wordchain.formatWordChainDisplay(gameState)}\n\nAdd words with: \`vibe multiplayer-game wordchain word --word "apple"\`` };
|
|
222
|
+
|
|
223
|
+
} else if (action === 'word') {
|
|
224
|
+
if (!word) {
|
|
225
|
+
return { display: 'Need a word! Example: `vibe multiplayer-game wordchain word --word "apple"`' };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// For wordchain, we need to determine if this is player 1 or 2 move
|
|
229
|
+
// For simplicity, let's alternate based on move count
|
|
230
|
+
const isPlayer1Move = gameState.moves % 2 === 0;
|
|
231
|
+
|
|
232
|
+
const result = wordchain.makeMove(gameState, word, isPlayer1Move);
|
|
233
|
+
if (result.error) {
|
|
234
|
+
return { display: `โ ${result.error}` };
|
|
235
|
+
}
|
|
236
|
+
updateGameRoom(game, roomId, result.gameState);
|
|
237
|
+
return { display: `๐ **Added word: ${word}**\n\n${wordchain.formatWordChainDisplay(result.gameState)}` };
|
|
238
|
+
|
|
239
|
+
} else if (action === 'show') {
|
|
240
|
+
return { display: wordchain.formatWordChainDisplay(gameState) };
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
} else if (game === 'storybuilder') {
|
|
244
|
+
if (action === 'join') {
|
|
245
|
+
const result = storybuilder.addPlayer(gameState, myHandle);
|
|
246
|
+
if (result.error) {
|
|
247
|
+
return { display: `โ ${result.error}` };
|
|
248
|
+
}
|
|
249
|
+
updateGameRoom(game, roomId, result.gameState);
|
|
250
|
+
return { display: `๐ **Joined Story Builder!**\n\n${storybuilder.formatStoryBuilderDisplay(result.gameState)}\n\nAdd sentences with: \`vibe multiplayer-game storybuilder sentence --sentence "Once upon a time..."\`` };
|
|
251
|
+
|
|
252
|
+
} else if (action === 'sentence') {
|
|
253
|
+
if (!sentence) {
|
|
254
|
+
return { display: 'Need a sentence! Example: `vibe multiplayer-game storybuilder sentence --sentence "Once upon a time..."`' };
|
|
255
|
+
}
|
|
256
|
+
const result = storybuilder.addSentence(gameState, sentence, myHandle);
|
|
257
|
+
if (result.error) {
|
|
258
|
+
return { display: `โ ${result.error}` };
|
|
259
|
+
}
|
|
260
|
+
updateGameRoom(game, roomId, result.gameState);
|
|
261
|
+
return { display: `๐ **Added sentence!**\n\n${storybuilder.formatStoryBuilderDisplay(result.gameState)}` };
|
|
262
|
+
|
|
263
|
+
} else if (action === 'show') {
|
|
264
|
+
return { display: storybuilder.formatStoryBuilderDisplay(gameState) };
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return { display: `โ Unknown action "${action}" for game "${game}"` };
|
|
269
|
+
|
|
270
|
+
} catch (error) {
|
|
271
|
+
return { display: `โ Error: ${error.message}` };
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
module.exports = { definition, handler };
|