77from typing import Any , Literal , TypedDict
88
99import models
10- from python .helpers import runtime , whisper , defer
10+ from python .helpers import runtime , whisper , defer , git
1111from . import files , dotenv
1212from python .helpers .print_style import PrintStyle
1313
1414
1515class Settings (TypedDict ):
16+ version : str
17+
1618 chat_model_provider : str
1719 chat_model_name : str
1820 chat_model_kwargs : dict [str , str ]
@@ -502,8 +504,8 @@ def convert_out(settings: Settings) -> SettingsOutput:
502504 agent_fields .append (
503505 {
504506 "id" : "agent_prompts_subdir" ,
505- "title" : "Prompts Subdirectory" ,
506- "description" : "Subdirectory of /prompts folder to use for agent prompts. Used to adjust agent behaviour." ,
507+ "title" : "A0 Prompts Subdirectory" ,
508+ "description" : "Subdirectory of /prompts folder to be used by default agent no. 0. Subordinate agents can be spawned with other subdirectories, that is on their superior agent to decide. This setting affects the behaviour of the top level agent you communicate with ." ,
507509 "type" : "select" ,
508510 "value" : settings ["agent_prompts_subdir" ],
509511 "options" : [
@@ -879,6 +881,11 @@ def normalize_settings(settings: Settings) -> Settings:
879881 copy = settings .copy ()
880882 default = get_default_settings ()
881883
884+ # adjust settings values to match current version if needed
885+ if "version" not in copy or copy ["version" ] != default ["version" ]:
886+ _adjust_to_version (copy , default )
887+ copy ["version" ] = default ["version" ] # sync version
888+
882889 # remove keys that are not in default
883890 keys_to_remove = [key for key in copy if key not in default ]
884891 for key in keys_to_remove :
@@ -900,6 +907,13 @@ def normalize_settings(settings: Settings) -> Settings:
900907 return copy
901908
902909
910+ def _adjust_to_version (settings : Settings , default : Settings ):
911+ # starting with 0.9, the default prompt subfolder for agent no. 0 is agent0
912+ # switch to agent0 if the old default is used from v0.8
913+ if "version" not in settings or settings ["version" ].startswith ("v0.8" ):
914+ if "agent_prompts_subdir" not in settings or settings ["agent_prompts_subdir" ] == "default" :
915+ settings ["agent_prompts_subdir" ] = "agent0"
916+
903917def _read_settings_file () -> Settings | None :
904918 if os .path .exists (SETTINGS_FILE ):
905919 content = files .read_file (SETTINGS_FILE )
@@ -945,6 +959,7 @@ def get_default_settings() -> Settings:
945959 from models import ModelProvider
946960
947961 return Settings (
962+ version = _get_version (),
948963 chat_model_provider = ModelProvider .OPENAI .name ,
949964 chat_model_name = "gpt-4.1" ,
950965 chat_model_kwargs = {"temperature" : "0" },
@@ -1076,14 +1091,14 @@ async def update_mcp_settings(mcp_servers: str):
10761091 ) # TODO overkill, replace with background task
10771092
10781093 # update token in mcp server
1079- current_token = create_auth_token () #TODO - ugly, token in settings is generated from dotenv and does not always correspond
1080- if (
1081- not previous
1082- or current_token != previous ["mcp_server_token" ]
1083- ):
1094+ current_token = (
1095+ create_auth_token ()
1096+ ) # TODO - ugly, token in settings is generated from dotenv and does not always correspond
1097+ if not previous or current_token != previous ["mcp_server_token" ]:
10841098
10851099 async def update_mcp_token (token : str ):
10861100 from python .helpers .mcp_server import DynamicMcpProxy
1101+
10871102 DynamicMcpProxy .get_instance ().reconfigure (token = token )
10881103
10891104 task3 = defer .DeferredTask ().start_task (
@@ -1161,3 +1176,11 @@ def create_auth_token() -> str:
11611176 # encode as base64 and remove any non-alphanumeric chars (like +, /, =)
11621177 b64_token = base64 .urlsafe_b64encode (hash_bytes ).decode ().replace ("=" , "" )
11631178 return b64_token [:16 ]
1179+
1180+
1181+ def _get_version ():
1182+ try :
1183+ git_info = git .get_git_info ()
1184+ return str (git_info .get ("short_tag" , "" )).strip () or "unknown"
1185+ except Exception :
1186+ return "unknown"
0 commit comments