@conto_finance/create-conto-agent 0.8.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 CHANGED
@@ -1,5 +1,26 @@
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
+
3
24
  ## 0.8.0
4
25
 
5
26
  - With the key from `conto login`, `conto teams` changes now go to owner review instead of failing.
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 signed event to a loopback address. It creates no payment and requires no API key.
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. Exit code 6 means the
51
- outcome is unknown and the payment may have gone through. Do not run the same command again, because
52
- that starts a new payment. Run `pay status <requestId>`, or, with no request ID yet, retry with
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
@@ -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-RQ4PUBL7.js";
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.8.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.orgApiKey : this.apiKey;
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.orgApiKey : this.apiKey;
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-HGEZBNZB.js";
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-2M2WVAJI.js";
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
- } from "./chunk-RQ4PUBL7.js";
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.orgApiKey : config.apiKey))
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
- const result = await work(createApiClient(config));
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.orgApiKey)
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(config);
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.orgApiKey) {
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.orgApiKey
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;
@@ -792,9 +900,9 @@ function mergeIssues(diagnostics, local) {
792
900
  const reported = new Set(server.map((issue) => issue.code));
793
901
  return [...server, ...local.filter((issue) => !reported.has(issue.code))];
794
902
  }
795
- function exitCodeFor(checks, issues, unavailable) {
903
+ function exitCodeFor(checks2, issues, unavailable) {
796
904
  if (unavailable) return DOCTOR_EXIT_CODES.UNAVAILABLE;
797
- if (checks.some((check) => check.status === "fail")) return DOCTOR_EXIT_CODES.ACTION_REQUIRED;
905
+ if (checks2.some((check) => check.status === "fail")) return DOCTOR_EXIT_CODES.ACTION_REQUIRED;
798
906
  if (issues.some((issue) => issue.severity === "error")) {
799
907
  return DOCTOR_EXIT_CODES.ACTION_REQUIRED;
800
908
  }
@@ -844,7 +952,7 @@ async function doctorCommand() {
844
952
  }
845
953
  async function runDoctor() {
846
954
  const config = loadConfig();
847
- const checks = [];
955
+ const checks2 = [];
848
956
  const local = [];
849
957
  const addLocal = (issue) => {
850
958
  if (!local.some((existing) => existing.code === issue.code)) local.push(issue);
@@ -852,7 +960,7 @@ async function runDoctor() {
852
960
  const finish = (fields = {}) => {
853
961
  const diagnostics2 = fields.diagnostics ?? null;
854
962
  const issues = mergeIssues(diagnostics2, local);
855
- const exitCode = exitCodeFor(checks, issues, fields.unavailable === true);
963
+ const exitCode = exitCodeFor(checks2, issues, fields.unavailable === true);
856
964
  let setup2 = null;
857
965
  if (fields.setup) {
858
966
  const { diagnostics: _serverDiagnostics, ...setupFields } = fields.setup;
@@ -864,7 +972,7 @@ async function runDoctor() {
864
972
  exitCode,
865
973
  baseUrl: config.baseUrl,
866
974
  diagnosticsSource: diagnostics2 ? "server" : "cli",
867
- checks: checks.map((check) => ({ ...check, name: check.name.trim() })),
975
+ checks: checks2.map((check) => ({ ...check, name: check.name.trim() })),
868
976
  issues,
869
977
  diagnostics: diagnostics2,
870
978
  setup: setup2
@@ -873,19 +981,19 @@ async function runDoctor() {
873
981
  let api = null;
874
982
  try {
875
983
  api = createApiClient({ baseUrl: config.baseUrl, apiKey: config.apiKey });
876
- checks.push({ name: "Base URL", status: "ok", detail: config.baseUrl });
984
+ checks2.push({ name: "Base URL", status: "ok", detail: config.baseUrl });
877
985
  } catch (error) {
878
986
  const message = errorMessage(error, "Invalid base URL");
879
- checks.push({ name: "Base URL", status: "fail", detail: `${config.baseUrl}: ${message}` });
987
+ checks2.push({ name: "Base URL", status: "fail", detail: `${config.baseUrl}: ${message}` });
880
988
  addLocal(baseUrlInvalidIssue(message));
881
989
  }
882
990
  if (!config.apiKey) {
883
991
  const message = missingSdkKeyMessage(config);
884
- checks.push({ name: "SDK key", status: "fail", detail: message });
992
+ checks2.push({ name: "SDK key", status: "fail", detail: message });
885
993
  addLocal(sdkKeyNotConfiguredIssue(message));
886
994
  return finish();
887
995
  }
888
- checks.push({
996
+ checks2.push({
889
997
  name: "SDK key",
890
998
  status: "ok",
891
999
  detail: `${maskSecret(config.apiKey)} (from ${process.env.CONTO_API_KEY ? "environment" : ".env.local or ~/.conto/config.json"})`
@@ -899,7 +1007,7 @@ async function runDoctor() {
899
1007
  const failure = error;
900
1008
  const status = typeof failure.status === "number" ? failure.status : 0;
901
1009
  const message = errorMessage(error, "Request failed");
902
- checks.push({
1010
+ checks2.push({
903
1011
  name: "Authentication",
904
1012
  status: "fail",
905
1013
  detail: `${config.baseUrl}/api/sdk/setup: ${message}`
@@ -923,13 +1031,13 @@ async function runDoctor() {
923
1031
  }
924
1032
  return finish({ diagnostics: diagnostics2 });
925
1033
  }
926
- checks.push({
1034
+ checks2.push({
927
1035
  name: "Authentication",
928
1036
  status: "ok",
929
1037
  detail: `Authenticated as agent "${setup.agent.name}"`
930
1038
  });
931
1039
  const diagnostics = readServerDiagnostics(setup.diagnostics);
932
- checks.push(
1040
+ checks2.push(
933
1041
  ...diagnostics ? diagnosticChecks(setup, diagnostics) : legacyChecks(setup, config)
934
1042
  );
935
1043
  return finish({ diagnostics, setup });
@@ -976,12 +1084,12 @@ function cardCheck(name, card) {
976
1084
  };
977
1085
  }
978
1086
  function diagnosticChecks(setup, diagnostics) {
979
- const checks = [];
1087
+ const checks2 = [];
980
1088
  const environment = diagnostics.environment;
981
1089
  if (environment) {
982
1090
  const expiry = environment.kind === "anonymous_sandbox" && environment.sandboxExpiresAt ? `, expires ${environment.sandboxExpiresAt}` : "";
983
1091
  const agentEnvironment = environment.kind === "account" ? `, agent environment ${environment.agentEnvironment}` : "";
984
- checks.push({
1092
+ checks2.push({
985
1093
  name: "Environment",
986
1094
  status: "ok",
987
1095
  detail: `${ENVIRONMENT_DETAIL[environment.kind] ?? environment.kind}${agentEnvironment}${expiry}`
@@ -991,7 +1099,7 @@ function diagnosticChecks(setup, diagnostics) {
991
1099
  (issue) => issue.resource.type === "agent" && issue.code.startsWith("AGENT_")
992
1100
  );
993
1101
  const agentActive = setup.agent.status === "active" && !agentIssue;
994
- checks.push({
1102
+ checks2.push({
995
1103
  name: "Agent status",
996
1104
  status: agentActive ? "ok" : "fail",
997
1105
  detail: agentIssue?.message ?? (agentActive ? "Active" : setup.agent.status)
@@ -1007,7 +1115,7 @@ function diagnosticChecks(setup, diagnostics) {
1007
1115
  ];
1008
1116
  for (const scope of scopeNames) {
1009
1117
  const missing = scopeIssues.find((issue) => issue.requiredScope === scope);
1010
- checks.push({
1118
+ checks2.push({
1011
1119
  name: `Scope ${scope}`,
1012
1120
  status: scopes.includes(scope) ? "ok" : missing?.severity === "error" ? "fail" : "warn",
1013
1121
  detail: scopes.includes(scope) ? "Granted" : missing?.message ?? "Missing. None of this agent's wallets needs it."
@@ -1016,7 +1124,7 @@ function diagnosticChecks(setup, diagnostics) {
1016
1124
  const wallets = setup.wallets || [];
1017
1125
  if (wallets.length === 0) {
1018
1126
  const noWallet = diagnostics.issues.find((issue) => issue.code === "NO_WALLET");
1019
- checks.push({
1127
+ checks2.push({
1020
1128
  name: "Wallet",
1021
1129
  status: noWallet?.severity === "error" ? "fail" : "warn",
1022
1130
  detail: noWallet?.message ?? "No wallet is linked to this agent."
@@ -1031,7 +1139,7 @@ function diagnosticChecks(setup, diagnostics) {
1031
1139
  (issue) => issue.severity === "error" && WALLET_ACCESS_CODES.has(issue.code)
1032
1140
  );
1033
1141
  const chainLabel = `${wallet.chainName} (${wallet.chainId})${wallet.isTestnet ? " testnet" : ""}`;
1034
- checks.push({
1142
+ checks2.push({
1035
1143
  name: `Wallet ${shortAddress(wallet.address)}`,
1036
1144
  status: blocking ? "fail" : "ok",
1037
1145
  detail: `${chainLabel}, ${wallet.custodyMode} custody, status ${wallet.status}${blocking ? `. ${blocking.message}` : ""}`
@@ -1040,18 +1148,18 @@ function diagnosticChecks(setup, diagnostics) {
1040
1148
  const executionIssue = walletIssues.find(
1041
1149
  (issue) => issue.severity === "error" && issue !== blocking
1042
1150
  );
1043
- checks.push({
1151
+ checks2.push({
1044
1152
  name: " Execution",
1045
1153
  status: capabilityStatus(entry.canExecute),
1046
1154
  detail: `${EXECUTION_DETAIL[entry.executionMode] ?? entry.executionMode}${entry.canExecute === "no" && executionIssue ? `. ${executionIssue.message}` : ""}`
1047
1155
  });
1048
- checks.push({
1156
+ checks2.push({
1049
1157
  name: " Balance",
1050
1158
  status: entry.funding === "unfunded" ? "fail" : "ok",
1051
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."
1052
1160
  });
1053
1161
  if (wallet.limits?.daily != null) {
1054
- checks.push({
1162
+ checks2.push({
1055
1163
  name: " Daily limit",
1056
1164
  status: "ok",
1057
1165
  detail: `${printAmount(wallet.spent?.today ?? 0, "USD")} spent of ${printAmount(wallet.limits.daily, "USD")}`
@@ -1059,22 +1167,22 @@ function diagnosticChecks(setup, diagnostics) {
1059
1167
  }
1060
1168
  }
1061
1169
  if (diagnostics.connectedCards) {
1062
- checks.push(cardCheck("Test cards", diagnostics.connectedCards.test));
1063
- checks.push(cardCheck("Live cards", diagnostics.connectedCards.live));
1170
+ checks2.push(cardCheck("Test cards", diagnostics.connectedCards.test));
1171
+ checks2.push(cardCheck("Live cards", diagnostics.connectedCards.live));
1064
1172
  }
1065
1173
  const { canRequest, canExecute } = diagnostics.status;
1066
1174
  const sandbox = environment ? environment.kind !== "account" : false;
1067
- checks.push({
1175
+ checks2.push({
1068
1176
  name: "Payment readiness",
1069
1177
  status: canRequest === "yes" ? capabilityStatus(canExecute) : "fail",
1070
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."
1071
1179
  });
1072
- return checks;
1180
+ return checks2;
1073
1181
  }
1074
1182
  function legacyChecks(setup, config) {
1075
- const checks = [];
1183
+ const checks2 = [];
1076
1184
  const isSandbox = config.sandboxMode === "test";
1077
- checks.push({
1185
+ checks2.push({
1078
1186
  name: "Agent status",
1079
1187
  status: setup.agent.status === "active" ? "ok" : "fail",
1080
1188
  detail: setup.agent.status === "active" ? "Active" : `${setup.agent.status}. Activate the agent in the dashboard.`
@@ -1082,19 +1190,19 @@ function legacyChecks(setup, config) {
1082
1190
  const scopes = setup.scopes || [];
1083
1191
  const canRequest = scopes.includes("payments:request");
1084
1192
  const canExecute = scopes.includes("payments:execute");
1085
- checks.push({
1193
+ checks2.push({
1086
1194
  name: "Scope payments:request",
1087
1195
  status: canRequest ? "ok" : "fail",
1088
1196
  detail: canRequest ? "Granted" : "Missing. This key cannot request payments."
1089
1197
  });
1090
- checks.push({
1198
+ checks2.push({
1091
1199
  name: "Scope payments:execute",
1092
1200
  status: canExecute ? "ok" : "warn",
1093
1201
  detail: canExecute ? "Granted" : 'Missing. "conto pay" can request but not execute. Create a new standard SDK key.'
1094
1202
  });
1095
1203
  const wallets = setup.wallets || [];
1096
1204
  if (wallets.length === 0) {
1097
- checks.push({
1205
+ checks2.push({
1098
1206
  name: "Wallet",
1099
1207
  status: "fail",
1100
1208
  detail: 'No wallet linked to this agent. Run "npx @conto_finance/create-conto-agent" or link one in the dashboard.'
@@ -1102,24 +1210,24 @@ function legacyChecks(setup, config) {
1102
1210
  }
1103
1211
  for (const w of wallets) {
1104
1212
  const chainLabel = `${w.chainName} (${w.chainId})${w.isTestnet ? " testnet" : ""}`;
1105
- checks.push({
1213
+ checks2.push({
1106
1214
  name: `Wallet ${shortAddress(w.address)}`,
1107
1215
  status: w.status === "active" ? "ok" : "warn",
1108
1216
  detail: `${chainLabel}, ${w.custodyMode} custody, status ${w.status}`
1109
1217
  });
1110
1218
  const paymentMode = isSandbox ? "test" : w.custodyMode === "MANAGED" ? "managed" : "external";
1111
- checks.push({
1219
+ checks2.push({
1112
1220
  name: " Execution",
1113
1221
  status: paymentMode === "managed" || paymentMode === "test" ? "ok" : "warn",
1114
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"
1115
1223
  });
1116
- checks.push({
1224
+ checks2.push({
1117
1225
  name: " Balance",
1118
1226
  status: w.balance > 0 || isSandbox ? "ok" : "warn",
1119
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)" : ""}.`
1120
1228
  });
1121
1229
  if (w.limits?.daily != null) {
1122
- checks.push({
1230
+ checks2.push({
1123
1231
  name: " Daily limit",
1124
1232
  status: "ok",
1125
1233
  detail: `${printAmount(w.spent?.today ?? 0, "USD")} spent of ${printAmount(w.limits.daily, "USD")}`
@@ -1130,12 +1238,12 @@ function legacyChecks(setup, config) {
1130
1238
  (wallet) => wallet.status === "active" && wallet.custodyMode === "MANAGED" && wallet.balance > 0
1131
1239
  );
1132
1240
  const readyForManagedExecution = setup.agent.status === "active" && canRequest && canExecute && (hasManagedWallet || isSandbox && wallets.some((wallet) => wallet.status === "active"));
1133
- checks.push({
1241
+ checks2.push({
1134
1242
  name: "Payment readiness",
1135
1243
  status: readyForManagedExecution ? "ok" : canRequest ? "warn" : "fail",
1136
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"
1137
1245
  });
1138
- return checks;
1246
+ return checks2;
1139
1247
  }
1140
1248
  function shortAddress(address) {
1141
1249
  if (!address || address.length <= 14) return address;
@@ -1255,7 +1363,7 @@ re-run with the printed key: --idempotency-key <key> returns the same request.
1255
1363
 
1256
1364
  Exit codes:
1257
1365
  0 sent, or already handled
1258
- 1 request failed
1366
+ 1 request failed, or denied by policy
1259
1367
  3 an approver rejected the payment
1260
1368
  4 not sent yet: waiting for approval (--no-wait, or the wait timed out),
1261
1369
  or approved and waiting for conto pay execute
@@ -1644,6 +1752,7 @@ async function payCommand(address, amountStr, options) {
1644
1752
  if (request.status === "DENIED") {
1645
1753
  if (isJsonMode()) {
1646
1754
  printJson({ ...request, idempotencyKey });
1755
+ process.exitCode = 1;
1647
1756
  return;
1648
1757
  }
1649
1758
  printError("Payment denied by policy");
@@ -1780,7 +1889,7 @@ async function walletsCommand(subcommand, options = {}) {
1780
1889
  const api = createApiClient({
1781
1890
  baseUrl: config.baseUrl,
1782
1891
  apiKey: config.apiKey,
1783
- orgApiKey: config.orgApiKey
1892
+ orgApiKey: orgApiKeySource(config)
1784
1893
  });
1785
1894
  try {
1786
1895
  await fetchChains(config.baseUrl);
@@ -1813,12 +1922,13 @@ async function walletsCommand(subcommand, options = {}) {
1813
1922
  return;
1814
1923
  }
1815
1924
  if (options.faucet) {
1816
- if (!config.orgApiKey) {
1925
+ if (!hasOrgApiKey(config)) {
1817
1926
  printError(
1818
1927
  'Faucet funding requires an organization key. Run "conto login" or create the project with "npx @conto_finance/create-conto-agent".'
1819
1928
  );
1820
1929
  process.exit(1);
1821
1930
  }
1931
+ await resolveOrgApiKey(config);
1822
1932
  const results = [];
1823
1933
  for (const w of wallets) {
1824
1934
  const chainEntry = getChain(w.chainId);
@@ -2166,6 +2276,22 @@ var ACTIONS = [
2166
2276
  hint: "Payment needs human approval if rule triggers"
2167
2277
  }
2168
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
+ ]);
2169
2295
  async function policiesCommand(subcommand = "list", idOrAmount, extra, reviewOptions = {}) {
2170
2296
  const config = loadConfig();
2171
2297
  if (!config.apiKey) {
@@ -2177,9 +2303,10 @@ async function policiesCommand(subcommand = "list", idOrAmount, extra, reviewOpt
2177
2303
  const api = createOwnerClient({
2178
2304
  baseUrl: config.baseUrl,
2179
2305
  apiKey: config.apiKey,
2180
- orgApiKey: config.orgApiKey
2306
+ orgApiKey: orgApiKeySource(config)
2181
2307
  });
2182
2308
  try {
2309
+ if (ORG_KEY_SUBCOMMANDS.has(subcommand)) await resolveOrgApiKey(config);
2183
2310
  switch (subcommand) {
2184
2311
  case "list":
2185
2312
  return await listAgentPolicies(api);
@@ -2655,7 +2782,7 @@ async function promptForRule(policyType) {
2655
2782
  }
2656
2783
  const action = await p.select({
2657
2784
  message: "Action when rule triggers",
2658
- options: ACTIONS
2785
+ ...actionChoicesFor(ruleType)
2659
2786
  });
2660
2787
  if (p.isCancel(action)) return null;
2661
2788
  return {
@@ -3527,6 +3654,7 @@ async function mcpCommand() {
3527
3654
 
3528
3655
  // src/commands/webhooks.ts
3529
3656
  import { createHmac, randomUUID as randomUUID2 } from "crypto";
3657
+ var sign = (secret, input) => createHmac("sha256", secret).update(input).digest("hex");
3530
3658
  async function testWebhook(url) {
3531
3659
  const started = Date.now();
3532
3660
  try {
@@ -3542,6 +3670,7 @@ async function testWebhook(url) {
3542
3670
  const event = "payment.confirmed";
3543
3671
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
3544
3672
  const paymentId = `test_${randomUUID2()}`;
3673
+ const deliveryId = randomUUID2();
3545
3674
  const body = JSON.stringify({
3546
3675
  event,
3547
3676
  timestamp,
@@ -3553,8 +3682,10 @@ async function testWebhook(url) {
3553
3682
  amount: 0.01,
3554
3683
  currency: "pathUSD",
3555
3684
  status: "CONFIRMED",
3685
+ settlementMode: "test",
3556
3686
  test: true
3557
- }
3687
+ },
3688
+ deliveryId
3558
3689
  });
3559
3690
  const response = await fetch(target, {
3560
3691
  method: "POST",
@@ -3564,8 +3695,10 @@ async function testWebhook(url) {
3564
3695
  "Content-Type": "application/json",
3565
3696
  "X-Conto-Event": event,
3566
3697
  "X-Conto-Timestamp": timestamp,
3698
+ "X-Conto-Delivery-Id": deliveryId,
3567
3699
  "X-Conto-Delivery-Attempt": "1",
3568
- "X-Conto-Signature": createHmac("sha256", secret).update(body).digest("hex")
3700
+ "X-Conto-Signature": sign(secret, body),
3701
+ "X-Conto-Signature-V2": sign(secret, `${timestamp}.${body}`)
3569
3702
  },
3570
3703
  body
3571
3704
  });
@@ -3576,6 +3709,7 @@ async function testWebhook(url) {
3576
3709
  elapsedMs: Date.now() - started,
3577
3710
  event,
3578
3711
  paymentId,
3712
+ deliveryId,
3579
3713
  test: true
3580
3714
  };
3581
3715
  if (isJsonMode()) printJson(result);
@@ -3607,7 +3741,7 @@ var HANDOFF_PATH = "/api/agents/sandbox/handoff";
3607
3741
  var DEFAULT_POLL_INTERVAL_SECONDS = 5;
3608
3742
  var MIN_POLL_INTERVAL_SECONDS = 1;
3609
3743
  var MAX_POLL_INTERVAL_SECONDS = 60;
3610
- var REQUEST_TIMEOUT_MS = 15e3;
3744
+ var REQUEST_TIMEOUT_MS2 = 15e3;
3611
3745
  var SANDBOX_ORG_KEY_PATTERN = /^conto_[a-f0-9]{64}$/;
3612
3746
  var HANDOFF_TOKEN_PATTERN = /^conto_claim_[a-f0-9]{64}$/;
3613
3747
  function isHandoffToken(value) {
@@ -3711,7 +3845,7 @@ async function initiateHandoff(input) {
3711
3845
  url: apiUrl(input.baseUrl, HANDOFF_PATH),
3712
3846
  method: "POST",
3713
3847
  bearer: input.sandboxKey,
3714
- timeoutMs: REQUEST_TIMEOUT_MS,
3848
+ timeoutMs: REQUEST_TIMEOUT_MS2,
3715
3849
  signal: input.signal
3716
3850
  });
3717
3851
  } catch (error) {
@@ -3762,7 +3896,7 @@ async function inspectHandoff(input) {
3762
3896
  url: apiUrl(input.baseUrl, input.statusPath),
3763
3897
  method: "GET",
3764
3898
  bearer: input.token,
3765
- timeoutMs: REQUEST_TIMEOUT_MS,
3899
+ timeoutMs: REQUEST_TIMEOUT_MS2,
3766
3900
  signal: input.signal
3767
3901
  });
3768
3902
  } catch (error) {
@@ -4727,7 +4861,7 @@ alertsGroup.command("resolve <alertId>").description("Resolve an alert").action(
4727
4861
  program.command("config [key] [value]").description("Show or update configuration").action(configCommand);
4728
4862
  program.command("login").description("Authenticate with Conto").option("--base-url <url>", "Conto instance URL").action(loginCommand);
4729
4863
  program.command("logout").description("Clear stored credentials").action(async () => {
4730
- const { clearGlobalConfig } = await import("./config-MACPIPYV.js");
4864
+ const { clearGlobalConfig } = await import("./config-2C6Q4NEJ.js");
4731
4865
  clearGlobalConfig();
4732
4866
  const { printSuccess: printSuccess2 } = await import("./output-GD3QK4HS.js");
4733
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-RQ4PUBL7.js";
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-HGEZBNZB.js";
4
- import "./chunk-RQ4PUBL7.js";
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
- var delegatedCommand = args[0] && CLI_COMMANDS.has(args[0]) || args[0] === "--json" && args[1] !== void 0 && CLI_COMMANDS.has(args[1]);
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 };
@@ -0,0 +1,8 @@
1
+ import {
2
+ CLI_COMMANDS,
3
+ delegatesToCli
4
+ } from "../chunk-D6JPJHU4.js";
5
+ export {
6
+ CLI_COMMANDS,
7
+ delegatesToCli
8
+ };
@@ -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 };
@@ -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-2M2WVAJI.js";
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.8.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",