@integrity-labs/agt-cli 0.27.81 → 0.27.83

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.
@@ -2369,8 +2369,12 @@ var LITERAL_SECRET_PATTERNS = [
2369
2369
  { name: "agt_host_api_key", re: /^tlk_/ },
2370
2370
  // Composio / generic api-key prefix — `ak_<...>`
2371
2371
  { name: "composio_api_key", re: /^ak_/ },
2372
- // Telegram bot token — `<10-digit bot id>:AAE<...>` (BotFather format).
2373
- { name: "telegram_bot_token", re: /^\d{10}:AAE/ },
2372
+ // Telegram bot token — `<bot id>:AA<...>` (BotFather format). ENG-5901
2373
+ // PR 4: the original `\d{10}:AAE` (from the issue AC) was too narrow —
2374
+ // live tokens on agt-aws-1 carry `AA` + a varying third character
2375
+ // (don/scout/stirling all had AA-not-E tokens the lint and migration
2376
+ // missed). Bot ids are 8–12 digits; the token part always starts `AA`.
2377
+ { name: "telegram_bot_token", re: /^\d{8,12}:AA[A-Za-z0-9_-]/ },
2374
2378
  // ENG-5901 extension beyond the original AC's five patterns: a literal
2375
2379
  // JWT (`eyJ...`) is the shape of a leaked AGT_API_KEY, which the
2376
2380
  // value-prefix patterns above would otherwise miss. Header values often
@@ -2421,6 +2425,7 @@ function formatLiteralSecretRejection(f) {
2421
2425
 
2422
2426
  // ../../packages/core/dist/provisioning/mcp-config-guards.js
2423
2427
  var MCP_FILE_MODE = 384;
2428
+ var lastRejectionFingerprintByPath = /* @__PURE__ */ new Map();
2424
2429
  var REQUIRED_ENV_RULES_BY_SERVER = {
2425
2430
  "cloud-broker": [
2426
2431
  { key: "AGT_HOST", mustBeConcrete: false },
@@ -2571,9 +2576,13 @@ function safeWriteMcpJson(path, config) {
2571
2576
  }
2572
2577
  const secretFindings = scanConfigForLiteralSecrets(config);
2573
2578
  if (secretFindings.length > 0) {
2574
- for (const f of secretFindings) {
2575
- process.stderr.write(`${formatLiteralSecretRejection(f)}
2579
+ const fingerprint = secretFindings.map((f) => `${f.server}.${f.field}.${f.location}`).sort().join("|");
2580
+ if (lastRejectionFingerprintByPath.get(path) !== fingerprint) {
2581
+ lastRejectionFingerprintByPath.set(path, fingerprint);
2582
+ for (const f of secretFindings) {
2583
+ process.stderr.write(`${formatLiteralSecretRejection(f)}
2576
2584
  `);
2585
+ }
2577
2586
  }
2578
2587
  return {
2579
2588
  written: false,
@@ -2584,6 +2593,7 @@ function safeWriteMcpJson(path, config) {
2584
2593
  }))
2585
2594
  };
2586
2595
  }
2596
+ lastRejectionFingerprintByPath.delete(path);
2587
2597
  safeWriteJsonAtomic(path, JSON.stringify(config, null, 2), { mode: MCP_FILE_MODE });
2588
2598
  return { written: true, errors: [] };
2589
2599
  }
@@ -3935,6 +3945,66 @@ function writeEnvIntegrationsForAgent(codeName, args) {
3935
3945
  `);
3936
3946
  }
3937
3947
  }
3948
+ var MIGRATABLE_FIELD_TO_ENV_VAR = {
3949
+ SLACK_BOT_TOKEN: "SLACK_BOT_TOKEN",
3950
+ SLACK_APP_TOKEN: "SLACK_APP_TOKEN",
3951
+ TELEGRAM_BOT_TOKEN: "TELEGRAM_BOT_TOKEN",
3952
+ MSTEAMS_CLIENT_SECRET: "MSTEAMS_CLIENT_SECRET",
3953
+ PIPEDREAM_CLIENT_SECRET: "PIPEDREAM_CLIENT_SECRET",
3954
+ "x-api-key": "COMPOSIO_API_KEY",
3955
+ AGT_API_KEY: "AGT_API_KEY"
3956
+ };
3957
+ function migrateExistingLiteralSecrets(codeName) {
3958
+ const mcpJsonPath = join4(getAgentDir(codeName), "provision", ".mcp.json");
3959
+ let config;
3960
+ try {
3961
+ config = JSON.parse(readFileSync5(mcpJsonPath, "utf-8"));
3962
+ } catch {
3963
+ return;
3964
+ }
3965
+ let existingEnvKeys = /* @__PURE__ */ new Set();
3966
+ try {
3967
+ existingEnvKeys = new Set(parseEnvFileEntries(readFileSync5(join4(getAgentDir(codeName), ".env.integrations"), "utf-8")).keys());
3968
+ } catch {
3969
+ }
3970
+ const updates = {};
3971
+ let hoisted = 0;
3972
+ for (const raw of Object.values(config.mcpServers ?? {})) {
3973
+ if (typeof raw !== "object" || raw === null)
3974
+ continue;
3975
+ const entry = raw;
3976
+ for (const block of [entry.env, entry.headers]) {
3977
+ if (!block)
3978
+ continue;
3979
+ for (const [field, envVar] of Object.entries(MIGRATABLE_FIELD_TO_ENV_VAR)) {
3980
+ const value = block[field];
3981
+ if (typeof value !== "string" || value.length === 0 || value.includes("${"))
3982
+ continue;
3983
+ if (envVar !== "AGT_API_KEY" && !existingEnvKeys.has(envVar)) {
3984
+ updates[envVar] = value;
3985
+ }
3986
+ block[field] = `\${${envVar}}`;
3987
+ hoisted++;
3988
+ }
3989
+ }
3990
+ }
3991
+ const unmapped = scanConfigForLiteralSecrets(config).map((f) => `${f.server}.${f.field}`);
3992
+ if (hoisted === 0 && unmapped.length === 0)
3993
+ return;
3994
+ if (hoisted === 0) {
3995
+ process.stderr.write(`[mcp-migrate] [no-mappable-literals] agent=${codeName} unmapped=${unmapped.join(",")}
3996
+ `);
3997
+ return;
3998
+ }
3999
+ if (Object.keys(updates).length > 0) {
4000
+ writeEnvIntegrationsForAgent(codeName, { mode: "upsert", updates });
4001
+ }
4002
+ if (writeMcpJsonGuarded(codeName, mcpJsonPath, config)) {
4003
+ syncMcpToProject(codeName);
4004
+ process.stderr.write(`[mcp-migrate] [literals-hoisted] agent=${codeName} hoisted=${hoisted}${unmapped.length > 0 ? ` unmapped=${unmapped.join(",")}` : ""}
4005
+ `);
4006
+ }
4007
+ }
3938
4008
  function assertValidCodeName(codeName) {
3939
4009
  if (!VALID_CODE_NAME.test(codeName)) {
3940
4010
  throw new Error(`Invalid agent code_name: "${codeName}". Must be kebab-case.`);
@@ -5783,6 +5853,12 @@ ${sections}`
5783
5853
  });
5784
5854
  return changed;
5785
5855
  },
5856
+ // ENG-5901 PR 3: hoist pre-Track-D literal secrets out of the on-disk
5857
+ // .mcp.json so the armed lint stops rejecting every incremental write.
5858
+ // See migrateExistingLiteralSecrets for the full story.
5859
+ migrateSecretStorage(codeName) {
5860
+ migrateExistingLiteralSecrets(codeName);
5861
+ },
5786
5862
  seedProfileConfig(codeName) {
5787
5863
  const agentDir = getAgentDir(codeName);
5788
5864
  const projectDir = getProjectDir(codeName);
@@ -7488,4 +7564,4 @@ export {
7488
7564
  managerInstallSystemUnitCommand,
7489
7565
  managerUninstallSystemUnitCommand
7490
7566
  };
7491
- //# sourceMappingURL=chunk-CGUXKOUF.js.map
7567
+ //# sourceMappingURL=chunk-HTXXJBB7.js.map