# MITMProxy
Currently the proxy is powered by [LLM Interceptor](https://github.com/chouzz/llm-interceptor) - this works but is not quiet fit for the goals of the project. This specificaiton defines the moving toward using https://www.mitmproxy.org/ instead of using the LLM interceptor. 

## Key features
- enable whitelist / blacklist of domains and methods. I.e. dont allow POST requests to api.github.com but allow GET. Allow all requests to pypip.com etc. This whitelist is defined in .spens.config.json otherwise its assumed all domains are whitelist. 
- capture llm logs similar to LLM Interceptor (jsonl of all trace capture domains including header)
- enable injecting secrets into the authorization header , mapped from env variables. Injected variables should be defined in the spens.config
- enable capturing a log of all requests - not capturing the body, but creating a list of all post/get etc made during the session. (in addition to the LLM logs for specific llm completion endpoints)

## how it works 
mitmproxy  should be used as the primary ssl interceptor. Just like LLM Interceptor, mitmproxy  should generate SSL certificates before the agent image starts up, and those certs should be loaded as RO in the agent. All traffic from the agent image should flow through the mitmproxy sidecar.

In order to support the advanced features needed by spens, the a plugin should be developed for mitmproxy that does the following 

1. captures completion requests and logs them (just like LLM interceptor ) - this should work like LLM interceptor, have a set list of domains, and then the abiltiy to add additional domains for capture. 
2. create a list of all requests
3. injects header data.
