@conto_finance/create-conto-agent 0.5.1 → 0.7.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.7.0
4
+
5
+ - `conto teams` lists and shows teams, and creates, renames and deletes them. `managers` replaces a
6
+ team's managers by email or membership id, and `add` and `remove` move agents in and out. Reads
7
+ work with any organization key. Changes need an organization key made in the dashboard under
8
+ Developers, set as `CONTO_ORG_API_KEY`, because the key from `conto login` can only tighten
9
+ controls and team changes have no owner review.
10
+ - A move that needs governance approval exits 4 and changes nothing. Once it is approved, run the
11
+ same command with `--approval <id>`.
12
+
13
+ ## 0.6.0
14
+
15
+ - `conto spending export` downloads the organization's spend as CSV, up to 20,000 rows, to stdout or
16
+ to a new private file with `--output`. It never overwrites a file. `--format json --limit 500`
17
+ returns one page and `nextCursor`, and `--cursor` with the same `--from` and `--to` gets the next.
18
+ It uses the configured organization API key, which needs `transactions:read`.
19
+ - `conto policies create` and `conto policies add-rule` save a budget cap as an amount and a period, such as
20
+ `{"amount":500,"period":"MONTHLY"}`. Earlier versions saved a bare number, which the server
21
+ cannot read as a budget, so the rule denied every payment its policy covered. The date range
22
+ example now starts today instead of showing a range that has already ended.
23
+
3
24
  ## 0.5.1
4
25
 
5
26
  - `conto pay` no longer invites a second payment after a failed call. Every run sends an idempotency
package/README.md CHANGED
@@ -116,6 +116,33 @@ 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. Changes need an organization key made in the dashboard under Developers, set as
130
+ `CONTO_ORG_API_KEY`. The key from `conto login` can only tighten controls. If a move needs
131
+ governance approval, the command exits 4 and nothing changes. Once it is approved, run the same
132
+ command with `--approval <id>`.
133
+
134
+ ## Accounting export
135
+
136
+ `conto spending export` downloads organization-wide accounting CSV using your configured
137
+ organization API key (`transactions:read`). Set the range with `--from` and `--to` ISO timestamps.
138
+ `--from` is included and `--to` is not. Use `--output spend.csv` to save a new private file without
139
+ overwriting an existing file. Without `--output`, the export goes to stdout.
140
+
141
+ `conto spending export --format json --limit 500` returns one page and `nextCursor`.
142
+ Pass `--cursor` with the same date bounds for the next page. CSV is limited to 20,000 rows and a
143
+ JSON page to 1,000. Categories are applied at export time. The nullable `receiptPath` links to an
144
+ authenticated Conto transaction receipt, not a merchant invoice.
145
+
119
146
  ## Documentation
120
147
 
121
148
  - [CLI quickstart](https://conto.finance/docs/cli/quickstart)
@@ -30,6 +30,25 @@ function buildVelocityCountValue(input, period) {
30
30
  }
31
31
  return { ok: true, value: JSON.stringify({ maxCount: count, period: normalizedPeriod }) };
32
32
  }
33
+ var BUDGET_PERIODS = ["DAILY", "WEEKLY", "MONTHLY", "QUARTERLY", "YEARLY"];
34
+ function buildBudgetCapValue(input, period) {
35
+ const trimmed = input.trim();
36
+ const amount = Number(trimmed);
37
+ if (trimmed === "" || !Number.isFinite(amount) || amount <= 0) {
38
+ return { ok: false, error: "Budget amount must be a number greater than 0." };
39
+ }
40
+ const normalizedPeriod = period.toUpperCase();
41
+ if (!BUDGET_PERIODS.includes(normalizedPeriod)) {
42
+ return { ok: false, error: `Period must be one of ${BUDGET_PERIODS.join(", ")}.` };
43
+ }
44
+ return { ok: true, value: JSON.stringify({ amount, period: normalizedPeriod }) };
45
+ }
46
+ function dateRangePlaceholder(now = /* @__PURE__ */ new Date()) {
47
+ const start = now.toISOString().slice(0, 10);
48
+ const end = new Date(now);
49
+ end.setUTCFullYear(end.getUTCFullYear() + 1);
50
+ return JSON.stringify({ start, end: end.toISOString().slice(0, 10) });
51
+ }
33
52
  var EVM_ADDRESS = /^0x[a-fA-F0-9]{40}$/;
34
53
  var SOLANA_ADDRESS = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
35
54
  var MAX_PAYMENT_AMOUNT = 1e9;
@@ -72,5 +91,8 @@ export {
72
91
  parseTrustScoreInput,
73
92
  VELOCITY_PERIODS,
74
93
  buildVelocityCountValue,
94
+ BUDGET_PERIODS,
95
+ buildBudgetCapValue,
96
+ dateRangePlaceholder,
75
97
  validatePaymentRequest
76
98
  };
@@ -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.5.1",
24
+ version: "0.7.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,13 +28,16 @@ import {
27
28
  retryAfterSeconds,
28
29
  runInit,
29
30
  writeProjectStateFile
