@conto_finance/create-conto-agent 0.3.0 → 0.4.2

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.
@@ -1,17 +1,27 @@
1
1
  import {
2
2
  clearGlobalConfig,
3
+ ensureEnvLocalGitignored,
4
+ isSensitiveConfigKey,
3
5
  loadConfig,
4
6
  loadGlobalConfig,
7
+ loadProjectConfig,
5
8
  loadProjectEnv,
9
+ maskSecret,
10
+ missingSdkKeyMessage,
6
11
  saveGlobalConfig,
7
12
  writeContoConfig,
8
13
  writeEnvLocal
9
- } from "./chunk-OS5PZNRM.js";
14
+ } from "./chunk-2U2MPMMD.js";
10
15
  export {
11
16
  clearGlobalConfig,
17
+ ensureEnvLocalGitignored,
18
+ isSensitiveConfigKey,
12
19
  loadConfig,
13
20
  loadGlobalConfig,
21
+ loadProjectConfig,
14
22
  loadProjectEnv,
23
+ maskSecret,
24
+ missingSdkKeyMessage,
15
25
  saveGlobalConfig,
16
26
  writeContoConfig,
17
27
  writeEnvLocal
package/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  runInit
3
- } from "./chunk-ICDSTI2Z.js";
3
+ } from "./chunk-5OT7YKV4.js";
4
4
  import {
5
+ isJsonMode,
6
+ printJson,
5
7
  setJsonMode
6
8
  } from "./chunk-K4LBO234.js";
7
- import "./chunk-OS5PZNRM.js";
9
+ import "./chunk-2U2MPMMD.js";
8
10
 
9
11
  // src/index.ts
