@posthog/agent 2.3.187 → 2.3.207
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/adapters/claude/conversion/tool-use-to-acp.js +9 -1
- package/dist/adapters/claude/conversion/tool-use-to-acp.js.map +1 -1
- package/dist/agent.js +18 -7
- package/dist/agent.js.map +1 -1
- package/dist/index.d.ts +57 -1
- package/dist/index.js +45 -1
- package/dist/index.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 +26 -10
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +26 -10
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/acp-extensions.ts +15 -4
- package/src/adapters/claude/claude-agent.ts +1 -1
- package/src/adapters/claude/conversion/sdk-to-acp.ts +4 -3
- package/src/adapters/claude/conversion/tool-use-to-acp.ts +11 -3
- package/src/adapters/claude/permissions/permission-handlers.ts +4 -1
- package/src/index.ts +1 -0
- package/src/sagas/resume-saga.test.ts +0 -29
- package/src/sagas/resume-saga.ts +5 -6
package/dist/server/bin.cjs
CHANGED
|
@@ -904,7 +904,7 @@ var import_hono = require("hono");
|
|
|
904
904
|
// package.json
|
|
905
905
|
var package_default = {
|
|
906
906
|
name: "@posthog/agent",
|
|
907
|
-
version: "2.3.
|
|
907
|
+
version: "2.3.207",
|
|
908
908
|
repository: "https://github.com/PostHog/code",
|
|
909
909
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
910
910
|
exports: {
|
|
@@ -1066,6 +1066,10 @@ var POSTHOG_NOTIFICATIONS = {
|
|
|
1066
1066
|
/** Token usage update for a session turn */
|
|
1067
1067
|
USAGE_UPDATE: "_posthog/usage_update"
|
|
1068
1068
|
};
|
|
1069
|
+
function isNotification(method, notification) {
|
|
1070
|
+
if (!method) return false;
|
|
1071
|
+
return method === notification || method === `_${notification}`;
|
|
1072
|
+
}
|
|
1069
1073
|
|
|
1070
1074
|
// src/adapters/acp-connection.ts
|
|
1071
1075
|
var import_sdk4 = require("@agentclientprotocol/sdk");
|
|
@@ -1917,7 +1921,15 @@ function toolInfoFromToolUse(toolUse, options) {
|
|
|
1917
1921
|
const writeDisplayPath = writeFilePath ? toDisplayPath(writeFilePath, options?.cwd) : void 0;
|
|
1918
1922
|
const contentStr = input?.content ? String(input.content) : void 0;
|
|
1919
1923
|
if (writeFilePath) {
|
|
1920
|
-
|
|
1924
|
+
let oldContent = null;
|
|
1925
|
+
if (options?.cachedFileContent && writeFilePath in options.cachedFileContent) {
|
|
1926
|
+
oldContent = options.cachedFileContent[writeFilePath];
|
|
1927
|
+
} else {
|
|
1928
|
+
try {
|
|
1929
|
+
oldContent = import_node_fs.default.readFileSync(writeFilePath, "utf-8");
|
|
1930
|
+
} catch {
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1921
1933
|
contentResult = toolContent().diff(writeFilePath, oldContent, contentStr ?? "").build();
|
|
1922
1934
|
} else if (contentStr) {
|
|
1923
1935
|
contentResult = toolContent().text(contentStr).build();
|
|
@@ -2681,7 +2693,7 @@ async function handleSystemMessage(message, context) {
|
|
|
2681
2693
|
case "init":
|
|
2682
2694
|
break;
|
|
2683
2695
|
case "compact_boundary":
|
|
2684
|
-
await client.extNotification(
|
|
2696
|
+
await client.extNotification(POSTHOG_NOTIFICATIONS.COMPACT_BOUNDARY, {
|
|
2685
2697
|
sessionId,
|
|
2686
2698
|
trigger: message.compact_metadata.trigger,
|
|
2687
2699
|
preTokens: message.compact_metadata.pre_tokens,
|
|
@@ -2697,7 +2709,7 @@ async function handleSystemMessage(message, context) {
|
|
|
2697
2709
|
case "status":
|
|
2698
2710
|
if (message.status === "compacting") {
|
|
2699
2711
|
logger.info("Session compacting started", { sessionId });
|
|
2700
|
-
await client.extNotification(
|
|
2712
|
+
await client.extNotification(POSTHOG_NOTIFICATIONS.STATUS, {
|
|
2701
2713
|
sessionId,
|
|
2702
2714
|
status: "compacting"
|
|
2703
2715
|
});
|
|
@@ -2710,7 +2722,7 @@ async function handleSystemMessage(message, context) {
|
|
|
2710
2722
|
status: message.status,
|
|
2711
2723
|
summary: message.summary
|
|
2712
2724
|
});
|
|
2713
|
-
await client.extNotification(
|
|
2725
|
+
await client.extNotification(POSTHOG_NOTIFICATIONS.TASK_NOTIFICATION, {
|
|
2714
2726
|
sessionId,
|
|
2715
2727
|
taskId: message.task_id,
|
|
2716
2728
|
status: message.status,
|
|
@@ -3369,7 +3381,10 @@ async function handleDefaultPermissionFlow(context) {
|
|
|
3369
3381
|
sessionId,
|
|
3370
3382
|
suggestions
|
|
3371
3383
|
} = context;
|
|
3372
|
-
const toolInfo = toolInfoFromToolUse(
|
|
3384
|
+
const toolInfo = toolInfoFromToolUse(
|
|
3385
|
+
{ name: toolName, input: toolInput },
|
|
3386
|
+
{ cachedFileContent: context.fileContentCache, cwd: session?.cwd }
|
|
3387
|
+
);
|
|
3373
3388
|
const options = buildPermissionOptions(
|
|
3374
3389
|
toolName,
|
|
3375
3390
|
toolInput,
|
|
@@ -4735,7 +4750,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
4735
4750
|
settingsManager.getSettings().model || meta?.model || void 0
|
|
4736
4751
|
),
|
|
4737
4752
|
...meta?.taskRunId ? [
|
|
4738
|
-
this.client.extNotification(
|
|
4753
|
+
this.client.extNotification(POSTHOG_NOTIFICATIONS.SDK_SESSION, {
|
|
4739
4754
|
taskRunId: meta.taskRunId,
|
|
4740
4755
|
sessionId,
|
|
4741
4756
|
adapter: "claude"
|
|
@@ -11510,11 +11525,12 @@ var ResumeSaga = class extends Saga {
|
|
|
11510
11525
|
};
|
|
11511
11526
|
}
|
|
11512
11527
|
findLatestTreeSnapshot(entries) {
|
|
11513
|
-
const sdkPrefixedMethod = `_${POSTHOG_NOTIFICATIONS.TREE_SNAPSHOT}`;
|
|
11514
11528
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
11515
11529
|
const entry = entries[i];
|
|
11516
|
-
|
|
11517
|
-
|
|
11530
|
+
if (isNotification(
|
|
11531
|
+
entry.notification?.method,
|
|
11532
|
+
POSTHOG_NOTIFICATIONS.TREE_SNAPSHOT
|
|
11533
|
+
)) {
|
|
11518
11534
|
const params = entry.notification.params;
|
|
11519
11535
|
if (params?.treeHash) {
|
|
11520
11536
|
return params;
|