@posthog/agent 2.3.11 → 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 +33 -4
- 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 +33 -4
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +33 -4
- 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 +44 -16
- 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 +12 -6
- package/src/adapters/claude/tools.ts +3 -3
- package/src/adapters/claude/types.ts +9 -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,39 +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
|
+
EffortLevel,
|
|
76
77
|
NewSessionMeta,
|
|
77
78
|
Session,
|
|
78
79
|
ToolUseCache,
|
|
79
|
-
} from "./types
|
|
80
|
+
} from "./types";
|
|
80
81
|
|
|
81
82
|
const SESSION_VALIDATION_TIMEOUT_MS = 10_000;
|
|
82
83
|
const MAX_TITLE_LENGTH = 256;
|
|
@@ -558,6 +559,10 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
|
|
|
558
559
|
const sdkModelId = toSdkModelId(params.value);
|
|
559
560
|
await this.session.query.setModel(sdkModelId);
|
|
560
561
|
this.session.modelId = params.value;
|
|
562
|
+
} else if (params.configId === "effort") {
|
|
563
|
+
const newEffort = params.value as EffortLevel;
|
|
564
|
+
this.session.effort = newEffort;
|
|
565
|
+
this.session.queryOptions.effort = newEffort;
|
|
561
566
|
}
|
|
562
567
|
|
|
563
568
|
this.session.configOptions = this.session.configOptions.map((o) =>
|
|
@@ -623,6 +628,7 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
|
|
|
623
628
|
|
|
624
629
|
const meta = params._meta as NewSessionMeta | undefined;
|
|
625
630
|
const taskId = meta?.persistence?.taskId;
|
|
631
|
+
const effort = meta?.claudeCode?.options?.effort as EffortLevel | undefined;
|
|
626
632
|
|
|
627
633
|
// We want to create a new session id unless it is resume,
|
|
628
634
|
// but not resume + forkSession.
|
|
@@ -673,6 +679,7 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
|
|
|
673
679
|
onModeChange: this.createOnModeChange(),
|
|
674
680
|
onProcessSpawned: this.options?.onProcessSpawned,
|
|
675
681
|
onProcessExited: this.options?.onProcessExited,
|
|
682
|
+
effort,
|
|
676
683
|
});
|
|
677
684
|
|
|
678
685
|
// Use the same abort controller that buildSessionOptions gave to the query
|
|
@@ -682,6 +689,7 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
|
|
|
682
689
|
|
|
683
690
|
const session: Session = {
|
|
684
691
|
query: q,
|
|
692
|
+
queryOptions: options,
|
|
685
693
|
input,
|
|
686
694
|
cancelled: false,
|
|
687
695
|
settingsManager,
|
|
@@ -693,6 +701,7 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
|
|
|
693
701
|
cachedReadTokens: 0,
|
|
694
702
|
cachedWriteTokens: 0,
|
|
695
703
|
},
|
|
704
|
+
effort,
|
|
696
705
|
configOptions: [],
|
|
697
706
|
promptRunning: false,
|
|
698
707
|
pendingMessages: new Map(),
|
|
@@ -790,7 +799,11 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
|
|
|
790
799
|
),
|
|
791
800
|
};
|
|
792
801
|
|
|
793
|
-
const configOptions = this.buildConfigOptions(
|
|
802
|
+
const configOptions = this.buildConfigOptions(
|
|
803
|
+
permissionMode,
|
|
804
|
+
modelOptions,
|
|
805
|
+
effort ?? "high",
|
|
806
|
+
);
|
|
794
807
|
session.configOptions = configOptions;
|
|
795
808
|
|
|
796
809
|
if (!creationOpts.skipBackgroundFetches) {
|
|
@@ -844,6 +857,7 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
|
|
|
844
857
|
currentModelId: string;
|
|
845
858
|
options: SessionConfigSelectOption[];
|
|
846
859
|
},
|
|
860
|
+
currentEffort: EffortLevel = "high",
|
|
847
861
|
): SessionConfigOption[] {
|
|
848
862
|
const modeOptions = getAvailableModes().map((mode) => ({
|
|
849
863
|
value: mode.id,
|
|
@@ -871,6 +885,20 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
|
|
|
871
885
|
category: "model" as SessionConfigOptionCategory,
|
|
872
886
|
description: "Choose which model Claude should use",
|
|
873
887
|
},
|
|
888
|
+
{
|
|
889
|
+
id: "effort",
|
|
890
|
+
name: "Effort",
|
|
891
|
+
type: "select",
|
|
892
|
+
currentValue: currentEffort,
|
|
893
|
+
options: [
|
|
894
|
+
{ value: "low", name: "Low" },
|
|
895
|
+
{ value: "medium", name: "Medium" },
|
|
896
|
+
{ value: "high", name: "High" },
|
|
897
|
+
{ value: "max", name: "Max" },
|
|
898
|
+
],
|
|
899
|
+
category: "thought_level" as SessionConfigOptionCategory,
|
|
900
|
+
description: "Controls how much effort Claude puts into its response",
|
|
901
|
+
},
|
|
874
902
|
];
|
|
875
903
|
}
|
|
876
904
|
|
|
@@ -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,16 +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 {
|
|
21
|
-
import
|
|
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";
|
|
22
23
|
|
|
23
24
|
export interface ProcessSpawnedInfo {
|
|
24
25
|
pid: number;
|
|
@@ -43,6 +44,7 @@ export interface BuildOptionsParams {
|
|
|
43
44
|
onModeChange?: OnModeChange;
|
|
44
45
|
onProcessSpawned?: (info: ProcessSpawnedInfo) => void;
|
|
45
46
|
onProcessExited?: (pid: number) => void;
|
|
47
|
+
effort?: EffortLevel;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
const BRANCH_NAMING_INSTRUCTIONS = `
|
|
@@ -295,6 +297,10 @@ export function buildSessionOptions(params: BuildOptionsParams): Options {
|
|
|
295
297
|
options.additionalDirectories = params.additionalDirectories;
|
|
296
298
|
}
|
|
297
299
|
|
|
300
|
+
if (params.effort) {
|
|
301
|
+
options.effort = params.effort;
|
|
302
|
+
}
|
|
303
|
+
|
|
298
304
|
clearStatsigCache();
|
|
299
305
|
return options;
|
|
300
306
|
}
|
|
@@ -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,12 @@ 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
|
+
|
|
16
|
+
export type EffortLevel = "low" | "medium" | "high" | "max";
|
|
15
17
|
|
|
16
18
|
export type AccumulatedUsage = {
|
|
17
19
|
inputTokens: number;
|
|
@@ -38,6 +40,8 @@ export type PendingMessage = {
|
|
|
38
40
|
|
|
39
41
|
export type Session = BaseSession & {
|
|
40
42
|
query: Query;
|
|
43
|
+
/** The Options object passed to query() — mutating it affects subsequent prompts */
|
|
44
|
+
queryOptions: Options;
|
|
41
45
|
input: Pushable<SDKUserMessage>;
|
|
42
46
|
settingsManager: SettingsManager;
|
|
43
47
|
permissionMode: CodeExecutionMode;
|
|
@@ -46,6 +50,7 @@ export type Session = BaseSession & {
|
|
|
46
50
|
taskRunId?: string;
|
|
47
51
|
lastPlanFilePath?: string;
|
|
48
52
|
lastPlanContent?: string;
|
|
53
|
+
effort?: EffortLevel;
|
|
49
54
|
configOptions: SessionConfigOption[];
|
|
50
55
|
accumulatedUsage: AccumulatedUsage;
|
|
51
56
|
promptRunning: boolean;
|
|
@@ -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
|
|