Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions core/src/main/java/com/google/adk/apps/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.google.adk.apps;

import com.google.adk.agents.BaseAgent;
import com.google.adk.plugins.BasePlugin;
import com.google.adk.plugins.Plugin;
import com.google.adk.summarizer.EventsCompactionConfig;
import com.google.common.collect.ImmutableList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
Expand All @@ -38,14 +38,14 @@ public class App {

private final String name;
private final BaseAgent rootAgent;
private final ImmutableList<BasePlugin> plugins;
private final ImmutableList<? extends Plugin> plugins;
@Nullable private final EventsCompactionConfig eventsCompactionConfig;
@Nullable private final ResumabilityConfig resumabilityConfig;

private App(
String name,
BaseAgent rootAgent,
List<BasePlugin> plugins,
List<? extends Plugin> plugins,
@Nullable EventsCompactionConfig eventsCompactionConfig,
@Nullable ResumabilityConfig resumabilityConfig) {
this.name = name;
Expand All @@ -63,7 +63,7 @@ public BaseAgent rootAgent() {
return rootAgent;
}

public ImmutableList<BasePlugin> plugins() {
public ImmutableList<? extends Plugin> plugins() {
return plugins;
}

Expand All @@ -81,7 +81,7 @@ public ResumabilityConfig resumabilityConfig() {
public static class Builder {
private String name;
private BaseAgent rootAgent;
private List<BasePlugin> plugins = ImmutableList.of();
private List<? extends Plugin> plugins = ImmutableList.of();
@Nullable private EventsCompactionConfig eventsCompactionConfig;
@Nullable private ResumabilityConfig resumabilityConfig;

Expand All @@ -98,7 +98,7 @@ public Builder rootAgent(BaseAgent rootAgent) {
}

@CanIgnoreReturnValue
public Builder plugins(List<BasePlugin> plugins) {
public Builder plugins(List<? extends Plugin> plugins) {
this.plugins = plugins;
return this;
}
Expand Down
15 changes: 4 additions & 11 deletions core/src/main/java/com/google/adk/plugins/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,21 @@
* <p>The PluginManager is an internal class that orchestrates the invocation of plugin callbacks at
* key points in the SDK's execution lifecycle.
*/
public class PluginManager implements Plugin {
public class PluginManager extends BasePlugin {
private static final Logger logger = LoggerFactory.getLogger(PluginManager.class);
private final List<Plugin> plugins;
private final List<Plugin> plugins = new ArrayList<>();

public PluginManager(List<? extends Plugin> plugins) {
this.plugins = new ArrayList<>();
super("PluginManager");
if (plugins != null) {
for (var plugin : plugins) {
this.registerPlugin(plugin);
}
plugins.forEach(this::registerPlugin);
}
}

public PluginManager() {
this(null);
}

@Override
public String getName() {
return "PluginManager";
}

/**
* Registers a new plugin.
*
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/com/google/adk/runner/InMemoryRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.google.adk.agents.BaseAgent;
import com.google.adk.artifacts.InMemoryArtifactService;
import com.google.adk.memory.InMemoryMemoryService;
import com.google.adk.plugins.BasePlugin;
import com.google.adk.plugins.Plugin;
import com.google.adk.sessions.InMemorySessionService;
import com.google.common.collect.ImmutableList;
import java.util.List;
Expand All @@ -37,7 +37,7 @@ public InMemoryRunner(BaseAgent agent, String appName) {
this(agent, appName, ImmutableList.of());
}

public InMemoryRunner(BaseAgent agent, String appName, List<BasePlugin> plugins) {
public InMemoryRunner(BaseAgent agent, String appName, List<? extends Plugin> plugins) {
super(
agent,
appName,
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/java/com/google/adk/runner/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.google.adk.events.EventActions;
import com.google.adk.memory.BaseMemoryService;
import com.google.adk.models.Model;
import com.google.adk.plugins.BasePlugin;
import com.google.adk.plugins.Plugin;
import com.google.adk.plugins.PluginManager;
import com.google.adk.sessions.BaseSessionService;
import com.google.adk.sessions.InMemorySessionService;
Expand Down Expand Up @@ -84,7 +84,7 @@ public static class Builder {
private BaseArtifactService artifactService = new InMemoryArtifactService();
private BaseSessionService sessionService = new InMemorySessionService();
@Nullable private BaseMemoryService memoryService = null;
private List<BasePlugin> plugins = ImmutableList.of();
private List<? extends Plugin> plugins = ImmutableList.of();

@CanIgnoreReturnValue
public Builder app(App app) {
Expand Down Expand Up @@ -126,7 +126,7 @@ public Builder memoryService(BaseMemoryService memoryService) {
}

@CanIgnoreReturnValue
public Builder plugins(List<BasePlugin> plugins) {
public Builder plugins(List<? extends Plugin> plugins) {
Preconditions.checkState(this.app == null, "plugins() cannot be called when app is set.");
this.plugins = plugins;
return this;
Expand All @@ -135,7 +135,7 @@ public Builder plugins(List<BasePlugin> plugins) {
public Runner build() {
BaseAgent buildAgent;
String buildAppName;
List<BasePlugin> buildPlugins;
List<? extends Plugin> buildPlugins;
ResumabilityConfig buildResumabilityConfig;
EventsCompactionConfig buildEventsCompactionConfig;

Expand Down Expand Up @@ -224,7 +224,7 @@ public Runner(
BaseArtifactService artifactService,
BaseSessionService sessionService,
@Nullable BaseMemoryService memoryService,
List<BasePlugin> plugins) {
List<? extends Plugin> plugins) {
this(
agent,
appName,
Expand All @@ -247,7 +247,7 @@ public Runner(
BaseArtifactService artifactService,
BaseSessionService sessionService,
@Nullable BaseMemoryService memoryService,
List<BasePlugin> plugins,
List<? extends Plugin> plugins,
ResumabilityConfig resumabilityConfig) {
this(
agent,
Expand All @@ -272,7 +272,7 @@ protected Runner(
BaseArtifactService artifactService,
BaseSessionService sessionService,
@Nullable BaseMemoryService memoryService,
List<BasePlugin> plugins,
List<? extends Plugin> plugins,
ResumabilityConfig resumabilityConfig,
@Nullable EventsCompactionConfig eventsCompactionConfig) {
this.agent = agent;
Expand Down