@posthog/agent 2.3.84 → 2.3.92

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.
@@ -904,7 +904,7 @@ var import_hono = require("hono");
904
904
  // package.json
905
905
  var package_default = {
906
906
  name: "@posthog/agent",
907
- version: "2.3.84",
907
+ version: "2.3.92",
908
908
  repository: "https://github.com/PostHog/code",
909
909
  description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
910
910
  exports: {
@@ -1060,6 +1060,63 @@ var POSTHOG_NOTIFICATIONS = {
1060
1060
  // src/adapters/acp-connection.ts
1061
1061
  var import_sdk3 = require("@agentclientprotocol/sdk");
1062
1062
 
1063
+ // src/gateway-models.ts
1064
+ var DEFAULT_GATEWAY_MODEL = "claude-opus-4-6";
1065
+ var BLOCKED_MODELS = /* @__PURE__ */ new Set(["gpt-5-mini", "openai/gpt-5-mini"]);
1066
+ var CACHE_TTL = 10 * 60 * 1e3;
1067
+ var gatewayModelsCache = null;
1068
+ async function fetchGatewayModels(options) {
1069
+ const gatewayUrl = options?.gatewayUrl ?? process.env.ANTHROPIC_BASE_URL;
1070
+ if (!gatewayUrl) {
1071
+ return [];
1072
+ }
1073
+ if (gatewayModelsCache && gatewayModelsCache.url === gatewayUrl && Date.now() < gatewayModelsCache.expiry) {
1074
+ return gatewayModelsCache.models;
1075
+ }
1076
+ const modelsUrl = `${gatewayUrl}/v1/models`;
1077
+ try {
1078
+ const response = await fetch(modelsUrl);
1079
+ if (!response.ok) {
1080
+ return [];
1081
+ }
1082
+ const data = await response.json();
1083
+ const models = (data.data ?? []).filter((m) => !BLOCKED_MODELS.has(m.id));
1084
+ gatewayModelsCache = {
1085
+ models,
1086
+ expiry: Date.now() + CACHE_TTL,
1087
+ url: gatewayUrl
1088
+ };
1089
+ return models;
1090
+ } catch {
1091
+ return [];
1092
+ }
1093
+ }
1094
+ function isAnthropicModel(model) {
1095
+ if (model.owned_by) {
1096
+ return model.owned_by === "anthropic";
1097
+ }
1098
+ return model.id.startsWith("claude-") || model.id.startsWith("anthropic/");
1099
+ }
1100
+ var PROVIDER_PREFIXES = ["anthropic/", "openai/", "google-vertex/"];
1101
+ function formatGatewayModelName(model) {
1102
+ return formatModelId(model.id);
1103
+ }
1104
+ function formatModelId(modelId) {
1105
+ let cleanId = modelId;
1106
+ for (const prefix of PROVIDER_PREFIXES) {
1107
+ if (cleanId.startsWith(prefix)) {
1108
+ cleanId = cleanId.slice(prefix.length);
1109
+ break;
1110
+ }
1111
+ }
1112
+ cleanId = cleanId.replace(/(\d)-(\d)/g, "$1.$2");
1113
+ const words = cleanId.split(/[-_]/).map((word) => {
1114
+ if (word.match(/^[0-9.]+$/)) return word;
1115
+ return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
1116
+ });
1117
+ return words.join(" ");
1118
+ }
1119
+
1063
1120
  // src/utils/logger.ts
1064
1121
  var Logger = class _Logger {
1065
1122
  debugEnabled;
@@ -1317,60 +1374,6 @@ function unreachable(value, logger) {
1317
1374
  logger.error(`Unexpected case: ${valueAsString}`);
1318
1375
  }
1319
1376
 
1320
- // src/gateway-models.ts
1321
- var DEFAULT_GATEWAY_MODEL = "claude-opus-4-6";
1322
- var BLOCKED_MODELS = /* @__PURE__ */ new Set(["gpt-5-mini", "openai/gpt-5-mini"]);
1323
- var CACHE_TTL = 10 * 60 * 1e3;
1324
- var gatewayModelsCache = null;
1325
- async function fetchGatewayModels(options) {
1326
- const gatewayUrl = options?.gatewayUrl ?? process.env.ANTHROPIC_BASE_URL;
1327
- if (!gatewayUrl) {
1328
- return [];
1329
- }
1330
- if (gatewayModelsCache && gatewayModelsCache.url === gatewayUrl && Date.now() < gatewayModelsCache.expiry) {
1331
- return gatewayModelsCache.models;
1332
- }
1333
- const modelsUrl = `${gatewayUrl}/v1/models`;
1334
- try {
1335
- const response = await fetch(modelsUrl);
1336
- if (!response.ok) {
1337
- return [];
1338
- }
1339
- const data = await response.json();
1340
- const models = (data.data ?? []).filter((m) => !BLOCKED_MODELS.has(m.id));
1341
- gatewayModelsCache = {
1342
- models,
1343
- expiry: Date.now() + CACHE_TTL,
1344
- url: gatewayUrl
1345
- };
1346
- return models;
1347
- } catch {
1348
- return [];
1349
- }
1350
- }
1351
- function isAnthropicModel(model) {
1352
- if (model.owned_by) {
1353
- return model.owned_by === "anthropic";
1354
- }
1355
- return model.id.startsWith("claude-") || model.id.startsWith("anthropic/");
1356
- }
1357
- var PROVIDER_PREFIXES = ["anthropic/", "openai/", "google-vertex/"];
1358
- function formatGatewayModelName(model) {
1359
- let cleanId = model.id;
1360
- for (const prefix of PROVIDER_PREFIXES) {
1361
- if (cleanId.startsWith(prefix)) {
1362
- cleanId = cleanId.slice(prefix.length);
1363
- break;
1364
- }
1365
- }
1366
- cleanId = cleanId.replace(/(\d)-(\d)/g, "$1.$2");
1367
- const words = cleanId.split(/[-_]/).map((word) => {
1368
- if (word.match(/^[0-9.]+$/)) return word;
1369
- return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
1370
- });
1371
- return words.join(" ");
1372
- }
1373
-
1374
1377
  // src/adapters/base-acp-agent.ts
1375
1378
  var DEFAULT_CONTEXT_WINDOW = 2e5;
1376
1379
  var BaseAcpAgent = class {
@@ -3431,6 +3434,7 @@ async function canUseTool(context) {
3431
3434
 
3432
3435
  // src/adapters/claude/session/commands.ts
3433
3436
  var UNSUPPORTED_COMMANDS = [
3437
+ "clear",
3434
3438
  "context",
3435
3439
  "cost",
3436
3440
  "keybindings-help",
@@ -4095,8 +4099,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
4095
4099
  sessionCapabilities: {
4096
4100
  list: {},
4097
4101
  fork: {},
4098
- resume: {},
4099
- close: {}
4102
+ resume: {}
4100
4103
  },
4101
4104
  _meta: {
4102
4105
  posthog: {
@@ -5027,6 +5030,10 @@ function spawnCodexProcess(options) {
5027
5030
  function isGroupedOptions(options) {
5028
5031
  return options.length > 0 && "group" in options[0];
5029
5032
  }
5033
+ function formatOption(o) {
5034
+ if (!o.value) return o;
5035
+ return { ...o, name: formatModelId(o.value) };
5036
+ }
5030
5037
  function filterModelConfigOptions(msg, allowedModelIds) {
5031
5038
  const payload = msg;
5032
5039
  const configOptions = payload.result?.configOptions ?? payload.params?.update?.configOptions;
@@ -5037,9 +5044,7 @@ function filterModelConfigOptions(msg, allowedModelIds) {
5037
5044
  if (isGroupedOptions(options)) {
5038
5045
  const filteredOptions2 = options.map((group) => ({
5039
5046
  ...group,
5040
- options: (group.options ?? []).filter(
5041
- (o) => o?.value && allowedModelIds.has(o.value)
5042
- )
5047
+ options: (group.options ?? []).filter((o) => o?.value && allowedModelIds.has(o.value)).map(formatOption)
5043
5048
  }));
5044
5049
  const flat = filteredOptions2.flatMap((g) => g.options ?? []);
5045
5050
  const currentAllowed2 = opt.currentValue && allowedModelIds.has(opt.currentValue);
@@ -5051,9 +5056,7 @@ function filterModelConfigOptions(msg, allowedModelIds) {
5051
5056
  };
5052
5057
  }
5053
5058
  const valueOptions = options;
5054
- const filteredOptions = valueOptions.filter(
5055
- (o) => o?.value && allowedModelIds.has(o.value)
5056
- );
5059
+ const filteredOptions = valueOptions.filter((o) => o?.value && allowedModelIds.has(o.value)).map(formatOption);
5057
5060
  const currentAllowed = opt.currentValue && allowedModelIds.has(opt.currentValue);
5058
5061
  const nextCurrent = currentAllowed || filteredOptions.length === 0 ? opt.currentValue : filteredOptions[0]?.value;
5059
5062
  return {
@@ -10381,6 +10384,20 @@ var AsyncReaderWriterLock = class {
10381
10384
  };
10382
10385
 
10383
10386
  // ../git/dist/operation-manager.js
10387
+ function getCleanEnv() {
10388
+ const env = {};
10389
+ for (const [key, value] of Object.entries(process.env)) {
10390
+ if (value === void 0)
10391
+ continue;
10392
+ if (key === "ELECTRON_RUN_AS_NODE")
10393
+ continue;
10394
+ if (key.startsWith("ELECTRON_") || key.startsWith("CHROME_"))
10395
+ continue;
10396
+ env[key] = value;
10397
+ }
10398
+ env.ELECTRON_RUN_AS_NODE = "1";
10399
+ return env;
10400
+ }
10384
10401
  var GitOperationManagerImpl = class _GitOperationManagerImpl {
10385
10402
  repoStates = /* @__PURE__ */ new Map();
10386
10403
  cleanupInterval = null;
@@ -10416,9 +10433,9 @@ var GitOperationManagerImpl = class _GitOperationManagerImpl {
10416
10433
  const scopedGit = createGitClient(repoPath, {
10417
10434
  abortSignal: options.signal
10418
10435
  });
10419
- return operation(scopedGit.env({ ...process.env, GIT_OPTIONAL_LOCKS: "0" }));
10436
+ return operation(scopedGit.env({ ...getCleanEnv(), GIT_OPTIONAL_LOCKS: "0" }));
10420
10437
  }
10421
- const git = state.client.env({ ...process.env, GIT_OPTIONAL_LOCKS: "0" });
10438
+ const git = state.client.env({ ...getCleanEnv(), GIT_OPTIONAL_LOCKS: "0" });
10422
10439
  return operation(git);
10423
10440
  }
10424
10441
  async executeWrite(repoPath, operation, options) {
@@ -10435,9 +10452,9 @@ var GitOperationManagerImpl = class _GitOperationManagerImpl {
10435
10452
  const scopedGit = createGitClient(repoPath, {
10436
10453
  abortSignal: options.signal
10437
10454
  });
10438
- return await operation(scopedGit.env(process.env));
10455
+ return await operation(scopedGit.env(getCleanEnv()));
10439
10456
  }
10440
- return await operation(state.client.env(process.env));
10457
+ return await operation(state.client.env(getCleanEnv()));
10441
10458
  } catch (error) {
10442
10459
  if (options?.signal?.aborted) {
10443
10460
  await removeLock(repoPath).catch(() => {