Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions helpers/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@


type ToggleState = Literal["enabled", "disabled", "advanced"]
CallerContext = Literal["ui", "agent", "api"]


class PluginAssetFile(TypedDict):
Expand Down Expand Up @@ -585,8 +586,9 @@ def get_plugin_config(
agent: Agent | None = None,
project_name: str | None = None,
agent_profile: str | None = None,
caller: CallerContext = "api",
):

"""Load plugin config. caller: who is requesting — 'ui' for browser display, 'agent' for agent runtime, 'api' for REST/service callers."""
default_used = False

if project_name is None and agent is not None:
Expand Down Expand Up @@ -629,6 +631,7 @@ def get_plugin_config(
agent=agent,
project_name=project_name,
agent_profile=agent_profile,
hook_context={"caller": caller},
)

return result
Expand All @@ -655,8 +658,10 @@ def get_default_plugin_config(plugin_name: str):

@extension.extensible
def save_plugin_config(
plugin_name: str, project_name: str, agent_profile: str, settings: dict
plugin_name: str, project_name: str, agent_profile: str, settings: dict,
caller: CallerContext = "api",
):
"""Persist plugin config. caller: who is requesting — 'ui' for browser display, 'agent' for agent runtime, 'api' for REST/service callers."""
file_path = determine_plugin_asset_path(
plugin_name, project_name, agent_profile, CONFIG_FILE_NAME
)
Expand All @@ -669,8 +674,8 @@ def save_plugin_config(
project_name=project_name,
agent_profile=agent_profile,
settings=settings,
hook_context={"caller": caller},
)

# or do standard load
if new_settings is not None and file_path:
files.write_file(file_path, json.dumps(new_settings))
Expand Down