@integrity-labs/agt-cli 0.28.1257 → 0.28.1259

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.
Files changed (31) hide show
  1. package/dist/{api-client-6W27Z5SN.js → api-client-ATRLQZOU.js} +3 -3
  2. package/dist/bin/agt.js +7 -7
  3. package/dist/{chunk-AMZ5XSTY.js → chunk-5433KPH4.js} +2 -2
  4. package/dist/{chunk-HXM2V3VK.js → chunk-BOITSKCM.js} +3 -3
  5. package/dist/{chunk-ZRQWRXGK.js → chunk-F6U3ZJCG.js} +2 -2
  6. package/dist/{chunk-MXDVYW5G.js → chunk-NRNPYXG6.js} +14 -1
  7. package/dist/chunk-NRNPYXG6.js.map +1 -0
  8. package/dist/{chunk-GSNAPMCA.js → chunk-RBC22FRC.js} +75 -9
  9. package/dist/chunk-RBC22FRC.js.map +1 -0
  10. package/dist/{chunk-W6NQLEKG.js → chunk-UAO5VMYK.js} +15 -12
  11. package/dist/chunk-UAO5VMYK.js.map +1 -0
  12. package/dist/{claude-code-updater-3YFSB22P.js → claude-code-updater-SUL3OSGB.js} +3 -3
  13. package/dist/{claude-pair-runtime-W4XS6BR2.js → claude-pair-runtime-D6ZRO2FC.js} +3 -3
  14. package/dist/lib/manager-worker.js +103 -65
  15. package/dist/lib/manager-worker.js.map +1 -1
  16. package/dist/{persistent-session-BBEOA3TR.js → persistent-session-UC56OJVB.js} +4 -4
  17. package/dist/{responsiveness-probe-X32GL24W.js → responsiveness-probe-KGBRCJQW.js} +4 -4
  18. package/dist/{session-auth-dead-5F3NEK57.js → session-auth-dead-AVYJASOL.js} +3 -3
  19. package/package.json +1 -1
  20. package/dist/chunk-GSNAPMCA.js.map +0 -1
  21. package/dist/chunk-MXDVYW5G.js.map +0 -1
  22. package/dist/chunk-W6NQLEKG.js.map +0 -1
  23. /package/dist/{api-client-6W27Z5SN.js.map → api-client-ATRLQZOU.js.map} +0 -0
  24. /package/dist/{chunk-AMZ5XSTY.js.map → chunk-5433KPH4.js.map} +0 -0
  25. /package/dist/{chunk-HXM2V3VK.js.map → chunk-BOITSKCM.js.map} +0 -0
  26. /package/dist/{chunk-ZRQWRXGK.js.map → chunk-F6U3ZJCG.js.map} +0 -0
  27. /package/dist/{claude-code-updater-3YFSB22P.js.map → claude-code-updater-SUL3OSGB.js.map} +0 -0
  28. /package/dist/{claude-pair-runtime-W4XS6BR2.js.map → claude-pair-runtime-D6ZRO2FC.js.map} +0 -0
  29. /package/dist/{persistent-session-BBEOA3TR.js.map → persistent-session-UC56OJVB.js.map} +0 -0
  30. /package/dist/{responsiveness-probe-X32GL24W.js.map → responsiveness-probe-KGBRCJQW.js.map} +0 -0
  31. /package/dist/{session-auth-dead-5F3NEK57.js.map → session-auth-dead-AVYJASOL.js.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  rotateDailySession,
5
5
  sessionFileExists,
6
6
  todayLocalIso
7
- } from "./chunk-ZRQWRXGK.js";
7
+ } from "./chunk-F6U3ZJCG.js";
8
8
  import {
9
9
  classifyUnanswerablePane,
10
10
  customApiKeyDialogKeys,
@@ -44,6 +44,7 @@ import {
44
44
  isClaudeFastMode,
45
45
  isDefaultRemoteMcpConnection,
46
46
  isDeprecatedFramework,
47
+ isPlatformGatewayOrigin,
47
48
  isUnsetTimezone,
48
49
  mcpWildcardsForServers,
49
50
  modelSlotsForFramework,
@@ -51,7 +52,7 @@ import {
51
52
  remoteMcpConnectionEnvInfix,
52
53
  remoteMcpConnectionLabel,
53
54
  remoteMcpConnectionScopedEnvVar
54
- } from "./chunk-MXDVYW5G.js";
55
+ } from "./chunk-NRNPYXG6.js";
55
56
  import {
56
57
  CLAUDE_CONFIG_DIR_ENV,
57
58
  approveApiKeyInClaudeConfig,
@@ -467,6 +468,7 @@ function probeMcpEnvSubstitution(args) {
467
468
  ...parseEnvIntegrations(readFileSync2(args.envIntegrationsPath, "utf-8"))
468
469
  };
469
470
  }
471
+ if (args.afterEnvFile) env = { ...env, ...args.afterEnvFile };
470
472
  return findMissingSubstitutionVars(config, env);
471
473
  } catch {
472
474
  return [];
@@ -3552,6 +3554,7 @@ function creditWatchdogUnclaimedDialogCount(codeName, count) {
3552
3554
  }
3553
3555
 
3554
3556
  // src/lib/model-policy.ts
3557
+ import { createHash as createHash2 } from "crypto";
3555
3558
  var TRANSPORTS = ["anthropic-direct", "bedrock", "gateway"];
3556
3559
  var WIRE_SCHEMAS = ["anthropic_messages", "openai_chat_completions"];
3557
3560
  var CREDENTIAL_SOURCES = [
@@ -3561,6 +3564,7 @@ var CREDENTIAL_SOURCES = [
3561
3564
  "aws_role"
3562
3565
  ];
3563
3566
  var ROLES = ["primary", "secondary"];
3567
+ var CREDENTIAL_OWNERS = ["platform", "customer"];
3564
3568
  var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
3565
3569
  function parseModelPolicyModels(raw) {
3566
3570
  if (raw === void 0 || raw === null) return [];
@@ -3606,12 +3610,21 @@ function parseBinding(raw) {
3606
3610
  const baseUrlRaw = raw["base_url"];
3607
3611
  const baseUrl = typeof baseUrlRaw === "string" && baseUrlRaw.trim() !== "" ? baseUrlRaw : null;
3608
3612
  if (transport === "gateway" !== (baseUrl !== null)) return null;
3613
+ const credentialOwnerRaw = raw["credential_owner"];
3614
+ let credentialOwner = "customer";
3615
+ if (credentialOwnerRaw !== void 0 && credentialOwnerRaw !== null) {
3616
+ if (typeof credentialOwnerRaw !== "string" || !CREDENTIAL_OWNERS.includes(credentialOwnerRaw)) {
3617
+ return null;
3618
+ }
3619
+ credentialOwner = credentialOwnerRaw;
3620
+ }
3609
3621
  return {
3610
3622
  role,
3611
3623
  transport,
3612
3624
  wireSchema,
3613
3625
  baseUrl,
3614
- credentialSource
3626
+ credentialSource,
3627
+ credentialOwner
3615
3628
  };
3616
3629
  }
3617
3630
  function parseModelPolicy(raw) {
@@ -3651,9 +3664,21 @@ function parseModelPolicy(raw) {
3651
3664
  models: parseModelPolicyModels(raw["models"])
3652
3665
  };
3653
3666
  }
3654
- function modelPolicyAuthComponent(policy) {
3667
+ var GATEWAY_TOKEN_FINGERPRINT_LENGTH = 16;
3668
+ function gatewayTokenFingerprint(token) {
3669
+ return createHash2("sha256").update(token, "utf8").digest("hex").slice(0, GATEWAY_TOKEN_FINGERPRINT_LENGTH);
3670
+ }
3671
+ var GATEWAY_TOKEN_FIELD = "model_policy_gateway_token";
3672
+ function parseGatewayToken(refreshData) {
3673
+ if (!refreshData || typeof refreshData !== "object") return null;
3674
+ const raw = refreshData[GATEWAY_TOKEN_FIELD];
3675
+ if (typeof raw !== "string") return null;
3676
+ return raw.trim() === "" ? null : raw;
3677
+ }
3678
+ function modelPolicyAuthComponent(policy, gatewayToken) {
3655
3679
  if (!policy) return null;
3656
- const base = `${policy.policyId}@${policy.revision}`;
3680
+ let base = `${policy.policyId}@${policy.revision}`;
3681
+ if (gatewayToken) base += `#${gatewayTokenFingerprint(gatewayToken)}`;
3657
3682
  return policy.activeRole === "primary" ? base : `${base}/${policy.activeRole}`;
3658
3683
  }
3659
3684
  function modelPolicyEgressDomains(policy) {
@@ -3680,6 +3705,12 @@ function resolveBindingCredential(binding, availableGatewayToken) {
3680
3705
  if (!availableGatewayToken) {
3681
3706
  return { kind: "blocked", reason: "credential-path-not-built" };
3682
3707
  }
3708
+ if (binding.credentialOwner !== "platform") {
3709
+ return { kind: "blocked", reason: "customer-owned-credential" };
3710
+ }
3711
+ if (!isPlatformGatewayOrigin(binding.baseUrl)) {
3712
+ return { kind: "blocked", reason: "not-platform-gateway-origin" };
3713
+ }
3683
3714
  return { kind: "gateway", baseUrl: binding.baseUrl, authToken: availableGatewayToken };
3684
3715
  }
3685
3716
  }
@@ -3781,7 +3812,27 @@ function resolveModelPolicySpawnEnv(input) {
3781
3812
  return {
3782
3813
  env: {
3783
3814
  ANTHROPIC_BASE_URL: resolution.baseUrl,
3784
- ANTHROPIC_AUTH_TOKEN: resolution.authToken
3815
+ ANTHROPIC_AUTH_TOKEN: resolution.authToken,
3816
+ // ENG-10865 — EMPTIED, and emitted HERE rather than at the spawn
3817
+ // sites, because this map is the one producer every site derives
3818
+ // from: the tmux `-e` loop iterates it, the MCP probe mirror copies
3819
+ // it, and the docker forward block's name list is asserted EQUAL to
3820
+ // its keys (`eng-9483-model-policy`'s parity test). Written at three
3821
+ // sites by hand it would be three things to keep in step; written
3822
+ // here it is one, and the parity test fails if a site drops it.
3823
+ //
3824
+ // Why empty and not absent: Claude Code reads `ANTHROPIC_API_KEY`
3825
+ // FIRST and a NON-EMPTY value there beats `ANTHROPIC_AUTH_TOKEN`.
3826
+ // Declining to set it says only that this code adds none — it says
3827
+ // nothing about what the pane inherits, and `tmux new-session -e`
3828
+ // ADDS to an environment the tmux server already took from the
3829
+ // manager, where an operator, a systemd unit or `/etc/environment`
3830
+ // can have put a real key. On such a host a gateway policy that
3831
+ // merely declined would route past the gateway to Anthropic on the
3832
+ // host's old key: healthy agent, correct-looking spawn, wrong
3833
+ // provider, no error anywhere. An empty value loses the precedence
3834
+ // fight; an absent one does not enter it.
3835
+ ANTHROPIC_API_KEY: ""
3785
3836
  },
3786
3837
  modelEnv,
3787
3838
  projectSettings,
@@ -4467,6 +4518,7 @@ function buildDockerRunCommand(args) {
4467
4518
  if (passModelPolicyGateway) {
4468
4519
  envArgs.push("-e ANTHROPIC_BASE_URL");
4469
4520
  envArgs.push("-e ANTHROPIC_AUTH_TOKEN");
4521
+ envArgs.push("-e ANTHROPIC_API_KEY=");
4470
4522
  }
4471
4523
  if (passModelPolicyModel) {
4472
4524
  envArgs.push("-e ANTHROPIC_MODEL");
@@ -4590,6 +4642,9 @@ function writePersistentClaudeWrapper(args) {
4590
4642
  );
4591
4643
  }
4592
4644
  wrapperLines.push("export DISABLE_AUTOUPDATER=1");
4645
+ if (args.modelPolicyGatewayActive) {
4646
+ wrapperLines.push("export ANTHROPIC_API_KEY=");
4647
+ }
4593
4648
  const brokerBinDir = join7(projectDir, ".claude", "agt-bin");
4594
4649
  if (existsSync6(brokerBinDir)) {
4595
4650
  wrapperLines.push(`export PATH=${JSON.stringify(brokerBinDir)}:"$PATH"`);
@@ -5166,7 +5221,13 @@ function spawnSession(config, session) {
5166
5221
  projectDir,
5167
5222
  claudeBin,
5168
5223
  initPrompt,
5169
- claudeArgsJoined
5224
+ claudeArgsJoined,
5225
+ // ENG-10865 — the condition is "did the resolver ask for the emptying",
5226
+ // read off `policyEnv` itself, NOT a re-derived "is this a gateway". The
5227
+ // resolver's gateway arm is the single producer of that key; asking it
5228
+ // what it decided keeps the wrapper from becoming a second place that
5229
+ // decides, which is how the two would come to disagree.
5230
+ modelPolicyGatewayActive: "ANTHROPIC_API_KEY" in policyEnv
5170
5231
  });
5171
5232
  const tmuxSessionEnvArgs = [];
5172
5233
  tmuxSessionEnvArgs.push("-e", `AGT_AGENT_ID=${config.agentId}`);
@@ -5385,7 +5446,11 @@ function spawnSession(config, session) {
5385
5446
  for (const f of probeMcpEnvSubstitution({
5386
5447
  mcpConfigPath,
5387
5448
  envIntegrationsPath: join7(projectDir, ".env.integrations"),
5388
- baseEnv: probeBaseEnv
5449
+ baseEnv: probeBaseEnv,
5450
+ // Mirrors `writePersistentClaudeWrapper`'s post-source re-assertion, and
5451
+ // keyed off the same fact it is: the presence of the variable in
5452
+ // `policyEnv`, not a re-derived "is this a gateway".
5453
+ ..."ANTHROPIC_API_KEY" in policyEnv ? { afterEnvFile: { ANTHROPIC_API_KEY: "" } } : {}
5389
5454
  })) {
5390
5455
  log2(`[persistent-session] ${formatMissingVar(f)} agent=${codeName}`);
5391
5456
  }
@@ -6202,6 +6267,7 @@ export {
6202
6267
  takeWatchdogUnclaimedDialogCount,
6203
6268
  creditWatchdogUnclaimedDialogCount,
6204
6269
  parseModelPolicy,
6270
+ parseGatewayToken,
6205
6271
  modelPolicyAuthComponent,
6206
6272
  modelPolicyEgressDomains,
6207
6273
  resolveModelPolicySpawnEnv,
@@ -6277,4 +6343,4 @@ export {
6277
6343
  stopAllSessionsAndWait,
6278
6344
  getProjectDir
6279
6345
  };
6280
- //# sourceMappingURL=chunk-GSNAPMCA.js.map
6346
+ //# sourceMappingURL=chunk-RBC22FRC.js.map