@conto_finance/create-conto-agent 0.4.3 → 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,13 @@
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
+
3
11
  ## 0.4.3
4
12
 
5
13
  - A confirmed mainnet setup creates the agent in the `PROD` environment. Earlier versions always
package/README.md CHANGED
@@ -17,7 +17,10 @@ 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
@@ -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.3",
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",
@@ -1042,6 +1044,17 @@ async function runSandboxInit(options) {
1042
1044
  ["CONTO_SANDBOX_API_KEY", sandbox.credentials.apiKey],
1043
1045
  ["CONTO_SANDBOX_EXPIRES_AT", sandbox.expiresAt]
1044
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;
1045
1058
  writeContoConfig(cwd, {
1046
1059
  agent: {
1047
1060
  id: sandbox.agent.id,
@@ -1116,9 +1129,16 @@ async function runSandboxInit(options) {
1116
1129
  credentials: {
1117
1130
  storedIn: ".env.local",
1118
1131
  sdkKeyEnv: "CONTO_API_KEY",
1119
- sandboxApiKeyEnv: "CONTO_SANDBOX_API_KEY"
1132
+ sandboxApiKeyEnv: "CONTO_SANDBOX_API_KEY",
1133
+ ...setupKeyFile ? { setupKeyStoredIn: setupKeyFile, setupKeyEnv: "CONTO_SANDBOX_SETUP_KEY" } : {}
1120
1134
  },
1121
- 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
+ ],
1122
1142
  claim: sandbox.claim ? {
1123
1143
  method: sandbox.claim.method,
1124
1144
  endpoint: sandbox.claim.endpoint,
@@ -1138,6 +1158,11 @@ async function runSandboxInit(options) {
1138
1158
  console.log(` ${chalk.bold(".env.local")} - SDK key + config (shown once)`);
1139
1159
  console.log(` ${chalk.bold("conto.config.json")} - Agent metadata`);
1140
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
+ }
1141
1166
  console.log("");
1142
1167
  console.log(
1143
1168
  ` ${chalk.dim("Wallet:")} ${sandbox.wallet.address} (${chain?.name || sandbox.wallet.chainId}, test mode)`
@@ -1146,7 +1171,7 @@ async function runSandboxInit(options) {
1146
1171
  ` ${chalk.dim("Balance:")} ${sandbox.wallet.balance} ${sandbox.wallet.currency} (test balance)`
1147
1172
  );
1148
1173
  console.log(
1149
- ` ${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)" : ""}`
1150
1175
  );
1151
1176
  console.log(` ${chalk.dim("Expires:")} ${sandbox.expiresAt}`);
1152
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-CMPYURB7.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-CMPYURB7.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.3",
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",