@posthog/agent 2.3.202 → 2.3.209

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.202",
907
+ version: "2.3.209",
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: {
@@ -1066,6 +1066,10 @@ var POSTHOG_NOTIFICATIONS = {
1066
1066
  /** Token usage update for a session turn */
1067
1067
  USAGE_UPDATE: "_posthog/usage_update"
1068
1068
  };
1069
+ function isNotification(method, notification) {
1070
+ if (!method) return false;
1071
+ return method === notification || method === `_${notification}`;
1072
+ }
1069
1073
 
1070
1074
  // src/adapters/acp-connection.ts
1071
1075
  var import_sdk4 = require("@agentclientprotocol/sdk");
@@ -2689,7 +2693,7 @@ async function handleSystemMessage(message, context) {
2689
2693
  case "init":
2690
2694
  break;
2691
2695
  case "compact_boundary":
2692
- await client.extNotification("_posthog/compact_boundary", {
2696
+ await client.extNotification(POSTHOG_NOTIFICATIONS.COMPACT_BOUNDARY, {
2693
2697
  sessionId,
2694
2698
  trigger: message.compact_metadata.trigger,
2695
2699
  preTokens: message.compact_metadata.pre_tokens,
@@ -2705,7 +2709,7 @@ async function handleSystemMessage(message, context) {
2705
2709
  case "status":
2706
2710
  if (message.status === "compacting") {
2707
2711
  logger.info("Session compacting started", { sessionId });
2708
- await client.extNotification("_posthog/status", {
2712
+ await client.extNotification(POSTHOG_NOTIFICATIONS.STATUS, {
2709
2713
  sessionId,
2710
2714
  status: "compacting"
2711
2715
  });
@@ -2718,7 +2722,7 @@ async function handleSystemMessage(message, context) {
2718
2722
  status: message.status,
2719
2723
  summary: message.summary
2720
2724
  });
2721
- await client.extNotification("_posthog/task_notification", {
2725
+ await client.extNotification(POSTHOG_NOTIFICATIONS.TASK_NOTIFICATION, {
2722
2726
  sessionId,
2723
2727
  taskId: message.task_id,
2724
2728
  status: message.status,
@@ -4350,6 +4354,14 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
4350
4354
  if (message.subtype === "compact_boundary") {
4351
4355
  lastAssistantTotalUsage = 0;
4352
4356
  promptReplayed = true;
4357
+ await this.client.sessionUpdate({
4358
+ sessionId: params.sessionId,
4359
+ update: {
4360
+ sessionUpdate: "usage_update",
4361
+ used: 0,
4362
+ size: lastContextWindowSize
4363
+ }
4364
+ });
4353
4365
  }
4354
4366
  if (message.subtype === "local_command_output") {
4355
4367
  promptReplayed = true;
@@ -4465,7 +4477,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
4465
4477
  }
4466
4478
  if ("usage" in message.message && message.parent_tool_use_id === null) {
4467
4479
  const usage = message.message.usage;
4468
- lastAssistantTotalUsage = usage.input_tokens + usage.cache_read_input_tokens + usage.cache_creation_input_tokens;
4480
+ lastAssistantTotalUsage = usage.input_tokens + usage.output_tokens + usage.cache_read_input_tokens + usage.cache_creation_input_tokens;
4469
4481
  await this.client.sessionUpdate({
4470
4482
  sessionId: params.sessionId,
4471
4483
  update: {
@@ -4746,7 +4758,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
4746
4758
  settingsManager.getSettings().model || meta?.model || void 0
4747
4759
  ),
4748
4760
  ...meta?.taskRunId ? [
4749
- this.client.extNotification("_posthog/sdk_session", {
4761
+ this.client.extNotification(POSTHOG_NOTIFICATIONS.SDK_SESSION, {
4750
4762
  taskRunId: meta.taskRunId,
4751
4763
  sessionId,
4752
4764
  adapter: "claude"
@@ -11521,11 +11533,12 @@ var ResumeSaga = class extends Saga {
11521
11533
  };
11522
11534
  }
11523
11535
  findLatestTreeSnapshot(entries) {
11524
- const sdkPrefixedMethod = `_${POSTHOG_NOTIFICATIONS.TREE_SNAPSHOT}`;
11525
11536
  for (let i = entries.length - 1; i >= 0; i--) {
11526
11537
  const entry = entries[i];
11527
- const method = entry.notification?.method;
11528
- if (method === sdkPrefixedMethod || method === POSTHOG_NOTIFICATIONS.TREE_SNAPSHOT) {
11538
+ if (isNotification(
11539
+ entry.notification?.method,
11540
+ POSTHOG_NOTIFICATIONS.TREE_SNAPSHOT
11541
+ )) {
11529
11542
  const params = entry.notification.params;
11530
11543
  if (params?.treeHash) {
11531
11544
  return params;