@conto_finance/create-conto-agent 0.9.0 → 0.9.1

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,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.1
4
+
5
+ - `conto login` and the `conto init` sign-in now collect the organization key from Conto instead
6
+ of waiting for the browser to send it to the CLI. Current Chrome can hold that send behind a
7
+ local network permission, so the page spun on "Connecting to CLI..." and the login timed out.
8
+ The CLI prints a code, and the browser shows the same one next to Connect CLI. Older Conto
9
+ servers still send the key from the browser, and the CLI accepts it as before.
10
+ - `conto alerts` works again. Without `--json` it failed as soon as an alert existed, and `--unread`
11
+ and `--active` always failed with "Invalid status filter". The table now shows each alert's ID,
12
+ date, severity, status, and title, and `--unread` and `--active` list open alerts.
13
+ - `conto config` no longer changes `server.baseUrl`, because the saved keys would go to the new
14
+ server. It tells you to run `conto login --base-url <url>`, which signs in to that server and
15
+ removes the agent key saved for the old one.
16
+ - Setup with `--api-key` or `CONTO_ORG_API_KEY` uses that organization key for the run and no longer
17
+ saves it in `~/.conto/config.json`, where other projects of the same organization on the machine
18
+ would use it. In a terminal, setup asks first, and the default is No. The output says when the key
19
+ was not saved, and the `--json` result has `credentials.orgApiKeySaved`. A key from the browser
20
+ sign-in or `conto login` is saved as before, and setup keeps one already saved for the same server.
21
+ - `--json` runs never prompt, even in a terminal. Setup uses the headless defaults for flags you
22
+ leave out and needs `--api-key`, `CONTO_ORG_API_KEY`, or `--sandbox`. `conto policies create`,
23
+ `update`, `delete`, and `add-rule` prompt for input, so under `--json` they now stop with an error.
24
+ - `conto agents unfreeze` no longer asks Conto to keep the agent's wallets frozen unless you pass
25
+ `--wallets`. With neither flag, Conto unfreezes the wallets the agent's freeze froze, leaving any
26
+ wallet a person froze or another frozen agent still holds. `--wallets` also does it for a freeze
27
+ recorded before Conto kept that list, and the new `--keep-wallets` leaves every wallet frozen.
28
+
3
29
  ## 0.9.0
4
30
 
5
31
  - `conto pay --json` now exits 1 when a policy denies the payment, as it already did without
