@conto_finance/create-conto-agent 0.4.5 → 0.4.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.6
4
+
5
+ - Generated starters support `--status REQUEST_ID` and `--resume REQUEST_ID`, so continuing after owner approval uses the existing request instead of creating another payment.
6
+
3
7
  ## 0.4.5
4
8
 
5
9
  - `sandbox claim` and `sandbox claim-status` hand an anonymous sandbox to its owner through the
@@ -20,7 +20,7 @@ import {
20
20
  // package.json
21
21
  var package_default = {
22
22
  name: "@conto_finance/create-conto-agent",
23
- version: "0.4.5",
23
+ version: "0.4.6",
24
24
  description: "Set up an AI agent with Conto spending controls",
25
25
  bin: {
26
26
  "create-conto-agent": "bin/create-conto-agent.js",
@@ -2322,7 +2322,7 @@ async function runSandboxInit(options) {
2322
2322
  },
2323
2323
  nextSteps: [
2324
2324
  "node example.mjs",
2325
- "node example.mjs --execute",
2325
+ "node example.mjs --resume REQUEST_ID",
2326
2326
  `${cli} doctor`,
2327
2327
  `${cli} pay 0x742d35Cc6634C0532925a3b844Bc454e4438f44e 1 --purpose test`,
2328
2328
  `${cli} sandbox claim --json`
@@ -2354,7 +2354,8 @@ async function runSandboxInit(options) {
2354
2354
  console.log("");
2355
2355
  console.log(chalk.bold(" Next steps:"));
2356
2356
  console.log(` 1. Run the example: ${chalk.cyan("node example.mjs")}`);
2357
- console.log(` 2. Execute it: ${chalk.cyan("node example.mjs --execute")}`);
2357
+ console.log(` 2. Continue it: ${chalk.cyan("node example.mjs --resume REQUEST_ID")}`);
2358
+ console.log(" Replace REQUEST_ID with the ID printed by the example.");
2358
2359
  console.log(` 3. Verify setup: ${chalk.cyan(`${cli} doctor`)}`);
2359
2360
  console.log("");
2360
2361
  printInfo(
@@ -2412,7 +2413,9 @@ function writeExampleFile(dir) {
2412
2413
  //
2413
2414
  // Usage:
2414
2415
  // node example.mjs Check setup and request a test payment (no funds move)
2415
- // node example.mjs --execute Also execute the payment if it is approved
2416
+ // node example.mjs --execute Start a new payment and execute it if approved
2417
+ // node example.mjs --resume REQUEST_ID Check and continue the same request
2418
+ // node example.mjs --status REQUEST_ID Read status without executing
2416
2419
  //
2417
2420
  // Reads CONTO_API_KEY and CONTO_BASE_URL from .env.local in this directory.
2418
2421
  // Docs: https://conto.finance/docs
@@ -2451,6 +2454,22 @@ async function api(method, path, body) {
2451
2454
  }
2452
2455
 
2453
2456
  async function main() {
2457
+ const resumeIndex = process.argv.indexOf('--resume');
2458
+ const statusIndex = process.argv.indexOf('--status');
2459
+ if (resumeIndex >= 0 || statusIndex >= 0) {
2460
+ const requestId = process.argv[(resumeIndex >= 0 ? resumeIndex : statusIndex) + 1];
2461
+ if (!requestId || !/^[a-zA-Z0-9_-]+$/.test(requestId)) {
2462
+ throw new Error('Supply the saved request ID after --resume or --status.');
2463
+ }
2464
+ lastRequestId = requestId;
2465
+ const current = await api('GET', '/api/sdk/payments/' + requestId);
2466
+ console.log(JSON.stringify(current, null, 2));
2467
+ // Approval may already have executed it. Never create another request here.
2468
+ if (resumeIndex >= 0 && current.status === 'approved') {
2469
+ console.log(JSON.stringify(await api('POST', '/api/sdk/payments/' + requestId + '/execute'), null, 2));
2470
+ }
2471
+ return;
2472
+ }
2454
2473
  // 1. Setup snapshot: agent, key scopes, wallets. Same data as "conto doctor".
2455
2474
  const setup = await api('GET', '/api/sdk/setup');
2456
2475
  console.log(\`Agent: \${setup.agent.name} (\${setup.agent.status})\`);
@@ -2493,7 +2512,7 @@ async function main() {
2493
2512
  return;
2494
2513
  }
2495
2514
  if (request.status === 'REQUIRES_APPROVAL') {
2496
- console.log('Approve it in the Conto dashboard, then execute it from there or via the API.');
2515
+ console.log('Ask the owner to review it in Conto. Then run: node example.mjs --resume ' + lastRequestId);
2497
2516
  return;
2498
2517
  }
2499
2518
  if (request.status !== 'APPROVED') {
@@ -2505,7 +2524,8 @@ async function main() {
2505
2524
  // quickstart includes the payments:execute scope.
2506
2525
  if (!EXECUTE) {
2507
2526
  console.log(\`\\nApproved (request \${request.requestId}). No funds moved.\`);
2508
- console.log('Re-run with --execute to send it, or use: npx @conto_finance/create-conto-agent pay <address> <amount>');
2527
+ console.log('Continue this same request: node example.mjs --resume ' + lastRequestId);
2528
+ console.log('Each run without --resume creates a new payment intent.');
2509
2529
  return;
2510
2530
  }
2511
2531
  const result = await api('POST', \`/api/sdk/payments/\${request.requestId}/execute\`);
package/dist/cli.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  retryAfterSeconds,
18
18
  runInit,
19
19
  writeProjectStateFile
20
- } from "./chunk-TBAJKVGC.js";
20
+ } from "./chunk-MASQPQTP.js";
21
21
  import {
22
22
  VELOCITY_PERIODS,
23
23
  buildVelocityCountValue,
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runInit
3
- } from "./chunk-TBAJKVGC.js";
3
+ } from "./chunk-MASQPQTP.js";
4
4
  import {
5
5
  isJsonMode,
6
6
  printJson,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conto_finance/create-conto-agent",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "Set up an AI agent with Conto spending controls",
5
5
  "bin": {
6
6
  "create-conto-agent": "bin/create-conto-agent.js",