10
12
  var CLI_COMMANDS = /* @__PURE__ */ new Set([
@@ -14,6 +16,7 @@ var CLI_COMMANDS = /* @__PURE__ */ new Set([
14
16
  "pay",
15
17
  "transactions",
16
18
  "wallets",
19
+ "webhooks",
17
20
  "fund",
18
21
  "policies",
19
22
  "limits",
@@ -31,7 +34,8 @@ var CLI_COMMANDS = /* @__PURE__ */ new Set([
31
34
  "-V"
32
35
  ]);
33
36
  var args = process.argv.slice(2);
34
- if (args.length > 0 && CLI_COMMANDS.has(args[0])) {
37
+ var delegatedCommand = args[0] && CLI_COMMANDS.has(args[0]) || args[0] === "--json" && args[1] !== void 0 && CLI_COMMANDS.has(args[1]);
38
+ if (delegatedCommand) {
35
39
  await import("./cli.js");
36
40
  } else {
37
41
  const options = {};
@@ -57,13 +61,17 @@ if (args.length > 0 && CLI_COMMANDS.has(args[0])) {
57
61
  options.json = true;
58
62
  } else if (arg === "--no-install") {
59
63
  options.noInstall = true;
64
+ } else if (arg === "--confirm-mainnet") {
65
+ options.confirmMainnet = true;
60
66
  }
61
67
  }
62
68
  if (options.json) {
63
69
  setJsonMode(true);
64
70
  }
65
- if (options.noBrowser && !options.sandbox && !options.apiKey) {
66
- console.error("--no-browser requires either --sandbox or --api-key <org-api-key>.");
71
+ if (options.noBrowser && !options.sandbox && !options.apiKey && !process.env.CONTO_ORG_API_KEY) {
72
+ const error = "--no-browser requires --sandbox, --api-key <org-api-key>, or CONTO_ORG_API_KEY.";
73
+ if (isJsonMode()) printJson({ ok: false, error });
74
+ else console.error(error);
67
75
  process.exit(1);
68
76
  }
69
77
  runInit({
@@ -74,9 +82,12 @@ if (args.length > 0 && CLI_COMMANDS.has(args[0])) {
74
82
  baseUrl: options.baseUrl,
75
83
  install: options.noInstall ? false : void 0,
76
84
  sandbox: options.sandbox === true,
77
- apiKey: options.apiKey
85
+ apiKey: options.apiKey,
86
+ confirmMainnet: options.confirmMainnet === true
78
87
  }).catch((err) => {
79
- console.error("Fatal error:", err.message || err);
88
+ const error = err instanceof Error ? err.message : String(err);
89
+ if (isJsonMode()) printJson({ ok: false, error });
90
+ else console.error("Fatal error:", error);
80
91
  process.exit(1);
81
92
  });
82
93
  }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Pure helpers that turn prompt input into policy rule values the server
3
+ * evaluates correctly. Kept free of prompts and I/O so tests can call them.
4
+ */
5
+ type ValidationResult = {
6
+ ok: true;
7
+ value: string;
8
+ } | {
9
+ ok: false;
10
+ error: string;
11
+ };
12
+ /**
13
+ * TRUST_SCORE rules compare against counterparty trust scores stored on a
14
+ * 0.0 to 1.0 scale. A value such as 50 would never pass, so reject it with a
15
+ * message instead of converting it silently.
16
+ */
17
+ declare function parseTrustScoreInput(input: string): ValidationResult;
18
+ declare const VELOCITY_PERIODS: readonly ["HOUR", "DAY", "WEEK", "MONTH"];
19
+ type VelocityPeriod = (typeof VELOCITY_PERIODS)[number];
20
+ /**
21
+ * VELOCITY_LIMIT rules with a bare number are read by the server as an hourly
22
+ * dollar cap. A transaction-count limit must be sent as
23
+ * {"maxCount": n, "period": "HOUR" | "DAY" | "WEEK" | "MONTH"}.
24
+ */
25
+ declare function buildVelocityCountValue(input: string, period: string): ValidationResult;
26
+ interface PaymentRequestBody {
27
+ amount: number;
28
+ recipientAddress: string;
29
+ purpose?: string;
30
+ category?: string;
31
+ walletId?: string;
32
+ }
33
+ type PaymentValidation = {
34
+ ok: true;
35
+ body: PaymentRequestBody;
36
+ } | {
37
+ ok: false;
38
+ errors: string[];
39
+ };
40
+ /**
41
+ * Mirrors the request schema of POST /api/sdk/payments/request so a dry run
42
+ * catches the same input errors without contacting the server.
43
+ */
44
+ declare function validatePaymentRequest(input: {
45
+ address: string;
46
+ amount: string;
47
+ purpose?: string;
48
+ category?: string;
49
+ walletId?: string;
50
+ }): PaymentValidation;
51
+
52
+ export { type PaymentRequestBody, type PaymentValidation, VELOCITY_PERIODS, type ValidationResult, type VelocityPeriod, buildVelocityCountValue, parseTrustScoreInput, validatePaymentRequest };
@@ -0,0 +1,12 @@
1
+ import {
2
+ VELOCITY_PERIODS,
3
+ buildVelocityCountValue,
4
+ parseTrustScoreInput,
5
+ validatePaymentRequest
6
+ } from "../chunk-TJJY5NFH.js";
7
+ export {
8
+ VELOCITY_PERIODS,
9
+ buildVelocityCountValue,
10
+ parseTrustScoreInput,
11
+ validatePaymentRequest
12
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@conto_finance/create-conto-agent",
3
- "version": "0.3.0",
4
- "description": "CLI quickstart for Conto — Agentic Payments Control Center",
3
+ "version": "0.4.2",
4
+ "description": "Set up an AI agent with Conto spending controls",
5
5
  "bin": {
6
6
  "create-conto-agent": "bin/create-conto-agent.js",
7
7
  "conto": "bin/conto.js"
@@ -10,16 +10,24 @@
10
10
  "type": "module",
11
11
  "files": [
12
12
  "dist",
13
- "bin"
13
+ "bin",
14
+ "README.md",
15
+ "CHANGELOG.md"
14
16
  ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
15
20
  "scripts": {
16
- "build": "tsup src/index.ts src/cli.ts --format esm --dts --clean",
17
- "dev": "tsup src/index.ts src/cli.ts --format esm --dts --watch",
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",
18
23
  "lint": "tsc --noEmit",
19
- "test": "npm run build && node --test test/*.test.mjs"
24
+ "test": "npm run lint && npm run test:contract",
25
+ "test:contract": "npm run build && node --test test/*.test.mjs",
26
+ "verify:release": "node scripts/verify-release.mjs",
27
+ "prepublishOnly": "npm run verify:release && npm test"
20
28
  },
21
29
  "engines": {
22
- "node": ">=18"
30
+ "node": ">=20.19.0"
23
31
  },
24
32
  "keywords": [
25
33
  "conto",
@@ -35,12 +43,12 @@
35
43
  "license": "MIT",
36
44
  "repository": {
37
45
  "type": "git",
38
- "url": "https://github.com/kwattana/conto.git",
46
+ "url": "https://github.com/conto-finance/conto.git",
39
47
  "directory": "packages/cli"
40
48
  },
41
- "homepage": "https://conto.finance",
49
+ "homepage": "https://conto.finance/docs/cli/quickstart",
42
50
  "bugs": {
43
- "url": "https://github.com/kwattana/conto/issues"
51
+ "email": "support@conto.finance"
44
52
  },
45
53
  "dependencies": {
46
54
  "@clack/prompts": "^0.9.1",
@@ -53,7 +61,7 @@
53
61
  "esbuild": "0.28.1"
54
62
  },
55
63
  "devDependencies": {
56
- "@types/node": "^22.19.18",
64
+ "@types/node": "22.19.18",
57
65
  "tsup": "^8.5.1",
58
66
  "typescript": "^5.9.3"
59
67
  }
@@ -1,87 +0,0 @@
1
- // src/lib/config.ts
2
- import fs from "fs";
3
- import path from "path";
4
- import os from "os";
5
- var CONTO_DIR = path.join(os.homedir(), ".conto");
6
- var CONFIG_FILE = path.join(CONTO_DIR, "config.json");
7
- var PRIVATE_DIR_MODE = 448;
8
- var PRIVATE_FILE_MODE = 384;
9
- function ensureContoDir() {
10
- if (!fs.existsSync(CONTO_DIR)) {
11
- fs.mkdirSync(CONTO_DIR, { recursive: true, mode: PRIVATE_DIR_MODE });
12
- }
13
- fs.chmodSync(CONTO_DIR, PRIVATE_DIR_MODE);
14
- }
15
- function writePrivateFile(filePath, content) {
16
- fs.writeFileSync(filePath, content, { mode: PRIVATE_FILE_MODE });
17
- fs.chmodSync(filePath, PRIVATE_FILE_MODE);
18
- }
19
- function loadGlobalConfig() {
20
- try {
21
- if (fs.existsSync(CONFIG_FILE)) {
22
- const raw = fs.readFileSync(CONFIG_FILE, "utf-8");
23
- return JSON.parse(raw);
24
- }
25
- } catch {
26
- }
27
- return {};
28
- }
29
- function saveGlobalConfig(config) {
30
- ensureContoDir();
31
- writePrivateFile(CONFIG_FILE, JSON.stringify(config, null, 2) + "\n");
32
- }
33
- function loadProjectEnv(dir) {
34
- const envPath = path.join(dir || process.cwd(), ".env.local");
35
- if (fs.existsSync(envPath)) {
36
- const content = fs.readFileSync(envPath, "utf-8");
37
- const result = {};
38
- for (const line of content.split("\n")) {
39
- const match = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);
40
- if (match) result[match[1]] = match[2];
41
- }
42
- return result;
43
- }
44
- return {};
45
- }
46
- function loadConfig() {
47
- const global = loadGlobalConfig();
48
- const env = loadProjectEnv();
49
- return {
50
- apiKey: env.CONTO_API_KEY || global.server?.apiKey,
51
- baseUrl: env.CONTO_BASE_URL || global.server?.baseUrl || "https://conto.finance",
52
- agentId: env.CONTO_AGENT_ID || global.agent?.id,
53
- chainId: env.CONTO_CHAIN_ID || global.network?.chainId,
54
- chainName: env.CONTO_CHAIN_NAME || global.network?.chain,
55
- currency: env.CONTO_CURRENCY || global.network?.currency,
56
- explorerUrl: env.CONTO_EXPLORER_URL || global.network?.explorerUrl,
57
- walletId: env.CONTO_WALLET_ID || global.wallet?.id,
58
- walletAddress: env.CONTO_WALLET_ADDRESS || global.wallet?.address,
59
- orgApiKey: global.server?.orgApiKey,
60
- testnet: global.network?.testnet || env.CONTO_CHAIN_ID === "42431"
61
- };
62
- }
63
- function writeEnvLocal(dir, entries) {
64
- const lines = entries.map(
65
- (entry) => typeof entry === "string" ? entry : `${entry[0]}=${entry[1]}`
66
- );
67
- const content = lines.join("\n") + "\n";
68
- writePrivateFile(path.join(dir, ".env.local"), content);
69
- }
70
- function writeContoConfig(dir, config) {
71
- fs.writeFileSync(path.join(dir, "conto.config.json"), JSON.stringify(config, null, 2) + "\n");
72
- }
73
- function clearGlobalConfig() {
74
- if (fs.existsSync(CONFIG_FILE)) {
75
- fs.unlinkSync(CONFIG_FILE);
76
- }
77
- }
78
-
79
- export {
80
- loadGlobalConfig,
81
- saveGlobalConfig,
82
- loadProjectEnv,
83
- loadConfig,
84
- writeEnvLocal,
85
- writeContoConfig,
86
- clearGlobalConfig
87
- };