|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | +// See the LICENSE file in the project root for more information. |
| 4 | + |
| 5 | +using DevProxy.Abstractions.Proxy; |
| 6 | + |
| 7 | +namespace DevProxy.Abstractions.Plugins; |
| 8 | + |
| 9 | +/// <summary> |
| 10 | +/// Interface for plugins that can intercept stdio messages. |
| 11 | +/// Plugins that implement both IPlugin and IStdioPlugin can participate |
| 12 | +/// in both HTTP proxy and stdio proxy scenarios. |
| 13 | +/// </summary> |
| 14 | +public interface IStdioPlugin |
| 15 | +{ |
| 16 | + /// <summary> |
| 17 | + /// Gets the name of the plugin. |
| 18 | + /// </summary> |
| 19 | + string Name { get; } |
| 20 | + |
| 21 | + /// <summary> |
| 22 | + /// Gets whether the plugin is enabled. |
| 23 | + /// </summary> |
| 24 | + bool Enabled { get; } |
| 25 | + |
| 26 | + /// <summary> |
| 27 | + /// Called before stdin message is forwarded to the child process. |
| 28 | + /// Plugins can inspect, modify, or consume the message. |
| 29 | + /// Set ResponseState.HasBeenSet to true to prevent the message from being forwarded. |
| 30 | + /// </summary> |
| 31 | + /// <param name="e">The event arguments containing the stdin message.</param> |
| 32 | + /// <param name="cancellationToken">Cancellation token.</param> |
| 33 | + Task BeforeStdinAsync(StdioRequestArgs e, CancellationToken cancellationToken); |
| 34 | + |
| 35 | + /// <summary> |
| 36 | + /// Called after stdout message is received from the child process. |
| 37 | + /// Plugins can inspect, modify, or consume the message. |
| 38 | + /// Set ResponseState.HasBeenSet to true to prevent the message from being forwarded. |
| 39 | + /// </summary> |
| 40 | + /// <param name="e">The event arguments containing the stdout message.</param> |
| 41 | + /// <param name="cancellationToken">Cancellation token.</param> |
| 42 | + Task AfterStdoutAsync(StdioResponseArgs e, CancellationToken cancellationToken); |
| 43 | + |
| 44 | + /// <summary> |
| 45 | + /// Called after stderr message is received from the child process. |
| 46 | + /// Plugins can inspect, modify, or consume the message. |
| 47 | + /// Set ResponseState.HasBeenSet to true to prevent the message from being forwarded. |
| 48 | + /// </summary> |
| 49 | + /// <param name="e">The event arguments containing the stderr message.</param> |
| 50 | + /// <param name="cancellationToken">Cancellation token.</param> |
| 51 | + Task AfterStderrAsync(StdioResponseArgs e, CancellationToken cancellationToken); |
| 52 | + |
| 53 | + /// <summary> |
| 54 | + /// Called after a stdin/stdout pair has been logged. |
| 55 | + /// Useful for recording and reporting plugins. |
| 56 | + /// </summary> |
| 57 | + /// <param name="e">The event arguments containing the request log.</param> |
| 58 | + /// <param name="cancellationToken">Cancellation token.</param> |
| 59 | + Task AfterStdioRequestLogAsync(StdioRequestLogArgs e, CancellationToken cancellationToken); |
| 60 | + |
| 61 | + /// <summary> |
| 62 | + /// Called after recording has stopped. |
| 63 | + /// Useful for reporting plugins that need to process all recorded messages. |
| 64 | + /// </summary> |
| 65 | + /// <param name="e">The event arguments containing all recorded logs.</param> |
| 66 | + /// <param name="cancellationToken">Cancellation token.</param> |
| 67 | + Task AfterStdioRecordingStopAsync(StdioRecordingArgs e, CancellationToken cancellationToken); |
| 68 | +} |
0 commit comments