@posthog/agent 2.1.71 → 2.1.82

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.
Files changed (34) hide show
  1. package/dist/adapters/claude/conversion/tool-use-to-acp.d.ts +22 -2
  2. package/dist/adapters/claude/permissions/permission-options.d.ts +3 -1
  3. package/dist/adapters/claude/permissions/permission-options.js +5 -2
  4. package/dist/adapters/claude/permissions/permission-options.js.map +1 -1
  5. package/dist/adapters/claude/questions/utils.d.ts +1 -0
  6. package/dist/agent.d.ts +30 -5
  7. package/dist/agent.js +8 -7
  8. package/dist/agent.js.map +1 -1
  9. package/dist/gateway-models.d.ts +1 -2
  10. package/dist/gateway-models.js +0 -5
  11. package/dist/gateway-models.js.map +1 -1
  12. package/dist/index.d.ts +1 -257
  13. package/dist/index.js +1 -10532
  14. package/dist/index.js.map +1 -1
  15. package/dist/server/agent-server.js +8 -7
  16. package/dist/server/agent-server.js.map +1 -1
  17. package/dist/server/bin.cjs +8 -7
  18. package/dist/server/bin.cjs.map +1 -1
  19. package/package.json +1 -4
  20. package/src/acp-extensions.ts +0 -98
  21. package/src/adapters/acp-connection.ts +1 -1
  22. package/src/adapters/claude/permissions/permission-handlers.ts +1 -0
  23. package/src/adapters/claude/permissions/permission-options.ts +10 -1
  24. package/src/gateway-models.ts +0 -7
  25. package/src/index.ts +1 -79
  26. package/src/test/mocks/msw-handlers.ts +0 -3
  27. package/dist/agent-DK1apkaG.d.ts +0 -133
  28. package/dist/logger-DDBiMOOD.d.ts +0 -24
  29. package/src/adapters/claude/tool-meta.ts +0 -143
  30. package/src/test/assertions.ts +0 -114
  31. package/src/test/controllers/sse-controller.ts +0 -107
  32. package/src/test/fixtures/notifications.ts +0 -92
  33. package/src/test/setup.ts +0 -114
  34. package/src/test/wait.ts +0 -41
@@ -12,7 +12,6 @@ declare const DEFAULT_GATEWAY_MODEL = "claude-opus-4-6";
12
12
  declare const BLOCKED_MODELS: Set<string>;
13
13
  declare function fetchGatewayModels(options?: FetchGatewayModelsOptions): Promise<GatewayModel[]>;
14
14
  declare function isAnthropicModel(model: GatewayModel): boolean;
15
- declare function fetchArrayModelIds(options?: FetchGatewayModelsOptions): Promise<string[]>;
16
15
  interface ArrayModelInfo {
17
16
  id: string;
18
17
  owned_by?: string;
@@ -21,4 +20,4 @@ declare function fetchArrayModels(options?: FetchGatewayModelsOptions): Promise<
21
20
  declare function getProviderName(ownedBy: string): string;
22
21
  declare function formatGatewayModelName(model: GatewayModel): string;
23
22
 
24
- export { type ArrayModelInfo, BLOCKED_MODELS, DEFAULT_GATEWAY_MODEL, type FetchGatewayModelsOptions, type GatewayModel, fetchArrayModelIds, fetchArrayModels, fetchGatewayModels, formatGatewayModelName, getProviderName, isAnthropicModel };
23
+ export { type ArrayModelInfo, BLOCKED_MODELS, DEFAULT_GATEWAY_MODEL, type FetchGatewayModelsOptions, type GatewayModel, fetchArrayModels, fetchGatewayModels, formatGatewayModelName, getProviderName, isAnthropicModel };
@@ -35,10 +35,6 @@ function isAnthropicModel(model) {
35
35
  }
36
36
  return model.id.startsWith("claude-") || model.id.startsWith("anthropic/");
37
37
  }
38
- async function fetchArrayModelIds(options) {
39
- const models = await fetchArrayModels(options);
40
- return models.map((model) => model.id);
41
- }
42
38
  var arrayModelsCache = null;
