@@ -5221,55 +5221,6 @@ export function createAdeRpcRequestHandler(args: {
52215221 } ,
52225222 } ;
52235223
5224- const auditActionCall = async (
5225- actionName : string ,
5226- actionArgs : Record < string , unknown > ,
5227- runner : ( ) => Promise < unknown >
5228- ) : Promise < unknown > => {
5229- const startedAt = Date . now ( ) ;
5230- const laneId = resolveRequestedOrSessionLaneId ( runtime , session , actionArgs ) ;
5231- const operation = runtime . operationService . start ( {
5232- laneId,
5233- kind : "ade_action_call" ,
5234- metadata : {
5235- action : actionName ,
5236- callerId : session . identity . callerId ,
5237- role : session . identity . role ,
5238- chatSessionId : session . identity . chatSessionId ,
5239- runId : session . identity . runId ,
5240- stepId : session . identity . stepId ,
5241- attemptId : session . identity . attemptId ,
5242- ownerId : session . identity . ownerId ,
5243- args : sanitizeForAudit ( actionArgs )
5244- }
5245- } ) ;
5246-
5247- try {
5248- const result = await runner ( ) ;
5249- runtime . operationService . finish ( {
5250- operationId : operation . operationId ,
5251- status : "succeeded" ,
5252- metadataPatch : {
5253- resultStatus : "success" ,
5254- durationMs : Date . now ( ) - startedAt ,
5255- result : sanitizeForAudit ( result )
5256- }
5257- } ) ;
5258- return result ;
5259- } catch ( error ) {
5260- runtime . operationService . finish ( {
5261- operationId : operation . operationId ,
5262- status : "failed" ,
5263- metadataPatch : {
5264- resultStatus : "failed" ,
5265- durationMs : Date . now ( ) - startedAt ,
5266- errorMessage : error instanceof Error ? error . message : String ( error )
5267- }
5268- } ) ;
5269- throw error ;
5270- }
5271- } ;
5272-
52735224 const listActions = async ( ) : Promise < Record < string , unknown > > => {
52745225 const actionSpecs = await listToolSpecsForSession ( runtime , session ) ;
52755226 return {
@@ -5282,18 +5233,16 @@ export function createAdeRpcRequestHandler(args: {
52825233 } ;
52835234
52845235 const callAction = async ( actionName : string , actionArgs : Record < string , unknown > ) : Promise < unknown > => {
5285- return await auditActionCall ( actionName , actionArgs , async ( ) => {
5286- if (
5287- READ_ONLY_TOOLS . has ( actionName ) ||
5288- MUTATION_TOOLS . has ( actionName ) ||
5289- actionName === "spawn_agent" ||
5290- actionName === "ask_user"
5291- ) {
5292- return await runTool ( { runtime, session, name : actionName , toolArgs : actionArgs } ) ;
5293- }
5236+ if (
5237+ READ_ONLY_TOOLS . has ( actionName ) ||
5238+ MUTATION_TOOLS . has ( actionName ) ||
5239+ actionName === "spawn_agent" ||
5240+ actionName === "ask_user"
5241+ ) {
5242+ return await runTool ( { runtime, session, name : actionName , toolArgs : actionArgs } ) ;
5243+ }
52945244
5295- throw new JsonRpcError ( JsonRpcErrorCode . methodNotFound , `Unsupported ADE action: ${ actionName } ` ) ;
5296- } ) ;
5245+ throw new JsonRpcError ( JsonRpcErrorCode . methodNotFound , `Unsupported ADE action: ${ actionName } ` ) ;
52975246 } ;
52985247
52995248 const handler = ( async ( request : JsonRpcRequest ) : Promise < unknown | null > => {
@@ -5424,48 +5373,35 @@ export function createAdeRpcRequestHandler(args: {
54245373 if ( isCtoOnlyAdeAction ( "pty" , ptyAction ) && ! callerHasRoleAtLeast ( session . identity . role , "cto" ) ) {
54255374 throw new JsonRpcError ( JsonRpcErrorCode . methodNotFound , `Unsupported PTY method: ${ method } ` ) ;
54265375 }
5427- const runPtyAction = async ( runner : ( ) => Promise < unknown > | unknown ) : Promise < unknown > =>
5428- auditActionCall ( method , ptyArgs , async ( ) => runner ( ) ) ;
54295376 if ( method === "pty.create" ) {
54305377 ensurePtyCreateAuthorized ( runtime , session , method , ptyArgs ) ;
5431- return await runPtyAction ( async ( ) => {
5432- const result = await runtime . ptyService . create ( ptyArgs as Parameters < typeof runtime . ptyService . create > [ 0 ] ) ;
5433- return {
5434- ...result ,
5435- session : runtime . sessionService . get ( result . sessionId ) ,
5436- } ;
5437- } ) ;
5378+ const result = await runtime . ptyService . create ( ptyArgs as Parameters < typeof runtime . ptyService . create > [ 0 ] ) ;
5379+ return {
5380+ ...result ,
5381+ session : runtime . sessionService . get ( result . sessionId ) ,
5382+ } ;
54385383 }
54395384 if ( method === "pty.sendToSession" ) {
54405385 ensurePtyTargetAuthorized ( runtime , session , method , ptyArgs ) ;
5441- return await runPtyAction ( ( ) =>
5442- runtime . ptyService . sendToSession ( ptyArgs as Parameters < typeof runtime . ptyService . sendToSession > [ 0 ] ) ) ;
5386+ return await runtime . ptyService . sendToSession ( ptyArgs as Parameters < typeof runtime . ptyService . sendToSession > [ 0 ] ) ;
54435387 }
54445388 if ( method === "pty.write" ) {
54455389 ensurePtyTargetAuthorized ( runtime , session , method , ptyArgs ) ;
5446- return await runPtyAction ( ( ) => {
5447- runtime . ptyService . write ( ptyArgs as Parameters < typeof runtime . ptyService . write > [ 0 ] ) ;
5448- return null ;
5449- } ) ;
5390+ runtime . ptyService . write ( ptyArgs as Parameters < typeof runtime . ptyService . write > [ 0 ] ) ;
5391+ return null ;
54505392 }
54515393 if ( method === "pty.resize" ) {
54525394 ensurePtyTargetAuthorized ( runtime , session , method , ptyArgs ) ;
5453- return await runPtyAction ( ( ) => {
5454- runtime . ptyService . resize ( ptyArgs as Parameters < typeof runtime . ptyService . resize > [ 0 ] ) ;
5455- return null ;
5456- } ) ;
5395+ runtime . ptyService . resize ( ptyArgs as Parameters < typeof runtime . ptyService . resize > [ 0 ] ) ;
5396+ return null ;
54575397 }
54585398 if ( method === "pty.dispose" ) {
54595399 ensurePtyTargetAuthorized ( runtime , session , method , ptyArgs ) ;
5460- return await runPtyAction ( ( ) => {
5461- runtime . ptyService . dispose ( ptyArgs as Parameters < typeof runtime . ptyService . dispose > [ 0 ] ) ;
5462- return null ;
5463- } ) ;
5400+ runtime . ptyService . dispose ( ptyArgs as Parameters < typeof runtime . ptyService . dispose > [ 0 ] ) ;
5401+ return null ;
54645402 }
54655403 if ( method === "pty.list" ) {
5466- return await runPtyAction ( ( ) => ( {
5467- sessions : listAuthorizedPtySessions ( runtime , session , method , ptyArgs ) ,
5468- } ) ) ;
5404+ return { sessions : listAuthorizedPtySessions ( runtime , session , method , ptyArgs ) } ;
54695405 }
54705406 throw new JsonRpcError ( JsonRpcErrorCode . methodNotFound , `Unsupported PTY method: ${ method } ` ) ;
54715407 }
0 commit comments