Class AgentsService

java.lang.Object
app.ductape.sdk.agents.AgentsService

public class AgentsService extends Object
TS parity: sdk/ts/src/agents/agents.service.ts (define/register/dispatch/local registry).

run() mirrors TS's createLLMProvider(resolvedModelConfig): it resolves the agent's configured model (via ModelService.fetch(java.util.Map<java.lang.String, java.lang.Object>)) to read provider/model/ the env-specific (encrypted) apiKey, decrypts the key with the product's private key (same algorithm ModelService uses to encrypt it), and builds a matching AnthropicLlmProvider/OpenAiLlmProvider for the call — exactly like TS's agent-executor.ts#createLLMProvider switch on config.provider. This only applies when the still-default DefaultAgentExecutor (auto-wired by the constructor with an echo/stub provider) is in place; an explicitly registered custom executor always takes priority, matching the existing override seam.

  • Constructor Details

  • Method Details

    • auth

      public RequestContext auth()
    • define

      public Map<String,Object> define(Map<String,Object> options)
      TS define: validates core fields, registers tools, optionally persists via createAgent.
    • register

      public void register(String productTag, Map<String,Object> agent)
      TS register(product, agent): persist agent configuration and refresh local cache.
    • registerLocal

      public void registerLocal(String tag, Map<String,Object> registration)
      Back-compat alias for simple local-only registration.
    • getAgent

      public Map<String,Object> getAgent(String tag)
    • listAgents

      public List<Map<String,Object>> listAgents()
    • deleteAgentLocal

      public void deleteAgentLocal(String tag)
    • clearAll

      public void clearAll()
    • tools

      public ToolRegistry tools(String agentTag)
    • setLocalExecutor

      public void setLocalExecutor(AgentLocalExecutor executor)
      Register an in-process AgentLocalExecutor (TS AgentExecutor parity seam), overriding the auto-wired default (echo-provider) executor. Once called, run(Map) always delegates to this executor as-is and no longer attempts the per-call model-to-LLM-provider resolution described on the class.
    • hasLocalExecutor

      public boolean hasLocalExecutor()
      Whether an AgentLocalExecutor is registered. Useful for callers that want to gate behavior at runtime without try/catching the configuration error from run(Map).
    • run

      public Map<String,Object> run(Map<String,Object> options)
      TS run: routes through the registered AgentLocalExecutor when available; otherwise raises an explicit configuration error guiding callers to dispatch(Map) or to wire a custom executor.
    • status

      public Map<String,Object> status(Map<String,Object> options)
      TS status: looks up an in-flight execution by id. Mirrors TS's own limitation — once run() returns, the execution is removed from the active map (same as TS deleting from activeExecutors right after execute()), so this only finds executions that are genuinely still running concurrently with the status() call.
    • list

      public Map<String,Object> list(Map<String,Object> options)
      TS list: lists currently-active executions, optionally filtered by agent tag and/or status, paginated the same way TS does (1-based page, default limit 10).
    • dispatch

      public Map<String,Object> dispatch(Map<String,Object> options)
      TS dispatch: enqueue processor job type action, event agent:{agent}.
    • createAgent

      public void createAgent(String productId, Map<String,Object> agentPayload)
    • updateAgent

      public void updateAgent(String productId, Map<String,Object> agentPayload)
    • fetchAgent

      public Map<String,Object> fetchAgent(String productId, String tag)
    • fetchAgents

      public List<Map<String,Object>> fetchAgents(String productId)
    • deleteAgent

      public void deleteAgent(String productId, String tag)