Parcourir la source

refactor(subagent): derive Claude exit projections

pku-xht il y a 2 mois
Parent
commit
a3a9f86d89
1 fichiers modifiés avec 3 ajouts et 8 suppressions
  1. 3 8
      packages/subagent/subagent-claude-code/src/process.ts

+ 3 - 8
packages/subagent/subagent-claude-code/src/process.ts

@@ -82,8 +82,6 @@ export class ManagedClaudeCodeProcess implements SpawnedProcess {
   readonly stdin
   readonly stdout
   private readonly events = new EventEmitter()
-  private exitCodeValue: number | null = null
-  private signalCodeValue: NodeJS.Signals | null = null
   private outcomeValue: SubprocessOutcome | undefined
   private killRequested = false
 
@@ -101,8 +99,6 @@ export class ManagedClaudeCodeProcess implements SpawnedProcess {
     void child.done.then(
       (outcome) => {
         this.outcomeValue = outcome
-        this.exitCodeValue = outcome.exitCode
-        this.signalCodeValue = outcome.signal
         this.events.emit('exit', outcome.exitCode, outcome.signal)
       },
       (error: unknown) => {
@@ -118,12 +114,12 @@ export class ManagedClaudeCodeProcess implements SpawnedProcess {
 
   /** Direct-child exit code, or null while running or after signal exit. */
   get exitCode(): number | null {
-    return this.exitCodeValue
+    return this.outcomeValue?.exitCode ?? null
   }
 
   /** Direct-child terminating signal, if any. */
   get signalCode(): NodeJS.Signals | null {
-    return this.signalCodeValue
+    return this.outcomeValue?.signal ?? null
   }
 
   /** Exact managed-process outcome after exit, or undefined while running. */
@@ -139,8 +135,7 @@ export class ManagedClaudeCodeProcess implements SpawnedProcess {
   kill(_signal: NodeJS.Signals): boolean {
     if (
       this.killRequested
-      || this.exitCodeValue !== null
-      || this.signalCodeValue !== null
+      || this.outcomeValue !== undefined
     ) {
       return false
     }