@conto_finance/create-conto-agent 0.6.0 → 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 +10 -0
- package/README.md +15 -0
- package/dist/{chunk-QJIXCSI2.js → chunk-YAC3XQVD.js} +52 -3
- package/dist/cli.js +301 -145
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
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
|
+
|
|
3
13
|
## 0.6.0
|
|
4
14
|
|
|
5
15
|
- `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,21 @@ 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
|
+
|
|
119
134
|
## Accounting export
|
|
120
135
|
|
|
121
136
|
`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.
|
|
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,7 +28,7 @@ import {
|
|
|
27
28
|
retryAfterSeconds,
|
|
28
29
|
runInit,
|
|
29
30
|
writeProjectStateFile
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-YAC3XQVD.js";
|
|
31
32
|
import {
|
|
32
33
|
BUDGET_PERIODS,
|
|
33
34
|
VELOCITY_PERIODS,
|
|
@@ -294,6 +295,206 @@ 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
|
+
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
|
+
|
|
297
498
|
// src/cli.ts
|
|
298
499
|
import { Command } from "commander";
|
|
299
500
|
|
|
@@ -396,7 +597,7 @@ function progressBar(pct, width = 20) {
|
|
|
396
597
|
}
|
|
397
598
|
|
|
398
599
|
// src/commands/doctor.ts
|
|
399
|
-
import
|
|
600
|
+
import chalk2 from "chalk";
|
|
400
601
|
|
|
401
602
|
// src/lib/setup-diagnostics.ts
|
|
402
603
|
var SETUP_DIAGNOSTICS_VERSION = "conto.setup-diagnostics.v1";
|
|
@@ -557,9 +758,9 @@ function describeAction(action, baseUrl) {
|
|
|
557
758
|
|
|
558
759
|
// src/commands/doctor.ts
|
|
559
760
|
function mark(status) {
|
|
560
|
-
if (status === "ok") return
|
|
561
|
-
if (status === "warn") return
|
|
562
|
-
return
|
|
761
|
+
if (status === "ok") return chalk2.green("\u2713");
|
|
762
|
+
if (status === "warn") return chalk2.yellow("\u26A0");
|
|
763
|
+
return chalk2.red("\u2717");
|
|
563
764
|
}
|
|
564
765
|
function errorMessage(error, fallback) {
|
|
565
766
|
return error instanceof Error && error.message ? error.message : fallback;
|
|
@@ -887,9 +1088,9 @@ function shortAddress(address) {
|
|
|
887
1088
|
return `${address.slice(0, 8)}...${address.slice(-6)}`;
|
|
888
1089
|
}
|
|
889
1090
|
var ISSUE_MARK = {
|
|
890
|
-
error:
|
|
891
|
-
warning:
|
|
892
|
-
info:
|
|
1091
|
+
error: chalk2.red("\u2717"),
|
|
1092
|
+
warning: chalk2.yellow("\u26A0"),
|
|
1093
|
+
info: chalk2.cyan("\u2022")
|
|
893
1094
|
};
|
|
894
1095
|
function printReport(report) {
|
|
895
1096
|
if (isJsonMode()) {
|
|
@@ -898,18 +1099,18 @@ function printReport(report) {
|
|
|
898
1099
|
}
|
|
899
1100
|
printHeader("Conto Doctor");
|
|
900
1101
|
for (const c of report.checks) {
|
|
901
|
-
console.log(` ${mark(c.status)} ${
|
|
902
|
-
console.log(` ${
|
|
1102
|
+
console.log(` ${mark(c.status)} ${chalk2.bold(c.name)}`);
|
|
1103
|
+
console.log(` ${chalk2.dim(c.detail)}`);
|
|
903
1104
|
}
|
|
904
1105
|
console.log("");
|
|
905
1106
|
if (report.issues.length > 0) {
|
|
906
|
-
console.log(` ${
|
|
1107
|
+
console.log(` ${chalk2.bold("Next steps")}`);
|
|
907
1108
|
for (const issue of report.issues) {
|
|
908
1109
|
const who = issue.actor === "owner" ? "owner action" : "agent action";
|
|
909
|
-
console.log(` ${ISSUE_MARK[issue.severity] ?? "\u2022"} ${
|
|
1110
|
+
console.log(` ${ISSUE_MARK[issue.severity] ?? "\u2022"} ${chalk2.bold(issue.code)} (${who})`);
|
|
910
1111
|
console.log(` ${issue.message}`);
|
|
911
1112
|
for (const action of issue.actions) {
|
|
912
|
-
console.log(` ${
|
|
1113
|
+
console.log(` ${chalk2.dim(describeAction(action, report.baseUrl))}`);
|
|
913
1114
|
}
|
|
914
1115
|
}
|
|
915
1116
|
console.log("");
|
|
@@ -917,19 +1118,19 @@ function printReport(report) {
|
|
|
917
1118
|
const fails = report.checks.filter((c) => c.status === "fail").length;
|
|
918
1119
|
const warns = report.checks.filter((c) => c.status === "warn").length;
|
|
919
1120
|
if (report.exitCode === DOCTOR_EXIT_CODES.UNAVAILABLE) {
|
|
920
|
-
console.log(
|
|
1121
|
+
console.log(chalk2.red(" The check could not complete. Nothing was verified."));
|
|
921
1122
|
} else if (report.exitCode === DOCTOR_EXIT_CODES.OK && warns === 0) {
|
|
922
|
-
console.log(
|
|
1123
|
+
console.log(chalk2.green(" All checks passed."));
|
|
923
1124
|
} else if (report.exitCode === DOCTOR_EXIT_CODES.OK) {
|
|
924
1125
|
console.log(
|
|
925
|
-
|
|
1126
|
+
chalk2.yellow(
|
|
926
1127
|
` ${warns} warning${warns === 1 ? "" : "s"}. Payments may still work; read the notes above.`
|
|
927
1128
|
)
|
|
928
1129
|
);
|
|
929
1130
|
} else if (fails > 0) {
|
|
930
|
-
console.log(
|
|
1131
|
+
console.log(chalk2.red(` ${fails} check${fails === 1 ? "" : "s"} failed.`));
|
|
931
1132
|
} else {
|
|
932
|
-
console.log(
|
|
1133
|
+
console.log(chalk2.red(" Action required. See the next steps above."));
|
|
933
1134
|
}
|
|
934
1135
|
console.log("");
|
|
935
1136
|
}
|
|
@@ -981,10 +1182,10 @@ async function balanceCommand() {
|
|
|
981
1182
|
|
|
982
1183
|
// src/commands/pay.ts
|
|
983
1184
|
import { randomUUID } from "crypto";
|
|
984
|
-
import
|
|
1185
|
+
import chalk4 from "chalk";
|
|
985
1186
|
|
|
986
1187
|
// src/lib/payment-review.ts
|
|
987
|
-
import
|
|
1188
|
+
import chalk3 from "chalk";
|
|
988
1189
|
var PAYMENT_EXIT_CODES_HELP = `
|
|
989
1190
|
Payments that need approval:
|
|
990
1191
|
the command prints a review link, opens it when it can, waits for the
|
|
@@ -1075,10 +1276,10 @@ function paymentReviewExitCode(review) {
|
|
|
1075
1276
|
function printReviewOutcome(review, requestId) {
|
|
1076
1277
|
if (review.nextAction.type === "WAIT_FOR_REVIEW") {
|
|
1077
1278
|
printPending("Still waiting for approval. Nothing was sent.");
|
|
1078
|
-
console.log(
|
|
1279
|
+
console.log(chalk3.dim(` Check later with: conto pay status ${requestId}`));
|
|
1079
1280
|
return;
|
|
1080
1281
|
}
|
|
1081
|
-
console.log(
|
|
1282
|
+
console.log(chalk3.dim(` ${review.nextAction.message}`));
|
|
1082
1283
|
}
|
|
1083
1284
|
|
|
1084
1285
|
// src/commands/pay.ts
|
|
@@ -1133,12 +1334,12 @@ function exitOutcomeUnknown(message, code, identity) {
|
|
|
1133
1334
|
printWarning(
|
|
1134
1335
|
requestId ? "Outcome unknown: this payment may have gone through." : "Outcome unknown: Conto may have recorded this request."
|
|
1135
1336
|
);
|
|
1136
|
-
console.log(
|
|
1337
|
+
console.log(chalk4.dim(" Do not re-run this command as it is. It would start a new payment."));
|
|
1137
1338
|
if (requestId) {
|
|
1138
1339
|
printKeyValue("Request ID", requestId);
|
|
1139
|
-
console.log(
|
|
1340
|
+
console.log(chalk4.dim(` Check it with: ${nextAction}`));
|
|
1140
1341
|
} else {
|
|
1141
|
-
console.log(
|
|
1342
|
+
console.log(chalk4.dim(` ${nextAction}. That returns the same request.`));
|
|
1142
1343
|
}
|
|
1143
1344
|
process.exit(PAY_EXIT_OUTCOME_UNKNOWN);
|
|
1144
1345
|
}
|
|
@@ -1161,18 +1362,18 @@ function handlePayError(err, identity = {}) {
|
|
|
1161
1362
|
printError(message);
|
|
1162
1363
|
if (code === "INSUFFICIENT_SCOPE") {
|
|
1163
1364
|
console.log(
|
|
1164
|
-
|
|
1365
|
+
chalk4.dim(' This SDK key cannot execute payments. Run "conto doctor" to see its scopes,')
|
|
1165
1366
|
);
|
|
1166
|
-
console.log(
|
|
1367
|
+
console.log(chalk4.dim(" or create a new standard SDK key (includes payments:execute)."));
|
|
1167
1368
|
} else if (nothingSent) {
|
|
1168
1369
|
console.log(
|
|
1169
|
-
|
|
1370
|
+
chalk4.dim(" Nothing was sent. Try again later or contact Conto support if it continues.")
|
|
1170
1371
|
);
|
|
1171
1372
|
}
|
|
1172
1373
|
if (requestId) {
|
|
1173
1374
|
printKeyValue("Request ID", requestId);
|
|
1174
1375
|
console.log(
|
|
1175
|
-
|
|
1376
|
+
chalk4.dim(
|
|
1176
1377
|
nothingSent ? ` Send it later with: ${sendLater}` : ` Check it with: conto pay status ${requestId}`
|
|
1177
1378
|
)
|
|
1178
1379
|
);
|
|
@@ -1211,7 +1412,7 @@ async function reportStoredPayment(api, requestId) {
|
|
|
1211
1412
|
break;
|
|
1212
1413
|
case "approved":
|
|
1213
1414
|
printPending("Approved and not sent yet.");
|
|
1214
|
-
console.log(
|
|
1415
|
+
console.log(chalk4.dim(` Send it with: conto pay execute ${requestId}`));
|
|
1215
1416
|
break;
|
|
1216
1417
|
case "reconciliation_required":
|
|
1217
1418
|
printWarning("Conto is confirming whether this transfer went through. Do not send it again.");
|
|
@@ -1227,7 +1428,7 @@ async function reportStoredPayment(api, requestId) {
|
|
|
1227
1428
|
break;
|
|
1228
1429
|
default:
|
|
1229
1430
|
printPending(`Payment is ${payment.status}.`);
|
|
1230
|
-
console.log(
|
|
1431
|
+
console.log(chalk4.dim(" Check the Conto dashboard for next steps."));
|
|
1231
1432
|
}
|
|
1232
1433
|
if (payment.transaction?.txHash) printKeyValue("TX Hash", payment.transaction.txHash);
|
|
1233
1434
|
printKeyValue("Amount", printAmount(payment.amount, payment.currency));
|
|
@@ -1236,7 +1437,7 @@ async function reportStoredPayment(api, requestId) {
|
|
|
1236
1437
|
printKeyValue("Request ID", requestId);
|
|
1237
1438
|
if (payment.transaction?.explorerUrl) printKeyValue("Explorer", payment.transaction.explorerUrl);
|
|
1238
1439
|
if (payment.reasons?.length) {
|
|
1239
|
-
console.log(
|
|
1440
|
+
console.log(chalk4.dim(` Reasons: ${payment.reasons.join(", ")}`));
|
|
1240
1441
|
}
|
|
1241
1442
|
console.log("");
|
|
1242
1443
|
}
|
|
@@ -1303,7 +1504,7 @@ async function payCommand(address, amountStr, options) {
|
|
|
1303
1504
|
});
|
|
1304
1505
|
} else {
|
|
1305
1506
|
for (const error of validation.errors) printError(error);
|
|
1306
|
-
console.log(
|
|
1507
|
+
console.log(chalk4.dim(`
|
|
1307
1508
|
${DRY_RUN_NOTICE}`));
|
|
1308
1509
|
}
|
|
1309
1510
|
process.exit(1);
|
|
@@ -1327,15 +1528,15 @@ async function payCommand(address, amountStr, options) {
|
|
|
1327
1528
|
if (options.wallet) printKeyValue("Wallet", options.wallet);
|
|
1328
1529
|
console.log("");
|
|
1329
1530
|
printSuccess("Input is valid");
|
|
1330
|
-
console.log(
|
|
1331
|
-
console.log(
|
|
1531
|
+
console.log(chalk4.dim(` Would send: POST ${url}`));
|
|
1532
|
+
console.log(chalk4.dim(` ${JSON.stringify({ ...validation.body, ...identity })}`));
|
|
1332
1533
|
if (!config.apiKey) {
|
|
1333
1534
|
printWarning('No API key configured. Run "conto login" before sending payments.');
|
|
1334
1535
|
}
|
|
1335
1536
|
console.log("");
|
|
1336
1537
|
printWarning(DRY_RUN_NOTICE);
|
|
1337
|
-
console.log(
|
|
1338
|
-
console.log(
|
|
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."));
|
|
1339
1540
|
console.log("");
|
|
1340
1541
|
return;
|
|
1341
1542
|
}
|
|
@@ -1383,7 +1584,7 @@ async function payCommand(address, amountStr, options) {
|
|
|
1383
1584
|
printSuccess("This payment was already sent. No new payment was created.");
|
|
1384
1585
|
printKeyValue("Status", request.status);
|
|
1385
1586
|
printKeyValue("Request ID", request.requestId);
|
|
1386
|
-
console.log(
|
|
1587
|
+
console.log(chalk4.dim(` Check it with: conto pay status ${request.requestId}`));
|
|
1387
1588
|
return;
|
|
1388
1589
|
}
|
|
1389
1590
|
if (request.status === "DENIED") {
|
|
@@ -1394,11 +1595,11 @@ async function payCommand(address, amountStr, options) {
|
|
|
1394
1595
|
printError("Payment denied by policy");
|
|
1395
1596
|
if (request.violations) {
|
|
1396
1597
|
for (const v of request.violations) {
|
|
1397
|
-
console.log(
|
|
1598
|
+
console.log(chalk4.red(` ${v.message}`));
|
|
1398
1599
|
}
|
|
1399
1600
|
}
|
|
1400
1601
|
if (request.reasons.length > 0) {
|
|
1401
|
-
console.log(
|
|
1602
|
+
console.log(chalk4.dim(`
|
|
1402
1603
|
Reasons: ${request.reasons.join(", ")}`));
|
|
1403
1604
|
}
|
|
1404
1605
|
process.exit(1);
|
|
@@ -1415,9 +1616,9 @@ async function payCommand(address, amountStr, options) {
|
|
|
1415
1616
|
printPending(`Payment is ${request.status}`);
|
|
1416
1617
|
printKeyValue("Request ID", request.requestId);
|
|
1417
1618
|
if (request.reasons.length > 0) {
|
|
1418
|
-
console.log(
|
|
1619
|
+
console.log(chalk4.dim(` Reasons: ${request.reasons.join(", ")}`));
|
|
1419
1620
|
}
|
|
1420
|
-
console.log(
|
|
1621
|
+
console.log(chalk4.dim(" Check the Conto dashboard for next steps."));
|
|
1421
1622
|
return;
|
|
1422
1623
|
}
|
|
1423
1624
|
printRecoveryId("Request ID", request.requestId);
|
|
@@ -1515,7 +1716,7 @@ async function transactionsCommand(id2, options) {
|
|
|
1515
1716
|
}
|
|
1516
1717
|
|
|
1517
1718
|
// src/commands/wallets.ts
|
|
1518
|
-
import
|
|
1719
|
+
import chalk5 from "chalk";
|
|
1519
1720
|
async function walletsCommand(subcommand, options = {}) {
|
|
1520
1721
|
const config = loadConfig();
|
|
1521
1722
|
if (!config.apiKey) {
|
|
@@ -1628,20 +1829,20 @@ async function walletsCommand(subcommand, options = {}) {
|
|
|
1628
1829
|
console.log("");
|
|
1629
1830
|
if (chainEntry?.faucetAvailable && config.testnet) {
|
|
1630
1831
|
console.log(
|
|
1631
|
-
|
|
1832
|
+
chalk5.cyan(
|
|
1632
1833
|
' This is a testnet wallet. Use "conto fund --faucet" to get free test tokens.'
|
|
1633
1834
|
)
|
|
1634
1835
|
);
|
|
1635
1836
|
console.log("");
|
|
1636
1837
|
} else {
|
|
1637
|
-
console.log(` To fund your agent wallet, send ${
|
|
1838
|
+
console.log(` To fund your agent wallet, send ${chalk5.bold(w.currency || "USD")} to:
|
|
1638
1839
|
`);
|
|
1639
|
-
console.log(
|
|
1840
|
+
console.log(chalk5.bold(` ${w.address}`));
|
|
1640
1841
|
console.log("");
|
|
1641
1842
|
const instructions = getFundingInstructions(w.currency || "USD", chainEntry);
|
|
1642
1843
|
console.log(` How to get ${w.currency || "USD"}:`);
|
|
1643
1844
|
for (const instruction of instructions) {
|
|
1644
|
-
console.log(` ${
|
|
1845
|
+
console.log(` ${chalk5.dim("\u2022")} ${instruction}`);
|
|
1645
1846
|
}
|
|
1646
1847
|
console.log("");
|
|
1647
1848
|
if (chainEntry) {
|
|
@@ -1693,7 +1894,7 @@ function getFundingInstructions(currency, chain) {
|
|
|
1693
1894
|
}
|
|
1694
1895
|
|
|
1695
1896
|
// src/commands/policies.ts
|
|
1696
|
-
import
|
|
1897
|
+
import chalk6 from "chalk";
|
|
1697
1898
|
import * as p from "@clack/prompts";
|
|
1698
1899
|
var POLICY_TYPES = [
|
|
1699
1900
|
{
|
|
@@ -2015,21 +2216,21 @@ async function listAgentPolicies(api) {
|
|
|
2015
2216
|
}
|
|
2016
2217
|
printHeader("Agent Policies");
|
|
2017
2218
|
for (const policy of policies) {
|
|
2018
|
-
const scope = policy.scope === "organization" ?
|
|
2219
|
+
const scope = policy.scope === "organization" ? chalk6.dim("[organization]") : chalk6.cyan(`[${policy.appliesVia.join("+")}]`);
|
|
2019
2220
|
console.log(
|
|
2020
2221
|
`
|
|
2021
|
-
${
|
|
2222
|
+
${chalk6.bold(policy.name)} ${scope} ${chalk6.dim(`(${policy.policyType}, priority: ${policy.priority})`)}`
|
|
2022
2223
|
);
|
|
2023
|
-
console.log(` ${
|
|
2224
|
+
console.log(` ${chalk6.dim("ID:")} ${policy.id}`);
|
|
2024
2225
|
console.log(
|
|
2025
|
-
` ${
|
|
2226
|
+
` ${chalk6.dim("Active:")} ${policy.isActive ? chalk6.green("Yes") : chalk6.red("No")}`
|
|
2026
2227
|
);
|
|
2027
2228
|
if (policy.rules.length > 0) {
|
|
2028
|
-
console.log(` ${
|
|
2229
|
+
console.log(` ${chalk6.dim("Rules:")}`);
|
|
2029
2230
|
for (const rule of policy.rules) {
|
|
2030
2231
|
const valueDisplay = formatRuleValue(rule.ruleType, rule.value);
|
|
2031
2232
|
console.log(
|
|
2032
|
-
` ${
|
|
2233
|
+
` ${chalk6.dim("\u2022")} ${rule.ruleType} ${rule.operator} ${valueDisplay} \u2192 ${rule.action}`
|
|
2033
2234
|
);
|
|
2034
2235
|
}
|
|
2035
2236
|
}
|
|
@@ -2052,18 +2253,18 @@ async function listAllPolicies(api) {
|
|
|
2052
2253
|
const scope = policy.scope === "organization" ? "organization-wide" : `${agentCount} agents`;
|
|
2053
2254
|
console.log(
|
|
2054
2255
|
`
|
|
2055
|
-
${
|
|
2256
|
+
${chalk6.bold(policy.name)} ${chalk6.dim(`(${policy.policyType}, priority: ${policy.priority}, ${scope})`)}`
|
|
2056
2257
|
);
|
|
2057
|
-
console.log(` ${
|
|
2258
|
+
console.log(` ${chalk6.dim("ID:")} ${policy.id}`);
|
|
2058
2259
|
console.log(
|
|
2059
|
-
` ${
|
|
2260
|
+
` ${chalk6.dim("Active:")} ${policy.isActive ? chalk6.green("Yes") : chalk6.red("No")}`
|
|
2060
2261
|
);
|
|
2061
2262
|
if (policy.rules.length > 0) {
|
|
2062
|
-
console.log(` ${
|
|
2263
|
+
console.log(` ${chalk6.dim("Rules:")}`);
|
|
2063
2264
|
for (const rule of policy.rules) {
|
|
2064
2265
|
const valueDisplay = formatRuleValue(rule.ruleType, rule.value);
|
|
2065
2266
|
console.log(
|
|
2066
|
-
` ${
|
|
2267
|
+
` ${chalk6.dim("\u2022")} [${rule.id.slice(-6)}] ${rule.ruleType} ${rule.operator} ${valueDisplay} \u2192 ${rule.action}`
|
|
2067
2268
|
);
|
|
2068
2269
|
}
|
|
2069
2270
|
}
|
|
@@ -2411,8 +2612,8 @@ async function promptForRule(policyType) {
|
|
|
2411
2612
|
};
|
|
2412
2613
|
}
|
|
2413
2614
|
function printPolicyHelp() {
|
|
2414
|
-
console.log(
|
|
2415
|
-
console.log(
|
|
2615
|
+
console.log(chalk6.bold("\n Conto Policy Management\n"));
|
|
2616
|
+
console.log(chalk6.bold(" Commands:"));
|
|
2416
2617
|
console.log(" conto policies List agent policies");
|
|
2417
2618
|
console.log(" conto policies all List all org policies");
|
|
2418
2619
|
console.log(" conto policies create Create a new policy");
|
|
@@ -2423,11 +2624,11 @@ function printPolicyHelp() {
|
|
|
2423
2624
|
console.log(" conto policies add-rule <id> Add a rule");
|
|
2424
2625
|
console.log(" conto policies remove-rule <id> <rid> Remove a rule");
|
|
2425
2626
|
console.log(" conto policies help This help page");
|
|
2426
|
-
console.log(
|
|
2627
|
+
console.log(chalk6.bold("\n Policy Types:"));
|
|
2427
2628
|
for (const pt of POLICY_TYPES) {
|
|
2428
|
-
console.log(` ${
|
|
2629
|
+
console.log(` ${chalk6.cyan(pt.value.padEnd(22))} ${chalk6.dim(pt.hint)}`);
|
|
2429
2630
|
}
|
|
2430
|
-
console.log(
|
|
2631
|
+
console.log(chalk6.bold("\n Common Rule Types:"));
|
|
2431
2632
|
const commonRules = [
|
|
2432
2633
|
["MAX_AMOUNT", "Max per-transaction amount (e.g. 500)"],
|
|
2433
2634
|
["DAILY_LIMIT", "Max total spend per day (e.g. 1000)"],
|
|
@@ -2441,9 +2642,9 @@ function printPolicyHelp() {
|
|
|
2441
2642
|
["DATE_RANGE", 'JSON: {"start":"2025-01-01","end":"2025-12-31"}']
|
|
2442
2643
|
];
|
|
2443
2644
|
for (const [rule, desc] of commonRules) {
|
|
2444
|
-
console.log(` ${
|
|
2645
|
+
console.log(` ${chalk6.cyan(rule.padEnd(28))} ${chalk6.dim(desc)}`);
|
|
2445
2646
|
}
|
|
2446
|
-
console.log(
|
|
2647
|
+
console.log(chalk6.bold("\n Value Examples:"));
|
|
2447
2648
|
console.log(" Spend limits: 500");
|
|
2448
2649
|
console.log(' Address lists: ["0xabc...","0xdef..."]');
|
|
2449
2650
|
console.log(' Country codes: ["CU","IR","KP","SY","RU"]');
|
|
@@ -2451,24 +2652,24 @@ function printPolicyHelp() {
|
|
|
2451
2652
|
console.log(' Velocity: {"maxCount":5,"period":"HOUR"}');
|
|
2452
2653
|
console.log(' Date range: {"start":"2025-01-01","end":"2025-12-31"}');
|
|
2453
2654
|
console.log(' Categories: ["API_PROVIDER","CLOUD","SAAS"]');
|
|
2454
|
-
console.log(
|
|
2655
|
+
console.log(chalk6.bold("\n Operators:"));
|
|
2455
2656
|
console.log(" LTE (<= at most) GTE (>= at least) EQUALS NOT_EQUALS");
|
|
2456
2657
|
console.log(" IN_LIST NOT_IN_LIST BETWEEN DENY");
|
|
2457
|
-
console.log(
|
|
2458
|
-
console.log(` ${
|
|
2459
|
-
console.log(` ${
|
|
2460
|
-
console.log(` ${
|
|
2461
|
-
console.log(
|
|
2462
|
-
console.log(
|
|
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"));
|
|
2463
2664
|
console.log(" conto policies create");
|
|
2464
|
-
console.log(
|
|
2665
|
+
console.log(chalk6.dim(" # Add a weekly limit rule to an existing policy"));
|
|
2465
2666
|
console.log(" conto policies add-rule cmn4abc123");
|
|
2466
|
-
console.log(
|
|
2667
|
+
console.log(chalk6.dim(" # Deactivate a policy without deleting"));
|
|
2467
2668
|
console.log(" conto policies update cmn4abc123");
|
|
2468
|
-
console.log(
|
|
2669
|
+
console.log(chalk6.dim(" # View all policies as JSON"));
|
|
2469
2670
|
console.log(" conto policies all --json");
|
|
2470
2671
|
console.log(`
|
|
2471
|
-
${
|
|
2672
|
+
${chalk6.dim("Full docs: https://conto.finance/docs/cli/policies")}
|
|
2472
2673
|
`);
|
|
2473
2674
|
}
|
|
2474
2675
|
function formatRuleValue(ruleType, value) {
|
|
@@ -2498,9 +2699,9 @@ async function listVersions(api, policyId) {
|
|
|
2498
2699
|
printHeader("Policy versions");
|
|
2499
2700
|
for (const version of versions) {
|
|
2500
2701
|
console.log(
|
|
2501
|
-
` ${
|
|
2702
|
+
` ${chalk6.bold(`v${version.version}`)} ${version.changeType.toLowerCase()} ${chalk6.dim(
|
|
2502
2703
|
new Date(version.createdAt).toLocaleString()
|
|
2503
|
-
)} ${version.rulesCount} rule${version.rulesCount === 1 ? "" : "s"}${version.note ?
|
|
2704
|
+
)} ${version.rulesCount} rule${version.rulesCount === 1 ? "" : "s"}${version.note ? chalk6.dim(` ${version.note}`) : ""}`
|
|
2504
2705
|
);
|
|
2505
2706
|
}
|
|
2506
2707
|
console.log("");
|
|
@@ -2553,19 +2754,19 @@ async function simulatePolicy(api, policyId) {
|
|
|
2553
2754
|
` ${summary.allow} allowed, ${summary.deny} blocked, ${summary.requireApproval} need approval`
|
|
2554
2755
|
);
|
|
2555
2756
|
console.log(
|
|
2556
|
-
|
|
2757
|
+
chalk6.dim(` ${summary.newlyBlocked} newly blocked, ${summary.newlyAllowed} newly allowed`)
|
|
2557
2758
|
);
|
|
2558
2759
|
const changed = results.filter((row) => row.changed).slice(0, 10);
|
|
2559
2760
|
for (const row of changed) {
|
|
2560
2761
|
console.log(
|
|
2561
|
-
` ${row.amount} to ${row.recipient ?? "unknown"}: ${row.currentResult} -> ${row.wouldBe}${row.reasons[0] ?
|
|
2762
|
+
` ${row.amount} to ${row.recipient ?? "unknown"}: ${row.currentResult} -> ${row.wouldBe}${row.reasons[0] ? chalk6.dim(` ${row.reasons[0]}`) : ""}`
|
|
2562
2763
|
);
|
|
2563
2764
|
}
|
|
2564
2765
|
console.log("");
|
|
2565
2766
|
}
|
|
2566
2767
|
|
|
2567
2768
|
// src/commands/limits.ts
|
|
2568
|
-
import
|
|
2769
|
+
import chalk7 from "chalk";
|
|
2569
2770
|
var UNLIMITED = "unlimited";
|
|
2570
2771
|
async function limitsCommand() {
|
|
2571
2772
|
const config = loadConfig();
|
|
@@ -2592,7 +2793,7 @@ async function limitsCommand() {
|
|
|
2592
2793
|
printHeader("Spending Limits");
|
|
2593
2794
|
for (const l of limits) {
|
|
2594
2795
|
console.log(`
|
|
2595
|
-
${
|
|
2796
|
+
${chalk7.bold(l.walletName)}`);
|
|
2596
2797
|
printWindow("Daily: ", l.daily);
|
|
2597
2798
|
printWindow("Weekly: ", l.weekly);
|
|
2598
2799
|
printWindow("Monthly: ", l.monthly);
|
|
@@ -2615,12 +2816,12 @@ async function limitsCommand() {
|
|
|
2615
2816
|
function printWindow(label, window) {
|
|
2616
2817
|
const spent = printAmount(window.spent, "USD");
|
|
2617
2818
|
if (window.limit === null) {
|
|
2618
|
-
console.log(` ${
|
|
2819
|
+
console.log(` ${chalk7.dim(label)} ${UNLIMITED} ${chalk7.dim(`(${spent} spent)`)}`);
|
|
2619
2820
|
return;
|
|
2620
2821
|
}
|
|
2621
2822
|
const pct = window.limit > 0 ? Math.round(window.spent / window.limit * 100) : 0;
|
|
2622
2823
|
console.log(
|
|
2623
|
-
` ${
|
|
2824
|
+
` ${chalk7.dim(label)} ${bar(pct)} ${spent} / ${printAmount(window.limit, "USD")} ${chalk7.dim(`(${printAmount(window.remaining ?? 0, "USD")} remaining)`)}`
|
|
2624
2825
|
);
|
|
2625
2826
|
}
|
|
2626
2827
|
function bar(pct, width = 15) {
|
|
@@ -2632,63 +2833,6 @@ function bar(pct, width = 15) {
|
|
|
2632
2833
|
|
|
2633
2834
|
// src/commands/alerts.ts
|
|
2634
2835
|
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
2836
|
async function alertsCommand(options = {}) {
|
|
2693
2837
|
const config = loadConfig();
|
|
2694
2838
|
if (!config.apiKey) {
|
|
@@ -3172,11 +3316,11 @@ async function channelsRemoveCommand(id2, options) {
|
|
|
3172
3316
|
// src/commands/changes.ts
|
|
3173
3317
|
async function changesStatusCommand(changeId, options) {
|
|
3174
3318
|
await runOwnerCommand("org", async ({ api }) => {
|
|
3175
|
-
const
|
|
3176
|
-
const outcome = await followChange(api,
|
|
3319
|
+
const change2 = await api.getOwnerAction(changeId);
|
|
3320
|
+
const outcome = await followChange(api, change2, { open: false, wait: false, ...options });
|
|
3177
3321
|
reportReview(
|
|
3178
3322
|
outcome,
|
|
3179
|
-
|
|
3323
|
+
change2.change.action ? `${change2.change.action}: done.` : "Change applied."
|
|
3180
3324
|
);
|
|
3181
3325
|
});
|
|
3182
3326
|
}
|
|
@@ -4470,6 +4614,18 @@ withReview(
|
|
|
4470
4614
|
keysGroup.command("create <agentId>").description("Create an SDK key (owner review, shown once)").option("--name <name>", "Key label")
|
|
4471
4615
|
).action(agentsKeysCreateCommand);
|
|
4472
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);
|
|
4473
4629
|
var payeesGroup = program.command("counterparties").description("Manage the organization's payees");
|
|
4474
4630
|
payeesGroup.command("list").description("List payees").action(counterpartiesListCommand);
|
|
4475
4631
|
payeesGroup.command("show <id>").description("Show one payee").action(counterpartiesShowCommand);
|
package/dist/index.js
CHANGED