@posthog/agent 2.3.443 → 2.3.449

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.
@@ -8723,7 +8723,7 @@ var import_zod3 = require("zod");
8723
8723
  // package.json
8724
8724
  var package_default = {
8725
8725
  name: "@posthog/agent",
8726
- version: "2.3.443",
8726
+ version: "2.3.449",
8727
8727
  repository: "https://github.com/PostHog/code",
8728
8728
  description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
8729
8729
  exports: {
@@ -15245,7 +15245,13 @@ function buildPermissionOptions(toolName, toolInput, repoRoot, suggestions) {
15245
15245
  }
15246
15246
  return permissionOptions("Yes, always allow");
15247
15247
  }
15248
- function buildExitPlanModePermissionOptions() {
15248
+ var CONTINUE_LABELS = {
15249
+ auto: 'Yes, continue in "auto" mode',
15250
+ acceptEdits: "Yes, continue auto-accepting edits",
15251
+ default: "Yes, continue manually approving edits",
15252
+ bypassPermissions: "Yes, continue bypassing all permissions"
15253
+ };
15254
+ function buildExitPlanModePermissionOptions(previousMode) {
15249
15255
  const options = [];
15250
15256
  if (ALLOW_BYPASS) {
15251
15257
  options.push({
@@ -15269,14 +15275,27 @@ function buildExitPlanModePermissionOptions() {
15269
15275
  kind: "allow_once",
15270
15276
  name: "Yes, and manually approve edits",
15271
15277
  optionId: "default"
15272
- },
15273
- {
15274
- kind: "reject_once",
15275
- name: "No, and tell the agent what to do differently",
15276
- optionId: "reject_with_feedback",
15277
- _meta: { customInput: true }
15278
15278
  }
15279
15279
  );
15280
+ const previousIndex = previousMode ? options.findIndex((opt) => opt.optionId === previousMode) : -1;
15281
+ if (previousIndex > 0) {
15282
+ const [previous] = options.splice(previousIndex, 1);
15283
+ const continueLabel = CONTINUE_LABELS[previous.optionId];
15284
+ options.unshift(
15285
+ continueLabel ? { ...previous, name: continueLabel } : previous
15286
+ );
15287
+ } else if (previousIndex === 0) {
15288
+ const continueLabel = CONTINUE_LABELS[options[0].optionId];
15289
+ if (continueLabel) {
15290
+ options[0] = { ...options[0], name: continueLabel };
15291
+ }
15292
+ }
15293
+ options.push({
15294
+ kind: "reject_once",
15295
+ name: "No, and tell the agent what to do differently",
15296
+ optionId: "reject_with_feedback",
15297
+ _meta: { customInput: true }
15298
+ });
15280
15299
  return options;
15281
15300
  }
15282
15301
 
@@ -15331,13 +15350,13 @@ async function validatePlanContent(planText, context) {
15331
15350
  return { valid: true };
15332
15351
  }
15333
15352
  async function requestPlanApproval(context, updatedInput) {
15334
- const { client, sessionId, toolUseID } = context;
15353
+ const { client, sessionId, toolUseID, session } = context;
15335
15354
  const toolInfo = toolInfoFromToolUse({
15336
15355
  name: context.toolName,
15337
15356
  input: updatedInput
15338
15357
  });
15339
15358
  return await client.requestPermission({
15340
- options: buildExitPlanModePermissionOptions(),
15359
+ options: buildExitPlanModePermissionOptions(session.modeBeforePlan),
15341
15360
  sessionId,
15342
15361
  toolCall: {
15343
15362
  toolCallId: toolUseID,
@@ -17089,6 +17108,9 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
17089
17108
  }
17090
17109
  const previousMode = this.session.permissionMode;
17091
17110
  this.session.permissionMode = modeId;
17111
+ if (modeId === "plan" && previousMode !== "plan") {
17112
+ this.session.modeBeforePlan = previousMode;
17113
+ }
17092
17114
  try {
17093
17115
  await this.session.query.setPermissionMode(modeId);
17094
17116
  } catch (error) {
@@ -17311,7 +17333,11 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
17311
17333
  createOnModeChange() {
17312
17334
  return async (newMode) => {
17313
17335
  if (this.session) {
17336
+ const previousMode = this.session.permissionMode;
17314
17337
  this.session.permissionMode = newMode;
17338
+ if (newMode === "plan" && previousMode !== "plan") {
17339
+ this.session.modeBeforePlan = previousMode;
17340
+ }
17315
17341
  }
17316
17342
  await this.updateConfigOption("mode", newMode);
17317
17343
  };