@posthog/agent 2.3.459 → 2.3.466

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.459",
3
+ "version": "2.3.466",
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": {
@@ -103,8 +103,8 @@
103
103
  "typescript": "^5.5.0",
104
104
  "vitest": "^2.1.8",
105
105
  "@posthog/shared": "1.0.0",
106
- "@posthog/enricher": "1.0.0",
107
- "@posthog/git": "1.0.0"
106
+ "@posthog/git": "1.0.0",
107
+ "@posthog/enricher": "1.0.0"
108
108
  },
109
109
  "dependencies": {
110
110
  "@agentclientprotocol/sdk": "0.19.0",
@@ -60,6 +60,7 @@ import {
60
60
  } from "../../utils/streams";
61
61
  import { BaseAcpAgent, type BaseSession } from "../base-acp-agent";
62
62
  import { createCodexClient } from "./codex-client";
63
+ import { normalizeCodexConfigOptions } from "./models";
63
64
  import {
64
65
  type CodexSessionState,
65
66
  createSessionState,
@@ -265,6 +266,9 @@ export class CodexAcpAgent extends BaseAcpAgent {
265
266
  const requestedPermissionMode = toCodexPermissionMode(meta?.permissionMode);
266
267
 
267
268
  const response = await this.codexConnection.newSession(params);
269
+ response.configOptions = normalizeCodexConfigOptions(
270
+ response.configOptions,
271
+ );
268
272
 
269
273
  // Initialize session state
270
274
  this.sessionState = createSessionState(response.sessionId, params.cwd, {
@@ -302,6 +306,9 @@ export class CodexAcpAgent extends BaseAcpAgent {
302
306
 
303
307
  async loadSession(params: LoadSessionRequest): Promise<LoadSessionResponse> {
304
308
  const response = await this.codexConnection.loadSession(params);
309
+ response.configOptions = normalizeCodexConfigOptions(
310
+ response.configOptions,
311
+ );
305
312
  const meta = params._meta as NewSessionMeta | undefined;
306
313
  const currentPermissionMode = getCurrentPermissionMode(
307
314
  response.modes?.currentModeId,
@@ -341,6 +348,9 @@ export class CodexAcpAgent extends BaseAcpAgent {
341
348
  cwd: params.cwd,
342
349
  mcpServers: params.mcpServers ?? [],
343
350
  });
351
+ loadResponse.configOptions = normalizeCodexConfigOptions(
352
+ loadResponse.configOptions,
353
+ );
344
354
 
345
355
  const meta = params._meta as NewSessionMeta | undefined;
346
356
  const currentPermissionMode = getCurrentPermissionMode(
@@ -380,6 +390,9 @@ export class CodexAcpAgent extends BaseAcpAgent {
380
390
  mcpServers: params.mcpServers ?? [],
381
391
  _meta: params._meta,
382
392
  });
393
+ newResponse.configOptions = normalizeCodexConfigOptions(
394
+ newResponse.configOptions,
395
+ );
383
396
 
384
397
  const meta = params._meta as NewSessionMeta | undefined;
385
398
  const requestedPermissionMode = toCodexPermissionMode(meta?.permissionMode);
@@ -665,6 +678,9 @@ export class CodexAcpAgent extends BaseAcpAgent {
665
678
  ): Promise<SetSessionConfigOptionResponse> {
666
679
  const response = await this.codexConnection.setSessionConfigOption(params);
667
680
  if (response.configOptions) {
681
+ response.configOptions = normalizeCodexConfigOptions(
682
+ response.configOptions,
683
+ ) as typeof response.configOptions;
668
684
  this.sessionState.configOptions = response.configOptions;
669
685
  }
670
686
  if (params.configId === "mode" && typeof params.value === "string") {
@@ -1,3 +1,9 @@
1
+ import type {
2
+ SessionConfigOption,
3
+ SessionConfigSelectGroup,
4
+ SessionConfigSelectOption,
5
+ } from "@agentclientprotocol/sdk";
6
+
1
7
  interface ReasoningEffortOption {
2
8
  value: string;
3
9
  name: string;
@@ -14,3 +20,47 @@ export function getReasoningEffortOptions(
14
20
  ): ReasoningEffortOption[] {
15
21
  return CODEX_REASONING_EFFORT_OPTIONS;
16
22
  }
23
+
24
+ const CODEX_ACRONYMS: Record<string, string> = {
25
+ gpt: "GPT",
26
+ };
27
+
28
+ export function formatCodexModelName(value: string): string {
29
+ const normalized = value.replace(/(\d)-(\d)/g, "$1.$2");
30
+ return normalized
31
+ .split("-")
32
+ .map((part) => {
33
+ const lower = part.toLowerCase();
34
+ if (CODEX_ACRONYMS[lower]) return CODEX_ACRONYMS[lower];
35
+ if (/^[0-9.]+$/.test(part)) return part;
36
+ return part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
37
+ })
38
+ .join("-");
39
+ }
40
+
41
+ export function normalizeCodexConfigOptions(
42
+ configOptions: SessionConfigOption[] | null | undefined,
43
+ ): SessionConfigOption[] | null | undefined {
44
+ if (!configOptions) return configOptions;
45
+ const formatOption = (
46
+ opt: SessionConfigSelectOption,
47
+ ): SessionConfigSelectOption => ({
48
+ ...opt,
49
+ name: formatCodexModelName(opt.value),
50
+ });
51
+ return configOptions.map((option) => {
52
+ if (option.category !== "model" || option.type !== "select") return option;
53
+ const options = option.options;
54
+ if (options.length === 0) return option;
55
+ const isGroup = "group" in options[0];
56
+ return {
57
+ ...option,
58
+ options: isGroup
59
+ ? (options as SessionConfigSelectGroup[]).map((group) => ({
60
+ ...group,
61
+ options: group.options.map(formatOption),
62
+ }))
63
+ : (options as SessionConfigSelectOption[]).map(formatOption),
64
+ } as SessionConfigOption;
65
+ });
66
+ }
@@ -18,7 +18,7 @@ export interface HandoffCheckpointTrackerConfig {
18
18
  logger?: Logger;
19
19
  }
20
20
 
21
- type ArtifactTransfer<T extends object = {}> = T & {
21
+ type ArtifactTransfer<T extends object = Record<string, never>> = T & {
22
22
  rawBytes: number;
23
23
  wireBytes: number;
24
24
  };