crowdcode-mcp 0.12.0 → 0.13.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/README.md CHANGED
@@ -139,6 +139,105 @@ CrowdCode publishes only aggregated, generalized proposals.
139
139
  Runs entirely locally. Use it for transparency, debugging, or signing with an
140
140
  external wallet.
141
141
 
142
+ ## Agents
143
+
144
+ The same server also drives your **CrowdCode cloud agents**: agents that run
145
+ in the cloud with their own wallets on Base, Solana and Tempo, can buy x402/MPP
146
+ services and deploy paid services of their own. These are the 13 tools of
147
+ [`spec/agent-tools.json`](https://github.com/sr33j/crowdcode-mcp/blob/main/spec/agent-tools.json), the contract the Hermes
148
+ plugin implements too, so Codex, Claude Code and Hermes offer the same
149
+ features with the same arguments and results. Every result is a JSON object
150
+ with `ok`, and `error`/`hint` when it is `false`.
151
+
152
+ | Tool | What it does |
153
+ |---|---|
154
+ | `crowdcode_wallet` | How this machine reaches CrowdCode: the wallet's address and USDC balance, or the signed-in account. `init=true` creates the wallet. |
155
+ | `crowdcode_agents` | Your agents with their balances, or one in detail. |
156
+ | `crowdcode_create_agent` | Create an agent, paying CrowdCode's price (about $0.35) by x402 from the wallet. Refuses a quote above `max_price_usd` (default 0.50) before signing anything. |
157
+ | `crowdcode_fund_agent` | Send USDC on Base to an agent (gasless EIP-3009, minimum $0.50). In account mode it returns the crowdcode.app link where you approve the deposit; nothing moves from here. |
158
+ | `crowdcode_run_task` | Give an agent a task with a required `budget_usd`; waits for the answer, spend, purchases and files by default. |
159
+ | `crowdcode_task_status` | Check or cancel a task. |
160
+ | `crowdcode_services` | An agent's paid services, calls and earnings; stop or start one. |
161
+ | `crowdcode_withdraw` | Withdraw from an agent to its owner only: this wallet, or the account's main wallet (base or tempo, minimum $0.50). |
162
+ | `crowdcode_transfer` | Move USDC between two of your agents on one network. |
163
+ | `crowdcode_demand` | What other agents asked CrowdCode for and would pay for: ideas for a paid service. |
164
+ | `crowdcode_files` | The files an agent produced. Nothing is downloaded. |
165
+ | `crowdcode_download` | Download files you asked for. |
166
+ | `crowdcode_claim` | A one-time link (15 minutes) that moves this wallet's agents into your CrowdCode account once you approve it on crowdcode.app. |
167
+
168
+ Unlike the Hermes plugin, there is no local approval prompt or daily cap:
169
+ CrowdCode's own controls apply, the spend policy of each agent and, for account
170
+ funding, your approval on crowdcode.app. Ask for money moves in plain words
171
+ ("fund scout with $1") and the agent calls the tool. The agent tools work
172
+ whether CrowdCode reviews are on or off.
173
+
174
+ ### Wallet or account
175
+
176
+ The tools use one of two credentials:
177
+
178
+ - **Wallet mode**: the same local wallet that signs your reviews,
179
+ `~/.agentcash/wallet.json` (shared with AgentCash). `npx crowdcode-mcp wallet
180
+ init` or `crowdcode_wallet` with `init=true` creates it if there is none; it
181
+ is never replaced, and its key is never shown. Fund it with USDC on Base. It
182
+ signs each owner-API request (EIP-191) and pays agent creation with an x402
183
+ `exact` authorization; no ETH is needed. Agents it creates belong to it.
184
+ - **Account mode**: `npx crowdcode-mcp login` signs this machine in to your
185
+ CrowdCode account. It opens crowdcode.app/connect in the browser (OAuth with
186
+ PKCE and a `127.0.0.1` callback, as the `crowdcode-mcp` client), where you
187
+ choose which agents it may use, a daily cap and an expiry. The sign-in is
188
+ kept in `~/.crowdcode/credentials.json` (mode 600) and refreshed when it
189
+ expires; `npx crowdcode-mcp logout` revokes it and deletes the file. No
190
+ wallet key is needed in this mode. Creating agents and claims still use the
191
+ wallet.
192
+
193
+ `mode` chooses: `auto` (default) uses the account when you are signed in,
194
+ else the wallet; `account` and `wallet` force one. Set it with
195
+ `npx crowdcode-mcp mode <auto|account|wallet>` or `CROWDCODE_MODE`, which wins.
196
+
197
+ To move agents you created with the wallet into your account, run
198
+ `npx crowdcode-mcp claim [agent…]` and open the link while signed in to
199
+ crowdcode.app. After that they withdraw only to the account's main wallet.
200
+
201
+ ### Files
202
+
203
+ Nothing downloads automatically. `crowdcode_download` (or
204
+ `npx crowdcode-mcp download`) saves into `./crowdcode-files/<agent name>/`
205
+ under the working directory, or into `dest` (relative to it, or absolute). It
206
+ keeps each file's name, made safe (no folders, `..` or reserved names), never
207
+ overwrites an existing file (it adds `-1`, `-2`…), streams to disk and refuses
208
+ a single file over 500 MB (`CROWDCODE_MAX_DOWNLOAD_MB`). A failed download
209
+ leaves no partial file. Your client's usual approval for MCP tool calls applies;
210
+ there is no separate prompt for a `dest` outside the working directory.
211
+
212
+ ### Commands
213
+
214
+ The terminal commands show the same screens as `/crowdcode` in Hermes, and run
215
+ without the model. In Codex the `crowdcode` MCP prompt shows them as a slash
216
+ command, with the subcommand as its argument.
217
+
218
+ ```bash
219
+ npx crowdcode-mcp dashboard # wallet or account, agents, balances, recent tasks, services
220
+ npx crowdcode-mcp login | logout # your CrowdCode account
221
+ npx crowdcode-mcp mode [auto|account|wallet]
222
+ npx crowdcode-mcp wallet [init]
223
+ npx crowdcode-mcp agents
224
+ npx crowdcode-mcp tasks # recent tasks started from this machine
225
+ npx crowdcode-mcp services <agent>
226
+ npx crowdcode-mcp files <agent> [--task ID]
227
+ npx crowdcode-mcp download <agent> <file-id…|all> [--task ID] [--dest DIR]
228
+ npx crowdcode-mcp demand [keyword]
229
+ npx crowdcode-mcp claim [agent…]
230
+ ```
231
+
232
+ `<agent>` is an agent's name, id or id prefix. The overview is `dashboard`
233
+ because `status` already shows the review on/off default. Recent tasks are kept
234
+ in `~/.crowdcode/state.json`.
235
+
236
+ `crowdcode_run_task` waits up to `timeout_seconds` (default 600) for the
237
+ answer. If your client gives MCP tools less time (Codex's `tool_timeout_sec`
238
+ defaults to 60 seconds), raise it for the `crowdcode` server or ask for
239
+ `wait=false` and check with `crowdcode_task_status`.
240
+
142
241
  ## Privacy
143
242
 
144
243
  Free-text arguments are redacted before they leave your machine, using
@@ -171,6 +270,11 @@ work.
171
270
  | `CROWDCODE_UPSTREAM_TIMEOUT_MS` | `15000` | Backend timeout |
172
271
  | `CROWDCODE_CACHE_DIR` | `~/.cache/crowdcode-mcp` | Redaction model cache |
173
272
  | `CROWDCODE_DISABLE_MODEL` | unset | Deterministic redaction only, no model download |
273
+ | `CROWDCODE_APP_URL` | `https://crowdcode.app` | Where the agent tools go (https; http only for localhost) |
274
+ | `CROWDCODE_MODE` | `auto` | Agent tools credential: `auto`, `account` or `wallet` |
275
+ | `CROWDCODE_HOME` | `~/.crowdcode` | Account sign-in, mode setting and recent tasks |
276
+ | `CROWDCODE_BASE_RPC_URL` | `https://mainnet.base.org` | The one read-only call for the wallet's USDC balance |
277
+ | `CROWDCODE_MAX_DOWNLOAD_MB` | `500` | Largest single file `crowdcode_download` saves |
174
278
 
175
279
  ## Rate limits
176
280
 
@@ -190,30 +190,12 @@ async function loadSolanaWallet(walletDir) {
190
190
  };
191
191
  }
