@conto_finance/create-conto-agent 0.4.2 → 0.4.4

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,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.4
4
+
5
+ - `--sandbox` stores the new sandbox setup key in `.conto/sandbox-setup.env`, an owner-only file
6
+ in an owner-only directory that is added to `.gitignore`. It stays out of `.env.local`, which the
7
+ payment runtime loads. `--json` output reports where the key is stored (`setupKeyStoredIn` and
8
+ `setupKeyEnv`), never the key itself. Servers that do not issue setup keys keep the previous
9
+ output.
10
+
11
+ ## 0.4.3
12
+
13
+ - A confirmed mainnet setup creates the agent in the `PROD` environment. Earlier versions always
14
+ created a `DEV` agent, and Conto denied every payment from its mainnet wallet with "DEV agents
15
+ cannot use mainnet or unclassified wallets". Testnet setups still create a `DEV` agent.
16
+
3
17
  ## 0.4.2
4
18
 
5
19
  - `conto pay --dry-run` no longer calls the payments API. It validates the input locally, prints the
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Set up an AI agent with Conto spending controls. Conto is a buyer-side control layer. Integrate it
4
4
  in the agent owner's runtime or payment tools. The owner or budget holder sets policy before the
5
5
  agent pays.
6
- See [buyer-side control](https://conto.finance/docs/guides/buyer-side-control) for the authorization
6
+ See [buyer-side control](https://conto.finance/docs/introduction/concepts) for the authorization
7
7
  and execution boundary.
8
8
 
9
9
  Node.js 20.19+. Create a temporary simulated sandbox without an account:
@@ -17,12 +17,19 @@ npx @conto_finance/create-conto-agent doctor
17
17
  ```
18
18
 
19
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.
20
+ `.env.local`, adds that file to `.gitignore`, and installs the `conto` command locally. The
21
+ sandbox setup key, which configures the sandbox's policies and spend limits, goes to
22
+ `.conto/sandbox-setup.env` instead, so the agent runtime that loads `.env.local` never holds it.
23
+ See [configure controls](https://conto.finance/docs/quickstart/agent-sandbox#configure-controls).
21
24
 
22
25
  Run the wizard without `--sandbox` to sign in and provision a managed wallet. Choose Tempo
23
26
  Testnet for free faucet tokens and actual onchain test transfers. For headless organization
24
27
  setup, set `CONTO_ORG_API_KEY` or pass `--api-key`.
25
28
 
29
+ A mainnet setup asks you to confirm the network (pass `--confirm-mainnet` when headless) and
30
+ creates the agent in the `PROD` environment, because only `PROD` agents can pay from mainnet
31
+ wallets. Testnet setups create a `DEV` agent.
32
+
26
33
  Inside a CLI-created project, `npx conto <command>` is a shorter form of the same commands. Outside
27
34
  one, bare `npx conto` fetches an unrelated npm package, so use the full package name.
28
35
  `--help`, `--version`, and `--json` work without an interactive terminal.
@@ -112,6 +112,32 @@ function ensureEnvLocalGitignored(dir) {
112
112
  fs.writeFileSync(gitignorePath, `${current}${separator}${comment}.env.local
113
113
  `);
114
114
  }
115
+ var SANDBOX_SETUP_ENV_FILE = path.join(".conto", "sandbox-setup.env");
116
+ function writeSandboxSetupEnv(dir, entries) {
117
+ const setupDir = path.join(dir, ".conto");
118
+ if (!fs.existsSync(setupDir)) {
119
+ fs.mkdirSync(setupDir, { recursive: true, mode: PRIVATE_DIR_MODE });
120
+ }
121
+ fs.chmodSync(setupDir, PRIVATE_DIR_MODE);
122
+ const lines = entries.map(
123
+ (entry) => typeof entry === "string" ? entry : `${entry[0]}=${entry[1]}`
124
+ );
125
+ writePrivateFile(path.join(dir, SANDBOX_SETUP_ENV_FILE), lines.join("\n") + "\n");
126
+ return SANDBOX_SETUP_ENV_FILE;
127
+ }
128
+ function ensureContoDirGitignored(dir) {
129
+ const gitignorePath = path.join(dir, ".gitignore");
130
+ const current = fs.existsSync(gitignorePath) ? fs.readFileSync(gitignorePath, "utf8") : "";
131
+ const alreadyIgnored = current.split(/\r?\n/).map((line) => line.trim()).some((line) => [".conto", ".conto/", "/.conto", "/.conto/"].includes(line));
132
+ if (alreadyIgnored) return;
133
+ const separator = current.length === 0 || current.endsWith("\n") ? "" : "\n";
134
+ fs.writeFileSync(
135
+ gitignorePath,
136
+ `${current}${separator}# Conto sandbox setup credentials
137
+ .conto/
138
+ `
139
+ );
140
+ }
115
141
  function writeContoConfig(dir, config) {
116
142
  fs.writeFileSync(path.join(dir, "conto.config.json"), JSON.stringify(config, null, 2) + "\n");
117
143
  }
@@ -147,6 +173,9 @@ export {
147
173
  loadConfig,
148
174
  writeEnvLocal,
149
175
  ensureEnvLocalGitignored,
176
+ SANDBOX_SETUP_ENV_FILE,
177
+ writeSandboxSetupEnv,
178
+ ensureContoDirGitignored,
150
179
  writeContoConfig,
151
180
  clearGlobalConfig,
152
181
  isSensitiveConfigKey,
@@ -8,16 +8,18 @@ import {
8
8
  printWarning
9
9
  } from "./chunk-K4LBO234.js";
10
10
  import {
11
+ ensureContoDirGitignored,
11
12
  ensureEnvLocalGitignored,
12
13
  saveGlobalConfig,
13
14
  writeContoConfig,
14
- writeEnvLocal
15
- } from "./chunk-2U2MPMMD.js";
15
+ writeEnvLocal,
16
+ writeSandboxSetupEnv
17
+ } from "./chunk-CR3H37ZX.js";
16
18
 
17
19
  // package.json
18
20
  var package_default = {
19
21
  name: "@conto_finance/create-conto-agent",
20
- version: "0.4.2",
22
+ version: "0.4.4",
21
23
  description: "Set up an AI agent with Conto spending controls",
22
24
  bin: {
23
25
  "create-conto-agent": "bin/create-conto-agent.js",
@@ -748,16 +750,18 @@ async function runInit(options = {}) {
748
750
  printInfo(err instanceof Error ? err.message : "Faucet unavailable");
749
751
  }
750
752
  }
753
+ const agentEnvironment = chain.testnet ? "DEV" : "PROD";
751
754
  s.start(`Registering agent "${agentName}"...`);
752
755
  let agent;
753
756
  try {
754
757
  agent = await api.createAgent({
755
758
  name: agentName,
756
759
  agentType,
757
- description: `Created via CLI quickstart`
760
+ description: `Created via CLI quickstart`,
761
+ environment: agentEnvironment
758
762
  });
759
763
  s.stop("Agent registered");
760
- printSuccess(`Agent "${agent.name}" created`);
764
+ printSuccess(`Agent "${agent.name}" created (${agent.environment ?? agentEnvironment})`);
761
765
  } catch (err) {
762
766
  s.stop("Agent creation failed");
763
767
  failInit(err instanceof Error ? err.message : "Failed to create agent");
@@ -1040,6 +1044,17 @@ async function runSandboxInit(options) {
1040
1044
  ["CONTO_SANDBOX_API_KEY", sandbox.credentials.apiKey],
1041
1045
  ["CONTO_SANDBOX_EXPIRES_AT", sandbox.expiresAt]
1042
1046
  ]);
1047
+ const setupKeyFile = sandbox.credentials.setupKey ? (ensureContoDirGitignored(cwd), writeSandboxSetupEnv(cwd, [
1048
+ "# Conto sandbox setup key: configures this sandbox's policies and spend limits.",
1049
+ "# Use it from setup scripts only. Never load it in the payment agent runtime.",
1050
+ "# Claiming the sandbox revokes it.",
1051
+ "",
1052
+ ["CONTO_SANDBOX_SETUP_KEY", sandbox.credentials.setupKey],
1053
+ ["CONTO_BASE_URL", baseUrl],
1054
+ ["CONTO_AGENT_ID", sandbox.agent.id],
1055
+ ["CONTO_WALLET_ID", sandbox.wallet.id],
1056
+ ["CONTO_SANDBOX_EXPIRES_AT", sandbox.expiresAt]
1057
+ ])) : null;
1043
1058
  writeContoConfig(cwd, {
1044
1059
  agent: {
1045
1060
  id: sandbox.agent.id,
@@ -1114,9 +1129,16 @@ async function runSandboxInit(options) {
1114
1129
  credentials: {
1115
1130
  storedIn: ".env.local",
1116
1131
  sdkKeyEnv: "CONTO_API_KEY",
1117
- sandboxApiKeyEnv: "CONTO_SANDBOX_API_KEY"
1132
+ sandboxApiKeyEnv: "CONTO_SANDBOX_API_KEY",
1133
+ ...setupKeyFile ? { setupKeyStoredIn: setupKeyFile, setupKeyEnv: "CONTO_SANDBOX_SETUP_KEY" } : {}
1118
1134
  },
1119
- files: [".env.local", ".gitignore", "conto.config.json", "example.mjs"],
1135
+ files: [
1136
+ ".env.local",
1137
+ ".gitignore",
1138
+ "conto.config.json",
1139
+ "example.mjs",
1140
+ ...setupKeyFile ? [setupKeyFile] : []
1141
+ ],
1120
1142
  claim: sandbox.claim ? {
1121
1143
  method: sandbox.claim.method,
1122
1144
  endpoint: sandbox.claim.endpoint,
@@ -1136,6 +1158,11 @@ async function runSandboxInit(options) {
1136
1158
  console.log(` ${chalk.bold(".env.local")} - SDK key + config (shown once)`);
1137
1159
  console.log(` ${chalk.bold("conto.config.json")} - Agent metadata`);
1138
1160
  console.log(` ${chalk.bold("example.mjs")} - Runnable payment example`);
1161
+ if (setupKeyFile) {
1162
+ console.log(
1163
+ ` ${chalk.bold(setupKeyFile)} - Setup key for policies and limits (keep out of the agent runtime)`
1164
+ );
1165
+ }
1139
1166
  console.log("");
1140
1167
  console.log(
1141
1168
  ` ${chalk.dim("Wallet:")} ${sandbox.wallet.address} (${chain?.name || sandbox.wallet.chainId}, test mode)`
@@ -1144,7 +1171,7 @@ async function runSandboxInit(options) {
1144
1171
  ` ${chalk.dim("Balance:")} ${sandbox.wallet.balance} ${sandbox.wallet.currency} (test balance)`
1145
1172
  );
1146
1173
  console.log(
1147
- ` ${chalk.dim("Limits:")} $${sandbox.wallet.limits.perTransaction}/tx, $${sandbox.wallet.limits.daily}/day`
1174
+ ` ${chalk.dim("Limits:")} $${sandbox.wallet.limits.perTransaction}/tx, $${sandbox.wallet.limits.daily}/day${setupKeyFile ? " (editable with the setup key)" : ""}`
1148
1175
  );
1149
1176
  console.log(` ${chalk.dim("Expires:")} ${sandbox.expiresAt}`);
1150
1177
  console.log("");
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  fetchChains,
6
6
  getChain,
7
7
  runInit
8
- } from "./chunk-5OT7YKV4.js";
8
+ } from "./chunk-ETJJHYIL.js";
9
9
  import {
10
10
  VELOCITY_PERIODS,
11
11
  buildVelocityCountValue,
@@ -34,7 +34,7 @@ import {
34
34
  maskSecret,
35
35
  missingSdkKeyMessage,
36
36
  saveGlobalConfig
37
- } from "./chunk-2U2MPMMD.js";
37
+ } from "./chunk-CR3H37ZX.js";
38
38
 
39
39
  // src/cli.ts
40
40
  import { Command } from "commander";
@@ -1770,7 +1770,7 @@ program.command("alerts").description("List alerts").option("--active", "Show on
1770
1770
  program.command("config [key] [value]").description("Show or update configuration").action(configCommand);
1771
1771
  program.command("login").description("Authenticate with Conto").option("--base-url <url>", "Conto instance URL").action(loginCommand);
1772
1772
  program.command("logout").description("Clear stored credentials").action(async () => {
1773
- const { clearGlobalConfig } = await import("./config-LEPHM5HT.js");
1773
+ const { clearGlobalConfig } = await import("./config-YV6X7VKJ.js");
1774
1774
  clearGlobalConfig();
1775
1775
  const { printSuccess: printSuccess2 } = await import("./output-IN47X4NU.js");
1776
1776
  printSuccess2("Logged out. Credentials cleared.");
@@ -1,5 +1,7 @@
1
1
  import {
2
+ SANDBOX_SETUP_ENV_FILE,
2
3
  clearGlobalConfig,
4
+ ensureContoDirGitignored,
3
5
  ensureEnvLocalGitignored,
4
6
  isSensitiveConfigKey,
5
7
  loadConfig,
@@ -10,10 +12,13 @@ import {
10
12
  missingSdkKeyMessage,
11
13
  saveGlobalConfig,
12
14
  writeContoConfig,
13
- writeEnvLocal
14
- } from "./chunk-2U2MPMMD.js";
15
+ writeEnvLocal,
16
+ writeSandboxSetupEnv
17
+ } from "./chunk-CR3H37ZX.js";
15
18
  export {
19
+ SANDBOX_SETUP_ENV_FILE,
16
20
  clearGlobalConfig,
21
+ ensureContoDirGitignored,
17
22
  ensureEnvLocalGitignored,
18
23
  isSensitiveConfigKey,
19
24
  loadConfig,
@@ -24,5 +29,6 @@ export {
24
29
  missingSdkKeyMessage,
25
30
  saveGlobalConfig,
26
31
  writeContoConfig,
27
- writeEnvLocal
32
+ writeEnvLocal,
33
+ writeSandboxSetupEnv
28
34
  };
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  runInit
3
- } from "./chunk-5OT7YKV4.js";
3
+ } from "./chunk-ETJJHYIL.js";
4
4
  import {
5
5
  isJsonMode,
6
6
  printJson,
7
7
  setJsonMode
8
8
  } from "./chunk-K4LBO234.js";
9
- import "./chunk-2U2MPMMD.js";
9
+ import "./chunk-CR3H37ZX.js";
10
10
 
11
11
  // src/index.ts
12
12
  var CLI_COMMANDS = /* @__PURE__ */ new Set([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conto_finance/create-conto-agent",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
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",