@posthog/agent 2.1.82 → 2.1.85
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 +22 -0
- package/dist/adapters/claude/conversion/tool-use-to-acp.js.map +1 -1
- package/dist/adapters/claude/permissions/permission-options.js.map +1 -1
- package/dist/adapters/claude/tools.js.map +1 -1
- package/dist/agent.js +37 -6
- package/dist/agent.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/server/agent-server.js +46 -11
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +46 -11
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/acp-connection.ts +5 -4
- package/src/adapters/claude/claude-agent.ts +1 -1
- package/src/adapters/claude/conversion/sdk-to-acp.ts +6 -3
- package/src/adapters/claude/conversion/tool-use-to-acp.ts +25 -0
- package/src/adapters/claude/mcp/tool-metadata.ts +8 -5
- package/src/adapters/claude/permissions/permission-handlers.ts +1 -1
- package/src/adapters/claude/session/options.ts +11 -2
- package/src/agent.ts +2 -2
- package/src/sagas/apply-snapshot-saga.ts +6 -3
- package/src/sagas/capture-tree-saga.test.ts +1 -1
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.85",
|
|
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: {
|
|
@@ -2001,6 +2001,28 @@ function toolUpdateFromToolResult(toolResult, toolUse) {
|
|
|
2001
2001
|
}
|
|
2002
2002
|
return { title: "Question answered" };
|
|
2003
2003
|
}
|
|
2004
|
+
case "WebFetch": {
|
|
2005
|
+
const input = toolUse?.input;
|
|
2006
|
+
const url = input?.url ? String(input.url) : "";
|
|
2007
|
+
const prompt = input?.prompt ? String(input.prompt) : void 0;
|
|
2008
|
+
const resultContent = toAcpContentUpdate(
|
|
2009
|
+
toolResult.content,
|
|
2010
|
+
"is_error" in toolResult ? toolResult.is_error : false
|
|
2011
|
+
);
|
|
2012
|
+
const content = [];
|
|
2013
|
+
if (url) {
|
|
2014
|
+
content.push({
|
|
2015
|
+
type: "content",
|
|
2016
|
+
content: resourceLink(url, url, {
|
|
2017
|
+
description: prompt
|
|
2018
|
+
})
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
if (resultContent.content) {
|
|
2022
|
+
content.push(...resultContent.content);
|
|
2023
|
+
}
|
|
2024
|
+
return { content };
|
|
2025
|
+
}
|
|
2004
2026
|
default: {
|
|
2005
2027
|
return toAcpContentUpdate(
|
|
2006
2028
|
toolResult.content,
|
|
@@ -2467,7 +2489,7 @@ function isHttpMcpServer(config) {
|
|
|
2467
2489
|
async function fetchToolsFromHttpServer(_serverName, config) {
|
|
2468
2490
|
const transport = new import_streamableHttp.StreamableHTTPClientTransport(new URL(config.url), {
|
|
2469
2491
|
requestInit: {
|
|
2470
|
-
headers: config.headers
|
|
2492
|
+
headers: config.headers ?? {}
|
|
2471
2493
|
}
|
|
2472
2494
|
});
|
|
2473
2495
|
const client = new import_client.Client({
|
|
@@ -2847,7 +2869,7 @@ async function applyPlanApproval(response, context, updatedInput) {
|
|
|
2847
2869
|
return { behavior: "deny", message, interrupt: false };
|
|
2848
2870
|
}
|
|
2849
2871
|
async function handleEnterPlanModeTool(context) {
|
|
2850
|
-
const { session, toolInput
|
|
2872
|
+
const { session, toolInput } = context;
|
|
2851
2873
|
session.permissionMode = "plan";
|
|
2852
2874
|
await session.query.setPermissionMode("plan");
|
|
2853
2875
|
await context.emitConfigOptionsUpdate();
|
|
@@ -3195,6 +3217,11 @@ function buildSpawnWrapper(sessionId, onProcessSpawned, onProcessExited) {
|
|
|
3195
3217
|
child.kill("SIGTERM");
|
|
3196
3218
|
});
|
|
3197
3219
|
}
|
|
3220
|
+
if (!child.stdin || !child.stdout) {
|
|
3221
|
+
throw new Error(
|
|
3222
|
+
`Failed to get stdio streams for spawned process (pid=${child.pid})`
|
|
3223
|
+
);
|
|
3224
|
+
}
|
|
3198
3225
|
return {
|
|
3199
3226
|
stdin: child.stdin,
|
|
3200
3227
|
stdout: child.stdout,
|
|
@@ -3207,12 +3234,15 @@ function buildSpawnWrapper(sessionId, onProcessSpawned, onProcessExited) {
|
|
|
3207
3234
|
kill(signal) {
|
|
3208
3235
|
return child.kill(signal);
|
|
3209
3236
|
},
|
|
3237
|
+
// biome-ignore lint/suspicious/noExplicitAny: ChildProcess event listener types require any[]
|
|
3210
3238
|
on(event, listener) {
|
|
3211
3239
|
child.on(event, listener);
|
|
3212
3240
|
},
|
|
3241
|
+
// biome-ignore lint/suspicious/noExplicitAny: ChildProcess event listener types require any[]
|
|
3213
3242
|
once(event, listener) {
|
|
3214
3243
|
child.once(event, listener);
|
|
3215
3244
|
},
|
|
3245
|
+
// biome-ignore lint/suspicious/noExplicitAny: ChildProcess event listener types require any[]
|
|
3216
3246
|
off(event, listener) {
|
|
3217
3247
|
child.off(event, listener);
|
|
3218
3248
|
}
|
|
@@ -3893,15 +3923,16 @@ function createClaudeConnection(config) {
|
|
|
3893
3923
|
deviceType: config.deviceType
|
|
3894
3924
|
});
|
|
3895
3925
|
}
|
|
3926
|
+
const taskRunId = config.taskRunId;
|
|
3896
3927
|
agentWritable = createTappedWritableStream(streams.agent.writable, {
|
|
3897
3928
|
onMessage: (line) => {
|
|
3898
|
-
logWriter.appendRawLine(
|
|
3929
|
+
logWriter.appendRawLine(taskRunId, line);
|
|
3899
3930
|
},
|
|
3900
3931
|
logger
|
|
3901
3932
|
});
|
|
3902
3933
|
clientWritable = createTappedWritableStream(streams.client.writable, {
|
|
3903
3934
|
onMessage: (line) => {
|
|
3904
|
-
logWriter.appendRawLine(
|
|
3935
|
+
logWriter.appendRawLine(taskRunId, line);
|
|
3905
3936
|
},
|
|
3906
3937
|
logger
|
|
3907
3938
|
});
|
|
@@ -4097,7 +4128,7 @@ function createCodexConnection(config) {
|
|
|
4097
4128
|
}
|
|
4098
4129
|
});
|
|
4099
4130
|
const shouldTapLogs = config.taskRunId && logWriter;
|
|
4100
|
-
if (shouldTapLogs) {
|
|
4131
|
+
if (shouldTapLogs && config.taskRunId) {
|
|
4101
4132
|
const taskRunId2 = config.taskRunId;
|
|
4102
4133
|
if (!logWriter.isRegistered(taskRunId2)) {
|
|
4103
4134
|
logWriter.register(taskRunId2, {
|
|
@@ -9229,11 +9260,13 @@ var AsyncReaderWriterLock = class {
|
|
|
9229
9260
|
return;
|
|
9230
9261
|
if (this.writeQueue.length > 0) {
|
|
9231
9262
|
const next = this.writeQueue.shift();
|
|
9232
|
-
next
|
|
9263
|
+
if (next)
|
|
9264
|
+
next();
|
|
9233
9265
|
} else {
|
|
9234
9266
|
while (this.readQueue.length > 0 && !this.writerWaiting) {
|
|
9235
9267
|
const next = this.readQueue.shift();
|
|
9236
|
-
next
|
|
9268
|
+
if (next)
|
|
9269
|
+
next();
|
|
9237
9270
|
}
|
|
9238
9271
|
}
|
|
9239
9272
|
}
|
|
@@ -9749,27 +9782,29 @@ var ApplySnapshotSaga = class extends Saga {
|
|
|
9749
9782
|
if (!snapshot.archiveUrl) {
|
|
9750
9783
|
throw new Error("Cannot apply snapshot: no archive URL");
|
|
9751
9784
|
}
|
|
9785
|
+
const archiveUrl = snapshot.archiveUrl;
|
|
9752
9786
|
await this.step({
|
|
9753
9787
|
name: "create_tmp_dir",
|
|
9754
9788
|
execute: () => (0, import_promises2.mkdir)(tmpDir, { recursive: true }),
|
|
9755
9789
|
rollback: async () => {
|
|
9756
9790
|
}
|
|
9757
9791
|
});
|
|
9758
|
-
|
|
9792
|
+
const archivePath = (0, import_node_path4.join)(tmpDir, `${snapshot.treeHash}.tar.gz`);
|
|
9793
|
+
this.archivePath = archivePath;
|
|
9759
9794
|
await this.step({
|
|
9760
9795
|
name: "download_archive",
|
|
9761
9796
|
execute: async () => {
|
|
9762
9797
|
const arrayBuffer = await apiClient.downloadArtifact(
|
|
9763
9798
|
taskId,
|
|
9764
9799
|
runId,
|
|
9765
|
-
|
|
9800
|
+
archiveUrl
|
|
9766
9801
|
);
|
|
9767
9802
|
if (!arrayBuffer) {
|
|
9768
9803
|
throw new Error("Failed to download archive");
|
|
9769
9804
|
}
|
|
9770
9805
|
const base64Content = Buffer.from(arrayBuffer).toString("utf-8");
|
|
9771
9806
|
const binaryContent = Buffer.from(base64Content, "base64");
|
|
9772
|
-
await (0, import_promises2.writeFile)(
|
|
9807
|
+
await (0, import_promises2.writeFile)(archivePath, binaryContent);
|
|
9773
9808
|
},
|
|
9774
9809
|
rollback: async () => {
|
|
9775
9810
|
if (this.archivePath) {
|