package/README.md CHANGED
@@ -24,7 +24,9 @@ See [configure controls](https://conto.finance/docs/quickstart/agent-sandbox#con
24
24
 
25
25
  Run the wizard without `--sandbox` to sign in and provision a managed wallet. Choose Tempo
26
26
  Testnet for free faucet tokens and actual onchain test transfers. For headless organization
27
- setup, set `CONTO_ORG_API_KEY` or pass `--api-key`.
27
+ setup, set `CONTO_ORG_API_KEY` or pass `--api-key`. Setup uses that key for the run and does not
28
+ save it in `~/.conto/config.json` unless you agree when it asks in a terminal. A `--json` run never
29
+ prompts.
28
30
 
29
31
  A mainnet setup asks you to confirm the network (pass `--confirm-mainnet` when headless) and
30
32
  creates the agent in the `PROD` environment, because only `PROD` agents can pay from mainnet
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  ensureContoDirGitignored,
3
3
  ensureEnvLocalGitignored,
4
+ loadGlobalConfig,
4
5
  loadProjectEnv,
5
6
  saveGlobalConfig,
6
7
  writeEnvLocal,
@@ -21,7 +22,7 @@ import {
21
22
  // package.json
22
23
  var package_default = {
23
24
  name: "@conto_finance/create-conto-agent",
24
- version: "0.9.0",
25
+ version: "0.9.1",
25
26
  description: "Set up an AI agent with Conto spending controls",
26
27
  bin: {
27
28
  "create-conto-agent": "bin/create-conto-agent.js",
@@ -364,7 +365,7 @@ function chainHint(chain) {
364
365
 
365
366
  // src/lib/auth.ts
366
367
  import http from "http";
367
- import { randomBytes } from "crypto";
368
+ import { createHash, randomBytes } from "crypto";
368
369
  import open from "open";
369
370
  var CALLBACK_BODY_LIMIT_BYTES = 16 * 1024;
370
371
  async function readRequestBody(req) {
@@ -404,16 +405,93 @@ async function parseCallbackPayload(req) {
404
405
  returnedState: params.get("state")
405
406
  };
406
407
  }
407
- async function browserAuth(baseUrl, onAuthUrl) {
408
- return new Promise((resolve, reject) => {
408
+ var PICKUP_POLL_MS = 2e3;
409
+ var PAIRING_ALPHABET = "BCDFGHJKLMNPQRSTVWXZ";
410
+ var PICKUP_FINAL_CODES = /* @__PURE__ */ new Set([
411
+ "CLI_AUTH_REFUSED",
412
+ "EXPIRED",
413
+ "ALREADY_PICKED_UP",
414
+ "INVALID_PICKUP_CODE"
415
+ ]);
416
+ function pairingCode(pickupHash) {
417
+ const digest = createHash("sha256").update(`conto-cli-pairing:${pickupHash}`).digest();
418
+ let code = "";
419
+ for (let i = 0; i < 8; i += 1) code += PAIRING_ALPHABET[digest[i] % PAIRING_ALPHABET.length];
420
+ return `${code.slice(0, 4)}-${code.slice(4)}`;
421
+ }
422
+ async function pollPickup(baseUrl, code, state) {
423
+ let response;
424
+ try {
425
+ response = await fetch(`${baseUrl.replace(/\/+$/, "")}/api/cli-auth/pickup`, {
426
+ method: "POST",
427
+ headers: { "Content-Type": "application/json" },
428
+ body: JSON.stringify({ code, state }),
429
+ redirect: "error"
430
+ });
431
+ } catch {
432
+ return { done: false };
433
+ }
434
+ const body = await response.json().catch(() => null);
435
+ if (response.status === 200 && body?.status === "DELIVERED" && typeof body.token === "string") {
436
+ if (body.state !== state) return { done: true, error: "Invalid authentication state" };
437
+ return {
438
+ done: true,
439
+ result: {
440
+ orgApiKey: body.token,
441
+ organizationName: typeof body.organizationName === "string" ? body.organizationName : "",
442
+ expiresAt: typeof body.expiresAt === "string" ? body.expiresAt : ""
443
+ }
444
+ };
445
+ }
446
+ if (typeof body?.code === "string" && PICKUP_FINAL_CODES.has(body.code)) {
447
+ return {
448
+ done: true,
449
+ error: typeof body.error === "string" ? body.error : "Authentication failed"
450
+ };
451
+ }
452
+ const retry = response.status === 202 || response.status === 429 || response.status >= 500;
453
+ return { done: false, stop: !retry };
454
+ }
455
+ async function browserAuth(baseUrl, onAuthUrl, onPairingCode) {
456
+ return new Promise((rawResolve, rawReject) => {
409
457
  const state = randomBytes(16).toString("hex");
458
+ const pickupCode = `conto_clipickup_${randomBytes(32).toString("hex")}`;
459
+ const pickupHash = createHash("sha256").update(pickupCode).digest("hex");
460
+ let settled = false;
461
+ let pollTimer;
462
+ const finish = () => {
463
+ settled = true;
464
+ clearTimeout(timeout);
465
+ clearTimeout(pollTimer);
466
+ server.close();
467
+ };
468
+ const resolve = (result) => {
469
+ if (settled) return;
470
+ finish();
471
+ rawResolve(result);
472
+ };
473
+ const reject = (error) => {
474
+ if (settled) return;
475
+ finish();
476
+ rawReject(error);
477
+ };
410
478
  const timeout = setTimeout(
411
479
  () => {
412
- server.close();
413
480
  reject(new Error("Authentication timed out. Please try again."));
414
481
  },
415
482
  5 * 60 * 1e3
416
483
  );
484
+ const poll = async () => {
485
+ if (settled) return;
486
+ const outcome = await pollPickup(baseUrl, pickupCode, state);
487
+ if (settled) return;
488
+ if (outcome.done) {
489
+ if ("result" in outcome) resolve(outcome.result);
490
+ else reject(new Error(`Authentication failed: ${outcome.error}`));
491
+ return;
492
+ }
493
+ if (!outcome.stop) pollTimer = setTimeout(() => void poll(), PICKUP_POLL_MS);
494
+ };
417
495
  const server = http.createServer((req, res) => {
418
496
  void (async () => {
419
497
  const url = new URL(req.url || "/", "http://127.0.0.1");
@@ -436,44 +514,37 @@ async function browserAuth(baseUrl, onAuthUrl) {
436
514
  if (error) {
437
515
  res.writeHead(200, { "Content-Type": "text/html" });
438
516
  res.end(getErrorHtml(error));
439
- clearTimeout(timeout);
440
- server.close();
441
517
  reject(new Error(`Authentication failed: ${error}`));
442
518
  return;
443
519
  }
444
520
  if (!orgApiKey) {
445
521
  res.writeHead(200, { "Content-Type": "text/html" });
446
522
  res.end(getErrorHtml("No token received"));
447
- clearTimeout(timeout);
448
- server.close();
449
523
  reject(new Error("No authentication token received"));
450
524
  return;
451
525
  }
452
526
  res.writeHead(200, { "Content-Type": "text/html" });
453
527
  res.end(getSuccessHtml());
454
- clearTimeout(timeout);
455
- server.close();
456
528
  resolve({ orgApiKey, organizationName, expiresAt });
457
529
  })().catch((error) => {
458
530
  res.writeHead(500, { "Content-Type": "text/html" });
459
531
  res.end(getErrorHtml("Authentication callback failed"));
460
- clearTimeout(timeout);
461
- server.close();
462
532
  reject(error instanceof Error ? error : new Error(String(error)));
463
533
  });
464
534
  });
465
535
  server.listen(0, "127.0.0.1", () => {
466
536
  const address = server.address();
467
537
  if (!address || typeof address === "string") {
468
- clearTimeout(timeout);
469
538
  reject(new Error("Failed to start local auth server"));
470
539
  return;
471
540
  }
472
541
  const callbackUrl = `http://127.0.0.1:${address.port}/callback`;
473
- const authUrl = `${baseUrl}/cli-auth?callback=${encodeURIComponent(callbackUrl)}&state=${encodeURIComponent(state)}`;
542
+ const authUrl = `${baseUrl}/cli-auth?pickup=${pickupHash}&callback=${encodeURIComponent(callbackUrl)}&state=${encodeURIComponent(state)}`;
474
543
  onAuthUrl?.(authUrl);
544
+ onPairingCode?.(pairingCode(pickupHash));
475
545
  open(authUrl).catch(() => {
476
546
  });
547
+ pollTimer = setTimeout(() => void poll(), PICKUP_POLL_MS);
477
548
  });
478
549
  });
479
550
  }
@@ -1270,7 +1341,7 @@ function reviewAccessFor(baseUrl, orgApiKey) {
1270
1341
  // src/lib/project-state.ts
1271
1342
  import fs from "fs";
1272
1343
  import path from "path";
1273
- import { createHash, randomBytes as randomBytes2 } from "crypto";
1344
+ import { createHash as createHash2, randomBytes as randomBytes2 } from "crypto";
1274
1345
  var PROJECT_STATE_DIR = ".conto";
1275
1346
  var PRIVATE_DIR_MODE = 448;
1276
1347
  var PRIVATE_FILE_MODE = 384;
@@ -1329,11 +1400,11 @@ function removeProjectStateFile(cwd, fileName) {
1329
1400
  }
1330
1401
  }
1331
1402
  function fingerprintSecret(secret) {
1332
- return `sha256:${createHash("sha256").update(secret).digest("hex").slice(0, 16)}`;
1403
+ return `sha256:${createHash2("sha256").update(secret).digest("hex").slice(0, 16)}`;
1333
1404
  }
1334
1405
 
1335
1406
  // src/lib/init-checkpoint.ts
1336
- import { createHash as createHash2, randomBytes as randomBytes3 } from "crypto";
1407
+ import { createHash as createHash3, randomBytes as randomBytes3 } from "crypto";
1337
1408
  var INIT_CHECKPOINT_NAME = "init-checkpoint.json";
1338
1409
  var INIT_CHECKPOINT_FILE = projectStateFile(INIT_CHECKPOINT_NAME);
1339
1410
  var STEP_ORDER = ["wallet", "faucet", "agent", "walletLink", "policy", "sdkKey"];
@@ -1354,7 +1425,7 @@ function canonicalJson(value) {
1354
1425
  return JSON.stringify(value);
1355
1426
  }
1356
1427
  function configurationHash(request) {
1357
- return `sha256:${createHash2("sha256").update(canonicalJson(request)).digest("hex")}`;
1428
+ return `sha256:${createHash3("sha256").update(canonicalJson(request)).digest("hex")}`;
1358
1429
  }
1359
1430
  function newOperationId() {
1360
1431
  return randomBytes3(8).toString("hex");
@@ -2400,7 +2471,9 @@ function resumeCommand(baseUrl, options) {
2400
2471
  ...isJsonMode() ? ["--json"] : []
2401
2472
  ].join(" ");
2402
2473
  }
2403
- var RESUME_CREDENTIAL_HINT = "Resume with the same organization: pass --api-key or set CONTO_ORG_API_KEY, or run it in a terminal to sign in with the browser.";
2474
+ function resumeCredentialHint() {
2475
+ return isJsonMode() ? "Resume with the same organization: pass --api-key or set CONTO_ORG_API_KEY, or run it in a terminal without --json to sign in with the browser." : "Resume with the same organization: pass --api-key or set CONTO_ORG_API_KEY, or run it in a terminal to sign in with the browser.";
2476
+ }
2404
2477
  function refuse(message, details) {
2405
2478
  failInit(message, { status: "refused", ...details }, INIT_EXIT_CODES.refused);
2406
2479
  }
@@ -2442,6 +2515,22 @@ function storedSdkKeyFor(cwd, baseUrl, agentId) {
2442
2515
  return void 0;
2443
2516
  }
2444
2517
  }
2518
+ var ORG_KEY_NOT_SAVED = 'The organization key was used for this setup only. It was not saved in ~/.conto/config.json. For commands that need it, set CONTO_ORG_API_KEY or run "conto login".';
2519
+ function isSameServer(a, b) {
2520
+ try {
2521
+ return normalizeBaseUrl(a) === normalizeBaseUrl(b);
2522
+ } catch {
2523
+ return false;
2524
+ }
2525
+ }
2526
+ function orgKeySavedFor(baseUrl) {
2527
+ const server = loadGlobalConfig().server;
2528
+ if (!server?.orgApiKey || !isSameServer(server.baseUrl || DEFAULT_BASE_URL, baseUrl)) return {};
2529
+ return { orgApiKey: server.orgApiKey, orgApiKeyExpiresAt: server.orgApiKeyExpiresAt };
2530
+ }
2531
+ function isSavedOrgApiKey(orgApiKey, baseUrl) {
2532
+ return orgKeySavedFor(baseUrl).orgApiKey === orgApiKey;
2533
+ }
2445
2534
  function organizationBindingProblem(checkpoint, credential) {
2446
2535
  const organization = checkpoint.binding.organization;
2447
2536
  if (organization.anchor) return null;
@@ -2454,7 +2543,7 @@ function organizationBindingProblem(checkpoint, credential) {
2454
2543
  }
2455
2544
  async function runOrganizationInit(options) {
2456
2545
  const cwd = process.cwd();
2457
- const interactive2 = Boolean(process.stdin.isTTY && process.stdout.isTTY);
2546
+ const interactive2 = Boolean(process.stdin.isTTY && process.stdout.isTTY) && !isJsonMode();
2458
2547
  const providedOrgApiKey = options.apiKey || process.env.CONTO_ORG_API_KEY;
2459
2548
  if (options.resume && options.restart) {
2460
2549
  refuse("Use --resume or --restart, not both.", { code: "INVALID_OPTIONS" });
@@ -2499,9 +2588,9 @@ async function runOrganizationInit(options) {
2499
2588
  if (!interactive2 && !providedOrgApiKey) {
2500
2589
  failInit(
2501
2590
  [
2502
- resumeFrom ? "Resuming setup without an interactive terminal needs an organization API key." : "create-conto-agent needs an interactive terminal for the setup wizard.",
2591
+ isJsonMode() ? "A --json run does not prompt or open a browser, so it needs an organization API key." : resumeFrom ? "Resuming setup without an interactive terminal needs an organization API key." : "create-conto-agent needs an interactive terminal for the setup wizard.",
2503
2592
  "Headless options: --sandbox, or --api-key <org-api-key>.",
2504
- "Add --json for machine-readable output."
2593
+ ...isJsonMode() ? [] : ["Add --json for machine-readable output."]
2505
2594
  ].join(" "),
2506
2595
  { headlessOptions: ["--sandbox", "--api-key <org-api-key>"] }
2507
2596
  );
@@ -2626,13 +2715,30 @@ async function runOrganizationInit(options) {
2626
2715
  let orgApiKey;
2627
2716
  let orgApiKeyExpiresAt;
2628
2717
  let organizationName;
2718
+ let saveOrgApiKey = true;
2629
2719
  if (providedOrgApiKey) {
2630
2720
  orgApiKey = providedOrgApiKey;
2631
2721
  printSuccess("Using provided organization API key");
2722
+ saveOrgApiKey = isSavedOrgApiKey(providedOrgApiKey, baseUrl);
2723
+ if (!saveOrgApiKey && interactive2) {
2724
+ const save = await p.confirm({
2725
+ message: "Save this organization key in ~/.conto/config.json? Other projects of this organization on this machine can then use it.",
2726
+ initialValue: false
2727
+ });
2728
+ if (p.isCancel(save)) {
2729
+ p.cancel("Setup cancelled.");
2730
+ process.exit(0);
2731
+ }
2732
+ saveOrgApiKey = save === true;
2733
+ }
2632
2734
  } else {
2633
2735
  s.start("Opening browser to authenticate...");
2634
2736
  try {
2635
- const authResult = await browserAuth(baseUrl);
2737
+ const authResult = await browserAuth(
2738
+ baseUrl,
2739
+ void 0,
2740
+ (code) => s.message(`Waiting for the browser. Connect only if it shows ${code}`)
2741
+ );
2636
2742
  orgApiKey = authResult.orgApiKey;
2637
2743
  orgApiKeyExpiresAt = authResult.expiresAt || void 0;
2638
2744
  organizationName = authResult.organizationName || void 0;
@@ -2763,6 +2869,8 @@ async function runOrganizationInit(options) {
2763
2869
  },
2764
2870
  options
2765
2871
  );
2872
+ const previousOrgKey = orgKeySavedFor(baseUrl);
2873
+ const savedOrgKey = !providedOrgApiKey ? { orgApiKey, orgApiKeyExpiresAt } : saveOrgApiKey && previousOrgKey.orgApiKey !== orgApiKey ? { orgApiKey } : previousOrgKey;
2766
2874
  saveGlobalConfig({
2767
2875
  agent: { id: agent.id, name: agent.name, type: agentType },
2768
2876
  network: {
@@ -2778,7 +2886,7 @@ async function runOrganizationInit(options) {
2778
2886
  address: wallet.address,
2779
2887
  custodyMode: wallet.custodyMode ?? "MANAGED"
2780
2888
  },
2781
- server: { baseUrl, apiKey: sdkKey.key, orgApiKey, orgApiKeyExpiresAt }
2889
+ server: { baseUrl, apiKey: sdkKey.key, ...savedOrgKey }
2782
2890
  });
2783
2891
  removeCheckpoint(cwd);
2784
2892
  let cliResolves = false;
@@ -2822,7 +2930,8 @@ async function runOrganizationInit(options) {
2822
2930
  },
2823
2931
  credentials: {
2824
2932
  storedIn: ".env.local",
2825
- sdkKeyEnv: "CONTO_API_KEY"
2933
+ sdkKeyEnv: "CONTO_API_KEY",
2934
+ orgApiKeySaved: saveOrgApiKey
2826
2935
  },
2827
2936
  files: PROJECT_FILES.filter((file) => !keptFiles.includes(file)),
2828
2937
  ...keptFiles.length > 0 ? { keptFiles } : {},
@@ -2843,6 +2952,10 @@ async function runOrganizationInit(options) {
2843
2952
  }
2844
2953
  console.log("");
2845
2954
  printKeptFiles(keptFiles);
2955
+ if (!saveOrgApiKey) {
2956
+ printInfo(ORG_KEY_NOT_SAVED);
2957
+ console.log("");
2958
+ }
2846
2959
  console.log(
2847
2960
  ` ${chalk2.dim("Wallet:")} ${wallet.address} (${chain.name}${chain.testnet ? " testnet" : ""}, ${wallet.custodyMode ?? "MANAGED"} custody)`
2848
2961
  );
@@ -2911,7 +3024,7 @@ function reportStoppedSetup(input) {
2911
3024
  checkpoint: INIT_CHECKPOINT_FILE,
2912
3025
  resume: resumable ? {
2913
3026
  command,
2914
- credential: RESUME_CREDENTIAL_HINT,
3027
+ credential: resumeCredentialHint(),
2915
3028
  ...stop.reconciliation?.notBefore ? { notBefore: stop.reconciliation.notBefore } : {}
2916
3029
  } : null,
2917
3030
  ...stop.retryAfterSeconds !== void 0 ? { retryAfterSeconds: stop.retryAfterSeconds } : {},
@@ -2966,7 +3079,7 @@ function reportStoppedSetup(input) {
2966
3079
  console.log("");
2967
3080
  if (resumable) {
2968
3081
  printInfo(`Resume: ${command}`);
2969
- printInfo(RESUME_CREDENTIAL_HINT);
3082
+ printInfo(resumeCredentialHint());
2970
3083
  } else {
2971
3084
  printInfo(`The unfinished setup is kept in ${INIT_CHECKPOINT_FILE}. Nothing was changed.`);
2972
3085
  }
package/dist/cli.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  retryAfterSeconds,
29
29
  runInit,
30
30
  writeProjectStateFile
31
- } from "./chunk-FW6E3QMB.js";
31
+ } from "./chunk-6PK4I5VO.js";
32
32
  import {
33
33
  BUDGET_PERIODS,
34
34
  VELOCITY_PERIODS,
@@ -2292,6 +2292,7 @@ var ORG_KEY_SUBCOMMANDS = /* @__PURE__ */ new Set([
2292
2292
  "rollback",
2293
2293
  "simulate"
2294
2294
  ]);
2295
+ var PROMPTING_SUBCOMMANDS = /* @__PURE__ */ new Set(["create", "update", "delete", "add-rule"]);
2295
2296
  async function policiesCommand(subcommand = "list", idOrAmount, extra, reviewOptions = {}) {
2296
2297
  const config = loadConfig();
2297
2298
  if (!config.apiKey) {
@@ -2306,6 +2307,11 @@ async function policiesCommand(subcommand = "list", idOrAmount, extra, reviewOpt
2306
2307
  orgApiKey: orgApiKeySource(config)
2307
2308
  });
2308
2309
  try {
2310
+ if (isJsonMode() && PROMPTING_SUBCOMMANDS.has(subcommand)) {
2311
+ throw new Error(
2312
+ `conto policies ${subcommand} prompts for input, so it does not run with --json. Run it in a terminal without --json.`
2313
+ );
2314
+ }
2309
2315
  if (ORG_KEY_SUBCOMMANDS.has(subcommand)) await resolveOrgApiKey(config);
2310
2316
  switch (subcommand) {
2311
2317
  case "list":
@@ -3027,25 +3033,25 @@ async function alertsCommand(options = {}) {
3027
3033
  try {
3028
3034
  const activeOnly = options.active || options.unread;
3029
3035
  const { alerts } = await api.getAlerts({
3030
- status: activeOnly ? "ACTIVE" : void 0
3036
+ status: activeOnly ? "open" : void 0
3031
3037
  });
3032
3038
  if (isJsonMode()) {
3033
3039
  printJson(alerts);
3034
3040
  return;
3035
3041
  }
3036
3042
  if (alerts.length === 0) {
3037
- console.log("\n No alerts." + (activeOnly ? " (showing active only)" : ""));
3043
+ console.log(activeOnly ? "\n No open alerts." : "\n No alerts.");
3038
3044
  return;
3039
3045
  }
3040
3046
  printHeader(`Alerts (${alerts.length})`);
3041
3047
  printTable(
3042
- ["Date", "Severity", "Type", "Message", "Status"],
3048
+ ["ID", "Date", "Severity", "Status", "Title"],
3043
3049
  alerts.map((a) => [
3050
+ a.id,
3044
3051
  new Date(a.createdAt).toLocaleDateString(),
3045
- severityColor(a.severity),
3046
- a.alertType,
3047
- a.message.length > 50 ? a.message.slice(0, 50) + "..." : a.message,
3048
- a.status
3052
+ severityColor(a.severity.label),
3053
+ a.status.label,
3054
+ a.title.length > 50 ? a.title.slice(0, 50) + "..." : a.title
3049
3055
  ])
3050
3056
  );
3051
3057
  console.log("");
@@ -3059,18 +3065,14 @@ async function alertsCommand(options = {}) {
3059
3065
  process.exit(1);
3060
3066
  }
3061
3067
  }
3062
- function severityColor(severity) {
3063
- switch (severity.toUpperCase()) {
3064
- case "CRITICAL":
3065
- return chalk8.red.bold(severity);
3066
- case "HIGH":
3067
- return chalk8.red(severity);
3068
- case "MEDIUM":
3069
- return chalk8.yellow(severity);
3070
- case "LOW":
3071
- return chalk8.dim(severity);
3068
+ function severityColor(label) {
3069
+ switch (label) {
3070
+ case "High":
3071
+ return chalk8.red(label);
3072
+ case "Medium":
3073
+ return chalk8.yellow(label);
3072
3074
  default:
3073
- return severity;
3075
+ return chalk8.dim(label);
3074
3076
  }
3075
3077
  }
3076
3078
  async function alertUpdateCommand(alertId, action) {
@@ -3147,18 +3149,28 @@ async function agentsFreezeCommand(agentId, options) {
3147
3149
  });
3148
3150
  }
3149
3151
  async function agentsUnfreezeCommand(agentId, options) {
3152
+ if (options.wallets && options.keepWallets) {
3153
+ if (isJsonMode()) {
3154
+ printJson({ ok: false, error: "Pick one of --wallets and --keep-wallets." });
3155
+ } else {
3156
+ printError("Pick one of --wallets and --keep-wallets.");
3157
+ }
3158
+ process.exitCode = 1;
3159
+ return;
3160
+ }
3161
+ const restoreWallets = options.keepWallets ? false : options.wallets ? true : void 0;
3150
3162
  await runOwnerCommand("org", async ({ api }) => {
3151
3163
  const result = await directOrReview(
3152
3164
  api,
3153
3165
  () => api.unfreezeAgent(agentId, {
3154
3166
  ...options.reason ? { reason: options.reason } : {},
3155
- unfreezeWallets: options.wallets === true
3167
+ ...restoreWallets === void 0 ? {} : { unfreezeWallets: restoreWallets }
3156
3168
  }),
3157
3169
  async () => ({
3158
3170
  action: "activate_agent",
3159
3171
  input: {
3160
3172
  agent_id: agentId,
3161
- restore_wallets: options.wallets === true,
3173
+ ...restoreWallets === void 0 ? {} : { restore_wallets: restoreWallets },
3162
3174
  ...options.reason ? { reason: options.reason } : {}
3163
3175
  }
3164
3176
  }),
@@ -3514,6 +3526,10 @@ function isSafeConfigPath(parts) {
3514
3526
  (part) => part.length > 0 && !FORBIDDEN_CONFIG_PATH_SEGMENTS.has(part.toLowerCase())
3515
3527
  );
3516
3528
  }
3529
+ var BASE_URL_NEEDS_LOGIN = 'conto config does not change server.baseUrl, because the saved keys would be sent to the new server. Run "conto login --base-url <url>" instead. It signs in to that server and removes the agent key saved for the old one.';
3530
+ function isServerBaseUrlPath(parts) {
3531
+ return parts.length >= 2 && parts[0].toLowerCase() === "server" && parts[1].toLowerCase() === "baseurl";
3532
+ }
3517
3533
  async function configCommand(key, value) {
3518
3534
  if (key && value) {
3519
3535
  const global = loadGlobalConfig();
@@ -3525,6 +3541,15 @@ async function configCommand(key, value) {
3525
3541
  process.exitCode = 1;
3526
3542
  return;
3527
3543
  }
3544
+ if (isServerBaseUrlPath(parts)) {
3545
+ if (isJsonMode()) {
3546
+ printJson({ ok: false, error: BASE_URL_NEEDS_LOGIN, code: "BASE_URL_NEEDS_LOGIN" });
3547
+ } else {
3548
+ printError(BASE_URL_NEEDS_LOGIN);
3549
+ }
3550
+ process.exitCode = 1;
3551
+ return;
3552
+ }
3528
3553
  let target = global;
3529
3554
  for (let i = 0; i < parts.length - 1; i++) {
3530
3555
  if (!target[parts[i]] || typeof target[parts[i]] !== "object") {
@@ -3584,7 +3609,8 @@ async function loginCommand(options = {}) {
3584
3609
  try {
3585
3610
  const { orgApiKey, organizationName, expiresAt } = await browserAuth(
3586
3611
  baseUrl,
3587
- (authUrl) => printInfo(`If the browser does not open, visit: ${authUrl}`)
3612
+ (authUrl) => printInfo(`If the browser does not open, visit: ${authUrl}`),
3613
+ (code) => printInfo(`Connect only if the browser shows this code: ${code}`)
3588
3614
  );
3589
3615
  const config = loadGlobalConfig();
3590
3616
  const previousBaseUrl = config.server?.baseUrl || DEFAULT_BASE_URL;
@@ -4786,7 +4812,7 @@ withReview(
4786
4812
  ).action(agentsResumeCommand);
4787
4813
  agentsGroup.command("freeze <agentId>").description("Freeze an agent").option("--reason <text>", "Why, for the audit log").option("--wallets", "Also freeze wallets only this agent uses").action(agentsFreezeCommand);
4788
4814
  withReview(
4789
- agentsGroup.command("unfreeze <agentId>").description("Lift a freeze (owner review)").option("--reason <text>", "Why, for the audit log").option("--wallets", "Also unfreeze the wallets frozen with it")
4815
+ agentsGroup.command("unfreeze <agentId>").description("Lift a freeze (owner review)").option("--reason <text>", "Why, for the audit log").option("--wallets", "Unfreeze the wallets frozen with it, also for an older freeze record").option("--keep-wallets", "Leave every wallet frozen")
4790
4816
  ).action(agentsUnfreezeCommand);
4791
4817
  withReview(
4792
4818
  agentsGroup.command("delete <agentId>").description("Delete an agent (owner review)").option("--yes", "Skip the confirmation prompt")
@@ -4855,7 +4881,7 @@ withReview(
4855
4881
  (subcommand, id2, extra, opts) => policiesCommand(subcommand || "list", id2, extra, opts)
4856
4882
  );
4857
4883
  program.command("limits").description("Show spending limits and remaining budget").action(limitsCommand);
4858
- var alertsGroup = program.command("alerts").description("List alerts, or acknowledge or resolve one").option("--active", "Show only active alerts").option("--unread", "Alias for --active").action(alertsCommand);
4884
+ var alertsGroup = program.command("alerts").description("List alerts, or acknowledge or resolve one").option("--active", "Show only open alerts").option("--unread", "Alias for --active").action(alertsCommand);
4859
4885
  alertsGroup.command("ack <alertId>").description("Acknowledge an alert").action((alertId) => alertUpdateCommand(alertId, "acknowledge"));
4860
4886
  alertsGroup.command("resolve <alertId>").description("Resolve an alert").action((alertId) => alertUpdateCommand(alertId, "resolve"));
4861
4887
  program.command("config [key] [value]").description("Show or update configuration").action(configCommand);
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runInit
3
- } from "./chunk-FW6E3QMB.js";
3
+ } from "./chunk-6PK4I5VO.js";
4
4
  import {
5
5
  delegatesToCli
6
6
  } from "./chunk-D6JPJHU4.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conto_finance/create-conto-agent",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
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",