refactor: trim unused acp exports

This commit is contained in:
Peter Steinberger
2026-05-02 09:48:55 +01:00
parent ae31aa6f84
commit a3628310e4
3 changed files with 13 additions and 24 deletions

View File

@@ -1,10 +1,8 @@
import {
resolveConfiguredBindingRecord,
resolveConfiguredBindingRecordBySessionKey,
resolveConfiguredBindingRecordForConversation,
} from "../channels/plugins/binding-registry.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import type { ConversationRef } from "../infra/outbound/session-binding-service.js";
import {
resolveConfiguredAcpBindingSpecFromRecord,
toResolvedConfiguredAcpBinding,
@@ -23,14 +21,6 @@ export function resolveConfiguredAcpBindingRecord(params: {
return resolved ? toResolvedConfiguredAcpBinding(resolved.record) : null;
}
export function resolveConfiguredAcpBindingRecordForConversation(params: {
cfg: OpenClawConfig;
conversation: ConversationRef;
}): ResolvedConfiguredAcpBinding | null {
const resolved = resolveConfiguredBindingRecordForConversation(params);
return resolved ? toResolvedConfiguredAcpBinding(resolved.record) : null;
}
export function resolveConfiguredAcpBindingSpecBySessionKey(params: {
cfg: OpenClawConfig;
sessionKey: string;

View File

@@ -2,58 +2,57 @@ import { describe, expect, it } from "vitest";
import {
isParentOwnedBackgroundAcpSession,
isRequesterParentOfBackgroundAcpSession,
resolveAcpSessionInteractionMode,
} from "./session-interaction-mode.js";
const parentKey = "agent:main:main";
const otherKey = "agent:peer:some-other";
describe("resolveAcpSessionInteractionMode", () => {
describe("isParentOwnedBackgroundAcpSession", () => {
it("returns interactive when entry is undefined", () => {
expect(resolveAcpSessionInteractionMode(undefined)).toBe("interactive");
expect(isParentOwnedBackgroundAcpSession(undefined)).toBe(false);
});
it("returns parent-owned-background for persistent sessions with spawnedBy set", () => {
expect(
resolveAcpSessionInteractionMode({
isParentOwnedBackgroundAcpSession({
acp: { mode: "persistent" } as never,
spawnedBy: parentKey,
}),
).toBe("parent-owned-background");
).toBe(true);
});
it("returns interactive for persistent ACP sessions without parent linkage", () => {
expect(
resolveAcpSessionInteractionMode({
isParentOwnedBackgroundAcpSession({
acp: { mode: "persistent" } as never,
}),
).toBe("interactive");
).toBe(false);
});
it("returns parent-owned-background for oneshot sessions with spawnedBy set", () => {
expect(
resolveAcpSessionInteractionMode({
isParentOwnedBackgroundAcpSession({
acp: { mode: "oneshot" } as never,
spawnedBy: parentKey,
}),
).toBe("parent-owned-background");
).toBe(true);
});
it("returns parent-owned-background for oneshot sessions with parentSessionKey set", () => {
expect(
resolveAcpSessionInteractionMode({
isParentOwnedBackgroundAcpSession({
acp: { mode: "oneshot" } as never,
parentSessionKey: parentKey,
}),
).toBe("parent-owned-background");
).toBe(true);
});
it("returns interactive for a oneshot session without any parent linkage", () => {
expect(
resolveAcpSessionInteractionMode({
isParentOwnedBackgroundAcpSession({
acp: { mode: "oneshot" } as never,
}),
).toBe("interactive");
).toBe(false);
});
});

View File

@@ -5,7 +5,7 @@ type AcpSessionInteractionMode = "interactive" | "parent-owned-background";
type SessionInteractionEntry = Pick<SessionEntry, "spawnedBy" | "parentSessionKey" | "acp">;
export function resolveAcpSessionInteractionMode(
function resolveAcpSessionInteractionMode(
entry?: SessionInteractionEntry | null,
): AcpSessionInteractionMode {
// Parent-owned ACP sessions are background work delegated from another session.