feat: mcp server first take
This commit is contained in:
@@ -3,6 +3,7 @@ defmodule BDS.Scripting do
|
||||
Facade for the configured user-script runtime.
|
||||
"""
|
||||
|
||||
alias BDS.Scripting.Capabilities
|
||||
alias BDS.Scripting.Runtime
|
||||
|
||||
@type job_status :: :queued | :running | :completed | :failed | :cancelled
|
||||
@@ -35,6 +36,28 @@ defmodule BDS.Scripting do
|
||||
runtime().execute(source, entrypoint, args, opts)
|
||||
end
|
||||
|
||||
@spec execute_project_script(String.t(), String.t(), String.t(), [term()], [Runtime.execution_option()]) ::
|
||||
{:ok, term()} | {:error, term()}
|
||||
def execute_project_script(project_id, source, entrypoint, args \\ [], opts \\ [])
|
||||
when is_binary(project_id) and is_binary(source) and is_binary(entrypoint) and
|
||||
is_list(args) and is_list(opts) do
|
||||
capabilities = Capabilities.for_project(project_id)
|
||||
execute(source, entrypoint, args, Keyword.put(opts, :capabilities, capabilities))
|
||||
end
|
||||
|
||||
@spec execute_macro(String.t(), String.t(), [term()], keyword()) :: {:ok, String.t()} | {:error, term()}
|
||||
def execute_macro(project_id, source, args, opts \\ [])
|
||||
when is_binary(project_id) and is_binary(source) and is_list(args) and is_list(opts) do
|
||||
config = Application.fetch_env!(:bds, :scripting)
|
||||
timeout = Keyword.get(opts, :timeout, Keyword.fetch!(config, :timeout))
|
||||
|
||||
case execute_project_script(project_id, source, "render", args, Keyword.put(opts, :timeout, timeout)) do
|
||||
{:ok, nil} -> {:ok, ""}
|
||||
{:ok, value} -> {:ok, to_string(value)}
|
||||
{:error, _reason} -> {:ok, ""}
|
||||
end
|
||||
end
|
||||
|
||||
@spec start_job(String.t(), String.t(), [term()], [Runtime.execution_option()]) ::
|
||||
{:ok, job_snapshot()} | {:error, term()}
|
||||
def start_job(source, entrypoint, args \\ [], opts \\ [])
|
||||
|
||||
Reference in New Issue
Block a user