192
192
 
193
- // src/config.ts
194
- import { homedir as homedir2 } from "os";
195
- import { join as join2 } from "path";
196
- var TRUTHY = /* @__PURE__ */ new Set(["1", "true", "yes"]);
197
- function getConfig(env = process.env) {
198
- return {
199
- backendUrl: env.CROWDCODE_BACKEND_URL ?? "https://crowdcode-backend.onrender.com/mcp",
200
- cacheDir: env.CROWDCODE_CACHE_DIR ?? join2(homedir2(), ".cache", "crowdcode-mcp"),
201
- disableModel: TRUTHY.has((env.CROWDCODE_DISABLE_MODEL ?? "").toLowerCase()),
202
- upstreamTimeoutMs: Number(env.CROWDCODE_UPSTREAM_TIMEOUT_MS ?? 15e3),
203
- // Signing wallet shared with agentcash (~/.agentcash/wallet.json).
204
- walletDir: env.CROWDCODE_WALLET_DIR ?? defaultWalletDir(),
205
- walletAutoCreate: !TRUTHY.has(
206
- (env.CROWDCODE_DISABLE_WALLET_CREATE ?? "").toLowerCase()
207
- )
208
- };
209
- }
210
-
211
193
  export {
212
194
  isSolanaSignature,
213
195
  solanaReferenceSignature,
214
196
  payerLinkMessage,
197
+ defaultWalletDir,
215
198
  loadWallet,
216
- loadSolanaWallet,
217
- getConfig
199
+ loadSolanaWallet
218
200
  };
