@@ -5,17 +5,14 @@ import { sendRpc } from '../../host/rpcClient.js';
55import type { RunResult } from '../../protocol/messages.js' ;
66import { RunResultSchema } from '../../protocol/messages.js' ;
77import { ERROR_CODES , makeCliError } from '../../protocol/errors.js' ;
8- import {
9- isCommandableSessionStatus ,
10- isDestroyedSessionStatus ,
11- } from '../../protocol/sessionStatusPolicy.js' ;
128import { readManifestIfExists } from '../../storage/manifests.js' ;
139import {
1410 manifestPath ,
1511 sessionDir ,
1612 socketPath ,
1713} from '../../storage/sessionPaths.js' ;
1814import { resolveCommandInputText } from './inputSource.js' ;
15+ import { assertSessionCommandable } from '../sessionGuards.js' ;
1916
2017interface CommandOptions {
2118 context : CommandContext ;
@@ -67,25 +64,7 @@ export async function runRunCommand(options: CommandOptions): Promise<void> {
6764 } ) ;
6865 }
6966
70- if ( isDestroyedSessionStatus ( manifest . status ) ) {
71- throw makeCliError ( ERROR_CODES . SESSION_ALREADY_DESTROYED , {
72- message : `Session "${ options . sessionId } " is already destroyed.` ,
73- details : {
74- sessionId : options . sessionId ,
75- status : manifest . status ,
76- } ,
77- } ) ;
78- }
79-
80- if ( ! isCommandableSessionStatus ( manifest . status ) ) {
81- throw makeCliError ( ERROR_CODES . SESSION_NOT_RUNNING , {
82- message : `Session "${ options . sessionId } " is not running.` ,
83- details : {
84- sessionId : options . sessionId ,
85- status : manifest . status ,
86- } ,
87- } ) ;
88- }
67+ assertSessionCommandable ( manifest , options . sessionId ) ;
8968
9069 const noWait = ! options . wait ;
9170 const rpcParams : Record < string , unknown > = {
0 commit comments