@takisvc/code-canvas 0.1.0 → 0.1.2
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/code-canvas.js +9 -43
- package/package.json +1 -1
package/dist/code-canvas.js
CHANGED
|
@@ -125,26 +125,6 @@ function showUsage(usage) {
|
|
|
125
125
|
function extractAgentkitChallenge(body) {
|
|
126
126
|
return body?.extensions?.agentkit ?? body?.accepts?.[0]?.extensions?.agentkit ?? body?.paymentRequirements?.[0]?.extensions?.agentkit ?? body?.challenge;
|
|
127
127
|
}
|
|
128
|
-
function runRegistration(address) {
|
|
129
|
-
console.log();
|
|
130
|
-
console.log(
|
|
131
|
-
chalk.yellow("Launching World ID registration \u2014 scan the QR code with your World App:")
|
|
132
|
-
);
|
|
133
|
-
console.log();
|
|
134
|
-
try {
|
|
135
|
-
execSync(
|
|
136
|
-
`npx @worldcoin/agentkit-cli register ${address} --network world`,
|
|
137
|
-
{ stdio: "inherit" }
|
|
138
|
-
);
|
|
139
|
-
console.log();
|
|
140
|
-
console.log(chalk.green("Registration successful!"));
|
|
141
|
-
return true;
|
|
142
|
-
} catch {
|
|
143
|
-
console.log();
|
|
144
|
-
console.log(chalk.red("Registration failed or was cancelled."));
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
128
|
async function generateImage(endpoint2, prompt2, account2) {
|
|
149
129
|
const spinner = ora(randomSpinnerMessage()).start();
|
|
150
130
|
const interval = setInterval(() => {
|
|
@@ -235,30 +215,19 @@ async function generateImage(endpoint2, prompt2, account2) {
|
|
|
235
215
|
spinner.stop();
|
|
236
216
|
console.log();
|
|
237
217
|
console.log(chalk.yellow("Your agent is not registered with World ID."));
|
|
238
|
-
const registered = runRegistration(account2.address);
|
|
239
|
-
if (registered) {
|
|
240
|
-
console.log();
|
|
241
|
-
console.log(chalk.cyan("Retrying image generation..."));
|
|
242
|
-
return false;
|
|
243
|
-
}
|
|
244
218
|
console.log();
|
|
245
|
-
console.log(
|
|
246
|
-
` ${chalk.bold("Option 1:")} Try registration again manually:`
|
|
247
|
-
);
|
|
248
|
-
console.log(
|
|
249
|
-
` npx @worldcoin/agentkit-cli register ${account2.address} --network world`
|
|
250
|
-
);
|
|
219
|
+
console.log(` ${chalk.bold("Register:")} Run this in your terminal and scan the QR code with World App:`);
|
|
251
220
|
console.log();
|
|
252
|
-
console.log(
|
|
253
|
-
|
|
254
|
-
);
|
|
255
|
-
console.log(
|
|
256
|
-
console.log(`
|
|
221
|
+
console.log(` npx @worldcoin/agentkit-cli register ${account2.address} --network world`);
|
|
222
|
+
console.log();
|
|
223
|
+
console.log(` Then re-run the image generation command.`);
|
|
224
|
+
console.log();
|
|
225
|
+
console.log(` ${chalk.bold("Or pay:")} Fund wallet ${account2.address} with ${chalk.cyan("$1.20 USDC")} on World Chain.`);
|
|
257
226
|
if (errorBody?.error) {
|
|
258
227
|
console.log();
|
|
259
228
|
console.log(chalk.dim(`Server: ${errorBody.error}`));
|
|
260
229
|
}
|
|
261
|
-
return
|
|
230
|
+
return "needs-registration";
|
|
262
231
|
} finally {
|
|
263
232
|
clearInterval(interval);
|
|
264
233
|
}
|
|
@@ -275,8 +244,5 @@ if (!prompt) {
|
|
|
275
244
|
}
|
|
276
245
|
var account = ensureWallet();
|
|
277
246
|
var endpoint = `${SERVER_URL}/code-canvas/generate-image`;
|
|
278
|
-
var
|
|
279
|
-
|
|
280
|
-
success = await generateImage(endpoint, prompt, account);
|
|
281
|
-
}
|
|
282
|
-
process.exit(success ? 0 : 1);
|
|
247
|
+
var result = await generateImage(endpoint, prompt, account);
|
|
248
|
+
process.exit(result === true ? 0 : result === "needs-registration" ? 0 : 1);
|