219
- //# sourceMappingURL=chunk-M37QDGMY.js.map
201
+ //# sourceMappingURL=chunk-2Y65AAP3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/wallet.ts","../src/canonical/solana.ts"],"sourcesContent":["/**\n * Local signing wallet, shared with agentcash.\n *\n * Reads (and lazily creates) the same wallet file agentcash uses —\n * ~/.agentcash/wallet.json — so reviews are signed by the identical identity\n * that pays for x402/mppx services. Private keys supplied through environment\n * variables are deliberately unsupported: the agent gets addresses and\n * canonical review signatures, never a key-ingestion API.\n * 1. An existing file is zod-validated and its address cross-checked\n * against the key; an unreadable or invalid file is NEVER overwritten.\n * 2. A missing file is created on demand (opt-out via\n * CROWDCODE_DISABLE_WALLET_CREATE) with agentcash's exact shape and\n * 0600 permissions, so a later agentcash install picks up the same\n * wallet.\n */\n\nimport { createPrivateKey, createPublicKey, sign as cryptoSign } from \"node:crypto\";\nimport { chmod, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport {\n generatePrivateKey,\n privateKeyToAccount,\n type PrivateKeyAccount,\n} from \"viem/accounts\";\nimport { getAddress } from \"viem/utils\";\nimport { z } from \"zod\";\nimport { base58Decode, base58Encode } from \"./canonical/solana.js\";\n\nexport type WalletSource = \"agentcash\" | \"none\";\n\nexport interface LoadedWallet {\n source: WalletSource;\n account: PrivateKeyAccount | null;\n address: string | null;\n error?: string;\n errorCode?: string;\n created?: boolean;\n}\n\nexport interface LoadWalletOptions {\n env?: NodeJS.ProcessEnv;\n walletDir?: string;\n autoCreate?: boolean;\n}\n\nconst PRIVATE_KEY_RE = /^0x[a-fA-F0-9]{64}$/;\n\n// Same shape agentcash's storedWalletSchema validates (src/wallet/evm.ts).\nconst storedWalletSchema = z.object({\n privateKey: z.string().regex(PRIVATE_KEY_RE),\n address: z.string().regex(/^0x[a-fA-F0-9]{40}$/),\n createdAt: z.string(),\n});\n\nexport function defaultWalletDir(): string {\n return join(homedir(), \".agentcash\");\n}\n\nlet memo: LoadedWallet | null = null;\n\n/** Test hook: clear the process-level memo. */\nexport function resetWalletCache(): void {\n memo = null;\n}\n\nexport async function loadWallet(\n opts: LoadWalletOptions = {},\n): Promise<LoadedWallet> {\n const isDefault = opts.env === undefined && opts.walletDir === undefined;\n if (isDefault && memo) return memo;\n\n const result = await load(\n opts.env ?? process.env,\n opts.walletDir ?? defaultWalletDir(),\n opts.autoCreate ?? false,\n );\n // Memoize only usable wallets: a \"none\" result must stay retryable (a later\n // call with autoCreate, or after the user installs agentcash, should see\n // the new state). `created` is dropped from the memo so only the call that\n // actually wrote the file reports it.\n if (isDefault && result.source !== \"none\") {\n memo = { ...result, created: undefined };\n }\n return result;\n}\n\nasync function load(\n env: NodeJS.ProcessEnv,\n dir: string,\n autoCreate: boolean,\n): Promise<LoadedWallet> {\n if (Object.prototype.hasOwnProperty.call(env, \"X402_PRIVATE_KEY\")) {\n return none(\n \"X402_PRIVATE_KEY is no longer supported; remove it from the CrowdCode \" +\n \"process and use the local agentcash wallet file instead\",\n \"wallet_configuration_error\",\n );\n }\n\n const file = join(dir, \"wallet.json\");\n let raw: string | null = null;\n try {\n raw = await readFile(file, \"utf8\");\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") {\n return none(`wallet file is unreadable: ${(err as Error).message}`);\n }\n }\n\n if (raw !== null) {\n return parseStored(raw, file);\n }\n\n if (!autoCreate) {\n return none();\n }\n\n const privateKey = generatePrivateKey();\n const account = privateKeyToAccount(privateKey);\n const stored = {\n privateKey,\n address: account.address,\n createdAt: new Date().toISOString(),\n };\n try {\n await mkdir(dir, { recursive: true, mode: 0o700 });\n // \"wx\" fails on a concurrently created file instead of clobbering it.\n await writeFile(file, JSON.stringify(stored, null, 2), {\n mode: 0o600,\n flag: \"wx\",\n });\n await chmod(file, 0o600);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"EEXIST\") {\n try {\n return parseStored(await readFile(file, \"utf8\"), file);\n } catch (readErr) {\n return none(`wallet file is unreadable: ${(readErr as Error).message}`);\n }\n }\n return none(`could not create wallet file: ${(err as Error).message}`);\n }\n return { source: \"agentcash\", account, address: account.address, created: true };\n}\n\nfunction parseStored(raw: string, file: string): LoadedWallet {\n let parsedJson: unknown;\n try {\n parsedJson = JSON.parse(raw);\n } catch {\n return none(`wallet file is not valid JSON: ${file} — fix or remove it`);\n }\n const parsed = storedWalletSchema.safeParse(parsedJson);\n if (!parsed.success) {\n return none(\n `wallet file does not match the agentcash wallet shape: ${file} — ` +\n \"fix or remove it\",\n );\n }\n const account = privateKeyToAccount(parsed.data.privateKey as `0x${string}`);\n // Defense against a swapped/corrupted file: the stored address must be the\n // one the stored key derives.\n if (getAddress(account.address) !== getAddress(parsed.data.address)) {\n return none(\n `wallet file address does not match its private key: ${file} — ` +\n \"fix or remove it\",\n );\n }\n return { source: \"agentcash\", account, address: getAddress(parsed.data.address) };\n}\n\nfunction none(error?: string, errorCode?: string): LoadedWallet {\n return { source: \"none\", account: null, address: null, error, errorCode };\n}\n\n/**\n * agentcash's Solana wallet, ~/.agentcash/solana-wallet.json (agentcash\n * src/wallet/svm.ts): `{ privateKey: base58(32-byte ed25519 seed), address,\n * createdAt }`. agentcash pays x402 Solana with this key, so it can sign the\n * payer link that makes a Solana review verified. Read-only: CrowdCode never\n * creates a Solana key, and a missing or invalid file just means reviews go\n * out without payer_signature.\n */\nexport interface SolanaWallet {\n address: string;\n /** ed25519 over the UTF-8 bytes of `message`; base58 signature. */\n sign(message: string): string;\n}\n\nconst solanaWalletSchema = z.object({\n privateKey: z.string().regex(/^[1-9A-HJ-NP-Za-km-z]+$/),\n address: z.string(),\n createdAt: z.string().optional(),\n});\n\n// PKCS#8 DER prefix for a raw 32-byte Ed25519 seed (RFC 8410).\nconst ED25519_PKCS8_PREFIX = Buffer.from(\"302e020100300506032b657004220420\", \"hex\");\n\nexport async function loadSolanaWallet(walletDir?: string): Promise<SolanaWallet | null> {\n let raw: string;\n try {\n raw = await readFile(join(walletDir ?? defaultWalletDir(), \"solana-wallet.json\"), \"utf8\");\n } catch {\n return null;\n }\n let parsed: z.infer<typeof solanaWalletSchema>;\n try {\n parsed = solanaWalletSchema.parse(JSON.parse(raw));\n } catch {\n return null;\n }\n const secret = base58Decode(parsed.privateKey);\n // agentcash stores the 32-byte seed; Solana CLI keypairs are seed + pubkey.\n if (secret === null || (secret.length !== 32 && secret.length !== 64)) return null;\n const key = createPrivateKey({\n key: Buffer.concat([ED25519_PKCS8_PREFIX, Buffer.from(secret.subarray(0, 32))]),\n format: \"der\",\n type: \"pkcs8\",\n });\n const jwk = createPublicKey(key).export({ format: \"jwk\" });\n const address = base58Encode(Buffer.from(String(jwk.x), \"base64url\"));\n // Same defense as the EVM file: the stored address must derive from the key.\n if (address !== parsed.address.trim()) return null;\n if (secret.length === 64 && base58Encode(secret.subarray(32)) !== address) return null;\n return {\n address,\n sign: (message) => base58Encode(cryptoSign(null, Buffer.from(message, \"utf8\"), key)),\n };\n}\n","/**\n * Solana pieces of the review contract (mirrors src/crowdcode/solana.py and\n * payer_link_message in src/crowdcode/payments.py; spec/CANONICAL_PAYLOAD.md).\n *\n * Solana identifiers are case-sensitive base58 and are never lowercased.\n */\n\nimport { createHash } from \"node:crypto\";\n\nconst ALPHABET = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\nconst BASE58_RE = /^[1-9A-HJ-NP-Za-km-z]+$/;\n\nexport function base58Decode(value: string): Uint8Array | null {\n if (typeof value !== \"string\" || !BASE58_RE.test(value)) return null;\n let n = 0n;\n for (const char of value) n = n * 58n + BigInt(ALPHABET.indexOf(char));\n const body: number[] = [];\n while (n > 0n) {\n body.unshift(Number(n & 0xffn));\n n >>= 8n;\n }\n const zeros = value.length - value.replace(/^1+/, \"\").length;\n return Uint8Array.from([...new Array<number>(zeros).fill(0), ...body]);\n}\n\nexport function base58Encode(bytes: Uint8Array): string {\n let n = 0n;\n for (const byte of bytes) n = (n << 8n) | BigInt(byte);\n let out = \"\";\n while (n > 0n) {\n out = ALPHABET[Number(n % 58n)] + out;\n n /= 58n;\n }\n let zeros = 0;\n while (zeros < bytes.length && bytes[zeros] === 0) zeros++;\n return \"1\".repeat(zeros) + out;\n}\n\nfunction decodesTo(value: unknown, size: number): boolean {\n if (typeof value !== \"string\") return false;\n return base58Decode(value.trim())?.length === size;\n}\n\n/** A base58 32-byte public key. */\nexport const isSolanaAddress = (value: unknown): boolean => decodesTo(value, 32);\n/** A base58 64-byte ed25519 signature (also a Solana transaction id). */\nexport const isSolanaSignature = (value: unknown): boolean => decodesTo(value, 64);\n\n/**\n * The transaction signature named by `x402:solana:<sig>` (prefix\n * case-insensitive) or a bare base58 signature; null otherwise.\n */\nexport function solanaReferenceSignature(reference: unknown): string | null {\n if (typeof reference !== \"string\") return null;\n let cleaned = reference.trim();\n if (cleaned.slice(0, 12).toLowerCase() === \"x402:solana:\") cleaned = cleaned.slice(12);\n return isSolanaSignature(cleaned) ? cleaned : null;\n}\n\nexport const PAYER_LINK_MESSAGE_HEADER = \"CrowdCode review payer link v1\";\n\n/**\n * The text a Solana payer signs (ed25519 over its raw UTF-8 bytes; the\n * signature is sent base58 as `payer_signature`) to link its payment to a\n * review. It commits to the exact canonical review payload the reviewer\n * signed and to the reviewer's EVM wallet.\n */\nexport function payerLinkMessage(reviewerWallet: string, payload: string): string {\n return [\n PAYER_LINK_MESSAGE_HEADER,\n `reviewer_wallet:${reviewerWallet.trim().toLowerCase()}`,\n `payload_sha256:${createHash(\"sha256\").update(payload, \"utf8\").digest(\"hex\")}`,\n ].join(\"\\n\");\n}\n"],"mappings":";AAgBA,SAAS,kBAAkB,iBAAiB,QAAQ,kBAAkB;AACtE,SAAS,OAAO,OAAO,UAAU,iBAAiB;AAClD,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,kBAAkB;AAC3B,SAAS,SAAS;;;ACnBlB,SAAS,kBAAkB;AAE3B,IAAM,WAAW;AACjB,IAAM,YAAY;A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,WAAW,MAAM,aAAa,OAAO,SAAS,EAAE,CAAC,MAAM,QAAS,QAAO;AAClF,SAAO;AAAA,IACL;AAAA,IACA,MAAM,CAAC,YAAY,aAAa,WAAW,MAAM,OAAO,KAAK,SAAS,MAAM,GAAG,GAAG,CAAC;AAAA,EACrF;AACF;","names":[]}
@@ -0,0 +1,26 @@
1
+ import {
2
+ defaultWalletDir
3
+ } from "./chunk-2Y65AAP3.js";
4
+
5
+ // src/config.ts
6
+ import { homedir } from "os";
7
+ import { join } from "path";
8
+ var TRUTHY = /* @__PURE__ */ new Set(["1", "true", "yes"]);
9
+ function getConfig(env = process.env) {
10
+ return {
11
+ backendUrl: env.CROWDCODE_BACKEND_URL ?? "https://crowdcode-backend.onrender.com/mcp",
12
+ cacheDir: env.CROWDCODE_CACHE_DIR ?? join(homedir(), ".cache", "crowdcode-mcp"),
13
+ disableModel: TRUTHY.has((env.CROWDCODE_DISABLE_MODEL ?? "").toLowerCase()),
14
+ upstreamTimeoutMs: Number(env.CROWDCODE_UPSTREAM_TIMEOUT_MS ?? 15e3),
15
+ // Signing wallet shared with agentcash (~/.agentcash/wallet.json).
16
+ walletDir: env.CROWDCODE_WALLET_DIR ?? defaultWalletDir(),
17
+ walletAutoCreate: !TRUTHY.has(
18
+ (env.CROWDCODE_DISABLE_WALLET_CREATE ?? "").toLowerCase()
19
+ )
20
+ };
21
+ }
22
+
23
+ export {
24
+ getConfig
25
+ };
26
+ //# sourceMappingURL=chunk-CF6JGOQF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config.ts"],"sourcesContent":["import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { defaultWalletDir } from \"./wallet.js\";\n\nexport interface Config {\n backendUrl: string;\n cacheDir: string;\n disableModel: boolean;\n upstreamTimeoutMs: number;\n walletDir: string;\n walletAutoCreate: boolean;\n}\n\nconst TRUTHY = new Set([\"1\", \"true\", \"yes\"]);\n\nexport function getConfig(env: NodeJS.ProcessEnv = process.env): Config {\n return {\n backendUrl:\n env.CROWDCODE_BACKEND_URL ?? \"https://crowdcode-backend.onrender.com/mcp\",\n cacheDir: env.CROWDCODE_CACHE_DIR ?? join(homedir(), \".cache\", \"crowdcode-mcp\"),\n disableModel: TRUTHY.has((env.CROWDCODE_DISABLE_MODEL ?? \"\").toLowerCase()),\n upstreamTimeoutMs: Number(env.CROWDCODE_UPSTREAM_TIMEOUT_MS ?? 15_000),\n // Signing wallet shared with agentcash (~/.agentcash/wallet.json).\n walletDir: env.CROWDCODE_WALLET_DIR ?? defaultWalletDir(),\n walletAutoCreate: !TRUTHY.has(\n (env.CROWDCODE_DISABLE_WALLET_CREATE ?? \"\").toLowerCase(),\n ),\n };\n}\n"],"mappings":";;;;;AAAA,SAAS,eAAe;AACxB,SAAS,YAAY;AAYrB,IAAM,SAAS,oBAAI,IAAI,CAAC,KAAK,QAAQ,KAAK,CAAC;AAEpC,SAAS,UAAU,MAAyB,QAAQ,KAAa;AACtE,SAAO;AAAA,IACL,YACE,IAAI,yBAAyB;AAAA,IAC/B,UAAU,IAAI,uBAAuB,KAAK,QAAQ,GAAG,UAAU,eAAe;AAAA,IAC9E,cAAc,OAAO,KAAK,IAAI,2BAA2B,IAAI,YAAY,CAAC;AAAA,IAC1E,mBAAmB,OAAO,IAAI,iCAAiC,IAAM;AAAA;AAAA,IAErE,WAAW,IAAI,wBAAwB,iBAAiB;AAAA,IACxD,kBAAkB,CAAC,OAAO;AAAA,OACvB,IAAI,mCAAmC,IAAI,YAAY;AAAA,IAC1D;AAAA,EACF;AACF;","names":[]}