@posthog/agent 2.1.87 → 2.1.89
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 +1 -1
- package/dist/agent.js.map +1 -1
- package/dist/server/agent-server.js +24 -20
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +24 -20
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/server/agent-server.ts +26 -28
|
@@ -1183,7 +1183,7 @@ import { v7 as uuidv7 } from "uuid";
|
|
|
1183
1183
|
// package.json
|
|
1184
1184
|
var package_default = {
|
|
1185
1185
|
name: "@posthog/agent",
|
|
1186
|
-
version: "2.1.
|
|
1186
|
+
version: "2.1.89",
|
|
1187
1187
|
repository: "https://github.com/PostHog/twig",
|
|
1188
1188
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
1189
1189
|
exports: {
|
|
@@ -10458,16 +10458,18 @@ var AgentServer = class {
|
|
|
10458
10458
|
`Processing user message: ${content.substring(0, 100)}...`
|
|
10459
10459
|
);
|
|
10460
10460
|
const result = await this.session.clientConnection.prompt({
|
|
10461
|
-
sessionId: this.session.
|
|
10461
|
+
sessionId: this.session.acpSessionId,
|
|
10462
10462
|
prompt: [{ type: "text", text: content }]
|
|
10463
10463
|
});
|
|
10464
10464
|
return { stopReason: result.stopReason };
|
|
10465
10465
|
}
|
|
10466
10466
|
case POSTHOG_NOTIFICATIONS.CANCEL:
|
|
10467
10467
|
case "cancel": {
|
|
10468
|
-
this.logger.info("Cancel requested"
|
|
10468
|
+
this.logger.info("Cancel requested", {
|
|
10469
|
+
acpSessionId: this.session.acpSessionId
|
|
10470
|
+
});
|
|
10469
10471
|
await this.session.clientConnection.cancel({
|
|
10470
|
-
sessionId: this.session.
|
|
10472
|
+
sessionId: this.session.acpSessionId
|
|
10471
10473
|
});
|
|
10472
10474
|
return { cancelled: true };
|
|
10473
10475
|
}
|
|
@@ -10541,7 +10543,7 @@ var AgentServer = class {
|
|
|
10541
10543
|
protocolVersion: PROTOCOL_VERSION,
|
|
10542
10544
|
clientCapabilities: {}
|
|
10543
10545
|
});
|
|
10544
|
-
await clientConnection.newSession({
|
|
10546
|
+
const sessionResponse = await clientConnection.newSession({
|
|
10545
10547
|
cwd: this.config.repositoryPath,
|
|
10546
10548
|
mcpServers: [],
|
|
10547
10549
|
_meta: {
|
|
@@ -10550,8 +10552,14 @@ var AgentServer = class {
|
|
|
10550
10552
|
systemPrompt: { append: this.buildCloudSystemPrompt() }
|
|
10551
10553
|
}
|
|
10552
10554
|
});
|
|
10555
|
+
const acpSessionId = sessionResponse.sessionId;
|
|
10556
|
+
this.logger.info("ACP session created", {
|
|
10557
|
+
acpSessionId,
|
|
10558
|
+
runId: payload.run_id
|
|
10559
|
+
});
|
|
10553
10560
|
this.session = {
|
|
10554
10561
|
payload,
|
|
10562
|
+
acpSessionId,
|
|
10555
10563
|
acpConnection,
|
|
10556
10564
|
clientConnection,
|
|
10557
10565
|
treeTracker,
|
|
@@ -10581,28 +10589,18 @@ var AgentServer = class {
|
|
|
10581
10589
|
descriptionLength: task.description.length
|
|
10582
10590
|
});
|
|
10583
10591
|
const result = await this.session.clientConnection.prompt({
|
|
10584
|
-
sessionId:
|
|
10592
|
+
sessionId: this.session.acpSessionId,
|
|
10585
10593
|
prompt: [{ type: "text", text: task.description }]
|
|
10586
10594
|
});
|
|
10587
10595
|
this.logger.info("Initial task message completed", {
|
|
10588
10596
|
stopReason: result.stopReason
|
|
10589
10597
|
});
|
|
10590
|
-
const mode = this.getEffectiveMode(payload);
|
|
10591
|
-
if (mode === "background") {
|
|
10592
|
-
await this.session.logWriter.flushAll();
|
|
10593
|
-
await this.signalTaskComplete(payload, result.stopReason);
|
|
10594
|
-
} else {
|
|
10595
|
-
this.logger.info("Interactive mode - staying open for conversation");
|
|
10596
|
-
}
|
|
10597
10598
|
} catch (error) {
|
|
10598
10599
|
this.logger.error("Failed to send initial task message", error);
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
if (this.session) {
|
|
10602
|
-
await this.session.logWriter.flushAll();
|
|
10603
|
-
}
|
|
10604
|
-
await this.signalTaskComplete(payload, "error");
|
|
10600
|
+
if (this.session) {
|
|
10601
|
+
await this.session.logWriter.flushAll();
|
|
10605
10602
|
}
|
|
10603
|
+
await this.signalTaskComplete(payload, "error");
|
|
10606
10604
|
}
|
|
10607
10605
|
}
|
|
10608
10606
|
buildCloudSystemPrompt() {
|
|
@@ -10633,7 +10631,13 @@ Important:
|
|
|
10633
10631
|
});
|
|
10634
10632
|
}
|
|
10635
10633
|
}
|
|
10636
|
-
|
|
10634
|
+
if (stopReason !== "error") {
|
|
10635
|
+
this.logger.info("Skipping status update for non-error stop reason", {
|
|
10636
|
+
stopReason
|
|
10637
|
+
});
|
|
10638
|
+
return;
|
|
10639
|
+
}
|
|
10640
|
+
const status = "failed";
|
|
10637
10641
|
try {
|
|
10638
10642
|
await this.posthogAPI.updateTaskRun(payload.task_id, payload.run_id, {
|
|
10639
10643
|
status,
|