@conto_finance/create-conto-agent 0.9.0 → 0.10.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 +45 -0
- package/README.md +18 -1
- package/dist/{chunk-FW6E3QMB.js → chunk-ALQ6UCGI.js} +799 -119
- package/dist/cli.js +93 -25
- package/dist/index.js +36 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -26,9 +26,10 @@ import {
|
|
|
26
26
|
responseErrorCode,
|
|
27
27
|
responseErrorMessage,
|
|
28
28
|
retryAfterSeconds,
|
|
29
|
+
runConnect,
|
|
29
30
|
runInit,
|
|
30
31
|
writeProjectStateFile
|
|
31
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-ALQ6UCGI.js";
|
|
32
33
|
import {
|
|
33
34
|
BUDGET_PERIODS,
|
|
34
35
|
VELOCITY_PERIODS,
|
|
@@ -2292,6 +2293,7 @@ var ORG_KEY_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
|
2292
2293
|
"rollback",
|
|
2293
2294
|
"simulate"
|
|
2294
2295
|
]);
|
|
2296
|
+
var PROMPTING_SUBCOMMANDS = /* @__PURE__ */ new Set(["create", "update", "delete", "add-rule"]);
|
|
2295
2297
|
async function policiesCommand(subcommand = "list", idOrAmount, extra, reviewOptions = {}) {
|
|
2296
2298
|
const config = loadConfig();
|
|
2297
2299
|
if (!config.apiKey) {
|
|
@@ -2306,6 +2308,11 @@ async function policiesCommand(subcommand = "list", idOrAmount, extra, reviewOpt
|
|
|
2306
2308
|
orgApiKey: orgApiKeySource(config)
|
|
2307
2309
|
});
|
|
2308
2310
|
try {
|
|
2311
|
+
if (isJsonMode() && PROMPTING_SUBCOMMANDS.has(subcommand)) {
|
|
2312
|
+
throw new Error(
|
|
2313
|
+
`conto policies ${subcommand} prompts for input, so it does not run with --json. Run it in a terminal without --json.`
|
|
2314
|
+
);
|
|
2315
|
+
}
|
|
2309
2316
|
if (ORG_KEY_SUBCOMMANDS.has(subcommand)) await resolveOrgApiKey(config);
|
|
2310
2317
|
switch (subcommand) {
|
|
2311
2318
|
case "list":
|
|
@@ -3027,25 +3034,25 @@ async function alertsCommand(options = {}) {
|
|
|
3027
3034
|
try {
|
|
3028
3035
|
const activeOnly = options.active || options.unread;
|
|
3029
3036
|
const { alerts } = await api.getAlerts({
|
|
3030
|
-
status: activeOnly ? "
|
|
3037
|
+
status: activeOnly ? "open" : void 0
|
|
3031
3038
|
});
|
|
3032
3039
|
if (isJsonMode()) {
|
|
3033
3040
|
printJson(alerts);
|
|
3034
3041
|
return;
|
|
3035
3042
|
}
|
|
3036
3043
|
if (alerts.length === 0) {
|
|
3037
|
-
console.log("\n No alerts."
|
|
3044
|
+
console.log(activeOnly ? "\n No open alerts." : "\n No alerts.");
|
|
3038
3045
|
return;
|
|
3039
3046
|
}
|
|
3040
3047
|
printHeader(`Alerts (${alerts.length})`);
|
|
3041
3048
|
printTable(
|
|
3042
|
-
["
|
|
3049
|
+
["ID", "Date", "Severity", "Status", "Title"],
|
|
3043
3050
|
alerts.map((a) => [
|
|
3051
|
+
a.id,
|
|
3044
3052
|
new Date(a.createdAt).toLocaleDateString(),
|
|
3045
|
-
severityColor(a.severity),
|
|
3046
|
-
a.
|
|
3047
|
-
a.
|
|
3048
|
-
a.status
|
|
3053
|
+
severityColor(a.severity.label),
|
|
3054
|
+
a.status.label,
|
|
3055
|
+
a.title.length > 50 ? a.title.slice(0, 50) + "..." : a.title
|
|
3049
3056
|
])
|
|
3050
3057
|
);
|
|
3051
3058
|
console.log("");
|
|
@@ -3059,18 +3066,14 @@ async function alertsCommand(options = {}) {
|
|
|
3059
3066
|
process.exit(1);
|
|
3060
3067
|
}
|
|
3061
3068
|
}
|
|
3062
|
-
function severityColor(
|
|
3063
|
-
switch (
|
|
3064
|
-
case "
|
|
3065
|
-
return chalk8.red
|
|
3066
|
-
case "
|
|
3067
|
-
return chalk8.
|
|
3068
|
-
case "MEDIUM":
|
|
3069
|
-
return chalk8.yellow(severity);
|
|
3070
|
-
case "LOW":
|
|
3071
|
-
return chalk8.dim(severity);
|
|
3069
|
+
function severityColor(label) {
|
|
3070
|
+
switch (label) {
|
|
3071
|
+
case "High":
|
|
3072
|
+
return chalk8.red(label);
|
|
3073
|
+
case "Medium":
|
|
3074
|
+
return chalk8.yellow(label);
|
|
3072
3075
|
default:
|
|
3073
|
-
return
|
|
3076
|
+
return chalk8.dim(label);
|
|
3074
3077
|
}
|
|
3075
3078
|
}
|
|
3076
3079
|
async function alertUpdateCommand(alertId, action) {
|
|
@@ -3147,18 +3150,28 @@ async function agentsFreezeCommand(agentId, options) {
|
|
|
3147
3150
|
});
|
|
3148
3151
|
}
|
|
3149
3152
|
async function agentsUnfreezeCommand(agentId, options) {
|
|
3153
|
+
if (options.wallets && options.keepWallets) {
|
|
3154
|
+
if (isJsonMode()) {
|
|
3155
|
+
printJson({ ok: false, error: "Pick one of --wallets and --keep-wallets." });
|
|
3156
|
+
} else {
|
|
3157
|
+
printError("Pick one of --wallets and --keep-wallets.");
|
|
3158
|
+
}
|
|
3159
|
+
process.exitCode = 1;
|
|
3160
|
+
return;
|
|
3161
|
+
}
|
|
3162
|
+
const restoreWallets = options.keepWallets ? false : options.wallets ? true : void 0;
|
|
3150
3163
|
await runOwnerCommand("org", async ({ api }) => {
|
|
3151
3164
|
const result = await directOrReview(
|
|
3152
3165
|
api,
|
|
3153
3166
|
() => api.unfreezeAgent(agentId, {
|
|
3154
3167
|
...options.reason ? { reason: options.reason } : {},
|
|
3155
|
-
unfreezeWallets:
|
|
3168
|
+
...restoreWallets === void 0 ? {} : { unfreezeWallets: restoreWallets }
|
|
3156
3169
|
}),
|
|
3157
3170
|
async () => ({
|
|
3158
3171
|
action: "activate_agent",
|
|
3159
3172
|
input: {
|
|
3160
3173
|
agent_id: agentId,
|
|
3161
|
-
restore_wallets:
|
|
3174
|
+
...restoreWallets === void 0 ? {} : { restore_wallets: restoreWallets },
|
|
3162
3175
|
...options.reason ? { reason: options.reason } : {}
|
|
3163
3176
|
}
|
|
3164
3177
|
}),
|
|
@@ -3514,6 +3527,10 @@ function isSafeConfigPath(parts) {
|
|
|
3514
3527
|
(part) => part.length > 0 && !FORBIDDEN_CONFIG_PATH_SEGMENTS.has(part.toLowerCase())
|
|
3515
3528
|
);
|
|
3516
3529
|
}
|
|
3530
|
+
var BASE_URL_NEEDS_LOGIN = 'conto config does not change server.baseUrl, because the saved keys would be sent to the new server. Run "conto login --base-url <url>" instead. It signs in to that server and removes the agent key saved for the old one.';
|
|
3531
|
+
function isServerBaseUrlPath(parts) {
|
|
3532
|
+
return parts.length >= 2 && parts[0].toLowerCase() === "server" && parts[1].toLowerCase() === "baseurl";
|
|
3533
|
+
}
|
|
3517
3534
|
async function configCommand(key, value) {
|
|
3518
3535
|
if (key && value) {
|
|
3519
3536
|
const global = loadGlobalConfig();
|
|
@@ -3525,6 +3542,15 @@ async function configCommand(key, value) {
|
|
|
3525
3542
|
process.exitCode = 1;
|
|
3526
3543
|
return;
|
|
3527
3544
|
}
|
|
3545
|
+
if (isServerBaseUrlPath(parts)) {
|
|
3546
|
+
if (isJsonMode()) {
|
|
3547
|
+
printJson({ ok: false, error: BASE_URL_NEEDS_LOGIN, code: "BASE_URL_NEEDS_LOGIN" });
|
|
3548
|
+
} else {
|
|
3549
|
+
printError(BASE_URL_NEEDS_LOGIN);
|
|
3550
|
+
}
|
|
3551
|
+
process.exitCode = 1;
|
|
3552
|
+
return;
|
|
3553
|
+
}
|
|
3528
3554
|
let target = global;
|
|
3529
3555
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
3530
3556
|
if (!target[parts[i]] || typeof target[parts[i]] !== "object") {
|
|
@@ -3584,7 +3610,8 @@ async function loginCommand(options = {}) {
|
|
|
3584
3610
|
try {
|
|
3585
3611
|
const { orgApiKey, organizationName, expiresAt } = await browserAuth(
|
|
3586
3612
|
baseUrl,
|
|
3587
|
-
(authUrl) => printInfo(`If the browser does not open, visit: ${authUrl}`)
|
|
3613
|
+
(authUrl) => printInfo(`If the browser does not open, visit: ${authUrl}`),
|
|
3614
|
+
(code) => printInfo(`Connect only if the browser shows this code: ${code}`)
|
|
3588
3615
|
);
|
|
3589
3616
|
const config = loadGlobalConfig();
|
|
3590
3617
|
const previousBaseUrl = config.server?.baseUrl || DEFAULT_BASE_URL;
|
|
@@ -4699,6 +4726,12 @@ Exit codes:
|
|
|
4699
4726
|
or the credential was rejected
|
|
4700
4727
|
3 partial setup: run again with --resume
|
|
4701
4728
|
4 reconciliation or owner action needed before --resume (see the output)
|
|
4729
|
+
|
|
4730
|
+
With --connect:
|
|
4731
|
+
0 approved and saved to .env.local, or (without --wait) the link is out
|
|
4732
|
+
1 failed, or the link expired
|
|
4733
|
+
2 the person declined, or the request was refused
|
|
4734
|
+
4 --wait ran out of time, the link is still valid. Run it again with --wait
|
|
4702
4735
|
`;
|
|
4703
4736
|
var SANDBOX_CLAIM_EXIT_CODES_HELP = `
|
|
4704
4737
|
Exit codes:
|
|
@@ -4725,10 +4758,45 @@ program.command("init").description("Run the setup wizard (interactive, or headl
|
|
|
4725
4758
|
).option(
|
|
4726
4759
|
"--confirm-mainnet",
|
|
4727
4760
|
"Confirm that the selected network can move real funds (required for headless mainnet setup)"
|
|
4728
|
-
).option("--no-install", "Skip installing the conto CLI into the project").option("--resume", "Finish an unfinished organization setup recorded in .conto/").option("--restart", "Discard an unfinished setup record and start a new setup").option("--overwrite", "Replace an existing conto.config.json and example.mjs without asking").
|
|
4761
|
+
).option("--no-install", "Skip installing the conto CLI into the project").option("--resume", "Finish an unfinished organization setup recorded in .conto/").option("--restart", "Discard an unfinished setup record and start a new setup").option("--overwrite", "Replace an existing conto.config.json and example.mjs without asking").option(
|
|
4762
|
+
"--connect",
|
|
4763
|
+
"Set up this agent in a person's real account: they approve it from a link (headless)"
|
|
4764
|
+
).option("--email <email>", "With --connect: email the approval link to this person").option(
|
|
4765
|
+
"--wait [seconds]",
|
|
4766
|
+
"With --connect: wait for approval and save the agent key (default: until the link expires)"
|
|
4767
|
+
).option(
|
|
4768
|
+
"--sandbox-key <key>",
|
|
4769
|
+
"With --connect: copy this sandbox's policies on approval (default: CONTO_SANDBOX_API_KEY in .env.local)"
|
|
4770
|
+
).addHelpText("after", INIT_EXIT_CODES_HELP).action(async (opts, command) => {
|
|
4729
4771
|
if (command.optsWithGlobals().json) {
|
|
4730
4772
|
setJsonMode(true);
|
|
4731
4773
|
}
|
|
4774
|
+
const connect = opts.connect === true || typeof opts.email === "string";
|
|
4775
|
+
if (connect && (opts.sandbox || opts.apiKey || opts.resume)) {
|
|
4776
|
+
const error = "--connect and --email set up an agent in a real account through an approval link. Leave out --sandbox, --api-key and --resume.";
|
|
4777
|
+
if (isJsonMode()) printJson({ ok: false, code: "INVALID_OPTIONS", error });
|
|
4778
|
+
else console.error(error);
|
|
4779
|
+
process.exit(2);
|
|
4780
|
+
}
|
|
4781
|
+
if (!connect && (opts.wait !== void 0 || opts.sandboxKey)) {
|
|
4782
|
+
const error = "--wait and --sandbox-key go with --connect or --email.";
|
|
4783
|
+
if (isJsonMode()) printJson({ ok: false, code: "INVALID_OPTIONS", error });
|
|
4784
|
+
else console.error(error);
|
|
4785
|
+
process.exit(2);
|
|
4786
|
+
}
|
|
4787
|
+
if (connect) {
|
|
4788
|
+
await runConnect({
|
|
4789
|
+
email: opts.email,
|
|
4790
|
+
name: opts.name,
|
|
4791
|
+
baseUrl: opts.baseUrl,
|
|
4792
|
+
wait: opts.wait === void 0 ? false : opts.wait === true ? true : Number(opts.wait),
|
|
4793
|
+
sandboxKey: opts.sandboxKey,
|
|
4794
|
+
restart: opts.restart === true,
|
|
4795
|
+
install: opts.install,
|
|
4796
|
+
overwrite: opts.overwrite === true
|
|
4797
|
+
});
|
|
4798
|
+
return;
|
|
4799
|
+
}
|
|
4732
4800
|
await runInit({
|
|
4733
4801
|
chain: opts.chain,
|
|
4734
4802
|
name: opts.name,
|
|
@@ -4786,7 +4854,7 @@ withReview(
|
|
|
4786
4854
|
).action(agentsResumeCommand);
|
|
4787
4855
|
agentsGroup.command("freeze <agentId>").description("Freeze an agent").option("--reason <text>", "Why, for the audit log").option("--wallets", "Also freeze wallets only this agent uses").action(agentsFreezeCommand);
|
|
4788
4856
|
withReview(
|
|
4789
|
-
agentsGroup.command("unfreeze <agentId>").description("Lift a freeze (owner review)").option("--reason <text>", "Why, for the audit log").option("--wallets", "
|
|
4857
|
+
agentsGroup.command("unfreeze <agentId>").description("Lift a freeze (owner review)").option("--reason <text>", "Why, for the audit log").option("--wallets", "Unfreeze the wallets frozen with it, also for an older freeze record").option("--keep-wallets", "Leave every wallet frozen")
|
|
4790
4858
|
).action(agentsUnfreezeCommand);
|
|
4791
4859
|
withReview(
|
|
4792
4860
|
agentsGroup.command("delete <agentId>").description("Delete an agent (owner review)").option("--yes", "Skip the confirmation prompt")
|
|
@@ -4855,7 +4923,7 @@ withReview(
|
|
|
4855
4923
|
(subcommand, id2, extra, opts) => policiesCommand(subcommand || "list", id2, extra, opts)
|
|
4856
4924
|
);
|
|
4857
4925
|
program.command("limits").description("Show spending limits and remaining budget").action(limitsCommand);
|
|
4858
|
-
var alertsGroup = program.command("alerts").description("List alerts, or acknowledge or resolve one").option("--active", "Show only
|
|
4926
|
+
var alertsGroup = program.command("alerts").description("List alerts, or acknowledge or resolve one").option("--active", "Show only open alerts").option("--unread", "Alias for --active").action(alertsCommand);
|
|
4859
4927
|
alertsGroup.command("ack <alertId>").description("Acknowledge an alert").action((alertId) => alertUpdateCommand(alertId, "acknowledge"));
|
|
4860
4928
|
alertsGroup.command("resolve <alertId>").description("Resolve an alert").action((alertId) => alertUpdateCommand(alertId, "resolve"));
|
|
4861
4929
|
program.command("config [key] [value]").description("Show or update configuration").action(configCommand);
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
runConnect,
|
|
2
3
|
runInit
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ALQ6UCGI.js";
|
|
4
5
|
import {
|
|
5
6
|
delegatesToCli
|
|
6
7
|
} from "./chunk-D6JPJHU4.js";
|
|
@@ -31,6 +32,15 @@ if (delegatesToCli(args)) {
|
|
|
31
32
|
options.baseUrl = args[++i];
|
|
32
33
|
} else if (arg === "--api-key" && args[i + 1]) {
|
|
33
34
|
options.apiKey = args[++i];
|
|
35
|
+
} else if (arg === "--email" && args[i + 1]) {
|
|
36
|
+
options.email = args[++i];
|
|
37
|
+
} else if (arg === "--sandbox-key" && args[i + 1]) {
|
|
38
|
+
options.sandboxKey = args[++i];
|
|
39
|
+
} else if (arg === "--connect") {
|
|
40
|
+
options.connect = true;
|
|
41
|
+
} else if (arg === "--wait") {
|
|
42
|
+
if (args[i + 1] && /^\d+$/.test(args[i + 1])) options.wait = args[++i];
|
|
43
|
+
else options.wait = true;
|
|
34
44
|
} else if (arg === "--sandbox") {
|
|
35
45
|
options.sandbox = true;
|
|
36
46
|
} else if (arg === "--no-browser") {
|
|
@@ -58,7 +68,29 @@ if (delegatesToCli(args)) {
|
|
|
58
68
|
else console.error(error);
|
|
59
69
|
process.exit(1);
|
|
60
70
|
}
|
|
61
|
-
|
|
71
|
+
const connect = options.connect === true || typeof options.email === "string";
|
|
72
|
+
if (connect && (options.sandbox || options.apiKey || options.resume)) {
|
|
73
|
+
const error = "--connect and --email set up an agent in a real account through an approval link. Leave out --sandbox, --api-key and --resume.";
|
|
74
|
+
if (isJsonMode()) printJson({ ok: false, code: "INVALID_OPTIONS", error });
|
|
75
|
+
else console.error(error);
|
|
76
|
+
process.exit(2);
|
|
77
|
+
}
|
|
78
|
+
if (!connect && (options.wait || options.sandboxKey)) {
|
|
79
|
+
const error = "--wait and --sandbox-key go with --connect or --email.";
|
|
80
|
+
if (isJsonMode()) printJson({ ok: false, code: "INVALID_OPTIONS", error });
|
|
81
|
+
else console.error(error);
|
|
82
|
+
process.exit(2);
|
|
83
|
+
}
|
|
84
|
+
const run = connect ? runConnect({
|
|
85
|
+
email: options.email,
|
|
86
|
+
name: options.name,
|
|
87
|
+
baseUrl: options.baseUrl,
|
|
88
|
+
wait: options.wait === true ? true : options.wait ? Number(options.wait) : false,
|
|
89
|
+
sandboxKey: options.sandboxKey,
|
|
90
|
+
restart: options.restart === true,
|
|
91
|
+
install: options.noInstall ? false : void 0,
|
|
92
|
+
overwrite: options.overwrite === true
|
|
93
|
+
}) : runInit({
|
|
62
94
|
chain: options.chain,
|
|
63
95
|
name: options.name,
|
|
64
96
|
type: options.type,
|
|
@@ -71,7 +103,8 @@ if (delegatesToCli(args)) {
|
|
|
71
103
|
resume: options.resume === true,
|
|
72
104
|
restart: options.restart === true,
|
|
73
105
|
overwrite: options.overwrite === true
|
|
74
|
-
})
|
|
106
|
+
});
|
|
107
|
+
run.catch((err) => {
|
|
75
108
|
const error = err instanceof Error ? err.message : String(err);
|
|
76
109
|
if (isJsonMode()) printJson({ ok: false, error });
|
|
77
110
|
else console.error("Fatal error:", error);
|