@posthog/agent 2.3.370 → 2.3.386

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.
@@ -0,0 +1,67 @@
1
+ import { PostHogAPIClient } from './posthog-api.js';
2
+ import { TreeSnapshot } from './types.js';
3
+ import { L as Logger } from './logger-RC7sPv0S.js';
4
+
5
+ /**
6
+ * TreeTracker - Git tree-based state capture for cloud/local sync
7
+ *
8
+ * Captures the entire working state as a git tree hash + archive:
9
+ * - Atomic state snapshots (no partial syncs)
10
+ * - Efficient delta detection using git's diffing
11
+ * - Simpler resume logic (restore tree, continue)
12
+ *
13
+ * Uses Saga pattern for atomic operations with automatic rollback on failure.
14
+ * Uses a temporary git index to avoid modifying the user's staging area.
15
+ */
16
+
17
+ interface TreeTrackerConfig {
18
+ repositoryPath: string;
19
+ taskId: string;
20
+ runId: string;
21
+ apiClient?: PostHogAPIClient;
22
+ logger?: Logger;
23
+ }
24
+ declare class TreeTracker {
25
+ private repositoryPath;
26
+ private taskId;
27
+ private runId;
28
+ private apiClient?;
29
+ private logger;
30
+ private lastTreeHash;
31
+ constructor(config: TreeTrackerConfig);
32
+ /**
33
+ * Capture current working tree state as a snapshot.
34
+ * Uses a temporary index to avoid modifying user's staging area.
35
+ * Uses Saga pattern for atomic operation with automatic cleanup on failure.
36
+ */
37
+ captureTree(options?: {
38
+ interrupted?: boolean;
39
+ }): Promise<TreeSnapshot | null>;
40
+ /**
41
+ * Download and apply a tree snapshot.
42
+ * Uses Saga pattern for atomic operation with rollback on failure.
43
+ */
44
+ applyTreeSnapshot(snapshot: TreeSnapshot): Promise<void>;
45
+ /**
46
+ * Get the last captured tree hash.
47
+ */
48
+ getLastTreeHash(): string | null;
49
+ /**
50
+ * Set the last tree hash (used when resuming).
51
+ */
52
+ setLastTreeHash(hash: string | null): void;
53
+ }
54
+ /**
55
+ * Check if a commit is available on any remote branch.
56
+ * Used to validate that cloud can fetch the base commit during handoff.
57
+ */
58
+ declare function isCommitOnRemote(commit: string, cwd: string): Promise<boolean>;
59
+ /**
60
+ * Validate that a snapshot can be handed off to cloud execution.
61
+ * Cloud needs to be able to fetch the baseCommit from a remote.
62
+ *
63
+ * @throws Error if the snapshot cannot be restored on cloud
64
+ */
65
+ declare function validateForCloudHandoff(snapshot: TreeSnapshot, repositoryPath: string): Promise<void>;
66
+
67
+ export { TreeSnapshot, TreeTracker, type TreeTrackerConfig, isCommitOnRemote, validateForCloudHandoff };