30
- } from "./chunk-YWVIBVYN.js";
31
+ } from "./chunk-YAC3XQVD.js";
31
32
  import {
33
+ BUDGET_PERIODS,
32
34
  VELOCITY_PERIODS,
35
+ buildBudgetCapValue,
33
36
  buildVelocityCountValue,
37
+ dateRangePlaceholder,
34
38
  parseTrustScoreInput,
35
39
  validatePaymentRequest
36
- } from "./chunk-TJJY5NFH.js";
40
+ } from "./chunk-2M2WVAJI.js";
37
41
  import {
38
42
  SANDBOX_SETUP_ENV_FILE,
39
43
  isSensitiveConfigKey,
@@ -102,6 +106,38 @@ async function run(work, owner = false) {
102
106
  }
103
107
  var id = encodeURIComponent;
104
108
  function registerSpendingCommands(program2) {
109
+ program2.command("spending").description("Organization accounting exports").command("export").description(
110
+ "Export cross-rail spend with categories and GL accounts (organization key required)"
111
+ ).option("--from <timestamp>", "Inclusive ISO timestamp").option("--to <timestamp>", "Exclusive ISO timestamp").option("--format <format>", "csv or json (JSON returns one page)").option("--limit <count>", "JSON page size, at most 1000").option("--cursor <cursor>", "JSON nextCursor from the previous page").option("--output <file>", "Save to a new file; refuse to overwrite").action(async (o) => {
112
+ try {
113
+ const config = loadConfig();
114
+ if (!config.orgApiKey)
115
+ throw new Error("An organization key is required for accounting exports.");
116
+ const format = o.format ?? (isJsonMode() ? "json" : "csv");
117
+ if (!["csv", "json"].includes(format)) throw new Error("Format must be csv or json.");
118
+ if (format === "csv" && (o.cursor || o.limit))
119
+ throw new Error("Cursor and limit require JSON format.");
120
+ const query = new URLSearchParams({ format });
121
+ for (const key of ["from", "to", "limit", "cursor"])
122
+ if (o[key] !== void 0) query.set(key, o[key]);
123
+ const api = createApiClient(config);
124
+ const data = format === "csv" ? await api.spendingDownload(`export?${query}`, true) : JSON.stringify(
125
+ await api.spending("GET", `export?${query}`, void 0, true),
126
+ null,
127
+ 2
128
+ ) + "\n";
129
+ if (o.output) {
130
+ await writeFile(o.output, data, { flag: "wx", mode: 384 });
131
+ if (isJsonMode()) printJson({ savedTo: o.output });
132
+ else printKeyValue("Saved", o.output);
133
+ } else process.stdout.write(data);
134
+ } catch (error) {
135
+ const message = error instanceof Error ? error.message : "Export failed";
136
+ if (isJsonMode()) printJson({ error: message });
137
+ else printError(message);
138
+ process.exitCode = 1;
139
+ }
140
+ });
105
141
  const budgets = program2.command("budgets").description("Shared budget availability and owner controls");
106
142
  budgets.command("list").option("--owner", "Use organization credentials").action((o) => run((api) => api.spending("GET", "budgets", void 0, o.owner), o.owner));
107
143
  budgets.command("create <file>").description("Owner: create a budget from a JSON definition").action(
@@ -259,6 +295,206 @@ function registerSpendingCommands(program2) {
259
295
  );
260
296
  }
261
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
+ var DASHBOARD_KEY_HINT = 'Team changes need an organization key made in the dashboard under Developers, set as CONTO_ORG_API_KEY. The key from "conto login" can only tighten controls. You can also make the change in the dashboard under Policies > By agent > Manage teams.';
355
+ async function change(work) {
356
+ try {
357
+ return await work();
358
+ } catch (err) {
359
+ if (isTightenOnlyRefusal(err)) {
360
+ const error = new Error(DASHBOARD_KEY_HINT);
361
+ error.code = "DASHBOARD_KEY_REQUIRED";
362
+ throw error;
363
+ }
364
+ throw err;
365
+ }
366
+ }
367
+ function printTeam(team) {
368
+ printHeader(team.name);
369
+ printKeyValue("ID", team.id);
370
+ printKeyValue("Department label", team.slug);
371
+ printKeyValue("Cost center", team.costCenterCode ?? "-");
372
+ printKeyValue(
373
+ "Managers",
374
+ team.managers.length ? team.managers.map((m) => m.email ?? m.name ?? m.membershipId).join(", ") : "-"
375
+ );
376
+ printKeyValue("Agents", team.agentCount);
377
+ printKeyValue("Policies", team.policyCount);
378
+ }
379
+ function reportMove(result, command, applied) {
380
+ if ("requiresGovernanceApproval" in result) {
381
+ process.exitCode = EXIT_PENDING;
382
+ if (isJsonMode()) return printJson(result);
383
+ printPending("This change waits for governance approval. Nothing has changed yet.");
384
+ printKeyValue("Approval", result.approvalRequest.id);
385
+ printInfo(`Once it is approved, run: ${command} --approval ${result.approvalRequest.id}`);
386
+ return;
387
+ }
388
+ if (isJsonMode()) return printJson(result);
389
+ printSuccess(applied);
390
+ }
391
+ async function teamsListCommand() {
392
+ await runOwnerCommand("org", async ({ api }) => {
393
+ const { teams } = await api.listTeams();
394
+ if (isJsonMode()) return printJson(teams);
395
+ if (teams.length === 0)
396
+ return printInfo("No teams yet. Create one with: conto teams create --name <name>");
397
+ printHeader("Teams");
398
+ printTable(
399
+ ["ID", "Name", "Cost center", "Managers", "Agents", "Policies"],
400
+ teams.map((team) => [
401
+ team.id,
402
+ team.name,
403
+ team.costCenterCode ?? "-",
404
+ String(team.managers.length),
405
+ String(team.agentCount),
406
+ String(team.policyCount)
407
+ ])
408
+ );
409
+ });
410
+ }
411
+ async function teamsShowCommand(teamId) {
412
+ await runOwnerCommand("org", async ({ api }) => {
413
+ const { team } = await api.getTeam(teamId);
414
+ if (isJsonMode()) return printJson(team);
415
+ printTeam(team);
416
+ });
417
+ }
418
+ async function teamsCreateCommand(options) {
419
+ await runOwnerCommand("org", async ({ api }) => {
420
+ if (!options.name) throw new Error("Pass --name.");
421
+ const { team } = await change(
422
+ () => api.createTeam({
423
+ name: options.name,
424
+ ...options.slug ? { slug: options.slug } : {},
425
+ ...options.costCenter ? { costCenterCode: options.costCenter } : {}
426
+ })
427
+ );
428
+ if (isJsonMode()) return printJson(team);
429
+ printSuccess(`Team ${team.name} created.`);
430
+ printKeyValue("ID", team.id);
431
+ });
432
+ }
433
+ async function teamsUpdateCommand(teamId, options) {
434
+ await runOwnerCommand("org", async ({ api }) => {
435
+ if (options.costCenter && options.clearCostCenter) {
436
+ throw new Error("Choose either --cost-center or --clear-cost-center.");
437
+ }
438
+ const body = {
439
+ ...options.name ? { name: options.name } : {},
440
+ ...options.costCenter ? { costCenterCode: options.costCenter } : {},
441
+ ...options.clearCostCenter ? { costCenterCode: null } : {}
442
+ };
443
+ if (Object.keys(body).length === 0) {
444
+ throw new Error("Pass --name, --cost-center or --clear-cost-center.");
445
+ }
446
+ const { team } = await change(() => api.updateTeam(teamId, body));
447
+ if (isJsonMode()) return printJson(team);
448
+ printSuccess(`Team ${team.name} updated.`);
449
+ });
450
+ }
451
+ async function teamsDeleteCommand(teamId) {
452
+ await runOwnerCommand("org", async ({ api }) => {
453
+ const result = await change(() => api.deleteTeam(teamId));
454
+ if (isJsonMode()) return printJson(result);
455
+ printSuccess("Team deleted.");
456
+ });
457
+ }
458
+ async function teamsManagersCommand(teamId, who) {
459
+ await runOwnerCommand("org", async ({ api }) => {
460
+ const emails = who.filter((entry) => entry.includes("@"));
461
+ let membershipIds = who.filter((entry) => !entry.includes("@"));
462
+ if (emails.length > 0) {
463
+ const { members } = await api.listMembers();
464
+ for (const email of emails) {
465
+ const member = members.find((m) => m.user?.email?.toLowerCase() === email.toLowerCase());
466
+ if (!member) throw new Error(`No organization member has the email ${email}.`);
467
+ membershipIds = [...membershipIds, member.id];
468
+ }
469
+ }
470
+ const { team } = await change(() => api.setTeamManagers(teamId, membershipIds));
471
+ if (isJsonMode()) return printJson(team);
472
+ printSuccess(
473
+ team.managers.length ? `${team.name} is managed by ${team.managers.map((m) => m.email ?? m.membershipId).join(", ")}.` : `${team.name} has no managers now.`
474
+ );
475
+ });
476
+ }
477
+ async function teamsAddCommand(teamId, agentIds, options) {
478
+ await runOwnerCommand("org", async ({ api }) => {
479
+ const result = await change(() => api.addTeamAgents(teamId, agentIds, options.approval));
480
+ reportMove(
481
+ result,
482
+ `conto teams add ${teamId} ${agentIds.join(" ")}`,
483
+ `Added ${agentIds.length} agent(s) to the team.`
484
+ );
485
+ });
486
+ }
487
+ async function teamsRemoveCommand(teamId, agentId, options) {
488
+ await runOwnerCommand("org", async ({ api }) => {
489
+ const result = await change(() => api.removeTeamAgent(teamId, agentId, options.approval));
490
+ reportMove(
491
+ result,
492
+ `conto teams remove ${teamId} ${agentId}`,
493
+ "Agent taken out of the team. It no longer follows the team policies."
494
+ );
495
+ });
496
+ }
497
+
262
498
  // src/cli.ts
263
499
  import { Command } from "commander";
264
500
 
@@ -361,7 +597,7 @@ function progressBar(pct, width = 20) {
361
597
  }
362
598
 
363
599
  // src/commands/doctor.ts
364
- import chalk from "chalk";
600
+ import chalk2 from "chalk";
365
601
 
366
602
  // src/lib/setup-diagnostics.ts
367
603
  var SETUP_DIAGNOSTICS_VERSION = "conto.setup-diagnostics.v1";
@@ -522,9 +758,9 @@ function describeAction(action, baseUrl) {
522
758
 
523
759
  // src/commands/doctor.ts
524
760
  function mark(status) {
525
- if (status === "ok") return chalk.green("\u2713");
526
- if (status === "warn") return chalk.yellow("\u26A0");
527
- return chalk.red("\u2717");
761
+ if (status === "ok") return chalk2.green("\u2713");
762
+ if (status === "warn") return chalk2.yellow("\u26A0");
763
+ return chalk2.red("\u2717");
528
764
  }
529
765
  function errorMessage(error, fallback) {
530
766
  return error instanceof Error && error.message ? error.message : fallback;
@@ -852,9 +1088,9 @@ function shortAddress(address) {
852
1088
  return `${address.slice(0, 8)}...${address.slice(-6)}`;
853
1089
  }
854
1090
  var ISSUE_MARK = {
855
- error: chalk.red("\u2717"),
856
- warning: chalk.yellow("\u26A0"),
857
- info: chalk.cyan("\u2022")
1091
+ error: chalk2.red("\u2717"),
1092
+ warning: chalk2.yellow("\u26A0"),
1093
+ info: chalk2.cyan("\u2022")
858
1094
  };
859
1095
  function printReport(report) {
860
1096
  if (isJsonMode()) {
@@ -863,18 +1099,18 @@ function printReport(report) {
863
1099
  }
864
1100
  printHeader("Conto Doctor");
865
1101
  for (const c of report.checks) {
866
- console.log(` ${mark(c.status)} ${chalk.bold(c.name)}`);
867
- console.log(` ${chalk.dim(c.detail)}`);
1102
+ console.log(` ${mark(c.status)} ${chalk2.bold(c.name)}`);
1103
+ console.log(` ${chalk2.dim(c.detail)}`);
868
1104
  }
869
1105
  console.log("");
870
1106
  if (report.issues.length > 0) {
871
- console.log(` ${chalk.bold("Next steps")}`);
1107
+ console.log(` ${chalk2.bold("Next steps")}`);
872
1108
  for (const issue of report.issues) {
873
1109
  const who = issue.actor === "owner" ? "owner action" : "agent action";
874
- console.log(` ${ISSUE_MARK[issue.severity] ?? "\u2022"} ${chalk.bold(issue.code)} (${who})`);
1110
+ console.log(` ${ISSUE_MARK[issue.severity] ?? "\u2022"} ${chalk2.bold(issue.code)} (${who})`);
875
1111
  console.log(` ${issue.message}`);
876
1112
  for (const action of issue.actions) {
877
- console.log(` ${chalk.dim(describeAction(action, report.baseUrl))}`);
1113
+ console.log(` ${chalk2.dim(describeAction(action, report.baseUrl))}`);
878
1114
  }
879
1115
  }
880
1116
  console.log("");
@@ -882,19 +1118,19 @@ function printReport(report) {
882
1118
  const fails = report.checks.filter((c) => c.status === "fail").length;
883
1119
  const warns = report.checks.filter((c) => c.status === "warn").length;
884
1120
  if (report.exitCode === DOCTOR_EXIT_CODES.UNAVAILABLE) {
885
- console.log(chalk.red(" The check could not complete. Nothing was verified."));
1121
+ console.log(chalk2.red(" The check could not complete. Nothing was verified."));
886
1122
  } else if (report.exitCode === DOCTOR_EXIT_CODES.OK && warns === 0) {
887
- console.log(chalk.green(" All checks passed."));
1123
+ console.log(chalk2.green(" All checks passed."));
888
1124
  } else if (report.exitCode === DOCTOR_EXIT_CODES.OK) {
889
1125
  console.log(
890
- chalk.yellow(
1126
+ chalk2.yellow(
891
1127
  ` ${warns} warning${warns === 1 ? "" : "s"}. Payments may still work; read the notes above.`
892
1128
  )
893
1129
  );
894
1130
  } else if (fails > 0) {
895
- console.log(chalk.red(` ${fails} check${fails === 1 ? "" : "s"} failed.`));
1131
+ console.log(chalk2.red(` ${fails} check${fails === 1 ? "" : "s"} failed.`));
896
1132
  } else {
897
- console.log(chalk.red(" Action required. See the next steps above."));
1133
+ console.log(chalk2.red(" Action required. See the next steps above."));
898
1134
  }
899
1135
  console.log("");
900
1136
  }
@@ -946,10 +1182,10 @@ async function balanceCommand() {
946
1182
 
947
1183
  // src/commands/pay.ts
948
1184
  import { randomUUID } from "crypto";
949
- import chalk3 from "chalk";
1185
+ import chalk4 from "chalk";
950
1186
 
951
1187
  // src/lib/payment-review.ts
952
- import chalk2 from "chalk";
1188
+ import chalk3 from "chalk";
953
1189
  var PAYMENT_EXIT_CODES_HELP = `
954
1190
  Payments that need approval:
955
1191
  the command prints a review link, opens it when it can, waits for the
@@ -1040,10 +1276,10 @@ function paymentReviewExitCode(review) {
1040
1276
  function printReviewOutcome(review, requestId) {
1041
1277
  if (review.nextAction.type === "WAIT_FOR_REVIEW") {
1042
1278
  printPending("Still waiting for approval. Nothing was sent.");
1043
- console.log(chalk2.dim(` Check later with: conto pay status ${requestId}`));
1279
+ console.log(chalk3.dim(` Check later with: conto pay status ${requestId}`));
1044
1280
  return;
1045
1281
  }
1046
- console.log(chalk2.dim(` ${review.nextAction.message}`));
1282
+ console.log(chalk3.dim(` ${review.nextAction.message}`));
1047
1283
  }
1048
1284
 
1049
1285
  // src/commands/pay.ts
@@ -1098,12 +1334,12 @@ function exitOutcomeUnknown(message, code, identity) {
1098
1334
  printWarning(
1099
1335
  requestId ? "Outcome unknown: this payment may have gone through." : "Outcome unknown: Conto may have recorded this request."
1100
1336
  );
1101
- console.log(chalk3.dim(" Do not re-run this command as it is. It would start a new payment."));
1337
+ console.log(chalk4.dim(" Do not re-run this command as it is. It would start a new payment."));
1102
1338
  if (requestId) {
1103
1339
  printKeyValue("Request ID", requestId);
1104
- console.log(chalk3.dim(` Check it with: ${nextAction}`));
1340
+ console.log(chalk4.dim(` Check it with: ${nextAction}`));
1105
1341
  } else {
1106
- console.log(chalk3.dim(` ${nextAction}. That returns the same request.`));
1342
+ console.log(chalk4.dim(` ${nextAction}. That returns the same request.`));
1107
1343
  }
1108
1344
  process.exit(PAY_EXIT_OUTCOME_UNKNOWN);
1109
1345
  }
@@ -1126,18 +1362,18 @@ function handlePayError(err, identity = {}) {
1126
1362
  printError(message);
1127
1363
  if (code === "INSUFFICIENT_SCOPE") {
1128
1364
  console.log(
1129
- chalk3.dim(' This SDK key cannot execute payments. Run "conto doctor" to see its scopes,')
1365
+ chalk4.dim(' This SDK key cannot execute payments. Run "conto doctor" to see its scopes,')
1130
1366
  );
1131
- console.log(chalk3.dim(" or create a new standard SDK key (includes payments:execute)."));
1367
+ console.log(chalk4.dim(" or create a new standard SDK key (includes payments:execute)."));
1132
1368
  } else if (nothingSent) {
1133
1369
  console.log(
1134
- chalk3.dim(" Nothing was sent. Try again later or contact Conto support if it continues.")
1370
+ chalk4.dim(" Nothing was sent. Try again later or contact Conto support if it continues.")
1135
1371
  );
1136
1372
  }
1137
1373
  if (requestId) {
1138
1374
  printKeyValue("Request ID", requestId);
1139
1375
  console.log(
1140
- chalk3.dim(
1376
+ chalk4.dim(
1141
1377
  nothingSent ? ` Send it later with: ${sendLater}` : ` Check it with: conto pay status ${requestId}`
1142
1378
  )
1143
1379
  );
@@ -1176,7 +1412,7 @@ async function reportStoredPayment(api, requestId) {
1176
1412
  break;
1177
1413
  case "approved":
1178
1414
  printPending("Approved and not sent yet.");
1179
- console.log(chalk3.dim(` Send it with: conto pay execute ${requestId}`));
1415
+ console.log(chalk4.dim(` Send it with: conto pay execute ${requestId}`));
1180
1416
  break;
1181
1417
  case "reconciliation_required":
1182
1418
  printWarning("Conto is confirming whether this transfer went through. Do not send it again.");
@@ -1192,7 +1428,7 @@ async function reportStoredPayment(api, requestId) {
1192
1428
  break;
1193
1429
  default:
1194
1430
  printPending(`Payment is ${payment.status}.`);
1195
- console.log(chalk3.dim(" Check the Conto dashboard for next steps."));
1431
+ console.log(chalk4.dim(" Check the Conto dashboard for next steps."));
1196
1432
  }
1197
1433
  if (payment.transaction?.txHash) printKeyValue("TX Hash", payment.transaction.txHash);
1198
1434
  printKeyValue("Amount", printAmount(payment.amount, payment.currency));
@@ -1201,7 +1437,7 @@ async function reportStoredPayment(api, requestId) {
1201
1437
  printKeyValue("Request ID", requestId);
1202
1438
  if (payment.transaction?.explorerUrl) printKeyValue("Explorer", payment.transaction.explorerUrl);
1203
1439
  if (payment.reasons?.length) {
1204
- console.log(chalk3.dim(` Reasons: ${payment.reasons.join(", ")}`));
1440
+ console.log(chalk4.dim(` Reasons: ${payment.reasons.join(", ")}`));
1205
1441
  }
1206
1442
  console.log("");
1207
1443
  }
@@ -1268,7 +1504,7 @@ async function payCommand(address, amountStr, options) {
1268
1504
  });
1269
1505
  } else {
1270
1506
  for (const error of validation.errors) printError(error);
1271
- console.log(chalk3.dim(`
1507
+ console.log(chalk4.dim(`
1272
1508
  ${DRY_RUN_NOTICE}`));
1273
1509
  }
1274
1510
  process.exit(1);
@@ -1292,15 +1528,15 @@ async function payCommand(address, amountStr, options) {
1292
1528
  if (options.wallet) printKeyValue("Wallet", options.wallet);
1293
1529
  console.log("");
1294
1530
  printSuccess("Input is valid");
1295
- console.log(chalk3.dim(` Would send: POST ${url}`));
1296
- console.log(chalk3.dim(` ${JSON.stringify({ ...validation.body, ...identity })}`));
1531
+ console.log(chalk4.dim(` Would send: POST ${url}`));
1532
+ console.log(chalk4.dim(` ${JSON.stringify({ ...validation.body, ...identity })}`));
1297
1533
  if (!config.apiKey) {
1298
1534
  printWarning('No API key configured. Run "conto login" before sending payments.');
1299
1535
  }
1300
1536
  console.log("");
1301
1537
  printWarning(DRY_RUN_NOTICE);
1302
- console.log(chalk3.dim(' Run "conto limits" to see current spend limits.'));
1303
- console.log(chalk3.dim(" Run without --dry-run to submit the payment for policy evaluation."));
1538
+ console.log(chalk4.dim(' Run "conto limits" to see current spend limits.'));
1539
+ console.log(chalk4.dim(" Run without --dry-run to submit the payment for policy evaluation."));
1304
1540
  console.log("");
1305
1541
  return;
1306
1542
  }
@@ -1348,7 +1584,7 @@ async function payCommand(address, amountStr, options) {
1348
1584
  printSuccess("This payment was already sent. No new payment was created.");
1349
1585
  printKeyValue("Status", request.status);
1350
1586
  printKeyValue("Request ID", request.requestId);
1351
- console.log(chalk3.dim(` Check it with: conto pay status ${request.requestId}`));
1587
+ console.log(chalk4.dim(` Check it with: conto pay status ${request.requestId}`));
1352
1588
  return;
1353
1589
  }
1354
1590
  if (request.status === "DENIED") {
@@ -1359,11 +1595,11 @@ async function payCommand(address, amountStr, options) {
1359
1595
  printError("Payment denied by policy");
1360
1596
  if (request.violations) {
1361
1597
  for (const v of request.violations) {
1362
- console.log(chalk3.red(` ${v.message}`));
1598
+ console.log(chalk4.red(` ${v.message}`));
1363
1599
  }
1364
1600
  }
1365
1601
  if (request.reasons.length > 0) {
1366
- console.log(chalk3.dim(`
1602
+ console.log(chalk4.dim(`
1367
1603
  Reasons: ${request.reasons.join(", ")}`));
1368
1604
  }
1369
1605
  process.exit(1);
@@ -1380,9 +1616,9 @@ async function payCommand(address, amountStr, options) {
1380
1616
  printPending(`Payment is ${request.status}`);
1381
1617
  printKeyValue("Request ID", request.requestId);
1382
1618
  if (request.reasons.length > 0) {
1383
- console.log(chalk3.dim(` Reasons: ${request.reasons.join(", ")}`));
1619
+ console.log(chalk4.dim(` Reasons: ${request.reasons.join(", ")}`));
1384
1620
  }
1385
- console.log(chalk3.dim(" Check the Conto dashboard for next steps."));
1621
+ console.log(chalk4.dim(" Check the Conto dashboard for next steps."));
1386
1622
  return;
1387
1623
  }
1388
1624
  printRecoveryId("Request ID", request.requestId);
@@ -1480,7 +1716,7 @@ async function transactionsCommand(id2, options) {
1480
1716
  }
1481
1717
 
1482
1718
  // src/commands/wallets.ts
1483
- import chalk4 from "chalk";
1719
+ import chalk5 from "chalk";
1484
1720
  async function walletsCommand(subcommand, options = {}) {
1485
1721
  const config = loadConfig();
1486
1722
  if (!config.apiKey) {
@@ -1593,20 +1829,20 @@ async function walletsCommand(subcommand, options = {}) {
1593
1829
  console.log("");
1594
1830
  if (chainEntry?.faucetAvailable && config.testnet) {
1595
1831
  console.log(
1596
- chalk4.cyan(
1832
+ chalk5.cyan(
1597
1833
  ' This is a testnet wallet. Use "conto fund --faucet" to get free test tokens.'
1598
1834
  )
1599
1835
  );
1600
1836
  console.log("");
1601
1837
  } else {
1602
- console.log(` To fund your agent wallet, send ${chalk4.bold(w.currency || "USD")} to:
1838
+ console.log(` To fund your agent wallet, send ${chalk5.bold(w.currency || "USD")} to:
1603
1839
  `);
1604
- console.log(chalk4.bold(` ${w.address}`));
1840
+ console.log(chalk5.bold(` ${w.address}`));
1605
1841
  console.log("");
1606
1842
  const instructions = getFundingInstructions(w.currency || "USD", chainEntry);
1607
1843
  console.log(` How to get ${w.currency || "USD"}:`);
1608
1844
  for (const instruction of instructions) {
1609
- console.log(` ${chalk4.dim("\u2022")} ${instruction}`);
1845
+ console.log(` ${chalk5.dim("\u2022")} ${instruction}`);
1610
1846
  }
1611
1847
  console.log("");
1612
1848
  if (chainEntry) {
@@ -1658,7 +1894,7 @@ function getFundingInstructions(currency, chain) {
1658
1894
  }
1659
1895
 
1660
1896
  // src/commands/policies.ts
1661
- import chalk5 from "chalk";
1897
+ import chalk6 from "chalk";
1662
1898
  import * as p from "@clack/prompts";
1663
1899
  var POLICY_TYPES = [
1664
1900
  {
@@ -1980,21 +2216,21 @@ async function listAgentPolicies(api) {
1980
2216
  }
1981
2217
  printHeader("Agent Policies");
1982
2218
  for (const policy of policies) {
1983
- const scope = policy.scope === "organization" ? chalk5.dim("[organization]") : chalk5.cyan(`[${policy.appliesVia.join("+")}]`);
2219
+ const scope = policy.scope === "organization" ? chalk6.dim("[organization]") : chalk6.cyan(`[${policy.appliesVia.join("+")}]`);
1984
2220
  console.log(
1985
2221
  `
1986
- ${chalk5.bold(policy.name)} ${scope} ${chalk5.dim(`(${policy.policyType}, priority: ${policy.priority})`)}`
2222
+ ${chalk6.bold(policy.name)} ${scope} ${chalk6.dim(`(${policy.policyType}, priority: ${policy.priority})`)}`
1987
2223
  );
1988
- console.log(` ${chalk5.dim("ID:")} ${policy.id}`);
2224
+ console.log(` ${chalk6.dim("ID:")} ${policy.id}`);
1989
2225
  console.log(
1990
- ` ${chalk5.dim("Active:")} ${policy.isActive ? chalk5.green("Yes") : chalk5.red("No")}`
2226
+ ` ${chalk6.dim("Active:")} ${policy.isActive ? chalk6.green("Yes") : chalk6.red("No")}`
1991
2227
  );
1992
2228
  if (policy.rules.length > 0) {
1993
- console.log(` ${chalk5.dim("Rules:")}`);
2229
+ console.log(` ${chalk6.dim("Rules:")}`);
1994
2230
  for (const rule of policy.rules) {
1995
2231
  const valueDisplay = formatRuleValue(rule.ruleType, rule.value);
1996
2232
  console.log(
1997
- ` ${chalk5.dim("\u2022")} ${rule.ruleType} ${rule.operator} ${valueDisplay} \u2192 ${rule.action}`
2233
+ ` ${chalk6.dim("\u2022")} ${rule.ruleType} ${rule.operator} ${valueDisplay} \u2192 ${rule.action}`
1998
2234
  );
1999
2235
  }
2000
2236
  }
@@ -2017,18 +2253,18 @@ async function listAllPolicies(api) {
2017
2253
  const scope = policy.scope === "organization" ? "organization-wide" : `${agentCount} agents`;
2018
2254
  console.log(
2019
2255
  `
2020
- ${chalk5.bold(policy.name)} ${chalk5.dim(`(${policy.policyType}, priority: ${policy.priority}, ${scope})`)}`
2256
+ ${chalk6.bold(policy.name)} ${chalk6.dim(`(${policy.policyType}, priority: ${policy.priority}, ${scope})`)}`
2021
2257
  );
2022
- console.log(` ${chalk5.dim("ID:")} ${policy.id}`);
2258
+ console.log(` ${chalk6.dim("ID:")} ${policy.id}`);
2023
2259
  console.log(
2024
- ` ${chalk5.dim("Active:")} ${policy.isActive ? chalk5.green("Yes") : chalk5.red("No")}`
2260
+ ` ${chalk6.dim("Active:")} ${policy.isActive ? chalk6.green("Yes") : chalk6.red("No")}`
2025
2261
  );
2026
2262
  if (policy.rules.length > 0) {
2027
- console.log(` ${chalk5.dim("Rules:")}`);
2263
+ console.log(` ${chalk6.dim("Rules:")}`);
2028
2264
  for (const rule of policy.rules) {
2029
2265
  const valueDisplay = formatRuleValue(rule.ruleType, rule.value);
2030
2266
  console.log(
2031
- ` ${chalk5.dim("\u2022")} [${rule.id.slice(-6)}] ${rule.ruleType} ${rule.operator} ${valueDisplay} \u2192 ${rule.action}`
2267
+ ` ${chalk6.dim("\u2022")} [${rule.id.slice(-6)}] ${rule.ruleType} ${rule.operator} ${valueDisplay} \u2192 ${rule.action}`
2032
2268
  );
2033
2269
  }
2034
2270
  }
@@ -2300,6 +2536,36 @@ async function promptForRule(policyType) {
2300
2536
  action: action2
2301
2537
  };
2302
2538
  }
2539
+ if (ruleStr === "BUDGET_CAP") {
2540
+ const period = await p.select({
2541
+ message: "Budget period",
2542
+ options: BUDGET_PERIODS.map((value2) => ({ value: value2, label: value2.toLowerCase() })),
2543
+ initialValue: "MONTHLY"
2544
+ });
2545
+ if (p.isCancel(period)) return null;
2546
+ const amount = await p.text({
2547
+ message: "Budget amount in dollars",
2548
+ placeholder: "500",
2549
+ validate: (v) => {
2550
+ const result = buildBudgetCapValue(v ?? "", period);
2551
+ return result.ok ? void 0 : result.error;
2552
+ }
2553
+ });
2554
+ if (p.isCancel(amount)) return null;
2555
+ const built = buildBudgetCapValue(amount, period);
2556
+ if (!built.ok) return null;
2557
+ const action2 = await p.select({
2558
+ message: "Action when rule triggers",
2559
+ options: ACTIONS
2560
+ });
2561
+ if (p.isCancel(action2)) return null;
2562
+ return {
2563
+ ruleType: ruleStr,
2564
+ operator,
2565
+ value: built.value,
2566
+ action: action2
2567
+ };
2568
+ }
2303
2569
  let placeholder = "500";
2304
2570
  let valueHint = "Enter a number for limits, or JSON for lists";
2305
2571
  if (ruleStr.includes("LIMIT") || ruleStr.includes("AMOUNT") || ruleStr.includes("CAP") || ruleStr === "REQUIRE_APPROVAL_ABOVE") {
@@ -2315,7 +2581,7 @@ async function promptForRule(policyType) {
2315
2581
  placeholder = '["US","GB","DE"]';
2316
2582
  valueHint = "JSON array of country codes";
2317
2583
  } else if (ruleStr === "DATE_RANGE") {
2318
- placeholder = '{"start":"2025-01-01","end":"2025-12-31"}';
2584
+ placeholder = dateRangePlaceholder();
2319
2585
  valueHint = "JSON with start and end dates (ISO format)";
2320
2586
  }
2321
2587
  const value = await p.text({
@@ -2346,8 +2612,8 @@ async function promptForRule(policyType) {
2346
2612
  };
2347
2613
  }
2348
2614
  function printPolicyHelp() {
2349
- console.log(chalk5.bold("\n Conto Policy Management\n"));
2350
- console.log(chalk5.bold(" Commands:"));
2615
+ console.log(chalk6.bold("\n Conto Policy Management\n"));
2616
+ console.log(chalk6.bold(" Commands:"));
2351
2617
  console.log(" conto policies List agent policies");
2352
2618
  console.log(" conto policies all List all org policies");
2353
2619
  console.log(" conto policies create Create a new policy");
@@ -2358,11 +2624,11 @@ function printPolicyHelp() {
2358
2624
  console.log(" conto policies add-rule <id> Add a rule");
2359
2625
  console.log(" conto policies remove-rule <id> <rid> Remove a rule");
2360
2626
  console.log(" conto policies help This help page");
2361
- console.log(chalk5.bold("\n Policy Types:"));
2627
+ console.log(chalk6.bold("\n Policy Types:"));
2362
2628
  for (const pt of POLICY_TYPES) {
2363
- console.log(` ${chalk5.cyan(pt.value.padEnd(22))} ${chalk5.dim(pt.hint)}`);
2629
+ console.log(` ${chalk6.cyan(pt.value.padEnd(22))} ${chalk6.dim(pt.hint)}`);
2364
2630
  }
2365
- console.log(chalk5.bold("\n Common Rule Types:"));
2631
+ console.log(chalk6.bold("\n Common Rule Types:"));
2366
2632
  const commonRules = [
2367
2633
  ["MAX_AMOUNT", "Max per-transaction amount (e.g. 500)"],
2368
2634
  ["DAILY_LIMIT", "Max total spend per day (e.g. 1000)"],
@@ -2376,9 +2642,9 @@ function printPolicyHelp() {
2376
2642
  ["DATE_RANGE", 'JSON: {"start":"2025-01-01","end":"2025-12-31"}']
2377
2643
  ];
2378
2644
  for (const [rule, desc] of commonRules) {
2379
- console.log(` ${chalk5.cyan(rule.padEnd(28))} ${chalk5.dim(desc)}`);
2645
+ console.log(` ${chalk6.cyan(rule.padEnd(28))} ${chalk6.dim(desc)}`);
2380
2646
  }
2381
- console.log(chalk5.bold("\n Value Examples:"));
2647
+ console.log(chalk6.bold("\n Value Examples:"));
2382
2648
  console.log(" Spend limits: 500");
2383
2649
  console.log(' Address lists: ["0xabc...","0xdef..."]');
2384
2650
  console.log(' Country codes: ["CU","IR","KP","SY","RU"]');
@@ -2386,24 +2652,24 @@ function printPolicyHelp() {
2386
2652
  console.log(' Velocity: {"maxCount":5,"period":"HOUR"}');
2387
2653
  console.log(' Date range: {"start":"2025-01-01","end":"2025-12-31"}');
2388
2654
  console.log(' Categories: ["API_PROVIDER","CLOUD","SAAS"]');
2389
- console.log(chalk5.bold("\n Operators:"));
2655
+ console.log(chalk6.bold("\n Operators:"));
2390
2656
  console.log(" LTE (<= at most) GTE (>= at least) EQUALS NOT_EQUALS");
2391
2657
  console.log(" IN_LIST NOT_IN_LIST BETWEEN DENY");
2392
- console.log(chalk5.bold("\n Actions:"));
2393
- console.log(` ${chalk5.green("ALLOW")} Payment proceeds if rule passes`);
2394
- console.log(` ${chalk5.red("DENY")} Payment is blocked`);
2395
- console.log(` ${chalk5.yellow("REQUIRE_APPROVAL")} Payment needs human approval`);
2396
- console.log(chalk5.bold("\n Examples:"));
2397
- console.log(chalk5.dim(" # Create a $500/day spend limit"));
2658
+ console.log(chalk6.bold("\n Actions:"));
2659
+ console.log(` ${chalk6.green("ALLOW")} Payment proceeds if rule passes`);
2660
+ console.log(` ${chalk6.red("DENY")} Payment is blocked`);
2661
+ console.log(` ${chalk6.yellow("REQUIRE_APPROVAL")} Payment needs human approval`);
2662
+ console.log(chalk6.bold("\n Examples:"));
2663
+ console.log(chalk6.dim(" # Create a $500/day spend limit"));
2398
2664
  console.log(" conto policies create");
2399
- console.log(chalk5.dim(" # Add a weekly limit rule to an existing policy"));
2665
+ console.log(chalk6.dim(" # Add a weekly limit rule to an existing policy"));
2400
2666
  console.log(" conto policies add-rule cmn4abc123");
2401
- console.log(chalk5.dim(" # Deactivate a policy without deleting"));
2667
+ console.log(chalk6.dim(" # Deactivate a policy without deleting"));
2402
2668
  console.log(" conto policies update cmn4abc123");
2403
- console.log(chalk5.dim(" # View all policies as JSON"));
2669
+ console.log(chalk6.dim(" # View all policies as JSON"));
2404
2670
  console.log(" conto policies all --json");
2405
2671
  console.log(`
2406
- ${chalk5.dim("Full docs: https://conto.finance/docs/cli/policies")}
2672
+ ${chalk6.dim("Full docs: https://conto.finance/docs/cli/policies")}
2407
2673
  `);
2408
2674
  }
2409
2675
  function formatRuleValue(ruleType, value) {
@@ -2433,9 +2699,9 @@ async function listVersions(api, policyId) {
2433
2699
  printHeader("Policy versions");
2434
2700
  for (const version of versions) {
2435
2701
  console.log(
2436
- ` ${chalk5.bold(`v${version.version}`)} ${version.changeType.toLowerCase()} ${chalk5.dim(
2702
+ ` ${chalk6.bold(`v${version.version}`)} ${version.changeType.toLowerCase()} ${chalk6.dim(
2437
2703
  new Date(version.createdAt).toLocaleString()
2438
- )} ${version.rulesCount} rule${version.rulesCount === 1 ? "" : "s"}${version.note ? chalk5.dim(` ${version.note}`) : ""}`
2704
+ )} ${version.rulesCount} rule${version.rulesCount === 1 ? "" : "s"}${version.note ? chalk6.dim(` ${version.note}`) : ""}`
2439
2705
  );
2440
2706
  }
2441
2707
  console.log("");
@@ -2488,19 +2754,19 @@ async function simulatePolicy(api, policyId) {
2488
2754
  ` ${summary.allow} allowed, ${summary.deny} blocked, ${summary.requireApproval} need approval`
2489
2755
  );
2490
2756
  console.log(
2491
- chalk5.dim(` ${summary.newlyBlocked} newly blocked, ${summary.newlyAllowed} newly allowed`)
2757
+ chalk6.dim(` ${summary.newlyBlocked} newly blocked, ${summary.newlyAllowed} newly allowed`)
2492
2758
  );
2493
2759
  const changed = results.filter((row) => row.changed).slice(0, 10);
2494
2760
  for (const row of changed) {
2495
2761
  console.log(
2496
- ` ${row.amount} to ${row.recipient ?? "unknown"}: ${row.currentResult} -> ${row.wouldBe}${row.reasons[0] ? chalk5.dim(` ${row.reasons[0]}`) : ""}`
2762
+ ` ${row.amount} to ${row.recipient ?? "unknown"}: ${row.currentResult} -> ${row.wouldBe}${row.reasons[0] ? chalk6.dim(` ${row.reasons[0]}`) : ""}`
2497
2763
  );
2498
2764
  }
2499
2765
  console.log("");
2500
2766
  }
2501
2767
 
2502
2768
  // src/commands/limits.ts
2503
- import chalk6 from "chalk";
2769
+ import chalk7 from "chalk";
2504
2770
  var UNLIMITED = "unlimited";
2505
2771
  async function limitsCommand() {
2506
2772
  const config = loadConfig();
@@ -2527,7 +2793,7 @@ async function limitsCommand() {
2527
2793
  printHeader("Spending Limits");
2528
2794
  for (const l of limits) {
2529
2795
  console.log(`
2530
- ${chalk6.bold(l.walletName)}`);
2796
+ ${chalk7.bold(l.walletName)}`);
2531
2797
  printWindow("Daily: ", l.daily);
2532
2798
  printWindow("Weekly: ", l.weekly);
2533
2799
  printWindow("Monthly: ", l.monthly);
@@ -2550,12 +2816,12 @@ async function limitsCommand() {
2550
2816
  function printWindow(label, window) {
2551
2817
  const spent = printAmount(window.spent, "USD");
2552
2818
  if (window.limit === null) {
2553
- console.log(` ${chalk6.dim(label)} ${UNLIMITED} ${chalk6.dim(`(${spent} spent)`)}`);
2819
+ console.log(` ${chalk7.dim(label)} ${UNLIMITED} ${chalk7.dim(`(${spent} spent)`)}`);
2554
2820
  return;
2555
2821
  }
2556
2822
  const pct = window.limit > 0 ? Math.round(window.spent / window.limit * 100) : 0;
2557
2823
  console.log(
2558
- ` ${chalk6.dim(label)} ${bar(pct)} ${spent} / ${printAmount(window.limit, "USD")} ${chalk6.dim(`(${printAmount(window.remaining ?? 0, "USD")} remaining)`)}`
2824
+ ` ${chalk7.dim(label)} ${bar(pct)} ${spent} / ${printAmount(window.limit, "USD")} ${chalk7.dim(`(${printAmount(window.remaining ?? 0, "USD")} remaining)`)}`
2559
2825
  );
2560
2826
  }
2561
2827
  function bar(pct, width = 15) {
@@ -2567,63 +2833,6 @@ function bar(pct, width = 15) {
2567
2833
 
2568
2834
  // src/commands/alerts.ts
2569
2835
  import chalk8 from "chalk";
2570
-
2571
- // src/lib/owner-command.ts
2572
- import chalk7 from "chalk";
2573
- var LOGIN_HINT = 'This command needs your organization login. Run "conto login" (or set CONTO_ORG_API_KEY) and try again.';
2574
- async function runOwnerCommand(needs, fn) {
2575
- const config = loadConfig();
2576
- if (needs === "org" && !config.orgApiKey) {
2577
- fail(LOGIN_HINT, "ORG_KEY_REQUIRED");
2578
- return;
2579
- }
2580
- if (needs === "sdk" && !config.apiKey) {
2581
- fail(
2582
- 'Not configured. Run "npx @conto_finance/create-conto-agent" or "conto login" first.',
2583
- "SDK_KEY_REQUIRED"
2584
- );
2585
- return;
2586
- }
2587
- const api = createOwnerClient({
2588
- baseUrl: config.baseUrl,
2589
- apiKey: config.apiKey,
2590
- orgApiKey: config.orgApiKey
2591
- });
2592
- try {
2593
- await fn({ api, config });
2594
- } catch (err) {
2595
- const error = err;
2596
- if (error.status === 401) {
2597
- fail(`${error.message}. ${LOGIN_HINT}`, error.code ?? "AUTH_FAILED");
2598
- return;
2599
- }
2600
- fail(error.message || "Request failed", error.code, error.recovery);
2601
- }
2602
- }
2603
- function fail(message, code, recovery) {
2604
- process.exitCode = 1;
2605
- if (isJsonMode()) {
2606
- printJson({
2607
- ok: false,
2608
- error: message,
2609
- ...code ? { code } : {},
2610
- ...recovery ? { recovery } : {}
2611
- });
2612
- return;
2613
- }
2614
- printError(message);
2615
- if (recovery) console.log(chalk7.dim(` ${recovery}`));
2616
- }
2617
- function parseUsd(value, flag) {
2618
- if (value === void 0) return void 0;
2619
- const amount = Number(value);
2620
- if (!Number.isFinite(amount) || amount < 0) {
2621
- throw new Error(`${flag} takes an amount in USD, for example 250`);
2622
- }
2623
- return amount;
2624
- }
2625
-
2626
- // src/commands/alerts.ts
2627
2836
  async function alertsCommand(options = {}) {
2628
2837
  const config = loadConfig();
2629
2838
  if (!config.apiKey) {
@@ -3107,11 +3316,11 @@ async function channelsRemoveCommand(id2, options) {
3107
3316
  // src/commands/changes.ts
3108
3317
  async function changesStatusCommand(changeId, options) {
3109
3318
  await runOwnerCommand("org", async ({ api }) => {
3110
- const change = await api.getOwnerAction(changeId);
3111
- const outcome = await followChange(api, change, { open: false, wait: false, ...options });
3319
+ const change2 = await api.getOwnerAction(changeId);
3320
+ const outcome = await followChange(api, change2, { open: false, wait: false, ...options });
3112
3321
  reportReview(
3113
3322
  outcome,
3114
- change.change.action ? `${change.change.action}: done.` : "Change applied."
3323
+ change2.change.action ? `${change2.change.action}: done.` : "Change applied."
3115
3324
  );
3116
3325
  });
3117
3326
  }
@@ -4405,6 +4614,18 @@ withReview(
4405
4614
  keysGroup.command("create <agentId>").description("Create an SDK key (owner review, shown once)").option("--name <name>", "Key label")
4406
4615
  ).action(agentsKeysCreateCommand);
4407
4616
  keysGroup.command("revoke <agentId> <keyId>").description("Revoke an SDK key").action(agentsKeysRevokeCommand);
4617
+ var teamsGroup = program.command("teams").description("Manage teams of agents, their managers and cost centers").addHelpText(
4618
+ "after",
4619
+ '\nReads work with any organization key. Changes need a key made in the dashboard,\nset as CONTO_ORG_API_KEY. The key from "conto login" can only tighten controls.\n\nExit codes:\n 0 done\n 1 request failed\n 4 waiting for governance approval, nothing changed\n'
4620
+ );
4621
+ teamsGroup.command("list").description("List teams").action(teamsListCommand);
4622
+ teamsGroup.command("show <teamId>").description("Show one team").action(teamsShowCommand);
4623
+ 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").action(teamsCreateCommand);
4624
+ 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").action(teamsUpdateCommand);
4625
+ teamsGroup.command("delete <teamId>").description("Delete a team with no agents, policies or budgets").action(teamsDeleteCommand);
4626
+ teamsGroup.command("managers <teamId> [who...]").description("Replace the managers, by email or membership id (none clears them)").action((teamId, who) => teamsManagersCommand(teamId, who ?? []));
4627
+ 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").action(teamsAddCommand);
4628
+ teamsGroup.command("remove <teamId> <agentId>").description("Take an agent out of a team").option("--approval <id>", "Approved governance request for this exact change").action(teamsRemoveCommand);
4408
4629
  var payeesGroup = program.command("counterparties").description("Manage the organization's payees");
4409
4630
  payeesGroup.command("list").description("List payees").action(counterpartiesListCommand);
4410
4631
  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-YWVIBVYN.js";
3
+ } from "./chunk-YAC3XQVD.js";
4
4
  import "./chunk-RQ4PUBL7.js";
5
5
  import {
6
6
  isJsonMode,
@@ -23,6 +23,19 @@ type VelocityPeriod = (typeof VELOCITY_PERIODS)[number];
23
23
  * {"maxCount": n, "period": "HOUR" | "DAY" | "WEEK" | "MONTH"}.
24
24
  */
25
25
  declare function buildVelocityCountValue(input: string, period: string): ValidationResult;
26
+ declare const BUDGET_PERIODS: readonly ["DAILY", "WEEKLY", "MONTHLY", "QUARTERLY", "YEARLY"];
27
+ /**
28
+ * BUDGET_CAP rules are read by the server as {"amount": n, "period": ...}. A
29
+ * bare number has no amount the server can read, so it denies every payment
30
+ * the policy covers.
31
+ */
32
+ declare function buildBudgetCapValue(input: string, period: string): ValidationResult;
33
+ /**
34
+ * An example DATE_RANGE value that is current when the prompt shows it: from
35
+ * today for one year. A fixed example goes out of date and saves a range that
36
+ * has already ended.
37
+ */
38
+ declare function dateRangePlaceholder(now?: Date): string;
26
39
  interface PaymentRequestBody {
27
40
  amount: number;
28
41
  recipientAddress: string;
@@ -49,5 +62,5 @@ declare function validatePaymentRequest(input: {
49
62
  walletId?: string;
50
63
  }): PaymentValidation;
51
64
 
52
- export { VELOCITY_PERIODS, buildVelocityCountValue, parseTrustScoreInput, validatePaymentRequest };
65
+ export { BUDGET_PERIODS, VELOCITY_PERIODS, buildBudgetCapValue, buildVelocityCountValue, dateRangePlaceholder, parseTrustScoreInput, validatePaymentRequest };
53
66
  export type { PaymentRequestBody, PaymentValidation, ValidationResult, VelocityPeriod };
@@ -1,12 +1,18 @@
1
1
  import {
2
+ BUDGET_PERIODS,
2
3
  VELOCITY_PERIODS,
4
+ buildBudgetCapValue,
3
5
  buildVelocityCountValue,
6
+ dateRangePlaceholder,
4
7
  parseTrustScoreInput,
5
8
  validatePaymentRequest
6
- } from "../chunk-TJJY5NFH.js";
9
+ } from "../chunk-2M2WVAJI.js";
7
10
  export {
11
+ BUDGET_PERIODS,
8
12
  VELOCITY_PERIODS,
13
+ buildBudgetCapValue,
9
14
  buildVelocityCountValue,
15
+ dateRangePlaceholder,
10
16
  parseTrustScoreInput,
11
17
  validatePaymentRequest
12
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conto_finance/create-conto-agent",
3
- "version": "0.5.1",
3
+ "version": "0.7.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",