1- /* oxlint-disable max-lines -- Resource-specific removal helpers split into owner modules in subsequent lifecycle slices. */
21import { createHash } from "node:crypto" ;
32import { stableStringify } from "../agents/stable-stringify.js" ;
43import { getRuntimeConfig } from "../config/config.js" ;
@@ -14,7 +13,6 @@ import {
1413 markClawCronRefRemoved ,
1514 readClawCronRefs ,
1615 type ClawCronGateway ,
17- type PersistedClawCronRef ,
1816} from "./cron.js" ;
1917import {
2018 claimClawAgentConfigRemoval ,
@@ -34,111 +32,41 @@ import {
3432 removeClawWorkspaceFile ,
3533 synthesizeOrphanInstall ,
3634 workspaceContainsUntrackedEntries ,
37- type ClawManagedFileStatus ,
3835 type ClawTrashPath ,
3936 type RemovedWorkspaceFile ,
4037} from "./lifecycle-delete-support.js" ;
38+ import {
39+ CLAW_REMOVE_PLAN_SCHEMA_VERSION ,
40+ CLAW_REMOVE_RESULT_SCHEMA_VERSION ,
41+ CLAW_STATUS_SCHEMA_VERSION ,
42+ type ClawRemovePlan ,
43+ type ClawRemovePlanAction ,
44+ type ClawRemoveResult ,
45+ type ClawStatusRecord ,
46+ type ClawStatusResult ,
47+ type RemovedCronJob ,
48+ } from "./lifecycle-state-contract.js" ;
4149import { projectClawPackageRemovePlan } from "./package-remove-plan.js" ;
4250import {
4351 applyClawPackageRemovals ,
4452 inspectClawPackage ,
4553 planClawPackageRemovals ,
46- type ClawPackageInspection ,
47- type ClawPackageRemovalResult ,
4854 type ClawReferencedCleanup ,
4955 type PackageRemovalDeps ,
5056} from "./package-remove.js" ;
5157import {
5258 readClawInstallRecords ,
5359 readClawPackageRefs ,
5460 updateClawInstallRecordStatus ,
55- type PersistedClawInstall ,
5661} from "./provenance.js" ;
5762import { CLAW_OUTPUT_STABILITY } from "./types.js" ;
5863import { readClawWorkspaceFiles } from "./workspace.js" ;
5964
6065export { ClawRemoveError } from "./lifecycle-delete-support.js" ;
61-
62- const CLAW_STATUS_SCHEMA_VERSION = "openclaw.clawStatus.v1" as const ;
63- export const CLAW_REMOVE_PLAN_SCHEMA_VERSION = "openclaw.clawRemovePlan.v1" as const ;
64- export const CLAW_REMOVE_RESULT_SCHEMA_VERSION = "openclaw.clawRemoveResult.v1" as const ;
65- type ClawStatusRecord = {
66- install : PersistedClawInstall ;
67- orphaned ?: boolean ;
68- agentState : "present" | "modified" | "missing" ;
69- workspaceFiles : ClawManagedFileStatus [ ] ;
70- packages : ClawPackageInspection [ ] ;
71- cronJobs : PersistedClawCronRef [ ] ;
72- } ;
73- type ClawStatusResult = {
74- schemaVersion : typeof CLAW_STATUS_SCHEMA_VERSION ;
75- stability : typeof CLAW_OUTPUT_STABILITY ;
76- target ?: string ;
77- records : ClawStatusRecord [ ] ;
78- summary : {
79- claws : number ;
80- partial : number ;
81- missingAgents : number ;
82- driftedFiles : number ;
83- packageRefs : number ;
84- missingPackages : number ;
85- driftedPackages : number ;
86- incompletePackages : number ;
87- cronRefs : number ;
88- unresolvedCronRefs : number ;
89- } ;
90- } ;
91- type ClawRemovePlanAction = {
92- kind :
93- | "agent"
94- | "configBinding"
95- | "agentAllow"
96- | "workspace"
97- | "agentState"
98- | "sessionIndex"
99- | "sessionTranscripts"
100- | "scheduledJob"
101- | "workspaceFile"
102- | "packageRef"
103- | "cronJob"
104- | "installRecord" ;
105- id : string ;
106- action : "remove" | "delete" | "retain" | "release" | "uninstall" | "trash" ;
107- target : string ;
108- blocked : boolean ;
109- reason ?: string ;
110- details ?: Record < string , unknown > ;
111- } ;
112- type ClawRemovePlan = {
113- schemaVersion : typeof CLAW_REMOVE_PLAN_SCHEMA_VERSION ;
114- stability : typeof CLAW_OUTPUT_STABILITY ;
115- dryRun : true ;
116- mutationAllowed : false ;
117- planIntegrity : string ;
118- target : string ;
119- agentId ?: string ;
120- actions : ClawRemovePlanAction [ ] ;
121- blockers : Array < { code : string ; message : string } > ;
122- } ;
123- type RemovedCronJob = {
124- manifestId : string ;
125- schedulerJobId ?: string ;
126- action : "removed" | "error" ;
127- message ?: string ;
128- } ;
129- type ClawRemoveResult = {
130- schemaVersion : typeof CLAW_REMOVE_RESULT_SCHEMA_VERSION ;
131- stability : typeof CLAW_OUTPUT_STABILITY ;
132- dryRun : false ;
133- status : "complete" | "partial" ;
134- agentId : string ;
135- agentRemoved : boolean ;
136- workspaceFiles : RemovedWorkspaceFile [ ] ;
137- packages : ClawPackageRemovalResult [ ] ;
138- cronJobs : RemovedCronJob [ ] ;
139- packageRefsReleased : number ;
140- error ?: { code : string ; message : string } ;
141- } ;
66+ export {
67+ CLAW_REMOVE_PLAN_SCHEMA_VERSION ,
68+ CLAW_REMOVE_RESULT_SCHEMA_VERSION ,
69+ } from "./lifecycle-state-contract.js" ;
14270
14371export async function readClawStatus (
14472 target ?: string ,
0 commit comments