refactor(acpx): privatize internal helpers (#106394)

This commit is contained in:
Vincent Koc
2026-07-13 21:01:52 +08:00
committed by GitHub
parent df3fe6a4f2
commit 194ed5d34c
5 changed files with 10 additions and 8 deletions
+2 -1
View File
@@ -13,11 +13,12 @@ import {
OPENCLAW_ACPX_LEASE_ID_ARG,
OPENCLAW_ACPX_LEASE_ID_ENV,
OPENCLAW_GATEWAY_INSTANCE_ID_ARG,
OPENCLAW_GATEWAY_INSTANCE_ID_ENV,
withAcpxLeaseEnvironment,
type AcpxProcessLease,
} from "./process-lease.js";
const OPENCLAW_GATEWAY_INSTANCE_ID_ENV = "OPENCLAW_GATEWAY_INSTANCE_ID";
function makeLease(index: number): AcpxProcessLease {
return {
leaseId: `lease-${index}`,
+1 -1
View File
@@ -12,7 +12,7 @@ import { ACPX_PROCESS_LEASE_MAX_ENTRIES, ACPX_PROCESS_LEASE_NAMESPACE } from "./
/** Environment variable carrying the ACPX process lease id. */
export const OPENCLAW_ACPX_LEASE_ID_ENV = "OPENCLAW_ACPX_LEASE_ID";
/** Environment variable carrying the owning gateway instance id. */
export const OPENCLAW_GATEWAY_INSTANCE_ID_ENV = "OPENCLAW_GATEWAY_INSTANCE_ID";
const OPENCLAW_GATEWAY_INSTANCE_ID_ENV = "OPENCLAW_GATEWAY_INSTANCE_ID";
/** CLI argument carrying the ACPX process lease id for platforms without env wrapping. */
export const OPENCLAW_ACPX_LEASE_ID_ARG = "--openclaw-acpx-lease-id";
/** CLI argument carrying the owning gateway instance id. */
+6 -3
View File
@@ -1,7 +1,7 @@
// ACPX tests cover legacy runTurn adaptation into the terminal result contract.
import { describe, expect, it, vi } from "vitest";
import type { AcpRuntime, AcpRuntimeEvent, AcpRuntimeTurnInput } from "../runtime-api.js";
import { startRuntimeTurn } from "./runtime-turn.js";
import { lazyStartRuntimeTurn } from "./runtime-turn.js";
function createLegacyRuntime(events: AcpRuntimeEvent[]): AcpRuntime {
return {
@@ -25,11 +25,14 @@ const turnInput: AcpRuntimeTurnInput = {
requestId: "request-1",
};
describe("startRuntimeTurn", () => {
describe("lazyStartRuntimeTurn", () => {
it.each(["cancel", "cancelled", "manual-cancel"])(
"preserves %s cancellation from a legacy done event",
async (stopReason) => {
const turn = startRuntimeTurn(createLegacyRuntime([{ type: "done", stopReason }]), turnInput);
const turn = lazyStartRuntimeTurn(
async () => createLegacyRuntime([{ type: "done", stopReason }]),
turnInput,
);
expect(await turn.result).toEqual({ status: "cancelled", stopReason });
const events: AcpRuntimeEvent[] = [];
+1 -1
View File
@@ -157,7 +157,7 @@ function legacyRunTurnAsStartTurn(runtime: AcpRuntime, input: AcpRuntimeTurnInpu
}
/** Start an ACP turn, adapting legacy runTurn-only runtimes when needed. */
export function startRuntimeTurn(runtime: AcpRuntime, input: AcpRuntimeTurnInput): AcpRuntimeTurn {
function startRuntimeTurn(runtime: AcpRuntime, input: AcpRuntimeTurnInput): AcpRuntimeTurn {
return runtime.startTurn?.(input) ?? legacyRunTurnAsStartTurn(runtime, input);
}
-2
View File
@@ -2,10 +2,8 @@
// New entries fail CI. After deleting dead code, run `pnpm deadcode:exports:update`.
// Do not add entries to avoid fixing new findings.
export const KNIP_UNUSED_EXPORT_BASELINE = [
"extensions/acpx/src/process-lease.ts: OPENCLAW_GATEWAY_INSTANCE_ID_ENV",
"extensions/acpx/src/process-reaper.ts: AcpxProcessInfo",
"extensions/acpx/src/process-reaper.ts: isOpenClawOwnedAcpxProcessCommand",
"extensions/acpx/src/runtime-turn.ts: startRuntimeTurn",
"extensions/canvas/src/host/a2ui.ts: createA2uiHttpRequestHandler",
"extensions/canvas/src/host/a2ui.ts: injectCanvasRuntime",
"extensions/canvas/src/host/a2ui.ts: isA2uiPath",