feat(mcp): emit channel events for process start/stop/kill
Some checks failed
CI / test (push) Failing after 3s
Some checks failed
CI / test (push) Failing after 3s
process.start on successful spawn, process.exit on stop/kill. Events include process ID, PID, command, and signal type. Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
4775f2c2d3
commit
bc3c7184e9
1 changed files with 8 additions and 2 deletions
|
|
@ -194,13 +194,17 @@ func (s *Service) processStart(ctx context.Context, req *mcp.CallToolRequest, in
|
|||
}
|
||||
|
||||
info := proc.Info()
|
||||
return nil, ProcessStartOutput{
|
||||
output := ProcessStartOutput{
|
||||
ID: proc.ID,
|
||||
PID: info.PID,
|
||||
Command: proc.Command,
|
||||
Args: proc.Args,
|
||||
StartedAt: proc.StartedAt,
|
||||
}, nil
|
||||
}
|
||||
s.ChannelSend(ctx, "process.start", map[string]any{
|
||||
"id": output.ID, "pid": output.PID, "command": output.Command,
|
||||
})
|
||||
return nil, output, nil
|
||||
}
|
||||
|
||||
// processStop handles the process_stop tool call.
|
||||
|
|
@ -224,6 +228,7 @@ func (s *Service) processStop(ctx context.Context, req *mcp.CallToolRequest, inp
|
|||
return nil, ProcessStopOutput{}, log.E("processStop", "failed to stop process", err)
|
||||
}
|
||||
|
||||
s.ChannelSend(ctx, "process.exit", map[string]any{"id": input.ID, "signal": "stop"})
|
||||
return nil, ProcessStopOutput{
|
||||
ID: input.ID,
|
||||
Success: true,
|
||||
|
|
@ -244,6 +249,7 @@ func (s *Service) processKill(ctx context.Context, req *mcp.CallToolRequest, inp
|
|||
return nil, ProcessKillOutput{}, log.E("processKill", "failed to kill process", err)
|
||||
}
|
||||
|
||||
s.ChannelSend(ctx, "process.exit", map[string]any{"id": input.ID, "signal": "kill"})
|
||||
return nil, ProcessKillOutput{
|
||||
ID: input.ID,
|
||||
Success: true,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue