@posthog/agent 1.27.0 → 1.29.0
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/index.d.ts +3 -1
- package/dist/index.js +51 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/claude/claude.ts +25 -0
- package/src/worktree-manager.ts +49 -2
package/dist/index.d.ts
CHANGED
|
@@ -1255,7 +1255,9 @@ declare class WorktreeManager {
|
|
|
1255
1255
|
ensureArrayDirIgnored(): Promise<void>;
|
|
1256
1256
|
private generateUniqueWorktreeName;
|
|
1257
1257
|
private getDefaultBranch;
|
|
1258
|
-
createWorktree(
|
|
1258
|
+
createWorktree(options?: {
|
|
1259
|
+
baseBranch?: string;
|
|
1260
|
+
}): Promise<WorktreeInfo>;
|
|
1259
1261
|
deleteWorktree(worktreePath: string): Promise<void>;
|
|
1260
1262
|
getWorktreeInfo(worktreePath: string): Promise<WorktreeInfo | null>;
|
|
1261
1263
|
listWorktrees(): Promise<WorktreeInfo[]>;
|
package/dist/index.js
CHANGED
|
@@ -196,7 +196,7 @@ function createTappedWritableStream(underlying, options) {
|
|
|
196
196
|
// package.json
|
|
197
197
|
var package_default = {
|
|
198
198
|
name: "@posthog/agent",
|
|
199
|
-
version: "1.
|
|
199
|
+
version: "1.29.0",
|
|
200
200
|
repository: "https://github.com/PostHog/array",
|
|
201
201
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
202
202
|
main: "./dist/index.js",
|
|
@@ -1729,6 +1729,18 @@ var ClaudeAcpAgent = class {
|
|
|
1729
1729
|
}
|
|
1730
1730
|
const availableCommands = await getAvailableSlashCommands(q);
|
|
1731
1731
|
const models = await getAvailableModels(q);
|
|
1732
|
+
const requestedModel = params._meta?.model;
|
|
1733
|
+
if (requestedModel) {
|
|
1734
|
+
try {
|
|
1735
|
+
await q.setModel(requestedModel);
|
|
1736
|
+
this.logger.info("Set initial model", { model: requestedModel });
|
|
1737
|
+
} catch (err) {
|
|
1738
|
+
this.logger.warn("Failed to set initial model, using default", {
|
|
1739
|
+
requestedModel,
|
|
1740
|
+
error: err
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1732
1744
|
setTimeout(() => {
|
|
1733
1745
|
this.client.sessionUpdate({
|
|
1734
1746
|
sessionId,
|
|
@@ -2121,6 +2133,11 @@ var ClaudeAcpAgent = class {
|
|
|
2121
2133
|
await this.resumeSession(params);
|
|
2122
2134
|
return {};
|
|
2123
2135
|
}
|
|
2136
|
+
if (method === "session/setModel") {
|
|
2137
|
+
const { sessionId, modelId } = params;
|
|
2138
|
+
await this.setSessionModel({ sessionId, modelId });
|
|
2139
|
+
return {};
|
|
2140
|
+
}
|
|
2124
2141
|
throw RequestError.methodNotFound(method);
|
|
2125
2142
|
}
|
|
2126
2143
|
/**
|
|
@@ -7083,7 +7100,7 @@ ${ignorePattern}
|
|
|
7083
7100
|
}
|
|
7084
7101
|
}
|
|
7085
7102
|
}
|
|
7086
|
-
async createWorktree() {
|
|
7103
|
+
async createWorktree(options) {
|
|
7087
7104
|
if (!this.usesExternalPath()) {
|
|
7088
7105
|
await this.ensureArrayDirIgnored();
|
|
7089
7106
|
}
|
|
@@ -7094,7 +7111,7 @@ ${ignorePattern}
|
|
|
7094
7111
|
const worktreeName = await this.generateUniqueWorktreeName();
|
|
7095
7112
|
const worktreePath = this.getWorktreePath(worktreeName);
|
|
7096
7113
|
const branchName = `array/${worktreeName}`;
|
|
7097
|
-
const baseBranch = await this.getDefaultBranch();
|
|
7114
|
+
const baseBranch = options?.baseBranch ?? await this.getDefaultBranch();
|
|
7098
7115
|
this.logger.info("Creating worktree", {
|
|
7099
7116
|
worktreeName,
|
|
7100
7117
|
worktreePath,
|
|
@@ -7127,6 +7144,37 @@ ${ignorePattern}
|
|
|
7127
7144
|
};
|
|
7128
7145
|
}
|
|
7129
7146
|
async deleteWorktree(worktreePath) {
|
|
7147
|
+
const resolvedWorktreePath = path2.resolve(worktreePath);
|
|
7148
|
+
const resolvedMainRepoPath = path2.resolve(this.mainRepoPath);
|
|
7149
|
+
if (resolvedWorktreePath === resolvedMainRepoPath) {
|
|
7150
|
+
const error = new Error(
|
|
7151
|
+
"Cannot delete worktree: path matches main repo path"
|
|
7152
|
+
);
|
|
7153
|
+
this.logger.error("Safety check failed", { worktreePath, error });
|
|
7154
|
+
throw error;
|
|
7155
|
+
}
|
|
7156
|
+
if (resolvedMainRepoPath.startsWith(resolvedWorktreePath) && resolvedMainRepoPath !== resolvedWorktreePath) {
|
|
7157
|
+
const error = new Error(
|
|
7158
|
+
"Cannot delete worktree: path is a parent of main repo path"
|
|
7159
|
+
);
|
|
7160
|
+
this.logger.error("Safety check failed", { worktreePath, error });
|
|
7161
|
+
throw error;
|
|
7162
|
+
}
|
|
7163
|
+
try {
|
|
7164
|
+
const gitPath = path2.join(resolvedWorktreePath, ".git");
|
|
7165
|
+
const stat2 = await fs5.stat(gitPath);
|
|
7166
|
+
if (stat2.isDirectory()) {
|
|
7167
|
+
const error = new Error(
|
|
7168
|
+
"Cannot delete worktree: path appears to be a main repository (contains .git directory)"
|
|
7169
|
+
);
|
|
7170
|
+
this.logger.error("Safety check failed", { worktreePath, error });
|
|
7171
|
+
throw error;
|
|
7172
|
+
}
|
|
7173
|
+
} catch (error) {
|
|
7174
|
+
if (error instanceof Error && error.message.includes("Cannot delete worktree")) {
|
|
7175
|
+
throw error;
|
|
7176
|
+
}
|
|
7177
|
+
}
|
|
7130
7178
|
this.logger.info("Deleting worktree", { worktreePath });
|
|
7131
7179
|
try {
|
|
7132
7180
|
await execFileAsync(
|