@conto_finance/create-conto-agent 0.3.1 → 0.4.3
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 +35 -0
- package/README.md +51 -0
- package/dist/chunk-2U2MPMMD.js +155 -0
- package/dist/{chunk-QN5FG53Q.js → chunk-CMPYURB7.js} +294 -183
- package/dist/chunk-TJJY5NFH.js +76 -0
- package/dist/cli.js +317 -86
- package/dist/{config-RZBPNEBZ.js → config-LEPHM5HT.js} +3 -1
- package/dist/index.js +18 -7
- package/dist/lib/rule-values.d.ts +52 -0
- package/dist/lib/rule-values.js +12 -0
- package/package.json +17 -9
- package/dist/chunk-WMVGNUSL.js +0 -127
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.4.3
|
|
4
|
+
|
|
5
|
+
- A confirmed mainnet setup creates the agent in the `PROD` environment. Earlier versions always
|
|
6
|
+
created a `DEV` agent, and Conto denied every payment from its mainnet wallet with "DEV agents
|
|
7
|
+
cannot use mainnet or unclassified wallets". Testnet setups still create a `DEV` agent.
|
|
8
|
+
|
|
9
|
+
## 0.4.2
|
|
10
|
+
|
|
11
|
+
- `conto pay --dry-run` no longer calls the payments API. It validates the input locally, prints the
|
|
12
|
+
request it would send, and states that no policy evaluation was performed. Earlier versions created
|
|
13
|
+
a real payment request, which could open an approval.
|
|
14
|
+
- Trust score rules take a value from 0.0 to 1.0, matching how Conto stores counterparty trust
|
|
15
|
+
scores. Values from 1 to 100 are rejected with a message instead of creating a rule that never
|
|
16
|
+
passes.
|
|
17
|
+
- Velocity rules ask for a time window and a transaction count and save
|
|
18
|
+
`{"maxCount": n, "period": ...}`. Earlier versions saved a bare number, which Conto reads as a
|
|
19
|
+
dollar amount per hour.
|
|
20
|
+
- `conto pay` checks the amount and recipient format before sending.
|
|
21
|
+
- Setup hints, the generated `example.mjs`, and `.env.local` use
|
|
22
|
+
`npx @conto_finance/create-conto-agent`. Bare `npx create-conto-agent` is not on npm, and bare
|
|
23
|
+
`npx conto` fetches an unrelated package unless the CLI is installed in the project.
|
|
24
|
+
- Package description, homepage, and README updated. 0.4.1 never reached npm, so 0.4.2 also includes
|
|
25
|
+
its changes.
|
|
26
|
+
|
|
27
|
+
## 0.4.1
|
|
28
|
+
|
|
29
|
+
- Publish through GitHub Actions trusted publishing, replacing the token authentication used by the unsuccessful 0.4.0 release.
|
|
30
|
+
- Bind authenticated requests to an origin from the credential's configuration source. Custom
|
|
31
|
+
project origins must now be supplied explicitly with `CONTO_BASE_URL` or saved with `conto login`.
|
|
32
|
+
|
|
33
|
+
## 0.4.0
|
|
34
|
+
|
|
35
|
+
- Ship the Conto CLI quickstart, account diagnostics, payment commands, and MCP handoff.
|
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Conto CLI
|
|
2
|
+
|
|
3
|
+
Set up an AI agent with Conto spending controls. Conto is a buyer-side control layer. Integrate it
|
|
4
|
+
in the agent owner's runtime or payment tools. The owner or budget holder sets policy before the
|
|
5
|
+
agent pays.
|
|
6
|
+
See [buyer-side control](https://conto.finance/docs/introduction/concepts) for the authorization
|
|
7
|
+
and execution boundary.
|
|
8
|
+
|
|
9
|
+
Node.js 20.19+. Create a temporary simulated sandbox without an account:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
mkdir conto-first-payment
|
|
13
|
+
cd conto-first-payment
|
|
14
|
+
npx @conto_finance/create-conto-agent --sandbox --json
|
|
15
|
+
node example.mjs --execute
|
|
16
|
+
npx @conto_finance/create-conto-agent doctor
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Success is `Status: completed` and `Settlement mode: test`. The CLI stores credentials in
|
|
20
|
+
`.env.local`, adds that file to `.gitignore`, and installs the `conto` command locally.
|
|
21
|
+
|
|
22
|
+
Run the wizard without `--sandbox` to sign in and provision a managed wallet. Choose Tempo
|
|
23
|
+
Testnet for free faucet tokens and actual onchain test transfers. For headless organization
|
|
24
|
+
setup, set `CONTO_ORG_API_KEY` or pass `--api-key`.
|
|
25
|
+
|
|
26
|
+
A mainnet setup asks you to confirm the network (pass `--confirm-mainnet` when headless) and
|
|
27
|
+
creates the agent in the `PROD` environment, because only `PROD` agents can pay from mainnet
|
|
28
|
+
wallets. Testnet setups create a `DEV` agent.
|
|
29
|
+
|
|
30
|
+
Inside a CLI-created project, `npx conto <command>` is a shorter form of the same commands. Outside
|
|
31
|
+
one, bare `npx conto` fetches an unrelated npm package, so use the full package name.
|
|
32
|
+
`--help`, `--version`, and `--json` work without an interactive terminal.
|
|
33
|
+
|
|
34
|
+
Test a local webhook handler with the same development secret configured in that handler:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
export CONTO_WEBHOOK_SECRET="your-local-development-secret"
|
|
38
|
+
npx @conto_finance/create-conto-agent webhooks test http://localhost:8080/webhooks/conto --json
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This sends one synthetic signed event to a loopback address. It creates no payment and requires no API key.
|
|
42
|
+
|
|
43
|
+
`npx @conto_finance/create-conto-agent pay <address> <amount> --dry-run` validates the payment
|
|
44
|
+
locally and prints the request it would send. It contacts nothing and does not evaluate policy. Use
|
|
45
|
+
`npx @conto_finance/create-conto-agent limits` to see current limits.
|
|
46
|
+
|
|
47
|
+
- [CLI quickstart](https://conto.finance/docs/cli/quickstart)
|
|
48
|
+
- [First payment](https://conto.finance/docs/quickstart/setup)
|
|
49
|
+
- [Commands](https://conto.finance/docs/cli/commands)
|
|
50
|
+
- [Recovery](https://conto.finance/docs/guides/payment-lifecycle)
|
|
51
|
+
- [Developer support](mailto:support@conto.finance)
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
var DEFAULT_VISIBLE_SECRET_CHARS = 10;
|
|
10
|
+
var DEFAULT_BASE_URL = "https://conto.finance";
|
|
11
|
+
var SENSITIVE_CONFIG_KEY_PATTERN = /(^|\.)(apiKey|orgApiKey)$/i;
|
|
12
|
+
function ensureContoDir() {
|
|
13
|
+
if (!fs.existsSync(CONTO_DIR)) {
|
|
14
|
+
fs.mkdirSync(CONTO_DIR, { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
15
|
+
}
|
|
16
|
+
fs.chmodSync(CONTO_DIR, PRIVATE_DIR_MODE);
|
|
17
|
+
}
|
|
18
|
+
function writePrivateFile(filePath, content) {
|
|
19
|
+
fs.writeFileSync(filePath, content, { mode: PRIVATE_FILE_MODE });
|
|
20
|
+
fs.chmodSync(filePath, PRIVATE_FILE_MODE);
|
|
21
|
+
}
|
|
22
|
+
function loadGlobalConfig() {
|
|
23
|
+
try {
|
|
24
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
25
|
+
const raw = fs.readFileSync(CONFIG_FILE, "utf-8");
|
|
26
|
+
return JSON.parse(raw);
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
function saveGlobalConfig(config) {
|
|
33
|
+
ensureContoDir();
|
|
34
|
+
writePrivateFile(CONFIG_FILE, JSON.stringify(config, null, 2) + "\n");
|
|
35
|
+
}
|
|
36
|
+
function loadProjectEnv(dir) {
|
|
37
|
+
const envPath = path.join(dir || process.cwd(), ".env.local");
|
|
38
|
+
if (fs.existsSync(envPath)) {
|
|
39
|
+
const content = fs.readFileSync(envPath, "utf-8");
|
|
40
|
+
const result = {};
|
|
41
|
+
for (const line of content.split("\n")) {
|
|
42
|
+
const match = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);
|
|
43
|
+
if (match) result[match[1]] = match[2];
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
function loadProjectConfig(dir) {
|
|
50
|
+
const configPath = path.join(dir || process.cwd(), "conto.config.json");
|
|
51
|
+
try {
|
|
52
|
+
if (fs.existsSync(configPath)) {
|
|
53
|
+
const raw = fs.readFileSync(configPath, "utf-8");
|
|
54
|
+
return JSON.parse(raw);
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
function loadConfig() {
|
|
61
|
+
const global = loadGlobalConfig();
|
|
62
|
+
const project = loadProjectConfig();
|
|
63
|
+
const env = loadProjectEnv();
|
|
64
|
+
const chainId = process.env.CONTO_CHAIN_ID || env.CONTO_CHAIN_ID || project.network?.chainId || global.network?.chainId;
|
|
65
|
+
const matchingNetwork = project.network?.chainId === chainId ? project.network : global.network?.chainId === chainId ? global.network : void 0;
|
|
66
|
+
const explicitTestnet = process.env.CONTO_TESTNET || env.CONTO_TESTNET;
|
|
67
|
+
const hasProcessCredential = Boolean(process.env.CONTO_API_KEY || process.env.CONTO_ORG_API_KEY);
|
|
68
|
+
const hasProjectCredential = !hasProcessCredential && Boolean(env.CONTO_API_KEY || env.CONTO_ORG_API_KEY);
|
|
69
|
+
const hasGlobalCredential = !hasProcessCredential && !hasProjectCredential && Boolean(global.server?.apiKey || global.server?.orgApiKey);
|
|
70
|
+
const apiKey = hasProcessCredential ? process.env.CONTO_API_KEY : hasProjectCredential ? env.CONTO_API_KEY : global.server?.apiKey;
|
|
71
|
+
const orgApiKey = hasProcessCredential ? process.env.CONTO_ORG_API_KEY : hasProjectCredential ? env.CONTO_ORG_API_KEY : global.server?.orgApiKey;
|
|
72
|
+
const baseUrl = 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);
|
|
73
|
+
return {
|
|
74
|
+
// Secrets never come from conto.config.json: it is written world-readable
|
|
75
|
+
// (0644) and is not gitignored. Read the API key only from the environment,
|
|
76
|
+
// the gitignored .env.local, or the private global store (~/.conto, 0600).
|
|
77
|
+
apiKey,
|
|
78
|
+
baseUrl,
|
|
79
|
+
agentId: process.env.CONTO_AGENT_ID || env.CONTO_AGENT_ID || project.agent?.id || global.agent?.id,
|
|
80
|
+
chainId,
|
|
81
|
+
chainName: process.env.CONTO_CHAIN_NAME || env.CONTO_CHAIN_NAME || project.network?.chain || global.network?.chain,
|
|
82
|
+
currency: process.env.CONTO_CURRENCY || env.CONTO_CURRENCY || project.network?.currency || global.network?.currency,
|
|
83
|
+
explorerUrl: process.env.CONTO_EXPLORER_URL || env.CONTO_EXPLORER_URL || project.network?.explorerUrl || global.network?.explorerUrl,
|
|
84
|
+
walletId: process.env.CONTO_WALLET_ID || env.CONTO_WALLET_ID || project.wallet?.id || global.wallet?.id,
|
|
85
|
+
walletAddress: process.env.CONTO_WALLET_ADDRESS || env.CONTO_WALLET_ADDRESS || project.wallet?.address || global.wallet?.address,
|
|
86
|
+
// Same as apiKey: the org key is a secret and must not be read from the
|
|
87
|
+
// world-readable conto.config.json. Env, .env.local, or the global store only.
|
|
88
|
+
orgApiKey,
|
|
89
|
+
orgApiKeyExpiresAt: (hasProcessCredential ? process.env.CONTO_ORG_API_KEY_EXPIRES_AT : hasProjectCredential ? env.CONTO_ORG_API_KEY_EXPIRES_AT : global.server?.orgApiKeyExpiresAt) || void 0,
|
|
90
|
+
sandboxMode: process.env.CONTO_SANDBOX_MODE || env.CONTO_SANDBOX_MODE || project.sandbox?.mode,
|
|
91
|
+
// Sandbox metadata is project-scoped and ephemeral. Do not let a prior
|
|
92
|
+
// sandbox stored in ~/.conto/config.json bleed into unrelated agents.
|
|
93
|
+
sandboxExecution: process.env.CONTO_SANDBOX_EXECUTION || env.CONTO_SANDBOX_EXECUTION || project.sandbox?.execution,
|
|
94
|
+
sandboxExpiresAt: process.env.CONTO_SANDBOX_EXPIRES_AT || env.CONTO_SANDBOX_EXPIRES_AT || project.sandbox?.expiresAt,
|
|
95
|
+
testnet: explicitTestnet === "true" ? true : explicitTestnet === "false" ? false : matchingNetwork?.testnet ?? chainId === "42431"
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function writeEnvLocal(dir, entries) {
|
|
99
|
+
const lines = entries.map(
|
|
100
|
+
(entry) => typeof entry === "string" ? entry : `${entry[0]}=${entry[1]}`
|
|
101
|
+
);
|
|
102
|
+
const content = lines.join("\n") + "\n";
|
|
103
|
+
writePrivateFile(path.join(dir, ".env.local"), content);
|
|
104
|
+
}
|
|
105
|
+
function ensureEnvLocalGitignored(dir) {
|
|
106
|
+
const gitignorePath = path.join(dir, ".gitignore");
|
|
107
|
+
const current = fs.existsSync(gitignorePath) ? fs.readFileSync(gitignorePath, "utf8") : "";
|
|
108
|
+
const alreadyIgnored = current.split(/\r?\n/).map((line) => line.trim()).some((line) => line === ".env.local" || line === "/.env.local");
|
|
109
|
+
if (alreadyIgnored) return;
|
|
110
|
+
const separator = current.length === 0 || current.endsWith("\n") ? "" : "\n";
|
|
111
|
+
const comment = current.length === 0 ? "# Conto local credentials\n" : "\n# Conto local credentials\n";
|
|
112
|
+
fs.writeFileSync(gitignorePath, `${current}${separator}${comment}.env.local
|
|
113
|
+
`);
|
|
114
|
+
}
|
|
115
|
+
function writeContoConfig(dir, config) {
|
|
116
|
+
fs.writeFileSync(path.join(dir, "conto.config.json"), JSON.stringify(config, null, 2) + "\n");
|
|
117
|
+
}
|
|
118
|
+
function clearGlobalConfig() {
|
|
119
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
120
|
+
fs.unlinkSync(CONFIG_FILE);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function isSensitiveConfigKey(key) {
|
|
124
|
+
return SENSITIVE_CONFIG_KEY_PATTERN.test(key);
|
|
125
|
+
}
|
|
126
|
+
function maskSecret(value, visibleChars = DEFAULT_VISIBLE_SECRET_CHARS) {
|
|
127
|
+
if (!value) return "";
|
|
128
|
+
const prefixLength = Math.max(1, Math.min(visibleChars, value.length));
|
|
129
|
+
return `${value.slice(0, prefixLength)}...`;
|
|
130
|
+
}
|
|
131
|
+
function missingSdkKeyMessage(config) {
|
|
132
|
+
if (config.orgApiKey) {
|
|
133
|
+
return [
|
|
134
|
+
"Logged in with an organization key, but no agent SDK key is configured.",
|
|
135
|
+
'Run "npx @conto_finance/create-conto-agent --api-key <org-api-key>" to create an agent,',
|
|
136
|
+
"or set CONTO_API_KEY to an existing conto_agent_ key."
|
|
137
|
+
].join(" ");
|
|
138
|
+
}
|
|
139
|
+
return 'Not configured. Run "npx @conto_finance/create-conto-agent" first, or set CONTO_API_KEY.';
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export {
|
|
143
|
+
loadGlobalConfig,
|
|
144
|
+
saveGlobalConfig,
|
|
145
|
+
loadProjectEnv,
|
|
146
|
+
loadProjectConfig,
|
|
147
|
+
loadConfig,
|
|
148
|
+
writeEnvLocal,
|
|
149
|
+
ensureEnvLocalGitignored,
|
|
150
|
+
writeContoConfig,
|
|
151
|
+
clearGlobalConfig,
|
|
152
|
+
isSensitiveConfigKey,
|
|
153
|
+
maskSecret,
|
|
154
|
+
missingSdkKeyMessage
|
|
155
|
+
};
|