@conto_finance/create-conto-agent 0.7.0 → 0.9.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 +32 -0
- package/README.md +21 -9
- package/dist/chunk-D6JPJHU4.js +45 -0
- package/dist/{chunk-RQ4PUBL7.js → chunk-F72EK2TO.js} +12 -0
- package/dist/{chunk-YAC3XQVD.js → chunk-FW6E3QMB.js} +9 -6
- package/dist/{chunk-2M2WVAJI.js → chunk-PUHGIKBB.js} +19 -1
- package/dist/cli.js +291 -89
- package/dist/{config-MACPIPYV.js → config-2C6Q4NEJ.js} +3 -1
- package/dist/index.js +6 -34
- package/dist/lib/cli-commands.d.ts +11 -0
- package/dist/lib/cli-commands.js +8 -0
- package/dist/lib/rule-values.d.ts +9 -1
- package/dist/lib/rule-values.js +5 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
- `conto pay --json` now exits 1 when a policy denies the payment, as it already did without
|
|
6
|
+
`--json`. Earlier versions exited 0, so a script that checks the exit code could read a denied
|
|
7
|
+
payment as sent. The JSON output is the same.
|
|
8
|
+
- Inside a project the CLI set up, commands that need the organization key, such as `conto teams`,
|
|
9
|
+
`conto policies all`, and `conto spending export`, now use the key that setup or `conto login`
|
|
10
|
+
saved in `~/.conto/config.json` when the project's `.env.local` has no `CONTO_ORG_API_KEY`.
|
|
11
|
+
First the CLI checks with Conto that this key and the project's agent key belong to the same
|
|
12
|
+
organization, and it uses the key only with the server it was saved for. If the organizations
|
|
13
|
+
differ or the check can't finish, the command stops and says what to do. A `CONTO_ORG_API_KEY`
|
|
14
|
+
in the environment or in `.env.local` is used as before.
|
|
15
|
+
- `npx @conto_finance/create-conto-agent teams`, `budgets`, `tasks`, `purchases`, and `spending` now
|
|
16
|
+
run those commands. Earlier versions started the setup wizard instead.
|
|
17
|
+
- `conto webhooks test` now sends `X-Conto-Signature-V2`, `X-Conto-Delivery-Id`, and `deliveryId`
|
|
18
|
+
in the body, like a real delivery, so a handler that checks the v2 signature accepts it. The
|
|
19
|
+
event's `data.settlementMode` is `test`.
|
|
20
|
+
- When you add a rule that blocks what it matches, such as `BLOCKED_COUNTERPARTIES` or
|
|
21
|
+
`BLACKOUT_PERIOD`, the action picker starts on Deny and no longer offers Allow, which Conto now
|
|
22
|
+
refuses for these rules.
|
|
23
|
+
|
|
24
|
+
## 0.8.0
|
|
25
|
+
|
|
26
|
+
- With the key from `conto login`, `conto teams` changes now go to owner review instead of failing.
|
|
27
|
+
The command prints a review link and waits for an owner or admin to confirm the change, as it
|
|
28
|
+
does for other changes that key can't make directly. `--no-wait` returns at once, and
|
|
29
|
+
`conto changes status <changeId>` checks the change later. A key made in the dashboard still makes
|
|
30
|
+
team changes directly.
|
|
31
|
+
- A move that takes an agent off a budget can't go through owner review when your organization
|
|
32
|
+
requires approval for budget changes. Make it in the dashboard, or with a dashboard key and
|
|
33
|
+
`--approval <id>`.
|
|
34
|
+
|
|
3
35
|
## 0.7.0
|
|
4
36
|
|
|
5
37
|
- `conto teams` lists and shows teams, and creates, renames and deletes them. `managers` replaces a
|
package/README.md
CHANGED
|
@@ -34,6 +34,12 @@ Inside a CLI-created project, `npx conto <command>` is a shorter form of the sam
|
|
|
34
34
|
one, bare `npx conto` fetches an unrelated npm package, so use the full package name.
|
|
35
35
|
`--help`, `--version`, and `--json` work without an interactive terminal.
|
|
36
36
|
|
|
37
|
+
Commands that need the organization key, such as `conto teams` and `conto policies all`, use
|
|
38
|
+
`CONTO_ORG_API_KEY` from the environment or `.env.local`. When a project has none, they use the key
|
|
39
|
+
that setup or `conto login` saved in `~/.conto/config.json`, but only with the server it was saved
|
|
40
|
+
for and only after Conto confirms it belongs to the same organization as the project's agent key.
|
|
41
|
+
Otherwise the command stops and says why. A key in the environment replaces both keys in the files.
|
|
42
|
+
|
|
37
43
|
Test a local webhook handler with the same development secret configured in that handler:
|
|
38
44
|
|
|
39
45
|
```bash
|
|
@@ -41,16 +47,18 @@ export CONTO_WEBHOOK_SECRET="your-local-development-secret"
|
|
|
41
47
|
npx @conto_finance/create-conto-agent webhooks test http://localhost:8080/webhooks/conto --json
|
|
42
48
|
```
|
|
43
49
|
|
|
44
|
-
This sends one synthetic
|
|
50
|
+
This sends one synthetic event to a loopback address, signed like a real delivery with both
|
|
51
|
+
`X-Conto-Signature` and `X-Conto-Signature-V2` and an `X-Conto-Delivery-Id`. It creates no payment
|
|
52
|
+
and requires no API key.
|
|
45
53
|
|
|
46
54
|
`npx @conto_finance/create-conto-agent pay <address> <amount> --dry-run` validates the payment
|
|
47
55
|
locally and prints the request it would send. It contacts nothing and does not evaluate policy. Use
|
|
48
56
|
`npx @conto_finance/create-conto-agent limits` to see current limits.
|
|
49
57
|
|
|
50
|
-
Every `pay` run prints an idempotency key and, before sending, the request ID.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
`--idempotency-key <key>`.
|
|
58
|
+
Every `pay` run prints an idempotency key and, before sending, the request ID. A policy denial exits
|
|
59
|
+
1, with or without `--json`. Exit code 6 means the outcome is unknown and the payment may have gone
|
|
60
|
+
through. Do not run the same command again, because that starts a new payment. Run
|
|
61
|
+
`pay status <requestId>`, or, with no request ID yet, retry with `--idempotency-key <key>`.
|
|
54
62
|
|
|
55
63
|
Setup keeps the other lines in an existing `.env.local` and replaces only its `CONTO_*` keys. It asks
|
|
56
64
|
before replacing an existing `conto.config.json` or `example.mjs`. A headless run keeps them unless
|
|
@@ -126,10 +134,14 @@ conto teams list
|
|
|
126
134
|
```
|
|
127
135
|
|
|
128
136
|
A team's policies apply to every agent in it, alongside company policies. Reads work with any
|
|
129
|
-
organization key.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
137
|
+
organization key. With the key from `conto login`, every change goes to owner review: the command
|
|
138
|
+
prints a review link and waits for an owner or admin to confirm it. A key made in the dashboard
|
|
139
|
+
under Developers, set as `CONTO_ORG_API_KEY`, makes the change directly.
|
|
140
|
+
|
|
141
|
+
If your organization requires approval for budget changes and a move takes an agent off a budget,
|
|
142
|
+
the move can't go through owner review. Make it in the dashboard, or with a dashboard key. With a
|
|
143
|
+
dashboard key, the command exits 4 and nothing changes. Once it is approved, run the same command
|
|
144
|
+
with `--approval <id>`.
|
|
133
145
|
|
|
134
146
|
## Accounting export
|
|
135
147
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/lib/cli-commands.ts
|
|
2
|
+
var CLI_COMMANDS = /* @__PURE__ */ new Set([
|
|
3
|
+
"status",
|
|
4
|
+
"doctor",
|
|
5
|
+
"balance",
|
|
6
|
+
"pay",
|
|
7
|
+
"transactions",
|
|
8
|
+
"wallets",
|
|
9
|
+
"webhooks",
|
|
10
|
+
"agents",
|
|
11
|
+
"teams",
|
|
12
|
+
"counterparties",
|
|
13
|
+
"channels",
|
|
14
|
+
"changes",
|
|
15
|
+
"test-report",
|
|
16
|
+
"fund",
|
|
17
|
+
"policies",
|
|
18
|
+
"limits",
|
|
19
|
+
"alerts",
|
|
20
|
+
"config",
|
|
21
|
+
"login",
|
|
22
|
+
"logout",
|
|
23
|
+
"mcp",
|
|
24
|
+
"docs",
|
|
25
|
+
"init",
|
|
26
|
+
"sandbox",
|
|
27
|
+
"spending",
|
|
28
|
+
"budgets",
|
|
29
|
+
"tasks",
|
|
30
|
+
"purchases",
|
|
31
|
+
"help",
|
|
32
|
+
"--help",
|
|
33
|
+
"-h",
|
|
34
|
+
"--version",
|
|
35
|
+
"-V"
|
|
36
|
+
]);
|
|
37
|
+
function delegatesToCli(args) {
|
|
38
|
+
if (args[0] !== void 0 && CLI_COMMANDS.has(args[0])) return true;
|
|
39
|
+
return args[0] === "--json" && args[1] !== void 0 && CLI_COMMANDS.has(args[1]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
CLI_COMMANDS,
|
|
44
|
+
delegatesToCli
|
|
45
|
+
};
|
|
@@ -87,7 +87,9 @@ function loadConfig() {
|
|
|
87
87
|
const baseUrl = withoutUrlCredentials(
|
|
88
88
|
process.env.CONTO_BASE_URL || (hasProcessCredential ? DEFAULT_BASE_URL : hasProjectCredential ? env.CONTO_BASE_URL || DEFAULT_BASE_URL : hasGlobalCredential ? global.server?.baseUrl || DEFAULT_BASE_URL : env.CONTO_BASE_URL || global.server?.baseUrl || DEFAULT_BASE_URL)
|
|
89
89
|
);
|
|
90
|
+
const credentialSource = hasProcessCredential ? "process" : hasProjectCredential ? "project" : hasGlobalCredential ? "global" : "none";
|
|
90
91
|
return {
|
|
92
|
+
credentialSource,
|
|
91
93
|
// Secrets never come from conto.config.json: it is written world-readable
|
|
92
94
|
// (0644) and is not gitignored. Read the API key only from the environment,
|
|
93
95
|
// the gitignored .env.local, or the private global store (~/.conto, 0600).
|
|
@@ -112,6 +114,15 @@ function loadConfig() {
|
|
|
112
114
|
testnet: explicitTestnet === "true" ? true : explicitTestnet === "false" ? false : matchingNetwork?.testnet ?? chainId === "42431"
|
|
113
115
|
};
|
|
114
116
|
}
|
|
117
|
+
function savedOrgKeyFor(config) {
|
|
118
|
+
if (config.credentialSource !== "project" || config.orgApiKey || !config.apiKey) return void 0;
|
|
119
|
+
const server = loadGlobalConfig().server;
|
|
120
|
+
if (!server?.orgApiKey) return void 0;
|
|
121
|
+
return {
|
|
122
|
+
orgApiKey: server.orgApiKey,
|
|
123
|
+
baseUrl: withoutUrlCredentials(server.baseUrl || DEFAULT_BASE_URL)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
115
126
|
function linesOutsideContoBlock(content) {
|
|
116
127
|
const lines = content.split("\n");
|
|
117
128
|
const kept = [];
|
|
@@ -204,6 +215,7 @@ export {
|
|
|
204
215
|
loadProjectEnv,
|
|
205
216
|
loadProjectConfig,
|
|
206
217
|
loadConfig,
|
|
218
|
+
savedOrgKeyFor,
|
|
207
219
|
writeEnvLocal,
|
|
208
220
|
ensureEnvLocalGitignored,
|
|
209
221
|
SANDBOX_SETUP_ENV_FILE,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
saveGlobalConfig,
|
|
6
6
|
writeEnvLocal,
|
|
7
7
|
writeSandboxSetupEnv
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-F72EK2TO.js";
|
|
9
9
|
import {
|
|
10
10
|
isJsonMode,
|
|
11
11
|
printBanner,
|
|
@@ -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.9.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",
|
|
@@ -39,8 +39,8 @@ var package_default = {
|
|
|
39
39
|
access: "public"
|
|
40
40
|
},
|
|
41
41
|
scripts: {
|
|
42
|
-
build: "tsup src/index.ts src/cli.ts src/lib/rule-values.ts --format esm --dts --clean",
|
|
43
|
-
dev: "tsup src/index.ts src/cli.ts src/lib/rule-values.ts --format esm --dts --watch",
|
|
42
|
+
build: "tsup src/index.ts src/cli.ts src/lib/rule-values.ts src/lib/cli-commands.ts --format esm --dts --clean",
|
|
43
|
+
dev: "tsup src/index.ts src/cli.ts src/lib/rule-values.ts src/lib/cli-commands.ts --format esm --dts --watch",
|
|
44
44
|
lint: "tsc --noEmit",
|
|
45
45
|
test: "npm run lint && npm run test:contract",
|
|
46
46
|
"test:contract": "npm run build && node --test test/*.test.mjs",
|
|
@@ -707,10 +707,13 @@ var ApiClient = class {
|
|
|
707
707
|
this.apiKey = options.apiKey;
|
|
708
708
|
this.orgApiKey = options.orgApiKey;
|
|
709
709
|
}
|
|
710
|
+
async orgToken() {
|
|
711
|
+
return typeof this.orgApiKey === "function" ? this.orgApiKey() : this.orgApiKey;
|
|
712
|
+
}
|
|
710
713
|
async request(method, path3, options) {
|
|
711
714
|
const url = `${this.baseUrl}${path3}`;
|
|
712
715
|
const authType = options?.auth || "sdk";
|
|
713
|
-
const token = authType === "org" ? this.
|
|
716
|
+
const token = authType === "org" ? await this.orgToken() : this.apiKey;
|
|
714
717
|
const headers = {
|
|
715
718
|
...options?.headers,
|
|
716
719
|
...options?.body instanceof FormData ? {} : { "Content-Type": "application/json" },
|
|
@@ -802,7 +805,7 @@ var ApiClient = class {
|
|
|
802
805
|
return response.data;
|
|
803
806
|
}
|
|
804
807
|
async spendingDownload(path3, owner = false) {
|
|
805
|
-
const token = owner ? this.
|
|
808
|
+
const token = owner ? await this.orgToken() : this.apiKey;
|
|
806
809
|
const response = await fetch(
|
|
807
810
|
`${this.baseUrl}/api/${owner ? "spending" : path3.startsWith("purchases") ? "sdk/spending" : "sdk"}/${path3}`,
|
|
808
811
|
{
|
|
@@ -86,6 +86,22 @@ function validatePaymentRequest(input) {
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
+
var BLOCKLIST_RULE_TYPES = [
|
|
90
|
+
"BLOCKED_COUNTERPARTIES",
|
|
91
|
+
"BLOCKED_CATEGORIES",
|
|
92
|
+
"X402_BLOCKED_SERVICES",
|
|
93
|
+
"MPP_BLOCKED_SERVICES",
|
|
94
|
+
"MPP_BLOCK_SESSION_INTENT",
|
|
95
|
+
"CARD_BLOCKED_MCCS",
|
|
96
|
+
"CARD_BLOCKED_MERCHANTS",
|
|
97
|
+
"CARD_BLOCKED_MERCHANT_DOMAINS",
|
|
98
|
+
"BLACKOUT_PERIOD",
|
|
99
|
+
"MAINTENANCE_WINDOW",
|
|
100
|
+
"BLOCKED_TIME_WINDOW"
|
|
101
|
+
];
|
|
102
|
+
function isBlocklistRuleType(ruleType) {
|
|
103
|
+
return BLOCKLIST_RULE_TYPES.includes(ruleType);
|
|
104
|
+
}
|
|
89
105
|
|
|
90
106
|
export {
|
|
91
107
|
parseTrustScoreInput,
|
|
@@ -94,5 +110,7 @@ export {
|
|
|
94
110
|
BUDGET_PERIODS,
|
|
95
111
|
buildBudgetCapValue,
|
|
96
112
|
dateRangePlaceholder,
|
|
97
|
-
validatePaymentRequest
|
|
113
|
+
validatePaymentRequest,
|
|
114
|
+
BLOCKLIST_RULE_TYPES,
|
|
115
|
+
isBlocklistRuleType
|
|
98
116
|
};
|
package/dist/cli.js
CHANGED
|
@@ -28,16 +28,17 @@ import {
|
|
|
28
28
|
retryAfterSeconds,
|
|
29
29
|
runInit,
|
|
30
30
|
writeProjectStateFile
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-FW6E3QMB.js";
|
|
32
32
|
import {
|
|
33
33
|
BUDGET_PERIODS,
|
|
34
34
|
VELOCITY_PERIODS,
|
|
35
35
|
buildBudgetCapValue,
|
|
36
36
|
buildVelocityCountValue,
|
|
37
37
|
dateRangePlaceholder,
|
|
38
|
+
isBlocklistRuleType,
|
|
38
39
|
parseTrustScoreInput,
|
|
39
40
|
validatePaymentRequest
|
|
40
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-PUHGIKBB.js";
|
|
41
42
|
import {
|
|
42
43
|
SANDBOX_SETUP_ENV_FILE,
|
|
43
44
|
isSensitiveConfigKey,
|
|
@@ -46,8 +47,9 @@ import {
|
|
|
46
47
|
loadProjectEnv,
|
|
47
48
|
maskSecret,
|
|
48
49
|
missingSdkKeyMessage,
|
|
49
|
-
saveGlobalConfig
|
|
50
|
-
|
|
50
|
+
saveGlobalConfig,
|
|
51
|
+
savedOrgKeyFor
|
|
52
|
+
} from "./chunk-F72EK2TO.js";
|
|
51
53
|
import {
|
|
52
54
|
isJsonMode,
|
|
53
55
|
printAmount,
|
|
@@ -67,14 +69,116 @@ import {
|
|
|
67
69
|
// src/commands/spending.ts
|
|
68
70
|
import { readFile, writeFile } from "fs/promises";
|
|
69
71
|
import { basename, extname } from "path";
|
|
72
|
+
|
|
73
|
+
// src/lib/org-key.ts
|
|
74
|
+
var OrgKeyError = class extends Error {
|
|
75
|
+
constructor(code, message) {
|
|
76
|
+
super(message);
|
|
77
|
+
this.code = code;
|
|
78
|
+
this.name = "OrgKeyError";
|
|
79
|
+
}
|
|
80
|
+
code;
|
|
81
|
+
};
|
|
82
|
+
var SAVED = "The organization key saved in ~/.conto/config.json";
|
|
83
|
+
var REQUEST_TIMEOUT_MS = Number(process.env.CONTO_REQUEST_TIMEOUT_MS) || 3e4;
|
|
84
|
+
var checks = /* @__PURE__ */ new Map();
|
|
85
|
+
function hasOrgApiKey(config) {
|
|
86
|
+
return Boolean(config.orgApiKey || savedOrgKeyFor(config));
|
|
87
|
+
}
|
|
88
|
+
function resolveOrgApiKey(config) {
|
|
89
|
+
if (config.orgApiKey) return Promise.resolve(config.orgApiKey);
|
|
90
|
+
const saved = savedOrgKeyFor(config);
|
|
91
|
+
if (!saved || !config.apiKey) return Promise.resolve(void 0);
|
|
92
|
+
const id2 = [config.baseUrl, config.apiKey, saved.baseUrl, saved.orgApiKey].join("\n");
|
|
93
|
+
let check = checks.get(id2);
|
|
94
|
+
if (!check) {
|
|
95
|
+
check = confirmSameOrganization(config.baseUrl, config.apiKey, saved);
|
|
96
|
+
checks.set(id2, check);
|
|
97
|
+
}
|
|
98
|
+
return check;
|
|
99
|
+
}
|
|
100
|
+
function orgApiKeySource(config) {
|
|
101
|
+
if (config.orgApiKey) return config.orgApiKey;
|
|
102
|
+
return savedOrgKeyFor(config) ? () => resolveOrgApiKey(config) : void 0;
|
|
103
|
+
}
|
|
104
|
+
function sameBaseUrl(a, b) {
|
|
105
|
+
try {
|
|
106
|
+
return normalizeBaseUrl(a) === normalizeBaseUrl(b);
|
|
107
|
+
} catch {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async function get(baseUrl, path2, bearer) {
|
|
112
|
+
try {
|
|
113
|
+
return await requestJson({
|
|
114
|
+
url: apiUrl(baseUrl, path2),
|
|
115
|
+
method: "GET",
|
|
116
|
+
bearer,
|
|
117
|
+
timeoutMs: REQUEST_TIMEOUT_MS
|
|
118
|
+
});
|
|
119
|
+
} catch (err) {
|
|
120
|
+
throw unconfirmed(
|
|
121
|
+
err instanceof HttpTransportError && err.code === "REDIRECT_REFUSED" ? "the server answered with a redirect" : "the server could not be reached"
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function unconfirmed(reason) {
|
|
126
|
+
return new OrgKeyError(
|
|
127
|
+
"ORG_KEY_UNCONFIRMED",
|
|
128
|
+
`${SAVED} was not used, because Conto could not confirm that it belongs to this project's organization: ${reason}. Try again, run "conto login", or set CONTO_ORG_API_KEY.`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
function agentIdFrom(data) {
|
|
132
|
+
const body = data;
|
|
133
|
+
if (typeof body?.agent?.id === "string") return body.agent.id;
|
|
134
|
+
const agent = body?.diagnostics?.issues?.find(
|
|
135
|
+
(issue) => issue.resource?.type === "agent" && typeof issue.resource.id === "string"
|
|
136
|
+
);
|
|
137
|
+
return agent?.resource?.id;
|
|
138
|
+
}
|
|
139
|
+
async function confirmSameOrganization(baseUrl, apiKey, saved) {
|
|
140
|
+
if (!sameBaseUrl(saved.baseUrl, baseUrl)) {
|
|
141
|
+
throw new OrgKeyError(
|
|
142
|
+
"ORG_KEY_BASE_URL_MISMATCH",
|
|
143
|
+
`${SAVED} is for ${saved.baseUrl}, and this project uses ${baseUrl}, so it was not used. Run "conto login --base-url ${baseUrl}", or set CONTO_ORG_API_KEY.`
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
const setup = await get(baseUrl, "/api/sdk/setup", apiKey);
|
|
147
|
+
const agentId = agentIdFrom(setup.data);
|
|
148
|
+
if (!agentId) {
|
|
149
|
+
throw unconfirmed(`the agent key's setup returned HTTP ${setup.status}`);
|
|
150
|
+
}
|
|
151
|
+
const agent = await get(baseUrl, `/api/agents/${encodeURIComponent(agentId)}`, saved.orgApiKey);
|
|
152
|
+
if (agent.status === 200 && agent.data?.id === agentId) {
|
|
153
|
+
return saved.orgApiKey;
|
|
154
|
+
}
|
|
155
|
+
if (agent.status === 404) {
|
|
156
|
+
throw new OrgKeyError(
|
|
157
|
+
"ORG_KEY_ORG_MISMATCH",
|
|
158
|
+
`${SAVED} belongs to a different organization than this project's agent key, so it was not used. Run "conto login" and sign in to this project's organization, or set CONTO_ORG_API_KEY.`
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
throw unconfirmed(
|
|
162
|
+
agent.status === 401 ? "the saved key was refused and may have expired" : `looking up the agent returned HTTP ${agent.status}`
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// src/commands/spending.ts
|
|
70
167
|
async function run(work, owner = false) {
|
|
71
168
|
try {
|
|
72
169
|
const config = loadConfig();
|
|
73
|
-
if (!(owner ? config
|
|
170
|
+
if (!(owner ? hasOrgApiKey(config) : config.apiKey))
|
|
74
171
|
throw new Error(
|
|
75
172
|
owner ? "An organization key is required for owner actions." : "Run conto login first."
|
|
76
173
|
);
|
|
77
|
-
|
|
174
|
+
if (owner) await resolveOrgApiKey(config);
|
|
175
|
+
const result = await work(
|
|
176
|
+
createApiClient({
|
|
177
|
+
baseUrl: config.baseUrl,
|
|
178
|
+
apiKey: config.apiKey,
|
|
179
|
+
orgApiKey: orgApiKeySource(config)
|
|
180
|
+
})
|
|
181
|
+
);
|
|
78
182
|
if (isJsonMode()) printJson(result);
|
|
79
183
|
else {
|
|
80
184
|
const object = result;
|
|
@@ -111,7 +215,7 @@ function registerSpendingCommands(program2) {
|
|
|
111
215
|
).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
216
|
try {
|
|
113
217
|
const config = loadConfig();
|
|
114
|
-
if (!config
|
|
218
|
+
if (!hasOrgApiKey(config))
|
|
115
219
|
throw new Error("An organization key is required for accounting exports.");
|
|
116
220
|
const format = o.format ?? (isJsonMode() ? "json" : "csv");
|
|
117
221
|
if (!["csv", "json"].includes(format)) throw new Error("Format must be csv or json.");
|
|
@@ -120,7 +224,10 @@ function registerSpendingCommands(program2) {
|
|
|
120
224
|
const query = new URLSearchParams({ format });
|
|
121
225
|
for (const key of ["from", "to", "limit", "cursor"])
|
|
122
226
|
if (o[key] !== void 0) query.set(key, o[key]);
|
|
123
|
-
const api = createApiClient(
|
|
227
|
+
const api = createApiClient({
|
|
228
|
+
baseUrl: config.baseUrl,
|
|
229
|
+
orgApiKey: await resolveOrgApiKey(config)
|
|
230
|
+
});
|
|
124
231
|
const data = format === "csv" ? await api.spendingDownload(`export?${query}`, true) : JSON.stringify(
|
|
125
232
|
await api.spending("GET", `export?${query}`, void 0, true),
|
|
126
233
|
null,
|
|
@@ -300,7 +407,7 @@ import chalk from "chalk";
|
|
|
300
407
|
var LOGIN_HINT = 'This command needs your organization login. Run "conto login" (or set CONTO_ORG_API_KEY) and try again.';
|
|
301
408
|
async function runOwnerCommand(needs, fn) {
|
|
302
409
|
const config = loadConfig();
|
|
303
|
-
if (needs === "org" && !config
|
|
410
|
+
if (needs === "org" && !hasOrgApiKey(config)) {
|
|
304
411
|
fail(LOGIN_HINT, "ORG_KEY_REQUIRED");
|
|
305
412
|
return;
|
|
306
413
|
}
|
|
@@ -314,9 +421,10 @@ async function runOwnerCommand(needs, fn) {
|
|
|
314
421
|
const api = createOwnerClient({
|
|
315
422
|
baseUrl: config.baseUrl,
|
|
316
423
|
apiKey: config.apiKey,
|
|
317
|
-
orgApiKey: config
|
|
424
|
+
orgApiKey: orgApiKeySource(config)
|
|
318
425
|
});
|
|
319
426
|
try {
|
|
427
|
+
if (needs === "org") await resolveOrgApiKey(config);
|
|
320
428
|
await fn({ api, config });
|
|
321
429
|
} catch (err) {
|
|
322
430
|
const error = err;
|
|
@@ -351,18 +459,8 @@ function parseUsd(value, flag) {
|
|
|
351
459
|
}
|
|
352
460
|
|
|
353
461
|
// 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
|
-
}
|
|
462
|
+
function change(api, direct, action, input, options) {
|
|
463
|
+
return directOrReview(api, direct, async () => ({ action, input }), options);
|
|
366
464
|
}
|
|
367
465
|
function printTeam(team) {
|
|
368
466
|
printHeader(team.name);
|
|
@@ -418,13 +516,29 @@ async function teamsShowCommand(teamId) {
|
|
|
418
516
|
async function teamsCreateCommand(options) {
|
|
419
517
|
await runOwnerCommand("org", async ({ api }) => {
|
|
420
518
|
if (!options.name) throw new Error("Pass --name.");
|
|
421
|
-
const
|
|
519
|
+
const name = options.name;
|
|
520
|
+
const result = await change(
|
|
521
|
+
api,
|
|
422
522
|
() => api.createTeam({
|
|
423
|
-
name
|
|
523
|
+
name,
|
|
424
524
|
...options.slug ? { slug: options.slug } : {},
|
|
425
525
|
...options.costCenter ? { costCenterCode: options.costCenter } : {}
|
|
426
|
-
})
|
|
526
|
+
}),
|
|
527
|
+
"create_team",
|
|
528
|
+
{
|
|
529
|
+
name,
|
|
530
|
+
...options.slug ? { slug: options.slug } : {},
|
|
531
|
+
...options.costCenter ? { cost_center_code: options.costCenter } : {}
|
|
532
|
+
},
|
|
533
|
+
options
|
|
427
534
|
);
|
|
535
|
+
if ("review" in result) {
|
|
536
|
+
return reportReview(
|
|
537
|
+
result.review,
|
|
538
|
+
`Team ${name} created. Run conto teams list to see its ID.`
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
const { team } = result.direct;
|
|
428
542
|
if (isJsonMode()) return printJson(team);
|
|
429
543
|
printSuccess(`Team ${team.name} created.`);
|
|
430
544
|
printKeyValue("ID", team.id);
|
|
@@ -443,19 +557,38 @@ async function teamsUpdateCommand(teamId, options) {
|
|
|
443
557
|
if (Object.keys(body).length === 0) {
|
|
444
558
|
throw new Error("Pass --name, --cost-center or --clear-cost-center.");
|
|
445
559
|
}
|
|
446
|
-
const
|
|
560
|
+
const result = await change(
|
|
561
|
+
api,
|
|
562
|
+
() => api.updateTeam(teamId, body),
|
|
563
|
+
"update_team",
|
|
564
|
+
{
|
|
565
|
+
team_id: teamId,
|
|
566
|
+
...body.name ? { name: body.name } : {},
|
|
567
|
+
..."costCenterCode" in body ? { cost_center_code: body.costCenterCode } : {}
|
|
568
|
+
},
|
|
569
|
+
options
|
|
570
|
+
);
|
|
571
|
+
if ("review" in result) return reportReview(result.review, "Team updated.");
|
|
572
|
+
const { team } = result.direct;
|
|
447
573
|
if (isJsonMode()) return printJson(team);
|
|
448
574
|
printSuccess(`Team ${team.name} updated.`);
|
|
449
575
|
});
|
|
450
576
|
}
|
|
451
|
-
async function teamsDeleteCommand(teamId) {
|
|
577
|
+
async function teamsDeleteCommand(teamId, options) {
|
|
452
578
|
await runOwnerCommand("org", async ({ api }) => {
|
|
453
|
-
const result = await change(
|
|
454
|
-
|
|
579
|
+
const result = await change(
|
|
580
|
+
api,
|
|
581
|
+
() => api.deleteTeam(teamId),
|
|
582
|
+
"delete_team",
|
|
583
|
+
{ team_id: teamId },
|
|
584
|
+
options
|
|
585
|
+
);
|
|
586
|
+
if ("review" in result) return reportReview(result.review, "Team deleted.");
|
|
587
|
+
if (isJsonMode()) return printJson(result.direct);
|
|
455
588
|
printSuccess("Team deleted.");
|
|
456
589
|
});
|
|
457
590
|
}
|
|
458
|
-
async function teamsManagersCommand(teamId, who) {
|
|
591
|
+
async function teamsManagersCommand(teamId, who, options = {}) {
|
|
459
592
|
await runOwnerCommand("org", async ({ api }) => {
|
|
460
593
|
const emails = who.filter((entry) => entry.includes("@"));
|
|
461
594
|
let membershipIds = who.filter((entry) => !entry.includes("@"));
|
|
@@ -467,7 +600,15 @@ async function teamsManagersCommand(teamId, who) {
|
|
|
467
600
|
membershipIds = [...membershipIds, member.id];
|
|
468
601
|
}
|
|
469
602
|
}
|
|
470
|
-
const
|
|
603
|
+
const result = await change(
|
|
604
|
+
api,
|
|
605
|
+
() => api.setTeamManagers(teamId, membershipIds),
|
|
606
|
+
"set_team_managers",
|
|
607
|
+
{ team_id: teamId, membership_ids: membershipIds },
|
|
608
|
+
options
|
|
609
|
+
);
|
|
610
|
+
if ("review" in result) return reportReview(result.review, "Team managers changed.");
|
|
611
|
+
const { team } = result.direct;
|
|
471
612
|
if (isJsonMode()) return printJson(team);
|
|
472
613
|
printSuccess(
|
|
473
614
|
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 +617,18 @@ async function teamsManagersCommand(teamId, who) {
|
|
|
476
617
|
}
|
|
477
618
|
async function teamsAddCommand(teamId, agentIds, options) {
|
|
478
619
|
await runOwnerCommand("org", async ({ api }) => {
|
|
479
|
-
const result = await change(
|
|
620
|
+
const result = await change(
|
|
621
|
+
api,
|
|
622
|
+
() => api.addTeamAgents(teamId, agentIds, options.approval),
|
|
623
|
+
"add_agents_to_team",
|
|
624
|
+
{ team_id: teamId, agent_ids: agentIds },
|
|
625
|
+
options
|
|
626
|
+
);
|
|
627
|
+
if ("review" in result) {
|
|
628
|
+
return reportReview(result.review, `Added ${agentIds.length} agent(s) to the team.`);
|
|
629
|
+
}
|
|
480
630
|
reportMove(
|
|
481
|
-
result,
|
|
631
|
+
result.direct,
|
|
482
632
|
`conto teams add ${teamId} ${agentIds.join(" ")}`,
|
|
483
633
|
`Added ${agentIds.length} agent(s) to the team.`
|
|
484
634
|
);
|
|
@@ -486,9 +636,21 @@ async function teamsAddCommand(teamId, agentIds, options) {
|
|
|
486
636
|
}
|
|
487
637
|
async function teamsRemoveCommand(teamId, agentId, options) {
|
|
488
638
|
await runOwnerCommand("org", async ({ api }) => {
|
|
489
|
-
const result = await change(
|
|
639
|
+
const result = await change(
|
|
640
|
+
api,
|
|
641
|
+
() => api.removeTeamAgent(teamId, agentId, options.approval),
|
|
642
|
+
"remove_agent_from_team",
|
|
643
|
+
{ team_id: teamId, agent_id: agentId },
|
|
644
|
+
options
|
|
645
|
+
);
|
|
646
|
+
if ("review" in result) {
|
|
647
|
+
return reportReview(
|
|
648
|
+
result.review,
|
|
649
|
+
"Agent taken out of the team. It no longer follows the team policies."
|
|
650
|
+
);
|
|
651
|
+
}
|
|
490
652
|
reportMove(
|
|
491
|
-
result,
|
|
653
|
+
result.direct,
|
|
492
654
|
`conto teams remove ${teamId} ${agentId}`,
|
|
493
655
|
"Agent taken out of the team. It no longer follows the team policies."
|
|
494
656
|
);
|
|
@@ -738,9 +900,9 @@ function mergeIssues(diagnostics, local) {
|
|
|
738
900
|
const reported = new Set(server.map((issue) => issue.code));
|
|
739
901
|
return [...server, ...local.filter((issue) => !reported.has(issue.code))];
|
|
740
902
|
}
|
|
741
|
-
function exitCodeFor(
|
|
903
|
+
function exitCodeFor(checks2, issues, unavailable) {
|
|
742
904
|
if (unavailable) return DOCTOR_EXIT_CODES.UNAVAILABLE;
|
|
743
|
-
if (
|
|
905
|
+
if (checks2.some((check) => check.status === "fail")) return DOCTOR_EXIT_CODES.ACTION_REQUIRED;
|
|
744
906
|
if (issues.some((issue) => issue.severity === "error")) {
|
|
745
907
|
return DOCTOR_EXIT_CODES.ACTION_REQUIRED;
|
|
746
908
|
}
|
|
@@ -790,7 +952,7 @@ async function doctorCommand() {
|
|
|
790
952
|
}
|
|
791
953
|
async function runDoctor() {
|
|
792
954
|
const config = loadConfig();
|
|
793
|
-
const
|
|
955
|
+
const checks2 = [];
|
|
794
956
|
const local = [];
|
|
795
957
|
const addLocal = (issue) => {
|
|
796
958
|
if (!local.some((existing) => existing.code === issue.code)) local.push(issue);
|
|
@@ -798,7 +960,7 @@ async function runDoctor() {
|
|
|
798
960
|
const finish = (fields = {}) => {
|
|
799
961
|
const diagnostics2 = fields.diagnostics ?? null;
|
|
800
962
|
const issues = mergeIssues(diagnostics2, local);
|
|
801
|
-
const exitCode = exitCodeFor(
|
|
963
|
+
const exitCode = exitCodeFor(checks2, issues, fields.unavailable === true);
|
|
802
964
|
let setup2 = null;
|
|
803
965
|
if (fields.setup) {
|
|
804
966
|
const { diagnostics: _serverDiagnostics, ...setupFields } = fields.setup;
|
|
@@ -810,7 +972,7 @@ async function runDoctor() {
|
|
|
810
972
|
exitCode,
|
|
811
973
|
baseUrl: config.baseUrl,
|
|
812
974
|
diagnosticsSource: diagnostics2 ? "server" : "cli",
|
|
813
|
-
checks:
|
|
975
|
+
checks: checks2.map((check) => ({ ...check, name: check.name.trim() })),
|
|
814
976
|
issues,
|
|
815
977
|
diagnostics: diagnostics2,
|
|
816
978
|
setup: setup2
|
|
@@ -819,19 +981,19 @@ async function runDoctor() {
|
|
|
819
981
|
let api = null;
|
|
820
982
|
try {
|
|
821
983
|
api = createApiClient({ baseUrl: config.baseUrl, apiKey: config.apiKey });
|
|
822
|
-
|
|
984
|
+
checks2.push({ name: "Base URL", status: "ok", detail: config.baseUrl });
|
|
823
985
|
} catch (error) {
|
|
824
986
|
const message = errorMessage(error, "Invalid base URL");
|
|
825
|
-
|
|
987
|
+
checks2.push({ name: "Base URL", status: "fail", detail: `${config.baseUrl}: ${message}` });
|
|
826
988
|
addLocal(baseUrlInvalidIssue(message));
|
|
827
989
|
}
|
|
828
990
|
if (!config.apiKey) {
|
|
829
991
|
const message = missingSdkKeyMessage(config);
|
|
830
|
-
|
|
992
|
+
checks2.push({ name: "SDK key", status: "fail", detail: message });
|
|
831
993
|
addLocal(sdkKeyNotConfiguredIssue(message));
|
|
832
994
|
return finish();
|
|
833
995
|
}
|
|
834
|
-
|
|
996
|
+
checks2.push({
|
|
835
997
|
name: "SDK key",
|
|
836
998
|
status: "ok",
|
|
837
999
|
detail: `${maskSecret(config.apiKey)} (from ${process.env.CONTO_API_KEY ? "environment" : ".env.local or ~/.conto/config.json"})`
|
|
@@ -845,7 +1007,7 @@ async function runDoctor() {
|
|
|
845
1007
|
const failure = error;
|
|
846
1008
|
const status = typeof failure.status === "number" ? failure.status : 0;
|
|
847
1009
|
const message = errorMessage(error, "Request failed");
|
|
848
|
-
|
|
1010
|
+
checks2.push({
|
|
849
1011
|
name: "Authentication",
|
|
850
1012
|
status: "fail",
|
|
851
1013
|
detail: `${config.baseUrl}/api/sdk/setup: ${message}`
|
|
@@ -869,13 +1031,13 @@ async function runDoctor() {
|
|
|
869
1031
|
}
|
|
870
1032
|
return finish({ diagnostics: diagnostics2 });
|
|
871
1033
|
}
|
|
872
|
-
|
|
1034
|
+
checks2.push({
|
|
873
1035
|
name: "Authentication",
|
|
874
1036
|
status: "ok",
|
|
875
1037
|
detail: `Authenticated as agent "${setup.agent.name}"`
|
|
876
1038
|
});
|
|
877
1039
|
const diagnostics = readServerDiagnostics(setup.diagnostics);
|
|
878
|
-
|
|
1040
|
+
checks2.push(
|
|
879
1041
|
...diagnostics ? diagnosticChecks(setup, diagnostics) : legacyChecks(setup, config)
|
|
880
1042
|
);
|
|
881
1043
|
return finish({ diagnostics, setup });
|
|
@@ -922,12 +1084,12 @@ function cardCheck(name, card) {
|
|
|
922
1084
|
};
|
|
923
1085
|
}
|
|
924
1086
|
function diagnosticChecks(setup, diagnostics) {
|
|
925
|
-
const
|
|
1087
|
+
const checks2 = [];
|
|
926
1088
|
const environment = diagnostics.environment;
|
|
927
1089
|
if (environment) {
|
|
928
1090
|
const expiry = environment.kind === "anonymous_sandbox" && environment.sandboxExpiresAt ? `, expires ${environment.sandboxExpiresAt}` : "";
|
|
929
1091
|
const agentEnvironment = environment.kind === "account" ? `, agent environment ${environment.agentEnvironment}` : "";
|
|
930
|
-
|
|
1092
|
+
checks2.push({
|
|
931
1093
|
name: "Environment",
|
|
932
1094
|
status: "ok",
|
|
933
1095
|
detail: `${ENVIRONMENT_DETAIL[environment.kind] ?? environment.kind}${agentEnvironment}${expiry}`
|
|
@@ -937,7 +1099,7 @@ function diagnosticChecks(setup, diagnostics) {
|
|
|
937
1099
|
(issue) => issue.resource.type === "agent" && issue.code.startsWith("AGENT_")
|
|
938
1100
|
);
|
|
939
1101
|
const agentActive = setup.agent.status === "active" && !agentIssue;
|
|
940
|
-
|
|
1102
|
+
checks2.push({
|
|
941
1103
|
name: "Agent status",
|
|
942
1104
|
status: agentActive ? "ok" : "fail",
|
|
943
1105
|
detail: agentIssue?.message ?? (agentActive ? "Active" : setup.agent.status)
|
|
@@ -953,7 +1115,7 @@ function diagnosticChecks(setup, diagnostics) {
|
|
|
953
1115
|
];
|
|
954
1116
|
for (const scope of scopeNames) {
|
|
955
1117
|
const missing = scopeIssues.find((issue) => issue.requiredScope === scope);
|
|
956
|
-
|
|
1118
|
+
checks2.push({
|
|
957
1119
|
name: `Scope ${scope}`,
|
|
958
1120
|
status: scopes.includes(scope) ? "ok" : missing?.severity === "error" ? "fail" : "warn",
|
|
959
1121
|
detail: scopes.includes(scope) ? "Granted" : missing?.message ?? "Missing. None of this agent's wallets needs it."
|
|
@@ -962,7 +1124,7 @@ function diagnosticChecks(setup, diagnostics) {
|
|
|
962
1124
|
const wallets = setup.wallets || [];
|
|
963
1125
|
if (wallets.length === 0) {
|
|
964
1126
|
const noWallet = diagnostics.issues.find((issue) => issue.code === "NO_WALLET");
|
|
965
|
-
|
|
1127
|
+
checks2.push({
|
|
966
1128
|
name: "Wallet",
|
|
967
1129
|
status: noWallet?.severity === "error" ? "fail" : "warn",
|
|
968
1130
|
detail: noWallet?.message ?? "No wallet is linked to this agent."
|
|
@@ -977,7 +1139,7 @@ function diagnosticChecks(setup, diagnostics) {
|
|
|
977
1139
|
(issue) => issue.severity === "error" && WALLET_ACCESS_CODES.has(issue.code)
|
|
978
1140
|
);
|
|
979
1141
|
const chainLabel = `${wallet.chainName} (${wallet.chainId})${wallet.isTestnet ? " testnet" : ""}`;
|
|
980
|
-
|
|
1142
|
+
checks2.push({
|
|
981
1143
|
name: `Wallet ${shortAddress(wallet.address)}`,
|
|
982
1144
|
status: blocking ? "fail" : "ok",
|
|
983
1145
|
detail: `${chainLabel}, ${wallet.custodyMode} custody, status ${wallet.status}${blocking ? `. ${blocking.message}` : ""}`
|
|
@@ -986,18 +1148,18 @@ function diagnosticChecks(setup, diagnostics) {
|
|
|
986
1148
|
const executionIssue = walletIssues.find(
|
|
987
1149
|
(issue) => issue.severity === "error" && issue !== blocking
|
|
988
1150
|
);
|
|
989
|
-
|
|
1151
|
+
checks2.push({
|
|
990
1152
|
name: " Execution",
|
|
991
1153
|
status: capabilityStatus(entry.canExecute),
|
|
992
1154
|
detail: `${EXECUTION_DETAIL[entry.executionMode] ?? entry.executionMode}${entry.canExecute === "no" && executionIssue ? `. ${executionIssue.message}` : ""}`
|
|
993
1155
|
});
|
|
994
|
-
|
|
1156
|
+
checks2.push({
|
|
995
1157
|
name: " Balance",
|
|
996
1158
|
status: entry.funding === "unfunded" ? "fail" : "ok",
|
|
997
1159
|
detail: entry.funding === "not_required" ? "Simulated sandbox: no onchain funding required" : entry.funding === "funded" ? printAmount(wallet.balance, wallet.currency) : entry.funding === "unfunded" ? `0 ${wallet.currency}. Fund this wallet before paying.` : "Not checked by Conto. The wallet you sign with must hold the funds."
|
|
998
1160
|
});
|
|
999
1161
|
if (wallet.limits?.daily != null) {
|
|
1000
|
-
|
|
1162
|
+
checks2.push({
|
|
1001
1163
|
name: " Daily limit",
|
|
1002
1164
|
status: "ok",
|
|
1003
1165
|
detail: `${printAmount(wallet.spent?.today ?? 0, "USD")} spent of ${printAmount(wallet.limits.daily, "USD")}`
|
|
@@ -1005,22 +1167,22 @@ function diagnosticChecks(setup, diagnostics) {
|
|
|
1005
1167
|
}
|
|
1006
1168
|
}
|
|
1007
1169
|
if (diagnostics.connectedCards) {
|
|
1008
|
-
|
|
1009
|
-
|
|
1170
|
+
checks2.push(cardCheck("Test cards", diagnostics.connectedCards.test));
|
|
1171
|
+
checks2.push(cardCheck("Live cards", diagnostics.connectedCards.live));
|
|
1010
1172
|
}
|
|
1011
1173
|
const { canRequest, canExecute } = diagnostics.status;
|
|
1012
1174
|
const sandbox = environment ? environment.kind !== "account" : false;
|
|
1013
|
-
|
|
1175
|
+
checks2.push({
|
|
1014
1176
|
name: "Payment readiness",
|
|
1015
1177
|
status: canRequest === "yes" ? capabilityStatus(canExecute) : "fail",
|
|
1016
1178
|
detail: canRequest !== "yes" ? "No wallet or card can take a payment request with this setup. See the next steps below." : canExecute === "yes" ? sandbox ? "Sandbox can request and record test payments" : "Can request and execute payments" : canExecute === "unknown" ? "Can request payments. Sending needs your own signer, which Conto cannot check." : "Requests work. Execution is blocked. See the next steps below."
|
|
1017
1179
|
});
|
|
1018
|
-
return
|
|
1180
|
+
return checks2;
|
|
1019
1181
|
}
|
|
1020
1182
|
function legacyChecks(setup, config) {
|
|
1021
|
-
const
|
|
1183
|
+
const checks2 = [];
|
|
1022
1184
|
const isSandbox = config.sandboxMode === "test";
|
|
1023
|
-
|
|
1185
|
+
checks2.push({
|
|
1024
1186
|
name: "Agent status",
|
|
1025
1187
|
status: setup.agent.status === "active" ? "ok" : "fail",
|
|
1026
1188
|
detail: setup.agent.status === "active" ? "Active" : `${setup.agent.status}. Activate the agent in the dashboard.`
|
|
@@ -1028,19 +1190,19 @@ function legacyChecks(setup, config) {
|
|
|
1028
1190
|
const scopes = setup.scopes || [];
|
|
1029
1191
|
const canRequest = scopes.includes("payments:request");
|
|
1030
1192
|
const canExecute = scopes.includes("payments:execute");
|
|
1031
|
-
|
|
1193
|
+
checks2.push({
|
|
1032
1194
|
name: "Scope payments:request",
|
|
1033
1195
|
status: canRequest ? "ok" : "fail",
|
|
1034
1196
|
detail: canRequest ? "Granted" : "Missing. This key cannot request payments."
|
|
1035
1197
|
});
|
|
1036
|
-
|
|
1198
|
+
checks2.push({
|
|
1037
1199
|
name: "Scope payments:execute",
|
|
1038
1200
|
status: canExecute ? "ok" : "warn",
|
|
1039
1201
|
detail: canExecute ? "Granted" : 'Missing. "conto pay" can request but not execute. Create a new standard SDK key.'
|
|
1040
1202
|
});
|
|
1041
1203
|
const wallets = setup.wallets || [];
|
|
1042
1204
|
if (wallets.length === 0) {
|
|
1043
|
-
|
|
1205
|
+
checks2.push({
|
|
1044
1206
|
name: "Wallet",
|
|
1045
1207
|
status: "fail",
|
|
1046
1208
|
detail: 'No wallet linked to this agent. Run "npx @conto_finance/create-conto-agent" or link one in the dashboard.'
|
|
@@ -1048,24 +1210,24 @@ function legacyChecks(setup, config) {
|
|
|
1048
1210
|
}
|
|
1049
1211
|
for (const w of wallets) {
|
|
1050
1212
|
const chainLabel = `${w.chainName} (${w.chainId})${w.isTestnet ? " testnet" : ""}`;
|
|
1051
|
-
|
|
1213
|
+
checks2.push({
|
|
1052
1214
|
name: `Wallet ${shortAddress(w.address)}`,
|
|
1053
1215
|
status: w.status === "active" ? "ok" : "warn",
|
|
1054
1216
|
detail: `${chainLabel}, ${w.custodyMode} custody, status ${w.status}`
|
|
1055
1217
|
});
|
|
1056
1218
|
const paymentMode = isSandbox ? "test" : w.custodyMode === "MANAGED" ? "managed" : "external";
|
|
1057
|
-
|
|
1219
|
+
checks2.push({
|
|
1058
1220
|
name: " Execution",
|
|
1059
1221
|
status: paymentMode === "managed" || paymentMode === "test" ? "ok" : "warn",
|
|
1060
1222
|
detail: paymentMode === "managed" ? "Managed by Conto (real transfers)" : paymentMode === "test" ? `Sandbox test mode${config.sandboxExpiresAt ? ` until ${config.sandboxExpiresAt}` : ""}; no onchain transfer required` : "External: the agent signs transactions and confirms them through the API"
|
|
1061
1223
|
});
|
|
1062
|
-
|
|
1224
|
+
checks2.push({
|
|
1063
1225
|
name: " Balance",
|
|
1064
1226
|
status: w.balance > 0 || isSandbox ? "ok" : "warn",
|
|
1065
1227
|
detail: isSandbox ? "Simulated sandbox: no onchain funding required" : w.balance > 0 ? `${printAmount(w.balance, w.currency)}` : `0 ${w.currency}. Fund this wallet before paying${w.isTestnet ? " (testnet faucet available via init)" : ""}.`
|
|
1066
1228
|
});
|
|
1067
1229
|
if (w.limits?.daily != null) {
|
|
1068
|
-
|
|
1230
|
+
checks2.push({
|
|
1069
1231
|
name: " Daily limit",
|
|
1070
1232
|
status: "ok",
|
|
1071
1233
|
detail: `${printAmount(w.spent?.today ?? 0, "USD")} spent of ${printAmount(w.limits.daily, "USD")}`
|
|
@@ -1076,12 +1238,12 @@ function legacyChecks(setup, config) {
|
|
|
1076
1238
|
(wallet) => wallet.status === "active" && wallet.custodyMode === "MANAGED" && wallet.balance > 0
|
|
1077
1239
|
);
|
|
1078
1240
|
const readyForManagedExecution = setup.agent.status === "active" && canRequest && canExecute && (hasManagedWallet || isSandbox && wallets.some((wallet) => wallet.status === "active"));
|
|
1079
|
-
|
|
1241
|
+
checks2.push({
|
|
1080
1242
|
name: "Payment readiness",
|
|
1081
1243
|
status: readyForManagedExecution ? "ok" : canRequest ? "warn" : "fail",
|
|
1082
1244
|
detail: readyForManagedExecution ? isSandbox ? "Sandbox can request and record test payments" : "Key and managed wallet can request and execute payments" : canRequest ? "Requests work; execution is limited (see checks above)" : "This key cannot request payments"
|
|
1083
1245
|
});
|
|
1084
|
-
return
|
|
1246
|
+
return checks2;
|
|
1085
1247
|
}
|
|
1086
1248
|
function shortAddress(address) {
|
|
1087
1249
|
if (!address || address.length <= 14) return address;
|
|
@@ -1201,7 +1363,7 @@ re-run with the printed key: --idempotency-key <key> returns the same request.
|
|
|
1201
1363
|
|
|
1202
1364
|
Exit codes:
|
|
1203
1365
|
0 sent, or already handled
|
|
1204
|
-
1 request failed
|
|
1366
|
+
1 request failed, or denied by policy
|
|
1205
1367
|
3 an approver rejected the payment
|
|
1206
1368
|
4 not sent yet: waiting for approval (--no-wait, or the wait timed out),
|
|
1207
1369
|
or approved and waiting for conto pay execute
|
|
@@ -1590,6 +1752,7 @@ async function payCommand(address, amountStr, options) {
|
|
|
1590
1752
|
if (request.status === "DENIED") {
|
|
1591
1753
|
if (isJsonMode()) {
|
|
1592
1754
|
printJson({ ...request, idempotencyKey });
|
|
1755
|
+
process.exitCode = 1;
|
|
1593
1756
|
return;
|
|
1594
1757
|
}
|
|
1595
1758
|
printError("Payment denied by policy");
|
|
@@ -1726,7 +1889,7 @@ async function walletsCommand(subcommand, options = {}) {
|
|
|
1726
1889
|
const api = createApiClient({
|
|
1727
1890
|
baseUrl: config.baseUrl,
|
|
1728
1891
|
apiKey: config.apiKey,
|
|
1729
|
-
orgApiKey: config
|
|
1892
|
+
orgApiKey: orgApiKeySource(config)
|
|
1730
1893
|
});
|
|
1731
1894
|
try {
|
|
1732
1895
|
await fetchChains(config.baseUrl);
|
|
@@ -1759,12 +1922,13 @@ async function walletsCommand(subcommand, options = {}) {
|
|
|
1759
1922
|
return;
|
|
1760
1923
|
}
|
|
1761
1924
|
if (options.faucet) {
|
|
1762
|
-
if (!config
|
|
1925
|
+
if (!hasOrgApiKey(config)) {
|
|
1763
1926
|
printError(
|
|
1764
1927
|
'Faucet funding requires an organization key. Run "conto login" or create the project with "npx @conto_finance/create-conto-agent".'
|
|
1765
1928
|
);
|
|
1766
1929
|
process.exit(1);
|
|
1767
1930
|
}
|
|
1931
|
+
await resolveOrgApiKey(config);
|
|
1768
1932
|
const results = [];
|
|
1769
1933
|
for (const w of wallets) {
|
|
1770
1934
|
const chainEntry = getChain(w.chainId);
|
|
@@ -2112,6 +2276,22 @@ var ACTIONS = [
|
|
|
2112
2276
|
hint: "Payment needs human approval if rule triggers"
|
|
2113
2277
|
}
|
|
2114
2278
|
];
|
|
2279
|
+
function actionChoicesFor(ruleType) {
|
|
2280
|
+
return isBlocklistRuleType(ruleType) ? { options: ACTIONS.filter((action) => action.value !== "ALLOW"), initialValue: "DENY" } : { options: ACTIONS };
|
|
2281
|
+
}
|
|
2282
|
+
var ORG_KEY_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
2283
|
+
"all",
|
|
2284
|
+
"create",
|
|
2285
|
+
"update",
|
|
2286
|
+
"delete",
|
|
2287
|
+
"assign",
|
|
2288
|
+
"unassign",
|
|
2289
|
+
"add-rule",
|
|
2290
|
+
"remove-rule",
|
|
2291
|
+
"versions",
|
|
2292
|
+
"rollback",
|
|
2293
|
+
"simulate"
|
|
2294
|
+
]);
|
|
2115
2295
|
async function policiesCommand(subcommand = "list", idOrAmount, extra, reviewOptions = {}) {
|
|
2116
2296
|
const config = loadConfig();
|
|
2117
2297
|
if (!config.apiKey) {
|
|
@@ -2123,9 +2303,10 @@ async function policiesCommand(subcommand = "list", idOrAmount, extra, reviewOpt
|
|
|
2123
2303
|
const api = createOwnerClient({
|
|
2124
2304
|
baseUrl: config.baseUrl,
|
|
2125
2305
|
apiKey: config.apiKey,
|
|
2126
|
-
orgApiKey: config
|
|
2306
|
+
orgApiKey: orgApiKeySource(config)
|
|
2127
2307
|
});
|
|
2128
2308
|
try {
|
|
2309
|
+
if (ORG_KEY_SUBCOMMANDS.has(subcommand)) await resolveOrgApiKey(config);
|
|
2129
2310
|
switch (subcommand) {
|
|
2130
2311
|
case "list":
|
|
2131
2312
|
return await listAgentPolicies(api);
|
|
@@ -2601,7 +2782,7 @@ async function promptForRule(policyType) {
|
|
|
2601
2782
|
}
|
|
2602
2783
|
const action = await p.select({
|
|
2603
2784
|
message: "Action when rule triggers",
|
|
2604
|
-
|
|
2785
|
+
...actionChoicesFor(ruleType)
|
|
2605
2786
|
});
|
|
2606
2787
|
if (p.isCancel(action)) return null;
|
|
2607
2788
|
return {
|
|
@@ -3473,6 +3654,7 @@ async function mcpCommand() {
|
|
|
3473
3654
|
|
|
3474
3655
|
// src/commands/webhooks.ts
|
|
3475
3656
|
import { createHmac, randomUUID as randomUUID2 } from "crypto";
|
|
3657
|
+
var sign = (secret, input) => createHmac("sha256", secret).update(input).digest("hex");
|
|
3476
3658
|
async function testWebhook(url) {
|
|
3477
3659
|
const started = Date.now();
|
|
3478
3660
|
try {
|
|
@@ -3488,6 +3670,7 @@ async function testWebhook(url) {
|
|
|
3488
3670
|
const event = "payment.confirmed";
|
|
3489
3671
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
3490
3672
|
const paymentId = `test_${randomUUID2()}`;
|
|
3673
|
+
const deliveryId = randomUUID2();
|
|
3491
3674
|
const body = JSON.stringify({
|
|
3492
3675
|
event,
|
|
3493
3676
|
timestamp,
|
|
@@ -3499,8 +3682,10 @@ async function testWebhook(url) {
|
|
|
3499
3682
|
amount: 0.01,
|
|
3500
3683
|
currency: "pathUSD",
|
|
3501
3684
|
status: "CONFIRMED",
|
|
3685
|
+
settlementMode: "test",
|
|
3502
3686
|
test: true
|
|
3503
|
-
}
|
|
3687
|
+
},
|
|
3688
|
+
deliveryId
|
|
3504
3689
|
});
|
|
3505
3690
|
const response = await fetch(target, {
|
|
3506
3691
|
method: "POST",
|
|
@@ -3510,8 +3695,10 @@ async function testWebhook(url) {
|
|
|
3510
3695
|
"Content-Type": "application/json",
|
|
3511
3696
|
"X-Conto-Event": event,
|
|
3512
3697
|
"X-Conto-Timestamp": timestamp,
|
|
3698
|
+
"X-Conto-Delivery-Id": deliveryId,
|
|
3513
3699
|
"X-Conto-Delivery-Attempt": "1",
|
|
3514
|
-
"X-Conto-Signature":
|
|
3700
|
+
"X-Conto-Signature": sign(secret, body),
|
|
3701
|
+
"X-Conto-Signature-V2": sign(secret, `${timestamp}.${body}`)
|
|
3515
3702
|
},
|
|
3516
3703
|
body
|
|
3517
3704
|
});
|
|
@@ -3522,6 +3709,7 @@ async function testWebhook(url) {
|
|
|
3522
3709
|
elapsedMs: Date.now() - started,
|
|
3523
3710
|
event,
|
|
3524
3711
|
paymentId,
|
|
3712
|
+
deliveryId,
|
|
3525
3713
|
test: true
|
|
3526
3714
|
};
|
|
3527
3715
|
if (isJsonMode()) printJson(result);
|
|
@@ -3553,7 +3741,7 @@ var HANDOFF_PATH = "/api/agents/sandbox/handoff";
|
|
|
3553
3741
|
var DEFAULT_POLL_INTERVAL_SECONDS = 5;
|
|
3554
3742
|
var MIN_POLL_INTERVAL_SECONDS = 1;
|
|
3555
3743
|
var MAX_POLL_INTERVAL_SECONDS = 60;
|
|
3556
|
-
var
|
|
3744
|
+
var REQUEST_TIMEOUT_MS2 = 15e3;
|
|
3557
3745
|
var SANDBOX_ORG_KEY_PATTERN = /^conto_[a-f0-9]{64}$/;
|
|
3558
3746
|
var HANDOFF_TOKEN_PATTERN = /^conto_claim_[a-f0-9]{64}$/;
|
|
3559
3747
|
function isHandoffToken(value) {
|
|
@@ -3657,7 +3845,7 @@ async function initiateHandoff(input) {
|
|
|
3657
3845
|
url: apiUrl(input.baseUrl, HANDOFF_PATH),
|
|
3658
3846
|
method: "POST",
|
|
3659
3847
|
bearer: input.sandboxKey,
|
|
3660
|
-
timeoutMs:
|
|
3848
|
+
timeoutMs: REQUEST_TIMEOUT_MS2,
|
|
3661
3849
|
signal: input.signal
|
|
3662
3850
|
});
|
|
3663
3851
|
} catch (error) {
|
|
@@ -3708,7 +3896,7 @@ async function inspectHandoff(input) {
|
|
|
3708
3896
|
url: apiUrl(input.baseUrl, input.statusPath),
|
|
3709
3897
|
method: "GET",
|
|
3710
3898
|
bearer: input.token,
|
|
3711
|
-
timeoutMs:
|
|
3899
|
+
timeoutMs: REQUEST_TIMEOUT_MS2,
|
|
3712
3900
|
signal: input.signal
|
|
3713
3901
|
});
|
|
3714
3902
|
} catch (error) {
|
|
@@ -4616,16 +4804,30 @@ withReview(
|
|
|
4616
4804
|
keysGroup.command("revoke <agentId> <keyId>").description("Revoke an SDK key").action(agentsKeysRevokeCommand);
|
|
4617
4805
|
var teamsGroup = program.command("teams").description("Manage teams of agents, their managers and cost centers").addHelpText(
|
|
4618
4806
|
"after",
|
|
4619
|
-
'\nReads work with any organization key.
|
|
4807
|
+
'\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
4808
|
);
|
|
4621
4809
|
teamsGroup.command("list").description("List teams").action(teamsListCommand);
|
|
4622
4810
|
teamsGroup.command("show <teamId>").description("Show one team").action(teamsShowCommand);
|
|
4623
|
-
|
|
4624
|
-
teamsGroup.command("
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
teamsGroup.command("
|
|
4628
|
-
|
|
4811
|
+
withReview(
|
|
4812
|
+
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")
|
|
4813
|
+
).action(teamsCreateCommand);
|
|
4814
|
+
withReview(
|
|
4815
|
+
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")
|
|
4816
|
+
).action(teamsUpdateCommand);
|
|
4817
|
+
withReview(
|
|
4818
|
+
teamsGroup.command("delete <teamId>").description("Delete a team with no agents, policies or budgets")
|
|
4819
|
+
).action(teamsDeleteCommand);
|
|
4820
|
+
withReview(
|
|
4821
|
+
teamsGroup.command("managers <teamId> [who...]").description("Replace the managers, by email or membership id (none clears them)")
|
|
4822
|
+
).action(
|
|
4823
|
+
(teamId, who, options) => teamsManagersCommand(teamId, who ?? [], options)
|
|
4824
|
+
);
|
|
4825
|
+
withReview(
|
|
4826
|
+
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")
|
|
4827
|
+
).action(teamsAddCommand);
|
|
4828
|
+
withReview(
|
|
4829
|
+
teamsGroup.command("remove <teamId> <agentId>").description("Take an agent out of a team").option("--approval <id>", "Approved governance request for this exact change")
|
|
4830
|
+
).action(teamsRemoveCommand);
|
|
4629
4831
|
var payeesGroup = program.command("counterparties").description("Manage the organization's payees");
|
|
4630
4832
|
payeesGroup.command("list").description("List payees").action(counterpartiesListCommand);
|
|
4631
4833
|
payeesGroup.command("show <id>").description("Show one payee").action(counterpartiesShowCommand);
|
|
@@ -4659,7 +4861,7 @@ alertsGroup.command("resolve <alertId>").description("Resolve an alert").action(
|
|
|
4659
4861
|
program.command("config [key] [value]").description("Show or update configuration").action(configCommand);
|
|
4660
4862
|
program.command("login").description("Authenticate with Conto").option("--base-url <url>", "Conto instance URL").action(loginCommand);
|
|
4661
4863
|
program.command("logout").description("Clear stored credentials").action(async () => {
|
|
4662
|
-
const { clearGlobalConfig } = await import("./config-
|
|
4864
|
+
const { clearGlobalConfig } = await import("./config-2C6Q4NEJ.js");
|
|
4663
4865
|
clearGlobalConfig();
|
|
4664
4866
|
const { printSuccess: printSuccess2 } = await import("./output-GD3QK4HS.js");
|
|
4665
4867
|
printSuccess2("Logged out. Credentials cleared.");
|
|
@@ -11,9 +11,10 @@ import {
|
|
|
11
11
|
maskSecret,
|
|
12
12
|
missingSdkKeyMessage,
|
|
13
13
|
saveGlobalConfig,
|
|
14
|
+
savedOrgKeyFor,
|
|
14
15
|
writeEnvLocal,
|
|
15
16
|
writeSandboxSetupEnv
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-F72EK2TO.js";
|
|
17
18
|
export {
|
|
18
19
|
SANDBOX_SETUP_ENV_FILE,
|
|
19
20
|
clearGlobalConfig,
|
|
@@ -27,6 +28,7 @@ export {
|
|
|
27
28
|
maskSecret,
|
|
28
29
|
missingSdkKeyMessage,
|
|
29
30
|
saveGlobalConfig,
|
|
31
|
+
savedOrgKeyFor,
|
|
30
32
|
writeEnvLocal,
|
|
31
33
|
writeSandboxSetupEnv
|
|
32
34
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runInit
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import
|
|
3
|
+
} from "./chunk-FW6E3QMB.js";
|
|
4
|
+
import {
|
|
5
|
+
delegatesToCli
|
|
6
|
+
} from "./chunk-D6JPJHU4.js";
|
|
7
|
+
import "./chunk-F72EK2TO.js";
|
|
5
8
|
import {
|
|
6
9
|
isJsonMode,
|
|
7
10
|
printJson,
|
|
@@ -9,39 +12,8 @@ import {
|
|
|
9
12
|
} from "./chunk-DT5NOLBD.js";
|
|
10
13
|
|
|
11
14
|
// src/index.ts
|
|
12
|
-
var CLI_COMMANDS = /* @__PURE__ */ new Set([
|
|
13
|
-
"status",
|
|
14
|
-
"doctor",
|
|
15
|
-
"balance",
|
|
16
|
-
"pay",
|
|
17
|
-
"transactions",
|
|
18
|
-
"wallets",
|
|
19
|
-
"webhooks",
|
|
20
|
-
"agents",
|
|
21
|
-
"counterparties",
|
|
22
|
-
"channels",
|
|
23
|
-
"changes",
|
|
24
|
-
"test-report",
|
|
25
|
-
"fund",
|
|
26
|
-
"policies",
|
|
27
|
-
"limits",
|
|
28
|
-
"alerts",
|
|
29
|
-
"config",
|
|
30
|
-
"login",
|
|
31
|
-
"logout",
|
|
32
|
-
"mcp",
|
|
33
|
-
"docs",
|
|
34
|
-
"init",
|
|
35
|
-
"sandbox",
|
|
36
|
-
"help",
|
|
37
|
-
"--help",
|
|
38
|
-
"-h",
|
|
39
|
-
"--version",
|
|
40
|
-
"-V"
|
|
41
|
-
]);
|
|
42
15
|
var args = process.argv.slice(2);
|
|
43
|
-
|
|
44
|
-
if (delegatedCommand) {
|
|
16
|
+
if (delegatesToCli(args)) {
|
|
45
17
|
await import("./cli.js");
|
|
46
18
|
} else {
|
|
47
19
|
const options = {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First arguments that `create-conto-agent` hands to the full conto CLI
|
|
3
|
+
* instead of starting the setup wizard. Every top-level command registered in
|
|
4
|
+
* cli.ts must be here, or `npx @conto_finance/create-conto-agent <command>`
|
|
5
|
+
* runs setup. test/delegation.test.mjs fails when one is missing.
|
|
6
|
+
*/
|
|
7
|
+
declare const CLI_COMMANDS: ReadonlySet<string>;
|
|
8
|
+
/** Whether these arguments name a conto CLI command, optionally after a leading --json. */
|
|
9
|
+
declare function delegatesToCli(args: readonly string[]): boolean;
|
|
10
|
+
|
|
11
|
+
export { CLI_COMMANDS, delegatesToCli };
|
|
@@ -61,6 +61,14 @@ declare function validatePaymentRequest(input: {
|
|
|
61
61
|
category?: string;
|
|
62
62
|
walletId?: string;
|
|
63
63
|
}): PaymentValidation;
|
|
64
|
+
/**
|
|
65
|
+
* Rule types that block what they match. Conto refuses ALLOW on these, since an
|
|
66
|
+
* ALLOW rule permits only what its condition matches, so a blocklist saved as
|
|
67
|
+
* ALLOW would permit only what it lists. Keep in step with the app's
|
|
68
|
+
* src/lib/policies/blocklist-rules.ts.
|
|
69
|
+
*/
|
|
70
|
+
declare const BLOCKLIST_RULE_TYPES: readonly string[];
|
|
71
|
+
declare function isBlocklistRuleType(ruleType: string): boolean;
|
|
64
72
|
|
|
65
|
-
export { BUDGET_PERIODS, VELOCITY_PERIODS, buildBudgetCapValue, buildVelocityCountValue, dateRangePlaceholder, parseTrustScoreInput, validatePaymentRequest };
|
|
73
|
+
export { BLOCKLIST_RULE_TYPES, BUDGET_PERIODS, VELOCITY_PERIODS, buildBudgetCapValue, buildVelocityCountValue, dateRangePlaceholder, isBlocklistRuleType, parseTrustScoreInput, validatePaymentRequest };
|
|
66
74
|
export type { PaymentRequestBody, PaymentValidation, ValidationResult, VelocityPeriod };
|
package/dist/lib/rule-values.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BLOCKLIST_RULE_TYPES,
|
|
2
3
|
BUDGET_PERIODS,
|
|
3
4
|
VELOCITY_PERIODS,
|
|
4
5
|
buildBudgetCapValue,
|
|
5
6
|
buildVelocityCountValue,
|
|
6
7
|
dateRangePlaceholder,
|
|
8
|
+
isBlocklistRuleType,
|
|
7
9
|
parseTrustScoreInput,
|
|
8
10
|
validatePaymentRequest
|
|
9
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-PUHGIKBB.js";
|
|
10
12
|
export {
|
|
13
|
+
BLOCKLIST_RULE_TYPES,
|
|
11
14
|
BUDGET_PERIODS,
|
|
12
15
|
VELOCITY_PERIODS,
|
|
13
16
|
buildBudgetCapValue,
|
|
14
17
|
buildVelocityCountValue,
|
|
15
18
|
dateRangePlaceholder,
|
|
19
|
+
isBlocklistRuleType,
|
|
16
20
|
parseTrustScoreInput,
|
|
17
21
|
validatePaymentRequest
|
|
18
22
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conto_finance/create-conto-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "tsup src/index.ts src/cli.ts src/lib/rule-values.ts --format esm --dts --clean",
|
|
22
|
-
"dev": "tsup src/index.ts src/cli.ts src/lib/rule-values.ts --format esm --dts --watch",
|
|
21
|
+
"build": "tsup src/index.ts src/cli.ts src/lib/rule-values.ts src/lib/cli-commands.ts --format esm --dts --clean",
|
|
22
|
+
"dev": "tsup src/index.ts src/cli.ts src/lib/rule-values.ts src/lib/cli-commands.ts --format esm --dts --watch",
|
|
23
23
|
"lint": "tsc --noEmit",
|
|
24
24
|
"test": "npm run lint && npm run test:contract",
|
|
25
25
|
"test:contract": "npm run build && node --test test/*.test.mjs",
|