@posthog/agent 2.1.62 → 2.1.69

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AcpConnection, a as AcpConnectionConfig, b as Agent, c as AgentAdapter, C as CodexProcessOptions, I as InProcessAcpConnection, O as OtelLogConfig, d as OtelLogWriter, S as SessionContext, e as SessionLogWriter, f as SessionLogWriterOptions, g as createAcpConnection } from './agent-9gv5HohC.js';
1
+ export { A as AcpConnection, a as AcpConnectionConfig, b as Agent, c as AgentAdapter, C as CodexProcessOptions, I as InProcessAcpConnection, O as OtelLogConfig, d as OtelLogWriter, S as SessionContext, e as SessionLogWriter, f as SessionLogWriterOptions, g as createAcpConnection } from './agent-DK1apkaG.js';
2
2
  import { McpServerConfig } from '@anthropic-ai/claude-agent-sdk';
3
3
  import { L as Logger } from './logger-DDBiMOOD.js';
4
4
  export { a as LoggerConfig } from './logger-DDBiMOOD.js';
package/dist/index.js CHANGED
@@ -1174,7 +1174,7 @@ import { v7 as uuidv7 } from "uuid";
1174
1174
  // package.json
1175
1175
  var package_default = {
1176
1176
  name: "@posthog/agent",
1177
- version: "2.1.62",
1177
+ version: "2.1.69",
1178
1178
  repository: "https://github.com/PostHog/twig",
1179
1179
  description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
1180
1180
  exports: {
@@ -1292,6 +1292,16 @@ var package_default = {
1292
1292
  };
1293
1293
 
1294
1294
  // src/utils/common.ts
1295
+ async function withTimeout(operation, timeoutMs) {
1296
+ const timeoutPromise = new Promise(
1297
+ (resolve4) => setTimeout(() => resolve4({ result: "timeout" }), timeoutMs)
1298
+ );
1299
+ const operationPromise = operation.then((value) => ({
1300
+ result: "success",
1301
+ value
1302
+ }));
1303
+ return Promise.race([operationPromise, timeoutPromise]);
1304
+ }
1295
1305
  var IS_ROOT = typeof process !== "undefined" && (process.geteuid?.() ?? process.getuid?.()) === 0;
1296
1306
  function unreachable(value, logger) {
1297
1307
  let valueAsString;
@@ -3128,6 +3138,7 @@ function parseMcpServers(params) {
3128
3138
  }
3129
3139
 
3130
3140
  // src/adapters/claude/session/models.ts
3141
+ var DEFAULT_MODEL = "opus";
3131
3142
  var GATEWAY_TO_SDK_MODEL = {
3132
3143
  "claude-opus-4-5": "opus",
3133
3144
  "claude-opus-4-6": "opus",
@@ -3315,6 +3326,7 @@ function clearStatsigCache() {
3315
3326
  }
3316
3327
 
3317
3328
  // src/adapters/claude/claude-agent.ts
3329
+ var SESSION_VALIDATION_TIMEOUT_MS = 1e4;
3318
3330
  var ClaudeAcpAgent = class extends BaseAcpAgent {
3319
3331
  adapterName = "claude";
3320
3332
  toolUseCache;
@@ -3388,6 +3400,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
3388
3400
  onProcessExited: this.options?.onProcessExited
3389
3401
  });
3390
3402
  const input = new Pushable();
3403
+ options.model = DEFAULT_MODEL;
3391
3404
  const q = query({ prompt: input, options });
3392
3405
  const session = this.createSession(
3393
3406
  sessionId,
@@ -3409,7 +3422,10 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
3409
3422
  const modelOptions = await this.getModelConfigOptions();
3410
3423
  this.deferBackgroundFetches(q, sessionId, mcpServers);
3411
3424
  session.modelId = modelOptions.currentModelId;
3412
- await this.trySetModel(q, modelOptions.currentModelId);
3425
+ const resolvedSdkModel = toSdkModelId(modelOptions.currentModelId);
3426
+ if (resolvedSdkModel !== DEFAULT_MODEL) {
3427
+ await this.trySetModel(q, modelOptions.currentModelId);
3428
+ }
3413
3429
  const configOptions = await this.buildConfigOptions(modelOptions);
3414
3430
  return {
3415
3431
  sessionId,
@@ -3442,6 +3458,13 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
3442
3458
  });
3443
3459
  session.taskRunId = meta?.taskRunId;
3444
3460
  this.registerPersistence(sessionId, meta);
3461
+ const validation = await withTimeout(
3462
+ q.initializationResult(),
3463
+ SESSION_VALIDATION_TIMEOUT_MS
3464
+ );
3465
+ if (validation.result === "timeout") {
3466
+ throw new Error("Session validation timed out");
3467
+ }
3445
3468
  this.deferBackgroundFetches(q, sessionId, mcpServers);
3446
3469
  const configOptions = await this.buildConfigOptions();
3447
3470
  return { configOptions };
@@ -4603,11 +4626,9 @@ var Agent = class {
4603
4626
  acpConnection;
4604
4627
  taskRunId;
4605
4628
  sessionLogWriter;
4606
- debug;
4607
4629
  constructor(config) {
4608
- this.debug = config.debug || false;
4609
4630
  this.logger = new Logger({
4610
- debug: this.debug,
4631
+ debug: config.debug || false,
4611
4632
  prefix: "[PostHog Agent]",
4612
4633
  onLog: config.onLog
4613
4634
  });