@posthog/agent 2.3.62 → 2.3.67
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 +41 -41
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.js +3 -3
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +93 -93
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +80 -80
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +3 -3
- package/src/adapters/claude/conversion/acp-to-sdk.ts +3 -3
package/dist/agent.js
CHANGED
|
@@ -267,7 +267,7 @@ function nodeWritableToWebWritable(nodeStream) {
|
|
|
267
267
|
import { randomUUID } from "crypto";
|
|
268
268
|
import * as fs4 from "fs";
|
|
269
269
|
import * as os4 from "os";
|
|
270
|
-
import * as
|
|
270
|
+
import * as path6 from "path";
|
|
271
271
|
import {
|
|
272
272
|
RequestError as RequestError2
|
|
273
273
|
} from "@agentclientprotocol/sdk";
|
|
@@ -281,7 +281,7 @@ import { v7 as uuidv7 } from "uuid";
|
|
|
281
281
|
// package.json
|
|
282
282
|
var package_default = {
|
|
283
283
|
name: "@posthog/agent",
|
|
284
|
-
version: "2.3.
|
|
284
|
+
version: "2.3.67",
|
|
285
285
|
repository: "https://github.com/PostHog/code",
|
|
286
286
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
287
287
|
exports: {
|
|
@@ -345,13 +345,13 @@ var package_default = {
|
|
|
345
345
|
author: "PostHog",
|
|
346
346
|
license: "SEE LICENSE IN LICENSE",
|
|
347
347
|
scripts: {
|
|
348
|
-
build: "
|
|
348
|
+
build: "node ../../scripts/rimraf.mjs dist && tsup",
|
|
349
349
|
dev: "tsup --watch",
|
|
350
350
|
test: "vitest run",
|
|
351
351
|
"test:watch": "vitest",
|
|
352
352
|
typecheck: "pnpm exec tsc --noEmit",
|
|
353
353
|
prepublishOnly: "pnpm run build",
|
|
354
|
-
clean: "
|
|
354
|
+
clean: "node ../../scripts/rimraf.mjs dist .turbo"
|
|
355
355
|
},
|
|
356
356
|
engines: {
|
|
357
357
|
node: ">=20.0.0"
|
|
@@ -591,6 +591,7 @@ var BaseAcpAgent = class {
|
|
|
591
591
|
};
|
|
592
592
|
|
|
593
593
|
// src/adapters/claude/conversion/acp-to-sdk.ts
|
|
594
|
+
import * as path from "path";
|
|
594
595
|
function sdkText(value) {
|
|
595
596
|
return { type: "text", text: value };
|
|
596
597
|
}
|
|
@@ -598,12 +599,11 @@ function formatUriAsLink(uri) {
|
|
|
598
599
|
try {
|
|
599
600
|
if (uri.startsWith("file://")) {
|
|
600
601
|
const filePath = uri.slice(7);
|
|
601
|
-
const name =
|
|
602
|
+
const name = path.basename(filePath) || filePath;
|
|
602
603
|
return `[@${name}](${uri})`;
|
|
603
604
|
}
|
|
604
605
|
if (uri.startsWith("zed://")) {
|
|
605
|
-
const
|
|
606
|
-
const name = parts[parts.length - 1] || uri;
|
|
606
|
+
const name = path.basename(uri) || uri;
|
|
607
607
|
return `[@${name}](${uri})`;
|
|
608
608
|
}
|
|
609
609
|
return uri;
|
|
@@ -708,8 +708,8 @@ var ToolContentBuilder = class {
|
|
|
708
708
|
this.items.push({ type: "content", content: image(data, mimeType, uri) });
|
|
709
709
|
return this;
|
|
710
710
|
}
|
|
711
|
-
diff(
|
|
712
|
-
this.items.push({ type: "diff", path:
|
|
711
|
+
diff(path8, oldText, newText) {
|
|
712
|
+
this.items.push({ type: "diff", path: path8, oldText, newText });
|
|
713
713
|
return this;
|
|
714
714
|
}
|
|
715
715
|
build() {
|
|
@@ -795,7 +795,7 @@ var createPreToolUseHook = (settingsManager, logger) => async (input, _toolUseID
|
|
|
795
795
|
|
|
796
796
|
// src/adapters/claude/conversion/tool-use-to-acp.ts
|
|
797
797
|
import fs from "fs";
|
|
798
|
-
import
|
|
798
|
+
import path2 from "path";
|
|
799
799
|
|
|
800
800
|
// src/adapters/claude/mcp/tool-metadata.ts
|
|
801
801
|
var mcpToolMetadataCache = /* @__PURE__ */ new Map();
|
|
@@ -881,10 +881,10 @@ function stripSystemReminders(value) {
|
|
|
881
881
|
}
|
|
882
882
|
function toDisplayPath(filePath, cwd) {
|
|
883
883
|
if (!cwd) return filePath;
|
|
884
|
-
const resolvedCwd =
|
|
885
|
-
const resolvedFile =
|
|
886
|
-
if (resolvedFile.startsWith(resolvedCwd +
|
|
887
|
-
return
|
|
884
|
+
const resolvedCwd = path2.resolve(cwd);
|
|
885
|
+
const resolvedFile = path2.resolve(filePath);
|
|
886
|
+
if (resolvedFile.startsWith(resolvedCwd + path2.sep) || resolvedFile === resolvedCwd) {
|
|
887
|
+
return path2.relative(resolvedCwd, resolvedFile);
|
|
888
888
|
}
|
|
889
889
|
return filePath;
|
|
890
890
|
}
|
|
@@ -1993,18 +1993,18 @@ async function handleUserAssistantMessage(message, context) {
|
|
|
1993
1993
|
|
|
1994
1994
|
// src/adapters/claude/plan/utils.ts
|
|
1995
1995
|
import * as os from "os";
|
|
1996
|
-
import * as
|
|
1996
|
+
import * as path3 from "path";
|
|
1997
1997
|
function getClaudeConfigDir() {
|
|
1998
|
-
return process.env.CLAUDE_CONFIG_DIR ||
|
|
1998
|
+
return process.env.CLAUDE_CONFIG_DIR || path3.join(os.homedir(), ".claude");
|
|
1999
1999
|
}
|
|
2000
2000
|
function getClaudePlansDir() {
|
|
2001
|
-
return
|
|
2001
|
+
return path3.join(getClaudeConfigDir(), "plans");
|
|
2002
2002
|
}
|
|
2003
2003
|
function isClaudePlanFilePath(filePath) {
|
|
2004
2004
|
if (!filePath) return false;
|
|
2005
|
-
const resolved =
|
|
2006
|
-
const plansDir =
|
|
2007
|
-
return resolved === plansDir || resolved.startsWith(plansDir +
|
|
2005
|
+
const resolved = path3.resolve(filePath);
|
|
2006
|
+
const plansDir = path3.resolve(getClaudePlansDir());
|
|
2007
|
+
return resolved === plansDir || resolved.startsWith(plansDir + path3.sep);
|
|
2008
2008
|
}
|
|
2009
2009
|
function isPlanReady(plan) {
|
|
2010
2010
|
if (!plan) return false;
|
|
@@ -2644,7 +2644,7 @@ function getEffortOptions(modelId) {
|
|
|
2644
2644
|
import { spawn } from "child_process";
|
|
2645
2645
|
import * as fs2 from "fs";
|
|
2646
2646
|
import * as os2 from "os";
|
|
2647
|
-
import * as
|
|
2647
|
+
import * as path4 from "path";
|
|
2648
2648
|
|
|
2649
2649
|
// src/adapters/claude/session/instructions.ts
|
|
2650
2650
|
var BRANCH_NAMING = `
|
|
@@ -2790,8 +2790,8 @@ function buildSpawnWrapper(sessionId, onProcessSpawned, onProcessExited, logger)
|
|
|
2790
2790
|
};
|
|
2791
2791
|
}
|
|
2792
2792
|
function ensureLocalSettings(cwd) {
|
|
2793
|
-
const claudeDir =
|
|
2794
|
-
const localSettingsPath =
|
|
2793
|
+
const claudeDir = path4.join(cwd, ".claude");
|
|
2794
|
+
const localSettingsPath = path4.join(claudeDir, "settings.local.json");
|
|
2795
2795
|
try {
|
|
2796
2796
|
if (!fs2.existsSync(localSettingsPath)) {
|
|
2797
2797
|
fs2.mkdirSync(claudeDir, { recursive: true });
|
|
@@ -2862,8 +2862,8 @@ function buildSessionOptions(params) {
|
|
|
2862
2862
|
return options;
|
|
2863
2863
|
}
|
|
2864
2864
|
function clearStatsigCache() {
|
|
2865
|
-
const statsigPath =
|
|
2866
|
-
process.env.CLAUDE_CONFIG_DIR ||
|
|
2865
|
+
const statsigPath = path4.join(
|
|
2866
|
+
process.env.CLAUDE_CONFIG_DIR || path4.join(os2.homedir(), ".claude"),
|
|
2867
2867
|
"statsig"
|
|
2868
2868
|
);
|
|
2869
2869
|
fs2.rm(statsigPath, { recursive: true, force: true }, () => {
|
|
@@ -2873,7 +2873,7 @@ function clearStatsigCache() {
|
|
|
2873
2873
|
// src/adapters/claude/session/settings.ts
|
|
2874
2874
|
import * as fs3 from "fs";
|
|
2875
2875
|
import * as os3 from "os";
|
|
2876
|
-
import * as
|
|
2876
|
+
import * as path5 from "path";
|
|
2877
2877
|
import { minimatch } from "minimatch";
|
|
2878
2878
|
var ACP_TOOL_NAME_PREFIX = "mcp__acp__";
|
|
2879
2879
|
var acpToolNames = {
|
|
@@ -2913,13 +2913,13 @@ function parseRule(rule) {
|
|
|
2913
2913
|
function normalizePath(filePath, cwd) {
|
|
2914
2914
|
let resolved = filePath;
|
|
2915
2915
|
if (resolved.startsWith("~/")) {
|
|
2916
|
-
resolved =
|
|
2916
|
+
resolved = path5.join(os3.homedir(), resolved.slice(2));
|
|
2917
2917
|
} else if (resolved.startsWith("./")) {
|
|
2918
|
-
resolved =
|
|
2919
|
-
} else if (!
|
|
2920
|
-
resolved =
|
|
2918
|
+
resolved = path5.join(cwd, resolved.slice(2));
|
|
2919
|
+
} else if (!path5.isAbsolute(resolved)) {
|
|
2920
|
+
resolved = path5.join(cwd, resolved);
|
|
2921
2921
|
}
|
|
2922
|
-
return
|
|
2922
|
+
return path5.normalize(resolved).replace(/\\/g, "/");
|
|
2923
2923
|
}
|
|
2924
2924
|
function matchesGlob(pattern, filePath, cwd) {
|
|
2925
2925
|
const normalizedPattern = normalizePath(pattern, cwd);
|
|
@@ -3003,14 +3003,14 @@ var SettingsManager = class {
|
|
|
3003
3003
|
this.initialized = true;
|
|
3004
3004
|
}
|
|
3005
3005
|
getUserSettingsPath() {
|
|
3006
|
-
const configDir = process.env.CLAUDE_CONFIG_DIR ||
|
|
3007
|
-
return
|
|
3006
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || path5.join(os3.homedir(), ".claude");
|
|
3007
|
+
return path5.join(configDir, "settings.json");
|
|
3008
3008
|
}
|
|
3009
3009
|
getProjectSettingsPath() {
|
|
3010
|
-
return
|
|
3010
|
+
return path5.join(this.cwd, ".claude", "settings.json");
|
|
3011
3011
|
}
|
|
3012
3012
|
getLocalSettingsPath() {
|
|
3013
|
-
return
|
|
3013
|
+
return path5.join(this.cwd, ".claude", "settings.local.json");
|
|
3014
3014
|
}
|
|
3015
3015
|
async loadAllSettings() {
|
|
3016
3016
|
const [userSettings, projectSettings, localSettings, enterpriseSettings] = await Promise.all([
|
|
@@ -3175,7 +3175,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
3175
3175
|
};
|
|
3176
3176
|
}
|
|
3177
3177
|
async newSession(params) {
|
|
3178
|
-
if (fs4.existsSync(
|
|
3178
|
+
if (fs4.existsSync(path6.resolve(os4.homedir(), ".claude.json.backup")) && !fs4.existsSync(path6.resolve(os4.homedir(), ".claude.json"))) {
|
|
3179
3179
|
throw RequestError2.authRequired();
|
|
3180
3180
|
}
|
|
3181
3181
|
const response = await this.createSession(params, {
|
|
@@ -4479,7 +4479,7 @@ var PostHogAPIClient = class {
|
|
|
4479
4479
|
// src/session-log-writer.ts
|
|
4480
4480
|
import fs5 from "fs";
|
|
4481
4481
|
import fsp from "fs/promises";
|
|
4482
|
-
import
|
|
4482
|
+
import path7 from "path";
|
|
4483
4483
|
var SessionLogWriter = class _SessionLogWriter {
|
|
4484
4484
|
static FLUSH_DEBOUNCE_MS = 500;
|
|
4485
4485
|
static FLUSH_MAX_INTERVAL_MS = 5e3;
|
|
@@ -4518,7 +4518,7 @@ var SessionLogWriter = class _SessionLogWriter {
|
|
|
4518
4518
|
this.sessions.set(sessionId, { context, currentTurnMessages: [] });
|
|
4519
4519
|
this.lastFlushAttemptTime.set(sessionId, Date.now());
|
|
4520
4520
|
if (this.localCachePath) {
|
|
4521
|
-
const sessionDir =
|
|
4521
|
+
const sessionDir = path7.join(
|
|
4522
4522
|
this.localCachePath,
|
|
4523
4523
|
"sessions",
|
|
4524
4524
|
context.runId
|
|
@@ -4740,7 +4740,7 @@ var SessionLogWriter = class _SessionLogWriter {
|
|
|
4740
4740
|
if (!this.localCachePath) return;
|
|
4741
4741
|
const session = this.sessions.get(sessionId);
|
|
4742
4742
|
if (!session) return;
|
|
4743
|
-
const logPath =
|
|
4743
|
+
const logPath = path7.join(
|
|
4744
4744
|
this.localCachePath,
|
|
4745
4745
|
"sessions",
|
|
4746
4746
|
session.context.runId,
|
|
@@ -4759,13 +4759,13 @@ var SessionLogWriter = class _SessionLogWriter {
|
|
|
4759
4759
|
}
|
|
4760
4760
|
}
|
|
4761
4761
|
static async cleanupOldSessions(localCachePath) {
|
|
4762
|
-
const sessionsDir =
|
|
4762
|
+
const sessionsDir = path7.join(localCachePath, "sessions");
|
|
4763
4763
|
let deleted = 0;
|
|
4764
4764
|
try {
|
|
4765
4765
|
const entries = await fsp.readdir(sessionsDir);
|
|
4766
4766
|
const now = Date.now();
|
|
4767
4767
|
for (const entry of entries) {
|
|
4768
|
-
const entryPath =
|
|
4768
|
+
const entryPath = path7.join(sessionsDir, entry);
|
|
4769
4769
|
try {
|
|
4770
4770
|
const stats = await fsp.stat(entryPath);
|
|
4771
4771
|
if (stats.isDirectory() && now - stats.birthtimeMs > _SessionLogWriter.SESSIONS_MAX_AGE_MS) {
|