Interface FrameworkAdapter

All Known Implementing Classes:
AgentScopeAdapter

public interface FrameworkAdapter
One adapter per agent framework, presenting a uniform view of that framework's sessions to SessionBridge. The Java counterpart of the Python SDK's FrameworkAdapter.

Bypass principle: interception copies data, it never replaces or blocks the framework's own path, and a failed report is swallowed rather than propagated. An instrumented agent must behave exactly as an uninstrumented one.

Optional operations default to failing with UnsupportedOperationException. Declare only what you actually implement in capabilities() — the control plane gates its UI on that list, so over-declaring produces buttons that fail.

  • Field Details

  • Method Details

    • frameworkName

      String frameworkName()
      Framework identifier reported on every snapshot, e.g. agentscope-java.
    • frameworkVersion

      default String frameworkVersion()
      Framework version, or an empty string when it cannot be determined.
    • canHandle

      boolean canHandle(Object target)
      Whether this adapter can instrument target. Must be side-effect free.
    • attach

      void attach(Object target, Consumer<SessionEvent> emit)
      Attaches to the framework object. Session activity is published through emit, which must never be allowed to break the framework's main path.
    • detach

      void detach()
      Removes the interception and restores the framework object.
    • onBridgeAttached

      default void onBridgeAttached(SessionBridge bridge)
      Called once the adapter is mounted, giving it a handle for metadata the event stream cannot carry — system prompt, tool list, context window — via SessionBridge.describeSession(java.lang.String, java.lang.String, java.util.List<io.agentscope.extensions.aistio.model.ContextSnapshot.ToolInfo>, int).
    • extractContext

      reactor.core.publisher.Mono<ContextSnapshot> extractContext(String sessionId)
      Level 4: the context that the session's next model call will actually see.
    • listMessages

      default reactor.core.publisher.Mono<MessagePage> listMessages(String sessionId, int offset, int limit)
      Level 3: full history including messages already compacted away.
    • listSubagents

      default reactor.core.publisher.Mono<List<Inventory.SubagentInfo>> listSubagents()
    • listWorkspaces

      default reactor.core.publisher.Mono<List<Inventory.WorkspaceInfo>> listWorkspaces()
    • listTasks

      default reactor.core.publisher.Mono<List<Map<String,Object>>> listTasks(String sessionId)
      Session task list for GET .../tasks. Each map follows the frozen Task shape: id, subject, state, owner, blockedBy, updatedAt, frameworkMeta.
    • listSubagentTasks

      default reactor.core.publisher.Mono<List<Map<String,Object>>> listSubagentTasks(String sessionId)
      Background subagent tasks for GET .../subagent-tasks (not todolist). Each map is framework-shaped; typical keys: id, status, subject/label.
    • cancelSubagentTask

      default reactor.core.publisher.Mono<Void> cancelSubagentTask(String sessionId, String taskId)
      Cancel one background subagent task. Capability: subagent-task-command.
    • setPlanMode

      default reactor.core.publisher.Mono<Void> setPlanMode(String sessionId, byte[] params)
      Enter or exit plan mode for the session. Capability: plan-mode. params is a JSON object with "active": true|false.
    • injectUserMessage

      default reactor.core.publisher.Mono<Void> injectUserMessage(String sessionId, String content)
      Inject a console/control-plane user message into the live session. Must use the framework's official continue-turn API.
    • runConversationTurn

      default reactor.core.publisher.Mono<String> runConversationTurn(String sessionId, String content)
      Run a control-plane conversation turn and return its terminal assistant reply. Unlike message injection, completion must carry the answer, not just acknowledge input.
    • buildAgentConfig

      default Map<String,Object> buildAgentConfig()
      Effective Definition snapshot for GET /agentscope/info → agentConfig.
    • handleCommand

      default reactor.core.publisher.Mono<Void> handleCommand(String sessionId, String command, byte[] params)
      Executes COMMAND_COMPRESS, COMMAND_TERMINATE, or COMMAND_ABORT against the session.
    • handleAgentTask

      default reactor.core.publisher.Mono<Void> handleAgentTask(AgentTaskAssignment assignment)
      Materializes a downstream AgentTask delivery as an isolated execution.
    • capabilities

      default Set<String> capabilities()
      Capabilities contributed by this adapter. Push-side capabilities (session-reporting, event-reporting, context-reporting) are added by the bridge.