mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-04 22:29:40 +00:00
Improved dev experience & allow native .NET debugging (#460)
This commit is contained in:
1 parent
c0cf620fe3
commit
4ca1fd54d9
7 files changed
+139
-42
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Tauri Dev" type="ShConfigurationType">
|
||||
<configuration default="false" name="[1] Start Tauri" type="ShConfigurationType">
|
||||
<option name="SCRIPT_TEXT" value="cargo tauri dev --no-watch" />
|
||||
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
|
||||
<option name="SCRIPT_PATH" value="" />
|
||||
@@ -0,0 +1,27 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="[2] Start .NET Server" type="DotNetProject" factoryName=".NET Project">
|
||||
<option name="EXE_PATH" value="$PROJECT_DIR$/MindWork AI Studio/bin/Debug/net9.0/osx-arm64/mindworkAIStudio" />
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/MindWork AI Studio" />
|
||||
<option name="PASS_PARENT_ENVS" value="1" />
|
||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||
<option name="ENV_FILE_PATHS" value="" />
|
||||
<option name="REDIRECT_INPUT_PATH" value="" />
|
||||
<option name="PTY_MODE" value="Auto" />
|
||||
<option name="USE_MONO" value="0" />
|
||||
<option name="RUNTIME_ARGUMENTS" value="" />
|
||||
<option name="AUTO_ATTACH_CHILDREN" value="0" />
|
||||
<option name="MIXED_MODE_DEBUG" value="0" />
|
||||
<option name="RUNTIME_TYPE" value="coreclr" />
|
||||
<option name="PROJECT_PATH" value="$PROJECT_DIR$/MindWork AI Studio/MindWork AI Studio.csproj" />
|
||||
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
||||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||
<option name="PROJECT_TFM" value="net9.0" />
|
||||
<method v="2">
|
||||
<option name="Build" />
|
||||
<option name="RunConfigurationTask" enabled="true" run_configuration_name="Collect I18N content" run_configuration_type="ShConfigurationType" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -25,14 +25,14 @@ internal sealed class Program
|
||||
public static IServiceProvider SERVICE_PROVIDER = null!;
|
||||
public static ILoggerFactory LOGGER_FACTORY = null!;
|
||||
|
||||
public static async Task Main(string[] args)
|
||||
public static async Task Main()
|
||||
{
|
||||
if(args.Length == 0)
|
||||
{
|
||||
Console.WriteLine("Error: Please provide the port of the runtime API.");
|
||||
return;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
// Read the environment variables from the .env file:
|
||||
var envFilePath = Path.Combine("..", "..", "startup.env");
|
||||
await EnvFile.Apply(envFilePath);
|
||||
#endif
|
||||
|
||||
// Read the secret key for the IPC from the AI_STUDIO_SECRET_KEY environment variable:
|
||||
var secretPasswordEncoded = Environment.GetEnvironmentVariable("AI_STUDIO_SECRET_PASSWORD");
|
||||
if(string.IsNullOrWhiteSpace(secretPasswordEncoded))
|
||||
@@ -58,6 +58,13 @@ internal sealed class Program
|
||||
return;
|
||||
}
|
||||
|
||||
var rustApiPort = Environment.GetEnvironmentVariable("AI_STUDIO_API_PORT");
|
||||
if(string.IsNullOrWhiteSpace(rustApiPort))
|
||||
{
|
||||
Console.WriteLine("Error: The AI_STUDIO_API_PORT environment variable is not set.");
|
||||
return;
|
||||
}
|
||||
|
||||
var apiToken = Environment.GetEnvironmentVariable("AI_STUDIO_API_TOKEN");
|
||||
if(string.IsNullOrWhiteSpace(apiToken))
|
||||
{
|
||||
@@ -67,7 +74,6 @@ internal sealed class Program
|
||||
|
||||
API_TOKEN = apiToken;
|
||||
|
||||
var rustApiPort = args[0];
|
||||
using var rust = new RustService(rustApiPort, certificateFingerprint);
|
||||
var appPort = await rust.GetAppPort();
|
||||
if(appPort == 0)
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#if DEBUG
|
||||
using System.Text;
|
||||
|
||||
namespace AIStudio.Tools;
|
||||
|
||||
/// <summary>
|
||||
/// Read environment variables for the application from an .env file.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// We consider this feature a security issue. Therefore, it is only
|
||||
/// available in DEBUG mode. To ensure this, we remove the code
|
||||
/// from any release build.
|
||||
/// </remarks>
|
||||
public static class EnvFile
|
||||
{
|
||||
public static async Task Apply(string filePath)
|
||||
{
|
||||
if(!File.Exists(filePath))
|
||||
{
|
||||
Console.WriteLine($"Error: The .env file '{filePath}' does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
var lines = await File.ReadAllLinesAsync(filePath, Encoding.UTF8);
|
||||
foreach (var line in lines)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line) || line.Trim().StartsWith('#'))
|
||||
continue;
|
||||
|
||||
var parts = line.Split(['='], 2);
|
||||
if (parts.Length != 2)
|
||||
continue;
|
||||
|
||||
var key = parts[0].Trim();
|
||||
var value = parts[1].Trim();
|
||||
|
||||
Environment.SetEnvironmentVariable(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user