@conto_finance/create-conto-agent 0.6.0 → 0.8.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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.0
4
+
5
+ - With the key from `conto login`, `conto teams` changes now go to owner review instead of failing.
6
+ The command prints a review link and waits for an owner or admin to confirm the change, as it
7
+ does for other changes that key can't make directly. `--no-wait` returns at once, and
8
+ `conto changes status <changeId>` checks the change later. A key made in the dashboard still makes
9
+ team changes directly.
10
+ - A move that takes an agent off a budget can't go through owner review when your organization
11
+ requires approval for budget changes. Make it in the dashboard, or with a dashboard key and
12
+ `--approval <id>`.
13
+
14
+ ## 0.7.0
15
+
16
+ - `conto teams` lists and shows teams, and creates, renames and deletes them. `managers` replaces a
17
+ team's managers by email or membership id, and `add` and `remove` move agents in and out. Reads
18
+ work with any organization key. Changes need an organization key made in the dashboard under
19
+ Developers, set as `CONTO_ORG_API_KEY`, because the key from `conto login` can only tighten
20
+ controls and team changes have no owner review.
21
+ - A move that needs governance approval exits 4 and changes nothing. Once it is approved, run the
22
+ same command with `--approval <id>`.
23
+
3
24
  ## 0.6.0
4
25
 
5
26
  - `conto spending export` downloads the organization's spend as CSV, up to 20,000 rows, to stdout or
package/README.md CHANGED
@@ -116,6 +116,25 @@ new setup. Resources the old setup created stay in the organization.
116
116
  | 3 | Partial setup, run the resume command |
117
117
  | 4 | Reconciliation or owner action needed first, see the output |
118
118
 
119
+ ## Teams
120
+
121
+ ```bash
122
+ conto teams create --name Marketing --cost-center CC-100
123
+ conto teams managers <teamId> pat@yourcompany.com
124
+ conto teams add <teamId> <agentId>
125
+ conto teams list
126
+ ```
127
+
128
+ A team's policies apply to every agent in it, alongside company policies. Reads work with any
129
+ organization key. With the key from `conto login`, every change goes to owner review: the command
130
+ prints a review link and waits for an owner or admin to confirm it. A key made in the dashboard
131
+ under Developers, set as `CONTO_ORG_API_KEY`, makes the change directly.
132
+
133
+ If your organization requires approval for budget changes and a move takes an agent off a budget,
134
+ the move can't go through owner review. Make it in the dashboard, or with a dashboard key. With a
135
+ dashboard key, the command exits 4 and nothing changes. Once it is approved, run the same command
136
+ with `--approval <id>`.
137
+
119
138
  ## Accounting export
120
139
 
121
140
  `conto spending export` downloads organization-wide accounting CSV using your configured
