mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 11:55:47 -06:00
refactor(agents): remove stale Claude CLI compat wrapper
This commit is contained in:
@@ -28,7 +28,6 @@ import {
|
||||
makeBootstrapWarn as realMakeBootstrapWarn,
|
||||
resolveBootstrapContextForRun as realResolveBootstrapContextForRun,
|
||||
} from "./bootstrap-files.js";
|
||||
import { buildRunClaudeCliAgentParams } from "./cli-runner.js";
|
||||
import {
|
||||
createManagedRun,
|
||||
mockSuccessfulCliRun,
|
||||
@@ -719,104 +718,6 @@ describe("runCliAgent spawn path", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("ignores legacy claudeSessionId on the compat wrapper", () => {
|
||||
const params = buildRunClaudeCliAgentParams({
|
||||
sessionId: "openclaw-session",
|
||||
sessionFile: "/tmp/session.jsonl",
|
||||
workspaceDir: "/tmp",
|
||||
prompt: "hi",
|
||||
model: "opus",
|
||||
timeoutMs: 1_000,
|
||||
runId: "run-claude-legacy-wrapper",
|
||||
claudeSessionId: "c9d7b831-1c31-4d22-80b9-1e50ca207d4b",
|
||||
});
|
||||
|
||||
expect(params.provider).toBe("claude-cli");
|
||||
expect(params.prompt).toBe("hi");
|
||||
expect(params).not.toHaveProperty("cliSessionId");
|
||||
expect(JSON.stringify(params)).not.toContain("c9d7b831-1c31-4d22-80b9-1e50ca207d4b");
|
||||
});
|
||||
|
||||
it("forwards channel context through the compat wrapper", () => {
|
||||
const params = buildRunClaudeCliAgentParams({
|
||||
sessionId: "openclaw-session",
|
||||
sessionFile: "/tmp/session.jsonl",
|
||||
workspaceDir: "/tmp",
|
||||
cwd: "/tmp/task-repo",
|
||||
prompt: "hi",
|
||||
timeoutMs: 1_000,
|
||||
runId: "run-claude-channel-wrapper",
|
||||
messageChannel: "telegram",
|
||||
messageProvider: "acp",
|
||||
currentChannelId: "telegram:-100123:topic:42",
|
||||
currentThreadTs: "42",
|
||||
currentMessageId: "reply-message-1",
|
||||
senderId: "sender-1",
|
||||
senderIsOwner: true,
|
||||
persistAssistantTranscript: true,
|
||||
storePath: "/tmp/sessions.json",
|
||||
currentInboundEventKind: "room_event",
|
||||
});
|
||||
|
||||
expect(params.messageChannel).toBe("telegram");
|
||||
expect(params.messageProvider).toBe("acp");
|
||||
expect(params.currentChannelId).toBe("telegram:-100123:topic:42");
|
||||
expect(params.currentThreadTs).toBe("42");
|
||||
expect(params.currentMessageId).toBe("reply-message-1");
|
||||
expect(params.senderId).toBe("sender-1");
|
||||
expect(params.senderIsOwner).toBe(true);
|
||||
expect(params.cwd).toBe("/tmp/task-repo");
|
||||
expect(params.persistAssistantTranscript).toBe(true);
|
||||
expect(params.storePath).toBe("/tmp/sessions.json");
|
||||
expect(params.currentInboundEventKind).toBe("room_event");
|
||||
});
|
||||
|
||||
it("forwards explicit message target policy through the compat wrapper", () => {
|
||||
const params = buildRunClaudeCliAgentParams({
|
||||
sessionId: "openclaw-session",
|
||||
sessionFile: "/tmp/session.jsonl",
|
||||
workspaceDir: "/tmp",
|
||||
prompt: "hi",
|
||||
timeoutMs: 1_000,
|
||||
runId: "run-claude-target-policy-wrapper",
|
||||
requireExplicitMessageTarget: true,
|
||||
});
|
||||
|
||||
expect(params.requireExplicitMessageTarget).toBe(true);
|
||||
});
|
||||
|
||||
it("forwards static extra system prompt through the compat wrapper", () => {
|
||||
const params = buildRunClaudeCliAgentParams({
|
||||
sessionId: "openclaw-session",
|
||||
sessionFile: "/tmp/session.jsonl",
|
||||
workspaceDir: "/tmp",
|
||||
prompt: "hi",
|
||||
timeoutMs: 1_000,
|
||||
runId: "run-claude-static-prompt-wrapper",
|
||||
extraSystemPrompt: "dynamic\n\nstatic",
|
||||
extraSystemPromptStatic: "static",
|
||||
});
|
||||
|
||||
expect(params.extraSystemPrompt).toBe("dynamic\n\nstatic");
|
||||
expect(params.extraSystemPromptStatic).toBe("static");
|
||||
});
|
||||
|
||||
it("forwards cron jobId through the compat wrapper", () => {
|
||||
const params = buildRunClaudeCliAgentParams({
|
||||
sessionId: "openclaw-session",
|
||||
sessionFile: "/tmp/session.jsonl",
|
||||
workspaceDir: "/tmp",
|
||||
prompt: "hi",
|
||||
timeoutMs: 1_000,
|
||||
runId: "run-claude-jobid-wrapper",
|
||||
trigger: "cron",
|
||||
jobId: "cron-job-123",
|
||||
});
|
||||
|
||||
expect(params.trigger).toBe("cron");
|
||||
expect(params.jobId).toBe("cron-job-123");
|
||||
});
|
||||
|
||||
it("runs CLI through supervisor and returns payload", async () => {
|
||||
const logInfoSpy = vi.spyOn(cliBackendLog, "info").mockImplementation(() => undefined);
|
||||
supervisorSpawnMock.mockResolvedValueOnce(
|
||||
|
||||
@@ -1240,54 +1240,3 @@ export async function runPreparedCliAgent(
|
||||
}
|
||||
return runResult;
|
||||
}
|
||||
|
||||
/** Legacy Claude-specific wrapper params for the generic CLI runner. */
|
||||
export type RunClaudeCliAgentParams = Omit<RunCliAgentParams, "provider" | "cliSessionId"> & {
|
||||
provider?: string;
|
||||
claudeSessionId?: string;
|
||||
};
|
||||
|
||||
/** Converts legacy Claude CLI wrapper params into generic CLI runner params. */
|
||||
export function buildRunClaudeCliAgentParams(params: RunClaudeCliAgentParams): RunCliAgentParams {
|
||||
return {
|
||||
sessionId: params.sessionId,
|
||||
sessionKey: params.sessionKey,
|
||||
sessionEntry: params.sessionEntry,
|
||||
agentId: params.agentId,
|
||||
trigger: params.trigger,
|
||||
sessionFile: params.sessionFile,
|
||||
workspaceDir: params.workspaceDir,
|
||||
cwd: params.cwd,
|
||||
config: params.config,
|
||||
prompt: params.prompt,
|
||||
persistAssistantTranscript: params.persistAssistantTranscript,
|
||||
storePath: params.storePath,
|
||||
currentInboundEventKind: params.currentInboundEventKind,
|
||||
provider: params.provider ?? "claude-cli",
|
||||
model: params.model ?? "opus",
|
||||
thinkLevel: params.thinkLevel,
|
||||
timeoutMs: params.timeoutMs,
|
||||
runTimeoutOverrideMs: params.runTimeoutOverrideMs,
|
||||
runId: params.runId,
|
||||
jobId: params.jobId,
|
||||
extraSystemPrompt: params.extraSystemPrompt,
|
||||
inputProvenance: params.inputProvenance,
|
||||
sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
|
||||
requireExplicitMessageTarget: params.requireExplicitMessageTarget,
|
||||
silentReplyPromptMode: params.silentReplyPromptMode,
|
||||
extraSystemPromptStatic: params.extraSystemPromptStatic,
|
||||
ownerNumbers: params.ownerNumbers,
|
||||
// Legacy `claudeSessionId` callers predate the shared CLI session contract.
|
||||
// Ignore it here so the compatibility wrapper does not accidentally resume
|
||||
// an incompatible Claude session on the generic runner path.
|
||||
images: params.images,
|
||||
messageChannel: params.messageChannel,
|
||||
messageProvider: params.messageProvider,
|
||||
currentChannelId: params.currentChannelId,
|
||||
currentThreadTs: params.currentThreadTs,
|
||||
currentMessageId: params.currentMessageId,
|
||||
currentInboundAudio: params.currentInboundAudio,
|
||||
senderId: params.senderId,
|
||||
senderIsOwner: params.senderIsOwner,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user