@posthog/agent 2.3.93 → 2.3.104

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 CHANGED
@@ -371,7 +371,7 @@ import { v7 as uuidv7 } from "uuid";
371
371
  // package.json
372
372
  var package_default = {
373
373
  name: "@posthog/agent",
374
- version: "2.3.93",
374
+ version: "2.3.104",
375
375
  repository: "https://github.com/PostHog/code",
376
376
  description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
377
377
  exports: {
@@ -4704,6 +4704,7 @@ var SessionLogWriter = class _SessionLogWriter {
4704
4704
  lastFlushAttemptTime = /* @__PURE__ */ new Map();
4705
4705
  retryCounts = /* @__PURE__ */ new Map();
4706
4706
  sessions = /* @__PURE__ */ new Map();
4707
+ flushQueues = /* @__PURE__ */ new Map();
4707
4708
  logger;
4708
4709
  localCachePath;
4709
4710
  constructor(options = {}) {
@@ -4797,6 +4798,18 @@ var SessionLogWriter = class _SessionLogWriter {
4797
4798
  }
4798
4799
  }
4799
4800
  async flush(sessionId) {
4801
+ const prev = this.flushQueues.get(sessionId) ?? Promise.resolve();
4802
+ const next = prev.catch(() => {
4803
+ }).then(() => this._doFlush(sessionId));
4804
+ this.flushQueues.set(sessionId, next);
4805
+ next.finally(() => {
4806
+ if (this.flushQueues.get(sessionId) === next) {
4807
+ this.flushQueues.delete(sessionId);
4808
+ }
4809
+ });
4810
+ return next;
4811
+ }
4812
+ async _doFlush(sessionId) {
4800
4813
  const session = this.sessions.get(sessionId);
4801
4814
  if (!session) {
4802
4815
  this.logger.warn("flush: no session found", { sessionId });