@conto_finance/create-conto-agent 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +8 -4
- package/dist/{chunk-YAC3XQVD.js → chunk-HGEZBNZB.js} +1 -1
- package/dist/cli.js +101 -33
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
- With the key from `conto login`, `conto teams` changes now go to owner review instead of failing.
|
|
6
|
+
The command prints a review link and waits for an owner or admin to confirm the change, as it
|
|
7
|
+
does for other changes that key can't make directly. `--no-wait` returns at once, and
|
|
8
|
+
`conto changes status <changeId>` checks the change later. A key made in the dashboard still makes
|
|
9
|
+
team changes directly.
|
|
10
|
+
- A move that takes an agent off a budget can't go through owner review when your organization
|
|
11
|
+
requires approval for budget changes. Make it in the dashboard, or with a dashboard key and
|
|
12
|
+
`--approval <id>`.
|
|
13
|
+
|
|
3
14
|
## 0.7.0
|
|
4
15
|
|
|
5
16
|
- `conto teams` lists and shows teams, and creates, renames and deletes them. `managers` replaces a
|
package/README.md
CHANGED
|
@@ -126,10 +126,14 @@ conto teams list
|
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
A team's policies apply to every agent in it, alongside company policies. Reads work with any
|
|
129
|
-
organization key.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
organization key. With the key from `conto login`, every change goes to owner review: the command
|
|
130
|
+
prints a review link and waits for an owner or admin to confirm it. A key made in the dashboard
|
|
131
|
+
under Developers, set as `CONTO_ORG_API_KEY`, makes the change directly.
|
|
132
|
+
|
|
133
|
+
If your organization requires approval for budget changes and a move takes an agent off a budget,
|
|
134
|
+
the move can't go through owner review. Make it in the dashboard, or with a dashboard key. With a
|
|
135
|
+
dashboard key, the command exits 4 and nothing changes. Once it is approved, run the same command
|
|
136
|
+
with `--approval <id>`.
|
|
133
137
|
|
|
134
138
|
## Accounting export
|
|
135
139
|
|
|
@@ -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.8.0",
|
|
25
25
|
description: "Set up an AI agent with Conto spending controls",
|
|
26
26
|
bin: {
|
|
27
27
|
"create-conto-agent": "bin/create-conto-agent.js",
|
package/dist/cli.js
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
retryAfterSeconds,
|
|
29
29
|
runInit,
|
|
30
30
|
writeProjectStateFile
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-HGEZBNZB.js";
|
|
32
32
|
import {
|
|
33
33
|
BUDGET_PERIODS,
|
|
34
34
|
VELOCITY_PERIODS,
|
|
@@ -351,18 +351,8 @@ function parseUsd(value, flag) {
|
|
|
351
351
|
}
|
|
352
352
|
|
|
353
353
|
// src/commands/teams.ts
|
|
354
|
-
|
|
355
|
-
async
|
|
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
|
-
}
|
|
354
|
+
function change(api, direct, action, input, options) {
|
|
355
|
+
return directOrReview(api, direct, async () => ({ action, input }), options);
|
|
366
356
|
}
|
|
367
357
|
function printTeam(team) {
|
|
368
358
|
printHeader(team.name);
|
|
@@ -418,13 +408,29 @@ async function teamsShowCommand(teamId) {
|
|
|
418
408
|
async function teamsCreateCommand(options) {
|
|
419
409
|
await runOwnerCommand("org", async ({ api }) => {
|
|
420
410
|
if (!options.name) throw new Error("Pass --name.");
|
|
421
|
-
const
|
|
411
|
+
const name = options.name;
|
|
412
|
+
const result = await change(
|
|
413
|
+
api,
|
|
422
414
|
() => api.createTeam({
|
|
423
|
-
name
|
|
415
|
+
name,
|
|
424
416
|
...options.slug ? { slug: options.slug } : {},
|
|
425
417
|
...options.costCenter ? { costCenterCode: options.costCenter } : {}
|
|
426
|
-
})
|
|
418
|
+
}),
|
|
419
|
+
"create_team",
|
|
420
|
+
{
|
|
421
|
+
name,
|
|
422
|
+
...options.slug ? { slug: options.slug } : {},
|
|
423
|
+
...options.costCenter ? { cost_center_code: options.costCenter } : {}
|
|
424
|
+
},
|
|
425
|
+
options
|
|
427
426
|
);
|
|
427
|
+
if ("review" in result) {
|
|
428
|
+
return reportReview(
|
|
429
|
+
result.review,
|
|
430
|
+
`Team ${name} created. Run conto teams list to see its ID.`
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
const { team } = result.direct;
|
|
428
434
|
if (isJsonMode()) return printJson(team);
|
|
429
435
|
printSuccess(`Team ${team.name} created.`);
|
|
430
436
|
printKeyValue("ID", team.id);
|
|
@@ -443,19 +449,38 @@ async function teamsUpdateCommand(teamId, options) {
|
|
|
443
449
|
if (Object.keys(body).length === 0) {
|
|
444
450
|
throw new Error("Pass --name, --cost-center or --clear-cost-center.");
|
|
445
451
|
}
|
|
446
|
-
const
|
|
452
|
+
const result = await change(
|
|
453
|
+
api,
|
|
454
|
+
() => api.updateTeam(teamId, body),
|
|
455
|
+
"update_team",
|
|
456
|
+
{
|
|
457
|
+
team_id: teamId,
|
|
458
|
+
...body.name ? { name: body.name } : {},
|
|
459
|
+
..."costCenterCode" in body ? { cost_center_code: body.costCenterCode } : {}
|
|
460
|
+
},
|
|
461
|
+
options
|
|
462
|
+
);
|
|
463
|
+
if ("review" in result) return reportReview(result.review, "Team updated.");
|
|
464
|
+
const { team } = result.direct;
|
|
447
465
|
if (isJsonMode()) return printJson(team);
|
|
448
466
|
printSuccess(`Team ${team.name} updated.`);
|
|
449
467
|
});
|
|
450
468
|
}
|
|
451
|
-
async function teamsDeleteCommand(teamId) {
|
|
469
|
+
async function teamsDeleteCommand(teamId, options) {
|
|
452
470
|
await runOwnerCommand("org", async ({ api }) => {
|
|
453
|
-
const result = await change(
|
|
454
|
-
|
|
471
|
+
const result = await change(
|
|
472
|
+
api,
|
|
473
|
+
() => api.deleteTeam(teamId),
|
|
474
|
+
"delete_team",
|
|
475
|
+
{ team_id: teamId },
|
|
476
|
+
options
|
|
477
|
+
);
|
|
478
|
+
if ("review" in result) return reportReview(result.review, "Team deleted.");
|
|
479
|
+
if (isJsonMode()) return printJson(result.direct);
|
|
455
480
|
printSuccess("Team deleted.");
|
|
456
481
|
});
|
|
457
482
|
}
|
|
458
|
-
async function teamsManagersCommand(teamId, who) {
|
|
483
|
+
async function teamsManagersCommand(teamId, who, options = {}) {
|
|
459
484
|
await runOwnerCommand("org", async ({ api }) => {
|
|
460
485
|
const emails = who.filter((entry) => entry.includes("@"));
|
|
461
486
|
let membershipIds = who.filter((entry) => !entry.includes("@"));
|
|
@@ -467,7 +492,15 @@ async function teamsManagersCommand(teamId, who) {
|
|
|
467
492
|
membershipIds = [...membershipIds, member.id];
|
|
468
493
|
}
|
|
469
494
|
}
|
|
470
|
-
const
|
|
495
|
+
const result = await change(
|
|
496
|
+
api,
|
|
497
|
+
() => api.setTeamManagers(teamId, membershipIds),
|
|
498
|
+
"set_team_managers",
|
|
499
|
+
{ team_id: teamId, membership_ids: membershipIds },
|
|
500
|
+
options
|
|
501
|
+
);
|
|
502
|
+
if ("review" in result) return reportReview(result.review, "Team managers changed.");
|
|
503
|
+
const { team } = result.direct;
|
|
471
504
|
if (isJsonMode()) return printJson(team);
|
|
472
505
|
printSuccess(
|
|
473
506
|
team.managers.length ? `${team.name} is managed by ${team.managers.map((m) => m.email ?? m.membershipId).join(", ")}.` : `${team.name} has no managers now.`
|
|
@@ -476,9 +509,18 @@ async function teamsManagersCommand(teamId, who) {
|
|
|
476
509
|
}
|
|
477
510
|
async function teamsAddCommand(teamId, agentIds, options) {
|
|
478
511
|
await runOwnerCommand("org", async ({ api }) => {
|
|
479
|
-
const result = await change(
|
|
512
|
+
const result = await change(
|
|
513
|
+
api,
|
|
514
|
+
() => api.addTeamAgents(teamId, agentIds, options.approval),
|
|
515
|
+
"add_agents_to_team",
|
|
516
|
+
{ team_id: teamId, agent_ids: agentIds },
|
|
517
|
+
options
|
|
518
|
+
);
|
|
519
|
+
if ("review" in result) {
|
|
520
|
+
return reportReview(result.review, `Added ${agentIds.length} agent(s) to the team.`);
|
|
521
|
+
}
|
|
480
522
|
reportMove(
|
|
481
|
-
result,
|
|
523
|
+
result.direct,
|
|
482
524
|
`conto teams add ${teamId} ${agentIds.join(" ")}`,
|
|
483
525
|
`Added ${agentIds.length} agent(s) to the team.`
|
|
484
526
|
);
|
|
@@ -486,9 +528,21 @@ async function teamsAddCommand(teamId, agentIds, options) {
|
|
|
486
528
|
}
|
|
487
529
|
async function teamsRemoveCommand(teamId, agentId, options) {
|
|
488
530
|
await runOwnerCommand("org", async ({ api }) => {
|
|
489
|
-
const result = await change(
|
|
531
|
+
const result = await change(
|
|
532
|
+
api,
|
|
533
|
+
() => api.removeTeamAgent(teamId, agentId, options.approval),
|
|
534
|
+
"remove_agent_from_team",
|
|
535
|
+
{ team_id: teamId, agent_id: agentId },
|
|
536
|
+
options
|
|
537
|
+
);
|
|
538
|
+
if ("review" in result) {
|
|
539
|
+
return reportReview(
|
|
540
|
+
result.review,
|
|
541
|
+
"Agent taken out of the team. It no longer follows the team policies."
|
|
542
|
+
);
|
|
543
|
+
}
|
|
490
544
|
reportMove(
|
|
491
|
-
result,
|
|
545
|
+
result.direct,
|
|
492
546
|
`conto teams remove ${teamId} ${agentId}`,
|
|
493
547
|
"Agent taken out of the team. It no longer follows the team policies."
|
|
494
548
|
);
|
|
@@ -4616,16 +4670,30 @@ withReview(
|
|
|
4616
4670
|
keysGroup.command("revoke <agentId> <keyId>").description("Revoke an SDK key").action(agentsKeysRevokeCommand);
|
|
4617
4671
|
var teamsGroup = program.command("teams").description("Manage teams of agents, their managers and cost centers").addHelpText(
|
|
4618
4672
|
"after",
|
|
4619
|
-
'\nReads work with any organization key.
|
|
4673
|
+
'\nReads work with any organization key. A key made in the dashboard (CONTO_ORG_API_KEY)\nmakes changes directly. With the key from "conto login", every change goes to owner\nreview: the command prints a review link and waits for an owner or admin.\n\nExit codes:\n 0 done, or nothing needed to change\n 1 request failed\n 3 the reviewer declined the change\n 4 waiting for review or governance approval, nothing changed\n 5 the review expired\n'
|
|
4620
4674
|
);
|
|
4621
4675
|
teamsGroup.command("list").description("List teams").action(teamsListCommand);
|
|
4622
4676
|
teamsGroup.command("show <teamId>").description("Show one team").action(teamsShowCommand);
|
|
4623
|
-
|
|
4624
|
-
teamsGroup.command("
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
teamsGroup.command("
|
|
4628
|
-
|
|
4677
|
+
withReview(
|
|
4678
|
+
teamsGroup.command("create").description("Create a team").option("--name <name>", "Team name, such as Marketing").option("--slug <slug>", "Department label on its payments (default: from the name)").option("--cost-center <code>", "Cost center or department code")
|
|
4679
|
+
).action(teamsCreateCommand);
|
|
4680
|
+
withReview(
|
|
4681
|
+
teamsGroup.command("update <teamId>").description("Rename a team or change its cost center").option("--name <name>", "New name").option("--cost-center <code>", "New cost center code").option("--clear-cost-center", "Remove the cost center code")
|
|
4682
|
+
).action(teamsUpdateCommand);
|
|
4683
|
+
withReview(
|
|
4684
|
+
teamsGroup.command("delete <teamId>").description("Delete a team with no agents, policies or budgets")
|
|
4685
|
+
).action(teamsDeleteCommand);
|
|
4686
|
+
withReview(
|
|
4687
|
+
teamsGroup.command("managers <teamId> [who...]").description("Replace the managers, by email or membership id (none clears them)")
|
|
4688
|
+
).action(
|
|
4689
|
+
(teamId, who, options) => teamsManagersCommand(teamId, who ?? [], options)
|
|
4690
|
+
);
|
|
4691
|
+
withReview(
|
|
4692
|
+
teamsGroup.command("add <teamId> <agentIds...>").description("Add agents to a team, moving them from another team").option("--approval <id>", "Approved governance request for this exact change")
|
|
4693
|
+
).action(teamsAddCommand);
|
|
4694
|
+
withReview(
|
|
4695
|
+
teamsGroup.command("remove <teamId> <agentId>").description("Take an agent out of a team").option("--approval <id>", "Approved governance request for this exact change")
|
|
4696
|
+
).action(teamsRemoveCommand);
|
|
4629
4697
|
var payeesGroup = program.command("counterparties").description("Manage the organization's payees");
|
|
4630
4698
|
payeesGroup.command("list").description("List payees").action(counterpartiesListCommand);
|
|
4631
4699
|
payeesGroup.command("show <id>").description("Show one payee").action(counterpartiesShowCommand);
|
package/dist/index.js
CHANGED