@posthog/agent 2.3.84 → 2.3.92
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 -97
- 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 -67
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +84 -67
- 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 +0 -1
- package/src/adapters/claude/session/commands.ts +1 -0
- package/src/agent.ts +1 -1
- package/src/gateway-models.ts +5 -1
package/package.json
CHANGED
|
@@ -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
|
|
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 ?? [])
|
|
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
|
|
95
|
-
const filteredOptions = valueOptions
|
|
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 =
|
package/src/agent.ts
CHANGED
package/src/gateway-models.ts
CHANGED
|
@@ -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
|
-
|
|
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);
|