@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/agent",
3
- "version": "2.3.81",
3
+ "version": "2.3.90",
4
4
  "repository": "https://github.com/PostHog/code",
5
5
  "description": "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
6
6
  "exports": {
@@ -1,5 +1,6 @@
1
1
  import { AgentSideConnection, ndJsonStream } from "@agentclientprotocol/sdk";
2
2
  import { POSTHOG_NOTIFICATIONS } from "../acp-extensions";
3
+ import { formatModelId } from "../gateway-models";
3
4
  import type { SessionLogWriter } from "../session-log-writer";
4
5
  import type { ProcessSpawnedCallback } from "../types";
5
6
  import { Logger } from "../utils/logger";
@@ -36,21 +37,27 @@ export type AcpConnection = {
36
37
 
37
38
  export type InProcessAcpConnection = AcpConnection;
38
39
 
40
+ type ModelOption = { value?: string; name?: string };
41
+ type ModelGroup = { group?: string; name?: string; options?: ModelOption[] };
42
+
39
43
  type ConfigOption = {
40
44
  id?: string;
41
45
  category?: string | null;
42
46
  currentValue?: string;
43
- options?: Array<
44
- { value?: string } | { group?: string; options?: Array<{ value?: string }> }
45
- >;
47
+ options?: Array<ModelOption | ModelGroup>;
46
48
  };
47
49
 
48
50
  function isGroupedOptions(
49
51
  options: NonNullable<ConfigOption["options"]>,
50
- ): options is Array<{ group?: string; options?: Array<{ value?: string }> }> {
52
+ ): options is ModelGroup[] {
51
53
  return options.length > 0 && "group" in options[0];
52
54
  }
53
55
 
56
+ function formatOption(o: ModelOption): ModelOption {
57
+ if (!o.value) return o;
58
+ return { ...o, name: formatModelId(o.value) };
59
+ }
60
+
54
61
  function filterModelConfigOptions(
55
62
  msg: Record<string, unknown>,
56
63
  allowedModelIds: Set<string>,
@@ -74,9 +81,9 @@ function filterModelConfigOptions(
74
81
  if (isGroupedOptions(options)) {
75
82
  const filteredOptions = options.map((group) => ({
76
83
  ...group,
77
- options: (group.options ?? []).filter(
78
- (o) => o?.value && allowedModelIds.has(o.value),
79
- ),
84
+ options: (group.options ?? [])
85
+ .filter((o) => o?.value && allowedModelIds.has(o.value))
86
+ .map(formatOption),
80
87
  }));
81
88
  const flat = filteredOptions.flatMap((g) => g.options ?? []);
82
89
  const currentAllowed =
@@ -91,10 +98,10 @@ function filterModelConfigOptions(
91
98
  };
92
99
  }
93
100
 
94
- const valueOptions = options as Array<{ value?: string }>;
95
- const filteredOptions = valueOptions.filter(
96
- (o) => o?.value && allowedModelIds.has(o.value),
97
- );
101
+ const valueOptions = options as ModelOption[];
102
+ const filteredOptions = valueOptions
103
+ .filter((o) => o?.value && allowedModelIds.has(o.value))
104
+ .map(formatOption);
98
105
  const currentAllowed =
99
106
  opt.currentValue && allowedModelIds.has(opt.currentValue);
100
107
  const nextCurrent =
@@ -88,7 +88,7 @@ import type {
88
88
  ToolUseCache,
89
89
  } from "./types";
90
90
 
91
- const SESSION_VALIDATION_TIMEOUT_MS = 10_000;
91
+ const SESSION_VALIDATION_TIMEOUT_MS = 30_000;
92
92
  const MAX_TITLE_LENGTH = 256;
93
93
  const LOCAL_ONLY_COMMANDS = new Set(["/context", "/heapdump", "/extra-usage"]);
94
94
 
@@ -143,7 +143,6 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
143
143
  list: {},
144
144
  fork: {},
145
145
  resume: {},
146
- close: {},
147
146
  },
148
147
  _meta: {
149
148
  posthog: {
package/src/agent.ts CHANGED
@@ -107,7 +107,7 @@ export class Agent {
107
107
  sanitizedModel = codexModelIds[0];
108
108
  }
109
109
  }
110
- if (!sanitizedModel) {
110
+ if (!sanitizedModel && options.adapter !== "codex") {
111
111
  sanitizedModel = DEFAULT_GATEWAY_MODEL;
112
112
  }
113
113
 
@@ -146,7 +146,11 @@ export function getProviderName(ownedBy: string): string {
146
146
  const PROVIDER_PREFIXES = ["anthropic/", "openai/", "google-vertex/"];
147
147
 
148
148
  export function formatGatewayModelName(model: GatewayModel): string {
149
- let cleanId = model.id;
149
+ return formatModelId(model.id);
150
+ }
151
+
152
+ export function formatModelId(modelId: string): string {
153
+ let cleanId = modelId;
150
154
  for (const prefix of PROVIDER_PREFIXES) {
151
155
  if (cleanId.startsWith(prefix)) {
152
156
  cleanId = cleanId.slice(prefix.length);