43
39
  async function fetchArrayModels(options) {
44
40
  const gatewayUrl = options?.gatewayUrl ?? process.env.ANTHROPIC_BASE_URL;
@@ -102,7 +98,6 @@ function formatGatewayModelName(model) {
102
98
  export {
103
99
  BLOCKED_MODELS,
104
100
  DEFAULT_GATEWAY_MODEL,
105
- fetchArrayModelIds,
106
101
  fetchArrayModels,
107
102
  fetchGatewayModels,
108
103
  formatGatewayModelName,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/gateway-models.ts"],"sourcesContent":["export interface GatewayModel {\n id: string;\n owned_by: string;\n context_window: number;\n supports_streaming: boolean;\n supports_vision: boolean;\n}\n\ninterface GatewayModelsResponse {\n object: \"list\";\n data: GatewayModel[];\n}\n\nexport interface FetchGatewayModelsOptions {\n gatewayUrl: string;\n}\n\nexport const DEFAULT_GATEWAY_MODEL = \"claude-opus-4-6\";\n\nexport const BLOCKED_MODELS = new Set([\"gpt-5-mini\", \"openai/gpt-5-mini\"]);\n\ntype ArrayModelsResponse =\n | {\n data?: Array<{ id?: string; owned_by?: string }>;\n models?: Array<{ id?: string; owned_by?: string }>;\n }\n | Array<{ id?: string; owned_by?: string }>;\n\nconst CACHE_TTL = 10 * 60 * 1000; // 10 minutes\n\nlet gatewayModelsCache: {\n models: GatewayModel[];\n expiry: number;\n url: string;\n} | null = null;\n\nexport async function fetchGatewayModels(\n options?: FetchGatewayModelsOptions,\n): Promise<GatewayModel[]> {\n const gatewayUrl = options?.gatewayUrl ?? process.env.ANTHROPIC_BASE_URL;\n if (!gatewayUrl) {\n return [];\n }\n\n if (\n gatewayModelsCache &&\n gatewayModelsCache.url === gatewayUrl &&\n Date.now() < gatewayModelsCache.expiry\n ) {\n return gatewayModelsCache.models;\n }\n\n const modelsUrl = `${gatewayUrl}/v1/models`;\n\n try {\n const response = await fetch(modelsUrl);\n\n if (!response.ok) {\n return [];\n }\n\n const data = (await response.json()) as GatewayModelsResponse;\n const models = (data.data ?? []).filter((m) => !BLOCKED_MODELS.has(m.id));\n gatewayModelsCache = {\n models,\n expiry: Date.now() + CACHE_TTL,\n url: gatewayUrl,\n };\n return models;\n } catch {\n return [];\n }\n}\n\nexport function isAnthropicModel(model: GatewayModel): boolean {\n if (model.owned_by) {\n return model.owned_by === \"anthropic\";\n }\n return model.id.startsWith(\"claude-\") || model.id.startsWith(\"anthropic/\");\n}\n\nexport async function fetchArrayModelIds(\n options?: FetchGatewayModelsOptions,\n): Promise<string[]> {\n const models = await fetchArrayModels(options);\n return models.map((model) => model.id);\n}\n\nexport interface ArrayModelInfo {\n id: string;\n owned_by?: string;\n}\n\nlet arrayModelsCache: {\n models: ArrayModelInfo[];\n expiry: number;\n url: string;\n} | null = null;\n\nexport async function fetchArrayModels(\n options?: FetchGatewayModelsOptions,\n): Promise<ArrayModelInfo[]> {\n const gatewayUrl = options?.gatewayUrl ?? process.env.ANTHROPIC_BASE_URL;\n if (!gatewayUrl) {\n return [];\n }\n\n if (\n arrayModelsCache &&\n arrayModelsCache.url === gatewayUrl &&\n Date.now() < arrayModelsCache.expiry\n ) {\n return arrayModelsCache.models;\n }\n\n try {\n const base = new URL(gatewayUrl);\n base.pathname = \"/array/v1/models\";\n base.search = \"\";\n base.hash = \"\";\n const response = await fetch(base.toString());\n if (!response.ok) {\n return [];\n }\n const data = (await response.json()) as ArrayModelsResponse;\n const models = Array.isArray(data)\n ? data\n : (data.data ?? data.models ?? []);\n const results: ArrayModelInfo[] = [];\n for (const model of models) {\n const id = model?.id ? String(model.id) : \"\";\n if (!id) continue;\n results.push({ id, owned_by: model?.owned_by });\n }\n arrayModelsCache = {\n models: results,\n expiry: Date.now() + CACHE_TTL,\n url: gatewayUrl,\n };\n return results;\n } catch {\n return [];\n }\n}\n\nconst PROVIDER_NAMES: Record<string, string> = {\n anthropic: \"Anthropic\",\n openai: \"OpenAI\",\n \"google-vertex\": \"Gemini\",\n};\n\nexport function getProviderName(ownedBy: string): string {\n return PROVIDER_NAMES[ownedBy] ?? ownedBy;\n}\n\nconst PROVIDER_PREFIXES = [\"anthropic/\", \"openai/\", \"google-vertex/\"];\n\nexport function formatGatewayModelName(model: GatewayModel): string {\n let cleanId = model.id;\n for (const prefix of PROVIDER_PREFIXES) {\n if (cleanId.startsWith(prefix)) {\n cleanId = cleanId.slice(prefix.length);\n break;\n }\n }\n\n cleanId = cleanId.replace(/(\\d)-(\\d)/g, \"$1.$2\");\n\n const words = cleanId.split(/[-_]/).map((word) => {\n if (word.match(/^[0-9.]+$/)) return word;\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n });\n\n return words.join(\" \");\n}\n"],"mappings":";AAiBO,IAAM,wBAAwB;AAE9B,IAAM,iBAAiB,oBAAI,IAAI,CAAC,cAAc,m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AAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY;AAAA,EAClE,CAAC;AAED,SAAO,MAAM,KAAK,GAAG;AACvB;","names":[]}
1
+ {"version":3,"sources":["../src/gateway-models.ts"],"sourcesContent":["export interface GatewayModel {\n id: string;\n owned_by: string;\n context_window: number;\n supports_streaming: boolean;\n supports_vision: boolean;\n}\n\ninterface GatewayModelsResponse {\n object: \"list\";\n data: GatewayModel[];\n}\n\nexport interface FetchGatewayModelsOptions {\n gatewayUrl: string;\n}\n\nexport const DEFAULT_GATEWAY_MODEL = \"claude-opus-4-6\";\n\nexport const BLOCKED_MODELS = new Set([\"gpt-5-mini\", \"openai/gpt-5-mini\"]);\n\ntype ArrayModelsResponse =\n | {\n data?: Array<{ id?: string; owned_by?: string }>;\n models?: Array<{ id?: string; owned_by?: string }>;\n }\n | Array<{ id?: string; owned_by?: string }>;\n\nconst CACHE_TTL = 10 * 60 * 1000; // 10 minutes\n\nlet gatewayModelsCache: {\n models: GatewayModel[];\n expiry: number;\n url: string;\n} | null = null;\n\nexport async function fetchGatewayModels(\n options?: FetchGatewayModelsOptions,\n): Promise<GatewayModel[]> {\n const gatewayUrl = options?.gatewayUrl ?? process.env.ANTHROPIC_BASE_URL;\n if (!gatewayUrl) {\n return [];\n }\n\n if (\n gatewayModelsCache &&\n gatewayModelsCache.url === gatewayUrl &&\n Date.now() < gatewayModelsCache.expiry\n ) {\n return gatewayModelsCache.models;\n }\n\n const modelsUrl = `${gatewayUrl}/v1/models`;\n\n try {\n const response = await fetch(modelsUrl);\n\n if (!response.ok) {\n return [];\n }\n\n const data = (await response.json()) as GatewayModelsResponse;\n const models = (data.data ?? []).filter((m) => !BLOCKED_MODELS.has(m.id));\n gatewayModelsCache = {\n models,\n expiry: Date.now() + CACHE_TTL,\n url: gatewayUrl,\n };\n return models;\n } catch {\n return [];\n }\n}\n\nexport function isAnthropicModel(model: GatewayModel): boolean {\n if (model.owned_by) {\n return model.owned_by === \"anthropic\";\n }\n return model.id.startsWith(\"claude-\") || model.id.startsWith(\"anthropic/\");\n}\n\nexport interface ArrayModelInfo {\n id: string;\n owned_by?: string;\n}\n\nlet arrayModelsCache: {\n models: ArrayModelInfo[];\n expiry: number;\n url: string;\n} | null = null;\n\nexport async function fetchArrayModels(\n options?: FetchGatewayModelsOptions,\n): Promise<ArrayModelInfo[]> {\n const gatewayUrl = options?.gatewayUrl ?? process.env.ANTHROPIC_BASE_URL;\n if (!gatewayUrl) {\n return [];\n }\n\n if (\n arrayModelsCache &&\n arrayModelsCache.url === gatewayUrl &&\n Date.now() < arrayModelsCache.expiry\n ) {\n return arrayModelsCache.models;\n }\n\n try {\n const base = new URL(gatewayUrl);\n base.pathname = \"/array/v1/models\";\n base.search = \"\";\n base.hash = \"\";\n const response = await fetch(base.toString());\n if (!response.ok) {\n return [];\n }\n const data = (await response.json()) as ArrayModelsResponse;\n const models = Array.isArray(data)\n ? data\n : (data.data ?? data.models ?? []);\n const results: ArrayModelInfo[] = [];\n for (const model of models) {\n const id = model?.id ? String(model.id) : \"\";\n if (!id) continue;\n results.push({ id, owned_by: model?.owned_by });\n }\n arrayModelsCache = {\n models: results,\n expiry: Date.now() + CACHE_TTL,\n url: gatewayUrl,\n };\n return results;\n } catch {\n return [];\n }\n}\n\nconst PROVIDER_NAMES: Record<string, string> = {\n anthropic: \"Anthropic\",\n openai: \"OpenAI\",\n \"google-vertex\": \"Gemini\",\n};\n\nexport function getProviderName(ownedBy: string): string {\n return PROVIDER_NAMES[ownedBy] ?? ownedBy;\n}\n\nconst PROVIDER_PREFIXES = [\"anthropic/\", \"openai/\", \"google-vertex/\"];\n\nexport function formatGatewayModelName(model: GatewayModel): string {\n let cleanId = model.id;\n for (const prefix of PROVIDER_PREFIXES) {\n if (cleanId.startsWith(prefix)) {\n cleanId = cleanId.slice(prefix.length);\n break;\n }\n }\n\n cleanId = cleanId.replace(/(\\d)-(\\d)/g, \"$1.$2\");\n\n const words = cleanId.split(/[-_]/).map((word) => {\n if (word.match(/^[0-9.]+$/)) return word;\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n });\n\n return words.join(\" \");\n}\n"],"mappings":";AAiBO,IAAM,wBAAwB;AAE9B,IAAM,iBAAiB,oBAAI,IAAI,CAAC,cAAc,mBAAmB,CAAC;AASzE,IAAM,YAAY,KAAK,KAAK;AAE5B,IAAI,qBAIO;AAEX,eAAsB,mBACpB,SACyB;AACzB,QAAM,aAAa,SAAS,cAAc,QAAQ,IAAI;AACtD,MAAI,CAAC,YAAY;AACf,WAAO,CAAC;AAAA,EACV;AAEA,MACE,sBACA,mBAAmB,QAAQ,cAC3B,KAAK,IAAI,IAAI,mBAAmB,QAChC;AACA,WAAO,mBAAmB;AAAA,EAC5B;AAEA,QAAM,YAAY,GAAG,UAAU;AAE/B,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,SAAS;AAEtC,QAAI,CAAC,SAAS,IAAI;AAChB,aAAO,CAAC;AAAA,IACV;AAEA,UAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,UAAM,UAAU,KAAK,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,eAAe,IAAI,EAAE,EAAE,CAAC;AACxE,yBAAqB;AAAA,MACnB;AAAA,MACA,QAAQ,KAAK,IAAI,IAAI;AAAA,MACrB,KAAK;AAAA,IACP;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACF;AAEO,SAAS,iBAAiB,OAA8B;AAC7D,MAAI,MAAM,UAAU;AAClB,WAAO,MAAM,aAAa;AAAA,EAC5B;AACA,SAAO,MAAM,GAAG,WAAW,SAAS,KAAK,MAAM,GAAG,WAAW,YAAY;AAC3E;AAOA,IAAI,mBAIO;AAEX,eAAsB,iBACpB,SAC2B;AAC3B,QAAM,aAAa,SAAS,cAAc,QAAQ,IAAI;AACtD,MAAI,CAAC,YAAY;AACf,WAAO,CAAC;AAAA,EACV;AAEA,MACE,oBACA,iBAAiB,Q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C,SAAS;AAChD,QAAI,KAAK,MAAM,WAAW,EAAG,QAAO;AACpC,WAAO,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY;AAAA,EAClE,CAAC;AAED,SAAO,MAAM,KAAK,GAAG;AACvB;","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,259 +1,3 @@
1
- export { A as AcpConnection, a as AcpConnectionConfig, b as Agent, c as AgentAdapter, C as CodexProcessOptions, I as InProcessAcpConnection, O as OtelLogConfig, d as OtelLogWriter, S as SessionContext, e as SessionLogWriter, f as SessionLogWriterOptions, g as createAcpConnection } from './agent-DK1apkaG.js';
2
- import { McpServerConfig } from '@anthropic-ai/claude-agent-sdk';
3
- import { L as Logger } from './logger-DDBiMOOD.js';
4
- export { a as LoggerConfig } from './logger-DDBiMOOD.js';
5
- export { ArrayModelInfo, BLOCKED_MODELS, DEFAULT_GATEWAY_MODEL, FetchGatewayModelsOptions, GatewayModel, fetchArrayModels, fetchGatewayModels, formatGatewayModelName, getProviderName, isAnthropicModel } from './gateway-models.js';
6
- import { PostHogAPIClient } from './posthog-api.js';
7
- export { getLlmGatewayUrl } from './posthog-api.js';
8
- import { ContentBlock } from '@agentclientprotocol/sdk';
9
- import { TreeSnapshotEvent, DeviceInfo, TreeSnapshot } from './types.js';
10
- export { AgentConfig, AgentMode, FileChange, FileStatus, LogLevel, OnLogCallback, OtelTransportConfig, StoredEntry, StoredNotification, Task, TaskRun } from './types.js';
11
-
12
- /**
13
- * PostHog-specific ACP extensions.
14
- *
15
- * These follow the ACP extensibility model:
16
- * - Custom notification methods are prefixed with `_posthog/`
17
- * - Custom data can be attached via `_meta` fields
18
- *
19
- * Note: When using `extNotification()` from the ACP SDK, it automatically
20
- * adds an extra underscore prefix (e.g., `_posthog/tree_snapshot` becomes
21
- * `__posthog/tree_snapshot` in the log). Code that reads logs should handle both.
22
- *
23
- * See: https://agentclientprotocol.com/docs/extensibility
24
- */
25
- /**
26
- * Custom notification methods for PostHog-specific events.
27
- * Used with AgentSideConnection.extNotification() or Client.extNotification()
28
- */
29
- declare const POSTHOG_NOTIFICATIONS: {
30
- /** Git branch was created for a task */
31
- readonly BRANCH_CREATED: "_posthog/branch_created";
32
- /** Task run has started execution */
33
- readonly RUN_STARTED: "_posthog/run_started";
34
- /** Task has completed (success or failure) */
35
- readonly TASK_COMPLETE: "_posthog/task_complete";
36
- /** Error occurred during task execution */
37
- readonly ERROR: "_posthog/error";
38
- /** Console/log output from the agent */
39
- readonly CONSOLE: "_posthog/console";
40
- /** Maps taskRunId to agent's sessionId and adapter type (for resumption) */
41
- readonly SDK_SESSION: "_posthog/sdk_session";
42
- /** Tree state snapshot captured (git tree hash + file archive) */
43
- readonly TREE_SNAPSHOT: "_posthog/tree_snapshot";
44
- /** Agent mode changed (interactive/background) */
45
- readonly MODE_CHANGE: "_posthog/mode_change";
46
- /** Request to resume a session from previous state */
47
- readonly SESSION_RESUME: "_posthog/session/resume";
48
- /** User message sent from client to agent */
49
- readonly USER_MESSAGE: "_posthog/user_message";
50
- /** Request to cancel current operation */
51
- readonly CANCEL: "_posthog/cancel";
52
- /** Request to close the session */
53
- readonly CLOSE: "_posthog/close";
54
- /** Agent status update (thinking, working, etc.) */
55
- readonly STATUS: "_posthog/status";
56
- /** Task-level notification (progress, milestones) */
57
- readonly TASK_NOTIFICATION: "_posthog/task_notification";
58
- /** Marks a boundary for log compaction */
59
- readonly COMPACT_BOUNDARY: "_posthog/compact_boundary";
60
- };
61
- type PostHogNotificationType = (typeof POSTHOG_NOTIFICATIONS)[keyof typeof POSTHOG_NOTIFICATIONS];
62
- interface BranchCreatedPayload {
63
- branch: string;
64
- }
65
- interface RunStartedPayload {
66
- sessionId: string;
67
- runId: string;
68
- taskId?: string;
69
- }
70
- interface TaskCompletePayload {
71
- sessionId: string;
72
- taskId: string;
73
- }
74
- interface ErrorNotificationPayload {
75
- sessionId: string;
76
- message: string;
77
- error?: unknown;
78
- }
79
- interface ConsoleNotificationPayload {
80
- sessionId: string;
81
- level: "debug" | "info" | "warn" | "error";
82
- message: string;
83
- }
84
- interface SdkSessionPayload {
85
- taskRunId: string;
86
- sessionId: string;
87
- adapter: "claude" | "codex";
88
- }
89
- interface TreeSnapshotPayload {
90
- treeHash: string;
91
- baseCommit: string | null;
92
- archiveUrl?: string;
93
- changes: Array<{
94
- path: string;
95
- status: "A" | "M" | "D";
96
- }>;
97
- timestamp: string;
98
- interrupted?: boolean;
99
- device?: {
100
- type: "local" | "cloud";
101
- name?: string;
102
- };
103
- }
104
- interface ModeChangePayload {
105
- mode: "interactive" | "background";
106
- previous_mode: "interactive" | "background";
107
- }
108
- interface SessionResumePayload {
109
- sessionId: string;
110
- fromSnapshot?: string;
111
- }
112
- interface UserMessagePayload {
113
- content: string;
114
- }
115
- interface StatusPayload {
116
- sessionId: string;
117
- status: string;
118
- message?: string;
119
- }
120
- interface TaskNotificationPayload {
121
- sessionId: string;
122
- type: string;
123
- message?: string;
124
- data?: Record<string, unknown>;
125
- }
126
- interface CompactBoundaryPayload {
127
- sessionId: string;
128
- timestamp: string;
129
- }
130
- type PostHogNotificationPayload = BranchCreatedPayload | RunStartedPayload | TaskCompletePayload | ErrorNotificationPayload | ConsoleNotificationPayload | SdkSessionPayload | TreeSnapshotPayload | ModeChangePayload | SessionResumePayload | UserMessagePayload | StatusPayload | TaskNotificationPayload | CompactBoundaryPayload;
131
-
132
- declare function fetchMcpToolMetadata(mcpServers: Record<string, McpServerConfig>, logger?: Logger): Promise<void>;
133
1
  declare function isMcpToolReadOnly(toolName: string): boolean;
134
2
 
135
- /**
136
- * Resume - Restore agent state from persisted log
137
- *
138
- * Handles resuming a task from any point:
139
- * - Fetches log via the PostHog API
140
- * - Finds latest tree_snapshot event
141
- * - Rebuilds conversation from log events
142
- * - Restores working tree from snapshot
143
- *
144
- * Uses Saga pattern for atomic operations with clear success/failure tracking.
145
- *
146
- * The log is the single source of truth for:
147
- * - Conversation history (user_message, agent_message_chunk, tool_call, tool_result)
148
- * - Working tree state (tree_snapshot events)
149
- * - Session metadata (device info, mode changes)
150
- */
151
-
152
- interface ResumeState {
153
- conversation: ConversationTurn[];
154
- latestSnapshot: TreeSnapshotEvent | null;
155
- /** Whether the tree snapshot was successfully applied (files restored) */
156
- snapshotApplied: boolean;
157
- interrupted: boolean;
158
- lastDevice?: DeviceInfo;
159
- logEntryCount: number;
160
- }
161
- interface ConversationTurn {
162
- role: "user" | "assistant";
163
- content: ContentBlock[];
164
- toolCalls?: ToolCallInfo[];
165
- }
166
- interface ToolCallInfo {
167
- toolCallId: string;
168
- toolName: string;
169
- input: unknown;
170
- result?: unknown;
171
- }
172
- interface ResumeConfig {
173
- taskId: string;
174
- runId: string;
175
- repositoryPath: string;
176
- apiClient: PostHogAPIClient;
177
- logger?: Logger;
178
- }
179
- /**
180
- * Resume a task from its persisted log.
181
- * Returns the rebuilt state for the agent to continue from.
182
- *
183
- * Uses Saga pattern internally for atomic operations.
184
- * Note: snapshotApplied field indicates if files were actually restored -
185
- * even if latestSnapshot is non-null, files may not have been restored if
186
- * the snapshot had no archive URL or download/extraction failed.
187
- */
188
- declare function resumeFromLog(config: ResumeConfig): Promise<ResumeState>;
189
- /**
190
- * Convert resumed conversation back to API format for continuation.
191
- */
192
- declare function conversationToPromptHistory(conversation: ConversationTurn[]): Array<{
193
- role: "user" | "assistant";
194
- content: ContentBlock[];
195
- }>;
196
-
197
- /**
198
- * TreeTracker - Git tree-based state capture for cloud/local sync
199
- *
200
- * Captures the entire working state as a git tree hash + archive:
201
- * - Atomic state snapshots (no partial syncs)
202
- * - Efficient delta detection using git's diffing
203
- * - Simpler resume logic (restore tree, continue)
204
- *
205
- * Uses Saga pattern for atomic operations with automatic rollback on failure.
206
- * Uses a temporary git index to avoid modifying the user's staging area.
207
- */
208
-
209
- interface TreeTrackerConfig {
210
- repositoryPath: string;
211
- taskId: string;
212
- runId: string;
213
- apiClient?: PostHogAPIClient;
214
- logger?: Logger;
215
- }
216
- declare class TreeTracker {
217
- private repositoryPath;
218
- private taskId;
219
- private runId;
220
- private apiClient?;
221
- private logger;
222
- private lastTreeHash;
223
- constructor(config: TreeTrackerConfig);
224
- /**
225
- * Capture current working tree state as a snapshot.
226
- * Uses a temporary index to avoid modifying user's staging area.
227
- * Uses Saga pattern for atomic operation with automatic cleanup on failure.
228
- */
229
- captureTree(options?: {
230
- interrupted?: boolean;
231
- }): Promise<TreeSnapshot | null>;
232
- /**
233
- * Download and apply a tree snapshot.
234
- * Uses Saga pattern for atomic operation with rollback on failure.
235
- */
236
- applyTreeSnapshot(snapshot: TreeSnapshot): Promise<void>;
237
- /**
238
- * Get the last captured tree hash.
239
- */
240
- getLastTreeHash(): string | null;
241
- /**
242
- * Set the last tree hash (used when resuming).
243
- */
244
- setLastTreeHash(hash: string | null): void;
245
- }
246
- /**
247
- * Check if a commit is available on any remote branch.
248
- * Used to validate that cloud can fetch the base commit during handoff.
249
- */
250
- declare function isCommitOnRemote(commit: string, cwd: string): Promise<boolean>;
251
- /**
252
- * Validate that a snapshot can be handed off to cloud execution.
253
- * Cloud needs to be able to fetch the baseCommit from a remote.
254
- *
255
- * @throws Error if the snapshot cannot be restored on cloud
256
- */
257
- declare function validateForCloudHandoff(snapshot: TreeSnapshot, repositoryPath: string): Promise<void>;
258
-
259
- export { type BranchCreatedPayload, type CompactBoundaryPayload, type ConsoleNotificationPayload, type ConversationTurn, DeviceInfo, type ErrorNotificationPayload, Logger, type ModeChangePayload, POSTHOG_NOTIFICATIONS, PostHogAPIClient, type PostHogNotificationPayload, type PostHogNotificationType, type ResumeConfig, type ResumeState, type RunStartedPayload, type SdkSessionPayload, type SessionResumePayload, type StatusPayload, type TaskCompletePayload, type TaskNotificationPayload, type ToolCallInfo, TreeSnapshot, TreeSnapshotEvent, type TreeSnapshotPayload, TreeTracker, type TreeTrackerConfig, type UserMessagePayload, conversationToPromptHistory, fetchMcpToolMetadata, isCommitOnRemote, isMcpToolReadOnly, resumeFromLog, validateForCloudHandoff };
3
+ export { isMcpToolReadOnly };