@@ -7,13 +7,34 @@ import type {
77 OpenKeyedStoreOptions ,
88 PluginStateKeyedStore ,
99} from "openclaw/plugin-sdk/plugin-state-runtime" ;
10+ import { splitCommandParts } from "./command-line.js" ;
1011import { ACPX_PROCESS_LEASE_MAX_ENTRIES , ACPX_PROCESS_LEASE_NAMESPACE } from "./state.js" ;
1112
1213/** CLI argument carrying the ACPX process lease id. */
1314export const OPENCLAW_ACPX_LEASE_ID_ARG = "--openclaw-acpx-lease-id" ;
1415/** CLI argument carrying the owning gateway instance id. */
1516export const OPENCLAW_GATEWAY_INSTANCE_ID_ARG = "--openclaw-gateway-instance-id" ;
1617
18+ export type AcpxProcessLeaseIdentity = {
19+ leaseId : string ;
20+ gatewayInstanceId : string ;
21+ } ;
22+
23+ /** Read OpenClaw lease identity from a generated wrapper command. */
24+ export function readAcpxProcessLeaseIdentity (
25+ command : string | undefined ,
26+ ) : AcpxProcessLeaseIdentity | undefined {
27+ const parts = splitCommandParts ( command ?. trim ( ) ?? "" ) ;
28+ const leaseIndex = parts . lastIndexOf ( OPENCLAW_ACPX_LEASE_ID_ARG ) ;
29+ const gatewayIndex = parts . lastIndexOf ( OPENCLAW_GATEWAY_INSTANCE_ID_ARG ) ;
30+ const leaseId = leaseIndex >= 0 ? parts [ leaseIndex + 1 ] ?. trim ( ) : "" ;
31+ const gatewayInstanceId = gatewayIndex >= 0 ? parts [ gatewayIndex + 1 ] ?. trim ( ) : "" ;
32+ if ( ! leaseId || ! gatewayInstanceId ) {
33+ return undefined ;
34+ }
35+ return { leaseId, gatewayInstanceId } ;
36+ }
37+
1738/** Lifecycle state for a tracked ACPX wrapper process. */
1839type AcpxProcessLeaseState = "open" | "closing" | "closed" | "lost" ;
1940
0 commit comments