@posthog/agent 2.3.81 → 2.3.90
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/dist/agent.js +100 -98
- package/dist/agent.js.map +1 -1
- package/dist/gateway-models.d.ts +2 -1
- package/dist/gateway-models.js +5 -1
- package/dist/gateway-models.js.map +1 -1
- package/dist/posthog-api.js +1 -1
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +84 -68
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +84 -68
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/acp-connection.ts +18 -11
- package/src/adapters/claude/claude-agent.ts +1 -2
- package/src/agent.ts +1 -1
- package/src/gateway-models.ts +5 -1
package/dist/server/bin.cjs
CHANGED
|
@@ -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.
|
|
907
|
+
version: "2.3.90",
|
|
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 {
|
|
@@ -4056,7 +4059,7 @@ var SettingsManager = class {
|
|
|
4056
4059
|
};
|
|
4057
4060
|
|
|
4058
4061
|
// src/adapters/claude/claude-agent.ts
|
|
4059
|
-
var SESSION_VALIDATION_TIMEOUT_MS =
|
|
4062
|
+
var SESSION_VALIDATION_TIMEOUT_MS = 3e4;
|
|
4060
4063
|
var MAX_TITLE_LENGTH = 256;
|
|
4061
4064
|
var LOCAL_ONLY_COMMANDS = /* @__PURE__ */ new Set(["/context", "/heapdump", "/extra-usage"]);
|
|
4062
4065
|
function sanitizeTitle(text2) {
|
|
@@ -4095,8 +4098,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
4095
4098
|
sessionCapabilities: {
|
|
4096
4099
|
list: {},
|
|
4097
4100
|
fork: {},
|
|
4098
|
-
resume: {}
|
|
4099
|
-
close: {}
|
|
4101
|
+
resume: {}
|
|
4100
4102
|
},
|
|
4101
4103
|
_meta: {
|
|
4102
4104
|
posthog: {
|
|
@@ -5027,6 +5029,10 @@ function spawnCodexProcess(options) {
|
|
|
5027
5029
|
function isGroupedOptions(options) {
|
|
5028
5030
|
return options.length > 0 && "group" in options[0];
|
|
5029
5031
|
}
|
|
5032
|
+
function formatOption(o) {
|
|
5033
|
+
if (!o.value) return o;
|
|
5034
|
+
return { ...o, name: formatModelId(o.value) };
|
|
5035
|
+
}
|
|
5030
5036
|
function filterModelConfigOptions(msg, allowedModelIds) {
|
|
5031
5037
|
const payload = msg;
|
|
5032
5038
|
const configOptions = payload.result?.configOptions ?? payload.params?.update?.configOptions;
|
|
@@ -5037,9 +5043,7 @@ function filterModelConfigOptions(msg, allowedModelIds) {
|
|
|
5037
5043
|
if (isGroupedOptions(options)) {
|
|
5038
5044
|
const filteredOptions2 = options.map((group) => ({
|
|
5039
5045
|
...group,
|
|
5040
|
-
options: (group.options ?? []).filter(
|
|
5041
|
-
(o) => o?.value && allowedModelIds.has(o.value)
|
|
5042
|
-
)
|
|
5046
|
+
options: (group.options ?? []).filter((o) => o?.value && allowedModelIds.has(o.value)).map(formatOption)
|
|
5043
5047
|
}));
|
|
5044
5048
|
const flat = filteredOptions2.flatMap((g) => g.options ?? []);
|
|
5045
5049
|
const currentAllowed2 = opt.currentValue && allowedModelIds.has(opt.currentValue);
|
|
@@ -5051,9 +5055,7 @@ function filterModelConfigOptions(msg, allowedModelIds) {
|
|
|
5051
5055
|
};
|
|
5052
5056
|
}
|
|
5053
5057
|
const valueOptions = options;
|
|
5054
|
-
const filteredOptions = valueOptions.filter(
|
|
5055
|
-
(o) => o?.value && allowedModelIds.has(o.value)
|
|
5056
|
-
);
|
|
5058
|
+
const filteredOptions = valueOptions.filter((o) => o?.value && allowedModelIds.has(o.value)).map(formatOption);
|
|
5057
5059
|
const currentAllowed = opt.currentValue && allowedModelIds.has(opt.currentValue);
|
|
5058
5060
|
const nextCurrent = currentAllowed || filteredOptions.length === 0 ? opt.currentValue : filteredOptions[0]?.value;
|
|
5059
5061
|
return {
|
|
@@ -10381,6 +10383,20 @@ var AsyncReaderWriterLock = class {
|
|
|
10381
10383
|
};
|
|
10382
10384
|
|
|
10383
10385
|
// ../git/dist/operation-manager.js
|
|
10386
|
+
function getCleanEnv() {
|
|
10387
|
+
const env = {};
|
|
10388
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
10389
|
+
if (value === void 0)
|
|
10390
|
+
continue;
|
|
10391
|
+
if (key === "ELECTRON_RUN_AS_NODE")
|
|
10392
|
+
continue;
|
|
10393
|
+
if (key.startsWith("ELECTRON_") || key.startsWith("CHROME_"))
|
|
10394
|
+
continue;
|
|
10395
|
+
env[key] = value;
|
|
10396
|
+
}
|
|
10397
|
+
env.ELECTRON_RUN_AS_NODE = "1";
|
|
10398
|
+
return env;
|
|
10399
|
+
}
|
|
10384
10400
|
var GitOperationManagerImpl = class _GitOperationManagerImpl {
|
|
10385
10401
|
repoStates = /* @__PURE__ */ new Map();
|
|
10386
10402
|
cleanupInterval = null;
|
|
@@ -10416,9 +10432,9 @@ var GitOperationManagerImpl = class _GitOperationManagerImpl {
|
|
|
10416
10432
|
const scopedGit = createGitClient(repoPath, {
|
|
10417
10433
|
abortSignal: options.signal
|
|
10418
10434
|
});
|
|
10419
|
-
return operation(scopedGit.env({ ...
|
|
10435
|
+
return operation(scopedGit.env({ ...getCleanEnv(), GIT_OPTIONAL_LOCKS: "0" }));
|
|
10420
10436
|
}
|
|
10421
|
-
const git = state.client.env({ ...
|
|
10437
|
+
const git = state.client.env({ ...getCleanEnv(), GIT_OPTIONAL_LOCKS: "0" });
|
|
10422
10438
|
return operation(git);
|
|
10423
10439
|
}
|
|
10424
10440
|
async executeWrite(repoPath, operation, options) {
|
|
@@ -10435,9 +10451,9 @@ var GitOperationManagerImpl = class _GitOperationManagerImpl {
|
|
|
10435
10451
|
const scopedGit = createGitClient(repoPath, {
|
|
10436
10452
|
abortSignal: options.signal
|
|
10437
10453
|
});
|
|
10438
|
-
return await operation(scopedGit.env(
|
|
10454
|
+
return await operation(scopedGit.env(getCleanEnv()));
|
|
10439
10455
|
}
|
|
10440
|
-
return await operation(state.client.env(
|
|
10456
|
+
return await operation(state.client.env(getCleanEnv()));
|
|
10441
10457
|
} catch (error) {
|
|
10442
10458
|
if (options?.signal?.aborted) {
|
|
10443
10459
|
await removeLock(repoPath).catch(() => {
|