@posthog/agent 2.3.53 → 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.
@@ -809,10 +809,10 @@ var require_src2 = __commonJS({
809
809
  var fs_1 = __require("fs");
810
810
  var debug_1 = __importDefault(require_src());
811
811
  var log = debug_1.default("@kwsites/file-exists");
812
- function check(path11, isFile, isDirectory) {
813
- log(`checking %s`, path11);
812
+ function check(path12, isFile, isDirectory) {
813
+ log(`checking %s`, path12);
814
814
  try {
815
- const stat = fs_1.statSync(path11);
815
+ const stat = fs_1.statSync(path12);
816
816
  if (stat.isFile() && isFile) {
817
817
  log(`[OK] path represents a file`);
818
818
  return true;
@@ -832,8 +832,8 @@ var require_src2 = __commonJS({
832
832
  throw e;
833
833
  }
834
834
  }
835
- function exists2(path11, type = exports.READABLE) {
836
- return check(path11, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
835
+ function exists2(path12, type = exports.READABLE) {
836
+ return check(path12, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
837
837
  }
838
838
  exports.exists = exists2;
839
839
  exports.FILE = 1;
@@ -908,7 +908,7 @@ import { Hono } from "hono";
908
908
  // package.json
909
909
  var package_default = {
910
910
  name: "@posthog/agent",
911
- version: "2.3.53",
911
+ version: "2.3.67",
912
912
  repository: "https://github.com/PostHog/code",
913
913
  description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
914
914
  exports: {
@@ -972,13 +972,13 @@ var package_default = {
972
972
  author: "PostHog",
973
973
  license: "SEE LICENSE IN LICENSE",
974
974
  scripts: {
975
- build: "rm -rf dist && tsup",
975
+ build: "node ../../scripts/rimraf.mjs dist && tsup",
976
976
  dev: "tsup --watch",
977
977
  test: "vitest run",
978
978
  "test:watch": "vitest",
979
979
  typecheck: "pnpm exec tsc --noEmit",
980
980
  prepublishOnly: "pnpm run build",
981
- clean: "rm -rf dist .turbo"
981
+ clean: "node ../../scripts/rimraf.mjs dist .turbo"
982
982
  },
983
983
  engines: {
984
984
  node: ">=20.0.0"
@@ -1294,7 +1294,7 @@ function nodeWritableToWebWritable(nodeStream) {
1294
1294
  import { randomUUID } from "crypto";
1295
1295
  import * as fs4 from "fs";
1296
1296
  import * as os4 from "os";
1297
- import * as path5 from "path";
1297
+ import * as path6 from "path";
1298
1298
  import {
1299
1299
  RequestError as RequestError2
1300
1300
  } from "@agentclientprotocol/sdk";
@@ -1465,6 +1465,7 @@ var BaseAcpAgent = class {
1465
1465
  };
1466
1466
 
1467
1467
  // src/adapters/claude/conversion/acp-to-sdk.ts
1468
+ import * as path from "path";
1468
1469
  function sdkText(value) {
1469
1470
  return { type: "text", text: value };
1470
1471
  }
@@ -1472,12 +1473,11 @@ function formatUriAsLink(uri) {
1472
1473
  try {
1473
1474
  if (uri.startsWith("file://")) {
1474
1475
  const filePath = uri.slice(7);
1475
- const name = filePath.split("/").pop() || filePath;
1476
+ const name = path.basename(filePath) || filePath;
1476
1477
  return `[@${name}](${uri})`;
1477
1478
  }
1478
1479
  if (uri.startsWith("zed://")) {
1479
- const parts = uri.split("/");
1480
- const name = parts[parts.length - 1] || uri;
1480
+ const name = path.basename(uri) || uri;
1481
1481
  return `[@${name}](${uri})`;
1482
1482
  }
1483
1483
  return uri;
@@ -1582,8 +1582,8 @@ var ToolContentBuilder = class {
1582
1582
  this.items.push({ type: "content", content: image(data, mimeType, uri) });
1583
1583
  return this;
1584
1584
  }
1585
- diff(path11, oldText, newText) {
1586
- this.items.push({ type: "diff", path: path11, oldText, newText });
1585
+ diff(path12, oldText, newText) {
1586
+ this.items.push({ type: "diff", path: path12, oldText, newText });
1587
1587
  return this;
1588
1588
  }
1589
1589
  build() {
@@ -1669,7 +1669,7 @@ var createPreToolUseHook = (settingsManager, logger) => async (input, _toolUseID
1669
1669
 
1670
1670
  // src/adapters/claude/conversion/tool-use-to-acp.ts
1671
1671
  import fs from "fs";
1672
- import path from "path";
1672
+ import path2 from "path";
1673
1673
 
1674
1674
  // src/adapters/claude/mcp/tool-metadata.ts
1675
1675
  var mcpToolMetadataCache = /* @__PURE__ */ new Map();
@@ -1739,6 +1739,14 @@ function isMcpToolReadOnly(toolName) {
1739
1739
  const metadata = mcpToolMetadataCache.get(toolName);
1740
1740
  return metadata?.readOnly === true;
1741
1741
  }
1742
+ function getConnectedMcpServerNames() {
1743
+ const names = /* @__PURE__ */ new Set();
1744
+ for (const key of mcpToolMetadataCache.keys()) {
1745
+ const parts = key.split("__");
1746
+ if (parts.length >= 3) names.add(parts[1]);
1747
+ }
1748
+ return [...names];
1749
+ }
1742
1750
 
1743
1751
  // src/adapters/claude/conversion/tool-use-to-acp.ts
1744
1752
  var SYSTEM_REMINDER_REGEX = /\s*<system-reminder>[\s\S]*?<\/system-reminder>/g;
@@ -1747,10 +1755,10 @@ function stripSystemReminders(value) {
1747
1755
  }
1748
1756
  function toDisplayPath(filePath, cwd) {
1749
1757
  if (!cwd) return filePath;
1750
- const resolvedCwd = path.resolve(cwd);
1751
- const resolvedFile = path.resolve(filePath);
1752
- if (resolvedFile.startsWith(resolvedCwd + path.sep) || resolvedFile === resolvedCwd) {
1753
- return path.relative(resolvedCwd, resolvedFile);
1758
+ const resolvedCwd = path2.resolve(cwd);
1759
+ const resolvedFile = path2.resolve(filePath);
1760
+ if (resolvedFile.startsWith(resolvedCwd + path2.sep) || resolvedFile === resolvedCwd) {
1761
+ return path2.relative(resolvedCwd, resolvedFile);
1754
1762
  }
1755
1763
  return filePath;
1756
1764
  }
@@ -2495,7 +2503,10 @@ function handleToolResultChunk(chunk, ctx) {
2495
2503
  toolCallId: chunk.tool_use_id,
2496
2504
  sessionUpdate: "tool_call_update",
2497
2505
  status: chunk.is_error ? "failed" : "completed",
2498
- rawOutput: chunk.content,
2506
+ rawOutput: ctx.mcpToolUseResult ? { ...ctx.mcpToolUseResult, isError: chunk.is_error ?? false } : {
2507
+ content: Array.isArray(chunk.content) ? chunk.content : typeof chunk.content === "string" ? [{ type: "text", text: chunk.content }] : [],
2508
+ isError: chunk.is_error ?? false
2509
+ },
2499
2510
  ...toolUpdate
2500
2511
  });
2501
2512
  return updates;
@@ -2549,7 +2560,7 @@ function processContentChunk(chunk, role, ctx) {
2549
2560
  return [];
2550
2561
  }
2551
2562
  }
2552
- function toAcpNotifications(content, role, sessionId, toolUseCache, fileContentCache, client, logger, parentToolCallId, registerHooks, supportsTerminalOutput, cwd) {
2563
+ function toAcpNotifications(content, role, sessionId, toolUseCache, fileContentCache, client, logger, parentToolCallId, registerHooks, supportsTerminalOutput, cwd, mcpToolUseResult) {
2553
2564
  if (typeof content === "string") {
2554
2565
  const update = {
2555
2566
  sessionUpdate: messageUpdateType(role),
@@ -2573,7 +2584,8 @@ function toAcpNotifications(content, role, sessionId, toolUseCache, fileContentC
2573
2584
  parentToolCallId,
2574
2585
  registerHooks,
2575
2586
  supportsTerminalOutput,
2576
- cwd
2587
+ cwd,
2588
+ mcpToolUseResult
2577
2589
  };
2578
2590
  const output = [];
2579
2591
  for (const chunk of content) {
@@ -2832,6 +2844,7 @@ async function handleUserAssistantMessage(message, context) {
2832
2844
  const content = message.message.content;
2833
2845
  const contentToProcess = message.type === "assistant" ? filterMessageContent(content) : content;
2834
2846
  const parentToolCallId = "parent_tool_use_id" in message ? message.parent_tool_use_id ?? void 0 : void 0;
2847
+ const mcpToolUseResult = message.type === "user" && message.tool_use_result != null ? message.tool_use_result : void 0;
2835
2848
  for (const notification of toAcpNotifications(
2836
2849
  contentToProcess,
2837
2850
  message.message.role,
@@ -2843,7 +2856,8 @@ async function handleUserAssistantMessage(message, context) {
2843
2856
  parentToolCallId,
2844
2857
  context.registerHooks,
2845
2858
  context.supportsTerminalOutput,
2846
- session.cwd
2859
+ session.cwd,
2860
+ mcpToolUseResult
2847
2861
  )) {
2848
2862
  await client.sessionUpdate(notification);
2849
2863
  session.notificationHistory.push(notification);
@@ -2853,18 +2867,18 @@ async function handleUserAssistantMessage(message, context) {
2853
2867
 
2854
2868
  // src/adapters/claude/plan/utils.ts
2855
2869
  import * as os from "os";
2856
- import * as path2 from "path";
2870
+ import * as path3 from "path";
2857
2871
  function getClaudeConfigDir() {
2858
- return process.env.CLAUDE_CONFIG_DIR || path2.join(os.homedir(), ".claude");
2872
+ return process.env.CLAUDE_CONFIG_DIR || path3.join(os.homedir(), ".claude");
2859
2873
  }
2860
2874
  function getClaudePlansDir() {
2861
- return path2.join(getClaudeConfigDir(), "plans");
2875
+ return path3.join(getClaudeConfigDir(), "plans");
2862
2876
  }
2863
2877
  function isClaudePlanFilePath(filePath) {
2864
2878
  if (!filePath) return false;
2865
- const resolved = path2.resolve(filePath);
2866
- const plansDir = path2.resolve(getClaudePlansDir());
2867
- return resolved === plansDir || resolved.startsWith(plansDir + path2.sep);
2879
+ const resolved = path3.resolve(filePath);
2880
+ const plansDir = path3.resolve(getClaudePlansDir());
2881
+ return resolved === plansDir || resolved.startsWith(plansDir + path3.sep);
2868
2882
  }
2869
2883
  function isPlanReady(plan) {
2870
2884
  if (!plan) return false;
@@ -3504,7 +3518,7 @@ function getEffortOptions(modelId) {
3504
3518
  import { spawn } from "child_process";
3505
3519
  import * as fs2 from "fs";
3506
3520
  import * as os2 from "os";
3507
- import * as path3 from "path";
3521
+ import * as path4 from "path";
3508
3522
 
3509
3523
  // src/adapters/claude/session/instructions.ts
3510
3524
  var BRANCH_NAMING = `
@@ -3650,8 +3664,8 @@ function buildSpawnWrapper(sessionId, onProcessSpawned, onProcessExited, logger)
3650
3664
  };
3651
3665
  }
3652
3666
  function ensureLocalSettings(cwd) {
3653
- const claudeDir = path3.join(cwd, ".claude");
3654
- const localSettingsPath = path3.join(claudeDir, "settings.local.json");
3667
+ const claudeDir = path4.join(cwd, ".claude");
3668
+ const localSettingsPath = path4.join(claudeDir, "settings.local.json");
3655
3669
  try {
3656
3670
  if (!fs2.existsSync(localSettingsPath)) {
3657
3671
  fs2.mkdirSync(claudeDir, { recursive: true });
@@ -3722,8 +3736,8 @@ function buildSessionOptions(params) {
3722
3736
  return options;
3723
3737
  }
3724
3738
  function clearStatsigCache() {
3725
- const statsigPath = path3.join(
3726
- process.env.CLAUDE_CONFIG_DIR || path3.join(os2.homedir(), ".claude"),
3739
+ const statsigPath = path4.join(
3740
+ process.env.CLAUDE_CONFIG_DIR || path4.join(os2.homedir(), ".claude"),
3727
3741
  "statsig"
3728
3742
  );
3729
3743
  fs2.rm(statsigPath, { recursive: true, force: true }, () => {
@@ -3733,7 +3747,7 @@ function clearStatsigCache() {
3733
3747
  // src/adapters/claude/session/settings.ts
3734
3748
  import * as fs3 from "fs";
3735
3749
  import * as os3 from "os";
3736
- import * as path4 from "path";
3750
+ import * as path5 from "path";
3737
3751
  import { minimatch } from "minimatch";
3738
3752
  var ACP_TOOL_NAME_PREFIX = "mcp__acp__";
3739
3753
  var acpToolNames = {
@@ -3773,13 +3787,13 @@ function parseRule(rule) {
3773
3787
  function normalizePath(filePath, cwd) {
3774
3788
  let resolved = filePath;
3775
3789
  if (resolved.startsWith("~/")) {
3776
- resolved = path4.join(os3.homedir(), resolved.slice(2));
3790
+ resolved = path5.join(os3.homedir(), resolved.slice(2));
3777
3791
  } else if (resolved.startsWith("./")) {
3778
- resolved = path4.join(cwd, resolved.slice(2));
3779
- } else if (!path4.isAbsolute(resolved)) {
3780
- resolved = path4.join(cwd, resolved);
3792
+ resolved = path5.join(cwd, resolved.slice(2));
3793
+ } else if (!path5.isAbsolute(resolved)) {
3794
+ resolved = path5.join(cwd, resolved);
3781
3795
  }
3782
- return path4.normalize(resolved).replace(/\\/g, "/");
3796
+ return path5.normalize(resolved).replace(/\\/g, "/");
3783
3797
  }
3784
3798
  function matchesGlob(pattern, filePath, cwd) {
3785
3799
  const normalizedPattern = normalizePath(pattern, cwd);
@@ -3863,14 +3877,14 @@ var SettingsManager = class {
3863
3877
  this.initialized = true;
3864
3878
  }
3865
3879
  getUserSettingsPath() {
3866
- const configDir = process.env.CLAUDE_CONFIG_DIR || path4.join(os3.homedir(), ".claude");
3867
- return path4.join(configDir, "settings.json");
3880
+ const configDir = process.env.CLAUDE_CONFIG_DIR || path5.join(os3.homedir(), ".claude");
3881
+ return path5.join(configDir, "settings.json");
3868
3882
  }
3869
3883
  getProjectSettingsPath() {
3870
- return path4.join(this.cwd, ".claude", "settings.json");
3884
+ return path5.join(this.cwd, ".claude", "settings.json");
3871
3885
  }
3872
3886
  getLocalSettingsPath() {
3873
- return path4.join(this.cwd, ".claude", "settings.local.json");
3887
+ return path5.join(this.cwd, ".claude", "settings.local.json");
3874
3888
  }
3875
3889
  async loadAllSettings() {
3876
3890
  const [userSettings, projectSettings, localSettings, enterpriseSettings] = await Promise.all([
@@ -4035,7 +4049,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
4035
4049
  };
4036
4050
  }
4037
4051
  async newSession(params) {
4038
- if (fs4.existsSync(path5.resolve(os4.homedir(), ".claude.json.backup")) && !fs4.existsSync(path5.resolve(os4.homedir(), ".claude.json"))) {
4052
+ if (fs4.existsSync(path6.resolve(os4.homedir(), ".claude.json.backup")) && !fs4.existsSync(path6.resolve(os4.homedir(), ".claude.json"))) {
4039
4053
  throw RequestError2.authRequired();
4040
4054
  }
4041
4055
  const response = await this.createSession(params, {
@@ -4683,11 +4697,17 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
4683
4697
  * Both populate caches used later — neither is needed to return configOptions.
4684
4698
  */
4685
4699
  deferBackgroundFetches(q) {
4700
+ this.logger.info("Starting background fetches (commands + MCP metadata)");
4686
4701
  Promise.all([
4687
4702
  new Promise((resolve4) => setTimeout(resolve4, 10)).then(
4688
4703
  () => this.sendAvailableCommandsUpdate()
4689
4704
  ),
4690
- fetchMcpToolMetadata(q, this.logger)
4705
+ fetchMcpToolMetadata(q, this.logger).then(() => {
4706
+ const serverNames = getConnectedMcpServerNames();
4707
+ if (serverNames.length > 0) {
4708
+ this.options?.onMcpServersReady?.(serverNames);
4709
+ }
4710
+ })
4691
4711
  ]).catch(
4692
4712
  (err) => this.logger.error("Background fetch failed", { error: err })
4693
4713
  );
@@ -5151,7 +5171,7 @@ function createCodexConnection(config) {
5151
5171
  import { randomUUID as randomUUID2 } from "crypto";
5152
5172
  import * as fs5 from "fs/promises";
5153
5173
  import * as os5 from "os";
5154
- import * as path6 from "path";
5174
+ import * as path7 from "path";
5155
5175
  var CHARS_PER_TOKEN = 4;
5156
5176
  var DEFAULT_MAX_TOKENS = 15e4;
5157
5177
  function estimateTurnTokens(turn) {
@@ -5498,7 +5518,7 @@ var Saga = class {
5498
5518
 
5499
5519
  // ../git/dist/queries.js
5500
5520
  import * as fs7 from "fs/promises";
5501
- import * as path8 from "path";
5521
+ import * as path9 from "path";
5502
5522
 
5503
5523
  // ../../node_modules/simple-git/dist/esm/index.js
5504
5524
  var import_file_exists = __toESM(require_dist(), 1);
@@ -5537,8 +5557,8 @@ function pathspec(...paths) {
5537
5557
  cache.set(key, paths);
5538
5558
  return key;
5539
5559
  }
5540
- function isPathSpec(path11) {
5541
- return path11 instanceof String && cache.has(path11);
5560
+ function isPathSpec(path12) {
5561
+ return path12 instanceof String && cache.has(path12);
5542
5562
  }
5543
5563
  function toPaths(pathSpec) {
5544
5564
  return cache.get(pathSpec) || [];
@@ -5627,8 +5647,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
5627
5647
  function forEachLineWithContent(input, callback) {
5628
5648
  return toLinesWithContent(input, true).map((line) => callback(line));
5629
5649
  }
5630
- function folderExists(path11) {
5631
- return (0, import_file_exists.exists)(path11, import_file_exists.FOLDER);
5650
+ function folderExists(path12) {
5651
+ return (0, import_file_exists.exists)(path12, import_file_exists.FOLDER);
5632
5652
  }
5633
5653
  function append(target, item) {
5634
5654
  if (Array.isArray(target)) {
@@ -6032,8 +6052,8 @@ function checkIsRepoRootTask() {
6032
6052
  commands,
6033
6053
  format: "utf-8",
6034
6054
  onError,
6035
- parser(path11) {
6036
- return /^\.(git)?$/.test(path11.trim());
6055
+ parser(path12) {
6056
+ return /^\.(git)?$/.test(path12.trim());
6037
6057
  }
6038
6058
  };
6039
6059
  }
@@ -6467,11 +6487,11 @@ function parseGrep(grep) {
6467
6487
  const paths = /* @__PURE__ */ new Set();
6468
6488
  const results = {};
6469
6489
  forEachLineWithContent(grep, (input) => {
6470
- const [path11, line, preview] = input.split(NULL);
6471
- paths.add(path11);
6472
- (results[path11] = results[path11] || []).push({
6490
+ const [path12, line, preview] = input.split(NULL);
6491
+ paths.add(path12);
6492
+ (results[path12] = results[path12] || []).push({
6473
6493
  line: asNumber(line),
6474
- path: path11,
6494
+ path: path12,
6475
6495
  preview
6476
6496
  });
6477
6497
  });
@@ -7236,14 +7256,14 @@ var init_hash_object = __esm({
7236
7256
  init_task();
7237
7257
  }
7238
7258
  });
7239
- function parseInit(bare, path11, text2) {
7259
+ function parseInit(bare, path12, text2) {
7240
7260
  const response = String(text2).trim();
7241
7261
  let result;
7242
7262
  if (result = initResponseRegex.exec(response)) {
7243
- return new InitSummary(bare, path11, false, result[1]);
7263
+ return new InitSummary(bare, path12, false, result[1]);
7244
7264
  }
7245
7265
  if (result = reInitResponseRegex.exec(response)) {
7246
- return new InitSummary(bare, path11, true, result[1]);
7266
+ return new InitSummary(bare, path12, true, result[1]);
7247
7267
  }
7248
7268
  let gitDir = "";
7249
7269
  const tokens = response.split(" ");
@@ -7254,7 +7274,7 @@ function parseInit(bare, path11, text2) {
7254
7274
  break;
7255
7275
  }
7256
7276
  }
7257
- return new InitSummary(bare, path11, /^re/i.test(response), gitDir);
7277
+ return new InitSummary(bare, path12, /^re/i.test(response), gitDir);
7258
7278
  }
7259
7279
  var InitSummary;
7260
7280
  var initResponseRegex;
@@ -7263,9 +7283,9 @@ var init_InitSummary = __esm({
7263
7283
  "src/lib/responses/InitSummary.ts"() {
7264
7284
  "use strict";
7265
7285
  InitSummary = class {
7266
- constructor(bare, path11, existing, gitDir) {
7286
+ constructor(bare, path12, existing, gitDir) {
7267
7287
  this.bare = bare;
7268
- this.path = path11;
7288
+ this.path = path12;
7269
7289
  this.existing = existing;
7270
7290
  this.gitDir = gitDir;
7271
7291
  }
@@ -7277,7 +7297,7 @@ var init_InitSummary = __esm({
7277
7297
  function hasBareCommand(command) {
7278
7298
  return command.includes(bareCommand);
7279
7299
  }
7280
- function initTask(bare = false, path11, customArgs) {
7300
+ function initTask(bare = false, path12, customArgs) {
7281
7301
  const commands = ["init", ...customArgs];
7282
7302
  if (bare && !hasBareCommand(commands)) {
7283
7303
  commands.splice(1, 0, bareCommand);
@@ -7286,7 +7306,7 @@ function initTask(bare = false, path11, customArgs) {
7286
7306
  commands,
7287
7307
  format: "utf-8",
7288
7308
  parser(text2) {
7289
- return parseInit(commands.includes("--bare"), path11, text2);
7309
+ return parseInit(commands.includes("--bare"), path12, text2);
7290
7310
  }
7291
7311
  };
7292
7312
  }
@@ -8102,12 +8122,12 @@ var init_FileStatusSummary = __esm({
8102
8122
  "use strict";
8103
8123
  fromPathRegex = /^(.+)\0(.+)$/;
8104
8124
  FileStatusSummary = class {
8105
- constructor(path11, index, working_dir) {
8106
- this.path = path11;
8125
+ constructor(path12, index, working_dir) {
8126
+ this.path = path12;
8107
8127
  this.index = index;
8108
8128
  this.working_dir = working_dir;
8109
8129
  if (index === "R" || working_dir === "R") {
8110
- const detail = fromPathRegex.exec(path11) || [null, path11, path11];
8130
+ const detail = fromPathRegex.exec(path12) || [null, path12, path12];
8111
8131
  this.from = detail[2] || "";
8112
8132
  this.path = detail[1] || "";
8113
8133
  }
@@ -8138,14 +8158,14 @@ function splitLine(result, lineStr) {
8138
8158
  default:
8139
8159
  return;
8140
8160
  }
8141
- function data(index, workingDir, path11) {
8161
+ function data(index, workingDir, path12) {
8142
8162
  const raw = `${index}${workingDir}`;
8143
8163
  const handler = parsers6.get(raw);
8144
8164
  if (handler) {
8145
- handler(result, path11);
8165
+ handler(result, path12);
8146
8166
  }
8147
8167
  if (raw !== "##" && raw !== "!!") {
8148
- result.files.push(new FileStatusSummary(path11, index, workingDir));
8168
+ result.files.push(new FileStatusSummary(path12, index, workingDir));
8149
8169
  }
8150
8170
  }
8151
8171
  }
@@ -8458,9 +8478,9 @@ var init_simple_git_api = __esm({
8458
8478
  next
8459
8479
  );
8460
8480
  }
8461
- hashObject(path11, write) {
8481
+ hashObject(path12, write) {
8462
8482
  return this._runTask(
8463
- hashObjectTask(path11, write === true),
8483
+ hashObjectTask(path12, write === true),
8464
8484
  trailingFunctionArgument(arguments)
8465
8485
  );
8466
8486
  }
@@ -8813,8 +8833,8 @@ var init_branch = __esm({
8813
8833
  }
8814
8834
  });
8815
8835
  function toPath(input) {
8816
- const path11 = input.trim().replace(/^["']|["']$/g, "");
8817
- return path11 && normalize2(path11);
8836
+ const path12 = input.trim().replace(/^["']|["']$/g, "");
8837
+ return path12 && normalize2(path12);
8818
8838
  }
8819
8839
  var parseCheckIgnore;
8820
8840
  var init_CheckIgnore = __esm({
@@ -9128,8 +9148,8 @@ __export(sub_module_exports, {
9128
9148
  subModuleTask: () => subModuleTask,
9129
9149
  updateSubModuleTask: () => updateSubModuleTask
9130
9150
  });
9131
- function addSubModuleTask(repo, path11) {
9132
- return subModuleTask(["add", repo, path11]);
9151
+ function addSubModuleTask(repo, path12) {
9152
+ return subModuleTask(["add", repo, path12]);
9133
9153
  }
9134
9154
  function initSubModuleTask(customArgs) {
9135
9155
  return subModuleTask(["init", ...customArgs]);
@@ -9459,8 +9479,8 @@ var require_git = __commonJS2({
9459
9479
  }
9460
9480
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
9461
9481
  };
9462
- Git2.prototype.submoduleAdd = function(repo, path11, then) {
9463
- return this._runTask(addSubModuleTask2(repo, path11), trailingFunctionArgument2(arguments));
9482
+ Git2.prototype.submoduleAdd = function(repo, path12, then) {
9483
+ return this._runTask(addSubModuleTask2(repo, path12), trailingFunctionArgument2(arguments));
9464
9484
  };
9465
9485
  Git2.prototype.submoduleUpdate = function(args, then) {
9466
9486
  return this._runTask(
@@ -10062,15 +10082,15 @@ function createGitClient(baseDir, options) {
10062
10082
  // ../git/dist/lock-detector.js
10063
10083
  import { execFile } from "child_process";
10064
10084
  import fs6 from "fs/promises";
10065
- import path7 from "path";
10085
+ import path8 from "path";
10066
10086
  import { promisify } from "util";
10067
10087
  var execFileAsync = promisify(execFile);
10068
10088
  async function getIndexLockPath(repoPath) {
10069
10089
  try {
10070
10090
  const { stdout } = await execFileAsync("git", ["rev-parse", "--git-path", "index.lock"], { cwd: repoPath });
10071
- return path7.resolve(repoPath, stdout.trim());
10091
+ return path8.resolve(repoPath, stdout.trim());
10072
10092
  } catch {
10073
- return path7.join(repoPath, ".git", "index.lock");
10093
+ return path8.join(repoPath, ".git", "index.lock");
10074
10094
  }
10075
10095
  }
10076
10096
  async function getLockInfo(repoPath) {
@@ -10259,7 +10279,7 @@ import { join as join7 } from "path";
10259
10279
  // ../git/dist/sagas/tree.js
10260
10280
  import { existsSync as existsSync4 } from "fs";
10261
10281
  import * as fs8 from "fs/promises";
10262
- import * as path9 from "path";
10282
+ import * as path10 from "path";
10263
10283
  import * as tar from "tar";
10264
10284
 
10265
10285
  // ../git/dist/git-saga.js
@@ -10286,14 +10306,14 @@ var CaptureTreeSaga = class extends GitSaga {
10286
10306
  tempIndexPath = null;
10287
10307
  async executeGitOperations(input) {
10288
10308
  const { baseDir, lastTreeHash, archivePath, signal } = input;
10289
- const tmpDir = path9.join(baseDir, ".git", "posthog-code-tmp");
10309
+ const tmpDir = path10.join(baseDir, ".git", "posthog-code-tmp");
10290
10310
  await this.step({
10291
10311
  name: "create_tmp_dir",
10292
10312
  execute: () => fs8.mkdir(tmpDir, { recursive: true }),
10293
10313
  rollback: async () => {
10294
10314
  }
10295
10315
  });
10296
- this.tempIndexPath = path9.join(tmpDir, `index-${Date.now()}`);
10316
+ this.tempIndexPath = path10.join(tmpDir, `index-${Date.now()}`);
10297
10317
  const tempIndexGit = this.git.env({
10298
10318
  ...process.env,
10299
10319
  GIT_INDEX_FILE: this.tempIndexPath
@@ -10348,14 +10368,14 @@ var CaptureTreeSaga = class extends GitSaga {
10348
10368
  if (filesToArchive.length === 0) {
10349
10369
  return void 0;
10350
10370
  }
10351
- const existingFiles = filesToArchive.filter((f) => existsSync4(path9.join(baseDir, f)));
10371
+ const existingFiles = filesToArchive.filter((f) => existsSync4(path10.join(baseDir, f)));
10352
10372
  if (existingFiles.length === 0) {
10353
10373
  return void 0;
10354
10374
  }
10355
10375
  await this.step({
10356
10376
  name: "create_archive",
10357
10377
  execute: async () => {
10358
- const archiveDir = path9.dirname(archivePath);
10378
+ const archiveDir = path10.dirname(archivePath);
10359
10379
  await fs8.mkdir(archiveDir, { recursive: true });
10360
10380
  await tar.create({
10361
10381
  gzip: true,
@@ -10464,7 +10484,7 @@ var ApplyTreeSaga = class extends GitSaga {
10464
10484
  const filesToExtract = changes.filter((c) => c.status !== "D").map((c) => c.path);
10465
10485
  await this.readOnlyStep("backup_existing_files", async () => {
10466
10486
  for (const filePath of filesToExtract) {
10467
- const fullPath = path9.join(baseDir, filePath);
10487
+ const fullPath = path10.join(baseDir, filePath);
10468
10488
  try {
10469
10489
  const content = await fs8.readFile(fullPath);
10470
10490
  this.fileBackups.set(filePath, content);
@@ -10483,10 +10503,10 @@ var ApplyTreeSaga = class extends GitSaga {
10483
10503
  },
10484
10504
  rollback: async () => {
10485
10505
  for (const filePath of this.extractedFiles) {
10486
- const fullPath = path9.join(baseDir, filePath);
10506
+ const fullPath = path10.join(baseDir, filePath);
10487
10507
  const backup = this.fileBackups.get(filePath);
10488
10508
  if (backup) {
10489
- const dir = path9.dirname(fullPath);
10509
+ const dir = path10.dirname(fullPath);
10490
10510
  await fs8.mkdir(dir, { recursive: true }).catch(() => {
10491
10511
  });
10492
10512
  await fs8.writeFile(fullPath, backup).catch(() => {
@@ -10500,7 +10520,7 @@ var ApplyTreeSaga = class extends GitSaga {
10500
10520
  });
10501
10521
  }
10502
10522
  for (const change of changes.filter((c) => c.status === "D")) {
10503
- const fullPath = path9.join(baseDir, change.path);
10523
+ const fullPath = path10.join(baseDir, change.path);
10504
10524
  const backupContent = await this.readOnlyStep(`backup_${change.path}`, async () => {
10505
10525
  try {
10506
10526
  return await fs8.readFile(fullPath);
@@ -10516,7 +10536,7 @@ var ApplyTreeSaga = class extends GitSaga {
10516
10536
  },
10517
10537
  rollback: async () => {
10518
10538
  if (backupContent) {
10519
- const dir = path9.dirname(fullPath);
10539
+ const dir = path10.dirname(fullPath);
10520
10540
  await fs8.mkdir(dir, { recursive: true }).catch(() => {
10521
10541
  });
10522
10542
  await fs8.writeFile(fullPath, backupContent).catch(() => {
@@ -11082,7 +11102,7 @@ async function resumeFromLog(config) {
11082
11102
  // src/session-log-writer.ts
11083
11103
  import fs9 from "fs";
11084
11104
  import fsp from "fs/promises";
11085
- import path10 from "path";
11105
+ import path11 from "path";
11086
11106
  var SessionLogWriter = class _SessionLogWriter {
11087
11107
  static FLUSH_DEBOUNCE_MS = 500;
11088
11108
  static FLUSH_MAX_INTERVAL_MS = 5e3;
@@ -11121,7 +11141,7 @@ var SessionLogWriter = class _SessionLogWriter {
11121
11141
  this.sessions.set(sessionId, { context, currentTurnMessages: [] });
11122
11142
  this.lastFlushAttemptTime.set(sessionId, Date.now());
11123
11143
  if (this.localCachePath) {
11124
- const sessionDir = path10.join(
11144
+ const sessionDir = path11.join(
11125
11145
  this.localCachePath,
11126
11146
  "sessions",
11127
11147
  context.runId
@@ -11343,7 +11363,7 @@ var SessionLogWriter = class _SessionLogWriter {
11343
11363
  if (!this.localCachePath) return;
11344
11364
  const session = this.sessions.get(sessionId);
11345
11365
  if (!session) return;
11346
- const logPath = path10.join(
11366
+ const logPath = path11.join(
11347
11367
  this.localCachePath,
11348
11368
  "sessions",
11349
11369
  session.context.runId,
@@ -11362,13 +11382,13 @@ var SessionLogWriter = class _SessionLogWriter {
11362
11382
  }
11363
11383
  }
11364
11384
  static async cleanupOldSessions(localCachePath) {
11365
- const sessionsDir = path10.join(localCachePath, "sessions");
11385
+ const sessionsDir = path11.join(localCachePath, "sessions");
11366
11386
  let deleted = 0;
11367
11387
  try {
11368
11388
  const entries = await fsp.readdir(sessionsDir);
11369
11389
  const now = Date.now();
11370
11390
  for (const entry of entries) {
11371
- const entryPath = path10.join(sessionsDir, entry);
11391
+ const entryPath = path11.join(sessionsDir, entry);
11372
11392
  try {
11373
11393
  const stats = await fsp.stat(entryPath);
11374
11394
  if (stats.isDirectory() && now - stats.birthtimeMs > _SessionLogWriter.SESSIONS_MAX_AGE_MS) {