@posthog/agent 2.3.13 → 2.3.15
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/adapters/claude/conversion/tool-use-to-acp.js.map +1 -1
- package/dist/adapters/claude/permissions/permission-options.js.map +1 -1
- package/dist/adapters/claude/questions/utils.js.map +1 -1
- package/dist/adapters/claude/session/jsonl-hydration.js.map +1 -1
- package/dist/adapters/claude/tools.js.map +1 -1
- package/dist/agent.js +1 -1
- package/dist/agent.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/posthog-api.js +1 -1
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +1 -1
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +1 -1
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/acp-connection.ts +7 -7
- package/src/adapters/base-acp-agent.ts +3 -3
- package/src/adapters/claude/claude-agent.ts +15 -15
- package/src/adapters/claude/conversion/sdk-to-acp.ts +6 -6
- package/src/adapters/claude/conversion/tool-use-to-acp.ts +2 -2
- package/src/adapters/claude/hooks.ts +3 -3
- package/src/adapters/claude/mcp/tool-metadata.ts +1 -1
- package/src/adapters/claude/permissions/permission-handlers.ts +8 -8
- package/src/adapters/claude/permissions/permission-options.ts +1 -1
- package/src/adapters/claude/questions/utils.ts +1 -1
- package/src/adapters/claude/session/jsonl-hydration.test.ts +2 -2
- package/src/adapters/claude/session/jsonl-hydration.ts +2 -2
- package/src/adapters/claude/session/options.ts +7 -7
- package/src/adapters/claude/tools.ts +3 -3
- package/src/adapters/claude/types.ts +4 -4
- package/src/adapters/codex/spawn.ts +2 -2
- package/src/agent.ts +6 -6
- package/src/execution-mode.ts +1 -1
- package/src/index.ts +1 -1
- package/src/otel-log-writer.test.ts +2 -2
- package/src/otel-log-writer.ts +2 -2
- package/src/posthog-api.ts +2 -2
- package/src/resume.ts +4 -4
- package/src/sagas/apply-snapshot-saga.test.ts +2 -2
- package/src/sagas/apply-snapshot-saga.ts +2 -2
- package/src/sagas/capture-tree-saga.test.ts +3 -3
- package/src/sagas/capture-tree-saga.ts +2 -2
- package/src/sagas/resume-saga.test.ts +4 -4
- package/src/sagas/resume-saga.ts +5 -5
- package/src/sagas/test-fixtures.ts +3 -3
- package/src/server/agent-server.test.ts +5 -5
- package/src/server/agent-server.ts +14 -14
- package/src/server/bin.ts +2 -2
- package/src/server/question-relay.test.ts +5 -5
- package/src/server/schemas.test.ts +1 -1
- package/src/server/types.ts +2 -2
- package/src/server/utils/retry.test.ts +1 -1
- package/src/server/utils/sse-parser.test.ts +1 -1
- package/src/session-log-writer.test.ts +3 -3
- package/src/session-log-writer.ts +4 -4
- package/src/test/fixtures/api.ts +2 -2
- package/src/test/fixtures/config.ts +2 -2
- package/src/tree-tracker.ts +5 -5
- package/src/utils/async-mutex.test.ts +1 -1
- package/src/utils/common.ts +1 -1
- package/src/utils/logger.ts +1 -1
- package/src/utils/streams.ts +1 -1
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { AgentSideConnection, ndJsonStream } from "@agentclientprotocol/sdk";
|
|
2
|
-
import { POSTHOG_NOTIFICATIONS } from "../acp-extensions
|
|
3
|
-
import type { SessionLogWriter } from "../session-log-writer
|
|
4
|
-
import type { ProcessSpawnedCallback } from "../types
|
|
5
|
-
import { Logger } from "../utils/logger
|
|
2
|
+
import { POSTHOG_NOTIFICATIONS } from "../acp-extensions";
|
|
3
|
+
import type { SessionLogWriter } from "../session-log-writer";
|
|
4
|
+
import type { ProcessSpawnedCallback } from "../types";
|
|
5
|
+
import { Logger } from "../utils/logger";
|
|
6
6
|
import {
|
|
7
7
|
createBidirectionalStreams,
|
|
8
8
|
createTappedWritableStream,
|
|
9
9
|
nodeReadableToWebReadable,
|
|
10
10
|
nodeWritableToWebWritable,
|
|
11
11
|
type StreamPair,
|
|
12
|
-
} from "../utils/streams
|
|
13
|
-
import { ClaudeAcpAgent } from "./claude/claude-agent
|
|
14
|
-
import { type CodexProcessOptions, spawnCodexProcess } from "./codex/spawn
|
|
12
|
+
} from "../utils/streams";
|
|
13
|
+
import { ClaudeAcpAgent } from "./claude/claude-agent";
|
|
14
|
+
import { type CodexProcessOptions, spawnCodexProcess } from "./codex/spawn";
|
|
15
15
|
|
|
16
16
|
type AgentAdapter = "claude" | "codex";
|
|
17
17
|
|
|
@@ -21,9 +21,9 @@ import {
|
|
|
21
21
|
fetchGatewayModels,
|
|
22
22
|
formatGatewayModelName,
|
|
23
23
|
isAnthropicModel,
|
|
24
|
-
} from "../gateway-models
|
|
25
|
-
import { Logger } from "../utils/logger
|
|
26
|
-
import type { SettingsManager } from "./claude/session/settings
|
|
24
|
+
} from "../gateway-models";
|
|
25
|
+
import { Logger } from "../utils/logger";
|
|
26
|
+
import type { SettingsManager } from "./claude/session/settings";
|
|
27
27
|
|
|
28
28
|
export interface BaseSession {
|
|
29
29
|
notificationHistory: SessionNotification[];
|
|
@@ -44,40 +44,40 @@ import {
|
|
|
44
44
|
} from "@anthropic-ai/claude-agent-sdk";
|
|
45
45
|
import { v7 as uuidv7 } from "uuid";
|
|
46
46
|
import packageJson from "../../../package.json" with { type: "json" };
|
|
47
|
-
import { unreachable, withTimeout } from "../../utils/common
|
|
48
|
-
import { Logger } from "../../utils/logger
|
|
49
|
-
import { Pushable } from "../../utils/streams
|
|
50
|
-
import { BaseAcpAgent } from "../base-acp-agent
|
|
51
|
-
import { promptToClaude } from "./conversion/acp-to-sdk
|
|
47
|
+
import { unreachable, withTimeout } from "../../utils/common";
|
|
48
|
+
import { Logger } from "../../utils/logger";
|
|
49
|
+
import { Pushable } from "../../utils/streams";
|
|
50
|
+
import { BaseAcpAgent } from "../base-acp-agent";
|
|
51
|
+
import { promptToClaude } from "./conversion/acp-to-sdk";
|
|
52
52
|
import {
|
|
53
53
|
handleResultMessage,
|
|
54
54
|
handleStreamEvent,
|
|
55
55
|
handleSystemMessage,
|
|
56
56
|
handleUserAssistantMessage,
|
|
57
|
-
} from "./conversion/sdk-to-acp
|
|
58
|
-
import { fetchMcpToolMetadata } from "./mcp/tool-metadata
|
|
59
|
-
import { canUseTool } from "./permissions/permission-handlers
|
|
60
|
-
import { getAvailableSlashCommands } from "./session/commands
|
|
61
|
-
import { parseMcpServers } from "./session/mcp-config
|
|
62
|
-
import { DEFAULT_MODEL, toSdkModelId } from "./session/models
|
|
57
|
+
} from "./conversion/sdk-to-acp";
|
|
58
|
+
import { fetchMcpToolMetadata } from "./mcp/tool-metadata";
|
|
59
|
+
import { canUseTool } from "./permissions/permission-handlers";
|
|
60
|
+
import { getAvailableSlashCommands } from "./session/commands";
|
|
61
|
+
import { parseMcpServers } from "./session/mcp-config";
|
|
62
|
+
import { DEFAULT_MODEL, toSdkModelId } from "./session/models";
|
|
63
63
|
import {
|
|
64
64
|
buildSessionOptions,
|
|
65
65
|
buildSystemPrompt,
|
|
66
66
|
type ProcessSpawnedInfo,
|
|
67
|
-
} from "./session/options
|
|
68
|
-
import { SettingsManager } from "./session/settings
|
|
67
|
+
} from "./session/options";
|
|
68
|
+
import { SettingsManager } from "./session/settings";
|
|
69
69
|
import {
|
|
70
70
|
CODE_EXECUTION_MODES,
|
|
71
71
|
type CodeExecutionMode,
|
|
72
72
|
getAvailableModes,
|
|
73
|
-
} from "./tools
|
|
73
|
+
} from "./tools";
|
|
74
74
|
import type {
|
|
75
75
|
BackgroundTerminal,
|
|
76
76
|
EffortLevel,
|
|
77
77
|
NewSessionMeta,
|
|
78
78
|
Session,
|
|
79
79
|
ToolUseCache,
|
|
80
|
-
} from "./types
|
|
80
|
+
} from "./types";
|
|
81
81
|
|
|
82
82
|
const SESSION_VALIDATION_TIMEOUT_MS = 10_000;
|
|
83
83
|
const MAX_TITLE_LENGTH = 256;
|
|
@@ -17,18 +17,18 @@ import type {
|
|
|
17
17
|
BetaContentBlock,
|
|
18
18
|
BetaRawContentBlockDelta,
|
|
19
19
|
} from "@anthropic-ai/sdk/resources/beta.mjs";
|
|
20
|
-
import { image, text } from "../../../utils/acp-content
|
|
21
|
-
import { unreachable } from "../../../utils/common
|
|
22
|
-
import type { Logger } from "../../../utils/logger
|
|
23
|
-
import { registerHookCallback } from "../hooks
|
|
24
|
-
import type { Session, ToolUpdateMeta, ToolUseCache } from "../types
|
|
20
|
+
import { image, text } from "../../../utils/acp-content";
|
|
21
|
+
import { unreachable } from "../../../utils/common";
|
|
22
|
+
import type { Logger } from "../../../utils/logger";
|
|
23
|
+
import { registerHookCallback } from "../hooks";
|
|
24
|
+
import type { Session, ToolUpdateMeta, ToolUseCache } from "../types";
|
|
25
25
|
import {
|
|
26
26
|
type ClaudePlanEntry,
|
|
27
27
|
planEntries,
|
|
28
28
|
toolInfoFromToolUse,
|
|
29
29
|
toolUpdateFromEditToolResponse,
|
|
30
30
|
toolUpdateFromToolResult,
|
|
31
|
-
} from "./tool-use-to-acp
|
|
31
|
+
} from "./tool-use-to-acp";
|
|
32
32
|
|
|
33
33
|
type AnthropicContentChunk =
|
|
34
34
|
| ContentBlockParam
|
|
@@ -29,8 +29,8 @@ function stripSystemReminders(value: string): string {
|
|
|
29
29
|
return value.replace(SYSTEM_REMINDER_REGEX, "");
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
import { resourceLink, text, toolContent } from "../../../utils/acp-content
|
|
33
|
-
import { getMcpToolMetadata } from "../mcp/tool-metadata
|
|
32
|
+
import { resourceLink, text, toolContent } from "../../../utils/acp-content";
|
|
33
|
+
import { getMcpToolMetadata } from "../mcp/tool-metadata";
|
|
34
34
|
|
|
35
35
|
type ToolInfo = Pick<ToolCall, "title" | "kind" | "content" | "locations">;
|
|
36
36
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HookCallback, HookInput } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
-
import type { Logger } from "../../utils/logger
|
|
3
|
-
import type { SettingsManager } from "./session/settings
|
|
4
|
-
import type { CodeExecutionMode } from "./tools
|
|
2
|
+
import type { Logger } from "../../utils/logger";
|
|
3
|
+
import type { SettingsManager } from "./session/settings";
|
|
4
|
+
import type { CodeExecutionMode } from "./tools";
|
|
5
5
|
|
|
6
6
|
const toolUseCallbacks: {
|
|
7
7
|
[toolUseId: string]: {
|
|
@@ -3,27 +3,27 @@ import type {
|
|
|
3
3
|
RequestPermissionResponse,
|
|
4
4
|
} from "@agentclientprotocol/sdk";
|
|
5
5
|
import type { PermissionUpdate } from "@anthropic-ai/claude-agent-sdk";
|
|
6
|
-
import { text } from "../../../utils/acp-content
|
|
7
|
-
import type { Logger } from "../../../utils/logger
|
|
8
|
-
import { toolInfoFromToolUse } from "../conversion/tool-use-to-acp
|
|
6
|
+
import { text } from "../../../utils/acp-content";
|
|
7
|
+
import type { Logger } from "../../../utils/logger";
|
|
8
|
+
import { toolInfoFromToolUse } from "../conversion/tool-use-to-acp";
|
|
9
9
|
import {
|
|
10
10
|
getClaudePlansDir,
|
|
11
11
|
getLatestAssistantText,
|
|
12
12
|
isClaudePlanFilePath,
|
|
13
13
|
isPlanReady,
|
|
14
|
-
} from "../plan/utils
|
|
14
|
+
} from "../plan/utils";
|
|
15
15
|
import {
|
|
16
16
|
type AskUserQuestionInput,
|
|
17
17
|
normalizeAskUserQuestionInput,
|
|
18
18
|
OPTION_PREFIX,
|
|
19
19
|
type QuestionItem,
|
|
20
|
-
} from "../questions/utils
|
|
21
|
-
import { isToolAllowedForMode, WRITE_TOOLS } from "../tools
|
|
22
|
-
import type { Session } from "../types
|
|
20
|
+
} from "../questions/utils";
|
|
21
|
+
import { isToolAllowedForMode, WRITE_TOOLS } from "../tools";
|
|
22
|
+
import type { Session } from "../types";
|
|
23
23
|
import {
|
|
24
24
|
buildExitPlanModePermissionOptions,
|
|
25
25
|
buildPermissionOptions,
|
|
26
|
-
} from "./permission-options
|
|
26
|
+
} from "./permission-options";
|
|
27
27
|
|
|
28
28
|
export type ToolPermissionResult =
|
|
29
29
|
| {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PermissionUpdate } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
-
import { BASH_TOOLS, READ_TOOLS, SEARCH_TOOLS, WRITE_TOOLS } from "../tools
|
|
2
|
+
import { BASH_TOOLS, READ_TOOLS, SEARCH_TOOLS, WRITE_TOOLS } from "../tools";
|
|
3
3
|
|
|
4
4
|
export interface PermissionOption {
|
|
5
5
|
kind: "allow_once" | "allow_always" | "reject_once" | "reject_always";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ToolCallContent, ToolKind } from "@agentclientprotocol/sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import type { PermissionOption } from "../permissions/permission-options
|
|
3
|
+
import type { PermissionOption } from "../permissions/permission-options";
|
|
4
4
|
|
|
5
5
|
export const OPTION_PREFIX = "option_";
|
|
6
6
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import type { StoredEntry } from "../../../types
|
|
2
|
+
import type { StoredEntry } from "../../../types";
|
|
3
3
|
import {
|
|
4
4
|
conversationTurnsToJsonlEntries,
|
|
5
5
|
getSessionJsonlPath,
|
|
6
6
|
rebuildConversation,
|
|
7
|
-
} from "./jsonl-hydration
|
|
7
|
+
} from "./jsonl-hydration";
|
|
8
8
|
|
|
9
9
|
function entry(
|
|
10
10
|
sessionUpdate: string,
|
|
@@ -3,8 +3,8 @@ import * as fs from "node:fs/promises";
|
|
|
3
3
|
import * as os from "node:os";
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
import type { ContentBlock } from "@agentclientprotocol/sdk";
|
|
6
|
-
import type { PostHogAPIClient } from "../../../posthog-api
|
|
7
|
-
import type { StoredEntry } from "../../../types
|
|
6
|
+
import type { PostHogAPIClient } from "../../../posthog-api";
|
|
7
|
+
import type { StoredEntry } from "../../../types";
|
|
8
8
|
|
|
9
9
|
interface ConversationTurn {
|
|
10
10
|
role: "user" | "assistant";
|
|
@@ -9,17 +9,17 @@ import type {
|
|
|
9
9
|
SpawnedProcess,
|
|
10
10
|
SpawnOptions,
|
|
11
11
|
} from "@anthropic-ai/claude-agent-sdk";
|
|
12
|
-
import { IS_ROOT } from "../../../utils/common
|
|
13
|
-
import type { Logger } from "../../../utils/logger
|
|
12
|
+
import { IS_ROOT } from "../../../utils/common";
|
|
13
|
+
import type { Logger } from "../../../utils/logger";
|
|
14
14
|
import {
|
|
15
15
|
createPostToolUseHook,
|
|
16
16
|
createPreToolUseHook,
|
|
17
17
|
type OnModeChange,
|
|
18
|
-
} from "../hooks
|
|
19
|
-
import type { CodeExecutionMode } from "../tools
|
|
20
|
-
import type { EffortLevel } from "../types
|
|
21
|
-
import { DEFAULT_MODEL } from "./models
|
|
22
|
-
import type { SettingsManager } from "./settings
|
|
18
|
+
} from "../hooks";
|
|
19
|
+
import type { CodeExecutionMode } from "../tools";
|
|
20
|
+
import type { EffortLevel } from "../types";
|
|
21
|
+
import { DEFAULT_MODEL } from "./models";
|
|
22
|
+
import type { SettingsManager } from "./settings";
|
|
23
23
|
|
|
24
24
|
export interface ProcessSpawnedInfo {
|
|
25
25
|
pid: number;
|
|
@@ -3,10 +3,10 @@ export {
|
|
|
3
3
|
type CodeExecutionMode,
|
|
4
4
|
getAvailableModes,
|
|
5
5
|
type ModeInfo,
|
|
6
|
-
} from "../../execution-mode
|
|
6
|
+
} from "../../execution-mode";
|
|
7
7
|
|
|
8
|
-
import type { CodeExecutionMode } from "../../execution-mode
|
|
9
|
-
import { isMcpToolReadOnly } from "./mcp/tool-metadata
|
|
8
|
+
import type { CodeExecutionMode } from "../../execution-mode";
|
|
9
|
+
import { isMcpToolReadOnly } from "./mcp/tool-metadata";
|
|
10
10
|
|
|
11
11
|
export const READ_TOOLS: Set<string> = new Set(["Read", "NotebookRead"]);
|
|
12
12
|
|
|
@@ -8,10 +8,10 @@ import type {
|
|
|
8
8
|
Query,
|
|
9
9
|
SDKUserMessage,
|
|
10
10
|
} from "@anthropic-ai/claude-agent-sdk";
|
|
11
|
-
import type { Pushable } from "../../utils/streams
|
|
12
|
-
import type { BaseSession } from "../base-acp-agent
|
|
13
|
-
import type { SettingsManager } from "./session/settings
|
|
14
|
-
import type { CodeExecutionMode } from "./tools
|
|
11
|
+
import type { Pushable } from "../../utils/streams";
|
|
12
|
+
import type { BaseSession } from "../base-acp-agent";
|
|
13
|
+
import type { SettingsManager } from "./session/settings";
|
|
14
|
+
import type { CodeExecutionMode } from "./tools";
|
|
15
15
|
|
|
16
16
|
export type EffortLevel = "low" | "medium" | "high" | "max";
|
|
17
17
|
|
|
@@ -2,8 +2,8 @@ import { type ChildProcess, spawn } from "node:child_process";
|
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { delimiter, dirname } from "node:path";
|
|
4
4
|
import type { Readable, Writable } from "node:stream";
|
|
5
|
-
import type { ProcessSpawnedCallback } from "../../types
|
|
6
|
-
import { Logger } from "../../utils/logger
|
|
5
|
+
import type { ProcessSpawnedCallback } from "../../types";
|
|
6
|
+
import { Logger } from "../../utils/logger";
|
|
7
7
|
|
|
8
8
|
export interface CodexProcessOptions {
|
|
9
9
|
cwd?: string;
|
package/src/agent.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAcpConnection,
|
|
3
3
|
type InProcessAcpConnection,
|
|
4
|
-
} from "./adapters/acp-connection
|
|
4
|
+
} from "./adapters/acp-connection";
|
|
5
5
|
import {
|
|
6
6
|
BLOCKED_MODELS,
|
|
7
7
|
DEFAULT_GATEWAY_MODEL,
|
|
8
8
|
fetchArrayModels,
|
|
9
|
-
} from "./gateway-models
|
|
10
|
-
import { PostHogAPIClient, type TaskRunUpdate } from "./posthog-api
|
|
11
|
-
import { SessionLogWriter } from "./session-log-writer
|
|
12
|
-
import type { AgentConfig, TaskExecutionOptions } from "./types
|
|
13
|
-
import { Logger } from "./utils/logger
|
|
9
|
+
} from "./gateway-models";
|
|
10
|
+
import { PostHogAPIClient, type TaskRunUpdate } from "./posthog-api";
|
|
11
|
+
import { SessionLogWriter } from "./session-log-writer";
|
|
12
|
+
import type { AgentConfig, TaskExecutionOptions } from "./types";
|
|
13
|
+
import { Logger } from "./utils/logger";
|
|
14
14
|
|
|
15
15
|
export class Agent {
|
|
16
16
|
private posthogAPI?: PostHogAPIClient;
|
package/src/execution-mode.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { isMcpToolReadOnly } from "./adapters/claude/mcp/tool-metadata
|
|
1
|
+
export { isMcpToolReadOnly } from "./adapters/claude/mcp/tool-metadata";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { OtelLogWriter } from "./otel-log-writer
|
|
3
|
-
import type { StoredNotification } from "./types
|
|
2
|
+
import { OtelLogWriter } from "./otel-log-writer";
|
|
3
|
+
import type { StoredNotification } from "./types";
|
|
4
4
|
|
|
5
5
|
// Mock the OTEL exporter
|
|
6
6
|
const mockExport = vi.fn((_logs, callback) => {
|
package/src/otel-log-writer.ts
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
LoggerProvider,
|
|
7
7
|
} from "@opentelemetry/sdk-logs";
|
|
8
8
|
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
9
|
-
import type { StoredNotification } from "./types
|
|
10
|
-
import type { Logger } from "./utils/logger
|
|
9
|
+
import type { StoredNotification } from "./types";
|
|
10
|
+
import type { Logger } from "./utils/logger";
|
|
11
11
|
|
|
12
12
|
export interface OtelLogConfig {
|
|
13
13
|
/** PostHog ingest host, e.g., "https://us.i.posthog.com" */
|
package/src/posthog-api.ts
CHANGED
package/src/resume.ts
CHANGED
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import type { ContentBlock } from "@agentclientprotocol/sdk";
|
|
19
|
-
import type { PostHogAPIClient } from "./posthog-api
|
|
20
|
-
import { ResumeSaga } from "./sagas/resume-saga
|
|
21
|
-
import type { DeviceInfo, TreeSnapshotEvent } from "./types
|
|
22
|
-
import { Logger } from "./utils/logger
|
|
19
|
+
import type { PostHogAPIClient } from "./posthog-api";
|
|
20
|
+
import { ResumeSaga } from "./sagas/resume-saga";
|
|
21
|
+
import type { DeviceInfo, TreeSnapshotEvent } from "./types";
|
|
22
|
+
import { Logger } from "./utils/logger";
|
|
23
23
|
|
|
24
24
|
export interface ResumeState {
|
|
25
25
|
conversation: ConversationTurn[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import type { SagaLogger } from "@posthog/shared";
|
|
3
3
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
-
import { ApplySnapshotSaga } from "./apply-snapshot-saga
|
|
4
|
+
import { ApplySnapshotSaga } from "./apply-snapshot-saga";
|
|
5
5
|
import {
|
|
6
6
|
createArchiveBuffer,
|
|
7
7
|
createMockApiClient,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
createSnapshot,
|
|
10
10
|
createTestRepo,
|
|
11
11
|
type TestRepo,
|
|
12
|
-
} from "./test-fixtures
|
|
12
|
+
} from "./test-fixtures";
|
|
13
13
|
|
|
14
14
|
describe("ApplySnapshotSaga", () => {
|
|
15
15
|
let repo: TestRepo;
|
|
@@ -2,8 +2,8 @@ import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { ApplyTreeSaga as GitApplyTreeSaga } from "@posthog/git/sagas/tree";
|
|
4
4
|
import { Saga } from "@posthog/shared";
|
|
5
|
-
import type { PostHogAPIClient } from "../posthog-api
|
|
6
|
-
import type { TreeSnapshot } from "../types
|
|
5
|
+
import type { PostHogAPIClient } from "../posthog-api";
|
|
6
|
+
import type { TreeSnapshot } from "../types";
|
|
7
7
|
|
|
8
8
|
export interface ApplySnapshotInput {
|
|
9
9
|
snapshot: TreeSnapshot;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import type { SagaLogger } from "@posthog/shared";
|
|
3
3
|
import { afterEach, beforeEach, describe, expect, it, type vi } from "vitest";
|
|
4
|
-
import { isCommitOnRemote, validateForCloudHandoff } from "../tree-tracker
|
|
5
|
-
import { CaptureTreeSaga } from "./capture-tree-saga
|
|
4
|
+
import { isCommitOnRemote, validateForCloudHandoff } from "../tree-tracker";
|
|
5
|
+
import { CaptureTreeSaga } from "./capture-tree-saga";
|
|
6
6
|
import {
|
|
7
7
|
createMockApiClient,
|
|
8
8
|
createMockLogger,
|
|
9
9
|
createSnapshot,
|
|
10
10
|
createTestRepo,
|
|
11
11
|
type TestRepo,
|
|
12
|
-
} from "./test-fixtures
|
|
12
|
+
} from "./test-fixtures";
|
|
13
13
|
|
|
14
14
|
describe("CaptureTreeSaga", () => {
|
|
15
15
|
let repo: TestRepo;
|
|
@@ -3,8 +3,8 @@ import { readFile, rm } from "node:fs/promises";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { CaptureTreeSaga as GitCaptureTreeSaga } from "@posthog/git/sagas/tree";
|
|
5
5
|
import { Saga } from "@posthog/shared";
|
|
6
|
-
import type { PostHogAPIClient } from "../posthog-api
|
|
7
|
-
import type { TreeSnapshot } from "../types
|
|
6
|
+
import type { PostHogAPIClient } from "../posthog-api";
|
|
7
|
+
import type { TreeSnapshot } from "../types";
|
|
8
8
|
|
|
9
9
|
export interface CaptureTreeInput {
|
|
10
10
|
repositoryPath: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { SagaLogger } from "@posthog/shared";
|
|
2
2
|
import { afterEach, beforeEach, describe, expect, it, type vi } from "vitest";
|
|
3
|
-
import { POSTHOG_NOTIFICATIONS } from "../acp-extensions
|
|
4
|
-
import type { PostHogAPIClient } from "../posthog-api
|
|
5
|
-
import { ResumeSaga } from "./resume-saga
|
|
3
|
+
import { POSTHOG_NOTIFICATIONS } from "../acp-extensions";
|
|
4
|
+
import type { PostHogAPIClient } from "../posthog-api";
|
|
5
|
+
import { ResumeSaga } from "./resume-saga";
|
|
6
6
|
import {
|
|
7
7
|
createAgentChunk,
|
|
8
8
|
createAgentMessage,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
createTreeSnapshotNotification,
|
|
18
18
|
createUserMessage,
|
|
19
19
|
type TestRepo,
|
|
20
|
-
} from "./test-fixtures
|
|
20
|
+
} from "./test-fixtures";
|
|
21
21
|
|
|
22
22
|
describe("ResumeSaga", () => {
|
|
23
23
|
let repo: TestRepo;
|
package/src/sagas/resume-saga.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { ContentBlock } from "@agentclientprotocol/sdk";
|
|
2
2
|
import { Saga } from "@posthog/shared";
|
|
3
|
-
import { POSTHOG_NOTIFICATIONS } from "../acp-extensions
|
|
4
|
-
import type { PostHogAPIClient } from "../posthog-api
|
|
5
|
-
import { TreeTracker } from "../tree-tracker
|
|
3
|
+
import { POSTHOG_NOTIFICATIONS } from "../acp-extensions";
|
|
4
|
+
import type { PostHogAPIClient } from "../posthog-api";
|
|
5
|
+
import { TreeTracker } from "../tree-tracker";
|
|
6
6
|
import type {
|
|
7
7
|
DeviceInfo,
|
|
8
8
|
StoredNotification,
|
|
9
9
|
TreeSnapshotEvent,
|
|
10
|
-
} from "../types
|
|
11
|
-
import { Logger } from "../utils/logger
|
|
10
|
+
} from "../types";
|
|
11
|
+
import { Logger } from "../utils/logger";
|
|
12
12
|
|
|
13
13
|
export interface ConversationTurn {
|
|
14
14
|
role: "user" | "assistant";
|
|
@@ -7,9 +7,9 @@ import { promisify } from "node:util";
|
|
|
7
7
|
import type { SagaLogger } from "@posthog/shared";
|
|
8
8
|
import * as tar from "tar";
|
|
9
9
|
import { vi } from "vitest";
|
|
10
|
-
import { POSTHOG_NOTIFICATIONS } from "../acp-extensions
|
|
11
|
-
import type { PostHogAPIClient } from "../posthog-api
|
|
12
|
-
import type { StoredNotification, TaskRun, TreeSnapshot } from "../types
|
|
10
|
+
import { POSTHOG_NOTIFICATIONS } from "../acp-extensions";
|
|
11
|
+
import type { PostHogAPIClient } from "../posthog-api";
|
|
12
|
+
import type { StoredNotification, TaskRun, TreeSnapshot } from "../types";
|
|
13
13
|
|
|
14
14
|
const execFileAsync = promisify(execFile);
|
|
15
15
|
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
expect,
|
|
10
10
|
it,
|
|
11
11
|
} from "vitest";
|
|
12
|
-
import { createTestRepo, type TestRepo } from "../test/fixtures/api
|
|
13
|
-
import { createPostHogHandlers } from "../test/mocks/msw-handlers
|
|
14
|
-
import type { TaskRun } from "../types
|
|
15
|
-
import { AgentServer } from "./agent-server
|
|
16
|
-
import { type JwtPayload, SANDBOX_CONNECTION_AUDIENCE } from "./jwt
|
|
12
|
+
import { createTestRepo, type TestRepo } from "../test/fixtures/api";
|
|
13
|
+
import { createPostHogHandlers } from "../test/mocks/msw-handlers";
|
|
14
|
+
import type { TaskRun } from "../types";
|
|
15
|
+
import { AgentServer } from "./agent-server";
|
|
16
|
+
import { type JwtPayload, SANDBOX_CONNECTION_AUDIENCE } from "./jwt";
|
|
17
17
|
|
|
18
18
|
interface TestableServer {
|
|
19
19
|
getInitialPromptOverride(run: TaskRun): string | null;
|
|
@@ -6,33 +6,33 @@ import {
|
|
|
6
6
|
import { type ServerType, serve } from "@hono/node-server";
|
|
7
7
|
import { Hono } from "hono";
|
|
8
8
|
import packageJson from "../../package.json" with { type: "json" };
|
|
9
|
-
import { POSTHOG_NOTIFICATIONS } from "../acp-extensions
|
|
9
|
+
import { POSTHOG_NOTIFICATIONS } from "../acp-extensions";
|
|
10
10
|
import {
|
|
11
11
|
createAcpConnection,
|
|
12
12
|
type InProcessAcpConnection,
|
|
13
|
-
} from "../adapters/acp-connection
|
|
14
|
-
import { selectRecentTurns } from "../adapters/claude/session/jsonl-hydration
|
|
15
|
-
import { PostHogAPIClient } from "../posthog-api
|
|
13
|
+
} from "../adapters/acp-connection";
|
|
14
|
+
import { selectRecentTurns } from "../adapters/claude/session/jsonl-hydration";
|
|
15
|
+
import { PostHogAPIClient } from "../posthog-api";
|
|
16
16
|
import {
|
|
17
17
|
type ConversationTurn,
|
|
18
18
|
type ResumeState,
|
|
19
19
|
resumeFromLog,
|
|
20
|
-
} from "../resume
|
|
21
|
-
import { SessionLogWriter } from "../session-log-writer
|
|
22
|
-
import { TreeTracker } from "../tree-tracker
|
|
20
|
+
} from "../resume";
|
|
21
|
+
import { SessionLogWriter } from "../session-log-writer";
|
|
22
|
+
import { TreeTracker } from "../tree-tracker";
|
|
23
23
|
import type {
|
|
24
24
|
AgentMode,
|
|
25
25
|
DeviceInfo,
|
|
26
26
|
LogLevel,
|
|
27
27
|
TaskRun,
|
|
28
28
|
TreeSnapshotEvent,
|
|
29
|
-
} from "../types
|
|
30
|
-
import { AsyncMutex } from "../utils/async-mutex
|
|
31
|
-
import { getLlmGatewayUrl } from "../utils/gateway
|
|
32
|
-
import { Logger } from "../utils/logger
|
|
33
|
-
import { type JwtPayload, JwtValidationError, validateJwt } from "./jwt
|
|
34
|
-
import { jsonRpcRequestSchema, validateCommandParams } from "./schemas
|
|
35
|
-
import type { AgentServerConfig } from "./types
|
|
29
|
+
} from "../types";
|
|
30
|
+
import { AsyncMutex } from "../utils/async-mutex";
|
|
31
|
+
import { getLlmGatewayUrl } from "../utils/gateway";
|
|
32
|
+
import { Logger } from "../utils/logger";
|
|
33
|
+
import { type JwtPayload, JwtValidationError, validateJwt } from "./jwt";
|
|
34
|
+
import { jsonRpcRequestSchema, validateCommandParams } from "./schemas";
|
|
35
|
+
import type { AgentServerConfig } from "./types";
|
|
36
36
|
|
|
37
37
|
type MessageCallback = (message: unknown) => void;
|
|
38
38
|
|
package/src/server/bin.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { AgentServer } from "./agent-server
|
|
5
|
-
import { mcpServersSchema } from "./schemas
|
|
4
|
+
import { AgentServer } from "./agent-server";
|
|
5
|
+
import { mcpServersSchema } from "./schemas";
|
|
6
6
|
|
|
7
7
|
const envSchema = z.object({
|
|
8
8
|
JWT_PUBLIC_KEY: z
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type SetupServerApi, setupServer } from "msw/node";
|
|
2
2
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
-
import type { PostHogAPIClient } from "../posthog-api
|
|
4
|
-
import { createTestRepo, type TestRepo } from "../test/fixtures/api
|
|
5
|
-
import { createPostHogHandlers } from "../test/mocks/msw-handlers
|
|
6
|
-
import type { Task, TaskRun } from "../types
|
|
7
|
-
import { AgentServer } from "./agent-server
|
|
3
|
+
import type { PostHogAPIClient } from "../posthog-api";
|
|
4
|
+
import { createTestRepo, type TestRepo } from "../test/fixtures/api";
|
|
5
|
+
import { createPostHogHandlers } from "../test/mocks/msw-handlers";
|
|
6
|
+
import type { Task, TaskRun } from "../types";
|
|
7
|
+
import { AgentServer } from "./agent-server";
|
|
8
8
|
|
|
9
9
|
interface TestableAgentServer {
|
|
10
10
|
posthogAPI: PostHogAPIClient;
|