@integrity-labs/agt-cli 0.28.1014 → 0.28.1016

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.
@@ -15,7 +15,7 @@ import {
15
15
  parseEnvFileEntries,
16
16
  parseEnvIntegrations,
17
17
  shellQuote
18
- } from "./chunk-QBQLG2PY.js";
18
+ } from "./chunk-YPS4AUHN.js";
19
19
  import {
20
20
  BIND_FAILURE_QUARANTINE_THRESHOLD,
21
21
  INTEGRATIONS_SECTION_END,
@@ -77,7 +77,7 @@ import {
77
77
  sessionTranscriptDir,
78
78
  worseConnectivityOutcome,
79
79
  wrapScheduledTaskPrompt
80
- } from "./chunk-MLCGPEN6.js";
80
+ } from "./chunk-B7XGAC54.js";
81
81
  import {
82
82
  classifyUnanswerablePane,
83
83
  summarizeUnanswerablePane
@@ -1965,6 +1965,16 @@ function syncGitHubBrokerCredentialTooling(projectDir, enabled) {
1965
1965
  function getProjectDir2(codeName) {
1966
1966
  return join4(getAgentDir(codeName), "project");
1967
1967
  }
1968
+ function reapLegacyTokenFile(codeName, onWarn = void 0) {
1969
+ const tokenFilePath = join4(getAgentDir(codeName), ".tokens.json");
1970
+ try {
1971
+ rmSync2(tokenFilePath, { force: true });
1972
+ return true;
1973
+ } catch (err) {
1974
+ (onWarn ?? ((m) => console.warn(m)))(`[claudecode] ENG-10939: could not remove ${tokenFilePath} (${err.code ?? "unknown"}) \u2014 a plaintext OAuth token file remains on disk for '${codeName}' and needs manual removal`);
1975
+ return false;
1976
+ }
1977
+ }
1968
1978
  function getScratchDir(codeName) {
1969
1979
  return join4(getAgentDir(codeName), "scratch");
1970
1980
  }
@@ -5497,8 +5507,10 @@ ${sections}`
5497
5507
  const senderPolicyTeamId = options?.senderPolicy?.mode === "team_agents_only" || options?.senderPolicy?.mode === "manager_only" || options?.senderPolicy?.mode === "team_only" ? options.senderPolicy.team_id : void 0;
5498
5508
  const slackPrincipalId = options?.senderPolicy?.mode === "manager_only" ? options.senderPolicy.principal?.slack_user_id : void 0;
5499
5509
  const teamsPrincipalId = options?.senderPolicy?.mode === "manager_only" ? options.senderPolicy.principal?.teams_aad_object_id : void 0;
5510
+ const telegramPrincipalId = options?.senderPolicy?.mode === "manager_only" ? options.senderPolicy.principal?.telegram_chat_id : void 0;
5500
5511
  const slackTeamPrincipalIds = options?.senderPolicy?.mode === "team_only" ? options.senderPolicy.team_principals?.slack_user_ids?.join(",") : void 0;
5501
5512
  const teamsTeamPrincipalIds = options?.senderPolicy?.mode === "team_only" ? options.senderPolicy.team_principals?.teams_aad_object_ids?.join(",") : void 0;
5513
+ const telegramTeamPrincipalIds = options?.senderPolicy?.mode === "team_only" ? options.senderPolicy.team_principals?.telegram_chat_ids?.join(",") : void 0;
5502
5514
  const senderPolicyInternalOnly = options?.senderPolicy?.internal_only === true;
5503
5515
  const senderPolicyEnv = senderPolicyTeamId ? { AGT_TEAM_ID: senderPolicyTeamId } : {};
5504
5516
  const agentDir = getAgentDir(codeName);
@@ -5536,6 +5548,18 @@ ${sections}`
5536
5548
  if (allowedChats && allowedChats.length > 0) {
5537
5549
  telegramEnv.TELEGRAM_ALLOWED_CHATS = allowedChats.join(",");
5538
5550
  }
5551
+ if (senderPolicyMode) {
5552
+ telegramEnv.TELEGRAM_SENDER_POLICY = senderPolicyMode;
5553
+ }
5554
+ for (const [policyKey, policyValue] of Object.entries(senderPolicyEnv)) {
5555
+ telegramEnv[policyKey] = policyValue;
5556
+ }
5557
+ if (telegramPrincipalId) {
5558
+ telegramEnv.TELEGRAM_SENDER_POLICY_PRINCIPAL_ID = telegramPrincipalId;
5559
+ }
5560
+ if (telegramTeamPrincipalIds) {
5561
+ telegramEnv.TELEGRAM_SENDER_POLICY_TEAM_PRINCIPAL_IDS = telegramTeamPrincipalIds;
5562
+ }
5539
5563
  const telegramAckReaction = config["ack_reaction"];
5540
5564
  if (typeof telegramAckReaction === "string" && telegramAckReaction.trim().length > 0) {
5541
5565
  telegramEnv.TELEGRAM_ACK_REACTION = telegramAckReaction.trim();
@@ -6165,6 +6189,7 @@ ${sections}`
6165
6189
  };
6166
6190
  });
6167
6191
  writeIntegrationsSummaryForAgent(codeName, summariesForSidecar);
6192
+ reapLegacyTokenFile(codeName, options?.log);
6168
6193
  const decryptedIntegrations = integrations.map((integration) => ({
6169
6194
  ...integration,
6170
6195
  // atrest-reader-context-allow: host adapter — POST /host/agent-integrations decrypts server-side and returns PLAINTEXT creds (the host holds no AUTH_ENCRYPTION_KEY and ResolvedIntegration carries no org/rowId to build a ref). This decrypt is dead-defensive on plaintext; a v2 (enc:2) blob never reaches the host (ENG-9110 trace).
@@ -6176,30 +6201,27 @@ ${sections}`
6176
6201
  const unscopedPrefix = remoteMcpEnvPrefix(integration.definition_id, null);
6177
6202
  const creds = integration.credentials;
6178
6203
  const def = INTEGRATION_REGISTRY.find((d) => d.id === integration.definition_id);
6179
- if (integration.credentialDelivery === "broker")
6180
- continue;
6181
- let token;
6182
- if (integration.auth_type === "oauth2" || integration.auth_type === "github_app") {
6183
- token = creds.access_token;
6184
- if (token) {
6185
- envUpdates[`${prefix}_ACCESS_TOKEN`] = token;
6204
+ if (integration.credentialDelivery !== "broker") {
6205
+ let token;
6206
+ if (integration.auth_type === "oauth2" || integration.auth_type === "github_app") {
6207
+ token = creds.access_token;
6208
+ if (token) {
6209
+ envUpdates[`${prefix}_ACCESS_TOKEN`] = token;
6210
+ }
6211
+ } else if (integration.auth_type === "api_key") {
6212
+ token = creds.api_key;
6213
+ if (token) {
6214
+ envUpdates[`${prefix}_API_KEY`] = token;
6215
+ }
6186
6216
  }
6187
- } else if (integration.auth_type === "api_key") {
6188
- token = creds.api_key;
6189
- if (token) {
6190
- envUpdates[`${prefix}_API_KEY`] = token;
6217
+ if (def?.cli_tool?.env_key && token && !(def.cli_tool.env_key in envUpdates)) {
6218
+ envUpdates[def.cli_tool.env_key] = token;
6191
6219
  }
6192
6220
  }
6193
- if (def?.cli_tool) {
6194
- const { env_key, extra_env } = def.cli_tool;
6195
- if (env_key && token && !(env_key in envUpdates)) {
6196
- envUpdates[env_key] = token;
6197
- }
6198
- if (extra_env) {
6199
- for (const [k, v] of Object.entries(extra_env)) {
6200
- if (typeof v === "string" && v && !(k in envUpdates)) {
6201
- envUpdates[k] = v;
6202
- }
6221
+ if (def?.cli_tool?.extra_env) {
6222
+ for (const [k, v] of Object.entries(def.cli_tool.extra_env)) {
6223
+ if (typeof v === "string" && v && !(k in envUpdates)) {
6224
+ envUpdates[k] = v;
6203
6225
  }
6204
6226
  }
6205
6227
  }
@@ -6864,29 +6886,6 @@ ${sections}`
6864
6886
  child.on("error", () => {
6865
6887
  });
6866
6888
  });
6867
- },
6868
- writeTokenFile(codeName, integrations) {
6869
- const agentDir = getAgentDir(codeName);
6870
- mkdirSync3(agentDir, { recursive: true });
6871
- const tokens = {};
6872
- for (const integration of integrations) {
6873
- if (integration.auth_type !== "oauth2" && integration.auth_type !== "github_app")
6874
- continue;
6875
- const creds = decryptIntegrationCredentials(integration.credentials);
6876
- const accessToken = creds.access_token;
6877
- if (!accessToken)
6878
- continue;
6879
- tokens[integration.definition_id] = {
6880
- access_token: accessToken,
6881
- ...Object.keys(integration.config).length > 0 ? { config: integration.config } : {},
6882
- ...creds.token_expires_at ? { expires_at: creds.token_expires_at } : {}
6883
- };
6884
- }
6885
- if (Object.keys(tokens).length === 0)
6886
- return;
6887
- const tokenPath = join4(agentDir, ".tokens.json");
6888
- writeFileSync4(tokenPath, JSON.stringify(tokens, null, 2));
6889
- chmodSync4(tokenPath, SECRET_FILE_MODE);
6890
6889
  }
6891
6890
  };
6892
6891
  registerFramework(claudeCodeAdapter);
@@ -7008,7 +7007,7 @@ function exchangeFailureKind(err) {
7008
7007
  }
7009
7008
 
7010
7009
  // src/lib/api-client.ts
7011
- var agtCliVersion = true ? "0.28.1014" : "dev";
7010
+ var agtCliVersion = true ? "0.28.1016" : "dev";
7012
7011
  var lastConfigHash = null;
7013
7012
  function setConfigHash(hash) {
7014
7013
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -11700,6 +11699,7 @@ export {
11700
11699
  extractCommandNotFound,
11701
11700
  describeChannelWriteFailure,
11702
11701
  migrateAgentDirToIdKeyed,
11702
+ reapLegacyTokenFile,
11703
11703
  provisionStopHook,
11704
11704
  provisionIsolationHook,
11705
11705
  provisionAutoKanbanProgressHook,
@@ -11789,4 +11789,4 @@ export {
11789
11789
  managerInstallSystemUnitCommand,
11790
11790
  managerUninstallSystemUnitCommand
11791
11791
  };
11792
- //# sourceMappingURL=chunk-7QXIJNLA.js.map
11792
+ //# sourceMappingURL=chunk-DFKQZGM7.js.map