@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
package/dist/server/bin.cjs
CHANGED
|
@@ -1175,7 +1175,7 @@ var import_uuid = require("uuid");
|
|
|
1175
1175
|
// package.json
|
|
1176
1176
|
var package_default = {
|
|
1177
1177
|
name: "@posthog/agent",
|
|
1178
|
-
version: "2.1.
|
|
1178
|
+
version: "2.1.89",
|
|
1179
1179
|
repository: "https://github.com/PostHog/twig",
|
|
1180
1180
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
1181
1181
|
exports: {
|
|
@@ -10450,16 +10450,18 @@ var AgentServer = class {
|
|
|
10450
10450
|
`Processing user message: ${content.substring(0, 100)}...`
|
|
10451
10451
|
);
|
|
10452
10452
|
const result = await this.session.clientConnection.prompt({
|
|
10453
|
-
sessionId: this.session.
|
|
10453
|
+
sessionId: this.session.acpSessionId,
|
|
10454
10454
|
prompt: [{ type: "text", text: content }]
|
|
10455
10455
|
});
|
|
10456
10456
|
return { stopReason: result.stopReason };
|
|
10457
10457
|
}
|
|
10458
10458
|
case POSTHOG_NOTIFICATIONS.CANCEL:
|
|
10459
10459
|
case "cancel": {
|
|
10460
|
-
this.logger.info("Cancel requested"
|
|
10460
|
+
this.logger.info("Cancel requested", {
|
|
10461
|
+
acpSessionId: this.session.acpSessionId
|
|
10462
|
+
});
|
|
10461
10463
|
await this.session.clientConnection.cancel({
|
|
10462
|
-
sessionId: this.session.
|
|
10464
|
+
sessionId: this.session.acpSessionId
|
|
10463
10465
|
});
|
|
10464
10466
|
return { cancelled: true };
|
|
10465
10467
|
}
|
|
@@ -10533,7 +10535,7 @@ var AgentServer = class {
|
|
|
10533
10535
|
protocolVersion: import_sdk4.PROTOCOL_VERSION,
|
|
10534
10536
|
clientCapabilities: {}
|
|
10535
10537
|
});
|
|
10536
|
-
await clientConnection.newSession({
|
|
10538
|
+
const sessionResponse = await clientConnection.newSession({
|
|
10537
10539
|
cwd: this.config.repositoryPath,
|
|
10538
10540
|
mcpServers: [],
|
|
10539
10541
|
_meta: {
|
|
@@ -10542,8 +10544,14 @@ var AgentServer = class {
|
|
|
10542
10544
|
systemPrompt: { append: this.buildCloudSystemPrompt() }
|
|
10543
10545
|
}
|
|
10544
10546
|
});
|
|
10547
|
+
const acpSessionId = sessionResponse.sessionId;
|
|
10548
|
+
this.logger.info("ACP session created", {
|
|
10549
|
+
acpSessionId,
|
|
10550
|
+
runId: payload.run_id
|
|
10551
|
+
});
|
|
10545
10552
|
this.session = {
|
|
10546
10553
|
payload,
|
|
10554
|
+
acpSessionId,
|
|
10547
10555
|
acpConnection,
|
|
10548
10556
|
clientConnection,
|
|
10549
10557
|
treeTracker,
|
|
@@ -10573,28 +10581,18 @@ var AgentServer = class {
|
|
|
10573
10581
|
descriptionLength: task.description.length
|
|
10574
10582
|
});
|
|
10575
10583
|
const result = await this.session.clientConnection.prompt({
|
|
10576
|
-
sessionId:
|
|
10584
|
+
sessionId: this.session.acpSessionId,
|
|
10577
10585
|
prompt: [{ type: "text", text: task.description }]
|
|
10578
10586
|
});
|
|
10579
10587
|
this.logger.info("Initial task message completed", {
|
|
10580
10588
|
stopReason: result.stopReason
|
|
10581
10589
|
});
|
|
10582
|
-
const mode = this.getEffectiveMode(payload);
|
|
10583
|
-
if (mode === "background") {
|
|
10584
|
-
await this.session.logWriter.flushAll();
|
|
10585
|
-
await this.signalTaskComplete(payload, result.stopReason);
|
|
10586
|
-
} else {
|
|
10587
|
-
this.logger.info("Interactive mode - staying open for conversation");
|
|
10588
|
-
}
|
|
10589
10590
|
} catch (error) {
|
|
10590
10591
|
this.logger.error("Failed to send initial task message", error);
|
|
10591
|
-
|
|
10592
|
-
|
|
10593
|
-
if (this.session) {
|
|
10594
|
-
await this.session.logWriter.flushAll();
|
|
10595
|
-
}
|
|
10596
|
-
await this.signalTaskComplete(payload, "error");
|
|
10592
|
+
if (this.session) {
|
|
10593
|
+
await this.session.logWriter.flushAll();
|
|
10597
10594
|
}
|
|
10595
|
+
await this.signalTaskComplete(payload, "error");
|
|
10598
10596
|
}
|
|
10599
10597
|
}
|
|
10600
10598
|
buildCloudSystemPrompt() {
|
|
@@ -10625,7 +10623,13 @@ Important:
|
|
|
10625
10623
|
});
|
|
10626
10624
|
}
|
|
10627
10625
|
}
|
|
10628
|
-
|
|
10626
|
+
if (stopReason !== "error") {
|
|
10627
|
+
this.logger.info("Skipping status update for non-error stop reason", {
|
|
10628
|
+
stopReason
|
|
10629
|
+
});
|
|
10630
|
+
return;
|
|
10631
|
+
}
|
|
10632
|
+
const status = "failed";
|
|
10629
10633
|
try {
|
|
10630
10634
|
await this.posthogAPI.updateTaskRun(payload.task_id, payload.run_id, {
|
|
10631
10635
|
status,
|