@@ -21,7 +21,7 @@ import {
21
21
  // package.json
22
22
  var package_default = {
23
23
  name: "@conto_finance/create-conto-agent",
24
- version: "0.6.0",
24
+ version: "0.8.0",
25
25
  description: "Set up an AI agent with Conto spending controls",
26
26
  bin: {
27
27
  "create-conto-agent": "bin/create-conto-agent.js",
@@ -712,6 +712,7 @@ var ApiClient = class {
712
712
  const authType = options?.auth || "sdk";
713
713
  const token = authType === "org" ? this.orgApiKey : this.apiKey;
714
714
  const headers = {
715
+ ...options?.headers,
715
716
  ...options?.body instanceof FormData ? {} : { "Content-Type": "application/json" },
716
717
  "User-Agent": `create-conto-agent/${CLI_PACKAGE_VERSION}`
717
718
  };
@@ -978,6 +979,53 @@ function createApiClient(options) {
978
979
  // src/lib/owner-client.ts
979
980
  var enc = encodeURIComponent;
980
981
  var OwnerApiClient = class extends ApiClient {
982
+ // ── Teams ──
983
+ listTeams() {
984
+ return this.request("GET", "/api/teams", { auth: "org" });
985
+ }
986
+ getTeam(teamId) {
987
+ return this.request("GET", `/api/teams/${enc(teamId)}`, { auth: "org" });
988
+ }
989
+ createTeam(body) {
990
+ return this.request("POST", "/api/teams", { body, auth: "org" });
991
+ }
992
+ updateTeam(teamId, body) {
993
+ return this.request("PATCH", `/api/teams/${enc(teamId)}`, {
994
+ body,
995
+ auth: "org"
996
+ });
997
+ }
998
+ deleteTeam(teamId) {
999
+ return this.request("DELETE", `/api/teams/${enc(teamId)}`, {
1000
+ auth: "org"
1001
+ });
1002
+ }
1003
+ setTeamManagers(teamId, membershipIds) {
1004
+ return this.request("PUT", `/api/teams/${enc(teamId)}/managers`, {
1005
+ body: { membershipIds },
1006
+ auth: "org"
1007
+ });
1008
+ }
1009
+ addTeamAgents(teamId, agentIds, approvalId) {
1010
+ return this.request("POST", `/api/teams/${enc(teamId)}/agents`, {
1011
+ body: { agentIds },
1012
+ auth: "org",
1013
+ ...approvalId ? { headers: { "x-governance-approval-id": approvalId } } : {}
1014
+ });
1015
+ }
1016
+ removeTeamAgent(teamId, agentId, approvalId) {
1017
+ return this.request(
1018
+ "DELETE",
1019
+ `/api/teams/${enc(teamId)}/agents?agentId=${enc(agentId)}`,
1020
+ {
1021
+ auth: "org",
1022
+ ...approvalId ? { headers: { "x-governance-approval-id": approvalId } } : {}
1023
+ }
1024
+ );
1025
+ }
1026
+ listMembers() {
1027
+ return this.request("GET", "/api/organizations/me/members", { auth: "org" });
1028
+ }
981
1029
  // ── Agents ──
982
1030
  listAgents() {
983
1031
  return this.request("GET", "/api/agents?limit=100", {
@@ -3402,15 +3450,16 @@ export {
3402
3450
  NOTHING_SENT_CODES,
3403
3451
  ApiClient,
3404
3452
  createApiClient,
3405
- fetchChains,
3406
- getChain,
3407
3453
  createOwnerClient,
3408
3454
  REVIEW_EXIT_CODES_HELP,
3455
+ EXIT_PENDING,
3409
3456
  isTightenOnlyRefusal,
3410
3457
  followChange,
3411
3458
  proposeForReview,
3412
3459
  directOrReview,
3413
3460
  reportReview,
3461
+ fetchChains,
3462
+ getChain,
3414
3463
  browserAuth,
3415
3464
  projectStateFile,
3416
3465
  readProjectStateFile,
package/dist/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  ApiClient,
3
3
  CLI_PACKAGE_VERSION,
4
+ EXIT_PENDING,
4
5
  HttpTransportError,
5
6
  NOTHING_SENT_CODES,
6
7
  REVIEW_EXIT_CODES_HELP,
@@ -27,7 +28,7 @@ import {
27
28
  retryAfterSeconds,
28
29
  runInit,
29
30
  writeProjectStateFile
30
- } from "./chunk-QJIXCSI2.js";
31
+ } from "./chunk-HGEZBNZB.js";
31
32
  import {
32
33
  BUDGET_PERIODS,
33
34
  VELOCITY_PERIODS,
@@ -294,6 +295,260 @@ function registerSpendingCommands(program2) {
294
295
  );
295
296
  }
296
297
 
298
+ // src/lib/owner-command.ts
299
+ import chalk from "chalk";
300
+ var LOGIN_HINT = 'This command needs your organization login. Run "conto login" (or set CONTO_ORG_API_KEY) and try again.';
301
+ async function runOwnerCommand(needs, fn) {
302
+ const config = loadConfig();
303
+ if (needs === "org" && !config.orgApiKey) {
304
+ fail(LOGIN_HINT, "ORG_KEY_REQUIRED");
305
+ return;
306
+ }
307
+ if (needs === "sdk" && !config.apiKey) {
308
+ fail(
309
+ 'Not configured. Run "npx @conto_finance/create-conto-agent" or "conto login" first.',
310
+ "SDK_KEY_REQUIRED"
311
+ );
312
+ return;
313
+ }
314
+ const api = createOwnerClient({
315
+ baseUrl: config.baseUrl,
316
+ apiKey: config.apiKey,
317
+ orgApiKey: config.orgApiKey
318
+ });
319
+ try {
320
+ await fn({ api, config });
321
+ } catch (err) {
322
+ const error = err;
323
+ if (error.status === 401) {
324
+ fail(`${error.message}. ${LOGIN_HINT}`, error.code ?? "AUTH_FAILED");
325
+ return;
326
+ }
327
+ fail(error.message || "Request failed", error.code, error.recovery);
328
+ }
329
+ }
330
+ function fail(message, code, recovery) {
331
+ process.exitCode = 1;
332
+ if (isJsonMode()) {
333
+ printJson({
334
+ ok: false,
335
+ error: message,
336
+ ...code ? { code } : {},
337
+ ...recovery ? { recovery } : {}
338
+ });
339
+ return;
340
+ }
341
+ printError(message);
342
+ if (recovery) console.log(chalk.dim(` ${recovery}`));
343
+ }
344
+ function parseUsd(value, flag) {
345
+ if (value === void 0) return void 0;
346
+ const amount = Number(value);
347
+ if (!Number.isFinite(amount) || amount < 0) {
348
+ throw new Error(`${flag} takes an amount in USD, for example 250`);
349
+ }
350
+ return amount;
351
+ }
352
+
353
+ // src/commands/teams.ts
354
+ function change(api, direct, action, input, options) {
355
+ return directOrReview(api, direct, async () => ({ action, input }), options);
356
+ }
357
+ function printTeam(team) {
358
+ printHeader(team.name);
359
+ printKeyValue("ID", team.id);
360
+ printKeyValue("Department label", team.slug);
361
+ printKeyValue("Cost center", team.costCenterCode ?? "-");
362
+ printKeyValue(
363
+ "Managers",
364
+ team.managers.length ? team.managers.map((m) => m.email ?? m.name ?? m.membershipId).join(", ") : "-"
365
+ );
366
+ printKeyValue("Agents", team.agentCount);
367
+ printKeyValue("Policies", team.policyCount);
368
+ }
369
+ function reportMove(result, command, applied) {
370
+ if ("requiresGovernanceApproval" in result) {
371
+ process.exitCode = EXIT_PENDING;
372
+ if (isJsonMode()) return printJson(result);
373
+ printPending("This change waits for governance approval. Nothing has changed yet.");
374
+ printKeyValue("Approval", result.approvalRequest.id);
375
+ printInfo(`Once it is approved, run: ${command} --approval ${result.approvalRequest.id}`);
376
+ return;
377
+ }
378
+ if (isJsonMode()) return printJson(result);
379
+ printSuccess(applied);
380
+ }
381
+ async function teamsListCommand() {
382
+ await runOwnerCommand("org", async ({ api }) => {
383
+ const { teams } = await api.listTeams();
384
+ if (isJsonMode()) return printJson(teams);
385
+ if (teams.length === 0)
386
+ return printInfo("No teams yet. Create one with: conto teams create --name <name>");
387
+ printHeader("Teams");
388
+ printTable(
389
+ ["ID", "Name", "Cost center", "Managers", "Agents", "Policies"],
390
+ teams.map((team) => [
391
+ team.id,
392
+ team.name,
393
+ team.costCenterCode ?? "-",
394
+ String(team.managers.length),
395
+ String(team.agentCount),
396
+ String(team.policyCount)
397
+ ])
398
+ );
399
+ });
400
+ }
401
+ async function teamsShowCommand(teamId) {
402
+ await runOwnerCommand("org", async ({ api }) => {
403
+ const { team } = await api.getTeam(teamId);
404
+ if (isJsonMode()) return printJson(team);
405
+ printTeam(team);
406
+ });
407
+ }
408
+ async function teamsCreateCommand(options) {
409
+ await runOwnerCommand("org", async ({ api }) => {
410
+ if (!options.name) throw new Error("Pass --name.");
411
+ const name = options.name;
412
+ const result = await change(
413
+ api,
414
+ () => api.createTeam({
415
+ name,
416
+ ...options.slug ? { slug: options.slug } : {},
417
+ ...options.costCenter ? { costCenterCode: options.costCenter } : {}
418
+ }),
419
+ "create_team",
420
+ {
421
+ name,
422
+ ...options.slug ? { slug: options.slug } : {},
423
+ ...options.costCenter ? { cost_center_code: options.costCenter } : {}
424
+ },
425
+ options
426
+ );
427
+ if ("review" in result) {
428
+ return reportReview(
429
+ result.review,
430
+ `Team ${name} created. Run conto teams list to see its ID.`
431
+ );
432
+ }
433
+ const { team } = result.direct;
434
+ if (isJsonMode()) return printJson(team);
435
+ printSuccess(`Team ${team.name} created.`);
436
+ printKeyValue("ID", team.id);
437
+ });
438
+ }
439
+ async function teamsUpdateCommand(teamId, options) {
440
+ await runOwnerCommand("org", async ({ api }) => {
441
+ if (options.costCenter && options.clearCostCenter) {
442
+ throw new Error("Choose either --cost-center or --clear-cost-center.");
443
+ }
444
+ const body = {
445
+ ...options.name ? { name: options.name } : {},
446
+ ...options.costCenter ? { costCenterCode: options.costCenter } : {},
447
+ ...options.clearCostCenter ? { costCenterCode: null } : {}
448
+ };
449
+ if (Object.keys(body).length === 0) {
450
+ throw new Error("Pass --name, --cost-center or --clear-cost-center.");
451
+ }
452
+ const result = await change(
453
+ api,
454
+ () => api.updateTeam(teamId, body),
455
+ "update_team",
456
+ {
457
+ team_id: teamId,
458
+ ...body.name ? { name: body.name } : {},
459
+ ..."costCenterCode" in body ? { cost_center_code: body.costCenterCode } : {}
460
+ },
461
+ options
462
+ );
463
+ if ("review" in result) return reportReview(result.review, "Team updated.");
464
+ const { team } = result.direct;
465
+ if (isJsonMode()) return printJson(team);
466
+ printSuccess(`Team ${team.name} updated.`);
467
+ });
468
+ }
469
+ async function teamsDeleteCommand(teamId, options) {
470
+ await runOwnerCommand("org", async ({ api }) => {
471
+ const result = await change(
472
+ api,
473
+ () => api.deleteTeam(teamId),
474
+ "delete_team",
475
+ { team_id: teamId },
476
+ options
477
+ );
478
+ if ("review" in result) return reportReview(result.review, "Team deleted.");
479
+ if (isJsonMode()) return printJson(result.direct);
480
+ printSuccess("Team deleted.");
481
+ });
482
+ }
483
+ async function teamsManagersCommand(teamId, who, options = {}) {
484
+ await runOwnerCommand("org", async ({ api }) => {
485
+ const emails = who.filter((entry) => entry.includes("@"));
486
+ let membershipIds = who.filter((entry) => !entry.includes("@"));
487
+ if (emails.length > 0) {
488
+ const { members } = await api.listMembers();
489
+ for (const email of emails) {
490
+ const member = members.find((m) => m.user?.email?.toLowerCase() === email.toLowerCase());
491
+ if (!member) throw new Error(`No organization member has the email ${email}.`);
492
+ membershipIds = [...membershipIds, member.id];
493
+ }
494
+ }
495
+ const result = await change(
496
+ api,
497
+ () => api.setTeamManagers(teamId, membershipIds),
498
+ "set_team_managers",
499
+ { team_id: teamId, membership_ids: membershipIds },
500
+ options
501
+ );
502
+ if ("review" in result) return reportReview(result.review, "Team managers changed.");
503
+ const { team } = result.direct;
504
+ if (isJsonMode()) return printJson(team);
505
+ printSuccess(
506
+ team.managers.length ? `${team.name} is managed by ${team.managers.map((m) => m.email ?? m.membershipId).join(", ")}.` : `${team.name} has no managers now.`
507
+ );
508
+ });
509
+ }
510
+ async function teamsAddCommand(teamId, agentIds, options) {
511
+ await runOwnerCommand("org", async ({ api }) => {
512
+ const result = await change(
513
+ api,
514
+ () => api.addTeamAgents(teamId, agentIds, options.approval),
515
+ "add_agents_to_team",
516
+ { team_id: teamId, agent_ids: agentIds },
517
+ options
518
+ );
519
+ if ("review" in result) {
520
+ return reportReview(result.review, `Added ${agentIds.length} agent(s) to the team.`);
521
+ }
522
+ reportMove(
523
+ result.direct,
524
+ `conto teams add ${teamId} ${agentIds.join(" ")}`,
525
+ `Added ${agentIds.length} agent(s) to the team.`
526
+ );
527
+ });
528
+ }
529
+ async function teamsRemoveCommand(teamId, agentId, options) {
530
+ await runOwnerCommand("org", async ({ api }) => {
531
+ const result = await change(
532
+ api,
533
+ () => api.removeTeamAgent(teamId, agentId, options.approval),
534
+ "remove_agent_from_team",
535
+ { team_id: teamId, agent_id: agentId },
536
+ options
537
+ );
538
+ if ("review" in result) {
539
+ return reportReview(
540
+ result.review,
541
+ "Agent taken out of the team. It no longer follows the team policies."
542
+ );
543
+ }
544
+ reportMove(
545
+ result.direct,
546
+ `conto teams remove ${teamId} ${agentId}`,
547
+ "Agent taken out of the team. It no longer follows the team policies."
548
+ );
549
+ });
550
+ }
551
+
297
552
  // src/cli.ts
298
553
  import { Command } from "commander";
299
554
 
@@ -396,7 +651,7 @@ function progressBar(pct, width = 20) {
396
651
  }
397
652
 
398
653
  // src/commands/doctor.ts
399
- import chalk from "chalk";
654
+ import chalk2 from "chalk";
400
655
 
401
656
  // src/lib/setup-diagnostics.ts
402
657
  var SETUP_DIAGNOSTICS_VERSION = "conto.setup-diagnostics.v1";
@@ -557,9 +812,9 @@ function describeAction(action, baseUrl) {
557
812
 
558
813
  // src/commands/doctor.ts
559
814
  function mark(status) {
560
- if (status === "ok") return chalk.green("\u2713");
561
- if (status === "warn") return chalk.yellow("\u26A0");
562
- return chalk.red("\u2717");
815
+ if (status === "ok") return chalk2.green("\u2713");
816
+ if (status === "warn") return chalk2.yellow("\u26A0");
817
+ return chalk2.red("\u2717");
563
818
  }
564
819
  function errorMessage(error, fallback) {
565
820
  return error instanceof Error && error.message ? error.message : fallback;
@@ -887,9 +1142,9 @@ function shortAddress(address) {
887
1142
  return `${address.slice(0, 8)}...${address.slice(-6)}`;
888
1143
  }
889
1144
  var ISSUE_MARK = {
890
- error: chalk.red("\u2717"),
891
- warning: chalk.yellow("\u26A0"),
892
- info: chalk.cyan("\u2022")
1145
+ error: chalk2.red("\u2717"),
1146
+ warning: chalk2.yellow("\u26A0"),
1147
+ info: chalk2.cyan("\u2022")
893
1148
  };
894
1149
  function printReport(report) {
895
1150
  if (isJsonMode()) {
@@ -898,18 +1153,18 @@ function printReport(report) {
898
1153
  }
899
1154
  printHeader("Conto Doctor");
900
1155
  for (const c of report.checks) {
901
- console.log(` ${mark(c.status)} ${chalk.bold(c.name)}`);
902
- console.log(` ${chalk.dim(c.detail)}`);
1156
+ console.log(` ${mark(c.status)} ${chalk2.bold(c.name)}`);
1157
+ console.log(` ${chalk2.dim(c.detail)}`);
903
1158
  }
904
1159
  console.log("");
905
1160
  if (report.issues.length > 0) {
906
- console.log(` ${chalk.bold("Next steps")}`);
1161
+ console.log(` ${chalk2.bold("Next steps")}`);
907
1162
  for (const issue of report.issues) {
908
1163
  const who = issue.actor === "owner" ? "owner action" : "agent action";
909
- console.log(` ${ISSUE_MARK[issue.severity] ?? "\u2022"} ${chalk.bold(issue.code)} (${who})`);
1164
+ console.log(` ${ISSUE_MARK[issue.severity] ?? "\u2022"} ${chalk2.bold(issue.code)} (${who})`);
910
1165
  console.log(` ${issue.message}`);
911
1166
  for (const action of issue.actions) {
912
- console.log(` ${chalk.dim(describeAction(action, report.baseUrl))}`);
1167
+ console.log(` ${chalk2.dim(describeAction(action, report.baseUrl))}`);
913
1168
  }
914
1169
  }
915
1170
  console.log("");
@@ -917,19 +1172,19 @@ function printReport(report) {
917
1172
  const fails = report.checks.filter((c) => c.status === "fail").length;
918
1173
  const warns = report.checks.filter((c) => c.status === "warn").length;
919
1174
  if (report.exitCode === DOCTOR_EXIT_CODES.UNAVAILABLE) {
920
- console.log(chalk.red(" The check could not complete. Nothing was verified."));
1175
+ console.log(chalk2.red(" The check could not complete. Nothing was verified."));
921
1176
  } else if (report.exitCode === DOCTOR_EXIT_CODES.OK && warns === 0) {
922
- console.log(chalk.green(" All checks passed."));
1177
+ console.log(chalk2.green(" All checks passed."));
923
1178
  } else if (report.exitCode === DOCTOR_EXIT_CODES.OK) {
924
1179
  console.log(
925
- chalk.yellow(
1180
+ chalk2.yellow(
926
1181
  ` ${warns} warning${warns === 1 ? "" : "s"}. Payments may still work; read the notes above.`
927
1182
  )
928
1183
  );
929
1184
  } else if (fails > 0) {
930
- console.log(chalk.red(` ${fails} check${fails === 1 ? "" : "s"} failed.`));
1185
+ console.log(chalk2.red(` ${fails} check${fails === 1 ? "" : "s"} failed.`));
931
1186
  } else {
932
- console.log(chalk.red(" Action required. See the next steps above."));
1187
+ console.log(chalk2.red(" Action required. See the next steps above."));
933
1188
  }
934
1189
  console.log("");
935
1190
  }
@@ -981,10 +1236,10 @@ async function balanceCommand() {
981
1236
 
982
1237
  // src/commands/pay.ts
983
1238
  import { randomUUID } from "crypto";
984
- import chalk3 from "chalk";
1239
+ import chalk4 from "chalk";
985
1240
 
986
1241
  // src/lib/payment-review.ts
987
- import chalk2 from "chalk";
1242
+ import chalk3 from "chalk";
988
1243
  var PAYMENT_EXIT_CODES_HELP = `
989
1244
  Payments that need approval:
990
1245
  the command prints a review link, opens it when it can, waits for the
@@ -1075,10 +1330,10 @@ function paymentReviewExitCode(review) {
1075
1330
  function printReviewOutcome(review, requestId) {
1076
1331
  if (review.nextAction.type === "WAIT_FOR_REVIEW") {
1077
1332
  printPending("Still waiting for approval. Nothing was sent.");
1078
- console.log(chalk2.dim(` Check later with: conto pay status ${requestId}`));
1333
+ console.log(chalk3.dim(` Check later with: conto pay status ${requestId}`));
1079
1334
  return;
1080
1335
  }
1081
- console.log(chalk2.dim(` ${review.nextAction.message}`));
1336
+ console.log(chalk3.dim(` ${review.nextAction.message}`));
1082
1337
  }
1083
1338
 
1084
1339
  // src/commands/pay.ts
@@ -1133,12 +1388,12 @@ function exitOutcomeUnknown(message, code, identity) {
1133
1388
  printWarning(
1134
1389
  requestId ? "Outcome unknown: this payment may have gone through." : "Outcome unknown: Conto may have recorded this request."
1135
1390
  );
1136
- console.log(chalk3.dim(" Do not re-run this command as it is. It would start a new payment."));
1391
+ console.log(chalk4.dim(" Do not re-run this command as it is. It would start a new payment."));
1137
1392
  if (requestId) {
1138
1393
  printKeyValue("Request ID", requestId);
1139
- console.log(chalk3.dim(` Check it with: ${nextAction}`));
1394
+ console.log(chalk4.dim(` Check it with: ${nextAction}`));
1140
1395
  } else {
1141
- console.log(chalk3.dim(` ${nextAction}. That returns the same request.`));
1396
+ console.log(chalk4.dim(` ${nextAction}. That returns the same request.`));
1142
1397
  }
1143
1398
  process.exit(PAY_EXIT_OUTCOME_UNKNOWN);
1144
1399
  }
@@ -1161,18 +1416,18 @@ function handlePayError(err, identity = {}) {
1161
1416
  printError(message);
1162
1417
  if (code === "INSUFFICIENT_SCOPE") {
1163
1418
  console.log(
1164
- chalk3.dim(' This SDK key cannot execute payments. Run "conto doctor" to see its scopes,')
1419
+ chalk4.dim(' This SDK key cannot execute payments. Run "conto doctor" to see its scopes,')
1165
1420
  );
1166
- console.log(chalk3.dim(" or create a new standard SDK key (includes payments:execute)."));
1421
+ console.log(chalk4.dim(" or create a new standard SDK key (includes payments:execute)."));
1167
1422
  } else if (nothingSent) {
1168
1423
  console.log(
1169
- chalk3.dim(" Nothing was sent. Try again later or contact Conto support if it continues.")
1424
+ chalk4.dim(" Nothing was sent. Try again later or contact Conto support if it continues.")
1170
1425
  );
1171
1426
  }
1172
1427
  if (requestId) {
1173
1428
  printKeyValue("Request ID", requestId);
1174
1429
  console.log(
1175
- chalk3.dim(
1430
+ chalk4.dim(
1176
1431
  nothingSent ? ` Send it later with: ${sendLater}` : ` Check it with: conto pay status ${requestId}`
1177
1432
  )
1178
1433
  );
@@ -1211,7 +1466,7 @@ async function reportStoredPayment(api, requestId) {
1211
1466
  break;
1212
1467
  case "approved":
1213
1468
  printPending("Approved and not sent yet.");
1214
- console.log(chalk3.dim(` Send it with: conto pay execute ${requestId}`));
1469
+ console.log(chalk4.dim(` Send it with: conto pay execute ${requestId}`));
1215
1470
  break;
1216
1471
  case "reconciliation_required":
1217
1472
  printWarning("Conto is confirming whether this transfer went through. Do not send it again.");
@@ -1227,7 +1482,7 @@ async function reportStoredPayment(api, requestId) {
1227
1482
  break;
1228
1483
  default:
1229
1484
  printPending(`Payment is ${payment.status}.`);
1230
- console.log(chalk3.dim(" Check the Conto dashboard for next steps."));
1485
+ console.log(chalk4.dim(" Check the Conto dashboard for next steps."));
1231
1486
  }
1232
1487
  if (payment.transaction?.txHash) printKeyValue("TX Hash", payment.transaction.txHash);
1233
1488
  printKeyValue("Amount", printAmount(payment.amount, payment.currency));
@@ -1236,7 +1491,7 @@ async function reportStoredPayment(api, requestId) {
1236
1491
  printKeyValue("Request ID", requestId);
1237
1492
  if (payment.transaction?.explorerUrl) printKeyValue("Explorer", payment.transaction.explorerUrl);
1238
1493
  if (payment.reasons?.length) {
1239
- console.log(chalk3.dim(` Reasons: ${payment.reasons.join(", ")}`));
1494
+ console.log(chalk4.dim(` Reasons: ${payment.reasons.join(", ")}`));
1240
1495
  }
1241
1496
  console.log("");
1242
1497
  }
@@ -1303,7 +1558,7 @@ async function payCommand(address, amountStr, options) {
1303
1558
  });
1304
1559
  } else {
1305
1560
  for (const error of validation.errors) printError(error);
1306
- console.log(chalk3.dim(`
1561
+ console.log(chalk4.dim(`
1307
1562
  ${DRY_RUN_NOTICE}`));
1308
1563
  }
1309
1564
  process.exit(1);
@@ -1327,15 +1582,15 @@ async function payCommand(address, amountStr, options) {
1327
1582
  if (options.wallet) printKeyValue("Wallet", options.wallet);
1328
1583
  console.log("");
1329
1584
  printSuccess("Input is valid");
1330
- console.log(chalk3.dim(` Would send: POST ${url}`));
1331
- console.log(chalk3.dim(` ${JSON.stringify({ ...validation.body, ...identity })}`));
1585
+ console.log(chalk4.dim(` Would send: POST ${url}`));
1586
+ console.log(chalk4.dim(` ${JSON.stringify({ ...validation.body, ...identity })}`));
1332
1587
  if (!config.apiKey) {
1333
1588
  printWarning('No API key configured. Run "conto login" before sending payments.');
1334
1589
  }
1335
1590
  console.log("");
1336
1591
  printWarning(DRY_RUN_NOTICE);
1337
- console.log(chalk3.dim(' Run "conto limits" to see current spend limits.'));
1338
- console.log(chalk3.dim(" Run without --dry-run to submit the payment for policy evaluation."));
1592
+ console.log(chalk4.dim(' Run "conto limits" to see current spend limits.'));
1593
+ console.log(chalk4.dim(" Run without --dry-run to submit the payment for policy evaluation."));
1339
1594
  console.log("");
1340
1595
  return;
1341
1596
  }
@@ -1383,7 +1638,7 @@ async function payCommand(address, amountStr, options) {
1383
1638
  printSuccess("This payment was already sent. No new payment was created.");
1384
1639
  printKeyValue("Status", request.status);
1385
1640
  printKeyValue("Request ID", request.requestId);
1386
- console.log(chalk3.dim(` Check it with: conto pay status ${request.requestId}`));
1641
+ console.log(chalk4.dim(` Check it with: conto pay status ${request.requestId}`));
1387
1642
  return;
1388
1643
  }
1389
1644
  if (request.status === "DENIED") {
@@ -1394,11 +1649,11 @@ async function payCommand(address, amountStr, options) {
1394
1649
  printError("Payment denied by policy");
1395
1650
  if (request.violations) {
1396
1651
  for (const v of request.violations) {
1397
- console.log(chalk3.red(` ${v.message}`));
1652
+ console.log(chalk4.red(` ${v.message}`));
1398
1653
  }
1399
1654
  }
1400
1655
  if (request.reasons.length > 0) {
1401
- console.log(chalk3.dim(`
1656
+ console.log(chalk4.dim(`
1402
1657
  Reasons: ${request.reasons.join(", ")}`));
1403
1658
  }
1404
1659
  process.exit(1);
@@ -1415,9 +1670,9 @@ async function payCommand(address, amountStr, options) {
1415
1670
  printPending(`Payment is ${request.status}`);
1416
1671
  printKeyValue("Request ID", request.requestId);
1417
1672
  if (request.reasons.length > 0) {
1418
- console.log(chalk3.dim(` Reasons: ${request.reasons.join(", ")}`));
1673
+ console.log(chalk4.dim(` Reasons: ${request.reasons.join(", ")}`));
1419
1674
  }
1420
- console.log(chalk3.dim(" Check the Conto dashboard for next steps."));
1675
+ console.log(chalk4.dim(" Check the Conto dashboard for next steps."));
1421
1676
  return;
1422
1677
  }
1423
1678
  printRecoveryId("Request ID", request.requestId);
@@ -1515,7 +1770,7 @@ async function transactionsCommand(id2, options) {
1515
1770
  }
1516
1771
 
1517
1772
  // src/commands/wallets.ts
1518
- import chalk4 from "chalk";
1773
+ import chalk5 from "chalk";
1519
1774
  async function walletsCommand(subcommand, options = {}) {
1520
1775
  const config = loadConfig();
1521
1776
  if (!config.apiKey) {
@@ -1628,20 +1883,20 @@ async function walletsCommand(subcommand, options = {}) {
1628
1883
  console.log("");
1629
1884
  if (chainEntry?.faucetAvailable && config.testnet) {
1630
1885
  console.log(
1631
- chalk4.cyan(
1886
+ chalk5.cyan(
1632
1887
  ' This is a testnet wallet. Use "conto fund --faucet" to get free test tokens.'
1633
1888
  )
1634
1889
  );
1635
1890
  console.log("");
1636
1891
  } else {
1637
- console.log(` To fund your agent wallet, send ${chalk4.bold(w.currency || "USD")} to:
1892
+ console.log(` To fund your agent wallet, send ${chalk5.bold(w.currency || "USD")} to:
1638
1893
  `);
1639
- console.log(chalk4.bold(` ${w.address}`));
1894
+ console.log(chalk5.bold(` ${w.address}`));
1640
1895
  console.log("");
1641
1896
  const instructions = getFundingInstructions(w.currency || "USD", chainEntry);
1642
1897
  console.log(` How to get ${w.currency || "USD"}:`);
1643
1898
  for (const instruction of instructions) {
1644
- console.log(` ${chalk4.dim("\u2022")} ${instruction}`);
1899
+ console.log(` ${chalk5.dim("\u2022")} ${instruction}`);
1645
1900
  }
1646
1901
  console.log("");
1647
1902
  if (chainEntry) {
@@ -1693,7 +1948,7 @@ function getFundingInstructions(currency, chain) {
1693
1948
  }
1694
1949
 
1695
1950
  // src/commands/policies.ts
1696
- import chalk5 from "chalk";
1951
+ import chalk6 from "chalk";
1697
1952
  import * as p from "@clack/prompts";
1698
1953
  var POLICY_TYPES = [
1699
1954
  {
@@ -2015,21 +2270,21 @@ async function listAgentPolicies(api) {
2015
2270
  }
2016
2271
  printHeader("Agent Policies");
2017
2272
  for (const policy of policies) {
2018
- const scope = policy.scope === "organization" ? chalk5.dim("[organization]") : chalk5.cyan(`[${policy.appliesVia.join("+")}]`);
2273
+ const scope = policy.scope === "organization" ? chalk6.dim("[organization]") : chalk6.cyan(`[${policy.appliesVia.join("+")}]`);
2019
2274
  console.log(
2020
2275
  `
2021
- ${chalk5.bold(policy.name)} ${scope} ${chalk5.dim(`(${policy.policyType}, priority: ${policy.priority})`)}`
2276
+ ${chalk6.bold(policy.name)} ${scope} ${chalk6.dim(`(${policy.policyType}, priority: ${policy.priority})`)}`
2022
2277
  );
2023
- console.log(` ${chalk5.dim("ID:")} ${policy.id}`);
2278
+ console.log(` ${chalk6.dim("ID:")} ${policy.id}`);
2024
2279
  console.log(
2025
- ` ${chalk5.dim("Active:")} ${policy.isActive ? chalk5.green("Yes") : chalk5.red("No")}`
2280
+ ` ${chalk6.dim("Active:")} ${policy.isActive ? chalk6.green("Yes") : chalk6.red("No")}`
2026
2281
  );
2027
2282
  if (policy.rules.length > 0) {
2028
- console.log(` ${chalk5.dim("Rules:")}`);
2283
+ console.log(` ${chalk6.dim("Rules:")}`);
2029
2284
  for (const rule of policy.rules) {
2030
2285
  const valueDisplay = formatRuleValue(rule.ruleType, rule.value);
2031
2286
  console.log(
2032
- ` ${chalk5.dim("\u2022")} ${rule.ruleType} ${rule.operator} ${valueDisplay} \u2192 ${rule.action}`
2287
+ ` ${chalk6.dim("\u2022")} ${rule.ruleType} ${rule.operator} ${valueDisplay} \u2192 ${rule.action}`
2033
2288
  );
2034
2289
  }
2035
2290
  }
@@ -2052,18 +2307,18 @@ async function listAllPolicies(api) {
2052
2307
  const scope = policy.scope === "organization" ? "organization-wide" : `${agentCount} agents`;
2053
2308
  console.log(
2054
2309
  `
2055
- ${chalk5.bold(policy.name)} ${chalk5.dim(`(${policy.policyType}, priority: ${policy.priority}, ${scope})`)}`
2310
+ ${chalk6.bold(policy.name)} ${chalk6.dim(`(${policy.policyType}, priority: ${policy.priority}, ${scope})`)}`
2056
2311
  );
2057
- console.log(` ${chalk5.dim("ID:")} ${policy.id}`);
2312
+ console.log(` ${chalk6.dim("ID:")} ${policy.id}`);
2058
2313
  console.log(
2059
- ` ${chalk5.dim("Active:")} ${policy.isActive ? chalk5.green("Yes") : chalk5.red("No")}`
2314
+ ` ${chalk6.dim("Active:")} ${policy.isActive ? chalk6.green("Yes") : chalk6.red("No")}`
2060
2315
  );
2061
2316
  if (policy.rules.length > 0) {
2062
- console.log(` ${chalk5.dim("Rules:")}`);
2317
+ console.log(` ${chalk6.dim("Rules:")}`);
2063
2318
  for (const rule of policy.rules) {
2064
2319
  const valueDisplay = formatRuleValue(rule.ruleType, rule.value);
2065
2320
  console.log(
2066
- ` ${chalk5.dim("\u2022")} [${rule.id.slice(-6)}] ${rule.ruleType} ${rule.operator} ${valueDisplay} \u2192 ${rule.action}`
2321
+ ` ${chalk6.dim("\u2022")} [${rule.id.slice(-6)}] ${rule.ruleType} ${rule.operator} ${valueDisplay} \u2192 ${rule.action}`
2067
2322
  );
2068
2323
  }
2069
2324
  }
@@ -2411,8 +2666,8 @@ async function promptForRule(policyType) {
2411
2666
  };
2412
2667
  }
2413
2668
  function printPolicyHelp() {
2414
- console.log(chalk5.bold("\n Conto Policy Management\n"));
2415
- console.log(chalk5.bold(" Commands:"));
2669
+ console.log(chalk6.bold("\n Conto Policy Management\n"));
2670
+ console.log(chalk6.bold(" Commands:"));
2416
2671
  console.log(" conto policies List agent policies");
2417
2672
  console.log(" conto policies all List all org policies");
2418
2673
  console.log(" conto policies create Create a new policy");
@@ -2423,11 +2678,11 @@ function printPolicyHelp() {
2423
2678
  console.log(" conto policies add-rule <id> Add a rule");
2424
2679
  console.log(" conto policies remove-rule <id> <rid> Remove a rule");
2425
2680
  console.log(" conto policies help This help page");
2426
- console.log(chalk5.bold("\n Policy Types:"));
2681
+ console.log(chalk6.bold("\n Policy Types:"));
2427
2682
  for (const pt of POLICY_TYPES) {
2428
- console.log(` ${chalk5.cyan(pt.value.padEnd(22))} ${chalk5.dim(pt.hint)}`);
2683
+ console.log(` ${chalk6.cyan(pt.value.padEnd(22))} ${chalk6.dim(pt.hint)}`);
2429
2684
  }
2430
- console.log(chalk5.bold("\n Common Rule Types:"));
2685
+ console.log(chalk6.bold("\n Common Rule Types:"));
2431
2686
  const commonRules = [
2432
2687
  ["MAX_AMOUNT", "Max per-transaction amount (e.g. 500)"],
2433
2688
  ["DAILY_LIMIT", "Max total spend per day (e.g. 1000)"],
@@ -2441,9 +2696,9 @@ function printPolicyHelp() {
2441
2696
  ["DATE_RANGE", 'JSON: {"start":"2025-01-01","end":"2025-12-31"}']
2442
2697
  ];
2443
2698
  for (const [rule, desc] of commonRules) {
2444
- console.log(` ${chalk5.cyan(rule.padEnd(28))} ${chalk5.dim(desc)}`);
2699
+ console.log(` ${chalk6.cyan(rule.padEnd(28))} ${chalk6.dim(desc)}`);
2445
2700
  }
2446
- console.log(chalk5.bold("\n Value Examples:"));
2701
+ console.log(chalk6.bold("\n Value Examples:"));
2447
2702
  console.log(" Spend limits: 500");
2448
2703
  console.log(' Address lists: ["0xabc...","0xdef..."]');
2449
2704
  console.log(' Country codes: ["CU","IR","KP","SY","RU"]');
@@ -2451,24 +2706,24 @@ function printPolicyHelp() {
2451
2706
  console.log(' Velocity: {"maxCount":5,"period":"HOUR"}');
2452
2707
  console.log(' Date range: {"start":"2025-01-01","end":"2025-12-31"}');
2453
2708
  console.log(' Categories: ["API_PROVIDER","CLOUD","SAAS"]');
2454
- console.log(chalk5.bold("\n Operators:"));
2709
+ console.log(chalk6.bold("\n Operators:"));
2455
2710
  console.log(" LTE (<= at most) GTE (>= at least) EQUALS NOT_EQUALS");
2456
2711
  console.log(" IN_LIST NOT_IN_LIST BETWEEN DENY");
2457
- console.log(chalk5.bold("\n Actions:"));
2458
- console.log(` ${chalk5.green("ALLOW")} Payment proceeds if rule passes`);
2459
- console.log(` ${chalk5.red("DENY")} Payment is blocked`);
2460
- console.log(` ${chalk5.yellow("REQUIRE_APPROVAL")} Payment needs human approval`);
2461
- console.log(chalk5.bold("\n Examples:"));
2462
- console.log(chalk5.dim(" # Create a $500/day spend limit"));
2712
+ console.log(chalk6.bold("\n Actions:"));
2713
+ console.log(` ${chalk6.green("ALLOW")} Payment proceeds if rule passes`);
2714
+ console.log(` ${chalk6.red("DENY")} Payment is blocked`);
2715
+ console.log(` ${chalk6.yellow("REQUIRE_APPROVAL")} Payment needs human approval`);
2716
+ console.log(chalk6.bold("\n Examples:"));
2717
+ console.log(chalk6.dim(" # Create a $500/day spend limit"));
2463
2718
  console.log(" conto policies create");
2464
- console.log(chalk5.dim(" # Add a weekly limit rule to an existing policy"));
2719
+ console.log(chalk6.dim(" # Add a weekly limit rule to an existing policy"));
2465
2720
  console.log(" conto policies add-rule cmn4abc123");
2466
- console.log(chalk5.dim(" # Deactivate a policy without deleting"));
2721
+ console.log(chalk6.dim(" # Deactivate a policy without deleting"));
2467
2722
  console.log(" conto policies update cmn4abc123");
2468
- console.log(chalk5.dim(" # View all policies as JSON"));
2723
+ console.log(chalk6.dim(" # View all policies as JSON"));
2469
2724
  console.log(" conto policies all --json");
2470
2725
  console.log(`
2471
- ${chalk5.dim("Full docs: https://conto.finance/docs/cli/policies")}
2726
+ ${chalk6.dim("Full docs: https://conto.finance/docs/cli/policies")}
2472
2727
  `);
2473
2728
  }
2474
2729
  function formatRuleValue(ruleType, value) {
@@ -2498,9 +2753,9 @@ async function listVersions(api, policyId) {
2498
2753
  printHeader("Policy versions");
2499
2754
  for (const version of versions) {
2500
2755
  console.log(
2501
- ` ${chalk5.bold(`v${version.version}`)} ${version.changeType.toLowerCase()} ${chalk5.dim(
2756
+ ` ${chalk6.bold(`v${version.version}`)} ${version.changeType.toLowerCase()} ${chalk6.dim(
2502
2757
  new Date(version.createdAt).toLocaleString()
2503
- )} ${version.rulesCount} rule${version.rulesCount === 1 ? "" : "s"}${version.note ? chalk5.dim(` ${version.note}`) : ""}`
2758
+ )} ${version.rulesCount} rule${version.rulesCount === 1 ? "" : "s"}${version.note ? chalk6.dim(` ${version.note}`) : ""}`
2504
2759
  );
2505
2760
  }
2506
2761
  console.log("");
@@ -2553,19 +2808,19 @@ async function simulatePolicy(api, policyId) {
2553
2808
  ` ${summary.allow} allowed, ${summary.deny} blocked, ${summary.requireApproval} need approval`
2554
2809
  );
2555
2810
  console.log(
2556
- chalk5.dim(` ${summary.newlyBlocked} newly blocked, ${summary.newlyAllowed} newly allowed`)
2811
+ chalk6.dim(` ${summary.newlyBlocked} newly blocked, ${summary.newlyAllowed} newly allowed`)
2557
2812
  );
2558
2813
  const changed = results.filter((row) => row.changed).slice(0, 10);
2559
2814
  for (const row of changed) {
2560
2815
  console.log(
2561
- ` ${row.amount} to ${row.recipient ?? "unknown"}: ${row.currentResult} -> ${row.wouldBe}${row.reasons[0] ? chalk5.dim(` ${row.reasons[0]}`) : ""}`
2816
+ ` ${row.amount} to ${row.recipient ?? "unknown"}: ${row.currentResult} -> ${row.wouldBe}${row.reasons[0] ? chalk6.dim(` ${row.reasons[0]}`) : ""}`
2562
2817
  );
2563
2818
  }
2564
2819
  console.log("");
2565
2820
  }
2566
2821
 
2567
2822
  // src/commands/limits.ts
2568
- import chalk6 from "chalk";
2823
+ import chalk7 from "chalk";
2569
2824
  var UNLIMITED = "unlimited";
2570
2825
  async function limitsCommand() {
2571
2826
  const config = loadConfig();
@@ -2592,7 +2847,7 @@ async function limitsCommand() {
2592
2847
  printHeader("Spending Limits");
2593
2848
  for (const l of limits) {
2594
2849
  console.log(`
2595
- ${chalk6.bold(l.walletName)}`);
2850
+ ${chalk7.bold(l.walletName)}`);
2596
2851
  printWindow("Daily: ", l.daily);
2597
2852
  printWindow("Weekly: ", l.weekly);
2598
2853
  printWindow("Monthly: ", l.monthly);
@@ -2615,12 +2870,12 @@ async function limitsCommand() {
2615
2870
  function printWindow(label, window) {
2616
2871
  const spent = printAmount(window.spent, "USD");
2617
2872
  if (window.limit === null) {
2618
- console.log(` ${chalk6.dim(label)} ${UNLIMITED} ${chalk6.dim(`(${spent} spent)`)}`);
2873
+ console.log(` ${chalk7.dim(label)} ${UNLIMITED} ${chalk7.dim(`(${spent} spent)`)}`);
2619
2874
  return;
2620
2875
  }
2621
2876
  const pct = window.limit > 0 ? Math.round(window.spent / window.limit * 100) : 0;
2622
2877
  console.log(
2623
- ` ${chalk6.dim(label)} ${bar(pct)} ${spent} / ${printAmount(window.limit, "USD")} ${chalk6.dim(`(${printAmount(window.remaining ?? 0, "USD")} remaining)`)}`
2878
+ ` ${chalk7.dim(label)} ${bar(pct)} ${spent} / ${printAmount(window.limit, "USD")} ${chalk7.dim(`(${printAmount(window.remaining ?? 0, "USD")} remaining)`)}`
2624
2879
  );
2625
2880
  }
2626
2881
  function bar(pct, width = 15) {
@@ -2632,63 +2887,6 @@ function bar(pct, width = 15) {
2632
2887
 
2633
2888
  // src/commands/alerts.ts
2634
2889
  import chalk8 from "chalk";
2635
-
2636
- // src/lib/owner-command.ts
2637
- import chalk7 from "chalk";
2638
- var LOGIN_HINT = 'This command needs your organization login. Run "conto login" (or set CONTO_ORG_API_KEY) and try again.';
2639
- async function runOwnerCommand(needs, fn) {
2640
- const config = loadConfig();
2641
- if (needs === "org" && !config.orgApiKey) {
2642
- fail(LOGIN_HINT, "ORG_KEY_REQUIRED");
2643
- return;
2644
- }
2645
- if (needs === "sdk" && !config.apiKey) {
2646
- fail(
2647
- 'Not configured. Run "npx @conto_finance/create-conto-agent" or "conto login" first.',
2648
- "SDK_KEY_REQUIRED"
2649
- );
2650
- return;
2651
- }
2652
- const api = createOwnerClient({
2653
- baseUrl: config.baseUrl,
2654
- apiKey: config.apiKey,
2655
- orgApiKey: config.orgApiKey
2656
- });
2657
- try {
2658
- await fn({ api, config });
2659
- } catch (err) {
2660
- const error = err;
2661
- if (error.status === 401) {
2662
- fail(`${error.message}. ${LOGIN_HINT}`, error.code ?? "AUTH_FAILED");
2663
- return;
2664
- }
2665
- fail(error.message || "Request failed", error.code, error.recovery);
2666
- }
2667
- }
2668
- function fail(message, code, recovery) {
2669
- process.exitCode = 1;
2670
- if (isJsonMode()) {
2671
- printJson({
2672
- ok: false,
2673
- error: message,
2674
- ...code ? { code } : {},
2675
- ...recovery ? { recovery } : {}
2676
- });
2677
- return;
2678
- }
2679
- printError(message);
2680
- if (recovery) console.log(chalk7.dim(` ${recovery}`));
2681
- }
2682
- function parseUsd(value, flag) {
2683
- if (value === void 0) return void 0;
2684
- const amount = Number(value);
2685
- if (!Number.isFinite(amount) || amount < 0) {
2686
- throw new Error(`${flag} takes an amount in USD, for example 250`);
2687
- }
2688
- return amount;
2689
- }
2690
-
2691
- // src/commands/alerts.ts
2692
2890
  async function alertsCommand(options = {}) {
2693
2891
  const config = loadConfig();
2694
2892
  if (!config.apiKey) {
@@ -3172,11 +3370,11 @@ async function channelsRemoveCommand(id2, options) {
3172
3370
  // src/commands/changes.ts
3173
3371
  async function changesStatusCommand(changeId, options) {
3174
3372
  await runOwnerCommand("org", async ({ api }) => {
3175
- const change = await api.getOwnerAction(changeId);
3176
- const outcome = await followChange(api, change, { open: false, wait: false, ...options });
3373
+ const change2 = await api.getOwnerAction(changeId);
3374
+ const outcome = await followChange(api, change2, { open: false, wait: false, ...options });
3177
3375
  reportReview(
3178
3376
  outcome,
3179
- change.change.action ? `${change.change.action}: done.` : "Change applied."
3377
+ change2.change.action ? `${change2.change.action}: done.` : "Change applied."
3180
3378
  );
3181
3379
  });
3182
3380
  }
@@ -4470,6 +4668,32 @@ withReview(
4470
4668
  keysGroup.command("create <agentId>").description("Create an SDK key (owner review, shown once)").option("--name <name>", "Key label")
4471
4669
  ).action(agentsKeysCreateCommand);
4472
4670
  keysGroup.command("revoke <agentId> <keyId>").description("Revoke an SDK key").action(agentsKeysRevokeCommand);
4671
+ var teamsGroup = program.command("teams").description("Manage teams of agents, their managers and cost centers").addHelpText(
4672
+ "after",
4673
+ '\nReads work with any organization key. A key made in the dashboard (CONTO_ORG_API_KEY)\nmakes changes directly. With the key from "conto login", every change goes to owner\nreview: the command prints a review link and waits for an owner or admin.\n\nExit codes:\n 0 done, or nothing needed to change\n 1 request failed\n 3 the reviewer declined the change\n 4 waiting for review or governance approval, nothing changed\n 5 the review expired\n'
4674
+ );
4675
+ teamsGroup.command("list").description("List teams").action(teamsListCommand);
4676
+ teamsGroup.command("show <teamId>").description("Show one team").action(teamsShowCommand);
4677
+ withReview(
4678
+ teamsGroup.command("create").description("Create a team").option("--name <name>", "Team name, such as Marketing").option("--slug <slug>", "Department label on its payments (default: from the name)").option("--cost-center <code>", "Cost center or department code")
4679
+ ).action(teamsCreateCommand);
4680
+ withReview(
4681
+ teamsGroup.command("update <teamId>").description("Rename a team or change its cost center").option("--name <name>", "New name").option("--cost-center <code>", "New cost center code").option("--clear-cost-center", "Remove the cost center code")
4682
+ ).action(teamsUpdateCommand);
4683
+ withReview(
4684
+ teamsGroup.command("delete <teamId>").description("Delete a team with no agents, policies or budgets")
4685
+ ).action(teamsDeleteCommand);
4686
+ withReview(
4687
+ teamsGroup.command("managers <teamId> [who...]").description("Replace the managers, by email or membership id (none clears them)")
4688
+ ).action(
4689
+ (teamId, who, options) => teamsManagersCommand(teamId, who ?? [], options)
4690
+ );
4691
+ withReview(
4692
+ teamsGroup.command("add <teamId> <agentIds...>").description("Add agents to a team, moving them from another team").option("--approval <id>", "Approved governance request for this exact change")
4693
+ ).action(teamsAddCommand);
4694
+ withReview(
4695
+ teamsGroup.command("remove <teamId> <agentId>").description("Take an agent out of a team").option("--approval <id>", "Approved governance request for this exact change")
4696
+ ).action(teamsRemoveCommand);
4473
4697
  var payeesGroup = program.command("counterparties").description("Manage the organization's payees");
4474
4698
  payeesGroup.command("list").description("List payees").action(counterpartiesListCommand);
4475
4699
  payeesGroup.command("show <id>").description("Show one payee").action(counterpartiesShowCommand);
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runInit
3
- } from "./chunk-QJIXCSI2.js";
3
+ } from "./chunk-HGEZBNZB.js";
4
4
  import "./chunk-RQ4PUBL7.js";
5
5
  import {
6
6
  isJsonMode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conto_finance/create-conto-agent",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
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",