@posthog/agent 2.1.124 → 2.1.131
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 +9 -40
- package/dist/agent.js.map +1 -1
- package/dist/claude-cli/cli.js +2420 -2030
- package/dist/posthog-api.js +3 -3
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +11 -42
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +26 -57
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +3 -3
- package/src/adapters/claude/conversion/sdk-to-acp.ts +2 -0
- package/src/adapters/codex/spawn.ts +4 -3
- package/src/session-log-writer.ts +1 -36
- package/src/test/mocks/claude-sdk.ts +7 -0
package/dist/agent.js
CHANGED
|
@@ -276,7 +276,7 @@ import { v7 as uuidv7 } from "uuid";
|
|
|
276
276
|
// package.json
|
|
277
277
|
var package_default = {
|
|
278
278
|
name: "@posthog/agent",
|
|
279
|
-
version: "2.1.
|
|
279
|
+
version: "2.1.131",
|
|
280
280
|
repository: "https://github.com/PostHog/twig",
|
|
281
281
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
282
282
|
exports: {
|
|
@@ -361,8 +361,8 @@ var package_default = {
|
|
|
361
361
|
},
|
|
362
362
|
dependencies: {
|
|
363
363
|
"@agentclientprotocol/sdk": "^0.14.0",
|
|
364
|
-
"@anthropic-ai/claude-agent-sdk": "0.2.
|
|
365
|
-
"@anthropic-ai/sdk": "^0.
|
|
364
|
+
"@anthropic-ai/claude-agent-sdk": "0.2.63",
|
|
365
|
+
"@anthropic-ai/sdk": "^0.78.0",
|
|
366
366
|
"@hono/node-server": "^1.19.9",
|
|
367
367
|
"@opentelemetry/api-logs": "^0.208.0",
|
|
368
368
|
"@opentelemetry/exporter-logs-otlp-http": "^0.208.0",
|
|
@@ -1465,6 +1465,8 @@ function processContentChunk(chunk, role, ctx) {
|
|
|
1465
1465
|
case "citations_delta":
|
|
1466
1466
|
case "signature_delta":
|
|
1467
1467
|
case "container_upload":
|
|
1468
|
+
case "compaction":
|
|
1469
|
+
case "compaction_delta":
|
|
1468
1470
|
return null;
|
|
1469
1471
|
default:
|
|
1470
1472
|
unreachable(chunk, ctx.logger);
|
|
@@ -2952,6 +2954,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
2952
2954
|
// src/adapters/codex/spawn.ts
|
|
2953
2955
|
import { spawn as spawn2 } from "child_process";
|
|
2954
2956
|
import { existsSync as existsSync3 } from "fs";
|
|
2957
|
+
import { delimiter, dirname } from "path";
|
|
2955
2958
|
function buildConfigArgs(options) {
|
|
2956
2959
|
const args = [];
|
|
2957
2960
|
args.push("-c", `features.remote_models=false`);
|
|
@@ -2992,8 +2995,8 @@ function spawnCodexProcess(options) {
|
|
|
2992
2995
|
}
|
|
2993
2996
|
const { command, args } = findCodexBinary(options);
|
|
2994
2997
|
if (options.binaryPath && existsSync3(options.binaryPath)) {
|
|
2995
|
-
const binDir = options.binaryPath
|
|
2996
|
-
env.PATH = `${binDir}
|
|
2998
|
+
const binDir = dirname(options.binaryPath);
|
|
2999
|
+
env.PATH = `${binDir}${delimiter}${env.PATH ?? ""}`;
|
|
2997
3000
|
}
|
|
2998
3001
|
logger.info("Spawning codex-acp process", {
|
|
2999
3002
|
command,
|
|
@@ -3010,7 +3013,7 @@ function spawnCodexProcess(options) {
|
|
|
3010
3013
|
detached: process.platform !== "win32"
|
|
3011
3014
|
});
|
|
3012
3015
|
child.stderr?.on("data", (data) => {
|
|
3013
|
-
logger.
|
|
3016
|
+
logger.error("codex-acp stderr:", data.toString());
|
|
3014
3017
|
});
|
|
3015
3018
|
child.on("error", (err) => {
|
|
3016
3019
|
logger.error("codex-acp process error:", err);
|
|
@@ -3585,7 +3588,6 @@ var SessionLogWriter = class _SessionLogWriter {
|
|
|
3585
3588
|
lastFlushAttemptTime = /* @__PURE__ */ new Map();
|
|
3586
3589
|
retryCounts = /* @__PURE__ */ new Map();
|
|
3587
3590
|
sessions = /* @__PURE__ */ new Map();
|
|
3588
|
-
messageCounts = /* @__PURE__ */ new Map();
|
|
3589
3591
|
logger;
|
|
3590
3592
|
localCachePath;
|
|
3591
3593
|
constructor(options = {}) {
|
|
@@ -3595,19 +3597,6 @@ var SessionLogWriter = class _SessionLogWriter {
|
|
|
3595
3597
|
}
|
|
3596
3598
|
async flushAll() {
|
|
3597
3599
|
const sessionIds = [...this.sessions.keys()];
|
|
3598
|
-
const pendingCounts = sessionIds.map((id) => {
|
|
3599
|
-
const session = this.sessions.get(id);
|
|
3600
|
-
return {
|
|
3601
|
-
taskId: session?.context.taskId,
|
|
3602
|
-
runId: session?.context.runId,
|
|
3603
|
-
pending: this.pendingEntries.get(id)?.length ?? 0,
|
|
3604
|
-
messages: this.messageCounts.get(id) ?? 0
|
|
3605
|
-
};
|
|
3606
|
-
});
|
|
3607
|
-
this.logger.info("flushAll called", {
|
|
3608
|
-
sessions: sessionIds.length,
|
|
3609
|
-
pending: pendingCounts
|
|
3610
|
-
});
|
|
3611
3600
|
const flushPromises = [];
|
|
3612
3601
|
for (const sessionId of sessionIds) {
|
|
3613
3602
|
flushPromises.push(this.flush(sessionId));
|
|
@@ -3651,15 +3640,6 @@ var SessionLogWriter = class _SessionLogWriter {
|
|
|
3651
3640
|
});
|
|
3652
3641
|
return;
|
|
3653
3642
|
}
|
|
3654
|
-
const count = (this.messageCounts.get(sessionId) ?? 0) + 1;
|
|
3655
|
-
this.messageCounts.set(sessionId, count);
|
|
3656
|
-
if (count % 10 === 1) {
|
|
3657
|
-
this.logger.info("Messages received", {
|
|
3658
|
-
count,
|
|
3659
|
-
taskId: session.context.taskId,
|
|
3660
|
-
runId: session.context.runId
|
|
3661
|
-
});
|
|
3662
|
-
}
|
|
3663
3643
|
try {
|
|
3664
3644
|
const message = JSON.parse(line);
|
|
3665
3645
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3708,12 +3688,6 @@ var SessionLogWriter = class _SessionLogWriter {
|
|
|
3708
3688
|
this.emitCoalescedMessage(sessionId, session);
|
|
3709
3689
|
const pending = this.pendingEntries.get(sessionId);
|
|
3710
3690
|
if (!this.posthogAPI || !pending?.length) {
|
|
3711
|
-
this.logger.info("flush: nothing to persist", {
|
|
3712
|
-
taskId: session.context.taskId,
|
|
3713
|
-
runId: session.context.runId,
|
|
3714
|
-
hasPosthogAPI: !!this.posthogAPI,
|
|
3715
|
-
pendingCount: pending?.length ?? 0
|
|
3716
|
-
});
|
|
3717
3691
|
return;
|
|
3718
3692
|
}
|
|
3719
3693
|
this.pendingEntries.delete(sessionId);
|
|
@@ -3730,11 +3704,6 @@ var SessionLogWriter = class _SessionLogWriter {
|
|
|
3730
3704
|
pending
|
|
3731
3705
|
);
|
|
3732
3706
|
this.retryCounts.set(sessionId, 0);
|
|
3733
|
-
this.logger.info("Flushed session logs", {
|
|
3734
|
-
taskId: session.context.taskId,
|
|
3735
|
-
runId: session.context.runId,
|
|
3736
|
-
entryCount: pending.length
|
|
3737
|
-
});
|
|
3738
3707
|
} catch (error) {
|
|
3739
3708
|
const retryCount = (this.retryCounts.get(sessionId) ?? 0) + 1;
|
|
3740
3709
|
this.retryCounts.set(sessionId, retryCount);
|